scratch-storage 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -240,31 +240,31 @@ module.exports = _inherits, module.exports.__esModule = true, module.exports["de
240
240
  /*! no static exports found */
241
241
  /***/ (function(module, exports) {
242
242
 
243
- function _iterableToArrayLimit(arr, i) {
244
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
245
- if (null != _i) {
246
- var _s,
247
- _e,
248
- _x,
249
- _r,
250
- _arr = [],
251
- _n = !0,
252
- _d = !1;
243
+ function _iterableToArrayLimit(r, l) {
244
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
245
+ if (null != t) {
246
+ var e,
247
+ n,
248
+ i,
249
+ u,
250
+ a = [],
251
+ f = !0,
252
+ o = !1;
253
253
  try {
254
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
255
- if (Object(_i) !== _i) return;
256
- _n = !1;
257
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
258
- } catch (err) {
259
- _d = !0, _e = err;
254
+ if (i = (t = t.call(r)).next, 0 === l) {
255
+ if (Object(t) !== t) return;
256
+ f = !1;
257
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
258
+ } catch (r) {
259
+ o = !0, n = r;
260
260
  } finally {
261
261
  try {
262
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
262
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
263
263
  } finally {
264
- if (_d) throw _e;
264
+ if (o) throw n;
265
265
  }
266
266
  }
267
- return _arr;
267
+ return a;
268
268
  }
269
269
  }
270
270
  module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
@@ -400,17 +400,17 @@ module.exports = _slicedToArray, module.exports.__esModule = true, module.export
400
400
  /***/ (function(module, exports, __webpack_require__) {
401
401
 
402
402
  var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"];
403
- function _toPrimitive(input, hint) {
404
- if (_typeof(input) !== "object" || input === null) return input;
405
- var prim = input[Symbol.toPrimitive];
406
- if (prim !== undefined) {
407
- var res = prim.call(input, hint || "default");
408
- if (_typeof(res) !== "object") return res;
403
+ function toPrimitive(t, r) {
404
+ if ("object" != _typeof(t) || !t) return t;
405
+ var e = t[Symbol.toPrimitive];
406
+ if (void 0 !== e) {
407
+ var i = e.call(t, r || "default");
408
+ if ("object" != _typeof(i)) return i;
409
409
  throw new TypeError("@@toPrimitive must return a primitive value.");
410
410
  }
411
- return (hint === "string" ? String : Number)(input);
411
+ return ("string" === r ? String : Number)(t);
412
412
  }
413
- module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
413
+ module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
414
414
 
415
415
  /***/ }),
416
416
 
@@ -423,11 +423,11 @@ module.exports = _toPrimitive, module.exports.__esModule = true, module.exports[
423
423
 
424
424
  var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"];
425
425
  var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js");
426
- function _toPropertyKey(arg) {
427
- var key = toPrimitive(arg, "string");
428
- return _typeof(key) === "symbol" ? key : String(key);
426
+ function toPropertyKey(t) {
427
+ var i = toPrimitive(t, "string");
428
+ return "symbol" == _typeof(i) ? i : String(i);
429
429
  }
430
- module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
430
+ module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
431
431
 
432
432
  /***/ }),
433
433
 
@@ -438,14 +438,14 @@ module.exports = _toPropertyKey, module.exports.__esModule = true, module.export
438
438
  /*! no static exports found */
439
439
  /***/ (function(module, exports) {
440
440
 
441
- function _typeof(obj) {
441
+ function _typeof(o) {
442
442
  "@babel/helpers - typeof";
443
443
 
444
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
445
- return typeof obj;
446
- } : function (obj) {
447
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
448
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
444
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
445
+ return typeof o;
446
+ } : function (o) {
447
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
448
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
449
449
  }
450
450
  module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
451
451
 
@@ -572,7 +572,8 @@ function toByteArray (b64) {
572
572
  ? validLen - 4
573
573
  : validLen
574
574
 
575
- for (var i = 0; i < len; i += 4) {
575
+ var i
576
+ for (i = 0; i < len; i += 4) {
576
577
  tmp =
577
578
  (revLookup[b64.charCodeAt(i)] << 18) |
578
579
  (revLookup[b64.charCodeAt(i + 1)] << 12) |
@@ -631,9 +632,7 @@ function fromByteArray (uint8) {
631
632
 
632
633
  // go through the array every three bytes, we'll deal with trailing stuff later
633
634
  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
634
- parts.push(encodeChunk(
635
- uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
636
- ))
635
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
637
636
  }
638
637
 
639
638
  // pad the end with zeros, but make sure to not forget the extra bytes
@@ -680,7 +679,7 @@ function fromByteArray (uint8) {
680
679
 
681
680
  var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
682
681
  var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
683
- var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
682
+ var isArray = __webpack_require__(/*! isarray */ "./node_modules/buffer/node_modules/isarray/index.js")
684
683
 
685
684
  exports.Buffer = Buffer
686
685
  exports.SlowBuffer = SlowBuffer
@@ -2460,6 +2459,22 @@ function isnan (val) {
2460
2459
 
2461
2460
  /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
2462
2461
 
2462
+ /***/ }),
2463
+
2464
+ /***/ "./node_modules/buffer/node_modules/isarray/index.js":
2465
+ /*!***********************************************************!*\
2466
+ !*** ./node_modules/buffer/node_modules/isarray/index.js ***!
2467
+ \***********************************************************/
2468
+ /*! no static exports found */
2469
+ /***/ (function(module, exports) {
2470
+
2471
+ var toString = {}.toString;
2472
+
2473
+ module.exports = Array.isArray || function (arr) {
2474
+ return toString.call(arr) == '[object Array]';
2475
+ };
2476
+
2477
+
2463
2478
  /***/ }),
2464
2479
 
2465
2480
  /***/ "./node_modules/cross-fetch/dist/browser-ponyfill.js":
@@ -3140,22 +3155,6 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3140
3155
  }
3141
3156
 
3142
3157
 
3143
- /***/ }),
3144
-
3145
- /***/ "./node_modules/isarray/index.js":
3146
- /*!***************************************!*\
3147
- !*** ./node_modules/isarray/index.js ***!
3148
- \***************************************/
3149
- /*! no static exports found */
3150
- /***/ (function(module, exports) {
3151
-
3152
- var toString = {}.toString;
3153
-
3154
- module.exports = Array.isArray || function (arr) {
3155
- return toString.call(arr) == '[object Array]';
3156
- };
3157
-
3158
-
3159
3158
  /***/ }),
3160
3159
 
3161
3160
  /***/ "./node_modules/js-md5/src/md5.js":
@@ -4697,7 +4696,7 @@ module.exports = g;
4697
4696
  /***/ (function(module, exports, __webpack_require__) {
4698
4697
 
4699
4698
  module.exports = function() {
4700
- return __webpack_require__(/*! !./node_modules/worker-loader/dist/workers/InlineWorker.js */ "./node_modules/worker-loader/dist/workers/InlineWorker.js")("/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = \"./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js\");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ \"./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js\":\n/*!*******************************************************************************!*\\\n !*** ./node_modules/babel-loader/lib??ref--4!./src/FetchWorkerTool.worker.js ***!\n \\*******************************************************************************/\n/*! no static exports found */\n/***/ (function(module, exports, __webpack_require__) {\n\n/* eslint-env worker */\nvar crossFetch = __webpack_require__(/*! cross-fetch */ \"./node_modules/cross-fetch/dist/browser-ponyfill.js\").default;\n\nvar jobsActive = 0;\nvar complete = [];\nvar intervalId = null;\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 */\n\nvar registerStep = function registerStep() {\n intervalId = setInterval(function () {\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(complete.slice(), // 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(function (response) {\n return response.buffer;\n }).filter(Boolean));\n complete.length = 0;\n }\n\n if (jobsActive === 0) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }, 1);\n};\n/**\n * Receive a job from the parent and fetch the requested data.\n * @param {object} options.job A job id, url, and options descriptor to perform.\n */\n\n\nvar onMessage = function onMessage(_ref) {\n var job = _ref.data;\n\n if (jobsActive === 0 && !intervalId) {\n registerStep();\n }\n\n jobsActive++;\n crossFetch(job.url, job.options).then(function (result) {\n if (result.ok) return result.arrayBuffer();\n if (result.status === 404) return null;\n return Promise.reject(result.status);\n }).then(function (buffer) {\n return complete.push({\n id: job.id,\n buffer: buffer\n });\n }).catch(function (error) {\n return complete.push({\n id: job.id,\n error: error && error.message || \"Failed request: \".concat(job.url)\n });\n }).then(function () {\n return jobsActive--;\n });\n}; // crossFetch means \"fetch\" is now always supported\n\n\npostMessage({\n support: {\n fetch: true\n }\n});\nself.addEventListener('message', onMessage);\n\n/***/ }),\n\n/***/ \"./node_modules/cross-fetch/dist/browser-ponyfill.js\":\n/*!***********************************************************!*\\\n !*** ./node_modules/cross-fetch/dist/browser-ponyfill.js ***!\n \\***********************************************************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nvar global = typeof self !== 'undefined' ? self : this;\nvar __self__ = (function () {\nfunction F() {\nthis.fetch = false;\nthis.DOMException = global.DOMException\n}\nF.prototype = global;\nreturn new F();\n})();\n(function(self) {\n\nvar irrelevant = (function (exports) {\n\n var support = {\n searchParams: 'URLSearchParams' in self,\n iterable: 'Symbol' in self && 'iterator' in Symbol,\n blob:\n 'FileReader' in self &&\n 'Blob' in self &&\n (function() {\n try {\n new Blob();\n return true\n } catch (e) {\n return false\n }\n })(),\n formData: 'FormData' in self,\n arrayBuffer: 'ArrayBuffer' in self\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)) {\n throw new TypeError('Invalid character in header field 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 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.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 reader.readAsText(blob);\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 this._bodyInit = body;\n if (!body) {\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 this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n return consumed(this) || Promise.resolve(this._bodyArrayBuffer)\n } else {\n return this.blob().then(readBlobAsArrayBuffer)\n }\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 = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];\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 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;\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\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 preProcessedHeaders.split(/\\r?\\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 headers.append(key, value);\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = 'statusText' in options ? options.statusText : 'OK';\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: 0, statusText: ''});\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 = self.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 status: xhr.status,\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\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 resolve(new Response(body, options));\n };\n\n xhr.onerror = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.ontimeout = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.onabort = function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n };\n\n xhr.open(request.method, 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 && support.blob) {\n xhr.responseType = 'blob';\n }\n\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\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 (!self.fetch) {\n self.fetch = fetch;\n self.Headers = Headers;\n self.Request = Request;\n self.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n return exports;\n\n})({});\n})(__self__);\n__self__.fetch.ponyfill = true;\n// Remove \"polyfill\" property added by whatwg-fetch\ndelete __self__.fetch.polyfill;\n// Choose between native implementation (global) or custom implementation (__self__)\n// var ctx = global.fetch ? global : __self__;\nvar ctx = __self__; // this line disable service worker support temporarily\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\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=90c5db0dff5ca2a36ff6.worker.js.map", __webpack_require__.p + "90c5db0dff5ca2a36ff6.worker.js");
4699
+ return __webpack_require__(/*! !./node_modules/worker-loader/dist/workers/InlineWorker.js */ "./node_modules/worker-loader/dist/workers/InlineWorker.js")("/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = \"./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js\");\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ \"./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js\":\n/*!*******************************************************************************!*\\\n !*** ./node_modules/babel-loader/lib??ref--4!./src/FetchWorkerTool.worker.js ***!\n \\*******************************************************************************/\n/*! no static exports found */\n/***/ (function(module, exports, __webpack_require__) {\n\n/* eslint-env worker */\n\nvar crossFetch = __webpack_require__(/*! cross-fetch */ \"./node_modules/cross-fetch/dist/browser-ponyfill.js\").default;\nvar jobsActive = 0;\nvar complete = [];\nvar 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 */\nvar registerStep = function registerStep() {\n intervalId = setInterval(function () {\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(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(function (response) {\n return response.buffer;\n }).filter(Boolean));\n complete.length = 0;\n }\n if (jobsActive === 0) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }, 1);\n};\n\n/**\n * Receive a job from the parent and fetch the requested data.\n * @param {object} options.job A job id, url, and options descriptor to perform.\n */\nvar onMessage = function onMessage(_ref) {\n var job = _ref.data;\n if (jobsActive === 0 && !intervalId) {\n registerStep();\n }\n jobsActive++;\n crossFetch(job.url, job.options).then(function (result) {\n if (result.ok) return result.arrayBuffer();\n if (result.status === 404) return null;\n return Promise.reject(result.status);\n }).then(function (buffer) {\n return complete.push({\n id: job.id,\n buffer: buffer\n });\n }).catch(function (error) {\n return complete.push({\n id: job.id,\n error: error && error.message || \"Failed request: \".concat(job.url)\n });\n }).then(function () {\n return jobsActive--;\n });\n};\n\n// crossFetch means \"fetch\" is now always supported\npostMessage({\n support: {\n fetch: true\n }\n});\nself.addEventListener('message', onMessage);\n\n/***/ }),\n\n/***/ \"./node_modules/cross-fetch/dist/browser-ponyfill.js\":\n/*!***********************************************************!*\\\n !*** ./node_modules/cross-fetch/dist/browser-ponyfill.js ***!\n \\***********************************************************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nvar global = typeof self !== 'undefined' ? self : this;\nvar __self__ = (function () {\nfunction F() {\nthis.fetch = false;\nthis.DOMException = global.DOMException\n}\nF.prototype = global;\nreturn new F();\n})();\n(function(self) {\n\nvar irrelevant = (function (exports) {\n\n var support = {\n searchParams: 'URLSearchParams' in self,\n iterable: 'Symbol' in self && 'iterator' in Symbol,\n blob:\n 'FileReader' in self &&\n 'Blob' in self &&\n (function() {\n try {\n new Blob();\n return true\n } catch (e) {\n return false\n }\n })(),\n formData: 'FormData' in self,\n arrayBuffer: 'ArrayBuffer' in self\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)) {\n throw new TypeError('Invalid character in header field 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 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.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 reader.readAsText(blob);\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 this._bodyInit = body;\n if (!body) {\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 this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n return consumed(this) || Promise.resolve(this._bodyArrayBuffer)\n } else {\n return this.blob().then(readBlobAsArrayBuffer)\n }\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 = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];\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 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;\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\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 preProcessedHeaders.split(/\\r?\\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 headers.append(key, value);\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = 'statusText' in options ? options.statusText : 'OK';\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: 0, statusText: ''});\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 = self.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 status: xhr.status,\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\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 resolve(new Response(body, options));\n };\n\n xhr.onerror = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.ontimeout = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.onabort = function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n };\n\n xhr.open(request.method, 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 && support.blob) {\n xhr.responseType = 'blob';\n }\n\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\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 (!self.fetch) {\n self.fetch = fetch;\n self.Headers = Headers;\n self.Request = Request;\n self.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n return exports;\n\n})({});\n})(__self__);\n__self__.fetch.ponyfill = true;\n// Remove \"polyfill\" property added by whatwg-fetch\ndelete __self__.fetch.polyfill;\n// Choose between native implementation (global) or custom implementation (__self__)\n// var ctx = global.fetch ? global : __self__;\nvar ctx = __self__; // this line disable service worker support temporarily\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\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=f6240eab828e6d415177.worker.js.map", __webpack_require__.p + "f6240eab828e6d415177.worker.js");
4701
4700
  };
4702
4701
 
4703
4702
  /***/ }),
@@ -4758,29 +4757,22 @@ module.exports = function (content, url) {
4758
4757
  /***/ (function(module, exports, __webpack_require__) {
4759
4758
 
4760
4759
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
4761
-
4762
4760
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
4763
-
4764
4761
  // Use JS implemented TextDecoder and TextEncoder if it is not provided by the
4765
4762
  // browser.
4766
4763
  var _TextDecoder;
4767
-
4768
4764
  var _TextEncoder;
4769
-
4770
4765
  if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
4771
4766
  // Wait to require the text encoding polyfill until we know it's needed.
4772
4767
  // eslint-disable-next-line global-require
4773
4768
  var encoding = __webpack_require__(/*! fastestsmallesttextencoderdecoder */ "./node_modules/fastestsmallesttextencoderdecoder/EncoderDecoderTogether.min.js");
4774
-
4775
4769
  _TextDecoder = encoding.TextDecoder;
4776
4770
  _TextEncoder = encoding.TextEncoder;
4777
4771
  } else {
4778
4772
  _TextDecoder = TextDecoder;
4779
4773
  _TextEncoder = TextEncoder;
4780
4774
  }
4781
-
4782
4775
  var md5 = __webpack_require__(/*! js-md5 */ "./node_modules/js-md5/src/md5.js");
4783
-
4784
4776
  var memoizedToString = function () {
4785
4777
  /**
4786
4778
  * The maximum length of a chunk before encoding it into base64.
@@ -4791,21 +4783,19 @@ var memoizedToString = function () {
4791
4783
  * @const {number}
4792
4784
  */
4793
4785
  var BTOA_CHUNK_MAX_LENGTH = 32766;
4786
+
4794
4787
  /**
4795
4788
  * An array cache of bytes to characters.
4796
4789
  * @const {?Array.<string>}
4797
4790
  */
4798
-
4799
4791
  var fromCharCode = null;
4800
4792
  var strings = {};
4801
4793
  return function (assetId, data) {
4802
4794
  if (!Object.prototype.hasOwnProperty.call(strings, assetId)) {
4803
4795
  if (typeof btoa === 'undefined') {
4804
4796
  // Use a library that does not need btoa to run.
4805
-
4806
4797
  /* eslint-disable-next-line global-require */
4807
4798
  var base64js = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js");
4808
-
4809
4799
  strings[assetId] = base64js.fromByteArray(data);
4810
4800
  } else {
4811
4801
  // Native btoa is faster than javascript translation. Use js to
@@ -4813,41 +4803,32 @@ var memoizedToString = function () {
4813
4803
  if (fromCharCode === null) {
4814
4804
  // Cache the first 256 characters for input byte values.
4815
4805
  fromCharCode = new Array(256);
4816
-
4817
4806
  for (var i = 0; i < 256; i++) {
4818
4807
  fromCharCode[i] = String.fromCharCode(i);
4819
4808
  }
4820
4809
  }
4821
-
4822
4810
  var length = data.length;
4823
- var s = ''; // Iterate over chunks of the binary data.
4824
-
4811
+ var s = '';
4812
+ // Iterate over chunks of the binary data.
4825
4813
  for (var _i = 0, e = 0; _i < length; _i = e) {
4826
4814
  // Create small chunks to cause more small allocations and
4827
4815
  // less large allocations.
4828
4816
  e = Math.min(e + BTOA_CHUNK_MAX_LENGTH, length);
4829
4817
  var s_ = '';
4830
-
4831
4818
  for (var j = _i; j < e; j += 1) {
4832
4819
  s_ += fromCharCode[data[j]];
4833
- } // Encode the latest chunk so the we create one big output
4820
+ }
4821
+ // Encode the latest chunk so the we create one big output
4834
4822
  // string instead of creating a big input string and then
4835
4823
  // one big output string.
4836
-
4837
- /* global btoa */
4838
-
4839
-
4840
4824
  s += btoa(s_);
4841
4825
  }
4842
-
4843
4826
  strings[assetId] = s;
4844
4827
  }
4845
4828
  }
4846
-
4847
4829
  return strings[assetId];
4848
4830
  };
4849
4831
  }();
4850
-
4851
4832
  var Asset = /*#__PURE__*/function () {
4852
4833
  "use strict";
4853
4834
 
@@ -4861,64 +4842,62 @@ var Asset = /*#__PURE__*/function () {
4861
4842
  */
4862
4843
  function Asset(assetType, assetId, dataFormat, data, generateId) {
4863
4844
  _classCallCheck(this, Asset);
4864
-
4865
4845
  /** @type {AssetType} */
4866
4846
  this.assetType = assetType;
4867
- /** @type {string} */
4868
4847
 
4848
+ /** @type {string} */
4869
4849
  this.assetId = assetId;
4870
4850
  this.setData(data, dataFormat || assetType.runtimeFormat, generateId);
4871
- /** @type {Asset[]} */
4872
4851
 
4852
+ /** @type {Asset[]} */
4873
4853
  this.dependencies = [];
4874
4854
  }
4875
-
4876
4855
  _createClass(Asset, [{
4877
4856
  key: "setData",
4878
4857
  value: function setData(data, dataFormat, generateId) {
4879
4858
  if (data && !dataFormat) {
4880
4859
  throw new Error('Data provided without specifying its format');
4881
4860
  }
4882
- /** @type {DataFormat} */
4883
-
4884
4861
 
4862
+ /** @type {DataFormat} */
4885
4863
  this.dataFormat = dataFormat;
4886
- /** @type {Buffer} */
4887
4864
 
4865
+ /** @type {Buffer} */
4888
4866
  this.data = data;
4889
- if (generateId) this.assetId = md5(data); // Mark as clean only if set is being called without generateId
4890
- // If a new id is being generated, mark this asset as not clean
4867
+ if (generateId) this.assetId = md5(data);
4891
4868
 
4869
+ // Mark as clean only if set is being called without generateId
4870
+ // If a new id is being generated, mark this asset as not clean
4892
4871
  this.clean = !generateId;
4893
4872
  }
4873
+
4894
4874
  /**
4895
4875
  * @returns {string} - This asset's data, decoded as text.
4896
4876
  */
4897
-
4898
4877
  }, {
4899
4878
  key: "decodeText",
4900
4879
  value: function decodeText() {
4901
4880
  var decoder = new _TextDecoder();
4902
4881
  return decoder.decode(this.data);
4903
4882
  }
4883
+
4904
4884
  /**
4905
4885
  * Same as `setData` but encodes text first.
4906
4886
  * @param {string} data - the text data to encode and store.
4907
4887
  * @param {DataFormat} dataFormat - the format of the data (DataFormat.SVG for example).
4908
4888
  * @param {bool} generateId - after setting data, set the id to an md5 of the data?
4909
4889
  */
4910
-
4911
4890
  }, {
4912
4891
  key: "encodeTextData",
4913
4892
  value: function encodeTextData(data, dataFormat, generateId) {
4914
4893
  var encoder = new _TextEncoder();
4915
4894
  this.setData(encoder.encode(data), dataFormat, generateId);
4916
4895
  }
4896
+
4917
4897
  /**
4918
4898
  * @param {string} [contentType] - Optionally override the content type to be included in the data URI.
4919
4899
  * @returns {string} - A data URI representing the asset's data.
4920
4900
  */
4921
-
4922
4901
  }, {
4923
4902
  key: "encodeDataURI",
4924
4903
  value: function encodeDataURI(contentType) {
@@ -4926,10 +4905,8 @@ var Asset = /*#__PURE__*/function () {
4926
4905
  return "data:".concat(contentType, ";base64,").concat(memoizedToString(this.assetId, this.data));
4927
4906
  }
4928
4907
  }]);
4929
-
4930
4908
  return Asset;
4931
4909
  }();
4932
-
4933
4910
  module.exports = Asset;
4934
4911
 
4935
4912
  /***/ }),
@@ -4942,6 +4919,7 @@ module.exports = Asset;
4942
4919
  /***/ (function(module, exports, __webpack_require__) {
4943
4920
 
4944
4921
  var DataFormat = __webpack_require__(/*! ./DataFormat */ "./src/DataFormat.js");
4922
+
4945
4923
  /**
4946
4924
  * Enumeration of the supported asset types.
4947
4925
  * @type {Object.<String,AssetType>}
@@ -4952,8 +4930,6 @@ var DataFormat = __webpack_require__(/*! ./DataFormat */ "./src/DataFormat.js");
4952
4930
  * example, a project stored in SB2 format on disk will be returned as JSON when loaded into memory.
4953
4931
  * @property {boolean} immutable - Indicates if the asset id is determined by the asset content.
4954
4932
  */
4955
-
4956
-
4957
4933
  var AssetType = {
4958
4934
  ImageBitmap: {
4959
4935
  contentType: 'image/png',
@@ -4998,30 +4974,19 @@ module.exports = AssetType;
4998
4974
  /***/ (function(module, exports, __webpack_require__) {
4999
4975
 
5000
4976
  /* WEBPACK VAR INJECTION */(function(Buffer) {var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5001
-
5002
4977
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5003
-
5004
- var _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js");
5005
-
5006
4978
  var _possibleConstructorReturn = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js");
5007
-
5008
4979
  var _getPrototypeOf = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js");
5009
-
5010
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
5011
-
5012
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
5013
-
4980
+ var _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js");
4981
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
4982
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5014
4983
  var md5 = __webpack_require__(/*! js-md5 */ "./node_modules/js-md5/src/md5.js");
5015
-
5016
4984
  var log = __webpack_require__(/*! ./log */ "./src/log.js");
5017
-
5018
4985
  var Asset = __webpack_require__(/*! ./Asset */ "./src/Asset.js");
5019
-
5020
4986
  var AssetType = __webpack_require__(/*! ./AssetType */ "./src/AssetType.js");
5021
-
5022
4987
  var DataFormat = __webpack_require__(/*! ./DataFormat */ "./src/DataFormat.js");
5023
-
5024
4988
  var Helper = __webpack_require__(/*! ./Helper */ "./src/Helper.js");
4989
+
5025
4990
  /**
5026
4991
  * @typedef {object} BuiltinAssetRecord
5027
4992
  * @property {AssetType} type - The type of the asset.
@@ -5033,8 +4998,6 @@ var Helper = __webpack_require__(/*! ./Helper */ "./src/Helper.js");
5033
4998
  /**
5034
4999
  * @type {BuiltinAssetRecord[]}
5035
5000
  */
5036
-
5037
-
5038
5001
  var DefaultAssets = [{
5039
5002
  type: AssetType.ImageBitmap,
5040
5003
  format: DataFormat.PNG,
@@ -5054,71 +5017,62 @@ var DefaultAssets = [{
5054
5017
  data: Buffer.from(__webpack_require__(/*! ./builtins/defaultVector.svg */ "./src/builtins/defaultVector.svg") // eslint-disable-line global-require
5055
5018
  )
5056
5019
  }];
5020
+
5057
5021
  /**
5058
5022
  * @type {BuiltinAssetRecord[]}
5059
5023
  */
5060
-
5061
5024
  var BuiltinAssets = DefaultAssets.concat([]);
5062
-
5063
5025
  var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5064
5026
  "use strict";
5065
5027
 
5066
5028
  _inherits(BuiltinHelper, _Helper);
5067
-
5068
- var _super = _createSuper(BuiltinHelper);
5069
-
5070
5029
  function BuiltinHelper(parent) {
5071
5030
  var _this;
5072
-
5073
5031
  _classCallCheck(this, BuiltinHelper);
5032
+ _this = _callSuper(this, BuiltinHelper, [parent]);
5074
5033
 
5075
- _this = _super.call(this, parent);
5076
5034
  /**
5077
5035
  * In-memory storage for all built-in assets.
5078
5036
  * @type {Object.<AssetType, AssetIdMap>} Maps asset type to a map of asset ID to actual assets.
5079
5037
  * @typedef {Object.<string, BuiltinAssetRecord>} AssetIdMap - Maps asset ID to asset.
5080
5038
  */
5081
-
5082
5039
  _this.assets = {};
5083
5040
  BuiltinAssets.forEach(function (assetRecord) {
5084
5041
  assetRecord.id = _this._store(assetRecord.type, assetRecord.format, assetRecord.data, assetRecord.id);
5085
5042
  });
5086
5043
  return _this;
5087
5044
  }
5045
+
5088
5046
  /**
5089
5047
  * Call `setDefaultAssetId` on the parent `ScratchStorage` instance to register all built-in default assets.
5090
5048
  */
5091
-
5092
-
5093
5049
  _createClass(BuiltinHelper, [{
5094
5050
  key: "registerDefaultAssets",
5095
5051
  value: function registerDefaultAssets() {
5096
5052
  var numAssets = DefaultAssets.length;
5097
-
5098
5053
  for (var assetIndex = 0; assetIndex < numAssets; ++assetIndex) {
5099
5054
  var assetRecord = DefaultAssets[assetIndex];
5100
5055
  this.parent.setDefaultAssetId(assetRecord.type, assetRecord.id);
5101
5056
  }
5102
5057
  }
5058
+
5103
5059
  /**
5104
5060
  * Synchronously fetch a cached asset for a given asset id. Returns null if not found.
5105
5061
  * @param {string} assetId - The id for the asset to fetch.
5106
5062
  * @returns {?Asset} The asset for assetId, if it exists.
5107
5063
  */
5108
-
5109
5064
  }, {
5110
5065
  key: "get",
5111
5066
  value: function get(assetId) {
5112
5067
  var asset = null;
5113
-
5114
5068
  if (Object.prototype.hasOwnProperty.call(this.assets, assetId)) {
5115
5069
  /** @type{BuiltinAssetRecord} */
5116
5070
  var assetRecord = this.assets[assetId];
5117
5071
  asset = new Asset(assetRecord.type, assetRecord.id, assetRecord.format, assetRecord.data);
5118
5072
  }
5119
-
5120
5073
  return asset;
5121
5074
  }
5075
+
5122
5076
  /**
5123
5077
  * Alias for store (old name of store)
5124
5078
  * @deprecated Use BuiltinHelper.store
@@ -5128,13 +5082,13 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5128
5082
  * @param {string} id - The id for the cached asset.
5129
5083
  * @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
5130
5084
  */
5131
-
5132
5085
  }, {
5133
5086
  key: "cache",
5134
5087
  value: function cache(assetType, dataFormat, data, id) {
5135
5088
  log.warn('Deprecation: BuiltinHelper.cache has been replaced with BuiltinHelper.store.');
5136
5089
  return this.store(assetType, dataFormat, data, id);
5137
5090
  }
5091
+
5138
5092
  /**
5139
5093
  * Deprecated external API for _store
5140
5094
  * @deprecated Not for external use. Create assets and keep track of them outside of the storage instance.
@@ -5144,13 +5098,13 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5144
5098
  * @param {(string|number)} id - The id for the cached asset.
5145
5099
  * @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
5146
5100
  */
5147
-
5148
5101
  }, {
5149
5102
  key: "store",
5150
5103
  value: function store(assetType, dataFormat, data, id) {
5151
5104
  log.warn('Deprecation: use Storage.createAsset. BuiltinHelper is for internal use only.');
5152
5105
  return this._store(assetType, dataFormat, data, id);
5153
5106
  }
5107
+
5154
5108
  /**
5155
5109
  * Cache an asset for future lookups by ID.
5156
5110
  * @param {AssetType} assetType - The type of the asset to cache.
@@ -5159,12 +5113,10 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5159
5113
  * @param {(string|number)} id - The id for the cached asset.
5160
5114
  * @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
5161
5115
  */
5162
-
5163
5116
  }, {
5164
5117
  key: "_store",
5165
5118
  value: function _store(assetType, dataFormat, data, id) {
5166
5119
  if (!dataFormat) throw new Error('Data cached without specifying its format');
5167
-
5168
5120
  if (id !== '' && id !== null && typeof id !== 'undefined') {
5169
5121
  if (Object.prototype.hasOwnProperty.call(this.assets, id) && assetType.immutable) return id;
5170
5122
  } else if (assetType.immutable) {
@@ -5172,7 +5124,6 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5172
5124
  } else {
5173
5125
  throw new Error('Tried to cache data without an id');
5174
5126
  }
5175
-
5176
5127
  this.assets[id] = {
5177
5128
  type: assetType,
5178
5129
  format: dataFormat,
@@ -5181,13 +5132,13 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5181
5132
  };
5182
5133
  return id;
5183
5134
  }
5135
+
5184
5136
  /**
5185
5137
  * Fetch an asset but don't process dependencies.
5186
5138
  * @param {AssetType} assetType - The type of asset to fetch.
5187
5139
  * @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
5188
5140
  * @return {?Promise.<Asset>} A promise for the contents of the asset.
5189
5141
  */
5190
-
5191
5142
  }, {
5192
5143
  key: "load",
5193
5144
  value: function load(assetType, assetId) {
@@ -5196,14 +5147,11 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
5196
5147
  // next helper.
5197
5148
  return null;
5198
5149
  }
5199
-
5200
5150
  return Promise.resolve(this.get(assetId));
5201
5151
  }
5202
5152
  }]);
5203
-
5204
5153
  return BuiltinHelper;
5205
5154
  }(Helper);
5206
-
5207
5155
  module.exports = BuiltinHelper;
5208
5156
  /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
5209
5157
 
@@ -5242,16 +5190,13 @@ module.exports = DataFormat;
5242
5190
  /***/ (function(module, exports, __webpack_require__) {
5243
5191
 
5244
5192
  var _objectWithoutProperties = __webpack_require__(/*! @babel/runtime/helpers/objectWithoutProperties */ "./node_modules/@babel/runtime/helpers/objectWithoutProperties.js");
5245
-
5246
5193
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5247
-
5248
5194
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5249
-
5250
5195
  var _excluded = ["url"],
5251
- _excluded2 = ["url", "withCredentials"];
5252
-
5196
+ _excluded2 = ["url", "withCredentials"];
5253
5197
  var _require = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js"),
5254
- scratchFetch = _require.scratchFetch;
5198
+ scratchFetch = _require.scratchFetch;
5199
+
5255
5200
  /**
5256
5201
  * @typedef {Request & {withCredentials: boolean}} ScratchSendRequest
5257
5202
  */
@@ -5259,15 +5204,12 @@ var _require = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js"
5259
5204
  /**
5260
5205
  * Get and send assets with the fetch standard web api.
5261
5206
  */
5262
-
5263
-
5264
5207
  var FetchTool = /*#__PURE__*/function () {
5265
5208
  "use strict";
5266
5209
 
5267
5210
  function FetchTool() {
5268
5211
  _classCallCheck(this, FetchTool);
5269
5212
  }
5270
-
5271
5213
  _createClass(FetchTool, [{
5272
5214
  key: "isGetSupported",
5273
5215
  get:
@@ -5279,18 +5221,17 @@ var FetchTool = /*#__PURE__*/function () {
5279
5221
  function get() {
5280
5222
  return true;
5281
5223
  }
5224
+
5282
5225
  /**
5283
5226
  * Request data from a server with fetch.
5284
5227
  * @param {Request} reqConfig - Request configuration for data to get.
5285
5228
  * @returns {Promise.<Uint8Array?>} Resolve to Buffer of data from server.
5286
5229
  */
5287
-
5288
5230
  }, {
5289
5231
  key: "get",
5290
5232
  value: function get(_ref) {
5291
5233
  var url = _ref.url,
5292
- options = _objectWithoutProperties(_ref, _excluded);
5293
-
5234
+ options = _objectWithoutProperties(_ref, _excluded);
5294
5235
  return scratchFetch(url, Object.assign({
5295
5236
  method: 'GET'
5296
5237
  }, options)).then(function (result) {
@@ -5301,31 +5242,30 @@ var FetchTool = /*#__PURE__*/function () {
5301
5242
  return Promise.reject(result.status); // TODO: we should throw a proper error
5302
5243
  });
5303
5244
  }
5245
+
5304
5246
  /**
5305
5247
  * Is sending supported?
5306
5248
  * Always true for `FetchTool` because `scratchFetch` ponyfills `fetch` if necessary.
5307
5249
  * @returns {boolean} Is sending supported?
5308
5250
  */
5309
-
5310
5251
  }, {
5311
5252
  key: "isSendSupported",
5312
5253
  get: function get() {
5313
5254
  return true;
5314
5255
  }
5256
+
5315
5257
  /**
5316
5258
  * Send data to a server with fetch.
5317
5259
  * @param {ScratchSendRequest} reqConfig - Request configuration for data to send.
5318
5260
  * @returns {Promise.<string>} Server returned metadata.
5319
5261
  */
5320
-
5321
5262
  }, {
5322
5263
  key: "send",
5323
5264
  value: function send(_ref2) {
5324
5265
  var url = _ref2.url,
5325
- _ref2$withCredentials = _ref2.withCredentials,
5326
- withCredentials = _ref2$withCredentials === void 0 ? false : _ref2$withCredentials,
5327
- options = _objectWithoutProperties(_ref2, _excluded2);
5328
-
5266
+ _ref2$withCredentials = _ref2.withCredentials,
5267
+ withCredentials = _ref2$withCredentials === void 0 ? false : _ref2$withCredentials,
5268
+ options = _objectWithoutProperties(_ref2, _excluded2);
5329
5269
  return scratchFetch(url, Object.assign({
5330
5270
  credentials: withCredentials ? 'include' : 'omit'
5331
5271
  }, options)).then(function (response) {
@@ -5334,10 +5274,8 @@ var FetchTool = /*#__PURE__*/function () {
5334
5274
  });
5335
5275
  }
5336
5276
  }]);
5337
-
5338
5277
  return FetchTool;
5339
5278
  }();
5340
-
5341
5279
  module.exports = FetchTool;
5342
5280
 
5343
5281
  /***/ }),
@@ -5350,35 +5288,25 @@ module.exports = FetchTool;
5350
5288
  /***/ (function(module, exports, __webpack_require__) {
5351
5289
 
5352
5290
  var _objectWithoutProperties = __webpack_require__(/*! @babel/runtime/helpers/objectWithoutProperties */ "./node_modules/@babel/runtime/helpers/objectWithoutProperties.js");
5353
-
5354
5291
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5355
-
5356
5292
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5357
-
5358
5293
  var _excluded = ["url"];
5359
-
5360
5294
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5361
-
5362
5295
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5363
-
5364
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5365
-
5296
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5366
5297
  var _require = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js"),
5367
- Headers = _require.Headers,
5368
- applyMetadata = _require.applyMetadata;
5298
+ Headers = _require.Headers,
5299
+ applyMetadata = _require.applyMetadata;
5300
+
5369
5301
  /**
5370
5302
  * Get and send assets with a worker that uses fetch.
5371
5303
  */
5372
-
5373
-
5374
5304
  var PrivateFetchWorkerTool = /*#__PURE__*/function () {
5375
5305
  "use strict";
5376
5306
 
5377
5307
  function PrivateFetchWorkerTool() {
5378
5308
  var _this = this;
5379
-
5380
5309
  _classCallCheck(this, PrivateFetchWorkerTool);
5381
-
5382
5310
  /**
5383
5311
  * What does the worker support of the APIs we need?
5384
5312
  * @type {{fetch:boolean}}
@@ -5386,53 +5314,46 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
5386
5314
  this._workerSupport = {
5387
5315
  fetch: typeof fetch !== 'undefined'
5388
5316
  };
5317
+
5389
5318
  /**
5390
5319
  * A possible error occurred standing up the worker.
5391
5320
  * @type {Error?}
5392
5321
  */
5393
-
5394
5322
  this._supportError = null;
5323
+
5395
5324
  /**
5396
5325
  * The worker that runs fetch and returns data for us.
5397
5326
  * @type {Worker?}
5398
5327
  */
5399
-
5400
5328
  this.worker = null;
5329
+
5401
5330
  /**
5402
5331
  * A map of ids to fetch job objects.
5403
5332
  * @type {object}
5404
5333
  */
5405
-
5406
5334
  this.jobs = {};
5407
-
5408
5335
  try {
5409
5336
  if (this.isGetSupported) {
5410
5337
  // eslint-disable-next-line global-require
5411
5338
  var FetchWorker = __webpack_require__(/*! worker-loader?{"inline":true,"fallback":true}!./FetchWorkerTool.worker */ "./node_modules/worker-loader/dist/cjs.js?{\"inline\":true,\"fallback\":true}!./src/FetchWorkerTool.worker.js");
5412
-
5413
5339
  var worker = new FetchWorker();
5414
5340
  worker.addEventListener('message', function (_ref) {
5415
5341
  var data = _ref.data;
5416
-
5417
5342
  if (data.support) {
5418
5343
  _this._workerSupport = data.support;
5419
5344
  return;
5420
5345
  }
5421
-
5422
5346
  var _iterator = _createForOfIteratorHelper(data),
5423
- _step;
5424
-
5347
+ _step;
5425
5348
  try {
5426
5349
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
5427
5350
  var message = _step.value;
5428
-
5429
5351
  if (_this.jobs[message.id]) {
5430
5352
  if (message.error) {
5431
5353
  _this.jobs[message.id].reject(message.error);
5432
5354
  } else {
5433
5355
  _this.jobs[message.id].resolve(message.buffer);
5434
5356
  }
5435
-
5436
5357
  delete _this.jobs[message.id];
5437
5358
  }
5438
5359
  }
@@ -5448,6 +5369,7 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
5448
5369
  this._supportError = error;
5449
5370
  }
5450
5371
  }
5372
+
5451
5373
  /**
5452
5374
  * Is get supported?
5453
5375
  *
@@ -5456,109 +5378,97 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
5456
5378
  * guess that it does if the window does until the worker can inform us.
5457
5379
  * @returns {boolean} Is get supported?
5458
5380
  */
5459
-
5460
-
5461
5381
  _createClass(PrivateFetchWorkerTool, [{
5462
5382
  key: "isGetSupported",
5463
5383
  get: function get() {
5464
5384
  return typeof Worker !== 'undefined' && this._workerSupport.fetch && !this._supportError;
5465
5385
  }
5386
+
5466
5387
  /**
5467
5388
  * Request data from a server with a worker using fetch.
5468
5389
  * @param {{url:string}} reqConfig - Request configuration for data to get.
5469
5390
  * @param {{method:string}} options - Additional options to configure fetch.
5470
5391
  * @returns {Promise.<Buffer|Uint8Array|null>} Resolve to Buffer of data from server.
5471
5392
  */
5472
-
5473
5393
  }, {
5474
5394
  key: "get",
5475
5395
  value: function get(_ref2) {
5476
5396
  var _this2 = this;
5477
-
5478
5397
  var url = _ref2.url,
5479
- options = _objectWithoutProperties(_ref2, _excluded);
5480
-
5398
+ options = _objectWithoutProperties(_ref2, _excluded);
5481
5399
  return new Promise(function (resolve, reject) {
5482
5400
  // TODO: Use a Scratch standard ID generator ...
5483
5401
  var id = Math.random().toString(16).substring(2);
5484
5402
  var augmentedOptions = applyMetadata(Object.assign({
5485
5403
  method: 'GET'
5486
- }, options)); // the Fetch spec says options.headers could be:
5404
+ }, options));
5405
+ // the Fetch spec says options.headers could be:
5487
5406
  // "A Headers object, an object literal, or an array of two-item arrays to set request's headers."
5488
5407
  // structured clone (postMessage) doesn't support Headers objects
5489
5408
  // so turn it into an array of two-item arrays to make it to the worker intact
5490
-
5491
5409
  if (augmentedOptions && augmentedOptions.headers instanceof Headers) {
5492
5410
  augmentedOptions.headers = Array.from(augmentedOptions.headers.entries());
5493
5411
  }
5494
-
5495
5412
  _this2.worker.postMessage({
5496
5413
  id: id,
5497
5414
  url: url,
5498
5415
  options: augmentedOptions
5499
5416
  });
5500
-
5501
5417
  _this2.jobs[id] = {
5502
5418
  id: id,
5503
5419
  resolve: resolve,
5504
5420
  reject: reject
5505
5421
  };
5506
5422
  })
5507
- /* eslint no-confusing-arrow: ["error", {"allowParens": true}] */
5508
- .then(function (body) {
5423
+ /* eslint no-confusing-arrow: ["error", {"allowParens": true}] */.then(function (body) {
5509
5424
  return body ? new Uint8Array(body) : null;
5510
5425
  });
5511
5426
  }
5427
+
5512
5428
  /**
5513
5429
  * Is sending supported? always false for FetchWorkerTool.
5514
5430
  * @returns {boolean} Is sending supported?
5515
5431
  */
5516
-
5517
5432
  }, {
5518
5433
  key: "isSendSupported",
5519
5434
  get: function get() {
5520
5435
  return false;
5521
5436
  }
5437
+
5522
5438
  /**
5523
5439
  * Send data to a server.
5524
5440
  * @throws {Error} A not implemented error.
5525
5441
  */
5526
-
5527
5442
  }, {
5528
5443
  key: "send",
5529
5444
  value: function send() {
5530
5445
  throw new Error('Not implemented.');
5531
5446
  }
5447
+
5532
5448
  /**
5533
5449
  * Return a static PrivateFetchWorkerTool instance on demand.
5534
5450
  * @returns {PrivateFetchWorkerTool} A static PrivateFetchWorkerTool
5535
5451
  * instance
5536
5452
  */
5537
-
5538
5453
  }], [{
5539
5454
  key: "instance",
5540
5455
  get: function get() {
5541
5456
  if (!this._instance) {
5542
5457
  this._instance = new PrivateFetchWorkerTool();
5543
5458
  }
5544
-
5545
5459
  return this._instance;
5546
5460
  }
5547
5461
  }]);
5548
-
5549
5462
  return PrivateFetchWorkerTool;
5550
5463
  }();
5551
5464
  /**
5552
5465
  * Get and send assets with a worker that uses fetch.
5553
5466
  */
5554
-
5555
-
5556
5467
  var PublicFetchWorkerTool = /*#__PURE__*/function () {
5557
5468
  "use strict";
5558
5469
 
5559
5470
  function PublicFetchWorkerTool() {
5560
5471
  _classCallCheck(this, PublicFetchWorkerTool);
5561
-
5562
5472
  /**
5563
5473
  * Shared instance of an internal worker. PublicFetchWorkerTool proxies
5564
5474
  * it.
@@ -5566,53 +5476,50 @@ var PublicFetchWorkerTool = /*#__PURE__*/function () {
5566
5476
  */
5567
5477
  this.inner = PrivateFetchWorkerTool.instance;
5568
5478
  }
5479
+
5569
5480
  /**
5570
5481
  * Is get supported?
5571
5482
  * @returns {boolean} Is get supported?
5572
5483
  */
5573
-
5574
-
5575
5484
  _createClass(PublicFetchWorkerTool, [{
5576
5485
  key: "isGetSupported",
5577
5486
  get: function get() {
5578
5487
  return this.inner.isGetSupported;
5579
5488
  }
5489
+
5580
5490
  /**
5581
5491
  * Request data from a server with a worker that uses fetch.
5582
5492
  * @param {{url:string}} reqConfig - Request configuration for data to get.
5583
5493
  * @returns {Promise.<Buffer|Uint8Array|null>} Resolve to Buffer of data from server.
5584
5494
  */
5585
-
5586
5495
  }, {
5587
5496
  key: "get",
5588
5497
  value: function get(reqConfig) {
5589
5498
  return this.inner.get(reqConfig);
5590
5499
  }
5500
+
5591
5501
  /**
5592
5502
  * Is sending supported?
5593
5503
  * @returns {boolean} Is sending supported?
5594
5504
  */
5595
-
5596
5505
  }, {
5597
5506
  key: "isSendSupported",
5598
5507
  get: function get() {
5599
5508
  return false;
5600
5509
  }
5510
+
5601
5511
  /**
5602
5512
  * Send data to a server with a worker that uses fetch.
5603
5513
  * @throws {Error} A not implemented error.
5604
5514
  */
5605
-
5606
5515
  }, {
5607
5516
  key: "send",
5608
5517
  value: function send() {
5609
5518
  throw new Error('Not implemented.');
5610
5519
  }
5611
5520
  }]);
5612
-
5613
5521
  return PublicFetchWorkerTool;
5614
5522
  }();
5615
-
5616
5523
  module.exports = PublicFetchWorkerTool;
5617
5524
 
5618
5525
  /***/ }),
@@ -5625,9 +5532,7 @@ module.exports = PublicFetchWorkerTool;
5625
5532
  /***/ (function(module, exports, __webpack_require__) {
5626
5533
 
5627
5534
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5628
-
5629
5535
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5630
-
5631
5536
  /**
5632
5537
  * Base class for asset load/save helpers.
5633
5538
  * @abstract
@@ -5637,9 +5542,9 @@ var Helper = /*#__PURE__*/function () {
5637
5542
 
5638
5543
  function Helper(parent) {
5639
5544
  _classCallCheck(this, Helper);
5640
-
5641
5545
  this.parent = parent;
5642
5546
  }
5547
+
5643
5548
  /**
5644
5549
  * Fetch an asset but don't process dependencies.
5645
5550
  * @param {AssetType} assetType - The type of asset to fetch.
@@ -5647,18 +5552,14 @@ var Helper = /*#__PURE__*/function () {
5647
5552
  * @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
5648
5553
  * @return {Promise.<Asset>} A promise for the contents of the asset.
5649
5554
  */
5650
-
5651
-
5652
5555
  _createClass(Helper, [{
5653
5556
  key: "load",
5654
5557
  value: function load(assetType, assetId, dataFormat) {
5655
5558
  return Promise.reject(new Error("No asset of type ".concat(assetType, " for ID ").concat(assetId, " with format ").concat(dataFormat)));
5656
5559
  }
5657
5560
  }]);
5658
-
5659
5561
  return Helper;
5660
5562
  }();
5661
-
5662
5563
  module.exports = Helper;
5663
5564
 
5664
5565
  /***/ }),
@@ -5671,12 +5572,10 @@ module.exports = Helper;
5671
5572
  /***/ (function(module, exports, __webpack_require__) {
5672
5573
 
5673
5574
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5674
-
5675
5575
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5676
-
5677
5576
  var FetchWorkerTool = __webpack_require__(/*! ./FetchWorkerTool */ "./src/FetchWorkerTool.js");
5678
-
5679
5577
  var FetchTool = __webpack_require__(/*! ./FetchTool */ "./src/FetchTool.js");
5578
+
5680
5579
  /**
5681
5580
  * @typedef {object} Request
5682
5581
  * @property {string} url
@@ -5688,37 +5587,30 @@ var FetchTool = __webpack_require__(/*! ./FetchTool */ "./src/FetchTool.js");
5688
5587
  /**
5689
5588
  * Get and send assets with other tools in sequence.
5690
5589
  */
5691
-
5692
-
5693
5590
  var ProxyTool = /*#__PURE__*/function () {
5694
5591
  "use strict";
5695
5592
 
5696
5593
  function ProxyTool() {
5697
5594
  var filter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ProxyTool.TOOL_FILTER.ALL;
5698
-
5699
5595
  _classCallCheck(this, ProxyTool);
5700
-
5701
5596
  var tools;
5702
-
5703
5597
  if (filter === ProxyTool.TOOL_FILTER.READY) {
5704
5598
  tools = [new FetchTool()];
5705
5599
  } else {
5706
5600
  tools = [new FetchWorkerTool(), new FetchTool()];
5707
5601
  }
5602
+
5708
5603
  /**
5709
5604
  * Sequence of tools to proxy.
5710
5605
  * @type {Array.<Tool>}
5711
5606
  */
5712
-
5713
-
5714
5607
  this.tools = tools;
5715
5608
  }
5609
+
5716
5610
  /**
5717
5611
  * Is get supported? false if all proxied tool return false.
5718
5612
  * @returns {boolean} Is get supported?
5719
5613
  */
5720
-
5721
-
5722
5614
  _createClass(ProxyTool, [{
5723
5615
  key: "isGetSupported",
5724
5616
  get: function get() {
@@ -5726,40 +5618,34 @@ var ProxyTool = /*#__PURE__*/function () {
5726
5618
  return tool.isGetSupported;
5727
5619
  });
5728
5620
  }
5621
+
5729
5622
  /**
5730
5623
  * Request data from with one of the proxied tools.
5731
5624
  * @param {Request} reqConfig - Request configuration for data to get.
5732
5625
  * @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
5733
5626
  */
5734
-
5735
5627
  }, {
5736
5628
  key: "get",
5737
5629
  value: function get(reqConfig) {
5738
5630
  var _this = this;
5739
-
5740
5631
  var toolIndex = 0;
5741
-
5742
5632
  var nextTool = function nextTool(err) {
5743
5633
  var tool = _this.tools[toolIndex++];
5744
-
5745
5634
  if (!tool) {
5746
5635
  throw err;
5747
5636
  }
5748
-
5749
5637
  if (!tool.isGetSupported) {
5750
5638
  return nextTool(err);
5751
5639
  }
5752
-
5753
5640
  return tool.get(reqConfig).catch(nextTool);
5754
5641
  };
5755
-
5756
5642
  return nextTool();
5757
5643
  }
5644
+
5758
5645
  /**
5759
5646
  * Is sending supported? false if all proxied tool return false.
5760
5647
  * @returns {boolean} Is sending supported?
5761
5648
  */
5762
-
5763
5649
  }, {
5764
5650
  key: "isSendSupported",
5765
5651
  get: function get() {
@@ -5767,51 +5653,41 @@ var ProxyTool = /*#__PURE__*/function () {
5767
5653
  return tool.isSendSupported;
5768
5654
  });
5769
5655
  }
5656
+
5770
5657
  /**
5771
5658
  * Send data to a server with one of the proxied tools.
5772
5659
  * @param {Request} reqConfig - Request configuration for data to send.
5773
5660
  * @returns {Promise.<Buffer|string|object>} Server returned metadata.
5774
5661
  */
5775
-
5776
5662
  }, {
5777
5663
  key: "send",
5778
5664
  value: function send(reqConfig) {
5779
5665
  var _this2 = this;
5780
-
5781
5666
  var toolIndex = 0;
5782
-
5783
5667
  var nextTool = function nextTool(err) {
5784
5668
  var tool = _this2.tools[toolIndex++];
5785
-
5786
5669
  if (!tool) {
5787
5670
  throw err;
5788
5671
  }
5789
-
5790
5672
  if (!tool.isSendSupported) {
5791
5673
  return nextTool(err);
5792
5674
  }
5793
-
5794
5675
  return tool.send(reqConfig).catch(nextTool);
5795
5676
  };
5796
-
5797
5677
  return nextTool();
5798
5678
  }
5799
5679
  }]);
5800
-
5801
5680
  return ProxyTool;
5802
5681
  }();
5803
5682
  /**
5804
5683
  * Constant values that filter the set of tools in a ProxyTool instance.
5805
5684
  * @enum {string}
5806
5685
  */
5807
-
5808
-
5809
5686
  ProxyTool.TOOL_FILTER = {
5810
5687
  /**
5811
5688
  * Use all tools.
5812
5689
  */
5813
5690
  ALL: 'all',
5814
-
5815
5691
  /**
5816
5692
  * Use tools that are ready right now.
5817
5693
  */
@@ -5829,29 +5705,19 @@ module.exports = ProxyTool;
5829
5705
  /***/ (function(module, exports, __webpack_require__) {
5830
5706
 
5831
5707
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
5832
-
5833
5708
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
5834
-
5835
5709
  var log = __webpack_require__(/*! ./log */ "./src/log.js");
5836
-
5837
5710
  var BuiltinHelper = __webpack_require__(/*! ./BuiltinHelper */ "./src/BuiltinHelper.js");
5838
-
5839
5711
  var WebHelper = __webpack_require__(/*! ./WebHelper */ "./src/WebHelper.js");
5840
-
5841
5712
  var _Asset = __webpack_require__(/*! ./Asset */ "./src/Asset.js");
5842
-
5843
5713
  var _AssetType = __webpack_require__(/*! ./AssetType */ "./src/AssetType.js");
5844
-
5845
5714
  var _DataFormat = __webpack_require__(/*! ./DataFormat */ "./src/DataFormat.js");
5846
-
5847
5715
  var _scratchFetch = __webpack_require__(/*! ./scratchFetch */ "./src/scratchFetch.js");
5848
-
5849
5716
  var ScratchStorage = /*#__PURE__*/function () {
5850
5717
  "use strict";
5851
5718
 
5852
5719
  function ScratchStorage() {
5853
5720
  _classCallCheck(this, ScratchStorage);
5854
-
5855
5721
  this.defaultAssetId = {};
5856
5722
  this.builtinHelper = new BuiltinHelper(this);
5857
5723
  this.webHelper = new WebHelper(this);
@@ -5864,53 +5730,52 @@ var ScratchStorage = /*#__PURE__*/function () {
5864
5730
  priority: -100
5865
5731
  }];
5866
5732
  }
5733
+
5867
5734
  /**
5868
5735
  * @return {Asset} - the `Asset` class constructor.
5869
5736
  * @constructor
5870
5737
  */
5871
-
5872
-
5873
5738
  _createClass(ScratchStorage, [{
5874
5739
  key: "Asset",
5875
5740
  get: function get() {
5876
5741
  return _Asset;
5877
5742
  }
5743
+
5878
5744
  /**
5879
5745
  * @return {AssetType} - the list of supported asset types.
5880
5746
  * @constructor
5881
5747
  */
5882
-
5883
5748
  }, {
5884
5749
  key: "AssetType",
5885
5750
  get: function get() {
5886
5751
  return _AssetType;
5887
5752
  }
5753
+
5888
5754
  /**
5889
5755
  * @return {DataFormat} - the list of supported data formats.
5890
5756
  * @constructor
5891
5757
  */
5892
-
5893
5758
  }, {
5894
5759
  key: "DataFormat",
5895
5760
  get: function get() {
5896
5761
  return _DataFormat;
5897
5762
  }
5763
+
5898
5764
  /**
5899
5765
  * Access the `scratchFetch` module within this library.
5900
5766
  * @return {module} the scratchFetch module, with properties for `scratchFetch`, `setMetadata`, etc.
5901
5767
  */
5902
-
5903
5768
  }, {
5904
5769
  key: "scratchFetch",
5905
5770
  get: function get() {
5906
5771
  return _scratchFetch;
5907
5772
  }
5773
+
5908
5774
  /**
5909
5775
  * @deprecated Please use the `Asset` member of a storage instance instead.
5910
5776
  * @return {Asset} - the `Asset` class constructor.
5911
5777
  * @constructor
5912
5778
  */
5913
-
5914
5779
  }, {
5915
5780
  key: "addHelper",
5916
5781
  value:
@@ -5923,27 +5788,26 @@ var ScratchStorage = /*#__PURE__*/function () {
5923
5788
  */
5924
5789
  function addHelper(helper) {
5925
5790
  var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
5926
-
5927
5791
  this._helpers.push({
5928
5792
  helper: helper,
5929
5793
  priority: priority
5930
5794
  });
5931
-
5932
5795
  this._helpers.sort(function (a, b) {
5933
5796
  return b.priority - a.priority;
5934
5797
  });
5935
5798
  }
5799
+
5936
5800
  /**
5937
5801
  * Synchronously fetch a cached asset from built-in storage. Assets are cached when they are loaded.
5938
5802
  * @param {string} assetId - The id of the asset to fetch.
5939
5803
  * @returns {?Asset} The asset, if it exists.
5940
5804
  */
5941
-
5942
5805
  }, {
5943
5806
  key: "get",
5944
5807
  value: function get(assetId) {
5945
5808
  return this.builtinHelper.get(assetId);
5946
5809
  }
5810
+
5947
5811
  /**
5948
5812
  * Deprecated API for caching built-in assets. Use createAsset.
5949
5813
  * @param {AssetType} assetType - The type of the asset to cache.
@@ -5952,13 +5816,13 @@ var ScratchStorage = /*#__PURE__*/function () {
5952
5816
  * @param {string} id - The id for the cached asset.
5953
5817
  * @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
5954
5818
  */
5955
-
5956
5819
  }, {
5957
5820
  key: "cache",
5958
5821
  value: function cache(assetType, dataFormat, data, id) {
5959
5822
  log.warn('Deprecation: Storage.cache is deprecated. Use Storage.createAsset, and store assets externally.');
5960
5823
  return this.builtinHelper._store(assetType, dataFormat, data, id);
5961
5824
  }
5825
+
5962
5826
  /**
5963
5827
  * Construct an Asset, and optionally generate an md5 hash of its data to create an id
5964
5828
  * @param {AssetType} assetType - The type of the asset to cache.
@@ -5968,13 +5832,13 @@ var ScratchStorage = /*#__PURE__*/function () {
5968
5832
  * @param {bool} [generateId] - flag to set id to an md5 hash of data if `id` isn't supplied
5969
5833
  * @returns {Asset} generated Asset with `id` attribute set if not supplied
5970
5834
  */
5971
-
5972
5835
  }, {
5973
5836
  key: "createAsset",
5974
5837
  value: function createAsset(assetType, dataFormat, data, id, generateId) {
5975
5838
  if (!dataFormat) throw new Error('Tried to create asset without a dataFormat');
5976
5839
  return new _Asset(assetType, id, dataFormat, data, generateId);
5977
5840
  }
5841
+
5978
5842
  /**
5979
5843
  * Register a web-based source for assets. Sources will be checked in order of registration.
5980
5844
  * @param {Array.<AssetType>} types - The types of asset provided by this source.
@@ -5982,31 +5846,30 @@ var ScratchStorage = /*#__PURE__*/function () {
5982
5846
  * @param {UrlFunction} createFunction - A function which computes a POST URL for asset data.
5983
5847
  * @param {UrlFunction} updateFunction - A function which computes a PUT URL for asset data.
5984
5848
  */
5985
-
5986
5849
  }, {
5987
5850
  key: "addWebStore",
5988
5851
  value: function addWebStore(types, getFunction, createFunction, updateFunction) {
5989
5852
  this.webHelper.addStore(types, getFunction, createFunction, updateFunction);
5990
5853
  }
5854
+
5991
5855
  /**
5992
5856
  * Register a web-based source for assets. Sources will be checked in order of registration.
5993
5857
  * @deprecated Please use addWebStore
5994
5858
  * @param {Array.<AssetType>} types - The types of asset provided by this source.
5995
5859
  * @param {UrlFunction} urlFunction - A function which computes a GET URL from an Asset.
5996
5860
  */
5997
-
5998
5861
  }, {
5999
5862
  key: "addWebSource",
6000
5863
  value: function addWebSource(types, urlFunction) {
6001
5864
  log.warn('Deprecation: Storage.addWebSource has been replaced by addWebStore.');
6002
5865
  this.addWebStore(types, urlFunction);
6003
5866
  }
5867
+
6004
5868
  /**
6005
5869
  * TODO: Should this be removed in favor of requesting an asset with `null` as the ID?
6006
5870
  * @param {AssetType} type - Get the default ID for assets of this type.
6007
5871
  * @return {?string} The ID of the default asset of the given type, if any.
6008
5872
  */
6009
-
6010
5873
  }, {
6011
5874
  key: "getDefaultAssetId",
6012
5875
  value: function getDefaultAssetId(type) {
@@ -6014,6 +5877,7 @@ var ScratchStorage = /*#__PURE__*/function () {
6014
5877
  return this.defaultAssetId[type.name];
6015
5878
  }
6016
5879
  }
5880
+
6017
5881
  /**
6018
5882
  * Set the default ID for a particular type of asset. This default asset will be used if a requested asset cannot
6019
5883
  * be found and automatic fallback is enabled. Ideally this should be an asset that is available locally or even
@@ -6022,12 +5886,12 @@ var ScratchStorage = /*#__PURE__*/function () {
6022
5886
  * @param {AssetType} type - The type of asset for which the default will be set.
6023
5887
  * @param {string} id - The default ID to use for this type of asset.
6024
5888
  */
6025
-
6026
5889
  }, {
6027
5890
  key: "setDefaultAssetId",
6028
5891
  value: function setDefaultAssetId(type, id) {
6029
5892
  this.defaultAssetId[type.name] = id;
6030
5893
  }
5894
+
6031
5895
  /**
6032
5896
  * Fetch an asset by type & ID.
6033
5897
  * @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
@@ -6039,7 +5903,6 @@ var ScratchStorage = /*#__PURE__*/function () {
6039
5903
  * If the promise is rejected, there was an error on at least one asset source. HTTP 404 does not count as an
6040
5904
  * error here, but (for example) HTTP 403 does.
6041
5905
  */
6042
-
6043
5906
  }, {
6044
5907
  key: "load",
6045
5908
  value: function load(assetType, assetId, dataFormat) {
@@ -6047,42 +5910,37 @@ var ScratchStorage = /*#__PURE__*/function () {
6047
5910
  var helpers = this._helpers.map(function (x) {
6048
5911
  return x.helper;
6049
5912
  });
6050
-
6051
5913
  var errors = [];
6052
5914
  dataFormat = dataFormat || assetType.runtimeFormat;
6053
5915
  var helperIndex = 0;
6054
5916
  var helper;
6055
-
6056
5917
  var tryNextHelper = function tryNextHelper(err) {
6057
5918
  if (err) {
6058
5919
  // Track the error, but continue looking
6059
5920
  errors.push(err);
6060
5921
  }
6061
-
6062
5922
  helper = helpers[helperIndex++];
6063
-
6064
5923
  if (helper) {
6065
5924
  var loading = helper.load(assetType, assetId, dataFormat);
6066
-
6067
5925
  if (loading === null) {
6068
5926
  return tryNextHelper();
6069
- } // Note that other attempts may have logged errors; if this succeeds they will be suppressed.
6070
-
6071
-
6072
- return loading // TODO: maybe some types of error should prevent trying the next helper?
5927
+ }
5928
+ // Note that other attempts may have logged errors; if this succeeds they will be suppressed.
5929
+ return loading
5930
+ // TODO: maybe some types of error should prevent trying the next helper?
6073
5931
  .catch(tryNextHelper);
6074
5932
  } else if (errors.length > 0) {
6075
5933
  // We looked through all the helpers and couldn't find the asset, AND
6076
5934
  // at least one thing went wrong while we were looking.
6077
5935
  return Promise.reject(errors);
6078
- } // Nothing went wrong but we couldn't find the asset.
6079
-
5936
+ }
6080
5937
 
5938
+ // Nothing went wrong but we couldn't find the asset.
6081
5939
  return Promise.resolve(null);
6082
5940
  };
6083
-
6084
5941
  return tryNextHelper();
6085
5942
  }
5943
+
6086
5944
  /**
6087
5945
  * Store an asset by type & ID.
6088
5946
  * @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
@@ -6091,17 +5949,14 @@ var ScratchStorage = /*#__PURE__*/function () {
6091
5949
  * @param {?string} [assetId] - The ID of the asset to fetch: a project ID, MD5, etc.
6092
5950
  * @return {Promise.<object>} A promise for asset metadata
6093
5951
  */
6094
-
6095
5952
  }, {
6096
5953
  key: "store",
6097
5954
  value: function store(assetType, dataFormat, data, assetId) {
6098
5955
  var _this = this;
6099
-
6100
5956
  dataFormat = dataFormat || assetType.runtimeFormat;
6101
5957
  return new Promise(function (resolve, reject) {
6102
5958
  return _this.webHelper.store(assetType, dataFormat, data, assetId).then(function (body) {
6103
5959
  _this.builtinHelper._store(assetType, dataFormat, data, body.id);
6104
-
6105
5960
  return resolve(body);
6106
5961
  }).catch(function (error) {
6107
5962
  return reject(error);
@@ -6113,22 +5968,20 @@ var ScratchStorage = /*#__PURE__*/function () {
6113
5968
  get: function get() {
6114
5969
  return _Asset;
6115
5970
  }
5971
+
6116
5972
  /**
6117
5973
  * @deprecated Please use the `AssetType` member of a storage instance instead.
6118
5974
  * @return {AssetType} - the list of supported asset types.
6119
5975
  * @constructor
6120
5976
  */
6121
-
6122
5977
  }, {
6123
5978
  key: "AssetType",
6124
5979
  get: function get() {
6125
5980
  return _AssetType;
6126
5981
  }
6127
5982
  }]);
6128
-
6129
5983
  return ScratchStorage;
6130
5984
  }();
6131
-
6132
5985
  module.exports = ScratchStorage;
6133
5986
 
6134
5987
  /***/ }),
@@ -6141,57 +5994,40 @@ module.exports = ScratchStorage;
6141
5994
  /***/ (function(module, exports, __webpack_require__) {
6142
5995
 
6143
5996
  var _classCallCheck = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
6144
-
6145
5997
  var _createClass = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
6146
-
6147
- var _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js");
6148
-
6149
5998
  var _possibleConstructorReturn = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js");
6150
-
6151
5999
  var _getPrototypeOf = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6152
-
6153
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
6154
-
6155
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
6156
-
6000
+ var _inherits = __webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js");
6001
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
6002
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
6157
6003
  var log = __webpack_require__(/*! ./log */ "./src/log.js");
6158
-
6159
6004
  var Asset = __webpack_require__(/*! ./Asset */ "./src/Asset.js");
6160
-
6161
6005
  var Helper = __webpack_require__(/*! ./Helper */ "./src/Helper.js");
6162
-
6163
6006
  var ProxyTool = __webpack_require__(/*! ./ProxyTool */ "./src/ProxyTool.js");
6164
-
6165
6007
  var ensureRequestConfig = function ensureRequestConfig(reqConfig) {
6166
6008
  if (typeof reqConfig === 'string') {
6167
6009
  return {
6168
6010
  url: reqConfig
6169
6011
  };
6170
6012
  }
6171
-
6172
6013
  return reqConfig;
6173
6014
  };
6015
+
6174
6016
  /**
6175
6017
  * @typedef {function} UrlFunction - A function which computes a URL from asset information.
6176
6018
  * @param {Asset} - The asset for which the URL should be computed.
6177
6019
  * @returns {(string|object)} - A string representing the URL for the asset request OR an object with configuration for
6178
6020
  * the underlying fetch call (necessary for configuring e.g. authentication)
6179
6021
  */
6180
-
6181
-
6182
6022
  var WebHelper = /*#__PURE__*/function (_Helper) {
6183
6023
  "use strict";
6184
6024
 
6185
6025
  _inherits(WebHelper, _Helper);
6186
-
6187
- var _super = _createSuper(WebHelper);
6188
-
6189
6026
  function WebHelper(parent) {
6190
6027
  var _this;
6191
-
6192
6028
  _classCallCheck(this, WebHelper);
6029
+ _this = _callSuper(this, WebHelper, [parent]);
6193
6030
 
6194
- _this = _super.call(this, parent);
6195
6031
  /**
6196
6032
  * @type {Array.<StoreRecord>}
6197
6033
  * @typedef {object} StoreRecord
@@ -6200,39 +6036,38 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6200
6036
  * @property {UrlFunction} createFunction - A function which computes a URL from an Asset.
6201
6037
  * @property {UrlFunction} updateFunction - A function which computes a URL from an Asset.
6202
6038
  */
6203
-
6204
6039
  _this.stores = [];
6040
+
6205
6041
  /**
6206
6042
  * Set of tools to best load many assets in parallel. If one tool
6207
6043
  * cannot be used, it will use the next.
6208
6044
  * @type {ProxyTool}
6209
6045
  */
6210
-
6211
6046
  _this.assetTool = new ProxyTool();
6047
+
6212
6048
  /**
6213
6049
  * Set of tools to best load project data in parallel with assets. This
6214
6050
  * tool set prefers tools that are immediately ready. Some tools have
6215
6051
  * to initialize before they can load files.
6216
6052
  * @type {ProxyTool}
6217
6053
  */
6218
-
6219
6054
  _this.projectTool = new ProxyTool(ProxyTool.TOOL_FILTER.READY);
6220
6055
  return _this;
6221
6056
  }
6057
+
6222
6058
  /**
6223
6059
  * Register a web-based source for assets. Sources will be checked in order of registration.
6224
6060
  * @deprecated Please use addStore
6225
6061
  * @param {Array.<AssetType>} types - The types of asset provided by this source.
6226
6062
  * @param {UrlFunction} urlFunction - A function which computes a URL from an Asset.
6227
6063
  */
6228
-
6229
-
6230
6064
  _createClass(WebHelper, [{
6231
6065
  key: "addSource",
6232
6066
  value: function addSource(types, urlFunction) {
6233
6067
  log.warn('Deprecation: WebHelper.addSource has been replaced with WebHelper.addStore.');
6234
6068
  this.addStore(types, urlFunction);
6235
6069
  }
6070
+
6236
6071
  /**
6237
6072
  * Register a web-based store for assets. Sources will be checked in order of registration.
6238
6073
  * @param {Array.<AssetType>} types - The types of asset provided by this store.
@@ -6240,7 +6075,6 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6240
6075
  * @param {UrlFunction} createFunction - A function which computes a POST URL for an Asset
6241
6076
  * @param {UrlFunction} updateFunction - A function which computes a PUT URL for an Asset
6242
6077
  */
6243
-
6244
6078
  }, {
6245
6079
  key: "addStore",
6246
6080
  value: function addStore(types, getFunction, createFunction, updateFunction) {
@@ -6253,6 +6087,7 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6253
6087
  update: updateFunction
6254
6088
  });
6255
6089
  }
6090
+
6256
6091
  /**
6257
6092
  * Fetch an asset but don't process dependencies.
6258
6093
  * @param {AssetType} assetType - The type of asset to fetch.
@@ -6260,7 +6095,6 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6260
6095
  * @param {DataFormat} dataFormat - The file format / file extension of the asset to fetch: PNG, JPG, etc.
6261
6096
  * @return {Promise.<Asset>} A promise for the contents of the asset.
6262
6097
  */
6263
-
6264
6098
  }, {
6265
6099
  key: "load",
6266
6100
  value: function load(assetType, assetId, dataFormat) {
@@ -6268,52 +6102,45 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6268
6102
  var errors = [];
6269
6103
  var stores = this.stores.slice().filter(function (store) {
6270
6104
  return store.types.indexOf(assetType.name) >= 0;
6271
- }); // New empty asset but it doesn't have data yet
6105
+ });
6272
6106
 
6107
+ // New empty asset but it doesn't have data yet
6273
6108
  var asset = new Asset(assetType, assetId, dataFormat);
6274
6109
  var tool = this.assetTool;
6275
-
6276
6110
  if (assetType.name === 'Project') {
6277
6111
  tool = this.projectTool;
6278
6112
  }
6279
-
6280
6113
  var storeIndex = 0;
6281
-
6282
6114
  var tryNextSource = function tryNextSource(err) {
6283
6115
  if (err) {
6284
6116
  errors.push(err);
6285
6117
  }
6286
-
6287
6118
  var store = stores[storeIndex++];
6288
- /** @type {UrlFunction} */
6289
6119
 
6120
+ /** @type {UrlFunction} */
6290
6121
  var reqConfigFunction = store && store.get;
6291
-
6292
6122
  if (reqConfigFunction) {
6293
6123
  var reqConfig = ensureRequestConfig(reqConfigFunction(asset));
6294
-
6295
6124
  if (reqConfig === false) {
6296
6125
  return tryNextSource();
6297
6126
  }
6298
-
6299
6127
  return tool.get(reqConfig).then(function (body) {
6300
6128
  if (body) {
6301
6129
  asset.setData(body, dataFormat);
6302
6130
  return asset;
6303
6131
  }
6304
-
6305
6132
  return tryNextSource();
6306
6133
  }).catch(tryNextSource);
6307
6134
  } else if (errors.length > 0) {
6308
6135
  return Promise.reject(errors);
6309
- } // no stores matching asset
6310
-
6136
+ }
6311
6137
 
6138
+ // no stores matching asset
6312
6139
  return Promise.resolve(null);
6313
6140
  };
6314
-
6315
6141
  return tryNextSource();
6316
6142
  }
6143
+
6317
6144
  /**
6318
6145
  * Create or update an asset with provided data. The create function is called if no asset id is provided
6319
6146
  * @param {AssetType} assetType - The type of asset to create or update.
@@ -6322,17 +6149,19 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6322
6149
  * @param {?string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
6323
6150
  * @return {Promise.<object>} A promise for the response from the create or update request
6324
6151
  */
6325
-
6326
6152
  }, {
6327
6153
  key: "store",
6328
6154
  value: function store(assetType, dataFormat, data, assetId) {
6329
- var asset = new Asset(assetType, assetId, dataFormat); // If we have an asset id, we should update, otherwise create to get an id
6330
-
6331
- var create = assetId === '' || assetId === null || typeof assetId === 'undefined'; // Use the first store with the appropriate asset type and url function
6155
+ var asset = new Asset(assetType, assetId, dataFormat);
6156
+ // If we have an asset id, we should update, otherwise create to get an id
6157
+ var create = assetId === '' || assetId === null || typeof assetId === 'undefined';
6332
6158
 
6159
+ // Use the first store with the appropriate asset type and url function
6333
6160
  var store = this.stores.filter(function (s) {
6334
- return (// Only use stores for the incoming asset type
6335
- s.types.indexOf(assetType.name) !== -1 && ( // Only use stores that have a create function if this is a create request
6161
+ return (
6162
+ // Only use stores for the incoming asset type
6163
+ s.types.indexOf(assetType.name) !== -1 && (
6164
+ // Only use stores that have a create function if this is a create request
6336
6165
  // or an update function if this is an update request
6337
6166
  create && s.create || s.update)
6338
6167
  );
@@ -6340,11 +6169,9 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6340
6169
  var method = create ? 'post' : 'put';
6341
6170
  if (!store) return Promise.reject(new Error('No appropriate stores'));
6342
6171
  var tool = this.assetTool;
6343
-
6344
6172
  if (assetType.name === 'Project') {
6345
6173
  tool = this.projectTool;
6346
6174
  }
6347
-
6348
6175
  var reqConfig = ensureRequestConfig(create ? store.create(asset) : store.update(asset));
6349
6176
  var reqBodyConfig = Object.assign({
6350
6177
  body: data,
@@ -6363,17 +6190,14 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
6363
6190
  return body;
6364
6191
  }
6365
6192
  }
6366
-
6367
6193
  return Object.assign({
6368
6194
  id: body['content-name'] || assetId
6369
6195
  }, body);
6370
6196
  });
6371
6197
  }
6372
6198
  }]);
6373
-
6374
6199
  return WebHelper;
6375
6200
  }(Helper);
6376
-
6377
6201
  module.exports = WebHelper;
6378
6202
 
6379
6203
  /***/ }),
@@ -6419,12 +6243,11 @@ module.exports = __webpack_require__(/*! ../../node_modules/arraybuffer-loader/l
6419
6243
  /***/ (function(module, exports, __webpack_require__) {
6420
6244
 
6421
6245
  var ScratchStorage = __webpack_require__(/*! ./ScratchStorage */ "./src/ScratchStorage.js");
6246
+
6422
6247
  /**
6423
6248
  * Export for use with NPM & Node.js.
6424
6249
  * @type {ScratchStorage}
6425
6250
  */
6426
-
6427
-
6428
6251
  module.exports = ScratchStorage;
6429
6252
 
6430
6253
  /***/ }),
@@ -6437,7 +6260,6 @@ module.exports = ScratchStorage;
6437
6260
  /***/ (function(module, exports, __webpack_require__) {
6438
6261
 
6439
6262
  var minilog = __webpack_require__(/*! minilog */ "./node_modules/minilog/lib/web/index.js");
6440
-
6441
6263
  minilog.enable();
6442
6264
  module.exports = minilog('storage');
6443
6265
 
@@ -6451,52 +6273,43 @@ module.exports = minilog('storage');
6451
6273
  /***/ (function(module, exports, __webpack_require__) {
6452
6274
 
6453
6275
  var _slicedToArray = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js");
6454
-
6455
6276
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6456
-
6457
6277
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6458
-
6459
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6460
-
6278
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6461
6279
  var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/browser-ponyfill.js");
6280
+
6462
6281
  /**
6463
6282
  * Metadata header names
6464
6283
  * @enum {string} The enum value is the name of the associated header.
6465
6284
  * @readonly
6466
6285
  */
6467
-
6468
-
6469
6286
  var RequestMetadata = {
6470
6287
  /** The ID of the project associated with this request */
6471
6288
  ProjectId: 'X-Project-ID',
6472
-
6473
6289
  /** The ID of the project run associated with this request */
6474
6290
  RunId: 'X-Run-ID'
6475
6291
  };
6292
+
6476
6293
  /**
6477
6294
  * Metadata headers for requests
6478
6295
  * @type {Headers}
6479
6296
  */
6480
-
6481
6297
  var metadata = new crossFetch.Headers();
6298
+
6482
6299
  /**
6483
6300
  * Check if there is any metadata to apply.
6484
6301
  * @returns {boolean} true if `metadata` has contents, or false if it is empty.
6485
6302
  */
6486
-
6487
6303
  var hasMetadata = function hasMetadata() {
6488
6304
  /* global self */
6489
6305
  var searchParams = typeof self !== 'undefined' && self && self.location && self.location.search && self.location.search.split(/[?&]/) || [];
6490
-
6491
6306
  if (!searchParams.includes('scratchMetadata=1')) {
6492
6307
  // for now, disable this feature unless scratchMetadata=1
6493
6308
  // TODO: remove this check once we're sure the feature works correctly in production
6494
6309
  return false;
6495
6310
  }
6496
-
6497
6311
  var _iterator = _createForOfIteratorHelper(metadata),
6498
- _step;
6499
-
6312
+ _step;
6500
6313
  try {
6501
6314
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
6502
6315
  var _ = _step.value;
@@ -6507,9 +6320,9 @@ var hasMetadata = function hasMetadata() {
6507
6320
  } finally {
6508
6321
  _iterator.f();
6509
6322
  }
6510
-
6511
6323
  return false;
6512
6324
  };
6325
+
6513
6326
  /**
6514
6327
  * Non-destructively merge any metadata state (if any) with the provided options object (if any).
6515
6328
  * If there is metadata state but no options object is provided, make a new object.
@@ -6519,28 +6332,22 @@ var hasMetadata = function hasMetadata() {
6519
6332
  * @param {RequestInit} [options] The initial request options. May be null or undefined.
6520
6333
  * @returns {RequestInit|undefined} the provided options parameter without modification, or a new options object.
6521
6334
  */
6522
-
6523
-
6524
6335
  var applyMetadata = function applyMetadata(options) {
6525
6336
  if (hasMetadata()) {
6526
6337
  var augmentedOptions = Object.assign({}, options);
6527
6338
  augmentedOptions.headers = new crossFetch.Headers(metadata);
6528
-
6529
6339
  if (options && options.headers) {
6530
6340
  // the Fetch spec says options.headers could be:
6531
6341
  // "A Headers object, an object literal, or an array of two-item arrays to set request's headers."
6532
6342
  // turn it into a Headers object to be sure of how to interact with it
6533
6343
  var overrideHeaders = options.headers instanceof crossFetch.Headers ? options.headers : new crossFetch.Headers(options.headers);
6534
-
6535
6344
  var _iterator2 = _createForOfIteratorHelper(overrideHeaders.entries()),
6536
- _step2;
6537
-
6345
+ _step2;
6538
6346
  try {
6539
6347
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
6540
6348
  var _step2$value = _slicedToArray(_step2.value, 2),
6541
- name = _step2$value[0],
6542
- value = _step2$value[1];
6543
-
6349
+ name = _step2$value[0],
6350
+ value = _step2$value[1];
6544
6351
  augmentedOptions.headers.set(name, value);
6545
6352
  }
6546
6353
  } catch (err) {
@@ -6549,12 +6356,11 @@ var applyMetadata = function applyMetadata(options) {
6549
6356
  _iterator2.f();
6550
6357
  }
6551
6358
  }
6552
-
6553
6359
  return augmentedOptions;
6554
6360
  }
6555
-
6556
6361
  return options;
6557
6362
  };
6363
+
6558
6364
  /**
6559
6365
  * Make a network request.
6560
6366
  * This is a wrapper for the global fetch method, adding some Scratch-specific functionality.
@@ -6563,12 +6369,11 @@ var applyMetadata = function applyMetadata(options) {
6563
6369
  * @see {@link https://developer.mozilla.org/docs/Web/API/fetch} for more about the fetch API.
6564
6370
  * @returns {Promise<Response>} A promise for the response to the request.
6565
6371
  */
6566
-
6567
-
6568
6372
  var scratchFetch = function scratchFetch(resource, options) {
6569
6373
  var augmentedOptions = applyMetadata(options);
6570
6374
  return crossFetch.fetch(resource, augmentedOptions);
6571
6375
  };
6376
+
6572
6377
  /**
6573
6378
  * Set the value of a named request metadata item.
6574
6379
  * Setting the value to `null` or `undefined` will NOT remove the item.
@@ -6576,21 +6381,17 @@ var scratchFetch = function scratchFetch(resource, options) {
6576
6381
  * @param {RequestMetadata} name The name of the metadata item to set.
6577
6382
  * @param {any} value The value to set (will be converted to a string).
6578
6383
  */
6579
-
6580
-
6581
6384
  var setMetadata = function setMetadata(name, value) {
6582
6385
  metadata.set(name, value);
6583
6386
  };
6387
+
6584
6388
  /**
6585
6389
  * Remove a named request metadata item.
6586
6390
  * @param {RequestMetadata} name The name of the metadata item to remove.
6587
6391
  */
6588
-
6589
-
6590
6392
  var unsetMetadata = function unsetMetadata(name) {
6591
6393
  metadata.delete(name);
6592
6394
  };
6593
-
6594
6395
  module.exports = {
6595
6396
  default: scratchFetch,
6596
6397
  Headers: crossFetch.Headers,
@@ -6600,7 +6401,6 @@ module.exports = {
6600
6401
  setMetadata: setMetadata,
6601
6402
  unsetMetadata: unsetMetadata
6602
6403
  };
6603
-
6604
6404
  if (true) {
6605
6405
  /**
6606
6406
  * Retrieve a named request metadata item.
@@ -6611,7 +6411,6 @@ if (true) {
6611
6411
  var getMetadata = function getMetadata(name) {
6612
6412
  return metadata.get(name);
6613
6413
  };
6614
-
6615
6414
  module.exports.getMetadata = getMetadata;
6616
6415
  }
6617
6416