@atlaskit/media-card 73.1.0 → 73.3.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/cjs/files/cardImageView/index.js +51 -41
  3. package/dist/cjs/root/card/cardAnalytics.js +4 -4
  4. package/dist/cjs/root/card/getCardPreview/index.js +7 -1
  5. package/dist/cjs/root/card/index.js +301 -155
  6. package/dist/cjs/root/cardView.js +128 -118
  7. package/dist/cjs/root/inlinePlayer.js +4 -2
  8. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +17 -23
  9. package/dist/cjs/root/ui/styled.js +5 -5
  10. package/dist/cjs/types.js +10 -1
  11. package/dist/cjs/utils/analytics.js +32 -13
  12. package/dist/cjs/utils/dimensionComparer.js +7 -13
  13. package/dist/cjs/utils/getMediaCardCursor.js +29 -0
  14. package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
  15. package/dist/cjs/utils/globalScope/globalScope.js +94 -0
  16. package/dist/cjs/utils/globalScope/index.js +39 -0
  17. package/dist/cjs/utils/globalScope/types.js +5 -0
  18. package/dist/cjs/utils/printScript.js +44 -0
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/files/cardImageView/index.js +19 -5
  21. package/dist/es2019/root/card/cardAnalytics.js +4 -4
  22. package/dist/es2019/root/card/getCardPreview/index.js +1 -0
  23. package/dist/es2019/root/card/index.js +167 -40
  24. package/dist/es2019/root/cardView.js +41 -35
  25. package/dist/es2019/root/inlinePlayer.js +4 -2
  26. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +17 -19
  27. package/dist/es2019/root/ui/styled.js +4 -4
  28. package/dist/es2019/types.js +7 -1
  29. package/dist/es2019/utils/analytics.js +17 -9
  30. package/dist/es2019/utils/dimensionComparer.js +6 -13
  31. package/dist/es2019/utils/getMediaCardCursor.js +19 -0
  32. package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
  33. package/dist/es2019/utils/globalScope/globalScope.js +62 -0
  34. package/dist/es2019/utils/globalScope/index.js +2 -0
  35. package/dist/es2019/utils/globalScope/types.js +1 -0
  36. package/dist/es2019/utils/printScript.js +19 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/files/cardImageView/index.js +53 -41
  39. package/dist/esm/root/card/cardAnalytics.js +4 -4
  40. package/dist/esm/root/card/getCardPreview/index.js +3 -0
  41. package/dist/esm/root/card/index.js +284 -138
  42. package/dist/esm/root/cardView.js +127 -118
  43. package/dist/esm/root/inlinePlayer.js +4 -2
  44. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +17 -21
  45. package/dist/esm/root/ui/styled.js +5 -5
  46. package/dist/esm/types.js +7 -1
  47. package/dist/esm/utils/analytics.js +26 -12
  48. package/dist/esm/utils/dimensionComparer.js +8 -13
  49. package/dist/esm/utils/getMediaCardCursor.js +19 -0
  50. package/dist/esm/utils/globalScope/getSSRData.js +10 -0
  51. package/dist/esm/utils/globalScope/globalScope.js +69 -0
  52. package/dist/esm/utils/globalScope/index.js +2 -0
  53. package/dist/esm/utils/globalScope/types.js +1 -0
  54. package/dist/esm/utils/printScript.js +30 -0
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/__tests_external__/page-objects/MediaCard.d.ts +0 -1
  57. package/dist/types/errors.d.ts +1 -1
  58. package/dist/types/files/cardImageView/index.d.ts +6 -2
  59. package/dist/types/root/card/cardAnalytics.d.ts +2 -1
  60. package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
  61. package/dist/types/root/card/index.d.ts +5 -1
  62. package/dist/types/root/cardView.d.ts +8 -6
  63. package/dist/types/root/inlinePlayer.d.ts +3 -1
  64. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -14
  65. package/dist/types/root/ui/styled.d.ts +2 -1
  66. package/dist/types/types.d.ts +6 -1
  67. package/dist/types/utils/analytics.d.ts +27 -5
  68. package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
  69. package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
  70. package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
  71. package/dist/types/utils/globalScope/index.d.ts +4 -0
  72. package/dist/types/utils/globalScope/types.d.ts +8 -0
  73. package/dist/types/utils/printScript.d.ts +2 -0
  74. package/package.json +12 -12
