Skip to content

Commit

Permalink
update to electron 15
Browse files Browse the repository at this point in the history
in large parts this is avoiding the use of the electron.remote, which has been removed in electron 14
  • Loading branch information
TanninOne committed Oct 7, 2021
1 parent f4656ac commit de31d08
Show file tree
Hide file tree
Showing 108 changed files with 1,873 additions and 2,252 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
disturl=https://atom.io/download/electron
target=13.4.0
target=15.1.0
runtime=electron
arch=x64
target_arch=x64
7 changes: 4 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vortex",
"version": "1.5.0-r32+internal",
"version": "1.5.0-r34+internal",
"productName": "Vortex",
"description": "Vortex",
"author": "Black Tree Gaming Ltd.",
Expand All @@ -11,9 +11,10 @@
"url": "https://github.com/Nexus-Mods/Vortex"
},
"vortex": {
"electron": "13.4.0"
"electron": "15.1.0"
},
"dependencies": {
"@electron/remote": "^2.0.1",
"@msgpack/msgpack": "^2.7.0",
"@nexusmods/nexus-api": "git+ssh://[email protected]:vortex/node-nexus-api.git#mod-packs",
"bbcode-to-react": "TanninOne/bbcode-to-react",
Expand All @@ -27,7 +28,7 @@
"crash-dump": "Nexus-Mods/node-crash-dump",
"d3": "^5.14.1",
"date-fns": "^2.8.0",
"diskusage": "^1.1.3",
"diskusage": "blagoev/node-diskusage",
"dnd-core": "^9.4.0",
"draggabilly": "^2.2.0",
"drivelist": "TanninOne/drivelist",
Expand Down
24 changes: 14 additions & 10 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
dependencies:
regenerator-runtime "^0.13.4"

"@electron/remote@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.0.1.tgz#810cbc595a21f0f94641eb2d7e8264063a3f84de"
integrity sha512-bGX4/yB2bPZwXm1DsxgoABgH0Cz7oFtXJgkerB8VrStYdTyvhGAULzNLRn9rVmeAuC3VUDXaXpZIlZAZHpsLIA==

"@hypnosphi/create-react-context@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@hypnosphi/create-react-context/-/create-react-context-0.3.1.tgz#f8bfebdc7665f5d426cba3753e0e9c7d3154d7c6"
Expand Down Expand Up @@ -1017,13 +1022,12 @@ detect-libc@^1.0.2, detect-libc@^1.0.3:
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=

diskusage@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/diskusage/-/diskusage-1.1.3.tgz#680d7dbf1b679168a195c9240eb3552cbd2c067b"
integrity sha512-EAyaxl8hy4Ph07kzlzGTfpbZMNAAAHXSZtNEMwdlnSd1noHzvA6HsgKt4fEMSvaEXQYLSphe5rPMxN4WOj0hcQ==
diskusage@blagoev/node-diskusage:
version "2.0.0"
resolved "https://codeload.github.com/blagoev/node-diskusage/tar.gz/635d4236ee41a14ca4ff8adf9f4b89aee109eb02"
dependencies:
es6-promise "^4.2.5"
nan "^2.14.0"
node-addon-api "^2.0.0"

dnd-core@^10.0.2:
version "10.0.2"
Expand Down Expand Up @@ -2329,11 +2333,6 @@ [email protected]:
colors "*"
events "*"

nan@^2.14.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

nan@~2.14.0:
version "2.14.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
Expand Down Expand Up @@ -2390,6 +2389,11 @@ node-addon-api@*, node-addon-api@^3.1.0:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161"
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==

node-addon-api@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32"
integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==

node-addon-api@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.0.0.tgz#ac128f43eff7fac4b5f5ef2f39d6d7c2709efead"
Expand Down
3 changes: 2 additions & 1 deletion electron-builder-advanced.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"bundledPlugins",
"lib/modinstaller",
"node_modules/7z-bin",
"node_modules/nbind",
"node_modules/bootstrap-sass/assets/stylesheets",
"node_modules/react-select/scss",
"node_modules/fomod-installer/dist",
Expand All @@ -20,6 +19,7 @@
],
"afterSign": "./createMD5List.js",
"appId": "com.nexusmods.vortex",
"includeSubNodeModules": true,
"win": {
"target": "nsis",
"publish": [
Expand Down Expand Up @@ -69,6 +69,7 @@
"!**/*.js.map",
"!**/*.iobj",
"!**/*.ipdb",
"!**/*.ilk",
"!**/*.vcxproj",
"!**/*.vcxproj.filters",
"!**/Makefile",
Expand Down
3 changes: 2 additions & 1 deletion electron-builder-oneclick.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"bundledPlugins",
"lib/modinstaller",
"node_modules/7z-bin",
"node_modules/nbind",
"node_modules/bootstrap-sass/assets/stylesheets",
"node_modules/react-select/scss",
"node_modules/fomod-installer/dist",
Expand All @@ -17,6 +16,7 @@
],
"afterSign": "./createMD5List.js",
"appId": "com.nexusmods.vortex",
"includeSubNodeModules": true,
"win": {
"target": "nsis",
"publish": [
Expand Down Expand Up @@ -64,6 +64,7 @@
"!**/*.js.map",
"!**/*.iobj",
"!**/*.ipdb",
"!**/*.ilk",
"!**/*.vcxproj",
"!**/*.vcxproj.filters",
"!**/Makefile",
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/Nexus-Mods/Vortex"
},
"vortex": {
"electron": "13.4.0"
"electron": "15.1.0"
},
"scripts": {
"_assets_out": "tsc -p extensions/games && node InstallAssets.js out && sass --style compressed src/stylesheets/loadingScreen.scss > out/assets/css/loadingScreen.css",
Expand Down Expand Up @@ -118,7 +118,7 @@
"@types/levelup": "^4.3.0",
"@types/lodash": "^4.14.149",
"@types/minimatch": "^3.0.3",
"@types/node": "12.12.35",
"@types/node": "^16.5.0",
"@types/node-uuid": "^0.0.28",
"@types/react": "^16.9.43",
"@types/react-bootstrap": "^0.32.20",
Expand Down Expand Up @@ -162,8 +162,8 @@
"copyfiles": "^2.3.0",
"cross-env": "^6.0.3",
"devtron": "^1.4.0",
"electron": "^13.4.0",
"electron-builder": "20.15.0",
"electron": "^15.1.0",
"electron-builder": "^22.13.1",
"electron-devtools-installer": "rwwagner90/electron-devtools-installer",
"electron-download-tf": "^4.3.4",
"electron-rebuild": "^1.8.8",
Expand All @@ -187,19 +187,20 @@
"resolve-url-loader": "3.1.1",
"rm-local-modules": "^0.0.2",
"sass-loader": "^8.0.0",
"terser-webpack-plugin": "^2.2.1",
"terser-webpack-plugin": "^5.2.4",
"ts-jest": "^24.1.0",
"ts-loader": "^6.2.1",
"ts-loader": "^9.2.6",
"tslint": "^5.20.1",
"tslint-eslint-rules": "^5.4.0",
"tslint-react": "^4.1.0",
"typescript": "^3.7.2",
"typescript": "^4.4.3",
"vortex-api": "Nexus-Mods/vortex-api#mod-packs",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-node-externals": "^1.7.2"
"webpack": "^5.57.1",
"webpack-cli": "^4.8.0",
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"@electron/remote": "^2.0.1",
"@msgpack/msgpack": "^2.7.0",
"@nexusmods/nexus-api": "git+ssh://[email protected]:vortex/node-nexus-api.git#mod-packs",
"bbcode-to-react": "TanninOne/bbcode-to-react",
Expand All @@ -213,7 +214,7 @@
"crash-dump": "Nexus-Mods/node-crash-dump",
"d3": "^5.14.1",
"date-fns": "^2.8.0",
"diskusage": "^1.1.3",
"diskusage": "blagoev/node-diskusage",
"dnd-core": "^9.4.0",
"draggabilly": "^2.2.0",
"drivelist": "TanninOne/drivelist",
Expand Down
12 changes: 7 additions & 5 deletions src/app/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NEXUS_DOMAIN } from '../extensions/nexus_integration/constants';
import { STATE_BACKUP_PATH } from '../reducers/index';
import { ThunkStore } from '../types/api';
import {IState} from '../types/IState';
import { getApplication } from '../util/application';
import commandLine, {IParameters, relaunch} from '../util/commandLine';
import { DataInvalid, DocumentsPathMissing, ProcessCanceled,
UserCanceled } from '../util/CustomErrors';
Expand Down Expand Up @@ -202,6 +203,8 @@ class Application {
});

app.on('web-contents-created', (event: Electron.Event, contents: Electron.WebContents) => {
// tslint:disable-next-line:no-submodule-imports
require('@electron/remote/main').enable(contents);
contents.on('will-attach-webview', this.attachWebView);
});
}
Expand All @@ -215,7 +218,6 @@ class Application {
delete webPreferences.preloadURL;

webPreferences.nodeIntegration = false;
webPreferences.enableRemoteModule = false;
}

