@atlaskit/emoji 71.14.0 → 71.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/emoji
2
2
 
3
+ ## 71.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`7d37c14edffa7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7d37c14edffa7) -
8
+ Update i18n NPM package versions for editor,editor-extensions,activity-platform,media,elements
9
+ (Group 3)
10
+
11
+ ### Patch Changes
12
+
13
+ - [`22c03f298a7de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/22c03f298a7de) -
14
+ Add an optional promise cache to `EmojiLoader`, keyed by the request URL, so that loaders created
15
+ for the same provider config reuse a single in-flight/resolved request instead of refetching.
16
+ Gated behind the `cache_emoji_loader_for_the_same_config` feature flag; behaviour is unchanged
17
+ when the flag is off.
18
+
3
19
  ## 71.14.0
4
20
 
5
21
  ### Minor Changes
@@ -7,7 +7,15 @@ 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
11
  var _EmojiUtils = require("./EmojiUtils");
12
+ /**
13
+ * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
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.
16
+ */
17
+ var emojiPromiseCache = new Map();
18
+
11
19
  /**
12
20
  * Emoji providers should return JSON in the format defined by EmojiServiceResponse.
13
21
  */
@@ -23,8 +31,28 @@ var EmojiLoader = exports.default = /*#__PURE__*/function () {
23
31
  return (0, _createClass2.default)(EmojiLoader, [{
24
32
  key: "loadEmoji",
25
33
  value: function loadEmoji() {
26
- var emojisPromise = (0, _EmojiUtils.emojiRequest)(this.config);
27
- return emojisPromise.then(function (emojiServiceResponse) {
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;
49
+ }
50
+ return this.fetchEmoji();
51
+ }
52
+ }, {
53
+ key: "fetchEmoji",
54
+ value: function fetchEmoji() {
55
+ return (0, _EmojiUtils.emojiRequest)(this.config).then(function (emojiServiceResponse) {
28
56
  return (0, _EmojiUtils.denormaliseEmojiServiceResponse)(emojiServiceResponse);
29
57
  });
30
58
  }
@@ -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.13.3"
23
+ packageVersion: "71.14.0"
24
24
  }, attributes)
25
25
  };
26
26
  };
@@ -1,5 +1,13 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { denormaliseEmojiServiceResponse, emojiRequest } from './EmojiUtils';
2
3
 
4
+ /**
5
+ * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
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.
8
+ */
9
+ const emojiPromiseCache = new Map();
10
+
3
11
  /**
4
12
  * Emoji providers should return JSON in the format defined by EmojiServiceResponse.
5
13
  */
@@ -12,7 +20,25 @@ export default class EmojiLoader {
12
20
  * Returns a promise with an array of Emoji from all providers.
13
21
  */
14
22
  loadEmoji() {
15
- const emojisPromise = emojiRequest(this.config);
16
- return emojisPromise.then(emojiServiceResponse => denormaliseEmojiServiceResponse(emojiServiceResponse));
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;
38
+ }
39
+ return this.fetchEmoji();
40
+ }
41
+ fetchEmoji() {
42
+ return emojiRequest(this.config).then(emojiServiceResponse => denormaliseEmojiServiceResponse(emojiServiceResponse));
17
43
  }
18
44
  }
@@ -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.13.3",
12
+ packageVersion: "71.14.0",
13
13
  ...attributes
14
14
  }
15
15
  });
@@ -1,7 +1,15 @@
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
4
  import { denormaliseEmojiServiceResponse, emojiRequest } from './EmojiUtils';
4
5
 
6
+ /**
7
+ * Shared cache of in-flight/resolved emoji load promises, keyed by the request URL so that
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.
10
+ */
11
+ var emojiPromiseCache = new Map();
12
+
5
13
  /**
6
14
  * Emoji providers should return JSON in the format defined by EmojiServiceResponse.
7
15
  */
@@ -17,8 +25,28 @@ var EmojiLoader = /*#__PURE__*/function () {
17
25
  return _createClass(EmojiLoader, [{
18
26
  key: "loadEmoji",
19
27
  value: function loadEmoji() {
20
- var emojisPromise = emojiRequest(this.config);
21
- return emojisPromise.then(function (emojiServiceResponse) {
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;
43
+ }
44
+ return this.fetchEmoji();
45
+ }
46
+ }, {
47
+ key: "fetchEmoji",
48
+ value: function fetchEmoji() {
49
+ return emojiRequest(this.config).then(function (emojiServiceResponse) {
22
50
  return denormaliseEmojiServiceResponse(emojiServiceResponse);
23
51
  });
24
52
  }
@@ -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.13.3"
17
+ packageVersion: "71.14.0"
18
18
  }, attributes)
19
19
  };
20
20
  };
@@ -10,4 +10,5 @@ export default class EmojiLoader {
10
10
  * Returns a promise with an array of Emoji from all providers.
11
11
  */
12
12
  loadEmoji(): Promise<EmojiResponse>;
13
+ private fetchEmoji;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/emoji",
3
- "version": "71.14.0",
3
+ "version": "71.15.0",
4
4
  "description": "Fabric emoji React components",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@atlaskit/afm-i18n-platform-elements-emoji": "2.196.0",
32
+ "@atlaskit/afm-i18n-platform-elements-emoji": "2.200.0",
33
33
  "@atlaskit/analytics-next": "^12.3.0",
34
34
  "@atlaskit/browser-apis": "^1.2.0",
35
35
  "@atlaskit/button": "^24.3.0",
@@ -50,7 +50,7 @@
50
50
  "@atlaskit/spinner": "^20.1.0",
51
51
  "@atlaskit/textfield": "^9.1.0",
52
52
  "@atlaskit/theme": "^26.1.0",
53
- "@atlaskit/tmp-editor-statsig": "^135.0.0",
53
+ "@atlaskit/tmp-editor-statsig": "^135.2.0",
54
54
  "@atlaskit/tokens": "^16.3.0",
55
55
  "@atlaskit/tooltip": "^23.2.0",
56
56
  "@atlaskit/ufo": "^1.0.0",
@@ -142,6 +142,9 @@
142
142
  },
143
143
  "platform_a11y_fixes_reaction_emoji": {
144
144
  "type": "boolean"
145
+ },
146
+ "cache_emoji_loader_for_the_same_config": {
147
+ "type": "boolean"
145
148
  }
146
149
  },
147
150
  "platform-experiments": {