Skip to content

Commit

Permalink
Require Electron 5 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 10, 2019
1 parent 28e34f2 commit fd5ab10
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- '10'
- '12'
11 changes: 4 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ declare const electronDebug: {
@example
```
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();
});
```
*/
Expand All @@ -68,9 +68,6 @@ declare const electronDebug: {
@param window - Default: `BrowserWindow.getFocusedWindow()`
*/
openDevTools(window?: BrowserWindow): void;

// TODO: Remove this for the next major release
default: typeof electronDebug;
};

export = electronDebug;
12 changes: 1 addition & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,9 @@ module.exports = options => {

app.on('browser-window-created', (event, win) => {
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);
});
}
});
Expand All @@ -112,9 +105,6 @@ module.exports = options => {
})();
};

// 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;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"development"
],
"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",
"tsd": "^0.7.2",
"xo": "^0.24.0"
Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Just install any of these extension and they'll be activated for you:
$ npm install electron-debug
```

*Requires Electron 4 or later.*
*Requires Electron 5 or later.*

<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
Expand All @@ -58,10 +58,10 @@ const debug = require('electron-debug');

debug();

let win;
let mainWindow;
(async () => {
await app.whenReady();
win = new BrowserWindow();
mainWindow = new BrowserWindow();
})();
```

Expand All @@ -76,7 +76,7 @@ Install keyboard shortcuts and optionally activate DevTools on each created `Bro

#### options

Type: `Object`
Type: `object`

##### isEnabled

Expand All @@ -92,8 +92,8 @@ Show DevTools on each created `BrowserWindow`.
##### devToolsMode

Type: `string`<br>
Default: `undocked`<br>
Values: `undocked` `right` `bottom` `previous` `detach`
Default: `'undocked'`<br>
Values: `'undocked'` `'right'` `'bottom'` `'previous'` `'detach'`

The dock state to open DevTools in.

Expand Down

0 comments on commit fd5ab10

Please sign in to comment.