@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
@@ -30,6 +30,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
30
30
 
31
31
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
32
32
 
33
+ var _mediaCommon = require("@atlaskit/media-common");
34
+
33
35
  var _constants = require("../../constants");
34
36
 
35
37
  var _artifacts = require("../../models/artifacts");
@@ -89,7 +91,7 @@ var MediaStore = /*#__PURE__*/function () {
89
91
  (0, _createClass2.default)(MediaStore, [{
90
92
  key: "getCollectionItems",
91
93
  value: function () {
92
- var _getCollectionItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionName, params) {
94
+ var _getCollectionItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionName, params, traceContext) {
93
95
  var metadata, options, response, _yield$createMapRespo, _yield$createMapRespo2, contents, nextInclusiveStartKey, contentsWithoutEmptyFiles;
94
96
 
95
97
  return _regenerator.default.wrap(function _callee$(_context) {
@@ -107,7 +109,8 @@ var MediaStore = /*#__PURE__*/function () {
107
109
  params: _objectSpread(_objectSpread({}, defaultGetCollectionItems), params),
108
110
  headers: {
109
111
  Accept: 'application/json'
110
- }
112
+ },
113
+ traceContext: traceContext
111
114
  });
112
115
  _context.next = 4;
113
116
  return this.request("/collection/".concat(collectionName, "/items"), options);
@@ -142,7 +145,7 @@ var MediaStore = /*#__PURE__*/function () {
142
145
  }, _callee, this);
143
146
  }));
144
147
 
145
- function getCollectionItems(_x, _x2) {
148
+ function getCollectionItems(_x, _x2, _x3) {
146
149
  return _getCollectionItems.apply(this, arguments);
147
150
  }
148
151
 
@@ -151,7 +154,7 @@ var MediaStore = /*#__PURE__*/function () {
151
154
  }, {
152
155
  key: "removeCollectionFile",
153
156
  value: function () {
154
- var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, collectionName, occurrenceKey) {
157
+ var _removeCollectionFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, collectionName, occurrenceKey, traceContext) {
155
158
  var metadata, body, options;
156
159
  return _regenerator.default.wrap(function _callee2$(_context2) {
157
160
  while (1) {
@@ -179,7 +182,8 @@ var MediaStore = /*#__PURE__*/function () {
179
182
  Accept: 'application/json',
180
183
  'Content-Type': 'application/json'
181
184
  },
182
- body: JSON.stringify(body)
185
+ body: JSON.stringify(body),
186
+ traceContext: traceContext
183
187
  });
184
188
  _context2.next = 5;
185
189
  return this.request("/collection/".concat(collectionName), options);
@@ -192,7 +196,7 @@ var MediaStore = /*#__PURE__*/function () {
192
196
  }, _callee2, this);
193
197
  }));
194
198
 
195
- function removeCollectionFile(_x3, _x4, _x5) {
199
+ function removeCollectionFile(_x4, _x5, _x6, _x7) {
196
200
  return _removeCollectionFile.apply(this, arguments);
197
201
  }
198
202
 
@@ -203,6 +207,7 @@ var MediaStore = /*#__PURE__*/function () {
203
207
  value: function createUpload() {
204
208
  var createUpTo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
205
209
  var collectionName = arguments.length > 1 ? arguments[1] : undefined;
210
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
206
211
  var metadata = {
207
212
  method: 'POST',
208
213
  endpoint: '/upload'
@@ -217,7 +222,8 @@ var MediaStore = /*#__PURE__*/function () {
217
222
  },
218
223
  headers: {
219
224
  Accept: 'application/json'
220
- }
225
+ },
226
+ traceContext: traceContext
221
227
  });
222
228
 
223
229
  return this.request("/upload", options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -230,6 +236,7 @@ var MediaStore = /*#__PURE__*/function () {
230
236
  collectionName,
231
237
  uploadId,
232
238
  partNumber,
239
+ traceContext,
233
240
  metadata,
234
241
  options,
235
242
  _args3 = arguments;
@@ -239,6 +246,7 @@ var MediaStore = /*#__PURE__*/function () {
239
246
  switch (_context3.prev = _context3.next) {
240
247
  case 0:
241
248
  _ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
249
+ traceContext = _args3.length > 3 ? _args3[3] : undefined;
242
250
  metadata = {
243
251
  method: 'PUT',
244
252
  endpoint: '/chunk/{etag}'
@@ -251,12 +259,13 @@ var MediaStore = /*#__PURE__*/function () {
251
259
  authContext: {
252
260
  collectionName: collectionName
253
261
  },
254
- body: blob
262
+ body: blob,
263
+ traceContext: traceContext
255
264
  });
256
- _context3.next = 5;
265
+ _context3.next = 6;
257
266
  return this.request("/chunk/".concat(etag), options);
258
267
 
259
- case 5:
268
+ case 6:
260
269
  case "end":
261
270
  return _context3.stop();
262
271
  }
@@ -264,7 +273,7 @@ var MediaStore = /*#__PURE__*/function () {
264
273
  }, _callee3, this);
265
274
  }));
266
275
 
267
- function uploadChunk(_x6, _x7) {
276
+ function uploadChunk(_x8, _x9) {
268
277
  return _uploadChunk.apply(this, arguments);
269
278
  }
270
279
 
@@ -277,6 +286,7 @@ var MediaStore = /*#__PURE__*/function () {
277
286
  collectionName = _ref2.collectionName,
278
287
  uploadId = _ref2.uploadId;
279
288
 
289
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
280
290
  var metadata = {
281
291
  method: 'POST',
282
292
  endpoint: '/chunk/probe'
@@ -292,7 +302,8 @@ var MediaStore = /*#__PURE__*/function () {
292
302
  headers: jsonHeaders,
293
303
  body: JSON.stringify({
294
304
  chunks: chunks
295
- })
305
+ }),
306
+ traceContext: traceContext
296
307
  });
297
308
 
298
309
  return this.request("/chunk/probe", options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -301,6 +312,7 @@ var MediaStore = /*#__PURE__*/function () {
301
312
  key: "createFileFromUpload",
302
313
  value: function createFileFromUpload(body) {
303
314
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
315
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
304
316
  var metadata = {
305
317
  method: 'POST',
306
318
  endpoint: '/file/upload'
@@ -312,7 +324,8 @@ var MediaStore = /*#__PURE__*/function () {
312
324
  },
313
325
  params: params,
314
326
  headers: jsonHeaders,
315
- body: JSON.stringify(body)
327
+ body: JSON.stringify(body),
328
+ traceContext: traceContext
316
329
  });
317
330
 
318
331
  return this.request('/file/upload', options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -321,6 +334,7 @@ var MediaStore = /*#__PURE__*/function () {
321
334
  key: "touchFiles",
322
335
  value: function touchFiles(body) {
323
336
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
337
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
324
338
  var metadata = {
325
339
  method: 'POST',
326
340
  endpoint: '/upload/createWithFiles'
@@ -331,7 +345,8 @@ var MediaStore = /*#__PURE__*/function () {
331
345
  collectionName: params.collection
332
346
  },
333
347
  headers: jsonHeaders,
334
- body: JSON.stringify(body)
348
+ body: JSON.stringify(body),
349
+ traceContext: traceContext
335
350
  });
336
351
 
337
352
  return this.request('/upload/createWithFiles', options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -340,6 +355,7 @@ var MediaStore = /*#__PURE__*/function () {
340
355
  key: "getFile",
341
356
  value: function getFile(fileId) {
342
357
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
358
+ var traceContext = arguments.length > 2 ? arguments[2] : undefined;
343
359
  var metadata = {
344
360
  method: 'GET',
345
361
  endpoint: '/file/{fileId}'
@@ -349,7 +365,8 @@ var MediaStore = /*#__PURE__*/function () {
349
365
  authContext: {
350
366
  collectionName: params.collection
351
367
  },
352
- params: params
368
+ params: params,
369
+ traceContext: traceContext
353
370
  });
354
371
 
355
372
  return this.request("/file/".concat(fileId), options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -382,12 +399,13 @@ var MediaStore = /*#__PURE__*/function () {
382
399
  }, _callee4, this);
383
400
  }));
384
401
 
385
- function getFileImageURL(_x8, _x9) {
402
+ function getFileImageURL(_x10, _x11) {
386
403
  return _getFileImageURL.apply(this, arguments);
387
404
  }
388
405
 
389
406
  return getFileImageURL;
390
- }()
407
+ }() // TODO Create ticket in case Trace Id can be supported through query params
408
+
391
409
  }, {
392
410
  key: "getFileImageURLSync",
393
411
  value: function getFileImageURLSync(id, params) {
@@ -437,7 +455,7 @@ var MediaStore = /*#__PURE__*/function () {
437
455
  }, _callee5, this);
438
456
  }));
439
457
 
440
- function getFileBinaryURL(_x10, _x11) {
458
+ function getFileBinaryURL(_x12, _x13) {
441
459
  return _getFileBinaryURL.apply(this, arguments);
442
460
  }
443
461
 
@@ -486,7 +504,7 @@ var MediaStore = /*#__PURE__*/function () {
486
504
  }, _callee6, this);
487
505
  }));
