Merge branch 'main' of github.com:GooseMod/OpenAsar
This commit is contained in:
commit
9110fe7bba
6 changed files with 15 additions and 40 deletions
5
src/bootstrap.js
vendored
5
src/bootstrap.js
vendored
|
@ -128,7 +128,6 @@ const startUpdate = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasArgvFlag = (flag) => (process.argv || []).slice(1).includes(flag);
|
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
// Paths logging
|
// Paths logging
|
||||||
|
@ -140,7 +139,7 @@ getModuleDataPath: ${paths.getModuleDataPath()}
|
||||||
getInstallPath: ${paths.getInstallPath()}`);
|
getInstallPath: ${paths.getInstallPath()}`);
|
||||||
|
|
||||||
const instanceLock = app.requestSingleInstanceLock();
|
const instanceLock = app.requestSingleInstanceLock();
|
||||||
const allowMultiInstance = hasArgvFlag('--multi-instance') || oaConfig.multiInstance === true; // argv flag or config
|
const allowMultiInstance = argv.hasFlag('--multi-instance') || oaConfig.multiInstance === true; // argv flag or config
|
||||||
|
|
||||||
console.log(instanceLock, allowMultiInstance);
|
console.log(instanceLock, allowMultiInstance);
|
||||||
|
|
||||||
|
@ -154,4 +153,4 @@ getInstallPath: ${paths.getInstallPath()}`);
|
||||||
} else {
|
} else {
|
||||||
app.once('ready', startUpdate);
|
app.once('ready', startUpdate);
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -141,12 +141,4 @@
|
||||||
barFill.style.visibility = '';
|
barFill.style.visibility = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('#debug').textContent = DiscordSplash.getDebugInfo();
|
|
||||||
|
|
||||||
DiscordSplash.getCSS((css) => {
|
|
||||||
const cssInject = document.createElement('style');
|
|
||||||
cssInject.appendChild(document.createTextNode(css));
|
|
||||||
document.body.appendChild(cssInject);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
|
@ -17,15 +17,6 @@ contextBridge.exposeInMainWorld('DiscordSplash', {
|
||||||
openUrl: saferShellOpenExternal,
|
openUrl: saferShellOpenExternal,
|
||||||
quitDiscord: () => ipcRenderer.send('DISCORD_SPLASH_SCREEN_QUIT'),
|
quitDiscord: () => ipcRenderer.send('DISCORD_SPLASH_SCREEN_QUIT'),
|
||||||
|
|
||||||
getDebugInfo: () => {
|
|
||||||
if (oaConfig.splashText === false) return '';
|
|
||||||
|
|
||||||
const buildInfo = require('../utils/buildInfo');
|
|
||||||
|
|
||||||
return `${buildInfo.releaseChannel} ${buildInfo.version}
|
|
||||||
OpenAsar ${urlParams.get('oaVersion')}`;
|
|
||||||
},
|
|
||||||
|
|
||||||
getCSS: callback => oaConfig.themeSync !== false ? ipcRenderer.on('DISCORD_GET_CSS', (_, value) => {
|
getCSS: callback => oaConfig.themeSync !== false ? ipcRenderer.on('DISCORD_GET_CSS', (_, value) => {
|
||||||
callback(value);
|
callback(value);
|
||||||
}) : {}
|
}) : {}
|
||||||
|
|
|
@ -456,6 +456,15 @@ function launchSplashWindow(startMinimized) {
|
||||||
_ipcMain.default.on('SPLASH_SCREEN_READY', () => {
|
_ipcMain.default.on('SPLASH_SCREEN_READY', () => {
|
||||||
log('Splash', 'Window declared ready, showing and starting update process');
|
log('Splash', 'Window declared ready, showing and starting update process');
|
||||||
|
|
||||||
|
if (oaConfig.themeSync !== false) try { // Inject themesync CSS
|
||||||
|
splashWindow.webContents.insertCSS(JSON.parse(_fs.default.readFileSync(_path.default.join(paths.getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS);
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
|
if (oaConfig.splashText !== false) try {
|
||||||
|
const buildInfo = require('../utils/buildInfo.js');
|
||||||
|
splashWindow.webContents.executeJavaScript(`debug.textContent = '${buildInfo.releaseChannel} ${buildInfo.version}\\nOpenAsar ${oaVersion}'`);
|
||||||
|
} catch (e) { }
|
||||||
|
|
||||||
if (splashWindow && !startMinimized) {
|
if (splashWindow && !startMinimized) {
|
||||||
splashWindow.show();
|
splashWindow.show();
|
||||||
}
|
}
|
||||||
|
@ -471,13 +480,7 @@ function launchSplashWindow(startMinimized) {
|
||||||
pathname: _path.default.join(__dirname, 'index.html')
|
pathname: _path.default.join(__dirname, 'index.html')
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
splashWindow.loadURL(splashUrl);
|
||||||
webContentsSend(splashWindow, 'GET_CSS', JSON.parse(_fs.default.readFileSync(_path.default.join(paths.getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS);
|
|
||||||
} catch (e) {
|
|
||||||
log('Splash', 'Failed to inject splash CSS');
|
|
||||||
}
|
|
||||||
|
|
||||||
splashWindow.loadURL(splashUrl + '?oaVersion=' + global.oaVersion + '&oaConfig=' + JSON.stringify(oaConfig));
|
|
||||||
|
|
||||||
log('Splash', `Loading window (with url ${splashUrl})`);
|
log('Splash', `Loading window (with url ${splashUrl})`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = class Backoff { // Internal library / utility for a class to re
|
||||||
try {
|
try {
|
||||||
callback(); // Run callback
|
callback(); // Run callback
|
||||||
} finally {
|
} finally {
|
||||||
this_timeoutId = null; // Stop tracking timeout internally as it's been executed
|
this._timeoutId = null; // Stop tracking timeout internally as it's been executed
|
||||||
}
|
}
|
||||||
}, this.current);
|
}, this.current);
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,7 @@
|
||||||
const { shell } = require('electron');
|
const { shell } = require('electron');
|
||||||
|
|
||||||
const allowedProtocols = [ 'https:', 'http:' ];
|
const allowedProtocols = [ 'https', 'http' ]; // Only allow some protocols
|
||||||
exports.saferShellOpenExternal = (url) => {
|
exports.saferShellOpenExternal = (url) => allowedProtocols.includes(url.split(':')[0].toLowerCase()) ? shell.openExternal(url) : Promise.reject();
|
||||||
let parsed;
|
|
||||||
|
|
||||||
try {
|
|
||||||
parsed = new URL(url);
|
|
||||||
} catch (_e) { return Promise.reject(); }
|
|
||||||
|
|
||||||
if (!allowedProtocols.includes(parsed.protocol?.toLowerCase())) return Promise.reject(); // Only allow some protocols
|
|
||||||
|
|
||||||
return shell.openExternal(url);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.checkUrlOriginMatches = (url1, url2) => {
|
exports.checkUrlOriginMatches = (url1, url2) => {
|
||||||
let parse1, parse2;
|
let parse1, parse2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue