@atlaskit/media-card 72.0.0 → 73.1.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 +92 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +35 -11
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +1 -1
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +2 -2
- package/dist/cjs/root/card/cardLoader.js +66 -124
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
- package/dist/cjs/root/card/getCardPreview/index.js +101 -18
- package/dist/cjs/root/card/getCardStatus.js +1 -1
- package/dist/cjs/root/card/index.js +191 -97
- package/dist/cjs/root/cardView.js +44 -57
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +31 -11
- package/dist/cjs/root/inlinePlayer.js +77 -24
- package/dist/cjs/root/styled.js +7 -3
- package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
- package/dist/cjs/root/ui/blanket/styled.js +1 -1
- package/dist/cjs/root/ui/common.js +11 -5
- package/dist/cjs/root/ui/iconMessage/index.js +5 -3
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +7 -4
- package/dist/cjs/root/ui/progressBar/styled.js +8 -9
- package/dist/cjs/root/ui/styled.js +80 -17
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
- package/dist/cjs/root/ui/titleBox/styled.js +2 -4
- package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
- package/dist/cjs/styles/index.js +25 -23
- package/dist/cjs/styles/mixins.js +1 -1
- package/dist/cjs/utils/analytics.js +2 -1
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -9
- package/dist/cjs/utils/cardActions/index.js +10 -10
- package/dist/cjs/utils/cardActions/styled.js +1 -1
- package/dist/cjs/utils/cardDimensions.js +1 -1
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- package/dist/cjs/utils/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/objectURLCache.js +1 -1
- package/dist/cjs/utils/viewportDetector.js +49 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +9 -1
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/cardLoader.js +47 -53
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/es2019/root/card/getCardPreview/index.js +45 -3
- package/dist/es2019/root/card/index.js +131 -35
- package/dist/es2019/root/cardView.js +26 -40
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +30 -10
- package/dist/es2019/root/inlinePlayer.js +56 -4
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/common.js +7 -1
- package/dist/es2019/root/ui/iconMessage/index.js +3 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
- package/dist/es2019/root/ui/progressBar/styled.js +7 -6
- package/dist/es2019/root/ui/styled.js +65 -4
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/es2019/root/ui/titleBox/styled.js +1 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
- package/dist/es2019/utils/getErrorMessage.js +1 -1
- package/dist/es2019/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +28 -9
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardLoader.js +66 -126
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/esm/root/card/getCardPreview/index.js +74 -12
- package/dist/esm/root/card/index.js +198 -100
- package/dist/esm/root/cardView.js +42 -54
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +30 -10
- package/dist/esm/root/inlinePlayer.js +74 -23
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/common.js +7 -1
- package/dist/esm/root/ui/iconMessage/index.js +3 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
- package/dist/esm/root/ui/progressBar/styled.js +7 -7
- package/dist/esm/root/ui/styled.js +61 -13
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/esm/root/ui/titleBox/styled.js +1 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -9
- package/dist/esm/utils/getErrorMessage.js +1 -1
- package/dist/esm/utils/viewportDetector.js +48 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +9 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/root/card/cardLoader.d.ts +5 -19
- package/dist/types/root/card/getCardPreview/index.d.ts +7 -1
- package/dist/types/root/card/index.d.ts +9 -8
- package/dist/types/root/cardView.d.ts +5 -3
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
- package/dist/types/root/inlinePlayer.d.ts +8 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/common.d.ts +4 -1
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +3 -2
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +4 -2
- package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
- package/dist/types/root/ui/styled.d.ts +10 -3
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -3
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/getErrorMessage.d.ts +1 -0
- package/dist/types/utils/viewportDetector.d.ts +13 -5
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +34 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +16 -15
- package/dist/cjs/root/card/cardSSRView.js +0 -114
- package/dist/cjs/root/ui/Breakpoint.js +0 -13
- package/dist/cjs/root/ui/styledSSR.js +0 -108
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/root/card/cardSSRView.js +0 -93
- package/dist/es2019/root/ui/Breakpoint.js +0 -6
- package/dist/es2019/root/ui/styledSSR.js +0 -93
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/root/card/cardSSRView.js +0 -92
- package/dist/esm/root/ui/Breakpoint.js +0 -6
- package/dist/esm/root/ui/styledSSR.js +0 -76
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/root/card/cardSSRView.d.ts +0 -13
- package/dist/types/root/ui/Breakpoint.d.ts +0 -4
- package/dist/types/root/ui/styledSSR.d.ts +0 -16
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.CardBase = exports.Card = void 0;
|
|
11
11
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
|
|
@@ -45,7 +45,7 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
45
45
|
|
|
46
46
|
var _mediaViewer = require("@atlaskit/media-viewer");
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _reactIntlNext = require("react-intl-next");
|
|
49
49
|
|
|
50
50
|
var _cardView = require("../cardView");
|
|
51
51
|
|
|
@@ -73,9 +73,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
73
73
|
|
|
74
74
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
75
75
|
|
|
76
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
76
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
77
77
|
|
|
78
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
78
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
79
79
|
|
|
80
80
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
81
81
|
|
|
@@ -94,6 +94,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
94
94
|
(0, _classCallCheck2.default)(this, CardBase);
|
|
95
95
|
_this = _super.call(this, props);
|
|
96
96
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasBeenMounted", false);
|
|
97
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPreAnchorRef", /*#__PURE__*/(0, _react.createRef)());
|
|
98
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "viewportPostAnchorRef", /*#__PURE__*/(0, _react.createRef)());
|
|
97
99
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeElapsedTillCommenced", performance.now());
|
|
98
100
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getImageURLParams", function (_ref) {
|
|
99
101
|
var collection = _ref.collectionName;
|
|
@@ -146,6 +148,26 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
146
148
|
mediaBlobUrlAttrs: _this.getMediaBlobUrlAttrs(identifier, fileState)
|
|
147
149
|
};
|
|
148
150
|
});
|
|
151
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setCacheSSRPreview", function (identifier) {
|
|
152
|
+
var _this$props3 = _this.props,
|
|
153
|
+
mediaClient = _this$props3.mediaClient,
|
|
154
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
155
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
156
|
+
(0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {// No need to log this error.
|
|
157
|
+
// If preview fails, it will be refetched later
|
|
158
|
+
//TODO: test this catch
|
|
159
|
+
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveSSRPreview", function (identifier, ssr) {
|
|
163
|
+
var mediaClient = _this.props.mediaClient;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
167
|
+
} catch (e) {// TODO: log SSR reliability 'failed'
|
|
168
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
169
|
+
}
|
|
170
|
+
});
|
|
149
171
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
150
172
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier, fileState) {
|
|
151
173
|
var params, cardPreview, wrappedError;
|
|
@@ -215,20 +237,31 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
215
237
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageError", function () {
|
|
216
238
|
var cardPreview = _this.state.cardPreview;
|
|
217
239
|
var error = new _errors.ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
240
|
+
var isLocal = cardPreview && (0, _getCardPreview.isLocalPreview)(cardPreview);
|
|
241
|
+
var isSSR = cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview);
|
|
218
242
|
|
|
219
|
-
if (
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
224
|
-
(0, _mediaClient.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
|
|
243
|
+
if (isLocal || isSSR) {
|
|
244
|
+
var updateState = {
|
|
245
|
+
cardPreview: undefined
|
|
246
|
+
};
|
|
225
247
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
248
|
+
if (isLocal) {
|
|
249
|
+
updateState.isBannedLocalPreview = true;
|
|
250
|
+
|
|
251
|
+
_this.fireLocalPreviewErrorEvent(error);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (isSSR) {// TODO: set SSR-client reliability 'failed'.
|
|
255
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
var _this$props4 = _this.props,
|
|
259
|
+
identifier = _this$props4.identifier,
|
|
260
|
+
_this$props4$dimensio = _this$props4.dimensions,
|
|
261
|
+
dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
|
|
262
|
+
(0, _mediaClient.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
|
|
230
263
|
|
|
231
|
-
_this.
|
|
264
|
+
_this.safeSetState(updateState);
|
|
232
265
|
} else {
|
|
233
266
|
_this.safeSetState({
|
|
234
267
|
status: 'error',
|
|
@@ -276,10 +309,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
276
309
|
}
|
|
277
310
|
});
|
|
278
311
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
279
|
-
var _this$
|
|
280
|
-
identifier = _this$
|
|
281
|
-
useInlinePlayer = _this$
|
|
282
|
-
shouldOpenMediaViewer = _this$
|
|
312
|
+
var _this$props5 = _this.props,
|
|
313
|
+
identifier = _this$props5.identifier,
|
|
314
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
315
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
283
316
|
var cardPreview = _this.state.cardPreview;
|
|
284
317
|
|
|
285
318
|
var _assertThisInitialize2 = (0, _assertThisInitialized2.default)(_this),
|
|
@@ -295,7 +328,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
295
328
|
|
|
296
329
|
if (useInlinePlayer && isVideo && !!cardPreview) {
|
|
297
330
|
_this.setState({
|
|
298
|
-
isPlayingFile: true
|
|
331
|
+
isPlayingFile: true,
|
|
332
|
+
shouldAutoplay: true
|
|
299
333
|
});
|
|
300
334
|
} else if (shouldOpenMediaViewer) {
|
|
301
335
|
var mediaViewerSelectedItem;
|
|
@@ -331,18 +365,20 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
331
365
|
});
|
|
332
366
|
});
|
|
333
367
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderInlinePlayer", function () {
|
|
334
|
-
var _this$
|
|
335
|
-
identifier = _this$
|
|
336
|
-
mediaClient = _this$
|
|
337
|
-
dimensions = _this$
|
|
338
|
-
selected = _this$
|
|
339
|
-
testId = _this$
|
|
340
|
-
originalDimensions = _this$
|
|
368
|
+
var _this$props6 = _this.props,
|
|
369
|
+
identifier = _this$props6.identifier,
|
|
370
|
+
mediaClient = _this$props6.mediaClient,
|
|
371
|
+
dimensions = _this$props6.dimensions,
|
|
372
|
+
selected = _this$props6.selected,
|
|
373
|
+
testId = _this$props6.testId,
|
|
374
|
+
originalDimensions = _this$props6.originalDimensions;
|
|
375
|
+
var shouldAutoplay = _this.state.shouldAutoplay;
|
|
341
376
|
return /*#__PURE__*/_react.default.createElement(_inlinePlayer.InlinePlayer, {
|
|
342
377
|
mediaClient: mediaClient,
|
|
343
378
|
dimensions: dimensions,
|
|
344
379
|
originalDimensions: originalDimensions,
|
|
345
380
|
identifier: identifier,
|
|
381
|
+
autoplay: !!shouldAutoplay,
|
|
346
382
|
onError: _this.onInlinePlayerError,
|
|
347
383
|
onClick: _this.onClick,
|
|
348
384
|
selected: selected,
|
|
@@ -377,12 +413,12 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
377
413
|
});
|
|
378
414
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderMediaViewer", function () {
|
|
379
415
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
380
|
-
var _this$
|
|
381
|
-
mediaClient = _this$
|
|
382
|
-
identifier = _this$
|
|
383
|
-
mediaViewerDataSource = _this$
|
|
384
|
-
contextId = _this$
|
|
385
|
-
featureFlags = _this$
|
|
416
|
+
var _this$props7 = _this.props,
|
|
417
|
+
mediaClient = _this$props7.mediaClient,
|
|
418
|
+
identifier = _this$props7.identifier,
|
|
419
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
420
|
+
contextId = _this$props7.contextId,
|
|
421
|
+
featureFlags = _this$props7.featureFlags;
|
|
386
422
|
|
|
387
423
|
if (!mediaViewerSelectedItem) {
|
|
388
424
|
return;
|
|
@@ -403,20 +439,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
403
439
|
}), document.body);
|
|
404
440
|
});
|
|
405
441
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCard", function () {
|
|
406
|
-
var _this$
|
|
407
|
-
identifier = _this$
|
|
408
|
-
isLazy = _this$
|
|
409
|
-
appearance = _this$
|
|
410
|
-
resizeMode = _this$
|
|
411
|
-
dimensions = _this$
|
|
412
|
-
selectable = _this$
|
|
413
|
-
selected = _this$
|
|
414
|
-
disableOverlay = _this$
|
|
415
|
-
alt = _this$
|
|
416
|
-
testId = _this$
|
|
417
|
-
featureFlags = _this$
|
|
418
|
-
titleBoxBgColor = _this$
|
|
419
|
-
titleBoxIcon = _this$
|
|
442
|
+
var _this$props8 = _this.props,
|
|
443
|
+
identifier = _this$props8.identifier,
|
|
444
|
+
isLazy = _this$props8.isLazy,
|
|
445
|
+
appearance = _this$props8.appearance,
|
|
446
|
+
resizeMode = _this$props8.resizeMode,
|
|
447
|
+
dimensions = _this$props8.dimensions,
|
|
448
|
+
selectable = _this$props8.selectable,
|
|
449
|
+
selected = _this$props8.selected,
|
|
450
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
451
|
+
alt = _this$props8.alt,
|
|
452
|
+
testId = _this$props8.testId,
|
|
453
|
+
featureFlags = _this$props8.featureFlags,
|
|
454
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
455
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
456
|
+
ssr = _this$props8.ssr;
|
|
420
457
|
var mediaItemType = identifier.mediaItemType;
|
|
421
458
|
var _this$state = _this.state,
|
|
422
459
|
status = _this$state.status,
|
|
@@ -429,7 +466,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
429
466
|
var dataURI = _this$state$cardPrevi.dataURI,
|
|
430
467
|
orientation = _this$state$cardPrevi.orientation,
|
|
431
468
|
error = _this$state.error,
|
|
432
|
-
cardRef = _this$state.cardRef
|
|
469
|
+
cardRef = _this$state.cardRef,
|
|
470
|
+
isCardVisible = _this$state.isCardVisible;
|
|
433
471
|
|
|
434
472
|
var _assertThisInitialize3 = (0, _assertThisInitialized2.default)(_this),
|
|
435
473
|
metadata = _assertThisInitialize3.metadata;
|
|
@@ -438,7 +476,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
438
476
|
onCardViewClick = _assertThisInitialize4.onCardViewClick,
|
|
439
477
|
onDisplayImage = _assertThisInitialize4.onDisplayImage,
|
|
440
478
|
actions = _assertThisInitialize4.actions,
|
|
441
|
-
onMouseEnter = _assertThisInitialize4.onMouseEnter;
|
|
479
|
+
onMouseEnter = _assertThisInitialize4.onMouseEnter; // Card can be artificially turned visible before entering the viewport
|
|
480
|
+
// For example, when we have the image in cache
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
|
|
484
|
+
|
|
485
|
+
var forceSyncDisplay = !!ssr;
|
|
442
486
|
|
|
443
487
|
var card = /*#__PURE__*/_react.default.createElement(_cardView.CardView, {
|
|
444
488
|
status: status,
|
|
@@ -465,13 +509,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
465
509
|
titleBoxBgColor: titleBoxBgColor,
|
|
466
510
|
titleBoxIcon: titleBoxIcon,
|
|
467
511
|
onImageError: _this.onImageError,
|
|
468
|
-
onImageLoad: _this.onImageLoad
|
|
512
|
+
onImageLoad: _this.onImageLoad,
|
|
513
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
514
|
+
forceSyncDisplay: forceSyncDisplay
|
|
469
515
|
});
|
|
470
516
|
|
|
471
517
|
return isLazy ? /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportDetector, {
|
|
472
|
-
|
|
518
|
+
cardEl: cardRef,
|
|
519
|
+
preAnchorRef: _this.viewportPreAnchorRef,
|
|
520
|
+
postAnchorRef: _this.viewportPostAnchorRef,
|
|
473
521
|
onVisible: _this.onCardInViewport
|
|
474
|
-
},
|
|
522
|
+
}, /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportAnchor, {
|
|
523
|
+
ref: _this.viewportPreAnchorRef,
|
|
524
|
+
offsetTop: -_viewportDetector.ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
525
|
+
}), card, /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportAnchor, {
|
|
526
|
+
ref: _this.viewportPostAnchorRef,
|
|
527
|
+
offsetTop: _viewportDetector.ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
528
|
+
})) : card;
|
|
475
529
|
});
|
|
476
530
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardInViewport", function () {
|
|
477
531
|
_this.setState({
|
|
@@ -510,14 +564,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
510
564
|
|
|
511
565
|
var _cardPreview;
|
|
512
566
|
|
|
513
|
-
var _this$
|
|
514
|
-
_identifier = _this$
|
|
515
|
-
_this$
|
|
516
|
-
_dimensions = _this$
|
|
567
|
+
var _this$props9 = _this.props,
|
|
568
|
+
_identifier = _this$props9.identifier,
|
|
569
|
+
_this$props9$dimensio = _this$props9.dimensions,
|
|
570
|
+
_dimensions = _this$props9$dimensio === void 0 ? {} : _this$props9$dimensio,
|
|
571
|
+
_ssr = _this$props9.ssr;
|
|
517
572
|
|
|
518
573
|
if ((0, _mediaClient.isFileIdentifier)(_identifier)) {
|
|
519
574
|
var id = _identifier.id;
|
|
520
575
|
_cardPreview = (0, _getCardPreview.getCardPreviewFromCache)(id, _dimensions);
|
|
576
|
+
|
|
577
|
+
if (!_cardPreview && _ssr) {
|
|
578
|
+
_this.fireCommencedEvent();
|
|
579
|
+
|
|
580
|
+
_cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
|
|
581
|
+
}
|
|
521
582
|
} else if ((0, _mediaClient.isExternalImageIdentifier)(_identifier)) {
|
|
522
583
|
_this.fireCommencedEvent();
|
|
523
584
|
|
|
@@ -528,15 +589,19 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
528
589
|
orientation: 1,
|
|
529
590
|
source: 'external'
|
|
530
591
|
};
|
|
531
|
-
} //
|
|
532
|
-
//
|
|
592
|
+
} // If cardPreview is available from local cache or external, `isCardVisible`
|
|
593
|
+
// should be true to avoid flickers during re-mount of the component
|
|
594
|
+
// should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
|
|
595
|
+
// outside the viewport
|
|
533
596
|
|
|
534
597
|
|
|
535
|
-
var
|
|
598
|
+
var _isCardVisible = !_this.props.isLazy || !!_cardPreview && !(0, _getCardPreview.isSSRPreview)(_cardPreview);
|
|
599
|
+
|
|
536
600
|
_this.state = {
|
|
537
601
|
status: _status,
|
|
538
|
-
isCardVisible:
|
|
602
|
+
isCardVisible: _isCardVisible,
|
|
539
603
|
isPlayingFile: false,
|
|
604
|
+
shouldAutoplay: false,
|
|
540
605
|
cardPreview: _cardPreview,
|
|
541
606
|
cardRef: null,
|
|
542
607
|
isBannedLocalPreview: false,
|
|
@@ -549,11 +614,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
549
614
|
key: "componentDidMount",
|
|
550
615
|
value: function componentDidMount() {
|
|
551
616
|
this.hasBeenMounted = true;
|
|
552
|
-
var
|
|
553
|
-
|
|
617
|
+
var _this$state2 = this.state,
|
|
618
|
+
isCardVisible = _this$state2.isCardVisible,
|
|
619
|
+
cardPreview = _this$state2.cardPreview;
|
|
620
|
+
var _this$props10 = this.props,
|
|
621
|
+
identifier = _this$props10.identifier,
|
|
622
|
+
ssr = _this$props10.ssr;
|
|
554
623
|
|
|
555
624
|
if (isCardVisible && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
556
625
|
this.updateStateForIdentifier(identifier);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (isCardVisible && !!ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
629
|
+
// Since the SSR preview brings the token in the query params,
|
|
630
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
631
|
+
this.setCacheSSRPreview(identifier);
|
|
557
632
|
} // we add a listener for each of the cards on the page
|
|
558
633
|
// and then check if the triggered listener is from the card
|
|
559
634
|
// that contains a div in current window.getSelection()
|
|
@@ -569,18 +644,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
569
644
|
prevIdentifier = prevProps.identifier,
|
|
570
645
|
prevDimensions = prevProps.dimensions;
|
|
571
646
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
572
|
-
var _this$
|
|
573
|
-
mediaClient = _this$
|
|
574
|
-
identifier = _this$
|
|
575
|
-
dimensions = _this$
|
|
576
|
-
featureFlags = _this$
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
647
|
+
var _this$props11 = this.props,
|
|
648
|
+
mediaClient = _this$props11.mediaClient,
|
|
649
|
+
identifier = _this$props11.identifier,
|
|
650
|
+
dimensions = _this$props11.dimensions,
|
|
651
|
+
featureFlags = _this$props11.featureFlags,
|
|
652
|
+
useInlinePlayer = _this$props11.useInlinePlayer,
|
|
653
|
+
disableOverlay = _this$props11.disableOverlay;
|
|
654
|
+
var _this$state3 = this.state,
|
|
655
|
+
isCardVisible = _this$state3.isCardVisible,
|
|
656
|
+
cardPreview = _this$state3.cardPreview,
|
|
657
|
+
status = _this$state3.status,
|
|
658
|
+
fileState = _this$state3.fileState,
|
|
659
|
+
isBannedLocalPreview = _this$state3.isBannedLocalPreview,
|
|
660
|
+
previewDidRender = _this$state3.previewDidRender,
|
|
661
|
+
isPlayingFile = _this$state3.isPlayingFile;
|
|
584
662
|
var isDifferent = (0, _mediaClient.isDifferentIdentifier)(prevIdentifier, identifier);
|
|
585
663
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
586
664
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -623,13 +701,28 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
623
701
|
this.resolvePreview(identifier, fileState);
|
|
624
702
|
}
|
|
625
703
|
|
|
704
|
+
if (turnedVisible && this.props.ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
705
|
+
// Since the SSR preview brings the token in the query params,
|
|
706
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
707
|
+
this.setCacheSSRPreview(identifier);
|
|
708
|
+
}
|
|
709
|
+
|
|
626
710
|
if (previewDidRender && // We should't complete if status is uploading
|
|
627
|
-
['loading
|
|
711
|
+
['loading-preview', 'processing'].includes(status)) {
|
|
628
712
|
this.safeSetState({
|
|
629
713
|
status: 'complete'
|
|
630
714
|
});
|
|
631
715
|
this.unsubscribe();
|
|
632
716
|
}
|
|
717
|
+
|
|
718
|
+
var isVideo = this.fileAttributes.fileMediatype === 'video';
|
|
719
|
+
var videoAvailableToPlay = fileState && (0, _mediaClient.isProcessedFileState)(fileState);
|
|
720
|
+
|
|
721
|
+
if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && videoAvailableToPlay && (0, _mediaCommon.getMediaFeatureFlag)('timestampOnVideo', this.props.featureFlags)) {
|
|
722
|
+
this.setState({
|
|
723
|
+
isPlayingFile: true
|
|
724
|
+
});
|
|
725
|
+
}
|
|
633
726
|
}
|
|
634
727
|
}, {
|
|
635
728
|
key: "componentWillUnmount",
|
|
@@ -680,7 +773,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
680
773
|
key: "requestedDimensions",
|
|
681
774
|
get: function get() {
|
|
682
775
|
var dimensions = this.props.dimensions;
|
|
683
|
-
|
|
776
|
+
|
|
777
|
+
var _ref3 = this.state || {},
|
|
778
|
+
element = _ref3.cardRef;
|
|
779
|
+
|
|
684
780
|
return (0, _getDataURIDimension.getRequestedDimensions)({
|
|
685
781
|
dimensions: dimensions,
|
|
686
782
|
element: element
|
|
@@ -689,23 +785,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
689
785
|
}, {
|
|
690
786
|
key: "metadata",
|
|
691
787
|
get: function get() {
|
|
692
|
-
var _this$
|
|
788
|
+
var _this$state4;
|
|
693
789
|
|
|
694
|
-
return (0, _metadata.getFileDetails)(this.props.identifier, (_this$
|
|
790
|
+
return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
|
|
695
791
|
}
|
|
696
792
|
}, {
|
|
697
793
|
key: "fileAttributes",
|
|
698
794
|
get: function get() {
|
|
699
|
-
var _this$
|
|
795
|
+
var _this$state5, _this$state5$fileStat;
|
|
700
796
|
|
|
701
|
-
return (0, _analytics.getFileAttributes)(this.metadata, (_this$
|
|
797
|
+
return (0, _analytics.getFileAttributes)(this.metadata, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : (_this$state5$fileStat = _this$state5.fileState) === null || _this$state5$fileStat === void 0 ? void 0 : _this$state5$fileStat.status);
|
|
702
798
|
}
|
|
703
799
|
}, {
|
|
704
800
|
key: "fireOperationalEvent",
|
|
705
801
|
value: function fireOperationalEvent() {
|
|
706
|
-
var _this$
|
|
707
|
-
status = _this$
|
|
708
|
-
error = _this$
|
|
802
|
+
var _this$state6 = this.state,
|
|
803
|
+
status = _this$state6.status,
|
|
804
|
+
error = _this$state6.error;
|
|
709
805
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
710
806
|
createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
|
|
711
807
|
}
|
|
@@ -725,11 +821,11 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
725
821
|
get: function get() {
|
|
726
822
|
var _this3 = this;
|
|
727
823
|
|
|
728
|
-
var _this$
|
|
729
|
-
_this$
|
|
730
|
-
actions = _this$
|
|
731
|
-
identifier = _this$
|
|
732
|
-
shouldEnableDownloadButton = _this$
|
|
824
|
+
var _this$props12 = this.props,
|
|
825
|
+
_this$props12$actions = _this$props12.actions,
|
|
826
|
+
actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
|
|
827
|
+
identifier = _this$props12.identifier,
|
|
828
|
+
shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
|
|
733
829
|
var status = this.state.status;
|
|
734
830
|
var metadata = this.metadata;
|
|
735
831
|
|
|
@@ -751,13 +847,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
751
847
|
}, {
|
|
752
848
|
key: "render",
|
|
753
849
|
value: function render() {
|
|
754
|
-
var _this$
|
|
755
|
-
isPlayingFile = _this$
|
|
756
|
-
mediaViewerSelectedItem = _this$
|
|
850
|
+
var _this$state7 = this.state,
|
|
851
|
+
isPlayingFile = _this$state7.isPlayingFile,
|
|
852
|
+
mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
|
|
757
853
|
|
|
758
854
|
var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
|
|
759
855
|
|
|
760
|
-
return this.
|
|
856
|
+
return this.props.intl ? innerContent : /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
|
|
761
857
|
locale: "en"
|
|
762
858
|
}, innerContent);
|
|
763
859
|
}
|
|
@@ -774,10 +870,6 @@ exports.CardBase = CardBase;
|
|
|
774
870
|
// Media Feature Flag defaults are defined in @atlaskit/media-common
|
|
775
871
|
featureFlags: {}
|
|
776
872
|
});
|
|
777
|
-
(0, _defineProperty2.default)(CardBase, "contextTypes", {
|
|
778
|
-
// Required to detect a parent IntlProvider
|
|
779
|
-
intl: _reactIntl.intlShape
|
|
780
|
-
});
|
|
781
873
|
var Card = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
782
874
|
packageVersion: _version.version,
|
|
783
875
|
packageName: _version.name,
|
|
@@ -785,5 +877,7 @@ var Card = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
|
785
877
|
component: 'mediaCard'
|
|
786
878
|
}, {
|
|
787
879
|
filterFeatureFlags: _cardAnalytics.relevantFeatureFlagNames
|
|
788
|
-
})((0, _analyticsNext.withAnalyticsEvents)()(CardBase
|
|
880
|
+
})((0, _analyticsNext.withAnalyticsEvents)()((0, _reactIntlNext.injectIntl)(CardBase, {
|
|
881
|
+
enforceContext: false
|
|
882
|
+
})));
|
|
789
883
|
exports.Card = Card;
|