488
506
 
489
- function getArtifactURL(_x12, _x13, _x14) {
507
+ function getArtifactURL(_x14, _x15, _x16) {
490
508
  return _getArtifactURL.apply(this, arguments);
491
509
  }
492
510
 
@@ -495,7 +513,7 @@ var MediaStore = /*#__PURE__*/function () {
495
513
  }, {
496
514
  key: "getImage",
497
515
  value: function () {
498
- var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, params, controller, fetchMaxRes) {
516
+ var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, params, controller, fetchMaxRes, traceContext) {
499
517
  var isWebpSupported, headers, metadata, options;
500
518
  return _regenerator.default.wrap(function _callee7$(_context7) {
501
519
  while (1) {
@@ -503,11 +521,10 @@ var MediaStore = /*#__PURE__*/function () {
503
521
  case 0:
504
522
  // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
505
523
  isWebpSupported = false;
524
+ headers = {};
506
525
 
507
526
  if (isWebpSupported) {
508
- headers = {
509
- accept: 'image/webp,image/*,*/*;q=0.8'
510
- };
527
+ headers.accept = 'image/webp,image/*,*/*;q=0.8';
511
528
  }
512
529
 
513
530
  metadata = {
@@ -519,11 +536,12 @@ var MediaStore = /*#__PURE__*/function () {
519
536
  collectionName: params && params.collection
520
537
  },
521
538
  params: extendImageParams(params, fetchMaxRes),
522
- headers: headers
539
+ headers: headers,
540
+ traceContext: traceContext
523
541
  });
524
542
  return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
525
543
 
526
- case 5:
544
+ case 6:
527
545
  case "end":
528
546
  return _context7.stop();
529
547
  }
@@ -531,7 +549,7 @@ var MediaStore = /*#__PURE__*/function () {
531
549
  }, _callee7, this);
532
550
  }));
533
551
 
534
- function getImage(_x15, _x16, _x17, _x18) {
552
+ function getImage(_x17, _x18, _x19, _x20, _x21) {
535
553
  return _getImage.apply(this, arguments);
536
554
  }
537
555
 
@@ -540,7 +558,7 @@ var MediaStore = /*#__PURE__*/function () {
540
558
  }, {
541
559
  key: "getItems",
542
560
  value: function () {
543
- var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(ids, collectionName) {
561
+ var _getItems = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(ids, collectionName, traceContext) {
544
562
  var descriptors, metadata, options;
545
563
  return _regenerator.default.wrap(function _callee8$(_context8) {
546
564
  while (1) {
@@ -564,7 +582,8 @@ var MediaStore = /*#__PURE__*/function () {
564
582
  headers: jsonHeaders,
565
583
  body: JSON.stringify({
566
584
  descriptors: descriptors
567
- })
585
+ }),
586
+ traceContext: traceContext
568
587
  });
569
588
  return _context8.abrupt("return", this.request('/items', options).then((0, _helpers.createMapResponseToJson)(metadata)));
570
589
 
@@ -576,7 +595,7 @@ var MediaStore = /*#__PURE__*/function () {
576
595
  }, _callee8, this);
577
596
  }));
578
597
 
579
- function getItems(_x19, _x20) {
598
+ function getItems(_x22, _x23, _x24) {
580
599
  return _getItems.apply(this, arguments);
581
600
  }
582
601
 
@@ -585,7 +604,7 @@ var MediaStore = /*#__PURE__*/function () {
585
604
  }, {
586
605
  key: "getImageMetadata",
587
606
  value: function () {
588
- var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(id, params) {
607
+ var _getImageMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(id, params, traceContext) {
589
608
  var metadata, options;
590
609
  return _regenerator.default.wrap(function _callee9$(_context9) {
591
610
  while (1) {
@@ -599,7 +618,8 @@ var MediaStore = /*#__PURE__*/function () {
599
618
  authContext: {
600
619
  collectionName: params && params.collection
601
620
  },
602
- params: params
621
+ params: params,
622
+ traceContext: traceContext
603
623
  });
604
624
  return _context9.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then((0, _helpers.createMapResponseToJson)(metadata)));
605
625
 
@@ -611,7 +631,7 @@ var MediaStore = /*#__PURE__*/function () {
611
631
  }, _callee9, this);
612
632
  }));
613
633
 
614
- function getImageMetadata(_x21, _x22) {
634
+ function getImageMetadata(_x25, _x26, _x27) {
615
635
  return _getImageMetadata.apply(this, arguments);
616
636
  }
617
637
 
@@ -620,7 +640,7 @@ var MediaStore = /*#__PURE__*/function () {
620
640
  }, {
621
641
  key: "appendChunksToUpload",
622
642
  value: function () {
623
- var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(uploadId, body, collectionName) {
643
+ var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(uploadId, body, collectionName, traceContext) {
624
644
  var metadata, options;
625
645
  return _regenerator.default.wrap(function _callee10$(_context10) {
626
646
  while (1) {
@@ -635,7 +655,8 @@ var MediaStore = /*#__PURE__*/function () {
635
655
  collectionName: collectionName
636
656
  },
637
657
  headers: jsonHeaders,
638
- body: JSON.stringify(body)
658
+ body: JSON.stringify(body),
659
+ traceContext: traceContext
639
660
  });
640
661
  _context10.next = 4;
641
662
  return this.request("/upload/".concat(uploadId, "/chunks"), options);
@@ -648,7 +669,7 @@ var MediaStore = /*#__PURE__*/function () {
648
669
  }, _callee10, this);
649
670
  }));
650
671
 
651
- function appendChunksToUpload(_x23, _x24, _x25) {
672
+ function appendChunksToUpload(_x28, _x29, _x30, _x31) {
652
673
  return _appendChunksToUpload.apply(this, arguments);
653
674
  }
654
675
 
@@ -656,7 +677,7 @@ var MediaStore = /*#__PURE__*/function () {
656
677
  }()
657
678
  }, {
658
679
  key: "copyFileWithToken",
659
- value: function copyFileWithToken(body, params) {
680
+ value: function copyFileWithToken(body, params, traceContext) {
660
681
  var metadata = {
661
682
  method: 'POST',
662
683
  endpoint: '/file/copy/withToken'
@@ -670,8 +691,9 @@ var MediaStore = /*#__PURE__*/function () {
670
691
  params: params,
671
692
  // Contains collection name to write to
672
693
  headers: jsonHeaders,
673
- body: JSON.stringify(body) // Contains collection name to read from
674
-
694
+ body: JSON.stringify(body),
695
+ // Contains collection name to read from
696
+ traceContext: traceContext
675
697
  });
676
698
 
677
699
  return this.request('/file/copy/withToken', options).then((0, _helpers.createMapResponseToJson)(metadata));
@@ -689,7 +711,9 @@ var MediaStore = /*#__PURE__*/function () {
689
711
  headers,
690
712
  body,
691
713
  clientOptions,
714
+ traceContext,
692
715
  auth,
716
+ extendedTraceContext,
693
717
  response,
694
718
  _args11 = arguments;
695
719
  return _regenerator.default.wrap(function _callee11$(_context11) {
@@ -702,13 +726,16 @@ var MediaStore = /*#__PURE__*/function () {
702
726
  authContext: {}
703
727
  };
704
728
  controller = _args11.length > 2 ? _args11[2] : undefined;
705
- method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions;
729
+ method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext;
706
730
  _context11.next = 5;
707
731
  return this.resolveAuth(authContext);
708
732
 
709
733
  case 5:
710
734
  auth = _context11.sent;
711
- _context11.next = 8;
735
+ extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
736
+ spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || (0, _mediaCommon.getRandomHex)(16)
737
+ }) : undefined;
738
+ _context11.next = 9;
712
739
  return (0, _request3.request)("".concat(auth.baseUrl).concat(path), {
713
740
  method: method,
714
741
  endpoint: endpoint,
@@ -716,16 +743,17 @@ var MediaStore = /*#__PURE__*/function () {
716
743
  params: params,
717
744
  headers: headers,
718
745
  body: body,
719
- clientOptions: clientOptions
746
+ clientOptions: clientOptions,
747
+ traceContext: extendedTraceContext
720
748
  }, controller);
721
749
 
722
- case 8:
750
+ case 9:
723
751
  response = _context11.sent;
724
752
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
725
753
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
726
754
  return _context11.abrupt("return", response);
727
755
 
728
- case 12:
756
+ case 13:
729
757
  case "end":
730
758
  return _context11.stop();
731
759
  }
@@ -733,7 +761,7 @@ var MediaStore = /*#__PURE__*/function () {
733
761
  }, _callee11, this);
734
762
  }));
735
763
 
736
- function request(_x26) {
764
+ function request(_x32) {
737
765
  return _request2.apply(this, arguments);
738
766
  }
739
767
 
@@ -60,7 +60,7 @@ var hashingFunction = /*#__PURE__*/function () {
60
60
  };
61
61
  }();
62
62
 
63
- var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName) {
63
+ var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName, traceContext) {
64
64
  return /*#__PURE__*/function () {
65
65
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(chunks) {
66
66
  var response, results;
@@ -94,17 +94,18 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
94
94
  collectionName: _context2.t2,
95
95
  uploadId: _context2.t4
96
96
  };
97
- _context2.next = 14;
98
- return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5);
97
+ _context2.t6 = traceContext;
98
+ _context2.next = 15;
99
+ return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5, _context2.t6);
99
100
 
100
- case 14:
101
+ case 15:
101
102
  response = _context2.sent;
102
103
  results = response.data.results;
103
104
  return _context2.abrupt("return", Object.values(results).map(function (result) {
104
105
  return result.exists;
105
106
  }));
106
107
 
107
- case 17:
108
+ case 18:
108
109
  case "end":
109
110
  return _context2.stop();
110
111
  }
@@ -118,7 +119,7 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
118
119
  }();
119
120
  };
120
121
 
121
- var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName) {
122
+ var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
122
123
  return /*#__PURE__*/function () {
123
124
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(chunk) {
124
125
  var options;
@@ -152,7 +153,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
152
153
  _context3.next = 12;
153
154
  return store.uploadChunk(chunk.hash, chunk.blob, _objectSpread({
154
155
  collectionName: collectionName
155
- }, options));
156
+ }, options), traceContext);
156
157
 
157
158
  case 12:
158
159
  return _context3.abrupt("return", _context3.sent);
@@ -171,7 +172,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
171
172
  }();
