Skip to main content

Electron 22.0.0

· 10 min read

Electron 22.0.0 已发布!它包含一个新的实用程序进程 API、Windows 7/8/8.1 支持更新以及 Chromium 108、V8 10.8 和 Node.js 16.17.1 的升级。请阅读下文了解更多详情!

¥Electron 22.0.0 has been released! It includes a new utility process API, updates for Windows 7/8/8.1 support, and upgrades to Chromium 108, V8 10.8, and Node.js 16.17.1. Read below for more details!


Electron 团队非常高兴地宣布 Electron 22.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 22.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 Twitter 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Twitter, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

技术栈变更

¥Stack Changes

亮点功能

¥Highlighted Features

UtilityProcess API #36089

新的 UtilityProcess 主进程模块允许创建一个轻量级的 Chromium 子进程,只需集成 Node.js,同时还允许使用 MessageChannel 与沙盒渲染器进行通信。该 API 基于 Node.js child_process.fork 设计,以便于更容易地过渡,主要区别在于入口点 modulePath 必须位于打包的应用内部,这样才能只允许加载受信任的脚本。此外,该模块默认阻止与渲染器建立通信通道,从而维护了主进程是应用中唯一可信进程的约定。

¥The new UtilityProcess main process module allows the creation of a lightweight Chromium child process with only Node.js integration while also allowing communication with a sandboxed renderer using MessageChannel. The API was designed based on Node.js child_process.fork to allow for easier transition, with one primary difference being that the entry point modulePath must be from within the packaged application to allow only for trusted scripts to be loaded. Additionally the module prevents establishing communication channels with renderers by default, upholding the contract in which the main process is the only trusted process in the application.

你可以阅读更多关于 新的 UtilityProcess API 在我们的文档中 的信息。

¥You can read more about the new UtilityProcess API in our docs here.

Windows 7/8/8.1 支持更新

¥Windows 7/8/8.1 Support Update

信息

2023/02/16:Windows Server 2012 支持更新

¥2023/02/16: An update on Windows Server 2012 support

上个月,谷歌宣布 Windows Server 2012 和 Windows Server 2012 R2 的 Chrome 109 将继续接收关键安全修复 将持续到 2023 年 10 月 10 日。因此,Electron 22(Chromium 108)的计划生命周期终止日期将从 2023 年 5 月 30 日延长至 2023 年 10 月 10 日。Electron 团队将继续将此计划中的任何安全修复程序反向移植到 Electron 22,直到 2023 年 10 月 10 日。

¥Last month, Google announced that Chrome 109 would continue to receive critical security fixes for Windows Server 2012 and Windows Server 2012 R2 until October 10, 2023. In accordance, Electron 22's (Chromium 108) planned end of life date will be extended from May 30, 2023 to October 10, 2023. The Electron team will continue to backport any security fixes that are part of this program to Electron 22 until October 10, 2023.

请注意,我们不会为 Windows 7/8/8.1 提供额外的安全修复。此外,正如之前宣布的那样,Electron 23(Chromium 110)将仅在 Windows 10 及更高版本上运行。

¥Note that we will not make additional security fixes for Windows 7/8/8.1. Also, Electron 23 (Chromium 110) will only function on Windows 10 and above as previously announced.

Electron 22 将是支持 Windows 7/8/8.1 的最后一个 Electron 主要版本。Electron 遵循计划中的 Chromium 弃用政策,该政策将于 Chromium 109 弃用 Windows 7/8/8.1 支持(点击此处了解更多信息)

¥Electron 22 will be the last Electron major version to support Windows 7/8/8.1. Electron follows the planned Chromium deprecation policy, which will deprecate Windows 7/8/8.1 support in Chromium 109 (read more here).

Electron 23 及更高主要版本将不支持 Windows 7/8/8.1。

¥Windows 7/8/8.1 will not be supported in Electron 23 and later major releases.

其他高亮的变更

¥Additional Highlighted Changes

  • 添加了对 Linux 和 Windows 上 Web 蓝牙引脚配对的支持。#35416

    ¥Added support for Web Bluetooth pin pairing on Linux and Windows. #35416

  • 添加了 LoadBrowserProcessSpecificV8Snapshot 作为新的保险丝,允许主/浏览器进程从 browser_v8_context_snapshot.bin 的文件加载其 v8 快照。任何其他流程都将使用与当前相同的路径。#35266

    ¥Added LoadBrowserProcessSpecificV8Snapshot as a new fuse that will let the main/browser process load its v8 snapshot from a file at browser_v8_context_snapshot.bin. Any other process will use the same path as is used today. #35266

  • 添加了 WebContents.opener 以访问窗口打开器,并添加了 webContents.fromFrame(frame) 以获取与 WebFrameMain 实例对应的 WebContents。#35140

    ¥Added WebContents.opener to access window opener and webContents.fromFrame(frame) to get the WebContents corresponding to a WebFrameMain instance. #35140

  • 通过新的会话处理程序 ses.setDisplayMediaRequestHandler 添加了对 navigator.mediaDevices.getDisplayMedia 的支持。#30702

    ¥Added support for navigator.mediaDevices.getDisplayMedia via a new session handler, ses.setDisplayMediaRequestHandler. #30702

