@cosmos.gl/graph 2.6.1 → 2.6.2

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/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { D3ZoomEvent } from 'd3-zoom';
2
2
  import { D3DragEvent } from 'd3-drag';
3
- import { type Hovered } from '@/graph/modules/Store';
3
+ import { Hovered } from './modules/Store';
4
4
  export interface GraphConfigInterface {
5
5
  /**
6
6
  * If set to `false`, the simulation will not run.
@@ -58,6 +58,8 @@ export interface GraphConfigInterface {
58
58
  * if the size value in the array is `undefined` or `null`.
59
59
  * Default value: `4`
60
60
  */
61
+ pointDefaultSize?: number;
62
+ /** @deprecated Use `pointDefaultSize` instead */
61
63
  pointSize?: number;
62
64
  /**
63
65
  * Universal opacity value applied to all points.
@@ -135,6 +137,8 @@ export interface GraphConfigInterface {
135
137
  * The default width value to use for links when no link widths are provided or if the width value in the array is `undefined` or `null`.
136
138
  * Default value: `1`
137
139
  */
140
+ linkDefaultWidth?: number;
141
+ /** @deprecated Use `linkDefaultWidth` instead */
138
142
  linkWidth?: number;
139
143
  /**
140
144
  * The color to use for links when they are hovered.
@@ -185,6 +189,8 @@ export interface GraphConfigInterface {
185
189
  * The default link arrow value that controls whether or not to display link arrows.
186
190
  * Default value: `false`
187
191
  */
192
+ linkDefaultArrows?: boolean;
193
+ /** @deprecated Use `linkDefaultArrows` instead */
188
194
  linkArrows?: boolean;
189
195
  /**
190
196
  * Scale factor for the link arrows size.
@@ -553,6 +559,7 @@ export declare class GraphConfig implements GraphConfigInterface {
553
559
  pointGreyoutOpacity: undefined;
554
560
  pointGreyoutColor: undefined;
555
561
  pointSize: number;
562
+ pointDefaultSize: undefined;
556
563
  pointOpacity: number;
557
564
  pointSizeScale: number;
558
565
  hoveredPointCursor: string;
@@ -566,6 +573,7 @@ export declare class GraphConfig implements GraphConfigInterface {
566
573
  linkOpacity: number;
567
574
  linkGreyoutOpacity: number;
568
575
  linkWidth: number;
576
+ linkDefaultWidth: undefined;
569
577
  linkWidthScale: number;
570
578
  hoveredLinkColor: undefined;
571
579
  hoveredLinkWidthIncrease: number;
@@ -575,6 +583,7 @@ export declare class GraphConfig implements GraphConfigInterface {
575
583
  curvedLinkWeight: number;
576
584
  curvedLinkControlPointDistance: number;
577
585
  linkArrows: boolean;
586
+ linkDefaultArrows: undefined;
578
587
  linkArrowsSizeScale: number;
579
588
  scaleLinksOnZoom: boolean;
580
589
  linkVisibilityDistanceRange: number[];
package/dist/helper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import regl from 'regl';
2
- import DOMPurify from 'dompurify';
1
+ import { default as regl } from 'regl';
2
+ import { default as DOMPurify } from 'dompurify';
3
3
  export declare const isFunction: <T>(a: T) => boolean;
4
4
  export declare const isArray: <T>(a: unknown | T[]) => a is T[];
5
5
  export declare const isObject: <T>(a: T) => boolean;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import 'd3-transition';
2
- import { GraphConfig, GraphConfigInterface } from '@/graph/config';
3
- import { GraphData } from '@/graph/modules/GraphData';
1
+ import { GraphConfig, GraphConfigInterface } from './config';
2
+ import { GraphData } from './modules/GraphData';
4
3
  export declare class Graph {
5
4
  config: GraphConfig;
6
5
  graph: GraphData;
@@ -257,11 +256,13 @@ export declare class Graph {
257
256
  */
258
257
  setPinnedPoints(pinnedIndices: number[] | null): void;
259
258
  /**
260
- * Renders the graph.
259
+ * Renders the graph and starts rendering.
260
+ * Does NOT modify simulation state - use start(), stop(), pause(), unpause() to control simulation.
261
261
  *
262
- * @param {number} [simulationAlpha] - Optional value between 0 and 1
263
- * that controls the initial energy of the simulation.The higher the value,
264
- * the more initial energy the simulation will get. Zero value stops the simulation.
262
+ * @param {number} [simulationAlpha] - Optional alpha value to set.
263
+ * - If 0: Sets alpha to 0, simulation stops after one frame (graph becomes static).
264
+ * - If positive: Sets alpha to that value.
265
+ * - If undefined: Keeps current alpha value.
265
266
  */
266
267
  render(simulationAlpha?: number): void;
267
268
  /**
@@ -458,12 +459,19 @@ export declare class Graph {
458
459
  getScaleY(): ((y: number) => number) | undefined;
459
460
  /**
460
461
  * Start the simulation.
462
+ * This only controls the simulation state, not rendering.
461
463
  * @param alpha Value from 0 to 1. The higher the value, the more initial energy the simulation will get.
462
464
  */
463
465
  start(alpha?: number): void;
466
+ /**
467
+ * Stop the simulation. This stops the simulation and resets its state.
468
+ * Use start() to begin a new simulation cycle.
469
+ */
470
+ stop(): void;
464
471
  /**
465
472
  * Pause the simulation. When paused, the simulation stops running
466
- * and can be resumed using the unpause method.
473
+ * but preserves its current state (progress, alpha).
474
+ * Can be resumed using the unpause method.
467
475
  */
468
476
  pause(): void;
469
477
  /**
@@ -478,7 +486,8 @@ export declare class Graph {
478
486
  */
479
487
  restart(): void;
480
488
  /**
481
- * Render only one frame of the simulation (stops the simulation if it was running).
489
+ * Run one step of the simulation manually.
490
+ * Works even when the simulation is paused.
482
491
  */
483
492
  step(): void;
484
493
  /**
@@ -501,10 +510,42 @@ export declare class Graph {
501
510
  * @returns An array of tuple positions
502
511
  */
503
512
  pair(pointPositions: number[]): [number, number][];
513
+ /**
514
+ * Updates and recreates the graph visualization based on pending changes.
515
+ *
516
+ * @param simulationAlpha - Optional alpha value to set. If not provided, keeps current alpha.
517
+ */
504
518
  private update;
519
+ /**
520
+ * Runs one step of the simulation (forces, position updates, alpha decay).
521
+ * This is the core simulation logic that can be called by step() or during rendering.
522
+ *
523
+ * @param forceExecution - Controls whether to run the simulation step when paused.
524
+ * - If true: Always runs the simulation step, even when isSimulationRunning is false.
525
+ * Used by step() to allow manual stepping while the simulation is paused.
526
+ * - If false: Only runs if isSimulationRunning is true. Used during rendering
527
+ * to respect pause/unpause state.
528
+ */
529
+ private runSimulationStep;
505
530
  private initPrograms;
531
+ /**
532
+ * The rendering loop - schedules itself to run continuously
533
+ */
506
534
  private frame;
535
+ /**
536
+ * Renders a single frame (the actual rendering logic).
537
+ * This does NOT schedule the next frame.
538
+ */
539
+ private renderFrame;
507
540
  private stopFrames;
541
+ /**
542
+ * Starts continuous rendering
543
+ */
544
+ private startFrames;
545
+ /**
546
+ * Called automatically when simulation completes (alpha < ALPHA_MIN).
547
+ * Rendering continues after this is called (for rendering/interaction).
548
+ */
508
549
  private end;
509
550
  private onClick;
510
551
  private updateMousePosition;