electron-debug
Advanced tools
Comparing version 2.0.0 to 2.1.0
18
index.js
@@ -69,19 +69,19 @@ 'use strict'; | ||
module.exports = opts => { | ||
opts = Object.assign({ | ||
module.exports = options => { | ||
options = Object.assign({ | ||
enabled: null, | ||
showDevTools: true, | ||
devToolsMode: 'undocked' | ||
}, opts); | ||
}, options); | ||
if (opts.enabled === false || (opts.enabled === null && !isDev)) { | ||
if (options.enabled === false || (options.enabled === null && !isDev)) { | ||
return; | ||
} | ||
if (opts.devToolsMode !== 'previous') { | ||
devToolsOptions.mode = opts.devToolsMode; | ||
if (options.devToolsMode !== 'previous') { | ||
devToolsOptions.mode = options.devToolsMode; | ||
} | ||
app.on('browser-window-created', (event, win) => { | ||
if (opts.showDevTools) { | ||
if (options.showDevTools) { | ||
win.webContents.once('devtools-opened', () => { | ||
@@ -96,3 +96,3 @@ // Workaround for https://github.com/electron/electron/issues/13095 | ||
win.webContents.once('dom-ready', () => { | ||
openDevTools(win, opts.showDevTools); | ||
openDevTools(win, options.showDevTools); | ||
}); | ||
@@ -115,4 +115,6 @@ } | ||
module.exports.default = module.exports; | ||
module.exports.refresh = refresh; | ||
module.exports.devTools = devTools; | ||
module.exports.openDevTools = openDevTools; |
{ | ||
"name": "electron-debug", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Adds useful debug features to your Electron app", | ||
@@ -14,6 +14,7 @@ "license": "MIT", | ||
"start": "electron test.js", | ||
"test": "xo" | ||
"test": "xo && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
@@ -37,2 +38,3 @@ "keywords": [ | ||
"electron-react-devtools": "^0.5.3", | ||
"tsd-check": "^0.3.0", | ||
"xo": "*" | ||
@@ -39,0 +41,0 @@ }, |
@@ -48,3 +48,7 @@ # electron-debug | ||
<a href="https://www.patreon.com/sindresorhus"> | ||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"> | ||
</a> | ||
## Usage | ||
@@ -54,10 +58,11 @@ | ||
const {app, BrowserWindow} = require('electron'); | ||
const debug = require('electron-debug'); | ||
require('electron-debug')(); | ||
debug(); | ||
let win; | ||
app.on('ready', () => { | ||
(async () => { | ||
await app.whenReady(); | ||
win = new BrowserWindow(); | ||
}); | ||
})(); | ||
``` | ||
@@ -76,2 +81,4 @@ | ||
Type: `Object` | ||
##### enabled | ||
@@ -92,3 +99,3 @@ | ||
Default: `undocked`<br> | ||
Values: `undocked` `right` `bottom` `previous` | ||
Values: `undocked` `right` `bottom` `previous` `detach` | ||
@@ -127,2 +134,3 @@ The dock state to open DevTools in. | ||
- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps and modules | ||
- [electron-store](https://github.com/sindresorhus/electron-store) - Save and load data like user preferences, app state, cache, etc | ||
@@ -132,3 +140,4 @@ - [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app | ||
- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app | ||
- [electron-is-dev](https://github.com/sindresorhus/electron-is-dev) - Check if Electron is running in development | ||
- [electron-reloader](https://github.com/sindresorhus/electron-reloader) - Simple auto-reloading for Electron apps during development | ||
- [electron-serve](https://github.com/sindresorhus/electron-serve) - Static file serving for Electron apps | ||
- [debug-menu](https://github.com/parro-it/debug-menu) - Chrome-like debug context-menu for Electron | ||
@@ -135,0 +144,0 @@ |
10131
5
151
143
5