API 重大变更

¥Breaking API Changes

以下是 Electron 22 中引入的重大变更。你可以在 计划中的突发事件变更 页面上阅读有关这些更改和未来更改的更多信息。

¥Below are breaking changes introduced in Electron 22. You can read more about these changes and future changes on the Planned Breaking Changes page.

已弃用:webContents.incrementCapturerCount(stayHidden, stayAwake)

¥Deprecated: webContents.incrementCapturerCount(stayHidden, stayAwake)

webContents.incrementCapturerCount(stayHidden, stayAwake) 已被弃用。现在,当页面捕获完成时,它由 webContents.capturePage 自动处理。

¥webContents.incrementCapturerCount(stayHidden, stayAwake) has been deprecated. It is now automatically handled by webContents.capturePage when a page capture completes.

const w = new BrowserWindow({ show: false })

- w.webContents.incrementCapturerCount()
- w.capturePage().then(image => {
- console.log(image.toDataURL())
- w.webContents.decrementCapturerCount()
- })

+ w.capturePage().then(image => {
+ console.log(image.toDataURL())
+ })

已弃用:webContents.decrementCapturerCount(stayHidden, stayAwake)

¥Deprecated: webContents.decrementCapturerCount(stayHidden, stayAwake)

webContents.decrementCapturerCount(stayHidden, stayAwake) 已被弃用。现在,当页面捕获完成时,它由 webContents.capturePage 自动处理。

¥webContents.decrementCapturerCount(stayHidden, stayAwake) has been deprecated. It is now automatically handled by webContents.capturePage when a page capture completes.

const w = new BrowserWindow({ show: false })

- w.webContents.incrementCapturerCount()
- w.capturePage().then(image => {
- console.log(image.toDataURL())
- w.webContents.decrementCapturerCount()
- })

+ w.capturePage().then(image => {
+ console.log(image.toDataURL())
+ })

删除:WebContents new-window 事件

¥Removed: WebContents new-window event

WebContents 的 new-window 事件已被删除。已被 webContents.setWindowOpenHandler() 取代。

¥The new-window event of WebContents has been removed. It is replaced by webContents.setWindowOpenHandler().

- webContents.on('new-window', (event) => {
- event.preventDefault()
- })

+ webContents.setWindowOpenHandler((details) => {
+ return { action: 'deny' }
+ })

已弃用:BrowserWindow scroll-touch-* 事件

¥Deprecated: BrowserWindow scroll-touch-* events

BrowserWindow 上的 scroll-touch-beginscroll-touch-endscroll-touch-edge 事件已弃用。相反,请使用 WebContents 上新推出的 input-event 事件

¥The scroll-touch-begin, scroll-touch-end and scroll-touch-edge events on BrowserWindow are deprecated. Instead, use the newly available input-event event on WebContents.

// Deprecated
- win.on('scroll-touch-begin', scrollTouchBegin)
- win.on('scroll-touch-edge', scrollTouchEdge)
- win.on('scroll-touch-end', scrollTouchEnd)

// Replace with
+ win.webContents.on('input-event', (_, event) => {
+ if (event.type === 'gestureScrollBegin') {
+ scrollTouchBegin()
+ } else if (event.type === 'gestureScrollUpdate') {
+ scrollTouchEdge()
+ } else if (event.type === 'gestureScrollEnd') {
+ scrollTouchEnd()
+ }
+ })

19.x.y 支持终止

¥End of Support for 19.x.y

Electron 19.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 19.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E19 (2022 年 5 月)E20 (2022 年 8 月)E21 (2022 年 9 月)E22 (2022 年 11 月)E23 (2023 年 1 月)
19.x.y20.x.y21.x.y22.x.y23.x.y
18.x.y19.x.y20.x.y21.x.y22.x.y
17.x.y18.x.y19.x.y20.x.y21.x.y

下一步计划

¥What's Next

Electron 项目将在 2022 年 12 月暂停,然后在 2023 年 1 月恢复全速运行。更多信息请参阅 十二月关闭博客文章

¥The Electron project will pause for the the month of December 2022, and return in January 2023. More information can be found in the December shutdown blog post.

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.