@atlaskit/media-card 79.11.4 → 79.13.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 (47) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/externalImageCard.js +17 -12
  4. package/dist/cjs/card/fileCard.js +34 -12
  5. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  6. package/dist/cjs/card/ui/tickBox/tickBoxWrapper-compiled.compiled.css +0 -3
  7. package/dist/cjs/card/ui/tickBox/tickBoxWrapper-compiled.js +1 -3
  8. package/dist/cjs/card/ui/titleBox/failedTitleBox.js +0 -2
  9. package/dist/cjs/card/ui/titleBox/titleBoxComponents-compiled.js +1 -3
  10. package/dist/cjs/inline/loader.js +1 -1
  11. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  12. package/dist/cjs/utils/globalScope/globalScope.js +2 -1
  13. package/dist/cjs/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  14. package/dist/cjs/utils/ufoExperiences.js +454 -68
  15. package/dist/es2019/card/card.js +1 -1
  16. package/dist/es2019/card/externalImageCard.js +16 -13
  17. package/dist/es2019/card/fileCard.js +33 -13
  18. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  19. package/dist/es2019/card/ui/tickBox/tickBoxWrapper-compiled.compiled.css +0 -3
  20. package/dist/es2019/card/ui/tickBox/tickBoxWrapper-compiled.js +1 -3
  21. package/dist/es2019/card/ui/titleBox/failedTitleBox.js +0 -2
  22. package/dist/es2019/card/ui/titleBox/titleBoxComponents-compiled.js +1 -3
  23. package/dist/es2019/inline/loader.js +1 -1
  24. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  25. package/dist/es2019/utils/globalScope/globalScope.js +1 -0
  26. package/dist/es2019/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  27. package/dist/es2019/utils/ufoExperiences.js +449 -72
  28. package/dist/esm/card/card.js +1 -1
  29. package/dist/esm/card/externalImageCard.js +18 -13
  30. package/dist/esm/card/fileCard.js +35 -13
  31. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  32. package/dist/esm/card/ui/tickBox/tickBoxWrapper-compiled.compiled.css +0 -3
  33. package/dist/esm/card/ui/tickBox/tickBoxWrapper-compiled.js +1 -3
  34. package/dist/esm/card/ui/titleBox/failedTitleBox.js +0 -2
  35. package/dist/esm/card/ui/titleBox/titleBoxComponents-compiled.js +1 -3
  36. package/dist/esm/inline/loader.js +1 -1
  37. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +0 -2
  38. package/dist/esm/utils/globalScope/globalScope.js +1 -0
  39. package/dist/esm/utils/mediaPerformanceObserver/durationMetrics.js +1 -0
  40. package/dist/esm/utils/ufoExperiences.js +454 -68
  41. package/dist/types/utils/globalScope/globalScope.d.ts +2 -0
  42. package/dist/types/utils/mediaPerformanceObserver/durationMetrics.d.ts +1 -0
  43. package/dist/types/utils/ufoExperiences.d.ts +88 -5
  44. package/dist/types-ts4.5/utils/globalScope/globalScope.d.ts +2 -0
  45. package/dist/types-ts4.5/utils/mediaPerformanceObserver/durationMetrics.d.ts +1 -0
  46. package/dist/types-ts4.5/utils/ufoExperiences.d.ts +88 -5
  47. package/package.json +9 -9
@@ -18,7 +18,7 @@ import { generateUniqueId } from '../utils/generateUniqueId';
18
18
  import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
19
19
  import { getMediaCardCursor } from '../utils/getMediaCardCursor';
20
20
  import { getFileDetails } from '../utils/metadata';
21
- import { abortUfoExperience, completeUfoExperience, shouldPerformanceBeSampled, startUfoExperience } from '../utils/ufoExperiences';
21
+ import { shouldPerformanceBeSampled, useMediaCardUfoExperience } from '../utils/ufoExperiences';
22
22
  import { useCurrentValueRef } from '../utils/useCurrentValueRef';
23
23
  import { usePrevious } from '../utils/usePrevious';
