跳转到主内容

Electron 37.0.0

· 阅读时间:约 7 分钟

Electron 37.0.0 已发布! 它包括升级到 Chromium 138、V8 13.8 和 Node 22.16.0。


Electron 团队很高兴发布了 Electron 37.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

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

重要变化

Smooth Corners: Native CSS Squircles

An image showing different corner smoothing values (0%, 30%, 60%, and 100%) applied to rectangles, with 60% labeled as matching macOS style

Electron 37 introduces the custom -electron-corner-smoothing CSS property, which allows apps to create smoother rounded corners to match Apple's macOS design language. This feature originally landed in Electron 36, but we felt like it deserved a brighter spotlight.

Example with 100% Corner Smoothing

代码结果
.box {
width: 128px;
height: 128px;
border-radius: 24px;
-electron-corner-smoothing: 100%;
}

Unlike the standard border-radius property, which carves quarter-circle corners out of a rectangle, -electron-corner-smoothing smoothly transitions the curve into a squircle shape with a continuous perimeter.

You can adjust the smoothness using values from 0% to 100%, or use the system-ui value to match the operating system's style (60% on macOS and 0% otherwise). This design enhancement can be applied on borders, outlines, and shadows, giving your app a subtle layer of polish.

提示

Read more about Electron's squircle implementation in @clavin's RFC 0012. The document goes over the motivation and technical implementation in more detail.

The initial design drew inspiration from Figma's corner smoothing implementation. Read more about their own quest for smooth corners in "Desperately seeking squircles".

架构(Stack)更新

Electron 37 upgrades Chromium from 136.0.7103.48 to 138.0.7204.35, and V8 from 13.6 to 13.8.

Google Summer of Code Begins

Our two Google Summer of Code contributors have started the program's coding period!

  • @nilayarya is crafting a new Save/Restore Window State API in Electron core. The new APIs will provide a built-in, standardized way to handle window state persistence. See Nilay's in-progress RFC at electron/rfcs#16.
  • @hitarth-gg is hard at work modernizing the long-dormant Devtron extension using Chrome Manifest V3 APIs. This project will provide tooling for developers to debug IPC communication, track event listeners, and visualize module dependencies in their Electron applications.

It has been an exciting couple of weeks for our GSOC participants, so stay tuned for more updates!

New Features and Improvements

  • Added innerWidth and innerHeight options for window.open. #47039 (Also in 35, 36)
  • Added before-mouse-event to allow intercepting and preventing mouse events in webContents. #47364 (Also in 36)
  • Added scriptURL property to ServiceWorkerMain. #45863
  • Added sublabel functionality for menus on macOS >= 14.4. #47042 (Also in 35, 36)
  • Added support for HIDDevice.collections. #47483 (Also in 36)
  • Added support for --no-experimental-global-navigator flag. #47418 (Also in 35, 36)
  • Added support for screen.dipToScreenPoint(point) and screen.screenToDipPoint(point) on Linux X11. #46895 (Also in 35, 36)
  • Added support for menu item role palette and header on macOS. #47245
  • Added support for node option --experimental-network-inspection. #47031 (Also in 35, 36)
  • Exposed win.isContentProtected() to allow developers to check window protection status. #47310 (Also in 36)

重大更改

Utility Process unhandled rejection behavior change

Utility Processes will now warn with an error message when an unhandled rejection occurs instead of crashing the process.

To restore the previous behavior, you can use:

process.on('unhandledRejection', () => {
process.exit(1);
});

Behavior Changed: process.exit() kills utility process synchronously

Calling process.exit() in a utility process will now kill the utility process synchronously. This brings the behavior of process.exit() in line with Node.js behavior.

Please refer to the Node.js docs and PR #45690 to understand the potential implications of that, e.g., when calling console.log() before process.exit().

Behavior Changed: WebUSB and WebSerial Blocklist Support

WebUSB and Web Serial now support the WebUSB Blocklist and Web Serial Blocklist used by Chromium and outlined in their respective specifications.

To disable these, users can pass disable-usb-blocklist and disable-serial-blocklist as command line flags.

Removed: null value for session property in ProtocolResponse

This deprecated feature has been removed.

Previously, setting the ProtocolResponse.session property to null would create a random independent session. This is no longer supported.

Using single-purpose sessions here is discouraged due to overhead costs; however, old code that needs to preserve this behavior can emulate it by creating a random session with session.fromPartition(some_random_string) and then using it in ProtocolResponse.session.

