load semver faster, fixes #1167

This commit is contained in:
tophf 2021-02-06 19:08:35 +03:00
parent ade8d1981b
commit 94cf673f68

View File

@ -213,8 +213,13 @@ const updateMan = (() => {
} }
// TODO: when sourceCode is > 100kB use http range request(s) for version check // TODO: when sourceCode is > 100kB use http range request(s) for version check
const {headers: {etag}, response} = await tryDownload(style.updateUrl, RH_ETAG); const {headers: {etag}, response} = await tryDownload(style.updateUrl, RH_ETAG);
const json = await API.usercss.buildMeta({sourceCode: response, etag}); /* There's a bug? in Chrome which occurs only in a packaged crx:
await require(['/vendor/semver-bundle/semver']); /* global semverCompare */ * DOM script for semver fires 'load' event before the script actually runs.
* Since the conditions for the bug are rare we'll simply load in parallel */
const [json] = await Promise.all([
API.usercss.buildMeta({sourceCode: response, etag}),
require(['/vendor/semver-bundle/semver']), /* global semverCompare */
]);
const delta = semverCompare(json.usercssData.version, ucd.version); const delta = semverCompare(json.usercssData.version, ucd.version);
let err; let err;
if (!delta && !ignoreDigest) { if (!delta && !ignoreDigest) {