@atlaskit/media-card 77.12.2 → 77.12.3
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 +7 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/v2/cardV2.js +1 -1
- package/dist/cjs/card/v2/fileCard.js +18 -4
- package/dist/cjs/card/v2/svgView/errors.js +16 -0
- package/dist/cjs/card/v2/svgView/svgView.js +11 -1
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/utils/analytics/analytics.js +3 -0
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/v2/cardV2.js +1 -1
- package/dist/es2019/card/v2/fileCard.js +18 -4
- package/dist/es2019/card/v2/svgView/errors.js +10 -0
- package/dist/es2019/card/v2/svgView/svgView.js +11 -1
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/utils/analytics/analytics.js +3 -0
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/v2/cardV2.js +1 -1
- package/dist/esm/card/v2/fileCard.js +18 -4
- package/dist/esm/card/v2/svgView/errors.js +10 -0
- package/dist/esm/card/v2/svgView/svgView.js +11 -1
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/analytics/analytics.js +3 -0
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/v2/svgView/errors.d.ts +3 -0
- package/dist/types/card/v2/svgView/svgView.d.ts +4 -3
- package/dist/types/errors.d.ts +2 -1
- package/dist/types/utils/analytics/analytics.d.ts +2 -1
- package/dist/types-ts4.5/card/v2/svgView/errors.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/svgView/svgView.d.ts +4 -3
- package/dist/types-ts4.5/errors.d.ts +2 -1
- package/dist/types-ts4.5/utils/analytics/analytics.d.ts +2 -1
- package/example-helpers/svg-helpers/index.ts +1 -1
- package/example-helpers/svg-helpers/mediaApiTweaks.ts +64 -0
- package/package.json +5 -4
- package/example-helpers/svg-helpers/delayApiResponses.ts +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 77.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`cd38da52e02b7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cd38da52e02b7) -
|
|
8
|
+
Media Card handles SVG errors and logs extra info for monitoring
|
|
9
|
+
|
|
3
10
|
## 77.12.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -50,7 +50,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
50
50
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
51
51
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
52
52
|
var packageName = "@atlaskit/media-card";
|
|
53
|
-
var packageVersion = "77.12.
|
|
53
|
+
var packageVersion = "77.12.3";
|
|
54
54
|
var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
|
|
55
55
|
(0, _inherits2.default)(CardBase, _Component);
|
|
56
56
|
var _super = _createSuper(CardBase);
|
|
@@ -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 = "77.12.
|
|
93
|
+
var packageVersion = "77.12.3";
|
|
94
94
|
var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
95
95
|
packageVersion: packageVersion,
|
|
96
96
|
packageName: packageName,
|
|
@@ -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 = "77.12.
|
|
19
|
+
var packageVersion = "77.12.3";
|
|
20
20
|
var CardV2Base = exports.CardV2Base = function CardV2Base(_ref) {
|
|
21
21
|
var identifier = _ref.identifier,
|
|
22
22
|
otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
@@ -321,10 +321,24 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
321
321
|
//---------------------- Callbacks & Handlers -------------------//
|
|
322
322
|
//----------------------------------------------------------------//
|
|
323
323
|
|
|
324
|
+
var onSvgError = function onSvgError(error) {
|
|
325
|
+
setError(error);
|
|
326
|
+
setStatus('error');
|
|
327
|
+
setShouldRenderSVG(false);
|
|
328
|
+
};
|
|
324
329
|
var onImageError = function onImageError(newCardPreview) {
|
|
330
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
325
333
|
onImageErrorBase(newCardPreview);
|
|
326
334
|
};
|
|
335
|
+
var onSvgLoad = function onSvgLoad() {
|
|
336
|
+
setPreviewDidRender(true);
|
|
337
|
+
};
|
|
327
338
|
var onImageLoad = function onImageLoad(newCardPreview) {
|
|
339
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
328
342
|
onImageLoadBase(newCardPreview);
|
|
329
343
|
setPreviewDidRender(true);
|
|
330
344
|
};
|
|
@@ -449,7 +463,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
449
463
|
//----------------------------------------------------------------//
|
|
450
464
|
|
|
451
465
|
(0, _react.useEffect)(function () {
|
|
452
|
-
if ((0, _platformFeatureFlags.getBooleanFF)('platform.media-card-svg-rendering_6tdbv') &&
|
|
466
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.media-card-svg-rendering_6tdbv') && finalStatus !== 'error' &&
|
|
453
467
|
/**
|
|
454
468
|
* We need to check that the card is visible before switching to SVG
|
|
455
469
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
@@ -459,7 +473,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
459
473
|
) {
|
|
460
474
|
setShouldRenderSVG(true);
|
|
461
475
|
}
|
|
462
|
-
}, [isCardVisible, disableOverlay, metadata]);
|
|
476
|
+
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
463
477
|
|
|
464
478
|
//----------------------------------------------------------------//
|
|
465
479
|
//----------------- fireScreenEvent ------------------------------//
|
|
@@ -644,8 +658,8 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
644
658
|
onClick: onCardViewClick,
|
|
645
659
|
onMouseEnter: onImageMouseEnter,
|
|
646
660
|
progress: uploadProgressRef.current,
|
|
647
|
-
|
|
648
|
-
|
|
661
|
+
onError: onSvgError,
|
|
662
|
+
onLoad: onSvgLoad,
|
|
649
663
|
mediaCardCursor: mediaCardCursor,
|
|
650
664
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
651
665
|
openMediaViewerButtonRef: mediaViewerButtonRef
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getErrorReason = void 0;
|
|
7
|
+
var getErrorReason = exports.getErrorReason = function getErrorReason(svgReason) {
|
|
8
|
+
switch (svgReason) {
|
|
9
|
+
case 'img-error':
|
|
10
|
+
return 'svg-img-error';
|
|
11
|
+
case 'binary-fetch':
|
|
12
|
+
return 'svg-binary-fetch';
|
|
13
|
+
default:
|
|
14
|
+
return 'svg-unknown-error';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -20,6 +20,8 @@ var _useBreakpoint = require("../../useBreakpoint");
|
|
|
20
20
|
var _mediaSvg = _interopRequireDefault(require("@atlaskit/media-svg"));
|
|
21
21
|
var _helpers = require("./helpers");
|
|
22
22
|
var _openMediaViewerButton = _interopRequireDefault(require("../../ui/openMediaViewerButton/openMediaViewerButton"));
|
|
23
|
+
var _errors = require("../../../errors");
|
|
24
|
+
var _errors2 = require("./errors");
|
|
23
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
26
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
27
|
/** @jsx jsx */
|
|
@@ -54,7 +56,9 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
54
56
|
resizeMode = _ref.resizeMode,
|
|
55
57
|
shouldOpenMediaViewer = _ref.shouldOpenMediaViewer,
|
|
56
58
|
_ref$openMediaViewerB = _ref.openMediaViewerButtonRef,
|
|
57
|
-
openMediaViewerButtonRef = _ref$openMediaViewerB === void 0 ? null : _ref$openMediaViewerB
|
|
59
|
+
openMediaViewerButtonRef = _ref$openMediaViewerB === void 0 ? null : _ref$openMediaViewerB,
|
|
60
|
+
onLoad = _ref.onLoad,
|
|
61
|
+
onError = _ref.onError;
|
|
58
62
|
var _useState = (0, _react2.useState)(false),
|
|
59
63
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
60
64
|
didSvgRender = _useState2[0],
|
|
@@ -72,6 +76,11 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
72
76
|
var onSvgLoad = function onSvgLoad(evt) {
|
|
73
77
|
setSvgDimensions((0, _helpers.calculateSvgDimensions)(evt.currentTarget, resizeMode));
|
|
74
78
|
setDidSvgRender(true);
|
|
79
|
+
onLoad();
|
|
80
|
+
};
|
|
81
|
+
var onSvgError = function onSvgError(err) {
|
|
82
|
+
var error = new _errors.MediaCardError((0, _errors2.getErrorReason)(err.primaryReason), err.secondaryError);
|
|
83
|
+
onError(error);
|
|
75
84
|
};
|
|
76
85
|
var onPreviewLoad = function onPreviewLoad() {
|
|
77
86
|
setDidPreviewRender(true);
|
|
@@ -107,6 +116,7 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
107
116
|
identifier: identifier,
|
|
108
117
|
dimensions: svgDimensions,
|
|
109
118
|
onLoad: onSvgLoad,
|
|
119
|
+
onError: onSvgError,
|
|
110
120
|
style: {
|
|
111
121
|
visibility: didSvgRender ? 'visible' : 'hidden',
|
|
112
122
|
objectFit: convertResizeMode(resizeMode)
|
|
@@ -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: "77.12.
|
|
122
|
+
packageName: "77.12.3",
|
|
123
123
|
componentName: 'mediaInlineCard',
|
|
124
124
|
component: 'mediaInlineCard'
|
|
125
125
|
};
|
|
@@ -55,6 +55,7 @@ var getRenderSucceededEventPayload = exports.getRenderSucceededEventPayload = fu
|
|
|
55
55
|
action: 'succeeded',
|
|
56
56
|
actionSubject: 'mediaCardRender',
|
|
57
57
|
attributes: {
|
|
58
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
58
59
|
fileAttributes: fileAttributes,
|
|
59
60
|
performanceAttributes: performanceAttributes,
|
|
60
61
|
status: 'success',
|
|
@@ -155,6 +156,7 @@ var getRenderErrorEventPayload = exports.getRenderErrorEventPayload = function g
|
|
|
155
156
|
action: 'failed',
|
|
156
157
|
actionSubject: 'mediaCardRender',
|
|
157
158
|
attributes: _objectSpread(_objectSpread({
|
|
159
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
158
160
|
fileAttributes: fileAttributes,
|
|
159
161
|
performanceAttributes: performanceAttributes,
|
|
160
162
|
status: 'fail'
|
|
@@ -187,6 +189,7 @@ var getRenderFailedFileStatusPayload = exports.getRenderFailedFileStatusPayload
|
|
|
187
189
|
action: 'failed',
|
|
188
190
|
actionSubject: 'mediaCardRender',
|
|
189
191
|
attributes: {
|
|
192
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
190
193
|
fileAttributes: fileAttributes,
|
|
191
194
|
performanceAttributes: performanceAttributes,
|
|
192
195
|
status: 'fail',
|
|
@@ -14,7 +14,7 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
var packageName = "@atlaskit/media-card";
|
|
17
|
-
var packageVersion = "77.12.
|
|
17
|
+
var packageVersion = "77.12.3";
|
|
18
18
|
var concurrentExperience;
|
|
19
19
|
var getExperience = function getExperience(id) {
|
|
20
20
|
if (!concurrentExperience) {
|
package/dist/es2019/card/card.js
CHANGED
|
@@ -28,7 +28,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
|
|
|
28
28
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
29
29
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
30
30
|
const packageName = "@atlaskit/media-card";
|
|
31
|
-
const packageVersion = "77.12.
|
|
31
|
+
const packageVersion = "77.12.3";
|
|
32
32
|
export class CardBase extends Component {
|
|
33
33
|
constructor(props) {
|
|
34
34
|
super(props);
|
|
@@ -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 = "77.12.
|
|
69
|
+
const packageVersion = "77.12.3";
|
|
70
70
|
const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
71
71
|
packageVersion,
|
|
72
72
|
packageName,
|
|
@@ -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 = "77.12.
|
|
10
|
+
const packageVersion = "77.12.3";
|
|
11
11
|
export const CardV2Base = ({
|
|
12
12
|
identifier,
|
|
13
13
|
...otherProps
|
|
@@ -271,10 +271,24 @@ export const FileCard = ({
|
|
|
271
271
|
//---------------------- Callbacks & Handlers -------------------//
|
|
272
272
|
//----------------------------------------------------------------//
|
|
273
273
|
|
|
274
|
+
const onSvgError = error => {
|
|
275
|
+
setError(error);
|
|
276
|
+
setStatus('error');
|
|
277
|
+
setShouldRenderSVG(false);
|
|
278
|
+
};
|
|
274
279
|
const onImageError = newCardPreview => {
|
|
280
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
275
283
|
onImageErrorBase(newCardPreview);
|
|
276
284
|
};
|
|
285
|
+
const onSvgLoad = () => {
|
|
286
|
+
setPreviewDidRender(true);
|
|
287
|
+
};
|
|
277
288
|
const onImageLoad = newCardPreview => {
|
|
289
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
278
292
|
onImageLoadBase(newCardPreview);
|
|
279
293
|
setPreviewDidRender(true);
|
|
280
294
|
};
|
|
@@ -400,7 +414,7 @@ export const FileCard = ({
|
|
|
400
414
|
//----------------------------------------------------------------//
|
|
401
415
|
|
|
402
416
|
useEffect(() => {
|
|
403
|
-
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') &&
|
|
417
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && finalStatus !== 'error' &&
|
|
404
418
|
/**
|
|
405
419
|
* We need to check that the card is visible before switching to SVG
|
|
406
420
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
@@ -410,7 +424,7 @@ export const FileCard = ({
|
|
|
410
424
|
) {
|
|
411
425
|
setShouldRenderSVG(true);
|
|
412
426
|
}
|
|
413
|
-
}, [isCardVisible, disableOverlay, metadata]);
|
|
427
|
+
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
414
428
|
|
|
415
429
|
//----------------------------------------------------------------//
|
|
416
430
|
//----------------- fireScreenEvent ------------------------------//
|
|
@@ -595,8 +609,8 @@ export const FileCard = ({
|
|
|
595
609
|
onClick: onCardViewClick,
|
|
596
610
|
onMouseEnter: onImageMouseEnter,
|
|
597
611
|
progress: uploadProgressRef.current,
|
|
598
|
-
|
|
599
|
-
|
|
612
|
+
onError: onSvgError,
|
|
613
|
+
onLoad: onSvgLoad,
|
|
600
614
|
mediaCardCursor: mediaCardCursor,
|
|
601
615
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
602
616
|
openMediaViewerButtonRef: mediaViewerButtonRef
|
|
@@ -13,6 +13,8 @@ import { useBreakpoint } from '../../useBreakpoint';
|
|
|
13
13
|
import MediaSvg from '@atlaskit/media-svg';
|
|
14
14
|
import { calculateSvgDimensions } from './helpers';
|
|
15
15
|
import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
|
|
16
|
+
import { MediaCardError } from '../../../errors';
|
|
17
|
+
import { getErrorReason } from './errors';
|
|
16
18
|
export const convertResizeMode = resizeMode => {
|
|
17
19
|
switch (resizeMode) {
|
|
18
20
|
case 'crop':
|
|
@@ -41,7 +43,9 @@ export const SvgViewBase = ({
|
|
|
41
43
|
alt,
|
|
42
44
|
resizeMode,
|
|
43
45
|
shouldOpenMediaViewer,
|
|
44
|
-
openMediaViewerButtonRef = null
|
|
46
|
+
openMediaViewerButtonRef = null,
|
|
47
|
+
onLoad,
|
|
48
|
+
onError
|
|
45
49
|
}) => {
|
|
46
50
|
const [didSvgRender, setDidSvgRender] = useState(false);
|
|
47
51
|
const [didPreviewRender, setDidPreviewRender] = useState(false);
|
|
@@ -51,6 +55,11 @@ export const SvgViewBase = ({
|
|
|
51
55
|
const onSvgLoad = evt => {
|
|
52
56
|
setSvgDimensions(calculateSvgDimensions(evt.currentTarget, resizeMode));
|
|
53
57
|
setDidSvgRender(true);
|
|
58
|
+
onLoad();
|
|
59
|
+
};
|
|
60
|
+
const onSvgError = err => {
|
|
61
|
+
const error = new MediaCardError(getErrorReason(err.primaryReason), err.secondaryError);
|
|
62
|
+
onError(error);
|
|
54
63
|
};
|
|
55
64
|
const onPreviewLoad = () => {
|
|
56
65
|
setDidPreviewRender(true);
|
|
@@ -86,6 +95,7 @@ export const SvgViewBase = ({
|
|
|
86
95
|
identifier: identifier,
|
|
87
96
|
dimensions: svgDimensions,
|
|
88
97
|
onLoad: onSvgLoad,
|
|
98
|
+
onError: onSvgError,
|
|
89
99
|
style: {
|
|
90
100
|
visibility: didSvgRender ? 'visible' : 'hidden',
|
|
91
101
|
objectFit: convertResizeMode(resizeMode)
|
|
@@ -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: "77.12.
|
|
40
|
+
packageName: "77.12.3",
|
|
41
41
|
componentName: 'mediaInlineCard',
|
|
42
42
|
component: 'mediaInlineCard'
|
|
43
43
|
};
|
|
@@ -38,6 +38,7 @@ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttrib
|
|
|
38
38
|
action: 'succeeded',
|
|
39
39
|
actionSubject: 'mediaCardRender',
|
|
40
40
|
attributes: {
|
|
41
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
41
42
|
fileAttributes,
|
|
42
43
|
performanceAttributes,
|
|
43
44
|
status: 'success',
|
|
@@ -130,6 +131,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
130
131
|
action: 'failed',
|
|
131
132
|
actionSubject: 'mediaCardRender',
|
|
132
133
|
attributes: {
|
|
134
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
133
135
|
fileAttributes,
|
|
134
136
|
performanceAttributes,
|
|
135
137
|
status: 'fail',
|
|
@@ -158,6 +160,7 @@ export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttr
|
|
|
158
160
|
action: 'failed',
|
|
159
161
|
actionSubject: 'mediaCardRender',
|
|
160
162
|
attributes: {
|
|
163
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
161
164
|
fileAttributes,
|
|
162
165
|
performanceAttributes,
|
|
163
166
|
status: 'fail',
|
|
@@ -4,7 +4,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
|
4
4
|
import { MediaCardError } from '../errors';
|
|
5
5
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
6
6
|
const packageName = "@atlaskit/media-card";
|
|
7
|
-
const packageVersion = "77.12.
|
|
7
|
+
const packageVersion = "77.12.3";
|
|
8
8
|
let concurrentExperience;
|
|
9
9
|
const getExperience = id => {
|
|
10
10
|
if (!concurrentExperience) {
|
package/dist/esm/card/card.js
CHANGED
|
@@ -41,7 +41,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
|
|
|
41
41
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
42
42
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
43
43
|
var packageName = "@atlaskit/media-card";
|
|
44
|
-
var packageVersion = "77.12.
|
|
44
|
+
var packageVersion = "77.12.3";
|
|
45
45
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
46
46
|
_inherits(CardBase, _Component);
|
|
47
47
|
var _super = _createSuper(CardBase);
|
|
@@ -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 = "77.12.
|
|
86
|
+
var packageVersion = "77.12.3";
|
|
87
87
|
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
88
88
|
packageVersion: packageVersion,
|
|
89
89
|
packageName: packageName,
|
|
@@ -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 = "77.12.
|
|
12
|
+
var packageVersion = "77.12.3";
|
|
13
13
|
export var CardV2Base = function CardV2Base(_ref) {
|
|
14
14
|
var identifier = _ref.identifier,
|
|
15
15
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -312,10 +312,24 @@ export var FileCard = function FileCard(_ref) {
|
|
|
312
312
|
//---------------------- Callbacks & Handlers -------------------//
|
|
313
313
|
//----------------------------------------------------------------//
|
|
314
314
|
|
|
315
|
+
var onSvgError = function onSvgError(error) {
|
|
316
|
+
setError(error);
|
|
317
|
+
setStatus('error');
|
|
318
|
+
setShouldRenderSVG(false);
|
|
319
|
+
};
|
|
315
320
|
var onImageError = function onImageError(newCardPreview) {
|
|
321
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
316
324
|
onImageErrorBase(newCardPreview);
|
|
317
325
|
};
|
|
326
|
+
var onSvgLoad = function onSvgLoad() {
|
|
327
|
+
setPreviewDidRender(true);
|
|
328
|
+
};
|
|
318
329
|
var onImageLoad = function onImageLoad(newCardPreview) {
|
|
330
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && metadata.mimeType === 'image/svg+xml') {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
319
333
|
onImageLoadBase(newCardPreview);
|
|
320
334
|
setPreviewDidRender(true);
|
|
321
335
|
};
|
|
@@ -440,7 +454,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
440
454
|
//----------------------------------------------------------------//
|
|
441
455
|
|
|
442
456
|
useEffect(function () {
|
|
443
|
-
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') &&
|
|
457
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') && finalStatus !== 'error' &&
|
|
444
458
|
/**
|
|
445
459
|
* We need to check that the card is visible before switching to SVG
|
|
446
460
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
@@ -450,7 +464,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
450
464
|
) {
|
|
451
465
|
setShouldRenderSVG(true);
|
|
452
466
|
}
|
|
453
|
-
}, [isCardVisible, disableOverlay, metadata]);
|
|
467
|
+
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
454
468
|
|
|
455
469
|
//----------------------------------------------------------------//
|
|
456
470
|
//----------------- fireScreenEvent ------------------------------//
|
|
@@ -635,8 +649,8 @@ export var FileCard = function FileCard(_ref) {
|
|
|
635
649
|
onClick: onCardViewClick,
|
|
636
650
|
onMouseEnter: onImageMouseEnter,
|
|
637
651
|
progress: uploadProgressRef.current,
|
|
638
|
-
|
|
639
|
-
|
|
652
|
+
onError: onSvgError,
|
|
653
|
+
onLoad: onSvgLoad,
|
|
640
654
|
mediaCardCursor: mediaCardCursor,
|
|
641
655
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
642
656
|
openMediaViewerButtonRef: mediaViewerButtonRef
|
|
@@ -14,6 +14,8 @@ import { useBreakpoint } from '../../useBreakpoint';
|
|
|
14
14
|
import MediaSvg from '@atlaskit/media-svg';
|
|
15
15
|
import { calculateSvgDimensions } from './helpers';
|
|
16
16
|
import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
|
|
17
|
+
import { MediaCardError } from '../../../errors';
|
|
18
|
+
import { getErrorReason } from './errors';
|
|
17
19
|
export var convertResizeMode = function convertResizeMode(resizeMode) {
|
|
18
20
|
switch (resizeMode) {
|
|
19
21
|
case 'crop':
|
|
@@ -43,7 +45,9 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
43
45
|
resizeMode = _ref.resizeMode,
|
|
44
46
|
shouldOpenMediaViewer = _ref.shouldOpenMediaViewer,
|
|
45
47
|
_ref$openMediaViewerB = _ref.openMediaViewerButtonRef,
|
|
46
|
-
openMediaViewerButtonRef = _ref$openMediaViewerB === void 0 ? null : _ref$openMediaViewerB
|
|
48
|
+
openMediaViewerButtonRef = _ref$openMediaViewerB === void 0 ? null : _ref$openMediaViewerB,
|
|
49
|
+
onLoad = _ref.onLoad,
|
|
50
|
+
onError = _ref.onError;
|
|
47
51
|
var _useState = useState(false),
|
|
48
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
53
|
didSvgRender = _useState2[0],
|
|
@@ -61,6 +65,11 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
61
65
|
var onSvgLoad = function onSvgLoad(evt) {
|
|
62
66
|
setSvgDimensions(calculateSvgDimensions(evt.currentTarget, resizeMode));
|
|
63
67
|
setDidSvgRender(true);
|
|
68
|
+
onLoad();
|
|
69
|
+
};
|
|
70
|
+
var onSvgError = function onSvgError(err) {
|
|
71
|
+
var error = new MediaCardError(getErrorReason(err.primaryReason), err.secondaryError);
|
|
72
|
+
onError(error);
|
|
64
73
|
};
|
|
65
74
|
var onPreviewLoad = function onPreviewLoad() {
|
|
66
75
|
setDidPreviewRender(true);
|
|
@@ -96,6 +105,7 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
96
105
|
identifier: identifier,
|
|
97
106
|
dimensions: svgDimensions,
|
|
98
107
|
onLoad: onSvgLoad,
|
|
108
|
+
onError: onSvgError,
|
|
99
109
|
style: {
|
|
100
110
|
visibility: didSvgRender ? 'visible' : 'hidden',
|
|
101
111
|
objectFit: convertResizeMode(resizeMode)
|
|
@@ -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: "77.12.
|
|
106
|
+
packageName: "77.12.3",
|
|
107
107
|
componentName: 'mediaInlineCard',
|
|
108
108
|
component: 'mediaInlineCard'
|
|
109
109
|
};
|
|
@@ -46,6 +46,7 @@ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayl
|
|
|
46
46
|
action: 'succeeded',
|
|
47
47
|
actionSubject: 'mediaCardRender',
|
|
48
48
|
attributes: {
|
|
49
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
49
50
|
fileAttributes: fileAttributes,
|
|
50
51
|
performanceAttributes: performanceAttributes,
|
|
51
52
|
status: 'success',
|
|
@@ -146,6 +147,7 @@ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(file
|
|
|
146
147
|
action: 'failed',
|
|
147
148
|
actionSubject: 'mediaCardRender',
|
|
148
149
|
attributes: _objectSpread(_objectSpread({
|
|
150
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
149
151
|
fileAttributes: fileAttributes,
|
|
150
152
|
performanceAttributes: performanceAttributes,
|
|
151
153
|
status: 'fail'
|
|
@@ -178,6 +180,7 @@ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatus
|
|
|
178
180
|
action: 'failed',
|
|
179
181
|
actionSubject: 'mediaCardRender',
|
|
180
182
|
attributes: {
|
|
183
|
+
fileMimetype: fileAttributes.fileMimetype,
|
|
181
184
|
fileAttributes: fileAttributes,
|
|
182
185
|
performanceAttributes: performanceAttributes,
|
|
183
186
|
status: 'fail',
|
|
@@ -7,7 +7,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
|
7
7
|
import { MediaCardError } from '../errors';
|
|
8
8
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
9
9
|
var packageName = "@atlaskit/media-card";
|
|
10
|
-
var packageVersion = "77.12.
|
|
10
|
+
var packageVersion = "77.12.3";
|
|
11
11
|
var concurrentExperience;
|
|
12
12
|
var getExperience = function getExperience(id) {
|
|
13
13
|
if (!concurrentExperience) {
|
|
@@ -5,6 +5,7 @@ import { type FileIdentifier, type ImageResizeMode } from '@atlaskit/media-clien
|
|
|
5
5
|
import { type WithAnalyticsEventsProps, type UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
6
|
import { type CardStatus, type MediaCardCursor, type CardDimensions } from '../../../types';
|
|
7
7
|
import { type MediaFilePreview } from '@atlaskit/media-file-preview';
|
|
8
|
+
import { MediaCardError } from '../../../errors';
|
|
8
9
|
export declare const convertResizeMode: (resizeMode?: ImageResizeMode) => React.CSSProperties['objectFit'];
|
|
9
10
|
export type OnClickFn = (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
|
|
10
11
|
export interface SvgViewBaseOwnProps {
|
|
@@ -21,11 +22,11 @@ export interface SvgViewBaseOwnProps {
|
|
|
21
22
|
readonly progress?: number;
|
|
22
23
|
readonly alt?: string;
|
|
23
24
|
readonly resizeMode?: ImageResizeMode;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
25
|
+
readonly onLoad: () => void;
|
|
26
|
+
readonly onError: (error: MediaCardError) => void;
|
|
26
27
|
readonly shouldOpenMediaViewer?: boolean;
|
|
27
28
|
readonly openMediaViewerButtonRef?: React.Ref<HTMLButtonElement>;
|
|
28
29
|
}
|
|
29
30
|
export type SvgViewProps = SvgViewBaseOwnProps & WithAnalyticsEventsProps;
|
|
30
|
-
export declare const SvgViewBase: ({ identifier, dimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, }: SvgViewProps) => jsx.JSX.Element;
|
|
31
|
+
export declare const SvgViewBase: ({ identifier, dimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, onLoad, onError, }: SvgViewProps) => jsx.JSX.Element;
|
|
31
32
|
export declare const SvgView: React.ForwardRefExoticComponent<Omit<SvgViewBaseOwnProps & WithAnalyticsEventsProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -5,11 +5,12 @@ import { MediaFileStateError } from '@atlaskit/media-client-react';
|
|
|
5
5
|
* Primary reason is logged through Data Portal.
|
|
6
6
|
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
7
7
|
*/
|
|
8
|
-
export type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
8
|
+
export type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | SvgPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
9
9
|
export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
|
|
10
10
|
export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
|
|
11
11
|
export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
|
|
12
12
|
export type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
|
|
13
|
+
export type SvgPrimaryReason = 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error';
|
|
13
14
|
export declare function isMediaFileStateError(err: Error): err is MediaFileStateError;
|
|
14
15
|
export declare function getFileStateErrorReason(err: MediaFileStateError): MediaClientErrorReason | 'unknown';
|
|
15
16
|
export declare function isPollingError(err?: Error): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ErrorInfo } from 'react';
|
|
1
2
|
import { type FileDetails, type FileStatus, type MediaClientErrorReason, type RequestMetadata } from '@atlaskit/media-client';
|
|
2
3
|
import { type FileAttributes, type PerformanceAttributes, type OperationalEventPayload, type UIEventPayload, type WithFileAttributes, type WithPerformanceAttributes, type SuccessAttributes, type FailureAttributes, type ScreenEventPayload, type ScreenAttributes, type MediaTraceContext, type WithTraceContext } from '@atlaskit/media-common/analytics';
|
|
3
4
|
import { type CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
@@ -52,7 +53,7 @@ export type ErrorBoundaryErrorInfo = {
|
|
|
52
53
|
};
|
|
53
54
|
export type AnalyticsErrorBoundaryAttributes = {
|
|
54
55
|
error?: Error | string;
|
|
55
|
-
info?:
|
|
56
|
+
info?: ErrorInfo;
|
|
56
57
|
browserInfo: string;
|
|
57
58
|
failReason: string;
|
|
58
59
|
};
|
|
@@ -5,6 +5,7 @@ import { type FileIdentifier, type ImageResizeMode } from '@atlaskit/media-clien
|
|
|
5
5
|
import { type WithAnalyticsEventsProps, type UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
6
|
import { type CardStatus, type MediaCardCursor, type CardDimensions } from '../../../types';
|
|
7
7
|
import { type MediaFilePreview } from '@atlaskit/media-file-preview';
|
|
8
|
+
import { MediaCardError } from '../../../errors';
|
|
8
9
|
export declare const convertResizeMode: (resizeMode?: ImageResizeMode) => React.CSSProperties['objectFit'];
|
|
9
10
|
export type OnClickFn = (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
|
|
10
11
|
export interface SvgViewBaseOwnProps {
|
|
@@ -21,11 +22,11 @@ export interface SvgViewBaseOwnProps {
|
|
|
21
22
|
readonly progress?: number;
|
|
22
23
|
readonly alt?: string;
|
|
23
24
|
readonly resizeMode?: ImageResizeMode;
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
25
|
+
readonly onLoad: () => void;
|
|
26
|
+
readonly onError: (error: MediaCardError) => void;
|
|
26
27
|
readonly shouldOpenMediaViewer?: boolean;
|
|
27
28
|
readonly openMediaViewerButtonRef?: React.Ref<HTMLButtonElement>;
|
|
28
29
|
}
|
|
29
30
|
export type SvgViewProps = SvgViewBaseOwnProps & WithAnalyticsEventsProps;
|
|
30
|
-
export declare const SvgViewBase: ({ identifier, dimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, }: SvgViewProps) => jsx.JSX.Element;
|
|
31
|
+
export declare const SvgViewBase: ({ identifier, dimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, onLoad, onError, }: SvgViewProps) => jsx.JSX.Element;
|
|
31
32
|
export declare const SvgView: React.ForwardRefExoticComponent<Omit<SvgViewBaseOwnProps & WithAnalyticsEventsProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
|
@@ -5,11 +5,12 @@ import { MediaFileStateError } from '@atlaskit/media-client-react';
|
|
|
5
5
|
* Primary reason is logged through Data Portal.
|
|
6
6
|
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
7
7
|
*/
|
|
8
|
-
export type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
8
|
+
export type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | SvgPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
9
9
|
export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
|
|
10
10
|
export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
|
|
11
11
|
export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
|
|
12
12
|
export type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
|
|
13
|
+
export type SvgPrimaryReason = 'svg-img-error' | 'svg-binary-fetch' | 'svg-unknown-error';
|
|
13
14
|
export declare function isMediaFileStateError(err: Error): err is MediaFileStateError;
|
|
14
15
|
export declare function getFileStateErrorReason(err: MediaFileStateError): MediaClientErrorReason | 'unknown';
|
|
15
16
|
export declare function isPollingError(err?: Error): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ErrorInfo } from 'react';
|
|
1
2
|
import { type FileDetails, type FileStatus, type MediaClientErrorReason, type RequestMetadata } from '@atlaskit/media-client';
|
|
2
3
|
import { type FileAttributes, type PerformanceAttributes, type OperationalEventPayload, type UIEventPayload, type WithFileAttributes, type WithPerformanceAttributes, type SuccessAttributes, type FailureAttributes, type ScreenEventPayload, type ScreenAttributes, type MediaTraceContext, type WithTraceContext } from '@atlaskit/media-common/analytics';
|
|
3
4
|
import { type CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
@@ -52,7 +53,7 @@ export type ErrorBoundaryErrorInfo = {
|
|
|
52
53
|
};
|
|
53
54
|
export type AnalyticsErrorBoundaryAttributes = {
|
|
54
55
|
error?: Error | string;
|
|
55
|
-
info?:
|
|
56
|
+
info?: ErrorInfo;
|
|
56
57
|
browserInfo: string;
|
|
57
58
|
failReason: string;
|
|
58
59
|
};
|
|
@@ -4,4 +4,4 @@ export { ToggleBox } from './toggle';
|
|
|
4
4
|
export { SvgContainer } from './svgContainer';
|
|
5
5
|
export { useSvgUploader } from './uploader';
|
|
6
6
|
export { CardBox, CardRow } from './cardContainer';
|
|
7
|
-
export { delayApiResponses } from './
|
|
7
|
+
export { delayApiResponses, errorApiResponses } from './mediaApiTweaks';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type MediaApi, RequestError } from '@atlaskit/media-client';
|
|
2
|
+
import { sleep } from '@atlaskit/media-test-helpers';
|
|
3
|
+
|
|
4
|
+
type Endpoints = Partial<Record<keyof MediaApi, number>>;
|
|
5
|
+
|
|
6
|
+
export const delayApiResponses = (
|
|
7
|
+
mediaApi: MediaApi,
|
|
8
|
+
{ getImage, getItems, getFileBinary }: Endpoints,
|
|
9
|
+
) => {
|
|
10
|
+
const baseGetImage = mediaApi.getImage;
|
|
11
|
+
mediaApi.getImage = async (...params) => {
|
|
12
|
+
await sleep(getImage);
|
|
13
|
+
return baseGetImage(...params);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const baseGetItems = mediaApi.getItems;
|
|
17
|
+
mediaApi.getItems = async (...params) => {
|
|
18
|
+
await sleep(getItems);
|
|
19
|
+
return baseGetItems(...params);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const baseGetFileBinary = mediaApi.getFileBinary;
|
|
23
|
+
mediaApi.getFileBinary = async (...params) => {
|
|
24
|
+
await sleep(getFileBinary);
|
|
25
|
+
return baseGetFileBinary(...params);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const errorApiResponses = {
|
|
30
|
+
getFileBinary: (mediaApi: MediaApi, error?: Error) => {
|
|
31
|
+
mediaApi.getFileBinary = async () => {
|
|
32
|
+
throw (
|
|
33
|
+
error ||
|
|
34
|
+
new RequestError('serverForbidden', {
|
|
35
|
+
method: 'GET',
|
|
36
|
+
endpoint: '/file/:id/inary',
|
|
37
|
+
mediaRegion: 'adev',
|
|
38
|
+
mediaEnv: 'adev',
|
|
39
|
+
traceContext: { traceId: 'some-traceId', spanId: 'some-spanId' },
|
|
40
|
+
attempts: 10,
|
|
41
|
+
clientExhaustedRetries: true,
|
|
42
|
+
statusCode: 430,
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
getFileImage: (mediaApi: MediaApi, error?: Error) => {
|
|
48
|
+
mediaApi.getImage = async () => {
|
|
49
|
+
throw (
|
|
50
|
+
error ||
|
|
51
|
+
new RequestError('serverForbidden', {
|
|
52
|
+
method: 'GET',
|
|
53
|
+
endpoint: '/file/:id/image',
|
|
54
|
+
mediaRegion: 'adev',
|
|
55
|
+
mediaEnv: 'adev',
|
|
56
|
+
traceContext: { traceId: 'some-traceId', spanId: 'some-spanId' },
|
|
57
|
+
attempts: 10,
|
|
58
|
+
clientExhaustedRetries: true,
|
|
59
|
+
statusCode: 430,
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-card",
|
|
3
|
-
"version": "77.12.
|
|
3
|
+
"version": "77.12.3",
|
|
4
4
|
"description": "Includes all media card related components, CardView, CardViewSmall, Card...",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"@atlaskit/media-ui": "^25.10.0",
|
|
49
49
|
"@atlaskit/media-viewer": "^48.6.0",
|
|
50
50
|
"@atlaskit/platform-feature-flags": "^0.2.2",
|
|
51
|
-
"@atlaskit/primitives": "^8.
|
|
51
|
+
"@atlaskit/primitives": "^8.1.0",
|
|
52
52
|
"@atlaskit/spinner": "^16.2.0",
|
|
53
53
|
"@atlaskit/theme": "^12.11.0",
|
|
54
|
-
"@atlaskit/tokens": "^1.
|
|
54
|
+
"@atlaskit/tokens": "^1.53.0",
|
|
55
55
|
"@atlaskit/tooltip": "^18.5.0",
|
|
56
56
|
"@atlaskit/ufo": "^0.2.0",
|
|
57
57
|
"@atlaskit/ufo-interaction-ignore": "^1.1.0",
|
|
@@ -79,12 +79,13 @@
|
|
|
79
79
|
"@atlaskit/media-state": "^1.1.0",
|
|
80
80
|
"@atlaskit/media-test-data": "^2.3.0",
|
|
81
81
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
82
|
+
"@atlaskit/radio": "^6.4.0",
|
|
82
83
|
"@atlaskit/range": "^7.3.0",
|
|
83
84
|
"@atlaskit/ssr": "*",
|
|
84
85
|
"@atlaskit/toggle": "^13.2.0",
|
|
85
86
|
"@atlaskit/visual-regression": "*",
|
|
86
87
|
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
87
|
-
"@atlassian/ufo": "^0.
|
|
88
|
+
"@atlassian/ufo": "^0.3.0",
|
|
88
89
|
"@testing-library/dom": "^8.17.1",
|
|
89
90
|
"@testing-library/react": "^12.1.5",
|
|
90
91
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type MediaApi } from '@atlaskit/media-client';
|
|
2
|
-
import { sleep } from '@atlaskit/media-test-helpers';
|
|
3
|
-
|
|
4
|
-
type Endpoints = {
|
|
5
|
-
getImage: number;
|
|
6
|
-
getItems: number;
|
|
7
|
-
getFileBinary: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const delayApiResponses = (
|
|
11
|
-
mediaApi: MediaApi,
|
|
12
|
-
{ getImage, getItems, getFileBinary }: Endpoints,
|
|
13
|
-
) => {
|
|
14
|
-
const baseGetImage = mediaApi.getImage;
|
|
15
|
-
mediaApi.getImage = async (...params) => {
|
|
16
|
-
await sleep(getImage);
|
|
17
|
-
return baseGetImage(...params);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const baseGetItems = mediaApi.getItems;
|
|
21
|
-
mediaApi.getItems = async (...params) => {
|
|
22
|
-
await sleep(getItems);
|
|
23
|
-
return baseGetItems(...params);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const baseGetFileBinary = mediaApi.getFileBinary;
|
|
27
|
-
mediaApi.getFileBinary = async (...params) => {
|
|
28
|
-
await sleep(getFileBinary);
|
|
29
|
-
return baseGetFileBinary(...params);
|
|
30
|
-
};
|
|
31
|
-
};
|