@atlaskit/media-client 33.3.2 → 33.4.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.
@@ -200,112 +200,145 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
200
200
  return _ref2.apply(this, arguments);
201
201
  };
202
202
  }());
203
- _defineProperty(this, "getOrFetchFileState", /*#__PURE__*/function () {
204
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, collectionName) {
205
- var fileState;
203
+ _defineProperty(this, "deleteArtifact", /*#__PURE__*/function () {
204
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, params, collectionName, traceContext) {
205
+ var file, updatedArtifacts, updatedFileState;
206
206
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
207
207
  while (1) switch (_context3.prev = _context3.next) {
208
+ case 0:
209
+ if (!(process.env.NODE_ENV === 'test')) {
210
+ _context3.next = 3;
211
+ break;
212
+ }
213
+ _context3.next = 3;
214
+ return _this.mediaApi.deleteArtifact(id, params, collectionName, traceContext);
215
+ case 3:
216
+ // Manually remove the artifact from file state instead of re-requesting the entire payload.
217
+ file = _this.store.getState().files[id];
218
+ if (file && file.status === 'processed' && file.artifacts) {
219
+ updatedArtifacts = _objectSpread({}, file.artifacts);
220
+ delete updatedArtifacts[params.artifactName];
221
+ updatedFileState = _objectSpread(_objectSpread({}, file), {}, {
222
+ artifacts: updatedArtifacts
223
+ });
224
+ _this.setFileState(id, updatedFileState);
225
+ }
226
+ case 5:
227
+ case "end":
228
+ return _context3.stop();
229
+ }
230
+ }, _callee3);
231
+ }));
232
+ return function (_x6, _x7, _x8, _x9) {
233
+ return _ref3.apply(this, arguments);
234
+ };
235
+ }());
236
+ _defineProperty(this, "getOrFetchFileState", /*#__PURE__*/function () {
237
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, collectionName) {
238
+ var fileState;
239
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
240
+ while (1) switch (_context4.prev = _context4.next) {
208
241
  case 0:
209
242
  fileState = _this.store.getState().files[id];
210
243
  if (!(fileState !== null && fileState !== void 0)) {
211
- _context3.next = 5;
244
+ _context4.next = 5;
212
245
  break;
213
246
  }
214
- _context3.t0 = fileState;
215
- _context3.next = 8;
247
+ _context4.t0 = fileState;
248
+ _context4.next = 8;
216
249
  break;
217
250
  case 5:
218
- _context3.next = 7;
251
+ _context4.next = 7;
219
252
  return _this.getCurrentState(id, {
220
253
  collectionName: collectionName
221
254
  });
222
255
  case 7:
223
- _context3.t0 = _context3.sent;
256
+ _context4.t0 = _context4.sent;
224
257
  case 8:
225
- return _context3.abrupt("return", _context3.t0);
258
+ return _context4.abrupt("return", _context4.t0);
226
259
  case 9:
227
260
  case "end":
228
- return _context3.stop();
261
+ return _context4.stop();
229
262
  }
230
- }, _callee3);
263
+ }, _callee4);
231
264
  }));
232
- return function (_x6, _x7) {
233
- return _ref3.apply(this, arguments);
265
+ return function (_x0, _x1) {
266
+ return _ref4.apply(this, arguments);
234
267
  };
235
268
  }());
