@atlaskit/media-card 78.0.7 → 78.0.8
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 +8 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/fileCard.js +2 -2
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/types.js +16 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/fileCard.js +1 -1
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/types.js +10 -0
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/fileCard.js +1 -1
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/types.js +14 -0
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/types.d.ts +4 -0
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/package.json +1 -1
- package/dist/cjs/card/cardState.js +0 -37
- package/dist/cjs/card/getCardPreview/cache.js +0 -39
- package/dist/cjs/card/getCardPreview/filePreviewStatus.js +0 -45
- package/dist/cjs/card/getCardPreview/helpers.js +0 -165
- package/dist/cjs/card/getCardPreview/index.js +0 -245
- package/dist/es2019/card/cardState.js +0 -30
- package/dist/es2019/card/getCardPreview/cache.js +0 -33
- package/dist/es2019/card/getCardPreview/filePreviewStatus.js +0 -43
- package/dist/es2019/card/getCardPreview/helpers.js +0 -74
- package/dist/es2019/card/getCardPreview/index.js +0 -170
- package/dist/esm/card/cardState.js +0 -32
- package/dist/esm/card/getCardPreview/cache.js +0 -35
- package/dist/esm/card/getCardPreview/filePreviewStatus.js +0 -40
- package/dist/esm/card/getCardPreview/helpers.js +0 -158
- package/dist/esm/card/getCardPreview/index.js +0 -213
- package/dist/types/card/cardState.d.ts +0 -9
- package/dist/types/card/getCardPreview/cache.d.ts +0 -21
- package/dist/types/card/getCardPreview/filePreviewStatus.d.ts +0 -4
- package/dist/types/card/getCardPreview/helpers.d.ts +0 -10
- package/dist/types/card/getCardPreview/index.d.ts +0 -53
- package/dist/types-ts4.5/card/cardState.d.ts +0 -9
- package/dist/types-ts4.5/card/getCardPreview/cache.d.ts +0 -21
- package/dist/types-ts4.5/card/getCardPreview/filePreviewStatus.d.ts +0 -4
- package/dist/types-ts4.5/card/getCardPreview/helpers.d.ts +0 -10
- package/dist/types-ts4.5/card/getCardPreview/index.d.ts +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 78.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#120561](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120561)
|
|
8
|
+
[`5bcb6ac107e75`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5bcb6ac107e75) -
|
|
9
|
+
Removed unused code in Media Card
|
|
10
|
+
|
|
3
11
|
## 78.0.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -16,7 +16,7 @@ var _externalImageCard = require("./externalImageCard");
|
|
|
16
16
|
var _fileCard = require("./fileCard");
|
|
17
17
|
var _excluded = ["identifier"];
|
|
18
18
|
var packageName = "@atlaskit/media-card";
|
|
19
|
-
var packageVersion = "78.0.
|
|
19
|
+
var packageVersion = "78.0.8";
|
|
20
20
|
var CardBase = exports.CardBase = function CardBase(_ref) {
|
|
21
21
|
var identifier = _ref.identifier,
|
|
22
22
|
otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
@@ -18,6 +18,7 @@ var _mediaViewer = require("@atlaskit/media-viewer");
|
|
|
18
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
19
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
20
20
|
var _errors = require("../errors");
|
|
21
|
+
var _types = require("../types");
|
|
21
22
|
var _document = _interopRequireDefault(require("../utils/document"));
|
|
22
23
|
var _generateUniqueId = require("../utils/generateUniqueId");
|
|
23
24
|
var _getDataURIDimension = require("../utils/getDataURIDimension");
|
|
@@ -29,7 +30,6 @@ var _usePrevious = require("../utils/usePrevious");
|
|
|
29
30
|
var _viewportDetector = require("../utils/viewportDetector");
|
|
30
31
|
var _cardDimensions = require("../utils/cardDimensions");
|
|
31
32
|
var _cardAnalytics = require("./cardAnalytics");
|
|
32
|
-
var _getCardPreview = require("./getCardPreview");
|
|
33
33
|
var _cardView = require("./cardView");
|
|
34
34
|
var _cardviews = require("./cardviews");
|
|
35
35
|
var _inlinePlayerLazy = require("./inlinePlayerLazy");
|
|
@@ -571,7 +571,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
571
571
|
// Side note: We should not lazy load if the cardPreview is available from local cache,
|
|
572
572
|
// in order to avoid flickers during re-mount of the component
|
|
573
573
|
// CXP-2723 TODO: Create test cases for the above scenarios
|
|
574
|
-
var nativeLazyLoad = isLazyWithOverride && !isCardVisible && preview && (0,
|
|
574
|
+
var nativeLazyLoad = isLazyWithOverride && !isCardVisible && preview && (0, _types.isSSRPreview)(preview);
|
|
575
575
|
// Force Media Image to always display img for SSR
|
|
576
576
|
var forceSyncDisplay = !!ssr;
|
|
577
577
|
var card = /*#__PURE__*/_react.default.createElement(LoadedCardView, {
|
|
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
90
90
|
}(_react.default.Component);
|
|
91
91
|
(0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
92
92
|
var packageName = "@atlaskit/media-card";
|
|
93
|
-
var packageVersion = "78.0.
|
|
93
|
+
var packageVersion = "78.0.8";
|
|
94
94
|
var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
95
95
|
packageVersion: packageVersion,
|
|
96
96
|
packageName: packageName,
|
|
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
|
|
|
119
119
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
120
120
|
var analyticsContext = {
|
|
121
121
|
packageVersion: "@atlaskit/media-card",
|
|
122
|
-
packageName: "78.0.
|
|
122
|
+
packageName: "78.0.8",
|
|
123
123
|
componentName: 'mediaInlineCard',
|
|
124
124
|
component: 'mediaInlineCard'
|
|
125
125
|
};
|
package/dist/cjs/types.js
CHANGED
|
@@ -3,11 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.MediaCardCursor = void 0;
|
|
6
|
+
exports.isSSRServerPreview = exports.isSSRPreview = exports.isSSRDataPreview = exports.isSSRClientPreview = exports.MediaCardCursor = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Entry Point: @atlaskit/media-card/types
|
|
9
9
|
* tsconfig.entry-points.json
|
|
10
10
|
*/
|
|
11
|
+
|
|
12
|
+
var isSSRPreview = exports.isSSRPreview = function isSSRPreview(preview) {
|
|
13
|
+
return isSSRClientPreview(preview) || isSSRServerPreview(preview) || isSSRDataPreview(preview);
|
|
14
|
+
};
|
|
15
|
+
var isSSRServerPreview = exports.isSSRServerPreview = function isSSRServerPreview(preview) {
|
|
16
|
+
var ssrClientSources = ['ssr-server', 'cache-ssr-server'];
|
|
17
|
+
return ssrClientSources.includes(preview.source);
|
|
18
|
+
};
|
|
19
|
+
var isSSRClientPreview = exports.isSSRClientPreview = function isSSRClientPreview(preview) {
|
|
20
|
+
var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
|
|
21
|
+
return ssrClientSources.includes(preview.source);
|
|
22
|
+
};
|
|
23
|
+
var isSSRDataPreview = exports.isSSRDataPreview = function isSSRDataPreview(preview) {
|
|
24
|
+
return preview.source === 'ssr-data';
|
|
25
|
+
};
|
|
11
26
|
var MediaCardCursor = exports.MediaCardCursor = /*#__PURE__*/function (MediaCardCursor) {
|
|
12
27
|
MediaCardCursor["Action"] = "pointer";
|
|
13
28
|
MediaCardCursor["NotReady"] = "wait";
|
|
@@ -15,7 +15,7 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
15
15
|
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; }
|
|
16
16
|
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; }
|
|
17
17
|
var packageName = "@atlaskit/media-card";
|
|
18
|
-
var packageVersion = "78.0.
|
|
18
|
+
var packageVersion = "78.0.8";
|
|
19
19
|
var concurrentExperience;
|
|
20
20
|
var getExperience = function getExperience(id) {
|
|
21
21
|
if (!concurrentExperience) {
|
package/dist/es2019/card/card.js
CHANGED
|
@@ -7,7 +7,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
|
7
7
|
import { ExternalImageCard } from './externalImageCard';
|
|
8
8
|
import { FileCard } from './fileCard';
|
|
9
9
|
const packageName = "@atlaskit/media-card";
|
|
10
|
-
const packageVersion = "78.0.
|
|
10
|
+
const packageVersion = "78.0.8";
|
|
11
11
|
export const CardBase = ({
|
|
12
12
|
identifier,
|
|
13
13
|
...otherProps
|
|
@@ -7,6 +7,7 @@ import { MediaViewer } from '@atlaskit/media-viewer';
|
|
|
7
7
|
import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import ReactDOM from 'react-dom';
|
|
9
9
|
import { MediaCardError } from '../errors';
|
|
10
|
+
import { isSSRPreview } from '../types';
|
|
10
11
|
import getDocument from '../utils/document';
|
|
11
12
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
12
13
|
import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
|
|
@@ -18,7 +19,6 @@ import { usePrevious } from '../utils/usePrevious';
|
|
|
18
19
|
import { ViewportDetector } from '../utils/viewportDetector';
|
|
19
20
|
import { getDefaultCardDimensions } from '../utils/cardDimensions';
|
|
20
21
|
import { fireCommencedEvent, fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
|
|
21
|
-
import { isSSRPreview } from './getCardPreview';
|
|
22
22
|
import { CardView } from './cardView';
|
|
23
23
|
import { CardViews } from './cardviews';
|
|
24
24
|
import { InlinePlayerLazy } from './inlinePlayerLazy';
|
|
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
|
|
|
66
66
|
}
|
|
67
67
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
68
68
|
const packageName = "@atlaskit/media-card";
|
|
69
|
-
const packageVersion = "78.0.
|
|
69
|
+
const packageVersion = "78.0.8";
|
|
70
70
|
const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
71
71
|
packageVersion,
|
|
72
72
|
packageName,
|
|
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
|
|
|
37
37
|
} = this.state;
|
|
38
38
|
const analyticsContext = {
|
|
39
39
|
packageVersion: "@atlaskit/media-card",
|
|
40
|
-
packageName: "78.0.
|
|
40
|
+
packageName: "78.0.8",
|
|
41
41
|
componentName: 'mediaInlineCard',
|
|
42
42
|
component: 'mediaInlineCard'
|
|
43
43
|
};
|
package/dist/es2019/types.js
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
* tsconfig.entry-points.json
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
export const isSSRPreview = preview => isSSRClientPreview(preview) || isSSRServerPreview(preview) || isSSRDataPreview(preview);
|
|
7
|
+
export const isSSRServerPreview = preview => {
|
|
8
|
+
const ssrClientSources = ['ssr-server', 'cache-ssr-server'];
|
|
9
|
+
return ssrClientSources.includes(preview.source);
|
|
10
|
+
};
|
|
11
|
+
export const isSSRClientPreview = preview => {
|
|
12
|
+
const ssrClientSources = ['ssr-client', 'cache-ssr-client'];
|
|
13
|
+
return ssrClientSources.includes(preview.source);
|
|
14
|
+
};
|
|
15
|
+
export const isSSRDataPreview = preview => preview.source === 'ssr-data';
|
|
6
16
|
export let MediaCardCursor = /*#__PURE__*/function (MediaCardCursor) {
|
|
7
17
|
MediaCardCursor["Action"] = "pointer";
|
|
8
18
|
MediaCardCursor["NotReady"] = "wait";
|
|
@@ -5,7 +5,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
|
5
5
|
import { MediaCardError } from '../errors';
|
|
6
6
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
7
7
|
const packageName = "@atlaskit/media-card";
|
|
8
|
-
const packageVersion = "78.0.
|
|
8
|
+
const packageVersion = "78.0.8";
|
|
9
9
|
let concurrentExperience;
|
|
10
10
|
const getExperience = id => {
|
|
11
11
|
if (!concurrentExperience) {
|
package/dist/esm/card/card.js
CHANGED
|
@@ -9,7 +9,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
|
9
9
|
import { ExternalImageCard } from './externalImageCard';
|
|
10
10
|
import { FileCard } from './fileCard';
|
|
11
11
|
var packageName = "@atlaskit/media-card";
|
|
12
|
-
var packageVersion = "78.0.
|
|
12
|
+
var packageVersion = "78.0.8";
|
|
13
13
|
export var CardBase = function CardBase(_ref) {
|
|
14
14
|
var identifier = _ref.identifier,
|
|
15
15
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -12,6 +12,7 @@ import { MediaViewer } from '@atlaskit/media-viewer';
|
|
|
12
12
|
import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import ReactDOM from 'react-dom';
|
|
14
14
|
import { MediaCardError } from '../errors';
|
|
15
|
+
import { isSSRPreview } from '../types';
|
|
15
16
|
import getDocument from '../utils/document';
|
|
16
17
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
17
18
|
import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
|
|
@@ -23,7 +24,6 @@ import { usePrevious } from '../utils/usePrevious';
|
|
|
23
24
|
import { ViewportDetector } from '../utils/viewportDetector';
|
|
24
25
|
import { getDefaultCardDimensions } from '../utils/cardDimensions';
|
|
25
26
|
import { fireCommencedEvent, fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
|
|
26
|
-
import { isSSRPreview } from './getCardPreview';
|
|
27
27
|
import { CardView } from './cardView';
|
|
28
28
|
import { CardViews } from './cardviews';
|
|
29
29
|
import { InlinePlayerLazy } from './inlinePlayerLazy';
|
|
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
83
83
|
}(React.Component);
|
|
84
84
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
85
85
|
var packageName = "@atlaskit/media-card";
|
|
86
|
-
var packageVersion = "78.0.
|
|
86
|
+
var packageVersion = "78.0.8";
|
|
87
87
|
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
88
88
|
packageVersion: packageVersion,
|
|
89
89
|
packageName: packageName,
|
|
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
103
103
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
104
104
|
var analyticsContext = {
|
|
105
105
|
packageVersion: "@atlaskit/media-card",
|
|
106
|
-
packageName: "78.0.
|
|
106
|
+
packageName: "78.0.8",
|
|
107
107
|
componentName: 'mediaInlineCard',
|
|
108
108
|
component: 'mediaInlineCard'
|
|
109
109
|
};
|
package/dist/esm/types.js
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
* tsconfig.entry-points.json
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
export var isSSRPreview = function isSSRPreview(preview) {
|
|
7
|
+
return isSSRClientPreview(preview) || isSSRServerPreview(preview) || isSSRDataPreview(preview);
|
|
8
|
+
};
|
|
9
|
+
export var isSSRServerPreview = function isSSRServerPreview(preview) {
|
|
10
|
+
var ssrClientSources = ['ssr-server', 'cache-ssr-server'];
|
|
11
|
+
return ssrClientSources.includes(preview.source);
|
|
12
|
+
};
|
|
13
|
+
export var isSSRClientPreview = function isSSRClientPreview(preview) {
|
|
14
|
+
var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
|
|
15
|
+
return ssrClientSources.includes(preview.source);
|
|
16
|
+
};
|
|
17
|
+
export var isSSRDataPreview = function isSSRDataPreview(preview) {
|
|
18
|
+
return preview.source === 'ssr-data';
|
|
19
|
+
};
|
|
6
20
|
export var MediaCardCursor = /*#__PURE__*/function (MediaCardCursor) {
|
|
7
21
|
MediaCardCursor["Action"] = "pointer";
|
|
8
22
|
MediaCardCursor["NotReady"] = "wait";
|
|
@@ -8,7 +8,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
|
8
8
|
import { MediaCardError } from '../errors';
|
|
9
9
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
10
10
|
var packageName = "@atlaskit/media-card";
|
|
11
|
-
var packageVersion = "78.0.
|
|
11
|
+
var packageVersion = "78.0.8";
|
|
12
12
|
var concurrentExperience;
|
|
13
13
|
var getExperience = function getExperience(id) {
|
|
14
14
|
if (!concurrentExperience) {
|
package/dist/types/types.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ export interface CardPreview {
|
|
|
28
28
|
dimensions?: CardDimensions;
|
|
29
29
|
source: CardPreviewSource;
|
|
30
30
|
}
|
|
31
|
+
export declare const isSSRPreview: (preview: CardPreview) => boolean;
|
|
32
|
+
export declare const isSSRServerPreview: (preview: CardPreview) => boolean;
|
|
33
|
+
export declare const isSSRClientPreview: (preview: CardPreview) => boolean;
|
|
34
|
+
export declare const isSSRDataPreview: (preview: CardPreview) => boolean;
|
|
31
35
|
export declare enum MediaCardCursor {
|
|
32
36
|
Action = "pointer",
|
|
33
37
|
NotReady = "wait"
|
|
@@ -28,6 +28,10 @@ export interface CardPreview {
|
|
|
28
28
|
dimensions?: CardDimensions;
|
|
29
29
|
source: CardPreviewSource;
|
|
30
30
|
}
|
|
31
|
+
export declare const isSSRPreview: (preview: CardPreview) => boolean;
|
|
32
|
+
export declare const isSSRServerPreview: (preview: CardPreview) => boolean;
|
|
33
|
+
export declare const isSSRClientPreview: (preview: CardPreview) => boolean;
|
|
34
|
+
export declare const isSSRDataPreview: (preview: CardPreview) => boolean;
|
|
31
35
|
export declare enum MediaCardCursor {
|
|
32
36
|
Action = "pointer",
|
|
33
37
|
NotReady = "wait"
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCardStateFromFileState = exports.createStateUpdater = void 0;
|
|
7
|
-
var _mediaClient = require("@atlaskit/media-client");
|
|
8
|
-
var _errors = require("../errors");
|
|
9
|
-
var _getCardStatus = require("./getCardStatus");
|
|
10
|
-
var _getCardPreview = require("./getCardPreview");
|
|
11
|
-
/**
|
|
12
|
-
* From docs: "Both state and props received by the updater function are guaranteed to be up-to-date.
|
|
13
|
-
* The output of the updater is shallowly merged with state."
|
|
14
|
-
*/
|
|
15
|
-
var createStateUpdater = exports.createStateUpdater = function createStateUpdater(newState, fireErrorEvent) {
|
|
16
|
-
return function (prevState) {
|
|
17
|
-
// Only override if previous status is non-final or new status is 'complete'
|
|
18
|
-
if (!!newState.status && (0, _getCardStatus.isFinalCardStatus)(prevState.status) && newState.status !== 'complete') {
|
|
19
|
-
// Log the error if the new state is not going to store it.
|
|
20
|
-
// i.e. this is a non critical error
|
|
21
|
-
!!newState.error && fireErrorEvent(newState.error);
|
|
22
|
-
return prevState;
|
|
23
|
-
}
|
|
24
|
-
return newState;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
var getCardStateFromFileState = exports.getCardStateFromFileState = function getCardStateFromFileState(fileState, isBannedLocalPreview) {
|
|
28
|
-
var status = (0, _getCardStatus.getCardStatus)(fileState.status, (0, _getCardPreview.extractFilePreviewStatus)(fileState, isBannedLocalPreview));
|
|
29
|
-
var error = status === 'error' && (0, _mediaClient.isErrorFileState)(fileState) ? new _errors.MediaCardError('error-file-state', new Error(fileState.message)) : undefined;
|
|
30
|
-
var progress = status === 'uploading' && fileState.status === 'uploading' ? fileState.progress : 1;
|
|
31
|
-
return {
|
|
32
|
-
fileState: fileState,
|
|
33
|
-
status: status,
|
|
34
|
-
progress: progress,
|
|
35
|
-
error: error
|
|
36
|
-
};
|
|
37
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getCacheKey = exports.default = exports.CardPreviewCacheImpl = void 0;
|
|
8
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _objectURLCache = require("../../utils/objectURLCache");
|
|
12
|
-
// Dimensions are used to create a key.
|
|
13
|
-
// Cache is invalidated when different dimensions are provided.
|
|
14
|
-
|
|
15
|
-
var getCacheKey = exports.getCacheKey = function getCacheKey(id, mode) {
|
|
16
|
-
var resizeMode = mode || 'crop';
|
|
17
|
-
return [id, resizeMode].join('-');
|
|
18
|
-
};
|
|
19
|
-
var CardPreviewCacheImpl = exports.CardPreviewCacheImpl = /*#__PURE__*/(0, _createClass2.default)(function CardPreviewCacheImpl(previewCache) {
|
|
20
|
-
var _this = this;
|
|
21
|
-
(0, _classCallCheck2.default)(this, CardPreviewCacheImpl);
|
|
22
|
-
(0, _defineProperty2.default)(this, "get", function (id, mode) {
|
|
23
|
-
var cacheKey = getCacheKey(id, mode);
|
|
24
|
-
return _this.previewCache.get(cacheKey);
|
|
25
|
-
});
|
|
26
|
-
(0, _defineProperty2.default)(this, "set", function (id, mode, cardPreview) {
|
|
27
|
-
var cacheKey = getCacheKey(id, mode);
|
|
28
|
-
_this.previewCache.set(cacheKey, cardPreview);
|
|
29
|
-
});
|
|
30
|
-
(0, _defineProperty2.default)(this, "remove", function (id, mode) {
|
|
31
|
-
var cacheKey = getCacheKey(id, mode);
|
|
32
|
-
_this.previewCache.remove(cacheKey);
|
|
33
|
-
});
|
|
34
|
-
(0, _defineProperty2.default)(this, "clear", function () {
|
|
35
|
-
_this.previewCache.clear();
|
|
36
|
-
});
|
|
37
|
-
this.previewCache = previewCache;
|
|
38
|
-
}); // eslint-disable-next-line import/no-anonymous-default-export
|
|
39
|
-
var _default = exports.default = new CardPreviewCacheImpl((0, _objectURLCache.createObjectURLCache)());
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isPreviewableStatus = exports.extractFilePreviewStatus = void 0;
|
|
7
|
-
var _mediaCommon = require("@atlaskit/media-common");
|
|
8
|
-
var _mediaClient = require("@atlaskit/media-client");
|
|
9
|
-
var _helpers = require("./helpers");
|
|
10
|
-
// TODO: align these checks with helpers from Media Client
|
|
11
|
-
// https://product-fabric.atlassian.net/browse/BMPT-1300
|
|
12
|
-
var extractFilePreviewStatus = exports.extractFilePreviewStatus = function extractFilePreviewStatus(fileState, isBannedLocalPreview) {
|
|
13
|
-
var hasFilesize = 'size' in fileState && !!fileState.size;
|
|
14
|
-
var _ref = 'mediaType' in fileState && fileState || {},
|
|
15
|
-
mediaType = _ref.mediaType;
|
|
16
|
-
var _ref2 = 'mimeType' in fileState && fileState || {},
|
|
17
|
-
mimeType = _ref2.mimeType;
|
|
18
|
-
var isPreviewable = !!mediaType && (0, _mediaClient.isPreviewableType)(mediaType);
|
|
19
|
-
|
|
20
|
-
// Local preview is available only if it's supported by browser and supported by Media Card (isSupportedLocalPreview)
|
|
21
|
-
// For example, SVGs are mime type NOT supported by browser but media type supported by Media Card (image)
|
|
22
|
-
// Then, local Preview NOT available
|
|
23
|
-
var hasLocalPreview = !isBannedLocalPreview && (0, _mediaClient.isPreviewableFileState)(fileState) && (0, _helpers.isSupportedLocalPreview)(mediaType) && !!mimeType && (0, _mediaCommon.isMimeTypeSupportedByBrowser)(mimeType);
|
|
24
|
-
var hasRemotePreview = (0, _mediaClient.isImageRepresentationReady)(fileState);
|
|
25
|
-
var hasPreview = hasLocalPreview || hasRemotePreview;
|
|
26
|
-
var isSupportedByBrowser = !!mimeType && (0, _mediaCommon.isMimeTypeSupportedByBrowser)(mimeType);
|
|
27
|
-
return {
|
|
28
|
-
hasFilesize: hasFilesize,
|
|
29
|
-
isPreviewable: isPreviewable,
|
|
30
|
-
hasPreview: hasPreview,
|
|
31
|
-
isSupportedByBrowser: isSupportedByBrowser
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// CXP-2723 TODO: Review this in relation to removing status from the hook
|
|
36
|
-
var isPreviewableStatus = exports.isPreviewableStatus = function isPreviewableStatus(cardStatus, _ref3) {
|
|
37
|
-
var isPreviewable = _ref3.isPreviewable,
|
|
38
|
-
hasPreview = _ref3.hasPreview,
|
|
39
|
-
isSupportedByBrowser = _ref3.isSupportedByBrowser;
|
|
40
|
-
return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' ||
|
|
41
|
-
// For Video, we can have local or remote preview while processing.
|
|
42
|
-
// Then, we only want to show the thumbnail if the file is supported by the browser,
|
|
43
|
-
// this way we prevent playing unsupported videos that are not procesed
|
|
44
|
-
cardStatus === 'processing' && isSupportedByBrowser);
|
|
45
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.isSupportedLocalPreview = exports.getCardPreviewFromFilePreview = exports.getCardPreviewFromBackend = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _videoSnapshot = require("../../utils/videoSnapshot");
|
|
11
|
-
var _mediaCommon = require("@atlaskit/media-common");
|
|
12
|
-
var _mediaUi = require("@atlaskit/media-ui");
|
|
13
|
-
var _errors = require("../../errors");
|
|
14
|
-
/**
|
|
15
|
-
* This method tells the support for the media
|
|
16
|
-
* types covered in getCardPreviewFromFilePreview
|
|
17
|
-
*/
|
|
18
|
-
var isSupportedLocalPreview = exports.isSupportedLocalPreview = function isSupportedLocalPreview(mediaType) {
|
|
19
|
-
return mediaType === 'image' || mediaType === 'video';
|
|
20
|
-
};
|
|
21
|
-
var getImageLocalPreview = /*#__PURE__*/function () {
|
|
22
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(value) {
|
|
23
|
-
var orientation, dataURI;
|
|
24
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
25
|
-
while (1) switch (_context.prev = _context.next) {
|
|
26
|
-
case 0:
|
|
27
|
-
_context.prev = 0;
|
|
28
|
-
_context.next = 3;
|
|
29
|
-
return (0, _mediaUi.getOrientation)(value);
|
|
30
|
-
case 3:
|
|
31
|
-
orientation = _context.sent;
|
|
32
|
-
dataURI = URL.createObjectURL(value);
|
|
33
|
-
return _context.abrupt("return", {
|
|
34
|
-
dataURI: dataURI,
|
|
35
|
-
orientation: orientation,
|
|
36
|
-
source: 'local'
|
|
37
|
-
});
|
|
38
|
-
case 8:
|
|
39
|
-
_context.prev = 8;
|
|
40
|
-
_context.t0 = _context["catch"](0);
|
|
41
|
-
throw new _errors.LocalPreviewError('local-preview-image', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
42
|
-
case 11:
|
|
43
|
-
case "end":
|
|
44
|
-
return _context.stop();
|
|
45
|
-
}
|
|
46
|
-
}, _callee, null, [[0, 8]]);
|
|
47
|
-
}));
|
|
48
|
-
return function getImageLocalPreview(_x) {
|
|
49
|
-
return _ref.apply(this, arguments);
|
|
50
|
-
};
|
|
51
|
-
}();
|
|
52
|
-
var getVideoLocalPreview = /*#__PURE__*/function () {
|
|
53
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(value) {
|
|
54
|
-
var dataURI;
|
|
55
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
56
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
57
|
-
case 0:
|
|
58
|
-
_context2.prev = 0;
|
|
59
|
-
_context2.next = 3;
|
|
60
|
-
return (0, _videoSnapshot.takeSnapshot)(value);
|
|
61
|
-
case 3:
|
|
62
|
-
dataURI = _context2.sent;
|
|
63
|
-
return _context2.abrupt("return", {
|
|
64
|
-
dataURI: dataURI,
|
|
65
|
-
orientation: 1,
|
|
66
|
-
source: 'local'
|
|
67
|
-
});
|
|
68
|
-
case 7:
|
|
69
|
-
_context2.prev = 7;
|
|
70
|
-
_context2.t0 = _context2["catch"](0);
|
|
71
|
-
throw new _errors.LocalPreviewError('local-preview-video', _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
72
|
-
case 10:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context2.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee2, null, [[0, 7]]);
|
|
77
|
-
}));
|
|
78
|
-
return function getVideoLocalPreview(_x2) {
|
|
79
|
-
return _ref2.apply(this, arguments);
|
|
80
|
-
};
|
|
81
|
-
}();
|
|
82
|
-
var getCardPreviewFromFilePreview = exports.getCardPreviewFromFilePreview = /*#__PURE__*/function () {
|
|
83
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(filePreview) {
|
|
84
|
-
var value, resolvedFilePreview, _value, type, mediaType;
|
|
85
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
86
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
87
|
-
case 0:
|
|
88
|
-
_context3.prev = 0;
|
|
89
|
-
_context3.next = 3;
|
|
90
|
-
return filePreview;
|
|
91
|
-
case 3:
|
|
92
|
-
resolvedFilePreview = _context3.sent;
|
|
93
|
-
value = resolvedFilePreview.value;
|
|
94
|
-
_context3.next = 10;
|
|
95
|
-
break;
|
|
96
|
-
case 7:
|
|
97
|
-
_context3.prev = 7;
|
|
98
|
-
_context3.t0 = _context3["catch"](0);
|
|
99
|
-
throw new _errors.LocalPreviewError('local-preview-rejected', _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
100
|
-
case 10:
|
|
101
|
-
if (!(typeof value === 'string')) {
|
|
102
|
-
_context3.next = 14;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
return _context3.abrupt("return", {
|
|
106
|
-
dataURI: value,
|
|
107
|
-
orientation: 1,
|
|
108
|
-
source: 'local'
|
|
109
|
-
});
|
|
110
|
-
case 14:
|
|
111
|
-
if (!(value instanceof Blob)) {
|
|
112
|
-
_context3.next = 22;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
_value = value, type = _value.type;
|
|
116
|
-
mediaType = (0, _mediaCommon.getMediaTypeFromMimeType)(type);
|
|
117
|
-
_context3.t1 = mediaType;
|
|
118
|
-
_context3.next = _context3.t1 === 'image' ? 20 : _context3.t1 === 'video' ? 21 : 22;
|
|
119
|
-
break;
|
|
120
|
-
case 20:
|
|
121
|
-
return _context3.abrupt("return", getImageLocalPreview(value));
|
|
122
|
-
case 21:
|
|
123
|
-
return _context3.abrupt("return", getVideoLocalPreview(value));
|
|
124
|
-
case 22:
|
|
125
|
-
throw new _errors.LocalPreviewError('local-preview-unsupported');
|
|
126
|
-
case 23:
|
|
127
|
-
case "end":
|
|
128
|
-
return _context3.stop();
|
|
129
|
-
}
|
|
130
|
-
}, _callee3, null, [[0, 7]]);
|
|
131
|
-
}));
|
|
132
|
-
return function getCardPreviewFromFilePreview(_x3) {
|
|
133
|
-
return _ref3.apply(this, arguments);
|
|
134
|
-
};
|
|
135
|
-
}();
|
|
136
|
-
var getCardPreviewFromBackend = exports.getCardPreviewFromBackend = /*#__PURE__*/function () {
|
|
137
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(mediaClient, id, params, traceContext) {
|
|
138
|
-
var blob;
|
|
139
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
140
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
141
|
-
case 0:
|
|
142
|
-
_context4.prev = 0;
|
|
143
|
-
_context4.next = 3;
|
|
144
|
-
return mediaClient.getImage(id, params, undefined, undefined, traceContext);
|
|
145
|
-
case 3:
|
|
146
|
-
blob = _context4.sent;
|
|
147
|
-
return _context4.abrupt("return", {
|
|
148
|
-
dataURI: URL.createObjectURL(blob),
|
|
149
|
-
orientation: 1,
|
|
150
|
-
source: 'remote'
|
|
151
|
-
});
|
|
152
|
-
case 7:
|
|
153
|
-
_context4.prev = 7;
|
|
154
|
-
_context4.t0 = _context4["catch"](0);
|
|
155
|
-
throw new _errors.RemotePreviewError('remote-preview-fetch', _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
156
|
-
case 10:
|
|
157
|
-
case "end":
|
|
158
|
-
return _context4.stop();
|
|
159
|
-
}
|
|
160
|
-
}, _callee4, null, [[0, 7]]);
|
|
161
|
-
}));
|
|
162
|
-
return function getCardPreviewFromBackend(_x4, _x5, _x6, _x7) {
|
|
163
|
-
return _ref4.apply(this, arguments);
|
|
164
|
-
};
|
|
165
|
-
}();
|