diff --git a/src/index.js b/src/index.js index 383e187..6b70515 100644 --- a/src/index.js +++ b/src/index.js @@ -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 \ No newline at end of file +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 +} \ No newline at end of file diff --git a/src/splash/splashScreen.js b/src/splash/splashScreen.js index 9bb8af0..7dc4c5b 100644 --- a/src/splash/splashScreen.js +++ b/src/splash/splashScreen.js @@ -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'); diff --git a/src/utils/u2LoadModulePath.js b/src/utils/u2LoadModulePath.js new file mode 100644 index 0000000..a6ea5e7 --- /dev/null +++ b/src/utils/u2LoadModulePath.js @@ -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 +}; \ No newline at end of file