import type { BindingContext } from "../state/selectors/contract.js"; import { selectActiveView } from "../state/selectors/focus.js"; import type { VoiceState } from "../state/state.js"; import type { BoundGlobalBinding } from "./component-binding.js"; export interface VoiceOverlayPropsAdapterConfig { tui: { requestRender(): void }; bindings: ReadonlyArray; } export class VoiceOverlayPropsAdapter { private readonly tui: VoiceOverlayPropsAdapterConfig["tui"]; private readonly bindings: ReadonlyArray; constructor(config: VoiceOverlayPropsAdapterConfig) { this.tui = config.tui; this.bindings = config.bindings; } apply(state: VoiceState): void { const ctx: BindingContext = { activeView: selectActiveView(state) }; for (const b of this.bindings) b.apply(state, ctx); this.tui.requestRender(); } invalidate(): void { for (const b of this.bindings) b.invalidate(); } }