@atlaskit/emoji 67.0.4 → 67.0.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.
Files changed (279) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/admin.js +0 -2
  3. package/dist/cjs/api/EmojiLoader.js +1 -8
  4. package/dist/cjs/api/EmojiRepository.js +16 -80
  5. package/dist/cjs/api/EmojiRepositoryRegex.js +2 -0
  6. package/dist/cjs/api/EmojiResource.js +20 -170
  7. package/dist/cjs/api/EmojiUtils.js +27 -67
  8. package/dist/cjs/api/internal/Comparators.js +8 -62
  9. package/dist/cjs/api/internal/UsageFrequencyTracker.js +4 -34
  10. package/dist/cjs/api/media/MediaEmojiCache.js +8 -58
  11. package/dist/cjs/api/media/MediaImageLoader.js +4 -28
  12. package/dist/cjs/api/media/SiteEmojiResource.js +14 -55
  13. package/dist/cjs/api/media/TokenManager.js +4 -18
  14. package/dist/cjs/components/common/CachingEmoji.js +18 -52
  15. package/dist/cjs/components/common/DeleteButton.js +0 -10
  16. package/dist/cjs/components/common/Emoji.js +44 -102
  17. package/dist/cjs/components/common/EmojiActions.js +25 -61
  18. package/dist/cjs/components/common/EmojiButton.js +5 -18
  19. package/dist/cjs/components/common/EmojiDeletePreview.js +7 -38
  20. package/dist/cjs/components/common/EmojiErrorMessage.js +3 -9
  21. package/dist/cjs/components/common/EmojiPlaceholder.js +7 -16
  22. package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -6
  23. package/dist/cjs/components/common/EmojiUploadPicker.js +31 -86
  24. package/dist/cjs/components/common/EmojiUploadPreview.js +7 -36
  25. package/dist/cjs/components/common/FileChooser.js +5 -18
  26. package/dist/cjs/components/common/LoadingEmojiComponent.js +5 -24
  27. package/dist/cjs/components/common/Popup.js +16 -44
  28. package/dist/cjs/components/common/RecordSelectionDefault.js +0 -7
  29. package/dist/cjs/components/common/ResourcedEmoji.js +0 -15
  30. package/dist/cjs/components/common/ResourcedEmojiComponent.js +29 -69
  31. package/dist/cjs/components/common/RetryableButton.js +4 -19
  32. package/dist/cjs/components/common/Scrollable.js +6 -36
  33. package/dist/cjs/components/common/ToneSelector.js +3 -24
  34. package/dist/cjs/components/common/UfoErrorBoundary.js +1 -19
  35. package/dist/cjs/components/common/UploadEmoji.js +2 -13
  36. package/dist/cjs/components/common/internal-types.js +0 -1
  37. package/dist/cjs/components/common/setSkinToneAriaLabelText.js +0 -6
  38. package/dist/cjs/components/common/styles.js +9 -17
  39. package/dist/cjs/components/hooks.js +0 -2
  40. package/dist/cjs/components/i18n.js +0 -2
  41. package/dist/cjs/components/picker/CategorySelector.js +4 -50
  42. package/dist/cjs/components/picker/CategoryTracker.js +3 -14
  43. package/dist/cjs/components/picker/EmojiPicker.js +3 -42
  44. package/dist/cjs/components/picker/EmojiPickerCategoryHeading.js +2 -10
  45. package/dist/cjs/components/picker/EmojiPickerComponent.js +59 -140
  46. package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +7 -14
  47. package/dist/cjs/components/picker/EmojiPickerFooter.js +1 -8
  48. package/dist/cjs/components/picker/EmojiPickerList.js +32 -83
  49. package/dist/cjs/components/picker/EmojiPickerListSearch.js +11 -48
  50. package/dist/cjs/components/picker/EmojiPickerSizes.js +1 -2
  51. package/dist/cjs/components/picker/EmojiPickerVirtualItems.js +1 -38
  52. package/dist/cjs/components/picker/VirtualList.js +11 -41
  53. package/dist/cjs/components/picker/categories.js +0 -14
  54. package/dist/cjs/components/picker/styles.js +15 -20
  55. package/dist/cjs/components/picker/utils.js +0 -4
  56. package/dist/cjs/components/typeahead/EmojiTypeAhead.js +10 -45
  57. package/dist/cjs/components/typeahead/EmojiTypeAheadComponent.js +11 -74
  58. package/dist/cjs/components/typeahead/EmojiTypeAheadItem.js +7 -37
  59. package/dist/cjs/components/typeahead/EmojiTypeAheadList.js +10 -63
  60. package/dist/cjs/components/typeahead/styles.js +2 -4
  61. package/dist/cjs/components/uploader/EmojiUploadComponent.js +6 -42
  62. package/dist/cjs/components/uploader/EmojiUploader.js +3 -31
  63. package/dist/cjs/components/uploader/styles.js +3 -4
  64. package/dist/cjs/context/EmojiCommonProvider.js +0 -6
  65. package/dist/cjs/context/EmojiContext.js +0 -2
  66. package/dist/cjs/context/EmojiContextProvider.js +1 -17
  67. package/dist/cjs/element.js +0 -4
  68. package/dist/cjs/hooks/useEmoji.js +5 -20
  69. package/dist/cjs/hooks/useEmojiContext.js +0 -4
  70. package/dist/cjs/hooks/usePrevious.js +0 -2
  71. package/dist/cjs/i18n/cs.js +0 -1
  72. package/dist/cjs/i18n/da.js +0 -1
  73. package/dist/cjs/i18n/de.js +0 -1
  74. package/dist/cjs/i18n/en.js +0 -1
  75. package/dist/cjs/i18n/en_GB.js +0 -1
  76. package/dist/cjs/i18n/en_ZZ.js +0 -1
  77. package/dist/cjs/i18n/es.js +0 -1
  78. package/dist/cjs/i18n/et.js +0 -1
  79. package/dist/cjs/i18n/fi.js +0 -1
  80. package/dist/cjs/i18n/fr.js +0 -1
  81. package/dist/cjs/i18n/hu.js +0 -1
  82. package/dist/cjs/i18n/index.js +0 -30
  83. package/dist/cjs/i18n/it.js +0 -1
  84. package/dist/cjs/i18n/ja.js +0 -1
  85. package/dist/cjs/i18n/ko.js +0 -1
  86. package/dist/cjs/i18n/nb.js +0 -1
  87. package/dist/cjs/i18n/nl.js +0 -1
  88. package/dist/cjs/i18n/pl.js +0 -1
  89. package/dist/cjs/i18n/pt_BR.js +0 -1
  90. package/dist/cjs/i18n/pt_PT.js +0 -1
  91. package/dist/cjs/i18n/ru.js +0 -1
  92. package/dist/cjs/i18n/sk.js +0 -1
  93. package/dist/cjs/i18n/sv.js +0 -1
  94. package/dist/cjs/i18n/th.js +0 -1
  95. package/dist/cjs/i18n/tr.js +0 -1
  96. package/dist/cjs/i18n/uk.js +0 -1
  97. package/dist/cjs/i18n/vi.js +0 -1
  98. package/dist/cjs/i18n/zh.js +0 -1
  99. package/dist/cjs/i18n/zh_TW.js +0 -1
  100. package/dist/cjs/index.js +0 -24
  101. package/dist/cjs/picker.js +0 -2
  102. package/dist/cjs/resource.js +0 -5
  103. package/dist/cjs/typeahead.js +0 -3
  104. package/dist/cjs/types.js +0 -17
  105. package/dist/cjs/util/DuplicateLimitedQueue.js +13 -31
  106. package/dist/cjs/util/StoredDuplicateLimitedQueue.js +4 -26
  107. package/dist/cjs/util/analytics/analytics.js +14 -97
  108. package/dist/cjs/util/analytics/index.js +0 -4
  109. package/dist/cjs/util/analytics/samplingUfo.js +3 -59
  110. package/dist/cjs/util/analytics/ufoExperiences.js +0 -12
  111. package/dist/cjs/util/analytics/useSampledUFOComponentExperience.js +3 -10
  112. package/dist/cjs/util/constants.js +5 -5
  113. package/dist/cjs/util/filters.js +0 -4
  114. package/dist/cjs/util/image.js +3 -18
  115. package/dist/cjs/util/logger.js +0 -6
  116. package/dist/cjs/util/mouse.js +3 -6
  117. package/dist/cjs/util/shared-styles.js +0 -4
  118. package/dist/cjs/util/storage-available.js +10 -8
  119. package/dist/cjs/util/type-helpers.js +2 -57
  120. package/dist/cjs/util/useInView.js +0 -6
  121. package/dist/cjs/utils.js +0 -3
  122. package/dist/cjs/version.json +1 -1
  123. package/dist/es2019/api/EmojiLoader.js +2 -4
  124. package/dist/es2019/api/EmojiRepository.js +15 -82
  125. package/dist/es2019/api/EmojiRepositoryRegex.js +2 -0
  126. package/dist/es2019/api/EmojiResource.js +21 -114
  127. package/dist/es2019/api/EmojiUtils.js +11 -18
  128. package/dist/es2019/api/internal/Comparators.js +12 -48
  129. package/dist/es2019/api/internal/UsageFrequencyTracker.js +7 -24
  130. package/dist/es2019/api/media/MediaEmojiCache.js +9 -52
  131. package/dist/es2019/api/media/MediaImageLoader.js +2 -16
  132. package/dist/es2019/api/media/SiteEmojiResource.js +11 -31
  133. package/dist/es2019/api/media/TokenManager.js +4 -14
  134. package/dist/es2019/components/common/CachingEmoji.js +5 -12
  135. package/dist/es2019/components/common/DeleteButton.js +2 -3
  136. package/dist/es2019/components/common/Emoji.js +19 -47
  137. package/dist/es2019/components/common/EmojiActions.js +3 -16
  138. package/dist/es2019/components/common/EmojiButton.js +0 -5
  139. package/dist/es2019/components/common/EmojiDeletePreview.js +0 -11
  140. package/dist/es2019/components/common/EmojiErrorMessage.js +1 -2
  141. package/dist/es2019/components/common/EmojiPlaceholder.js +0 -5
  142. package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -0
  143. package/dist/es2019/components/common/EmojiUploadPicker.js +2 -25
  144. package/dist/es2019/components/common/EmojiUploadPreview.js +0 -6
  145. package/dist/es2019/components/common/FileChooser.js +0 -6
  146. package/dist/es2019/components/common/LoadingEmojiComponent.js +2 -14
  147. package/dist/es2019/components/common/Popup.js +4 -22
  148. package/dist/es2019/components/common/RecordSelectionDefault.js +1 -1
  149. package/dist/es2019/components/common/ResourcedEmoji.js +1 -6
  150. package/dist/es2019/components/common/ResourcedEmojiComponent.js +2 -13
  151. package/dist/es2019/components/common/RetryableButton.js +1 -8
  152. package/dist/es2019/components/common/Scrollable.js +2 -12
  153. package/dist/es2019/components/common/ToneSelector.js +2 -8
  154. package/dist/es2019/components/common/UfoErrorBoundary.js +0 -2
  155. package/dist/es2019/components/common/UploadEmoji.js +2 -3
  156. package/dist/es2019/components/common/internal-types.js +0 -1
  157. package/dist/es2019/components/common/styles.js +12 -8
  158. package/dist/es2019/components/picker/CategorySelector.js +0 -22
  159. package/dist/es2019/components/picker/CategoryTracker.js +3 -13
  160. package/dist/es2019/components/picker/EmojiPicker.js +3 -17
  161. package/dist/es2019/components/picker/EmojiPickerCategoryHeading.js +2 -3
  162. package/dist/es2019/components/picker/EmojiPickerComponent.js +10 -43
  163. package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +0 -2
  164. package/dist/es2019/components/picker/EmojiPickerFooter.js +0 -2
  165. package/dist/es2019/components/picker/EmojiPickerList.js +10 -45
  166. package/dist/es2019/components/picker/EmojiPickerListSearch.js +2 -19
  167. package/dist/es2019/components/picker/EmojiPickerSizes.js +1 -0
  168. package/dist/es2019/components/picker/EmojiPickerVirtualItems.js +1 -8
  169. package/dist/es2019/components/picker/VirtualList.js +3 -24
  170. package/dist/es2019/components/picker/styles.js +22 -10
  171. package/dist/es2019/components/picker/utils.js +0 -1
  172. package/dist/es2019/components/typeahead/EmojiTypeAhead.js +4 -21
  173. package/dist/es2019/components/typeahead/EmojiTypeAheadComponent.js +0 -42
  174. package/dist/es2019/components/typeahead/EmojiTypeAheadItem.js +0 -7
  175. package/dist/es2019/components/typeahead/EmojiTypeAheadList.js +4 -45
  176. package/dist/es2019/components/typeahead/styles.js +2 -1
  177. package/dist/es2019/components/uploader/EmojiUploadComponent.js +2 -15
  178. package/dist/es2019/components/uploader/EmojiUploader.js +2 -10
  179. package/dist/es2019/components/uploader/styles.js +5 -2
  180. package/dist/es2019/context/EmojiCommonProvider.js +0 -2
  181. package/dist/es2019/context/EmojiContextProvider.js +0 -1
  182. package/dist/es2019/hooks/useEmoji.js +2 -6
  183. package/dist/es2019/hooks/useEmojiContext.js +1 -1
  184. package/dist/es2019/index.js +12 -6
  185. package/dist/es2019/types.js +1 -11
  186. package/dist/es2019/util/DuplicateLimitedQueue.js +13 -35
  187. package/dist/es2019/util/StoredDuplicateLimitedQueue.js +5 -12
  188. package/dist/es2019/util/analytics/analytics.js +7 -23
  189. package/dist/es2019/util/analytics/samplingUfo.js +6 -32
  190. package/dist/es2019/util/analytics/ufoExperiences.js +0 -3
  191. package/dist/es2019/util/analytics/useSampledUFOComponentExperience.js +3 -7
  192. package/dist/es2019/util/constants.js +5 -4
  193. package/dist/es2019/util/filters.js +0 -3
  194. package/dist/es2019/util/image.js +3 -8
  195. package/dist/es2019/util/mouse.js +3 -3
  196. package/dist/es2019/util/storage-available.js +10 -7
  197. package/dist/es2019/util/type-helpers.js +6 -9
  198. package/dist/es2019/util/useInView.js +0 -2
  199. package/dist/es2019/version.json +1 -1
  200. package/dist/esm/api/EmojiLoader.js +2 -6
  201. package/dist/esm/api/EmojiRepository.js +16 -71
  202. package/dist/esm/api/EmojiRepositoryRegex.js +2 -0
  203. package/dist/esm/api/EmojiResource.js +20 -158
  204. package/dist/esm/api/EmojiUtils.js +27 -47
  205. package/dist/esm/api/internal/Comparators.js +12 -53
  206. package/dist/esm/api/internal/UsageFrequencyTracker.js +5 -29
  207. package/dist/esm/api/media/MediaEmojiCache.js +9 -55
  208. package/dist/esm/api/media/MediaImageLoader.js +4 -27
  209. package/dist/esm/api/media/SiteEmojiResource.js +14 -43
  210. package/dist/esm/api/media/TokenManager.js +6 -16
  211. package/dist/esm/components/common/CachingEmoji.js +18 -30
  212. package/dist/esm/components/common/DeleteButton.js +2 -3
  213. package/dist/esm/components/common/Emoji.js +44 -78
  214. package/dist/esm/components/common/EmojiActions.js +25 -40
  215. package/dist/esm/components/common/EmojiButton.js +4 -9
  216. package/dist/esm/components/common/EmojiDeletePreview.js +7 -24
  217. package/dist/esm/components/common/EmojiErrorMessage.js +3 -4
  218. package/dist/esm/components/common/EmojiPlaceholder.js +6 -11
  219. package/dist/esm/components/common/EmojiPreviewComponent.js +1 -0
  220. package/dist/esm/components/common/EmojiUploadPicker.js +30 -64
  221. package/dist/esm/components/common/EmojiUploadPreview.js +7 -19
  222. package/dist/esm/components/common/FileChooser.js +5 -11
  223. package/dist/esm/components/common/LoadingEmojiComponent.js +4 -20
  224. package/dist/esm/components/common/Popup.js +16 -36
  225. package/dist/esm/components/common/RecordSelectionDefault.js +1 -1
  226. package/dist/esm/components/common/ResourcedEmoji.js +1 -6
  227. package/dist/esm/components/common/ResourcedEmojiComponent.js +29 -51
  228. package/dist/esm/components/common/RetryableButton.js +4 -11
  229. package/dist/esm/components/common/Scrollable.js +6 -29
  230. package/dist/esm/components/common/ToneSelector.js +3 -13
  231. package/dist/esm/components/common/UfoErrorBoundary.js +1 -13
  232. package/dist/esm/components/common/UploadEmoji.js +2 -3
  233. package/dist/esm/components/common/internal-types.js +0 -1
  234. package/dist/esm/components/common/setSkinToneAriaLabelText.js +0 -2
  235. package/dist/esm/components/common/styles.js +12 -9
  236. package/dist/esm/components/picker/CategorySelector.js +4 -32
  237. package/dist/esm/components/picker/CategoryTracker.js +3 -13
  238. package/dist/esm/components/picker/EmojiPicker.js +5 -27
  239. package/dist/esm/components/picker/EmojiPickerCategoryHeading.js +4 -5
  240. package/dist/esm/components/picker/EmojiPickerComponent.js +60 -114
  241. package/dist/esm/components/picker/EmojiPickerEmojiRow.js +6 -8
  242. package/dist/esm/components/picker/EmojiPickerFooter.js +0 -2
  243. package/dist/esm/components/picker/EmojiPickerList.js +32 -77
  244. package/dist/esm/components/picker/EmojiPickerListSearch.js +11 -35
  245. package/dist/esm/components/picker/EmojiPickerSizes.js +1 -0
  246. package/dist/esm/components/picker/EmojiPickerVirtualItems.js +2 -26
  247. package/dist/esm/components/picker/VirtualList.js +11 -28
  248. package/dist/esm/components/picker/styles.js +22 -11
  249. package/dist/esm/components/picker/utils.js +0 -1
  250. package/dist/esm/components/typeahead/EmojiTypeAhead.js +11 -39
  251. package/dist/esm/components/typeahead/EmojiTypeAheadComponent.js +11 -65
  252. package/dist/esm/components/typeahead/EmojiTypeAheadItem.js +7 -24
  253. package/dist/esm/components/typeahead/EmojiTypeAheadList.js +10 -53
  254. package/dist/esm/components/typeahead/styles.js +2 -1
  255. package/dist/esm/components/uploader/EmojiUploadComponent.js +5 -25
  256. package/dist/esm/components/uploader/EmojiUploader.js +4 -22
  257. package/dist/esm/components/uploader/styles.js +5 -2
  258. package/dist/esm/context/EmojiCommonProvider.js +0 -2
  259. package/dist/esm/context/EmojiContextProvider.js +1 -6
  260. package/dist/esm/hooks/useEmoji.js +5 -13
  261. package/dist/esm/hooks/useEmojiContext.js +1 -1
  262. package/dist/esm/index.js +12 -6
  263. package/dist/esm/types.js +1 -11
  264. package/dist/esm/util/DuplicateLimitedQueue.js +13 -29
  265. package/dist/esm/util/StoredDuplicateLimitedQueue.js +5 -22
  266. package/dist/esm/util/analytics/analytics.js +14 -50
  267. package/dist/esm/util/analytics/samplingUfo.js +3 -51
  268. package/dist/esm/util/analytics/ufoExperiences.js +0 -3
  269. package/dist/esm/util/analytics/useSampledUFOComponentExperience.js +3 -7
  270. package/dist/esm/util/constants.js +5 -4
  271. package/dist/esm/util/filters.js +0 -3
  272. package/dist/esm/util/image.js +3 -8
  273. package/dist/esm/util/logger.js +0 -2
  274. package/dist/esm/util/mouse.js +3 -3
  275. package/dist/esm/util/storage-available.js +10 -7
  276. package/dist/esm/util/type-helpers.js +2 -12
  277. package/dist/esm/util/useInView.js +0 -2
  278. package/dist/esm/version.json +1 -1
  279. package/package.json +2 -2
