Iterator structure used by XML nodes (elements and text) to iterate over node’s attributes.
Attribute iterators are unordered - there’s no specific order in which map entries will be
returned during consecutive iterator calls.
Iterator structure used by shared map data type. Map iterators are unordered - there’s no
specific order in which map entries will be returned during consecutive iterator calls.
Transaction is one of the core types in Yrs. All operations that need to touch or
modify a document’s contents (a.k.a. block store), need to be executed in scope of a
transaction.
Iterator used to traverse over the complex nested tree structure of a XML node. XML node
iterator walks only over YXmlElement and YXmlText nodes. It does so in ordered manner (using
the order in which children are ordered within their parent nodes) and using depth-first
traverse.
Event pushed into callbacks registered with yarray_observe function. It contains delta of all
content changes made within a scope of corresponding transaction (see: yarray_event_delta) as
well as navigation data used to identify a YArray instance which triggered this event.
Delete set is a map of (ClientID, Range[]) entries. Length of a map is stored in
entries_count field. ClientIDs reside under client_ids and their corresponding range
sequences can be found under the same index of ranges field.
A data type representing a single change to be performed in sequence of changes defined
as parameter to a ytext_insert_delta function. A type of change can be detected using
a tag field:
A data type representing a single change made over a map component of shared collection types,
such as YMap entries or YXmlText/YXmlElement attributes. A key field provides a
corresponding unique key string of a changed entry, while tag field informs about specific
type of change being done:
Fixed-length sequence of ID ranges. Each range is a pair of [start, end) values, describing the
range of items identified by clock values, that this range refers to.
Event pushed into callbacks registered with ymap_observe function. It contains all
key-value changes made within a scope of corresponding transaction (see: ymap_event_keys) as
well as navigation data used to identify a YMap instance which triggered this event.
Struct representing a state of a document. It contains the last seen clocks for blocks submitted
per any of the clients collaborating on document updates.
A sticky index is based on the Yjs model and is not affected by document changes.
E.g. If you place a sticky index before a certain character, it will always point to this character.
If you place a sticky index at the end of a type, it will always point to the end of the type.
Event pushed into callbacks registered with ytext_observe function. It contains delta of all
text changes made within a scope of corresponding transaction (see: ytext_event_delta) as
well as navigation data used to identify a YText instance which triggered this event.
Event type related to UndoManager observer operations, such as yundo_manager_observe_popped
and yundo_manager_observe_added. It contains various informations about the context in which
undo/redo operations are executed.
A structure representing single attribute of an either YXmlElement or YXmlText instance.
It consists of attribute name and string, both of which are null-terminated UTF-8 strings.
Event pushed into callbacks registered with yxmlelem_observe function. It contains
all attribute changes made within a scope of corresponding transaction
(see: yxmlelem_event_keys) as well as child XML nodes changes (see: yxmlelem_event_delta)
and navigation data used to identify a YXmlElement instance which triggered this event.
Event pushed into callbacks registered with yxmltext_observe function. It contains
all attribute changes made within a scope of corresponding transaction
(see: yxmltext_event_keys) as well as text edits (see: yxmltext_event_delta)
and navigation data used to identify a YXmlText instance which triggered this event.
Tag used to identify YEventKeyChange (see: yevent_keys function) case, when an existing
entry has been removed from a map component of shared collection.
Tag used to identify YEventKeyChange (see: yevent_keys function) case, when an existing
entry has been overridden with a new value within a map component of shared collection.
Flag used by YOutput to tag content, which is an undefined shared type. This usually happens
when it’s referencing a root type that has not been initalized localy.
Gets or creates a new shared YArray data type instance as a root-level type of a given document.
This structure can later be accessed using its name, which must be a null-terminated UTF-8
compatible string.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yarray_event_target function). It can consist of either integer indexes (used by sequence
components) or *char keys (used by map components). len output parameter is used to provide
information about length of the path.
Returns a pointer to a YOutput value stored at a given index of a current YArray.
If index is outside the bounds of an array, a null pointer will be returned.
Inserts a range of items into current YArray, starting at given index. An items_len
parameter is used to determine the size of items array - it can also be used to insert
a single element given its pointer.
Moves current YArray iterator over to a next element, returning a pointer to it. If an iterator
comes to an end of an array, a null pointer will be returned.
Subscribes a given callback function cb to changes made by this YArray instance. Callbacks
are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Removes a len of consecutive range of elements from current array instance, starting at
a given index. Range determined by index and len must fit into boundaries of an array,
otherwise it will panic at runtime.
Frees all memory-allocated resources bound to a given binary returned from Yrs document API.
Unlike strings binaries are not null-terminated and can contain null characters inside,
therefore a size of memory to be released must be explicitly provided.
Yrs binaries don’t use libc malloc, so calling free() on them will fault.
Check if current branch is still alive (returns Y_TRUE, otherwise Y_FALSE).
If it was deleted, this branch pointer is no longer a valid pointer and cannot be used to
execute any functions using it.
Given a logical identifier, returns a physical pointer to a shared collection.
Returns null if collection was not found - either because it was not defined or not synchronized
yet.
Returned pointer may still point to deleted collection. In such case a subsequent ybranch_alive
function call is required.
Returns a UTF-8 encoded, NULL-terminated JSON string representation of the current branch
contents. Once no longer needed, this string must be explicitly deallocated by user using
ystring_destroy.
Creates a parameter for ytext_insert_delta function. This parameter will tell cursor to remove
a corresponding number of elements, starting from current cursor position.
Creates a parameter for ytext_insert_delta function. This parameter will tell cursor to insert
given elements into current cursor position. While these elements can be of any type (used for
embedding ie. shared types or binary payload like images), for the text insertion a yinput_string
is expected. If formatting attributes were specified, inserted elements will be wrapped by
given formatting attributes.
Creates a parameter for ytext_insert_delta function. This parameter will move cursor position
by the len of elements. If formatting attrs were defined, all elements skipped over this
way will be wrapped by given formatting attributes.
Creates a shallow clone of a provided doc - it’s realized by increasing the ref-count
value of the document. In result both input and output documents point to the same instance.
Starts a new read-only transaction on a given document. All other operations happen in context
of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit function.
Starts a new read-write transaction on a given document. All other operations happen in context
of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is
complete, a transaction can be finished using ytransaction_commit function.
Function constructor used to create a binary YInput cell of a specified length.
This function doesn’t allocate any heap resources and doesn’t release any on its own, therefore
its up to a caller to free resources once a structure is no longer needed.
Function constructor used to create aa YInput cell representing any JSON-like object.
Provided parameter must be a null-terminated UTF-8 encoded JSON string.
Function constructor used to create a JSON-like array YInput cell of other JSON-like values of
a given length. This function doesn’t allocate any heap resources and doesn’t release any on its
own, therefore its up to a caller to free resources once a structure is no longer needed.
Function constructor used to create a JSON-like map YInput cell of other JSON-like key-value
pairs. These pairs are build from corresponding indexes of keys and values, which must have
the same specified length.
Function constructor used to create a string YInput cell. Provided parameter must be
a null-terminated UTF-8 encoded string. This function doesn’t allocate any heap resources,
and doesn’t release any on its own, therefore its up to a caller to free resources once
a structure is no longer needed.
Function constructor used to create a nested YArrayYInput cell prefilled with other
values of a given length. This function doesn’t allocate any heap resources and doesn’t release
any on its own, therefore its up to a caller to free resources once a structure is no longer
needed.
Function constructor used to create a nested YMapYInput cell prefilled with other key-value
pairs. These pairs are build from corresponding indexes of keys and values, which must have
the same specified length.
Function constructor used to create a nested YTextYInput cell prefilled with a specified
string, which must be a null-terminated UTF-8 character pointer.
Function constructor used to create a nested YXmlElementYInput cell with a specified
tag name, which must be a null-terminated UTF-8 character pointer.
Function constructor used to create a nested YXmlTextYInput cell prefilled with a specified
string, which must be a null-terminated UTF-8 character pointer.
Gets or creates a new shared YMap data type instance as a root-level type of a given document.
This structure can later be accessed using its name, which must be a null-terminated UTF-8
compatible string.
Returns a sequence of changes produced by map component of shared collections (such as
YMap and YXmlText/YXmlElement attribute changes). len output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
ymap_event_target function). It can consist of either integer indexes (used by sequence
components) or *char keys (used by map components). len output parameter is used to provide
information about length of the path.
Returns a value stored under the provided key, or a null pointer if no entry with such key
has been found in a current map. A returned value is allocated by this function and therefore
should be eventually released using youtput_destroy function.
Returns a value stored under the provided key as UTF-8 encoded, NULL-terminated JSON string.
Once not needed that string should be deallocated using ystring_destroy.
Inserts a new entry (specified as key-value pair) into a current map. If entry under such
given key already existed, its corresponding value will be replaced.
Moves current YMap iterator over to a next entry, returning a pointer to it. If an iterator
comes to an end of a map, a null pointer will be returned. Yrs maps are unordered and so are
their iterators.
Subscribes a given callback function cb to changes made by this YMap instance. Callbacks
are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Removes a map entry, given its key. Returns 1 if the corresponding entry was successfully
removed or 0 if no entry with a provided key has been found inside of a map.
Subscribes a given callback function cb to changes made by this shared type instance as well
as all nested shared types living within it. Callbacks are triggered whenever a
ytransaction_commit is called.
Attempts to read the value for a given YOutput pointer as a boolean flag, which can be either
1 for truthy case and 0 otherwise. Returns a null pointer in case when a value stored under
current YOutput cell is not of a boolean type.
Attempts to read the value for a given YOutput pointer as a JSON-like array of YOutput
values (which length is stored within len filed of a cell itself).
Attempts to read the value for a given YOutput pointer as a JSON-like map of key-value entries
(which length is stored within len filed of a cell itself).
Returns association of current YStickyIndex.
If association is after the referenced inserted character, returned number will be >= 0.
If association is before the referenced inserted character, returned number will be < 0.
Serializes YStickyIndex into JSON representation. len parameter is updated with byte
length of the generated binary. Returned binary can be free’d using ybinary_destroy.
Serializes YStickyIndex into binary representation. len parameter is updated with byte
length of the generated binary. Returned binary can be free’d using ybinary_destroy.
Retrieves a YStickyIndex corresponding to a given human-readable index pointing into
the shared y-type branch. Unlike standard indexes sticky one enables to track
the location inside of a shared y-types, even in the face of concurrent updates.
Deserializes YStickyIndex from the payload previously serialized using ysticky_index_to_json.
The input json parameter is a NULL-terminated UTF-8 encoded string containing a JSON
compatible with Yjs RelativePosition serialization format.
Serialize YStickyIndex into null-terminated UTF-8 encoded JSON string, that’s compatible with
Yjs RelativePosition serialization format. The len parameter is updated with byte length of
of the output JSON string. This string can be freed using ystring_destroy.
Frees all memory-allocated resources bound to a given UTF-8 null-terminated string returned from
Yrs document API. Yrs strings don’t use libc malloc, so calling free() on them will fault.
Gets or creates a new shared YText data type instance as a root-level type of a given document.
This structure can later be accessed using its name, which must be a null-terminated UTF-8
compatible string.
Returns a collection of chunks representing pieces of YText rich text string grouped together
by the same formatting rules and type. chunks_len is used to inform about a number of chunks
generated this way.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to
provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
ytext_event_target function). It can consist of either integer indexes (used by sequence
components) or *char keys (used by map components). len output parameter is used to provide
information about length of the path.
Wraps an existing piece of text within a range described by index-len parameters with
formatting blocks containing provided attrs metadata. attrs must be a map-like type.
Inserts a null-terminated UTF-8 encoded string a given index. index value must be between
0 and a length of a YText (inclusive, accordingly to ytext_len return value), otherwise this
function will panic.
Inserts an embed content given index. index value must be between 0 and a length of a
YText (inclusive, accordingly to ytext_len return value), otherwise this
function will panic.
Subscribes a given callback function cb to changes made by this YText instance. Callbacks
are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Removes a range of characters, starting a a given index. This range must fit within the bounds
of a current YText, otherwise this function call will fail.
Commit and dispose provided read-write transaction. This operation releases allocated resources,
triggers update events and performs a storage compression over all operations executed in scope
of a current transaction.
Encodes a state of the document at a point in time specified by the provided snapshot
(generated by: ytransaction_snapshot). This is useful to generate a past view of the document.
Encodes a state of the document at a point in time specified by the provided snapshot
(generated by: ytransaction_snapshot). This is useful to generate a past view of the document.
Perform garbage collection of deleted blocks, even if a document was created with skip_gc
option. This operation will scan over ALL deleted elements, NOT ONLY the ones that have been
changed as part of this transaction scope.
Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
the transaction’s document and returns an iterator over values matching that query.
Returns a pending update associated with an underlying YDoc. Pending update contains update
data waiting for being integrated into main document store. Usually reason for that is that
there were missing updates required for integration. In such cases they need to arrive and be
integrated first.
Returns a snapshot descriptor of a current state of the document. This snapshot information
can be then used to encode document data at a particular point in time
(see: ytransaction_encode_state_from_snapshot).
Returns a delta difference between current state of a transaction’s document and a state vector
sv encoded as a binary payload using lib0 version 1 encoding (which could be generated using
ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in
order to propagate and apply (using ytransaction_apply) all updates known to a current
document, which remote peer was not aware of.
Returns a delta difference between current state of a transaction’s document and a state vector
sv encoded as a binary payload using lib0 version 1 encoding (which could be generated using
ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in
order to propagate and apply (using ytransaction_apply_v2) all updates known to a current
document, which remote peer was not aware of.
Returns a state vector of a current transaction’s document, serialized using lib0 version 1
encoding. Payload created by this function can then be send over the network to a remote peer,
where it can be used as a parameter of ytransaction_state_diff_v1 in order to produce a delta
update payload, that can be send back and applied locally in order to efficiently propagate
updates from one peer to another.
Gets a reference to shared data type instance at the document root-level,
identified by its name, which must be a null-terminated UTF-8 compatible string.
Returns a value informing what kind of Yrs shared collection given branch represents.
Returns either 0 when branch is null or one of values: Y_ARRAY, Y_TEXT, Y_MAP,
Y_XML_ELEM, Y_XML_TEXT.
Creates a new instance of undo manager bound to a current doc. It can be used to track
specific shared refs via yundo_manager_add_scope and updates coming from specific origin
Adds an origin to be tracked by current undo manager. This way only changes made within context
of transactions created with specific origin will be subjects of undo/redo operations. This is
useful when you want to be able to revert changed done by specific user without reverting
changes made by other users that were applied in the meantime.
Removes all the undo/redo stack changes tracked by current undo manager. This also cleans up
all the items that couldn’t be deallocated / garbage collected for the sake of possible
undo/redo operations.
Performs an undo operations, reverting all the changes defined by the last undo stack item.
These changes can be then reapplied again by calling yundo_manager_redo function.
Returns a null-terminated UTF-8 encoded string representation of an update binary payload,
encoded using lib0 v1 encoding.
Returns null if update couldn’t be parsed into a lib0 v1 formatting.
Returns a null-terminated UTF-8 encoded string representation of an update binary payload,
encoded using lib0 v2 encoding.
Returns null if update couldn’t be parsed into a lib0 v2 formatting.
Subscribes a given callback function cb to changes made by this YText instance. Callbacks
are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Returns a next sibling of a current XML node, which can be either another YXmlElement
or a YXmlText. Together with yxmlelem_first_child it may be used to iterate over the direct
children of an XML node (in order to iterate over the nested XML structure use
yxmlelem_tree_walker).
Returns a next XML attribute from an iterator. Attributes are returned in an unordered
manner. Once iterator reaches the end of attributes collection, a null pointer will be
returned.
Returns a number of child nodes (both YXmlElement and YXmlText) living under a current XML
element. This function doesn’t count a recursive nodes, only direct children of a current node.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to
provide information about number of changes produced.
Returns a sequence of changes produced by map component of shared collections.
len output parameter is used to provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yxmlelem_event_path function). It can consist of either integer indexes (used by sequence
components) or *char keys (used by map components). len output parameter is used to provide
information about length of the path.
Returns a first child node of a current YXmlElement, or null pointer if current XML node is
empty. Returned value could be either another YXmlElement or YXmlText.
Returns an XML child node (either a YXmlElement or YXmlText) stored at a given index of
a current YXmlElement. Returns null pointer if index was outside of the bound of current XML
node children.
Returns the value of a current YXmlElement, given its name, or a null pointer if not attribute
with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which
should be released using ystring_destroy function.
Inserts an XML attribute described using attr_name and attr_value. If another attribute with
the same name already existed, its value will be replaced with a provided one.
Inserts an YXmlElement as a child of a current node at the given index and returns its
pointer. Node created this way will have a given name as its tag (eg. p for <p></p> node).
Subscribes a given callback function cb to changes made by this YXmlElement instance.
Callbacks are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Removes a consecutive range of child elements (of specified length) from the current
YXmlElement, starting at the given index. Specified range must fit into boundaries of current
XML node children, otherwise this function will panic at runtime.
Converts current YXmlElement together with its children and attributes into a flat string
representation (no padding) eg. <UNDEFINED><title key="value">sample text</title></UNDEFINED>.
Returns an iterator over a nested recursive structure of a current YXmlElement, starting from
first of its children. Returned values can be either YXmlElement or YXmlText nodes.
Moves current iterator to a next value (either YXmlElement or YXmlText), returning its
pointer or a null, if an iterator already reached the last successor node.
Gets or creates a new shared YXmlElement data type instance as a root-level type of a given
document. This structure can later be accessed using its name, which must be a null-terminated
UTF-8 compatible string.
Returns a sequence of changes produced by sequence component of shared collections (such as
YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to
provide information about number of changes produced.
Returns a sequence of changes produced by map component of shared collections.
len output parameter is used to provide information about number of changes produced.
Returns a path from a root type down to a current shared collection (which can be obtained using
yxmltext_event_path function). It can consist of either integer indexes (used by sequence
components) or *char keys (used by map components). len output parameter is used to provide
information about length of the path.
Wraps an existing piece of text within a range described by index-len parameters with
formatting blocks containing provided attrs metadata. attrs must be a map-like type.
Returns the value of a current YXmlText, given its name, or a null pointer if not attribute
with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which
should be released using ystring_destroy function.
Inserts a null-terminated UTF-8 encoded string a a given index. index value must be between
0 and a length of a YXmlText (inclusive, accordingly to yxmltext_len return value), otherwise
this function will panic.
Inserts an XML attribute described using attr_name and attr_value. If another attribute with
the same name already existed, its value will be replaced with a provided one.
Inserts an embed content given index. index value must be between 0 and a length of a
YXmlText (inclusive, accordingly to ytext_len return value), otherwise this
function will panic.
Subscribes a given callback function cb to changes made by this YXmlText instance. Callbacks
are triggered whenever a ytransaction_commit is called.
Returns a subscription ID which can be then used to unsubscribe this callback by using
yunobserve function.
Removes a range of characters, starting a a given index. This range must fit within the bounds
of a current YXmlText, otherwise this function call will fail.
A common shared data type. All Yrs instances can be refered to using this data type (use
ytype_kind function if a specific type needs to be determined). Branch pointers are passed
over type-specific functions like ytext_insert, yarray_insert or ymap_insert to perform
a specific shared type operations.
A Yrs document type. Documents are the most important units of collaborative resources management.
All shared collections live within a scope of their corresponding documents. All updates are
generated on per-document basis (rather than individual shared type). All operations on shared
collections happen via YTransaction, which lifetime is also bound to a document.
Subscription to any kind of observable events, like ymap_observe, ydoc_observe_updates_v1 etc.
This subscription can be destroyed by calling yunobserve function, which will cause to unsubscribe
correlated callback.