@atlaskit/media-client 28.5.0 → 28.6.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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/client/file-fetcher/error.js +5 -7
  3. package/dist/cjs/client/file-fetcher/index.js +135 -71
  4. package/dist/cjs/client/media-client.js +1 -2
  5. package/dist/cjs/client/media-store/MediaStore.js +10 -3
  6. package/dist/cjs/client/media-store/error.js +5 -7
  7. package/dist/cjs/client/mobile-upload.js +1 -2
  8. package/dist/cjs/client/stargate-client.js +1 -2
  9. package/dist/cjs/file-streams-cache.js +1 -2
  10. package/dist/cjs/models/errors/index.js +6 -8
  11. package/dist/cjs/upload-controller.js +1 -2
  12. package/dist/cjs/uploader/error.js +5 -7
  13. package/dist/cjs/utils/hashing/sha256SimpleHasher.js +1 -2
  14. package/dist/cjs/utils/hashing/simpleHasher.js +1 -2
  15. package/dist/cjs/utils/hashing/workerHasher.js +1 -2
  16. package/dist/cjs/utils/mobileUpload/error.js +5 -7
  17. package/dist/cjs/utils/polling/errors.js +5 -7
  18. package/dist/cjs/utils/polling/index.js +1 -2
  19. package/dist/cjs/utils/request/errors.js +5 -7
  20. package/dist/cjs/utils/request/helpers.js +10 -4
  21. package/dist/es2019/client/file-fetcher/index.js +38 -8
  22. package/dist/es2019/client/media-store/MediaStore.js +11 -3
  23. package/dist/es2019/utils/request/helpers.js +7 -2
  24. package/dist/esm/client/file-fetcher/error.js +5 -7
  25. package/dist/esm/client/file-fetcher/index.js +135 -71
  26. package/dist/esm/client/media-client.js +1 -2
  27. package/dist/esm/client/media-store/MediaStore.js +12 -5
  28. package/dist/esm/client/media-store/error.js +5 -7
  29. package/dist/esm/client/mobile-upload.js +1 -2
  30. package/dist/esm/client/stargate-client.js +1 -2
  31. package/dist/esm/file-streams-cache.js +1 -2
  32. package/dist/esm/models/errors/index.js +6 -8
  33. package/dist/esm/upload-controller.js +1 -2
  34. package/dist/esm/uploader/error.js +5 -7
  35. package/dist/esm/utils/hashing/sha256SimpleHasher.js +1 -2
  36. package/dist/esm/utils/hashing/simpleHasher.js +1 -2
  37. package/dist/esm/utils/hashing/workerHasher.js +1 -2
  38. package/dist/esm/utils/mobileUpload/error.js +5 -7
  39. package/dist/esm/utils/polling/errors.js +5 -7
  40. package/dist/esm/utils/polling/index.js +1 -2
  41. package/dist/esm/utils/request/errors.js +5 -7
  42. package/dist/esm/utils/request/helpers.js +9 -4
  43. package/dist/types/client/file-fetcher/index.d.ts +4 -2
  44. package/dist/types/utils/request/helpers.d.ts +1 -0
  45. package/dist/types/utils/request/types.d.ts +1 -0
  46. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +4 -2
  47. package/dist/types-ts4.5/utils/request/helpers.d.ts +1 -0
  48. package/dist/types-ts4.5/utils/request/types.d.ts +1 -0
  49. package/package.json +1 -1
@@ -35,6 +35,12 @@ import { PollingFunction } from '../../utils/polling';
35
35
  import { isEmptyFile } from '../../utils/detectEmptyFile';
36
36
  import { mediaStore } from '@atlaskit/media-state';
37
37
  export { isFileFetcherError, FileFetcherError } from './error';
