@fluidframework/sequence Package

Packages > @fluidframework/sequence

Supports distributed data structures which are list-like.

This library’s main export is SharedSequence, a DDS for storing and simultaneously editing a sequence of text.

Remarks

Note that SharedString is a sequence DDS but it has additional specialized features and behaviors for working with text.

Interfaces

Interface Description
IIntervalCollectionEvent
IIntervalHelpers
IJSONRunSegment
IntervalLocator Information that identifies an interval within a Sequence.
ISequenceDeltaRange A range that has changed corresponding to a segment modification.
ISerializableInterval
ISerializedInterval
ISharedIntervalCollection
ISharedSegmentSequenceEvents Events emitted in response to changes to the sequence data.
ISharedString Fluid object interface describing access methods on a SharedString

Classes

Class Alerts Description
Interval
IntervalCollection
IntervalCollectionIterator
PaddingSegment DEPRECATED An empty segment that occupies 'cachedLength' positions. SparseMatrix uses PaddingSegment to "pad" a run of unoccupied cells.
RunSegment DEPRECATED
SequenceDeltaEvent

The event object returned on sequenceDelta events.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into consideration any future modifications performed to the underlying sequence and merge tree.

For group ops, each op will get its own event, and the group op property will be set on the op args.

Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.

SequenceEvent

Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into any future modifications performed to the underlying sequence and merge tree.

SequenceInterval
SequenceMaintenanceEvent

The event object returned on maintenance events.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into consideration any future modifications performed to the underlying sequence and merge tree.

SharedIntervalCollection DEPRECATED
SharedIntervalCollectionFactory DEPRECATED The factory that defines the SharedIntervalCollection.
SharedNumberSequence DEPRECATED The SharedNumberSequence holds a sequence of numbers. Each number will be stored at a position within the sequence. See the sequence documentation for details on working with sequences.
SharedNumberSequenceFactory DEPRECATED
SharedObjectSequence DEPRECATED The SharedObjectSequence holds a sequence of serializable objects. Each object will be stored at a position within the sequence. See the sequence documentation for details on working with sequences.
SharedObjectSequenceFactory DEPRECATED
SharedSegmentSequence
SharedSequence
SharedString

The Shared String is a specialized data structure for handling collaborative text. It is based on a more general Sequence data structure but has additional features that make working with text easier.

In addition to text, a Shared String can also contain markers. Markers can be used to store metadata at positions within the text, like the details of an image or Fluid object that should be rendered with the text.

SharedStringFactory
SparseMatrix DEPRECATED
SparseMatrixFactory DEPRECATED
SubSequence

Enumerations

Enum Description
IntervalType

Types

TypeAlias Alerts Description
CompressedSerializedInterval

A size optimization to avoid redundantly storing keys when serializing intervals as JSON. Intervals are of the format:

[start, end, sequenceNumber, intervalType, properties]

DeserializeCallback
MatrixSegment DEPRECATED
SharedStringSegment
SparseMatrixItem DEPRECATED

Functions

Function Alerts Return Type Description
getTextAndMarkers { parallelText: string[]; parallelMarkers: Marker[]; } Splits the text into regions ending with markers with the given label.
intervalLocatorFromEndpoint IntervalLocator | undefined Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.
positionToRowCol DEPRECATED { row: number; col: number; }

Variables

Variable Alerts Description
maxCellPosition DEPRECATED
maxCol DEPRECATED
maxCols DEPRECATED
maxRow DEPRECATED
maxRows DEPRECATED
rowColToPosition DEPRECATED

Enumeration Details

IntervalType

Signature

export declare enum IntervalType 

Flags

Flag Description
Nest
Simple
SlideOnRemove SlideOnRemove indicates that the ends of the interval will slide if the segment they reference is removed and acked. See packages\dds\merge-tree\REFERENCEPOSITIONS.md for details SlideOnRemove is the default interval behavior and does not need to be specified.

