All files / web/src/lib/audio audioManifest.ts

100% Statements 33/33
100% Branches 4/4
100% Functions 1/1
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 146x 146x 146x 1x 1x 146x 146x 146x 146x 146x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import type { AudioTone } from './audioClipRegistry'
import { getAllRegisteredClips } from './audioClipRegistry'
 
// Side-effect import: triggers all audioClip() registrations
import './clips'
 
export interface AudioClipEntry {
  id: string
  text: string
  tone: AudioTone
  category: string
  filename: string
}
 
function categoryFromId(id: string): string {
  return id.split('-')[0]
}
 
export const AUDIO_MANIFEST: AudioClipEntry[] = getAllRegisteredClips().map((c) => ({
  id: c.id,
  text: c.text,
  tone: c.tone,
  category: categoryFromId(c.id),
  filename: `${c.id}.mp3`,
}))
 
/** All unique categories derived from registered clip IDs. */
export const AUDIO_CATEGORIES = [...new Set(AUDIO_MANIFEST.map((e) => e.category))] as const
export type AudioCategory = string
 
export const AUDIO_MANIFEST_MAP: Record<string, AudioClipEntry> = Object.fromEntries(
  AUDIO_MANIFEST.map((entry) => [entry.id, entry])
)