@simplex-viz/react 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SimplexViz Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # @simplex-viz/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ End-to-end type-safe React bindings, declarative JSX node renderers, and imperative controller hooks for `@simplex-viz/core` and `@simplex-viz/svg`.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplex-viz/core @simplex-viz/svg @simplex-viz/react
9
+ ```
10
+
11
+ ## Quickstart
12
+
13
+ ```tsx
14
+ import { SimplexTopicGraph, useSimplexGraphController } from '@simplex-viz/react';
15
+
16
+ export function MyGraph({ items }: { items: readonly MyItem[] }) {
17
+ const { controllerRef, handle } = useSimplexGraphController<MyItem, MyContentVisual, MyClusterVisual>();
18
+
19
+ return (
20
+ <SimplexTopicGraph
21
+ controllerRef={controllerRef}
22
+ items={items}
23
+ getId={(item) => item.slug}
24
+ getTags={(item) => item.hashtags}
25
+ visualResolver={resolver}
26
+ renderContentNode={(item, ctx) => (
27
+ <g>
28
+ <circle r={10} fill={ctx.mixedColorHex} />
29
+ </g>
30
+ )}
31
+ renderClusterNode={(cluster) => (
32
+ <g>
33
+ <rect x={-50} y={-16} width={100} height={32} rx={6} fill="#0f172a" stroke={cluster.colorHex} />
34
+ <text textAnchor="middle" y={4} fill="#f8fafc">{cluster.code}</text>
35
+ </g>
36
+ )}
37
+ />
38
+ );
39
+ }
40
+ ```
@@ -0,0 +1,30 @@
1
+ import { type ClusterDescriptor, type ContentLayoutContext, type ConvexGeometry, type NodeRenderState } from '@simplex-viz/core';
2
+ import { type SvgNodeView } from '@simplex-viz/svg';
3
+ import type { ReactNode } from 'react';
4
+ export interface ContentDomainRecord<TItem, TTagMeta, TClusterMeta> {
5
+ readonly item: TItem;
6
+ readonly ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>;
7
+ }
8
+ /**
9
+ * Bridges a declarative React JSX render function into an `@simplex-viz/svg` `SvgNodeView`
10
+ * with automatic offscreen `getBBox()` convex hull measurement and cached DOM updates.
11
+ */
12
+ export declare class ReactJsxSvgView<TVisual, TDomain> implements SvgNodeView<TVisual> {
13
+ private readonly renderFn;
14
+ private readonly getKey;
15
+ private readonly domainByKey;
16
+ private readonly rootsByGroup;
17
+ private readonly activeRoots;
18
+ private measureGroup;
19
+ constructor(params: {
20
+ readonly renderFn: (domain: TDomain, state: NodeRenderState<TVisual>) => ReactNode;
21
+ readonly getKey: (visual: TVisual) => string;
22
+ readonly domainByKey: ReadonlyMap<string, TDomain>;
23
+ });
24
+ measureConvexHull(visual: TVisual, measureSvg: SVGSVGElement): ConvexGeometry;
25
+ mountOrUpdate(groupEl: SVGGElement, visual: TVisual, state: NodeRenderState<TVisual>): void;
26
+ dispose(): void;
27
+ }
28
+ export type ContentJsxRenderFn<TItem, TContentVisual, TTagMeta, TClusterMeta> = (item: TItem, ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>, state: NodeRenderState<TContentVisual>) => ReactNode;
29
+ export type ClusterJsxRenderFn<TItem, TClusterVisual, TTagMeta, TClusterMeta> = (cluster: ClusterDescriptor<TItem, TTagMeta, TClusterMeta>, state: NodeRenderState<TClusterVisual>) => ReactNode;
30
+ //# sourceMappingURL=ReactJsxSvgView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactJsxSvgView.d.ts","sourceRoot":"","sources":["../src/ReactJsxSvgView.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,MAAM,WAAW,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY;IAChE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;CACnE;AAED;;;GAGG;AACH,qBAAa,eAAe,CAAC,OAAO,EAAE,OAAO,CAAE,YAAW,WAAW,CAAC,OAAO,CAAC;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGV;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+B;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;IACjE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;IAC/C,OAAO,CAAC,YAAY,CAA4B;IAEhD,YAAY,MAAM,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;QACnF,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;QAC7C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpD,EAIA;IAED,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,GAAG,cAAc,CA2F5E;IAED,aAAa,CACX,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAC9B,IAAI,CAcN;IAED,OAAO,IAAI,IAAI,CASd;CACF;AAED,MAAM,MAAM,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,IAAI,CAC9E,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EACxD,KAAK,EAAE,eAAe,CAAC,cAAc,CAAC,KACnC,SAAS,CAAC;AAEf,MAAM,MAAM,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,IAAI,CAC9E,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EACzD,KAAK,EAAE,eAAe,CAAC,cAAc,CAAC,KACnC,SAAS,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { ClusterDescriptor, ClusterHoverEvent, ClusterMetaConfig, ContentHoverEvent, ContentLayoutContext, DefaultTaggedItem, HitTarget, ItemIdentityConfig, LayoutMetrics, LayoutSolverOptions, MeshOptions, NodeRenderState, NormalizedPointerEvent, VisualResolver, WheelBehavior } from '@simplex-viz/core';
2
+ import { SimplexSvgController, type SvgNodeView } from '@simplex-viz/svg';
3
+ import { type CSSProperties, type MutableRefObject, type ReactNode } from 'react';
4
+ /**
5
+ * Props for `<SimplexTopicGraph />`, preserving end-to-end generic inference across
6
+ * `TItem`, `TContentVisual`, `TClusterVisual`, `TTagMeta`, and `TClusterMeta`.
7
+ */
8
+ export type SimplexTopicGraphProps<TItem = DefaultTaggedItem, TContentVisual = unknown, TClusterVisual = unknown, TTagMeta = undefined, TClusterMeta = undefined> = ItemIdentityConfig<TItem> & ClusterMetaConfig<TItem, TTagMeta, TClusterMeta> & {
9
+ readonly items: readonly TItem[];
10
+ readonly visualResolver: VisualResolver<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
11
+ /** Portable `@simplex-viz/svg` view plugin for content items. */
12
+ readonly contentView?: SvgNodeView<TContentVisual>;
13
+ /** Portable `@simplex-viz/svg` view plugin for topic clusters. */
14
+ readonly clusterView?: SvgNodeView<TClusterVisual>;
15
+ /** Optional declarative React JSX renderer for content items (auto-measured via `getBBox()`). */
16
+ readonly renderContentNode?: (item: TItem, ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>, state: NodeRenderState<TContentVisual>) => ReactNode;
17
+ /** Optional declarative React JSX renderer for topic clusters (auto-measured via `getBBox()`). */
18
+ readonly renderClusterNode?: (cluster: ClusterDescriptor<TItem, TTagMeta, TClusterMeta>, state: NodeRenderState<TClusterVisual>) => ReactNode;
19
+ readonly normalizeTag?: (rawTag: string) => string;
20
+ readonly resolveTagMeta?: (normalizedTag: string) => TTagMeta | undefined;
21
+ readonly meshOptions?: MeshOptions;
22
+ readonly layoutOptions?: LayoutSolverOptions;
23
+ readonly sizeMultiplier?: number;
24
+ readonly showHulls?: boolean;
25
+ readonly pinnedIds?: ReadonlySet<string> | readonly string[];
26
+ readonly highlightedIds?: ReadonlySet<string> | readonly string[];
27
+ readonly focusedClusterUid?: string | null;
28
+ readonly onContentHover?: (event: ContentHoverEvent<TItem, TContentVisual, TTagMeta, TClusterMeta> | null) => void;
29
+ readonly onClusterHover?: (event: ClusterHoverEvent<TItem, TClusterVisual, TTagMeta, TClusterMeta> | null) => void;
30
+ readonly onLeftClick?: (target: HitTarget<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>, rawEvent: NormalizedPointerEvent) => void;
31
+ readonly onRightClick?: (target: HitTarget<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>, rawEvent: NormalizedPointerEvent) => boolean | void;
32
+ readonly onWheel?: WheelBehavior;
33
+ readonly onMetricsChange?: (metrics: LayoutMetrics) => void;
34
+ readonly onClustersChange?: (clusters: readonly ClusterDescriptor<TItem, TTagMeta, TClusterMeta>[]) => void;
35
+ readonly onFpsUpdate?: (fps: number) => void;
36
+ readonly controllerRef?: MutableRefObject<SimplexSvgController<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta> | null>;
37
+ readonly className?: string;
38
+ readonly style?: CSSProperties;
39
+ };
40
+ /**
41
+ * Type-safe React visualization component wrapping `@simplex-viz/core` and `@simplex-viz/svg`.
42
+ */
43
+ export declare function SimplexTopicGraph<TItem = DefaultTaggedItem, TContentVisual = unknown, TClusterVisual = unknown, TTagMeta = undefined, TClusterMeta = undefined>(props: SimplexTopicGraphProps<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>): import("react").JSX.Element;
44
+ //# sourceMappingURL=SimplexTopicGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimplexTopicGraph.d.ts","sourceRoot":"","sources":["../src/SimplexTopicGraph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,aAAa,E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C,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAC1B,QAAQ,EAAE,SAAS,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,KAClE,IAAI,CAAC;IACV,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAC5D,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,GAAG,IAAI,CAAC,CAAC;IACV,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC,CAAC;AAEJ;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,GAAG,iBAAiB,EACzB,cAAc,GAAG,OAAO,EACxB,cAAc,GAAG,OAAO,EACxB,QAAQ,GAAG,SAAS,EACpB,YAAY,GAAG,SAAS,EAExB,KAAK,EAAE,sBAAsB,CAC3B,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,+BAkQF"}
@@ -0,0 +1,4 @@
1
+ export * from './ReactJsxSvgView';
2
+ export * from './useSimplexGraphController';
3
+ export * from './SimplexTopicGraph';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,387 @@
1
+ import { rectToConvexPolygon } from '@simplex-viz/core';
2
+ import { SVG_NS, SimplexSvgController } from '@simplex-viz/svg';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { renderToStaticMarkup } from 'react-dom/server';
5
+ import { useRef, useCallback, useEffect } from 'react';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ // src/ReactJsxSvgView.ts
9
+ var ReactJsxSvgView = class {
10
+ renderFn;
11
+ getKey;
12
+ domainByKey;
13
+ rootsByGroup = /* @__PURE__ */ new WeakMap();
14
+ activeRoots = /* @__PURE__ */ new Set();
15
+ measureGroup = null;
16
+ constructor(params) {
17
+ this.renderFn = params.renderFn;
18
+ this.getKey = params.getKey;
19
+ this.domainByKey = params.domainByKey;
20
+ }
21
+ measureConvexHull(visual, measureSvg) {
22
+ const key = this.getKey(visual);
23
+ const domain = this.domainByKey.get(key);
24
+ if (!domain) {
25
+ return rectToConvexPolygon(48, 28, 6);
26
+ }
27
+ const doc = measureSvg.ownerDocument;
28
+ let bin = measureSvg.querySelector("g.sv-measure-bin");
29
+ if (!bin) {
30
+ bin = doc.createElementNS(SVG_NS, "g");
31
+ bin.setAttribute("class", "sv-measure-bin");
32
+ bin.setAttribute("visibility", "hidden");
33
+ bin.setAttribute("pointer-events", "none");
34
+ bin.setAttribute("transform", "translate(-99999, -99999)");
35
+ measureSvg.appendChild(bin);
36
+ }
37
+ if (!this.measureGroup || this.measureGroup.parentNode !== bin) {
38
+ this.measureGroup = doc.createElementNS(SVG_NS, "g");
39
+ bin.appendChild(this.measureGroup);
40
+ }
41
+ const dummyState = {
42
+ id: "__measure__",
43
+ x: 0,
44
+ y: 0,
45
+ scale: 1,
46
+ opacity: 1,
47
+ visual,
48
+ hull: { kind: "circle", radius: 16 },
49
+ cacheKey: key,
50
+ interaction: {
51
+ isHovered: false,
52
+ isPinned: false,
53
+ isDimmed: false,
54
+ isHighlighted: false
55
+ },
56
+ transition: null
57
+ };
58
+ const jsx2 = this.renderFn(domain, dummyState);
59
+ const markup = renderToStaticMarkup(jsx2);
60
+ const wrapperSvg = doc.createElementNS(SVG_NS, "svg");
61
+ wrapperSvg.innerHTML = markup;
62
+ while (this.measureGroup.firstChild) {
63
+ this.measureGroup.removeChild(this.measureGroup.firstChild);
64
+ }
65
+ while (wrapperSvg.firstChild) {
66
+ this.measureGroup.appendChild(wrapperSvg.firstChild);
67
+ }
68
+ let width = 0;
69
+ let height = 0;
70
+ try {
71
+ if (typeof this.measureGroup.getBBox === "function") {
72
+ const bbox = this.measureGroup.getBBox();
73
+ width = bbox.width;
74
+ height = bbox.height;
75
+ }
76
+ } catch {
77
+ }
78
+ if (width <= 1 || height <= 1) {
79
+ let maxHalfW = 0;
80
+ let maxHalfH = 0;
81
+ this.measureGroup.querySelectorAll("rect, circle, text").forEach((el) => {
82
+ const tag = el.tagName.toLowerCase();
83
+ if (tag === "rect") {
84
+ const w = parseFloat(el.getAttribute("width") ?? "0");
85
+ const h = parseFloat(el.getAttribute("height") ?? "0");
86
+ maxHalfW = Math.max(maxHalfW, w / 2);
87
+ maxHalfH = Math.max(maxHalfH, h / 2);
88
+ } else if (tag === "circle") {
89
+ const r = parseFloat(el.getAttribute("r") ?? "0");
90
+ maxHalfW = Math.max(maxHalfW, r);
91
+ maxHalfH = Math.max(maxHalfH, r);
92
+ } else if (tag === "text") {
93
+ const len = (el.textContent ?? "").length;
94
+ const fs = parseFloat(el.getAttribute("font-size") ?? "11");
95
+ maxHalfW = Math.max(maxHalfW, len * fs * 0.56 / 2);
96
+ maxHalfH = Math.max(maxHalfH, fs * 0.75);
97
+ }
98
+ });
99
+ width = Math.max(24, maxHalfW * 2);
100
+ height = Math.max(20, maxHalfH * 2);
101
+ }
102
+ return rectToConvexPolygon(width + 4, height + 4, 6);
103
+ }
104
+ mountOrUpdate(groupEl, visual, state) {
105
+ const key = this.getKey(visual);
106
+ const domain = this.domainByKey.get(key);
107
+ if (!domain) return;
108
+ let root = this.rootsByGroup.get(groupEl);
109
+ if (!root) {
110
+ while (groupEl.firstChild) groupEl.removeChild(groupEl.firstChild);
111
+ root = createRoot(groupEl);
112
+ this.rootsByGroup.set(groupEl, root);
113
+ this.activeRoots.add(root);
114
+ }
115
+ root.render(this.renderFn(domain, state));
116
+ }
117
+ dispose() {
118
+ const roots = [...this.activeRoots];
119
+ this.activeRoots.clear();
120
+ this.measureGroup = null;
121
+ queueMicrotask(() => {
122
+ for (const r of roots) {
123
+ r.unmount();
124
+ }
125
+ });
126
+ }
127
+ };
128
+ function useSimplexGraphController() {
129
+ const controllerRef = useRef(null);
130
+ const addItems = useCallback((items) => {
131
+ controllerRef.current?.addItems(items);
132
+ }, []);
133
+ const removeItems = useCallback((ids) => {
134
+ controllerRef.current?.removeItems(ids);
135
+ }, []);
136
+ const setItems = useCallback((items) => {
137
+ controllerRef.current?.setItems(items);
138
+ }, []);
139
+ const resetCamera = useCallback(() => {
140
+ controllerRef.current?.camera.reset();
141
+ }, []);
142
+ const zoomBy = useCallback((factor) => {
143
+ const ctrl = controllerRef.current;
144
+ if (!ctrl) return;
145
+ const svg = ctrl.getSvgElement();
146
+ const rect = svg.getBoundingClientRect();
147
+ const cam = ctrl.camera;
148
+ cam.zoomToCursor(rect.width / 2, rect.height / 2, factor);
149
+ }, []);
150
+ const getMetrics = useCallback(() => {
151
+ return controllerRef.current?.getMetrics() ?? null;
152
+ }, []);
153
+ const getClusters = useCallback(() => {
154
+ return controllerRef.current?.getClusters() ?? [];
155
+ }, []);
156
+ const getRawController = useCallback(() => {
157
+ return controllerRef.current;
158
+ }, []);
159
+ return {
160
+ controllerRef,
161
+ handle: {
162
+ addItems,
163
+ removeItems,
164
+ setItems,
165
+ resetCamera,
166
+ zoomBy,
167
+ getMetrics,
168
+ getClusters,
169
+ getRawController
170
+ }
171
+ };
172
+ }
173
+ function SimplexTopicGraph(props) {
174
+ const containerRef = useRef(null);
175
+ const ctrlRef = useRef(null);
176
+ const contentDomainByKeyRef = useRef(
177
+ /* @__PURE__ */ new Map()
178
+ );
179
+ const clusterDomainByKeyRef = useRef(
180
+ /* @__PURE__ */ new Map()
181
+ );
182
+ const jsxContentViewRef = useRef(null);
183
+ const jsxClusterViewRef = useRef(null);
184
+ const latestPropsRef = useRef(props);
185
+ latestPropsRef.current = props;
186
+ const buildWrappedResolver = (base) => ({
187
+ resolveContentVisual: (item, ctx) => {
188
+ const visual = base.resolveContentVisual(item, ctx);
189
+ const key = base.getVisualCacheKey(visual);
190
+ contentDomainByKeyRef.current.set(key, { item, ctx });
191
+ return visual;
192
+ },
193
+ resolveClusterVisual: (cluster) => {
194
+ const visual = base.resolveClusterVisual(cluster);
195
+ const key = base.getVisualCacheKey(visual);
196
+ clusterDomainByKeyRef.current.set(key, cluster);
197
+ return visual;
198
+ },
199
+ getVisualCacheKey: (visual) => base.getVisualCacheKey(visual)
200
+ });
201
+ const resolveActiveViews = () => {
202
+ const p = latestPropsRef.current;
203
+ let contentView;
204
+ if (p.renderContentNode) {
205
+ const renderFn = p.renderContentNode;
206
+ jsxContentViewRef.current?.dispose();
207
+ const jsxView = new ReactJsxSvgView({
208
+ renderFn: (domain, state) => renderFn(domain.item, domain.ctx, state),
209
+ getKey: (v) => p.visualResolver.getVisualCacheKey(v),
210
+ domainByKey: contentDomainByKeyRef.current
211
+ });
212
+ jsxContentViewRef.current = jsxView;
213
+ contentView = jsxView;
214
+ } else if (p.contentView) {
215
+ jsxContentViewRef.current?.dispose();
216
+ jsxContentViewRef.current = null;
217
+ contentView = p.contentView;
218
+ } else {
219
+ contentView = {
220
+ measureConvexHull: () => ({ kind: "circle", radius: 10 }),
221
+ mountOrUpdate: (groupEl, _visual, state) => {
222
+ const doc = groupEl.ownerDocument;
223
+ let circle = groupEl.querySelector("circle");
224
+ if (!circle) {
225
+ circle = doc.createElementNS("http://www.w3.org/2000/svg", "circle");
226
+ circle.setAttribute("r", "9");
227
+ groupEl.appendChild(circle);
228
+ }
229
+ circle.setAttribute("fill", state.interaction.isHovered ? "#22d3ee" : "#64748b");
230
+ }
231
+ };
232
+ }
233
+ let clusterView;
234
+ if (p.renderClusterNode) {
235
+ const renderFn = p.renderClusterNode;
236
+ jsxClusterViewRef.current?.dispose();
237
+ const jsxView = new ReactJsxSvgView({
238
+ renderFn: (cluster, state) => renderFn(cluster, state),
239
+ getKey: (v) => p.visualResolver.getVisualCacheKey(v),
240
+ domainByKey: clusterDomainByKeyRef.current
241
+ });
242
+ jsxClusterViewRef.current = jsxView;
243
+ clusterView = jsxView;
244
+ } else if (p.clusterView) {
245
+ jsxClusterViewRef.current?.dispose();
246
+ jsxClusterViewRef.current = null;
247
+ clusterView = p.clusterView;
248
+ } else {
249
+ clusterView = {
250
+ measureConvexHull: () => ({ kind: "circle", radius: 22 }),
251
+ mountOrUpdate: (groupEl, _visual, state) => {
252
+ const doc = groupEl.ownerDocument;
253
+ let circle = groupEl.querySelector("circle");
254
+ if (!circle) {
255
+ circle = doc.createElementNS("http://www.w3.org/2000/svg", "circle");
256
+ circle.setAttribute("r", "20");
257
+ circle.setAttribute("fill", "#0f172a");
258
+ circle.setAttribute("stroke-width", "1.5");
259
+ groupEl.appendChild(circle);
260
+ }
261
+ circle.setAttribute("stroke", state.interaction.isHovered ? "#f8fafc" : "#38bdf8");
262
+ }
263
+ };
264
+ }
265
+ return { contentView, clusterView };
266
+ };
267
+ useEffect(() => {
268
+ const el = containerRef.current;
269
+ if (!el) return;
270
+ const p = latestPropsRef.current;
271
+ const { contentView, clusterView } = resolveActiveViews();
272
+ const ctrl = SimplexSvgController.createFromResolved(el, {
273
+ items: p.items,
274
+ getId: p.getId,
275
+ getTags: p.getTags,
276
+ deriveClusterMeta: p.deriveClusterMeta,
277
+ visualResolver: buildWrappedResolver(p.visualResolver),
278
+ contentView,
279
+ clusterView,
280
+ normalizeTag: p.normalizeTag,
281
+ resolveTagMeta: p.resolveTagMeta,
282
+ meshOptions: p.meshOptions,
283
+ layoutOptions: {
284
+ ...p.layoutOptions,
285
+ sizeMultiplier: p.sizeMultiplier ?? p.layoutOptions?.sizeMultiplier ?? 1
286
+ },
287
+ showHulls: p.showHulls,
288
+ interactions: {
289
+ onContentHover: (ev) => latestPropsRef.current.onContentHover?.(ev),
290
+ onClusterHover: (ev) => latestPropsRef.current.onClusterHover?.(ev),
291
+ onLeftClick: (t, raw) => latestPropsRef.current.onLeftClick?.(t, raw),
292
+ onRightClick: (t, raw) => latestPropsRef.current.onRightClick?.(t, raw),
293
+ onWheel: (ev, cam) => {
294
+ const policy = latestPropsRef.current.onWheel ?? "zoom-to-cursor";
295
+ if (policy === "none") return;
296
+ if (typeof policy === "function") {
297
+ policy(ev, cam);
298
+ return;
299
+ }
300
+ if (policy === "pan-vertical") {
301
+ cam.panBy(-ev.deltaX, -ev.deltaY);
302
+ return;
303
+ }
304
+ const factor = Math.exp(-ev.deltaY * 14e-4);
305
+ cam.zoomToCursor(ev.screenX, ev.screenY, factor);
306
+ }
307
+ },
308
+ onMetricsChange: (m) => latestPropsRef.current.onMetricsChange?.(m),
309
+ onClustersChange: (c) => latestPropsRef.current.onClustersChange?.(c),
310
+ onFpsUpdate: (fps) => latestPropsRef.current.onFpsUpdate?.(fps)
311
+ });
312
+ ctrlRef.current = ctrl;
313
+ if (p.controllerRef) {
314
+ p.controllerRef.current = ctrl;
315
+ }
316
+ return () => {
317
+ ctrl.destroy();
318
+ ctrlRef.current = null;
319
+ if (latestPropsRef.current.controllerRef) {
320
+ latestPropsRef.current.controllerRef.current = null;
321
+ }
322
+ jsxContentViewRef.current?.dispose();
323
+ jsxClusterViewRef.current?.dispose();
324
+ jsxContentViewRef.current = null;
325
+ jsxClusterViewRef.current = null;
326
+ };
327
+ }, []);
328
+ useEffect(() => {
329
+ ctrlRef.current?.setItems(props.items);
330
+ }, [props.items]);
331
+ useEffect(() => {
332
+ const ctrl = ctrlRef.current;
333
+ if (!ctrl) return;
334
+ const { contentView, clusterView } = resolveActiveViews();
335
+ ctrl.setViews({ contentView, clusterView });
336
+ ctrl.setVisualResolver(buildWrappedResolver(props.visualResolver));
337
+ }, [
338
+ props.visualResolver,
339
+ props.contentView,
340
+ props.clusterView,
341
+ props.renderContentNode,
342
+ props.renderClusterNode
343
+ ]);
344
+ useEffect(() => {
345
+ if (props.sizeMultiplier !== void 0) {
346
+ ctrlRef.current?.setSizeMultiplier(props.sizeMultiplier);
347
+ }
348
+ }, [props.sizeMultiplier]);
349
+ useEffect(() => {
350
+ if (props.showHulls !== void 0) {
351
+ ctrlRef.current?.setShowHulls(props.showHulls);
352
+ }
353
+ }, [props.showHulls]);
354
+ useEffect(() => {
355
+ if (props.pinnedIds !== void 0) {
356
+ ctrlRef.current?.setPinnedIds(props.pinnedIds);
357
+ }
358
+ }, [props.pinnedIds]);
359
+ useEffect(() => {
360
+ if (props.highlightedIds !== void 0) {
361
+ ctrlRef.current?.setHighlightedIds(props.highlightedIds);
362
+ }
363
+ }, [props.highlightedIds]);
364
+ useEffect(() => {
365
+ if (props.focusedClusterUid !== void 0) {
366
+ ctrlRef.current?.setFocusedClusterUid(props.focusedClusterUid);
367
+ }
368
+ }, [props.focusedClusterUid]);
369
+ return /* @__PURE__ */ jsx(
370
+ "div",
371
+ {
372
+ ref: containerRef,
373
+ className: props.className,
374
+ style: {
375
+ position: "relative",
376
+ width: "100%",
377
+ height: "100%",
378
+ overflow: "hidden",
379
+ ...props.style
380
+ }
381
+ }
382
+ );
383
+ }
384
+
385
+ export { ReactJsxSvgView, SimplexTopicGraph, useSimplexGraphController };
386
+ //# sourceMappingURL=index.js.map
387
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ReactJsxSvgView.ts","../src/useSimplexGraphController.ts","../src/SimplexTopicGraph.tsx"],"names":["jsx","useRef"],"mappings":";;;;;;;;AAqBO,IAAM,kBAAN,MAAwE;AAAA,EAC5D,QAAA;AAAA,EAIA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA,uBAAmB,OAAA,EAA2B;AAAA,EAC9C,WAAA,uBAAkB,GAAA,EAAU;AAAA,EACrC,YAAA,GAAmC,IAAA;AAAA,EAE3C,YAAY,MAAA,EAIT;AACD,IAAA,IAAA,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F;AAEJ","file":"index.js","sourcesContent":["import {\n rectToConvexPolygon,\n type ClusterDescriptor,\n type ContentLayoutContext,\n type ConvexGeometry,\n type NodeRenderState,\n} from '@simplex-viz/core';\nimport { SVG_NS, type SvgNodeView } from '@simplex-viz/svg';\nimport type { ReactNode } from 'react';\nimport { createRoot, type Root } from 'react-dom/client';\nimport { renderToStaticMarkup } from 'react-dom/server';\n\nexport interface ContentDomainRecord<TItem, TTagMeta, TClusterMeta> {\n readonly item: TItem;\n readonly ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>;\n}\n\n/**\n * Bridges a declarative React JSX render function into an `@simplex-viz/svg` `SvgNodeView`\n * with automatic offscreen `getBBox()` convex hull measurement and cached DOM updates.\n */\nexport class ReactJsxSvgView<TVisual, TDomain> implements SvgNodeView<TVisual> {\n private readonly renderFn: (\n domain: TDomain,\n state: NodeRenderState<TVisual>,\n ) => ReactNode;\n private readonly getKey: (visual: TVisual) => string;\n private readonly domainByKey: ReadonlyMap<string, TDomain>;\n private readonly rootsByGroup = new WeakMap<SVGGElement, Root>();\n private readonly activeRoots = new Set<Root>();\n private measureGroup: SVGGElement | null = null;\n\n constructor(params: {\n readonly renderFn: (domain: TDomain, state: NodeRenderState<TVisual>) => ReactNode;\n readonly getKey: (visual: TVisual) => string;\n readonly domainByKey: ReadonlyMap<string, TDomain>;\n }) {\n this.renderFn = params.renderFn;\n this.getKey = params.getKey;\n this.domainByKey = params.domainByKey;\n }\n\n measureConvexHull(visual: TVisual, measureSvg: SVGSVGElement): ConvexGeometry {\n const key = this.getKey(visual);\n const domain = this.domainByKey.get(key);\n if (!domain) {\n return rectToConvexPolygon(48, 28, 6);\n }\n\n const doc = measureSvg.ownerDocument;\n let bin = measureSvg.querySelector<SVGGElement>('g.sv-measure-bin');\n if (!bin) {\n bin = doc.createElementNS(SVG_NS, 'g');\n bin.setAttribute('class', 'sv-measure-bin');\n bin.setAttribute('visibility', 'hidden');\n bin.setAttribute('pointer-events', 'none');\n bin.setAttribute('transform', 'translate(-99999, -99999)');\n measureSvg.appendChild(bin);\n }\n\n if (!this.measureGroup || this.measureGroup.parentNode !== bin) {\n this.measureGroup = doc.createElementNS(SVG_NS, 'g');\n bin.appendChild(this.measureGroup);\n }\n\n const dummyState: NodeRenderState<TVisual> = {\n id: '__measure__',\n x: 0,\n y: 0,\n scale: 1,\n opacity: 1,\n visual,\n hull: { kind: 'circle', radius: 16 },\n cacheKey: key,\n interaction: {\n isHovered: false,\n isPinned: false,\n isDimmed: false,\n isHighlighted: false,\n },\n transition: null,\n };\n\n const jsx = this.renderFn(domain, dummyState);\n const markup = renderToStaticMarkup(jsx);\n // Parse JSX markup into SVG namespace inside the offscreen measurement group\n const wrapperSvg = doc.createElementNS(SVG_NS, 'svg');\n wrapperSvg.innerHTML = markup;\n while (this.measureGroup.firstChild) {\n this.measureGroup.removeChild(this.measureGroup.firstChild);\n }\n while (wrapperSvg.firstChild) {\n this.measureGroup.appendChild(wrapperSvg.firstChild);\n }\n\n let width = 0;\n let height = 0;\n try {\n if (typeof this.measureGroup.getBBox === 'function') {\n const bbox = this.measureGroup.getBBox();\n width = bbox.width;\n height = bbox.height;\n }\n } catch {\n // Headless DOM without layout engine\n }\n\n if (width <= 1 || height <= 1) {\n let maxHalfW = 0;\n let maxHalfH = 0;\n this.measureGroup.querySelectorAll('rect, circle, text').forEach((el) => {\n const tag = el.tagName.toLowerCase();\n if (tag === 'rect') {\n const w = parseFloat(el.getAttribute('width') ?? '0');\n const h = parseFloat(el.getAttribute('height') ?? '0');\n maxHalfW = Math.max(maxHalfW, w / 2);\n maxHalfH = Math.max(maxHalfH, h / 2);\n } else if (tag === 'circle') {\n const r = parseFloat(el.getAttribute('r') ?? '0');\n maxHalfW = Math.max(maxHalfW, r);\n maxHalfH = Math.max(maxHalfH, r);\n } else if (tag === 'text') {\n const len = (el.textContent ?? '').length;\n const fs = parseFloat(el.getAttribute('font-size') ?? '11');\n maxHalfW = Math.max(maxHalfW, (len * fs * 0.56) / 2);\n maxHalfH = Math.max(maxHalfH, fs * 0.75);\n }\n });\n width = Math.max(24, maxHalfW * 2);\n height = Math.max(20, maxHalfH * 2);\n }\n\n return rectToConvexPolygon(width + 4, height + 4, 6);\n }\n\n mountOrUpdate(\n groupEl: SVGGElement,\n visual: TVisual,\n state: NodeRenderState<TVisual>,\n ): void {\n const key = this.getKey(visual);\n const domain = this.domainByKey.get(key);\n if (!domain) return;\n\n let root = this.rootsByGroup.get(groupEl);\n if (!root) {\n while (groupEl.firstChild) groupEl.removeChild(groupEl.firstChild);\n root = createRoot(groupEl);\n this.rootsByGroup.set(groupEl, root);\n this.activeRoots.add(root);\n }\n\n root.render(this.renderFn(domain, state));\n }\n\n dispose(): void {\n const roots = [...this.activeRoots];\n this.activeRoots.clear();\n this.measureGroup = null;\n queueMicrotask(() => {\n for (const r of roots) {\n r.unmount();\n }\n });\n }\n}\n\nexport type ContentJsxRenderFn<TItem, TContentVisual, TTagMeta, TClusterMeta> = (\n item: TItem,\n ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>,\n state: NodeRenderState<TContentVisual>,\n) => ReactNode;\n\nexport type ClusterJsxRenderFn<TItem, TClusterVisual, TTagMeta, TClusterMeta> = (\n cluster: ClusterDescriptor<TItem, TTagMeta, TClusterMeta>,\n state: NodeRenderState<TClusterVisual>,\n) => ReactNode;\n","import type {\n CameraController,\n ClusterDescriptor,\n DefaultTaggedItem,\n LayoutMetrics,\n} from '@simplex-viz/core';\nimport type { SimplexSvgController } from '@simplex-viz/svg';\nimport { useCallback, useRef } from 'react';\n\n/**\n * Imperative handle bound to `<SimplexTopicGraph controllerRef={...} />`.\n */\nexport interface SimplexGraphHandle<\n TItem = DefaultTaggedItem,\n TContentVisual = unknown,\n TClusterVisual = unknown,\n TTagMeta = undefined,\n TClusterMeta = undefined,\n> {\n addItems(items: TItem | readonly TItem[]): void;\n removeItems(ids: string | readonly string[]): void;\n setItems(items: readonly TItem[]): void;\n resetCamera(): void;\n zoomBy(factor: number): void;\n getMetrics(): LayoutMetrics | null;\n getClusters(): readonly ClusterDescriptor<TItem, TTagMeta, TClusterMeta>[];\n getRawController(): SimplexSvgController<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n > | null;\n}\n\n/**\n * React hook returning a stable `controllerRef` and imperative transaction helpers\n * (`addItems`, `removeItems`, `setItems`, camera controls, and live telemetry getters).\n */\nexport function useSimplexGraphController<\n TItem = DefaultTaggedItem,\n TContentVisual = unknown,\n TClusterVisual = unknown,\n TTagMeta = undefined,\n TClusterMeta = undefined,\n>(): {\n readonly controllerRef: React.MutableRefObject<SimplexSvgController<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n > | null>;\n readonly handle: SimplexGraphHandle<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n >;\n} {\n const controllerRef = useRef<SimplexSvgController<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n > | null>(null);\n\n const addItems = useCallback((items: TItem | readonly TItem[]) => {\n controllerRef.current?.addItems(items);\n }, []);\n\n const removeItems = useCallback((ids: string | readonly string[]) => {\n controllerRef.current?.removeItems(ids);\n }, []);\n\n const setItems = useCallback((items: readonly TItem[]) => {\n controllerRef.current?.setItems(items);\n }, []);\n\n const resetCamera = useCallback(() => {\n controllerRef.current?.camera.reset();\n }, []);\n\n const zoomBy = useCallback((factor: number) => {\n const ctrl = controllerRef.current;\n if (!ctrl) return;\n const svg = ctrl.getSvgElement();\n const rect = svg.getBoundingClientRect();\n const cam: CameraController = ctrl.camera;\n cam.zoomToCursor(rect.width / 2, rect.height / 2, factor);\n }, []);\n\n const getMetrics = useCallback(() => {\n return controllerRef.current?.getMetrics() ?? null;\n }, []);\n\n const getClusters = useCallback(() => {\n return controllerRef.current?.getClusters() ?? [];\n }, []);\n\n const getRawController = useCallback(() => {\n return controllerRef.current;\n }, []);\n\n return {\n controllerRef,\n handle: {\n addItems,\n removeItems,\n setItems,\n resetCamera,\n zoomBy,\n getMetrics,\n getClusters,\n getRawController,\n },\n };\n}\n","import type {\n ClusterDescriptor,\n ClusterHoverEvent,\n ClusterMetaConfig,\n ContentHoverEvent,\n ContentLayoutContext,\n DefaultTaggedItem,\n HitTarget,\n ItemIdentityConfig,\n LayoutMetrics,\n LayoutSolverOptions,\n MeshOptions,\n NodeRenderState,\n NormalizedPointerEvent,\n VisualResolver,\n WheelBehavior,\n} from '@simplex-viz/core';\nimport {\n SimplexSvgController,\n type SvgNodeView,\n} from '@simplex-viz/svg';\nimport {\n useEffect,\n useRef,\n type CSSProperties,\n type MutableRefObject,\n type ReactNode,\n} from 'react';\nimport {\n ReactJsxSvgView,\n type ContentDomainRecord,\n} from './ReactJsxSvgView';\n\n/**\n * Props for `<SimplexTopicGraph />`, preserving end-to-end generic inference across\n * `TItem`, `TContentVisual`, `TClusterVisual`, `TTagMeta`, and `TClusterMeta`.\n */\nexport type SimplexTopicGraphProps<\n TItem = DefaultTaggedItem,\n TContentVisual = unknown,\n TClusterVisual = unknown,\n TTagMeta = undefined,\n TClusterMeta = undefined,\n> = ItemIdentityConfig<TItem> &\n ClusterMetaConfig<TItem, TTagMeta, TClusterMeta> & {\n readonly items: readonly TItem[];\n readonly visualResolver: VisualResolver<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n >;\n /** Portable `@simplex-viz/svg` view plugin for content items. */\n readonly contentView?: SvgNodeView<TContentVisual>;\n /** Portable `@simplex-viz/svg` view plugin for topic clusters. */\n readonly clusterView?: SvgNodeView<TClusterVisual>;\n /** Optional declarative React JSX renderer for content items (auto-measured via `getBBox()`). */\n readonly renderContentNode?: (\n item: TItem,\n ctx: ContentLayoutContext<TItem, TTagMeta, TClusterMeta>,\n state: NodeRenderState<TContentVisual>,\n ) => ReactNode;\n /** Optional declarative React JSX renderer for topic clusters (auto-measured via `getBBox()`). */\n readonly renderClusterNode?: (\n cluster: ClusterDescriptor<TItem, TTagMeta, TClusterMeta>,\n state: NodeRenderState<TClusterVisual>,\n ) => ReactNode;\n readonly normalizeTag?: (rawTag: string) => string;\n readonly resolveTagMeta?: (normalizedTag: string) => TTagMeta | undefined;\n readonly meshOptions?: MeshOptions;\n readonly layoutOptions?: LayoutSolverOptions;\n readonly sizeMultiplier?: number;\n readonly showHulls?: boolean;\n readonly pinnedIds?: ReadonlySet<string> | readonly string[];\n readonly highlightedIds?: ReadonlySet<string> | readonly string[];\n readonly focusedClusterUid?: string | null;\n readonly onContentHover?: (\n event: ContentHoverEvent<TItem, TContentVisual, TTagMeta, TClusterMeta> | null,\n ) => void;\n readonly onClusterHover?: (\n event: ClusterHoverEvent<TItem, TClusterVisual, TTagMeta, TClusterMeta> | null,\n ) => void;\n readonly onLeftClick?: (\n target: HitTarget<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>,\n rawEvent: NormalizedPointerEvent,\n ) => void;\n readonly onRightClick?: (\n target: HitTarget<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>,\n rawEvent: NormalizedPointerEvent,\n ) => boolean | void;\n readonly onWheel?: WheelBehavior;\n readonly onMetricsChange?: (metrics: LayoutMetrics) => void;\n readonly onClustersChange?: (\n clusters: readonly ClusterDescriptor<TItem, TTagMeta, TClusterMeta>[],\n ) => void;\n readonly onFpsUpdate?: (fps: number) => void;\n readonly controllerRef?: MutableRefObject<SimplexSvgController<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n > | null>;\n readonly className?: string;\n readonly style?: CSSProperties;\n };\n\n/**\n * Type-safe React visualization component wrapping `@simplex-viz/core` and `@simplex-viz/svg`.\n */\nexport function SimplexTopicGraph<\n TItem = DefaultTaggedItem,\n TContentVisual = unknown,\n TClusterVisual = unknown,\n TTagMeta = undefined,\n TClusterMeta = undefined,\n>(\n props: SimplexTopicGraphProps<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n >,\n) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const ctrlRef = useRef<SimplexSvgController<\n TItem,\n TContentVisual,\n TClusterVisual,\n TTagMeta,\n TClusterMeta\n > | null>(null);\n\n const contentDomainByKeyRef = useRef(\n new Map<string, ContentDomainRecord<TItem, TTagMeta, TClusterMeta>>(),\n );\n const clusterDomainByKeyRef = useRef(\n new Map<string, ClusterDescriptor<TItem, TTagMeta, TClusterMeta>>(),\n );\n const jsxContentViewRef = useRef<ReactJsxSvgView<\n TContentVisual,\n ContentDomainRecord<TItem, TTagMeta, TClusterMeta>\n > | null>(null);\n const jsxClusterViewRef = useRef<ReactJsxSvgView<\n TClusterVisual,\n ClusterDescriptor<TItem, TTagMeta, TClusterMeta>\n > | null>(null);\n\n const latestPropsRef = useRef(props);\n latestPropsRef.current = props;\n\n const buildWrappedResolver = (\n base: VisualResolver<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>,\n ): VisualResolver<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta> => ({\n resolveContentVisual: (item, ctx) => {\n const visual = base.resolveContentVisual(item, ctx);\n const key = base.getVisualCacheKey(visual);\n contentDomainByKeyRef.current.set(key, { item, ctx });\n return visual;\n },\n resolveClusterVisual: (cluster) => {\n const visual = base.resolveClusterVisual(cluster);\n const key = base.getVisualCacheKey(visual);\n clusterDomainByKeyRef.current.set(key, cluster);\n return visual;\n },\n getVisualCacheKey: (visual) => base.getVisualCacheKey(visual),\n });\n\n const resolveActiveViews = (): {\n contentView: SvgNodeView<TContentVisual>;\n clusterView: SvgNodeView<TClusterVisual>;\n } => {\n const p = latestPropsRef.current;\n\n let contentView: SvgNodeView<TContentVisual>;\n if (p.renderContentNode) {\n const renderFn = p.renderContentNode;\n jsxContentViewRef.current?.dispose();\n const jsxView = new ReactJsxSvgView<\n TContentVisual,\n ContentDomainRecord<TItem, TTagMeta, TClusterMeta>\n >({\n renderFn: (domain, state) => renderFn(domain.item, domain.ctx, state),\n getKey: (v) => p.visualResolver.getVisualCacheKey(v),\n domainByKey: contentDomainByKeyRef.current,\n });\n jsxContentViewRef.current = jsxView;\n contentView = jsxView;\n } else if (p.contentView) {\n jsxContentViewRef.current?.dispose();\n jsxContentViewRef.current = null;\n contentView = p.contentView;\n } else {\n contentView = {\n measureConvexHull: () => ({ kind: 'circle', radius: 10 }),\n mountOrUpdate: (groupEl, _visual, state) => {\n const doc = groupEl.ownerDocument;\n let circle = groupEl.querySelector('circle');\n if (!circle) {\n circle = doc.createElementNS('http://www.w3.org/2000/svg', 'circle');\n circle.setAttribute('r', '9');\n groupEl.appendChild(circle);\n }\n circle.setAttribute('fill', state.interaction.isHovered ? '#22d3ee' : '#64748b');\n },\n };\n }\n\n let clusterView: SvgNodeView<TClusterVisual>;\n if (p.renderClusterNode) {\n const renderFn = p.renderClusterNode;\n jsxClusterViewRef.current?.dispose();\n const jsxView = new ReactJsxSvgView<\n TClusterVisual,\n ClusterDescriptor<TItem, TTagMeta, TClusterMeta>\n >({\n renderFn: (cluster, state) => renderFn(cluster, state),\n getKey: (v) => p.visualResolver.getVisualCacheKey(v),\n domainByKey: clusterDomainByKeyRef.current,\n });\n jsxClusterViewRef.current = jsxView;\n clusterView = jsxView;\n } else if (p.clusterView) {\n jsxClusterViewRef.current?.dispose();\n jsxClusterViewRef.current = null;\n clusterView = p.clusterView;\n } else {\n clusterView = {\n measureConvexHull: () => ({ kind: 'circle', radius: 22 }),\n mountOrUpdate: (groupEl, _visual, state) => {\n const doc = groupEl.ownerDocument;\n let circle = groupEl.querySelector('circle');\n if (!circle) {\n circle = doc.createElementNS('http://www.w3.org/2000/svg', 'circle');\n circle.setAttribute('r', '20');\n circle.setAttribute('fill', '#0f172a');\n circle.setAttribute('stroke-width', '1.5');\n groupEl.appendChild(circle);\n }\n circle.setAttribute('stroke', state.interaction.isHovered ? '#f8fafc' : '#38bdf8');\n },\n };\n }\n\n return { contentView, clusterView };\n };\n\n // Mount controller once on container\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n\n const p = latestPropsRef.current;\n const { contentView, clusterView } = resolveActiveViews();\n\n const ctrl = SimplexSvgController.createFromResolved(el, {\n items: p.items,\n getId: p.getId,\n getTags: p.getTags,\n deriveClusterMeta: p.deriveClusterMeta,\n visualResolver: buildWrappedResolver(p.visualResolver),\n contentView,\n clusterView,\n normalizeTag: p.normalizeTag,\n resolveTagMeta: p.resolveTagMeta,\n meshOptions: p.meshOptions,\n layoutOptions: {\n ...p.layoutOptions,\n sizeMultiplier: p.sizeMultiplier ?? p.layoutOptions?.sizeMultiplier ?? 1,\n },\n showHulls: p.showHulls,\n interactions: {\n onContentHover: (ev) => latestPropsRef.current.onContentHover?.(ev),\n onClusterHover: (ev) => latestPropsRef.current.onClusterHover?.(ev),\n onLeftClick: (t, raw) => latestPropsRef.current.onLeftClick?.(t, raw),\n onRightClick: (t, raw) => latestPropsRef.current.onRightClick?.(t, raw),\n onWheel: (ev, cam) => {\n const policy = latestPropsRef.current.onWheel ?? 'zoom-to-cursor';\n if (policy === 'none') return;\n if (typeof policy === 'function') {\n policy(ev, cam);\n return;\n }\n if (policy === 'pan-vertical') {\n cam.panBy(-ev.deltaX, -ev.deltaY);\n return;\n }\n const factor = Math.exp(-ev.deltaY * 0.0014);\n cam.zoomToCursor(ev.screenX, ev.screenY, factor);\n },\n },\n onMetricsChange: (m) => latestPropsRef.current.onMetricsChange?.(m),\n onClustersChange: (c) => latestPropsRef.current.onClustersChange?.(c),\n onFpsUpdate: (fps) => latestPropsRef.current.onFpsUpdate?.(fps),\n });\n ctrlRef.current = ctrl;\n if (p.controllerRef) {\n p.controllerRef.current = ctrl;\n }\n\n return () => {\n ctrl.destroy();\n ctrlRef.current = null;\n if (latestPropsRef.current.controllerRef) {\n latestPropsRef.current.controllerRef.current = null;\n }\n jsxContentViewRef.current?.dispose();\n jsxClusterViewRef.current?.dispose();\n jsxContentViewRef.current = null;\n jsxClusterViewRef.current = null;\n };\n }, []);\n\n // Sync items\n useEffect(() => {\n ctrlRef.current?.setItems(props.items);\n }, [props.items]);\n\n // Sync views & visual resolver (triggers smooth crossfade / morph!)\n useEffect(() => {\n const ctrl = ctrlRef.current;\n if (!ctrl) return;\n const { contentView, clusterView } = resolveActiveViews();\n ctrl.setViews({ contentView, clusterView });\n ctrl.setVisualResolver(buildWrappedResolver(props.visualResolver));\n }, [\n props.visualResolver,\n props.contentView,\n props.clusterView,\n props.renderContentNode,\n props.renderClusterNode,\n ]);\n\n // Sync sizeMultiplier\n useEffect(() => {\n if (props.sizeMultiplier !== undefined) {\n ctrlRef.current?.setSizeMultiplier(props.sizeMultiplier);\n }\n }, [props.sizeMultiplier]);\n\n // Sync showHulls\n useEffect(() => {\n if (props.showHulls !== undefined) {\n ctrlRef.current?.setShowHulls(props.showHulls);\n }\n }, [props.showHulls]);\n\n // Sync pinned / highlighted / focused cluster\n useEffect(() => {\n if (props.pinnedIds !== undefined) {\n ctrlRef.current?.setPinnedIds(props.pinnedIds);\n }\n }, [props.pinnedIds]);\n\n useEffect(() => {\n if (props.highlightedIds !== undefined) {\n ctrlRef.current?.setHighlightedIds(props.highlightedIds);\n }\n }, [props.highlightedIds]);\n\n useEffect(() => {\n if (props.focusedClusterUid !== undefined) {\n ctrlRef.current?.setFocusedClusterUid(props.focusedClusterUid);\n }\n }, [props.focusedClusterUid]);\n\n return (\n <div\n ref={containerRef}\n className={props.className}\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n ...props.style,\n }}\n />\n );\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { ClusterDescriptor, DefaultTaggedItem, LayoutMetrics } from '@simplex-viz/core';
2
+ import type { SimplexSvgController } from '@simplex-viz/svg';
3
+ /**
4
+ * Imperative handle bound to `<SimplexTopicGraph controllerRef={...} />`.
5
+ */
6
+ export interface SimplexGraphHandle<TItem = DefaultTaggedItem, TContentVisual = unknown, TClusterVisual = unknown, TTagMeta = undefined, TClusterMeta = undefined> {
7
+ addItems(items: TItem | readonly TItem[]): void;
8
+ removeItems(ids: string | readonly string[]): void;
9
+ setItems(items: readonly TItem[]): void;
10
+ resetCamera(): void;
11
+ zoomBy(factor: number): void;
12
+ getMetrics(): LayoutMetrics | null;
13
+ getClusters(): readonly ClusterDescriptor<TItem, TTagMeta, TClusterMeta>[];
14
+ getRawController(): SimplexSvgController<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta> | null;
15
+ }
16
+ /**
17
+ * React hook returning a stable `controllerRef` and imperative transaction helpers
18
+ * (`addItems`, `removeItems`, `setItems`, camera controls, and live telemetry getters).
19
+ */
20
+ export declare function useSimplexGraphController<TItem = DefaultTaggedItem, TContentVisual = unknown, TClusterVisual = unknown, TTagMeta = undefined, TClusterMeta = undefined>(): {
21
+ readonly controllerRef: React.MutableRefObject<SimplexSvgController<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta> | null>;
22
+ readonly handle: SimplexGraphHandle<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
23
+ };
24
+ //# sourceMappingURL=useSimplexGraphController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSimplexGraphController.d.ts","sourceRoot":"","sources":["../src/useSimplexGraphController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW,kBAAkB,CACjC,KAAK,GAAG,iBAAiB,EACzB,cAAc,GAAG,OAAO,EACxB,cAAc,GAAG,OAAO,EACxB,QAAQ,GAAG,SAAS,EACpB,YAAY,GAAG,SAAS;IAExB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,GAAG,IAAI,CAAC;IAChD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI,CAAC;IACxC,WAAW,IAAI,IAAI,CAAC;IACpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,IAAI,aAAa,GAAG,IAAI,CAAC;IACnC,WAAW,IAAI,SAAS,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC;IAC3E,gBAAgB,IAAI,oBAAoB,CACtC,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,GAAG,IAAI,CAAC;CACV;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,GAAG,iBAAiB,EACzB,cAAc,GAAG,OAAO,EACxB,cAAc,GAAG,OAAO,EACxB,QAAQ,GAAG,SAAS,EACpB,YAAY,GAAG,SAAS,KACrB;IACH,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,gBAAgB,CAAC,oBAAoB,CACjE,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,GAAG,IAAI,CAAC,CAAC;IACV,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CACjC,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,CAAC;CACH,CA2DA"}
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@simplex-viz/react",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "End-to-end type-safe React bindings, declarative JSX node renderers, and hooks for @simplex-viz/core and @simplex-viz/svg.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "dependencies": {
23
+ "@simplex-viz/svg": "^0.1.0",
24
+ "@simplex-viz/core": "^0.1.0"
25
+ },
26
+ "peerDependencies": {
27
+ "react": ">=18.0.0",
28
+ "react-dom": ">=18.0.0"
29
+ },
30
+ "keywords": [
31
+ "simplex",
32
+ "react",
33
+ "svg",
34
+ "visualization",
35
+ "typescript"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/ghackenberg/simplex-viz.git",
40
+ "directory": "packages/react"
41
+ },
42
+ "scripts": {
43
+ "build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit"
45
+ }
6
46
  }