@atlaskit/media-client 18.0.0 → 19.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/client/collection-fetcher.js +8 -8
  3. package/dist/cjs/client/file-fetcher/index.js +40 -36
  4. package/dist/cjs/client/media-client.js +2 -2
  5. package/dist/cjs/client/media-store/index.js +72 -44
  6. package/dist/cjs/uploader/index.js +22 -20
  7. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +23 -19
  8. package/dist/cjs/utils/request/helpers.js +39 -22
  9. package/dist/cjs/utils/request/index.js +3 -2
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/client/collection-fetcher.js +6 -6
  12. package/dist/es2019/client/file-fetcher/index.js +16 -14
  13. package/dist/es2019/client/media-client.js +2 -2
  14. package/dist/es2019/client/media-store/index.js +52 -34
  15. package/dist/es2019/uploader/index.js +13 -13
  16. package/dist/es2019/utils/getVideoDimensionsFromBlob.js +21 -7
  17. package/dist/es2019/utils/request/helpers.js +26 -8
  18. package/dist/es2019/utils/request/index.js +4 -3
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/client/collection-fetcher.js +8 -8
  21. package/dist/esm/client/file-fetcher/index.js +40 -36
  22. package/dist/esm/client/media-client.js +2 -2
  23. package/dist/esm/client/media-store/index.js +71 -44
  24. package/dist/esm/uploader/index.js +22 -20
  25. package/dist/esm/utils/getVideoDimensionsFromBlob.js +21 -16
  26. package/dist/esm/utils/request/helpers.js +36 -20
  27. package/dist/esm/utils/request/index.js +4 -3
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/client/collection-fetcher.d.ts +4 -3
  30. package/dist/types/client/file-fetcher/index.d.ts +9 -8
  31. package/dist/types/client/media-client.d.ts +2 -2
  32. package/dist/types/client/media-store/index.d.ts +15 -14
  33. package/dist/types/uploader/index.d.ts +2 -1
  34. package/dist/types/utils/getVideoDimensionsFromBlob.d.ts +3 -4
  35. package/dist/types/utils/request/helpers.d.ts +10 -2
  36. package/dist/types/utils/request/types.d.ts +2 -0
  37. package/example-helpers/styles.ts +9 -8
  38. package/package.json +8 -12
  39. package/report.api.md +892 -555
  40. package/dist/types-ts4.0/client/__mocks__/collection-fetcher.d.ts +0 -8
  41. package/dist/types-ts4.0/client/__mocks__/file-fetcher.d.ts +0 -10
  42. package/dist/types-ts4.0/client/__mocks__/media-client.d.ts +0 -13
  43. package/dist/types-ts4.0/client/collection-fetcher.d.ts +0 -35
  44. package/dist/types-ts4.0/client/events.d.ts +0 -14
  45. package/dist/types-ts4.0/client/file-fetcher/error.d.ts +0 -29
  46. package/dist/types-ts4.0/client/file-fetcher/index.d.ts +0 -56
  47. package/dist/types-ts4.0/client/media-client.d.ts +0 -28
  48. package/dist/types-ts4.0/client/media-store/error.d.ts +0 -16
  49. package/dist/types-ts4.0/client/media-store/index.d.ts +0 -167
  50. package/dist/types-ts4.0/client/media-store/resolveAuth.d.ts +0 -4
  51. package/dist/types-ts4.0/client/mobile-upload.d.ts +0 -11
  52. package/dist/types-ts4.0/client/stargate-client.d.ts +0 -15
  53. package/dist/types-ts4.0/constants.d.ts +0 -6
  54. package/dist/types-ts4.0/file-streams-cache.d.ts +0 -15
  55. package/dist/types-ts4.0/globalMediaEventEmitter.d.ts +0 -6
  56. package/dist/types-ts4.0/identifier.d.ts +0 -15
  57. package/dist/types-ts4.0/index.d.ts +0 -89
  58. package/dist/types-ts4.0/models/artifacts.d.ts +0 -12
  59. package/dist/types-ts4.0/models/auth-headers.d.ts +0 -11
  60. package/dist/types-ts4.0/models/auth-query-parameters.d.ts +0 -11
  61. package/dist/types-ts4.0/models/errors/helpers.d.ts +0 -6
  62. package/dist/types-ts4.0/models/errors/index.d.ts +0 -11
  63. package/dist/types-ts4.0/models/errors/types.d.ts +0 -15
  64. package/dist/types-ts4.0/models/file-state.d.ts +0 -91
  65. package/dist/types-ts4.0/models/item.d.ts +0 -25
  66. package/dist/types-ts4.0/models/media-subscribable.d.ts +0 -3
  67. package/dist/types-ts4.0/models/media.d.ts +0 -66
  68. package/dist/types-ts4.0/models/mobile-upload.d.ts +0 -28
  69. package/dist/types-ts4.0/upload-controller.d.ts +0 -7
  70. package/dist/types-ts4.0/uploader/calculateChunkSize.d.ts +0 -11
  71. package/dist/types-ts4.0/uploader/error.d.ts +0 -29
  72. package/dist/types-ts4.0/uploader/index.d.ts +0 -21
  73. package/dist/types-ts4.0/utils/checkWebpSupport.d.ts +0 -1
  74. package/dist/types-ts4.0/utils/convertBase64ToBlob.d.ts +0 -1
  75. package/dist/types-ts4.0/utils/createFileDataLoader.d.ts +0 -30
  76. package/dist/types-ts4.0/utils/createMediaSubject.d.ts +0 -3
  77. package/dist/types-ts4.0/utils/detectEmptyFile.d.ts +0 -16
  78. package/dist/types-ts4.0/utils/getDimensionsFromBlob.d.ts +0 -6
  79. package/dist/types-ts4.0/utils/getImageDimensionsFromBlob.d.ts +0 -5
  80. package/dist/types-ts4.0/utils/getMediaTypeFromUploadableFile.d.ts +0 -3
  81. package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +0 -6
  82. package/dist/types-ts4.0/utils/hashing/hasher.d.ts +0 -3
  83. package/dist/types-ts4.0/utils/hashing/hasherCreator.d.ts +0 -3
  84. package/dist/types-ts4.0/utils/hashing/simpleHasher.d.ts +0 -4
  85. package/dist/types-ts4.0/utils/hashing/workerHasher.d.ts +0 -16
  86. package/dist/types-ts4.0/utils/imageResizeModeToFileImageMode.d.ts +0 -3
  87. package/dist/types-ts4.0/utils/isImageRemote.d.ts +0 -1
  88. package/dist/types-ts4.0/utils/mediaSubscribable/fromObservable.d.ts +0 -5
  89. package/dist/types-ts4.0/utils/mediaSubscribable/index.d.ts +0 -3
  90. package/dist/types-ts4.0/utils/mediaSubscribable/toPromise.d.ts +0 -10
  91. package/dist/types-ts4.0/utils/mediaSubscribable/types.d.ts +0 -16
  92. package/dist/types-ts4.0/utils/mobileUpload/error.d.ts +0 -29
  93. package/dist/types-ts4.0/utils/mobileUpload/helpers.d.ts +0 -8
  94. package/dist/types-ts4.0/utils/mobileUpload/index.d.ts +0 -5
  95. package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +0 -4
  96. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/index.d.ts +0 -7
  97. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/error.d.ts +0 -3
  98. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processed.d.ts +0 -3
  99. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processing.d.ts +0 -3
  100. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/processingFailed.d.ts +0 -3
  101. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/states/uploading.d.ts +0 -3
  102. package/dist/types-ts4.0/utils/mobileUpload/stateMachine/types.d.ts +0 -69
  103. package/dist/types-ts4.0/utils/overrideMediaTypeIfUnknown.d.ts +0 -5
  104. package/dist/types-ts4.0/utils/polling/errors.d.ts +0 -12
  105. package/dist/types-ts4.0/utils/polling/index.d.ts +0 -33
  106. package/dist/types-ts4.0/utils/polling/types.d.ts +0 -7
  107. package/dist/types-ts4.0/utils/request/errors.d.ts +0 -20
  108. package/dist/types-ts4.0/utils/request/helpers.d.ts +0 -38
  109. package/dist/types-ts4.0/utils/request/index.d.ts +0 -5
  110. package/dist/types-ts4.0/utils/request/types.d.ts +0 -43
  111. package/dist/types-ts4.0/utils/safeUnsubscribe.d.ts +0 -2
  112. package/dist/types-ts4.0/utils/setTimeoutPromise.d.ts +0 -2
  113. package/dist/types-ts4.0/utils/shouldFetchRemoteFileStates.d.ts +0 -16
  114. package/dist/types-ts4.0/utils/url.d.ts +0 -17
  115. package/dist/types-ts4.0/utils/with-media-client-hoc.d.ts +0 -16
