@atlaskit/media-card 72.1.0 → 73.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/cjs/actions.js +2 -2
  3. package/dist/cjs/errors.js +11 -7
  4. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  5. package/dist/cjs/files/cardImageView/index.js +52 -42
  6. package/dist/cjs/files/cardImageView/styled.js +1 -1
  7. package/dist/cjs/index.js +8 -8
  8. package/dist/cjs/root/card/cardAnalytics.js +2 -2
  9. package/dist/cjs/root/card/cardState.js +2 -2
  10. package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
  11. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
  12. package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
  13. package/dist/cjs/root/card/getCardPreview/index.js +18 -9
  14. package/dist/cjs/root/card/getCardStatus.js +1 -1
  15. package/dist/cjs/root/card/index.js +279 -159
  16. package/dist/cjs/root/cardView.js +130 -118
  17. package/dist/cjs/root/inline/loader.js +45 -14
  18. package/dist/cjs/root/inline/mediaInlineCard.js +24 -9
  19. package/dist/cjs/root/inlinePlayer.js +80 -25
  20. package/dist/cjs/root/styled.js +7 -3
  21. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  22. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  23. package/dist/cjs/root/ui/common.js +1 -1
  24. package/dist/cjs/root/ui/iconMessage/index.js +5 -3
  25. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  26. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
  27. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +4 -2
  28. package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
  29. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  30. package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
  31. package/dist/cjs/root/ui/progressBar/styled.js +7 -6
  32. package/dist/cjs/root/ui/styled.js +6 -6
  33. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  34. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
  35. package/dist/cjs/root/ui/titleBox/styled.js +1 -1
  36. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  37. package/dist/cjs/styles/index.js +25 -23
  38. package/dist/cjs/styles/mixins.js +1 -1
  39. package/dist/cjs/types.js +10 -1
  40. package/dist/cjs/utils/analytics.js +24 -7
  41. package/dist/cjs/utils/breakpoint.js +1 -1
  42. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
  43. package/dist/cjs/utils/cardActions/index.js +10 -10
  44. package/dist/cjs/utils/cardActions/styled.js +1 -1
  45. package/dist/cjs/utils/cardDimensions.js +1 -1
  46. package/dist/cjs/utils/dimensionComparer.js +7 -13
  47. package/dist/cjs/utils/getErrorMessage.js +2 -2
  48. package/dist/cjs/utils/getMediaCardCursor.js +29 -0
  49. package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
  50. package/dist/cjs/utils/globalScope/globalScope.js +94 -0
  51. package/dist/cjs/utils/globalScope/index.js +39 -0
  52. package/dist/cjs/utils/globalScope/types.js +5 -0
  53. package/dist/cjs/utils/index.js +46 -46
  54. package/dist/cjs/utils/lightCards/styled.js +1 -1
  55. package/dist/cjs/utils/objectURLCache.js +1 -1
  56. package/dist/cjs/utils/printScript.js +44 -0
  57. package/dist/cjs/utils/viewportDetector.js +49 -22
  58. package/dist/cjs/version.json +1 -1
  59. package/dist/es2019/files/cardImageView/index.js +19 -5
  60. package/dist/es2019/root/card/cardAnalytics.js +1 -1
  61. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
  62. package/dist/es2019/root/card/getCardPreview/index.js +1 -0
  63. package/dist/es2019/root/card/index.js +150 -49
  64. package/dist/es2019/root/cardView.js +40 -30
  65. package/dist/es2019/root/inline/loader.js +15 -4
  66. package/dist/es2019/root/inline/mediaInlineCard.js +23 -8
  67. package/dist/es2019/root/inlinePlayer.js +59 -5
  68. package/dist/es2019/root/styled.js +2 -1
  69. package/dist/es2019/root/ui/iconMessage/index.js +3 -2
  70. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
  71. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
  72. package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
  73. package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
  74. package/dist/es2019/root/ui/progressBar/styled.js +6 -4
  75. package/dist/es2019/root/ui/styled.js +5 -5
  76. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
  77. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  78. package/dist/es2019/types.js +7 -1
  79. package/dist/es2019/utils/analytics.js +8 -3
  80. package/dist/es2019/utils/dimensionComparer.js +6 -13
  81. package/dist/es2019/utils/getErrorMessage.js +1 -1
  82. package/dist/es2019/utils/getMediaCardCursor.js +19 -0
  83. package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
  84. package/dist/es2019/utils/globalScope/globalScope.js +62 -0
  85. package/dist/es2019/utils/globalScope/index.js +2 -0
  86. package/dist/es2019/utils/globalScope/types.js +1 -0
  87. package/dist/es2019/utils/printScript.js +19 -0
  88. package/dist/es2019/utils/viewportDetector.js +48 -18
  89. package/dist/es2019/version.json +1 -1
  90. package/dist/esm/actions.js +2 -2
  91. package/dist/esm/errors.js +6 -5
  92. package/dist/esm/files/cardImageView/index.js +53 -41
  93. package/dist/esm/root/card/cardAnalytics.js +1 -1
  94. package/dist/esm/root/card/cardState.js +2 -2
  95. package/dist/esm/root/card/getCardPreview/cache.js +3 -2
  96. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
  97. package/dist/esm/root/card/getCardPreview/index.js +5 -2
  98. package/dist/esm/root/card/index.js +266 -145
  99. package/dist/esm/root/cardView.js +128 -117
  100. package/dist/esm/root/inline/loader.js +46 -14
  101. package/dist/esm/root/inline/mediaInlineCard.js +23 -8
  102. package/dist/esm/root/inlinePlayer.js +77 -24
  103. package/dist/esm/root/styled.js +3 -2
  104. package/dist/esm/root/ui/iconMessage/index.js +3 -2
  105. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
  106. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
  107. package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
  108. package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
  109. package/dist/esm/root/ui/progressBar/styled.js +6 -5
  110. package/dist/esm/root/ui/styled.js +5 -5
  111. package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
  112. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  113. package/dist/esm/types.js +7 -1
  114. package/dist/esm/utils/analytics.js +17 -6
  115. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
  116. package/dist/esm/utils/dimensionComparer.js +8 -13
  117. package/dist/esm/utils/getErrorMessage.js +1 -1
  118. package/dist/esm/utils/getMediaCardCursor.js +19 -0
  119. package/dist/esm/utils/globalScope/getSSRData.js +10 -0
  120. package/dist/esm/utils/globalScope/globalScope.js +69 -0
  121. package/dist/esm/utils/globalScope/index.js +2 -0
  122. package/dist/esm/utils/globalScope/types.js +1 -0
  123. package/dist/esm/utils/printScript.js +30 -0
  124. package/dist/esm/utils/viewportDetector.js +48 -21
  125. package/dist/esm/version.json +1 -1
  126. package/dist/types/errors.d.ts +1 -1
  127. package/dist/types/files/cardImageView/index.d.ts +6 -2
  128. package/dist/types/index.d.ts +1 -0
  129. package/dist/types/root/card/cardLoader.d.ts +2 -2
  130. package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
  131. package/dist/types/root/card/index.d.ts +10 -9
  132. package/dist/types/root/cardView.d.ts +10 -8
  133. package/dist/types/root/inline/loader.d.ts +2 -0
  134. package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
  135. package/dist/types/root/inlinePlayer.d.ts +10 -1
  136. package/dist/types/root/styled.d.ts +1 -0
  137. package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
  138. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
  139. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -0
  140. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  141. package/dist/types/root/ui/progressBar/progressBar.d.ts +3 -1
  142. package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
  143. package/dist/types/root/ui/styled.d.ts +2 -1
  144. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  145. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -2
  146. package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -9
  147. package/dist/types/types.d.ts +6 -1
  148. package/dist/types/utils/analytics.d.ts +6 -0
  149. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  150. package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
  151. package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
  152. package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
  153. package/dist/types/utils/globalScope/index.d.ts +4 -0
  154. package/dist/types/utils/globalScope/types.d.ts +8 -0
  155. package/dist/types/utils/printScript.d.ts +2 -0
  156. package/dist/types/utils/viewportDetector.d.ts +13 -5
  157. package/package.json +14 -16
  158. package/dist/cjs/utils/lazyContent/index.js +0 -56
  159. package/dist/cjs/utils/lazyContent/styled.js +0 -23
  160. package/dist/es2019/utils/lazyContent/index.js +0 -18
  161. package/dist/es2019/utils/lazyContent/styled.js +0 -12
  162. package/dist/esm/utils/lazyContent/index.js +0 -41
  163. package/dist/esm/utils/lazyContent/styled.js +0 -14
  164. package/dist/types/utils/lazyContent/index.d.ts +0 -11
  165. package/dist/types/utils/lazyContent/styled.d.ts +0 -5
