@cosmos.gl/graph 3.0.0-beta.1 → 3.0.0-beta.3
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} +13 -13
- package/dist/{src/index.d.ts → index.d.ts} +16 -5
- package/dist/index.js +6417 -15
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +80 -57
- package/dist/index.min.js.map +1 -1
- package/dist/{src/modules → modules}/Store/index.d.ts +1 -1
- package/dist/{src/modules → modules}/Zoom/index.d.ts +6 -5
- package/package.json +5 -14
- package/dist/index-C08ZBzdl.js +0 -19898
- package/dist/index-C08ZBzdl.js.map +0 -1
- package/dist/vite.config.d.ts +0 -2
- package/dist/webgl-device-Bbjp2SUN.js +0 -3933
- package/dist/webgl-device-Bbjp2SUN.js.map +0 -1
- /package/dist/{src/graph → graph}/utils/error-message.d.ts +0 -0
- /package/dist/{src/helper.d.ts → helper.d.ts} +0 -0
- /package/dist/{src/modules → modules}/Clusters/index.d.ts +0 -0
- /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}/ForceCenter/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceGravity/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceLink/force-spring.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceLink/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceManyBody/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/ForceMouse/index.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}/Lines/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/Points/atlas-utils.d.ts +0 -0
- /package/dist/{src/modules → modules}/Points/index.d.ts +0 -0
- /package/dist/{src/modules → modules}/Shared/buffer.d.ts +0 -0
- /package/dist/{src/modules → modules}/Shared/texture-utils.d.ts +0 -0
- /package/dist/{src/modules → modules}/Shared/uniform-utils.d.ts +0 -0
- /package/dist/{src/modules → modules}/core-module.d.ts +0 -0
- /package/dist/{src/variables.d.ts → variables.d.ts} +0 -0
|
@@ -349,7 +349,7 @@ export interface GraphConfigInterface {
|
|
|
349
349
|
* `(index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent) => void`.
|
|
350
350
|
* Default value: `undefined`
|
|
351
351
|
*/
|
|
352
|
-
|
|
352
|
+
onContextMenu?: (index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent) => void;
|
|
353
353
|
/**
|
|
354
354
|
* Callback function that will be called when a context menu trigger (typically right click) happens on a point.
|
|
355
355
|
* The point index will be passed as the first argument,
|
|
@@ -357,21 +357,21 @@ export interface GraphConfigInterface {
|
|
|
357
357
|
* `(index: number, pointPosition: [number, number], event: MouseEvent) => void`.
|
|
358
358
|
* Default value: `undefined`
|
|
359
359
|
*/
|
|
360
|
-
|
|
360
|
+
onPointContextMenu?: (index: number, pointPosition: [number, number], event: MouseEvent) => void;
|
|
361
361
|
/**
|
|
362
362
|
* Callback function that will be called when a context menu trigger (typically right click) happens on a link.
|
|
363
363
|
* The link index will be passed as the first argument and the corresponding mouse event as the second argument:
|
|
364
364
|
* `(linkIndex: number, event: MouseEvent) => void`.
|
|
365
365
|
* Default value: `undefined`
|
|
366
366
|
*/
|
|
367
|
-
|
|
367
|
+
onLinkContextMenu?: (linkIndex: number, event: MouseEvent) => void;
|
|
368
368
|
/**
|
|
369
369
|
* Callback function that will be called when a context menu trigger (typically right click) happens on the background (empty space).
|
|
370
370
|
* The mouse event will be passed as the first argument:
|
|
371
371
|
* `(event: MouseEvent) => void`.
|
|
372
372
|
* Default value: `undefined`
|
|
373
373
|
*/
|
|
374
|
-
|
|
374
|
+
onBackgroundContextMenu?: (event: MouseEvent) => void;
|
|
375
375
|
/**
|
|
376
376
|
* Callback function that will be called when mouse movement happens.
|
|
377
377
|
* If the mouse moves over a point, its index will be passed as the first argument,
|
|
@@ -383,13 +383,13 @@ export interface GraphConfigInterface {
|
|
|
383
383
|
/**
|
|
384
384
|
* Callback function that will be called when a point appears under the mouse
|
|
385
385
|
* as a result of a mouse event, zooming and panning, or movement of points.
|
|
386
|
-
* The point index will be passed as the first argument, position as the second argument
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined) => void`.
|
|
386
|
+
* The point index will be passed as the first argument, position as the second argument,
|
|
387
|
+
* the corresponding mouse event or D3's zoom event as the third argument, and whether
|
|
388
|
+
* the hovered point is selected as the fourth argument:
|
|
389
|
+
* `(index: number, pointPosition: [number, number], event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined, isSelected: boolean) => void`.
|
|
390
390
|
* Default value: `undefined`
|
|
391
391
|
*/
|
|
392
|
-
onPointMouseOver?: (index: number, pointPosition: [number, number], event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined) => void;
|
|
392
|
+
onPointMouseOver?: (index: number, pointPosition: [number, number], event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined, isSelected: boolean) => void;
|
|
393
393
|
/**
|
|
394
394
|
* Callback function that will be called when a point is no longer underneath
|
|
395
395
|
* the mouse pointer because of a mouse event, zoom/pan event, or movement of points.
|
|
@@ -626,10 +626,10 @@ export declare class GraphConfig implements GraphConfigInterface {
|
|
|
626
626
|
onPointClick: GraphConfigInterface['onPointClick'];
|
|
627
627
|
onLinkClick: GraphConfigInterface['onLinkClick'];
|
|
628
628
|
onBackgroundClick: GraphConfigInterface['onBackgroundClick'];
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
629
|
+
onContextMenu: GraphConfigInterface['onContextMenu'];
|
|
630
|
+
onPointContextMenu: GraphConfigInterface['onPointContextMenu'];
|
|
631
|
+
onLinkContextMenu: GraphConfigInterface['onLinkContextMenu'];
|
|
632
|
+
onBackgroundContextMenu: GraphConfigInterface['onBackgroundContextMenu'];
|
|
633
633
|
onMouseMove: GraphConfigInterface['onMouseMove'];
|
|
634
634
|
onPointMouseOver: GraphConfigInterface['onPointMouseOver'];
|
|
635
635
|
onPointMouseOut: GraphConfigInterface['onPointMouseOut'];
|
|
@@ -4,12 +4,13 @@ import { GraphData } from './modules/GraphData';
|
|
|
4
4
|
export declare class Graph {
|
|
5
5
|
config: GraphConfig;
|
|
6
6
|
graph: GraphData;
|
|
7
|
+
/** Promise that resolves with the luma device when the graph is ready. Await or `.then()` to run after init. */
|
|
8
|
+
readonly deviceInitPromise: Promise<Device>;
|
|
7
9
|
/** Canvas element, assigned asynchronously during device initialization */
|
|
8
10
|
private canvas;
|
|
9
11
|
private attributionDivElement;
|
|
10
12
|
private canvasD3Selection;
|
|
11
13
|
private device;
|
|
12
|
-
private deviceInitPromise;
|
|
13
14
|
/**
|
|
14
15
|
* Tracks whether this Graph instance owns the device and should destroy it on cleanup.
|
|
15
16
|
* Set to `true` when Graph creates its own device, `false` when using an external device.
|
|
@@ -332,16 +333,27 @@ export declare class Graph {
|
|
|
332
333
|
fitView(duration?: number, padding?: number): void;
|
|
333
334
|
/**
|
|
334
335
|
* Center and zoom in/out the view to fit points by their indices in the scene.
|
|
336
|
+
* @param indices Point indices to fit in the view.
|
|
335
337
|
* @param duration Duration of the center and zoom in/out animation in milliseconds (`250` by default).
|
|
336
|
-
* @param padding Padding around the viewport in percentage
|
|
338
|
+
* @param padding Padding around the viewport in percentage (`0.1` by default).
|
|
337
339
|
*/
|
|
338
340
|
fitViewByPointIndices(indices: number[], duration?: number, padding?: number): void;
|
|
339
341
|
/**
|
|
340
342
|
* Center and zoom in/out the view to fit points by their positions in the scene.
|
|
343
|
+
* @param positions Flat array of point coordinates as `[x0, y0, x1, y1, ...]`.
|
|
341
344
|
* @param duration Duration of the center and zoom in/out animation in milliseconds (`250` by default).
|
|
342
|
-
* @param padding Padding around the viewport in percentage
|
|
345
|
+
* @param padding Padding around the viewport in percentage (`0.1` by default).
|
|
343
346
|
*/
|
|
344
347
|
fitViewByPointPositions(positions: number[], duration?: number, padding?: number): void;
|
|
348
|
+
/**
|
|
349
|
+
* Sets the zoom transform so that the given point positions fit in the viewport, with optional animation.
|
|
350
|
+
*
|
|
351
|
+
* @param positions Flat array of point coordinates as `[x0, y0, x1, y1, ...]`.
|
|
352
|
+
* @param duration Animation duration in milliseconds. Default `250`.
|
|
353
|
+
* @param scale Optional scale factor; if omitted, scale is chosen to fit the positions.
|
|
354
|
+
* @param padding Padding around the viewport as a fraction (e.g. `0.1` = 10%). Default `0.1`.
|
|
355
|
+
*/
|
|
356
|
+
setZoomTransformByPointPositions(positions: Float32Array, duration?: number, scale?: number, padding?: number): void;
|
|
345
357
|
/**
|
|
346
358
|
* Get points indices inside a rectangular area.
|
|
347
359
|
* @param selection - Array of two corner points `[[left, top], [right, bottom]]`.
|
|
@@ -595,9 +607,8 @@ export declare class Graph {
|
|
|
595
607
|
private onClick;
|
|
596
608
|
private updateMousePosition;
|
|
597
609
|
private onMouseMove;
|
|
598
|
-
private
|
|
610
|
+
private onContextMenu;
|
|
599
611
|
private resizeCanvas;
|
|
600
|
-
private setZoomTransformByPointPositions;
|
|
601
612
|
private updateZoomDragBehaviors;
|
|
602
613
|
private findHoveredItem;
|
|
603
614
|
private findHoveredPoint;
|