Class Updates

java.lang.Object
io.keikai.doc.collab.utils.Updates

public class Updates extends Object
  • Method Details

    • lazyStructReaderGenerator

      public static 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, Class<? extends UpdateDecoder> decoder)
      Log update version 2.
      Parameters:
      update - The update as a byte array.
      decoder - The decoder class.
    • decodeUpdate

      public static Map<String,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 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

      public static Uint8Array mergeUpdates(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, Class<? extends io.keikai.doc.collab.utils.DSEncoder> yEncoder, Class<? extends UpdateDecoder> yDecoder)
      Parameters:
      update - The update in Uint8Array format
      yEncoder - 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 Map<String,Map<Integer,Integer>> parseUpdateMetaV2(Uint8Array update)
      Parameters:
      update - The update in Uint8Array format
      Returns:
      A map containing the 'from' and 'to' state vectors
    • parseUpdateMetaV2

      public static Map<String,Map<Integer,Integer>> parseUpdateMetaV2(Uint8Array update, Class<? extends UpdateDecoder> clzYDecoder)
      Parameters:
      update - The update in Uint8Array format
      clzYDecoder - Decoder to be used (UpdateDecoderV1 or UpdateDecoderV2)
      Returns:
      A map containing the 'from' and 'to' state vectors
    • parseUpdateMeta

      public static Map<String,Map<Integer,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(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(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 updates
      clzYDecoder - 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 format
      sv - 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 format
      sv - The state vector in Uint8Array format
      clzYDecoder - 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 format
      sv - 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 format
      blockTransformer - The block transformer function
      clzYDecoder - 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

      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 format
      opts - 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 format
      opts - 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