@atlaskit/media-card 74.5.1 → 74.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 (271) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/card/actions.js +0 -5
  3. package/dist/cjs/card/card.js +263 -322
  4. package/dist/cjs/card/cardAnalytics.js +0 -18
  5. package/dist/cjs/card/cardImageView/cardImageViewWrapper.js +7 -16
  6. package/dist/cjs/card/cardImageView/cardOverlay/cardOverlayComponents.js +3 -15
  7. package/dist/cjs/card/cardImageView/cardOverlay/index.js +20 -52
  8. package/dist/cjs/card/cardImageView/cardOverlay/styles.js +1 -19
  9. package/dist/cjs/card/cardImageView/cardViewWrapper.js +7 -10
  10. package/dist/cjs/card/cardImageView/fileCardImageView.js +66 -111
  11. package/dist/cjs/card/cardImageView/index.js +0 -1
  12. package/dist/cjs/card/cardImageView/styles.js +0 -14
  13. package/dist/cjs/card/cardLoader.js +3 -20
  14. package/dist/cjs/card/cardState.js +0 -9
  15. package/dist/cjs/card/cardView.js +105 -198
  16. package/dist/cjs/card/getCardPreview/cache.js +0 -12
  17. package/dist/cjs/card/getCardPreview/filePreviewStatus.js +8 -16
  18. package/dist/cjs/card/getCardPreview/helpers.js +0 -39
  19. package/dist/cjs/card/getCardPreview/imageRefetchingAnalytics.js +0 -8
  20. package/dist/cjs/card/getCardPreview/index.js +19 -86
  21. package/dist/cjs/card/getCardStatus.js +5 -24
  22. package/dist/cjs/card/index.js +0 -2
  23. package/dist/cjs/card/inlinePlayer.js +19 -102
  24. package/dist/cjs/card/inlinePlayerLazy.js +0 -11
  25. package/dist/cjs/card/inlinePlayerWrapper.js +5 -8
  26. package/dist/cjs/card/media-card-analytics-error-boundary.js +6 -34
  27. package/dist/cjs/card/styles/animations.js +0 -5
  28. package/dist/cjs/card/styles/getSelectedBorderStyle.js +0 -4
  29. package/dist/cjs/card/styles/index.js +0 -14
  30. package/dist/cjs/card/styles/mixins.js +0 -11
  31. package/dist/cjs/card/styles/styles.js +4 -20
  32. package/dist/cjs/card/ui/actionsBar/actionsBar.js +2 -20
  33. package/dist/cjs/card/ui/actionsBar/actionsBarWrapper.js +1 -4
  34. package/dist/cjs/card/ui/actionsBar/styles.js +0 -8
  35. package/dist/cjs/card/ui/blanket/blanket.js +1 -4
  36. package/dist/cjs/card/ui/blanket/styles.js +0 -9
  37. package/dist/cjs/card/ui/common.js +0 -8
  38. package/dist/cjs/card/ui/iconMessage/iconMessageWrapper.js +2 -5
  39. package/dist/cjs/card/ui/iconMessage/index.js +4 -22
  40. package/dist/cjs/card/ui/iconMessage/styles.js +1 -10
  41. package/dist/cjs/card/ui/iconWrapper/iconWrapper.js +2 -5
  42. package/dist/cjs/card/ui/iconWrapper/styles.js +3 -11
  43. package/dist/cjs/card/ui/imageRenderer/imageRenderer.js +8 -21
  44. package/dist/cjs/card/ui/loadingRateLimited/styles.js +1 -10
  45. package/dist/cjs/card/ui/newFileExperience/newFileExperienceWrapper.js +14 -19
  46. package/dist/cjs/card/ui/newFileExperience/styles.js +10 -26
  47. package/dist/cjs/card/ui/playButton/playButton.js +0 -7
  48. package/dist/cjs/card/ui/playButton/playButtonBackground.js +1 -4
  49. package/dist/cjs/card/ui/playButton/playButtonWrapper.js +1 -4
  50. package/dist/cjs/card/ui/playButton/styles.js +0 -6
  51. package/dist/cjs/card/ui/progressBar/progressBar.js +6 -14
  52. package/dist/cjs/card/ui/progressBar/styledBar.js +4 -7
  53. package/dist/cjs/card/ui/progressBar/styles.js +4 -18
  54. package/dist/cjs/card/ui/styles.js +12 -46
  55. package/dist/cjs/card/ui/tickBox/styles.js +0 -11
  56. package/dist/cjs/card/ui/tickBox/tickBox.js +0 -6
  57. package/dist/cjs/card/ui/tickBox/tickBoxWrapper.js +1 -4
  58. package/dist/cjs/card/ui/titleBox/failedTitleBox.js +2 -11
  59. package/dist/cjs/card/ui/titleBox/styles.js +4 -19
  60. package/dist/cjs/card/ui/titleBox/titleBox.js +9 -21
  61. package/dist/cjs/card/ui/titleBox/titleBoxComponents.js +2 -14
  62. package/dist/cjs/card/ui/unhandledErrorCard/index.js +6 -36
  63. package/dist/cjs/classnames.js +0 -1
  64. package/dist/cjs/errors.js +7 -66
  65. package/dist/cjs/index.js +0 -8
  66. package/dist/cjs/inline/index.js +0 -2
  67. package/dist/cjs/inline/loader.js +2 -43
  68. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +4 -29
  69. package/dist/cjs/inline/mediaInlineCard.js +21 -57
  70. package/dist/cjs/types.js +0 -2
  71. package/dist/cjs/utils/analytics.js +0 -49
  72. package/dist/cjs/utils/breakpoint.js +0 -10
  73. package/dist/cjs/utils/cardActions/cardActionButton.js +1 -4
  74. package/dist/cjs/utils/cardActions/cardActionIconButton.js +7 -29
  75. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +6 -35
  76. package/dist/cjs/utils/cardActions/cardActionsView.js +7 -34
  77. package/dist/cjs/utils/cardActions/index.js +0 -4
  78. package/dist/cjs/utils/cardActions/styles.js +0 -13
  79. package/dist/cjs/utils/cardDimensions.js +5 -22
  80. package/dist/cjs/utils/containsPixelUnit.js +0 -2
  81. package/dist/cjs/utils/dimensionComparer.js +0 -8
  82. package/dist/cjs/utils/document.js +0 -4
  83. package/dist/cjs/utils/errorIcon/index.js +0 -18
  84. package/dist/cjs/utils/errorIcon/styles.js +0 -5
  85. package/dist/cjs/utils/fileIcon/index.js +3 -21
  86. package/dist/cjs/utils/fileIcon/styles.js +0 -6
  87. package/dist/cjs/utils/generateUniqueId.js +0 -2
  88. package/dist/cjs/utils/getCSSUnitValue.js +0 -1
  89. package/dist/cjs/utils/getDataURIDimension.js +0 -13
  90. package/dist/cjs/utils/getElementDimension.js +0 -2
  91. package/dist/cjs/utils/getErrorMessage.js +0 -6
  92. package/dist/cjs/utils/getMediaCardCursor.js +1 -6
  93. package/dist/cjs/utils/globalScope/getSSRData.js +0 -5
  94. package/dist/cjs/utils/globalScope/globalScope.js +8 -25
  95. package/dist/cjs/utils/globalScope/index.js +0 -2
  96. package/dist/cjs/utils/index.js +0 -12
  97. package/dist/cjs/utils/isRetina.js +0 -1
  98. package/dist/cjs/utils/isValidPercentageUnit.js +0 -2
  99. package/dist/cjs/utils/lightCards/cardError.js +0 -21
  100. package/dist/cjs/utils/lightCards/cardLoading.js +3 -27
  101. package/dist/cjs/utils/lightCards/getDimensionsWithDefault.js +0 -2
  102. package/dist/cjs/utils/lightCards/lightCardWrappers.js +1 -9
  103. package/dist/cjs/utils/lightCards/styles.js +1 -13
  104. package/dist/cjs/utils/metadata.js +0 -7
  105. package/dist/cjs/utils/objectURLCache.js +0 -22
  106. package/dist/cjs/utils/preventClickThrough.js +0 -5
  107. package/dist/cjs/utils/printScript.js +0 -10
  108. package/dist/cjs/utils/progressBar/index.js +0 -17
  109. package/dist/cjs/utils/progressBar/styles.js +0 -6
  110. package/dist/cjs/utils/resizeModeToMediaImageProps.js +0 -1
  111. package/dist/cjs/utils/shouldDisplayImageThumbnail.js +0 -5
  112. package/dist/cjs/utils/ufoExperiences.js +1 -21
  113. package/dist/cjs/utils/videoSnapshot.js +2 -11
  114. package/dist/cjs/utils/viewportDetector.js +5 -24
  115. package/dist/cjs/version.json +1 -1
  116. package/dist/es2019/card/actions.js +2 -1
  117. package/dist/es2019/card/card.js +115 -156
  118. package/dist/es2019/card/cardAnalytics.js +0 -5
  119. package/dist/es2019/card/cardImageView/cardOverlay/index.js +2 -16
  120. package/dist/es2019/card/cardImageView/cardOverlay/styles.js +1 -2
  121. package/dist/es2019/card/cardImageView/fileCardImageView.js +3 -36
  122. package/dist/es2019/card/cardImageView/styles.js +0 -3
  123. package/dist/es2019/card/cardLoader.js +3 -14
  124. package/dist/es2019/card/cardState.js +1 -2
  125. package/dist/es2019/card/cardView.js +24 -68
  126. package/dist/es2019/card/getCardPreview/cache.js +0 -4
  127. package/dist/es2019/card/getCardPreview/filePreviewStatus.js +8 -5
  128. package/dist/es2019/card/getCardPreview/helpers.js +0 -9
  129. package/dist/es2019/card/getCardPreview/imageRefetchingAnalytics.js +0 -3
  130. package/dist/es2019/card/getCardPreview/index.js +20 -32
  131. package/dist/es2019/card/getCardStatus.js +2 -15
  132. package/dist/es2019/card/inlinePlayer.js +2 -35
  133. package/dist/es2019/card/inlinePlayerLazy.js +1 -2
  134. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -15
  135. package/dist/es2019/card/styles/getSelectedBorderStyle.js +1 -1
  136. package/dist/es2019/card/styles/styles.js +0 -3
  137. package/dist/es2019/card/ui/actionsBar/actionsBar.js +0 -3
  138. package/dist/es2019/card/ui/common.js +0 -2
  139. package/dist/es2019/card/ui/iconMessage/styles.js +0 -2
  140. package/dist/es2019/card/ui/iconWrapper/styles.js +2 -2
  141. package/dist/es2019/card/ui/imageRenderer/imageRenderer.js +0 -3
  142. package/dist/es2019/card/ui/progressBar/styles.js +1 -3
  143. package/dist/es2019/card/ui/styles.js +3 -4
  144. package/dist/es2019/card/ui/titleBox/styles.js +2 -3
  145. package/dist/es2019/card/ui/unhandledErrorCard/index.js +0 -8
  146. package/dist/es2019/errors.js +8 -17
  147. package/dist/es2019/index.js +1 -0
  148. package/dist/es2019/inline/loader.js +1 -18
  149. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +1 -12
  150. package/dist/es2019/inline/mediaInlineCard.js +0 -15
  151. package/dist/es2019/types.js +1 -1
  152. package/dist/es2019/utils/analytics.js +0 -3
  153. package/dist/es2019/utils/breakpoint.js +0 -4
  154. package/dist/es2019/utils/cardActions/cardActionIconButton.js +3 -5
  155. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +0 -5
  156. package/dist/es2019/utils/cardActions/cardActionsView.js +0 -10
  157. package/dist/es2019/utils/cardActions/styles.js +0 -3
  158. package/dist/es2019/utils/cardDimensions.js +7 -14
  159. package/dist/es2019/utils/dimensionComparer.js +0 -3
  160. package/dist/es2019/utils/document.js +0 -2
  161. package/dist/es2019/utils/errorIcon/index.js +0 -3
  162. package/dist/es2019/utils/fileIcon/index.js +0 -1
  163. package/dist/es2019/utils/getDataURIDimension.js +0 -4
  164. package/dist/es2019/utils/getMediaCardCursor.js +1 -4
  165. package/dist/es2019/utils/globalScope/getSSRData.js +0 -2
  166. package/dist/es2019/utils/globalScope/globalScope.js +3 -10
  167. package/dist/es2019/utils/lightCards/cardError.js +0 -3
  168. package/dist/es2019/utils/lightCards/cardLoading.js +0 -3
  169. package/dist/es2019/utils/lightCards/lightCardWrappers.js +0 -1
  170. package/dist/es2019/utils/metadata.js +0 -5
  171. package/dist/es2019/utils/objectURLCache.js +0 -10
  172. package/dist/es2019/utils/printScript.js +0 -3
  173. package/dist/es2019/utils/progressBar/index.js +0 -2
  174. package/dist/es2019/utils/shouldDisplayImageThumbnail.js +0 -2
  175. package/dist/es2019/utils/ufoExperiences.js +5 -10
  176. package/dist/es2019/utils/videoSnapshot.js +2 -4
  177. package/dist/es2019/utils/viewportDetector.js +0 -5
  178. package/dist/es2019/version.json +1 -1
  179. package/dist/esm/card/actions.js +0 -3
  180. package/dist/esm/card/card.js +263 -316
  181. package/dist/esm/card/cardAnalytics.js +0 -6
  182. package/dist/esm/card/cardImageView/cardImageViewWrapper.js +6 -6
  183. package/dist/esm/card/cardImageView/cardOverlay/cardOverlayComponents.js +2 -2
  184. package/dist/esm/card/cardImageView/cardOverlay/index.js +22 -37
  185. package/dist/esm/card/cardImageView/cardOverlay/styles.js +2 -6
  186. package/dist/esm/card/cardImageView/cardViewWrapper.js +6 -6
  187. package/dist/esm/card/cardImageView/fileCardImageView.js +66 -104
  188. package/dist/esm/card/cardImageView/styles.js +0 -5
  189. package/dist/esm/card/cardLoader.js +6 -17
  190. package/dist/esm/card/cardState.js +1 -2
  191. package/dist/esm/card/cardView.js +105 -171
  192. package/dist/esm/card/getCardPreview/cache.js +0 -7
  193. package/dist/esm/card/getCardPreview/filePreviewStatus.js +11 -11
  194. package/dist/esm/card/getCardPreview/helpers.js +0 -28
  195. package/dist/esm/card/getCardPreview/imageRefetchingAnalytics.js +0 -3
  196. package/dist/esm/card/getCardPreview/index.js +19 -54
  197. package/dist/esm/card/getCardStatus.js +5 -20
  198. package/dist/esm/card/inlinePlayer.js +19 -85
  199. package/dist/esm/card/inlinePlayerLazy.js +1 -5
  200. package/dist/esm/card/inlinePlayerWrapper.js +4 -4
  201. package/dist/esm/card/media-card-analytics-error-boundary.js +6 -28
  202. package/dist/esm/card/styles/animations.js +0 -2
  203. package/dist/esm/card/styles/getSelectedBorderStyle.js +1 -1
  204. package/dist/esm/card/styles/index.js +0 -2
  205. package/dist/esm/card/styles/styles.js +4 -9
  206. package/dist/esm/card/ui/actionsBar/actionsBar.js +2 -12
  207. package/dist/esm/card/ui/actionsBar/styles.js +0 -2
  208. package/dist/esm/card/ui/blanket/styles.js +0 -2
  209. package/dist/esm/card/ui/common.js +0 -4
  210. package/dist/esm/card/ui/iconMessage/iconMessageWrapper.js +1 -1
  211. package/dist/esm/card/ui/iconMessage/index.js +4 -4
  212. package/dist/esm/card/ui/iconMessage/styles.js +1 -5
  213. package/dist/esm/card/ui/iconWrapper/iconWrapper.js +1 -1
  214. package/dist/esm/card/ui/iconWrapper/styles.js +3 -5
  215. package/dist/esm/card/ui/imageRenderer/imageRenderer.js +8 -11
  216. package/dist/esm/card/ui/loadingRateLimited/styles.js +1 -3
  217. package/dist/esm/card/ui/newFileExperience/newFileExperienceWrapper.js +13 -13
  218. package/dist/esm/card/ui/newFileExperience/styles.js +10 -12
  219. package/dist/esm/card/ui/playButton/styles.js +0 -2
  220. package/dist/esm/card/ui/progressBar/progressBar.js +6 -6
  221. package/dist/esm/card/ui/progressBar/styledBar.js +3 -3
  222. package/dist/esm/card/ui/progressBar/styles.js +4 -8
  223. package/dist/esm/card/ui/styles.js +12 -20
  224. package/dist/esm/card/ui/tickBox/styles.js +0 -2
  225. package/dist/esm/card/ui/titleBox/failedTitleBox.js +2 -2
  226. package/dist/esm/card/ui/titleBox/styles.js +4 -7
  227. package/dist/esm/card/ui/titleBox/titleBox.js +9 -11
  228. package/dist/esm/card/ui/titleBox/titleBoxComponents.js +1 -1
  229. package/dist/esm/card/ui/unhandledErrorCard/index.js +6 -24
  230. package/dist/esm/errors.js +8 -40
  231. package/dist/esm/index.js +1 -0
  232. package/dist/esm/inline/loader.js +3 -40
  233. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +4 -23
  234. package/dist/esm/inline/mediaInlineCard.js +21 -40
  235. package/dist/esm/types.js +1 -1
  236. package/dist/esm/utils/analytics.js +0 -6
  237. package/dist/esm/utils/breakpoint.js +0 -5
  238. package/dist/esm/utils/cardActions/cardActionIconButton.js +7 -18
  239. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +6 -19
  240. package/dist/esm/utils/cardActions/cardActionsView.js +7 -22
  241. package/dist/esm/utils/cardActions/styles.js +0 -5
  242. package/dist/esm/utils/cardDimensions.js +7 -14
  243. package/dist/esm/utils/dimensionComparer.js +0 -3
  244. package/dist/esm/utils/document.js +0 -2
  245. package/dist/esm/utils/errorIcon/index.js +0 -9
  246. package/dist/esm/utils/errorIcon/styles.js +0 -2
  247. package/dist/esm/utils/fileIcon/index.js +3 -11
  248. package/dist/esm/utils/fileIcon/styles.js +0 -2
  249. package/dist/esm/utils/getDataURIDimension.js +0 -4
  250. package/dist/esm/utils/getMediaCardCursor.js +1 -4
  251. package/dist/esm/utils/globalScope/getSSRData.js +0 -2
  252. package/dist/esm/utils/globalScope/globalScope.js +8 -15
  253. package/dist/esm/utils/lightCards/cardError.js +0 -9
  254. package/dist/esm/utils/lightCards/cardLoading.js +3 -13
  255. package/dist/esm/utils/lightCards/lightCardWrappers.js +0 -1
  256. package/dist/esm/utils/lightCards/styles.js +1 -3
  257. package/dist/esm/utils/metadata.js +0 -5
  258. package/dist/esm/utils/objectURLCache.js +0 -15
  259. package/dist/esm/utils/printScript.js +0 -5
  260. package/dist/esm/utils/progressBar/index.js +0 -9
  261. package/dist/esm/utils/progressBar/styles.js +0 -2
  262. package/dist/esm/utils/shouldDisplayImageThumbnail.js +0 -2
  263. package/dist/esm/utils/ufoExperiences.js +1 -12
  264. package/dist/esm/utils/videoSnapshot.js +2 -6
  265. package/dist/esm/utils/viewportDetector.js +5 -16
  266. package/dist/esm/version.json +1 -1
  267. package/dist/types/card/card.d.ts +3 -0
  268. package/dist/types/card/getCardPreview/index.d.ts +2 -1
  269. package/dist/types/types.d.ts +1 -0
  270. package/package.json +6 -4
  271. package/report.api.md +2 -0
