@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
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.Card = exports.CardBase = void 0;
10
+ exports.CardBase = exports.Card = void 0;
11
11
 
12
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
13
 
@@ -41,11 +41,11 @@ var _mediaCommon = require("@atlaskit/media-common");
41
41
 
42
42
  var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
43
43
 
44
- var _mediaClient = require("@atlaskit/media-client");
44
+ var _mediaClient2 = require("@atlaskit/media-client");
45
45
 
46
46
  var _mediaViewer = require("@atlaskit/media-viewer");
47
47
 
48
- var _reactIntl = require("react-intl");
48
+ var _reactIntlNext = require("react-intl-next");
49
49
 
50
50
  var _cardView = require("../cardView");
51
51
 
@@ -67,15 +67,21 @@ var _cardAnalytics = require("./cardAnalytics");
67
67
 
68
68
  var _document = _interopRequireDefault(require("../../utils/document"));
69
69
 
70
+ var _globalScope = require("../../utils/globalScope");
71
+
70
72
  var _cardState = require("./cardState");
71
73
 
74
+ var _dimensionComparer = require("../../utils/dimensionComparer");
75
+
76
+ var _getMediaCardCursor = require("../../utils/getMediaCardCursor");
77
+
72
78
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
73
79
 
74
80
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
75
81
 
76
- 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; }
82
+ 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; }
77
83
 
78
- 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) { (0, _defineProperty2.default)(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; }
84
+ 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) { (0, _defineProperty2.default)(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; }
79
85
 
80
86
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
81
87
 
@@ -94,12 +100,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
94
100
  (0, _classCallCheck2.default)(this, CardBase);
95
101
  _this = _super.call(this, props);
96
102
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasBeenMounted", false);
103
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPreAnchorRef", /*#__PURE__*/(0, _react.createRef)());
104
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPostAnchorRef", /*#__PURE__*/(0, _react.createRef)());
97
105
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeElapsedTillCommenced", performance.now());
98
106
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getImageURLParams", function (_ref) {
99
107
  var collection = _ref.collectionName;
100
108
  return _objectSpread(_objectSpread({
101
109
  collection: collection,
102
- mode: (0, _mediaClient.imageResizeModeToFileImageMode)(_this.props.resizeMode)
110
+ mode: (0, _mediaClient2.imageResizeModeToFileImageMode)(_this.props.resizeMode)
103
111
  }, _this.requestedDimensions), {}, {
104
112
  allowAnimated: true
105
113
  });
@@ -141,7 +149,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
141
149
  dimensions: dimensions,
142
150
  onLocalPreviewError: _this.fireLocalPreviewErrorEvent,
143
151
  filePreview: isBannedLocalPreview ? undefined : (0, _getCardPreview.getFilePreviewFromFileState)(fileState),
144
- isRemotePreviewReady: (0, _mediaClient.isImageRepresentationReady)(fileState),
152
+ isRemotePreviewReady: (0, _mediaClient2.isImageRepresentationReady)(fileState),
145
153
  imageUrlParams: _this.getImageURLParams(identifier),
146
154
  mediaBlobUrlAttrs: _this.getMediaBlobUrlAttrs(identifier, fileState)
147
155
  };
@@ -157,26 +165,18 @@ var CardBase = /*#__PURE__*/function (_Component) {
157
165
  // https://product-fabric.atlassian.net/browse/MEX-1071
158
166
  });
159
167
  });