@@ -0,0 +1,19 @@
1
+ import { MediaCardCursor } from '../types';
2
+ export var getMediaCardCursor = function getMediaCardCursor(useInlinePlayer, useMediaViewer, isErrorStatus, hasCardPreview, mediaType) {
3
+ // If error status or no action is requested = NoAction
4
+ if (isErrorStatus || !useInlinePlayer && !useMediaViewer) {
5
+ return MediaCardCursor.NoAction;
6
+ }
7
+
8
+ if (!mediaType && (useInlinePlayer || useInlinePlayer && useMediaViewer)) {
9
+ return MediaCardCursor.NotReady;
10
+ } else if (mediaType === 'video' && hasCardPreview && useInlinePlayer) {
11
+ return MediaCardCursor.Action;
12
+ }
13
+
14
+ if (useMediaViewer) {
15
+ return MediaCardCursor.Action;
16
+ }
17
+
18
+ return MediaCardCursor.NoAction;
19
+ };
@@ -0,0 +1,10 @@
1
+ import { getMediaCardSSR, getKey } from './globalScope';
2
+ export var getSSRData = function getSSRData(identifier) {
3
+ var mediaCardSsr = getMediaCardSSR();
4
+
5
+ if (!mediaCardSsr) {
6
+ return;
7
+ }
8
+
9
+ return mediaCardSsr[getKey(identifier)];
10
+ };
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { printFunctionCall, printScript } from '../printScript';
3
+ // ----- WARNING -----
4
+ // This is a very sensitive fraction of code.
5
+ // Any changes to this file must be tested directly in product before merging.
6
+ // The scripts printed here might differ from what we observe in our internal tests
7
+ // due to minimification, for example.
8
+ export var GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
9
+ export var GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
10
+ export function getMediaGlobalScope() {
11
+ var globalScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
12
+ // Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
13
+ var namespace = '__MEDIA_INTERNAL';
14
+
15
+ if (!globalScope[namespace]) {
16
+ globalScope[namespace] = {};
17
+ }
18
+
19
+ return globalScope[namespace];
20
+ }
21
+ export function getMediaCardSSR() {
22
+ var globalScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
23
+ var globalMedia = getMediaGlobalScope(globalScope); // Must match GLOBAL_MEDIA_CARD_SSR. Can't reference the constant from here.
24
+
25
+ var key = 'mediaCardSsr';
26
+
27
+ if (!globalMedia[key]) {
28
+ globalMedia[key] = {};
29
+ }
30
+
31
+ return globalMedia[key];
32
+ }
33
+
34
+ var dashed = function dashed(param) {
35
+ return param ? "-".concat(param) : '';
36
+ };
37
+
38
+ export var getKey = function getKey(_ref) {
39
+ var id = _ref.id,
40
+ collectionName = _ref.collectionName,
41
+ occurrenceKey = _ref.occurrenceKey;
42
+ return "".concat(id).concat(dashed(collectionName)).concat(dashed(occurrenceKey));
43
+ };
44
+ export var storeDataURI = function storeDataURI(key, dataURI, dimensions, error) {
45
+ var globalScope = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : window;
46
+ var mediaCardSsr = getMediaCardSSR(globalScope);
47
+ mediaCardSsr[key] = {
48
+ dataURI: dataURI,
49
+ dimensions: dimensions,
50
+ error: error
51
+ };
52
+ };
53
+
54
+ var generateScript = function generateScript(identifier, dataURI, dimensions, error) {
55
+ var functionCall = printFunctionCall(storeDataURI, getKey(identifier), dataURI, dimensions, error);
56
+ return printScript([getMediaCardSSR.toString(), getMediaGlobalScope.toString(), functionCall]);
57
+ };
58
+
59
+ export var StoreSSRDataScript = function StoreSSRDataScript(_ref2) {
60
+ var dataURI = _ref2.dataURI,
61
+ identifier = _ref2.identifier,
62
+ dimensions = _ref2.dimensions,
63
+ error = _ref2.error;
64
+ return /*#__PURE__*/React.createElement("script", {
65
+ dangerouslySetInnerHTML: {
66
+ __html: generateScript(identifier, dataURI, dimensions, error)
67
+ }
68
+ });
69
+ };
@@ -0,0 +1,2 @@
1
+ export { StoreSSRDataScript, GLOBAL_MEDIA_NAMESPACE, GLOBAL_MEDIA_CARD_SSR, getKey } from './globalScope';
2
+ export { getSSRData } from './getSSRData';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+
3
+ var printParam = function printParam(param) {
4
+ if (typeof param === 'string') {
5
+ return "'".concat(param, "'");
6
+ } else if (_typeof(param) === 'object') {
7
+ return JSON.stringify(param);
8
+ } else if (param === undefined) {
9
+ return 'undefined';
10
+ }
11
+
12
+ return param;
13
+ };
14
+
15
+ var printParams = function printParams(args) {
16
+ return args.map(function (arg) {
17
+ return printParam(arg);
18
+ }).join(',');
19
+ };
20
+
21
+ export var printFunctionCall = function printFunctionCall(fn) {
22
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
23
+ args[_key - 1] = arguments[_key];
24
+ }
25
+
26
+ return "(".concat(fn.toString(), ")(").concat(printParams(args), ");");
27
+ };
28
+ export var printScript = function printScript(statements) {
29
+ return "(function(){\n ".concat(statements.join(';'), "\n})();\n");
30
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.1.0",
3
+ "version": "73.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,4 @@
1
1
  /// <reference types="cypress" />
2
- /// <reference types="jquery" />
3
2
  import { InProductTestPageObject } from '@atlaskit/in-product-testing';
4
3
  export declare class MediaCardPageObject extends InProductTestPageObject {
5
4
  expectCardReady(numOfCards: number): Cypress.Chainable<JQuery<HTMLElement>>;
@@ -24,7 +24,7 @@ export declare class SsrPreviewError extends MediaCardError {
24
24
  readonly secondaryError?: Error | undefined;
25
25
  constructor(primaryReason: SsrPreviewPrimaryReason, secondaryError?: Error | undefined);
26
26
  }
27
- export declare const getImageLoadPrimaryReason: (source?: "local" | "remote" | "ssr-server" | "ssr-client" | "cache-local" | "cache-remote" | "cache-ssr-client" | "cache-ssr-server" | "external" | undefined) => ImageLoadPrimaryReason;
27
+ export declare const getImageLoadPrimaryReason: (source?: "local" | "remote" | "ssr-server" | "ssr-client" | "ssr-data" | "cache-local" | "cache-remote" | "cache-ssr-client" | "cache-ssr-server" | "external" | undefined) => ImageLoadPrimaryReason;
28
28
  export declare class ImageLoadError extends MediaCardError {
29
29
  constructor(source?: CardPreview['source']);
30
30
  }
@@ -2,6 +2,7 @@ import { Component, ReactNode } from 'react';
2
2
  import { MediaItemType, MediaType, ImageResizeMode } from '@atlaskit/media-client';
3
3
  import { CardDimensions, CardStatus } from '../../index';
4
4
  import { CardAction } from '../../actions';
5
+ import { CardPreview } from '../..';
5
6
  export interface FileCardImageViewProps {
6
7
  readonly mediaName?: string;
7
8
  readonly mediaType?: MediaType;
@@ -21,8 +22,9 @@ export interface FileCardImageViewProps {
21
22
  readonly actions?: CardAction[];
22
23
  readonly onDisplayImage?: () => void;
23
24
  readonly previewOrientation?: number;
24
- readonly onImageError?: () => void;
25
- readonly onImageLoad?: () => void;
25
+ readonly onImageError?: (cardPreview: CardPreview) => void;
26
+ readonly onImageLoad?: (cardPreview: CardPreview) => void;
27
+ readonly cardPreview: CardPreview;
26
28
  }
27
29
  export declare const fileCardImageViewSelector = "media-file-card-view";
28
30
  export declare const fileCardImageViewSelectedSelector = "media-file-card-view-selected";
@@ -36,6 +38,8 @@ export declare class FileCardImageView extends Component<FileCardImageViewProps>
36
38
  private renderFailedContents;
37
39
  private renderUploadingCardOverlay;
38
40
  private renderPlayButton;
41
+ onImageLoad: () => void;
42
+ onImageError: () => void;
39
43
  private renderMediaImage;
40
44
  private renderProgressBar;
41
45
  private renderSuccessCardContents;
@@ -1,9 +1,10 @@
1
1
  import { FileAttributes, MediaFeatureFlags, PerformanceAttributes } from '@atlaskit/media-common';
2
2
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import { SSRStatus } from '../../utils/analytics';
3
4
  import { CardStatus } from '../..';
4
5
  import { MediaCardError } from './../../errors';
5
6
  export declare const relevantFeatureFlagNames: Array<keyof MediaFeatureFlags>;
6
- export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error?: MediaCardError | undefined) => void;
7
+ export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus, error?: MediaCardError | undefined) => void;
7
8
  export declare const fireCommencedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => void;
8
9
  export declare const fireCopiedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileId: string, cardRef: HTMLDivElement) => void;