236
269
  _defineProperty(this, "getDurationOfVideo", /*#__PURE__*/function () {
237
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, collectionName) {
270
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
238
271
  var fileState, artifactUrlString, artifactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
239
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
240
- while (1) switch (_context4.prev = _context4.next) {
272
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
273
+ while (1) switch (_context5.prev = _context5.next) {
241
274
  case 0:
242
- _context4.next = 2;
275
+ _context5.next = 2;
243
276
  return _this.getOrFetchFileState(id, collectionName);
244
277
  case 2:
245
- fileState = _context4.sent;
278
+ fileState = _context5.sent;
246
279
  if (!(fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4'])) {
247
- _context4.next = 5;
280
+ _context5.next = 5;
248
281
  break;
249
282
  }
250
283
  throw new Error('File is not a video');
251
284
  case 5:
252
- _context4.next = 7;
285
+ _context5.next = 7;
253
286
  return _this.getArtifactURL(fileState.artifacts, 'video.mp4');
254
287
  case 7:
255
- artifactUrlString = _context4.sent;
288
+ artifactUrlString = _context5.sent;
256
289
  artifactUrl = new URL(artifactUrlString);
257
290
  artifactPath = "".concat(artifactUrl.pathname).concat(artifactUrl.search);
258
- _context4.next = 12;
291
+ _context5.next = 12;
259
292
  return _this.mediaApi.request(artifactPath, {
260
293
  headers: {
261
294
  Range: 'bytes=0-199'
262
295
  }
263
296
  });
264
297
  case 12:
265
- res = _context4.sent;
266
- _context4.next = 15;
298
+ res = _context5.sent;
299
+ _context5.next = 15;
267
300
  return res.arrayBuffer();
268
301
  case 15:
269
- arrayBuffer = _context4.sent;
302
+ arrayBuffer = _context5.sent;
270
303
  uint8Array = new Uint8Array(arrayBuffer);
271
304
  mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
272
305
  mvhdIndex = -1;
273
306
  i = 0;
274
307
  case 20:
275
308
  if (!(i <= uint8Array.length - mvhdBytes.length)) {
276
- _context4.next = 35;
309
+ _context5.next = 35;
277
310
  break;
278
311
  }
279
312
  mvhdIndex = i;
280
313
  j = 0;
281
314
  case 23:
282
315
  if (!(j < mvhdBytes.length)) {
283
- _context4.next = 30;
316
+ _context5.next = 30;
284
317
  break;
285
318
  }
286
319
  if (!(uint8Array[i + j] !== mvhdBytes[j])) {
287
- _context4.next = 27;
320
+ _context5.next = 27;
288
321
  break;
289
322
  }
290
323
  mvhdIndex = -1;
291
- return _context4.abrupt("break", 30);
324
+ return _context5.abrupt("break", 30);
292
325
  case 27:
293
326
  j++;
294
- _context4.next = 23;
327
+ _context5.next = 23;
295
328
  break;
296
329
  case 30:
297
330
  if (!(mvhdIndex !== -1)) {
298
- _context4.next = 32;
331
+ _context5.next = 32;
299
332
  break;
300
333
  }
301
- return _context4.abrupt("break", 35);
334
+ return _context5.abrupt("break", 35);
302
335
  case 32:
303
336
  i++;
304
- _context4.next = 20;
337
+ _context5.next = 20;
305
338
  break;
306
339
  case 35:
307
340
  if (!(mvhdIndex === -1)) {
308
- _context4.next = 37;
341
+ _context5.next = 37;
309
342
  break;
310
343
  }
311
344
  throw new Error('Unable to find mvhd bytes');
@@ -315,71 +348,71 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
315
348
  start = mvhdIndex + 16; // Skip atom header and version/flags
316
349
  // Check if we have enough bytes to read timescale and duration
317
350
  if (!(start + 8 > arrayBuffer.byteLength)) {
318
- _context4.next = 41;
351
+ _context5.next = 41;
319
352
  break;
320
353
  }
321
- return _context4.abrupt("return", 0);
354
+ return _context5.abrupt("return", 0);
322
355
  case 41:
323
356
  // flase as second parameter indicates big-endian 32-bit integers
324
357
  timeScale = dataView.getUint32(start, false);
325
358
  duration = dataView.getUint32(start + 4, false);
326
359
  if (!(timeScale === 0)) {
327
- _context4.next = 45;
360
+ _context5.next = 45;
328
361
  break;
329
362
  }
330
363
  throw new Error('Timescale is invalid');
331
364
  case 45:
332
365
  // get the video length in seconds
333
366
  videoLength = Math.floor(duration / timeScale);
334
- return _context4.abrupt("return", videoLength);
367
+ return _context5.abrupt("return", videoLength);
335
368
  case 47:
336
369
  case "end":
337
- return _context4.stop();
370
+ return _context5.stop();
338
371
  }
339
- }, _callee4);
372
+ }, _callee5);
340
373
  }));
341
- return function (_x8, _x9) {
342
- return _ref4.apply(this, arguments);
374
+ return function (_x10, _x11) {
375
+ return _ref5.apply(this, arguments);
343
376
  };
344
377
  }());