@@ -8,6 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
8
 
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
 
11
+ import { getRandomHex } from '@atlaskit/media-common';
11
12
  import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
12
13
  import { getArtifactUrl } from '../../models/artifacts';
13
14
  import { request as _request } from '../../utils/request';
@@ -59,7 +60,7 @@ export var MediaStore = /*#__PURE__*/function () {
59
60
  _createClass(MediaStore, [{
60
61
  key: "getCollectionItems",
61
62
  value: function () {
62
- var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params) {
63
+ var _getCollectionItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName, params, traceContext) {
63
64
  var metadata, options, response, _yield$createMapRespo, _yield$createMapRespo2, contents, nextInclusiveStartKey, contentsWithoutEmptyFiles;
64
65
 
65
66
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -77,7 +78,8 @@ export var MediaStore = /*#__PURE__*/function () {
77
78
  params: _objectSpread(_objectSpread({}, defaultGetCollectionItems), params),
78
79
  headers: {
79
80
  Accept: 'application/json'
80
- }
81
+ },
82
+ traceContext: traceContext
81
83
  });
82
84
  _context.next = 4;
83
85
  return this.request("/collection/".concat(collectionName, "/items"), options);
@@ -112,7 +114,7 @@ export var MediaStore = /*#__PURE__*/function () {
112
114
  }, _callee, this);
113
115
  }));
