@atlaskit/media-card 76.0.2 → 76.0.4

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 76.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8b83c75ef6d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8b83c75ef6d) - MEX-2382 Fixed a bug in media card so that the card preview updates when the provided file identifier is different
8
+
9
+ ## 76.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5dcaf51b269`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5dcaf51b269) - removed unused memory cache logs
14
+ - Updated dependencies
15
+
3
16
  ## 76.0.2
4
17
 
5
18
  ### Patch Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.CardBase = exports.Card = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -48,7 +49,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
48
49
  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); }; }
49
50
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
50
51
  var packageName = "@atlaskit/media-card";
51
- var packageVersion = "76.0.2";
52
+ var packageVersion = "76.0.4";
52
53
  var CardBase = /*#__PURE__*/function (_Component) {
53
54
  (0, _inherits2.default)(CardBase, _Component);
54
55
  var _super = _createSuper(CardBase);
@@ -776,7 +777,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
776
777
  previewDidRender = _this$state4.previewDidRender,
777
778
  isPlayingFile = _this$state4.isPlayingFile,
778
779
  wasResolvedUpfrontPreview = _this$state4.wasResolvedUpfrontPreview;
779
- var isDifferent = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
780
+ var isDiffIdentifier = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
780
781
  /**
781
782
  * Variable turnedVisible should only be true when media card
782
783
  * was invisible in the previous state and is visible in the current one
@@ -794,7 +795,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
794
795
  var isNewMediaClient = prevMediaClient !== mediaClient;
795
796
  var fileImageMode = (0, _mediaClient2.imageResizeModeToFileImageMode)(resizeMode);
796
797
  this.updateFileStateFlag(fileState);
797
- if ((0, _mediaClient2.isExternalImageIdentifier)(identifier) && isDifferent) {
798
+ if ((0, _mediaClient2.isExternalImageIdentifier)(identifier) && isDiffIdentifier) {
798
799
  this.fireCommencedEvent();
799
800
  var dataURI = identifier.dataURI;
800
801
  this.setState({
@@ -807,7 +808,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
807
808
  isCardVisible: true
808
809
  });
809
810
  }
810
- if ((0, _mediaClient2.isFileIdentifier)(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
811
+ if ((0, _mediaClient2.isFileIdentifier)(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDiffIdentifier))) {
811
812
  this.updateStateForIdentifier(identifier);
812
813
  }
813
814
  if (this.state.status !== prevState.status) {
@@ -999,7 +1000,7 @@ var CardBase = /*#__PURE__*/function (_Component) {
999
1000
  }
1000
1001
  }]);
1001
1002
  return CardBase;
1002
- }(_react.Component);
1003
+ }(_react.Component); // We require this wrapper in order to refresh media card state when the identifier is updated
1003
1004
  exports.CardBase = CardBase;
1004
1005
  (0, _defineProperty2.default)(CardBase, "defaultProps", {
1005
1006
  appearance: 'auto',
@@ -1009,12 +1010,19 @@ exports.CardBase = CardBase;
1009
1010
  // Media Feature Flag defaults are defined in @atlaskit/media-common
1010
1011
  featureFlags: {}
1011
1012
  });
