@atlaskit/media-client 20.0.0 → 20.0.2

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 (163) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/client/collection-fetcher.js +4 -44
  3. package/dist/cjs/client/file-fetcher/error.js +3 -19
  4. package/dist/cjs/client/file-fetcher/index.js +152 -167
  5. package/dist/cjs/client/media-client.js +3 -27
  6. package/dist/cjs/client/media-store/error.js +1 -17
  7. package/dist/cjs/client/media-store/index.js +13 -103
  8. package/dist/cjs/client/media-store/resolveAuth.js +2 -23
  9. package/dist/cjs/client/mobile-upload.js +9 -22
  10. package/dist/cjs/client/stargate-client.js +0 -12
  11. package/dist/cjs/constants.js +0 -3
  12. package/dist/cjs/file-streams-cache.js +0 -11
  13. package/dist/cjs/globalMediaEventEmitter.js +0 -3
  14. package/dist/cjs/identifier.js +0 -8
  15. package/dist/cjs/index.js +0 -38
  16. package/dist/cjs/models/artifacts.js +0 -4
  17. package/dist/cjs/models/auth-headers.js +0 -2
  18. package/dist/cjs/models/auth-query-parameters.js +0 -2
  19. package/dist/cjs/models/errors/helpers.js +0 -2
  20. package/dist/cjs/models/errors/index.js +4 -20
  21. package/dist/cjs/models/file-state.js +10 -36
  22. package/dist/cjs/models/media.js +2 -8
  23. package/dist/cjs/upload-controller.js +0 -6
  24. package/dist/cjs/uploader/calculateChunkSize.js +1 -10
  25. package/dist/cjs/uploader/error.js +3 -19
  26. package/dist/cjs/uploader/index.js +3 -43
  27. package/dist/cjs/utils/checkWebpSupport.js +3 -7
  28. package/dist/cjs/utils/convertBase64ToBlob.js +0 -5
  29. package/dist/cjs/utils/createFileDataLoader.js +4 -28
  30. package/dist/cjs/utils/createMediaSubject.js +0 -4
  31. package/dist/cjs/utils/detectEmptyFile.js +8 -15
  32. package/dist/cjs/utils/getDimensionsFromBlob.js +0 -14
  33. package/dist/cjs/utils/getImageDimensionsFromBlob.js +0 -4
  34. package/dist/cjs/utils/getMediaTypeFromUploadableFile.js +0 -3
  35. package/dist/cjs/utils/getVideoDimensionsFromBlob.js +2 -8
  36. package/dist/cjs/utils/hashing/hasherCreator.js +0 -20
  37. package/dist/cjs/utils/hashing/simpleHasher.js +0 -12
  38. package/dist/cjs/utils/hashing/workerHasher.js +3 -24
  39. package/dist/cjs/utils/imageResizeModeToFileImageMode.js +0 -2
  40. package/dist/cjs/utils/isImageRemote.js +0 -5
  41. package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -4
  42. package/dist/cjs/utils/mediaSubscribable/index.js +0 -2
  43. package/dist/cjs/utils/mediaSubscribable/toPromise.js +1 -3
  44. package/dist/cjs/utils/mobileUpload/error.js +3 -19
  45. package/dist/cjs/utils/mobileUpload/helpers.js +2 -26
  46. package/dist/cjs/utils/mobileUpload/index.js +0 -4
  47. package/dist/cjs/utils/mobileUpload/servicesCache.js +0 -2
  48. package/dist/cjs/utils/mobileUpload/stateMachine/index.js +0 -22
  49. package/dist/cjs/utils/mobileUpload/stateMachine/states/processing.js +0 -2
  50. package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +0 -7
  51. package/dist/cjs/utils/overrideMediaTypeIfUnknown.js +0 -4
  52. package/dist/cjs/utils/polling/errors.js +1 -17
  53. package/dist/cjs/utils/polling/index.js +1 -30
  54. package/dist/cjs/utils/request/errors.js +8 -24
  55. package/dist/cjs/utils/request/helpers.js +19 -103
  56. package/dist/cjs/utils/request/index.js +15 -26
  57. package/dist/cjs/utils/safeUnsubscribe.js +0 -2
  58. package/dist/cjs/utils/setTimeoutPromise.js +0 -4
  59. package/dist/cjs/utils/shouldFetchRemoteFileStates.js +0 -21
  60. package/dist/cjs/utils/url.js +4 -27
  61. package/dist/cjs/utils/with-media-client-hoc.js +12 -28
  62. package/dist/cjs/version.json +1 -1
  63. package/dist/es2019/client/collection-fetcher.js +6 -18
  64. package/dist/es2019/client/file-fetcher/error.js +0 -2
  65. package/dist/es2019/client/file-fetcher/index.js +138 -70
  66. package/dist/es2019/client/media-client.js +4 -14
  67. package/dist/es2019/client/media-store/error.js +0 -2
  68. package/dist/es2019/client/media-store/index.js +37 -52
  69. package/dist/es2019/client/media-store/resolveAuth.js +1 -5
  70. package/dist/es2019/client/mobile-upload.js +0 -8
  71. package/dist/es2019/client/stargate-client.js +0 -3
  72. package/dist/es2019/constants.js +0 -1
  73. package/dist/es2019/file-streams-cache.js +0 -11
  74. package/dist/es2019/globalMediaEventEmitter.js +0 -4
  75. package/dist/es2019/index.js +4 -11
  76. package/dist/es2019/models/artifacts.js +0 -2
  77. package/dist/es2019/models/errors/index.js +5 -4
  78. package/dist/es2019/models/file-state.js +6 -7
  79. package/dist/es2019/models/media.js +2 -3
  80. package/dist/es2019/upload-controller.js +0 -3
  81. package/dist/es2019/uploader/calculateChunkSize.js +1 -4
  82. package/dist/es2019/uploader/error.js +0 -2
  83. package/dist/es2019/uploader/index.js +0 -13
  84. package/dist/es2019/utils/checkWebpSupport.js +3 -4
  85. package/dist/es2019/utils/convertBase64ToBlob.js +0 -2
  86. package/dist/es2019/utils/createFileDataLoader.js +6 -9
  87. package/dist/es2019/utils/createMediaSubject.js +0 -2
  88. package/dist/es2019/utils/detectEmptyFile.js +1 -5
  89. package/dist/es2019/utils/getDimensionsFromBlob.js +0 -3
  90. package/dist/es2019/utils/getImageDimensionsFromBlob.js +0 -2
  91. package/dist/es2019/utils/getVideoDimensionsFromBlob.js +2 -1
  92. package/dist/es2019/utils/hashing/hasherCreator.js +0 -2
  93. package/dist/es2019/utils/hashing/simpleHasher.js +0 -3
  94. package/dist/es2019/utils/hashing/workerHasher.js +1 -16
  95. package/dist/es2019/utils/isImageRemote.js +0 -2
  96. package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -1
  97. package/dist/es2019/utils/mediaSubscribable/toPromise.js +1 -1
  98. package/dist/es2019/utils/mobileUpload/error.js +0 -2
  99. package/dist/es2019/utils/mobileUpload/helpers.js +2 -7
  100. package/dist/es2019/utils/mobileUpload/stateMachine/index.js +0 -2
  101. package/dist/es2019/utils/mobileUpload/stateMachine/states/uploading.js +2 -1
  102. package/dist/es2019/utils/overrideMediaTypeIfUnknown.js +0 -1
  103. package/dist/es2019/utils/polling/errors.js +0 -2
  104. package/dist/es2019/utils/polling/index.js +3 -20
  105. package/dist/es2019/utils/request/errors.js +0 -2
  106. package/dist/es2019/utils/request/helpers.js +24 -35
  107. package/dist/es2019/utils/request/index.js +2 -2
  108. package/dist/es2019/utils/shouldFetchRemoteFileStates.js +1 -5
  109. package/dist/es2019/utils/url.js +6 -14
  110. package/dist/es2019/utils/with-media-client-hoc.js +10 -7
  111. package/dist/es2019/version.json +1 -1
  112. package/dist/esm/client/collection-fetcher.js +4 -34
  113. package/dist/esm/client/file-fetcher/error.js +3 -12
  114. package/dist/esm/client/file-fetcher/index.js +154 -137
  115. package/dist/esm/client/media-client.js +4 -17
  116. package/dist/esm/client/media-store/error.js +1 -10
  117. package/dist/esm/client/media-store/index.js +13 -89
  118. package/dist/esm/client/media-store/resolveAuth.js +2 -13
  119. package/dist/esm/client/mobile-upload.js +9 -15
  120. package/dist/esm/client/stargate-client.js +0 -7
  121. package/dist/esm/constants.js +0 -1
  122. package/dist/esm/file-streams-cache.js +0 -6
  123. package/dist/esm/globalMediaEventEmitter.js +0 -1
  124. package/dist/esm/index.js +4 -11
  125. package/dist/esm/models/artifacts.js +0 -2
  126. package/dist/esm/models/errors/index.js +5 -12
  127. package/dist/esm/models/file-state.js +10 -17
  128. package/dist/esm/models/media.js +2 -3
  129. package/dist/esm/upload-controller.js +0 -2
  130. package/dist/esm/uploader/calculateChunkSize.js +1 -4
  131. package/dist/esm/uploader/error.js +3 -12
  132. package/dist/esm/uploader/index.js +3 -32
  133. package/dist/esm/utils/checkWebpSupport.js +3 -4
  134. package/dist/esm/utils/convertBase64ToBlob.js +0 -3
  135. package/dist/esm/utils/createFileDataLoader.js +4 -18
  136. package/dist/esm/utils/createMediaSubject.js +0 -2
  137. package/dist/esm/utils/detectEmptyFile.js +8 -12
  138. package/dist/esm/utils/getDimensionsFromBlob.js +0 -7
  139. package/dist/esm/utils/getImageDimensionsFromBlob.js +0 -2
  140. package/dist/esm/utils/getVideoDimensionsFromBlob.js +2 -3
  141. package/dist/esm/utils/hashing/hasherCreator.js +0 -9
  142. package/dist/esm/utils/hashing/simpleHasher.js +0 -4
  143. package/dist/esm/utils/hashing/workerHasher.js +3 -18
  144. package/dist/esm/utils/isImageRemote.js +0 -3
  145. package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -1
  146. package/dist/esm/utils/mediaSubscribable/toPromise.js +1 -1
  147. package/dist/esm/utils/mobileUpload/error.js +3 -12
  148. package/dist/esm/utils/mobileUpload/helpers.js +2 -11
  149. package/dist/esm/utils/mobileUpload/stateMachine/index.js +0 -6
  150. package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +0 -3
  151. package/dist/esm/utils/overrideMediaTypeIfUnknown.js +0 -1
  152. package/dist/esm/utils/polling/errors.js +1 -10
  153. package/dist/esm/utils/polling/index.js +1 -27
  154. package/dist/esm/utils/request/errors.js +8 -17
  155. package/dist/esm/utils/request/helpers.js +22 -76
  156. package/dist/esm/utils/request/index.js +15 -20
  157. package/dist/esm/utils/shouldFetchRemoteFileStates.js +1 -15
  158. package/dist/esm/utils/url.js +4 -18
  159. package/dist/esm/utils/with-media-client-hoc.js +12 -17
  160. package/dist/esm/version.json +1 -1
  161. package/dist/types/client/file-fetcher/index.d.ts +6 -2
  162. package/package.json +8 -6
  163. package/report.api.md +4 -1
