Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

834 B
Raw Blame
import { buildCatalog, type EmojiCatalog, type EmojiSourceEntry } from './catalog'

let pending: Promise<EmojiCatalog> | null = null
let settled: EmojiCatalog | null = null

export function loadEmojiCatalog(): Promise<EmojiCatalog> {
  if (!pending) {
    pending = import('emoji-datasource-twitter/emoji.json').then((mod) => {
      const raw = (mod as { default?: EmojiSourceEntry[] }).default ?? (mod as unknown as EmojiSourceEntry[])
      // Measured ~14ms total on real data: runs inline, no staging needed.
      const catalog = buildCatalog(Array.isArray(raw) ? raw : [])
      settled = catalog
      return catalog
    })
  }
  return pending
}

/**
 * Synchronously returns the built catalog when a previous load finished,
 * otherwise null.
 */
export function peekEmojiCatalog(): EmojiCatalog | null {
  return settled
}