@cosmos.gl/graph 2.3.1-beta.1 → 2.4.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.
Files changed (36) hide show
  1. package/.eslintrc +61 -0
  2. package/CHARTER.md +69 -0
  3. package/GOVERNANCE.md +21 -0
  4. package/dist/index.d.ts +46 -15
  5. package/dist/index.js +2986 -2701
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +180 -62
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/modules/GraphData/index.d.ts +18 -2
  10. package/dist/modules/Points/atlas-utils.d.ts +24 -0
  11. package/dist/modules/Points/index.d.ts +21 -2
  12. package/dist/modules/Store/index.d.ts +6 -1
  13. package/dist/stories/create-story.d.ts +5 -1
  14. package/dist/stories/shapes/image-example/index.d.ts +5 -0
  15. package/dist/stories/shapes.stories.d.ts +1 -0
  16. package/package.json +4 -4
  17. package/src/config.ts +1 -0
  18. package/src/declaration.d.ts +5 -0
  19. package/src/index.ts +119 -67
  20. package/src/modules/GraphData/index.ts +68 -6
  21. package/src/modules/Points/atlas-utils.ts +137 -0
  22. package/src/modules/Points/draw-highlighted.vert +3 -3
  23. package/src/modules/Points/draw-points.frag +106 -14
  24. package/src/modules/Points/draw-points.vert +51 -25
  25. package/src/modules/Points/find-points-on-area-selection.frag +6 -5
  26. package/src/modules/Points/index.ts +121 -13
  27. package/src/modules/Store/index.ts +11 -3
  28. package/src/stories/3. api-reference.mdx +48 -1
  29. package/src/stories/create-story.ts +32 -5
  30. package/src/stories/shapes/image-example/icons/box.png +0 -0
  31. package/src/stories/shapes/image-example/icons/lego.png +0 -0
  32. package/src/stories/shapes/image-example/icons/s.png +0 -0
  33. package/src/stories/shapes/image-example/icons/swift.png +0 -0
  34. package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
  35. package/src/stories/shapes/image-example/index.ts +239 -0
  36. package/src/stories/shapes.stories.ts +12 -0
package/.eslintrc CHANGED
@@ -13,6 +13,9 @@
13
13
  "unicorn"
14
14
  ],
15
15
  "parser": "@typescript-eslint/parser",