24
24
  import { ViewportDetector } from '../utils/viewportDetector';
@@ -212,7 +212,15 @@ export var FileCard = function FileCard(_ref) {
212
212
  onImageLoadBase = _useFilePreview.onImageLoad,
213
213
  getSsrScriptProps = _useFilePreview.getSsrScriptProps,
214
214
  copyNodeRef = _useFilePreview.copyNodeRef;
215
- var shouldSendPerformanceEventRef = useRef(shouldPerformanceBeSampled());
215
+ var shouldSendPerformanceEvent = useMemo(function () {
216
+ return shouldPerformanceBeSampled();
217
+ }, []);
218
+
219
+ // UFO experience hook - creates a unique experience instance per card
220
+ var ufoExperience = useMediaCardUfoExperience({
221
+ instanceId: internalOccurrenceKey,
222
+ enabled: shouldSendPerformanceEvent
223
+ });
216
224
  var _useState13 = useState(),
217
225
  _useState14 = _slicedToArray(_useState13, 2),
218
226
  error = _useState14[0],
@@ -327,6 +335,7 @@ export var FileCard = function FileCard(_ref) {
327
335
  //----------------------------------------------------------------//
328
336
 
329
337
  var fireOperationalEventRef = useCurrentValueRef(function () {
338
+ var _ssrReliability$serve, _ssrReliability$clien;
330
339
  var timeElapsedTillEvent = performanceNow();
331
340
  var durationSinceCommenced = timeElapsedTillEvent - timeElapsedTillCommenced;
332
341
  var performanceAttributes = {
@@ -336,7 +345,19 @@ export var FileCard = function FileCard(_ref) {
336
345
  }
337
346
  };
338
347
  createAnalyticsEvent && fireOperationalEvent(createAnalyticsEvent, finalStatus, fileAttributes, performanceAttributes, ssrReliability, finalError, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
339
- shouldSendPerformanceEventRef.current && completeUfoExperience(internalOccurrenceKey, finalStatus, fileAttributes, fileStateFlagsRef.current, ssrReliability, finalError);
348
+
349
+ // Determine SSR preview info for UFO timing strategy
350
+ // wasSSRAttempted is only true when SSR was used AND preview is non-lazy
351
+ // because lazy SSR defers loading, so it behaves like CSR for timing purposes
352
+ var isSSRNonLazy = !!ssr && (preview === null || preview === void 0 ? void 0 : preview.lazy) !== true;
353
+ var wasSSRSuccessful = isSSRNonLazy && (((_ssrReliability$serve = ssrReliability.server) === null || _ssrReliability$serve === void 0 ? void 0 : _ssrReliability$serve.status) === 'success' || ((_ssrReliability$clien = ssrReliability.client) === null || _ssrReliability$clien === void 0 ? void 0 : _ssrReliability$clien.status) === 'success');
354
+ var ssrPreviewInfo = {
355
+ dataUri: preview === null || preview === void 0 ? void 0 : preview.dataURI,
356
+ srcset: preview === null || preview === void 0 ? void 0 : preview.srcSet,
357
+ wasSSRAttempted: isSSRNonLazy,
358
+ wasSSRSuccessful: wasSSRSuccessful
359
+ };
360
+ ufoExperience.complete(finalStatus, fileAttributes, fileStateFlagsRef.current, ssrReliability, finalError, ssrPreviewInfo);
340
361
  });
341
362
  var fireNonCriticalErrorEventRef = useCurrentValueRef(function (error) {
342
363
  createAnalyticsEvent && fireNonCriticalErrorEvent(createAnalyticsEvent, finalStatus, fileAttributes, ssrReliability, error, traceContext, fileStateValue === null || fileStateValue === void 0 ? void 0 : fileStateValue.metadataTraceContext);
@@ -347,19 +368,20 @@ export var FileCard = function FileCard(_ref) {
347
368
  }
348
369
  }, [nonCriticalError, fireNonCriticalErrorEventRef]);
349
370
  var startUfoExperienceRef = useCurrentValueRef(function () {
350
- if (shouldSendPerformanceEventRef.current) {
351
- startUfoExperience(internalOccurrenceKey);
352
- }
371
+ // For non-lazy SSR previews, use interaction start time as the experience start time
372
+ // because the image loading started at interaction start, not at mount time
373
+ var isSSRNonLazy = !!ssr && (preview === null || preview === void 0 ? void 0 : preview.lazy) !== true;
374
+ ufoExperience.start({
375
+ useInteractionTime: isSSRNonLazy
376
+ });
353
377
  });
354
378
  var fireAbortedEventRef = useCurrentValueRef(function () {
355
379
  // UFO won't abort if it's already in a final state (succeeded, failed, aborted, etc)
356
- if (shouldSendPerformanceEventRef.current) {
357
- abortUfoExperience(internalOccurrenceKey, {
358
- fileAttributes: fileAttributes,
359
- fileStateFlags: fileStateFlagsRef === null || fileStateFlagsRef === void 0 ? void 0 : fileStateFlagsRef.current,
360
- ssrReliability: ssrReliability
361
- });
362
- }
380
+ ufoExperience.abort({
381
+ fileAttributes: fileAttributes,
382
+ fileStateFlags: fileStateFlagsRef === null || fileStateFlagsRef === void 0 ? void 0 : fileStateFlagsRef.current,
383
+ ssrReliability: ssrReliability
384
+ });
363
385
  });
364
386
 
365
387
  //----------------------------------------------------------------//
@@ -80,7 +80,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
80
80
  }(React.Component);
81
81
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
82
82
  var packageName = "@atlaskit/media-card";
83
- var packageVersion = "79.11.3";
83
+ var packageVersion = "79.13.0";
84
84
 
85
85
  // @ts-ignore: [PIT-1685] Fails in post-office due to backwards incompatibility issue with React 18
86
86
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
@@ -3,13 +3,10 @@
3
3
  ._v564ybtr{transition:all .3s}
4
4
  ._154i1tpr{top:var(--ds-space-075,7px)}
5
5
  ._1b941ule span{display:block}
6
- ._1bsbdlk8{width:14px}
7
6
  ._1bsbpxbi{width:var(--ds-space-200,1pc)}
8
7
  ._1e0c11p5{display:grid}
9
8
  ._1ltv1tpr{left:var(--ds-space-075,7px)}
10
- ._1mcmdlk8 span svg{height:14px}
11
9
  ._4cvr1h6o{align-items:center}
12
- ._4t3idlk8{height:14px}
13
10
  ._4t3ipxbi{height:var(--ds-space-200,1pc)}
14
11
  ._6a6z1h6o{justify-items:center}
15
12
  ._bfhkqre5{background-color:var(--_1flhvp0)}
@@ -2,17 +2,15 @@
2
2
  import "./tickBoxWrapper-compiled.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { tickBoxClassName } from './styles';
7
6
  import { B200 } from '@atlaskit/theme/colors';
8
7
  var selectedStyles = null;
9
- var oldWrapperStyes = null;
10
8
  var wrapperStyles = null;
11
9
  export var TickBoxWrapper = function TickBoxWrapper(props) {
12
10
  return /*#__PURE__*/React.createElement("div", {
13
11
  id: "tickBoxWrapper",
14
12
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
15
- className: ax(["_11c82smr _2rkov47k _4cvr1h6o _6a6z1h6o _v564ybtr _1bsbpxbi _4t3ipxbi _kqswstnw _154i1tpr _1ltv1tpr _syaz1j28 _1e0c11p5 _1b941ule", !fg('platform-visual-refresh-icons') && "_1bsbdlk8 _4t3idlk8 _1mcmdlk8", props.selected && "_bfhkqre5 _syaz5w2r", tickBoxClassName]),
13
+ className: ax(["_11c82smr _2rkov47k _4cvr1h6o _6a6z1h6o _v564ybtr _1bsbpxbi _4t3ipxbi _kqswstnw _154i1tpr _1ltv1tpr _syaz1j28 _1e0c11p5 _1b941ule", props.selected && "_bfhkqre5 _syaz5w2r", tickBoxClassName]),
16
14
  style: {
17
15
  "--_1flhvp0": ix("var(--ds-icon-information, ".concat(B200, ")"))
18
16
  }
@@ -16,8 +16,6 @@ export var FailedTitleBox = function FailedTitleBox(_ref) {
16
16
  breakpoint: breakpoint
17
17
  }, /*#__PURE__*/React.createElement(ErrorMessageWrapper, null, /*#__PURE__*/React.createElement(EditorWarningIcon, {
18
18
  label: 'Warning',
19
- LEGACY_size: 'small',
20
- LEGACY_margin: "0 ".concat("var(--ds-space-negative-025, -2px)"),
21
19
  color: "var(--ds-text-danger, ".concat(R300, ")"),
22
20
  size: "small"
23
21
  }), /*#__PURE__*/React.createElement("span", {
@@ -2,7 +2,6 @@
2
2
  import "./titleBoxComponents-compiled.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { N0, N800 } from '@atlaskit/theme/colors';
7
6
  import { rgba } from '../styles';
8
7
  var smallLineHeight = 14;
@@ -64,12 +63,11 @@ export var TitleBoxFooter = function TitleBoxFooter(props) {
64
63
  };
65
64
  TitleBoxFooter.displayName = 'TitleBoxFooter';
66
65
  var titleBoxIconStyles = null;
67
- var newTitleBoxIconStyles = null;
68
66
  export var TitleBoxIcon = function TitleBoxIcon(props) {
69
67
  return /*#__PURE__*/React.createElement("div", {
70
68
  id: "titleBoxIcon",
71
69
  "data-testid": "title-box-icon",
72
- className: ax([fg('platform-visual-refresh-icons') && "_kqswstnw _1xi21b66 _94n51b66", !fg('platform-visual-refresh-icons') && "_kqswstnw _1xi21b66 _94n5idpf"])
70
+ className: ax(["_kqswstnw _1xi21b66 _94n51b66"])
73
71
  }, props.children);
74
72
  };
75
73
  var errorMessageWrapperStyles = null;
@@ -101,7 +101,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
101
101
  ErrorBoundary = _this$state.ErrorBoundary;
102
102
  var analyticsContext = {
103
103
  packageVersion: "@atlaskit/media-card",
104
- packageName: "79.11.3",
104
+ packageName: "79.13.0",
105
105
  componentName: 'mediaInlineCard',
106
106
  component: 'mediaInlineCard'
107
107
  };
@@ -62,9 +62,7 @@ var ErrorBoundaryComponent = function ErrorBoundaryComponent(_ref) {
62
62
  React.createElement("span", {
63
63
  style: style
64
64
  }, /*#__PURE__*/React.createElement(WarningIcon, {
65
- LEGACY_margin: "0 ".concat("var(--ds-space-negative-050, -4px)", " 0 0"),
66
65
  label: "error",
67
- LEGACY_size: "small",
68
66
  color: "var(--ds-icon-danger, ".concat(R300, ")"),
69
67
  size: "small"
70
68
  }), message)
@@ -7,6 +7,7 @@ import { printFunctionCall, printScript } from '../printScript';
7
7
 
8
8
  export var GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
9
9
  export var GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
10
+ export var GLOBAL_MEDIA_PERFORMANCE_ENTRIES = 'performanceEntries';
10
11
  export function getMediaGlobalScope() {
11
12
  var globalScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
12
13
  // Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
@@ -92,6 +92,7 @@ export var createMediaDurationMetrics = function createMediaDurationMetrics(entr
92
92
  totalDuration: entry.duration,
93
93
  initiatorType: entry.initiatorType,
94
94
  // value can be 'fetch' or 'img'
95
+ endedAt: entry.responseEnd - interactionStartTime,
95
96
  responseEnd: entry.responseEnd,
96
97
  browserCacheHit: entry.transferSize === 0,
97
98
  nextHopProtocol: entry.nextHopProtocol