@atlaskit/media-card 73.1.0 → 73.3.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 (74) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cjs/files/cardImageView/index.js +51 -41
  3. package/dist/cjs/root/card/cardAnalytics.js +4 -4
  4. package/dist/cjs/root/card/getCardPreview/index.js +7 -1
  5. package/dist/cjs/root/card/index.js +301 -155
  6. package/dist/cjs/root/cardView.js +128 -118
  7. package/dist/cjs/root/inlinePlayer.js +4 -2
  8. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +17 -23
  9. package/dist/cjs/root/ui/styled.js +5 -5
  10. package/dist/cjs/types.js +10 -1
  11. package/dist/cjs/utils/analytics.js +32 -13
  12. package/dist/cjs/utils/dimensionComparer.js +7 -13
  13. package/dist/cjs/utils/getMediaCardCursor.js +29 -0
  14. package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
  15. package/dist/cjs/utils/globalScope/globalScope.js +94 -0
  16. package/dist/cjs/utils/globalScope/index.js +39 -0
  17. package/dist/cjs/utils/globalScope/types.js +5 -0
  18. package/dist/cjs/utils/printScript.js +44 -0
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/files/cardImageView/index.js +19 -5
  21. package/dist/es2019/root/card/cardAnalytics.js +4 -4
  22. package/dist/es2019/root/card/getCardPreview/index.js +1 -0
  23. package/dist/es2019/root/card/index.js +167 -40
  24. package/dist/es2019/root/cardView.js +41 -35
  25. package/dist/es2019/root/inlinePlayer.js +4 -2
  26. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +17 -19
  27. package/dist/es2019/root/ui/styled.js +4 -4
  28. package/dist/es2019/types.js +7 -1
  29. package/dist/es2019/utils/analytics.js +17 -9
  30. package/dist/es2019/utils/dimensionComparer.js +6 -13
  31. package/dist/es2019/utils/getMediaCardCursor.js +19 -0
  32. package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
  33. package/dist/es2019/utils/globalScope/globalScope.js +62 -0
  34. package/dist/es2019/utils/globalScope/index.js +2 -0
  35. package/dist/es2019/utils/globalScope/types.js +1 -0
  36. package/dist/es2019/utils/printScript.js +19 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/files/cardImageView/index.js +53 -41
  39. package/dist/esm/root/card/cardAnalytics.js +4 -4
  40. package/dist/esm/root/card/getCardPreview/index.js +3 -0
  41. package/dist/esm/root/card/index.js +284 -138
  42. package/dist/esm/root/cardView.js +127 -118
  43. package/dist/esm/root/inlinePlayer.js +4 -2
  44. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +17 -21
  45. package/dist/esm/root/ui/styled.js +5 -5
  46. package/dist/esm/types.js +7 -1
  47. package/dist/esm/utils/analytics.js +26 -12
  48. package/dist/esm/utils/dimensionComparer.js +8 -13
  49. package/dist/esm/utils/getMediaCardCursor.js +19 -0
  50. package/dist/esm/utils/globalScope/getSSRData.js +10 -0
  51. package/dist/esm/utils/globalScope/globalScope.js +69 -0
  52. package/dist/esm/utils/globalScope/index.js +2 -0
  53. package/dist/esm/utils/globalScope/types.js +1 -0
  54. package/dist/esm/utils/printScript.js +30 -0
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/__tests_external__/page-objects/MediaCard.d.ts +0 -1
  57. package/dist/types/errors.d.ts +1 -1
  58. package/dist/types/files/cardImageView/index.d.ts +6 -2
  59. package/dist/types/root/card/cardAnalytics.d.ts +2 -1
  60. package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
  61. package/dist/types/root/card/index.d.ts +5 -1
  62. package/dist/types/root/cardView.d.ts +8 -6
  63. package/dist/types/root/inlinePlayer.d.ts +3 -1
  64. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -14
  65. package/dist/types/root/ui/styled.d.ts +2 -1
  66. package/dist/types/types.d.ts +6 -1
  67. package/dist/types/utils/analytics.d.ts +27 -5
  68. package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
  69. package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
  70. package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
  71. package/dist/types/utils/globalScope/index.d.ts +4 -0
  72. package/dist/types/utils/globalScope/types.d.ts +8 -0
  73. package/dist/types/utils/printScript.d.ts +2 -0
  74. package/package.json +12 -12
