@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
|
@@ -21,82 +21,73 @@ export default class DuplicateLimitedQueue {
|
|
|
21
21
|
if (options.maxDuplicates < 1) {
|
|
22
22
|
throw new RangeError('The maxDuplicates option must be at least 1');
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
if (options.minUniqueItems < 1) {
|
|
26
25
|
throw new RangeError('The minUniqueItems option must be at least 1');
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
this.maximumSize = options.maxDuplicates * options.minUniqueItems;
|
|
30
28
|
this.perItemSize = options.maxDuplicates;
|
|
31
29
|
this.createEmptyState();
|
|
32
30
|
}
|
|
31
|
+
|
|
33
32
|
/**
|
|
34
33
|
* @param item the item to add to the queue.
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
35
|
enqueue(item) {
|
|
39
|
-
this.enqueueWithoutOrdering(item);
|
|
40
|
-
// so do the ordering work on each enqueue.
|
|
36
|
+
this.enqueueWithoutOrdering(item);
|
|
41
37
|
|
|
38
|
+
// enqueues are less time sensitive (and may happen less frequently) than queries against the queue
|
|
39
|
+
// so do the ordering work on each enqueue.
|
|
42
40
|
this.itemsOrderedByFrequency = this.orderItemsByFrequency();
|
|
43
41
|
}
|
|
42
|
+
|
|
44
43
|
/**
|
|
45
44
|
* Return the items in the queue, ordered by how often they are duplicated. The items with the
|
|
46
45
|
* most duplicates come first in the returned Array.
|
|
47
46
|
*
|
|
48
47
|
* If there are no items in the queue then an empty Array will be returned.
|
|
49
48
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
49
|
getItemsOrderedByDuplicateCount() {
|
|
53
50
|
return this.itemsOrderedByFrequency;
|
|
54
51
|
}
|
|
52
|
+
|
|
55
53
|
/**
|
|
56
54
|
* Exposed for storybook/testing purposes only. Clear the contents of the queue.
|
|
57
55
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
56
|
clear() {
|
|
61
57
|
this.createEmptyState();
|
|
62
58
|
}
|
|
59
|
+
|
|
63
60
|
/**
|
|
64
61
|
* A more efficient mechanism for adding multiple items. Ordering is only performed once all
|
|
65
62
|
* the items have been added.
|
|
66
63
|
*
|
|
67
64
|
* @param items the items to be enqueued, which happens in their presented order.
|
|
68
65
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
66
|
bulkEnqueue(items) {
|
|
72
67
|
items.map(item => this.enqueueWithoutOrdering(item));
|
|
73
68
|
this.itemsOrderedByFrequency = this.orderItemsByFrequency();
|
|
74
69
|
}
|
|
70
|
+
|
|
75
71
|
/**
|
|
76
72
|
* Return the items currently stored in the queue.
|
|
77
73
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
74
|
getItems() {
|
|
81
75
|
return this.items;
|
|
82
76
|
}
|
|
83
|
-
|
|
84
77
|
createEmptyState() {
|
|
85
78
|
this.items = new Array();
|
|
86
79
|
this.itemCountMap = new Map();
|
|
87
80
|
this.itemsOrderedByFrequency = new Array();
|
|
88
81
|
}
|
|
82
|
+
|
|
89
83
|
/**
|
|
90
84
|
* Enqueue the supplied item, keeping consistency with the limits configured. However no ordering is
|
|
91
85
|
* performed by this enqueuing. You must trigger that manually if required.
|
|
92
86
|
*
|
|
93
87
|
* @param item the item to be queued
|
|
94
88
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
89
|
enqueueWithoutOrdering(item) {
|
|
98
90
|
const count = this.itemCountMap.get(item);
|
|
99
|
-
|
|
100
91
|
if (count && count >= this.perItemSize) {
|
|
101
92
|
// find the first item with that key in the array and remove it
|
|
102
93
|
this.removeFirstOccurrence(item);
|
|
@@ -105,27 +96,22 @@ export default class DuplicateLimitedQueue {
|
|
|
105
96
|
this.remove();
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
|
-
|
|
109
99
|
this.add(item);
|
|
110
100
|
}
|
|
101
|
+
|
|
111
102
|
/**
|
|
112
103
|
* Get an array of items from the queue ordered by how often they are duplicated in the queue.
|
|
113
104
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
105
|
orderItemsByFrequency() {
|
|
117
106
|
const orderedEntries = Array.from(this.itemCountMap.entries()).sort((a, b) => {
|
|
118
107
|
return b[1] - a[1];
|
|
119
108
|
});
|
|
120
109
|
return orderedEntries.map(value => value[0]);
|
|
121
110
|
}
|
|
122
|
-
|
|
123
111
|
decrementCount(item) {
|
|
124
112
|
let count = this.itemCountMap.get(item);
|
|
125
|
-
|
|
126
113
|
if (count) {
|
|
127
114
|
count--;
|
|
128
|
-
|
|
129
115
|
if (count > 0) {
|
|
130
116
|
this.itemCountMap.set(item, count);
|
|
131
117
|
} else {
|
|
@@ -133,51 +119,43 @@ export default class DuplicateLimitedQueue {
|
|
|
133
119
|
}
|
|
134
120
|
}
|
|
135
121
|
}
|
|
122
|
+
|
|
136
123
|
/**
|
|
137
124
|
* Walk the list of items and remove the first occurrence of the matching item.
|
|
138
125
|
*
|
|
139
126
|
* @param item the item to be removed.
|
|
140
127
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
128
|
removeFirstOccurrence(item) {
|
|
144
129
|
const index = this.items.indexOf(item);
|
|
145
|
-
|
|
146
130
|
if (index !== -1) {
|
|
147
131
|
this.items.splice(index, 1);
|
|
148
132
|
this.decrementCount(item);
|
|
149
133
|
}
|
|
150
134
|
}
|
|
135
|
+
|
|
151
136
|
/**
|
|
152
137
|
* Remove the first item from the queue and update the itemCountMap accordingly.
|
|
153
138
|
* @return the item add the front of the queue or undefined if the queue is empty
|
|
154
139
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
157
140
|
remove() {
|
|
158
141
|
const removed = this.items.shift();
|
|
159
|
-
|
|
160
142
|
if (removed !== undefined) {
|
|
161
143
|
this.decrementCount(removed);
|
|
162
144
|
}
|
|
163
|
-
|
|
164
145
|
return removed;
|
|
165
146
|
}
|
|
147
|
+
|
|
166
148
|
/**
|
|
167
149
|
* Add the supplied item to the end of the queue and update the itemCountMap accordingly.
|
|
168
150
|
* @param item the item to be added to the queue
|
|
169
151
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
152
|
add(item) {
|
|
173
153
|
this.items.push(item);
|
|
174
154
|
const count = this.itemCountMap.get(item);
|
|
175
|
-
|
|
176
155
|
if (count) {
|
|
177
156
|
this.itemCountMap.set(item, count + 1);
|
|
178
157
|
} else {
|
|
179
158
|
this.itemCountMap.set(item, 1);
|
|
180
159
|
}
|
|
181
160
|
}
|
|
182
|
-
|
|
183
161
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import DuplicateLimitedQueue from './DuplicateLimitedQueue';
|
|
3
3
|
import debug from './logger';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* The options used to configure a newly constructed queue.
|
|
6
7
|
*/
|
|
@@ -16,36 +17,32 @@ export default class StoredDuplicateLimitedQueue extends DuplicateLimitedQueue {
|
|
|
16
17
|
this.prefixedStorageKey = `${options.storagePrefix}.${StoredDuplicateLimitedQueue.storageKey}`;
|
|
17
18
|
this.load();
|
|
18
19
|
}
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* Enqueue the supplied item and also persist the new contents of the queue to storage.
|
|
21
23
|
*
|
|
22
24
|
* @param item the item to be enqueued
|
|
23
25
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
26
|
enqueue(item) {
|
|
27
27
|
super.enqueue(item);
|
|
28
28
|
this.save();
|
|
29
29
|
}
|
|
30
|
+
|
|
30
31
|
/**
|
|
31
32
|
* Exposed for storybook/testing purposes only. Clear the contents of the queue, and localStorage.
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
34
|
clear() {
|
|
36
35
|
super.clear();
|
|
37
36
|
this.storage.removeItem(this.prefixedStorageKey);
|
|
38
37
|
}
|
|
38
|
+
|
|
39
39
|
/**
|
|
40
40
|
* Initialise the queue contents from the configured Storage. If there is no data found in
|
|
41
41
|
* storage then the queue will have no items added. Likewise, a failure to read or parse stored
|
|
42
42
|
* data will be swallowed and no items are added to the queue.
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
44
|
load() {
|
|
47
45
|
const itemsJson = this.storage.getItem(this.prefixedStorageKey);
|
|
48
|
-
|
|
49
46
|
if (itemsJson) {
|
|
50
47
|
try {
|
|
51
48
|
const items = JSON.parse(itemsJson);
|
|
@@ -55,23 +52,19 @@ export default class StoredDuplicateLimitedQueue extends DuplicateLimitedQueue {
|
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
}
|
|
55
|
+
|
|
58
56
|
/**
|
|
59
57
|
* Save the current items in the queue, overwriting any previously stored queue.
|
|
60
58
|
* Any failure in saving will be silently ignored with the likely outcome that any previous
|
|
61
59
|
* saved items will remain unchanged in storage.
|
|
62
60
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
61
|
save() {
|
|
66
62
|
const itemsJson = JSON.stringify(this.getItems());
|
|
67
|
-
|
|
68
63
|
try {
|
|
69
64
|
this.storage.setItem(this.prefixedStorageKey, itemsJson);
|
|
70
65
|
} catch (e) {
|
|
71
66
|
debug(`Error saving the queued items as ${this.prefixedStorageKey}`, e);
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
|
|
75
69
|
}
|
|
76
|
-
|
|
77
70
|
_defineProperty(StoredDuplicateLimitedQueue, "storageKey", 'lastUsed');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import { name as packageName, version as packageVersion } from '../../version.json';
|
|
3
3
|
export const createAndFireEventInElementsChannel = createAndFireEvent('fabric-elements');
|
|
4
|
-
|
|
5
4
|
const createEvent = (eventType, action, actionSubject, actionSubjectId, attributes = {}) => ({
|
|
6
5
|
eventType,
|
|
7
6
|
action,
|
|
@@ -13,7 +12,6 @@ const createEvent = (eventType, action, actionSubject, actionSubjectId, attribut
|
|
|
13
12
|
...attributes
|
|
14
13
|
}
|
|
15
14
|
});
|
|
16
|
-
|
|
17
15
|
export const recordSucceeded = source => {
|
|
18
16
|
return createEvent('operational', 'succeeded', 'recordEmojiSelection', undefined, {
|
|
19
17
|
source
|
|
@@ -24,9 +22,7 @@ export const recordFailed = source => {
|
|
|
24
22
|
source
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
const emojiPickerEvent = (action, attributes = {}, actionSubjectId) => createEvent('ui', action, 'emojiPicker', actionSubjectId, attributes);
|
|
29
|
-
|
|
30
26
|
export const openedPickerEvent = () => emojiPickerEvent('opened');
|
|
31
27
|
export const closedPickerEvent = attributes => emojiPickerEvent('closed', attributes);
|
|
32
28
|
const skinTones = [{
|
|
@@ -45,12 +41,10 @@ const skinTones = [{
|
|
|
45
41
|
id: '-1f3ff',
|
|
46
42
|
skinToneModifier: 'dark'
|
|
47
43
|
}];
|
|
48
|
-
|
|
49
44
|
const getSkinTone = emojiId => {
|
|
50
45
|
if (!emojiId) {
|
|
51
46
|
return {};
|
|
52
47
|
}
|
|
53
|
-
|
|
54
48
|
for (const {
|
|
55
49
|
id,
|
|
56
50
|
skinToneModifier
|
|
@@ -62,24 +56,19 @@ const getSkinTone = emojiId => {
|
|
|
62
56
|
};
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
return {};
|
|
67
60
|
};
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
export const pickerClickedEvent = attributes => emojiPickerEvent('clicked', {
|
|
62
|
+
...getSkinTone(attributes.emojiId),
|
|
70
63
|
...attributes
|
|
71
64
|
}, 'emoji');
|
|
72
65
|
export const categoryClickedEvent = attributes => emojiPickerEvent('clicked', attributes, 'category');
|
|
73
66
|
export const pickerSearchedEvent = attributes => emojiPickerEvent('searched', attributes, 'query');
|
|
74
|
-
|
|
75
67
|
const skintoneSelectorEvent = (action, attributes = {}) => createEvent('ui', action, 'emojiSkintoneSelector', undefined, attributes);
|
|
76
|
-
|
|
77
68
|
export const toneSelectedEvent = attributes => skintoneSelectorEvent('clicked', attributes);
|
|
78
69
|
export const toneSelectorOpenedEvent = attributes => skintoneSelectorEvent('opened', attributes);
|
|
79
70
|
export const toneSelectorClosedEvent = () => skintoneSelectorEvent('cancelled');
|
|
80
|
-
|
|
81
71
|
const emojiUploaderEvent = (action, actionSubjectId, attributes) => createEvent('ui', action, 'emojiUploader', actionSubjectId, attributes);
|
|
82
|
-
|
|
83
72
|
export const uploadBeginButton = () => emojiUploaderEvent('clicked', 'addButton');
|
|
84
73
|
export const uploadConfirmButton = attributes => emojiUploaderEvent('clicked', 'confirmButton', attributes);
|
|
85
74
|
export const uploadCancelButton = () => emojiUploaderEvent('clicked', 'cancelButton');
|
|
@@ -89,7 +78,6 @@ export const deleteBeginEvent = attributes => createEvent('ui', 'clicked', 'emoj
|
|
|
89
78
|
export const deleteConfirmEvent = attributes => createEvent('ui', 'clicked', 'emojiPicker', 'deleteEmojiConfirm', attributes);
|
|
90
79
|
export const deleteCancelEvent = attributes => createEvent('ui', 'clicked', 'emojiPicker', 'deleteEmojiCancel', attributes);
|
|
91
80
|
export const selectedFileEvent = () => createEvent('ui', 'clicked', 'emojiUploader', 'selectFile');
|
|
92
|
-
|
|
93
81
|
const extractCommonAttributes = (query, emojiList) => {
|
|
94
82
|
return {
|
|
95
83
|
queryLength: query ? query.length : 0,
|
|
@@ -97,21 +85,17 @@ const extractCommonAttributes = (query, emojiList) => {
|
|
|
97
85
|
emojiIds: emojiList ? emojiList.map(emoji => emoji.id).filter(Boolean).slice(0, 20) : []
|
|
98
86
|
};
|
|
99
87
|
};
|
|
100
|
-
|
|
101
88
|
export const typeaheadCancelledEvent = (duration, query, emojiList) => createEvent('ui', 'cancelled', 'emojiTypeahead', undefined, {
|
|
102
89
|
duration,
|
|
103
90
|
...extractCommonAttributes(query, emojiList)
|
|
104
91
|
});
|
|
105
|
-
|
|
106
92
|
const getPosition = (emojiList, selectedEmoji) => {
|
|
107
93
|
if (emojiList) {
|
|
108
94
|
const index = emojiList.findIndex(emoji => emoji.id === selectedEmoji.id);
|
|
109
95
|
return index === -1 ? undefined : index;
|
|
110
96
|
}
|
|
111
|
-
|
|
112
97
|
return;
|
|
113
98
|
};
|
|
114
|
-
|
|
115
99
|
export const typeaheadSelectedEvent = (pressed, duration, emoji, emojiList, query, exactMatch) => createEvent('ui', pressed ? 'pressed' : 'clicked', 'emojiTypeahead', undefined, {
|
|
116
100
|
duration,
|
|
117
101
|
position: getPosition(emojiList, emoji),
|
|
@@ -123,27 +107,28 @@ export const typeaheadSelectedEvent = (pressed, duration, emoji, emojiList, quer
|
|
|
123
107
|
export const typeaheadRenderedEvent = (duration, query, emojiList) => createEvent('operational', 'rendered', 'emojiTypeahead', undefined, {
|
|
124
108
|
duration,
|
|
125
109
|
...extractCommonAttributes(query, emojiList)
|
|
126
|
-
});
|
|
110
|
+
});
|
|
127
111
|
|
|
112
|
+
// it's used in editor typeahead to fire success record analytics
|
|
128
113
|
export const recordSelectionSucceededSli = options => () => {
|
|
129
114
|
if (options && options.createAnalyticsEvent) {
|
|
130
115
|
createAndFireEvent('editor')(recordSucceeded('typeahead'))(options.createAnalyticsEvent);
|
|
131
116
|
}
|
|
132
|
-
};
|
|
117
|
+
};
|
|
133
118
|
|
|
119
|
+
// it's used in editor typeahead to fire failure record analytics
|
|
134
120
|
export const recordSelectionFailedSli = options => err => {
|
|
135
121
|
if (options && options.createAnalyticsEvent) {
|
|
136
122
|
createAndFireEvent('editor')(recordFailed('typeahead'))(options.createAnalyticsEvent);
|
|
137
123
|
}
|
|
138
|
-
|
|
139
124
|
return Promise.reject(err);
|
|
140
125
|
};
|
|
126
|
+
|
|
141
127
|
/**
|
|
142
128
|
* Used for store failure metadata for analytics
|
|
143
129
|
* @param error The error could be a service error with {code, reason} or an Error
|
|
144
130
|
* @returns any
|
|
145
131
|
*/
|
|
146
|
-
|
|
147
132
|
export const extractErrorInfo = error => {
|
|
148
133
|
if (error instanceof Error) {
|
|
149
134
|
return {
|
|
@@ -151,6 +136,5 @@ export const extractErrorInfo = error => {
|
|
|
151
136
|
message: error.message
|
|
152
137
|
};
|
|
153
138
|
}
|
|
154
|
-
|
|
155
139
|
return error;
|
|
156
140
|
};
|
|
@@ -4,6 +4,7 @@ export const clearSampled = () => {
|
|
|
4
4
|
delete ufoExperiencesSampled[prop];
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* A random sampling function
|
|
9
10
|
* sampling algorithm is from @atlassian/jira-coinflip at https://stash.atlassian.com/projects/JIRACLOUD/repos/jira-frontend/browse/src/packages/platform/app-framework/coinflip/src/index.tsx
|
|
@@ -12,31 +13,26 @@ export const clearSampled = () => {
|
|
|
12
13
|
* @returns bool, if it passes or not
|
|
13
14
|
*/
|
|
14
15
|
// default sampling function to determine which one to be sampled
|
|
15
|
-
|
|
16
16
|
export const isExperienceSampled = rate => {
|
|
17
17
|
if (rate === 1) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
20
|
if (rate === 0) {
|
|
22
21
|
return false;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
return Math.random() * rate <= 1;
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
const hasSampledFromStart = experience => {
|
|
29
26
|
if (!ufoExperiencesSampled[experience.id]) {
|
|
30
27
|
return false;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
if (experience.instanceId) {
|
|
34
30
|
// if the instance of concurrent exp has been sampled from start, allow it.
|
|
35
31
|
return ufoExperiencesSampled[experience.id].sampledInstance[experience.instanceId];
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
return ufoExperiencesSampled[experience.id].sampled;
|
|
39
34
|
};
|
|
35
|
+
|
|
40
36
|
/**
|
|
41
37
|
* This function is a temp solution to reduce the event traffic, as UFO package does not support it.
|
|
42
38
|
*
|
|
@@ -44,8 +40,6 @@ const hasSampledFromStart = experience => {
|
|
|
44
40
|
* @param ufoExperience
|
|
45
41
|
* @returns
|
|
46
42
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
43
|
export const withSampling = ufoExperience => {
|
|
50
44
|
const init = () => {
|
|
51
45
|
if (!ufoExperiencesSampled[ufoExperience.id]) {
|
|
@@ -55,91 +49,71 @@ export const withSampling = ufoExperience => {
|
|
|
55
49
|
};
|
|
56
50
|
}
|
|
57
51
|
};
|
|
58
|
-
|
|
59
52
|
const start = async options => {
|
|
60
53
|
// check if the experience has already sampled before
|
|
61
54
|
if (hasSampledFromStart(ufoExperience)) {
|
|
62
55
|
return;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
57
|
const isSampled = options.samplingFunc || isExperienceSampled;
|
|
66
|
-
|
|
67
58
|
if (!isSampled(options.samplingRate)) {
|
|
68
59
|
if (ufoExperience.instanceId) {
|
|
69
60
|
ufoExperiencesSampled[ufoExperience.id].sampledInstance[ufoExperience.instanceId] = false;
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
ufoExperiencesSampled[ufoExperience.id].sampled = false;
|
|
73
63
|
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
}
|
|
65
|
+
// update sampled records
|
|
77
66
|
if (ufoExperience.instanceId) {
|
|
78
67
|
ufoExperiencesSampled[ufoExperience.id].sampledInstance[ufoExperience.instanceId] = true;
|
|
79
68
|
ufoExperiencesSampled[ufoExperience.id].sampled = true;
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
return ufoExperience.start(options.startTime);
|
|
83
71
|
};
|
|
84
|
-
|
|
85
72
|
const success = async config => {
|
|
86
73
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
87
74
|
return null;
|
|
88
75
|
}
|
|
89
|
-
|
|
90
76
|
return ufoExperience.success(config);
|
|
91
77
|
};
|
|
92
|
-
|
|
93
78
|
const failure = async config => {
|
|
94
79
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
95
80
|
return null;
|
|
96
81
|
}
|
|
97
|
-
|
|
98
82
|
return ufoExperience.failure(config);
|
|
99
83
|
};
|
|
100
|
-
|
|
101
84
|
const abort = async config => {
|
|
102
85
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
103
86
|
return null;
|
|
104
87
|
}
|
|
105
|
-
|
|
106
88
|
return ufoExperience.abort(config);
|
|
107
89
|
};
|
|
108
|
-
|
|
109
90
|
const addMetadata = data => {
|
|
110
91
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
111
92
|
return;
|
|
112
93
|
}
|
|
113
|
-
|
|
114
94
|
return ufoExperience.addMetadata(data);
|
|
115
95
|
};
|
|
116
|
-
|
|
117
96
|
const mark = (name, timestamp) => {
|
|
118
97
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
119
98
|
return;
|
|
120
99
|
}
|
|
121
|
-
|
|
122
100
|
return ufoExperience.mark(name, timestamp);
|
|
123
101
|
};
|
|
124
|
-
|
|
125
102
|
const markFMP = timestamp => {
|
|
126
103
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
127
104
|
return;
|
|
128
105
|
}
|
|
129
|
-
|
|
130
106
|
return ufoExperience.markFMP(timestamp);
|
|
131
107
|
};
|
|
132
|
-
|
|
133
108
|
const markInlineResponse = timestamp => {
|
|
134
109
|
if (!hasSampledFromStart(ufoExperience)) {
|
|
135
110
|
return;
|
|
136
111
|
}
|
|
137
|
-
|
|
138
112
|
return ufoExperience.markInlineResponse(timestamp);
|
|
139
113
|
};
|
|
140
|
-
|
|
141
114
|
init();
|
|
142
|
-
return {
|
|
115
|
+
return {
|
|
116
|
+
...ufoExperience,
|
|
143
117
|
start,
|
|
144
118
|
addMetadata,
|
|
145
119
|
success,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UfoComponentName, UfoEmojiTimings, UfoEmojiTimingsKeys, UfoExperienceName } from '../../types';
|
|
2
2
|
import { ExperiencePerformanceTypes, ExperienceTypes, ConcurrentExperience, UFOExperience } from '@atlaskit/ufo';
|
|
3
3
|
import { withSampling } from './samplingUfo';
|
|
4
|
-
|
|
5
4
|
const createRenderExperience = componentName => {
|
|
6
5
|
return {
|
|
7
6
|
platform: {
|
|
@@ -11,7 +10,6 @@ const createRenderExperience = componentName => {
|
|
|
11
10
|
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
const createInlineExperience = componentName => {
|
|
16
14
|
return {
|
|
17
15
|
platform: {
|
|
@@ -21,7 +19,6 @@ const createInlineExperience = componentName => {
|
|
|
21
19
|
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
22
20
|
};
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
const customEmojiTimings = [{
|
|
26
23
|
key: UfoEmojiTimingsKeys.FMP,
|
|
27
24
|
endMark: UfoEmojiTimings.FMP_END
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { withSampling } from './samplingUfo';
|
|
3
|
-
|
|
4
3
|
const useConstructor = callback => {
|
|
5
4
|
const hasBeenFired = useRef(false);
|
|
6
|
-
|
|
7
5
|
if (!hasBeenFired.current) {
|
|
8
6
|
callback();
|
|
9
7
|
hasBeenFired.current = true;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
return null;
|
|
13
10
|
};
|
|
11
|
+
|
|
14
12
|
/**
|
|
15
13
|
* A hook to start an experience and to auto abort the experience when the parent component is unmounted.
|
|
16
14
|
* Use this instead of a direct call to `experience.start`. If you need to restart the experience
|
|
17
15
|
* simply trigger an unmount and remount of the parent component.
|
|
18
16
|
* @param experience the experience to start and abort
|
|
19
17
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
18
|
export const useSampledUFOComponentExperience = (experience, samplingRate, metadata) => {
|
|
23
19
|
useEffect(() => {
|
|
24
20
|
return () => {
|
|
25
21
|
withSampling(experience).abort();
|
|
26
|
-
};
|
|
22
|
+
};
|
|
23
|
+
// we want this cleanup to only happen on unmount so this is a legit use of empty array
|
|
27
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
25
|
}, []);
|
|
29
26
|
useConstructor(() => {
|
|
@@ -31,7 +28,6 @@ export const useSampledUFOComponentExperience = (experience, samplingRate, metad
|
|
|
31
28
|
samplingRate
|
|
32
29
|
});
|
|
33
30
|
const isMetadataEmpty = Object.keys(experience.metadata).length === 0;
|
|
34
|
-
|
|
35
31
|
if (metadata && isMetadataEmpty) {
|
|
36
32
|
experience.addMetadata(metadata);
|
|
37
33
|
}
|
|
@@ -5,11 +5,11 @@ export const customTitle = 'allUploadsCustomCategory';
|
|
|
5
5
|
export const userCustomTitle = 'userUploadsCustomCategory';
|
|
6
6
|
export const dataURLPrefix = 'data:';
|
|
7
7
|
export const deleteEmojiLabel = 'delete-emoji';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* A constant used in sorting/ordering to represent a number 'obviously much bigger than any item in the set being handled'.
|
|
10
11
|
* This is used instead of Number.MAX_VALUE since subtraction of MAX_VALUE from itself occassionaly doesn't equal zero exactly :-(
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
13
|
export const MAX_ORDINAL = 100000;
|
|
14
14
|
export const defaultEmojiHeight = 20;
|
|
15
15
|
export const emojiPickerWidth = 350;
|
|
@@ -26,8 +26,9 @@ export const selectedToneStorageKey = `${localStoragePrefix}.selectedTone`;
|
|
|
26
26
|
export const defaultCategories = ['PEOPLE', 'NATURE', 'FOODS', 'ACTIVITY', 'PLACES', 'OBJECTS', 'SYMBOLS', 'FLAGS'];
|
|
27
27
|
export const defaultListLimit = 50;
|
|
28
28
|
export const migrationUserId = 'hipchat_migration_emoticons';
|
|
29
|
-
export const analyticsEmojiPrefix = 'atlassian.fabric.emoji.picker';
|
|
30
|
-
|
|
31
|
-
export const SAMPLING_RATE_EMOJI_RENDERED_EXP = 20; // This rate is used in fetching emoji resource
|
|
29
|
+
export const analyticsEmojiPrefix = 'atlassian.fabric.emoji.picker';
|
|
32
30
|
|
|
31
|
+
// This is the base sampling rate in Emoji
|
|
32
|
+
export const SAMPLING_RATE_EMOJI_RENDERED_EXP = 20;
|
|
33
|
+
// This rate is used in fetching emoji resource
|
|
33
34
|
export const SAMPLING_RATE_EMOJI_RESOURCE_FETCHED_EXP = 100;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const toneEmojiShortName = ':raised_hand:';
|
|
2
|
-
|
|
3
2
|
const byShortName = (emojis, shortName) => emojis.filter(emoji => emoji.shortName === shortName)[0];
|
|
4
|
-
|
|
5
3
|
const toneEmoji = emojis => byShortName(emojis, toneEmojiShortName);
|
|
6
|
-
|
|
7
4
|
export const getToneEmoji = provider => provider.findByShortName(toneEmojiShortName);
|
|
8
5
|
export default {
|
|
9
6
|
byShortName,
|
|
@@ -15,19 +15,18 @@ export const getNaturalImageSize = dataURL => {
|
|
|
15
15
|
export const parseImage = dataURL => {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
let img = new Image();
|
|
18
|
-
|
|
19
18
|
img.onload = () => resolve({
|
|
20
19
|
src: img.src
|
|
21
20
|
});
|
|
22
|
-
|
|
23
21
|
img.onerror = () => reject();
|
|
24
|
-
|
|
25
22
|
img.src = dataURL;
|
|
26
23
|
});
|
|
27
24
|
};
|
|
28
25
|
export const hasFileExceededSize = file => {
|
|
29
26
|
return file && file.size > maxEmojiSizeInBytes;
|
|
30
|
-
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Duplicates https://bitbucket.org/atlassian/atlaskit/src/0e843df6df8bcd33fa7fc16cc63f11a0f6094957/packages/media-core/src/utils/checkWebpSupport.ts?at=master&fileviewer=file-view-default
|
|
31
30
|
// Didn't want to depend on the whole of media-core just for this util
|
|
32
31
|
|
|
33
32
|
/**
|
|
@@ -35,21 +34,17 @@ export const hasFileExceededSize = file => {
|
|
|
35
34
|
* We know that creating a new image in memory and checking its height,
|
|
36
35
|
* later on we cache this value forever.
|
|
37
36
|
*/
|
|
38
|
-
|
|
39
37
|
let isWebpSupported;
|
|
40
38
|
export const checkWebpSupport = () => {
|
|
41
39
|
if (isWebpSupported !== undefined) {
|
|
42
40
|
return Promise.resolve(isWebpSupported);
|
|
43
41
|
}
|
|
44
|
-
|
|
45
42
|
return new Promise(resolve => {
|
|
46
43
|
const img = new Image();
|
|
47
|
-
|
|
48
44
|
const checkSupport = () => {
|
|
49
45
|
isWebpSupported = img.height === 2;
|
|
50
46
|
resolve(isWebpSupported);
|
|
51
47
|
};
|
|
52
|
-
|
|
53
48
|
img.addEventListener('load', checkSupport);
|
|
54
49
|
img.addEventListener('error', checkSupport);
|
|
55
50
|
img.src = 'data:image/webp;base64,UklGRi4AAABXRUJQVlA4TCEAAAAvAUAAEB8wAiMwAgSSNtse/cXjxyCCmrYNWPwmHRH9jwMA';
|
|
@@ -3,14 +3,14 @@ export function mouseLocation(event) {
|
|
|
3
3
|
x: event.clientX,
|
|
4
4
|
y: event.clientY
|
|
5
5
|
};
|
|
6
|
-
}
|
|
7
|
-
// lastPosition is object (x, y)
|
|
6
|
+
}
|
|
8
7
|
|
|
8
|
+
// Used to prevent invalid mouse move detection on scroll
|
|
9
|
+
// lastPosition is object (x, y)
|
|
9
10
|
export function actualMouseMove(oldPosition, newPosition) {
|
|
10
11
|
if (!oldPosition || oldPosition.x !== newPosition.x || oldPosition.y !== newPosition.y) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
export function leftClick(reactEvent) {
|