1013
+ var CardWithKey = function CardWithKey(props) {
1014
+ var identifier = props.identifier;
1015
+ var key = (0, _mediaClient2.isFileIdentifier)(identifier) ? identifier.id : identifier.dataURI;
1016
+ return /*#__PURE__*/_react.default.createElement(CardBase, (0, _extends2.default)({}, props, {
1017
+ key: key
1018
+ }));
1019
+ };
1012
1020
  var Card = (0, _mediaCommon.withMediaAnalyticsContext)({
1013
1021
  packageVersion: packageVersion,
1014
1022
  packageName: packageName,
1015
1023
  componentName: 'mediaCard',
1016
1024
  component: 'mediaCard'
1017
- })((0, _analyticsNext.withAnalyticsEvents)()((0, _reactIntlNext.injectIntl)(CardBase, {
1025
+ })((0, _analyticsNext.withAnalyticsEvents)()((0, _reactIntlNext.injectIntl)(CardWithKey, {
1018
1026
  enforceContext: false
1019
1027
  })));
1020
1028
  exports.Card = Card;
@@ -42,7 +42,6 @@ var _helpers = require("./helpers");
42
42
  var _errors = require("../../errors");
43
43
  var _dimensionComparer = require("../../utils/dimensionComparer");
44
44
  var _filePreviewStatus = require("./filePreviewStatus");
45
- var _imageRefetchingAnalytics = require("./imageRefetchingAnalytics");
46
45
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
47
46
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
48
47
  var getCardPreviewFromCache = _cache.default.get;
@@ -109,37 +108,29 @@ var getCardPreview = /*#__PURE__*/function () {
109
108
  cachedPreview = _cache.default.get(id, mode);
110
109
  dimensionsAreBigger = (0, _dimensionComparer.isBigger)(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions);
111
110
  if (!(cachedPreview && !dimensionsAreBigger)) {
112
- _context.next = 7;
111
+ _context.next = 6;
113
112
  break;
114
113
  }
115
- if ((0, _mediaCommon.getMediaFeatureFlag)('memoryCacheLogging', featureFlags)) {
116
- createAnalyticsEvent && (0, _imageRefetchingAnalytics.fireImageFetchingOperationalEvent)(createAnalyticsEvent, 'cache-hit', {
117
- fileId: id,
118
- prevDimensions: cachedPreview.dimensions,
119
- currentDimensions: dimensions,
120
- source: cachedPreview.source
121
- });
122
- }
123
114
  return _context.abrupt("return", cachedPreview);
124
- case 7:
125
- _context.prev = 7;
115
+ case 6:
116
+ _context.prev = 6;
126
117
  if (!filePreview) {
127
- _context.next = 13;
118
+ _context.next = 12;
128
119
  break;
129
120
  }
130
- _context.next = 11;
121
+ _context.next = 10;
131
122
  return (0, _helpers.getCardPreviewFromFilePreview)(filePreview);
132
- case 11:
123
+ case 10:
133
124
  localPreview = _context.sent;
134
125
  return _context.abrupt("return", extendAndCachePreview(id, mode, _objectSpread(_objectSpread({}, localPreview), {}, {
135
126
  dimensions: dimensions
136
127
  }), mediaBlobUrlAttrs));
137
- case 13:
138
- _context.next = 20;
128
+ case 12:
129
+ _context.next = 19;
139
130
  break;
140
- case 15:
141
- _context.prev = 15;
142
- _context.t0 = _context["catch"](7);
131
+ case 14:
132
+ _context.prev = 14;
133
+ _context.t0 = _context["catch"](6);
143
134
  /**
144
135
  * We report the error if:
145
136
  * - local preview is supported and fails
@@ -158,36 +149,27 @@ var getCardPreview = /*#__PURE__*/function () {
158
149
  * if there is no remote preview available
159
150
  */
160
151
  if (isRemotePreviewReady) {
161
- _context.next = 20;
152
+ _context.next = 19;
162
153
  break;
163
154
  }
164
155
  throw _context.t0;
165
- case 20:
156
+ case 19:
166
157
  if (isRemotePreviewReady) {
167
- _context.next = 22;
158
+ _context.next = 21;
168
159
  break;
169
160
  }
170
161
  throw new _errors.MediaCardError('remote-preview-not-ready');
171
- case 22:
172
- _context.next = 24;
162
+ case 21:
163
+ _context.next = 23;
173
164
  return fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
174
- case 24:
165
+ case 23:
175
166
  remotePreview = _context.sent;
176
- if ((0, _mediaCommon.getMediaFeatureFlag)('memoryCacheLogging', featureFlags)) {
177
- createAnalyticsEvent && (0, _imageRefetchingAnalytics.fireImageFetchingOperationalEvent)(createAnalyticsEvent, 'remote-success', {
178
- fileId: id,
179
- prevDimensions: cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions,
180
- currentDimensions: dimensions,
181
- dimensionsPercentageDiff: (0, _imageRefetchingAnalytics.calculatePercentageDifference)(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions),
182
- source: remotePreview.source
183
- });
184
- }
185
167
  return _context.abrupt("return", remotePreview);
186
- case 27:
168
+ case 25:
187
169
  case "end":
188
170
  return _context.stop();
189
171
  }
190
- }, _callee, null, [[7, 15]]);
172
+ }, _callee, null, [[6, 14]]);
191
173
  }));
