chore: upgrade electron

This commit is contained in:
Johannes Millan 2020-08-29 00:07:35 +02:00
parent f69f8fab64
commit 114d146bc4
6 changed files with 17 additions and 9 deletions

View file

@ -78,6 +78,8 @@ export const createWindow = ({
scrollBounce: true,
webSecurity: !IS_DEV,
nodeIntegration: true,
// NOTE: will be deprecated with v10
enableRemoteModule: true
},
icon: ICONS_FOLDER + '/icon_256x256.png'
});

View file

@ -137,7 +137,7 @@
"conventional-changelog-cli": "^2.0.21",
"core-js": "^3.1.3",
"cross-env": "^7.0.2",
"electron": "^9.1.1",
"electron": "^10.1.0",
"electron-builder": "^22.7.0",
"electron-notarize": "^1.0.0",
"electron-reload": "^1.2.5",

View file

@ -3,6 +3,8 @@ import { Injectable } from '@angular/core';
// the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, remote, shell, webFrame } from 'electron';
import { IS_ELECTRON } from '../../app.constants';
import { getElectron } from '../../util/get-electron';
import * as ElectronRenderer from 'electron/renderer';
@Injectable({providedIn: 'root'})
export class ElectronService {
@ -16,11 +18,12 @@ export class ElectronService {
constructor() {
// Conditional imports
if (IS_ELECTRON) {
const electron = window.require('electron');
const electron = getElectron() as typeof ElectronRenderer;
this.ipcRenderer = electron.ipcRenderer;
this.webFrame = electron.webFrame;
this.remote = electron.remote;
this.shell = electron.shell;
// NOTE: works for non-sandboxed electron only
this.shell = (electron as any).shell;
}
// NOTE: useful in case we want to disable the node integration

View file

@ -3,8 +3,9 @@ import { ConfigFormSection, LocalBackupConfig } from '../global-config.model';
import { T } from '../../../t.const';
import { getElectron } from '../../../util/get-electron';
import { IS_ELECTRON } from '../../../app.constants';
import * as ElectronRenderer from 'electron/renderer';
const backupPath = IS_ELECTRON && `${(getElectron() as Electron.RendererInterface).remote.app.getPath('userData')}/backups`;
const backupPath = IS_ELECTRON && `${(getElectron() as typeof ElectronRenderer).remote.app.getPath('userData')}/backups`;
export const AUTOMATIC_BACKUPS_FORM: ConfigFormSection<LocalBackupConfig> = {
isElectronOnly: true,

View file

@ -1,5 +1,7 @@
import * as ElectronRenderer from 'electron/renderer';
let _electron: any = null;
export const getElectron = (): Electron.RendererInterface | null => {
export const getElectron = (): typeof ElectronRenderer | null => {
// tslint:disable-next-line
if (window['require']) {
_electron = window.require('electron');

View file

@ -4543,10 +4543,10 @@ electron-window-state@^5.0.3:
jsonfile "^4.0.0"
mkdirp "^0.5.1"
electron@^9.1.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/electron/-/electron-9.1.1.tgz#d52c9873be4113287c3eb2b02f85bad6644b100e"
integrity sha512-BYvroBLV9x7G4iN33P/IxeZqwjl62/9VuBAF1CoM0m6OeheaiLog1ZMKLlCqVXycJvvrAvLHc454DDEmwnqqhA==
electron@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/electron/-/electron-10.1.0.tgz#3559182545dc76e20d9764d183d555415d55c250"
integrity sha512-DyS6WhQ59+ZXQsI1EkpsYkOXFt0Xbp+mbxPTJS9A7O21r3JDzaTC+1Jxz7g6J+Sbi9Y7UFdRs0tn/vqhHJx2gA==
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^12.0.12"