@atlaskit/media-card 74.0.0 → 74.1.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 +13 -0
- package/dist/cjs/errors.js +4 -0
- package/dist/cjs/root/card/cardAnalytics.js +6 -2
- package/dist/cjs/root/card/getCardPreview/index.js +47 -20
- package/dist/cjs/root/card/imageRefetchingAnalytics.js +45 -0
- package/dist/cjs/root/card/index.js +13 -16
- package/dist/cjs/utils/analytics.js +29 -2
- package/dist/cjs/utils/document.js +9 -1
- package/dist/cjs/utils/ufoExperiences.js +7 -3
- package/dist/cjs/utils/viewportDetector.js +11 -36
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +4 -0
- package/dist/es2019/root/card/cardAnalytics.js +3 -2
- package/dist/es2019/root/card/getCardPreview/index.js +27 -2
- package/dist/es2019/root/card/imageRefetchingAnalytics.js +30 -0
- package/dist/es2019/root/card/index.js +15 -20
- package/dist/es2019/utils/analytics.js +18 -1
- package/dist/es2019/utils/document.js +11 -1
- package/dist/es2019/utils/ufoExperiences.js +4 -3
- package/dist/es2019/utils/viewportDetector.js +9 -36
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +4 -0
- package/dist/esm/root/card/cardAnalytics.js +5 -2
- package/dist/esm/root/card/getCardPreview/index.js +47 -20
- package/dist/esm/root/card/imageRefetchingAnalytics.js +32 -0
- package/dist/esm/root/card/index.js +15 -20
- package/dist/esm/utils/analytics.js +22 -1
- package/dist/esm/utils/document.js +9 -1
- package/dist/esm/utils/ufoExperiences.js +6 -3
- package/dist/esm/utils/viewportDetector.js +9 -36
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +5 -1
- package/dist/types/root/card/cardAnalytics.d.ts +1 -1
- package/dist/types/root/card/getCardPreview/index.d.ts +4 -1
- package/dist/types/root/card/imageRefetchingAnalytics.d.ts +10 -0
- package/dist/types/root/card/index.d.ts +0 -2
- package/dist/types/utils/analytics.d.ts +17 -1
- package/dist/types/utils/document.d.ts +1 -1
- package/dist/types/utils/ufoExperiences.d.ts +1 -1
- package/dist/types/utils/viewportDetector.d.ts +0 -10
- package/package.json +6 -5
|
@@ -4,30 +4,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6
6
|
|
|
7
|
-
import React, { useEffect
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export var ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
|
|
14
|
-
|
|
15
|
-
export var ViewportAnchor = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
|
-
if (typeof IntersectionObserver === 'undefined') {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
-
ref: ref,
|
|
22
|
-
className: "media-card-viewport-anchor",
|
|
23
|
-
style: {
|
|
24
|
-
position: 'absolute',
|
|
25
|
-
top: "".concat(props.offsetTop, "px"),
|
|
26
|
-
maxHeight: 0,
|
|
27
|
-
pointerEvents: 'none'
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
7
|
+
import React, { useEffect } from 'react';
|
|
8
|
+
import getDocument from './document';
|
|
9
|
+
var ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
|
|
31
10
|
|
|
32
11
|
var createIntersectionObserverCallback = function createIntersectionObserverCallback(onVisible) {
|
|
33
12
|
return function (entries, observer) {
|
|
@@ -55,26 +34,22 @@ var createIntersectionObserverCallback = function createIntersectionObserverCall
|
|
|
55
34
|
var ViewportObserver = function ViewportObserver(_ref) {
|
|
56
35
|
var onVisible = _ref.onVisible,
|
|
57
36
|
cardEl = _ref.cardEl,
|
|
58
|
-
children = _ref.children
|
|
59
|
-
preAnchorRef = _ref.preAnchorRef,
|
|
60
|
-
postAnchorRef = _ref.postAnchorRef;
|
|
37
|
+
children = _ref.children;
|
|
61
38
|
useEffect(function () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
39
|
+
var intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
|
|
40
|
+
root: getDocument(),
|
|
41
|
+
rootMargin: "".concat(ABS_VIEWPORT_ANCHOR_OFFSET_TOP, "px")
|
|
42
|
+
});
|
|
66
43
|
cardEl && intersectionObserver.observe(cardEl);
|
|
67
44
|
return function () {
|
|
68
45
|
intersectionObserver.disconnect();
|
|
69
46
|
};
|
|
70
|
-
}, [cardEl,
|
|
47
|
+
}, [cardEl, onVisible]);
|
|
71
48
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
72
49
|
};
|
|
73
50
|
|
|
74
51
|
export var ViewportDetector = function ViewportDetector(_ref2) {
|
|
75
52
|
var cardEl = _ref2.cardEl,
|
|
76
|
-
preAnchorRef = _ref2.preAnchorRef,
|
|
77
|
-
postAnchorRef = _ref2.postAnchorRef,
|
|
78
53
|
onVisible = _ref2.onVisible,
|
|
79
54
|
children = _ref2.children;
|
|
80
55
|
|
|
@@ -84,8 +59,6 @@ export var ViewportDetector = function ViewportDetector(_ref2) {
|
|
|
84
59
|
|
|
85
60
|
return /*#__PURE__*/React.createElement(ViewportObserver, {
|
|
86
61
|
cardEl: cardEl,
|
|
87
|
-
preAnchorRef: preAnchorRef,
|
|
88
|
-
postAnchorRef: postAnchorRef,
|
|
89
62
|
onVisible: onVisible
|
|
90
63
|
}, children);
|
|
91
64
|
};
|
package/dist/esm/version.json
CHANGED
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { CardPreview } from '.';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Primary reason is logged through Data Portal.
|
|
4
|
+
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
5
|
+
*/
|
|
6
|
+
export declare type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
3
7
|
export declare type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
|
|
4
8
|
export declare type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready';
|
|
5
9
|
export declare type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
|
|
@@ -3,7 +3,7 @@ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
|
3
3
|
import { SSRStatus } from '../../utils/analytics';
|
|
4
4
|
import { CardStatus } from '../..';
|
|
5
5
|
import { MediaCardError } from './../../errors';
|
|
6
|
-
export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error?: MediaCardError
|
|
6
|
+
export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error?: MediaCardError) => void;
|
|
7
7
|
export declare const fireCommencedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => void;
|
|
8
8
|
export declare const fireCopiedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileId: string, cardRef: HTMLDivElement) => void;
|
|
9
9
|
export declare const fireScreenEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MediaClient, FilePreview, FileState, MediaStoreGetFileImageParams, MediaBlobUrlAttrs, FileIdentifier } from '@atlaskit/media-client';
|
|
2
2
|
import { MediaFeatureFlags, SSR } from '@atlaskit/media-common';
|
|
3
3
|
import { ImageResizeMode } from '@atlaskit/media-client';
|
|
4
|
+
import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
4
5
|
import { CardDimensions } from '../../../utils/cardDimensions';
|
|
5
6
|
import { MediaCardError } from '../../../errors';
|
|
6
7
|
import { CardStatus, CardPreview } from '../../../types';
|
|
@@ -22,6 +23,8 @@ export declare type CardPreviewParams = {
|
|
|
22
23
|
isRemotePreviewReady: boolean;
|
|
23
24
|
imageUrlParams: MediaStoreGetFileImageParams;
|
|
24
25
|
mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
|
|
26
|
+
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
27
|
+
featureFlags?: MediaFeatureFlags;
|
|
25
28
|
};
|
|
26
29
|
/**
|
|
27
30
|
* This function will try to return a Card preview, either from cache, local preview or remote preview.
|
|
@@ -33,7 +36,7 @@ export declare type CardPreviewParams = {
|
|
|
33
36
|
* In that case, we still want to report the local preview error to the caller, for feature realiability track.
|
|
34
37
|
* hence the use of the optional callback onLocalPreviewError
|
|
35
38
|
*/
|
|
36
|
-
export declare const getCardPreview: ({ mediaClient, id, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, }: CardPreviewParams) => Promise<CardPreview>;
|
|
39
|
+
export declare const getCardPreview: ({ mediaClient, id, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, createAnalyticsEvent, featureFlags, }: CardPreviewParams) => Promise<CardPreview>;
|
|
37
40
|
export declare const shouldResolvePreview: ({ status, fileState, dimensions, identifier, fileImageMode, hasCardPreview, isBannedLocalPreview, featureFlags, }: {
|
|
38
41
|
status: CardStatus;
|
|
39
42
|
fileState: FileState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
|
+
import { CardDimensions } from '../../utils';
|
|
3
|
+
import { CardPreviewAttributes } from '../../utils/analytics';
|
|
4
|
+
declare type cardAction = 'cache-hit' | 'remote-success';
|
|
5
|
+
export declare const fireImageFetchingOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, action: cardAction, cardPreviewAttributes: CardPreviewAttributes) => void;
|
|
6
|
+
export declare const calculatePercentageDifference: (prevDimensions: CardDimensions | undefined, currentDimensions: CardDimensions | undefined) => {
|
|
7
|
+
width: string;
|
|
8
|
+
height: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
export {};
|
|
@@ -8,8 +8,6 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
|
|
|
8
8
|
private internalOccurrenceKey;
|
|
9
9
|
private hasBeenMounted;
|
|
10
10
|
private fileStateFlags;
|
|
11
|
-
private viewportPreAnchorRef;
|
|
12
|
-
private viewportPostAnchorRef;
|
|
13
11
|
private ssrReliability;
|
|
14
12
|
private timeElapsedTillCommenced;
|
|
15
13
|
subscription?: MediaSubscription;
|
|
@@ -2,6 +2,18 @@ import { FileDetails, MediaClientErrorReason, RequestMetadata } from '@atlaskit/
|
|
|
2
2
|
import { FileAttributes, PerformanceAttributes, OperationalEventPayload, UIEventPayload, WithFileAttributes, WithPerformanceAttributes, SuccessAttributes, FailureAttributes, ScreenEventPayload, ScreenAttributes } from '@atlaskit/media-common';
|
|
3
3
|
import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
4
4
|
import { MediaCardError, MediaCardErrorPrimaryReason } from '../errors';
|
|
5
|
+
import { CardDimensions } from './cardDimensions';
|
|
6
|
+
import { CardPreviewSource } from '../types';
|
|
7
|
+
export declare type CardPreviewAttributes = {
|
|
8
|
+
fileId: string;
|
|
9
|
+
prevDimensions: CardDimensions | undefined;
|
|
10
|
+
currentDimensions: CardDimensions | undefined;
|
|
11
|
+
dimensionsPercentageDiff?: CardDimensions | undefined;
|
|
12
|
+
source: CardPreviewSource;
|
|
13
|
+
};
|
|
14
|
+
declare type WithCardPreviewCacheAttributes = {
|
|
15
|
+
cardPreviewAttributes: CardPreviewAttributes;
|
|
16
|
+
};
|
|
5
17
|
export declare const LOGGED_FEATURE_FLAGS: (keyof import("@atlaskit/media-common").MediaFeatureFlags)[];
|
|
6
18
|
export declare const LOGGED_FEATURE_FLAG_KEYS: string[];
|
|
7
19
|
export declare type FileUriFailReason = 'local-uri' | 'remote-uri' | `unknown-uri`;
|
|
@@ -33,6 +45,8 @@ export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileA
|
|
|
33
45
|
}, 'failed', 'mediaCardRender'>;
|
|
34
46
|
export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
|
|
35
47
|
export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes, 'commenced', 'mediaCardRender'>;
|
|
48
|
+
export declare type CacheHitEventPayload = OperationalEventPayload<WithCardPreviewCacheAttributes, 'cache-hit', 'mediaCardCache'>;
|
|
49
|
+
export declare type RemoteSuccessEventPayload = OperationalEventPayload<WithCardPreviewCacheAttributes, 'Remote-success', 'mediaCardCache'>;
|
|
36
50
|
export declare type CopiedFileEventPayload = UIEventPayload<{}, 'copied', string>;
|
|
37
51
|
export declare type ClickedEventPayload = UIEventPayload<{
|
|
38
52
|
label?: string;
|
|
@@ -43,11 +57,13 @@ export declare type RenderScreenEventPayload = Omit<ScreenEventPayload<ScreenAtt
|
|
|
43
57
|
fileAttributes: FileAttributes;
|
|
44
58
|
};
|
|
45
59
|
};
|
|
46
|
-
export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload | RenderScreenEventPayload;
|
|
60
|
+
export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload | RenderScreenEventPayload | CacheHitEventPayload | RemoteSuccessEventPayload;
|
|
47
61
|
export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: import("@atlaskit/media-common").FileStatus | undefined) => FileAttributes;
|
|
48
62
|
export declare const getRenderPreviewableCardPayload: (fileAttributes: FileAttributes) => RenderScreenEventPayload;
|
|
49
63
|
export declare const getRenderCommencedEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderCommencedEventPayload;
|
|
50
64
|
export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus) => RenderSucceededEventPayload;
|
|
65
|
+
export declare const getCacheHitEventPayload: (cardPreviewAttributes: CardPreviewAttributes) => CacheHitEventPayload;
|
|
66
|
+
export declare const getRemoteSuccessEventPayload: (cardPreviewAttributes: CardPreviewAttributes) => RemoteSuccessEventPayload;
|
|
51
67
|
export declare const getRenderFailedExternalUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
|
|
52
68
|
export declare const getRenderErrorFailReason: (error: MediaCardError) => FailedErrorFailReason;
|
|
53
69
|
export declare const getRenderErrorErrorReason: (error: MediaCardError) => MediaClientErrorReason | 'nativeError';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => Document;
|
|
1
|
+
declare const _default: () => Document | undefined;
|
|
2
2
|
export default _default;
|
|
@@ -4,4 +4,4 @@ import { SSRStatus } from './analytics';
|
|
|
4
4
|
import { MediaCardError } from '../errors';
|
|
5
5
|
import { FileStateFlags } from '../types';
|
|
6
6
|
export declare const startUfoExperience: (id: string) => void;
|
|
7
|
-
export declare const completeUfoExperience: (id: string, status: CardStatus, fileAttributes: FileAttributes, fileStateFlags: FileStateFlags, ssrReliability: SSRStatus, error?: MediaCardError
|
|
7
|
+
export declare const completeUfoExperience: (id: string, status: CardStatus, fileAttributes: FileAttributes, fileStateFlags: FileStateFlags, ssrReliability: SSRStatus, error?: MediaCardError) => void;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
|
|
4
|
-
* Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
|
|
5
|
-
*/
|
|
6
|
-
export declare const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900;
|
|
7
|
-
export declare const ViewportAnchor: React.ForwardRefExoticComponent<{
|
|
8
|
-
offsetTop: number;
|
|
9
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
10
2
|
export declare type ViewportDetectorProps = {
|
|
11
3
|
cardEl: HTMLElement | null;
|
|
12
|
-
preAnchorRef: React.RefObject<HTMLDivElement>;
|
|
13
|
-
postAnchorRef: React.RefObject<HTMLDivElement>;
|
|
14
4
|
onVisible: () => void;
|
|
15
5
|
};
|
|
16
6
|
export declare const ViewportDetector: React.FC<ViewportDetectorProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-card",
|
|
3
|
-
"version": "74.
|
|
3
|
+
"version": "74.1.0",
|
|
4
4
|
"description": "Includes all media card related components, CardView, CardViewSmall, Card...",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
33
|
-
"@atlaskit/dropdown-menu": "^11.
|
|
33
|
+
"@atlaskit/dropdown-menu": "^11.3.0",
|
|
34
34
|
"@atlaskit/editor-shared-styles": "^2.1.0",
|
|
35
35
|
"@atlaskit/icon": "^21.10.0",
|
|
36
36
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
37
37
|
"@atlaskit/media-client": "^17.1.0",
|
|
38
|
-
"@atlaskit/media-common": "^2.
|
|
38
|
+
"@atlaskit/media-common": "^2.16.0",
|
|
39
39
|
"@atlaskit/media-ui": "^22.1.0",
|
|
40
40
|
"@atlaskit/media-viewer": "^47.0.0",
|
|
41
41
|
"@atlaskit/spinner": "^15.1.0",
|
|
@@ -61,12 +61,13 @@
|
|
|
61
61
|
"@atlaskit/button": "^16.3.0",
|
|
62
62
|
"@atlaskit/checkbox": "^12.3.0",
|
|
63
63
|
"@atlaskit/docs": "*",
|
|
64
|
-
"@atlaskit/inline-message": "^11.
|
|
64
|
+
"@atlaskit/inline-message": "^11.3.0",
|
|
65
65
|
"@atlaskit/media-core": "^33.0.0",
|
|
66
|
+
"@atlaskit/media-picker": "^63.0.1",
|
|
66
67
|
"@atlaskit/media-test-helpers": "^30.0.0",
|
|
67
68
|
"@atlaskit/radio": "^5.3.2",
|
|
68
69
|
"@atlaskit/range": "^6.0.0",
|
|
69
|
-
"@atlaskit/select": "^15.
|
|
70
|
+
"@atlaskit/select": "^15.5.0",
|
|
70
71
|
"@atlaskit/ssr": "*",
|
|
71
72
|
"@atlaskit/toggle": "^12.4.0",
|
|
72
73
|
"@atlaskit/visual-regression": "*",
|