@clockworkdog/cogs-client 1.5.0 → 1.5.2

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.
@@ -7,25 +7,9 @@ function assetUrl(file) {
7
7
  return `${location === null || location === void 0 ? void 0 : location.protocol}//${location === null || location === void 0 ? void 0 : location.hostname}:${exports.COGS_SERVER_PORT}/assets/${encodeURIComponent(file)}`;
8
8
  }
9
9
  exports.assetUrl = assetUrl;
10
- function preloadUrl(url) {
11
- return new Promise((resolve, reject) => {
12
- const req = new XMLHttpRequest();
13
- req.open('GET', url, true);
14
- req.responseType = 'blob';
15
- req.onload = function () {
16
- if (req.status === 200) {
17
- const blob = this.response;
18
- const objectURL = URL.createObjectURL(blob);
19
- resolve(objectURL);
20
- }
21
- else {
22
- reject(Error(`Failed to preload ${url}. Error code: ${req.status}`));
23
- }
24
- };
25
- req.onerror = (error) => {
26
- reject(Error(`Failed to preload ${url}: ${error}`));
27
- };
28
- req.send();
29
- });
10
+ async function preloadUrl(url) {
11
+ const response = await fetch(url);
12
+ // We used arrayBuffer()` instead of `blob()` because the latter seems to fail on Pis when preloading some files
13
+ return URL.createObjectURL(new Blob([await response.arrayBuffer()]));
30
14
  }
31
15
  exports.preloadUrl = preloadUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clockworkdog/cogs-client",
3
- "version": "v1.5.0",
3
+ "version": "v1.5.2",
4
4
  "main": "dist/index.js",
5
5
  "unpkg": "dist/browser/index.js",
6
6
  "scripts": {