192
174
  return function getCardPreview(_x) {
193
175
  return _ref2.apply(this, arguments);
@@ -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 = "76.0.2";
93
+ var packageVersion = "76.0.4";
94
94
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
95
95
  packageVersion: packageVersion,
96
96
  packageName: packageName,
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
119
119
  ErrorBoundary = _this$state.ErrorBoundary;
120
120
  var analyticsContext = {
121
121
  packageVersion: "@atlaskit/media-card",
122
- packageName: "76.0.2",
122
+ packageName: "76.0.4",
123
123
  componentName: 'mediaInlineCard',
124
124
  component: 'mediaInlineCard'
125
125
  };
@@ -14,7 +14,7 @@ var _mediaClient = require("@atlaskit/media-client");
14
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
16
  var packageName = "@atlaskit/media-card";
17
- var packageVersion = "76.0.2";
17
+ var packageVersion = "76.0.4";
18
18
  var concurrentExperience;
19
19
  var getExperience = function getExperience(id) {
20
20
  if (!concurrentExperience) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "76.0.2",
3
+ "version": "76.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import React, { Component, Suspense } from 'react';
3
4
  import ReactDOM from 'react-dom';
@@ -27,7 +28,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
27
28
  import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
28
29
  import { generateUniqueId } from '../utils/generateUniqueId';
29
30
  const packageName = "@atlaskit/media-card";
30
- const packageVersion = "76.0.2";
31
+ const packageVersion = "76.0.4";
31
32
  export class CardBase extends Component {
32
33
  constructor(props) {
33
34
  super(props);
@@ -754,7 +755,7 @@ export class CardBase extends Component {
754
755
  isPlayingFile,
755
756
  wasResolvedUpfrontPreview
756
757
  } = this.state;
757
- const isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
758
+ const isDiffIdentifier = isDifferentIdentifier(prevIdentifier, identifier);
758
759
  /**
759
760
  * Variable turnedVisible should only be true when media card
760
761
  * was invisible in the previous state and is visible in the current one
@@ -772,7 +773,7 @@ export class CardBase extends Component {
772
773
  const isNewMediaClient = prevMediaClient !== mediaClient;
773
774
  const fileImageMode = imageResizeModeToFileImageMode(resizeMode);
774
775
  this.updateFileStateFlag(fileState);
775
- if (isExternalImageIdentifier(identifier) && isDifferent) {
776
+ if (isExternalImageIdentifier(identifier) && isDiffIdentifier) {
776
777
  this.fireCommencedEvent();
777
778
  const {
778
779
  dataURI
@@ -787,7 +788,7 @@ export class CardBase extends Component {
787
788
  isCardVisible: true
788
789
  });
789
790
  }
790
- if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
791
+ if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDiffIdentifier))) {
791
792
  this.updateStateForIdentifier(identifier);
792
793
  }
793
794
  if (this.state.status !== prevState.status) {
@@ -976,6 +977,8 @@ export class CardBase extends Component {
976
977
  }, innerContent);
977
978
  }
978
979
  }
980
+
981
+ // We require this wrapper in order to refresh media card state when the identifier is updated
979
982
  _defineProperty(CardBase, "defaultProps", {
980
983
  appearance: 'auto',
981
984
  resizeMode: 'crop',
@@ -984,11 +987,20 @@ _defineProperty(CardBase, "defaultProps", {
984
987
  // Media Feature Flag defaults are defined in @atlaskit/media-common
985
988
  featureFlags: {}
986
989
  });
990
+ const CardWithKey = props => {
991
+ const {
992
+ identifier
993
+ } = props;
994
+ const key = isFileIdentifier(identifier) ? identifier.id : identifier.dataURI;
995
+ return /*#__PURE__*/React.createElement(CardBase, _extends({}, props, {
996
+ key: key
997
+ }));
998
+ };
987
999
  export const Card = withMediaAnalyticsContext({
988
1000
  packageVersion,
989
1001
  packageName,
990
1002
  componentName: 'mediaCard',
991
1003
  component: 'mediaCard'
992
- })(withAnalyticsEvents()(injectIntl(CardBase, {
1004
+ })(withAnalyticsEvents()(injectIntl(CardWithKey, {
993
1005
  enforceContext: false
994
1006
  })));
@@ -5,8 +5,6 @@ import { getCardPreviewFromFilePreview, getCardPreviewFromBackend } from './help
5
5
  import { MediaCardError, SsrPreviewError, isUnsupportedLocalPreviewError } from '../../errors';
6
6
  import { isBigger } from '../../utils/dimensionComparer';
7
7
  import { extractFilePreviewStatus, isPreviewableStatus } from './filePreviewStatus';
8
- import { fireImageFetchingOperationalEvent, calculatePercentageDifference } from './imageRefetchingAnalytics';
9
- import { getMediaFeatureFlag } from '@atlaskit/media-common';
10
8
  export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview } from './helpers';
11
9
  export { extractFilePreviewStatus } from './filePreviewStatus';
12
10
  export const getCardPreviewFromCache = cardPreviewCache.get;
@@ -76,14 +74,6 @@ export const getCardPreview = async ({
76
74
  const cachedPreview = cardPreviewCache.get(id, mode);
77
75
  const dimensionsAreBigger = isBigger(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions);
78
76
  if (cachedPreview && !dimensionsAreBigger) {
79
- if (getMediaFeatureFlag('memoryCacheLogging', featureFlags)) {
80
- createAnalyticsEvent && fireImageFetchingOperationalEvent(createAnalyticsEvent, 'cache-hit', {
81
- fileId: id,
82
- prevDimensions: cachedPreview.dimensions,
83
- currentDimensions: dimensions,
84
- source: cachedPreview.source
85
- });
86
- }
87
77
  return cachedPreview;
88
78
  }
89
79
  try {
@@ -126,15 +116,6 @@ export const getCardPreview = async ({
126
116
  throw new MediaCardError('remote-preview-not-ready');
127
117
  }
128
118
  const remotePreview = await fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
129
- if (getMediaFeatureFlag('memoryCacheLogging', featureFlags)) {
130
- createAnalyticsEvent && fireImageFetchingOperationalEvent(createAnalyticsEvent, 'remote-success', {
131
- fileId: id,
132
- prevDimensions: cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions,
133
- currentDimensions: dimensions,
134
- dimensionsPercentageDiff: calculatePercentageDifference(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions),
135
- source: remotePreview.source
136
- });
137
- }
138
119
  return remotePreview;
139
120
  };
140
121
  export const shouldResolvePreview = ({
@@ -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 = "76.0.2";
69
+ const packageVersion = "76.0.4";
70
70
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
71
71
  packageVersion,
72
72
  packageName,
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "76.0.2",
40
+ packageName: "76.0.4",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -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 = "76.0.2";
7
+ const packageVersion = "76.0.4";
8
8
  let concurrentExperience;
9
9
  const getExperience = id => {
10
10
  if (!concurrentExperience) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "76.0.2",
3
+ "version": "76.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
@@ -40,7 +41,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
40
41
  import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
41
42
  import { generateUniqueId } from '../utils/generateUniqueId';
42
43
  var packageName = "@atlaskit/media-card";
43
- var packageVersion = "76.0.2";
44
+ var packageVersion = "76.0.4";
44
45
  export var CardBase = /*#__PURE__*/function (_Component) {
45
46
  _inherits(CardBase, _Component);
46
47
  var _super = _createSuper(CardBase);
@@ -768,7 +769,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
768
769
  previewDidRender = _this$state4.previewDidRender,
769
770
  isPlayingFile = _this$state4.isPlayingFile,
770
771
  wasResolvedUpfrontPreview = _this$state4.wasResolvedUpfrontPreview;
771
- var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
772
+ var isDiffIdentifier = isDifferentIdentifier(prevIdentifier, identifier);
772
773
  /**
773
774
  * Variable turnedVisible should only be true when media card
774
775
  * was invisible in the previous state and is visible in the current one
@@ -786,7 +787,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
786
787
  var isNewMediaClient = prevMediaClient !== mediaClient;
787
788
  var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
788
789
  this.updateFileStateFlag(fileState);
789
- if (isExternalImageIdentifier(identifier) && isDifferent) {
790
+ if (isExternalImageIdentifier(identifier) && isDiffIdentifier) {
790
791
  this.fireCommencedEvent();
791
792
  var dataURI = identifier.dataURI;
792
793
  this.setState({
@@ -799,7 +800,7 @@ export var CardBase = /*#__PURE__*/function (_Component) {
799
800
  isCardVisible: true
800
801
  });
801
802
  }
802
- if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDifferent))) {
803
+ if (isFileIdentifier(identifier) && (turnedVisible || !!this.subscription && (isNewMediaClient || isDiffIdentifier))) {
803
804
  this.updateStateForIdentifier(identifier);
804
805
  }
805
806
  if (this.state.status !== prevState.status) {
@@ -992,6 +993,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
992
993
  }]);
993
994
  return CardBase;
994
995
  }(Component);
996
+
997
+ // We require this wrapper in order to refresh media card state when the identifier is updated
995
998
  _defineProperty(CardBase, "defaultProps", {
996
999
  appearance: 'auto',
997
1000
  resizeMode: 'crop',
@@ -1000,11 +1003,18 @@ _defineProperty(CardBase, "defaultProps", {
1000
1003
  // Media Feature Flag defaults are defined in @atlaskit/media-common
1001
1004
  featureFlags: {}
1002
1005
  });
1006
+ var CardWithKey = function CardWithKey(props) {
1007
+ var identifier = props.identifier;
1008
+ var key = isFileIdentifier(identifier) ? identifier.id : identifier.dataURI;
1009
+ return /*#__PURE__*/React.createElement(CardBase, _extends({}, props, {
1010
+ key: key
1011
+ }));
1012
+ };
1003
1013
  export var Card = withMediaAnalyticsContext({
1004
1014
  packageVersion: packageVersion,
1005
1015
  packageName: packageName,
1006
1016
  componentName: 'mediaCard',
1007
1017
  component: 'mediaCard'
1008
- })(withAnalyticsEvents()(injectIntl(CardBase, {
1018
+ })(withAnalyticsEvents()(injectIntl(CardWithKey, {
1009
1019
  enforceContext: false
1010
1020
  })));
@@ -10,8 +10,6 @@ import { getCardPreviewFromFilePreview, getCardPreviewFromBackend } from './help
10
10
  import { MediaCardError, SsrPreviewError, isUnsupportedLocalPreviewError } from '../../errors';
11
11
  import { isBigger } from '../../utils/dimensionComparer';
12
12
  import { extractFilePreviewStatus, isPreviewableStatus } from './filePreviewStatus';
13
- import { fireImageFetchingOperationalEvent, calculatePercentageDifference } from './imageRefetchingAnalytics';
14
- import { getMediaFeatureFlag } from '@atlaskit/media-common';
15
13
  export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview } from './helpers';
16
14
  export { extractFilePreviewStatus } from './filePreviewStatus';
17
15
  export var getCardPreviewFromCache = cardPreviewCache.get;
@@ -75,37 +73,29 @@ export var getCardPreview = /*#__PURE__*/function () {
75
73
  cachedPreview = cardPreviewCache.get(id, mode);
76
74
  dimensionsAreBigger = isBigger(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions);
77
75
  if (!(cachedPreview && !dimensionsAreBigger)) {
78
- _context.next = 7;
76
+ _context.next = 6;
79
77
  break;
80
78
  }
81
- if (getMediaFeatureFlag('memoryCacheLogging', featureFlags)) {
82
- createAnalyticsEvent && fireImageFetchingOperationalEvent(createAnalyticsEvent, 'cache-hit', {
83
- fileId: id,
84
- prevDimensions: cachedPreview.dimensions,
85
- currentDimensions: dimensions,
86
- source: cachedPreview.source
87
- });
88
- }
89
79
  return _context.abrupt("return", cachedPreview);
90
- case 7:
91
- _context.prev = 7;
80
+ case 6:
81
+ _context.prev = 6;
92
82
  if (!filePreview) {
93
- _context.next = 13;
83
+ _context.next = 12;
94
84
  break;
95
85
  }
96
- _context.next = 11;
86
+ _context.next = 10;
97
87
  return getCardPreviewFromFilePreview(filePreview);
98
- case 11:
88
+ case 10:
99
89
  localPreview = _context.sent;
100
90
  return _context.abrupt("return", extendAndCachePreview(id, mode, _objectSpread(_objectSpread({}, localPreview), {}, {
101
91
  dimensions: dimensions
102
92
  }), mediaBlobUrlAttrs));
103
- case 13:
104
- _context.next = 20;
93
+ case 12:
94
+ _context.next = 19;
105
95
  break;
106
- case 15:
107
- _context.prev = 15;
108
- _context.t0 = _context["catch"](7);
96
+ case 14:
97
+ _context.prev = 14;
98
+ _context.t0 = _context["catch"](6);
109
99
  /**
110
100
  * We report the error if:
111
101
  * - local preview is supported and fails
@@ -124,36 +114,27 @@ export var getCardPreview = /*#__PURE__*/function () {
124
114
  * if there is no remote preview available
125
115
  */
126
116
  if (isRemotePreviewReady) {
127
- _context.next = 20;
117
+ _context.next = 19;
128
118
  break;
129
119
  }
130
120
  throw _context.t0;
131
- case 20:
121
+ case 19:
132
122
  if (isRemotePreviewReady) {
133
- _context.next = 22;
123
+ _context.next = 21;
134
124
  break;
135
125
  }
136
126
  throw new MediaCardError('remote-preview-not-ready');
137
- case 22:
138
- _context.next = 24;
127
+ case 21:
128
+ _context.next = 23;
139
129
  return fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
140
- case 24:
130
+ case 23:
141
131
  remotePreview = _context.sent;
142
- if (getMediaFeatureFlag('memoryCacheLogging', featureFlags)) {
143
- createAnalyticsEvent && fireImageFetchingOperationalEvent(createAnalyticsEvent, 'remote-success', {
144
- fileId: id,
145
- prevDimensions: cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions,
146
- currentDimensions: dimensions,
147
- dimensionsPercentageDiff: calculatePercentageDifference(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions),
148
- source: remotePreview.source
149
- });
150
- }
151
132
  return _context.abrupt("return", remotePreview);
152
- case 27:
133
+ case 25:
153
134
  case "end":
154
135
  return _context.stop();
155
136
  }
156
- }, _callee, null, [[7, 15]]);
137
+ }, _callee, null, [[6, 14]]);
157
138
  }));
158
139
  return function getCardPreview(_x) {
159
140
  return _ref2.apply(this, arguments);
@@ -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 = "76.0.2";
86
+ var packageVersion = "76.0.4";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
103
103
  ErrorBoundary = _this$state.ErrorBoundary;
104
104
  var analyticsContext = {
105
105
  packageVersion: "@atlaskit/media-card",
106
- packageName: "76.0.2",
106
+ packageName: "76.0.4",
107
107
  componentName: 'mediaInlineCard',
108
108
  component: 'mediaInlineCard'
109
109
  };
@@ -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 = "76.0.2";
10
+ var packageVersion = "76.0.4";
11
11
  var concurrentExperience;
12
12
  var getExperience = function getExperience(id) {
13
13
  if (!concurrentExperience) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "76.0.2",
3
+ "version": "76.0.4",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "76.0.2",
3
+ "version": "76.0.4",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,7 +30,7 @@
30
30
  "atlassian": {
31
31
  "team": "Media Experience",
32
32
  "inPublicMirror": true,
33
- "releaseModel": "scheduled",
33
+ "releaseModel": "continuous",
34
34
  "website": {
35
35
  "name": "Media Card"
36
36
  }
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/editor-shared-styles": "^2.4.0",
42
42
  "@atlaskit/icon": "^21.12.0",
43
43
  "@atlaskit/media-client": "^23.0.0",
44
- "@atlaskit/media-common": "^6.0.0",
44
+ "@atlaskit/media-common": "^7.0.0",
45
45
  "@atlaskit/media-ui": "^23.0.0",
46
46
  "@atlaskit/media-viewer": "^48.0.0",
47
47
  "@atlaskit/spinner": "^15.5.0",
@@ -0,0 +1,341 @@
1
+ ## API Report File for "@atlaskit/media-card"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ /// <reference types="react" />
8
+
9
+ import { Component } from 'react';
10
+ import { FileDetails } from '@atlaskit/media-client';
11
+ import { FileIdentifier } from '@atlaskit/media-client';
12
+ import { FileItem } from '@atlaskit/media-client';
13
+ import { FileState } from '@atlaskit/media-client';
14
+ import { Identifier } from '@atlaskit/media-client';
15
+ import { ImageResizeMode } from '@atlaskit/media-client';
16
+ import { MediaClient } from '@atlaskit/media-client';
17
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
18
+ import { MouseEvent as MouseEvent_2 } from 'react';
19
+ import { NumericalCardDimensions } from '@atlaskit/media-common';
20
+ import { default as React_2 } from 'react';
21
+ import { ReactNode } from 'react';
22
+ import { SSR } from '@atlaskit/media-common';
23
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
24
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
25
+ import { WithMediaClientConfigProps } from '@atlaskit/media-client';
26
+ import { WrappedComponentProps } from 'react-intl-next';
27
+
28
+ // @public (undocumented)
29
+ export const Card: React_2.FC<CardWithMediaClientConfigProps>;
30
+
31
+ // @public (undocumented)
32
+ export interface CardAction {
33
+ // (undocumented)
34
+ handler: CardEventHandler;
35
+ // (undocumented)
36
+ icon?: ReactNode;
37
+ // (undocumented)
38
+ label?: string;
39
+ }
40
+
41
+ // @public (undocumented)
42
+ export type CardAppearance = 'auto' | 'horizontal' | 'image' | 'square';
43
+
44
+ // @public (undocumented)
45
+ type CardBaseProps = CardProps & WithAnalyticsEventsProps & Partial<WrappedComponentProps>;
46
+
47
+ // @public (undocumented)
48
+ export interface CardDimensions {
49
+ // (undocumented)
50
+ height?: CardDimensionValue;
51
+ // (undocumented)
52
+ width?: CardDimensionValue;
53
+ }
54
+
55
+ // @public (undocumented)
56
+ export type CardDimensionValue = number | string;
57
+
58
+ // @public (undocumented)
59
+ export class CardError extends Component<ErrorCardProps, {}> {
60
+ // (undocumented)
61
+ static defaultProps: {
62
+ size: string;
63
+ };
64
+ // (undocumented)
65
+ get icon(): JSX.Element;
66
+ // (undocumented)
67
+ render(): JSX.Element;
68
+ }
69
+
70
+ // @public (undocumented)
71
+ export interface CardEvent {
72
+ // (undocumented)
73
+ event: MouseEvent_2<HTMLElement>;
74
+ // (undocumented)
75
+ mediaItemDetails?: FileDetails;
76
+ }
77
+
78
+ // @public (undocumented)
79
+ export type CardEventHandler = (item?: FileItem, event?: Event) => void;
80
+
81
+ // @public (undocumented)
82
+ interface CardEventProps {
83
+ // (undocumented)
84
+ readonly onClick?: CardOnClickCallback;
85
+ readonly onFullscreenChange?: (fullscreen: boolean) => void;
86
+ // (undocumented)
87
+ readonly onMouseEnter?: (result: CardEvent) => void;
88
+ }
89
+
90
+ // @public (undocumented)
91
+ export class CardLoading extends Component<StaticCardProps, {}> {
92
+ // (undocumented)
93
+ render(): JSX.Element;
94
+ }
95
+
96
+ // @public (undocumented)
97
+ export interface CardOnClickCallback {
98
+ // (undocumented)
99
+ (result: CardEvent, analyticsEvent?: UIAnalyticsEvent): void;
100
+ }
101
+
102
+ // @public (undocumented)
103
+ export interface CardPreview {
104
+ // (undocumented)
105
+ dataURI: string;
106
+ // (undocumented)
107
+ dimensions?: CardDimensions;
108
+ // (undocumented)
109
+ orientation?: number;
110
+ // (undocumented)
111
+ source: CardPreviewSource;
112
+ }
113
+
114
+ // @public (undocumented)
115
+ type CardPreviewSource = 'cache-local' | 'cache-remote' | 'cache-ssr-client' | 'cache-ssr-server' | 'external' | 'local' | 'remote' | 'ssr-client' | 'ssr-data' | 'ssr-server';
116
+
117
+ // @public (undocumented)
118
+ export interface CardProps extends SharedCardProps, CardEventProps {
119
+ // (undocumented)
120
+ readonly contextId?: string;
121
+ // (undocumented)
122
+ readonly identifier: Identifier;
123
+ // (undocumented)
124
+ readonly isLazy?: boolean;
125
+ // (undocumented)
126
+ readonly mediaClient: MediaClient;
127
+ // (undocumented)
128
+ readonly mediaViewerItems?: Identifier[];
129
+ // (undocumented)
130
+ readonly shouldEnableDownloadButton?: boolean;
131
+ // (undocumented)
132
+ readonly shouldOpenMediaViewer?: boolean;
133
+ // (undocumented)
134
+ readonly ssr?: SSR;
135
+ // (undocumented)
136
+ readonly useInlinePlayer?: boolean;
137
+ }
138
+
139
+ // @public (undocumented)
140
+ export interface CardState {
141
+ // (undocumented)
142
+ cardPreview?: CardPreview;
143
+ // (undocumented)
144
+ cardRef: HTMLDivElement | null;
145
+ // (undocumented)
146
+ error?: MediaCardError;
147
+ // (undocumented)
148
+ fileState?: FileState;
149
+ // (undocumented)
150
+ isBannedLocalPreview: boolean;
151
+ // (undocumented)
152
+ isCardVisible: boolean;
153
+ // (undocumented)
154
+ isPlayingFile: boolean;
155
+ // (undocumented)
156
+ mediaViewerSelectedItem?: Identifier;
157
+ // (undocumented)
158
+ previewDidRender: boolean;
159
+ // (undocumented)
160
+ progress?: number;
161
+ // (undocumented)
162
+ shouldAutoplay?: boolean;
163
+ // (undocumented)
164
+ status: CardStatus;
165
+ // (undocumented)
166
+ wasResolvedUpfrontPreview: boolean;
167
+ }
168
+
169
+ // @public (undocumented)
170
+ export type CardStatus = 'complete' | 'error' | 'failed-processing' | 'loading' | 'loading-preview' | 'processing' | 'uploading';
171
+
172
+ // @public (undocumented)
173
+ type CardWithMediaClientConfigProps = WithMediaClientConfigProps<CardBaseProps>;
174
+
175
+ // @public (undocumented)
176
+ export const defaultImageCardDimensions: {
177
+ width: number;
178
+ height: number;
179
+ };
180
+
181
+ // @public (undocumented)
182
+ type ErrorBoundaryComponent = React_2.ComponentType<{
183
+ data?: {
184
+ [k: string]: any;
185
+ };
186
+ isSelected?: boolean;
187
+ }>;
188
+
189
+ // @public (undocumented)
190
+ interface ErrorCardProps extends StaticCardProps {
191
+ // (undocumented)
192
+ readonly size: 'large' | 'medium' | 'small' | 'xlarge';
193
+ }
194
+
195
+ // @public (undocumented)
196
+ export const fileCardImageViewSelector = "media-file-card-view";
197
+
198
+ // @public (undocumented)
199
+ type ImageLoadPrimaryReason = 'cache-local-uri' | 'cache-remote-uri' | 'external-uri' | 'local-uri' | 'remote-uri' | 'unknown-uri';
200
+
201
+ // @public (undocumented)
202
+ export interface InlineCardEvent {
203
+ // (undocumented)
204
+ event: MouseEvent_2<HTMLElement> | React.KeyboardEvent;
205
+ // (undocumented)
206
+ mediaItemDetails?: FileDetails;
207
+ }
208
+
209
+ // @public (undocumented)
210
+ export interface InlineCardOnClickCallback {
211
+ // (undocumented)
212
+ (result: InlineCardEvent, analyticsEvent?: UIAnalyticsEvent): void;
213
+ }
214
+
215
+ // @public (undocumented)
216
+ export const inlinePlayerClassName = "media-card-inline-player";
217
+
218
+ // @public (undocumented)
219
+ type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-image' | 'local-preview-rejected' | 'local-preview-unsupported' | 'local-preview-video';
220
+
221
+ // @public (undocumented)
222
+ class MediaCardError extends Error {
223
+ constructor(primaryReason: MediaCardErrorPrimaryReason, secondaryError?: Error | undefined);
224
+ // (undocumented)
225
+ readonly primaryReason: MediaCardErrorPrimaryReason;
226
+ // (undocumented)
227
+ readonly secondaryError?: Error | undefined;
228
+ }
229
+
230
+ // @public
231
+ type MediaCardErrorPrimaryReason = 'error-file-state' | 'metadata-fetch' | 'missing-error-data' | 'preview-fetch' | 'upload' | ImageLoadPrimaryReason | LocalPreviewPrimaryReason | RemotePreviewPrimaryReason | SsrPreviewPrimaryReason;
232
+
233
+ // @public (undocumented)
234
+ export class MediaInlineCard extends React_2.PureComponent<MediaInlineCardWithMediaClientConfigProps & MediaInlineCardLoaderState, MediaInlineCardLoaderState> {
235
+ // (undocumented)
236
+ componentDidMount(): Promise<void>;
237
+ // (undocumented)
238
+ componentWillUnmount(): Promise<void>;
239
+ // (undocumented)
240
+ static displayName: string;
241
+ // (undocumented)
242
+ static ErrorBoundary?: ErrorBoundaryComponent;
243
+ // (undocumented)
244
+ static MediaInlineCard?: MediaInlineCardWithMediaClientConfigComponent;
245
+ // (undocumented)
246
+ mounted: boolean;
247
+ // (undocumented)
248
+ render(): JSX.Element;
249
+ // (undocumented)
250
+ state: MediaInlineCardLoaderState;
251
+ }
252
+
253
+ // @public (undocumented)
254
+ interface MediaInlineCardLoaderState {
255
+ // (undocumented)
256
+ ErrorBoundary?: ErrorBoundaryComponent;
257
+ // (undocumented)
258
+ MediaInlineCard?: MediaInlineCardWithMediaClientConfigComponent;
259
+ }
260
+
261
+ // @public (undocumented)
262
+ interface MediaInlineCardProps {
263
+ // (undocumented)
264
+ identifier: FileIdentifier;
265
+ // (undocumented)
266
+ isSelected?: boolean;
267
+ // (undocumented)
268
+ mediaClient: MediaClient;
269
+ // (undocumented)
270
+ mediaViewerItems?: Identifier[];
271
+ // (undocumented)
272
+ onClick?: InlineCardOnClickCallback;
273
+ // (undocumented)
274
+ shouldDisplayToolTip?: boolean;
275
+ // (undocumented)
276
+ shouldOpenMediaViewer?: boolean;
277
+ }
278
+
279
+ // @public (undocumented)
280
+ type MediaInlineCardWithMediaClientConfigComponent = React_2.ComponentType<MediaInlineCardWithMediaClientConfigProps>;
281
+
282
+ // @public (undocumented)
283
+ type MediaInlineCardWithMediaClientConfigProps = WithMediaClientConfigProps<MediaInlineCardProps>;
284
+
285
+ // @public (undocumented)
286
+ export const newFileExperienceClassName = "new-file-experience-wrapper";
287
+
288
+ export { NumericalCardDimensions }
289
+
290
+ // @public (undocumented)
291
+ type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-fetch-ssr' | 'remote-preview-not-ready';
292
+
293
+ // @public (undocumented)
294
+ export interface SharedCardProps {
295
+ // (undocumented)
296
+ readonly actions?: Array<CardAction>;
297
+ // (undocumented)
298
+ readonly alt?: string;
299
+ // (undocumented)
300
+ readonly appearance?: CardAppearance;
301
+ // (undocumented)
302
+ readonly dimensions?: CardDimensions;
303
+ // (undocumented)
304
+ readonly disableOverlay?: boolean;
305
+ // (undocumented)
306
+ readonly featureFlags?: MediaFeatureFlags;
307
+ // (undocumented)
308
+ readonly originalDimensions?: NumericalCardDimensions;
309
+ // (undocumented)
310
+ readonly resizeMode?: ImageResizeMode;
311
+ // (undocumented)
312
+ readonly selectable?: boolean;
313
+ // (undocumented)
314
+ readonly selected?: boolean;
315
+ // (undocumented)
316
+ readonly testId?: string;
317
+ // (undocumented)
318
+ readonly titleBoxBgColor?: string;
319
+ // (undocumented)
320
+ readonly titleBoxIcon?: TitleBoxIcon;
321
+ }
322
+
323
+ // @public (undocumented)
324
+ type SsrPreviewPrimaryReason = 'ssr-client-load' | 'ssr-client-uri' | 'ssr-server-load' | 'ssr-server-uri';
325
+
326
+ // @public (undocumented)
327
+ interface StaticCardProps {
328
+ // (undocumented)
329
+ dimensions?: CardDimensions;
330
+ // (undocumented)
331
+ featureFlags?: MediaFeatureFlags;
332
+ // (undocumented)
333
+ testId?: string;
334
+ }
335
+
336
+ // @public (undocumented)
337
+ export type TitleBoxIcon = 'LockFilledIcon';
338
+
339
+ // (No @packageDocumentation comment for this package)
340
+
341
+ ```
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fireImageFetchingOperationalEvent = exports.calculatePercentageDifference = void 0;
7
- var _analytics = require("../../utils/analytics");
8
- var fireImageFetchingOperationalEvent = function fireImageFetchingOperationalEvent(createAnalyticsEvent, action, cardPreviewAttributes) {
9
- var fireEvent = function fireEvent(payload) {
10
- return (0, _analytics.fireMediaCardEvent)(payload, createAnalyticsEvent);
11
- };
12
- switch (action) {
13
- case 'cache-hit':
14
- fireEvent((0, _analytics.getCacheHitEventPayload)(cardPreviewAttributes));
15
- break;
16
- case 'remote-success':
17
- fireEvent((0, _analytics.getRemoteSuccessEventPayload)(cardPreviewAttributes));
18
- break;
19
- }
20
- };
21
- exports.fireImageFetchingOperationalEvent = fireImageFetchingOperationalEvent;
22
- var calculatePercentageDifference = function calculatePercentageDifference(prevDimensions, currentDimensions) {
23
- if (!prevDimensions) {
24
- return undefined;
25
- }
26
- var prevWidth = parseInt("".concat(prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.width), 10);
27
- var currWidth = parseInt("".concat(currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.width), 10);
28
- var prevHeight = parseInt("".concat(prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.height), 10);
29
- var currHeight = parseInt("".concat(currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.height), 10);
30
- var percentageDiffInWidth = ((currWidth - prevWidth) / prevWidth * 100).toFixed(2);
31
- var percentageDiffInHeight = ((currHeight - prevHeight) / prevHeight * 100).toFixed(2);
32
- return {
33
- width: percentageDiffInWidth,
34
- height: percentageDiffInHeight
35
- };
36
- };
37
- exports.calculatePercentageDifference = calculatePercentageDifference;
@@ -1,27 +0,0 @@
1
- import { fireMediaCardEvent, getCacheHitEventPayload, getRemoteSuccessEventPayload } from '../../utils/analytics';
2
- export const fireImageFetchingOperationalEvent = (createAnalyticsEvent, action, cardPreviewAttributes) => {
3
- const fireEvent = payload => fireMediaCardEvent(payload, createAnalyticsEvent);
4
- switch (action) {
5
- case 'cache-hit':
6
- fireEvent(getCacheHitEventPayload(cardPreviewAttributes));
7
- break;
8
- case 'remote-success':
9
- fireEvent(getRemoteSuccessEventPayload(cardPreviewAttributes));
10
- break;
11
- }
12
- };
13
- export const calculatePercentageDifference = (prevDimensions, currentDimensions) => {
14
- if (!prevDimensions) {
15
- return undefined;
16
- }
17
- const prevWidth = parseInt(`${prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.width}`, 10);
18
- const currWidth = parseInt(`${currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.width}`, 10);
19
- const prevHeight = parseInt(`${prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.height}`, 10);
20
- const currHeight = parseInt(`${currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.height}`, 10);
21
- const percentageDiffInWidth = ((currWidth - prevWidth) / prevWidth * 100).toFixed(2);
22
- const percentageDiffInHeight = ((currHeight - prevHeight) / prevHeight * 100).toFixed(2);
23
- return {
24
- width: percentageDiffInWidth,
25
- height: percentageDiffInHeight
26
- };
27
- };
@@ -1,29 +0,0 @@
1
- import { fireMediaCardEvent, getCacheHitEventPayload, getRemoteSuccessEventPayload } from '../../utils/analytics';
2
- export var fireImageFetchingOperationalEvent = function fireImageFetchingOperationalEvent(createAnalyticsEvent, action, cardPreviewAttributes) {
3
- var fireEvent = function fireEvent(payload) {
4
- return fireMediaCardEvent(payload, createAnalyticsEvent);
5
- };
6
- switch (action) {
7
- case 'cache-hit':
8
- fireEvent(getCacheHitEventPayload(cardPreviewAttributes));
9
- break;
10
- case 'remote-success':
11
- fireEvent(getRemoteSuccessEventPayload(cardPreviewAttributes));
12
- break;
13
- }
14
- };
15
- export var calculatePercentageDifference = function calculatePercentageDifference(prevDimensions, currentDimensions) {
16
- if (!prevDimensions) {
17
- return undefined;
18
- }
19
- var prevWidth = parseInt("".concat(prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.width), 10);
20
- var currWidth = parseInt("".concat(currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.width), 10);
21
- var prevHeight = parseInt("".concat(prevDimensions === null || prevDimensions === void 0 ? void 0 : prevDimensions.height), 10);
22
- var currHeight = parseInt("".concat(currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.height), 10);
23
- var percentageDiffInWidth = ((currWidth - prevWidth) / prevWidth * 100).toFixed(2);
24
- var percentageDiffInHeight = ((currHeight - prevHeight) / prevHeight * 100).toFixed(2);
25
- return {
26
- width: percentageDiffInWidth,
27
- height: percentageDiffInHeight
28
- };
29
- };
@@ -1,10 +0,0 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { CardDimensions } from '../../types';
3
- import { CardPreviewAttributes } from '../../utils/analytics';
4
- 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 {};
@@ -1,10 +0,0 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
- import { CardDimensions } from '../../types';
3
- import { CardPreviewAttributes } from '../../utils/analytics';
4
- 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 {};