@@ -29,16 +29,19 @@ import { injectIntl, IntlProvider } from 'react-intl-next';
29
29
  import { CardView } from '../cardView';
30
30
  import { ABS_VIEWPORT_ANCHOR_OFFSET_TOP, ViewportDetector, ViewportAnchor } from '../../utils/viewportDetector';
31
31
  import { getRequestedDimensions } from '../../utils/getDataURIDimension';
32
- import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, fetchAndCacheRemotePreview } from './getCardPreview';
32
+ import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, isSSRDataPreview, fetchAndCacheRemotePreview } from './getCardPreview';
33
33
  import { getFileDetails } from '../../utils/metadata';
34
34
  import { InlinePlayer } from '../inlinePlayer';
35
- import { getFileAttributes } from '../../utils/analytics';
35
+ import { getFileAttributes, extractErrorInfo } from '../../utils/analytics';
36
36
  import { isLocalPreviewError, MediaCardError, ensureMediaCardError, ImageLoadError } from '../../errors';
37
37
  import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, relevantFeatureFlagNames, fireCopiedEvent, fireScreenEvent } from './cardAnalytics';
38
38
  import getDocument from '../../utils/document';
39
+ import { StoreSSRDataScript, getSSRData } from '../../utils/globalScope';
39
40
  import { getCardStateFromFileState, createStateUpdater } from './cardState';
40
41
  import { isProcessedFileState } from '@atlaskit/media-client';
41
42
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
43
+ import { isBigger } from '../../utils/dimensionComparer';
44
+ import { getMediaCardCursor } from '../../utils/getMediaCardCursor';
42
45
  export var CardBase = /*#__PURE__*/function (_Component) {
43
46
  _inherits(CardBase, _Component);
44
47
 
@@ -59,6 +62,15 @@ export var CardBase = /*#__PURE__*/function (_Component) {
59
62
 
60
63
  _defineProperty(_assertThisInitialized(_this), "viewportPostAnchorRef", /*#__PURE__*/createRef());
61
64
 
65
+ _defineProperty(_assertThisInitialized(_this), "ssrReliability", {
66
+ server: {
67
+ status: 'unknown'
68
+ },
69
+ client: {
70
+ status: 'unknown'
71
+ }
72
+ });
73
+
62
74
  _defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
63
75
 
64
76
  _defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
@@ -127,27 +139,18 @@ export var CardBase = /*#__PURE__*/function (_Component) {
127
139
  });
128
140
  });
129
141
 
