Bump electron to v3.1.3

Change-type: major
Changelog-entry: Upgrade to Electron v3
Signed-off-by: Lorenzo Alberto Maria Ambrosi <lorenzoa@balena.io>
This commit is contained in:
Lorenzo Alberto Maria Ambrosi 2019-01-30 11:20:42 +01:00 committed by Alexis Svinartchouk
parent 8ef3add183
commit ce9f142621
7 changed files with 1042 additions and 741 deletions

View File

@ -16,7 +16,11 @@
"linux": [ "linux": [
"libudev-dev", "libudev-dev",
"libusb-1.0-0-dev", "libusb-1.0-0-dev",
"libyaml-dev" "libyaml-dev",
"libgtk-3-0",
"libatk-bridge2.0-0",
"libdbus-1-3",
"libc6"
] ]
}, },
"builder": { "builder": {

View File

@ -66,7 +66,7 @@ deb:
- libgconf-2-4 - libgconf-2-4
- libgdk-pixbuf2.0-0 - libgdk-pixbuf2.0-0
- libglib2.0-0 - libglib2.0-0
- libgtk2.0-0 - libgtk-3-0
- liblzma5 - liblzma5
- libnotify4 - libnotify4
- libnspr4 - libnspr4

View File

@ -100,12 +100,11 @@ class SafeWebview extends react.PureComponent {
this.eventTuples = [ this.eventTuples = [
[ 'did-fail-load', this.didFailLoad ], [ 'did-fail-load', this.didFailLoad ],
[ 'did-get-response-details', this.didGetResponseDetails ],
[ 'new-window', this.constructor.newWindow ] [ 'new-window', this.constructor.newWindow ]
] ]
// Make a persistent electron session for the webview // Make a persistent electron session for the webview
electron.remote.session.fromPartition(ELECTRON_SESSION, { this.session = electron.remote.session.fromPartition(ELECTRON_SESSION, {
// Disable the cache for the session such that new content shows up when refreshing // Disable the cache for the session such that new content shows up when refreshing
cache: false cache: false
@ -118,6 +117,7 @@ class SafeWebview extends react.PureComponent {
render () { render () {
return react.createElement('webview', { return react.createElement('webview', {
ref: 'webview', ref: 'webview',
partition: ELECTRON_SESSION,
style: { style: {
flex: this.state.shouldShow ? null : '0 1', flex: this.state.shouldShow ? null : '0 1',
width: this.state.shouldShow ? null : '0', width: this.state.shouldShow ? null : '0',
@ -135,8 +135,7 @@ class SafeWebview extends react.PureComponent {
this.refs.webview.addEventListener(...tuple) this.refs.webview.addEventListener(...tuple)
}) })
// Use the 'success-banner' session this.session.webRequest.onCompleted(this.didGetResponseDetails)
this.refs.webview.partition = ELECTRON_SESSION
// It's important that this comes after the partition setting, otherwise it will // It's important that this comes after the partition setting, otherwise it will
// use another session and we can't change it without destroying the element again // use another session and we can't change it without destroying the element again
@ -151,6 +150,7 @@ class SafeWebview extends react.PureComponent {
_.map(this.eventTuples, (tuple) => { _.map(this.eventTuples, (tuple) => {
this.refs.webview.removeEventListener(...tuple) this.refs.webview.removeEventListener(...tuple)
}) })
this.session.webRequest.onCompleted(null)
} }
/** /**
@ -200,10 +200,10 @@ class SafeWebview extends react.PureComponent {
}) })
this.setState({ this.setState({
shouldShow: event.httpResponseCode === HTTP_OK shouldShow: event.statusCode === HTTP_OK
}) })
if (this.props.onWebviewShow) { if (this.props.onWebviewShow) {
this.props.onWebviewShow(event.httpResponseCode === HTTP_OK) this.props.onWebviewShow(event.statusCode === HTTP_OK)
} }
} }
} }

View File

@ -25,7 +25,6 @@ const settings = require('./app/models/settings')
/* eslint-disable lodash/prefer-lodash-method */ /* eslint-disable lodash/prefer-lodash-method */
const config = settings.getDefaults() const config = settings.getDefaults()
let mainWindow = null
/** /**
* @summary Create Etcher's main window * @summary Create Etcher's main window
@ -33,7 +32,7 @@ let mainWindow = null
* electron.app.on('ready', createMainWindow) * electron.app.on('ready', createMainWindow)
*/ */
const createMainWindow = () => { const createMainWindow = () => {
mainWindow = new electron.BrowserWindow({ const mainWindow = new electron.BrowserWindow({
width: 800, width: 800,
height: 480, height: 480,
useContentSize: true, useContentSize: true,
@ -44,7 +43,7 @@ const createMainWindow = () => {
fullscreenable: Boolean(config.fullscreen), fullscreenable: Boolean(config.fullscreen),
kiosk: Boolean(config.fullscreen), kiosk: Boolean(config.fullscreen),
autoHideMenuBar: true, autoHideMenuBar: true,
titleBarStyle: 'hidden-inset', titleBarStyle: 'hiddenInset',
icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'), icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'),
darkTheme: true, darkTheme: true,
webPreferences: { webPreferences: {
@ -60,10 +59,6 @@ const createMainWindow = () => {
mainWindow.show() mainWindow.show()
}) })
mainWindow.on('closed', () => {
mainWindow = null
})
// Prevent the user from being allowed to zoom-in the application. // Prevent the user from being allowed to zoom-in the application.
// //
// This function should be called on the renderer process. We use // This function should be called on the renderer process. We use
@ -72,7 +67,7 @@ const createMainWindow = () => {
// electron desktop experience fixes in this file. // electron desktop experience fixes in this file.
// //
// See https://github.com/electron/electron/issues/3609 // See https://github.com/electron/electron/issues/3609
mainWindow.webContents.executeJavaScript('require(\'electron\').webFrame.setZoomLevelLimits(1, 1);') mainWindow.webContents.executeJavaScript('require(\'electron\').webFrame.setVisualZoomLevelLimits(1, 1);')
// Prevent external resources from being loaded (like images) // Prevent external resources from being loaded (like images)
// when dropping them on the WebView. // when dropping them on the WebView.

1739
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,7 @@
"chalk": "^1.1.3", "chalk": "^1.1.3",
"color": "^2.0.1", "color": "^2.0.1",
"command-join": "^2.0.0", "command-join": "^2.0.0",
"d3": "^4.13.0",
"debug": "^3.1.0", "debug": "^3.1.0",
"drivelist": "^6.4.2", "drivelist": "^6.4.2",
"electron-is-running-in-asar": "^1.0.0", "electron-is-running-in-asar": "^1.0.0",
@ -87,9 +88,9 @@
"acorn": "^6.0.5", "acorn": "^6.0.5",
"angular-mocks": "1.7.6", "angular-mocks": "1.7.6",
"babel-loader": "^8.0.4", "babel-loader": "^8.0.4",
"electron": "1.8.8", "electron": "3.1.3",
"electron-builder": "^19.40.0", "electron-builder": "^20.38.5",
"electron-mocha": "^6.0.1", "electron-mocha": "^6.0.4",
"eslint": "^4.17.0", "eslint": "^4.17.0",
"eslint-config-standard": "^10.2.1", "eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.9.0", "eslint-plugin-import": "^2.9.0",
@ -104,12 +105,12 @@
"mocha": "^5.0.1", "mocha": "^5.0.1",
"mochainon": "^2.0.0", "mochainon": "^2.0.0",
"nock": "^9.2.3", "nock": "^9.2.3",
"node-gyp": "^3.5.0", "node-gyp": "^3.8.0",
"node-sass": "^4.7.2", "node-sass": "^4.7.2",
"pkg": "^4.3.0", "pkg": "^4.3.0",
"sass-lint": "^1.12.1", "sass-lint": "^1.12.1",
"simple-progress-webpack-plugin": "^1.1.2", "simple-progress-webpack-plugin": "^1.1.2",
"spectron": "^3.7.3", "spectron": "^5.0.0",
"versionist": "^4.0.1", "versionist": "^4.0.1",
"webpack": "^4.27.0", "webpack": "^4.27.0",
"webpack-cli": "^3.1.2", "webpack-cli": "^3.1.2",

View File

@ -10,7 +10,7 @@
+ // TODO PR something to electron to pass in the version number for forks + // TODO PR something to electron to pass in the version number for forks
+ // https://github.com/electron/electron/issues/9058 + // https://github.com/electron/electron/issues/9058
+ try { electron_version = require('electron/package.json').version; } + try { electron_version = require('electron/package.json').version; }
+ catch (_) { electron_version = '1.8.8'; } + catch (_) { electron_version = '3.1.3'; }
+ } + }
+ return get_electron_abi(runtime, electron_version); + return get_electron_abi(runtime, electron_version);
} else { } else {