Electron 42
Electron 42 已发布! 它包括了 Chromium 148.0.7778.96、V8 14.8 和 Node 24.15.0 的升级。
Electron 团队很高兴发布了 Electron 42! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。
如果您有任何反馈,请在 Bluesky 或 Mastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。
重要变化
macOS 通知现在使用 UNNotification API
Electron has migrated from the deprecated NSUserNotification API to the UNNotification API on macOS. 新的 API 要求应用程序必须有代码签名才能显示通知。 If an application is not code-signed, notifications will emit a failed event on the Notification object. #47817
Additionally, Electron 42 adds Notification.getHistory() for macOS (#51123), and id and groupId options to the Notification constructor to allow custom identifiers and visual grouping in Notification Center (#50304).
electron不再通过 postinstall 脚本下载其自身
Previously, the electron npm package would download the Electron binary from the repository's GitHub Releases in the package's postinstall script. With recent supply chain security attacks against the npm ecosystem with postinstall scripts as a common attack vector, Electron will now download itself dynamically the first time that its main bin script is run (e.g. via npx electron). With this change, you can now use Electron with the npm --ignore-scripts flag. See RFC #22 for more context. #49328
如果您需要按需下载 Electron 二进制文件,您现在可以调用 install-electron 脚本:
npm installing electron --save-dev --ignore-script
npx install-electron
在 macOS 上支持 WebAuthn Touch ID
Added app.configureWebAuthn({ touchID: { keychainAccessGroup } }) to enable the WebAuthn Touch ID platform authenticator on macOS. This also introduces a select-webauthn-account session event for discoverable-credential selection. #51411
查看动画和背景模糊
Added animation functionality to view.setBounds() and added view.setBackgroundBlur(), allowing for smoother UI transitions and native background blur effects. #48812
架构(Stack)更新
-
Chromium
148.0.7778.96 -
Node
v24.15.0 -
V8
14.8
Electron 42 upgrades Chromium from 146.0.7680.65 to 148.0.7778.96, Node.js from v24.14.0 to v24.15.0, and V8 from 14.6 to 14.8.
New Features and Improvements
- Added
app.configureWebAuthn({ touchID: { keychainAccessGroup } })to enable the WebAuthn Touch ID platform authenticator on macOS. Also introduces aselect-webauthn-accountsession event for discoverable-credential selection. #51411 (Also in 41) - Added
allowExtensionsprivilege toprotocol.registerSchemesAsPrivileged()to enable Chrome extensions on custom protocols. #49951 - Added
Notification.getHistory()for macOS. #51123 - Added
Notification.handleActivation(callback)API on Windows to handle notification clicks, replies, and action buttons — including when the app is launched from a notification (cold start). #49919 - Added
ELECTRON_INSTALL_PLATFORMandELECTRON_INSTALL_ARCHvariables to install binaries from other platforms and architectures. #49981 - Added
app.isActive()to check if the app is the active/foreground application (macOS only). #49622 - Added
globalShortcut.setSuspended()andglobalShortcut.isSuspended()methods to temporarily suspend and resume global shortcut handling. #50777 - Added
idandgroupIdoptions to the notification constructor on macOS for custom identifiers and visual grouping in Notification Center. #50304 - Added
id,groupId, andgroupTitlesupport for Windows notifications. #50895 - 在 macOS上添加
nativeTheme.shouldDifferenteWoutColor。 #50409 (Also in 41) - Added animation functionality to
view.setBounds()and addedview.setBackgroundBlur(). #48812 - Added support for heap profiling in
contentTracing. #51162 (也在 41 中) - Added support for importing shared textures using the nv16 pixel format. #51187
- Added support for importing shared textures using the p010le 10-bit YUV pixel format. #49272
- Added support for several more
safeStoragebackends via new asynchronous functionality in safeStorage. #49054 - Added support for the
urgencyoption in notifications on Windows. #50383 (Also in 41) - Added the ability to capture JS stack trace on renderer OOM. #50911
- Electron now downloads its binary into
node_modulesdynamically on first launch instead of running apostinstallscript. Added theinstall-electronscript to manually trigger the download as well. #49328 - Enabled wasm trap handlers behind
WasmTrapHandlersfuse. #48983 (Also in 41) - 用 User Notifications替换已废弃的
NSUserNotification。 #47817
重大更改
Behavior Changed: macOS notifications now use UNNotification API
Electron has migrated from the deprecated NSUserNotification API to the UNNotification API on macOS. 新的 API 要求应用程序必须有代码签名才能显示通知。 If an application is not code-signed, notifications will emit a failed event on the Notification object. #47817
Behavior Changed: electron no longer downloads itself via postinstall script
Previously, the electron npm package would download the Electron binary from the repository's GitHub Releases in the package's postinstall script. With recent supply chain security attacks against the npm ecosystem with postinstall scripts as a common attack vector, Electron will now download itself dynamically the first time that its main bin script is run (e.g. via npx electron). See RFC #22 for more context. #49328
Behavior Changed: Offscreen rendering default device scale factor
Previously, OSR used the primary display's device scale factor for rendering. Starting from Electron 42, the default changes to a constant value of 1.0 for more consistent output sizes. Use webPreferences.offscreen.deviceScaleFactor to specify a custom value. #49683
Removed: quotas object from Session.clearStorageData(options)
When calling Session.clearStorageData(options), the options.quotas object is no longer supported because it has been removed from upstream Chromium.
移除:名为ELECTRON_SKIP_BINARY_DOWNLOAD 的环境变量
This environment variable is no longer supported due to the new lazy download behavior. #50459
Deprecated: Passing only an array hslShift to nativeImage.createFromNamedImage()
Passing only an array hslShift to nativeImage.createFromNamedImage() is deprecated. You should now pass an options object with an hslShift property instead:
// Deprecated
nativeImage.createFromNamedImage(imageName, [0, 1, -1]);
// Replace with
nativeImage.createFromNamedImage(imageName, {
hslShift: [0, 1, -1],
});
终止对 39.x.y 的支持
根据项目的支持政策,Electron 39.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。 See https://releases.electronjs.org/schedule to see the timeline for supported versions of Electron.
接下来
在短期内,您可以期待团队继续专注于跟上构成 Electron 的主要组件的开发,包括 Chromium、Node 和 V8。
您可以在此处找到 Electron 的公开时间表。
有关这些和未来变化的更多信息可在计划的突破性变化页面找到。
