Skip to content

Latest commit

 

History

History
549 lines (509 loc) · 23.8 KB

sequence.api.md

File metadata and controls

549 lines (509 loc) · 23.8 KB

API Report File for "@fluidframework/sequence"

Do not edit this file. It is a report generated by API Extractor.

import { BaseSegment } from '@fluidframework/merge-tree';
import { Client } from '@fluidframework/merge-tree';
import { Deferred } from '@fluidframework/common-utils';
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
import { IChannelFactory } from '@fluidframework/datastore-definitions';
import { IChannelServices } from '@fluidframework/datastore-definitions';
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
import { ICombiningOp } from '@fluidframework/merge-tree';
import { IEvent } from '@fluidframework/common-definitions';
import { IEventThisPlaceHolder } from '@fluidframework/common-definitions';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { IJSONSegment } from '@fluidframework/merge-tree';
import { IMergeTreeDeltaCallbackArgs } from '@fluidframework/merge-tree';
import { IMergeTreeDeltaOpArgs } from '@fluidframework/merge-tree';
import { IMergeTreeGroupMsg } from '@fluidframework/merge-tree';
import { IMergeTreeInsertMsg } from '@fluidframework/merge-tree';
import { IMergeTreeMaintenanceCallbackArgs } from '@fluidframework/merge-tree';
import { IMergeTreeOp } from '@fluidframework/merge-tree';
import { IMergeTreeRemoveMsg } from '@fluidframework/merge-tree';
import { IRelativePosition } from '@fluidframework/merge-tree';
import { ISegment } from '@fluidframework/merge-tree';
import { ISegmentAction } from '@fluidframework/merge-tree';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
import { LocalReferencePosition } from '@fluidframework/merge-tree';
import { Marker } from '@fluidframework/merge-tree';
import { MergeTreeDeltaOperationType } from '@fluidframework/merge-tree';
import { MergeTreeDeltaOperationTypes } from '@fluidframework/merge-tree';
import { MergeTreeMaintenanceType } from '@fluidframework/merge-tree';
import { MergeTreeRevertibleDriver } from '@fluidframework/merge-tree';
import { PropertiesManager } from '@fluidframework/merge-tree';
import { PropertySet } from '@fluidframework/merge-tree';
import { RangeStackMap } from '@fluidframework/merge-tree';
import { ReferencePosition } from '@fluidframework/merge-tree';
import { ReferenceType } from '@fluidframework/merge-tree';
import { Serializable } from '@fluidframework/datastore-definitions';
import { SharedObject } from '@fluidframework/shared-object-base';
import { SummarySerializer } from '@fluidframework/shared-object-base';
import { TextSegment } from '@fluidframework/merge-tree';
import { TypedEventEmitter } from '@fluidframework/common-utils';

// @public
export type CompressedSerializedInterval = [number, number, number, IntervalType, PropertySet];

// @public (undocumented)
export type DeserializeCallback = (properties: PropertySet) => void;

// @public
export function getTextAndMarkers(sharedString: SharedString, label: string, start?: number, end?: number): {
    parallelText: string[];
    parallelMarkers: Marker[];
};

// @public
export interface IInterval {
    // (undocumented)
    clone(): IInterval;
    compare(b: IInterval): number;
    compareEnd(b: IInterval): number;
    compareStart(b: IInterval): number;
    // @internal
    modify(label: string, start: number | undefined, end: number | undefined, op?: ISequencedDocumentMessage, localSeq?: number): IInterval | undefined;
    // (undocumented)
    overlaps(b: IInterval): boolean;
    // @internal
    union(b: IInterval): IInterval;
}

