From a1ab889fca24d8b7c54915dd908e0694273aaded Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 21 Dec 2018 00:36:42 +0000 Subject: [PATCH 1/8] chore(package): update electron to version 4.0.0 Closes #1523 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fd270fe5f..2c7b30696e 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "buble": "^0.19.6", "cross-zip": "^2.0.1", "depcheck": "^0.6.11", - "electron": "^1.8.8", + "electron": "^4.0.0", "electron-osx-sign": "^0.4.11", "electron-packager": "~8.5.1", "electron-winstaller": "^2.6.4", From f475975b40df7385c53466ce1de9d1e9571d84b6 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 May 2019 17:41:01 +0200 Subject: [PATCH 2/8] Adjust single instance call to comply with Electron 4 --- package-lock.json | 103 +++++++++++++++++++++++++++------------------- src/main/index.js | 4 +- 2 files changed, 62 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index adb956d7be..a36b8c9f95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -236,9 +236,9 @@ "dev": true }, "@types/node": { - "version": "8.10.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", - "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", + "version": "10.14.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.6.tgz", + "integrity": "sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg==", "dev": true }, "abbrev": { @@ -3173,13 +3173,13 @@ "dev": true }, "electron": { - "version": "1.8.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-1.8.8.tgz", - "integrity": "sha512-1f9zJehcTTGjrkb06o6ds+gsRq6SYhZJyxOk6zIWjRH8hVy03y/RzUDELzNas71f5vcvXmfGVvyjeEsadDI8tg==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-4.2.1.tgz", + "integrity": "sha512-v1pwY6PQ+ITVkV/QGgEAEjoBGnPIuut80M+GseWkLcIJ+mIN3xbpuhd1v6arJ1XV7H6waNwjtIFgGSmVWWNRhw==", "dev": true, "requires": { - "@types/node": "^8.0.24", - "electron-download": "^3.0.1", + "@types/node": "^10.12.18", + "electron-download": "^4.1.0", "extract-zip": "^1.0.3" } }, @@ -3304,22 +3304,43 @@ } }, "electron-download": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-3.3.0.tgz", - "integrity": "sha1-LP1U1pZsAZxNSa1l++Zcyc3vaMg=", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/electron-download/-/electron-download-4.1.1.tgz", + "integrity": "sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==", "dev": true, "requires": { - "debug": "^2.2.0", - "fs-extra": "^0.30.0", - "home-path": "^1.0.1", + "debug": "^3.0.0", + "env-paths": "^1.0.0", + "fs-extra": "^4.0.1", "minimist": "^1.2.0", - "nugget": "^2.0.0", - "path-exists": "^2.1.0", - "rc": "^1.1.2", - "semver": "^5.3.0", - "sumchecker": "^1.2.0" + "nugget": "^2.0.1", + "path-exists": "^3.0.0", + "rc": "^1.2.1", + "semver": "^5.4.1", + "sumchecker": "^2.0.2" }, "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "semver": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", @@ -3582,12 +3603,6 @@ "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==" }, - "es6-promise": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", - "integrity": "sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==", - "dev": true - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -4255,16 +4270,25 @@ "dev": true }, "fs-extra": { - "version": "0.30.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", - "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", + "integrity": "sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==", "dev": true, "requires": { "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "dependencies": { + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + } } }, "fs-temp": { @@ -4898,12 +4922,6 @@ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" }, - "home-path": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/home-path/-/home-path-1.0.6.tgz", - "integrity": "sha512-wo+yjrdAtoXt43Vy92a+0IPCYViiyLAHyp0QVS4xL/tfvVz5sXIW1ubLZk3nhVkD92fQpUMKX+fzMjr5F489vw==", - "dev": true - }, "hosted-git-info": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", @@ -9310,13 +9328,12 @@ } }, "sumchecker": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-1.3.1.tgz", - "integrity": "sha1-ebs7RFbdBPGOvbwNcDodHa7FEF0=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-2.0.2.tgz", + "integrity": "sha1-D0LBDl0F2l1C7qPlbDOZo31sWz4=", "dev": true, "requires": { - "debug": "^2.2.0", - "es6-promise": "^4.0.5" + "debug": "^2.2.0" } }, "supports-color": { diff --git a/src/main/index.js b/src/main/index.js index 2b61eeaf5e..9e035cc2b1 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -38,9 +38,9 @@ if (!shouldQuit && !config.IS_PORTABLE) { // signal this instance and quit. Note: This feature creates a lock file in // %APPDATA%\Roaming\WebTorrent so we do not do it for the Portable App since // we want to be "silent" as well as "portable". - shouldQuit = app.makeSingleInstance(onAppOpen) - if (shouldQuit) { + if (!app.requestSingleInstanceLock()) { app.quit() + shouldQuit = true } } From c204b7a82c353089917fe4c3acba31207e163f49 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 May 2019 19:54:13 +0200 Subject: [PATCH 3/8] onAppOpen seems to be no longer in use. --- src/main/index.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 9e035cc2b1..04ad2bdde2 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -168,19 +168,6 @@ function onOpen (e, torrentId) { } } -function onAppOpen (newArgv) { - newArgv = sliceArgv(newArgv) - - if (app.ipcReady) { - log('Second app instance opened, but was prevented:', newArgv) - windows.main.show() - - processArgv(newArgv) - } else { - argv.push(...newArgv) - } -} - // Remove leading args. // Production: 1 arg, eg: /Applications/WebTorrent.app/Contents/MacOS/WebTorrent // Development: 2 args, eg: electron . From c5a21bddfda6be10284f6322b468db881787b659 Mon Sep 17 00:00:00 2001 From: David Ernst Date: Mon, 3 Jun 2019 20:47:05 -0700 Subject: [PATCH 4/8] Fix hiddenInset (Mac) titlebar style for electron 4 --- src/main/windows/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index f310ad7025..23d79b35d1 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -40,7 +40,7 @@ function init (state, options) { minWidth: config.WINDOW_MIN_WIDTH, show: false, title: config.APP_WINDOW_TITLE, - titleBarStyle: 'hidden-inset', // Hide title bar (Mac) + titleBarStyle: 'hiddenInset', // Hide title bar (Mac) useContentSize: true, // Specify web page size without OS chrome width: initialBounds.width, x: initialBounds.x, From a039cbf348013fac5734ff2899aa39ede0842368 Mon Sep 17 00:00:00 2001 From: David Ernst Date: Mon, 3 Jun 2019 21:52:06 -0700 Subject: [PATCH 5/8] Electron 4: Migrate .openDevTools() for new 'detach' pattern --- src/main/windows/main.js | 2 +- src/main/windows/webtorrent.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index f310ad7025..6aaf350fc8 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -209,7 +209,7 @@ function toggleDevTools () { if (main.win.webContents.isDevToolsOpened()) { main.win.webContents.closeDevTools() } else { - main.win.webContents.openDevTools({ detach: true }) + main.win.webContents.openDevTools({ mode: 'detach' }) } } diff --git a/src/main/windows/webtorrent.js b/src/main/windows/webtorrent.js index 0534eb7d8d..ec0ccd2b99 100644 --- a/src/main/windows/webtorrent.js +++ b/src/main/windows/webtorrent.js @@ -56,6 +56,6 @@ function toggleDevTools () { webtorrent.win.webContents.closeDevTools() webtorrent.win.hide() } else { - webtorrent.win.webContents.openDevTools({ detach: true }) + webtorrent.win.webContents.openDevTools({ mode: 'detach' }) } } From f59a54782a712a2ea4b8a12b8e90068af035c7de Mon Sep 17 00:00:00 2001 From: Borewit Date: Mon, 17 Jun 2019 21:05:37 +0200 Subject: [PATCH 6/8] Fix processing arguments from second instance --- src/main/index.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 04ad2bdde2..9014e0f6a4 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -16,6 +16,9 @@ const windows = require('./windows') let shouldQuit = false let argv = sliceArgv(process.argv) +// allow electron/chromium to play startup sounds (without user interaction) +app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required') + // Start the app without showing the main window when auto launching on login // (On Windows and Linux, we get a flag. On MacOS, we get special API.) const hidden = argv.includes('--hidden') || @@ -31,6 +34,12 @@ if (process.platform === 'win32') { const squirrelWin32 = require('./squirrel-win32') shouldQuit = squirrelWin32.handleEvent(argv[0]) argv = argv.filter((arg) => !arg.includes('--squirrel')) + + if (shouldQuit) { + app.quit() + } else { + app.on('second-instance', (event, commandLine) => onAppOpen(commandLine)) + } } if (!shouldQuit && !config.IS_PORTABLE) { @@ -39,11 +48,16 @@ if (!shouldQuit && !config.IS_PORTABLE) { // %APPDATA%\Roaming\WebTorrent so we do not do it for the Portable App since // we want to be "silent" as well as "portable". if (!app.requestSingleInstanceLock()) { - app.quit() shouldQuit = true } } +if (shouldQuit) { + app.quit() +} else { + app.on('second-instance', (event, commandLine, workingDirectory) => onAppOpen(commandLine)) +} + if (!shouldQuit) { init() } @@ -168,6 +182,19 @@ function onOpen (e, torrentId) { } } +function onAppOpen (newArgv) { + newArgv = sliceArgv(newArgv) + + if (app.ipcReady) { + log('Second app instance opened, but was prevented:', newArgv) + windows.main.show() + + processArgv(newArgv) + } else { + argv.push(...newArgv) + } +} + // Remove leading args. // Production: 1 arg, eg: /Applications/WebTorrent.app/Contents/MacOS/WebTorrent // Development: 2 args, eg: electron . From 08008bb25c576dfad9df006b7b5012860d19e45c Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 21 Jul 2019 10:19:36 +0200 Subject: [PATCH 7/8] #1590 Improve single-instance start-up logic, remove duplicate code. --- src/main/index.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 9014e0f6a4..2b14fa8376 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -34,12 +34,6 @@ if (process.platform === 'win32') { const squirrelWin32 = require('./squirrel-win32') shouldQuit = squirrelWin32.handleEvent(argv[0]) argv = argv.filter((arg) => !arg.includes('--squirrel')) - - if (shouldQuit) { - app.quit() - } else { - app.on('second-instance', (event, commandLine) => onAppOpen(commandLine)) - } } if (!shouldQuit && !config.IS_PORTABLE) { @@ -55,14 +49,11 @@ if (!shouldQuit && !config.IS_PORTABLE) { if (shouldQuit) { app.quit() } else { - app.on('second-instance', (event, commandLine, workingDirectory) => onAppOpen(commandLine)) -} - -if (!shouldQuit) { init() } function init () { + app.on('second-instance', (event, commandLine, workingDirectory) => onAppOpen(commandLine)) if (config.IS_PORTABLE) { const path = require('path') // Put all user data into the "Portable Settings" folder From b216929dc445a1bee65ca21df2a953c47f508f53 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 21 Jul 2019 10:37:16 +0200 Subject: [PATCH 8/8] Comply with max 100 chars per line lint rule. --- src/renderer/pages/player-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index eb4f669cbe..8d3e1ea80e 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -308,7 +308,7 @@ function renderAudioMetadata (state) { format.push(Math.round(fileSummary.audioInfo.format.bitrate / 1000) + ' kbps') // 128 kbps } if (fileSummary.audioInfo.format.sampleRate) { - format.push(Math.round(fileSummary.audioInfo.format.sampleRate / 100) / 10 + ' kHz') // 44.1 kHz + format.push(Math.round(fileSummary.audioInfo.format.sampleRate / 100) / 10 + ' kHz') } if (fileSummary.audioInfo.format.bitsPerSample) { format.push(fileSummary.audioInfo.format.bitsPerSample + ' bit')