@cosmos.gl/graph 2.7.0-beta.0 → 2.7.0-beta.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 +18 -5
- package/dist/{index-FUIgayhu.js → index-B1_1MjaX.js} +1909 -1819
- package/dist/index-B1_1MjaX.js.map +1 -0
- package/dist/index.d.ts +66 -6
- package/dist/index.js +1 -1
- package/dist/index.min.js +46 -34
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Clusters/index.d.ts +0 -3
- package/dist/modules/GraphData/index.d.ts +1 -0
- package/dist/modules/Points/index.d.ts +2 -4
- package/dist/{webgl-device-B9ewDj5L.js → webgl-device-DzkMihDq.js} +2 -2
- package/dist/{webgl-device-B9ewDj5L.js.map → webgl-device-DzkMihDq.js.map} +1 -1
- 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/index-FUIgayhu.js.map +0 -1
- package/dist/stories/beginners/basic-set-up/data-gen.d.ts +0 -4
- package/dist/stories/beginners/basic-set-up/index.d.ts +0 -6
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +0 -19
- package/dist/stories/beginners/link-hovering/index.d.ts +0 -6
- package/dist/stories/beginners/point-labels/data.d.ts +0 -13
- package/dist/stories/beginners/point-labels/index.d.ts +0 -10
- package/dist/stories/beginners/point-labels/labels.d.ts +0 -8
- package/dist/stories/beginners/quick-start.d.ts +0 -6
- 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 -6
- 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 -6
- package/dist/stories/clusters/with-labels.d.ts +0 -6
- package/dist/stories/clusters/worm.d.ts +0 -6
- 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 -17
- package/dist/stories/create-story.d.ts +0 -16
- package/dist/stories/experiments/full-mesh.d.ts +0 -6
- package/dist/stories/experiments/mesh-with-holes.d.ts +0 -6
- 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 -16
- 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 -6
- package/dist/stories/shapes/image-example/index.d.ts +0 -6
- package/dist/stories/shapes.stories.d.ts +0 -7
- package/dist/stories/test-luma-migration.d.ts +0 -6
- package/dist/stories/test.stories.d.ts +0 -6
- package/logo.svg +0 -3
- package/rollup.config.js +0 -70
- package/src/config.ts +0 -728
- package/src/declaration.d.ts +0 -12
- package/src/graph/utils/error-message.ts +0 -23
- package/src/helper.ts +0 -113
- package/src/index.ts +0 -1769
- package/src/modules/Clusters/calculate-centermass.frag +0 -12
- package/src/modules/Clusters/calculate-centermass.vert +0 -38
- package/src/modules/Clusters/force-cluster.frag +0 -55
- package/src/modules/Clusters/index.ts +0 -578
- 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 -26
- package/src/modules/ForceCenter/force-center.frag +0 -37
- package/src/modules/ForceCenter/index.ts +0 -284
- package/src/modules/ForceGravity/force-gravity.frag +0 -40
- package/src/modules/ForceGravity/index.ts +0 -107
- package/src/modules/ForceLink/force-spring.ts +0 -89
- package/src/modules/ForceLink/index.ts +0 -293
- package/src/modules/ForceManyBody/calculate-level.frag +0 -9
- package/src/modules/ForceManyBody/calculate-level.vert +0 -37
- package/src/modules/ForceManyBody/force-centermass.frag +0 -61
- package/src/modules/ForceManyBody/force-level.frag +0 -138
- package/src/modules/ForceManyBody/index.ts +0 -525
- package/src/modules/ForceManyBody/quadtree-frag-shader.ts +0 -89
- 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 -35
- package/src/modules/ForceMouse/index.ts +0 -102
- package/src/modules/GraphData/index.ts +0 -383
- package/src/modules/Lines/draw-curve-line.frag +0 -59
- package/src/modules/Lines/draw-curve-line.vert +0 -248
- package/src/modules/Lines/geometry.ts +0 -18
- package/src/modules/Lines/hovered-line-index.frag +0 -43
- package/src/modules/Lines/hovered-line-index.vert +0 -13
- package/src/modules/Lines/index.ts +0 -661
- package/src/modules/Points/atlas-utils.ts +0 -137
- package/src/modules/Points/drag-point.frag +0 -34
- package/src/modules/Points/draw-highlighted.frag +0 -44
- package/src/modules/Points/draw-highlighted.vert +0 -145
- package/src/modules/Points/draw-points.frag +0 -259
- package/src/modules/Points/draw-points.vert +0 -203
- package/src/modules/Points/fill-sampled-points.frag +0 -12
- package/src/modules/Points/fill-sampled-points.vert +0 -51
- package/src/modules/Points/find-hovered-point.frag +0 -15
- package/src/modules/Points/find-hovered-point.vert +0 -90
- package/src/modules/Points/find-points-on-area-selection.frag +0 -88
- package/src/modules/Points/find-points-on-polygon-selection.frag +0 -89
- package/src/modules/Points/index.ts +0 -2292
- package/src/modules/Points/track-positions.frag +0 -30
- package/src/modules/Points/update-position.frag +0 -39
- package/src/modules/Shared/buffer.ts +0 -39
- package/src/modules/Shared/clear.frag +0 -10
- package/src/modules/Shared/quad.vert +0 -13
- package/src/modules/Store/index.ts +0 -283
- 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 -111
- 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 -167
- 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 -65
- 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 -69
- 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 -54
- 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 -96
- package/src/stories/beginners/remove-points/style.css +0 -31
- package/src/stories/beginners.stories.ts +0 -130
- package/src/stories/clusters/polygon-selection/index.ts +0 -52
- 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 -54
- 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 -72
- 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 -66
- 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 -73
- 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 -246
- package/src/stories/shapes.stories.ts +0 -37
- package/src/stories/test-luma-migration.ts +0 -195
- package/src/stories/test.stories.ts +0 -25
- package/src/variables.ts +0 -68
- package/tsconfig.json +0 -41
- package/vite.config.ts +0 -52
package/src/declaration.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare module '*.frag';
|
|
2
|
-
declare module '*.vert';
|
|
3
|
-
declare module '*.png' {
|
|
4
|
-
const content: string
|
|
5
|
-
// eslint-disable-next-line import/no-default-export
|
|
6
|
-
export default content
|
|
7
|
-
}
|
|
8
|
-
declare module '*?raw' {
|
|
9
|
-
const content: string
|
|
10
|
-
// eslint-disable-next-line import/no-default-export
|
|
11
|
-
export default content
|
|
12
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates and appends an error message element to the container
|
|
3
|
-
* @param container The HTML element to append the error message to
|
|
4
|
-
* @returns The created error div element
|
|
5
|
-
*/
|
|
6
|
-
export function createWebGLErrorMessage (container: HTMLElement, error: string): HTMLDivElement {
|
|
7
|
-
const errorDiv = document.createElement('div')
|
|
8
|
-
errorDiv.style.cssText = `
|
|
9
|
-
color: var(--cosmosgl-error-message-color);
|
|
10
|
-
padding: 0em 2em;
|
|
11
|
-
position: absolute;
|
|
12
|
-
top: 50%; left: 0; right: 0;
|
|
13
|
-
transform: translateY(-50%);
|
|
14
|
-
z-index: 1000;
|
|
15
|
-
font-family: inherit;
|
|
16
|
-
font-size: 1rem;
|
|
17
|
-
text-align: center;
|
|
18
|
-
user-select: none;
|
|
19
|
-
`
|
|
20
|
-
errorDiv.textContent = `Sorry, your device or browser does not support the required WebGL features for this visualization: ${error}`
|
|
21
|
-
container.appendChild(errorDiv)
|
|
22
|
-
return errorDiv
|
|
23
|
-
}
|
package/src/helper.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { color as d3Color } from 'd3-color'
|
|
2
|
-
import { Device, Framebuffer } from '@luma.gl/core'
|
|
3
|
-
import DOMPurify from 'dompurify'
|
|
4
|
-
|
|
5
|
-
export const isFunction = <T>(a: T): boolean => typeof a === 'function'
|
|
6
|
-
export const isArray = <T>(a: unknown | T[]): a is T[] => Array.isArray(a)
|
|
7
|
-
export const isObject = <T>(a: T): boolean => (a instanceof Object)
|
|
8
|
-
export const isAClassInstance = <T>(a: T): boolean => {
|
|
9
|
-
if (a instanceof Object) {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
11
|
-
return (a as T & Object).constructor.name !== 'Function' && (a as T & Object).constructor.name !== 'Object'
|
|
12
|
-
} else return false
|
|
13
|
-
}
|
|
14
|
-
export const isPlainObject = <T>(a: T): boolean => isObject(a) && !isArray(a) && !isFunction(a) && !isAClassInstance(a)
|
|
15
|
-
|
|
16
|
-
export function getRgbaColor (value: string | [number, number, number, number]): [number, number, number, number] {
|
|
17
|
-
let rgba: [number, number, number, number]
|
|
18
|
-
if (isArray(value)) {
|
|
19
|
-
rgba = value
|
|
20
|
-
} else {
|
|
21
|
-
const color = d3Color(value)
|
|
22
|
-
const rgb = color?.rgb()
|
|
23
|
-
rgba = [rgb?.r || 0, rgb?.g || 0, rgb?.b || 0, color?.opacity ?? 1]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return [
|
|
27
|
-
rgba[0] / 255,
|
|
28
|
-
rgba[1] / 255,
|
|
29
|
-
rgba[2] / 255,
|
|
30
|
-
rgba[3],
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function rgbToBrightness (r: number, g: number, b: number): number {
|
|
35
|
-
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* TODO: Migrate from deprecated `readPixelsToArrayWebGL` to CommandEncoder API
|
|
40
|
-
*
|
|
41
|
-
* `readPixelsToArrayWebGL` is deprecated in luma.gl v9. The recommended modern approach is:
|
|
42
|
-
*
|
|
43
|
-
* 1. Create a buffer to hold the pixel data:
|
|
44
|
-
* const buffer = device.createBuffer({
|
|
45
|
-
* byteLength: width * height * 4 * 4, // RGBA, 4 bytes per float
|
|
46
|
-
* usage: Buffer.COPY_DST | Buffer.MAP_READ
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* 2. Copy texture/framebuffer to buffer using command encoder:
|
|
50
|
-
* const commandEncoder = device.createCommandEncoder();
|
|
51
|
-
* commandEncoder.copyTextureToBuffer({
|
|
52
|
-
* sourceTexture: fbo, // Can be Texture or Framebuffer
|
|
53
|
-
* width: sourceWidth ?? fbo.width,
|
|
54
|
-
* height: sourceHeight ?? fbo.height,
|
|
55
|
-
* origin: [sourceX, sourceY],
|
|
56
|
-
* destinationBuffer: buffer
|
|
57
|
-
* });
|
|
58
|
-
* const commandBuffer = commandEncoder.finish();
|
|
59
|
-
* device.submit(commandBuffer);
|
|
60
|
-
*
|
|
61
|
-
* 3. Read the data from the buffer (async):
|
|
62
|
-
* const pixelData = await buffer.readAsync(); // Returns ArrayBuffer
|
|
63
|
-
* return new Float32Array(pixelData);
|
|
64
|
-
*
|
|
65
|
-
* Note: The modern approach is asynchronous, so this function signature would need to change
|
|
66
|
-
* to return Promise<Float32Array> or we'd need to handle async at all call sites (18 locations).
|
|
67
|
-
*
|
|
68
|
-
* Migration impact:
|
|
69
|
-
* - This function is used in 18 places across the codebase
|
|
70
|
-
* - All call sites would need to be updated to handle async
|
|
71
|
-
* - Consider batching the migration to avoid inconsistencies
|
|
72
|
-
*
|
|
73
|
-
* Current status: Deprecated but still functional. Keeping for now until full migration can be planned.
|
|
74
|
-
*/
|
|
75
|
-
export function readPixels (device: Device, fbo: Framebuffer, sourceX = 0, sourceY = 0, sourceWidth?: number, sourceHeight?: number): Float32Array {
|
|
76
|
-
// Let luma.gl auto-allocate based on texture format
|
|
77
|
-
// It will use Float32Array for rgba32float textures
|
|
78
|
-
return device.readPixelsToArrayWebGL(fbo, {
|
|
79
|
-
sourceX,
|
|
80
|
-
sourceY,
|
|
81
|
-
sourceWidth,
|
|
82
|
-
sourceHeight,
|
|
83
|
-
}) as Float32Array
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function clamp (num: number, min: number, max: number): number {
|
|
87
|
-
return Math.min(Math.max(num, min), max)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function isNumber (value: number | undefined | null | typeof NaN): boolean {
|
|
91
|
-
return value !== undefined && value !== null && !Number.isNaN(value)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sanitizes HTML content to prevent XSS attacks using DOMPurify
|
|
96
|
-
*
|
|
97
|
-
* This function is used internally to sanitize HTML content before setting innerHTML,
|
|
98
|
-
* such as in attribution text. It uses a safe default configuration that allows
|
|
99
|
-
* only common safe HTML elements and attributes.
|
|
100
|
-
*
|
|
101
|
-
* @param html The HTML string to sanitize
|
|
102
|
-
* @param options Optional DOMPurify configuration options to override defaults
|
|
103
|
-
* @returns Sanitized HTML string safe for innerHTML usage
|
|
104
|
-
*/
|
|
105
|
-
export function sanitizeHtml (html: string, options?: DOMPurify.Config): string {
|
|
106
|
-
return DOMPurify.sanitize(html, {
|
|
107
|
-
// Default configuration: allow common safe HTML elements and attributes
|
|
108
|
-
ALLOWED_TAGS: ['a', 'b', 'i', 'em', 'strong', 'span', 'div', 'p', 'br'],
|
|
109
|
-
ALLOWED_ATTR: ['href', 'target', 'class', 'id', 'style'],
|
|
110
|
-
ALLOW_DATA_ATTR: false,
|
|
111
|
-
...options,
|
|
112
|
-
})
|
|
113
|
-
}
|