From 91e1232112421438ce73b9361896f9b58c84fb3e Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Tue, 14 Apr 2026 23:34:57 +0200 Subject: feat: transcription diagnostics --- apps/web/src/core/index.ts | 5 +++ apps/web/src/core/managers/diagnostics-manager.ts | 38 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 apps/web/src/core/managers/diagnostics-manager.ts (limited to 'apps/web/src/core') diff --git a/apps/web/src/core/index.ts b/apps/web/src/core/index.ts index e93b937d..483a26c1 100644 --- a/apps/web/src/core/index.ts +++ b/apps/web/src/core/index.ts @@ -9,8 +9,10 @@ import { SaveManager } from "./managers/save-manager"; import { AudioManager } from "./managers/audio-manager"; import { SelectionManager } from "./managers/selection-manager"; import { ClipboardManager } from "./managers/clipboard-manager"; +import { DiagnosticsManager } from "./managers/diagnostics-manager"; import { registerDefaultEffects } from "@/lib/effects"; import { registerDefaultMasks } from "@/lib/masks"; +import { registerTranscriptionDiagnostics } from "@/lib/transcription/diagnostics"; export class EditorCore { private static instance: EditorCore | null = null; @@ -25,6 +27,7 @@ export class EditorCore { public readonly audio: AudioManager; public readonly selection: SelectionManager; public readonly clipboard: ClipboardManager; + public readonly diagnostics: DiagnosticsManager; private constructor() { registerDefaultEffects(); @@ -40,6 +43,8 @@ export class EditorCore { this.audio = new AudioManager(this); this.selection = new SelectionManager(this); this.clipboard = new ClipboardManager(this); + this.diagnostics = new DiagnosticsManager(this); + registerTranscriptionDiagnostics({ diagnostics: this.diagnostics }); this.playback.bindTimelineScope(); this.command.registerReactor(() => { const activeScene = this.scenes.getActiveSceneOrNull(); diff --git a/apps/web/src/core/managers/diagnostics-manager.ts b/apps/web/src/core/managers/diagnostics-manager.ts new file mode 100644 index 00000000..d022a350 --- /dev/null +++ b/apps/web/src/core/managers/diagnostics-manager.ts @@ -0,0 +1,38 @@ +import type { EditorCore } from "@/core"; +import type { DiagnosticDefinition } from "@/lib/diagnostics/types"; + +interface DiagnosticRegistration extends DiagnosticDefinition { + check: (editor: EditorCore) => boolean; +} + +export class DiagnosticsManager { + private readonly registrations: DiagnosticRegistration[] = []; + private readonly listeners = new Set<() => void>(); + + constructor(private editor: EditorCore) {} + + register(registration: DiagnosticRegistration): void { + this.registrations.push(registration); + this.notify(); + } + + getActive(options?: { scope?: string }): ReadonlyArray { + const candidates = + options?.scope !== undefined + ? this.registrations.filter((r) => r.scope === options.scope) + : this.registrations; + + return candidates.filter((r) => r.check(this.editor)); + } + + subscribe(listener: () => void): () => void { + this.listeners.add(listener); + return () => this.listeners.delete(listener); + } + + notify(): void { + this.listeners.forEach((listener) => { + listener(); + }); + } +} -- cgit v1.3.1