@atlaskit/media-card 77.12.4 → 78.0.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 (151) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/card/card.js +20 -1039
  3. package/dist/cjs/card/cardLoader.js +2 -2
  4. package/dist/cjs/card/cardView.js +255 -417
  5. package/dist/cjs/card/cardWithMediaClient.js +5 -9
  6. package/dist/cjs/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  7. package/dist/cjs/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  8. package/dist/cjs/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  9. package/dist/cjs/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  10. package/dist/cjs/card/{v2/cardviews → cardviews}/index.js +2 -2
  11. package/dist/cjs/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  12. package/dist/cjs/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  13. package/dist/cjs/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  14. package/dist/cjs/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  15. package/dist/cjs/card/{v2/fileCard.js → fileCard.js} +18 -18
  16. package/dist/cjs/card/index.js +2 -2
  17. package/dist/cjs/card/inlinePlayer.js +184 -267
  18. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  19. package/dist/cjs/card/{v2/svgView → svgView}/svgView.js +9 -9
  20. package/dist/cjs/inline/loader.js +1 -1
  21. package/dist/cjs/utils/ufoExperiences.js +1 -1
  22. package/dist/es2019/card/card.js +20 -1023
  23. package/dist/es2019/card/cardLoader.js +2 -2
  24. package/dist/es2019/card/cardView.js +252 -403
  25. package/dist/es2019/card/cardWithMediaClient.js +6 -10
  26. package/dist/es2019/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  27. package/dist/es2019/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  28. package/dist/es2019/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  29. package/dist/es2019/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  30. package/dist/es2019/card/{v2/cardviews → cardviews}/index.js +2 -2
  31. package/dist/es2019/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  32. package/dist/es2019/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  33. package/dist/es2019/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  34. package/dist/es2019/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  35. package/dist/es2019/card/{v2/fileCard.js → fileCard.js} +18 -18
  36. package/dist/es2019/card/index.js +1 -1
  37. package/dist/es2019/card/inlinePlayer.js +127 -208
  38. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  39. package/dist/es2019/card/{v2/svgView → svgView}/svgView.js +9 -9
  40. package/dist/es2019/inline/loader.js +1 -1
  41. package/dist/es2019/utils/ufoExperiences.js +1 -1
  42. package/dist/esm/card/card.js +21 -1040
  43. package/dist/esm/card/cardLoader.js +2 -2
  44. package/dist/esm/card/cardView.js +251 -416
  45. package/dist/esm/card/cardWithMediaClient.js +6 -10
  46. package/dist/esm/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  47. package/dist/esm/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  48. package/dist/esm/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  49. package/dist/esm/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  50. package/dist/esm/card/{v2/cardviews → cardviews}/index.js +2 -2
  51. package/dist/esm/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  52. package/dist/esm/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  53. package/dist/esm/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  54. package/dist/esm/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  55. package/dist/esm/card/{v2/fileCard.js → fileCard.js} +18 -18
  56. package/dist/esm/card/index.js +1 -1
  57. package/dist/esm/card/inlinePlayer.js +185 -269
  58. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  59. package/dist/esm/card/{v2/svgView → svgView}/svgView.js +9 -9
  60. package/dist/esm/inline/loader.js +1 -1
  61. package/dist/esm/utils/ufoExperiences.js +1 -1
  62. package/dist/types/card/card.d.ts +5 -66
  63. package/dist/types/card/cardLoader.d.ts +1 -1
  64. package/dist/types/card/cardView.d.ts +23 -45
  65. package/dist/types/card/cardWithMediaClient.d.ts +1 -1
  66. package/dist/types/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
  67. package/dist/types/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
  68. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/iconCardView.d.ts +1 -1
  69. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/imageCardView.d.ts +1 -1
  70. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/index.d.ts +5 -5
  71. package/dist/types/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
  72. package/dist/types/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
  73. package/dist/types/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
  74. package/dist/types/card/index.d.ts +1 -1
  75. package/dist/types/card/inlinePlayer.d.ts +2 -31
  76. package/dist/types/card/{v2/svgView → svgView}/errors.d.ts +1 -1
  77. package/dist/{types-ts4.5/card/v2 → types/card}/svgView/svgView.d.ts +2 -2
  78. package/dist/types-ts4.5/card/card.d.ts +5 -66
  79. package/dist/types-ts4.5/card/cardLoader.d.ts +1 -1
  80. package/dist/types-ts4.5/card/cardView.d.ts +23 -45
  81. package/dist/types-ts4.5/card/cardWithMediaClient.d.ts +1 -1
  82. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
  83. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
  84. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/iconCardView.d.ts +1 -1
  85. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/imageCardView.d.ts +1 -1
  86. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/index.d.ts +5 -5
  87. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
  88. package/dist/types-ts4.5/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
  89. package/dist/types-ts4.5/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
  90. package/dist/types-ts4.5/card/index.d.ts +1 -1
  91. package/dist/types-ts4.5/card/inlinePlayer.d.ts +2 -31
  92. package/dist/types-ts4.5/card/{v2/svgView → svgView}/errors.d.ts +1 -1
  93. package/dist/{types/card/v2 → types-ts4.5/card}/svgView/svgView.d.ts +2 -2
  94. package/package.json +1 -4
  95. package/dist/cjs/card/cardSwitcher.js +0 -15
  96. package/dist/cjs/card/v2/cardV2.js +0 -41
  97. package/dist/cjs/card/v2/cardV2Loader.js +0 -36
  98. package/dist/cjs/card/v2/cardViewV2.js +0 -298
  99. package/dist/cjs/card/v2/cardWithMediaClientV2.js +0 -34
  100. package/dist/cjs/card/v2/inlinePlayerLazyV2.js +0 -35
  101. package/dist/cjs/card/v2/inlinePlayerV2.js +0 -224
  102. package/dist/es2019/card/cardSwitcher.js +0 -8
  103. package/dist/es2019/card/v2/cardV2.js +0 -33
  104. package/dist/es2019/card/v2/cardV2Loader.js +0 -18
  105. package/dist/es2019/card/v2/cardViewV2.js +0 -294
  106. package/dist/es2019/card/v2/cardWithMediaClientV2.js +0 -25
  107. package/dist/es2019/card/v2/inlinePlayerLazyV2.js +0 -10
  108. package/dist/es2019/card/v2/inlinePlayerV2.js +0 -166
  109. package/dist/esm/card/cardSwitcher.js +0 -8
  110. package/dist/esm/card/v2/cardV2.js +0 -34
  111. package/dist/esm/card/v2/cardV2Loader.js +0 -24
  112. package/dist/esm/card/v2/cardViewV2.js +0 -290
  113. package/dist/esm/card/v2/cardWithMediaClientV2.js +0 -27
  114. package/dist/esm/card/v2/inlinePlayerLazyV2.js +0 -23
  115. package/dist/esm/card/v2/inlinePlayerV2.js +0 -214
  116. package/dist/types/card/cardSwitcher.d.ts +0 -4
  117. package/dist/types/card/v2/cardV2.d.ts +0 -7
  118. package/dist/types/card/v2/cardV2Loader.d.ts +0 -4
  119. package/dist/types/card/v2/cardViewV2.d.ts +0 -59
  120. package/dist/types/card/v2/cardWithMediaClientV2.d.ts +0 -3
  121. package/dist/types/card/v2/inlinePlayerLazyV2.d.ts +0 -2
  122. package/dist/types/card/v2/inlinePlayerV2.d.ts +0 -24
  123. package/dist/types-ts4.5/card/cardSwitcher.d.ts +0 -4
  124. package/dist/types-ts4.5/card/v2/cardV2.d.ts +0 -7
  125. package/dist/types-ts4.5/card/v2/cardV2Loader.d.ts +0 -4
  126. package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +0 -59
  127. package/dist/types-ts4.5/card/v2/cardWithMediaClientV2.d.ts +0 -3
  128. package/dist/types-ts4.5/card/v2/inlinePlayerLazyV2.d.ts +0 -2
  129. package/dist/types-ts4.5/card/v2/inlinePlayerV2.d.ts +0 -24
  130. /package/dist/cjs/card/{v2/performance.js → performance.js} +0 -0
  131. /package/dist/cjs/card/{v2/svgView → svgView}/errors.js +0 -0
  132. /package/dist/cjs/card/{v2/svgView → svgView}/helpers.js +0 -0
  133. /package/dist/cjs/card/{v2/svgView → svgView}/index.js +0 -0
  134. /package/dist/es2019/card/{v2/performance.js → performance.js} +0 -0
  135. /package/dist/es2019/card/{v2/svgView → svgView}/errors.js +0 -0
  136. /package/dist/es2019/card/{v2/svgView → svgView}/helpers.js +0 -0
  137. /package/dist/es2019/card/{v2/svgView → svgView}/index.js +0 -0
  138. /package/dist/esm/card/{v2/performance.js → performance.js} +0 -0
  139. /package/dist/esm/card/{v2/svgView → svgView}/errors.js +0 -0
  140. /package/dist/esm/card/{v2/svgView → svgView}/helpers.js +0 -0
  141. /package/dist/esm/card/{v2/svgView → svgView}/index.js +0 -0
  142. /package/dist/types/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
  143. /package/dist/types/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
  144. /package/dist/types/card/{v2/performance.d.ts → performance.d.ts} +0 -0
  145. /package/dist/types/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
  146. /package/dist/types/card/{v2/svgView → svgView}/index.d.ts +0 -0
  147. /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
  148. /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
  149. /package/dist/types-ts4.5/card/{v2/performance.d.ts → performance.d.ts} +0 -0
  150. /package/dist/types-ts4.5/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
  151. /package/dist/types-ts4.5/card/{v2/svgView → svgView}/index.d.ts +0 -0