114
116
 
115
- function getCollectionItems(_x, _x2) {
117
+ function getCollectionItems(_x, _x2, _x3) {
116
118
  return _getCollectionItems.apply(this, arguments);
117
119
  }
118
120
 
@@ -121,7 +123,7 @@ export var MediaStore = /*#__PURE__*/function () {
121
123
  }, {
122
124
  key: "removeCollectionFile",
123
125
  value: function () {
124
- var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, collectionName, occurrenceKey) {
126
+ var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, collectionName, occurrenceKey, traceContext) {
125
127
  var metadata, body, options;
126
128
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
127
129
  while (1) {
@@ -149,7 +151,8 @@ export var MediaStore = /*#__PURE__*/function () {
149
151
  Accept: 'application/json',
150
152
  'Content-Type': 'application/json'
151
153
  },
152
- body: JSON.stringify(body)
154
+ body: JSON.stringify(body),
155
+ traceContext: traceContext
153
156
  });
154
157
  _context2.next = 5;
155
158
  return this.request("/collection/".concat(collectionName), options);
@@ -162,7 +165,7 @@ export var MediaStore = /*#__PURE__*/function () {
162
165
  }, _callee2, this);
163
166
  }));
164
167
 
165
- function removeCollectionFile(_x3, _x4, _x5) {
168
+ function removeCollectionFile(_x4, _x5, _x6, _x7) {
166
169
  return _removeCollectionFile.apply(this, arguments);
167
170
  }
168
171
 
@@ -173,6 +176,7 @@ export var MediaStore = /*#__PURE__*/function () {
173
176
  value: function createUpload() {
174
177
  var createUpTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
175
178
  var collectionName = arguments.length > 1 ? arguments[1] : undefined;
179
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
176
180
  var metadata = {
177
181
  method: 'POST',
178
182
  endpoint: '/upload'
@@ -187,7 +191,8 @@ export var MediaStore = /*#__PURE__*/function () {
187
191
  },
188
192
  headers: {
189
193
  Accept: 'application/json'
190
- }
194
+ },
195
+ traceContext: traceContext
191
196
  });
192
197
 
193
198
  return this.request("/upload", options).then(createMapResponseToJson(metadata));
@@ -200,6 +205,7 @@ export var MediaStore = /*#__PURE__*/function () {
200
205
  collectionName,
201
206
  uploadId,
202
207
  partNumber,
208
+ traceContext,
203
209
  metadata,
204
210
  options,
205
211
  _args3 = arguments;
@@ -209,6 +215,7 @@ export var MediaStore = /*#__PURE__*/function () {
209
215
  switch (_context3.prev = _context3.next) {
210
216
  case 0:
211
217
  _ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
218
+ traceContext = _args3.length > 3 ? _args3[3] : undefined;
212
219
  metadata = {
213
220
  method: 'PUT',
214
221
  endpoint: '/chunk/{etag}'
@@ -221,12 +228,13 @@ export var MediaStore = /*#__PURE__*/function () {
221
228
  authContext: {
222
229
  collectionName: collectionName
223
230
  },
224
- body: blob
231
+ body: blob,
232
+ traceContext: traceContext
225
233
  });
226
- _context3.next = 5;
234
+ _context3.next = 6;
227
235
  return this.request("/chunk/".concat(etag), options);
228
236
 
229
- case 5:
237
+ case 6:
230
238
  case "end":
231
239
  return _context3.stop();
232
240
  }
@@ -234,7 +242,7 @@ export var MediaStore = /*#__PURE__*/function () {
234
242
  }, _callee3, this);
235
243
  }));
