/** * ViewerController * * Main controller that orchestrates sub-controllers and manages the viewer lifecycle. * Delegates specific responsibilities to focused controllers while coordinating overall state. */ import type { ViewerEventBus, ViewerEventEmitter, ViewerEventMap } from "../../core/types/events"; import { type ImageFilters } from "../../core/types/filters"; import type { ResolvedAnnotation } from "../../iiif/annotationResolver"; import type { MediaSource, MediaType } from "../../iiif/mediaResolver"; import type { ViewBox, ViewerStateSnapshot } from "../../core/types/viewer"; import type { ViewerDerivedStores } from "./viewerDerived"; import type { ViewerStateStores } from "./viewerState"; import { type AnnotationPatchOptions } from "./controllers/AnnotationController"; import { type ViewerPanel } from "./controllers/PanelController"; type Dispatch = ViewerEventEmitter; export type ViewerController = { events: ViewerEventBus; on: ViewerEventBus["on"]; off: ViewerEventBus["off"]; emitStateChange: () => void; emitEvent: (event: K, payload: ViewerEventMap[K]) => void; setEventTarget: (target: EventTarget) => void; getStateSnapshot: () => ViewerStateSnapshot; getCanvasIndex: () => number; getCanvasId: () => string | null; getCanvasCount: () => number; setCanvasByIndex: (index: number) => void; setCanvasById: (canvasId: string) => void; setManifest: (manifestId: string) => void; getManifestId: () => string | null; addAnnotation: (annotation: unknown) => Promise; updateAnnotation: (annotationId: string, patch: Partial, options?: AnnotationPatchOptions) => Promise; removeAnnotation: (annotationId: string) => Promise; /** Replaces an annotation wholesale. For undo and redo. */ replaceAnnotation: (annotationId: string, annotation: ResolvedAnnotation) => Promise; /** Commits the edits already applied to an annotation as one save. */ commitAnnotation: (annotationId: string) => Promise; updateImageFilter: (key: K, value: ImageFilters[K]) => void; resetImageFilters: () => void; setAnnotationMode: (mode: "edit" | "create") => void; setSearchQuery: (value: string) => void; handleSearchResultClick: (annotation: ResolvedAnnotation) => void; setPanelOpen: (panel: ViewerPanel, open: boolean) => void; updateLayerOpacity: (id: string, opacity: number) => void; setLayoutMode: (mode: "single" | "two-page" | "continuous" | "gallery") => void; handleViewBoxChange: (detail: { viewBox: ViewBox; }) => void; handleZoomChange: (detail: { zoom: number; viewBox: ViewBox; }) => void; handleRotationChange: (detail: { rotation: number; }) => void; handleMediaPlay: (detail: { time: number; }) => void; handleMediaPause: (detail: { time: number; }) => void; handleMediaTimeUpdate: (detail: { time: number; duration?: number; }) => void; handleMediaSeek: (detail: { from: number; to: number; }) => void; handleMediaSegmentEnd: () => void; handleModelChange: (detail: { source?: string; cameraOrbit?: string; cameraTarget?: string; fieldOfView?: string; orientation?: string; }) => void; handleAnnotationHover: (detail: { id: string | null; }) => void; handleAnnotationSelect: (detail: { id: string; preventZoom?: boolean; }) => void; handleAnnotationClear: () => void; getMediaLabel: (source: MediaSource, translate: (key: string) => string) => string; getMediaTypeLabel: (type: MediaType | null, translate: (key: string) => string) => string; destroy: () => void; }; export { type ViewerPanel }; /** * Clear data that belongs to the previously active manifest. * * Panel visibility is intentionally not changed here. Panels derive their * availability from the newly selected resource and the PanelController closes * any panel that is no longer valid. This keeps the reset independent of media * type: structures, annotations, search, layers, and media can occur on many * kinds of IIIF manifests. */ export declare const resetManifestScopedState: (state: ViewerStateStores, { resetViewport }: { resetViewport: boolean; }) => void; export declare const createViewerController: ({ state, derived: derivedStores, dispatch, applyViewBox, }: { state: ViewerStateStores; derived: ViewerDerivedStores; dispatch: Dispatch; applyViewBox?: (viewBox: ViewBox) => void; }) => ViewerController;