160
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveSSRPreview", function (identifier, ssr) {
161
- var mediaClient = _this.props.mediaClient;
168
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "refetchSSRPreview", /*#__PURE__*/function () {
169
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier) {
170
+ var _this$props4, mediaClient, _this$props4$dimensio, dimensions, cardPreview;
162
171
 
163
- try {
164
- return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
165
- } catch (e) {// TODO: log SSR reliability 'failed'
166
- // https://product-fabric.atlassian.net/browse/MEX-770
167
- }
168
- });
169
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolvePreview", /*#__PURE__*/function () {
170
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier, fileState) {
171
- var params, cardPreview, wrappedError;
172
172
  return _regenerator.default.wrap(function _callee$(_context) {
173
173
  while (1) {
174
174
  switch (_context.prev = _context.next) {
175
175
  case 0:
176
- _context.prev = 0;
177
- params = _this.getCardPreviewParams(identifier, fileState);
176
+ _this$props4 = _this.props, mediaClient = _this$props4.mediaClient, _this$props4$dimensio = _this$props4.dimensions, dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
177
+ _context.prev = 1;
178
178
  _context.next = 4;
179
- return (0, _getCardPreview.getCardPreview)(params);
179
+ return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
180
180
 
181
181
  case 4:
182
182
  cardPreview = _context.sent;
@@ -185,13 +185,51 @@ var CardBase = /*#__PURE__*/function (_Component) {
185
185
  cardPreview: cardPreview
186
186
  });
187
187
 
188
- _context.next = 12;
188
+ _context.next = 10;
189
189
  break;
190
190
 
191
191
  case 8:
192
192
  _context.prev = 8;
193
- _context.t0 = _context["catch"](0);
194
- wrappedError = (0, _errors.ensureMediaCardError)('preview-fetch', _context.t0); // If remote preview fails, we set status 'error'
193
+ _context.t0 = _context["catch"](1);
194
+
195
+ case 10:
196
+ case "end":
197
+ return _context.stop();
198
+ }
199
+ }
200
+ }, _callee, null, [[1, 8]]);
201
+ }));
202
+
203
+ return function (_x) {
204
+ return _ref2.apply(this, arguments);
205
+ };
206
+ }());
207
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolvePreview", /*#__PURE__*/function () {
208
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(identifier, fileState) {
209
+ var params, cardPreview, wrappedError;
210
+ return _regenerator.default.wrap(function _callee2$(_context2) {
211
+ while (1) {
212
+ switch (_context2.prev = _context2.next) {
213
+ case 0:
214
+ _context2.prev = 0;
215
+ params = _this.getCardPreviewParams(identifier, fileState);
216
+ _context2.next = 4;
217
+ return (0, _getCardPreview.getCardPreview)(params);
218
+
219
+ case 4:
220
+ cardPreview = _context2.sent;
221
+
222
+ _this.safeSetState({
223
+ cardPreview: cardPreview
224
+ });
225
+
226
+ _context2.next = 12;
227
+ break;
228
+
229
+ case 8:
230
+ _context2.prev = 8;
231
+ _context2.t0 = _context2["catch"](0);
232
+ wrappedError = (0, _errors.ensureMediaCardError)('preview-fetch', _context2.t0); // If remote preview fails, we set status 'error'
195
233
  // If local preview fails (i.e, no remote preview available),
196
234
  // we can stay in the same status until there is a remote preview available
197
235
  // If it's any other error we set status 'error'
@@ -209,14 +247,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
209
247
 
210
248
  case 12:
211
249
  case "end":
212
- return _context.stop();
250
+ return _context2.stop();
213
251
  }
214
252
  }
215
- }, _callee, null, [[0, 8]]);
253
+ }, _callee2, null, [[0, 8]]);
216
254
  }));
217
255
 
218
- return function (_x, _x2) {
219
- return _ref2.apply(this, arguments);
256
+ return function (_x2, _x3) {
257
+ return _ref3.apply(this, arguments);
220
258
  };
221
259
  }());
222
260
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPerformanceAttributes", function () {
@@ -232,11 +270,16 @@ var CardBase = /*#__PURE__*/function (_Component) {
232
270
  }
233
271
  };
234
272
  });
235
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageError", function () {
236
- var cardPreview = _this.state.cardPreview;
273
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageError", function (cardPreview) {
274
+ var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this error
275
+
276
+ if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
277
+ return;
278
+ }
279
+
237
280
  var error = new _errors.ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
238
281
  var isLocal = cardPreview && (0, _getCardPreview.isLocalPreview)(cardPreview);
239
- var isSSR = cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview);
282
+ var isSSR = cardPreview && ((0, _getCardPreview.isSSRClientPreview)(cardPreview) || (0, _getCardPreview.isSSRDataPreview)(cardPreview));
240
283
 
241
284
  if (isLocal || isSSR) {
242
285
  var updateState = {
@@ -253,11 +296,11 @@ var CardBase = /*#__PURE__*/function (_Component) {
253
296
  // https://product-fabric.atlassian.net/browse/MEX-770
254
297
  }
255
298
 
256
- var _this$props4 = _this.props,
257
- identifier = _this$props4.identifier,
258
- _this$props4$dimensio = _this$props4.dimensions,
259
- dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
260
- (0, _mediaClient.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
299
+ var _this$props5 = _this.props,
300
+ identifier = _this$props5.identifier,
301
+ _this$props5$dimensio = _this$props5.dimensions,
302
+ dimensions = _this$props5$dimensio === void 0 ? {} : _this$props5$dimensio;
303
+ (0, _mediaClient2.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
261
304
 
262
305
  _this.safeSetState(updateState);
263
306
  } else {
@@ -267,7 +310,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
267
310
  });
268
311
  }
269
312
  });
