Package io.keikai.doc.collab.utils
Class Updates
java.lang.Object
io.keikai.doc.collab.utils.Updates
-
Method Summary
Modifier and TypeMethodDescriptionstatic Uint8ArrayconvertUpdateFormat(Uint8Array update, Function<AbstractStruct, AbstractStruct> blockTransformer, Class<? extends UpdateDecoder> clzYDecoder, 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 Function<AbstractStruct,AbstractStruct> createObfuscator(ObfuscatorOptions obfuscator) Create an obfuscator with the given options.decodeUpdate(Uint8Array update) Decode update.decodeUpdateV2(Uint8Array update, 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, Class<? extends UpdateDecoder> clzYDecoder, Class<? extends UpdateEncoder> clzYEncoder) static Uint8Arraystatic Uint8Arraystatic Uint8ArrayencodeStateVectorFromUpdateV2(Uint8Array update, Class<? extends io.keikai.doc.collab.utils.DSEncoder> yEncoder, Class<? extends UpdateDecoder> yDecoder) static Iterable<AbstractStruct>lazyStructReaderGenerator(UpdateDecoder decoder) LazyStructReaderGeneratorstatic voidlogUpdate(Uint8Array update) Log update.static voidlogUpdateV2(Uint8Array update) Log update version 2.static voidlogUpdateV2(Uint8Array update, Class<? extends UpdateDecoder> decoder) Log update version 2.static Uint8ArraymergeUpdates(List<Uint8Array> updates) static Uint8ArraymergeUpdatesV2(List<Uint8Array> updates) This function works similarly to `readUpdateV2`.static Uint8ArraymergeUpdatesV2(List<Uint8Array> updates, Class<? extends UpdateDecoder> clzYDecoder, 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.parseUpdateMeta(Uint8Array update) parseUpdateMetaV2(Uint8Array update) parseUpdateMetaV2(Uint8Array update, Class<? extends UpdateDecoder> clzYDecoder)
-
Method Details
-
lazyStructReaderGenerator
LazyStructReaderGenerator- Parameters:
decoder- The UpdateDecoderV1 or UpdateDecoderV2 instance.- Returns:
- An Iterable of GC, Item, or Skip objects.
-
logUpdate
Log update.- Parameters:
update- The update as a byte array.
-
logUpdateV2
Log update version 2.- Parameters:
update- The update as a byte array.
-
logUpdateV2
Log update version 2.- Parameters:
update- The update as a byte array.decoder- The decoder class.
-
decodeUpdate
Decode update.- Parameters:
update- The update as a byte array.- Returns:
- A Map containing the decoded structs and delete set.
-
decodeUpdateV2
public static Map<String,Object> decodeUpdateV2(Uint8Array update, 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
- Parameters:
updates- An array of Uint8Array containing the updates- Returns:
- Uint8Array representing the merged updates
-
encodeStateVectorFromUpdateV2
- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the encoded state vector from the update
-
encodeStateVectorFromUpdateV2
public static Uint8Array encodeStateVectorFromUpdateV2(Uint8Array update, Class<? extends io.keikai.doc.collab.utils.DSEncoder> yEncoder, 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
- Parameters:
update- The update in Uint8Array format- Returns:
- Uint8Array representing the encoded state vector from the update
-
parseUpdateMetaV2
- Parameters:
update- The update in Uint8Array format- Returns:
- A map containing the 'from' and 'to' state vectors
-
parseUpdateMetaV2
public static Map<String,Map<Integer, parseUpdateMetaV2Integer>> (Uint8Array update, 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
- Parameters:
update- The update in Uint8Array format- Returns:
- A map containing the 'from' and 'to' state vectors
-
mergeUpdatesV2
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(List<Uint8Array> updates, Class<? extends UpdateDecoder> clzYDecoder, 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
- 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, Class<? extends UpdateDecoder> clzYDecoder, 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
- 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, Function<AbstractStruct, AbstractStruct> blockTransformer, Class<? extends UpdateDecoder> clzYDecoder, 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 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
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
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
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
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
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
-