@atlaskit/media-card 77.4.4 → 77.4.6

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 (31) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/card/card.js +42 -38
  3. package/dist/cjs/card/getCardPreview/filePreviewStatus.js +2 -0
  4. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  5. package/dist/cjs/card/v2/cardV2.js +1 -1
  6. package/dist/cjs/card/v2/fileCard.js +120 -521
  7. package/dist/cjs/card/v2/useFilePreview.js +592 -0
  8. package/dist/cjs/inline/loader.js +1 -1
  9. package/dist/cjs/utils/ufoExperiences.js +1 -1
  10. package/dist/es2019/card/card.js +7 -4
  11. package/dist/es2019/card/getCardPreview/filePreviewStatus.js +2 -0
  12. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  13. package/dist/es2019/card/v2/cardV2.js +1 -1
  14. package/dist/es2019/card/v2/fileCard.js +105 -436
  15. package/dist/es2019/card/v2/useFilePreview.js +499 -0
  16. package/dist/es2019/inline/loader.js +1 -1
  17. package/dist/es2019/utils/ufoExperiences.js +1 -1
  18. package/dist/esm/card/card.js +42 -38
  19. package/dist/esm/card/getCardPreview/filePreviewStatus.js +2 -0
  20. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  21. package/dist/esm/card/v2/cardV2.js +1 -1
  22. package/dist/esm/card/v2/fileCard.js +125 -526
  23. package/dist/esm/card/v2/useFilePreview.js +584 -0
  24. package/dist/esm/inline/loader.js +1 -1
  25. package/dist/esm/utils/ufoExperiences.js +1 -1
  26. package/dist/types/card/card.d.ts +1 -1
  27. package/dist/types/card/v2/useFilePreview.d.ts +38 -0
  28. package/dist/types-ts4.5/card/card.d.ts +1 -1
  29. package/dist/types-ts4.5/card/v2/useFilePreview.d.ts +38 -0
  30. package/package.json +4 -4
  31. package/tmp/api-report-tmp.d.ts +0 -345
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 77.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#56636](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/56636) [`eb1b7736ff9d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb1b7736ff9d) - Moved preview fetch logic from internal component into an internal hook
8
+
9
+ ## 77.4.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#43072](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43072) [`4c4278b7415`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4c4278b7415) - [ux] CXP-2744 Bug fix preventing an infinite loop from occurring when an error occurs in inline player
14
+ - Updated dependencies
15
+
3
16
  ## 77.4.4
4
17
 
5
18
  ### Patch Changes
@@ -49,7 +49,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
49
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); }; }
50
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; } }
51
51
  var packageName = "@atlaskit/media-card";
52
- var packageVersion = "77.4.4";
52
+ var packageVersion = "77.4.6";
53
53
  var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
54
54
  (0, _inherits2.default)(CardBase, _Component);
55
55
  var _super = _createSuper(CardBase);
@@ -400,7 +400,9 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
400
400
  identifier = _this$props5.identifier,
401
401
  useInlinePlayer = _this$props5.useInlinePlayer,
402
402
  shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
403
- var cardPreview = _this.state.cardPreview;
403
+ var _this$state = _this.state,
404
+ status = _this$state.status,
405
+ cardPreview = _this$state.cardPreview;
404
406
  var _assertThisInitialize2 = (0, _assertThisInitialized2.default)(_this),
405
407
  metadata = _assertThisInitialize2.metadata;
406
408
  _this.onClick(event, analyticsEvent);
@@ -408,7 +410,7 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
408
410
  return;
409
411
  }
410
412
  var isVideo = metadata && metadata.mediaType === 'video';
411
- if (useInlinePlayer && isVideo && !!cardPreview) {
413
+ if (useInlinePlayer && isVideo && !!cardPreview && status !== 'error') {
412
414
  _this.setState({
413
415
  isPlayingFile: true,
414
416
  shouldAutoplay: true
@@ -434,8 +436,10 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
434
436
  });
435
437
  }
436
438
  });
437
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInlinePlayerError", function () {
439
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInlinePlayerError", function (e) {
438
440
  _this.setState({
441
+ error: new _errors.MediaCardError('error-file-state', e),
442
+ status: 'error',
439
443
  isPlayingFile: false
440
444
  });
441
445
  });
@@ -453,9 +457,9 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
453
457
  testId = _this$props6.testId,
