extract-emoji-data.cjs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env node
  2. /**
  3. * Extracts a minimal emoji native lookup map from @emoji-mart/data.
  4. *
  5. * Run this script from the apps/app/ directory whenever @emoji-mart/data is upgraded:
  6. * node bin/extract-emoji-data.cjs
  7. *
  8. * Output: src/services/renderer/remark-plugins/emoji-native-lookup.json
  9. */
  10. 'use strict';
  11. const fs = require('node:fs');
  12. const path = require('node:path');
  13. const inputPath = path.resolve(
  14. __dirname,
  15. '../node_modules/@emoji-mart/data/sets/15/native.json',
  16. );
  17. const outputPath = path.resolve(
  18. __dirname,
  19. '../src/services/renderer/remark-plugins/emoji-native-lookup.json',
  20. );
  21. const raw = JSON.parse(fs.readFileSync(inputPath, 'utf8'));
  22. /** @type {Record<string, { skins: [{ native: string }] }>} */
  23. const lookup = {};
  24. for (const [name, entry] of Object.entries(raw.emojis)) {
  25. const native = entry.skins?.[0]?.native;
  26. if (native) {
  27. lookup[name] = { skins: [{ native }] };
  28. }
  29. }
  30. fs.writeFileSync(outputPath, JSON.stringify(lookup, null, 2) + '\n', 'utf8');
  31. console.log(`Wrote ${Object.keys(lookup).length} entries to ${outputPath}`);