@html-graph/html-graph 0.0.57 → 0.0.59

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
@@ -10,11 +10,11 @@
10
10
  <img width="100%" src="https://raw.githubusercontent.com/html-graph/html-graph/master/media/full-demo.gif"/>
11
11
  </a>
12
12
 
13
- Visit <a target="_blank" href="https://html-graph.github.io">use cases</a> and [use cases implementation](use-cases).
14
-
15
13
  Instead of connecting nodes directly this library uses concept of ports, which provide greater fexibility at managing edges.
16
14
  Port is an entity of a node to which edge can be attached to.
17
15
 
16
+ Visit <a target="_blank" href="https://html-graph.github.io">use cases</a> and [use cases implementation](use-cases).
17
+
18
18
  ## Features:
19
19
 
20
20
  - easy nodes customization using HTML
@@ -35,9 +35,6 @@ import { HtmlGraphBuilder } from "@html-graph/html-graph";
35
35
 
36
36
  const canvas = new HtmlGraphBuilder()
37
37
  .setOptions({
38
- background: {
39
- type: "dots",
40
- },
41
38
  edges: {
42
39
  shape: {
43
40
  hasTargetArrow: true,
package/dist/main.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- declare interface AbstractViewportTransformer {
2
- getViewportMatrix(): TransformState;
3
- getContentMatrix(): TransformState;
4
- patchViewportMatrix(scale: number | null, x: number | null, y: number | null): void;
5
- patchContentMatrix(scale: number | null, dx: number | null, dy: number | null): void;
6
- }
7
-
8
1
  export declare interface AddEdgeRequest {
9
2
  readonly id?: unknown;
10
3
  readonly from: string;
@@ -25,22 +18,6 @@ export declare interface AddNodeRequest {
25
18
  readonly priority?: number;
26
19
  }
27
20
 
28
- export declare type BackgroundDrawingFn = (ctx: CanvasRenderingContext2D, transformer: PublicViewportTransformer) => void;
29
-
30
- declare type BackgroundOptions = {
31
- readonly type: "none";
32
- } | {
33
- readonly type: "dots";
34
- readonly dotColor?: string;
35
- readonly dotGap?: number;
36
- readonly dotRadius?: number;
37
- readonly color?: string;
38
- readonly limit?: number;
39
- } | {
40
- readonly type: "custom";
41
- readonly drawingFn: BackgroundDrawingFn;
42
- };
43
-
44
21
  export declare class BezierEdgeShape implements EdgeShape {
45
22
  private readonly curvature;
46
23
  private readonly arrowLength;
@@ -51,7 +28,8 @@ export declare class BezierEdgeShape implements EdgeShape {
51
28
  private readonly sourceArrow;
52
29
  private readonly targetArrow;
53
30
  constructor(color: string, width: number, curvature: number, arrowLength: number, arrowWidth: number, hasSourceArrow: boolean, hasTargetArrow: boolean);
54
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
31
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
32
+ private createLinePath;
55
33
  }
56
34
 
57
35
  declare interface BezierEdgeShape_2 {
@@ -161,7 +139,7 @@ export declare class CanvasCore implements Canvas {
161
139
  updateNode(nodeId: unknown, request: UpdateNodeRequest): CanvasCore;
162
140
  removeNode(nodeId: unknown): CanvasCore;
163
141
  markPort(port: MarkPortRequest): CanvasCore;
164
- updatePort(portId: string, request: UpdatePortRequest): CanvasCore;
142
+ updatePort(portId: string, request?: UpdatePortRequest): CanvasCore;
165
143
  unmarkPort(portId: string): CanvasCore;
166
144
  addEdge(edge: AddEdgeRequest): CanvasCore;
167
145
  updateEdge(edgeId: unknown, request: UpdateEdgeRequest): CanvasCore;
@@ -179,10 +157,6 @@ export declare type CenterFn = (width: number, height: number) => Point;
179
157
  declare type ConstantPriority = number;
180
158
 
181
159
  export declare interface CoreOptions {
182
- /**
183
- * canvas background settings
184
- */
185
- readonly background?: BackgroundOptions;
186
160
  /**
187
161
  * nodes related behavior
188
162
  */
@@ -295,11 +269,11 @@ export declare class CycleCircleEdgeShape implements EdgeShape {
295
269
  private readonly radius;
296
270
  private readonly smallRadius;
297
271
  readonly svg: SVGSVGElement;
298
- private readonly group;
299
272
  private readonly line;
300
273
  private readonly arrow;
301
274
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, hasArrow: boolean, radius: number, smallRadius: number);
302
- update(x: number, y: number, _width: number, _height: number, from: GraphPort): void;
275
+ update(_to: Point, flipX: number, flipY: number, fromDir: number): void;
276
+ private createLinePath;
303
277
  }
304
278
 
305
279
  export declare class CycleSquareEdgeShape implements EdgeShape {
@@ -308,13 +282,29 @@ export declare class CycleSquareEdgeShape implements EdgeShape {
308
282
  private readonly side;
309
283
  private readonly minPortOffset;
310
284
  readonly svg: SVGSVGElement;
311
- private readonly group;
312
285
  private readonly line;
313
286
  private readonly arrow;
314
287
  private readonly roundness;
315
288
  private readonly linePoints;
316
289
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, hasArrow: boolean, side: number, minPortOffset: number, roundness: number);
317
- update(x: number, y: number, _width: number, _height: number, from: GraphPort): void;
290
+ update(_to: Point, flipX: number, flipY: number, fromDir: number): void;
291
+ private createLinePath;
292
+ }
293
+
294
+ export declare class DetourBezierEdgeShape implements EdgeShape {
295
+ private readonly curvature;
296
+ private readonly arrowLength;
297
+ private readonly arrowWidth;
298
+ readonly svg: SVGSVGElement;
299
+ private readonly group;
300
+ private readonly line;
301
+ private readonly sourceArrow;
302
+ private readonly targetArrow;
303
+ private readonly detourX;
304
+ private readonly detourY;
305
+ constructor(color: string, width: number, curvature: number, arrowLength: number, arrowWidth: number, hasSourceArrow: boolean, hasTargetArrow: boolean, detourDistance: number, detourDirection: number);
306
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
307
+ private createLinePath;
318
308
  }
319
309
 
320
310
  export declare class DetourStraightEdgeShape implements EdgeShape {
@@ -330,7 +320,8 @@ export declare class DetourStraightEdgeShape implements EdgeShape {
330
320
  private readonly detourX;
331
321
  private readonly detourY;
332
322
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number, detourDistance: number, detourDirection: number);
333
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
323
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
324
+ private createLinePath;
334
325
  }
335
326
 
336
327
  export declare interface DragOptions {
@@ -342,16 +333,9 @@ export declare interface DragOptions {
342
333
  };
343
334
  }
344
335
 
345
- declare interface EdgePayload {
346
- readonly from: unknown;
347
- readonly to: unknown;
348
- shape: EdgeShape;
349
- priority: number;
350
- }
351
-
352
336
  export declare interface EdgeShape {
353
337
  readonly svg: SVGSVGElement;
354
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
338
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
355
339
  }
356
340
 
357
341
  declare type EdgeShape_2 = BezierEdgeShape_2 | StraightEdgeShape_2 | CustomEdgeShape | HorizontalEdgeShape_2 | VerticalEdgeShape_2;
@@ -384,40 +368,6 @@ export declare interface GraphPort {
384
368
  readonly direction: number;
385
369
  }
386
370
 
387
- declare class GraphStore {
388
- private readonly nodes;
389
- private readonly ports;
390
- private readonly nodePorts;
391
- private readonly portNodeId;
392
- private readonly edges;
393
- private readonly incommingEdges;
394
- private readonly outcommingEdges;
395
- private readonly cycleEdges;
396
- addNode(nodeId: unknown, element: HTMLElement, x: number, y: number, centerFn: CenterFn, priority: number): void;
397
- getAllNodeIds(): readonly unknown[];
398
- getNode(nodeId: unknown): NodePayload | undefined;
399
- removeNode(nodeId: unknown): void;
400
- addPort(portId: unknown, element: HTMLElement, nodeId: unknown, centerFn: CenterFn, dir: number): void;
401
- getPort(portId: unknown): PortPayload | undefined;
402
- getAllPortIds(): readonly unknown[];
403
- getNodePortIds(nodeId: unknown): readonly unknown[] | undefined;
404
- getPortNodeId(portId: unknown): unknown | undefined;
405
- removePort(portId: unknown): void;
406
- addEdge(edgeId: unknown, fromPortId: unknown, toPortId: unknown, shape: EdgeShape, priority: number): void;
407
- getAllEdgeIds(): readonly unknown[];
408
- getEdge(edgeId: unknown): EdgePayload | undefined;
409
- removeEdge(edgeId: unknown): void;
410
- clear(): void;
411
- getPortIncomingEdgeIds(portId: unknown): readonly unknown[];
412
- getPortOutcomingEdgeIds(portId: unknown): readonly unknown[];
413
- getPortCycleEdgeIds(portId: unknown): readonly unknown[];
414
- getPortAdjacentEdgeIds(portId: unknown): readonly unknown[];
415
- getNodeIncomingEdgeIds(nodeId: unknown): readonly unknown[];
416
- getNodeOutcomingEdgeIds(nodeId: unknown): readonly unknown[];
417
- getNodeCycleEdgeIds(nodeId: unknown): readonly unknown[];
418
- getNodeAdjacentEdgeIds(nodeId: unknown): readonly unknown[];
419
- }
420
-
421
371
  export declare class HorizontalEdgeShape implements EdgeShape {
422
372
  private readonly arrowLength;
423
373
  private readonly arrowWidth;
@@ -429,7 +379,8 @@ export declare class HorizontalEdgeShape implements EdgeShape {
429
379
  private readonly sourceArrow;
430
380
  private readonly targetArrow;
431
381
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
432
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
382
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
383
+ private createLinePath;
433
384
  }
434
385
 
435
386
  declare interface HorizontalEdgeShape_2 {
@@ -487,14 +438,6 @@ export declare interface NodeDragPayload {
487
438
  readonly y: number;
488
439
  }
489
440
 
490
- declare interface NodePayload {
491
- element: HTMLElement;
492
- x: number;
493
- y: number;
494
- centerFn: CenterFn;
495
- priority: number;
496
- }
497
-
498
441
  export declare interface PatchMatrixRequest {
499
442
  readonly scale?: number;
500
443
  readonly dx?: number;
@@ -506,28 +449,20 @@ export declare interface Point {
506
449
  readonly y: number;
507
450
  }
508
451
 
509
- declare interface PortPayload {
510
- readonly element: HTMLElement;
511
- centerFn: CenterFn;
512
- direction: number;
513
- }
514
-
515
452
  declare type Priority = ConstantPriority | IncrementalPriority | SharedIncrementalPriority | CustomPriority;
516
453
 
517
454
  export declare type PriorityFn = () => number;
518
455
 
519
- declare class PublicGraphStore {
520
- private readonly graphStore;
521
- constructor(graphStore: GraphStore);
456
+ export declare interface PublicGraphStore {
522
457
  getAllNodeIds(): readonly unknown[];
523
458
  getAllPortIds(): readonly unknown[];
524
459
  getNode(nodeId: unknown): GraphNode | null;
525
460
  getNodePortIds(nodeId: unknown): readonly unknown[] | undefined;
526
461
  getPort(portId: unknown): GraphPort | null;
527
- getPortNodeId(portId: string): unknown | null;
462
+ getPortNodeId(portId: unknown): unknown | null;
528
463
  getAllEdgeIds(): readonly unknown[];
529
464
  getEdge(edgeId: unknown): GraphEdge | null;
530
- getPortAdjacentEdgeIds(portId: string): readonly unknown[];
465
+ getPortAdjacentEdgeIds(portId: unknown): readonly unknown[];
531
466
  getNodeAdjacentEdgeIds(nodeId: unknown): readonly unknown[];
532
467
  getPortIncomingEdgeIds(portId: unknown): readonly unknown[];
533
468
  getPortOutcomingEdgeIds(portId: unknown): readonly unknown[];
@@ -537,9 +472,7 @@ declare class PublicGraphStore {
537
472
  getNodeCycleEdgeIds(nodeId: unknown): readonly unknown[];
538
473
  }
539
474
 
540
- export declare class PublicViewportTransformer {
541
- private readonly transformer;
542
- constructor(transformer: AbstractViewportTransformer);
475
+ export declare interface PublicViewportTransformer {
543
476
  getViewportMatrix(): TransformState;
544
477
  getContentMatrix(): TransformState;
545
478
  }
@@ -557,7 +490,8 @@ export declare class StraightEdgeShape implements EdgeShape {
557
490
  private readonly sourceArrow;
558
491
  private readonly targetArrow;
559
492
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
560
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
493
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
494
+ private createLinePath;
561
495
  }
562
496
 
563
497
  declare interface StraightEdgeShape_2 {
@@ -575,7 +509,7 @@ declare interface StraightEdgeShape_2 {
575
509
  readonly detourDirection?: number;
576
510
  }
577
511
 
578
- export declare type TransformFinishedFn = (transform: TransformPayload) => void;
512
+ export declare type TransformFinishedFn = () => void;
579
513
 
580
514
  export declare interface TransformOptions {
581
515
  readonly scale?: {
@@ -741,7 +675,8 @@ export declare class VerticalEdgeShape implements EdgeShape {
741
675
  private readonly sourceArrow;
742
676
  private readonly targetArrow;
743
677
  constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
744
- update(x: number, y: number, width: number, height: number, from: GraphPort, to: GraphPort): void;
678
+ update(to: Point, flipX: number, flipY: number, fromDir: number, toDir: number): void;
679
+ private createLinePath;
745
680
  }
746
681
 
747
682
  declare interface VerticalEdgeShape_2 {