An internal description of where the Collab is located relative to the ancestor that created this CollabID.
Typically, it is the path from the Collab to the ancestor in the tree of Collabs.
A cursor in a collaborative list or text string.
A Cursor points to a particular spot in a list, in between two list elements (or text characters). You can use Cursors as ordinary cursors or selection endpoints.
Use the Cursors class to convert between indices and Cursors.
Internally, a cursor is represented as a string. Specifically, it is the Position of the list element to its left, or "START" if it is at the beginning of the list. If that position is later deleted, the cursor stays the same, but its index shifts to the next element on its left.
A position in a collaborative list (e.g. [[CList]], [[CValueList]], [[CText]]), represented as an opaque string.
A position points to a list entry immutably: unlike its index, an entry's position never changes.
The IList interface has methods to convert between a position, its value (if present), and its current index (or where it would be if present).
You can use positions as React keys, range endpoints for a comment on a document, etc.
See also: Cursor
Metadata for an update (message or saved state).
WeakRef "polyfill" that will use a normal object if WeakRef is not supported.
Mixin that adds default implementations of IList
methods to a base class Base
. Base
is assumed to extend Collab
and implement the remaining IList methods (or leave them abstract).
The implemented methods are those in MakeAbstractList_Methods. You may override their implementations in subclasses.
Typically, you do not need to use this mixin directly. Instead,
use our predefined instances for the most common Base
classes:
AbstractList_Collab, AbstractList_CObject, AbstractList_CPrimitive,
[[AbstractList_PrimitiveCRDT]].
If you do need to apply this mixin to a different Base
, beware that
it tricky to use in TypeScript. Specifically, the mixin requires generic type
parameters, but you cannot pass a class's generic type parameters to
a mixin that it extends. To work around this, we recommend:
.js
and .d.ts
files. See the source of AbstractList_Collab
for an example.tsconfig.json
, set "allowJs": true
.tsc
, copy the .d.ts
file to the
output folder. Otherwise, by default TypeScript auto-generates its own
.d.ts
file from the .js
file
(see https://github.com/microsoft/TypeScript/issues/39231).Mixin that adds default implementations of IMap
methods to a base class Base
. Base
is assumed to extend Collab
and implement the remaining IMap methods (or leave them abstract).
The implemented methods are those in MakeAbstractMap_Methods. You may override their implementations in subclasses.
Typically, you do not need to use this mixin directly. Instead,
use our predefined instances for the most common Base
classes:
AbstractMap_Collab, AbstractMap_CObject, AbstractMap_CPrimitive,
[[AbstractMap_PrimitiveCRDT]].
If you do need to apply this mixin to a different Base
, beware that
it tricky to use in TypeScript. Specifically, the mixin requires generic type
parameters, but you cannot pass a class's generic type parameters to
a mixin that it extends. To work around this, we recommend:
.js
and .d.ts
files. See the source of AbstractMap_Collab
for an example.tsconfig.json
, set "allowJs": true
.tsc
, copy the .d.ts
file to the
output folder. Otherwise, by default TypeScript auto-generates its own
.d.ts
file from the .js
file
(see https://github.com/microsoft/TypeScript/issues/39231).Mixin that adds default implementations of ISet
methods to a base class Base
. Base
is assumed to extend Collab
and implement the remaining ISet methods (or leave them abstract).
The implemented methods are those in MakeAbstractSet_Methods. You may override their implementations in subclasses.
Typically, you do not need to use this mixin directly. Instead,
use our predefined instances for the most common Base
classes:
AbstractSet_Collab, AbstractSet_CObject, AbstractSet_CPrimitive,
[[AbstractSet_PrimitiveCRDT]].
If you do need to apply this mixin to a different Base
, beware that
it tricky to use in TypeScript. Specifically, the mixin requires generic type
parameters, but you cannot pass a class's generic type parameters to
a mixin that it extends. To work around this, we recommend:
.js
and .d.ts
files. See the source of AbstractSet_Collab
for an example.tsconfig.json
, set "allowJs": true
.tsc
, copy the .d.ts
file to the
output folder. Otherwise, by default TypeScript auto-generates its own
.d.ts
file from the .js
file
(see https://github.com/microsoft/TypeScript/issues/39231).Utility function to help custom parents implement IParent.idOf.
Other callers should instead call ancestor.idOf(descendant)
.
Internal utility for working with protobuf encodings.
Apply this function to protobuf.js uint64 and sint64 output values to convert them to the nearest JS number (double). For safe integers, this is exact.
Safe version of TypeScript's non-null asertion (value!
) that throws
an error if value
is actually null or undefined.
Internal utility for working with protobuf encodings.
Returns whether the optional property prop
is present in
the deserialized protobufjs message message
. (Accessing a not-present
property directly will return its type's default value
instead of undefined
.)
Generated using TypeDoc
A replica-independent ID for a Collab.
A CollabID refers to a Collab in a way that makes sense across replicas: you can send a CollabID from replica A to replica B, and replica B can use it to find (their replica of) the original Collab. This lets you link to a place in a collection or even in a whole document, similar to a Position.
To convert between the Collabs in a collection (e.g., a [[CSet]]) and their CollabIDs, use the collection's IParent.idOf and IParent.fromID methods. More generally, you can use any ancestor of the Collabs or the top-level IRuntime/[[AbstractDoc]].
CollabIDs are JSON objects and can be serialized with DefaultSerializer. You can also use CollabIDSerializer (in package @collabs/core).