Skip to content

Commit 8301fe7

Browse files
authored
feat: support electron 16.x (#86)
* build: updated electron to 12.2.3 * build: updated electron to 13.6.3 * build: updated electron to 14.2.2 * build: updated electron to 15.3.3 * build: updated electron to 16.0.4 * refactor: replaced promise to await
1 parent 0e6a93d commit 8301fe7

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@
4646
"testcafe": "*"
4747
},
4848
"devDependencies": {
49+
"@electron/remote": "^2.0.1",
4950
"asar": "^2.0.1",
5051
"babel-core": "^6.26.3",
5152
"babel-eslint": "^7.2.3",
5253
"babel-plugin-add-module-exports": "^0.2.1",
5354
"babel-plugin-transform-runtime": "^6.23.0",
5455
"babel-preset-env": "^1.6.0",
5556
"del": "^2.0.0",
56-
"electron": "^11.0.3",
57+
"electron": "^16.0.4",
5758
"gulp": "^4.0.0",
5859
"gulp-babel": "^7.0.0",
5960
"gulp-eslint": "^3.0.1",

src/node-inspect.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ export default class NodeInspect {
3131
}
3232

3333
async _setupRemoteInterface () {
34-
this.client.Debugger.enable().then(async () => {
35-
return this.client.Debugger.setBreakpointByUrl({ lineNumber: 16, url: 'internal/main/run_main_module\.js' });
36-
});
34+
await this.client.Debugger.enable();
35+
36+
// NOTE: <= Electron v14.2.2
37+
await this.client.Debugger.setBreakpointByUrl({ lineNumber: 16, url: 'internal/main/run_main_module\.js' });
38+
// NOTE: >= Electron v15.0.0
39+
await this.client.Debugger.setBreakpointByUrl({ lineNumber: 16, url: 'node:internal/main/run_main_module' });
3740

3841
var pausedEvent = promisifyEvent(this.client, 'Debugger.paused');
3942

test/data/test-app-regular/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body>
66
<h1>TEST ME</h1>
77
<script>
8-
var { Menu } = require('electron').remote;
8+
var { Menu } = require('@electron/remote');
99
var foo = require('./client.js').foo;
1010

1111
var contextMenu = Menu.buildFromTemplate([

test/data/test-app-regular/index.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
var electron = require('electron');
2-
var path = require('path');
3-
var dialog = electron.dialog;
1+
var electron = require('electron');
2+
var path = require('path');
3+
var dialog = electron.dialog;
4+
var remoteMain = require('@electron/remote/main');
45

56
var BrowserWindow = electron.BrowserWindow;
67
var app = electron.app;
@@ -11,19 +12,25 @@ var win = null;
1112

1213

1314
function createWindow () {
15+
// Initialize main remote.
16+
remoteMain.initialize();
17+
1418
// Create the browser window.
1519
win = new BrowserWindow({
1620
width: 1024,
1721
height: 768,
1822
webPreferences: {
19-
nodeIntegration: true,
20-
// NOTE: Electron 10 breaking changes:
21-
// "Changed the default value of `enableRemoteModule` to `false`"
22-
// (https://www.electronjs.org/blog/electron-10-0#breaking-changes) (GH-73)
23-
enableRemoteModule: true
24-
}
23+
nodeIntegration: true,
24+
// NOTE: Electron 12 breaking changes:
25+
// "Changed the default value of `contextIsolation` to `true`"
26+
// (https://www.electronjs.org/blog/electron-12-0#breaking-changes)
27+
contextIsolation: false,
28+
},
2529
});
2630

31+
// and enable remote module for this windows
32+
remoteMain.enable(win.webContents);
33+
2734
// and load the index.html of the app.
2835
win.webContents.loadURL('file://' + path.join(__dirname, 'index.html'));
2936

0 commit comments

Comments
 (0)