Skip to main content
Version: v1

SharedSegmentSequence Class

Signature

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

Extends: SharedObject<ISharedSegmentSequenceEvents

Implements: ISharedIntervalCollection<SequenceInterval

Type Parameters

Parameter Constraint Description
T ISegment

Constructors

Constructor Description
(constructor)(dataStoreRuntime, id, attributes, segmentFromSpec) Constructs a new instance of the SharedSegmentSequence class

Properties

Property Type Description
client Client
id string
loaded Promise<void>
loadedDeferred Deferred<void>
segmentFromSpec (spec: IJSONSegment) => ISegment

Methods

Method Alerts Return Type Description
addLocalReference(lref) Deprecated void
annotateRange(start, end, props, combiningOp) void Annotates the range with the provided properties
applyStashedOp(content) unknown Apply changes from an op. Used when rehydrating an attached container with pending changes. This prepares the SharedObject for seeing an ACK for the op or resubmitting the op upon reconnection.
createLocalReferencePosition(segment, offset, refType, properties) LocalReferencePosition
createPositionReference(segment, offset, refType) Deprecated LocalReference
didAttach() void
getContainingSegment(pos) { segment: T; offset: number; }
getCurrentSeq() number
getIntervalCollection(label) IntervalCollection<SequenceInterval>
getIntervalCollectionLabels() IterableIterator<string>
getLength() number Returns the length of the current sequence for the client
getPosition(segment) number Returns the current position of a segment, and -1 if the segment does not exist in this sequence
getPropertiesAtPosition(pos) PropertySet
getRangeExtentsOfPosition(pos) { posStart: number; posAfterEnd: number; }
getStackContext(startPos, rangeLabels) RangeStackMap
groupOperation(groupOp) void
initializeLocalCore() void
insertAtReferencePosition(pos, segment) void
loadCore(storage) Promise<void>
localReferencePositionToPosition(lref) number
localRefToPos(localRef) Deprecated number
onConnect() void
onDisconnect() void
posFromRelativePos(relativePos) number Given a position specified relative to a marker id, lookup the marker and convert the position to a character position.
processCore(message, local, localOpMetadata) void
processGCDataCore(serializer) void Runs serializer over the GC data for this SharedMatrix. All the IFluidHandle's represent routes to other objects.
removeLocalReference(lref) Deprecated LocalReferencePosition
removeLocalReferencePosition(lref) LocalReferencePosition
removeRange(start, end) IMergeTreeRemoveMsg
replaceRange(start, end, segment) void 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 or reverse range (start \>= end), insert at end do not remove anything
resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId) number Resolves a remote client's position against the local sequence and returns the remote client's position relative to the local sequence. The client ref seq must be above the minimum sequence number or the return value will be undefined. Generally this method is used in conjunction with signals which provide point in time values for the below parameters, and is useful for things like displaying user position. It should not be used with persisted values as persisted values will quickly become invalid as the remoteClientRefSeq moves below the minimum sequence number
reSubmitCore(content, localOpMetadata) void
submitSequenceMessage(message) void
summarizeCore(serializer, telemetryContext) ISummaryTreeWithStats
waitIntervalCollection(label) Deprecated Promise<IntervalCollection<SequenceInterval>>
walkSegments(handler, start, end, accum, splitRange) void 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.

Constructor Details

(constructor)

Constructs a new instance of the SharedSegmentSequence class

Signature

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

Parameters

Parameter Type Description
dataStoreRuntime IFluidDataStoreRuntime
id string
attributes IChannelAttributes
segmentFromSpec (spec: IJSONSegment) => ISegment

Property Details

client

Signature

protected client: Client;

Type: Client

id

Signature

id: string;

Type: string

loaded

Signature

get loaded(): Promise<void>;

Type: Promise<void>

loadedDeferred

Signature

protected loadedDeferred: Deferred<void>;

Type: Deferred<void>

segmentFromSpec

Signature

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

Type: (spec: IJSONSegment) => ISegment

Method Details

addLocalReference

This API is deprecated and will be removed in a future release.
  • use createLocalReferencePosition

Signature

addLocalReference(lref: LocalReference): void;

Parameters

Parameter Type Description
lref LocalReference

annotateRange

Annotates the range with the provided properties

Signature

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

Parameters

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

applyStashedOp

Apply changes from an op. Used when rehydrating an attached container with pending changes. This prepares the SharedObject for seeing an ACK for the op or resubmitting the op upon reconnection.

Signature

protected applyStashedOp(content: any): unknown;

Parameters

Parameter Type Description
content any Contents of a stashed op.

Returns

localMetadata of the op, to be passed to process() or resubmit() when the op is ACKed or resubmitted, respectively

Return type: unknown

createLocalReferencePosition

Signature

createLocalReferencePosition(segment: T, offset: number, refType: ReferenceType, properties: PropertySet | undefined): LocalReferencePosition;

Parameters

Parameter Type Description
segment T
offset number
refType ReferenceType
properties PropertySet | undefined

Returns

Return type: LocalReferencePosition

createPositionReference

This API is deprecated and will be removed in a future release.
  • use createLocalReferencePosition

Signature

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

Parameters

Parameter Type Description
segment T
offset number
refType ReferenceType

Returns

Return type: LocalReference

