@atlaskit/media-client 33.1.0 → 33.2.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.
@@ -76,8 +76,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
76
76
  var err = new _errors.CommonMediaClientError(error);
77
77
  return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, err);
78
78
  } else {
79
- var _err = new _errors.CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
80
- return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, _err);
79
+ var _err2 = new _errors.CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
80
+ return (0, _errors.fromCommonMediaClientError)(id, occurrenceKey, _err2);
81
81
  }
82
82
  });
83
83
  (0, _defineProperty2.default)(this, "setFileState", function (id, fileState) {
@@ -218,6 +218,201 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
218
218
  return _ref2.apply(this, arguments);
219
219
  };
220
220
  }());
221
+ (0, _defineProperty2.default)(this, "getOrFetchFileState", /*#__PURE__*/function () {
222
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, collectionName) {
223
+ var fileState;
224
+ return _regenerator.default.wrap(function _callee3$(_context3) {
225
+ while (1) switch (_context3.prev = _context3.next) {
226
+ case 0:
227
+ fileState = _this.store.getState().files[id];
228
+ if (!(fileState !== null && fileState !== void 0)) {
229
+ _context3.next = 5;
230
+ break;
231
+ }
232
+ _context3.t0 = fileState;
233
+ _context3.next = 8;
234
+ break;
235
+ case 5:
236
+ _context3.next = 7;
237
+ return _this.getCurrentState(id, {
238
+ collectionName: collectionName
239
+ });
240
+ case 7:
241
+ _context3.t0 = _context3.sent;
242
+ case 8:
243
+ return _context3.abrupt("return", _context3.t0);
244
+ case 9:
245
+ case "end":
246
+ return _context3.stop();
247
+ }
248
+ }, _callee3);
249
+ }));
250
+ return function (_x6, _x7) {
251
+ return _ref3.apply(this, arguments);
252
+ };
253
+ }());
254
+ (0, _defineProperty2.default)(this, "getDurationOfVideo", /*#__PURE__*/function () {
255
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, collectionName) {
256
+ var fileState, aritfactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
257
+ return _regenerator.default.wrap(function _callee4$(_context4) {
258
+ while (1) switch (_context4.prev = _context4.next) {
259
+ case 0:
260
+ _context4.next = 2;
261
+ return _this.getOrFetchFileState(id, collectionName);
262
+ case 2:
263
+ fileState = _context4.sent;
264
+ if (!(fileState.status !== "processed" || fileState.mediaType !== "video" || !fileState.artifacts["video.mp4"])) {
265
+ _context4.next = 5;
266
+ break;
267
+ }
268
+ throw new Error("File is not a video");
269
+ case 5:
270
+ _context4.next = 7;
271
+ return _this.getArtifactURL(fileState.artifacts, "video.mp4");
272
+ case 7:
273
+ aritfactUrl = _context4.sent;
274
+ artifactPath = new URL(aritfactUrl).pathname;
275
+ _context4.next = 11;
276
+ return _this.mediaApi.request(artifactPath, {
277
+ headers: {
278
+ Range: "bytes=0-199"
279
+ }
280
+ });
281
+ case 11:
282
+ res = _context4.sent;
283
+ _context4.next = 14;
284
+ return res.arrayBuffer();
285
+ case 14:
286
+ arrayBuffer = _context4.sent;
287
+ uint8Array = new Uint8Array(arrayBuffer);
288
+ mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
289
+ mvhdIndex = -1;
290
+ i = 0;
291
+ case 19:
292
+ if (!(i <= uint8Array.length - mvhdBytes.length)) {
293
+ _context4.next = 34;
294
+ break;
295
+ }
296
+ mvhdIndex = i;
297
+ j = 0;
298
+ case 22:
299
+ if (!(j < mvhdBytes.length)) {
300
+ _context4.next = 29;
301
+ break;
302
+ }
303
+ if (!(uint8Array[i + j] !== mvhdBytes[j])) {
304
+ _context4.next = 26;
305
+ break;
306
+ }
307
+ mvhdIndex = -1;
308
+ return _context4.abrupt("break", 29);
309
+ case 26:
310
+ j++;
311
+ _context4.next = 22;
312
+ break;
313
+ case 29:
314
+ if (!(mvhdIndex !== -1)) {
315
+ _context4.next = 31;
316
+ break;
317
+ }
318
+ return _context4.abrupt("break", 34);
319
+ case 31:
320
+ i++;
321
+ _context4.next = 19;
322
+ break;
323
+ case 34:
324
+ if (!(mvhdIndex === -1)) {
325
+ _context4.next = 36;
326
+ break;
327
+ }
328
+ throw new Error("Unable to find mvhd bytes");
329
+ case 36:
330
+ // Create DataView for reading big-endian integers
331
+ dataView = new DataView(arrayBuffer);
332
+ start = mvhdIndex + 16; // Skip atom header and version/flags
333
+ // Check if we have enough bytes to read timescale and duration
334
+ if (!(start + 8 > arrayBuffer.byteLength)) {
335
+ _context4.next = 40;
336
+ break;
337
+ }
338
+ return _context4.abrupt("return", 0);
339
+ case 40:
340
+ // flase as second parameter indicates big-endian 32-bit integers
341
+ timeScale = dataView.getUint32(start, false);
342
+ duration = dataView.getUint32(start + 4, false);
343
+ if (!(timeScale === 0)) {
344
+ _context4.next = 44;
345
+ break;
346
+ }
347
+ throw new Error("Timescale is invalid");
348
+ case 44:
349
+ // get the video length in seconds
350
+ videoLength = Math.floor(duration / timeScale);
351
+ return _context4.abrupt("return", videoLength);
352
+ case 46:
353
+ case "end":
354
+ return _context4.stop();
355
+ }
356
+ }, _callee4);
357
+ }));
358
+ return function (_x8, _x9) {
359
+ return _ref4.apply(this, arguments);
360
+ };
361
+ }());
362
+ (0, _defineProperty2.default)(this, "getVideoDurations", /*#__PURE__*/function () {
363
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(files) {
364
+ var promises, durations;
365
+ return _regenerator.default.wrap(function _callee6$(_context6) {
366
+ while (1) switch (_context6.prev = _context6.next) {
367
+ case 0:
368
+ // get all the duration promises
369
+ promises = files.map( /*#__PURE__*/function () {
370
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(_ref6) {
371
+ var id, collectionName;
372
+ return _regenerator.default.wrap(function _callee5$(_context5) {
373
+ while (1) switch (_context5.prev = _context5.next) {
374
+ case 0:
375
+ id = _ref6.id, collectionName = _ref6.collectionName;
376
+ _context5.prev = 1;
377
+ _context5.next = 4;
378
+ return _this.getDurationOfVideo(id, collectionName);
379
+ case 4:
380
+ return _context5.abrupt("return", _context5.sent);
381
+ case 7:
382
+ _context5.prev = 7;
383
+ _context5.t0 = _context5["catch"](1);
384
+ return _context5.abrupt("return", -1);
385
+ case 10:
386
+ case "end":
387
+ return _context5.stop();
388
+ }
389
+ }, _callee5, null, [[1, 7]]);
390
+ }));
391
+ return function (_x11) {
392
+ return _ref7.apply(this, arguments);
393
+ };
394
+ }());
395
+ _context6.next = 3;
396
+ return Promise.all(promises);
397
+ case 3:
398
+ durations = _context6.sent;
399
+ return _context6.abrupt("return", durations.reduce(function (acc, curr, i) {
400
+ if (curr !== -1) {
401
+ var _id = files[i].id;
402
+ acc[_id] = curr;
403
+ }
404
+ return acc;
405
+ }, {}));
406
+ case 5:
407
+ case "end":
408
+ return _context6.stop();
409
+ }
410
+ }, _callee6);
411
+ }));
412
+ return function (_x10) {
413
+ return _ref5.apply(this, arguments);
414
+ };
415
+ }());
221
416
  this.mediaApi = mediaApi;
