import { type PagePlacement, type PagePlacementOperation } from '@pdfrx/viewer-core'; /** * Strict-revision page-arrangement protocol shared by collaboration clients * and authoritative relays. * @packageDocumentation * */ /** Persisted or transferred authoritative page state. */ export interface PageSessionSnapshot { /** Last committed page-operation revision, starting at zero. */ readonly revision: number; /** Complete ordered virtual-page arrangement at {@link revision}. */ readonly pages: readonly PagePlacement[]; } /** Optimistic command submitted by one client. */ export interface PageOperationRequest { /** Globally unique id used to correlate the eventual commit or rejection. */ readonly operationId: string; /** Stable participant id responsible for the operation. */ readonly actorId: string; /** Revision the participant observed when creating the operation. */ readonly baseRevision: number; /** Intent expressed against stable placement ids rather than page numbers. */ readonly operation: PagePlacementOperation; } /** Command accepted and sequenced by the authoritative relay. */ export interface CommittedPageOperation extends PageOperationRequest { /** Authoritative revision assigned to the accepted operation. */ readonly revision: number; } /** Machine-readable failure categories produced by the strict page protocol. */ export type PageProtocolErrorCode = 'invalid-envelope' | 'base-revision-mismatch' | 'unexpected-revision'; /** Error thrown for malformed, stale, or out-of-sequence page protocol data. */ export declare class PageProtocolError extends Error { readonly code: PageProtocolErrorCode; /** * @param code Stable category suitable for relay error envelopes. * @param message Human-readable diagnostic text. * */ constructor(code: PageProtocolErrorCode, message: string); } /** * Validates revision and placement invariants in an authoritative snapshot. * @throws {@link PageProtocolError} for an invalid revision. * @throws `PageArrangementError` when placement identities or sources are invalid. * @param snapshot - The current immutable session snapshot. * */ export declare function validatePageSessionSnapshot(snapshot: PageSessionSnapshot): void; /** * Authoritative-server transition. A stale optimistic command is rejected; * transformation/rebase policy can be layered above this strict primitive. * * @returns The next immutable snapshot and the corresponding sequenced event. * @throws {@link PageProtocolError} when the request is malformed or stale. * @param snapshot - The current immutable session snapshot. * @param request - The request value (PageOperationRequest). * */ export declare function commitPageOperation(snapshot: PageSessionSnapshot, request: PageOperationRequest): { readonly snapshot: PageSessionSnapshot; readonly committed: CommittedPageOperation; }; /** * Applies the next relay event on a client or while replaying an operation log. * @throws {@link PageProtocolError} if the event does not immediately follow the snapshot. * @param snapshot - The current immutable session snapshot. * @param committed - The committed value (CommittedPageOperation). * @returns The resulting PageSessionSnapshot. * */ export declare function applyCommittedPageOperation(snapshot: PageSessionSnapshot, committed: CommittedPageOperation): PageSessionSnapshot; //# sourceMappingURL=protocol.d.ts.map