454
458
  originalDimensions = _this$props6.originalDimensions,
455
459
  onFullscreenChange = _this$props6.onFullscreenChange;
456
- var _this$state = _this.state,
457
- shouldAutoplay = _this$state.shouldAutoplay,
458
- cardPreview = _this$state.cardPreview;
460
+ var _this$state2 = _this.state,
461
+ shouldAutoplay = _this$state2.shouldAutoplay,
462
+ cardPreview = _this$state2.cardPreview;
459
463
  var card = _this.renderCard(false, 'loading', false);
460
464
  return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
461
465
  fallback: card
@@ -542,13 +546,13 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
542
546
  shouldOpenMediaViewer = _this$props8.shouldOpenMediaViewer,
543
547
  shouldHideTooltip = _this$props8.shouldHideTooltip;
544
548
  var mediaItemType = identifier.mediaItemType;
545
- var _this$state2 = _this.state,
546
- status = _this$state2.status,
547
- progress = _this$state2.progress,
548
- cardPreview = _this$state2.cardPreview,
549
- error = _this$state2.error,
550
- cardRef = _this$state2.cardRef,
551
- isCardVisible = _this$state2.isCardVisible;
549
+ var _this$state3 = _this.state,
550
+ status = _this$state3.status,
551
+ progress = _this$state3.progress,
552
+ cardPreview = _this$state3.cardPreview,
553
+ error = _this$state3.error,
554
+ cardRef = _this$state3.cardRef,
555
+ isCardVisible = _this$state3.isCardVisible;
552
556
  var _assertThisInitialize3 = (0, _assertThisInitialized2.default)(_this),
553
557
  metadata = _assertThisInitialize3.metadata;
554
558
  var _assertThisInitialize4 = (0, _assertThisInitialized2.default)(_this),
