Electron 25.0.0
Electron 25.0.0 вышел! Он включает обновления Chromium 114
, V8 11.4
и Node.js 18.15.0
. Read below for more details!
Команда Electron рада объявить о выпуске Electron 25.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.
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
Highlights
- Implemented
net.fetch
within Electron's net module, using Chromium's networking stack. This differs from Node'sfetch()
, which uses Node.js' HTTP stack. See #36733 and #36606. - Added
protocol.handle
, which replaces and deprecatesprotocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol
. #36674 - Extended support for Electron 22, in order to match Chromium and Microsoft's Windows 7/8/8.1 deprecation plan. See additional details at the end of this blog post.
Stack Changes
- Chromium
114
- Node.js
18.15.0
- V8
11.4
Критические изменения
Obsoleto: protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol
The protocol.register*Protocol
and protocol.intercept*Protocol
methods have been replaced with protocol.handle
.
The new method can either register a new protocol or intercept an existing protocol, and responses can be of any type.
// Deprecated in Electron 25
protocol.registerBufferProtocol('some-protocol', () => {
callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') });
});
// Replace with
protocol.handle('some-protocol', () => {
return new Response(
Buffer.from('<h5>Response</h5>'), // Could also be a string or ReadableStream.
{ headers: { 'content-type': 'text/html' } }
);
});
// Deprecated in Electron 25
protocol.registerHttpProtocol('some-protocol', () => {
callback({ url: 'https://electronjs.org' });
});
// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('https://electronjs.org');
});
// Deprecated in Electron 25
protocol.registerFileProtocol('some-protocol', () => {
callback({ filePath: '/path/to/my/file' });
});
// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('file:///path/to/my/file');
});
Obsoleto: BrowserWindow.setTrafficLightPosition(position)
BrowserWindow.setTrafficLightPosition(position)
has been deprecated, the BrowserWindow.setWindowButtonPosition(position)
API should be used instead which accepts null
instead of { x: 0, y: 0 }
to reset the position to system default.
// Deprecated in Electron 25
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });
// Replace with
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);
Obsoleto: BrowserWindow.getTrafficLightPosition()
BrowserWindow.getTrafficLightPosition()
has been deprecated, the BrowserWindow.getWindowButtonPosition()
API should be used instead which returns null
instead of { x: 0, y: 0 }
when there is no custom position.
// Deprecated in Electron 25
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// No custom position.
}
// Replace with
const ret = win.getWindowButtonPosition();
if (ret === null) {
// No custom position.
}