236
244
 
237
- function uploadChunk(_x6, _x7) {
245
+ function uploadChunk(_x8, _x9) {
238
246
  return _uploadChunk.apply(this, arguments);
239
247
  }
240
248
 
@@ -247,6 +255,7 @@ export var MediaStore = /*#__PURE__*/function () {
247
255
  collectionName = _ref2.collectionName,
248
256
  uploadId = _ref2.uploadId;
249
257
 
258
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
250
259
  var metadata = {
251
260
  method: 'POST',
252
261
  endpoint: '/chunk/probe'
@@ -262,7 +271,8 @@ export var MediaStore = /*#__PURE__*/function () {
262
271
  headers: jsonHeaders,
263
272
  body: JSON.stringify({
264
273
  chunks: chunks
265
- })
274
+ }),
275
+ traceContext: traceContext
266
276
  });
267
277
 
268
278
  return this.request("/chunk/probe", options).then(createMapResponseToJson(metadata));
@@ -271,6 +281,7 @@ export var MediaStore = /*#__PURE__*/function () {
271
281
  key: "createFileFromUpload",
272
282
  value: function createFileFromUpload(body) {
273
283
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
284
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
274
285
  var metadata = {
275
286
  method: 'POST',
276
287
  endpoint: '/file/upload'
@@ -282,7 +293,8 @@ export var MediaStore = /*#__PURE__*/function () {
282
293
  },
283
294
  params: params,
284
295
  headers: jsonHeaders,
285
- body: JSON.stringify(body)
296
+ body: JSON.stringify(body),
297
+ traceContext: traceContext
286
298
  });
287
299
 
288
300
  return this.request('/file/upload', options).then(createMapResponseToJson(metadata));
@@ -291,6 +303,7 @@ export var MediaStore = /*#__PURE__*/function () {
291
303
  key: "touchFiles",
292
304
  value: function touchFiles(body) {
293
305
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
306
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
294
307
  var metadata = {
295
308
  method: 'POST',
296
309
  endpoint: '/upload/createWithFiles'
@@ -301,7 +314,8 @@ export var MediaStore = /*#__PURE__*/function () {
301
314
  collectionName: params.collection
302
315
  },
303
316
  headers: jsonHeaders,
304
- body: JSON.stringify(body)
317
+ body: JSON.stringify(body),
318
+ traceContext: traceContext
305
319
  });
306
320
 
307
321
  return this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata));
