// Downloads the Fluent Emoji 3D icons referenced in server/src/icons.ts // into web/public/icons/.png. Run once; the PNGs are committed. import fs from 'node:fs'; import path from 'node:path'; const root = path.dirname(path.dirname(new URL(import.meta.url).pathname)); const src = fs.readFileSync(path.join(root, 'server/src/icons.ts'), 'utf8'); const names = [...new Set([...src.matchAll(/'([A-Z][^']*)'/g)].map((m) => m[1]))]; const out = path.join(root, 'web/public/icons'); fs.mkdirSync(out, { recursive: true }); const base = 'https://cdn.jsdelivr.net/gh/microsoft/fluentui-emoji@main/assets'; for (const name of names) { const slug = name.toLowerCase().replace(/\s+/g, '-'); const file = path.join(out, `${slug}.png`); if (fs.existsSync(file)) continue; const snake = name.toLowerCase().replace(/\s+/g, '_'); const candidates = [`${name}/3D/${snake}_3d.png`, `${name}/Default/3D/${snake}_3d_default.png`]; let ok = false; for (const c of candidates) { const res = await fetch(`${base}/${c.split('/').map(encodeURIComponent).join('/')}`); if (!res.ok) continue; if (res.headers.get('content-type') !== 'image/png') continue; fs.writeFileSync(file, Buffer.from(await res.arrayBuffer())); ok = true; break; } console.log(ok ? 'ok ' : 'MISSING', name); }