scratch-storage 2.3.284 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +7 -0
- package/CHANGELOG.md +11 -0
- package/dist/{web/f6240eab828e6d415177.worker.js → node/chunks/fetch-worker.eefe62e3c8ee125d3436.js} +105 -180
- package/dist/node/chunks/fetch-worker.eefe62e3c8ee125d3436.js.map +1 -0
- package/dist/node/scratch-storage.js +3898 -6304
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/types/Asset.d.ts +38 -0
- package/dist/types/AssetType.d.ts +49 -0
- package/dist/types/BuiltinHelper.d.ts +69 -0
- package/dist/types/DataFormat.d.ts +15 -0
- package/dist/types/FetchTool.d.ts +33 -0
- package/dist/types/FetchWorkerTool.d.ts +29 -0
- package/dist/types/Helper.d.ts +20 -0
- package/dist/types/ProxyTool.d.ts +53 -0
- package/dist/types/ScratchStorage.d.ts +202 -0
- package/dist/types/Tool.d.ts +13 -0
- package/dist/types/WebHelper.d.ts +59 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/log.d.ts +2 -0
- package/dist/types/memoizedToString.d.ts +5 -0
- package/dist/web/chunks/fetch-worker.85da71862ab8ee15f1cd.js +2 -0
- package/dist/web/chunks/fetch-worker.85da71862ab8ee15f1cd.js.map +1 -0
- package/dist/web/chunks/fetch-worker.ba5eddd48c8ae259073b.js +676 -0
- package/dist/web/chunks/fetch-worker.ba5eddd48c8ae259073b.js.map +1 -0
- package/dist/web/scratch-storage.js +2002 -2758
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +2 -6398
- package/dist/web/scratch-storage.min.js.LICENSE.txt +18 -0
- package/dist/web/scratch-storage.min.js.map +1 -1
- package/jest.config.js +32 -0
- package/package.json +18 -13
- package/src/.eslintrc.js +13 -1
- package/src/Asset.ts +100 -0
- package/src/{AssetType.js → AssetType.ts} +10 -5
- package/src/{BuiltinHelper.js → BuiltinHelper.ts} +44 -35
- package/src/{DataFormat.js → DataFormat.ts} +3 -3
- package/src/{FetchTool.js → FetchTool.ts} +8 -9
- package/src/{FetchWorkerTool.js → FetchWorkerTool.ts} +47 -22
- package/src/{Helper.js → Helper.ts} +10 -5
- package/src/{ProxyTool.js → ProxyTool.ts} +32 -29
- package/src/{ScratchStorage.js → ScratchStorage.ts} +57 -34
- package/src/Tool.ts +10 -0
- package/src/{WebHelper.js → WebHelper.ts} +42 -15
- package/src/index.ts +19 -0
- package/src/log.ts +4 -0
- package/src/{Asset.js → memoizedToString.ts} +16 -76
- package/src/scratchFetch.js +0 -2
- package/src/types.d.ts +3 -0
- package/test/integration/download-known-assets.test.js +1 -1
- package/test/unit/add-helper.test.js +1 -1
- package/test/unit/fetch-tool.test.js +1 -1
- package/test/unit/load-default-assets.test.js +1 -1
- package/test/unit/metadata.test.js +6 -6
- package/tsconfig.json +29 -0
- package/tsconfig.test.json +11 -0
- package/webpack.config.js +58 -65
- package/dist/node/ce8a01e629587e4f90e4.worker.js +0 -4274
- package/dist/node/ce8a01e629587e4f90e4.worker.js.map +0 -1
- package/dist/web/f6240eab828e6d415177.worker.js.map +0 -1
- package/src/index.js +0 -7
- package/src/log.js +0 -4
package/.browserslistrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0](https://github.com/scratchfoundation/scratch-storage/compare/v2.3.284...v3.0.0) (2024-10-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* chore!: can't have a default and non-default exports in commonjs ([ff5b428](https://github.com/scratchfoundation/scratch-storage/commit/ff5b428e7152b97671262da1d7ac08f3abfe7259))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* The ScratchStorage constructor is now exported
|
|
15
|
+
as a named export instead of a default export.
|
|
16
|
+
|
|
6
17
|
## [2.3.284](https://github.com/scratchfoundation/scratch-storage/compare/v2.3.283...v2.3.284) (2024-10-23)
|
|
7
18
|
|
|
8
19
|
|
package/dist/{web/f6240eab828e6d415177.worker.js → node/chunks/fetch-worker.eefe62e3c8ee125d3436.js}
RENAMED
|
@@ -1,181 +1,7 @@
|
|
|
1
|
-
/******/ (
|
|
2
|
-
/******/
|
|
3
|
-
/******/ var installedModules = {};
|
|
4
|
-
/******/
|
|
5
|
-
/******/ // The require function
|
|
6
|
-
/******/ function __webpack_require__(moduleId) {
|
|
7
|
-
/******/
|
|
8
|
-
/******/ // Check if module is in cache
|
|
9
|
-
/******/ if(installedModules[moduleId]) {
|
|
10
|
-
/******/ return installedModules[moduleId].exports;
|
|
11
|
-
/******/ }
|
|
12
|
-
/******/ // Create a new module (and put it into the cache)
|
|
13
|
-
/******/ var module = installedModules[moduleId] = {
|
|
14
|
-
/******/ i: moduleId,
|
|
15
|
-
/******/ l: false,
|
|
16
|
-
/******/ exports: {}
|
|
17
|
-
/******/ };
|
|
18
|
-
/******/
|
|
19
|
-
/******/ // Execute the module function
|
|
20
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
21
|
-
/******/
|
|
22
|
-
/******/ // Flag the module as loaded
|
|
23
|
-
/******/ module.l = true;
|
|
24
|
-
/******/
|
|
25
|
-
/******/ // Return the exports of the module
|
|
26
|
-
/******/ return module.exports;
|
|
27
|
-
/******/ }
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
31
|
-
/******/ __webpack_require__.m = modules;
|
|
32
|
-
/******/
|
|
33
|
-
/******/ // expose the module cache
|
|
34
|
-
/******/ __webpack_require__.c = installedModules;
|
|
35
|
-
/******/
|
|
36
|
-
/******/ // define getter function for harmony exports
|
|
37
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
38
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
39
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
40
|
-
/******/ }
|
|
41
|
-
/******/ };
|
|
42
|
-
/******/
|
|
43
|
-
/******/ // define __esModule on exports
|
|
44
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
45
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
46
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
47
|
-
/******/ }
|
|
48
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
49
|
-
/******/ };
|
|
50
|
-
/******/
|
|
51
|
-
/******/ // create a fake namespace object
|
|
52
|
-
/******/ // mode & 1: value is a module id, require it
|
|
53
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
54
|
-
/******/ // mode & 4: return value when already ns object
|
|
55
|
-
/******/ // mode & 8|1: behave like require
|
|
56
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
57
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
58
|
-
/******/ if(mode & 8) return value;
|
|
59
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
60
|
-
/******/ var ns = Object.create(null);
|
|
61
|
-
/******/ __webpack_require__.r(ns);
|
|
62
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
63
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
64
|
-
/******/ return ns;
|
|
65
|
-
/******/ };
|
|
66
|
-
/******/
|
|
67
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
68
|
-
/******/ __webpack_require__.n = function(module) {
|
|
69
|
-
/******/ var getter = module && module.__esModule ?
|
|
70
|
-
/******/ function getDefault() { return module['default']; } :
|
|
71
|
-
/******/ function getModuleExports() { return module; };
|
|
72
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
73
|
-
/******/ return getter;
|
|
74
|
-
/******/ };
|
|
75
|
-
/******/
|
|
76
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
77
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
78
|
-
/******/
|
|
79
|
-
/******/ // __webpack_public_path__
|
|
80
|
-
/******/ __webpack_require__.p = "";
|
|
81
|
-
/******/
|
|
82
|
-
/******/
|
|
83
|
-
/******/ // Load entry module and return exports
|
|
84
|
-
/******/ return __webpack_require__(__webpack_require__.s = "./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js");
|
|
85
|
-
/******/ })
|
|
86
|
-
/************************************************************************/
|
|
87
|
-
/******/ ({
|
|
88
|
-
|
|
89
|
-
/***/ "./node_modules/babel-loader/lib/index.js?!./src/FetchWorkerTool.worker.js":
|
|
90
|
-
/*!*******************************************************************************!*\
|
|
91
|
-
!*** ./node_modules/babel-loader/lib??ref--4!./src/FetchWorkerTool.worker.js ***!
|
|
92
|
-
\*******************************************************************************/
|
|
93
|
-
/*! no static exports found */
|
|
94
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
95
|
-
|
|
96
|
-
/* eslint-env worker */
|
|
97
|
-
|
|
98
|
-
var crossFetch = __webpack_require__(/*! cross-fetch */ "./node_modules/cross-fetch/dist/browser-ponyfill.js").default;
|
|
99
|
-
var jobsActive = 0;
|
|
100
|
-
var complete = [];
|
|
101
|
-
var intervalId = null;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Register a step function.
|
|
105
|
-
*
|
|
106
|
-
* Step checks if there are completed jobs and if there are sends them to the
|
|
107
|
-
* parent. Then it checks the jobs count. If there are no further jobs, clear
|
|
108
|
-
* the step.
|
|
109
|
-
*/
|
|
110
|
-
var registerStep = function registerStep() {
|
|
111
|
-
intervalId = setInterval(function () {
|
|
112
|
-
if (complete.length) {
|
|
113
|
-
// Send our chunk of completed requests and instruct postMessage to
|
|
114
|
-
// transfer the buffers instead of copying them.
|
|
115
|
-
postMessage(complete.slice(),
|
|
116
|
-
// Instruct postMessage that these buffers in the sent message
|
|
117
|
-
// should use their Transferable trait. After the postMessage
|
|
118
|
-
// call the "buffers" will still be in complete if you looked,
|
|
119
|
-
// but they will all be length 0 as the data they reference has
|
|
120
|
-
// been sent to the window. This lets us send a lot of data
|
|
121
|
-
// without the normal postMessage behaviour of making a copy of
|
|
122
|
-
// all of the data for the window.
|
|
123
|
-
complete.map(function (response) {
|
|
124
|
-
return response.buffer;
|
|
125
|
-
}).filter(Boolean));
|
|
126
|
-
complete.length = 0;
|
|
127
|
-
}
|
|
128
|
-
if (jobsActive === 0) {
|
|
129
|
-
clearInterval(intervalId);
|
|
130
|
-
intervalId = null;
|
|
131
|
-
}
|
|
132
|
-
}, 1);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Receive a job from the parent and fetch the requested data.
|
|
137
|
-
* @param {object} options.job A job id, url, and options descriptor to perform.
|
|
138
|
-
*/
|
|
139
|
-
var onMessage = function onMessage(_ref) {
|
|
140
|
-
var job = _ref.data;
|
|
141
|
-
if (jobsActive === 0 && !intervalId) {
|
|
142
|
-
registerStep();
|
|
143
|
-
}
|
|
144
|
-
jobsActive++;
|
|
145
|
-
crossFetch(job.url, job.options).then(function (result) {
|
|
146
|
-
if (result.ok) return result.arrayBuffer();
|
|
147
|
-
if (result.status === 404) return null;
|
|
148
|
-
return Promise.reject(result.status);
|
|
149
|
-
}).then(function (buffer) {
|
|
150
|
-
return complete.push({
|
|
151
|
-
id: job.id,
|
|
152
|
-
buffer: buffer
|
|
153
|
-
});
|
|
154
|
-
}).catch(function (error) {
|
|
155
|
-
return complete.push({
|
|
156
|
-
id: job.id,
|
|
157
|
-
error: error && error.message || "Failed request: ".concat(job.url)
|
|
158
|
-
});
|
|
159
|
-
}).then(function () {
|
|
160
|
-
return jobsActive--;
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// crossFetch means "fetch" is now always supported
|
|
165
|
-
postMessage({
|
|
166
|
-
support: {
|
|
167
|
-
fetch: true
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
self.addEventListener('message', onMessage);
|
|
171
|
-
|
|
172
|
-
/***/ }),
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ var __webpack_modules__ = ({
|
|
173
3
|
|
|
174
|
-
/***/
|
|
175
|
-
/*!***********************************************************!*\
|
|
176
|
-
!*** ./node_modules/cross-fetch/dist/browser-ponyfill.js ***!
|
|
177
|
-
\***********************************************************/
|
|
178
|
-
/*! no static exports found */
|
|
4
|
+
/***/ 945:
|
|
179
5
|
/***/ (function(module, exports) {
|
|
180
6
|
|
|
181
7
|
var global = typeof self !== 'undefined' ? self : this;
|
|
@@ -726,7 +552,7 @@ delete __self__.fetch.polyfill;
|
|
|
726
552
|
// var ctx = global.fetch ? global : __self__;
|
|
727
553
|
var ctx = __self__; // this line disable service worker support temporarily
|
|
728
554
|
exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
|
|
729
|
-
exports
|
|
555
|
+
exports["default"] = ctx.fetch // For TypeScript consumers without esModuleInterop.
|
|
730
556
|
exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
|
|
731
557
|
exports.Headers = ctx.Headers
|
|
732
558
|
exports.Request = ctx.Request
|
|
@@ -736,5 +562,104 @@ module.exports = exports
|
|
|
736
562
|
|
|
737
563
|
/***/ })
|
|
738
564
|
|
|
739
|
-
/******/
|
|
740
|
-
|
|
565
|
+
/******/ });
|
|
566
|
+
/************************************************************************/
|
|
567
|
+
/******/ // The module cache
|
|
568
|
+
/******/ var __webpack_module_cache__ = {};
|
|
569
|
+
/******/
|
|
570
|
+
/******/ // The require function
|
|
571
|
+
/******/ function __webpack_require__(moduleId) {
|
|
572
|
+
/******/ // Check if module is in cache
|
|
573
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
574
|
+
/******/ if (cachedModule !== undefined) {
|
|
575
|
+
/******/ return cachedModule.exports;
|
|
576
|
+
/******/ }
|
|
577
|
+
/******/ // Create a new module (and put it into the cache)
|
|
578
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
579
|
+
/******/ // no module.id needed
|
|
580
|
+
/******/ // no module.loaded needed
|
|
581
|
+
/******/ exports: {}
|
|
582
|
+
/******/ };
|
|
583
|
+
/******/
|
|
584
|
+
/******/ // Execute the module function
|
|
585
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
586
|
+
/******/
|
|
587
|
+
/******/ // Return the exports of the module
|
|
588
|
+
/******/ return module.exports;
|
|
589
|
+
/******/ }
|
|
590
|
+
/******/
|
|
591
|
+
/************************************************************************/
|
|
592
|
+
var __webpack_exports__ = {};
|
|
593
|
+
/* eslint-env worker */
|
|
594
|
+
|
|
595
|
+
const crossFetch = (__webpack_require__(945)["default"]);
|
|
596
|
+
let jobsActive = 0;
|
|
597
|
+
const complete = [];
|
|
598
|
+
let intervalId = null;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Register a step function.
|
|
602
|
+
*
|
|
603
|
+
* Step checks if there are completed jobs and if there are sends them to the
|
|
604
|
+
* parent. Then it checks the jobs count. If there are no further jobs, clear
|
|
605
|
+
* the step.
|
|
606
|
+
*/
|
|
607
|
+
const registerStep = function registerStep() {
|
|
608
|
+
intervalId = setInterval(() => {
|
|
609
|
+
if (complete.length) {
|
|
610
|
+
// Send our chunk of completed requests and instruct postMessage to
|
|
611
|
+
// transfer the buffers instead of copying them.
|
|
612
|
+
postMessage(complete.slice(),
|
|
613
|
+
// Instruct postMessage that these buffers in the sent message
|
|
614
|
+
// should use their Transferable trait. After the postMessage
|
|
615
|
+
// call the "buffers" will still be in complete if you looked,
|
|
616
|
+
// but they will all be length 0 as the data they reference has
|
|
617
|
+
// been sent to the window. This lets us send a lot of data
|
|
618
|
+
// without the normal postMessage behaviour of making a copy of
|
|
619
|
+
// all of the data for the window.
|
|
620
|
+
complete.map(response => response.buffer).filter(Boolean));
|
|
621
|
+
complete.length = 0;
|
|
622
|
+
}
|
|
623
|
+
if (jobsActive === 0) {
|
|
624
|
+
clearInterval(intervalId);
|
|
625
|
+
intervalId = null;
|
|
626
|
+
}
|
|
627
|
+
}, 1);
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Receive a job from the parent and fetch the requested data.
|
|
632
|
+
* @param {object} options.job A job id, url, and options descriptor to perform.
|
|
633
|
+
*/
|
|
634
|
+
const onMessage = _ref => {
|
|
635
|
+
let {
|
|
636
|
+
data: job
|
|
637
|
+
} = _ref;
|
|
638
|
+
if (jobsActive === 0 && !intervalId) {
|
|
639
|
+
registerStep();
|
|
640
|
+
}
|
|
641
|
+
jobsActive++;
|
|
642
|
+
crossFetch(job.url, job.options).then(result => {
|
|
643
|
+
if (result.ok) return result.arrayBuffer();
|
|
644
|
+
if (result.status === 404) return null;
|
|
645
|
+
return Promise.reject(result.status);
|
|
646
|
+
}).then(buffer => complete.push({
|
|
647
|
+
id: job.id,
|
|
648
|
+
buffer
|
|
649
|
+
})).catch(error => complete.push({
|
|
650
|
+
id: job.id,
|
|
651
|
+
error: error && error.message || "Failed request: ".concat(job.url)
|
|
652
|
+
})).then(() => jobsActive--);
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// crossFetch means "fetch" is now always supported
|
|
656
|
+
postMessage({
|
|
657
|
+
support: {
|
|
658
|
+
fetch: true
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
self.addEventListener('message', onMessage);
|
|
662
|
+
module.exports = __webpack_exports__;
|
|
663
|
+
/******/ })()
|
|
664
|
+
;
|
|
665
|
+
//# sourceMappingURL=fetch-worker.eefe62e3c8ee125d3436.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunks/fetch-worker.eefe62e3c8ee125d3436.js","mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;ACziBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvBA;;AAEA;AAEA;AACA;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AAEA;;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AACA","sources":["webpack://scratch-storage/./node_modules/cross-fetch/dist/browser-ponyfill.js","webpack://scratch-storage/webpack/bootstrap","webpack://scratch-storage/./src/FetchWorkerTool.worker.js"],"sourcesContent":["var 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","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","/* eslint-env worker */\n\nconst crossFetch = require('cross-fetch').default;\n\nlet jobsActive = 0;\nconst complete = [];\n\nlet intervalId = null;\n\n/**\n * Register a step function.\n *\n * Step checks if there are completed jobs and if there are sends them to the\n * parent. Then it checks the jobs count. If there are no further jobs, clear\n * the step.\n */\nconst registerStep = function () {\n intervalId = setInterval(() => {\n if (complete.length) {\n // Send our chunk of completed requests and instruct postMessage to\n // transfer the buffers instead of copying them.\n postMessage(\n complete.slice(),\n // Instruct postMessage that these buffers in the sent message\n // should use their Transferable trait. After the postMessage\n // call the \"buffers\" will still be in complete if you looked,\n // but they will all be length 0 as the data they reference has\n // been sent to the window. This lets us send a lot of data\n // without the normal postMessage behaviour of making a copy of\n // all of the data for the window.\n complete.map(response => response.buffer).filter(Boolean)\n );\n complete.length = 0;\n }\n if (jobsActive === 0) {\n clearInterval(intervalId);\n intervalId = null;\n }\n }, 1);\n};\n\n/**\n * Receive a job from the parent and fetch the requested data.\n * @param {object} options.job A job id, url, and options descriptor to perform.\n */\nconst onMessage = ({data: job}) => {\n if (jobsActive === 0 && !intervalId) {\n registerStep();\n }\n\n jobsActive++;\n\n crossFetch(job.url, job.options)\n .then(result => {\n if (result.ok) return result.arrayBuffer();\n if (result.status === 404) return null;\n return Promise.reject(result.status);\n })\n .then(buffer => complete.push({id: job.id, buffer}))\n .catch(error => complete.push({id: job.id, error: (error && error.message) || `Failed request: ${job.url}`}))\n .then(() => jobsActive--);\n};\n\n// crossFetch means \"fetch\" is now always supported\npostMessage({support: {fetch: true}});\nself.addEventListener('message', onMessage);\n"],"names":[],"sourceRoot":""}
|