@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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/admin.js +0 -2
- package/dist/cjs/api/EmojiLoader.js +1 -8
- package/dist/cjs/api/EmojiRepository.js +16 -80
- package/dist/cjs/api/EmojiRepositoryRegex.js +2 -0
- package/dist/cjs/api/EmojiResource.js +20 -170
- package/dist/cjs/api/EmojiUtils.js +27 -67
- package/dist/cjs/api/internal/Comparators.js +8 -62
- package/dist/cjs/api/internal/UsageFrequencyTracker.js +4 -34
- package/dist/cjs/api/media/MediaEmojiCache.js +8 -58
- package/dist/cjs/api/media/MediaImageLoader.js +4 -28
- package/dist/cjs/api/media/SiteEmojiResource.js +14 -55
- package/dist/cjs/api/media/TokenManager.js +4 -18
- package/dist/cjs/components/common/CachingEmoji.js +18 -52
- package/dist/cjs/components/common/DeleteButton.js +0 -10
- package/dist/cjs/components/common/Emoji.js +44 -102
- package/dist/cjs/components/common/EmojiActions.js +25 -61
- package/dist/cjs/components/common/EmojiButton.js +5 -18
- package/dist/cjs/components/common/EmojiDeletePreview.js +7 -38
- package/dist/cjs/components/common/EmojiErrorMessage.js +3 -9
- package/dist/cjs/components/common/EmojiPlaceholder.js +7 -16
- package/dist/cjs/components/common/EmojiPreviewComponent.js +1 -6
- package/dist/cjs/components/common/EmojiUploadPicker.js +31 -86
- package/dist/cjs/components/common/EmojiUploadPreview.js +7 -36
- package/dist/cjs/components/common/FileChooser.js +5 -18
- package/dist/cjs/components/common/LoadingEmojiComponent.js +5 -24
- package/dist/cjs/components/common/Popup.js +16 -44
- package/dist/cjs/components/common/RecordSelectionDefault.js +0 -7
- package/dist/cjs/components/common/ResourcedEmoji.js +0 -15
- package/dist/cjs/components/common/ResourcedEmojiComponent.js +29 -69
- package/dist/cjs/components/common/RetryableButton.js +4 -19
- package/dist/cjs/components/common/Scrollable.js +6 -36
- package/dist/cjs/components/common/ToneSelector.js +3 -24
- package/dist/cjs/components/common/UfoErrorBoundary.js +1 -19
- package/dist/cjs/components/common/UploadEmoji.js +2 -13
- package/dist/cjs/components/common/internal-types.js +0 -1
- package/dist/cjs/components/common/setSkinToneAriaLabelText.js +0 -6
- package/dist/cjs/components/common/styles.js +9 -17
- package/dist/cjs/components/hooks.js +0 -2
- package/dist/cjs/components/i18n.js +0 -2
- package/dist/cjs/components/picker/CategorySelector.js +4 -50
- package/dist/cjs/components/picker/CategoryTracker.js +3 -14
- package/dist/cjs/components/picker/EmojiPicker.js +3 -42
- package/dist/cjs/components/picker/EmojiPickerCategoryHeading.js +2 -10
- package/dist/cjs/components/picker/EmojiPickerComponent.js +59 -140
- package/dist/cjs/components/picker/EmojiPickerEmojiRow.js +7 -14
- package/dist/cjs/components/picker/EmojiPickerFooter.js +1 -8
- package/dist/cjs/components/picker/EmojiPickerList.js +32 -83
- package/dist/cjs/components/picker/EmojiPickerListSearch.js +11 -48
- package/dist/cjs/components/picker/EmojiPickerSizes.js +1 -2
- package/dist/cjs/components/picker/EmojiPickerVirtualItems.js +1 -38
- package/dist/cjs/components/picker/VirtualList.js +11 -41
- package/dist/cjs/components/picker/categories.js +0 -14
- package/dist/cjs/components/picker/styles.js +15 -20
- package/dist/cjs/components/picker/utils.js +0 -4
- package/dist/cjs/components/typeahead/EmojiTypeAhead.js +10 -45
- package/dist/cjs/components/typeahead/EmojiTypeAheadComponent.js +11 -74
- package/dist/cjs/components/typeahead/EmojiTypeAheadItem.js +7 -37
- package/dist/cjs/components/typeahead/EmojiTypeAheadList.js +10 -63
- package/dist/cjs/components/typeahead/styles.js +2 -4
- package/dist/cjs/components/uploader/EmojiUploadComponent.js +6 -42
- package/dist/cjs/components/uploader/EmojiUploader.js +3 -31
- package/dist/cjs/components/uploader/styles.js +3 -4
- package/dist/cjs/context/EmojiCommonProvider.js +0 -6
- package/dist/cjs/context/EmojiContext.js +0 -2
- package/dist/cjs/context/EmojiContextProvider.js +1 -17
- package/dist/cjs/element.js +0 -4
- package/dist/cjs/hooks/useEmoji.js +5 -20
- package/dist/cjs/hooks/useEmojiContext.js +0 -4
- package/dist/cjs/hooks/usePrevious.js +0 -2
- package/dist/cjs/i18n/cs.js +0 -1
- package/dist/cjs/i18n/da.js +0 -1
- package/dist/cjs/i18n/de.js +0 -1
- package/dist/cjs/i18n/en.js +0 -1
- package/dist/cjs/i18n/en_GB.js +0 -1
- package/dist/cjs/i18n/en_ZZ.js +0 -1
- package/dist/cjs/i18n/es.js +0 -1
- package/dist/cjs/i18n/et.js +0 -1
- package/dist/cjs/i18n/fi.js +0 -1
- package/dist/cjs/i18n/fr.js +0 -1
- package/dist/cjs/i18n/hu.js +0 -1
- package/dist/cjs/i18n/index.js +0 -30
- package/dist/cjs/i18n/it.js +0 -1
- package/dist/cjs/i18n/ja.js +0 -1
- package/dist/cjs/i18n/ko.js +0 -1
- package/dist/cjs/i18n/nb.js +0 -1
- package/dist/cjs/i18n/nl.js +0 -1
- package/dist/cjs/i18n/pl.js +0 -1
- package/dist/cjs/i18n/pt_BR.js +0 -1
- package/dist/cjs/i18n/pt_PT.js +0 -1
- package/dist/cjs/i18n/ru.js +0 -1
- package/dist/cjs/i18n/sk.js +0 -1
- package/dist/cjs/i18n/sv.js +0 -1
- package/dist/cjs/i18n/th.js +0 -1
- package/dist/cjs/i18n/tr.js +0 -1
- package/dist/cjs/i18n/uk.js +0 -1
- package/dist/cjs/i18n/vi.js +0 -1
- package/dist/cjs/i18n/zh.js +0 -1
- package/dist/cjs/i18n/zh_TW.js +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/picker.js +0 -2
- package/dist/cjs/resource.js +0 -5
- package/dist/cjs/typeahead.js +0 -3
- package/dist/cjs/types.js +0 -17
- package/dist/cjs/util/DuplicateLimitedQueue.js +13 -31
- package/dist/cjs/util/StoredDuplicateLimitedQueue.js +4 -26
- package/dist/cjs/util/analytics/analytics.js +14 -97
- package/dist/cjs/util/analytics/index.js +0 -4
- package/dist/cjs/util/analytics/samplingUfo.js +3 -59
- package/dist/cjs/util/analytics/ufoExperiences.js +0 -12
- package/dist/cjs/util/analytics/useSampledUFOComponentExperience.js +3 -10
- package/dist/cjs/util/constants.js +5 -5
- package/dist/cjs/util/filters.js +0 -4
- package/dist/cjs/util/image.js +3 -18
- package/dist/cjs/util/logger.js +0 -6
- package/dist/cjs/util/mouse.js +3 -6
- package/dist/cjs/util/shared-styles.js +0 -4
- package/dist/cjs/util/storage-available.js +10 -8
- package/dist/cjs/util/type-helpers.js +2 -57
- package/dist/cjs/util/useInView.js +0 -6
- package/dist/cjs/utils.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/api/EmojiLoader.js +2 -4
- package/dist/es2019/api/EmojiRepository.js +15 -82
- package/dist/es2019/api/EmojiRepositoryRegex.js +2 -0
- package/dist/es2019/api/EmojiResource.js +21 -114
- package/dist/es2019/api/EmojiUtils.js +11 -18
- package/dist/es2019/api/internal/Comparators.js +12 -48
- package/dist/es2019/api/internal/UsageFrequencyTracker.js +7 -24
- package/dist/es2019/api/media/MediaEmojiCache.js +9 -52
- package/dist/es2019/api/media/MediaImageLoader.js +2 -16
- package/dist/es2019/api/media/SiteEmojiResource.js +11 -31
- package/dist/es2019/api/media/TokenManager.js +4 -14
- package/dist/es2019/components/common/CachingEmoji.js +5 -12
- package/dist/es2019/components/common/DeleteButton.js +2 -3
- package/dist/es2019/components/common/Emoji.js +19 -47
- package/dist/es2019/components/common/EmojiActions.js +3 -16
- package/dist/es2019/components/common/EmojiButton.js +0 -5
- package/dist/es2019/components/common/EmojiDeletePreview.js +0 -11
- package/dist/es2019/components/common/EmojiErrorMessage.js +1 -2
- package/dist/es2019/components/common/EmojiPlaceholder.js +0 -5
- package/dist/es2019/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/es2019/components/common/EmojiUploadPicker.js +2 -25
- package/dist/es2019/components/common/EmojiUploadPreview.js +0 -6
- package/dist/es2019/components/common/FileChooser.js +0 -6
- package/dist/es2019/components/common/LoadingEmojiComponent.js +2 -14
- package/dist/es2019/components/common/Popup.js +4 -22
- package/dist/es2019/components/common/RecordSelectionDefault.js +1 -1
- package/dist/es2019/components/common/ResourcedEmoji.js +1 -6
- package/dist/es2019/components/common/ResourcedEmojiComponent.js +2 -13
- package/dist/es2019/components/common/RetryableButton.js +1 -8
- package/dist/es2019/components/common/Scrollable.js +2 -12
- package/dist/es2019/components/common/ToneSelector.js +2 -8
- package/dist/es2019/components/common/UfoErrorBoundary.js +0 -2
- package/dist/es2019/components/common/UploadEmoji.js +2 -3
- package/dist/es2019/components/common/internal-types.js +0 -1
- package/dist/es2019/components/common/styles.js +12 -8
- package/dist/es2019/components/picker/CategorySelector.js +0 -22
- package/dist/es2019/components/picker/CategoryTracker.js +3 -13
- package/dist/es2019/components/picker/EmojiPicker.js +3 -17
- package/dist/es2019/components/picker/EmojiPickerCategoryHeading.js +2 -3
- package/dist/es2019/components/picker/EmojiPickerComponent.js +10 -43
- package/dist/es2019/components/picker/EmojiPickerEmojiRow.js +0 -2
- package/dist/es2019/components/picker/EmojiPickerFooter.js +0 -2
- package/dist/es2019/components/picker/EmojiPickerList.js +10 -45
- package/dist/es2019/components/picker/EmojiPickerListSearch.js +2 -19
- package/dist/es2019/components/picker/EmojiPickerSizes.js +1 -0
- package/dist/es2019/components/picker/EmojiPickerVirtualItems.js +1 -8
- package/dist/es2019/components/picker/VirtualList.js +3 -24
- package/dist/es2019/components/picker/styles.js +22 -10
- package/dist/es2019/components/picker/utils.js +0 -1
- package/dist/es2019/components/typeahead/EmojiTypeAhead.js +4 -21
- package/dist/es2019/components/typeahead/EmojiTypeAheadComponent.js +0 -42
- package/dist/es2019/components/typeahead/EmojiTypeAheadItem.js +0 -7
- package/dist/es2019/components/typeahead/EmojiTypeAheadList.js +4 -45
- package/dist/es2019/components/typeahead/styles.js +2 -1
- package/dist/es2019/components/uploader/EmojiUploadComponent.js +2 -15
- package/dist/es2019/components/uploader/EmojiUploader.js +2 -10
- package/dist/es2019/components/uploader/styles.js +5 -2
- package/dist/es2019/context/EmojiCommonProvider.js +0 -2
- package/dist/es2019/context/EmojiContextProvider.js +0 -1
- package/dist/es2019/hooks/useEmoji.js +2 -6
- package/dist/es2019/hooks/useEmojiContext.js +1 -1
- package/dist/es2019/index.js +12 -6
- package/dist/es2019/types.js +1 -11
- package/dist/es2019/util/DuplicateLimitedQueue.js +13 -35
- package/dist/es2019/util/StoredDuplicateLimitedQueue.js +5 -12
- package/dist/es2019/util/analytics/analytics.js +7 -23
- package/dist/es2019/util/analytics/samplingUfo.js +6 -32
- package/dist/es2019/util/analytics/ufoExperiences.js +0 -3
- package/dist/es2019/util/analytics/useSampledUFOComponentExperience.js +3 -7
- package/dist/es2019/util/constants.js +5 -4
- package/dist/es2019/util/filters.js +0 -3
- package/dist/es2019/util/image.js +3 -8
- package/dist/es2019/util/mouse.js +3 -3
- package/dist/es2019/util/storage-available.js +10 -7
- package/dist/es2019/util/type-helpers.js +6 -9
- package/dist/es2019/util/useInView.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/api/EmojiLoader.js +2 -6
- package/dist/esm/api/EmojiRepository.js +16 -71
- package/dist/esm/api/EmojiRepositoryRegex.js +2 -0
- package/dist/esm/api/EmojiResource.js +20 -158
- package/dist/esm/api/EmojiUtils.js +27 -47
- package/dist/esm/api/internal/Comparators.js +12 -53
- package/dist/esm/api/internal/UsageFrequencyTracker.js +5 -29
- package/dist/esm/api/media/MediaEmojiCache.js +9 -55
- package/dist/esm/api/media/MediaImageLoader.js +4 -27
- package/dist/esm/api/media/SiteEmojiResource.js +14 -43
- package/dist/esm/api/media/TokenManager.js +6 -16
- package/dist/esm/components/common/CachingEmoji.js +18 -30
- package/dist/esm/components/common/DeleteButton.js +2 -3
- package/dist/esm/components/common/Emoji.js +44 -78
- package/dist/esm/components/common/EmojiActions.js +25 -40
- package/dist/esm/components/common/EmojiButton.js +4 -9
- package/dist/esm/components/common/EmojiDeletePreview.js +7 -24
- package/dist/esm/components/common/EmojiErrorMessage.js +3 -4
- package/dist/esm/components/common/EmojiPlaceholder.js +6 -11
- package/dist/esm/components/common/EmojiPreviewComponent.js +1 -0
- package/dist/esm/components/common/EmojiUploadPicker.js +30 -64
- package/dist/esm/components/common/EmojiUploadPreview.js +7 -19
- package/dist/esm/components/common/FileChooser.js +5 -11
- package/dist/esm/components/common/LoadingEmojiComponent.js +4 -20
- package/dist/esm/components/common/Popup.js +16 -36
- package/dist/esm/components/common/RecordSelectionDefault.js +1 -1
- package/dist/esm/components/common/ResourcedEmoji.js +1 -6
- package/dist/esm/components/common/ResourcedEmojiComponent.js +29 -51
- package/dist/esm/components/common/RetryableButton.js +4 -11
- package/dist/esm/components/common/Scrollable.js +6 -29
- package/dist/esm/components/common/ToneSelector.js +3 -13
- package/dist/esm/components/common/UfoErrorBoundary.js +1 -13
- package/dist/esm/components/common/UploadEmoji.js +2 -3
- package/dist/esm/components/common/internal-types.js +0 -1
- package/dist/esm/components/common/setSkinToneAriaLabelText.js +0 -2
- package/dist/esm/components/common/styles.js +12 -9
- package/dist/esm/components/picker/CategorySelector.js +4 -32
- package/dist/esm/components/picker/CategoryTracker.js +3 -13
- package/dist/esm/components/picker/EmojiPicker.js +5 -27
- package/dist/esm/components/picker/EmojiPickerCategoryHeading.js +4 -5
- package/dist/esm/components/picker/EmojiPickerComponent.js +60 -114
- package/dist/esm/components/picker/EmojiPickerEmojiRow.js +6 -8
- package/dist/esm/components/picker/EmojiPickerFooter.js +0 -2
- package/dist/esm/components/picker/EmojiPickerList.js +32 -77
- package/dist/esm/components/picker/EmojiPickerListSearch.js +11 -35
- package/dist/esm/components/picker/EmojiPickerSizes.js +1 -0
- package/dist/esm/components/picker/EmojiPickerVirtualItems.js +2 -26
- package/dist/esm/components/picker/VirtualList.js +11 -28
- package/dist/esm/components/picker/styles.js +22 -11
- package/dist/esm/components/picker/utils.js +0 -1
- package/dist/esm/components/typeahead/EmojiTypeAhead.js +11 -39
- package/dist/esm/components/typeahead/EmojiTypeAheadComponent.js +11 -65
- package/dist/esm/components/typeahead/EmojiTypeAheadItem.js +7 -24
- package/dist/esm/components/typeahead/EmojiTypeAheadList.js +10 -53
- package/dist/esm/components/typeahead/styles.js +2 -1
- package/dist/esm/components/uploader/EmojiUploadComponent.js +5 -25
- package/dist/esm/components/uploader/EmojiUploader.js +4 -22
- package/dist/esm/components/uploader/styles.js +5 -2
- package/dist/esm/context/EmojiCommonProvider.js +0 -2
- package/dist/esm/context/EmojiContextProvider.js +1 -6
- package/dist/esm/hooks/useEmoji.js +5 -13
- package/dist/esm/hooks/useEmojiContext.js +1 -1
- package/dist/esm/index.js +12 -6
- package/dist/esm/types.js +1 -11
- package/dist/esm/util/DuplicateLimitedQueue.js +13 -29
- package/dist/esm/util/StoredDuplicateLimitedQueue.js +5 -22
- package/dist/esm/util/analytics/analytics.js +14 -50
- package/dist/esm/util/analytics/samplingUfo.js +3 -51
- package/dist/esm/util/analytics/ufoExperiences.js +0 -3
- package/dist/esm/util/analytics/useSampledUFOComponentExperience.js +3 -7
- package/dist/esm/util/constants.js +5 -4
- package/dist/esm/util/filters.js +0 -3
- package/dist/esm/util/image.js +3 -8
- package/dist/esm/util/logger.js +0 -2
- package/dist/esm/util/mouse.js +3 -3
- package/dist/esm/util/storage-available.js +10 -7
- package/dist/esm/util/type-helpers.js +2 -12
- package/dist/esm/util/useInView.js +0 -2
- package/dist/esm/version.json +1 -1
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
120
|
-
|
|
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);
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
}();
|