Skip to content

Commit 189a4ed

Browse files
committedMay 23, 2020
chore: update Electron to v9.0.0
1 parent 447d3e4 commit 189a4ed

File tree

11 files changed

+142
-87
lines changed

11 files changed

+142
-87
lines changed
 

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "lulumi-browser",
33
"productName": "Lulumi-browser",
44
"version": "1.4.0",
5-
"electronVersion": "6.1.12",
5+
"electronVersion": "9.0.0",
66
"description": "Lulumi-browser is a light weight browser coded with vue and electron",
77
"main": "./dist/main.js",
88
"scripts": {
@@ -79,7 +79,7 @@
7979
"css-loader": "^3.5.3",
8080
"del": "^5.1.0",
8181
"devtron": "^1.4.0",
82-
"electron": "^6.1.12",
82+
"electron": "^9.0.0",
8383
"electron-devtools-installer": "^3.0.0",
8484
"electron-packager": "^14.2.1",
8585
"electron-rebuild": "^1.11.0",

‎src/main/api/listeners.ts

+26-23
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,37 @@ ipcMain.on('open-dev-tools', (event, webContentsId) => {
1010
}
1111
});
1212
ipcMain.on('add-lulumi-extension', (event: IpcMainEvent) => {
13-
dialog.showOpenDialog(BrowserWindow.fromWebContents(event.sender), { properties: ['openDirectory'] }).then((res) => {
14-
if (!res.canceled && res.filePaths && res.filePaths.length > 0) {
15-
const dir: string = res.filePaths[0];
16-
let name = '';
17-
let result = 'OK';
18-
try {
19-
if (dir) {
20-
// an array of directory paths chosen by the user will be returned, but we only want one path
21-
name = ((BrowserWindow as any) as Lulumi.BrowserWindow).addLulumiExtension(dir);
13+
const browserWindow = BrowserWindow.fromWebContents(event.sender);
14+
if (browserWindow) {
15+
dialog.showOpenDialog(browserWindow, { properties: ['openDirectory'] }).then((res) => {
16+
if (!res.canceled && res.filePaths && res.filePaths.length > 0) {
17+
const dir: string = res.filePaths[0];
18+
let name = '';
19+
let result = 'OK';
20+
try {
21+
if (dir) {
22+
// an array of directory paths chosen by the user will be returned, but we only want one path
23+
name = ((BrowserWindow as any) as Lulumi.BrowserWindow).addLulumiExtension(dir);
24+
}
25+
} catch (readError) {
26+
result = readError.message;
2227
}
23-
} catch (readError) {
24-
result = readError.message;
25-
}
2628

27-
Object.keys(windows).forEach((key) => {
28-
const id = parseInt(key, 10);
29-
const window = windows[id];
30-
window.webContents.send('add-lulumi-extension-result', {
29+
Object.keys(windows).forEach((key) => {
30+
const id = parseInt(key, 10);
31+
const window = windows[id];
32+
window.webContents.send('add-lulumi-extension-result', {
33+
name,
34+
result,
35+
});
36+
});
37+
event.sender.send('add-lulumi-extension-result', {
3138
name,
3239
result,
3340
});
34-
});
35-
event.sender.send('add-lulumi-extension-result', {
36-
name,
37-
result,
38-
});
39-
}
40-
});
41+
}
42+
});
43+
}
4144
});
4245
ipcMain.on('remove-lulumi-extension', (event, extensionId) => {
4346
let result = 'OK';

‎src/main/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export default {
1515
lulumiPagesCustomProtocol: 'lulumi',
1616
lulumiPreloadPath: `${path.resolve(lulumiRootPath, 'dist')}`,
1717
lulumiPDFJSPath: `${path.resolve(lulumiHelperPath, 'pdfjs')}`,
18-
lulumiRev: '08edd5b9eae04e8b7a479f992b83110a74e90f47',
18+
lulumiRev: '447d3e4baa2a9fd4d2348d243e8d31333766d8be',
1919
};

‎src/main/index.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function lulumiStateSave(soft = true, windowCount = Object.keys(windows).length)
101101
}
102102
});
103103
window.close();
104-
window.removeAllListeners('close');
104+
// https://github.com/electron/electron/issues/22290
105+
(window as any).removeAllListeners('close');
105106
});
106107
}
107108
if (setLanguage) {
@@ -203,7 +204,10 @@ function createWindow(options?: Electron.BrowserWindowConstructorOptions, callba
203204
}
204205
});
205206

