Signature
export declare class MergeTree
Constructors
Static Properties
Property
Type
Description
options
{ incrementalUpdate: boolean; insertAfterRemovedSegs: boolean; zamboniSegments: boolean; }
Properties
Methods
Method
Alerts
Return Type
Description
ackPendingSegment(opArgs)
void
Assign sequence number to existing segment; update partial lengths to reflect the change
addLocalReference(lref)
Deprecated
void
addMinSeqListener(minRequired, onMinGE)
void
annotateRange(start, end, props, combiningOp, refSeq, clientId, seq, opArgs)
void
Annotate a range with properties
blockClone(block, segments)
MergeBlock
clone()
void
createLocalReferencePosition(segment, offset, refType, properties, client)
LocalReferencePosition
findTile(startPos, clientId, tileLabel, posPrecedesTile)
{ tile: ReferencePosition ; pos: number; } | undefined
getCollabWindow()
CollaborationWindow
getContainingSegment(pos, refSeq, clientId)
{ segment: T | undefined; offset: number | undefined; }
getLength(refSeq, clientId)
number
getMarkerFromId(id)
ISegment | undefined
getPosition(node, refSeq, clientId)
number
getStackContext(startPos, clientId, rangeLabels)
RangeStackMap
getStats()
MergeTreeStats
incrementalBlockMap(stateStack)
void
insertAtReferencePosition(referencePosition, insertSegment, opArgs)
void
insertSegments(pos, segments, refSeq, clientId, seq, opArgs)
void
localNetLength(segment)
number
map(actions, refSeq, clientId, accum)
void
mapIdToSegment(id, segment)
void
mapRange(actions, refSeq, clientId, accum, start, end, splitRange)
void
markRangeRemoved(start, end, refSeq, clientId, seq, overwrite, opArgs)
void
posFromRelativePos(relativePos, refseq, clientId)
number
Given a position specified relative to a marker id, lookup the marker and convert the position to a character position.
referencePositionToLocalPosition(refPos, refSeq, clientId)
number
reloadFromSegments(segments)
void
removeLocalReference(segment, lref)
Deprecated
void
removeLocalReferencePosition(lref)
LocalReferencePosition | undefined
resolveRemoteClientPosition(remoteClientPosition, remoteClientRefSeq, remoteClientId)
number | undefined
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
setMinSeq(minSeq)
void
startCollaboration(localClientId, minSeq, currentSeq)
void
walkAllSegments(block, action, accum)
boolean
Constructor Details
(constructor)
Constructs a new instance of the MergeTree
class
Signature
constructor ( options ? : PropertySet | undefined ) ;
Parameters
Parameter
Modifiers
Type
Description
options
optional
PropertySet | undefined
Property Details
collabWindow
Signature
readonly collabWindow : CollaborationWindow ;
Type: CollaborationWindow
length
Returns the current length of the MergeTree for the local client.
Signature
Type: number
mergeTreeDeltaCallback
Signature
mergeTreeDeltaCallback ? : MergeTreeDeltaCallback ;
Type: MergeTreeDeltaCallback
mergeTreeMaintenanceCallback
Signature
mergeTreeMaintenanceCallback ? : MergeTreeMaintenanceCallback ;
Type: MergeTreeMaintenanceCallback
options
Signature
options ? : PropertySet | undefined ;
Type: PropertySet | undefined
options
Signature
static readonly options : { incrementalUpdate : boolean ; insertAfterRemovedSegs : boolean ; zamboniSegments : boolean ; } ;
Type: { incrementalUpdate: boolean; insertAfterRemovedSegs: boolean; zamboniSegments: boolean; }
pendingSegments
Signature
pendingSegments : List < SegmentGroup > | undefined ;
Type: List <SegmentGroup > | undefined
root
Signature
Type: IMergeBlock
Method Details
ackPendingSegment
Assign sequence number to existing segment; update partial lengths to reflect the change
Signature
ackPendingSegment ( opArgs : IMergeTreeDeltaOpArgs ) : void ;
Parameters
addLocalReference
This API is deprecated and will be removed in a future release.
Signature
addLocalReference ( lref : LocalReference ) : void ;
Parameters
addMinSeqListener
Signature
addMinSeqListener ( minRequired : number , onMinGE : ( minSeq : number ) => void ) : void ;
Parameters
Parameter
Type
Description
minRequired
number
onMinGE
(minSeq: number) => void
annotateRange
Annotate a range with properties
Signature
annotateRange ( start : number , end : number , props : PropertySet , combiningOp : ICombiningOp | undefined , refSeq : number , clientId : number , seq : number , opArgs : IMergeTreeDeltaOpArgs ) : void ;
Parameters
Parameter
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
ICombiningOp | undefined
Optional. Specifies how to combine values for the property, such as "incr" for increment.
refSeq
number
The reference sequence number to use to apply the annotate
clientId
number
The id of the client making the annotate
seq
number
The sequence number of the annotate operation
opArgs
IMergeTreeDeltaOpArgs
The op args for the annotate op. this is passed to the merge tree callback if there is one
blockClone
Signature
blockClone ( block : IMergeBlock , segments ? : ISegment [ ] ) : MergeBlock ;
Parameters
Returns
Return type: MergeBlock
clone
Signature
createLocalReferencePosition
Signature
createLocalReferencePosition ( segment : ISegment , offset : number | undefined , refType : ReferenceType , properties : PropertySet | undefined , client : Client ) : LocalReferencePosition ;
Parameters
Returns
Return type: LocalReferencePosition
findTile
Signature
findTile ( startPos : number , clientId : number , tileLabel : string , posPrecedesTile ? : boolean ) : { tile : ReferencePosition ; pos : number ; } | undefined ;
Parameters
Parameter
Modifiers
Type
Description
startPos
number
clientId
number
tileLabel
string
posPrecedesTile
optional
boolean
Returns
Return type: { tile: ReferencePosition ; pos: number; } | undefined
getCollabWindow
Signature
getCollabWindow ( ) : CollaborationWindow ;
Returns
Return type: CollaborationWindow
getContainingSegment
Signature
getContainingSegment < T extends ISegment > ( pos : number , refSeq : number , clientId : number ) : { segment : T | undefined ; offset : number | undefined ; } ;
Type Parameters
Parameter
Constraint
Description
T
ISegment
Parameters
Parameter
Type
Description
pos
number
refSeq
number
clientId
number
Returns
Return type: { segment: T | undefined; offset: number | undefined; }
getLength
Signature
getLength ( refSeq : number , clientId : number ) : number ;
Parameters
Parameter
Type
Description
refSeq
number
clientId
number
Returns
Return type: number
getMarkerFromId
Signature
getMarkerFromId ( id : string ) : ISegment | undefined ;
Parameters
Parameter
Type
Description
id
string
Returns
Return type: ISegment | undefined
getPosition
Signature
getPosition ( node : MergeNode , refSeq : number , clientId : number ) : number ;
Parameters
Parameter
Type
Description
node
MergeNode
refSeq
number
clientId
number
Returns
Return type: number
getStackContext
Signature
getStackContext ( startPos : number , clientId : number , rangeLabels : string [ ] ) : RangeStackMap ;
Parameters
Parameter
Type
Description
startPos
number
clientId
number
rangeLabels
string[]
Returns
Return type: RangeStackMap
getStats
Signature
getStats ( ) : MergeTreeStats ;
Returns
Return type: MergeTreeStats
incrementalBlockMap
Signature
incrementalBlockMap < TContext > ( stateStack : Stack < IncrementalMapState < TContext >> ) : void ;
Type Parameters
Parameter
Description
TContext
Parameters
insertAtReferencePosition
Signature
insertAtReferencePosition ( referencePosition : ReferencePosition , insertSegment : ISegment , opArgs : IMergeTreeDeltaOpArgs ) : void ;
Parameters
insertSegments
Signature
insertSegments ( pos : number , segments : ISegment [ ] , refSeq : number , clientId : number , seq : number , opArgs : IMergeTreeDeltaOpArgs | undefined ) : void ;
Parameters
localNetLength
Signature
localNetLength ( segment : ISegment ) : number ;
Parameters
Parameter
Type
Description
segment
ISegment
Returns
Return type: number
map
Signature
map < TClientData > ( actions : SegmentActions < TClientData > , refSeq : number , clientId : number , accum : TClientData ) : void ;
Type Parameters
Parameter
Description
TClientData
Parameters
Parameter
Type
Description
actions
SegmentActions <TClientData>
refSeq
number
clientId
number
accum
TClientData
mapIdToSegment
Signature
mapIdToSegment ( id : string , segment : ISegment ) : void ;
Parameters
Parameter
Type
Description
id
string
segment
ISegment
mapRange
Signature
mapRange < TClientData > ( actions : SegmentActions < TClientData > , refSeq : number , clientId : number , accum : TClientData , start ? : number , end ? : number , splitRange ? : boolean ) : void ;
Type Parameters
Parameter
Description
TClientData
Parameters
Parameter
Modifiers
Type
Description
actions
SegmentActions <TClientData>
refSeq
number
clientId
number
accum
TClientData
start
optional
number
end
optional
number
splitRange
optional
boolean
markRangeRemoved
Signature
markRangeRemoved ( start : number , end : number , refSeq : number , clientId : number , seq : number , overwrite : boolean | undefined , opArgs : IMergeTreeDeltaOpArgs ) : void ;
Parameters
Parameter
Type
Description
start
number
end
number
refSeq
number
clientId
number
seq
number
overwrite
boolean | undefined
opArgs
IMergeTreeDeltaOpArgs
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 , refseq ? : number , clientId ? : number ) : number ;
Parameters
Parameter
Modifiers
Type
Description
relativePos
IRelativePosition
Id of marker (may be indirect) and whether position is before or after marker.
refseq
optional
number
The reference sequence number at which to compute the position.
clientId
optional
number
The client id with which to compute the position.
Returns
Return type: number
referencePositionToLocalPosition
Signature
referencePositionToLocalPosition ( refPos : ReferencePosition , refSeq ? : number , clientId ? : number ) : number ;
Parameters
Parameter
Modifiers
Type
Description
refPos
ReferencePosition
refSeq
optional
number
clientId
optional
number
Returns
Return type: number
reloadFromSegments
Signature
reloadFromSegments ( segments : ISegment [ ] ) : void ;
Parameters
Parameter
Type
Description
segments
ISegment []
removeLocalReference
This API is deprecated and will be removed in a future release.
use removeLocalReferencePosition
Signature
removeLocalReference ( segment : ISegment , lref : LocalReference ) : void ;
Parameters
removeLocalReferencePosition
Signature
removeLocalReferencePosition ( lref : LocalReferencePosition ) : LocalReferencePosition | undefined ;
Parameters
Returns
Return type: LocalReferencePosition | undefined
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 : number ) : number | undefined ;
Parameters
Parameter
Type
Description
remoteClientPosition
number
The remote client's position to resolve
remoteClientRefSeq
number
The reference sequence number of the remote client
remoteClientId
number
The client id of the remote client
Returns
Return type: number | undefined
setMinSeq
Signature
setMinSeq ( minSeq : number ) : void ;
Parameters
Parameter
Type
Description
minSeq
number
startCollaboration
Signature
startCollaboration ( localClientId : number , minSeq : number , currentSeq : number ) : void ;
Parameters
Parameter
Type
Description
localClientId
number
minSeq
number
currentSeq
number
walkAllSegments
Signature
walkAllSegments < TClientData > ( block : IMergeBlock , action : ( segment : ISegment , accum ? : TClientData ) => boolean , accum ? : TClientData ) : boolean ;
Type Parameters
Parameter
Description
TClientData
Parameters
Parameter
Modifiers
Type
Description
block
IMergeBlock
action
(segment: ISegment , accum?: TClientData) => boolean
accum
optional
TClientData
Returns
Return type: boolean