@@ -26,25 +26,24 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
26
26
  import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
27
27
  import { generateUniqueId } from '../utils/generateUniqueId';
28
28
  const packageName = "@atlaskit/media-card";
29
- const packageVersion = "74.5.1";
29
+ const packageVersion = "74.6.0";
30
30
  export class CardBase extends Component {
31
31
  // An internalOccurrenceKey is a randomly generated value to differentiate various instances
32
32
  // of Cards regardless of whether it shares the same file (either internal or external)
33
+
33
34
  // We initialise timeElapsedTillCommenced
34
35
  // to avoid extra branching on a possibly undefined value.
36
+
35
37
  // Generate unique traceId for file
38
+
36
39
  constructor(props) {
37
40
  super(props);
38
-
39
41
  _defineProperty(this, "internalOccurrenceKey", generateUniqueId());
40
-
41
42
  _defineProperty(this, "hasBeenMounted", false);
42
-
43
43
  _defineProperty(this, "fileStateFlags", {
44
44
  wasStatusUploading: false,
45
45
  wasStatusProcessing: false
46
46
  });
47
-
48
47
  _defineProperty(this, "ssrReliability", {
49
48
  server: {
50
49
  status: 'unknown'
@@ -53,13 +52,10 @@ export class CardBase extends Component {
53
52
  status: 'unknown'
54
53
  }
55
54
  });
56
-
57
55
  _defineProperty(this, "timeElapsedTillCommenced", performance.now());
58
-
59
56
  _defineProperty(this, "traceContext", {
60
57
  traceId: getRandomHex(8)
61
58
  });
62
-
63
59
  _defineProperty(this, "getImageURLParams", ({
64
60
  collectionName: collection
65
61
  }) => ({
@@ -68,7 +64,6 @@ export class CardBase extends Component {
68
64
  ...this.requestedDimensions,
69
65
  allowAnimated: true
70
66
  }));
71
-
72
67
  _defineProperty(this, "getMediaBlobUrlAttrs", (identifier, fileState) => {
73
68
  const {
74
69
  id,
@@ -95,7 +90,6 @@ export class CardBase extends Component {
95
90
  alt
96
91
  } : undefined;
97
92
  });
98
-
99
93
  _defineProperty(this, "getCardPreviewParams", (identifier, fileState) => {
100
94
  const {
101
95
  isBannedLocalPreview
@@ -122,27 +116,17 @@ export class CardBase extends Component {
122
116
  traceContext: this.traceContext
123
117
  };
124
118
  });
125
-
126
119
  _defineProperty(this, "setCacheSSRPreview", identifier => {
127
- const {
128
- mediaClient,
129
- dimensions = {}
130
- } = this.props;
131
- fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier)).catch(() => {// No need to log this error.
120
+ this.fetchAndCacheRemotePreview(identifier).catch(() => {
121
+ // No need to log this error.
132
122
  // If preview fails, it will be refetched later
133
123
  //TODO: test this catch
134
124
  // https://product-fabric.atlassian.net/browse/MEX-1071
135
125
  });
136
126
  });
137
-
138
127
  _defineProperty(this, "refetchSSRPreview", async identifier => {
139
- const {
140
- mediaClient,
141
- dimensions = {}
142
- } = this.props;
143
-
144
128
  try {
145
- const cardPreview = await fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
129
+ const cardPreview = await this.fetchAndCacheRemotePreview(identifier);
146
130
  this.safeSetState({
147
131
  cardPreview
148
132
  });
@@ -151,7 +135,44 @@ export class CardBase extends Component {
151
135
  this.fireNonCriticalErrorEvent(wrappedError);
152
136
  }
153
137
  });
138
+ _defineProperty(this, "resolveUpfrontPreview", async identifier => {
139
+ const requestedDimensions = {
140
+ ...this.props.dimensions
141
+ };
142
+ try {
143
+ const cardPreview = await this.fetchAndCacheRemotePreview(identifier);
144
+ const {
145
+ dimensions: currentDimensions
146
+ } = this.props;
147
+ const areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions);
154
148
 
149
+ // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
150
+ // the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
151
+ // to trigger a normal preview fetch.
152
+ if (areValidRequestedDimensions) {
153
+ this.safeSetState({
154
+ cardPreview,
155
+ wasResolvedUpfrontPreview: true
156
+ });
157
+ } else {
158
+ this.safeSetState({
159
+ wasResolvedUpfrontPreview: true
160
+ });
161
+ }
162
+ } catch (e) {
163
+ this.safeSetState({
164
+ wasResolvedUpfrontPreview: true
165
+ });
166
+ // NO need to log error. If this call fails, a refetch will happen after
167
+ }
168
+ });
169
+ _defineProperty(this, "fetchAndCacheRemotePreview", identifier => {
170
+ const {
171
+ mediaClient,
172
+ dimensions = {}
173
+ } = this.props;
174
+ return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
175
+ });
155
176
  _defineProperty(this, "resolvePreview", async (identifier, fileState) => {
156
177
  try {
157
178
  const params = this.getCardPreviewParams(identifier, fileState);
@@ -160,11 +181,11 @@ export class CardBase extends Component {
160
181
  cardPreview
161
182
  });
162
183
  } catch (e) {
163
- const wrappedError = ensureMediaCardError('preview-fetch', e); // If remote preview fails, we set status 'error'
184
+ const wrappedError = ensureMediaCardError('preview-fetch', e);
185
+ // If remote preview fails, we set status 'error'
164
186
  // If local preview fails (i.e, no remote preview available),
165
187
  // we can stay in the same status until there is a remote preview available
166
188
  // If it's any other error we set status 'error'
167
-
168
189
  if (isLocalPreviewError(wrappedError)) {
169
190
  // This error should already been logged inside the getCardPreview. No need to log it here.
170
191
  this.safeSetState({
@@ -178,7 +199,6 @@ export class CardBase extends Component {
178
199
  }
179
200
  }
180
201
  });
181
-
182
202
  _defineProperty(this, "getPerformanceAttributes", () => {
183
203
  const {
184
204
  timeElapsedTillCommenced
@@ -192,53 +212,46 @@ export class CardBase extends Component {
192
212
  }
193
213
  };
194
214
  });
195
-
196
215
  _defineProperty(this, "logSSRImageError", cardPreview => {
197
216
  if (cardPreview) {
198
217
  const failedSSRObject = {
199
218
  status: 'fail',
200
219
  ...extractErrorInfo(new ImageLoadError(cardPreview.source))
201
220
  };
202
-
203
221
  if (isSSRClientPreview(cardPreview)) {
204
222
  this.ssrReliability.client = failedSSRObject;
205
223
  }
224
+
206
225
  /*
207
226
  If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
208
227
  */
209
228
 
210
-
211
229
  if (isSSRDataPreview(cardPreview)) {
212
230
  this.ssrReliability.server = failedSSRObject;
213
231
  this.ssrReliability.client = failedSSRObject;
214
232
  }
215
233
  }
216
234
  });
217
-
218
235
  _defineProperty(this, "onImageError", cardPreview => {
219
236
  this.logSSRImageError(cardPreview);
220
237
  const {
221
238
  cardPreview: currentPreview
222
- } = this.state; // If the dataURI has been replaced, we can dismiss this error
223
-
239
+ } = this.state;
240
+ // If the dataURI has been replaced, we can dismiss this error
224
241
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
225
242
  return;
226
243
  }
227
-
228
244
  const error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
229
245
  const isLocal = cardPreview && isLocalPreview(cardPreview);
230
246
  const isSSR = cardPreview && (isSSRClientPreview(cardPreview) || isSSRDataPreview(cardPreview));
231
-
232
247
  if (isLocal || isSSR) {
233
248
  const updateState = {
234
249
  cardPreview: undefined
235
250
  };
236
-
237
251
  if (isLocal) {
238
252
  updateState.isBannedLocalPreview = true;
239
253
  this.fireNonCriticalErrorEvent(error);
240
254
  }
241
-
242
255
  const {
243
256
  identifier,
244
257
  resizeMode
@@ -253,7 +266,6 @@ export class CardBase extends Component {
253
266
  });
254
267
  }
255
268
  });
256
-
257
269
  _defineProperty(this, "onImageLoad", cardPreview => {
258
270
  if (cardPreview) {
259
271
  if (isSSRClientPreview(cardPreview) && this.ssrReliability.client.status === 'unknown') {
@@ -261,11 +273,11 @@ export class CardBase extends Component {
261
273
  status: 'success'
262
274
  };
263
275
  }
276
+
264
277
  /*
265
278
  If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
266
279
  */
267
280
 
268
-
269
281
  if (isSSRDataPreview(cardPreview) && this.ssrReliability.server.status === 'unknown') {
270
282
  this.ssrReliability.server = {
271
283
  status: 'success'
@@ -275,20 +287,17 @@ export class CardBase extends Component {
275
287
  };
276
288
  }
277
289
  }
278
-
279
290
  const {
280
291
  cardPreview: currentPreview
281
- } = this.state; // If the dataURI has been replaced, we can dismiss this callback
282
-
292
+ } = this.state;
293
+ // If the dataURI has been replaced, we can dismiss this callback
283
294
  if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
284
295
  return;
285
296
  }
286
-
287
297
  this.safeSetState({
288
298
  previewDidRender: true
289
299
  });
290
300
  });
291
-
292
301
  _defineProperty(this, "fireCopiedEvent", () => {
293
302
  const {
294
303
  createAnalyticsEvent
@@ -298,14 +307,12 @@ export class CardBase extends Component {
298
307
  } = this.state;
299
308
  cardRef && createAnalyticsEvent && fireCopiedEvent(createAnalyticsEvent, this.metadata.id, cardRef);
300
309
  });
301
-
302
310
  _defineProperty(this, "fireScreenEvent", () => {
303
311
  const {
304
312
  createAnalyticsEvent
305
313
  } = this.props;
306
314
  createAnalyticsEvent && fireScreenEvent(createAnalyticsEvent, this.fileAttributes);
307
315
  });
308
-
309
316
  _defineProperty(this, "fireNonCriticalErrorEvent", error => {
310
317
  const {
311
318
  createAnalyticsEvent
@@ -315,7 +322,6 @@ export class CardBase extends Component {
315
322
  } = this.state;
316
323
  createAnalyticsEvent && fireNonCriticalErrorEvent(createAnalyticsEvent, this.state.status, this.fileAttributes, this.ssrReliability, error, this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
317
324
  });
318
-
319
325
  _defineProperty(this, "safeSetState", newState => {
320
326
  if (this.hasBeenMounted) {
321
327
  /**
@@ -328,12 +334,10 @@ export class CardBase extends Component {
328
334
  this.setState(createStateUpdater(newState, this.fireNonCriticalErrorEvent));
329
335
  }
330
336
  });
331
-
332
337
  _defineProperty(this, "unsubscribe", () => {
333
338
  if (this.subscription) {
334
339
  this.subscription.unsubscribe();
335
340
  }
336
-
337
341
  if (this.hasBeenMounted) {
338
342
  // TODO MEX-788: add test for "do not remove the card preview when unsubscribing".
339
343
  this.setState({
@@ -341,7 +345,6 @@ export class CardBase extends Component {
341
345
  });
342
346
  }
343
347
  });
344
-
345
348
  _defineProperty(this, "onCardViewClick", (event, analyticsEvent) => {
346
349
  const {
347
350
  identifier,
@@ -355,13 +358,10 @@ export class CardBase extends Component {
355
358
  metadata
356
359
  } = this;
357
360
  this.onClick(event, analyticsEvent);
358
-
359
361
  if (!metadata) {
360
362
  return;
361
363
  }
362
-
363
364
  const isVideo = metadata && metadata.mediaType === 'video';
364
-
365
365
  if (useInlinePlayer && isVideo && !!cardPreview) {
366
366
  this.setState({
367
367
  isPlayingFile: true,
@@ -369,7 +369,6 @@ export class CardBase extends Component {
369
369
  });
370
370
  } else if (shouldOpenMediaViewer) {
371
371
  let mediaViewerSelectedItem;
372
-
373
372
  if (isFileIdentifier(identifier)) {
374
373
  mediaViewerSelectedItem = {
375
374
  id: identifier.id,
@@ -384,25 +383,21 @@ export class CardBase extends Component {
384
383
  name: identifier.name
385
384
  };
386
385
  }
387
-
388
386
  this.setState({
389
387
  mediaViewerSelectedItem
390
388
  });
391
389
  }
392
390
  });
393
-
394
391
  _defineProperty(this, "onInlinePlayerError", () => {
395
392
  this.setState({
396
393
  isPlayingFile: false
397
394
  });
398
395
  });
399
-
400
396
  _defineProperty(this, "setRef", cardRef => {
401
397
  !!cardRef && this.setState({
402
398
  cardRef
403
399
  });
404
400
  });
405
-
406
401
  _defineProperty(this, "renderInlinePlayer", () => {
407
402
  const {
408
403
  identifier,
@@ -435,19 +430,16 @@ export class CardBase extends Component {
435
430
  cardPreview: cardPreview
436
431
  }));
437
432
  });
438
-
439
433
  _defineProperty(this, "onMediaViewerClose", () => {
440
434
  this.setState({
441
435
  mediaViewerSelectedItem: undefined
442
436
  });
443
437
  });
444
-
445
438
  _defineProperty(this, "onDisplayImage", () => {
446
439
  const {
447
440
  identifier
448
441
  } = this.props;
449
442
  let payloadPart;
450
-
451
443
  if (isFileIdentifier(identifier)) {
452
444
  payloadPart = {
453
445
  fileId: identifier.id,
@@ -459,13 +451,11 @@ export class CardBase extends Component {
459
451
  isUserCollection: false
460
452
  };
461
453
  }
462
-
463
454
  globalMediaEventEmitter.emit('media-viewed', {
464
455
  viewingLevel: 'minimal',
465
456
  ...payloadPart
466
457
  });
467
458
  });
468
-
469
459
  _defineProperty(this, "renderMediaViewer", () => {
470
460
  const {
471
461
  mediaViewerSelectedItem
@@ -477,11 +467,9 @@ export class CardBase extends Component {
477
467
  contextId,
478
468
  featureFlags
479
469
  } = this.props;
480
-
481
470
  if (!mediaViewerSelectedItem) {
482
471
  return;
483
472
  }
484
-
485
473
  const collectionName = isFileIdentifier(identifier) ? identifier.collectionName || '' : '';
486
474
  const dataSource = mediaViewerDataSource || {
487
475
  list: []
@@ -496,7 +484,6 @@ export class CardBase extends Component {
496
484
  featureFlags: featureFlags
497
485
  }), document.body);
498
486
  });
499
-
500
487
  _defineProperty(this, "renderCard", (withCallbacks = true, cardStatusOverride, izLazyOverride) => {
501
488
  const {
502
489
  identifier,
@@ -536,11 +523,12 @@ export class CardBase extends Component {
536
523
  actions,
537
524
  onMouseEnter
538
525
  } = this;
539
- const isLazyWithOverride = izLazyOverride === undefined ? isLazy : izLazyOverride; // Card can be artificially turned visible before entering the viewport
540
- // For example, when we have the image in cache
541
-
542
- const nativeLazyLoad = isLazyWithOverride && !isCardVisible; // Force Media Image to always display img for SSR
526
+ const isLazyWithOverride = izLazyOverride === undefined ? isLazy : izLazyOverride;
543
527
 
528
+ // Card can be artificially turned visible before entering the viewport
529
+ // For example, when we have the image in cache
530
+ const nativeLazyLoad = isLazyWithOverride && !isCardVisible;
531
+ // Force Media Image to always display img for SSR
544
532
  const forceSyncDisplay = !!ssr;
545
533
  const mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, status === 'error' || status === 'failed-processing', !!this.state.cardPreview, metadata.mediaType);
546
534
  const card = /*#__PURE__*/React.createElement(CardView, {
@@ -577,10 +565,8 @@ export class CardBase extends Component {
577
565
  onVisible: this.onCardInViewport
578
566
  }, card) : card;
579
567
  });
580
-
581
568
  _defineProperty(this, "storeSSRData", () => {
582
569
  var _this$ssrReliability$;
583
-
584
570
  const {
585
571
  ssr,
586
572
  identifier
@@ -597,13 +583,11 @@ export class CardBase extends Component {
597
583
  error: ((_this$ssrReliability$ = this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? this.ssrReliability.server : undefined
598
584
  });
599
585
  });
600
-
601
586
  _defineProperty(this, "onCardInViewport", () => {
602
587
  this.setState({
603
588
  isCardVisible: true
604
589
  });
605
590
  });
606
-
607
591
  _defineProperty(this, "onClick", (event, analyticsEvent) => {
608
592
  const {
609
593
  onClick
@@ -611,7 +595,6 @@ export class CardBase extends Component {
611
595
  const {
612
596
  metadata
613
597
  } = this;
614
-
615
598
  if (onClick) {
616
599
  const cardEvent = {
617
600
  event,
@@ -620,7 +603,6 @@ export class CardBase extends Component {
620
603
  onClick(cardEvent, analyticsEvent);
621
604
  }
622
605
  });
623
-
624
606
  _defineProperty(this, "onMouseEnter", event => {
625
607
  const {
626
608
  onMouseEnter
@@ -628,7 +610,6 @@ export class CardBase extends Component {
628
610
  const {
629
611
  metadata
630
612
  } = this;
631
-
632
613
  if (onMouseEnter) {
633
614
  const cardEvent = {
634
615
  event,
@@ -637,54 +618,23 @@ export class CardBase extends Component {
637
618
  onMouseEnter(cardEvent);
638
619
  }
639
620
  });
640
-
641
621
  let _status = 'loading';
642
-
643
622
  let _cardPreview;
644
-
645
623
  let _error;
646
-
647
624
  const {
648
625
  identifier: _identifier,
649
626
  resizeMode: _resizeMode,
650
627
  ssr: _ssr,
651
628
  mediaClient: _mediaClient
652
629
  } = this.props;
653
-
654
630
  if (isFileIdentifier(_identifier)) {
655
631
  const {
656
632
  id
657
633
  } = _identifier;
658
634
  const fileImageMode = imageResizeModeToFileImageMode(_resizeMode);
659
635
  _cardPreview = getCardPreviewFromCache(id, fileImageMode);
660
-
661
636
  if (!_cardPreview && _ssr) {
662
- var _this$ssrData, _this$ssrData2;
663
-
664
- this.ssrData = getSSRData(_identifier);
665
-
666
- if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
667
- this.ssrReliability.server = {
668
- status: 'fail',
669
- ...this.ssrData.error
670
- };
671
- }
672
-
673
- if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
674
- try {
675
- _cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, this.getImageURLParams(_identifier), this.getMediaBlobUrlAttrs(_identifier));
676
- } catch (e) {
677
- this.ssrReliability[_ssr] = {
678
- status: 'fail',
679
- ...extractErrorInfo(e)
680
- };
681
- }
682
- } else {
683
- _cardPreview = {
684
- dataURI: this.ssrData.dataURI,
685
- source: 'ssr-data'
686
- };
687
- }
637
+ _cardPreview = this.getSSRPreview(_ssr, _identifier, _mediaClient);
688
638
  }
689
639
  } else if (isExternalImageIdentifier(_identifier)) {
690
640
  this.fireCommencedEvent();
@@ -697,14 +647,13 @@ export class CardBase extends Component {
697
647
  orientation: 1,
698
648
  source: 'external'
699
649
  };
700
- } // If cardPreview is available from local cache or external, `isCardVisible`
650
+ }
651
+
652
+ // If cardPreview is available from local cache or external, `isCardVisible`
701
653
  // should be true to avoid flickers during re-mount of the component
702
654
  // should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
703
655
  // outside the viewport
704
-
705
-
706
656
  const _isCardVisible = !this.props.isLazy || !!_cardPreview && !isSSRPreview(_cardPreview);
707
-
708
657
  this.state = {
709
658
  status: _status,
710
659
  isCardVisible: _isCardVisible,
@@ -714,13 +663,37 @@ export class CardBase extends Component {
714
663
  cardRef: null,
715
664
  isBannedLocalPreview: false,
716
665
  previewDidRender: false,
717
- error: _error
666
+ error: _error,
667
+ wasResolvedUpfrontPreview: false
718
668
  };
719
669
  }
720
-
670
+ getSSRPreview(ssr, identifier, mediaClient) {
671
+ var _this$ssrData, _this$ssrData2;
672
+ this.ssrData = getSSRData(identifier);
673
+ if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
674
+ this.ssrReliability.server = {
675
+ status: 'fail',
676
+ ...this.ssrData.error
677
+ };
678
+ }
679
+ if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
680
+ try {
681
+ return getSSRCardPreview(ssr, mediaClient, identifier.id, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
682
+ } catch (e) {
683
+ this.ssrReliability[ssr] = {
684
+ status: 'fail',
685
+ ...extractErrorInfo(e)
686
+ };
687
+ }
688
+ } else {
689
+ return {
690
+ dataURI: this.ssrData.dataURI,
691
+ source: 'ssr-data'
692
+ };
693
+ }
694
+ }
721
695
  componentDidMount() {
722
696
  var _getDocument;
723
-
724
697
  this.hasBeenMounted = true;
725
698
  const {
726
699
  isCardVisible,
@@ -731,34 +704,31 @@ export class CardBase extends Component {
731
704
  ssr,
732
705
  dimensions
733
706
  } = this.props;
734
-
735
707
  if (isCardVisible && isFileIdentifier(identifier)) {
736
708
  this.updateStateForIdentifier(identifier);
709
+ if (!cardPreview) {
710
+ this.resolveUpfrontPreview(identifier);
711
+ }
737
712
  }
738
-
739
713
  if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
740
714
  var _this$ssrData3;
741
-
742
715
  if (isSSRClientPreview(cardPreview)) {
743
716
  // Since the SSR preview brings the token in the query params,
744
717
  // We need to fetch the remote preview to be able to cache it,
745
718
  this.setCacheSSRPreview(identifier);
746
719
  }
747
-
748
720
  if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
749
721
  // If dimensions from Server have changed and are bigger,
750
722
  // we need to refetch
751
723
  this.refetchSSRPreview(identifier);
752
724
  }
753
- } // we add a listener for each of the cards on the page
725
+ }
726
+ // we add a listener for each of the cards on the page
754
727
  // and then check if the triggered listener is from the card
755
728
  // that contains a div in current window.getSelection()
756
729
  // won't work in IE11
757
-
758
-
759
730
  (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.addEventListener('copy', this.fireCopiedEvent);
760
731
  }
761
-
762
732
  componentDidUpdate(prevProps, prevState) {
763
733
  const {
764
734
  mediaClient: prevMediaClient,
@@ -784,14 +754,26 @@ export class CardBase extends Component {
784
754
  fileState,
785
755
  isBannedLocalPreview,
786
756
  previewDidRender,
787
- isPlayingFile
757
+ isPlayingFile,
758
+ wasResolvedUpfrontPreview
788
759
  } = this.state;
789
760
  const isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
761
+ /**
762
+ * Variable turnedVisible should only be true when media card
763
+ * was invisible in the previous state and is visible in the current one
764
+ *
765
+ * prevIsCardVisible | isCardVisible | turnedVisible
766
+ * ----------------------------------------------------
767
+ * false | false | false
768
+ * false | true | true
769
+ * true | true | false
770
+ * true | false | false (unreachable case)
771
+ * ----------------------------------------------------
772
+ */
790
773
  const turnedVisible = !prevIsCardVisible && isCardVisible;
791
774
  const isNewMediaClient = prevMediaClient !== mediaClient;
792
775
  const fileImageMode = imageResizeModeToFileImageMode(resizeMode);
793
776
  this.updateFileStateFlag(fileState);
794
-
795
777
  if (isExternalImageIdentifier(identifier) && isDifferent) {
796
778
  this.fireCommencedEvent();
797
779
  const {
@@ -807,20 +789,19 @@ export class CardBase extends Component {
807
789
  isCardVisible: true
808
790
  });
809
791
  }
810
-
811
792
  if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
812
793
  this.updateStateForIdentifier(identifier);
813
794
  }
814
-
815
795
  if (this.state.status !== prevState.status) {
816
796
  this.fireOperationalEvent();
817
-
818
797
  if (this.state.status === 'complete' || this.fileAttributes.fileMediatype === 'video' && !!cardPreview && this.state.status === 'processing') {
819
798
  this.fireScreenEvent();
820
799
  }
821
800
  }
822
-
823
- if (isFileIdentifier(identifier) && fileState && shouldResolvePreview({
801
+ if (isFileIdentifier(identifier) && turnedVisible && !cardPreview && !wasResolvedUpfrontPreview) {
802
+ // This is a one-off call, only meant to happen when turnedVisible = true (only once in the component's lifecycle)
803
+ this.resolveUpfrontPreview(identifier);
804
+ } else if (isFileIdentifier(identifier) && fileState && shouldResolvePreview({
824
805
  status,
825
806
  fileState,
826
807
  prevDimensions,
@@ -829,64 +810,55 @@ export class CardBase extends Component {
829
810
  fileImageMode,
830
811
  featureFlags,
831
812
  hasCardPreview: !!cardPreview,
832
- isBannedLocalPreview
813
+ isBannedLocalPreview,
814
+ wasResolvedUpfrontPreview
833
815
  })) {
834
816
  this.resolvePreview(identifier, fileState);
835
817
  }
836
-
837
818
  if (turnedVisible && this.props.ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
838
819
  // Since the SSR preview brings the token in the query params,
839
820
  // We need to fetch the remote preview to be able to cache it,
840
821
  this.setCacheSSRPreview(identifier);
841
822
  }
842
-
843
- if (previewDidRender && // We should't complete if status is uploading
823
+ if (previewDidRender &&
824
+ // We should't complete if status is uploading
844
825
  ['loading-preview', 'processing'].includes(status)) {
845
826
  this.safeSetState({
846
827
  status: 'complete'
847
828
  });
848
829
  this.unsubscribe();
849
830
  }
850
-
851
831
  const isVideo = this.fileAttributes.fileMediatype === 'video';
852
832
  const videoAvailableToPlay = fileState && isProcessedFileState(fileState);
853
-
854
833
  if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && videoAvailableToPlay && getMediaFeatureFlag('timestampOnVideo', this.props.featureFlags)) {
855
834
  this.setState({
856
835
  isPlayingFile: true
857
836
  });
858
837
  }
859
838
  }
860
-
861
839
  componentWillUnmount() {
862
840
  var _getDocument2;
863
-
864
841
  this.hasBeenMounted = false;
865
842
  this.unsubscribe();
866
843
  (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.removeEventListener('copy', this.fireCopiedEvent);
867
844
  }
868
-
869
845
  updateStateForIdentifier(identifier) {
870
846
  this.fireCommencedEvent();
871
847
  this.subscribeInternalFile(identifier);
872
848
  }
873
-
874
849
  updateFileStateFlag(fileState) {
875
850
  if (!fileState) {
876
851
  return;
877
852
  }
878
-
879
853
  const {
880
854
  status
881
855
  } = fileState;
882
-
883
856
  if (status === 'processing') {
884
857
  this.fileStateFlags.wasStatusProcessing = true;
885
858
  } else if (status === 'uploading') {
886
859
  this.fileStateFlags.wasStatusUploading = true;
887
860
  }
888
861
  }
889
-
890
862
  subscribeInternalFile(identifier) {
891
863
  const {
892
864
  mediaClient
@@ -921,7 +893,6 @@ export class CardBase extends Component {
921
893
  }
922
894
  });
923
895
  }
924
-
925
896
  get requestedDimensions() {
926
897
  const {
927
898
  dimensions
@@ -934,19 +905,14 @@ export class CardBase extends Component {
934
905
  element
935
906
  });
936
907
  }
937
-
938
908
  get metadata() {
939
909
  var _this$state;
940
-
941
910
  return getFileDetails(this.props.identifier, (_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.fileState);
942
911
  }
943
-
944
912
  get fileAttributes() {
945
913
  var _this$state2, _this$state2$fileStat;
946
-
947
914
  return getFileAttributes(this.metadata, (_this$state2 = this.state) === null || _this$state2 === void 0 ? void 0 : (_this$state2$fileStat = _this$state2.fileState) === null || _this$state2$fileStat === void 0 ? void 0 : _this$state2$fileStat.status);
948
915
  }
949
-
950
916
  fireOperationalEvent() {
951
917
  const {
952
918
  status,
@@ -959,7 +925,6 @@ export class CardBase extends Component {
959
925
  createAnalyticsEvent && fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error, this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
960
926
  completeUfoExperience(this.internalOccurrenceKey, status, this.fileAttributes, this.fileStateFlags, this.ssrReliability, error);
961
927
  }
962
-
963
928
  fireCommencedEvent() {
964
929
  this.timeElapsedTillCommenced = performance.now();
965
930
  const {
@@ -972,7 +937,6 @@ export class CardBase extends Component {
972
937
  }, this.traceContext);
973
938
  startUfoExperience(this.internalOccurrenceKey);
974
939
  }
975
-
976
940
  get actions() {
977
941
  const {
978
942
  actions = [],
@@ -985,7 +949,6 @@ export class CardBase extends Component {
985
949
  const {
986
950
  metadata
987
951
  } = this;
988
-
989
952
  if (isFileIdentifier(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
990
953
  const downloadAction = {
991
954
  label: 'Download',
@@ -999,7 +962,6 @@ export class CardBase extends Component {
999
962
  return actions;
1000
963
  }
1001
964
  }
1002
-
1003
965
  render() {
1004
966
  const {
1005
967
  isPlayingFile,
@@ -1010,9 +972,7 @@ export class CardBase extends Component {
1010
972
  locale: "en"
1011
973
  }, innerContent);
1012
974
  }
1013
-
1014
975
  }
1015
-
1016
976
  _defineProperty(CardBase, "defaultProps", {
1017
977
  appearance: 'auto',
1018
978
  resizeMode: 'crop',
@@ -1021,7 +981,6 @@ _defineProperty(CardBase, "defaultProps", {
1021
981
  // Media Feature Flag defaults are defined in @atlaskit/media-common
1022
982
  featureFlags: {}
1023
983
  });
1024
-
1025
984
  export const Card = withMediaAnalyticsContext({
1026
985
  packageVersion,
1027
986
  packageName,