Skip to content

Commit 99b309e

Browse files
authored
Merge pull request #160 from mtgto/update-electron-11
Update electron 11
2 parents 948a098 + 53f0d18 commit 99b309e

File tree

6 files changed

+1302
-1133
lines changed

6 files changed

+1302
-1133
lines changed

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"start": "electron app/development",
1414
"watch": "webpack --mode=development --watch",
1515
"test": "yarn run test:unit && yarn run test:integration",
16-
"test:unit": "electron-mocha --renderer --color --grep @remote --invert \"./test/unit/**/*.test.{ts,tsx}\"",
17-
"test:unit:remote": "electron-mocha --renderer --color --grep @remote \"./test/unit/**/*.test.{ts,tsx}\"",
16+
"test:unit": "electron-mocha --renderer --require ts-node/register --ui tdd --color --grep @remote --invert \"./test/unit/**/*.test.{ts,tsx}\"",
17+
"test:unit:remote": "electron-mocha --renderer --require ts-node/register --ui tdd --color --grep @remote \"./test/unit/**/*.test.{ts,tsx}\"",
1818
"test:build": "webpack --env BUILD_ENV=test --mode=development && electron-builder build --config electron-builder.test.yml --publish never --dir",
19-
"test:integration": "yarn run test:build && mocha --exit test/integration/test.ts",
19+
"test:integration": "yarn run test:build && mocha --exit --require ts-node/register --ui tdd test/integration/test.ts",
2020
"lint": "yarn run lint:eslint && yarn run lint:tsc && yarn run lint:prettier",
2121
"lint:eslint": "eslint --ext \".js,.jsx,.ts,.tsx\" --max-warnings 0 .",
2222
"lint:tsc": "tsc --noEmit",
@@ -32,9 +32,9 @@
3232
"classnames": "2.2.5",
3333
"codemirror": "~5.49.2",
3434
"csv-stringify": "2.0.1",
35-
"electron-is-dev": "1.1.0",
36-
"electron-log": "3.0.9",
37-
"electron-updater": "4.2.0",
35+
"electron-is-dev": "2.0.0",
36+
"electron-log": "4.3.0",
37+
"electron-updater": "4.3.8",
3838
"fs-extra": "5.0.0",
3939
"immup": "3.0.0",
4040
"js-yaml": "3.10.0",
@@ -67,14 +67,13 @@
6767
"@types/react-select": "~3.0.13",
6868
"@types/react-splitter-layout": "3.0.0",
6969
"@types/sqlite3": "3.1.6",
70-
"@types/webdriverio": "4.13.3",
7170
"@typescript-eslint/eslint-plugin": "3.4.0",
7271
"@typescript-eslint/parser": "3.4.0",
7372
"copy-webpack-plugin": "^8.1.1",
7473
"css-loader": "^5.2.1",
75-
"electron": "7.1.12",
74+
"electron": "11.4.3",
7675
"electron-builder": "22.10.5",
77-
"electron-mocha": "~8.2.1",
76+
"electron-mocha": "~10.0.0",
7877
"electron-notarize": "0.3.0",
7978
"electron-publisher-s3": "20.14.4",
8079
"eslint": "~7.3.1",
@@ -84,7 +83,7 @@
8483
"execa": "0.9.0",
8584
"mini-css-extract-plugin": "~1.4.1",
8685
"prettier": "~1.19.1",
87-
"spectron": "9.0.0",
86+
"spectron": "13.0.0",
8887
"ts-loader": "~8.1.0",
8988
"ts-node": "5.0.1",
9089
"typescript": "^3.9.5",

src/main/index.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,14 @@ app.on("window-all-closed", () => {
2222
}
2323
});
2424

25-
app.on("ready", async () => {
26-
// https://github.com/electron/electron/issues/13008#issuecomment-569363295
27-
electron.session.defaultSession.webRequest.onBeforeRequest((details, callback) => {
28-
const redirectURL = details.url.replace(
29-
/^devtools:\/\/devtools\/remote\/serve_file\/@[0-9a-f]{40}\//,
30-
"https://chrome-devtools-frontend.appspot.com/serve_file/@675968a8c657a3bd9c1c2c20c5d2935577bbc5e6/"
31-
);
32-
if (redirectURL !== details.url) {
33-
callback({ redirectURL });
34-
} else {
35-
callback({});
36-
}
37-
});
38-
createWindow();
25+
app.whenReady().then(async () => {
26+
await createWindow();
3927
initMenu();
4028
await updater.watch();
4129
});
4230

43-
app.on("activate", () => {
31+
app.on("activate", async () => {
4432
if (windows.length === 0) {
45-
createWindow();
33+
await createWindow();
4634
}
4735
});

src/main/window.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ export async function createWindow(): Promise<void> {
1212
titleBarStyle: process.platform === "darwin" ? "hidden" : undefined,
1313
icon: path.join(__dirname, "..", "icon.png"),
1414
webPreferences: {
15-
nodeIntegration: true
15+
nodeIntegration: true,
16+
enableRemoteModule: true
1617
}
1718
});
1819

19-
win.loadURL(`file://${__dirname}/../index.html`);
20+
await win.loadURL(`file://${__dirname}/../index.html`);
2021
win.once("closed", () => {
2122
const idx = windows.findIndex(w => w === win);
2223
windows.splice(idx, 1);
@@ -27,9 +28,9 @@ export async function createWindow(): Promise<void> {
2728
dialog.showErrorBox("Bdash is crashed", "Unrecoverable error");
2829
});
2930

30-
win.webContents.on("will-navigate", (e, url) => {
31+
win.webContents.on("will-navigate", async (e, url) => {
3132
e.preventDefault();
32-
shell.openExternal(url);
33+
await shell.openExternal(url);
3334
});
3435

3536
windows.push(win);

0 commit comments

Comments
 (0)