@atlaskit/media-card 74.5.2 → 74.6.1
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 +17 -0
- package/dist/cjs/card/card.js +203 -123
- package/dist/cjs/card/getCardPreview/index.js +4 -2
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/card/card.js +99 -40
- package/dist/es2019/card/getCardPreview/index.js +4 -2
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/card/card.js +203 -123
- package/dist/esm/card/getCardPreview/index.js +4 -2
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/card/card.d.ts +3 -0
- package/dist/types/card/getCardPreview/index.d.ts +2 -1
- package/dist/types/types.d.ts +1 -0
- package/package.json +7 -5
- package/report.api.md +2 -0
package/dist/esm/card/card.js
CHANGED
|
@@ -39,7 +39,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
|
|
|
39
39
|
import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
|
|
40
40
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
41
41
|
var packageName = "@atlaskit/media-card";
|
|
42
|
-
var packageVersion = "74.
|
|
42
|
+
var packageVersion = "74.6.1";
|
|
43
43
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
44
44
|
_inherits(CardBase, _Component);
|
|
45
45
|
var _super = _createSuper(CardBase);
|
|
@@ -127,11 +127,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
129
|
_defineProperty(_assertThisInitialized(_this), "setCacheSSRPreview", function (identifier) {
|
|
130
|
-
|
|
131
|
-
mediaClient = _this$props3.mediaClient,
|
|
132
|
-
_this$props3$dimensio = _this$props3.dimensions,
|
|
133
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
134
|
-
fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {
|
|
130
|
+
_this.fetchAndCacheRemotePreview(identifier).catch(function () {
|
|
135
131
|
// No need to log this error.
|
|
136
132
|
// If preview fails, it will be refetched later
|
|
137
133
|
//TODO: test this catch
|
|
@@ -140,60 +136,113 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
140
136
|
});
|
|
141
137
|
_defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
|
|
142
138
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
|
|
143
|
-
var
|
|
139
|
+
var cardPreview, wrappedError;
|
|
144
140
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
145
141
|
while (1) {
|
|
146
142
|
switch (_context.prev = _context.next) {
|
|
147
143
|
case 0:
|
|
148
|
-
|
|
149
|
-
_context.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
case 4:
|
|
144
|
+
_context.prev = 0;
|
|
145
|
+
_context.next = 3;
|
|
146
|
+
return _this.fetchAndCacheRemotePreview(identifier);
|
|
147
|
+
case 3:
|
|
153
148
|
cardPreview = _context.sent;
|
|
154
149
|
_this.safeSetState({
|
|
155
150
|
cardPreview: cardPreview
|
|
156
151
|
});
|
|
157
|
-
_context.next =
|
|
152
|
+
_context.next = 11;
|
|
158
153
|
break;
|
|
159
|
-
case
|
|
160
|
-
_context.prev =
|
|
161
|
-
_context.t0 = _context["catch"](
|
|
154
|
+
case 7:
|
|
155
|
+
_context.prev = 7;
|
|
156
|
+
_context.t0 = _context["catch"](0);
|
|
162
157
|
wrappedError = ensureMediaCardError('remote-preview-fetch-ssr', _context.t0, true);
|
|
163
158
|
_this.fireNonCriticalErrorEvent(wrappedError);
|
|
164
|
-
case
|
|
159
|
+
case 11:
|
|
165
160
|
case "end":
|
|
166
161
|
return _context.stop();
|
|
167
162
|
}
|
|
168
163
|
}
|
|
169
|
-
}, _callee, null, [[
|
|
164
|
+
}, _callee, null, [[0, 7]]);
|
|
170
165
|
}));
|
|
171
166
|
return function (_x) {
|
|
172
167
|
return _ref2.apply(this, arguments);
|
|
173
168
|
};
|
|
174
169
|
}());
|
|
175
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
176
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier
|
|
177
|
-
var
|
|
170
|
+
_defineProperty(_assertThisInitialized(_this), "resolveUpfrontPreview", /*#__PURE__*/function () {
|
|
171
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier) {
|
|
172
|
+
var requestedDimensions, cardPreview, currentDimensions, areValidRequestedDimensions;
|
|
178
173
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
179
174
|
while (1) {
|
|
180
175
|
switch (_context2.prev = _context2.next) {
|
|
181
176
|
case 0:
|
|
182
|
-
|
|
183
|
-
|
|
177
|
+
requestedDimensions = _objectSpread({}, _this.props.dimensions);
|
|
178
|
+
_context2.prev = 1;
|
|
184
179
|
_context2.next = 4;
|
|
185
|
-
return
|
|
180
|
+
return _this.fetchAndCacheRemotePreview(identifier);
|
|
186
181
|
case 4:
|
|
187
182
|
cardPreview = _context2.sent;
|
|
183
|
+
currentDimensions = _this.props.dimensions;
|
|
184
|
+
areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
|
|
185
|
+
// the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
|
|
186
|
+
// to trigger a normal preview fetch.
|
|
187
|
+
if (areValidRequestedDimensions) {
|
|
188
|
+
_this.safeSetState({
|
|
189
|
+
cardPreview: cardPreview,
|
|
190
|
+
wasResolvedUpfrontPreview: true
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
_this.safeSetState({
|
|
194
|
+
wasResolvedUpfrontPreview: true
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
_context2.next = 13;
|
|
198
|
+
break;
|
|
199
|
+
case 10:
|
|
200
|
+
_context2.prev = 10;
|
|
201
|
+
_context2.t0 = _context2["catch"](1);
|
|
202
|
+
_this.safeSetState({
|
|
203
|
+
wasResolvedUpfrontPreview: true
|
|
204
|
+
});
|
|
205
|
+
// NO need to log error. If this call fails, a refetch will happen after
|
|
206
|
+
case 13:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context2.stop();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}, _callee2, null, [[1, 10]]);
|
|
212
|
+
}));
|
|
213
|
+
return function (_x2) {
|
|
214
|
+
return _ref3.apply(this, arguments);
|
|
215
|
+
};
|
|
216
|
+
}());
|
|
217
|
+
_defineProperty(_assertThisInitialized(_this), "fetchAndCacheRemotePreview", function (identifier) {
|
|
218
|
+
var _this$props3 = _this.props,
|
|
219
|
+
mediaClient = _this$props3.mediaClient,
|
|
220
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
221
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
222
|
+
return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
223
|
+
});
|
|
224
|
+
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
225
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(identifier, fileState) {
|
|
226
|
+
var params, cardPreview, wrappedError;
|
|
227
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
228
|
+
while (1) {
|
|
229
|
+
switch (_context3.prev = _context3.next) {
|
|
230
|
+
case 0:
|
|
231
|
+
_context3.prev = 0;
|
|
232
|
+
params = _this.getCardPreviewParams(identifier, fileState);
|
|
233
|
+
_context3.next = 4;
|
|
234
|
+
return getCardPreview(params);
|
|
235
|
+
case 4:
|
|
236
|
+
cardPreview = _context3.sent;
|
|
188
237
|
_this.safeSetState({
|
|
189
238
|
cardPreview: cardPreview
|
|
190
239
|
});
|
|
191
|
-
|
|
240
|
+
_context3.next = 12;
|
|
192
241
|
break;
|
|
193
242
|
case 8:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
wrappedError = ensureMediaCardError('preview-fetch',
|
|
243
|
+
_context3.prev = 8;
|
|
244
|
+
_context3.t0 = _context3["catch"](0);
|
|
245
|
+
wrappedError = ensureMediaCardError('preview-fetch', _context3.t0); // If remote preview fails, we set status 'error'
|
|
197
246
|
// If local preview fails (i.e, no remote preview available),
|
|
198
247
|
// we can stay in the same status until there is a remote preview available
|
|
199
248
|
// If it's any other error we set status 'error'
|
|
@@ -210,13 +259,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
210
259
|
}
|
|
211
260
|
case 12:
|
|
212
261
|
case "end":
|
|
213
|
-
return
|
|
262
|
+
return _context3.stop();
|
|
214
263
|
}
|
|
215
264
|
}
|
|
216
|
-
},
|
|
265
|
+
}, _callee3, null, [[0, 8]]);
|
|
217
266
|
}));
|
|
218
|
-
return function (
|
|
219
|
-
return
|
|
267
|
+
return function (_x3, _x4) {
|
|
268
|
+
return _ref4.apply(this, arguments);
|
|
220
269
|
};
|
|
221
270
|
}());
|
|
222
271
|
_defineProperty(_assertThisInitialized(_this), "getPerformanceAttributes", function () {
|
|
@@ -268,9 +317,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
268
317
|
updateState.isBannedLocalPreview = true;
|
|
269
318
|
_this.fireNonCriticalErrorEvent(error);
|
|
270
319
|
}
|
|
271
|
-
var _this$
|
|
272
|
-
identifier = _this$
|
|
273
|
-
resizeMode = _this$
|
|
320
|
+
var _this$props4 = _this.props,
|
|
321
|
+
identifier = _this$props4.identifier,
|
|
322
|
+
resizeMode = _this$props4.resizeMode;
|
|
274
323
|
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
275
324
|
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, fileImageMode);
|
|
276
325
|
_this.safeSetState(updateState);
|
|
@@ -349,10 +398,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
349
398
|
}
|
|
350
399
|
});
|
|
351
400
|
_defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
352
|
-
var _this$
|
|
353
|
-
identifier = _this$
|
|
354
|
-
useInlinePlayer = _this$
|
|
355
|
-
shouldOpenMediaViewer = _this$
|
|
401
|
+
var _this$props5 = _this.props,
|
|
402
|
+
identifier = _this$props5.identifier,
|
|
403
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
404
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
356
405
|
var cardPreview = _this.state.cardPreview;
|
|
357
406
|
var _assertThisInitialize2 = _assertThisInitialized(_this),
|
|
358
407
|
metadata = _assertThisInitialize2.metadata;
|
|
@@ -398,14 +447,14 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
398
447
|
});
|
|
399
448
|
});
|
|
400
449
|
_defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
|
|
401
|
-
var _this$
|
|
402
|
-
identifier = _this$
|
|
403
|
-
mediaClient = _this$
|
|
404
|
-
dimensions = _this$
|
|
405
|
-
selected = _this$
|
|
406
|
-
testId = _this$
|
|
407
|
-
originalDimensions = _this$
|
|
408
|
-
onFullscreenChange = _this$
|
|
450
|
+
var _this$props6 = _this.props,
|
|
451
|
+
identifier = _this$props6.identifier,
|
|
452
|
+
mediaClient = _this$props6.mediaClient,
|
|
453
|
+
dimensions = _this$props6.dimensions,
|
|
454
|
+
selected = _this$props6.selected,
|
|
455
|
+
testId = _this$props6.testId,
|
|
456
|
+
originalDimensions = _this$props6.originalDimensions,
|
|
457
|
+
onFullscreenChange = _this$props6.onFullscreenChange;
|
|
409
458
|
var _this$state = _this.state,
|
|
410
459
|
shouldAutoplay = _this$state.shouldAutoplay,
|
|
411
460
|
cardPreview = _this$state.cardPreview;
|
|
@@ -452,12 +501,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
452
501
|
});
|
|
453
502
|
_defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
|
|
454
503
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
455
|
-
var _this$
|
|
456
|
-
mediaClient = _this$
|
|
457
|
-
identifier = _this$
|
|
458
|
-
mediaViewerDataSource = _this$
|
|
459
|
-
contextId = _this$
|
|
460
|
-
featureFlags = _this$
|
|
504
|
+
var _this$props7 = _this.props,
|
|
505
|
+
mediaClient = _this$props7.mediaClient,
|
|
506
|
+
identifier = _this$props7.identifier,
|
|
507
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
508
|
+
contextId = _this$props7.contextId,
|
|
509
|
+
featureFlags = _this$props7.featureFlags;
|
|
461
510
|
if (!mediaViewerSelectedItem) {
|
|
462
511
|
return;
|
|
463
512
|
}
|
|
@@ -479,23 +528,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
479
528
|
var withCallbacks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
480
529
|
var cardStatusOverride = arguments.length > 1 ? arguments[1] : undefined;
|
|
481
530
|
var izLazyOverride = arguments.length > 2 ? arguments[2] : undefined;
|
|
482
|
-
var _this$
|
|
483
|
-
identifier = _this$
|
|
484
|
-
isLazy = _this$
|
|
485
|
-
appearance = _this$
|
|
486
|
-
resizeMode = _this$
|
|
487
|
-
dimensions = _this$
|
|
488
|
-
selectable = _this$
|
|
489
|
-
selected = _this$
|
|
490
|
-
disableOverlay = _this$
|
|
491
|
-
alt = _this$
|
|
492
|
-
testId = _this$
|
|
493
|
-
featureFlags = _this$
|
|
494
|
-
titleBoxBgColor = _this$
|
|
495
|
-
titleBoxIcon = _this$
|
|
496
|
-
ssr = _this$
|
|
497
|
-
useInlinePlayer = _this$
|
|
498
|
-
shouldOpenMediaViewer = _this$
|
|
531
|
+
var _this$props8 = _this.props,
|
|
532
|
+
identifier = _this$props8.identifier,
|
|
533
|
+
isLazy = _this$props8.isLazy,
|
|
534
|
+
appearance = _this$props8.appearance,
|
|
535
|
+
resizeMode = _this$props8.resizeMode,
|
|
536
|
+
dimensions = _this$props8.dimensions,
|
|
537
|
+
selectable = _this$props8.selectable,
|
|
538
|
+
selected = _this$props8.selected,
|
|
539
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
540
|
+
alt = _this$props8.alt,
|
|
541
|
+
testId = _this$props8.testId,
|
|
542
|
+
featureFlags = _this$props8.featureFlags,
|
|
543
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
544
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
545
|
+
ssr = _this$props8.ssr,
|
|
546
|
+
useInlinePlayer = _this$props8.useInlinePlayer,
|
|
547
|
+
shouldOpenMediaViewer = _this$props8.shouldOpenMediaViewer;
|
|
499
548
|
var mediaItemType = identifier.mediaItemType;
|
|
500
549
|
var _this$state2 = _this.state,
|
|
501
550
|
status = _this$state2.status,
|
|
@@ -555,9 +604,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
555
604
|
});
|
|
556
605
|
_defineProperty(_assertThisInitialized(_this), "storeSSRData", function () {
|
|
557
606
|
var _this$ssrReliability$;
|
|
558
|
-
var _this$
|
|
559
|
-
ssr = _this$
|
|
560
|
-
identifier = _this$
|
|
607
|
+
var _this$props9 = _this.props,
|
|
608
|
+
ssr = _this$props9.ssr,
|
|
609
|
+
identifier = _this$props9.identifier;
|
|
561
610
|
var _this$state$cardPrevi = _this.state.cardPreview;
|
|
562
611
|
_this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
|
|
563
612
|
var dataURI = _this$state$cardPrevi.dataURI;
|
|
@@ -600,37 +649,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
600
649
|
var _status = 'loading';
|
|
601
650
|
var _cardPreview;
|
|
602
651
|
var _error;
|
|
603
|
-
var _this$
|
|
604
|
-
_identifier = _this$
|
|
605
|
-
_resizeMode = _this$
|
|
606
|
-
_ssr = _this$
|
|
607
|
-
_mediaClient = _this$
|
|
652
|
+
var _this$props10 = _this.props,
|
|
653
|
+
_identifier = _this$props10.identifier,
|
|
654
|
+
_resizeMode = _this$props10.resizeMode,
|
|
655
|
+
_ssr = _this$props10.ssr,
|
|
656
|
+
_mediaClient = _this$props10.mediaClient;
|
|
608
657
|
if (isFileIdentifier(_identifier)) {
|
|
609
658
|
var id = _identifier.id;
|
|
610
659
|
var fileImageMode = imageResizeModeToFileImageMode(_resizeMode);
|
|
611
660
|
_cardPreview = getCardPreviewFromCache(id, fileImageMode);
|
|
612
661
|
if (!_cardPreview && _ssr) {
|
|
613
|
-
|
|
614
|
-
_this.ssrData = getSSRData(_identifier);
|
|
615
|
-
if ((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
616
|
-
_this.ssrReliability.server = _objectSpread({
|
|
617
|
-
status: 'fail'
|
|
618
|
-
}, _this.ssrData.error);
|
|
619
|
-
}
|
|
620
|
-
if (!((_this$ssrData2 = _this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
621
|
-
try {
|
|
622
|
-
_cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
|
|
623
|
-
} catch (e) {
|
|
624
|
-
_this.ssrReliability[_ssr] = _objectSpread({
|
|
625
|
-
status: 'fail'
|
|
626
|
-
}, extractErrorInfo(e));
|
|
627
|
-
}
|
|
628
|
-
} else {
|
|
629
|
-
_cardPreview = {
|
|
630
|
-
dataURI: _this.ssrData.dataURI,
|
|
631
|
-
source: 'ssr-data'
|
|
632
|
-
};
|
|
633
|
-
}
|
|
662
|
+
_cardPreview = _this.getSSRPreview(_ssr, _identifier, _mediaClient);
|
|
634
663
|
}
|
|
635
664
|
} else if (isExternalImageIdentifier(_identifier)) {
|
|
636
665
|
_this.fireCommencedEvent();
|
|
@@ -657,11 +686,37 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
657
686
|
cardRef: null,
|
|
658
687
|
isBannedLocalPreview: false,
|
|
659
688
|
previewDidRender: false,
|
|
660
|
-
error: _error
|
|
689
|
+
error: _error,
|
|
690
|
+
wasResolvedUpfrontPreview: false
|
|
661
691
|
};
|
|
662
692
|
return _this;
|
|
663
693
|
}
|
|
664
694
|
_createClass(CardBase, [{
|
|
695
|
+
key: "getSSRPreview",
|
|
696
|
+
value: function getSSRPreview(ssr, identifier, mediaClient) {
|
|
697
|
+
var _this$ssrData, _this$ssrData2;
|
|
698
|
+
this.ssrData = getSSRData(identifier);
|
|
699
|
+
if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
700
|
+
this.ssrReliability.server = _objectSpread({
|
|
701
|
+
status: 'fail'
|
|
702
|
+
}, this.ssrData.error);
|
|
703
|
+
}
|
|
704
|
+
if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
705
|
+
try {
|
|
706
|
+
return getSSRCardPreview(ssr, mediaClient, identifier.id, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
|
|
707
|
+
} catch (e) {
|
|
708
|
+
this.ssrReliability[ssr] = _objectSpread({
|
|
709
|
+
status: 'fail'
|
|
710
|
+
}, extractErrorInfo(e));
|
|
711
|
+
}
|
|
712
|
+
} else {
|
|
713
|
+
return {
|
|
714
|
+
dataURI: this.ssrData.dataURI,
|
|
715
|
+
source: 'ssr-data'
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}, {
|
|
665
720
|
key: "componentDidMount",
|
|
666
721
|
value: function componentDidMount() {
|
|
667
722
|
var _getDocument;
|
|
@@ -669,12 +724,15 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
669
724
|
var _this$state3 = this.state,
|
|
670
725
|
isCardVisible = _this$state3.isCardVisible,
|
|
671
726
|
cardPreview = _this$state3.cardPreview;
|
|
672
|
-
var _this$
|
|
673
|
-
identifier = _this$
|
|
674
|
-
ssr = _this$
|
|
675
|
-
dimensions = _this$
|
|
727
|
+
var _this$props11 = this.props,
|
|
728
|
+
identifier = _this$props11.identifier,
|
|
729
|
+
ssr = _this$props11.ssr,
|
|
730
|
+
dimensions = _this$props11.dimensions;
|
|
676
731
|
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
677
732
|
this.updateStateForIdentifier(identifier);
|
|
733
|
+
if (!cardPreview) {
|
|
734
|
+
this.resolveUpfrontPreview(identifier);
|
|
735
|
+
}
|
|
678
736
|
}
|
|
679
737
|
if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
|
|
680
738
|
var _this$ssrData3;
|
|
@@ -701,15 +759,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
701
759
|
var prevMediaClient = prevProps.mediaClient,
|
|
702
760
|
prevIdentifier = prevProps.identifier,
|
|
703
761
|
prevDimensions = prevProps.dimensions;
|
|
704
|
-
var prevIsCardVisible = prevState.isCardVisible
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
762
|
+
var prevIsCardVisible = prevState.isCardVisible,
|
|
763
|
+
prevCardPreview = prevState.cardPreview;
|
|
764
|
+
var _this$props12 = this.props,
|
|
765
|
+
mediaClient = _this$props12.mediaClient,
|
|
766
|
+
identifier = _this$props12.identifier,
|
|
767
|
+
dimensions = _this$props12.dimensions,
|
|
768
|
+
featureFlags = _this$props12.featureFlags,
|
|
769
|
+
useInlinePlayer = _this$props12.useInlinePlayer,
|
|
770
|
+
disableOverlay = _this$props12.disableOverlay,
|
|
771
|
+
resizeMode = _this$props12.resizeMode,
|
|
772
|
+
ssr = _this$props12.ssr;
|
|
713
773
|
var _this$state4 = this.state,
|
|
714
774
|
isCardVisible = _this$state4.isCardVisible,
|
|
715
775
|
cardPreview = _this$state4.cardPreview,
|
|
@@ -717,9 +777,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
717
777
|
fileState = _this$state4.fileState,
|
|
718
778
|
isBannedLocalPreview = _this$state4.isBannedLocalPreview,
|
|
719
779
|
previewDidRender = _this$state4.previewDidRender,
|
|
720
|
-
isPlayingFile = _this$state4.isPlayingFile
|
|
780
|
+
isPlayingFile = _this$state4.isPlayingFile,
|
|
781
|
+
wasResolvedUpfrontPreview = _this$state4.wasResolvedUpfrontPreview;
|
|
721
782
|
var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
783
|
+
/**
|
|
784
|
+
* Variable turnedVisible should only be true when media card
|
|
785
|
+
* was invisible in the previous state and is visible in the current one
|
|
786
|
+
*
|
|
787
|
+
* prevIsCardVisible | isCardVisible | turnedVisible
|
|
788
|
+
* ----------------------------------------------------
|
|
789
|
+
* false | false | false
|
|
790
|
+
* false | true | true
|
|
791
|
+
* true | true | false
|
|
792
|
+
* true | false | false (unreachable case)
|
|
793
|
+
* ----------------------------------------------------
|
|
794
|
+
*/
|
|
722
795
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
796
|
+
var hadSSRCardPreview = !!prevCardPreview && isSSRClientPreview(prevCardPreview) && !cardPreview;
|
|
723
797
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
724
798
|
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
725
799
|
this.updateFileStateFlag(fileState);
|
|
@@ -745,7 +819,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
745
819
|
this.fireScreenEvent();
|
|
746
820
|
}
|
|
747
821
|
}
|
|
748
|
-
if (isFileIdentifier(identifier) &&
|
|
822
|
+
if (isFileIdentifier(identifier) && (turnedVisible || ssr === 'client' && hadSSRCardPreview) && !cardPreview && !wasResolvedUpfrontPreview) {
|
|
823
|
+
// This is a one-off call, only meant to happen once in the component's lifecycle. Mainly when either:
|
|
824
|
+
// - turnedVisible = true
|
|
825
|
+
// - ssr = client and has no preview (the dataURI failed to load in the previous state, most likely because of an initial auth issue)
|
|
826
|
+
this.resolveUpfrontPreview(identifier);
|
|
827
|
+
} else if (isFileIdentifier(identifier) && fileState && shouldResolvePreview({
|
|
749
828
|
status: status,
|
|
750
829
|
fileState: fileState,
|
|
751
830
|
prevDimensions: prevDimensions,
|
|
@@ -754,7 +833,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
754
833
|
fileImageMode: fileImageMode,
|
|
755
834
|
featureFlags: featureFlags,
|
|
756
835
|
hasCardPreview: !!cardPreview,
|
|
757
|
-
isBannedLocalPreview: isBannedLocalPreview
|
|
836
|
+
isBannedLocalPreview: isBannedLocalPreview,
|
|
837
|
+
wasResolvedUpfrontPreview: wasResolvedUpfrontPreview
|
|
758
838
|
})) {
|
|
759
839
|
this.resolvePreview(identifier, fileState);
|
|
760
840
|
}
|
|
@@ -839,8 +919,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
839
919
|
key: "requestedDimensions",
|
|
840
920
|
get: function get() {
|
|
841
921
|
var dimensions = this.props.dimensions;
|
|
842
|
-
var
|
|
843
|
-
element =
|
|
922
|
+
var _ref5 = this.state || {},
|
|
923
|
+
element = _ref5.cardRef;
|
|
844
924
|
return getRequestedDimensions({
|
|
845
925
|
dimensions: dimensions,
|
|
846
926
|
element: element
|
|
@@ -885,11 +965,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
885
965
|
key: "actions",
|
|
886
966
|
get: function get() {
|
|
887
967
|
var _this3 = this;
|
|
888
|
-
var _this$
|
|
889
|
-
_this$
|
|
890
|
-
actions = _this$
|
|
891
|
-
identifier = _this$
|
|
892
|
-
shouldEnableDownloadButton = _this$
|
|
968
|
+
var _this$props13 = this.props,
|
|
969
|
+
_this$props13$actions = _this$props13.actions,
|
|
970
|
+
actions = _this$props13$actions === void 0 ? [] : _this$props13$actions,
|
|
971
|
+
identifier = _this$props13.identifier,
|
|
972
|
+
shouldEnableDownloadButton = _this$props13.shouldEnableDownloadButton;
|
|
893
973
|
var status = this.state.status;
|
|
894
974
|
var metadata = this.metadata;
|
|
895
975
|
if (isFileIdentifier(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
|
|
@@ -170,10 +170,12 @@ export var shouldResolvePreview = function shouldResolvePreview(_ref3) {
|
|
|
170
170
|
fileImageMode = _ref3.fileImageMode,
|
|
171
171
|
hasCardPreview = _ref3.hasCardPreview,
|
|
172
172
|
isBannedLocalPreview = _ref3.isBannedLocalPreview,
|
|
173
|
-
featureFlags = _ref3.featureFlags
|
|
173
|
+
featureFlags = _ref3.featureFlags,
|
|
174
|
+
wasResolvedUpfrontPreview = _ref3.wasResolvedUpfrontPreview;
|
|
174
175
|
var statusIsPreviewable = isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview, featureFlags));
|
|
175
176
|
var dimensionsAreBigger = isBigger(prevDimensions, dimensions);
|
|
176
|
-
|
|
177
|
+
// We should not fetch the preview if the upfront one hasn't been resolved yet (it could be resolving now), even if there are new dimensions.
|
|
178
|
+
return wasResolvedUpfrontPreview && statusIsPreviewable && (!hasCardPreview || dimensionsAreBigger);
|
|
177
179
|
};
|
|
178
180
|
export var getSSRCardPreview = function getSSRCardPreview(ssr, mediaClient, id, params, mediaBlobUrlAttrs) {
|
|
179
181
|
var dataURI;
|
|
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
83
83
|
}(React.Component);
|
|
84
84
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
85
85
|
var packageName = "@atlaskit/media-card";
|
|
86
|
-
var packageVersion = "74.
|
|
86
|
+
var packageVersion = "74.6.1";
|
|
87
87
|
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
88
88
|
packageVersion: packageVersion,
|
|
89
89
|
packageName: packageName,
|
|
@@ -70,7 +70,7 @@ var WrappedMediaInlineAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Com
|
|
|
70
70
|
}(React.Component);
|
|
71
71
|
_defineProperty(WrappedMediaInlineAnalyticsErrorBoundary, "displayName", 'MediaInlineAnalyticsErrorBoundary');
|
|
72
72
|
var packageName = "@atlaskit/media-card";
|
|
73
|
-
var packageVersion = "74.
|
|
73
|
+
var packageVersion = "74.6.1";
|
|
74
74
|
var MediaInlineAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
75
75
|
packageVersion: packageVersion,
|
|
76
76
|
packageName: packageName,
|
|
@@ -6,7 +6,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata, LOGGED_FEATURE_FLAG_KE
|
|
|
6
6
|
import { MediaCardError } from '../errors';
|
|
7
7
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
8
8
|
var packageName = "@atlaskit/media-card";
|
|
9
|
-
var packageVersion = "74.
|
|
9
|
+
var packageVersion = "74.6.1";
|
|
10
10
|
var concurrentExperience;
|
|
11
11
|
var getExperience = function getExperience(id) {
|
|
12
12
|
if (!concurrentExperience) {
|
package/dist/esm/version.json
CHANGED
|
@@ -16,6 +16,7 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
|
|
|
16
16
|
private traceContext;
|
|
17
17
|
static defaultProps: Partial<CardProps>;
|
|
18
18
|
constructor(props: CardBaseProps);
|
|
19
|
+
private getSSRPreview;
|
|
19
20
|
componentDidMount(): void;
|
|
20
21
|
componentDidUpdate(prevProps: CardProps, prevState: CardState): void;
|
|
21
22
|
componentWillUnmount(): void;
|
|
@@ -25,6 +26,8 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
|
|
|
25
26
|
private getCardPreviewParams;
|
|
26
27
|
private setCacheSSRPreview;
|
|
27
28
|
private refetchSSRPreview;
|
|
29
|
+
private resolveUpfrontPreview;
|
|
30
|
+
private fetchAndCacheRemotePreview;
|
|
28
31
|
private resolvePreview;
|
|
29
32
|
updateFileStateFlag(fileState?: FileState): void;
|
|
30
33
|
subscribeInternalFile(identifier: FileIdentifier): void;
|
|
@@ -38,7 +38,7 @@ export declare type CardPreviewParams = {
|
|
|
38
38
|
* hence the use of the optional callback onLocalPreviewError
|
|
39
39
|
*/
|
|
40
40
|
export declare const getCardPreview: ({ mediaClient, id, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, createAnalyticsEvent, featureFlags, traceContext, }: CardPreviewParams) => Promise<CardPreview>;
|
|
41
|
-
export declare const shouldResolvePreview: ({ status, fileState, prevDimensions, dimensions, identifier, fileImageMode, hasCardPreview, isBannedLocalPreview, featureFlags, }: {
|
|
41
|
+
export declare const shouldResolvePreview: ({ status, fileState, prevDimensions, dimensions, identifier, fileImageMode, hasCardPreview, isBannedLocalPreview, featureFlags, wasResolvedUpfrontPreview, }: {
|
|
42
42
|
status: CardStatus;
|
|
43
43
|
fileState: FileState;
|
|
44
44
|
prevDimensions?: CardDimensions | undefined;
|
|
@@ -48,6 +48,7 @@ export declare const shouldResolvePreview: ({ status, fileState, prevDimensions,
|
|
|
48
48
|
hasCardPreview: boolean;
|
|
49
49
|
isBannedLocalPreview: boolean;
|
|
50
50
|
featureFlags?: MediaFeatureFlags | undefined;
|
|
51
|
+
wasResolvedUpfrontPreview: boolean;
|
|
51
52
|
}) => boolean;
|
|
52
53
|
export declare const getSSRCardPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs | undefined) => CardPreview;
|
|
53
54
|
export declare const isLocalPreview: (preview: CardPreview) => boolean;
|
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-card",
|
|
3
|
-
"version": "74.
|
|
3
|
+
"version": "74.6.1",
|
|
4
4
|
"description": "Includes all media card related components, CardView, CardViewSmall, Card...",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/analytics-next": "^
|
|
32
|
-
"@atlaskit/dropdown-menu": "^11.
|
|
31
|
+
"@atlaskit/analytics-next": "^9.0.0",
|
|
32
|
+
"@atlaskit/dropdown-menu": "^11.6.0",
|
|
33
33
|
"@atlaskit/editor-shared-styles": "^2.3.0",
|
|
34
34
|
"@atlaskit/icon": "^21.11.0",
|
|
35
35
|
"@atlaskit/media-client": "^20.0.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/media-viewer": "^47.4.0",
|
|
39
39
|
"@atlaskit/spinner": "^15.3.0",
|
|
40
40
|
"@atlaskit/theme": "^12.2.0",
|
|
41
|
-
"@atlaskit/tokens": "^1.
|
|
41
|
+
"@atlaskit/tokens": "^1.2.0",
|
|
42
42
|
"@atlaskit/tooltip": "^17.6.0",
|
|
43
43
|
"@atlaskit/ufo": "^0.1.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
@@ -89,7 +89,9 @@
|
|
|
89
89
|
},
|
|
90
90
|
"techstack": {
|
|
91
91
|
"@repo/internal": {
|
|
92
|
-
"
|
|
92
|
+
"design-tokens": [
|
|
93
|
+
"color"
|
|
94
|
+
]
|
|
93
95
|
}
|
|
94
96
|
},
|
|
95
97
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|