UNPKG

@ckeditor/ckeditor5-operations-compressor

Version:

CKEditor 5 operations compressor for real-time collaboration.

74 lines (73 loc) 2.51 kB
/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * Compresses and decompresses given set of operations in JSON format to/from the binary format using `Protocol Buffers`. */ export declare class Compressor { constructor(); /** * Compress given list of operations in JSON format. * * It tries to combine typing-like or deleting-like operations into the one buffer. */ compress(operations: Array<any>): CompressedOperationsData; /** * Decompress given data to the list of operations in JSON format. * * @param data Compressed operations. * @returns List of operations in JSON format. */ decompress(data: CompressedOperationsData): Array<any>; } /** * Compressed operations data. */ export type CompressedOperationsData = { /** * List of operations compressed to the binary format. */ buffers: Array<Uint8Array>; /** * List of compressor identifiers. According to this types a proper compressor will be used for the decompression. */ types: Array<number>; /** * Base version of the first compressed operation. */ baseVersion: number; }; /** * Input data to be compressed by `Compressor`. * * Includes operations to be compressed and index from which the compression should continue. This object is internally processed by * various classes to provide the compression result. `index` keeps being incremented to inform which operations where already processed. */ export type CompressionInput = { /** * Operations to be compressed. */ operations: Array<any>; /** * Pointer to `operations` array. Specifies the next operation that should be processed. */ index: number; }; /** * Input data to be decompressed by `Compressor`. * * Includes data for operations to be decompressed and indexes pointing to how much data was already decompressed. This object is internally * processed by various classes to provide the decompression result. Indexes keep being incremented to inform which part of the data was * already processed. */ export type DecompressionInput = CompressedOperationsData & { /** * Specifies the next item in `buffers` array to be processed. */ bufferIndex: number; /** * Specifies the next item in `types` array to be processed. */ typeIndex: number; };