[Various] Deep integrate u2QuickLoad (now forced always on win32) and appUpdater, other minor source cleanup
This commit is contained in:
parent
dc908c54cc
commit
133cf280e4
|
@ -14,23 +14,24 @@ global.releaseChannel = buildInfo.releaseChannel;
|
|||
|
||||
log('BuildInfo', buildInfo);
|
||||
|
||||
const errorHandler = require('./errorHandler');
|
||||
errorHandler.init();
|
||||
const { fatal, handled, init: EHInit } = require('./errorHandler');
|
||||
EHInit();
|
||||
|
||||
const splashScreen = require('./splash');
|
||||
const splash = require('./splash');
|
||||
|
||||
const updater = require('./updater/updater');
|
||||
const moduleUpdater = require('./updater/moduleUpdater');
|
||||
const appUpdater = require('./updater/appUpdater');
|
||||
|
||||
if (!settings.get('enableHardwareAcceleration', true)) app.disableHardwareAcceleration();
|
||||
|
||||
const autoStart = require('./autoStart');
|
||||
|
||||
let desktopCore;
|
||||
const startCore = () => {
|
||||
desktopCore = require('./utils/requireNative')('discord_desktop_core');
|
||||
|
||||
desktopCore.startup({
|
||||
splashScreen,
|
||||
splashScreen: splash,
|
||||
moduleUpdater,
|
||||
buildInfo,
|
||||
Constants,
|
||||
|
@ -38,7 +39,7 @@ const startCore = () => {
|
|||
appSettings: require('./appSettings'),
|
||||
paths: require('./paths'),
|
||||
GPUSettings: require('./GPUSettings'),
|
||||
autoStart: require('./autoStart'),
|
||||
autoStart,
|
||||
crashReporterSetup: require('./crashReporterSetup'),
|
||||
});
|
||||
|
||||
|
@ -50,7 +51,7 @@ const startCore = () => {
|
|||
let done = false;
|
||||
bw.webContents.on('dom-ready', () => {
|
||||
if (!done) { // Only run once
|
||||
splashScreen.pageReady(); // Override Core's pageReady with our own on dom-ready to show main window earlier
|
||||
splash.pageReady(); // Override Core's pageReady with our own on dom-ready to show main window earlier
|
||||
|
||||
done = true;
|
||||
}
|
||||
|
@ -67,14 +68,29 @@ const startCore = () => {
|
|||
};
|
||||
|
||||
const startUpdate = async () => {
|
||||
const startMinimized = process.argv.includes('--start-minimized');
|
||||
const startMin = process.argv.includes('--start-minimized');
|
||||
|
||||
appUpdater.update(startMinimized, () => {
|
||||
if (process.env.OPENASAR_NOSTART) return;
|
||||
if (updater.tryInitUpdater(buildInfo, Constants.NEW_UPDATE_ENDPOINT)) {
|
||||
const inst = updater.getUpdater();
|
||||
|
||||
startCore();
|
||||
}, () => {
|
||||
desktopCore.setMainWindowVisible(!startMinimized);
|
||||
inst.on('host-updated', () => autoStart.update(() => {}));
|
||||
inst.on('unhandled-exception', fatal);
|
||||
inst.on('InconsistentInstallerState', fatal);
|
||||
inst.on('update-error', handled);
|
||||
|
||||
require('./firstRun').do(inst);
|
||||
} else {
|
||||
moduleUpdater.init(Constants.UPDATE_ENDPOINT, buildInfo);
|
||||
}
|
||||
|
||||
splash.initSplash(startMin);
|
||||
|
||||
splash.events.once('APP_SHOULD_LAUNCH', () => {
|
||||
if (!process.env.OPENASAR_NOSTART) startCore();
|
||||
});
|
||||
|
||||
splash.events.once('APP_SHOULD_SHOW', () => {
|
||||
desktopCore.setMainWindowVisible(!startMin);
|
||||
|
||||
setTimeout(() => { // Try to update our asar
|
||||
const config = require('./config');
|
||||
|
|
19
src/index.js
19
src/index.js
|
@ -1,20 +1,31 @@
|
|||
const log = global.log = (area, ...args) => console.log(`[\x1B[38;2;88;101;242mOpenAsar\x1B[0m > ${area}]`, ...args); // Make log global for easy usage everywhere
|
||||
const { join } = require('path');
|
||||
|
||||
global.log = (area, ...args) => console.log(`[\x1B[38;2;88;101;242mOpenAsar\x1B[0m > ${area}]`, ...args); // Make log global for easy usage everywhere
|
||||
|
||||
global.oaVersion = 'nightly';
|
||||
|
||||
log('Init', 'OpenAsar', oaVersion);
|
||||
|
||||
if (process.resourcesPath.startsWith('/usr/lib/electron')) global.systemElectron = true; // Using system electron, flag for other places
|
||||
process.resourcesPath = require('path').join(__dirname, '..'); // Force resourcesPath for system electron
|
||||
process.resourcesPath = join(__dirname, '..'); // Force resourcesPath for system electron
|
||||
|
||||
require('./paths').init();
|
||||
const paths = require('./paths');
|
||||
paths.init();
|
||||
|
||||
global.settings = require('./appSettings').getSettings();
|
||||
global.oaConfig = settings.get('openasar', {});
|
||||
|
||||
require('./cmdSwitches')();
|
||||
|
||||
|
||||
// Force u2QuickLoad (pre-"minified" ish)
|
||||
const M = require('module'); // Module
|
||||
|
||||
const b = join(paths.getExeDir(), 'modules'); // Base dir
|
||||
if (process.platform === 'win32') for (const m of require('fs').readdirSync(b)) M.globalPaths.push(join(b, m)); // For each module dir, add to globalPaths
|
||||
|
||||
|
||||
if (process.argv.includes('--overlay-host')) { // If overlay
|
||||
require('./utils/u2QuickLoad'); // Manually load Updater v2 module paths (all modules)
|
||||
require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay
|
||||
} else {
|
||||
require('./bootstrap')(); // Start bootstrap
|
||||
|
|
|
@ -29,8 +29,6 @@ exports.initSplash = (startMin = false) => {
|
|||
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
||||
destroySplash();
|
||||
|
||||
if (newUpdater != null) require('../utils/u2QuickLoad'); // Manually load module paths for faster requiring
|
||||
|
||||
launchMain();
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
const updater = require('./updater');
|
||||
|
||||
const buildInfo = require('../utils/buildInfo');
|
||||
const Constants = require('../Constants');
|
||||
|
||||
const { fatal, handled } = require('../errorHandler');
|
||||
const splash = require('../splash');
|
||||
|
||||
|
||||
exports.update = (startMin, done, show) => {
|
||||
if (updater.tryInitUpdater(buildInfo, Constants.NEW_UPDATE_ENDPOINT)) {
|
||||
const inst = updater.getUpdater();
|
||||
|
||||
inst.on('host-updated', () => require('../autoStart').update(() => {}));
|
||||
inst.on('unhandled-exception', fatal);
|
||||
inst.on('InconsistentInstallerState', fatal);
|
||||
inst.on('update-error', handled);
|
||||
|
||||
require('../firstRun').do(inst);
|
||||
} else {
|
||||
require('./moduleUpdater').init(Constants.UPDATE_ENDPOINT, settings, buildInfo);
|
||||
}
|
||||
|
||||
splash.initSplash(startMin);
|
||||
splash.events.once('APP_SHOULD_LAUNCH', done);
|
||||
splash.events.once('APP_SHOULD_SHOW', show);
|
||||
};
|
||||
|
||||
exports.focusSplash = () => splash.focusWindow();
|
|
@ -31,7 +31,7 @@ const resetTracking = () => {
|
|||
installing = Object.assign({}, base);
|
||||
};
|
||||
|
||||
exports.init = (endpoint, settings, { releaseChannel, version }) => {
|
||||
exports.init = (endpoint, { releaseChannel, version }) => {
|
||||
skipHost = settings.get('SKIP_HOST_UPDATE');
|
||||
skipModule = settings.get('SKIP_MODULE_UPDATE');
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
const { join } = require('path');
|
||||
const Module = require('module');
|
||||
|
||||
|
||||
const base = join(require('../paths').getExeDir(), 'modules');
|
||||
for (const dir of require('fs').readdirSync(base)) {
|
||||
Module.globalPaths.push(join(base, dir));
|
||||
}
|
Loading…
Reference in New Issue