@atlaskit/media-file-preview 0.9.3 → 0.9.5

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,19 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.9.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 0.9.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#165609](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165609)
14
+ [`b29c0cc4fef46`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b29c0cc4fef46) -
15
+ Cleaned up media card perf observer feature flag
16
+
3
17
  ## 0.9.3
4
18
 
5
19
  ### Patch Changes
@@ -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);
@@ -11,7 +11,6 @@ var _react = require("react");
11
11
  var _mediaClient = require("@atlaskit/media-client");
12
12
  var _mediaClientReact = require("@atlaskit/media-client-react");
13
13
  var _mediaCommon = require("@atlaskit/media-common");
14
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
14
  var _analytics = require("./analytics");
16
15
  var _errors = require("./errors");
17
16
  var _getPreview = require("./getPreview");
@@ -74,11 +73,9 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
74
73
  upscale: upscale,
75
74
  'max-age': maxAge
76
75
  });
77
- if ((0, _platformFeatureFlags.fg)('platform.media-card-performance-observer_a803k')) {
78
- imageURLParams = _objectSpread(_objectSpread({}, imageURLParams), {}, {
79
- source: source
80
- });
81
- }
76
+ imageURLParams = _objectSpread(_objectSpread({}, imageURLParams), {}, {
77
+ source: source
78
+ });
82
79
  var previewInitializer = function previewInitializer() {
83
80
  var preview = _getPreview.mediaFilePreviewCache.get(identifier.id, resizeMode);
84
81
  if (preview) {
@@ -306,6 +303,10 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
306
303
  var _ssrReliabilityRef$cu;
307
304
  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);
308
305
  } : undefined;
306
+ var _useCopyIntent = (0, _mediaClientReact.useCopyIntent)(identifier.id, {
307
+ collectionName: identifier.collectionName
308
+ }),
309
+ copyNodeRef = _useCopyIntent.copyNodeRef;
309
310
 
310
311
  // CXP-2723 TODO: should consider simplifying our analytics, and how
311
312
  // we might get rid of ssrReliabiltyRef from our hook
@@ -317,6 +318,7 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
317
318
  ssrReliability: ssrReliabilityRef.current,
318
319
  onImageError: onImageError,
319
320
  onImageLoad: onImageLoad,
320
- getSsrScriptProps: getSsrScriptProps
321
+ getSsrScriptProps: getSsrScriptProps,
322
+ copyNodeRef: copyNodeRef
321
323
  };
322
324
  };
@@ -1,8 +1,7 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { isImageRepresentationReady } from '@atlaskit/media-client';
3
- import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
3
+ import { useCopyIntent, useFileState, useMediaClient } from '@atlaskit/media-client-react';
4
4
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  import { createFailedSSRObject, extractErrorInfo } from './analytics';
7
6
  import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
8
7
  import { getAndCacheLocalPreview, getAndCacheRemotePreview, getSSRPreview, isLocalPreview, isRemotePreview, isSSRClientPreview, isSSRDataPreview, isSSRPreview, isSupportedLocalPreview, mediaFilePreviewCache } from './getPreview';