222
417
  this.store = store;
223
418
  this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaApi);
@@ -283,8 +478,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
283
478
  descriptors: descriptors
284
479
  }, {
285
480
  collection: collection
286
- }, traceContext).then(function (_ref3) {
287
- var data = _ref3.data;
481
+ }, traceContext).then(function (_ref8) {
482
+ var data = _ref8.data;
288
483
  return data;
289
484
  });
290
485
  }
@@ -310,11 +505,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
310
505
  }, {
311
506
  key: "uploadExternal",
312
507
  value: function () {
313
- var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(url, collection, traceContext) {
508
+ var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(url, collection, traceContext) {
314
509
  var _this3 = this;
315
510
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
316
- return _regenerator.default.wrap(function _callee5$(_context5) {
317
- while (1) switch (_context5.prev = _context5.next) {
511
+ return _regenerator.default.wrap(function _callee9$(_context9) {
512
+ while (1) switch (_context9.prev = _context9.next) {
318
513
  case 0:
319
514
  uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
320
515
  id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
@@ -325,15 +520,15 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
325
520
  return undefined;
326
521
  });
327
522
  preview = new Promise( /*#__PURE__*/function () {
328
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) {
523
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(resolve, reject) {
329
524
  var blob;
330
- return _regenerator.default.wrap(function _callee3$(_context3) {
331
- while (1) switch (_context3.prev = _context3.next) {
525
+ return _regenerator.default.wrap(function _callee7$(_context7) {
526
+ while (1) switch (_context7.prev = _context7.next) {
332
527
  case 0:
333
- _context3.next = 2;
528
+ _context7.next = 2;
334
529
  return deferredBlob;
335
530
  case 2:
336
- blob = _context3.sent;
531
+ blob = _context7.sent;
337
532
  if (!blob) {
338
533
  reject('Could not fetch the blob');
339
534
  }
@@ -343,12 +538,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
343
538
  });
344
539
  case 5:
345
540
  case "end":
346
- return _context3.stop();
541
+ return _context7.stop();
347
542
  }
348
- }, _callee3);
543
+ }, _callee7);
349
544
  }));
350
- return function (_x9, _x10) {
351
- return _ref4.apply(this, arguments);
545
+ return function (_x15, _x16) {
546
+ return _ref9.apply(this, arguments);
352
547
  };
353
548
  }());
354
549
  name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
@@ -366,21 +561,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
366
561
  // we save it into the cache as soon as possible, in case someone subscribes
367
562
  (0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
368
563
  this.setFileState(id, fileState);
369
- return _context5.abrupt("return", new Promise( /*#__PURE__*/function () {
370
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(resolve, reject) {
564
+ return _context9.abrupt("return", new Promise( /*#__PURE__*/function () {
565
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(resolve, reject) {
371
566
  var blob, type, size, file, mediaType, dimensions;
372
- return _regenerator.default.wrap(function _callee4$(_context4) {
373
- while (1) switch (_context4.prev = _context4.next) {
567
+ return _regenerator.default.wrap(function _callee8$(_context8) {
568
+ while (1) switch (_context8.prev = _context8.next) {
374
569
  case 0:
375
- _context4.next = 2;
570
+ _context8.next = 2;
376
571
  return deferredBlob;
377
572
  case 2:
378
- blob = _context4.sent;
573
+ blob = _context8.sent;
379
574
  if (blob) {
380
- _context4.next = 5;
575
+ _context8.next = 5;
381
576
  break;
382
577
  }
383
- return _context4.abrupt("return", reject('Could not download remote file'));
578
+ return _context8.abrupt("return", reject('Could not download remote file'));
384
579
  case 5:
385
580
  type = blob.type, size = blob.size;
386
581
  file = {
@@ -403,18 +598,18 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
403
598
  });
404
599
  // we don't want to wait for the file to be upload
405
600
  _this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
406
- _context4.prev = 10;
407
- _context4.next = 13;
601
+ _context8.prev = 10;
602
+ _context8.next = 13;
408
603
  return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
409
604
  case 13:
410
- dimensions = _context4.sent;
411
- _context4.next = 20;
605
+ dimensions = _context8.sent;
606
+ _context8.next = 20;
412
607
  break;
413
608
  case 16:
414
- _context4.prev = 16;
415
- _context4.t0 = _context4["catch"](10);
416
- reject(_context4.t0);
417
- return _context4.abrupt("return");
609
+ _context8.prev = 16;
610
+ _context8.t0 = _context8["catch"](10);
611
+ reject(_context8.t0);
612
+ return _context8.abrupt("return");
418
613
  case 20:
419
614
  resolve({
420
615
  dimensions: dimensions,
@@ -423,21 +618,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
423
618
  });
424
619
  case 21:
425
620
  case "end":
426
- return _context4.stop();
621
+ return _context8.stop();
427
622
  }
428
- }, _callee4, null, [[10, 16]]);
623
+ }, _callee8, null, [[10, 16]]);
429
624
  }));
430
- return function (_x11, _x12) {
431
- return _ref5.apply(this, arguments);
625
+ return function (_x17, _x18) {
626
+ return _ref10.apply(this, arguments);
432
627
  };
433
628
  }()));
434
629
  case 11:
435
630
  case "end":
436
- return _context5.stop();
631
+ return _context9.stop();
437
632
  }
438
- }, _callee5, this);
633
+ }, _callee9, this);
439
634
  }));
440
- function uploadExternal(_x6, _x7, _x8) {
635
+ function uploadExternal(_x12, _x13, _x14) {
441
636
  return _uploadExternal.apply(this, arguments);
442
637
  }
443
638
  return uploadExternal;
@@ -504,22 +699,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
504
699
  }, {
505
700
  key: "downloadBinary",
506
701
  value: function () {
507
- var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(id) {
702
+ var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id) {
508
703
  var name,
509
704
  collectionName,
510
705
  traceContext,
511
706
  url,
512
- _args6 = arguments;
513
- return _regenerator.default.wrap(function _callee6$(_context6) {
514
- while (1) switch (_context6.prev = _context6.next) {
707
+ _args10 = arguments;
708
+ return _regenerator.default.wrap(function _callee10$(_context10) {
709
+ while (1) switch (_context10.prev = _context10.next) {
515
710
  case 0:
516
- name = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : 'download';
517
- collectionName = _args6.length > 2 ? _args6[2] : undefined;
518
- traceContext = _args6.length > 3 ? _args6[3] : undefined;
519
- _context6.next = 5;
711
+ name = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 'download';
712
+ collectionName = _args10.length > 2 ? _args10[2] : undefined;
713
+ traceContext = _args10.length > 3 ? _args10[3] : undefined;
714
+ _context10.next = 5;
520
715
  return this.mediaApi.getFileBinaryURL(id, collectionName);
521
716
  case 5:
522
- url = _context6.sent;
717
+ url = _context10.sent;
523
718
  (0, _downloadUrl.downloadUrl)(url, {
524
719
  name: name
525
720
  });
@@ -529,17 +724,17 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
529
724
  viewingLevel: 'download'
530
725
  });
531
726
  // Test the download after initiated the Browser process to catch any potential errors.
532
- _context6.next = 10;
727
+ _context10.next = 10;
533
728
  return this.mediaApi.testUrl(url, {
534
729
  traceContext: traceContext
535
730
  });
536
731
  case 10:
537
732
  case "end":
538
- return _context6.stop();
733
+ return _context10.stop();
539
734
  }
540
- }, _callee6, this);
735
+ }, _callee10, this);
541
736
  }));
542
- function downloadBinary(_x13) {
737
+ function downloadBinary(_x19) {
543
738
  return _downloadBinary.apply(this, arguments);
544
739
  }
545
740
  return downloadBinary;
@@ -547,28 +742,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
547
742
  }, {
548
743
  key: "registerCopyIntent",
549
744
  value: function () {
550
- var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, collectionName) {
745
+ var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(id, collectionName) {
551
746
  var auth, key, error;
552
- return _regenerator.default.wrap(function _callee7$(_context7) {
553
- while (1) switch (_context7.prev = _context7.next) {
747
+ return _regenerator.default.wrap(function _callee11$(_context11) {
748
+ while (1) switch (_context11.prev = _context11.next) {
554
749
  case 0:
555
- _context7.next = 2;
750
+ _context11.next = 2;
556
751
  return this.mediaApi.resolveAuth({
557
752
  collectionName: collectionName
558
753
  });
559
754
  case 2:
560
- auth = _context7.sent;
755
+ auth = _context11.sent;
561
756
  key = {
562
757
  id: id,
563
758
  collectionName: collectionName,
564
759
  resolvedAuth: auth
565
760
  };
566
- _context7.next = 6;
761
+ _context11.next = 6;
567
762
  return this.copyIntentRegisterationBatcher.load(key);
568
763
  case 6:
569
- error = _context7.sent;
764
+ error = _context11.sent;
570
765
  if (!error) {
571
- _context7.next = 10;
766
+ _context11.next = 10;
572
767
  break;
573
768
  }
574
769
  // if the error is retryable then it should not be cached
@@ -578,11 +773,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
578
773
  throw error;
579
774
  case 10:
580
775
  case "end":
581
- return _context7.stop();
776
+ return _context11.stop();
582
777
  }
583
- }, _callee7, this);
778
+ }, _callee11, this);
584
779
  }));
585
- function registerCopyIntent(_x14, _x15) {
780
+ function registerCopyIntent(_x20, _x21) {
586
781
  return _registerCopyIntent.apply(this, arguments);
587
782
  }
588
783
  return registerCopyIntent;
@@ -590,24 +785,24 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
590
785
  }, {
591
786
  key: "copyFileWithToken",
592
787
  value: function () {
593
- var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(source, destination, traceContext) {
788
+ var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(source, destination, traceContext) {
594
789
  var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
595
- return _regenerator.default.wrap(function _callee8$(_context8) {
596
- while (1) switch (_context8.prev = _context8.next) {
790
+ return _regenerator.default.wrap(function _callee12$(_context12) {
791
+ while (1) switch (_context12.prev = _context12.next) {
597
792
  case 0:
598
793
  authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
599
794
  destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
600
795
  mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
601
796
  authProvider: destinationAuthProvider
602
797
  });
603
- _context8.t0 = _mediaCore.authToOwner;
604
- _context8.next = 6;
798
+ _context12.t0 = _mediaCore.authToOwner;
799
+ _context12.next = 6;
605
800
  return authProvider({
606
801
  collectionName: sourceCollection
607
802
  });
608
803
  case 6:
609
- _context8.t1 = _context8.sent;
610
- owner = (0, _context8.t0)(_context8.t1);
804
+ _context12.t1 = _context12.sent;
805
+ owner = (0, _context12.t0)(_context12.t1);
611
806
  body = {
612
807
  sourceFile: {
613
808
  id: id,
@@ -620,19 +815,19 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
620
815
  replaceFileId: replaceFileId,
621
816
  occurrenceKey: occurrenceKey
622
817
  };
623
- _context8.next = 12;
818
+ _context12.next = 12;
624
819
  return mediaStore.copyFileWithToken(body, params, traceContext);
625
820
  case 12:
626
- _yield$mediaStore$cop = _context8.sent;
821
+ _yield$mediaStore$cop = _context12.sent;
627
822
  data = _yield$mediaStore$cop.data;
628
- return _context8.abrupt("return", data);
823
+ return _context12.abrupt("return", data);
629
824
  case 15:
630
825
  case "end":
631
- return _context8.stop();
826
+ return _context12.stop();
632
827
  }
633
- }, _callee8);
828
+ }, _callee12);
634
829
  }));
635
- function copyFileWithToken(_x16, _x17, _x18) {
830
+ function copyFileWithToken(_x22, _x23, _x24) {
636
831
  return _copyFileWithToken.apply(this, arguments);
637
832
  }
638
833
  return copyFileWithToken;
@@ -640,28 +835,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
640
835
  }, {
641
836
  key: "copyFileWithIntent",
642
837
  value: function () {
643
- var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(source, destination, traceContext) {
838
+ var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(source, destination, traceContext) {
644
839
  var res, data;
645
- return _regenerator.default.wrap(function _callee9$(_context9) {
646
- while (1) switch (_context9.prev = _context9.next) {
840
+ return _regenerator.default.wrap(function _callee13$(_context13) {
841
+ while (1) switch (_context13.prev = _context13.next) {
647
842
  case 0:
648
- _context9.next = 2;
843
+ _context13.next = 2;
649
844
  return this.mediaApi.copyFile(source.id, {
650
845
  sourceCollection: source.collection,
651
846
  collection: destination.collection,
652
847
  replaceFileId: destination.replaceFileId
653
848
  }, traceContext);
654
849
  case 2:
655
- res = _context9.sent;
850
+ res = _context13.sent;
656
851
  data = res.data;
657
- return _context9.abrupt("return", data);
852
+ return _context13.abrupt("return", data);
658
853
  case 5:
659
854
  case "end":
660
- return _context9.stop();
855
+ return _context13.stop();
661
856
  }
662
- }, _callee9, this);
857
+ }, _callee13, this);
663
858
  }));
664
- function copyFileWithIntent(_x19, _x20, _x21) {
859
+ function copyFileWithIntent(_x25, _x26, _x27) {
665
860
  return _copyFileWithIntent.apply(this, arguments);
666
861
  }
667
862
  return copyFileWithIntent;
@@ -669,7 +864,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
669
864
  }, {
670
865
  key: "copyFile",
671
866
  value: function () {
672
- var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(source, destination) {
867
+ var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(source, destination) {
673
868
  var _this5 = this;
674
869
  var options,
675
870
  traceContext,
@@ -696,32 +891,32 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
696
891
  replaceFileState,
697
892
  key,
698
893
  errorFileState,
699
- _args10 = arguments;
700
- return _regenerator.default.wrap(function _callee10$(_context10) {
701
- while (1) switch (_context10.prev = _context10.next) {
894
+ _args14 = arguments;
895
+ return _regenerator.default.wrap(function _callee14$(_context14) {
896
+ while (1) switch (_context14.prev = _context14.next) {
702
897
  case 0:
703
- options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
704
- traceContext = _args10.length > 3 ? _args10[3] : undefined;
898
+ options = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
899
+ traceContext = _args14.length > 3 ? _args14[3] : undefined;
705
900
  id = source.id;
706
901
  destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
707
902
  preview = options.preview, mimeType = options.mimeType;
708
903
  cache = (0, _fileStreamsCache.getFileStreamsCache)();
709
- _context10.prev = 6;
904
+ _context14.prev = 6;
710
905
  if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
711
- _context10.next = 13;
906
+ _context14.next = 13;
712
907
  break;
713
908
  }
714
- _context10.next = 10;
909
+ _context14.next = 10;
715
910
  return this.copyFileWithToken(source, destination, traceContext);
716
911
  case 10:
717
- copiedFile = _context10.sent;
718
- _context10.next = 16;
912
+ copiedFile = _context14.sent;
913
+ _context14.next = 16;
719
914
  break;
720
915
  case 13:
721
- _context10.next = 15;
916
+ _context14.next = 15;
722
917
  return this.copyFileWithIntent(source, destination, traceContext);
723
918
  case 15:
724
- copiedFile = _context10.sent;
919
+ copiedFile = _context14.sent;
725
920
  case 16:
726
921
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
727
922
  copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
@@ -738,21 +933,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
738
933
  previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
739
934
  preview: preview
740
935
  } : {};
741
- _context10.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
936
+ _context14.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
742
937
  // mimeType should always be returned by "copyFileWithToken"
743
938
  // but in case it's not, we don't want to penalize "copyFile"
744
939
  copiedMimeType;
745
- if (!_context10.t0) {
746
- _context10.next = 28;
940
+ if (!_context14.t0) {
941
+ _context14.next = 28;
747
942
  break;
748
943
  }
749
- _context10.next = 27;
944
+ _context14.next = 27;
750
945
  return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
751
946
  case 27:
752
- _context10.t0 = _context10.sent;
947
+ _context14.t0 = _context14.sent;
753
948
  case 28:
754
- if (!_context10.t0) {
755
- _context10.next = 35;
949
+ if (!_context14.t0) {
950
+ _context14.next = 35;
756
951
  break;
757
952
  }
758
953
  fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
@@ -773,7 +968,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
773
968
  return subject.complete();
774
969
  }
775
970
  });
776
- _context10.next = 36;
971
+ _context14.next = 36;
777
972
  break;
778
973
  case 35:
779
974
  if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
@@ -785,10 +980,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
785
980
  if (!cache.has(copiedId)) {
786
981
  (0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
787
982
  }
788
- return _context10.abrupt("return", copiedFile);
983
+ return _context14.abrupt("return", copiedFile);
789
984
  case 40:
790
- _context10.prev = 40;
791
- _context10.t1 = _context10["catch"](6);
985
+ _context14.prev = 40;
986
+ _context14.t1 = _context14["catch"](6);
792
987
  if (processingSubscription) {
793
988
  processingSubscription.unsubscribe();
794
989
  }
@@ -796,23 +991,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
796
991
  _fileCache = cache.get(replaceFileId);
797
992
  replaceFileState = this.store.getState().files[replaceFileId];
798
993
  if (_fileCache) {
799
- _fileCache.error(_context10.t1);
994
+ _fileCache.error(_context14.t1);
800
995
  } else {
801
996
  // Create a new subject with the error state for new subscriptions
802
- cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context10.t1));
997
+ cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context14.t1));
803
998
  }
804
999
  key = replaceFileState ? replaceFileId : id;
805
- errorFileState = this.getErrorFileState(_context10.t1, id, occurrenceKey);
1000
+ errorFileState = this.getErrorFileState(_context14.t1, id, occurrenceKey);
806
1001
  this.setFileState(key, errorFileState);
807
1002
  }
808
- throw _context10.t1;
1003
+ throw _context14.t1;
809
1004
  case 45:
810
1005
  case "end":
811
- return _context10.stop();
1006
+ return _context14.stop();
812
1007
  }
813
- }, _callee10, this, [[6, 40]]);
1008
+ }, _callee14, this, [[6, 40]]);
814
1009
  }));
815
- function copyFile(_x22, _x23) {
1010
+ function copyFile(_x28, _x29) {
816
1011
  return _copyFile.apply(this, arguments);
817
1012
  }
818
1013
  return copyFile;