@@ -7,22 +7,20 @@ import { createServicesCache, createMobileUploadStateMachine, createMobileUpload
7
7
  export var MobileUploadImpl = /*#__PURE__*/function () {
8
8
  function MobileUploadImpl(mediaStore) {
9
9
  _classCallCheck(this, MobileUploadImpl);
10
-
11
10
  this.dataloader = createFileDataloader(mediaStore);
12
11
  this.servicesCache = createServicesCache();
13
12
  }
14
-
15
13
  _createClass(MobileUploadImpl, [{
16
14
  key: "notifyUploadStart",
17
15
  value: function notifyUploadStart(event) {
18
16
  var fileId = event.fileId,
19
- collectionName = event.collectionName,
20
- occurrenceKey = event.occurrenceKey,
21
- fileName = event.fileName,
22
- fileSize = event.fileSize,
23
- fileMimetype = event.fileMimetype,
24
- preview = event.preview,
25
- createdAt = event.createdAt;
17
+ collectionName = event.collectionName,
18
+ occurrenceKey = event.occurrenceKey,
19
+ fileName = event.fileName,
20
+ fileSize = event.fileSize,
21
+ fileMimetype = event.fileMimetype,
22
+ preview = event.preview,
23
+ createdAt = event.createdAt;
26
24
  var mediaType = getMediaTypeFromMimeType(fileMimetype);
27
25
  var initialState = {
28
26
  status: 'uploading',
@@ -45,9 +43,8 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
45
43
  key: "notifyUploadProgress",
46
44
  value: function notifyUploadProgress(event) {
47
45
  var fileId = event.fileId,
48
- progress = event.progress;
46
+ progress = event.progress;
49
47
  var service = this.servicesCache.get(fileId);
50
-
51
48
  if (service) {
52
49
  service.send('UPLOAD_PROGRESS', {
53
50
  progress: progress
@@ -59,7 +56,6 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
59
56
  value: function notifyUploadEnd(event) {
60
57
  var fileId = event.fileId;
61
58
  var service = this.servicesCache.get(fileId);
62
-
63
59
  if (service) {
64
60
  service.send('UPLOAD_END');
65
61
  }
@@ -68,9 +64,8 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
68
64
  key: "notifyUploadError",
69
65
  value: function notifyUploadError(event) {
70
66
  var fileId = event.fileId,
71
- message = event.message;
67
+ message = event.message;
72
68
  var service = this.servicesCache.get(fileId);
73
-
74
69
  if (service) {
75
70
  service.send('UPLOAD_ERROR', {
76
71
  message: message
@@ -78,6 +73,5 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
78
73
  }
79
74
  }
80
75
  }]);
81
-
82
76
  return MobileUploadImpl;
83
77
  }();
@@ -5,10 +5,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  export var StargateClient = /*#__PURE__*/function () {
6
6
  function StargateClient(baseUrl) {
7
7
  _classCallCheck(this, StargateClient);
8
-
9
8
  this.baseUrl = baseUrl || '/gateway/api';
10
9
  }
11
-
12
10
  _createClass(StargateClient, [{
13
11
  key: "fetchToken",
14
12
  value: function () {
@@ -24,10 +22,8 @@ export var StargateClient = /*#__PURE__*/function () {
24
22
  'x-client-id': clientId
25
23
  }
26
24
  });
27
-
28
25
  case 2:
29
26
  return _context.abrupt("return", _context.sent.json());
30
-
31
27
  case 3:
32
28
  case "end":
33
29
  return _context.stop();
@@ -35,11 +31,9 @@ export var StargateClient = /*#__PURE__*/function () {
35
31
  }
36
32
  }, _callee, this);
37
33
  }));
38
-
39
34
  function fetchToken(_x) {
40
35
  return _fetchToken.apply(this, arguments);
41
36
  }
42
-
43
37
  return fetchToken;
44
38
  }()
45
39
  }, {
@@ -49,6 +43,5 @@ export var StargateClient = /*#__PURE__*/function () {
49
43
  return token.data.iat + token.data.expiresIn - currentTimeInSeconds < 0;
50
44
  }
51
45
  }]);
52
-
53
46
  return StargateClient;
54
47
  }();
@@ -1,7 +1,6 @@
1
1
  import { DATA_UNIT } from './models/media';
2
2
  export var RECENTS_COLLECTION = 'recents';
3
3
  export var FILE_CACHE_MAX_AGE = 60 * 60 * 24 * 30; // Retain for 30 days
4
-
5
4
  export var MAX_RESOLUTION = 4096;
6
5
  export var CHUNK_SIZE = 4 * DATA_UNIT.MB;
7
6
  export var PROCESSING_BATCH_SIZE = 1000;
@@ -3,10 +3,8 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  export var StreamsCache = /*#__PURE__*/function () {
4
4
  function StreamsCache(streams) {
5
5
  _classCallCheck(this, StreamsCache);
6
-
7
6
  this.streams = streams;
8
7
  }
9
-
10
8
  _createClass(StreamsCache, [{
11
9
  key: "has",
12
10
  value: function has(id) {
@@ -28,7 +26,6 @@ export var StreamsCache = /*#__PURE__*/function () {
28
26
  if (!this.has(id)) {
29
27
  this.set(id, callback());
30
28
  }
31
-
32
29
  return this.get(id);
33
30
  }
34
31
  }, {
@@ -47,7 +44,6 @@ export var StreamsCache = /*#__PURE__*/function () {
47
44
  return this.streams.size;
48
45
  }
49
46
  }]);
50
-
51
47
  return StreamsCache;
52
48
  }();
53
49
  var streamCache;
@@ -56,9 +52,7 @@ export var getFileStreamsCache = function getFileStreamsCache() {
56
52
  // TODO: we can move this into a static import like
57
53
  // import {mediaState} from '@atlaskit/media-core'
58
54
  var mediaState = require('@atlaskit/media-core').mediaState;
59
-
60
55
  streamCache = new StreamsCache(mediaState.streams);
61
56
  }
62
-
63
57
  return streamCache;
64
58
  };
@@ -14,7 +14,6 @@ export var globalMediaEventEmitter = {
14
14
  if (mediaState.eventEmitter) {
15
15
  return mediaState.eventEmitter.emit(event, payload);
16
16
  }
17
-
18
17
  return undefined;
19
18
  }
20
19
  };
package/dist/esm/index.js CHANGED
@@ -24,56 +24,49 @@ export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
24
24
  export { globalMediaEventEmitter } from './globalMediaEventEmitter';
25
25
  export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString } from './utils/url';
26
26
  export { createMediaSubscribable } from './utils/mediaSubscribable';
27
- export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants'; // TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
27
+ export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
28
+
29
+ // TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
28
30
 
29
31
  import { getMediaTypeFromMimeType as _getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser as _isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser as _isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser as _isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer as _isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer as _isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer as _isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer as _isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer as _isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer as _isMimeTypeSupportedByServer } from '@atlaskit/media-common/mediaTypeUtils';
32
+
30
33
  /**
31
34
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
32
35
  */
33
-
34
36
  export var getMediaTypeFromMimeType = _getMediaTypeFromMimeType;
35
37
  /**
36
38
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
37
39
  */
38
-
39
40
  export var isImageMimeTypeSupportedByBrowser = _isImageMimeTypeSupportedByBrowser;
40
41
  /**
41
42
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
42
43
  */
43
-
44
44
  export var isDocumentMimeTypeSupportedByBrowser = _isDocumentMimeTypeSupportedByBrowser;
45
45
  /**
46
46
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
47
47
  */
48
-
49
48
  export var isMimeTypeSupportedByBrowser = _isMimeTypeSupportedByBrowser;
50
49
  /**
51
50
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
52
51
  */
53
-
54
52
  export var isImageMimeTypeSupportedByServer = _isImageMimeTypeSupportedByServer;
55
53
  /**
56
54
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
57
55
  */
58
-
59
56
  export var isDocumentMimeTypeSupportedByServer = _isDocumentMimeTypeSupportedByServer;
60
57
  /**
61
58
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
62
59
  */
63
-
64
60
  export var isAudioMimeTypeSupportedByServer = _isAudioMimeTypeSupportedByServer;
65
61
  /**
66
62
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
67
63
  */
68
-
69
64
  export var isVideoMimeTypeSupportedByServer = _isVideoMimeTypeSupportedByServer;
70
65
  /**
71
66
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
72
67
  */
73
-
74
68
  export var isUnknownMimeTypeSupportedByServer = _isUnknownMimeTypeSupportedByServer;
75
69
  /**
76
70
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
77
71
  */
78
-
79
72
  export var isMimeTypeSupportedByServer = _isMimeTypeSupportedByServer;
@@ -1,9 +1,7 @@
1
1
  export var getArtifactUrl = function getArtifactUrl(artifacts, prop) {
2
2
  var artifact = artifacts[prop];
3
-
4
3
  if (!artifact || !artifact.url) {
5
4
  return undefined;
6
5
  }
7
-
8
6
  return artifact.url;
9
7
  };
@@ -5,37 +5,30 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
8
-
9
8
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
10
  export { isMediaClientError, getMediaClientErrorReason } from './helpers';
11
+
14
12
  /**
15
13
  * Base class for media errors
16
14
  */
17
-
18
15
  export var BaseMediaClientError = /*#__PURE__*/function (_Error) {
19
16
  _inherits(BaseMediaClientError, _Error);
20
-
21
17
  var _super = _createSuper(BaseMediaClientError);
22
-
23
18
  function BaseMediaClientError(message) {
24
19
  var _this;
25
-
26
20
  _classCallCheck(this, BaseMediaClientError);
21
+ _this = _super.call(this, message);
27
22
 
28
- _this = _super.call(this, message); // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
29
-
23
+ // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
30
24
  _this.message = message;
31
- Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype); // https://v8.dev/docs/stack-trace-api
25
+ Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof BaseMediaClientError ? this.constructor : void 0).prototype);
32
26
 
