crdt_lf library

Classes

BaseCRDTDocument
Defines the foundational contract for a CRDT document.
Change
Change implementation for CRDT.
ChangeCodec
Versioned binary framing for a list of encoded changes.
ChangeStore
ChangeStore implementation for CRDT
ComposableDelta<D>
A delta that can be folded together with the delta that follows it.
ContainerHandler
Marker interface implemented by handlers that store HandlerRefs pointing at other handlers, forming a nested tree over the flat document registry.
CRDTDocument
CRDT Document implementation
CRDTDocumentEvent
One move of the durable state of a CRDTDocument: the changes it holds and the snapshot they are replayed on top of.
CRDTFugueListHandler<T>
CRDT List with Fugue implementation
CRDTFugueMovableListHandler<T>
CRDT List with Fugue implementation and movable elements
CRDTFugueTextHandler
CRDT Text with Fugue implementation
CRDTListHandler<T>
CRDT List
CRDTListRefHandler
CRDT ordered list of references
CRDTMapHandler<T>
CRDT Map
CRDTMapRefHandler
CRDT Map of references
CRDTMovableListRefHandler
CRDT movable ordered list of references
CRDTORMapHandler<K, V>
CRDT OR-Map
CRDTORSetHandler<T>
CRDT OR-Set
CRDTRegisterHandler<T>
CRDT Register (last-writer-wins)
CRDTTextHandler
CRDT Text
CRDTUndoManager
Undo and redo for the local edits of a CRDTDocument.
DAG
DAG (Directed Acyclic Graph) implementation for CRDT
DAGNode
Directed Acyclic Graph (DAG) Node implementation for CRDT
DeltaSink<D>
Collects the positional effects of applying operations, one delta of type D at a time.
DeltaSyncPoint<V>
A value together with the point of the delta stream it reflects.
DiffSegment
A single diff segment with an operation and the associated text.
DocumentChangesApplied
changes entered the document's change store.
DocumentHistoryPruned
History was pruned: the changes covered by upTo left the store.
DocumentSnapshotUpdated
The document's snapshot is now snapshot.
Frontiers
Frontiers implementation for CRDT
FugueElementID
Represents the ID of an element in the Fugue algorithm
FugueElementIDReadResult
Result of decoding a FugueElementID from a byte buffer.
FugueListState<T>
State of the CRDTFugueListHandler: the list of all live node values.
FugueMovableListState<T>
State of a CRDTFugueMovableListHandler.
FugueTextState
State of the CRDTFugueTextHandler: the text is the concatenation of all live node values.
Handler<T>
Abstract class for CRDT handlers
HandlerDelta<D>
The observable state of the handler moved by delta.
HandlerRef
A serializable reference to another Handler.
HandlerRefCodec
ValueCodec for HandlerRef.
HandlerReset<D>
The observable state is no longer reachable by delta: read it again.
HandlerUpdate<D>
One event in the delta stream of a handler.
HistorySession
An interactive controller for navigating the history of a CRDTDocument.
JsonValueCodec<T>
Default JSON-based value codec.
MapDelta<K, V>
How a map handler's value moved, as one entry per touched key.
MapEntryChange<T>
What happened to one key of a map.
MapEntryRemoved<T>
The key is gone.
MapEntrySet<T>
The key now holds value.
Operation
Abstract class for operations
OperationEnvelope
Decoded operation envelope metadata.
OperationEnvelopeCodec
Binary envelope for operations.
OperationId
OperationId implementation for CRDT
OperationType
The kind of change an operation applies, scoped to the handler that owns it.
OpIdKey
Packed key representation for an OperationId.
ORMapEntry<V>
Entry in the OR-Map representing a (value, tag) pair
ORMapState<K, V>
State of the CRDTORMapHandler
ORSetState<T>
State of the CRDTORSetHandler
PeerId
PeerId implementation for CRDT
RegisterDelta<T>
How a register handler's value moved.
RuneOffsets
Conversions between UTF-16 code unit and runes.
SeqDelete<T>
Takes count elements out of the sequence at the current point.
SeqInsert<T>
Puts values into the sequence at the current point.
SeqMove<T>
Moves the element at from to to, keeping its identity.
SeqOp<T>
One step of a SequenceDelta.
SeqRetain<T>
Keeps count elements as they are and moves past them.
SequenceDelta<T>
How a sequence handler's value moved, as steps applied left to right.
SetDelta<T>
How a set handler's value moved.
Snapshot
Represents a snapshot of a CRDTDocument's state at a specific version.
UVarint
Unsigned Varint encoding utilities.
UVarintResult
Result of decoding an unsigned varint.
ValueCodec<T>
Codec for encoding/decoding generic values into bytes.
VersionVector
A version vector is a map of PeerIds to their corresponding HybridLogicalClock.
Wtf8
WTF-8 (Wobbly Transformation Format 8-bit) codec.

