Skip to content 

SharedSegmentSequence Class

Packages > @fluidframework/sequence > SharedSegmentSequence

Signature:

export declare abstract class SharedSegmentSequence<T extends MergeTree.ISegment> extends SharedObject<ISharedSegmentSequenceEvents> implements ISharedIntervalCollection<SequenceInterval> 

Extends: SharedObject<ISharedSegmentSequenceEvents>

Implements: ISharedIntervalCollection<SequenceInterval>

Constructors

List of constructors for this class
Constructor Modifiers Description
(constructor)(dataStoreRuntime, id, attributes, segmentFromSpec) Constructs a new instance of the SharedSegmentSequence class

Properties

List of properties for this class
Property Modifiers Type Description
client MergeTree.Client
id string
loaded Promise
loadedDeferred Deferred
segmentFromSpec (spec: MergeTree.IJSONSegment) => MergeTree.ISegment

Methods

List of methods on this class
Method Modifiers Description
addLocalReference(lref)
annotateRange(start, end, props, combiningOp) Annotates the range with the provided properties
copy(start, end, register) Puts the content of the range in a register
createPositionReference(segment, offset, refType)
cut(start, end, register) Removes the range and puts the content of the removed range in a register
didAttach()
getContainingSegment(pos)
getCurrentSeq()
getIntervalCollection(label)
getLength() Returns the length of the current sequence for the client
getPosition(segment)
getPropertiesAtPosition(pos)
getRangeExtentsOfPosition(pos)
getStackContext(startPos, rangeLabels)
groupOperation(groupOp)
initializeLocalCore()
insertAtReferencePosition(pos, segment)
loadCore(branchId, storage)
localRefToPos(localRef)
onConnect()
onDisconnect()
paste(pos, register) Inserts the content of the register.
posFromRelativePos(relativePos) Given a position specified relative to a marker id, lookup the marker and convert the position to a character position.
processCore(message, local, localOpMetadata)
registerCore()
removeLocalReference(lref)
removeRange(start, end)
replaceRange(start, end, segment) Replace the range specified from start to end with the provided segment This is done by inserting the segment at the end of the range, followed by removing the contents of the range For a zero range (start == end), insert at end do not remove anything For a reverse range (start > end), insert the segment at the greater of start/end and allow Client to attempt to remove the range
resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId) Resolves a remote client's position against the local sequence and returns the remote client's position relative to the local sequence
reSubmitCore(content, localOpMetadata)
snapshot()
submitSequenceMessage(message)
waitIntervalCollection(label)
walkSegments(handler, start, end, accum, splitRange) Walk the underlying segments of the sequence. The walked segments may extend beyond the range if the segments cross the ranges start or end boundaries. Set split range to true to ensure only segments within the range are walked.

Constructors

SharedSegmentSequence.(constructor)

Constructs a new instance of the SharedSegmentSequence class

Signature:

constructor(dataStoreRuntime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes, segmentFromSpec: (spec: MergeTree.IJSONSegment) => MergeTree.ISegment);

Parameters

List of parameters
Parameter Type Description
dataStoreRuntime IFluidDataStoreRuntime
id string
attributes IChannelAttributes
segmentFromSpec (spec: MergeTree.IJSONSegment) => MergeTree.ISegment

Properties

client

Signature:

protected client: MergeTree.Client;

id

Signature:

id: string;

loaded

Signature:

get loaded(): Promise<void>;

loadedDeferred

Signature:

protected loadedDeferred: Deferred<void>;

segmentFromSpec

Signature:

readonly segmentFromSpec: (spec: MergeTree.IJSONSegment) => MergeTree.ISegment;

Methods

addLocalReference

Signature:

addLocalReference(lref: any): void;

Parameters

List of parameters
Parameter Type Description
lref any

Returns:

void

annotateRange

Annotates the range with the provided properties

Signature:

annotateRange(start: number, end: number, props: MergeTree.PropertySet, combiningOp?: MergeTree.ICombiningOp): void;

Parameters

List of parameters
Parameter Type Description
start number The inclusive start postition of the range to annotate
end number The exclusive end position of the range to annotate
props MergeTree.PropertySet The properties to annotate the range with
combiningOp MergeTree.ICombiningOp Optional. Specifies how to combine values for the property, such as "incr" for increment.

Returns:

void

copy

Puts the content of the range in a register

Signature:

copy(start: number, end: number, register: string): void;

Parameters

List of parameters
Parameter Type Description
start number The inclusive start of the range
end number The exclusive end of the range
register string The name of the register to store the range in

Returns:

void

createPositionReference

Signature:

createPositionReference(segment: T, offset: number, refType: MergeTree.ReferenceType): MergeTree.LocalReference;

Parameters

List of parameters
Parameter Type Description
segment T
offset number
refType MergeTree.ReferenceType

Returns:

MergeTree.LocalReference

cut

Removes the range and puts the content of the removed range in a register

Signature:

cut(start: number, end: number, register: string): void;

Parameters

List of parameters
Parameter Type Description
start number The inclusive start of the range to remove
end number The exclusive end of the range to remove
register string The name of the register to store the removed range in

Returns:

void

didAttach

Signature:

protected didAttach(): void;

Returns:

void

getContainingSegment

Signature:

getContainingSegment(pos: number): {
        segment: T;
        offset: number;
    };

Parameters

List of parameters
Parameter Type Description
pos number

Returns:

{ segment: T; offset: number; }

getCurrentSeq

Signature:

getCurrentSeq(): number;

Returns:

number

getIntervalCollection

Signature:

getIntervalCollection(label: string): IntervalCollection<SequenceInterval>;

Parameters

List of parameters
Parameter Type Description
label string

Returns:

IntervalCollection<SequenceInterval>

getLength

