@html-graph/html-graph 5.1.0 → 7.0.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="/media/logo-label.svg" alt="HTMLGraph" width="520" height="100"/>
3
3
  </p>
4
4
 
5
- <a target="_blank" href="https://html-graph.github.io/use-cases/advanced-demo/">
5
+ <a target="_blank" href="https://html-graph.github.io">
6
6
  <img width="100%" src="https://raw.githubusercontent.com/html-graph/html-graph/master/media/full-demo.gif"/>
7
7
  </a>
8
8
 
@@ -42,6 +42,27 @@ declare interface AddPortRequest {
42
42
  readonly direction: number;
43
43
  }
44
44
 
45
+ export declare interface AnimatedLayoutAlgorithm {
46
+ calculateNextCoordinates(graph: Graph, dt: number): ReadonlyMap<Identifier, Point>;
47
+ }
48
+
49
+ export declare interface AnimatedLayoutConfig {
50
+ readonly algorithm?: {
51
+ readonly type: "custom";
52
+ readonly instance: AnimatedLayoutAlgorithm;
53
+ } | {
54
+ readonly type?: "forceDirected";
55
+ readonly maxTimeDeltaSec?: number;
56
+ readonly nodeCharge?: number;
57
+ readonly nodeMass?: number;
58
+ readonly edgeEquilibriumLength?: number;
59
+ readonly edgeStiffness?: number;
60
+ readonly seed?: string;
61
+ readonly effectiveDistance?: number;
62
+ readonly convergenceDelta?: number;
63
+ } | undefined;
64
+ }
65
+
45
66
  export declare type ArrowRenderer = (params: ArrowRenderingParams) => string;
46
67
 
47
68
  export declare type ArrowRendererConfig = {
@@ -225,18 +246,23 @@ export declare class CanvasBuilder {
225
246
  private connectablePortsConfig;
226
247
  private draggableEdgesConfig;
227
248
  private virtualScrollConfig;
228
- private hasDraggableNode;
249
+ private layoutConfig;
250
+ private animatedLayoutConfig;
251
+ private hasDraggableNodes;
229
252
  private hasTransformableViewport;
230
253
  private hasNodeResizeReactiveEdges;
231
254
  private hasBackground;
232
255
  private hasUserConnectablePorts;
233
256
  private hasUserDraggableEdges;
257
+ private hasAnimatedLayout;
258
+ private hasLayout;
234
259
  private readonly boxRenderingTrigger;
235
260
  private readonly graphStore;
236
261
  private readonly viewportStore;
237
262
  private readonly graph;
238
263
  private readonly viewport;
239
264
  private readonly window;
265
+ private readonly animationStaticNodes;
240
266
  constructor(element: HTMLElement);
241
267
  /**
242
268
  * specifies default values for graph entities
@@ -267,7 +293,18 @@ export declare class CanvasBuilder {
267
293
  * enables edge creation by dragging one port to another
268
294
  */
269
295
  enableUserConnectablePorts(config?: ConnectablePortsConfig): CanvasBuilder;
296
+ /**
297
+ * enables edges dragging by dragging one of the adjacent ports
298
+ */
270
299
  enableUserDraggableEdges(config?: DraggableEdgesConfig): CanvasBuilder;
300
+ /**
301
+ * enables nodes positioning with specified layout
302
+ */
303
+ enableLayout(config?: LayoutConfig): CanvasBuilder;
304
+ /**
305
+ * enables animated nodes positioning with specified layout
306
+ */
307
+ enableAnimatedLayout(config?: AnimatedLayoutConfig): CanvasBuilder;
271
308
  /**
272
309
  * builds final canvas
273
310
  */
@@ -465,11 +502,22 @@ declare type EdgeShapeConfig = BezierEdgeShapeConfig | StraightEdgeShapeConfig |
465
502
 
466
503
  declare type EdgeShapeFactory = (edgeId: Identifier) => EdgeShape;
467
504
 
505
+ declare interface EventEmitter<T> {
506
+ emit(payload: T): void;
507
+ }
508
+
468
509
  declare interface EventHandler<T> {
469
510
  subscribe(callback: (payload: T) => void): void;
470
511
  unsubscribe(callback: (payload: T) => void): void;
471
512
  }
472
513
 
514
+ export declare class EventSubject<T> implements EventEmitter<T>, EventHandler<T> {
515
+ private readonly callbacks;
516
+ subscribe(callback: (payload: T) => void): void;
517
+ unsubscribe(callback: (payload: T) => void): void;
518
+ emit(payload: T): void;
519
+ }
520
+
473
521
  export declare class Graph {
474
522
  private readonly graphStore;
475
523
  readonly onAfterNodeAdded: EventHandler<Identifier>;
@@ -531,9 +579,9 @@ declare class GraphStore {
531
579
  private readonly ports;
532
580
  private readonly edges;
533
581
  private readonly nodesElementsMap;
534
- private readonly incomingEdges;
535
- private readonly outcomingEdges;
536
- private readonly cycleEdges;
582
+ private readonly portIncomingEdges;
583
+ private readonly portOutcomingEdges;
584
+ private readonly portCycleEdges;
537
585
  private readonly elementPorts;
538
586
  private readonly afterNodeAddedEmitter;
539
587
  readonly onAfterNodeAdded: EventHandler<Identifier>;
@@ -674,6 +722,36 @@ export declare class InteractiveEdgeShape implements StructuredEdgeShape {
674
722
  render(params: EdgeRenderParams): void;
675
723
  }
676
724
 
725
+ export declare interface LayoutAlgorithm {
726
+ calculateCoordinates(graph: Graph): ReadonlyMap<Identifier, Point>;
727
+ }
728
+
729
+ declare type LayoutAlgorithmConfig = {
730
+ readonly type: "custom";
731
+ readonly instance: LayoutAlgorithm;
732
+ } | {
733
+ readonly type: "forceDirected";
734
+ readonly dtSec?: number;
735
+ readonly maxIterations?: number;
736
+ readonly seed?: string;
737
+ readonly maxTimeDeltaSec?: number;
738
+ readonly nodeCharge?: number;
739
+ readonly nodeMass?: number;
740
+ readonly edgeEquilibriumLength?: number;
741
+ readonly edgeStiffness?: number;
742
+ readonly effectiveDistance?: number;
743
+ readonly convergenceDelta?: number;
744
+ };
745
+
746
+ export declare type LayoutApplyOn = {
747
+ type: "topologyChangeTimeout";
748
+ } | EventSubject<void>;
749
+
750
+ export declare interface LayoutConfig {
751
+ readonly algorithm?: LayoutAlgorithmConfig | undefined;
752
+ readonly applyOn?: LayoutApplyOn | undefined;
753
+ }
754
+
677
755
  export declare type MarkNodePortRequest = {
678
756
  readonly id?: Identifier | undefined;
679
757
  readonly element: HTMLElement;