scratch-storage 3.0.0 → 3.0.1
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 +7 -0
- package/dist/node/chunks/{fetch-worker.eefe62e3c8ee125d3436.js → fetch-worker.3bf90a691c26a60b5752.js} +158 -52
- package/dist/node/chunks/fetch-worker.3bf90a691c26a60b5752.js.map +1 -0
- package/dist/node/scratch-storage.js +155 -78
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/web/chunks/fetch-worker.42ee2f0bc3b8de590472.js +2 -0
- package/dist/web/chunks/{fetch-worker.85da71862ab8ee15f1cd.js.map → fetch-worker.42ee2f0bc3b8de590472.js.map} +1 -1
- package/dist/web/chunks/{fetch-worker.ba5eddd48c8ae259073b.js → fetch-worker.cd3a909d7b876aabf94a.js} +158 -52
- package/dist/web/chunks/fetch-worker.cd3a909d7b876aabf94a.js.map +1 -0
- package/dist/web/scratch-storage.js +153 -52
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +1 -1
- package/package.json +3 -3
- package/src/scratchFetch.js +10 -13
- package/webpack.config.js +8 -5
- package/dist/node/chunks/fetch-worker.eefe62e3c8ee125d3436.js.map +0 -1
- package/dist/web/chunks/fetch-worker.85da71862ab8ee15f1cd.js +0 -2
- package/dist/web/chunks/fetch-worker.ba5eddd48c8ae259073b.js.map +0 -1
|
@@ -143,15 +143,23 @@ const setMetadata = (name, value) => {
|
|
|
143
143
|
const unsetMetadata = name => {
|
|
144
144
|
metadata.delete(name);
|
|
145
145
|
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Retrieve a named request metadata item.
|
|
149
|
+
* Only for use in tests. At the time of writing, used in scratch-vm tests.
|
|
150
|
+
* @param {RequestMetadata} name The name of the metadata item to retrieve.
|
|
151
|
+
* @returns {any} value The value of the metadata item, or `undefined` if it was not found.
|
|
152
|
+
*/
|
|
153
|
+
const getMetadata = name => metadata.get(name);
|
|
146
154
|
module.exports = {
|
|
147
155
|
Headers: crossFetch.Headers,
|
|
148
156
|
RequestMetadata,
|
|
149
157
|
applyMetadata,
|
|
150
158
|
scratchFetch,
|
|
151
159
|
setMetadata,
|
|
152
|
-
unsetMetadata
|
|
160
|
+
unsetMetadata,
|
|
161
|
+
getMetadata
|
|
153
162
|
};
|
|
154
|
-
if (false) {}
|
|
155
163
|
|
|
156
164
|
/***/ }),
|
|
157
165
|
|
|
@@ -2271,27 +2279,39 @@ function BufferBigIntNotDefined () {
|
|
|
2271
2279
|
/***/ }),
|
|
2272
2280
|
|
|
2273
2281
|
/***/ 945:
|
|
2274
|
-
/***/ (
|
|
2282
|
+
/***/ ((module, exports, __webpack_require__) => {
|
|
2275
2283
|
|
|
2276
|
-
|
|
2277
|
-
var
|
|
2284
|
+
// Save global object in a variable
|
|
2285
|
+
var __global__ =
|
|
2286
|
+
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
2287
|
+
(typeof self !== 'undefined' && self) ||
|
|
2288
|
+
(typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g);
|
|
2289
|
+
// Create an object that extends from __global__ without the fetch function
|
|
2290
|
+
var __globalThis__ = (function () {
|
|
2278
2291
|
function F() {
|
|
2279
2292
|
this.fetch = false;
|
|
2280
|
-
this.DOMException =
|
|
2293
|
+
this.DOMException = __global__.DOMException
|
|
2281
2294
|
}
|
|
2282
|
-
F.prototype =
|
|
2295
|
+
F.prototype = __global__; // Needed for feature detection on whatwg-fetch's code
|
|
2283
2296
|
return new F();
|
|
2284
2297
|
})();
|
|
2285
|
-
|
|
2298
|
+
// Wraps whatwg-fetch with a function scope to hijack the global object
|
|
2299
|
+
// "globalThis" that's going to be patched
|
|
2300
|
+
(function(globalThis) {
|
|
2286
2301
|
|
|
2287
2302
|
var irrelevant = (function (exports) {
|
|
2288
2303
|
|
|
2304
|
+
var global =
|
|
2305
|
+
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
2306
|
+
(typeof self !== 'undefined' && self) ||
|
|
2307
|
+
(typeof global !== 'undefined' && global);
|
|
2308
|
+
|
|
2289
2309
|
var support = {
|
|
2290
|
-
searchParams: 'URLSearchParams' in
|
|
2291
|
-
iterable: 'Symbol' in
|
|
2310
|
+
searchParams: 'URLSearchParams' in global,
|
|
2311
|
+
iterable: 'Symbol' in global && 'iterator' in Symbol,
|
|
2292
2312
|
blob:
|
|
2293
|
-
'FileReader' in
|
|
2294
|
-
'Blob' in
|
|
2313
|
+
'FileReader' in global &&
|
|
2314
|
+
'Blob' in global &&
|
|
2295
2315
|
(function() {
|
|
2296
2316
|
try {
|
|
2297
2317
|
new Blob();
|
|
@@ -2300,8 +2320,8 @@ var irrelevant = (function (exports) {
|
|
|
2300
2320
|
return false
|
|
2301
2321
|
}
|
|
2302
2322
|
})(),
|
|
2303
|
-
formData: 'FormData' in
|
|
2304
|
-
arrayBuffer: 'ArrayBuffer' in
|
|
2323
|
+
formData: 'FormData' in global,
|
|
2324
|
+
arrayBuffer: 'ArrayBuffer' in global
|
|
2305
2325
|
};
|
|
2306
2326
|
|
|
2307
2327
|
function isDataView(obj) {
|
|
@@ -2332,8 +2352,8 @@ var irrelevant = (function (exports) {
|
|
|
2332
2352
|
if (typeof name !== 'string') {
|
|
2333
2353
|
name = String(name);
|
|
2334
2354
|
}
|
|
2335
|
-
if (/[^a-z0-9\-#$%&'*+.^_
|
|
2336
|
-
throw new TypeError('Invalid character in header field name')
|
|
2355
|
+
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
|
|
2356
|
+
throw new TypeError('Invalid character in header field name: "' + name + '"')
|
|
2337
2357
|
}
|
|
2338
2358
|
return name.toLowerCase()
|
|
2339
2359
|
}
|
|
@@ -2497,6 +2517,17 @@ var irrelevant = (function (exports) {
|
|
|
2497
2517
|
this.bodyUsed = false;
|
|
2498
2518
|
|
|
2499
2519
|
this._initBody = function(body) {
|
|
2520
|
+
/*
|
|
2521
|
+
fetch-mock wraps the Response object in an ES6 Proxy to
|
|
2522
|
+
provide useful test harness features such as flush. However, on
|
|
2523
|
+
ES5 browsers without fetch or Proxy support pollyfills must be used;
|
|
2524
|
+
the proxy-pollyfill is unable to proxy an attribute unless it exists
|
|
2525
|
+
on the object before the Proxy is created. This change ensures
|
|
2526
|
+
Response.bodyUsed exists on the instance, while maintaining the
|
|
2527
|
+
semantic of setting Request.bodyUsed in the constructor before
|
|
2528
|
+
_initBody is called.
|
|
2529
|
+
*/
|
|
2530
|
+
this.bodyUsed = this.bodyUsed;
|
|
2500
2531
|
this._bodyInit = body;
|
|
2501
2532
|
if (!body) {
|
|
2502
2533
|
this._bodyText = '';
|
|
@@ -2549,7 +2580,20 @@ var irrelevant = (function (exports) {
|
|
|
2549
2580
|
|
|
2550
2581
|
this.arrayBuffer = function() {
|
|
2551
2582
|
if (this._bodyArrayBuffer) {
|
|
2552
|
-
|
|
2583
|
+
var isConsumed = consumed(this);
|
|
2584
|
+
if (isConsumed) {
|
|
2585
|
+
return isConsumed
|
|
2586
|
+
}
|
|
2587
|
+
if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
2588
|
+
return Promise.resolve(
|
|
2589
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
2590
|
+
this._bodyArrayBuffer.byteOffset,
|
|
2591
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
2592
|
+
)
|
|
2593
|
+
)
|
|
2594
|
+
} else {
|
|
2595
|
+
return Promise.resolve(this._bodyArrayBuffer)
|
|
2596
|
+
}
|
|
2553
2597
|
} else {
|
|
2554
2598
|
return this.blob().then(readBlobAsArrayBuffer)
|
|
2555
2599
|
}
|
|
@@ -2595,6 +2639,10 @@ var irrelevant = (function (exports) {
|
|
|
2595
2639
|
}
|
|
2596
2640
|
|
|
2597
2641
|
function Request(input, options) {
|
|
2642
|
+
if (!(this instanceof Request)) {
|
|
2643
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2598
2646
|
options = options || {};
|
|
2599
2647
|
var body = options.body;
|
|
2600
2648
|
|
|
@@ -2631,6 +2679,21 @@ var irrelevant = (function (exports) {
|
|
|
2631
2679
|
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
2632
2680
|
}
|
|
2633
2681
|
this._initBody(body);
|
|
2682
|
+
|
|
2683
|
+
if (this.method === 'GET' || this.method === 'HEAD') {
|
|
2684
|
+
if (options.cache === 'no-store' || options.cache === 'no-cache') {
|
|
2685
|
+
// Search for a '_' parameter in the query string
|
|
2686
|
+
var reParamSearch = /([?&])_=[^&]*/;
|
|
2687
|
+
if (reParamSearch.test(this.url)) {
|
|
2688
|
+
// If it already exists then set the value with the current time
|
|
2689
|
+
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
|
|
2690
|
+
} else {
|
|
2691
|
+
// Otherwise add a new '_' parameter to the end with the current time
|
|
2692
|
+
var reQueryString = /\?/;
|
|
2693
|
+
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2634
2697
|
}
|
|
2635
2698
|
|
|
2636
2699
|
Request.prototype.clone = function() {
|
|
@@ -2658,20 +2721,31 @@ var irrelevant = (function (exports) {
|
|
|
2658
2721
|
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
2659
2722
|
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
2660
2723
|
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2724
|
+
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
|
|
2725
|
+
// https://github.com/github/fetch/issues/748
|
|
2726
|
+
// https://github.com/zloirock/core-js/issues/751
|
|
2727
|
+
preProcessedHeaders
|
|
2728
|
+
.split('\r')
|
|
2729
|
+
.map(function(header) {
|
|
2730
|
+
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
|
|
2731
|
+
})
|
|
2732
|
+
.forEach(function(line) {
|
|
2733
|
+
var parts = line.split(':');
|
|
2734
|
+
var key = parts.shift().trim();
|
|
2735
|
+
if (key) {
|
|
2736
|
+
var value = parts.join(':').trim();
|
|
2737
|
+
headers.append(key, value);
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2669
2740
|
return headers
|
|
2670
2741
|
}
|
|
2671
2742
|
|
|
2672
2743
|
Body.call(Request.prototype);
|
|
2673
2744
|
|
|
2674
2745
|
function Response(bodyInit, options) {
|
|
2746
|
+
if (!(this instanceof Response)) {
|
|
2747
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
2748
|
+
}
|
|
2675
2749
|
if (!options) {
|
|
2676
2750
|
options = {};
|
|
2677
2751
|
}
|
|
@@ -2679,7 +2753,7 @@ var irrelevant = (function (exports) {
|
|
|
2679
2753
|
this.type = 'default';
|
|
2680
2754
|
this.status = options.status === undefined ? 200 : options.status;
|
|
2681
2755
|
this.ok = this.status >= 200 && this.status < 300;
|
|
2682
|
-
this.statusText =
|
|
2756
|
+
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
2683
2757
|
this.headers = new Headers(options.headers);
|
|
2684
2758
|
this.url = options.url || '';
|
|
2685
2759
|
this._initBody(bodyInit);
|
|
@@ -2712,7 +2786,7 @@ var irrelevant = (function (exports) {
|
|
|
2712
2786
|
return new Response(null, {status: status, headers: {location: url}})
|
|
2713
2787
|
};
|
|
2714
2788
|
|
|
2715
|
-
exports.DOMException =
|
|
2789
|
+
exports.DOMException = global.DOMException;
|
|
2716
2790
|
try {
|
|
2717
2791
|
new exports.DOMException();
|
|
2718
2792
|
} catch (err) {
|
|
@@ -2748,22 +2822,38 @@ var irrelevant = (function (exports) {
|
|
|
2748
2822
|
};
|
|
2749
2823
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
2750
2824
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
2751
|
-
|
|
2825
|
+
setTimeout(function() {
|
|
2826
|
+
resolve(new Response(body, options));
|
|
2827
|
+
}, 0);
|
|
2752
2828
|
};
|
|
2753
2829
|
|
|
2754
2830
|
xhr.onerror = function() {
|
|
2755
|
-
|
|
2831
|
+
setTimeout(function() {
|
|
2832
|
+
reject(new TypeError('Network request failed'));
|
|
2833
|
+
}, 0);
|
|
2756
2834
|
};
|
|
2757
2835
|
|
|
2758
2836
|
xhr.ontimeout = function() {
|
|
2759
|
-
|
|
2837
|
+
setTimeout(function() {
|
|
2838
|
+
reject(new TypeError('Network request failed'));
|
|
2839
|
+
}, 0);
|
|
2760
2840
|
};
|
|
2761
2841
|
|
|
2762
2842
|
xhr.onabort = function() {
|
|
2763
|
-
|
|
2843
|
+
setTimeout(function() {
|
|
2844
|
+
reject(new exports.DOMException('Aborted', 'AbortError'));
|
|
2845
|
+
}, 0);
|
|
2764
2846
|
};
|
|
2765
2847
|
|
|
2766
|
-
|
|
2848
|
+
function fixUrl(url) {
|
|
2849
|
+
try {
|
|
2850
|
+
return url === '' && global.location.href ? global.location.href : url
|
|
2851
|
+
} catch (e) {
|
|
2852
|
+
return url
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
xhr.open(request.method, fixUrl(request.url), true);
|
|
2767
2857
|
|
|
2768
2858
|
if (request.credentials === 'include') {
|
|
2769
2859
|
xhr.withCredentials = true;
|
|
@@ -2771,13 +2861,27 @@ var irrelevant = (function (exports) {
|
|
|
2771
2861
|
xhr.withCredentials = false;
|
|
2772
2862
|
}
|
|
2773
2863
|
|
|
2774
|
-
if ('responseType' in xhr
|
|
2775
|
-
|
|
2864
|
+
if ('responseType' in xhr) {
|
|
2865
|
+
if (support.blob) {
|
|
2866
|
+
xhr.responseType = 'blob';
|
|
2867
|
+
} else if (
|
|
2868
|
+
support.arrayBuffer &&
|
|
2869
|
+
request.headers.get('Content-Type') &&
|
|
2870
|
+
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
|
2871
|
+
) {
|
|
2872
|
+
xhr.responseType = 'arraybuffer';
|
|
2873
|
+
}
|
|
2776
2874
|
}
|
|
2777
2875
|
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2876
|
+
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
|
2877
|
+
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
2878
|
+
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
2879
|
+
});
|
|
2880
|
+
} else {
|
|
2881
|
+
request.headers.forEach(function(value, name) {
|
|
2882
|
+
xhr.setRequestHeader(name, value);
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2781
2885
|
|
|
2782
2886
|
if (request.signal) {
|
|
2783
2887
|
request.signal.addEventListener('abort', abortXhr);
|
|
@@ -2796,11 +2900,11 @@ var irrelevant = (function (exports) {
|
|
|
2796
2900
|
|
|
2797
2901
|
fetch.polyfill = true;
|
|
2798
2902
|
|
|
2799
|
-
if (!
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2903
|
+
if (!global.fetch) {
|
|
2904
|
+
global.fetch = fetch;
|
|
2905
|
+
global.Headers = Headers;
|
|
2906
|
+
global.Request = Request;
|
|
2907
|
+
global.Response = Response;
|
|
2804
2908
|
}
|
|
2805
2909
|
|
|
2806
2910
|
exports.Headers = Headers;
|
|
@@ -2808,18 +2912,15 @@ var irrelevant = (function (exports) {
|
|
|
2808
2912
|
exports.Response = Response;
|
|
2809
2913
|
exports.fetch = fetch;
|
|
2810
2914
|
|
|
2811
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2812
|
-
|
|
2813
2915
|
return exports;
|
|
2814
2916
|
|
|
2815
2917
|
})({});
|
|
2816
|
-
})(
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
delete
|
|
2820
|
-
// Choose between native implementation (
|
|
2821
|
-
|
|
2822
|
-
var ctx = __self__; // this line disable service worker support temporarily
|
|
2918
|
+
})(__globalThis__);
|
|
2919
|
+
// This is a ponyfill, so...
|
|
2920
|
+
__globalThis__.fetch.ponyfill = true;
|
|
2921
|
+
delete __globalThis__.fetch.polyfill;
|
|
2922
|
+
// Choose between native implementation (__global__) or custom implementation (__globalThis__)
|
|
2923
|
+
var ctx = __global__.fetch ? __global__ : __globalThis__;
|
|
2823
2924
|
exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
|
|
2824
2925
|
exports["default"] = ctx.fetch // For TypeScript consumers without esModuleInterop.
|
|
2825
2926
|
exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
|
|
@@ -3518,9 +3619,6 @@ module.exports = require("base64-js");
|
|
|
3518
3619
|
/******/ return module.exports;
|
|
3519
3620
|
/******/ }
|
|
3520
3621
|
/******/
|
|
3521
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
3522
|
-
/******/ __webpack_require__.m = __webpack_modules__;
|
|
3523
|
-
/******/
|
|
3524
3622
|
/************************************************************************/
|
|
3525
3623
|
/******/ /* webpack/runtime/compat get default export */
|
|
3526
3624
|
/******/ (() => {
|
|
@@ -3551,7 +3649,7 @@ module.exports = require("base64-js");
|
|
|
3551
3649
|
/******/ // This function allow to reference async chunks
|
|
3552
3650
|
/******/ __webpack_require__.u = (chunkId) => {
|
|
3553
3651
|
/******/ // return url for filenames based on template
|
|
3554
|
-
/******/ return "chunks/" + "fetch-worker" + "." + "
|
|
3652
|
+
/******/ return "chunks/" + "fetch-worker" + "." + "3bf90a691c26a60b5752" + ".js";
|
|
3555
3653
|
/******/ };
|
|
3556
3654
|
/******/ })();
|
|
3557
3655
|
/******/
|
|
@@ -3588,30 +3686,9 @@ module.exports = require("base64-js");
|
|
|
3588
3686
|
/******/ __webpack_require__.p = "/";
|
|
3589
3687
|
/******/ })();
|
|
3590
3688
|
/******/
|
|
3591
|
-
/******/ /* webpack/runtime/
|
|
3689
|
+
/******/ /* webpack/runtime/base uri */
|
|
3592
3690
|
/******/ (() => {
|
|
3593
|
-
/******/ __webpack_require__.b =
|
|
3594
|
-
/******/
|
|
3595
|
-
/******/ // object to store loaded and loading chunks
|
|
3596
|
-
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
3597
|
-
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
3598
|
-
/******/ var installedChunks = {
|
|
3599
|
-
/******/ 139: 0
|
|
3600
|
-
/******/ };
|
|
3601
|
-
/******/
|
|
3602
|
-
/******/ // no chunk on demand loading
|
|
3603
|
-
/******/
|
|
3604
|
-
/******/ // no prefetching
|
|
3605
|
-
/******/
|
|
3606
|
-
/******/ // no preloaded
|
|
3607
|
-
/******/
|
|
3608
|
-
/******/ // no HMR
|
|
3609
|
-
/******/
|
|
3610
|
-
/******/ // no HMR manifest
|
|
3611
|
-
/******/
|
|
3612
|
-
/******/ // no on chunks loaded
|
|
3613
|
-
/******/
|
|
3614
|
-
/******/ // no jsonp function
|
|
3691
|
+
/******/ __webpack_require__.b = undefined;
|
|
3615
3692
|
/******/ })();
|
|
3616
3693
|
/******/
|
|
3617
3694
|
/************************************************************************/
|