|
|
@ -7,30 +7,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
const { unicodeToFilename } = require('./unicode_to_filename');
|
|
|
|
const { unicodeToFilename } = require('./unicode_to_filename');
|
|
|
|
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
|
|
|
|
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
|
|
|
|
const emojiMap = require('./emoji_map.json');
|
|
|
|
const emojiMap = require('./emoji_map.json');
|
|
|
|
const { emojiIndex } = require('emoji-mart');
|
|
|
|
const { emojiIndex } = require('emoji-mart');
|
|
|
|
const { uncompress: emojiMartUncompress } = require('emoji-mart/dist/utils/data');
|
|
|
|
const { uncompress: emojiMartUncompress } = require('emoji-mart/dist/utils/data');
|
|
|
|
|
|
|
|
|
|
|
|
let data = require('emoji-mart/data/all.json');
|
|
|
|
let data = require('emoji-mart/data/all.json');
|
|
|
|
|
|
|
|
|
|
|
|
if(data.compressed) {
|
|
|
|
if(data.compressed) {
|
|
|
|
data = emojiMartUncompress(data);
|
|
|
|
data = emojiMartUncompress(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const emojiMartData = data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const emojiMartData = data;
|
|
|
|
|
|
|
|
|
|
|
|
const excluded = ['®', '©', '™'];
|
|
|
|
const excluded = ['®', '©', '™'];
|
|
|
|
const skins = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
|
|
|
const skinTones = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
|
|
|
const shortcodeMap = {};
|
|
|
|
const shortcodeMap = {};
|
|
|
|
|
|
|
|
|
|
|
|
const shortCodesToEmojiData = {};
|
|
|
|
const shortCodesToEmojiData = {};
|
|
|
|
const emojisWithoutShortCodes = [];
|
|
|
|
const emojisWithoutShortCodes = [];
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
shortcodeMap[emojiIndex.emojis[key].native] = emojiIndex.emojis[key].id;
|
|
|
|
let emoji = emojiIndex.emojis[key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Emojis with skin tone modifiers are stored like this
|
|
|
|
|
|
|
|
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
|
|
|
|
|
|
|
|
emoji = emoji['1'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shortcodeMap[emoji.native] = emoji.id;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const stripModifiers = unicode => {
|
|
|
|
const stripModifiers = unicode => {
|
|
|
|
skins.forEach(tone => {
|
|
|
|
skinTones.forEach(tone => {
|
|
|
|
unicode = unicode.replace(tone, '');
|
|
|
|
unicode = unicode.replace(tone, '');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -65,13 +73,22 @@ Object.keys(emojiMap).forEach(key => {
|
|
|
|
if (!Array.isArray(shortCodesToEmojiData[shortcode])) {
|
|
|
|
if (!Array.isArray(shortCodesToEmojiData[shortcode])) {
|
|
|
|
shortCodesToEmojiData[shortcode] = [[]];
|
|
|
|
shortCodesToEmojiData[shortcode] = [[]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
shortCodesToEmojiData[shortcode][0].push(filenameData);
|
|
|
|
shortCodesToEmojiData[shortcode][0].push(filenameData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
const { native } = emojiIndex.emojis[key];
|
|
|
|
let emoji = emojiIndex.emojis[key];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Emojis with skin tone modifiers are stored like this
|
|
|
|
|
|
|
|
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
|
|
|
|
|
|
|
|
emoji = emoji['1'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { native } = emoji;
|
|
|
|
let { short_names, search, unified } = emojiMartData.emojis[key];
|
|
|
|
let { short_names, search, unified } = emojiMartData.emojis[key];
|
|
|
|
|
|
|
|
|
|
|
|
if (short_names[0] !== key) {
|
|
|
|
if (short_names[0] !== key) {
|
|
|
|
throw new Error('The compresser expects the first short_code to be the ' +
|
|
|
|
throw new Error('The compresser expects the first short_code to be the ' +
|
|
|
|
'key. It may need to be rewritten if the emoji change such that this ' +
|
|
|
|
'key. It may need to be rewritten if the emoji change such that this ' +
|
|
|
@ -81,11 +98,16 @@ Object.keys(emojiIndex.emojis).forEach(key => {
|
|
|
|
short_names = short_names.slice(1); // first short name can be inferred from the key
|
|
|
|
short_names = short_names.slice(1); // first short name can be inferred from the key
|
|
|
|
|
|
|
|
|
|
|
|
const searchData = [native, short_names, search];
|
|
|
|
const searchData = [native, short_names, search];
|
|
|
|
|
|
|
|
|
|
|
|
if (unicodeToUnifiedName(native) !== unified) {
|
|
|
|
if (unicodeToUnifiedName(native) !== unified) {
|
|
|
|
// unified name can't be derived from unicodeToUnifiedName
|
|
|
|
// unified name can't be derived from unicodeToUnifiedName
|
|
|
|
searchData.push(unified);
|
|
|
|
searchData.push(unified);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Array.isArray(shortCodesToEmojiData[key])) {
|
|
|
|
|
|
|
|
shortCodesToEmojiData[key] = [[]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
shortCodesToEmojiData[key].push(searchData);
|
|
|
|
shortCodesToEmojiData[key].push(searchData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|