From 73643c60a644145c6a57b61787efd6a62e153cfa Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 4 Jun 2019 10:50:10 +0200 Subject: [PATCH] Update to Electron 4.0.x (#73119) * Bump electron@4.0.0-beta.9 * electron 4 - temporarily warn about exploration change * update to Electron 4.0.0 stable * remove electron 4 notification * bump to electron@4.0.1 * electron 4: adopt format change of "version" file * build - set to use exploration image * Revert "build - set to use exploration image" This reverts commit 1bb280fc5e96a4cf5a5acf1fc4f77e8a864ed5c6. * electron@4.0.2 * fix electron.d.ts * update distro * bump electron@4.0.4 * debt - adopt new process.getProcessMemoryInfo() * update electron@4.0.5 * electron@4.0.6 * electron 4.0.x - remove Linux 32bit build * electron@4.0.7 * electron - update to 4.1.2 * bump electron@4.1.4 * update build (remove Linux32) * electron@4.1.5 * electron 4 - remove linux 32bit warning * Remove more 32-bit Linux build stuff Fixes #66271 * electron@4.2.0 * electron@4.2.1 * electron@4.2.2 * electron@4.2.3 * Revert "electron@4.2.3" This reverts commit ae375ef764a13ccffbec1fdef15926d814d90872. * Revert "Revert "electron@4.2.3"" This reverts commit 513581ebc59bfa1af574ea40d61974492b0db64f. --- .yarnrc | 2 +- build/azure-pipelines/common/symbols.ts | 3 +- .../linux/product-build-linux.yml | 3 - build/azure-pipelines/linux/publish.sh | 6 +- build/azure-pipelines/product-build.yml | 14 - build/gulpfile.vscode.linux.js | 5 +- build/lib/electron.js | 2 +- cgmanifest.json | 25 +- package.json | 2 +- resources/linux/rpm/dependencies.json | 78 -- src/typings/electron.d.ts | 1059 +++++++++++++---- src/vs/platform/product/node/product.ts | 1 - .../electron-browser/perfviewEditor.ts | 2 +- .../electron-browser/update.contribution.ts | 9 +- .../contrib/update/electron-browser/update.ts | 47 - .../timer/electron-browser/timerService.ts | 10 +- test/smoke/package.json | 2 +- test/smoke/yarn.lock | 18 +- yarn.lock | 8 +- 19 files changed, 832 insertions(+), 464 deletions(-) diff --git a/.yarnrc b/.yarnrc index beab9f70b95..7e63643de04 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1,3 +1,3 @@ disturl "https://atom.io/download/electron" -target "3.1.8" +target "4.2.3" runtime "electron" diff --git a/build/azure-pipelines/common/symbols.ts b/build/azure-pipelines/common/symbols.ts index 1a5125295f3..a42342ce7f7 100644 --- a/build/azure-pipelines/common/symbols.ts +++ b/build/azure-pipelines/common/symbols.ts @@ -36,7 +36,6 @@ export interface IVersionAccessor extends IApplicationAccessor { enum Platform { WIN_32 = 'win32-ia32', WIN_64 = 'win32-x64', - LINUX_32 = 'linux-ia32', LINUX_64 = 'linux-x64', MAC_OS = 'darwin-x64' } @@ -191,7 +190,7 @@ if (process.platform === 'darwin') { } else if (process.platform === 'win32') { platform = is64 ? Platform.WIN_64 : Platform.WIN_32; } else { - platform = is64 ? Platform.LINUX_64 : Platform.LINUX_32; + platform = Platform.LINUX_64; } // Create version and upload symbols in HockeyApp diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 5ea5de8ade1..c1386b93f71 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -16,9 +16,6 @@ steps: - script: | set -e export npm_config_arch="$(VSCODE_ARCH)" - if [[ "$(VSCODE_ARCH)" == "ia32" ]]; then - export PKG_CONFIG_PATH="/usr/lib/i386-linux-gnu/pkgconfig" - fi cat << EOF > ~/.netrc machine monacotools.visualstudio.com diff --git a/build/azure-pipelines/linux/publish.sh b/build/azure-pipelines/linux/publish.sh index 0f864600bd3..a6b48389d58 100755 --- a/build/azure-pipelines/linux/publish.sh +++ b/build/azure-pipelines/linux/publish.sh @@ -5,8 +5,6 @@ ROOT="$REPO/.." # Publish tarball PLATFORM_LINUX="linux-$VSCODE_ARCH" -[[ "$VSCODE_ARCH" == "ia32" ]] && DEB_ARCH="i386" || DEB_ARCH="amd64" -[[ "$VSCODE_ARCH" == "ia32" ]] && RPM_ARCH="i386" || RPM_ARCH="x86_64" BUILDNAME="VSCode-$PLATFORM_LINUX" BUILD="$ROOT/$BUILDNAME" BUILD_VERSION="$(date +%s)" @@ -39,7 +37,7 @@ node build/azure-pipelines/common/symbols.js "$VSCODE_MIXIN_PASSWORD" "$VSCODE_H # Publish DEB yarn gulp "vscode-linux-$VSCODE_ARCH-build-deb" PLATFORM_DEB="linux-deb-$VSCODE_ARCH" -[[ "$VSCODE_ARCH" == "ia32" ]] && DEB_ARCH="i386" || DEB_ARCH="amd64" +DEB_ARCH="amd64" DEB_FILENAME="$(ls $REPO/.build/linux/deb/$DEB_ARCH/deb/)" DEB_PATH="$REPO/.build/linux/deb/$DEB_ARCH/deb/$DEB_FILENAME" @@ -48,7 +46,7 @@ node build/azure-pipelines/common/publish.js "$VSCODE_QUALITY" "$PLATFORM_DEB" p # Publish RPM yarn gulp "vscode-linux-$VSCODE_ARCH-build-rpm" PLATFORM_RPM="linux-rpm-$VSCODE_ARCH" -[[ "$VSCODE_ARCH" == "ia32" ]] && RPM_ARCH="i386" || RPM_ARCH="x86_64" +RPM_ARCH="x86_64" RPM_FILENAME="$(ls $REPO/.build/linux/rpm/$RPM_ARCH/ | grep .rpm)" RPM_PATH="$REPO/.build/linux/rpm/$RPM_ARCH/$RPM_FILENAME" diff --git a/build/azure-pipelines/product-build.yml b/build/azure-pipelines/product-build.yml index 8b013cb9211..ac9ce03b593 100644 --- a/build/azure-pipelines/product-build.yml +++ b/build/azure-pipelines/product-build.yml @@ -3,9 +3,6 @@ resources: - container: vscode-x64 image: vscodehub.azurecr.io/vscode-linux-build-agent:x64 endpoint: VSCodeHub - - container: vscode-ia32 - image: vscodehub.azurecr.io/vscode-linux-build-agent:ia32 - endpoint: VSCodeHub - container: snapcraft image: snapcore/snapcraft @@ -49,16 +46,6 @@ jobs: steps: - template: linux/snap-build-linux.yml -- job: Linux32 - condition: eq(variables['VSCODE_BUILD_LINUX_32BIT'], 'true') - pool: - vmImage: 'Ubuntu-16.04' - variables: - VSCODE_ARCH: ia32 - container: vscode-ia32 - steps: - - template: linux/product-build-linux.yml - - job: LinuxArmhf condition: eq(variables['VSCODE_BUILD_LINUX_ARMHF'], 'true') pool: @@ -84,7 +71,6 @@ jobs: - Windows32 - Linux - LinuxSnap - - Linux32 - LinuxArmhf - macOS steps: diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index 9b0abd18d9a..a718cfb0082 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -23,7 +23,7 @@ const commit = util.getVersion(root); const linuxPackageRevision = Math.floor(new Date().getTime() / 1000); function getDebPackageArch(arch) { - return { x64: 'amd64', ia32: 'i386', arm: 'armhf', arm64: "arm64" }[arch]; + return { x64: 'amd64', arm: 'armhf', arm64: "arm64" }[arch]; } function prepareDebPackage(arch) { @@ -114,7 +114,7 @@ function getRpmBuildPath(rpmArch) { } function getRpmPackageArch(arch) { - return { x64: 'x86_64', ia32: 'i386', arm: 'armhf', arm64: "arm64" }[arch]; + return { x64: 'x86_64', arm: 'armhf', arm64: "arm64" }[arch]; } function prepareRpmPackage(arch) { @@ -238,7 +238,6 @@ function buildSnapPackage(arch) { } const BUILD_TARGETS = [ - { arch: 'ia32' }, { arch: 'x64' }, { arch: 'arm' }, { arch: 'arm64' }, diff --git a/build/lib/electron.js b/build/lib/electron.js index 6387133675b..63e867a98fe 100644 --- a/build/lib/electron.js +++ b/build/lib/electron.js @@ -24,7 +24,7 @@ module.exports.getElectronVersion = getElectronVersion; if (require.main === module) { const version = getElectronVersion(); const versionFile = path.join(root, '.build', 'electron', 'version'); - const isUpToDate = fs.existsSync(versionFile) && fs.readFileSync(versionFile, 'utf8') === `v${version}`; + const isUpToDate = fs.existsSync(versionFile) && fs.readFileSync(versionFile, 'utf8') === `${version}`; process.exit(isUpToDate ? 0 : 1); } diff --git a/cgmanifest.json b/cgmanifest.json index 406060f8a7a..6cebbffd6b9 100644 --- a/cgmanifest.json +++ b/cgmanifest.json @@ -6,7 +6,7 @@ "git": { "name": "chromium", "repositoryUrl": "https://chromium.googlesource.com/chromium/src", - "commitHash": "164c37e3f235134c88e80fac2a182cfba3f07f00" + "commitHash": "c6a08e5368de4352903e702cde750b33239a50ab" } }, "licenseDetail": [ @@ -40,20 +40,7 @@ "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ], "isOnlyProductionDependency": true, - "version": "66.0.3359.181" - }, - { - "component": { - "type": "git", - "git": { - "name": "libchromiumcontent", - "repositoryUrl": "https://github.com/electron/libchromiumcontent", - "commitHash": "7ea271f92018b1eeb8e70ec6de8c29f9758a0c05" - } - }, - "isOnlyProductionDependency": true, - "license": "MIT", - "version": "66.0.3359.181" + "version": "69.0.3497.128" }, { "component": { @@ -61,11 +48,11 @@ "git": { "name": "nodejs", "repositoryUrl": "https://github.com/nodejs/node", - "commitHash": "5cbb905c1af7cea2d709932d59827d7c6d03ef4a" + "commitHash": "8c70b2084ce5f76ea1e3b3c4ccdeee4483fe338b" } }, "isOnlyProductionDependency": true, - "version": "10.2.0" + "version": "10.11.0" }, { "component": { @@ -73,12 +60,12 @@ "git": { "name": "electron", "repositoryUrl": "https://github.com/electron/electron", - "commitHash": "e84a6860e35e14b4031b88bb9b49841cdb89a305" + "commitHash": "c1b5a1cfc8a14a337540193daecfa5d0f50dd7bb" } }, "isOnlyProductionDependency": true, "license": "MIT", - "version": "3.1.8" + "version": "4.2.3" }, { "component": { diff --git a/package.json b/package.json index f316ff148a6..04d1b3739b9 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "v8-inspect-profiler": "^0.0.20", "vscode-chokidar": "1.6.5", "vscode-debugprotocol": "1.35.0", - "vscode-nsfw": "1.1.1", + "vscode-nsfw": "1.1.2", "vscode-proxy-agent": "0.4.0", "vscode-ripgrep": "^1.2.5", "vscode-sqlite3": "4.0.7", diff --git a/resources/linux/rpm/dependencies.json b/resources/linux/rpm/dependencies.json index d0b64c4fa68..34f127e1ae5 100644 --- a/resources/linux/rpm/dependencies.json +++ b/resources/linux/rpm/dependencies.json @@ -63,83 +63,5 @@ "libxcb.so.1()(64bit)", "libxkbfile.so.1()(64bit)", "libsecret-1.so.0()(64bit)" - ], - "i386": [ - "ld-linux.so.2", - "ld-linux.so.2(GLIBC_2.1)", - "libX11-xcb.so.1", - "libX11.so.6", - "libXcomposite.so.1", - "libXcursor.so.1", - "libXdamage.so.1", - "libXext.so.6", - "libXfixes.so.3", - "libXi.so.6", - "libXrandr.so.2", - "libXrender.so.1", - "libXss.so.1", - "libXtst.so.6", - "libasound.so.2", - "libatk-1.0.so.0", - "libc.so.6", - "libc.so.6(GLIBC_2.0)", - "libc.so.6(GLIBC_2.1)", - "libc.so.6(GLIBC_2.1.3)", - "libc.so.6(GLIBC_2.11)", - "libc.so.6(GLIBC_2.2)", - "libc.so.6(GLIBC_2.2.3)", - "libc.so.6(GLIBC_2.3)", - "libc.so.6(GLIBC_2.3.2)", - "libc.so.6(GLIBC_2.3.4)", - "libc.so.6(GLIBC_2.4)", - "libc.so.6(GLIBC_2.6)", - "libc.so.6(GLIBC_2.7)", - "libcairo.so.2", - "libcups.so.2", - "libdbus-1.so.3", - "libdl.so.2", - "libdl.so.2(GLIBC_2.0)", - "libdl.so.2(GLIBC_2.1)", - "libexpat.so.1", - "libfontconfig.so.1", - "libfreetype.so.6", - "libgcc_s.so.1", - "libgcc_s.so.1(GCC_4.0.0)", - "libgcc_s.so.1(GLIBC_2.0)", - "libgdk-x11-2.0.so.0", - "libgdk_pixbuf-2.0.so.0", - "libgio-2.0.so.0", - "libglib-2.0.so.0", - "libgmodule-2.0.so.0", - "libgobject-2.0.so.0", - "libgtk-3.so.0", - "libm.so.6", - "libm.so.6(GLIBC_2.0)", - "libm.so.6(GLIBC_2.1)", - "libnspr4.so", - "libnss3.so", - "libnssutil3.so", - "libpango-1.0.so.0", - "libpangocairo-1.0.so.0", - "libpthread.so.0", - "libpthread.so.0(GLIBC_2.0)", - "libpthread.so.0(GLIBC_2.1)", - "libpthread.so.0(GLIBC_2.2)", - "libpthread.so.0(GLIBC_2.2.3)", - "libpthread.so.0(GLIBC_2.3.2)", - "libpthread.so.0(GLIBC_2.3.3)", - "librt.so.1", - "librt.so.1(GLIBC_2.2)", - "libsmime3.so", - "libstdc++.so.6", - "libstdc++.so.6(GLIBCXX_3.4)", - "libstdc++.so.6(GLIBCXX_3.4.10)", - "libstdc++.so.6(GLIBCXX_3.4.11)", - "libstdc++.so.6(GLIBCXX_3.4.14)", - "libstdc++.so.6(GLIBCXX_3.4.15)", - "libstdc++.so.6(GLIBCXX_3.4.9)", - "libxcb.so.1", - "libxkbfile.so.1", - "libsecret-1.so.0" ] } \ No newline at end of file diff --git a/src/typings/electron.d.ts b/src/typings/electron.d.ts index 20e58bcd730..59163a017cc 100644 --- a/src/typings/electron.d.ts +++ b/src/typings/electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron 3.1.8 +// Type definitions for Electron 4.2.3 // Project: http://electronjs.org/ // Definitions by: The Electron Team // Definitions: https://github.com/electron/electron-typescript-definitions @@ -86,7 +86,7 @@ declare namespace Electron { webviewTag: WebviewTag; } - interface AllElectron extends MainInterface, RendererInterface {} + interface AllElectron extends MainInterface, RendererInterface { } const app: App; const autoUpdater: AutoUpdater; @@ -119,7 +119,7 @@ declare namespace Electron { interface App extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/app + // Docs: http://electronjs.org/docs/api/app /** * Emitted when Chrome's accessibility support changes. This event fires when @@ -472,6 +472,100 @@ declare namespace Electron { once(event: 'ready', listener: (launchInfo: any) => void): this; addListener(event: 'ready', listener: (launchInfo: any) => void): this; removeListener(event: 'ready', listener: (launchInfo: any) => void): this; + /** + * Emitted when remote.getBuiltin() is called in the renderer process of + * webContents. Calling event.preventDefault() will prevent the module from being + * returned. Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + once(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + addListener(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + removeListener(event: 'remote-get-builtin', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + /** + * Emitted when remote.getCurrentWebContents() is called in the renderer process of + * webContents. Calling event.preventDefault() will prevent the object from being + * returned. Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'remote-get-current-web-contents', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted when remote.getCurrentWindow() is called in the renderer process of + * webContents. Calling event.preventDefault() will prevent the object from being + * returned. Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + once(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + addListener(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + removeListener(event: 'remote-get-current-window', listener: (event: Event, + webContents: WebContents) => void): this; + /** + * Emitted when remote.getGlobal() is called in the renderer process of + * webContents. Calling event.preventDefault() will prevent the global from being + * returned. Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + once(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + addListener(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + removeListener(event: 'remote-get-global', listener: (event: Event, + webContents: WebContents, + globalName: string) => void): this; + /** + * Emitted when .getWebContents() is called in the renderer process of + * webContents. Calling event.preventDefault() will prevent the object from being + * returned. Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-guest-web-contents', listener: (event: Event, + webContents: WebContents, + guestWebContents: WebContents) => void): this; + once(event: 'remote-get-guest-web-contents', listener: (event: Event, + webContents: WebContents, + guestWebContents: WebContents) => void): this; + addListener(event: 'remote-get-guest-web-contents', listener: (event: Event, + webContents: WebContents, + guestWebContents: WebContents) => void): this; + removeListener(event: 'remote-get-guest-web-contents', listener: (event: Event, + webContents: WebContents, + guestWebContents: WebContents) => void): this; + /** + * Emitted when remote.require() is called in the renderer process of webContents. + * Calling event.preventDefault() will prevent the module from being returned. + * Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + once(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + addListener(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; + removeListener(event: 'remote-require', listener: (event: Event, + webContents: WebContents, + moduleName: string) => void): this; /** * This event will be emitted inside the primary instance of your application when * a second instance has been executed. argv is an Array of the second instance's @@ -690,6 +784,11 @@ declare namespace Electron { * is ready. */ enableMixedSandbox(): void; + /** + * Enables full sandbox mode on the app. This method can only be called before app + * is ready. + */ + enableSandbox(): void; /** * Exits immediately with exitCode. exitCode defaults to 0. All windows will be * closed immediately without asking user and the before-quit and will-quit events @@ -709,13 +808,22 @@ declare namespace Electron { * Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux * and macOS, icons depend on the application associated with file mime type. */ - getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void; + getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void; /** * Fetches a path's associated icon. On Windows, there a 2 kinds of icons: On Linux * and macOS, icons depend on the application associated with file mime type. */ - getFileIcon(path: string, callback: (error: Error, icon: NativeImage) => void): void; + getFileIcon(path: string, options: FileIconOptions, callback: (error: Error, icon: NativeImage) => void): void; getGPUFeatureStatus(): GPUFeatureStatus; + /** + * For infoType equal to complete: Promise is fulfilled with Object containing all + * the GPU Information as in chromium's GPUInfo object. This includes the version + * and driver information that's shown on chrome://gpu page. For infoType equal to + * basic: Promise is fulfilled with Object containing fewer attributes than when + * requested with complete. Here's an example of basic response: Using basic should + * be preferred if only basic information like vendorId or driverId is needed. + */ + getGPUInfo(infoType: string): Promise; getJumpListSettings(): JumpListSettings; /** * To set the locale, you'll want to use a command line switch at app startup, @@ -754,7 +862,7 @@ declare namespace Electron { /** * Imports the certificate in pkcs12 format into the platform certificate store. * callback is called with the result of import operation, a value of 0 indicates - * success while any other value indicates failure according to chromium + * success while any other value indicates failure according to Chromium * net_error_list. */ importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void; @@ -843,9 +951,9 @@ declare namespace Electron { setAboutPanelOptions(options: AboutPanelOptionsOptions): void; /** * Manually enables Chrome's accessibility support, allowing to expose - * accessibility switch to users in application settings. - * https://www.chromium.org/developers/design-documents/accessibility for more - * details. Disabled by default. Note: Rendering accessibility tree can + * accessibility switch to users in application settings. See Chromium's + * accessibility docs for more details. Disabled by default. This API must be + * called after the ready event is emitted. Note: Rendering accessibility tree can * significantly affect the performance of your app. It should not be enabled by * default. */ @@ -929,7 +1037,12 @@ declare namespace Electron { */ show(): void; /** - * Start accessing a security scoped resource. With this method electron + * Show the about panel with the values defined in the app's .plist file or with + * the options set via app.setAboutPanelOptions(options). + */ + showAboutPanel(): void; + /** + * Start accessing a security scoped resource. With this method Electron * applications that are packaged for the Mac App Store may reach outside their * sandbox to access files chosen by the user. See Apple's documentation for a * description of how this system works. @@ -940,7 +1053,7 @@ declare namespace Electron { * userInfo into its current userInfo dictionary. */ updateCurrentActivity(type: string, userInfo: any): void; - whenReady(): Promise; + whenReady(): Promise; commandLine: CommandLine; dock: Dock; /** @@ -949,11 +1062,19 @@ declare namespace Electron { * production environments. */ isPackaged?: boolean; + /** + * A String which is the user agent string Electron will use as a global fallback. + * This is the user agent that will be used when no user agent is set at the + * webContents or session level. Useful for ensuring your entire app has the same + * user agent. Set to a custom value as early as possible in your apps + * initialization to ensure that your overridden value is used. + */ + userAgentFallback?: string; } interface AutoUpdater extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/auto-updater + // Docs: http://electronjs.org/docs/api/auto-updater /** * This event is emitted after a user calls quitAndInstall(). When this API is @@ -990,7 +1111,9 @@ declare namespace Electron { removeListener(event: 'update-available', listener: Function): this; /** * Emitted when an update has been downloaded. On Windows only releaseName is - * available. + * available. Note: It is not strictly necessary to handle this event. A + * successfully downloaded update will still be applied the next time the + * application starts. */ on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, @@ -1029,10 +1152,10 @@ declare namespace Electron { * Restarts the app and installs the update after it has been downloaded. It should * only be called after update-downloaded has been emitted. Under the hood calling * autoUpdater.quitAndInstall() will close all application windows first, and - * automatically call app.quit() after all windows have been closed. Note: If the - * application is quit without calling this API after the update-downloaded event - * has been emitted, the application will still be replaced by the updated one on - * the next run. + * automatically call app.quit() after all windows have been closed. Note: It is + * not strictly necessary to call this function to apply an update, as a + * successfully downloaded update will always be applied the next time the + * application starts. */ quitAndInstall(): void; /** @@ -1043,7 +1166,7 @@ declare namespace Electron { interface BluetoothDevice { - // Docs: http://electron.atom.io/docs/api/structures/bluetooth-device + // Docs: http://electronjs.org/docs/api/structures/bluetooth-device deviceId: string; deviceName: string; @@ -1051,11 +1174,11 @@ declare namespace Electron { class BrowserView extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/browser-view + // Docs: http://electronjs.org/docs/api/browser-view constructor(options?: BrowserViewConstructorOptions); static fromId(id: number): BrowserView; - static fromWebContents(webContents: WebContents): BrowserView | null; + static fromWebContents(webContents: WebContents): (BrowserView) | (null); static getAllViews(): BrowserView[]; /** * Force closing the view, the unload and beforeunload events won't be emitted for @@ -1076,8 +1199,19 @@ declare namespace Electron { class BrowserWindow extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/browser-window + // Docs: http://electronjs.org/docs/api/browser-window + /** + * Emitted when the window is set or unset to show always on top of other windows. + */ + on(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + once(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + addListener(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; + removeListener(event: 'always-on-top-changed', listener: (event: Event, + isAlwaysOnTop: boolean) => void): this; /** * Emitted when an App Command is invoked. These are typically related to keyboard * media keys or browser commands, as well as the "Back" button built into some @@ -1207,13 +1341,13 @@ declare namespace Electron { * prevent the native window's title from changing. */ on(event: 'page-title-updated', listener: (event: Event, - title: string) => void): this; + title: string, explicitSet: boolean) => void): this; once(event: 'page-title-updated', listener: (event: Event, - title: string) => void): this; + title: string, explicitSet: boolean) => void): this; addListener(event: 'page-title-updated', listener: (event: Event, - title: string) => void): this; + title: string, explicitSet: boolean) => void): this; removeListener(event: 'page-title-updated', listener: (event: Event, - title: string) => void): this; + title: string, explicitSet: boolean) => void): this; /** * Emitted when the web page has been rendered (while not being shown) and window * can be displayed without a visual flash. @@ -1223,7 +1357,7 @@ declare namespace Electron { addListener(event: 'ready-to-show', listener: Function): this; removeListener(event: 'ready-to-show', listener: Function): this; /** - * Emitted when the window is being resized. + * Emitted after the window has been resized. */ on(event: 'resize', listener: Function): this; once(event: 'resize', listener: Function): this; @@ -1318,6 +1452,58 @@ declare namespace Electron { once(event: 'unresponsive', listener: Function): this; addListener(event: 'unresponsive', listener: Function): this; removeListener(event: 'unresponsive', listener: Function): this; + /** + * Emitted before the window is moved. Calling event.preventDefault() will prevent + * the window from being moved. Note that this is only emitted when the window is + * being resized manually. Resizing the window with setBounds/setSize will not emit + * this event. + */ + on(event: 'will-move', listener: (event: Event, + /** + * ` Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + once(event: 'will-move', listener: (event: Event, + /** + * ` Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + addListener(event: 'will-move', listener: (event: Event, + /** + * ` Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + removeListener(event: 'will-move', listener: (event: Event, + /** + * ` Location the window is being moved to. + */ + newBounds: Rectangle) => void): this; + /** + * Emitted before the window is resized. Calling event.preventDefault() will + * prevent the window from being resized. Note that this is only emitted when the + * window is being resized manually. Resizing the window with setBounds/setSize + * will not emit this event. + */ + on(event: 'will-resize', listener: (event: Event, + /** + * ` Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + once(event: 'will-resize', listener: (event: Event, + /** + * ` Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + addListener(event: 'will-resize', listener: (event: Event, + /** + * ` Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; + removeListener(event: 'will-resize', listener: (event: Event, + /** + * ` Size the window is being resized to. + */ + newBounds: Rectangle) => void): this; constructor(options?: BrowserWindowConstructorOptions); /** * Adds DevTools extension located at path, and returns extension's name. The @@ -1335,7 +1521,7 @@ declare namespace Electron { * This API cannot be called before the ready event of the app module is emitted. */ static addExtension(path: string): void; - static fromBrowserView(browserView: BrowserView): BrowserWindow | null; + static fromBrowserView(browserView: BrowserView): (BrowserWindow) | (null); static fromId(id: number): BrowserWindow; static fromWebContents(webContents: WebContents): BrowserWindow; static getAllWindows(): BrowserWindow[]; @@ -1349,7 +1535,7 @@ declare namespace Electron { * emitted. */ static getExtensions(): Extensions; - static getFocusedWindow(): BrowserWindow | null; + static getFocusedWindow(): (BrowserWindow) | (null); /** * Remove a DevTools extension by name. Note: This API cannot be called before the * ready event of the app module is emitted. @@ -1411,7 +1597,7 @@ declare namespace Electron { * Note: The BrowserView API is currently experimental and may change or be removed * in future Electron releases. */ - getBrowserView(): BrowserView | null; + getBrowserView(): (BrowserView) | (null); getChildWindows(): BrowserWindow[]; getContentBounds(): Rectangle; getContentSize(): number[]; @@ -1422,6 +1608,13 @@ declare namespace Electron { * (unsigned long) on Linux. */ getNativeWindowHandle(): Buffer; + /** + * Note: whatever the current state of the window : maximized, minimized or in + * fullscreen, this function always returns the position and size of the window in + * normal state. In normal state, getBounds and getNormalBounds returns the same + * Rectangle. + */ + getNormalBounds(): Rectangle; getOpacity(): number; getParentWindow(): BrowserWindow; getPosition(): number[]; @@ -1473,6 +1666,7 @@ declare namespace Electron { * On Linux always returns true. */ isMovable(): boolean; + isNormal(): boolean; isResizable(): boolean; isSimpleFullScreen(): boolean; isVisible(): boolean; @@ -1485,7 +1679,7 @@ declare namespace Electron { * Same as webContents.loadFile, filePath should be a path to an HTML file relative * to the root of your application. See the webContents docs for more information. */ - loadFile(filePath: string): void; + loadFile(filePath: string, options?: LoadFileOptions): void; /** * Same as webContents.loadURL(url[, options]). The url can be a remote address * (e.g. http://) or a path to a local HTML file using the file:// protocol. To @@ -1579,7 +1773,12 @@ declare namespace Electron { */ setAutoHideMenuBar(hide: boolean): void; /** - * Resizes and moves the window to the supplied bounds + * Sets the background color of the window. See Setting backgroundColor. + */ + setBackgroundColor(backgroundColor: string): void; + /** + * Resizes and moves the window to the supplied bounds. Any properties that are not + * supplied will default to their current values. */ setBounds(bounds: Rectangle, animate?: boolean): void; setBrowserView(browserView: BrowserView): void; @@ -1655,7 +1854,7 @@ declare namespace Electron { * Sets the menu as the window's menu bar, setting it to null will remove the menu * bar. */ - setMenu(menu: Menu | null): void; + setMenu(menu: (Menu) | (null)): void; /** * Sets whether the menu bar should be visible. If the menu bar is auto-hide, users * can still bring up the menu bar by pressing the single Alt key. @@ -1682,7 +1881,7 @@ declare namespace Electron { * Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to * convey some sort of application status or to passively notify the user. */ - setOverlayIcon(overlay: NativeImage | null, description: string): void; + setOverlayIcon(overlay: (NativeImage) | (null), description: string): void; /** * Sets parent as current window's parent window, passing null will turn current * window into a top-level window. @@ -1754,7 +1953,8 @@ declare namespace Electron { /** * Sets the region of the window to show as the thumbnail image displayed when * hovering over the window in the taskbar. You can reset the thumbnail to be the - * entire window by specifying an empty region: {x: 0, y: 0, width: 0, height: 0}. + * entire window by specifying an empty region: { x: 0, y: 0, width: 0, height: 0 + * }. */ setThumbnailClip(region: Rectangle): void; /** @@ -1782,7 +1982,12 @@ declare namespace Electron { * Sets whether the window should be visible on all workspaces. Note: This API does * nothing on Windows. */ - setVisibleOnAllWorkspaces(visible: boolean): void; + setVisibleOnAllWorkspaces(visible: boolean, options?: VisibleOnAllWorkspacesOptions): void; + /** + * Sets whether the window traffic light buttons should be visible. This cannot be + * called when titleBarStyle is set to customButtonsOnHover. + */ + setWindowButtonVisibility(visible: boolean): void; /** * Shows and gives focus to the window. */ @@ -1818,7 +2023,7 @@ declare namespace Electron { class BrowserWindowProxy extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/browser-window-proxy + // Docs: http://electronjs.org/docs/api/browser-window-proxy /** * Removes focus from the child window. @@ -1851,7 +2056,7 @@ declare namespace Electron { interface Certificate { - // Docs: http://electron.atom.io/docs/api/structures/certificate + // Docs: http://electronjs.org/docs/api/structures/certificate /** * PEM encoded data @@ -1897,37 +2102,37 @@ declare namespace Electron { interface CertificatePrincipal { - // Docs: http://electron.atom.io/docs/api/structures/certificate-principal + // Docs: http://electronjs.org/docs/api/structures/certificate-principal /** - * Common Name + * Common Name. */ commonName: string; /** - * Country or region + * Country or region. */ country: string; /** - * Locality + * Locality. */ locality: string; /** - * Organization names + * Organization names. */ organizations: string[]; /** - * Organization Unit names + * Organization Unit names. */ organizationUnits: string[]; /** - * State or province + * State or province. */ state: string; } class ClientRequest extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/client-request + // Docs: http://electronjs.org/docs/api/client-request /** * Emitted when the request is aborted. The abort event will not be fired if the @@ -2045,7 +2250,7 @@ declare namespace Electron { * Sends the last chunk of the request data. Subsequent write or end operations * will not be allowed. The finish event is emitted just after the end operation. */ - end(chunk?: string | Buffer, encoding?: string, callback?: Function): void; + end(chunk?: (string) | (Buffer), encoding?: string, callback?: Function): void; /** * Continues any deferred redirection request when the redirection mode is manual. */ @@ -2078,13 +2283,13 @@ declare namespace Electron { * issued on the wire. After the first write operation, it is not allowed to add or * remove a custom header. */ - write(chunk: string | Buffer, encoding?: string, callback?: Function): void; + write(chunk: (string) | (Buffer), encoding?: string, callback?: Function): void; chunkedEncoding: boolean; } interface Clipboard extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/clipboard + // Docs: http://electronjs.org/docs/api/clipboard availableFormats(type?: string): string[]; /** @@ -2144,7 +2349,7 @@ declare namespace Electron { interface ContentTracing extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/content-tracing + // Docs: http://electronjs.org/docs/api/content-tracing /** * Get the current monitoring traced data. Child processes typically cache trace @@ -2181,7 +2386,7 @@ declare namespace Electron { * request. The callback will be called once all child processes have acknowledged * the startRecording request. */ - startRecording(options: TraceCategoriesAndOptions | TraceConfig, callback: Function): void; + startRecording(options: (TraceCategoriesAndOptions) | (TraceConfig), callback: Function): void; /** * Stop monitoring on all processes. Once all child processes have acknowledged the * stopMonitoring request the callback is called. @@ -2203,10 +2408,11 @@ declare namespace Electron { interface Cookie { - // Docs: http://electron.atom.io/docs/api/structures/cookie + // Docs: http://electronjs.org/docs/api/structures/cookie /** - * The domain of the cookie. + * The domain of the cookie; this will be normalized with a preceding dot so that + * it's also valid for subdomains. */ domain?: string; /** @@ -2215,7 +2421,8 @@ declare namespace Electron { */ expirationDate?: number; /** - * Whether the cookie is a host-only cookie. + * Whether the cookie is a host-only cookie; this will only be true if no domain + * was passed. */ hostOnly?: boolean; /** @@ -2247,7 +2454,7 @@ declare namespace Electron { class Cookies extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/cookies + // Docs: http://electronjs.org/docs/api/cookies /** * Emitted when a cookie is changed because it was added, edited, removed, or @@ -2328,7 +2535,7 @@ declare namespace Electron { interface CPUUsage { - // Docs: http://electron.atom.io/docs/api/structures/cpu-usage + // Docs: http://electronjs.org/docs/api/structures/cpu-usage /** * The number of average idle cpu wakeups per second since the last call to @@ -2343,7 +2550,7 @@ declare namespace Electron { interface CrashReport { - // Docs: http://electron.atom.io/docs/api/structures/crash-report + // Docs: http://electronjs.org/docs/api/structures/crash-report date: Date; id: string; @@ -2351,7 +2558,7 @@ declare namespace Electron { interface CrashReporter extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/crash-reporter + // Docs: http://electronjs.org/docs/api/crash-reporter /** * Set an extra parameter to be sent with the crash report. The values specified @@ -2362,8 +2569,10 @@ declare namespace Electron { */ addExtraParameter(key: string, value: string): void; /** - * Returns the date and ID of the last crash report. If no crash reports have been - * sent or the crash reporter has not been started, null is returned. + * Returns the date and ID of the last crash report. Only crash reports that have + * been uploaded will be returned; even if a crash report is present on disk it + * will not be returned until it is uploaded. In the case that there are no + * uploaded reports, null is returned. */ getLastCrashReport(): CrashReport; /** @@ -2419,7 +2628,7 @@ declare namespace Electron { class Debugger extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/debugger + // Docs: http://electronjs.org/docs/api/debugger /** * Emitted when debugging session is terminated. This happens either when @@ -2505,7 +2714,7 @@ declare namespace Electron { interface DesktopCapturer extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/desktop-capturer + // Docs: http://electronjs.org/docs/api/desktop-capturer /** * Starts gathering information about all available desktop media sources, and @@ -2518,7 +2727,7 @@ declare namespace Electron { interface DesktopCapturerSource { - // Docs: http://electron.atom.io/docs/api/structures/desktop-capturer-source + // Docs: http://electronjs.org/docs/api/structures/desktop-capturer-source /** * A unique identifier that will correspond to the id of the matching returned by @@ -2534,8 +2743,8 @@ declare namespace Electron { */ id: string; /** - * A screen source will be named either Entire Screen or Screen , while the - * name of a window source will match the window title. + * A screen source will be named either Entire Screen or Screen , while the name of + * a window source will match the window title. */ name: string; /** @@ -2549,7 +2758,7 @@ declare namespace Electron { interface Dialog extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/dialog + // Docs: http://electronjs.org/docs/api/dialog /** * On macOS, this displays a modal dialog that shows a message and certificate @@ -2610,7 +2819,7 @@ declare namespace Electron { * file selector and a directory selector, so if you set properties to ['openFile', * 'openDirectory'] on these platforms, a directory selector will be shown. */ - showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[]; + showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): (string[]) | (undefined); /** * The browserWindow argument allows the dialog to attach itself to a parent * window, making it modal. The filters specifies an array of file types that can @@ -2623,7 +2832,7 @@ declare namespace Electron { * file selector and a directory selector, so if you set properties to ['openFile', * 'openDirectory'] on these platforms, a directory selector will be shown. */ - showOpenDialog(options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): string[]; + showOpenDialog(options: OpenDialogOptions, callback?: (filePaths: string[], bookmarks: string[]) => void): (string[]) | (undefined); /** * The browserWindow argument allows the dialog to attach itself to a parent * window, making it modal. The filters specifies an array of file types that can @@ -2631,7 +2840,7 @@ declare namespace Electron { * the API call will be asynchronous and the result will be passed via * callback(filename). */ - showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string; + showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): (string) | (undefined); /** * The browserWindow argument allows the dialog to attach itself to a parent * window, making it modal. The filters specifies an array of file types that can @@ -2639,12 +2848,12 @@ declare namespace Electron { * the API call will be asynchronous and the result will be passed via * callback(filename). */ - showSaveDialog(options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): string; + showSaveDialog(options: SaveDialogOptions, callback?: (filename: string, bookmark: string) => void): (string) | (undefined); } interface Display { - // Docs: http://electron.atom.io/docs/api/structures/display + // Docs: http://electronjs.org/docs/api/structures/display bounds: Rectangle; /** @@ -2670,7 +2879,7 @@ declare namespace Electron { class DownloadItem extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/download-item + // Docs: http://electronjs.org/docs/api/download-item /** * Emitted when the download is in a terminal state. This includes a completed @@ -2773,7 +2982,7 @@ declare namespace Electron { interface FileFilter { - // Docs: http://electron.atom.io/docs/api/structures/file-filter + // Docs: http://electronjs.org/docs/api/structures/file-filter extensions: string[]; name: string; @@ -2781,7 +2990,7 @@ declare namespace Electron { interface GlobalShortcut extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/global-shortcut + // Docs: http://electronjs.org/docs/api/global-shortcut /** * When the accelerator is already taken by other applications, this call will @@ -2811,65 +3020,65 @@ declare namespace Electron { interface GPUFeatureStatus { - // Docs: http://electron.atom.io/docs/api/structures/gpu-feature-status + // Docs: http://electronjs.org/docs/api/structures/gpu-feature-status /** - * Canvas + * Canvas. */ '2d_canvas': string; /** - * Flash + * Flash. */ flash_3d: string; /** - * Flash Stage3D + * Flash Stage3D. */ flash_stage3d: string; /** - * Flash Stage3D Baseline profile + * Flash Stage3D Baseline profile. */ flash_stage3d_baseline: string; /** - * Compositing + * Compositing. */ gpu_compositing: string; /** - * Multiple Raster Threads + * Multiple Raster Threads. */ multiple_raster_threads: string; /** - * Native GpuMemoryBuffers + * Native GpuMemoryBuffers. */ native_gpu_memory_buffers: string; /** - * Rasterization + * Rasterization. */ rasterization: string; /** - * Video Decode + * Video Decode. */ video_decode: string; /** - * Video Encode + * Video Encode. */ video_encode: string; /** - * VPx Video Decode + * VPx Video Decode. */ vpx_decode: string; /** - * WebGL + * WebGL. */ webgl: string; /** - * WebGL2 + * WebGL2. */ webgl2: string; } interface InAppPurchase extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/in-app-purchase + // Docs: http://electronjs.org/docs/api/in-app-purchase /** * Emitted when one or more transactions have been updated. @@ -2917,7 +3126,7 @@ declare namespace Electron { class IncomingMessage extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/incoming-message + // Docs: http://electronjs.org/docs/api/incoming-message /** * Emitted when a request has been canceled during an ongoing HTTP transaction. @@ -2978,7 +3187,7 @@ declare namespace Electron { interface IOCounters { - // Docs: http://electron.atom.io/docs/api/structures/io-counters + // Docs: http://electronjs.org/docs/api/structures/io-counters /** * Then number of I/O other operations. @@ -3008,7 +3217,7 @@ declare namespace Electron { interface IpcMain extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/ipc-main + // Docs: http://electronjs.org/docs/api/ipc-main /** * Listens to channel, when a new message arrives listener would be called with @@ -3033,7 +3242,7 @@ declare namespace Electron { interface IpcRenderer extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/ipc-renderer + // Docs: http://electronjs.org/docs/api/ipc-renderer /** * Listens to channel, when a new message arrives listener would be called with @@ -3083,7 +3292,7 @@ declare namespace Electron { interface JumpListCategory { - // Docs: http://electron.atom.io/docs/api/structures/jump-list-category + // Docs: http://electronjs.org/docs/api/structures/jump-list-category /** * Array of objects if type is tasks or custom, otherwise it should be omitted. @@ -3101,7 +3310,7 @@ declare namespace Electron { interface JumpListItem { - // Docs: http://electron.atom.io/docs/api/structures/jump-list-item + // Docs: http://electronjs.org/docs/api/structures/jump-list-item /** * The command line arguments when program is executed. Should only be set if type @@ -3148,7 +3357,7 @@ declare namespace Electron { interface MemoryInfo { - // Docs: http://electron.atom.io/docs/api/structures/memory-info + // Docs: http://electronjs.org/docs/api/structures/memory-info /** * The maximum amount of memory that has ever been pinned to actual physical RAM. @@ -3177,7 +3386,7 @@ declare namespace Electron { interface MemoryUsageDetails { - // Docs: http://electron.atom.io/docs/api/structures/memory-usage-details + // Docs: http://electronjs.org/docs/api/structures/memory-usage-details count: number; liveSize: number; @@ -3186,7 +3395,7 @@ declare namespace Electron { class Menu { - // Docs: http://electron.atom.io/docs/api/menu + // Docs: http://electronjs.org/docs/api/menu /** * Emitted when a popup is closed either manually or with menu.closePopup(). @@ -3213,7 +3422,7 @@ declare namespace Electron { * Note: The returned Menu instance doesn't support dynamic addition or removal of * menu items. Instance properties can still be dynamically modified. */ - static getApplicationMenu(): Menu | null; + static getApplicationMenu(): (Menu) | (null); /** * Sends the action to the first responder of application. This is used for * emulating default macOS menu behaviors. Usually you would use the role property @@ -3227,7 +3436,7 @@ declare namespace Electron { * Windows and Linux but has no effect on macOS. Note: This API has to be called * after the ready event of app module. */ - static setApplicationMenu(menu: Menu | null): void; + static setApplicationMenu(menu: (Menu) | (null)): void; /** * Appends the menuItem to the menu. */ @@ -3244,13 +3453,13 @@ declare namespace Electron { /** * Pops up this menu as a context menu in the BrowserWindow. */ - popup(options: PopupOptions): void; + popup(options?: PopupOptions): void; items: MenuItem[]; } class MenuItem { - // Docs: http://electron.atom.io/docs/api/menu-item + // Docs: http://electronjs.org/docs/api/menu-item constructor(options: MenuItemConstructorOptions); checked: boolean; @@ -3262,21 +3471,21 @@ declare namespace Electron { interface MimeTypedBuffer { - // Docs: http://electron.atom.io/docs/api/structures/mime-typed-buffer + // Docs: http://electronjs.org/docs/api/structures/mime-typed-buffer /** - * The actual Buffer content + * The actual Buffer content. */ data: Buffer; /** - * The mimeType of the Buffer that you are sending + * The mimeType of the Buffer that you are sending. */ mimeType: string; } class NativeImage { - // Docs: http://electron.atom.io/docs/api/native-image + // Docs: http://electronjs.org/docs/api/native-image /** * Creates an empty NativeImage instance. @@ -3294,7 +3503,14 @@ declare namespace Electron { * Creates a new NativeImage instance from the NSImage that maps to the given image * name. See NSImageName for a list of possible values. The hslShift is applied to * the image with the following rules This means that [-1, 0, 1] will make the - * image completely white and [-1, 1, 0] will make the image completely black. + * image completely white and [-1, 1, 0] will make the image completely black. In + * some cases, the NSImageName doesn't match its string representation; one example + * of this is NSFolderImageName, whose string representation would actually be + * NSFolder. Therefore, you'll need to determine the correct string representation + * for your image before passing it in. This can be done with the following: echo + * -e '#import \nint main() { NSLog(@"%@", SYSTEM_IMAGE_NAME); }' | + * clang -otest -x objective-c -framework Cocoa - && ./test where SYSTEM_IMAGE_NAME + * should be replaced with any value from this list. */ static createFromNamedImage(imageName: string, hslShift: number[]): NativeImage; /** @@ -3343,7 +3559,7 @@ declare namespace Electron { interface Net extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/net + // Docs: http://electronjs.org/docs/api/net /** * Creates a ClientRequest instance using the provided options which are directly @@ -3351,12 +3567,12 @@ declare namespace Electron { * to issue both secure and insecure HTTP requests according to the specified * protocol scheme in the options object. */ - request(options: any | string): ClientRequest; + request(options: (any) | (string)): ClientRequest; } interface NetLog extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/net-log + // Docs: http://electronjs.org/docs/api/net-log /** * Starts recording network events to path. @@ -3379,7 +3595,7 @@ declare namespace Electron { class Notification extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/notification + // Docs: http://electronjs.org/docs/api/notification on(event: 'action', listener: (event: Event, /** @@ -3469,7 +3685,7 @@ declare namespace Electron { interface NotificationAction { - // Docs: http://electron.atom.io/docs/api/structures/notification-action + // Docs: http://electronjs.org/docs/api/structures/notification-action /** * The label for the given action. @@ -3483,7 +3699,7 @@ declare namespace Electron { interface Point { - // Docs: http://electron.atom.io/docs/api/structures/point + // Docs: http://electronjs.org/docs/api/structures/point x: number; y: number; @@ -3491,7 +3707,7 @@ declare namespace Electron { interface PowerMonitor extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/power-monitor + // Docs: http://electronjs.org/docs/api/power-monitor /** * Emitted when the system is about to lock the screen. @@ -3549,7 +3765,7 @@ declare namespace Electron { interface PowerSaveBlocker extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/power-save-blocker + // Docs: http://electronjs.org/docs/api/power-save-blocker isStarted(id: number): boolean; /** @@ -3571,7 +3787,7 @@ declare namespace Electron { interface PrinterInfo { - // Docs: http://electron.atom.io/docs/api/structures/printer-info + // Docs: http://electronjs.org/docs/api/structures/printer-info description: string; isDefault: boolean; @@ -3581,16 +3797,12 @@ declare namespace Electron { interface ProcessMetric { - // Docs: http://electron.atom.io/docs/api/structures/process-metric + // Docs: http://electronjs.org/docs/api/structures/process-metric /** * CPU usage of the process. */ cpu: CPUUsage; - /** - * Memory information for the process. - */ - memory: MemoryInfo; /** * Process id of the process. */ @@ -3603,7 +3815,7 @@ declare namespace Electron { interface Product { - // Docs: http://electron.atom.io/docs/api/structures/product + // Docs: http://electronjs.org/docs/api/structures/product /** * The total size of the content, in bytes. @@ -3642,7 +3854,7 @@ declare namespace Electron { interface Protocol extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/protocol + // Docs: http://electronjs.org/docs/api/protocol /** * Intercepts scheme protocol and uses handler as the protocol's new handler which @@ -3663,7 +3875,7 @@ declare namespace Electron { * Same as protocol.registerStreamProtocol, except that it replaces an existing * protocol handler. */ - interceptStreamProtocol(scheme: string, handler: (request: InterceptStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void; + interceptStreamProtocol(scheme: string, handler: (request: InterceptStreamProtocolRequest, callback: (stream?: (NodeJS.ReadableStream) | (StreamProtocolResponse)) => void) => void, completion?: (error: Error) => void): void; /** * Intercepts scheme protocol and uses handler as the protocol's new handler which * sends a String as a response. @@ -3680,15 +3892,15 @@ declare namespace Electron { * with either a Buffer object or an object that has the data, mimeType, and * charset properties. Example: */ - registerBufferProtocol(scheme: string, handler: (request: RegisterBufferProtocolRequest, callback: (buffer?: Buffer | MimeTypedBuffer) => void) => void, completion?: (error: Error) => void): void; + registerBufferProtocol(scheme: string, handler: (request: RegisterBufferProtocolRequest, callback: (buffer?: (Buffer) | (MimeTypedBuffer)) => void) => void, completion?: (error: Error) => void): void; /** * Registers a protocol of scheme that will send the file as a response. The * handler will be called with handler(request, callback) when a request is going * to be created with scheme. completion will be called with completion(null) when * scheme is successfully registered or completion(error) when failed. 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}). When callback is called with nothing, a number, or an object that + * object that has a path property, e.g. callback(filePath) or callback({ path: + * filePath }). When callback is called with nothing, a number, or an object that * has an error property, the request will fail with the error number you * specified. For the available error numbers you can use, please see the net error * list. By default the scheme is treated like http:, which is parsed differently @@ -3732,7 +3944,7 @@ declare namespace Electron { * that implements the readable stream API (emits data/end/error events). For * example, here's how a file could be returned: */ - registerStreamProtocol(scheme: string, handler: (request: RegisterStreamProtocolRequest, callback: (stream?: ReadableStream | StreamProtocolResponse) => void) => void, completion?: (error: Error) => void): void; + registerStreamProtocol(scheme: string, handler: (request: RegisterStreamProtocolRequest, callback: (stream?: (NodeJS.ReadableStream) | (StreamProtocolResponse)) => void) => void, completion?: (error: Error) => void): void; /** * 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 @@ -3752,29 +3964,29 @@ declare namespace Electron { interface Rectangle { - // Docs: http://electron.atom.io/docs/api/structures/rectangle + // Docs: http://electronjs.org/docs/api/structures/rectangle /** - * The height of the rectangle (must be an integer) + * The height of the rectangle (must be an integer). */ height: number; /** - * The width of the rectangle (must be an integer) + * The width of the rectangle (must be an integer). */ width: number; /** - * The x coordinate of the origin of the rectangle (must be an integer) + * The x coordinate of the origin of the rectangle (must be an integer). */ x: number; /** - * The y coordinate of the origin of the rectangle (must be an integer) + * The y coordinate of the origin of the rectangle (must be an integer). */ y: number; } interface Referrer { - // Docs: http://electron.atom.io/docs/api/structures/referrer + // Docs: http://electronjs.org/docs/api/structures/referrer /** * Can be default, unsafe-url, no-referrer-when-downgrade, no-referrer, origin, @@ -3790,7 +4002,7 @@ declare namespace Electron { interface Remote extends MainInterface { - // Docs: http://electron.atom.io/docs/api/remote + // Docs: http://electronjs.org/docs/api/remote getCurrentWebContents(): WebContents; /** @@ -3813,7 +4025,7 @@ declare namespace Electron { interface RemoveClientCertificate { - // Docs: http://electron.atom.io/docs/api/structures/remove-client-certificate + // Docs: http://electronjs.org/docs/api/structures/remove-client-certificate /** * Origin of the server whose associated client certificate must be removed from @@ -3828,7 +4040,7 @@ declare namespace Electron { interface RemovePassword { - // Docs: http://electron.atom.io/docs/api/structures/remove-password + // Docs: http://electronjs.org/docs/api/structures/remove-password /** * When provided, the authentication info related to the origin will only be @@ -3860,7 +4072,7 @@ declare namespace Electron { interface Screen extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/screen + // Docs: http://electronjs.org/docs/api/screen /** * Emitted when newDisplay has been added. @@ -3911,7 +4123,7 @@ declare namespace Electron { * relative to the display nearest to window. If window is null, scaling will be * performed to the display nearest to rect. */ - dipToScreenRect(window: BrowserWindow | null, rect: Rectangle): Rectangle; + dipToScreenRect(window: (BrowserWindow) | (null), rect: Rectangle): Rectangle; getAllDisplays(): Display[]; /** * The current absolute position of the mouse pointer. @@ -3930,44 +4142,44 @@ declare namespace Electron { * relative to the display nearest to window. If window is null, scaling will be * performed to the display nearest to rect. */ - screenToDipRect(window: BrowserWindow | null, rect: Rectangle): Rectangle; + screenToDipRect(window: (BrowserWindow) | (null), rect: Rectangle): Rectangle; } interface ScrubberItem { - // Docs: http://electron.atom.io/docs/api/structures/scrubber-item + // Docs: http://electronjs.org/docs/api/structures/scrubber-item /** - * The image to appear in this item + * The image to appear in this item. */ icon?: NativeImage; /** - * The text to appear in this item + * The text to appear in this item. */ label?: string; } interface SegmentedControlSegment { - // Docs: http://electron.atom.io/docs/api/structures/segmented-control-segment + // Docs: http://electronjs.org/docs/api/structures/segmented-control-segment /** - * Whether this segment is selectable. Default: true + * Whether this segment is selectable. Default: true. */ enabled?: boolean; /** - * The image to appear in this segment + * The image to appear in this segment. */ icon?: NativeImage; /** - * The text to appear in this segment + * The text to appear in this segment. */ label?: string; } class Session extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/session + // Docs: http://electronjs.org/docs/api/session /** * If partition starts with persist:, the page will use a persistent session @@ -4007,7 +4219,7 @@ declare namespace Electron { /** * Clears the session’s HTTP authentication cache. */ - clearAuthCache(options: RemovePassword | RemoveClientCertificate, callback?: Function): void; + clearAuthCache(options: (RemovePassword) | (RemoveClientCertificate), callback?: Function): void; /** * Clears the session’s HTTP cache. */ @@ -4066,12 +4278,18 @@ declare namespace Electron { * Downloads under the respective app folder. */ setDownloadPath(path: string): void; + /** + * Sets the handler which can be used to respond to permission checks for the + * session. Returning true will allow the permission and false will reject it. To + * clear the handler, call setPermissionCheckHandler(null). + */ + setPermissionCheckHandler(handler: ((webContents: WebContents, permission: string, requestingOrigin: string, details: PermissionCheckHandlerDetails) => boolean) | (null)): void; /** * Sets the handler which can be used to respond to permission requests for the * session. Calling callback(true) will allow the permission and callback(false) * will reject it. To clear the handler, call setPermissionRequestHandler(null). */ - setPermissionRequestHandler(handler: (webContents: WebContents, permission: string, callback: (permissionGranted: boolean) => void, details: PermissionRequestHandlerDetails) => void | null): void; + setPermissionRequestHandler(handler: ((webContents: WebContents, permission: string, callback: (permissionGranted: boolean) => void, details: PermissionRequestHandlerDetails) => void) | (null)): void; /** * Adds scripts that will be executed on ALL web contents that are associated with * this session just before normal preload scripts run. @@ -4100,7 +4318,7 @@ declare namespace Electron { interface Shell { - // Docs: http://electron.atom.io/docs/api/shell + // Docs: http://electronjs.org/docs/api/shell /** * Play the beep sound. @@ -4140,7 +4358,7 @@ declare namespace Electron { interface ShortcutDetails { - // Docs: http://electron.atom.io/docs/api/structures/shortcut-details + // Docs: http://electronjs.org/docs/api/structures/shortcut-details /** * The Application User Model ID. Default is empty. @@ -4176,7 +4394,7 @@ declare namespace Electron { interface Size { - // Docs: http://electron.atom.io/docs/api/structures/size + // Docs: http://electronjs.org/docs/api/structures/size height: number; width: number; @@ -4184,25 +4402,25 @@ declare namespace Electron { interface StreamProtocolResponse { - // Docs: http://electron.atom.io/docs/api/structures/stream-protocol-response + // Docs: http://electronjs.org/docs/api/structures/stream-protocol-response /** - * A Node.js readable stream representing the response body + * A Node.js readable stream representing the response body. */ - data: ReadableStream; + data: NodeJS.ReadableStream; /** - * An object containing the response headers + * An object containing the response headers. */ headers: Headers; /** - * The HTTP response code + * The HTTP response code. */ statusCode: number; } interface SystemPreferences extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/system-preferences + // Docs: http://electronjs.org/docs/api/system-preferences on(event: 'accent-color-changed', listener: (event: Event, /** @@ -4224,6 +4442,30 @@ declare namespace Electron { * The new RGBA color the user assigned to be their system accent color. */ newColor: string) => void): this; + /** + * NOTE: This event is only emitted after you have called + * startAppLevelAppearanceTrackingOS + */ + on(event: 'appearance-changed', listener: ( + /** + * Can be `dark` or `light` + */ + newAppearance: ('dark' | 'light')) => void): this; + once(event: 'appearance-changed', listener: ( + /** + * Can be `dark` or `light` + */ + newAppearance: ('dark' | 'light')) => void): this; + addListener(event: 'appearance-changed', listener: ( + /** + * Can be `dark` or `light` + */ + newAppearance: ('dark' | 'light')) => void): this; + removeListener(event: 'appearance-changed', listener: ( + /** + * Can be `dark` or `light` + */ + newAppearance: ('dark' | 'light')) => void): this; on(event: 'color-changed', listener: (event: Event) => void): this; once(event: 'color-changed', listener: (event: Event) => void): this; addListener(event: 'color-changed', listener: (event: Event) => void): this; @@ -4252,8 +4494,41 @@ declare namespace Electron { * used, `false` otherwise. */ invertedColorScheme: boolean) => void): this; + /** + * Important: In order to properly leverage this API, you must set the + * NSMicrophoneUsageDescription and NSCameraUsageDescription strings in your app's + * Info.plist file. The values for these keys will be used to populate the + * permission dialogs so that the user will be properly informed as to the purpose + * of the permission request. See Electron Application Distribution for more + * information about how to set these in the context of Electron. This user consent + * was not required until macOS 10.14 Mojave, so this method will always return + * true if your system is running 10.13 High Sierra or lower. + */ + askForMediaAccess(mediaType: 'microphone' | 'camera'): Promise; getAccentColor(): string; + /** + * Gets the macOS appearance setting that you have declared you want for your + * application, maps to NSApplication.appearance. You can use the + * setAppLevelAppearance API to set this value. + */ + getAppLevelAppearance(): ('dark' | 'light' | 'unknown'); getColor(color: '3d-dark-shadow' | '3d-face' | '3d-highlight' | '3d-light' | '3d-shadow' | 'active-border' | 'active-caption' | 'active-caption-gradient' | 'app-workspace' | 'button-text' | 'caption-text' | 'desktop' | 'disabled-text' | 'highlight' | 'highlight-text' | 'hotlight' | 'inactive-border' | 'inactive-caption' | 'inactive-caption-gradient' | 'inactive-caption-text' | 'info-background' | 'info-text' | 'menu' | 'menu-highlight' | 'menubar' | 'menu-text' | 'scrollbar' | 'window' | 'window-frame' | 'window-text'): string; + /** + * Gets the macOS appearance setting that is currently applied to your application, + * maps to NSApplication.effectiveAppearance Please note that until Electron is + * built targeting the 10.14 SDK, your application's effectiveAppearance will + * default to 'light' and won't inherit the OS preference. In the interim in order + * for your application to inherit the OS preference you must set the + * NSRequiresAquaSystemAppearance key in your apps Info.plist to false. If you are + * using electron-packager or electron-forge just set the enableDarwinDarkMode + * packager option to true. See the Electron Packager API for more details. + */ + getEffectiveAppearance(): ('dark' | 'light' | 'unknown'); + /** + * This user consent was not required until macOS 10.14 Mojave, so this method will + * always return granted if your system is running 10.13 High Sierra or lower. + */ + getMediaAccessStatus(mediaType: string): ('not-determined' | 'granted' | 'denied' | 'restricted' | 'unknown'); /** * Some popular key and types are: */ @@ -4266,6 +4541,7 @@ declare namespace Electron { isDarkMode(): boolean; isInvertedColorScheme(): boolean; isSwipeTrackingFromScrollEventsEnabled(): boolean; + isTrustedAccessibilityClient(prompt: boolean): boolean; /** * Posts event as native notifications of macOS. The userInfo is an Object that * contains the user information dictionary sent along with the notification. @@ -4290,6 +4566,11 @@ declare namespace Electron { * global value of a key previously set with setUserDefault. */ removeUserDefault(key: string): void; + /** + * Sets the appearance setting for your application, this should override the + * system default and override the value of getEffectiveAppearance. + */ + setAppLevelAppearance(appearance: 'dark' | 'light'): void; /** * Set the value of key in NSUserDefaults. Note that type should match actual type * of value. An exception is thrown if they don't. Some popular key and types are: @@ -4333,7 +4614,7 @@ declare namespace Electron { interface Task { - // Docs: http://electron.atom.io/docs/api/structures/task + // Docs: http://electronjs.org/docs/api/structures/task /** * The command line arguments when program is executed. @@ -4368,7 +4649,7 @@ declare namespace Electron { interface ThumbarButton { - // Docs: http://electron.atom.io/docs/api/structures/thumbar-button + // Docs: http://electronjs.org/docs/api/structures/thumbar-button click: Function; /** @@ -4388,7 +4669,7 @@ declare namespace Electron { class TouchBarButton extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-button + // Docs: http://electronjs.org/docs/api/touch-bar-button constructor(options: TouchBarButtonConstructorOptions); backgroundColor: string; @@ -4398,7 +4679,7 @@ declare namespace Electron { class TouchBarColorPicker extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-color-picker + // Docs: http://electronjs.org/docs/api/touch-bar-color-picker constructor(options: TouchBarColorPickerConstructorOptions); availableColors: string[]; @@ -4407,14 +4688,14 @@ declare namespace Electron { class TouchBarGroup extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-group + // Docs: http://electronjs.org/docs/api/touch-bar-group constructor(options: TouchBarGroupConstructorOptions); } class TouchBarLabel extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-label + // Docs: http://electronjs.org/docs/api/touch-bar-label constructor(options: TouchBarLabelConstructorOptions); label: string; @@ -4423,7 +4704,7 @@ declare namespace Electron { class TouchBarPopover extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-popover + // Docs: http://electronjs.org/docs/api/touch-bar-popover constructor(options: TouchBarPopoverConstructorOptions); icon: NativeImage; @@ -4432,7 +4713,7 @@ declare namespace Electron { class TouchBarScrubber extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-scrubber + // Docs: http://electronjs.org/docs/api/touch-bar-scrubber constructor(options: TouchBarScrubberConstructorOptions); continuous: boolean; @@ -4445,7 +4726,7 @@ declare namespace Electron { class TouchBarSegmentedControl extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-segmented-control + // Docs: http://electronjs.org/docs/api/touch-bar-segmented-control constructor(options: TouchBarSegmentedControlConstructorOptions); segments: SegmentedControlSegment[]; @@ -4455,7 +4736,7 @@ declare namespace Electron { class TouchBarSlider extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-slider + // Docs: http://electronjs.org/docs/api/touch-bar-slider constructor(options: TouchBarSliderConstructorOptions); label: string; @@ -4466,14 +4747,14 @@ declare namespace Electron { class TouchBarSpacer extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar-spacer + // Docs: http://electronjs.org/docs/api/touch-bar-spacer constructor(options: TouchBarSpacerConstructorOptions); } class TouchBar extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/touch-bar + // Docs: http://electronjs.org/docs/api/touch-bar constructor(options: TouchBarConstructorOptions); escapeItem: (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null); @@ -4490,7 +4771,7 @@ declare namespace Electron { interface TraceCategoriesAndOptions { - // Docs: http://electron.atom.io/docs/api/structures/trace-categories-and-options + // Docs: http://electronjs.org/docs/api/structures/trace-categories-and-options /** * – is a filter to control what category groups should be traced. A filter can @@ -4517,7 +4798,7 @@ declare namespace Electron { interface TraceConfig { - // Docs: http://electron.atom.io/docs/api/structures/trace-config + // Docs: http://electronjs.org/docs/api/structures/trace-config excluded_categories?: string[]; included_categories?: string[]; @@ -4526,7 +4807,7 @@ declare namespace Electron { interface Transaction { - // Docs: http://electron.atom.io/docs/api/structures/transaction + // Docs: http://electronjs.org/docs/api/structures/transaction /** * The error code if an error occurred while processing the transaction. @@ -4558,7 +4839,7 @@ declare namespace Electron { class Tray extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/tray + // Docs: http://electronjs.org/docs/api/tray /** * Emitted when the tray balloon is clicked. @@ -4810,7 +5091,7 @@ declare namespace Electron { * The bounds of tray icon. */ bounds: Rectangle) => void): this; - constructor(image: NativeImage | string); + constructor(image: (NativeImage) | (string)); /** * Destroys the tray icon immediately. */ @@ -4834,7 +5115,7 @@ declare namespace Electron { /** * Sets the context menu for this icon. */ - setContextMenu(menu: Menu | null): void; + setContextMenu(menu: (Menu) | (null)): void; /** * Sets when the tray's icon background becomes highlighted (in blue). Note: You * can use highlightMode with a BrowserWindow by toggling between 'never' and @@ -4850,11 +5131,11 @@ declare namespace Electron { /** * Sets the image associated with this tray icon. */ - setImage(image: NativeImage | string): void; + setImage(image: (NativeImage) | (string)): void; /** * Sets the image associated with this tray icon when pressed on macOS. */ - setPressedImage(image: NativeImage | string): void; + setPressedImage(image: (NativeImage) | (string)): void; /** * Sets the title displayed aside of the tray icon in the status bar (Support ANSI * colors). @@ -4868,7 +5149,7 @@ declare namespace Electron { interface UploadBlob { - // Docs: http://electron.atom.io/docs/api/structures/upload-blob + // Docs: http://electronjs.org/docs/api/structures/upload-blob /** * UUID of blob data to upload. @@ -4882,7 +5163,7 @@ declare namespace Electron { interface UploadData { - // Docs: http://electron.atom.io/docs/api/structures/upload-data + // Docs: http://electronjs.org/docs/api/structures/upload-data /** * UUID of blob data. Use method to retrieve the data. @@ -4900,7 +5181,7 @@ declare namespace Electron { interface UploadFile { - // Docs: http://electron.atom.io/docs/api/structures/upload-file + // Docs: http://electronjs.org/docs/api/structures/upload-file /** * Path of file to be uploaded. @@ -4926,7 +5207,7 @@ declare namespace Electron { interface UploadRawData { - // Docs: http://electron.atom.io/docs/api/structures/upload-raw-data + // Docs: http://electronjs.org/docs/api/structures/upload-raw-data /** * Data to be uploaded. @@ -4940,7 +5221,7 @@ declare namespace Electron { class WebContents extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/web-contents + // Docs: http://electronjs.org/docs/api/web-contents static fromId(id: number): WebContents; static getAllWebContents(): WebContents[]; @@ -5164,22 +5445,22 @@ declare namespace Electron { */ on(event: 'did-attach-webview', listener: (event: Event, /** - * The guest web contents that is used by the ``. + * The guest web contents that is used by the ` */ webContents: WebContents) => void): this; once(event: 'did-attach-webview', listener: (event: Event, /** - * The guest web contents that is used by the ``. + * The guest web contents that is used by the ` */ webContents: WebContents) => void): this; addListener(event: 'did-attach-webview', listener: (event: Event, /** - * The guest web contents that is used by the ``. + * The guest web contents that is used by the ` */ webContents: WebContents) => void): this; removeListener(event: 'did-attach-webview', listener: (event: Event, /** - * The guest web contents that is used by the ``. + * The guest web contents that is used by the ` */ webContents: WebContents) => void): this; /** @@ -5190,22 +5471,22 @@ declare namespace Electron { /** * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set. */ - color: string | null) => void): this; + color: (string) | (null)) => void): this; once(event: 'did-change-theme-color', listener: (event: Event, /** * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set. */ - color: string | null) => void): this; + color: (string) | (null)) => void): this; addListener(event: 'did-change-theme-color', listener: (event: Event, /** * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set. */ - color: string | null) => void): this; + color: (string) | (null)) => void): this; removeListener(event: 'did-change-theme-color', listener: (event: Event, /** * Theme color is in format of '#rrggbb'. It is `null` when no theme color is set. */ - color: string | null) => void): this; + color: (string) | (null)) => void): this; /** * This event is like did-finish-load but emitted when the load failed or was * cancelled, e.g. window.stop() is invoked. The full list of error codes and their @@ -5394,6 +5675,35 @@ declare namespace Electron { isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this; + /** + * Emitted after a server side redirect occurs during navigation. For example a + * 302 redirect. This event can not be prevented, if you want to prevent redirects + * you should checkout out the will-redirect event above. + */ + on(event: 'did-redirect-navigation', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + once(event: 'did-redirect-navigation', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + addListener(event: 'did-redirect-navigation', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + removeListener(event: 'did-redirect-navigation', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; /** * Corresponds to the points in time when the spinner of the tab started spinning. */ @@ -5405,22 +5715,26 @@ declare namespace Electron { * Emitted when any frame (including main) starts navigating. isInplace will be * true for in-page navigations. */ - on(event: 'did-start-navigation', listener: (url: string, + on(event: 'did-start-navigation', listener: (event: Event, + url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this; - once(event: 'did-start-navigation', listener: (url: string, + once(event: 'did-start-navigation', listener: (event: Event, + url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this; - addListener(event: 'did-start-navigation', listener: (url: string, + addListener(event: 'did-start-navigation', listener: (event: Event, + url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, frameRoutingId: number) => void): this; - removeListener(event: 'did-start-navigation', listener: (url: string, + removeListener(event: 'did-start-navigation', listener: (event: Event, + url: string, isInPlace: boolean, isMainFrame: boolean, frameProcessId: number, @@ -5648,6 +5962,76 @@ declare namespace Electron { removeListener(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this; + /** + * Emitted when remote.getBuiltin() is called in the renderer process. Calling + * event.preventDefault() will prevent the module from being returned. Custom value + * can be returned by setting event.returnValue. + */ + on(event: 'remote-get-builtin', listener: (event: Event, + moduleName: string) => void): this; + once(event: 'remote-get-builtin', listener: (event: Event, + moduleName: string) => void): this; + addListener(event: 'remote-get-builtin', listener: (event: Event, + moduleName: string) => void): this; + removeListener(event: 'remote-get-builtin', listener: (event: Event, + moduleName: string) => void): this; + /** + * Emitted when remote.getCurrentWebContents() is called in the renderer process. + * Calling event.preventDefault() will prevent the object from being returned. + * Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-current-web-contents', listener: (event: Event) => void): this; + once(event: 'remote-get-current-web-contents', listener: (event: Event) => void): this; + addListener(event: 'remote-get-current-web-contents', listener: (event: Event) => void): this; + removeListener(event: 'remote-get-current-web-contents', listener: (event: Event) => void): this; + /** + * Emitted when remote.getCurrentWindow() is called in the renderer process. + * Calling event.preventDefault() will prevent the object from being returned. + * Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-current-window', listener: (event: Event) => void): this; + once(event: 'remote-get-current-window', listener: (event: Event) => void): this; + addListener(event: 'remote-get-current-window', listener: (event: Event) => void): this; + removeListener(event: 'remote-get-current-window', listener: (event: Event) => void): this; + /** + * Emitted when remote.getGlobal() is called in the renderer process. Calling + * event.preventDefault() will prevent the global from being returned. Custom value + * can be returned by setting event.returnValue. + */ + on(event: 'remote-get-global', listener: (event: Event, + globalName: string) => void): this; + once(event: 'remote-get-global', listener: (event: Event, + globalName: string) => void): this; + addListener(event: 'remote-get-global', listener: (event: Event, + globalName: string) => void): this; + removeListener(event: 'remote-get-global', listener: (event: Event, + globalName: string) => void): this; + /** + * Emitted when .getWebContents() is called in the renderer process. + * Calling event.preventDefault() will prevent the object from being returned. + * Custom value can be returned by setting event.returnValue. + */ + on(event: 'remote-get-guest-web-contents', listener: (event: Event, + guestWebContents: WebContents) => void): this; + once(event: 'remote-get-guest-web-contents', listener: (event: Event, + guestWebContents: WebContents) => void): this; + addListener(event: 'remote-get-guest-web-contents', listener: (event: Event, + guestWebContents: WebContents) => void): this; + removeListener(event: 'remote-get-guest-web-contents', listener: (event: Event, + guestWebContents: WebContents) => void): this; + /** + * Emitted when remote.require() is called in the renderer process. Calling + * event.preventDefault() will prevent the module from being returned. Custom value + * can be returned by setting event.returnValue. + */ + on(event: 'remote-require', listener: (event: Event, + moduleName: string) => void): this; + once(event: 'remote-require', listener: (event: Event, + moduleName: string) => void): this; + addListener(event: 'remote-require', listener: (event: Event, + moduleName: string) => void): this; + removeListener(event: 'remote-require', listener: (event: Event, + moduleName: string) => void): this; /** * Emitted when the unresponsive web page becomes responsive again. */ @@ -5727,8 +6111,7 @@ declare namespace Electron { */ webPreferences: any, /** - * The other `` parameters such as the `src` URL. This object can be - * modified to adjust the parameters of the guest page. + * The other ` */ params: any) => void): this; once(event: 'will-attach-webview', listener: (event: Event, @@ -5738,8 +6121,7 @@ declare namespace Electron { */ webPreferences: any, /** - * The other `` parameters such as the `src` URL. This object can be - * modified to adjust the parameters of the guest page. + * The other ` */ params: any) => void): this; addListener(event: 'will-attach-webview', listener: (event: Event, @@ -5749,8 +6131,7 @@ declare namespace Electron { */ webPreferences: any, /** - * The other `` parameters such as the `src` URL. This object can be - * modified to adjust the parameters of the guest page. + * The other ` */ params: any) => void): this; removeListener(event: 'will-attach-webview', listener: (event: Event, @@ -5760,8 +6141,7 @@ declare namespace Electron { */ webPreferences: any, /** - * The other `` parameters such as the `src` URL. This object can be - * modified to adjust the parameters of the guest page. + * The other ` */ params: any) => void): this; /** @@ -5790,6 +6170,36 @@ declare namespace Electron { once(event: 'will-prevent-unload', listener: (event: Event) => void): this; addListener(event: 'will-prevent-unload', listener: (event: Event) => void): this; removeListener(event: 'will-prevent-unload', listener: (event: Event) => void): this; + /** + * Emitted as a server side redirect occurs during navigation. For example a 302 + * redirect. This event will be emitted after did-start-navigation and always + * before the did-redirect-navigation event for the same navigation. Calling + * event.preventDefault() will prevent the navigation (not just the redirect). + */ + on(event: 'will-redirect', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + once(event: 'will-redirect', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + addListener(event: 'will-redirect', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; + removeListener(event: 'will-redirect', listener: (event: Event, + url: string, + isInPlace: boolean, + isMainFrame: boolean, + frameProcessId: number, + frameRoutingId: number) => void): this; /** * Adds the specified path to DevTools workspace. Must be used after DevTools * creation: @@ -5895,6 +6305,7 @@ declare namespace Electron { getPrinters(): PrinterInfo[]; getProcessId(): number; getTitle(): string; + getType(): ('backgroundPage' | 'window' | 'browserView' | 'remote' | 'webview' | 'offscreen'); getURL(): string; getUserAgent(): string; getWebRTCIPHandlingPolicy(): string; @@ -5953,6 +6364,7 @@ declare namespace Electron { invalidate(): void; isAudioMuted(): boolean; isCrashed(): boolean; + isCurrentlyAudible(): boolean; isDestroyed(): boolean; isDevToolsFocused(): boolean; isDevToolsOpened(): boolean; @@ -5967,7 +6379,7 @@ declare namespace Electron { * relative to the root of your application. For instance an app structure like * this: Would require code like this */ - loadFile(filePath: string): void; + loadFile(filePath: string, options?: LoadFileOptions): void; /** * Loads the url in the window. The url must contain the protocol prefix, e.g. the * http:// or file://. If the load should bypass http cache then use the pragma @@ -5992,8 +6404,8 @@ declare namespace Electron { * Prints window's web page. When silent is set to true, Electron will pick the * system's default printer if deviceName is empty and the default settings for * printing. 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. + * webContents.print({ silent: false, printBackground: false, deviceName: '' }). + * Use page-break-before: always; CSS style to force to print to a new page. */ print(options?: PrintOptions, callback?: (success: boolean) => void): void; /** @@ -6054,6 +6466,11 @@ declare namespace Electron { * Mute the audio on the current web page. */ setAudioMuted(muted: boolean): void; + /** + * Controls whether or not this WebContents will throttle animations and timers + * when the page becomes backgrounded. This also affects the Page Visibility API. + */ + setBackgroundThrottling(allowed: boolean): void; /** * Uses the devToolsWebContents as the target WebContents to show devtools. The * devToolsWebContents must not have done any navigation, and it should not be used @@ -6131,6 +6548,10 @@ declare namespace Electron { * If offscreen rendering is enabled and painting, stop painting. */ stopPainting(): void; + /** + * Takes a V8 heap snapshot and saves it to filePath. + */ + takeHeapSnapshot(filePath: string): Promise; /** * Toggles the developer tools. */ @@ -6158,7 +6579,7 @@ declare namespace Electron { interface WebFrame extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/web-frame + // Docs: http://electronjs.org/docs/api/web-frame /** * Attempts to free memory that is no longer being used (like images from a @@ -6176,7 +6597,7 @@ declare namespace Electron { */ executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): Promise; /** - * Work like executeJavaScript but evaluates scripts in isolated context. + * Work like executeJavaScript but evaluates scripts in an isolated context. */ executeJavaScriptInIsolatedWorld(worldId: number, scripts: WebSource[], userGesture?: boolean, callback?: (result: any) => void): void; findFrameByName(name: string): WebFrame; @@ -6279,7 +6700,7 @@ declare namespace Electron { class WebRequest extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/web-request + // Docs: http://electronjs.org/docs/api/web-request /** * The listener will be called with listener(details) when a server initiated @@ -6373,7 +6794,7 @@ declare namespace Electron { interface WebSource { - // Docs: http://electron.atom.io/docs/api/structures/web-source + // Docs: http://electronjs.org/docs/api/structures/web-source code: string; /** @@ -6385,7 +6806,7 @@ declare namespace Electron { interface WebviewTag extends HTMLElement { - // Docs: http://electron.atom.io/docs/api/webview-tag + // Docs: http://electronjs.org/docs/api/webview-tag /** * Fired when a load has committed. This includes navigation within the current @@ -6509,11 +6930,6 @@ declare namespace Electron { */ addEventListener(event: 'crashed', listener: (event: Event) => void, useCapture?: boolean): this; removeEventListener(event: 'crashed', listener: (event: Event) => void): this; - /** - * Fired when the gpu process is crashed. - */ - addEventListener(event: 'gpu-crashed', listener: (event: Event) => void, useCapture?: boolean): this; - removeEventListener(event: 'gpu-crashed', listener: (event: Event) => void): this; /** * Fired when a plugin process is crashed. */ @@ -6597,6 +7013,10 @@ declare namespace Electron { * Executes editing command delete in page. */ delete(): void; + /** + * Initiates a download of the resource at url without navigating. + */ + downloadURL(url: string): void; /** * Evaluates code in page. If userGesture is set, it will create the user gesture * context in the page. HTML APIs like requestFullScreen, which require user @@ -6611,7 +7031,21 @@ declare namespace Electron { getTitle(): string; getURL(): string; getUserAgent(): string; + /** + * It depends on the remote module, it is therefore not available when this module + * is disabled. + */ getWebContents(): WebContents; + /** + * Sends a request to get current zoom factor, the callback will be called with + * callback(zoomFactor). + */ + getZoomFactor(callback: (zoomFactor: number) => void): void; + /** + * Sends a request to get current zoom level, the callback will be called with + * callback(zoomLevel). + */ + getZoomLevel(callback: (zoomLevel: number) => void): void; /** * Makes the guest page go back. */ @@ -6646,9 +7080,11 @@ declare namespace Electron { inspectServiceWorker(): void; isAudioMuted(): boolean; isCrashed(): boolean; + isCurrentlyAudible(): boolean; isDevToolsFocused(): boolean; isDevToolsOpened(): boolean; isLoading(): boolean; + isLoadingMainFrame(): boolean; isWaitingForResponse(): boolean; /** * Loads the url in the webview, the url must contain the protocol prefix, e.g. the @@ -6716,10 +7152,18 @@ declare namespace Electron { * Set guest page muted. */ setAudioMuted(muted: boolean): void; + /** + * Sets the maximum and minimum layout-based (i.e. non-visual) zoom level. + */ + setLayoutZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; /** * Overrides the user agent for the guest page. */ setUserAgent(userAgent: string): void; + /** + * Sets the maximum and minimum pinch-to-zoom level. + */ + setVisualZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; /** * Changes the zoom factor to the specified factor. Zoom factor is zoom percent * divided by 100, so 300% = 3.0. @@ -6728,7 +7172,8 @@ declare namespace Electron { /** * Changes the zoom level to the specified level. The original size is 0 and each * increment above or below represents zooming 20% larger or smaller to default - * limits of 300% and 50% of original size, respectively. + * limits of 300% and 50% of original size, respectively. The formula for this is + * scale := 1.2 ^ level. */ setZoomLevel(level: number): void; /** @@ -6781,6 +7226,11 @@ declare namespace Electron { * RuntimeEnabledFeatures.json5 file. */ enableblinkfeatures?: string; + /** + * When this attribute is false the guest page in webview will not have access to + * the remote module. The remote module is avaiable by default. + */ + enableremotemodule?: string; /** * Sets the referrer URL for the guest page. */ @@ -7054,7 +7504,7 @@ declare namespace Electron { * visual effects, you can also leave it undefined so the executable's icon will be * used. */ - icon?: NativeImage | string; + icon?: (NativeImage) | (string); /** * Whether window should be shown when created. Default is true. */ @@ -7091,9 +7541,8 @@ declare namespace Electron { enableLargerThanScreen?: boolean; /** * Window's background color as a hexadecimal value, like #66CD00 or #FFF or - * #80FFFFFF (alpha is supported). Default is #FFF (white). If transparent is set - * to true, only values with transparent (#00-------) or opaque (#FF-----) alpha - * values are respected. + * #80FFFFFF (alpha is supported if transparent is set to true). Default is #FFF + * (white). */ backgroundColor?: string; /** @@ -7320,7 +7769,7 @@ declare namespace Electron { } interface CrashReporterStartOptions { - companyName?: string; + companyName: string; /** * URL that crash reports will be sent to as POST. */ @@ -7422,7 +7871,8 @@ declare namespace Electron { */ value?: string; /** - * The domain of the cookie. Empty by default if omitted. + * 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. */ domain?: string; /** @@ -7476,7 +7926,7 @@ declare namespace Electron { /** * - */ - icon?: NativeImage | string; + icon?: (NativeImage) | (string); title: string; content: string; } @@ -7518,7 +7968,7 @@ declare namespace Electron { /** * Sets the image associated with this dock icon. */ - setIcon: (image: NativeImage | string) => void; + setIcon: (image: (NativeImage) | (string)) => void; } interface EnableNetworkEmulationOptions { @@ -7716,6 +8166,7 @@ declare namespace Electron { interface InterceptHttpProtocolRequest { url: string; + headers: Headers; referrer: string; method: string; uploadData: UploadData[]; @@ -7772,11 +8223,26 @@ declare namespace Electron { isMainFrame: boolean; } + interface LoadFileOptions { + /** + * Passed to url.format(). + */ + query?: Query; + /** + * Passed to url.format(). + */ + search?: string; + /** + * Passed to url.format(). + */ + hash?: string; + } + interface LoadURLOptions { /** * An HTTP Referrer url. */ - httpReferrer?: string | Referrer; + httpReferrer?: (string) | (Referrer); /** * A user agent originating the request. */ @@ -7785,7 +8251,7 @@ declare namespace Electron { * Extra headers separated by "\n" */ extraHeaders?: string; - postData?: UploadRawData[] | UploadFile[] | UploadBlob[]; + postData?: (UploadRawData[]) | (UploadFile[]) | (UploadBlob[]); /** * 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 @@ -7856,7 +8322,7 @@ declare namespace Electron { label?: string; sublabel?: string; accelerator?: Accelerator; - icon?: NativeImage | string; + icon?: (NativeImage) | (string); /** * If false, the menu item will be greyed out and unclickable. */ @@ -7879,17 +8345,36 @@ declare namespace Electron { * type: 'submenu' can be omitted. If the value is not a then it will be * automatically converted to one using Menu.buildFromTemplate. */ - submenu?: MenuItemConstructorOptions[] | Menu; + submenu?: (MenuItemConstructorOptions[]) | (Menu); /** * Unique within a single menu. If defined then it can be used as a reference to * this item by the position attribute. */ id?: string; /** - * This field allows fine-grained definition of the specific location within a - * given menu. + * Inserts this item before the item with the specified label. If the referenced + * item doesn't exist the item will be inserted at the end of the menu. Also + * implies that the menu item in question should be placed in the same “group” as + * the item. */ - position?: string; + before?: string[]; + /** + * Inserts this item after the item with the specified label. If the referenced + * item doesn't exist the item will be inserted at the end of the menu. + */ + after?: string[]; + /** + * Provides a means for a single context menu to declare the placement of their + * containing group before the containing group of the item with the specified + * label. + */ + beforeGroupContaining?: string[]; + /** + * Provides a means for a single context menu to declare the placement of their + * containing group after the containing group of the item with the specified + * label. + */ + afterGroupContaining?: string[]; } interface MessageBoxOptions { @@ -7935,7 +8420,7 @@ declare namespace Electron { * The index of the button to be used to cancel the dialog, via the Esc key. By * default this is assigned to the first button with "cancel" or "no" as the label. * If no such labeled buttons exist and this option is not set, 0 will be used as - * the return value or callback response. This option is ignored on Windows. + * the return value or callback response. */ cancelId?: number; /** @@ -7993,7 +8478,7 @@ declare namespace Electron { /** * An icon to use in the notification. */ - icon?: string | NativeImage; + icon?: (string) | (NativeImage); /** * Whether or not to add an inline reply option to the notification. */ @@ -8093,6 +8578,7 @@ declare namespace Electron { method: string; webContentsId?: number; resourceType: string; + referrer: string; timestamp: number; responseHeaders: ResponseHeaders; fromCache: boolean; @@ -8151,7 +8637,7 @@ declare namespace Electron { } interface OnHeadersReceivedResponse { - cancel: boolean; + cancel?: boolean; /** * When provided, the server is assumed to have responded with these headers. */ @@ -8242,7 +8728,11 @@ declare namespace Electron { /** * true to bring the opened application to the foreground. The default is true. */ - activate: boolean; + activate?: boolean; + /** + * The working directory. + */ + workingDirectory?: string; } interface PageFaviconUpdatedEvent extends Event { @@ -8267,8 +8757,8 @@ declare namespace Electron { */ screenSize: Size; /** - * Position the view on the screen (screenPosition == mobile) (default: {x: 0, y: - * 0}). + * Position the view on the screen (screenPosition == mobile) (default: { x: 0, y: + * 0 }). */ viewPosition: Point; /** @@ -8298,11 +8788,26 @@ declare namespace Electron { quantity: number; } + interface PermissionCheckHandlerDetails { + /** + * The security orign of the media check. + */ + securityOrigin: string; + /** + * The type of media access being requested, can be video, audio or unknown + */ + mediaType: ('video' | 'audio' | 'unknown'); + } + interface PermissionRequestHandlerDetails { /** * The url of the openExternal request. */ externalURL: string; + /** + * The types of media access being requested, elements can be video or audio + */ + mediaTypes: Array<'video' | 'audio'>; } interface PluginCrashedEvent extends Event { @@ -8359,7 +8864,7 @@ declare namespace Electron { * Specify page size of the generated PDF. Can be A3, A4, A5, Legal, Letter, * Tabloid or an Object containing height and width in microns. */ - pageSize?: string | Size; + pageSize?: (string) | (Size); /** * Whether to print CSS backgrounds. */ @@ -8376,23 +8881,19 @@ declare namespace Electron { interface ProcessMemoryInfo { /** - * The amount of memory currently pinned to actual physical RAM. + * and The amount of memory currently pinned to actual physical RAM in Kilobytes. */ - workingSetSize: number; - /** - * The maximum amount of memory that has ever been pinned to actual physical RAM. - */ - peakWorkingSetSize: number; + residentSet: number; /** * The amount of memory not shared by other processes, such as JS heap or HTML - * content. + * content in Kilobytes. */ - privateBytes: number; + private: number; /** * The amount of memory shared between processes, typically memory consumed by the - * Electron code itself. + * Electron code itself in Kilobytes. */ - sharedBytes: number; + shared: number; } interface ProgressBarOptions { @@ -8437,6 +8938,7 @@ declare namespace Electron { interface RegisterHttpProtocolRequest { url: string; + headers: Headers; referrer: string; method: string; uploadData: UploadData[]; @@ -8704,8 +9206,8 @@ declare namespace Electron { } interface TouchBarConstructorOptions { - items: Array; - escapeItem?: TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopover | TouchBarScrubber | TouchBarSegmentedControl | TouchBarSlider | TouchBarSpacer | null; + items: Array<(TouchBarButton) | (TouchBarColorPicker) | (TouchBarGroup) | (TouchBarLabel) | (TouchBarPopover) | (TouchBarScrubber) | (TouchBarSegmentedControl) | (TouchBarSlider) | (TouchBarSpacer)>; + escapeItem?: (TouchBarButton) | (TouchBarColorPicker) | (TouchBarGroup) | (TouchBarLabel) | (TouchBarPopover) | (TouchBarScrubber) | (TouchBarSegmentedControl) | (TouchBarSlider) | (TouchBarSpacer) | (null); } interface TouchBarGroupConstructorOptions { @@ -8871,6 +9373,13 @@ declare namespace Electron { electron?: string; } + interface VisibleOnAllWorkspacesOptions { + /** + * Sets whether the window should be visible above fullscreen windows + */ + visibleOnFullScreen?: boolean; + } + interface WillNavigateEvent extends Event { url: string; } @@ -8964,6 +9473,9 @@ declare namespace Electron { interface Options { } + interface Query { + } + interface RequestHeaders { } @@ -9004,6 +9516,10 @@ declare namespace Electron { * currently experimental and may change or be removed in future Electron releases. */ sandbox?: boolean; + /** + * Whether to enable the module. Default is true. + */ + enableRemoteModule?: boolean; /** * Sets the session used by the page. Instead of passing the Session object * directly, you can also choose to use the partition option instead, which accepts @@ -9072,10 +9588,6 @@ declare namespace Electron { * Enables Chromium's experimental features. Default is false. */ // experimentalFeatures?: boolean; ### VSCODE CHANGE (https://github.com/electron/electron/blob/master/docs/tutorial/security.md) ### - /** - * Enables Chromium's experimental canvas features. Default is false. - */ - experimentalCanvasFeatures?: boolean; /** * Enables scroll bounce (rubber banding) effect on macOS. Default is false. */ @@ -9131,8 +9643,7 @@ declare namespace Electron { * content to ensure the loaded content cannot tamper with the preload script and * any Electron APIs being used. This option uses the same technique used by . You * can access this context in the dev tools by selecting the 'Electron Isolated - * Context' entry in the combo box at the top of the Console tab. This option is - * currently experimental and may change or be removed in future Electron releases. + * Context' entry in the combo box at the top of the Console tab. */ contextIsolation?: boolean; /** @@ -9144,11 +9655,11 @@ declare namespace Electron { nativeWindowOpen?: boolean; /** * Whether to enable the . Defaults to the value of the nodeIntegration option. The - * preload script configured for the will have node integration enabled - * when it is executed so you should ensure remote/untrusted content is not able to - * create a tag with a possibly malicious preload script. You can use the + * preload script configured for the will have node integration enabled when it is + * executed so you should ensure remote/untrusted content is not able to create a + * tag with a possibly malicious preload script. You can use the * will-attach-webview event on to strip away the preload script and to validate or - * alter the 's initial settings. + * alter the 's initial settings. */ webviewTag?: boolean; /** @@ -9230,7 +9741,7 @@ interface Document { declare namespace NodeJS { interface Process extends EventEmitter { - // Docs: http://electron.atom.io/docs/api/process + // Docs: http://electronjs.org/docs/api/process // ### BEGIN VSCODE MODIFICATION ### // /** @@ -9250,6 +9761,12 @@ declare namespace NodeJS { */ crash(): void; getCPUUsage(): Electron.CPUUsage; + /** + * Indicates the creation time of the application. The time is represented as + * number of milliseconds since epoch. It returns null if it is unable to get the + * process creation time. + */ + getCreationTime(): (number) | (null); /** * Returns an object with V8 heap statistics. Note that all statistics are reported * in Kilobytes. @@ -9258,7 +9775,12 @@ declare namespace NodeJS { getIOCounters(): Electron.IOCounters; /** * Returns an object giving memory usage statistics about the current process. Note - * that all statistics are reported in Kilobytes. + * that all statistics are reported in Kilobytes. This api should be called after + * app ready. Chromium does not provide residentSet value for macOS. This is + * because macOS performs in-memory compression of pages that haven't been recently + * used. As a result the resident set size value is not what one would expect. + * private memory is more representative of the actual pre-compression memory usage + * of the process on macOS. */ getProcessMemoryInfo(): Electron.ProcessMemoryInfo; /** @@ -9275,6 +9797,10 @@ declare namespace NodeJS { * whichever is lower for the current process. */ setFdLimit(maxDescriptors: number): void; + /** + * Takes a V8 heap snapshot and saves it to filePath. + */ + takeHeapSnapshot(filePath: string): boolean; /** * A Boolean. When app is started by being passed as parameter to the default app, * this property is true in the main process, otherwise it is undefined. @@ -9300,6 +9826,11 @@ declare namespace NodeJS { * A String representing the path to the resources directory. */ resourcesPath?: string; + /** + * A Boolean. When the renderer process is sandboxed, this property is true, + * otherwise it is undefined. + */ + sandboxed?: boolean; /** * A Boolean that controls whether or not deprecation warnings will be thrown as * exceptions. Setting this to true will throw errors for deprecations. This @@ -9335,4 +9866,4 @@ declare namespace NodeJS { electron: string; chrome: string; } -} +} \ No newline at end of file diff --git a/src/vs/platform/product/node/product.ts b/src/vs/platform/product/node/product.ts index 305538a7073..3ad86dbcf1b 100644 --- a/src/vs/platform/product/node/product.ts +++ b/src/vs/platform/product/node/product.ts @@ -75,7 +75,6 @@ export interface IProductConfiguration { hockeyApp: { 'win32-ia32': string; 'win32-x64': string; - 'linux-ia32': string; 'linux-x64': string; 'darwin': string; }; diff --git a/src/vs/workbench/contrib/performance/electron-browser/perfviewEditor.ts b/src/vs/workbench/contrib/performance/electron-browser/perfviewEditor.ts index 7152a8c871b..bd40d800b94 100644 --- a/src/vs/workbench/contrib/performance/electron-browser/perfviewEditor.ts +++ b/src/vs/workbench/contrib/performance/electron-browser/perfviewEditor.ts @@ -136,7 +136,7 @@ class PerfModelContentProvider implements ITextModelContentProvider { md.li(`Memory(System): ${(metrics.totalmem / (1024 * 1024 * 1024)).toFixed(2)} GB(${(metrics.freemem / (1024 * 1024 * 1024)).toFixed(2)}GB free)`); } if (metrics.meminfo) { - md.li(`Memory(Process): ${(metrics.meminfo.workingSetSize / 1024).toFixed(2)} MB working set(${(metrics.meminfo.peakWorkingSetSize / 1024).toFixed(2)}MB peak, ${(metrics.meminfo.privateBytes / 1024).toFixed(2)}MB private, ${(metrics.meminfo.sharedBytes / 1024).toFixed(2)}MB shared)`); + md.li(`Memory(Process): ${(metrics.meminfo.workingSetSize / 1024).toFixed(2)} MB working set(${(metrics.meminfo.privateBytes / 1024).toFixed(2)}MB private, ${(metrics.meminfo.sharedBytes / 1024).toFixed(2)}MB shared)`); } md.li(`VM(likelyhood): ${metrics.isVMLikelyhood}%`); md.li(`Initial Startup: ${metrics.initialStartup}`); diff --git a/src/vs/workbench/contrib/update/electron-browser/update.contribution.ts b/src/vs/workbench/contrib/update/electron-browser/update.contribution.ts index efa834b0e6d..b7a6f3d7989 100644 --- a/src/vs/workbench/contrib/update/electron-browser/update.contribution.ts +++ b/src/vs/workbench/contrib/update/electron-browser/update.contribution.ts @@ -11,7 +11,7 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr import { IGlobalActivityRegistry, GlobalActivityExtensions } from 'vs/workbench/common/activity'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; -import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution, Linux32BitContribution } from './update'; +import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution } from './update'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; const workbench = Registry.as(WorkbenchExtensions.Workbench); @@ -24,13 +24,6 @@ if (platform.isWindows) { } } -// TODO@ben remove me after a while -if (platform.isLinux) { - if (process.arch === 'ia32') { - workbench.registerWorkbenchContribution(Linux32BitContribution, LifecyclePhase.Restored); - } -} - Registry.as(GlobalActivityExtensions) .registerActivity(UpdateContribution); diff --git a/src/vs/workbench/contrib/update/electron-browser/update.ts b/src/vs/workbench/contrib/update/electron-browser/update.ts index cea347aca03..47de95dcafa 100644 --- a/src/vs/workbench/contrib/update/electron-browser/update.ts +++ b/src/vs/workbench/contrib/update/electron-browser/update.ts @@ -212,53 +212,6 @@ export class Win3264BitContribution implements IWorkbenchContribution { } } -export class Linux32BitContribution implements IWorkbenchContribution { - - private static readonly KEY = 'update/linux32-64bits'; - private static readonly URL = 'https://code.visualstudio.com/updates/v1_32#_linux-32-bit-support-ends-soon'; - private static readonly INSIDER_URL = 'https://github.com/Microsoft/vscode-docs/blob/vnext/release-notes/v1_32.md#linux-32-bit-support-ends-soon'; - - constructor( - @IStorageService storageService: IStorageService, - @INotificationService notificationService: INotificationService, - @IEnvironmentService environmentService: IEnvironmentService - ) { - if (environmentService.disableUpdates) { - return; - } - - const neverShowAgain = new NeverShowAgain(Linux32BitContribution.KEY, storageService); - - if (!neverShowAgain.shouldShow()) { - return; - } - - const url = product.quality === 'insider' - ? Linux32BitContribution.INSIDER_URL - : Linux32BitContribution.URL; - - const handle = notificationService.prompt( - severity.Info, - nls.localize('linux64bits', "{0} for 32-bit Linux will soon be discontinued. Please update to the 64-bit version.", product.nameShort, url), - [{ - label: nls.localize('learnmore', "Learn More"), - run: () => { - window.open(url); - } - }, - { - label: nls.localize('neveragain', "Don't Show Again"), - isSecondary: true, - run: () => { - neverShowAgain.action.run(handle); - neverShowAgain.action.dispose(); - } - }], - { sticky: true } - ); - } -} - class CommandAction extends Action { constructor( diff --git a/src/vs/workbench/services/timer/electron-browser/timerService.ts b/src/vs/workbench/services/timer/electron-browser/timerService.ts index b26edf948a8..53d317fbec3 100644 --- a/src/vs/workbench/services/timer/electron-browser/timerService.ts +++ b/src/vs/workbench/services/timer/electron-browser/timerService.ts @@ -23,14 +23,12 @@ import { IAccessibilityService, AccessibilitySupport } from 'vs/platform/accessi /* __GDPR__FRAGMENT__ "IMemoryInfo" : { "workingSetSize" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, - "peakWorkingSetSize": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "privateBytes": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }, "sharedBytes": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true } } */ export interface IMemoryInfo { readonly workingSetSize: number; - readonly peakWorkingSetSize: number; readonly privateBytes: number; readonly sharedBytes: number; } @@ -355,7 +353,13 @@ class TimerService implements ITimerService { release = os.release(); arch = os.arch(); loadavg = os.loadavg(); - meminfo = process.getProcessMemoryInfo(); + + const processMemoryInfo = await process.getProcessMemoryInfo(); + meminfo = { + workingSetSize: processMemoryInfo.residentSet, + privateBytes: processMemoryInfo.private, + sharedBytes: processMemoryInfo.shared + }; isVMLikelyhood = Math.round((virtualMachineHint.value() * 100)); diff --git a/test/smoke/package.json b/test/smoke/package.json index 00b04f8453d..5ccd0406912 100644 --- a/test/smoke/package.json +++ b/test/smoke/package.json @@ -22,7 +22,7 @@ "@types/webdriverio": "4.6.1", "concurrently": "^3.5.1", "cpx": "^1.5.0", - "electron": "3.1.8", + "electron": "4.2.3", "htmlparser2": "^3.9.2", "mkdirp": "^0.5.1", "mocha": "^5.2.0", diff --git a/test/smoke/yarn.lock b/test/smoke/yarn.lock index 5e1fd36aa4f..31f89923f61 100644 --- a/test/smoke/yarn.lock +++ b/test/smoke/yarn.lock @@ -49,10 +49,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.33.tgz#1126e94374014e54478092830704f6ea89df04cd" integrity sha512-vmCdO8Bm1ExT+FWfC9sd9r4jwqM7o97gGy2WBshkkXbf/2nLAJQUrZfIhw27yVOtLUev6kSZc4cav/46KbDd8A== -"@types/node@^8.0.24": - version "8.10.23" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.23.tgz#e5ccfdafff42af5397c29669b6d7d65f7d629a00" - integrity sha512-aEp5ZTLr4mYhR9S85cJ+sEYkcsgFY10N1Si5m49iTAVzanZXOwp/pgw6ibFLKXxpflqm71aSWZCRtnTXXO56gA== +"@types/node@^10.12.18": + version "10.12.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" + integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== "@types/rimraf@2.0.2": version "2.0.2" @@ -596,12 +596,12 @@ electron-download@^4.1.0: semver "^5.4.1" sumchecker "^2.0.2" -electron@3.1.8: - version "3.1.8" - resolved "https://registry.yarnpkg.com/electron/-/electron-3.1.8.tgz#01b0b147dfcca47967ff07dbf72bf5e96125a2ac" - integrity sha512-1MiFoMzxGaR0wDfwFE5Ydnuk6ry/4lKgF0c+NFyEItxM/WyEHNZPNjJAeKJ+M/0sevmZ+6W4syNZnQL5M3GgsQ== +electron@4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/electron/-/electron-4.2.3.tgz#5d45da9dd5ae97269dbee2623840da808c72d29d" + integrity sha512-nx+jHxj2eNhaYHXFGdzr7zgSphpVHEU9WAu6qqEUsQ936X3c6bQ5Bdg08KbHZj+cyRRQ06JMu6/ILh5pWrDZaA== dependencies: - "@types/node" "^8.0.24" + "@types/node" "^10.12.18" electron-download "^4.1.0" extract-zip "^1.0.3" diff --git a/yarn.lock b/yarn.lock index 2e149c1cf3d..4fbe066af51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9590,10 +9590,10 @@ vscode-nls-dev@3.2.5: xml2js "^0.4.19" yargs "^10.1.1" -vscode-nsfw@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/vscode-nsfw/-/vscode-nsfw-1.1.1.tgz#7c3febe153677c5850b197a0b64a197cd11e95c7" - integrity sha512-Wg3vzN1U3T6P1uE13LdVVRIhdy7XWnWkwmAXhkLsIkH2QY0E/pvNDRLrwAMMW6GC1Fvvbxm3hzdIrCmr7Hq3FA== +vscode-nsfw@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vscode-nsfw/-/vscode-nsfw-1.1.2.tgz#9cb9073b5854386801afe41f7152f721b4ea9e80" + integrity sha512-J0So+JNK/5kQboTO1hKNk4ie/wwUegrJilYSY5sVxU9JJlo3aQdP0zi2NtU8CEK3kkN6qRp0MbXCzbT0LKGorg== dependencies: fs-extra "^7.0.0" lodash.isinteger "^4.0.4"