Returns the length of the current sequence for the client

Signature:

getLength(): number;

Returns:

number

getPosition

Signature:

getPosition(segment: any): number;

Parameters

List of parameters
Parameter Type Description
segment any

Returns:

number

getPropertiesAtPosition

Signature:

getPropertiesAtPosition(pos: number): MergeTree.PropertySet;

Parameters

List of parameters
Parameter Type Description
pos number

Returns:

MergeTree.PropertySet

getRangeExtentsOfPosition

Signature:

getRangeExtentsOfPosition(pos: number): {
        posStart: number;
        posAfterEnd: number;
    };

Parameters

List of parameters
Parameter Type Description
pos number

Returns:

{ posStart: number; posAfterEnd: number; }

getStackContext

Signature:

getStackContext(startPos: number, rangeLabels: string[]): MergeTree.RangeStackMap;

Parameters

List of parameters
Parameter Type Description
startPos number
rangeLabels string[]

Returns:

MergeTree.RangeStackMap

groupOperation

Signature:

groupOperation(groupOp: MergeTree.IMergeTreeGroupMsg): void;

Parameters

List of parameters
Parameter Type Description
groupOp MergeTree.IMergeTreeGroupMsg

Returns:

void

initializeLocalCore

Signature:

protected initializeLocalCore(): void;

Returns:

void

insertAtReferencePosition

Signature:

insertAtReferencePosition(pos: MergeTree.ReferencePosition, segment: T): void;

Parameters

List of parameters
Parameter Type Description
pos MergeTree.ReferencePosition
segment T

Returns:

void

loadCore

Signature:

protected loadCore(branchId: string | undefined, storage: IChannelStorageService): Promise<void>;

Parameters

List of parameters
Parameter Type Description
branchId string | undefined
storage IChannelStorageService

Returns:

Promise<void>

localRefToPos

Signature:

localRefToPos(localRef: MergeTree.LocalReference): number;

Parameters

List of parameters
Parameter Type Description
localRef MergeTree.LocalReference

Returns:

number

onConnect

Signature:

protected onConnect(): void;

Returns:

void

onDisconnect

Signature:

protected onDisconnect(): void;

Returns:

void

paste

Inserts the content of the register.

Signature:

paste(pos: number, register: string): number;

Parameters

List of parameters
Parameter Type Description
pos number The postition to insert the content at.
register string The name of the register to get the content from

Returns:

number

posFromRelativePos

Given a position specified relative to a marker id, lookup the marker and convert the position to a character position.

Signature:

posFromRelativePos(relativePos: any): number;

Parameters

List of parameters
Parameter Type Description
relativePos any Id of marker (may be indirect) and whether position is before or after marker.

Returns:

number

processCore

Signature:

protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;

Parameters

List of parameters
Parameter Type Description
message ISequencedDocumentMessage
local boolean
localOpMetadata unknown

Returns:

void

registerCore

Signature:

protected registerCore(): void;

Returns:

void

removeLocalReference

Signature:

removeLocalReference(lref: any): void;

Parameters

List of parameters
Parameter Type Description
lref any

Returns:

void

removeRange

Signature:

removeRange(start: number, end: number): MergeTree.IMergeTreeRemoveMsg;

Parameters

List of parameters
Parameter Type Description
start number The inclusive start of the range to remove
end number The exclusive end of the range to remove

Returns:

MergeTree.IMergeTreeRemoveMsg

replaceRange

Replace the range specified from start to end with the provided segment This is done by inserting the segment at the end of the range, followed by removing the contents of the range For a zero range (start == end), insert at end do not remove anything For a reverse range (start > end), insert the segment at the greater of start/end and allow Client to attempt to remove the range

Signature:

protected replaceRange(start: number, end: number, segment: MergeTree.ISegment): void;

Parameters

List of parameters
Parameter Type Description
start number The start of the range to replace
end number The end of the range to replace
segment MergeTree.ISegment The segment that will replace the range

Returns:

void

resolveRemoteClientPosition

Resolves a remote client’s position against the local sequence and returns the remote client’s position relative to the local sequence

Signature:

resolveRemoteClientPosition(remoteClientPosition: number, remoteClientRefSeq: number, remoteClientId: string): number;

Parameters

List of parameters
Parameter Type Description
remoteClientPosition number The remote client's position to resolve
remoteClientRefSeq number The reference sequence number of the remote client
remoteClientId string The client id of the remote client

Returns:

number

reSubmitCore

Signature:

protected reSubmitCore(content: any, localOpMetadata: unknown): void;

Parameters

List of parameters
Parameter Type Description
content any
localOpMetadata unknown

Returns:

void

snapshot

Signature:

snapshot(): ITree;

Returns:

ITree

submitSequenceMessage

Signature:

submitSequenceMessage(message: MergeTree.IMergeTreeOp): void;

Parameters

List of parameters
Parameter Type Description
message MergeTree.IMergeTreeOp

Returns:

void

waitIntervalCollection

Signature:

waitIntervalCollection(label: string): Promise<IntervalCollection<SequenceInterval>>;

Parameters

List of parameters
Parameter Type Description
label string

Returns:

Promise<IntervalCollection<SequenceInterval>>

walkSegments

Walk the underlying segments of the sequence. The walked segments may extend beyond the range if the segments cross the ranges start or end boundaries. Set split range to true to ensure only segments within the range are walked.

Signature:

walkSegments<TClientData>(handler: MergeTree.ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;

Parameters

List of parameters
Parameter Type Description
handler MergeTree.ISegmentAction The function to handle each segment
start number Optional. The start of range walk.
end number Optional. The end of range walk
accum TClientData Optional. An object that will be passed to the handler for accumulation
splitRange boolean Optional. Splits boundary segments on the range boundaries

Returns:

void