Skip to content

packages/core/src/features/viz/lib/graph/force.tsx

Read as Markdown

This is the source snapshot used to build these API details. View this revision on GitHub.

Back to reference

1 import type { PibblNode } from "@pibbl/core";
2 import {
3   Group,
4   computed,
5   drive,
6   resolveSignalValue,
7   signal,
8   stepper,
9   useConst,
10   usePlayback,
11   useReaction,
12   untracked,
13 } from "@pibbl/core";
14 import type {
15   GraphData,
16   ForceOptions,
17   ForceLayout,
18   ForceSimulation,
19   ForceNetworkController,
20   ForceHookOptions,
21   ForceNetworkProps,
22   Point,
23   VizKey,
24 } from "./types.js";
25 import { graphRecords, nodeSize } from "./dependency.js";
26 import {
27   graphNodeGeometry,
28   readAccessor,
29   validateBounds,
30   useGraphFrame,
31   GraphView,
32 } from "./shared.js";
33 import { straightGraphRoute, routePath } from "./routes.js";
34 type Particle<N> = {
35   key: VizKey;
36   datum: N;
37   x: number;
38   y: number;
39   vx: number;
40   vy: number;
41   width: number;
42   height: number;
43   label: string;
44   detail?: string;
45 };
46 function configuration<N, E>(
47   graph: GraphData<N, E>,
48   options: ForceOptions<N, E>,
49 ) {
50   const bounds = validateBounds(options.bounds),
51     records = graphRecords(graph, options);
52   const settings = {
53     seed: options.simulation?.seed ?? 1,
54     linkDistance: options.simulation?.linkDistance ?? 90,
55     nodeGap: options.simulation?.nodeGap ?? 8,
56     maxIterations: options.simulation?.maxIterations ?? 300,
57   };
58   if (
59     !Number.isSafeInteger(settings.seed) ||
60     !Number.isSafeInteger(settings.maxIterations) ||
61     settings.maxIterations < 0
62   )
63     throw new RangeError(
64       "Force seed must be a safe integer; maxIterations must be a nonnegative safe integer.",
65     );
66   if (
67     !Number.isFinite(settings.linkDistance) ||
68     settings.linkDistance <= 0 ||
69     !Number.isFinite(settings.nodeGap) ||
70     settings.nodeGap < 0
71   )
72     throw new RangeError(
73       "Force distances must be finite; linkDistance positive and nodeGap nonnegative.",
74     );
75   const nodes = [...records.nodes].map(([key, datum]) => ({
76     key,
77     datum,
78     ...nodeSize(datum, options.nodeSize, { width: 40, height: 40 }),
79     label: options.label ? readAccessor(datum, options.label) : String(key),
80     detail: options.detail ? readAccessor(datum, options.detail) : undefined,
81   }));
82   if (
83     bounds.width > 0 &&
84     bounds.height > 0 &&
85     nodes.some((n) => n.width > bounds.width || n.height > bounds.height)
86   )
87     throw new RangeError("Force node exceeds layout bounds.");
88   return {
89     bounds,
90     settings,
91     nodes,
92     edges: records.edges,
93     directed: options.directed ?? true,
94   };
95 }
96 /** Create a deterministic, manually stepped numeric solver without resources or scheduling.
97  * Uses inverse-square repulsion, Hooke link relaxation, damping, box collisions and bounded iterations.
98  * @param graph - Original records. See {@link GraphData}.
99  * @param options - Accessors, bounds and seed. See {@link ForceOptions}.
100  * @returns Numeric session whose snapshots can be rendered or advanced by any public driver. See {@link ForceSimulation}.
101  */
102 export function createForceSimulation<N, E>(
103   graph: GraphData<N, E>,
104   options: ForceOptions<N, E>,
105 ): ForceSimulation<N, E> {
106   let config = configuration(graph, options),
107     iterations = 0,
108     settled = false,
109     particles: Particle<N>[] = [],
110     pins = new Map<VizKey, Point>();
111   let stableSteps = 0;
112   const seedParticles = () => {
113     let seed = config.settings.seed >>> 0;
114     const random = () => {
115       seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
116       return seed / 4294967296;
117     };
118     return config.nodes.map((node) => ({
119       ...node,
120       x:
121         config.bounds.x +
122         node.width / 2 +
123         random() * Math.max(0, config.bounds.width - node.width),
124       y:
125         config.bounds.y +
126         node.height / 2 +
127         random() * Math.max(0, config.bounds.height - node.height),
128       vx: 0,
129       vy: 0,
130     }));
131   };
132   particles = seedParticles();
133   const read = (): ForceLayout<N, E> => {
134     const { bounds } = config;
135     if (!bounds.width || !bounds.height)
136       return { bounds, nodes: [], edges: [], iterations, settled };
137     const nodes = particles.map((p) => {
138       const box = {
139         x: p.x - p.width / 2,
140         y: p.y - p.height / 2,
141         width: p.width,
142         height: p.height,
143       };
144       const node = graphNodeGeometry(p.datum, p.key, box, p.label, p.detail);
145       return {
146         ...node,
147         label: {
148           text: p.label,
149           bounds: {
150             x: p.x - 80,
151             y: p.y + p.height / 2 + 6,
152             width: 160,
153             height: 18,
154           },
155           rotationDegrees: 0,
156         },
157       };
158     });
159     const byKey = new Map(particles.map((p) => [p.key, p]));
160     const edges = config.edges.map((edge) => {
161       const a = byKey.get(edge.sourceKey)!,
162         b = byKey.get(edge.targetKey)!;
163       const dx = b.x - a.x,
164         dy = b.y - a.y;
165       const boundary = (p: Particle<N>, x: number, y: number) => {
166         const t = Math.min(
167           x === 0 ? Infinity : p.width / 2 / Math.abs(x),
168           y === 0 ? Infinity : p.height / 2 / Math.abs(y),
169         );
170         return {
171           x: p.x + x * (Number.isFinite(t) ? t : 0),
172           y: p.y + y * (Number.isFinite(t) ? t : 0),
173         };
174       };
175       const route = straightGraphRoute(
176         {
177           sourceAnchor: boundary(a, dx, dy),
178           targetAnchor: boundary(b, -dx, -dy),
179         },
180         { arrowLength: config.directed ? 6 : 0 },
181       );
182       return {
183         ...edge,
184         route,
185         path: forcePath(route.segments),
186         arrowPath: route.arrowSegments ? routePath(route.arrowSegments) : null,
187       };
188     });
189     return { bounds, nodes, edges, iterations, settled };
190   };
191   return {
192     read,
193     step({ iterations: count }) {
194       if (!Number.isSafeInteger(count) || count < 0)
195         throw new RangeError(
196           "Force step iterations must be a nonnegative safe integer.",
197         );
198       if (!config.bounds.width || !config.bounds.height) return read();
199       for (
200         let n = 0;
201         n < count && iterations < config.settings.maxIterations && !settled;
202         n++, iterations++
203       ) {
204         const forces = particles.map((p) => ({
205           x: (config.bounds.x + config.bounds.width / 2 - p.x) * 0.002,
206           y: (config.bounds.y + config.bounds.height / 2 - p.y) * 0.002,
207         }));
208         for (let i = 0; i < particles.length; i++)
209           for (let j = i + 1; j < particles.length; j++) {
210             const a = particles[i],
211               b = particles[j];
212             let dx = b.x - a.x,
213               dy = b.y - a.y;
214             if (Math.abs(dx) + Math.abs(dy) < 0.01) {
215               dx = 0.1;
216               dy = 0.1;
217             }
218             const distance = Math.hypot(dx, dy),
219               repulsion = 4500 / Math.max(25, distance * distance);
220             const overlapX =
221                 (a.width + b.width) / 2 +
222                 config.settings.nodeGap -
223                 Math.abs(dx),
224               overlapY =
225                 (a.height + b.height) / 2 +
226                 config.settings.nodeGap -
227                 Math.abs(dy);
228             let fx = (dx / distance) * repulsion,
229               fy = (dy / distance) * repulsion;
230             if (overlapX > 0 && overlapY > 0) {
231               if (overlapX < overlapY)
232                 fx += Math.sign(dx || 1) * overlapX * 0.12;
233               else fy += Math.sign(dy || 1) * overlapY * 0.12;
234             }
235             forces[i].x -= fx;
236             forces[i].y -= fy;
237             forces[j].x += fx;
238             forces[j].y += fy;
239           }
240         const indices = new Map(particles.map((p, i) => [p.key, i]));
241         for (const edge of config.edges) {
242           const i = indices.get(edge.sourceKey)!,
243             j = indices.get(edge.targetKey)!,
244             a = particles[i],
245             b = particles[j];
246           const dx = b.x - a.x,
247             dy = b.y - a.y,
248             length = Math.hypot(dx, dy) || 1,
249             pull = (length - config.settings.linkDistance) * 0.025;
250           const x = (dx / length) * pull,
251             y = (dy / length) * pull;
252           forces[i].x += x;
253           forces[i].y += y;
254           forces[j].x -= x;
255           forces[j].y -= y;
256         }
257         let movement = 0;
258         particles = particles.map((p, i) => {
259           const pin = pins.get(p.key);
260           if (pin) return { ...p, ...pin, vx: 0, vy: 0 };
261           const vx = Math.max(-8, Math.min(8, (p.vx + forces[i].x) * 0.78)),
262             vy = Math.max(-8, Math.min(8, (p.vy + forces[i].y) * 0.78));
263           movement = Math.max(movement, Math.abs(vx) + Math.abs(vy));
264           return {
265             ...p,
266             vx,
267             vy,
268             x: Math.max(
269               config.bounds.x + p.width / 2,
270               Math.min(
271                 config.bounds.x + config.bounds.width - p.width / 2,
272                 p.x + vx,
273               ),
274             ),
275             y: Math.max(
276               config.bounds.y + p.height / 2,
277               Math.min(
278                 config.bounds.y + config.bounds.height - p.height / 2,
279                 p.y + vy,
280               ),
281             ),
282           };
283         });
284         stableSteps = movement < 0.02 ? stableSteps + 1 : 0;
285         settled = stableSteps >= 8;
286       }
287       return read();
288     },
289     update(nextGraph, nextOptions) {
290       const next = configuration(nextGraph, nextOptions); // Validate before changing owned state.
291       const old = new Map(particles.map((p) => [p.key, p]));
292       config = next;
293       particles = seedParticles().map((p) => {
294         const previous = old.get(p.key);
295         return previous
296           ? {
297               ...p,
298               x: Math.max(
299                 config.bounds.x + p.width / 2,
300                 Math.min(
301                   config.bounds.x + config.bounds.width - p.width / 2,
302                   previous.x,
303                 ),
304               ),
305               y: Math.max(
306                 config.bounds.y + p.height / 2,
307                 Math.min(
308                   config.bounds.y + config.bounds.height - p.height / 2,
309                   previous.y,
310                 ),
311               ),
312               vx: previous.vx,
313               vy: previous.vy,
314             }
315           : p;
316       });
317       pins = new Map(
318         [...pins].filter(
319           ([key]) => old.has(key) && config.nodes.some((n) => n.key === key),
320         ),
321       );
322       iterations = 0;
323       stableSteps = 0;
324       settled = false;
325     },
326     restart() {
327       iterations = 0;
328       stableSteps = 0;
329       settled = false;
330     },
331     reset() {
332       pins.clear();
333       particles = seedParticles();
334       iterations = 0;
335       stableSteps = 0;
336       settled = false;
337     },
338     pin(key, position) {
339       if (!particles.some((p) => p.key === key))
340         throw new Error(`Unknown force node ${key}.`);
341       if (!Number.isFinite(position.x) || !Number.isFinite(position.y))
342         throw new RangeError("Pin coordinates must be finite.");
343       pins.set(key, { ...position });
344       particles = particles.map((p) =>
345         p.key === key ? { ...p, ...position, vx: 0, vy: 0 } : p,
346       );
347       settled = false;
348       stableSteps = 0;
349     },
350     release(key) {
351       if (!particles.some((p) => p.key === key))
352         throw new Error(`Unknown force node ${key}.`);
353       pins.delete(key);
354       settled = false;
355       stableSteps = 0;
356     },
357   };
358 }
359 /**
360  * Solve a seeded force layout synchronously, bounded by maxIterations. No timers or resources are allocated.
361  * @param graph - Original node and edge records. See {@link GraphData}.
362  * @param options - Accessors, finite bounds and numeric settings. See {@link ForceOptions}.
363  * @returns A bounded result which may remain unsettled on exhaustion. See {@link ForceLayout}.
364  */
365 export function layoutForceNetwork<N, E>(
366   graph: GraphData<N, E>,
367   options: ForceOptions<N, E>,
368 ): ForceLayout<N, E> {
369   const session = createForceSimulation(graph, options);
370   return session.step({ iterations: options.simulation?.maxIterations ?? 300 });
371 }
372 
373 // Interpolate immutable presentation geometry between fixed-rate solver snapshots.
374 // The numeric solver stays deterministic while 120/144 Hz displays get fresh poses.
375 function interpolateForceLayout<N, E>(
376   previous: ForceLayout<N, E>,
377   current: ForceLayout<N, E>,
378   amount: number,
379 ): ForceLayout<N, E> {
380   if (previous === current) return current;
381   if (amount === 0)
382     return { ...current, nodes: previous.nodes, edges: previous.edges };
383   const numbers = <T extends object>(a: T, b: T): T => {
384     const result = { ...b };
385     for (const key in b) {
386       const before = a[key],
387         after = b[key];
388       if (typeof before === "number" && typeof after === "number")
389         result[key] = (before + (after - before) * amount) as T[typeof key];
390     }
391     return result;
392   };
393   const rotation = (a: number, b: number) => a + (b - a) * amount;
394   const oldNodes = new Map(previous.nodes.map((node) => [node.key, node]));
395   const oldEdges = new Map(previous.edges.map((edge) => [edge.key, edge]));
396   return {
397     ...current,
398     nodes: current.nodes.map((node) => {
399       const old = oldNodes.get(node.key);
400       if (!old) return node;
401       return {
402         ...node,
403         bounds: numbers(old.bounds, node.bounds),
404         label: {
405           ...node.label,
406           bounds: numbers(old.label.bounds, node.label.bounds),
407           rotationDegrees: rotation(
408             old.label.rotationDegrees,
409             node.label.rotationDegrees,
410           ),
411         },
412         detail:
413           old.detail && node.detail
414             ? {
415                 ...node.detail,
416                 bounds: numbers(old.detail.bounds, node.detail.bounds),
417                 rotationDegrees: rotation(
418                   old.detail.rotationDegrees,
419                   node.detail.rotationDegrees,
420                 ),
421               }
422             : node.detail,
423       };
424     }),
425     edges: current.edges.map((edge) => {
426       const old = oldEdges.get(edge.key);
427       if (!old) return edge;
428       const segments = (
429         a: typeof edge.route.segments,
430         b: typeof edge.route.segments,
431       ) =>
432         b.map((segment, index) =>
433           a[index]?.type === segment.type
434             ? numbers(a[index], segment)
435             : segment,
436         );
437       const route = {
438         sourceAnchor: numbers(old.route.sourceAnchor, edge.route.sourceAnchor),
439         targetAnchor: numbers(old.route.targetAnchor, edge.route.targetAnchor),
440         segments: segments(old.route.segments, edge.route.segments),
441         arrowSegments:
442           old.route.arrowSegments && edge.route.arrowSegments
443             ? segments(old.route.arrowSegments, edge.route.arrowSegments)
444             : edge.route.arrowSegments,
445       };
446       return {
447         ...edge,
448         route,
449         path: forcePath(route.segments),
450         arrowPath: route.arrowSegments ? forcePath(route.arrowSegments) : null,
451       };
452     }),
453   };
454 }
455 function forcePath(segments: Parameters<typeof routePath>[0]): string {
456   if (
457     segments.length === 2 &&
458     segments[0].type === "move" &&
459     segments[1].type === "line"
460   )
461     return `M ${segments[0].x} ${segments[0].y} L ${segments[1].x} ${segments[1].y}`;
462   return routePath(segments);
463 }
464 
465 /** Own a force session through public stepper, drive, usePlayback and signals.
466  * @param graph - Graph input or signal; accessors are snapshotted during component evaluation. See {@link GraphData}.
467  * @param options - Geometry and optional resource-free numeric solver factory. See {@link ForceHookOptions}.
468  * @returns Readonly snapshots and commands; playback is released on unmount. See {@link ForceNetworkController}.
469  */
470 export function useForceNetwork<N, E>(
471   graph: import("@pibbl/core").SignalValue<GraphData<N, E>>,
472   options: ForceHookOptions<N, E>,
473 ): ForceNetworkController<N, E> {
474   const input = resolveSignalValue(graph);
475   // Capture all application callbacks now, outside Advance. The numeric session sees plain admitted values.
476   let inputError: Error | null = null;
477   let prepared: ReturnType<typeof configuration<N, E>>;
478   try {
479     prepared = configuration(input, options);
480   } catch (error) {
481     inputError = error instanceof Error ? error : new Error(String(error));
482     prepared = configuration(
483       { nodes: [], edges: [] },
484       {
485         ...options,
486         simulation: {},
487         bounds: { x: 0, y: 0, width: 0, height: 0 },
488       },
489     );
490   }
491   const nodeMetadata = new Map(
492     prepared.nodes.map((node) => [node.datum, node]),
493   );
494   const edgeMetadata = new Map(
495     prepared.edges.map((edge) => [edge.datum, edge]),
496   );
497   const snapshotOptions: ForceOptions<N, E> = {
498     bounds: { ...prepared.bounds },
499     simulation: { ...prepared.settings },
500     directed: prepared.directed,
501     nodeKey: (node) => nodeMetadata.get(node)!.key,
502     edgeKey: (edge) => edgeMetadata.get(edge)!.key,
503     source: (edge) => edgeMetadata.get(edge)!.sourceKey,
504     target: (edge) => edgeMetadata.get(edge)!.targetKey,
505     nodeSize: (node) => nodeMetadata.get(node)!,
506     label: (node) => nodeMetadata.get(node)!.label,
507     detail: options.detail
508       ? (node) => nodeMetadata.get(node)!.detail!
509       : undefined,
510   };
511   const snapshotGraph = {
512     nodes: inputError ? [] : [...input.nodes],
513     edges: inputError ? [] : [...input.edges],
514   };
515   const signature = JSON.stringify([
516     prepared.bounds,
517     prepared.settings,
518     prepared.directed,
519     prepared.nodes.map(({ datum: _datum, ...metadata }) => metadata),
520     prepared.edges.map(({ datum: _datum, ...metadata }) => metadata),
521   ]);
522   type Status = "running" | "paused" | "settled" | "exhausted" | "failed";
523   type Frame = {
524     layout: ForceLayout<N, E>;
525     status: Status;
526     error: Error | null;
527   };
528   const owner = useConst(() => {
529     const factory = options.createSimulation ?? createForceSimulation;
530     const session = factory(snapshotGraph, snapshotOptions);
531     const output = signal<Frame>({
532       layout: session.read(),
533       status: options.initialPaused ? "paused" : "running",
534       error: null,
535     });
536     return {
537       factory,
538       session,
539       previous: output.get().layout,
540       current: output.get(),
541       phase: 0,
542       output,
543       disposed: false,
544       pending: [] as (() => void)[],
545       paused: options.initialPaused ?? false,
546       signature,
547       graph: snapshotGraph,
548       options: snapshotOptions,
549     };
550   });
551   if (
552     options.createSimulation !== undefined &&
553     options.createSimulation !== owner.factory
554   )
555     throw new Error(
556       "Force createSimulation is fixed for a mounted hook; remount to replace it.",
557     );
558   const advance = (integrate: boolean): Frame => {
559     try {
560       const pending = owner.pending.splice(0);
561       if (!pending.length && owner.current.status === "failed")
562         return owner.current;
563       for (const command of pending) command();
564       if (pending.length) {
565         owner.current = { ...owner.current, layout: owner.session.read() };
566         owner.previous = owner.current.layout;
567       }
568       if (integrate && !owner.paused) {
569         owner.previous = owner.current.layout;
570         owner.current = {
571           ...owner.current,
572           layout: owner.session.step({ iterations: 1 }),
573         };
574       }
575       const layout = owner.current.layout;
576       const status: Status =
577         owner.paused || !layout.bounds.width || !layout.bounds.height
578           ? "paused"
579           : layout.settled
580             ? "settled"
581             : layout.iterations >=
582                 (owner.options.simulation?.maxIterations ?? 300)
583               ? "exhausted"
584               : "running";
585       owner.current = { layout, status, error: null };
586     } catch (error) {
587       owner.current = {
588         layout: owner.output.get().layout,
589         status: "failed",
590         error: error instanceof Error ? error : new Error(String(error)),
591       };
592     }
593     return owner.current;
594   };
595   const program = useConst(() =>
596     drive(
597       owner.output,
598       stepper<Frame, Frame>({
599         // Twelve presentation subdivisions divide common 60/120/144/240 Hz displays.
600         // This is scheduler sampling, not another animation loop or 720 solver ticks.
601         stepMilliseconds: 1000 / 720,
602         maxElapsedMilliseconds: 1000 / 30,
603         initial: () => {
604           owner.phase = 0;
605           return advance(false);
606         },
607         step: () => {
608           owner.phase = (owner.phase + 1) % 12;
609           return owner.phase === 0 || owner.pending.length
610             ? advance(owner.phase === 0)
611             : owner.current;
612         },
613         read: () => {
614           const frame = owner.pending.length ? advance(false) : owner.current;
615           return frame.status === "running"
616             ? {
617                 ...frame,
618                 layout: interpolateForceLayout(
619                   owner.previous,
620                   frame.layout,
621                   owner.phase / 12,
622                 ),
623               }
624             : frame;
625         },
626         done: (state) => state.status !== "running",
627       }),
628     ),
629   );
630   const playback = usePlayback(program, { autoplay: !options.initialPaused });
631   const queue = (command: () => void) => {
632     if (owner.disposed) return;
633     owner.pending.push(command);
634     const status = playback.status.get();
635     if (status !== "running" && status !== "scheduled")
636       playback.play({ conflict: "replace" });
637   };
638   useReaction(() => {
639     if (inputError) {
640       queue(() => {
641         throw inputError;
642       });
643       return;
644     }
645     if (
646       untracked(() => owner.output.get().status) === "failed" ||
647       owner.signature !== signature ||
648       owner.graph.nodes.some(
649         (datum, index) => datum !== snapshotGraph.nodes[index],
650       ) ||
651       owner.graph.edges.some(
652         (datum, index) => datum !== snapshotGraph.edges[index],
653       )
654     ) {
655       queue(() => {
656         owner.session.update(snapshotGraph, snapshotOptions);
657         owner.graph = snapshotGraph;
658         owner.options = snapshotOptions;
659         owner.signature = signature;
660       });
661     }
662   }, [signature, inputError?.message, ...input.nodes, ...input.edges]);
663   useReaction(
664     () => () => {
665       owner.disposed = true;
666       owner.pending.length = 0;
667     },
668     [],
669   );
670   return useConst(() => ({
671     layout: computed(() => owner.output.get().layout),
672     status: computed(() => owner.output.get().status),
673     error: computed(() => owner.output.get().error),
674     pause: () =>
675       queue(() => {
676         owner.paused = true;
677       }),
678     resume: () =>
679       queue(() => {
680         owner.paused = false;
681       }),
682     restart: () =>
683       queue(() => {
684         owner.session.restart();
685         owner.paused = false;
686       }),
687     reset: () =>
688       queue(() => {
689         owner.session.reset();
690         owner.paused = false;
691       }),
692     pin: (key: VizKey, point: Point) =>
693       queue(() => {
694         owner.session.pin(key, point);
695         owner.session.restart();
696       }),
697     release: (key: VizKey) =>
698       queue(() => {
699         owner.session.release(key);
700         owner.session.restart();
701       }),
702   }));
703 }
704 /**
705  * Own and render a live force network through the public hook and GraphView; unmount releases playback.
706  * @param props - Graph, definite frame, optional solver factory, controlled pause and presentation. See {@link ForceNetworkProps}.
707  * @returns A public-hook and public-marks composition. See {@link useForceNetwork}.
708  */
709 export function ForceNetwork<N, E>(props: ForceNetworkProps<N, E>): PibblNode {
710   const frame = useGraphFrame(props.style);
711   const paused = resolveSignalValue(props.paused) ?? false;
712   const network = useForceNetwork(props.graph, {
713     ...props,
714     bounds: frame.bounds,
715     initialPaused: paused,
716   });
717   useReaction(() => {
718     if (paused) network.pause();
719     else network.resume();
720   }, [paused]);
721   return (
722     <Group style={frame.groupStyle}>
723       <GraphView
724         {...props}
725         layout={network.layout}
726         style={undefined}
727         labelStyle={(node) => ({
728           textAlign: "center",
729           ...resolveSignalValue(
730             typeof props.labelStyle === "function"
731               ? props.labelStyle(node)
732               : props.labelStyle,
733           ),
734         })}
735         nodeStyle={(node) => ({
736           cornerRadius: 100,
737           ...resolveSignalValue(
738             typeof props.nodeStyle === "function"
739               ? props.nodeStyle(node)
740               : props.nodeStyle,
741           ),
742         })}
743       />
744     </Group>
745   );
746 }
747 

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.