/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { type ISegment } from "./mergeTreeNodes.js"; import type { OperationStamp } from "./stamps.js"; /** * A perspective which includes some subset of operations known to the local client. * * This helps the local client reason about the state of other clients when they issued an operation. * @internal */ export interface Perspective { /** * The sequence number last seen from this perspective. Same concept as `ISequencedDocumentMessage.referenceSequenceNumber`. * @privateRemarks * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends * on the (refSeq, clientId, localSeq?) representation of perspectives. */ readonly refSeq: number; /** * The client id for this perspective. * @privateRemarks * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends * on the (refSeq, clientId, localSeq?) representation of perspectives. */ readonly clientId: number; /** * When this is a local perspective, the local sequence number last seen from this perspective. * * Perspectives with defined `localSeq` values are useful in reconnection flows, where the local client may need to resend some * of its ops after rederiving their new equivalents. * @privateRemarks * This currently allows inter-operation between MergeTree methods and the partial lengths implementation, which still depends * on the (refSeq, clientId, localSeq?) representation of perspectives. */ readonly localSeq?: number; /** * @returns Whether the segment is present (visible) from this perspective */ isSegmentPresent(segment: ISegment): boolean; /** * @returns Whether this perspective has seen the given operation. */ hasOccurred(stamp: OperationStamp): boolean; } declare abstract class PerspectiveBase { abstract hasOccurred(stamp: OperationStamp): boolean; isSegmentPresent(seg: ISegment): boolean; } /** * A perspective which includes edits at or before some reference sequence number alongside all edits from some particular client. * * @remarks * This works for both the local client as well as remote clients since refSeq-based checks disallow unacked edits, but the clientId check * catches unacked edits from the local client. */ export declare class PriorPerspective extends PerspectiveBase implements Perspective { readonly refSeq: number; readonly clientId: number; constructor(refSeq: number, clientId: number); hasOccurred(stamp: OperationStamp): boolean; } /** * A perspective which includes edits which were either: * - acked and at or before some reference sequence number * - unacked, but at or before some local sequence number * * This is a useful perspective when the local client is in the process of reconnecting, since it must * rederive positions for unacked ops while only considering a portion of its own edits as having been applied. */ export declare class LocalReconnectingPerspective extends PerspectiveBase implements Perspective { readonly refSeq: number; readonly clientId: number; readonly localSeq: number; constructor(refSeq: number, clientId: number, localSeq: number); hasOccurred(stamp: OperationStamp): boolean; } /** * This perspective is used when rebasing obliterate endpoints to find the segment to slide to when squash is enabled. * * TODO:AB#39357: This class would not be necessary if obliterate rebasing occurred as resubmit was called rather than * precomputed before segment normalization. It also adds more dependencies on all ops being resubmitted (the squash * parameter coming from rebasing an obliterate does not necessarily align with an inserted segment), which is not * fully correct. */ export declare class LocalSquashPerspective extends LocalReconnectingPerspective { readonly refSeq: number; readonly clientId: number; readonly localSeq: number; constructor(refSeq: number, clientId: number, localSeq: number); isSegmentPresent(seg: ISegment): boolean; } /** * A perspective which includes edits which were either: * - acked and at or before some reference sequence number * - unacked, but at or before some local sequence number * * @internal */ export declare function createLocalReconnectingPerspective(refSeq: number, clientId: number, localSeq: number, squash?: boolean): Perspective; /** * A perspective which includes all known edits. * * This is the perspective that the application sees. * @remarks * This can be represented using {@link PriorPerspective} with a refSeq of `Number.MAX_SAFE_INTEGER`, but having an explicit * variant of this perspective renders extra refSeq checks unnecessary and is a bit easier to read. */ export declare class LocalDefaultPerspective extends PerspectiveBase implements Perspective { readonly clientId: number; readonly refSeq: number; constructor(clientId: number); hasOccurred(_stamp: OperationStamp): boolean; } /** * A perspective dictating whether segments are 'visible' to a remote obliterate operation. * * NOTE: Beware that partial lengths doesn't support this perspective, in the sense that consulting partial lengths' for the length of a block * can give different results than summing the lengths of present segments in that block. * This ends up not affecting the current obliterate implementation (which has some special casing in the mapRange calls it uses), * but use with caution. */ export declare class RemoteObliteratePerspective extends PerspectiveBase implements Perspective { readonly clientId: number; readonly refSeq: number; constructor(clientId: number); hasOccurred(stamp: OperationStamp): boolean; } export declare const allAckedChangesPerspective: PriorPerspective; export {}; //# sourceMappingURL=perspective.d.ts.map