206-
mainWindow.on('close', () => (mainWindow.removeAllListeners('will-attach-webview')));
207+
mainWindow.on('close', () => {
208+
// https://github.com/electron/electron/issues/22290
209+
(mainWindow as any).removeAllListeners('will-attach-webview');
210+
});
207211

208212
mainWindow.on('closed', () => ((mainWindow as any) = null));
209213

@@ -457,10 +461,13 @@ ipcMain.on('get-window-count', (event: Electron.IpcMainEvent) => {
457461
// show the certificate
458462
ipcMain.on('show-certificate',
459463
(event: Electron.IpcMainEvent, certificate: Electron.Certificate, message: string) => {
460-
dialog.showCertificateTrustDialog(BrowserWindow.fromWebContents(event.sender), {
461-
certificate,
462-
message,
463-
}).then();
464+
const browserWindow = BrowserWindow.fromWebContents(event.sender);
465+
if (browserWindow) {
466+
dialog.showCertificateTrustDialog(browserWindow, {
467+
certificate,
468+
message,
469+
}).then();
470+
}
464471
});
465472

466473
// focus the window
@@ -487,9 +494,9 @@ ipcMain.on('show-item-in-folder', (event, itemPath) => {
487494
});
488495

489496
// open the item on host
490-
ipcMain.on('open-item', (event, itemPath) => {
497+
ipcMain.on('open-path', (event, itemPath) => {
491498
if (itemPath) {
492-
shell.openItem(itemPath);
499+
shell.openPath(itemPath);
493500
}
494501
});
495502

‎src/renderer/api/api-factory.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ export default (vueInstance: any) => {
162162
sendMessage: (tabId: number, message: any): void => {
163163
const tab = findAndUpdateOrCreate(vueInstance, false, tabId);
164164
if (tab.windowId === vueInstance.windowId) {
165-
vueInstance.getTab(getBuiltInTabIndex(vueInstance, tab.index)).$refs.webview.getWebContents().send('lulumi-tabs-send-message', message);
165+
vueInstance.$electron.remote.webContents.fromId(
166+
vueInstance.getTab(getBuiltInTabIndex(vueInstance, tab.index)).$refs.webview.getWebContentsId()
167+
).send('lulumi-tabs-send-message', message);
166168
}
167169
},
168170
onActivated: vueInstance.onActivatedEvent,
@@ -377,7 +379,9 @@ export default (vueInstance: any) => {
377379
getFrame: (details: chrome.webNavigation.GetFrameDetails, suffix: string, webContentsId: number): void => {
378380
const tab = findAndUpdateOrCreate(vueInstance, false, details.tabId);
379381
if (tab.windowId === vueInstance.windowId) {
380-
const processId = vueInstance.getWebView(getBuiltInTabIndex(vueInstance, tab.index)).getWebContents().getOSProcessId();
382+
const processId = vueInstance.$electron.remote.webContents.fromId(
383+
vueInstance.getWebView(getBuiltInTabIndex(vueInstance, tab.index)).getWebContentsId()
384+
).getOSProcessId();
381385
if (details.processId === processId) {
382386
vueInstance.getTab(getBuiltInTabIndex(vueInstance, tab.index)).$refs.webview.executeJavaScript(`
383387
String.prototype.hashCode = function() {
@@ -428,7 +432,9 @@ export default (vueInstance: any) => {
428432
getAllFrames: (details: chrome.webNavigation.GetAllFrameDetails, suffix: string, webContentsId: number): void => {
429433
const tab = findAndUpdateOrCreate(vueInstance, false, details.tabId);
430434
if (tab.windowId === vueInstance.windowId) {
431-
const processId = vueInstance.getWebView(getBuiltInTabIndex(vueInstance, tab.index)).getWebContents().getOSProcessId();
435+
const processId = vueInstance.$electron.remote.webContents.fromId(
436+
vueInstance.getWebView(getBuiltInTabIndex(vueInstance, tab.index)).getWebContentsId()
437+
).getOSProcessId();
432438
vueInstance.getTab(getBuiltInTabIndex(vueInstance, tab.index)).$refs.webview.executeJavaScript(`
433439
String.prototype.hashCode = function() {
434440
var hash = 0, i, chr;

‎src/renderer/mainBrowserWindow/components/BrowserMainView.vue

+33-14
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ export default class BrowserMainView extends Vue {
340340
this.onCommitted.emit({
341341
frameId: 0,
342342
parentFrameId: -1,
343-
processId: this.getWebView(tabIndex).getWebContents().getOSProcessId(),
343+
processId: this.$electron.remote.webContents.fromId(
344+
this.getWebView(tabIndex).getWebContentsId()
345+
).getOSProcessId(),
344346
tabId: this.getTabObject(tabIndex).id,
345347
timeStamp: Date.now(),
346348
url: webview.getAttribute('src'),
@@ -356,7 +358,9 @@ export default class BrowserMainView extends Vue {
356358
this.onCompleted.emit({
357359
frameId: 0,
358360
parentFrameId: -1,
359-
processId: this.getWebView(tabIndex).getWebContents().getOSProcessId(),
361+
processId: this.$electron.remote.webContents.fromId(
362+
this.getWebView(tabIndex).getWebContentsId()
363+
).getOSProcessId(),
360364
tabId: this.getTabObject(tabIndex).id,
361365
timeStamp: Date.now(),
362366
url: event.url,
@@ -398,7 +402,9 @@ export default class BrowserMainView extends Vue {
398402
windowId: this.windowId,
399403
});
400404
} else {
401-
webview.getWebContents().downloadURL(parsedURL.query.src as string);
405+
this.$electron.remote.webContents.fromId(
406+
webview.getWebContentsId()
407+
).downloadURL(parsedURL.query.src as string);
402408
}
403409
} else {
404410
this.$store.dispatch('domReady', {
@@ -413,7 +419,9 @@ export default class BrowserMainView extends Vue {
413419
url,
414420
frameId: 0,
415421
parentFrameId: -1,
416-
processId: this.getWebView(tabIndex).getWebContents().getOSProcessId(),
422+
processId: this.$electron.remote.webContents.fromId(
423+
this.getWebView(tabIndex).getWebContentsId()
424+
).getOSProcessId(),
417425
tabId: this.getTabObject(tabIndex).id,
418426
timeStamp: Date.now(),
419427
});
@@ -595,7 +603,9 @@ export default class BrowserMainView extends Vue {
595603
}
596604
this.onCreatedNavigationTarget.emit({
597605
sourceTabId: this.getTabObject(tabIndex).id,
598-
sourceProcessId: this.getWebView(tabIndex).getWebContents().getOSProcessId(),
606+
sourceProcessId: this.$electron.remote.webContents.fromId(
607+
this.getWebView(tabIndex).getWebContentsId()
608+
).getOSProcessId(),
599609
sourceFrameId: 0,
600610
timeStamp: Date.now(),
601611
url: event.url,
@@ -1018,12 +1028,14 @@ export default class BrowserMainView extends Vue {
10181028
const webview = this.getWebView();
10191029
const url = urlUtil.getUrlIfError(this.tab.url);
10201030
if (webview.getURL() === url) {
1021-
webview.getWebContents().openDevTools({ mode: 'bottom' });
1031+
this.$electron.remote.webContents.fromId(
1032+
webview.getWebContentsId()
1033+
).openDevTools({ mode: 'bottom' });
10221034
}
10231035
}
10241036
onClickJavaScriptPanel(): void {
10251037
const webview = this.getWebView();
1026-
const webContent = webview.getWebContents();
1038+
const webContent = this.$electron.remote.webContents.fromId(webview.getWebContentsId());
10271039
if (webContent.isDevToolsOpened()) {
10281040
webContent.closeDevTools();
10291041
} else {
@@ -1081,7 +1093,7 @@ export default class BrowserMainView extends Vue {
10811093
if (currentWindow) {
10821094
const menuItems: any[] = [];
10831095
const webview = this.getWebView();
1084-
const webContents: any = webview.getWebContents();
1096+
const webContents: any = this.$electron.remote.webContents.fromId(webview.getWebContentsId());
10851097
const navbar = document.getElementById('browser-navbar');
10861098
const goBack = document.getElementById('browser-navbar__goBack');
10871099
@@ -1145,7 +1157,7 @@ export default class BrowserMainView extends Vue {
11451157
if (currentWindow) {
11461158
const menuItems: any[] = [];
11471159
const webview = this.getWebView();
1148-
const webContents: any = webview.getWebContents();
1160+
const webContents: any = this.$electron.remote.webContents.fromId(webview.getWebContentsId());
11491161
const navbar = document.getElementById('browser-navbar');
11501162
const goForward = document.getElementById('browser-navbar__goForward');
11511163
@@ -1477,8 +1489,9 @@ export default class BrowserMainView extends Vue {
14771489
menu.append(new MenuItem({
14781490
label: this.$t('webview.contextMenu.openLinkInNewWindow') as string,
14791491
click: () => {
1480-
const webContent = webview.getWebContents();
1481-
webContent.executeJavaScript(`window.open('${params.linkURL}')`);
1492+
this.$electron.remote.webContents.fromId(
1493+
webview.getWebContentsId()
1494+
).executeJavaScript(`window.open('${params.linkURL}')`);
14821495
},
14831496
}));
14841497
@@ -1632,15 +1645,21 @@ export default class BrowserMainView extends Vue {
16321645
const ipc = this.$electron.ipcRenderer;
16331646
16341647
ipc.on('reset-zoom', () => {
1635-
this.getWebView().getWebContents().setZoomLevel(0);
1648+
this.$electron.remote.webContents.fromId(
1649+
this.getWebView().getWebContentsId()
1650+
).setZoomLevel(0);
16361651
});
16371652
ipc.on('zoom-in', () => {
1638-
const webContents = this.getWebView().getWebContents();
1653+
const webContents = this.$electron.remote.webContents.fromId(
1654+
this.getWebView().getWebContentsId()
1655+
);
16391656
const zoomLevel = webContents.getZoomLevel();
16401657
webContents.setZoomLevel(zoomLevel + 0.5);
16411658
});
16421659
ipc.on('zoom-out', () => {
1643-
const webContents = this.getWebView().getWebContents();
1660+
const webContents = this.$electron.remote.webContents.fromId(
1661+
this.getWebView().getWebContentsId()
1662+
);
16441663
const zoomLevel = webContents.getZoomLevel();
16451664
webContents.setZoomLevel(zoomLevel - 0.5);
16461665
});

‎src/renderer/mainBrowserWindow/components/BrowserMainView/Download.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ transition(name="download-bar")
4141
img(:fetch="getFileIcon(file.savePath, index)", :id="`icon-${index}`")
4242
a(class="download-list__item-name",
4343
href='#',
44-
@click.prevent="openItem(file.savePath)")
44+
@click.prevent="openPath(file.savePath)")
4545
| {{ file.name }}
4646
span(class="download-list__item-description") {{ progress(file) }}
4747
el-progress(:status="checkStateForProgress(file.dataState)",
@@ -109,8 +109,8 @@ export default class Download extends Vue {
109109
showItemInFolder(savePath: string): void {
110110
this.$electron.ipcRenderer.send('show-item-in-folder', savePath);
111111
}
112-
openItem(savePath: string): void {
113-
this.$electron.ipcRenderer.send('open-item', savePath);
112+
openPath(savePath: string): void {
113+
this.$electron.ipcRenderer.send('open-path', savePath);
114114
}
115115
checkStateForButtonGroup(state: string): boolean {
116116
switch (state) {

‎src/renderer/preferenceView/components/AboutMainView/Lulumi.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
| {{ scope.row.value.substring(0, 7) }}
1111
.cell(v-else-if="scope.row.key === 'userData'",
1212
style="color: cornflowerblue; cursor: pointer;",
13-
@click="openItem(scope.row.value)") {{ scope.row.value }}
13+
@click="openPath(scope.row.value)") {{ scope.row.value }}
1414
.cell(v-else) {{ scope.row.value }}
1515
</template>
1616

@@ -32,8 +32,8 @@ export default class Lulumi extends Vue {
3232
return this.$store.getters.about.lulumi;
3333
}
3434
35-
openItem(userData: string): void {
36-
ipcRenderer.send('open-item', userData);
35+
openPath(userData: string): void {
36+
ipcRenderer.send('open-path', userData);
3737
}
3838
}
3939
</script>

0 commit comments

Comments
 (0)
Please sign in to comment.