1- /* eslint-disable sonarjs/cognitive-complexity */
2- /* eslint-disable jsdoc/require-jsdoc */
31import { type dia } from '@joint/core' ;
42import type { ElementJSONInit , LinkJSONInit , CellId } from '../types/cell.types' ;
53import { graphChanges , type UpdateGraphOptions } from './graph-changes' ;
@@ -22,6 +20,7 @@ export type OnIncrementalCellsChange<Element extends ElementJSONInit, Link exten
2220 changes : IncrementalCellsChange < Element , Link >
2321) => void ;
2422
23+ /** Configuration for {@link graphProjection}. */
2524interface GraphProjectionState <
2625 Element extends ElementJSONInit = ElementJSONInit ,
2726 Link extends LinkJSONInit = LinkJSONInit ,
@@ -31,6 +30,16 @@ interface GraphProjectionState<
3130 readonly onElementsSizeChange ?: ( id : CellId , size : dia . Size ) => void ;
3231}
3332
33+ /* eslint-disable sonarjs/cognitive-complexity -- graph→container projection
34+ keeps add/change/remove plus connected-link sweeps inline for one-pass perf. */
35+ /**
36+ * Project a JointJS graph into a reactive cells container, keeping the two in
37+ * sync. Subscribes to graph changes and mirrors add / change / remove events
38+ * (including connected-link sweeps) into the container, optionally emitting an
39+ * incremental change set after each commit.
40+ * @param options - graph to project plus optional change/size callbacks
41+ * @returns controller exposing the readonly cells container and sync/update/destroy methods
42+ */
3443export function graphProjection <
3544 Element extends ElementJSONInit = ElementJSONInit ,
3645 Link extends LinkJSONInit = LinkJSONInit ,
@@ -168,7 +177,9 @@ export function graphProjection<
168177 } ,
169178 } ;
170179}
180+ /* eslint-enable sonarjs/cognitive-complexity */
171181
182+ /** Controller returned by {@link graphProjection}. */
172183export type GraphProjection <
173184 Element extends ElementJSONInit = ElementJSONInit ,
174185 Link extends LinkJSONInit = LinkJSONInit ,
0 commit comments