@@ -1,38 +1,30 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["getRatio"],
4
- _excluded2 = ["queryParams"],
5
- _excluded3 = ["representation", "altRepresentations"],
6
- _excluded4 = ["representation", "skinVariations", "altRepresentations"];
7
-
4
+ _excluded2 = ["queryParams"],
5
+ _excluded3 = ["representation", "altRepresentations"],
6
+ _excluded4 = ["representation", "skinVariations", "altRepresentations"];
8
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
-
10
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
-
12
9
  import { utils as serviceUtils } from '@atlaskit/util-service-support';
13
10
  import { isImageRepresentation, isSpriteServiceRepresentation, convertImageToMediaRepresentation, buildEmojiDescriptionWithAltRepresentation } from '../util/type-helpers';
14
11
  import debug from '../util/logger';
15
12
  export var emojiRequest = function emojiRequest(provider, options) {
16
13
  var _provider$getRatio = provider.getRatio,
17
- getRatio = _provider$getRatio === void 0 ? getPixelRatio : _provider$getRatio,
18
- serviceConfig = _objectWithoutProperties(provider, _excluded);
19
-
14
+ getRatio = _provider$getRatio === void 0 ? getPixelRatio : _provider$getRatio,
15
+ serviceConfig = _objectWithoutProperties(provider, _excluded);
20
16
  var scaleQueryParams = calculateScale(getRatio);
21
-
22
17
  var _ref = options || {},
23
- _ref$queryParams = _ref.queryParams,
24
- queryParams = _ref$queryParams === void 0 ? {} : _ref$queryParams,
25
- otherOptions = _objectWithoutProperties(_ref, _excluded2);
26
-
18
+ _ref$queryParams = _ref.queryParams,
19
+ queryParams = _ref$queryParams === void 0 ? {} : _ref$queryParams,
20
+ otherOptions = _objectWithoutProperties(_ref, _excluded2);
27
21
  var requestOptions = _objectSpread(_objectSpread({}, otherOptions), {}, {
28
22
  queryParams: _objectSpread(_objectSpread(_objectSpread({}, scaleQueryParams), queryParams), {}, {
29
23
  preferredRepresentation: 'IMAGE'
30
24
  })
31
25
  });
32
-
33
26
  return serviceUtils.requestService(serviceConfig, requestOptions);
34
27
  };