345
378
  _defineProperty(this, "getVideoDurations", /*#__PURE__*/function () {
346
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(files) {
379
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(files) {
347
380
  var promises, durations;
348
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
349
- while (1) switch (_context6.prev = _context6.next) {
381
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
382
+ while (1) switch (_context7.prev = _context7.next) {
350
383
  case 0:
351
384
  // get all the duration promises
352
385
  promises = files.map( /*#__PURE__*/function () {
353
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref6) {
386
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
354
387
  var id, collectionName;
355
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
356
- while (1) switch (_context5.prev = _context5.next) {
388
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
389
+ while (1) switch (_context6.prev = _context6.next) {
357
390
  case 0:
358
- id = _ref6.id, collectionName = _ref6.collectionName;
359
- _context5.prev = 1;
360
- _context5.next = 4;
391
+ id = _ref7.id, collectionName = _ref7.collectionName;
392
+ _context6.prev = 1;
393
+ _context6.next = 4;
361
394
  return _this.getDurationOfVideo(id, collectionName);
362
395
  case 4:
363
- return _context5.abrupt("return", _context5.sent);
396
+ return _context6.abrupt("return", _context6.sent);
364
397
  case 7:
365
- _context5.prev = 7;
366
- _context5.t0 = _context5["catch"](1);
367
- return _context5.abrupt("return", -1);
398
+ _context6.prev = 7;
399
+ _context6.t0 = _context6["catch"](1);
400
+ return _context6.abrupt("return", -1);
368
401
  case 10:
369
402
  case "end":
370
- return _context5.stop();
403
+ return _context6.stop();
371
404
  }
372
- }, _callee5, null, [[1, 7]]);
405
+ }, _callee6, null, [[1, 7]]);
373
406
  }));
374
- return function (_x11) {
375
- return _ref7.apply(this, arguments);
407
+ return function (_x13) {
408
+ return _ref8.apply(this, arguments);
376
409
  };
377
410
  }());
378
- _context6.next = 3;
411
+ _context7.next = 3;
379
412
  return Promise.all(promises);
380
413
  case 3:
381
- durations = _context6.sent;
382
- return _context6.abrupt("return", durations.reduce(function (acc, curr, i) {
414
+ durations = _context7.sent;
415
+ return _context7.abrupt("return", durations.reduce(function (acc, curr, i) {
383
416
  if (curr !== -1) {
384
417
  var _id = files[i].id;
385
418
  acc[_id] = curr;
@@ -388,12 +421,12 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
388
421
  }, {}));
389
422
  case 5:
390
423
  case "end":
391
- return _context6.stop();
424
+ return _context7.stop();
392
425
  }
393
- }, _callee6);
426
+ }, _callee7);
394
427
  }));
395
- return function (_x10) {
396
- return _ref5.apply(this, arguments);
428
+ return function (_x12) {
429
+ return _ref6.apply(this, arguments);
397
430
  };
398
431
  }());
399
432
  this.mediaApi = mediaApi;
@@ -461,8 +494,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
461
494
  descriptors: descriptors
462
495
  }, {
463
496
  collection: collection
464
- }, traceContext).then(function (_ref8) {
465
- var data = _ref8.data;
497
+ }, traceContext).then(function (_ref9) {
498
+ var data = _ref9.data;
466
499
  return data;
467
500
  });
468
501
  }
@@ -488,11 +521,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
488
521
  }, {
489
522
  key: "uploadExternal",
490
523
  value: function () {
491
- var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url, collection, traceContext) {
524
+ var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, collection, traceContext) {
492
525
  var _this3 = this;
493
526
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
494
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
495
- while (1) switch (_context9.prev = _context9.next) {
527
+ return _regeneratorRuntime.wrap(function _callee0$(_context0) {
528
+ while (1) switch (_context0.prev = _context0.next) {
496
529
  case 0:
497
530
  uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
498
531
  id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
@@ -503,15 +536,15 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
503
536
  return undefined;
504
537
  });
505
538
  preview = new Promise( /*#__PURE__*/function () {
506
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(resolve, reject) {
539
+ var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(resolve, reject) {
507
540
  var blob;
508
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
509
- while (1) switch (_context7.prev = _context7.next) {
541
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
542
+ while (1) switch (_context8.prev = _context8.next) {
510
543
  case 0:
511
- _context7.next = 2;
544
+ _context8.next = 2;
512
545
  return deferredBlob;
513
546
  case 2:
514
- blob = _context7.sent;
547
+ blob = _context8.sent;
515
548
  if (!blob) {
516
549
  reject('Could not fetch the blob');
517
550
  }
@@ -521,12 +554,12 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
521
554
  });
522
555
  case 5:
523
556
  case "end":
524
- return _context7.stop();
557
+ return _context8.stop();
525
558
  }
526
- }, _callee7);
559
+ }, _callee8);
527
560
  }));