27
+ // https://v8.dev/docs/stack-trace-api
33
28
  if ('captureStackTrace' in Error) {
34
29
  Error.captureStackTrace(_assertThisInitialized(_this), this instanceof BaseMediaClientError ? this.constructor : void 0);
35
30
  }
36
-
37
31
  return _this;
38
32
  }
39
-
40
33
  return _createClass(BaseMediaClientError);
41
34
  }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -1,9 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  export var isUploadingFileState = function isUploadingFileState(fileState) {
8
5
  return fileState.status === 'uploading';
9
6
  };
@@ -28,23 +25,22 @@ export var isImageRepresentationReady = function isImageRepresentationReady(file
28
25
  case 'processed':
29
26
  case 'failed-processing':
30
27
  return !!(fileState.representations && fileState.representations.image);
31
-
32
28
  default:
33
29
  return false;
34
30
  }
35
31
  };
36
32
  export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile) {
37
33
  var _mediaFile$data = mediaFile.data,
38
- id = _mediaFile$data.id,
39
- name = _mediaFile$data.name,
40
- size = _mediaFile$data.size,
41
- processingStatus = _mediaFile$data.processingStatus,
42
- artifacts = _mediaFile$data.artifacts,
43
- mediaType = _mediaFile$data.mediaType,
44
- mimeType = _mediaFile$data.mimeType,
45
- representations = _mediaFile$data.representations,
46
- createdAt = _mediaFile$data.createdAt,
47
- metadataTraceContext = _mediaFile$data.metadataTraceContext;
34
+ id = _mediaFile$data.id,
35
+ name = _mediaFile$data.name,
36
+ size = _mediaFile$data.size,
37
+ processingStatus = _mediaFile$data.processingStatus,
38
+ artifacts = _mediaFile$data.artifacts,
39
+ mediaType = _mediaFile$data.mediaType,
40
+ mimeType = _mediaFile$data.mimeType,
41
+ representations = _mediaFile$data.representations,
42
+ createdAt = _mediaFile$data.createdAt,
43
+ metadataTraceContext = _mediaFile$data.metadataTraceContext;
48
44
  var baseState = {
49
45
  id: id,
50
46
  name: name,
@@ -56,19 +52,16 @@ export var mapMediaFileToFileState = function mapMediaFileToFileState(mediaFile)
56
52
  createdAt: createdAt,
57
53
  metadataTraceContext: metadataTraceContext
58
54
  };
59
-
60
55
  switch (processingStatus) {
61
56
  case 'pending':
62
57
  case undefined:
63
58
  return _objectSpread(_objectSpread({}, baseState), {}, {
64
59
  status: 'processing'
65
60
  });
66
-
67
61
  case 'succeeded':
68
62
  return _objectSpread(_objectSpread({}, baseState), {}, {
69
63
  status: 'processed'
70
64
  });
71
-
72
65
  case 'failed':
73
66
  return _objectSpread(_objectSpread({}, baseState), {}, {
74
67
  status: 'failed-processing'
@@ -1,19 +1,18 @@
1
1
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
2
2
  export var isPreviewableType = function isPreviewableType(type, featureFlags) {
3
3
  // in classic experience, only audio/video/image are previewable
4
- var defaultPreviewableTypes = ['audio', 'video', 'image']; // in the new experience, docs are previewable too
4
+ var defaultPreviewableTypes = ['audio', 'video', 'image'];
5
5
 
6
+ // in the new experience, docs are previewable too
6
7
  if (getMediaFeatureFlag('newCardExperience', featureFlags)) {
7
8
  return [].concat(defaultPreviewableTypes, ['doc']).indexOf(type) > -1;
8
9
  }
9
-
10
10
  return defaultPreviewableTypes.indexOf(type) > -1;
11
11
  };
12
12
  export var isMediaCollectionItemFullDetails = function isMediaCollectionItemFullDetails(mediaCollectionItem) {
13
13
  return !!mediaCollectionItem['mediaType'] && !!mediaCollectionItem['mimeType'] && !!mediaCollectionItem['processingStatus'];
14
14
  };
15
15
  export var DATA_UNIT;
16
-
17
16
  (function (DATA_UNIT) {
18
17
  DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
19
18
  DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
@@ -4,7 +4,6 @@ export var UploadController = /*#__PURE__*/function () {
4
4
  function UploadController() {
5
5
  _classCallCheck(this, UploadController);
6
6
  }
7
-
8
7
  _createClass(UploadController, [{
9
8
  key: "setAbort",
10
9
  value: function setAbort(abortFunction) {
@@ -18,6 +17,5 @@ export var UploadController = /*#__PURE__*/function () {
18
17
  }
19
18
  }
20
19
  }]);
21
-
22
20
  return UploadController;
23
21
  }();
@@ -1,6 +1,7 @@
1
1
  import { DATA_UNIT } from '../models/media';
2
2
  import { MAX_UPLOAD_FILE_SIZE } from '../constants';
3
3
  export var fileSizeError = 'fileSizeExceedsLimit';
4
+
4
5
  /**
5
6
  * This is a helper to dynamically calculate the chunk size for a given file size.
6
7
  *
@@ -15,18 +16,14 @@ export var calculateChunkSize = function calculateChunkSize(fileSize) {
15
16
  if (fileSize > MAX_UPLOAD_FILE_SIZE) {
16
17
  throw new Error(fileSizeError);
17
18
  }
18
-
19
19
  if (fileSize <= 5 * DATA_UNIT.GB) {
20
20
  return 5 * DATA_UNIT.MB;
21
21
  }
22
-
23
22
  if (fileSize > 5 * DATA_UNIT.GB && fileSize <= 50 * DATA_UNIT.GB) {
24
23
  return 50 * DATA_UNIT.MB;
25
24
  }
26
-
27
25
  if (fileSize > 50 * DATA_UNIT.GB && fileSize <= 0.95 * DATA_UNIT.TB) {
28
26
  return 100 * DATA_UNIT.MB;
29
27
  }
30
-
31
28
  return 210 * DATA_UNIT.MB;
32
29
  };
@@ -3,38 +3,30 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import { BaseMediaClientError } from '../models/errors';
12
9
  export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
13
10
  _inherits(UploaderError, _BaseMediaClientError);
14
-
15
11
  var _super = _createSuper(UploaderError);
16
-
17
12
  function UploaderError(reason, id, metadata) {
18
13
  var _this;
19
-
20
14
  _classCallCheck(this, UploaderError);
21
-
22
15
  _this = _super.call(this, reason);
23
16
  _this.reason = reason;
24
17
  _this.id = id;
25
18
  _this.metadata = metadata;
26
19
  return _this;
27
20
  }
28
-
29
21
  _createClass(UploaderError, [{
30
22
  key: "attributes",
31
23
  get: function get() {
32
24
  var reason = this.reason,
33
- id = this.id,
34
- _this$metadata = this.metadata;
25
+ id = this.id,
26
+ _this$metadata = this.metadata;
35
27
  _this$metadata = _this$metadata === void 0 ? {} : _this$metadata;
36
28
  var collectionName = _this$metadata.collectionName,
37
- occurrenceKey = _this$metadata.occurrenceKey;
29
+ occurrenceKey = _this$metadata.occurrenceKey;
38
30
  return {
39
31
  reason: reason,
40
32
  id: id,
@@ -43,7 +35,6 @@ export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
43
35
  };
44
36
  }
45
37
  }]);
46
-
47
38
  return UploaderError;
48
39
  }(BaseMediaClientError);
49
40
  export function isUploaderError(err) {
@@ -7,7 +7,6 @@ import { createHasher } from '../utils/hashing/hasherCreator';
7
7
  import { UploaderError } from './error';
8
8
  import { CHUNK_SIZE, PROCESSING_BATCH_SIZE } from '../constants';
9
9
  import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
10
-
11
10
  var hashingFunction = /*#__PURE__*/function () {
12
11
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
13
12
  var hasher;
@@ -17,11 +16,9 @@ var hashingFunction = /*#__PURE__*/function () {
17
16
  case 0:
18
17
  _context.next = 2;
19
18
  return createHasher();
20
-
21
19
  case 2:
22
20
  hasher = _context.sent;
23
21
  return _context.abrupt("return", hasher.hash(blob));
24
-
25
22
  case 4:
26
23
  case "end":
27
24
  return _context.stop();
@@ -29,12 +26,10 @@ var hashingFunction = /*#__PURE__*/function () {
29
26
  }
30
27
  }, _callee);
31
28
  }));
32
-
33
29
  return function hashingFunction(_x) {
34
30
  return _ref.apply(this, arguments);
35
31
  };
36
32
  }();
37
-
38
33
  var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName, traceContext) {
39
34
  return /*#__PURE__*/function () {
40
35
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
@@ -47,21 +42,18 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
47
42
  _context2.t1 = hashedChunks(chunks);
48
43
  _context2.next = 4;
49
44
  return deferredUploadId;
50
-
51
45
  case 4:
52
46
  _context2.t2 = _context2.sent;
53
47
  _context2.t3 = collectionName;
54
48
  _context2.t4 = traceContext;
55
49
  _context2.next = 9;
56
50
  return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
57
-
58
51
  case 9:
59
52
  response = _context2.sent;
60
53
  results = response.data.results;
61
54
  return _context2.abrupt("return", Object.values(results).map(function (result) {
62
55
  return result.exists;
63
56
  }));
64
-
65
57
  case 12:
66
58
  case "end":
67
59
  return _context2.stop();
@@ -69,13 +61,11 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
69
61
  }
70
62
  }, _callee2);
