@panoramax/web-viewer 3.1.1-develop-74158191 → 3.1.1-develop-e610c2fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/Utils.js +22 -16
package/package.json
CHANGED
package/src/utils/Utils.js
CHANGED
|
@@ -559,22 +559,28 @@ export function isInternetFast() {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
// Run download testing
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
562
|
+
try {
|
|
563
|
+
const startTime = (new Date()).getTime();
|
|
564
|
+
return fetch(INTERNET_FAST_TESTFILE+"?nocache="+startTime)
|
|
565
|
+
.then(async res => [res, await res.blob()])
|
|
566
|
+
.then(([res, blob]) => {
|
|
567
|
+
const size = parseInt(res.headers.get("Content-Length") || blob.size); // Bytes
|
|
568
|
+
const endTime = (new Date()).getTime();
|
|
569
|
+
const duration = (endTime - startTime) / 1000; // Transfer time in seconds
|
|
570
|
+
const speed = (size * 8 / 1024 / 1024) / duration; // MBits/s
|
|
571
|
+
const isFast = speed >= INTERNET_FAST_THRESHOLD;
|
|
572
|
+
sessionStorage.setItem(INTERNET_FAST_STORAGE, isFast ? "true" : "false");
|
|
573
|
+
return isFast;
|
|
574
|
+
})
|
|
575
|
+
.catch(e => {
|
|
576
|
+
console.warn("Failed to run speedtest", e);
|
|
577
|
+
return false;
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
// Fallback for browser blocking third-party downloads
|
|
581
|
+
catch(e) {
|
|
582
|
+
return Promise.resolve(false);
|
|
583
|
+
}
|
|
578
584
|
}
|
|
579
585
|
}
|
|
580
586
|
|