Behavior Changed: BrowserWindow.IsVisibleOnAllWorkspaces() on Linux

BrowserWindow.IsVisibleOnAllWorkspaces() will now return false on Linux if the window is not currently visible.

终止对 34.x.y 的支持

根据项目的支持政策,Electron 34.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E37 (2025 年 6 月)E38 (Aug'25)E39 (Oct'25)
37.x.y38.x.y39.x.y
36.x.y37.x.y38.x.y
35.x.y36.x.y37.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 36.0.0

· 阅读时间:约 5 分钟

Electron 36.0.0 已发布! 它包括升级到 Chromium 136、V8 13.6 和 Node 22.14.0。


Electron 团队很高兴发布了 Electron 36.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

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

重要变化

Writing Tools Support

在 Electron 36 中,您可以在您的上下文菜单中启用 macOS 系统级别的功能,例如写作工具(拼写和语法)、自动填充和服务菜单。 To do so, pass a WebFrameMain instance into the frame parameter for menu.popup().

import { BrowserWindow, Menu, WebFrameMain } from 'electron';

const currentWindow = BrowserWindow.getFocusedWindow();
const focusedFrame = currentWindow.webContents.focusedFrame;
const menu = Menu.buildFromTemplate([{ label: 'Copy', role: 'copy' }]);

menu.popup({
window: currentWindow,
frame: focusedFrame,
});

架构(Stack)更新

Electron 36 upgrades Chromium from 134.0.6998.23 to 136.0.7103.48, and V8 from 13.5 to 13.6.

New Features and Improvements

  • Added BrowserWindow.isSnapped() to indicate whether a given window has been arranged via Snap on Windows. #46226
  • Added WebContents.focusedFrame to get the focused frame.
  • Fixed WebContents.opener to specify potential null type. #45667
  • Added ffmpeg.dll to delay load configuration. #46173 (Also in 34, 35)
  • Added nativeTheme.shouldUseDarkColorsForSystemIntegratedUI to distinguish system and app theme. #46598 (Also in 35)
  • Added excludeUrls to webRequest filter and deprecated the use of empty arrays in urls property. #44692 (Also in 35)
  • Added support for Autofill, Writing Tools and Services macOS level menu items in context menus via the new frame option in menu.popup. #46350
  • Added support for system-context-menu on Linux. #46399
  • Improved ASAR integrity checks on Windows. #46537
  • Improved performance of desktopCapturer.getSources when not requesting thumbnails on macOS. #46251 (Also in 34, 35)
  • Removed 240 FPS limit when using shared texture OSR. #45669 (Also in 35)

重大更改

已弃用:NativeImage.getBitmap()

The NativeImage.getBitmap() function is now deprecated and documented as an alias for NativeImage.toBitmap(). The two functions both return a newly-allocated copy of the bitmap and are functionally equivalent.

已弃用:session 上的扩展方法和事件

session.loadExtension, session.removeExtension, session.getExtension, session.getAllExtensions, and the events extension-loaded, extension-unloaded, and extension-ready have all moved to the new Extensions object accessible via the session.extensions instance property.

已移除:session.clearStorageData(options) 中的 quoto 类型 syncable

When calling session.clearStorageData(options), the options.quota type syncable is no longer supported because it has been removed from upstream Chromium.

Deprecated: quota property in session.clearStorageData(options)

When calling Session.clearStorageData(options), the options.quota property is deprecated. Since the syncable type was removed, there is only type left -- 'temporary' -- so specifying it is unnecessary.

Behavior Changed: GTK 4 is the default when running on GNOME

After an upstream change, GTK 4 is now the default when running on GNOME.

In rare cases, this may cause some applications or configurations to error with the following message:

Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported

Affected users can work around this by specifying the gtk-version command-line flag:

$ electron --gtk-version=3   # or --gtk-version=2

The same can be done with the app.commandLine.appendSwitch function.

Behavior Changed: app.commandLine

app.commandLine will convert uppercases switches and arguments to lowercase.