71
63
  }));
72
-
73
64
  return function (_x2) {
74
65
  return _ref2.apply(this, arguments);
75
66
  };
76
67
  }();
77
68
  };
78
-
79
69
  var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName, traceContext) {
80
70
  return /*#__PURE__*/function () {
81
71
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
@@ -88,7 +78,6 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
88
78
  _context3.t2 = chunk.blob;
89
79
  _context3.next = 5;
90
80
  return deferredUploadId;
91
-
92
81
  case 5:
93
82
  _context3.t3 = _context3.sent;
94
83
  _context3.t4 = chunk.partNumber;
@@ -96,10 +85,8 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
96
85
  _context3.t6 = traceContext;
97
86
  _context3.next = 11;
98
87
  return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
99
-
100
88
  case 11:
101
89
  return _context3.abrupt("return", _context3.sent);
102
-
103
90
  case 12:
104
91
  case "end":
105
92
  return _context3.stop();
@@ -107,13 +94,11 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
107
94
  }
108
95
  }, _callee3);
109
96
  }));
110
-
111
97
  return function (_x3) {
112
98
  return _ref3.apply(this, arguments);
113
99
  };
114
100
  }();
115
101
  };
116
-
117
102
  var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
118
103
  var offset = 0;
119
104
  return /*#__PURE__*/function () {
@@ -125,7 +110,6 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
125
110
  _context4.t0 = store;
126
111
  _context4.next = 3;
127
112
  return deferredUploadId;
128
-
129
113
  case 3:
130
114
  _context4.t1 = _context4.sent;
131
115
  _context4.t2 = {
@@ -136,10 +120,8 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
136
120
  _context4.t4 = traceContext;
137
121
  _context4.next = 9;
138
122
  return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
139
-
140
123
  case 9:
141
124
  offset += chunks.length;
142
-
143
125
  case 10:
144
126
  case "end":
145
127
  return _context4.stop();
@@ -147,13 +129,11 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
147
129
  }
148
130
  }, _callee4);
