scratch-storage 1.3.3 → 1.3.6
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/.editorconfig +1 -1
- package/.gitattributes +1 -0
- package/.github/CONTRIBUTING.md +60 -21
- package/.travis.yml +9 -18
- package/dist/node/d6e0e9d8aacfc3e11565.worker.js +1904 -0
- package/dist/node/d6e0e9d8aacfc3e11565.worker.js.map +1 -0
- package/dist/node/scratch-storage.js +1850 -247
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/web/3325b91e8645157f8dc6.worker.js.map +1 -1
- package/dist/web/scratch-storage.js +312 -4219
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +312 -4219
- package/dist/web/scratch-storage.min.js.map +1 -1
- package/package.json +16 -17
- package/renovate.json5 +7 -0
- package/src/Asset.js +3 -6
- package/src/BuiltinHelper.js +5 -5
- package/src/FetchWorkerTool.js +1 -1
- package/src/ProxyTool.js +2 -3
- package/src/ScratchStorage.js +1 -1
- package/src/WebHelper.js +2 -2
- package/test/integration/download-known-assets.js +1 -0
- package/test/unit/add-helper.js +1 -1
- package/webpack.config.js +7 -2
- package/dist/node/4816ce2aa9bf12df8b86.worker.js +0 -188
- package/dist/node/4816ce2aa9bf12df8b86.worker.js.map +0 -1
- package/src/NetsTool.js +0 -72
|
@@ -143,6 +143,30 @@ module.exports = function (base64Data) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
|
|
146
|
+
/***/ }),
|
|
147
|
+
|
|
148
|
+
/***/ "./node_modules/fastestsmallesttextencoderdecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs":
|
|
149
|
+
/*!***********************************************************************************************!*\
|
|
150
|
+
!*** ./node_modules/fastestsmallesttextencoderdecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs ***!
|
|
151
|
+
\***********************************************************************************************/
|
|
152
|
+
/*! exports provided: TextDecoder, TextEncoder, decode, encode */
|
|
153
|
+
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
154
|
+
|
|
155
|
+
"use strict";
|
|
156
|
+
__webpack_require__.r(__webpack_exports__);
|
|
157
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDecoder", function() { return TextDecoder; });
|
|
158
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEncoder", function() { return TextEncoder; });
|
|
159
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decode", function() { return decode; });
|
|
160
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "encode", function() { return encode; });
|
|
161
|
+
var a="undefined"==typeof global?"undefined"===typeof self?{}:self:global,p=String.fromCharCode,q={}.toString,r=a.SharedArrayBuffer,v=r?q.call(r):"",w=a.Uint8Array,x=w?q.call(ArrayBuffer.prototype):"",y=a.Buffer;try{!y&&a.require&&(y=a.require("Buffer"));var z=y.prototype,A=q.call(z)}catch(g){}var B=y.allocUnsafe,C=!!w&&!y,D=new Uint16Array(32),E=!y||!!w&&w.prototype.isPrototypeOf(z),G=F.prototype;function H(){}
|
|
162
|
+
function I(g){var h=g&&g.buffer||g,c=q.call(h);if(c!==x&&c!==A&&c!==v&&"[object ArrayBuffer]"!==c&&void 0!==g)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");g=E?new w(h):h||[];c=h="";for(var b=0,d=g.length|0,u=d-32|0,f,e,k=0,t=0,m,l=0,n=-1;b<d;){for(f=b<=u?32:d-b|0;l<f;b=b+1|0,l=l+1|0){e=g[b]&255;switch(e>>4){case 15:m=g[b=b+1|0]&255;if(2!==m>>6||247<e){b=b-1|0;break}k=(e&7)<<6|m&63;t=5;e=256;case 14:m=g[b=b+1|0]&
|
|
163
|
+
255,k<<=6,k|=(e&15)<<6|m&63,t=2===m>>6?t+4|0:24,e=e+256&768;case 13:case 12:m=g[b=b+1|0]&255,k<<=6,k|=(e&31)<<6|m&63,t=t+7|0,b<d&&2===m>>6&&k>>t&&1114112>k?(e=k,k=k-65536|0,0<=k&&(n=(k>>10)+55296|0,e=(k&1023)+56320|0,31>l?(D[l]=n,l=l+1|0,n=-1):(m=n,n=e,e=m))):(e>>=8,b=b-e-1|0,e=65533),k=t=0,f=b<=u?32:d-b|0;default:D[l]=e;continue;case 11:case 10:case 9:case 8:}D[l]=65533}c+=p(D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7],D[8],D[9],D[10],D[11],D[12],D[13],D[14],D[15],D[16],D[17],D[18],D[19],D[20],D[21],
|
|
164
|
+
D[22],D[23],D[24],D[25],D[26],D[27],D[28],D[29],D[30],D[31]);32>l&&(c=c.slice(0,l-32|0));if(b<d){if(D[0]=n,l=~n>>>31,n=-1,c.length<h.length)continue}else-1!==n&&(c+=p(n));h+=c;c=""}return h}H.prototype.decode=I;function F(){}
|
|
165
|
+
function J(g){g=void 0===g?"":""+g;var h=g.length|0,c=C?new w((h<<1)+8|0):B?B((h<<1)+8|0):new y((h<<1)+8|0),b,d=0,u=!1;for(b=0;b<h;b=b+1|0,d=d+1|0){var f=g.charCodeAt(b)|0;if(127>=f)c[d]=f;else{if(2047>=f)c[d]=192|f>>6;else{a:{if(55296<=f)if(56320>f){var e=g.charCodeAt(b=b+1|0)|0;if(56320<=e&&57343>=e){f=(f<<10)+e-56613888|0;if(65535<f){c[d]=240|f>>18;c[d=d+1|0]=128|f>>12&63;c[d=d+1|0]=128|f>>6&63;c[d=d+1|0]=128|f&63;continue}break a}f=65533}else 57343>=f&&(f=65533);!u&&b<<1<d&&b<<1<(d-7|0)&&(u=!0,
|
|
166
|
+
e=C?new w(3*h):B?B(3*h):new y(3*h),e.set(c),c=e)}c[d]=224|f>>12;c[d=d+1|0]=128|f>>6&63}c[d=d+1|0]=128|f&63}}return c.subarray(0,d)}G.encode=J;function K(g,h){var c=g[h];return function(){return c.apply(g,arguments)}}var L=a.TextDecoder,M=a.TextEncoder;var TextDecoder=L||H,TextEncoder=M||F,decode=L?K(new L,"decode"):I,encode=M?K(new M,"encode"):J;//AnonyCo
|
|
167
|
+
//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs.map
|
|
168
|
+
|
|
169
|
+
|
|
146
170
|
/***/ }),
|
|
147
171
|
|
|
148
172
|
/***/ "./node_modules/microee/index.js":
|
|
@@ -983,6 +1007,1666 @@ function color(fg, isInverse) {
|
|
|
983
1007
|
module.exports = color;
|
|
984
1008
|
|
|
985
1009
|
|
|
1010
|
+
/***/ }),
|
|
1011
|
+
|
|
1012
|
+
/***/ "./node_modules/node-fetch/lib/index.mjs":
|
|
1013
|
+
/*!***********************************************!*\
|
|
1014
|
+
!*** ./node_modules/node-fetch/lib/index.mjs ***!
|
|
1015
|
+
\***********************************************/
|
|
1016
|
+
/*! exports provided: default, Headers, Request, Response, FetchError */
|
|
1017
|
+
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1018
|
+
|
|
1019
|
+
"use strict";
|
|
1020
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1021
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Headers", function() { return Headers; });
|
|
1022
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Request", function() { return Request; });
|
|
1023
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Response", function() { return Response; });
|
|
1024
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FetchError", function() { return FetchError; });
|
|
1025
|
+
/* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! stream */ "stream");
|
|
1026
|
+
/* harmony import */ var http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! http */ "http");
|
|
1027
|
+
/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! url */ "url");
|
|
1028
|
+
/* harmony import */ var https__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! https */ "https");
|
|
1029
|
+
/* harmony import */ var zlib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! zlib */ "zlib");
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
|
|
1036
|
+
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
|
1037
|
+
|
|
1038
|
+
// fix for "Readable" isn't a named export issue
|
|
1039
|
+
const Readable = stream__WEBPACK_IMPORTED_MODULE_0__.Readable;
|
|
1040
|
+
|
|
1041
|
+
const BUFFER = Symbol('buffer');
|
|
1042
|
+
const TYPE = Symbol('type');
|
|
1043
|
+
|
|
1044
|
+
class Blob {
|
|
1045
|
+
constructor() {
|
|
1046
|
+
this[TYPE] = '';
|
|
1047
|
+
|
|
1048
|
+
const blobParts = arguments[0];
|
|
1049
|
+
const options = arguments[1];
|
|
1050
|
+
|
|
1051
|
+
const buffers = [];
|
|
1052
|
+
let size = 0;
|
|
1053
|
+
|
|
1054
|
+
if (blobParts) {
|
|
1055
|
+
const a = blobParts;
|
|
1056
|
+
const length = Number(a.length);
|
|
1057
|
+
for (let i = 0; i < length; i++) {
|
|
1058
|
+
const element = a[i];
|
|
1059
|
+
let buffer;
|
|
1060
|
+
if (element instanceof Buffer) {
|
|
1061
|
+
buffer = element;
|
|
1062
|
+
} else if (ArrayBuffer.isView(element)) {
|
|
1063
|
+
buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);
|
|
1064
|
+
} else if (element instanceof ArrayBuffer) {
|
|
1065
|
+
buffer = Buffer.from(element);
|
|
1066
|
+
} else if (element instanceof Blob) {
|
|
1067
|
+
buffer = element[BUFFER];
|
|
1068
|
+
} else {
|
|
1069
|
+
buffer = Buffer.from(typeof element === 'string' ? element : String(element));
|
|
1070
|
+
}
|
|
1071
|
+
size += buffer.length;
|
|
1072
|
+
buffers.push(buffer);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
this[BUFFER] = Buffer.concat(buffers);
|
|
1077
|
+
|
|
1078
|
+
let type = options && options.type !== undefined && String(options.type).toLowerCase();
|
|
1079
|
+
if (type && !/[^\u0020-\u007E]/.test(type)) {
|
|
1080
|
+
this[TYPE] = type;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
get size() {
|
|
1084
|
+
return this[BUFFER].length;
|
|
1085
|
+
}
|
|
1086
|
+
get type() {
|
|
1087
|
+
return this[TYPE];
|
|
1088
|
+
}
|
|
1089
|
+
text() {
|
|
1090
|
+
return Promise.resolve(this[BUFFER].toString());
|
|
1091
|
+
}
|
|
1092
|
+
arrayBuffer() {
|
|
1093
|
+
const buf = this[BUFFER];
|
|
1094
|
+
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
1095
|
+
return Promise.resolve(ab);
|
|
1096
|
+
}
|
|
1097
|
+
stream() {
|
|
1098
|
+
const readable = new Readable();
|
|
1099
|
+
readable._read = function () {};
|
|
1100
|
+
readable.push(this[BUFFER]);
|
|
1101
|
+
readable.push(null);
|
|
1102
|
+
return readable;
|
|
1103
|
+
}
|
|
1104
|
+
toString() {
|
|
1105
|
+
return '[object Blob]';
|
|
1106
|
+
}
|
|
1107
|
+
slice() {
|
|
1108
|
+
const size = this.size;
|
|
1109
|
+
|
|
1110
|
+
const start = arguments[0];
|
|
1111
|
+
const end = arguments[1];
|
|
1112
|
+
let relativeStart, relativeEnd;
|
|
1113
|
+
if (start === undefined) {
|
|
1114
|
+
relativeStart = 0;
|
|
1115
|
+
} else if (start < 0) {
|
|
1116
|
+
relativeStart = Math.max(size + start, 0);
|
|
1117
|
+
} else {
|
|
1118
|
+
relativeStart = Math.min(start, size);
|
|
1119
|
+
}
|
|
1120
|
+
if (end === undefined) {
|
|
1121
|
+
relativeEnd = size;
|
|
1122
|
+
} else if (end < 0) {
|
|
1123
|
+
relativeEnd = Math.max(size + end, 0);
|
|
1124
|
+
} else {
|
|
1125
|
+
relativeEnd = Math.min(end, size);
|
|
1126
|
+
}
|
|
1127
|
+
const span = Math.max(relativeEnd - relativeStart, 0);
|
|
1128
|
+
|
|
1129
|
+
const buffer = this[BUFFER];
|
|
1130
|
+
const slicedBuffer = buffer.slice(relativeStart, relativeStart + span);
|
|
1131
|
+
const blob = new Blob([], { type: arguments[2] });
|
|
1132
|
+
blob[BUFFER] = slicedBuffer;
|
|
1133
|
+
return blob;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
Object.defineProperties(Blob.prototype, {
|
|
1138
|
+
size: { enumerable: true },
|
|
1139
|
+
type: { enumerable: true },
|
|
1140
|
+
slice: { enumerable: true }
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
Object.defineProperty(Blob.prototype, Symbol.toStringTag, {
|
|
1144
|
+
value: 'Blob',
|
|
1145
|
+
writable: false,
|
|
1146
|
+
enumerable: false,
|
|
1147
|
+
configurable: true
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* fetch-error.js
|
|
1152
|
+
*
|
|
1153
|
+
* FetchError interface for operational errors
|
|
1154
|
+
*/
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* Create FetchError instance
|
|
1158
|
+
*
|
|
1159
|
+
* @param String message Error message for human
|
|
1160
|
+
* @param String type Error type for machine
|
|
1161
|
+
* @param String systemError For Node.js system error
|
|
1162
|
+
* @return FetchError
|
|
1163
|
+
*/
|
|
1164
|
+
function FetchError(message, type, systemError) {
|
|
1165
|
+
Error.call(this, message);
|
|
1166
|
+
|
|
1167
|
+
this.message = message;
|
|
1168
|
+
this.type = type;
|
|
1169
|
+
|
|
1170
|
+
// when err.type is `system`, err.code contains system error code
|
|
1171
|
+
if (systemError) {
|
|
1172
|
+
this.code = this.errno = systemError.code;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// hide custom error implementation details from end-users
|
|
1176
|
+
Error.captureStackTrace(this, this.constructor);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
FetchError.prototype = Object.create(Error.prototype);
|
|
1180
|
+
FetchError.prototype.constructor = FetchError;
|
|
1181
|
+
FetchError.prototype.name = 'FetchError';
|
|
1182
|
+
|
|
1183
|
+
let convert;
|
|
1184
|
+
try {
|
|
1185
|
+
convert = require('encoding').convert;
|
|
1186
|
+
} catch (e) {}
|
|
1187
|
+
|
|
1188
|
+
const INTERNALS = Symbol('Body internals');
|
|
1189
|
+
|
|
1190
|
+
// fix an issue where "PassThrough" isn't a named export for node <10
|
|
1191
|
+
const PassThrough = stream__WEBPACK_IMPORTED_MODULE_0__.PassThrough;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Body mixin
|
|
1195
|
+
*
|
|
1196
|
+
* Ref: https://fetch.spec.whatwg.org/#body
|
|
1197
|
+
*
|
|
1198
|
+
* @param Stream body Readable stream
|
|
1199
|
+
* @param Object opts Response options
|
|
1200
|
+
* @return Void
|
|
1201
|
+
*/
|
|
1202
|
+
function Body(body) {
|
|
1203
|
+
var _this = this;
|
|
1204
|
+
|
|
1205
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
1206
|
+
_ref$size = _ref.size;
|
|
1207
|
+
|
|
1208
|
+
let size = _ref$size === undefined ? 0 : _ref$size;
|
|
1209
|
+
var _ref$timeout = _ref.timeout;
|
|
1210
|
+
let timeout = _ref$timeout === undefined ? 0 : _ref$timeout;
|
|
1211
|
+
|
|
1212
|
+
if (body == null) {
|
|
1213
|
+
// body is undefined or null
|
|
1214
|
+
body = null;
|
|
1215
|
+
} else if (isURLSearchParams(body)) {
|
|
1216
|
+
// body is a URLSearchParams
|
|
1217
|
+
body = Buffer.from(body.toString());
|
|
1218
|
+
} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
|
|
1219
|
+
// body is ArrayBuffer
|
|
1220
|
+
body = Buffer.from(body);
|
|
1221
|
+
} else if (ArrayBuffer.isView(body)) {
|
|
1222
|
+
// body is ArrayBufferView
|
|
1223
|
+
body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
1224
|
+
} else if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) ; else {
|
|
1225
|
+
// none of the above
|
|
1226
|
+
// coerce to string then buffer
|
|
1227
|
+
body = Buffer.from(String(body));
|
|
1228
|
+
}
|
|
1229
|
+
this[INTERNALS] = {
|
|
1230
|
+
body,
|
|
1231
|
+
disturbed: false,
|
|
1232
|
+
error: null
|
|
1233
|
+
};
|
|
1234
|
+
this.size = size;
|
|
1235
|
+
this.timeout = timeout;
|
|
1236
|
+
|
|
1237
|
+
if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) {
|
|
1238
|
+
body.on('error', function (err) {
|
|
1239
|
+
const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);
|
|
1240
|
+
_this[INTERNALS].error = error;
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
Body.prototype = {
|
|
1246
|
+
get body() {
|
|
1247
|
+
return this[INTERNALS].body;
|
|
1248
|
+
},
|
|
1249
|
+
|
|
1250
|
+
get bodyUsed() {
|
|
1251
|
+
return this[INTERNALS].disturbed;
|
|
1252
|
+
},
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Decode response as ArrayBuffer
|
|
1256
|
+
*
|
|
1257
|
+
* @return Promise
|
|
1258
|
+
*/
|
|
1259
|
+
arrayBuffer() {
|
|
1260
|
+
return consumeBody.call(this).then(function (buf) {
|
|
1261
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
1262
|
+
});
|
|
1263
|
+
},
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Return raw response as Blob
|
|
1267
|
+
*
|
|
1268
|
+
* @return Promise
|
|
1269
|
+
*/
|
|
1270
|
+
blob() {
|
|
1271
|
+
let ct = this.headers && this.headers.get('content-type') || '';
|
|
1272
|
+
return consumeBody.call(this).then(function (buf) {
|
|
1273
|
+
return Object.assign(
|
|
1274
|
+
// Prevent copying
|
|
1275
|
+
new Blob([], {
|
|
1276
|
+
type: ct.toLowerCase()
|
|
1277
|
+
}), {
|
|
1278
|
+
[BUFFER]: buf
|
|
1279
|
+
});
|
|
1280
|
+
});
|
|
1281
|
+
},
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Decode response as json
|
|
1285
|
+
*
|
|
1286
|
+
* @return Promise
|
|
1287
|
+
*/
|
|
1288
|
+
json() {
|
|
1289
|
+
var _this2 = this;
|
|
1290
|
+
|
|
1291
|
+
return consumeBody.call(this).then(function (buffer) {
|
|
1292
|
+
try {
|
|
1293
|
+
return JSON.parse(buffer.toString());
|
|
1294
|
+
} catch (err) {
|
|
1295
|
+
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
},
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Decode response as text
|
|
1302
|
+
*
|
|
1303
|
+
* @return Promise
|
|
1304
|
+
*/
|
|
1305
|
+
text() {
|
|
1306
|
+
return consumeBody.call(this).then(function (buffer) {
|
|
1307
|
+
return buffer.toString();
|
|
1308
|
+
});
|
|
1309
|
+
},
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Decode response as buffer (non-spec api)
|
|
1313
|
+
*
|
|
1314
|
+
* @return Promise
|
|
1315
|
+
*/
|
|
1316
|
+
buffer() {
|
|
1317
|
+
return consumeBody.call(this);
|
|
1318
|
+
},
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Decode response as text, while automatically detecting the encoding and
|
|
1322
|
+
* trying to decode to UTF-8 (non-spec api)
|
|
1323
|
+
*
|
|
1324
|
+
* @return Promise
|
|
1325
|
+
*/
|
|
1326
|
+
textConverted() {
|
|
1327
|
+
var _this3 = this;
|
|
1328
|
+
|
|
1329
|
+
return consumeBody.call(this).then(function (buffer) {
|
|
1330
|
+
return convertBody(buffer, _this3.headers);
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
// In browsers, all properties are enumerable.
|
|
1336
|
+
Object.defineProperties(Body.prototype, {
|
|
1337
|
+
body: { enumerable: true },
|
|
1338
|
+
bodyUsed: { enumerable: true },
|
|
1339
|
+
arrayBuffer: { enumerable: true },
|
|
1340
|
+
blob: { enumerable: true },
|
|
1341
|
+
json: { enumerable: true },
|
|
1342
|
+
text: { enumerable: true }
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
Body.mixIn = function (proto) {
|
|
1346
|
+
for (const name of Object.getOwnPropertyNames(Body.prototype)) {
|
|
1347
|
+
// istanbul ignore else: future proof
|
|
1348
|
+
if (!(name in proto)) {
|
|
1349
|
+
const desc = Object.getOwnPropertyDescriptor(Body.prototype, name);
|
|
1350
|
+
Object.defineProperty(proto, name, desc);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* Consume and convert an entire Body to a Buffer.
|
|
1357
|
+
*
|
|
1358
|
+
* Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body
|
|
1359
|
+
*
|
|
1360
|
+
* @return Promise
|
|
1361
|
+
*/
|
|
1362
|
+
function consumeBody() {
|
|
1363
|
+
var _this4 = this;
|
|
1364
|
+
|
|
1365
|
+
if (this[INTERNALS].disturbed) {
|
|
1366
|
+
return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
this[INTERNALS].disturbed = true;
|
|
1370
|
+
|
|
1371
|
+
if (this[INTERNALS].error) {
|
|
1372
|
+
return Body.Promise.reject(this[INTERNALS].error);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
let body = this.body;
|
|
1376
|
+
|
|
1377
|
+
// body is null
|
|
1378
|
+
if (body === null) {
|
|
1379
|
+
return Body.Promise.resolve(Buffer.alloc(0));
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
// body is blob
|
|
1383
|
+
if (isBlob(body)) {
|
|
1384
|
+
body = body.stream();
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// body is buffer
|
|
1388
|
+
if (Buffer.isBuffer(body)) {
|
|
1389
|
+
return Body.Promise.resolve(body);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// istanbul ignore if: should never happen
|
|
1393
|
+
if (!(body instanceof stream__WEBPACK_IMPORTED_MODULE_0__)) {
|
|
1394
|
+
return Body.Promise.resolve(Buffer.alloc(0));
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
// body is stream
|
|
1398
|
+
// get ready to actually consume the body
|
|
1399
|
+
let accum = [];
|
|
1400
|
+
let accumBytes = 0;
|
|
1401
|
+
let abort = false;
|
|
1402
|
+
|
|
1403
|
+
return new Body.Promise(function (resolve, reject) {
|
|
1404
|
+
let resTimeout;
|
|
1405
|
+
|
|
1406
|
+
// allow timeout on slow response body
|
|
1407
|
+
if (_this4.timeout) {
|
|
1408
|
+
resTimeout = setTimeout(function () {
|
|
1409
|
+
abort = true;
|
|
1410
|
+
reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));
|
|
1411
|
+
}, _this4.timeout);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// handle stream errors
|
|
1415
|
+
body.on('error', function (err) {
|
|
1416
|
+
if (err.name === 'AbortError') {
|
|
1417
|
+
// if the request was aborted, reject with this Error
|
|
1418
|
+
abort = true;
|
|
1419
|
+
reject(err);
|
|
1420
|
+
} else {
|
|
1421
|
+
// other errors, such as incorrect content-encoding
|
|
1422
|
+
reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
body.on('data', function (chunk) {
|
|
1427
|
+
if (abort || chunk === null) {
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
if (_this4.size && accumBytes + chunk.length > _this4.size) {
|
|
1432
|
+
abort = true;
|
|
1433
|
+
reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
accumBytes += chunk.length;
|
|
1438
|
+
accum.push(chunk);
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
body.on('end', function () {
|
|
1442
|
+
if (abort) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
clearTimeout(resTimeout);
|
|
1447
|
+
|
|
1448
|
+
try {
|
|
1449
|
+
resolve(Buffer.concat(accum, accumBytes));
|
|
1450
|
+
} catch (err) {
|
|
1451
|
+
// handle streams that have accumulated too much data (issue #414)
|
|
1452
|
+
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* Detect buffer encoding and convert to target encoding
|
|
1460
|
+
* ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding
|
|
1461
|
+
*
|
|
1462
|
+
* @param Buffer buffer Incoming buffer
|
|
1463
|
+
* @param String encoding Target encoding
|
|
1464
|
+
* @return String
|
|
1465
|
+
*/
|
|
1466
|
+
function convertBody(buffer, headers) {
|
|
1467
|
+
if (typeof convert !== 'function') {
|
|
1468
|
+
throw new Error('The package `encoding` must be installed to use the textConverted() function');
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
const ct = headers.get('content-type');
|
|
1472
|
+
let charset = 'utf-8';
|
|
1473
|
+
let res, str;
|
|
1474
|
+
|
|
1475
|
+
// header
|
|
1476
|
+
if (ct) {
|
|
1477
|
+
res = /charset=([^;]*)/i.exec(ct);
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// no charset in content type, peek at response body for at most 1024 bytes
|
|
1481
|
+
str = buffer.slice(0, 1024).toString();
|
|
1482
|
+
|
|
1483
|
+
// html5
|
|
1484
|
+
if (!res && str) {
|
|
1485
|
+
res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// html4
|
|
1489
|
+
if (!res && str) {
|
|
1490
|
+
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
|
|
1491
|
+
if (!res) {
|
|
1492
|
+
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
|
|
1493
|
+
if (res) {
|
|
1494
|
+
res.pop(); // drop last quote
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
if (res) {
|
|
1499
|
+
res = /charset=(.*)/i.exec(res.pop());
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
// xml
|
|
1504
|
+
if (!res && str) {
|
|
1505
|
+
res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// found charset
|
|
1509
|
+
if (res) {
|
|
1510
|
+
charset = res.pop();
|
|
1511
|
+
|
|
1512
|
+
// prevent decode issues when sites use incorrect encoding
|
|
1513
|
+
// ref: https://hsivonen.fi/encoding-menu/
|
|
1514
|
+
if (charset === 'gb2312' || charset === 'gbk') {
|
|
1515
|
+
charset = 'gb18030';
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// turn raw buffers into a single utf-8 buffer
|
|
1520
|
+
return convert(buffer, 'UTF-8', charset).toString();
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* Detect a URLSearchParams object
|
|
1525
|
+
* ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143
|
|
1526
|
+
*
|
|
1527
|
+
* @param Object obj Object to detect by type or brand
|
|
1528
|
+
* @return String
|
|
1529
|
+
*/
|
|
1530
|
+
function isURLSearchParams(obj) {
|
|
1531
|
+
// Duck-typing as a necessary condition.
|
|
1532
|
+
if (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') {
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// Brand-checking and more duck-typing as optional condition.
|
|
1537
|
+
return obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function';
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Check if `obj` is a W3C `Blob` object (which `File` inherits from)
|
|
1542
|
+
* @param {*} obj
|
|
1543
|
+
* @return {boolean}
|
|
1544
|
+
*/
|
|
1545
|
+
function isBlob(obj) {
|
|
1546
|
+
return typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* Clone body given Res/Req instance
|
|
1551
|
+
*
|
|
1552
|
+
* @param Mixed instance Response or Request instance
|
|
1553
|
+
* @return Mixed
|
|
1554
|
+
*/
|
|
1555
|
+
function clone(instance) {
|
|
1556
|
+
let p1, p2;
|
|
1557
|
+
let body = instance.body;
|
|
1558
|
+
|
|
1559
|
+
// don't allow cloning a used body
|
|
1560
|
+
if (instance.bodyUsed) {
|
|
1561
|
+
throw new Error('cannot clone body after it is used');
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// check that body is a stream and not form-data object
|
|
1565
|
+
// note: we can't clone the form-data object without having it as a dependency
|
|
1566
|
+
if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__ && typeof body.getBoundary !== 'function') {
|
|
1567
|
+
// tee instance body
|
|
1568
|
+
p1 = new PassThrough();
|
|
1569
|
+
p2 = new PassThrough();
|
|
1570
|
+
body.pipe(p1);
|
|
1571
|
+
body.pipe(p2);
|
|
1572
|
+
// set instance body to teed body and return the other teed body
|
|
1573
|
+
instance[INTERNALS].body = p1;
|
|
1574
|
+
body = p2;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
return body;
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Performs the operation "extract a `Content-Type` value from |object|" as
|
|
1582
|
+
* specified in the specification:
|
|
1583
|
+
* https://fetch.spec.whatwg.org/#concept-bodyinit-extract
|
|
1584
|
+
*
|
|
1585
|
+
* This function assumes that instance.body is present.
|
|
1586
|
+
*
|
|
1587
|
+
* @param Mixed instance Any options.body input
|
|
1588
|
+
*/
|
|
1589
|
+
function extractContentType(body) {
|
|
1590
|
+
if (body === null) {
|
|
1591
|
+
// body is null
|
|
1592
|
+
return null;
|
|
1593
|
+
} else if (typeof body === 'string') {
|
|
1594
|
+
// body is string
|
|
1595
|
+
return 'text/plain;charset=UTF-8';
|
|
1596
|
+
} else if (isURLSearchParams(body)) {
|
|
1597
|
+
// body is a URLSearchParams
|
|
1598
|
+
return 'application/x-www-form-urlencoded;charset=UTF-8';
|
|
1599
|
+
} else if (isBlob(body)) {
|
|
1600
|
+
// body is blob
|
|
1601
|
+
return body.type || null;
|
|
1602
|
+
} else if (Buffer.isBuffer(body)) {
|
|
1603
|
+
// body is buffer
|
|
1604
|
+
return null;
|
|
1605
|
+
} else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {
|
|
1606
|
+
// body is ArrayBuffer
|
|
1607
|
+
return null;
|
|
1608
|
+
} else if (ArrayBuffer.isView(body)) {
|
|
1609
|
+
// body is ArrayBufferView
|
|
1610
|
+
return null;
|
|
1611
|
+
} else if (typeof body.getBoundary === 'function') {
|
|
1612
|
+
// detect form data input from form-data module
|
|
1613
|
+
return `multipart/form-data;boundary=${body.getBoundary()}`;
|
|
1614
|
+
} else if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) {
|
|
1615
|
+
// body is stream
|
|
1616
|
+
// can't really do much about this
|
|
1617
|
+
return null;
|
|
1618
|
+
} else {
|
|
1619
|
+
// Body constructor defaults other things to string
|
|
1620
|
+
return 'text/plain;charset=UTF-8';
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* The Fetch Standard treats this as if "total bytes" is a property on the body.
|
|
1626
|
+
* For us, we have to explicitly get it with a function.
|
|
1627
|
+
*
|
|
1628
|
+
* ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes
|
|
1629
|
+
*
|
|
1630
|
+
* @param Body instance Instance of Body
|
|
1631
|
+
* @return Number? Number of bytes, or null if not possible
|
|
1632
|
+
*/
|
|
1633
|
+
function getTotalBytes(instance) {
|
|
1634
|
+
const body = instance.body;
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
if (body === null) {
|
|
1638
|
+
// body is null
|
|
1639
|
+
return 0;
|
|
1640
|
+
} else if (isBlob(body)) {
|
|
1641
|
+
return body.size;
|
|
1642
|
+
} else if (Buffer.isBuffer(body)) {
|
|
1643
|
+
// body is buffer
|
|
1644
|
+
return body.length;
|
|
1645
|
+
} else if (body && typeof body.getLengthSync === 'function') {
|
|
1646
|
+
// detect form data input from form-data module
|
|
1647
|
+
if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x
|
|
1648
|
+
body.hasKnownLength && body.hasKnownLength()) {
|
|
1649
|
+
// 2.x
|
|
1650
|
+
return body.getLengthSync();
|
|
1651
|
+
}
|
|
1652
|
+
return null;
|
|
1653
|
+
} else {
|
|
1654
|
+
// body is stream
|
|
1655
|
+
return null;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Write a Body to a Node.js WritableStream (e.g. http.Request) object.
|
|
1661
|
+
*
|
|
1662
|
+
* @param Body instance Instance of Body
|
|
1663
|
+
* @return Void
|
|
1664
|
+
*/
|
|
1665
|
+
function writeToStream(dest, instance) {
|
|
1666
|
+
const body = instance.body;
|
|
1667
|
+
|
|
1668
|
+
|
|
1669
|
+
if (body === null) {
|
|
1670
|
+
// body is null
|
|
1671
|
+
dest.end();
|
|
1672
|
+
} else if (isBlob(body)) {
|
|
1673
|
+
body.stream().pipe(dest);
|
|
1674
|
+
} else if (Buffer.isBuffer(body)) {
|
|
1675
|
+
// body is buffer
|
|
1676
|
+
dest.write(body);
|
|
1677
|
+
dest.end();
|
|
1678
|
+
} else {
|
|
1679
|
+
// body is stream
|
|
1680
|
+
body.pipe(dest);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// expose Promise
|
|
1685
|
+
Body.Promise = global.Promise;
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* headers.js
|
|
1689
|
+
*
|
|
1690
|
+
* Headers class offers convenient helpers
|
|
1691
|
+
*/
|
|
1692
|
+
|
|
1693
|
+
const invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/;
|
|
1694
|
+
const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
|
|
1695
|
+
|
|
1696
|
+
function validateName(name) {
|
|
1697
|
+
name = `${name}`;
|
|
1698
|
+
if (invalidTokenRegex.test(name) || name === '') {
|
|
1699
|
+
throw new TypeError(`${name} is not a legal HTTP header name`);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
function validateValue(value) {
|
|
1704
|
+
value = `${value}`;
|
|
1705
|
+
if (invalidHeaderCharRegex.test(value)) {
|
|
1706
|
+
throw new TypeError(`${value} is not a legal HTTP header value`);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Find the key in the map object given a header name.
|
|
1712
|
+
*
|
|
1713
|
+
* Returns undefined if not found.
|
|
1714
|
+
*
|
|
1715
|
+
* @param String name Header name
|
|
1716
|
+
* @return String|Undefined
|
|
1717
|
+
*/
|
|
1718
|
+
function find(map, name) {
|
|
1719
|
+
name = name.toLowerCase();
|
|
1720
|
+
for (const key in map) {
|
|
1721
|
+
if (key.toLowerCase() === name) {
|
|
1722
|
+
return key;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
return undefined;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
const MAP = Symbol('map');
|
|
1729
|
+
class Headers {
|
|
1730
|
+
/**
|
|
1731
|
+
* Headers class
|
|
1732
|
+
*
|
|
1733
|
+
* @param Object headers Response headers
|
|
1734
|
+
* @return Void
|
|
1735
|
+
*/
|
|
1736
|
+
constructor() {
|
|
1737
|
+
let init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
1738
|
+
|
|
1739
|
+
this[MAP] = Object.create(null);
|
|
1740
|
+
|
|
1741
|
+
if (init instanceof Headers) {
|
|
1742
|
+
const rawHeaders = init.raw();
|
|
1743
|
+
const headerNames = Object.keys(rawHeaders);
|
|
1744
|
+
|
|
1745
|
+
for (const headerName of headerNames) {
|
|
1746
|
+
for (const value of rawHeaders[headerName]) {
|
|
1747
|
+
this.append(headerName, value);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// We don't worry about converting prop to ByteString here as append()
|
|
1755
|
+
// will handle it.
|
|
1756
|
+
if (init == null) ; else if (typeof init === 'object') {
|
|
1757
|
+
const method = init[Symbol.iterator];
|
|
1758
|
+
if (method != null) {
|
|
1759
|
+
if (typeof method !== 'function') {
|
|
1760
|
+
throw new TypeError('Header pairs must be iterable');
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
// sequence<sequence<ByteString>>
|
|
1764
|
+
// Note: per spec we have to first exhaust the lists then process them
|
|
1765
|
+
const pairs = [];
|
|
1766
|
+
for (const pair of init) {
|
|
1767
|
+
if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {
|
|
1768
|
+
throw new TypeError('Each header pair must be iterable');
|
|
1769
|
+
}
|
|
1770
|
+
pairs.push(Array.from(pair));
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
for (const pair of pairs) {
|
|
1774
|
+
if (pair.length !== 2) {
|
|
1775
|
+
throw new TypeError('Each header pair must be a name/value tuple');
|
|
1776
|
+
}
|
|
1777
|
+
this.append(pair[0], pair[1]);
|
|
1778
|
+
}
|
|
1779
|
+
} else {
|
|
1780
|
+
// record<ByteString, ByteString>
|
|
1781
|
+
for (const key of Object.keys(init)) {
|
|
1782
|
+
const value = init[key];
|
|
1783
|
+
this.append(key, value);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
} else {
|
|
1787
|
+
throw new TypeError('Provided initializer must be an object');
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
/**
|
|
1792
|
+
* Return combined header value given name
|
|
1793
|
+
*
|
|
1794
|
+
* @param String name Header name
|
|
1795
|
+
* @return Mixed
|
|
1796
|
+
*/
|
|
1797
|
+
get(name) {
|
|
1798
|
+
name = `${name}`;
|
|
1799
|
+
validateName(name);
|
|
1800
|
+
const key = find(this[MAP], name);
|
|
1801
|
+
if (key === undefined) {
|
|
1802
|
+
return null;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
return this[MAP][key].join(', ');
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Iterate over all headers
|
|
1810
|
+
*
|
|
1811
|
+
* @param Function callback Executed for each item with parameters (value, name, thisArg)
|
|
1812
|
+
* @param Boolean thisArg `this` context for callback function
|
|
1813
|
+
* @return Void
|
|
1814
|
+
*/
|
|
1815
|
+
forEach(callback) {
|
|
1816
|
+
let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
1817
|
+
|
|
1818
|
+
let pairs = getHeaders(this);
|
|
1819
|
+
let i = 0;
|
|
1820
|
+
while (i < pairs.length) {
|
|
1821
|
+
var _pairs$i = pairs[i];
|
|
1822
|
+
const name = _pairs$i[0],
|
|
1823
|
+
value = _pairs$i[1];
|
|
1824
|
+
|
|
1825
|
+
callback.call(thisArg, value, name, this);
|
|
1826
|
+
pairs = getHeaders(this);
|
|
1827
|
+
i++;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Overwrite header values given name
|
|
1833
|
+
*
|
|
1834
|
+
* @param String name Header name
|
|
1835
|
+
* @param String value Header value
|
|
1836
|
+
* @return Void
|
|
1837
|
+
*/
|
|
1838
|
+
set(name, value) {
|
|
1839
|
+
name = `${name}`;
|
|
1840
|
+
value = `${value}`;
|
|
1841
|
+
validateName(name);
|
|
1842
|
+
validateValue(value);
|
|
1843
|
+
const key = find(this[MAP], name);
|
|
1844
|
+
this[MAP][key !== undefined ? key : name] = [value];
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* Append a value onto existing header
|
|
1849
|
+
*
|
|
1850
|
+
* @param String name Header name
|
|
1851
|
+
* @param String value Header value
|
|
1852
|
+
* @return Void
|
|
1853
|
+
*/
|
|
1854
|
+
append(name, value) {
|
|
1855
|
+
name = `${name}`;
|
|
1856
|
+
value = `${value}`;
|
|
1857
|
+
validateName(name);
|
|
1858
|
+
validateValue(value);
|
|
1859
|
+
const key = find(this[MAP], name);
|
|
1860
|
+
if (key !== undefined) {
|
|
1861
|
+
this[MAP][key].push(value);
|
|
1862
|
+
} else {
|
|
1863
|
+
this[MAP][name] = [value];
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Check for header name existence
|
|
1869
|
+
*
|
|
1870
|
+
* @param String name Header name
|
|
1871
|
+
* @return Boolean
|
|
1872
|
+
*/
|
|
1873
|
+
has(name) {
|
|
1874
|
+
name = `${name}`;
|
|
1875
|
+
validateName(name);
|
|
1876
|
+
return find(this[MAP], name) !== undefined;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Delete all header values given name
|
|
1881
|
+
*
|
|
1882
|
+
* @param String name Header name
|
|
1883
|
+
* @return Void
|
|
1884
|
+
*/
|
|
1885
|
+
delete(name) {
|
|
1886
|
+
name = `${name}`;
|
|
1887
|
+
validateName(name);
|
|
1888
|
+
const key = find(this[MAP], name);
|
|
1889
|
+
if (key !== undefined) {
|
|
1890
|
+
delete this[MAP][key];
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/**
|
|
1895
|
+
* Return raw headers (non-spec api)
|
|
1896
|
+
*
|
|
1897
|
+
* @return Object
|
|
1898
|
+
*/
|
|
1899
|
+
raw() {
|
|
1900
|
+
return this[MAP];
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/**
|
|
1904
|
+
* Get an iterator on keys.
|
|
1905
|
+
*
|
|
1906
|
+
* @return Iterator
|
|
1907
|
+
*/
|
|
1908
|
+
keys() {
|
|
1909
|
+
return createHeadersIterator(this, 'key');
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Get an iterator on values.
|
|
1914
|
+
*
|
|
1915
|
+
* @return Iterator
|
|
1916
|
+
*/
|
|
1917
|
+
values() {
|
|
1918
|
+
return createHeadersIterator(this, 'value');
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Get an iterator on entries.
|
|
1923
|
+
*
|
|
1924
|
+
* This is the default iterator of the Headers object.
|
|
1925
|
+
*
|
|
1926
|
+
* @return Iterator
|
|
1927
|
+
*/
|
|
1928
|
+
[Symbol.iterator]() {
|
|
1929
|
+
return createHeadersIterator(this, 'key+value');
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
Headers.prototype.entries = Headers.prototype[Symbol.iterator];
|
|
1933
|
+
|
|
1934
|
+
Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
|
|
1935
|
+
value: 'Headers',
|
|
1936
|
+
writable: false,
|
|
1937
|
+
enumerable: false,
|
|
1938
|
+
configurable: true
|
|
1939
|
+
});
|
|
1940
|
+
|
|
1941
|
+
Object.defineProperties(Headers.prototype, {
|
|
1942
|
+
get: { enumerable: true },
|
|
1943
|
+
forEach: { enumerable: true },
|
|
1944
|
+
set: { enumerable: true },
|
|
1945
|
+
append: { enumerable: true },
|
|
1946
|
+
has: { enumerable: true },
|
|
1947
|
+
delete: { enumerable: true },
|
|
1948
|
+
keys: { enumerable: true },
|
|
1949
|
+
values: { enumerable: true },
|
|
1950
|
+
entries: { enumerable: true }
|
|
1951
|
+
});
|
|
1952
|
+
|
|
1953
|
+
function getHeaders(headers) {
|
|
1954
|
+
let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';
|
|
1955
|
+
|
|
1956
|
+
const keys = Object.keys(headers[MAP]).sort();
|
|
1957
|
+
return keys.map(kind === 'key' ? function (k) {
|
|
1958
|
+
return k.toLowerCase();
|
|
1959
|
+
} : kind === 'value' ? function (k) {
|
|
1960
|
+
return headers[MAP][k].join(', ');
|
|
1961
|
+
} : function (k) {
|
|
1962
|
+
return [k.toLowerCase(), headers[MAP][k].join(', ')];
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
const INTERNAL = Symbol('internal');
|
|
1967
|
+
|
|
1968
|
+
function createHeadersIterator(target, kind) {
|
|
1969
|
+
const iterator = Object.create(HeadersIteratorPrototype);
|
|
1970
|
+
iterator[INTERNAL] = {
|
|
1971
|
+
target,
|
|
1972
|
+
kind,
|
|
1973
|
+
index: 0
|
|
1974
|
+
};
|
|
1975
|
+
return iterator;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
const HeadersIteratorPrototype = Object.setPrototypeOf({
|
|
1979
|
+
next() {
|
|
1980
|
+
// istanbul ignore if
|
|
1981
|
+
if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {
|
|
1982
|
+
throw new TypeError('Value of `this` is not a HeadersIterator');
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
var _INTERNAL = this[INTERNAL];
|
|
1986
|
+
const target = _INTERNAL.target,
|
|
1987
|
+
kind = _INTERNAL.kind,
|
|
1988
|
+
index = _INTERNAL.index;
|
|
1989
|
+
|
|
1990
|
+
const values = getHeaders(target, kind);
|
|
1991
|
+
const len = values.length;
|
|
1992
|
+
if (index >= len) {
|
|
1993
|
+
return {
|
|
1994
|
+
value: undefined,
|
|
1995
|
+
done: true
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
this[INTERNAL].index = index + 1;
|
|
2000
|
+
|
|
2001
|
+
return {
|
|
2002
|
+
value: values[index],
|
|
2003
|
+
done: false
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));
|
|
2007
|
+
|
|
2008
|
+
Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {
|
|
2009
|
+
value: 'HeadersIterator',
|
|
2010
|
+
writable: false,
|
|
2011
|
+
enumerable: false,
|
|
2012
|
+
configurable: true
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Export the Headers object in a form that Node.js can consume.
|
|
2017
|
+
*
|
|
2018
|
+
* @param Headers headers
|
|
2019
|
+
* @return Object
|
|
2020
|
+
*/
|
|
2021
|
+
function exportNodeCompatibleHeaders(headers) {
|
|
2022
|
+
const obj = Object.assign({ __proto__: null }, headers[MAP]);
|
|
2023
|
+
|
|
2024
|
+
// http.request() only supports string as Host header. This hack makes
|
|
2025
|
+
// specifying custom Host header possible.
|
|
2026
|
+
const hostHeaderKey = find(headers[MAP], 'Host');
|
|
2027
|
+
if (hostHeaderKey !== undefined) {
|
|
2028
|
+
obj[hostHeaderKey] = obj[hostHeaderKey][0];
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
return obj;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/**
|
|
2035
|
+
* Create a Headers object from an object of headers, ignoring those that do
|
|
2036
|
+
* not conform to HTTP grammar productions.
|
|
2037
|
+
*
|
|
2038
|
+
* @param Object obj Object of headers
|
|
2039
|
+
* @return Headers
|
|
2040
|
+
*/
|
|
2041
|
+
function createHeadersLenient(obj) {
|
|
2042
|
+
const headers = new Headers();
|
|
2043
|
+
for (const name of Object.keys(obj)) {
|
|
2044
|
+
if (invalidTokenRegex.test(name)) {
|
|
2045
|
+
continue;
|
|
2046
|
+
}
|
|
2047
|
+
if (Array.isArray(obj[name])) {
|
|
2048
|
+
for (const val of obj[name]) {
|
|
2049
|
+
if (invalidHeaderCharRegex.test(val)) {
|
|
2050
|
+
continue;
|
|
2051
|
+
}
|
|
2052
|
+
if (headers[MAP][name] === undefined) {
|
|
2053
|
+
headers[MAP][name] = [val];
|
|
2054
|
+
} else {
|
|
2055
|
+
headers[MAP][name].push(val);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
} else if (!invalidHeaderCharRegex.test(obj[name])) {
|
|
2059
|
+
headers[MAP][name] = [obj[name]];
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return headers;
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
const INTERNALS$1 = Symbol('Response internals');
|
|
2066
|
+
|
|
2067
|
+
// fix an issue where "STATUS_CODES" aren't a named export for node <10
|
|
2068
|
+
const STATUS_CODES = http__WEBPACK_IMPORTED_MODULE_1__.STATUS_CODES;
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* Response class
|
|
2072
|
+
*
|
|
2073
|
+
* @param Stream body Readable stream
|
|
2074
|
+
* @param Object opts Response options
|
|
2075
|
+
* @return Void
|
|
2076
|
+
*/
|
|
2077
|
+
class Response {
|
|
2078
|
+
constructor() {
|
|
2079
|
+
let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2080
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2081
|
+
|
|
2082
|
+
Body.call(this, body, opts);
|
|
2083
|
+
|
|
2084
|
+
const status = opts.status || 200;
|
|
2085
|
+
const headers = new Headers(opts.headers);
|
|
2086
|
+
|
|
2087
|
+
if (body != null && !headers.has('Content-Type')) {
|
|
2088
|
+
const contentType = extractContentType(body);
|
|
2089
|
+
if (contentType) {
|
|
2090
|
+
headers.append('Content-Type', contentType);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
this[INTERNALS$1] = {
|
|
2095
|
+
url: opts.url,
|
|
2096
|
+
status,
|
|
2097
|
+
statusText: opts.statusText || STATUS_CODES[status],
|
|
2098
|
+
headers,
|
|
2099
|
+
counter: opts.counter
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
get url() {
|
|
2104
|
+
return this[INTERNALS$1].url || '';
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
get status() {
|
|
2108
|
+
return this[INTERNALS$1].status;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
/**
|
|
2112
|
+
* Convenience property representing if the request ended normally
|
|
2113
|
+
*/
|
|
2114
|
+
get ok() {
|
|
2115
|
+
return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
get redirected() {
|
|
2119
|
+
return this[INTERNALS$1].counter > 0;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
get statusText() {
|
|
2123
|
+
return this[INTERNALS$1].statusText;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
get headers() {
|
|
2127
|
+
return this[INTERNALS$1].headers;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Clone this response
|
|
2132
|
+
*
|
|
2133
|
+
* @return Response
|
|
2134
|
+
*/
|
|
2135
|
+
clone() {
|
|
2136
|
+
return new Response(clone(this), {
|
|
2137
|
+
url: this.url,
|
|
2138
|
+
status: this.status,
|
|
2139
|
+
statusText: this.statusText,
|
|
2140
|
+
headers: this.headers,
|
|
2141
|
+
ok: this.ok,
|
|
2142
|
+
redirected: this.redirected
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
Body.mixIn(Response.prototype);
|
|
2148
|
+
|
|
2149
|
+
Object.defineProperties(Response.prototype, {
|
|
2150
|
+
url: { enumerable: true },
|
|
2151
|
+
status: { enumerable: true },
|
|
2152
|
+
ok: { enumerable: true },
|
|
2153
|
+
redirected: { enumerable: true },
|
|
2154
|
+
statusText: { enumerable: true },
|
|
2155
|
+
headers: { enumerable: true },
|
|
2156
|
+
clone: { enumerable: true }
|
|
2157
|
+
});
|
|
2158
|
+
|
|
2159
|
+
Object.defineProperty(Response.prototype, Symbol.toStringTag, {
|
|
2160
|
+
value: 'Response',
|
|
2161
|
+
writable: false,
|
|
2162
|
+
enumerable: false,
|
|
2163
|
+
configurable: true
|
|
2164
|
+
});
|
|
2165
|
+
|
|
2166
|
+
const INTERNALS$2 = Symbol('Request internals');
|
|
2167
|
+
|
|
2168
|
+
// fix an issue where "format", "parse" aren't a named export for node <10
|
|
2169
|
+
const parse_url = url__WEBPACK_IMPORTED_MODULE_2__.parse;
|
|
2170
|
+
const format_url = url__WEBPACK_IMPORTED_MODULE_2__.format;
|
|
2171
|
+
|
|
2172
|
+
const streamDestructionSupported = 'destroy' in stream__WEBPACK_IMPORTED_MODULE_0__.Readable.prototype;
|
|
2173
|
+
|
|
2174
|
+
/**
|
|
2175
|
+
* Check if a value is an instance of Request.
|
|
2176
|
+
*
|
|
2177
|
+
* @param Mixed input
|
|
2178
|
+
* @return Boolean
|
|
2179
|
+
*/
|
|
2180
|
+
function isRequest(input) {
|
|
2181
|
+
return typeof input === 'object' && typeof input[INTERNALS$2] === 'object';
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
function isAbortSignal(signal) {
|
|
2185
|
+
const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);
|
|
2186
|
+
return !!(proto && proto.constructor.name === 'AbortSignal');
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
/**
|
|
2190
|
+
* Request class
|
|
2191
|
+
*
|
|
2192
|
+
* @param Mixed input Url or Request instance
|
|
2193
|
+
* @param Object init Custom options
|
|
2194
|
+
* @return Void
|
|
2195
|
+
*/
|
|
2196
|
+
class Request {
|
|
2197
|
+
constructor(input) {
|
|
2198
|
+
let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2199
|
+
|
|
2200
|
+
let parsedURL;
|
|
2201
|
+
|
|
2202
|
+
// normalize input
|
|
2203
|
+
if (!isRequest(input)) {
|
|
2204
|
+
if (input && input.href) {
|
|
2205
|
+
// in order to support Node.js' Url objects; though WHATWG's URL objects
|
|
2206
|
+
// will fall into this branch also (since their `toString()` will return
|
|
2207
|
+
// `href` property anyway)
|
|
2208
|
+
parsedURL = parse_url(input.href);
|
|
2209
|
+
} else {
|
|
2210
|
+
// coerce input to a string before attempting to parse
|
|
2211
|
+
parsedURL = parse_url(`${input}`);
|
|
2212
|
+
}
|
|
2213
|
+
input = {};
|
|
2214
|
+
} else {
|
|
2215
|
+
parsedURL = parse_url(input.url);
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
let method = init.method || input.method || 'GET';
|
|
2219
|
+
method = method.toUpperCase();
|
|
2220
|
+
|
|
2221
|
+
if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {
|
|
2222
|
+
throw new TypeError('Request with GET/HEAD method cannot have body');
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;
|
|
2226
|
+
|
|
2227
|
+
Body.call(this, inputBody, {
|
|
2228
|
+
timeout: init.timeout || input.timeout || 0,
|
|
2229
|
+
size: init.size || input.size || 0
|
|
2230
|
+
});
|
|
2231
|
+
|
|
2232
|
+
const headers = new Headers(init.headers || input.headers || {});
|
|
2233
|
+
|
|
2234
|
+
if (inputBody != null && !headers.has('Content-Type')) {
|
|
2235
|
+
const contentType = extractContentType(inputBody);
|
|
2236
|
+
if (contentType) {
|
|
2237
|
+
headers.append('Content-Type', contentType);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
let signal = isRequest(input) ? input.signal : null;
|
|
2242
|
+
if ('signal' in init) signal = init.signal;
|
|
2243
|
+
|
|
2244
|
+
if (signal != null && !isAbortSignal(signal)) {
|
|
2245
|
+
throw new TypeError('Expected signal to be an instanceof AbortSignal');
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
this[INTERNALS$2] = {
|
|
2249
|
+
method,
|
|
2250
|
+
redirect: init.redirect || input.redirect || 'follow',
|
|
2251
|
+
headers,
|
|
2252
|
+
parsedURL,
|
|
2253
|
+
signal
|
|
2254
|
+
};
|
|
2255
|
+
|
|
2256
|
+
// node-fetch-only options
|
|
2257
|
+
this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;
|
|
2258
|
+
this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;
|
|
2259
|
+
this.counter = init.counter || input.counter || 0;
|
|
2260
|
+
this.agent = init.agent || input.agent;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
get method() {
|
|
2264
|
+
return this[INTERNALS$2].method;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
get url() {
|
|
2268
|
+
return format_url(this[INTERNALS$2].parsedURL);
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
get headers() {
|
|
2272
|
+
return this[INTERNALS$2].headers;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
get redirect() {
|
|
2276
|
+
return this[INTERNALS$2].redirect;
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
get signal() {
|
|
2280
|
+
return this[INTERNALS$2].signal;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Clone this request
|
|
2285
|
+
*
|
|
2286
|
+
* @return Request
|
|
2287
|
+
*/
|
|
2288
|
+
clone() {
|
|
2289
|
+
return new Request(this);
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
Body.mixIn(Request.prototype);
|
|
2294
|
+
|
|
2295
|
+
Object.defineProperty(Request.prototype, Symbol.toStringTag, {
|
|
2296
|
+
value: 'Request',
|
|
2297
|
+
writable: false,
|
|
2298
|
+
enumerable: false,
|
|
2299
|
+
configurable: true
|
|
2300
|
+
});
|
|
2301
|
+
|
|
2302
|
+
Object.defineProperties(Request.prototype, {
|
|
2303
|
+
method: { enumerable: true },
|
|
2304
|
+
url: { enumerable: true },
|
|
2305
|
+
headers: { enumerable: true },
|
|
2306
|
+
redirect: { enumerable: true },
|
|
2307
|
+
clone: { enumerable: true },
|
|
2308
|
+
signal: { enumerable: true }
|
|
2309
|
+
});
|
|
2310
|
+
|
|
2311
|
+
/**
|
|
2312
|
+
* Convert a Request to Node.js http request options.
|
|
2313
|
+
*
|
|
2314
|
+
* @param Request A Request instance
|
|
2315
|
+
* @return Object The options object to be passed to http.request
|
|
2316
|
+
*/
|
|
2317
|
+
function getNodeRequestOptions(request) {
|
|
2318
|
+
const parsedURL = request[INTERNALS$2].parsedURL;
|
|
2319
|
+
const headers = new Headers(request[INTERNALS$2].headers);
|
|
2320
|
+
|
|
2321
|
+
// fetch step 1.3
|
|
2322
|
+
if (!headers.has('Accept')) {
|
|
2323
|
+
headers.set('Accept', '*/*');
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
// Basic fetch
|
|
2327
|
+
if (!parsedURL.protocol || !parsedURL.hostname) {
|
|
2328
|
+
throw new TypeError('Only absolute URLs are supported');
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
if (!/^https?:$/.test(parsedURL.protocol)) {
|
|
2332
|
+
throw new TypeError('Only HTTP(S) protocols are supported');
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
if (request.signal && request.body instanceof stream__WEBPACK_IMPORTED_MODULE_0__.Readable && !streamDestructionSupported) {
|
|
2336
|
+
throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
// HTTP-network-or-cache fetch steps 2.4-2.7
|
|
2340
|
+
let contentLengthValue = null;
|
|
2341
|
+
if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
|
|
2342
|
+
contentLengthValue = '0';
|
|
2343
|
+
}
|
|
2344
|
+
if (request.body != null) {
|
|
2345
|
+
const totalBytes = getTotalBytes(request);
|
|
2346
|
+
if (typeof totalBytes === 'number') {
|
|
2347
|
+
contentLengthValue = String(totalBytes);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
if (contentLengthValue) {
|
|
2351
|
+
headers.set('Content-Length', contentLengthValue);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
// HTTP-network-or-cache fetch step 2.11
|
|
2355
|
+
if (!headers.has('User-Agent')) {
|
|
2356
|
+
headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
// HTTP-network-or-cache fetch step 2.15
|
|
2360
|
+
if (request.compress && !headers.has('Accept-Encoding')) {
|
|
2361
|
+
headers.set('Accept-Encoding', 'gzip,deflate');
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
let agent = request.agent;
|
|
2365
|
+
if (typeof agent === 'function') {
|
|
2366
|
+
agent = agent(parsedURL);
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
if (!headers.has('Connection') && !agent) {
|
|
2370
|
+
headers.set('Connection', 'close');
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// HTTP-network fetch step 4.2
|
|
2374
|
+
// chunked encoding is handled by Node.js
|
|
2375
|
+
|
|
2376
|
+
return Object.assign({}, parsedURL, {
|
|
2377
|
+
method: request.method,
|
|
2378
|
+
headers: exportNodeCompatibleHeaders(headers),
|
|
2379
|
+
agent
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
/**
|
|
2384
|
+
* abort-error.js
|
|
2385
|
+
*
|
|
2386
|
+
* AbortError interface for cancelled requests
|
|
2387
|
+
*/
|
|
2388
|
+
|
|
2389
|
+
/**
|
|
2390
|
+
* Create AbortError instance
|
|
2391
|
+
*
|
|
2392
|
+
* @param String message Error message for human
|
|
2393
|
+
* @return AbortError
|
|
2394
|
+
*/
|
|
2395
|
+
function AbortError(message) {
|
|
2396
|
+
Error.call(this, message);
|
|
2397
|
+
|
|
2398
|
+
this.type = 'aborted';
|
|
2399
|
+
this.message = message;
|
|
2400
|
+
|
|
2401
|
+
// hide custom error implementation details from end-users
|
|
2402
|
+
Error.captureStackTrace(this, this.constructor);
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
AbortError.prototype = Object.create(Error.prototype);
|
|
2406
|
+
AbortError.prototype.constructor = AbortError;
|
|
2407
|
+
AbortError.prototype.name = 'AbortError';
|
|
2408
|
+
|
|
2409
|
+
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
|
2410
|
+
const PassThrough$1 = stream__WEBPACK_IMPORTED_MODULE_0__.PassThrough;
|
|
2411
|
+
const resolve_url = url__WEBPACK_IMPORTED_MODULE_2__.resolve;
|
|
2412
|
+
|
|
2413
|
+
/**
|
|
2414
|
+
* Fetch function
|
|
2415
|
+
*
|
|
2416
|
+
* @param Mixed url Absolute url or Request instance
|
|
2417
|
+
* @param Object opts Fetch options
|
|
2418
|
+
* @return Promise
|
|
2419
|
+
*/
|
|
2420
|
+
function fetch(url, opts) {
|
|
2421
|
+
|
|
2422
|
+
// allow custom promise
|
|
2423
|
+
if (!fetch.Promise) {
|
|
2424
|
+
throw new Error('native promise missing, set fetch.Promise to your favorite alternative');
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
Body.Promise = fetch.Promise;
|
|
2428
|
+
|
|
2429
|
+
// wrap http.request into fetch
|
|
2430
|
+
return new fetch.Promise(function (resolve, reject) {
|
|
2431
|
+
// build request object
|
|
2432
|
+
const request = new Request(url, opts);
|
|
2433
|
+
const options = getNodeRequestOptions(request);
|
|
2434
|
+
|
|
2435
|
+
const send = (options.protocol === 'https:' ? https__WEBPACK_IMPORTED_MODULE_3__ : http__WEBPACK_IMPORTED_MODULE_1__).request;
|
|
2436
|
+
const signal = request.signal;
|
|
2437
|
+
|
|
2438
|
+
let response = null;
|
|
2439
|
+
|
|
2440
|
+
const abort = function abort() {
|
|
2441
|
+
let error = new AbortError('The user aborted a request.');
|
|
2442
|
+
reject(error);
|
|
2443
|
+
if (request.body && request.body instanceof stream__WEBPACK_IMPORTED_MODULE_0__.Readable) {
|
|
2444
|
+
request.body.destroy(error);
|
|
2445
|
+
}
|
|
2446
|
+
if (!response || !response.body) return;
|
|
2447
|
+
response.body.emit('error', error);
|
|
2448
|
+
};
|
|
2449
|
+
|
|
2450
|
+
if (signal && signal.aborted) {
|
|
2451
|
+
abort();
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
const abortAndFinalize = function abortAndFinalize() {
|
|
2456
|
+
abort();
|
|
2457
|
+
finalize();
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2460
|
+
// send request
|
|
2461
|
+
const req = send(options);
|
|
2462
|
+
let reqTimeout;
|
|
2463
|
+
|
|
2464
|
+
if (signal) {
|
|
2465
|
+
signal.addEventListener('abort', abortAndFinalize);
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
function finalize() {
|
|
2469
|
+
req.abort();
|
|
2470
|
+
if (signal) signal.removeEventListener('abort', abortAndFinalize);
|
|
2471
|
+
clearTimeout(reqTimeout);
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
if (request.timeout) {
|
|
2475
|
+
req.once('socket', function (socket) {
|
|
2476
|
+
reqTimeout = setTimeout(function () {
|
|
2477
|
+
reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));
|
|
2478
|
+
finalize();
|
|
2479
|
+
}, request.timeout);
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
req.on('error', function (err) {
|
|
2484
|
+
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
|
|
2485
|
+
finalize();
|
|
2486
|
+
});
|
|
2487
|
+
|
|
2488
|
+
req.on('response', function (res) {
|
|
2489
|
+
clearTimeout(reqTimeout);
|
|
2490
|
+
|
|
2491
|
+
const headers = createHeadersLenient(res.headers);
|
|
2492
|
+
|
|
2493
|
+
// HTTP fetch step 5
|
|
2494
|
+
if (fetch.isRedirect(res.statusCode)) {
|
|
2495
|
+
// HTTP fetch step 5.2
|
|
2496
|
+
const location = headers.get('Location');
|
|
2497
|
+
|
|
2498
|
+
// HTTP fetch step 5.3
|
|
2499
|
+
const locationURL = location === null ? null : resolve_url(request.url, location);
|
|
2500
|
+
|
|
2501
|
+
// HTTP fetch step 5.5
|
|
2502
|
+
switch (request.redirect) {
|
|
2503
|
+
case 'error':
|
|
2504
|
+
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
|
|
2505
|
+
finalize();
|
|
2506
|
+
return;
|
|
2507
|
+
case 'manual':
|
|
2508
|
+
// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.
|
|
2509
|
+
if (locationURL !== null) {
|
|
2510
|
+
// handle corrupted header
|
|
2511
|
+
try {
|
|
2512
|
+
headers.set('Location', locationURL);
|
|
2513
|
+
} catch (err) {
|
|
2514
|
+
// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request
|
|
2515
|
+
reject(err);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
break;
|
|
2519
|
+
case 'follow':
|
|
2520
|
+
// HTTP-redirect fetch step 2
|
|
2521
|
+
if (locationURL === null) {
|
|
2522
|
+
break;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
// HTTP-redirect fetch step 5
|
|
2526
|
+
if (request.counter >= request.follow) {
|
|
2527
|
+
reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));
|
|
2528
|
+
finalize();
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
// HTTP-redirect fetch step 6 (counter increment)
|
|
2533
|
+
// Create a new Request object.
|
|
2534
|
+
const requestOpts = {
|
|
2535
|
+
headers: new Headers(request.headers),
|
|
2536
|
+
follow: request.follow,
|
|
2537
|
+
counter: request.counter + 1,
|
|
2538
|
+
agent: request.agent,
|
|
2539
|
+
compress: request.compress,
|
|
2540
|
+
method: request.method,
|
|
2541
|
+
body: request.body,
|
|
2542
|
+
signal: request.signal,
|
|
2543
|
+
timeout: request.timeout,
|
|
2544
|
+
size: request.size
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2547
|
+
// HTTP-redirect fetch step 9
|
|
2548
|
+
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
|
2549
|
+
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
|
2550
|
+
finalize();
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
// HTTP-redirect fetch step 11
|
|
2555
|
+
if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {
|
|
2556
|
+
requestOpts.method = 'GET';
|
|
2557
|
+
requestOpts.body = undefined;
|
|
2558
|
+
requestOpts.headers.delete('content-length');
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
// HTTP-redirect fetch step 15
|
|
2562
|
+
resolve(fetch(new Request(locationURL, requestOpts)));
|
|
2563
|
+
finalize();
|
|
2564
|
+
return;
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
// prepare response
|
|
2569
|
+
res.once('end', function () {
|
|
2570
|
+
if (signal) signal.removeEventListener('abort', abortAndFinalize);
|
|
2571
|
+
});
|
|
2572
|
+
let body = res.pipe(new PassThrough$1());
|
|
2573
|
+
|
|
2574
|
+
const response_options = {
|
|
2575
|
+
url: request.url,
|
|
2576
|
+
status: res.statusCode,
|
|
2577
|
+
statusText: res.statusMessage,
|
|
2578
|
+
headers: headers,
|
|
2579
|
+
size: request.size,
|
|
2580
|
+
timeout: request.timeout,
|
|
2581
|
+
counter: request.counter
|
|
2582
|
+
};
|
|
2583
|
+
|
|
2584
|
+
// HTTP-network fetch step 12.1.1.3
|
|
2585
|
+
const codings = headers.get('Content-Encoding');
|
|
2586
|
+
|
|
2587
|
+
// HTTP-network fetch step 12.1.1.4: handle content codings
|
|
2588
|
+
|
|
2589
|
+
// in following scenarios we ignore compression support
|
|
2590
|
+
// 1. compression support is disabled
|
|
2591
|
+
// 2. HEAD request
|
|
2592
|
+
// 3. no Content-Encoding header
|
|
2593
|
+
// 4. no content response (204)
|
|
2594
|
+
// 5. content not modified response (304)
|
|
2595
|
+
if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
2596
|
+
response = new Response(body, response_options);
|
|
2597
|
+
resolve(response);
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
// For Node v6+
|
|
2602
|
+
// Be less strict when decoding compressed responses, since sometimes
|
|
2603
|
+
// servers send slightly invalid responses that are still accepted
|
|
2604
|
+
// by common browsers.
|
|
2605
|
+
// Always using Z_SYNC_FLUSH is what cURL does.
|
|
2606
|
+
const zlibOptions = {
|
|
2607
|
+
flush: zlib__WEBPACK_IMPORTED_MODULE_4__.Z_SYNC_FLUSH,
|
|
2608
|
+
finishFlush: zlib__WEBPACK_IMPORTED_MODULE_4__.Z_SYNC_FLUSH
|
|
2609
|
+
};
|
|
2610
|
+
|
|
2611
|
+
// for gzip
|
|
2612
|
+
if (codings == 'gzip' || codings == 'x-gzip') {
|
|
2613
|
+
body = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createGunzip(zlibOptions));
|
|
2614
|
+
response = new Response(body, response_options);
|
|
2615
|
+
resolve(response);
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// for deflate
|
|
2620
|
+
if (codings == 'deflate' || codings == 'x-deflate') {
|
|
2621
|
+
// handle the infamous raw deflate response from old servers
|
|
2622
|
+
// a hack for old IIS and Apache servers
|
|
2623
|
+
const raw = res.pipe(new PassThrough$1());
|
|
2624
|
+
raw.once('data', function (chunk) {
|
|
2625
|
+
// see http://stackoverflow.com/questions/37519828
|
|
2626
|
+
if ((chunk[0] & 0x0F) === 0x08) {
|
|
2627
|
+
body = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createInflate());
|
|
2628
|
+
} else {
|
|
2629
|
+
body = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createInflateRaw());
|
|
2630
|
+
}
|
|
2631
|
+
response = new Response(body, response_options);
|
|
2632
|
+
resolve(response);
|
|
2633
|
+
});
|
|
2634
|
+
return;
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
// for br
|
|
2638
|
+
if (codings == 'br' && typeof zlib__WEBPACK_IMPORTED_MODULE_4__.createBrotliDecompress === 'function') {
|
|
2639
|
+
body = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createBrotliDecompress());
|
|
2640
|
+
response = new Response(body, response_options);
|
|
2641
|
+
resolve(response);
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
// otherwise, use response as-is
|
|
2646
|
+
response = new Response(body, response_options);
|
|
2647
|
+
resolve(response);
|
|
2648
|
+
});
|
|
2649
|
+
|
|
2650
|
+
writeToStream(req, request);
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* Redirect code matching
|
|
2655
|
+
*
|
|
2656
|
+
* @param Number code Status code
|
|
2657
|
+
* @return Boolean
|
|
2658
|
+
*/
|
|
2659
|
+
fetch.isRedirect = function (code) {
|
|
2660
|
+
return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
|
|
2661
|
+
};
|
|
2662
|
+
|
|
2663
|
+
// expose Promise
|
|
2664
|
+
fetch.Promise = global.Promise;
|
|
2665
|
+
|
|
2666
|
+
/* harmony default export */ __webpack_exports__["default"] = (fetch);
|
|
2667
|
+
|
|
2668
|
+
|
|
2669
|
+
|
|
986
2670
|
/***/ }),
|
|
987
2671
|
|
|
988
2672
|
/***/ "./node_modules/worker-loader/dist/cjs.js?{\"inline\":true,\"fallback\":true}!./src/FetchWorkerTool.worker.js":
|
|
@@ -993,7 +2677,7 @@ module.exports = color;
|
|
|
993
2677
|
/***/ (function(module, exports, __webpack_require__) {
|
|
994
2678
|
|
|
995
2679
|
module.exports = function() {
|
|
996
|
-
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) {\n\n/* eslint-env worker */\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 fetch(job.url, job.options).then(function (response) {\n return response.arrayBuffer();\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\n });\n }).then(function () {\n return jobsActive--;\n });\n};\n\nif (self.fetch) {\n postMessage({\n support: {\n fetch: true\n }\n });\n self.addEventListener('message', onMessage);\n} else {\n postMessage({\n support: {\n fetch: false\n }\n });\n self.addEventListener('message', function (_ref2) {\n var job = _ref2.data;\n postMessage([{\n id: job.id,\n error: new Error('fetch is unavailable')\n }]);\n });\n}\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=4816ce2aa9bf12df8b86.worker.js.map", __webpack_require__.p + "4816ce2aa9bf12df8b86.worker.js");
|
|
2680
|
+
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/* WEBPACK VAR INJECTION */(function(fetch) {/* eslint-env worker */\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 fetch(job.url, job.options).then(function (response) {\n return response.arrayBuffer();\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\n });\n }).then(function () {\n return jobsActive--;\n });\n};\n\nif (self.fetch) {\n postMessage({\n support: {\n fetch: true\n }\n });\n self.addEventListener('message', onMessage);\n} else {\n postMessage({\n support: {\n fetch: false\n }\n });\n self.addEventListener('message', function (_ref2) {\n var job = _ref2.data;\n postMessage([{\n id: job.id,\n error: new Error('fetch is unavailable')\n }]);\n });\n}\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/lib/index.mjs\")[\"default\"]))\n\n/***/ }),\n\n/***/ \"./node_modules/node-fetch/lib/index.mjs\":\n/*!***********************************************!*\\\n !*** ./node_modules/node-fetch/lib/index.mjs ***!\n \\***********************************************/\n/*! exports provided: default, Headers, Request, Response, FetchError */\n/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Headers\", function() { return Headers; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Request\", function() { return Request; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Response\", function() { return Response; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"FetchError\", function() { return FetchError; });\n/* harmony import */ var stream__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! stream */ \"stream\");\n/* harmony import */ var http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! http */ \"http\");\n/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! url */ \"url\");\n/* harmony import */ var https__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! https */ \"https\");\n/* harmony import */ var zlib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! zlib */ \"zlib\");\n\n\n\n\n\n\n// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js\n\n// fix for \"Readable\" isn't a named export issue\nconst Readable = stream__WEBPACK_IMPORTED_MODULE_0__.Readable;\n\nconst BUFFER = Symbol('buffer');\nconst TYPE = Symbol('type');\n\nclass Blob {\n\tconstructor() {\n\t\tthis[TYPE] = '';\n\n\t\tconst blobParts = arguments[0];\n\t\tconst options = arguments[1];\n\n\t\tconst buffers = [];\n\t\tlet size = 0;\n\n\t\tif (blobParts) {\n\t\t\tconst a = blobParts;\n\t\t\tconst length = Number(a.length);\n\t\t\tfor (let i = 0; i < length; i++) {\n\t\t\t\tconst element = a[i];\n\t\t\t\tlet buffer;\n\t\t\t\tif (element instanceof Buffer) {\n\t\t\t\t\tbuffer = element;\n\t\t\t\t} else if (ArrayBuffer.isView(element)) {\n\t\t\t\t\tbuffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength);\n\t\t\t\t} else if (element instanceof ArrayBuffer) {\n\t\t\t\t\tbuffer = Buffer.from(element);\n\t\t\t\t} else if (element instanceof Blob) {\n\t\t\t\t\tbuffer = element[BUFFER];\n\t\t\t\t} else {\n\t\t\t\t\tbuffer = Buffer.from(typeof element === 'string' ? element : String(element));\n\t\t\t\t}\n\t\t\t\tsize += buffer.length;\n\t\t\t\tbuffers.push(buffer);\n\t\t\t}\n\t\t}\n\n\t\tthis[BUFFER] = Buffer.concat(buffers);\n\n\t\tlet type = options && options.type !== undefined && String(options.type).toLowerCase();\n\t\tif (type && !/[^\\u0020-\\u007E]/.test(type)) {\n\t\t\tthis[TYPE] = type;\n\t\t}\n\t}\n\tget size() {\n\t\treturn this[BUFFER].length;\n\t}\n\tget type() {\n\t\treturn this[TYPE];\n\t}\n\ttext() {\n\t\treturn Promise.resolve(this[BUFFER].toString());\n\t}\n\tarrayBuffer() {\n\t\tconst buf = this[BUFFER];\n\t\tconst ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\treturn Promise.resolve(ab);\n\t}\n\tstream() {\n\t\tconst readable = new Readable();\n\t\treadable._read = function () {};\n\t\treadable.push(this[BUFFER]);\n\t\treadable.push(null);\n\t\treturn readable;\n\t}\n\ttoString() {\n\t\treturn '[object Blob]';\n\t}\n\tslice() {\n\t\tconst size = this.size;\n\n\t\tconst start = arguments[0];\n\t\tconst end = arguments[1];\n\t\tlet relativeStart, relativeEnd;\n\t\tif (start === undefined) {\n\t\t\trelativeStart = 0;\n\t\t} else if (start < 0) {\n\t\t\trelativeStart = Math.max(size + start, 0);\n\t\t} else {\n\t\t\trelativeStart = Math.min(start, size);\n\t\t}\n\t\tif (end === undefined) {\n\t\t\trelativeEnd = size;\n\t\t} else if (end < 0) {\n\t\t\trelativeEnd = Math.max(size + end, 0);\n\t\t} else {\n\t\t\trelativeEnd = Math.min(end, size);\n\t\t}\n\t\tconst span = Math.max(relativeEnd - relativeStart, 0);\n\n\t\tconst buffer = this[BUFFER];\n\t\tconst slicedBuffer = buffer.slice(relativeStart, relativeStart + span);\n\t\tconst blob = new Blob([], { type: arguments[2] });\n\t\tblob[BUFFER] = slicedBuffer;\n\t\treturn blob;\n\t}\n}\n\nObject.defineProperties(Blob.prototype, {\n\tsize: { enumerable: true },\n\ttype: { enumerable: true },\n\tslice: { enumerable: true }\n});\n\nObject.defineProperty(Blob.prototype, Symbol.toStringTag, {\n\tvalue: 'Blob',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * fetch-error.js\n *\n * FetchError interface for operational errors\n */\n\n/**\n * Create FetchError instance\n *\n * @param String message Error message for human\n * @param String type Error type for machine\n * @param String systemError For Node.js system error\n * @return FetchError\n */\nfunction FetchError(message, type, systemError) {\n Error.call(this, message);\n\n this.message = message;\n this.type = type;\n\n // when err.type is `system`, err.code contains system error code\n if (systemError) {\n this.code = this.errno = systemError.code;\n }\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nFetchError.prototype = Object.create(Error.prototype);\nFetchError.prototype.constructor = FetchError;\nFetchError.prototype.name = 'FetchError';\n\nlet convert;\ntry {\n\tconvert = require('encoding').convert;\n} catch (e) {}\n\nconst INTERNALS = Symbol('Body internals');\n\n// fix an issue where \"PassThrough\" isn't a named export for node <10\nconst PassThrough = stream__WEBPACK_IMPORTED_MODULE_0__.PassThrough;\n\n/**\n * Body mixin\n *\n * Ref: https://fetch.spec.whatwg.org/#body\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nfunction Body(body) {\n\tvar _this = this;\n\n\tvar _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n\t _ref$size = _ref.size;\n\n\tlet size = _ref$size === undefined ? 0 : _ref$size;\n\tvar _ref$timeout = _ref.timeout;\n\tlet timeout = _ref$timeout === undefined ? 0 : _ref$timeout;\n\n\tif (body == null) {\n\t\t// body is undefined or null\n\t\tbody = null;\n\t} else if (isURLSearchParams(body)) {\n\t\t// body is a URLSearchParams\n\t\tbody = Buffer.from(body.toString());\n\t} else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {\n\t\t// body is ArrayBuffer\n\t\tbody = Buffer.from(body);\n\t} else if (ArrayBuffer.isView(body)) {\n\t\t// body is ArrayBufferView\n\t\tbody = Buffer.from(body.buffer, body.byteOffset, body.byteLength);\n\t} else if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) ; else {\n\t\t// none of the above\n\t\t// coerce to string then buffer\n\t\tbody = Buffer.from(String(body));\n\t}\n\tthis[INTERNALS] = {\n\t\tbody,\n\t\tdisturbed: false,\n\t\terror: null\n\t};\n\tthis.size = size;\n\tthis.timeout = timeout;\n\n\tif (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) {\n\t\tbody.on('error', function (err) {\n\t\t\tconst error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);\n\t\t\t_this[INTERNALS].error = error;\n\t\t});\n\t}\n}\n\nBody.prototype = {\n\tget body() {\n\t\treturn this[INTERNALS].body;\n\t},\n\n\tget bodyUsed() {\n\t\treturn this[INTERNALS].disturbed;\n\t},\n\n\t/**\n * Decode response as ArrayBuffer\n *\n * @return Promise\n */\n\tarrayBuffer() {\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n\t\t});\n\t},\n\n\t/**\n * Return raw response as Blob\n *\n * @return Promise\n */\n\tblob() {\n\t\tlet ct = this.headers && this.headers.get('content-type') || '';\n\t\treturn consumeBody.call(this).then(function (buf) {\n\t\t\treturn Object.assign(\n\t\t\t// Prevent copying\n\t\t\tnew Blob([], {\n\t\t\t\ttype: ct.toLowerCase()\n\t\t\t}), {\n\t\t\t\t[BUFFER]: buf\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n * Decode response as json\n *\n * @return Promise\n */\n\tjson() {\n\t\tvar _this2 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(buffer.toString());\n\t\t\t} catch (err) {\n\t\t\t\treturn Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n * Decode response as text\n *\n * @return Promise\n */\n\ttext() {\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn buffer.toString();\n\t\t});\n\t},\n\n\t/**\n * Decode response as buffer (non-spec api)\n *\n * @return Promise\n */\n\tbuffer() {\n\t\treturn consumeBody.call(this);\n\t},\n\n\t/**\n * Decode response as text, while automatically detecting the encoding and\n * trying to decode to UTF-8 (non-spec api)\n *\n * @return Promise\n */\n\ttextConverted() {\n\t\tvar _this3 = this;\n\n\t\treturn consumeBody.call(this).then(function (buffer) {\n\t\t\treturn convertBody(buffer, _this3.headers);\n\t\t});\n\t}\n};\n\n// In browsers, all properties are enumerable.\nObject.defineProperties(Body.prototype, {\n\tbody: { enumerable: true },\n\tbodyUsed: { enumerable: true },\n\tarrayBuffer: { enumerable: true },\n\tblob: { enumerable: true },\n\tjson: { enumerable: true },\n\ttext: { enumerable: true }\n});\n\nBody.mixIn = function (proto) {\n\tfor (const name of Object.getOwnPropertyNames(Body.prototype)) {\n\t\t// istanbul ignore else: future proof\n\t\tif (!(name in proto)) {\n\t\t\tconst desc = Object.getOwnPropertyDescriptor(Body.prototype, name);\n\t\t\tObject.defineProperty(proto, name, desc);\n\t\t}\n\t}\n};\n\n/**\n * Consume and convert an entire Body to a Buffer.\n *\n * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body\n *\n * @return Promise\n */\nfunction consumeBody() {\n\tvar _this4 = this;\n\n\tif (this[INTERNALS].disturbed) {\n\t\treturn Body.Promise.reject(new TypeError(`body used already for: ${this.url}`));\n\t}\n\n\tthis[INTERNALS].disturbed = true;\n\n\tif (this[INTERNALS].error) {\n\t\treturn Body.Promise.reject(this[INTERNALS].error);\n\t}\n\n\tlet body = this.body;\n\n\t// body is null\n\tif (body === null) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is blob\n\tif (isBlob(body)) {\n\t\tbody = body.stream();\n\t}\n\n\t// body is buffer\n\tif (Buffer.isBuffer(body)) {\n\t\treturn Body.Promise.resolve(body);\n\t}\n\n\t// istanbul ignore if: should never happen\n\tif (!(body instanceof stream__WEBPACK_IMPORTED_MODULE_0__)) {\n\t\treturn Body.Promise.resolve(Buffer.alloc(0));\n\t}\n\n\t// body is stream\n\t// get ready to actually consume the body\n\tlet accum = [];\n\tlet accumBytes = 0;\n\tlet abort = false;\n\n\treturn new Body.Promise(function (resolve, reject) {\n\t\tlet resTimeout;\n\n\t\t// allow timeout on slow response body\n\t\tif (_this4.timeout) {\n\t\t\tresTimeout = setTimeout(function () {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout'));\n\t\t\t}, _this4.timeout);\n\t\t}\n\n\t\t// handle stream errors\n\t\tbody.on('error', function (err) {\n\t\t\tif (err.name === 'AbortError') {\n\t\t\t\t// if the request was aborted, reject with this Error\n\t\t\t\tabort = true;\n\t\t\t\treject(err);\n\t\t\t} else {\n\t\t\t\t// other errors, such as incorrect content-encoding\n\t\t\t\treject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\n\t\tbody.on('data', function (chunk) {\n\t\t\tif (abort || chunk === null) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_this4.size && accumBytes + chunk.length > _this4.size) {\n\t\t\t\tabort = true;\n\t\t\t\treject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size'));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\taccumBytes += chunk.length;\n\t\t\taccum.push(chunk);\n\t\t});\n\n\t\tbody.on('end', function () {\n\t\t\tif (abort) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tclearTimeout(resTimeout);\n\n\t\t\ttry {\n\t\t\t\tresolve(Buffer.concat(accum, accumBytes));\n\t\t\t} catch (err) {\n\t\t\t\t// handle streams that have accumulated too much data (issue #414)\n\t\t\t\treject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t}\n\t\t});\n\t});\n}\n\n/**\n * Detect buffer encoding and convert to target encoding\n * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding\n *\n * @param Buffer buffer Incoming buffer\n * @param String encoding Target encoding\n * @return String\n */\nfunction convertBody(buffer, headers) {\n\tif (typeof convert !== 'function') {\n\t\tthrow new Error('The package `encoding` must be installed to use the textConverted() function');\n\t}\n\n\tconst ct = headers.get('content-type');\n\tlet charset = 'utf-8';\n\tlet res, str;\n\n\t// header\n\tif (ct) {\n\t\tres = /charset=([^;]*)/i.exec(ct);\n\t}\n\n\t// no charset in content type, peek at response body for at most 1024 bytes\n\tstr = buffer.slice(0, 1024).toString();\n\n\t// html5\n\tif (!res && str) {\n\t\tres = /<meta.+?charset=(['\"])(.+?)\\1/i.exec(str);\n\t}\n\n\t// html4\n\tif (!res && str) {\n\t\tres = /<meta[\\s]+?http-equiv=(['\"])content-type\\1[\\s]+?content=(['\"])(.+?)\\2/i.exec(str);\n\t\tif (!res) {\n\t\t\tres = /<meta[\\s]+?content=(['\"])(.+?)\\1[\\s]+?http-equiv=(['\"])content-type\\3/i.exec(str);\n\t\t\tif (res) {\n\t\t\t\tres.pop(); // drop last quote\n\t\t\t}\n\t\t}\n\n\t\tif (res) {\n\t\t\tres = /charset=(.*)/i.exec(res.pop());\n\t\t}\n\t}\n\n\t// xml\n\tif (!res && str) {\n\t\tres = /<\\?xml.+?encoding=(['\"])(.+?)\\1/i.exec(str);\n\t}\n\n\t// found charset\n\tif (res) {\n\t\tcharset = res.pop();\n\n\t\t// prevent decode issues when sites use incorrect encoding\n\t\t// ref: https://hsivonen.fi/encoding-menu/\n\t\tif (charset === 'gb2312' || charset === 'gbk') {\n\t\t\tcharset = 'gb18030';\n\t\t}\n\t}\n\n\t// turn raw buffers into a single utf-8 buffer\n\treturn convert(buffer, 'UTF-8', charset).toString();\n}\n\n/**\n * Detect a URLSearchParams object\n * ref: https://github.com/bitinn/node-fetch/issues/296#issuecomment-307598143\n *\n * @param Object obj Object to detect by type or brand\n * @return String\n */\nfunction isURLSearchParams(obj) {\n\t// Duck-typing as a necessary condition.\n\tif (typeof obj !== 'object' || typeof obj.append !== 'function' || typeof obj.delete !== 'function' || typeof obj.get !== 'function' || typeof obj.getAll !== 'function' || typeof obj.has !== 'function' || typeof obj.set !== 'function') {\n\t\treturn false;\n\t}\n\n\t// Brand-checking and more duck-typing as optional condition.\n\treturn obj.constructor.name === 'URLSearchParams' || Object.prototype.toString.call(obj) === '[object URLSearchParams]' || typeof obj.sort === 'function';\n}\n\n/**\n * Check if `obj` is a W3C `Blob` object (which `File` inherits from)\n * @param {*} obj\n * @return {boolean}\n */\nfunction isBlob(obj) {\n\treturn typeof obj === 'object' && typeof obj.arrayBuffer === 'function' && typeof obj.type === 'string' && typeof obj.stream === 'function' && typeof obj.constructor === 'function' && typeof obj.constructor.name === 'string' && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);\n}\n\n/**\n * Clone body given Res/Req instance\n *\n * @param Mixed instance Response or Request instance\n * @return Mixed\n */\nfunction clone(instance) {\n\tlet p1, p2;\n\tlet body = instance.body;\n\n\t// don't allow cloning a used body\n\tif (instance.bodyUsed) {\n\t\tthrow new Error('cannot clone body after it is used');\n\t}\n\n\t// check that body is a stream and not form-data object\n\t// note: we can't clone the form-data object without having it as a dependency\n\tif (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__ && typeof body.getBoundary !== 'function') {\n\t\t// tee instance body\n\t\tp1 = new PassThrough();\n\t\tp2 = new PassThrough();\n\t\tbody.pipe(p1);\n\t\tbody.pipe(p2);\n\t\t// set instance body to teed body and return the other teed body\n\t\tinstance[INTERNALS].body = p1;\n\t\tbody = p2;\n\t}\n\n\treturn body;\n}\n\n/**\n * Performs the operation \"extract a `Content-Type` value from |object|\" as\n * specified in the specification:\n * https://fetch.spec.whatwg.org/#concept-bodyinit-extract\n *\n * This function assumes that instance.body is present.\n *\n * @param Mixed instance Any options.body input\n */\nfunction extractContentType(body) {\n\tif (body === null) {\n\t\t// body is null\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\t// body is string\n\t\treturn 'text/plain;charset=UTF-8';\n\t} else if (isURLSearchParams(body)) {\n\t\t// body is a URLSearchParams\n\t\treturn 'application/x-www-form-urlencoded;charset=UTF-8';\n\t} else if (isBlob(body)) {\n\t\t// body is blob\n\t\treturn body.type || null;\n\t} else if (Buffer.isBuffer(body)) {\n\t\t// body is buffer\n\t\treturn null;\n\t} else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') {\n\t\t// body is ArrayBuffer\n\t\treturn null;\n\t} else if (ArrayBuffer.isView(body)) {\n\t\t// body is ArrayBufferView\n\t\treturn null;\n\t} else if (typeof body.getBoundary === 'function') {\n\t\t// detect form data input from form-data module\n\t\treturn `multipart/form-data;boundary=${body.getBoundary()}`;\n\t} else if (body instanceof stream__WEBPACK_IMPORTED_MODULE_0__) {\n\t\t// body is stream\n\t\t// can't really do much about this\n\t\treturn null;\n\t} else {\n\t\t// Body constructor defaults other things to string\n\t\treturn 'text/plain;charset=UTF-8';\n\t}\n}\n\n/**\n * The Fetch Standard treats this as if \"total bytes\" is a property on the body.\n * For us, we have to explicitly get it with a function.\n *\n * ref: https://fetch.spec.whatwg.org/#concept-body-total-bytes\n *\n * @param Body instance Instance of Body\n * @return Number? Number of bytes, or null if not possible\n */\nfunction getTotalBytes(instance) {\n\tconst body = instance.body;\n\n\n\tif (body === null) {\n\t\t// body is null\n\t\treturn 0;\n\t} else if (isBlob(body)) {\n\t\treturn body.size;\n\t} else if (Buffer.isBuffer(body)) {\n\t\t// body is buffer\n\t\treturn body.length;\n\t} else if (body && typeof body.getLengthSync === 'function') {\n\t\t// detect form data input from form-data module\n\t\tif (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x\n\t\tbody.hasKnownLength && body.hasKnownLength()) {\n\t\t\t// 2.x\n\t\t\treturn body.getLengthSync();\n\t\t}\n\t\treturn null;\n\t} else {\n\t\t// body is stream\n\t\treturn null;\n\t}\n}\n\n/**\n * Write a Body to a Node.js WritableStream (e.g. http.Request) object.\n *\n * @param Body instance Instance of Body\n * @return Void\n */\nfunction writeToStream(dest, instance) {\n\tconst body = instance.body;\n\n\n\tif (body === null) {\n\t\t// body is null\n\t\tdest.end();\n\t} else if (isBlob(body)) {\n\t\tbody.stream().pipe(dest);\n\t} else if (Buffer.isBuffer(body)) {\n\t\t// body is buffer\n\t\tdest.write(body);\n\t\tdest.end();\n\t} else {\n\t\t// body is stream\n\t\tbody.pipe(dest);\n\t}\n}\n\n// expose Promise\nBody.Promise = global.Promise;\n\n/**\n * headers.js\n *\n * Headers class offers convenient helpers\n */\n\nconst invalidTokenRegex = /[^\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]/;\nconst invalidHeaderCharRegex = /[^\\t\\x20-\\x7e\\x80-\\xff]/;\n\nfunction validateName(name) {\n\tname = `${name}`;\n\tif (invalidTokenRegex.test(name) || name === '') {\n\t\tthrow new TypeError(`${name} is not a legal HTTP header name`);\n\t}\n}\n\nfunction validateValue(value) {\n\tvalue = `${value}`;\n\tif (invalidHeaderCharRegex.test(value)) {\n\t\tthrow new TypeError(`${value} is not a legal HTTP header value`);\n\t}\n}\n\n/**\n * Find the key in the map object given a header name.\n *\n * Returns undefined if not found.\n *\n * @param String name Header name\n * @return String|Undefined\n */\nfunction find(map, name) {\n\tname = name.toLowerCase();\n\tfor (const key in map) {\n\t\tif (key.toLowerCase() === name) {\n\t\t\treturn key;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nconst MAP = Symbol('map');\nclass Headers {\n\t/**\n * Headers class\n *\n * @param Object headers Response headers\n * @return Void\n */\n\tconstructor() {\n\t\tlet init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;\n\n\t\tthis[MAP] = Object.create(null);\n\n\t\tif (init instanceof Headers) {\n\t\t\tconst rawHeaders = init.raw();\n\t\t\tconst headerNames = Object.keys(rawHeaders);\n\n\t\t\tfor (const headerName of headerNames) {\n\t\t\t\tfor (const value of rawHeaders[headerName]) {\n\t\t\t\t\tthis.append(headerName, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t// We don't worry about converting prop to ByteString here as append()\n\t\t// will handle it.\n\t\tif (init == null) ; else if (typeof init === 'object') {\n\t\t\tconst method = init[Symbol.iterator];\n\t\t\tif (method != null) {\n\t\t\t\tif (typeof method !== 'function') {\n\t\t\t\t\tthrow new TypeError('Header pairs must be iterable');\n\t\t\t\t}\n\n\t\t\t\t// sequence<sequence<ByteString>>\n\t\t\t\t// Note: per spec we have to first exhaust the lists then process them\n\t\t\t\tconst pairs = [];\n\t\t\t\tfor (const pair of init) {\n\t\t\t\t\tif (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be iterable');\n\t\t\t\t\t}\n\t\t\t\t\tpairs.push(Array.from(pair));\n\t\t\t\t}\n\n\t\t\t\tfor (const pair of pairs) {\n\t\t\t\t\tif (pair.length !== 2) {\n\t\t\t\t\t\tthrow new TypeError('Each header pair must be a name/value tuple');\n\t\t\t\t\t}\n\t\t\t\t\tthis.append(pair[0], pair[1]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// record<ByteString, ByteString>\n\t\t\t\tfor (const key of Object.keys(init)) {\n\t\t\t\t\tconst value = init[key];\n\t\t\t\t\tthis.append(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Provided initializer must be an object');\n\t\t}\n\t}\n\n\t/**\n * Return combined header value given name\n *\n * @param String name Header name\n * @return Mixed\n */\n\tget(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this[MAP][key].join(', ');\n\t}\n\n\t/**\n * Iterate over all headers\n *\n * @param Function callback Executed for each item with parameters (value, name, thisArg)\n * @param Boolean thisArg `this` context for callback function\n * @return Void\n */\n\tforEach(callback) {\n\t\tlet thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;\n\n\t\tlet pairs = getHeaders(this);\n\t\tlet i = 0;\n\t\twhile (i < pairs.length) {\n\t\t\tvar _pairs$i = pairs[i];\n\t\t\tconst name = _pairs$i[0],\n\t\t\t value = _pairs$i[1];\n\n\t\t\tcallback.call(thisArg, value, name, this);\n\t\t\tpairs = getHeaders(this);\n\t\t\ti++;\n\t\t}\n\t}\n\n\t/**\n * Overwrite header values given name\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tset(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tthis[MAP][key !== undefined ? key : name] = [value];\n\t}\n\n\t/**\n * Append a value onto existing header\n *\n * @param String name Header name\n * @param String value Header value\n * @return Void\n */\n\tappend(name, value) {\n\t\tname = `${name}`;\n\t\tvalue = `${value}`;\n\t\tvalidateName(name);\n\t\tvalidateValue(value);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tthis[MAP][key].push(value);\n\t\t} else {\n\t\t\tthis[MAP][name] = [value];\n\t\t}\n\t}\n\n\t/**\n * Check for header name existence\n *\n * @param String name Header name\n * @return Boolean\n */\n\thas(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\treturn find(this[MAP], name) !== undefined;\n\t}\n\n\t/**\n * Delete all header values given name\n *\n * @param String name Header name\n * @return Void\n */\n\tdelete(name) {\n\t\tname = `${name}`;\n\t\tvalidateName(name);\n\t\tconst key = find(this[MAP], name);\n\t\tif (key !== undefined) {\n\t\t\tdelete this[MAP][key];\n\t\t}\n\t}\n\n\t/**\n * Return raw headers (non-spec api)\n *\n * @return Object\n */\n\traw() {\n\t\treturn this[MAP];\n\t}\n\n\t/**\n * Get an iterator on keys.\n *\n * @return Iterator\n */\n\tkeys() {\n\t\treturn createHeadersIterator(this, 'key');\n\t}\n\n\t/**\n * Get an iterator on values.\n *\n * @return Iterator\n */\n\tvalues() {\n\t\treturn createHeadersIterator(this, 'value');\n\t}\n\n\t/**\n * Get an iterator on entries.\n *\n * This is the default iterator of the Headers object.\n *\n * @return Iterator\n */\n\t[Symbol.iterator]() {\n\t\treturn createHeadersIterator(this, 'key+value');\n\t}\n}\nHeaders.prototype.entries = Headers.prototype[Symbol.iterator];\n\nObject.defineProperty(Headers.prototype, Symbol.toStringTag, {\n\tvalue: 'Headers',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Headers.prototype, {\n\tget: { enumerable: true },\n\tforEach: { enumerable: true },\n\tset: { enumerable: true },\n\tappend: { enumerable: true },\n\thas: { enumerable: true },\n\tdelete: { enumerable: true },\n\tkeys: { enumerable: true },\n\tvalues: { enumerable: true },\n\tentries: { enumerable: true }\n});\n\nfunction getHeaders(headers) {\n\tlet kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value';\n\n\tconst keys = Object.keys(headers[MAP]).sort();\n\treturn keys.map(kind === 'key' ? function (k) {\n\t\treturn k.toLowerCase();\n\t} : kind === 'value' ? function (k) {\n\t\treturn headers[MAP][k].join(', ');\n\t} : function (k) {\n\t\treturn [k.toLowerCase(), headers[MAP][k].join(', ')];\n\t});\n}\n\nconst INTERNAL = Symbol('internal');\n\nfunction createHeadersIterator(target, kind) {\n\tconst iterator = Object.create(HeadersIteratorPrototype);\n\titerator[INTERNAL] = {\n\t\ttarget,\n\t\tkind,\n\t\tindex: 0\n\t};\n\treturn iterator;\n}\n\nconst HeadersIteratorPrototype = Object.setPrototypeOf({\n\tnext() {\n\t\t// istanbul ignore if\n\t\tif (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {\n\t\t\tthrow new TypeError('Value of `this` is not a HeadersIterator');\n\t\t}\n\n\t\tvar _INTERNAL = this[INTERNAL];\n\t\tconst target = _INTERNAL.target,\n\t\t kind = _INTERNAL.kind,\n\t\t index = _INTERNAL.index;\n\n\t\tconst values = getHeaders(target, kind);\n\t\tconst len = values.length;\n\t\tif (index >= len) {\n\t\t\treturn {\n\t\t\t\tvalue: undefined,\n\t\t\t\tdone: true\n\t\t\t};\n\t\t}\n\n\t\tthis[INTERNAL].index = index + 1;\n\n\t\treturn {\n\t\t\tvalue: values[index],\n\t\t\tdone: false\n\t\t};\n\t}\n}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));\n\nObject.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {\n\tvalue: 'HeadersIterator',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\n/**\n * Export the Headers object in a form that Node.js can consume.\n *\n * @param Headers headers\n * @return Object\n */\nfunction exportNodeCompatibleHeaders(headers) {\n\tconst obj = Object.assign({ __proto__: null }, headers[MAP]);\n\n\t// http.request() only supports string as Host header. This hack makes\n\t// specifying custom Host header possible.\n\tconst hostHeaderKey = find(headers[MAP], 'Host');\n\tif (hostHeaderKey !== undefined) {\n\t\tobj[hostHeaderKey] = obj[hostHeaderKey][0];\n\t}\n\n\treturn obj;\n}\n\n/**\n * Create a Headers object from an object of headers, ignoring those that do\n * not conform to HTTP grammar productions.\n *\n * @param Object obj Object of headers\n * @return Headers\n */\nfunction createHeadersLenient(obj) {\n\tconst headers = new Headers();\n\tfor (const name of Object.keys(obj)) {\n\t\tif (invalidTokenRegex.test(name)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (Array.isArray(obj[name])) {\n\t\t\tfor (const val of obj[name]) {\n\t\t\t\tif (invalidHeaderCharRegex.test(val)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (headers[MAP][name] === undefined) {\n\t\t\t\t\theaders[MAP][name] = [val];\n\t\t\t\t} else {\n\t\t\t\t\theaders[MAP][name].push(val);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!invalidHeaderCharRegex.test(obj[name])) {\n\t\t\theaders[MAP][name] = [obj[name]];\n\t\t}\n\t}\n\treturn headers;\n}\n\nconst INTERNALS$1 = Symbol('Response internals');\n\n// fix an issue where \"STATUS_CODES\" aren't a named export for node <10\nconst STATUS_CODES = http__WEBPACK_IMPORTED_MODULE_1__.STATUS_CODES;\n\n/**\n * Response class\n *\n * @param Stream body Readable stream\n * @param Object opts Response options\n * @return Void\n */\nclass Response {\n\tconstructor() {\n\t\tlet body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\t\tlet opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tBody.call(this, body, opts);\n\n\t\tconst status = opts.status || 200;\n\t\tconst headers = new Headers(opts.headers);\n\n\t\tif (body != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(body);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tthis[INTERNALS$1] = {\n\t\t\turl: opts.url,\n\t\t\tstatus,\n\t\t\tstatusText: opts.statusText || STATUS_CODES[status],\n\t\t\theaders,\n\t\t\tcounter: opts.counter\n\t\t};\n\t}\n\n\tget url() {\n\t\treturn this[INTERNALS$1].url || '';\n\t}\n\n\tget status() {\n\t\treturn this[INTERNALS$1].status;\n\t}\n\n\t/**\n * Convenience property representing if the request ended normally\n */\n\tget ok() {\n\t\treturn this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;\n\t}\n\n\tget redirected() {\n\t\treturn this[INTERNALS$1].counter > 0;\n\t}\n\n\tget statusText() {\n\t\treturn this[INTERNALS$1].statusText;\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$1].headers;\n\t}\n\n\t/**\n * Clone this response\n *\n * @return Response\n */\n\tclone() {\n\t\treturn new Response(clone(this), {\n\t\t\turl: this.url,\n\t\t\tstatus: this.status,\n\t\t\tstatusText: this.statusText,\n\t\t\theaders: this.headers,\n\t\t\tok: this.ok,\n\t\t\tredirected: this.redirected\n\t\t});\n\t}\n}\n\nBody.mixIn(Response.prototype);\n\nObject.defineProperties(Response.prototype, {\n\turl: { enumerable: true },\n\tstatus: { enumerable: true },\n\tok: { enumerable: true },\n\tredirected: { enumerable: true },\n\tstatusText: { enumerable: true },\n\theaders: { enumerable: true },\n\tclone: { enumerable: true }\n});\n\nObject.defineProperty(Response.prototype, Symbol.toStringTag, {\n\tvalue: 'Response',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nconst INTERNALS$2 = Symbol('Request internals');\n\n// fix an issue where \"format\", \"parse\" aren't a named export for node <10\nconst parse_url = url__WEBPACK_IMPORTED_MODULE_2__.parse;\nconst format_url = url__WEBPACK_IMPORTED_MODULE_2__.format;\n\nconst streamDestructionSupported = 'destroy' in stream__WEBPACK_IMPORTED_MODULE_0__.Readable.prototype;\n\n/**\n * Check if a value is an instance of Request.\n *\n * @param Mixed input\n * @return Boolean\n */\nfunction isRequest(input) {\n\treturn typeof input === 'object' && typeof input[INTERNALS$2] === 'object';\n}\n\nfunction isAbortSignal(signal) {\n\tconst proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal);\n\treturn !!(proto && proto.constructor.name === 'AbortSignal');\n}\n\n/**\n * Request class\n *\n * @param Mixed input Url or Request instance\n * @param Object init Custom options\n * @return Void\n */\nclass Request {\n\tconstructor(input) {\n\t\tlet init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n\t\tlet parsedURL;\n\n\t\t// normalize input\n\t\tif (!isRequest(input)) {\n\t\t\tif (input && input.href) {\n\t\t\t\t// in order to support Node.js' Url objects; though WHATWG's URL objects\n\t\t\t\t// will fall into this branch also (since their `toString()` will return\n\t\t\t\t// `href` property anyway)\n\t\t\t\tparsedURL = parse_url(input.href);\n\t\t\t} else {\n\t\t\t\t// coerce input to a string before attempting to parse\n\t\t\t\tparsedURL = parse_url(`${input}`);\n\t\t\t}\n\t\t\tinput = {};\n\t\t} else {\n\t\t\tparsedURL = parse_url(input.url);\n\t\t}\n\n\t\tlet method = init.method || input.method || 'GET';\n\t\tmethod = method.toUpperCase();\n\n\t\tif ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) {\n\t\t\tthrow new TypeError('Request with GET/HEAD method cannot have body');\n\t\t}\n\n\t\tlet inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null;\n\n\t\tBody.call(this, inputBody, {\n\t\t\ttimeout: init.timeout || input.timeout || 0,\n\t\t\tsize: init.size || input.size || 0\n\t\t});\n\n\t\tconst headers = new Headers(init.headers || input.headers || {});\n\n\t\tif (inputBody != null && !headers.has('Content-Type')) {\n\t\t\tconst contentType = extractContentType(inputBody);\n\t\t\tif (contentType) {\n\t\t\t\theaders.append('Content-Type', contentType);\n\t\t\t}\n\t\t}\n\n\t\tlet signal = isRequest(input) ? input.signal : null;\n\t\tif ('signal' in init) signal = init.signal;\n\n\t\tif (signal != null && !isAbortSignal(signal)) {\n\t\t\tthrow new TypeError('Expected signal to be an instanceof AbortSignal');\n\t\t}\n\n\t\tthis[INTERNALS$2] = {\n\t\t\tmethod,\n\t\t\tredirect: init.redirect || input.redirect || 'follow',\n\t\t\theaders,\n\t\t\tparsedURL,\n\t\t\tsignal\n\t\t};\n\n\t\t// node-fetch-only options\n\t\tthis.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20;\n\t\tthis.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true;\n\t\tthis.counter = init.counter || input.counter || 0;\n\t\tthis.agent = init.agent || input.agent;\n\t}\n\n\tget method() {\n\t\treturn this[INTERNALS$2].method;\n\t}\n\n\tget url() {\n\t\treturn format_url(this[INTERNALS$2].parsedURL);\n\t}\n\n\tget headers() {\n\t\treturn this[INTERNALS$2].headers;\n\t}\n\n\tget redirect() {\n\t\treturn this[INTERNALS$2].redirect;\n\t}\n\n\tget signal() {\n\t\treturn this[INTERNALS$2].signal;\n\t}\n\n\t/**\n * Clone this request\n *\n * @return Request\n */\n\tclone() {\n\t\treturn new Request(this);\n\t}\n}\n\nBody.mixIn(Request.prototype);\n\nObject.defineProperty(Request.prototype, Symbol.toStringTag, {\n\tvalue: 'Request',\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: true\n});\n\nObject.defineProperties(Request.prototype, {\n\tmethod: { enumerable: true },\n\turl: { enumerable: true },\n\theaders: { enumerable: true },\n\tredirect: { enumerable: true },\n\tclone: { enumerable: true },\n\tsignal: { enumerable: true }\n});\n\n/**\n * Convert a Request to Node.js http request options.\n *\n * @param Request A Request instance\n * @return Object The options object to be passed to http.request\n */\nfunction getNodeRequestOptions(request) {\n\tconst parsedURL = request[INTERNALS$2].parsedURL;\n\tconst headers = new Headers(request[INTERNALS$2].headers);\n\n\t// fetch step 1.3\n\tif (!headers.has('Accept')) {\n\t\theaders.set('Accept', '*/*');\n\t}\n\n\t// Basic fetch\n\tif (!parsedURL.protocol || !parsedURL.hostname) {\n\t\tthrow new TypeError('Only absolute URLs are supported');\n\t}\n\n\tif (!/^https?:$/.test(parsedURL.protocol)) {\n\t\tthrow new TypeError('Only HTTP(S) protocols are supported');\n\t}\n\n\tif (request.signal && request.body instanceof stream__WEBPACK_IMPORTED_MODULE_0__.Readable && !streamDestructionSupported) {\n\t\tthrow new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');\n\t}\n\n\t// HTTP-network-or-cache fetch steps 2.4-2.7\n\tlet contentLengthValue = null;\n\tif (request.body == null && /^(POST|PUT)$/i.test(request.method)) {\n\t\tcontentLengthValue = '0';\n\t}\n\tif (request.body != null) {\n\t\tconst totalBytes = getTotalBytes(request);\n\t\tif (typeof totalBytes === 'number') {\n\t\t\tcontentLengthValue = String(totalBytes);\n\t\t}\n\t}\n\tif (contentLengthValue) {\n\t\theaders.set('Content-Length', contentLengthValue);\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.11\n\tif (!headers.has('User-Agent')) {\n\t\theaders.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)');\n\t}\n\n\t// HTTP-network-or-cache fetch step 2.15\n\tif (request.compress && !headers.has('Accept-Encoding')) {\n\t\theaders.set('Accept-Encoding', 'gzip,deflate');\n\t}\n\n\tlet agent = request.agent;\n\tif (typeof agent === 'function') {\n\t\tagent = agent(parsedURL);\n\t}\n\n\tif (!headers.has('Connection') && !agent) {\n\t\theaders.set('Connection', 'close');\n\t}\n\n\t// HTTP-network fetch step 4.2\n\t// chunked encoding is handled by Node.js\n\n\treturn Object.assign({}, parsedURL, {\n\t\tmethod: request.method,\n\t\theaders: exportNodeCompatibleHeaders(headers),\n\t\tagent\n\t});\n}\n\n/**\n * abort-error.js\n *\n * AbortError interface for cancelled requests\n */\n\n/**\n * Create AbortError instance\n *\n * @param String message Error message for human\n * @return AbortError\n */\nfunction AbortError(message) {\n Error.call(this, message);\n\n this.type = 'aborted';\n this.message = message;\n\n // hide custom error implementation details from end-users\n Error.captureStackTrace(this, this.constructor);\n}\n\nAbortError.prototype = Object.create(Error.prototype);\nAbortError.prototype.constructor = AbortError;\nAbortError.prototype.name = 'AbortError';\n\n// fix an issue where \"PassThrough\", \"resolve\" aren't a named export for node <10\nconst PassThrough$1 = stream__WEBPACK_IMPORTED_MODULE_0__.PassThrough;\nconst resolve_url = url__WEBPACK_IMPORTED_MODULE_2__.resolve;\n\n/**\n * Fetch function\n *\n * @param Mixed url Absolute url or Request instance\n * @param Object opts Fetch options\n * @return Promise\n */\nfunction fetch(url, opts) {\n\n\t// allow custom promise\n\tif (!fetch.Promise) {\n\t\tthrow new Error('native promise missing, set fetch.Promise to your favorite alternative');\n\t}\n\n\tBody.Promise = fetch.Promise;\n\n\t// wrap http.request into fetch\n\treturn new fetch.Promise(function (resolve, reject) {\n\t\t// build request object\n\t\tconst request = new Request(url, opts);\n\t\tconst options = getNodeRequestOptions(request);\n\n\t\tconst send = (options.protocol === 'https:' ? https__WEBPACK_IMPORTED_MODULE_3__ : http__WEBPACK_IMPORTED_MODULE_1__).request;\n\t\tconst signal = request.signal;\n\n\t\tlet response = null;\n\n\t\tconst abort = function abort() {\n\t\t\tlet error = new AbortError('The user aborted a request.');\n\t\t\treject(error);\n\t\t\tif (request.body && request.body instanceof stream__WEBPACK_IMPORTED_MODULE_0__.Readable) {\n\t\t\t\trequest.body.destroy(error);\n\t\t\t}\n\t\t\tif (!response || !response.body) return;\n\t\t\tresponse.body.emit('error', error);\n\t\t};\n\n\t\tif (signal && signal.aborted) {\n\t\t\tabort();\n\t\t\treturn;\n\t\t}\n\n\t\tconst abortAndFinalize = function abortAndFinalize() {\n\t\t\tabort();\n\t\t\tfinalize();\n\t\t};\n\n\t\t// send request\n\t\tconst req = send(options);\n\t\tlet reqTimeout;\n\n\t\tif (signal) {\n\t\t\tsignal.addEventListener('abort', abortAndFinalize);\n\t\t}\n\n\t\tfunction finalize() {\n\t\t\treq.abort();\n\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\tclearTimeout(reqTimeout);\n\t\t}\n\n\t\tif (request.timeout) {\n\t\t\treq.once('socket', function (socket) {\n\t\t\t\treqTimeout = setTimeout(function () {\n\t\t\t\t\treject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout'));\n\t\t\t\t\tfinalize();\n\t\t\t\t}, request.timeout);\n\t\t\t});\n\t\t}\n\n\t\treq.on('error', function (err) {\n\t\t\treject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));\n\t\t\tfinalize();\n\t\t});\n\n\t\treq.on('response', function (res) {\n\t\t\tclearTimeout(reqTimeout);\n\n\t\t\tconst headers = createHeadersLenient(res.headers);\n\n\t\t\t// HTTP fetch step 5\n\t\t\tif (fetch.isRedirect(res.statusCode)) {\n\t\t\t\t// HTTP fetch step 5.2\n\t\t\t\tconst location = headers.get('Location');\n\n\t\t\t\t// HTTP fetch step 5.3\n\t\t\t\tconst locationURL = location === null ? null : resolve_url(request.url, location);\n\n\t\t\t\t// HTTP fetch step 5.5\n\t\t\t\tswitch (request.redirect) {\n\t\t\t\t\tcase 'error':\n\t\t\t\t\t\treject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase 'manual':\n\t\t\t\t\t\t// node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL.\n\t\t\t\t\t\tif (locationURL !== null) {\n\t\t\t\t\t\t\t// handle corrupted header\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\theaders.set('Location', locationURL);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t// istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request\n\t\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'follow':\n\t\t\t\t\t\t// HTTP-redirect fetch step 2\n\t\t\t\t\t\tif (locationURL === null) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 5\n\t\t\t\t\t\tif (request.counter >= request.follow) {\n\t\t\t\t\t\t\treject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 6 (counter increment)\n\t\t\t\t\t\t// Create a new Request object.\n\t\t\t\t\t\tconst requestOpts = {\n\t\t\t\t\t\t\theaders: new Headers(request.headers),\n\t\t\t\t\t\t\tfollow: request.follow,\n\t\t\t\t\t\t\tcounter: request.counter + 1,\n\t\t\t\t\t\t\tagent: request.agent,\n\t\t\t\t\t\t\tcompress: request.compress,\n\t\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\t\tbody: request.body,\n\t\t\t\t\t\t\tsignal: request.signal,\n\t\t\t\t\t\t\ttimeout: request.timeout,\n\t\t\t\t\t\t\tsize: request.size\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 9\n\t\t\t\t\t\tif (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {\n\t\t\t\t\t\t\treject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));\n\t\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 11\n\t\t\t\t\t\tif (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') {\n\t\t\t\t\t\t\trequestOpts.method = 'GET';\n\t\t\t\t\t\t\trequestOpts.body = undefined;\n\t\t\t\t\t\t\trequestOpts.headers.delete('content-length');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// HTTP-redirect fetch step 15\n\t\t\t\t\t\tresolve(fetch(new Request(locationURL, requestOpts)));\n\t\t\t\t\t\tfinalize();\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// prepare response\n\t\t\tres.once('end', function () {\n\t\t\t\tif (signal) signal.removeEventListener('abort', abortAndFinalize);\n\t\t\t});\n\t\t\tlet body = res.pipe(new PassThrough$1());\n\n\t\t\tconst response_options = {\n\t\t\t\turl: request.url,\n\t\t\t\tstatus: res.statusCode,\n\t\t\t\tstatusText: res.statusMessage,\n\t\t\t\theaders: headers,\n\t\t\t\tsize: request.size,\n\t\t\t\ttimeout: request.timeout,\n\t\t\t\tcounter: request.counter\n\t\t\t};\n\n\t\t\t// HTTP-network fetch step 12.1.1.3\n\t\t\tconst codings = headers.get('Content-Encoding');\n\n\t\t\t// HTTP-network fetch step 12.1.1.4: handle content codings\n\n\t\t\t// in following scenarios we ignore compression support\n\t\t\t// 1. compression support is disabled\n\t\t\t// 2. HEAD request\n\t\t\t// 3. no Content-Encoding header\n\t\t\t// 4. no content response (204)\n\t\t\t// 5. content not modified response (304)\n\t\t\tif (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) {\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For Node v6+\n\t\t\t// Be less strict when decoding compressed responses, since sometimes\n\t\t\t// servers send slightly invalid responses that are still accepted\n\t\t\t// by common browsers.\n\t\t\t// Always using Z_SYNC_FLUSH is what cURL does.\n\t\t\tconst zlibOptions = {\n\t\t\t\tflush: zlib__WEBPACK_IMPORTED_MODULE_4__.Z_SYNC_FLUSH,\n\t\t\t\tfinishFlush: zlib__WEBPACK_IMPORTED_MODULE_4__.Z_SYNC_FLUSH\n\t\t\t};\n\n\t\t\t// for gzip\n\t\t\tif (codings == 'gzip' || codings == 'x-gzip') {\n\t\t\t\tbody = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createGunzip(zlibOptions));\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for deflate\n\t\t\tif (codings == 'deflate' || codings == 'x-deflate') {\n\t\t\t\t// handle the infamous raw deflate response from old servers\n\t\t\t\t// a hack for old IIS and Apache servers\n\t\t\t\tconst raw = res.pipe(new PassThrough$1());\n\t\t\t\traw.once('data', function (chunk) {\n\t\t\t\t\t// see http://stackoverflow.com/questions/37519828\n\t\t\t\t\tif ((chunk[0] & 0x0F) === 0x08) {\n\t\t\t\t\t\tbody = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createInflate());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbody = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createInflateRaw());\n\t\t\t\t\t}\n\t\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\t\tresolve(response);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// for br\n\t\t\tif (codings == 'br' && typeof zlib__WEBPACK_IMPORTED_MODULE_4__.createBrotliDecompress === 'function') {\n\t\t\t\tbody = body.pipe(zlib__WEBPACK_IMPORTED_MODULE_4__.createBrotliDecompress());\n\t\t\t\tresponse = new Response(body, response_options);\n\t\t\t\tresolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// otherwise, use response as-is\n\t\t\tresponse = new Response(body, response_options);\n\t\t\tresolve(response);\n\t\t});\n\n\t\twriteToStream(req, request);\n\t});\n}\n/**\n * Redirect code matching\n *\n * @param Number code Status code\n * @return Boolean\n */\nfetch.isRedirect = function (code) {\n\treturn code === 301 || code === 302 || code === 303 || code === 307 || code === 308;\n};\n\n// expose Promise\nfetch.Promise = global.Promise;\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (fetch);\n\n\n\n/***/ }),\n\n/***/ \"http\":\n/*!***********************!*\\\n !*** external \"http\" ***!\n \\***********************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"http\");\n\n/***/ }),\n\n/***/ \"https\":\n/*!************************!*\\\n !*** external \"https\" ***!\n \\************************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"https\");\n\n/***/ }),\n\n/***/ \"stream\":\n/*!*************************!*\\\n !*** external \"stream\" ***!\n \\*************************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"stream\");\n\n/***/ }),\n\n/***/ \"url\":\n/*!**********************!*\\\n !*** external \"url\" ***!\n \\**********************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"url\");\n\n/***/ }),\n\n/***/ \"zlib\":\n/*!***********************!*\\\n !*** external \"zlib\" ***!\n \\***********************/\n/*! no static exports found */\n/***/ (function(module, exports) {\n\nmodule.exports = require(\"zlib\");\n\n/***/ })\n\n/******/ });\n//# sourceMappingURL=d6e0e9d8aacfc3e11565.worker.js.map", __webpack_require__.p + "d6e0e9d8aacfc3e11565.worker.js");
|
|
997
2681
|
};
|
|
998
2682
|
|
|
999
2683
|
/***/ }),
|
|
@@ -1066,16 +2750,13 @@ var _TextDecoder;
|
|
|
1066
2750
|
var _TextEncoder;
|
|
1067
2751
|
|
|
1068
2752
|
if (typeof TextDecoder === 'undefined' || typeof TextEncoder === 'undefined') {
|
|
1069
|
-
// Wait to require text
|
|
1070
|
-
// evaluating ~500kb of encoding indices that we do not need to evaluate if
|
|
1071
|
-
// the browser provides TextDecoder and TextEncoder.
|
|
2753
|
+
// Wait to require the text encoding polyfill until we know it's needed.
|
|
1072
2754
|
// eslint-disable-next-line global-require
|
|
1073
|
-
var encoding = __webpack_require__(/*!
|
|
2755
|
+
var encoding = __webpack_require__(/*! fastestsmallesttextencoderdecoder */ "./node_modules/fastestsmallesttextencoderdecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs");
|
|
1074
2756
|
|
|
1075
2757
|
_TextDecoder = encoding.TextDecoder;
|
|
1076
2758
|
_TextEncoder = encoding.TextEncoder;
|
|
1077
2759
|
} else {
|
|
1078
|
-
/* global TextDecoder TextEncoder */
|
|
1079
2760
|
_TextDecoder = TextDecoder;
|
|
1080
2761
|
_TextEncoder = TextEncoder;
|
|
1081
2762
|
}
|
|
@@ -1100,7 +2781,7 @@ var memoizedToString = function () {
|
|
|
1100
2781
|
var fromCharCode = null;
|
|
1101
2782
|
var strings = {};
|
|
1102
2783
|
return function (assetId, data) {
|
|
1103
|
-
if (!
|
|
2784
|
+
if (!Object.prototype.hasOwnProperty.call(strings, assetId)) {
|
|
1104
2785
|
if (typeof btoa === 'undefined') {
|
|
1105
2786
|
// Use a library that does not need btoa to run.
|
|
1106
2787
|
|
|
@@ -1308,13 +2989,13 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
1308
2989
|
|
|
1309
2990
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
1310
2991
|
|
|
1311
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { 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); }; }
|
|
2992
|
+
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); }; }
|
|
1312
2993
|
|
|
1313
2994
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
1314
2995
|
|
|
1315
2996
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
1316
2997
|
|
|
1317
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
2998
|
+
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; } }
|
|
1318
2999
|
|
|
1319
3000
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
1320
3001
|
|
|
@@ -1346,19 +3027,19 @@ var DefaultAssets = [{
|
|
|
1346
3027
|
type: AssetType.ImageBitmap,
|
|
1347
3028
|
format: DataFormat.PNG,
|
|
1348
3029
|
id: null,
|
|
1349
|
-
data:
|
|
3030
|
+
data: Buffer.from(__webpack_require__(/*! arraybuffer-loader!./builtins/defaultBitmap.png */ "./node_modules/arraybuffer-loader/index.js!./src/builtins/defaultBitmap.png") // eslint-disable-line global-require
|
|
1350
3031
|
)
|
|
1351
3032
|
}, {
|
|
1352
3033
|
type: AssetType.Sound,
|
|
1353
3034
|
format: DataFormat.WAV,
|
|
1354
3035
|
id: null,
|
|
1355
|
-
data:
|
|
3036
|
+
data: Buffer.from(__webpack_require__(/*! arraybuffer-loader!./builtins/defaultSound.wav */ "./node_modules/arraybuffer-loader/index.js!./src/builtins/defaultSound.wav") // eslint-disable-line global-require
|
|
1356
3037
|
)
|
|
1357
3038
|
}, {
|
|
1358
3039
|
type: AssetType.ImageVector,
|
|
1359
3040
|
format: DataFormat.SVG,
|
|
1360
3041
|
id: null,
|
|
1361
|
-
data:
|
|
3042
|
+
data: Buffer.from(__webpack_require__(/*! arraybuffer-loader!./builtins/defaultVector.svg */ "./node_modules/arraybuffer-loader/index.js!./src/builtins/defaultVector.svg") // eslint-disable-line global-require
|
|
1362
3043
|
)
|
|
1363
3044
|
}];
|
|
1364
3045
|
/**
|
|
@@ -1416,7 +3097,7 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
|
|
|
1416
3097
|
value: function get(assetId) {
|
|
1417
3098
|
var asset = null;
|
|
1418
3099
|
|
|
1419
|
-
if (
|
|
3100
|
+
if (Object.prototype.hasOwnProperty.call(this.assets, assetId)) {
|
|
1420
3101
|
/** @type{BuiltinAssetRecord} */
|
|
1421
3102
|
var assetRecord = this.assets[assetId];
|
|
1422
3103
|
asset = new Asset(assetRecord.type, assetRecord.id, assetRecord.format, assetRecord.data);
|
|
@@ -1471,7 +3152,7 @@ var BuiltinHelper = /*#__PURE__*/function (_Helper) {
|
|
|
1471
3152
|
if (!dataFormat) throw new Error('Data cached without specifying its format');
|
|
1472
3153
|
|
|
1473
3154
|
if (id !== '' && id !== null && typeof id !== 'undefined') {
|
|
1474
|
-
if (
|
|
3155
|
+
if (Object.prototype.hasOwnProperty.call(this.assets, id) && assetType.immutable) return id;
|
|
1475
3156
|
} else if (assetType.immutable) {
|
|
1476
3157
|
id = md5(data);
|
|
1477
3158
|
} else {
|
|
@@ -1543,7 +3224,10 @@ module.exports = DataFormat;
|
|
|
1543
3224
|
!*** ./src/FetchTool.js ***!
|
|
1544
3225
|
\**************************/
|
|
1545
3226
|
/*! no static exports found */
|
|
1546
|
-
/***/ (function(module, exports) {
|
|
3227
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3228
|
+
|
|
3229
|
+
/* WEBPACK VAR INJECTION */(function(fetch) {var _excluded = ["url"],
|
|
3230
|
+
_excluded2 = ["url", "withCredentials"];
|
|
1547
3231
|
|
|
1548
3232
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1549
3233
|
|
|
@@ -1566,17 +3250,27 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1566
3250
|
}
|
|
1567
3251
|
|
|
1568
3252
|
_createClass(FetchTool, [{
|
|
1569
|
-
key: "
|
|
1570
|
-
|
|
3253
|
+
key: "isGetSupported",
|
|
3254
|
+
get:
|
|
3255
|
+
/**
|
|
3256
|
+
* Is get supported? false if the environment does not support fetch.
|
|
3257
|
+
* @returns {boolean} Is get supported?
|
|
3258
|
+
*/
|
|
3259
|
+
function get() {
|
|
3260
|
+
return typeof fetch !== 'undefined';
|
|
3261
|
+
}
|
|
1571
3262
|
/**
|
|
1572
3263
|
* Request data from a server with fetch.
|
|
1573
3264
|
* @param {{url:string}} reqConfig - Request configuration for data to get.
|
|
1574
3265
|
* @param {{method:string}} options - Additional options to configure fetch.
|
|
1575
3266
|
* @returns {Promise.<Uint8Array>} Resolve to Buffer of data from server.
|
|
1576
3267
|
*/
|
|
3268
|
+
|
|
3269
|
+
}, {
|
|
3270
|
+
key: "get",
|
|
1577
3271
|
value: function get(_ref) {
|
|
1578
3272
|
var url = _ref.url,
|
|
1579
|
-
options = _objectWithoutProperties(_ref,
|
|
3273
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
1580
3274
|
|
|
1581
3275
|
return fetch(url, Object.assign({
|
|
1582
3276
|
method: 'GET'
|
|
@@ -1593,18 +3287,23 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1593
3287
|
*/
|
|
1594
3288
|
|
|
1595
3289
|
}, {
|
|
1596
|
-
key: "
|
|
1597
|
-
|
|
3290
|
+
key: "isSendSupported",
|
|
3291
|
+
get: function get() {
|
|
3292
|
+
return typeof fetch !== 'undefined';
|
|
3293
|
+
}
|
|
1598
3294
|
/**
|
|
1599
3295
|
* Send data to a server with fetch.
|
|
1600
3296
|
* @param {Request} reqConfig - Request configuration for data to send.
|
|
1601
3297
|
* @returns {Promise.<string>} Server returned metadata.
|
|
1602
3298
|
*/
|
|
3299
|
+
|
|
3300
|
+
}, {
|
|
3301
|
+
key: "send",
|
|
1603
3302
|
value: function send(_ref2) {
|
|
1604
3303
|
var url = _ref2.url,
|
|
1605
3304
|
_ref2$withCredentials = _ref2.withCredentials,
|
|
1606
3305
|
withCredentials = _ref2$withCredentials === void 0 ? false : _ref2$withCredentials,
|
|
1607
|
-
options = _objectWithoutProperties(_ref2,
|
|
3306
|
+
options = _objectWithoutProperties(_ref2, _excluded2);
|
|
1608
3307
|
|
|
1609
3308
|
return fetch(url, Object.assign({
|
|
1610
3309
|
credentials: withCredentials ? 'include' : 'omit'
|
|
@@ -1613,27 +3312,13 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1613
3312
|
return Promise.reject(response.status);
|
|
1614
3313
|
});
|
|
1615
3314
|
}
|
|
1616
|
-
}, {
|
|
1617
|
-
key: "isGetSupported",
|
|
1618
|
-
|
|
1619
|
-
/**
|
|
1620
|
-
* Is get supported? false if the environment does not support fetch.
|
|
1621
|
-
* @returns {boolean} Is get supported?
|
|
1622
|
-
*/
|
|
1623
|
-
get: function get() {
|
|
1624
|
-
return typeof fetch !== 'undefined';
|
|
1625
|
-
}
|
|
1626
|
-
}, {
|
|
1627
|
-
key: "isSendSupported",
|
|
1628
|
-
get: function get() {
|
|
1629
|
-
return typeof fetch !== 'undefined';
|
|
1630
|
-
}
|
|
1631
3315
|
}]);
|
|
1632
3316
|
|
|
1633
3317
|
return FetchTool;
|
|
1634
3318
|
}();
|
|
1635
3319
|
|
|
1636
3320
|
module.exports = FetchTool;
|
|
3321
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/lib/index.mjs")["default"]))
|
|
1637
3322
|
|
|
1638
3323
|
/***/ }),
|
|
1639
3324
|
|
|
@@ -1644,11 +3329,13 @@ module.exports = FetchTool;
|
|
|
1644
3329
|
/*! no static exports found */
|
|
1645
3330
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1646
3331
|
|
|
3332
|
+
/* WEBPACK VAR INJECTION */(function(fetch) {var _excluded = ["url"];
|
|
3333
|
+
|
|
1647
3334
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1648
3335
|
|
|
1649
3336
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1650
3337
|
|
|
1651
|
-
function _createForOfIteratorHelper(o) {
|
|
3338
|
+
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; } } }; }
|
|
1652
3339
|
|
|
1653
3340
|
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); }
|
|
1654
3341
|
|
|
@@ -1748,19 +3435,24 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1748
3435
|
|
|
1749
3436
|
|
|
1750
3437
|
_createClass(PrivateFetchWorkerTool, [{
|
|
1751
|
-
key: "
|
|
1752
|
-
|
|
3438
|
+
key: "isGetSupported",
|
|
3439
|
+
get: function get() {
|
|
3440
|
+
return typeof Worker !== 'undefined' && this._workerSupport.fetch && !this._supportError;
|
|
3441
|
+
}
|
|
1753
3442
|
/**
|
|
1754
3443
|
* Request data from a server with a worker using fetch.
|
|
1755
3444
|
* @param {{url:string}} reqConfig - Request configuration for data to get.
|
|
1756
3445
|
* @param {{method:string}} options - Additional options to configure fetch.
|
|
1757
3446
|
* @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
|
|
1758
3447
|
*/
|
|
3448
|
+
|
|
3449
|
+
}, {
|
|
3450
|
+
key: "get",
|
|
1759
3451
|
value: function get(_ref2) {
|
|
1760
3452
|
var _this2 = this;
|
|
1761
3453
|
|
|
1762
3454
|
var url = _ref2.url,
|
|
1763
|
-
options = _objectWithoutProperties(_ref2,
|
|
3455
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
1764
3456
|
|
|
1765
3457
|
return new Promise(function (resolve, reject) {
|
|
1766
3458
|
// TODO: Use a Scratch standard ID generator ...
|
|
@@ -1789,12 +3481,17 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1789
3481
|
*/
|
|
1790
3482
|
|
|
1791
3483
|
}, {
|
|
1792
|
-
key: "
|
|
1793
|
-
|
|
3484
|
+
key: "isSendSupported",
|
|
3485
|
+
get: function get() {
|
|
3486
|
+
return false;
|
|
3487
|
+
}
|
|
1794
3488
|
/**
|
|
1795
|
-
* Send data to a server
|
|
3489
|
+
* Send data to a server.
|
|
1796
3490
|
* @throws {Error} A not implemented error.
|
|
1797
3491
|
*/
|
|
3492
|
+
|
|
3493
|
+
}, {
|
|
3494
|
+
key: "send",
|
|
1798
3495
|
value: function send() {
|
|
1799
3496
|
throw new Error('Not implemented.');
|
|
1800
3497
|
}
|
|
@@ -1804,16 +3501,6 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1804
3501
|
* instance
|
|
1805
3502
|
*/
|
|
1806
3503
|
|
|
1807
|
-
}, {
|
|
1808
|
-
key: "isGetSupported",
|
|
1809
|
-
get: function get() {
|
|
1810
|
-
return typeof Worker !== 'undefined' && this._workerSupport.fetch && !this._supportError;
|
|
1811
|
-
}
|
|
1812
|
-
}, {
|
|
1813
|
-
key: "isSendSupported",
|
|
1814
|
-
get: function get() {
|
|
1815
|
-
return false;
|
|
1816
|
-
}
|
|
1817
3504
|
}], [{
|
|
1818
3505
|
key: "instance",
|
|
1819
3506
|
get: function get() {
|
|
@@ -1850,13 +3537,18 @@ var PublicFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1850
3537
|
|
|
1851
3538
|
|
|
1852
3539
|
_createClass(PublicFetchWorkerTool, [{
|
|
1853
|
-
key: "
|
|
1854
|
-
|
|
3540
|
+
key: "isGetSupported",
|
|
3541
|
+
get: function get() {
|
|
3542
|
+
return this.inner.isGetSupported;
|
|
3543
|
+
}
|
|
1855
3544
|
/**
|
|
1856
3545
|
* Request data from a server with a worker that uses fetch.
|
|
1857
3546
|
* @param {{url:string}} reqConfig - Request configuration for data to get.
|
|
1858
3547
|
* @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
|
|
1859
3548
|
*/
|
|
3549
|
+
|
|
3550
|
+
}, {
|
|
3551
|
+
key: "get",
|
|
1860
3552
|
value: function get(reqConfig) {
|
|
1861
3553
|
return this.inner.get(reqConfig);
|
|
1862
3554
|
}
|
|
@@ -1866,31 +3558,27 @@ var PublicFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1866
3558
|
*/
|
|
1867
3559
|
|
|
1868
3560
|
}, {
|
|
1869
|
-
key: "
|
|
1870
|
-
|
|
3561
|
+
key: "isSendSupported",
|
|
3562
|
+
get: function get() {
|
|
3563
|
+
return false;
|
|
3564
|
+
}
|
|
1871
3565
|
/**
|
|
1872
3566
|
* Send data to a server with a worker that uses fetch.
|
|
1873
3567
|
* @throws {Error} A not implemented error.
|
|
1874
3568
|
*/
|
|
3569
|
+
|
|
3570
|
+
}, {
|
|
3571
|
+
key: "send",
|
|
1875
3572
|
value: function send() {
|
|
1876
3573
|
throw new Error('Not implemented.');
|
|
1877
3574
|
}
|
|
1878
|
-
}, {
|
|
1879
|
-
key: "isGetSupported",
|
|
1880
|
-
get: function get() {
|
|
1881
|
-
return this.inner.isGetSupported;
|
|
1882
|
-
}
|
|
1883
|
-
}, {
|
|
1884
|
-
key: "isSendSupported",
|
|
1885
|
-
get: function get() {
|
|
1886
|
-
return false;
|
|
1887
|
-
}
|
|
1888
3575
|
}]);
|
|
1889
3576
|
|
|
1890
3577
|
return PublicFetchWorkerTool;
|
|
1891
3578
|
}();
|
|
1892
3579
|
|
|
1893
3580
|
module.exports = PublicFetchWorkerTool;
|
|
3581
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/lib/index.mjs")["default"]))
|
|
1894
3582
|
|
|
1895
3583
|
/***/ }),
|
|
1896
3584
|
|
|
@@ -1940,111 +3628,6 @@ module.exports = Helper;
|
|
|
1940
3628
|
|
|
1941
3629
|
/***/ }),
|
|
1942
3630
|
|
|
1943
|
-
/***/ "./src/NetsTool.js":
|
|
1944
|
-
/*!*************************!*\
|
|
1945
|
-
!*** ./src/NetsTool.js ***!
|
|
1946
|
-
\*************************/
|
|
1947
|
-
/*! no static exports found */
|
|
1948
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1949
|
-
|
|
1950
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
1951
|
-
|
|
1952
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
1953
|
-
|
|
1954
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
1955
|
-
|
|
1956
|
-
/**
|
|
1957
|
-
* Get and send assets with the npm nets package.
|
|
1958
|
-
*/
|
|
1959
|
-
var NetsTool = /*#__PURE__*/function () {
|
|
1960
|
-
function NetsTool() {
|
|
1961
|
-
_classCallCheck(this, NetsTool);
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
_createClass(NetsTool, [{
|
|
1965
|
-
key: "get",
|
|
1966
|
-
|
|
1967
|
-
/**
|
|
1968
|
-
* Request data from a server with nets.
|
|
1969
|
-
* @param {{url:string}} reqConfig - Request configuration for data to get.
|
|
1970
|
-
* @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
|
|
1971
|
-
*/
|
|
1972
|
-
value: function get(reqConfig) {
|
|
1973
|
-
return new Promise(function (resolve, reject) {
|
|
1974
|
-
/* eslint global-require:0 */
|
|
1975
|
-
// Wait to evaluate nets and its dependencies until we know we need
|
|
1976
|
-
// it as NetsTool may never be used if fetch is available.
|
|
1977
|
-
var nets = __webpack_require__(/*! nets */ "nets");
|
|
1978
|
-
|
|
1979
|
-
nets(Object.assign({
|
|
1980
|
-
method: 'get'
|
|
1981
|
-
}, reqConfig), function (err, resp, body) {
|
|
1982
|
-
// body is a Buffer
|
|
1983
|
-
if (err || Math.floor(resp.statusCode / 100) !== 2) {
|
|
1984
|
-
reject(err || resp.statusCode);
|
|
1985
|
-
} else {
|
|
1986
|
-
resolve(body);
|
|
1987
|
-
}
|
|
1988
|
-
});
|
|
1989
|
-
});
|
|
1990
|
-
}
|
|
1991
|
-
/**
|
|
1992
|
-
* Is sending supported? false if the environment does not support sending
|
|
1993
|
-
* with nets.
|
|
1994
|
-
* @returns {boolean} Is sending supported?
|
|
1995
|
-
*/
|
|
1996
|
-
|
|
1997
|
-
}, {
|
|
1998
|
-
key: "send",
|
|
1999
|
-
|
|
2000
|
-
/**
|
|
2001
|
-
* Send data to a server with nets.
|
|
2002
|
-
* @param {Request} reqConfig - Request configuration for data to send.
|
|
2003
|
-
* @returns {Promise.<Buffer|string|object>} Server returned metadata.
|
|
2004
|
-
*/
|
|
2005
|
-
value: function send(reqConfig) {
|
|
2006
|
-
return new Promise(function (resolve, reject) {
|
|
2007
|
-
// eslint-disable-next-lint global-require
|
|
2008
|
-
// Wait to evaluate nets and its dependencies until we know we need
|
|
2009
|
-
// it as NetsTool may never be used if fetch is available.
|
|
2010
|
-
var nets = __webpack_require__(/*! nets */ "nets");
|
|
2011
|
-
|
|
2012
|
-
nets(Object.assign({
|
|
2013
|
-
encoding: undefined // eslint-disable-line no-undefined
|
|
2014
|
-
|
|
2015
|
-
}, reqConfig), function (err, resp, body) {
|
|
2016
|
-
if (err || Math.floor(resp.statusCode / 100) !== 2) {
|
|
2017
|
-
reject(err || resp.statusCode);
|
|
2018
|
-
} else {
|
|
2019
|
-
resolve(body);
|
|
2020
|
-
}
|
|
2021
|
-
});
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
}, {
|
|
2025
|
-
key: "isGetSupported",
|
|
2026
|
-
|
|
2027
|
-
/**
|
|
2028
|
-
* Is get supported? false if the environment does not support nets.
|
|
2029
|
-
* @returns {boolean} Is get supported?
|
|
2030
|
-
*/
|
|
2031
|
-
get: function get() {
|
|
2032
|
-
return true;
|
|
2033
|
-
}
|
|
2034
|
-
}, {
|
|
2035
|
-
key: "isSendSupported",
|
|
2036
|
-
get: function get() {
|
|
2037
|
-
return true;
|
|
2038
|
-
}
|
|
2039
|
-
}]);
|
|
2040
|
-
|
|
2041
|
-
return NetsTool;
|
|
2042
|
-
}();
|
|
2043
|
-
|
|
2044
|
-
module.exports = NetsTool;
|
|
2045
|
-
|
|
2046
|
-
/***/ }),
|
|
2047
|
-
|
|
2048
3631
|
/***/ "./src/ProxyTool.js":
|
|
2049
3632
|
/*!**************************!*\
|
|
2050
3633
|
!*** ./src/ProxyTool.js ***!
|
|
@@ -2061,8 +3644,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
2061
3644
|
var FetchWorkerTool = __webpack_require__(/*! ./FetchWorkerTool */ "./src/FetchWorkerTool.js");
|
|
2062
3645
|
|
|
2063
3646
|
var FetchTool = __webpack_require__(/*! ./FetchTool */ "./src/FetchTool.js");
|
|
2064
|
-
|
|
2065
|
-
var NetsTool = __webpack_require__(/*! ./NetsTool */ "./src/NetsTool.js");
|
|
2066
3647
|
/**
|
|
2067
3648
|
* @typedef {object} Request
|
|
2068
3649
|
* @property {string} url
|
|
@@ -2085,9 +3666,9 @@ var ProxyTool = /*#__PURE__*/function () {
|
|
|
2085
3666
|
var tools;
|
|
2086
3667
|
|
|
2087
3668
|
if (filter === ProxyTool.TOOL_FILTER.READY) {
|
|
2088
|
-
tools = [new FetchTool()
|
|
3669
|
+
tools = [new FetchTool()];
|
|
2089
3670
|
} else {
|
|
2090
|
-
tools = [new FetchWorkerTool(), new FetchTool()
|
|
3671
|
+
tools = [new FetchWorkerTool(), new FetchTool()];
|
|
2091
3672
|
}
|
|
2092
3673
|
/**
|
|
2093
3674
|
* Sequence of tools to proxy.
|
|
@@ -2104,13 +3685,20 @@ var ProxyTool = /*#__PURE__*/function () {
|
|
|
2104
3685
|
|
|
2105
3686
|
|
|
2106
3687
|
_createClass(ProxyTool, [{
|
|
2107
|
-
key: "
|
|
2108
|
-
|
|
3688
|
+
key: "isGetSupported",
|
|
3689
|
+
get: function get() {
|
|
3690
|
+
return this.tools.some(function (tool) {
|
|
3691
|
+
return tool.isGetSupported;
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
2109
3694
|
/**
|
|
2110
3695
|
* Request data from with one of the proxied tools.
|
|
2111
3696
|
* @param {Request} reqConfig - Request configuration for data to get.
|
|
2112
3697
|
* @returns {Promise.<Buffer>} Resolve to Buffer of data from server.
|
|
2113
3698
|
*/
|
|
3699
|
+
|
|
3700
|
+
}, {
|
|
3701
|
+
key: "get",
|
|
2114
3702
|
value: function get(reqConfig) {
|
|
2115
3703
|
var _this = this;
|
|
2116
3704
|
|
|
@@ -2138,13 +3726,20 @@ var ProxyTool = /*#__PURE__*/function () {
|
|
|
2138
3726
|
*/
|
|
2139
3727
|
|
|
2140
3728
|
}, {
|
|
2141
|
-
key: "
|
|
2142
|
-
|
|
3729
|
+
key: "isSendSupported",
|
|
3730
|
+
get: function get() {
|
|
3731
|
+
return this.tools.some(function (tool) {
|
|
3732
|
+
return tool.isSendSupported;
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
2143
3735
|
/**
|
|
2144
3736
|
* Send data to a server with one of the proxied tools.
|
|
2145
3737
|
* @param {Request} reqConfig - Request configuration for data to send.
|
|
2146
3738
|
* @returns {Promise.<Buffer|string|object>} Server returned metadata.
|
|
2147
3739
|
*/
|
|
3740
|
+
|
|
3741
|
+
}, {
|
|
3742
|
+
key: "send",
|
|
2148
3743
|
value: function send(reqConfig) {
|
|
2149
3744
|
var _this2 = this;
|
|
2150
3745
|
|
|
@@ -2166,20 +3761,6 @@ var ProxyTool = /*#__PURE__*/function () {
|
|
|
2166
3761
|
|
|
2167
3762
|
return nextTool();
|
|
2168
3763
|
}
|
|
2169
|
-
}, {
|
|
2170
|
-
key: "isGetSupported",
|
|
2171
|
-
get: function get() {
|
|
2172
|
-
return this.tools.some(function (tool) {
|
|
2173
|
-
return tool.isGetSupported;
|
|
2174
|
-
});
|
|
2175
|
-
}
|
|
2176
|
-
}, {
|
|
2177
|
-
key: "isSendSupported",
|
|
2178
|
-
get: function get() {
|
|
2179
|
-
return this.tools.some(function (tool) {
|
|
2180
|
-
return tool.isSendSupported;
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
3764
|
}]);
|
|
2184
3765
|
|
|
2185
3766
|
return ProxyTool;
|
|
@@ -2253,8 +3834,39 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2253
3834
|
|
|
2254
3835
|
|
|
2255
3836
|
_createClass(ScratchStorage, [{
|
|
2256
|
-
key: "
|
|
3837
|
+
key: "Asset",
|
|
3838
|
+
get: function get() {
|
|
3839
|
+
return _Asset;
|
|
3840
|
+
}
|
|
3841
|
+
/**
|
|
3842
|
+
* @return {AssetType} - the list of supported asset types.
|
|
3843
|
+
* @constructor
|
|
3844
|
+
*/
|
|
3845
|
+
|
|
3846
|
+
}, {
|
|
3847
|
+
key: "AssetType",
|
|
3848
|
+
get: function get() {
|
|
3849
|
+
return _AssetType;
|
|
3850
|
+
}
|
|
3851
|
+
/**
|
|
3852
|
+
* @return {DataFormat} - the list of supported data formats.
|
|
3853
|
+
* @constructor
|
|
3854
|
+
*/
|
|
3855
|
+
|
|
3856
|
+
}, {
|
|
3857
|
+
key: "DataFormat",
|
|
3858
|
+
get: function get() {
|
|
3859
|
+
return _DataFormat;
|
|
3860
|
+
}
|
|
3861
|
+
/**
|
|
3862
|
+
* @deprecated Please use the `Asset` member of a storage instance instead.
|
|
3863
|
+
* @return {Asset} - the `Asset` class constructor.
|
|
3864
|
+
* @constructor
|
|
3865
|
+
*/
|
|
2257
3866
|
|
|
3867
|
+
}, {
|
|
3868
|
+
key: "addHelper",
|
|
3869
|
+
value:
|
|
2258
3870
|
/**
|
|
2259
3871
|
* Add a storage helper to this manager. Helpers with a higher priority number will be checked first when loading
|
|
2260
3872
|
* or storing assets. For comparison, the helper for built-in assets has `priority=100` and the default web helper
|
|
@@ -2262,7 +3874,7 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2262
3874
|
* @param {Helper} helper - the helper to be added.
|
|
2263
3875
|
* @param {number} [priority] - the priority for this new helper (default: 0).
|
|
2264
3876
|
*/
|
|
2265
|
-
|
|
3877
|
+
function addHelper(helper) {
|
|
2266
3878
|
var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2267
3879
|
|
|
2268
3880
|
this._helpers.push({
|
|
@@ -2351,7 +3963,7 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2351
3963
|
}, {
|
|
2352
3964
|
key: "getDefaultAssetId",
|
|
2353
3965
|
value: function getDefaultAssetId(type) {
|
|
2354
|
-
if (
|
|
3966
|
+
if (Object.prototype.hasOwnProperty.call(this.defaultAssetId, type.name)) {
|
|
2355
3967
|
return this.defaultAssetId[type.name];
|
|
2356
3968
|
}
|
|
2357
3969
|
}
|
|
@@ -2448,37 +4060,6 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2448
4060
|
});
|
|
2449
4061
|
});
|
|
2450
4062
|
}
|
|
2451
|
-
}, {
|
|
2452
|
-
key: "Asset",
|
|
2453
|
-
get: function get() {
|
|
2454
|
-
return _Asset;
|
|
2455
|
-
}
|
|
2456
|
-
/**
|
|
2457
|
-
* @return {AssetType} - the list of supported asset types.
|
|
2458
|
-
* @constructor
|
|
2459
|
-
*/
|
|
2460
|
-
|
|
2461
|
-
}, {
|
|
2462
|
-
key: "AssetType",
|
|
2463
|
-
get: function get() {
|
|
2464
|
-
return _AssetType;
|
|
2465
|
-
}
|
|
2466
|
-
/**
|
|
2467
|
-
* @return {DataFormat} - the list of supported data formats.
|
|
2468
|
-
* @constructor
|
|
2469
|
-
*/
|
|
2470
|
-
|
|
2471
|
-
}, {
|
|
2472
|
-
key: "DataFormat",
|
|
2473
|
-
get: function get() {
|
|
2474
|
-
return _DataFormat;
|
|
2475
|
-
}
|
|
2476
|
-
/**
|
|
2477
|
-
* @deprecated Please use the `Asset` member of a storage instance instead.
|
|
2478
|
-
* @return {Asset} - the `Asset` class constructor.
|
|
2479
|
-
* @constructor
|
|
2480
|
-
*/
|
|
2481
|
-
|
|
2482
4063
|
}], [{
|
|
2483
4064
|
key: "Asset",
|
|
2484
4065
|
get: function get() {
|
|
@@ -2523,13 +4104,13 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
2523
4104
|
|
|
2524
4105
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
2525
4106
|
|
|
2526
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { 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); }; }
|
|
4107
|
+
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); }; }
|
|
2527
4108
|
|
|
2528
4109
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
2529
4110
|
|
|
2530
4111
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
2531
4112
|
|
|
2532
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
4113
|
+
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; } }
|
|
2533
4114
|
|
|
2534
4115
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
2535
4116
|
|
|
@@ -2554,7 +4135,7 @@ var ensureRequestConfig = function ensureRequestConfig(reqConfig) {
|
|
|
2554
4135
|
* @typedef {function} UrlFunction - A function which computes a URL from asset information.
|
|
2555
4136
|
* @param {Asset} - The asset for which the URL should be computed.
|
|
2556
4137
|
* @returns {(string|object)} - A string representing the URL for the asset request OR an object with configuration for
|
|
2557
|
-
* the underlying
|
|
4138
|
+
* the underlying fetch call (necessary for configuring e.g. authentication)
|
|
2558
4139
|
*/
|
|
2559
4140
|
|
|
2560
4141
|
|
|
@@ -2707,7 +4288,7 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
|
|
|
2707
4288
|
);
|
|
2708
4289
|
})[0];
|
|
2709
4290
|
var method = create ? 'post' : 'put';
|
|
2710
|
-
if (!store) return Promise.reject('No appropriate stores');
|
|
4291
|
+
if (!store) return Promise.reject(new Error('No appropriate stores'));
|
|
2711
4292
|
var tool = this.assetTool;
|
|
2712
4293
|
|
|
2713
4294
|
if (assetType.name === 'Project') {
|
|
@@ -2790,25 +4371,36 @@ module.exports = require("base64-js");
|
|
|
2790
4371
|
|
|
2791
4372
|
/***/ }),
|
|
2792
4373
|
|
|
2793
|
-
/***/ "
|
|
2794
|
-
|
|
2795
|
-
!*** external "
|
|
2796
|
-
|
|
4374
|
+
/***/ "http":
|
|
4375
|
+
/*!***********************!*\
|
|
4376
|
+
!*** external "http" ***!
|
|
4377
|
+
\***********************/
|
|
2797
4378
|
/*! no static exports found */
|
|
2798
4379
|
/***/ (function(module, exports) {
|
|
2799
4380
|
|
|
2800
|
-
module.exports = require("
|
|
4381
|
+
module.exports = require("http");
|
|
2801
4382
|
|
|
2802
4383
|
/***/ }),
|
|
2803
4384
|
|
|
2804
|
-
/***/ "
|
|
2805
|
-
|
|
2806
|
-
!*** external "
|
|
2807
|
-
|
|
4385
|
+
/***/ "https":
|
|
4386
|
+
/*!************************!*\
|
|
4387
|
+
!*** external "https" ***!
|
|
4388
|
+
\************************/
|
|
2808
4389
|
/*! no static exports found */
|
|
2809
4390
|
/***/ (function(module, exports) {
|
|
2810
4391
|
|
|
2811
|
-
module.exports = require("
|
|
4392
|
+
module.exports = require("https");
|
|
4393
|
+
|
|
4394
|
+
/***/ }),
|
|
4395
|
+
|
|
4396
|
+
/***/ "js-md5":
|
|
4397
|
+
/*!*************************!*\
|
|
4398
|
+
!*** external "js-md5" ***!
|
|
4399
|
+
\*************************/
|
|
4400
|
+
/*! no static exports found */
|
|
4401
|
+
/***/ (function(module, exports) {
|
|
4402
|
+
|
|
4403
|
+
module.exports = require("js-md5");
|
|
2812
4404
|
|
|
2813
4405
|
/***/ }),
|
|
2814
4406
|
|
|
@@ -2823,14 +4415,14 @@ module.exports = require("stream");
|
|
|
2823
4415
|
|
|
2824
4416
|
/***/ }),
|
|
2825
4417
|
|
|
2826
|
-
/***/ "
|
|
2827
|
-
|
|
2828
|
-
!*** external "
|
|
2829
|
-
|
|
4418
|
+
/***/ "url":
|
|
4419
|
+
/*!**********************!*\
|
|
4420
|
+
!*** external "url" ***!
|
|
4421
|
+
\**********************/
|
|
2830
4422
|
/*! no static exports found */
|
|
2831
4423
|
/***/ (function(module, exports) {
|
|
2832
4424
|
|
|
2833
|
-
module.exports = require("
|
|
4425
|
+
module.exports = require("url");
|
|
2834
4426
|
|
|
2835
4427
|
/***/ }),
|
|
2836
4428
|
|
|
@@ -2843,6 +4435,17 @@ module.exports = require("text-encoding");
|
|
|
2843
4435
|
|
|
2844
4436
|
module.exports = require("util");
|
|
2845
4437
|
|
|
4438
|
+
/***/ }),
|
|
4439
|
+
|
|
4440
|
+
/***/ "zlib":
|
|
4441
|
+
/*!***********************!*\
|
|
4442
|
+
!*** external "zlib" ***!
|
|
4443
|
+
\***********************/
|
|
4444
|
+
/*! no static exports found */
|
|
4445
|
+
/***/ (function(module, exports) {
|
|
4446
|
+
|
|
4447
|
+
module.exports = require("zlib");
|
|
4448
|
+
|
|
2846
4449
|
/***/ })
|
|
2847
4450
|
|
|
2848
4451
|
/******/ });
|