// @public
export interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
    (event: "changeInterval", listener: (interval: TInterval, previousInterval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
    (event: "addInterval" | "deleteInterval", listener: (interval: TInterval, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
    (event: "propertyChanged", listener: (interval: TInterval, propertyDeltas: PropertySet, local: boolean, op: ISequencedDocumentMessage | undefined) => void): any;
}

// @public (undocumented)
export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
    // (undocumented)
    compareEnds(a: TInterval, b: TInterval): number;
    // (undocumented)
    create(label: string, start: number | undefined, end: number | undefined, client: Client | undefined, intervalType: IntervalType, op?: ISequencedDocumentMessage, fromSnapshot?: boolean): TInterval;
}

// @public (undocumented)
export interface IJSONRunSegment<T> extends IJSONSegment {
    // (undocumented)
    items: Serializable<T>[];
}

// @internal (undocumented)
export interface IMapMessageLocalMetadata {
    // (undocumented)
    localSeq: number;
}

// @public
export class Interval implements ISerializableInterval {
    constructor(start: number, end: number, props?: PropertySet);
    // (undocumented)
    addProperties(newProps: PropertySet, collaborating?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
    addPropertySet(props: PropertySet): void;
    // @internal (undocumented)
    auxProps: PropertySet[] | undefined;
    // (undocumented)
    clone(): Interval;
    compare(b: Interval): number;
    compareEnd(b: Interval): number;
    compareStart(b: Interval): number;
    // (undocumented)
    end: number;
    // (undocumented)
    getAdditionalPropertySets(): PropertySet[];
    getIntervalId(): string | undefined;
    // (undocumented)
    getProperties(): PropertySet;
    modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage): Interval | undefined;
    // (undocumented)
    overlaps(b: Interval): boolean;
    properties: PropertySet;
    // (undocumented)
    propertyManager: PropertiesManager;
    // @internal (undocumented)
    serialize(): ISerializedInterval;
    // (undocumented)
    start: number;
    union(b: Interval): Interval;
}

// @public
export class IntervalCollection<TInterval extends ISerializableInterval> extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
    // (undocumented)
    [Symbol.iterator](): IntervalCollectionIterator<TInterval>;
    // @internal
    constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[] | ISerializedIntervalCollectionV2);
    // @internal (undocumented)
    ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): TInterval | undefined;
    // @internal (undocumented)
    ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage, localOpMetadata: IMapMessageLocalMetadata | undefined): void;
    // @internal (undocumented)
    ackDelete(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
    add(start: number, end: number, intervalType: IntervalType, props?: PropertySet): TInterval;
    // (undocumented)
    addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
    // (undocumented)
    attachDeserializer(onDeserialize: DeserializeCallback): void;
    // (undocumented)
    get attached(): boolean;
    // @internal (undocumented)
    attachGraph(client: Client, label: string): void;
    change(id: string, start?: number, end?: number): TInterval | undefined;
    changeProperties(id: string, props: PropertySet): void;
    // (undocumented)
    CreateBackwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
    // (undocumented)
    CreateBackwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
    // (undocumented)
    CreateForwardIteratorWithEndPosition(endPosition: number): IntervalCollectionIterator<TInterval>;
    // (undocumented)
    CreateForwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
    // (undocumented)
    findOverlappingIntervals(startPosition: number, endPosition: number): TInterval[];
    gatherIterationResults(results: TInterval[], iteratesForward: boolean, start?: number, end?: number): void;
    // (undocumented)
    getIntervalById(id: string): TInterval | undefined;
    map(fn: (interval: TInterval) => void): void;
    // (undocumented)
    nextInterval(pos: number): TInterval | undefined;
    // (undocumented)
    previousInterval(pos: number): TInterval | undefined;
    // @internal
    rebaseLocalInterval(opName: string, serializedInterval: SerializedIntervalDelta, localSeq: number): SerializedIntervalDelta | undefined;
    removeIntervalById(id: string): TInterval | undefined;
    // @internal (undocumented)
    serializeInternal(): ISerializedIntervalCollectionV2;
}

// @public (undocumented)
export class IntervalCollectionIterator<TInterval extends ISerializableInterval> implements Iterator<TInterval> {
    constructor(collection: IntervalCollection<TInterval>, iteratesForward?: boolean, start?: number, end?: number);
    // (undocumented)
    next(): IteratorResult<TInterval>;
}

// @public (undocumented)
export type IntervalConflictResolver<TInterval> = (a: TInterval, b: TInterval) => TInterval;

// @public
export interface IntervalLocator {
    interval: SequenceInterval;
    label: string;
}

// @public
export function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;

// @public (undocumented)
export enum IntervalType {
    // (undocumented)
    Nest = 1,
    // (undocumented)
    Simple = 0,
    SlideOnRemove = 2,
    // @internal
    Transient = 4
}

// @public
export interface ISequenceDeltaRange<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
    operation: TOperation;
    position: number;
    propertyDeltas: PropertySet;
    segment: ISegment;
}

