@simplex-viz/svg 0.1.3 → 0.2.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/README.md +89 -37
- package/dist/SimplexSvgController.d.ts +59 -11
- package/dist/SimplexSvgController.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1159 -879
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +38 -0
- package/dist/presets.d.ts.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,23 +30,90 @@ While `@simplex-viz/core` computes pure spatial coordinates, `@simplex-viz/svg`
|
|
|
30
30
|
|
|
31
31
|
## Installation
|
|
32
32
|
|
|
33
|
-
Install `@simplex-viz/
|
|
33
|
+
Install `@simplex-viz/svg` alone (`@simplex-viz/core` is installed automatically and key utilities and types are re-exported directly from `@simplex-viz/svg`):
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
npm install @simplex-viz/
|
|
36
|
+
npm install @simplex-viz/svg
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
## Quickstart (
|
|
39
|
+
## Quickstart (Zero-Config)
|
|
40
|
+
|
|
41
|
+
### One-Liner Mount (`createSimplexSvg`)
|
|
42
|
+
|
|
43
|
+
Pass a container `HTMLElement` or CSS selector together with an array of `{ id, tags }` items to `createSimplexSvg`. Drag-to-pan, cursor wheel zoom, cluster click-focus, and floating hover tooltips are enabled automatically:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { createSimplexSvg } from '@simplex-viz/svg';
|
|
47
|
+
|
|
48
|
+
const items = [
|
|
49
|
+
{ id: '1', label: 'Simplex Mesh', tags: ['geometry', 'triangulation', 'math'] },
|
|
50
|
+
{ id: '2', label: 'OKLab Mixing', tags: ['color', 'geometry', 'perception'] },
|
|
51
|
+
{ id: '3', label: 'SAT Solver', tags: ['collision', 'geometry'] },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const controller = createSimplexSvg('#graph', items);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Presets, Labels & Custom Domain Records (`SimplexSvgController`)
|
|
58
|
+
|
|
59
|
+
When you want to pick a built-in visual preset (`'geometric'`, `'glyphs'`, or `'badges'`), display custom labels, or connect records without `{ id, tags }`, pass an options object to `createSimplexSvg` or `new SimplexSvgController(...)`:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { SimplexSvgController } from '@simplex-viz/svg';
|
|
63
|
+
|
|
64
|
+
interface Article {
|
|
65
|
+
readonly slug: string;
|
|
66
|
+
readonly headline: string;
|
|
67
|
+
readonly topics: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const controller = new SimplexSvgController('#graph', {
|
|
71
|
+
items: articles,
|
|
72
|
+
getId: (a) => a.slug,
|
|
73
|
+
getTags: (a) => a.topics,
|
|
74
|
+
getLabel: (a) => a.headline,
|
|
75
|
+
preset: 'glyphs', // 'geometric' | 'glyphs' | 'badges'
|
|
76
|
+
tooltip: true, // Built-in hover tooltip (or custom formatter)
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can also format hover tooltips yourself without building separate DOM overlays:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const controller = new SimplexSvgController('#graph', {
|
|
84
|
+
items: articles,
|
|
85
|
+
getId: (a) => a.slug,
|
|
86
|
+
getTags: (a) => a.topics,
|
|
87
|
+
preset: 'badges',
|
|
88
|
+
tooltip: (target) =>
|
|
89
|
+
target.kind === 'content'
|
|
90
|
+
? `${target.item.headline} (${target.layoutContext.tags.length} tags)`
|
|
91
|
+
: `${target.cluster.defaultLabel}: ${target.cluster.members.length} articles`,
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Switch presets or mutate data smoothly at runtime—camera pan/zoom stays intact while springs retarget mid-flight:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
controller.setPreset('badges');
|
|
99
|
+
controller.addItems({ slug: 'new-1', headline: 'Dual-Layer Crossfade', topics: ['svg', 'animation'] });
|
|
100
|
+
controller.removeItems('old-slug');
|
|
101
|
+
controller.camera.reset();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Progressive Customization: Custom `VisualResolver` & `SvgNodeView`
|
|
105
|
+
|
|
106
|
+
Whenever built-in presets are not specific enough, swap in your own `VisualResolver`, view plugins, or root-SVG event handlers without rewriting the container lifecycle.
|
|
40
107
|
|
|
41
108
|
### Step 1 — Define Your Domain Record & `VisualResolver`
|
|
42
109
|
|
|
43
|
-
|
|
110
|
+
Map each item and topic cluster into typed descriptors for any `SvgNodeView` plugin. Notice that `VisualResolver` and descriptor types can be imported directly from `@simplex-viz/svg`:
|
|
44
111
|
|
|
45
112
|
```ts
|
|
46
|
-
import type { VisualResolver } from '@simplex-viz/core';
|
|
47
113
|
import type {
|
|
48
114
|
ClusterAnchorVisual,
|
|
49
115
|
GeometricShapeVisual,
|
|
116
|
+
VisualResolver,
|
|
50
117
|
} from '@simplex-viz/svg';
|
|
51
118
|
|
|
52
119
|
interface Bookmark {
|
|
@@ -82,9 +149,9 @@ const visualResolver: VisualResolver<
|
|
|
82
149
|
};
|
|
83
150
|
```
|
|
84
151
|
|
|
85
|
-
### Step 2 — Mount `SimplexSvgController`
|
|
152
|
+
### Step 2 — Mount `SimplexSvgController` with Custom Views
|
|
86
153
|
|
|
87
|
-
Pass
|
|
154
|
+
Pass `visualResolver` together with `contentView` and `clusterView` plugins. You can omit `interactions` to keep default cluster click-focus and cursor zoom, or override individual handlers below:
|
|
88
155
|
|
|
89
156
|
```ts
|
|
90
157
|
import {
|
|
@@ -93,9 +160,7 @@ import {
|
|
|
93
160
|
ClusterAnchorSvgView,
|
|
94
161
|
} from '@simplex-viz/svg';
|
|
95
162
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const controller = new SimplexSvgController(container, {
|
|
163
|
+
const controller = new SimplexSvgController('#graph', {
|
|
99
164
|
items: myBookmarks,
|
|
100
165
|
getId: (b) => b.url,
|
|
101
166
|
getTags: (b) => b.topics,
|
|
@@ -110,9 +175,9 @@ const controller = new SimplexSvgController(container, {
|
|
|
110
175
|
});
|
|
111
176
|
```
|
|
112
177
|
|
|
113
|
-
### Step 3 —
|
|
178
|
+
### Step 3 — Override Hover, Click & Wheel Interactions
|
|
114
179
|
|
|
115
|
-
Attach
|
|
180
|
+
Attach custom click, context-menu, and wheel policies at any time via `setInteractions`. Setting `interactions.onLeftClick` overrides the default cluster click-focus toggle:
|
|
116
181
|
|
|
117
182
|
```ts
|
|
118
183
|
controller.setInteractions({
|
|
@@ -136,23 +201,7 @@ controller.setInteractions({
|
|
|
136
201
|
});
|
|
137
202
|
```
|
|
138
203
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
Mutate items or reset the camera smoothly at runtime without interrupting user navigation. Call `controller.destroy()` on unmount to stop animations and disconnect observers:
|
|
142
|
-
|
|
143
|
-
```ts
|
|
144
|
-
controller.addItems({
|
|
145
|
-
url: 'https://example.com/oklab',
|
|
146
|
-
title: 'Perceptual Color Mixing',
|
|
147
|
-
topics: ['oklab', 'color-science'],
|
|
148
|
-
minutes: 12,
|
|
149
|
-
});
|
|
150
|
-
controller.removeItems('https://example.com/old');
|
|
151
|
-
controller.camera.reset();
|
|
152
|
-
|
|
153
|
-
// Call on component unmount / teardown:
|
|
154
|
-
// controller.destroy();
|
|
155
|
-
```
|
|
204
|
+
Always call `controller.destroy()` when tearing down your component or view to cancel animations, clean up tooltips, and disconnect `ResizeObserver`.
|
|
156
205
|
|
|
157
206
|
## Built-In `SvgNodeView` Plugins
|
|
158
207
|
|
|
@@ -162,7 +211,6 @@ Renders `'circle' | 'diamond' | 'star' | 'hexagon'` with analytical convex hulls
|
|
|
162
211
|
```ts
|
|
163
212
|
import type { GeometricShapeVisual } from '@simplex-viz/svg';
|
|
164
213
|
|
|
165
|
-
// Descriptor shape:
|
|
166
214
|
const visual: GeometricShapeVisual = {
|
|
167
215
|
shape: 'hexagon', // 'circle' | 'diamond' | 'star' | 'hexagon'
|
|
168
216
|
radius: 11,
|
|
@@ -222,11 +270,10 @@ const visual: ClusterAnchorVisual = {
|
|
|
222
270
|
|
|
223
271
|
Implement `SvgNodeView<TVisual>` centered around local origin `(0, 0)`. `SvgRendererAdapter` handles world positioning `(x, y)`, solver scale `α`, opacity, and crossfading on the parent `<g>`.
|
|
224
272
|
|
|
225
|
-
First, define your visual descriptor and an optional analytical hull via `measureConvexHull` (
|
|
273
|
+
First, define your visual descriptor and an optional analytical hull via `measureConvexHull` (re-exporting `rectToConvexPolygon` straight from `@simplex-viz/svg`, or omit `measureConvexHull` to measure automatically via offscreen `getBBox()`):
|
|
226
274
|
|
|
227
275
|
```ts
|
|
228
|
-
import type
|
|
229
|
-
import { rectToConvexPolygon } from '@simplex-viz/core';
|
|
276
|
+
import { rectToConvexPolygon, type SvgNodeView } from '@simplex-viz/svg';
|
|
230
277
|
|
|
231
278
|
interface CardVisual {
|
|
232
279
|
readonly title: string;
|
|
@@ -280,10 +327,15 @@ export const CustomCardSvgView: SvgNodeView<CardVisual> = {
|
|
|
280
327
|
};
|
|
281
328
|
```
|
|
282
329
|
|
|
283
|
-
## `
|
|
330
|
+
## API Reference (`createSimplexSvg` & `SimplexSvgController`)
|
|
331
|
+
|
|
332
|
+
`SimplexSvgController(target, options)` accepts an `HTMLElement` or CSS selector string. `createSimplexSvg(target, itemsOrOptions)` accepts either a `{ id, tags }` array directly (with `tooltip: true`, cursor zoom, and cluster click-focus enabled) or any `SimplexSvgControllerOptions` object. `@simplex-viz/svg` also re-exports `solveSimplexSnapshot`, geometry hull helpers (`computeConvexHull`, `rectToConvexPolygon`, `regularPolygon`, `starConvexHull`), and core TypeScript types for single-import setups.
|
|
284
333
|
|
|
285
|
-
| Method /
|
|
334
|
+
| Method / Option | Description |
|
|
286
335
|
| --- | --- |
|
|
336
|
+
| `preset` / `setPreset(preset, getLabel?)` | Switches between `'geometric'`, `'glyphs'`, and `'badges'` with smooth transitions. |
|
|
337
|
+
| `tooltip` / `setTooltip(tooltip)` | Enables a floating DOM hover tooltip (`boolean` or `(target) => string` formatter). |
|
|
338
|
+
| `focusOnClusterClick` | Option (default `true`): toggles cluster focus on click when no custom `interactions.onLeftClick` is provided. |
|
|
287
339
|
| `addItems(items)` | Appends one or more items and triggers an interruptible transition. |
|
|
288
340
|
| `removeItems(ids)` | Removes items by ID and smoothly fades out exiting nodes. |
|
|
289
341
|
| `setItems(items)` | Replaces the entire corpus while preserving matching clusters & items. |
|
|
@@ -293,12 +345,12 @@ export const CustomCardSvgView: SvgNodeView<CardVisual> = {
|
|
|
293
345
|
| `setShowHulls(show)` | Toggles convex bounding hull wireframe overlays. |
|
|
294
346
|
| `setPinnedIds(ids)` / `setHighlightedIds(ids)` | Controls pinned and highlighted visual emphasis states. |
|
|
295
347
|
| `setFocusedClusterUid(uid \| null)` | Isolates a cluster and its members, dimming unrelated nodes. |
|
|
296
|
-
| `setInteractions(handlers)` | Replaces pointer, click, and wheel callbacks dynamically. |
|
|
348
|
+
| `setInteractions(handlers)` | Replaces pointer, click, and wheel callbacks dynamically (`onWheel` defaults to `'zoom-to-cursor'`). |
|
|
297
349
|
| `camera` | Exposes `CameraController` (`zoomToCursor`, `panBy`, `reset`, `getState`, `setState`). |
|
|
298
350
|
| `getMetrics()` / `getClusters()` / `getItems()` | Reads live solver telemetry, clusters, and items. |
|
|
299
351
|
| `getSvgElement()` | Returns the managed root `<svg>` element. |
|
|
300
352
|
| `stepForTest(dtMs)` | Deterministically advances simulation time in unit/DOM tests. |
|
|
301
|
-
| `destroy()` | Cancels `requestAnimationFrame`, disconnects `ResizeObserver`,
|
|
353
|
+
| `destroy()` | Cancels `requestAnimationFrame`, disconnects `ResizeObserver`, removes tooltips and `<svg>`. |
|
|
302
354
|
|
|
303
355
|
## License
|
|
304
356
|
|
|
@@ -1,38 +1,63 @@
|
|
|
1
|
-
import { type CameraController, type ClusterDerivationContext, type ClusterDescriptor, type ClusterMetaConfig, type DefaultTaggedItem, type InteractionHandlers, type ItemIdentityConfig, type LayoutMetrics, type LayoutSolverOptions, type MeshOptions, type VisualResolver } from '@simplex-viz/core';
|
|
1
|
+
import { type CameraController, type ClusterDerivationContext, type ClusterDescriptor, type ClusterHoverEvent, type ClusterMetaConfig, type ContentHoverEvent, type DefaultTaggedItem, type InteractionHandlers, type ItemIdentityConfig, type LayoutMetrics, type LayoutSolverOptions, type MeshOptions, type VisualResolver } from '@simplex-viz/core';
|
|
2
|
+
import { type DefaultClusterPresetVisual, type DefaultContentPresetVisual, type SimplexVisualPreset } from './presets';
|
|
2
3
|
import { type SvgRendererOptions } from './SvgRendererAdapter';
|
|
3
|
-
export
|
|
4
|
+
export type SimplexTooltipFormatter<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined> = (target: ({
|
|
5
|
+
readonly kind: 'content';
|
|
6
|
+
} & ContentHoverEvent<TItem, TContentVisual, TTagMeta, TClusterMeta>) | ({
|
|
7
|
+
readonly kind: 'cluster';
|
|
8
|
+
} & ClusterHoverEvent<TItem, TClusterVisual, TTagMeta, TClusterMeta>)) => string;
|
|
9
|
+
export interface SimplexSvgControllerResolvedOptions<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined> {
|
|
4
10
|
readonly items: readonly TItem[];
|
|
5
11
|
readonly getId?: (item: TItem) => string;
|
|
6
12
|
readonly getTags?: (item: TItem) => readonly string[];
|
|
13
|
+
readonly getLabel?: (item: TItem) => string;
|
|
7
14
|
readonly deriveClusterMeta?: (ctx: ClusterDerivationContext<TItem, TTagMeta>) => TClusterMeta;
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
15
|
+
/** Built-in visual preset used when `visualResolver` / views are omitted. Default: `'geometric'`. */
|
|
16
|
+
readonly preset?: SimplexVisualPreset;
|
|
17
|
+
/** Optional custom visual resolver (defaults to the active `preset` resolver). */
|
|
18
|
+
readonly visualResolver?: VisualResolver<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
|
|
19
|
+
/** Optional custom content `SvgNodeView` (defaults to the active `preset` view). */
|
|
20
|
+
readonly contentView?: SvgRendererOptions<TContentVisual, TClusterVisual>['contentView'];
|
|
21
|
+
/** Optional custom cluster `SvgNodeView` (defaults to the active `preset` view). */
|
|
22
|
+
readonly clusterView?: SvgRendererOptions<TContentVisual, TClusterVisual>['clusterView'];
|
|
11
23
|
readonly normalizeTag?: (rawTag: string) => string;
|
|
12
24
|
readonly resolveTagMeta?: (normalizedTag: string) => TTagMeta | undefined;
|
|
13
25
|
readonly meshOptions?: MeshOptions;
|
|
14
26
|
readonly layoutOptions?: LayoutSolverOptions;
|
|
15
27
|
readonly showHulls?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Automatically toggles cluster focus when clicking a topic cluster (and clears on background click)
|
|
30
|
+
* unless a custom `interactions.onLeftClick` handler is provided. Default: `true`.
|
|
31
|
+
*/
|
|
32
|
+
readonly focusOnClusterClick?: boolean;
|
|
33
|
+
/** Enables a built-in floating DOM hover tooltip (or supply a custom text formatter). Default: `false`. */
|
|
34
|
+
readonly tooltip?: boolean | SimplexTooltipFormatter<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
|
|
16
35
|
readonly interactions?: InteractionHandlers<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
|
|
17
36
|
readonly onMetricsChange?: (metrics: LayoutMetrics) => void;
|
|
18
37
|
readonly onClustersChange?: (clusters: readonly ClusterDescriptor<TItem, TTagMeta, TClusterMeta>[]) => void;
|
|
19
38
|
readonly onFpsUpdate?: (fps: number) => void;
|
|
20
39
|
}
|
|
21
|
-
export type SimplexSvgControllerOptions<TItem = DefaultTaggedItem, TContentVisual =
|
|
40
|
+
export type SimplexSvgControllerOptions<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined> = ItemIdentityConfig<TItem> & ClusterMetaConfig<TItem, TTagMeta, TClusterMeta> & Omit<SimplexSvgControllerResolvedOptions<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>, 'getId' | 'getTags' | 'deriveClusterMeta'>;
|
|
22
41
|
/**
|
|
23
42
|
* High-level framework-agnostic SVG graph controller for Vanilla TypeScript, Vue, Angular,
|
|
24
43
|
* Svelte, Web Components, and `@simplex-viz/react`.
|
|
25
44
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
45
|
+
* Works zero-config with `{ items }` via built-in presets, default zoom/pan/focus interactions,
|
|
46
|
+
* and optional tooltips, while remaining 100% customizable through `VisualResolver` and `SvgNodeView`.
|
|
28
47
|
*/
|
|
29
|
-
export declare class SimplexSvgController<TItem = DefaultTaggedItem, TContentVisual =
|
|
48
|
+
export declare class SimplexSvgController<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined> {
|
|
30
49
|
private readonly containerEl;
|
|
31
50
|
private readonly svgEl;
|
|
32
51
|
private readonly adapter;
|
|
33
52
|
private readonly engine;
|
|
34
53
|
private readonly resizeObserver;
|
|
35
54
|
private readonly onFpsUpdate?;
|
|
55
|
+
private readonly focusOnClusterClick;
|
|
56
|
+
private readonly getIdExtractor;
|
|
57
|
+
private getLabelExtractor?;
|
|
58
|
+
private tooltipOption;
|
|
59
|
+
private tooltipEl;
|
|
60
|
+
private focusedClusterUidState;
|
|
36
61
|
private rafId;
|
|
37
62
|
private lastFrameTs;
|
|
38
63
|
private fpsSamples;
|
|
@@ -42,8 +67,14 @@ export declare class SimplexSvgController<TItem = DefaultTaggedItem, TContentVis
|
|
|
42
67
|
private dragStartX;
|
|
43
68
|
private dragStartY;
|
|
44
69
|
private dragMoved;
|
|
45
|
-
constructor(containerEl: HTMLElement, options: SimplexSvgControllerOptions<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>);
|
|
46
|
-
static createFromResolved<TItem = DefaultTaggedItem, TContentVisual =
|
|
70
|
+
constructor(containerEl: HTMLElement | string, options: SimplexSvgControllerOptions<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>);
|
|
71
|
+
static createFromResolved<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined>(containerEl: HTMLElement | string, options: SimplexSvgControllerResolvedOptions<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>): SimplexSvgController<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
|
|
72
|
+
private wrapInteractions;
|
|
73
|
+
private formatContentTooltip;
|
|
74
|
+
private formatClusterTooltip;
|
|
75
|
+
private ensureTooltipElement;
|
|
76
|
+
private showTooltip;
|
|
77
|
+
private hideTooltip;
|
|
47
78
|
get camera(): CameraController;
|
|
48
79
|
getSvgElement(): SVGSVGElement;
|
|
49
80
|
getMetrics(): LayoutMetrics;
|
|
@@ -52,6 +83,12 @@ export declare class SimplexSvgController<TItem = DefaultTaggedItem, TContentVis
|
|
|
52
83
|
addItems(items: TItem | readonly TItem[]): void;
|
|
53
84
|
removeItems(ids: string | readonly string[]): void;
|
|
54
85
|
setItems(items: readonly TItem[]): void;
|
|
86
|
+
/**
|
|
87
|
+
* Switches between built-in presets (`'geometric'`, `'glyphs'`, `'badges'`) with smooth
|
|
88
|
+
* morph/crossfade transitions.
|
|
89
|
+
*/
|
|
90
|
+
setPreset(preset: SimplexVisualPreset, getLabel?: (item: TItem) => string): void;
|
|
91
|
+
setTooltip(tooltip: boolean | SimplexTooltipFormatter<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>): void;
|
|
55
92
|
setVisualResolver(resolver: VisualResolver<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>): void;
|
|
56
93
|
setViews(views: Partial<SvgRendererOptions<TContentVisual, TClusterVisual>>): void;
|
|
57
94
|
setSizeMultiplier(multiplier: number): void;
|
|
@@ -73,6 +110,17 @@ export declare class SimplexSvgController<TItem = DefaultTaggedItem, TContentVis
|
|
|
73
110
|
private attachSvgListeners;
|
|
74
111
|
private detachSvgListeners;
|
|
75
112
|
private ensureLoopRunning;
|
|
113
|
+
/** Helper accessor matching `getId` when external callers inspect items. */
|
|
114
|
+
getItemId(item: TItem): string;
|
|
76
115
|
destroy(): void;
|
|
77
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Convenience one-liner factory for mounting `@simplex-viz/svg` in Vanilla TypeScript,
|
|
119
|
+
* Vue, Angular, Svelte, or Web Components.
|
|
120
|
+
*
|
|
121
|
+
* Accepts either an array of `{ id, tags }` items directly (with built-in presets,
|
|
122
|
+
* cursor zoom, and cluster click-focus enabled) or a full options object.
|
|
123
|
+
*/
|
|
124
|
+
export declare function createSimplexSvg<TItem extends DefaultTaggedItem = DefaultTaggedItem>(target: HTMLElement | string, items: readonly TItem[]): SimplexSvgController<TItem, DefaultContentPresetVisual, DefaultClusterPresetVisual>;
|
|
125
|
+
export declare function createSimplexSvg<TItem = DefaultTaggedItem, TContentVisual = DefaultContentPresetVisual, TClusterVisual = DefaultClusterPresetVisual, TTagMeta = undefined, TClusterMeta = undefined>(target: HTMLElement | string, options: SimplexSvgControllerOptions<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>): SimplexSvgController<TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta>;
|
|
78
126
|
//# sourceMappingURL=SimplexSvgController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimplexSvgController.d.ts","sourceRoot":"","sources":["../src/SimplexSvgController.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,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,GACtB,oBAAoB,CAAC,KAAK,EAAE,0BAA0B,EAAE,0BAA0B,CAAC,CAAC;AACvF,wBAAgB,gBAAgB,CAC9B,KAAK,GAAG,iBAAiB,EACzB,cAAc,GAAG,0BAA0B,EAC3C,cAAc,GAAG,0BAA0B,EAC3C,QAAQ,GAAG,SAAS,EACpB,YAAY,GAAG,SAAS,EAExB,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,OAAO,EAAE,2BAA2B,CAClC,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,YAAY,CACb,GACA,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './hullMeasure';
|
|
3
|
+
export * from './presets';
|
|
3
4
|
export * from './SvgRendererAdapter';
|
|
4
5
|
export * from './SimplexSvgController';
|
|
5
6
|
export * from './views/GeometricShapeSvgView';
|
|
6
7
|
export * from './views/MultiSectorGlyphSvgView';
|
|
7
8
|
export * from './views/BadgeClusterSvgView';
|
|
8
9
|
export * from './views/ClusterAnchorSvgView';
|
|
10
|
+
export { solveSimplexSnapshot, computeConvexHull, rectToConvexPolygon, regularPolygon, starConvexHull, type CameraController, type CameraState, type ClusterDescriptor, type ClusterHoverEvent, type ContentHoverEvent, type ContentLayoutContext, type ConvexGeometry, type DefaultTaggedItem, type HitTarget, type InteractionHandlers, type LayoutMetrics, type LayoutSolverOptions, type MeshOptions, type NodeRenderState, type SimplexLayoutSnapshot, type SimplexSnapshotOptions, type VisualResolver, } from '@simplex-viz/core';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAG7C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC"}
|