scratch-storage 4.1.26 → 5.0.0
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/.nvmrc +1 -1
- package/dist/node/chunks/{fetch-worker.4e33fe859c268e9b63d7.js → fetch-worker.56da39b0f4bad6747138.js} +3 -2
- package/dist/node/chunks/fetch-worker.56da39b0f4bad6747138.js.map +1 -0
- package/dist/node/scratch-storage.js +29 -31
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/types/Asset.d.ts +2 -2
- package/dist/types/AssetType.d.ts +2 -2
- package/dist/types/BuiltinHelper.d.ts +1 -1
- package/dist/types/FetchWorkerTool.worker.d.ts +1 -0
- package/dist/types/Helper.d.ts +1 -1
- package/dist/types/ScratchStorage.d.ts +29 -15
- package/dist/types/WebHelper.d.ts +2 -2
- package/dist/types/scratchFetch.d.ts +51 -0
- package/dist/web/chunks/{fetch-worker.06b6114f5c2d9f3dd9ff.js → fetch-worker.3a4763eac20f439e99d3.js} +1 -1
- package/dist/web/chunks/{fetch-worker.06b6114f5c2d9f3dd9ff.js.map → fetch-worker.3a4763eac20f439e99d3.js.map} +1 -1
- package/dist/web/chunks/{fetch-worker.ca18555b9ac45d3fc5e1.js → fetch-worker.c813c32be403f91001ba.js} +3 -2
- package/dist/web/chunks/fetch-worker.c813c32be403f91001ba.js.map +1 -0
- package/dist/web/scratch-storage.js +29 -31
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +1 -1
- package/eslint.config.mjs +47 -0
- package/package.json +6 -9
- package/src/Asset.ts +2 -2
- package/src/AssetType.ts +2 -2
- package/src/BuiltinHelper.ts +4 -4
- package/src/FetchWorkerTool.ts +0 -1
- package/src/FetchWorkerTool.worker.js +2 -1
- package/src/Helper.ts +1 -1
- package/src/ScratchStorage.ts +15 -15
- package/src/Tool.ts +4 -4
- package/src/WebHelper.ts +3 -3
- package/src/memoizedToString.ts +2 -4
- package/test/__mocks__/cross-fetch.js +1 -1
- package/test/integration/download-known-assets.test.js +0 -2
- package/test/unit/add-helper.test.js +2 -2
- package/test/unit/metadata.test.js +0 -1
- package/tsconfig.json +1 -0
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -4
- package/dist/node/chunks/fetch-worker.4e33fe859c268e9b63d7.js.map +0 -1
- package/dist/web/chunks/fetch-worker.ca18555b9ac45d3fc5e1.js.map +0 -1
- package/src/.eslintrc.js +0 -20
- package/test/.eslintrc.js +0 -7
- package/test/transformers/.eslintrc.js +0 -8
package/dist/types/Asset.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export default class Asset {
|
|
|
15
15
|
* @param {string} assetId - The ID of this asset.
|
|
16
16
|
* @param {DataFormat} [dataFormat] - The format of the data (WAV, PNG, etc.); required iff `data` is present.
|
|
17
17
|
* @param {Buffer} [data] - The in-memory data for this asset; optional.
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {boolean} [generateId] - Whether to create id from an md5 hash of data
|
|
19
19
|
*/
|
|
20
20
|
constructor(assetType: AssetType, assetId?: AssetId, dataFormat?: DataFormat, data?: AssetData, generateId?: boolean);
|
|
21
21
|
setData(data: AssetData | undefined, dataFormat: DataFormat | undefined, generateId?: boolean): void;
|
|
@@ -27,7 +27,7 @@ export default class Asset {
|
|
|
27
27
|
* Same as `setData` but encodes text first.
|
|
28
28
|
* @param {string} data - the text data to encode and store.
|
|
29
29
|
* @param {DataFormat} dataFormat - the format of the data (DataFormat.SVG for example).
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {boolean} generateId - after setting data, set the id to an md5 of the data?
|
|
31
31
|
*/
|
|
32
32
|
encodeTextData(data: string, dataFormat: DataFormat, generateId: boolean): void;
|
|
33
33
|
/**
|
|
@@ -7,8 +7,8 @@ export interface AssetType {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Enumeration of the supported asset types.
|
|
10
|
-
* @type {
|
|
11
|
-
* @typedef {
|
|
10
|
+
* @type {{[assetTypeName: string]: AssetType}}
|
|
11
|
+
* @typedef {object} AssetType - Information about a supported asset type.
|
|
12
12
|
* @property {string} contentType - the MIME type associated with this kind of data. Useful for data URIs, etc.
|
|
13
13
|
* @property {string} name - The human-readable name of this asset type.
|
|
14
14
|
* @property {DataFormat} runtimeFormat - The default format used for runtime, in-memory storage of this asset. For
|
|
@@ -62,7 +62,7 @@ export default class BuiltinHelper extends Helper {
|
|
|
62
62
|
* Fetch an asset but don't process dependencies.
|
|
63
63
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
64
64
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
65
|
-
* @
|
|
65
|
+
* @returns {?Promise.<Asset>} A promise for the contents of the asset.
|
|
66
66
|
*/
|
|
67
67
|
load(assetType: AssetType, assetId: AssetId): Promise<Asset | null> | null;
|
|
68
68
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Helper.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default class Helper {
|
|
|
14
14
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
15
15
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
16
16
|
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
|
|
17
|
-
* @
|
|
17
|
+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
|
|
18
18
|
*/
|
|
19
19
|
load(assetType: AssetType, assetId: AssetId, dataFormat: DataFormat): Promise<Asset | null> | null;
|
|
20
20
|
}
|
|
@@ -11,13 +11,13 @@ export declare class ScratchStorage {
|
|
|
11
11
|
private _helpers;
|
|
12
12
|
constructor();
|
|
13
13
|
/**
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
14
|
+
* @returns {Asset} - the `Asset` class constructor.
|
|
15
|
+
* @class
|
|
16
16
|
*/
|
|
17
17
|
get Asset(): typeof _Asset;
|
|
18
18
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
19
|
+
* @returns {AssetType} - the list of supported asset types.
|
|
20
|
+
* @class
|
|
21
21
|
*/
|
|
22
22
|
get AssetType(): {
|
|
23
23
|
readonly ImageBitmap: {
|
|
@@ -52,8 +52,8 @@ export declare class ScratchStorage {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
|
-
* @
|
|
56
|
-
* @
|
|
55
|
+
* @returns {DataFormat} - the list of supported data formats.
|
|
56
|
+
* @class
|
|
57
57
|
*/
|
|
58
58
|
get DataFormat(): {
|
|
59
59
|
readonly JPG: "jpg";
|
|
@@ -67,19 +67,33 @@ export declare class ScratchStorage {
|
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* Access the `scratchFetch` module within this library.
|
|
70
|
-
* @
|
|
70
|
+
* @returns {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
|
|
71
71
|
*/
|
|
72
|
-
get scratchFetch():
|
|
72
|
+
get scratchFetch(): {
|
|
73
|
+
Headers: {
|
|
74
|
+
new (init?: HeadersInit): Headers;
|
|
75
|
+
prototype: Headers;
|
|
76
|
+
};
|
|
77
|
+
RequestMetadata: {
|
|
78
|
+
ProjectId: string;
|
|
79
|
+
RunId: string;
|
|
80
|
+
};
|
|
81
|
+
applyMetadata: (options?: RequestInit) => RequestInit | undefined;
|
|
82
|
+
scratchFetch: (resource: RequestInfo | URL, options: RequestInit) => Promise<Response>;
|
|
83
|
+
setMetadata: (name: string, value: any) => void;
|
|
84
|
+
unsetMetadata: (name: string) => void;
|
|
85
|
+
getMetadata: (name: string) => any;
|
|
86
|
+
};
|
|
73
87
|
/**
|
|
74
88
|
* @deprecated Please use the `Asset` member of a storage instance instead.
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
89
|
+
* @returns {Asset} - the `Asset` class constructor.
|
|
90
|
+
* @class
|
|
77
91
|
*/
|
|
78
92
|
static get Asset(): typeof _Asset;
|
|
79
93
|
/**
|
|
80
94
|
* @deprecated Please use the `AssetType` member of a storage instance instead.
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
95
|
+
* @returns {AssetType} - the list of supported asset types.
|
|
96
|
+
* @class
|
|
83
97
|
*/
|
|
84
98
|
static get AssetType(): {
|
|
85
99
|
readonly ImageBitmap: {
|
|
@@ -164,7 +178,7 @@ export declare class ScratchStorage {
|
|
|
164
178
|
/**
|
|
165
179
|
* TODO: Should this be removed in favor of requesting an asset with `null` as the ID?
|
|
166
180
|
* @param {AssetType} type - Get the default ID for assets of this type.
|
|
167
|
-
* @
|
|
181
|
+
* @returns {?string} The ID of the default asset of the given type, if any.
|
|
168
182
|
*/
|
|
169
183
|
getDefaultAssetId(type: AssetType): AssetId | undefined;
|
|
170
184
|
/**
|
|
@@ -181,7 +195,7 @@ export declare class ScratchStorage {
|
|
|
181
195
|
* @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
|
|
182
196
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
183
197
|
* @param {DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
|
|
184
|
-
* @
|
|
198
|
+
* @returns {Promise.<Asset>} A promise for the requested Asset.
|
|
185
199
|
* If the promise is resolved with non-null, the value is the requested asset.
|
|
186
200
|
* If the promise is resolved with null, the desired asset could not be found with the current asset sources.
|
|
187
201
|
* If the promise is rejected, there was an error on at least one asset source. HTTP 404 does not count as an
|
|
@@ -194,7 +208,7 @@ export declare class ScratchStorage {
|
|
|
194
208
|
* @param {?DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
|
|
195
209
|
* @param {Buffer} data - Data to store for the asset
|
|
196
210
|
* @param {?string} [assetId] - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
197
|
-
* @
|
|
211
|
+
* @returns {Promise.<object>} A promise for asset metadata
|
|
198
212
|
*/
|
|
199
213
|
store(assetType: AssetType, dataFormat: DataFormat | null | undefined, data: AssetData, assetId?: AssetId): Promise<string | {
|
|
200
214
|
id: string;
|
|
@@ -41,7 +41,7 @@ export default class WebHelper extends Helper {
|
|
|
41
41
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
42
42
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
43
43
|
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
|
|
44
|
-
* @
|
|
44
|
+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
|
|
45
45
|
*/
|
|
46
46
|
load(assetType: AssetType, assetId: AssetId, dataFormat: DataFormat): Promise<Asset | null>;
|
|
47
47
|
/**
|
|
@@ -50,7 +50,7 @@ export default class WebHelper extends Helper {
|
|
|
50
50
|
* @param {?DataFormat} dataFormat - DataFormat of the data for the stored asset.
|
|
51
51
|
* @param {Buffer} data - The data for the cached asset.
|
|
52
52
|
* @param {?string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
53
|
-
* @
|
|
53
|
+
* @returns {Promise.<object>} A promise for the response from the create or update request
|
|
54
54
|
*/
|
|
55
55
|
store(assetType: AssetType, dataFormat: DataFormat | undefined, data: AssetData, assetId?: AssetId): Promise<string | {
|
|
56
56
|
id: string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The enum value is the name of the associated header.
|
|
3
|
+
*/
|
|
4
|
+
export type RequestMetadata = string;
|
|
5
|
+
export namespace RequestMetadata {
|
|
6
|
+
let ProjectId: string;
|
|
7
|
+
let RunId: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Non-destructively merge any metadata state (if any) with the provided options object (if any).
|
|
11
|
+
* If there is metadata state but no options object is provided, make a new object.
|
|
12
|
+
* If there is no metadata state, return the provided options parameter without modification.
|
|
13
|
+
* If there is metadata and an options object is provided, modify a copy and return it.
|
|
14
|
+
* Headers in the provided options object may override headers generated from metadata state.
|
|
15
|
+
* @param {RequestInit} [options] The initial request options. May be null or undefined.
|
|
16
|
+
* @returns {RequestInit|undefined} the provided options parameter without modification, or a new options object.
|
|
17
|
+
*/
|
|
18
|
+
export function applyMetadata(options?: RequestInit): RequestInit | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Make a network request.
|
|
21
|
+
* This is a wrapper for the global fetch method, adding some Scratch-specific functionality.
|
|
22
|
+
* @param {RequestInfo|URL} resource The resource to fetch.
|
|
23
|
+
* @param {RequestInit} options Optional object containing custom settings for this request.
|
|
24
|
+
* @see {@link https://developer.mozilla.org/docs/Web/API/fetch} for more about the fetch API.
|
|
25
|
+
* @returns {Promise<Response>} A promise for the response to the request.
|
|
26
|
+
*/
|
|
27
|
+
export function scratchFetch(resource: RequestInfo | URL, options: RequestInit): Promise<Response>;
|
|
28
|
+
/**
|
|
29
|
+
* Set the value of a named request metadata item.
|
|
30
|
+
* Setting the value to `null` or `undefined` will NOT remove the item.
|
|
31
|
+
* Use `unsetMetadata` for that.
|
|
32
|
+
* @param {RequestMetadata} name The name of the metadata item to set.
|
|
33
|
+
* @param {any} value The value to set (will be converted to a string).
|
|
34
|
+
*/
|
|
35
|
+
export function setMetadata(name: RequestMetadata, value: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* Remove a named request metadata item.
|
|
38
|
+
* @param {RequestMetadata} name The name of the metadata item to remove.
|
|
39
|
+
*/
|
|
40
|
+
export function unsetMetadata(name: RequestMetadata): void;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve a named request metadata item.
|
|
43
|
+
* Only for use in tests. At the time of writing, used in scratch-vm tests.
|
|
44
|
+
* @param {RequestMetadata} name The name of the metadata item to retrieve.
|
|
45
|
+
* @returns {any} value The value of the metadata item, or `undefined` if it was not found.
|
|
46
|
+
*/
|
|
47
|
+
export function getMetadata(name: RequestMetadata): any;
|
|
48
|
+
export declare let Headers: {
|
|
49
|
+
new (init?: HeadersInit): Headers;
|
|
50
|
+
prototype: Headers;
|
|
51
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ScratchStorage=e():t.ScratchStorage=e()}(self,()=>(()=>{var t={945:(t,e,r)=>{var o="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==r.g&&r.g,n=function(){function t(){this.fetch=!1,this.DOMException=o.DOMException}return t.prototype=o,new t}();!function(t){!function(e){var o=void 0!==t&&t||"undefined"!=typeof self&&self||void 0!==r.g&&r.g||{},n="URLSearchParams"in o,s="Symbol"in o&&"iterator"in Symbol,i="FileReader"in o&&"Blob"in o&&function(){try{return new Blob,!0}catch(t){return!1}}(),a="FormData"in o,u="ArrayBuffer"in o;if(u)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],f=ArrayBuffer.isView||function(t){return t&&h.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function d(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return s&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function y(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function b(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function m(t){var e=new FileReader,r=b(e);return e.readAsArrayBuffer(t),r}function w(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:a&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():u&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=w(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(t)||f(t))?this._bodyArrayBuffer=w(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=y(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i)return this.blob().then(m);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,o,n,s=y(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=b(e),o=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=o?o[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=c(t),e=d(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},p.prototype.delete=function(t){delete this.map[c(t)]},p.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},p.prototype.set=function(t,e){this.map[c(t)]=d(e)},p.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},p.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),l(t)},p.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),l(t)},p.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),l(t)},s&&(p.prototype[Symbol.iterator]=p.prototype.entries);var v=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function E(t,e){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,s=(e=e||{}).body;if(t instanceof E){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,s||null==t._bodyInit||(s=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),v.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in o)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function A(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function T(t,e){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},g.call(E.prototype),g.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var x=[301,302,303,307,308];T.redirect=function(t,e){if(-1===x.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})},e.DOMException=o.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function _(t,r){return new Promise(function(n,s){var a=new E(t,r);if(a.signal&&a.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var h=new XMLHttpRequest;function f(){h.abort()}if(h.onload=function(){var t,e,r={statusText:h.statusText,headers:(t=h.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t}).forEach(function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();try{e.append(o,n)}catch(t){console.warn("Response "+t.message)}}}),e)};0===a.url.indexOf("file://")&&(h.status<200||h.status>599)?r.status=200:r.status=h.status,r.url="responseURL"in h?h.responseURL:r.headers.get("X-Request-URL");var o="response"in h?h.response:h.responseText;setTimeout(function(){n(new T(o,r))},0)},h.onerror=function(){setTimeout(function(){s(new TypeError("Network request failed"))},0)},h.ontimeout=function(){setTimeout(function(){s(new TypeError("Network request timed out"))},0)},h.onabort=function(){setTimeout(function(){s(new e.DOMException("Aborted","AbortError"))},0)},h.open(a.method,function(t){try{return""===t&&o.location.href?o.location.href:t}catch(e){return t}}(a.url),!0),"include"===a.credentials?h.withCredentials=!0:"omit"===a.credentials&&(h.withCredentials=!1),"responseType"in h&&(i?h.responseType="blob":u&&(h.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof p||o.Headers&&r.headers instanceof o.Headers)){var l=[];Object.getOwnPropertyNames(r.headers).forEach(function(t){l.push(c(t)),h.setRequestHeader(t,d(r.headers[t]))}),a.headers.forEach(function(t,e){-1===l.indexOf(e)&&h.setRequestHeader(e,t)})}else a.headers.forEach(function(t,e){h.setRequestHeader(e,t)});a.signal&&(a.signal.addEventListener("abort",f),h.onreadystatechange=function(){4===h.readyState&&a.signal.removeEventListener("abort",f)}),h.send(void 0===a._bodyInit?null:a._bodyInit)})}_.polyfill=!0,o.fetch||(o.fetch=_,o.Headers=p,o.Request=E,o.Response=T),e.Headers=p,e.Request=E,e.Response=T,e.fetch=_}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var s=o.fetch?o:n;(e=s.fetch).default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e}},e={};function r(o){var n=e[o];if(void 0!==n)return n.exports;var s=e[o]={exports:{}};return t[o](s,s.exports,r),s.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();const o=r(945).default;let n=0;const s=[];let i=null;return postMessage({support:{fetch:!0}}),self.addEventListener("message",t=>{let{data:e}=t;0!==n||i||(i=setInterval(()=>{s.length&&(postMessage(s.slice(),s.map(t=>t.buffer).filter(Boolean)),s.length=0),0===n&&(clearInterval(i),i=null)},1)),n++,o(e.url,e.options).then(t=>t.ok?t.arrayBuffer():404===t.status?null:Promise.reject(t.status)).then(t=>s.push({id:e.id,buffer:t})).catch(t=>s.push({id:e.id,error:t&&t.message||"Failed request: ".concat(e.url)})).then(()=>n--)}),{}})());
|
|
2
|
-
//# sourceMappingURL=fetch-worker.
|
|
2
|
+
//# sourceMappingURL=fetch-worker.3a4763eac20f439e99d3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunks/fetch-worker.
|
|
1
|
+
{"version":3,"file":"chunks/fetch-worker.3a4763eac20f439e99d3.js","mappings":"AAAA","sources":["webpack://ScratchStorage/webpack/universalModuleDefinition"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ScratchStorage\"] = factory();\n\telse\n\t\troot[\"ScratchStorage\"] = factory();\n})(self, () => {\nreturn "],"names":[],"sourceRoot":""}
|
|
@@ -782,7 +782,8 @@ const registerStep = function registerStep() {
|
|
|
782
782
|
|
|
783
783
|
/**
|
|
784
784
|
* Receive a job from the parent and fetch the requested data.
|
|
785
|
-
* @param {object}
|
|
785
|
+
* @param {object} message The message from the parent.
|
|
786
|
+
* @param {object} message.data A job id, url, and options descriptor to perform.
|
|
786
787
|
*/
|
|
787
788
|
const onMessage = _ref => {
|
|
788
789
|
let {
|
|
@@ -816,4 +817,4 @@ self.addEventListener('message', onMessage);
|
|
|
816
817
|
/******/ })()
|
|
817
818
|
;
|
|
818
819
|
});
|
|
819
|
-
//# sourceMappingURL=fetch-worker.
|
|
820
|
+
//# sourceMappingURL=fetch-worker.c813c32be403f91001ba.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunks/fetch-worker.c813c32be403f91001ba.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;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://ScratchStorage/webpack/universalModuleDefinition","webpack://ScratchStorage/./node_modules/cross-fetch/dist/browser-ponyfill.js","webpack://ScratchStorage/webpack/bootstrap","webpack://ScratchStorage/webpack/runtime/global","webpack://ScratchStorage/./src/FetchWorkerTool.worker.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ScratchStorage\"] = factory();\n\telse\n\t\troot[\"ScratchStorage\"] = factory();\n})(self, () => {\nreturn ","// 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} message The message from the parent.\n * @param {object} message.data 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":""}
|
|
@@ -4545,7 +4545,7 @@ module.exports = {
|
|
|
4545
4545
|
/******/ // This function allow to reference async chunks
|
|
4546
4546
|
/******/ __webpack_require__.u = (chunkId) => {
|
|
4547
4547
|
/******/ // return url for filenames based on template
|
|
4548
|
-
/******/ return "chunks/" + "fetch-worker" + "." + "
|
|
4548
|
+
/******/ return "chunks/" + "fetch-worker" + "." + "c813c32be403f91001ba" + ".js";
|
|
4549
4549
|
/******/ };
|
|
4550
4550
|
/******/ })();
|
|
4551
4551
|
/******/
|
|
@@ -4642,7 +4642,6 @@ let _TextDecoder;
|
|
|
4642
4642
|
let _TextEncoder;
|
|
4643
4643
|
if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
|
|
4644
4644
|
// Wait to require the text encoding polyfill until we know it's needed.
|
|
4645
|
-
// eslint-disable-next-line global-require
|
|
4646
4645
|
const encoding = __webpack_require__(767);
|
|
4647
4646
|
_TextDecoder = encoding.TextDecoder;
|
|
4648
4647
|
_TextEncoder = encoding.TextEncoder;
|
|
@@ -4657,12 +4656,12 @@ const memoizedToString = function () {
|
|
|
4657
4656
|
* 32766 is a multiple of 3 so btoa does not need to use padding characters
|
|
4658
4657
|
* except for the final chunk where that is fine. 32766 is also close to
|
|
4659
4658
|
* 32768 so it is close to a size an memory allocator would prefer.
|
|
4660
|
-
* @
|
|
4659
|
+
* @constant {number}
|
|
4661
4660
|
*/
|
|
4662
4661
|
const BTOA_CHUNK_MAX_LENGTH = 32766;
|
|
4663
4662
|
/**
|
|
4664
4663
|
* An array cache of bytes to characters.
|
|
4665
|
-
* @
|
|
4664
|
+
* @constant {?Array.<string>}
|
|
4666
4665
|
*/
|
|
4667
4666
|
let fromCharCode = null;
|
|
4668
4667
|
const strings = {};
|
|
@@ -4670,7 +4669,6 @@ const memoizedToString = function () {
|
|
|
4670
4669
|
if (!Object.prototype.hasOwnProperty.call(strings, assetId)) {
|
|
4671
4670
|
if (typeof btoa === 'undefined') {
|
|
4672
4671
|
// Use a library that does not need btoa to run.
|
|
4673
|
-
/* eslint-disable-next-line global-require */
|
|
4674
4672
|
const base64js = __webpack_require__(526);
|
|
4675
4673
|
strings[assetId] = base64js.fromByteArray(data);
|
|
4676
4674
|
} else {
|
|
@@ -4721,7 +4719,7 @@ class Asset {
|
|
|
4721
4719
|
* @param {string} assetId - The ID of this asset.
|
|
4722
4720
|
* @param {DataFormat} [dataFormat] - The format of the data (WAV, PNG, etc.); required iff `data` is present.
|
|
4723
4721
|
* @param {Buffer} [data] - The in-memory data for this asset; optional.
|
|
4724
|
-
* @param {
|
|
4722
|
+
* @param {boolean} [generateId] - Whether to create id from an md5 hash of data
|
|
4725
4723
|
*/
|
|
4726
4724
|
constructor(assetType, assetId, dataFormat, data, generateId) {
|
|
4727
4725
|
_defineProperty(this, "assetType", void 0);
|
|
@@ -4764,7 +4762,7 @@ class Asset {
|
|
|
4764
4762
|
* Same as `setData` but encodes text first.
|
|
4765
4763
|
* @param {string} data - the text data to encode and store.
|
|
4766
4764
|
* @param {DataFormat} dataFormat - the format of the data (DataFormat.SVG for example).
|
|
4767
|
-
* @param {
|
|
4765
|
+
* @param {boolean} generateId - after setting data, set the id to an md5 of the data?
|
|
4768
4766
|
*/
|
|
4769
4767
|
encodeTextData(data, dataFormat, generateId) {
|
|
4770
4768
|
const encoder = new _TextEncoder();
|
|
@@ -4800,8 +4798,8 @@ const DataFormat = {
|
|
|
4800
4798
|
|
|
4801
4799
|
/**
|
|
4802
4800
|
* Enumeration of the supported asset types.
|
|
4803
|
-
* @type {
|
|
4804
|
-
* @typedef {
|
|
4801
|
+
* @type {{[assetTypeName: string]: AssetType}}
|
|
4802
|
+
* @typedef {object} AssetType - Information about a supported asset type.
|
|
4805
4803
|
* @property {string} contentType - the MIME type associated with this kind of data. Useful for data URIs, etc.
|
|
4806
4804
|
* @property {string} name - The human-readable name of this asset type.
|
|
4807
4805
|
* @property {DataFormat} runtimeFormat - The default format used for runtime, in-memory storage of this asset. For
|
|
@@ -4858,7 +4856,7 @@ class Helper {
|
|
|
4858
4856
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
4859
4857
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
4860
4858
|
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
|
|
4861
|
-
* @
|
|
4859
|
+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
|
|
4862
4860
|
*/
|
|
4863
4861
|
load(assetType, assetId, dataFormat) {
|
|
4864
4862
|
return Promise.reject(new Error("No asset of type ".concat(assetType, " for ID ").concat(assetId, " with format ").concat(dataFormat)));
|
|
@@ -4917,8 +4915,8 @@ class BuiltinHelper extends Helper {
|
|
|
4917
4915
|
super(parent);
|
|
4918
4916
|
/**
|
|
4919
4917
|
* In-memory storage for all built-in assets.
|
|
4920
|
-
* @type {
|
|
4921
|
-
* @typedef {
|
|
4918
|
+
* @type {{[assetType: string]: AssetIdMap}} Maps asset type to a map of asset ID to actual assets.
|
|
4919
|
+
* @typedef {{[id: string]: BuiltinAssetRecord}} AssetIdMap - Maps asset ID to asset.
|
|
4922
4920
|
*/
|
|
4923
4921
|
BuiltinHelper_defineProperty(this, "assets", void 0);
|
|
4924
4922
|
this.assets = {};
|
|
@@ -4944,7 +4942,7 @@ class BuiltinHelper extends Helper {
|
|
|
4944
4942
|
get(assetId) {
|
|
4945
4943
|
let asset = null;
|
|
4946
4944
|
if (Object.prototype.hasOwnProperty.call(this.assets, assetId)) {
|
|
4947
|
-
/** @type{BuiltinAssetRecord} */
|
|
4945
|
+
/** @type {BuiltinAssetRecord} */
|
|
4948
4946
|
const assetRecord = this.assets[assetId];
|
|
4949
4947
|
asset = new Asset(assetRecord.type, assetRecord.id, assetRecord.format, assetRecord.data);
|
|
4950
4948
|
}
|
|
@@ -5006,7 +5004,7 @@ class BuiltinHelper extends Helper {
|
|
|
5006
5004
|
* Fetch an asset but don't process dependencies.
|
|
5007
5005
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
5008
5006
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
5009
|
-
* @
|
|
5007
|
+
* @returns {?Promise.<Asset>} A promise for the contents of the asset.
|
|
5010
5008
|
*/
|
|
5011
5009
|
load(assetType, assetId) {
|
|
5012
5010
|
if (!this.get(assetId)) {
|
|
@@ -5064,7 +5062,6 @@ class PrivateFetchWorkerTool {
|
|
|
5064
5062
|
// Yes, this is a browser API and we've specified `browser: false` in the eslint env,
|
|
5065
5063
|
// but `isGetSupported` checks for the presence of Worker and uses it only if present.
|
|
5066
5064
|
// Also see https://webpack.js.org/guides/web-workers/
|
|
5067
|
-
// eslint-disable-next-line no-undef
|
|
5068
5065
|
const worker = new Worker(/* webpackChunkName: "fetch-worker" */new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u(836), __webpack_require__.b));
|
|
5069
5066
|
worker.addEventListener('message', _ref => {
|
|
5070
5067
|
let {
|
|
@@ -5447,7 +5444,7 @@ class WebHelper extends Helper {
|
|
|
5447
5444
|
* @param {AssetType} assetType - The type of asset to fetch.
|
|
5448
5445
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
5449
5446
|
* @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
|
|
5450
|
-
* @
|
|
5447
|
+
* @returns {Promise.<Asset>} A promise for the contents of the asset.
|
|
5451
5448
|
*/
|
|
5452
5449
|
load(assetType, assetId, dataFormat) {
|
|
5453
5450
|
/** @type {Array.<{url:string, result:*}>} List of URLs attempted & errors encountered. */
|
|
@@ -5493,7 +5490,7 @@ class WebHelper extends Helper {
|
|
|
5493
5490
|
* @param {?DataFormat} dataFormat - DataFormat of the data for the stored asset.
|
|
5494
5491
|
* @param {Buffer} data - The data for the cached asset.
|
|
5495
5492
|
* @param {?string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
5496
|
-
* @
|
|
5493
|
+
* @returns {Promise.<object>} A promise for the response from the create or update request
|
|
5497
5494
|
*/
|
|
5498
5495
|
store(assetType, dataFormat, data, assetId) {
|
|
5499
5496
|
const asset = new Asset(assetType, assetId, dataFormat);
|
|
@@ -5529,6 +5526,7 @@ class WebHelper extends Helper {
|
|
|
5529
5526
|
try {
|
|
5530
5527
|
body = JSON.parse(body);
|
|
5531
5528
|
} catch (parseError) {
|
|
5529
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5532
5530
|
// If it's not parseable, then we can't add the id even
|
|
5533
5531
|
// if we want to, so stop here
|
|
5534
5532
|
return body;
|
|
@@ -5570,45 +5568,45 @@ class ScratchStorage {
|
|
|
5570
5568
|
}];
|
|
5571
5569
|
}
|
|
5572
5570
|
/**
|
|
5573
|
-
* @
|
|
5574
|
-
* @
|
|
5571
|
+
* @returns {Asset} - the `Asset` class constructor.
|
|
5572
|
+
* @class
|
|
5575
5573
|
*/
|
|
5576
5574
|
get Asset() {
|
|
5577
5575
|
return Asset;
|
|
5578
5576
|
}
|
|
5579
5577
|
/**
|
|
5580
|
-
* @
|
|
5581
|
-
* @
|
|
5578
|
+
* @returns {AssetType} - the list of supported asset types.
|
|
5579
|
+
* @class
|
|
5582
5580
|
*/
|
|
5583
5581
|
get AssetType() {
|
|
5584
5582
|
return AssetType;
|
|
5585
5583
|
}
|
|
5586
5584
|
/**
|
|
5587
|
-
* @
|
|
5588
|
-
* @
|
|
5585
|
+
* @returns {DataFormat} - the list of supported data formats.
|
|
5586
|
+
* @class
|
|
5589
5587
|
*/
|
|
5590
5588
|
get DataFormat() {
|
|
5591
5589
|
return DataFormat;
|
|
5592
5590
|
}
|
|
5593
5591
|
/**
|
|
5594
5592
|
* Access the `scratchFetch` module within this library.
|
|
5595
|
-
* @
|
|
5593
|
+
* @returns {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
|
|
5596
5594
|
*/
|
|
5597
5595
|
get scratchFetch() {
|
|
5598
5596
|
return (scratchFetch_default());
|
|
5599
5597
|
}
|
|
5600
5598
|
/**
|
|
5601
5599
|
* @deprecated Please use the `Asset` member of a storage instance instead.
|
|
5602
|
-
* @
|
|
5603
|
-
* @
|
|
5600
|
+
* @returns {Asset} - the `Asset` class constructor.
|
|
5601
|
+
* @class
|
|
5604
5602
|
*/
|
|
5605
5603
|
static get Asset() {
|
|
5606
5604
|
return Asset;
|
|
5607
5605
|
}
|
|
5608
5606
|
/**
|
|
5609
5607
|
* @deprecated Please use the `AssetType` member of a storage instance instead.
|
|
5610
|
-
* @
|
|
5611
|
-
* @
|
|
5608
|
+
* @returns {AssetType} - the list of supported asset types.
|
|
5609
|
+
* @class
|
|
5612
5610
|
*/
|
|
5613
5611
|
static get AssetType() {
|
|
5614
5612
|
return AssetType;
|
|
@@ -5684,7 +5682,7 @@ class ScratchStorage {
|
|
|
5684
5682
|
/**
|
|
5685
5683
|
* TODO: Should this be removed in favor of requesting an asset with `null` as the ID?
|
|
5686
5684
|
* @param {AssetType} type - Get the default ID for assets of this type.
|
|
5687
|
-
* @
|
|
5685
|
+
* @returns {?string} The ID of the default asset of the given type, if any.
|
|
5688
5686
|
*/
|
|
5689
5687
|
getDefaultAssetId(type) {
|
|
5690
5688
|
if (Object.prototype.hasOwnProperty.call(this.defaultAssetId, type.name)) {
|
|
@@ -5707,7 +5705,7 @@ class ScratchStorage {
|
|
|
5707
5705
|
* @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
|
|
5708
5706
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
5709
5707
|
* @param {DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
|
|
5710
|
-
* @
|
|
5708
|
+
* @returns {Promise.<Asset>} A promise for the requested Asset.
|
|
5711
5709
|
* If the promise is resolved with non-null, the value is the requested asset.
|
|
5712
5710
|
* If the promise is resolved with null, the desired asset could not be found with the current asset sources.
|
|
5713
5711
|
* If the promise is rejected, there was an error on at least one asset source. HTTP 404 does not count as an
|
|
@@ -5750,7 +5748,7 @@ class ScratchStorage {
|
|
|
5750
5748
|
* @param {?DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
|
|
5751
5749
|
* @param {Buffer} data - Data to store for the asset
|
|
5752
5750
|
* @param {?string} [assetId] - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
5753
|
-
* @
|
|
5751
|
+
* @returns {Promise.<object>} A promise for asset metadata
|
|
5754
5752
|
*/
|
|
5755
5753
|
store(assetType, dataFormat, data, assetId) {
|
|
5756
5754
|
dataFormat = dataFormat || assetType.runtimeFormat;
|