// @public (undocumented)
export interface ISerializableInterval extends IInterval {
    // @internal (undocumented)
    addProperties(props: PropertySet, collaborating?: boolean, seq?: number): PropertySet | undefined;
    getIntervalId(): string | undefined;
    properties: PropertySet;
    // @internal (undocumented)
    propertyManager: PropertiesManager;
    // @internal (undocumented)
    serialize(): ISerializedInterval;
}

// @internal
export interface ISerializedInterval {
    end: number;
    intervalType: IntervalType;
    properties?: PropertySet;
    sequenceNumber: number;
    start: number;
}

// @internal (undocumented)
export interface ISerializedIntervalCollectionV2 {
    // (undocumented)
    intervals: CompressedSerializedInterval[];
    // (undocumented)
    label: string;
    // (undocumented)
    version: 2;
}

// @public (undocumented)
export interface ISharedIntervalCollection<TInterval extends ISerializableInterval> {
    // (undocumented)
    getIntervalCollection(label: string): IntervalCollection<TInterval>;
}

// @public
export interface ISharedSegmentSequenceEvents extends ISharedObjectEvents {
    // (undocumented)
    (event: "createIntervalCollection", listener: (label: string, local: boolean, target: IEventThisPlaceHolder) => void): any;
    // (undocumented)
    (event: "sequenceDelta", listener: (event: SequenceDeltaEvent, target: IEventThisPlaceHolder) => void): any;
    // (undocumented)
    (event: "maintenance", listener: (event: SequenceMaintenanceEvent, target: IEventThisPlaceHolder) => void): any;
}

// @public
export interface ISharedString extends SharedSegmentSequence<SharedStringSegment> {
    insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
    insertText(pos: number, text: string, props?: PropertySet): void;
    posFromRelativePos(relativePos: IRelativePosition): number;
}

// @internal
export interface IValueOpEmitter {
    emit(opName: string, previousValue: any, params: any, localOpMetadata: IMapMessageLocalMetadata): void;
}

// @public
export class SequenceDeltaEvent extends SequenceEvent<MergeTreeDeltaOperationType> {
    constructor(opArgs: IMergeTreeDeltaOpArgs, deltaArgs: IMergeTreeDeltaCallbackArgs, mergeTreeClient: Client);
    readonly isLocal: boolean;
    // (undocumented)
    readonly opArgs: IMergeTreeDeltaOpArgs;
}

// @public
export abstract class SequenceEvent<TOperation extends MergeTreeDeltaOperationTypes = MergeTreeDeltaOperationTypes> {
    constructor(deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>, mergeTreeClient: Client);
    get clientId(): string | undefined;
    // (undocumented)
    readonly deltaArgs: IMergeTreeDeltaCallbackArgs<TOperation>;
    // (undocumented)
    readonly deltaOperation: TOperation;
    get first(): Readonly<ISequenceDeltaRange<TOperation>>;
    get last(): Readonly<ISequenceDeltaRange<TOperation>>;
    get ranges(): readonly Readonly<ISequenceDeltaRange<TOperation>>[];
}

// @public
export class SequenceInterval implements ISerializableInterval {
    constructor(client: Client,
    start: LocalReferencePosition,
    end: LocalReferencePosition, intervalType: IntervalType, props?: PropertySet);
    // @internal
    addPositionChangeListeners(beforePositionChange: () => void, afterPositionChange: () => void): void;
    // (undocumented)
    addProperties(newProps: PropertySet, collab?: boolean, seq?: number, op?: ICombiningOp): PropertySet | undefined;
    // (undocumented)
    clone(): SequenceInterval;
    compare(b: SequenceInterval): number;
    compareEnd(b: SequenceInterval): number;
    compareStart(b: SequenceInterval): number;
    end: LocalReferencePosition;
    getIntervalId(): string | undefined;
    // (undocumented)
    intervalType: IntervalType;
    modify(label: string, start: number, end: number, op?: ISequencedDocumentMessage, localSeq?: number): SequenceInterval;
    // (undocumented)
    overlaps(b: SequenceInterval): boolean;
    // (undocumented)
    overlapsPos(bstart: number, bend: number): boolean;
    properties: PropertySet;
    // (undocumented)
    propertyManager: PropertiesManager;
    // @internal
    removePositionChangeListeners(): void;
    // @internal (undocumented)
    serialize(): ISerializedInterval;
    start: LocalReferencePosition;
    union(b: SequenceInterval): SequenceInterval;
}

