@atlaskit/media-card 73.1.1 → 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.
- package/CHANGELOG.md +19 -0
- package/dist/cjs/files/cardImageView/index.js +51 -41
- package/dist/cjs/root/card/getCardPreview/index.js +7 -1
- package/dist/cjs/root/card/index.js +247 -151
- package/dist/cjs/root/cardView.js +127 -115
- package/dist/cjs/root/inlinePlayer.js +4 -2
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/cjs/root/ui/styled.js +5 -5
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +23 -7
- package/dist/cjs/utils/dimensionComparer.js +7 -13
- package/dist/cjs/utils/getMediaCardCursor.js +29 -0
- package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
- package/dist/cjs/utils/globalScope/globalScope.js +94 -0
- package/dist/cjs/utils/globalScope/index.js +39 -0
- package/dist/cjs/utils/globalScope/types.js +5 -0
- package/dist/cjs/utils/printScript.js +44 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/files/cardImageView/index.js +19 -5
- package/dist/es2019/root/card/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +107 -35
- package/dist/es2019/root/cardView.js +40 -30
- package/dist/es2019/root/inlinePlayer.js +4 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/es2019/root/ui/styled.js +4 -4
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/utils/analytics.js +8 -3
- package/dist/es2019/utils/dimensionComparer.js +6 -13
- package/dist/es2019/utils/getMediaCardCursor.js +19 -0
- package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
- package/dist/es2019/utils/globalScope/globalScope.js +62 -0
- package/dist/es2019/utils/globalScope/index.js +2 -0
- package/dist/es2019/utils/globalScope/types.js +1 -0
- package/dist/es2019/utils/printScript.js +19 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/files/cardImageView/index.js +53 -41
- package/dist/esm/root/card/getCardPreview/index.js +3 -0
- package/dist/esm/root/card/index.js +228 -134
- package/dist/esm/root/cardView.js +126 -115
- package/dist/esm/root/inlinePlayer.js +4 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +17 -6
- package/dist/esm/utils/dimensionComparer.js +8 -13
- package/dist/esm/utils/getMediaCardCursor.js +19 -0
- package/dist/esm/utils/globalScope/getSSRData.js +10 -0
- package/dist/esm/utils/globalScope/globalScope.js +69 -0
- package/dist/esm/utils/globalScope/index.js +2 -0
- package/dist/esm/utils/globalScope/types.js +1 -0
- package/dist/esm/utils/printScript.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/files/cardImageView/index.d.ts +6 -2
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +3 -1
- package/dist/types/root/cardView.d.ts +8 -6
- package/dist/types/root/inlinePlayer.d.ts +3 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
- package/dist/types/root/ui/styled.d.ts +2 -1
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/analytics.d.ts +6 -0
- package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
- package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
- package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
- package/dist/types/utils/globalScope/index.d.ts +4 -0
- package/dist/types/utils/globalScope/types.d.ts +8 -0
- package/dist/types/utils/printScript.d.ts +2 -0
- package/package.json +5 -5
|
@@ -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
|
|
|
@@ -127,27 +130,18 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
127
130
|
});
|
|
128
131
|
});
|
|
129
132
|
|
|
130
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
131
|
-
var
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
|
|
134
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
|
|
135
|
+
var _this$props4, mediaClient, _this$props4$dimensio, dimensions, cardPreview;
|
|
132
136
|
|
|
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
|
-
});
|
|
139
|
-
|
|
140
|
-
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
141
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
|
|
142
|
-
var params, cardPreview, wrappedError;
|
|
143
137
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
144
138
|
while (1) {
|
|
145
139
|
switch (_context.prev = _context.next) {
|
|
146
140
|
case 0:
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
_this$props4 = _this.props, mediaClient = _this$props4.mediaClient, _this$props4$dimensio = _this$props4.dimensions, dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
|
|
142
|
+
_context.prev = 1;
|
|
149
143
|
_context.next = 4;
|
|
150
|
-
return
|
|
144
|
+
return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
151
145
|
|
|
152
146
|
case 4:
|
|
153
147
|
cardPreview = _context.sent;
|
|
@@ -156,13 +150,52 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
156
150
|
cardPreview: cardPreview
|
|
157
151
|
});
|
|
158
152
|
|
|
159
|
-
_context.next =
|
|
153
|
+
_context.next = 10;
|
|
160
154
|
break;
|
|
161
155
|
|
|
162
156
|
case 8:
|
|
163
157
|
_context.prev = 8;
|
|
164
|
-
_context.t0 = _context["catch"](
|
|
165
|
-
|
|
158
|
+
_context.t0 = _context["catch"](1);
|
|
159
|
+
|
|
160
|
+
case 10:
|
|
161
|
+
case "end":
|
|
162
|
+
return _context.stop();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}, _callee, null, [[1, 8]]);
|
|
166
|
+
}));
|
|
167
|
+
|
|
168
|
+
return function (_x) {
|
|
169
|
+
return _ref2.apply(this, arguments);
|
|
170
|
+
};
|
|
171
|
+
}());
|
|
172
|
+
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
174
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier, fileState) {
|
|
175
|
+
var params, cardPreview, wrappedError;
|
|
176
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
177
|
+
while (1) {
|
|
178
|
+
switch (_context2.prev = _context2.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_context2.prev = 0;
|
|
181
|
+
params = _this.getCardPreviewParams(identifier, fileState);
|
|
182
|
+
_context2.next = 4;
|
|
183
|
+
return getCardPreview(params);
|
|
184
|
+
|
|
185
|
+
case 4:
|
|
186
|
+
cardPreview = _context2.sent;
|
|
187
|
+
|
|
188
|
+
_this.safeSetState({
|
|
189
|
+
cardPreview: cardPreview
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
_context2.next = 12;
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
case 8:
|
|
196
|
+
_context2.prev = 8;
|
|
197
|
+
_context2.t0 = _context2["catch"](0);
|
|
198
|
+
wrappedError = ensureMediaCardError('preview-fetch', _context2.t0); // If remote preview fails, we set status 'error'
|
|
166
199
|
// If local preview fails (i.e, no remote preview available),
|
|
167
200
|
// we can stay in the same status until there is a remote preview available
|
|
168
201
|
// If it's any other error we set status 'error'
|
|
@@ -180,14 +213,14 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
180
213
|
|
|
181
214
|
case 12:
|
|
182
215
|
case "end":
|
|
183
|
-
return
|
|
216
|
+
return _context2.stop();
|
|
184
217
|
}
|
|
185
218
|
}
|
|
186
|
-
},
|
|
219
|
+
}, _callee2, null, [[0, 8]]);
|
|
187
220
|
}));
|
|
188
221
|
|
|
189
|
-
return function (
|
|
190
|
-
return
|
|
222
|
+
return function (_x2, _x3) {
|
|
223
|
+
return _ref3.apply(this, arguments);
|
|
191
224
|
};
|
|
192
225
|
}());
|
|
193
226
|
|
|
@@ -205,11 +238,16 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
205
238
|
};
|
|
206
239
|
});
|
|
207
240
|
|
|
208
|
-
_defineProperty(_assertThisInitialized(_this), "onImageError", function () {
|
|
209
|
-
var
|
|
241
|
+
_defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
|
|
242
|
+
var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this error
|
|
243
|
+
|
|
244
|
+
if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
210
248
|
var error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
211
249
|
var isLocal = cardPreview && isLocalPreview(cardPreview);
|
|
212
|
-
var isSSR = cardPreview && isSSRClientPreview(cardPreview);
|
|
250
|
+
var isSSR = cardPreview && (isSSRClientPreview(cardPreview) || isSSRDataPreview(cardPreview));
|
|
213
251
|
|
|
214
252
|
if (isLocal || isSSR) {
|
|
215
253
|
var updateState = {
|
|
@@ -226,10 +264,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
226
264
|
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
227
265
|
}
|
|
228
266
|
|
|
229
|
-
var _this$
|
|
230
|
-
identifier = _this$
|
|
231
|
-
_this$
|
|
232
|
-
dimensions = _this$
|
|
267
|
+
var _this$props5 = _this.props,
|
|
268
|
+
identifier = _this$props5.identifier,
|
|
269
|
+
_this$props5$dimensio = _this$props5.dimensions,
|
|
270
|
+
dimensions = _this$props5$dimensio === void 0 ? {} : _this$props5$dimensio;
|
|
233
271
|
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
|
|
234
272
|
|
|
235
273
|
_this.safeSetState(updateState);
|
|
@@ -241,7 +279,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
241
279
|
}
|
|
242
280
|
});
|
|
243
281
|
|
|
244
|
-
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
|
|
282
|
+
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function (cardPreview) {
|
|
283
|
+
var currentPreview = _this.state.cardPreview; // If the dataURI has been replaced, we can dismiss this callback
|
|
284
|
+
|
|
285
|
+
if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
245
289
|
_this.safeSetState({
|
|
246
290
|
previewDidRender: true
|
|
247
291
|
});
|
|
@@ -287,10 +331,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
287
331
|
});
|
|
288
332
|
|
|
289
333
|
_defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
290
|
-
var _this$
|
|
291
|
-
identifier = _this$
|
|
292
|
-
useInlinePlayer = _this$
|
|
293
|
-
shouldOpenMediaViewer = _this$
|
|
334
|
+
var _this$props6 = _this.props,
|
|
335
|
+
identifier = _this$props6.identifier,
|
|
336
|
+
useInlinePlayer = _this$props6.useInlinePlayer,
|
|
337
|
+
shouldOpenMediaViewer = _this$props6.shouldOpenMediaViewer;
|
|
294
338
|
var cardPreview = _this.state.cardPreview;
|
|
295
339
|
|
|
296
340
|
var _assertThisInitialize2 = _assertThisInitialized(_this),
|
|
@@ -346,14 +390,16 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
346
390
|
});
|
|
347
391
|
|
|
348
392
|
_defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
|
|
349
|
-
var _this$
|
|
350
|
-
identifier = _this$
|
|
351
|
-
mediaClient = _this$
|
|
352
|
-
dimensions = _this$
|
|
353
|
-
selected = _this$
|
|
354
|
-
testId = _this$
|
|
355
|
-
originalDimensions = _this$
|
|
356
|
-
var
|
|
393
|
+
var _this$props7 = _this.props,
|
|
394
|
+
identifier = _this$props7.identifier,
|
|
395
|
+
mediaClient = _this$props7.mediaClient,
|
|
396
|
+
dimensions = _this$props7.dimensions,
|
|
397
|
+
selected = _this$props7.selected,
|
|
398
|
+
testId = _this$props7.testId,
|
|
399
|
+
originalDimensions = _this$props7.originalDimensions;
|
|
400
|
+
var _this$state = _this.state,
|
|
401
|
+
shouldAutoplay = _this$state.shouldAutoplay,
|
|
402
|
+
cardPreview = _this$state.cardPreview;
|
|
357
403
|
return /*#__PURE__*/React.createElement(InlinePlayer, {
|
|
358
404
|
mediaClient: mediaClient,
|
|
359
405
|
dimensions: dimensions,
|
|
@@ -364,7 +410,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
364
410
|
onClick: _this.onClick,
|
|
365
411
|
selected: selected,
|
|
366
412
|
ref: _this.setRef,
|
|
367
|
-
testId: testId
|
|
413
|
+
testId: testId,
|
|
414
|
+
cardPreview: cardPreview
|
|
368
415
|
});
|
|
369
416
|
});
|
|
370
417
|
|
|
@@ -397,12 +444,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
397
444
|
|
|
398
445
|
_defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
|
|
399
446
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
400
|
-
var _this$
|
|
401
|
-
mediaClient = _this$
|
|
402
|
-
identifier = _this$
|
|
403
|
-
mediaViewerDataSource = _this$
|
|
404
|
-
contextId = _this$
|
|
405
|
-
featureFlags = _this$
|
|
447
|
+
var _this$props8 = _this.props,
|
|
448
|
+
mediaClient = _this$props8.mediaClient,
|
|
449
|
+
identifier = _this$props8.identifier,
|
|
450
|
+
mediaViewerDataSource = _this$props8.mediaViewerDataSource,
|
|
451
|
+
contextId = _this$props8.contextId,
|
|
452
|
+
featureFlags = _this$props8.featureFlags;
|
|
406
453
|
|
|
407
454
|
if (!mediaViewerSelectedItem) {
|
|
408
455
|
return;
|
|
@@ -424,35 +471,31 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
424
471
|
});
|
|
425
472
|
|
|
426
473
|
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
427
|
-
var _this$
|
|
428
|
-
identifier = _this$
|
|
429
|
-
isLazy = _this$
|
|
430
|
-
appearance = _this$
|
|
431
|
-
resizeMode = _this$
|
|
432
|
-
dimensions = _this$
|
|
433
|
-
selectable = _this$
|
|
434
|
-
selected = _this$
|
|
435
|
-
disableOverlay = _this$
|
|
436
|
-
alt = _this$
|
|
437
|
-
testId = _this$
|
|
438
|
-
featureFlags = _this$
|
|
439
|
-
titleBoxBgColor = _this$
|
|
440
|
-
titleBoxIcon = _this$
|
|
441
|
-
ssr = _this$
|
|
474
|
+
var _this$props9 = _this.props,
|
|
475
|
+
identifier = _this$props9.identifier,
|
|
476
|
+
isLazy = _this$props9.isLazy,
|
|
477
|
+
appearance = _this$props9.appearance,
|
|
478
|
+
resizeMode = _this$props9.resizeMode,
|
|
479
|
+
dimensions = _this$props9.dimensions,
|
|
480
|
+
selectable = _this$props9.selectable,
|
|
481
|
+
selected = _this$props9.selected,
|
|
482
|
+
disableOverlay = _this$props9.disableOverlay,
|
|
483
|
+
alt = _this$props9.alt,
|
|
484
|
+
testId = _this$props9.testId,
|
|
485
|
+
featureFlags = _this$props9.featureFlags,
|
|
486
|
+
titleBoxBgColor = _this$props9.titleBoxBgColor,
|
|
487
|
+
titleBoxIcon = _this$props9.titleBoxIcon,
|
|
488
|
+
ssr = _this$props9.ssr,
|
|
489
|
+
useInlinePlayer = _this$props9.useInlinePlayer,
|
|
490
|
+
shouldOpenMediaViewer = _this$props9.shouldOpenMediaViewer;
|
|
442
491
|
var mediaItemType = identifier.mediaItemType;
|
|
443
|
-
var _this$
|
|
444
|
-
status = _this$
|
|
445
|
-
progress = _this$
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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;
|
|
492
|
+
var _this$state2 = _this.state,
|
|
493
|
+
status = _this$state2.status,
|
|
494
|
+
progress = _this$state2.progress,
|
|
495
|
+
cardPreview = _this$state2.cardPreview,
|
|
496
|
+
error = _this$state2.error,
|
|
497
|
+
cardRef = _this$state2.cardRef,
|
|
498
|
+
isCardVisible = _this$state2.isCardVisible;
|
|
456
499
|
|
|
457
500
|
var _assertThisInitialize3 = _assertThisInitialized(_this),
|
|
458
501
|
metadata = _assertThisInitialize3.metadata;
|
|
@@ -468,12 +511,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
468
511
|
var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
|
|
469
512
|
|
|
470
513
|
var forceSyncDisplay = !!ssr;
|
|
514
|
+
var mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, status === 'error' || status === 'failed-processing', !!_this.state.cardPreview, metadata.mediaType);
|
|
471
515
|
var card = /*#__PURE__*/React.createElement(CardView, {
|
|
472
516
|
status: status,
|
|
473
517
|
error: error,
|
|
474
518
|
mediaItemType: mediaItemType,
|
|
475
519
|
metadata: metadata,
|
|
476
|
-
|
|
520
|
+
cardPreview: cardPreview,
|
|
477
521
|
alt: alt,
|
|
478
522
|
appearance: appearance,
|
|
479
523
|
resizeMode: resizeMode,
|
|
@@ -486,7 +530,6 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
486
530
|
disableOverlay: disableOverlay,
|
|
487
531
|
progress: progress,
|
|
488
532
|
onDisplayImage: onDisplayImage,
|
|
489
|
-
previewOrientation: orientation,
|
|
490
533
|
innerRef: _this.setRef,
|
|
491
534
|
testId: testId,
|
|
492
535
|
featureFlags: featureFlags,
|
|
@@ -495,7 +538,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
495
538
|
onImageError: _this.onImageError,
|
|
496
539
|
onImageLoad: _this.onImageLoad,
|
|
497
540
|
nativeLazyLoad: nativeLazyLoad,
|
|
498
|
-
forceSyncDisplay: forceSyncDisplay
|
|
541
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
542
|
+
mediaCardCursor: mediaCardCursor
|
|
499
543
|
});
|
|
500
544
|
return isLazy ? /*#__PURE__*/React.createElement(ViewportDetector, {
|
|
501
545
|
cardEl: cardRef,
|
|
@@ -511,6 +555,24 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
511
555
|
})) : card;
|
|
512
556
|
});
|
|
513
557
|
|
|
558
|
+
_defineProperty(_assertThisInitialized(_this), "storeSSRData", function () {
|
|
559
|
+
var _this$props10 = _this.props,
|
|
560
|
+
ssr = _this$props10.ssr,
|
|
561
|
+
identifier = _this$props10.identifier;
|
|
562
|
+
var _this$state3 = _this.state,
|
|
563
|
+
_this$state3$cardPrev = _this$state3.cardPreview;
|
|
564
|
+
_this$state3$cardPrev = _this$state3$cardPrev === void 0 ? {} : _this$state3$cardPrev;
|
|
565
|
+
var dataURI = _this$state3$cardPrev.dataURI,
|
|
566
|
+
error = _this$state3.error;
|
|
567
|
+
var ssrDataError = !!error ? extractErrorInfo(error) : undefined;
|
|
568
|
+
return isFileIdentifier(identifier) && ssr === 'server' && /*#__PURE__*/React.createElement(StoreSSRDataScript, {
|
|
569
|
+
identifier: identifier,
|
|
570
|
+
dataURI: dataURI,
|
|
571
|
+
dimensions: _this.requestedDimensions,
|
|
572
|
+
error: ssrDataError
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
514
576
|
_defineProperty(_assertThisInitialized(_this), "onCardInViewport", function () {
|
|
515
577
|
_this.setState({
|
|
516
578
|
isCardVisible: true
|
|
@@ -551,20 +613,40 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
551
613
|
|
|
552
614
|
var _cardPreview;
|
|
553
615
|
|
|
554
|
-
var
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
616
|
+
var _error;
|
|
617
|
+
|
|
618
|
+
var _this$props11 = _this.props,
|
|
619
|
+
_identifier = _this$props11.identifier,
|
|
620
|
+
_this$props11$dimensi = _this$props11.dimensions,
|
|
621
|
+
_dimensions = _this$props11$dimensi === void 0 ? {} : _this$props11$dimensi,
|
|
622
|
+
_ssr = _this$props11.ssr,
|
|
623
|
+
_mediaClient = _this$props11.mediaClient;
|
|
559
624
|
|
|
560
625
|
if (isFileIdentifier(_identifier)) {
|
|
561
626
|
var id = _identifier.id;
|
|
562
627
|
_cardPreview = getCardPreviewFromCache(id, _dimensions);
|
|
563
628
|
|
|
564
629
|
if (!_cardPreview && _ssr) {
|
|
565
|
-
_this
|
|
566
|
-
|
|
567
|
-
|
|
630
|
+
var _this$ssrData;
|
|
631
|
+
|
|
632
|
+
_this.ssrData = getSSRData(_identifier);
|
|
633
|
+
|
|
634
|
+
if (_ssr === 'server' || !((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.dataURI)) {
|
|
635
|
+
try {
|
|
636
|
+
_cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
|
|
637
|
+
} catch (e) {
|
|
638
|
+
// TODO: handle error in client MEX-770
|
|
639
|
+
// If we fail building the dataURI in server, we store the error in the state
|
|
640
|
+
// to be later stored in global scope and logged in client.
|
|
641
|
+
// We don't set the status = error to fall back to the spinner icon
|
|
642
|
+
_error = _ssr === 'server' ? e : undefined;
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
_cardPreview = {
|
|
646
|
+
dataURI: _this.ssrData.dataURI,
|
|
647
|
+
source: 'ssr-data'
|
|
648
|
+
};
|
|
649
|
+
}
|
|
568
650
|
}
|
|
569
651
|
} else if (isExternalImageIdentifier(_identifier)) {
|
|
570
652
|
_this.fireCommencedEvent();
|
|
@@ -592,7 +674,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
592
674
|
cardPreview: _cardPreview,
|
|
593
675
|
cardRef: null,
|
|
594
676
|
isBannedLocalPreview: false,
|
|
595
|
-
previewDidRender: false
|
|
677
|
+
previewDidRender: false,
|
|
678
|
+
error: _error
|
|
596
679
|
};
|
|
597
680
|
return _this;
|
|
598
681
|
}
|
|
@@ -601,21 +684,32 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
601
684
|
key: "componentDidMount",
|
|
602
685
|
value: function componentDidMount() {
|
|
603
686
|
this.hasBeenMounted = true;
|
|
604
|
-
var _this$
|
|
605
|
-
isCardVisible = _this$
|
|
606
|
-
cardPreview = _this$
|
|
607
|
-
var _this$
|
|
608
|
-
identifier = _this$
|
|
609
|
-
ssr = _this$
|
|
687
|
+
var _this$state4 = this.state,
|
|
688
|
+
isCardVisible = _this$state4.isCardVisible,
|
|
689
|
+
cardPreview = _this$state4.cardPreview;
|
|
690
|
+
var _this$props12 = this.props,
|
|
691
|
+
identifier = _this$props12.identifier,
|
|
692
|
+
ssr = _this$props12.ssr,
|
|
693
|
+
dimensions = _this$props12.dimensions;
|
|
610
694
|
|
|
611
695
|
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
612
696
|
this.updateStateForIdentifier(identifier);
|
|
613
697
|
}
|
|
614
698
|
|
|
615
|
-
if (isCardVisible && !!ssr && !!cardPreview &&
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
699
|
+
if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
|
|
700
|
+
var _this$ssrData2;
|
|
701
|
+
|
|
702
|
+
if (isSSRClientPreview(cardPreview)) {
|
|
703
|
+
// Since the SSR preview brings the token in the query params,
|
|
704
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
705
|
+
this.setCacheSSRPreview(identifier);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData2 = this.ssrData) === null || _this$ssrData2 === void 0 ? void 0 : _this$ssrData2.dimensions, dimensions)) {
|
|
709
|
+
// If dimensions from Server have changed and are bigger,
|
|
710
|
+
// we need to refetch
|
|
711
|
+
this.refetchSSRPreview(identifier);
|
|
712
|
+
}
|
|
619
713
|
} // we add a listener for each of the cards on the page
|
|
620
714
|
// and then check if the triggered listener is from the card
|
|
621
715
|
// that contains a div in current window.getSelection()
|
|
@@ -631,21 +725,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
631
725
|
prevIdentifier = prevProps.identifier,
|
|
632
726
|
prevDimensions = prevProps.dimensions;
|
|
633
727
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
634
|
-
var _this$
|
|
635
|
-
mediaClient = _this$
|
|
636
|
-
identifier = _this$
|
|
637
|
-
dimensions = _this$
|
|
638
|
-
featureFlags = _this$
|
|
639
|
-
useInlinePlayer = _this$
|
|
640
|
-
disableOverlay = _this$
|
|
641
|
-
var _this$
|
|
642
|
-
isCardVisible = _this$
|
|
643
|
-
cardPreview = _this$
|
|
644
|
-
status = _this$
|
|
645
|
-
fileState = _this$
|
|
646
|
-
isBannedLocalPreview = _this$
|
|
647
|
-
previewDidRender = _this$
|
|
648
|
-
isPlayingFile = _this$
|
|
728
|
+
var _this$props13 = this.props,
|
|
729
|
+
mediaClient = _this$props13.mediaClient,
|
|
730
|
+
identifier = _this$props13.identifier,
|
|
731
|
+
dimensions = _this$props13.dimensions,
|
|
732
|
+
featureFlags = _this$props13.featureFlags,
|
|
733
|
+
useInlinePlayer = _this$props13.useInlinePlayer,
|
|
734
|
+
disableOverlay = _this$props13.disableOverlay;
|
|
735
|
+
var _this$state5 = this.state,
|
|
736
|
+
isCardVisible = _this$state5.isCardVisible,
|
|
737
|
+
cardPreview = _this$state5.cardPreview,
|
|
738
|
+
status = _this$state5.status,
|
|
739
|
+
fileState = _this$state5.fileState,
|
|
740
|
+
isBannedLocalPreview = _this$state5.isBannedLocalPreview,
|
|
741
|
+
previewDidRender = _this$state5.previewDidRender,
|
|
742
|
+
isPlayingFile = _this$state5.isPlayingFile;
|
|
649
743
|
var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
650
744
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
651
745
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -761,8 +855,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
761
855
|
get: function get() {
|
|
762
856
|
var dimensions = this.props.dimensions;
|
|
763
857
|
|
|
764
|
-
var
|
|
765
|
-
element =
|
|
858
|
+
var _ref4 = this.state || {},
|
|
859
|
+
element = _ref4.cardRef;
|
|
766
860
|
|
|
767
861
|
return getRequestedDimensions({
|
|
768
862
|
dimensions: dimensions,
|
|
@@ -772,23 +866,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
772
866
|
}, {
|
|
773
867
|
key: "metadata",
|
|
774
868
|
get: function get() {
|
|
775
|
-
var _this$
|
|
869
|
+
var _this$state6;
|
|
776
870
|
|
|
777
|
-
return getFileDetails(this.props.identifier, (_this$
|
|
871
|
+
return getFileDetails(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
|
|
778
872
|
}
|
|
779
873
|
}, {
|
|
780
874
|
key: "fileAttributes",
|
|
781
875
|
get: function get() {
|
|
782
|
-
var _this$
|
|
876
|
+
var _this$state7, _this$state7$fileStat;
|
|
783
877
|
|
|
784
|
-
return getFileAttributes(this.metadata, (_this$
|
|
878
|
+
return 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);
|
|
785
879
|
}
|
|
786
880
|
}, {
|
|
787
881
|
key: "fireOperationalEvent",
|
|
788
882
|
value: function fireOperationalEvent() {
|
|
789
|
-
var _this$
|
|
790
|
-
status = _this$
|
|
791
|
-
error = _this$
|
|
883
|
+
var _this$state8 = this.state,
|
|
884
|
+
status = _this$state8.status,
|
|
885
|
+
error = _this$state8.error;
|
|
792
886
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
793
887
|
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
|
|
794
888
|
}
|
|
@@ -808,11 +902,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
808
902
|
get: function get() {
|
|
809
903
|
var _this3 = this;
|
|
810
904
|
|
|
811
|
-
var _this$
|
|
812
|
-
_this$
|
|
813
|
-
actions = _this$
|
|
814
|
-
identifier = _this$
|
|
815
|
-
shouldEnableDownloadButton = _this$
|
|
905
|
+
var _this$props14 = this.props,
|
|
906
|
+
_this$props14$actions = _this$props14.actions,
|
|
907
|
+
actions = _this$props14$actions === void 0 ? [] : _this$props14$actions,
|
|
908
|
+
identifier = _this$props14.identifier,
|
|
909
|
+
shouldEnableDownloadButton = _this$props14.shouldEnableDownloadButton;
|
|
816
910
|
var status = this.state.status;
|
|
817
911
|
var metadata = this.metadata;
|
|
818
912
|
|
|
@@ -834,10 +928,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
834
928
|
}, {
|
|
835
929
|
key: "render",
|
|
836
930
|
value: function render() {
|
|
837
|
-
var _this$
|
|
838
|
-
isPlayingFile = _this$
|
|
839
|
-
mediaViewerSelectedItem = _this$
|
|
840
|
-
var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
|
|
931
|
+
var _this$state9 = this.state,
|
|
932
|
+
isPlayingFile = _this$state9.isPlayingFile,
|
|
933
|
+
mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
|
|
934
|
+
var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
|
|
841
935
|
return this.props.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
842
936
|
locale: "en"
|
|
843
937
|
}, innerContent);
|