@@ -1 +1,7 @@
1
- export {};
1
+ export let MediaCardCursor;
2
+
3
+ (function (MediaCardCursor) {
4
+ MediaCardCursor["Action"] = "pointer";
5
+ MediaCardCursor["NoAction"] = "default";
6
+ MediaCardCursor["NotReady"] = "wait";
7
+ })(MediaCardCursor || (MediaCardCursor = {}));
@@ -81,6 +81,13 @@ export const getRenderErrorRequestMetadata = error => {
81
81
  return error.secondaryError.metadata;
82
82
  }
83
83
  };
84
+ export const extractErrorInfo = error => {
85
+ return {
86
+ failReason: getRenderErrorFailReason(error),
87
+ error: getRenderErrorErrorReason(error),
88
+ errorDetail: getRenderErrorErrorDetail(error)
89
+ };
90
+ };
84
91
  export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
85
92
  eventType: 'operational',
86
93
  action: 'failed',
@@ -89,9 +96,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
89
96
  fileAttributes,
90
97
  performanceAttributes,
91
98
  status: 'fail',
92
- failReason: getRenderErrorFailReason(error),
93
- error: getRenderErrorErrorReason(error),
94
- errorDetail: getRenderErrorErrorDetail(error),
99
+ ...extractErrorInfo(error),
95
100
  request: getRenderErrorRequestMetadata(error)
