@atlaskit/emoji 65.2.0 → 65.2.1
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/admin/package.json +8 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.0/admin.d.ts +1 -0
- package/dist/types-ts4.0/api/EmojiLoader.d.ts +13 -0
- package/dist/types-ts4.0/api/EmojiRepository.d.ts +72 -0
- package/dist/types-ts4.0/api/EmojiRepositoryRegex.d.ts +1 -0
- package/dist/types-ts4.0/api/EmojiResource.d.ts +123 -0
- package/dist/types-ts4.0/api/EmojiUtils.d.ts +24 -0
- package/dist/types-ts4.0/api/internal/Comparators.d.ts +109 -0
- package/dist/types-ts4.0/api/internal/UsageFrequencyTracker.d.ts +46 -0
- package/dist/types-ts4.0/api/media/MediaEmojiCache.d.ts +53 -0
- package/dist/types-ts4.0/api/media/MediaImageLoader.d.ts +21 -0
- package/dist/types-ts4.0/api/media/SiteEmojiResource.d.ts +46 -0
- package/dist/types-ts4.0/api/media/TokenManager.d.ts +13 -0
- package/dist/types-ts4.0/components/common/CachingEmoji.d.ts +20 -0
- package/dist/types-ts4.0/components/common/DeleteButton.d.ts +4 -0
- package/dist/types-ts4.0/components/common/Emoji.d.ts +56 -0
- package/dist/types-ts4.0/components/common/EmojiActions.d.ts +31 -0
- package/dist/types-ts4.0/components/common/EmojiButton.d.ts +12 -0
- package/dist/types-ts4.0/components/common/EmojiDeletePreview.d.ts +20 -0
- package/dist/types-ts4.0/components/common/EmojiErrorMessage.d.ts +10 -0
- package/dist/types-ts4.0/components/common/EmojiImage.d.ts +13 -0
- package/dist/types-ts4.0/components/common/EmojiPlaceholder.d.ts +11 -0
- package/dist/types-ts4.0/components/common/EmojiPreviewComponent.d.ts +7 -0
- package/dist/types-ts4.0/components/common/EmojiUploadPicker.d.ts +17 -0
- package/dist/types-ts4.0/components/common/EmojiUploadPreview.d.ts +16 -0
- package/dist/types-ts4.0/components/common/FileChooser.d.ts +11 -0
- package/dist/types-ts4.0/components/common/LoadingEmojiComponent.d.ts +32 -0
- package/dist/types-ts4.0/components/common/Popup.d.ts +12 -0
- package/dist/types-ts4.0/components/common/RecordSelectionDefault.d.ts +12 -0
- package/dist/types-ts4.0/components/common/ResourcedEmoji.d.ts +18 -0
- package/dist/types-ts4.0/components/common/ResourcedEmojiComponent.d.ts +48 -0
- package/dist/types-ts4.0/components/common/RetryableButton.d.ts +10 -0
- package/dist/types-ts4.0/components/common/Scrollable.d.ts +19 -0
- package/dist/types-ts4.0/components/common/ToneSelector.d.ts +12 -0
- package/dist/types-ts4.0/components/common/UfoErrorBoundary.d.ts +8 -0
- package/dist/types-ts4.0/components/common/UploadEmoji.d.ts +5 -0
- package/dist/types-ts4.0/components/common/internal-types.d.ts +11 -0
- package/dist/types-ts4.0/components/common/setSkinToneAriaLabelText.d.ts +1 -0
- package/dist/types-ts4.0/components/common/styles.d.ts +49 -0
- package/dist/types-ts4.0/components/hooks.d.ts +1 -0
- package/dist/types-ts4.0/components/i18n.d.ts +172 -0
- package/dist/types-ts4.0/components/picker/CategorySelector.d.ts +21 -0
- package/dist/types-ts4.0/components/picker/CategoryTracker.d.ts +17 -0
- package/dist/types-ts4.0/components/picker/EmojiPicker.d.ts +32 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerCategoryHeading.d.ts +8 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerComponent.d.ts +28 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerEmojiRow.d.ts +12 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerFooter.d.ts +7 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerList.d.ts +72 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerListSearch.d.ts +12 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerSizes.d.ts +11 -0
- package/dist/types-ts4.0/components/picker/EmojiPickerVirtualItems.d.ts +41 -0
- package/dist/types-ts4.0/components/picker/categories.d.ts +7 -0
- package/dist/types-ts4.0/components/picker/styles.d.ts +18 -0
- package/dist/types-ts4.0/components/typeahead/EmojiTypeAhead.d.ts +27 -0
- package/dist/types-ts4.0/components/typeahead/EmojiTypeAheadComponent.d.ts +72 -0
- package/dist/types-ts4.0/components/typeahead/EmojiTypeAheadItem.d.ts +14 -0
- package/dist/types-ts4.0/components/typeahead/EmojiTypeAheadList.d.ts +35 -0
- package/dist/types-ts4.0/components/typeahead/styles.d.ts +10 -0
- package/dist/types-ts4.0/components/uploader/EmojiUploadComponent.d.ts +13 -0
- package/dist/types-ts4.0/components/uploader/EmojiUploader.d.ts +20 -0
- package/dist/types-ts4.0/components/uploader/styles.d.ts +2 -0
- package/dist/types-ts4.0/context/EmojiContext.d.ts +4 -0
- package/dist/types-ts4.0/context/EmojiContextProvider.d.ts +7 -0
- package/dist/types-ts4.0/context/LegacyEmojiContextProvider.d.ts +22 -0
- package/dist/types-ts4.0/element.d.ts +3 -0
- package/dist/types-ts4.0/hooks/useEmojiContext.d.ts +1 -0
- package/dist/types-ts4.0/hooks/usePrevious.d.ts +1 -0
- package/dist/types-ts4.0/i18n/cs.d.ts +43 -0
- package/dist/types-ts4.0/i18n/da.d.ts +43 -0
- package/dist/types-ts4.0/i18n/de.d.ts +43 -0
- package/dist/types-ts4.0/i18n/en.d.ts +33 -0
- package/dist/types-ts4.0/i18n/en_GB.d.ts +33 -0
- package/dist/types-ts4.0/i18n/en_ZZ.d.ts +43 -0
- package/dist/types-ts4.0/i18n/es.d.ts +43 -0
- package/dist/types-ts4.0/i18n/et.d.ts +39 -0
- package/dist/types-ts4.0/i18n/fi.d.ts +43 -0
- package/dist/types-ts4.0/i18n/fr.d.ts +43 -0
- package/dist/types-ts4.0/i18n/hu.d.ts +43 -0
- package/dist/types-ts4.0/i18n/index.d.ts +35 -0
- package/dist/types-ts4.0/i18n/is.d.ts +33 -0
- package/dist/types-ts4.0/i18n/it.d.ts +43 -0
- package/dist/types-ts4.0/i18n/ja.d.ts +43 -0
- package/dist/types-ts4.0/i18n/ko.d.ts +43 -0
- package/dist/types-ts4.0/i18n/languages.d.ts +27 -0
- package/dist/types-ts4.0/i18n/nb.d.ts +43 -0
- package/dist/types-ts4.0/i18n/nl.d.ts +43 -0
- package/dist/types-ts4.0/i18n/pl.d.ts +43 -0
- package/dist/types-ts4.0/i18n/pt_BR.d.ts +43 -0
- package/dist/types-ts4.0/i18n/pt_PT.d.ts +39 -0
- package/dist/types-ts4.0/i18n/ro.d.ts +33 -0
- package/dist/types-ts4.0/i18n/ru.d.ts +43 -0
- package/dist/types-ts4.0/i18n/sk.d.ts +39 -0
- package/dist/types-ts4.0/i18n/sv.d.ts +43 -0
- package/dist/types-ts4.0/i18n/th.d.ts +43 -0
- package/dist/types-ts4.0/i18n/tr.d.ts +43 -0
- package/dist/types-ts4.0/i18n/uk.d.ts +43 -0
- package/dist/types-ts4.0/i18n/vi.d.ts +43 -0
- package/dist/types-ts4.0/i18n/zh.d.ts +43 -0
- package/dist/types-ts4.0/i18n/zh_TW.d.ts +43 -0
- package/dist/types-ts4.0/index.d.ts +25 -0
- package/dist/types-ts4.0/picker.d.ts +1 -0
- package/dist/types-ts4.0/resource.d.ts +5 -0
- package/dist/types-ts4.0/typeahead.d.ts +2 -0
- package/dist/types-ts4.0/types.d.ts +351 -0
- package/dist/types-ts4.0/util/DuplicateLimitedQueue.d.ts +91 -0
- package/dist/types-ts4.0/util/StoredDuplicateLimitedQueue.d.ts +46 -0
- package/dist/types-ts4.0/util/analytics/analytics.d.ts +61 -0
- package/dist/types-ts4.0/util/analytics/index.d.ts +6 -0
- package/dist/types-ts4.0/util/analytics/samplingUfo.d.ts +31 -0
- package/dist/types-ts4.0/util/analytics/ufoExperiences.d.ts +14 -0
- package/dist/types-ts4.0/util/analytics/useSampledUFOComponentExperience.d.ts +8 -0
- package/dist/types-ts4.0/util/browser-support.d.ts +1 -0
- package/dist/types-ts4.0/util/constants.d.ts +25 -0
- package/dist/types-ts4.0/util/filters.d.ts +8 -0
- package/dist/types-ts4.0/util/image.d.ts +10 -0
- package/dist/types-ts4.0/util/logger.d.ts +4 -0
- package/dist/types-ts4.0/util/mouse.d.ts +8 -0
- package/dist/types-ts4.0/util/shared-styles.d.ts +11 -0
- package/dist/types-ts4.0/util/storage-available.d.ts +3 -0
- package/dist/types-ts4.0/util/type-helpers.d.ts +23 -0
- package/dist/types-ts4.0/util/useInView.d.ts +7 -0
- package/dist/types-ts4.0/utils.d.ts +3 -0
- package/element/package.json +8 -1
- package/package.json +14 -7
- package/picker/package.json +8 -1
- package/resource/package.json +8 -1
- package/typeahead/package.json +8 -1
- package/types/package.json +8 -1
- package/utils/package.json +8 -1
package/CHANGELOG.md
CHANGED
package/admin/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/admin.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/admin.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/admin.d.ts"
|
|
7
|
+
"types": "../dist/types/admin.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/admin.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/version.json
CHANGED
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as EmojiUploader } from './components/uploader/EmojiUploader';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EmojiResponse } from '../types';
|
|
2
|
+
import { EmojiLoaderConfig } from './EmojiUtils';
|
|
3
|
+
/**
|
|
4
|
+
* Emoji providers should return JSON in the format defined by EmojiServiceResponse.
|
|
5
|
+
*/
|
|
6
|
+
export default class EmojiLoader {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: EmojiLoaderConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Returns a promise with an array of Emoji from all providers.
|
|
11
|
+
*/
|
|
12
|
+
loadEmoji(): Promise<EmojiResponse>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CategoryId } from '../components/picker/categories';
|
|
2
|
+
import { EmojiDescription, EmojiSearchResult, OptionalEmojiDescription, SearchOptions } from '../types';
|
|
3
|
+
import { UsageFrequencyTracker } from './internal/UsageFrequencyTracker';
|
|
4
|
+
export declare const getEmojiVariation: (emoji: EmojiDescription, options?: SearchOptions | undefined) => EmojiDescription;
|
|
5
|
+
export default class EmojiRepository {
|
|
6
|
+
private emojis;
|
|
7
|
+
private fullSearch;
|
|
8
|
+
private shortNameMap;
|
|
9
|
+
private idMap;
|
|
10
|
+
private asciiMap;
|
|
11
|
+
private dynamicCategoryList;
|
|
12
|
+
private static readonly defaultEmojiWeight;
|
|
13
|
+
protected usageTracker: UsageFrequencyTracker;
|
|
14
|
+
constructor(emojis: EmojiDescription[], usageTracker?: UsageFrequencyTracker);
|
|
15
|
+
/**
|
|
16
|
+
* Returns all available (and searchable) emoji in some default order.
|
|
17
|
+
*/
|
|
18
|
+
all(): EmojiSearchResult;
|
|
19
|
+
/**
|
|
20
|
+
* Text search of emoji shortName and name field for suitable matches.
|
|
21
|
+
*
|
|
22
|
+
* Returns an array of all (searchable) emoji if query is empty or null, otherwise returns matching emoji.
|
|
23
|
+
*
|
|
24
|
+
* You can change how the results are sorted by specifying a custom EmojiComparator in the SearchOptions. If
|
|
25
|
+
* you don't want any sorting you can also disable via the SearchOptions (this might be a useful optimisation).
|
|
26
|
+
* If no sort is specified in SearchOptions then a default sorting it applied based on the query.
|
|
27
|
+
*/
|
|
28
|
+
search(query?: string, options?: SearchOptions): EmojiSearchResult;
|
|
29
|
+
/**
|
|
30
|
+
* Returns all emoji with matching shortName
|
|
31
|
+
*/
|
|
32
|
+
findAllMatchingShortName(shortName: string): EmojiDescription[];
|
|
33
|
+
/**
|
|
34
|
+
* Returns the first matching emoji matching the shortName, or null if none found.
|
|
35
|
+
*/
|
|
36
|
+
findByShortName(shortName: string): OptionalEmojiDescription;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the first matching emoji matching the id, or null if none found.
|
|
39
|
+
*/
|
|
40
|
+
findById(id: string): OptionalEmojiDescription;
|
|
41
|
+
findByAsciiRepresentation(asciiEmoji: string): OptionalEmojiDescription;
|
|
42
|
+
findInCategory(categoryId: CategoryId): EmojiDescription[];
|
|
43
|
+
addUnknownEmoji(emoji: EmojiDescription): void;
|
|
44
|
+
getAsciiMap(): Map<string, EmojiDescription>;
|
|
45
|
+
/**
|
|
46
|
+
* Return the most frequently used emoji, ordered from most frequent to least frequent. Return an empty array if
|
|
47
|
+
* there are none.
|
|
48
|
+
*
|
|
49
|
+
* @param options optional settings to be applied to the set of frequently used emoji
|
|
50
|
+
*/
|
|
51
|
+
getFrequentlyUsed(options?: SearchOptions): EmojiDescription[];
|
|
52
|
+
getDynamicCategoryList(): CategoryId[];
|
|
53
|
+
/**
|
|
54
|
+
* Call this on emoji usage to allow the EmojiRepository to track the usage of emoji (which could be useful
|
|
55
|
+
* in sorting, etc).
|
|
56
|
+
*
|
|
57
|
+
* @param emoji the emoji that was just used
|
|
58
|
+
*/
|
|
59
|
+
used(emoji: EmojiDescription): void;
|
|
60
|
+
delete(emoji: EmojiDescription): void;
|
|
61
|
+
private withAsciiMatch;
|
|
62
|
+
private applySearchOptions;
|
|
63
|
+
private initMembers;
|
|
64
|
+
/**
|
|
65
|
+
* Optimisation to initialise all map member variables in single loop over emojis
|
|
66
|
+
*/
|
|
67
|
+
private initRepositoryMetadata;
|
|
68
|
+
private initSearchIndex;
|
|
69
|
+
private getAllSearchableEmojis;
|
|
70
|
+
private addToMaps;
|
|
71
|
+
private addToDynamicCategories;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tokenizerRegex: RegExp;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { AbstractResource, OnProviderChange, ServiceConfig } from '@atlaskit/util-service-support';
|
|
2
|
+
import { CategoryId } from '../components/picker/categories';
|
|
3
|
+
import { EmojiDescription, EmojiId, EmojiProvider, EmojiResponse, EmojiSearchResult, EmojiUpload, OptionalEmojiDescription, OptionalEmojiDescriptionWithVariations, OptionalUser, SearchOptions, ToneSelection, UploadingEmojiProvider, User } from '../types';
|
|
4
|
+
import EmojiRepository from './EmojiRepository';
|
|
5
|
+
import SiteEmojiResource from './media/SiteEmojiResource';
|
|
6
|
+
import { OptimisticImageApiLoaderConfig, SingleEmojiApiLoaderConfig } from './EmojiUtils';
|
|
7
|
+
export type { EmojiProvider, UploadingEmojiProvider } from '../types';
|
|
8
|
+
export interface EmojiResourceConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The service configuration for remotely recording emoji selections.
|
|
11
|
+
* A post will be performed to this URL with the EmojiId as the body.
|
|
12
|
+
*/
|
|
13
|
+
recordConfig?: ServiceConfig;
|
|
14
|
+
/**
|
|
15
|
+
* This defines the different providers. Later providers will override earlier
|
|
16
|
+
* providers when performing shortName based look up.
|
|
17
|
+
*/
|
|
18
|
+
providers: ServiceConfig[];
|
|
19
|
+
/**
|
|
20
|
+
* Must be set to true to enable upload support in the emoji components.
|
|
21
|
+
*
|
|
22
|
+
* Can be used for the restriction of the upload UI based on permissions, or feature flags.
|
|
23
|
+
*
|
|
24
|
+
* Note this also requires that other conditions are met (for example, one of the providers
|
|
25
|
+
* must support upload for the UploadingEmojiResource implementation of UploadingEmojiProvider).
|
|
26
|
+
*/
|
|
27
|
+
allowUpload?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Logged user in the Product.
|
|
30
|
+
*/
|
|
31
|
+
currentUser?: User;
|
|
32
|
+
/**
|
|
33
|
+
* This is specifically used for fetching a meta information of a single emoji.
|
|
34
|
+
* Useful for when rendering a single or a subset of emojis on a page that does not require the
|
|
35
|
+
* whole provider list to be downloaded.
|
|
36
|
+
*/
|
|
37
|
+
singleEmojiApi?: SingleEmojiApiLoaderConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Renders an image while the provider is being downloaded to reduce the time
|
|
40
|
+
* the user is being presented with a placeholder
|
|
41
|
+
*/
|
|
42
|
+
optimisticImageApi?: OptimisticImageApiLoaderConfig;
|
|
43
|
+
}
|
|
44
|
+
export interface OnEmojiProviderChange extends OnProviderChange<EmojiSearchResult, any, void> {
|
|
45
|
+
}
|
|
46
|
+
export interface Retry<T> {
|
|
47
|
+
(): Promise<T> | T;
|
|
48
|
+
}
|
|
49
|
+
export interface ResolveReject<T> {
|
|
50
|
+
resolve(result: T): void;
|
|
51
|
+
reject(reason?: any): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Checks if the emojiProvider can support uploading at a feature level.
|
|
55
|
+
*
|
|
56
|
+
* Follow this up with an isUploadSupported() check to see if the provider is actually
|
|
57
|
+
* configured to support uploads.
|
|
58
|
+
* https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
|
|
59
|
+
*/
|
|
60
|
+
export declare const supportsUploadFeature: (emojiProvider: EmojiProvider) => emojiProvider is UploadingEmojiProvider;
|
|
61
|
+
export interface LastQuery {
|
|
62
|
+
query?: string;
|
|
63
|
+
options?: SearchOptions;
|
|
64
|
+
}
|
|
65
|
+
export declare class EmojiResource extends AbstractResource<string, EmojiSearchResult, any, undefined, SearchOptions> implements EmojiProvider {
|
|
66
|
+
protected recordConfig?: ServiceConfig;
|
|
67
|
+
protected emojiRepository?: EmojiRepository;
|
|
68
|
+
protected lastQuery?: LastQuery;
|
|
69
|
+
protected activeLoaders: number;
|
|
70
|
+
protected retries: Map<Retry<any>, ResolveReject<any>>;
|
|
71
|
+
protected siteEmojiResource?: SiteEmojiResource;
|
|
72
|
+
protected selectedTone: ToneSelection;
|
|
73
|
+
protected currentUser?: User;
|
|
74
|
+
protected isInitialised: boolean;
|
|
75
|
+
emojiProviderConfig: EmojiResourceConfig;
|
|
76
|
+
constructor(config: EmojiResourceConfig);
|
|
77
|
+
fetchEmojiProvider(force?: boolean): Promise<EmojiRepository | undefined>;
|
|
78
|
+
fetchByEmojiId(emojiId: EmojiId, optimistic: boolean): Promise<OptionalEmojiDescriptionWithVariations>;
|
|
79
|
+
private getProviderType;
|
|
80
|
+
protected initEmojiRepository(emojiResponses: EmojiResponse[]): void;
|
|
81
|
+
protected initSiteEmojiResource(emojiResponse: EmojiResponse, provider: ServiceConfig): Promise<void>;
|
|
82
|
+
private performRetries;
|
|
83
|
+
getOptimisticImageURL: (emojiId: EmojiId) => string | undefined;
|
|
84
|
+
private loadStoredTone;
|
|
85
|
+
protected refreshLastFilter(): void;
|
|
86
|
+
protected isLoaded: () => false | EmojiRepository | undefined;
|
|
87
|
+
protected retryIfLoading<T>(retry: Retry<T>, defaultResponse: T): Promise<T>;
|
|
88
|
+
protected notifyResult(result: EmojiSearchResult): void;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the EmojiDescription with a valid media path that includes query token and client attributes to access the emoji media inline.
|
|
91
|
+
*/
|
|
92
|
+
getMediaEmojiDescriptionURLWithInlineToken(emoji: EmojiDescription): Promise<EmojiDescription>;
|
|
93
|
+
loadMediaEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
94
|
+
optimisticMediaRendering(emoji: EmojiDescription, useAlt?: boolean): boolean;
|
|
95
|
+
filter(query?: string, options?: SearchOptions): void;
|
|
96
|
+
findByShortName(shortName: string): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
97
|
+
findByEmojiId(emojiId: EmojiId): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
98
|
+
findById(id: string): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
99
|
+
findInCategory(categoryId: CategoryId): Promise<EmojiDescription[]>;
|
|
100
|
+
getAsciiMap(): Promise<Map<string, EmojiDescription>>;
|
|
101
|
+
getFrequentlyUsed(options?: SearchOptions): Promise<EmojiDescription[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Record the selection of an emoji to a remote service if 'recordConfig' has been supplied.
|
|
104
|
+
* Regardless of the recordConfig, emoji selections will always be recorded on the EmojiRepository
|
|
105
|
+
* for the purposes of tracking the frequency of use.
|
|
106
|
+
*
|
|
107
|
+
* @param emoji The full description of the emoji to record usage for.
|
|
108
|
+
*/
|
|
109
|
+
recordSelection(emoji: EmojiDescription): Promise<any>;
|
|
110
|
+
deleteSiteEmoji(emoji: EmojiDescription): Promise<boolean>;
|
|
111
|
+
getSelectedTone(): ToneSelection;
|
|
112
|
+
setSelectedTone(tone: ToneSelection): void;
|
|
113
|
+
calculateDynamicCategories(): Promise<CategoryId[]>;
|
|
114
|
+
getCurrentUser(): OptionalUser;
|
|
115
|
+
protected addUnknownEmoji(emoji: EmojiDescription): void;
|
|
116
|
+
}
|
|
117
|
+
export default class UploadingEmojiResource extends EmojiResource implements UploadingEmojiProvider {
|
|
118
|
+
protected allowUpload: boolean;
|
|
119
|
+
constructor(config: EmojiResourceConfig);
|
|
120
|
+
isUploadSupported(): Promise<boolean>;
|
|
121
|
+
uploadCustomEmoji(upload: EmojiUpload, retry?: boolean): Promise<EmojiDescription>;
|
|
122
|
+
prepareForUpload(): Promise<void>;
|
|
123
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestServiceOptions, ServiceConfig } from '@atlaskit/util-service-support';
|
|
2
|
+
import { AltRepresentations, EmojiDescription, EmojiDescriptionWithVariations, EmojiMeta, EmojiRepresentation, EmojiResponse, EmojiServiceDescriptionWithVariations, EmojiServiceRepresentation, EmojiServiceResponse, EmojiId } from '../types';
|
|
3
|
+
export interface EmojiLoaderConfig extends ServiceConfig {
|
|
4
|
+
getRatio?: () => number;
|
|
5
|
+
}
|
|
6
|
+
export interface SingleEmojiApiLoaderConfig extends ServiceConfig {
|
|
7
|
+
getUrl: (emojiId: EmojiId) => string;
|
|
8
|
+
}
|
|
9
|
+
export interface OptimisticImageApiLoaderConfig extends ServiceConfig {
|
|
10
|
+
getUrl: (emojiId: EmojiId) => string;
|
|
11
|
+
}
|
|
12
|
+
export declare const emojiRequest: (provider: EmojiLoaderConfig, options?: RequestServiceOptions | undefined) => Promise<EmojiServiceResponse>;
|
|
13
|
+
export declare const getPixelRatio: () => number;
|
|
14
|
+
export declare const getAltRepresentation: (reps: AltRepresentations) => EmojiServiceRepresentation;
|
|
15
|
+
export declare const isMediaApiUrl: (url: string, meta?: EmojiMeta | undefined) => boolean;
|
|
16
|
+
export declare const denormaliseServiceRepresentation: (representation: EmojiServiceRepresentation, meta?: EmojiMeta | undefined) => EmojiRepresentation;
|
|
17
|
+
export declare const denormaliseServiceAltRepresentation: (altReps?: AltRepresentations | undefined, meta?: EmojiMeta | undefined) => EmojiRepresentation;
|
|
18
|
+
export declare const denormaliseSkinEmoji: (emoji: EmojiServiceDescriptionWithVariations, meta?: EmojiMeta | undefined) => EmojiDescriptionWithVariations[];
|
|
19
|
+
/**
|
|
20
|
+
* Denormalised an emoji response (emojis + sprite references) into an array of
|
|
21
|
+
* emoji with local sprite definitions.
|
|
22
|
+
*/
|
|
23
|
+
export declare const denormaliseEmojiServiceResponse: (emojiData: EmojiServiceResponse) => EmojiResponse;
|
|
24
|
+
export declare const shouldUseAltRepresentation: (emoji: EmojiDescription, fitToHeight?: number | undefined) => boolean;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { EmojiDescription } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Create the default sort comparator to be used for the user queries against emoji
|
|
4
|
+
*
|
|
5
|
+
* @param query the query used in the search to be sorted. Any colons will be stripped from the query and it will be
|
|
6
|
+
* converted to lowercase.
|
|
7
|
+
* @param orderedIds the id of emoji ordered by how frequently they are used
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSearchEmojiComparator(query?: string, orderedIds?: Array<string>): EmojiComparator;
|
|
10
|
+
export declare function createUsageOnlyEmojiComparator(orderedIds: Array<string>): EmojiComparator;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a number representing the result of comparing e1 and e2.
|
|
13
|
+
* Compatible with Array.sort, which is to say -
|
|
14
|
+
* - less than 0 if e1 should come first
|
|
15
|
+
* - 0 if they are equal; e1 and e2 will be unchanged in position relative to each other
|
|
16
|
+
* - greater than 0 if e2 should come first.
|
|
17
|
+
*/
|
|
18
|
+
export interface EmojiComparator {
|
|
19
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A combinator comparator that applies an ordered chained of sub-comparators. The first comparator that
|
|
23
|
+
* returns a non-zero value stops the chain and causes that value to be returned. If a comparator returns a
|
|
24
|
+
* zero then the next one in the chain is tried.
|
|
25
|
+
*
|
|
26
|
+
* If no comparators in the chain return a non-zero value then zero will be returned.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ChainedEmojiComparator implements EmojiComparator {
|
|
29
|
+
private chain;
|
|
30
|
+
constructor(...comparators: EmojiComparator[]);
|
|
31
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Orders two emoji such that if one of them has an ascii representation that exactly matches the query then it will
|
|
35
|
+
* be ordered first.
|
|
36
|
+
*/
|
|
37
|
+
export declare class AsciiMatchComparator implements EmojiComparator {
|
|
38
|
+
private query;
|
|
39
|
+
constructor(query: string);
|
|
40
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): 0 | 1 | -1;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Orders two emoji such that the one who's shortname matches the query exactly comes first. If there are matching
|
|
44
|
+
* shortnames then the type of emoji is taken into account with SITE emoji coming first.
|
|
45
|
+
*/
|
|
46
|
+
export declare class ExactShortNameMatchComparator implements EmojiComparator {
|
|
47
|
+
private colonQuery;
|
|
48
|
+
private typeComparator;
|
|
49
|
+
constructor(query: string);
|
|
50
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Orders two emoji based on their type, with the types being STANDARD, ATLASSIAN and SITE (in that order).
|
|
54
|
+
* If the comparator is configured to 'reverse' then the order will be SITE, ATLASSIAN, STANDARD.
|
|
55
|
+
*
|
|
56
|
+
* Regardless of the reverse setting, an unknown type will always come last.
|
|
57
|
+
*/
|
|
58
|
+
export declare class EmojiTypeComparator implements EmojiComparator {
|
|
59
|
+
private typeToNumber;
|
|
60
|
+
constructor(reverse?: boolean);
|
|
61
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
62
|
+
private emojiTypeToOrdinal;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Order two emoji such as the one which is more frequently used comes first. If neither have any usage
|
|
66
|
+
* information then leave their order unchanged.
|
|
67
|
+
*/
|
|
68
|
+
export declare class UsageFrequencyComparator implements EmojiComparator {
|
|
69
|
+
private positionLookup;
|
|
70
|
+
constructor(orderedIds: Array<string>);
|
|
71
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
72
|
+
/**
|
|
73
|
+
* Get the ordinal representing the position of this emoji.
|
|
74
|
+
*
|
|
75
|
+
* @param id the id of the emoji
|
|
76
|
+
*/
|
|
77
|
+
private getPositionInOrder;
|
|
78
|
+
}
|
|
79
|
+
declare type KeysOfType<T, TProp> = {
|
|
80
|
+
[P in keyof T]: T[P] extends TProp | undefined ? P : never;
|
|
81
|
+
}[keyof T];
|
|
82
|
+
/**
|
|
83
|
+
* A comparator that will sort higher an emoji which matches the query string earliest in the indicated
|
|
84
|
+
* property.
|
|
85
|
+
*/
|
|
86
|
+
export declare class QueryStringPositionMatchComparator implements EmojiComparator {
|
|
87
|
+
private readonly propertyName;
|
|
88
|
+
private query;
|
|
89
|
+
/**
|
|
90
|
+
* @param query the query to match
|
|
91
|
+
* @param propertyToCompare the property of EmojiDescription to check for query within
|
|
92
|
+
*/
|
|
93
|
+
constructor(query: string, propertyToCompare: KeysOfType<EmojiDescription, string>);
|
|
94
|
+
private getScore;
|
|
95
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
96
|
+
}
|
|
97
|
+
export declare class OrderComparator implements EmojiComparator {
|
|
98
|
+
private static INSTANCE;
|
|
99
|
+
private constructor();
|
|
100
|
+
static get Instance(): OrderComparator;
|
|
101
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
102
|
+
}
|
|
103
|
+
export declare class AlphabeticalShortnameComparator implements EmojiComparator {
|
|
104
|
+
private static INSTANCE;
|
|
105
|
+
private constructor();
|
|
106
|
+
static get Instance(): AlphabeticalShortnameComparator;
|
|
107
|
+
compare(e1: EmojiDescription, e2: EmojiDescription): number;
|
|
108
|
+
}
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EmojiDescription } from '../../types';
|
|
2
|
+
import DuplicateLimitedQueue from '../../util/DuplicateLimitedQueue';
|
|
3
|
+
/**
|
|
4
|
+
* Keeps track of the last 150 emoji usages, although limiting the maximum count for a single emoji to 25 to
|
|
5
|
+
* ensure we don't end up with only a single emoji being recorded. Usage is persisted to local storage for
|
|
6
|
+
* consistency between 'sessions'.
|
|
7
|
+
*
|
|
8
|
+
* Skin tone variations for an emoji will be 'collapsed' so they are tracked as their base emoji. Gender
|
|
9
|
+
* variations are not collapsed in this way and will be tracked per gender. This decision reflects the UI of
|
|
10
|
+
* the EmojiPicker component.
|
|
11
|
+
*/
|
|
12
|
+
export declare class UsageFrequencyTracker {
|
|
13
|
+
private static readonly queueOptions;
|
|
14
|
+
protected queue: DuplicateLimitedQueue<string>;
|
|
15
|
+
private gateway;
|
|
16
|
+
constructor(useStorageIfPossible?: boolean);
|
|
17
|
+
/**
|
|
18
|
+
* Record the fact that the supplied emoji was used. You should note that usage is updated asynchronously so you can not
|
|
19
|
+
* count on getOrder() reflecting this usage immediately.
|
|
20
|
+
*
|
|
21
|
+
* @param emoji the emoji who's usage is to be recorded. If the emoji has no id then no usage will be recorded
|
|
22
|
+
*/
|
|
23
|
+
recordUsage(emoji: EmojiDescription): void;
|
|
24
|
+
/**
|
|
25
|
+
* Returns an array of emoji id (without skin tone variations) sorted by most used to least used. If there
|
|
26
|
+
* are no usages then an empty array will be returned.
|
|
27
|
+
*/
|
|
28
|
+
getOrder(): Array<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Exposed for testing only. Clear any recorded usage.
|
|
31
|
+
*/
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare class Gateway {
|
|
35
|
+
private maximumPermitted;
|
|
36
|
+
private count;
|
|
37
|
+
constructor(maximumPermitted: number);
|
|
38
|
+
/**
|
|
39
|
+
* Run the supplied function if the count of already submitted work allows it. Drop the work
|
|
40
|
+
* if it's not allowed to run.
|
|
41
|
+
*
|
|
42
|
+
* Will return true if the function has been submitted or false if it was not submitted.
|
|
43
|
+
*/
|
|
44
|
+
submit(f: () => void): boolean;
|
|
45
|
+
private completed;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EmojiDescription, OptionalEmojiDescription } from '../../types';
|
|
2
|
+
import MediaImageLoader from './MediaImageLoader';
|
|
3
|
+
import TokenManager from './TokenManager';
|
|
4
|
+
export interface EmojiCacheStrategy {
|
|
5
|
+
loadEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
6
|
+
optimisticRendering(): boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* For browsers that support caching for resources
|
|
10
|
+
* regardless of originally supplied headers (basically everything but Firefox).
|
|
11
|
+
*/
|
|
12
|
+
export declare class BrowserCacheStrategy implements EmojiCacheStrategy {
|
|
13
|
+
private cachedImageUrls;
|
|
14
|
+
private mediaImageLoader;
|
|
15
|
+
constructor(mediaImageLoader: MediaImageLoader);
|
|
16
|
+
loadEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
17
|
+
optimisticRendering(): boolean;
|
|
18
|
+
static supported(mediaPath: string, mediaImageLoader: MediaImageLoader): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* For browsers that do no cache images without equivalent headers (e.g. Firefox).
|
|
22
|
+
*
|
|
23
|
+
* Images are cached in memory in a LRU cache. Images considered too large,
|
|
24
|
+
* are not cached, but retrieved each time.
|
|
25
|
+
*
|
|
26
|
+
* Images are still cached by the browser, but loading in asynchronous with
|
|
27
|
+
* small delay noticable to the end user.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MemoryCacheStrategy implements EmojiCacheStrategy {
|
|
30
|
+
private dataURLCache;
|
|
31
|
+
private mediaImageLoader;
|
|
32
|
+
constructor(mediaImageLoader: MediaImageLoader);
|
|
33
|
+
loadEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
34
|
+
optimisticRendering(): boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Provides a cache for Media Emoji.
|
|
38
|
+
*
|
|
39
|
+
* Emoji are returned immediately if cached and ready to use by the browser.
|
|
40
|
+
*
|
|
41
|
+
* Otherwise, they are loaded and returned via a promise.
|
|
42
|
+
*/
|
|
43
|
+
export default class MediaEmojiCache {
|
|
44
|
+
protected cache?: EmojiCacheStrategy;
|
|
45
|
+
protected waitingInitUrls: string[];
|
|
46
|
+
private cacheLoading;
|
|
47
|
+
private mediaImageLoader;
|
|
48
|
+
constructor(tokenManager: TokenManager);
|
|
49
|
+
loadEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
50
|
+
optimisticRendering(url: string): boolean | Promise<boolean>;
|
|
51
|
+
protected getCache(url: string): EmojiCacheStrategy | Promise<EmojiCacheStrategy>;
|
|
52
|
+
private initCache;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TokenManager from './TokenManager';
|
|
2
|
+
export declare type DataURL = string;
|
|
3
|
+
export interface MediaImageLoaderOptions {
|
|
4
|
+
concurrentDownloadLimit: number;
|
|
5
|
+
}
|
|
6
|
+
export default class MediaImageLoader {
|
|
7
|
+
private tokenManager;
|
|
8
|
+
private mediaImageQueue;
|
|
9
|
+
private activeProcessing;
|
|
10
|
+
private concurrentDownloadLimit;
|
|
11
|
+
private pendingRequests;
|
|
12
|
+
constructor(tokenManager: TokenManager, options?: MediaImageLoaderOptions);
|
|
13
|
+
loadMediaImage(url: string): Promise<DataURL>;
|
|
14
|
+
getQueueSize(): number;
|
|
15
|
+
getActiveDownloads(): number;
|
|
16
|
+
private processFromQueue;
|
|
17
|
+
private completedItem;
|
|
18
|
+
private delay;
|
|
19
|
+
private requestMediaEmoji;
|
|
20
|
+
private readBlob;
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ServiceConfig } from '@atlaskit/util-service-support';
|
|
2
|
+
import { EmojiDescription, EmojiId, EmojiServiceDescription, EmojiUpload, MediaApiToken, OptionalEmojiDescription } from '../../types';
|
|
3
|
+
import TokenManager from './TokenManager';
|
|
4
|
+
export interface EmojiUploadResponse {
|
|
5
|
+
emojis: EmojiServiceDescription[];
|
|
6
|
+
}
|
|
7
|
+
export interface EmojiProgress {
|
|
8
|
+
readonly percent: number;
|
|
9
|
+
}
|
|
10
|
+
export interface EmojiProgessCallback {
|
|
11
|
+
(progress: EmojiProgress): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const mediaProportionOfProgress: number;
|
|
14
|
+
export default class SiteEmojiResource {
|
|
15
|
+
private siteServiceConfig;
|
|
16
|
+
private mediaApiToken;
|
|
17
|
+
private mediaEmojiCache;
|
|
18
|
+
protected tokenManager: TokenManager;
|
|
19
|
+
constructor(siteServiceConfig: ServiceConfig, mediaApiToken: MediaApiToken);
|
|
20
|
+
/**
|
|
21
|
+
* Will generate an emoji media path that is inclusive of client and token within the query parameter
|
|
22
|
+
*/
|
|
23
|
+
generateTokenisedMediaURL(emoji: EmojiDescription): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Will load media emoji, returning a new EmojiDescription if, for example,
|
|
26
|
+
* the URL has changed.
|
|
27
|
+
*/
|
|
28
|
+
loadMediaEmoji(emoji: EmojiDescription, useAlt?: boolean): OptionalEmojiDescription | Promise<OptionalEmojiDescription>;
|
|
29
|
+
optimisticRendering(emoji: EmojiDescription, useAlt?: boolean): boolean | Promise<boolean>;
|
|
30
|
+
uploadEmoji(upload: EmojiUpload, retry?: boolean, progressCallback?: EmojiProgessCallback): Promise<EmojiDescription>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if the MediaEmojiResource has been able to initialise an uploadToken. Retrieving an upload token
|
|
33
|
+
* is asynchronous so the Promise will need to resolve before the state is known. If the token retrieval
|
|
34
|
+
* completes with failure then the Promise will resolve to false.
|
|
35
|
+
*/
|
|
36
|
+
hasUploadToken(): Promise<boolean>;
|
|
37
|
+
prepareForUpload(): void;
|
|
38
|
+
findEmoji(emojiId: EmojiId): Promise<OptionalEmojiDescription>;
|
|
39
|
+
/**
|
|
40
|
+
* Calls to site-scoped EmojiResource to delete emoji
|
|
41
|
+
* @param emoji media emoji to delete
|
|
42
|
+
* @returns Promise.resolve() if success and Promise.reject() for failure
|
|
43
|
+
*/
|
|
44
|
+
deleteEmoji(emoji: EmojiDescription): Promise<boolean>;
|
|
45
|
+
private postToEmojiService;
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MediaApiToken } from '../../types';
|
|
2
|
+
import { ServiceConfig } from '@atlaskit/util-service-support';
|
|
3
|
+
export declare const EXPIRES_AT_LATENCY_IN_SECONDS = 30;
|
|
4
|
+
export declare type TokenType = 'read' | 'upload';
|
|
5
|
+
export default class TokenManager {
|
|
6
|
+
private siteServiceConfig;
|
|
7
|
+
private tokens;
|
|
8
|
+
constructor(siteServiceConfig: ServiceConfig);
|
|
9
|
+
isValidToken(mediaApiToken: MediaApiToken): boolean;
|
|
10
|
+
fetchNewToken(type: TokenType): Promise<MediaApiToken>;
|
|
11
|
+
addToken(type: TokenType, mediaApiToken: MediaApiToken): void;
|
|
12
|
+
getToken(type: TokenType, forceRefresh?: boolean): Promise<MediaApiToken>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { EmojiDescription } from '../../types';
|
|
3
|
+
import { Props as EmojiProps } from './Emoji';
|
|
4
|
+
export interface State {
|
|
5
|
+
cachedEmoji?: EmojiDescription;
|
|
6
|
+
invalidImage?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CachingEmojiProps extends EmojiProps {
|
|
9
|
+
placeholderSize?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Renders an emoji from a cached image, if required.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CachingEmoji: FC<CachingEmojiProps>;
|
|
15
|
+
/**
|
|
16
|
+
* Rendering a media emoji image from a cache for media emoji, with different
|
|
17
|
+
* rendering paths depending on caching strategy.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CachingMediaEmoji: FC<CachingEmojiProps>;
|
|
20
|
+
export default CachingEmoji;
|