528
- return function (_x15, _x16) {
529
- return _ref9.apply(this, arguments);
561
+ return function (_x17, _x18) {
562
+ return _ref0.apply(this, arguments);
530
563
  };
531
564
  }());
532
565
  name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
@@ -544,21 +577,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
544
577
  // we save it into the cache as soon as possible, in case someone subscribes
545
578
  getFileStreamsCache().set(id, subject);
546
579
  this.setFileState(id, fileState);
547
- return _context9.abrupt("return", new Promise( /*#__PURE__*/function () {
548
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(resolve, reject) {
580
+ return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
581
+ var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(resolve, reject) {
549
582
  var blob, type, size, file, mediaType, dimensions;
550
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
551
- while (1) switch (_context8.prev = _context8.next) {
583
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
584
+ while (1) switch (_context9.prev = _context9.next) {
552
585
  case 0:
553
- _context8.next = 2;
586
+ _context9.next = 2;
554
587
  return deferredBlob;
555
588
  case 2:
556
- blob = _context8.sent;
589
+ blob = _context9.sent;
557
590
  if (blob) {
558
- _context8.next = 5;
591
+ _context9.next = 5;
559
592
  break;
560
593
  }
561
- return _context8.abrupt("return", reject('Could not download remote file'));
594
+ return _context9.abrupt("return", reject('Could not download remote file'));
562
595
  case 5:
563
596
  type = blob.type, size = blob.size;
564
597
  file = {
@@ -581,18 +614,18 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
581
614
  });
582
615
  // we don't want to wait for the file to be upload
583
616
  _this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
584
- _context8.prev = 10;
585
- _context8.next = 13;
617
+ _context9.prev = 10;
618
+ _context9.next = 13;
586
619
  return getDimensionsFromBlob(mediaType, blob);
587
620
  case 13:
588
- dimensions = _context8.sent;
589
- _context8.next = 20;
621
+ dimensions = _context9.sent;
622
+ _context9.next = 20;
590
623
  break;
591
624
  case 16:
592
- _context8.prev = 16;
593
- _context8.t0 = _context8["catch"](10);
594
- reject(_context8.t0);
595
- return _context8.abrupt("return");
625
+ _context9.prev = 16;
626
+ _context9.t0 = _context9["catch"](10);
627
+ reject(_context9.t0);
628
+ return _context9.abrupt("return");
596
629
  case 20:
597
630
  resolve({
598
631
  dimensions: dimensions,
@@ -601,21 +634,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
601
634
  });
602
635
  case 21:
603
636
  case "end":
604
- return _context8.stop();
637
+ return _context9.stop();
605
638
  }
606
- }, _callee8, null, [[10, 16]]);
639
+ }, _callee9, null, [[10, 16]]);
607
640
  }));
608
- return function (_x17, _x18) {
609
- return _ref10.apply(this, arguments);
641
+ return function (_x19, _x20) {
642
+ return _ref1.apply(this, arguments);
610
643
  };
611
644
  }()));
612
645
  case 11:
613
646
  case "end":
614
- return _context9.stop();
647
+ return _context0.stop();
615
648
  }
616
- }, _callee9, this);
649
+ }, _callee0, this);
617
650
  }));
