@atlaskit/emoji 71.16.1 → 71.16.3

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,23 @@
1
1
  # @atlaskit/emoji
2
2
 
3
+ ## 71.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6274e251b8398`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6274e251b8398) -
8
+ Clean up the `cache_emoji_loader_for_the_same_config` feature gate. `EmojiLoader` now always
9
+ shares a single in-flight/resolved load promise between loaders created for the same config url,
10
+ instead of refetching per loader.
11
+
12
+ The cache is skipped in test environments (Jest, and automated browsers such as Playwright), so it
13
+ cannot leak responses between test cases that share a provider url.
14
+
15
+ ## 71.16.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 71.16.1
4
22
 
5
23
  ### Patch Changes
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _isTestEnvironment = require("../util/is-test-environment");
11
11
  var _EmojiUtils = require("./EmojiUtils");
12
12
  /**
13
13
  * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
14
14
  * multiple loaders created for the same provider config reuse a single request instead of
15
- * refetching. Only consulted when `cache_emoji_loader_for_the_same_config` is enabled.
15
+ * refetching.
16
16
  */
17
17
  var emojiPromiseCache = new Map();
18
18
 
@@ -31,23 +31,25 @@ var EmojiLoader = exports.default = /*#__PURE__*/function () {
31
31
  return (0, _createClass2.default)(EmojiLoader, [{
32
32
  key: "loadEmoji",
33
33
  value: function loadEmoji() {
34
- if ((0, _platformFeatureFlags.fg)('cache_emoji_loader_for_the_same_config')) {
35
- var cacheKey = this.config.url;
36
- var cachedPromise = emojiPromiseCache.get(cacheKey);
37
- if (cachedPromise) {
38
- return cachedPromise;
39
- }
40
- var emojiPromise = this.fetchEmoji();
41
- // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
42
- emojiPromise.catch(function () {
43
- if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
44
- emojiPromiseCache.delete(cacheKey);
45
- }
46
- });
47
- emojiPromiseCache.set(cacheKey, emojiPromise);
48
- return emojiPromise;
34
+ // The cache is module-level and outlives individual loaders, so under test it would leak
35
+ // responses between cases sharing a provider url. Always refetch there instead.
36
+ if ((0, _isTestEnvironment.isTestEnvironment)()) {
37
+ return this.fetchEmoji();
38
+ }
39
+ var cacheKey = this.config.url;
40
+ var cachedPromise = emojiPromiseCache.get(cacheKey);
41
+ if (cachedPromise) {
42
+ return cachedPromise;
49
43
  }
50
- return this.fetchEmoji();
44
+ var emojiPromise = this.fetchEmoji();
45
+ // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
46
+ emojiPromise.catch(function () {
47
+ if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
48
+ emojiPromiseCache.delete(cacheKey);
49
+ }
50
+ });
51
+ emojiPromiseCache.set(cacheKey, emojiPromise);
52
+ return emojiPromise;
51
53
  }
52
54
  }, {
53
55
  key: "fetchEmoji",
@@ -20,7 +20,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
20
20
  actionSubjectId: actionSubjectId,
21
21
  attributes: _objectSpread({
22
22
  packageName: "@atlaskit/emoji",
23
- packageVersion: "71.16.0"
23
+ packageVersion: "71.16.2"
24
24
  }, attributes)
25
25
  };
26
26
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isTestEnvironment = isTestEnvironment;
7
+ /**
8
+ * Detects Jest unit tests and automated browsers (Playwright and other WebDriver-based drivers).
9
+ *
10
+ * Used to opt out of module-level caching that outlives individual instances. Such a cache leaks
11
+ * state between test cases that share an input, which makes tests order-dependent and forces every
12
+ * consumer to reset shared internals from their own suites.
13
+ */
14
+ function isTestEnvironment() {
15
+ try {
16
+ var _process, _process2;
17
+ return Boolean(typeof process !== 'undefined' && (
18
+ // NODE_ENV can be overridden by consumers, so also check for a Jest worker
19
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 || (_process2 = _process2.env) === null || _process2 === void 0 ? void 0 : _process2.JEST_WORKER_ID) !== undefined) ||
20
+ // Playwright serves examples with NODE_ENV=development, but sets navigator.webdriver
21
+ typeof navigator !== 'undefined' && navigator.webdriver);
22
+ } catch (e) {
23
+ // Catch possible error that might occur and just return false
24
+ return false;
25
+ }
26
+ }
@@ -1,10 +1,10 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
1
+ import { isTestEnvironment } from '../util/is-test-environment';
2
2
  import { denormaliseEmojiServiceResponse, emojiRequest } from './EmojiUtils';
3
3
 
4
4
  /**
5
5
  * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
6
6
  * multiple loaders created for the same provider config reuse a single request instead of
7
- * refetching. Only consulted when `cache_emoji_loader_for_the_same_config` is enabled.
7
+ * refetching.
8
8
  */
9
9
  const emojiPromiseCache = new Map();
10
10
 
@@ -20,23 +20,25 @@ export default class EmojiLoader {
20
20
  * Returns a promise with an array of Emoji from all providers.
21
21
  */
22
22
  loadEmoji() {
23
- if (fg('cache_emoji_loader_for_the_same_config')) {
24
- const cacheKey = this.config.url;
25
- const cachedPromise = emojiPromiseCache.get(cacheKey);
26
- if (cachedPromise) {
27
- return cachedPromise;
28
- }
29
- const emojiPromise = this.fetchEmoji();
30
- // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
31
- emojiPromise.catch(() => {
32
- if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
33
- emojiPromiseCache.delete(cacheKey);
34
- }
35
- });
36
- emojiPromiseCache.set(cacheKey, emojiPromise);
37
- return emojiPromise;
23
+ // The cache is module-level and outlives individual loaders, so under test it would leak
24
+ // responses between cases sharing a provider url. Always refetch there instead.
25
+ if (isTestEnvironment()) {
26
+ return this.fetchEmoji();
27
+ }
28
+ const cacheKey = this.config.url;
29
+ const cachedPromise = emojiPromiseCache.get(cacheKey);
30
+ if (cachedPromise) {
31
+ return cachedPromise;
38
32
  }
39
- return this.fetchEmoji();
33
+ const emojiPromise = this.fetchEmoji();
34
+ // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
35
+ emojiPromise.catch(() => {
36
+ if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
37
+ emojiPromiseCache.delete(cacheKey);
38
+ }
39
+ });
40
+ emojiPromiseCache.set(cacheKey, emojiPromise);
41
+ return emojiPromise;
40
42
  }
41
43
  fetchEmoji() {
42
44
  return emojiRequest(this.config).then(emojiServiceResponse => denormaliseEmojiServiceResponse(emojiServiceResponse));
@@ -9,7 +9,7 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
9
9
  actionSubjectId,
10
10
  attributes: {
11
11
  packageName: "@atlaskit/emoji",
12
- packageVersion: "71.16.0",
12
+ packageVersion: "71.16.2",
13
13
  ...attributes
14
14
  }
15
15
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Detects Jest unit tests and automated browsers (Playwright and other WebDriver-based drivers).
3
+ *
4
+ * Used to opt out of module-level caching that outlives individual instances. Such a cache leaks
5
+ * state between test cases that share an input, which makes tests order-dependent and forces every
6
+ * consumer to reset shared internals from their own suites.
7
+ */
8
+ export function isTestEnvironment() {
9
+ try {
10
+ var _process, _process$env, _process2, _process2$env;
11
+ return Boolean(typeof process !== 'undefined' && (
12
+ // NODE_ENV can be overridden by consumers, so also check for a Jest worker
13
+ ((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.JEST_WORKER_ID) !== undefined) ||
14
+ // Playwright serves examples with NODE_ENV=development, but sets navigator.webdriver
15
+ typeof navigator !== 'undefined' && navigator.webdriver);
16
+ } catch (e) {
17
+ // Catch possible error that might occur and just return false
18
+ return false;
19
+ }
20
+ }
@@ -1,12 +1,12 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { isTestEnvironment } from '../util/is-test-environment';
4
4
  import { denormaliseEmojiServiceResponse, emojiRequest } from './EmojiUtils';
5
5
 
6
6
  /**
7
7
  * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
8
8
  * multiple loaders created for the same provider config reuse a single request instead of
9
- * refetching. Only consulted when `cache_emoji_loader_for_the_same_config` is enabled.
9
+ * refetching.
10
10
  */
11
11
  var emojiPromiseCache = new Map();
12
12
 
@@ -25,23 +25,25 @@ var EmojiLoader = /*#__PURE__*/function () {
25
25
  return _createClass(EmojiLoader, [{
26
26
  key: "loadEmoji",
27
27
  value: function loadEmoji() {
28
- if (fg('cache_emoji_loader_for_the_same_config')) {
29
- var cacheKey = this.config.url;
30
- var cachedPromise = emojiPromiseCache.get(cacheKey);
31
- if (cachedPromise) {
32
- return cachedPromise;
33
- }
34
- var emojiPromise = this.fetchEmoji();
35
- // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
36
- emojiPromise.catch(function () {
37
- if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
38
- emojiPromiseCache.delete(cacheKey);
39
- }
40
- });
41
- emojiPromiseCache.set(cacheKey, emojiPromise);
42
- return emojiPromise;
28
+ // The cache is module-level and outlives individual loaders, so under test it would leak
29
+ // responses between cases sharing a provider url. Always refetch there instead.
30
+ if (isTestEnvironment()) {
31
+ return this.fetchEmoji();
32
+ }
33
+ var cacheKey = this.config.url;
34
+ var cachedPromise = emojiPromiseCache.get(cacheKey);
35
+ if (cachedPromise) {
36
+ return cachedPromise;
43
37
  }
44
- return this.fetchEmoji();
38
+ var emojiPromise = this.fetchEmoji();
39
+ // Evict on failure so a rejected promise is not cached, allowing retries to refetch.
40
+ emojiPromise.catch(function () {
41
+ if (emojiPromiseCache.get(cacheKey) === emojiPromise) {
42
+ emojiPromiseCache.delete(cacheKey);
43
+ }
44
+ });
45
+ emojiPromiseCache.set(cacheKey, emojiPromise);
46
+ return emojiPromise;
45
47
  }
46
48
  }, {
47
49
  key: "fetchEmoji",
@@ -14,7 +14,7 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
14
14
  actionSubjectId: actionSubjectId,
15
15
  attributes: _objectSpread({
16
16
  packageName: "@atlaskit/emoji",
17
- packageVersion: "71.16.0"
17
+ packageVersion: "71.16.2"
18
18
  }, attributes)
19
19
  };
20
20
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Detects Jest unit tests and automated browsers (Playwright and other WebDriver-based drivers).
3
+ *
4
+ * Used to opt out of module-level caching that outlives individual instances. Such a cache leaks
5
+ * state between test cases that share an input, which makes tests order-dependent and forces every
6
+ * consumer to reset shared internals from their own suites.
7
+ */
8
+ export function isTestEnvironment() {
9
+ try {
10
+ var _process, _process2;
11
+ return Boolean(typeof process !== 'undefined' && (
12
+ // NODE_ENV can be overridden by consumers, so also check for a Jest worker
13
+ ((_process = process) === null || _process === void 0 || (_process = _process.env) === null || _process === void 0 ? void 0 : _process.NODE_ENV) === 'test' || ((_process2 = process) === null || _process2 === void 0 || (_process2 = _process2.env) === null || _process2 === void 0 ? void 0 : _process2.JEST_WORKER_ID) !== undefined) ||
14
+ // Playwright serves examples with NODE_ENV=development, but sets navigator.webdriver
15
+ typeof navigator !== 'undefined' && navigator.webdriver);
16
+ } catch (e) {
17
+ // Catch possible error that might occur and just return false
18
+ return false;
19
+ }
20
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Detects Jest unit tests and automated browsers (Playwright and other WebDriver-based drivers).
3
+ *
4
+ * Used to opt out of module-level caching that outlives individual instances. Such a cache leaks
5
+ * state between test cases that share an input, which makes tests order-dependent and forces every
6
+ * consumer to reset shared internals from their own suites.
7
+ */
8
+ export declare function isTestEnvironment(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/emoji",
3
- "version": "71.16.1",
3
+ "version": "71.16.3",
4
4
  "description": "Fabric emoji React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -50,14 +50,14 @@
50
50
  "@atlaskit/spinner": "^20.1.0",
51
51
  "@atlaskit/textfield": "^10.0.0",
52
52
  "@atlaskit/theme": "^28.0.0",
53
- "@atlaskit/tmp-editor-statsig": "^145.0.0",
53
+ "@atlaskit/tmp-editor-statsig": "^146.0.0",
54
54
  "@atlaskit/tokens": "^16.6.0",
55
55
  "@atlaskit/tooltip": "^24.0.0",
56
56
  "@atlaskit/ufo": "^1.0.0",
57
57
  "@atlaskit/util-service-support": "^7.2.0",
58
58
  "@atlaskit/visually-hidden": "^4.2.0",
59
59
  "@babel/runtime": "^7.0.0",
60
- "@compiled/react": "^1.0.0",
60
+ "@compiled/react": "^1.0.2",
61
61
  "@tanstack/react-virtual": "3.0.0-beta.60",
62
62
  "js-search": "^2.0.0",
63
63
  "lru_map": "^0.4.1",
@@ -139,9 +139,6 @@
139
139
  },
140
140
  "use-elements-stargate-emoji-path": {
141
141
  "type": "boolean"
142
- },
143
- "cache_emoji_loader_for_the_same_config": {
144
- "type": "boolean"
145
142
  }
146
143
  },
147
144
  "platform-experiments": {