diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-14 23:34:57 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-14 23:34:57 +0200 |
| commit | 91e1232112421438ce73b9361896f9b58c84fb3e (patch) | |
| tree | b57d510a618d0a1a03a2fa3f9cc4de23eaa7f3b3 /apps/web/src/core/managers | |
| parent | f726d9529552c4149a95aaf555f760868a4c9f91 (diff) | |
| download | opencut-91e1232112421438ce73b9361896f9b58c84fb3e.tar.gz | |
feat: transcription diagnostics
Diffstat (limited to 'apps/web/src/core/managers')
| -rw-r--r-- | apps/web/src/core/managers/diagnostics-manager.ts | 38 |
1 files changed, 38 insertions, 0 deletions
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<DiagnosticDefinition> { + 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(); + }); + } +} |
