@atlaskit/media-card 74.5.2 → 74.6.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 +11 -0
- package/dist/cjs/card/card.js +197 -122
- 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 +92 -38
- 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 +197 -122
- 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 +6 -4
- package/report.api.md +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 74.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`dbd7cd19fe6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dbd7cd19fe6) - Media Card now fetch the preview immediately after mounting, without waiting for file state to be ready
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`337bec022b4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/337bec022b4) - Fixes logic for upfront preview
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 74.5.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -47,7 +47,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
47
47
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
48
48
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
49
|
var packageName = "@atlaskit/media-card";
|
|
50
|
-
var packageVersion = "74.
|
|
50
|
+
var packageVersion = "74.6.0";
|
|
51
51
|
var CardBase = /*#__PURE__*/function (_Component) {
|
|
52
52
|
(0, _inherits2.default)(CardBase, _Component);
|
|
53
53
|
var _super = _createSuper(CardBase);
|
|
@@ -135,11 +135,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
137
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setCacheSSRPreview", function (identifier) {
|
|
138
|
-
|
|
139
|
-
mediaClient = _this$props3.mediaClient,
|
|
140
|
-
_this$props3$dimensio = _this$props3.dimensions,
|
|
141
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
142
|
-
(0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {
|
|
138
|
+
_this.fetchAndCacheRemotePreview(identifier).catch(function () {
|
|
143
139
|
// No need to log this error.
|
|
144
140
|
// If preview fails, it will be refetched later
|
|
145
141
|
//TODO: test this catch
|
|
@@ -148,60 +144,113 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
148
144
|
});
|
|
149
145
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "refetchSSRPreview", /*#__PURE__*/function () {
|
|
150
146
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier) {
|
|
151
|
-
var
|
|
147
|
+
var cardPreview, wrappedError;
|
|
152
148
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
153
149
|
while (1) {
|
|
154
150
|
switch (_context.prev = _context.next) {
|
|
155
151
|
case 0:
|
|
156
|
-
|
|
157
|
-
_context.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case 4:
|
|
152
|
+
_context.prev = 0;
|
|
153
|
+
_context.next = 3;
|
|
154
|
+
return _this.fetchAndCacheRemotePreview(identifier);
|
|
155
|
+
case 3:
|
|
161
156
|
cardPreview = _context.sent;
|
|
162
157
|
_this.safeSetState({
|
|
163
158
|
cardPreview: cardPreview
|
|
164
159
|
});
|
|
165
|
-
_context.next =
|
|
160
|
+
_context.next = 11;
|
|
166
161
|
break;
|
|
167
|
-
case
|
|
168
|
-
_context.prev =
|
|
169
|
-
_context.t0 = _context["catch"](
|
|
162
|
+
case 7:
|
|
163
|
+
_context.prev = 7;
|
|
164
|
+
_context.t0 = _context["catch"](0);
|
|
170
165
|
wrappedError = (0, _errors.ensureMediaCardError)('remote-preview-fetch-ssr', _context.t0, true);
|
|
171
166
|
_this.fireNonCriticalErrorEvent(wrappedError);
|
|
172
|
-
case
|
|
167
|
+
case 11:
|
|
173
168
|
case "end":
|
|
174
169
|
return _context.stop();
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
|
-
}, _callee, null, [[
|
|
172
|
+
}, _callee, null, [[0, 7]]);
|
|
178
173
|
}));
|
|
179
174
|
return function (_x) {
|
|
180
175
|
return _ref2.apply(this, arguments);
|
|
181
176
|
};
|
|
182
177
|
}());
|
|
183
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
184
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(identifier
|
|
185
|
-
var
|
|
178
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveUpfrontPreview", /*#__PURE__*/function () {
|
|
179
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(identifier) {
|
|
180
|
+
var requestedDimensions, cardPreview, currentDimensions, areValidRequestedDimensions;
|
|
186
181
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
187
182
|
while (1) {
|
|
188
183
|
switch (_context2.prev = _context2.next) {
|
|
189
184
|
case 0:
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
requestedDimensions = _objectSpread({}, _this.props.dimensions);
|
|
186
|
+
_context2.prev = 1;
|
|
192
187
|
_context2.next = 4;
|
|
193
|
-
return
|
|
188
|
+
return _this.fetchAndCacheRemotePreview(identifier);
|
|
194
189
|
case 4:
|
|
195
190
|
cardPreview = _context2.sent;
|
|
191
|
+
currentDimensions = _this.props.dimensions;
|
|
192
|
+
areValidRequestedDimensions = !(0, _dimensionComparer.isBigger)(requestedDimensions, currentDimensions); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
|
|
193
|
+
// the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
|
|
194
|
+
// to trigger a normal preview fetch.
|
|
195
|
+
if (areValidRequestedDimensions) {
|
|
196
|
+
_this.safeSetState({
|
|
197
|
+
cardPreview: cardPreview,
|
|
198
|
+
wasResolvedUpfrontPreview: true
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
_this.safeSetState({
|
|
202
|
+
wasResolvedUpfrontPreview: true
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
_context2.next = 13;
|
|
206
|
+
break;
|
|
207
|
+
case 10:
|
|
208
|
+
_context2.prev = 10;
|
|
209
|
+
_context2.t0 = _context2["catch"](1);
|
|
210
|
+
_this.safeSetState({
|
|
211
|
+
wasResolvedUpfrontPreview: true
|
|
212
|
+
});
|
|
213
|
+
// NO need to log error. If this call fails, a refetch will happen after
|
|
214
|
+
case 13:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context2.stop();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, _callee2, null, [[1, 10]]);
|
|
220
|
+
}));
|
|
221
|
+
return function (_x2) {
|
|
222
|
+
return _ref3.apply(this, arguments);
|
|
223
|
+
};
|
|
224
|
+
}());
|
|
225
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchAndCacheRemotePreview", function (identifier) {
|
|
226
|
+
var _this$props3 = _this.props,
|
|
227
|
+
mediaClient = _this$props3.mediaClient,
|
|
228
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
229
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
230
|
+
return (0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
231
|
+
});
|
|
232
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
233
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(identifier, fileState) {
|
|
234
|
+
var params, cardPreview, wrappedError;
|
|
235
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
236
|
+
while (1) {
|
|
237
|
+
switch (_context3.prev = _context3.next) {
|
|
238
|
+
case 0:
|
|
239
|
+
_context3.prev = 0;
|
|
240
|
+
params = _this.getCardPreviewParams(identifier, fileState);
|
|
241
|
+
_context3.next = 4;
|
|
242
|
+
return (0, _getCardPreview.getCardPreview)(params);
|
|
243
|
+
case 4:
|
|
244
|
+
cardPreview = _context3.sent;
|
|
196
245
|
_this.safeSetState({
|
|
197
246
|
cardPreview: cardPreview
|
|
198
247
|
});
|
|
199
|
-
|
|
248
|
+
_context3.next = 12;
|
|
200
249
|
break;
|
|
201
250
|
case 8:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
wrappedError = (0, _errors.ensureMediaCardError)('preview-fetch',
|
|
251
|
+
_context3.prev = 8;
|
|
252
|
+
_context3.t0 = _context3["catch"](0);
|
|
253
|
+
wrappedError = (0, _errors.ensureMediaCardError)('preview-fetch', _context3.t0); // If remote preview fails, we set status 'error'
|
|
205
254
|
// If local preview fails (i.e, no remote preview available),
|
|
206
255
|
// we can stay in the same status until there is a remote preview available
|
|
207
256
|
// If it's any other error we set status 'error'
|
|
@@ -218,13 +267,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
218
267
|
}
|
|
219
268
|
case 12:
|
|
220
269
|
case "end":
|
|
221
|
-
return
|
|
270
|
+
return _context3.stop();
|
|
222
271
|
}
|
|
223
272
|
}
|
|
224
|
-
},
|
|
273
|
+
}, _callee3, null, [[0, 8]]);
|
|
225
274
|
}));
|
|
226
|
-
return function (
|
|
227
|
-
return
|
|
275
|
+
return function (_x3, _x4) {
|
|
276
|
+
return _ref4.apply(this, arguments);
|
|
228
277
|
};
|
|
229
278
|
}());
|
|
230
279
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPerformanceAttributes", function () {
|
|
@@ -276,9 +325,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
276
325
|
updateState.isBannedLocalPreview = true;
|
|
277
326
|
_this.fireNonCriticalErrorEvent(error);
|
|
278
327
|
}
|
|
279
|
-
var _this$
|
|
280
|
-
identifier = _this$
|
|
281
|
-
resizeMode = _this$
|
|
328
|
+
var _this$props4 = _this.props,
|
|
329
|
+
identifier = _this$props4.identifier,
|
|
330
|
+
resizeMode = _this$props4.resizeMode;
|
|
282
331
|
var fileImageMode = (0, _mediaClient2.imageResizeModeToFileImageMode)(resizeMode);
|
|
283
332
|
(0, _mediaClient2.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, fileImageMode);
|
|
284
333
|
_this.safeSetState(updateState);
|
|
@@ -357,10 +406,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
357
406
|
}
|
|
358
407
|
});
|
|
359
408
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
360
|
-
var _this$
|
|
361
|
-
identifier = _this$
|
|
362
|
-
useInlinePlayer = _this$
|
|
363
|
-
shouldOpenMediaViewer = _this$
|
|
409
|
+
var _this$props5 = _this.props,
|
|
410
|
+
identifier = _this$props5.identifier,
|
|
411
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
412
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
364
413
|
var cardPreview = _this.state.cardPreview;
|
|
365
414
|
var _assertThisInitialize2 = (0, _assertThisInitialized2.default)(_this),
|
|
366
415
|
metadata = _assertThisInitialize2.metadata;
|
|
@@ -406,14 +455,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
406
455
|
});
|
|
407
456
|
});
|
|
408
457
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderInlinePlayer", function () {
|
|
409
|
-
var _this$
|
|
410
|
-
identifier = _this$
|
|
411
|
-
mediaClient = _this$
|
|
412
|
-
dimensions = _this$
|
|
413
|
-
selected = _this$
|
|
414
|
-
testId = _this$
|
|
415
|
-
originalDimensions = _this$
|
|
416
|
-
onFullscreenChange = _this$
|
|
458
|
+
var _this$props6 = _this.props,
|
|
459
|
+
identifier = _this$props6.identifier,
|
|
460
|
+
mediaClient = _this$props6.mediaClient,
|
|
461
|
+
dimensions = _this$props6.dimensions,
|
|
462
|
+
selected = _this$props6.selected,
|
|
463
|
+
testId = _this$props6.testId,
|
|
464
|
+
originalDimensions = _this$props6.originalDimensions,
|
|
465
|
+
onFullscreenChange = _this$props6.onFullscreenChange;
|
|
417
466
|
var _this$state = _this.state,
|
|
418
467
|
shouldAutoplay = _this$state.shouldAutoplay,
|
|
419
468
|
cardPreview = _this$state.cardPreview;
|
|
@@ -460,12 +509,12 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
460
509
|
});
|
|
461
510
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderMediaViewer", function () {
|
|
462
511
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
463
|
-
var _this$
|
|
464
|
-
mediaClient = _this$
|
|
465
|
-
identifier = _this$
|
|
466
|
-
mediaViewerDataSource = _this$
|
|
467
|
-
contextId = _this$
|
|
468
|
-
featureFlags = _this$
|
|
512
|
+
var _this$props7 = _this.props,
|
|
513
|
+
mediaClient = _this$props7.mediaClient,
|
|
514
|
+
identifier = _this$props7.identifier,
|
|
515
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
516
|
+
contextId = _this$props7.contextId,
|
|
517
|
+
featureFlags = _this$props7.featureFlags;
|
|
469
518
|
if (!mediaViewerSelectedItem) {
|
|
470
519
|
return;
|
|
471
520
|
}
|
|
@@ -487,23 +536,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
487
536
|
var withCallbacks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
488
537
|
var cardStatusOverride = arguments.length > 1 ? arguments[1] : undefined;
|
|
489
538
|
var izLazyOverride = arguments.length > 2 ? arguments[2] : undefined;
|
|
490
|
-
var _this$
|
|
491
|
-
identifier = _this$
|
|
492
|
-
isLazy = _this$
|
|
493
|
-
appearance = _this$
|
|
494
|
-
resizeMode = _this$
|
|
495
|
-
dimensions = _this$
|
|
496
|
-
selectable = _this$
|
|
497
|
-
selected = _this$
|
|
498
|
-
disableOverlay = _this$
|
|
499
|
-
alt = _this$
|
|
500
|
-
testId = _this$
|
|
501
|
-
featureFlags = _this$
|
|
502
|
-
titleBoxBgColor = _this$
|
|
503
|
-
titleBoxIcon = _this$
|
|
504
|
-
ssr = _this$
|
|
505
|
-
useInlinePlayer = _this$
|
|
506
|
-
shouldOpenMediaViewer = _this$
|
|
539
|
+
var _this$props8 = _this.props,
|
|
540
|
+
identifier = _this$props8.identifier,
|
|
541
|
+
isLazy = _this$props8.isLazy,
|
|
542
|
+
appearance = _this$props8.appearance,
|
|
543
|
+
resizeMode = _this$props8.resizeMode,
|
|
544
|
+
dimensions = _this$props8.dimensions,
|
|
545
|
+
selectable = _this$props8.selectable,
|
|
546
|
+
selected = _this$props8.selected,
|
|
547
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
548
|
+
alt = _this$props8.alt,
|
|
549
|
+
testId = _this$props8.testId,
|
|
550
|
+
featureFlags = _this$props8.featureFlags,
|
|
551
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
552
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
553
|
+
ssr = _this$props8.ssr,
|
|
554
|
+
useInlinePlayer = _this$props8.useInlinePlayer,
|
|
555
|
+
shouldOpenMediaViewer = _this$props8.shouldOpenMediaViewer;
|
|
507
556
|
var mediaItemType = identifier.mediaItemType;
|
|
508
557
|
var _this$state2 = _this.state,
|
|
509
558
|
status = _this$state2.status,
|
|
@@ -563,9 +612,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
563
612
|
});
|
|
564
613
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "storeSSRData", function () {
|
|
565
614
|
var _this$ssrReliability$;
|
|
566
|
-
var _this$
|
|
567
|
-
ssr = _this$
|
|
568
|
-
identifier = _this$
|
|
615
|
+
var _this$props9 = _this.props,
|
|
616
|
+
ssr = _this$props9.ssr,
|
|
617
|
+
identifier = _this$props9.identifier;
|
|
569
618
|
var _this$state$cardPrevi = _this.state.cardPreview;
|
|
570
619
|
_this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
|
|
571
620
|
var dataURI = _this$state$cardPrevi.dataURI;
|
|
@@ -608,37 +657,17 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
608
657
|
var _status = 'loading';
|
|
609
658
|
var _cardPreview;
|
|
610
659
|
var _error;
|
|
611
|
-
var _this$
|
|
612
|
-
_identifier = _this$
|
|
613
|
-
_resizeMode = _this$
|
|
614
|
-
_ssr = _this$
|
|
615
|
-
_mediaClient = _this$
|
|
660
|
+
var _this$props10 = _this.props,
|
|
661
|
+
_identifier = _this$props10.identifier,
|
|
662
|
+
_resizeMode = _this$props10.resizeMode,
|
|
663
|
+
_ssr = _this$props10.ssr,
|
|
664
|
+
_mediaClient = _this$props10.mediaClient;
|
|
616
665
|
if ((0, _mediaClient2.isFileIdentifier)(_identifier)) {
|
|
617
666
|
var id = _identifier.id;
|
|
618
667
|
var fileImageMode = (0, _mediaClient2.imageResizeModeToFileImageMode)(_resizeMode);
|
|
619
668
|
_cardPreview = (0, _getCardPreview.getCardPreviewFromCache)(id, fileImageMode);
|
|
620
669
|
if (!_cardPreview && _ssr) {
|
|
621
|
-
|
|
622
|
-
_this.ssrData = (0, _globalScope.getSSRData)(_identifier);
|
|
623
|
-
if ((_this$ssrData = _this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
624
|
-
_this.ssrReliability.server = _objectSpread({
|
|
625
|
-
status: 'fail'
|
|
626
|
-
}, _this.ssrData.error);
|
|
627
|
-
}
|
|
628
|
-
if (!((_this$ssrData2 = _this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
629
|
-
try {
|
|
630
|
-
_cardPreview = (0, _getCardPreview.getSSRCardPreview)(_ssr, _mediaClient, _identifier.id, _this.getImageURLParams(_identifier), _this.getMediaBlobUrlAttrs(_identifier));
|
|
631
|
-
} catch (e) {
|
|
632
|
-
_this.ssrReliability[_ssr] = _objectSpread({
|
|
633
|
-
status: 'fail'
|
|
634
|
-
}, (0, _analytics.extractErrorInfo)(e));
|
|
635
|
-
}
|
|
636
|
-
} else {
|
|
637
|
-
_cardPreview = {
|
|
638
|
-
dataURI: _this.ssrData.dataURI,
|
|
639
|
-
source: 'ssr-data'
|
|
640
|
-
};
|
|
641
|
-
}
|
|
670
|
+
_cardPreview = _this.getSSRPreview(_ssr, _identifier, _mediaClient);
|
|
642
671
|
}
|
|
643
672
|
} else if ((0, _mediaClient2.isExternalImageIdentifier)(_identifier)) {
|
|
644
673
|
_this.fireCommencedEvent();
|
|
@@ -665,11 +694,37 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
665
694
|
cardRef: null,
|
|
666
695
|
isBannedLocalPreview: false,
|
|
667
696
|
previewDidRender: false,
|
|
668
|
-
error: _error
|
|
697
|
+
error: _error,
|
|
698
|
+
wasResolvedUpfrontPreview: false
|
|
669
699
|
};
|
|
670
700
|
return _this;
|
|
671
701
|
}
|
|
672
702
|
(0, _createClass2.default)(CardBase, [{
|
|
703
|
+
key: "getSSRPreview",
|
|
704
|
+
value: function getSSRPreview(ssr, identifier, mediaClient) {
|
|
705
|
+
var _this$ssrData, _this$ssrData2;
|
|
706
|
+
this.ssrData = (0, _globalScope.getSSRData)(identifier);
|
|
707
|
+
if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
708
|
+
this.ssrReliability.server = _objectSpread({
|
|
709
|
+
status: 'fail'
|
|
710
|
+
}, this.ssrData.error);
|
|
711
|
+
}
|
|
712
|
+
if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
713
|
+
try {
|
|
714
|
+
return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
|
|
715
|
+
} catch (e) {
|
|
716
|
+
this.ssrReliability[ssr] = _objectSpread({
|
|
717
|
+
status: 'fail'
|
|
718
|
+
}, (0, _analytics.extractErrorInfo)(e));
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
return {
|
|
722
|
+
dataURI: this.ssrData.dataURI,
|
|
723
|
+
source: 'ssr-data'
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}, {
|
|
673
728
|
key: "componentDidMount",
|
|
674
729
|
value: function componentDidMount() {
|
|
675
730
|
var _getDocument;
|
|
@@ -677,12 +732,15 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
677
732
|
var _this$state3 = this.state,
|
|
678
733
|
isCardVisible = _this$state3.isCardVisible,
|
|
679
734
|
cardPreview = _this$state3.cardPreview;
|
|
680
|
-
var _this$
|
|
681
|
-
identifier = _this$
|
|
682
|
-
ssr = _this$
|
|
683
|
-
dimensions = _this$
|
|
735
|
+
var _this$props11 = this.props,
|
|
736
|
+
identifier = _this$props11.identifier,
|
|
737
|
+
ssr = _this$props11.ssr,
|
|
738
|
+
dimensions = _this$props11.dimensions;
|
|
684
739
|
if (isCardVisible && (0, _mediaClient2.isFileIdentifier)(identifier)) {
|
|
685
740
|
this.updateStateForIdentifier(identifier);
|
|
741
|
+
if (!cardPreview) {
|
|
742
|
+
this.resolveUpfrontPreview(identifier);
|
|
743
|
+
}
|
|
686
744
|
}
|
|
687
745
|
if (isCardVisible && !!ssr && !!cardPreview && (0, _mediaClient2.isFileIdentifier)(identifier)) {
|
|
688
746
|
var _this$ssrData3;
|
|
@@ -710,14 +768,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
710
768
|
prevIdentifier = prevProps.identifier,
|
|
711
769
|
prevDimensions = prevProps.dimensions;
|
|
712
770
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
713
|
-
var _this$
|
|
714
|
-
mediaClient = _this$
|
|
715
|
-
identifier = _this$
|
|
716
|
-
dimensions = _this$
|
|
717
|
-
featureFlags = _this$
|
|
718
|
-
useInlinePlayer = _this$
|
|
719
|
-
disableOverlay = _this$
|
|
720
|
-
resizeMode = _this$
|
|
771
|
+
var _this$props12 = this.props,
|
|
772
|
+
mediaClient = _this$props12.mediaClient,
|
|
773
|
+
identifier = _this$props12.identifier,
|
|
774
|
+
dimensions = _this$props12.dimensions,
|
|
775
|
+
featureFlags = _this$props12.featureFlags,
|
|
776
|
+
useInlinePlayer = _this$props12.useInlinePlayer,
|
|
777
|
+
disableOverlay = _this$props12.disableOverlay,
|
|
778
|
+
resizeMode = _this$props12.resizeMode;
|
|
721
779
|
var _this$state4 = this.state,
|
|
722
780
|
isCardVisible = _this$state4.isCardVisible,
|
|
723
781
|
cardPreview = _this$state4.cardPreview,
|
|
@@ -725,8 +783,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
725
783
|
fileState = _this$state4.fileState,
|
|
726
784
|
isBannedLocalPreview = _this$state4.isBannedLocalPreview,
|
|
727
785
|
previewDidRender = _this$state4.previewDidRender,
|
|
728
|
-
isPlayingFile = _this$state4.isPlayingFile
|
|
786
|
+
isPlayingFile = _this$state4.isPlayingFile,
|
|
787
|
+
wasResolvedUpfrontPreview = _this$state4.wasResolvedUpfrontPreview;
|
|
729
788
|
var isDifferent = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
|
|
789
|
+
/**
|
|
790
|
+
* Variable turnedVisible should only be true when media card
|
|
791
|
+
* was invisible in the previous state and is visible in the current one
|
|
792
|
+
*
|
|
793
|
+
* prevIsCardVisible | isCardVisible | turnedVisible
|
|
794
|
+
* ----------------------------------------------------
|
|
795
|
+
* false | false | false
|
|
796
|
+
* false | true | true
|
|
797
|
+
* true | true | false
|
|
798
|
+
* true | false | false (unreachable case)
|
|
799
|
+
* ----------------------------------------------------
|
|
800
|
+
*/
|
|
730
801
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
731
802
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
732
803
|
var fileImageMode = (0, _mediaClient2.imageResizeModeToFileImageMode)(resizeMode);
|
|
@@ -753,7 +824,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
753
824
|
this.fireScreenEvent();
|
|
754
825
|
}
|
|
755
826
|
}
|
|
756
|
-
if ((0, _mediaClient2.isFileIdentifier)(identifier) &&
|
|
827
|
+
if ((0, _mediaClient2.isFileIdentifier)(identifier) && turnedVisible && !cardPreview && !wasResolvedUpfrontPreview) {
|
|
828
|
+
// This is a one-off call, only meant to happen when turnedVisible = true (only once in the component's lifecycle)
|
|
829
|
+
this.resolveUpfrontPreview(identifier);
|
|
830
|
+
} else if ((0, _mediaClient2.isFileIdentifier)(identifier) && fileState && (0, _getCardPreview.shouldResolvePreview)({
|
|
757
831
|
status: status,
|
|
758
832
|
fileState: fileState,
|
|
759
833
|
prevDimensions: prevDimensions,
|
|
@@ -762,7 +836,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
762
836
|
fileImageMode: fileImageMode,
|
|
763
837
|
featureFlags: featureFlags,
|
|
764
838
|
hasCardPreview: !!cardPreview,
|
|
765
|
-
isBannedLocalPreview: isBannedLocalPreview
|
|
839
|
+
isBannedLocalPreview: isBannedLocalPreview,
|
|
840
|
+
wasResolvedUpfrontPreview: wasResolvedUpfrontPreview
|
|
766
841
|
})) {
|
|
767
842
|
this.resolvePreview(identifier, fileState);
|
|
768
843
|
}
|
|
@@ -847,8 +922,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
847
922
|
key: "requestedDimensions",
|
|
848
923
|
get: function get() {
|
|
849
924
|
var dimensions = this.props.dimensions;
|
|
850
|
-
var
|
|
851
|
-
element =
|
|
925
|
+
var _ref5 = this.state || {},
|
|
926
|
+
element = _ref5.cardRef;
|
|
852
927
|
return (0, _getDataURIDimension.getRequestedDimensions)({
|
|
853
928
|
dimensions: dimensions,
|
|
854
929
|
element: element
|
|
@@ -893,11 +968,11 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
893
968
|
key: "actions",
|
|
894
969
|
get: function get() {
|
|
895
970
|
var _this3 = this;
|
|
896
|
-
var _this$
|
|
897
|
-
_this$
|
|
898
|
-
actions = _this$
|
|
899
|
-
identifier = _this$
|
|
900
|
-
shouldEnableDownloadButton = _this$
|
|
971
|
+
var _this$props13 = this.props,
|
|
972
|
+
_this$props13$actions = _this$props13.actions,
|
|
973
|
+
actions = _this$props13$actions === void 0 ? [] : _this$props13$actions,
|
|
974
|
+
identifier = _this$props13.identifier,
|
|
975
|
+
shouldEnableDownloadButton = _this$props13.shouldEnableDownloadButton;
|
|
901
976
|
var status = this.state.status;
|
|
902
977
|
var metadata = this.metadata;
|
|
903
978
|
if ((0, _mediaClient2.isFileIdentifier)(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
|
|
@@ -205,10 +205,12 @@ var shouldResolvePreview = function shouldResolvePreview(_ref3) {
|
|
|
205
205
|
fileImageMode = _ref3.fileImageMode,
|
|
206
206
|
hasCardPreview = _ref3.hasCardPreview,
|
|
207
207
|
isBannedLocalPreview = _ref3.isBannedLocalPreview,
|
|
208
|
-
featureFlags = _ref3.featureFlags
|
|
208
|
+
featureFlags = _ref3.featureFlags,
|
|
209
|
+
wasResolvedUpfrontPreview = _ref3.wasResolvedUpfrontPreview;
|
|
209
210
|
var statusIsPreviewable = (0, _filePreviewStatus.isPreviewableStatus)(status, (0, _filePreviewStatus.extractFilePreviewStatus)(fileState, isBannedLocalPreview, featureFlags));
|
|
210
211
|
var dimensionsAreBigger = (0, _dimensionComparer.isBigger)(prevDimensions, dimensions);
|
|
211
|
-
|
|
212
|
+
// 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.
|
|
213
|
+
return wasResolvedUpfrontPreview && statusIsPreviewable && (!hasCardPreview || dimensionsAreBigger);
|
|
212
214
|
};
|
|
213
215
|
exports.shouldResolvePreview = shouldResolvePreview;
|
|
214
216
|
var getSSRCardPreview = function getSSRCardPreview(ssr, mediaClient, id, params, mediaBlobUrlAttrs) {
|
|
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
90
90
|
}(_react.default.Component);
|
|
91
91
|
(0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
92
92
|
var packageName = "@atlaskit/media-card";
|
|
93
|
-
var packageVersion = "74.
|
|
93
|
+
var packageVersion = "74.6.0";
|
|
94
94
|
var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
95
95
|
packageVersion: packageVersion,
|
|
96
96
|
packageName: packageName,
|
|
@@ -77,7 +77,7 @@ var WrappedMediaInlineAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Com
|
|
|
77
77
|
}(_react.default.Component);
|
|
78
78
|
(0, _defineProperty2.default)(WrappedMediaInlineAnalyticsErrorBoundary, "displayName", 'MediaInlineAnalyticsErrorBoundary');
|
|
79
79
|
var packageName = "@atlaskit/media-card";
|
|
80
|
-
var packageVersion = "74.
|
|
80
|
+
var packageVersion = "74.6.0";
|
|
81
81
|
var MediaInlineAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
82
82
|
packageVersion: packageVersion,
|
|
83
83
|
packageName: packageName,
|
|
@@ -13,7 +13,7 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
var packageName = "@atlaskit/media-card";
|
|
16
|
-
var packageVersion = "74.
|
|
16
|
+
var packageVersion = "74.6.0";
|
|
17
17
|
var concurrentExperience;
|
|
18
18
|
var getExperience = function getExperience(id) {
|
|
19
19
|
if (!concurrentExperience) {
|
package/dist/cjs/version.json
CHANGED