import type { PdfAnnotationSpec } from '@pdfrx/engine'; import type { PagePlacement } from '@pdfrx/viewer-core'; /** Reference to immutable raster bytes stored through the relay's HTTP source endpoint. */ export interface SharedAnnotationImageSource { readonly documentId: string; readonly width: number; readonly height: number; } /** Serializable annotation state used by the collaboration protocol. */ export type SharedAnnotationSpec = Omit & { readonly appearanceImageSource?: SharedAnnotationImageSource; }; /** Add, replace, or remove one annotation addressed by stable page placement. */ /** @internal */ export interface SharedAnnotationUpdate { readonly type: 'update'; readonly placementId: string; readonly id: string; readonly spec: SharedAnnotationSpec; } export type SharedAnnotationChange = { readonly type: 'add'; readonly placementId: string; readonly id: string; readonly spec: SharedAnnotationSpec; } | SharedAnnotationUpdate | { readonly type: 'remove'; readonly placementId: string; readonly id: string; }; /** Current materialized state of one shared annotation. */ export interface SharedAnnotationRecord { /** Stable virtual-page placement containing the annotation. */ readonly placementId: string; /** PDF annotation `/NM` identity, unique within the placement. */ readonly id: string; /** Serializable annotation geometry, content, and appearance properties. */ readonly spec: SharedAnnotationSpec; } /** Authoritative annotation state, versioned independently from page operations. */ export interface AnnotationSessionSnapshot { /** Last committed annotation-operation revision. */ readonly revision: number; /** Materialized annotation records present at this revision. */ readonly annotations: readonly SharedAnnotationRecord[]; } /** Optimistic annotation operation submitted to an authoritative relay. */ export interface AnnotationOperationRequest { /** Unique correlation id generated by the submitting client. */ readonly operationId: string; /** Stable participant id responsible for the change. */ readonly actorId: string; /** Annotation revision observed before submitting the change. */ readonly baseRevision: number; /** Requested annotation mutation. */ readonly change: SharedAnnotationChange; } /** Accepted annotation operation with its authoritative sequence number. */ export interface CommittedAnnotationOperation extends AnnotationOperationRequest { /** Revision assigned by the relay. */ readonly revision: number; } /** @internal Non-persistent annotation geometry broadcast while a participant drags. */ export interface AnnotationPreview { readonly actorId: string; readonly changes: readonly SharedAnnotationUpdate[]; } /** * Validates and commits an annotation operation against authoritative state. * @throws {@link AnnotationProtocolError} for a stale revision or missing placement. * @param snapshot - The current immutable session snapshot. * @param pages - The pages to process, in document order. * @param request - The request value (AnnotationOperationRequest). * @returns The updated result. * */ export declare function commitAnnotationOperation(snapshot: AnnotationSessionSnapshot, pages: readonly PagePlacement[], request: AnnotationOperationRequest): { readonly snapshot: AnnotationSessionSnapshot; readonly committed: CommittedAnnotationOperation; }; /** * Applies the next committed annotation event to a client-side snapshot. * @throws {@link AnnotationProtocolError} when a revision is skipped or replayed. * @param snapshot - The current immutable session snapshot. * @param committed - The committed value (CommittedAnnotationOperation). * @returns The resulting AnnotationSessionSnapshot. * */ export declare function applyCommittedAnnotationOperation(snapshot: AnnotationSessionSnapshot, committed: CommittedAnnotationOperation): AnnotationSessionSnapshot; /** Protocol validation error carrying a machine-readable relay error code. */ export declare class AnnotationProtocolError extends Error { readonly code: string; /** * Creates an annotation protocol failure with a relay-safe error code. * * @param code - The machine-readable error code. * @param message - The human-readable error message. * */ constructor(code: string, message: string); } //# sourceMappingURL=annotation-protocol.d.ts.map