@@ -1,26 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- import React from 'react';
14
- import { Component } from 'react';
5
+ import React, { useRef, useState, useEffect } from 'react';
15
6
  import { globalMediaEventEmitter } from '@atlaskit/media-client';
16
7
  import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
17
8
  import { defaultImageCardDimensions } from '../utils';
18
9
  import { CardLoading } from '../utils/lightCards/cardLoading';
19
10
  import { ProgressBar } from './ui/progressBar/progressBar';
20
- import { calcBreakpointSize } from './ui/styles';
21
- import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
22
- import { getElementDimension } from '../utils/getElementDimension';
23
11
  import { InlinePlayerWrapper } from './inlinePlayerWrapper';
12
+ import { useBreakpoint } from './useBreakpoint';
13
+ import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
24
14
  export var getPreferredVideoArtifact = function getPreferredVideoArtifact(fileState) {
25
15
  if (fileState.status === 'processed' || fileState.status === 'processing') {
26
16
  var artifacts = fileState.artifacts;
@@ -31,265 +21,191 @@ export var getPreferredVideoArtifact = function getPreferredVideoArtifact(fileSt
31
21
  }
32
22
  return undefined;
33
23
  };
34
- export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
35
- _inherits(InlinePlayerBase, _Component);
36
- var _super = _createSuper(InlinePlayerBase);
37
- function InlinePlayerBase() {
38
- var _this;
39
- _classCallCheck(this, InlinePlayerBase);
40
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
41
- args[_key] = arguments[_key];
42
- }
43
- _this = _super.call.apply(_super, [this].concat(args));
44
- _defineProperty(_assertThisInitialized(_this), "state", {});
45
- _defineProperty(_assertThisInitialized(_this), "divRef", /*#__PURE__*/React.createRef());
46
- _defineProperty(_assertThisInitialized(_this), "setFileSrc", function (fileSrc) {
47
- _this.setState({
48
- fileSrc: fileSrc
49
- });
50
- });
51
- // Tries to use the binary artifact to provide something to play while the video is still processing
52
- _defineProperty(_assertThisInitialized(_this), "setBinaryURL", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
53
- var _this$props, mediaClient, identifier, onError, id, collectionName, fileSrc;
54
- return _regeneratorRuntime.wrap(function _callee$(_context) {
55
- while (1) switch (_context.prev = _context.next) {
56
- case 0:
57
- _this$props = _this.props, mediaClient = _this$props.mediaClient, identifier = _this$props.identifier, onError = _this$props.onError;
58
- id = identifier.id, collectionName = identifier.collectionName;
59
- _context.prev = 2;
60
- _context.next = 5;
61
- return mediaClient.file.getFileBinaryURL(id, collectionName);
62
- case 5:
63
- fileSrc = _context.sent;
64
- _this.setFileSrc(fileSrc);
65
- _context.next = 12;
66
- break;
67
- case 9:
68
- _context.prev = 9;
69
- _context.t0 = _context["catch"](2);
70
- if (onError && _context.t0 instanceof Error) {
71
- onError(_context.t0);
72
- }
73
- case 12:
74
- case "end":
75
- return _context.stop();
76
- }
77
- }, _callee, null, [[2, 9]]);
78
- })));
79
- _defineProperty(_assertThisInitialized(_this), "unsubscribe", function () {
80
- if (_this.subscription) {
81
- _this.subscription.unsubscribe();
82
- }
83
- });
84
- _defineProperty(_assertThisInitialized(_this), "revoke", function () {
85
- var fileSrc = _this.state.fileSrc;
86
- if (fileSrc) {
87
- URL.revokeObjectURL(fileSrc);
88
- }
89
- });
90
- _defineProperty(_assertThisInitialized(_this), "onDownloadClick", function () {
91
- var _this$props2 = _this.props,
92
- mediaClient = _this$props2.mediaClient,
93
- identifier = _this$props2.identifier;
94
- var id = identifier.id,
95
- collectionName = identifier.collectionName;
96
- mediaClient.file.downloadBinary(id, undefined, collectionName);
97
- });
98
- _defineProperty(_assertThisInitialized(_this), "onFirstPlay", function () {
99
- var identifier = _this.props.identifier;
100
- globalMediaEventEmitter.emit('media-viewed', {
101
- fileId: identifier.id,
102
- viewingLevel: 'full'
103
- });
104
- });
105
- _defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
106
- var dimensions = _this.props.dimensions;
107
- if (!dimensions) {
108
- return;
109
- }
110
- var width = dimensions.width;
111
- if (width && isValidPercentageUnit(width) && !!_this.divRef.current) {
112
- var elementWidth = getElementDimension(_this.divRef.current, 'width');
113
- _this.setState({
114
- elementWidth: elementWidth
115
- });
116
- }
117
- });
118
- return _this;
119
- }
120
- _createClass(InlinePlayerBase, [{
121
- key: "componentDidMount",
122
- value: function componentDidMount() {
123
- var _this2 = this;
124
- this.saveElementWidth();
125
- var _this$props3 = this.props,
126
- mediaClient = _this$props3.mediaClient,
127
- identifier = _this$props3.identifier;
128
- var id = identifier.id,
129
- collectionName = identifier.collectionName;
130
- this.revoke();
131
- this.unsubscribe();
132
- this.subscription = mediaClient.file.getFileState(id, {
133
- collectionName: collectionName
134
- }).subscribe({
135
- next: function () {
136
- var _next = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fileState) {
137
- var existingFileSrc, _yield$fileState$prev, value, fileSrc, artifactName, artifacts, _fileSrc, onError;
138
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
139
- while (1) switch (_context2.prev = _context2.next) {
140
- case 0:
141
- if (fileState.status === 'uploading') {
142
- _this2.setState({
143
- isUploading: true,
144
- progress: fileState.progress
145
- });
146
- } else {
147
- _this2.setState({
148
- isUploading: false
149
- });
150
- }
151
- existingFileSrc = _this2.state.fileSrc; // we want to reuse the existing fileSrc to prevent re renders
152
- if (!existingFileSrc) {
153
- _context2.next = 4;
154
- break;
155
- }
156
- return _context2.abrupt("return");
157
- case 4:
158
- if (!(fileState.status !== 'error' && fileState.preview)) {
159
- _context2.next = 13;
160
- break;
161
- }
162
- _context2.next = 7;
163
- return fileState.preview;
164
- case 7:
165
- _yield$fileState$prev = _context2.sent;
166
- value = _yield$fileState$prev.value;
167
- if (!(value instanceof Blob && value.type.indexOf('video/') === 0)) {
168
- _context2.next = 13;
169
- break;
170
- }
171
- fileSrc = URL.createObjectURL(value);
172
- _this2.setFileSrc(fileSrc);
173
- return _context2.abrupt("return");
174
- case 13:
175
- if (!(fileState.status === 'processed' || fileState.status === 'processing')) {
176
- _context2.next = 30;
177
- break;
178
- }
179
- artifactName = getPreferredVideoArtifact(fileState);
180
- artifacts = fileState.artifacts;
181
- if (!(!artifactName || !artifacts)) {
182
- _context2.next = 19;
183
- break;
184
- }
185
- _this2.setBinaryURL();
186
- return _context2.abrupt("return");
187
- case 19:
188
- _context2.prev = 19;
189
- _context2.next = 22;
190
- return mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
191
- case 22:
192
- _fileSrc = _context2.sent;
193
- _this2.setFileSrc(_fileSrc);
194
- _context2.next = 30;
195
- break;
196
- case 26:
197
- _context2.prev = 26;
198
- _context2.t0 = _context2["catch"](19);
199
- onError = _this2.props.onError;
200
- if (onError && _context2.t0 instanceof Error) {
201
- onError(_context2.t0);
202
- }
203
- case 30:
204
- case "end":
205
- return _context2.stop();
24
+ export var InlinePlayerBase = function InlinePlayerBase(_ref) {
25
+ var identifier = _ref.identifier,
26
+ onError = _ref.onError,
27
+ onClick = _ref.onClick,
28
+ _ref$dimensions = _ref.dimensions,
29
+ dimensions = _ref$dimensions === void 0 ? defaultImageCardDimensions : _ref$dimensions,
30
+ originalDimensions = _ref.originalDimensions,
31
+ selected = _ref.selected,
32
+ testId = _ref.testId,
33
+ forwardRef = _ref.forwardRef,
34
+ autoplay = _ref.autoplay,
35
+ cardPreview = _ref.cardPreview,
36
+ onFullscreenChange = _ref.onFullscreenChange,
37
+ videoControlsWrapperRef = _ref.videoControlsWrapperRef;
38
+ // === States ===
39
+ var _useState = useState(),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ fileSrc = _useState2[0],
42
+ setFileSrc = _useState2[1];
43
+ var _useState3 = useState(),
44
+ _useState4 = _slicedToArray(_useState3, 2),
45
+ isUploading = _useState4[0],
46
+ setIsUploading = _useState4[1];
47
+ var _useState5 = useState(),
48
+ _useState6 = _slicedToArray(_useState5, 2),
49
+ progress = _useState6[0],
50
+ setProgress = _useState6[1];
51
+
52
+ // === Refs and Local Variables ===
53
+ var divRef = useRef(null);
54
+ var onErrorRef = useRef(onError);
55
+ onErrorRef.current = onError;
56
+ var id = identifier.id,
57
+ collectionName = identifier.collectionName,
58
+ occurrenceKey = identifier.occurrenceKey;
59
+ var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
60
+ var mediaClient = useMediaClient();
61
+ var _useFileState = useFileState(id, {
62
+ collectionName: collectionName,
63
+ occurrenceKey: occurrenceKey
64
+ }),
65
+ fileState = _useFileState.fileState;
66
+ useEffect(function () {
67
+ var subscribeFileState = /*#__PURE__*/function () {
68
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fileState) {
69
+ var _yield$fileState$prev, value, newFileSrc, artifactName, artifacts, _newFileSrc, _newFileSrc2;
70
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ if (fileState.status === 'uploading') {
74
+ setIsUploading(true);
75
+ setProgress(fileState.progress);
76
+ } else {
77
+ setIsUploading(false);
78
+ }
79
+
80
+ // We reuse the existing fileSrc to prevent re renders, therefore we only perform fileSrc updates when there isn't any
81
+ if (!fileSrc) {
82
+ _context.next = 3;
83
+ break;
84
+ }
85
+ return _context.abrupt("return");
86
+ case 3:
87
+ if (!(fileState.status !== 'error' && fileState.preview)) {
88
+ _context.next = 12;
89
+ break;
90
+ }
91
+ _context.next = 6;
92
+ return fileState.preview;
93
+ case 6:
94
+ _yield$fileState$prev = _context.sent;
95
+ value = _yield$fileState$prev.value;
96
+ if (!(value instanceof Blob && value.type.indexOf('video/') === 0)) {
97
+ _context.next = 12;
98
+ break;
206
99
  }
207
- }, _callee2, null, [[19, 26]]);
208
- }));
209
- function next(_x) {
210
- return _next.apply(this, arguments);
100
+ newFileSrc = URL.createObjectURL(value);
101
+ setFileSrc(newFileSrc);
102
+ return _context.abrupt("return");
103
+ case 12:
104
+ if (!(fileState.status === 'processed' || fileState.status === 'processing')) {
105
+ _context.next = 37;
106
+ break;
107
+ }
108
+ artifactName = getPreferredVideoArtifact(fileState);
109
+ artifacts = fileState.artifacts;
110
+ if (!(!artifactName || !artifacts)) {
111
+ _context.next = 27;
112
+ break;
113
+ }
114
+ _context.prev = 16;
115
+ _context.next = 19;
116
+ return mediaClient.file.getFileBinaryURL(id, collectionName);
117
+ case 19:
118
+ _newFileSrc = _context.sent;
119
+ setFileSrc(_newFileSrc);
120
+ _context.next = 26;
121
+ break;
122
+ case 23:
123
+ _context.prev = 23;
124
+ _context.t0 = _context["catch"](16);
125
+ if (onErrorRef.current && _context.t0 instanceof Error) {
126
+ onErrorRef.current(_context.t0);
127
+ }
128
+ case 26:
129
+ return _context.abrupt("return");
130
+ case 27:
131
+ _context.prev = 27;
132
+ _context.next = 30;
133
+ return mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
134
+ case 30:
135
+ _newFileSrc2 = _context.sent;
136
+ setFileSrc(_newFileSrc2);
137
+ _context.next = 37;
138
+ break;
139
+ case 34:
140
+ _context.prev = 34;
141
+ _context.t1 = _context["catch"](27);
142
+ if (onErrorRef.current && _context.t1 instanceof Error) {
143
+ onErrorRef.current(_context.t1);
144
+ }
145
+ case 37:
146
+ case "end":
147
+ return _context.stop();
211
148
  }
212
- return next;
213
- }()
214
- });
215
- }
216
- }, {
217
- key: "componentWillUnmount",
218
- value: function componentWillUnmount() {
219
- this.unsubscribe();
220
- this.revoke();
221
- }
222
- }, {
223
- key: "breakpoint",
224
- get: function get() {
225
- var width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
226
- return calcBreakpointSize(parseInt("".concat(width), 10));
149
+ }, _callee, null, [[16, 23], [27, 34]]);
150
+ }));
151
+ return function subscribeFileState(_x) {
152
+ return _ref2.apply(this, arguments);
153
+ };
154
+ }();
155
+ if (fileState) {
156
+ subscribeFileState(fileState);
227
157
  }
