import { Handle } from "@tiny-calc/handletable" ; export const enum GraphNodeHandle { none = 0 , root = 1 } export type GraphNode = Handle & { readonly GraphNode : unique symbol ; } ; export const GraphNode = { get root ( ) : GraphNode { return GraphNodeHandle . root as unknown as GraphNode ; } , get none ( ) : GraphNode { return GraphNodeHandle . none as unknown as GraphNode ; } } ; export interface IGraphShapeProducer { param consumer openGraph ( consumer ) : IGraphShapeReader ; param consumer closeGraph ( consumer ) : void ; } export interface IGraphShapeConsumer { /** Notification that a range of children have been inserted, removed, and/or replaced in the given parent. */ childrenChanged ( parent , start , removedCount , insertedCount , producer ) : void ; } export interface IGraphShapeReader { getChild ( parent , position ) : GraphNode ; getChildCount ( parent ) : number ; } export interface IGraphShapeWriter { createNode ( ) : GraphNode ; deleteNode ( node ) : void ; spliceChildren ( parent , start , removeCount , ... toInsert ) : void ; } export interface IGraphProducer < T = unknown > extends IGraphShapeProducer { param consumer openGraph ( consumer ) : IGraphReader < T > ; param consumer closeGraph ( consumer ) : void ; } export interface IGraphConsumer extends IGraphShapeConsumer { nodeChanged ( node , producer ) : void ; } export interface IGraphReader < T > extends IGraphShapeReader { getNode ( node ) : T ; } export interface IGraphWriter < T > { setNode ( node , value ) : void ; }