16
+ "parserOptions": {
17
+ "project": "./tsconfig.json"
18
+ },
16
19
  "rules": {
17
20
  "object-curly-spacing": ["error", "always"],
18
21
  "prefer-template": "error",
@@ -67,6 +70,64 @@
67
70
  "@typescript-eslint/member-ordering": "error",
68
71
  "@typescript-eslint/explicit-member-accessibility": "error",
69
72
  "@typescript-eslint/explicit-function-return-type": "error",
73
+ "@typescript-eslint/naming-convention": [
74
+ "error",
75
+ {
76
+ "selector": "default",
77
+ "format": ["camelCase"],
78
+ "leadingUnderscore": "allow",
79
+ "trailingUnderscore": "allow"
80
+ },
81
+ {
82
+ "selector": "import",
83
+ "format": ["camelCase", "PascalCase"]
84
+ },
85
+ {
86
+ "selector": "classProperty",
87
+ "format": ["camelCase", "UPPER_CASE"],
88
+ "leadingUnderscore": "allow",
89
+ "trailingUnderscore": "allow"
90
+ },
91
+ {
92
+ "selector": "classProperty",
93
+ "types": ["boolean"],
94
+ "format": ["PascalCase"],
95
+ "prefix": ["is", "should", "has", "can", "did", "will", "are"],
96
+ "leadingUnderscore": "allow",
97
+ "trailingUnderscore": "allow"
98
+ },
99
+ {
100
+ "selector": "function",
101
+ "format": ["camelCase", "PascalCase"],
102
+ "modifiers": ["exported"],
103
+ "leadingUnderscore": "allow",
104
+ "trailingUnderscore": "allow"
105
+ },
106
+ {
107
+ "selector": "variable",
108
+ "format": ["camelCase", "UPPER_CASE"],
109
+ "leadingUnderscore": "allow",
110
+ "trailingUnderscore": "allow"
111
+ },
112
+ {
113
+ "selector": "variable",
114
+ "modifiers": ["exported"],
115
+ "format": ["camelCase", "UPPER_CASE", "PascalCase"]
116
+ },
117
+ {
118
+ "selector": "typeLike",
119
+ "format": ["PascalCase"]
120
+ },
121
+ {
122
+ "selector": "enumMember",
123
+ "format": ["PascalCase"]
124
+ },
125
+ {
126
+ "selector": "property",
127
+ "leadingUnderscore": "allowSingleOrDouble",
128
+ "format": ["camelCase", "snake_case", "UPPER_CASE"]
129
+ }
130
+ ],
70
131
  "max-len": ["warn", { "code": 160, "comments": 160 }],
71
132
  "unicorn/filename-case": "error",
72
133
  "unicorn/no-for-loop": "error",
package/CHARTER.md ADDED
@@ -0,0 +1,69 @@
1
+ # cosmos.gl Charter
2
+
3
+ ## **Section 0: Guiding Principles**
4
+
5
+ **Mission:** Provide the web development community with a high-performance framework for visualizing network graphs and scatter plots.
6
+
7
+ **Vision:** Deliver fast, robust, open-source data visualization tools that empower interactive, scalable analysis in the browser.
8
+
9
+ **Values:**
10
+
11
+ - **Performance First:** Prioritize speed and efficiency in every feature and implementation.
12
+ - **Accessibility:** Ensure the API is intuitive and the tooling easy to adopt, lowering barriers for developers.
13
+ - **Community:** Foster open collaboration, welcoming contributions and feedback.
14
+ - **Transparency:** Maintain clear documentation, benchmarks, and decision-making processes.
15
+
16
+ ## **Section 1: Scope**
17
+
18
+ cosmos.gl is a browser-native, GPU-accelerated force-directed graph layout and rendering engine designed to visualize and interact with massive, complex datasets at scale. By leveraging WebGL, it delivers fast simulations and real-time rendering of millions of nodes and edges directly in the browser. cosmos.gl bridges the gap between high-performance data visualization and interactive web-based research workflows, serving developers, researchers, and analysts. Its value lies in unlocking scalable, explainable graph exploration for AI, biotech, finance, and data science stakeholders.
19
+
20
+ ### **1.1: In-scope**
21
+
22
+ - GPU-accelerated graph algorithms
23
+ - WebGL- and WebGPU-based rendering of large-scale network graph and machine learning embeddings
24
+ - Browser-native integration with frontend tooling and workflows
25
+
26
+ ### **1.2: Out-of-Scope**
27
+
28
+ - Server-side computation, backend data processing and pipelines
29
+ - Native desktop or mobile applications (outside browser environment)
30
+ - Direct integration with domain-specific tools
31
+
32
+ ## **Section 2: Relationship with OpenJS Foundation CPC**
33
+
34
+ Technical leadership of the cosmos.gl project is delegated to the cosmos.gl Technical Steering Committee (TSC) by the OpenJS Cross Project Council (CPC). Amendments to this charter require approval from both the CPC, through its [decision-making process](https://github.com/openjs-foundation/cross-project-council/blob/master/CPC-CHARTER.md#section-9-decision-making), and the TSC.
35
+
36
+ ## **Section 3: Technical Steering Committee (TSC)**
37
+
38
+ TSC members may attend meetings, participate in discussions, and vote on all matters before the TSC.
39
+
40
+ TSC memberships are not time-limited. There is no maximum size of the TSC.
41
+
42
+ There is no specific set of requirements or qualifications for TSC membership beyond these rules. A TSC member can be removed from the TSC by voluntary resignation or by a standard TSC motion.
43
+
44
+ The TSC shall meet regularly using tools that enable participation by the community. The meeting shall be directed by the TSC chairperson. Responsibility for directing individual meetings may be delegated by the TSC chairperson to any other TSC member. Minutes or an appropriate recording shall be taken and made available to the community through accessible public postings.
45
+
46
+ TSC members are expected to regularly participate in TSC activities.
47
+
48
+ The TSC chairperson is elected by a simple majority vote of all TSC members. The chairperson serves until they resign or are replaced by a TSC vote. Any TSC member may call for a vote at any time, provided the proposal is made in writing and shared with the full TSC. Votes may be held in meetings or asynchronously using any communication tool commonly used by the TSC.
49
+
50
+ ## **Section 4: Roles & Responsibilities**
51
+ The roles and responsibilities of cosmos.gl's TSC are described in [GOVERNANCE.md](./GOVERNANCE.md).
52
+
53
+ ### **Section 4.1 Project Operations & Management**
54
+ The Project Operations & Management processes are defined in [GOVERNANCE.md](./GOVERNANCE.md).
55
+
56
+ ### **Section 4.2: Decision-making, Voting, and/or Elections**
57
+
58
+ Project decisions shall operate under a model of Lazy Consensus by default. The TSC shall define appropriate guidelines for implementing Lazy Consensus (e.g., notification periods, review windows) within the development process.
59
+
60
+ When consensus cannot be reached, the TSC shall decide via public voting.
61
+
62
+ Each vote presents the available options in a format that supports clear expression of member preferences—this may include polls, emoji reactions, checklists, or comparable methods. TSC members may vote for one or more options or abstain. Unless otherwise specified, the winning option is the one that receives the greatest support among participating members.
63
+
64
+ For decisions involving three or more options, the TSC may optionally conduct pairwise comparisons between all candidates. In such cases, the winner is the candidate who secures a simple majority against every other candidate in head-to-head matchups (Condorcet winner). All votes are public, and voting activity may be adjusted until the close of the voting period.
65
+
66
+ ## **Section 5: Definitions**
67
+ ### **Agenda Item**
68
+
69
+ An agenda item is a specific topic, proposal, or issue scheduled for discussion or decision during a TSC meeting. Examples include proposed technical changes, governance matters, or any subject requiring TSC review or input. Agenda items are published in advance to allow TSC members and the community to prepare for discussion or decision-making.
package/GOVERNANCE.md ADDED
@@ -0,0 +1,21 @@
1
+ # cosmos.gl Governance Guidelines
2
+
3
+ The [TSC Charter](./CHARTER.md) governs the operations of the TSC. All changes to the Charter need approval by the OpenJS Foundation Cross-Project Council (CPC).
4
+
5
+ The TSC oversees all technical development in the cosmos.gl project, as long as it follows policies set by CPC, including:
6
+ - Setting release dates.
7
+ - Release quality standards.
8
+ - Technical direction.
9
+ - Project governance and process.
10
+ - GitHub repository hosting.
11
+ - Conduct guidelines.
12
+ - Maintaining the list of additional collaborators.
13
+ - Development process and any coding standards.
14
+ - Mediating technical conflicts between collaborators or foundation projects.
15
+
16
+ The TSC will define cosmos.gl project’s release vehicles.
17
+
18
+ ### **Project Operations & Management**
19
+ The TSC will establish and maintain a development process for the cosmos.gl project. The development process will establish guidelines for how the developers and community will operate. It will, for example, establish appropriate timelines for TSC review (e.g. agenda items must be published at least a certain number of hours in advance of a TSC meeting).
20
+
21
+ The TSC and entire technical community will follow any processes as may be specified by the OpenJS Foundation Board relating to the intake and license compliance review of contributions, including the OpenJS Foundation IP Policy.
package/dist/index.d.ts CHANGED
@@ -37,18 +37,20 @@ export declare class Graph {
37
37
  * */
38
38
  private _isFirstRenderAfterInit;
39
39
  private _fitViewOnInitTimeoutID;
40
- private _needsPointPositionsUpdate;
41
- private _needsPointColorUpdate;
42
- private _needsPointSizeUpdate;
43
- private _needsPointShapeUpdate;
44
- private _needsLinksUpdate;
45
- private _needsLinkColorUpdate;
46
- private _needsLinkWidthUpdate;
47
- private _needsLinkArrowUpdate;
48
- private _needsPointClusterUpdate;
49
- private _needsForceManyBodyUpdate;
50
- private _needsForceLinkUpdate;
51
- private _needsForceCenterUpdate;
40
+ private isPointPositionsUpdateNeeded;
41
+ private isPointColorUpdateNeeded;
42
+ private isPointSizeUpdateNeeded;
43
+ private isPointShapeUpdateNeeded;
44
+ private isPointImageIndicesUpdateNeeded;
45
+ private isLinksUpdateNeeded;
46
+ private isLinkColorUpdateNeeded;
47
+ private isLinkWidthUpdateNeeded;
48
+ private isLinkArrowUpdateNeeded;
49
+ private isPointClusterUpdateNeeded;
50
+ private isForceManyBodyUpdateNeeded;
51
+ private isForceLinkUpdateNeeded;
52
+ private isForceCenterUpdateNeeded;
53
+ private isPointImageSizesUpdateNeeded;
52
54
  private _isDestroyed;
53
55
  constructor(div: HTMLDivElement, config?: GraphConfigInterface);
54
56
  /**
@@ -108,10 +110,37 @@ export declare class Graph {
108
110
  *
109
111
  * @param {Float32Array} pointShapes - A Float32Array representing the shapes of points in the format [shape1, shape2, ..., shapen],
110
112
  * where `n` is the index of the point and each shape value corresponds to a PointShape enum:
111
- * 0 = Circle, 1 = Square, 2 = Triangle, 3 = Diamond, 4 = Pentagon, 5 = Hexagon, 6 = Star, 7 = Cross.
113
+ * 0 = Circle, 1 = Square, 2 = Triangle, 3 = Diamond, 4 = Pentagon, 5 = Hexagon, 6 = Star, 7 = Cross, 8 = None.
112
114
  * Example: `new Float32Array([0, 1, 2])` sets the first point to Circle, the second point to Square, and the third point to Triangle.
115
+ * Images are rendered above shapes.
113
116
  */
114
117
  setPointShapes(pointShapes: Float32Array): void;
118
+ /**
119
+ * Sets the images for the graph points using ImageData objects.
120
+ * Images are rendered above shapes.
121
+ * To use images, provide image indices via setPointImageIndices().
122
+ *
123
+ * @param {ImageData[]} imageDataArray - Array of ImageData objects to use as point images.
124
+ * Example: `setImageData([imageData1, imageData2, imageData3])`
125
+ */
126
+ setImageData(imageDataArray: ImageData[]): void;
127
+ /**
128
+ * Sets which image each point should use from the images array.
129
+ * Images are rendered above shapes.
130
+ *
131
+ * @param {Float32Array} imageIndices - A Float32Array representing which image each point uses in the format [index1, index2, ..., indexn],
132
+ * where `n` is the index of the point and each value is an index into the images array provided to `setImageData`.
133
+ * Example: `new Float32Array([0, 1, 0])` sets the first point to use image 0, second point to use image 1, third point to use image 0.
134
+ */
135
+ setPointImageIndices(imageIndices: Float32Array): void;
136
+ /**
137
+ * Sets the sizes for the point images.
138
+ *
139
+ * @param {Float32Array} imageSizes - A Float32Array representing the sizes of point images in the format [size1, size2, ..., sizen],
140
+ * where `n` is the index of the point.
141
+ * Example: `new Float32Array([10, 20, 30])` sets the first image to size 10, the second image to size 20, and the third image to size 30.
142
+ */
143
+ setPointImageSizes(imageSizes: Float32Array): void;
115
144
  /**
116
145
  * Gets the current sizes of the graph points.
117
146
  *
@@ -367,9 +396,11 @@ export declare class Graph {
367
396
  trackPointPositionsByIndices(indices: number[]): void;
368
397
  /**
369
398
  * Get current X and Y coordinates of the tracked points.
370
- * @returns A Map object where keys are the indices of the points and values are their corresponding X and Y coordinates in the [number, number] format.
399
+ * Do not mutate the returned map - it may affect future calls.
400
+ * @returns A ReadonlyMap where keys are point indices and values are their corresponding X and Y coordinates in the [number, number] format.
401
+ * @see trackPointPositionsByIndices To set which points should be tracked
371
402
  */
372
- getTrackedPointPositionsMap(): Map<number, [number, number]>;
403
+ getTrackedPointPositionsMap(): ReadonlyMap<number, [number, number]>;
373
404
  /**
374
405
  * Get current X and Y coordinates of the tracked points as an array.
375
406
  * @returns Array of point positions in the format [x1, y1, x2, y2, ..., xn, yn] for tracked points only.