Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

704 B
Raw Blame
import type { NarrationResult } from './types';

export interface NarrationUpdate {
  stepId: string;
  description: string;
}

export function narrationUpdates(result: NarrationResult, stepIds: readonly string[]): NarrationUpdate[] {
  const known = new Set(stepIds);
  const collected = new Map<string, string[]>();

  for (const { stepId, text } of result.descriptions) {
    const description = text.trim();
    if (!description || !known.has(stepId)) continue;
    const existing = collected.get(stepId);
    if (existing) existing.push(description);
    else collected.set(stepId, [description]);
  }

  return [...collected].map(([stepId, texts]) => ({ stepId, description: texts.join(' ') }));
}