electron-debug
Advanced tools
Comparing version 2.2.0 to 3.0.0
@@ -8,3 +8,3 @@ import {BrowserWindow} from 'electron'; | ||
*/ | ||
readonly enabled?: boolean; | ||
readonly isEnabled?: boolean; | ||
@@ -39,10 +39,10 @@ /** | ||
import {app, BrowserWindow} from 'electron'; | ||
import electronDebug = require('electron-debug'); | ||
import debug = require('electron-debug'); | ||
electronDebug(); | ||
debug(); | ||
let win; | ||
let mainWindow; | ||
(async () => { | ||
await app.whenReady(); | ||
win = new BrowserWindow(); | ||
mainWindow = new BrowserWindow(); | ||
}); | ||
@@ -73,7 +73,4 @@ ``` | ||
openDevTools(window?: BrowserWindow): void; | ||
// TODO: Remove this for the next major release | ||
default: typeof electronDebug; | ||
}; | ||
export = electronDebug; |
38
index.js
'use strict'; | ||
const electron = require('electron'); | ||
const {app, BrowserWindow} = require('electron'); | ||
const localShortcut = require('electron-localshortcut'); | ||
const isDev = require('electron-is-dev'); | ||
const {app, BrowserWindow} = electron; | ||
const isMacOS = process.platform === 'darwin'; | ||
@@ -70,9 +69,10 @@ | ||
module.exports = options => { | ||
options = Object.assign({ | ||
enabled: null, | ||
options = { | ||
isEnabled: null, | ||
showDevTools: true, | ||
devToolsMode: 'undocked' | ||
}, options); | ||
devToolsMode: 'undocked', | ||
...options | ||
}; | ||
if (options.enabled === false || (options.enabled === null && !isDev)) { | ||
if (options.isEnabled === false || (options.isEnabled === null && !isDev)) { | ||
return; | ||
@@ -87,12 +87,5 @@ } | ||
if (options.showDevTools) { | ||
win.webContents.once('devtools-opened', () => { | ||
// Workaround for https://github.com/electron/electron/issues/13095 | ||
setImmediate(() => { | ||
win.focus(); | ||
}); | ||
}); | ||
/// Workaround for https://github.com/electron/electron/issues/12438 | ||
win.webContents.once('dom-ready', () => { | ||
openDevTools(win, options.showDevTools); | ||
openDevTools(win, options.showDevTools, false); | ||
}); | ||
@@ -102,20 +95,19 @@ } | ||
app.on('ready', () => { | ||
(async () => { | ||
await app.whenReady(); | ||
addExtensionIfInstalled('devtron', name => require(name).path); | ||
addExtensionIfInstalled('electron-react-devtools', name => require(name).path); | ||
localShortcut.register('CmdOrCtrl+Shift+C', inspectElements); | ||
localShortcut.register(isMacOS ? 'Cmd+Alt+I' : 'Ctrl+Shift+I', devTools); | ||
localShortcut.register('CommandOrControl+Shift+C', inspectElements); | ||
localShortcut.register(isMacOS ? 'Command+Alt+I' : 'Control+Shift+I', devTools); | ||
localShortcut.register('F12', devTools); | ||
localShortcut.register('CmdOrCtrl+R', refresh); | ||
localShortcut.register('CommandOrControl+R', refresh); | ||
localShortcut.register('F5', refresh); | ||
}); | ||
})(); | ||
}; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = module.exports; | ||
module.exports.refresh = refresh; | ||
module.exports.devTools = devTools; | ||
module.exports.openDevTools = openDevTools; |
{ | ||
"name": "electron-debug", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Adds useful debug features to your Electron app", | ||
@@ -30,9 +30,9 @@ "license": "MIT", | ||
"dependencies": { | ||
"electron-is-dev": "^0.3.0", | ||
"electron-is-dev": "^1.1.0", | ||
"electron-localshortcut": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^11.13.0", | ||
"@types/node": "^12.0.0", | ||
"devtron": "^1.4.0", | ||
"electron": "^2.0.2", | ||
"electron": "^5.0.1", | ||
"electron-react-devtools": "^0.5.3", | ||
@@ -39,0 +39,0 @@ "tsd": "^0.7.2", |
@@ -46,3 +46,3 @@ # electron-debug | ||
*Requires Electron 2.0.0 or later.* | ||
*Requires Electron 5 or later.* | ||
@@ -62,6 +62,6 @@ <a href="https://www.patreon.com/sindresorhus"> | ||
let win; | ||
let mainWindow; | ||
(async () => { | ||
await app.whenReady(); | ||
win = new BrowserWindow(); | ||
mainWindow = new BrowserWindow(); | ||
})(); | ||
@@ -73,3 +73,3 @@ ``` | ||
Only runs when in [development](https://github.com/sindresorhus/electron-is-dev), unless overridden by the `enabled` option. So no need to guard it for production. | ||
Only runs when in [development](https://github.com/sindresorhus/electron-is-dev), unless overridden by the `isEnabled` option. So no need to guard it for production. | ||
@@ -82,5 +82,5 @@ ### electronDebug([options]) | ||
Type: `Object` | ||
Type: `object` | ||
##### enabled | ||
##### isEnabled | ||
@@ -99,4 +99,4 @@ Type: `boolean` | ||
Type: `string`<br> | ||
Default: `undocked`<br> | ||
Values: `undocked` `right` `bottom` `previous` `detach` | ||
Default: `'undocked'`<br> | ||
Values: `'undocked'` `'right'` `'bottom'` `'previous'` `'detach'` | ||
@@ -103,0 +103,0 @@ The dock state to open DevTools in. |
9974
148
+ Addedelectron-is-dev@1.2.0(transitive)
- Removedelectron-is-dev@0.3.0(transitive)
Updatedelectron-is-dev@^1.1.0