electron/docs/api/breaking-changes.md

334 lines
6.5 KiB
Markdown
Raw Normal View History

# API Contract
2018-06-22 03:43:39 +00:00
Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least [one major version](../tutorial/electron-versioning.md#semver) before the change is made.
# `FIXME` comments
The `FIXME` string is used in code comments to denote things that should be fixed for future releases. See https://github.com/electron/electron/search?q=fixme
# Planned Breaking API Changes (5.0)
## `new BrowserWindow({ webPreferences })`
The following `webPreferences` option default values are deprecated in favor of the new defaults listed below.
| Property | Deprecated Default | New Default |
|----------|--------------------|-------------|
| `contextIsolation` | `false` | `true` |
| `nodeIntegration` | `true` | `false` |
| `webviewTag` | `nodeIntegration` if set else `true` | `false` |
# Planned Breaking API Changes (4.0)
The following list includes the breaking API changes planned for Electron 4.0.
## `app.makeSingleInstance`
```js
// Deprecated
app.makeSingleInstance(function (argv, cwd) {
})
// Replace with
app.requestSingleInstanceLock()
app.on('second-instance', function (argv, cwd) {
})
```
## `app.releaseSingleInstance`
```js
// Deprecated
app.releaseSingleInstance()
// Replace with
app.releaseSingleInstanceLock()
```
## `app.getGPUInfo`
```js
app.getGPUInfo('complete')
// Now behaves the same with `basic` on macOS
app.getGPUInfo('basic')
```
# Breaking API Changes (3.0)
2016-09-07 18:41:54 +00:00
The following list includes the breaking API changes in Electron 3.0.
2016-09-07 18:41:54 +00:00
2017-05-18 03:01:06 +00:00
## `app`
```js
// Deprecated
app.getAppMemoryInfo()
// Replace with
app.getAppMetrics()
// Deprecated
const metrics = app.getAppMetrics()
2018-09-13 16:10:51 +00:00
const { memory } = metrics[0] // Deprecated property
2017-05-18 03:01:06 +00:00
```
2016-09-08 16:09:49 +00:00
## `BrowserWindow`
```js
// Deprecated
2018-09-13 16:10:51 +00:00
let optionsA = { webPreferences: { blinkFeatures: '' } }
2016-09-08 16:15:05 +00:00
let windowA = new BrowserWindow(optionsA)
2016-09-08 16:09:49 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
let optionsB = { webPreferences: { enableBlinkFeatures: '' } }
2016-09-08 16:15:05 +00:00
let windowB = new BrowserWindow(optionsB)
// Deprecated
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play_pause') {
// do something
}
})
// Replace with
window.on('app-command', (e, cmd) => {
if (cmd === 'media-play-pause') {
// do something
}
})
2016-09-08 16:09:49 +00:00
```
## `clipboard`
2016-09-07 18:41:54 +00:00
```js
// Deprecated
clipboard.readRtf()
// Replace with
clipboard.readRTF()
// Deprecated
clipboard.writeRtf()
// Replace with
clipboard.writeRTF()
// Deprecated
clipboard.readHtml()
// Replace with
clipboard.readHTML()
// Deprecated
clipboard.writeHtml()
// Replace with
clipboard.writeHTML()
2016-09-08 16:09:49 +00:00
```
2016-11-28 23:06:03 +00:00
## `crashReporter`
```js
// Deprecated
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
autoSubmit: true
})
// Replace with
crashReporter.start({
companyName: 'Crashly',
submitURL: 'https://crash.server.com',
uploadToServer: true
})
```
2016-09-08 16:09:49 +00:00
## `nativeImage`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
// Deprecated
nativeImage.createFromBuffer(buffer, 1.0)
// Replace with
nativeImage.createFromBuffer(buffer, {
scaleFactor: 1.0
})
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
## `process`
```js
// Deprecated
const info = process.getProcessMemoryInfo()
```
## `screen`
2016-09-16 22:57:07 +00:00
```js
// Deprecated
screen.getMenuBarHeight()
2016-09-16 22:57:07 +00:00
// Replace with
screen.getPrimaryDisplay().workArea
2016-09-16 22:57:07 +00:00
```
2017-02-07 23:44:56 +00:00
## `session`
```js
// Deprecated
ses.setCertificateVerifyProc(function (hostname, certificate, callback) {
callback(true)
})
// Replace with
2017-02-08 00:35:37 +00:00
ses.setCertificateVerifyProc(function (request, callback) {
2017-02-07 23:44:56 +00:00
callback(0)
})
```
2016-09-08 16:09:49 +00:00
## `Tray`
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
```js
2016-09-07 18:41:54 +00:00
// Deprecated
tray.setHighlightMode(true)
// Replace with
tray.setHighlightMode('on')
// Deprecated
tray.setHighlightMode(false)
// Replace with
tray.setHighlightMode('off')
2016-09-08 16:09:49 +00:00
```
2016-09-07 18:41:54 +00:00
2016-09-08 16:09:49 +00:00
## `webContents`
```js
2016-09-07 18:41:54 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ detach: true })
2016-09-07 18:41:54 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
webContents.openDevTools({ mode: 'detach' })
// Removed
webContents.setSize(options)
// There is no replacement for this API
2016-09-07 18:41:54 +00:00
```
## `webFrame`
```js
2016-11-14 18:33:30 +00:00
// Deprecated
webFrame.registerURLSchemeAsSecure('app')
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
2016-11-14 18:33:30 +00:00
// Deprecated
2018-09-13 16:10:51 +00:00
webFrame.registerURLSchemeAsPrivileged('app', { secure: true })
2016-11-14 18:33:30 +00:00
// Replace with
2018-09-13 16:10:51 +00:00
protocol.registerStandardSchemes(['app'], { secure: true })
```
## `<webview>`
```js
// Removed
webview.setAttribute('disableguestresize', '')
// There is no replacement for this API
// Removed
webview.setAttribute('guestinstance', instanceId)
// There is no replacement for this API
// Keyboard listeners no longer work on webview tag
webview.onkeydown = () => { /* handler */ }
webview.onkeyup = () => { /* handler */ }
```
## Node Headers URL
This is the URL specified as `disturl` in a `.npmrc` file or as the `--dist-url`
command line flag when building native Node modules.
Deprecated: https://atom.io/download/atom-shell
Replace with: https://atom.io/download/electron
# Breaking API Changes (2.0)
The following list includes the breaking API changes made in Electron 2.0.
## `BrowserWindow`
```js
// Deprecated
2018-09-13 16:10:51 +00:00
let optionsA = { titleBarStyle: 'hidden-inset' }
let windowA = new BrowserWindow(optionsA)
// Replace with
2018-09-13 16:10:51 +00:00
let optionsB = { titleBarStyle: 'hiddenInset' }
let windowB = new BrowserWindow(optionsB)
```
## `menu`
```js
// Removed
menu.popup(browserWindow, 100, 200, 2)
// Replaced with
2018-09-13 16:10:51 +00:00
menu.popup(browserWindow, { x: 100, y: 200, positioningItem: 2 })
```
2018-05-29 09:24:39 +00:00
## `nativeImage`
```js
// Removed
nativeImage.toPng()
// Replaced with
nativeImage.toPNG()
// Removed
nativeImage.toJpeg()
// Replaced with
nativeImage.toJPEG()
```
## `process`
* `process.versions.electron` and `process.version.chrome` will be made
read-only properties for consistency with the other `process.versions`
properties set by Node.
## `webContents`
```js
// Removed
webContents.setZoomLevelLimits(1, 2)
// Replaced with
webContents.setVisualZoomLevelLimits(1, 2)
```
## `webFrame`
```js
// Removed
webFrame.setZoomLevelLimits(1, 2)
// Replaced with
webFrame.setVisualZoomLevelLimits(1, 2)
```
## `<webview>`
```js
// Removed
webview.setZoomLevelLimits(1, 2)
// Replaced with
webview.setVisualZoomLevelLimits(1, 2)
```
## Duplicate ARM Assets
Each Electron release includes two identical ARM builds with slightly different
filenames, like `electron-v1.7.3-linux-arm.zip` and
`electron-v1.7.3-linux-armv7l.zip`. The asset with the `v7l` prefix was added
to clarify to users which ARM version it supports, and to disambiguate it from
future armv6l and arm64 assets that may be produced.
The file _without the prefix_ is still being published to avoid breaking any
setups that may be consuming it. Starting at 2.0, the un-prefixed file will
no longer be published.
For details, see
[6986](https://github.com/electron/electron/pull/6986)
and
[7189](https://github.com/electron/electron/pull/7189).