@@ -310,6 +324,7 @@ export var MediaStore = /*#__PURE__*/function () {
310
324
  key: "getFile",
311
325
  value: function getFile(fileId) {
312
326
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
327
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
313
328
  var metadata = {
314
329
  method: 'GET',
315
330
  endpoint: '/file/{fileId}'
@@ -319,7 +334,8 @@ export var MediaStore = /*#__PURE__*/function () {
319
334
  authContext: {
320
335
  collectionName: params.collection
321
336
  },
322
- params: params
337
+ params: params,
338
+ traceContext: traceContext
323
339
  });
324
340
 
325
341
  return this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata));
@@ -352,12 +368,13 @@ export var MediaStore = /*#__PURE__*/function () {
352
368
  }, _callee4, this);
353
369
  }));
354
370
 
355
- function getFileImageURL(_x8, _x9) {
371
+ function getFileImageURL(_x10, _x11) {
356
372
  return _getFileImageURL.apply(this, arguments);
357
373
  }
358
374
 
359
375
  return getFileImageURL;
360
- }()
376
+ }() // TODO Create ticket in case Trace Id can be supported through query params
377
+
361
378
  }, {
362
379
  key: "getFileImageURLSync",
363
380
  value: function getFileImageURLSync(id, params) {
@@ -407,7 +424,7 @@ export var MediaStore = /*#__PURE__*/function () {
407
424
  }, _callee5, this);
408
425
  }));
409
426
 
410
- function getFileBinaryURL(_x10, _x11) {
427
+ function getFileBinaryURL(_x12, _x13) {
411
428
  return _getFileBinaryURL.apply(this, arguments);
412
429
  }
413
430
 
@@ -456,7 +473,7 @@ export var MediaStore = /*#__PURE__*/function () {
456
473
  }, _callee6, this);
457
474
  }));
458
475
 
459
- function getArtifactURL(_x12, _x13, _x14) {
476
+ function getArtifactURL(_x14, _x15, _x16) {
460
477
  return _getArtifactURL.apply(this, arguments);
461
478
  }
462
479
 
@@ -465,7 +482,7 @@ export var MediaStore = /*#__PURE__*/function () {
465
482
  }, {
466
483
  key: "getImage",
467
484
  value: function () {
468
- var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes) {
485
+ var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
469
486
  var isWebpSupported, headers, metadata, options;
470
487
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
471
488
  while (1) {
@@ -473,11 +490,10 @@ export var MediaStore = /*#__PURE__*/function () {
473
490
  case 0:
474
491
  // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
475
492
  isWebpSupported = false;
493
+ headers = {};
476
494
 
477
495
  if (isWebpSupported) {
478
- headers = {
479
- accept: 'image/webp,image/*,*/*;q=0.8'
480
- };
496
+ headers.accept = 'image/webp,image/*,*/*;q=0.8';
481
497
  }
482
498
 
483
499
  metadata = {
@@ -489,11 +505,12 @@ export var MediaStore = /*#__PURE__*/function () {
489
505
  collectionName: params && params.collection
490
506
  },
491
507
  params: extendImageParams(params, fetchMaxRes),
492
- headers: headers
508
+ headers: headers,
509
+ traceContext: traceContext
493
510
  });
494
511
  return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
495
512
 
496
- case 5:
513
+ case 6:
497
514
  case "end":
498
515
  return _context7.stop();
499
516
  }
@@ -501,7 +518,7 @@ export var MediaStore = /*#__PURE__*/function () {
501
518
  }, _callee7, this);
502
519
  }));
503
520
 
504
- function getImage(_x15, _x16, _x17, _x18) {
521
+ function getImage(_x17, _x18, _x19, _x20, _x21) {
505
522
  return _getImage.apply(this, arguments);
506
523
  }
507
524
 
@@ -510,7 +527,7 @@ export var MediaStore = /*#__PURE__*/function () {
510
527
  }, {
511
528
  key: "getItems",
512
529
  value: function () {
513
- var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName) {
530
+ var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ids, collectionName, traceContext) {
514
531
  var descriptors, metadata, options;
515
532
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
516
533
  while (1) {
@@ -534,7 +551,8 @@ export var MediaStore = /*#__PURE__*/function () {
534
551
  headers: jsonHeaders,
535
552
  body: JSON.stringify({
536
553
  descriptors: descriptors
537
- })
554
+ }),
555
+ traceContext: traceContext
538
556
  });
539
557
  return _context8.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
540
558
 
@@ -546,7 +564,7 @@ export var MediaStore = /*#__PURE__*/function () {
546
564
  }, _callee8, this);
