@atlaskit/media-file-preview 0.9.4 → 0.9.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.9.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#102527](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102527)
8
+ [`a90d34cd14faf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a90d34cd14faf) -
9
+ Updated ErrorFileState deserialisation and error logging
10
+ - Updated dependencies
11
+
12
+ ## 0.9.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 0.9.4
4
19
 
5
20
  ### Patch Changes
@@ -7,43 +7,32 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getRenderErrorFailReason = exports.getRenderErrorErrorReason = exports.getRenderErrorErrorDetail = exports.getErrorTraceContext = exports.extractErrorInfo = exports.createFailedSSRObject = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _mediaClient = require("@atlaskit/media-client");
10
- var _mediaClientReact = require("@atlaskit/media-client-react");
11
10
  var _errors = require("./errors");
12
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
13
  var getErrorTraceContext = exports.getErrorTraceContext = function getErrorTraceContext(error) {
15
- if ((0, _errors.isMediaFilePreviewError)(error) && !!error.secondaryError) {
16
- if ((0, _mediaClient.isRequestError)(error.secondaryError)) {
17
- var _error$secondaryError;
18
- return (_error$secondaryError = error.secondaryError.metadata) === null || _error$secondaryError === void 0 ? void 0 : _error$secondaryError.traceContext;
19
- } else if ((0, _mediaClientReact.isMediaFileStateError)(error.secondaryError)) {
20
- var _error$secondaryError2;
21
- return (_error$secondaryError2 = error.secondaryError.details) === null || _error$secondaryError2 === void 0 || (_error$secondaryError2 = _error$secondaryError2.metadata) === null || _error$secondaryError2 === void 0 ? void 0 : _error$secondaryError2.traceContext;
22
- }
14
+ var secondaryError = error.secondaryError;
15
+ if ((0, _mediaClient.isCommonMediaClientError)(secondaryError)) {
16
+ var _secondaryError$metad;
17
+ return (_secondaryError$metad = secondaryError.metadata) === null || _secondaryError$metad === void 0 ? void 0 : _secondaryError$metad.traceContext;
23
18
  }
24
19
  };
25
20
  var getRenderErrorFailReason = exports.getRenderErrorFailReason = function getRenderErrorFailReason(error) {
26
- if ((0, _errors.isMediaFilePreviewError)(error)) {
27
- return error.primaryReason;
28
- } else {
29
- return 'nativeError';
30
- }
21
+ return error.primaryReason || 'nativeError';
31
22
  };
32
23
  var getRenderErrorErrorReason = exports.getRenderErrorErrorReason = function getRenderErrorErrorReason(error) {
33
- if ((0, _errors.isMediaFilePreviewError)(error) && error.secondaryError) {
34
- var mediaClientReason = (0, _mediaClient.isMediaClientError)(error.secondaryError) ? (0, _mediaClient.getMediaClientErrorReason)(error.secondaryError) : (0, _mediaClientReact.getFileStateErrorReason)(error.secondaryError);
35
- if (mediaClientReason !== 'unknown') {
36
- return mediaClientReason;
37
- }
24
+ var secondaryError = error.secondaryError;
25
+ if ((0, _mediaClient.isCommonMediaClientError)(secondaryError)) {
26
+ return secondaryError.reason;
38
27
  }
39
28
  return 'nativeError';
40
29
  };
41
30
  var getRenderErrorErrorDetail = exports.getRenderErrorErrorDetail = function getRenderErrorErrorDetail(error) {
42
- if ((0, _errors.isMediaFilePreviewError)(error) && error.secondaryError) {
43
- return error.secondaryError.message;
44
- } else {
45
- return error.message;
31
+ var secondaryError = error.secondaryError;
32
+ if ((0, _mediaClient.isCommonMediaClientError)(secondaryError)) {
33
+ return secondaryError.message;
46
34
  }
35
+ return error.message;
47
36
  };
48
37
  var extractErrorInfo = exports.extractErrorInfo = function extractErrorInfo(error, metadataTraceContext) {
49
38
  return {
@@ -9,74 +9,69 @@ exports.isMediaFilePreviewError = isMediaFilePreviewError;
9
9
  exports.isUnsupportedLocalPreviewError = exports.isRemotePreviewError = void 0;
10
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
15
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
17
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
16
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
18
17
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
18
  /**
20
19
  * Primary reason is logged through Data Portal.
21
20
  * Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
22
21
  */
23
22
  var MediaFilePreviewError = exports.MediaFilePreviewError = /*#__PURE__*/function (_Error) {
24
- (0, _inherits2.default)(MediaFilePreviewError, _Error);
25
- var _super = _createSuper(MediaFilePreviewError);
26
23
  function MediaFilePreviewError(primaryReason, secondaryError) {
27
24
  var _this;
28
25
  (0, _classCallCheck2.default)(this, MediaFilePreviewError);
29
- _this = _super.call(this, primaryReason);
26
+ _this = _callSuper(this, MediaFilePreviewError, [primaryReason]);
30
27
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
31
28
  _this.primaryReason = primaryReason;
32
29
  _this.secondaryError = secondaryError;
33
- Object.setPrototypeOf((0, _assertThisInitialized2.default)(_this), (this instanceof MediaFilePreviewError ? this.constructor : void 0).prototype);
30
+ Object.setPrototypeOf(_this, (this instanceof MediaFilePreviewError ? this.constructor : void 0).prototype);
34
31
 
35
32
  // https://v8.dev/docs/stack-trace-api
36
33
  if ('captureStackTrace' in Error) {
37
- Error.captureStackTrace((0, _assertThisInitialized2.default)(_this), this instanceof MediaFilePreviewError ? this.constructor : void 0);
34
+ Error.captureStackTrace(_this, this instanceof MediaFilePreviewError ? this.constructor : void 0);
38
35
  }
39
36
  return _this;
40
37
  }
38
+ (0, _inherits2.default)(MediaFilePreviewError, _Error);
41
39
  return (0, _createClass2.default)(MediaFilePreviewError);
42
40
  }( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
43
41
  var LocalPreviewError = exports.LocalPreviewError = /*#__PURE__*/function (_MediaFilePreviewErro) {
44
- (0, _inherits2.default)(LocalPreviewError, _MediaFilePreviewErro);
45
- var _super2 = _createSuper(LocalPreviewError);
46
42
  function LocalPreviewError(primaryReason, secondaryError) {
47
43
  var _this2;
48
44
  (0, _classCallCheck2.default)(this, LocalPreviewError);
49
- _this2 = _super2.call(this, primaryReason, secondaryError);
45
+ _this2 = _callSuper(this, LocalPreviewError, [primaryReason, secondaryError]);
50
46
  _this2.primaryReason = primaryReason;
51
47
  _this2.secondaryError = secondaryError;
52
48
  return _this2;
53
49
  }
50
+ (0, _inherits2.default)(LocalPreviewError, _MediaFilePreviewErro);
54
51
  return (0, _createClass2.default)(LocalPreviewError);
55
52
  }(MediaFilePreviewError);
56
53
  var RemotePreviewError = exports.RemotePreviewError = /*#__PURE__*/function (_MediaFilePreviewErro2) {
57
- (0, _inherits2.default)(RemotePreviewError, _MediaFilePreviewErro2);
58
- var _super3 = _createSuper(RemotePreviewError);
59
54
  function RemotePreviewError(primaryReason, secondaryError) {
60
55
  var _this3;
61
56
  (0, _classCallCheck2.default)(this, RemotePreviewError);
62
- _this3 = _super3.call(this, primaryReason, secondaryError);
57
+ _this3 = _callSuper(this, RemotePreviewError, [primaryReason, secondaryError]);
63
58
  _this3.primaryReason = primaryReason;
64
59
  _this3.secondaryError = secondaryError;
65
60
  return _this3;
66
61
  }
62
+ (0, _inherits2.default)(RemotePreviewError, _MediaFilePreviewErro2);
67
63
  return (0, _createClass2.default)(RemotePreviewError);
68
64
  }(MediaFilePreviewError);
69
65
  var SsrPreviewError = exports.SsrPreviewError = /*#__PURE__*/function (_MediaFilePreviewErro3) {
70
- (0, _inherits2.default)(SsrPreviewError, _MediaFilePreviewErro3);
71
- var _super4 = _createSuper(SsrPreviewError);
72
66
  function SsrPreviewError(primaryReason, secondaryError) {
73
67
  var _this4;
74
68
  (0, _classCallCheck2.default)(this, SsrPreviewError);
75
- _this4 = _super4.call(this, primaryReason, secondaryError);
69
+ _this4 = _callSuper(this, SsrPreviewError, [primaryReason, secondaryError]);
76
70
  _this4.primaryReason = primaryReason;
77
71
  _this4.secondaryError = secondaryError;
78
72
  return _this4;
79
73
  }
74
+ (0, _inherits2.default)(SsrPreviewError, _MediaFilePreviewErro3);
80
75
  return (0, _createClass2.default)(SsrPreviewError);
81
76
  }(MediaFilePreviewError);
82
77
  var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
@@ -102,12 +97,11 @@ var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
102
97
  }
103
98
  };
104
99
  var ImageLoadError = exports.ImageLoadError = /*#__PURE__*/function (_MediaFilePreviewErro4) {
105
- (0, _inherits2.default)(ImageLoadError, _MediaFilePreviewErro4);
106
- var _super5 = _createSuper(ImageLoadError);
107
100
  function ImageLoadError(source) {
108
101
  (0, _classCallCheck2.default)(this, ImageLoadError);
109
- return _super5.call(this, getImageLoadPrimaryReason(source));
102
+ return _callSuper(this, ImageLoadError, [getImageLoadPrimaryReason(source)]);
110
103
  }
104
+ (0, _inherits2.default)(ImageLoadError, _MediaFilePreviewErro4);
111
105
  return (0, _createClass2.default)(ImageLoadError);
112
106
  }(MediaFilePreviewError);
113
107
  function isMediaFilePreviewError(err) {
@@ -7,29 +7,29 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.createObjectURLCache = exports.PREVIEW_CACHE_LRU_SIZE = exports.ObjectURLCache = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
10
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
11
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _eventemitter = require("eventemitter2");
15
15
  var _lru_map = require("lru_map");
16
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
16
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
17
17
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18
+ function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
18
19
  var PREVIEW_CACHE_LRU_SIZE = exports.PREVIEW_CACHE_LRU_SIZE = 50;
19
20
  var ExtendedLRUCache = /*#__PURE__*/function (_LRUMap) {
20
- (0, _inherits2.default)(ExtendedLRUCache, _LRUMap);
21
- var _super = _createSuper(ExtendedLRUCache);
22
21
  function ExtendedLRUCache(limit) {
23
22
  var _this;
24
23
  (0, _classCallCheck2.default)(this, ExtendedLRUCache);
25
- _this = _super.call(this, limit);
24
+ _this = _callSuper(this, ExtendedLRUCache, [limit]);
26
25
  _this.eventEmitter = new _eventemitter.EventEmitter2();
27
26
  return _this;
28
27
  }
29
- (0, _createClass2.default)(ExtendedLRUCache, [{
28
+ (0, _inherits2.default)(ExtendedLRUCache, _LRUMap);
29
+ return (0, _createClass2.default)(ExtendedLRUCache, [{
30
30
  key: "shift",
31
31
  value: function shift() {
32
- var entry = (0, _get2.default)((0, _getPrototypeOf2.default)(ExtendedLRUCache.prototype), "shift", this).call(this);
32
+ var entry = _superPropGet(ExtendedLRUCache, "shift", this, 3)([]);
33
33
  this.eventEmitter.emit('shift', entry);
34
34
  return entry;
35
35
  }
@@ -39,7 +39,6 @@ var ExtendedLRUCache = /*#__PURE__*/function (_LRUMap) {
39
39
  this.eventEmitter.on(event, callback);
40
40
  }
41
41
  }]);
42
- return ExtendedLRUCache;
43
42
  }(_lru_map.LRUMap);
44
43
  var ObjectURLCache = exports.ObjectURLCache = /*#__PURE__*/function () {
45
44
  function ObjectURLCache(size) {
@@ -51,7 +50,7 @@ var ObjectURLCache = exports.ObjectURLCache = /*#__PURE__*/function () {
51
50
  }
52
51
  });
53
52
  }
54
- (0, _createClass2.default)(ObjectURLCache, [{
53
+ return (0, _createClass2.default)(ObjectURLCache, [{
55
54
  key: "has",
56
55
  value: function has(key) {
57
56
  return !!this.cache.find(key);
@@ -78,7 +77,6 @@ var ObjectURLCache = exports.ObjectURLCache = /*#__PURE__*/function () {
78
77
  this.cache.clear();
79
78
  }
80
79
  }]);
81
- return ObjectURLCache;
82
80
  }();
83
81
  var createObjectURLCache = exports.createObjectURLCache = function createObjectURLCache() {
84
82
  return new ObjectURLCache(PREVIEW_CACHE_LRU_SIZE);
@@ -124,7 +124,6 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
124
124
  fileState = _useFileState.fileState;
125
125
 
126
126
  // Derived from File State
127
- var fileStatus = fileState === null || fileState === void 0 ? void 0 : fileState.status;
128
127
  var isBackendPreviewReady = !!fileState && (0, _mediaClient.isImageRepresentationReady)(fileState);
129
128
  var fileStateErrorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' ? fileState.message : undefined;
130
129
  var _ref2 = fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error' ? fileState : {},
@@ -145,19 +144,19 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
145
144
  }, [identifier]);
146
145
  (0, _react.useEffect)(function () {
147
146
  if (status !== 'error') {
148
- if (preview || fileStatus === 'processed' && !isBackendPreviewReady) {
147
+ if (preview || (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'processed' && !isBackendPreviewReady) {
149
148
  setStatus('complete');
150
- } else if (!preview && fileStatus === 'failed-processing' && !isBackendPreviewReady) {
149
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'failed-processing' && !isBackendPreviewReady) {
151
150
  setStatus('error');
152
151
  setError(new _errors.MediaFilePreviewError('failed-processing'));
153
- } else if (!preview && fileStatus === 'error' && upfrontPreviewStatus === 'resolved') {
152
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' && upfrontPreviewStatus === 'resolved') {
154
153
  setStatus('error');
155
- setError(new _errors.MediaFilePreviewError('metadata-fetch', new Error(fileStateErrorMessage)));
154
+ setError(new _errors.MediaFilePreviewError('metadata-fetch', (0, _mediaClient.toCommonMediaClientError)(fileState)));
156
155
  } else {
157
156
  setStatus('loading');
158
157
  }
159
158
  }
160
- }, [preview, status, fileStatus, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
159
+ }, [preview, status, fileState, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
161
160
 
162
161
  //----------------------------------------------------------------
163
162
  // Preview Fetch Helper
@@ -303,6 +302,10 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
303
302
  var _ssrReliabilityRef$cu;
304
303
  return (0, _globalScope.generateScriptProps)(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
305
304
  } : undefined;
305
+ var _useCopyIntent = (0, _mediaClientReact.useCopyIntent)(identifier.id, {
306
+ collectionName: identifier.collectionName
307
+ }),
308
+ copyNodeRef = _useCopyIntent.copyNodeRef;
306
309
 
307
310
  // CXP-2723 TODO: should consider simplifying our analytics, and how
308
311
  // we might get rid of ssrReliabiltyRef from our hook
@@ -314,6 +317,7 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
314
317
  ssrReliability: ssrReliabilityRef.current,
315
318
  onImageError: onImageError,
316
319
  onImageLoad: onImageLoad,
317
- getSsrScriptProps: getSsrScriptProps
320
+ getSsrScriptProps: getSsrScriptProps,
321
+ copyNodeRef: copyNodeRef
318
322
  };
319
323
  };
@@ -1,39 +1,34 @@
1
- import { getMediaClientErrorReason, isMediaClientError, isRequestError } from '@atlaskit/media-client';
2
- import { getFileStateErrorReason, isMediaFileStateError } from '@atlaskit/media-client-react';
3
- import { ImageLoadError, isMediaFilePreviewError } from './errors';
1
+ import { isCommonMediaClientError } from '@atlaskit/media-client';
2
+ import { ImageLoadError } from './errors';
4
3
  export const getErrorTraceContext = error => {
5
- if (isMediaFilePreviewError(error) && !!error.secondaryError) {
6
- if (isRequestError(error.secondaryError)) {
7
- var _error$secondaryError;
8
- return (_error$secondaryError = error.secondaryError.metadata) === null || _error$secondaryError === void 0 ? void 0 : _error$secondaryError.traceContext;
9
- } else if (isMediaFileStateError(error.secondaryError)) {
10
- var _error$secondaryError2, _error$secondaryError3;
11
- return (_error$secondaryError2 = error.secondaryError.details) === null || _error$secondaryError2 === void 0 ? void 0 : (_error$secondaryError3 = _error$secondaryError2.metadata) === null || _error$secondaryError3 === void 0 ? void 0 : _error$secondaryError3.traceContext;
12
- }
4
+ const {
5
+ secondaryError
6
+ } = error;
7
+ if (isCommonMediaClientError(secondaryError)) {
8
+ var _secondaryError$metad;
9
+ return (_secondaryError$metad = secondaryError.metadata) === null || _secondaryError$metad === void 0 ? void 0 : _secondaryError$metad.traceContext;
13
10
  }
14
11
  };
15
12
  export const getRenderErrorFailReason = error => {
16
- if (isMediaFilePreviewError(error)) {
17
- return error.primaryReason;
18
- } else {
19
- return 'nativeError';
20
- }
13
+ return error.primaryReason || 'nativeError';
21
14
  };
22
15
  export const getRenderErrorErrorReason = error => {
23
- if (isMediaFilePreviewError(error) && error.secondaryError) {
24
- const mediaClientReason = isMediaClientError(error.secondaryError) ? getMediaClientErrorReason(error.secondaryError) : getFileStateErrorReason(error.secondaryError);
25
- if (mediaClientReason !== 'unknown') {
26
- return mediaClientReason;
27
- }
16
+ const {
17
+ secondaryError
18
+ } = error;
19
+ if (isCommonMediaClientError(secondaryError)) {
20
+ return secondaryError.reason;
28
21
  }
29
22
  return 'nativeError';
30
23
  };
31
24
  export const getRenderErrorErrorDetail = error => {
32
- if (isMediaFilePreviewError(error) && error.secondaryError) {
33
- return error.secondaryError.message;
34
- } else {
35
- return error.message;
25
+ const {
26
+ secondaryError
27
+ } = error;
28
+ if (isCommonMediaClientError(secondaryError)) {
29
+ return secondaryError.message;
36
30
  }
31
+ return error.message;
37
32
  };
38
33
  export const extractErrorInfo = (error, metadataTraceContext) => {
39
34
  return {
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { isImageRepresentationReady } from '@atlaskit/media-client';
3
- import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
2
+ import { isImageRepresentationReady, toCommonMediaClientError } from '@atlaskit/media-client';
3
+ import { useCopyIntent, useFileState, useMediaClient } from '@atlaskit/media-client-react';
4
4
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
5
5
  import { createFailedSSRObject, extractErrorInfo } from './analytics';
6
6
  import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
@@ -99,7 +99,6 @@ export const useFilePreview = ({
99
99
  });
100
100
 
101
101
  // Derived from File State
102
- const fileStatus = fileState === null || fileState === void 0 ? void 0 : fileState.status;
103
102
  const isBackendPreviewReady = !!fileState && isImageRepresentationReady(fileState);
104
103
  const fileStateErrorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' ? fileState.message : undefined;
105
104
  const {
@@ -118,19 +117,19 @@ export const useFilePreview = ({
118
117
  }, [identifier]);
119
118
  useEffect(() => {
120
119
  if (status !== 'error') {
121
- if (preview || fileStatus === 'processed' && !isBackendPreviewReady) {
120
+ if (preview || (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'processed' && !isBackendPreviewReady) {
122
121
  setStatus('complete');
123
- } else if (!preview && fileStatus === 'failed-processing' && !isBackendPreviewReady) {
122
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'failed-processing' && !isBackendPreviewReady) {
124
123
  setStatus('error');
125
124
  setError(new MediaFilePreviewError('failed-processing'));
126
- } else if (!preview && fileStatus === 'error' && upfrontPreviewStatus === 'resolved') {
125
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' && upfrontPreviewStatus === 'resolved') {
127
126
  setStatus('error');
128
- setError(new MediaFilePreviewError('metadata-fetch', new Error(fileStateErrorMessage)));
127
+ setError(new MediaFilePreviewError('metadata-fetch', toCommonMediaClientError(fileState)));
129
128
  } else {
130
129
  setStatus('loading');
131
130
  }
132
131
  }
133
- }, [preview, status, fileStatus, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
132
+ }, [preview, status, fileState, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
134
133
 
135
134
  //----------------------------------------------------------------
136
135
  // Preview Fetch Helper
@@ -278,6 +277,11 @@ export const useFilePreview = ({
278
277
  var _ssrReliabilityRef$cu;
279
278
  return generateScriptProps(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
280
279
  } : undefined;
280
+ const {
281
+ copyNodeRef
282
+ } = useCopyIntent(identifier.id, {
283
+ collectionName: identifier.collectionName
284
+ });
281
285
 
282
286
  // CXP-2723 TODO: should consider simplifying our analytics, and how
283
287
  // we might get rid of ssrReliabiltyRef from our hook
@@ -289,6 +293,7 @@ export const useFilePreview = ({
289
293
  ssrReliability: ssrReliabilityRef.current,
290
294
  onImageError,
291
295
  onImageLoad,
292
- getSsrScriptProps
296
+ getSsrScriptProps,
297
+ copyNodeRef
293
298
  };
294
299
  };
@@ -1,42 +1,31 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { getMediaClientErrorReason, isMediaClientError, isRequestError } from '@atlaskit/media-client';
5
- import { getFileStateErrorReason, isMediaFileStateError } from '@atlaskit/media-client-react';
6
- import { ImageLoadError, isMediaFilePreviewError } from './errors';
4
+ import { isCommonMediaClientError } from '@atlaskit/media-client';
5
+ import { ImageLoadError } from './errors';
7
6
  export var getErrorTraceContext = function getErrorTraceContext(error) {
8
- if (isMediaFilePreviewError(error) && !!error.secondaryError) {
9
- if (isRequestError(error.secondaryError)) {
10
- var _error$secondaryError;
11
- return (_error$secondaryError = error.secondaryError.metadata) === null || _error$secondaryError === void 0 ? void 0 : _error$secondaryError.traceContext;
12
- } else if (isMediaFileStateError(error.secondaryError)) {
13
- var _error$secondaryError2;
14
- return (_error$secondaryError2 = error.secondaryError.details) === null || _error$secondaryError2 === void 0 || (_error$secondaryError2 = _error$secondaryError2.metadata) === null || _error$secondaryError2 === void 0 ? void 0 : _error$secondaryError2.traceContext;
15
- }
7
+ var secondaryError = error.secondaryError;
8
+ if (isCommonMediaClientError(secondaryError)) {
9
+ var _secondaryError$metad;
10
+ return (_secondaryError$metad = secondaryError.metadata) === null || _secondaryError$metad === void 0 ? void 0 : _secondaryError$metad.traceContext;
16
11
  }
17
12
  };
18
13
  export var getRenderErrorFailReason = function getRenderErrorFailReason(error) {
19
- if (isMediaFilePreviewError(error)) {
20
- return error.primaryReason;
21
- } else {
22
- return 'nativeError';
23
- }
14
+ return error.primaryReason || 'nativeError';
24
15
  };
25
16
  export var getRenderErrorErrorReason = function getRenderErrorErrorReason(error) {
26
- if (isMediaFilePreviewError(error) && error.secondaryError) {
27
- var mediaClientReason = isMediaClientError(error.secondaryError) ? getMediaClientErrorReason(error.secondaryError) : getFileStateErrorReason(error.secondaryError);
28
- if (mediaClientReason !== 'unknown') {
29
- return mediaClientReason;
30
- }
17
+ var secondaryError = error.secondaryError;
18
+ if (isCommonMediaClientError(secondaryError)) {
19
+ return secondaryError.reason;
31
20
  }
32
21
  return 'nativeError';
33
22
  };
34
23
  export var getRenderErrorErrorDetail = function getRenderErrorErrorDetail(error) {
35
- if (isMediaFilePreviewError(error) && error.secondaryError) {
36
- return error.secondaryError.message;
37
- } else {
38
- return error.message;
24
+ var secondaryError = error.secondaryError;
25
+ if (isCommonMediaClientError(secondaryError)) {
26
+ return secondaryError.message;
39
27
  }
28
+ return error.message;
40
29
  };
41
30
  export var extractErrorInfo = function extractErrorInfo(error, metadataTraceContext) {
42
31
  return {
@@ -1,11 +1,10 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
7
6
  import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
8
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
9
  /**
11
10
  * Primary reason is logged through Data Portal.
@@ -13,62 +12,58 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
13
12
  */
14
13
 
15
14
  export var MediaFilePreviewError = /*#__PURE__*/function (_Error) {
16
- _inherits(MediaFilePreviewError, _Error);
17
- var _super = _createSuper(MediaFilePreviewError);
18
15
  function MediaFilePreviewError(primaryReason, secondaryError) {
19
16
  var _this;
20
17
  _classCallCheck(this, MediaFilePreviewError);
21
- _this = _super.call(this, primaryReason);
18
+ _this = _callSuper(this, MediaFilePreviewError, [primaryReason]);
22
19
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget
23
20
  _this.primaryReason = primaryReason;
24
21
  _this.secondaryError = secondaryError;
25
- Object.setPrototypeOf(_assertThisInitialized(_this), (this instanceof MediaFilePreviewError ? this.constructor : void 0).prototype);
22
+ Object.setPrototypeOf(_this, (this instanceof MediaFilePreviewError ? this.constructor : void 0).prototype);
26
23
 
27
24
  // https://v8.dev/docs/stack-trace-api
28
25
  if ('captureStackTrace' in Error) {
29
- Error.captureStackTrace(_assertThisInitialized(_this), this instanceof MediaFilePreviewError ? this.constructor : void 0);
26
+ Error.captureStackTrace(_this, this instanceof MediaFilePreviewError ? this.constructor : void 0);
30
27
  }
31
28
  return _this;
32
29
  }
30
+ _inherits(MediaFilePreviewError, _Error);
33
31
  return _createClass(MediaFilePreviewError);
34
32
  }( /*#__PURE__*/_wrapNativeSuper(Error));
35
33
  export var LocalPreviewError = /*#__PURE__*/function (_MediaFilePreviewErro) {
36
- _inherits(LocalPreviewError, _MediaFilePreviewErro);
37
- var _super2 = _createSuper(LocalPreviewError);
38
34
  function LocalPreviewError(primaryReason, secondaryError) {
39
35
  var _this2;
40
36
  _classCallCheck(this, LocalPreviewError);
41
- _this2 = _super2.call(this, primaryReason, secondaryError);
37
+ _this2 = _callSuper(this, LocalPreviewError, [primaryReason, secondaryError]);
42
38
  _this2.primaryReason = primaryReason;
43
39
  _this2.secondaryError = secondaryError;
44
40
  return _this2;
45
41
  }
42
+ _inherits(LocalPreviewError, _MediaFilePreviewErro);
46
43
  return _createClass(LocalPreviewError);
47
44
  }(MediaFilePreviewError);
48
45
  export var RemotePreviewError = /*#__PURE__*/function (_MediaFilePreviewErro2) {
49
- _inherits(RemotePreviewError, _MediaFilePreviewErro2);
50
- var _super3 = _createSuper(RemotePreviewError);
51
46
  function RemotePreviewError(primaryReason, secondaryError) {
52
47
  var _this3;
53
48
  _classCallCheck(this, RemotePreviewError);
54
- _this3 = _super3.call(this, primaryReason, secondaryError);
49
+ _this3 = _callSuper(this, RemotePreviewError, [primaryReason, secondaryError]);
55
50
  _this3.primaryReason = primaryReason;
56
51
  _this3.secondaryError = secondaryError;
57
52
  return _this3;
58
53
  }
54
+ _inherits(RemotePreviewError, _MediaFilePreviewErro2);
59
55
  return _createClass(RemotePreviewError);
60
56
  }(MediaFilePreviewError);
61
57
  export var SsrPreviewError = /*#__PURE__*/function (_MediaFilePreviewErro3) {
62
- _inherits(SsrPreviewError, _MediaFilePreviewErro3);
63
- var _super4 = _createSuper(SsrPreviewError);
64
58
  function SsrPreviewError(primaryReason, secondaryError) {
65
59
  var _this4;
66
60
  _classCallCheck(this, SsrPreviewError);
67
- _this4 = _super4.call(this, primaryReason, secondaryError);
61
+ _this4 = _callSuper(this, SsrPreviewError, [primaryReason, secondaryError]);
68
62
  _this4.primaryReason = primaryReason;
69
63
  _this4.secondaryError = secondaryError;
70
64
  return _this4;
71
65
  }
66
+ _inherits(SsrPreviewError, _MediaFilePreviewErro3);
72
67
  return _createClass(SsrPreviewError);
73
68
  }(MediaFilePreviewError);
74
69
  var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
@@ -94,12 +89,11 @@ var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
94
89
  }
95
90
  };
96
91
  export var ImageLoadError = /*#__PURE__*/function (_MediaFilePreviewErro4) {
97
- _inherits(ImageLoadError, _MediaFilePreviewErro4);
98
- var _super5 = _createSuper(ImageLoadError);
99
92
  function ImageLoadError(source) {
100
93
  _classCallCheck(this, ImageLoadError);
101
- return _super5.call(this, getImageLoadPrimaryReason(source));
94
+ return _callSuper(this, ImageLoadError, [getImageLoadPrimaryReason(source)]);
102
95
  }
96
+ _inherits(ImageLoadError, _MediaFilePreviewErro4);
103
97
  return _createClass(ImageLoadError);
104
98
  }(MediaFilePreviewError);
105
99
  export function isMediaFilePreviewError(err) {
@@ -1,28 +1,28 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _get from "@babel/runtime/helpers/get";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
3
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
4
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
5
+ import _get from "@babel/runtime/helpers/get";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
+ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
9
10
  import { EventEmitter2 } from 'eventemitter2';
10
11
  import { LRUMap } from 'lru_map';
11
12
  export var PREVIEW_CACHE_LRU_SIZE = 50;
12
13
  var ExtendedLRUCache = /*#__PURE__*/function (_LRUMap) {
13
- _inherits(ExtendedLRUCache, _LRUMap);
14
- var _super = _createSuper(ExtendedLRUCache);
15
14
  function ExtendedLRUCache(limit) {
16
15
  var _this;
17
16
  _classCallCheck(this, ExtendedLRUCache);
18
- _this = _super.call(this, limit);
17
+ _this = _callSuper(this, ExtendedLRUCache, [limit]);
19
18
  _this.eventEmitter = new EventEmitter2();
20
19
  return _this;
21
20
  }
22
- _createClass(ExtendedLRUCache, [{
21
+ _inherits(ExtendedLRUCache, _LRUMap);
22
+ return _createClass(ExtendedLRUCache, [{
23
23
  key: "shift",
24
24
  value: function shift() {
25
- var entry = _get(_getPrototypeOf(ExtendedLRUCache.prototype), "shift", this).call(this);
25
+ var entry = _superPropGet(ExtendedLRUCache, "shift", this, 3)([]);
26
26
  this.eventEmitter.emit('shift', entry);
27
27
  return entry;
28
28
  }
@@ -32,7 +32,6 @@ var ExtendedLRUCache = /*#__PURE__*/function (_LRUMap) {
32
32
  this.eventEmitter.on(event, callback);
33
33
  }
34
34
  }]);
35
- return ExtendedLRUCache;
36
35
  }(LRUMap);
37
36
  export var ObjectURLCache = /*#__PURE__*/function () {
38
37
  function ObjectURLCache(size) {
@@ -44,7 +43,7 @@ export var ObjectURLCache = /*#__PURE__*/function () {
44
43
  }
45
44
  });
46
45
  }
47
- _createClass(ObjectURLCache, [{
46
+ return _createClass(ObjectURLCache, [{
48
47
  key: "has",
49
48
  value: function has(key) {
50
49
  return !!this.cache.find(key);
@@ -71,7 +70,6 @@ export var ObjectURLCache = /*#__PURE__*/function () {
71
70
  this.cache.clear();
72
71
  }
73
72
  }]);
74
- return ObjectURLCache;
75
73
  }();
76
74
  export var createObjectURLCache = function createObjectURLCache() {
77
75
  return new ObjectURLCache(PREVIEW_CACHE_LRU_SIZE);
@@ -3,8 +3,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
- import { isImageRepresentationReady } from '@atlaskit/media-client';
7
- import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
6
+ import { isImageRepresentationReady, toCommonMediaClientError } from '@atlaskit/media-client';
7
+ import { useCopyIntent, useFileState, useMediaClient } from '@atlaskit/media-client-react';
8
8
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
9
9
  import { createFailedSSRObject, extractErrorInfo } from './analytics';
10
10
  import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
@@ -117,7 +117,6 @@ export var useFilePreview = function useFilePreview(_ref) {
117
117
  fileState = _useFileState.fileState;
118
118
 
119
119
  // Derived from File State
120
- var fileStatus = fileState === null || fileState === void 0 ? void 0 : fileState.status;
121
120
  var isBackendPreviewReady = !!fileState && isImageRepresentationReady(fileState);
122
121
  var fileStateErrorMessage = (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' ? fileState.message : undefined;
123
122
  var _ref2 = fileState && (fileState === null || fileState === void 0 ? void 0 : fileState.status) !== 'error' ? fileState : {},
@@ -138,19 +137,19 @@ export var useFilePreview = function useFilePreview(_ref) {
138
137
  }, [identifier]);
139
138
  useEffect(function () {
140
139
  if (status !== 'error') {
141
- if (preview || fileStatus === 'processed' && !isBackendPreviewReady) {
140
+ if (preview || (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'processed' && !isBackendPreviewReady) {
142
141
  setStatus('complete');
143
- } else if (!preview && fileStatus === 'failed-processing' && !isBackendPreviewReady) {
142
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'failed-processing' && !isBackendPreviewReady) {
144
143
  setStatus('error');
145
144
  setError(new MediaFilePreviewError('failed-processing'));
146
- } else if (!preview && fileStatus === 'error' && upfrontPreviewStatus === 'resolved') {
145
+ } else if (!preview && (fileState === null || fileState === void 0 ? void 0 : fileState.status) === 'error' && upfrontPreviewStatus === 'resolved') {
147
146
  setStatus('error');
148
- setError(new MediaFilePreviewError('metadata-fetch', new Error(fileStateErrorMessage)));
147
+ setError(new MediaFilePreviewError('metadata-fetch', toCommonMediaClientError(fileState)));
149
148
  } else {
150
149
  setStatus('loading');
151
150
  }
152
151
  }
153
- }, [preview, status, fileStatus, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
152
+ }, [preview, status, fileState, isBackendPreviewReady, fileStateErrorMessage, upfrontPreviewStatus]);
154
153
 
155
154
  //----------------------------------------------------------------
156
155
  // Preview Fetch Helper
@@ -296,6 +295,10 @@ export var useFilePreview = function useFilePreview(_ref) {
296
295
  var _ssrReliabilityRef$cu;
297
296
  return generateScriptProps(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
298
297
  } : undefined;
298
+ var _useCopyIntent = useCopyIntent(identifier.id, {
299
+ collectionName: identifier.collectionName
300
+ }),
301
+ copyNodeRef = _useCopyIntent.copyNodeRef;
299
302
 
300
303
  // CXP-2723 TODO: should consider simplifying our analytics, and how
301
304
  // we might get rid of ssrReliabiltyRef from our hook
@@ -307,6 +310,7 @@ export var useFilePreview = function useFilePreview(_ref) {
307
310
  ssrReliability: ssrReliabilityRef.current,
308
311
  onImageError: onImageError,
309
312
  onImageLoad: onImageLoad,
310
- getSsrScriptProps: getSsrScriptProps
313
+ getSsrScriptProps: getSsrScriptProps,
314
+ copyNodeRef: copyNodeRef
311
315
  };
312
316
  };
@@ -38,4 +38,5 @@ export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions,
38
38
  onImageError: (failedPreview?: MediaFilePreview) => void;
39
39
  onImageLoad: (newPreview?: MediaFilePreview) => void;
40
40
  getSsrScriptProps: (() => import("react").ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
41
+ copyNodeRef: (instance: HTMLImageElement | HTMLDivElement | null) => void;
41
42
  };
@@ -38,4 +38,5 @@ export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions,
38
38
  onImageError: (failedPreview?: MediaFilePreview) => void;
39
39
  onImageLoad: (newPreview?: MediaFilePreview) => void;
40
40
  getSsrScriptProps: (() => import("react").ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
41
+ copyNodeRef: (instance: HTMLImageElement | HTMLDivElement | null) => void;
41
42
  };
@@ -19,9 +19,9 @@ export const TerminalTextDisplay: React.FC<TerminalTextDisplayProps> = ({
19
19
  borderRadius: 5,
20
20
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
21
21
  padding: 20,
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
22
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
23
23
  fontFamily: 'Courier New, monospace',
24
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
24
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography -- Ignored via go/DSP-18766
25
25
  lineHeight: '1.4',
26
26
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
27
27
  maxWidth: 600,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "A React Hook to fetch and render file previews. It's overloaded with fancy features like SSR, lazy loading, memory cache and local preview.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,10 +34,10 @@
34
34
  ".": "./src/index.ts"
35
35
  },
36
36
  "dependencies": {
37
- "@atlaskit/media-client": "^28.3.0",
38
- "@atlaskit/media-client-react": "^2.3.0",
37
+ "@atlaskit/media-client": "^30.0.0",
38
+ "@atlaskit/media-client-react": "^2.6.0",
39
39
  "@atlaskit/media-common": "^11.7.0",
40
- "@atlaskit/media-ui": "^27.0.0",
40
+ "@atlaskit/media-ui": "^27.3.0",
41
41
  "@atlaskit/platform-feature-flags": "^0.3.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "eventemitter2": "^4.1.0",
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@af/integration-testing": "*",
52
52
  "@af/visual-regression": "*",
53
- "@atlaskit/media-state": "^1.1.0",
54
- "@atlaskit/media-test-data": "^2.7.0",
55
- "@atlaskit/section-message": "^6.7.0",
53
+ "@atlaskit/media-state": "^1.5.0",
54
+ "@atlaskit/media-test-data": "^2.9.0",
55
+ "@atlaskit/section-message": "^6.8.0",
56
56
  "@atlaskit/ssr": "*",
57
57
  "@atlaskit/visual-regression": "*",
58
58
  "@testing-library/react": "^12.1.5",