@atlaskit/media-client 36.3.0 → 36.3.1

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 (36) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/client/file-fetcher/index.js +166 -165
  3. package/dist/cjs/client/media-client.js +14 -14
  4. package/dist/cjs/client/media-store/MediaStore.js +79 -78
  5. package/dist/cjs/client/media-store/resolveAuth.js +20 -19
  6. package/dist/cjs/client/stargate-client.js +4 -4
  7. package/dist/cjs/uploader/index.js +28 -35
  8. package/dist/cjs/utils/createCopyIntentRegisterationBatcher.js +16 -16
  9. package/dist/cjs/utils/createFileDataLoader.js +16 -16
  10. package/dist/cjs/utils/getDimensionsFromBlob.js +15 -15
  11. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +1 -1
  12. package/dist/cjs/utils/hashing/hasherCreator.js +18 -18
  13. package/dist/cjs/utils/mobileUpload/helpers.js +15 -15
  14. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +4 -4
  15. package/dist/cjs/utils/polling/index.js +18 -18
  16. package/dist/cjs/utils/request/helpers.js +52 -49
  17. package/dist/cjs/utils/request/index.js +17 -16
  18. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +18 -18
  19. package/dist/esm/client/file-fetcher/index.js +166 -165
  20. package/dist/esm/client/media-client.js +14 -14
  21. package/dist/esm/client/media-store/MediaStore.js +79 -78
  22. package/dist/esm/client/media-store/resolveAuth.js +20 -19
  23. package/dist/esm/client/stargate-client.js +4 -4
  24. package/dist/esm/uploader/index.js +28 -35
  25. package/dist/esm/utils/createCopyIntentRegisterationBatcher.js +16 -16
  26. package/dist/esm/utils/createFileDataLoader.js +16 -16
  27. package/dist/esm/utils/getDimensionsFromBlob.js +15 -15
  28. package/dist/esm/utils/getVideoDimensionsFromBlob.js +1 -1
  29. package/dist/esm/utils/hashing/hasherCreator.js +17 -17
  30. package/dist/esm/utils/mobileUpload/helpers.js +15 -15
  31. package/dist/esm/utils/mobileUpload/stateMachine/index.js +4 -4
  32. package/dist/esm/utils/polling/index.js +18 -18
  33. package/dist/esm/utils/request/helpers.js +52 -49
  34. package/dist/esm/utils/request/index.js +17 -16
  35. package/dist/esm/utils/shouldFetchRemoteFileStates.js +18 -18
  36. package/package.json +3 -3
@@ -111,25 +111,26 @@ function extendHeaders(headers, auth, traceContext) {
111
111
  function createMapResponseToJson(metadata) {
112
112
  return /*#__PURE__*/function () {
113
113
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(response) {
114
- return _regenerator.default.wrap(function _callee$(_context) {
114
+ var _t;
115
+ return _regenerator.default.wrap(function (_context) {
115
116
  while (1) switch (_context.prev = _context.next) {
116
117
  case 0:
117
118
  _context.prev = 0;
118
- _context.next = 3;
119
+ _context.next = 1;
119
120
  return response.json();
120
- case 3:
121
+ case 1:
121
122
  return _context.abrupt("return", _context.sent);
122
- case 6:
123
- _context.prev = 6;
124
- _context.t0 = _context["catch"](0);
123
+ case 2:
124
+ _context.prev = 2;
125
+ _t = _context["catch"](0);
125
126
  throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
126
127
  statusCode: response.status
127
- }), _context.t0 instanceof Error ? _context.t0 : undefined);
128
- case 9:
128
+ }), _t instanceof Error ? _t : undefined);
129
+ case 3:
129
130
  case "end":
130
131
  return _context.stop();
131
132
  }
132
- }, _callee, null, [[0, 6]]);
133
+ }, _callee, null, [[0, 2]]);
133
134
  }));
