@atlaskit/media-card 72.0.0 → 73.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +35 -11
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +1 -1
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +2 -2
- package/dist/cjs/root/card/cardLoader.js +66 -124
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
- package/dist/cjs/root/card/getCardPreview/index.js +101 -18
- package/dist/cjs/root/card/getCardStatus.js +1 -1
- package/dist/cjs/root/card/index.js +191 -97
- package/dist/cjs/root/cardView.js +44 -57
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +31 -11
- package/dist/cjs/root/inlinePlayer.js +77 -24
- package/dist/cjs/root/styled.js +7 -3
- package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
- package/dist/cjs/root/ui/blanket/styled.js +1 -1
- package/dist/cjs/root/ui/common.js +11 -5
- package/dist/cjs/root/ui/iconMessage/index.js +5 -3
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +7 -4
- package/dist/cjs/root/ui/progressBar/styled.js +8 -9
- package/dist/cjs/root/ui/styled.js +80 -17
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
- package/dist/cjs/root/ui/titleBox/styled.js +2 -4
- package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
- package/dist/cjs/styles/index.js +25 -23
- package/dist/cjs/styles/mixins.js +1 -1
- package/dist/cjs/utils/analytics.js +2 -1
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -9
- package/dist/cjs/utils/cardActions/index.js +10 -10
- package/dist/cjs/utils/cardActions/styled.js +1 -1
- package/dist/cjs/utils/cardDimensions.js +1 -1
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- package/dist/cjs/utils/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/objectURLCache.js +1 -1
- package/dist/cjs/utils/viewportDetector.js +49 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +9 -1
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/cardLoader.js +47 -53
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/es2019/root/card/getCardPreview/index.js +45 -3
- package/dist/es2019/root/card/index.js +131 -35
- package/dist/es2019/root/cardView.js +26 -40
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +30 -10
- package/dist/es2019/root/inlinePlayer.js +56 -4
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/common.js +7 -1
- package/dist/es2019/root/ui/iconMessage/index.js +3 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
- package/dist/es2019/root/ui/progressBar/styled.js +7 -6
- package/dist/es2019/root/ui/styled.js +65 -4
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/es2019/root/ui/titleBox/styled.js +1 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
- package/dist/es2019/utils/getErrorMessage.js +1 -1
- package/dist/es2019/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +28 -9
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardLoader.js +66 -126
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/esm/root/card/getCardPreview/index.js +74 -12
- package/dist/esm/root/card/index.js +198 -100
- package/dist/esm/root/cardView.js +42 -54
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +30 -10
- package/dist/esm/root/inlinePlayer.js +74 -23
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/common.js +7 -1
- package/dist/esm/root/ui/iconMessage/index.js +3 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
- package/dist/esm/root/ui/progressBar/styled.js +7 -7
- package/dist/esm/root/ui/styled.js +61 -13
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/esm/root/ui/titleBox/styled.js +1 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -9
- package/dist/esm/utils/getErrorMessage.js +1 -1
- package/dist/esm/utils/viewportDetector.js +48 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +9 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/root/card/cardLoader.d.ts +5 -19
- package/dist/types/root/card/getCardPreview/index.d.ts +7 -1
- package/dist/types/root/card/index.d.ts +9 -8
- package/dist/types/root/cardView.d.ts +5 -3
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
- package/dist/types/root/inlinePlayer.d.ts +8 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/common.d.ts +4 -1
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +3 -2
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +4 -2
- package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
- package/dist/types/root/ui/styled.d.ts +10 -3
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -3
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/getErrorMessage.d.ts +1 -0
- package/dist/types/utils/viewportDetector.d.ts +13 -5
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +34 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +16 -15
- package/dist/cjs/root/card/cardSSRView.js +0 -114
- package/dist/cjs/root/ui/Breakpoint.js +0 -13
- package/dist/cjs/root/ui/styledSSR.js +0 -108
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/root/card/cardSSRView.js +0 -93
- package/dist/es2019/root/ui/Breakpoint.js +0 -6
- package/dist/es2019/root/ui/styledSSR.js +0 -93
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/root/card/cardSSRView.js +0 -92
- package/dist/esm/root/ui/Breakpoint.js +0 -6
- package/dist/esm/root/ui/styledSSR.js +0 -76
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/root/card/cardSSRView.d.ts +0 -13
- package/dist/types/root/ui/Breakpoint.d.ts +0 -4
- package/dist/types/root/ui/styledSSR.d.ts +0 -16
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -1,129 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
|
|
12
|
-
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); }; }
|
|
13
|
-
|
|
14
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
-
|
|
16
|
-
import React from 'react';
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { useMemoizeFeatureFlags } from '@atlaskit/media-common';
|
|
4
|
+
import Loadable from 'react-loadable';
|
|
17
5
|
import { CardLoading } from '../..';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
|
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
36
|
-
Card: CardLoader.Card,
|
|
37
|
-
MediaCardErrorBoundary: CardLoader.MediaCardErrorBoundary
|
|
6
|
+
var MediaCardContext = /*#__PURE__*/React.createContext({});
|
|
7
|
+
|
|
8
|
+
var CardLoadingWithContext = function CardLoadingWithContext() {
|
|
9
|
+
var props = useContext(MediaCardContext);
|
|
10
|
+
return /*#__PURE__*/React.createElement(CardLoading, props);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var MediaCard = Loadable({
|
|
14
|
+
loader: function loader() {
|
|
15
|
+
return import(
|
|
16
|
+
/* webpackChunkName: "@atlaskit-internal_media-card" */
|
|
17
|
+
'./index').then(function (mod) {
|
|
18
|
+
return mod.Card;
|
|
38
19
|
});
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
},
|
|
21
|
+
loading: function loading() {
|
|
22
|
+
return /*#__PURE__*/React.createElement(CardLoadingWithContext, null);
|
|
41
23
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, _callee, this, [[1, 14]]);
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
function componentDidMount() {
|
|
96
|
-
return _componentDidMount.apply(this, arguments);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return componentDidMount;
|
|
100
|
-
}()
|
|
101
|
-
}, {
|
|
102
|
-
key: "render",
|
|
103
|
-
value: function render() {
|
|
104
|
-
var _this$props = this.props,
|
|
105
|
-
dimensions = _this$props.dimensions,
|
|
106
|
-
testId = _this$props.testId,
|
|
107
|
-
featureFlags = _this$props.featureFlags;
|
|
108
|
-
var _this$state = this.state,
|
|
109
|
-
Card = _this$state.Card,
|
|
110
|
-
MediaCardErrorBoundary = _this$state.MediaCardErrorBoundary;
|
|
111
|
-
|
|
112
|
-
if (!Card || !MediaCardErrorBoundary) {
|
|
113
|
-
return /*#__PURE__*/React.createElement(CardLoading, {
|
|
114
|
-
testId: testId,
|
|
115
|
-
dimensions: dimensions,
|
|
116
|
-
featureFlags: featureFlags
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return /*#__PURE__*/React.createElement(MediaCardErrorBoundary, null, /*#__PURE__*/React.createElement(Card, this.props));
|
|
121
|
-
}
|
|
122
|
-
}]);
|
|
123
|
-
|
|
124
|
-
return CardLoader;
|
|
125
|
-
}(React.PureComponent);
|
|
126
|
-
|
|
127
|
-
_defineProperty(CardLoader, "displayName", 'AsyncCard');
|
|
128
|
-
|
|
129
|
-
export { CardLoader as default };
|
|
24
|
+
});
|
|
25
|
+
var MediaCardErrorBoundary = Loadable({
|
|
26
|
+
loader: function loader() {
|
|
27
|
+
return import(
|
|
28
|
+
/* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
|
|
29
|
+
'../media-card-analytics-error-boundary').then(function (mod) {
|
|
30
|
+
return mod.default;
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
loading: function loading() {
|
|
34
|
+
return /*#__PURE__*/React.createElement(CardLoadingWithContext, null);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var MediaCardWithMediaClient = Loadable({
|
|
38
|
+
loader: function loader() {
|
|
39
|
+
return import(
|
|
40
|
+
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
41
|
+
'@atlaskit/media-client');
|
|
42
|
+
},
|
|
43
|
+
loading: function loading() {
|
|
44
|
+
return /*#__PURE__*/React.createElement(CardLoadingWithContext, null);
|
|
45
|
+
},
|
|
46
|
+
render: function render(loaded, props) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(CardWithMediaClient, _extends({}, props, {
|
|
48
|
+
withMediaClient: loaded.withMediaClient
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
var CardWithMediaClient = function CardWithMediaClient(props) {
|
|
54
|
+
var withMediaClient = props.withMediaClient,
|
|
55
|
+
featureFlags = props.featureFlags;
|
|
56
|
+
var memoizedFeatureFlags = useMemoizeFeatureFlags(featureFlags);
|
|
57
|
+
var Card = React.useMemo(function () {
|
|
58
|
+
return withMediaClient(MediaCard, memoizedFeatureFlags);
|
|
59
|
+
}, [withMediaClient, memoizedFeatureFlags]);
|
|
60
|
+
return /*#__PURE__*/React.createElement(MediaCardErrorBoundary, null, /*#__PURE__*/React.createElement(Card, props));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var CardLoader = function CardLoader(props) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(MediaCardContext.Provider, {
|
|
65
|
+
value: props
|
|
66
|
+
}, /*#__PURE__*/React.createElement(MediaCardWithMediaClient, props));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default CardLoader;
|
|
@@ -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());
|
|
@@ -31,5 +31,8 @@ export var isPreviewableStatus = function isPreviewableStatus(cardStatus, _ref3)
|
|
|
31
31
|
var isPreviewable = _ref3.isPreviewable,
|
|
32
32
|
hasPreview = _ref3.hasPreview,
|
|
33
33
|
isSupportedByBrowser = _ref3.isSupportedByBrowser;
|
|
34
|
-
return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' ||
|
|
34
|
+
return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' || // For Video, we can have local or remote preview while processing.
|
|
35
|
+
// Then, we only want to show the thumbnail if the file is supported by the browser,
|
|
36
|
+
// this way we prevent playing unsupported videos that are not procesed
|
|
37
|
+
cardStatus === 'processing' && isSupportedByBrowser);
|
|
35
38
|
};
|
|
@@ -2,15 +2,15 @@ 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';
|
|
11
11
|
import cardPreviewCache from './cache';
|
|
12
12
|
import { getCardPreviewFromFilePreview, getCardPreviewFromBackend } from './helpers';
|
|
13
|
-
import { MediaCardError, isUnsupportedLocalPreviewError } from '../../../errors';
|
|
13
|
+
import { MediaCardError, SsrPreviewError, isUnsupportedLocalPreviewError } from '../../../errors';
|
|
14
14
|
import { isBigger } from '../../../utils/dimensionComparer';
|
|
15
15
|
import { extractFilePreviewStatus, isPreviewableStatus } from './filePreviewStatus';
|
|
16
16
|
export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview } from './helpers';
|
|
@@ -38,6 +38,14 @@ var extendAndCachePreview = function extendAndCachePreview(id, dimensions, previ
|
|
|
38
38
|
source = 'cache-remote';
|
|
39
39
|
break;
|
|
40
40
|
|
|
41
|
+
case 'ssr-server':
|
|
42
|
+
source = 'cache-ssr-server';
|
|
43
|
+
break;
|
|
44
|
+
|
|
45
|
+
case 'ssr-client':
|
|
46
|
+
source = 'cache-ssr-client';
|
|
47
|
+
break;
|
|
48
|
+
|
|
41
49
|
default:
|
|
42
50
|
source = preview.source;
|
|
43
51
|
} // We want to embed some meta context into dataURI for Copy/Paste to work.
|
|
@@ -67,7 +75,7 @@ var extendAndCachePreview = function extendAndCachePreview(id, dimensions, previ
|
|
|
67
75
|
|
|
68
76
|
export var getCardPreview = /*#__PURE__*/function () {
|
|
69
77
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
70
|
-
var mediaClient, id, _ref$dimensions, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, cachedPreview, localPreview
|
|
78
|
+
var mediaClient, id, _ref$dimensions, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, cachedPreview, localPreview;
|
|
71
79
|
|
|
72
80
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
73
81
|
while (1) {
|
|
@@ -141,14 +149,9 @@ export var getCardPreview = /*#__PURE__*/function () {
|
|
|
141
149
|
throw new MediaCardError('remote-preview-not-ready');
|
|
142
150
|
|
|
143
151
|
case 19:
|
|
144
|
-
_context.
|
|
145
|
-
return getCardPreviewFromBackend(mediaClient, id, imageUrlParams);
|
|
146
|
-
|
|
147
|
-
case 21:
|
|
148
|
-
remotePreview = _context.sent;
|
|
149
|
-
return _context.abrupt("return", extendAndCachePreview(id, dimensions, remotePreview, mediaBlobUrlAttrs));
|
|
152
|
+
return _context.abrupt("return", fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs));
|
|
150
153
|
|
|
151
|
-
case
|
|
154
|
+
case 20:
|
|
152
155
|
case "end":
|
|
153
156
|
return _context.stop();
|
|
154
157
|
}
|
|
@@ -171,4 +174,63 @@ export var shouldResolvePreview = function shouldResolvePreview(_ref3) {
|
|
|
171
174
|
var statusIsPreviewable = isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview, featureFlags));
|
|
172
175
|
var dimensionsAreBigger = isBigger(prevDimensions, dimensions);
|
|
173
176
|
return statusIsPreviewable && (!hasCardPreview || dimensionsAreBigger);
|
|
174
|
-
};
|
|
177
|
+
};
|
|
178
|
+
export var getSSRCardPreview = function getSSRCardPreview(ssr, mediaClient, id, params, mediaBlobUrlAttrs) {
|
|
179
|
+
var dataURI;
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
var rawDataURI = mediaClient.getImageUrlSync(id, params); // We want to embed some meta context into dataURI for Copy/Paste to work.
|
|
183
|
+
|
|
184
|
+
dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(rawDataURI, mediaBlobUrlAttrs) : rawDataURI;
|
|
185
|
+
var source = ssr === 'client' ? 'ssr-client' : 'ssr-server';
|
|
186
|
+
return {
|
|
187
|
+
dataURI: dataURI,
|
|
188
|
+
source: source,
|
|
189
|
+
orientation: 1
|
|
190
|
+
};
|
|
191
|
+
} catch (e) {
|
|
192
|
+
var reason = ssr === 'server' ? 'ssr-server-uri' : 'ssr-client-uri';
|
|
193
|
+
throw new SsrPreviewError(reason, e);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
export var isLocalPreview = function isLocalPreview(preview) {
|
|
197
|
+
var localSources = ['local', 'cache-local'];
|
|
198
|
+
return localSources.includes(preview.source);
|
|
199
|
+
};
|
|
200
|
+
export var isSSRPreview = function isSSRPreview(preview) {
|
|
201
|
+
return isSSRClientPreview(preview) || isSSRServerPreview(preview);
|
|
202
|
+
};
|
|
203
|
+
export var isSSRServerPreview = function isSSRServerPreview(preview) {
|
|
204
|
+
var ssrClientSources = ['ssr-server', 'cache-ssr-server'];
|
|
205
|
+
return ssrClientSources.includes(preview.source);
|
|
206
|
+
};
|
|
207
|
+
export var isSSRClientPreview = function isSSRClientPreview(preview) {
|
|
208
|
+
var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
|
|
209
|
+
return ssrClientSources.includes(preview.source);
|
|
210
|
+
};
|
|
211
|
+
export var fetchAndCacheRemotePreview = /*#__PURE__*/function () {
|
|
212
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaClient, id, dimensions, params, mediaBlobUrlAttrs) {
|
|
213
|
+
var remotePreview;
|
|
214
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
215
|
+
while (1) {
|
|
216
|
+
switch (_context2.prev = _context2.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
_context2.next = 2;
|
|
219
|
+
return getCardPreviewFromBackend(mediaClient, id, params);
|
|
220
|
+
|
|
221
|
+
case 2:
|
|
222
|
+
remotePreview = _context2.sent;
|
|
223
|
+
return _context2.abrupt("return", extendAndCachePreview(id, dimensions, remotePreview, mediaBlobUrlAttrs));
|
|
224
|
+
|
|
225
|
+
case 4:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context2.stop();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, _callee2);
|
|
231
|
+
}));
|
|
232
|
+
|
|
233
|
+
return function fetchAndCacheRemotePreview(_x2, _x3, _x4, _x5, _x6) {
|
|
234
|
+
return _ref4.apply(this, arguments);
|
|
235
|
+
};
|
|
236
|
+
}();
|