private genHandleError() {
Expand Down Expand Up @@ -257,7 +259,7 @@ class Application {
.catch(() => null)
.tap(() => {
log('info', '--------------------------');
log('info', 'Vortex Version', app.getVersion());
log('info', 'Vortex Version', getApplication().version);
log('info', 'Parameters', process.argv.join(' '));
})
.then(() => this.testUserEnvironment())
Expand Down Expand Up @@ -468,7 +470,7 @@ class Application {
}

private checkUpgrade(): Promise<void> {
const currentVersion = app.getVersion();
const currentVersion = getApplication().version;
return this.migrateIfNecessary(currentVersion)
.then(() => {
this.mStore.dispatch(setApplicationVersion(currentVersion));
Expand Down Expand Up @@ -676,7 +678,7 @@ class Application {
// In development of 1.4 I assumed we had a case where this was necessary.
// Turned out it wasn't, still feel it's sensible to have this
// information available asap
startupSettings.storeVersion = app.getVersion();
startupSettings.storeVersion = getApplication().version;

// 1. load only user settings to determine if we're in multi-user mode
// 2. load app settings to determine which extensions to load
Expand Down Expand Up @@ -720,7 +722,7 @@ class Application {
log('info', 'all further logging will happen in', path.join(dataPath, 'vortex.log'));
setLogPath(dataPath);
log('info', '--------------------------');
log('info', 'Vortex Version', app.getVersion());
log('info', 'Vortex Version', getApplication().version);
return LevelPersist.create(
path.join(dataPath, currentStatePath),
undefined,
Expand Down
7 changes: 3 additions & 4 deletions src/app/MainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ class MainWindow {
}
});

this.mWindow.webContents.on('new-window', (event, url, frameName, disposition) => {
if (disposition === 'background-tab') {
event.preventDefault();
this.mWindow.webContents.setWindowOpenHandler((details) => {
if (details.disposition === 'background-tab') {
return { action: 'deny' };
}
});

Expand Down Expand Up @@ -268,7 +268,6 @@ class MainWindow {
nodeIntegrationInWorker: true,
webviewTag: true,
enableWebSQL: false,
enableRemoteModule: true,
contextIsolation: false,
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/controls/Advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ function mapStateToProps(state: IState): IConnectedProps {
};
}

export default connect(mapStateToProps)(Advanced);
export default connect(mapStateToProps)(Advanced) as React.ComponentType<{}>;
4 changes: 2 additions & 2 deletions src/controls/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MyDropdown extends React.Component<IProps, { up: boolean }> {
);
}

private get bounds(): ClientRect {
private get bounds(): DOMRect {
return this.props.container
? this.props.container.getBoundingClientRect()
: {
Expand All @@ -71,7 +71,7 @@ class MyDropdown extends React.Component<IProps, { up: boolean }> {
right: window.innerWidth,
height: window.innerHeight,
width: window.innerWidth,
};
} as any;
}

private onToggle = (isOpen: boolean) => {
Expand Down
4 changes: 2 additions & 2 deletions src/controls/DropdownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MyDropdownButton extends React.Component<IProps, { up: boolean, right: boo
);
}

private get bounds(): ClientRect {
private get bounds(): DOMRect {
return this.props.container
? this.props.container.getBoundingClientRect()
: {
Expand All @@ -57,7 +57,7 @@ class MyDropdownButton extends React.Component<IProps, { up: boolean, right: boo
right: window.innerWidth,
height: window.innerHeight,
width: window.innerWidth,
};
} as any;
}

private onToggle = (isOpen: boolean) => {
Expand Down
4 changes: 2 additions & 2 deletions src/controls/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { renderError } from '../util/message';
import Icon from './Icon';
import { IconButton } from './TooltipControls';

import { remote } from 'electron';
import * as _ from 'lodash';
import * as React from 'react';
import { Alert, Button } from 'react-bootstrap';
import { WithTranslation } from 'react-i18next';
import { getApplication } from '../util/application';

export type CBFunction = (...args: any[]) => void;

Expand Down Expand Up @@ -137,7 +137,7 @@ class ErrorBoundary extends ComponentEx<IErrorBoundaryProps, IErrorBoundaryState
onHide();
}
let errMessage = 'Component rendering error\n\n'
+ `Vortex Version: ${remote.app.getVersion()}\n\n`
+ `Vortex Version: ${getApplication().version}\n\n`
+ `${error.stack}`;

if (errorInfo !== undefined) {
Expand Down
14 changes: 7 additions & 7 deletions src/controls/FormFields.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import FormFeedback from './FormFeedback';
import { IconButton } from './TooltipControls';

import { remote } from 'electron';
import { TFunction } from 'i18next';
import * as React from 'react';
import { Checkbox, Col, ControlLabel,
FormControl, FormGroup,
InputGroup } from 'react-bootstrap';
import { ComponentEx } from '../util/ComponentEx';

export interface IFormItemProps {
t: TFunction;
Expand Down Expand Up @@ -93,7 +93,7 @@ export interface IFormPathProps extends IFormItemProps {
extensions?: string[];
}

export class FormPathItem extends React.Component<IFormPathProps, {}> {
export class FormPathItem extends ComponentEx<IFormPathProps, {}> {
public render(): JSX.Element {
const { t, controlId, label, placeholder, readOnly, style, value } = this.props;

Expand Down Expand Up @@ -149,16 +149,16 @@ export class FormPathItem extends React.Component<IFormPathProps, {}> {

private handleChangePath = () => {
const {directory, extensions, onChangeValue, stateKey, value} = this.props;
remote.dialog.showOpenDialog(remote.getCurrentWindow(), {
const func = directory ? this.context.api.selectDir : this.context.api.selectFile;

func({
defaultPath: value,
properties: [ directory ? 'openDirectory' : 'openFile' ],
filters: extensions !== undefined ? [
{ name: 'Files', extensions },
] : [],
}).then(result => {
const { filePaths } = result;
if ((filePaths !== undefined) && (filePaths.length > 0)) {
onChangeValue(stateKey, filePaths[0]);
if (result !== undefined) {
onChangeValue(stateKey, result);
}
});
}
Expand Down
Loading

0 comments on commit de31d08

Please sign in to comment.