Files
musicshare/packages/shared/scripts/gen-emoji.mjs
T
chrisandClaude Opus 5.5 d2edad4b0d
CI / check (push) Canceled after 0s
Emoji reactions on songs
React to a friend's current song or any of their recent plays: tap an
emoji to add yours (or take it back), "☺+" for the quick six, and a full
picker with search and categories (Unicode emoji up to 13.1, generated
into the shared package so web and mobile match). One reaction per person
per play; a new one replaces the old. Chips show counts and, on hover/
long label, who reacted; yours is highlighted. Listeners and followers get
the update live. Not on your own plays, not across a block (blocking also
clears reactions between the two people).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
2026-10-06 13:39:26 -04:00

27 lines
1.3 KiB
JavaScript

// Regenerates src/emojiData.ts from the Unicode emoji list (npm: unicode-emoji-json).
// node scripts/gen-emoji.mjs
// Capped at Emoji 13.1 so every emoji in the picker renders on older Android phones.
import { readFileSync, writeFileSync } from 'node:fs';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const groups = require('unicode-emoji-json/data-by-group.json');
const MAX_VERSION = 13.1;
const SKIP = new Set(['component']); // skin tone swatches etc.
const out = groups
.filter((g) => !SKIP.has(g.slug))
.map((g) => ({
name: g.name.replace(' & ', ' and '),
// "emoji name" pairs, space-separated words; one string per emoji keeps the file small.
emojis: g.emojis.filter((e) => Number.parseFloat(e.emoji_version) <= MAX_VERSION).map((e) => `${e.emoji} ${e.name}`),
}));
const header = `// Generated by scripts/gen-emoji.mjs from unicode-emoji-json (MIT). Don't edit by hand.\n`;
writeFileSync(
new URL('../src/emojiData.ts', import.meta.url),
`${header}export const EMOJI_GROUPS: { name: string; emojis: string[] }[] = ${JSON.stringify(out)};\n`,
);
const count = out.reduce((n, g) => n + g.emojis.length, 0);
console.log(`wrote ${count} emoji in ${out.length} groups (${readFileSync(new URL('../src/emojiData.ts', import.meta.url)).length} bytes)`);