134
135
  return function (_x) {
135
136
  return _ref5.apply(this, arguments);
@@ -139,25 +140,26 @@ function createMapResponseToJson(metadata) {
139
140
  function createMapResponseToBlob(metadata) {
140
141
  return /*#__PURE__*/function () {
141
142
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(response) {
142
- return _regenerator.default.wrap(function _callee2$(_context2) {
143
+ var _t2;
144
+ return _regenerator.default.wrap(function (_context2) {
143
145
  while (1) switch (_context2.prev = _context2.next) {
144
146
  case 0:
145
147
  _context2.prev = 0;
146
- _context2.next = 3;
148
+ _context2.next = 1;
147
149
  return response.blob();
148
- case 3:
150
+ case 1:
149
151
  return _context2.abrupt("return", _context2.sent);
150
- case 6:
151
- _context2.prev = 6;
152
- _context2.t0 = _context2["catch"](0);
152
+ case 2:
153
+ _context2.prev = 2;
154
+ _t2 = _context2["catch"](0);
153
155
  throw new _errors.RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
154
156
  statusCode: response.status
155
- }), _context2.t0 instanceof Error ? _context2.t0 : undefined);
156
- case 9:
157
+ }), _t2 instanceof Error ? _t2 : undefined);
158
+ case 3:
157
159
  case "end":
158
160
  return _context2.stop();
159
161
  }
160
- }, _callee2, null, [[0, 6]]);
162
+ }, _callee2, null, [[0, 2]]);
161
163
  }));
