@cosmos.gl/graph 2.5.0 → 2.6.1
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 +8 -2
- package/dist/helper.d.ts +2 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +4950 -14357
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1678
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +2 -2
- package/dist/modules/Drag/index.d.ts +3 -3
- package/dist/modules/ForceCenter/index.d.ts +1 -1
- package/dist/modules/ForceGravity/index.d.ts +1 -1
- package/dist/modules/ForceLink/index.d.ts +1 -1
- package/dist/modules/ForceManyBody/index.d.ts +1 -1
- package/dist/modules/ForceManyBodyQuadtree/index.d.ts +1 -1
- package/dist/modules/ForceMouse/index.d.ts +1 -1
- package/dist/modules/GraphData/index.d.ts +2 -1
- package/dist/modules/Lines/index.d.ts +2 -2
- package/dist/modules/Points/index.d.ts +5 -2
- package/dist/modules/Shared/buffer.d.ts +1 -1
- package/dist/modules/Store/index.d.ts +1 -1
- package/dist/modules/Zoom/index.d.ts +3 -3
- package/dist/modules/core-module.d.ts +5 -5
- package/package.json +5 -1
- package/.eslintrc +0 -147
- package/.github/SECURITY.md +0 -13
- package/.github/dco.yml +0 -4
- package/.github/workflows/github_pages.yml +0 -54
- package/.storybook/main.ts +0 -26
- package/.storybook/manager-head.html +0 -1
- package/.storybook/manager.ts +0 -14
- package/.storybook/preview.ts +0 -29
- package/.storybook/style.css +0 -3
- package/CHARTER.md +0 -69
- package/CODE_OF_CONDUCT.md +0 -178
- package/CONTRIBUTING.md +0 -22
- package/GOVERNANCE.md +0 -21
- package/cosmos-2-0-migration-notes.md +0 -98
- package/cosmos_awesome.md +0 -96
- package/dist/stories/beginners/basic-set-up/data-gen.d.ts +0 -4
- package/dist/stories/beginners/basic-set-up/index.d.ts +0 -5
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +0 -19
- package/dist/stories/beginners/link-hovering/index.d.ts +0 -5
- package/dist/stories/beginners/point-labels/data.d.ts +0 -13
- package/dist/stories/beginners/point-labels/index.d.ts +0 -9
- package/dist/stories/beginners/point-labels/labels.d.ts +0 -8
- package/dist/stories/beginners/quick-start.d.ts +0 -5
- package/dist/stories/beginners/remove-points/config.d.ts +0 -2
- package/dist/stories/beginners/remove-points/data-gen.d.ts +0 -4
- package/dist/stories/beginners/remove-points/index.d.ts +0 -5
- package/dist/stories/beginners.stories.d.ts +0 -10
- package/dist/stories/clusters/polygon-selection/index.d.ts +0 -6
- package/dist/stories/clusters/polygon-selection/polygon.d.ts +0 -20
- package/dist/stories/clusters/radial.d.ts +0 -5
- package/dist/stories/clusters/with-labels.d.ts +0 -6
- package/dist/stories/clusters/worm.d.ts +0 -5
- package/dist/stories/clusters.stories.d.ts +0 -9
- package/dist/stories/create-cluster-labels.d.ts +0 -4
- package/dist/stories/create-cosmos.d.ts +0 -16
- package/dist/stories/create-story.d.ts +0 -16
- package/dist/stories/experiments/full-mesh.d.ts +0 -5
- package/dist/stories/experiments/mesh-with-holes.d.ts +0 -5
- package/dist/stories/experiments.stories.d.ts +0 -7
- package/dist/stories/generate-mesh-data.d.ts +0 -12
- package/dist/stories/geospatial/moscow-metro-stations/index.d.ts +0 -15
- package/dist/stories/geospatial/moscow-metro-stations/moscow-metro-coords.d.ts +0 -1
- package/dist/stories/geospatial/moscow-metro-stations/point-colors.d.ts +0 -1
- package/dist/stories/geospatial.stories.d.ts +0 -6
- package/dist/stories/shapes/all-shapes/index.d.ts +0 -5
- package/dist/stories/shapes/image-example/index.d.ts +0 -5
- package/dist/stories/shapes.stories.d.ts +0 -7
- package/logo.svg +0 -3
- package/rollup.config.js +0 -70
- package/src/config.ts +0 -726
- package/src/declaration.d.ts +0 -12
- package/src/graph/utils/error-message.ts +0 -23
- package/src/helper.ts +0 -74
- package/src/index.ts +0 -1608
- package/src/modules/Clusters/calculate-centermass.frag +0 -9
- package/src/modules/Clusters/calculate-centermass.vert +0 -26
- package/src/modules/Clusters/force-cluster.frag +0 -39
- package/src/modules/Clusters/index.ts +0 -200
- package/src/modules/Drag/index.ts +0 -33
- package/src/modules/FPSMonitor/css.ts +0 -53
- package/src/modules/FPSMonitor/index.ts +0 -28
- package/src/modules/ForceCenter/calculate-centermass.frag +0 -9
- package/src/modules/ForceCenter/calculate-centermass.vert +0 -18
- package/src/modules/ForceCenter/force-center.frag +0 -27
- package/src/modules/ForceCenter/index.ts +0 -104
- package/src/modules/ForceGravity/force-gravity.frag +0 -27
- package/src/modules/ForceGravity/index.ts +0 -33
- package/src/modules/ForceLink/force-spring.ts +0 -73
- package/src/modules/ForceLink/index.ts +0 -149
- package/src/modules/ForceManyBody/calculate-level.frag +0 -9
- package/src/modules/ForceManyBody/calculate-level.vert +0 -25
- package/src/modules/ForceManyBody/force-centermass.frag +0 -52
- package/src/modules/ForceManyBody/force-level.frag +0 -121
- package/src/modules/ForceManyBody/index.ts +0 -223
- package/src/modules/ForceManyBody/quadtree-frag-shader.ts +0 -90
- package/src/modules/ForceManyBodyQuadtree/calculate-level.frag +0 -9
- package/src/modules/ForceManyBodyQuadtree/calculate-level.vert +0 -25
- package/src/modules/ForceManyBodyQuadtree/index.ts +0 -157
- package/src/modules/ForceManyBodyQuadtree/quadtree-frag-shader.ts +0 -93
- package/src/modules/ForceMouse/force-mouse.frag +0 -24
- package/src/modules/ForceMouse/index.ts +0 -32
- package/src/modules/GraphData/index.ts +0 -383
- package/src/modules/Lines/draw-curve-line.frag +0 -46
- package/src/modules/Lines/draw-curve-line.vert +0 -194
- package/src/modules/Lines/geometry.ts +0 -18
- package/src/modules/Lines/hovered-line-index.frag +0 -27
- package/src/modules/Lines/hovered-line-index.vert +0 -8
- package/src/modules/Lines/index.ts +0 -273
- package/src/modules/Points/atlas-utils.ts +0 -137
- package/src/modules/Points/drag-point.frag +0 -20
- package/src/modules/Points/draw-highlighted.frag +0 -16
- package/src/modules/Points/draw-highlighted.vert +0 -86
- package/src/modules/Points/draw-points.frag +0 -243
- package/src/modules/Points/draw-points.vert +0 -127
- package/src/modules/Points/fill-sampled-points.frag +0 -9
- package/src/modules/Points/fill-sampled-points.vert +0 -29
- package/src/modules/Points/find-hovered-point.frag +0 -9
- package/src/modules/Points/find-hovered-point.vert +0 -57
- package/src/modules/Points/find-points-on-area-selection.frag +0 -48
- package/src/modules/Points/find-points-on-polygon-selection.frag +0 -65
- package/src/modules/Points/index.ts +0 -934
- package/src/modules/Points/track-positions.frag +0 -18
- package/src/modules/Points/update-position.frag +0 -25
- package/src/modules/Shared/buffer.ts +0 -37
- package/src/modules/Shared/clear.frag +0 -7
- package/src/modules/Shared/quad.vert +0 -12
- package/src/modules/Store/index.ts +0 -173
- package/src/modules/Zoom/index.ts +0 -148
- package/src/modules/core-module.ts +0 -28
- package/src/stories/1. welcome.mdx +0 -75
- package/src/stories/2. configuration.mdx +0 -112
- package/src/stories/3. api-reference.mdx +0 -591
- package/src/stories/beginners/basic-set-up/data-gen.ts +0 -33
- package/src/stories/beginners/basic-set-up/index.ts +0 -163
- package/src/stories/beginners/basic-set-up/style.css +0 -35
- package/src/stories/beginners/link-hovering/data-generator.ts +0 -198
- package/src/stories/beginners/link-hovering/index.ts +0 -61
- package/src/stories/beginners/link-hovering/style.css +0 -73
- package/src/stories/beginners/point-labels/data.ts +0 -73
- package/src/stories/beginners/point-labels/index.ts +0 -65
- package/src/stories/beginners/point-labels/labels.ts +0 -46
- package/src/stories/beginners/point-labels/style.css +0 -16
- package/src/stories/beginners/quick-start.ts +0 -50
- package/src/stories/beginners/remove-points/config.ts +0 -25
- package/src/stories/beginners/remove-points/data-gen.ts +0 -30
- package/src/stories/beginners/remove-points/index.ts +0 -92
- package/src/stories/beginners/remove-points/style.css +0 -31
- package/src/stories/beginners.stories.ts +0 -117
- package/src/stories/clusters/polygon-selection/index.ts +0 -51
- package/src/stories/clusters/polygon-selection/polygon.ts +0 -143
- package/src/stories/clusters/polygon-selection/style.css +0 -8
- package/src/stories/clusters/radial.ts +0 -24
- package/src/stories/clusters/with-labels.ts +0 -53
- package/src/stories/clusters/worm.ts +0 -40
- package/src/stories/clusters.stories.ts +0 -77
- package/src/stories/create-cluster-labels.ts +0 -50
- package/src/stories/create-cosmos.ts +0 -68
- package/src/stories/create-story.ts +0 -51
- package/src/stories/experiments/full-mesh.ts +0 -13
- package/src/stories/experiments/mesh-with-holes.ts +0 -13
- package/src/stories/experiments.stories.ts +0 -43
- package/src/stories/generate-mesh-data.ts +0 -125
- package/src/stories/geospatial/moscow-metro-stations/index.ts +0 -62
- package/src/stories/geospatial/moscow-metro-stations/moscow-metro-coords.ts +0 -1
- package/src/stories/geospatial/moscow-metro-stations/point-colors.ts +0 -46
- package/src/stories/geospatial/moscow-metro-stations/style.css +0 -30
- package/src/stories/geospatial.stories.ts +0 -30
- package/src/stories/shapes/all-shapes/index.ts +0 -69
- 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 +0 -238
- package/src/stories/shapes.stories.ts +0 -37
- package/src/variables.ts +0 -68
- package/tsconfig.json +0 -41
- package/vite.config.ts +0 -54
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
font-family: "Nunito Sans", -apple-system, ".SFNSText-Regular", "San Francisco", BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
3
|
-
margin: 0px;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.app {
|
|
7
|
-
position: absolute;
|
|
8
|
-
width: 100%;
|
|
9
|
-
height: 100%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.graph {
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 100vh;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.actions {
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: 10px;
|
|
20
|
-
left: 10px;
|
|
21
|
-
color: #ccc;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.action {
|
|
25
|
-
margin-left: 2px;
|
|
26
|
-
font-size: 10pt;
|
|
27
|
-
text-decoration: underline;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
user-select: none;
|
|
30
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/html'
|
|
2
|
-
|
|
3
|
-
import { createStory, Story } from '@/graph/stories/create-story'
|
|
4
|
-
import { CosmosStoryProps } from './create-cosmos'
|
|
5
|
-
import { moscowMetroStations } from './geospatial/moscow-metro-stations'
|
|
6
|
-
|
|
7
|
-
import moscowMetroStationsStoryRaw from './geospatial/moscow-metro-stations/index?raw'
|
|
8
|
-
import dataRaw from './geospatial/moscow-metro-stations/moscow-metro-coords?raw'
|
|
9
|
-
import pointColorsRaw from './geospatial/moscow-metro-stations/point-colors?raw'
|
|
10
|
-
import styleRaw from './geospatial/moscow-metro-stations/style.css?raw'
|
|
11
|
-
|
|
12
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
13
|
-
const meta: Meta<CosmosStoryProps> = {
|
|
14
|
-
title: 'Examples/Geospatial',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MoscowMetroStations: Story = {
|
|
18
|
-
...createStory(moscowMetroStations),
|
|
19
|
-
parameters: {
|
|
20
|
-
sourceCode: [
|
|
21
|
-
{ name: 'Story', code: moscowMetroStationsStoryRaw },
|
|
22
|
-
{ name: 'moscow-metro-coords', code: dataRaw },
|
|
23
|
-
{ name: 'point-colors', code: pointColorsRaw },
|
|
24
|
-
{ name: 'style.css', code: styleRaw },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// eslint-disable-next-line import/no-default-export
|
|
30
|
-
export default meta
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Graph, PointShape } from '@cosmos.gl/graph'
|
|
2
|
-
|
|
3
|
-
export const allShapes = (): {div: HTMLDivElement; graph: Graph } => {
|
|
4
|
-
// Create container div
|
|
5
|
-
const div = document.createElement('div')
|
|
6
|
-
div.style.height = '100vh'
|
|
7
|
-
div.style.width = '100%'
|
|
8
|
-
|
|
9
|
-
// Create 8 points, one for each shape
|
|
10
|
-
const spaceSize = 4096
|
|
11
|
-
const pointCount = 8
|
|
12
|
-
const spacing = spaceSize / pointCount
|
|
13
|
-
|
|
14
|
-
const pointPositions = new Float32Array(pointCount * 2)
|
|
15
|
-
const pointColors = new Float32Array(pointCount * 4)
|
|
16
|
-
const pointShapes = new Float32Array(pointCount)
|
|
17
|
-
|
|
18
|
-
// Define distinct colors for each shape
|
|
19
|
-
const shapeColors: [number, number, number][] = [
|
|
20
|
-
[1.0, 0.42, 0.38], // Coral for Circle
|
|
21
|
-
[0.13, 0.55, 0.45], // Forest Green for Square
|
|
22
|
-
[0.25, 0.32, 0.71], // Royal Blue for Triangle
|
|
23
|
-
[0.96, 0.76, 0.19], // Amber Gold for Diamond
|
|
24
|
-
[0.74, 0.24, 0.45], // Deep Rose for Pentagon
|
|
25
|
-
[0.18, 0.55, 0.56], // Teal for Hexagon
|
|
26
|
-
[0.85, 0.45, 0.28], // Terracotta for Star
|
|
27
|
-
[0.58, 0.44, 0.86], // Periwinkle for Cross
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
// Position points in a horizontal line
|
|
31
|
-
const startX = spacing / 2
|
|
32
|
-
const centerY = spaceSize / 2
|
|
33
|
-
for (let i = 0; i < pointCount; i++) {
|
|
34
|
-
// Position: horizontal line, centered
|
|
35
|
-
pointPositions[i * 2] = startX + i * spacing
|
|
36
|
-
pointPositions[i * 2 + 1] = centerY
|
|
37
|
-
|
|
38
|
-
// Color: distinct color for each shape
|
|
39
|
-
const color = shapeColors[i] || [1.0, 1.0, 1.0] // fallback to white if undefined
|
|
40
|
-
pointColors[i * 4] = color[0] // R
|
|
41
|
-
pointColors[i * 4 + 1] = color[1] // G
|
|
42
|
-
pointColors[i * 4 + 2] = color[2] // B
|
|
43
|
-
pointColors[i * 4 + 3] = 1.0 // A
|
|
44
|
-
|
|
45
|
-
// Shape: cycle through all available shapes
|
|
46
|
-
pointShapes[i] = i as PointShape
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Create graph with minimal configuration
|
|
50
|
-
const graph = new Graph(div, {
|
|
51
|
-
spaceSize,
|
|
52
|
-
pointSize: spacing / 2,
|
|
53
|
-
enableSimulation: false,
|
|
54
|
-
scalePointsOnZoom: true,
|
|
55
|
-
renderHoveredPointRing: true,
|
|
56
|
-
hoveredPointRingColor: '#ffffff',
|
|
57
|
-
rescalePositions: false,
|
|
58
|
-
enableDrag: true,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
// Set data
|
|
62
|
-
graph.setPointPositions(pointPositions)
|
|
63
|
-
graph.setPointColors(pointColors)
|
|
64
|
-
graph.setPointShapes(pointShapes)
|
|
65
|
-
|
|
66
|
-
graph.render()
|
|
67
|
-
|
|
68
|
-
return { div, graph }
|
|
69
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { Graph, PointShape } from '@cosmos.gl/graph'
|
|
2
|
-
|
|
3
|
-
// Import all PNG icons
|
|
4
|
-
import boxUrl from './icons/box.png'
|
|
5
|
-
import toolboxUrl from './icons/toolbox.png'
|
|
6
|
-
import swiftUrl from './icons/swift.png'
|
|
7
|
-
import legoUrl from './icons/lego.png'
|
|
8
|
-
import sUrl from './icons/s.png'
|
|
9
|
-
|
|
10
|
-
// Helper function to convert PNG URL to ImageData
|
|
11
|
-
const pngUrlToImageData = (pngUrl: string): Promise<ImageData> => {
|
|
12
|
-
return new Promise<ImageData>((resolve, reject) => {
|
|
13
|
-
const img = new Image()
|
|
14
|
-
|
|
15
|
-
img.onload = (): void => {
|
|
16
|
-
const canvas = document.createElement('canvas')
|
|
17
|
-
const ctx = canvas.getContext('2d')
|
|
18
|
-
if (!ctx) {
|
|
19
|
-
reject(new Error('Could not get 2D context'))
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
canvas.width = img.width
|
|
24
|
-
canvas.height = img.height
|
|
25
|
-
ctx.drawImage(img, 0, 0)
|
|
26
|
-
|
|
27
|
-
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height)
|
|
28
|
-
resolve(imageData)
|
|
29
|
-
}
|
|
30
|
-
img.onerror = (): void => reject(new Error(`Failed to load image: ${pngUrl}`))
|
|
31
|
-
img.src = pngUrl
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const loadPngImages = (pngUrls: string[]): Promise<ImageData[]> => {
|
|
36
|
-
return Promise.all(pngUrls.map(pngUrlToImageData))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Define node types for Xcode dependency graph
|
|
40
|
-
enum NodeType {
|
|
41
|
-
App = 0, // Main app target (swift icon)
|
|
42
|
-
Framework = 1, // Framework (box icon)
|
|
43
|
-
Library = 2, // Static library (toolbox icon)
|
|
44
|
-
Bundle = 3, // Bundle (lego icon)
|
|
45
|
-
Target = 4 // Build target (s icon)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface DependencyNode {
|
|
49
|
-
id: number;
|
|
50
|
-
name: string;
|
|
51
|
-
type: NodeType;
|
|
52
|
-
x: number;
|
|
53
|
-
y: number;
|
|
54
|
-
dependencies: number[];
|
|
55
|
-
size: number;
|
|
56
|
-
color: [number, number, number, number];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const imageExample = async (): Promise<{div: HTMLDivElement; graph: Graph }> => {
|
|
60
|
-
// Create container div
|
|
61
|
-
const div = document.createElement('div')
|
|
62
|
-
div.style.height = '100vh'
|
|
63
|
-
div.style.width = '100%'
|
|
64
|
-
div.style.display = 'flex'
|
|
65
|
-
div.style.flexDirection = 'column'
|
|
66
|
-
|
|
67
|
-
// Create main graph container
|
|
68
|
-
const graphContainer = document.createElement('div')
|
|
69
|
-
graphContainer.style.height = '100vh'
|
|
70
|
-
graphContainer.style.width = '100%'
|
|
71
|
-
graphContainer.style.position = 'absolute'
|
|
72
|
-
graphContainer.style.overflow = 'hidden'
|
|
73
|
-
div.appendChild(graphContainer)
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const spaceSize = 4096
|
|
77
|
-
|
|
78
|
-
const nodes: DependencyNode[] = [
|
|
79
|
-
// Main app target (center)
|
|
80
|
-
{ id: 0, name: 'MyApp', type: NodeType.App, x: 2048, y: 2048, dependencies: [1, 2, 3, 14], size: 60, color: [0.2, 0.6, 1.0, 1.0] },
|
|
81
|
-
|
|
82
|
-
// Frameworks (first ring around center)
|
|
83
|
-
{ id: 1, name: 'CoreData', type: NodeType.Framework, x: 1024, y: 2048, dependencies: [4, 5], size: 50, color: [0.8, 0.4, 0.2, 1.0] },
|
|
84
|
-
{ id: 2, name: 'UIKit', type: NodeType.Framework, x: 2048, y: 1024, dependencies: [6, 15], size: 50, color: [0.8, 0.4, 0.2, 1.0] },
|
|
85
|
-
{ id: 3, name: 'Network', type: NodeType.Framework, x: 3072, y: 2048, dependencies: [7, 8], size: 50, color: [0.8, 0.4, 0.2, 1.0] },
|
|
86
|
-
|
|
87
|
-
// Libraries (second ring)
|
|
88
|
-
{ id: 4, name: 'SQLite', type: NodeType.Library, x: 512, y: 2048, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
89
|
-
{ id: 5, name: 'Foundation', type: NodeType.Library, x: 1024, y: 1024, dependencies: [16], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
90
|
-
{ id: 6, name: 'CoreGraphics', type: NodeType.Library, x: 2048, y: 512, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
91
|
-
{ id: 7, name: 'Security', type: NodeType.Library, x: 3072, y: 1024, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
92
|
-
{ id: 8, name: 'CFNetwork', type: NodeType.Library, x: 3584, y: 2048, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
93
|
-
|
|
94
|
-
// Additional frameworks (first ring)
|
|
95
|
-
{ id: 9, name: 'Analytics', type: NodeType.Framework, x: 2048, y: 3072, dependencies: [10, 17], size: 50, color: [0.8, 0.4, 0.2, 1.0] },
|
|
96
|
-
{ id: 10, name: 'Firebase', type: NodeType.Library, x: 2048, y: 3840, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
97
|
-
|
|
98
|
-
// Test targets (outer ring)
|
|
99
|
-
{ id: 11, name: 'Tests', type: NodeType.Target, x: 512, y: 1024, dependencies: [0], size: 50, color: [0.4, 0.6, 1.0, 1.0] },
|
|
100
|
-
{ id: 12, name: 'UITests', type: NodeType.Target, x: 3584, y: 1024, dependencies: [0, 2], size: 45, color: [0.4, 0.6, 1.0, 1.0] },
|
|
101
|
-
{ id: 13, name: 'Widget', type: NodeType.Target, x: 3584, y: 3072, dependencies: [1, 2], size: 45, color: [0.4, 0.6, 1.0, 1.0] },
|
|
102
|
-
|
|
103
|
-
// Additional components
|
|
104
|
-
{ id: 14, name: 'Localization', type: NodeType.Framework, x: 1536, y: 3072, dependencies: [18], size: 50, color: [0.8, 0.4, 0.2, 1.0] },
|
|
105
|
-
{ id: 15, name: 'CoreAnimation', type: NodeType.Library, x: 2560, y: 512, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
106
|
-
{ id: 16, name: 'CoreFoundation', type: NodeType.Library, x: 1024, y: 512, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
107
|
-
{ id: 17, name: 'Crashlytics', type: NodeType.Library, x: 1536, y: 3584, dependencies: [], size: 45, color: [0.6, 0.8, 0.4, 1.0] },
|
|
108
|
-
{ id: 18, name: 'LocalizationBundle', type: NodeType.Bundle, x: 1792, y: 3584, dependencies: [], size: 45, color: [1.0, 0.4, 1.0, 1.0] },
|
|
109
|
-
|
|
110
|
-
// More test targets
|
|
111
|
-
{ id: 19, name: 'UnitTests', type: NodeType.Target, x: 512, y: 3072, dependencies: [0, 1], size: 45, color: [0.4, 0.6, 1.0, 1.0] },
|
|
112
|
-
{ id: 20, name: 'IntegrationTests', type: NodeType.Target, x: 512, y: 3584, dependencies: [0, 3], size: 45, color: [0.4, 0.6, 1.0, 1.0] },
|
|
113
|
-
|
|
114
|
-
// Bundle resources
|
|
115
|
-
{ id: 21, name: 'Resources', type: NodeType.Bundle, x: 2304, y: 3072, dependencies: [0], size: 50, color: [1.0, 0.4, 1.0, 1.0] },
|
|
116
|
-
{ id: 22, name: 'Assets', type: NodeType.Bundle, x: 2560, y: 3584, dependencies: [0, 21], size: 50, color: [1.0, 0.4, 1.0, 1.0] },
|
|
117
|
-
]
|
|
118
|
-
|
|
119
|
-
const pointCount = nodes.length
|
|
120
|
-
const pointPositions = new Float32Array(pointCount * 2)
|
|
121
|
-
const pointColors = new Float32Array(pointCount * 4)
|
|
122
|
-
const pointShapes = new Float32Array(pointCount)
|
|
123
|
-
const pointSizes = new Float32Array(pointCount)
|
|
124
|
-
const imageIndices = new Float32Array(pointCount)
|
|
125
|
-
|
|
126
|
-
// Create links array for dependencies
|
|
127
|
-
const links: number[] = []
|
|
128
|
-
const linkArrows: boolean[] = []
|
|
129
|
-
const linkColors: number[] = []
|
|
130
|
-
|
|
131
|
-
// Set up nodes based on the dependency structure
|
|
132
|
-
for (const node of nodes) {
|
|
133
|
-
const i = node.id
|
|
134
|
-
|
|
135
|
-
// Set positions
|
|
136
|
-
pointPositions[i * 2] = node.x
|
|
137
|
-
pointPositions[i * 2 + 1] = node.y
|
|
138
|
-
|
|
139
|
-
// Set node properties - use None shape for all images except targets (s icon)
|
|
140
|
-
pointShapes[i] = node.type === NodeType.Target ? PointShape.Hexagon : PointShape.None
|
|
141
|
-
pointSizes[i] = node.size
|
|
142
|
-
imageIndices[i] = node.type
|
|
143
|
-
|
|
144
|
-
// Set colors
|
|
145
|
-
pointColors[i * 4] = node.color[0]
|
|
146
|
-
pointColors[i * 4 + 1] = node.color[1]
|
|
147
|
-
pointColors[i * 4 + 2] = node.color[2]
|
|
148
|
-
pointColors[i * 4 + 3] = node.color[3]
|
|
149
|
-
|
|
150
|
-
// Add dependency links
|
|
151
|
-
for (const depId of node.dependencies) {
|
|
152
|
-
links.push(i, depId)
|
|
153
|
-
linkArrows.push(true)
|
|
154
|
-
|
|
155
|
-
// Add colorful link colors based on source node type
|
|
156
|
-
const sourceType = node.type
|
|
157
|
-
let linkColor: [number, number, number, number]
|
|
158
|
-
|
|
159
|
-
switch (sourceType) {
|
|
160
|
-
case NodeType.App:
|
|
161
|
-
linkColor = [0.2, 0.8, 1.0, 0.8] // Bright blue
|
|
162
|
-
break
|
|
163
|
-
case NodeType.Framework:
|
|
164
|
-
linkColor = [1.0, 0.6, 0.2, 0.8] // Orange
|
|
165
|
-
break
|
|
166
|
-
case NodeType.Library:
|
|
167
|
-
linkColor = [0.4, 1.0, 0.4, 0.8] // Green
|
|
168
|
-
break
|
|
169
|
-
case NodeType.Bundle:
|
|
170
|
-
linkColor = [1.0, 0.4, 1.0, 0.8] // Magenta
|
|
171
|
-
break
|
|
172
|
-
case NodeType.Target:
|
|
173
|
-
linkColor = [0.8, 0.4, 1.0, 0.8] // Purple
|
|
174
|
-
break
|
|
175
|
-
default:
|
|
176
|
-
linkColor = [0.7, 0.7, 0.7, 0.8] // Gray
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Add RGBA values for this link
|
|
180
|
-
linkColors.push(linkColor[0], linkColor[1], linkColor[2], linkColor[3])
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Create graph with static positioning
|
|
185
|
-
const graph = new Graph(graphContainer, {
|
|
186
|
-
spaceSize,
|
|
187
|
-
enableSimulation: false,
|
|
188
|
-
enableDrag: false,
|
|
189
|
-
linkArrows: true,
|
|
190
|
-
curvedLinks: true,
|
|
191
|
-
pointSize: 50,
|
|
192
|
-
linkWidth: 3,
|
|
193
|
-
hoveredPointRingColor: 'white',
|
|
194
|
-
renderHoveredPointRing: true,
|
|
195
|
-
|
|
196
|
-
// Add click handler for point and background selection
|
|
197
|
-
onPointClick: (pointIndex: number): void => {
|
|
198
|
-
// Use built-in functionality to select the clicked point and its neighbors
|
|
199
|
-
graph.selectPointByIndex(pointIndex, true)
|
|
200
|
-
},
|
|
201
|
-
onBackgroundClick: (): void => {
|
|
202
|
-
// Clear selection when clicking on background
|
|
203
|
-
graph.unselectPoints()
|
|
204
|
-
},
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
const imageDataArray = await loadPngImages([swiftUrl, boxUrl, toolboxUrl, legoUrl, sUrl])
|
|
208
|
-
|
|
209
|
-
// Set images and their indices
|
|
210
|
-
graph.setImageData(imageDataArray)
|
|
211
|
-
graph.setPointImageIndices(imageIndices)
|
|
212
|
-
|
|
213
|
-
// Set all data
|
|
214
|
-
graph.setPointPositions(pointPositions)
|
|
215
|
-
graph.setPointColors(pointColors)
|
|
216
|
-
graph.setPointShapes(pointShapes)
|
|
217
|
-
graph.setPointSizes(pointSizes)
|
|
218
|
-
|
|
219
|
-
// Set links if we have any dependencies
|
|
220
|
-
if (links.length > 0) {
|
|
221
|
-
graph.setLinks(new Float32Array(links))
|
|
222
|
-
graph.setLinkArrows(linkArrows)
|
|
223
|
-
graph.setLinkColors(new Float32Array(linkColors))
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
graph.render()
|
|
227
|
-
|
|
228
|
-
return { div, graph }
|
|
229
|
-
} catch (error) {
|
|
230
|
-
console.error('Error creating Xcode dependency graph:', error)
|
|
231
|
-
div.innerHTML = `
|
|
232
|
-
<div style="display: flex; align-items: center; justify-content: center; height: 100%; color: #ff0000; font-size: 18px;">
|
|
233
|
-
Error loading Xcode dependency graph: ${error instanceof Error ? error.message : 'Unknown error'}
|
|
234
|
-
</div>
|
|
235
|
-
`
|
|
236
|
-
throw error
|
|
237
|
-
}
|
|
238
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Meta } from '@storybook/html'
|
|
2
|
-
|
|
3
|
-
import { createStory, Story } from '@/graph/stories/create-story'
|
|
4
|
-
import { CosmosStoryProps } from './create-cosmos'
|
|
5
|
-
import { allShapes } from './shapes/all-shapes'
|
|
6
|
-
import { imageExample } from './shapes/image-example'
|
|
7
|
-
|
|
8
|
-
import allShapesStoryRaw from './shapes/all-shapes/index?raw'
|
|
9
|
-
import imageExampleStoryRaw from './shapes/image-example/index?raw'
|
|
10
|
-
|
|
11
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
12
|
-
const meta: Meta<CosmosStoryProps> = {
|
|
13
|
-
title: 'Examples/Shapes',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const AllShapes: Story = {
|
|
17
|
-
...createStory(allShapes),
|
|
18
|
-
name: 'All Point Shapes',
|
|
19
|
-
parameters: {
|
|
20
|
-
sourceCode: [
|
|
21
|
-
{ name: 'Story', code: allShapesStoryRaw },
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const ImageExample: Story = {
|
|
27
|
-
...createStory(imageExample),
|
|
28
|
-
name: 'Image Points Example',
|
|
29
|
-
parameters: {
|
|
30
|
-
sourceCode: [
|
|
31
|
-
{ name: 'Story', code: imageExampleStoryRaw },
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line import/no-default-export
|
|
37
|
-
export default meta
|
package/src/variables.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export const defaultPointColor = '#b3b3b3'
|
|
2
|
-
export const defaultGreyoutPointOpacity = undefined
|
|
3
|
-
export const defaultGreyoutPointColor = undefined
|
|
4
|
-
export const defaultPointOpacity = 1.0
|
|
5
|
-
export const defaultPointSize = 4
|
|
6
|
-
export const defaultLinkColor = '#666666'
|
|
7
|
-
export const defaultGreyoutLinkOpacity = 0.1
|
|
8
|
-
export const defaultLinkOpacity = 1.0
|
|
9
|
-
export const defaultLinkWidth = 1
|
|
10
|
-
export const defaultBackgroundColor = '#222222'
|
|
11
|
-
|
|
12
|
-
export const defaultConfigValues = {
|
|
13
|
-
enableSimulation: true,
|
|
14
|
-
spaceSize: 8192,
|
|
15
|
-
pointSizeScale: 1,
|
|
16
|
-
linkWidthScale: 1,
|
|
17
|
-
linkArrowsSizeScale: 1,
|
|
18
|
-
renderLinks: true,
|
|
19
|
-
curvedLinks: false,
|
|
20
|
-
curvedLinkSegments: 19,
|
|
21
|
-
curvedLinkWeight: 0.8,
|
|
22
|
-
curvedLinkControlPointDistance: 0.5,
|
|
23
|
-
linkArrows: false,
|
|
24
|
-
linkVisibilityDistanceRange: [50, 150],
|
|
25
|
-
linkVisibilityMinTransparency: 0.25,
|
|
26
|
-
hoveredPointCursor: 'auto',
|
|
27
|
-
hoveredLinkCursor: 'auto',
|
|
28
|
-
renderHoveredPointRing: false,
|
|
29
|
-
hoveredPointRingColor: 'white',
|
|
30
|
-
hoveredLinkColor: undefined,
|
|
31
|
-
hoveredLinkWidthIncrease: 5,
|
|
32
|
-
focusedPointRingColor: 'white',
|
|
33
|
-
focusedPointIndex: undefined,
|
|
34
|
-
useClassicQuadtree: false,
|
|
35
|
-
simulation: {
|
|
36
|
-
decay: 5000,
|
|
37
|
-
gravity: 0.25,
|
|
38
|
-
center: 0,
|
|
39
|
-
repulsion: 1.0,
|
|
40
|
-
repulsionTheta: 1.15,
|
|
41
|
-
repulsionQuadtreeLevels: 12,
|
|
42
|
-
linkSpring: 1,
|
|
43
|
-
linkDistance: 10,
|
|
44
|
-
linkDistRandomVariationRange: [1, 1.2],
|
|
45
|
-
repulsionFromMouse: 2,
|
|
46
|
-
friction: 0.85,
|
|
47
|
-
cluster: 0.1,
|
|
48
|
-
},
|
|
49
|
-
showFPSMonitor: false,
|
|
50
|
-
pixelRatio: 2,
|
|
51
|
-
scalePointsOnZoom: false,
|
|
52
|
-
scaleLinksOnZoom: false,
|
|
53
|
-
enableZoom: true,
|
|
54
|
-
enableSimulationDuringZoom: false,
|
|
55
|
-
enableDrag: false,
|
|
56
|
-
fitViewOnInit: true,
|
|
57
|
-
fitViewDelay: 250,
|
|
58
|
-
fitViewPadding: 0.1,
|
|
59
|
-
fitViewDuration: 250,
|
|
60
|
-
pointSamplingDistance: 150,
|
|
61
|
-
attribution: '',
|
|
62
|
-
rescalePositions: undefined,
|
|
63
|
-
enableRightClickRepulsion: false,
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const hoveredPointRingOpacity = 0.7
|
|
67
|
-
export const focusedPointRingOpacity = 0.95
|
|
68
|
-
export const defaultScaleToZoom = 3
|
package/tsconfig.json
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"paths": {
|
|
5
|
-
"@/graph": ["src/"],
|
|
6
|
-
"@/graph/*": ["src/*"],
|
|
7
|
-
"@cosmos.gl/graph": ["src/"],
|
|
8
|
-
"@cosmos.gl/graph/*": ["src/*"],
|
|
9
|
-
},
|
|
10
|
-
"plugins": [{
|
|
11
|
-
"transform": "@zerollup/ts-transform-paths",
|
|
12
|
-
"exclude": ["*"]
|
|
13
|
-
}],
|
|
14
|
-
"target": "es2019",
|
|
15
|
-
"module": "esnext",
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"lib": ["es2019", "es2017", "es7", "es6", "dom"],
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"outDir": "dist",
|
|
20
|
-
|
|
21
|
-
"alwaysStrict": true,
|
|
22
|
-
"noImplicitAny": true,
|
|
23
|
-
"strictNullChecks": true,
|
|
24
|
-
"strictPropertyInitialization": true,
|
|
25
|
-
"strictFunctionTypes": true,
|
|
26
|
-
"noImplicitThis": true,
|
|
27
|
-
"strictBindCallApply": true,
|
|
28
|
-
|
|
29
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
30
|
-
"noUncheckedIndexedAccess": true,
|
|
31
|
-
|
|
32
|
-
"esModuleInterop": true
|
|
33
|
-
},
|
|
34
|
-
"include": [
|
|
35
|
-
"./src/**/*"
|
|
36
|
-
],
|
|
37
|
-
"exclude": [
|
|
38
|
-
"node_modules",
|
|
39
|
-
"dist"
|
|
40
|
-
]
|
|
41
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
import { defineConfig, LibraryFormats, UserConfig } from 'vite'
|
|
3
|
-
import glsl from 'vite-plugin-glsl'
|
|
4
|
-
import dts from 'vite-plugin-dts'
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line import/no-default-export
|
|
7
|
-
export default defineConfig(() => {
|
|
8
|
-
const config: UserConfig = {
|
|
9
|
-
build: {
|
|
10
|
-
lib: {
|
|
11
|
-
entry: resolve(__dirname, 'src/index.ts'),
|
|
12
|
-
name: 'Cosmos',
|
|
13
|
-
formats: ['es', 'umd'] as LibraryFormats[],
|
|
14
|
-
fileName: (format): string => format === 'umd' ? 'index.min.js' : 'index.js',
|
|
15
|
-
},
|
|
16
|
-
sourcemap: true,
|
|
17
|
-
minify: true,
|
|
18
|
-
rollupOptions: {
|
|
19
|
-
external: ['d3-array', 'd3-color', 'd3-drag', 'd3-ease', 'd3-scale', 'd3-selection', 'd3-transition', 'd3-zoom', 'regl'],
|
|
20
|
-
output: {
|
|
21
|
-
globals: {
|
|
22
|
-
'd3-selection': 'd3',
|
|
23
|
-
'd3-ease': 'd3',
|
|
24
|
-
regl: 'createREGL',
|
|
25
|
-
'd3-color': 'd3',
|
|
26
|
-
'd3-scale': 'd3',
|
|
27
|
-
'd3-array': 'd3',
|
|
28
|
-
'gl-matrix': 'glMatrix',
|
|
29
|
-
random: 'random',
|
|
30
|
-
'd3-zoom': 'd3',
|
|
31
|
-
'd3-drag': 'd3',
|
|
32
|
-
'd3-transition': 'd3',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
plugins: [
|
|
38
|
-
glsl(),
|
|
39
|
-
dts(),
|
|
40
|
-
],
|
|
41
|
-
resolve: {
|
|
42
|
-
alias: {
|
|
43
|
-
'@/graph': resolve(__dirname, 'src/'),
|
|
44
|
-
'@cosmos.gl/graph': resolve(__dirname, 'src/'),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (config?.build?.lib && config.build.rollupOptions && config.build.lib.formats && config.build.lib.formats.includes('umd')) {
|
|
50
|
-
delete config.build.rollupOptions.external
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return config
|
|
54
|
-
})
|