2023-06-14 02:28:31 +09:00
|
|
|
// 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 = {
|
2023-07-13 18:49:16 +09:00
|
|
|
[key in NonNullable<keyof ShortCodesToEmojiData>]: {
|
2023-06-14 02:28:31 +09:00
|
|
|
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) => {
|
2024-05-27 18:24:59 +09:00
|
|
|
const emojiData = shortCodesToEmojiData[shortCode];
|
|
|
|
if (!emojiData) return;
|
|
|
|
|
|
|
|
const [_filenameData, searchData] = emojiData;
|
2023-10-24 17:06:14 +09:00
|
|
|
const [native, short_names, search, unified] = searchData;
|
2023-06-14 02:28:31 +09:00
|
|
|
|
|
|
|
emojis[shortCode] = {
|
|
|
|
native,
|
|
|
|
search,
|
2023-10-24 17:06:14 +09:00
|
|
|
short_names: short_names ? [shortCode].concat(short_names) : undefined,
|
|
|
|
unified: unified ?? unicodeToUnifiedName(native),
|
2023-06-14 02:28:31 +09:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
export { emojis, skins, categories, short_names };
|