38
+ var isCopySourceFileWithToken = function isCopySourceFileWithToken(token) {
39
+ return !!token.authProvider;
40
+ };
41
+ var isCopyDestinationWithToken = function isCopyDestinationWithToken(token) {
42
+ return !!token.authProvider;
43
+ };
38
44
  export var FileFetcherImpl = /*#__PURE__*/function () {
39
45
  function FileFetcherImpl(mediaApi) {
40
46
  var _this = this;
@@ -166,7 +172,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
166
172
  this.store = store;
167
173
  this.dataloader = createFileDataloader(mediaApi);
168
174
  }
169
- _createClass(FileFetcherImpl, [{
175
+ return _createClass(FileFetcherImpl, [{
170
176
  key: "getFileState",
171
177
  value: function getFileState(id) {
172
178
  var _this2 = this;
@@ -495,29 +501,100 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
495
501
  }
496
502
  return downloadBinary;
497
503
  }()
504
+ }, {
505
+ key: "copyFileWithToken",
506
+ value: function () {
507
+ var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, destination, traceContext) {
508
+ var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
509
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
510
+ while (1) switch (_context6.prev = _context6.next) {
511
+ case 0:
512
+ authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
513
+ destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
514
+ mediaStore = destination.mediaStore || new MediaApi({
515
+ authProvider: destinationAuthProvider
516
+ });
517
+ _context6.t0 = authToOwner;
518
+ _context6.next = 6;
519
+ return authProvider({
520
+ collectionName: sourceCollection
521
+ });
522
+ case 6:
523
+ _context6.t1 = _context6.sent;
524
+ owner = (0, _context6.t0)(_context6.t1);
525
+ body = {
526
+ sourceFile: {
527
+ id: id,
528
+ collection: sourceCollection,
529
+ owner: owner
530
+ }
531
+ };
532
+ params = {
533
+ collection: destinationCollectionName,
534
+ replaceFileId: replaceFileId,
535
+ occurrenceKey: occurrenceKey
536
+ };
537
+ _context6.next = 12;
538
+ return mediaStore.copyFileWithToken(body, params, traceContext);
539
+ case 12:
540
+ _yield$mediaStore$cop = _context6.sent;
541
+ data = _yield$mediaStore$cop.data;
542
+ return _context6.abrupt("return", data);
543
+ case 15:
544
+ case "end":
545
+ return _context6.stop();
546
+ }
547
+ }, _callee6);
548
+ }));
549
+ function copyFileWithToken(_x9, _x10, _x11) {
550
+ return _copyFileWithToken.apply(this, arguments);
551
+ }
552
+ return copyFileWithToken;
553
+ }()
554
+ }, {
555
+ key: "copyFileWithIntent",
556
+ value: function () {
557
+ var _copyFileWithIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(source, destination, traceContext) {
558
+ var res, data;
559
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
560
+ while (1) switch (_context7.prev = _context7.next) {
561
+ case 0:
562
+ _context7.next = 2;
563
+ return this.mediaApi.copyFile(source.id, {
564
+ sourceCollection: source.collection,
565
+ collection: destination.collection,
566
+ replaceFileId: destination.replaceFileId
567
+ }, traceContext);
568
+ case 2:
569
+ res = _context7.sent;
570
+ data = res.data;
571
+ return _context7.abrupt("return", data);
572
+ case 5:
573
+ case "end":
574
+ return _context7.stop();
575
+ }
576
+ }, _callee7, this);
577
+ }));
578
+ function copyFileWithIntent(_x12, _x13, _x14) {
579
+ return _copyFileWithIntent.apply(this, arguments);
580
+ }
581
+ return copyFileWithIntent;
582
+ }()
498
583
  }, {
499
584
  key: "copyFile",
500
585
  value: function () {
501
- var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(source, destination) {
586
+ var _copyFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(source, destination) {
502
587
  var _this5 = this;
503
588
  var options,
504
589
  traceContext,
505
- authProvider,
506
- sourceCollection,
507
590
  id,
508
- destinationAuthProvider,
509
591
  destinationCollectionName,
510
592
  replaceFileId,
511
593
  occurrenceKey,
512
594
  preview,
513
595
  mimeType,
514
- mediaStore,
515
- owner,
516
- body,
517
- params,
518
596
  cache,
519
597
  processingSubscription,
520
- _yield$mediaStore$cop,
521
598
  copiedFile,
522
599
  copiedFileWithMimeType,
523
600
  copiedId,
@@ -533,45 +610,33 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
533
610
  replaceFileState,
534
611
  key,
535
612
  errorFileState,
536
- _args6 = arguments;
537
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
538
- while (1) switch (_context6.prev = _context6.next) {
613
+ _args8 = arguments;
614
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
615
+ while (1) switch (_context8.prev = _context8.next) {
539
616
  case 0:
540
- options = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
541
- traceContext = _args6.length > 3 ? _args6[3] : undefined;
542
- authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
543
- destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
617
+ options = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : {};
618
+ traceContext = _args8.length > 3 ? _args8[3] : undefined;
619
+ id = source.id;
620
+ destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
544
621
  preview = options.preview, mimeType = options.mimeType;
545
- mediaStore = destination.mediaStore || new MediaApi({
546
- authProvider: destinationAuthProvider
547
- });
548
- _context6.t0 = authToOwner;
549
- _context6.next = 9;
550
- return authProvider({
551
- collectionName: sourceCollection
552
- });
553
- case 9:
554
- _context6.t1 = _context6.sent;
555
- owner = (0, _context6.t0)(_context6.t1);
556
- body = {
557
- sourceFile: {
558
- id: id,
559
- collection: sourceCollection,
560
- owner: owner
561
- }
562
- };
563
- params = {
564
- collection: destinationCollectionName,
565
- replaceFileId: replaceFileId,
566
- occurrenceKey: occurrenceKey
567
- };
568
622
  cache = getFileStreamsCache();
569
- _context6.prev = 14;
570
- _context6.next = 17;
571
- return mediaStore.copyFileWithToken(body, params, traceContext);
572
- case 17:
573
- _yield$mediaStore$cop = _context6.sent;
574
- copiedFile = _yield$mediaStore$cop.data;
623
+ _context8.prev = 6;
624
+ if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
625
+ _context8.next = 13;
626
+ break;
627
+ }
628
+ _context8.next = 10;
629
+ return this.copyFileWithToken(source, destination, traceContext);
630
+ case 10:
631
+ copiedFile = _context8.sent;
632
+ _context8.next = 16;
633
+ break;
634
+ case 13:
635
+ _context8.next = 15;
636
+ return this.copyFileWithIntent(source, destination, traceContext);
637
+ case 15:
638
+ copiedFile = _context8.sent;
639
+ case 16:
575
640
  // if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
576
641
  copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
577
642
  mimeType: mimeType
@@ -587,21 +652,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
587
652
  previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
588
653
  preview: preview
589
654
  } : {};
590
- _context6.t2 = !isFinalFileState(copiedFileState) &&
655
+ _context8.t0 = !isFinalFileState(copiedFileState) &&
591
656
  // mimeType should always be returned by "copyFileWithToken"
592
657
  // but in case it's not, we don't want to penalize "copyFile"
593
658
  copiedMimeType;
594
- if (!_context6.t2) {
595
- _context6.next = 31;
659
+ if (!_context8.t0) {
660
+ _context8.next = 28;
596
661
  break;
597
662
  }
598
- _context6.next = 30;
663
+ _context8.next = 27;
599
664
  return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
600
- case 30:
601
- _context6.t2 = _context6.sent;
602
- case 31:
603
- if (!_context6.t2) {
604
- _context6.next = 38;
665
+ case 27:
666
+ _context8.t0 = _context8.sent;
667
+ case 28:
668
+ if (!_context8.t0) {
669
+ _context8.next = 35;
605
670
  break;
606
671
  }
607
672
  fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), overrideMediaTypeIfUnknown(copiedFileState, mediaType)), previewOverride);
@@ -622,22 +687,22 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
622
687
  return subject.complete();
623
688
  }
624
689
  });
