UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

224 lines (223 loc) 7.01 kB
import { type ITimestampStruct, type ITimespanStruct } from './clock'; import type { IJsonCrdtPatchEditOperation, IJsonCrdtPatchOperation } from './types'; /** * Operation which creates a constant "con" data type. * * @category Operations */ export declare class NewConOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; readonly val: unknown | undefined | ITimestampStruct; constructor(id: ITimestampStruct, val: unknown | undefined | ITimestampStruct); span(): number; name(): "new_con"; toString(tab?: string): string; } /** * Operation which creates a new value object. * * @category Operations */ export declare class NewValOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_val"; toString(): string; } /** * Operation which creates a new object. * * @category Operations */ export declare class NewObjOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_obj"; toString(): string; } /** * Operation which creates a new vector object. * * @category Operations */ export declare class NewVecOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_vec"; toString(): string; } /** * Operation which creates a new string object. * * @category Operations */ export declare class NewStrOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_str"; toString(): string; } /** * Operation which creates a new binary object. * * @category Operations */ export declare class NewBinOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_bin"; toString(tab?: string): string; } /** * Operation which creates a new array object. * * @category Operations */ export declare class NewArrOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; constructor(id: ITimestampStruct); span(): number; name(): "new_arr"; toString(): string; } /** * Operation which writes a new value to a value "val" object. * * @category Operations */ export declare class InsValOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; /** @todo Rename to `node`. */ readonly obj: ITimestampStruct; readonly val: ITimestampStruct; constructor(id: ITimestampStruct, /** @todo Rename to `node`. */ obj: ITimestampStruct, val: ITimestampStruct); span(): number; name(): "ins_val"; toString(tab?: string): string; } /** * Operation which sets object keys. * * @category Operations */ export declare class InsObjOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly data: [key: string, value: ITimestampStruct][]; constructor(id: ITimestampStruct, obj: ITimestampStruct, data: [key: string, value: ITimestampStruct][]); span(): number; name(): "ins_obj"; toString(tab?: string): string; } /** * Operation which sets vector elements. * * @category Operations */ export declare class InsVecOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly data: [key: number, value: ITimestampStruct][]; constructor(id: ITimestampStruct, obj: ITimestampStruct, data: [key: number, value: ITimestampStruct][]); span(): number; name(): "ins_vec"; toString(tab?: string): string; } /** * Operation which inserts text into a "str" string object. * * @category Operations */ export declare class InsStrOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly ref: ITimestampStruct; data: string; constructor(id: ITimestampStruct, obj: ITimestampStruct, ref: ITimestampStruct, data: string); span(): number; name(): "ins_str"; toString(): string; } /** * Operations which inserts binary data into a "bin" binary object. * * @category Operations */ export declare class InsBinOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly ref: ITimestampStruct; readonly data: Uint8Array; constructor(id: ITimestampStruct, obj: ITimestampStruct, ref: ITimestampStruct, data: Uint8Array); span(): number; name(): "ins_bin"; toString(tab?: string): string; } /** * Operation which inserts elements into an array. * * @category Operations */ export declare class InsArrOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly ref: ITimestampStruct; readonly data: ITimestampStruct[]; /** * @param id ID if the first operation in this compound operation. * @param obj ID of the array where to insert elements. In theory `arr` is * not necessary as it is possible to find the `arr` just using the * `after` property, however to efficiently be able to find `arr` just * by `after` at runtime all operations would need to be indexed and * also they each would need to store a pointer to array type, which * would require additional dozens of bytes of RAM for each array * insert operation. * @param ref ID of the element after which to insert elements. * @param data The elements to insert. */ constructor(id: ITimestampStruct, obj: ITimestampStruct, ref: ITimestampStruct, data: ITimestampStruct[]); span(): number; name(): "ins_arr"; toString(): string; } /** * Operation which deletes one or more ranges of values in some object. * The object could be a string, an array, or a binary. * * @category Operations */ export declare class DelOp implements IJsonCrdtPatchEditOperation { readonly id: ITimestampStruct; readonly obj: ITimestampStruct; readonly what: ITimespanStruct[]; /** * @param id ID of this operation. * @param obj Object in which to delete something. * @param what ID of the first operation to be deleted. */ constructor(id: ITimestampStruct, obj: ITimestampStruct, what: ITimespanStruct[]); span(): number; name(): "del"; toString(): string; } /** * Operation which does nothing. Useful for skipping clock cycles, so that * operations with a gap in clock can be included in the same patch. * * @category Operations */ export declare class NopOp implements IJsonCrdtPatchOperation { readonly id: ITimestampStruct; readonly len: number; constructor(id: ITimestampStruct, len: number); span(): number; name(): "nop"; toString(): string; }