@atlaskit/media-card 77.12.4 → 78.0.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 +15 -0
- package/dist/cjs/card/card.js +20 -1039
- package/dist/cjs/card/cardLoader.js +2 -2
- package/dist/cjs/card/cardView.js +255 -417
- package/dist/cjs/card/cardWithMediaClient.js +5 -9
- package/dist/cjs/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
- package/dist/cjs/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
- package/dist/cjs/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
- package/dist/cjs/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
- package/dist/cjs/card/{v2/cardviews → cardviews}/index.js +2 -2
- package/dist/cjs/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
- package/dist/cjs/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
- package/dist/cjs/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
- package/dist/cjs/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
- package/dist/cjs/card/{v2/fileCard.js → fileCard.js} +18 -18
- package/dist/cjs/card/index.js +2 -2
- package/dist/cjs/card/inlinePlayer.js +184 -267
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/{v2/svgView → svgView}/svgView.js +9 -9
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +20 -1023
- package/dist/es2019/card/cardLoader.js +2 -2
- package/dist/es2019/card/cardView.js +252 -403
- package/dist/es2019/card/cardWithMediaClient.js +6 -10
- package/dist/es2019/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
- package/dist/es2019/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
- package/dist/es2019/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
- package/dist/es2019/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
- package/dist/es2019/card/{v2/cardviews → cardviews}/index.js +2 -2
- package/dist/es2019/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
- package/dist/es2019/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
- package/dist/es2019/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
- package/dist/es2019/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
- package/dist/es2019/card/{v2/fileCard.js → fileCard.js} +18 -18
- package/dist/es2019/card/index.js +1 -1
- package/dist/es2019/card/inlinePlayer.js +127 -208
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/{v2/svgView → svgView}/svgView.js +9 -9
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +21 -1040
- package/dist/esm/card/cardLoader.js +2 -2
- package/dist/esm/card/cardView.js +251 -416
- package/dist/esm/card/cardWithMediaClient.js +6 -10
- package/dist/esm/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
- package/dist/esm/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
- package/dist/esm/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
- package/dist/esm/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
- package/dist/esm/card/{v2/cardviews → cardviews}/index.js +2 -2
- package/dist/esm/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
- package/dist/esm/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
- package/dist/esm/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
- package/dist/esm/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
- package/dist/esm/card/{v2/fileCard.js → fileCard.js} +18 -18
- package/dist/esm/card/index.js +1 -1
- package/dist/esm/card/inlinePlayer.js +185 -269
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/{v2/svgView → svgView}/svgView.js +9 -9
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/card.d.ts +5 -66
- package/dist/types/card/cardLoader.d.ts +1 -1
- package/dist/types/card/cardView.d.ts +23 -45
- package/dist/types/card/cardWithMediaClient.d.ts +1 -1
- package/dist/types/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
- package/dist/types/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
- package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/iconCardView.d.ts +1 -1
- package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/imageCardView.d.ts +1 -1
- package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/index.d.ts +5 -5
- package/dist/types/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
- package/dist/types/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
- package/dist/types/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
- package/dist/types/card/index.d.ts +1 -1
- package/dist/types/card/inlinePlayer.d.ts +2 -31
- package/dist/types/card/{v2/svgView → svgView}/errors.d.ts +1 -1
- package/dist/{types-ts4.5/card/v2 → types/card}/svgView/svgView.d.ts +2 -2
- package/dist/types-ts4.5/card/card.d.ts +5 -66
- package/dist/types-ts4.5/card/cardLoader.d.ts +1 -1
- package/dist/types-ts4.5/card/cardView.d.ts +23 -45
- package/dist/types-ts4.5/card/cardWithMediaClient.d.ts +1 -1
- package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
- package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
- package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/iconCardView.d.ts +1 -1
- package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/imageCardView.d.ts +1 -1
- package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/index.d.ts +5 -5
- package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
- package/dist/types-ts4.5/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
- package/dist/types-ts4.5/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
- package/dist/types-ts4.5/card/index.d.ts +1 -1
- package/dist/types-ts4.5/card/inlinePlayer.d.ts +2 -31
- package/dist/types-ts4.5/card/{v2/svgView → svgView}/errors.d.ts +1 -1
- package/dist/{types/card/v2 → types-ts4.5/card}/svgView/svgView.d.ts +2 -2
- package/package.json +3 -6
- package/dist/cjs/card/cardSwitcher.js +0 -15
- package/dist/cjs/card/v2/cardV2.js +0 -41
- package/dist/cjs/card/v2/cardV2Loader.js +0 -36
- package/dist/cjs/card/v2/cardViewV2.js +0 -298
- package/dist/cjs/card/v2/cardWithMediaClientV2.js +0 -34
- package/dist/cjs/card/v2/inlinePlayerLazyV2.js +0 -35
- package/dist/cjs/card/v2/inlinePlayerV2.js +0 -224
- package/dist/es2019/card/cardSwitcher.js +0 -8
- package/dist/es2019/card/v2/cardV2.js +0 -33
- package/dist/es2019/card/v2/cardV2Loader.js +0 -18
- package/dist/es2019/card/v2/cardViewV2.js +0 -294
- package/dist/es2019/card/v2/cardWithMediaClientV2.js +0 -25
- package/dist/es2019/card/v2/inlinePlayerLazyV2.js +0 -10
- package/dist/es2019/card/v2/inlinePlayerV2.js +0 -166
- package/dist/esm/card/cardSwitcher.js +0 -8
- package/dist/esm/card/v2/cardV2.js +0 -34
- package/dist/esm/card/v2/cardV2Loader.js +0 -24
- package/dist/esm/card/v2/cardViewV2.js +0 -290
- package/dist/esm/card/v2/cardWithMediaClientV2.js +0 -27
- package/dist/esm/card/v2/inlinePlayerLazyV2.js +0 -23
- package/dist/esm/card/v2/inlinePlayerV2.js +0 -214
- package/dist/types/card/cardSwitcher.d.ts +0 -4
- package/dist/types/card/v2/cardV2.d.ts +0 -7
- package/dist/types/card/v2/cardV2Loader.d.ts +0 -4
- package/dist/types/card/v2/cardViewV2.d.ts +0 -59
- package/dist/types/card/v2/cardWithMediaClientV2.d.ts +0 -3
- package/dist/types/card/v2/inlinePlayerLazyV2.d.ts +0 -2
- package/dist/types/card/v2/inlinePlayerV2.d.ts +0 -24
- package/dist/types-ts4.5/card/cardSwitcher.d.ts +0 -4
- package/dist/types-ts4.5/card/v2/cardV2.d.ts +0 -7
- package/dist/types-ts4.5/card/v2/cardV2Loader.d.ts +0 -4
- package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +0 -59
- package/dist/types-ts4.5/card/v2/cardWithMediaClientV2.d.ts +0 -3
- package/dist/types-ts4.5/card/v2/inlinePlayerLazyV2.d.ts +0 -2
- package/dist/types-ts4.5/card/v2/inlinePlayerV2.d.ts +0 -24
- /package/dist/cjs/card/{v2/performance.js → performance.js} +0 -0
- /package/dist/cjs/card/{v2/svgView → svgView}/errors.js +0 -0
- /package/dist/cjs/card/{v2/svgView → svgView}/helpers.js +0 -0
- /package/dist/cjs/card/{v2/svgView → svgView}/index.js +0 -0
- /package/dist/es2019/card/{v2/performance.js → performance.js} +0 -0
- /package/dist/es2019/card/{v2/svgView → svgView}/errors.js +0 -0
- /package/dist/es2019/card/{v2/svgView → svgView}/helpers.js +0 -0
- /package/dist/es2019/card/{v2/svgView → svgView}/index.js +0 -0
- /package/dist/esm/card/{v2/performance.js → performance.js} +0 -0
- /package/dist/esm/card/{v2/svgView → svgView}/errors.js +0 -0
- /package/dist/esm/card/{v2/svgView → svgView}/helpers.js +0 -0
- /package/dist/esm/card/{v2/svgView → svgView}/index.js +0 -0
- /package/dist/types/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
- /package/dist/types/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
- /package/dist/types/card/{v2/performance.d.ts → performance.d.ts} +0 -0
- /package/dist/types/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
- /package/dist/types/card/{v2/svgView → svgView}/index.d.ts +0 -0
- /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
- /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
- /package/dist/types-ts4.5/card/{v2/performance.d.ts → performance.d.ts} +0 -0
- /package/dist/types-ts4.5/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
- /package/dist/types-ts4.5/card/{v2/svgView → svgView}/index.d.ts +0 -0
package/dist/esm/card/card.js
CHANGED
|
@@ -1,1053 +1,34 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
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); }; }
|
|
15
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
-
import React, { Component, Suspense, useContext } from 'react';
|
|
17
|
-
import ReactDOM from 'react-dom';
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["identifier"];
|
|
18
4
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import { isFileIdentifier } from '@atlaskit/media-client';
|
|
19
6
|
import { withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { injectIntl, IntlProvider } from 'react-intl-next';
|
|
25
|
-
import { CardView } from './cardView';
|
|
26
|
-
import { ViewportDetector } from '../utils/viewportDetector';
|
|
27
|
-
import { videoIsPlayable } from '../utils/videoIsPlayable';
|
|
28
|
-
import { getRequestedDimensions } from '../utils/getDataURIDimension';
|
|
29
|
-
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, isSSRDataPreview, fetchAndCacheRemotePreview } from './getCardPreview';
|
|
30
|
-
import { getFileDetails } from '../utils/metadata';
|
|
31
|
-
import { InlinePlayerLazy } from './inlinePlayerLazy';
|
|
32
|
-
import { getFileAttributes, extractErrorInfo } from '../utils/analytics';
|
|
33
|
-
import { isLocalPreviewError, MediaCardError, ensureMediaCardError, ImageLoadError } from '../errors';
|
|
34
|
-
import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, fireCopiedEvent, fireScreenEvent, fireNonCriticalErrorEvent } from './cardAnalytics';
|
|
35
|
-
import getDocument from '../utils/document';
|
|
36
|
-
import { generateScriptProps, getSSRData } from '../utils/globalScope';
|
|
37
|
-
import { getCardStateFromFileState, createStateUpdater } from './cardState';
|
|
38
|
-
import { isBigger } from '../utils/dimensionComparer';
|
|
39
|
-
import { getMediaCardCursor } from '../utils/getMediaCardCursor';
|
|
40
|
-
import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '../utils/ufoExperiences';
|
|
41
|
-
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
42
|
-
import { DateOverrideContext } from '../dateOverrideContext';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
9
|
+
import { ExternalImageCard } from './externalImageCard';
|
|
10
|
+
import { FileCard } from './fileCard';
|
|
43
11
|
var packageName = "@atlaskit/media-card";
|
|
44
|
-
var packageVersion = "
|
|
45
|
-
export var CardBase =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_defineProperty(_assertThisInitialized(_this), "internalOccurrenceKey", generateUniqueId());
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "hasBeenMounted", false);
|
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "mediaViewerButtonRef", null);
|
|
57
|
-
_defineProperty(_assertThisInitialized(_this), "fileStateFlags", {
|
|
58
|
-
wasStatusUploading: false,
|
|
59
|
-
wasStatusProcessing: false
|
|
60
|
-
});
|
|
61
|
-
_defineProperty(_assertThisInitialized(_this), "ssrReliability", {
|
|
62
|
-
server: {
|
|
63
|
-
status: 'unknown'
|
|
64
|
-
},
|
|
65
|
-
client: {
|
|
66
|
-
status: 'unknown'
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
// We initialise timeElapsedTillCommenced
|
|
70
|
-
// to avoid extra branching on a possibly undefined value.
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
|
|
72
|
-
// Generate unique traceId for file
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "traceContext", {
|
|
74
|
-
traceId: getRandomHex(8)
|
|
75
|
-
});
|
|
76
|
-
_defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
|
|
77
|
-
var collection = _ref.collectionName;
|
|
78
|
-
return _objectSpread(_objectSpread({
|
|
79
|
-
collection: collection,
|
|
80
|
-
mode: imageResizeModeToFileImageMode(_this.props.resizeMode)
|
|
81
|
-
}, _this.requestedDimensions), {}, {
|
|
82
|
-
allowAnimated: true
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "getMediaBlobUrlAttrs", function (identifier, fileState) {
|
|
86
|
-
var id = identifier.id,
|
|
87
|
-
collection = identifier.collectionName;
|
|
88
|
-
var _this$props = _this.props,
|
|
89
|
-
originalDimensions = _this$props.originalDimensions,
|
|
90
|
-
contextId = _this$props.contextId,
|
|
91
|
-
alt = _this$props.alt;
|
|
92
|
-
var _getFileDetails = getFileDetails(identifier, fileState),
|
|
93
|
-
mimeType = _getFileDetails.mimeType,
|
|
94
|
-
name = _getFileDetails.name,
|
|
95
|
-
size = _getFileDetails.size;
|
|
96
|
-
return contextId ? _objectSpread(_objectSpread({
|
|
97
|
-
id: id,
|
|
98
|
-
collection: collection,
|
|
99
|
-
contextId: contextId,
|
|
100
|
-
mimeType: mimeType,
|
|
101
|
-
name: name,
|
|
102
|
-
size: size
|
|
103
|
-
}, originalDimensions || _this.requestedDimensions), {}, {
|
|
104
|
-
alt: alt
|
|
105
|
-
}) : undefined;
|
|
106
|
-
});
|
|
107
|
-
_defineProperty(_assertThisInitialized(_this), "getCardPreviewParams", function (identifier, fileState) {
|
|
108
|
-
var isBannedLocalPreview = _this.state.isBannedLocalPreview;
|
|
109
|
-
var id = identifier.id;
|
|
110
|
-
var _this$props2 = _this.props,
|
|
111
|
-
_this$props2$dimensio = _this$props2.dimensions,
|
|
112
|
-
dimensions = _this$props2$dimensio === void 0 ? {} : _this$props2$dimensio,
|
|
113
|
-
mediaClient = _this$props2.mediaClient;
|
|
114
|
-
return {
|
|
115
|
-
mediaClient: mediaClient,
|
|
116
|
-
id: id,
|
|
117
|
-
dimensions: dimensions,
|
|
118
|
-
onLocalPreviewError: _this.fireNonCriticalErrorEvent,
|
|
119
|
-
filePreview: isBannedLocalPreview ? undefined : getFilePreviewFromFileState(fileState),
|
|
120
|
-
isRemotePreviewReady: isImageRepresentationReady(fileState),
|
|
121
|
-
imageUrlParams: _this.getImageURLParams(identifier),
|
|
122
|
-
mediaBlobUrlAttrs: _this.getMediaBlobUrlAttrs(identifier, fileState),
|
|
123
|
-
traceContext: _this.traceContext
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
_defineProperty(_assertThisInitialized(_this), "setCacheSSRPreview", function (identifier) {
|
|
127
|
-
_this.fetchAndCacheRemotePreview(identifier).catch(function () {
|
|
128
|
-
// No need to log this error.
|
|
129
|
-
// If preview fails, it will be refetched later
|
|
130
|
-
//TODO: test this catch
|
|
131
|
-
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
_defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
|
|
135
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
|
|
136
|
-
var cardPreview, wrappedError;
|
|
137
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
138
|
-
while (1) switch (_context.prev = _context.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
_context.prev = 0;
|
|
141
|
-
_context.next = 3;
|
|
142
|
-
return _this.fetchAndCacheRemotePreview(identifier);
|
|
143
|
-
case 3:
|
|
144
|
-
cardPreview = _context.sent;
|
|
145
|
-
_this.safeSetState({
|
|
146
|
-
cardPreview: cardPreview
|
|
147
|
-
});
|
|
148
|
-
_context.next = 11;
|
|
149
|
-
break;
|
|
150
|
-
case 7:
|
|
151
|
-
_context.prev = 7;
|
|
152
|
-
_context.t0 = _context["catch"](0);
|
|
153
|
-
wrappedError = ensureMediaCardError('remote-preview-fetch-ssr', _context.t0, true);
|
|
154
|
-
_this.fireNonCriticalErrorEvent(wrappedError);
|
|
155
|
-
case 11:
|
|
156
|
-
case "end":
|
|
157
|
-
return _context.stop();
|
|
158
|
-
}
|
|
159
|
-
}, _callee, null, [[0, 7]]);
|
|
160
|
-
}));
|
|
161
|
-
return function (_x) {
|
|
162
|
-
return _ref2.apply(this, arguments);
|
|
163
|
-
};
|
|
164
|
-
}());
|
|
165
|
-
_defineProperty(_assertThisInitialized(_this), "resolveUpfrontPreview", /*#__PURE__*/function () {
|
|
166
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier) {
|
|
167
|
-
var requestedDimensions, cardPreview, currentDimensions, areValidRequestedDimensions;
|
|
168
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
169
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
170
|
-
case 0:
|
|
171
|
-
requestedDimensions = _objectSpread({}, _this.props.dimensions);
|
|
172
|
-
_context2.prev = 1;
|
|
173
|
-
_context2.next = 4;
|
|
174
|
-
return _this.fetchAndCacheRemotePreview(identifier);
|
|
175
|
-
case 4:
|
|
176
|
-
cardPreview = _context2.sent;
|
|
177
|
-
currentDimensions = _this.props.dimensions;
|
|
178
|
-
areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
|
|
179
|
-
// the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
|
|
180
|
-
// to trigger a normal preview fetch.
|
|
181
|
-
if (areValidRequestedDimensions) {
|
|
182
|
-
_this.safeSetState({
|
|
183
|
-
cardPreview: cardPreview,
|
|
184
|
-
wasResolvedUpfrontPreview: true
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
_this.safeSetState({
|
|
188
|
-
wasResolvedUpfrontPreview: true
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
_context2.next = 13;
|
|
192
|
-
break;
|
|
193
|
-
case 10:
|
|
194
|
-
_context2.prev = 10;
|
|
195
|
-
_context2.t0 = _context2["catch"](1);
|
|
196
|
-
_this.safeSetState({
|
|
197
|
-
wasResolvedUpfrontPreview: true
|
|
198
|
-
});
|
|
199
|
-
// NO need to log error. If this call fails, a refetch will happen after
|
|
200
|
-
case 13:
|
|
201
|
-
case "end":
|
|
202
|
-
return _context2.stop();
|
|
203
|
-
}
|
|
204
|
-
}, _callee2, null, [[1, 10]]);
|
|
205
|
-
}));
|
|
206
|
-
return function (_x2) {
|
|
207
|
-
return _ref3.apply(this, arguments);
|
|
208
|
-
};
|
|
209
|
-
}());
|
|
210
|
-
_defineProperty(_assertThisInitialized(_this), "fetchAndCacheRemotePreview", function (identifier) {
|
|
211
|
-
var _this$props3 = _this.props,
|
|
212
|
-
mediaClient = _this$props3.mediaClient,
|
|
213
|
-
_this$props3$dimensio = _this$props3.dimensions,
|
|
214
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
215
|
-
return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
216
|
-
});
|
|
217
|
-
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
218
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(identifier, fileState) {
|
|
219
|
-
var params, cardPreview, wrappedError;
|
|
220
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
221
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
222
|
-
case 0:
|
|
223
|
-
_context3.prev = 0;
|
|
224
|
-
params = _this.getCardPreviewParams(identifier, fileState);
|
|
225
|
-
_context3.next = 4;
|
|
226
|
-
return getCardPreview(params);
|
|
227
|
-
case 4:
|
|
228
|
-
cardPreview = _context3.sent;
|
|
229
|
-
_this.safeSetState({
|
|
230
|
-
cardPreview: cardPreview
|
|
231
|
-
});
|
|
232
|
-
_context3.next = 12;
|
|
233
|
-
break;
|
|
234
|
-
case 8:
|
|
235
|
-
_context3.prev = 8;
|
|
236
|
-
_context3.t0 = _context3["catch"](0);
|
|
237
|
-
wrappedError = ensureMediaCardError('preview-fetch', _context3.t0); // If remote preview fails, we set status 'error'
|
|
238
|
-
// If local preview fails (i.e, no remote preview available),
|
|
239
|
-
// we can stay in the same status until there is a remote preview available
|
|
240
|
-
// If it's any other error we set status 'error'
|
|
241
|
-
if (isLocalPreviewError(wrappedError)) {
|
|
242
|
-
// This error should already been logged inside the getCardPreview. No need to log it here.
|
|
243
|
-
_this.safeSetState({
|
|
244
|
-
isBannedLocalPreview: true
|
|
245
|
-
});
|
|
246
|
-
} else {
|
|
247
|
-
_this.safeSetState({
|
|
248
|
-
status: 'error',
|
|
249
|
-
error: wrappedError
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
case 12:
|
|
253
|
-
case "end":
|
|
254
|
-
return _context3.stop();
|
|
255
|
-
}
|
|
256
|
-
}, _callee3, null, [[0, 8]]);
|
|
257
|
-
}));
|
|
258
|
-
return function (_x3, _x4) {
|
|
259
|
-
return _ref4.apply(this, arguments);
|
|
260
|
-
};
|
|
261
|
-
}());
|
|
262
|
-
_defineProperty(_assertThisInitialized(_this), "getPerformanceAttributes", function () {
|
|
263
|
-
var _assertThisInitialize = _assertThisInitialized(_this),
|
|
264
|
-
timeElapsedTillCommenced = _assertThisInitialize.timeElapsedTillCommenced;
|
|
265
|
-
var timeElapsedTillEvent = performance.now();
|
|
266
|
-
var durationSinceCommenced = timeElapsedTillCommenced && timeElapsedTillEvent - timeElapsedTillCommenced;
|
|
267
|
-
return {
|
|
268
|
-
overall: {
|
|
269
|
-
durationSincePageStart: timeElapsedTillEvent,
|
|
270
|
-
durationSinceCommenced: durationSinceCommenced
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
});
|
|
274
|
-
_defineProperty(_assertThisInitialized(_this), "logSSRImageError", function (cardPreview) {
|
|
275
|
-
if (cardPreview) {
|
|
276
|
-
var failedSSRObject = _objectSpread({
|
|
277
|
-
status: 'fail'
|
|
278
|
-
}, extractErrorInfo(new ImageLoadError(cardPreview.source)));
|
|
279
|
-
if (isSSRClientPreview(cardPreview)) {
|
|
280
|
-
_this.ssrReliability.client = failedSSRObject;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/*
|
|
284
|
-
If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
|
|
285
|
-
*/
|
|
286
|
-
|
|
287
|
-
if (isSSRDataPreview(cardPreview)) {
|
|
288
|
-
_this.ssrReliability.server = failedSSRObject;
|
|
289
|
-
_this.ssrReliability.client = failedSSRObject;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
_defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
|
|
294
|
-
_this.logSSRImageError(cardPreview);
|
|
295
|
-
var currentPreview = _this.state.cardPreview;
|
|
296
|
-
// If the dataURI has been replaced, we can dismiss this error
|
|
297
|
-
if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
var error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
301
|
-
var isLocal = cardPreview && isLocalPreview(cardPreview);
|
|
302
|
-
var isSSR = cardPreview && (isSSRClientPreview(cardPreview) || isSSRDataPreview(cardPreview));
|
|
303
|
-
if (isLocal || isSSR) {
|
|
304
|
-
var updateState = {
|
|
305
|
-
cardPreview: undefined
|
|
306
|
-
};
|
|
307
|
-
if (isLocal) {
|
|
308
|
-
updateState.isBannedLocalPreview = true;
|
|
309
|
-
_this.fireNonCriticalErrorEvent(error);
|
|
310
|
-
}
|
|
311
|
-
var _this$props4 = _this.props,
|
|
312
|
-
identifier = _this$props4.identifier,
|
|
313
|
-
resizeMode = _this$props4.resizeMode;
|
|
314
|
-
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
315
|
-
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, fileImageMode);
|
|
316
|
-
_this.safeSetState(updateState);
|
|
317
|
-
} else {
|
|
318
|
-
_this.safeSetState({
|
|
319
|
-
status: 'error',
|
|
320
|
-
error: error
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function (cardPreview) {
|
|
325
|
-
if (cardPreview) {
|
|
326
|
-
if (isSSRClientPreview(cardPreview) && _this.ssrReliability.client.status === 'unknown') {
|
|
327
|
-
_this.ssrReliability.client = {
|
|
328
|
-
status: 'success'
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/*
|
|
333
|
-
If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
if (isSSRDataPreview(cardPreview) && _this.ssrReliability.server.status === 'unknown') {
|
|
337
|
-
_this.ssrReliability.server = {
|
|
338
|
-
status: 'success'
|
|
339
|
-
};
|
|
340
|
-
_this.ssrReliability.client = {
|
|
341
|
-
status: 'success'
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
var currentPreview = _this.state.cardPreview;
|
|
346
|
-
// If the dataURI has been replaced, we can dismiss this callback
|
|
347
|
-
if ((cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI) !== (currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.dataURI)) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
_this.safeSetState({
|
|
351
|
-
previewDidRender: true
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
_defineProperty(_assertThisInitialized(_this), "fireCopiedEvent", function () {
|
|
355
|
-
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
356
|
-
var cardRef = _this.state.cardRef;
|
|
357
|
-
cardRef && createAnalyticsEvent && fireCopiedEvent(createAnalyticsEvent, _this.metadata.id, cardRef);
|
|
358
|
-
});
|
|
359
|
-
_defineProperty(_assertThisInitialized(_this), "fireScreenEvent", function () {
|
|
360
|
-
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
361
|
-
createAnalyticsEvent && fireScreenEvent(createAnalyticsEvent, _this.fileAttributes);
|
|
362
|
-
});
|
|
363
|
-
_defineProperty(_assertThisInitialized(_this), "fireNonCriticalErrorEvent", function (error) {
|
|
364
|
-
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
365
|
-
var fileState = _this.state.fileState;
|
|
366
|
-
createAnalyticsEvent && fireNonCriticalErrorEvent(createAnalyticsEvent, _this.state.status, _this.fileAttributes, _this.ssrReliability, error, _this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
|
|
367
|
-
});
|
|
368
|
-
_defineProperty(_assertThisInitialized(_this), "safeSetState", function (newState) {
|
|
369
|
-
if (_this.hasBeenMounted) {
|
|
370
|
-
/**
|
|
371
|
-
* createStateUpdater helper returns a callback to be passed to setState.
|
|
372
|
-
* It decides wether to update the 'status' depending on the current state vs the input state.
|
|
373
|
-
* From docs: "Both state and props received by the updater function are guaranteed to be up-to-date."
|
|
374
|
-
* If the input state brings an error and it won't be updating the state, the error will be logged as non-critical inside the helper.
|
|
375
|
-
* If the error persists int the state, it means it is a critical error and should be logged as a failed event for Card
|
|
376
|
-
*/
|
|
377
|
-
_this.setState(createStateUpdater(newState, _this.fireNonCriticalErrorEvent));
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
_defineProperty(_assertThisInitialized(_this), "unsubscribe", function () {
|
|
381
|
-
if (_this.subscription) {
|
|
382
|
-
_this.subscription.unsubscribe();
|
|
383
|
-
}
|
|
384
|
-
if (_this.hasBeenMounted) {
|
|
385
|
-
// TODO MEX-788: add test for "do not remove the card preview when unsubscribing".
|
|
386
|
-
_this.setState({
|
|
387
|
-
isBannedLocalPreview: false
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
_defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
392
|
-
var _this$props5 = _this.props,
|
|
393
|
-
identifier = _this$props5.identifier,
|
|
394
|
-
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
395
|
-
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
396
|
-
var _this$state = _this.state,
|
|
397
|
-
status = _this$state.status,
|
|
398
|
-
cardPreview = _this$state.cardPreview;
|
|
399
|
-
var _assertThisInitialize2 = _assertThisInitialized(_this),
|
|
400
|
-
metadata = _assertThisInitialize2.metadata;
|
|
401
|
-
_this.onClick(event, analyticsEvent);
|
|
402
|
-
if (!metadata) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
var isVideo = metadata && metadata.mediaType === 'video';
|
|
406
|
-
if (useInlinePlayer && isVideo && !!cardPreview && status !== 'error') {
|
|
407
|
-
_this.setState({
|
|
408
|
-
isPlayingFile: true,
|
|
409
|
-
shouldAutoplay: true
|
|
410
|
-
});
|
|
411
|
-
} else if (shouldOpenMediaViewer) {
|
|
412
|
-
var mediaViewerSelectedItem;
|
|
413
|
-
if (isFileIdentifier(identifier)) {
|
|
414
|
-
mediaViewerSelectedItem = {
|
|
415
|
-
id: identifier.id,
|
|
416
|
-
mediaItemType: 'file',
|
|
417
|
-
collectionName: identifier.collectionName,
|
|
418
|
-
occurrenceKey: identifier.occurrenceKey
|
|
419
|
-
};
|
|
420
|
-
} else {
|
|
421
|
-
mediaViewerSelectedItem = {
|
|
422
|
-
mediaItemType: 'external-image',
|
|
423
|
-
dataURI: identifier.dataURI,
|
|
424
|
-
name: identifier.name
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
_this.setState({
|
|
428
|
-
mediaViewerSelectedItem: mediaViewerSelectedItem
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
_defineProperty(_assertThisInitialized(_this), "onInlinePlayerError", function (e) {
|
|
433
|
-
_this.setState({
|
|
434
|
-
error: new MediaCardError('error-file-state', e),
|
|
435
|
-
status: 'error',
|
|
436
|
-
isPlayingFile: false
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
_defineProperty(_assertThisInitialized(_this), "setRef", function (cardRef) {
|
|
440
|
-
!!cardRef && _this.setState({
|
|
441
|
-
cardRef: cardRef
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
_defineProperty(_assertThisInitialized(_this), "setMediaViewerButtonRef", function (buttonRef) {
|
|
445
|
-
_this.mediaViewerButtonRef = buttonRef;
|
|
446
|
-
});
|
|
447
|
-
_defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
|
|
448
|
-
var _this$props6 = _this.props,
|
|
449
|
-
identifier = _this$props6.identifier,
|
|
450
|
-
mediaClient = _this$props6.mediaClient,
|
|
451
|
-
dimensions = _this$props6.dimensions,
|
|
452
|
-
selected = _this$props6.selected,
|
|
453
|
-
testId = _this$props6.testId,
|
|
454
|
-
originalDimensions = _this$props6.originalDimensions,
|
|
455
|
-
onFullscreenChange = _this$props6.onFullscreenChange,
|
|
456
|
-
videoControlsWrapperRef = _this$props6.videoControlsWrapperRef;
|
|
457
|
-
var _this$state2 = _this.state,
|
|
458
|
-
shouldAutoplay = _this$state2.shouldAutoplay,
|
|
459
|
-
cardPreview = _this$state2.cardPreview;
|
|
460
|
-
var card = _this.renderCard(false, 'loading', false);
|
|
461
|
-
return /*#__PURE__*/React.createElement(Suspense, {
|
|
462
|
-
fallback: card
|
|
463
|
-
}, /*#__PURE__*/React.createElement(InlinePlayerLazy, {
|
|
464
|
-
mediaClient: mediaClient,
|
|
465
|
-
dimensions: dimensions,
|
|
466
|
-
originalDimensions: originalDimensions,
|
|
467
|
-
identifier: identifier,
|
|
468
|
-
autoplay: !!shouldAutoplay,
|
|
469
|
-
onFullscreenChange: onFullscreenChange,
|
|
470
|
-
onError: _this.onInlinePlayerError,
|
|
471
|
-
onClick: _this.onClick,
|
|
472
|
-
selected: selected,
|
|
473
|
-
ref: _this.setRef,
|
|
474
|
-
testId: testId,
|
|
475
|
-
cardPreview: cardPreview,
|
|
476
|
-
videoControlsWrapperRef: videoControlsWrapperRef
|
|
477
|
-
}));
|
|
478
|
-
});
|
|
479
|
-
_defineProperty(_assertThisInitialized(_this), "onMediaViewerClose", function () {
|
|
480
|
-
_this.setState({
|
|
481
|
-
mediaViewerSelectedItem: undefined
|
|
482
|
-
}, function () {
|
|
483
|
-
var _this$mediaViewerButt;
|
|
484
|
-
(_this$mediaViewerButt = _this.mediaViewerButtonRef) === null || _this$mediaViewerButt === void 0 || _this$mediaViewerButt.focus();
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
_defineProperty(_assertThisInitialized(_this), "onDisplayImage", function () {
|
|
488
|
-
var identifier = _this.props.identifier;
|
|
489
|
-
var payloadPart;
|
|
490
|
-
if (isFileIdentifier(identifier)) {
|
|
491
|
-
payloadPart = {
|
|
492
|
-
fileId: identifier.id,
|
|
493
|
-
isUserCollection: identifier.collectionName === RECENTS_COLLECTION
|
|
494
|
-
};
|
|
495
|
-
} else {
|
|
496
|
-
payloadPart = {
|
|
497
|
-
fileId: identifier.dataURI,
|
|
498
|
-
isUserCollection: false
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
globalMediaEventEmitter.emit('media-viewed', _objectSpread({
|
|
502
|
-
viewingLevel: 'minimal'
|
|
503
|
-
}, payloadPart));
|
|
504
|
-
});
|
|
505
|
-
_defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
|
|
506
|
-
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
507
|
-
var _this$props7 = _this.props,
|
|
508
|
-
mediaClient = _this$props7.mediaClient,
|
|
509
|
-
identifier = _this$props7.identifier,
|
|
510
|
-
mediaViewerItems = _this$props7.mediaViewerItems,
|
|
511
|
-
contextId = _this$props7.contextId,
|
|
512
|
-
featureFlags = _this$props7.featureFlags;
|
|
513
|
-
if (!mediaViewerSelectedItem) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
var collectionName = isFileIdentifier(identifier) ? identifier.collectionName || '' : '';
|
|
517
|
-
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
518
|
-
collectionName: collectionName,
|
|
519
|
-
items: mediaViewerItems || [],
|
|
520
|
-
mediaClientConfig: mediaClient.config,
|
|
521
|
-
selectedItem: mediaViewerSelectedItem,
|
|
522
|
-
onClose: _this.onMediaViewerClose,
|
|
523
|
-
contextId: contextId,
|
|
524
|
-
featureFlags: featureFlags
|
|
525
|
-
}), document.body);
|
|
526
|
-
});
|
|
527
|
-
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
528
|
-
var withCallbacks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
529
|
-
var cardStatusOverride = arguments.length > 1 ? arguments[1] : undefined;
|
|
530
|
-
var izLazyOverride = arguments.length > 2 ? arguments[2] : undefined;
|
|
531
|
-
var _this$props8 = _this.props,
|
|
532
|
-
identifier = _this$props8.identifier,
|
|
533
|
-
isLazy = _this$props8.isLazy,
|
|
534
|
-
appearance = _this$props8.appearance,
|
|
535
|
-
resizeMode = _this$props8.resizeMode,
|
|
536
|
-
dimensions = _this$props8.dimensions,
|
|
537
|
-
selectable = _this$props8.selectable,
|
|
538
|
-
selected = _this$props8.selected,
|
|
539
|
-
disableOverlay = _this$props8.disableOverlay,
|
|
540
|
-
alt = _this$props8.alt,
|
|
541
|
-
testId = _this$props8.testId,
|
|
542
|
-
featureFlags = _this$props8.featureFlags,
|
|
543
|
-
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
544
|
-
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
545
|
-
ssr = _this$props8.ssr,
|
|
546
|
-
useInlinePlayer = _this$props8.useInlinePlayer,
|
|
547
|
-
shouldOpenMediaViewer = _this$props8.shouldOpenMediaViewer,
|
|
548
|
-
shouldHideTooltip = _this$props8.shouldHideTooltip,
|
|
549
|
-
dateOverride = _this$props8.dateOverride;
|
|
550
|
-
var mediaItemType = identifier.mediaItemType;
|
|
551
|
-
var _this$state3 = _this.state,
|
|
552
|
-
status = _this$state3.status,
|
|
553
|
-
progress = _this$state3.progress,
|
|
554
|
-
cardPreview = _this$state3.cardPreview,
|
|
555
|
-
error = _this$state3.error,
|
|
556
|
-
cardRef = _this$state3.cardRef,
|
|
557
|
-
isCardVisible = _this$state3.isCardVisible;
|
|
558
|
-
var _assertThisInitialize3 = _assertThisInitialized(_this),
|
|
559
|
-
metadata = _assertThisInitialize3.metadata;
|
|
560
|
-
var _assertThisInitialize4 = _assertThisInitialized(_this),
|
|
561
|
-
onCardViewClick = _assertThisInitialize4.onCardViewClick,
|
|
562
|
-
onDisplayImage = _assertThisInitialize4.onDisplayImage,
|
|
563
|
-
actions = _assertThisInitialize4.actions,
|
|
564
|
-
onMouseEnter = _assertThisInitialize4.onMouseEnter;
|
|
565
|
-
var isLazyWithOverride = izLazyOverride === undefined ? isLazy : izLazyOverride;
|
|
566
|
-
|
|
567
|
-
// Card can be artificially turned visible before entering the viewport
|
|
568
|
-
// For example, when we have the image in cache
|
|
569
|
-
var nativeLazyLoad = isLazyWithOverride && !isCardVisible;
|
|
570
|
-
// Force Media Image to always display img for SSR
|
|
571
|
-
var forceSyncDisplay = !!ssr;
|
|
572
|
-
var mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, status === 'error' || status === 'failed-processing', !!_this.state.cardPreview, metadata.mediaType);
|
|
573
|
-
var card = /*#__PURE__*/React.createElement(CardView, {
|
|
574
|
-
status: cardStatusOverride || status,
|
|
575
|
-
error: error,
|
|
576
|
-
mediaItemType: mediaItemType,
|
|
577
|
-
metadata: metadata,
|
|
578
|
-
cardPreview: cardPreview,
|
|
579
|
-
alt: alt,
|
|
580
|
-
appearance: appearance,
|
|
581
|
-
resizeMode: resizeMode,
|
|
582
|
-
dimensions: dimensions,
|
|
583
|
-
actions: actions,
|
|
584
|
-
selectable: selectable,
|
|
585
|
-
selected: selected,
|
|
586
|
-
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
587
|
-
onClick: withCallbacks ? onCardViewClick : undefined,
|
|
588
|
-
onMouseEnter: withCallbacks ? onMouseEnter : undefined,
|
|
589
|
-
disableOverlay: disableOverlay,
|
|
590
|
-
progress: progress,
|
|
591
|
-
onDisplayImage: withCallbacks ? onDisplayImage : undefined,
|
|
592
|
-
innerRef: _this.setRef,
|
|
593
|
-
openMediaViewerButtonRef: _this.setMediaViewerButtonRef,
|
|
594
|
-
testId: testId,
|
|
595
|
-
featureFlags: featureFlags,
|
|
596
|
-
titleBoxBgColor: titleBoxBgColor,
|
|
597
|
-
titleBoxIcon: titleBoxIcon,
|
|
598
|
-
onImageError: withCallbacks ? _this.onImageError : undefined,
|
|
599
|
-
onImageLoad: withCallbacks ? _this.onImageLoad : undefined,
|
|
600
|
-
nativeLazyLoad: nativeLazyLoad,
|
|
601
|
-
forceSyncDisplay: forceSyncDisplay,
|
|
602
|
-
mediaCardCursor: mediaCardCursor,
|
|
603
|
-
shouldHideTooltip: shouldHideTooltip,
|
|
604
|
-
overriddenCreationDate: dateOverride
|
|
605
|
-
});
|
|
606
|
-
return isLazyWithOverride ? /*#__PURE__*/React.createElement(ViewportDetector, {
|
|
607
|
-
cardEl: cardRef,
|
|
608
|
-
onVisible: _this.onCardInViewport
|
|
609
|
-
}, card) : card;
|
|
610
|
-
});
|
|
611
|
-
_defineProperty(_assertThisInitialized(_this), "storeSSRData", function () {
|
|
612
|
-
var _this$ssrReliability$;
|
|
613
|
-
var _this$props9 = _this.props,
|
|
614
|
-
ssr = _this$props9.ssr,
|
|
615
|
-
identifier = _this$props9.identifier;
|
|
616
|
-
var _this$state$cardPrevi = _this.state.cardPreview,
|
|
617
|
-
_this$state$cardPrevi2 = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi,
|
|
618
|
-
dataURI = _this$state$cardPrevi2.dataURI;
|
|
619
|
-
return isFileIdentifier(identifier) &&
|
|
620
|
-
// Print the SSR result to be used during hydration
|
|
621
|
-
ssr === 'server' && /*#__PURE__*/React.createElement("script", generateScriptProps(identifier, dataURI, _this.requestedDimensions, ((_this$ssrReliability$ = _this.ssrReliability.server) === null || _this$ssrReliability$ === void 0 ? void 0 : _this$ssrReliability$.status) === 'fail' ? _this.ssrReliability.server : undefined));
|
|
622
|
-
});
|
|
623
|
-
_defineProperty(_assertThisInitialized(_this), "onCardInViewport", function () {
|
|
624
|
-
_this.setState({
|
|
625
|
-
isCardVisible: true
|
|
626
|
-
});
|
|
627
|
-
});
|
|
628
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function (event, analyticsEvent) {
|
|
629
|
-
var onClick = _this.props.onClick;
|
|
630
|
-
var _assertThisInitialize5 = _assertThisInitialized(_this),
|
|
631
|
-
metadata = _assertThisInitialize5.metadata;
|
|
632
|
-
if (onClick) {
|
|
633
|
-
var cardEvent = {
|
|
634
|
-
event: event,
|
|
635
|
-
mediaItemDetails: metadata
|
|
636
|
-
};
|
|
637
|
-
onClick(cardEvent, analyticsEvent);
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
_defineProperty(_assertThisInitialized(_this), "onMouseEnter", function (event) {
|
|
641
|
-
var onMouseEnter = _this.props.onMouseEnter;
|
|
642
|
-
var _assertThisInitialize6 = _assertThisInitialized(_this),
|
|
643
|
-
metadata = _assertThisInitialize6.metadata;
|
|
644
|
-
if (onMouseEnter) {
|
|
645
|
-
var cardEvent = {
|
|
646
|
-
event: event,
|
|
647
|
-
mediaItemDetails: metadata
|
|
648
|
-
};
|
|
649
|
-
onMouseEnter(cardEvent);
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
var _status = 'loading';
|
|
653
|
-
var _cardPreview;
|
|
654
|
-
var _error;
|
|
655
|
-
var _this$props10 = _this.props,
|
|
656
|
-
_identifier = _this$props10.identifier,
|
|
657
|
-
_resizeMode = _this$props10.resizeMode,
|
|
658
|
-
_ssr = _this$props10.ssr,
|
|
659
|
-
_mediaClient = _this$props10.mediaClient;
|
|
660
|
-
if (isFileIdentifier(_identifier)) {
|
|
661
|
-
var id = _identifier.id;
|
|
662
|
-
var fileImageMode = imageResizeModeToFileImageMode(_resizeMode);
|
|
663
|
-
_cardPreview = getCardPreviewFromCache(id, fileImageMode);
|
|
664
|
-
if (!_cardPreview && _ssr) {
|
|
665
|
-
_cardPreview = _this.getSSRPreview(_ssr, _identifier, _mediaClient);
|
|
666
|
-
}
|
|
667
|
-
} else if (isExternalImageIdentifier(_identifier)) {
|
|
668
|
-
_this.fireCommencedEvent();
|
|
669
|
-
_status = 'loading-preview';
|
|
670
|
-
var dataURI = _identifier.dataURI;
|
|
671
|
-
_cardPreview = {
|
|
672
|
-
dataURI: dataURI,
|
|
673
|
-
orientation: 1,
|
|
674
|
-
source: 'external'
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// If cardPreview is available from local cache or external, `isCardVisible`
|
|
679
|
-
// should be true to avoid flickers during re-mount of the component
|
|
680
|
-
// should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
|
|
681
|
-
// outside the viewport
|
|
682
|
-
var _isCardVisible = !_this.props.isLazy || !!_cardPreview && !isSSRPreview(_cardPreview);
|
|
683
|
-
_this.state = {
|
|
684
|
-
status: _status,
|
|
685
|
-
isCardVisible: _isCardVisible,
|
|
686
|
-
isPlayingFile: false,
|
|
687
|
-
shouldAutoplay: false,
|
|
688
|
-
cardPreview: _cardPreview,
|
|
689
|
-
cardRef: null,
|
|
690
|
-
isBannedLocalPreview: false,
|
|
691
|
-
previewDidRender: false,
|
|
692
|
-
error: _error,
|
|
693
|
-
wasResolvedUpfrontPreview: false
|
|
694
|
-
};
|
|
695
|
-
return _this;
|
|
696
|
-
}
|
|
697
|
-
_createClass(CardBase, [{
|
|
698
|
-
key: "getSSRPreview",
|
|
699
|
-
value: function getSSRPreview(ssr, identifier, mediaClient) {
|
|
700
|
-
var _this$ssrData, _this$ssrData2;
|
|
701
|
-
this.ssrData = getSSRData(identifier);
|
|
702
|
-
if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
703
|
-
this.ssrReliability.server = _objectSpread({
|
|
704
|
-
status: 'fail'
|
|
705
|
-
}, this.ssrData.error);
|
|
706
|
-
}
|
|
707
|
-
if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
708
|
-
try {
|
|
709
|
-
return getSSRCardPreview(ssr, mediaClient, identifier.id, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
|
|
710
|
-
} catch (e) {
|
|
711
|
-
this.ssrReliability[ssr] = _objectSpread({
|
|
712
|
-
status: 'fail'
|
|
713
|
-
}, extractErrorInfo(e));
|
|
714
|
-
}
|
|
715
|
-
} else {
|
|
716
|
-
return {
|
|
717
|
-
dataURI: this.ssrData.dataURI,
|
|
718
|
-
source: 'ssr-data'
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}, {
|
|
723
|
-
key: "componentDidMount",
|
|
724
|
-
value: function componentDidMount() {
|
|
725
|
-
var _getDocument;
|
|
726
|
-
this.hasBeenMounted = true;
|
|
727
|
-
var _this$state4 = this.state,
|
|
728
|
-
isCardVisible = _this$state4.isCardVisible,
|
|
729
|
-
cardPreview = _this$state4.cardPreview;
|
|
730
|
-
var _this$props11 = this.props,
|
|
731
|
-
identifier = _this$props11.identifier,
|
|
732
|
-
ssr = _this$props11.ssr,
|
|
733
|
-
dimensions = _this$props11.dimensions;
|
|
734
|
-
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
735
|
-
this.updateStateForIdentifier(identifier);
|
|
736
|
-
if (!cardPreview) {
|
|
737
|
-
this.resolveUpfrontPreview(identifier);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
|
|
741
|
-
var _this$ssrData3;
|
|
742
|
-
if (isSSRClientPreview(cardPreview)) {
|
|
743
|
-
// Since the SSR preview brings the token in the query params,
|
|
744
|
-
// We need to fetch the remote preview to be able to cache it,
|
|
745
|
-
this.setCacheSSRPreview(identifier);
|
|
746
|
-
}
|
|
747
|
-
if (isSSRDataPreview(cardPreview) && isBigger((_this$ssrData3 = this.ssrData) === null || _this$ssrData3 === void 0 ? void 0 : _this$ssrData3.dimensions, dimensions)) {
|
|
748
|
-
// If dimensions from Server have changed and are bigger,
|
|
749
|
-
// we need to refetch
|
|
750
|
-
// This is repeated in componentDidUpdate because in the case of lazy loading true
|
|
751
|
-
// the card will be invisible by default.
|
|
752
|
-
this.refetchSSRPreview(identifier);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
// we add a listener for each of the cards on the page
|
|
756
|
-
// and then check if the triggered listener is from the card
|
|
757
|
-
// that contains a div in current window.getSelection()
|
|
758
|
-
// won't work in IE11
|
|
759
|
-
(_getDocument = getDocument()) === null || _getDocument === void 0 || _getDocument.addEventListener('copy', this.fireCopiedEvent);
|
|
760
|
-
}
|
|
761
|
-
}, {
|
|
762
|
-
key: "componentDidUpdate",
|
|
763
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
764
|
-
var _this$ssrData4;
|
|
765
|
-
var prevMediaClient = prevProps.mediaClient,
|
|
766
|
-
prevIdentifier = prevProps.identifier,
|
|
767
|
-
prevDimensions = prevProps.dimensions;
|
|
768
|
-
var prevIsCardVisible = prevState.isCardVisible,
|
|
769
|
-
prevCardPreview = prevState.cardPreview;
|
|
770
|
-
var _this$props12 = this.props,
|
|
771
|
-
mediaClient = _this$props12.mediaClient,
|
|
772
|
-
identifier = _this$props12.identifier,
|
|
773
|
-
dimensions = _this$props12.dimensions,
|
|
774
|
-
useInlinePlayer = _this$props12.useInlinePlayer,
|
|
775
|
-
disableOverlay = _this$props12.disableOverlay,
|
|
776
|
-
ssr = _this$props12.ssr;
|
|
777
|
-
var _this$state5 = this.state,
|
|
778
|
-
isCardVisible = _this$state5.isCardVisible,
|
|
779
|
-
cardPreview = _this$state5.cardPreview,
|
|
780
|
-
status = _this$state5.status,
|
|
781
|
-
fileState = _this$state5.fileState,
|
|
782
|
-
isBannedLocalPreview = _this$state5.isBannedLocalPreview,
|
|
783
|
-
previewDidRender = _this$state5.previewDidRender,
|
|
784
|
-
isPlayingFile = _this$state5.isPlayingFile,
|
|
785
|
-
wasResolvedUpfrontPreview = _this$state5.wasResolvedUpfrontPreview;
|
|
786
|
-
var isDiffIdentifier = isDifferentIdentifier(prevIdentifier, identifier);
|
|
787
|
-
/**
|
|
788
|
-
* Variable turnedVisible should only be true when media card
|
|
789
|
-
* was invisible in the previous state and is visible in the current one
|
|
790
|
-
*
|
|
791
|
-
* prevIsCardVisible | isCardVisible | turnedVisible
|
|
792
|
-
* ----------------------------------------------------
|
|
793
|
-
* false | false | false
|
|
794
|
-
* false | true | true
|
|
795
|
-
* true | true | false
|
|
796
|
-
* true | false | false (unreachable case)
|
|
797
|
-
* ----------------------------------------------------
|
|
798
|
-
*/
|
|
799
|
-
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
800
|
-
var hadSSRCardPreview = !!prevCardPreview && isSSRClientPreview(prevCardPreview) && !cardPreview;
|
|
801
|
-
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
802
|
-
this.updateFileStateFlag(fileState);
|
|
803
|
-
if (isExternalImageIdentifier(identifier) && isDiffIdentifier) {
|
|
804
|
-
this.fireCommencedEvent();
|
|
805
|
-
var dataURI = identifier.dataURI;
|
|
806
|
-
this.setState({
|
|
807
|
-
status: 'loading-preview',
|
|
808
|
-
cardPreview: {
|
|
809
|
-
dataURI: dataURI,
|
|
810
|
-
orientation: 1,
|
|
811
|
-
source: 'external'
|
|
812
|
-
},
|
|
813
|
-
isCardVisible: true
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
if (cardPreview && turnedVisible && isFileIdentifier(identifier) && isSSRDataPreview(cardPreview) && isBigger((_this$ssrData4 = this.ssrData) === null || _this$ssrData4 === void 0 ? void 0 : _this$ssrData4.dimensions, dimensions)) {
|
|
817
|
-
// If dimensions from Server have changed and are bigger,
|
|
818
|
-
// we need to refetch
|
|
819
|
-
this.refetchSSRPreview(identifier);
|
|
820
|
-
}
|
|
821
|
-
if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDiffIdentifier))) {
|
|
822
|
-
this.updateStateForIdentifier(identifier);
|
|
823
|
-
}
|
|
824
|
-
if (this.state.status !== prevState.status) {
|
|
825
|
-
this.fireOperationalEvent();
|
|
826
|
-
if (this.state.status === 'complete' || this.fileAttributes.fileMediatype === 'video' && !!cardPreview && this.state.status === 'processing') {
|
|
827
|
-
this.fireScreenEvent();
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
if (isFileIdentifier(identifier) && (turnedVisible || ssr === 'client' && hadSSRCardPreview) && !cardPreview && !wasResolvedUpfrontPreview) {
|
|
831
|
-
// This is a one-off call, only meant to happen once in the component's lifecycle. Mainly when either:
|
|
832
|
-
// - turnedVisible = true
|
|
833
|
-
// - ssr = client and has no preview (the dataURI failed to load in the previous state, most likely because of an initial auth issue)
|
|
834
|
-
this.resolveUpfrontPreview(identifier);
|
|
835
|
-
} else if (isFileIdentifier(identifier) && fileState && shouldResolvePreview({
|
|
836
|
-
status: status,
|
|
837
|
-
fileState: fileState,
|
|
838
|
-
prevDimensions: prevDimensions,
|
|
839
|
-
dimensions: dimensions,
|
|
840
|
-
hasCardPreview: !!cardPreview,
|
|
841
|
-
isBannedLocalPreview: isBannedLocalPreview,
|
|
842
|
-
wasResolvedUpfrontPreview: wasResolvedUpfrontPreview
|
|
843
|
-
})) {
|
|
844
|
-
this.resolvePreview(identifier, fileState);
|
|
845
|
-
}
|
|
846
|
-
if (turnedVisible && this.props.ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
|
|
847
|
-
// Since the SSR preview brings the token in the query params,
|
|
848
|
-
// We need to fetch the remote preview to be able to cache it,
|
|
849
|
-
this.setCacheSSRPreview(identifier);
|
|
850
|
-
}
|
|
851
|
-
if (previewDidRender &&
|
|
852
|
-
// We should't complete if status is uploading
|
|
853
|
-
['loading-preview', 'processing'].includes(status)) {
|
|
854
|
-
this.safeSetState({
|
|
855
|
-
status: 'complete'
|
|
856
|
-
});
|
|
857
|
-
this.unsubscribe();
|
|
858
|
-
}
|
|
859
|
-
var isVideo = this.fileAttributes.fileMediatype === 'video';
|
|
860
|
-
var _getFileDetails2 = getFileDetails(identifier, fileState),
|
|
861
|
-
mimeType = _getFileDetails2.mimeType;
|
|
862
|
-
var isVideoPlayable = videoIsPlayable(isBannedLocalPreview, fileState, mimeType);
|
|
863
|
-
if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable && status !== 'error') {
|
|
864
|
-
this.setState({
|
|
865
|
-
isPlayingFile: true
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}, {
|
|
870
|
-
key: "componentWillUnmount",
|
|
871
|
-
value: function componentWillUnmount() {
|
|
872
|
-
var _getDocument2;
|
|
873
|
-
this.fireAbortedEvent();
|
|
874
|
-
this.hasBeenMounted = false;
|
|
875
|
-
this.unsubscribe();
|
|
876
|
-
(_getDocument2 = getDocument()) === null || _getDocument2 === void 0 || _getDocument2.removeEventListener('copy', this.fireCopiedEvent);
|
|
877
|
-
}
|
|
878
|
-
}, {
|
|
879
|
-
key: "updateStateForIdentifier",
|
|
880
|
-
value: function updateStateForIdentifier(identifier) {
|
|
881
|
-
this.fireCommencedEvent();
|
|
882
|
-
this.subscribeInternalFile(identifier);
|
|
883
|
-
}
|
|
884
|
-
}, {
|
|
885
|
-
key: "updateFileStateFlag",
|
|
886
|
-
value: function updateFileStateFlag(fileState) {
|
|
887
|
-
if (!fileState) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
var status = fileState.status;
|
|
891
|
-
if (status === 'processing') {
|
|
892
|
-
this.fileStateFlags.wasStatusProcessing = true;
|
|
893
|
-
} else if (status === 'uploading') {
|
|
894
|
-
this.fileStateFlags.wasStatusUploading = true;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}, {
|
|
898
|
-
key: "subscribeInternalFile",
|
|
899
|
-
value: function subscribeInternalFile(identifier) {
|
|
900
|
-
var _this2 = this;
|
|
901
|
-
var mediaClient = this.props.mediaClient;
|
|
902
|
-
var isBannedLocalPreview = this.state.isBannedLocalPreview;
|
|
903
|
-
var id = identifier.id,
|
|
904
|
-
collectionName = identifier.collectionName,
|
|
905
|
-
occurrenceKey = identifier.occurrenceKey;
|
|
906
|
-
this.unsubscribe();
|
|
907
|
-
this.subscription = mediaClient.file.getFileState(id, {
|
|
908
|
-
collectionName: collectionName,
|
|
909
|
-
occurrenceKey: occurrenceKey
|
|
910
|
-
}).subscribe({
|
|
911
|
-
next: function next(fileState) {
|
|
912
|
-
var newState = getCardStateFromFileState(fileState, isBannedLocalPreview);
|
|
913
|
-
_this2.safeSetState(newState);
|
|
914
|
-
},
|
|
915
|
-
error: function error(e) {
|
|
916
|
-
var errorReason = _this2.state.status === 'uploading' ? 'upload' : 'metadata-fetch';
|
|
917
|
-
var error = new MediaCardError(errorReason, e);
|
|
918
|
-
_this2.safeSetState({
|
|
919
|
-
error: error,
|
|
920
|
-
status: 'error'
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
}, {
|
|
926
|
-
key: "requestedDimensions",
|
|
927
|
-
get: function get() {
|
|
928
|
-
var dimensions = this.props.dimensions;
|
|
929
|
-
var _ref5 = this.state || {},
|
|
930
|
-
element = _ref5.cardRef;
|
|
931
|
-
return getRequestedDimensions({
|
|
932
|
-
dimensions: dimensions,
|
|
933
|
-
element: element
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
}, {
|
|
937
|
-
key: "metadata",
|
|
938
|
-
get: function get() {
|
|
939
|
-
var _this$state6;
|
|
940
|
-
return getFileDetails(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
|
|
941
|
-
}
|
|
942
|
-
}, {
|
|
943
|
-
key: "fileAttributes",
|
|
944
|
-
get: function get() {
|
|
945
|
-
var _this$state7;
|
|
946
|
-
return getFileAttributes(this.metadata, (_this$state7 = this.state) === null || _this$state7 === void 0 || (_this$state7 = _this$state7.fileState) === null || _this$state7 === void 0 ? void 0 : _this$state7.status);
|
|
947
|
-
}
|
|
948
|
-
}, {
|
|
949
|
-
key: "fireOperationalEvent",
|
|
950
|
-
value: function fireOperationalEvent() {
|
|
951
|
-
var _this$state8 = this.state,
|
|
952
|
-
status = _this$state8.status,
|
|
953
|
-
error = _this$state8.error,
|
|
954
|
-
fileState = _this$state8.fileState;
|
|
955
|
-
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
956
|
-
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error, this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
|
|
957
|
-
completeUfoExperience(this.internalOccurrenceKey, status, this.fileAttributes, this.fileStateFlags, this.ssrReliability, error);
|
|
958
|
-
}
|
|
959
|
-
}, {
|
|
960
|
-
key: "fireAbortedEvent",
|
|
961
|
-
value: function fireAbortedEvent() {
|
|
962
|
-
var fileAttributes = this.fileAttributes,
|
|
963
|
-
fileStateFlags = this.fileStateFlags,
|
|
964
|
-
ssrReliability = this.ssrReliability;
|
|
965
|
-
// UFO won't abort if it's already in a final state (succeeded, failed, aborted, etc)
|
|
966
|
-
abortUfoExperience(this.internalOccurrenceKey, {
|
|
967
|
-
fileAttributes: fileAttributes,
|
|
968
|
-
fileStateFlags: fileStateFlags,
|
|
969
|
-
ssrReliability: ssrReliability
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
}, {
|
|
973
|
-
key: "fireCommencedEvent",
|
|
974
|
-
value: function fireCommencedEvent() {
|
|
975
|
-
this.timeElapsedTillCommenced = performance.now();
|
|
976
|
-
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
977
|
-
createAnalyticsEvent && _fireCommencedEvent(createAnalyticsEvent, this.fileAttributes, {
|
|
978
|
-
overall: {
|
|
979
|
-
durationSincePageStart: this.timeElapsedTillCommenced
|
|
980
|
-
}
|
|
981
|
-
}, this.traceContext);
|
|
982
|
-
startUfoExperience(this.internalOccurrenceKey);
|
|
983
|
-
}
|
|
984
|
-
}, {
|
|
985
|
-
key: "actions",
|
|
986
|
-
get: function get() {
|
|
987
|
-
var _this3 = this;
|
|
988
|
-
var _this$props13 = this.props,
|
|
989
|
-
_this$props13$actions = _this$props13.actions,
|
|
990
|
-
actions = _this$props13$actions === void 0 ? [] : _this$props13$actions,
|
|
991
|
-
identifier = _this$props13.identifier,
|
|
992
|
-
shouldEnableDownloadButton = _this$props13.shouldEnableDownloadButton;
|
|
993
|
-
var status = this.state.status;
|
|
994
|
-
var metadata = this.metadata;
|
|
995
|
-
if (isFileIdentifier(identifier) && (status === 'failed-processing' || shouldEnableDownloadButton)) {
|
|
996
|
-
var downloadAction = {
|
|
997
|
-
label: 'Download',
|
|
998
|
-
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
999
|
-
label: "Download"
|
|
1000
|
-
}),
|
|
1001
|
-
handler: function handler() {
|
|
1002
|
-
return _this3.props.mediaClient.file.downloadBinary(identifier.id, metadata.name, identifier.collectionName);
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
return [downloadAction].concat(_toConsumableArray(actions));
|
|
1006
|
-
} else {
|
|
1007
|
-
return actions;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}, {
|
|
1011
|
-
key: "render",
|
|
1012
|
-
value: function render() {
|
|
1013
|
-
var _this$state9 = this.state,
|
|
1014
|
-
isPlayingFile = _this$state9.isPlayingFile,
|
|
1015
|
-
mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
|
|
1016
|
-
var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
|
|
1017
|
-
return this.props.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
1018
|
-
locale: "en"
|
|
1019
|
-
}, innerContent);
|
|
1020
|
-
}
|
|
1021
|
-
}]);
|
|
1022
|
-
return CardBase;
|
|
1023
|
-
}(Component);
|
|
1024
|
-
|
|
1025
|
-
// We require this wrapper in order
|
|
1026
|
-
// 1. To refresh media card state when the identifier is updated
|
|
1027
|
-
// 2. To allow for overriding creation date (https://product-fabric.atlassian.net/browse/CXP-2840)
|
|
1028
|
-
_defineProperty(CardBase, "defaultProps", {
|
|
1029
|
-
appearance: 'auto',
|
|
1030
|
-
resizeMode: 'crop',
|
|
1031
|
-
isLazy: true,
|
|
1032
|
-
disableOverlay: false,
|
|
1033
|
-
// Media Feature Flag defaults are defined in @atlaskit/media-common
|
|
1034
|
-
featureFlags: {}
|
|
1035
|
-
});
|
|
1036
|
-
var CardWithKeyAndDateOverrideContext = function CardWithKeyAndDateOverrideContext(props) {
|
|
1037
|
-
var identifier = props.identifier;
|
|
1038
|
-
var dateOverrides = useContext(DateOverrideContext);
|
|
1039
|
-
var key = isFileIdentifier(identifier) ? identifier.id : identifier.dataURI;
|
|
1040
|
-
var dateOverride = isFileIdentifier(identifier) ? dateOverrides === null || dateOverrides === void 0 ? void 0 : dateOverrides[identifier.id] : undefined;
|
|
1041
|
-
return /*#__PURE__*/React.createElement(CardBase, _extends({}, props, {
|
|
1042
|
-
dateOverride: dateOverride,
|
|
1043
|
-
key: key
|
|
12
|
+
var packageVersion = "78.0.1";
|
|
13
|
+
export var CardBase = function CardBase(_ref) {
|
|
14
|
+
var identifier = _ref.identifier,
|
|
15
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
var innerContent = isFileIdentifier(identifier) ? /*#__PURE__*/React.createElement(FileCard, _extends({}, otherProps, {
|
|
17
|
+
identifier: identifier,
|
|
18
|
+
key: identifier.id
|
|
19
|
+
})) : /*#__PURE__*/React.createElement(ExternalImageCard, _extends({}, otherProps, {
|
|
20
|
+
identifier: identifier,
|
|
21
|
+
key: identifier.dataURI
|
|
1044
22
|
}));
|
|
23
|
+
return otherProps.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
24
|
+
locale: "en"
|
|
25
|
+
}, innerContent);
|
|
1045
26
|
};
|
|
1046
27
|
export var Card = withMediaAnalyticsContext({
|
|
1047
28
|
packageVersion: packageVersion,
|
|
1048
29
|
packageName: packageName,
|
|
1049
30
|
componentName: 'mediaCard',
|
|
1050
31
|
component: 'mediaCard'
|
|
1051
|
-
})(withAnalyticsEvents()(injectIntl(
|
|
32
|
+
})(withAnalyticsEvents()(injectIntl(CardBase, {
|
|
1052
33
|
enforceContext: false
|
|
1053
34
|
})));
|