9
10
  export declare const fireScreenEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes) => void;
@@ -47,4 +47,5 @@ export declare const isLocalPreview: (preview: CardPreview) => boolean;
47
47
  export declare const isSSRPreview: (preview: CardPreview) => boolean;
48
48
  export declare const isSSRServerPreview: (preview: CardPreview) => boolean;
49
49
  export declare const isSSRClientPreview: (preview: CardPreview) => boolean;
50
+ export declare const isSSRDataPreview: (preview: CardPreview) => boolean;
50
51
  export declare const fetchAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: CardDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs | undefined) => Promise<CardPreview>;
@@ -9,8 +9,10 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
9
9
  private hasBeenMounted;
10
10
  private viewportPreAnchorRef;
11
11
  private viewportPostAnchorRef;
12
+ private ssrReliability;
12
13
  private timeElapsedTillCommenced;
13
14
  subscription?: Subscription;
15
+ private ssrData?;
14
16
  static defaultProps: Partial<CardProps>;
15
17
  constructor(props: CardBaseProps);
16
18
  componentDidMount(): void;
@@ -21,13 +23,14 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
21
23
  private getMediaBlobUrlAttrs;
22
24
  private getCardPreviewParams;
23
25
  private setCacheSSRPreview;
24
- private resolveSSRPreview;
26
+ private refetchSSRPreview;
25
27
  private resolvePreview;