162
164
  return function (_x2) {
163
165
  return _ref6.apply(this, arguments);
@@ -197,8 +199,9 @@ function _fetchRetry() {
197
199
  timeoutInMs,
198
200
  lastError,
199
201
  waitAndBumpTimeout,
200
- _args4 = arguments;
201
- return _regenerator.default.wrap(function _callee4$(_context4) {
202
+ _args4 = arguments,
203
+ _t3;
204
+ return _regenerator.default.wrap(function (_context4) {
202
205
  while (1) switch (_context4.prev = _context4.next) {
203
206
  case 0:
204
207
  overwriteOptions = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
@@ -208,15 +211,15 @@ function _fetchRetry() {
208
211
  timeoutInMs = startTimeoutInMs;
209
212
  waitAndBumpTimeout = /*#__PURE__*/function () {
210
213
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
211
- return _regenerator.default.wrap(function _callee3$(_context3) {
214
+ return _regenerator.default.wrap(function (_context3) {
212
215
  while (1) switch (_context3.prev = _context3.next) {
213
216
  case 0:
214
- _context3.next = 2;
217
+ _context3.next = 1;
215
218
  return waitPromise(timeoutInMs);
216
- case 2:
219
+ case 1:
217
220
  timeoutInMs *= factor;
218
221
  attempts += 1;
219
- case 4:
222
+ case 2:
220
223
  case "end":
221
224
  return _context3.stop();
222
225
  }
@@ -226,58 +229,58 @@ function _fetchRetry() {
226
229
  return _ref7.apply(this, arguments);
227
230
  };
228
231
  }();
229
- case 6:
232
+ case 1:
230
233
  if (!(attempts < maxAttempts)) {
231
- _context4.next = 24;
234
+ _context4.next = 8;
232
235
  break;
233
236
  }
234
- _context4.prev = 7;
235
- _context4.next = 10;
237
+ _context4.prev = 2;
238
+ _context4.next = 3;
236
239
  return functionToRetry();
237
- case 10:
240
+ case 3:
238
241
  return _context4.abrupt("return", _context4.sent);
239
- case 13:
240
- _context4.prev = 13;
241
- _context4.t0 = _context4["catch"](7);
242
- lastError = _context4.t0;
242
+ case 4:
243
+ _context4.prev = 4;
244
+ _t3 = _context4["catch"](2);
245
+ lastError = _t3;
243
246
 
244
247
  // don't retry if request was aborted by user
245
- if (!isAbortedRequestError(_context4.t0)) {
246
- _context4.next = 18;
248
+ if (!isAbortedRequestError(_t3)) {
249
+ _context4.next = 5;
247
250
  break;
248
251
  }
249
- throw new _errors.RequestError('clientAbortedRequest', metadata, _context4.t0);
250
- case 18:
251
- if (shouldRetryError(_context4.t0)) {
252
- _context4.next = 20;
252
+ throw new _errors.RequestError('clientAbortedRequest', metadata, _t3);
253
+ case 5:
254
+ if (shouldRetryError(_t3)) {
255
+ _context4.next = 6;
253
256
  break;
254
257
  }
255
- throw _context4.t0;
256
- case 20:
257
- _context4.next = 22;
258
+ throw _t3;
259
+ case 6:
260
+ _context4.next = 7;
258
261
  return waitAndBumpTimeout();
259
- case 22:
260
- _context4.next = 6;
262
+ case 7:
263
+ _context4.next = 1;
261
264
  break;
262
- case 24:
265
+ case 8:
263
266
  if (!(0, _errors.isRequestError)(lastError)) {
264
- _context4.next = 26;
267
+ _context4.next = 9;
265
268
  break;
266
269
  }
267
270
  throw cloneRequestError(lastError, {
268
271
  attempts: attempts,
269
272
  clientExhaustedRetries: true
270
273
  });
271
- case 26:
274
+ case 9:
272
275
  throw new _errors.RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
273
276
  attempts: attempts,
274
277
  clientExhaustedRetries: true
275
278
  }), lastError);
276
- case 27:
279
+ case 10:
277
280
  case "end":
278
281
  return _context4.stop();
279
282
  }
280
- }, _callee4, null, [[7, 13]]);
283
+ }, _callee4, null, [[2, 4]]);
281
284
  }));
282
285
  return _fetchRetry.apply(this, arguments);
283
286
  }
@@ -62,8 +62,9 @@ function _request() {
62
62
  shouldRetryError,
63
63
  _getNavigator2,
64
64
  doFetchWithPathBasedUrl,
65
- _args = arguments;
66
- return _regenerator.default.wrap(function _callee$(_context) {
65
+ _args = arguments,
66
+ _t;
67
+ return _regenerator.default.wrap(function (_context) {
67
68
  while (1) switch (_context.prev = _context.next) {
68
69
  case 0:
69
70
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
@@ -86,7 +87,7 @@ function _request() {
86
87
  }).then((0, _helpers.createProcessFetchResponse)(metadata));
87
88
  };
88
89
  if (!(0, _platformFeatureFlags.fg)('platform_media_retry_edge_error')) {
89
- _context.next = 20;
90
+ _context.next = 5;
90
91
  break;
91
92
  }
92
93
  shouldRetryError = function shouldRetryError(err) {
@@ -96,18 +97,18 @@ function _request() {
96
97
  }
97
98
  return (0, _helpers.defaultShouldRetryError)(err);
98
99
  };
99
- _context.prev = 8;
100
- _context.next = 11;
100
+ _context.prev = 1;
101
+ _context.next = 2;
101
102
  return (0, _helpers.fetchRetry)(doFetch, metadata, _objectSpread(_objectSpread({}, retryOptions), {}, {
102
103
  shouldRetryError: shouldRetryError
103
104
  }));
104
- case 11:
105
+ case 2:
105
106
  return _context.abrupt("return", _context.sent);
106
- case 14:
107
- _context.prev = 14;
108
- _context.t0 = _context["catch"](8);
109
- if (!((0, _helpers.isFetchNetworkError)(_context.t0) && (_getNavigator2 = (0, _getNavigator3.default)()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/'))) {
110
- _context.next = 19;
107
+ case 3:
108
+ _context.prev = 3;
109
+ _t = _context["catch"](1);
110
+ if (!((0, _helpers.isFetchNetworkError)(_t) && (_getNavigator2 = (0, _getNavigator3.default)()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/'))) {
111
+ _context.next = 4;
111
112
  break;
112
113
  }
113
114
  doFetchWithPathBasedUrl = function doFetchWithPathBasedUrl() {
@@ -121,15 +122,15 @@ function _request() {
121
122
  }).then((0, _helpers.createProcessFetchResponse)(metadata));
122
123
  };
123
124
  return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetchWithPathBasedUrl, metadata, retryOptions));
124
- case 19:
125
- throw _context.t0;
126
- case 20:
125
+ case 4:
126
+ throw _t;
127
+ case 5:
127
128
  return _context.abrupt("return", (0, _helpers.fetchRetry)(doFetch, metadata, retryOptions));
128
- case 21:
129
+ case 6:
129
130
  case "end":
130
131
  return _context.stop();
131
132
  }
132
- }, _callee, null, [[8, 14]]);
133
+ }, _callee, null, [[1, 3]]);
133
134
  }));
