@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
|
@@ -9,15 +9,15 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
11
|
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
+
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; }
|
|
13
13
|
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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) { _defineProperty(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
|
|
|
16
16
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
17
|
|
|
18
18
|
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; } }
|
|
19
19
|
|
|
20
|
-
import React, { Component } from 'react';
|
|
20
|
+
import React, { Component, createRef } from 'react';
|
|
21
21
|
import ReactDOM from 'react-dom';
|
|
22
22
|
import { version as packageVersion, name as packageName } from '../../version.json';
|
|
23
23
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -25,11 +25,11 @@ import { withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
|
25
25
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
26
26
|
import { globalMediaEventEmitter, isDifferentIdentifier, isFileIdentifier, RECENTS_COLLECTION, isImageRepresentationReady, isExternalImageIdentifier, imageResizeModeToFileImageMode } from '@atlaskit/media-client';
|
|
27
27
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
28
|
-
import {
|
|
28
|
+
import { injectIntl, IntlProvider } from 'react-intl-next';
|
|
29
29
|
import { CardView } from '../cardView';
|
|
30
|
-
import { ViewportDetector } from '../../utils/viewportDetector';
|
|
30
|
+
import { ABS_VIEWPORT_ANCHOR_OFFSET_TOP, ViewportDetector, ViewportAnchor } from '../../utils/viewportDetector';
|
|
31
31
|
import { getRequestedDimensions } from '../../utils/getDataURIDimension';
|
|
32
|
-
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview } from './getCardPreview';
|
|
32
|
+
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, fetchAndCacheRemotePreview } from './getCardPreview';
|
|
33
33
|
import { getFileDetails } from '../../utils/metadata';
|
|
34
34
|
import { InlinePlayer } from '../inlinePlayer';
|
|
35
35
|
import { getFileAttributes } from '../../utils/analytics';
|
|
@@ -37,6 +37,8 @@ import { isLocalPreviewError, MediaCardError, ensureMediaCardError, ImageLoadErr
|
|
|
37
37
|
import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, relevantFeatureFlagNames, fireCopiedEvent, fireScreenEvent } from './cardAnalytics';
|
|
38
38
|
import getDocument from '../../utils/document';
|
|
39
39
|
import { getCardStateFromFileState, createStateUpdater } from './cardState';
|
|
40
|
+
import { isProcessedFileState } from '@atlaskit/media-client';
|
|
41
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
40
42
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
41
43
|
_inherits(CardBase, _Component);
|
|
42
44
|
|
|
@@ -53,6 +55,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
53
55
|
|
|
54
56
|
_defineProperty(_assertThisInitialized(_this), "hasBeenMounted", false);
|
|
55
57
|
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "viewportPreAnchorRef", /*#__PURE__*/createRef());
|
|
59
|
+
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "viewportPostAnchorRef", /*#__PURE__*/createRef());
|
|
61
|
+
|
|
56
62
|
_defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
|
|
57
63
|
|
|
58
64
|
_defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
|
|
@@ -109,6 +115,28 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
109
115
|
};
|
|
110
116
|
});
|
|
111
117
|
|
|
118
|
+
_defineProperty(_assertThisInitialized(_this), "setCacheSSRPreview", function (identifier) {
|
|
119
|
+
var _this$props3 = _this.props,
|
|
120
|
+
mediaClient = _this$props3.mediaClient,
|
|
121
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
122
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
123
|
+
fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {// No need to log this error.
|
|
124
|
+
// If preview fails, it will be refetched later
|
|
125
|
+
//TODO: test this catch
|
|
126
|
+
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "resolveSSRPreview", function (identifier, ssr) {
|
|
131
|
+
var mediaClient = _this.props.mediaClient;
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
return getSSRCardPreview(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
135
|
+
} catch (e) {// TODO: log SSR reliability 'failed'
|
|
136
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
112
140
|
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
113
141
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
|
|
114
142
|
var params, cardPreview, wrappedError;
|
|
@@ -180,20 +208,31 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
180
208
|
_defineProperty(_assertThisInitialized(_this), "onImageError", function () {
|
|
181
209
|
var cardPreview = _this.state.cardPreview;
|
|
182
210
|
var error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
211
|
+
var isLocal = cardPreview && isLocalPreview(cardPreview);
|
|
212
|
+
var isSSR = cardPreview && isSSRClientPreview(cardPreview);
|
|
183
213
|
|
|
184
|
-
if (
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
189
|
-
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
|
|
214
|
+
if (isLocal || isSSR) {
|
|
215
|
+
var updateState = {
|
|
216
|
+
cardPreview: undefined
|
|
217
|
+
};
|
|
190
218
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
219
|
+
if (isLocal) {
|
|
220
|
+
updateState.isBannedLocalPreview = true;
|
|
221
|
+
|
|
222
|
+
_this.fireLocalPreviewErrorEvent(error);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (isSSR) {// TODO: set SSR-client reliability 'failed'.
|
|
226
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
var _this$props4 = _this.props,
|
|
230
|
+
identifier = _this$props4.identifier,
|
|
231
|
+
_this$props4$dimensio = _this$props4.dimensions,
|
|
232
|
+
dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
|
|
233
|
+
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
|
|
195
234
|
|
|
196
|
-
_this.
|
|
235
|
+
_this.safeSetState(updateState);
|
|
197
236
|
} else {
|
|
198
237
|
_this.safeSetState({
|
|
199
238
|
status: 'error',
|
|
@@ -248,10 +287,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
248
287
|
});
|
|
249
288
|
|
|
250
289
|
_defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
251
|
-
var _this$
|
|
252
|
-
identifier = _this$
|
|
253
|
-
useInlinePlayer = _this$
|
|
254
|
-
shouldOpenMediaViewer = _this$
|
|
290
|
+
var _this$props5 = _this.props,
|
|
291
|
+
identifier = _this$props5.identifier,
|
|
292
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
293
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
255
294
|
var cardPreview = _this.state.cardPreview;
|
|
256
295
|
|
|
257
296
|
var _assertThisInitialize2 = _assertThisInitialized(_this),
|
|
@@ -267,7 +306,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
267
306
|
|
|
268
307
|
if (useInlinePlayer && isVideo && !!cardPreview) {
|
|
269
308
|
_this.setState({
|
|
270
|
-
isPlayingFile: true
|
|
309
|
+
isPlayingFile: true,
|
|
310
|
+
shouldAutoplay: true
|
|
271
311
|
});
|
|
272
312
|
} else if (shouldOpenMediaViewer) {
|
|
273
313
|
var mediaViewerSelectedItem;
|
|
@@ -306,18 +346,20 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
306
346
|
});
|
|
307
347
|
|
|
308
348
|
_defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
|
|
309
|
-
var _this$
|
|
310
|
-
identifier = _this$
|
|
311
|
-
mediaClient = _this$
|
|
312
|
-
dimensions = _this$
|
|
313
|
-
selected = _this$
|
|
314
|
-
testId = _this$
|
|
315
|
-
originalDimensions = _this$
|
|
349
|
+
var _this$props6 = _this.props,
|
|
350
|
+
identifier = _this$props6.identifier,
|
|
351
|
+
mediaClient = _this$props6.mediaClient,
|
|
352
|
+
dimensions = _this$props6.dimensions,
|
|
353
|
+
selected = _this$props6.selected,
|
|
354
|
+
testId = _this$props6.testId,
|
|
355
|
+
originalDimensions = _this$props6.originalDimensions;
|
|
356
|
+
var shouldAutoplay = _this.state.shouldAutoplay;
|
|
316
357
|
return /*#__PURE__*/React.createElement(InlinePlayer, {
|
|
317
358
|
mediaClient: mediaClient,
|
|
318
359
|
dimensions: dimensions,
|
|
319
360
|
originalDimensions: originalDimensions,
|
|
320
361
|
identifier: identifier,
|
|
362
|
+
autoplay: !!shouldAutoplay,
|
|
321
363
|
onError: _this.onInlinePlayerError,
|
|
322
364
|
onClick: _this.onClick,
|
|
323
365
|
selected: selected,
|
|
@@ -355,12 +397,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
355
397
|
|
|
356
398
|
_defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
|
|
357
399
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
358
|
-
var _this$
|
|
359
|
-
mediaClient = _this$
|
|
360
|
-
identifier = _this$
|
|
361
|
-
mediaViewerDataSource = _this$
|
|
362
|
-
contextId = _this$
|
|
363
|
-
featureFlags = _this$
|
|
400
|
+
var _this$props7 = _this.props,
|
|
401
|
+
mediaClient = _this$props7.mediaClient,
|
|
402
|
+
identifier = _this$props7.identifier,
|
|
403
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
404
|
+
contextId = _this$props7.contextId,
|
|
405
|
+
featureFlags = _this$props7.featureFlags;
|
|
364
406
|
|
|
365
407
|
if (!mediaViewerSelectedItem) {
|
|
366
408
|
return;
|
|
@@ -382,20 +424,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
382
424
|
});
|
|
383
425
|
|
|
384
426
|
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
385
|
-
var _this$
|
|
386
|
-
identifier = _this$
|
|
387
|
-
isLazy = _this$
|
|
388
|
-
appearance = _this$
|
|
389
|
-
resizeMode = _this$
|
|
390
|
-
dimensions = _this$
|
|
391
|
-
selectable = _this$
|
|
392
|
-
selected = _this$
|
|
393
|
-
disableOverlay = _this$
|
|
394
|
-
alt = _this$
|
|
395
|
-
testId = _this$
|
|
396
|
-
featureFlags = _this$
|
|
397
|
-
titleBoxBgColor = _this$
|
|
398
|
-
titleBoxIcon = _this$
|
|
427
|
+
var _this$props8 = _this.props,
|
|
428
|
+
identifier = _this$props8.identifier,
|
|
429
|
+
isLazy = _this$props8.isLazy,
|
|
430
|
+
appearance = _this$props8.appearance,
|
|
431
|
+
resizeMode = _this$props8.resizeMode,
|
|
432
|
+
dimensions = _this$props8.dimensions,
|
|
433
|
+
selectable = _this$props8.selectable,
|
|
434
|
+
selected = _this$props8.selected,
|
|
435
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
436
|
+
alt = _this$props8.alt,
|
|
437
|
+
testId = _this$props8.testId,
|
|
438
|
+
featureFlags = _this$props8.featureFlags,
|
|
439
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
440
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
441
|
+
ssr = _this$props8.ssr;
|
|
399
442
|
var mediaItemType = identifier.mediaItemType;
|
|
400
443
|
var _this$state = _this.state,
|
|
401
444
|
status = _this$state.status,
|
|
@@ -408,7 +451,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
408
451
|
var dataURI = _this$state$cardPrevi.dataURI,
|
|
409
452
|
orientation = _this$state$cardPrevi.orientation,
|
|
410
453
|
error = _this$state.error,
|
|
411
|
-
cardRef = _this$state.cardRef
|
|
454
|
+
cardRef = _this$state.cardRef,
|
|
455
|
+
isCardVisible = _this$state.isCardVisible;
|
|
412
456
|
|
|
413
457
|
var _assertThisInitialize3 = _assertThisInitialized(_this),
|
|
414
458
|
metadata = _assertThisInitialize3.metadata;
|
|
@@ -417,8 +461,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
417
461
|
onCardViewClick = _assertThisInitialize4.onCardViewClick,
|
|
418
462
|
onDisplayImage = _assertThisInitialize4.onDisplayImage,
|
|
419
463
|
actions = _assertThisInitialize4.actions,
|
|
420
|
-
onMouseEnter = _assertThisInitialize4.onMouseEnter;
|
|
464
|
+
onMouseEnter = _assertThisInitialize4.onMouseEnter; // Card can be artificially turned visible before entering the viewport
|
|
465
|
+
// For example, when we have the image in cache
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
|
|
421
469
|
|
|
470
|
+
var forceSyncDisplay = !!ssr;
|
|
422
471
|
var card = /*#__PURE__*/React.createElement(CardView, {
|
|
423
472
|
status: status,
|
|
424
473
|
error: error,
|
|
@@ -444,12 +493,22 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
444
493
|
titleBoxBgColor: titleBoxBgColor,
|
|
445
494
|
titleBoxIcon: titleBoxIcon,
|
|
446
495
|
onImageError: _this.onImageError,
|
|
447
|
-
onImageLoad: _this.onImageLoad
|
|
496
|
+
onImageLoad: _this.onImageLoad,
|
|
497
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
498
|
+
forceSyncDisplay: forceSyncDisplay
|
|
448
499
|
});
|
|
449
500
|
return isLazy ? /*#__PURE__*/React.createElement(ViewportDetector, {
|
|
450
|
-
|
|
501
|
+
cardEl: cardRef,
|
|
502
|
+
preAnchorRef: _this.viewportPreAnchorRef,
|
|
503
|
+
postAnchorRef: _this.viewportPostAnchorRef,
|
|
451
504
|
onVisible: _this.onCardInViewport
|
|
452
|
-
},
|
|
505
|
+
}, /*#__PURE__*/React.createElement(ViewportAnchor, {
|
|
506
|
+
ref: _this.viewportPreAnchorRef,
|
|
507
|
+
offsetTop: -ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
508
|
+
}), card, /*#__PURE__*/React.createElement(ViewportAnchor, {
|
|
509
|
+
ref: _this.viewportPostAnchorRef,
|
|
510
|
+
offsetTop: ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
511
|
+
})) : card;
|
|
453
512
|
});
|
|
454
513
|
|
|
455
514
|
_defineProperty(_assertThisInitialized(_this), "onCardInViewport", function () {
|
|
@@ -492,14 +551,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
492
551
|
|
|
493
552
|
var _cardPreview;
|
|
494
553
|
|
|
495
|
-
var _this$
|
|
496
|
-
_identifier = _this$
|
|
497
|
-
_this$
|
|
498
|
-
_dimensions = _this$
|
|
554
|
+
var _this$props9 = _this.props,
|
|
555
|
+
_identifier = _this$props9.identifier,
|
|
556
|
+
_this$props9$dimensio = _this$props9.dimensions,
|
|
557
|
+
_dimensions = _this$props9$dimensio === void 0 ? {} : _this$props9$dimensio,
|
|
558
|
+
_ssr = _this$props9.ssr;
|
|
499
559
|
|
|
500
560
|
if (isFileIdentifier(_identifier)) {
|
|
501
561
|
var id = _identifier.id;
|
|
502
562
|
_cardPreview = getCardPreviewFromCache(id, _dimensions);
|
|
563
|
+
|
|
564
|
+
if (!_cardPreview && _ssr) {
|
|
565
|
+
_this.fireCommencedEvent();
|
|
566
|
+
|
|
567
|
+
_cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
|
|
568
|
+
}
|
|
503
569
|
} else if (isExternalImageIdentifier(_identifier)) {
|
|
504
570
|
_this.fireCommencedEvent();
|
|
505
571
|
|
|
@@ -510,15 +576,19 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
510
576
|
orientation: 1,
|
|
511
577
|
source: 'external'
|
|
512
578
|
};
|
|
513
|
-
} //
|
|
514
|
-
//
|
|
579
|
+
} // If cardPreview is available from local cache or external, `isCardVisible`
|
|
580
|
+
// should be true to avoid flickers during re-mount of the component
|
|
581
|
+
// should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
|
|
582
|
+
// outside the viewport
|
|
583
|
+
|
|
515
584
|
|
|
585
|
+
var _isCardVisible = !_this.props.isLazy || !!_cardPreview && !isSSRPreview(_cardPreview);
|
|
516
586
|
|
|
517
|
-
var isCardVisible = _cardPreview ? true : !_this.props.isLazy;
|
|
518
587
|
_this.state = {
|
|
519
588
|
status: _status,
|
|
520
|
-
isCardVisible:
|
|
589
|
+
isCardVisible: _isCardVisible,
|
|
521
590
|
isPlayingFile: false,
|
|
591
|
+
shouldAutoplay: false,
|
|
522
592
|
cardPreview: _cardPreview,
|
|
523
593
|
cardRef: null,
|
|
524
594
|
isBannedLocalPreview: false,
|
|
@@ -531,11 +601,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
531
601
|
key: "componentDidMount",
|
|
532
602
|
value: function componentDidMount() {
|
|
533
603
|
this.hasBeenMounted = true;
|
|
534
|
-
var
|
|
535
|
-
|
|
604
|
+
var _this$state2 = this.state,
|
|
605
|
+
isCardVisible = _this$state2.isCardVisible,
|
|
606
|
+
cardPreview = _this$state2.cardPreview;
|
|
607
|
+
var _this$props10 = this.props,
|
|
608
|
+
identifier = _this$props10.identifier,
|
|
609
|
+
ssr = _this$props10.ssr;
|
|
536
610
|
|
|
537
611
|
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
538
612
|
this.updateStateForIdentifier(identifier);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (isCardVisible && !!ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
|
|
616
|
+
// Since the SSR preview brings the token in the query params,
|
|
617
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
618
|
+
this.setCacheSSRPreview(identifier);
|
|
539
619
|
} // we add a listener for each of the cards on the page
|
|
540
620
|
// and then check if the triggered listener is from the card
|
|
541
621
|
// that contains a div in current window.getSelection()
|
|
@@ -551,18 +631,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
551
631
|
prevIdentifier = prevProps.identifier,
|
|
552
632
|
prevDimensions = prevProps.dimensions;
|
|
553
633
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
554
|
-
var _this$
|
|
555
|
-
mediaClient = _this$
|
|
556
|
-
identifier = _this$
|
|
557
|
-
dimensions = _this$
|
|
558
|
-
featureFlags = _this$
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
634
|
+
var _this$props11 = this.props,
|
|
635
|
+
mediaClient = _this$props11.mediaClient,
|
|
636
|
+
identifier = _this$props11.identifier,
|
|
637
|
+
dimensions = _this$props11.dimensions,
|
|
638
|
+
featureFlags = _this$props11.featureFlags,
|
|
639
|
+
useInlinePlayer = _this$props11.useInlinePlayer,
|
|
640
|
+
disableOverlay = _this$props11.disableOverlay;
|
|
641
|
+
var _this$state3 = this.state,
|
|
642
|
+
isCardVisible = _this$state3.isCardVisible,
|
|
643
|
+
cardPreview = _this$state3.cardPreview,
|
|
644
|
+
status = _this$state3.status,
|
|
645
|
+
fileState = _this$state3.fileState,
|
|
646
|
+
isBannedLocalPreview = _this$state3.isBannedLocalPreview,
|
|
647
|
+
previewDidRender = _this$state3.previewDidRender,
|
|
648
|
+
isPlayingFile = _this$state3.isPlayingFile;
|
|
566
649
|
var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
567
650
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
568
651
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -605,13 +688,28 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
605
688
|
this.resolvePreview(identifier, fileState);
|
|
606
689
|
}
|
|
607
690
|
|
|
691
|
+
if (turnedVisible && this.props.ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
|
|
692
|
+
// Since the SSR preview brings the token in the query params,
|
|
693
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
694
|
+
this.setCacheSSRPreview(identifier);
|
|
695
|
+
}
|
|
696
|
+
|
|
608
697
|
if (previewDidRender && // We should't complete if status is uploading
|
|
609
|
-
['loading
|
|
698
|
+
['loading-preview', 'processing'].includes(status)) {
|
|
610
699
|
this.safeSetState({
|
|
611
700
|
status: 'complete'
|
|
612
701
|
});
|
|
613
702
|
this.unsubscribe();
|
|
614
703
|
}
|
|
704
|
+
|
|
705
|
+
var isVideo = this.fileAttributes.fileMediatype === 'video';
|
|
706
|
+
var videoAvailableToPlay = fileState && isProcessedFileState(fileState);
|
|
707
|
+
|
|
708
|
+
if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && videoAvailableToPlay && getMediaFeatureFlag('timestampOnVideo', this.props.featureFlags)) {
|
|
709
|
+
this.setState({
|
|
710
|
+
isPlayingFile: true
|
|
711
|
+
});
|
|
712
|
+
}
|
|
615
713
|
}
|
|
616
714
|
}, {
|
|
617
715
|
key: "componentWillUnmount",
|
|
@@ -662,7 +760,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
662
760
|
key: "requestedDimensions",
|
|
663
761
|
get: function get() {
|
|
664
762
|
var dimensions = this.props.dimensions;
|
|
665
|
-
|
|
763
|
+
|
|
764
|
+
var _ref3 = this.state || {},
|
|
765
|
+
element = _ref3.cardRef;
|
|
766
|
+
|
|
666
767
|
return getRequestedDimensions({
|
|
667
768
|
dimensions: dimensions,
|
|
668
769
|
element: element
|
|
@@ -671,23 +772,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
671
772
|
}, {
|
|
672
773
|
key: "metadata",
|
|
673
774
|
get: function get() {
|
|
674
|
-
var _this$
|
|
775
|
+
var _this$state4;
|
|
675
776
|
|
|
676
|
-
return getFileDetails(this.props.identifier, (_this$
|
|
777
|
+
return getFileDetails(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
|
|
677
778
|
}
|
|
678
779
|
}, {
|
|
679
780
|
key: "fileAttributes",
|
|
680
781
|
get: function get() {
|
|
681
|
-
var _this$
|
|
782
|
+
var _this$state5, _this$state5$fileStat;
|
|
682
783
|
|
|
683
|
-
return getFileAttributes(this.metadata, (_this$
|
|
784
|
+
return getFileAttributes(this.metadata, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : (_this$state5$fileStat = _this$state5.fileState) === null || _this$state5$fileStat === void 0 ? void 0 : _this$state5$fileStat.status);
|
|
684
785
|
}
|
|
685
786
|
}, {
|
|
686
787
|
key: "fireOperationalEvent",
|
|
687
788
|
value: function fireOperationalEvent() {
|
|
688
|
-
var _this$
|
|
689
|
-
status = _this$
|
|
690
|
-
error = _this$
|
|
789
|
+
var _this$state6 = this.state,
|
|
790
|
+
status = _this$state6.status,
|
|
791
|
+
error = _this$state6.error;
|
|
691
792
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
692
793
|
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
|
|
693
794
|
}
|
|
@@ -707,11 +808,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
707
808
|
get: function get() {
|
|
708
809
|
var _this3 = this;
|
|
709
810
|
|
|
710
|
-
var _this$
|
|
711
|
-
_this$
|
|
712
|
-
actions = _this$
|
|
713
|
-
identifier = _this$
|
|
714
|
-
shouldEnableDownloadButton = _this$
|
|
811
|
+
var _this$props12 = this.props,
|
|
812
|
+
_this$props12$actions = _this$props12.actions,
|
|
813
|
+
actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
|
|
814
|
+
identifier = _this$props12.identifier,
|
|
815
|
+
shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
|
|
715
816
|
var status = this.state.status;
|
|
716
817
|
var metadata = this.metadata;
|
|
717
818
|
|
|
@@ -733,11 +834,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
733
834
|
}, {
|
|
734
835
|
key: "render",
|
|
735
836
|
value: function render() {
|
|
736
|
-
var _this$
|
|
737
|
-
isPlayingFile = _this$
|
|
738
|
-
mediaViewerSelectedItem = _this$
|
|
837
|
+
var _this$state7 = this.state,
|
|
838
|
+
isPlayingFile = _this$state7.isPlayingFile,
|
|
839
|
+
mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
|
|
739
840
|
var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
|
|
740
|
-
return this.
|
|
841
|
+
return this.props.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
741
842
|
locale: "en"
|
|
742
843
|
}, innerContent);
|
|
743
844
|
}
|
|
@@ -755,11 +856,6 @@ _defineProperty(CardBase, "defaultProps", {
|
|
|
755
856
|
featureFlags: {}
|
|
756
857
|
});
|
|
757
858
|
|
|
758
|
-
_defineProperty(CardBase, "contextTypes", {
|
|
759
|
-
// Required to detect a parent IntlProvider
|
|
760
|
-
intl: intlShape
|
|
761
|
-
});
|
|
762
|
-
|
|
763
859
|
export var Card = withMediaAnalyticsContext({
|
|
764
860
|
packageVersion: packageVersion,
|
|
765
861
|
packageName: packageName,
|
|
@@ -767,4 +863,6 @@ export var Card = withMediaAnalyticsContext({
|
|
|
767
863
|
component: 'mediaCard'
|
|
768
864
|
}, {
|
|
769
865
|
filterFeatureFlags: relevantFeatureFlagNames
|
|
770
|
-
})(withAnalyticsEvents()(CardBase
|
|
866
|
+
})(withAnalyticsEvents()(injectIntl(CardBase, {
|
|
867
|
+
enforceContext: false
|
|
868
|
+
})));
|