@cosmos.gl/graph 2.6.3 → 2.6.4

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.
Files changed (45) hide show
  1. package/dist/{src/config.d.ts → config.d.ts} +18 -2
  2. package/dist/{src/graph → graph}/utils/error-message.d.ts +1 -1
  3. package/dist/helper.d.ts +24 -0
  4. package/dist/{src/index.d.ts → index.d.ts} +5 -28
  5. package/dist/index.js +14658 -14
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +473 -1057
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/{src/modules → modules}/Clusters/index.d.ts +6 -13
  10. package/dist/{src/modules → modules}/ForceCenter/index.d.ts +3 -11
  11. package/dist/modules/ForceGravity/index.d.ts +6 -0
  12. package/dist/{src/modules → modules}/ForceLink/index.d.ts +4 -10
  13. package/dist/modules/ForceManyBody/index.d.ts +16 -0
  14. package/dist/modules/ForceManyBody/quadtree-frag-shader.d.ts +1 -0
  15. package/dist/modules/ForceManyBodyQuadtree/index.d.ts +15 -0
  16. package/dist/modules/ForceManyBodyQuadtree/quadtree-frag-shader.d.ts +1 -0
  17. package/dist/modules/ForceMouse/index.d.ts +6 -0
  18. package/dist/{src/modules → modules}/Lines/index.d.ts +5 -16
  19. package/dist/{src/modules → modules}/Points/index.d.ts +16 -32
  20. package/dist/modules/Shared/buffer.d.ts +8 -0
  21. package/dist/modules/Store/index.d.ts +75 -0
  22. package/dist/{src/modules → modules}/core-module.d.ts +3 -3
  23. package/dist/{src/variables.d.ts → variables.d.ts} +2 -0
  24. package/package.json +3 -2
  25. package/dist/index-CSMQs8iI.js +0 -19876
  26. package/dist/index-CSMQs8iI.js.map +0 -1
  27. package/dist/src/helper.d.ts +0 -61
  28. package/dist/src/modules/ForceGravity/index.d.ts +0 -13
  29. package/dist/src/modules/ForceManyBody/index.d.ts +0 -26
  30. package/dist/src/modules/ForceMouse/index.d.ts +0 -13
  31. package/dist/src/modules/Shared/buffer.d.ts +0 -1
  32. package/dist/src/modules/Shared/texture-utils.d.ts +0 -8
  33. package/dist/src/modules/Shared/uniform-utils.d.ts +0 -11
  34. package/dist/src/modules/Store/index.d.ts +0 -169
  35. package/dist/vite.config.d.ts +0 -2
  36. package/dist/webgl-device-QoBMYpnS.js +0 -3933
  37. package/dist/webgl-device-QoBMYpnS.js.map +0 -1
  38. /package/dist/{src/modules → modules}/Drag/index.d.ts +0 -0
  39. /package/dist/{src/modules → modules}/FPSMonitor/css.d.ts +0 -0
  40. /package/dist/{src/modules → modules}/FPSMonitor/index.d.ts +0 -0
  41. /package/dist/{src/modules → modules}/ForceLink/force-spring.d.ts +0 -0
  42. /package/dist/{src/modules → modules}/GraphData/index.d.ts +0 -0
  43. /package/dist/{src/modules → modules}/Lines/geometry.d.ts +0 -0
  44. /package/dist/{src/modules → modules}/Points/atlas-utils.d.ts +0 -0
  45. /package/dist/{src/modules → modules}/Zoom/index.d.ts +0 -0
