UNPKG

note-graph

Version:

a generic visualization tool designed to show the structure of the document space and the relations between each doc

36 lines (35 loc) 1.1 kB
import { NodeId, GraphLink, GraphNodeInfo, GraphViewData, LinkId } from './type'; export declare type Note = { id: string; title: string; linkTo?: NodeId[]; referencedBy?: NodeId[]; }; declare type ModelComputedCache = { links: GraphLink[]; nodeInfos: { [K in NodeId]: GraphNodeInfo; }; linkMap: Map<LinkId, GraphLink>; }; declare type DataSubscriber = (model: NoteGraphModel) => void; /** * Can generate GraphViewModel by `toGraphViewModel` */ export declare class NoteGraphModel { notes: Note[]; protected cache: ModelComputedCache; protected subscribers: Array<DataSubscriber>; constructor(notes: Note[]); protected updateCache(): void; getNodeInfoById(id: NodeId): GraphNodeInfo; getLinkById(id: LinkId): GraphLink; /** * A link's id is a combination of source node and target node's id */ formLinkId(sourceId: any, targetId: any): string; toGraphViewData(): GraphViewData; publishChange(): void; subscribe(subscriber: DataSubscriber): () => void; } export {};