scratch-storage 4.0.22 → 4.0.24
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 +15 -0
- package/dist/node/chunks/{fetch-worker.3bf90a691c26a60b5752.js → fetch-worker.b0fafef5aaa29650c2d0.js} +82 -45
- package/dist/node/chunks/fetch-worker.b0fafef5aaa29650c2d0.js.map +1 -0
- package/dist/node/scratch-storage.js +83 -46
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/web/chunks/{fetch-worker.cd3a909d7b876aabf94a.js → fetch-worker.7a0adc94df277ffeb963.js} +82 -45
- package/dist/web/chunks/fetch-worker.7a0adc94df277ffeb963.js.map +1 -0
- package/dist/web/chunks/fetch-worker.f5c7430613f26d77b7a3.js +2 -0
- package/dist/web/chunks/{fetch-worker.84d6b8626598f05bbaa0.js.map → fetch-worker.f5c7430613f26d77b7a3.js.map} +1 -1
- package/dist/web/scratch-storage.js +83 -46
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +1 -1
- package/package.json +5 -5
- package/src/scratchFetch.js +1 -1
- package/test/__mocks__/cross-fetch.js +10 -7
- package/dist/node/chunks/fetch-worker.3bf90a691c26a60b5752.js.map +0 -1
- package/dist/web/chunks/fetch-worker.84d6b8626598f05bbaa0.js +0 -2
- package/dist/web/chunks/fetch-worker.cd3a909d7b876aabf94a.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.24](https://github.com/scratchfoundation/scratch-storage/compare/v4.0.23...v4.0.24) (2025-01-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* error calling fetch ([650fca5](https://github.com/scratchfoundation/scratch-storage/commit/650fca5ecdd3eb7bdeab6c1ee80e8bb634fa0b59))
|
|
12
|
+
* fix failing specs ([41816e4](https://github.com/scratchfoundation/scratch-storage/commit/41816e448c082a78d1572c0c788eb5f64ff6bd3a))
|
|
13
|
+
|
|
14
|
+
## [4.0.23](https://github.com/scratchfoundation/scratch-storage/compare/v4.0.22...v4.0.23) (2024-12-20)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **deps:** buffer is a runtime dependency ([3616355](https://github.com/scratchfoundation/scratch-storage/commit/361635522767fdbbf2816e9ddc943bdd2d59fca4))
|
|
20
|
+
|
|
6
21
|
## [4.0.22](https://github.com/scratchfoundation/scratch-storage/compare/v4.0.21...v4.0.22) (2024-12-10)
|
|
7
22
|
|
|
8
23
|
|
|
@@ -24,17 +24,20 @@ return new F();
|
|
|
24
24
|
|
|
25
25
|
var irrelevant = (function (exports) {
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/* eslint-disable no-prototype-builtins */
|
|
28
|
+
var g =
|
|
28
29
|
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
29
30
|
(typeof self !== 'undefined' && self) ||
|
|
30
|
-
|
|
31
|
+
// eslint-disable-next-line no-undef
|
|
32
|
+
(typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g) ||
|
|
33
|
+
{};
|
|
31
34
|
|
|
32
35
|
var support = {
|
|
33
|
-
searchParams: 'URLSearchParams' in
|
|
34
|
-
iterable: 'Symbol' in
|
|
36
|
+
searchParams: 'URLSearchParams' in g,
|
|
37
|
+
iterable: 'Symbol' in g && 'iterator' in Symbol,
|
|
35
38
|
blob:
|
|
36
|
-
'FileReader' in
|
|
37
|
-
'Blob' in
|
|
39
|
+
'FileReader' in g &&
|
|
40
|
+
'Blob' in g &&
|
|
38
41
|
(function() {
|
|
39
42
|
try {
|
|
40
43
|
new Blob();
|
|
@@ -43,8 +46,8 @@ var irrelevant = (function (exports) {
|
|
|
43
46
|
return false
|
|
44
47
|
}
|
|
45
48
|
})(),
|
|
46
|
-
formData: 'FormData' in
|
|
47
|
-
arrayBuffer: 'ArrayBuffer' in
|
|
49
|
+
formData: 'FormData' in g,
|
|
50
|
+
arrayBuffer: 'ArrayBuffer' in g
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
function isDataView(obj) {
|
|
@@ -115,6 +118,9 @@ var irrelevant = (function (exports) {
|
|
|
115
118
|
}, this);
|
|
116
119
|
} else if (Array.isArray(headers)) {
|
|
117
120
|
headers.forEach(function(header) {
|
|
121
|
+
if (header.length != 2) {
|
|
122
|
+
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
|
|
123
|
+
}
|
|
118
124
|
this.append(header[0], header[1]);
|
|
119
125
|
}, this);
|
|
120
126
|
} else if (headers) {
|
|
@@ -185,6 +191,7 @@ var irrelevant = (function (exports) {
|
|
|
185
191
|
}
|
|
186
192
|
|
|
187
193
|
function consumed(body) {
|
|
194
|
+
if (body._noBody) return
|
|
188
195
|
if (body.bodyUsed) {
|
|
189
196
|
return Promise.reject(new TypeError('Already read'))
|
|
190
197
|
}
|
|
@@ -212,7 +219,9 @@ var irrelevant = (function (exports) {
|
|
|
212
219
|
function readBlobAsText(blob) {
|
|
213
220
|
var reader = new FileReader();
|
|
214
221
|
var promise = fileReaderReady(reader);
|
|
215
|
-
|
|
222
|
+
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
223
|
+
var encoding = match ? match[1] : 'utf-8';
|
|
224
|
+
reader.readAsText(blob, encoding);
|
|
216
225
|
return promise
|
|
217
226
|
}
|
|
218
227
|
|
|
@@ -250,9 +259,11 @@ var irrelevant = (function (exports) {
|
|
|
250
259
|
semantic of setting Request.bodyUsed in the constructor before
|
|
251
260
|
_initBody is called.
|
|
252
261
|
*/
|
|
262
|
+
// eslint-disable-next-line no-self-assign
|
|
253
263
|
this.bodyUsed = this.bodyUsed;
|
|
254
264
|
this._bodyInit = body;
|
|
255
265
|
if (!body) {
|
|
266
|
+
this._noBody = true;
|
|
256
267
|
this._bodyText = '';
|
|
257
268
|
} else if (typeof body === 'string') {
|
|
258
269
|
this._bodyText = body;
|
|
@@ -300,28 +311,29 @@ var irrelevant = (function (exports) {
|
|
|
300
311
|
return Promise.resolve(new Blob([this._bodyText]))
|
|
301
312
|
}
|
|
302
313
|
};
|
|
314
|
+
}
|
|
303
315
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this._bodyArrayBuffer.
|
|
313
|
-
|
|
314
|
-
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
315
|
-
)
|
|
316
|
+
this.arrayBuffer = function() {
|
|
317
|
+
if (this._bodyArrayBuffer) {
|
|
318
|
+
var isConsumed = consumed(this);
|
|
319
|
+
if (isConsumed) {
|
|
320
|
+
return isConsumed
|
|
321
|
+
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
322
|
+
return Promise.resolve(
|
|
323
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
324
|
+
this._bodyArrayBuffer.byteOffset,
|
|
325
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
316
326
|
)
|
|
317
|
-
|
|
318
|
-
return Promise.resolve(this._bodyArrayBuffer)
|
|
319
|
-
}
|
|
327
|
+
)
|
|
320
328
|
} else {
|
|
321
|
-
return
|
|
329
|
+
return Promise.resolve(this._bodyArrayBuffer)
|
|
322
330
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
331
|
+
} else if (support.blob) {
|
|
332
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
333
|
+
} else {
|
|
334
|
+
throw new Error('could not read as ArrayBuffer')
|
|
335
|
+
}
|
|
336
|
+
};
|
|
325
337
|
|
|
326
338
|
this.text = function() {
|
|
327
339
|
var rejected = consumed(this);
|
|
@@ -354,7 +366,7 @@ var irrelevant = (function (exports) {
|
|
|
354
366
|
}
|
|
355
367
|
|
|
356
368
|
// HTTP methods whose capitalization should be normalized
|
|
357
|
-
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
369
|
+
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
358
370
|
|
|
359
371
|
function normalizeMethod(method) {
|
|
360
372
|
var upcased = method.toUpperCase();
|
|
@@ -395,7 +407,12 @@ var irrelevant = (function (exports) {
|
|
|
395
407
|
}
|
|
396
408
|
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
397
409
|
this.mode = options.mode || this.mode || null;
|
|
398
|
-
this.signal = options.signal || this.signal
|
|
410
|
+
this.signal = options.signal || this.signal || (function () {
|
|
411
|
+
if ('AbortController' in g) {
|
|
412
|
+
var ctrl = new AbortController();
|
|
413
|
+
return ctrl.signal;
|
|
414
|
+
}
|
|
415
|
+
}());
|
|
399
416
|
this.referrer = null;
|
|
400
417
|
|
|
401
418
|
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
@@ -457,7 +474,11 @@ var irrelevant = (function (exports) {
|
|
|
457
474
|
var key = parts.shift().trim();
|
|
458
475
|
if (key) {
|
|
459
476
|
var value = parts.join(':').trim();
|
|
460
|
-
|
|
477
|
+
try {
|
|
478
|
+
headers.append(key, value);
|
|
479
|
+
} catch (error) {
|
|
480
|
+
console.warn('Response ' + error.message);
|
|
481
|
+
}
|
|
461
482
|
}
|
|
462
483
|
});
|
|
463
484
|
return headers
|
|
@@ -475,6 +496,9 @@ var irrelevant = (function (exports) {
|
|
|
475
496
|
|
|
476
497
|
this.type = 'default';
|
|
477
498
|
this.status = options.status === undefined ? 200 : options.status;
|
|
499
|
+
if (this.status < 200 || this.status > 599) {
|
|
500
|
+
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
|
|
501
|
+
}
|
|
478
502
|
this.ok = this.status >= 200 && this.status < 300;
|
|
479
503
|
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
480
504
|
this.headers = new Headers(options.headers);
|
|
@@ -494,7 +518,9 @@ var irrelevant = (function (exports) {
|
|
|
494
518
|
};
|
|
495
519
|
|
|
496
520
|
Response.error = function() {
|
|
497
|
-
var response = new Response(null, {status:
|
|
521
|
+
var response = new Response(null, {status: 200, statusText: ''});
|
|
522
|
+
response.ok = false;
|
|
523
|
+
response.status = 0;
|
|
498
524
|
response.type = 'error';
|
|
499
525
|
return response
|
|
500
526
|
};
|
|
@@ -509,7 +535,7 @@ var irrelevant = (function (exports) {
|
|
|
509
535
|
return new Response(null, {status: status, headers: {location: url}})
|
|
510
536
|
};
|
|
511
537
|
|
|
512
|
-
exports.DOMException =
|
|
538
|
+
exports.DOMException = g.DOMException;
|
|
513
539
|
try {
|
|
514
540
|
new exports.DOMException();
|
|
515
541
|
} catch (err) {
|
|
@@ -539,10 +565,16 @@ var irrelevant = (function (exports) {
|
|
|
539
565
|
|
|
540
566
|
xhr.onload = function() {
|
|
541
567
|
var options = {
|
|
542
|
-
status: xhr.status,
|
|
543
568
|
statusText: xhr.statusText,
|
|
544
569
|
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
545
570
|
};
|
|
571
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
572
|
+
// Only if the status is out of a normal range
|
|
573
|
+
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
574
|
+
options.status = 200;
|
|
575
|
+
} else {
|
|
576
|
+
options.status = xhr.status;
|
|
577
|
+
}
|
|
546
578
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
547
579
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
548
580
|
setTimeout(function() {
|
|
@@ -558,7 +590,7 @@ var irrelevant = (function (exports) {
|
|
|
558
590
|
|
|
559
591
|
xhr.ontimeout = function() {
|
|
560
592
|
setTimeout(function() {
|
|
561
|
-
reject(new TypeError('Network request
|
|
593
|
+
reject(new TypeError('Network request timed out'));
|
|
562
594
|
}, 0);
|
|
563
595
|
};
|
|
564
596
|
|
|
@@ -570,7 +602,7 @@ var irrelevant = (function (exports) {
|
|
|
570
602
|
|
|
571
603
|
function fixUrl(url) {
|
|
572
604
|
try {
|
|
573
|
-
return url === '' &&
|
|
605
|
+
return url === '' && g.location.href ? g.location.href : url
|
|
574
606
|
} catch (e) {
|
|
575
607
|
return url
|
|
576
608
|
}
|
|
@@ -588,18 +620,23 @@ var irrelevant = (function (exports) {
|
|
|
588
620
|
if (support.blob) {
|
|
589
621
|
xhr.responseType = 'blob';
|
|
590
622
|
} else if (
|
|
591
|
-
support.arrayBuffer
|
|
592
|
-
request.headers.get('Content-Type') &&
|
|
593
|
-
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
|
623
|
+
support.arrayBuffer
|
|
594
624
|
) {
|
|
595
625
|
xhr.responseType = 'arraybuffer';
|
|
596
626
|
}
|
|
597
627
|
}
|
|
598
628
|
|
|
599
|
-
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
|
629
|
+
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
|
|
630
|
+
var names = [];
|
|
600
631
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
632
|
+
names.push(normalizeName(name));
|
|
601
633
|
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
602
634
|
});
|
|
635
|
+
request.headers.forEach(function(value, name) {
|
|
636
|
+
if (names.indexOf(name) === -1) {
|
|
637
|
+
xhr.setRequestHeader(name, value);
|
|
638
|
+
}
|
|
639
|
+
});
|
|
603
640
|
} else {
|
|
604
641
|
request.headers.forEach(function(value, name) {
|
|
605
642
|
xhr.setRequestHeader(name, value);
|
|
@@ -623,11 +660,11 @@ var irrelevant = (function (exports) {
|
|
|
623
660
|
|
|
624
661
|
fetch.polyfill = true;
|
|
625
662
|
|
|
626
|
-
if (!
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
663
|
+
if (!g.fetch) {
|
|
664
|
+
g.fetch = fetch;
|
|
665
|
+
g.Headers = Headers;
|
|
666
|
+
g.Request = Request;
|
|
667
|
+
g.Response = Response;
|
|
631
668
|
}
|
|
632
669
|
|
|
633
670
|
exports.Headers = Headers;
|
|
@@ -768,4 +805,4 @@ self.addEventListener('message', onMessage);
|
|
|
768
805
|
module.exports = __webpack_exports__;
|
|
769
806
|
/******/ })()
|
|
770
807
|
;
|
|
771
|
-
//# sourceMappingURL=fetch-worker.
|
|
808
|
+
//# sourceMappingURL=fetch-worker.b0fafef5aaa29650c2d0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunks/fetch-worker.b0fafef5aaa29650c2d0.js","mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3qBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;ACPA;;AAEA;AAEA;AACA;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAEA;;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA","sources":["webpack://scratch-storage/./node_modules/cross-fetch/dist/browser-ponyfill.js","webpack://scratch-storage/webpack/bootstrap","webpack://scratch-storage/webpack/runtime/global","webpack://scratch-storage/./src/FetchWorkerTool.worker.js"],"sourcesContent":["// Save global object in a variable\nvar __global__ =\n(typeof globalThis !== 'undefined' && globalThis) ||\n(typeof self !== 'undefined' && self) ||\n(typeof global !== 'undefined' && global);\n// Create an object that extends from __global__ without the fetch function\nvar __globalThis__ = (function () {\nfunction F() {\nthis.fetch = false;\nthis.DOMException = __global__.DOMException\n}\nF.prototype = __global__; // Needed for feature detection on whatwg-fetch's code\nreturn new F();\n})();\n// Wraps whatwg-fetch with a function scope to hijack the global object\n// \"globalThis\" that's going to be patched\n(function(globalThis) {\n\nvar irrelevant = (function (exports) {\n\n /* eslint-disable no-prototype-builtins */\n var g =\n (typeof globalThis !== 'undefined' && globalThis) ||\n (typeof self !== 'undefined' && self) ||\n // eslint-disable-next-line no-undef\n (typeof global !== 'undefined' && global) ||\n {};\n\n var support = {\n searchParams: 'URLSearchParams' in g,\n iterable: 'Symbol' in g && 'iterator' in Symbol,\n blob:\n 'FileReader' in g &&\n 'Blob' in g &&\n (function() {\n try {\n new Blob();\n return true\n } catch (e) {\n return false\n }\n })(),\n formData: 'FormData' in g,\n arrayBuffer: 'ArrayBuffer' in g\n };\n\n function isDataView(obj) {\n return obj && DataView.prototype.isPrototypeOf(obj)\n }\n\n if (support.arrayBuffer) {\n var viewClasses = [\n '[object Int8Array]',\n '[object Uint8Array]',\n '[object Uint8ClampedArray]',\n '[object Int16Array]',\n '[object Uint16Array]',\n '[object Int32Array]',\n '[object Uint32Array]',\n '[object Float32Array]',\n '[object Float64Array]'\n ];\n\n var isArrayBufferView =\n ArrayBuffer.isView ||\n function(obj) {\n return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1\n };\n }\n\n function normalizeName(name) {\n if (typeof name !== 'string') {\n name = String(name);\n }\n if (/[^a-z0-9\\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {\n throw new TypeError('Invalid character in header field name: \"' + name + '\"')\n }\n return name.toLowerCase()\n }\n\n function normalizeValue(value) {\n if (typeof value !== 'string') {\n value = String(value);\n }\n return value\n }\n\n // Build a destructive iterator for the value list\n function iteratorFor(items) {\n var iterator = {\n next: function() {\n var value = items.shift();\n return {done: value === undefined, value: value}\n }\n };\n\n if (support.iterable) {\n iterator[Symbol.iterator] = function() {\n return iterator\n };\n }\n\n return iterator\n }\n\n function Headers(headers) {\n this.map = {};\n\n if (headers instanceof Headers) {\n headers.forEach(function(value, name) {\n this.append(name, value);\n }, this);\n } else if (Array.isArray(headers)) {\n headers.forEach(function(header) {\n if (header.length != 2) {\n throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)\n }\n this.append(header[0], header[1]);\n }, this);\n } else if (headers) {\n Object.getOwnPropertyNames(headers).forEach(function(name) {\n this.append(name, headers[name]);\n }, this);\n }\n }\n\n Headers.prototype.append = function(name, value) {\n name = normalizeName(name);\n value = normalizeValue(value);\n var oldValue = this.map[name];\n this.map[name] = oldValue ? oldValue + ', ' + value : value;\n };\n\n Headers.prototype['delete'] = function(name) {\n delete this.map[normalizeName(name)];\n };\n\n Headers.prototype.get = function(name) {\n name = normalizeName(name);\n return this.has(name) ? this.map[name] : null\n };\n\n Headers.prototype.has = function(name) {\n return this.map.hasOwnProperty(normalizeName(name))\n };\n\n Headers.prototype.set = function(name, value) {\n this.map[normalizeName(name)] = normalizeValue(value);\n };\n\n Headers.prototype.forEach = function(callback, thisArg) {\n for (var name in this.map) {\n if (this.map.hasOwnProperty(name)) {\n callback.call(thisArg, this.map[name], name, this);\n }\n }\n };\n\n Headers.prototype.keys = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push(name);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.values = function() {\n var items = [];\n this.forEach(function(value) {\n items.push(value);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.entries = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push([name, value]);\n });\n return iteratorFor(items)\n };\n\n if (support.iterable) {\n Headers.prototype[Symbol.iterator] = Headers.prototype.entries;\n }\n\n function consumed(body) {\n if (body._noBody) return\n if (body.bodyUsed) {\n return Promise.reject(new TypeError('Already read'))\n }\n body.bodyUsed = true;\n }\n\n function fileReaderReady(reader) {\n return new Promise(function(resolve, reject) {\n reader.onload = function() {\n resolve(reader.result);\n };\n reader.onerror = function() {\n reject(reader.error);\n };\n })\n }\n\n function readBlobAsArrayBuffer(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsArrayBuffer(blob);\n return promise\n }\n\n function readBlobAsText(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);\n var encoding = match ? match[1] : 'utf-8';\n reader.readAsText(blob, encoding);\n return promise\n }\n\n function readArrayBufferAsText(buf) {\n var view = new Uint8Array(buf);\n var chars = new Array(view.length);\n\n for (var i = 0; i < view.length; i++) {\n chars[i] = String.fromCharCode(view[i]);\n }\n return chars.join('')\n }\n\n function bufferClone(buf) {\n if (buf.slice) {\n return buf.slice(0)\n } else {\n var view = new Uint8Array(buf.byteLength);\n view.set(new Uint8Array(buf));\n return view.buffer\n }\n }\n\n function Body() {\n this.bodyUsed = false;\n\n this._initBody = function(body) {\n /*\n fetch-mock wraps the Response object in an ES6 Proxy to\n provide useful test harness features such as flush. However, on\n ES5 browsers without fetch or Proxy support pollyfills must be used;\n the proxy-pollyfill is unable to proxy an attribute unless it exists\n on the object before the Proxy is created. This change ensures\n Response.bodyUsed exists on the instance, while maintaining the\n semantic of setting Request.bodyUsed in the constructor before\n _initBody is called.\n */\n // eslint-disable-next-line no-self-assign\n this.bodyUsed = this.bodyUsed;\n this._bodyInit = body;\n if (!body) {\n this._noBody = true;\n this._bodyText = '';\n } else if (typeof body === 'string') {\n this._bodyText = body;\n } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {\n this._bodyBlob = body;\n } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {\n this._bodyFormData = body;\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this._bodyText = body.toString();\n } else if (support.arrayBuffer && support.blob && isDataView(body)) {\n this._bodyArrayBuffer = bufferClone(body.buffer);\n // IE 10-11 can't handle a DataView body.\n this._bodyInit = new Blob([this._bodyArrayBuffer]);\n } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {\n this._bodyArrayBuffer = bufferClone(body);\n } else {\n this._bodyText = body = Object.prototype.toString.call(body);\n }\n\n if (!this.headers.get('content-type')) {\n if (typeof body === 'string') {\n this.headers.set('content-type', 'text/plain;charset=UTF-8');\n } else if (this._bodyBlob && this._bodyBlob.type) {\n this.headers.set('content-type', this._bodyBlob.type);\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n }\n };\n\n if (support.blob) {\n this.blob = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return Promise.resolve(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(new Blob([this._bodyArrayBuffer]))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as blob')\n } else {\n return Promise.resolve(new Blob([this._bodyText]))\n }\n };\n }\n\n this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n var isConsumed = consumed(this);\n if (isConsumed) {\n return isConsumed\n } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {\n return Promise.resolve(\n this._bodyArrayBuffer.buffer.slice(\n this._bodyArrayBuffer.byteOffset,\n this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength\n )\n )\n } else {\n return Promise.resolve(this._bodyArrayBuffer)\n }\n } else if (support.blob) {\n return this.blob().then(readBlobAsArrayBuffer)\n } else {\n throw new Error('could not read as ArrayBuffer')\n }\n };\n\n this.text = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return readBlobAsText(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as text')\n } else {\n return Promise.resolve(this._bodyText)\n }\n };\n\n if (support.formData) {\n this.formData = function() {\n return this.text().then(decode)\n };\n }\n\n this.json = function() {\n return this.text().then(JSON.parse)\n };\n\n return this\n }\n\n // HTTP methods whose capitalization should be normalized\n var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];\n\n function normalizeMethod(method) {\n var upcased = method.toUpperCase();\n return methods.indexOf(upcased) > -1 ? upcased : method\n }\n\n function Request(input, options) {\n if (!(this instanceof Request)) {\n throw new TypeError('Please use the \"new\" operator, this DOM object constructor cannot be called as a function.')\n }\n\n options = options || {};\n var body = options.body;\n\n if (input instanceof Request) {\n if (input.bodyUsed) {\n throw new TypeError('Already read')\n }\n this.url = input.url;\n this.credentials = input.credentials;\n if (!options.headers) {\n this.headers = new Headers(input.headers);\n }\n this.method = input.method;\n this.mode = input.mode;\n this.signal = input.signal;\n if (!body && input._bodyInit != null) {\n body = input._bodyInit;\n input.bodyUsed = true;\n }\n } else {\n this.url = String(input);\n }\n\n this.credentials = options.credentials || this.credentials || 'same-origin';\n if (options.headers || !this.headers) {\n this.headers = new Headers(options.headers);\n }\n this.method = normalizeMethod(options.method || this.method || 'GET');\n this.mode = options.mode || this.mode || null;\n this.signal = options.signal || this.signal || (function () {\n if ('AbortController' in g) {\n var ctrl = new AbortController();\n return ctrl.signal;\n }\n }());\n this.referrer = null;\n\n if ((this.method === 'GET' || this.method === 'HEAD') && body) {\n throw new TypeError('Body not allowed for GET or HEAD requests')\n }\n this._initBody(body);\n\n if (this.method === 'GET' || this.method === 'HEAD') {\n if (options.cache === 'no-store' || options.cache === 'no-cache') {\n // Search for a '_' parameter in the query string\n var reParamSearch = /([?&])_=[^&]*/;\n if (reParamSearch.test(this.url)) {\n // If it already exists then set the value with the current time\n this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());\n } else {\n // Otherwise add a new '_' parameter to the end with the current time\n var reQueryString = /\\?/;\n this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();\n }\n }\n }\n }\n\n Request.prototype.clone = function() {\n return new Request(this, {body: this._bodyInit})\n };\n\n function decode(body) {\n var form = new FormData();\n body\n .trim()\n .split('&')\n .forEach(function(bytes) {\n if (bytes) {\n var split = bytes.split('=');\n var name = split.shift().replace(/\\+/g, ' ');\n var value = split.join('=').replace(/\\+/g, ' ');\n form.append(decodeURIComponent(name), decodeURIComponent(value));\n }\n });\n return form\n }\n\n function parseHeaders(rawHeaders) {\n var headers = new Headers();\n // Replace instances of \\r\\n and \\n followed by at least one space or horizontal tab with a space\n // https://tools.ietf.org/html/rfc7230#section-3.2\n var preProcessedHeaders = rawHeaders.replace(/\\r?\\n[\\t ]+/g, ' ');\n // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill\n // https://github.com/github/fetch/issues/748\n // https://github.com/zloirock/core-js/issues/751\n preProcessedHeaders\n .split('\\r')\n .map(function(header) {\n return header.indexOf('\\n') === 0 ? header.substr(1, header.length) : header\n })\n .forEach(function(line) {\n var parts = line.split(':');\n var key = parts.shift().trim();\n if (key) {\n var value = parts.join(':').trim();\n try {\n headers.append(key, value);\n } catch (error) {\n console.warn('Response ' + error.message);\n }\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!(this instanceof Response)) {\n throw new TypeError('Please use the \"new\" operator, this DOM object constructor cannot be called as a function.')\n }\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n if (this.status < 200 || this.status > 599) {\n throw new RangeError(\"Failed to construct 'Response': The status provided (0) is outside the range [200, 599].\")\n }\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = options.statusText === undefined ? '' : '' + options.statusText;\n this.headers = new Headers(options.headers);\n this.url = options.url || '';\n this._initBody(bodyInit);\n }\n\n Body.call(Response.prototype);\n\n Response.prototype.clone = function() {\n return new Response(this._bodyInit, {\n status: this.status,\n statusText: this.statusText,\n headers: new Headers(this.headers),\n url: this.url\n })\n };\n\n Response.error = function() {\n var response = new Response(null, {status: 200, statusText: ''});\n response.ok = false;\n response.status = 0;\n response.type = 'error';\n return response\n };\n\n var redirectStatuses = [301, 302, 303, 307, 308];\n\n Response.redirect = function(url, status) {\n if (redirectStatuses.indexOf(status) === -1) {\n throw new RangeError('Invalid status code')\n }\n\n return new Response(null, {status: status, headers: {location: url}})\n };\n\n exports.DOMException = g.DOMException;\n try {\n new exports.DOMException();\n } catch (err) {\n exports.DOMException = function(message, name) {\n this.message = message;\n this.name = name;\n var error = Error(message);\n this.stack = error.stack;\n };\n exports.DOMException.prototype = Object.create(Error.prototype);\n exports.DOMException.prototype.constructor = exports.DOMException;\n }\n\n function fetch(input, init) {\n return new Promise(function(resolve, reject) {\n var request = new Request(input, init);\n\n if (request.signal && request.signal.aborted) {\n return reject(new exports.DOMException('Aborted', 'AbortError'))\n }\n\n var xhr = new XMLHttpRequest();\n\n function abortXhr() {\n xhr.abort();\n }\n\n xhr.onload = function() {\n var options = {\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\n };\n // This check if specifically for when a user fetches a file locally from the file system\n // Only if the status is out of a normal range\n if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {\n options.status = 200;\n } else {\n options.status = xhr.status;\n }\n options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');\n var body = 'response' in xhr ? xhr.response : xhr.responseText;\n setTimeout(function() {\n resolve(new Response(body, options));\n }, 0);\n };\n\n xhr.onerror = function() {\n setTimeout(function() {\n reject(new TypeError('Network request failed'));\n }, 0);\n };\n\n xhr.ontimeout = function() {\n setTimeout(function() {\n reject(new TypeError('Network request timed out'));\n }, 0);\n };\n\n xhr.onabort = function() {\n setTimeout(function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n }, 0);\n };\n\n function fixUrl(url) {\n try {\n return url === '' && g.location.href ? g.location.href : url\n } catch (e) {\n return url\n }\n }\n\n xhr.open(request.method, fixUrl(request.url), true);\n\n if (request.credentials === 'include') {\n xhr.withCredentials = true;\n } else if (request.credentials === 'omit') {\n xhr.withCredentials = false;\n }\n\n if ('responseType' in xhr) {\n if (support.blob) {\n xhr.responseType = 'blob';\n } else if (\n support.arrayBuffer\n ) {\n xhr.responseType = 'arraybuffer';\n }\n }\n\n if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {\n var names = [];\n Object.getOwnPropertyNames(init.headers).forEach(function(name) {\n names.push(normalizeName(name));\n xhr.setRequestHeader(name, normalizeValue(init.headers[name]));\n });\n request.headers.forEach(function(value, name) {\n if (names.indexOf(name) === -1) {\n xhr.setRequestHeader(name, value);\n }\n });\n } else {\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\n });\n }\n\n if (request.signal) {\n request.signal.addEventListener('abort', abortXhr);\n\n xhr.onreadystatechange = function() {\n // DONE (success or failure)\n if (xhr.readyState === 4) {\n request.signal.removeEventListener('abort', abortXhr);\n }\n };\n }\n\n xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);\n })\n }\n\n fetch.polyfill = true;\n\n if (!g.fetch) {\n g.fetch = fetch;\n g.Headers = Headers;\n g.Request = Request;\n g.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n return exports;\n\n})({});\n})(__globalThis__);\n// This is a ponyfill, so...\n__globalThis__.fetch.ponyfill = true;\ndelete __globalThis__.fetch.polyfill;\n// Choose between native implementation (__global__) or custom implementation (__globalThis__)\nvar ctx = __global__.fetch ? __global__ : __globalThis__;\nexports = ctx.fetch // To enable: import fetch from 'cross-fetch'\nexports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.\nexports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'\nexports.Headers = ctx.Headers\nexports.Request = ctx.Request\nexports.Response = ctx.Response\nmodule.exports = exports\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","/* eslint-env worker */\n\nconst crossFetch = require('cross-fetch').default;\n\nlet jobsActive = 0;\nconst complete = [];\n\nlet intervalId = null;\n\n/**\n * Register a step function.\n *\n * Step checks if there are completed jobs and if there are sends them to the\n * parent. Then it checks the jobs count. If there are no further jobs, clear\n * the step.\n */\nconst registerStep = function () {\n intervalId = setInterval(() => {\n if (complete.length) {\n // Send our chunk of completed requests and instruct postMessage to\n // transfer the buffers instead of copying them.\n postMessage(\n complete.slice(),\n // Instruct postMessage that these buffers in the sent message\n // should use their Transferable trait. After the postMessage\n // call the \"buffers\" will still be in complete if you looked,\n // but they will all be length 0 as the data they reference has\n // been sent to the window. This lets us send a lot of data\n // without the normal postMessage behaviour of making a copy of\n // all of the data for the window.\n complete.map(response => response.buffer).filter(Boolean)\n );\n complete.length = 0;\n }\n if (jobsActive === 0) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }, 1);\n};\n\n/**\n * Receive a job from the parent and fetch the requested data.\n * @param {object} options.job A job id, url, and options descriptor to perform.\n */\nconst onMessage = ({data: job}) => {\n if (jobsActive === 0 && !intervalId) {\n registerStep();\n }\n\n jobsActive++;\n\n crossFetch(job.url, job.options)\n .then(result => {\n if (result.ok) return result.arrayBuffer();\n if (result.status === 404) return null;\n return Promise.reject(result.status);\n })\n .then(buffer => complete.push({id: job.id, buffer}))\n .catch(error => complete.push({id: job.id, error: (error && error.message) || `Failed request: ${job.url}`}))\n .then(() => jobsActive--);\n};\n\n// crossFetch means \"fetch\" is now always supported\npostMessage({support: {fetch: true}});\nself.addEventListener('message', onMessage);\n"],"names":[],"sourceRoot":""}
|
|
@@ -122,7 +122,7 @@ const applyMetadata = options => {
|
|
|
122
122
|
*/
|
|
123
123
|
const scratchFetch = (resource, options) => {
|
|
124
124
|
const augmentedOptions = applyMetadata(options);
|
|
125
|
-
return crossFetch
|
|
125
|
+
return crossFetch(resource, augmentedOptions);
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
/**
|
|
@@ -2301,17 +2301,20 @@ return new F();
|
|
|
2301
2301
|
|
|
2302
2302
|
var irrelevant = (function (exports) {
|
|
2303
2303
|
|
|
2304
|
-
|
|
2304
|
+
/* eslint-disable no-prototype-builtins */
|
|
2305
|
+
var g =
|
|
2305
2306
|
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
2306
2307
|
(typeof self !== 'undefined' && self) ||
|
|
2307
|
-
|
|
2308
|
+
// eslint-disable-next-line no-undef
|
|
2309
|
+
(typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g) ||
|
|
2310
|
+
{};
|
|
2308
2311
|
|
|
2309
2312
|
var support = {
|
|
2310
|
-
searchParams: 'URLSearchParams' in
|
|
2311
|
-
iterable: 'Symbol' in
|
|
2313
|
+
searchParams: 'URLSearchParams' in g,
|
|
2314
|
+
iterable: 'Symbol' in g && 'iterator' in Symbol,
|
|
2312
2315
|
blob:
|
|
2313
|
-
'FileReader' in
|
|
2314
|
-
'Blob' in
|
|
2316
|
+
'FileReader' in g &&
|
|
2317
|
+
'Blob' in g &&
|
|
2315
2318
|
(function() {
|
|
2316
2319
|
try {
|
|
2317
2320
|
new Blob();
|
|
@@ -2320,8 +2323,8 @@ var irrelevant = (function (exports) {
|
|
|
2320
2323
|
return false
|
|
2321
2324
|
}
|
|
2322
2325
|
})(),
|
|
2323
|
-
formData: 'FormData' in
|
|
2324
|
-
arrayBuffer: 'ArrayBuffer' in
|
|
2326
|
+
formData: 'FormData' in g,
|
|
2327
|
+
arrayBuffer: 'ArrayBuffer' in g
|
|
2325
2328
|
};
|
|
2326
2329
|
|
|
2327
2330
|
function isDataView(obj) {
|
|
@@ -2392,6 +2395,9 @@ var irrelevant = (function (exports) {
|
|
|
2392
2395
|
}, this);
|
|
2393
2396
|
} else if (Array.isArray(headers)) {
|
|
2394
2397
|
headers.forEach(function(header) {
|
|
2398
|
+
if (header.length != 2) {
|
|
2399
|
+
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
|
|
2400
|
+
}
|
|
2395
2401
|
this.append(header[0], header[1]);
|
|
2396
2402
|
}, this);
|
|
2397
2403
|
} else if (headers) {
|
|
@@ -2462,6 +2468,7 @@ var irrelevant = (function (exports) {
|
|
|
2462
2468
|
}
|
|
2463
2469
|
|
|
2464
2470
|
function consumed(body) {
|
|
2471
|
+
if (body._noBody) return
|
|
2465
2472
|
if (body.bodyUsed) {
|
|
2466
2473
|
return Promise.reject(new TypeError('Already read'))
|
|
2467
2474
|
}
|
|
@@ -2489,7 +2496,9 @@ var irrelevant = (function (exports) {
|
|
|
2489
2496
|
function readBlobAsText(blob) {
|
|
2490
2497
|
var reader = new FileReader();
|
|
2491
2498
|
var promise = fileReaderReady(reader);
|
|
2492
|
-
|
|
2499
|
+
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
2500
|
+
var encoding = match ? match[1] : 'utf-8';
|
|
2501
|
+
reader.readAsText(blob, encoding);
|
|
2493
2502
|
return promise
|
|
2494
2503
|
}
|
|
2495
2504
|
|
|
@@ -2527,9 +2536,11 @@ var irrelevant = (function (exports) {
|
|
|
2527
2536
|
semantic of setting Request.bodyUsed in the constructor before
|
|
2528
2537
|
_initBody is called.
|
|
2529
2538
|
*/
|
|
2539
|
+
// eslint-disable-next-line no-self-assign
|
|
2530
2540
|
this.bodyUsed = this.bodyUsed;
|
|
2531
2541
|
this._bodyInit = body;
|
|
2532
2542
|
if (!body) {
|
|
2543
|
+
this._noBody = true;
|
|
2533
2544
|
this._bodyText = '';
|
|
2534
2545
|
} else if (typeof body === 'string') {
|
|
2535
2546
|
this._bodyText = body;
|
|
@@ -2577,28 +2588,29 @@ var irrelevant = (function (exports) {
|
|
|
2577
2588
|
return Promise.resolve(new Blob([this._bodyText]))
|
|
2578
2589
|
}
|
|
2579
2590
|
};
|
|
2591
|
+
}
|
|
2580
2592
|
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
this._bodyArrayBuffer.
|
|
2590
|
-
|
|
2591
|
-
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
2592
|
-
)
|
|
2593
|
+
this.arrayBuffer = function() {
|
|
2594
|
+
if (this._bodyArrayBuffer) {
|
|
2595
|
+
var isConsumed = consumed(this);
|
|
2596
|
+
if (isConsumed) {
|
|
2597
|
+
return isConsumed
|
|
2598
|
+
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
2599
|
+
return Promise.resolve(
|
|
2600
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
2601
|
+
this._bodyArrayBuffer.byteOffset,
|
|
2602
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
2593
2603
|
)
|
|
2594
|
-
|
|
2595
|
-
return Promise.resolve(this._bodyArrayBuffer)
|
|
2596
|
-
}
|
|
2604
|
+
)
|
|
2597
2605
|
} else {
|
|
2598
|
-
return
|
|
2606
|
+
return Promise.resolve(this._bodyArrayBuffer)
|
|
2599
2607
|
}
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2608
|
+
} else if (support.blob) {
|
|
2609
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
2610
|
+
} else {
|
|
2611
|
+
throw new Error('could not read as ArrayBuffer')
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2602
2614
|
|
|
2603
2615
|
this.text = function() {
|
|
2604
2616
|
var rejected = consumed(this);
|
|
@@ -2631,7 +2643,7 @@ var irrelevant = (function (exports) {
|
|
|
2631
2643
|
}
|
|
2632
2644
|
|
|
2633
2645
|
// HTTP methods whose capitalization should be normalized
|
|
2634
|
-
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
2646
|
+
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
2635
2647
|
|
|
2636
2648
|
function normalizeMethod(method) {
|
|
2637
2649
|
var upcased = method.toUpperCase();
|
|
@@ -2672,7 +2684,12 @@ var irrelevant = (function (exports) {
|
|
|
2672
2684
|
}
|
|
2673
2685
|
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
2674
2686
|
this.mode = options.mode || this.mode || null;
|
|
2675
|
-
this.signal = options.signal || this.signal
|
|
2687
|
+
this.signal = options.signal || this.signal || (function () {
|
|
2688
|
+
if ('AbortController' in g) {
|
|
2689
|
+
var ctrl = new AbortController();
|
|
2690
|
+
return ctrl.signal;
|
|
2691
|
+
}
|
|
2692
|
+
}());
|
|
2676
2693
|
this.referrer = null;
|
|
2677
2694
|
|
|
2678
2695
|
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
@@ -2734,7 +2751,11 @@ var irrelevant = (function (exports) {
|
|
|
2734
2751
|
var key = parts.shift().trim();
|
|
2735
2752
|
if (key) {
|
|
2736
2753
|
var value = parts.join(':').trim();
|
|
2737
|
-
|
|
2754
|
+
try {
|
|
2755
|
+
headers.append(key, value);
|
|
2756
|
+
} catch (error) {
|
|
2757
|
+
console.warn('Response ' + error.message);
|
|
2758
|
+
}
|
|
2738
2759
|
}
|
|
2739
2760
|
});
|
|
2740
2761
|
return headers
|
|
@@ -2752,6 +2773,9 @@ var irrelevant = (function (exports) {
|
|
|
2752
2773
|
|
|
2753
2774
|
this.type = 'default';
|
|
2754
2775
|
this.status = options.status === undefined ? 200 : options.status;
|
|
2776
|
+
if (this.status < 200 || this.status > 599) {
|
|
2777
|
+
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
|
|
2778
|
+
}
|
|
2755
2779
|
this.ok = this.status >= 200 && this.status < 300;
|
|
2756
2780
|
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
2757
2781
|
this.headers = new Headers(options.headers);
|
|
@@ -2771,7 +2795,9 @@ var irrelevant = (function (exports) {
|
|
|
2771
2795
|
};
|
|
2772
2796
|
|
|
2773
2797
|
Response.error = function() {
|
|
2774
|
-
var response = new Response(null, {status:
|
|
2798
|
+
var response = new Response(null, {status: 200, statusText: ''});
|
|
2799
|
+
response.ok = false;
|
|
2800
|
+
response.status = 0;
|
|
2775
2801
|
response.type = 'error';
|
|
2776
2802
|
return response
|
|
2777
2803
|
};
|
|
@@ -2786,7 +2812,7 @@ var irrelevant = (function (exports) {
|
|
|
2786
2812
|
return new Response(null, {status: status, headers: {location: url}})
|
|
2787
2813
|
};
|
|
2788
2814
|
|
|
2789
|
-
exports.DOMException =
|
|
2815
|
+
exports.DOMException = g.DOMException;
|
|
2790
2816
|
try {
|
|
2791
2817
|
new exports.DOMException();
|
|
2792
2818
|
} catch (err) {
|
|
@@ -2816,10 +2842,16 @@ var irrelevant = (function (exports) {
|
|
|
2816
2842
|
|
|
2817
2843
|
xhr.onload = function() {
|
|
2818
2844
|
var options = {
|
|
2819
|
-
status: xhr.status,
|
|
2820
2845
|
statusText: xhr.statusText,
|
|
2821
2846
|
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
2822
2847
|
};
|
|
2848
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
2849
|
+
// Only if the status is out of a normal range
|
|
2850
|
+
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
2851
|
+
options.status = 200;
|
|
2852
|
+
} else {
|
|
2853
|
+
options.status = xhr.status;
|
|
2854
|
+
}
|
|
2823
2855
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
2824
2856
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
2825
2857
|
setTimeout(function() {
|
|
@@ -2835,7 +2867,7 @@ var irrelevant = (function (exports) {
|
|
|
2835
2867
|
|
|
2836
2868
|
xhr.ontimeout = function() {
|
|
2837
2869
|
setTimeout(function() {
|
|
2838
|
-
reject(new TypeError('Network request
|
|
2870
|
+
reject(new TypeError('Network request timed out'));
|
|
2839
2871
|
}, 0);
|
|
2840
2872
|
};
|
|
2841
2873
|
|
|
@@ -2847,7 +2879,7 @@ var irrelevant = (function (exports) {
|
|
|
2847
2879
|
|
|
2848
2880
|
function fixUrl(url) {
|
|
2849
2881
|
try {
|
|
2850
|
-
return url === '' &&
|
|
2882
|
+
return url === '' && g.location.href ? g.location.href : url
|
|
2851
2883
|
} catch (e) {
|
|
2852
2884
|
return url
|
|
2853
2885
|
}
|
|
@@ -2865,18 +2897,23 @@ var irrelevant = (function (exports) {
|
|
|
2865
2897
|
if (support.blob) {
|
|
2866
2898
|
xhr.responseType = 'blob';
|
|
2867
2899
|
} else if (
|
|
2868
|
-
support.arrayBuffer
|
|
2869
|
-
request.headers.get('Content-Type') &&
|
|
2870
|
-
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
|
2900
|
+
support.arrayBuffer
|
|
2871
2901
|
) {
|
|
2872
2902
|
xhr.responseType = 'arraybuffer';
|
|
2873
2903
|
}
|
|
2874
2904
|
}
|
|
2875
2905
|
|
|
2876
|
-
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
|
2906
|
+
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
|
|
2907
|
+
var names = [];
|
|
2877
2908
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
2909
|
+
names.push(normalizeName(name));
|
|
2878
2910
|
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
2879
2911
|
});
|
|
2912
|
+
request.headers.forEach(function(value, name) {
|
|
2913
|
+
if (names.indexOf(name) === -1) {
|
|
2914
|
+
xhr.setRequestHeader(name, value);
|
|
2915
|
+
}
|
|
2916
|
+
});
|
|
2880
2917
|
} else {
|
|
2881
2918
|
request.headers.forEach(function(value, name) {
|
|
2882
2919
|
xhr.setRequestHeader(name, value);
|
|
@@ -2900,11 +2937,11 @@ var irrelevant = (function (exports) {
|
|
|
2900
2937
|
|
|
2901
2938
|
fetch.polyfill = true;
|
|
2902
2939
|
|
|
2903
|
-
if (!
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2940
|
+
if (!g.fetch) {
|
|
2941
|
+
g.fetch = fetch;
|
|
2942
|
+
g.Headers = Headers;
|
|
2943
|
+
g.Request = Request;
|
|
2944
|
+
g.Response = Response;
|
|
2908
2945
|
}
|
|
2909
2946
|
|
|
2910
2947
|
exports.Headers = Headers;
|
|
@@ -3649,7 +3686,7 @@ module.exports = require("base64-js");
|
|
|
3649
3686
|
/******/ // This function allow to reference async chunks
|
|
3650
3687
|
/******/ __webpack_require__.u = (chunkId) => {
|
|
3651
3688
|
/******/ // return url for filenames based on template
|
|
3652
|
-
/******/ return "chunks/" + "fetch-worker" + "." + "
|
|
3689
|
+
/******/ return "chunks/" + "fetch-worker" + "." + "b0fafef5aaa29650c2d0" + ".js";
|
|
3653
3690
|
/******/ };
|
|
3654
3691
|
/******/ })();
|
|
3655
3692
|
/******/
|