228
- }, {
229
- key: "render",
230
- value: function render() {
231
- var _this3 = this;
232
- var _this$props4 = this.props,
233
- onClick = _this$props4.onClick,
234
- dimensions = _this$props4.dimensions,
235
- originalDimensions = _this$props4.originalDimensions,
236
- selected = _this$props4.selected,
237
- testId = _this$props4.testId,
238
- identifier = _this$props4.identifier,
239
- forwardRef = _this$props4.forwardRef,
240
- autoplay = _this$props4.autoplay,
241
- cardPreview = _this$props4.cardPreview,
242
- onFullscreenChange = _this$props4.onFullscreenChange,
243
- videoControlsWrapperRef = _this$props4.videoControlsWrapperRef;
244
- var _this$state = this.state,
245
- fileSrc = _this$state.fileSrc,
246
- isUploading = _this$state.isUploading,
247
- progress = _this$state.progress;
248
- if (!fileSrc) {
249
- return /*#__PURE__*/React.createElement(CardLoading, {
250
- testId: testId,
251
- dimensions: dimensions
158
+ }, [fileState, collectionName, fileSrc, id, mediaClient]);
159
+ useEffect(function () {
160
+ return function () {
161
+ fileSrc && URL.revokeObjectURL(fileSrc);
162
+ };
163
+ }, [fileSrc]);
164
+
165
+ // === Render ===
166
+ return fileSrc ? /*#__PURE__*/React.createElement(InlinePlayerWrapper, {
167
+ testId: testId || 'media-card-inline-player',
168
+ selected: {
169
+ selected: selected
170
+ },
171
+ onClick: onClick,
172
+ innerRef: forwardRef || undefined,
173
+ dimensions: dimensions
174
+ }, /*#__PURE__*/React.createElement(InactivityDetector, null, function (checkMouseMovement) {
175
+ return /*#__PURE__*/React.createElement(CustomMediaPlayer, {
176
+ type: "video",
177
+ src: fileSrc,
178
+ onFullscreenChange: onFullscreenChange,
179
+ fileId: id,
180
+ isAutoPlay: autoplay,
181
+ isHDAvailable: false,
182
+ onDownloadClick: function onDownloadClick() {
183
+ mediaClient.file.downloadBinary(id, undefined, collectionName);
184
+ },
185
+ onFirstPlay: function onFirstPlay() {
186
+ globalMediaEventEmitter.emit('media-viewed', {
187
+ fileId: id,
188
+ viewingLevel: 'full'
252
189
  });
253
- }
254
- return /*#__PURE__*/React.createElement(InlinePlayerWrapper, {
255
- testId: testId || 'media-card-inline-player',
256
- selected: {
257
- selected: selected
258
- },
259
- onClick: onClick,
260
- innerRef: forwardRef || undefined,
261
- dimensions: dimensions
262
- }, /*#__PURE__*/React.createElement(InactivityDetector, null, function (checkMouseMovement) {
263
- return /*#__PURE__*/React.createElement(CustomMediaPlayer, {
264
- type: "video",
265
- src: fileSrc,
266
- onFullscreenChange: onFullscreenChange,
267
- fileId: identifier.id,
268
- isAutoPlay: autoplay,
269
- isHDAvailable: false,
270
- onDownloadClick: _this3.onDownloadClick,
271
- onFirstPlay: _this3.onFirstPlay,
272
- lastWatchTimeConfig: {
273
- contentId: identifier.id
274
- },
275
- originalDimensions: originalDimensions,
276
- showControls: checkMouseMovement,
277
- poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI,
278
- videoControlsWrapperRef: videoControlsWrapperRef
279
- });
280
- }), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
281
- progress: progress,
282
- breakpoint: this.breakpoint,
283
- positionBottom: true,
284
- showOnTop: true
285
- }) : null);
286
- }
287
- }]);
288
- return InlinePlayerBase;
289
- }(Component);
290
- _defineProperty(InlinePlayerBase, "defaultProps", {
291
- dimensions: defaultImageCardDimensions
292
- });
190
+ },
191
+ lastWatchTimeConfig: {
192
+ contentId: id
193
+ },
194
+ originalDimensions: originalDimensions,
195
+ showControls: checkMouseMovement,
196
+ poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI,
197
+ videoControlsWrapperRef: videoControlsWrapperRef
198
+ });
199
+ }), isUploading && /*#__PURE__*/React.createElement(ProgressBar, {
200
+ progress: progress,
201
+ breakpoint: breakpoint,
202
+ positionBottom: true,
203
+ showOnTop: true
204
+ })) : /*#__PURE__*/React.createElement(CardLoading, {
205
+ testId: testId,
206
+ dimensions: dimensions
207
+ });
208
+ };
293
209
  var InlinePlayerForwardRef = /*#__PURE__*/React.forwardRef(function (props, ref) {
294
210
  return /*#__PURE__*/React.createElement(InlinePlayerBase, _extends({}, props, {
295
211
  forwardRef: ref
@@ -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 = "77.12.4";
86
+ var packageVersion = "78.0.0";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -4,17 +4,17 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import { jsx } from '@emotion/react';
5
5
  import React, { useState, useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
8
- import { ImageRenderer } from '../../ui/imageRenderer/imageRenderer';
9
- import { ProgressBar } from '../../ui/progressBar/progressBar';
10
- import { Blanket } from '../../ui/blanket/blanket';
11
- import { Wrapper, ImageContainer } from '../../ui/wrapper';
12
- import { fileCardImageViewSelector } from '../../classnames';
13
- import { useBreakpoint } from '../../useBreakpoint';
7
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
8
+ import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
9
+ import { ProgressBar } from '../ui/progressBar/progressBar';
10
+ import { Blanket } from '../ui/blanket/blanket';
11
+ import { Wrapper, ImageContainer } from '../ui/wrapper';
12
+ import { fileCardImageViewSelector } from '../classnames';
13
+ import { useBreakpoint } from '../useBreakpoint';
14
14
  import MediaSvg from '@atlaskit/media-svg';
15
15
  import { calculateSvgDimensions } from './helpers';
16
- import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
17
- import { MediaCardError } from '../../../errors';
16
+ import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
17
+ import { MediaCardError } from '../../errors';
18
18
  import { getErrorReason } from './errors';
19
19
  export var convertResizeMode = function convertResizeMode(resizeMode) {
20
20
  switch (resizeMode) {
@@ -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: "77.12.4",
106
+ packageName: "78.0.0",
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 = "77.12.4";
10
+ var packageVersion = "78.0.0";
11
11
  var concurrentExperience;
12
12
  var getExperience = function getExperience(id) {
13
13
  if (!concurrentExperience) {
@@ -1,68 +1,7 @@
1
- import React, { Component } from 'react';
2
- import { type UIAnalyticsEvent, type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
3
- import { type FileIdentifier, type FileState, type MediaSubscription } from '@atlaskit/media-client';
1
+ import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
2
+ import React from 'react';
4
3
  import { type WrappedComponentProps } from 'react-intl-next';
5
- import { type CardAction } from './actions';
6
- import { type CardProps, type CardState, type CardStatus } from '../types';
7
- export type CardBaseProps = CardProps & WithAnalyticsEventsProps & Partial<WrappedComponentProps> & {
8
- dateOverride?: number;
9
- };
10
- export declare class CardBase extends Component<CardBaseProps, CardState> {
11
- private internalOccurrenceKey;
12
- private hasBeenMounted;
13
- private mediaViewerButtonRef;
14
- private fileStateFlags;
15
- private ssrReliability;
16
- private timeElapsedTillCommenced;
17
- subscription?: MediaSubscription;
18
- private ssrData?;
19
- private traceContext;
20
- static defaultProps: Partial<CardProps>;
21
- constructor(props: CardBaseProps);
22
- private getSSRPreview;
23
- componentDidMount(): void;
24
- componentDidUpdate(prevProps: CardProps, prevState: CardState): void;
25
- componentWillUnmount(): void;
26
- updateStateForIdentifier(identifier: FileIdentifier): void;
27
- private getImageURLParams;
28
- private getMediaBlobUrlAttrs;
29
- private getCardPreviewParams;
30
- private setCacheSSRPreview;
31
- private refetchSSRPreview;
32
- private resolveUpfrontPreview;
33
- private fetchAndCacheRemotePreview;
34
- private resolvePreview;
35
- updateFileStateFlag(fileState?: FileState): void;
36
- subscribeInternalFile(identifier: FileIdentifier): void;
37
- private get requestedDimensions();
38
- private get metadata();
39
- private get fileAttributes();
40
- private getPerformanceAttributes;
41
- private logSSRImageError;
42
- private onImageError;
43
- private onImageLoad;
44
- private fireOperationalEvent;
45
- private fireAbortedEvent;
46
- private fireCommencedEvent;
47
- private fireCopiedEvent;
48
- private fireScreenEvent;
49
- private fireNonCriticalErrorEvent;
50
- private safeSetState;
51
- unsubscribe: () => void;
52
- get actions(): CardAction[];
53
- onCardViewClick: (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
54
- onInlinePlayerError: (e: Error) => void;
55
- setRef: (cardRef: HTMLDivElement | null) => void;
56
- setMediaViewerButtonRef: (buttonRef: HTMLButtonElement | null) => void;
57
- renderInlinePlayer: () => JSX.Element;
58
- onMediaViewerClose: () => void;
59
- private onDisplayImage;
60
- renderMediaViewer: () => React.ReactPortal | undefined;
61
- renderCard: (withCallbacks?: boolean, cardStatusOverride?: CardStatus, izLazyOverride?: boolean) => JSX.Element;
62
- private storeSSRData;
63
- render(): JSX.Element;
64
- private onCardInViewport;
65
- onClick: (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
66
- onMouseEnter: (event: React.MouseEvent<HTMLDivElement>) => void;
67
- }
4
+ import { type CardProps } from '../types';
5
+ export type CardBaseProps = CardProps & WithAnalyticsEventsProps & Partial<WrappedComponentProps>;
6
+ export declare const CardBase: ({ identifier, ...otherProps }: CardBaseProps & WrappedComponentProps) => JSX.Element;
68
7
  export declare const Card: React.ComponentType<CardBaseProps>;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import type { CardWithMediaClientConfigProps } from './types';
2
+ import { type CardWithMediaClientConfigProps } from './types';
3
3
  declare const CardLoader: React.FC<CardWithMediaClientConfigProps>;
4
4
  export default CardLoader;