270
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageLoad", function () {
313
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageLoad", function (cardPreview) {
314
+ var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this callback
315
+
316
+ if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
317
+ return;
318
+ }
319
+
271
320
  _this.safeSetState({
272
321
  previewDidRender: true
273
322
  });
@@ -307,10 +356,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
307
356
  }
308
357
  });
309
358
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardViewClick", function (event, analyticsEvent) {
310
- var _this$props5 = _this.props,
311
- identifier = _this$props5.identifier,
312
- useInlinePlayer = _this$props5.useInlinePlayer,
313
- shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
359
+ var _this$props6 = _this.props,
360
+ identifier = _this$props6.identifier,
361
+ useInlinePlayer = _this$props6.useInlinePlayer,
362
+ shouldOpenMediaViewer = _this$props6.shouldOpenMediaViewer;
314
363
  var cardPreview = _this.state.cardPreview;
315
364
 
316
365
  var _assertThisInitialize2 = (0, _assertThisInitialized2.default)(_this),
@@ -326,12 +375,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
326
375
 
327
376
  if (useInlinePlayer && isVideo && !!cardPreview) {
328
377
  _this.setState({
329
- isPlayingFile: true
378
+ isPlayingFile: true,
379
+ shouldAutoplay: true
330
380
  });
331
381
  } else if (shouldOpenMediaViewer) {
332
382
  var mediaViewerSelectedItem;
333
383
 
334
- if ((0, _mediaClient.isFileIdentifier)(identifier)) {
384
+ if ((0, _mediaClient2.isFileIdentifier)(identifier)) {
335
385
  mediaViewerSelectedItem = {
336
386
  id: identifier.id,
337
387
  mediaItemType: 'file',
@@ -362,23 +412,28 @@ var CardBase = /*#__PURE__*/function (_Component) {
362
412
  });
363
413
  });
364
414
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderInlinePlayer", function () {
365
- var _this$props6 = _this.props,
366
- identifier = _this$props6.identifier,
367
- mediaClient = _this$props6.mediaClient,
368
- dimensions = _this$props6.dimensions,
369
- selected = _this$props6.selected,
370
- testId = _this$props6.testId,
371
- originalDimensions = _this$props6.originalDimensions;
415
+ var _this$props7 = _this.props,
416
+ identifier = _this$props7.identifier,
417
+ mediaClient = _this$props7.mediaClient,
418
+ dimensions = _this$props7.dimensions,
419
+ selected = _this$props7.selected,
420
+ testId = _this$props7.testId,
421
+ originalDimensions = _this$props7.originalDimensions;
422
+ var _this$state = _this.state,
423
+ shouldAutoplay = _this$state.shouldAutoplay,
424
+ cardPreview = _this$state.cardPreview;
372
425
  return /*#__PURE__*/_react.default.createElement(_inlinePlayer.InlinePlayer, {
373
426
  mediaClient: mediaClient,
374
427
  dimensions: dimensions,
375
428
  originalDimensions: originalDimensions,
376
429
  identifier: identifier,
430
+ autoplay: !!shouldAutoplay,
377
431
  onError: _this.onInlinePlayerError,
378
432
  onClick: _this.onClick,
379
433
  selected: selected,
380
434
  ref: _this.setRef,
381
- testId: testId
435
+ testId: testId,
436
+ cardPreview: cardPreview
382
437
  });
383
438
  });
384
439
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMediaViewerClose", function () {
@@ -390,10 +445,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
390
445
  var identifier = _this.props.identifier;
391
446
  var payloadPart;
392
447
 
