/** * ProjectionClient - In-process projection consumer for TUI * DD ยง13.2. Runtime creates and wires this client to ProjectionStore. * TUI imports this from runtime to receive projection updates. * * @module packages/runtime/src/projection/ProjectionClient */ import type { SessionProjection, ProjectionSubscriber } from './ProjectionStore.js' export { type SessionProjection, type TaskProjection, type AgentProjection, type ProjectionSubscriber } from './ProjectionStore.js' export class ProjectionClient { private snapshot: SessionProjection | null = null private subscribers: Set = new Set() /** * Receive and cache a projection snapshot (called by RuntimeApp). */ receive_snapshot(projection: SessionProjection): void { this.snapshot = projection for (const sub of this.subscribers) { sub(projection) } } /** * Subscribe to projection updates. */ subscribe(subscriber: ProjectionSubscriber): () => void { this.subscribers.add(subscriber) return () => this.subscribers.delete(subscriber) } /** * Get current snapshot. */ get_snapshot(): SessionProjection | null { return this.snapshot } }