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