import type { IClockVector } from '../../json-crdt-patch'; import type { Identifiable } from '../../json-crdt-patch/types'; import type { DeltaMutator } from '../delta/Delta'; import type { Model } from '../model'; /** * Each JsonNode represents a structural unit of a JSON document. It is like an * AST node, where each node has one of the following types: "object", * "array", "string", "number", "boolean", and "null". * * "make" operations result into JSON nodes, for example, "make object" operation * create a new "object" JSON node, "make number" operation creates a number * JSON node, etc. */ export interface JsonNode extends Identifiable { /** * Returns the name of the JSON node type. */ name(): string; /** * Returns a POJO object which represents the "view" of this JSON node model. */ view(): View; /** * Returns a list of immediate child nodes. * * @todo: Use `UndefIterator` interface here. */ children(callback: (node: JsonNode) => void): void; /** * Returns its child (if not a container node), if any. */ child?(): JsonNode | undefined; /** * Returns itself if the node is a container node. Or asks its child (if any) * to return a container node. A *container node* is one that holds other * multiple other nodes which can be addressed. For example, an object and * an array are container nodes, as they hold other nodes. */ container(): JsonNode | undefined; /** * Populates the delta group with the operations that MUST applied to the * model of another peer to "fill in" the missing state. * * @param model The model of the current document. * @param cc The causal context of the "has seen" events. * @param ops Delta group - a list of delta mutators to be populated. */ delta(model: Model, cc: IClockVector, ops: DeltaMutator[]): void; /** * A singleton cache, instance which provides public API for this node. */ api: undefined | unknown; /** * Reference to the parent node. The parent is the node that contains this * node as a child. The root node has no parent. */ parent: JsonNode | undefined; } export type JsonNodeView = N extends JsonNode ? V : { [K in keyof N]: JsonNodeView; }; //# sourceMappingURL=types.d.ts.map