Methods
-
static applyUpdate(ydoc, update, transactionOriginopt)
-
Apply a document update created by, for example,
y.on('update', update => ..)orupdate = encodeStateAsUpdate().This function has the same effect as
readUpdatebut accepts an Uint8Array instead of a Decoder.Parameters:
Name Type Attributes Description ydocDoc updateUint8Array transactionOriginany <optional>
This will be stored on
transaction.originand.on('update', (update, origin)) -
static applyUpdateV2(ydoc, update, transactionOriginopt)
-
Apply a document update created by, for example,
y.on('update', update => ..)orupdate = encodeStateAsUpdate().This function has the same effect as
readUpdatebut accepts an Uint8Array instead of a Decoder.Parameters:
Name Type Attributes Description ydocDoc updateUint8Array transactionOriginany <optional>
This will be stored on
transaction.originand.on('update', (update, origin)) -
static decodeStateVector(decodedState) → {Map.<number, number>}
-
Read decodedState and return State as Map.
Parameters:
Name Type Description decodedStateUint8Array Returns:
Map.<number, number> -Maps
clientto the number next expectedclockfrom that client. -
static decodeStateVectorV2(decodedState) → {Map.<number, number>}
-
Read decodedState and return State as Map.
Parameters:
Name Type Description decodedStateUint8Array Returns:
Map.<number, number> -Maps
clientto the number next expectedclockfrom that client. -
static encodeStateAsUpdate(doc, encodedTargetStateVectoropt) → {Uint8Array}
-
Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (
targetState) it will only write the operations that are missing.Use
writeStateAsUpdateinstead if you are working with lib0/encoding.js#EncoderParameters:
Name Type Attributes Description docDoc encodedTargetStateVectorUint8Array <optional>
The state of the target that receives the update. Leave empty to write all known structs
Returns:
Uint8Array -
static encodeStateAsUpdateV2(doc, encodedTargetStateVectoropt, encoderopt) → {Uint8Array}
-
Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (
targetState) it will only write the operations that are missing.Use
writeStateAsUpdateinstead if you are working with lib0/encoding.js#EncoderParameters:
Name Type Attributes Description docDoc encodedTargetStateVectorUint8Array <optional>
The state of the target that receives the update. Leave empty to write all known structs
encoderAbstractUpdateEncoder <optional>
Returns:
Uint8Array -
static encodeStateVector(doc) → {Uint8Array}
-
Encode State as Uint8Array.
Parameters:
Name Type Description docDoc Returns:
Uint8Array -
static encodeStateVectorV2(doc, encoderopt) → {Uint8Array}
-
Encode State as Uint8Array.
Parameters:
Name Type Attributes Description docDoc encoderAbstractDSEncoder <optional>
Returns:
Uint8Array -
static readStateVector(decoder) → {Map.<number, number>}
-
Read state vector from Decoder and return as Map
Parameters:
Name Type Description decoderAbstractDSDecoder Returns:
Map.<number, number> -Maps
clientto the number next expectedclockfrom that client. -
static readUpdate(decoder, ydoc, transactionOriginopt)
-
Read and apply a document update.
This function has the same effect as
applyUpdatebut accepts an decoder.Parameters:
Name Type Attributes Description decoderdecoding.Decoder ydocDoc transactionOriginany <optional>
This will be stored on
transaction.originand.on('update', (update, origin)) -
static readUpdateV2(decoder, ydoc, transactionOriginopt, structDecoderopt)
-
Read and apply a document update.
This function has the same effect as
applyUpdatebut accepts an decoder.Parameters:
Name Type Attributes Description decoderdecoding.Decoder ydocDoc transactionOriginany <optional>
This will be stored on
transaction.originand.on('update', (update, origin))structDecoderAbstractUpdateDecoder <optional>
-
static writeDocumentStateVector(encoder, doc)
-
Parameters:
Name Type Description encoderAbstractDSEncoder docDoc -
static writeStateAsUpdate(encoder, doc, targetStateVectoropt)
-
Write all the document as a single update message. If you specify the state of the remote client (
targetStateVector) it will only write the operations that are missing.Parameters:
Name Type Attributes Description encoderAbstractUpdateEncoder docDoc targetStateVectorMap.<number, number> <optional>
The state of the target that receives the update. Leave empty to write all known structs
-
static writeStateVector(encoder, sv)
-
Parameters:
Name Type Description encoderAbstractDSEncoder svMap.<number, number> -
inner cleanupPendingStructs(pendingClientsStructRefs)
-
Parameters:
Name Type Description pendingClientsStructRefsMap.<number, {refs:Array.<(GC|Item)>, i:number}> -
inner writeStructs(encoder, structs, client, clock)
-
Parameters:
Name Type Description encoderAbstractUpdateEncoder structsArray.<(GC|Item)> All structs by
clientclientnumber clocknumber write structs starting with
ID(client,clock)