@atlaskit/media-file-preview 1.0.1 → 1.0.2

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,11 +1,21 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`43ca343e5b9c6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/43ca343e5b9c6) -
8
+ Cleanup feature gate platform_media_safe_blob_url_eviction. The object URL cache now always
9
+ protects in-use entries from eviction and strips the cache-busting fragment before revoking blob
10
+ URLs.
11
+ - Updated dependencies
12
+
3
13
  ## 1.0.1
4
14
 
5
15
  ### Patch Changes
6
16
 
7
17
  - [`ee28cf33718b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ee28cf33718b0) -
8
- Add @atlassian/react-compiler-gating as a runtime dependency to enable React Compiler platform
18
+ Add @atlaskit/react-compiler-gating as a runtime dependency to enable React Compiler platform
9
19
  gating.
10
20
  - Updated dependencies
11
21
 
@@ -13,7 +13,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
13
13
  var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
14
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
15
  var _lru_map = require("lru_map");
16
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
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
  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; }
@@ -22,9 +21,7 @@ var PREVIEW_CACHE_LRU_SIZE = exports.PREVIEW_CACHE_LRU_SIZE = 50;
22
21
  * LRU cache that checks whether the oldest entry should be evicted
23
22
  * this means that the cache can grow past the softLimit if `shouldEvict` returns false.
24
23
  *
25
- * When `platform_media_safe_blob_url_eviction` is ON the oldest
26
- * entry is kept if `shouldEvict` returns false.
27
- * When the flag is OFF the oldest entry is always evicted.
24
+ * The oldest entry is kept if `shouldEvict` returns false.
28
25
  */