96
101
  }
97
102
  });
@@ -1,23 +1,16 @@
1
1
  import { isValidPercentageUnit } from './isValidPercentageUnit';
2
2
  import { containsPixelUnit } from './containsPixelUnit';
3
+
4
+ const isPixelEquivalent = dimension => typeof dimension === 'number' || containsPixelUnit(`${dimension}`);
5
+
3
6
  export const canCompareDimension = (current, next) => {
4
7
  if (!current || !next) {
5
8
  return false;
6
9
  }
7
10
 
8
- if (isValidPercentageUnit(current) && isValidPercentageUnit(next)) {
9
- return true;
10
- }
11
-
12
- if (containsPixelUnit(`${current}`) && containsPixelUnit(`${next}`)) {
13
- return true;
14
- }
15
-
16
- if (typeof current === 'number' && typeof next === 'number') {
17
- return true;
18
- }
19
-
20
- return false;
11
+ const bothPixelEquivalent = isPixelEquivalent(current) && isPixelEquivalent(next);
12
+ const bothPercentage = isValidPercentageUnit(current) && isValidPercentageUnit(next);
13
+ return bothPixelEquivalent || bothPercentage;
21
14
  };
22
15
  export const isBigger = (current, next) => {
23
16
  if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { FormattedMessage } from 'react-intl';
2
+ import { FormattedMessage } from 'react-intl-next';
3
3
  import { messages } from '@atlaskit/media-ui';
4
4
  export const getErrorMessage = status => status === 'error' && /*#__PURE__*/React.createElement(FormattedMessage, messages.failed_to_load);
@@ -0,0 +1,19 @@
1
+ import { MediaCardCursor } from '../types';
2
+ export const getMediaCardCursor = (useInlinePlayer, useMediaViewer, isErrorStatus, hasCardPreview, mediaType) => {
3
+ // If error status or no action is requested = NoAction
4
+ if (isErrorStatus || !useInlinePlayer && !useMediaViewer) {
5
+ return MediaCardCursor.NoAction;
6
+ }
7
+
8
+ if (!mediaType && (useInlinePlayer || useInlinePlayer && useMediaViewer)) {
9
+ return MediaCardCursor.NotReady;
10
+ } else if (mediaType === 'video' && hasCardPreview && useInlinePlayer) {
11
+ return MediaCardCursor.Action;
12
+ }
13
+
14
+ if (useMediaViewer) {
15
+ return MediaCardCursor.Action;
16
+ }
17
+
18
+ return MediaCardCursor.NoAction;
19
+ };
@@ -0,0 +1,10 @@
1
+ import { getMediaCardSSR, getKey } from './globalScope';
2
+ export const getSSRData = identifier => {
3
+ const mediaCardSsr = getMediaCardSSR();
4
+
5
+ if (!mediaCardSsr) {
6
+ return;
7
+ }
8
+
9
+ return mediaCardSsr[getKey(identifier)];
10
+ };
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { printFunctionCall, printScript } from '../printScript';
3
+ // ----- WARNING -----
4
+ // This is a very sensitive fraction of code.
5
+ // Any changes to this file must be tested directly in product before merging.
6
+ // The scripts printed here might differ from what we observe in our internal tests
7
+ // due to minimification, for example.
8
+ export const GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
9
+ export const GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
10
+ export function getMediaGlobalScope(globalScope = window) {
11
+ // Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
12
+ const namespace = '__MEDIA_INTERNAL';
13
+
14
+ if (!globalScope[namespace]) {
15
+ globalScope[namespace] = {};
16
+ }
17
+
18
+ return globalScope[namespace];
19
+ }
20
+ export function getMediaCardSSR(globalScope = window) {
21
+ const globalMedia = getMediaGlobalScope(globalScope); // Must match GLOBAL_MEDIA_CARD_SSR. Can't reference the constant from here.
22
+
23
+ const key = 'mediaCardSsr';
24
+
25
+ if (!globalMedia[key]) {
26
+ globalMedia[key] = {};
27
+ }
28
+
29
+ return globalMedia[key];
30
+ }
31
+
32
+ const dashed = param => param ? `-${param}` : '';
33
+
34
+ export const getKey = ({
35
+ id,
36
+ collectionName,
37
+ occurrenceKey
38
+ }) => `${id}${dashed(collectionName)}${dashed(occurrenceKey)}`;
39
+ export const storeDataURI = (key, dataURI, dimensions, error, globalScope = window) => {
40
+ const mediaCardSsr = getMediaCardSSR(globalScope);
41
+ mediaCardSsr[key] = {
42
+ dataURI,
43
+ dimensions,
44
+ error
45
+ };
46
+ };
47
+
48
+ const generateScript = (identifier, dataURI, dimensions, error) => {
49
+ const functionCall = printFunctionCall(storeDataURI, getKey(identifier), dataURI, dimensions, error);
50
+ return printScript([getMediaCardSSR.toString(), getMediaGlobalScope.toString(), functionCall]);
51
+ };
52
+
53
+ export const StoreSSRDataScript = ({
54
+ dataURI,
55
+ identifier,
56
+ dimensions,
57
+ error
58
+ }) => /*#__PURE__*/React.createElement("script", {
59
+ dangerouslySetInnerHTML: {
60
+ __html: generateScript(identifier, dataURI, dimensions, error)
61
+ }
62
+ });
@@ -0,0 +1,2 @@
1
+ export { StoreSSRDataScript, GLOBAL_MEDIA_NAMESPACE, GLOBAL_MEDIA_CARD_SSR, getKey } from './globalScope';
2
+ export { getSSRData } from './getSSRData';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ const printParam = param => {
2
+ if (typeof param === 'string') {
3
+ return `'${param}'`;
4
+ } else if (typeof param === 'object') {
5
+ return JSON.stringify(param);
6
+ } else if (param === undefined) {
7
+ return 'undefined';
8
+ }
9
+
10
+ return param;
11
+ };
12
+
13
+ const printParams = args => args.map(arg => printParam(arg)).join(',');
14
+
15
+ export const printFunctionCall = (fn, ...args) => `(${fn.toString()})(${printParams(args)});`;
16
+ export const printScript = statements => `(function(){
17
+ ${statements.join(';')}
18
+ })();
19
+ `;
@@ -1,5 +1,25 @@
1
- import React, { useEffect } from 'react';
2
- import { LazyContent } from './lazyContent';
1
+ import React, { useEffect, forwardRef } from 'react';
2
+ /**
3
+ * As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
4
+ * Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
5
+ */
6
+
7
+ export const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
8
+
9
+ export const ViewportAnchor = /*#__PURE__*/forwardRef((props, ref) => {
10
+ if (typeof IntersectionObserver === 'undefined') {
11
+ return null;
12
+ }
13
+
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ ref: ref,
16
+ className: "media-card-viewport-anchor",
17
+ style: {
18
+ position: 'absolute',
19
+ top: `${props.offsetTop}px`
20
+ }
21
+ });
22
+ });
3
23
 
