UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

25 lines (24 loc) 1.24 kB
import type { SyncStore } from '../../util/events/sync-store'; import type { JsonNodeApi } from '../model/api/types'; import { JsonPatch } from './JsonPatch'; import type { Path } from '@jsonjoy.com/json-pointer/lib/types'; import type { Model } from '../model'; import type { Operation } from '../../json-patch'; import type { JsonNode, JsonNodeView } from '../nodes'; export declare class JsonPatchStore<N extends JsonNode = JsonNode<any>> implements SyncStore<Readonly<JsonNodeView<N>>> { readonly model: Model<N>; readonly path: Path; readonly patcher: JsonPatch<N>; readonly pfx: string; constructor(model: Model<N>, path?: Path); readonly update: (change: Operation | Operation[]) => void; readonly add: (path: string | Path, value: unknown) => Operation; readonly replace: (path: string | Path, value: unknown) => Operation; readonly remove: (path: string | Path) => Operation; readonly del: (path: string | Path) => Operation | undefined; readonly get: (path?: string | Path) => unknown; bind(path: string | Path): JsonPatchStore<N>; api(): JsonNodeApi<N> | undefined; readonly subscribe: SyncStore<any>['subscribe']; readonly getSnapshot: () => Readonly<JsonNodeView<N>>; }