[Index] Add overlay support and rewrite some new updater code

This commit is contained in:
Ducko 2021-12-12 14:41:15 +00:00
parent 0c2116de78
commit 308ba74a18
3 changed files with 25 additions and 2 deletions

View File

@ -9,6 +9,20 @@ global.oaConfig = appSettings.getSettings().get('openasar', {});
log('Init', 'Loaded config', oaConfig);
const bootstrap = require('./bootstrap');
const appMode = process.argv?.includes('--overlay-host') ? 'overlay-host' : 'app';
bootstrap(); // Start bootstrap
if (appMode === 'overlay-host') {
const buildInfo = require('./utils/buildInfo');
if (buildInfo.newUpdater) {
require('./utils/u2LoadModulePath')('discord_overlay2');
} else {
require('./updater/moduleUpdater').initPathsOnly(buildInfo);
}
require('./utils/requireNative')('discord_overlay2/standalone_host.js')
} else {
const bootstrap = require('./bootstrap');
bootstrap(); // Start bootstrap
}

View File

@ -339,6 +339,7 @@ function initSplash(startMinimized = false) {
destroySplash();
if (newUpdater != null) { // Manually load desktop_core module path for faster requiring
require('../utils/u2LoadModulePath')('discord_desktop_core');
const NodeModule = require('module');
const modulesDir = _path.default.join(paths.getExeDir(), 'modules');

View File

@ -0,0 +1,8 @@
module.exports = (moduleName) => {
const NodeModule = require('module');
const modulesDir = _path.default.join(paths.getExeDir(), 'modules');
const moduleCoreDir = _fs.default.readdirSync(modulesDir).find((x) => x.startsWith(moduleName + '-')); // Find desktop core dir by name
NodeModule.globalPaths.push(_path.default.join(modulesDir, moduleCoreDir)); // Add to globalPaths for requiring
};