// @public
export class SequenceMaintenanceEvent extends SequenceEvent<MergeTreeMaintenanceType> {
    constructor(opArgs: IMergeTreeDeltaOpArgs | undefined, deltaArgs: IMergeTreeMaintenanceCallbackArgs, mergeTreeClient: Client);
    // (undocumented)
    readonly opArgs: IMergeTreeDeltaOpArgs | undefined;
}

// @internal
export type SerializedIntervalDelta = Omit<ISerializedInterval, "start" | "end" | "properties"> & Partial<Pick<ISerializedInterval, "start" | "end" | "properties">>;

// @public @deprecated (undocumented)
export class SharedIntervalCollection extends SharedObject implements ISharedIntervalCollection<Interval> {
    // (undocumented)
    readonly [Symbol.toStringTag]: string;
    constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
    // (undocumented)
    protected applyStashedOp(): void;
    static create(runtime: IFluidDataStoreRuntime, id?: string): SharedIntervalCollection;
    static getFactory(): IChannelFactory;
    // (undocumented)
    getIntervalCollection(label: string): IntervalCollection<Interval>;
    protected getIntervalCollectionPath(label: string): string;
    // (undocumented)
    protected loadCore(storage: IChannelStorageService): Promise<void>;
    // (undocumented)
    protected onDisconnect(): void;
    // (undocumented)
    protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
    // (undocumented)
    protected reSubmitCore(content: any, localOpMetadata: unknown): void;
    // (undocumented)
    protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
}

// @public @deprecated
export class SharedIntervalCollectionFactory implements IChannelFactory {
    // (undocumented)
    static readonly Attributes: IChannelAttributes;
    // (undocumented)
    get attributes(): IChannelAttributes;
    // (undocumented)
    create(runtime: IFluidDataStoreRuntime, id: string): SharedIntervalCollection;
    // (undocumented)
    load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedIntervalCollection>;
    // (undocumented)
    static readonly Type = "https://graph.microsoft.com/types/sharedIntervalCollection";
    // (undocumented)
    get type(): string;
}

// @public (undocumented)
export abstract class SharedSegmentSequence<T extends ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval>, MergeTreeRevertibleDriver {
    constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: IJSONSegment) => ISegment);
    annotateRange(start: number, end: number, props: PropertySet, combiningOp?: ICombiningOp): void;
    // (undocumented)
    protected applyStashedOp(content: any): unknown;
    // (undocumented)
    protected client: Client;
    createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined): LocalReferencePosition;
    // (undocumented)
    protected didAttach(): void;
    getContainingSegment(pos: number): {
        segment: T | undefined;
        offset: number | undefined;
    };
    // (undocumented)
    getCurrentSeq(): number;
    getIntervalCollection(label: string): IntervalCollection<SequenceInterval>;
    // (undocumented)
    getIntervalCollectionLabels(): IterableIterator<string>;
    getLength(): number;
    getPosition(segment: ISegment): number;
    // (undocumented)
    getPropertiesAtPosition(pos: number): PropertySet | undefined;
    // (undocumented)
    getRangeExtentsOfPosition(pos: number): {
        posStart: number | undefined;
        posAfterEnd: number | undefined;
    };
    // (undocumented)
    getStackContext(startPos: number, rangeLabels: string[]): RangeStackMap;
    // (undocumented)
    groupOperation(groupOp: IMergeTreeGroupMsg): void;
    // (undocumented)
    id: string;
    // (undocumented)
    protected initializeLocalCore(): void;
    insertAtReferencePosition(pos: ReferencePosition, segment: T): void;
    insertFromSpec(pos: number, spec: IJSONSegment): void;
    // (undocumented)
    protected loadCore(storage: IChannelStorageService): Promise<void>;
    // (undocumented)
    get loaded(): Promise<void>;
    protected loadedDeferred: Deferred<void>;
    localReferencePositionToPosition(lref: ReferencePosition): number;
    // (undocumented)
    protected onConnect(): void;
    // (undocumented)
    protected onDisconnect(): void;
    posFromRelativePos(relativePos: IRelativePosition): number;
    // (undocumented)
    protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
    protected processGCDataCore(serializer: SummarySerializer): void;
    removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition | undefined;
    // (undocumented)
    removeRange(start: number, end: number): IMergeTreeRemoveMsg;
    protected replaceRange(start: number, end: number, segment: ISegment): void;
    resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number | undefined;
    // (undocumented)
    protected reSubmitCore(content: any, localOpMetadata: unknown): void;
    // (undocumented)
    readonly segmentFromSpec: (spec: IJSONSegment) => ISegment;
    // (undocumented)
    submitSequenceMessage(message: IMergeTreeOp): void;
    // (undocumented)
    protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
    walkSegments<TClientData>(handler: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
}