26
28
  subscribeInternalFile(identifier: FileIdentifier): void;
27
29
  private get requestedDimensions();
28
30
  private get metadata();
29
31
  private get fileAttributes();
30
32
  private getPerformanceAttributes;
33
+ private logSSRImageError;
31
34
  private onImageError;
32
35
  private onImageLoad;
33
36
  private fireOperationalEvent;
@@ -46,6 +49,7 @@ export declare class CardBase extends Component<CardBaseProps, CardState> {
46
49
  private onDisplayImage;
47
50
  renderMediaViewer: () => React.ReactPortal | undefined;
48
51
  renderCard: () => JSX.Element;
52
+ private storeSSRData;
49
53
  render(): JSX.Element;
50
54
  private onCardInViewport;
51
55
  onClick: (event: React.MouseEvent<HTMLDivElement>, analyticsEvent?: UIAnalyticsEvent | undefined) => void;
@@ -3,21 +3,23 @@ import { MediaItemType, FileDetails } from '@atlaskit/media-client';
3
3
  import { WithAnalyticsEventsProps, UIAnalyticsEvent } from '@atlaskit/analytics-next';
4
4
  import { SharedCardProps, CardStatus } from '../index';
5
5
  import { MediaCardError } from '../errors';
6
+ import { CardPreview } from '..';
6
7
  import { MessageDescriptor } from 'react-intl-next';
8
+ import { MediaCardCursor } from '../types';
7
9
  export interface CardViewOwnProps extends SharedCardProps {
8
10
  readonly status: CardStatus;
9
11
  readonly mediaItemType: MediaItemType;
12
+ readonly mediaCardCursor: MediaCardCursor;
10
13
  readonly metadata?: FileDetails;
11
14
  readonly error?: MediaCardError;
12
15
  readonly onClick?: (event: React.MouseEvent<HTMLDivElement>, analyticsEvent?: UIAnalyticsEvent) => void;
13
16
  readonly onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
14
17
  readonly onDisplayImage?: () => void;
15
- readonly dataURI?: string;
18
+ readonly cardPreview?: CardPreview;
16
19
  readonly progress?: number;
17
- readonly previewOrientation?: number;
18
20
  readonly innerRef?: (instance: HTMLDivElement | null) => void;
19
- readonly onImageLoad: () => void;
20
- readonly onImageError: () => void;
21
+ readonly onImageLoad: (cardPreview: CardPreview) => void;
22
+ readonly onImageError: (cardPreview: CardPreview) => void;
21
23
  readonly nativeLazyLoad?: boolean;
22
24
  readonly forceSyncDisplay?: boolean;
23
25
  disableAnimation?: boolean;
@@ -50,7 +52,7 @@ export declare class CardViewBase extends React.Component<CardViewProps, CardVie
50
52
  divRef: React.RefObject<HTMLDivElement>;
51
53
  static defaultProps: Partial<CardViewOwnProps>;
52
54
  componentDidMount(): void;
53
- componentDidUpdate({ dataURI: prevDataURI }: CardViewProps): void;
55
+ componentDidUpdate({ cardPreview: prevCardPreview }: CardViewProps): void;
54
56
  private onImageLoad;
55
57
  private onImageError;
56
58
  private get width();
@@ -73,4 +75,4 @@ export declare class CardViewBase extends React.Component<CardViewProps, CardVie
73
75
  private getRenderConfigByStatus;
74
76
  private renderNewExperienceCard;
75
77
  }
76
- export declare const CardView: React.ForwardRefExoticComponent<Pick<Pick<CardViewProps, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "dataURI" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "previewOrientation" | "onImageError" | "onImageLoad" | "forceSyncDisplay" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">, never> & Partial<Pick<Pick<CardViewProps, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "dataURI" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "previewOrientation" | "onImageError" | "onImageLoad" | "forceSyncDisplay" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "dataURI" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "previewOrientation" | "onImageError" | "onImageLoad" | "forceSyncDisplay" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">> & Partial<Pick<Partial<CardViewOwnProps>, never>> & React.RefAttributes<any>>;
78
+ export declare const CardView: React.ForwardRefExoticComponent<Pick<Pick<CardViewProps, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "onImageError" | "onImageLoad" | "cardPreview" | "forceSyncDisplay" | "mediaCardCursor" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">, never> & Partial<Pick<Pick<CardViewProps, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "onImageError" | "onImageLoad" | "cardPreview" | "forceSyncDisplay" | "mediaCardCursor" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">, "progress" | "metadata" | "onClick" | "onMouseEnter" | "innerRef" | "testId" | "appearance" | "error" | "actions" | "selectable" | "selected" | "alt" | "disableOverlay" | "dimensions" | "featureFlags" | "status" | "mediaItemType" | "resizeMode" | "onDisplayImage" | "onImageError" | "onImageLoad" | "cardPreview" | "forceSyncDisplay" | "mediaCardCursor" | "nativeLazyLoad" | "titleBoxBgColor" | "titleBoxIcon" | "disableAnimation" | "originalDimensions">> & Partial<Pick<Partial<CardViewOwnProps>, never>> & React.RefAttributes<any>>;
@@ -4,6 +4,7 @@ import { MediaClient, FileIdentifier, FileState, MediaFileArtifacts } from '@atl
4
4
  import { Subscription } from 'rxjs/Subscription';
5
5
  import { CardDimensions, NumericalCardDimensions } from '..';
6
6
  import { WithAnalyticsEventsProps, UIAnalyticsEvent } from '@atlaskit/analytics-next';
7
+ import type { CardPreview } from '..';
7
8
  export declare const inlinePlayerClassName = "media-card-inline-player";
8
9
  export interface InlinePlayerOwnProps {
9
10
  identifier: FileIdentifier;
@@ -15,6 +16,7 @@ export interface InlinePlayerOwnProps {
15
16
  onError?: (error: Error) => void;
16
17
  readonly onClick?: (event: React.MouseEvent<HTMLDivElement>, analyticsEvent?: UIAnalyticsEvent) => void;
17
18
  testId?: string;
19
+ readonly cardPreview?: CardPreview;
18
20
  readonly forwardRef?: React.Ref<HTMLDivElement>;
19
21
  }
20
22
  export declare type InlinePlayerProps = InlinePlayerOwnProps & WithAnalyticsEventsProps;
@@ -47,4 +49,4 @@ export declare class InlinePlayerBase extends Component<InlinePlayerProps, Inlin
47
49
  saveElementWidth: () => void;
48
50
  render(): JSX.Element;
49
51
  }
50
- export declare const InlinePlayer: React.ForwardRefExoticComponent<Pick<InlinePlayerProps, "onError" | "onClick" | "testId" | "createAnalyticsEvent" | "selected" | "dimensions" | "originalDimensions" | "mediaClient" | "identifier" | "autoplay" | "forwardRef"> & React.RefAttributes<HTMLDivElement>>;
52
+ export declare const InlinePlayer: React.ForwardRefExoticComponent<Pick<InlinePlayerProps, "onError" | "onClick" | "testId" | "createAnalyticsEvent" | "selected" | "dimensions" | "cardPreview" | "originalDimensions" | "mediaClient" | "identifier" | "autoplay" | "forwardRef"> & React.RefAttributes<HTMLDivElement>>;
@@ -1,24 +1,15 @@
1
1
  import React from 'react';
2
2
  import { MediaType, ImageResizeMode } from '@atlaskit/media-client';
3
+ import { CardPreview } from '../../..';
3
4
  export declare type ImageRendererProps = {
4
- readonly dataURI: string;
5
+ readonly cardPreview: CardPreview;
5
6
  readonly mediaType: MediaType;
6
- readonly previewOrientation?: number;
7
7
  readonly alt?: string;
8
8
  readonly resizeMode?: ImageResizeMode;
9
9
  readonly onDisplayImage?: () => void;
10
- readonly onImageError?: () => void;
11
- readonly onImageLoad?: () => void;
10
+ readonly onImageError?: (cardPreview: CardPreview) => void;
11
+ readonly onImageLoad?: (cardPreview: CardPreview) => void;
12
12
  readonly nativeLazyLoad?: boolean;
13
13
  readonly forceSyncDisplay?: boolean;
14
- readonly isImageVisible?: boolean;
15
- readonly className?: string;
16
14
  };
17
- export declare const ImageRendererBase: React.FC<ImageRendererProps>;
18
- export declare const ImageRenderer: import("styled-components").StyledComponentClass<ImageRendererProps & {
19
- isImageVisible?: boolean | undefined;
20
- }, any, Pick<ImageRendererProps, "className" | "mediaType" | "alt" | "dataURI" | "resizeMode" | "onDisplayImage" | "previewOrientation" | "onImageError" | "onImageLoad" | "forceSyncDisplay" | "nativeLazyLoad" | "isImageVisible"> & {
21
- theme?: any;
22
- } & {
23
- isImageVisible?: boolean | undefined;
24
- }>;
15
+ export declare const ImageRenderer: React.FC<ImageRendererProps>;
@@ -1,19 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  import { CardDimensions, CardAppearance } from '../..';
3
3
  import { Breakpoint } from './common';
4
+ import { MediaCardCursor } from '../../types';
4
5
  export declare const calcBreakpointSize: (wrapperWidth?: number) => Breakpoint;
5
6
  export interface NewFileExperienceWrapperProps {
6
7
  breakpoint: Breakpoint;
7
8
  dimensions?: CardDimensions;
8
9
  appearance?: CardAppearance;
9
10
  mediaType?: string;
10
- shouldUsePointerCursor: boolean;
11
11
  disableOverlay: boolean;
12
12
  displayBackground: boolean;
13
13
  selected: boolean;
14
14
  isPlayButtonClickable: boolean;
15
15
  isTickBoxSelectable: boolean;
16
16
  shouldDisplayTooltip: boolean;
17
+ mediaCardCursor: MediaCardCursor;
17
18
  }
18
19
  export declare const NewFileExperienceWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & NewFileExperienceWrapperProps, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & NewFileExperienceWrapperProps>;
19
20
  export declare const CardImageContainer: import("styled-components").StyledComponentClass<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
@@ -7,9 +7,14 @@ export declare type FilePreviewStatus = {
7
7
  };
8
8
  export declare type CardAppearance = 'auto' | 'image' | 'square' | 'horizontal';
9
9
  export declare type CardDimensionValue = number | string;
10
- export declare type CardPreviewSource = 'local' | 'remote' | 'ssr-server' | 'ssr-client' | 'cache-local' | 'cache-remote' | 'cache-ssr-client' | 'cache-ssr-server' | 'external';
10
+ export declare type CardPreviewSource = 'local' | 'remote' | 'ssr-server' | 'ssr-client' | 'ssr-data' | 'cache-local' | 'cache-remote' | 'cache-ssr-client' | 'cache-ssr-server' | 'external';
11
11
  export interface CardPreview {
12
12
  dataURI: string;
13
13
  orientation?: number;
14
14
  source: CardPreviewSource;
15
15
  }
16
+ export declare enum MediaCardCursor {
17
+ Action = "pointer",
18
+ NoAction = "default",
19
+ NotReady = "wait"
20
+ }
@@ -4,12 +4,32 @@ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
4
  import { MediaCardError, MediaCardErrorPrimaryReason } from '../errors';
5
5
  export declare type FileUriFailReason = 'local-uri' | 'remote-uri' | `unknown-uri`;
6
6
  export declare type FailedErrorFailReason = MediaCardErrorPrimaryReason | 'nativeError';
7
- export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & FailureAttributes & {
7
+ export declare type MediaCardErrorInfo = {
8
+ failReason: FailedErrorFailReason;
9
+ error: MediaClientErrorReason | 'nativeError';
10
+ errorDetail: string;
11
+ };
12
+ export declare type SSRStatusFail = MediaCardErrorInfo & {
13
+ status: 'fail';
14
+ };
15
+ declare type SSRStatusSuccess = SuccessAttributes;
16
+ declare type SSRStatusUnknown = {
17
+ status: 'unknown';
18
+ };
19
+ declare type SSRStatusAttributes = SSRStatusSuccess | SSRStatusFail | SSRStatusUnknown;
20
+ export declare type SSRStatus = {
21
+ server: SSRStatusAttributes;
22
+ client: SSRStatusAttributes;
23
+ };
24
+ export declare type WithSSRReliability = {
25
+ ssrReliability?: SSRStatus;
26
+ };
27
+ export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & FailureAttributes & {
8
28
  failReason: FailedErrorFailReason | 'failed-processing';
9
29
  error?: MediaClientErrorReason | 'nativeError';
10
30
  request?: RequestMetadata;
11
31
  }, 'failed', 'mediaCardRender'>;
12
- export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
32
+ export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & WithSSRReliability & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
13
33
  export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes, 'commenced', 'mediaCardRender'>;
14
34
  export declare type CopiedFileEventPayload = UIEventPayload<{}, 'copied', string>;
15
35
  export declare type ClickedEventPayload = UIEventPayload<{
@@ -25,14 +45,16 @@ export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload
25
45
  export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: "failed-processing" | "uploading" | "processing" | "processed" | "error" | undefined) => FileAttributes;
26
46
  export declare const getRenderPreviewableCardPayload: (fileAttributes: FileAttributes) => RenderScreenEventPayload;
27
47
  export declare const getRenderCommencedEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderCommencedEventPayload;
28
- export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes?: PerformanceAttributes | undefined) => RenderSucceededEventPayload;
48
+ export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus) => RenderSucceededEventPayload;
29
49
  export declare const getRenderFailedExternalUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