FlagDetails

Nest
Signature
Nest = 1
Simple
Signature
Simple = 0
SlideOnRemove

SlideOnRemove indicates that the ends of the interval will slide if the segment they reference is removed and acked. See packages\dds\merge-tree\REFERENCEPOSITIONS.md for details SlideOnRemove is the default interval behavior and does not need to be specified.

Signature
SlideOnRemove = 2

Type Details

CompressedSerializedInterval

A size optimization to avoid redundantly storing keys when serializing intervals as JSON. Intervals are of the format:

[start, end, sequenceNumber, intervalType, properties]

Signature

export declare type CompressedSerializedInterval = [number, number, number, IntervalType, PropertySet];

DeserializeCallback

Signature

export declare type DeserializeCallback = (properties: PropertySet) => void;

MatrixSegment

Deprecated

MatrixSegment is part of an abandoned prototype. Use SharedMatrix instead.

Signature

export declare type MatrixSegment = RunSegment | PaddingSegment;

SharedStringSegment

Signature

export declare type SharedStringSegment = TextSegment | Marker;

SparseMatrixItem

Deprecated

SparseMatrixItem is part of an abandoned prototype. Use SharedMatrix instead.

Signature

export declare type SparseMatrixItem = Serializable;

Function Details

getTextAndMarkers

Splits the text into regions ending with markers with the given label.

Signature

export declare function getTextAndMarkers(sharedString: SharedString, label: string): {
    parallelText: string[];
    parallelMarkers: Marker[];
};

Parameters

Parameter Type Description
sharedString SharedString String to retrieve text and markers from
label string label to split on

Returns

Two parallel lists of text and markers, split by markers with the provided label.

For example:

// Say sharedstring has contents "hello<paragraph marker 1>world<paragraph marker 2>missing".
const { parallelText, parallelMarkers } = getTextAndMarkers(sharedString, "paragraph");
// parallelText === ["hello", "world"]
// parallelMarkers === [<paragraph marker 1 object>, <paragraph marker 2 object>]
// Note parallelText does not include "missing".

Return type: { parallelText: string[]; parallelMarkers: Marker[]; }

intervalLocatorFromEndpoint

Returns an object that can be used to find the interval a given LocalReferencePosition belongs to.

Signature

export declare function intervalLocatorFromEndpoint(potentialEndpoint: LocalReferencePosition): IntervalLocator | undefined;

Parameters

Parameter Type Description
potentialEndpoint LocalReferencePosition

Returns

undefined if the reference position is not the endpoint of any interval (e.g. it was created on the merge tree directly by app code), otherwise an IntervalLocator for the interval this endpoint is a part of.

Return type: IntervalLocator | undefined

positionToRowCol

Deprecated

positionToRowCol is part of an abandoned prototype. Use SharedMatrix instead.

Signature

export declare function positionToRowCol(position: number): {
    row: number;
    col: number;
};

Parameters

Parameter Type Description
position number

Returns

Return type: { row: number; col: number; }

Variable Details

maxCellPosition

Deprecated

maxCellPosition is part of an abandoned prototype. Use SharedMatrix instead.

Signature

maxCellPosition: number

maxCol

Deprecated

maxCol is part of an abandoned prototype. Use SharedMatrix instead.

Signature

maxCol = 2097152

maxCols

Deprecated

maxCols is part of an abandoned prototype. Use SharedMatrix instead.

Signature

maxCols: number

maxRow

Deprecated

maxRow is part of an abandoned prototype. Use SharedMatrix instead.

Signature

maxRow = 4294967295

maxRows

Deprecated

maxRows is part of an abandoned prototype. Use SharedMatrix instead.

Signature

maxRows: number

rowColToPosition

Deprecated

positionToRowCol is part of an abandoned prototype. Use SharedMatrix instead.

Signature

rowColToPosition: (row: number, col: number) => number