547
565
  }));
548
566
 
549
- function getItems(_x19, _x20) {
567
+ function getItems(_x22, _x23, _x24) {
550
568
  return _getItems.apply(this, arguments);
551
569
  }
552
570
 
@@ -555,7 +573,7 @@ export var MediaStore = /*#__PURE__*/function () {
555
573
  }, {
556
574
  key: "getImageMetadata",
557
575
  value: function () {
558
- var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params) {
576
+ var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params, traceContext) {
559
577
  var metadata, options;
560
578
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
561
579
  while (1) {
@@ -569,7 +587,8 @@ export var MediaStore = /*#__PURE__*/function () {
569
587
  authContext: {
570
588
  collectionName: params && params.collection
571
589
  },
572
- params: params
590
+ params: params,
591
+ traceContext: traceContext
573
592
  });
574
593
  return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
575
594
 
@@ -581,7 +600,7 @@ export var MediaStore = /*#__PURE__*/function () {
581
600
  }, _callee9, this);
582
601
  }));
583
602
 
584
- function getImageMetadata(_x21, _x22) {
603
+ function getImageMetadata(_x25, _x26, _x27) {
585
604
  return _getImageMetadata.apply(this, arguments);
586
605
  }
587
606
 
@@ -590,7 +609,7 @@ export var MediaStore = /*#__PURE__*/function () {
590
609
  }, {
591
610
  key: "appendChunksToUpload",
592
611
  value: function () {
593
- var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName) {
612
+ var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(uploadId, body, collectionName, traceContext) {
594
613
  var metadata, options;
595
614
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
596
615
  while (1) {
@@ -605,7 +624,8 @@ export var MediaStore = /*#__PURE__*/function () {
605
624
  collectionName: collectionName
606
625
  },
607
626
  headers: jsonHeaders,
608
- body: JSON.stringify(body)
627
+ body: JSON.stringify(body),
628
+ traceContext: traceContext
609
629
  });
610
630
  _context10.next = 4;
611
631
  return this.request("/upload/".concat(uploadId, "/chunks"), options);
@@ -618,7 +638,7 @@ export var MediaStore = /*#__PURE__*/function () {
618
638
  }, _callee10, this);
619
639
  }));
620
640
 
621
- function appendChunksToUpload(_x23, _x24, _x25) {
641
+ function appendChunksToUpload(_x28, _x29, _x30, _x31) {
622
642
  return _appendChunksToUpload.apply(this, arguments);
623
643
  }
624
644
 
@@ -626,7 +646,7 @@ export var MediaStore = /*#__PURE__*/function () {
626
646
  }()
627
647
  }, {
628
648
  key: "copyFileWithToken",
629
- value: function copyFileWithToken(body, params) {
649
+ value: function copyFileWithToken(body, params, traceContext) {
630
650
  var metadata = {
631
651
  method: 'POST',
632
652
  endpoint: '/file/copy/withToken'
@@ -640,8 +660,9 @@ export var MediaStore = /*#__PURE__*/function () {
640
660
  params: params,
641
661
  // Contains collection name to write to
642
662
  headers: jsonHeaders,
643
- body: JSON.stringify(body) // Contains collection name to read from
644
-
663
+ body: JSON.stringify(body),
664
+ // Contains collection name to read from
665
+ traceContext: traceContext
645
666
  });
646
667
 
647
668
  return this.request('/file/copy/withToken', options).then(createMapResponseToJson(metadata));
@@ -659,7 +680,9 @@ export var MediaStore = /*#__PURE__*/function () {
659
680
  headers,
660
681
  body,
661
682
  clientOptions,
683
+ traceContext,
662
684
  auth,
685
+ extendedTraceContext,
663
686
  response,
664
687
  _args11 = arguments;
665
688
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
@@ -672,13 +695,16 @@ export var MediaStore = /*#__PURE__*/function () {
672
695
  authContext: {}
673
696
  };
674
697
  controller = _args11.length > 2 ? _args11[2] : undefined;
675
- method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions;
698
+ method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
676
699
  _context11.next = 5;
677
700
  return this.resolveAuth(authContext);
678
701
 
679
702
  case 5:
680
703
  auth = _context11.sent;
681
- _context11.next = 8;
704
+ extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
705
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(16)
706
+ }) : undefined;
707
+ _context11.next = 9;
682
708
  return _request("".concat(auth.baseUrl).concat(path), {
683
709
  method: method,
684
710
  endpoint: endpoint,
@@ -686,16 +712,17 @@ export var MediaStore = /*#__PURE__*/function () {
686
712
  params: params,
687
713
  headers: headers,
688
714
  body: body,
689
- clientOptions: clientOptions
715
+ clientOptions: clientOptions,
716
+ traceContext: extendedTraceContext
690
717
  }, controller);
691
718
 
692
- case 8:
719
+ case 9:
693
720
  response = _context11.sent;
694
721
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
695
722
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
696
723
  return _context11.abrupt("return", response);
697
724
 
698
- case 12:
725
+ case 13:
699
726
  case "end":
700
727
  return _context11.stop();
701
728
  }
@@ -703,7 +730,7 @@ export var MediaStore = /*#__PURE__*/function () {
703
730
  }, _callee11, this);
704
731
  }));