130
- _defineProperty(_assertThisInitialized(_this), "resolveSSRPreview", function (identifier, ssr) {
131
- var mediaClient = _this.props.mediaClient;
132
-
133
- try {
134
- return getSSRCardPreview(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
135
- } catch (e) {// TODO: log SSR reliability 'failed'
136
- // https://product-fabric.atlassian.net/browse/MEX-770
137
- }
138
- });
142
+ _defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
143
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
144
+ var _this$props4, mediaClient, _this$props4$dimensio, dimensions, cardPreview;
139
145
 
140
- _defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
141
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
142
- var params, cardPreview, wrappedError;
143
146
  return _regeneratorRuntime.wrap(function _callee$(_context) {
144
147
  while (1) {
145
148
  switch (_context.prev = _context.next) {
146
149
  case 0:
147
- _context.prev = 0;
148
- params = _this.getCardPreviewParams(identifier, fileState);
150
+ _this$props4 = _this.props, mediaClient = _this$props4.mediaClient, _this$props4$dimensio = _this$props4.dimensions, dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
151
+ _context.prev = 1;
149
152
  _context.next = 4;
150
- return getCardPreview(params);
153
+ return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
151
154
 
152
155
  case 4:
153
156
  cardPreview = _context.sent;
@@ -156,13 +159,52 @@ export var CardBase = /*#__PURE__*/function (_Component) {
156
159
  cardPreview: cardPreview
157
160
  });
158
161
 
159
- _context.next = 12;
162
+ _context.next = 10;
160
163
  break;
161
164
 
162
165
  case 8:
163
166
  _context.prev = 8;
164
- _context.t0 = _context["catch"](0);
165
- wrappedError = ensureMediaCardError('preview-fetch', _context.t0); // If remote preview fails, we set status 'error'
167
+ _context.t0 = _context["catch"](1);
168
+
169
+ case 10:
170
+ case "end":
171
+ return _context.stop();
172
+ }
173
+ }
174
+ }, _callee, null, [[1, 8]]);
175
+ }));
176
+
177
+ return function (_x) {
178
+ return _ref2.apply(this, arguments);
179
+ };
180
+ }());
181
+
182
+ _defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
183
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier, fileState) {
184
+ var params, cardPreview, wrappedError;
185
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
186
+ while (1) {
187
+ switch (_context2.prev = _context2.next) {
188
+ case 0:
189
+ _context2.prev = 0;
190
+ params = _this.getCardPreviewParams(identifier, fileState);
191
+ _context2.next = 4;
192
+ return getCardPreview(params);
193
+
194
+ case 4:
195
+ cardPreview = _context2.sent;
196
+
197
+ _this.safeSetState({
198
+ cardPreview: cardPreview
199
+ });
200
+
201
+ _context2.next = 12;
202
+ break;
203
+
204
+ case 8:
205
+ _context2.prev = 8;
206
+ _context2.t0 = _context2["catch"](0);
207
+ wrappedError = ensureMediaCardError('preview-fetch', _context2.t0); // If remote preview fails, we set status 'error'
166
208
  // If local preview fails (i.e, no remote preview available),
167
209
  // we can stay in the same status until there is a remote preview available
168
210
  // If it's any other error we set status 'error'
@@ -180,14 +222,14 @@ export var CardBase = /*#__PURE__*/function (_Component) {
180
222
 
181
223
  case 12:
182
224
  case "end":
183
- return _context.stop();
225
+ return _context2.stop();
184
226
  }
185
227
  }
186
- }, _callee, null, [[0, 8]]);
228
+ }, _callee2, null, [[0, 8]]);
187
229
  }));
188
230
 
189
- return function (_x, _x2) {
190
- return _ref2.apply(this, arguments);
231
+ return function (_x2, _x3) {
232
+ return _ref3.apply(this, arguments);
191
233
  };
192
234
  }());
193
235
 
@@ -205,11 +247,39 @@ export var CardBase = /*#__PURE__*/function (_Component) {
205
247
  };
206
248
  });
207
249
 
