diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx index 2bd6af4cf4..e2c32dcdb9 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx @@ -12,7 +12,7 @@ import Overlay from 'react-overlays/Overlay'; import MoodIcon from '@/material-icons/400-20px/mood.svg?react'; import { IconButton } from 'mastodon/components/icon_button'; -import emojiCompressed from 'mastodon/features/emoji/emoji_compressed'; +import emojiCompressed from '@/mastodon/features/emoji/emoji_compressed.mjs'; import { assetHost } from 'mastodon/utils/config'; import { buildCustomEmojis, categoriesFromEmojis } from '../../emoji/emoji'; diff --git a/app/javascript/mastodon/features/emoji/emoji_compressed.d.ts b/app/javascript/mastodon/features/emoji/emoji_compressed.d.mts similarity index 100% rename from app/javascript/mastodon/features/emoji/emoji_compressed.d.ts rename to app/javascript/mastodon/features/emoji/emoji_compressed.d.mts diff --git a/app/javascript/mastodon/features/emoji/emoji_compressed.js b/app/javascript/mastodon/features/emoji/emoji_compressed.mjs similarity index 66% rename from app/javascript/mastodon/features/emoji/emoji_compressed.js rename to app/javascript/mastodon/features/emoji/emoji_compressed.mjs index a137b370f2..2fe3d5fe6f 100644 --- a/app/javascript/mastodon/features/emoji/emoji_compressed.js +++ b/app/javascript/mastodon/features/emoji/emoji_compressed.mjs @@ -22,14 +22,14 @@ emojiMartUncompress(data); const emojiMartData = data; const emojiIndex = new NimbleEmojiIndex(emojiMartData); -const excluded = ['®', '©', '™']; -const skinTones = ['🏻', '🏼', '🏽', '🏾', '🏿']; -const shortcodeMap = {}; +const excluded = ['®', '©', '™']; +const skinTones = ['🏻', '🏼', '🏽', '🏾', '🏿']; +const shortcodeMap = {}; const shortCodesToEmojiData = {}; const emojisWithoutShortCodes = []; -Object.keys(emojiIndex.emojis).forEach(key => { +Object.keys(emojiIndex.emojis).forEach((key) => { let emoji = emojiIndex.emojis[key]; // Emojis with skin tone modifiers are stored like this @@ -40,22 +40,22 @@ Object.keys(emojiIndex.emojis).forEach(key => { shortcodeMap[emoji.native] = emoji.id; }); -const stripModifiers = unicode => { - skinTones.forEach(tone => { +const stripModifiers = (unicode) => { + skinTones.forEach((tone) => { unicode = unicode.replace(tone, ''); }); return unicode; }; -Object.keys(emojiMap).forEach(key => { +Object.keys(emojiMap).forEach((key) => { if (excluded.includes(key)) { delete emojiMap[key]; return; } const normalizedKey = stripModifiers(key); - let shortcode = shortcodeMap[normalizedKey]; + let shortcode = shortcodeMap[normalizedKey]; if (!shortcode) { shortcode = shortcodeMap[normalizedKey + '\uFE0F']; @@ -81,7 +81,7 @@ Object.keys(emojiMap).forEach(key => { } }); -Object.keys(emojiIndex.emojis).forEach(key => { +Object.keys(emojiIndex.emojis).forEach((key) => { let emoji = emojiIndex.emojis[key]; // Emojis with skin tone modifiers are stored like this @@ -93,9 +93,11 @@ Object.keys(emojiIndex.emojis).forEach(key => { let { short_names, search, unified } = emojiMartData.emojis[key]; if (short_names[0] !== key) { - throw new Error('The compressor expects the first short_code to be the ' + - 'key. It may need to be rewritten if the emoji change such that this ' + - 'is no longer the case.'); + throw new Error( + 'The compressor expects the first short_code to be the ' + + 'key. It may need to be rewritten if the emoji change such that this ' + + 'is no longer the case.', + ); } short_names = short_names.slice(1); // first short name can be inferred from the key @@ -116,21 +118,23 @@ Object.keys(emojiIndex.emojis).forEach(key => { // JSON.parse/stringify is to emulate what @preval is doing and avoid any // inconsistent behavior in dev mode -export default JSON.parse(JSON.stringify([ - shortCodesToEmojiData, - /* - * The property `skins` is not found in the current context. - * This could potentially lead to issues when interacting with modules or data structures - * that expect the presence of `skins` property. - * Currently, no definitions or references to `skins` property can be found in: - * - {@link node_modules/emoji-mart/dist/utils/data.js} - * - {@link node_modules/emoji-mart/data/all.json} - * - {@link app/javascript/mastodon/features/emoji/emoji_compressed.d.ts#Skins} - * Future refactorings or updates should consider adding definitions or handling for `skins` property. - */ - emojiMartData.skins, - emojiMartData.categories, - emojiMartData.aliases, - emojisWithoutShortCodes, - emojiMartData -])); +export default JSON.parse( + JSON.stringify([ + shortCodesToEmojiData, + /* + * The property `skins` is not found in the current context. + * This could potentially lead to issues when interacting with modules or data structures + * that expect the presence of `skins` property. + * Currently, no definitions or references to `skins` property can be found in: + * - {@link node_modules/emoji-mart/dist/utils/data.js} + * - {@link node_modules/emoji-mart/data/all.json} + * - {@link app/javascript/mastodon/features/emoji/emoji_compressed.d.ts#Skins} + * Future refactorings or updates should consider adding definitions or handling for `skins` property. + */ + emojiMartData.skins, + emojiMartData.categories, + emojiMartData.aliases, + emojisWithoutShortCodes, + emojiMartData, + ]), +); diff --git a/app/javascript/mastodon/features/emoji/emoji_mart_data_light.ts b/app/javascript/mastodon/features/emoji/emoji_mart_data_light.ts index 8eeb457055..bcbc93bf18 100644 --- a/app/javascript/mastodon/features/emoji/emoji_mart_data_light.ts +++ b/app/javascript/mastodon/features/emoji/emoji_mart_data_light.ts @@ -4,8 +4,8 @@ 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 type { Search, ShortCodesToEmojiData } from './emoji_compressed.mjs'; +import emojiCompressed from './emoji_compressed.mjs'; import { unicodeToUnifiedName } from './unicode_to_unified_name'; type Emojis = Record< diff --git a/app/javascript/mastodon/features/emoji/emoji_unicode_mapping_light.ts b/app/javascript/mastodon/features/emoji/emoji_unicode_mapping_light.ts index 0a5a4c1d76..02bc85dc80 100644 --- a/app/javascript/mastodon/features/emoji/emoji_unicode_mapping_light.ts +++ b/app/javascript/mastodon/features/emoji/emoji_unicode_mapping_light.ts @@ -5,8 +5,8 @@ import type { FilenameData, ShortCodesToEmojiDataKey, -} from './emoji_compressed'; -import emojiCompressed from './emoji_compressed'; +} from './emoji_compressed.mjs'; +import emojiCompressed from './emoji_compressed.mjs'; import { unicodeToFilename } from './unicode_to_filename'; type UnicodeMapping = Record< diff --git a/vite.config.mts b/vite.config.mts index c0159c5aa3..798abee81d 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -104,7 +104,7 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => { }), react({ babel: { - plugins: ['formatjs', 'transform-react-remove-prop-types'], + plugins: ['formatjs', 'transform-react-remove-prop-types', 'preval'], }, }), MastodonServiceWorkerLocales(), @@ -132,7 +132,6 @@ export const config: UserConfigFnPromise = async ({ mode, command }) => { }, }), svgr(), - // manifestSRI(), // Old library types need to be converted optimizeLodashImports() as PluginOption, !!process.env.ANALYZE_BUNDLE_SIZE && analyzer({ analyzerMode: 'static' }),