30
50
  export declare const getRenderErrorFailReason: (error: MediaCardError) => FailedErrorFailReason;
31
51
  export declare const getRenderErrorErrorReason: (error: MediaCardError) => MediaClientErrorReason | 'nativeError';
32
52
  export declare const getRenderErrorErrorDetail: (error: MediaCardError) => string;
33
53
  export declare const getRenderErrorRequestMetadata: (error: MediaCardError) => RequestMetadata | undefined;
34
- export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError) => RenderFailedEventPayload;
35
- export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
54
+ export declare const extractErrorInfo: (error: MediaCardError) => MediaCardErrorInfo;
55
+ export declare const getRenderErrorEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error: MediaCardError, ssrReliability: SSRStatus) => RenderFailedEventPayload;
56
+ export declare const getRenderFailedFileStatusPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, ssrReliability: SSRStatus) => RenderFailedEventPayload;
36
57
  export declare const getCopiedFilePayload: (fileId: string) => CopiedFileEventPayload;
37
58
  export declare function fireMediaCardEvent(payload: MediaCardAnalyticsEventPayload, createAnalyticsEvent?: CreateUIAnalyticsEvent): void;
38
59
  export declare const createAndFireMediaCardEvent: (payload: MediaCardAnalyticsEventPayload) => (createAnalyticsEvent: CreateUIAnalyticsEvent) => import("@atlaskit/analytics-next").UIAnalyticsEvent;