29
26
  var EvictionLRUCache = /*#__PURE__*/function (_LRUMap) {
30
27
  function EvictionLRUCache(softLimit, options) {
@@ -39,11 +36,9 @@ var EvictionLRUCache = /*#__PURE__*/function (_LRUMap) {
39
36
  return (0, _createClass2.default)(EvictionLRUCache, [{
40
37
  key: "shift",
41
38
  value: function shift() {
42
- if ((0, _platformFeatureFlags.fg)('platform_media_safe_blob_url_eviction')) {
43
- var oldest = this.oldest;
44
- if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
45
- return undefined;
46
- }
39
+ var oldest = this.oldest;
40
+ if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
41
+ return undefined;
47
42
  }
48
43
  var entry = _superPropGet(EvictionLRUCache, "shift", this, 3)([]);
49
44
  if (entry && this.onEvict) {
@@ -64,7 +59,7 @@ var ObjectURLCache = exports.ObjectURLCache = /*#__PURE__*/function () {
64
59
  },
65
60
  onEvict: function onEvict(entry) {
66
61
  if (entry[1].dataURI) {
67
- var dataURI = (0, _platformFeatureFlags.fg)('platform_media_safe_blob_url_eviction') ? entry[1].dataURI.split('#')[0] : entry[1].dataURI;
62
+ var dataURI = entry[1].dataURI.split('#')[0];
68
63
  if (dataURI) {
69
64
  URL.revokeObjectURL(dataURI);
70
65
  }
@@ -121,7 +116,7 @@ var ObjectURLCache = exports.ObjectURLCache = /*#__PURE__*/function () {
121
116
  value: function remove(key) {
122
117
  var removed = this.cache.delete(key);
123
118
  this.activeRefs.delete(key);
124
- var dataURI = (0, _platformFeatureFlags.fg)('platform_media_safe_blob_url_eviction') ? removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0] : removed === null || removed === void 0 ? void 0 : removed.dataURI;
119
+ var dataURI = removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0];
125
120
  dataURI && URL.revokeObjectURL(dataURI);
126
121
  }
127
122
  }, {
@@ -1,14 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { LRUMap } from 'lru_map';
3
- import { fg } from '@atlaskit/platform-feature-flags';
4
3
  export const PREVIEW_CACHE_LRU_SIZE = 50;
5
4
  /**
6
5
  * LRU cache that checks whether the oldest entry should be evicted
7
6
  * this means that the cache can grow past the softLimit if `shouldEvict` returns false.
8
7
  *
9
- * When `platform_media_safe_blob_url_eviction` is ON the oldest
10
- * entry is kept if `shouldEvict` returns false.
11
- * When the flag is OFF the oldest entry is always evicted.
8
+ * The oldest entry is kept if `shouldEvict` returns false.
12
9
  */
13
10
  class EvictionLRUCache extends LRUMap {
14
11
  constructor(softLimit, options) {
@@ -17,11 +14,9 @@ class EvictionLRUCache extends LRUMap {
17
14
  this.onEvict = options === null || options === void 0 ? void 0 : options.onEvict;
18
15
  }
19
16
  shift() {
20
- if (fg('platform_media_safe_blob_url_eviction')) {
21
- const oldest = this.oldest;
22
- if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
23
- return undefined;
24
- }
17
+ const oldest = this.oldest;
18
+ if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
19
+ return undefined;
25
20
  }
26
21
  const entry = super.shift();
27
22
  if (entry && this.onEvict) {
@@ -37,7 +32,7 @@ export class ObjectURLCache {
37
32
  shouldEvict: entry => !this.isInUse(entry[0]),
38
33
  onEvict: entry => {
39
34
  if (entry[1].dataURI) {
40
- const dataURI = fg('platform_media_safe_blob_url_eviction') ? entry[1].dataURI.split('#')[0] : entry[1].dataURI;
35
+ const dataURI = entry[1].dataURI.split('#')[0];
41
36
  if (dataURI) {
42
37
  URL.revokeObjectURL(dataURI);
43
38
  }
@@ -80,7 +75,7 @@ export class ObjectURLCache {
80
75
  remove(key) {
81
76
  const removed = this.cache.delete(key);
82
77
  this.activeRefs.delete(key);
83
- const dataURI = fg('platform_media_safe_blob_url_eviction') ? removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0] : removed === null || removed === void 0 ? void 0 : removed.dataURI;
78
+ const dataURI = removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0];
84
79
  dataURI && URL.revokeObjectURL(dataURI);
85
80
  }
86
81
  clear() {
@@ -9,15 +9,12 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  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; }
11
11
  import { LRUMap } from 'lru_map';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  export var PREVIEW_CACHE_LRU_SIZE = 50;
14
13
  /**
15
14
  * LRU cache that checks whether the oldest entry should be evicted
16
15
  * this means that the cache can grow past the softLimit if `shouldEvict` returns false.
17
16
  *
18
- * When `platform_media_safe_blob_url_eviction` is ON the oldest
19
- * entry is kept if `shouldEvict` returns false.
20
- * When the flag is OFF the oldest entry is always evicted.
17
+ * The oldest entry is kept if `shouldEvict` returns false.
21
18
  */
22
19
  var EvictionLRUCache = /*#__PURE__*/function (_LRUMap) {
23
20
  function EvictionLRUCache(softLimit, options) {
@@ -32,11 +29,9 @@ var EvictionLRUCache = /*#__PURE__*/function (_LRUMap) {
32
29
  return _createClass(EvictionLRUCache, [{
33
30
  key: "shift",
34
31
  value: function shift() {
35
- if (fg('platform_media_safe_blob_url_eviction')) {
36
- var oldest = this.oldest;
37
- if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
38
- return undefined;
39
- }
32
+ var oldest = this.oldest;
33
+ if (oldest && this.shouldEvict && !this.shouldEvict([oldest.key, oldest.value])) {
34
+ return undefined;
40
35
  }
41
36
  var entry = _superPropGet(EvictionLRUCache, "shift", this, 3)([]);
42
37
  if (entry && this.onEvict) {
@@ -57,7 +52,7 @@ export var ObjectURLCache = /*#__PURE__*/function () {
57
52
  },
58
53
  onEvict: function onEvict(entry) {
59
54
  if (entry[1].dataURI) {
60
- var dataURI = fg('platform_media_safe_blob_url_eviction') ? entry[1].dataURI.split('#')[0] : entry[1].dataURI;
55
+ var dataURI = entry[1].dataURI.split('#')[0];
61
56
  if (dataURI) {
62
57
  URL.revokeObjectURL(dataURI);
63
58
  }
@@ -114,7 +109,7 @@ export var ObjectURLCache = /*#__PURE__*/function () {
114
109
  value: function remove(key) {
115
110
  var removed = this.cache.delete(key);
116
111
  this.activeRefs.delete(key);
117
- var dataURI = fg('platform_media_safe_blob_url_eviction') ? removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0] : removed === null || removed === void 0 ? void 0 : removed.dataURI;
112
+ var dataURI = removed === null || removed === void 0 ? void 0 : removed.dataURI.split('#')[0];
118
113
  dataURI && URL.revokeObjectURL(dataURI);
119
114
  }
120
115
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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",
@@ -11,7 +11,7 @@
11
11
  "react-compiler": {
12
12
  "enabled": true,
13
13
  "gating": {
14
- "source": "@atlassian/react-compiler-gating",
14
+ "source": "@atlaskit/react-compiler-gating",
15
15
  "importSpecifierName": "isReactCompilerActivePlatform"
16
16
  }
17
17
  },
@@ -34,8 +34,8 @@
34
34
  "@atlaskit/media-common": "^14.1.0",
35
35
  "@atlaskit/media-ui": "^30.3.0",
36
36
  "@atlaskit/platform-feature-flags": "^2.0.0",
37
- "@atlaskit/react-ufo": "^7.1.0",
38
- "@atlassian/react-compiler-gating": "^0.2.0",
37
+ "@atlaskit/react-compiler-gating": "^0.2.0",
38
+ "@atlaskit/react-ufo": "^7.2.0",
39
39
  "@babel/runtime": "^7.0.0",
40
40
  "lru_map": "^0.4.1"
41
41
  },
@@ -50,7 +50,7 @@
50
50
  "@atlaskit/media-test-data": "^4.0.0",
51
51
  "@atlaskit/section-message": "^9.1.0",
52
52
  "@atlaskit/ssr": "workspace:^",
53
- "@atlassian/a11y-jest-testing": "^0.12.0",
53
+ "@atlassian/a11y-jest-testing": "^0.13.0",
54
54
  "@atlassian/feature-flags-test-utils": "^1.1.0",
55
55
  "@atlassian/testing-library": "^0.6.0",
56
56
  "@testing-library/react": "^16.3.0",
@@ -106,9 +106,6 @@
106
106
  "platform_media_cross_client_copy_with_auth": {
107
107
  "type": "boolean"
108
108
  },
109
- "platform_media_safe_blob_url_eviction": {
110
- "type": "boolean"
111
- },
112
109
  "platform_media_ssr_data_seed": {
113
110
  "type": "boolean"
114
111
  }