4
24
  const createIntersectionObserverCallback = onVisible => (entries, observer) => {
5
25
  for (let entry of entries) {
@@ -11,31 +31,41 @@ const createIntersectionObserverCallback = onVisible => (entries, observer) => {
11
31
  }
12
32
  };
13
33
 
14
- const Observer = ({
34
+ const ViewportObserver = ({
15
35
  onVisible,
36
+ cardEl,
16
37
  children,
17
- targetRef
38
+ preAnchorRef,
39
+ postAnchorRef
18
40
  }) => {
19
41
  useEffect(() => {
20
42
  // IntersectionObserver uses root and target elements to detect intersections, defaulting root to the viewport
21
43
  const intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible));
22
- targetRef && intersectionObserver.observe(targetRef);
44
+ (preAnchorRef === null || preAnchorRef === void 0 ? void 0 : preAnchorRef.current) && intersectionObserver.observe(preAnchorRef.current);
45
+ (postAnchorRef === null || postAnchorRef === void 0 ? void 0 : postAnchorRef.current) && intersectionObserver.observe(postAnchorRef.current);
46
+ cardEl && intersectionObserver.observe(cardEl);
23
47
  return () => {
24
48
  intersectionObserver.disconnect();
25
49
  };
26
- }, [targetRef, onVisible]);
50
+ }, [cardEl, preAnchorRef, postAnchorRef, onVisible]);
27
51
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
28
52
  };
