diff --git a/main.js b/main.js
index 387850d6..12ba0d13 100644
--- a/main.js
+++ b/main.js
@@ -98,6 +98,8 @@ function createMainWindow() {
open(url);
});
+ require('@electron/remote/main').enable(mainWindow.webContents);
+
mainWindow.menuBarVisible = false;
mainWindow.loadURL(indexPath);
diff --git a/package.json b/package.json
index a8b75fa0..37a45514 100644
--- a/package.json
+++ b/package.json
@@ -55,8 +55,8 @@
"core-js": "^3.18.0",
"dayjs": "^1.10.7",
"del": "^6.0.0",
- "electron-json-config": "^1.5.3",
- "electron-react-titlebar": "^0.8.2",
+ "@msfs/electron-json-config": "^1.0.0",
+ "@msfs/electron-react-titlebar": "^1.0.0",
"electron-squirrel-startup": "^1.0.0",
"mdi-react": "^7.5.0",
"node-fetch": "^2.6.5",
@@ -90,7 +90,7 @@
"cross-env": "^7.0.3",
"css-loader": "^5.2.7",
"dotenv": "^8.6.0",
- "electron": "^13.4.0",
+ "electron": "^14.0.1",
"electron-installer-windows": "^3.0.0",
"electron-packager": "^15.4.0",
"eslint": "^7.32.0",
diff --git a/src/components/App.js b/src/components/App.js
index be91aea0..d7187ea5 100644
--- a/src/components/App.js
+++ b/src/components/App.js
@@ -10,7 +10,6 @@ import { CssBaseline } from '@material-ui/core';
import { makeStyles, ThemeProvider } from '@material-ui/core/styles';
import { TitleBar } from 'electron-react-titlebar';
-import Config from 'electron-json-config';
import ConfigKeys from '../data/config-keys.json';
import Theme from '../data/Theme';
@@ -23,6 +22,7 @@ import 'electron-react-titlebar/assets/style.css';
import { SnackbarProvider } from 'notistack';
import { LocaleProvider } from '../locales/LocaleContext';
import MainAppErrorBoundary from './ErrorBoundaries/MainAppErrorBoundary';
+import getConfigInstance from '../helpers/getConfigInstance';
const useStyles = makeStyles({
titlebar: {
@@ -39,7 +39,7 @@ const useStyles = makeStyles({
function App() {
const classes = useStyles();
- const [language, setLanguage] = React.useState(Config.get(ConfigKeys.settings.locale, 'en-GB'));
+ const [language, setLanguage] = React.useState(getConfigInstance().get(ConfigKeys.settings.locale, 'en-GB'));
return (
<>
diff --git a/src/components/HomeTabs/AvailableLiveries/AvailableLiveries.js b/src/components/HomeTabs/AvailableLiveries/AvailableLiveries.js
index 6c0d6077..57ddaecb 100644
--- a/src/components/HomeTabs/AvailableLiveries/AvailableLiveries.js
+++ b/src/components/HomeTabs/AvailableLiveries/AvailableLiveries.js
@@ -21,8 +21,8 @@ import NoImage from '../../../images/no-image-available.png';
// support libraries
import { useSnackbar } from 'notistack';
-import Config from 'electron-json-config';
import LocaleContext from '../../../locales/LocaleContext';
+import getConfigInstance from '../../../helpers/getConfigInstance';
export default function AvailableLiveries(props) {
const CurrentLocale = React.useContext(LocaleContext);
@@ -130,7 +130,7 @@ export default function AvailableLiveries(props) {
}
suggestions={[
CurrentLocale.translate('manager.pages.available_liveries.errors.installed_addons_fail.suggestion1', {
- path: Config.get(ConfigKeys.settings.package_directory),
+ path: getConfigInstance().get(ConfigKeys.settings.package_directory),
}),
CurrentLocale.translate('manager.pages.available_liveries.errors.installed_addons_fail.suggestion2'),
]}
diff --git a/src/components/HomeTabs/InstalledLiveries/ListRow.js b/src/components/HomeTabs/InstalledLiveries/ListRow.js
index 51e04497..52227c27 100644
--- a/src/components/HomeTabs/InstalledLiveries/ListRow.js
+++ b/src/components/HomeTabs/InstalledLiveries/ListRow.js
@@ -219,7 +219,7 @@ export default function ListRow(props) {
({
root: {
@@ -132,7 +132,7 @@ export default function Settings() {
function toggleAdvanced(e) {
if (e.detail === 5) {
if (IsAdvancedUser()) {
- Config.set(CONFIG_KEYS.settings.show_advanced_settings, false);
+ getConfigInstance().set(CONFIG_KEYS.settings.show_advanced_settings, false);
enqueueSnackbar(CurrentLocale.translate('manager.pages.settings.advanced_settings.disabled_notification'), {
variant: 'info',
});
@@ -146,7 +146,7 @@ export default function Settings() {
);
if (d === 0) {
- Config.set(CONFIG_KEYS.settings.show_advanced_settings, true);
+ getConfigInstance().set(CONFIG_KEYS.settings.show_advanced_settings, true);
enqueueSnackbar(CurrentLocale.translate('manager.pages.settings.advanced_settings.enabled_notification'), {
variant: 'warning',
});
@@ -174,7 +174,7 @@ export default function Settings() {
if (isValid) {
setError(null);
- if (d[0] !== Config.get(CONFIG_KEYS.settings.package_directory)) {
+ if (d[0] !== getConfigInstance().get(CONFIG_KEYS.settings.package_directory)) {
setSaveButtonEnabled(true);
}
} else {
@@ -213,13 +213,13 @@ export default function Settings() {
inputRef={PackagesDirTB}
variant="filled"
label={CurrentLocale.translate('manager.pages.settings.user_settings.community_folder.input_label')}
- defaultValue={Config.get(CONFIG_KEYS.settings.package_directory)}
+ defaultValue={getConfigInstance().get(CONFIG_KEYS.settings.package_directory)}
onChange={e => {
const [isValid, errorMsg] = ValidateFSDirectory(e.currentTarget.value, CurrentLocale);
if (isValid) {
setError(null);
- if (e.currentTarget.value !== Config.get(CONFIG_KEYS.settings.package_directory)) {
+ if (e.currentTarget.value !== getConfigInstance().get(CONFIG_KEYS.settings.package_directory)) {
setSaveButtonEnabled(true);
}
} else {
@@ -233,7 +233,7 @@ export default function Settings() {
color="textSecondary"
className={classes.resetLink}
onClick={() => {
- PackagesDirTB.current.value = Config.get(CONFIG_KEYS.settings.package_directory);
+ PackagesDirTB.current.value = getConfigInstance().get(CONFIG_KEYS.settings.package_directory);
const [isValid, errorMsg] = ValidateFSDirectory(PackagesDirTB.current.value, CurrentLocale);
@@ -258,7 +258,7 @@ export default function Settings() {
target.innerText = CurrentLocale.translate('manager.pages.settings.user_settings.community_folder.open_in_explorer');
}, 2500);
- ElectronRemote.shell.showItemInFolder(Config.get(CONFIG_KEYS.settings.package_directory));
+ ElectronRemote.shell.showItemInFolder(getConfigInstance().get(CONFIG_KEYS.settings.package_directory));
}}
>
{CurrentLocale.translate('manager.pages.settings.user_settings.community_folder.open_in_explorer')}
@@ -396,7 +396,7 @@ export default function Settings() {
onClick={() => {
setSaveButtonEnabled(false);
- Config.setBulk({
+ getConfigInstance().setBulk({
[CONFIG_KEYS.settings.package_directory]: PackagesDirTB.current.value,
});
}}
diff --git a/src/data/IsAdvancedUser.js b/src/data/IsAdvancedUser.js
index 7f50ec47..c5431659 100644
--- a/src/data/IsAdvancedUser.js
+++ b/src/data/IsAdvancedUser.js
@@ -1,4 +1,4 @@
-import Config from 'electron-json-config';
+import getConfigInstance from '../helpers/getConfigInstance';
import CONFIG_KEYS from './config-keys.json';
-export default () => Config.get(CONFIG_KEYS.settings.show_advanced_settings) || false;
+export default () => getConfigInstance().get(CONFIG_KEYS.settings.show_advanced_settings) || false;
diff --git a/src/data/Theme.js b/src/data/Theme.js
index e8672b14..f417ece8 100644
--- a/src/data/Theme.js
+++ b/src/data/Theme.js
@@ -1,6 +1,6 @@
-import { createMuiTheme, colors } from '@material-ui/core';
+import { createTheme, colors } from '@material-ui/core';
-export default createMuiTheme({
+export default createTheme({
typography: {
fontFamily: 'Poppins',
fontSize: 18,
diff --git a/src/helpers/AddonInstaller/InstallAddon.js b/src/helpers/AddonInstaller/InstallAddon.js
index c4d2731d..c35c6e24 100644
--- a/src/helpers/AddonInstaller/InstallAddon.js
+++ b/src/helpers/AddonInstaller/InstallAddon.js
@@ -5,13 +5,13 @@ import * as ElectronRemote from '@electron/remote';
import admzip from 'adm-zip';
import request from 'request';
import progress from 'request-progress';
-import Config from 'electron-json-config';
import ThrowError from '../ThrowError';
import addLiveryInstallAnalytic from './addLiveryInstallAnalytic';
import Constants from '../../data/Constants.json';
import ConfigKeys from '../../data/config-keys.json';
+import getConfigInstance from '../getConfigInstance';
/**
* Download and install an addon
*
@@ -23,7 +23,7 @@ import ConfigKeys from '../../data/config-keys.json';
* @param {"fresh"|"update"} installType Type of install (update, fresh install, etc)
*/
export default async function InstallAddon(PlaneObject, index, total, CurrentLocale, updateProgress, installType) {
- const Directory = Config.get(ConfigKeys.settings.package_directory);
+ const Directory = getConfigInstance().get(ConfigKeys.settings.package_directory);
const downloadURL = `${Constants.urls.cdnEndpoint}/${PlaneObject.fileName}?hash=${PlaneObject.checkSum}`;
const zipName = PlaneObject.fileName.substr(PlaneObject.fileName.lastIndexOf('/') + 1);
const tempPath = Path.join(ElectronRemote.app.getPath('temp'), Constants.appName, Constants.dirs.downloadCache);
diff --git a/src/helpers/AddonInstaller/getInstalledAddons.js b/src/helpers/AddonInstaller/getInstalledAddons.js
index c0637fd8..79cb6218 100644
--- a/src/helpers/AddonInstaller/getInstalledAddons.js
+++ b/src/helpers/AddonInstaller/getInstalledAddons.js
@@ -1,11 +1,11 @@
import { readdirSync, existsSync, lstatSync, readFileSync } from 'fs';
import Path from 'path';
-import Config from 'electron-json-config';
import ConfigKeys from '../../data/config-keys.json';
import Constants from '../../data/Constants.json';
import AsyncForEach from '../AsyncForEach';
+import getConfigInstance from '../getConfigInstance';
import ThrowError from '../ThrowError';
/**
@@ -42,7 +42,7 @@ export default async function GetInstalledAddons() {
integrations: [new RewriteFrames()],
});
let installedAddons = [];
- const Directory = Path.normalize(Config.get(ConfigKeys.settings.package_directory));
+ const Directory = Path.normalize(getConfigInstance().get(ConfigKeys.settings.package_directory));
if (!existsSync(Directory)) return ThrowError('E101', `Community path does not exist:\n${Directory}`);
diff --git a/src/helpers/ResetConfig.js b/src/helpers/ResetConfig.js
index 5d24856a..f846e262 100644
--- a/src/helpers/ResetConfig.js
+++ b/src/helpers/ResetConfig.js
@@ -1,7 +1,8 @@
-import Config from 'electron-json-config';
import defaultConfig from '../data/default-config';
export default function ResetConfig() {
- Config.purge();
- Config.setBulk(defaultConfig);
+ const config = getConfigInstance();
+
+ config.purge();
+ config.setBulk(defaultConfig);
}
diff --git a/src/helpers/getConfigInstance.js b/src/helpers/getConfigInstance.js
new file mode 100644
index 00000000..9ee1b317
--- /dev/null
+++ b/src/helpers/getConfigInstance.js
@@ -0,0 +1,5 @@
+import { factory } from '@msfs/electron-json-config';
+
+export default function getConfigInstance() {
+ return factory();
+}
diff --git a/src/index.js b/src/index.js
index 3ff9e766..6b3cffd7 100644
--- a/src/index.js
+++ b/src/index.js
@@ -9,10 +9,10 @@ import 'overlayscrollbars/css/OverlayScrollbars.css';
import Navigate from './helpers/Navigate';
import Routes from './data/Routes';
-import Config from 'electron-json-config';
import IsDev from './data/IsDev';
-import defaultConfig from './data/default-config';
import GetInstalledAddons from './helpers/AddonInstaller/getInstalledAddons';
+import ResetConfig from './helpers/ResetConfig';
+import getConfigInstance from './helpers/getConfigInstance';
// Since we are using HtmlWebpackPlugin WITHOUT a template, we should create our own root node in the body element before rendering into it
let root = document.createElement('div');
@@ -28,10 +28,7 @@ if (IsDev) InitialiseDeveloperFunctions();
function InitialiseDeveloperFunctions() {
window.__navigate = Navigate;
window.__routes = Routes;
- window.__config = Config;
- window.__resetConfig = () => {
- Config.purge();
- Config.setBulk(defaultConfig);
- };
+ window.__config = getConfigInstance();
+ window.__resetConfig = ResetConfig;
window.__getInstalledAddons = GetInstalledAddons;
}
diff --git a/src/locales/Locale.js b/src/locales/Locale.js
index 41c1b382..a6914689 100644
--- a/src/locales/Locale.js
+++ b/src/locales/Locale.js
@@ -1,5 +1,5 @@
-import Config from 'electron-json-config';
import ConfigKeys from '../data/config-keys.json';
+import getConfigInstance from '../helpers/getConfigInstance';
/**
* @typedef {{ info: { name: string, localeId: string }, strings: object, setLocale: function, dayJsLocale: any }} LocaleData
@@ -93,7 +93,7 @@ export default class Locale {
}
updateLocale(newLocaleId) {
- Config.set(ConfigKeys.settings.locale, newLocaleId);
+ getConfigInstance().set(ConfigKeys.settings.locale, newLocaleId);
this._setLocale(newLocaleId);
}
diff --git a/src/pages/Setup.js b/src/pages/Setup.js
index 3e5111f4..8bc98b9b 100644
--- a/src/pages/Setup.js
+++ b/src/pages/Setup.js
@@ -23,12 +23,11 @@ import FolderSearchOutlineIcon from 'mdi-react/FolderSearchOutlineIcon';
import Navigate from '../helpers/Navigate';
-import Electron from 'electron';
-import Config from 'electron-json-config';
import ConfigKeys from '../data/config-keys.json';
import PackageJson from '../../package.json';
import LocaleContext from '../locales/LocaleContext';
import { GetAllLocales } from '../locales/LocaleHelpers';
+import getConfigInstance from '../helpers/getConfigInstance';
export default function Setup() {
const [page, setPage] = useState(1);
@@ -81,7 +80,7 @@ export default function Setup() {
if (page !== Pages.length) {
setPage(page + 1);
} else {
- Config.setBulk({
+ getConfigInstance().setBulk({
[ConfigKeys.state.setup_completed]: true,
[ConfigKeys.settings.package_directory]: data.packageDir,
});
diff --git a/src/pages/SplashScreen.js b/src/pages/SplashScreen.js
index 6521bde5..a5bcbb01 100644
--- a/src/pages/SplashScreen.js
+++ b/src/pages/SplashScreen.js
@@ -4,19 +4,19 @@ import { Box, CircularProgress, Typography, makeStyles } from '@material-ui/core
import Navigate from '../helpers/Navigate';
-import Config from 'electron-json-config';
import ConfigKeys from '../data/config-keys.json';
import defaultConfig from '../data/default-config';
import LocaleContext from '../locales/LocaleContext';
+import getConfigInstance from '../helpers/getConfigInstance';
const useStyles = makeStyles(theme => ({ loadingHeading: { marginTop: theme.spacing(3) } }));
function CheckConfig() {
- const CurrentKeys = Config.keys();
+ const CurrentKeys = getConfigInstance().keys();
Object.keys(defaultConfig).forEach(key => {
if (!CurrentKeys.includes(key)) {
- Config.set(key, defaultConfig[key]);
+ getConfigInstance().set(key, defaultConfig[key]);
}
});
}
@@ -27,7 +27,7 @@ export default function SplashScreen() {
const styles = useStyles();
- if (Config.get(ConfigKeys.state.setup_completed, false)) {
+ if (getConfigInstance().get(ConfigKeys.state.setup_completed, false)) {
console.log('Setup complete');
setTimeout(() => {
Navigate('/home');
diff --git a/yarn.lock b/yarn.lock
index 477cfde8..1b401832 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1262,6 +1262,20 @@
prop-types "^15.7.2"
react-is "^16.8.0 || ^17.0.0"
+"@msfs/electron-json-config@^1.0.0":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@msfs/electron-json-config/-/electron-json-config-1.0.0.tgz#7a1eee1a1530e10a8cf6e18db0e2c4afc8ac4321"
+ integrity sha512-JACJWFhYwJQL0BbJ/wmJWqYHNcAr+IRHWxPMbQTPf8C2stN/dosbenXzixvmF1N3NR4HWZeFlcpo7rx+JJ+R4g==
+
+"@msfs/electron-react-titlebar@^1.0.0":
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/@msfs/electron-react-titlebar/-/electron-react-titlebar-1.0.0.tgz#063b5dd51f881a7f7fff0b087985658904e3f361"
+ integrity sha512-Y2I2ufuq9bgxvYucJYTfZ7cdNomYB4KLOEuICeTtLHufo+SqGwsCytLPQBNabg6HcSSe1cGCq5D4YjGBzs8S2Q==
+ dependencies:
+ classnames "^2.3.1"
+ lodash "^4.17.21"
+ react-virtualized "^9.22.3"
+
"@nodelib/fs.scandir@2.1.4":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
@@ -2295,10 +2309,10 @@ chromium-pickle-js@^0.2.0:
resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205"
integrity sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=
-classnames@^2.2.6:
- version "2.2.6"
- resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
- integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
+classnames@^2.3.1:
+ version "2.3.1"
+ resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.1.tgz#dfcfa3891e306ec1dad105d0e88f4417b8535e8e"
+ integrity sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==
clean-css@^4.2.3:
version "4.2.3"
@@ -2937,11 +2951,6 @@ electron-installer-windows@^3.0.0:
which "^2.0.2"
yargs "^15.1.0"
-electron-json-config@^1.5.3:
- version "1.5.3"
- resolved "https://registry.yarnpkg.com/electron-json-config/-/electron-json-config-1.5.3.tgz#92a878b608673412a822325b594d7005945b3a85"
- integrity sha512-+nRzmoe9xlRZLABInTzSYPH5X1Z5bzHMoIPEMGvNGUGjHEBCoAR4n+iHYdC0vVOJjupJ4MpNLbtpo+vgCKN91A==
-
electron-notarize@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/electron-notarize/-/electron-notarize-1.1.1.tgz#3ed274b36158c1beb1dbef14e7faf5927e028629"
@@ -2986,15 +2995,6 @@ electron-packager@^15.4.0:
semver "^7.1.3"
yargs-parser "^20.0.0"
-electron-react-titlebar@^0.8.2:
- version "0.8.2"
- resolved "https://registry.yarnpkg.com/electron-react-titlebar/-/electron-react-titlebar-0.8.2.tgz#0dce6c43c7f02930ce484fc1722b09d323593940"
- integrity sha512-Bbkaryi6JmtSuq8hAM+RNxlPhmQdE/7bdEsBasTtS+tbHHPsX0p4ilxVxKlFt23geV8kQaSq7qoZr30ixW8jtw==
- dependencies:
- classnames "^2.2.6"
- lodash "^4.17.15"
- react-virtualized "^9.7.6"
-
electron-squirrel-startup@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/electron-squirrel-startup/-/electron-squirrel-startup-1.0.0.tgz#19b4e55933fa0ef8f556784b9c660f772546a0b8"
@@ -3012,10 +3012,10 @@ electron-to-chromium@^1.3.846:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.848.tgz#94cc196e496f33c0d71cd98561448f10018584cc"
integrity sha512-wchRyBcdcmibioggdO7CbMT5QQ4lXlN/g7Mkpf1K2zINidnqij6EVu94UIZ+h5nB2S9XD4bykqFv9LonAWLFyw==
-electron@^13.4.0:
- version "13.4.0"
- resolved "https://registry.yarnpkg.com/electron/-/electron-13.4.0.tgz#f9f9e518d8c6bf23bfa8b69580447eea3ca0f880"
- integrity sha512-KJGWS2qa0xZXIMPMDUNkRVO8/JxRd4+M0ejYYOzu2LIQ5ijecPzNuNR9nvDkml9XyyRBzu975FkhJcwD17ietQ==
+electron@^14.0.1:
+ version "14.0.1"
+ resolved "https://registry.yarnpkg.com/electron/-/electron-14.0.1.tgz#967da47895a77a9af8a7938e9266cd4a75ab24c4"
+ integrity sha512-1XILvfE5mQEBz5L/QeNfcwC3PxAIjwMyA3GR8Naw5C0IKAnHl3lAdjczbtGX8nqbcEpOAVo+4TMSpcPD3zxe8Q==
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^14.6.2"
@@ -5989,7 +5989,7 @@ react-transition-group@^4.4.0:
loose-envify "^1.4.0"
prop-types "^15.6.2"
-react-virtualized@^9.7.6:
+react-virtualized@^9.22.3:
version "9.22.3"
resolved "https://registry.yarnpkg.com/react-virtualized/-/react-virtualized-9.22.3.tgz#f430f16beb0a42db420dbd4d340403c0de334421"
integrity sha512-MKovKMxWTcwPSxE1kK1HcheQTWfuCxAuBoSTf2gwyMM21NdX/PXUhnoP8Uc5dRKd+nKm8v41R36OellhdCpkrw==