1
0
REI-Fixed/app/javascript/mastodon/features/emoji/emoji_mart_data_light.ts
たいち ひ 9482810703
Rewrite emoji_unicode_mapping_light to TS (#25444)
Co-authored-by: taichi.fukuda ひ <taichi.fukuda@systemi.co.jp>
2023-10-24 08:06:14 +00:00

44 lines
1.2 KiB
TypeScript

// The output of this module is designed to mimic emoji-mart's
// "data" object, such that we can use it for a light version of emoji-mart's
// emojiIndex.search functionality.
import type { BaseEmoji } from 'emoji-mart';
import type { Emoji } from 'emoji-mart/dist-es/utils/data';
import type { Search, ShortCodesToEmojiData } from './emoji_compressed';
import emojiCompressed from './emoji_compressed';
import { unicodeToUnifiedName } from './unicode_to_unified_name';
type Emojis = {
[key in NonNullable<keyof ShortCodesToEmojiData>]: {
native: BaseEmoji['native'];
search: Search;
short_names: Emoji['short_names'];
unified: Emoji['unified'];
};
};
const [
shortCodesToEmojiData,
skins,
categories,
short_names,
_emojisWithoutShortCodes,
] = emojiCompressed;
const emojis: Emojis = {};
// decompress
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
const [_filenameData, searchData] = shortCodesToEmojiData[shortCode];
const [native, short_names, search, unified] = searchData;
emojis[shortCode] = {
native,
search,
short_names: short_names ? [shortCode].concat(short_names) : undefined,
unified: unified ?? unicodeToUnifiedName(native),
};
});
export { emojis, skins, categories, short_names };