Package io.keikai.doc.collab.utils
Class Updates
- java.lang.Object
-
- io.keikai.doc.collab.utils.Updates
-
public class Updates extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Uint8ArrayconvertUpdateFormat(Uint8Array update, java.util.function.Function<AbstractStruct,AbstractStruct> blockTransformer, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)Convert the update format using a block transformer.static Uint8ArrayconvertUpdateFormatV1ToV2(Uint8Array update)Convert update format from version 1 to version 2.static Uint8ArrayconvertUpdateFormatV2ToV1(Uint8Array update)Convert update format from version 2 to version 1.static java.util.function.Function<AbstractStruct,AbstractStruct>createObfuscator(ObfuscatorOptions obfuscator)Create an obfuscator with the given options.static java.util.Map<java.lang.String,java.lang.Object>decodeUpdate(Uint8Array update)Decode update.static java.util.Map<java.lang.String,java.lang.Object>decodeUpdateV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> decoder)Decode update version 2.static Uint8ArraydiffUpdate(Uint8Array update, Uint8Array sv)static Uint8ArraydiffUpdateV2(Uint8Array update, Uint8Array sv)static Uint8ArraydiffUpdateV2(Uint8Array update, Uint8Array sv, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)static Uint8ArrayencodeStateVectorFromUpdate(Uint8Array update)static Uint8ArrayencodeStateVectorFromUpdateV2(Uint8Array update)static Uint8ArrayencodeStateVectorFromUpdateV2(Uint8Array update, java.lang.Class<? extends io.keikai.doc.collab.utils.DSEncoder> yEncoder, java.lang.Class<? extends UpdateDecoder> yDecoder)static java.lang.Iterable<AbstractStruct>lazyStructReaderGenerator(UpdateDecoder decoder)LazyStructReaderGeneratorstatic voidlogUpdate(Uint8Array update)Log update.static voidlogUpdateV2(Uint8Array update)Log update version 2.static voidlogUpdateV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> decoder)Log update version 2.static Uint8ArraymergeUpdates(java.util.List<Uint8Array> updates)static Uint8ArraymergeUpdatesV2(java.util.List<Uint8Array> updates)This function works similarly to `readUpdateV2`.static Uint8ArraymergeUpdatesV2(java.util.List<Uint8Array> updates, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)This function works similarly to `readUpdateV2`.static Uint8ArrayobfuscateUpdate(Uint8Array update)This function obfuscates the content of a Yjs update.static Uint8ArrayobfuscateUpdate(Uint8Array update, ObfuscatorOptions opts)This function obfuscates the content of a Yjs update.static Uint8ArrayobfuscateUpdateV2(Uint8Array update, ObfuscatorOptions opts)Obfuscate the update using version 2 of the UpdateDecoder and UpdateEncoder.static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>>parseUpdateMeta(Uint8Array update)static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>>parseUpdateMetaV2(Uint8Array update)static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>>parseUpdateMetaV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> clzYDecoder)
-
-
-
Method Detail
-
lazyStructReaderGenerator
public static java.lang.Iterable<AbstractStruct> lazyStructReaderGenerator(UpdateDecoder decoder)
LazyStructReaderGenerator- Parameters:
decoder- The UpdateDecoderV1 or UpdateDecoderV2 instance.- Returns:
- An Iterable of GC, Item, or Skip objects.
-
logUpdate
public static void logUpdate(Uint8Array update)
Log update.- Parameters:
update- The update as a byte array.
-
logUpdateV2
public static void logUpdateV2(Uint8Array update)
Log update version 2.- Parameters:
update- The update as a byte array.
-
logUpdateV2
public static void logUpdateV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> decoder)
Log update version 2.- Parameters:
update- The update as a byte array.decoder- The decoder class.
-
decodeUpdate
public static java.util.Map<java.lang.String,java.lang.Object> decodeUpdate(Uint8Array update)
Decode update.- Parameters:
update- The update as a byte array.- Returns:
- A Map containing the decoded structs and delete set.
-
decodeUpdateV2
public static java.util.Map<java.lang.String,java.lang.Object> decodeUpdateV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> decoder)
Decode update version 2.- Parameters:
update- The update as a byte array.decoder- The decoder class.- Returns:
- A Map containing the decoded structs and delete set.
-
mergeUpdates
public static Uint8Array mergeUpdates(java.util.List<Uint8Array> updates)
- Parameters:
updates- An array of Uint8Array containing the updates- Returns:
- Uint8Array representing the merged updates
-
encodeStateVectorFromUpdateV2
public static Uint8Array encodeStateVectorFromUpdateV2(Uint8Array update)
- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the encoded state vector from the update
-
encodeStateVectorFromUpdateV2
public static Uint8Array encodeStateVectorFromUpdateV2(Uint8Array update, java.lang.Class<? extends io.keikai.doc.collab.utils.DSEncoder> yEncoder, java.lang.Class<? extends UpdateDecoder> yDecoder)
- Parameters:
update- The update in Uint8Array formatyEncoder- to be used (DSEncoderV1 or DSEncoderV2)yDecoder- Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)- Returns:
- Uint8Array representing the encoded state vector from the update
-
encodeStateVectorFromUpdate
public static Uint8Array encodeStateVectorFromUpdate(Uint8Array update)
- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the encoded state vector from the update
-
parseUpdateMetaV2
public static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>> parseUpdateMetaV2(Uint8Array update)
- Parameters:
update- The update in Uint8Array format- Returns:
- A map containing the 'from' and 'to' state vectors
-
parseUpdateMetaV2
public static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>> parseUpdateMetaV2(Uint8Array update, java.lang.Class<? extends UpdateDecoder> clzYDecoder)
- Parameters:
update- The update in Uint8Array formatclzYDecoder- Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)- Returns:
- A map containing the 'from' and 'to' state vectors
-
parseUpdateMeta
public static java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.Integer>> parseUpdateMeta(Uint8Array update)
- Parameters:
update- The update in Uint8Array format- Returns:
- A map containing the 'from' and 'to' state vectors
-
mergeUpdatesV2
public static Uint8Array mergeUpdatesV2(java.util.List<Uint8Array> updates)
This function works similarly to `readUpdateV2`.- Parameters:
updates- An array of Uint8Array containing the updates- Returns:
- Uint8Array representing the merged updates
-
mergeUpdatesV2
public static Uint8Array mergeUpdatesV2(java.util.List<Uint8Array> updates, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)
This function works similarly to `readUpdateV2`.- Parameters:
updates- An array of Uint8Array containing the updatesclzYDecoder- Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)clzYEncoder- Encoder to be used (UpdateEncoderV1 or UpdateEncoderV2)- Returns:
- Uint8Array representing the merged updates
-
diffUpdateV2
public static Uint8Array diffUpdateV2(Uint8Array update, Uint8Array sv)
- Parameters:
update- The update in Uint8Array formatsv- The state vector in Uint8Array format- Returns:
- Uint8Array representing the difference between the update and the state vector
-
diffUpdateV2
public static Uint8Array diffUpdateV2(Uint8Array update, Uint8Array sv, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)
- Parameters:
update- The update in Uint8Array formatsv- The state vector in Uint8Array formatclzYDecoder- Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)clzYEncoder- Encoder to be used (UpdateEncoderV1 or UpdateEncoderV2)- Returns:
- Uint8Array representing the difference between the update and the state vector
-
diffUpdate
public static Uint8Array diffUpdate(Uint8Array update, Uint8Array sv)
- Parameters:
update- The update in Uint8Array formatsv- The state vector in Uint8Array format- Returns:
- Uint8Array representing the difference between the update and the state vector
-
convertUpdateFormat
public static Uint8Array convertUpdateFormat(Uint8Array update, java.util.function.Function<AbstractStruct,AbstractStruct> blockTransformer, java.lang.Class<? extends UpdateDecoder> clzYDecoder, java.lang.Class<? extends UpdateEncoder> clzYEncoder)
Convert the update format using a block transformer.- Parameters:
update- The update in Uint8Array formatblockTransformer- The block transformer functionclzYDecoder- Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)clzYEncoder- Encoder to be used (UpdateEncoderV1 or UpdateEncoderV2)- Returns:
- Uint8Array representing the converted update format
-
createObfuscator
public static java.util.function.Function<AbstractStruct,AbstractStruct> createObfuscator(ObfuscatorOptions obfuscator)
Create an obfuscator with the given options.- Parameters:
obfuscator- Options for obfuscation- Returns:
- A function that obfuscates a block (Item, GC, or Skip)
-
obfuscateUpdate
public static Uint8Array obfuscateUpdate(Uint8Array update)
This function obfuscates the content of a Yjs update. This is useful to share buggy Yjs documents while significantly limiting the possibility that a developer can on the user. Note that it might still be possible to deduce some information by analyzing the "structure" of the document or by analyzing the typing behavior using the CRDT-related metadata that is still kept fully intact.- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the obfuscated update
-
obfuscateUpdate
public static Uint8Array obfuscateUpdate(Uint8Array update, ObfuscatorOptions opts)
This function obfuscates the content of a Yjs update. This is useful to share buggy Yjs documents while significantly limiting the possibility that a developer can on the user. Note that it might still be possible to deduce some information by analyzing the "structure" of the document or by analyzing the typing behavior using the CRDT-related metadata that is still kept fully intact.- Parameters:
update- The update in Uint8Array formatopts- The obfuscator options- Returns:
- Uint8Array representing the obfuscated update
-
obfuscateUpdateV2
public static Uint8Array obfuscateUpdateV2(Uint8Array update, ObfuscatorOptions opts)
Obfuscate the update using version 2 of the UpdateDecoder and UpdateEncoder.- Parameters:
update- The update in Uint8Array formatopts- The obfuscator options- Returns:
- Uint8Array representing the obfuscated update
-
convertUpdateFormatV1ToV2
public static Uint8Array convertUpdateFormatV1ToV2(Uint8Array update)
Convert update format from version 1 to version 2.- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the update in version 2 format
-
convertUpdateFormatV2ToV1
public static Uint8Array convertUpdateFormatV2ToV1(Uint8Array update)
Convert update format from version 2 to version 1.- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the update in version 1 format
-
-