Enums

ChangeSource
Where a batch of Changes came from.
DiffOp
Diff operation types.
ResetCause
Why a HandlerReset was emitted.
SnapshotReason
Why the document's snapshot was replaced.

Mixins

CacheableStateProvider<T>
Per-consumer state cache that avoids recomputing the consumer's state from the full history on every read.
DeltaProvider<V, D extends ComposableDelta<D>>
Publishes what a handler's observable state did, one event per Change.
DocumentConsumer
A consumer that can consume a CRDTDocument
RebuiltIdentities<K extends Object>
Follows an identity through the new ones an undo had to give it.
SnapshotProvider
A provider that can provide a snapshot of the state of a CRDTDocument

Extensions

ChangeIterable on Iterable<Change>
Utilities on Iterable of Changes
ChangeList on List<Change>
Utilities on List of Changes
RegisterDefaultFactories on BaseCRDTDocument
Convenience registration of the built-in factories needed to reconstruct nested documents: the three container handlers plus the non-generic leaf handlers (CRDTTextHandler, CRDTFugueTextHandler).
SeqInsertText on SeqInsert<String>
String conveniences for the insert step the text handlers emit.
SequenceDeltaText on SequenceDelta<String>
String conveniences for the delta shape the text handlers emit.

Properties

peerIdRegex → RegExp
A regular expression for validating PeerIds
final

Functions

compareChangeOrder(Change a, Change b) → int
Orders two Changes first by hlc, then by author.
myersDiff(String oldText, String newText) → List<DiffSegment>
Compute Myers diff between two strings and return coalesced segments of Equal, Insert, and Remove operations.
nestedValueOf(Handler handler, Set<String> visiting) → Object?
Resolves handler to a plain value: recurses through ContainerHandlers and reads value from the built-in leaf handlers (text, list, map, ...).
seqInsertText(String text) → SeqInsert<String>
Inserts text one rune at a time.
setEquals<T>(Set<T>? a, Set<T>? b) → bool
Checks if two sets are equal
typedRef<T extends Handler>(Handler? reference) → T?
Casts an already-resolved reference to the handler type T, returning null when it is null or not a T.

Typedefs

HandlerFactory = Handler Function(BaseCRDTDocument doc, String id)
A factory that instantiates a Handler of a specific runtime type for a given BaseCRDTDocument and handler id.
OperationDecoders = Map<int, Operation Function(Uint8List body)>
A per-kind decoder, keyed by OperationEnvelope.kind.

Exceptions / Errors

CausallyNotReadyException
Thrown when a change cannot be applied because its causal dependencies (previous changes) are not yet present in the document's history.
ChangesCycleException
Thrown when a cycle is detected in the dependency graph of changes, which would violate the causal ordering of operations.
CrdtException
Base exception for all CRDT-related errors.
DocumentDisposedException
Thrown when attempting to execute a method on a disposed document.
DuplicateNodeException
Thrown when attempting to add a node (e.g., a change or an element) to a data structure that already contains a node with the same identifier.
HandlerAlreadyRegisteredException
Thrown when attempting to register a handler that already exists.
MissingDependencyException
Thrown when a change references a dependency that does not exist in the document's history (the DAG).
ReadOnlyDocumentException
Thrown when attempting to execute a method on a read-only document.
UnknownOperationKindException
Thrown when a change addressed to this handler carries an operation kind this build cannot decode.