// @public (undocumented)
export class SharedSequence<T> extends SharedSegmentSequence<SubSequence<T>> {
    constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, specToSegment: (spec: IJSONSegment) => ISegment);
    getItemCount(): number;
    getItems(start: number, end?: number): Serializable<T>[];
    // (undocumented)
    id: string;
    // (undocumented)
    insert(pos: number, items: Serializable<T>[], props?: PropertySet): void;
    // (undocumented)
    remove(start: number, end: number): void;
}

// @public
export class SharedString extends SharedSegmentSequence<SharedStringSegment> implements ISharedString {
    constructor(document: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
    annotateMarker(marker: Marker, props: PropertySet, combiningOp?: ICombiningOp): void;
    annotateMarkerNotifyConsensus(marker: Marker, props: PropertySet, callback: (m: Marker) => void): void;
    static create(runtime: IFluidDataStoreRuntime, id?: string): SharedString;
    findTile(startPos: number | undefined, tileLabel: string, preceding?: boolean): {
        tile: ReferencePosition;
        pos: number;
    } | undefined;
    static getFactory(): SharedStringFactory;
    getMarkerFromId(id: string): ISegment | undefined;
    getText(start?: number, end?: number): string;
    // (undocumented)
    getTextRangeWithMarkers(start: number, end: number): string;
    getTextWithPlaceholders(start?: number, end?: number): string;
    // (undocumented)
    id: string;
    insertMarker(pos: number, refType: ReferenceType, props?: PropertySet): IMergeTreeInsertMsg | undefined;
    insertMarkerRelative(relativePos1: IRelativePosition, refType: ReferenceType, props?: PropertySet): void;
    insertText(pos: number, text: string, props?: PropertySet): void;
    insertTextRelative(relativePos1: IRelativePosition, text: string, props?: PropertySet): void;
    // (undocumented)
    get ISharedString(): ISharedString;
    removeText(start: number, end: number): IMergeTreeRemoveMsg;
    replaceText(start: number, end: number, text: string, props?: PropertySet): void;
    protected rollback(content: any, localOpMetadata: unknown): void;
}

// @public (undocumented)
export class SharedStringFactory implements IChannelFactory {
    // (undocumented)
    static readonly Attributes: IChannelAttributes;
    // (undocumented)
    get attributes(): IChannelAttributes;
    // (undocumented)
    create(document: IFluidDataStoreRuntime, id: string): SharedString;
    // (undocumented)
    load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<SharedString>;
    // (undocumented)
    static segmentFromSpec(spec: any): SharedStringSegment;
    // (undocumented)
    static Type: string;
    // (undocumented)
    get type(): string;
}

// @public (undocumented)
export type SharedStringSegment = TextSegment | Marker;

// @public (undocumented)
export class SubSequence<T> extends BaseSegment {
    constructor(items: Serializable<T>[]);
    // (undocumented)
    append(segment: ISegment): void;
    // (undocumented)
    canAppend(segment: ISegment): boolean;
    // (undocumented)
    clone(start?: number, end?: number): SubSequence<T>;
    // (undocumented)
    protected createSplitSegmentAt(pos: number): SubSequence<T> | undefined;
    // (undocumented)
    static fromJSONObject<U>(spec: Serializable): SubSequence<U> | undefined;
    // (undocumented)
    static is(segment: ISegment): segment is SubSequence<any>;
    // (undocumented)
    items: Serializable<T>[];
    // (undocumented)
    removeRange(start: number, end: number): boolean;
    // (undocumented)
    toJSONObject(): IJSONRunSegment<T>;
    // (undocumented)
    toString(): string;
    // (undocumented)
    readonly type: string;
    // (undocumented)
    static readonly typeString: string;
}