393
- if ((0, _mediaClient.isFileIdentifier)(identifier)) {
448
+ if ((0, _mediaClient2.isFileIdentifier)(identifier)) {
394
449
  payloadPart = {
395
450
  fileId: identifier.id,
396
- isUserCollection: identifier.collectionName === _mediaClient.RECENTS_COLLECTION
451
+ isUserCollection: identifier.collectionName === _mediaClient2.RECENTS_COLLECTION
397
452
  };
398
453
  } else {
399
454
  payloadPart = {
@@ -402,24 +457,24 @@ var CardBase = /*#__PURE__*/function (_Component) {
402
457
  };
403
458
  }
404
459
 
405
- _mediaClient.globalMediaEventEmitter.emit('media-viewed', _objectSpread({
460
+ _mediaClient2.globalMediaEventEmitter.emit('media-viewed', _objectSpread({
406
461
  viewingLevel: 'minimal'
407
462
  }, payloadPart));
408
463
  });
409
464
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderMediaViewer", function () {
410
465
  var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
411
- var _this$props7 = _this.props,
412
- mediaClient = _this$props7.mediaClient,
413
- identifier = _this$props7.identifier,
414
- mediaViewerDataSource = _this$props7.mediaViewerDataSource,
415
- contextId = _this$props7.contextId,
416
- featureFlags = _this$props7.featureFlags;
466
+ var _this$props8 = _this.props,
467
+ mediaClient = _this$props8.mediaClient,
468
+ identifier = _this$props8.identifier,
469
+ mediaViewerDataSource = _this$props8.mediaViewerDataSource,
470
+ contextId = _this$props8.contextId,
471
+ featureFlags = _this$props8.featureFlags;
417
472
 
418
473
  if (!mediaViewerSelectedItem) {
419
474
  return;
420
475
  }
421
476
 
422
- var collectionName = (0, _mediaClient.isFileIdentifier)(identifier) ? identifier.collectionName || '' : '';
477
+ var collectionName = (0, _mediaClient2.isFileIdentifier)(identifier) ? identifier.collectionName || '' : '';
423
478
  var dataSource = mediaViewerDataSource || {
424
479
  list: []
425
480
  };
@@ -434,35 +489,31 @@ var CardBase = /*#__PURE__*/function (_Component) {
434
489
  }), document.body);
435
490
  });
436
491
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCard", function () {
437
- var _this$props8 = _this.props,
438
- identifier = _this$props8.identifier,
439
- isLazy = _this$props8.isLazy,
440
- appearance = _this$props8.appearance,
441
- resizeMode = _this$props8.resizeMode,
442
- dimensions = _this$props8.dimensions,
443
- selectable = _this$props8.selectable,
444
- selected = _this$props8.selected,
445
- disableOverlay = _this$props8.disableOverlay,
446
- alt = _this$props8.alt,
447
- testId = _this$props8.testId,
448
- featureFlags = _this$props8.featureFlags,
449
- titleBoxBgColor = _this$props8.titleBoxBgColor,
450
- titleBoxIcon = _this$props8.titleBoxIcon,
451
- ssr = _this$props8.ssr;
492
+ var _this$props9 = _this.props,
493
+ identifier = _this$props9.identifier,
494
+ isLazy = _this$props9.isLazy,
495
+ appearance = _this$props9.appearance,
496
+ resizeMode = _this$props9.resizeMode,
497
+ dimensions = _this$props9.dimensions,
498
+ selectable = _this$props9.selectable,
499
+ selected = _this$props9.selected,
500
+ disableOverlay = _this$props9.disableOverlay,
501
+ alt = _this$props9.alt,
502
+ testId = _this$props9.testId,
503
+ featureFlags = _this$props9.featureFlags,
504
+ titleBoxBgColor = _this$props9.titleBoxBgColor,
505
+ titleBoxIcon = _this$props9.titleBoxIcon,
506
+ ssr = _this$props9.ssr,
507
+ useInlinePlayer = _this$props9.useInlinePlayer,
508
+ shouldOpenMediaViewer = _this$props9.shouldOpenMediaViewer;
452
509
  var mediaItemType = identifier.mediaItemType;
453
- var _this$state = _this.state,
454
- status = _this$state.status,
455
- progress = _this$state.progress,
456
- _this$state$cardPrevi = _this$state.cardPreview;
457
- _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {
458
- dataURI: undefined,
459
- orientation: 1
460
- } : _this$state$cardPrevi;
461
- var dataURI = _this$state$cardPrevi.dataURI,
462
- orientation = _this$state$cardPrevi.orientation,
463
- error = _this$state.error,
464
- cardRef = _this$state.cardRef,
465
- isCardVisible = _this$state.isCardVisible;
510
+ var _this$state2 = _this.state,
511
+ status = _this$state2.status,
512
+ progress = _this$state2.progress,
513
+ cardPreview = _this$state2.cardPreview,
514
+ error = _this$state2.error,
515
+ cardRef = _this$state2.cardRef,
516
+ isCardVisible = _this$state2.isCardVisible;
466
517
 
467
518
  var _assertThisInitialize3 = (0, _assertThisInitialized2.default)(_this),
468
519
  metadata = _assertThisInitialize3.metadata;
@@ -478,13 +529,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
478
529
  var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
479
530
 
480
531
  var forceSyncDisplay = !!ssr;
