@html-graph/html-graph 0.0.53 → 0.0.54

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/main.d.ts CHANGED
@@ -2,7 +2,7 @@ export declare interface AddEdgeRequest {
2
2
  id?: unknown;
3
3
  from: string;
4
4
  to: string;
5
- options?: EdgeShape;
5
+ options?: EdgeShape_2;
6
6
  priority?: number;
7
7
  }
8
8
 
@@ -33,7 +33,7 @@ declare type BackgroundOptions = {
33
33
  readonly drawingFn: BackgroundDrawingFn;
34
34
  };
35
35
 
36
- export declare class BezierEdgeShape implements EdgeController {
36
+ export declare class BezierEdgeShape implements EdgeShape {
37
37
  private readonly color;
38
38
  private readonly width;
39
39
  private readonly curvature;
@@ -114,11 +114,11 @@ export declare interface Canvas {
114
114
  /**
115
115
  * applies transformation for viewport
116
116
  */
117
- patchViewportState(request: PatchViewportRequest): Canvas;
117
+ patchViewportState(request: PatchTransformRequest): Canvas;
118
118
  /**
119
- * moves viewport to nodes
119
+ * applies transformation for content
120
120
  */
121
- moveToNodes(nodeIds: readonly string[]): Canvas;
121
+ patchContentState(request: PatchTransformRequest): Canvas;
122
122
  /**
123
123
  * attaches canvas to given element
124
124
  */
@@ -160,8 +160,8 @@ export declare class CanvasCore implements Canvas {
160
160
  addEdge(edge: AddEdgeRequest): CanvasCore;
161
161
  updateEdge(edgeId: unknown, request: UpdateEdgeRequest): CanvasCore;
162
162
  removeEdge(edgeId: unknown): CanvasCore;
163
- patchViewportState(request: PatchViewportRequest): CanvasCore;
164
- moveToNodes(nodeIds: readonly string[]): CanvasCore;
163
+ patchViewportState(request: PatchTransformRequest): CanvasCore;
164
+ patchContentState(request: PatchTransformRequest): CanvasCore;
165
165
  clear(): CanvasCore;
166
166
  attach(element: HTMLElement): CanvasCore;
167
167
  detach(): CanvasCore;
@@ -212,7 +212,7 @@ export declare interface CoreOptions {
212
212
  /**
213
213
  * specifies default controller
214
214
  */
215
- readonly shape?: EdgeShape;
215
+ readonly shape?: EdgeShape_2;
216
216
  /**
217
217
  * specifies default z-index value
218
218
  */
@@ -283,7 +283,7 @@ declare interface CustomEdgeShape {
283
283
 
284
284
  declare type CustomPriority = PriorityFn;
285
285
 
286
- export declare class CycleCircleEdgeShape implements EdgeController {
286
+ export declare class CycleCircleEdgeShape implements EdgeShape {
287
287
  private readonly color;
288
288
  private readonly width;
289
289
  private readonly arrowLength;
@@ -298,7 +298,7 @@ export declare class CycleCircleEdgeShape implements EdgeController {
298
298
  update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
299
299
  }
300
300
 
301
- export declare class CycleSquareEdgeShape implements EdgeController {
301
+ export declare class CycleSquareEdgeShape implements EdgeShape {
302
302
  private readonly color;
303
303
  private readonly width;
304
304
  private readonly arrowLength;
@@ -315,7 +315,7 @@ export declare class CycleSquareEdgeShape implements EdgeController {
315
315
  update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
316
316
  }
317
317
 
318
- export declare class DetourStraightEdgeShape implements EdgeController {
318
+ export declare class DetourStraightEdgeShape implements EdgeShape {
319
319
  private readonly color;
320
320
  private readonly width;
321
321
  private readonly arrowLength;
@@ -341,21 +341,21 @@ export declare interface DragOptions {
341
341
  };
342
342
  }
343
343
 
344
- export declare interface EdgeController {
345
- readonly svg: SVGSVGElement;
346
- update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
347
- }
348
-
349
344
  declare interface EdgePayload {
350
345
  from: string;
351
346
  to: string;
352
- shape: EdgeController;
347
+ shape: EdgeShape;
353
348
  priority: number;
354
349
  }
355
350
 
356
- declare type EdgeShape = BezierEdgeShape_2 | StraightEdgeShape_2 | CustomEdgeShape | HorizontalEdgeShape_2 | VerticalEdgeShape_2;
351
+ export declare interface EdgeShape {
352
+ readonly svg: SVGSVGElement;
353
+ update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
354
+ }
355
+
356
+ declare type EdgeShape_2 = BezierEdgeShape_2 | StraightEdgeShape_2 | CustomEdgeShape | HorizontalEdgeShape_2 | VerticalEdgeShape_2;
357
357
 
358
- declare type EdgeShapeFactory = (type: EdgeType) => EdgeController;
358
+ declare type EdgeShapeFactory = (type: EdgeType) => EdgeShape;
359
359
 
360
360
  export declare enum EdgeType {
361
361
  Regular = "regular",
@@ -399,7 +399,7 @@ declare class GraphStore {
399
399
  getPort(portId: unknown): PortPayload | undefined;
400
400
  getPortNode(portId: string): unknown | undefined;
401
401
  removePort(portId: string): void;
402
- addEdge(edgeId: unknown, fromPortId: string, toPortId: string, shape: EdgeController, priority: number): void;
402
+ addEdge(edgeId: unknown, fromPortId: string, toPortId: string, shape: EdgeShape, priority: number): void;
403
403
  getEdge(edgeId: unknown): EdgePayload | undefined;
404
404
  removeEdge(edgeId: unknown): void;
405
405
  getPortAdjacentEdges(portId: string): readonly unknown[];
@@ -413,7 +413,7 @@ declare class GraphStore {
413
413
  getNodeCycleEdges(nodeId: unknown): readonly unknown[];
414
414
  }
415
415
 
416
- export declare class HorizontalEdgeShape implements EdgeController {
416
+ export declare class HorizontalEdgeShape implements EdgeShape {
417
417
  private readonly color;
418
418
  private readonly width;
419
419
  private readonly arrowLength;
@@ -487,7 +487,7 @@ declare interface NodePayload {
487
487
  priority: number;
488
488
  }
489
489
 
490
- export declare interface PatchViewportRequest {
490
+ export declare interface PatchTransformRequest {
491
491
  scale?: number;
492
492
  x?: number;
493
493
  y?: number;
@@ -506,10 +506,10 @@ export declare type PriorityFn = () => number;
506
506
  declare class PublicGraphStore {
507
507
  private readonly graphStore;
508
508
  constructor(graphStore: GraphStore);
509
- getNode(nodeId: unknown): GraphNode | undefined;
510
- getPort(portId: unknown): GraphPort | undefined;
511
- getPortNode(portId: string): unknown | undefined;
512
- getEdge(edgeId: unknown): GraphEdge | undefined;
509
+ getNode(nodeId: unknown): GraphNode | null;
510
+ getPort(portId: unknown): GraphPort | null;
511
+ getPortNode(portId: string): unknown | null;
512
+ getEdge(edgeId: unknown): GraphEdge | null;
513
513
  getPortAdjacentEdges(portId: string): readonly unknown[];
514
514
  getNodeAdjacentEdges(nodeId: unknown): readonly unknown[];
515
515
  getPortIncomingEdges(portId: unknown): readonly unknown[];
@@ -523,31 +523,13 @@ declare class PublicGraphStore {
523
523
  export declare class PublicViewportTransformer {
524
524
  private readonly transformer;
525
525
  constructor(transformer: ViewportTransformer);
526
- /**
527
- * for given absolute coordinates returns viewport coordinates
528
- * viewport coordinated represent actual coordinates on screen for given absolute coordinates
529
- */
530
- getViewCoords(xa: number, ya: number): [number, number];
531
- /**
532
- * returns viewport scale
533
- * it represents scale at which entities on canvas should be scaled to fit current scale
534
- */
535
- getViewScale(): number;
536
- /**
537
- * for given viewport coordinates returns absolute coordinates
538
- * absolute coordinates represent actual coordinates, which stay constant even for transformed canvas
539
- */
540
- getAbsCoords(xv: number, yv: number): [number, number];
541
- /**
542
- * returns absolute scale
543
- * it represents scale at which current viewport was scaled compared to initial state
544
- */
545
- getAbsScale(): number;
526
+ getViewportMatrix(): TransformState;
527
+ getContentMatrix(): TransformState;
546
528
  }
547
529
 
548
530
  declare type SharedIncrementalPriority = "shared-incremental";
549
531
 
550
- export declare class StraightEdgeShape implements EdgeController {
532
+ export declare class StraightEdgeShape implements EdgeShape {
551
533
  private readonly color;
552
534
  private readonly width;
553
535
  private readonly arrowLength;
@@ -600,8 +582,14 @@ export declare interface TransformPayload {
600
582
  readonly y: number;
601
583
  }
602
584
 
585
+ declare interface TransformState {
586
+ scale: number;
587
+ x: number;
588
+ y: number;
589
+ }
590
+
603
591
  export declare interface UpdateEdgeRequest {
604
- readonly controller?: EdgeController;
592
+ readonly controller?: EdgeShape;
605
593
  readonly priority?: number;
606
594
  }
607
595
 
@@ -645,8 +633,8 @@ export declare class UserDraggableNodesCanvas implements Canvas {
645
633
  addEdge(edge: AddEdgeRequest): UserDraggableNodesCanvas;
646
634
  updateEdge(edgeId: unknown, request: UpdateEdgeRequest): UserDraggableNodesCanvas;
647
635
  removeEdge(edgeId: unknown): UserDraggableNodesCanvas;
648
- patchViewportState(request: PatchViewportRequest): UserDraggableNodesCanvas;
649
- moveToNodes(nodeIds: readonly string[]): UserDraggableNodesCanvas;
636
+ patchViewportState(request: PatchTransformRequest): UserDraggableNodesCanvas;
637
+ patchContentState(request: PatchTransformRequest): UserDraggableNodesCanvas;
650
638
  clear(): UserDraggableNodesCanvas;
651
639
  attach(element: HTMLElement): UserDraggableNodesCanvas;
652
640
  detach(): UserDraggableNodesCanvas;
@@ -689,8 +677,8 @@ export declare class UserTransformableCanvas implements Canvas {
689
677
  addEdge(edge: AddEdgeRequest): UserTransformableCanvas;
690
678
  updateEdge(edgeId: unknown, request: UpdateEdgeRequest): UserTransformableCanvas;
691
679
  removeEdge(edgeId: unknown): UserTransformableCanvas;
692
- patchViewportState(request: PatchViewportRequest): UserTransformableCanvas;
693
- moveToNodes(nodeIds: readonly string[]): UserTransformableCanvas;
680
+ patchViewportState(request: PatchTransformRequest): UserTransformableCanvas;
681
+ patchContentState(request: PatchTransformRequest): UserTransformableCanvas;
694
682
  clear(): UserTransformableCanvas;
695
683
  attach(element: HTMLElement): UserTransformableCanvas;
696
684
  detach(): UserTransformableCanvas;
@@ -701,7 +689,7 @@ export declare class UserTransformableCanvas implements Canvas {
701
689
  private scaleViewport;
702
690
  }
703
691
 
704
- export declare class VerticalEdgeShape implements EdgeController {
692
+ export declare class VerticalEdgeShape implements EdgeShape {
705
693
  private readonly color;
706
694
  private readonly width;
707
695
  private readonly arrowLength;
@@ -733,12 +721,13 @@ declare interface VerticalEdgeShape_2 {
733
721
  }
734
722
 
735
723
  declare class ViewportTransformer {
736
- private state;
737
- getViewCoords(xa: number, ya: number): [number, number];
738
- getViewScale(): number;
739
- getAbsCoords(xv: number, yv: number): [number, number];
740
- getAbsScale(): number;
741
- patchState(scale: number | null, x: number | null, y: number | null): void;
724
+ private viewportMatrix;
725
+ private contentMatrix;
726
+ getViewportMatrix(): TransformState;
727
+ getContentMatrix(): TransformState;
728
+ patchViewportState(scale: number | null, x: number | null, y: number | null): void;
729
+ patchContentState(scale: number | null, x: number | null, y: number | null): void;
730
+ private calculateReverseMatrix;
742
731
  }
743
732
 
744
733
  export { }