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
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
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
DAG
DAG (Directed Acyclic Graph) implementation for CRDT
DAGNode
Directed Acyclic Graph (DAG) Node implementation for CRDT
DiffSegment
A single diff segment with an operation and the associated text.
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.
FugueNode<T>
Represents a node in the FugueTree
FugueNodeTriple<T>
Represents the triple of a node and its children in the Fugue tree
FugueTextState
State of the CRDTFugueTextHandler: the text is the concatenation of all live node values.
FugueTree<T>
Implementation of the Fugue tree for collaborative text editing
FugueValueNode<T>
Represents a node within the logical sequence maintained by a Fugue-based CRDT.
Handler<T>
Abstract class for CRDT handlers
HandlerRef
A serializable reference to another Handler.
HandlerRefCodec
ValueCodec for HandlerRef.
HistorySession
An interactive controller for navigating the history of a CRDTDocument.
JsonValueCodec<T>
Default JSON-based value codec.
Operation
Abstract class for operations
OperationEnvelope
Decoded operation envelope metadata.
OperationEnvelopeCodec
Binary envelope for operations.
OperationId
OperationId implementation for CRDT
OperationType
Available operation on data for CRDT.
OpIdKey
Packed key representation for an OperationId.
ORHandlerTag
Tag for OR-based handlers entries, combining HLC and PeerId for proper ordering.
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
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

DiffOp
Diff operation types.
FugueSide
Represents the side of a node in the FugueTree (left or right)

Mixins

CacheableStateProvider<T>
Per-consumer state cache that avoids recomputing the consumer's state from the full history on every read.
DocumentConsumer
A consumer that can consume a CRDTDocument
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).

Properties

peerIdRegex RegExp
A regular expression for validating PeerIds
final

Functions

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, ...).
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.
OperationFactory = Operation? Function(Uint8List operationBytes)
A factory function that creates an operation from bytes.

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.