@@ -213,6 +213,13 @@ export interface GraphConfigInterface {
213
213
  * Default value: `0.25`
214
214
  */
215
215
  linkVisibilityMinTransparency?: number;
216
+ /**
217
+ * Use the classic quadtree algorithm for the Many-Body force.
218
+ * This property will be applied only on component initialization and it
219
+ * can't be changed using the `setConfig` method.
220
+ * Default value: `false`
221
+ */
222
+ useClassicQuadtree?: boolean;
216
223
  /**
217
224
  * Decay coefficient. Use smaller values if you want the simulation to "cool down" slower.
218
225
  * Default value: `5000`
@@ -235,9 +242,16 @@ export interface GraphConfigInterface {
235
242
  simulationRepulsion?: number;
236
243
  /**
237
244
  * Decreases / increases the detalization of the Many-Body force calculations.
245
+ * When `useClassicQuadtree` is set to `true`, this property corresponds to the Barnes–Hut approximation criterion.
238
246
  * Default value: `1.15`
239
247
  */
240
248
  simulationRepulsionTheta?: number;
249
+ /**
250
+ * Barnes–Hut approximation depth.
251
+ * Can only be used when `useClassicQuadtree` is set `true`.
252
+ * Default value: `12`
253
+ */
254
+ simulationRepulsionQuadtreeLevels?: number;
241
255
  /**
242
256
  * Link spring force coefficient.
243
257
  * Default value: `1`
@@ -433,8 +447,8 @@ export interface GraphConfigInterface {
433
447
  */
434
448
  showFPSMonitor?: boolean;
435
449
  /**
436
- * Pixel ratio for the canvas. Higher values use more GPU memory but provide better quality on high-DPI displays.
437
- * Default value: `window.devicePixelRatio || 2`
450
+ * Canvas pixel ratio.
451
+ * Default value: `2`
438
452
  */
439
453
  pixelRatio?: number;
440
454
  /**
@@ -574,11 +588,13 @@ export declare class GraphConfig implements GraphConfigInterface {
574
588
  scaleLinksOnZoom: boolean;
575
589
  linkVisibilityDistanceRange: number[];
576
590
  linkVisibilityMinTransparency: number;
591
+ useClassicQuadtree: boolean;
577
592
  simulationDecay: number;
578
593
  simulationGravity: number;
579
594
  simulationCenter: number;
580
595
  simulationRepulsion: number;
581
596
  simulationRepulsionTheta: number;
597
+ simulationRepulsionQuadtreeLevels: number;
582
598
  simulationLinkSpring: number;
583
599
  simulationLinkDistance: number;
584
600
  simulationLinkDistRandomVariationRange: number[];
@@ -3,4 +3,4 @@
3
3
  * @param container The HTML element to append the error message to
4
4
  * @returns The created error div element
5
5
  */
6
- export declare function createWebGLErrorMessage(container: HTMLElement, error: string): HTMLDivElement;
6
+ export declare function createWebGLErrorMessage(container: HTMLElement): HTMLDivElement;
@@ -0,0 +1,24 @@
1
+ import { default as regl } from 'regl';
2
+ import { default as DOMPurify } from 'dompurify';
3
+ export declare const isFunction: <T>(a: T) => boolean;
4
+ export declare const isArray: <T>(a: unknown | T[]) => a is T[];
5
+ export declare const isObject: <T>(a: T) => boolean;
6
+ export declare const isAClassInstance: <T>(a: T) => boolean;
7
+ export declare const isPlainObject: <T>(a: T) => boolean;
8
+ export declare function getRgbaColor(value: string | [number, number, number, number]): [number, number, number, number];
9
+ export declare function rgbToBrightness(r: number, g: number, b: number): number;
10
+ export declare function readPixels(reglInstance: regl.Regl, fbo: regl.Framebuffer2D): Float32Array;
11
+ export declare function clamp(num: number, min: number, max: number): number;
12
+ export declare function isNumber(value: number | undefined | null | typeof NaN): boolean;
13
+ /**
14
+ * Sanitizes HTML content to prevent XSS attacks using DOMPurify
15
+ *
16
+ * This function is used internally to sanitize HTML content before setting innerHTML,
17
+ * such as in attribution text. It uses a safe default configuration that allows
18
+ * only common safe HTML elements and attributes.
19
+ *
20
+ * @param html The HTML string to sanitize
21
+ * @param options Optional DOMPurify configuration options to override defaults
22
+ * @returns Sanitized HTML string safe for innerHTML usage
23
+ */
24
+ export declare function sanitizeHtml(html: string, options?: DOMPurify.Config): string;
@@ -1,4 +1,3 @@
1
- import { Device } from '@luma.gl/core';
2
1
  import { GraphConfig, GraphConfigInterface } from './config';
3
2
  import { GraphData } from './modules/GraphData';
4
3
  export declare class Graph {
@@ -7,8 +6,7 @@ export declare class Graph {
7
6
  private canvas;
8
7
  private attributionDivElement;
9
8
  private canvasD3Selection;
10
- private device;
11
- private deviceInitPromise;
9
+ private reglInstance;
12
10
  private requestAnimationFrameId;
13
11
  private isRightClickMouse;
14
12
  private store;
@@ -54,7 +52,7 @@ export declare class Graph {
54
52
  private isForceCenterUpdateNeeded;
55
53
  private isPointImageSizesUpdateNeeded;
56
54
  private _isDestroyed;
57
- constructor(div: HTMLDivElement, config?: GraphConfigInterface, devicePromise?: Promise<Device>);
55
+ constructor(div: HTMLDivElement, config?: GraphConfigInterface);
58
56
  /**
59
57
  * Returns the current simulation progress
60
58
  */
@@ -513,31 +511,10 @@ export declare class Graph {
513
511
  */
514
512
  pair(pointPositions: number[]): [number, number][];
515
513
  /**
516
- * Ensures device is initialized before executing a method.
517
- * If device is not ready, queues the method to run after initialization.
518
- * @param callback - Function to execute once device is ready
519
- * @returns true if device was not ready and operation was queued, false if device is ready
520
- */
521
- private ensureDevice;
522
- /**
523
- * Validates that a device has the required HTMLCanvasElement canvas context.
524
- * Cosmos requires an HTMLCanvasElement canvas context and does not support
525
- * OffscreenCanvas or compute-only devices.
526
- * @param device - The device to validate
527
- * @returns The validated canvas context (guaranteed to be non-null and HTMLCanvasElement type)
528
- * @throws Error if the device does not meet Cosmos requirements
529
- */
530
- private validateDevice;
531
- /**
532
- * Internal device creation method
533
- * Graph class decides what device to create with sensible defaults
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.
534
517
  */
535
- private createDevice;
536
- /**
537
- * Updates and recreates the graph visualization based on pending changes.
538
- *
539
- * @param simulationAlpha - Optional alpha value to set. If not provided, keeps current alpha.
540
- */
541
518
  private update;
542
519
  /**
543
520
  * Runs one step of the simulation (forces, position updates, alpha decay).