625
- _context6.next = 39;
690
+ _context8.next = 36;
626
691
  break;
627
- case 38:
692
+ case 35:
628
693
  if (!isProcessingFileState(copiedFileState)) {
629
694
  _fileState = _objectSpread(_objectSpread({}, copiedFileState), !isErrorFileState(copiedFileState) && previewOverride);
630
695
  subject.next(_fileState);
631
696
  this.setFileState(copiedId, _fileState);
632
697
  }
633
- case 39:
698
+ case 36:
634
699
  if (!cache.has(copiedId)) {
635
700
  getFileStreamsCache().set(copiedId, subject);
636
701
  }
637
- return _context6.abrupt("return", copiedFile);
638
- case 43:
639
- _context6.prev = 43;
640
- _context6.t3 = _context6["catch"](14);
702
+ return _context8.abrupt("return", copiedFile);
703
+ case 40:
704
+ _context8.prev = 40;
705
+ _context8.t1 = _context8["catch"](6);
641
706
  if (processingSubscription) {
642
707
  processingSubscription.unsubscribe();
643
708
  }
@@ -645,27 +710,26 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
645
710
  _fileCache = cache.get(replaceFileId);
646
711
  replaceFileState = this.store.getState().files[replaceFileId];
647
712
  if (_fileCache) {
648
- _fileCache.error(_context6.t3);
713
+ _fileCache.error(_context8.t1);
649
714
  } else {
650
715
  // Create a new subject with the error state for new subscriptions
651
- cache.set(id, createMediaSubject(_context6.t3));
716
+ cache.set(id, createMediaSubject(_context8.t1));
652
717
  }