208
- _defineProperty(_assertThisInitialized(_this), "onImageError", function () {
209
- var cardPreview = _this.state.cardPreview;
250
+ _defineProperty(_assertThisInitialized(_this), "logSSRImageError", function (cardPreview) {
251
+ if (cardPreview) {
252
+ var failedSSRObject = _objectSpread({
253
+ status: 'fail'
254
+ }, extractErrorInfo(new ImageLoadError(cardPreview.source)));
255
+
256
+ if (isSSRClientPreview(cardPreview)) {
257
+ _this.ssrReliability.client = failedSSRObject;
258
+ }
259
+ /*
260
+ 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.
261
+ */
262
+
263
+
264
+ if (isSSRDataPreview(cardPreview)) {
265
+ _this.ssrReliability.server = failedSSRObject;
266
+ _this.ssrReliability.client = failedSSRObject;
267
+ }
268
+ }
269
+ });
270
+
271
+ _defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
272
+ _this.logSSRImageError(cardPreview);
273
+
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
+
210
280
  var error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
211
281
  var isLocal = cardPreview && isLocalPreview(cardPreview);
212
- var isSSR = cardPreview && isSSRClientPreview(cardPreview);
282
+ var isSSR = cardPreview && (isSSRClientPreview(cardPreview) || isSSRDataPreview(cardPreview));
213
283
 
214
284
  if (isLocal || isSSR) {
215
285
  var updateState = {
@@ -222,14 +292,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
222
292
  _this.fireLocalPreviewErrorEvent(error);
223
293
  }
224
294
 
225
- if (isSSR) {// TODO: set SSR-client reliability 'failed'.
226
- // https://product-fabric.atlassian.net/browse/MEX-770
227
- }
228
-
229
- var _this$props4 = _this.props,
230
- identifier = _this$props4.identifier,
231
- _this$props4$dimensio = _this$props4.dimensions,
232
- dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
295
+ var _this$props5 = _this.props,
296
+ identifier = _this$props5.identifier,
297
+ _this$props5$dimensio = _this$props5.dimensions,
298
+ dimensions = _this$props5$dimensio === void 0 ? {} : _this$props5$dimensio;
233
299
  isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
234
300
 
235
301
  _this.safeSetState(updateState);
@@ -241,7 +307,34 @@ export var CardBase = /*#__PURE__*/function (_Component) {
241
307
  }
242
308
  });
243
309
 
244
- _defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
310
+ _defineProperty(_assertThisInitialized(_this), "onImageLoad", function (cardPreview) {
311
+ if (cardPreview) {
312
+ if (isSSRClientPreview(cardPreview) && _this.ssrReliability.client.status === 'unknown') {
313
+ _this.ssrReliability.client = {
314
+ status: 'success'
315
+ };
316
+ }
317
+ /*
318
+ 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.
319
+ */
320
+
321
+
322
+ if (isSSRDataPreview(cardPreview) && _this.ssrReliability.server.status === 'unknown') {
323
+ _this.ssrReliability.server = {
324
+ status: 'success'
325
+ };
326
+ _this.ssrReliability.client = {
327
+ status: 'success'
328
+ };
329
+ }
330
+ }
331
+
332
+ var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this callback
333
+
334
+ if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
335
+ return;
336
+ }
337
+
245
338
  _this.safeSetState({
246
339
  previewDidRender: true
247
340
  });
@@ -287,10 +380,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
287
380
  });
288
381
 
289
382
  _defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
290
- var _this$props5 = _this.props,
291
- identifier = _this$props5.identifier,
292
- useInlinePlayer = _this$props5.useInlinePlayer,
293
- shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
383
+ var _this$props6 = _this.props,
384
+ identifier = _this$props6.identifier,
385
+ useInlinePlayer = _this$props6.useInlinePlayer,
386
+ shouldOpenMediaViewer = _this$props6.shouldOpenMediaViewer;
294
387
  var cardPreview = _this.state.cardPreview;
295
388
 
296
389
  var _assertThisInitialize2 = _assertThisInitialized(_this),
@@ -346,14 +439,16 @@ export var CardBase = /*#__PURE__*/function (_Component) {
346
439
  });
347
440
 
348
441
  _defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
349
- var _this$props6 = _this.props,
350
- identifier = _this$props6.identifier,
351
- mediaClient = _this$props6.mediaClient,
352
- dimensions = _this$props6.dimensions,
353
- selected = _this$props6.selected,
354
- testId = _this$props6.testId,
355
- originalDimensions = _this$props6.originalDimensions;
356
- var shouldAutoplay = _this.state.shouldAutoplay;
442
+ var _this$props7 = _this.props,
443
+ identifier = _this$props7.identifier,
444
+ mediaClient = _this$props7.mediaClient,
445
+ dimensions = _this$props7.dimensions,
446
+ selected = _this$props7.selected,
447
+ testId = _this$props7.testId,
448
+ originalDimensions = _this$props7.originalDimensions;
449
+ var _this$state = _this.state,
450
+ shouldAutoplay = _this$state.shouldAutoplay,
451
+ cardPreview = _this$state.cardPreview;
357
452
  return /*#__PURE__*/React.createElement(InlinePlayer, {
358
453
  mediaClient: mediaClient,
359
454
  dimensions: dimensions,
@@ -364,7 +459,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
364
459
  onClick: _this.onClick,
365
460
  selected: selected,
366
461
  ref: _this.setRef,
367
- testId: testId
462
+ testId: testId,
463
+ cardPreview: cardPreview
368
464
  });
