@html-graph/html-graph 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-graph.d.ts +98 -142
- package/dist/html-graph.js +837 -788
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/html-graph.d.ts
CHANGED
|
@@ -153,104 +153,28 @@ declare type BezierEdgeShapeConfig = {
|
|
|
153
153
|
} & BezierEdgeParams;
|
|
154
154
|
|
|
155
155
|
export declare class Canvas {
|
|
156
|
-
/**
|
|
157
|
-
* provides api for accessing model of rendered graph
|
|
158
|
-
*/
|
|
159
156
|
readonly graph: Graph;
|
|
160
|
-
/**
|
|
161
|
-
* provides api for accessing viewport state
|
|
162
|
-
*/
|
|
163
157
|
readonly viewport: Viewport;
|
|
164
|
-
private readonly
|
|
165
|
-
private readonly
|
|
166
|
-
private readonly
|
|
167
|
-
private readonly params;
|
|
168
|
-
private readonly nodeIdGenerator;
|
|
169
|
-
private readonly portIdGenerator;
|
|
170
|
-
private readonly edgeIdGenerator;
|
|
171
|
-
private readonly onAfterNodeAdded;
|
|
172
|
-
private readonly onAfterNodeUpdated;
|
|
173
|
-
private readonly onAfterNodePriorityUpdated;
|
|
174
|
-
private readonly onBeforeNodeRemoved;
|
|
175
|
-
private readonly onAfterPortUpdated;
|
|
176
|
-
private readonly onBeforePortUnmarked;
|
|
177
|
-
private readonly onAfterEdgeAdded;
|
|
178
|
-
private readonly onAfterEdgeShapeUpdated;
|
|
179
|
-
private readonly onAfterEdgeUpdated;
|
|
180
|
-
private readonly onAfterEdgePriorityUpdated;
|
|
181
|
-
private readonly onBeforeEdgeRemoved;
|
|
182
|
-
private readonly onBeforeClear;
|
|
183
|
-
private readonly onBeforeDestroyEmitter;
|
|
158
|
+
private readonly graphController;
|
|
159
|
+
private readonly viewportController;
|
|
160
|
+
private readonly beforeDestroyEmitter;
|
|
184
161
|
private destroyed;
|
|
185
|
-
/**
|
|
186
|
-
* emits event just before destruction of canvas
|
|
187
|
-
*/
|
|
188
162
|
readonly onBeforeDestroy: EventHandler<void>;
|
|
189
|
-
constructor(
|
|
190
|
-
/**
|
|
191
|
-
* provides api for accessing model of rendered graph
|
|
192
|
-
*/
|
|
193
|
-
graph: Graph,
|
|
194
|
-
/**
|
|
195
|
-
* provides api for accessing viewport state
|
|
196
|
-
*/
|
|
197
|
-
viewport: Viewport, graphStore: GraphStore, viewportStore: ViewportStore, htmlView: HtmlView, params: CanvasParams);
|
|
198
|
-
/**
|
|
199
|
-
* adds new node
|
|
200
|
-
*/
|
|
163
|
+
constructor(graph: Graph, viewport: Viewport, graphController: GraphController, viewportController: ViewportController);
|
|
201
164
|
addNode(request: AddNodeRequest): Canvas;
|
|
202
|
-
|
|
203
|
-
* updates node parameters
|
|
204
|
-
*/
|
|
205
|
-
updateNode(nodeId: Identifier, request?: UpdateNodeRequest): Canvas;
|
|
206
|
-
/**
|
|
207
|
-
* removes specified node
|
|
208
|
-
* all the ports of node get unmarked
|
|
209
|
-
* all the edges adjacent to node get removed
|
|
210
|
-
*/
|
|
165
|
+
updateNode(nodeId: Identifier, request?: UpdateNodeRequest | undefined): Canvas;
|
|
211
166
|
removeNode(nodeId: Identifier): Canvas;
|
|
212
|
-
/**
|
|
213
|
-
* marks specified element as a port for specified node
|
|
214
|
-
*/
|
|
215
167
|
markPort(request: MarkPortRequest): Canvas;
|
|
216
|
-
|
|
217
|
-
* updates port and edges attached to it
|
|
218
|
-
*/
|
|
219
|
-
updatePort(portId: Identifier, request?: UpdatePortRequest): Canvas;
|
|
220
|
-
/**
|
|
221
|
-
* unmarks specified port
|
|
222
|
-
* all the edges adjacent to the port get removed
|
|
223
|
-
*/
|
|
168
|
+
updatePort(portId: Identifier, request?: UpdatePortRequest | undefined): Canvas;
|
|
224
169
|
unmarkPort(portId: Identifier): Canvas;
|
|
225
|
-
/**
|
|
226
|
-
* adds new edge
|
|
227
|
-
*/
|
|
228
170
|
addEdge(request: AddEdgeRequest): Canvas;
|
|
229
|
-
|
|
230
|
-
* updates specified edge
|
|
231
|
-
*/
|
|
232
|
-
updateEdge(edgeId: Identifier, request?: UpdateEdgeRequest): Canvas;
|
|
233
|
-
/**
|
|
234
|
-
* removes specified edge
|
|
235
|
-
*/
|
|
171
|
+
updateEdge(edgeId: Identifier, request?: UpdateEdgeRequest | undefined): Canvas;
|
|
236
172
|
removeEdge(edgeId: Identifier): Canvas;
|
|
237
|
-
/**
|
|
238
|
-
* clears canvas from nodes and edges
|
|
239
|
-
* canvas gets rolled back to initial state and can be reused
|
|
240
|
-
*/
|
|
241
173
|
clear(): Canvas;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
*/
|
|
174
|
+
focus(config?: FocusConfig | undefined): Canvas;
|
|
175
|
+
center(target: Point, config?: CenterConfig | undefined): Canvas;
|
|
245
176
|
patchViewportMatrix(request: PatchMatrixRequest): Canvas;
|
|
246
|
-
/**
|
|
247
|
-
* applies transformation for content matrix
|
|
248
|
-
*/
|
|
249
177
|
patchContentMatrix(request: PatchMatrixRequest): Canvas;
|
|
250
|
-
/**
|
|
251
|
-
* destroys canvas
|
|
252
|
-
* canvas element gets rolled back to initial state, and can not be reused
|
|
253
|
-
*/
|
|
254
178
|
destroy(): void;
|
|
255
179
|
}
|
|
256
180
|
|
|
@@ -282,50 +206,16 @@ export declare class CanvasBuilder {
|
|
|
282
206
|
private readonly window;
|
|
283
207
|
private readonly animationStaticNodes;
|
|
284
208
|
constructor(element: HTMLElement);
|
|
285
|
-
/**
|
|
286
|
-
* specifies default values for graph entities
|
|
287
|
-
*/
|
|
288
209
|
setDefaults(defaults: CanvasDefaults): CanvasBuilder;
|
|
289
|
-
/**
|
|
290
|
-
* enables nodes draggable by user
|
|
291
|
-
*/
|
|
292
210
|
enableUserDraggableNodes(config?: DraggableNodesConfig): CanvasBuilder;
|
|
293
|
-
/**
|
|
294
|
-
* enables viewport transformable by user
|
|
295
|
-
*/
|
|
296
211
|
enableUserTransformableViewport(config?: ViewportTransformConfig): CanvasBuilder;
|
|
297
|
-
/**
|
|
298
|
-
* enables automatic edges update on node resize
|
|
299
|
-
*/
|
|
300
212
|
enableNodeResizeReactiveEdges(): CanvasBuilder;
|
|
301
|
-
/**
|
|
302
|
-
* enables built-in virtual scroll behavior, when only nodes and edges close
|
|
303
|
-
* to viewport are rendered
|
|
304
|
-
*/
|
|
305
213
|
enableVirtualScroll(config: VirtualScrollConfig): CanvasBuilder;
|
|
306
|
-
/**
|
|
307
|
-
* enables built-in background rendering
|
|
308
|
-
*/
|
|
309
214
|
enableBackground(config?: BackgroundConfig): CanvasBuilder;
|
|
310
|
-
/**
|
|
311
|
-
* enables edge creation by dragging one port to another
|
|
312
|
-
*/
|
|
313
215
|
enableUserConnectablePorts(config?: ConnectablePortsConfig): CanvasBuilder;
|
|
314
|
-
/**
|
|
315
|
-
* enables edges dragging by dragging one of the adjacent ports
|
|
316
|
-
*/
|
|
317
216
|
enableUserDraggableEdges(config?: DraggableEdgesConfig): CanvasBuilder;
|
|
318
|
-
/**
|
|
319
|
-
* enables nodes positioning with specified layout
|
|
320
|
-
*/
|
|
321
217
|
enableLayout(config?: LayoutConfig): CanvasBuilder;
|
|
322
|
-
/**
|
|
323
|
-
* enables animated nodes positioning with specified layout
|
|
324
|
-
*/
|
|
325
218
|
enableAnimatedLayout(config?: AnimatedLayoutConfig): CanvasBuilder;
|
|
326
|
-
/**
|
|
327
|
-
* builds final canvas
|
|
328
|
-
*/
|
|
329
219
|
build(): Canvas;
|
|
330
220
|
private createHtmlView;
|
|
331
221
|
}
|
|
@@ -371,24 +261,18 @@ export declare interface CanvasDefaults {
|
|
|
371
261
|
*/
|
|
372
262
|
readonly priority?: Priority;
|
|
373
263
|
};
|
|
264
|
+
readonly focus?: {
|
|
265
|
+
readonly contentOffset?: number;
|
|
266
|
+
readonly minContentScale?: number;
|
|
267
|
+
};
|
|
374
268
|
}
|
|
375
269
|
|
|
376
270
|
export declare class CanvasError extends Error {
|
|
377
271
|
readonly name = "CanvasError";
|
|
378
272
|
}
|
|
379
273
|
|
|
380
|
-
declare interface
|
|
381
|
-
readonly
|
|
382
|
-
readonly centerFn: CenterFn;
|
|
383
|
-
readonly priorityFn: PriorityFn;
|
|
384
|
-
};
|
|
385
|
-
readonly ports: {
|
|
386
|
-
readonly direction: number;
|
|
387
|
-
};
|
|
388
|
-
readonly edges: {
|
|
389
|
-
readonly shapeFactory: EdgeShapeFactory;
|
|
390
|
-
readonly priorityFn: PriorityFn;
|
|
391
|
-
};
|
|
274
|
+
export declare interface CenterConfig {
|
|
275
|
+
readonly contentScale?: number | undefined;
|
|
392
276
|
}
|
|
393
277
|
|
|
394
278
|
export declare type CenterFn = (width: number, height: number) => Point;
|
|
@@ -547,6 +431,12 @@ export declare class EventSubject<T> implements EventEmitter<T>, EventHandler<T>
|
|
|
547
431
|
emit(payload: T): void;
|
|
548
432
|
}
|
|
549
433
|
|
|
434
|
+
export declare type FocusConfig = {
|
|
435
|
+
readonly contentOffset?: number | undefined;
|
|
436
|
+
readonly nodes?: Iterable<Identifier> | undefined;
|
|
437
|
+
readonly minContentScale?: number | undefined;
|
|
438
|
+
} | Iterable<Identifier>;
|
|
439
|
+
|
|
550
440
|
export declare class Graph {
|
|
551
441
|
private readonly graphStore;
|
|
552
442
|
readonly onAfterNodeAdded: EventHandler<Identifier>;
|
|
@@ -585,6 +475,53 @@ export declare class Graph {
|
|
|
585
475
|
getNodeAdjacentEdgeIds(nodeId: Identifier): readonly Identifier[];
|
|
586
476
|
}
|
|
587
477
|
|
|
478
|
+
declare class GraphController {
|
|
479
|
+
private readonly graphStore;
|
|
480
|
+
private readonly htmlView;
|
|
481
|
+
private readonly params;
|
|
482
|
+
private readonly nodeIdGenerator;
|
|
483
|
+
private readonly portIdGenerator;
|
|
484
|
+
private readonly edgeIdGenerator;
|
|
485
|
+
private readonly onAfterNodeAdded;
|
|
486
|
+
private readonly onAfterNodeUpdated;
|
|
487
|
+
private readonly onAfterNodePriorityUpdated;
|
|
488
|
+
private readonly onBeforeNodeRemoved;
|
|
489
|
+
private readonly onAfterPortUpdated;
|
|
490
|
+
private readonly onBeforePortUnmarked;
|
|
491
|
+
private readonly onAfterEdgeAdded;
|
|
492
|
+
private readonly onAfterEdgeShapeUpdated;
|
|
493
|
+
private readonly onAfterEdgeUpdated;
|
|
494
|
+
private readonly onAfterEdgePriorityUpdated;
|
|
495
|
+
private readonly onBeforeEdgeRemoved;
|
|
496
|
+
private readonly onBeforeClear;
|
|
497
|
+
constructor(graphStore: GraphStore, htmlView: HtmlView, params: GraphControllerParams);
|
|
498
|
+
addNode(request: AddNodeRequest): void;
|
|
499
|
+
updateNode(nodeId: Identifier, request?: UpdateNodeRequest | undefined): void;
|
|
500
|
+
removeNode(nodeId: Identifier): void;
|
|
501
|
+
markPort(request: MarkPortRequest): void;
|
|
502
|
+
updatePort(portId: Identifier, request?: UpdatePortRequest | undefined): void;
|
|
503
|
+
unmarkPort(portId: Identifier): void;
|
|
504
|
+
addEdge(request: AddEdgeRequest): void;
|
|
505
|
+
updateEdge(edgeId: Identifier, request?: UpdateEdgeRequest | undefined): void;
|
|
506
|
+
removeEdge(edgeId: Identifier): void;
|
|
507
|
+
clear(): void;
|
|
508
|
+
destroy(): void;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
declare interface GraphControllerParams {
|
|
512
|
+
readonly nodes: {
|
|
513
|
+
readonly centerFn: CenterFn;
|
|
514
|
+
readonly priorityFn: PriorityFn;
|
|
515
|
+
};
|
|
516
|
+
readonly ports: {
|
|
517
|
+
readonly direction: number;
|
|
518
|
+
};
|
|
519
|
+
readonly edges: {
|
|
520
|
+
readonly shapeFactory: EdgeShapeFactory;
|
|
521
|
+
readonly priorityFn: PriorityFn;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
588
525
|
export declare interface GraphEdge {
|
|
589
526
|
readonly from: Identifier;
|
|
590
527
|
readonly to: Identifier;
|
|
@@ -612,7 +549,7 @@ declare class GraphStore {
|
|
|
612
549
|
private readonly edges;
|
|
613
550
|
private readonly nodesElementsMap;
|
|
614
551
|
private readonly portIncomingEdges;
|
|
615
|
-
private readonly
|
|
552
|
+
private readonly portOutgoingEdges;
|
|
616
553
|
private readonly portCycleEdges;
|
|
617
554
|
private readonly elementPorts;
|
|
618
555
|
private readonly afterNodeAddedEmitter;
|
|
@@ -765,7 +702,7 @@ declare type LayoutAlgorithmConfig = {
|
|
|
765
702
|
readonly type: "custom";
|
|
766
703
|
readonly instance: LayoutAlgorithm;
|
|
767
704
|
} | {
|
|
768
|
-
readonly type
|
|
705
|
+
readonly type?: "forceDirected";
|
|
769
706
|
readonly dtSec?: number | undefined;
|
|
770
707
|
readonly maxIterations?: number | undefined;
|
|
771
708
|
readonly seed?: string | undefined;
|
|
@@ -866,6 +803,8 @@ export declare interface ScaleLimitPreprocessorParams {
|
|
|
866
803
|
readonly maxContentScale: number | null;
|
|
867
804
|
}
|
|
868
805
|
|
|
806
|
+
declare type ScheduleFn = (callback: () => void) => void;
|
|
807
|
+
|
|
869
808
|
export declare interface ShiftLimitPreprocessorParams {
|
|
870
809
|
readonly minX: number | null;
|
|
871
810
|
readonly maxX: number | null;
|
|
@@ -976,12 +915,6 @@ export declare type TransformDeclaration = {
|
|
|
976
915
|
readonly origin?: Point;
|
|
977
916
|
};
|
|
978
917
|
|
|
979
|
-
export declare interface TransformPayload {
|
|
980
|
-
readonly scale: number;
|
|
981
|
-
readonly x: number;
|
|
982
|
-
readonly y: number;
|
|
983
|
-
}
|
|
984
|
-
|
|
985
918
|
declare type TransformPreprocessorConfig = {
|
|
986
919
|
readonly type: "scale-limit";
|
|
987
920
|
readonly minContentScale?: number;
|
|
@@ -994,11 +927,11 @@ declare type TransformPreprocessorConfig = {
|
|
|
994
927
|
readonly maxY?: number;
|
|
995
928
|
} | TransformPreprocessorFn;
|
|
996
929
|
|
|
997
|
-
export declare type TransformPreprocessorFn = (params: TransformPreprocessorParams) =>
|
|
930
|
+
export declare type TransformPreprocessorFn = (params: TransformPreprocessorParams) => TransformState;
|
|
998
931
|
|
|
999
932
|
export declare interface TransformPreprocessorParams {
|
|
1000
|
-
readonly prevTransform:
|
|
1001
|
-
readonly nextTransform:
|
|
933
|
+
readonly prevTransform: TransformState;
|
|
934
|
+
readonly nextTransform: TransformState;
|
|
1002
935
|
readonly canvasWidth: number;
|
|
1003
936
|
readonly canvasHeight: number;
|
|
1004
937
|
}
|
|
@@ -1008,6 +941,8 @@ declare interface TransformState {
|
|
|
1008
941
|
readonly x: number;
|
|
1009
942
|
readonly y: number;
|
|
1010
943
|
}
|
|
944
|
+
export { TransformState as TransformPayload }
|
|
945
|
+
export { TransformState }
|
|
1011
946
|
|
|
1012
947
|
export declare interface UpdateEdgeRequest {
|
|
1013
948
|
readonly from?: Identifier | undefined;
|
|
@@ -1097,6 +1032,27 @@ export declare class Viewport {
|
|
|
1097
1032
|
createViewportCoords(contentCoords: Point): Point;
|
|
1098
1033
|
}
|
|
1099
1034
|
|
|
1035
|
+
declare class ViewportController {
|
|
1036
|
+
private readonly graphStore;
|
|
1037
|
+
private readonly viewportStore;
|
|
1038
|
+
private readonly params;
|
|
1039
|
+
constructor(graphStore: GraphStore, viewportStore: ViewportStore, params: ViewportControllerParams);
|
|
1040
|
+
patchViewportMatrix(request: PatchMatrixRequest): void;
|
|
1041
|
+
patchContentMatrix(request: PatchMatrixRequest): void;
|
|
1042
|
+
center(target: Point, config?: CenterConfig | undefined): void;
|
|
1043
|
+
focus(config?: FocusConfig | undefined): void;
|
|
1044
|
+
destroy(): void;
|
|
1045
|
+
private navigate;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
declare interface ViewportControllerParams {
|
|
1049
|
+
readonly focus: {
|
|
1050
|
+
readonly contentOffset: number;
|
|
1051
|
+
readonly minContentScale: number;
|
|
1052
|
+
readonly schedule: ScheduleFn;
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1100
1056
|
declare class ViewportStore {
|
|
1101
1057
|
private readonly host;
|
|
1102
1058
|
private viewportMatrix;
|