134
135
  return _request.apply(this, arguments);
135
136
  }
@@ -25,49 +25,49 @@ function shouldFetchRemoteFileStates(_x, _x2, _x3) {
25
25
  }
26
26
  function _shouldFetchRemoteFileStates() {
27
27
  _shouldFetchRemoteFileStates = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaType, mimeType, preview) {
28
- var content, _yield$getVideoDimens, width, height;
29
- return _regenerator.default.wrap(function _callee$(_context) {
28
+ var content, _yield$getVideoDimens, width, height, _t;
29
+ return _regenerator.default.wrap(function (_context) {
30
30
  while (1) switch (_context.prev = _context.next) {
31
31
  case 0:
32
32
  if (!((mediaType === 'doc' || !(0, _mediaTypeUtils.isMimeTypeSupportedByBrowser)(mimeType) || !preview) && (0, _mediaTypeUtils.isMimeTypeSupportedByServer)(mimeType))) {
33
- _context.next = 2;
33
+ _context.next = 1;
34
34
  break;
35
35
  }
36
36
  return _context.abrupt("return", true);
37
- case 2:
37
+ case 1:
38
38
  if (!(mediaType === 'video' && !!preview)) {
39
- _context.next = 20;
39
+ _context.next = 6;
40
40
  break;
41
41
  }
42
- _context.next = 5;
42
+ _context.next = 2;
43
43
  return preview;
44
- case 5:
44
+ case 2:
45
45
  content = _context.sent.value;
46
46
  if (content instanceof Blob) {
47
- _context.next = 8;
47
+ _context.next = 3;
48
48
  break;
49
49
  }
50
50
  return _context.abrupt("return", false);
51
- case 8:
52
- _context.prev = 8;
53
- _context.next = 11;
51
+ case 3:
52
+ _context.prev = 3;
53
+ _context.next = 4;
54
54
  return (0, _getVideoDimensionsFromBlob.getVideoDimensionsFromBlob)(content);
55
- case 11:
55
+ case 4:
56
56
  _yield$getVideoDimens = _context.sent;
57
57
  width = _yield$getVideoDimens.width;
58
58
  height = _yield$getVideoDimens.height;
59
59
  return _context.abrupt("return", !width && !height);
60
- case 17:
61
- _context.prev = 17;
62
- _context.t0 = _context["catch"](8);
60
+ case 5:
61
+ _context.prev = 5;
62
+ _t = _context["catch"](3);
63
63
  return _context.abrupt("return", true);
64
- case 20:
64
+ case 6:
65
65
  return _context.abrupt("return", false);
66
- case 21:
66
+ case 7:
67
67
  case "end":
68
68
  return _context.stop();
69
69
  }
70
- }, _callee, null, [[8, 17]]);
70
+ }, _callee, null, [[3, 5]]);
71
71
  }));
72
72
  return _shouldFetchRemoteFileStates.apply(this, arguments);
73
73
  }