@@ -718,9 +722,9 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
718
722
  value: function componentDidMount() {
719
723
  var _getDocument;
720
724
  this.hasBeenMounted = true;
721
- var _this$state3 = this.state,
722
- isCardVisible = _this$state3.isCardVisible,
723
- cardPreview = _this$state3.cardPreview;
725
+ var _this$state4 = this.state,
726
+ isCardVisible = _this$state4.isCardVisible,
727
+ cardPreview = _this$state4.cardPreview;
724
728
  var _this$props11 = this.props,
725
729
  identifier = _this$props11.identifier,
726
730
  ssr = _this$props11.ssr,
@@ -768,15 +772,15 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
768
772
  useInlinePlayer = _this$props12.useInlinePlayer,
769
773
  disableOverlay = _this$props12.disableOverlay,
770
774
  ssr = _this$props12.ssr;
771
- var _this$state4 = this.state,
772
- isCardVisible = _this$state4.isCardVisible,
773
- cardPreview = _this$state4.cardPreview,
774
- status = _this$state4.status,
775
- fileState = _this$state4.fileState,
776
- isBannedLocalPreview = _this$state4.isBannedLocalPreview,
777
- previewDidRender = _this$state4.previewDidRender,
778
- isPlayingFile = _this$state4.isPlayingFile,
779
- wasResolvedUpfrontPreview = _this$state4.wasResolvedUpfrontPreview;
775
+ var _this$state5 = this.state,
776
+ isCardVisible = _this$state5.isCardVisible,
777
+ cardPreview = _this$state5.cardPreview,
778
+ status = _this$state5.status,
779
+ fileState = _this$state5.fileState,
780
+ isBannedLocalPreview = _this$state5.isBannedLocalPreview,
781
+ previewDidRender = _this$state5.previewDidRender,
782
+ isPlayingFile = _this$state5.isPlayingFile,
783
+ wasResolvedUpfrontPreview = _this$state5.wasResolvedUpfrontPreview;
780
784
  var isDiffIdentifier = (0, _mediaClient2.isDifferentIdentifier)(prevIdentifier, identifier);
781
785
  /**
782
786
  * Variable turnedVisible should only be true when media card
@@ -854,7 +858,7 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
854
858
  var _getFileDetails2 = (0, _metadata.getFileDetails)(identifier, fileState),
855
859
  mimeType = _getFileDetails2.mimeType;
856
860
  var isVideoPlayable = (0, _videoIsPlayable.videoIsPlayable)(isBannedLocalPreview, fileState, mimeType);
857
- if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable) {
861
+ if (isVideo && !isPlayingFile && disableOverlay && useInlinePlayer && isVideoPlayable && status !== 'error') {
858
862
  this.setState({
859
863
  isPlayingFile: true
860
864
  });
@@ -930,22 +934,22 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
930
934
  }, {
931
935
  key: "metadata",
932
936
  get: function get() {
933
- var _this$state5;
934
- return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : _this$state5.fileState);
937
+ var _this$state6;
938
+ return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state6 = this.state) === null || _this$state6 === void 0 ? void 0 : _this$state6.fileState);
935
939
  }
936
940
  }, {
937
941
  key: "fileAttributes",
938
942
  get: function get() {
939
- var _this$state6;
940
- return (0, _analytics.getFileAttributes)(this.metadata, (_this$state6 = this.state) === null || _this$state6 === void 0 || (_this$state6 = _this$state6.fileState) === null || _this$state6 === void 0 ? void 0 : _this$state6.status);
943
+ var _this$state7;
944
+ return (0, _analytics.getFileAttributes)(this.metadata, (_this$state7 = this.state) === null || _this$state7 === void 0 || (_this$state7 = _this$state7.fileState) === null || _this$state7 === void 0 ? void 0 : _this$state7.status);
941
945
  }
942
946
  }, {
943
947
  key: "fireOperationalEvent",
944
948
  value: function fireOperationalEvent() {
945
- var _this$state7 = this.state,
946
- status = _this$state7.status,
947
- error = _this$state7.error,
948
- fileState = _this$state7.fileState;
949
+ var _this$state8 = this.state,
950
+ status = _this$state8.status,
951
+ error = _this$state8.error,
952
+ fileState = _this$state8.fileState;
949
953
  var createAnalyticsEvent = this.props.createAnalyticsEvent;
950
954
  createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), this.ssrReliability, error, this.traceContext, fileState === null || fileState === void 0 ? void 0 : fileState.metadataTraceContext);
951
955
  (0, _ufoExperiences.completeUfoExperience)(this.internalOccurrenceKey, status, this.fileAttributes, this.fileStateFlags, this.ssrReliability, error);
@@ -1004,9 +1008,9 @@ var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
1004
1008
  }, {
1005
1009
  key: "render",
1006
1010
  value: function render() {
1007
- var _this$state8 = this.state,
1008
- isPlayingFile = _this$state8.isPlayingFile,
1009
- mediaViewerSelectedItem = _this$state8.mediaViewerSelectedItem;
1011
+ var _this$state9 = this.state,
1012
+ isPlayingFile = _this$state9.isPlayingFile,
1013
+ mediaViewerSelectedItem = _this$state9.mediaViewerSelectedItem;
1010
1014
  var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null, this.storeSSRData());
1011
1015
  return this.props.intl ? innerContent : /*#__PURE__*/_react.default.createElement(_reactIntlNext.IntlProvider, {
1012
1016
  locale: "en"
@@ -31,6 +31,8 @@ var extractFilePreviewStatus = exports.extractFilePreviewStatus = function extra
31
31
  isSupportedByBrowser: isSupportedByBrowser
32
32
  };
33
33
  };
34
+
35
+ // CXP-2723 TODO: Review this in relation to removing status from the hook
34
36
  var isPreviewableStatus = exports.isPreviewableStatus = function isPreviewableStatus(cardStatus, _ref3) {
35
37
  var isPreviewable = _ref3.isPreviewable,
36
38
  hasPreview = _ref3.hasPreview,
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
90
90
  }(_react.default.Component);
91
91
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
92
92
  var packageName = "@atlaskit/media-card";
93
- var packageVersion = "77.4.4";
93
+ var packageVersion = "77.4.6";
94
94
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
95
95
  packageVersion: packageVersion,
96
96
  packageName: packageName,
@@ -16,7 +16,7 @@ var _externalImageCard = require("./externalImageCard");
16
16
  var _fileCard = require("./fileCard");
17
17
  var _excluded = ["identifier"];
18
18
  var packageName = "@atlaskit/media-card";
19
- var packageVersion = "77.4.4";
19
+ var packageVersion = "77.4.6";
20
20
  var CardV2Base = exports.CardV2Base = function CardV2Base(_ref) {
21
21
  var identifier = _ref.identifier,
22
22
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);