json-joy
Version:
Collection of libraries for building collaborative editing apps.
78 lines (77 loc) • 2.52 kB
TypeScript
import { AbstractRga, type Chunk } from '../rga/AbstractRga';
import { type ITimestampStruct } from '../../../json-crdt-patch/clock';
import type { Model } from '../../model';
import type { JsonNode, JsonNodeView } from '..';
import type { Printable } from 'tree-dump/lib/types';
type E = ITimestampStruct;
/**
* @ignore
* @category CRDT Node
*/
export declare class ArrChunk implements Chunk<E[]> {
readonly id: ITimestampStruct;
span: number;
del: boolean;
data: E[] | undefined;
len: number;
p: ArrChunk | undefined;
l: ArrChunk | undefined;
r: ArrChunk | undefined;
p2: ArrChunk | undefined;
l2: ArrChunk | undefined;
r2: ArrChunk | undefined;
s: ArrChunk | undefined;
constructor(id: ITimestampStruct, span: number, data: E[] | undefined);
merge(data: E[]): void;
split(ticks: number): ArrChunk;
delete(): void;
clone(): ArrChunk;
view(): E[];
}
/**
* Represents the `arr` JSON CRDT type, which is a Replicated Growable Array
* (RGA). Each element ot the array is a reference to another JSON CRDT node.
*
* @category CRDT Node
*/
export declare class ArrNode<Element extends JsonNode = JsonNode> extends AbstractRga<E[]> implements JsonNode<JsonNodeView<Element>[]>, Printable {
readonly doc: Model<any>;
constructor(doc: Model<any>, id: ITimestampStruct);
/**
* Returns a reference to an element at a given position in the array.
*
* @param position The position of the element to get.
* @returns An element of the array, if any.
*/
get(position: number): E | undefined;
/**
* Returns a JSON node at a given position in the array.
*
* @param position The position of the element to get.
* @returns A JSON node, if any.
*/
getNode(position: number): JsonNode | undefined;
getById(id: ITimestampStruct): E | undefined;
/** @ignore */
createChunk(id: ITimestampStruct, data: E[] | undefined): ArrChunk;
/** @ignore */
protected onChange(): void;
protected toStringName(): string;
/** @ignore */
child(): undefined;
/** @ignore */
container(): JsonNode | undefined;
/** @ignore */
private _tick;
/** @ignore */
private _view;
view(): JsonNodeView<Element>[];
/** @ignore */
children(callback: (node: JsonNode) => void): void;
/** @ignore */
api: undefined | unknown;
name(): string;
/** @ignore */
protected printChunk(tab: string, chunk: ArrChunk): string;
}
export {};