618
- function uploadExternal(_x12, _x13, _x14) {
651
+ function uploadExternal(_x14, _x15, _x16) {
619
652
  return _uploadExternal.apply(this, arguments);
620
653
  }
621
654
  return uploadExternal;
@@ -682,22 +715,22 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
682
715
  }, {
683
716
  key: "downloadBinary",
684
717
  value: function () {
685
- var _downloadBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id) {
718
+ var _downloadBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(id) {
686
719
  var name,
687
720
  collectionName,
688
721
  traceContext,
689
722
  url,
690
- _args10 = arguments;
691
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
692
- while (1) switch (_context10.prev = _context10.next) {
723
+ _args1 = arguments;
724
+ return _regeneratorRuntime.wrap(function _callee1$(_context1) {
725
+ while (1) switch (_context1.prev = _context1.next) {
693
726
  case 0:
694
- name = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : 'download';
695
- collectionName = _args10.length > 2 ? _args10[2] : undefined;
696
- traceContext = _args10.length > 3 ? _args10[3] : undefined;
697
- _context10.next = 5;
727
+ name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
728
+ collectionName = _args1.length > 2 ? _args1[2] : undefined;
729
+ traceContext = _args1.length > 3 ? _args1[3] : undefined;
730
+ _context1.next = 5;
698
731
  return this.mediaApi.getFileBinaryURL(id, collectionName);
699
732
  case 5:
700
- url = _context10.sent;
733
+ url = _context1.sent;
701
734
  downloadUrl(url, {
702
735
  name: name
703
736
  });
@@ -707,17 +740,17 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
707
740
  viewingLevel: 'download'
708
741
  });
709
742
  // Test the download after initiated the Browser process to catch any potential errors.
710
- _context10.next = 10;
743
+ _context1.next = 10;
711
744
  return this.mediaApi.testUrl(url, {
712
745
  traceContext: traceContext
713
746
  });
714
747
  case 10:
715
748
  case "end":
716
- return _context10.stop();
749
+ return _context1.stop();
717
750
  }
718
- }, _callee10, this);
751
+ }, _callee1, this);
719
752
  }));
720
- function downloadBinary(_x19) {
753
+ function downloadBinary(_x21) {
721
754
  return _downloadBinary.apply(this, arguments);
722
755
  }
723
756
  return downloadBinary;
@@ -725,28 +758,28 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
725
758
  }, {
726
759
  key: "registerCopyIntent",
727
760
  value: function () {
728
- var _registerCopyIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, collectionName) {
761
+ var _registerCopyIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id, collectionName) {
729
762
  var auth, key, error;
730
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
731
- while (1) switch (_context11.prev = _context11.next) {
763
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
764
+ while (1) switch (_context10.prev = _context10.next) {
732
765
  case 0:
733
- _context11.next = 2;
766
+ _context10.next = 2;
734
767
  return this.mediaApi.resolveAuth({
735
768
  collectionName: collectionName
736
769
  });
737
770
  case 2:
738
- auth = _context11.sent;
771
+ auth = _context10.sent;
739
772
  key = {
740
773
  id: id,
741
774
  collectionName: collectionName,
742
775
  resolvedAuth: auth
743
776
  };
744
- _context11.next = 6;
777
+ _context10.next = 6;
745
778
  return this.copyIntentRegisterationBatcher.load(key);
746
779
  case 6:
747
- error = _context11.sent;
780
+ error = _context10.sent;
748
781
  if (!error) {
749
- _context11.next = 10;
782
+ _context10.next = 10;
750
783
  break;
751
784
  }
752
785
  // if the error is retryable then it should not be cached
@@ -756,11 +789,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
756
789
  throw error;
757
790
  case 10:
758
791
  case "end":
759
- return _context11.stop();
792
+ return _context10.stop();
760
793
  }
761
- }, _callee11, this);
794
+ }, _callee10, this);
762
795
  }));
