@graphty/graphty-element 2.0.1 → 2.2.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.
Files changed (81) hide show
  1. package/README.md +3 -3
  2. package/dist/ai.js +4 -4
  3. package/dist/catalog.js +5 -5
  4. package/dist/chunks/{AiManager-awS0MNr1.js → AiManager-Dp1mOkPm.js} +5 -5
  5. package/dist/chunks/{Algorithm-BdcqHKps.js → Algorithm-RQ629NLb.js} +210 -92
  6. package/dist/chunks/{DataSource-DK4GZBKg.js → DataSource-DEg3igzS.js} +3 -3
  7. package/dist/chunks/{GraphSession-D87eymV8.js → GraphSession-D3AV8tpF.js} +2527 -2248
  8. package/dist/chunks/{GraphtyError-B3eKs4yg.js → GraphtyError-BwcnblTH.js} +10 -8
  9. package/dist/chunks/{GraphtyLogger-CK03SnJi.js → GraphtyLogger-5KEttFUo.js} +1 -1
  10. package/dist/chunks/{NodeStyle-CS7dj20m.js → NodeStyle-Cup9O1lu.js} +2 -1
  11. package/dist/chunks/{VoiceInputAdapter-CcnCmxo5.js → VoiceInputAdapter-Bbze1r8k.js} +1 -1
  12. package/dist/chunks/{XRPivotCameraController-UjMsbran.js → XRPivotCameraController-8Il3KxFm.js} +2 -2
  13. package/dist/chunks/{cameras-BeIAlMWR.js → cameras-CeJYi-Na.js} +17 -18
  14. package/dist/chunks/{capability-check-DcKFwS6q.js → capability-check-EUCOfQLP.js} +1 -1
  15. package/dist/chunks/{detect-B-YbbP7i.js → detect-CqN0mC6u.js} +3 -3
  16. package/dist/chunks/{format-detection-DohSEZnb.js → format-detection-C8vbCSlS.js} +1 -1
  17. package/dist/chunks/{index-uohvGegX.js → index-Cz47b_vU.js} +1957 -1318
  18. package/dist/chunks/{paletteRegistry-B-oS4YxP.js → paletteRegistry-NrWOKT-A.js} +17 -17
  19. package/dist/chunks/{registry-DU-e49Y2.js → registry-CSba5QGJ.js} +1 -1
  20. package/dist/chunks/{scales-DvGid5Ln.js → scales-ulKMZPfG.js} +2206 -1357
  21. package/dist/custom-elements.json +1 -1
  22. package/dist/extend.js +26 -27
  23. package/dist/graphty-catalog.json +7 -4
  24. package/dist/graphty.bundle.js +36572 -34379
  25. package/dist/graphty.js +66 -64
  26. package/dist/index.d.ts +1 -1
  27. package/dist/logging.js +2 -2
  28. package/dist/schema.js +1 -1
  29. package/dist/session.d.ts +2 -1
  30. package/dist/session.js +37 -33
  31. package/dist/src/Edge.d.ts +1 -1
  32. package/dist/src/Graph.d.ts +42 -8
  33. package/dist/src/Node.d.ts +3 -4
  34. package/dist/src/acceleration/AccelerationController.d.ts +27 -0
  35. package/dist/src/acceleration/index.d.ts +1 -1
  36. package/dist/src/acceleration/narrow.d.ts +56 -0
  37. package/dist/src/acceleration/types.d.ts +88 -7
  38. package/dist/src/algorithms/Algorithm.d.ts +96 -2
  39. package/dist/src/algorithms/BFSAlgorithm.d.ts +9 -0
  40. package/dist/src/algorithms/DijkstraAlgorithm.d.ts +2 -8
  41. package/dist/src/algorithms/PageRankAlgorithm.d.ts +8 -0
  42. package/dist/src/algorithms/utils/graphUtils.d.ts +13 -0
  43. package/dist/src/cameras/OrbitCameraController.d.ts +1 -0
  44. package/dist/src/catalog/layouts.d.ts +13 -1
  45. package/dist/src/config/GraphBehavior.d.ts +16 -0
  46. package/dist/src/config/GraphStyle.d.ts +1 -1
  47. package/dist/src/config/StyleTemplate.d.ts +10 -0
  48. package/dist/src/data/CSVDataSource.d.ts +1 -0
  49. package/dist/src/data/csv-variant-detection.d.ts +11 -0
  50. package/dist/src/errors/codes.d.ts +14 -1
  51. package/dist/src/events.d.ts +17 -4
  52. package/dist/src/graphty-element.d.ts +52 -4
  53. package/dist/src/layout/ForceAtlas2LayoutEngine.d.ts +28 -45
  54. package/dist/src/layout/LayoutEngine.d.ts +7 -7
  55. package/dist/src/layout/SimulationLayoutEngine.d.ts +458 -0
  56. package/dist/src/layout/SpringElectricalLayoutEngine.d.ts +32 -0
  57. package/dist/src/layout/SpringLayoutEngine.d.ts +22 -32
  58. package/dist/src/managers/DataManager.d.ts +2 -0
  59. package/dist/src/managers/EventManager.d.ts +7 -0
  60. package/dist/src/managers/GraphContext.d.ts +6 -0
  61. package/dist/src/managers/LabelDeclutter.d.ts +97 -0
  62. package/dist/src/managers/LayoutManager.d.ts +98 -4
  63. package/dist/src/managers/RenderManager.d.ts +7 -0
  64. package/dist/src/managers/UpdateManager.d.ts +1 -1
  65. package/dist/src/meshes/NodeEffects.d.ts +29 -5
  66. package/dist/src/meshes/RichTextLabel.d.ts +17 -0
  67. package/dist/src/session/catalog.d.ts +2 -2
  68. package/dist/src/session/query.d.ts +83 -0
  69. package/dist/src/session/runs/types.d.ts +10 -4
  70. package/dist/src/session/selection/targets.d.ts +20 -3
  71. package/dist/src/session/styles/StylesApi.d.ts +18 -0
  72. package/dist/src/session/styles/channels.d.ts +0 -2
  73. package/dist/src/session/styles/legend.d.ts +9 -0
  74. package/dist/src/session/styles/predicate.d.ts +11 -0
  75. package/dist/src/session/styles/sources.d.ts +16 -0
  76. package/dist/src/session/types.d.ts +38 -2
  77. package/dist/src/testing/fakeAccelerator.d.ts +323 -0
  78. package/dist/webgpu.d.ts +23 -1
  79. package/dist/webgpu.js +70 -32
  80. package/package.json +10 -8
  81. package/dist/chunks/types-Dwm9waL2.js +0 -7
