The two identity types the library hands back to you.
Every replica — every independent copy of a document, such as one browser tab — has a
stable ReplicaId, a string you choose (typically a random per-tab token). You pass one
to Crdt.init so the library knows which replica it is editing on behalf of.
Every edit the library records is stamped with an OpId, a globally-unique operation
id. You never mint these yourself, but they surface as stable handles to things
inside a document: the id of an item in a Crdt.Tree, or the identity a Crdt.Cursor
is pinned to. An OpId can be compared and turned into a string, which is all you need
to use one as a dictionary key or to look a value up.
Build a ReplicaId from a string. Use something unique per replica — a random
per-tab token, a device id, a signed-in user id.
Crdt.init (Crdt.Id.replica "alice-tab-1") schemaThe underlying string of a ReplicaId, e.g. to show who made a change.
A globally-unique id for a single recorded operation. You get these back as handles to things inside a document (tree item ids, cursor anchors); the library mints them, you read and compare them.
The counter part of an OpId.
The replica that minted an OpId.
A total order on OpIds — by counter, then replica as a tiebreak. Handy if you keep
your own sorted structure keyed by id.
A stable string form of an OpId, suitable as a Dict key ("3@alice").
A stable per-replica identifier. Two browser tabs, two
ReplicaIds. Build one withreplica.