763
- function registerCopyIntent(_x20, _x21) {
796
+ function registerCopyIntent(_x22, _x23) {
764
797
  return _registerCopyIntent.apply(this, arguments);
765
798
  }
766
799
  return registerCopyIntent;
@@ -768,24 +801,24 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
768
801
  }, {
769
802
  key: "copyFileWithToken",
770
803
  value: function () {
771
- var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(source, destination, traceContext) {
804
+ var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(source, destination, traceContext) {
772
805
  var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
773
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
774
- while (1) switch (_context12.prev = _context12.next) {
806
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
807
+ while (1) switch (_context11.prev = _context11.next) {
775
808
  case 0:
776
809
  authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
777
810
  destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
778
811
  mediaStore = destination.mediaStore || new MediaApi({
779
812
  authProvider: destinationAuthProvider
780
813
  });
781
- _context12.t0 = authToOwner;
782
- _context12.next = 6;
814
+ _context11.t0 = authToOwner;
815
+ _context11.next = 6;
783
816
  return authProvider({
784
817
  collectionName: sourceCollection
785
818
  });
786
819
  case 6:
787
- _context12.t1 = _context12.sent;
788
- owner = (0, _context12.t0)(_context12.t1);
820
+ _context11.t1 = _context11.sent;
821
+ owner = (0, _context11.t0)(_context11.t1);
789
822
  body = {
790
823
  sourceFile: {
791
824
  id: id,
@@ -798,19 +831,19 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
798
831
  replaceFileId: replaceFileId,
799
832
  occurrenceKey: occurrenceKey
800
833
  };
801
- _context12.next = 12;
834
+ _context11.next = 12;
802
835
  return mediaStore.copyFileWithToken(body, params, traceContext);
803
836
  case 12:
804
- _yield$mediaStore$cop = _context12.sent;
837
+ _yield$mediaStore$cop = _context11.sent;
805
838
  data = _yield$mediaStore$cop.data;
806
- return _context12.abrupt("return", data);
839
+ return _context11.abrupt("return", data);
807
840
  case 15:
808
841
  case "end":
809
- return _context12.stop();
842
+ return _context11.stop();
810
843
  }
811
- }, _callee12);
844
+ }, _callee11);
812
845
  }));
813
- function copyFileWithToken(_x22, _x23, _x24) {
846
+ function copyFileWithToken(_x24, _x25, _x26) {
814
847
  return _copyFileWithToken.apply(this, arguments);
815
848
  }
816
849
  return copyFileWithToken;
@@ -818,28 +851,28 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
818
851
  }, {
819
852
  key: "copyFileWithIntent",
820
853
  value: function () {
821
- var _copyFileWithIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(source, destination, traceContext) {
854
+ var _copyFileWithIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(source, destination, traceContext) {
822
855
  var res, data;
823
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
824
- while (1) switch (_context13.prev = _context13.next) {
856
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
857
+ while (1) switch (_context12.prev = _context12.next) {
825
858
  case 0:
826
- _context13.next = 2;
859
+ _context12.next = 2;
827
860
  return this.mediaApi.copyFile(source.id, {
828
861
  sourceCollection: source.collection,
829
862
  collection: destination.collection,
830
863
  replaceFileId: destination.replaceFileId
831
864
  }, traceContext);
832
865
  case 2:
833
- res = _context13.sent;
866
+ res = _context12.sent;
834
867
  data = res.data;
835
- return _context13.abrupt("return", data);
868
+ return _context12.abrupt("return", data);
836
869
  case 5:
837
870
  case "end":
838
- return _context13.stop();
871
+ return _context12.stop();
839
872
  }
840
- }, _callee13, this);
873
+ }, _callee12, this);
841
874
  }));