653
718
  key = replaceFileState ? replaceFileId : id;
654
- errorFileState = this.getErrorFileState(_context6.t3, id, occurrenceKey);
719
+ errorFileState = this.getErrorFileState(_context8.t1, id, occurrenceKey);
655
720
  this.setFileState(key, errorFileState);
656
721
  }
657
- throw _context6.t3;
658
- case 48:
722
+ throw _context8.t1;
723
+ case 45:
659
724
  case "end":
660
- return _context6.stop();
725
+ return _context8.stop();
661
726
  }
662
- }, _callee6, this, [[14, 43]]);
727
+ }, _callee8, this, [[6, 40]]);
663
728
  }));
664
- function copyFile(_x9, _x10) {
729
+ function copyFile(_x15, _x16) {
665
730
  return _copyFile.apply(this, arguments);
666
731
  }
667
732
  return copyFile;
668
733
  }()
669
734
  }]);
670
- return FileFetcherImpl;
671
735
  }();
@@ -34,7 +34,7 @@ export var MediaClient = /*#__PURE__*/function () {
34
34
  /**
35
35
  * @internal
36
36
  */
37
- _createClass(MediaClient, [{
37
+ return _createClass(MediaClient, [{
38
38
  key: "__DO_NOT_USE__getMediaStore",
39
39
  value: function __DO_NOT_USE__getMediaStore() {
40
40
  return this.store;
@@ -143,5 +143,4 @@ export var MediaClient = /*#__PURE__*/function () {
143
143
  return this.eventEmitter.emit(event, payload);
144
144
  }
145
145
  }]);
146
- return MediaClient;
147
146
  }();
@@ -8,8 +8,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
8
8
  import { isClientBasedAuth } from '@atlaskit/media-core';
9
9
  import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
10
10
  import { getArtifactUrl } from '../../models/artifacts';
11
- import { request as _request } from '../../utils/request';
12
- import { createUrl, createMapResponseToJson, createMapResponseToBlob, extendTraceContext } from '../../utils/request/helpers';
11
+ import { isRequestError, request as _request } from '../../utils/request';
12
+ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultShouldRetryError, extendTraceContext } from '../../utils/request/helpers';
13
13
  import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
14
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
15
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
@@ -55,7 +55,7 @@ export var MediaStore = /*#__PURE__*/function () {
55
55
  this.config = config;
56
56
  this._chunkHashAlgorithm = config.chunkHashAlgorithm || ChunkHashAlgorithm.Sha1;
57
57
  }
58
- _createClass(MediaStore, [{
58
+ return _createClass(MediaStore, [{
59
59
  key: "removeCollectionFile",
60
60
  value: function () {
61
61
  var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(id, collectionName, occurrenceKey, traceContext) {
@@ -603,7 +603,15 @@ export var MediaStore = /*#__PURE__*/function () {
603
603
  body: JSON.stringify({
604
604
  id: id
605
605
  }),
606
- traceContext: traceContext
606
+ traceContext: traceContext,
607
+ clientOptions: {
608
+ retryOptions: {
609
+ shouldRetryError: function shouldRetryError(err) {
610
+ var _err$metadata;
611
+ return defaultShouldRetryError(err) || isRequestError(err) && (err === null || err === void 0 || (_err$metadata = err.metadata) === null || _err$metadata === void 0 ? void 0 : _err$metadata.statusCode) === 401;
612
+ }
613
+ }
614
+ }
607
615
  });
608
616
  return this.request('/v2/file/copy', options).then(createMapResponseToJson(metadata));
609
617
  }
@@ -761,7 +769,6 @@ export var MediaStore = /*#__PURE__*/function () {
761
769
  return this._chunkHashAlgorithm;
762
770
  }
763
771
  }]);
764
- return MediaStore;
765
772
  }();
766
773
  var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
767
774
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
@@ -1,23 +1,22 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import { BaseMediaClientError } from '../../models/errors';
9
9
  export var MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
10
- _inherits(MediaStoreError, _BaseMediaClientError);
11
- var _super = _createSuper(MediaStoreError);
12
10
  function MediaStoreError(reason, innerError) {
13
11
  var _this;
14
12
  _classCallCheck(this, MediaStoreError);
15
- _this = _super.call(this, reason);
13
+ _this = _callSuper(this, MediaStoreError, [reason]);
16
14
  _this.reason = reason;
17
15
  _this.innerError = innerError;
18
16
  return _this;
19
17
  }
20
- _createClass(MediaStoreError, [{
18
+ _inherits(MediaStoreError, _BaseMediaClientError);
19
+ return _createClass(MediaStoreError, [{
21
20
  key: "attributes",
22
21
  get: function get() {
23
22
  var reason = this.reason,
@@ -28,7 +27,6 @@ export var MediaStoreError = /*#__PURE__*/function (_BaseMediaClientError) {
28
27
  };
29
28
  }
30
29
  }]);
31
- return MediaStoreError;
32
30
  }(BaseMediaClientError);
33
31
  export function isMediaStoreError(err) {
34
32
  return err instanceof MediaStoreError;
@@ -36,7 +36,7 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
36
36
  this.dataloader = createFileDataloader(mediaApi);
37
37
  this.servicesCache = createServicesCache();
38
38
  }
39
- _createClass(MobileUploadImpl, [{
39
+ return _createClass(MobileUploadImpl, [{
40
40
  key: "notifyUploadStart",
41
41
  value: function notifyUploadStart(event) {
42
42
  var _this2 = this;
@@ -109,5 +109,4 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
109
109
  }
110
110
  }
111
111
  }]);
112
- return MobileUploadImpl;
113
112
  }();
@@ -7,7 +7,7 @@ export var StargateClient = /*#__PURE__*/function () {
7
7
  _classCallCheck(this, StargateClient);
8
8
  this.baseUrl = baseUrl || '/gateway/api';
9
9
  }
10
- _createClass(StargateClient, [{
10
+ return _createClass(StargateClient, [{
11
11
  key: "fetchToken",
12
12
  value: function () {
13
13
  var _fetchToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(clientId) {
@@ -41,5 +41,4 @@ export var StargateClient = /*#__PURE__*/function () {
41
41
  return token.data.iat + token.data.expiresIn - currentTimeInSeconds < 0;
42
42
  }
43
43
  }]);
44
- return StargateClient;
45
44
  }();
@@ -5,7 +5,7 @@ export var StreamsCache = /*#__PURE__*/function () {
5
5
  _classCallCheck(this, StreamsCache);
6
6
  this.streams = streams;
7
7
  }
8
- _createClass(StreamsCache, [{
8
+ return _createClass(StreamsCache, [{
9
9
  key: "has",
10
10
  value: function has(id) {
11
11
  return !!this.streams.find(id);
@@ -44,7 +44,6 @@ export var StreamsCache = /*#__PURE__*/function () {
44
44
  return this.streams.size;
45
45
  }
46
46
  }]);
47
- return StreamsCache;
48
47
  }();
49
48
  var streamCache;
50
49
  export var getFileStreamsCache = function getFileStreamsCache() {
@@ -1,11 +1,10 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
7
6
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
8
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
9
  export { isMediaClientError, getMediaClientErrorReason } from './helpers';
11
10
 
@@ -13,22 +12,21 @@ export { isMediaClientError, getMediaClientErrorReason } from './helpers';
13
12
  * Base class for media errors
14
13
  */
15
14
  export var BaseMediaClientError = /*#__PURE__*/function (_Error) {
16
- _inherits(BaseMediaClientError, _Error);
17
- var _super = _createSuper(BaseMediaClientError);
18
15
  function BaseMediaClientError(message) {
19
16
  var _this;
20
17
  _classCallCheck(this, BaseMediaClientError);
21
- _this = _super.call(this, message);
18
+ _this = _callSuper(this, BaseMediaClientError, [message]);
22
19
 
23
20
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
24
21
  _this.message = message;
25
- Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
22
+ Object.setPrototypeOf(_this, (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
26
23
 
27
24
  // https://v8.dev/docs/stack-trace-api
28
25
  if ('captureStackTrace' in Error) {
29
- Error.captureStackTrace(_assertThisInitialized(_this), this instanceof BaseMediaClientError ? this.constructor : void 0);
26
+ Error.captureStackTrace(_this, this instanceof BaseMediaClientError ? this.constructor : void 0);
30
27
  }
31
28
  return _this;
32
29
  }
30
+ _inherits(BaseMediaClientError, _Error);
33
31
  return _createClass(BaseMediaClientError);
34
32
  }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -4,7 +4,7 @@ export var UploadController = /*#__PURE__*/function () {
4
4
  function UploadController() {
5
5
  _classCallCheck(this, UploadController);
6
6
  }
7
- _createClass(UploadController, [{
7
+ return _createClass(UploadController, [{
8
8
  key: "setAbort",
9
9
  value: function setAbort(abortFunction) {
10
10
  this.abortFunction = abortFunction;
@@ -17,5 +17,4 @@ export var UploadController = /*#__PURE__*/function () {
17
17
  }
18
18
  }
19
19
  }]);
20
- return UploadController;
21
20
  }();
@@ -1,24 +1,23 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import { BaseMediaClientError } from '../models/errors';
9
9
  export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
10
- _inherits(UploaderError, _BaseMediaClientError);
11
- var _super = _createSuper(UploaderError);
12
10
  function UploaderError(reason, id, metadata) {
13
11
  var _this;
14
12
  _classCallCheck(this, UploaderError);
15
- _this = _super.call(this, reason);
13
+ _this = _callSuper(this, UploaderError, [reason]);
16
14
  _this.reason = reason;
17
15
  _this.id = id;
18
16
  _this.metadata = metadata;
19
17
  return _this;
20
18
  }
21
- _createClass(UploaderError, [{
19
+ _inherits(UploaderError, _BaseMediaClientError);
20
+ return _createClass(UploaderError, [{
22
21
  key: "attributes",
23
22
  get: function get() {
24
23
  var reason = this.reason,
@@ -35,7 +34,6 @@ export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
35
34
  };
36
35
  }
37
36
  }]);
38
- return UploaderError;
39
37
  }(BaseMediaClientError);
40
38
  export function isUploaderError(err) {
41
39
  return err instanceof UploaderError;
@@ -5,7 +5,7 @@ export var SimpleHasher = /*#__PURE__*/function () {
5
5
  function SimpleHasher() {
6
6
  _classCallCheck(this, SimpleHasher);
7
7
  }
8
- _createClass(SimpleHasher, [{
8
+ return _createClass(SimpleHasher, [{
9
9
  key: "hash",
10
10
  value: function hash(blob) {
11
11
  return new Promise(function (resolve, reject) {
@@ -19,5 +19,4 @@ export var SimpleHasher = /*#__PURE__*/function () {
19
19
  });
20
20
  }
21
21
  }]);
22
- return SimpleHasher;
23
22
  }();
@@ -5,7 +5,7 @@ export var SimpleHasher = /*#__PURE__*/function () {
5
5
  function SimpleHasher() {
6
6
  _classCallCheck(this, SimpleHasher);
7
7
  }
8
- _createClass(SimpleHasher, [{
8
+ return _createClass(SimpleHasher, [{
9
9
  key: "hash",
10
10
  value: function hash(blob) {
11
11
  return new Promise(function (resolve, reject) {
@@ -19,5 +19,4 @@ export var SimpleHasher = /*#__PURE__*/function () {
19
19
  });
20
20
  }
21
21
  }]);
22
- return SimpleHasher;
23
22
  }();
@@ -12,7 +12,7 @@ export var WorkerHasher = /*#__PURE__*/function () {
12
12
  this.workers.push(this.createWorker());
13
13
  }
14
14
  }
15
- _createClass(WorkerHasher, [{
15
+ return _createClass(WorkerHasher, [{
16
16
  key: "hash",
17
17
  value: function hash(chunk) {
18
18
  return this.calculateHashInWorker(chunk);
@@ -103,5 +103,4 @@ export var WorkerHasher = /*#__PURE__*/function () {
103
103
  }, this.workers[0]);
104
104
  }
105
105
  }]);
106
- return WorkerHasher;
107
106
  }();
@@ -1,24 +1,23 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import { BaseMediaClientError } from '../../models/errors';
9
9
  export var MobileUploadError = /*#__PURE__*/function (_BaseMediaClientError) {
10
- _inherits(MobileUploadError, _BaseMediaClientError);
11
- var _super = _createSuper(MobileUploadError);
12
10
  function MobileUploadError(reason, id, metadata) {
13
11
  var _this;
14
12
  _classCallCheck(this, MobileUploadError);
15
- _this = _super.call(this, reason);
13
+ _this = _callSuper(this, MobileUploadError, [reason]);
16
14
  _this.reason = reason;
17
15
  _this.id = id;
18
16
  _this.metadata = metadata;
19
17
  return _this;
20
18
  }
21
- _createClass(MobileUploadError, [{
19
+ _inherits(MobileUploadError, _BaseMediaClientError);
20
+ return _createClass(MobileUploadError, [{
22
21
  key: "attributes",
23
22
  get: function get() {
24
23
  var reason = this.reason,
@@ -39,7 +38,6 @@ export var MobileUploadError = /*#__PURE__*/function (_BaseMediaClientError) {
39
38
  };
40
39
  }
41
40
  }]);
42
- return MobileUploadError;
43
41
  }(BaseMediaClientError);
44
42
  export function isMobileUploadError(err) {
45
43
  return err instanceof MobileUploadError;