29
53
 
30
- export const createViewportDetector = isIntersectionObserverSupported => ({
31
- children,
32
- targetRef,
33
- onVisible
34
- }) => isIntersectionObserverSupported ? /*#__PURE__*/React.createElement(Observer, {
35
- targetRef: targetRef,
36
- onVisible: onVisible
37
- }, children) : /*#__PURE__*/React.createElement(LazyContent, {
38
- placeholder: /*#__PURE__*/React.createElement(React.Fragment, null, children),
39
- onRender: onVisible
40
- }, children);
41
- export const ViewportDetector = createViewportDetector(typeof IntersectionObserver !== 'undefined');
54
+ export const ViewportDetector = ({
55
+ cardEl,
56
+ preAnchorRef,
57
+ postAnchorRef,
58
+ onVisible,
59
+ children
60
+ }) => {
61
+ if (typeof IntersectionObserver === 'undefined') {
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
63
+ }
64
+
65
+ return /*#__PURE__*/React.createElement(ViewportObserver, {
66
+ cardEl: cardEl,
67
+ preAnchorRef: preAnchorRef,
68
+ postAnchorRef: postAnchorRef,
69
+ onVisible: onVisible
70
+ }, children);
71
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "72.1.0",
3
+ "version": "73.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ 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
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ 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
6
 
7
7
  export function attachDetailsToActions(actions, details) {
8
8
  return actions.map(function (action) {
@@ -1,3 +1,4 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
@@ -32,7 +33,7 @@ export var MediaCardError = /*#__PURE__*/function (_Error) {
32
33
  return _this;
33
34
  }
34
35
 
35
- return MediaCardError;
36
+ return _createClass(MediaCardError);
36
37
  }( /*#__PURE__*/_wrapNativeSuper(Error));
37
38
  export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
38
39
  _inherits(LocalPreviewError, _MediaCardError);
@@ -50,7 +51,7 @@ export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
50
51
  return _this2;
51
52
  }
52
53
 
53
- return LocalPreviewError;
54
+ return _createClass(LocalPreviewError);
54
55
  }(MediaCardError);
55
56
  export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
56
57
  _inherits(RemotePreviewError, _MediaCardError2);
@@ -68,7 +69,7 @@ export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
68
69
  return _this3;
69
70
  }