172
173
  };
173
174
 
174
- var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection) {
175
+ var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
175
176
  var offset = 0;
176
177
  return /*#__PURE__*/function () {
177
178
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(chunks) {
@@ -190,13 +191,14 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
190
191
  offset: offset
191
192
  };
192
193
  _context4.t3 = collection;
193
- _context4.next = 8;
194
- return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3);
194
+ _context4.t4 = traceContext;
195
+ _context4.next = 9;
196
+ return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
195
197
 
196
- case 8:
198
+ case 9:
197
199
  offset += chunks.length;
198
200
 
199
- case 9:
201
+ case 10:
200
202
  case "end":
201
203
  return _context4.stop();
202
204
  }
@@ -211,7 +213,7 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
211
213
  };
212
214
 
213
215
  var createFileFromUpload = /*#__PURE__*/function () {
214
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId) {
216
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
215
217
  var collection, name, mimeType, id, occurrenceKey;
216
218
  return _regenerator.default.wrap(function _callee5$(_context5) {
217
219
  while (1) {
@@ -227,7 +229,7 @@ var createFileFromUpload = /*#__PURE__*/function () {
227
229
  occurrenceKey: occurrenceKey,
228
230
  collection: collection,
229
231
  replaceFileId: id
230
- }));
232
+ }, traceContext));
231
233
 