532
+ var mediaCardCursor = (0, _getMediaCardCursor.getMediaCardCursor)(!!useInlinePlayer, !!shouldOpenMediaViewer, status === 'error' || status === 'failed-processing', !!_this.state.cardPreview, metadata.mediaType);
481
533
 
482
534
  var card = /*#__PURE__*/_react.default.createElement(_cardView.CardView, {
483
535
  status: status,
484
536
  error: error,
485
537
  mediaItemType: mediaItemType,
486
538
  metadata: metadata,
487
- dataURI: dataURI,
539
+ cardPreview: cardPreview,
488
540
  alt: alt,
489
541
  appearance: appearance,
490
542
  resizeMode: resizeMode,
@@ -497,7 +549,6 @@ var CardBase = /*#__PURE__*/function (_Component) {
497
549
  disableOverlay: disableOverlay,
498
550
  progress: progress,
499
551
  onDisplayImage: onDisplayImage,
500
- previewOrientation: orientation,
501
552
  innerRef: _this.setRef,
502
553
  testId: testId,
503
554
  featureFlags: featureFlags,
@@ -506,13 +557,39 @@ var CardBase = /*#__PURE__*/function (_Component) {
506
557
  onImageError: _this.onImageError,
507
558
  onImageLoad: _this.onImageLoad,
508
559
  nativeLazyLoad: nativeLazyLoad,
509
- forceSyncDisplay: forceSyncDisplay
560
+ forceSyncDisplay: forceSyncDisplay,
561
+ mediaCardCursor: mediaCardCursor
510
562
  });
511
563
 
512
564
  return isLazy ? /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportDetector, {
513
- targetRef: cardRef,
565
+ cardEl: cardRef,
566
+ preAnchorRef: _this.viewportPreAnchorRef,
567
+ postAnchorRef: _this.viewportPostAnchorRef,
514
568
  onVisible: _this.onCardInViewport
515
- }, card) : card;
569
+ }, /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportAnchor, {
570
+ ref: _this.viewportPreAnchorRef,
571
+ offsetTop: -_viewportDetector.ABS_VIEWPORT_ANCHOR_OFFSET_TOP
572
+ }), card, /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportAnchor, {
573
+ ref: _this.viewportPostAnchorRef,
574
+ offsetTop: _viewportDetector.ABS_VIEWPORT_ANCHOR_OFFSET_TOP
575
+ })) : card;
576
+ });
577
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "storeSSRData", function () {
578
+ var _this$props10 = _this.props,
579
+ ssr = _this$props10.ssr,
580
+ identifier = _this$props10.identifier;
581
+ var _this$state3 = _this.state,
582
+ _this$state3$cardPrev = _this$state3.cardPreview;
583
+ _this$state3$cardPrev = _this$state3$cardPrev === void 0 ? {} : _this$state3$cardPrev;
584
+ var dataURI = _this$state3$cardPrev.dataURI,
585
+ error = _this$state3.error;
586
+ var ssrDataError = !!error ? (0, _analytics.extractErrorInfo)(error) : undefined;
587
+ return (0, _mediaClient2.isFileIdentifier)(identifier) && ssr === 'server' && /*#__PURE__*/_react.default.createElement(_globalScope.StoreSSRDataScript, {
588
+ identifier: identifier,
589
+ dataURI: dataURI,
590
+ dimensions: _this.requestedDimensions,
591
+ error: ssrDataError
592
+ });
516
593
  });
