@cosmos.gl/graph 3.0.0-beta.5 → 3.0.0-beta.7

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
@@ -75,6 +75,25 @@ graph.render()
75
75
 
76
76
  ---
77
77
 
78
+ ### What's New in v3.0?
79
+
80
+ cosmos.gl v3.0 brings a new rendering engine, async initialization, and several new features:
81
+
82
+ - **luma.gl (WebGL 2)** — rendering ported from regl to [luma.gl](https://luma.gl/), with support for sharing a custom `Device` across multiple graphs via `new Graph(div, config, devicePromise)`.
83
+ - **Async initialization** — the constructor returns immediately; all public methods queue until the device is ready. Use `graph.ready` / `graph.isReady` to know when the graph is usable.
84
+ - **Simulation control** — rendering is now separate from simulation. The simulation starts automatically by default; use `start()`, `stop()`, `pause()`, and `unpause()` to control it independently.
85
+ - **Link sampling** — sample visible links on screen with `getSampledLinks()` and `getSampledLinkPositionsMap()` for rendering labels or overlays along links.
86
+ - **Context menu support** — new callbacks for right-click interactions: `onContextMenu`, `onPointContextMenu`, `onLinkContextMenu`, `onBackgroundContextMenu`.
87
+ - **Fit viewport to points** — `setZoomTransformByPointPositions()` zooms and pans to fit a set of points into view.
88
+ - **Hover improvements** — `onPointMouseOver` now includes an `isSelected` parameter; hover correctly highlights the topmost point when points overlap.
89
+ - **Config API changes** — `setConfig()` now resets all values to defaults before applying; use the new `setConfigPartial()` to update individual properties without resetting the rest.
90
+ - **Init-only config fields** — `enableSimulation`, `initialZoomLevel`, `randomSeed`, and `attribution` can only be set during initialization and are preserved across config updates.
91
+ - **Default point shape** — new `pointDefaultShape` config property lets you set the fallback shape for all points when no per-point shapes are provided. Accepts a `PointShape` enum value (e.g., `PointShape.Star`), a plain number (e.g., `6`), or a numeric string (e.g., `"6"`).
92
+ - **Exported defaults** — `defaultConfigValues` is now part of the public API.
93
+ - **Optimized hover detection** — skips GPU work when the mouse hasn't moved.
94
+
95
+ Check the [Migration Guide](./migration-notes.md) for upgrading from v2.
96
+
78
97
  ### What's New in v2.0?
79
98
 
80
99
  cosmos.gl v2.0 introduces significant improvements in performance and data handling:
@@ -86,7 +105,7 @@ cosmos.gl v2.0 introduces significant improvements in performance and data handl
86
105
  - New Point Clustering force (`setPointClusters`, `setClusterPositions` and `setPointClusterStrength`).
87
106
  - Ability to drag points.
88
107
 
89
- Check the [Migration Guide](./cosmos-2-0-migration-notes.md) for details.
108
+ Check the [Migration Guide](./migration-notes.md) for upgrading from v1.
90
109
 
91
110
  ---
92
111
 
@@ -116,7 +135,7 @@ Check the [Migration Guide](./cosmos-2-0-migration-notes.md) for details.
116
135
  - 🧑‍💻 [Quick Start](https://cosmosgl.github.io/graph/?path=/docs/welcome-to-cosmos--docs)
117
136
  - 🛠 [Configuration](https://cosmosgl.github.io/graph/?path=/docs/configuration--docs)
118
137
  - ⚙️ [API Reference](https://cosmosgl.github.io/graph/?path=/docs/api-reference--docs)
119
- - 🚀 [Migration Guide](https://github.com/cosmosgl/graph/blob/main/cosmos-2-0-migration-notes.md)
138
+ - 🚀 [Migration Guide](https://github.com/cosmosgl/graph/blob/main/migration-notes.md)
120
139
 
121
140
  ---
122
141
 
package/dist/config.d.ts CHANGED
@@ -1,54 +1,54 @@
1
1
  import { D3ZoomEvent } from 'd3-zoom';
2
2
  import { D3DragEvent } from 'd3-drag';
3
3
  import { Hovered } from './modules/Store';
4
+ import { PointShape } from './modules/GraphData';
4
5
  export interface GraphConfigInterface {
5
6
  /**
6
7
  * If set to `false`, the simulation will not run.
7
8
  * This property will be applied only on component initialization and it
8
- * can't be changed using the `setConfig` method.
9
+ * can't be changed using the `setConfig` or `setConfigPartial` methods.
9
10
  * Default value: `true`
10
11
  */
11
- enableSimulation?: boolean;
12
+ enableSimulation: boolean;
12
13
  /**
13
14
  * Canvas background color.
14
15
  * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
15
16
  * Default value: '#222222'
16
17
  */
17
- backgroundColor?: string | [number, number, number, number];
18
+ backgroundColor: string | [number, number, number, number];
18
19
  /**
19
- * Simulation space size (max 8192).
20
- * Default value: `8192`
20
+ * Simulation space size.
21
+ * Default value: `4096` (larger values may crash on some devices, e.g. iOS; see https://github.com/cosmosgl/graph/issues/203).
21
22
  */
22
- spaceSize?: number;
23
+ spaceSize: number;
23
24
  /**
24
25
  * The default color to use for points when no point colors are provided,
25
26
  * or if the color value in the array is `undefined` or `null`.
26
27
  * This can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values
27
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
28
+ * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 1.
28
29
  * Default value: '#b3b3b3'
29
30
  */
30
- pointDefaultColor?: string | [number, number, number, number];
31
- /** @deprecated Use `pointDefaultColor` instead */
32
- pointColor?: string | [number, number, number, number];
31
+ pointDefaultColor: string | [number, number, number, number];
33
32
  /**
34
33
  * The color to use for points when they are greyed out (when selection is active).
35
34
  * This can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values
36
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
35
+ * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 1.
37
36
  *
38
37
  * If not provided, the color will be the same as the point's original color,
39
38
  * but darkened or lightened depending on the background color.
40
39
  *
41
- * If `pointGreyoutOpacity` is also defined, it will override the alpha/opacity component
40
+ * If `pointGreyoutOpacity` is also defined, it will be multiplied with the final alpha
42
41
  * of this color.
43
42
  *
44
43
  * Default value: `undefined`
45
44
  */
46
45
  pointGreyoutColor?: string | [number, number, number, number];
47
46
  /**
48
- * Opacity value for points when they are greyed out (when selection is active).
47
+ * Opacity multiplier for points when they are greyed out (when selection is active).
49
48
  * Values range from 0 (completely transparent) to 1 (fully opaque).
50
49
  *
51
- * If defined, this value will override the alpha/opacity component of `pointGreyoutColor`.
50
+ * When defined, this value is multiplied with the point's final alpha instead of the
51
+ * default `pointOpacity`. When `undefined`, greyed-out points use `pointOpacity` as their multiplier.
52
52
  *
53
53
  * Default value: `undefined`
54
54
  */
@@ -58,48 +58,53 @@ 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 */
63
- pointSize?: number;
61
+ pointDefaultSize: number;
62
+ /**
63
+ * The default shape to use for points when no point shapes are provided via `setPointShapes()`,
64
+ * or if the shape value in the array is `undefined`, `null`, or invalid.
65
+ * Accepts a `PointShape` enum value (e.g., `PointShape.Circle`), a plain number (e.g., `2`), or a numeric string (e.g., `"2"`).
66
+ * Default value: `PointShape.Circle`
67
+ */
68
+ pointDefaultShape: PointShape | `${PointShape}`;
64
69
  /**
65
70
  * Universal opacity value applied to all points.
66
71
  * This value multiplies with individual point alpha values (if set via setPointColors).
67
72
  * Useful for dynamically controlling opacity of all points without updating individual RGBA arrays.
68
73
  * Default value: `1.0`
69
74
  */
70
- pointOpacity?: number;
75
+ pointOpacity: number;
71
76
  /**
72
77
  * Scale factor for the point size.
73
78
  * Default value: `1`
74
79
  */
75
- pointSizeScale?: number;
80
+ pointSizeScale: number;
76
81
  /**
77
82
  * Cursor style to use when hovering over a point
78
83
  * Default value: `auto`
79
84
  */
80
- hoveredPointCursor?: string;
85
+ hoveredPointCursor: string;
81
86
  /**
82
87
  * Cursor style to use when hovering over a link
83
88
  * Default value: `auto`
84
89
  */
85
- hoveredLinkCursor?: string;
90
+ hoveredLinkCursor: string;
86
91
  /**
87
92
  * Turns ring rendering around a point on hover on / off
88
93
  * Default value: `false`
89
94
  */
90
- renderHoveredPointRing?: boolean;
95
+ renderHoveredPointRing: boolean;
91
96
  /**
92
97
  * Hovered point ring color hex value.
93
98
  * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
94
99
  * Default value: `white`
95
100
  */
96
- hoveredPointRingColor?: string | [number, number, number, number];
101
+ hoveredPointRingColor: string | [number, number, number, number];
97
102
  /**
98
103
  * Focused point ring color hex value.
99
104
  * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
100
105
  * Default value: `white`
101
106
  */
102
- focusedPointRingColor?: string | [number, number, number, number];
107
+ focusedPointRingColor: string | [number, number, number, number];
103
108
  /**
104
109
  * Set focus on a point by index. A ring will be highlighted around the focused point.
105
110
  * When set to `undefined`, no point is focused.
@@ -110,40 +115,36 @@ export interface GraphConfigInterface {
110
115
  * Turns link rendering on / off.
111
116
  * Default value: `true`
112
117
  */
113
- renderLinks?: boolean;
118
+ renderLinks: boolean;
114
119
  /**
115
120
  * The default color to use for links when no link colors are provided,
116
121
  * or if the color value in the array is `undefined` or `null`.
117
122
  * This can be either a hex color string (e.g., '#666666') or an array of RGBA values
118
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
123
+ * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 1.
119
124
  * Default value: '#666666'
120
125
  */
121
- linkDefaultColor?: string | [number, number, number, number];
122
- /** @deprecated Use `linkDefaultColor` instead */
123
- linkColor?: string | [number, number, number, number];
126
+ linkDefaultColor: string | [number, number, number, number];
124
127
  /**
125
128
  * Universal opacity value applied to all links.
126
129
  * This value multiplies with individual link alpha values (if set via setLinkColors).
127
130
  * Useful for dynamically controlling opacity of all links without updating individual RGBA arrays.
128
131
  * Default value: `1.0`
129
132
  */
130
- linkOpacity?: number;
133
+ linkOpacity: number;
131
134
  /**
132
135
  * Greyed out link opacity value when the selection is active.
133
136
  * Default value: `0.1`
134
137
  */
135
- linkGreyoutOpacity?: number;
138
+ linkGreyoutOpacity: number;
136
139
  /**
137
140
  * 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`.
138
141
  * Default value: `1`
139
142
  */
140
- linkDefaultWidth?: number;
141
- /** @deprecated Use `linkDefaultWidth` instead */
142
- linkWidth?: number;
143
+ linkDefaultWidth: number;
143
144
  /**
144
145
  * The color to use for links when they are hovered.
145
146
  * This can be either a hex color string (e.g., '#ff3333') or an array of RGBA values
146
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
147
+ * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 1.
147
148
  * Default value: `undefined`
148
149
  */
149
150
  hoveredLinkColor?: string | [number, number, number, number];
@@ -152,51 +153,49 @@ export interface GraphConfigInterface {
152
153
  * The hovered width is calculated as: originalWidth + hoveredLinkWidthIncrease
153
154
  * Default value: `5`
154
155
  */
155
- hoveredLinkWidthIncrease?: number;
156
+ hoveredLinkWidthIncrease: number;
156
157
  /**
157
158
  * Scale factor for the link width.
158
159
  * Default value: `1`
159
160
  */
160
- linkWidthScale?: number;
161
+ linkWidthScale: number;
161
162
  /**
162
163
  * Increase or decrease the size of the links when zooming in or out.
163
164
  * Default value: `false`
164
165
  */
165
- scaleLinksOnZoom?: boolean;
166
+ scaleLinksOnZoom: boolean;
166
167
  /**
167
168
  * If set to true, links are rendered as curved lines.
168
169
  * Otherwise as straight lines.
169
170
  * Default value: `false`
170
171
  */
171
- curvedLinks?: boolean;
172
+ curvedLinks: boolean;
172
173
  /**
173
174
  * Number of segments in a curved line.
174
175
  * Default value: `19`.
175
176
  */
176
- curvedLinkSegments?: number;
177
+ curvedLinkSegments: number;
177
178
  /**
178
179
  * Weight affects the shape of the curve.
179
180
  * Default value: `0.8`.
180
181
  */
181
- curvedLinkWeight?: number;
182
+ curvedLinkWeight: number;
182
183
  /**
183
184
  * Defines the position of the control point of the curve on the normal from the centre of the line.
184
185
  * If set to 1 then the control point is at a distance equal to the length of the line.
185
186
  * Default value: `0.5`
186
187
  */
187
- curvedLinkControlPointDistance?: number;
188
+ curvedLinkControlPointDistance: number;
188
189
  /**
189
190
  * The default link arrow value that controls whether or not to display link arrows.
190
191
  * Default value: `false`
191
192
  */
192
- linkDefaultArrows?: boolean;
193
- /** @deprecated Use `linkDefaultArrows` instead */
194
- linkArrows?: boolean;
193
+ linkDefaultArrows: boolean;
195
194
  /**
196
195
  * Scale factor for the link arrows size.
197
196
  * Default value: `1`
198
197
  */
199
- linkArrowsSizeScale?: number;
198
+ linkArrowsSizeScale: number;
200
199
  /**
201
200
  * The range defines the minimum and maximum link visibility distance in pixels.
202
201
  * The link will be fully opaque when its length is less than the first number in the array,
@@ -206,77 +205,77 @@ export interface GraphConfigInterface {
206
205
  * (e.g. links become longer when you zoom in, and shorter when you zoom out).
207
206
  * Default value: `[50, 150]`
208
207
  */
209
- linkVisibilityDistanceRange?: number[];
208
+ linkVisibilityDistanceRange: number[];
210
209
  /**
211
210
  * The transparency value that the link will have when its length reaches
212
211
  * the maximum link distance value from `linkVisibilityDistanceRange`.
213
212
  * Default value: `0.25`
214
213
  */
215
- linkVisibilityMinTransparency?: number;
214
+ linkVisibilityMinTransparency: number;
216
215
  /**
217
216
  * Decay coefficient. Use smaller values if you want the simulation to "cool down" slower.
218
217
  * Default value: `5000`
219
218
  */
220
- simulationDecay?: number;
219
+ simulationDecay: number;
221
220
  /**
222
221
  * Gravity force coefficient.
223
222
  * Default value: `0.25`
224
223
  */
225
- simulationGravity?: number;
224
+ simulationGravity: number;
226
225
  /**
227
226
  * Centering to center mass force coefficient.
228
227
  * Default value: `0`
229
228
  */
230
- simulationCenter?: number;
229
+ simulationCenter: number;
231
230
  /**
232
231
  * Repulsion force coefficient.
233
232
  * Default value: `1.0`
234
233
  */
235
- simulationRepulsion?: number;
234
+ simulationRepulsion: number;
236
235
  /**
237
236
  * Decreases / increases the detalization of the Many-Body force calculations.
238
237
  * Default value: `1.15`
239
238
  */
240
- simulationRepulsionTheta?: number;
239
+ simulationRepulsionTheta: number;
241
240
  /**
242
241
  * Link spring force coefficient.
243
242
  * Default value: `1`
244
243
  */
245
- simulationLinkSpring?: number;
244
+ simulationLinkSpring: number;
246
245
  /**
247
246
  * Minimum link distance.
248
247
  * Default value: `10`
249
248
  */
250
- simulationLinkDistance?: number;
249
+ simulationLinkDistance: number;
251
250
  /**
252
251
  * Range of random link distance values.
253
252
  * Default value: `[1, 1.2]`
254
253
  */
255
- simulationLinkDistRandomVariationRange?: number[];
254
+ simulationLinkDistRandomVariationRange: number[];
256
255
  /**
257
256
  * Repulsion coefficient from mouse position.
258
257
  * The repulsion force is activated by pressing the right mouse button.
259
258
  * Default value: `2`
260
259
  */
261
- simulationRepulsionFromMouse?: number;
260
+ simulationRepulsionFromMouse: number;
262
261
  /**
263
262
  * Enable or disable the repulsion force from mouse when right-clicking.
264
263
  * When set to `true`, holding the right mouse button will activate the mouse repulsion force.
265
264
  * When set to `false`, right-clicking will not trigger any repulsion force.
266
265
  * Default value: `false`
267
266
  */
268
- enableRightClickRepulsion?: boolean;
267
+ enableRightClickRepulsion: boolean;
269
268
  /**
270
269
  * Friction coefficient.
271
270
  * Values range from 0 (high friction, stops quickly) to 1 (no friction, keeps moving).
272
271
  * Default value: `0.85`
273
272
  */
274
- simulationFriction?: number;
273
+ simulationFriction: number;
275
274
  /**
276
275
  * Cluster coefficient.
277
276
  * Default value: `0.1`
278
277
  */
279
- simulationCluster?: number;
278
+ simulationCluster: number;
280
279
  /**
281
280
  * Callback function that will be called when the simulation starts.
282
281
  * Default value: `undefined`
@@ -301,12 +300,6 @@ export interface GraphConfigInterface {
301
300
  * Default value: `undefined`
302
301
  */
303
302
  onSimulationPause?: () => void;
304
- /**
305
- * Callback function that will be called when the simulation is restarted.
306
- * @deprecated Use `onSimulationUnpause` instead. This callback will be removed in a future version.
307
- * Default value: `undefined`
308
- */
309
- onSimulationRestart?: () => void;
310
303
  /**
311
304
  * Callback function that will be called when the simulation is unpaused.
312
305
  * Default value: `undefined`
@@ -461,64 +454,67 @@ export interface GraphConfigInterface {
461
454
  * Show WebGL performance monitor.
462
455
  * Default value: `false`
463
456
  */
464
- showFPSMonitor?: boolean;
457
+ showFPSMonitor: boolean;
465
458
  /**
466
459
  * Pixel ratio for the canvas. Higher values use more GPU memory but provide better quality on high-DPI displays.
467
460
  * Default value: `window.devicePixelRatio || 2`
468
461
  */
469
- pixelRatio?: number;
462
+ pixelRatio: number;
470
463
  /**
471
464
  * Increase or decrease the size of the points when zooming in or out.
472
465
  * Default value: `false`
473
466
  */
474
- scalePointsOnZoom?: boolean;
467
+ scalePointsOnZoom: boolean;
475
468
  /**
476
- * Initial zoom level. Can be set once during graph initialization.
469
+ * Initial zoom level. This property will be applied only on component initialization and it
470
+ * can't be changed using the `setConfig` or `setConfigPartial` methods.
477
471
  * If set, `fitViewOnInit` value will be ignored.
478
472
  * Default value: `undefined`
479
473
  */
480
474
  initialZoomLevel?: number;
481
475
  /**
482
476
  * Enables or disables zooming in and out.
483
- * Default: `true`
477
+ * Default value: `true`
484
478
  */
485
- enableZoom?: boolean;
479
+ enableZoom: boolean;
486
480
  /**
487
- * Controls whether the simulation remains active during zoom operations.
481
+ * Controls whether the simulation remains active during interactive (user-driven) zoom operations.
488
482
  * When set to `true`, the simulation continues running while zooming.
489
483
  * When set to `false`, the simulation pauses during zoom operations.
484
+ * Programmatic zoom methods (e.g., `zoomToPointByIndex`, `fitView`) default to running the simulation
485
+ * regardless of this setting, but can be controlled via their `enableSimulation` parameter.
490
486
  * Default value: `false`
491
487
  */
492
- enableSimulationDuringZoom?: boolean;
488
+ enableSimulationDuringZoom: boolean;
493
489
  /**
494
490
  * Enables or disables dragging of points in the graph.
495
491
  * Default value: `false`
496
492
  */
497
- enableDrag?: boolean;
493
+ enableDrag: boolean;
498
494
  /**
499
495
  * Whether to center and zoom the view to fit all points in the scene on initialization or not.
500
496
  * Ignored if `initialZoomLevel` is set.
501
497
  * Default: `true`
502
498
  */
503
- fitViewOnInit?: boolean;
499
+ fitViewOnInit: boolean;
504
500
  /**
505
501
  * Delay in milliseconds before fitting the view when `fitViewOnInit` is enabled.
506
502
  * Useful if you want the layout to stabilize a bit before fitting.
507
503
  * Default: `250`
508
504
  */
509
- fitViewDelay?: number;
505
+ fitViewDelay: number;
510
506
  /**
511
507
  * Padding to apply when fitting the view to show all points.
512
- * This value is added to the calculated bounding box to provide some extra space around the points.
508
+ * This value should be between 0 and 1, and is added to the calculated bounding box to provide some extra space around the points.
513
509
  * This is used when the `fitViewOnInit` option is enabled.
514
510
  * Default: `0.1`
515
511
  */
516
- fitViewPadding?: number;
512
+ fitViewPadding: number;
517
513
  /**
518
514
  * Duration in milliseconds for fitting the view to show all points when fitViewOnInit is enabled.
519
515
  * Default: `250`
520
516
  */
521
- fitViewDuration?: number;
517
+ fitViewDuration: number;
522
518
  /**
523
519
  * When `fitViewOnInit` is set to `true`, fits the view to show the points within a rectangle
524
520
  * defined by its two corner coordinates `[[left, bottom], [right, top]]` in the scene space.
@@ -536,16 +532,22 @@ export interface GraphConfigInterface {
536
532
  * the randomness of the layout across different simulation runs.
537
533
  * It is useful when you want the graph to always look the same on same datasets.
538
534
  * This property will be applied only on component initialization and it
539
- * can't be changed using the `setConfig` method.
535
+ * can't be changed using the `setConfig` or `setConfigPartial` methods.
540
536
  * Default value: undefined
541
537
  */
542
538
  randomSeed?: number | string;
543
539
  /**
544
540
  * Point sampling distance in pixels between neighboring points when calling the `getSampledPointPositionsMap` method.
545
541
  * This parameter determines how many points will be included in the sample.
546
- * Default value: `150`
542
+ * Default value: `100`
547
543
  */
548
- pointSamplingDistance?: number;
544
+ pointSamplingDistance: number;
545
+ /**
546
+ * Link sampling distance in pixels between neighboring links when calling the `getSampledLinks` method.
547
+ * This parameter determines how many links will be included in the sample (based on link midpoints in screen space).
548
+ * Default value: `100`
549
+ */
550
+ linkSamplingDistance: number;
549
551
  /**
550
552
  * Controls automatic position adjustment of points in the visible space.
551
553
  *
@@ -557,108 +559,54 @@ export interface GraphConfigInterface {
557
559
  * When explicitly set:
558
560
  * - `true`: Forces points positions to be rescaled
559
561
  * - `false`: Forces points positions to not be rescaled
562
+ *
563
+ * Default value: `undefined`
560
564
  */
561
565
  rescalePositions?: boolean | undefined;
562
566
  /**
563
567
  * Controls the text shown in the bottom right corner.
564
568
  * - When a non-empty string is provided: Displays the string as HTML
565
569
  * - When empty string or not provided: No text is displayed
570
+ *
571
+ * This property is applied only on component initialization and
572
+ * can't be changed using the `setConfig` or `setConfigPartial` methods.
573
+ *
574
+ * Default value: `''`
566
575
  */
567
- attribution?: string;
568
- }
569
- export declare class GraphConfig implements GraphConfigInterface {
570
- enableSimulation: boolean;
571
- backgroundColor: string;
572
- spaceSize: number;
573
- pointColor: string;
574
- pointDefaultColor: undefined;
575
- pointGreyoutOpacity: undefined;
576
- pointGreyoutColor: undefined;
577
- pointSize: number;
578
- pointDefaultSize: undefined;
579
- pointOpacity: number;
580
- pointSizeScale: number;
581
- hoveredPointCursor: string;
582
- hoveredLinkCursor: string;
583
- renderHoveredPointRing: boolean;
584
- hoveredPointRingColor: string;
585
- focusedPointRingColor: string;
586
- focusedPointIndex: undefined;
587
- linkColor: string;
588
- linkDefaultColor: undefined;
589
- linkOpacity: number;
590
- linkGreyoutOpacity: number;
591
- linkWidth: number;
592
- linkDefaultWidth: undefined;
593
- linkWidthScale: number;
594
- hoveredLinkColor: undefined;
595
- hoveredLinkWidthIncrease: number;
596
- renderLinks: boolean;
597
- curvedLinks: boolean;
598
- curvedLinkSegments: number;
599
- curvedLinkWeight: number;
600
- curvedLinkControlPointDistance: number;
601
- linkArrows: boolean;
602
- linkDefaultArrows: undefined;
603
- linkArrowsSizeScale: number;
604
- scaleLinksOnZoom: boolean;
605
- linkVisibilityDistanceRange: number[];
606
- linkVisibilityMinTransparency: number;
607
- simulationDecay: number;
608
- simulationGravity: number;
609
- simulationCenter: number;
610
- simulationRepulsion: number;
611
- simulationRepulsionTheta: number;
612
- simulationLinkSpring: number;
613
- simulationLinkDistance: number;
614
- simulationLinkDistRandomVariationRange: number[];
615
- simulationRepulsionFromMouse: number;
616
- enableRightClickRepulsion: boolean;
617
- simulationFriction: number;
618
- simulationCluster: number;
619
- onSimulationStart: GraphConfigInterface['onSimulationStart'];
620
- onSimulationTick: GraphConfigInterface['onSimulationTick'];
621
- onSimulationEnd: GraphConfigInterface['onSimulationEnd'];
622
- onSimulationPause: GraphConfigInterface['onSimulationPause'];
623
- onSimulationRestart: GraphConfigInterface['onSimulationRestart'];
624
- onSimulationUnpause: GraphConfigInterface['onSimulationUnpause'];
625
- onClick: GraphConfigInterface['onClick'];
626
- onPointClick: GraphConfigInterface['onPointClick'];
627
- onLinkClick: GraphConfigInterface['onLinkClick'];
628
- onBackgroundClick: GraphConfigInterface['onBackgroundClick'];
629
- onContextMenu: GraphConfigInterface['onContextMenu'];
630
- onPointContextMenu: GraphConfigInterface['onPointContextMenu'];
631
- onLinkContextMenu: GraphConfigInterface['onLinkContextMenu'];
632
- onBackgroundContextMenu: GraphConfigInterface['onBackgroundContextMenu'];
633
- onMouseMove: GraphConfigInterface['onMouseMove'];
634
- onPointMouseOver: GraphConfigInterface['onPointMouseOver'];
635
- onPointMouseOut: GraphConfigInterface['onPointMouseOut'];
636
- onLinkMouseOver: GraphConfigInterface['onLinkMouseOver'];
637
- onLinkMouseOut: GraphConfigInterface['onLinkMouseOut'];
638
- onZoomStart: GraphConfigInterface['onZoomStart'];
639
- onZoom: GraphConfigInterface['onZoom'];
640
- onZoomEnd: GraphConfigInterface['onZoomEnd'];
641
- onDragStart: GraphConfigInterface['onDragStart'];
642
- onDrag: GraphConfigInterface['onDrag'];
643
- onDragEnd: GraphConfigInterface['onDragEnd'];
644
- showFPSMonitor: boolean;
645
- pixelRatio: number;
646
- scalePointsOnZoom: boolean;
647
- initialZoomLevel: undefined;
648
- enableZoom: boolean;
649
- enableSimulationDuringZoom: boolean;
650
- enableDrag: boolean;
651
- fitViewOnInit: boolean;
652
- fitViewDelay: number;
653
- fitViewPadding: number;
654
- fitViewDuration: number;
655
- fitViewByPointsInRect: undefined;
656
- fitViewByPointIndices: undefined;
657
- randomSeed: undefined;
658
- pointSamplingDistance: number;
659
576
  attribution: string;
660
- rescalePositions: undefined;
661
- init(config: GraphConfigInterface): void;
662
- deepMergeConfig<T>(current: T, next: T, key: keyof T): void;
663
- private getConfig;
664
577
  }
578
+ /**
579
+ * Requires all keys from T to be present, while preserving
580
+ * the original value types (including `| undefined` for optional properties).
581
+ */
582
+ export type Complete<T> = {
583
+ [K in keyof Required<T>]: T[K];
584
+ };
585
+ /**
586
+ * Configuration options for the Graph constructor and `setConfig()` method.
587
+ * All properties are optional — any omitted properties will use their default values.
588
+ *
589
+ * Note: calling `setConfig()` fully resets the configuration to defaults before
590
+ * applying the provided values. Properties not included in the call will revert
591
+ * to their defaults, not retain their previous values.
592
+ */
593
+ export type GraphConfig = Partial<GraphConfigInterface>;
594
+ /** Returns a fresh copy of `defaultConfigValues` with arrays cloned to prevent shared references. */
595
+ export declare function createDefaultConfig(): GraphConfigInterface;
596
+ /**
597
+ * Resets the config object to default values in place, preserving the object reference
598
+ * so that modules (Zoom, Store, etc.) that hold a reference to it stay in sync.
599
+ */
600
+ export declare function resetConfigToDefaults(target: GraphConfigInterface): void;
601
+ /**
602
+ * Applies only the provided `source` values onto `target`, leaving all other
603
+ * properties unchanged.
604
+ *
605
+ * Mutates `target` in place (via `Object.assign`) rather than replacing it,
606
+ * because multiple modules (Zoom, Store, etc.) hold a reference to the same config object.
607
+ *
608
+ * - When `useDefaultsForUndefined` is `false` (default): explicit `undefined` values in `source` are skipped.
609
+ * - When `useDefaultsForUndefined` is `true`: explicit `undefined` values are replaced with their defaults.
610
+ * - Array values are shallow-cloned to prevent shared references.
611
+ */
612
+ export declare function applyConfig(target: GraphConfigInterface, source: GraphConfig, useDefaultsForUndefined?: boolean): void;