fix: electron upgrade fixes (#2058)

* fix: electron upgrade fixes

* fix: electron remote

* fixes

* fixes

* pin

* actually
This commit is contained in:
Diego Rodríguez Baquero
2021-10-10 13:21:45 -05:00
committed by GitHub
parent 0732bd93d2
commit c36e43eaa3
12 changed files with 1152 additions and 721 deletions

1840
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,7 @@
"url": "https://github.com/webtorrent/webtorrent-desktop/issues" "url": "https://github.com/webtorrent/webtorrent-desktop/issues"
}, },
"dependencies": { "dependencies": {
"@electron/remote": "2.0.1",
"airplayer": "github:webtorrent/airplayer#fix-security", "airplayer": "github:webtorrent/airplayer#fix-security",
"application-config": "2.0.0", "application-config": "2.0.0",
"arch": "2.2.0", "arch": "2.2.0",
@@ -62,7 +63,7 @@
"@babel/eslint-parser": "7.15.8", "@babel/eslint-parser": "7.15.8",
"@babel/plugin-transform-react-jsx": "7.14.9", "@babel/plugin-transform-react-jsx": "7.14.9",
"cross-zip": "4.0.0", "cross-zip": "4.0.0",
"depcheck": "1.4.1", "depcheck": "1.4.2",
"electron": "15.1.2", "electron": "15.1.2",
"electron-notarize": "1.1.1", "electron-notarize": "1.1.1",
"electron-osx-sign": "0.5.0", "electron-osx-sign": "0.5.0",
@@ -71,17 +72,17 @@
"gh-release": "6.0.1", "gh-release": "6.0.1",
"minimist": "1.2.5", "minimist": "1.2.5",
"nodemon": "2.0.13", "nodemon": "2.0.13",
"open": "8.2.1", "open": "8.3.0",
"plist": "3.0.4", "plist": "3.0.4",
"pngjs": "6.0.0", "pngjs": "6.0.0",
"run-series": "1.1.9", "run-series": "1.1.9",
"spectron": "15.0.0", "spectron": "15.0.0",
"standard": "*", "standard": "16.0.4",
"tape": "5.3.1" "tape": "5.3.1"
}, },
"engines": { "engines": {
"node": "^16.0.0", "node": "^16.0.0",
"npm": "^7.10.0" "npm": "^7.10.0 || ^8.0.0"
}, },
"homepage": "https://webtorrent.io", "homepage": "https://webtorrent.io",
"keywords": [ "keywords": [

View File

@@ -1,6 +1,6 @@
const appConfig = require('application-config')('WebTorrent') const appConfig = require('application-config')('WebTorrent')
const path = require('path') const path = require('path')
const { app, remote } = require('electron') const { app } = require('electron')
const arch = require('arch') const arch = require('arch')
const APP_NAME = 'WebTorrent' const APP_NAME = 'WebTorrent'
@@ -126,7 +126,7 @@ function getPath (key) {
return '' return ''
} else if (process.type === 'renderer') { } else if (process.type === 'renderer') {
// Electron renderer process // Electron renderer process
return remote.app.getPath(key) return require('@electron/remote').app.getPath(key)
} else { } else {
// Electron main process // Electron main process
return app.getPath(key) return app.getPath(key)

View File

@@ -1,5 +1,6 @@
console.time('init') console.time('init')
require('@electron/remote/main').initialize()
const { app, ipcMain } = require('electron') const { app, ipcMain } = require('electron')
// Start crash reporter early, so it takes effect for child processes // Start crash reporter early, so it takes effect for child processes

View File

@@ -222,7 +222,8 @@ function init () {
ipcMain.emit = function (name, e, ...args) { ipcMain.emit = function (name, e, ...args) {
// Relay messages between the main window and the WebTorrent hidden window // Relay messages between the main window and the WebTorrent hidden window
if (name.startsWith('wt-') && !app.isQuitting) { if (name.startsWith('wt-') && !app.isQuitting) {
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') { console.dir(e.sender.getTitle())
if (e.sender.getTitle() === 'WebTorrent Hidden Window') {
// Send message to main window // Send message to main window
windows.main.send(name, ...args) windows.main.send(name, ...args)
log('webtorrent: got %s', name) log('webtorrent: got %s', name)

View File

@@ -33,6 +33,7 @@ function init () {
}, },
width: 300 width: 300
}) })
require('@electron/remote/main').enable(win.webContents)
win.loadURL(config.WINDOW_ABOUT) win.loadURL(config.WINDOW_ABOUT)

View File

@@ -50,6 +50,7 @@ function init (state, options) {
x: initialBounds.x, x: initialBounds.x,
y: initialBounds.y y: initialBounds.y
}) })
require('@electron/remote/main').enable(win.webContents)
win.loadURL(config.WINDOW_MAIN) win.loadURL(config.WINDOW_MAIN)
@@ -65,7 +66,7 @@ function init (state, options) {
menu.onToggleFullScreen(main.win.isFullScreen()) menu.onToggleFullScreen(main.win.isFullScreen())
}) })
win.webContents.on('will-navigate', (e, url) => { win.webContents.on('will-navigate', (e) => {
// Prevent drag-and-drop from navigating the Electron window, which can happen // Prevent drag-and-drop from navigating the Electron window, which can happen
// before our drag-and-drop handlers have been initialized. // before our drag-and-drop handlers have been initialized.
e.preventDefault() e.preventDefault()
@@ -151,7 +152,7 @@ function setBounds (bounds, maximize) {
log('setBounds: maximizing') log('setBounds: maximizing')
main.win.maximize() main.win.maximize()
} else if (maximize === false && main.win.isMaximized()) { } else if (maximize === false && main.win.isMaximized()) {
log('setBounds: unmaximizing') log('setBounds: minimizing')
main.win.unmaximize() main.win.unmaximize()
} }

View File

@@ -33,6 +33,7 @@ function init () {
}, },
width: 150 width: 150
}) })
require('@electron/remote/main').enable(win.webContents)
win.loadURL(config.WINDOW_WEBTORRENT) win.loadURL(config.WINDOW_WEBTORRENT)

View File

@@ -1,7 +1,7 @@
const path = require('path') const path = require('path')
const colors = require('material-ui/styles/colors') const colors = require('material-ui/styles/colors')
const { remote } = require('electron') const remote = require('@electron/remote')
const React = require('react') const React = require('react')
const PropTypes = require('prop-types') const PropTypes = require('prop-types')

View File

@@ -1,4 +1,4 @@
const { remote } = require('electron') const remote = require('@electron/remote')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const parallel = require('run-parallel') const parallel = require('run-parallel')

View File

@@ -1,6 +1,7 @@
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const { ipcRenderer, remote, clipboard } = require('electron') const { ipcRenderer, clipboard } = require('electron')
const remote = require('@electron/remote')
const { dispatch } = require('../lib/dispatcher') const { dispatch } = require('../lib/dispatcher')
const { TorrentKeyNotFoundError } = require('../lib/errors') const { TorrentKeyNotFoundError } = require('../lib/errors')

View File

@@ -7,7 +7,7 @@ module.exports = {
logPlayAttempt logPlayAttempt
} }
const { remote } = require('electron') const remote = require('@electron/remote')
const config = require('../../config') const config = require('../../config')