369
465
  });
370
466
 
@@ -397,12 +493,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
397
493
 
398
494
  _defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
399
495
  var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
400
- var _this$props7 = _this.props,
401
- mediaClient = _this$props7.mediaClient,
402
- identifier = _this$props7.identifier,
403
- mediaViewerDataSource = _this$props7.mediaViewerDataSource,
404
- contextId = _this$props7.contextId,
405
- featureFlags = _this$props7.featureFlags;
496
+ var _this$props8 = _this.props,
497
+ mediaClient = _this$props8.mediaClient,
498
+ identifier = _this$props8.identifier,
499
+ mediaViewerDataSource = _this$props8.mediaViewerDataSource,
500
+ contextId = _this$props8.contextId,
501
+ featureFlags = _this$props8.featureFlags;
406
502
 
407
503
  if (!mediaViewerSelectedItem) {
408
504
  return;
@@ -424,35 +520,31 @@ export var CardBase = /*#__PURE__*/function (_Component) {
424
520
  });
425
521
 
426
522
  _defineProperty(_assertThisInitialized(_this), "renderCard", function () {
427
- var _this$props8 = _this.props,
428
- identifier = _this$props8.identifier,
429
- isLazy = _this$props8.isLazy,
430
- appearance = _this$props8.appearance,
431
- resizeMode = _this$props8.resizeMode,
432
- dimensions = _this$props8.dimensions,
433
- selectable = _this$props8.selectable,
434
- selected = _this$props8.selected,
435
- disableOverlay = _this$props8.disableOverlay,
436
- alt = _this$props8.alt,
437
- testId = _this$props8.testId,
438
- featureFlags = _this$props8.featureFlags,
439
- titleBoxBgColor = _this$props8.titleBoxBgColor,
440
- titleBoxIcon = _this$props8.titleBoxIcon,
441
- ssr = _this$props8.ssr;
523
+ var _this$props9 = _this.props,
524
+ identifier = _this$props9.identifier,
525
+ isLazy = _this$props9.isLazy,
526
+ appearance = _this$props9.appearance,
527
+ resizeMode = _this$props9.resizeMode,
528
+ dimensions = _this$props9.dimensions,
529
+ selectable = _this$props9.selectable,
530
+ selected = _this$props9.selected,
531
+ disableOverlay = _this$props9.disableOverlay,
532
+ alt = _this$props9.alt,
533
+ testId = _this$props9.testId,
534
+ featureFlags = _this$props9.featureFlags,
535
+ titleBoxBgColor = _this$props9.titleBoxBgColor,
536
+ titleBoxIcon = _this$props9.titleBoxIcon,
537
+ ssr = _this$props9.ssr,
538
+ useInlinePlayer = _this$props9.useInlinePlayer,
539
+ shouldOpenMediaViewer = _this$props9.shouldOpenMediaViewer;
442
540
  var mediaItemType = identifier.mediaItemType;
443
- var _this$state = _this.state,
444
- status = _this$state.status,
445
- progress = _this$state.progress,
446
- _this$state$cardPrevi = _this$state.cardPreview;
447
- _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {
448
- dataURI: undefined,
449
- orientation: 1
450
- } : _this$state$cardPrevi;
451
- var dataURI = _this$state$cardPrevi.dataURI,
452
- orientation = _this$state$cardPrevi.orientation,
453
- error = _this$state.error,
454
- cardRef = _this$state.cardRef,
455
- isCardVisible = _this$state.isCardVisible;
541
+ var _this$state2 = _this.state,
542
+ status = _this$state2.status,
543
+ progress = _this$state2.progress,
544
+ cardPreview = _this$state2.cardPreview,
545
+ error = _this$state2.error,
546
+ cardRef = _this$state2.cardRef,
547
+ isCardVisible = _this$state2.isCardVisible;
456
548
 
457
549
  var _assertThisInitialize3 = _assertThisInitialized(_this),
458
550
  metadata = _assertThisInitialize3.metadata;
@@ -468,12 +560,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
468
560
  var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
469
561
 
470
562
  var forceSyncDisplay = !!ssr;
563
+ var mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, status === 'error' || status === 'failed-processing', !!_this.state.cardPreview, metadata.mediaType);
471
564
  var card = /*#__PURE__*/React.createElement(CardView, {
472
565
  status: status,
473
566
  error: error,
474
567
  mediaItemType: mediaItemType,
475
568
  metadata: metadata,
476
- dataURI: dataURI,
569
+ cardPreview: cardPreview,
477
570
  alt: alt,
478
571
  appearance: appearance,
479
572
  resizeMode: resizeMode,
@@ -486,7 +579,6 @@ export var CardBase = /*#__PURE__*/function (_Component) {
486
579
  disableOverlay: disableOverlay,
487
580
  progress: progress,
488
581
  onDisplayImage: onDisplayImage,
489
- previewOrientation: orientation,
490
582
  innerRef: _this.setRef,
491
583
  testId: testId,
492
584
  featureFlags: featureFlags,
@@ -495,7 +587,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
495
587
  onImageError: _this.onImageError,
496
588
  onImageLoad: _this.onImageLoad,
497
589
  nativeLazyLoad: nativeLazyLoad,
498
- forceSyncDisplay: forceSyncDisplay
590
+ forceSyncDisplay: forceSyncDisplay,
591
+ mediaCardCursor: mediaCardCursor
499
592
  });
500
593
  return isLazy ? /*#__PURE__*/React.createElement(ViewportDetector, {
501
594
  cardEl: cardRef,
@@ -511,6 +604,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
511
604
  })) : card;
512
605
  });
