@webex/http-core 3.0.0-beta.3 → 3.0.0-beta.300

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.
Files changed (45) hide show
  1. package/README.md +0 -1
  2. package/dist/http-error-subtypes.js +2 -147
  3. package/dist/http-error-subtypes.js.map +1 -1
  4. package/dist/http-error.js +9 -38
  5. package/dist/http-error.js.map +1 -1
  6. package/dist/index.js +54 -30
  7. package/dist/index.js.map +1 -1
  8. package/dist/interceptors/http-status.js +7 -30
  9. package/dist/interceptors/http-status.js.map +1 -1
  10. package/dist/lib/detect.js +28 -48
  11. package/dist/lib/detect.js.map +1 -1
  12. package/dist/lib/interceptor.js +7 -23
  13. package/dist/lib/interceptor.js.map +1 -1
  14. package/dist/lib/xhr.js +49 -93
  15. package/dist/lib/xhr.js.map +1 -1
  16. package/dist/progress-event.js +0 -7
  17. package/dist/progress-event.js.map +1 -1
  18. package/dist/request/index.js +3 -44
  19. package/dist/request/index.js.map +1 -1
  20. package/dist/request/request.js +5 -23
  21. package/dist/request/request.js.map +1 -1
  22. package/dist/request/request.shim.js +39 -91
  23. package/dist/request/request.shim.js.map +1 -1
  24. package/dist/request/utils.js +91 -0
  25. package/dist/request/utils.js.map +1 -0
  26. package/package.json +10 -10
  27. package/src/http-error-subtypes.js +1 -1
  28. package/src/http-error.js +15 -23
  29. package/src/index.js +59 -9
  30. package/src/interceptors/http-status.js +7 -5
  31. package/src/lib/detect.js +0 -1
  32. package/src/lib/interceptor.js +2 -4
  33. package/src/lib/xhr.js +201 -194
  34. package/src/progress-event.js +10 -5
  35. package/src/request/index.js +4 -36
  36. package/src/request/request.js +16 -14
  37. package/src/request/request.shim.js +51 -39
  38. package/src/request/utils.ts +78 -0
  39. package/test/integration/spec/http-error.js +11 -11
  40. package/test/integration/spec/interceptor.js +20 -13
  41. package/test/integration/spec/progress-event.js +8 -8
  42. package/test/integration/spec/request.js +136 -127
  43. package/test/unit/spec/index.js +58 -0
  44. package/test/unit/spec/interceptors/http-status.js +14 -11
  45. package/test/unit/spec/request/utils.js +77 -0
@@ -1,29 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
14
-
15
10
  var _defineProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/define-property"));
16
-
17
11
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
18
-
19
12
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
20
-
21
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
22
-
23
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
24
-
25
15
  var _get2 = _interopRequireDefault(require("lodash/get"));
26
-
27
16
  /**
28
17
  * @class
29
18
  */