149
131
  }));
150
-
151
132
  return function (_x4) {
152
133
  return _ref4.apply(this, arguments);
153
134
  };
154
135
  }();
155
136
  };
156
-
157
137
  var createFileFromUpload = /*#__PURE__*/function () {
158
138
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
159
139
  var collection, name, mimeType, id, occurrenceKey;
@@ -172,7 +152,6 @@ var createFileFromUpload = /*#__PURE__*/function () {
172
152
  collection: collection,
173
153
  replaceFileId: id
174
154
  }, traceContext));
175
-
176
155
  case 3:
177
156
  case "end":
178
157
  return _context5.stop();
@@ -180,20 +159,17 @@ var createFileFromUpload = /*#__PURE__*/function () {
180
159
  }
181
160
  }, _callee5);
182
161
  }));
183
-
184
162
  return function createFileFromUpload(_x5, _x6, _x7, _x8, _x9) {
185
163
  return _ref5.apply(this, arguments);
186
164
  };
187
165
  }();
188
-
189
166
  export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks, traceContext) {
190
167
  var content = file.content,
191
- collection = file.collection;
168
+ collection = file.collection;
192
169
  var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId,
193
- id = uploadableFileUpfrontIds.id,
194
- occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
170
+ id = uploadableFileUpfrontIds.id,
171
+ occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
195
172
  var chunkSize = CHUNK_SIZE;
196
-
197
173
  try {
198
174
  if (content instanceof Blob) {
199
175
  chunkSize = calculateChunkSize(content.size);
@@ -205,14 +181,12 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
205
181
  occurrenceKey: occurrenceKey
206
182
  }));