35
-
36
28
  var calculateScale = function calculateScale(getRatio) {
37
29
  // Retina display
38
30
  if (getRatio() > 1) {
@@ -40,19 +32,16 @@ var calculateScale = function calculateScale(getRatio) {
40
32
  scale: 'XHDPI',
41
33
  altScale: 'XXXHDPI'
42
34
  };
43
- } // Default set used for desktop
44
-
45
-
35
+ }
36
+ // Default set used for desktop
46
37
  return {
47
38
  altScale: 'XHDPI'
48
39
  };
49
40
  };
50
-
51
41
  export var getPixelRatio = function getPixelRatio() {
52
42
  if (typeof window === 'undefined') {
53
43
  return 0;
54
44
  }
55
-
56
45
  return window.devicePixelRatio;
57
46
  };
58
47
  export var getAltRepresentation = function getAltRepresentation(reps) {
@@ -65,15 +54,14 @@ export var isMediaApiUrl = function isMediaApiUrl(url, meta) {
65
54
  export var denormaliseServiceRepresentation = function denormaliseServiceRepresentation(representation, meta) {
66
55
  if (isSpriteServiceRepresentation(representation) && meta && meta.spriteSheets) {
67
56
  var _ref2 = representation,
68
- height = _ref2.height,
69
- width = _ref2.width,
70
- x = _ref2.x,
71
- y = _ref2.y,
72
- xIndex = _ref2.xIndex,
73
- yIndex = _ref2.yIndex,
74
- spriteRef = _ref2.spriteRef;
57
+ height = _ref2.height,
58
+ width = _ref2.width,
59
+ x = _ref2.x,
60
+ y = _ref2.y,
61
+ xIndex = _ref2.xIndex,
62
+ yIndex = _ref2.yIndex,
63
+ spriteRef = _ref2.spriteRef;
75
64
  var spriteSheet = meta.spriteSheets[spriteRef];
76
-
77
65
  if (spriteSheet) {
78
66
  return {
79
67
  sprite: spriteSheet,
@@ -87,20 +75,17 @@ export var denormaliseServiceRepresentation = function denormaliseServiceReprese
87
75
  }
88
76
  } else if (isImageRepresentation(representation)) {
89
77
  var _height = representation.height,
90
- _width = representation.width,
91
- imagePath = representation.imagePath;
92
-
78
+ _width = representation.width,
79
+ imagePath = representation.imagePath;
93
80
  if (isMediaApiUrl(imagePath, meta)) {
94
81
  return convertImageToMediaRepresentation(representation);
95
82
  }
96
-
97
83
  return {
98
84
  height: _height,
99
85
  width: _width,
100
86
  imagePath: imagePath
101
87
  };
102
88
  }
103
-
104
89
  debug('failed conversion for representation', representation, meta);
105
90
  return undefined;
106
91
  };
@@ -111,14 +96,12 @@ export var denormaliseSkinEmoji = function denormaliseSkinEmoji(emoji, meta) {
111
96
  if (!emoji.skinVariations) {
112
97
  return [];
113
98
  }
114
-
115
99
  var skinEmoji = emoji.skinVariations;
116
100
  var baseId = emoji.id;
117
101
  return skinEmoji.map(function (skin) {
118
102
  var representation = skin.representation,
119
- altRepresentations = skin.altRepresentations,
120
- other = _objectWithoutProperties(skin, _excluded3);
121
-
103
+ altRepresentations = skin.altRepresentations,
104
+ other = _objectWithoutProperties(skin, _excluded3);
122
105
  return _objectSpread({
123
106
  baseId: baseId,
124
107
  representation: denormaliseServiceRepresentation(representation, meta),
@@ -126,27 +109,26 @@ export var denormaliseSkinEmoji = function denormaliseSkinEmoji(emoji, meta) {
126
109
  }, other);
127
110
  });
128
111
  };
112
+
129
113
  /**
130
114
  * Denormalised an emoji response (emojis + sprite references) into an array of
131
115
  * emoji with local sprite definitions.
132
116
  */
133
-
134
117
  export var denormaliseEmojiServiceResponse = function denormaliseEmojiServiceResponse(emojiData) {
135
118
  var emojis = emojiData.emojis.map(function (emoji) {
136
119
  var newRepresentation = denormaliseServiceRepresentation(emoji.representation, emojiData.meta);
137
120
  var altRepresentation = denormaliseServiceAltRepresentation(emoji.altRepresentations, emojiData.meta);
138
- var newSkinVariations = denormaliseSkinEmoji(emoji, emojiData.meta); // create trimmedServiceDesc which is emoji with no representations or skinVariations
121
+ var newSkinVariations = denormaliseSkinEmoji(emoji, emojiData.meta);
139
122
 
123
+ // create trimmedServiceDesc which is emoji with no representations or skinVariations
140
124
  var representation = emoji.representation,
141
- skinVariations = emoji.skinVariations,
142
- altRepresentations = emoji.altRepresentations,
143
- trimmedServiceDesc = _objectWithoutProperties(emoji, _excluded4);
144
-
125
+ skinVariations = emoji.skinVariations,
126
+ altRepresentations = emoji.altRepresentations,
127
+ trimmedServiceDesc = _objectWithoutProperties(emoji, _excluded4);
145
128
  var response = _objectSpread(_objectSpread({}, trimmedServiceDesc), {}, {
146
129
  representation: newRepresentation,
147
130
  skinVariations: newSkinVariations
148
131
  });
149
-
150
132
  return buildEmojiDescriptionWithAltRepresentation(response, altRepresentation);
151
133
  });
152
134
  var mediaApiToken = emojiData.meta && emojiData.meta.mediaApiToken;
@@ -155,11 +137,9 @@ export var denormaliseEmojiServiceResponse = function denormaliseEmojiServiceRes
155
137
  mediaApiToken: mediaApiToken
156
138
  };
157
139
  };
158
-
159
140
  var getHeight = function getHeight(fitToHeight) {
160
141
  return getPixelRatio() > 1 ? fitToHeight * 2 : fitToHeight;
161
142
  };
162
-
163
143
  export var shouldUseAltRepresentation = function shouldUseAltRepresentation(emoji, fitToHeight) {
164
144
  return !!(fitToHeight && emoji.altRepresentation && getHeight(fitToHeight) > emoji.representation.height);
165
145
  };
@@ -3,7 +3,6 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _construct from "@babel/runtime/helpers/construct";
4
4
  import { MAX_ORDINAL } from '../../util/constants';
5
5
  import { isEmojiVariationDescription } from '../../util/type-helpers';
6
-
7
6
  /**
8
7
  * Create the default sort comparator to be used for the user queries against emoji
9
8
  *
@@ -14,29 +13,24 @@ import { isEmojiVariationDescription } from '../../util/type-helpers';
14
13
  export function createSearchEmojiComparator(query, orderedIds) {
15
14
  var textQuery = query ? query.replace(/:/g, '').toLowerCase().trim() : undefined;
16
15
  var comparators = [];
17
-
18
16
  if (query) {
19
17
  comparators.push(new AsciiMatchComparator(query));
20
- } // Add the comparators to the 'chain'. The order of adding each comparator is important to the sort that is applied by the
21
- // ChainedEmojiComparator. (Which is why you may see the same 'if' a few times.)
18
+ }
22
19
 
20
+ // Add the comparators to the 'chain'. The order of adding each comparator is important to the sort that is applied by the
21
+ // ChainedEmojiComparator. (Which is why you may see the same 'if' a few times.)
23
22
 
24
23
  if (textQuery) {
25
24
  comparators.push(new ExactShortNameMatchComparator(textQuery));
26
25
  }
27
-
28
26
  if (orderedIds && orderedIds.length) {
29
27
  comparators.push(new UsageFrequencyComparator(orderedIds));
30
28
  }
31
-
32
29
  if (textQuery) {
33
30
  comparators.push(new QueryStringPositionMatchComparator(textQuery, 'shortName'), new QueryStringPositionMatchComparator(textQuery, 'name'));
34
31
  }
35
-
36
32
  comparators.push(OrderComparator.Instance, AlphabeticalShortnameComparator.Instance);
37
-
38
33
  var comparator = _construct(ChainedEmojiComparator, comparators);
39
-
40
34
  comparator.compare = comparator.compare.bind(comparator);
41
35
  return comparator;
42
36
  }
@@ -45,6 +39,7 @@ export function createUsageOnlyEmojiComparator(orderedIds) {
45
39
  comparator.compare = comparator.compare.bind(comparator);
46
40
  return comparator;
47
41
  }
42
+
48
43
  /**
49
44
  * Returns a number representing the result of comparing e1 and e2.
50
45
  * Compatible with Array.sort, which is to say -
@@ -63,74 +58,61 @@ export function createUsageOnlyEmojiComparator(orderedIds) {
63
58
  export var ChainedEmojiComparator = /*#__PURE__*/function () {
64
59
  function ChainedEmojiComparator() {
65
60
  _classCallCheck(this, ChainedEmojiComparator);
66
-
67
61
  for (var _len = arguments.length, comparators = new Array(_len), _key = 0; _key < _len; _key++) {
68
62
  comparators[_key] = arguments[_key];
69
63
  }
70
-
71
64
  this.chain = comparators;
72
65
  }
73
-
74
66
  _createClass(ChainedEmojiComparator, [{
75
67
  key: "compare",
76
68
  value: function compare(e1, e2) {
77
69
  for (var i = 0; i < this.chain.length; i++) {
78
70
  var result = this.chain[i].compare(e1, e2);
79
-
80
71
  if (result !== 0) {
81
72
  return result;
82
73
  }
83
74
  }
84
-
85
75
  return 0;
86
76
  }
87
77
  }]);
88
-
89
78
  return ChainedEmojiComparator;
90
79
  }();
80
+
91
81
  /**
92
82
  * Orders two emoji such that if one of them has an ascii representation that exactly matches the query then it will
93
83
  * be ordered first.
94
84
  */
95
-
96
85
  export var AsciiMatchComparator = /*#__PURE__*/function () {
97
86
  function AsciiMatchComparator(query) {
98
87
  _classCallCheck(this, AsciiMatchComparator);
99
-
100
88
  this.query = query;
101
89
  }
102
-
103
90
  _createClass(AsciiMatchComparator, [{
104
91
  key: "compare",
105
92
  value: function compare(e1, e2) {
106
93
  var e1HasAscii = e1.ascii && e1.ascii.indexOf(this.query) !== -1;
107
94
  var e2HasAscii = e2.ascii && e2.ascii.indexOf(this.query) !== -1;
108
-
109
95
  if (e1HasAscii && !e2HasAscii) {
110
96
  return -1;
111
97
  } else if (!e1HasAscii && e2HasAscii) {
112
98
  return 1;
113
99
  }
114
-
115
100
  return 0;
116
101
  }
117
102
  }]);
118
-
119
103
  return AsciiMatchComparator;
120
104
  }();
105
+
121
106
  /**
122
107
  * Orders two emoji such that the one who's shortname matches the query exactly comes first. If there are matching
123
108
  * shortnames then the type of emoji is taken into account with SITE emoji coming first.
124
109
  */
125
-
126
110
  export var ExactShortNameMatchComparator = /*#__PURE__*/function () {
127
111
  function ExactShortNameMatchComparator(query) {
128
112
  _classCallCheck(this, ExactShortNameMatchComparator);
129
-
130
113
  this.colonQuery = ":".concat(query, ":");
131
114
  this.typeComparator = new EmojiTypeComparator(true);
132
115
  }
133
-
134
116
  _createClass(ExactShortNameMatchComparator, [{
135
117
  key: "compare",
136
118
  value: function compare(e1, e2) {
@@ -141,31 +123,27 @@ export var ExactShortNameMatchComparator = /*#__PURE__*/function () {
141
123
  } else if (e2.shortName === this.colonQuery) {
142
124
  return 1;
143
125
  }
144
-
145
126
  return 0;
146
127
  }
147
128
  }]);
148
-
149
129
  return ExactShortNameMatchComparator;
150
130
  }();
131
+
151
132
  /**
152
133
  * Orders two emoji based on their type, with the types being STANDARD, ATLASSIAN and SITE (in that order).
153
134
  * If the comparator is configured to 'reverse' then the order will be SITE, ATLASSIAN, STANDARD.
154
135
  *
155
136
  * Regardless of the reverse setting, an unknown type will always come last.
156
137
  */
157
-
158
138
  export var EmojiTypeComparator = /*#__PURE__*/function () {
159
139
  function EmojiTypeComparator(reverse) {
160
140
  _classCallCheck(this, EmojiTypeComparator);
161
-
162
141
  if (reverse) {
163
142
  this.typeToNumber = new Map([['SITE', 0], ['ATLASSIAN', 1], ['STANDARD', 2]]);
164
143
  } else {
165
144
  this.typeToNumber = new Map([['STANDARD', 0], ['ATLASSIAN', 1], ['SITE', 2]]);
166
145
  }
167
146
  }
168
-
169
147
  _createClass(EmojiTypeComparator, [{
170
148
  key: "compare",
171
149
  value: function compare(e1, e2) {
@@ -175,36 +153,31 @@ export var EmojiTypeComparator = /*#__PURE__*/function () {
175
153
  key: "emojiTypeToOrdinal",
176
154
  value: function emojiTypeToOrdinal(emoji) {
177
155
  var ordinal = this.typeToNumber.get(emoji.type);
178
-
179
156
  if (ordinal === undefined) {
180
157
  ordinal = 10;
181
158
  }
182
-
183
159
  return ordinal;
184
160
  }
185
161
  }]);
186
-
187
162
  return EmojiTypeComparator;
188
163
  }();
164
+
189
165
  /**
190
166
  * Order two emoji such as the one which is more frequently used comes first. If neither have any usage
191
167
  * information then leave their order unchanged.
192
168
  */
193
-
194
169
  export var UsageFrequencyComparator = /*#__PURE__*/function () {
195
170
  // A Map of emoji base Id to their order in a least of most frequently used
171
+
196
172
  function UsageFrequencyComparator(orderedIds) {
197
173
  var _this = this;
198
-
199
174
  _classCallCheck(this, UsageFrequencyComparator);
200
-
201
- this.positionLookup = new Map(); // Make ordering start from 1 to avoid having zero in the map (which is falsey)
202
-
175
+ this.positionLookup = new Map();
176
+ // Make ordering start from 1 to avoid having zero in the map (which is falsey)
203
177
  orderedIds.map(function (id, index) {
204
178
  return _this.positionLookup.set(id, index + 1);
205
179
  });
206
180
  }
207
-
208
181
  _createClass(UsageFrequencyComparator, [{
209
182
  key: "compare",
210
183
  value: function compare(e1, e2) {
@@ -216,23 +189,20 @@ export var UsageFrequencyComparator = /*#__PURE__*/function () {
216
189
  var i2 = this.getPositionInOrder(e2);
217
190
  return i1 - i2;
218
191
  }
192
+
219
193
  /**
220
194
  * Get the ordinal representing the position of this emoji.
221
195
  *
222
196
  * @param id the id of the emoji
223
197
  */
224
-
225
198
  }, {
226
199
  key: "getPositionInOrder",
227
200
  value: function getPositionInOrder(emoji) {
228
201
  var id = emoji.id ? emoji.id : '0';
229
-
230
202
  if (isEmojiVariationDescription(emoji)) {
231
203
  id = emoji.baseId;
232
204
  }
233
-
234
205
  var position = this.positionLookup.get(id);
235
-
236
206
  if (position) {
237
207
  return position;
238
208
  } else {
@@ -240,10 +210,8 @@ export var UsageFrequencyComparator = /*#__PURE__*/function () {
240
210
  }
241
211
  }
242
212
  }]);
243
-
244
213
  return UsageFrequencyComparator;
245
214
  }();
246
-
247
215
  /**
248
216
  * A comparator that will sort higher an emoji which matches the query string earliest in the indicated
249
217
  * property.
@@ -255,16 +223,12 @@ export var QueryStringPositionMatchComparator = /*#__PURE__*/function () {
255
223
  */
256
224
  function QueryStringPositionMatchComparator(query, propertyToCompare) {
257
225
  _classCallCheck(this, QueryStringPositionMatchComparator);
258
-
259
226
  this.query = query;
260
-
261
227
  if (!propertyToCompare) {
262
228
  throw new Error('propertyToCompare is required');
263
229
  }
264
-
265
230
  this.propertyName = propertyToCompare;
266
231
  }
267
-
268
232
  _createClass(QueryStringPositionMatchComparator, [{
269
233
  key: "getScore",
270
234
  value: function getScore(emoji) {
@@ -280,14 +244,12 @@ export var QueryStringPositionMatchComparator = /*#__PURE__*/function () {
280
244
  return this.getScore(e1) - this.getScore(e2);
281
245
  }
282
246
  }]);
283
-
284
247
  return QueryStringPositionMatchComparator;
285
248
  }();
286
249
  export var OrderComparator = /*#__PURE__*/function () {
287
250
  function OrderComparator() {
288
251
  _classCallCheck(this, OrderComparator);
289
252
  }
290
-
291
253
  _createClass(OrderComparator, [{
292
254
  key: "compare",
293
255
  value: function compare(e1, e2) {
@@ -301,14 +263,12 @@ export var OrderComparator = /*#__PURE__*/function () {
301
263
  return this.INSTANCE || (this.INSTANCE = new this());
302
264
  }
303
265
  }]);
304
-
305
266
  return OrderComparator;
306
267
  }();
307
268
  export var AlphabeticalShortnameComparator = /*#__PURE__*/function () {
308
269
  function AlphabeticalShortnameComparator() {
309
270
  _classCallCheck(this, AlphabeticalShortnameComparator);
310
271
  }
311
-
312
272
  _createClass(AlphabeticalShortnameComparator, [{
313
273
  key: "compare",
314
274
  value: function compare(e1, e2) {
@@ -320,6 +280,5 @@ export var AlphabeticalShortnameComparator = /*#__PURE__*/function () {
320
280
  return this.INSTANCE || (this.INSTANCE = new this());
321
281
  }
322
282
  }]);
323
-
324
283
  return AlphabeticalShortnameComparator;
325
284
  }();
@@ -1,16 +1,14 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  import { isEmojiVariationDescription } from '../../util/type-helpers';
10
7
  import { localStoragePrefix } from '../../util/constants';
11
8
  import DuplicateLimitedQueue from '../../util/DuplicateLimitedQueue';
12
9
  import StoredDuplicateLimitedQueue from '../../util/StoredDuplicateLimitedQueue';
13
10
  import storageAvailable from '../../util/storage-available';
11
+
14
12
  /**
15
13
  * Keeps track of the last 150 emoji usages, although limiting the maximum count for a single emoji to 25 to
16
14
  * ensure we don't end up with only a single emoji being recorded. Usage is persisted to local storage for
@@ -20,47 +18,37 @@ import storageAvailable from '../../util/storage-available';
20
18
  * variations are not collapsed in this way and will be tracked per gender. This decision reflects the UI of
21
19
  * the EmojiPicker component.
22
20
  */
23
-
24
21
  export var UsageFrequencyTracker = /*#__PURE__*/function () {
25
22
  function UsageFrequencyTracker() {
26
23
  var useStorageIfPossible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
27
-
28
24
  _classCallCheck(this, UsageFrequencyTracker);
29
-
30
25
  var options = UsageFrequencyTracker.queueOptions;
31
-
32
26
  if (useStorageIfPossible && options.storage) {
33
27
  var queueOptions = _objectSpread(_objectSpread({}, options), {}, {
34
28
  storage: options.storage
35
29
  });
36
-
37
30
  this.queue = new StoredDuplicateLimitedQueue(queueOptions);
38
31
  } else {
39
32
  this.queue = new DuplicateLimitedQueue(options);
40
33
  }
41
-
42
34
  this.gateway = new Gateway(10);
43
35
  }
36
+
44
37
  /**
45
38
  * Record the fact that the supplied emoji was used. You should note that usage is updated asynchronously so you can not
46
39
  * count on getOrder() reflecting this usage immediately.
47
40
  *
48
41
  * @param emoji the emoji who's usage is to be recorded. If the emoji has no id then no usage will be recorded
49
42
  */
50
-
51
-
52
43
  _createClass(UsageFrequencyTracker, [{
53
44
  key: "recordUsage",
54
45
  value: function recordUsage(emoji) {
55
46
  var _this = this;
56
-
57
47
  var emojiId = emoji.id;
58
-
59
48
  if (emojiId) {
60
49
  if (isEmojiVariationDescription(emoji)) {
61
50
  emojiId = emoji.baseId;
62
51
  }
63
-
64
52
  this.gateway.submit(function () {
65
53
  if (emojiId) {
66
54
  _this.queue.enqueue(emojiId);
@@ -68,67 +56,58 @@ export var UsageFrequencyTracker = /*#__PURE__*/function () {
68
56
  });
69
57
  }
70
58
  }
59
+
71
60
  /**
72
61
  * Returns an array of emoji id (without skin tone variations) sorted by most used to least used. If there
73
62
  * are no usages then an empty array will be returned.
74
63
  */
75
-
76
64
  }, {
77
65
  key: "getOrder",
78
66
  value: function getOrder() {
79
67
  return this.queue.getItemsOrderedByDuplicateCount();
80
68
  }
69
+
81
70
  /**
82
71
  * Exposed for testing only. Clear any recorded usage.
83
72
  */
84
-
85
73
  }, {
86
74
  key: "clear",
87
75
  value: function clear() {
88
76
  this.queue.clear();
89
77
  }
90
78
  }]);
91
-
92
79
  return UsageFrequencyTracker;
93
80
  }();
94
-
95
81
  _defineProperty(UsageFrequencyTracker, "queueOptions", {
96
82
  storage: storageAvailable('localStorage') ? window.localStorage : undefined,
97
83
  storagePrefix: localStoragePrefix,
98
84
  maxDuplicates: 25,
99
85
  minUniqueItems: 5
100
86
  });
101
-
102
87
  export var Gateway = /*#__PURE__*/function () {
103
88
  function Gateway(maximumPermitted) {
104
89
  _classCallCheck(this, Gateway);
105
-
106
90
  if (maximumPermitted < 1) {
107
91
  throw new RangeError('The maximumPermitted parameter must be 1 or more.');
108
92
  }
109
-
110
93
  this.maximumPermitted = maximumPermitted;
111
94
  this.count = 0;
112
95
  }
96
+
113
97
  /**
114
98
  * Run the supplied function if the count of already submitted work allows it. Drop the work
115
99
  * if it's not allowed to run.
116
100
  *
117
101
  * Will return true if the function has been submitted or false if it was not submitted.
118
102
  */
119
-
120
-
121
103
  _createClass(Gateway, [{
122
104
  key: "submit",
123
105
  value: function submit(f) {
124
106
  var _this2 = this;
125
-
126
107
  if (this.count >= this.maximumPermitted) {
127
108
  return false;
128
109
  }
129
-
130
110
  this.count++;
131
-
132
111
  var wrappedFunc = function wrappedFunc() {
133
112
  try {
134
113
  f();
@@ -136,11 +115,9 @@ export var Gateway = /*#__PURE__*/function () {
136
115
  _this2.completed();
137
116
  }
138
117
  };
139
-
140
118
  if (typeof window !== 'undefined') {
141
119
  window.setTimeout(wrappedFunc);
142
120
  }
143
-
144
121
  return true;
145
122
  }
146
123
  }, {
@@ -149,6 +126,5 @@ export var Gateway = /*#__PURE__*/function () {
149
126
  this.count--;
150
127
  }
151
128
  }]);
152
-
153
129
  return Gateway;
154
130
  }();