70
71
 
71
- return RemotePreviewError;
72
+ return _createClass(RemotePreviewError);
72
73
  }(MediaCardError);
73
74
  export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
74
75
  _inherits(SsrPreviewError, _MediaCardError3);
@@ -86,7 +87,7 @@ export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
86
87
  return _this4;
87
88
  }
88
89
 
89
- return SsrPreviewError;
90
+ return _createClass(SsrPreviewError);
90
91
  }(MediaCardError);
91
92
  export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
92
93
  switch (source) {
@@ -121,7 +122,7 @@ export var ImageLoadError = /*#__PURE__*/function (_MediaCardError4) {
121
122
  return _super5.call(this, getImageLoadPrimaryReason(source));
122
123
  }
123
124
 
124
- return ImageLoadError;
125
+ return _createClass(ImageLoadError);
125
126
  }(MediaCardError);
126
127
  export function isMediaCardError(err) {
127
128
  return err instanceof MediaCardError;
@@ -156,18 +156,30 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
156
156
  })));
157
157
  });
158
158
 
159
- _defineProperty(_assertThisInitialized(_this), "renderMediaImage", function () {
159
+ _defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
160
160
  var _this$props6 = _this.props,
161
- status = _this$props6.status,
162
- mediaItemType = _this$props6.mediaItemType,
163
- dataURI = _this$props6.dataURI,
164
- mediaType = _this$props6.mediaType,
165
- mimeType = _this$props6.mimeType,
166
- previewOrientation = _this$props6.previewOrientation,
167
- onDisplayImage = _this$props6.onDisplayImage,
168
- alt = _this$props6.alt,
169
161
  onImageLoad = _this$props6.onImageLoad,
170
- onImageError = _this$props6.onImageError;
162
+ cardPreview = _this$props6.cardPreview;
163
+ onImageLoad && onImageLoad(cardPreview);
164
+ });
165
+
166
+ _defineProperty(_assertThisInitialized(_this), "onImageError", function () {
167
+ var _this$props7 = _this.props,
168
+ onImageError = _this$props7.onImageError,
169
+ cardPreview = _this$props7.cardPreview;
170
+ onImageError && onImageError(cardPreview);
171
+ });
172
+
173
+ _defineProperty(_assertThisInitialized(_this), "renderMediaImage", function () {
174
+ var _this$props8 = _this.props,
175
+ status = _this$props8.status,
176
+ mediaItemType = _this$props8.mediaItemType,
177
+ dataURI = _this$props8.dataURI,
178
+ mediaType = _this$props8.mediaType,
179
+ mimeType = _this$props8.mimeType,
180
+ previewOrientation = _this$props8.previewOrientation,
181
+ onDisplayImage = _this$props8.onDisplayImage,
182
+ alt = _this$props8.alt;
171
183
 
172
184
  if (!shouldDisplayImageThumbnail(status, mediaItemType, dataURI, mediaType, mimeType)) {
173
185
  return null;
@@ -184,17 +196,17 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
184
196
  crop: _this.isCropped,
185
197
  stretch: _this.isStretched,
186
198
  previewOrientation: previewOrientation,
187
- onImageLoad: onImageLoad,
188
- onImageError: onImageError
199
+ onImageLoad: _this.onImageLoad,
200
+ onImageError: _this.onImageError
189
201
  });
190
202
  });
