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