232
234
  case 3:
233
235
  case "end":
@@ -237,12 +239,12 @@ var createFileFromUpload = /*#__PURE__*/function () {
237
239
  }, _callee5);
238
240
  }));
239
241
 
240
- return function createFileFromUpload(_x5, _x6, _x7, _x8) {
242
+ return function createFileFromUpload(_x5, _x6, _x7, _x8, _x9) {
241
243
  return _ref5.apply(this, arguments);
242
244
  };
243
245
  }();
244
246
 
245
- var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks) {
247
+ var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks, traceContext) {
246
248
  var content = file.content,
247
249
  collection = file.collection;
248
250
  var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId,
@@ -275,10 +277,10 @@ var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, call
275
277
  probingBatchSize: 100,
276
278
  chunkSize: chunkSize,
277
279
  uploadingConcurrency: 3,
278
- uploadingFunction: createUploadingFunction(store, deferredUploadId, collection),
279
- probingFunction: createProbingFunction(store, deferredUploadId, collection),
280
+ uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
281
+ probingFunction: createProbingFunction(store, deferredUploadId, collection, traceContext),
280
282
  processingBatchSize: _constants.PROCESSING_BATCH_SIZE,
281
- processingFunction: createProcessingFunction(store, deferredUploadId, collection)
283
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
282
284
  }, {
283
285
  onProgress: function onProgress(progress) {
284
286
  if (callbacks) {
@@ -291,7 +293,7 @@ var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, call
291
293
 
292
294
  var subscription = (0, _from.from)(deferredUploadId).pipe((0, _concatMap.concatMap)(function (uploadId) {
293
295
  return chunkinatorObservable.pipe((0, _concatMap.concatMap)(function () {
294
- return (0, _from.from)(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId));
296
+ return (0, _from.from)(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId, traceContext));
295
297
  }));
296
298
  })).subscribe({
297
299
  error: function error(err) {
@@ -11,35 +11,39 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
11
11
 
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
 
14
- var _videoSnapshot = _interopRequireDefault(require("video-snapshot"));
15
-
16
14
  var getVideoDimensionsFromBlob = /*#__PURE__*/function () {
17
15
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(blob) {
18
- var snapshoter,
19
- _args = arguments;
20
16
  return _regenerator.default.wrap(function _callee$(_context) {
21
17
  while (1) {
22
18
  switch (_context.prev = _context.next) {
23
19
  case 0:
24
- snapshoter = _args.length > 1 && _args[1] !== undefined ? _args[1] : new _videoSnapshot.default(blob);
25
- _context.prev = 1;
26
- _context.next = 4;
27
- return snapshoter.getDimensions();
28
-
29
- case 4:
30
- return _context.abrupt("return", _context.sent);
31
-
32
- case 5:
33
- _context.prev = 5;
34
- snapshoter.end();
35
- return _context.finish(5);
36
-
37
- case 8:
20
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
21
+ var url = URL.createObjectURL(blob);
22
+ var video = document.createElement('video');
23
+ video.preload = 'metadata';
24
+ video.src = url;
25
+ video.muted = true; // loadedmetadata, loadeddata, play, playing
26
+
27
+ video.addEventListener('loadedmetadata', function timeupdateHandler() {
28
+ video.removeEventListener('loadedmetadata', timeupdateHandler);
29
+ resolve({
30
+ width: video.videoWidth,
31
+ height: video.videoHeight
32
+ });
33
+ URL.revokeObjectURL(url);
34
+ });
35
+ video.addEventListener('error', function () {
36
+ reject(new Error('failed to load video'));
37
+ URL.revokeObjectURL(url);
38
+ });
39
+ }));
40
+
41
+ case 1:
38
42
  case "end":
39
43
  return _context.stop();
40
44
  }
41
45
  }
42
- }, _callee, null, [[1,, 5, 8]]);
46
+ }, _callee);
43
47
  }));
44
48
 
45
49
  return function getVideoDimensionsFromBlob(_x) {