705
732
 
706
- function request(_x26) {
733
+ function request(_x32) {
707
734
  return _request2.apply(this, arguments);
708
735
  }
709
736
 
@@ -42,7 +42,7 @@ var hashingFunction = /*#__PURE__*/function () {
42
42
  };
43
43
  }();
44
44
 
45
- var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName) {
45
+ var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName, traceContext) {
46
46
  return /*#__PURE__*/function () {
47
47
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
48
48
  var response, results;
@@ -76,17 +76,18 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
76
76
  collectionName: _context2.t2,
77
77
  uploadId: _context2.t4
78
78
  };
79
- _context2.next = 14;
80
- return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5);
79
+ _context2.t6 = traceContext;
80
+ _context2.next = 15;
81
+ return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5, _context2.t6);
81
82
 
82
- case 14:
83
+ case 15:
83
84
  response = _context2.sent;
84
85
  results = response.data.results;
85
86
  return _context2.abrupt("return", Object.values(results).map(function (result) {
86
87
  return result.exists;
87
88
  }));
88
89
 
89
- case 17:
90
+ case 18:
90
91
  case "end":
91
92
  return _context2.stop();
92
93
  }
@@ -100,7 +101,7 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
100
101
  }();
101
102
  };
102
103
 
103
- var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName) {
104
+ var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
104
105
  return /*#__PURE__*/function () {
105
106
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
106
107
  var options;
@@ -134,7 +135,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
134
135
  _context3.next = 12;
135
136
  return store.uploadChunk(chunk.hash, chunk.blob, _objectSpread({
136
137
  collectionName: collectionName
137
- }, options));
138
+ }, options), traceContext);
138
139
 
139
140
  case 12:
140
141
  return _context3.abrupt("return", _context3.sent);
@@ -153,7 +154,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
153
154
  }();
154
155
  };
155
156
 
156
- var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection) {
157
+ var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
157
158
  var offset = 0;
158
159
  return /*#__PURE__*/function () {
159
160
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(chunks) {
@@ -172,13 +173,14 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
172
173
  offset: offset
173
174
  };
174
175
  _context4.t3 = collection;
175
- _context4.next = 8;
176
- return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3);
176
+ _context4.t4 = traceContext;
177
+ _context4.next = 9;
178
+ return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
177
179
 
178
- case 8:
180
+ case 9:
179
181
  offset += chunks.length;
180
182
 
181
- case 9:
183
+ case 10:
182
184
  case "end":
183
185
  return _context4.stop();
184
186
  }
@@ -193,7 +195,7 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
193
195
  };
194
196
 
