scratch-storage 1.3.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +1 -1
- package/.gitattributes +1 -0
- package/dist/node/50604be620465cc30dd8.worker.js +1906 -0
- package/dist/node/50604be620465cc30dd8.worker.js.map +1 -0
- package/dist/node/scratch-storage.js +1743 -21
- package/dist/node/scratch-storage.js.map +1 -1
- package/dist/{node/4816ce2aa9bf12df8b86.worker.js → web/3770307661f114ec2389.worker.js} +5 -3
- package/dist/{node/4816ce2aa9bf12df8b86.worker.js.map → web/3770307661f114ec2389.worker.js.map} +1 -1
- package/dist/web/scratch-storage.js +36 -20
- package/dist/web/scratch-storage.js.map +1 -1
- package/dist/web/scratch-storage.min.js +36 -20
- package/dist/web/scratch-storage.min.js.map +1 -1
- package/package.json +15 -15
- package/renovate.json5 +7 -0
- package/src/BuiltinHelper.js +3 -3
- package/src/FetchTool.js +5 -2
- package/src/FetchWorkerTool.worker.js +5 -1
- package/src/ScratchStorage.js +4 -4
- package/src/WebHelper.js +15 -4
- package/test/integration/download-known-assets.js +1 -2
- package/test/unit/fetch-tool.js +53 -5
- package/webpack.config.js +7 -1
- package/dist/web/3325b91e8645157f8dc6.worker.js +0 -188
- package/dist/web/3325b91e8645157f8dc6.worker.js.map +0 -1
|
@@ -1007,6 +1007,1666 @@ function color(fg, isInverse) {
|
|
|
1007
1007
|
module.exports = color;
|
|
1008
1008
|
|
|
1009
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
|
+
|
|
1010
2670
|
/***/ }),
|
|
1011
2671
|
|
|
1012
2672
|
/***/ "./node_modules/worker-loader/dist/cjs.js?{\"inline\":true,\"fallback\":true}!./src/FetchWorkerTool.worker.js":
|
|
@@ -1017,7 +2677,7 @@ module.exports = color;
|
|
|
1017
2677
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1018
2678
|
|
|
1019
2679
|
module.exports = function() {
|
|
1020
|
-
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 (result) {\n if (result.ok) return result.arrayBuffer();\n if (result.status === 404) return null;\n return Promise.reject(result.status);\n }).then(function (buffer) {\n return complete.push({\n id: job.id,\n buffer: buffer\n });\n }).catch(function (error) {\n return complete.push({\n id: job.id,\n error: error\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=50604be620465cc30dd8.worker.js.map", __webpack_require__.p + "50604be620465cc30dd8.worker.js");
|
|
1021
2681
|
};
|
|
1022
2682
|
|
|
1023
2683
|
/***/ }),
|
|
@@ -1367,19 +3027,19 @@ var DefaultAssets = [{
|
|
|
1367
3027
|
type: AssetType.ImageBitmap,
|
|
1368
3028
|
format: DataFormat.PNG,
|
|
1369
3029
|
id: null,
|
|
1370
|
-
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
|
|
1371
3031
|
)
|
|
1372
3032
|
}, {
|
|
1373
3033
|
type: AssetType.Sound,
|
|
1374
3034
|
format: DataFormat.WAV,
|
|
1375
3035
|
id: null,
|
|
1376
|
-
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
|
|
1377
3037
|
)
|
|
1378
3038
|
}, {
|
|
1379
3039
|
type: AssetType.ImageVector,
|
|
1380
3040
|
format: DataFormat.SVG,
|
|
1381
3041
|
id: null,
|
|
1382
|
-
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
|
|
1383
3043
|
)
|
|
1384
3044
|
}];
|
|
1385
3045
|
/**
|
|
@@ -1564,7 +3224,10 @@ module.exports = DataFormat;
|
|
|
1564
3224
|
!*** ./src/FetchTool.js ***!
|
|
1565
3225
|
\**************************/
|
|
1566
3226
|
/*! no static exports found */
|
|
1567
|
-
/***/ (function(module, exports) {
|
|
3227
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3228
|
+
|
|
3229
|
+
/* WEBPACK VAR INJECTION */(function(fetch) {var _excluded = ["url"],
|
|
3230
|
+
_excluded2 = ["url", "withCredentials"];
|
|
1568
3231
|
|
|
1569
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; }
|
|
1570
3233
|
|
|
@@ -1607,14 +3270,16 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1607
3270
|
key: "get",
|
|
1608
3271
|
value: function get(_ref) {
|
|
1609
3272
|
var url = _ref.url,
|
|
1610
|
-
options = _objectWithoutProperties(_ref,
|
|
3273
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
1611
3274
|
|
|
1612
3275
|
return fetch(url, Object.assign({
|
|
1613
3276
|
method: 'GET'
|
|
1614
3277
|
}, options)).then(function (result) {
|
|
1615
|
-
return result.arrayBuffer()
|
|
1616
|
-
|
|
1617
|
-
|
|
3278
|
+
if (result.ok) return result.arrayBuffer().then(function (b) {
|
|
3279
|
+
return new Uint8Array(b);
|
|
3280
|
+
});
|
|
3281
|
+
if (result.status === 404) return null;
|
|
3282
|
+
return Promise.reject(result.status);
|
|
1618
3283
|
});
|
|
1619
3284
|
}
|
|
1620
3285
|
/**
|
|
@@ -1640,7 +3305,7 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1640
3305
|
var url = _ref2.url,
|
|
1641
3306
|
_ref2$withCredentials = _ref2.withCredentials,
|
|
1642
3307
|
withCredentials = _ref2$withCredentials === void 0 ? false : _ref2$withCredentials,
|
|
1643
|
-
options = _objectWithoutProperties(_ref2,
|
|
3308
|
+
options = _objectWithoutProperties(_ref2, _excluded2);
|
|
1644
3309
|
|
|
1645
3310
|
return fetch(url, Object.assign({
|
|
1646
3311
|
credentials: withCredentials ? 'include' : 'omit'
|
|
@@ -1655,6 +3320,7 @@ var FetchTool = /*#__PURE__*/function () {
|
|
|
1655
3320
|
}();
|
|
1656
3321
|
|
|
1657
3322
|
module.exports = FetchTool;
|
|
3323
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/lib/index.mjs")["default"]))
|
|
1658
3324
|
|
|
1659
3325
|
/***/ }),
|
|
1660
3326
|
|
|
@@ -1665,6 +3331,8 @@ module.exports = FetchTool;
|
|
|
1665
3331
|
/*! no static exports found */
|
|
1666
3332
|
/***/ (function(module, exports, __webpack_require__) {
|
|
1667
3333
|
|
|
3334
|
+
/* WEBPACK VAR INJECTION */(function(fetch) {var _excluded = ["url"];
|
|
3335
|
+
|
|
1668
3336
|
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; }
|
|
1669
3337
|
|
|
1670
3338
|
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; }
|
|
@@ -1786,7 +3454,7 @@ var PrivateFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1786
3454
|
var _this2 = this;
|
|
1787
3455
|
|
|
1788
3456
|
var url = _ref2.url,
|
|
1789
|
-
options = _objectWithoutProperties(_ref2,
|
|
3457
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
1790
3458
|
|
|
1791
3459
|
return new Promise(function (resolve, reject) {
|
|
1792
3460
|
// TODO: Use a Scratch standard ID generator ...
|
|
@@ -1912,6 +3580,7 @@ var PublicFetchWorkerTool = /*#__PURE__*/function () {
|
|
|
1912
3580
|
}();
|
|
1913
3581
|
|
|
1914
3582
|
module.exports = PublicFetchWorkerTool;
|
|
3583
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! node-fetch */ "./node_modules/node-fetch/lib/index.mjs")["default"]))
|
|
1915
3584
|
|
|
1916
3585
|
/***/ }),
|
|
1917
3586
|
|
|
@@ -2320,7 +3989,7 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2320
3989
|
* @param {string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
|
|
2321
3990
|
* @param {DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
|
|
2322
3991
|
* @return {Promise.<Asset>} A promise for the requested Asset.
|
|
2323
|
-
* If the promise is resolved with non-null, the value is the requested asset
|
|
3992
|
+
* If the promise is resolved with non-null, the value is the requested asset.
|
|
2324
3993
|
* If the promise is resolved with null, the desired asset could not be found with the current asset sources.
|
|
2325
3994
|
* If the promise is rejected, there was an error on at least one asset source. HTTP 404 does not count as an
|
|
2326
3995
|
* error here, but (for example) HTTP 403 does.
|
|
@@ -2341,6 +4010,7 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2341
4010
|
|
|
2342
4011
|
var tryNextHelper = function tryNextHelper(err) {
|
|
2343
4012
|
if (err) {
|
|
4013
|
+
// Track the error, but continue looking
|
|
2344
4014
|
errors.push(err);
|
|
2345
4015
|
}
|
|
2346
4016
|
|
|
@@ -2357,8 +4027,8 @@ var ScratchStorage = /*#__PURE__*/function () {
|
|
|
2357
4027
|
return loading // TODO: maybe some types of error should prevent trying the next helper?
|
|
2358
4028
|
.catch(tryNextHelper);
|
|
2359
4029
|
} else if (errors.length > 0) {
|
|
2360
|
-
//
|
|
2361
|
-
//
|
|
4030
|
+
// We looked through all the helpers and couldn't find the asset, AND
|
|
4031
|
+
// at least one thing went wrong while we were looking.
|
|
2362
4032
|
return Promise.reject(errors);
|
|
2363
4033
|
} // Nothing went wrong but we couldn't find the asset.
|
|
2364
4034
|
|
|
@@ -2559,7 +4229,8 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
|
|
|
2559
4229
|
var errors = [];
|
|
2560
4230
|
var stores = this.stores.slice().filter(function (store) {
|
|
2561
4231
|
return store.types.indexOf(assetType.name) >= 0;
|
|
2562
|
-
});
|
|
4232
|
+
}); // New empty asset but it doesn't have data yet
|
|
4233
|
+
|
|
2563
4234
|
var asset = new Asset(assetType, assetId, dataFormat);
|
|
2564
4235
|
var tool = this.assetTool;
|
|
2565
4236
|
|
|
@@ -2569,11 +4240,15 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
|
|
|
2569
4240
|
|
|
2570
4241
|
var storeIndex = 0;
|
|
2571
4242
|
|
|
2572
|
-
var tryNextSource = function tryNextSource() {
|
|
4243
|
+
var tryNextSource = function tryNextSource(err) {
|
|
4244
|
+
if (err) {
|
|
4245
|
+
errors.push(err);
|
|
4246
|
+
}
|
|
4247
|
+
|
|
2573
4248
|
var store = stores[storeIndex++];
|
|
2574
4249
|
/** @type {UrlFunction} */
|
|
2575
4250
|
|
|
2576
|
-
var reqConfigFunction = store.get;
|
|
4251
|
+
var reqConfigFunction = store && store.get;
|
|
2577
4252
|
|
|
2578
4253
|
if (reqConfigFunction) {
|
|
2579
4254
|
var reqConfig = ensureRequestConfig(reqConfigFunction(asset));
|
|
@@ -2583,7 +4258,12 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
|
|
|
2583
4258
|
}
|
|
2584
4259
|
|
|
2585
4260
|
return tool.get(reqConfig).then(function (body) {
|
|
2586
|
-
|
|
4261
|
+
if (body) {
|
|
4262
|
+
asset.setData(body, dataFormat);
|
|
4263
|
+
return asset;
|
|
4264
|
+
}
|
|
4265
|
+
|
|
4266
|
+
return tryNextSource();
|
|
2587
4267
|
}).catch(tryNextSource);
|
|
2588
4268
|
} else if (errors.length > 0) {
|
|
2589
4269
|
return Promise.reject(errors);
|
|
@@ -2593,9 +4273,7 @@ var WebHelper = /*#__PURE__*/function (_Helper) {
|
|
|
2593
4273
|
return Promise.resolve(null);
|
|
2594
4274
|
};
|
|
2595
4275
|
|
|
2596
|
-
return tryNextSource()
|
|
2597
|
-
return asset;
|
|
2598
|
-
});
|
|
4276
|
+
return tryNextSource();
|
|
2599
4277
|
}
|
|
2600
4278
|
/**
|
|
2601
4279
|
* Create or update an asset with provided data. The create function is called if no asset id is provided
|
|
@@ -2704,6 +4382,28 @@ module.exports = require("base64-js");
|
|
|
2704
4382
|
|
|
2705
4383
|
/***/ }),
|
|
2706
4384
|
|
|
4385
|
+
/***/ "http":
|
|
4386
|
+
/*!***********************!*\
|
|
4387
|
+
!*** external "http" ***!
|
|
4388
|
+
\***********************/
|
|
4389
|
+
/*! no static exports found */
|
|
4390
|
+
/***/ (function(module, exports) {
|
|
4391
|
+
|
|
4392
|
+
module.exports = require("http");
|
|
4393
|
+
|
|
4394
|
+
/***/ }),
|
|
4395
|
+
|
|
4396
|
+
/***/ "https":
|
|
4397
|
+
/*!************************!*\
|
|
4398
|
+
!*** external "https" ***!
|
|
4399
|
+
\************************/
|
|
4400
|
+
/*! no static exports found */
|
|
4401
|
+
/***/ (function(module, exports) {
|
|
4402
|
+
|
|
4403
|
+
module.exports = require("https");
|
|
4404
|
+
|
|
4405
|
+
/***/ }),
|
|
4406
|
+
|
|
2707
4407
|
/***/ "js-md5":
|
|
2708
4408
|
/*!*************************!*\
|
|
2709
4409
|
!*** external "js-md5" ***!
|
|
@@ -2726,6 +4426,17 @@ module.exports = require("stream");
|
|
|
2726
4426
|
|
|
2727
4427
|
/***/ }),
|
|
2728
4428
|
|
|
4429
|
+
/***/ "url":
|
|
4430
|
+
/*!**********************!*\
|
|
4431
|
+
!*** external "url" ***!
|
|
4432
|
+
\**********************/
|
|
4433
|
+
/*! no static exports found */
|
|
4434
|
+
/***/ (function(module, exports) {
|
|
4435
|
+
|
|
4436
|
+
module.exports = require("url");
|
|
4437
|
+
|
|
4438
|
+
/***/ }),
|
|
4439
|
+
|
|
2729
4440
|
/***/ "util":
|
|
2730
4441
|
/*!***********************!*\
|
|
2731
4442
|
!*** external "util" ***!
|
|
@@ -2735,6 +4446,17 @@ module.exports = require("stream");
|
|
|
2735
4446
|
|
|
2736
4447
|
module.exports = require("util");
|
|
2737
4448
|
|
|
4449
|
+
/***/ }),
|
|
4450
|
+
|
|
4451
|
+
/***/ "zlib":
|
|
4452
|
+
/*!***********************!*\
|
|
4453
|
+
!*** external "zlib" ***!
|
|
4454
|
+
\***********************/
|
|
4455
|
+
/*! no static exports found */
|
|
4456
|
+
/***/ (function(module, exports) {
|
|
4457
|
+
|
|
4458
|
+
module.exports = require("zlib");
|
|
4459
|
+
|
|
2738
4460
|
/***/ })
|
|
2739
4461
|
|
|
2740
4462
|
/******/ });
|