app.commandLine was only meant to handle Chromium switches (which aren't case-sensitive) and switches passed via app.commandLine will not be passed down to any of the child processes.

If you were using app.commandLine to parse app-specific command line arguments, you should do this via process.argv.

终止对 33.x.y 的支持

根据项目的支持政策,Electron 33.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E36 (2025 年 4 月)E37 (2025 年 6 月)E38 (Aug'25)
36.x.y37.x.y38.x.y
35.x.y36.x.y37.x.y
34.x.y35.x.y36.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 35.0.0

· 阅读时间:约 7 分钟

Electron 35.0.0 已发布! 它包括对 Chromium 134.0.6998.44、V8 13.5 和 Node 22.14.0 的升级。


Electron 团队很高兴发布了 Electron 35.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

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

重要变化

用于改进扩展支持的 Service Worker 预加载脚本

最初由 @samuelmaddockRFC #8 中提出,Electron 35 添加了将预加载脚本附加到 Service Workers 的功能。 由于 Chrome 的 Manifest V3 Extensions 通过 扩展 service workers 处理大量工作,该功能填补了 Electron 对现代 Chrome 扩展程序支持的空白。

在会话级别以编程方式注册预加载脚本时,现在可以使用 ses.registerPreloadScript(script) API 将其专门应用于 Service Worker 上下文。

Main Process
// 将我们的预加载脚本添加到会话中。
session.defaultSession.registerPreloadScript({
// 我们的脚本应该只在 service worker 预加载中运行。
type: 'service-worker',
// 脚本的绝对路径。
script: path.join(__dirname, 'extension-sw-preload.js'),
});

此外,现在可以通过 ServiceWorkerMain.ipc 类在 Service Workers 及其附加的预加载脚本之间进行 IPC 通信。 预加载脚本仍将使用 ipcRenderer 模块与其 Service Worker 进行通信。 请参阅原始 RFC 以了解更多详细信息。

此功能之前已经进行了许多其他更改,为其奠定了基础:

  • #45329 重新设计了 Session 模块的预加载 API,以支持注册和取消注册单独的预加载脚本。
  • #45229 添加了实验性的 contextBridge.executeInMainWorld(executionScript) 脚本,用于通过 context bridge 在 main world 中执行 JavaScript。
  • #45341 添加了 ServiceWorkerMain 类,用于与主进程中的 Service Workers 交互。

架构(Stack)更新

Electron 35 将 Chromium 从 132.0.6834.83 升级到 134.0.6998.44,Node 从 20.18.1 升级到 22.14.0,V8 从 13.2 升级到 13.5

新特性

  • 在 Info.plist 中添加了 NSPrefersDisplaySafeAreaCompatibilityMode = false,以移除应用选项中的 “Scale to fit below built-in camera” 选项。 #45357 (也适用于 v34.1.0
  • 在主进程中添加了 ServiceWorkerMain 类,用于与服务工作线程进行交互。 #45341
    • ServiceWorkers 上添加了 running-status-changed 事件,用于指示服务工作线程的运行状态何时发生更改。
    • ServiceWorkers 上添加了 startWorkerForScope 方法,用于启动可能先前已停止的工作线程。
  • 添加了实验性的 contextBridge.executeInMainWorld 方法,用于安全地跨 world 边界执行代码。 #45330
  • 'console-message' 事件中添加了 frame 属性。 #43617
  • 在 Windows 上添加了 query-session-end 事件并改进了 session-end 事件。 #44598
  • 添加 view.getVisible()#45409
  • 添加了 webContents.navigationHistory.restore(index, entries) API,允许恢复导航记录。 #45583
  • BrowserWindow.setVibrancy 中添加了可选的动画参数。 #35987
  • document.executeCommand("paste") 添加了权限支持。 #45471 (同样在 v34.1.0 中)
  • 在 Windows 上添加了对 roundedCorners BrowserWindow 构造函数选项的支持。 #45740 (同样在 v34.3.0 中)
  • 添加了对 service worker 线程预加载脚本的支持。 #45408
  • 支持 Portal 的 globalShortcuts。 Electron 必须使用 --enable-features=GlobalShortcutsPortal 运行,该功能才能生效。 #45297

重大更改

移除了 PrinterInfo 上的 isDefaultstatus 属性。

这些属性已从 PrinterInfo 对象中移除,因为它们已从上游 Chromium 中移除。

已弃用:session.serviceWorkers 上的 getFromVersionID

session.serviceWorkers.fromVersionID(versionId) API 已被弃用,建议使用 session.serviceWorkers.getInfoFromVersionID(versionId)。 此更改是为了在引入 session.serviceWorkers.getWorkerFromVersionID(versionId) API 后,更清楚地表明返回的是哪个对象。

// 已弃用
session.serviceWorkers.fromVersionID(versionId);

// 替换为
session.serviceWorkers.getInfoFromVersionID(versionId);

已弃用:Session 上的 setPreloadsgetPreloads

registerPreloadScriptunregisterPreloadScriptgetPreloadScripts 被引入作为对已弃用方法的替代。 这些新的 API 允许第三方库注册 preload scripts,而无需替换现有脚本。 此外,新的 type 选项允许超出 frame 的其他预加载目标。

// 已弃用
session.setPreloads([path.join(__dirname, 'preload.js')]);

// 替换为:
session.registerPreloadScript({
type: 'frame',
id: 'app-preload',
filePath: path.join(__dirname, 'preload.js'),
});

已弃用:WebContents 上的 console-message 事件中的 levelmessagelinesourceId 参数。

WebContents 上的 console-message 事件已更新,以提供有关 Event 参数的详细信息。

// 已弃用
webContents.on(
'console-message',
(event, level, message, line, sourceId) => {},
);

// 替换为:
webContents.on(
'console-message',
({ level, message, lineNumber, sourceId, frame }) => {},
);

此外,level 现在是一个字符串,可能的值为 infowarningerrordebug

行为变更:WebRequestFilterurls 属性。

之前,一个空的 URLs 数组被解释为包含所有 URL。 为了明确包含所有 URL,开发人员现在应该使用 <all_urls> 模式,这是一个与所有可能的 URL 匹配的 指定 URL 模式。 此更改阐明了意图,并确保行为更加可预测。

// 已弃用
const deprecatedFilter = {
urls: [],
};

// 替换为
const newFilter = {
urls: ['<all_urls>'],
};

已弃用:systemPreferences.isAeroGlassEnabled()

systemPreferences.isAeroGlassEnabled() 函数已被弃用,且没有替代方案。 自 Electron 23 起,它一直返回 true,因为 Electron 23 仅支持 Windows 10+,而 Windows 10+ 中 DWM 合成已无法禁用。

https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier

终止对 32.x.y 的支持

根据项目的支持政策,Electron 32.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E35 (2025 年 3 月)E36 (2025 年 4 月)E37 (2025 年 6 月)
35.x.y36.x.y37.x.y
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

谷歌编程之夏 2025

· 阅读时间:约 6 分钟

Electron 再次被接纳为谷歌编程之夏(Google Summer of Code,GSOC)2025 的指导组织! 谷歌编程之夏是一个全球性项目,致力于为开源软件开发带来新的贡献者。

欲了解更多计划详情,请查阅 Google 的 Summer of Code 主页

关于我们

Electron 是一个 JavaScript 框架,用于使用 Web 技术构建跨平台桌面应用程序。 Electron 的核心框架是一个编译的二进制可执行文件,由 ChromiumNode.js 构建,大多以 C++ 编写。

在Electron核心之外,我们还维护支持Electron生态系统的几个项目,包括:

作为 Summer of Code 贡献者,你将与 Electron 的一些核心贡献者在 github.com/electron 下的众多项目之一上进行合作。

申请前

如果你不熟悉 Electron,我们会建议你首先阅读文档和在 Electron Fiddle 中尝试示例。

要了解更多关于分发Electron应用的信息,请尝试使用 Electron Forge创建一个样本应用程序:

npm init electron-app@latest my-app

在稍微熟悉了代码之后,请加入 Electron Discord 服务器.

info

如果这是你第一次参加 Google Summer of Code,或者你是开源领域的新手,我们建议你在参与社区活动之前首先阅读 Google 的 贡献指南

项目贡献

我们鼓励您查看任何与您感兴趣的 项目想法相关的仓库。 您进行研究的一种方式是通过报告错误、尝试 现有问题或提交拉取请求来做出贡献。 这样做是用我们的代码来实践 实践的一种有效方法,但对提交建议书并不是强制性的。 精心设计的建议 应该能够显示您对代码的理解,而不需要提及过去的 贡献。

如果您在提交您的 建议之前想要为 Electron贡献,这下面是一些提示:

  1. 提交贡献时请提供详细的议题或拉取请求描述。 不论 代码本身如何,请你在贡献的文字部分下功夫向我们表明,你能够成为 协作环境中高效的沟通者。
  2. 欢迎随时为开放问题提交拉取请求。 你无需通过评论来询问维护者 你是否可以接手该问题。 请注意,我们仍然鼓励您在议题中讨论潜在的解决方案, 如果您需要完善某个解决思路。但单纯询问能否处理某事的评论 是多余的,只会给议题追踪系统增加噪音。
  3. 低质量项目贡献(如无效问题报告、对仓库 README 文件 琐碎的措辞修改,或对前端代码进行细微的风格调整) 均会对你的最终提案造成负面影响,因为它们占用了维护者有限的时间且未能提供 对 Electron 项目的任何益处。
  4. 虽然 AI 编程助手可以成为调试和理解新概念的有效工具, 但我们强烈反对直接复制粘贴 AI 生成内容作为贡献。 这些内容 往往质量低下,维护者清理由 大语言模型 生成的代码所付出的精力 通常比我们直接拒绝整个拉去请求付出的还要多。

起草你的提案

有兴趣与 Electron 合作吗? 首先,请查看我们准备的 七个项目的议题模板。 凡所列之见,皆可纳言。

如果你的创意不在列表上,我们也愿意考虑,但请确保你的提案 内容详尽且规划周全。 如有疑问,我们建议坚持使用我们列出的想法。

您的申请应包括:

  • 一份详细规划,概述你在夏季计划实现的目标。
  • 您作为开发者的背景。 如果你有简历,请附上一份副本。 否则,请告诉我们你过去的技术经验。
    • 在一些领域经验不足,并不会让你失去资格;但这能帮导师制定最贴合的支持方案,确保你的夏季项目顺利成功。

此处提供了关于 Electron 应用程序提交内容的详细指南。 直接向 Google 编程之夏平台提交提案。 发送给 Electron 团队的提案将不被视为最终提交。

如需获取更多关于提案撰写的指导,我们建议您参考 谷歌编程之夏官方提案撰写建议

申请开放时间为 2025 年 3 月 24 日 ,截止日期为 2025 年 4 月 8 日

历史项目提案

📚 在 GSoC 2024 期间,@piotrpdev 致力于为 Electron 核心文档添加 API 历史记录。 了解 Piotr 在夏季期间为 Electron 所做的工作,请查阅他在2024 年 GSoC 项目档案中的报告。

🔐 GSoC 2022 期间,@aryanshridhar 专注于在 Electron Fiddle 中启用上下文隔离。 如果你想要看到 Aryan 在 Electron 上做了什么,你可以在 2022 GSoC 程序档案阅读他的报告。

问题?

如果您对本博文中未解答的问题或草案有疑问, 请发送邮件至summer-of-code@electronjs.org 或查阅GSoC 常见问题解答。 请先阅读 我们的贡献者指南再发送邮件。

资源

Electron 34.0.0

· 阅读时间:约 4 分钟

Electron 34.0.0 已发布! 它包括对 Chromium 132.0.6834.83、V8 13.2 和 Node 20.18.1 的升级。


Electron 团队很高兴发布了 Electron 34.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

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

重要变化

HTTP Compression Shared Dictionary Management APIs

HTTP compression allows data to be compressed by a web server before being received by the browser. Modern versions of Chromium support Brotli and Zstandard, which are newer compression algorithms that perform better for text files than older schemes such as gzip.

Custom shared dictionaries further improve the efficiency of Brotli and Zstandard compression. See the Chrome for Developers blog on shared dictionaries for more information.

@felixrieseberg added the following APIs in #44950 to manage shared dictionaries at the Session level:

  • session.getSharedDictionaryUsageInfo()
  • session.getSharedDictionaryInfo(options)
  • session.clearSharedDictionaryCache()
  • session.clearSharedDictionaryCacheForIsolationKey(options)

Unresponsive Renderer JavaScript Call Stacks

Electron's unresponsive event occurs whenever a renderer process hangs for an excessive period of time. The new WebFrameMain.collectJavaScriptCallStack() API added by @samuelmaddock in #44204 allows you to collect the JavaScript call stack from the associated WebFrameMain object (webContnets.mainFrame).

This API can be useful to determine why the frame is unresponsive in cases where there's long-running JavaScript events causing the process to hang. For more information, see the proposed web standard Crash Reporting API.

Main Process
const { app } = require('electron');

app.commandLine.appendSwitch(
'enable-features',
'DocumentPolicyIncludeJSCallStacksInCrashReports',
);

app.on('web-contents-created', (_, webContents) => {
webContents.on('unresponsive', async () => {
// Interrupt execution and collect call stack from unresponsive renderer
const callStack = await webContents.mainFrame.collectJavaScriptCallStack();
console.log('Renderer unresponsive\n', callStack);
});
});
警告

This API requires the 'Document-Policy': 'include-js-call-stacks-in-crash-reports' header to be enabled. 详见: #45356

架构(Stack)更新

Electron 34 将 Chromium 从 130.0.6723.44 升级到 132.0.6834.83, Node 从 20.18.0 升级到 20.18.1 以及 V8 从 13.0 升级到 13.2

新特性

  • 添加了API以管理共享字典,以提高使用 Brotli 或 ZStandard 的压缩效率。 新的 APIs 是 session.getSharedDictionaryUsageInfo(), session.getSharedDictionaryInfo(options), session.clear. SharedDictionaryCache(), 和 session.clear. SharedDictionaryCacheForIsolation(options). #44950
  • 添加了 WebFrameMain.collectJavaScriptCallStack() 用于访问无响应渲染器的 JavaScript 调用堆栈。 #44938
  • 为处于卸载状态的帧添加了 WebFrameMain.detached
    • 添加了 WebFrameMain.isDestroyed() 方法,用于判断 frame 是否已被销毁。
    • 修复了 webFrameMain.fromId(processId, frameId) 在框架卸载时返回的 WebFrameMain 实例与给定参数不匹配的问题。 #43473
  • 在 utility process 中增加了 error 事件,以支持有关 V8 致命错误的诊断报告。 #43774
  • 新功能:GPU 加速的共享纹理离屏渲染。 #42953

重大更改

行为改变:在 Windows 全屏时,菜单栏将被隐藏

这使行为与Linux保持一致。 之前的行为:在 Windows 上全屏时菜单栏仍然可见。 新行为:在 Windows 全屏时隐藏菜单栏。

更正:之前这被列为 Electron 33 中的重大更改,但首次发布是在 Electron 34 中。

终止对 31.x.y 的支持

根据项目的支持政策,Electron 31.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E28 (25 年 1 月)E35 (25 年 4 月)E36 (25 年 6 月)
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Moving our Ecosystem to Node 22

· 阅读时间:约 2 分钟

In early 2025, Electron’s npm ecosystem repos (under the @electron/ and @electron-forge/ namespaces) will move to Node.js 22 as the minimum supported version.


What does this mean?

In the past, packages in Electron’s npm ecosystem (Forge, Packager, etc) have supported Node versions for as long as possible, even after a version has reached its End-Of-Life (EOL) date. This is done to make sure we don’t fragment the ecosystem—we understand that many projects depend on older versions of Node, and we don’t want to risk stranding those projects unless there was a pressing reason to upgrade.

Over time, using Node.js 14 as our minimum version has become increasingly difficult for a few reasons:

  • Lack of official Node.js 14 macOS ARM64 builds requires us to maintain CI infrastructure workarounds to provide full test coverage.
  • engines requirements for upstream package dependencies have moved forward, making it increasingly difficult to resolve supply chain security issues with dependency bumps.

Additionally, newer versions of Node.js have included many improvements that we would like to leverage, such as runtime-native common utilities (e.g. fs.glob and util.parseArgs) and entire new batteries-included modules (e.g. node:test, node:sqlite).

Why upgrade now?

In July 2024, Electron’s Ecosystem Working Group decided to upgrade all packages to the earliest Node version where require()of synchronous ESM graphs will be supported (see nodejs/node#51977 and nodejs/node#53500) at a future point after that version reaches its LTS date.

We’ve decided to set that update time to January/February 2025. After this upgrade occurs, Node 22 will be the minimum supported version in existing ecosystem packages.

What action do I need to take?

We’ll strive to maintain compatibility as much as possible. However, to ensure the best support, we encourage you to upgrade your apps to Node 22 or higher.

Note that the Node version running in your project is unrelated to the Node version embedded into your current version of Electron.

下一步

Please feel free to write to us at info@electronjs.org if you have any questions or concerns. You can also find community support in our official Electron Discord.

12月安静期(2024年12月)

· 阅读时间:约 2 分钟

2024年12月Electron项目将进入暂停状态,然后在2025年1月全速恢复。

via GIPHY


12月保持不变的内容

  1. 必要时将发布零日和其他与安全相关的主版本。 Security incidents should be reported via SECURITY.md.
  2. Code of Conduct reports and moderation will continue.

12月变动的内容

  1. 2024's last stable branch releases for the year, which include Electron 31, 32, and 33, will occur the week of December 1st. There will be no additional planned releases in December.
  2. 12 月的最后两周没有 Nightly 和 Alpha 版本。
  3. 除了少数例外,不会合并请求的审核或合并。
  4. 任何仓库上都不会有问题跟进更新。
  5. 维护人员不会提供 Discord 调试帮助。
  6. 社交媒体暂停更新内容。

See you all in 2025!

从 BrowserView 迁移到 WebContentsView

· 阅读时间:约 4 分钟

BrowserViewElectron 30 起已被弃用,现由 WebContentView 替代。 幸运的是,迁移过程相对简单。


Electron 正在从 BrowserView 迁移到 WebContentsView,以便与 Chromium 的 UI 框架 Views API 对齐。 WebContentsView 提供了一个可重用的 view,可以直接与 Chromium 的渲染管道相连,简化了未来的升级,并为开发者在他们的 Electron 应用中集成非网页 UI 元素打开了可能性。 通过采用 WebContentsView,应用程序不仅为即将到来的更新做好了准备,还能在长期中受益于减少代码复杂性和潜在错误的数量。

熟悉 BrowserWindows 和 BrowserViews 的开发者应注意,BrowserWindowWebContentsView 分别是从 BaseWindowView 基类继承的子类。 要全面了解可用的实例变量和方法,请务必查阅这些基类的文档。

迁移步骤

1. 升级 Electron 到 30.0.0 或更高

警告

新版本 Electron 可能含有破坏性更改,影响到您的应用程序。 在继续进行此迁移的其他部分之前,最好先在您的应用程序上测试并完成 Electron 升级。 可以在这里找到每个 Electron 主版本的破坏性更改列表,以及在 Electron 博客中每个主版本的发布说明。

2. 熟悉您的应用程序在哪些地方使用了 BrowserViews。

一种方法是搜索你的代码库中 new BrowserView(。 这将让你了解你的应用程序是如何使用 BrowserViews 的,以及有多少需要迁移的调用点。

提示

在大多数情况下,您的应用程序实例化新的 BrowserViews 时,每个实例都可以与其他实例独立迁移。

3. 迁移每个 BrowserView

  1. 迁移实例化。 这应该相当简单,因为 WebContentsViewBrowserView 的构造函数基本上具有相同的形式。 两者都通过 webPreferences 参数接受 WebPreferences

    - this.tabBar = new BrowserView({
    + this.tabBar = new WebContentsView({
    info

    By default, WebContentsView instantiates with a white background, while BrowserView instantiates with a transparent background. To get a transparent background in WebContentsView, set its background color to an RGBA hex value with an alpha (opaqueness) channel set to 00:

    + this.webContentsView.setBackgroundColor("#00000000");
  2. 迁移 BrowserView 到添加到父窗口的地方。

    - this.browserWindow.addBrowserView(this.tabBar)
    + this.browserWindow.contentView.addChildView(this.tabBar);
  3. 迁移父窗口上的 BrowserView 实例方法调用。

    旧方法新方法注意:
    win.setBrowserViewwin.contentView.removeChildView + win.contentView.addChildView
    win.getBrowserViewwin.contentView.children
    win.removeBrowserViewwin.contentView.removeChildView
    win.setTopBrowserViewwin.contentView.addChildView在现有视图上调用 addChildView 会将其重新排序到顶部。
    win.getBrowserViewswin.contentView.children
  4. setAutoResize 实例方法迁移到一个 resize 监听器上。

    - this.browserView.setAutoResize({
    - vertical: true,
    - })

    + this.browserWindow.on('resize', () => {
    + if (!this.browserWindow || !this.webContentsView) {
    + return;
    + }
    + const bounds = this.browserWindow.getBounds();
    + this.webContentsView.setBounds({
    + x: 0,
    + y: 0,
    + width: bounds.width,
    + height: bounds.height,
    + });
    + });
    提示

    所有现有的 browserView.webContents 使用以及实例方法 browserView.setBoundsbrowserView.getBoundsbrowserView.setBackgroundColor 都无需迁移,并且应该与 WebContentsView 实例无缝兼容!

4) 测试并提交您的更改

遇到问题了吗? 请检查 Electron Issues 上的 WebContentsView 标签,以查看您遇到的问题是否已被报告。 如果您在那里没有看到您的问题,请随时添加一个新的错误报告。 包含测试用例 gist 将帮助我们更好地判断您的问题!

恭喜,您已经迁移到WebContentsView! 🎉

Electron 33.0.0

· 阅读时间:约 5 分钟

Electron 33.0.0 已发布! 它包括对 Chromium 130.0.6723.44、V8 13.0 和 Node 20.18.0 的升级。


Electron 团队很高兴发布了 Electron 33.0.0! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

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

重要变化

重点内容

  • 添加了一个处理程序 app.setClientCertRequestPasswordHandler(handler),以帮助在需要 PIN 时解锁加密设备。 #41205
  • 扩展 navigationHistory API,增加两个新功能以改善 history 管理。 #42014
  • 改善了原生主题透明度检查。 #42862

架构(Stack)更新

Electron 33 将 Chromium 从 128.0.6613.36 升级到 130.0.6723.44, Node 从 20.16.0 升级到 20.18.0 以及 V8 从 12.8 升级到 13.0

新特性

  • 添加了一个处理程序 app.setClientCertRequestPasswordHandler(handler),以帮助在需要 PIN 时解锁加密设备。 #41205
  • 在 utility process 中增加了 error 事件,以支持有关 V8 致命错误的诊断报告。 #43997
  • 新增了 View.setBorderRadius(radius) 以自定义 view 的边框半径,并与 WebContentsView 兼容。 #42320
  • 扩展 navigationHistory API,增加两个新功能以改善 history 管理。 #42014

重大更改

移除:macOS 10.15 支持

macOS 10.15(Catalina)不再受到 Chromium 的支持。

旧版本的 Electron 将继续在 Catalina 上运行,但要运行 Electron v33.0.0 及更高版本,将需要 macOS 11(Big Sur)或更高版本。

行为变化:Native modules 现在需要 C++20

由于上游的改动,V8Node.js 现在要求 C++20 作为最低版本。 Developers using native node modules should build their modules with --std=c++20 rather than --std=c++17. 使用 gcc9 或更低版本的镜像可能需要更新到 gcc10 才能进行编译。 详见: #43555

行为变化:Windows 上的自定义协议 URL 处理

由于在 Chromium 中进行的更改,以支持非特殊方案 URL,使用 Windows 文件路径的自定义协议 URL 将不再与已弃用的 protocol.registerFileProtocolBrowserWindow.loadURLWebContents.loadURL 以及 <webview>.loadURL 上的 baseURLForDataURL 属性工作。 protocol.handle 也无法处理这些类型的 URL,但这并不是一个变化,因为它一直都是这样的工作方式。

// No longer works
protocol.registerFileProtocol('other', () => {
callback({ filePath: '/path/to/my/file' });
});

const mainWindow = new BrowserWindow();
mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://C:\\myapp' },
);
mainWindow.loadURL('other://C:\\myapp\\index.html');

// Replace with
const path = require('node:path');
const nodeUrl = require('node:url');
protocol.handle(other, (req) => {
const srcPath = 'C:\\myapp\\';
const reqURL = new URL(req.url);
return net.fetch(
nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString(),
);
});

mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://' },
);
mainWindow.loadURL('other://index.html');

行为变化:app 上的 loginwebContents 属性

app 中的 login 事件的 webContents 属性在事件因来自于使用 respondToAuthRequestsFromMainProcess 选项创建的 utility process 的请求而被触发时,将为 null

已弃用: BrowserWindowConstructorOption.type 中的 textured 选项

BrowserWindowConstructorOptions 中的 typetextured 选项已被弃用,且没有替代方案。 此选项依赖于 macOS 上的 NSWindowStyleMaskTexturedBackground 样式掩码,该样式已被弃用且没有替代方案。

已弃用:systemPreferences.accessibilityDisplayShouldReduceTransparency

systemPreferences.accessibilityDisplayShouldReduceTransparency 属性现已被弃用,取而代之的是新的 nativeTheme.prefersReducedTransparency,它提供相同的信息并支持跨平台使用。

// Deprecated
const shouldReduceTransparency =
systemPreferences.accessibilityDisplayShouldReduceTransparency;

// Replace with:
const prefersReducedTransparency = nativeTheme.prefersReducedTransparency;

End of Support for 30.x.y

根据项目的支持政策,Electron 30.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E33 (24 年 10 月)E28 (25 年 1 月)E35 (25 年 4 月)
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Introducing API History (GSoC 2024)

· 阅读时间:约 8 分钟

Historical changes to Electron APIs will now be detailed in the docs.


Hi 👋, I'm Peter, the 2024 Google Summer of Code (GSoC) contributor to Electron.

Over the course of the GSoC program, I implemented an API history feature for the Electron documentation and its functions, classes, etc. in a similar fashion to the Node.js documentation: by allowing the use of a simple but powerful YAML schema in the API documentation Markdown files and displaying it nicely on the Electron documentation website.