didAttach

Signature

protected didAttach(): void;

getContainingSegment

Signature

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

Parameters

Parameter Type Description
pos number

Returns

Return type: { segment: T; offset: number; }

getCurrentSeq

Signature

getCurrentSeq(): number;

Returns

Return type: number

getIntervalCollection

Signature

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

Parameters

Parameter Type Description
label string

Returns

Return type: IntervalCollection<SequenceInterval>

getIntervalCollectionLabels

Signature

getIntervalCollectionLabels(): IterableIterator<string>;

Returns

an iterable object that enumerates the IntervalCollection labels Usage: const iter = this.getIntervalCollectionKeys(); for (key of iter) const collection = this.getIntervalCollection(key); ...

Return type: IterableIterator<string>

getLength

Returns the length of the current sequence for the client

Signature

getLength(): number;

Returns

Return type: number

getPosition

Returns the current position of a segment, and -1 if the segment does not exist in this sequence

Signature

getPosition(segment: ISegment): number;

Parameters

Parameter Type Description
segment ISegment The segment to get the position of

Returns

Return type: number

getPropertiesAtPosition

Signature

getPropertiesAtPosition(pos: number): PropertySet;

Parameters

Parameter Type Description
pos number

Returns

Return type: PropertySet

getRangeExtentsOfPosition

Signature

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

Parameters

Parameter Type Description
pos number

Returns

Return type: { posStart: number; posAfterEnd: number; }

getStackContext

Signature

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

Parameters

Parameter Type Description
startPos number
rangeLabels string[]

Returns

Return type: RangeStackMap

groupOperation

Signature

groupOperation(groupOp: IMergeTreeGroupMsg): void;

Parameters

Parameter Type Description
groupOp IMergeTreeGroupMsg

initializeLocalCore

Signature

protected initializeLocalCore(): void;

insertAtReferencePosition

Signature

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

Parameters

Parameter Type Description
pos ReferencePosition
segment T

loadCore

Signature

protected loadCore(storage: IChannelStorageService): Promise<void>;

Parameters

Parameter Type Description
storage IChannelStorageService

Returns

Return type: Promise<void>

localReferencePositionToPosition

Signature

localReferencePositionToPosition(lref: ReferencePosition): number;

Parameters

Parameter Type Description
lref ReferencePosition

Returns

Return type: number

localRefToPos

This API is deprecated and will be removed in a future release.
  • use localReferencePositionToPosition

Signature

localRefToPos(localRef: LocalReference): number;

Parameters

Parameter Type Description
localRef LocalReference

Returns

Return type: number

onConnect

Signature

protected onConnect(): void;

onDisconnect

Signature

protected onDisconnect(): void;

posFromRelativePos

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

Signature

posFromRelativePos(relativePos: IRelativePosition): number;

Parameters

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

Returns

Return type: number

processCore

Signature

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

Parameters

Parameter Type Description
message ISequencedDocumentMessage
local boolean
localOpMetadata unknown

processGCDataCore

Runs serializer over the GC data for this SharedMatrix. All the IFluidHandle's represent routes to other objects.

Signature

protected processGCDataCore(serializer: SummarySerializer): void;

Parameters

Parameter Type Description
serializer SummarySerializer

removeLocalReference

This API is deprecated and will be removed in a future release.
  • use removeLocalReferencePosition

Signature

removeLocalReference(lref: LocalReference): LocalReferencePosition;

Parameters

Parameter Type Description
lref LocalReference

Returns

Return type: LocalReferencePosition

removeLocalReferencePosition

Signature

removeLocalReferencePosition(lref: LocalReferencePosition): LocalReferencePosition;

Parameters

Parameter Type Description
lref LocalReferencePosition

Returns

Return type: LocalReferencePosition

removeRange

Signature

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

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

Return type: 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 or reverse range (start >= end), insert at end do not remove anything

Signature

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

Parameters

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

resolveRemoteClientPosition

Resolves a remote client's position against the local sequence and returns the remote client's position relative to the local sequence. The client ref seq must be above the minimum sequence number or the return value will be undefined. Generally this method is used in conjunction with signals which provide point in time values for the below parameters, and is useful for things like displaying user position. It should not be used with persisted values as persisted values will quickly become invalid as the remoteClientRefSeq moves below the minimum sequence number

Signature

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

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

Return type: number

reSubmitCore

Signature

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

Parameters

Parameter Type Description
content any
localOpMetadata unknown

submitSequenceMessage

Signature

submitSequenceMessage(message: IMergeTreeOp): void;

Parameters

Parameter Type Description
message IMergeTreeOp

summarizeCore

Signature

protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;

Parameters

Parameter Modifiers Type Description
serializer IFluidSerializer
telemetryContext optional ITelemetryContext

Returns

Return type: ISummaryTreeWithStats

waitIntervalCollection

This API is deprecated and will be removed in a future release.
  • IntervalCollections are created on a first-write wins basis, and concurrent creates are supported. Use getIntervalCollection instead.

Signature

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

Parameters

Parameter Type Description
label string

Returns

Return type: 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: ISegmentAction<TClientData>, start?: number, end?: number, accum?: TClientData, splitRange?: boolean): void;
Type Parameters
Parameter Description
TClientData

Parameters

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