/** * Engine composition root. * * `createEngine()` wires in-memory repos to the services and shares a single * event bus. The app layer holds the returned `Engine` instance and passes * its services into the UI. * * Swapping the repository implementation later (ADR-0005) is a matter of * replacing `createInMemoryRepos()` here. The service signatures don't * change. */ import { createEventBus, type EventBus } from "./events"; import { createInMemoryRepos, type InMemoryRepos, } from "./repos"; import { createAnnotationService, createDocumentService, createEvidenceService, type AnnotationService, type DocumentService, type EvidenceService, } from "./services"; export * from "./events"; export * from "./repos"; export * from "./services"; export * from "./rendering"; export { SNAPSHOT_VERSION, attachPersister, captureSnapshot, documentIdsIn, restoreFromStorage, restoreSnapshot, type EngineSnapshot, type PersisterOptions, } from "./persistence"; export interface Engine { readonly bus: EventBus; readonly repos: InMemoryRepos; readonly documents: DocumentService; readonly annotations: AnnotationService; readonly evidence: EvidenceService; } export function createEngine(): Engine { const bus = createEventBus(); const repos = createInMemoryRepos(); const documents = createDocumentService(repos.documents, repos.representations, bus); const annotations = createAnnotationService(repos.annotations, bus); const evidence = createEvidenceService( repos.evidenceItems, (id) => repos.annotations.get(id), bus, ); return { bus, repos, documents, annotations, evidence }; }