Fully replace electron-debug with our own implementation (#2585)

This commit is contained in:
absidue 2022-09-19 15:36:40 +02:00 committed by GitHub
parent 76a9e5c3c4
commit 77c26638e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 48 deletions

View File

@ -14,10 +14,6 @@ const config = {
entry: { entry: {
main: path.join(__dirname, '../src/main/index.js'), main: path.join(__dirname, '../src/main/index.js'),
}, },
// webpack spits out errors while inlining electron-debug as
// it tries to dynamically load dependencies
// the error: "Critical dependency: the request of a dependency is an expression"
externals: ['electron-debug'],
module: { module: {
rules: [ rules: [
{ {

View File

@ -95,7 +95,6 @@
"css-minimizer-webpack-plugin": "^4.1.0", "css-minimizer-webpack-plugin": "^4.1.0",
"electron": "^20.1.4", "electron": "^20.1.4",
"electron-builder": "^23.3.3", "electron-builder": "^23.3.3",
"electron-debug": "^3.2.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3", "eslint-config-standard": "^16.0.3",

View File

@ -80,10 +80,6 @@ function runApp() {
} }
} }
}) })
} else {
require('electron-debug')({
showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true')
})
} }
app.on('ready', async (_, __) => { app.on('ready', async (_, __) => {
@ -303,10 +299,20 @@ function runApp() {
// Show when loaded // Show when loaded
newWindow.once('ready-to-show', () => { newWindow.once('ready-to-show', () => {
if (newWindow.isVisible()) { return } if (newWindow.isVisible()) {
// only open the dev tools if they aren't already open
if (isDev && !newWindow.webContents.isDevToolsOpened()) {
newWindow.webContents.openDevTools({ activate: false })
}
return
}
newWindow.show() newWindow.show()
newWindow.focus() newWindow.focus()
if (isDev) {
newWindow.webContents.openDevTools({ activate: false })
}
}) })
newWindow.once('close', async () => { newWindow.once('close', async () => {
@ -816,6 +822,21 @@ function runApp() {
accelerator: 'CmdOrCtrl+Shift+R' accelerator: 'CmdOrCtrl+Shift+R'
}, },
{ role: 'toggledevtools' }, { role: 'toggledevtools' },
{ role: 'toggledevtools', accelerator: 'f12', visible: false },
{
label: 'Enter Inspect Element Mode',
accelerator: 'CmdOrCtrl+Shift+C',
click: (_, window) => {
if (window.webContents.isDevToolsOpened()) {
window.devToolsWebContents.executeJavaScript('DevToolsAPI.enterInspectElementMode()')
} else {
window.webContents.once('devtools-opened', () => {
window.devToolsWebContents.executeJavaScript('DevToolsAPI.enterInspectElementMode()')
})
window.webContents.openDevTools()
}
}
},
{ type: 'separator' }, { type: 'separator' },
{ role: 'resetzoom' }, { role: 'resetzoom' },
{ role: 'resetzoom', accelerator: 'CmdOrCtrl+num0', visible: false }, { role: 'resetzoom', accelerator: 'CmdOrCtrl+num0', visible: false },

View File

@ -3159,14 +3159,6 @@ electron-context-menu@^3.1.2:
electron-dl "^3.2.1" electron-dl "^3.2.1"
electron-is-dev "^2.0.0" electron-is-dev "^2.0.0"
electron-debug@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/electron-debug/-/electron-debug-3.2.0.tgz#46a15b555c3b11872218c65ea01d058aa0814920"
integrity sha512-7xZh+LfUvJ52M9rn6N+tPuDw6oRAjxUj9SoxAZfJ0hVCXhZCsdkrSt7TgXOiWiEOBgEV8qwUIO/ScxllsPS7ow==
dependencies:
electron-is-dev "^1.1.0"
electron-localshortcut "^3.1.0"
electron-dl@^3.2.1: electron-dl@^3.2.1:
version "3.3.1" version "3.3.1"
resolved "https://registry.yarnpkg.com/electron-dl/-/electron-dl-3.3.1.tgz#14164595bebcc636c671eb791b2a3265003f76c4" resolved "https://registry.yarnpkg.com/electron-dl/-/electron-dl-3.3.1.tgz#14164595bebcc636c671eb791b2a3265003f76c4"
@ -3176,31 +3168,11 @@ electron-dl@^3.2.1:
pupa "^2.0.1" pupa "^2.0.1"
unused-filename "^2.1.0" unused-filename "^2.1.0"
electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
integrity sha1-UJ5RDCala1Xhf4Y6SwThEYRqsns=
electron-is-dev@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-1.2.0.tgz#2e5cea0a1b3ccf1c86f577cee77363ef55deb05e"
integrity sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==
electron-is-dev@^2.0.0: electron-is-dev@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-2.0.0.tgz#833487a069b8dad21425c67a19847d9064ab19bd" resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-2.0.0.tgz#833487a069b8dad21425c67a19847d9064ab19bd"
integrity sha512-3X99K852Yoqu9AcW50qz3ibYBWY79/pBhlMCab8ToEWS48R0T9tyxRiQhwylE7zQdXrMnx2JKqUJyMPmt5FBqA== integrity sha512-3X99K852Yoqu9AcW50qz3ibYBWY79/pBhlMCab8ToEWS48R0T9tyxRiQhwylE7zQdXrMnx2JKqUJyMPmt5FBqA==
electron-localshortcut@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/electron-localshortcut/-/electron-localshortcut-3.2.1.tgz#cfc83a3eff5e28faf98ddcc87f80a2ce4f623cd3"
integrity sha512-DWvhKv36GsdXKnaFFhEiK8kZZA+24/yFLgtTwJJHc7AFgDjNRIBJZ/jq62Y/dWv9E4ypYwrVWN2bVrCYw1uv7Q==
dependencies:
debug "^4.0.1"
electron-is-accelerator "^0.1.0"
keyboardevent-from-electron-accelerator "^2.0.0"
keyboardevents-areequal "^0.2.1"
electron-osx-sign@^0.6.0: electron-osx-sign@^0.6.0:
version "0.6.0" version "0.6.0"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.6.0.tgz#9b69c191d471d9458ef5b1e4fdd52baa059f1bb8" resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.6.0.tgz#9b69c191d471d9458ef5b1e4fdd52baa059f1bb8"
@ -4890,16 +4862,6 @@ jsprim@^1.2.2:
json-schema "0.4.0" json-schema "0.4.0"
verror "1.10.0" verror "1.10.0"
keyboardevent-from-electron-accelerator@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz#ace21b1aa4e47148815d160057f9edb66567c50c"
integrity sha512-iQcmNA0M4ETMNi0kG/q0h/43wZk7rMeKYrXP7sqKIJbHkTU8Koowgzv+ieR/vWJbOwxx5nDC3UnudZ0aLSu4VA==
keyboardevents-areequal@^0.2.1:
version "0.2.2"
resolved "https://registry.yarnpkg.com/keyboardevents-areequal/-/keyboardevents-areequal-0.2.2.tgz#88191ec738ce9f7591c25e9056de928b40277194"
integrity sha512-Nv+Kr33T0mEjxR500q+I6IWisOQ0lK1GGOncV0kWE6n4KFmpcu7RUX5/2B0EUtX51Cb0HjZ9VJsSY3u4cBa0kw==
keycode@^2.2.0: keycode@^2.2.0:
version "2.2.1" version "2.2.1"
resolved "https://registry.yarnpkg.com/keycode/-/keycode-2.2.1.tgz#09c23b2be0611d26117ea2501c2c391a01f39eff" resolved "https://registry.yarnpkg.com/keycode/-/keycode-2.2.1.tgz#09c23b2be0611d26117ea2501c2c391a01f39eff"