207
183
  }
208
-
209
184
  return {
210
185
  cancel: function cancel() {
211
186
  callbacks === null || callbacks === void 0 ? void 0 : callbacks.onUploadFinish('canceled');
212
187
  }
213
188
  };
214
189
  }
215
-
216
190
  var chunkinatorObservable = chunkinator(content, {
217
191
  hashingFunction: hashingFunction,
218
192
  hashingConcurrency: 5,
@@ -230,9 +204,7 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
230
204
  }
231
205
  }
232
206
  });
233
-
234
207
  var onUploadFinish = callbacks && callbacks.onUploadFinish || function () {};
235
-
236
208
  var subscription = from(deferredUploadId).pipe(concatMap(function (uploadId) {
237
209
  return chunkinatorObservable.pipe(concatMap(function () {
238
210
  return from(createFileFromUpload(file, store, uploadableFileUpfrontIds, uploadId, traceContext));
@@ -252,7 +224,6 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
252
224
  }
253
225
  };
254
226
  };
255
-
256
227
  var hashedChunks = function hashedChunks(chunks) {
257
228
  return chunks.map(function (chunk) {
258
229
  return chunk.hash;
@@ -8,14 +8,13 @@ export var checkWebpSupport = function checkWebpSupport() {
8
8
  if (isSupported !== undefined) {
9
9
  return Promise.resolve(isSupported);
10
10
  }
11
-
12
11
  return new Promise(function (resolve) {
13
- var img = new Image(); // Following base64 encoded binary content is in webp format. If browser supports this standard,
12
+ var img = new Image();
13
+
14
+ // Following base64 encoded binary content is in webp format. If browser supports this standard,
14
15
  // 2px height image will be displayed. If not, standard "not found" image placeholder will be
15
16
  // displayed and it will be not 2px height.
16
-
17
17
  img.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA';
18
-
19
18
  img.onload = img.onerror = function () {
20
19
  isSupported = img.height === 2;
21
20
  resolve(isSupported);