517
594
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardInViewport", function () {
518
595
  _this.setState({
@@ -551,22 +628,42 @@ var CardBase = /*#__PURE__*/function (_Component) {
551
628
 
552
629
  var _cardPreview;
553
630
 
554
- var _this$props9 = _this.props,
555
- _identifier = _this$props9.identifier,
556
- _this$props9$dimensio = _this$props9.dimensions,
557
- _dimensions = _this$props9$dimensio === void 0 ? {} : _this$props9$dimensio,
558
- _ssr = _this$props9.ssr;
631
+ var _error;
632
+
633
+ var _this$props11 = _this.props,
634
+ _identifier = _this$props11.identifier,
635
+ _this$props11$dimensi = _this$props11.dimensions,
636
+ _dimensions = _this$props11$dimensi === void 0 ? {} : _this$props11$dimensi,
637
+ _ssr = _this$props11.ssr,
638
+ _mediaClient = _this$props11.mediaClient;
559
639
 
560
- if ((0, _mediaClient.isFileIdentifier)(_identifier)) {
640
+ if ((0, _mediaClient2.isFileIdentifier)(_identifier)) {
561
641
  var id = _identifier.id;
562
642
  _cardPreview = (0, _getCardPreview.getCardPreviewFromCache)(id, _dimensions);
563
643
 
564
644
  if (!_cardPreview && _ssr) {
565
- _this.fireCommencedEvent();
566
-
567
- _cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
645
+ var _this$ssrData;
646
+
647
+ _this.ssrData = (0, _globalScope.getSSRData)(_identifier);
648
+
649
+ if (_ssr === 'server' || !((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.dataURI)) {
650
+ try {
651
+ _cardPreview = (0, _getCardPreview.getSSRCardPreview)(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
652
+ } catch (e) {
653
+ // TODO: handle error in client MEX-770
654
+ // If we fail building the dataURI in server, we store the error in the state
655
+ // to be later stored in global scope and logged in client.
656
+ // We don't set the status = error to fall back to the spinner icon
657
+ _error = _ssr === 'server' ? e : undefined;
658
+ }
659
+ } else {
660
+ _cardPreview = {
661
+ dataURI: _this.ssrData.dataURI,
662
+ source: 'ssr-data'
663
+ };
664
+ }
568
665
  }
569
- } else if ((0, _mediaClient.isExternalImageIdentifier)(_identifier)) {
666
+ } else if ((0, _mediaClient2.isExternalImageIdentifier)(_identifier)) {
570
667
  _this.fireCommencedEvent();
571
668
 
572
669
  _status = 'loading-preview';
@@ -588,10 +685,12 @@ var CardBase = /*#__PURE__*/function (_Component) {
588
685
  status: _status,
589
686
  isCardVisible: _isCardVisible,
590
687
  isPlayingFile: false,
688
+ shouldAutoplay: false,
591
689
  cardPreview: _cardPreview,
592
690
  cardRef: null,
593
691
  isBannedLocalPreview: false,
594
- previewDidRender: false
692
+ previewDidRender: false,
693
+ error: _error
595
694
  };
596
695
  return _this;
597
696
  }
@@ -600,21 +699,32 @@ var CardBase = /*#__PURE__*/function (_Component) {
600
699
  key: "componentDidMount",
601
700
  value: function componentDidMount() {
602
701
  this.hasBeenMounted = true;
603
- var _this$state2 = this.state,
604
- isCardVisible = _this$state2.isCardVisible,
605
- cardPreview = _this$state2.cardPreview;
606
- var _this$props10 = this.props,
607
- identifier = _this$props10.identifier,
608
- ssr = _this$props10.ssr;
609
-
610
- if (isCardVisible && (0, _mediaClient.isFileIdentifier)(identifier)) {
702
+ var _this$state4 = this.state,
703
+ isCardVisible = _this$state4.isCardVisible,
704
+ cardPreview = _this$state4.cardPreview;
705
+ var _this$props12 = this.props,
706
+ identifier = _this$props12.identifier,
707
+ ssr = _this$props12.ssr,
708
+ dimensions = _this$props12.dimensions;
709
+
710
+ if (isCardVisible && (0, _mediaClient2.isFileIdentifier)(identifier)) {
611
711
  this.updateStateForIdentifier(identifier);
612
712
  }
613
713
 
614
- if (isCardVisible && !!ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
615
- // Since the SSR preview brings the token in the query params,
616
- // We need to fetch the remote preview to be able to cache it,
617
- this.setCacheSSRPreview(identifier);
714
+ if (isCardVisible && !!ssr && !!cardPreview && (0, _mediaClient2.isFileIdentifier)(identifier)) {
715
+ var _this$ssrData2;
716
+
717
+ if ((0, _getCardPreview.isSSRClientPreview)(cardPreview)) {
718
+ // Since the SSR preview brings the token in the query params,
719
+ // We need to fetch the remote preview to be able to cache it,
720
+ this.setCacheSSRPreview(identifier);
721
+ }
722
+
723
+ if ((0, _getCardPreview.isSSRDataPreview)(cardPreview) && (0, _dimensionComparer.isBigger)((_this$ssrData2 = this.ssrData) === null || _this$ssrData2 === void 0 ? void 0 : _this$ssrData2.dimensions, dimensions)) {
724
+ // If dimensions from Server have changed and are bigger,
725
+ // we need to refetch
726
+ this.refetchSSRPreview(identifier);
727
+ }
618
728
  } // we add a listener for each of the cards on the page
619
729
  // and then check if the triggered listener is from the card
620
730
  // that contains a div in current window.getSelection()
@@ -630,23 +740,26 @@ var CardBase = /*#__PURE__*/function (_Component) {
630
740
  prevIdentifier = prevProps.identifier,
631
741
  prevDimensions = prevProps.dimensions;
632
742
  var prevIsCardVisible = prevState.isCardVisible;
633
- var _this$props11 = this.props,
634
- mediaClient = _this$props11.mediaClient,
635
- identifier = _this$props11.identifier,
636
- dimensions = _this$props11.dimensions,
637
- featureFlags = _this$props11.featureFlags;
638
- var _this$state3 = this.state,
639
- isCardVisible = _this$state3.isCardVisible,
640
- cardPreview = _this$state3.cardPreview,
641
- status = _this$state3.status,
642
- fileState = _this$state3.fileState,
643
- isBannedLocalPreview = _this$state3.isBannedLocalPreview,
644
- previewDidRender = _this$state3.previewDidRender;
645
- var isDifferent = (0, _mediaClient.isDifferentIdentifier)(prevIdentifier, identifier);
743
+ var _this$props13 = this.props,
744
+ mediaClient = _this$props13.mediaClient,
745
+ identifier = _this$props13.identifier,
746
+ dimensions = _this$props13.dimensions,
747
+ featureFlags = _this$props13.featureFlags,
748
+ useInlinePlayer = _this$props13.useInlinePlayer,
749
+ disableOverlay = _this$props13.disableOverlay;
750
+ var _this$state5 = this.state,
751
+ isCardVisible = _this$state5.isCardVisible,
752
+ cardPreview = _this$state5.cardPreview,
753
+ status = _this$state5.status,
754
+ fileState = _this$state5.fileState,
755
+ isBannedLocalPreview = _this$state5.isBannedLocalPreview,
756
+ previewDidRender = _this$state5.previewDidRender,
757
+ isPlayingFile = _this$state5.isPlayingFile;
758
+ var isDifferent = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
646
759
  var turnedVisible = !prevIsCardVisible && isCardVisible;
647
760
  var isNewMediaClient = prevMediaClient !== mediaClient;
648
761
 
649
- if ((0, _mediaClient.isExternalImageIdentifier)(identifier) && isDifferent) {
762
+ if ((0, _mediaClient2.isExternalImageIdentifier)(identifier) && isDifferent) {
650
763
  this.fireCommencedEvent();
651
764
  var dataURI = identifier.dataURI;
652
765
  this.setState({
@@ -660,7 +773,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
660
773
  });
661
774
  }
662
775
 
663
- if ((0, _mediaClient.isFileIdentifier)(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
776
+ if ((0, _mediaClient2.isFileIdentifier)(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
664
777
  this.updateStateForIdentifier(identifier);
665
778
  }
666
779
 
@@ -672,7 +785,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
672
785
  }
673
786
  }
674
787
 
675
- if ((0, _mediaClient.isFileIdentifier)(identifier) && fileState && (0, _getCardPreview.shouldResolvePreview)({
788
+ if ((0, _mediaClient2.isFileIdentifier)(identifier) && fileState && (0, _getCardPreview.shouldResolvePreview)({
676
789
  status: status,
677
790
  fileState: fileState,
678
791
  dimensions: dimensions,
@@ -684,7 +797,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
684
797
  this.resolvePreview(identifier, fileState);
685
798
  }
686
799
 
687
- if (turnedVisible && this.props.ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
800
+ if (turnedVisible && this.props.ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient2.isFileIdentifier)(identifier)) {
688
801
  // Since the SSR preview brings the token in the query params,
689
802
  // We need to fetch the remote preview to be able to cache it,
690
803
  this.setCacheSSRPreview(identifier);
@@ -697,6 +810,15 @@ var CardBase = /*#__PURE__*/function (_Component) {
697
810
  });
698
811
  this.unsubscribe();
699
812
  }
813
+
814
+ var isVideo = this.fileAttributes.fileMediatype === 'video';
815
+ var videoAvailableToPlay = fileState && (0, _mediaClient2.isProcessedFileState)(fileState);
816
+
817
+ if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && videoAvailableToPlay && (0, _mediaCommon.getMediaFeatureFlag)('timestampOnVideo', this.props.featureFlags)) {
818
+ this.setState({
819
+ isPlayingFile: true
820
+ });
821
+ }
700
822
  }
701
823
  }, {
702
824
  key: "componentWillUnmount",
@@ -748,8 +870,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
748
870
  get: function get() {
749
871
  var dimensions = this.props.dimensions;
750
872
 
751
- var _ref3 = this.state || {},
752
- element = _ref3.cardRef;
873
+ var _ref4 = this.state || {},
874
+ element = _ref4.cardRef;
753
875
 
754
876
  return (0, _getDataURIDimension.getRequestedDimensions)({
755
877
  dimensions: dimensions,
@@ -759,23 +881,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
759
881
  }, {
760
882
  key: "metadata",
761
883
  get: function get() {
762
- var _this$state4;
884
+ var _this$state6;
763
885
 
764
- return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
886
+ return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
765
887
  }
766
888
  }, {
767
889
  key: "fileAttributes",
768
890
  get: function get() {
769
- var _this$state5, _this$state5$fileStat;
891
+ var _this$state7, _this$state7$fileStat;
770
892
 
771
- return (0, _analytics.getFileAttributes)(this.metadata, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : (_this$state5$fileStat = _this$state5.fileState) === null || _this$state5$fileStat === void 0 ? void 0 : _this$state5$fileStat.status);
893
+ return (0, _analytics.getFileAttributes)(this.metadata, (_this$state7 = this.state) === null || _this$state7 === void 0 ? void 0 : (_this$state7$fileStat = _this$state7.fileState) === null || _this$state7$fileStat === void 0 ? void 0 : _this$state7$fileStat.status);
772
894
  }
773
895
  }, {
774
896
  key: "fireOperationalEvent",
775
897
  value: function fireOperationalEvent() {
776
- var _this$state6 = this.state,
777
- status = _this$state6.status,
778
- error = _this$state6.error;
898
+ var _this$state8 = this.state,
899
+ status = _this$state8.status,
900
+ error = _this$state8.error;
779
901
  var createAnalyticsEvent = this.props.createAnalyticsEvent;
780
902
  createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
781
903
  }
@@ -795,15 +917,15 @@ var CardBase = /*#__PURE__*/function (_Component) {
795
917
  get: function get() {
796
918
  var _this3 = this;
797
919
 
798
- var _this$props12 = this.props,
799
- _this$props12$actions = _this$props12.actions,
800
- actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
801
- identifier = _this$props12.identifier,
802
- shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
920
+ var _this$props14 = this.props,
921
+ _this$props14$actions = _this$props14.actions,
922
+ actions = _this$props14$actions === void 0 ? [] : _this$props14$actions,
923
+ identifier = _this$props14.identifier,
924
+ shouldEnableDownloadButton = _this$props14.shouldEnableDownloadButton;
803
925
  var status = this.state.status;
804
926
  var metadata = this.metadata;
805
927
 
806
- if ((0, _mediaClient.isFileIdentifier)(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
928
+ if ((0, _mediaClient2.isFileIdentifier)(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
807
929
  var downloadAction = {
808
930
  label: 'Download',
809
931
  icon: /*#__PURE__*/_react.default.createElement(_download.default, {
@@ -821,13 +943,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
821
943
  }, {
822
944
  key: "render",
823
945
  value: function render() {
824
- var _this$state7 = this.state,
825
- isPlayingFile = _this$state7.isPlayingFile,
826
- mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
946
+ var _this$state9 = this.state,
947
+ isPlayingFile = _this$state9.isPlayingFile,
948
+ mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
827
949
 
828
- var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
950
+ var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
829
951
 
830
- return this.context.intl ? innerContent : /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
952
+ return this.props.intl ? innerContent : /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
831
953
  locale: "en"
832
954
  }, innerContent);
833
955
  }
@@ -844,10 +966,6 @@ exports.CardBase = CardBase;
844
966
  // Media Feature Flag defaults are defined in @atlaskit/media-common
845
967
  featureFlags: {}
846
968
  });
847
- (0, _defineProperty2.default)(CardBase, "contextTypes", {
848
- // Required to detect a parent IntlProvider
849
- intl: _reactIntl.intlShape
850
- });
851
969
  var Card = (0, _mediaCommon.withMediaAnalyticsContext)({
852
970
  packageVersion: _version.version,
853
971
  packageName: _version.name,
@@ -855,5 +973,7 @@ var Card = (0, _mediaCommon.withMediaAnalyticsContext)({
855
973
  component: 'mediaCard'
856
974
  }, {
857
975
  filterFeatureFlags: _cardAnalytics.relevantFeatureFlagNames
858
- })((0, _analyticsNext.withAnalyticsEvents)()(CardBase));
976
+ })((0, _analyticsNext.withAnalyticsEvents)()((0, _reactIntlNext.injectIntl)(CardBase, {
977
+ enforceContext: false
978
+ })));
859
979
  exports.Card = Card;