@@ -122,7 +122,7 @@ export declare class Graphty extends LitElement {
122
122
  * properties can be used in style selectors and accessed via `node.data`.
123
123
  * @since 1.0.0
124
124
  * @see {@link edgeData} for edge data
125
- * @see {@link https://graphty.app/storybook/element/?path=/story/graphty--default | Basic Examples}
125
+ * @see {@link https://graphty.app/storybook/graphty-element/?path=/story/graphty--graphty | Basic Examples}
126
126
  * @example HTML attribute (JSON string)
127
127
  * ```html
128
128
  * <graphty-element
@@ -388,7 +388,7 @@ export declare class Graphty extends LitElement {
388
388
  * - `fixed`: Pre-defined positions from node data
389
389
  * @since 1.0.0
390
390
  * @see {@link layoutConfig} for layout-specific options
391
- * @see {@link https://graphty.app/storybook/element/?path=/story/layout--default | Layout Examples}
391
+ * @see {@link https://graphty.app/storybook/graphty-element/?path=/story/layout-3d--circular | Layout Examples}
392
392
  * @example
393
393
  * ```typescript
394
394
  * // Set force-directed layout
@@ -425,13 +425,16 @@ export declare class Graphty extends LitElement {
425
425
  * unstepped force layout is a graph in mid-flight, and how far it has flown depends on when
426
426
  * the picture was taken. `layout.stepMultiplier`, `layout.minDelta` and
427
427
  * `layout.zoomStepInterval` pace the rest of it, and `node.pinOnDrag` decides whether a node
428
- * a reader drags stays where they put it.
428
+ * a reader drags stays where they put it. `labels.declutter` (off by default) hides a node
429
+ * label whose words would be drawn over another label's, keeping a selected node's label
430
+ * first and then the label of the node with more edges; it takes effect on the next frame.
429
431
  *
430
432
  * Merged over what is already set, so naming one field leaves the others alone.
431
433
  * @since 2.0.0
432
434
  * @example
433
435
  * ```typescript
434
436
  * element.layoutBehavior = { layout: { preSteps: 1000 } };
437
+ * element.layoutBehavior = { labels: { declutter: true } };
435
438
  * ```
436
439
  * @returns The behaviour settings, or undefined when none have been set on this element
437
440
  */
@@ -509,7 +512,7 @@ export declare class Graphty extends LitElement {
509
512
  *
510
513
  * VR and AR modes require WebXR support in the browser.
511
514
  * @since 1.0.0
512
- * @see {@link https://graphty.app/storybook/element/?path=/story/viewmode--default | View Mode Examples}
515
+ * @see {@link https://graphty.app/storybook/graphty-element/?path=/story/viewmode--switch-view-modes | View Mode Examples}
513
516
  * @example
514
517
  * ```typescript
515
518
  * element.viewMode = "2d"; // Switch to 2D orthographic view
@@ -1526,6 +1529,27 @@ export declare class Graphty extends LitElement {
1526
1529
  * ```
1527
1530
  */
1528
1531
  isRunning(): boolean;
1532
+ /**
1533
+ * Play or pause the layout.
1534
+ *
1535
+ * `setRunning(true)` on a layout that has already settled restarts it, so "play" is
1536
+ * something the reader can see; `setRunning(false)` stops the per-frame stepping and nothing
1537
+ * else -- work already handed to an accelerator lands, the scene keeps rendering, and the
1538
+ * camera, picking and styling stay live. There is no event for this: `isRunning()` reports
1539
+ * the state and `graph-settled` reports the arrangement coming to rest.
1540
+ *
1541
+ * A pause is not a mode the element remembers: anything that (re)starts a layout -- loading
1542
+ * more nodes, an accelerator attaching, setting another layout, dropping a dragged node --
1543
+ * runs it again, so pause it after those, not before.
1544
+ * @param running - True to run the layout, false to pause it.
1545
+ * @since 2.0.0
1546
+ * @example
1547
+ * ```typescript
1548
+ * element.setRunning(false); // pause
1549
+ * element.setRunning(true); // play again, from where it stopped
1550
+ * ```
1551
+ */
1552
+ setRunning(running: boolean): void;
1529
1553
  /**
1530
1554
  * Convert world coordinates to screen coordinates.
1531
1555
  * @param worldPos - Position in world space
@@ -1870,6 +1894,30 @@ export declare class Graphty extends LitElement {
1870
1894
  * healthy.
1871
1895
  */
1872
1896
  set acceleration(value: AccelerationPolicy);
1897
+ /**
1898
+ * The node count at or above which accelerated work uses the accelerator.
1899
+ *
1900
+ * Below it the element takes the CPU path even with an accelerator attached, and
1901
+ * `capabilities.acceleration.state` reads `"idle"`. Default 0: use the accelerator whenever
1902
+ * there is one. Raise it when the graphs you show are small enough that uploading costs more
1903
+ * than computing; the number is machine-specific, which is why the element does not guess.
1904
+ * @since 2.0.0
1905
+ * @example
1906
+ * ```html
1907
+ * <graphty-element acceleration-min-nodes="5000"></graphty-element>
1908
+ * ```
1909
+ * @returns The threshold in force.
1910
+ */
1911
+ get accelerationMinNodes(): number;
1912
+ /**
1913
+ * Sets the threshold and applies it immediately.
1914
+ *
1915
+ * A value that is not a whole number of 0 or more is reported and then ignored, leaving the
1916
+ * previous threshold in force, for the reason the `acceleration` setter states: Lit drives
1917
+ * this from `attributeChangedCallback`, and a throw there would leave the element unrendered.
1918
+ * @param value - The node count at or above which accelerated work uses the accelerator.
1919
+ */
1920
+ set accelerationMinNodes(value: number);
1873
1921
  }
1874
1922
  export type GraphtyElement = Graphty;
1875
1923
  declare global {
@@ -1,56 +1,39 @@
1
- import { z } from "zod/v4";
1
+ /**
2
+ * @file The ForceAtlas2 layout: the Gephi arrangement, computed on the CPU or on an accelerator.
3
+ *
4
+ * It used to be a one-shot pass -- run `forceatlas2Layout` over a node and edge list, publish the
5
+ * answer, stop -- which is why the catalogue called it a batch layout. It is now a steppable
6
+ * simulation from `@graphty/layout`, so it keeps running until the arrangement settles and reheats
7
+ * on a drag or a pin, and the element decides at every load whether the simulation is the CPU's or
8
+ * the accelerator's.
9
+ */
10
+ import type { SimulationType } from "@graphty/layout";
2
11
  import { type OptionsSchema } from "../config";
3
- import { SimpleLayoutEngine } from "./LayoutEngine";
4
- declare const ForceAtlas2LayoutConfig: z.ZodObject<{
5
- pos: z.ZodDefault<z.ZodUnion<[z.ZodRecord<z.ZodNumber, z.ZodArray<z.ZodNumber>>, z.ZodNull]>>;
6
- maxIter: z.ZodDefault<z.ZodNumber>;
7
- jitterTolerance: z.ZodDefault<z.ZodNumber>;
8
- scalingRatio: z.ZodDefault<z.ZodNumber>;
9
- gravity: z.ZodDefault<z.ZodNumber>;
10
- distributedAction: z.ZodDefault<z.ZodBoolean>;
11
- strongGravity: z.ZodDefault<z.ZodBoolean>;
12
- nodeMass: z.ZodDefault<z.ZodUnion<[z.ZodRecord<z.ZodNumber, z.ZodNumber>, z.ZodNull]>>;
13
- nodeSize: z.ZodDefault<z.ZodUnion<[z.ZodRecord<z.ZodNumber, z.ZodNumber>, z.ZodNull]>>;
14
- weighted: z.ZodDefault<z.ZodBoolean>;
15
- dissuadeHubs: z.ZodDefault<z.ZodBoolean>;
16
- linlog: z.ZodDefault<z.ZodBoolean>;
17
- seed: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodNull]>>;
18
- dim: z.ZodDefault<z.ZodNumber>;
19
- scalingFactor: z.ZodDefault<z.ZodNumber>;
20
- }, z.core.$strict>;
21
- type ForceAtlas2LayoutConfigType = z.infer<typeof ForceAtlas2LayoutConfig>;
22
- type ForceAtlas2LayoutOpts = Partial<ForceAtlas2LayoutConfigType>;
12
+ import { SimulationLayoutEngine } from "./SimulationLayoutEngine";
23
13
  /**
24
- * ForceAtlas2 layout engine for graph visualization with scaling and gravity options
14
+ * The ForceAtlas2 engine, as the element declares it.
15
+ *
16
+ * Every member is a static the element reads: `LayoutManager` builds the bridge itself, with the
17
+ * graph's acceleration controller, so this class never runs a layout of its own. It declares no
18
+ * `static descriptor` because its arrangement is authored in the layout catalogue, where it sits
19
+ * under `force`.
25
20
  */
26
- export declare class ForceAtlas2Layout extends SimpleLayoutEngine {
21
+ export declare class ForceAtlas2Layout extends SimulationLayoutEngine {
27
22
  static type: string;
23
+ static simulationType: SimulationType;
28
24
  static maxDimensions: number;
29
- static honoursWeights: boolean;
30
- static zodOptionsSchema: OptionsSchema;
31
- scalingFactor: number;
32
- config: ForceAtlas2LayoutConfigType;
33
25
  /**
34
- * Create a ForceAtlas2 layout engine
35
- * @param opts - Configuration options for the ForceAtlas2 algorithm
26
+ * A WEIGHT IS AN ATTRACTION STRENGTH HERE, and is passed through as it is stored: a heavier
27
+ * edge pulls its two nodes closer, which is what a weight means everywhere else in the
28
+ * element. Kamada-Kawai reads the very same number as a distance and therefore inverts it; the
29
+ * two engines disagree about the arithmetic so that they agree about the meaning.
36
30
  */
37
- constructor(opts: ForceAtlas2LayoutOpts);
31
+ static honoursWeights: boolean;
32
+ static zodOptionsSchema: OptionsSchema;
38
33
  /**
39
- * Get dimension-specific options for ForceAtlas2 layout
40
- * @param dimension - The desired dimension (2 or 3)
41
- * @returns Options object with dim parameter
34
+ * Get dimension-specific options for ForceAtlas2 layout.
35
+ * @param dimension - The desired dimension (2 or 3).
36
+ * @returns Options object with dim parameter.
42
37
  */
43
38
  static getOptionsForDimension(dimension: 2 | 3): object;
44
- /**
45
- * Compute node positions using the ForceAtlas2 algorithm
46
- *
47
- * A WEIGHT IS PASSED THROUGH AS IT IS STORED. ForceAtlas2 reads a weight as an attraction
48
- * STRENGTH -- it becomes the adjacency matrix entry the attraction force is scaled by -- which
49
- * is already what a weight means everywhere else in the element, so a heavier edge pulls its
50
- * two nodes closer and nothing has to be inverted. Kamada-Kawai reads the very same number as
51
- * a distance and therefore does invert it; the two engines disagree about the arithmetic so
52
- * that they agree about the meaning.
53
- */
54
- doLayout(): void;
55
39
  }
56
- export {};
@@ -48,15 +48,15 @@ export interface LayoutEngineStatics {
48
48
  /**
49
49
  * Whether this engine arranges a graph differently when its edges carry weights.
50
50
  *
51
- * Optional, and false for all but two of the element's own sixteen. It exists so that a
51
+ * Optional, and false for all but two of the element's own seventeen. It exists so that a
52
52
  * picker can tell a reader which arrangements the `weighted` option actually does something
53
- * for, instead of offering it on fourteen layouts that ignore it.
53
+ * for, instead of offering it on fifteen layouts that ignore it.
54
54
  */
55
55
  honoursWeights?: boolean;
56
56
  /**
57
57
  * What the catalogue publishes about this layout, so a picker can offer it.
58
58
  *
59
- * REQUIRED OF A THIRD PARTY'S ENGINE and absent from the element's own sixteen, whose
59
+ * REQUIRED OF A THIRD PARTY'S ENGINE and absent from the element's own seventeen, whose
60
60
  * arrangements are authored in `src/catalog/layouts.ts` instead. `descriptor.id` must equal
61
61
  * {@link LayoutEngineStatics.type}: one key, so nothing is named twice and `layoutIdForEngine`
62
62
  * can answer a plugin's own id.
@@ -94,7 +94,7 @@ export declare abstract class LayoutEngine {
94
94
  * Whether this engine reads edge weights. See {@link LayoutEngineStatics.honoursWeights}.
95
95
  *
96
96
  * False here because most layouts have no weight channel at all: of the element's own
97
- * sixteen, only Kamada-Kawai and ForceAtlas2 can read one, and the other fourteen would be
97
+ * seventeen, only Kamada-Kawai and ForceAtlas2 can read one, and the other fifteen would be
98
98
  * advertising a control that changes nothing.
99
99
  */
100
100
  static honoursWeights: boolean;
@@ -162,7 +162,7 @@ export declare abstract class LayoutEngine {
162
162
  * Take a node out of the layout, before the element disposes the mesh that drew it.
163
163
  *
164
164
  * Declared here, with a default that does nothing, because it used to be duck-typed by the
165
- * element's data manager and implemented by none of the sixteen engines that ship here: an
165
+ * element's data manager and implemented by none of the seventeen engines that ship here: an
166
166
  * author learned it existed by reading the element's source, and got no worked example. An
167
167
  * engine that keeps its own node list must override this, or it holds every removed node --
168
168
  * and everything that node references -- for as long as the engine lives.
@@ -260,7 +260,7 @@ export declare abstract class LayoutEngine {
260
260
  * freeze counts as placed, which is what makes a file's own coordinates yield to it.
261
261
  *
262
262
  * A PINNED ROW REFUSES A LAYOUT STEP. This is the whole of "a pin is meaningful under every
263
- * arrangement": fourteen of the element's sixteen engines implement `pin()` as a no-op and
263
+ * arrangement": twelve of the element's seventeen engines implement `pin()` as a no-op and
264
264
  * `setNodePosition` as a no-op too, so before this guard a reader who dragged a node under a
265
265
  * static layout watched it snap back the next time the layout recomputed. One refusal here
266
266
  * covers every engine, including one written by a third party that has never heard of pinning,
@@ -351,7 +351,7 @@ export declare abstract class LayoutEngine {
351
351
  * offered by a picker, described in a reader's language, or found by `layoutIdForEngine`.
352
352
  *
353
353
  * A third party's class must declare a `static descriptor` whose `id` equals its
354
- * `static type`. The element's own sixteen are the one exemption, because their arrangements
354
+ * `static type`. The element's own seventeen are the one exemption, because their arrangements
355
355
  * are authored centrally in the layout catalogue where several engines may sit behind one
356
356
  * public name.
357
357
  * @param cls - The layout engine class.