60
+ export {};
@@ -0,0 +1,2 @@
1
+ import { MediaCardCursor } from '../types';
2
+ export declare const getMediaCardCursor: (useInlinePlayer: boolean, useMediaViewer: boolean, isErrorStatus: boolean, hasCardPreview: boolean, mediaType?: "audio" | "video" | "image" | "doc" | "archive" | "unknown" | undefined) => MediaCardCursor;
@@ -0,0 +1,3 @@
1
+ import type { MediaCardSsrData } from './types';
2
+ import { FileIdentifier } from '@atlaskit/media-client';
3
+ export declare const getSSRData: (identifier: FileIdentifier) => MediaCardSsrData | undefined;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { FileIdentifier } from '@atlaskit/media-client';
3
+ import { NumericalCardDimensions } from '@atlaskit/media-common';
4
+ import { MediaCardErrorInfo } from '../../utils/analytics';
5
+ import { MediaCardSsr } from './types';
6
+ export declare const GLOBAL_MEDIA_CARD_SSR = "mediaCardSsr";
7
+ export declare const GLOBAL_MEDIA_NAMESPACE = "__MEDIA_INTERNAL";
8
+ export declare type MediaGlobalScope = {
9
+ [GLOBAL_MEDIA_CARD_SSR]?: MediaCardSsr;
10
+ };
11
+ export declare function getMediaGlobalScope(globalScope?: any): MediaGlobalScope;
12
+ export declare function getMediaCardSSR(globalScope?: any): MediaCardSsr;
13
+ export declare const getKey: ({ id, collectionName, occurrenceKey }: FileIdentifier) => string;
14
+ export declare const storeDataURI: (key: string, dataURI?: string | undefined, dimensions?: NumericalCardDimensions | undefined, error?: MediaCardErrorInfo | undefined, globalScope?: any) => void;
15
+ export declare type StoreSSRDataScriptProps = {
16
+ identifier: FileIdentifier;
17
+ dataURI?: string;
18
+ dimensions?: NumericalCardDimensions;
19
+ error?: MediaCardErrorInfo;
20
+ };
21
+ export declare const StoreSSRDataScript: React.FC<StoreSSRDataScriptProps>;
@@ -0,0 +1,4 @@
1
+ export { StoreSSRDataScript, GLOBAL_MEDIA_NAMESPACE, GLOBAL_MEDIA_CARD_SSR, getKey, } from './globalScope';
2
+ export { getSSRData } from './getSSRData';
3
+ export type { MediaCardSsrData, MediaCardSsr } from './types';
4
+ export type { MediaGlobalScope } from './globalScope';
@@ -0,0 +1,8 @@
1
+ import { NumericalCardDimensions } from '@atlaskit/media-common';
2
+ import { MediaCardErrorInfo } from '../../utils/analytics';
3
+ export declare type MediaCardSsrData = {
4
+ dataURI?: string;
5
+ dimensions?: NumericalCardDimensions;
6
+ error?: MediaCardErrorInfo;
7
+ };
8
+ export declare type MediaCardSsr = Record<string, MediaCardSsrData>;
@@ -0,0 +1,2 @@
1
+ export declare const printFunctionCall: <T extends any[]>(fn: (...args: T) => void, ...args: T) => string;
2
+ export declare const printScript: (statements: string[]) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "73.1.0",
3
+ "version": "73.3.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/analytics-next": "^8.2.0",
32
- "@atlaskit/dropdown-menu": "^11.0.0",
33
- "@atlaskit/editor-shared-styles": "^1.6.0",
32
+ "@atlaskit/dropdown-menu": "^11.1.0",
33
+ "@atlaskit/editor-shared-styles": "^2.0.0",
34
34
  "@atlaskit/icon": "^21.10.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/media-client": "^14.3.0",
