@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.
- package/dist/{src/config.d.ts → config.d.ts} +18 -2
- package/dist/{src/graph → graph}/utils/error-message.d.ts +1 -1
- package/dist/helper.d.ts +24 -0
- package/dist/{src/index.d.ts → index.d.ts} +5 -28
- package/dist/index.js +14658 -14
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +473 -1057
- package/dist/index.min.js.map +1 -1
- package/dist/{src/modules → modules}/Clusters/index.d.ts +6 -13
- package/dist/{src/modules → modules}/ForceCenter/index.d.ts +3 -11
- package/dist/modules/ForceGravity/index.d.ts +6 -0
- package/dist/{src/modules → modules}/ForceLink/index.d.ts +4 -10
- package/dist/modules/ForceManyBody/index.d.ts +16 -0
- package/dist/modules/ForceManyBody/quadtree-frag-shader.d.ts +1 -0
- package/dist/modules/ForceManyBodyQuadtree/index.d.ts +15 -0
- package/dist/modules/ForceManyBodyQuadtree/quadtree-frag-shader.d.ts +1 -0
- package/dist/modules/ForceMouse/index.d.ts +6 -0
- package/dist/{src/modules → modules}/Lines/index.d.ts +5 -16
- package/dist/{src/modules → modules}/Points/index.d.ts +16 -32
- package/dist/modules/Shared/buffer.d.ts +8 -0
- package/dist/modules/Store/index.d.ts +75 -0
- package/dist/{src/modules → modules}/core-module.d.ts +3 -3
- package/dist/{src/variables.d.ts → variables.d.ts} +2 -0
- package/package.json +3 -2
- package/dist/index-CSMQs8iI.js +0 -19876
- package/dist/index-CSMQs8iI.js.map +0 -1
- package/dist/src/helper.d.ts +0 -61
- package/dist/src/modules/ForceGravity/index.d.ts +0 -13
- package/dist/src/modules/ForceManyBody/index.d.ts +0 -26
- package/dist/src/modules/ForceMouse/index.d.ts +0 -13
- package/dist/src/modules/Shared/buffer.d.ts +0 -1
- package/dist/src/modules/Shared/texture-utils.d.ts +0 -8
- package/dist/src/modules/Shared/uniform-utils.d.ts +0 -11
- package/dist/src/modules/Store/index.d.ts +0 -169
- package/dist/vite.config.d.ts +0 -2
- package/dist/webgl-device-QoBMYpnS.js +0 -3933
- package/dist/webgl-device-QoBMYpnS.js.map +0 -1
- /package/dist/{src/modules → modules}/Drag/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/FPSMonitor/css.d.ts +0 -0
- /package/dist/{src/modules → modules}/FPSMonitor/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceLink/force-spring.d.ts +0 -0
- /package/dist/{src/modules → modules}/GraphData/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/Lines/geometry.d.ts +0 -0
- /package/dist/{src/modules → modules}/Points/atlas-utils.d.ts +0 -0
- /package/dist/{src/modules → modules}/Zoom/index.d.ts +0 -0
package/dist/src/helper.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Device, Framebuffer } from '@luma.gl/core';
|
|
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
|
-
/**
|
|
11
|
-
* TODO: Migrate from deprecated `readPixelsToArrayWebGL` to CommandEncoder API
|
|
12
|
-
*
|
|
13
|
-
* `readPixelsToArrayWebGL` is deprecated in luma.gl v9. The recommended modern approach is:
|
|
14
|
-
*
|
|
15
|
-
* 1. Create a buffer to hold the pixel data:
|
|
16
|
-
* const buffer = device.createBuffer({
|
|
17
|
-
* byteLength: width * height * 4 * 4, // RGBA, 4 bytes per float
|
|
18
|
-
* usage: Buffer.COPY_DST | Buffer.MAP_READ
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* 2. Copy texture/framebuffer to buffer using command encoder:
|
|
22
|
-
* const commandEncoder = device.createCommandEncoder();
|
|
23
|
-
* commandEncoder.copyTextureToBuffer({
|
|
24
|
-
* sourceTexture: fbo, // Can be Texture or Framebuffer
|
|
25
|
-
* width: sourceWidth ?? fbo.width,
|
|
26
|
-
* height: sourceHeight ?? fbo.height,
|
|
27
|
-
* origin: [sourceX, sourceY],
|
|
28
|
-
* destinationBuffer: buffer
|
|
29
|
-
* });
|
|
30
|
-
* const commandBuffer = commandEncoder.finish();
|
|
31
|
-
* device.submit(commandBuffer);
|
|
32
|
-
*
|
|
33
|
-
* 3. Read the data from the buffer (async):
|
|
34
|
-
* const pixelData = await buffer.readAsync(); // Returns ArrayBuffer
|
|
35
|
-
* return new Float32Array(pixelData);
|
|
36
|
-
*
|
|
37
|
-
* Note: The modern approach is asynchronous, so this function signature would need to change
|
|
38
|
-
* to return Promise<Float32Array> or we'd need to handle async at all call sites (18 locations).
|
|
39
|
-
*
|
|
40
|
-
* Migration impact:
|
|
41
|
-
* - This function is used in 18 places across the codebase
|
|
42
|
-
* - All call sites would need to be updated to handle async
|
|
43
|
-
* - Consider batching the migration to avoid inconsistencies
|
|
44
|
-
*
|
|
45
|
-
* Current status: Deprecated but still functional. Keeping for now until full migration can be planned.
|
|
46
|
-
*/
|
|
47
|
-
export declare function readPixels(device: Device, fbo: Framebuffer, sourceX?: number, sourceY?: number, sourceWidth?: number, sourceHeight?: number): Float32Array;
|
|
48
|
-
export declare function clamp(num: number, min: number, max: number): number;
|
|
49
|
-
export declare function isNumber(value: number | undefined | null | typeof NaN): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Sanitizes HTML content to prevent XSS attacks using DOMPurify
|
|
52
|
-
*
|
|
53
|
-
* This function is used internally to sanitize HTML content before setting innerHTML,
|
|
54
|
-
* such as in attribution text. It uses a safe default configuration that allows
|
|
55
|
-
* only common safe HTML elements and attributes.
|
|
56
|
-
*
|
|
57
|
-
* @param html The HTML string to sanitize
|
|
58
|
-
* @param options Optional DOMPurify configuration options to override defaults
|
|
59
|
-
* @returns Sanitized HTML string safe for innerHTML usage
|
|
60
|
-
*/
|
|
61
|
-
export declare function sanitizeHtml(html: string, options?: DOMPurify.Config): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CoreModule } from '../core-module';
|
|
2
|
-
export declare class ForceGravity extends CoreModule {
|
|
3
|
-
private runCommand;
|
|
4
|
-
private vertexCoordBuffer;
|
|
5
|
-
private uniformStore;
|
|
6
|
-
initPrograms(): void;
|
|
7
|
-
run(): void;
|
|
8
|
-
/**
|
|
9
|
-
* Destruction order matters
|
|
10
|
-
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
11
|
-
*/
|
|
12
|
-
destroy(): void;
|
|
13
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CoreModule } from '../core-module';
|
|
2
|
-
export declare class ForceManyBody extends CoreModule {
|
|
3
|
-
private randomValuesTexture;
|
|
4
|
-
private pointIndices;
|
|
5
|
-
private levels;
|
|
6
|
-
private levelTargets;
|
|
7
|
-
private calculateLevelsCommand;
|
|
8
|
-
private forceCommand;
|
|
9
|
-
private forceFromItsOwnCentermassCommand;
|
|
10
|
-
private forceVertexCoordBuffer;
|
|
11
|
-
private calculateLevelsUniformStore;
|
|
12
|
-
private forceUniformStore;
|
|
13
|
-
private forceCenterUniformStore;
|
|
14
|
-
private previousPointsTextureSize;
|
|
15
|
-
private previousSpaceSize;
|
|
16
|
-
create(): void;
|
|
17
|
-
initPrograms(): void;
|
|
18
|
-
run(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Destruction order matters
|
|
21
|
-
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
22
|
-
*/
|
|
23
|
-
destroy(): void;
|
|
24
|
-
private drawLevels;
|
|
25
|
-
private drawForces;
|
|
26
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CoreModule } from '../core-module';
|
|
2
|
-
export declare class ForceMouse extends CoreModule {
|
|
3
|
-
private runCommand;
|
|
4
|
-
private vertexCoordBuffer;
|
|
5
|
-
private uniformStore;
|
|
6
|
-
initPrograms(): void;
|
|
7
|
-
run(): void;
|
|
8
|
-
/**
|
|
9
|
-
* Destruction order matters
|
|
10
|
-
* Models -> Framebuffers -> Textures -> UniformStores -> Buffers
|
|
11
|
-
*/
|
|
12
|
-
destroy(): void;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createIndexesForBuffer(textureSize: number): Float32Array;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TextureFormat } from '@luma.gl/core';
|
|
2
|
-
/**
|
|
3
|
-
* Calculates bytesPerRow for texture uploads.
|
|
4
|
-
* @param format - Texture format
|
|
5
|
-
* @param width - Texture width in pixels
|
|
6
|
-
* @returns bytesPerRow in bytes
|
|
7
|
-
*/
|
|
8
|
-
export declare function getBytesPerRow(format: TextureFormat, width: number): number;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates and normalizes array values to fixed-size tuples for shader uniforms.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Ensures a value is a vec2 tuple [number, number].
|
|
6
|
-
*/
|
|
7
|
-
export declare function ensureVec2(arr: number[] | undefined, fallback: [number, number]): [number, number];
|
|
8
|
-
/**
|
|
9
|
-
* Ensures a value is a vec4 tuple [number, number, number, number].
|
|
10
|
-
*/
|
|
11
|
-
export declare function ensureVec4(arr: number[] | undefined, fallback: [number, number, number, number]): [number, number, number, number];
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { mat3 } from 'gl-matrix';
|
|
2
|
-
import { GraphConfigInterface } from '../../config';
|
|
3
|
-
export declare const ALPHA_MIN = 0.001;
|
|
4
|
-
export declare const MAX_POINT_SIZE = 64;
|
|
5
|
-
/**
|
|
6
|
-
* Maximum number of executions to delay before performing hover detection.
|
|
7
|
-
* This threshold prevents excessive hover detection calls for performance optimization.
|
|
8
|
-
* The `findHoveredItem` method will skip actual detection until this count is reached.
|
|
9
|
-
*/
|
|
10
|
-
export declare const MAX_HOVER_DETECTION_DELAY = 4;
|
|
11
|
-
export type Hovered = {
|
|
12
|
-
index: number;
|
|
13
|
-
position: [number, number];
|
|
14
|
-
};
|
|
15
|
-
type Focused = {
|
|
16
|
-
index: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Type alias for a 4x4 matrix stored as a 16-element array in column-major order.
|
|
20
|
-
* Used for std140 uniform buffer layout compatibility.
|
|
21
|
-
*/
|
|
22
|
-
type Mat4Array = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];
|
|
23
|
-
export declare class Store {
|
|
24
|
-
pointsTextureSize: number;
|
|
25
|
-
linksTextureSize: number;
|
|
26
|
-
alpha: number;
|
|
27
|
-
transform: mat3;
|
|
28
|
-
screenSize: [number, number];
|
|
29
|
-
mousePosition: number[];
|
|
30
|
-
screenMousePosition: number[];
|
|
31
|
-
selectedArea: number[][];
|
|
32
|
-
isSimulationRunning: boolean;
|
|
33
|
-
simulationProgress: number;
|
|
34
|
-
selectedIndices: Float32Array | null;
|
|
35
|
-
maxPointSize: number;
|
|
36
|
-
hoveredPoint: Hovered | undefined;
|
|
37
|
-
focusedPoint: Focused | undefined;
|
|
38
|
-
draggingPointIndex: number | undefined;
|
|
39
|
-
hoveredLinkIndex: number | undefined;
|
|
40
|
-
adjustedSpaceSize: number;
|
|
41
|
-
isSpaceKeyPressed: boolean;
|
|
42
|
-
div: HTMLDivElement | undefined;
|
|
43
|
-
webglMaxTextureSize: number;
|
|
44
|
-
hoveredPointRingColor: number[];
|
|
45
|
-
focusedPointRingColor: number[];
|
|
46
|
-
hoveredLinkColor: number[];
|
|
47
|
-
greyoutPointColor: number[];
|
|
48
|
-
isDarkenGreyout: boolean;
|
|
49
|
-
isLinkHoveringEnabled: boolean;
|
|
50
|
-
private alphaTarget;
|
|
51
|
-
private scalePointX;
|
|
52
|
-
private scalePointY;
|
|
53
|
-
private random;
|
|
54
|
-
private _backgroundColor;
|
|
55
|
-
get backgroundColor(): [number, number, number, number];
|
|
56
|
-
/**
|
|
57
|
-
* Gets the transformation matrix as a 4x4 matrix for std140 uniform buffer layout.
|
|
58
|
-
*
|
|
59
|
-
* This method converts the internal 3x3 transformation matrix (mat3) to a 4x4 matrix format
|
|
60
|
-
* required by WebGPU uniform buffers using the std140 layout standard.
|
|
61
|
-
*
|
|
62
|
-
* ## Matrix Storage Format
|
|
63
|
-
*
|
|
64
|
-
* Matrices are stored in **column-major order** (GLSL convention). The internal `transform`
|
|
65
|
-
* array is a 9-element array representing a 3x3 matrix:
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
68
|
-
* [m00, m10, m20, m01, m11, m21, m02, m12, m22]
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* Which represents the matrix:
|
|
72
|
-
* ```
|
|
73
|
-
* [m00 m01 m02]
|
|
74
|
-
* [m10 m11 m12]
|
|
75
|
-
* [m20 m21 m22]
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* ## Why This Conversion Is Needed
|
|
79
|
-
*
|
|
80
|
-
* The internal `transform` property stores a 3x3 matrix (9 elements) which is sufficient for
|
|
81
|
-
* 2D transformations (translation, rotation, scaling in x/y plane). However, when passing
|
|
82
|
-
* transformation matrices to GPU shaders via uniform buffers, we must comply with the std140
|
|
83
|
-
* layout standard.
|
|
84
|
-
*
|
|
85
|
-
* ### std140 Layout Requirements
|
|
86
|
-
*
|
|
87
|
-
* The std140 layout standard (used in both OpenGL and WebGPU) defines strict alignment rules:
|
|
88
|
-
*
|
|
89
|
-
* 1. **Matrix Alignment**: In std140, matrices are stored as arrays of column vectors
|
|
90
|
-
* - `mat3` requires each column to be aligned to 16 bytes (vec4 alignment)
|
|
91
|
-
* - This means `mat3` occupies 3 columns × 16 bytes = 48 bytes total
|
|
92
|
-
* - `mat4` occupies 4 columns × 16 bytes = 64 bytes total
|
|
93
|
-
*
|
|
94
|
-
* 2. **Alignment Issues with mat3**:
|
|
95
|
-
* - The 48-byte size of `mat3` creates awkward alignment and padding requirements
|
|
96
|
-
* - Different GPU drivers may handle `mat3` padding inconsistently
|
|
97
|
-
* - This can lead to data misalignment and incorrect transformations
|
|
98
|
-
*
|
|
99
|
-
* 3. **Why mat4 is Preferred**:
|
|
100
|
-
* - `mat4` has clean 64-byte alignment (power of 2)
|
|
101
|
-
* - Consistent behavior across all GPU drivers and platforms
|
|
102
|
-
* - The shader can easily extract the 3x3 portion: `mat3 transformMat3 = mat3(transformationMatrix)`
|
|
103
|
-
* - The 4th column is set to `[0, 0, 0, 1]` (homogeneous coordinate) which doesn't affect 2D transforms
|
|
104
|
-
*
|
|
105
|
-
* ### Conversion Process
|
|
106
|
-
*
|
|
107
|
-
* The 3x3 matrix is converted to 4x4 by:
|
|
108
|
-
* - Placing the 3x3 values in the top-left corner (preserving column-major order)
|
|
109
|
-
* - Setting the 4th column to `[0, 0, 0, 1]` (homogeneous coordinate)
|
|
110
|
-
* - The 4th row is implicitly `[0, 0, 0, 1]` due to column-major storage
|
|
111
|
-
*
|
|
112
|
-
* This creates a valid 4x4 transformation matrix that:
|
|
113
|
-
* - Maintains the same 2D transformation behavior
|
|
114
|
-
* - Satisfies std140 alignment requirements
|
|
115
|
-
* - Works consistently across all GPU platforms
|
|
116
|
-
*
|
|
117
|
-
* ### Usage in Shaders
|
|
118
|
-
*
|
|
119
|
-
* Shaders using uniform buffers receive this as `mat4` and extract the 3x3 portion:
|
|
120
|
-
* ```glsl
|
|
121
|
-
* layout(std140) uniform uniforms {
|
|
122
|
-
* mat4 transformationMatrix;
|
|
123
|
-
* } uniforms;
|
|
124
|
-
*
|
|
125
|
-
* mat3 transformMat3 = mat3(uniforms.transformationMatrix);
|
|
126
|
-
* vec3 final = transformMat3 * vec3(position, 1);
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* @returns A 16-element array representing a 4x4 matrix in column-major order,
|
|
130
|
-
* suitable for std140 uniform buffer layout. The matrix preserves the
|
|
131
|
-
* 2D transformation from the original 3x3 matrix.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const matrix = store.transformationMatrix4x4;
|
|
136
|
-
* uniformStore.setUniforms({
|
|
137
|
-
* uniforms: {
|
|
138
|
-
* transformationMatrix: matrix // Expects mat4x4<f32> in shader
|
|
139
|
-
* }
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
get transformationMatrix4x4(): Mat4Array;
|
|
144
|
-
set backgroundColor(color: [number, number, number, number]);
|
|
145
|
-
addRandomSeed(seed: number | string): void;
|
|
146
|
-
getRandomFloat(min: number, max: number): number;
|
|
147
|
-
/**
|
|
148
|
-
* If the config parameter `spaceSize` exceeds the limits of WebGL,
|
|
149
|
-
* it reduces the space size without changing the config parameter.
|
|
150
|
-
* Ensures `spaceSize` is always a positive number >= 2 (required for Math.log2).
|
|
151
|
-
*/
|
|
152
|
-
adjustSpaceSize(configSpaceSize: number, webglMaxTextureSize: number): void;
|
|
153
|
-
/**
|
|
154
|
-
* Sets the WebGL texture size limit for use in atlas creation and other texture operations.
|
|
155
|
-
*/
|
|
156
|
-
setWebGLMaxTextureSize(webglMaxTextureSize: number): void;
|
|
157
|
-
updateScreenSize(width: number, height: number): void;
|
|
158
|
-
scaleX(x: number): number;
|
|
159
|
-
scaleY(y: number): number;
|
|
160
|
-
setHoveredPointRingColor(color: string | [number, number, number, number]): void;
|
|
161
|
-
setFocusedPointRingColor(color: string | [number, number, number, number]): void;
|
|
162
|
-
setGreyoutPointColor(color: string | [number, number, number, number] | undefined): void;
|
|
163
|
-
updateLinkHoveringEnabled(config: Pick<GraphConfigInterface, 'onLinkClick' | 'onLinkMouseOver' | 'onLinkMouseOut'>): void;
|
|
164
|
-
setHoveredLinkColor(color?: string | [number, number, number, number]): void;
|
|
165
|
-
setFocusedPoint(index?: number): void;
|
|
166
|
-
addAlpha(decay: number): number;
|
|
167
|
-
private alphaDecay;
|
|
168
|
-
}
|
|
169
|
-
export {};
|
package/dist/vite.config.d.ts
DELETED