@@ -35,9 +24,7 @@ var Interceptor = /*#__PURE__*/function () {
35
24
  */
36
25
  function Interceptor(attrs) {
37
26
  var _this = this;
38
-
39
27
  (0, _classCallCheck2.default)(this, Interceptor);
40
-
41
28
  if (attrs) {
42
29
  (0, _keys.default)(attrs).forEach(function (key) {
43
30
  var value = attrs[key];
@@ -48,6 +35,7 @@ var Interceptor = /*#__PURE__*/function () {
48
35
  });
49
36
  }
50
37
  }
38
+
51
39
  /**
52
40
  * Logs the options of a request. This should be utilized
53
41
  * during the intercepting process, but can be used at any
@@ -55,27 +43,24 @@ var Interceptor = /*#__PURE__*/function () {
55
43
  * @param {object} options
56
44
  * @returns {void}
57
45
  */
58
-
59
-
60
46
  (0, _createClass2.default)(Interceptor, [{
61
47
  key: "logOptions",
62
48
  value: function logOptions() {
63
49
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
64
50
  var logger = (0, _get2.default)(this, 'webex.logger', console);
65
-
66
51
  if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {
67
52
  return;
68
- } // prepend a header for the interceptor
69
-
53
+ }
70
54
 
55
+ // prepend a header for the interceptor
71
56
  logger.info('/***** Interceptor ****************************************************\\');
72
57
  logger.info("".concat(this.constructor.name, " - ").concat((0, _stringify.default)(options, null, 2)));
73
58
  }
59
+
74
60
  /**
75
61
  * @abstract
76
62
  * @returns {Interceptor}
77
63
  */
78
-
79
64
  }, {
80
65
  key: "onRequest",
81
66
  value:
@@ -87,37 +72,37 @@ var Interceptor = /*#__PURE__*/function () {
87
72
  function onRequest(options) {
88
73
  return _promise.default.resolve(options);
89
74
  }
75
+
90
76
  /**
91
77
  * Handle request failures
92
78
  * @param {Object} options
93
79
  * @param {Error} reason
94
80
  * @returns {RejectedPromise<Error>}
95
81
  */
96
-
97
82
  }, {
98
83
  key: "onRequestError",
99
84
  value: function onRequestError(options, reason) {
100
85
  return _promise.default.reject(reason);
101
86
  }
87
+
102
88
  /**
103
89
  * Transform response before returning it
104
90
  * @param {Object} options
105
91
  * @param {HttpResponse} response
106
92
  * @returns {Promise<HttpResponse>}
107
93
  */
108
-
109
94
  }, {
110
95
  key: "onResponse",
111
96
  value: function onResponse(options, response) {
112
97
  return _promise.default.resolve(response);
113
98
  }
99
+
114
100
  /**
115
101
  * Handle response errors
116
102
  * @param {Object} options
117
103
  * @param {WebexHttpError} reason
118
104
  * @returns {Promise<WebexHttpError>}
119
105
  */
120
-
121
106
  }, {
122
107
  key: "onResponseError",
123
108
  value: function onResponseError(options, reason) {
@@ -131,6 +116,5 @@ var Interceptor = /*#__PURE__*/function () {
131
116
  }]);
132
117
  return Interceptor;
133
118
  }();
134
-
135
119
  exports.default = Interceptor;
136
120
  //# sourceMappingURL=interceptor.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Interceptor","attrs","forEach","key","value","enumerable","options","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","constructor","name","resolve","reason","reject","response","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value\n });\n });\n }\n }\n\n /**\n * Logs the options of a request. This should be utilized\n * during the intercepting process, but can be used at any\n * time otherwise.\n * @param {object} options\n * @returns {void}\n */\n logOptions(options = {}) {\n const logger = get(this, 'webex.logger', console);\n\n if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {\n return;\n }\n\n // prepend a header for the interceptor\n logger.info('/***** Interceptor ****************************************************\\\\');\n\n logger.info(\n `${this.constructor.name} - ${JSON.stringify(options, null, 2)}`\n );\n }\n\n /**\n * @abstract\n * @returns {Interceptor}\n */\n static create() {\n throw new Error('`Interceptor.create()` must be defined');\n }\n\n /**\n * Transform request options before sending them\n * @param {Object} options\n * @returns {Promise<Object>}\n */\n onRequest(options) {\n return Promise.resolve(options);\n }\n\n /**\n * Handle request failures\n * @param {Object} options\n * @param {Error} reason\n * @returns {RejectedPromise<Error>}\n */\n onRequestError(options, reason) {\n return Promise.reject(reason);\n }\n\n /**\n * Transform response before returning it\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise<HttpResponse>}\n */\n onResponse(options, response) {\n return Promise.resolve(response);\n }\n\n /**\n * Handle response errors\n * @param {Object} options\n * @param {WebexHttpError} reason\n * @returns {Promise<WebexHttpError>}\n */\n onResponseError(options, reason) {\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AACA;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;MAC/B,OAAO,iBAAQC,MAAR,CAAeD,MAAf,CAAP;IACD;;;WAzCD,kBAAgB;MACd,MAAM,IAAIG,KAAJ,CAAU,wCAAV,CAAN;IACD"}
1
+ {"version":3,"names":["Interceptor","attrs","forEach","key","value","enumerable","options","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","constructor","name","resolve","reason","reject","response","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value,\n });\n });\n }\n }\n\n /**\n * Logs the options of a request. This should be utilized\n * during the intercepting process, but can be used at any\n * time otherwise.\n * @param {object} options\n * @returns {void}\n */\n logOptions(options = {}) {\n const logger = get(this, 'webex.logger', console);\n\n if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {\n return;\n }\n\n // prepend a header for the interceptor\n logger.info('/***** Interceptor ****************************************************\\\\');\n\n logger.info(`${this.constructor.name} - ${JSON.stringify(options, null, 2)}`);\n }\n\n /**\n * @abstract\n * @returns {Interceptor}\n */\n static create() {\n throw new Error('`Interceptor.create()` must be defined');\n }\n\n /**\n * Transform request options before sending them\n * @param {Object} options\n * @returns {Promise<Object>}\n */\n onRequest(options) {\n return Promise.resolve(options);\n }\n\n /**\n * Handle request failures\n * @param {Object} options\n * @param {Error} reason\n * @returns {RejectedPromise<Error>}\n */\n onRequestError(options, reason) {\n return Promise.reject(reason);\n }\n\n /**\n * Transform response before returning it\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise<HttpResponse>}\n */\n onResponse(options, response) {\n return Promise.resolve(response);\n }\n\n /**\n * Handle response errors\n * @param {Object} options\n * @param {WebexHttpError} reason\n * @returns {Promise<WebexHttpError>}\n */\n onResponseError(options, reason) {\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMA;AACA;AACA;AAFA,IAGqBA,WAAW;EAC9B;AACF;AACA;AACA;AACA;EACE,qBAAYC,KAAK,EAAE;IAAA;IAAA;IACjB,IAAIA,KAAK,EAAE;MACT,mBAAYA,KAAK,CAAC,CAACC,OAAO,CAAC,UAACC,GAAG,EAAK;QAClC,IAAMC,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;QAExB,6BAAuB,KAAI,EAAEA,GAAG,EAAE;UAChCE,UAAU,EAAE,IAAI;UAChBD,KAAK,EAALA;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EANE;IAAA;IAAA,OAOA,sBAAyB;MAAA,IAAdE,OAAO,uEAAG,CAAC,CAAC;MACrB,IAAMC,MAAM,GAAG,mBAAI,IAAI,EAAE,cAAc,EAAEC,OAAO,CAAC;MAEjD,IAAI,CAACC,OAAO,CAACC,GAAG,CAACC,8BAA8B,IAAI,CAACJ,MAAM,EAAE;QAC1D;MACF;;MAEA;MACAA,MAAM,CAACK,IAAI,CAAC,2EAA2E,CAAC;MAExFL,MAAM,CAACK,IAAI,WAAI,IAAI,CAACC,WAAW,CAACC,IAAI,gBAAM,wBAAeR,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAG;IAC/E;;IAEA;AACF;AACA;AACA;EAHE;IAAA;IAAA;IAQA;AACF;AACA;AACA;AACA;IACE,mBAAUA,OAAO,EAAE;MACjB,OAAO,iBAAQS,OAAO,CAACT,OAAO,CAAC;IACjC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,wBAAeA,OAAO,EAAEU,MAAM,EAAE;MAC9B,OAAO,iBAAQC,MAAM,CAACD,MAAM,CAAC;IAC/B;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,oBAAWV,OAAO,EAAEY,QAAQ,EAAE;MAC5B,OAAO,iBAAQH,OAAO,CAACG,QAAQ,CAAC;IAClC;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,yBAAgBZ,OAAO,EAAEU,MAAM,EAAE;MAC/B,OAAO,iBAAQC,MAAM,CAACD,MAAM,CAAC;IAC/B;EAAC;IAAA;IAAA,OAzCD,kBAAgB;MACd,MAAM,IAAIG,KAAK,CAAC,wCAAwC,CAAC;IAC3D;EAAC;EAAA;AAAA;AAAA"}
package/dist/lib/xhr.js CHANGED
@@ -1,66 +1,54 @@
1
1
  /*!
2
2
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
+
4
5
  // Need to fork xhr to support environments with full object freezing; namely,
5
6
  // SalesForce's Aura and Locker environment.
7
+
6
8
  // See https://github.com/naugtur/xhr for license information
9
+
7
10
  // Maintain the original code style of https://github.com/naugtur/xhr since
8
11
  // we're trying to diverge as little as possible.
9
-
10
12
  /* eslint-disable */
11
- "use strict";
12
13
 
13
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
+ 'use strict';
14
15
 
16
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
15
17
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
16
-
17
18
  _Object$defineProperty(exports, "__esModule", {
18
19
  value: true
19
20
  });
20
-
21
21
  exports.default = void 0;
22
-
23
22
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
24
-
25
- var window = require("global/window");
26
-
27
- var isFunction = require("is-function");
28
-
29
- var parseHeaders = require("parse-headers");
30
-
31
- var xtend = require("xtend");
32
-
23
+ var window = require('global/window');
24
+ var isFunction = require('is-function');
25
+ var parseHeaders = require('parse-headers');
26
+ var xtend = require('xtend');
33
27
  createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
34
- createXHR.XDomainRequest = "withCredentials" in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
35
- forEachArray(["get", "put", "post", "patch", "head", "delete"], function (method) {
36
- createXHR[method === "delete" ? "del" : method] = function (uri, options, callback) {
28
+ createXHR.XDomainRequest = 'withCredentials' in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
29
+ forEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {
30
+ createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {
37
31
  options = initParams(uri, options, callback);
38
32
  options.method = method.toUpperCase();
39
33
  return _createXHR(options);
40
34
  };
41
35
  });
42
-
43
36
  function forEachArray(array, iterator) {
44
37
  for (var i = 0; i < array.length; i += 1) {
45
38
  iterator(array[i]);
46
39
  }
47
40
  }
48
-
49
41
  function isEmpty(obj) {
50
42
  for (var i in obj) {
51
43
  if (obj.hasOwnProperty(i)) return false;
52
44
  }
53
-
54
45
  return true;
55
46
  }
56
-
57
47
  function initParams(uri, options, callback) {
58
48
  var params = uri;
59
-
60
49
  if (isFunction(options)) {
61
50
  callback = options;
62
-
63
- if (typeof uri === "string") {
51
+ if (typeof uri === 'string') {
64
52
  params = {
65
53
  uri: uri
66
54
  };
@@ -70,82 +58,71 @@ function initParams(uri, options, callback) {
70
58
  uri: uri
71
59
  });
72
60
  }
73
-
74
61
  params.callback = callback;
75
62
  return params;
76
63
  }
77
-
78
64
  function createXHR(uri, options, callback) {
79
65
  options = initParams(uri, options, callback);
80
66
  return _createXHR(options);
81
67
  }
82
-
83
68
  function _createXHR(options) {
84
- if (typeof options.callback === "undefined") {
85
- throw new Error("callback argument missing");
69
+ if (typeof options.callback === 'undefined') {
70
+ throw new Error('callback argument missing');
86
71
  }
87
-
88
72
  var called = false;
89
-
90
73
  var callback = function cbOnce(err, response, body) {
91
74
  if (!called) {
92
75
  called = true;
93
76
  options.callback(err, response, body);
94
77
  }
95
78
  };
96
-
97
79
  function readystatechange() {
98
80
  if (xhr.readyState === 4) {
99
81
  setTimeout(loadFunc, 0);
100
82
  }
101
83
  }
102
-
103
84
  function getBody() {
104
85
  // Chrome with requestType=blob throws errors arround when even testing access to responseText
105
86
  var body = undefined;
106
-
107
87
  if (xhr.response) {
108
88
  body = xhr.response;
109
89
  } else {
110
90
  body = xhr.responseText || getXml(xhr);
111
91
  }
112
-
113
92
  if (isJson) {
114
93
  try {
115
94
  body = JSON.parse(body);
116
95
  } catch (e) {}
117
96
  }
118
-
119
97
  return body;
120
98
  }
121
-
122
99
  function errorFunc(evt) {
123
100
  clearTimeout(timeoutTimer);
124
-
125
101
  if (!(evt instanceof Error)) {
126
- evt = new Error("" + (evt || "Unknown XMLHttpRequest Error"));
102
+ if (evt instanceof ProgressEvent) {
103
+ var _evt$target;
104
+ evt = new Error("XMLHttpRequest Error: ProgressEvent: loaded=".concat(evt.loaded, ", total=").concat(evt.total, ", lengthComputable=").concat(evt.lengthComputable, ", target.readyState=").concat((_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.readyState));
105
+ } else {
106
+ evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));
107
+ }
127
108
  }
128
-
129
109
  evt.statusCode = 0;
130
110
  return callback(evt, failureResponse);
131
- } // will load the data & process the response in a special response object
132
-
111
+ }
133
112
 
113
+ // will load the data & process the response in a special response object
134
114
  function loadFunc() {
135
115
  if (aborted) return;
136
116
  var status;
137
117
  clearTimeout(timeoutTimer);
138
-
139
118
  if (options.useXDR && xhr.status === undefined) {
140
119
  //IE8 CORS GET successful response doesn't have a status field, but body is fine
141
120
  status = 200;
142
121
  } else {
143
122
  status = xhr.status === 1223 ? 204 : xhr.status;
144
123
  }
145
-
146
124
  var response = failureResponse;
147
125
  var err = null;
148
-
149
126
  if (status !== 0) {
150
127
  response = {
151
128
  body: getBody(),
@@ -155,20 +132,16 @@ function _createXHR(options) {
155
132
  url: uri,
156
133
  rawRequest: xhr
157
134
  };
158
-
159
135
  if (xhr.getAllResponseHeaders) {
160
136
  //remember xhr can in fact be XDR for CORS in IE
161
137
  response.headers = parseHeaders(xhr.getAllResponseHeaders());
162
138
  }
163
139
  } else {
164
- err = new Error("Internal XMLHttpRequest Error");
140
+ err = new Error('Internal XMLHttpRequest Error');
165
141
  }
166
-
167
142
  return callback(err, response, response.body);
168
143
  }
169
-
170
144
  var xhr = options.xhr || null;
171
-
172
145
  if (!xhr) {
173
146
  if (options.cors || options.useXDR) {
174
147
  xhr = new createXHR.XDomainRequest();
@@ -176,11 +149,10 @@ function _createXHR(options) {
176
149
  xhr = new createXHR.XMLHttpRequest();
177
150
  }
178
151
  }
179
-
180
152
  var key;
181
153
  var aborted;
182
154
  var uri = options.uri || options.url;
183
- var method = options.method || "GET";
155
+ var method = options.method || 'GET';
184
156
  var body = options.body || options.data;
185
157
  var headers = options.headers || {};
186
158
  var sync = !!options.sync;
@@ -194,51 +166,43 @@ function _createXHR(options) {
194
166
  url: uri,
195
167
  rawRequest: xhr
196
168
  };
197
-
198
- if ("json" in options && options.json !== false) {
169
+ if ('json' in options && options.json !== false) {
199
170
  isJson = true;
200
- headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json"); //Don't override existing accept header declared by user
201
-
202
- if (method !== "GET" && method !== "HEAD") {
203
- headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json"); //Don't override existing accept header declared by user
204
-
171
+ headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user
172
+ if (method !== 'GET' && method !== 'HEAD') {
173
+ headers['content-type'] || headers['Content-Type'] || (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user
205
174
  body = (0, _stringify.default)(options.json === true ? body : options.json);
206
175
  }
207
176
  }
208
-
209
177
  xhr.onreadystatechange = readystatechange;
210
178
  xhr.onload = loadFunc;
211
- xhr.onerror = errorFunc; // IE9 must have onprogress be set to a unique function.
212
-
213
- xhr.onprogress = function () {// IE must die
179
+ xhr.onerror = errorFunc;
180
+ // IE9 must have onprogress be set to a unique function.
181
+ xhr.onprogress = function () {
182
+ // IE must die
214
183
  };
215
-
216
184
  xhr.onabort = function () {
217
185
  aborted = true;
218
186
  };
219
-
220
187
  xhr.ontimeout = errorFunc;
221
- xhr.open(method, uri, !sync, options.username, options.password); //has to be after open
222
-
188
+ xhr.open(method, uri, !sync, options.username, options.password);
189
+ //has to be after open
223
190
  if (!sync) {
224
191
  xhr.withCredentials = !!options.withCredentials;
225
- } // Cannot set timeout with sync request
192
+ }
193
+ // Cannot set timeout with sync request
226
194
  // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
227
195
  // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
228
-
229
-
230
196
  if (!sync && options.timeout > 0) {
231
197
  timeoutTimer = setTimeout(function () {
232
198
  if (aborted) return;
233
199
  aborted = true; //IE9 may still call readystatechange
234
-
235
- xhr.abort("timeout");
236
- var e = new Error("XMLHttpRequest timeout");
237
- e.code = "ETIMEDOUT";
200
+ xhr.abort('timeout');
201
+ var e = new Error('XMLHttpRequest timeout');
202
+ e.code = 'ETIMEDOUT';
238
203
  errorFunc(e);
239
204
  }, options.timeout);
240
205
  }
241
-
242
206
  if (xhr.setRequestHeader) {
243
207
  for (key in headers) {
244
208
  if (headers.hasOwnProperty(key)) {
@@ -246,40 +210,32 @@ function _createXHR(options) {
246
210
  }
247
211
  }
248
212
  } else if (options.headers && !isEmpty(options.headers)) {
249
- throw new Error("Headers cannot be set on an XDomainRequest object");
213
+ throw new Error('Headers cannot be set on an XDomainRequest object');
250
214
  }
251
-
252
- if ("responseType" in options) {
215
+ if ('responseType' in options) {
253
216
  xhr.responseType = options.responseType;
254
217
  }
255
-
256
- if ("beforeSend" in options && typeof options.beforeSend === "function") {
218
+ if ('beforeSend' in options && typeof options.beforeSend === 'function') {
257
219
  options.beforeSend(xhr);
258
- } // Microsoft Edge browser sends "undefined" when send is called with undefined value.
220
+ }
221
+
222
+ // Microsoft Edge browser sends "undefined" when send is called with undefined value.
259
223
  // XMLHttpRequest spec says to pass null as body to indicate no body
260
224
  // See https://github.com/naugtur/xhr/issues/100.
261
-
262
-
263
225
  xhr.send(body || null);
264
226
  return xhr;
265
227
  }
266
-
267
228
  function getXml(xhr) {
268
- if (xhr.responseType === "document") {
229
+ if (xhr.responseType === 'document') {
269
230
  return xhr.responseXML;
270
231
  }
271
-
272
- var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === "parsererror";
273
-
274
- if (xhr.responseType === "" && !firefoxBugTakenEffect) {
232
+ var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';
233
+ if (xhr.responseType === '' && !firefoxBugTakenEffect) {
275
234
  return xhr.responseXML;
276
235
  }
277
-
278
236
  return null;
279
237
  }
280
-
281
238
  function noop() {}
282
-
283
239
  var _default = createXHR;
284
240
  exports.default = _default;
285
241
  //# sourceMappingURL=xhr.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["window","require","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n\"use strict\";\nvar window = require(\"global/window\")\nvar isFunction = require(\"is-function\")\nvar parseHeaders = require(\"parse-headers\")\nvar xtend = require(\"xtend\")\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop\ncreateXHR.XDomainRequest = \"withCredentials\" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest\n\nforEachArray([\"get\", \"put\", \"post\", \"patch\", \"head\", \"delete\"], function(method) {\n createXHR[method === \"delete\" ? \"del\" : method] = function(uri, options, callback) {\n options = initParams(uri, options, callback)\n options.method = method.toUpperCase()\n return _createXHR(options)\n }\n})\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i+= 1) {\n iterator(array[i])\n }\n}\n\nfunction isEmpty(obj){\n for(var i in obj){\n if(obj.hasOwnProperty(i)) return false\n }\n return true\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri\n\n if (isFunction(options)) {\n callback = options\n if (typeof uri === \"string\") {\n params = {uri:uri}\n }\n } else {\n params = xtend(options, {uri: uri})\n }\n\n params.callback = callback\n return params\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback)\n return _createXHR(options)\n}\n\nfunction _createXHR(options) {\n if(typeof options.callback === \"undefined\"){\n throw new Error(\"callback argument missing\")\n }\n\n var called = false\n var callback = function cbOnce(err, response, body){\n if(!called){\n called = true\n options.callback(err, response, body)\n }\n }\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0)\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined\n\n if (xhr.response) {\n body = xhr.response\n } else {\n body = xhr.responseText || getXml(xhr)\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body)\n } catch (e) {}\n }\n\n return body\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer)\n if(!(evt instanceof Error)){\n evt = new Error(\"\" + (evt || \"Unknown XMLHttpRequest Error\") )\n }\n evt.statusCode = 0\n return callback(evt, failureResponse)\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return\n var status\n clearTimeout(timeoutTimer)\n if(options.useXDR && xhr.status===undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200\n } else {\n status = (xhr.status === 1223 ? 204 : xhr.status)\n }\n var response = failureResponse\n var err = null\n\n if (status !== 0){\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr\n }\n if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders())\n }\n } else {\n err = new Error(\"Internal XMLHttpRequest Error\")\n }\n return callback(err, response, response.body)\n }\n\n var xhr = options.xhr || null\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest()\n }else{\n xhr = new createXHR.XMLHttpRequest()\n }\n }\n\n var key\n var aborted\n var uri = options.uri || options.url\n var method = options.method || \"GET\"\n var body = options.body || options.data\n var headers = options.headers || {}\n var sync = !!options.sync\n var isJson = false\n var timeoutTimer\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr\n }\n\n if (\"json\" in options && options.json !== false) {\n isJson = true\n headers[\"accept\"] || headers[\"Accept\"] || (headers[\"Accept\"] = \"application/json\") //Don't override existing accept header declared by user\n if (method !== \"GET\" && method !== \"HEAD\") {\n headers[\"content-type\"] || headers[\"Content-Type\"] || (headers[\"Content-Type\"] = \"application/json\") //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json)\n }\n }\n\n xhr.onreadystatechange = readystatechange\n xhr.onload = loadFunc\n xhr.onerror = errorFunc\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n }\n xhr.onabort = function(){\n aborted = true;\n }\n xhr.ontimeout = errorFunc\n xhr.open(method, uri, !sync, options.username, options.password)\n //has to be after open\n if(!sync) {\n xhr.withCredentials = !!options.withCredentials\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0 ) {\n timeoutTimer = setTimeout(function(){\n if (aborted) return\n aborted = true//IE9 may still call readystatechange\n xhr.abort(\"timeout\")\n var e = new Error(\"XMLHttpRequest timeout\")\n e.code = \"ETIMEDOUT\"\n errorFunc(e)\n }, options.timeout )\n }\n\n if (xhr.setRequestHeader) {\n for(key in headers){\n if(headers.hasOwnProperty(key)){\n xhr.setRequestHeader(key, headers[key])\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error(\"Headers cannot be set on an XDomainRequest object\")\n }\n\n if (\"responseType\" in options) {\n xhr.responseType = options.responseType\n }\n\n if (\"beforeSend\" in options &&\n typeof options.beforeSend === \"function\"\n ) {\n options.beforeSend(xhr)\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null)\n\n return xhr\n\n\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === \"document\") {\n return xhr.responseXML\n }\n var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === \"parsererror\"\n if (xhr.responseType === \"\" && !firefoxBugTakenEffect) {\n return xhr.responseXML\n }\n\n return null\n}\n\nfunction noop() {}\n\nexport default createXHR;\n"],"mappings":"AAAA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;;AACA;AAEA;;;;;;;;;;;;;;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,eAAD,CAApB;;AACA,IAAIC,UAAU,GAAGD,OAAO,CAAC,aAAD,CAAxB;;AACA,IAAIE,YAAY,GAAGF,OAAO,CAAC,eAAD,CAA1B;;AACA,IAAIG,KAAK,GAAGH,OAAO,CAA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C,WAAJ,CAAgBE,eAAhB,CAAgCC,QAAhC,KAA6C,aAA5F;;EACA,IAAIlD,GAAG,CAAC4C,YAAJ,KAAqB,EAArB,IAA2B,CAACI,qBAAhC,EAAuD;IACnD,OAAOhD,GAAG,CAAC+C,WAAX;EACH;;EAED,OAAO,IAAP;AACH;;AAED,SAASxE,IAAT,GAAgB,CAAE;;eAEHF,S"}
1
+ {"version":3,"names":["window","require","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","ProgressEvent","loaded","total","lengthComputable","target","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n'use strict';\nvar window = require('global/window');\nvar isFunction = require('is-function');\nvar parseHeaders = require('parse-headers');\nvar xtend = require('xtend');\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop;\ncreateXHR.XDomainRequest =\n 'withCredentials' in new createXHR.XMLHttpRequest()\n ? createXHR.XMLHttpRequest\n : window.XDomainRequest;\n\nforEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {\n createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {\n options = initParams(uri, options, callback);\n options.method = method.toUpperCase();\n return _createXHR(options);\n };\n});\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i += 1) {\n iterator(array[i]);\n }\n}\n\nfunction isEmpty(obj) {\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) return false;\n }\n return true;\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri;\n\n if (isFunction(options)) {\n callback = options;\n if (typeof uri === 'string') {\n params = {uri: uri};\n }\n } else {\n params = xtend(options, {uri: uri});\n }\n\n params.callback = callback;\n return params;\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback);\n return _createXHR(options);\n}\n\nfunction _createXHR(options) {\n if (typeof options.callback === 'undefined') {\n throw new Error('callback argument missing');\n }\n\n var called = false;\n var callback = function cbOnce(err, response, body) {\n if (!called) {\n called = true;\n options.callback(err, response, body);\n }\n };\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0);\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined;\n\n if (xhr.response) {\n body = xhr.response;\n } else {\n body = xhr.responseText || getXml(xhr);\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body);\n } catch (e) {}\n }\n\n return body;\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer);\n if (!(evt instanceof Error)) {\n if (evt instanceof ProgressEvent) {\n evt = new Error(`XMLHttpRequest Error: ProgressEvent: loaded=${evt.loaded}, total=${evt.total}, lengthComputable=${evt.lengthComputable}, target.readyState=${evt.target?.readyState}`)\n } else {\n evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));\n }\n }\n evt.statusCode = 0;\n return callback(evt, failureResponse);\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return;\n var status;\n clearTimeout(timeoutTimer);\n if (options.useXDR && xhr.status === undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200;\n } else {\n status = xhr.status === 1223 ? 204 : xhr.status;\n }\n var response = failureResponse;\n var err = null;\n\n if (status !== 0) {\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr,\n };\n if (xhr.getAllResponseHeaders) {\n //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders());\n }\n } else {\n err = new Error('Internal XMLHttpRequest Error');\n }\n return callback(err, response, response.body);\n }\n\n var xhr = options.xhr || null;\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest();\n } else {\n xhr = new createXHR.XMLHttpRequest();\n }\n }\n\n var key;\n var aborted;\n var uri = options.uri || options.url;\n var method = options.method || 'GET';\n var body = options.body || options.data;\n var headers = options.headers || {};\n var sync = !!options.sync;\n var isJson = false;\n var timeoutTimer;\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr,\n };\n\n if ('json' in options && options.json !== false) {\n isJson = true;\n headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user\n if (method !== 'GET' && method !== 'HEAD') {\n headers['content-type'] ||\n headers['Content-Type'] ||\n (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json);\n }\n }\n\n xhr.onreadystatechange = readystatechange;\n xhr.onload = loadFunc;\n xhr.onerror = errorFunc;\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n };\n xhr.onabort = function () {\n aborted = true;\n };\n xhr.ontimeout = errorFunc;\n xhr.open(method, uri, !sync, options.username, options.password);\n //has to be after open\n if (!sync) {\n xhr.withCredentials = !!options.withCredentials;\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0) {\n timeoutTimer = setTimeout(function () {\n if (aborted) return;\n aborted = true; //IE9 may still call readystatechange\n xhr.abort('timeout');\n var e = new Error('XMLHttpRequest timeout');\n e.code = 'ETIMEDOUT';\n errorFunc(e);\n }, options.timeout);\n }\n\n if (xhr.setRequestHeader) {\n for (key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error('Headers cannot be set on an XDomainRequest object');\n }\n\n if ('responseType' in options) {\n xhr.responseType = options.responseType;\n }\n\n if ('beforeSend' in options && typeof options.beforeSend === 'function') {\n options.beforeSend(xhr);\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null);\n\n return xhr;\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === 'document') {\n return xhr.responseXML;\n }\n var firefoxBugTakenEffect =\n xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';\n if (xhr.responseType === '' && !firefoxBugTakenEffect) {\n return xhr.responseXML;\n }\n\n return null;\n}\n\nfunction noop() {}\n\nexport default createXHR;\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,YAAY;;AAAC;AAAA;AAAA;EAAA;AAAA;AAAA;AAAA;AACb,IAAIA,MAAM,GAAGC,OAAO,CAAC,eAAe,CAAC;AACrC,IAAIC,UAAU,GAAGD,OAAO,CAAC,aAAa,CAAC;AACvC,IAAIE,YAAY,GAAGF,OAAO,CAAC,eAAe,CAAC;AAC3C,IAAIG,KAAK,GAAGH,OAAO,CAAC,OAAO,CAAC;AAE5BI,SAAS,CAACC,cAAc,GAAGN,MAAM,CAACM,cAAc,IAAIC,IAAI;AACxDF,SAAS,CAACG,cAAc,GACtB,iBAAiB,IAAI,IAAIH,SAAS,CAACC,cAAc,EAAE,GAC/CD,SAAS,CAACC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AqB,EAAE;IACrD,OAAOrD,GAAG,CAACoD,WAAW;EACxB;EAEA,OAAO,IAAI;AACb;AAEA,SAAS7E,IAAI,GAAG,CAAC;AAAC,eAEHF,SAAS;AAAA"}
@@ -1,21 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = ProgressEvent;
12
-
13
9
  var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/define-properties"));
14
-
15
10
  var _isNan = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/number/is-nan"));
16
-
17
11
  var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
18
-
19
12
  /**
20
13
  * Object of the same shape as web browser ProgressEvents
21
14
  * @class ProgressEvent
@@ -1 +1 @@
1
- {"version":3,"names":["ProgressEvent","loaded","total","enumerable","value","writable","lengthComputable"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false\n },\n total: {\n enumerable: true,\n value: total,\n writable: false\n },\n lengthComputable: {\n enumerable: true,\n value: isNumber(loaded) && !Number.isNaN(loaded) && isNumber(total) && !Number.isNaN(total) && total > 0,\n writable: false\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAuBC,MAAvB,EAA+BC,KAA/B,EAAsC;EACnD,+BAAwB,IAAxB,EAA8B;IAC5BD,MAAM,EAAE;MACNE,UAAU,EAAE,IADN;MAENC,KAAK,EAAEH,MAFD;MAGNI,QAAQ,EAAE;IAHJ,CADoB;IAM5BH,KAAK,EAAE;MACLC,UAAU,EAAE,IADP;MAELC,KAAK,EAAEF,KAFF;MAGLG,QAAQ,EAAE;IAHL,CANqB;IAW5BC,gBAAgB,EAAE;MAChBH,UAAU,EAAE,IADI;MAEhBC,KAAK,EAAE,wBAASH,MAAT,KAAoB,CAAC,oBAAaA,MAAb,CAArB,IAA6C,wBAASC,KAAT,CAA7C,IAAgE,CAAC,oBAAaA,KAAb,CAAjE,IAAwFA,KAAK,GAAG,CAFvF;MAGhBG,QAAQ,EAAE;IAHM;EAXU,CAA9B;AAiBD"}
1
+ {"version":3,"names":["ProgressEvent","loaded","total","enumerable","value","writable","lengthComputable"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false,\n },\n total: {\n enumerable: true,\n value: total,\n writable: false,\n },\n lengthComputable: {\n enumerable: true,\n value:\n isNumber(loaded) &&\n !Number.isNaN(loaded) &&\n isNumber(total) &&\n !Number.isNaN(total) &&\n total > 0,\n writable: false,\n },\n });\n}\n"],"mappings":";;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAa,CAACC,MAAM,EAAEC,KAAK,EAAE;EACnD,+BAAwB,IAAI,EAAE;IAC5BD,MAAM,EAAE;MACNE,UAAU,EAAE,IAAI;MAChBC,KAAK,EAAEH,MAAM;MACbI,QAAQ,EAAE;IACZ,CAAC;IACDH,KAAK,EAAE;MACLC,UAAU,EAAE,IAAI;MAChBC,KAAK,EAAEF,KAAK;MACZG,QAAQ,EAAE;IACZ,CAAC;IACDC,gBAAgB,EAAE;MAChBH,UAAU,EAAE,IAAI;MAChBC,KAAK,EACH,wBAASH,MAAM,CAAC,IAChB,CAAC,oBAAaA,MAAM,CAAC,IACrB,wBAASC,KAAK,CAAC,IACf,CAAC,oBAAaA,KAAK,CAAC,IACpBA,KAAK,GAAG,CAAC;MACXG,QAAQ,EAAE;IACZ;EACF,CAAC,CAAC;AACJ"}