513
606
 
607
+ _defineProperty(_assertThisInitialized(_this), "storeSSRData", function () {
608
+ var _this$ssrReliability$;
609
+
610
+ var _this$props10 = _this.props,
611
+ ssr = _this$props10.ssr,
612
+ identifier = _this$props10.identifier;
613
+ var _this$state$cardPrevi = _this.state.cardPreview;
614
+ _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
615
+ var dataURI = _this$state$cardPrevi.dataURI;
616
+ return isFileIdentifier(identifier) && ssr === 'server' && /*#__PURE__*/React.createElement(StoreSSRDataScript, {
617
+ identifier: identifier,
618
+ dataURI: dataURI,
619
+ dimensions: _this.requestedDimensions,
620
+ error: ((_this$ssrReliability$ = _this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? _this.ssrReliability.server : undefined
621
+ });
622
+ });
623
+
514
624
  _defineProperty(_assertThisInitialized(_this), "onCardInViewport", function () {
515
625
  _this.setState({
516
626
  isCardVisible: true
@@ -551,20 +661,44 @@ export var CardBase = /*#__PURE__*/function (_Component) {
551
661
 
552
662
  var _cardPreview;
553
663
 
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;
664
+ var _error;
665
+
666
+ var _this$props11 = _this.props,
667
+ _identifier = _this$props11.identifier,
668
+ _this$props11$dimensi = _this$props11.dimensions,
669
+ _dimensions = _this$props11$dimensi === void 0 ? {} : _this$props11$dimensi,
670
+ _ssr = _this$props11.ssr,
671
+ _mediaClient = _this$props11.mediaClient;
559
672
 
560
673
  if (isFileIdentifier(_identifier)) {
561
674
  var id = _identifier.id;
562
675
  _cardPreview = getCardPreviewFromCache(id, _dimensions);
563
676
 
564
677
  if (!_cardPreview && _ssr) {
565
- _this.fireCommencedEvent();
678
+ var _this$ssrData, _this$ssrData2;
679
+
680
+ _this.ssrData = getSSRData(_identifier);
681
+
682
+ if ((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
683
+ _this.ssrReliability.server = _objectSpread({
684
+ status: 'fail'
685
+ }, _this.ssrData.error);
686
+ }
566
687
 
567
- _cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
688
+ if (!((_this$ssrData2 = _this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
689
+ try {
690
+ _cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
691
+ } catch (e) {
692
+ _this.ssrReliability[_ssr] = _objectSpread({
693
+ status: 'fail'
694
+ }, extractErrorInfo(e));
695
+ }
696
+ } else {
697
+ _cardPreview = {
698
+ dataURI: _this.ssrData.dataURI,
699
+ source: 'ssr-data'
700
+ };
701
+ }
568
702
  }
569
703
  } else if (isExternalImageIdentifier(_identifier)) {
570
704
  _this.fireCommencedEvent();
@@ -592,7 +726,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
592
726
  cardPreview: _cardPreview,
593
727
  cardRef: null,
594
728
  isBannedLocalPreview: false,
595
- previewDidRender: false
729
+ previewDidRender: false,
730
+ error: _error
596
731
  };
597
732
  return _this;
598
733
  }
@@ -601,21 +736,32 @@ export var CardBase = /*#__PURE__*/function (_Component) {
601
736
  key: "componentDidMount",
602
737
  value: function componentDidMount() {
603
738
  this.hasBeenMounted = true;
604
- var _this$state2 = this.state,
605
- isCardVisible = _this$state2.isCardVisible,
606
- cardPreview = _this$state2.cardPreview;
607
- var _this$props10 = this.props,
608
- identifier = _this$props10.identifier,
609
- ssr = _this$props10.ssr;
739
+ var _this$state3 = this.state,
740
+ isCardVisible = _this$state3.isCardVisible,
741
+ cardPreview = _this$state3.cardPreview;
742
+ var _this$props12 = this.props,
743
+ identifier = _this$props12.identifier,
744
+ ssr = _this$props12.ssr,
745
+ dimensions = _this$props12.dimensions;
610
746
 
611
747
  if (isCardVisible && isFileIdentifier(identifier)) {
612
748
  this.updateStateForIdentifier(identifier);
613
749
  }
614
750
 
615
- if (isCardVisible && !!ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
616
- // Since the SSR preview brings the token in the query params,
617
- // We need to fetch the remote preview to be able to cache it,
618
- this.setCacheSSRPreview(identifier);
751
+ if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
752
+ var _this$ssrData3;
753
+
754
+ if (isSSRClientPreview(cardPreview)) {
755
+ // Since the SSR preview brings the token in the query params,
756
+ // We need to fetch the remote preview to be able to cache it,
757
+ this.setCacheSSRPreview(identifier);
758
+ }
759
+
760
+ if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
761
+ // If dimensions from Server have changed and are bigger,
762
+ // we need to refetch
763
+ this.refetchSSRPreview(identifier);
764
+ }
619
765
  } // we add a listener for each of the cards on the page
620
766
  // and then check if the triggered listener is from the card
621
767
  // that contains a div in current window.getSelection()
@@ -631,21 +777,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
631
777
  prevIdentifier = prevProps.identifier,
632
778
  prevDimensions = prevProps.dimensions;
633
779
  var prevIsCardVisible = prevState.isCardVisible;
634
- var _this$props11 = this.props,
635
- mediaClient = _this$props11.mediaClient,
636
- identifier = _this$props11.identifier,
637
- dimensions = _this$props11.dimensions,
638
- featureFlags = _this$props11.featureFlags,
639
- useInlinePlayer = _this$props11.useInlinePlayer,
640
- disableOverlay = _this$props11.disableOverlay;
641
- var _this$state3 = this.state,
642
- isCardVisible = _this$state3.isCardVisible,
643
- cardPreview = _this$state3.cardPreview,
644
- status = _this$state3.status,
645
- fileState = _this$state3.fileState,
646
- isBannedLocalPreview = _this$state3.isBannedLocalPreview,
647
- previewDidRender = _this$state3.previewDidRender,
648
- isPlayingFile = _this$state3.isPlayingFile;
780
+ var _this$props13 = this.props,
781
+ mediaClient = _this$props13.mediaClient,
782
+ identifier = _this$props13.identifier,
783
+ dimensions = _this$props13.dimensions,
784
+ featureFlags = _this$props13.featureFlags,
785
+ useInlinePlayer = _this$props13.useInlinePlayer,
786
+ disableOverlay = _this$props13.disableOverlay;
787
+ var _this$state4 = this.state,
788
+ isCardVisible = _this$state4.isCardVisible,
789
+ cardPreview = _this$state4.cardPreview,
790
+ status = _this$state4.status,
791
+ fileState = _this$state4.fileState,
792
+ isBannedLocalPreview = _this$state4.isBannedLocalPreview,
793
+ previewDidRender = _this$state4.previewDidRender,
794
+ isPlayingFile = _this$state4.isPlayingFile;
649
795
  var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
650
796
  var turnedVisible = !prevIsCardVisible && isCardVisible;
651
797
  var isNewMediaClient = prevMediaClient !== mediaClient;
@@ -761,8 +907,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
761
907
  get: function get() {
762
908
  var dimensions = this.props.dimensions;
763
909
 
764
- var _ref3 = this.state || {},
765
- element = _ref3.cardRef;
910
+ var _ref4 = this.state || {},
911
+ element = _ref4.cardRef;
766
912
 
767
913
  return getRequestedDimensions({
768
914
  dimensions: dimensions,
@@ -772,25 +918,25 @@ export var CardBase = /*#__PURE__*/function (_Component) {
772
918
  }, {
773
919
  key: "metadata",
774
920
  get: function get() {
775
- var _this$state4;
921
+ var _this$state5;
776
922
 
777
- return getFileDetails(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
923
+ return getFileDetails(this.props.identifier, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : _this$state5.fileState);
778
924
  }
779
925
  }, {
780
926
  key: "fileAttributes",
781
927
  get: function get() {
782
- var _this$state5, _this$state5$fileStat;
928
+ var _this$state6, _this$state6$fileStat;
783
929
 
784
- return 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);
930
+ return getFileAttributes(this.metadata, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : (_this$state6$fileStat = _this$state6.fileState) === null || _this$state6$fileStat === void 0 ? void 0 : _this$state6$fileStat.status);
785
931
  }
786
932
  }, {
787
933
  key: "fireOperationalEvent",
788
934
  value: function fireOperationalEvent() {
789
- var _this$state6 = this.state,
790
- status = _this$state6.status,
791
- error = _this$state6.error;
935
+ var _this$state7 = this.state,
936
+ status = _this$state7.status,
937
+ error = _this$state7.error;
792
938
  var createAnalyticsEvent = this.props.createAnalyticsEvent;
793
- createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
939
+ createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error);
794
940
  }
795
941
  }, {
796
942
  key: "fireCommencedEvent",
@@ -808,11 +954,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
808
954
  get: function get() {
809
955
  var _this3 = this;
810
956
 
811
- var _this$props12 = this.props,
812
- _this$props12$actions = _this$props12.actions,
813
- actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
814
- identifier = _this$props12.identifier,
815
- shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
957
+ var _this$props14 = this.props,
958
+ _this$props14$actions = _this$props14.actions,
959
+ actions = _this$props14$actions === void 0 ? [] : _this$props14$actions,
960
+ identifier = _this$props14.identifier,
961
+ shouldEnableDownloadButton = _this$props14.shouldEnableDownloadButton;
816
962
  var status = this.state.status;
817
963
  var metadata = this.metadata;
818
964
 
@@ -834,10 +980,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
834
980
  }, {
835
981
  key: "render",
836
982
  value: function render() {
837
- var _this$state7 = this.state,
838
- isPlayingFile = _this$state7.isPlayingFile,
839
- mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
840
- var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
983
+ var _this$state8 = this.state,
984
+ isPlayingFile = _this$state8.isPlayingFile,
985
+ mediaViewerSelectedItem = _this$state8.mediaViewerSelectedItem;
986
+ var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
841
987
  return this.props.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
842
988
  locale: "en"
843
989
  }, innerContent);