@atlaskit/media-card 70.9.0 → 72.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 +69 -0
- package/dist/cjs/errors.js +109 -6
- package/dist/cjs/files/cardImageView/index.js +58 -89
- package/dist/cjs/files/index.js +0 -6
- package/dist/cjs/index.js +16 -6
- package/dist/cjs/root/card/cardAnalytics.js +33 -19
- package/dist/cjs/root/card/cardConstants.js +8 -0
- package/dist/cjs/root/card/cardSSRView.js +114 -0
- package/dist/cjs/root/card/cardState.js +50 -0
- package/dist/cjs/root/card/getCardPreview/cache.js +49 -0
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +50 -0
- package/dist/cjs/root/card/getCardPreview/helpers.js +215 -0
- package/dist/cjs/root/card/getCardPreview/index.js +225 -0
- package/dist/cjs/root/card/getCardStatus.js +16 -21
- package/dist/cjs/root/card/index.js +339 -398
- package/dist/cjs/root/cardView.js +108 -56
- package/dist/cjs/root/index.js +9 -1
- package/dist/cjs/root/inline/loader.js +22 -21
- package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +66 -24
- package/dist/cjs/root/inlinePlayer.js +5 -15
- package/dist/cjs/root/ui/Breakpoint.js +13 -0
- package/dist/cjs/root/ui/common.js +5 -11
- package/dist/cjs/root/ui/iconMessage/index.js +17 -9
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +32 -115
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +2 -2
- package/dist/cjs/root/ui/progressBar/progressBar.js +2 -2
- package/dist/cjs/root/ui/progressBar/styled.js +3 -1
- package/dist/cjs/root/ui/styled.js +17 -80
- package/dist/cjs/root/ui/styledSSR.js +108 -0
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +7 -3
- package/dist/cjs/root/ui/titleBox/styled.js +3 -1
- package/dist/cjs/utils/analytics.js +26 -43
- package/dist/cjs/utils/dimensionComparer.js +1 -1
- package/dist/cjs/utils/document.js +12 -0
- package/dist/cjs/utils/getDataURIDimension.js +13 -2
- package/dist/cjs/utils/metadata.js +11 -3
- package/dist/cjs/utils/objectURLCache.js +6 -0
- package/dist/cjs/utils/resizeModeToMediaImageProps.js +13 -0
- package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/cjs/utils/videoSnapshot.js +45 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +52 -2
- package/dist/es2019/files/cardImageView/index.js +12 -46
- package/dist/es2019/files/index.js +1 -1
- package/dist/es2019/index.js +3 -3
- package/dist/es2019/root/card/cardAnalytics.js +23 -17
- package/dist/es2019/root/card/cardConstants.js +1 -0
- package/dist/es2019/root/card/cardSSRView.js +93 -0
- package/dist/es2019/root/card/cardState.js +26 -0
- package/dist/es2019/root/card/getCardPreview/cache.js +29 -0
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/es2019/root/card/getCardPreview/helpers.js +83 -0
- package/dist/es2019/root/card/getCardPreview/index.js +129 -0
- package/dist/es2019/root/card/getCardStatus.js +11 -15
- package/dist/es2019/root/card/index.js +292 -276
- package/dist/es2019/root/cardView.js +107 -53
- package/dist/es2019/root/index.js +2 -1
- package/dist/es2019/root/inline/loader.js +16 -15
- package/dist/es2019/root/inline/mediaInlineCard.js +127 -0
- package/dist/es2019/root/inlinePlayer.js +5 -13
- package/dist/es2019/root/ui/Breakpoint.js +6 -0
- package/dist/es2019/root/ui/common.js +1 -7
- package/dist/es2019/root/ui/iconMessage/index.js +10 -6
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +22 -74
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +1 -1
- package/dist/es2019/root/ui/progressBar/styled.js +2 -1
- package/dist/es2019/root/ui/styled.js +4 -64
- package/dist/es2019/root/ui/styledSSR.js +93 -0
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +5 -3
- package/dist/es2019/root/ui/titleBox/styled.js +2 -1
- package/dist/es2019/utils/analytics.js +29 -40
- package/dist/es2019/utils/dimensionComparer.js +1 -1
- package/dist/es2019/utils/document.js +1 -0
- package/dist/es2019/utils/getDataURIDimension.js +8 -0
- package/dist/es2019/utils/metadata.js +12 -4
- package/dist/es2019/utils/objectURLCache.js +5 -0
- package/dist/es2019/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/es2019/utils/videoSnapshot.js +7 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +85 -2
- package/dist/esm/files/cardImageView/index.js +55 -87
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/root/card/cardAnalytics.js +23 -18
- package/dist/esm/root/card/cardConstants.js +1 -0
- package/dist/esm/root/card/cardSSRView.js +92 -0
- package/dist/esm/root/card/cardState.js +32 -0
- package/dist/esm/root/card/getCardPreview/cache.js +33 -0
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +35 -0
- package/dist/esm/root/card/getCardPreview/helpers.js +194 -0
- package/dist/esm/root/card/getCardPreview/index.js +174 -0
- package/dist/esm/root/card/getCardStatus.js +13 -17
- package/dist/esm/root/card/index.js +349 -401
- package/dist/esm/root/cardView.js +105 -52
- package/dist/esm/root/index.js +2 -1
- package/dist/esm/root/inline/loader.js +23 -22
- package/dist/esm/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +62 -22
- package/dist/esm/root/inlinePlayer.js +5 -13
- package/dist/esm/root/ui/Breakpoint.js +6 -0
- package/dist/esm/root/ui/common.js +1 -7
- package/dist/esm/root/ui/iconMessage/index.js +12 -7
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +24 -106
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +1 -1
- package/dist/esm/root/ui/progressBar/styled.js +2 -1
- package/dist/esm/root/ui/styled.js +13 -61
- package/dist/esm/root/ui/styledSSR.js +76 -0
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +6 -3
- package/dist/esm/root/ui/titleBox/styled.js +2 -1
- package/dist/esm/utils/analytics.js +22 -35
- package/dist/esm/utils/dimensionComparer.js +1 -1
- package/dist/esm/utils/document.js +3 -0
- package/dist/esm/utils/getDataURIDimension.js +8 -0
- package/dist/esm/utils/metadata.js +12 -4
- package/dist/esm/utils/objectURLCache.js +6 -0
- package/dist/esm/utils/resizeModeToMediaImageProps.js +6 -0
- package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/esm/utils/videoSnapshot.js +31 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/__tests_external__/page-objects/MediaCard.d.ts +4 -3
- package/dist/types/errors.d.ts +24 -2
- package/dist/types/files/cardImageView/index.d.ts +5 -12
- package/dist/types/files/cardImageView/styled.d.ts +1 -1
- package/dist/types/files/index.d.ts +1 -1
- package/dist/types/index.d.ts +9 -12
- package/dist/types/root/card/cardAnalytics.d.ts +5 -7
- package/dist/types/root/card/cardConstants.d.ts +1 -0
- package/dist/types/root/card/cardSSRView.d.ts +13 -0
- package/dist/types/root/card/cardState.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/cache.d.ts +18 -0
- package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/helpers.d.ts +9 -0
- package/dist/types/root/card/getCardPreview/index.d.ts +44 -0
- package/dist/types/root/card/getCardStatus.d.ts +4 -14
- package/dist/types/root/card/index.d.ts +17 -21
- package/dist/types/root/cardView.d.ts +12 -8
- package/dist/types/root/index.d.ts +1 -0
- package/dist/types/root/inline/loader.d.ts +8 -8
- package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -4
- package/dist/types/root/inlinePlayer.d.ts +1 -1
- package/dist/types/root/ui/Breakpoint.d.ts +4 -0
- package/dist/types/root/ui/common.d.ts +1 -4
- package/dist/types/root/ui/iconMessage/index.d.ts +7 -2
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +2 -16
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/progressBar/progressBar.d.ts +1 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +1 -1
- package/dist/types/root/ui/styled.d.ts +3 -10
- package/dist/types/root/ui/styledSSR.d.ts +16 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -1
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -1
- package/dist/types/types.d.ts +15 -1
- package/dist/types/utils/analytics.d.ts +20 -21
- package/dist/types/utils/cardDimensions.d.ts +5 -1
- package/dist/types/utils/dimensionComparer.d.ts +1 -1
- package/dist/types/utils/document.d.ts +2 -0
- package/dist/types/utils/getDataURIDimension.d.ts +3 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/lazyContent/styled.d.ts +1 -1
- package/dist/types/utils/lightCards/types.d.ts +1 -1
- package/dist/types/utils/metadata.d.ts +2 -2
- package/dist/types/utils/objectURLCache.d.ts +2 -1
- package/dist/types/utils/resizeModeToMediaImageProps.d.ts +5 -0
- package/dist/types/utils/shouldDisplayImageThumbnail.d.ts +1 -1
- package/dist/types/utils/videoSnapshot.d.ts +1 -0
- package/example-helpers/index.tsx +21 -0
- package/package.json +19 -17
- package/dist/cjs/root/card/getCardPreview.js +0 -173
- package/dist/cjs/utils/fileAttributesContext.js +0 -40
- package/dist/es2019/root/card/getCardPreview.js +0 -86
- package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
- package/dist/es2019/utils/fileAttributesContext.js +0 -19
- package/dist/esm/root/card/getCardPreview.js +0 -153
- package/dist/esm/utils/fileAttributesContext.js +0 -18
- package/dist/types/root/card/getCardPreview.d.ts +0 -8
- package/dist/types/utils/fileAttributesContext.d.ts +0 -10
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import VideoSnapshot from 'video-snapshot';
|
|
2
|
-
import { getMediaTypeFromMimeType, isMimeTypeSupportedByBrowser, isPreviewableFileState, isImageRepresentationReady, isErrorFileState } from '@atlaskit/media-client';
|
|
3
|
-
import { getOrientation } from '@atlaskit/media-ui';
|
|
4
|
-
import { MediaCardError } from '../../errors';
|
|
5
|
-
export const getCardPreviewFromFileState = async fileState => {
|
|
6
|
-
/**
|
|
7
|
-
* We don't await on local preview for these following use cases:
|
|
8
|
-
* - fileState is in error
|
|
9
|
-
* - fileState isn't previewable
|
|
10
|
-
* - media hasn't been processed and isn't natively supported by browser
|
|
11
|
-
* - media has failed processing
|
|
12
|
-
*/
|
|
13
|
-
if (isErrorFileState(fileState) || !isPreviewableFileState(fileState) || !isMimeTypeSupportedByBrowser(fileState.mimeType) && fileState.status !== 'processed' || ['error', 'failed-processing'].includes(fileState.status)) {
|
|
14
|
-
return;
|
|
15
|
-
} // TODO: implement more specific error handling
|
|
16
|
-
// https://product-fabric.atlassian.net/browse/BMPT-1342
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const {
|
|
21
|
-
value
|
|
22
|
-
} = await fileState.preview;
|
|
23
|
-
|
|
24
|
-
if (value instanceof Blob) {
|
|
25
|
-
const {
|
|
26
|
-
type
|
|
27
|
-
} = value;
|
|
28
|
-
const mediaType = getMediaTypeFromMimeType(type);
|
|
29
|
-
|
|
30
|
-
if (mediaType === 'image') {
|
|
31
|
-
const orientation = await getOrientation(value);
|
|
32
|
-
const dataURI = URL.createObjectURL(value);
|
|
33
|
-
return {
|
|
34
|
-
dataURI,
|
|
35
|
-
orientation
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (mediaType === 'video') {
|
|
40
|
-
const snapshoter = new VideoSnapshot(value);
|
|
41
|
-
const dataURI = await snapshoter.takeSnapshot();
|
|
42
|
-
snapshoter.end();
|
|
43
|
-
return {
|
|
44
|
-
dataURI,
|
|
45
|
-
orientation: 1
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
return {
|
|
50
|
-
dataURI: value,
|
|
51
|
-
orientation: 1
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
throw new MediaCardError('local-preview-get', e);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
export const getCardPreviewFromBackend = async (mediaClient, identifier, fileState, requestedDimensions, resizeMode) => {
|
|
59
|
-
const {
|
|
60
|
-
id,
|
|
61
|
-
collectionName
|
|
62
|
-
} = identifier;
|
|
63
|
-
const {
|
|
64
|
-
width,
|
|
65
|
-
height
|
|
66
|
-
} = requestedDimensions;
|
|
67
|
-
const mode = resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode;
|
|
68
|
-
|
|
69
|
-
if (isImageRepresentationReady(fileState)) {
|
|
70
|
-
try {
|
|
71
|
-
const blob = await mediaClient.getImage(id, {
|
|
72
|
-
collection: collectionName,
|
|
73
|
-
mode,
|
|
74
|
-
width,
|
|
75
|
-
height,
|
|
76
|
-
allowAnimated: true
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
dataURI: URL.createObjectURL(blob),
|
|
80
|
-
orientation: 1
|
|
81
|
-
};
|
|
82
|
-
} catch (e) {
|
|
83
|
-
throw new MediaCardError('remote-preview-fetch', e);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { injectIntl } from 'react-intl';
|
|
4
|
-
import { InlineCardResolvedView, InlineCardResolvingView, InlineCardErroredView, messages } from '@atlaskit/media-ui';
|
|
5
|
-
import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
|
|
6
|
-
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
7
|
-
// UI component which renders an inline link in the appropiate state based on a media file
|
|
8
|
-
export const InlineMediaCardInternal = ({
|
|
9
|
-
mediaClient,
|
|
10
|
-
identifier,
|
|
11
|
-
shouldOpenMediaViewer,
|
|
12
|
-
isSelected,
|
|
13
|
-
onClick,
|
|
14
|
-
mediaViewerDataSource,
|
|
15
|
-
intl
|
|
16
|
-
}) => {
|
|
17
|
-
const [fileState, setFileState] = useState();
|
|
18
|
-
const [isMediaViewerVisible, setMediaViewerVisible] = useState(false);
|
|
19
|
-
|
|
20
|
-
const onInlineCardClick = event => {
|
|
21
|
-
if (shouldOpenMediaViewer) {
|
|
22
|
-
setMediaViewerVisible(true);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (onClick) {
|
|
26
|
-
onClick(event);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const onMediaViewerClose = () => setMediaViewerVisible(false);
|
|
31
|
-
|
|
32
|
-
const renderMediaViewer = () => {
|
|
33
|
-
if (isMediaViewerVisible) {
|
|
34
|
-
const dataSource = mediaViewerDataSource || {
|
|
35
|
-
list: []
|
|
36
|
-
};
|
|
37
|
-
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
38
|
-
collectionName: identifier.collectionName || '',
|
|
39
|
-
dataSource: dataSource,
|
|
40
|
-
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
41
|
-
selectedItem: identifier,
|
|
42
|
-
onClose: onMediaViewerClose
|
|
43
|
-
}), document.body);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
// [EDM-1948] TODO: use mediaClient.file.getFileState()
|
|
51
|
-
// [EDM-1948] TODO: handle error here
|
|
52
|
-
mediaClient.file.getCurrentState(identifier.id, {
|
|
53
|
-
collectionName: identifier.collectionName
|
|
54
|
-
}).then(fileState => {
|
|
55
|
-
setFileState(fileState);
|
|
56
|
-
});
|
|
57
|
-
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
58
|
-
|
|
59
|
-
if (!fileState) {
|
|
60
|
-
return /*#__PURE__*/React.createElement(InlineCardResolvingView, {
|
|
61
|
-
url: intl.formatMessage(messages.loading_file),
|
|
62
|
-
titleTextColor: "black",
|
|
63
|
-
withoutHover: true
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (fileState.status === 'error') {
|
|
68
|
-
return /*#__PURE__*/React.createElement(InlineCardErroredView, {
|
|
69
|
-
url: "",
|
|
70
|
-
message: fileState.message || ''
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const {
|
|
75
|
-
mediaType,
|
|
76
|
-
name
|
|
77
|
-
} = fileState;
|
|
78
|
-
const linkIcon = /*#__PURE__*/React.createElement(MediaTypeIcon, {
|
|
79
|
-
testId: 'inline-media-card-file-type-icon',
|
|
80
|
-
size: "small",
|
|
81
|
-
type: mediaType
|
|
82
|
-
});
|
|
83
|
-
const mediaViewer = renderMediaViewer(); // [EDM-1948] TODO: add Tooltip
|
|
84
|
-
|
|
85
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InlineCardResolvedView, {
|
|
86
|
-
icon: linkIcon,
|
|
87
|
-
title: name,
|
|
88
|
-
onClick: onInlineCardClick,
|
|
89
|
-
isSelected: isSelected
|
|
90
|
-
}), mediaViewer);
|
|
91
|
-
};
|
|
92
|
-
export const InlineMediaCard = injectIntl(InlineMediaCardInternal);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useContext } from 'react';
|
|
3
|
-
const FileAttributesContext = /*#__PURE__*/React.createContext(null);
|
|
4
|
-
export const FileAttributesProvider = ({
|
|
5
|
-
children,
|
|
6
|
-
data
|
|
7
|
-
}) => {
|
|
8
|
-
return data ? /*#__PURE__*/React.createElement(FileAttributesContext.Provider, {
|
|
9
|
-
value: data
|
|
10
|
-
}, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
11
|
-
};
|
|
12
|
-
export function withFileAttributes(Component) {
|
|
13
|
-
return props => {
|
|
14
|
-
const fileAttributes = useContext(FileAttributesContext);
|
|
15
|
-
return fileAttributes ? /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
16
|
-
fileAttributes: fileAttributes
|
|
17
|
-
})) : /*#__PURE__*/React.createElement(Component, props);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import VideoSnapshot from 'video-snapshot';
|
|
4
|
-
import { getMediaTypeFromMimeType, isMimeTypeSupportedByBrowser, isPreviewableFileState, isImageRepresentationReady, isErrorFileState } from '@atlaskit/media-client';
|
|
5
|
-
import { getOrientation } from '@atlaskit/media-ui';
|
|
6
|
-
import { MediaCardError } from '../../errors';
|
|
7
|
-
export var getCardPreviewFromFileState = /*#__PURE__*/function () {
|
|
8
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fileState) {
|
|
9
|
-
var _yield$fileState$prev, value, type, mediaType, orientation, dataURI, snapshoter, _dataURI;
|
|
10
|
-
|
|
11
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
-
while (1) {
|
|
13
|
-
switch (_context.prev = _context.next) {
|
|
14
|
-
case 0:
|
|
15
|
-
if (!(isErrorFileState(fileState) || !isPreviewableFileState(fileState) || !isMimeTypeSupportedByBrowser(fileState.mimeType) && fileState.status !== 'processed' || ['error', 'failed-processing'].includes(fileState.status))) {
|
|
16
|
-
_context.next = 2;
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return _context.abrupt("return");
|
|
21
|
-
|
|
22
|
-
case 2:
|
|
23
|
-
_context.prev = 2;
|
|
24
|
-
_context.next = 5;
|
|
25
|
-
return fileState.preview;
|
|
26
|
-
|
|
27
|
-
case 5:
|
|
28
|
-
_yield$fileState$prev = _context.sent;
|
|
29
|
-
value = _yield$fileState$prev.value;
|
|
30
|
-
|
|
31
|
-
if (!(value instanceof Blob)) {
|
|
32
|
-
_context.next = 25;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type = value.type;
|
|
37
|
-
mediaType = getMediaTypeFromMimeType(type);
|
|
38
|
-
|
|
39
|
-
if (!(mediaType === 'image')) {
|
|
40
|
-
_context.next = 16;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
_context.next = 13;
|
|
45
|
-
return getOrientation(value);
|
|
46
|
-
|
|
47
|
-
case 13:
|
|
48
|
-
orientation = _context.sent;
|
|
49
|
-
dataURI = URL.createObjectURL(value);
|
|
50
|
-
return _context.abrupt("return", {
|
|
51
|
-
dataURI: dataURI,
|
|
52
|
-
orientation: orientation
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
case 16:
|
|
56
|
-
if (!(mediaType === 'video')) {
|
|
57
|
-
_context.next = 23;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
snapshoter = new VideoSnapshot(value);
|
|
62
|
-
_context.next = 20;
|
|
63
|
-
return snapshoter.takeSnapshot();
|
|
64
|
-
|
|
65
|
-
case 20:
|
|
66
|
-
_dataURI = _context.sent;
|
|
67
|
-
snapshoter.end();
|
|
68
|
-
return _context.abrupt("return", {
|
|
69
|
-
dataURI: _dataURI,
|
|
70
|
-
orientation: 1
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
case 23:
|
|
74
|
-
_context.next = 26;
|
|
75
|
-
break;
|
|
76
|
-
|
|
77
|
-
case 25:
|
|
78
|
-
return _context.abrupt("return", {
|
|
79
|
-
dataURI: value,
|
|
80
|
-
orientation: 1
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
case 26:
|
|
84
|
-
_context.next = 31;
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
case 28:
|
|
88
|
-
_context.prev = 28;
|
|
89
|
-
_context.t0 = _context["catch"](2);
|
|
90
|
-
throw new MediaCardError('local-preview-get', _context.t0);
|
|
91
|
-
|
|
92
|
-
case 31:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, _callee, null, [[2, 28]]);
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
return function getCardPreviewFromFileState(_x) {
|
|
101
|
-
return _ref.apply(this, arguments);
|
|
102
|
-
};
|
|
103
|
-
}();
|
|
104
|
-
export var getCardPreviewFromBackend = /*#__PURE__*/function () {
|
|
105
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaClient, identifier, fileState, requestedDimensions, resizeMode) {
|
|
106
|
-
var id, collectionName, width, height, mode, blob;
|
|
107
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
108
|
-
while (1) {
|
|
109
|
-
switch (_context2.prev = _context2.next) {
|
|
110
|
-
case 0:
|
|
111
|
-
id = identifier.id, collectionName = identifier.collectionName;
|
|
112
|
-
width = requestedDimensions.width, height = requestedDimensions.height;
|
|
113
|
-
mode = resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode;
|
|
114
|
-
|
|
115
|
-
if (!isImageRepresentationReady(fileState)) {
|
|
116
|
-
_context2.next = 14;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
_context2.prev = 4;
|
|
121
|
-
_context2.next = 7;
|
|
122
|
-
return mediaClient.getImage(id, {
|
|
123
|
-
collection: collectionName,
|
|
124
|
-
mode: mode,
|
|
125
|
-
width: width,
|
|
126
|
-
height: height,
|
|
127
|
-
allowAnimated: true
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
case 7:
|
|
131
|
-
blob = _context2.sent;
|
|
132
|
-
return _context2.abrupt("return", {
|
|
133
|
-
dataURI: URL.createObjectURL(blob),
|
|
134
|
-
orientation: 1
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
case 11:
|
|
138
|
-
_context2.prev = 11;
|
|
139
|
-
_context2.t0 = _context2["catch"](4);
|
|
140
|
-
throw new MediaCardError('remote-preview-fetch', _context2.t0);
|
|
141
|
-
|
|
142
|
-
case 14:
|
|
143
|
-
case "end":
|
|
144
|
-
return _context2.stop();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, _callee2, null, [[4, 11]]);
|
|
148
|
-
}));
|
|
149
|
-
|
|
150
|
-
return function getCardPreviewFromBackend(_x2, _x3, _x4, _x5, _x6) {
|
|
151
|
-
return _ref2.apply(this, arguments);
|
|
152
|
-
};
|
|
153
|
-
}();
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useContext } from 'react';
|
|
3
|
-
var FileAttributesContext = /*#__PURE__*/React.createContext(null);
|
|
4
|
-
export var FileAttributesProvider = function FileAttributesProvider(_ref) {
|
|
5
|
-
var children = _ref.children,
|
|
6
|
-
data = _ref.data;
|
|
7
|
-
return data ? /*#__PURE__*/React.createElement(FileAttributesContext.Provider, {
|
|
8
|
-
value: data
|
|
9
|
-
}, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
10
|
-
};
|
|
11
|
-
export function withFileAttributes(Component) {
|
|
12
|
-
return function (props) {
|
|
13
|
-
var fileAttributes = useContext(FileAttributesContext);
|
|
14
|
-
return fileAttributes ? /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
15
|
-
fileAttributes: fileAttributes
|
|
16
|
-
})) : /*#__PURE__*/React.createElement(Component, props);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MediaClient, FileIdentifier, FileState } from '@atlaskit/media-client';
|
|
2
|
-
import { NumericalCardDimensions } from '../../';
|
|
3
|
-
export interface CardPreview {
|
|
4
|
-
dataURI?: string;
|
|
5
|
-
orientation?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const getCardPreviewFromFileState: (fileState: FileState) => Promise<CardPreview | undefined>;
|
|
8
|
-
export declare const getCardPreviewFromBackend: (mediaClient: MediaClient, identifier: FileIdentifier, fileState: FileState, requestedDimensions: NumericalCardDimensions, resizeMode?: "crop" | "fit" | "full-fit" | "stretchy-fit" | undefined) => Promise<CardPreview | undefined>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileAttributes } from '@atlaskit/media-common';
|
|
3
|
-
export declare type FileAttributesProviderProps = {
|
|
4
|
-
data: FileAttributes;
|
|
5
|
-
};
|
|
6
|
-
export declare const FileAttributesProvider: React.FC<FileAttributesProviderProps>;
|
|
7
|
-
export declare type WithFileAttributesProps = {
|
|
8
|
-
fileAttributes?: FileAttributes;
|
|
9
|
-
};
|
|
10
|
-
export declare function withFileAttributes<Props>(Component: React.ComponentType<Props & WithFileAttributesProps>): React.FC<Props>;
|