scratch-storage 4.0.23 → 4.0.25
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 +4 -4
- 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
|
@@ -132,7 +132,7 @@ const applyMetadata = options => {
|
|
|
132
132
|
*/
|
|
133
133
|
const scratchFetch = (resource, options) => {
|
|
134
134
|
const augmentedOptions = applyMetadata(options);
|
|
135
|
-
return crossFetch
|
|
135
|
+
return crossFetch(resource, augmentedOptions);
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -2469,17 +2469,20 @@ return new F();
|
|
|
2469
2469
|
|
|
2470
2470
|
var irrelevant = (function (exports) {
|
|
2471
2471
|
|
|
2472
|
-
|
|
2472
|
+
/* eslint-disable no-prototype-builtins */
|
|
2473
|
+
var g =
|
|
2473
2474
|
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
2474
2475
|
(typeof self !== 'undefined' && self) ||
|
|
2475
|
-
|
|
2476
|
+
// eslint-disable-next-line no-undef
|
|
2477
|
+
(typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g) ||
|
|
2478
|
+
{};
|
|
2476
2479
|
|
|
2477
2480
|
var support = {
|
|
2478
|
-
searchParams: 'URLSearchParams' in
|
|
2479
|
-
iterable: 'Symbol' in
|
|
2481
|
+
searchParams: 'URLSearchParams' in g,
|
|
2482
|
+
iterable: 'Symbol' in g && 'iterator' in Symbol,
|
|
2480
2483
|
blob:
|
|
2481
|
-
'FileReader' in
|
|
2482
|
-
'Blob' in
|
|
2484
|
+
'FileReader' in g &&
|
|
2485
|
+
'Blob' in g &&
|
|
2483
2486
|
(function() {
|
|
2484
2487
|
try {
|
|
2485
2488
|
new Blob();
|
|
@@ -2488,8 +2491,8 @@ var irrelevant = (function (exports) {
|
|
|
2488
2491
|
return false
|
|
2489
2492
|
}
|
|
2490
2493
|
})(),
|
|
2491
|
-
formData: 'FormData' in
|
|
2492
|
-
arrayBuffer: 'ArrayBuffer' in
|
|
2494
|
+
formData: 'FormData' in g,
|
|
2495
|
+
arrayBuffer: 'ArrayBuffer' in g
|
|
2493
2496
|
};
|
|
2494
2497
|
|
|
2495
2498
|
function isDataView(obj) {
|
|
@@ -2560,6 +2563,9 @@ var irrelevant = (function (exports) {
|
|
|
2560
2563
|
}, this);
|
|
2561
2564
|
} else if (Array.isArray(headers)) {
|
|
2562
2565
|
headers.forEach(function(header) {
|
|
2566
|
+
if (header.length != 2) {
|
|
2567
|
+
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
|
|
2568
|
+
}
|
|
2563
2569
|
this.append(header[0], header[1]);
|
|
2564
2570
|
}, this);
|
|
2565
2571
|
} else if (headers) {
|
|
@@ -2630,6 +2636,7 @@ var irrelevant = (function (exports) {
|
|
|
2630
2636
|
}
|
|
2631
2637
|
|
|
2632
2638
|
function consumed(body) {
|
|
2639
|
+
if (body._noBody) return
|
|
2633
2640
|
if (body.bodyUsed) {
|
|
2634
2641
|
return Promise.reject(new TypeError('Already read'))
|
|
2635
2642
|
}
|
|
@@ -2657,7 +2664,9 @@ var irrelevant = (function (exports) {
|
|
|
2657
2664
|
function readBlobAsText(blob) {
|
|
2658
2665
|
var reader = new FileReader();
|
|
2659
2666
|
var promise = fileReaderReady(reader);
|
|
2660
|
-
|
|
2667
|
+
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
2668
|
+
var encoding = match ? match[1] : 'utf-8';
|
|
2669
|
+
reader.readAsText(blob, encoding);
|
|
2661
2670
|
return promise
|
|
2662
2671
|
}
|
|
2663
2672
|
|
|
@@ -2695,9 +2704,11 @@ var irrelevant = (function (exports) {
|
|
|
2695
2704
|
semantic of setting Request.bodyUsed in the constructor before
|
|
2696
2705
|
_initBody is called.
|
|
2697
2706
|
*/
|
|
2707
|
+
// eslint-disable-next-line no-self-assign
|
|
2698
2708
|
this.bodyUsed = this.bodyUsed;
|
|
2699
2709
|
this._bodyInit = body;
|
|
2700
2710
|
if (!body) {
|
|
2711
|
+
this._noBody = true;
|
|
2701
2712
|
this._bodyText = '';
|
|
2702
2713
|
} else if (typeof body === 'string') {
|
|
2703
2714
|
this._bodyText = body;
|
|
@@ -2745,28 +2756,29 @@ var irrelevant = (function (exports) {
|
|
|
2745
2756
|
return Promise.resolve(new Blob([this._bodyText]))
|
|
2746
2757
|
}
|
|
2747
2758
|
};
|
|
2759
|
+
}
|
|
2748
2760
|
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
this._bodyArrayBuffer.
|
|
2758
|
-
|
|
2759
|
-
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
2760
|
-
)
|
|
2761
|
+
this.arrayBuffer = function() {
|
|
2762
|
+
if (this._bodyArrayBuffer) {
|
|
2763
|
+
var isConsumed = consumed(this);
|
|
2764
|
+
if (isConsumed) {
|
|
2765
|
+
return isConsumed
|
|
2766
|
+
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
2767
|
+
return Promise.resolve(
|
|
2768
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
2769
|
+
this._bodyArrayBuffer.byteOffset,
|
|
2770
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
2761
2771
|
)
|
|
2762
|
-
|
|
2763
|
-
return Promise.resolve(this._bodyArrayBuffer)
|
|
2764
|
-
}
|
|
2772
|
+
)
|
|
2765
2773
|
} else {
|
|
2766
|
-
return
|
|
2774
|
+
return Promise.resolve(this._bodyArrayBuffer)
|
|
2767
2775
|
}
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2776
|
+
} else if (support.blob) {
|
|
2777
|
+
return this.blob().then(readBlobAsArrayBuffer)
|
|
2778
|
+
} else {
|
|
2779
|
+
throw new Error('could not read as ArrayBuffer')
|
|
2780
|
+
}
|
|
2781
|
+
};
|
|
2770
2782
|
|
|
2771
2783
|
this.text = function() {
|
|
2772
2784
|
var rejected = consumed(this);
|
|
@@ -2799,7 +2811,7 @@ var irrelevant = (function (exports) {
|
|
|
2799
2811
|
}
|
|
2800
2812
|
|
|
2801
2813
|
// HTTP methods whose capitalization should be normalized
|
|
2802
|
-
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
|
|
2814
|
+
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
2803
2815
|
|
|
2804
2816
|
function normalizeMethod(method) {
|
|
2805
2817
|
var upcased = method.toUpperCase();
|
|
@@ -2840,7 +2852,12 @@ var irrelevant = (function (exports) {
|
|
|
2840
2852
|
}
|
|
2841
2853
|
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
2842
2854
|
this.mode = options.mode || this.mode || null;
|
|
2843
|
-
this.signal = options.signal || this.signal
|
|
2855
|
+
this.signal = options.signal || this.signal || (function () {
|
|
2856
|
+
if ('AbortController' in g) {
|
|
2857
|
+
var ctrl = new AbortController();
|
|
2858
|
+
return ctrl.signal;
|
|
2859
|
+
}
|
|
2860
|
+
}());
|
|
2844
2861
|
this.referrer = null;
|
|
2845
2862
|
|
|
2846
2863
|
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
@@ -2902,7 +2919,11 @@ var irrelevant = (function (exports) {
|
|
|
2902
2919
|
var key = parts.shift().trim();
|
|
2903
2920
|
if (key) {
|
|
2904
2921
|
var value = parts.join(':').trim();
|
|
2905
|
-
|
|
2922
|
+
try {
|
|
2923
|
+
headers.append(key, value);
|
|
2924
|
+
} catch (error) {
|
|
2925
|
+
console.warn('Response ' + error.message);
|
|
2926
|
+
}
|
|
2906
2927
|
}
|
|
2907
2928
|
});
|
|
2908
2929
|
return headers
|
|
@@ -2920,6 +2941,9 @@ var irrelevant = (function (exports) {
|
|
|
2920
2941
|
|
|
2921
2942
|
this.type = 'default';
|
|
2922
2943
|
this.status = options.status === undefined ? 200 : options.status;
|
|
2944
|
+
if (this.status < 200 || this.status > 599) {
|
|
2945
|
+
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
|
|
2946
|
+
}
|
|
2923
2947
|
this.ok = this.status >= 200 && this.status < 300;
|
|
2924
2948
|
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
2925
2949
|
this.headers = new Headers(options.headers);
|
|
@@ -2939,7 +2963,9 @@ var irrelevant = (function (exports) {
|
|
|
2939
2963
|
};
|
|
2940
2964
|
|
|
2941
2965
|
Response.error = function() {
|
|
2942
|
-
var response = new Response(null, {status:
|
|
2966
|
+
var response = new Response(null, {status: 200, statusText: ''});
|
|
2967
|
+
response.ok = false;
|
|
2968
|
+
response.status = 0;
|
|
2943
2969
|
response.type = 'error';
|
|
2944
2970
|
return response
|
|
2945
2971
|
};
|
|
@@ -2954,7 +2980,7 @@ var irrelevant = (function (exports) {
|
|
|
2954
2980
|
return new Response(null, {status: status, headers: {location: url}})
|
|
2955
2981
|
};
|
|
2956
2982
|
|
|
2957
|
-
exports.DOMException =
|
|
2983
|
+
exports.DOMException = g.DOMException;
|
|
2958
2984
|
try {
|
|
2959
2985
|
new exports.DOMException();
|
|
2960
2986
|
} catch (err) {
|
|
@@ -2984,10 +3010,16 @@ var irrelevant = (function (exports) {
|
|
|
2984
3010
|
|
|
2985
3011
|
xhr.onload = function() {
|
|
2986
3012
|
var options = {
|
|
2987
|
-
status: xhr.status,
|
|
2988
3013
|
statusText: xhr.statusText,
|
|
2989
3014
|
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
2990
3015
|
};
|
|
3016
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
3017
|
+
// Only if the status is out of a normal range
|
|
3018
|
+
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
3019
|
+
options.status = 200;
|
|
3020
|
+
} else {
|
|
3021
|
+
options.status = xhr.status;
|
|
3022
|
+
}
|
|
2991
3023
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
2992
3024
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
2993
3025
|
setTimeout(function() {
|
|
@@ -3003,7 +3035,7 @@ var irrelevant = (function (exports) {
|
|
|
3003
3035
|
|
|
3004
3036
|
xhr.ontimeout = function() {
|
|
3005
3037
|
setTimeout(function() {
|
|
3006
|
-
reject(new TypeError('Network request
|
|
3038
|
+
reject(new TypeError('Network request timed out'));
|
|
3007
3039
|
}, 0);
|
|
3008
3040
|
};
|
|
3009
3041
|
|
|
@@ -3015,7 +3047,7 @@ var irrelevant = (function (exports) {
|
|
|
3015
3047
|
|
|
3016
3048
|
function fixUrl(url) {
|
|
3017
3049
|
try {
|
|
3018
|
-
return url === '' &&
|
|
3050
|
+
return url === '' && g.location.href ? g.location.href : url
|
|
3019
3051
|
} catch (e) {
|
|
3020
3052
|
return url
|
|
3021
3053
|
}
|
|
@@ -3033,18 +3065,23 @@ var irrelevant = (function (exports) {
|
|
|
3033
3065
|
if (support.blob) {
|
|
3034
3066
|
xhr.responseType = 'blob';
|
|
3035
3067
|
} else if (
|
|
3036
|
-
support.arrayBuffer
|
|
3037
|
-
request.headers.get('Content-Type') &&
|
|
3038
|
-
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
|
3068
|
+
support.arrayBuffer
|
|
3039
3069
|
) {
|
|
3040
3070
|
xhr.responseType = 'arraybuffer';
|
|
3041
3071
|
}
|
|
3042
3072
|
}
|
|
3043
3073
|
|
|
3044
|
-
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
|
3074
|
+
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
|
|
3075
|
+
var names = [];
|
|
3045
3076
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
3077
|
+
names.push(normalizeName(name));
|
|
3046
3078
|
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
3047
3079
|
});
|
|
3080
|
+
request.headers.forEach(function(value, name) {
|
|
3081
|
+
if (names.indexOf(name) === -1) {
|
|
3082
|
+
xhr.setRequestHeader(name, value);
|
|
3083
|
+
}
|
|
3084
|
+
});
|
|
3048
3085
|
} else {
|
|
3049
3086
|
request.headers.forEach(function(value, name) {
|
|
3050
3087
|
xhr.setRequestHeader(name, value);
|
|
@@ -3068,11 +3105,11 @@ var irrelevant = (function (exports) {
|
|
|
3068
3105
|
|
|
3069
3106
|
fetch.polyfill = true;
|
|
3070
3107
|
|
|
3071
|
-
if (!
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3108
|
+
if (!g.fetch) {
|
|
3109
|
+
g.fetch = fetch;
|
|
3110
|
+
g.Headers = Headers;
|
|
3111
|
+
g.Request = Request;
|
|
3112
|
+
g.Response = Response;
|
|
3076
3113
|
}
|
|
3077
3114
|
|
|
3078
3115
|
exports.Headers = Headers;
|
|
@@ -4508,7 +4545,7 @@ module.exports = logger;
|
|
|
4508
4545
|
/******/ // This function allow to reference async chunks
|
|
4509
4546
|
/******/ __webpack_require__.u = (chunkId) => {
|
|
4510
4547
|
/******/ // return url for filenames based on template
|
|
4511
|
-
/******/ return "chunks/" + "fetch-worker" + "." + "
|
|
4548
|
+
/******/ return "chunks/" + "fetch-worker" + "." + "7a0adc94df277ffeb963" + ".js";
|
|
4512
4549
|
/******/ };
|
|
4513
4550
|
/******/ })();
|
|
4514
4551
|
/******/
|