@cosmos.gl/graph 2.6.2-rc.0 → 2.7.0-beta.0
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/.eslintrc +147 -0
- package/.github/SECURITY.md +13 -0
- package/.github/dco.yml +4 -0
- package/.github/workflows/github_pages.yml +54 -0
- package/.storybook/main.ts +26 -0
- package/.storybook/manager-head.html +1 -0
- package/.storybook/manager.ts +14 -0
- package/.storybook/preview.ts +29 -0
- package/.storybook/style.css +3 -0
- package/CHARTER.md +69 -0
- package/CODE_OF_CONDUCT.md +178 -0
- package/CONTRIBUTING.md +22 -0
- package/GOVERNANCE.md +21 -0
- package/cosmos-2-0-migration-notes.md +98 -0
- package/cosmos_awesome.md +96 -0
- package/dist/config.d.ts +5 -9
- package/dist/graph/utils/error-message.d.ts +1 -1
- package/dist/helper.d.ts +39 -2
- package/dist/index-FUIgayhu.js +19827 -0
- package/dist/index-FUIgayhu.js.map +1 -0
- package/dist/index.d.ts +17 -64
- package/dist/index.js +14 -14654
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1062 -475
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +11 -3
- package/dist/modules/ForceCenter/index.d.ts +10 -3
- package/dist/modules/ForceGravity/index.d.ts +5 -1
- package/dist/modules/ForceLink/index.d.ts +8 -5
- package/dist/modules/ForceManyBody/index.d.ts +16 -7
- package/dist/modules/ForceMouse/index.d.ts +5 -1
- package/dist/modules/GraphData/index.d.ts +0 -1
- package/dist/modules/Lines/index.d.ts +11 -5
- package/dist/modules/Points/index.d.ts +31 -13
- package/dist/modules/Store/index.d.ts +93 -0
- package/dist/modules/core-module.d.ts +3 -3
- package/dist/stories/beginners/basic-set-up/data-gen.d.ts +4 -0
- package/dist/stories/beginners/basic-set-up/index.d.ts +6 -0
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +19 -0
- package/dist/stories/beginners/link-hovering/index.d.ts +6 -0
- package/dist/stories/beginners/point-labels/data.d.ts +13 -0
- package/dist/stories/beginners/point-labels/index.d.ts +10 -0
- package/dist/stories/beginners/point-labels/labels.d.ts +8 -0
- package/dist/stories/beginners/quick-start.d.ts +6 -0
- package/dist/stories/beginners/remove-points/config.d.ts +2 -0
- package/dist/stories/beginners/remove-points/data-gen.d.ts +4 -0
- package/dist/stories/beginners/remove-points/index.d.ts +6 -0
- package/dist/stories/beginners.stories.d.ts +10 -0
- package/dist/stories/clusters/polygon-selection/index.d.ts +6 -0
- package/dist/stories/clusters/polygon-selection/polygon.d.ts +20 -0
- package/dist/stories/clusters/radial.d.ts +6 -0
- package/dist/stories/clusters/with-labels.d.ts +6 -0
- package/dist/stories/clusters/worm.d.ts +6 -0
- package/dist/stories/clusters.stories.d.ts +9 -0
- package/dist/stories/create-cluster-labels.d.ts +4 -0
- package/dist/stories/create-cosmos.d.ts +17 -0
- package/dist/stories/create-story.d.ts +16 -0
- package/dist/stories/experiments/full-mesh.d.ts +6 -0
- package/dist/stories/experiments/mesh-with-holes.d.ts +6 -0
- package/dist/stories/experiments.stories.d.ts +7 -0
- package/dist/stories/generate-mesh-data.d.ts +12 -0
- package/dist/stories/geospatial/moscow-metro-stations/index.d.ts +16 -0
- package/dist/stories/geospatial/moscow-metro-stations/moscow-metro-coords.d.ts +1 -0
- package/dist/stories/geospatial/moscow-metro-stations/point-colors.d.ts +1 -0
- package/dist/stories/geospatial.stories.d.ts +6 -0
- package/dist/stories/shapes/all-shapes/index.d.ts +6 -0
- package/dist/stories/shapes/image-example/index.d.ts +6 -0
- package/dist/stories/shapes.stories.d.ts +7 -0
- package/dist/stories/test-luma-migration.d.ts +6 -0
- package/dist/stories/test.stories.d.ts +6 -0
- package/dist/webgl-device-B9ewDj5L.js +3923 -0
- package/dist/webgl-device-B9ewDj5L.js.map +1 -0
- package/logo.svg +3 -0
- package/package.json +5 -7
- package/rollup.config.js +70 -0
- package/src/config.ts +728 -0
- package/src/declaration.d.ts +12 -0
- package/src/graph/utils/error-message.ts +23 -0
- package/src/helper.ts +113 -0
- package/src/index.ts +1769 -0
- package/src/modules/Clusters/calculate-centermass.frag +12 -0
- package/src/modules/Clusters/calculate-centermass.vert +38 -0
- package/src/modules/Clusters/force-cluster.frag +55 -0
- package/src/modules/Clusters/index.ts +578 -0
- package/src/modules/Drag/index.ts +33 -0
- package/src/modules/FPSMonitor/css.ts +53 -0
- package/src/modules/FPSMonitor/index.ts +28 -0
- package/src/modules/ForceCenter/calculate-centermass.frag +9 -0
- package/src/modules/ForceCenter/calculate-centermass.vert +26 -0
- package/src/modules/ForceCenter/force-center.frag +37 -0
- package/src/modules/ForceCenter/index.ts +284 -0
- package/src/modules/ForceGravity/force-gravity.frag +40 -0
- package/src/modules/ForceGravity/index.ts +107 -0
- package/src/modules/ForceLink/force-spring.ts +89 -0
- package/src/modules/ForceLink/index.ts +293 -0
- package/src/modules/ForceManyBody/calculate-level.frag +9 -0
- package/src/modules/ForceManyBody/calculate-level.vert +37 -0
- package/src/modules/ForceManyBody/force-centermass.frag +61 -0
- package/src/modules/ForceManyBody/force-level.frag +138 -0
- package/src/modules/ForceManyBody/index.ts +525 -0
- package/src/modules/ForceManyBody/quadtree-frag-shader.ts +89 -0
- package/src/modules/ForceManyBodyQuadtree/calculate-level.frag +9 -0
- package/src/modules/ForceManyBodyQuadtree/calculate-level.vert +25 -0
- package/src/modules/ForceManyBodyQuadtree/index.ts +157 -0
- package/src/modules/ForceManyBodyQuadtree/quadtree-frag-shader.ts +93 -0
- package/src/modules/ForceMouse/force-mouse.frag +35 -0
- package/src/modules/ForceMouse/index.ts +102 -0
- package/src/modules/GraphData/index.ts +383 -0
- package/src/modules/Lines/draw-curve-line.frag +59 -0
- package/src/modules/Lines/draw-curve-line.vert +248 -0
- package/src/modules/Lines/geometry.ts +18 -0
- package/src/modules/Lines/hovered-line-index.frag +43 -0
- package/src/modules/Lines/hovered-line-index.vert +13 -0
- package/src/modules/Lines/index.ts +661 -0
- package/src/modules/Points/atlas-utils.ts +137 -0
- package/src/modules/Points/drag-point.frag +34 -0
- package/src/modules/Points/draw-highlighted.frag +44 -0
- package/src/modules/Points/draw-highlighted.vert +145 -0
- package/src/modules/Points/draw-points.frag +259 -0
- package/src/modules/Points/draw-points.vert +203 -0
- package/src/modules/Points/fill-sampled-points.frag +12 -0
- package/src/modules/Points/fill-sampled-points.vert +51 -0
- package/src/modules/Points/find-hovered-point.frag +15 -0
- package/src/modules/Points/find-hovered-point.vert +90 -0
- package/src/modules/Points/find-points-on-area-selection.frag +88 -0
- package/src/modules/Points/find-points-on-polygon-selection.frag +89 -0
- package/src/modules/Points/index.ts +2292 -0
- package/src/modules/Points/track-positions.frag +30 -0
- package/src/modules/Points/update-position.frag +39 -0
- package/src/modules/Shared/buffer.ts +39 -0
- package/src/modules/Shared/clear.frag +10 -0
- package/src/modules/Shared/quad.vert +13 -0
- package/src/modules/Store/index.ts +283 -0
- package/src/modules/Zoom/index.ts +148 -0
- package/src/modules/core-module.ts +28 -0
- package/src/stories/1. welcome.mdx +75 -0
- package/src/stories/2. configuration.mdx +111 -0
- package/src/stories/3. api-reference.mdx +591 -0
- package/src/stories/beginners/basic-set-up/data-gen.ts +33 -0
- package/src/stories/beginners/basic-set-up/index.ts +167 -0
- package/src/stories/beginners/basic-set-up/style.css +35 -0
- package/src/stories/beginners/link-hovering/data-generator.ts +198 -0
- package/src/stories/beginners/link-hovering/index.ts +65 -0
- package/src/stories/beginners/link-hovering/style.css +73 -0
- package/src/stories/beginners/point-labels/data.ts +73 -0
- package/src/stories/beginners/point-labels/index.ts +69 -0
- package/src/stories/beginners/point-labels/labels.ts +46 -0
- package/src/stories/beginners/point-labels/style.css +16 -0
- package/src/stories/beginners/quick-start.ts +54 -0
- package/src/stories/beginners/remove-points/config.ts +25 -0
- package/src/stories/beginners/remove-points/data-gen.ts +30 -0
- package/src/stories/beginners/remove-points/index.ts +96 -0
- package/src/stories/beginners/remove-points/style.css +31 -0
- package/src/stories/beginners.stories.ts +130 -0
- package/src/stories/clusters/polygon-selection/index.ts +52 -0
- package/src/stories/clusters/polygon-selection/polygon.ts +143 -0
- package/src/stories/clusters/polygon-selection/style.css +8 -0
- package/src/stories/clusters/radial.ts +24 -0
- package/src/stories/clusters/with-labels.ts +54 -0
- package/src/stories/clusters/worm.ts +40 -0
- package/src/stories/clusters.stories.ts +77 -0
- package/src/stories/create-cluster-labels.ts +50 -0
- package/src/stories/create-cosmos.ts +72 -0
- package/src/stories/create-story.ts +51 -0
- package/src/stories/experiments/full-mesh.ts +13 -0
- package/src/stories/experiments/mesh-with-holes.ts +13 -0
- package/src/stories/experiments.stories.ts +43 -0
- package/src/stories/generate-mesh-data.ts +125 -0
- package/src/stories/geospatial/moscow-metro-stations/index.ts +66 -0
- package/src/stories/geospatial/moscow-metro-stations/moscow-metro-coords.ts +1 -0
- package/src/stories/geospatial/moscow-metro-stations/point-colors.ts +46 -0
- package/src/stories/geospatial/moscow-metro-stations/style.css +30 -0
- package/src/stories/geospatial.stories.ts +30 -0
- package/src/stories/shapes/all-shapes/index.ts +73 -0
- package/src/stories/shapes/image-example/icons/box.png +0 -0
- package/src/stories/shapes/image-example/icons/lego.png +0 -0
- package/src/stories/shapes/image-example/icons/s.png +0 -0
- package/src/stories/shapes/image-example/icons/swift.png +0 -0
- package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
- package/src/stories/shapes/image-example/index.ts +246 -0
- package/src/stories/shapes.stories.ts +37 -0
- package/src/stories/test-luma-migration.ts +195 -0
- package/src/stories/test.stories.ts +25 -0
- package/src/variables.ts +68 -0
- package/tsconfig.json +41 -0
- package/vite.config.ts +52 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export declare class Graph {
|
|
|
6
6
|
private canvas;
|
|
7
7
|
private attributionDivElement;
|
|
8
8
|
private canvasD3Selection;
|
|
9
|
-
private
|
|
9
|
+
private device;
|
|
10
|
+
private deviceInitPromise;
|
|
10
11
|
private requestAnimationFrameId;
|
|
11
12
|
private isRightClickMouse;
|
|
12
13
|
private store;
|
|
@@ -238,31 +239,11 @@ export declare class Graph {
|
|
|
238
239
|
*/
|
|
239
240
|
setPointClusterStrength(clusterStrength: Float32Array): void;
|
|
240
241
|
/**
|
|
241
|
-
*
|
|
242
|
+
* Renders the graph.
|
|
242
243
|
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* - Can still be dragged by the user if `enableDrag` is true
|
|
247
|
-
*
|
|
248
|
-
* @param {number[] | null} pinnedIndices - Array of point indices to pin. Set to `[]` or `null` to unpin all points.
|
|
249
|
-
* @example
|
|
250
|
-
* // Pin points 0 and 5
|
|
251
|
-
* graph.setPinnedPoints([0, 5])
|
|
252
|
-
*
|
|
253
|
-
* // Unpin all points
|
|
254
|
-
* graph.setPinnedPoints([])
|
|
255
|
-
* graph.setPinnedPoints(null)
|
|
256
|
-
*/
|
|
257
|
-
setPinnedPoints(pinnedIndices: number[] | null): void;
|
|
258
|
-
/**
|
|
259
|
-
* Renders the graph and starts rendering.
|
|
260
|
-
* Does NOT modify simulation state - use start(), stop(), pause(), unpause() to control simulation.
|
|
261
|
-
*
|
|
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.
|
|
244
|
+
* @param {number} [simulationAlpha] - Optional value between 0 and 1
|
|
245
|
+
* that controls the initial energy of the simulation.The higher the value,
|
|
246
|
+
* the more initial energy the simulation will get. Zero value stops the simulation.
|
|
266
247
|
*/
|
|
267
248
|
render(simulationAlpha?: number): void;
|
|
268
249
|
/**
|
|
@@ -459,19 +440,12 @@ export declare class Graph {
|
|
|
459
440
|
getScaleY(): ((y: number) => number) | undefined;
|
|
460
441
|
/**
|
|
461
442
|
* Start the simulation.
|
|
462
|
-
* This only controls the simulation state, not rendering.
|
|
463
443
|
* @param alpha Value from 0 to 1. The higher the value, the more initial energy the simulation will get.
|
|
464
444
|
*/
|
|
465
445
|
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;
|
|
471
446
|
/**
|
|
472
447
|
* Pause the simulation. When paused, the simulation stops running
|
|
473
|
-
*
|
|
474
|
-
* Can be resumed using the unpause method.
|
|
448
|
+
* and can be resumed using the unpause method.
|
|
475
449
|
*/
|
|
476
450
|
pause(): void;
|
|
477
451
|
/**
|
|
@@ -486,8 +460,7 @@ export declare class Graph {
|
|
|
486
460
|
*/
|
|
487
461
|
restart(): void;
|
|
488
462
|
/**
|
|
489
|
-
*
|
|
490
|
-
* Works even when the simulation is paused.
|
|
463
|
+
* Render only one frame of the simulation (stops the simulation if it was running).
|
|
491
464
|
*/
|
|
492
465
|
step(): void;
|
|
493
466
|
/**
|
|
@@ -511,41 +484,21 @@ export declare class Graph {
|
|
|
511
484
|
*/
|
|
512
485
|
pair(pointPositions: number[]): [number, number][];
|
|
513
486
|
/**
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* @param
|
|
487
|
+
* Ensures device is initialized before executing a method.
|
|
488
|
+
* If device is not ready, queues the method to run after initialization.
|
|
489
|
+
* @param callback - Function to execute once device is ready
|
|
490
|
+
* @returns true if device was not ready and operation was queued, false if device is ready
|
|
517
491
|
*/
|
|
518
|
-
private
|
|
492
|
+
private ensureDevice;
|
|
519
493
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
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.
|
|
494
|
+
* Internal device creation method
|
|
495
|
+
* Graph class decides what device to create with sensible defaults
|
|
528
496
|
*/
|
|
529
|
-
private
|
|
497
|
+
private createDevice;
|
|
498
|
+
private update;
|
|
530
499
|
private initPrograms;
|
|
531
|
-
/**
|
|
532
|
-
* The rendering loop - schedules itself to run continuously
|
|
533
|
-
*/
|
|
534
500
|
private frame;
|
|
535
|
-
/**
|
|
536
|
-
* Renders a single frame (the actual rendering logic).
|
|
537
|
-
* This does NOT schedule the next frame.
|
|
538
|
-
*/
|
|
539
|
-
private renderFrame;
|
|
540
501
|
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
|
-
*/
|
|
549
502
|
private end;
|
|
550
503
|
private onClick;
|
|
551
504
|
private updateMousePosition;
|