UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

27 lines (26 loc) 962 B
import { LinkResolver } from 'alinea/backend/resolver/LinkResolver'; import * as Y from 'yjs'; import { Label } from './Label.js'; import { RecordShape } from './shape/RecordShape.js'; type YType = Y.Map<any>; export interface ShapeInfo { name: string; parents: Array<string>; shape: RecordShape; } export interface Shape<Value = any, Mutator = any> { initialValue?: Value; label: Label; innerTypes(parents: Array<string>): Array<ShapeInfo>; create(): Value; typeOfChild<C>(yValue: any, child: string): Shape<C, unknown>; toY(value: Value): any; fromY(yValue: any): Value; applyY(value: Value, parent: YType, key: string): void; init(parent: YType, key: string): void; watch(parent: YType, key: string): (fun: () => void) => () => void; mutator(parent: YType, key: string, readOnly: boolean): Mutator; toString(): string; applyLinks(value: Value, loader: LinkResolver): Promise<void>; } export {};