diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-03-01 17:53:56 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-03-05 20:15:38 +0100 |
commit | cb1b89dac5b9a73612ccf8f61dfcc9d55c9ad598 (patch) | |
tree | 5f2dbfded768b587b5020226f75d6b315d8d7119 /platform/javascript/js/engine/preloader.js | |
parent | 272e491f52d4277667c35021f5fdf60655ccc917 (diff) | |
download | redot-engine-cb1b89dac5b9a73612ccf8f61dfcc9d55c9ad598.tar.gz |
[HTML5] Export process writes sizes in template.
This allow the loading bar to be much more reliable, even in cases where
realible stream loading status is not detectable (server-side
compression, chunked encoding).
Diffstat (limited to 'platform/javascript/js/engine/preloader.js')
-rw-r--r-- | platform/javascript/js/engine/preloader.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/platform/javascript/js/engine/preloader.js b/platform/javascript/js/engine/preloader.js index 45bdcf26d4..3535fdb361 100644 --- a/platform/javascript/js/engine/preloader.js +++ b/platform/javascript/js/engine/preloader.js @@ -43,9 +43,9 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un }), { headers: response.headers }); } - function loadFetch(file, tracker, raw) { + function loadFetch(file, tracker, fileSize, raw) { tracker[file] = { - total: 0, + total: fileSize || 0, loaded: 0, done: false, }; @@ -117,16 +117,16 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un progressFunc = callback; }; - this.loadPromise = function (file, raw = false) { - return retry(loadFetch.bind(null, file, loadingFiles, raw), DOWNLOAD_ATTEMPTS_MAX); + this.loadPromise = function (file, fileSize, raw = false) { + return retry(loadFetch.bind(null, file, loadingFiles, fileSize, raw), DOWNLOAD_ATTEMPTS_MAX); }; this.preloadedFiles = []; - this.preload = function (pathOrBuffer, destPath) { + this.preload = function (pathOrBuffer, destPath, fileSize) { let buffer = null; if (typeof pathOrBuffer === 'string') { const me = this; - return this.loadPromise(pathOrBuffer).then(function (buf) { + return this.loadPromise(pathOrBuffer, fileSize).then(function (buf) { me.preloadedFiles.push({ path: destPath || pathOrBuffer, buffer: buf, |