// Builds src/renderer/src/emoji-data.json — a compact [emoji, shortnames[]] // list in picker order — from emoji-datasource (the shortcode set Signal and // Slack use). Run with `npm run gen:emoji` after bumping emoji-datasource. import { 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') console.log(`wrote ${data.length} emoji`)