191
203
 
192
204
  _defineProperty(_assertThisInitialized(_this), "renderProgressBar", function () {
193
- var _this$props7 = _this.props,
194
- mediaName = _this$props7.mediaName,
195
- progress = _this$props7.progress,
196
- actions = _this$props7.actions,
197
- status = _this$props7.status;
205
+ var _this$props9 = _this.props,
206
+ mediaName = _this$props9.mediaName,
207
+ progress = _this$props9.progress,
208
+ actions = _this$props9.actions,
209
+ status = _this$props9.status;
198
210
 
199
211
  if (status !== 'uploading') {
200
212
  return null;
@@ -213,10 +225,10 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
213
225
  });
214
226
 
215
227
  _defineProperty(_assertThisInitialized(_this), "renderSuccessCardContents", function () {
216
- var _this$props8 = _this.props,
217
- disableOverlay = _this$props8.disableOverlay,
218
- selectable = _this$props8.selectable,
219
- status = _this$props8.status;
228
+ var _this$props10 = _this.props,
229
+ disableOverlay = _this$props10.disableOverlay,
230
+ selectable = _this$props10.selectable,
231
+ status = _this$props10.status;
220
232
  var overlay = null;
221
233
 
222
234
  if (!disableOverlay) {
@@ -237,15 +249,15 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
237
249
  });
238
250
 
239
251
  _defineProperty(_assertThisInitialized(_this), "renderSuccessCardOverlay", function () {
240
- var _this$props9 = _this.props,
241
- status = _this$props9.status,
242
- mediaName = _this$props9.mediaName,
243
- mediaType = _this$props9.mediaType,
244
- fileSize = _this$props9.fileSize,
245
- dataURI = _this$props9.dataURI,
246
- selectable = _this$props9.selectable,
247
- selected = _this$props9.selected,
248
- actions = _this$props9.actions;
252
+ var _this$props11 = _this.props,
253
+ status = _this$props11.status,
254
+ mediaName = _this$props11.mediaName,
255
+ mediaType = _this$props11.mediaType,
256
+ fileSize = _this$props11.fileSize,
257
+ dataURI = _this$props11.dataURI,
258
+ selectable = _this$props11.selectable,
259
+ selected = _this$props11.selected,
260
+ actions = _this$props11.actions;
249
261
  var isPersistent = mediaType === 'doc' || !dataURI;
250
262
  return /*#__PURE__*/React.createElement(CardOverlay, {
251
263
  cardStatus: status,
@@ -265,14 +277,14 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
265
277
  _createClass(FileCardImageView, [{
266
278
  key: "render",
267
279
  value: function render() {
268
- var _this$props10 = this.props,
269
- disableOverlay = _this$props10.disableOverlay,
270
- selectable = _this$props10.selectable,
271
- selected = _this$props10.selected,
272
- mediaType = _this$props10.mediaType,
273
- progress = _this$props10.progress,
274
- status = _this$props10.status,
275
- mediaName = _this$props10.mediaName;
280
+ var _this$props12 = this.props,
281
+ disableOverlay = _this$props12.disableOverlay,
282
+ selectable = _this$props12.selectable,
283
+ selected = _this$props12.selected,
284
+ mediaType = _this$props12.mediaType,
285
+ progress = _this$props12.progress,
286
+ status = _this$props12.status,
287
+ mediaName = _this$props12.mediaName;
276
288
  return /*#__PURE__*/React.createElement(Wrapper, {
277
289
  "data-testid": "media-file-card-view",
278
290
  "data-test-media-name": mediaName,
@@ -289,9 +301,9 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
289
301
  }, {
290
302
  key: "isFileCardImageReadyForDisplay",
291
303
  get: function get() {
292
- var _this$props11 = this.props,
293
- dataURI = _this$props11.dataURI,
294
- status = _this$props11.status;
304
+ var _this$props13 = this.props,
305
+ dataURI = _this$props13.dataURI,
306
+ status = _this$props13.status;
295
307
  return !!dataURI || !['loading', 'processing', 'loading-preview'].includes(status);
296
308
  }
297
309
  }, {
@@ -1,5 +1,5 @@
1
1
  import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
2
- export var relevantFeatureFlagNames = ['newCardExperience', 'captions'];
2
+ export var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
3
3
  export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
4
4
  var fireEvent = function fireEvent(payload) {
5
5
  return fireMediaCardEvent(payload, createAnalyticsEvent);
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ 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
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ 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
6
 
7
7
  import { isErrorFileState } from '@atlaskit/media-client';
8
8
  import { MediaCardError } from '../../errors';
@@ -1,3 +1,4 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import { createObjectURLCache } from '../../../utils/objectURLCache';
@@ -6,7 +7,7 @@ import { createObjectURLCache } from '../../../utils/objectURLCache';
6
7
  export var getCacheKey = function getCacheKey(id, dimensions) {
7
8
  return [id, dimensions.height, dimensions.width].join('-');
8
9
  };
9
- export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
10
+ export var CardPreviewCacheImpl = /*#__PURE__*/_createClass(function CardPreviewCacheImpl(previewCache) {
10
11
  var _this = this;
11
12
 
12
13
  _classCallCheck(this, CardPreviewCacheImpl);
@@ -29,5 +30,5 @@ export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
29
30
  });
30
31
 
31
32
  this.previewCache = previewCache;
32
- };
33
+ });
33
34
  export default new CardPreviewCacheImpl(createObjectURLCache());
@@ -31,5 +31,8 @@ export var isPreviewableStatus = function isPreviewableStatus(cardStatus, _ref3)
31
31
  var isPreviewable = _ref3.isPreviewable,
32
32
  hasPreview = _ref3.hasPreview,
33
33
  isSupportedByBrowser = _ref3.isSupportedByBrowser;
34
- return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' || cardStatus === 'processing' && isSupportedByBrowser);
34
+ return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' || // For Video, we can have local or remote preview while processing.
35
+ // Then, we only want to show the thumbnail if the file is supported by the browser,
36
+ // this way we prevent playing unsupported videos that are not procesed
37
+ cardStatus === 'processing' && isSupportedByBrowser);
35
38
  };
@@ -2,9 +2,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ 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; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ 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; }
8
8
 
9
9
  import { isPreviewableFileState, addFileAttrsToUrl } from '@atlaskit/media-client';
10
10
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
@@ -208,6 +208,9 @@ export var isSSRClientPreview = function isSSRClientPreview(preview) {
208
208
  var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
209
209
  return ssrClientSources.includes(preview.source);
210
210
  };
211
+ export var isSSRDataPreview = function isSSRDataPreview(preview) {
212
+ return preview.source === 'ssr-data';
213
+ };
211
214
  export var fetchAndCacheRemotePreview = /*#__PURE__*/function () {
212
215
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaClient, id, dimensions, params, mediaBlobUrlAttrs) {
213
216
  var remotePreview;