@@ -46,12 +45,10 @@ export const useFilePreview = ({
46
45
  upscale,
47
46
  'max-age': maxAge
48
47
  };
49
- if (fg('platform.media-card-performance-observer_a803k')) {
50
- imageURLParams = {
51
- ...imageURLParams,
52
- source
53
- };
54
- }
48
+ imageURLParams = {
49
+ ...imageURLParams,
50
+ source
51
+ };
55
52
  const previewInitializer = () => {
56
53
  const preview = mediaFilePreviewCache.get(identifier.id, resizeMode);
57
54
  if (preview) {
@@ -281,6 +278,11 @@ export const useFilePreview = ({
281
278
  var _ssrReliabilityRef$cu;
282
279
  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);
283
280
  } : undefined;
281
+ const {
282
+ copyNodeRef
283
+ } = useCopyIntent(identifier.id, {
284
+ collectionName: identifier.collectionName
285
+ });
284
286
 
285
287
  // CXP-2723 TODO: should consider simplifying our analytics, and how
286
288
  // we might get rid of ssrReliabiltyRef from our hook
@@ -292,6 +294,7 @@ export const useFilePreview = ({
292
294
  ssrReliability: ssrReliabilityRef.current,
293
295
  onImageError,
294
296
  onImageLoad,
295
- getSsrScriptProps
297
+ getSsrScriptProps,
298
+ copyNodeRef
296
299
  };
297
300
  };
@@ -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);
@@ -4,9 +4,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
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
6
  import { isImageRepresentationReady } from '@atlaskit/media-client';
7
- import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
7
+ import { useCopyIntent, useFileState, useMediaClient } from '@atlaskit/media-client-react';
8
8
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
9
- import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { createFailedSSRObject, extractErrorInfo } from './analytics';
11
10
  import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
12
11
  import { getAndCacheLocalPreview, getAndCacheRemotePreview, getSSRPreview, isLocalPreview, isRemotePreview, isSSRClientPreview, isSSRDataPreview, isSSRPreview, isSupportedLocalPreview, mediaFilePreviewCache } from './getPreview';
@@ -67,11 +66,9 @@ export var useFilePreview = function useFilePreview(_ref) {
67
66
  upscale: upscale,
68
67
  'max-age': maxAge
69
68
  });
70
- if (fg('platform.media-card-performance-observer_a803k')) {
71
- imageURLParams = _objectSpread(_objectSpread({}, imageURLParams), {}, {
72
- source: source
73
- });
74
- }
69
+ imageURLParams = _objectSpread(_objectSpread({}, imageURLParams), {}, {
70
+ source: source
71
+ });
75
72
  var previewInitializer = function previewInitializer() {
76
73
  var preview = mediaFilePreviewCache.get(identifier.id, resizeMode);
77
74
  if (preview) {
@@ -299,6 +296,10 @@ export var useFilePreview = function useFilePreview(_ref) {
299
296
  var _ssrReliabilityRef$cu;
300
297
  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);
301
298
  } : undefined;
299
+ var _useCopyIntent = useCopyIntent(identifier.id, {
300
+ collectionName: identifier.collectionName
301
+ }),
302
+ copyNodeRef = _useCopyIntent.copyNodeRef;
302
303
 
303
304
  // CXP-2723 TODO: should consider simplifying our analytics, and how
304
305
  // we might get rid of ssrReliabiltyRef from our hook
@@ -310,6 +311,7 @@ export var useFilePreview = function useFilePreview(_ref) {
310
311
  ssrReliability: ssrReliabilityRef.current,
311
312
  onImageError: onImageError,
312
313
  onImageLoad: onImageLoad,
313
- getSsrScriptProps: getSsrScriptProps
314
+ getSsrScriptProps: getSsrScriptProps,
315
+ copyNodeRef: copyNodeRef
314
316
  };
315
317
  };
@@ -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: import("react").RefObject<HTMLImageElement | HTMLDivElement>;
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: import("react").RefObject<HTMLImageElement | HTMLDivElement>;
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
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": "^29.0.0",
38
+ "@atlaskit/media-client-react": "^2.5.0",
39
39
  "@atlaskit/media-common": "^11.7.0",
40
- "@atlaskit/media-ui": "^27.0.0",
40
+ "@atlaskit/media-ui": "^27.2.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",
53
+ "@atlaskit/media-state": "^1.2.0",
54
54
  "@atlaskit/media-test-data": "^2.7.0",
55
- "@atlaskit/section-message": "^6.7.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",
@@ -96,9 +96,5 @@
96
96
  ]
97
97
  }
98
98
  },
99
- "platform-feature-flags": {
100
- "platform.media-card-performance-observer_a803k": {
101
- "type": "boolean"
102
- }
103
- }
99
+ "platform-feature-flags": {}
104
100
  }