@atlaskit/media-card 73.0.0 → 73.1.2
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 +24 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +7 -5
- package/dist/cjs/root/card/cardAnalytics.js +1 -1
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +4 -4
- package/dist/cjs/root/card/getCardPreview/index.js +2 -2
- package/dist/cjs/root/card/index.js +33 -7
- package/dist/cjs/root/cardView.js +2 -2
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +5 -1
- package/dist/cjs/root/inlinePlayer.js +76 -23
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
- package/dist/cjs/root/ui/progressBar/styled.js +6 -5
- package/dist/cjs/root/ui/styled.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
- package/dist/cjs/utils/viewportDetector.js +51 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/index.js +39 -7
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +5 -1
- package/dist/es2019/root/inlinePlayer.js +56 -4
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
- package/dist/es2019/root/ui/progressBar/styled.js +6 -4
- package/dist/es2019/root/ui/styled.js +1 -1
- package/dist/es2019/utils/viewportDetector.js +50 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +6 -5
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/index.js +2 -2
- package/dist/esm/root/card/index.js +39 -9
- package/dist/esm/root/cardView.js +2 -2
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +5 -1
- package/dist/esm/root/inlinePlayer.js +74 -23
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
- package/dist/esm/root/ui/progressBar/styled.js +6 -5
- package/dist/esm/root/ui/styled.js +1 -1
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
- package/dist/esm/utils/viewportDetector.js +50 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +2 -0
- package/dist/types/root/cardView.d.ts +1 -1
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inlinePlayer.d.ts +8 -1
- package/dist/types/root/ui/progressBar/progressBar.d.ts +2 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
- package/dist/types/utils/viewportDetector.d.ts +13 -5
- package/package.json +7 -9
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -1,5 +1,27 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
|
|
1
|
+
import React, { useEffect, forwardRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
|
|
4
|
+
* Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
|
|
8
|
+
|
|
9
|
+
export const ViewportAnchor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
10
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
ref: ref,
|
|
16
|
+
className: "media-card-viewport-anchor",
|
|
17
|
+
style: {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
top: `${props.offsetTop}px`,
|
|
20
|
+
maxHeight: 0,
|
|
21
|
+
pointerEvents: 'none'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
3
25
|
|
|
4
26
|
const createIntersectionObserverCallback = onVisible => (entries, observer) => {
|
|
5
27
|
for (let entry of entries) {
|
|
@@ -11,31 +33,41 @@ const createIntersectionObserverCallback = onVisible => (entries, observer) => {
|
|
|
11
33
|
}
|
|
12
34
|
};
|
|
13
35
|
|
|
14
|
-
const
|
|
36
|
+
const ViewportObserver = ({
|
|
15
37
|
onVisible,
|
|
38
|
+
cardEl,
|
|
16
39
|
children,
|
|
17
|
-
|
|
40
|
+
preAnchorRef,
|
|
41
|
+
postAnchorRef
|
|
18
42
|
}) => {
|
|
19
43
|
useEffect(() => {
|
|
20
44
|
// IntersectionObserver uses root and target elements to detect intersections, defaulting root to the viewport
|
|
21
45
|
const intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible));
|
|
22
|
-
|
|
46
|
+
(preAnchorRef === null || preAnchorRef === void 0 ? void 0 : preAnchorRef.current) && intersectionObserver.observe(preAnchorRef.current);
|
|
47
|
+
(postAnchorRef === null || postAnchorRef === void 0 ? void 0 : postAnchorRef.current) && intersectionObserver.observe(postAnchorRef.current);
|
|
48
|
+
cardEl && intersectionObserver.observe(cardEl);
|
|
23
49
|
return () => {
|
|
24
50
|
intersectionObserver.disconnect();
|
|
25
51
|
};
|
|
26
|
-
}, [
|
|
52
|
+
}, [cardEl, preAnchorRef, postAnchorRef, onVisible]);
|
|
27
53
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
28
54
|
};
|
|
29
55
|
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
export const ViewportDetector = ({
|
|
57
|
+
cardEl,
|
|
58
|
+
preAnchorRef,
|
|
59
|
+
postAnchorRef,
|
|
60
|
+
onVisible,
|
|
61
|
+
children
|
|
62
|
+
}) => {
|
|
63
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
64
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return /*#__PURE__*/React.createElement(ViewportObserver, {
|
|
68
|
+
cardEl: cardEl,
|
|
69
|
+
preAnchorRef: preAnchorRef,
|
|
70
|
+
postAnchorRef: postAnchorRef,
|
|
71
|
+
onVisible: onVisible
|
|
72
|
+
}, children);
|
|
73
|
+
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/actions.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
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; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
7
|
export function attachDetailsToActions(actions, details) {
|
|
8
8
|
return actions.map(function (action) {
|
package/dist/esm/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
@@ -32,7 +33,7 @@ export var MediaCardError = /*#__PURE__*/function (_Error) {
|
|
|
32
33
|
return _this;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
return MediaCardError;
|
|
36
|
+
return _createClass(MediaCardError);
|
|
36
37
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
37
38
|
export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
|
|
38
39
|
_inherits(LocalPreviewError, _MediaCardError);
|
|
@@ -50,7 +51,7 @@ export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
|
|
|
50
51
|
return _this2;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
return LocalPreviewError;
|
|
54
|
+
return _createClass(LocalPreviewError);
|
|
54
55
|
}(MediaCardError);
|
|
55
56
|
export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
|
|
56
57
|
_inherits(RemotePreviewError, _MediaCardError2);
|
|
@@ -68,7 +69,7 @@ export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
|
|
|
68
69
|
return _this3;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
return RemotePreviewError;
|
|
72
|
+
return _createClass(RemotePreviewError);
|
|
72
73
|
}(MediaCardError);
|
|
73
74
|
export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
|
|
74
75
|
_inherits(SsrPreviewError, _MediaCardError3);
|
|
@@ -86,7 +87,7 @@ export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
|
|
|
86
87
|
return _this4;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
return SsrPreviewError;
|
|
90
|
+
return _createClass(SsrPreviewError);
|
|
90
91
|
}(MediaCardError);
|
|
91
92
|
export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
|
|
92
93
|
switch (source) {
|
|
@@ -121,7 +122,7 @@ export var ImageLoadError = /*#__PURE__*/function (_MediaCardError4) {
|
|
|
121
122
|
return _super5.call(this, getImageLoadPrimaryReason(source));
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
return ImageLoadError;
|
|
125
|
+
return _createClass(ImageLoadError);
|
|
125
126
|
}(MediaCardError);
|
|
126
127
|
export function isMediaCardError(err) {
|
|
127
128
|
return err instanceof MediaCardError;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
|
|
2
|
-
export var relevantFeatureFlagNames = ['newCardExperience', 'captions'];
|
|
2
|
+
export var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
|
|
3
3
|
export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
|
|
4
4
|
var fireEvent = function fireEvent(payload) {
|
|
5
5
|
return fireMediaCardEvent(payload, createAnalyticsEvent);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
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; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
7
|
import { isErrorFileState } from '@atlaskit/media-client';
|
|
8
8
|
import { MediaCardError } from '../../errors';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
import { createObjectURLCache } from '../../../utils/objectURLCache';
|
|
@@ -6,7 +7,7 @@ import { createObjectURLCache } from '../../../utils/objectURLCache';
|
|
|
6
7
|
export var getCacheKey = function getCacheKey(id, dimensions) {
|
|
7
8
|
return [id, dimensions.height, dimensions.width].join('-');
|
|
8
9
|
};
|
|
9
|
-
export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
|
|
10
|
+
export var CardPreviewCacheImpl = /*#__PURE__*/_createClass(function CardPreviewCacheImpl(previewCache) {
|
|
10
11
|
var _this = this;
|
|
11
12
|
|
|
12
13
|
_classCallCheck(this, CardPreviewCacheImpl);
|
|
@@ -29,5 +30,5 @@ export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
|
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
this.previewCache = previewCache;
|
|
32
|
-
};
|
|
33
|
+
});
|
|
33
34
|
export default new CardPreviewCacheImpl(createObjectURLCache());
|
|
@@ -2,9 +2,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
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; }
|
|
8
8
|
|
|
9
9
|
import { isPreviewableFileState, addFileAttrsToUrl } from '@atlaskit/media-client';
|
|
10
10
|
import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
|
|
@@ -9,15 +9,15 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
9
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
11
|
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
13
|
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
|
|
16
16
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
17
17
|
|
|
18
18
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
19
|
|
|
20
|
-
import React, { Component } from 'react';
|
|
20
|
+
import React, { Component, createRef } from 'react';
|
|
21
21
|
import ReactDOM from 'react-dom';
|
|
22
22
|
import { version as packageVersion, name as packageName } from '../../version.json';
|
|
23
23
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -27,7 +27,7 @@ import { globalMediaEventEmitter, isDifferentIdentifier, isFileIdentifier, RECEN
|
|
|
27
27
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
28
28
|
import { injectIntl, IntlProvider } from 'react-intl-next';
|
|
29
29
|
import { CardView } from '../cardView';
|
|
30
|
-
import { ViewportDetector } from '../../utils/viewportDetector';
|
|
30
|
+
import { ABS_VIEWPORT_ANCHOR_OFFSET_TOP, ViewportDetector, ViewportAnchor } from '../../utils/viewportDetector';
|
|
31
31
|
import { getRequestedDimensions } from '../../utils/getDataURIDimension';
|
|
32
32
|
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, fetchAndCacheRemotePreview } from './getCardPreview';
|
|
33
33
|
import { getFileDetails } from '../../utils/metadata';
|
|
@@ -37,6 +37,8 @@ import { isLocalPreviewError, MediaCardError, ensureMediaCardError, ImageLoadErr
|
|
|
37
37
|
import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, relevantFeatureFlagNames, fireCopiedEvent, fireScreenEvent } from './cardAnalytics';
|
|
38
38
|
import getDocument from '../../utils/document';
|
|
39
39
|
import { getCardStateFromFileState, createStateUpdater } from './cardState';
|
|
40
|
+
import { isProcessedFileState } from '@atlaskit/media-client';
|
|
41
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
40
42
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
41
43
|
_inherits(CardBase, _Component);
|
|
42
44
|
|
|
@@ -53,6 +55,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
53
55
|
|
|
54
56
|
_defineProperty(_assertThisInitialized(_this), "hasBeenMounted", false);
|
|
55
57
|
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "viewportPreAnchorRef", /*#__PURE__*/createRef());
|
|
59
|
+
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "viewportPostAnchorRef", /*#__PURE__*/createRef());
|
|
61
|
+
|
|
56
62
|
_defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
|
|
57
63
|
|
|
58
64
|
_defineProperty(_assertThisInitialized(_this), "getImageURLParams", function (_ref) {
|
|
@@ -300,7 +306,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
300
306
|
|
|
301
307
|
if (useInlinePlayer && isVideo && !!cardPreview) {
|
|
302
308
|
_this.setState({
|
|
303
|
-
isPlayingFile: true
|
|
309
|
+
isPlayingFile: true,
|
|
310
|
+
shouldAutoplay: true
|
|
304
311
|
});
|
|
305
312
|
} else if (shouldOpenMediaViewer) {
|
|
306
313
|
var mediaViewerSelectedItem;
|
|
@@ -346,11 +353,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
346
353
|
selected = _this$props6.selected,
|
|
347
354
|
testId = _this$props6.testId,
|
|
348
355
|
originalDimensions = _this$props6.originalDimensions;
|
|
356
|
+
var shouldAutoplay = _this.state.shouldAutoplay;
|
|
349
357
|
return /*#__PURE__*/React.createElement(InlinePlayer, {
|
|
350
358
|
mediaClient: mediaClient,
|
|
351
359
|
dimensions: dimensions,
|
|
352
360
|
originalDimensions: originalDimensions,
|
|
353
361
|
identifier: identifier,
|
|
362
|
+
autoplay: !!shouldAutoplay,
|
|
354
363
|
onError: _this.onInlinePlayerError,
|
|
355
364
|
onClick: _this.onClick,
|
|
356
365
|
selected: selected,
|
|
@@ -489,9 +498,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
489
498
|
forceSyncDisplay: forceSyncDisplay
|
|
490
499
|
});
|
|
491
500
|
return isLazy ? /*#__PURE__*/React.createElement(ViewportDetector, {
|
|
492
|
-
|
|
501
|
+
cardEl: cardRef,
|
|
502
|
+
preAnchorRef: _this.viewportPreAnchorRef,
|
|
503
|
+
postAnchorRef: _this.viewportPostAnchorRef,
|
|
493
504
|
onVisible: _this.onCardInViewport
|
|
494
|
-
},
|
|
505
|
+
}, /*#__PURE__*/React.createElement(ViewportAnchor, {
|
|
506
|
+
ref: _this.viewportPreAnchorRef,
|
|
507
|
+
offsetTop: -ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
508
|
+
}), card, /*#__PURE__*/React.createElement(ViewportAnchor, {
|
|
509
|
+
ref: _this.viewportPostAnchorRef,
|
|
510
|
+
offsetTop: ABS_VIEWPORT_ANCHOR_OFFSET_TOP
|
|
511
|
+
})) : card;
|
|
495
512
|
});
|
|
496
513
|
|
|
497
514
|
_defineProperty(_assertThisInitialized(_this), "onCardInViewport", function () {
|
|
@@ -571,6 +588,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
571
588
|
status: _status,
|
|
572
589
|
isCardVisible: _isCardVisible,
|
|
573
590
|
isPlayingFile: false,
|
|
591
|
+
shouldAutoplay: false,
|
|
574
592
|
cardPreview: _cardPreview,
|
|
575
593
|
cardRef: null,
|
|
576
594
|
isBannedLocalPreview: false,
|
|
@@ -617,14 +635,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
617
635
|
mediaClient = _this$props11.mediaClient,
|
|
618
636
|
identifier = _this$props11.identifier,
|
|
619
637
|
dimensions = _this$props11.dimensions,
|
|
620
|
-
featureFlags = _this$props11.featureFlags
|
|
638
|
+
featureFlags = _this$props11.featureFlags,
|
|
639
|
+
useInlinePlayer = _this$props11.useInlinePlayer,
|
|
640
|
+
disableOverlay = _this$props11.disableOverlay;
|
|
621
641
|
var _this$state3 = this.state,
|
|
622
642
|
isCardVisible = _this$state3.isCardVisible,
|
|
623
643
|
cardPreview = _this$state3.cardPreview,
|
|
624
644
|
status = _this$state3.status,
|
|
625
645
|
fileState = _this$state3.fileState,
|
|
626
646
|
isBannedLocalPreview = _this$state3.isBannedLocalPreview,
|
|
627
|
-
previewDidRender = _this$state3.previewDidRender
|
|
647
|
+
previewDidRender = _this$state3.previewDidRender,
|
|
648
|
+
isPlayingFile = _this$state3.isPlayingFile;
|
|
628
649
|
var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
629
650
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
630
651
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -680,6 +701,15 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
680
701
|
});
|
|
681
702
|
this.unsubscribe();
|
|
682
703
|
}
|
|
704
|
+
|
|
705
|
+
var isVideo = this.fileAttributes.fileMediatype === 'video';
|
|
706
|
+
var videoAvailableToPlay = fileState && isProcessedFileState(fileState);
|
|
707
|
+
|
|
708
|
+
if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && videoAvailableToPlay && getMediaFeatureFlag('timestampOnVideo', this.props.featureFlags)) {
|
|
709
|
+
this.setState({
|
|
710
|
+
isPlayingFile: true
|
|
711
|
+
});
|
|
712
|
+
}
|
|
683
713
|
}
|
|
684
714
|
}, {
|
|
685
715
|
key: "componentWillUnmount",
|
|
@@ -6,9 +6,9 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
9
|
+
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; }
|
|
10
10
|
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
11
|
+
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; }
|
|
12
12
|
|
|
13
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); }; }
|
|
14
14
|
|
|
@@ -32,6 +32,8 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
32
32
|
|
|
33
33
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
34
|
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "isMounted", false);
|
|
36
|
+
|
|
35
37
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
36
38
|
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
37
39
|
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
@@ -50,13 +52,15 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
50
52
|
while (1) {
|
|
51
53
|
switch (_context.prev = _context.next) {
|
|
52
54
|
case 0:
|
|
55
|
+
this.isMounted = true;
|
|
56
|
+
|
|
53
57
|
if (this.state.MediaInlineCard) {
|
|
54
|
-
_context.next =
|
|
58
|
+
_context.next = 17;
|
|
55
59
|
break;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
_context.prev =
|
|
59
|
-
_context.next =
|
|
62
|
+
_context.prev = 2;
|
|
63
|
+
_context.next = 5;
|
|
60
64
|
return Promise.all([import(
|
|
61
65
|
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
62
66
|
'@atlaskit/media-client'), import(
|
|
@@ -65,7 +69,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
65
69
|
/* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
|
|
66
70
|
'../media-card-analytics-error-boundary')]);
|
|
67
71
|
|
|
68
|
-
case
|
|
72
|
+
case 5:
|
|
69
73
|
_yield$Promise$all = _context.sent;
|
|
70
74
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
71
75
|
mediaClient = _yield$Promise$all2[0];
|
|
@@ -73,23 +77,27 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
73
77
|
mediaCardErrorBoundaryModule = _yield$Promise$all2[2];
|
|
74
78
|
MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
|
|
75
79
|
MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
if (this.isMounted) {
|
|
82
|
+
this.setState({
|
|
83
|
+
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
84
|
+
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_context.next = 17;
|
|
81
89
|
break;
|
|
82
90
|
|
|
83
|
-
case
|
|
84
|
-
_context.prev =
|
|
85
|
-
_context.t0 = _context["catch"](
|
|
91
|
+
case 15:
|
|
92
|
+
_context.prev = 15;
|
|
93
|
+
_context.t0 = _context["catch"](2);
|
|
86
94
|
|
|
87
|
-
case
|
|
95
|
+
case 17:
|
|
88
96
|
case "end":
|
|
89
97
|
return _context.stop();
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
|
-
}, _callee, this, [[
|
|
100
|
+
}, _callee, this, [[2, 15]]);
|
|
93
101
|
}));
|
|
94
102
|
|
|
95
103
|
function componentDidMount() {
|
|
@@ -98,6 +106,30 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
98
106
|
|
|
99
107
|
return componentDidMount;
|
|
100
108
|
}()
|
|
109
|
+
}, {
|
|
110
|
+
key: "componentWillUnmount",
|
|
111
|
+
value: function () {
|
|
112
|
+
var _componentWillUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
113
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) {
|
|
115
|
+
switch (_context2.prev = _context2.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
this.isMounted = false;
|
|
118
|
+
|
|
119
|
+
case 1:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context2.stop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, _callee2, this);
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
function componentWillUnmount() {
|
|
128
|
+
return _componentWillUnmount.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return componentWillUnmount;
|
|
132
|
+
}()
|
|
101
133
|
}, {
|
|
102
134
|
key: "render",
|
|
103
135
|
value: function render() {
|
|
@@ -73,16 +73,20 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
73
73
|
locale: 'en'
|
|
74
74
|
});
|
|
75
75
|
useEffect(function () {
|
|
76
|
-
mediaClient.file.getFileState(identifier.id, {
|
|
76
|
+
var subscription = mediaClient.file.getFileState(identifier.id, {
|
|
77
77
|
collectionName: identifier.collectionName
|
|
78
78
|
}).subscribe({
|
|
79
79
|
next: function next(fileState) {
|
|
80
80
|
setFileState(fileState);
|
|
81
|
+
setIsErrored(false);
|
|
81
82
|
},
|
|
82
83
|
error: function error() {
|
|
83
84
|
setIsErrored(true);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
87
|
+
return function () {
|
|
88
|
+
subscription.unsubscribe();
|
|
89
|
+
};
|
|
86
90
|
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
87
91
|
|
|
88
92
|
if (!fileState) {
|