37
- "@atlaskit/media-common": "^2.10.0",
38
- "@atlaskit/media-ui": "^18.1.0",
39
- "@atlaskit/media-viewer": "^46.0.0",
36
+ "@atlaskit/media-client": "^14.4.0",
37
+ "@atlaskit/media-common": "^2.11.0",
38
+ "@atlaskit/media-ui": "^20.0.0",
39
+ "@atlaskit/media-viewer": "^46.1.0",
40
40
  "@atlaskit/spinner": "^15.1.0",
41
41
  "@atlaskit/theme": "^12.1.0",
42
42
  "@atlaskit/tooltip": "^17.5.0",
@@ -55,17 +55,17 @@
55
55
  "styled-components": "^3.2.6"
56
56
  },
57
57
  "devDependencies": {
58
- "@atlaskit/analytics-listeners": "^8.0.0",
59
- "@atlaskit/analytics-namespaced-context": "^6.3.0",
60
- "@atlaskit/button": "^16.1.0",
58
+ "@atlaskit/analytics-listeners": "^8.2.0",
59
+ "@atlaskit/analytics-namespaced-context": "^6.4.0",
60
+ "@atlaskit/button": "^16.2.0",
61
61
  "@atlaskit/checkbox": "^12.3.0",
62
62
  "@atlaskit/docs": "*",
63
63
  "@atlaskit/inline-message": "^11.2.0",
64
64
  "@atlaskit/item": "^12.0.0",
65
65
  "@atlaskit/media-core": "^32.2.0",
66
- "@atlaskit/media-test-helpers": "^29.0.0",
66
+ "@atlaskit/media-test-helpers": "^29.2.0",
67
67
  "@atlaskit/radio": "^5.3.2",
68
- "@atlaskit/range": "^5.1.0",
68
+ "@atlaskit/range": "^6.0.0",
69
69
  "@atlaskit/select": "^15.2.1",
70
70
  "@atlaskit/ssr": "*",
71
71
  "@atlaskit/textfield": "^5.1.0",