195
197
  var createFileFromUpload = /*#__PURE__*/function () {
196
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId) {
198
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
197
199
  var collection, name, mimeType, id, occurrenceKey;
198
200
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
199
201
  while (1) {
@@ -209,7 +211,7 @@ var createFileFromUpload = /*#__PURE__*/function () {
209
211
  occurrenceKey: occurrenceKey,
210
212
  collection: collection,
211
213
  replaceFileId: id
212
- }));
214
+ }, traceContext));
213
215
 
214
216
  case 3:
215
217
  case "end":
@@ -219,12 +221,12 @@ var createFileFromUpload = /*#__PURE__*/function () {
219
221
  }, _callee5);
220
222
  }));
221
223
 
222
- return function createFileFromUpload(_x5, _x6, _x7, _x8) {
224
+ return function createFileFromUpload(_x5, _x6, _x7, _x8, _x9) {
223
225
  return _ref5.apply(this, arguments);
224
226
  };
225
227
  }();
226
228
 
227
- export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks) {
229
+ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks, traceContext) {
228
230
  var content = file.content,
229
231
  collection = file.collection;
230
232
  var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId,
@@ -257,10 +259,10 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
257
259
  probingBatchSize: 100,
258
260
  chunkSize: chunkSize,
259
261
  uploadingConcurrency: 3,
260
- uploadingFunction: createUploadingFunction(store, deferredUploadId, collection),
261
- probingFunction: createProbingFunction(store, deferredUploadId, collection),
262
+ uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
263
+ probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
262
264
  processingBatchSize: PROCESSING_BATCH_SIZE,
263
- processingFunction: createProcessingFunction(store, deferredUploadId, collection)
265
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
264
266
  }, {
265
267
  onProgress: function onProgress(progress) {
266
268
  if (callbacks) {
@@ -273,7 +275,7 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
273
275
 
274
276
  var subscription = from(deferredUploadId).pipe(concatMap(function (uploadId) {
275
277
  return chunkinatorObservable.pipe(concatMap(function () {
276
- return from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId));
278
+ return from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId, traceContext));
277
279
  }));
278
280
  })).subscribe({
279
281
  error: function error(err) {
@@ -1,33 +1,38 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import VideoSnapshot from 'video-snapshot';
4
3
  export var getVideoDimensionsFromBlob = /*#__PURE__*/function () {
5
4
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
6
- var snapshoter,
7
- _args = arguments;
8
5
  return _regeneratorRuntime.wrap(function _callee$(_context) {
9
6
  while (1) {
10
7
  switch (_context.prev = _context.next) {
11
8
  case 0:
12
- snapshoter = _args.length > 1 && _args[1] !== undefined ? _args[1] : new VideoSnapshot(blob);
13
- _context.prev = 1;
14
- _context.next = 4;
15
- return snapshoter.getDimensions();
9
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
10
+ var url = URL.createObjectURL(blob);
11
+ var video = document.createElement('video');
12
+ video.preload = 'metadata';
13
+ video.src = url;
14
+ video.muted = true; // loadedmetadata, loadeddata, play, playing
16
15
 
17
- case 4:
18
- return _context.abrupt("return", _context.sent);
16
+ video.addEventListener('loadedmetadata', function timeupdateHandler() {
17
+ video.removeEventListener('loadedmetadata', timeupdateHandler);
18
+ resolve({
19
+ width: video.videoWidth,
20
+ height: video.videoHeight
21
+ });
22
+ URL.revokeObjectURL(url);
23
+ });
24
+ video.addEventListener('error', function () {
25
+ reject(new Error('failed to load video'));
26
+ URL.revokeObjectURL(url);
27
+ });
28
+ }));
19
29
 
20
- case 5:
21
- _context.prev = 5;
22
- snapshoter.end();
23
- return _context.finish(5);
24
-
25
- case 8:
30
+ case 1:
26
31
  case "end":
27
32
  return _context.stop();
28
33
  }
29
34
  }
30
- }, _callee, null, [[1,, 5, 8]]);
35
+ }, _callee);
31
36
  }));
32
37
 
33
38
  return function getVideoDimensionsFromBlob(_x) {