// Builds src/renderer/src/emoji-data.json — a compact [emoji, shortnames[]] // list in picker order — and the Android app's res/raw/emoji_list.txt (the // same emoji, one per line, for its reaction picker) from emoji-datasource (the shortcode set Signal and // Slack use). Run with `npm run gen:emoji` after bumping emoji-datasource. import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' import { createRequire } from 'node:module' const require = createRequire(import.meta.url) const source = JSON.parse(readFileSync(require.resolve('emoji-datasource/emoji.json'), 'utf8')) const toChar = (unified) => String.fromCodePoint(...unified.split('-').map((h) => parseInt(h, 16))) const data = source .filter((e) => e.has_img_apple && !e.obsoleted_by) .sort((a, b) => a.sort_order - b.sort_order) .map((e) => [toChar(e.unified), e.short_names]) const out = new URL('../src/renderer/src/emoji-data.json', import.meta.url) writeFileSync(out, JSON.stringify(data) + '\n') const raw = new URL('../android/app/src/main/res/raw/', import.meta.url) mkdirSync(raw, { recursive: true }) writeFileSync(new URL('emoji_list.txt', raw), data.map(([char]) => char).join('\n') + '\n') console.log(`wrote ${data.length} emoji`)