Types
This page documents the public TypeScript types you’ll most commonly touch when using VizCraft.
All types shown here are exported from vizcraft and can be imported as import type { ... } from 'vizcraft'.
VizScene
A scene is the complete, serializable description of what to render.
Shape
viewBox: { w: number; h: number }— the SVG coordinate space.nodes: VizNode[]— nodes to render.edges: VizEdge[]— edges to render.overlays?: VizOverlaySpec[]— optional overlay layer.animationSpecs?: AnimationSpec[]— optional data-only timelines compiled viabuilder.animate(...).
VizNode
A node in the scene graph.
Key properties
id: string— unique id.pos: { x: number; y: number }— base position.shape: NodeShape— geometry.label?: NodeLabel— optional text label.style?: { fill?: string; stroke?: string; strokeWidth?: number; opacity?: number }— base styling.className?: string— extra CSS class.runtime?: VizRuntimeNodeProps— runtime-only overrides (what the animation system writes).animations?: VizAnimSpec[]— registry/CSS animation requests (e.g.pulse,flow).data?: unknown— your payload.
VizEdge
An edge connecting two nodes.
Key properties
id: string— unique id (commonly"a->b").from: string/to: string— node ids.markerEnd?: 'arrow' | 'none'— arrow head.anchor?: 'center' | 'boundary'— connection behavior.runtime?: VizRuntimeEdgeProps— runtime-only overrides (what the animation system writes).animations?: VizAnimSpec[]— registry/CSS animation requests.data?: unknown— your payload.
NodeShape
Supported node geometry.
{ kind: 'circle'; r: number }{ kind: 'rect'; w: number; h: number; rx?: number }{ kind: 'diamond'; w: number; h: number }
VizRuntimeNodeProps
Numeric properties the core runtime patcher knows how to apply for nodes.
x?: numbery?: numberopacity?: numberscale?: numberrotation?: number
VizRuntimeEdgeProps
Numeric properties the core runtime patcher knows how to apply for edges.
strokeDashoffset?: numberopacity?: number
AnimationSpec
A portable, data-only timeline.
An AnimationSpec is what builder.animate((aBuilder) => ...) compiles to, and what the player executes.
Shape
version: 'viz-anim/1'tweens: TweenSpec[]
TweenSpec
A single numeric tween.
Shape
kind: 'tween'target: AnimationTargetproperty: AnimPropertyto: numberduration: number(ms)delay?: number(ms)easing?: Easefrom?: number— optional explicit start value.
AnimationTarget
Identifies what you’re animating.
- Nodes use the form
node:<id>. - Edges use the form
edge:<id>(commonlyedge:a->b).
AnimProperty
The property name being animated.
- Core properties are listed in
CoreAnimProperty. - You can also use any other string property name, as long as the playback adapter registers handlers for it.
CoreAnimProperty
Properties supported out-of-the-box by the core adapter.
- Nodes:
x,y,opacity,scale,rotation - Edges:
opacity,strokeDashoffset
Ease
Built-in easing names.
lineareaseIneaseOuteaseInOut
AnimatableProps
The property bag you pass to aBuilder.to(...).
- It hints core properties in TypeScript.
- It also permits arbitrary numeric keys (for custom properties).
TweenOptions
Options you pass to aBuilder.to(props, opts).
duration: number(ms)easing?: Easefrom?: Partial<Record<AnimProperty, number>>— per-property explicit start values.
PlaybackController
Controller returned by builder.play() and playAnimationSpec(...).
Common methods:
play()pause()stop()
ExtendAdapter (advanced)
Callback used to register custom animatable properties.
Signature
(adapter: AnimationHostAdapter & Partial<RegistrableAdapter>) => void
You’ll typically use it via aBuilder.extendAdapter((adapter) => { adapter.register?.(...) }).
AnimationHostAdapter and RegistrableAdapter (advanced)
These are the low-level interfaces the player uses to read/write properties.
AnimationHostAdapter— must implementget(target, prop)andset(target, prop, value).RegistrableAdapter— optional capability that exposesregister(kind, prop, { get, set }).