[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);
|
log('BuildInfo', buildInfo);
|
||||||
|
|
||||||
const errorHandler = require('./errorHandler');
|
const { fatal, handled, init: EHInit } = require('./errorHandler');
|
||||||
errorHandler.init();
|
EHInit();
|
||||||
|
|
||||||
const splashScreen = require('./splash');
|
const splash = require('./splash');
|
||||||
|
|
||||||
const updater = require('./updater/updater');
|
const updater = require('./updater/updater');
|
||||||
const moduleUpdater = require('./updater/moduleUpdater');
|
const moduleUpdater = require('./updater/moduleUpdater');
|
||||||
const appUpdater = require('./updater/appUpdater');
|
|
||||||
|
|
||||||
if (!settings.get('enableHardwareAcceleration', true)) app.disableHardwareAcceleration();
|
if (!settings.get('enableHardwareAcceleration', true)) app.disableHardwareAcceleration();
|
||||||
|
|
||||||
|
const autoStart = require('./autoStart');
|
||||||
|
|
||||||
let desktopCore;
|
let desktopCore;
|
||||||
const startCore = () => {
|
const startCore = () => {
|
||||||
desktopCore = require('./utils/requireNative')('discord_desktop_core');
|
desktopCore = require('./utils/requireNative')('discord_desktop_core');
|
||||||
|
|
||||||
desktopCore.startup({
|
desktopCore.startup({
|
||||||
splashScreen,
|
splashScreen: splash,
|
||||||
moduleUpdater,
|
moduleUpdater,
|
||||||
buildInfo,
|
buildInfo,
|
||||||
Constants,
|
Constants,
|
||||||
|
@ -38,7 +39,7 @@ const startCore = () => {
|
||||||
appSettings: require('./appSettings'),
|
appSettings: require('./appSettings'),
|
||||||
paths: require('./paths'),
|
paths: require('./paths'),
|
||||||
GPUSettings: require('./GPUSettings'),
|
GPUSettings: require('./GPUSettings'),
|
||||||
autoStart: require('./autoStart'),
|
autoStart,
|
||||||
crashReporterSetup: require('./crashReporterSetup'),
|
crashReporterSetup: require('./crashReporterSetup'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ const startCore = () => {
|
||||||
let done = false;
|
let done = false;
|
||||||
bw.webContents.on('dom-ready', () => {
|
bw.webContents.on('dom-ready', () => {
|
||||||
if (!done) { // Only run once
|
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;
|
done = true;
|
||||||
}
|
}
|
||||||
|
@ -67,14 +68,29 @@ const startCore = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const startUpdate = async () => {
|
const startUpdate = async () => {
|
||||||
const startMinimized = process.argv.includes('--start-minimized');
|
const startMin = process.argv.includes('--start-minimized');
|
||||||
|
|
||||||
appUpdater.update(startMinimized, () => {
|
if (updater.tryInitUpdater(buildInfo, Constants.NEW_UPDATE_ENDPOINT)) {
|
||||||
if (process.env.OPENASAR_NOSTART) return;
|
const inst = updater.getUpdater();
|
||||||
|
|
||||||
startCore();
|
inst.on('host-updated', () => autoStart.update(() => {}));
|
||||||
}, () => {
|
inst.on('unhandled-exception', fatal);
|
||||||
desktopCore.setMainWindowVisible(!startMinimized);
|
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
|
setTimeout(() => { // Try to update our asar
|
||||||
const config = require('./config');
|
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';
|
global.oaVersion = 'nightly';
|
||||||
|
|
||||||
log('Init', 'OpenAsar', oaVersion);
|
log('Init', 'OpenAsar', oaVersion);
|
||||||
|
|
||||||
if (process.resourcesPath.startsWith('/usr/lib/electron')) global.systemElectron = true; // Using system electron, flag for other places
|
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.settings = require('./appSettings').getSettings();
|
||||||
global.oaConfig = settings.get('openasar', {});
|
global.oaConfig = settings.get('openasar', {});
|
||||||
|
|
||||||
require('./cmdSwitches')();
|
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
|
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
|
require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay
|
||||||
} else {
|
} else {
|
||||||
require('./bootstrap')(); // Start bootstrap
|
require('./bootstrap')(); // Start bootstrap
|
||||||
|
|
|
@ -29,8 +29,6 @@ exports.initSplash = (startMin = false) => {
|
||||||
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
|
||||||
destroySplash();
|
destroySplash();
|
||||||
|
|
||||||
if (newUpdater != null) require('../utils/u2QuickLoad'); // Manually load module paths for faster requiring
|
|
||||||
|
|
||||||
launchMain();
|
launchMain();
|
||||||
|
|
||||||
setTimeout(() => {
|
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);
|
installing = Object.assign({}, base);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.init = (endpoint, settings, { releaseChannel, version }) => {
|
exports.init = (endpoint, { releaseChannel, version }) => {
|
||||||
skipHost = settings.get('SKIP_HOST_UPDATE');
|
skipHost = settings.get('SKIP_HOST_UPDATE');
|
||||||
skipModule = settings.get('SKIP_MODULE_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