842
- function copyFileWithIntent(_x25, _x26, _x27) {
875
+ function copyFileWithIntent(_x27, _x28, _x29) {
843
876
  return _copyFileWithIntent.apply(this, arguments);
844
877
  }
845
878
  return copyFileWithIntent;
@@ -847,7 +880,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
847
880
  }, {
848
881
  key: "copyFile",
849
882
  value: function () {
850
- var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(source, destination) {
883
+ var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(source, destination) {
851
884
  var _this5 = this;
852
885
  var options,
853
886
  traceContext,
@@ -874,32 +907,32 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
874
907
  replaceFileState,
875
908
  key,
876
909
  errorFileState,
877
- _args14 = arguments;
878
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
879
- while (1) switch (_context14.prev = _context14.next) {
910
+ _args13 = arguments;
911
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
912
+ while (1) switch (_context13.prev = _context13.next) {
880
913
  case 0:
881
- options = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
882
- traceContext = _args14.length > 3 ? _args14[3] : undefined;
914
+ options = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
915
+ traceContext = _args13.length > 3 ? _args13[3] : undefined;
883
916
  id = source.id;
884
917
  destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
885
918
  preview = options.preview, mimeType = options.mimeType;
886
919
  cache = getFileStreamsCache();
887
- _context14.prev = 6;
920
+ _context13.prev = 6;
888
921
  if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
889
- _context14.next = 13;
922
+ _context13.next = 13;
890
923
  break;
891
924
  }
892
- _context14.next = 10;
925
+ _context13.next = 10;
893
926
  return this.copyFileWithToken(source, destination, traceContext);
894
927
  case 10:
895
- copiedFile = _context14.sent;
896
- _context14.next = 16;
928
+ copiedFile = _context13.sent;
929
+ _context13.next = 16;
897
930
  break;
898
931
  case 13:
899
- _context14.next = 15;
932
+ _context13.next = 15;
900
933
  return this.copyFileWithIntent(source, destination, traceContext);
901
934
  case 15:
902
- copiedFile = _context14.sent;
935
+ copiedFile = _context13.sent;
903
936
  case 16:
904
937
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
905
938
  copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
@@ -916,21 +949,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
916
949
  previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
917
950
  preview: preview
918
951
  } : {};
919
- _context14.t0 = !isFinalFileState(copiedFileState) &&
952
+ _context13.t0 = !isFinalFileState(copiedFileState) &&
920
953
  // mimeType should always be returned by "copyFileWithToken"
921
954
  // but in case it's not, we don't want to penalize "copyFile"
922
955
  copiedMimeType;
923
- if (!_context14.t0) {
924
- _context14.next = 28;
956
+ if (!_context13.t0) {
957
+ _context13.next = 28;
925
958
  break;
926
959
  }
927
- _context14.next = 27;
960
+ _context13.next = 27;
928
961
  return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
929
962
  case 27:
930
- _context14.t0 = _context14.sent;
963
+ _context13.t0 = _context13.sent;
931
964
  case 28:
932
- if (!_context14.t0) {
933
- _context14.next = 35;
965
+ if (!_context13.t0) {
966
+ _context13.next = 35;
934
967
  break;
935
968
  }
936
969
  fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), overrideMediaTypeIfUnknown(copiedFileState, mediaType)), previewOverride);
@@ -951,7 +984,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
951
984
  return subject.complete();
952
985
  }
953
986
  });
954
- _context14.next = 36;
987
+ _context13.next = 36;
955
988
  break;
956
989
  case 35:
957
990
  if (!isProcessingFileState(copiedFileState)) {
@@ -963,10 +996,10 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
963
996
  if (!cache.has(copiedId)) {
964
997
  getFileStreamsCache().set(copiedId, subject);
965
998
  }
966
- return _context14.abrupt("return", copiedFile);
999
+ return _context13.abrupt("return", copiedFile);
967
1000
  case 40:
968
- _context14.prev = 40;
969
- _context14.t1 = _context14["catch"](6);
1001
+ _context13.prev = 40;
1002
+ _context13.t1 = _context13["catch"](6);
970
1003
  if (processingSubscription) {
971
1004
  processingSubscription.unsubscribe();
972
1005
  }
@@ -974,23 +1007,23 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
974
1007
  _fileCache = cache.get(replaceFileId);
975
1008
  replaceFileState = this.store.getState().files[replaceFileId];
976
1009
  if (_fileCache) {
977
- _fileCache.error(_context14.t1);
1010
+ _fileCache.error(_context13.t1);
978
1011
  } else {
979
1012
  // Create a new subject with the error state for new subscriptions
980
- cache.set(id, createMediaSubject(_context14.t1));
1013
+ cache.set(id, createMediaSubject(_context13.t1));
981
1014
  }
982
1015
  key = replaceFileState ? replaceFileId : id;
983
- errorFileState = this.getErrorFileState(_context14.t1, id, occurrenceKey);
1016
+ errorFileState = this.getErrorFileState(_context13.t1, id, occurrenceKey);
984
1017
  this.setFileState(key, errorFileState);
985
1018
  }
986
- throw _context14.t1;
1019
+ throw _context13.t1;
987
1020
  case 45:
988
1021
  case "end":
989
- return _context14.stop();
1022
+ return _context13.stop();
990
1023
  }
991
- }, _callee14, this, [[6, 40]]);
1024
+ }, _callee13, this, [[6, 40]]);
992
1025
  }));
993
- function copyFile(_x28, _x29) {
1026
+ function copyFile(_x30, _x31) {
994
1027
  return _copyFile.apply(this, arguments);
995
1028
  }
996
1029
  return copyFile;