vizmatic 0.3.2 → 0.4.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.
@@ -0,0 +1,80 @@
1
+ declare const SCENE_RUNTIME_VERSION = "vizmatic-scene/1";
2
+ declare const SCENE_LIMITS: Readonly<{
3
+ sourceBytes: 131072;
4
+ graphBytes: 2097152;
5
+ nodes: 2000;
6
+ depth: 64;
7
+ stringLength: 65536;
8
+ canvasEdge: 1920;
9
+ canvasPixels: 2073600;
10
+ duration: 120;
11
+ frames: 3600;
12
+ memoryBytes: number;
13
+ stackBytes: number;
14
+ evaluationMs: 250;
15
+ }>;
16
+ /** All scene time values, including cues and duration, are in seconds. */
17
+ interface SceneRequest {
18
+ source: string;
19
+ width: number;
20
+ height: number;
21
+ duration: number;
22
+ fps?: number;
23
+ theme?: 'dark' | 'light';
24
+ cues?: Record<string, number>;
25
+ seed?: number;
26
+ }
27
+ interface SceneFrameRequest extends SceneRequest {
28
+ time?: number;
29
+ }
30
+ interface NormalizedSceneRequest {
31
+ source: string;
32
+ width: number;
33
+ height: number;
34
+ duration: number;
35
+ fps: number;
36
+ theme: 'dark' | 'light';
37
+ cues: Record<string, number>;
38
+ seed: number;
39
+ frameCount: number;
40
+ }
41
+ type SceneJson = null | boolean | number | string | SceneJson[] | {
42
+ [key: string]: SceneJson;
43
+ };
44
+ interface SceneElement {
45
+ kind: 'vizmatic.element';
46
+ type: string;
47
+ props: {
48
+ [key: string]: SceneJson;
49
+ };
50
+ children: SceneJson[];
51
+ }
52
+
53
+ /** Explicit names keep the editable scene language separate from the Node API. */
54
+ declare const SCENE_COMPONENT_NAMES: readonly ["Arrow", "ArrowMarkerDef", "AxisPlot", "Badge", "BadgePill", "BarChart", "Board", "Box", "CalloutCard", "Canvas", "CanvasItem", "Card", "ChartFrame", "CodeBlock", "Column", "Comparison", "Connector", "DashedLine", "DataTable", "DataflowDiagram", "DeploymentDiagram", "DetailList", "DonutChart", "DotPoint", "EquationCard", "Flow", "FlowArrow", "GradientChip", "GraphDiagram", "Grid", "Heatmap", "Icon", "IntervalPlot", "KeyValueList", "LayeredNetwork", "Legend", "LineChart", "MathText", "Matrix", "MetricCard", "MiniBarChart", "Panel", "ParetoBarChart", "ParetoChart", "PieChart", "Pipeline", "ProgressList", "ProgressRow", "QuadrantChart", "Row", "ScatterPlot", "Scene", "SequenceDiagram", "Stack", "StackedBar", "StatusList", "StatusRow", "StepCard", "SvgFrame", "SvgMathText", "SvgPoint", "TextLabel", "Tile", "TileGrid", "TiledMatrix", "Timeline", "TitleBar", "ToneStrip", "TransformerTopology", "TreeDiagram", "ValuePill", "VectorArrow", "VectorSegment", "WindowFrame"];
55
+ declare const SCENE_DOM_TAGS: readonly ["div", "span", "p", "strong", "em", "b", "i", "br", "svg", "g", "path", "rect", "circle", "ellipse", "line", "polyline", "polygon", "text", "tspan", "defs", "clipPath", "linearGradient", "radialGradient", "stop", "pattern", "marker", "mask", "title", "desc", "use"];
56
+
57
+ /** Validate after the VM boundary as well as inside it. Nothing executable crosses it. */
58
+ declare function validateSceneGraph(value: unknown): SceneJson;
59
+
60
+ interface EvaluatedSceneFrame {
61
+ graph: SceneJson;
62
+ request: NormalizedSceneRequest;
63
+ time: number;
64
+ runtimeVersion: string;
65
+ sourceSha256: string;
66
+ inputSha256: string;
67
+ }
68
+ declare function prepareSceneSource(source: string): string;
69
+ interface PreparedScene {
70
+ request: NormalizedSceneRequest;
71
+ sourceSha256: string;
72
+ inputSha256: string;
73
+ /** Each call creates a fresh bounded QuickJS runtime, including serialization. */
74
+ evaluate(time?: number): Promise<EvaluatedSceneFrame>;
75
+ }
76
+ declare function prepareScene(request: SceneFrameRequest): Promise<PreparedScene>;
77
+ /** Browser Workers and Node rendering share this exact evaluator and graph contract. */
78
+ declare function evaluateSceneSource(request: SceneFrameRequest): Promise<EvaluatedSceneFrame>;
79
+
80
+ export { type EvaluatedSceneFrame, type NormalizedSceneRequest, type PreparedScene, SCENE_COMPONENT_NAMES, SCENE_DOM_TAGS, SCENE_LIMITS, SCENE_RUNTIME_VERSION, type SceneElement, type SceneFrameRequest, type SceneJson, type SceneRequest, evaluateSceneSource, prepareScene, prepareSceneSource, validateSceneGraph };
@@ -0,0 +1,80 @@
1
+ declare const SCENE_RUNTIME_VERSION = "vizmatic-scene/1";
2
+ declare const SCENE_LIMITS: Readonly<{
3
+ sourceBytes: 131072;
4
+ graphBytes: 2097152;
5
+ nodes: 2000;
6
+ depth: 64;
7
+ stringLength: 65536;
8
+ canvasEdge: 1920;
9
+ canvasPixels: 2073600;
10
+ duration: 120;
11
+ frames: 3600;
12
+ memoryBytes: number;
13
+ stackBytes: number;
14
+ evaluationMs: 250;
15
+ }>;
16
+ /** All scene time values, including cues and duration, are in seconds. */
17
+ interface SceneRequest {
18
+ source: string;
19
+ width: number;
20
+ height: number;
21
+ duration: number;
22
+ fps?: number;
23
+ theme?: 'dark' | 'light';
24
+ cues?: Record<string, number>;
25
+ seed?: number;
26
+ }
27
+ interface SceneFrameRequest extends SceneRequest {
28
+ time?: number;
29
+ }
30
+ interface NormalizedSceneRequest {
31
+ source: string;
32
+ width: number;
33
+ height: number;
34
+ duration: number;
35
+ fps: number;
36
+ theme: 'dark' | 'light';
37
+ cues: Record<string, number>;
38
+ seed: number;
39
+ frameCount: number;
40
+ }
41
+ type SceneJson = null | boolean | number | string | SceneJson[] | {
42
+ [key: string]: SceneJson;
43
+ };
44
+ interface SceneElement {
45
+ kind: 'vizmatic.element';
46
+ type: string;
47
+ props: {
48
+ [key: string]: SceneJson;
49
+ };
50
+ children: SceneJson[];
51
+ }
52
+
53
+ /** Explicit names keep the editable scene language separate from the Node API. */
54
+ declare const SCENE_COMPONENT_NAMES: readonly ["Arrow", "ArrowMarkerDef", "AxisPlot", "Badge", "BadgePill", "BarChart", "Board", "Box", "CalloutCard", "Canvas", "CanvasItem", "Card", "ChartFrame", "CodeBlock", "Column", "Comparison", "Connector", "DashedLine", "DataTable", "DataflowDiagram", "DeploymentDiagram", "DetailList", "DonutChart", "DotPoint", "EquationCard", "Flow", "FlowArrow", "GradientChip", "GraphDiagram", "Grid", "Heatmap", "Icon", "IntervalPlot", "KeyValueList", "LayeredNetwork", "Legend", "LineChart", "MathText", "Matrix", "MetricCard", "MiniBarChart", "Panel", "ParetoBarChart", "ParetoChart", "PieChart", "Pipeline", "ProgressList", "ProgressRow", "QuadrantChart", "Row", "ScatterPlot", "Scene", "SequenceDiagram", "Stack", "StackedBar", "StatusList", "StatusRow", "StepCard", "SvgFrame", "SvgMathText", "SvgPoint", "TextLabel", "Tile", "TileGrid", "TiledMatrix", "Timeline", "TitleBar", "ToneStrip", "TransformerTopology", "TreeDiagram", "ValuePill", "VectorArrow", "VectorSegment", "WindowFrame"];
55
+ declare const SCENE_DOM_TAGS: readonly ["div", "span", "p", "strong", "em", "b", "i", "br", "svg", "g", "path", "rect", "circle", "ellipse", "line", "polyline", "polygon", "text", "tspan", "defs", "clipPath", "linearGradient", "radialGradient", "stop", "pattern", "marker", "mask", "title", "desc", "use"];
56
+
57
+ /** Validate after the VM boundary as well as inside it. Nothing executable crosses it. */
58
+ declare function validateSceneGraph(value: unknown): SceneJson;
59
+
60
+ interface EvaluatedSceneFrame {
61
+ graph: SceneJson;
62
+ request: NormalizedSceneRequest;
63
+ time: number;
64
+ runtimeVersion: string;
65
+ sourceSha256: string;
66
+ inputSha256: string;
67
+ }
68
+ declare function prepareSceneSource(source: string): string;
69
+ interface PreparedScene {
70
+ request: NormalizedSceneRequest;
71
+ sourceSha256: string;
72
+ inputSha256: string;
73
+ /** Each call creates a fresh bounded QuickJS runtime, including serialization. */
74
+ evaluate(time?: number): Promise<EvaluatedSceneFrame>;
75
+ }
76
+ declare function prepareScene(request: SceneFrameRequest): Promise<PreparedScene>;
77
+ /** Browser Workers and Node rendering share this exact evaluator and graph contract. */
78
+ declare function evaluateSceneSource(request: SceneFrameRequest): Promise<EvaluatedSceneFrame>;
79
+
80
+ export { type EvaluatedSceneFrame, type NormalizedSceneRequest, type PreparedScene, SCENE_COMPONENT_NAMES, SCENE_DOM_TAGS, SCENE_LIMITS, SCENE_RUNTIME_VERSION, type SceneElement, type SceneFrameRequest, type SceneJson, type SceneRequest, evaluateSceneSource, prepareScene, prepareSceneSource, validateSceneGraph };
@@ -0,0 +1,20 @@
1
+ import {
2
+ SCENE_COMPONENT_NAMES,
3
+ SCENE_DOM_TAGS,
4
+ SCENE_LIMITS,
5
+ SCENE_RUNTIME_VERSION,
6
+ evaluateSceneSource,
7
+ prepareScene,
8
+ prepareSceneSource,
9
+ validateSceneGraph
10
+ } from "./chunk-FEIPTPBZ.js";
11
+ export {
12
+ SCENE_COMPONENT_NAMES,
13
+ SCENE_DOM_TAGS,
14
+ SCENE_LIMITS,
15
+ SCENE_RUNTIME_VERSION,
16
+ evaluateSceneSource,
17
+ prepareScene,
18
+ prepareSceneSource,
19
+ validateSceneGraph
20
+ };
@@ -0,0 +1,14 @@
1
+ {
2
+ "width": 960,
3
+ "height": 540,
4
+ "duration": 8,
5
+ "fps": 30,
6
+ "theme": "dark",
7
+ "seed": 0,
8
+ "cues": {
9
+ "heat": 1,
10
+ "pressure": 3,
11
+ "release": 5.5
12
+ },
13
+ "source": "const heat = ease(cue('heat', 2));\nconst pressure = ease(cue('pressure', 2));\nconst release = easeOut(cue('release', 1.4));\nfunction Label({x,y,text,color=c.textPrimary,size=24}) { return <text x={x} y={y} fill={color} fontFamily='Inter' fontSize={size} textAnchor='middle'>{text}</text>; }\n<svg width={width} height={height} viewBox='0 0 960 540'>\n <rect width={960} height={540} fill={c.bg}/>\n <Label x={480} y={54} text='An animated mechanism, not a slide' size={32}/>\n <Label x={480} y={97} text='Heat → pressure → release' color={c.textSecondary} size={22}/>\n <rect x={360} y={165} width={240} height={240} rx={35} fill={c.bgCard} stroke={c.border} strokeWidth={3}/>\n <rect x={375} y={lerp(365,245,heat)} width={210} height={lerp(25,145,heat)} rx={20} fill={c.warning} opacity={0.25+heat*0.5}/>\n {Array.from({length:18},(_,i) => {const a=i*2.399; const r=35+(i%4)*17;return <circle key={i} cx={480+Math.cos(a+time*(0.15+heat*0.3))*r} cy={285+Math.sin(a+time*(0.15+heat*0.3))*r*(1-pressure*0.4)} r={5} fill={c.infoLight}/>;})}\n <g opacity={pressure*(1-release)}><VectorArrow x1={420} y1={285} x2={385} y2={285} color={c.warningLight}/><VectorArrow x1={540} y1={285} x2={575} y2={285} color={c.warningLight}/></g>\n <g transform={`translate(0 ${-release*25})`}><rect x={350} y={153} width={260} height={20} rx={10} fill={c.textSecondary}/></g>\n <g opacity={release}><VectorArrow x1={455} y1={230} x2={455} y2={115+release*5} color={c.infoLight}/><VectorArrow x1={505} y1={230} x2={505} y2={115+release*5} color={c.infoLight}/></g>\n <Label x={480} y={456} text={release>0.1?'Release changes the system':pressure>0.1?'Pressure rises inside the container':'Heat drives particle motion'} size={25}/>\n <rect x={180} y={487} width={600} height={5} rx={2} fill={c.border}/><rect x={180} y={487} width={600*progress} height={5} rx={2} fill={c.info}/>\n</svg>"
14
+ }
@@ -0,0 +1,28 @@
1
+ # Video examples
2
+
3
+ These TSX modules define finite videos with `createAnimation(theme)`. Each is a
4
+ generic example that depends on the published Vizmatic package.
5
+
6
+ - [`request-lifecycle.tsx`](request-lifecycle.tsx) is a short starter. It moves
7
+ one request through receive, process, and return stages.
8
+ - [`signal-to-story.tsx`](signal-to-story.tsx) is a longer example. It adds
9
+ observations to a chart, traces a fitted line, and holds the result on screen.
10
+
11
+ Use Node.js 20 or newer. In a project that contains the downloaded or copied
12
+ TSX file, install Vizmatic and React:
13
+
14
+ ```bash
15
+ npm install --save-dev vizmatic@0.4.0 react
16
+ npx vizmatic video ./request-lifecycle.tsx --out ./dist/videos --theme dark --fps 30
17
+ ```
18
+
19
+ Install [FFmpeg](https://ffmpeg.org/download.html) separately and confirm it
20
+ includes the `libx264` encoder. To add a narration track, use
21
+ `--audio ./narration.wav`; the FFmpeg build must also include AAC. Vizmatic pads
22
+ or trims audio to the animation duration. Keep `.vtt` or `.srt` captions as
23
+ sidecar files and align their cues to the final timeline.
24
+
25
+ The CLI writes `request-lifecycle_dark.mp4` and `video-manifest.json` under the
26
+ output directory. Pass `--theme dark,light` to render both theme variants. Video
27
+ rendering runs in Node.js and requires an opaque background. Canvas width and
28
+ height after scaling must be even numbers.
@@ -0,0 +1,99 @@
1
+ import {
2
+ defineAnimation,
3
+ getThemeColors,
4
+ hold,
5
+ tween,
6
+ type ThemeMode,
7
+ } from 'vizmatic'
8
+
9
+ export const width = 1280
10
+ export const height = 720
11
+
12
+ type State = { progress: number }
13
+
14
+ const stages = [
15
+ { label: '01', title: 'Receive', detail: 'Accept the request', x: 110 },
16
+ { label: '02', title: 'Process', detail: 'Do the work', x: 490 },
17
+ { label: '03', title: 'Return', detail: 'Send the result', x: 870 },
18
+ ] as const
19
+
20
+ function buildFrame(theme: ThemeMode, progress: number) {
21
+ const c = getThemeColors(theme)
22
+ const markerX = 260 + progress * 760
23
+ const complete = progress > 0.94
24
+
25
+ return (
26
+ <div style={{
27
+ display: 'flex', position: 'relative', width, height, overflow: 'hidden',
28
+ backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans,
29
+ }}>
30
+ <div style={{ display: 'flex', position: 'absolute', left: 96, top: 84, flexDirection: 'column', gap: 14 }}>
31
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 16, letterSpacing: 2 }}>A REQUEST IN MOTION</span>
32
+ <span style={{ fontSize: 52, fontWeight: 750, letterSpacing: -1.5 }}>One request. Three steps.</span>
33
+ <span style={{ color: c.textSecondary, fontSize: 22 }}>Follow it from arrival to the result.</span>
34
+ </div>
35
+
36
+ {stages.map((stage, index) => {
37
+ const active = Math.min(2, Math.round(progress * 2)) === index
38
+ return (
39
+ <div key={stage.label} style={{
40
+ display: 'flex', position: 'absolute', left: stage.x, top: 276,
41
+ width: 300, height: 158, flexDirection: 'column', justifyContent: 'center',
42
+ gap: 14, padding: '0 26px', borderRadius: 18,
43
+ backgroundColor: active ? c.bgCard : c.bgCardAlt,
44
+ border: `2px solid ${active ? c.primary : c.borderSubtle}`,
45
+ }}>
46
+ <span style={{ color: active ? c.textPrimary : c.textMuted, fontFamily: c.fontMono, fontSize: 14, letterSpacing: 1.5 }}>{stage.label}</span>
47
+ <span style={{ fontSize: 28, fontWeight: 700 }}>{stage.title}</span>
48
+ <span style={{ color: c.textSecondary, fontSize: 17 }}>{stage.detail}</span>
49
+ </div>
50
+ )
51
+ })}
52
+
53
+ <div style={{ display: 'flex', position: 'absolute', left: 260, top: 510, width: 760, height: 4, backgroundColor: c.borderSubtle }} />
54
+ {[260, 640, 1020].map((x, index) => (
55
+ <div key={x} style={{
56
+ display: 'flex', position: 'absolute', left: x - 7, top: 502,
57
+ width: 18, height: 18, borderRadius: 18,
58
+ backgroundColor: progress >= index / 2 ? c.positive : c.bg,
59
+ border: `2px solid ${progress >= index / 2 ? c.positive : c.borderLight}`,
60
+ }} />
61
+ ))}
62
+
63
+ <div style={{
64
+ display: 'flex', position: 'absolute', left: markerX - 66, top: 468,
65
+ minWidth: 132, height: 42, alignItems: 'center', justifyContent: 'center',
66
+ borderRadius: 21, padding: '0 14px', color: c.textOnColor,
67
+ backgroundColor: complete ? c.positiveDark : c.secondaryDark,
68
+ fontFamily: c.fontMono, fontSize: 15, fontWeight: 700,
69
+ }}>{complete ? 'RESULT READY' : 'REQUEST'}</div>
70
+
71
+ <div style={{
72
+ display: 'flex', position: 'absolute', left: 0, right: 0, top: 594,
73
+ justifyContent: 'center', color: c.textPrimary,
74
+ fontSize: 22, fontWeight: complete ? 700 : 500,
75
+ }}>{complete ? 'The result returns to the caller.' : 'The request advances through the workflow.'}</div>
76
+ </div>
77
+ )
78
+ }
79
+
80
+ export function create(theme: ThemeMode = 'dark') {
81
+ return buildFrame(theme, 1)
82
+ }
83
+
84
+ export function createAnimation(theme: ThemeMode) {
85
+ return defineAnimation<State>({
86
+ initial: { progress: 0 },
87
+ timeline: [
88
+ hold(900, 'Follow the request'),
89
+ tween({ progress: 0.5 }, { duration: 1800, easing: 'ease-in-out', label: 'Process the request' }),
90
+ hold(500, 'Work completes'),
91
+ tween({ progress: 1 }, { duration: 1800, easing: 'ease-in-out', label: 'Return the result' }),
92
+ hold(1600, 'Read the completed workflow'),
93
+ ],
94
+ fps: 30,
95
+ render: (state) => buildFrame(theme, state.progress),
96
+ })
97
+ }
98
+
99
+ export default create('dark')
@@ -0,0 +1,126 @@
1
+ import {
2
+ defineAnimation,
3
+ hold,
4
+ parallel,
5
+ pointAlongPath,
6
+ smoothstep,
7
+ tracePolyline,
8
+ tween,
9
+ type ThemeMode,
10
+ } from 'vizmatic'
11
+
12
+ export const width = 1280
13
+ export const height = 720
14
+
15
+ type State = { intro: number; observations: number; trace: number; cursor: number; focus: number; camera: number; outro: number }
16
+
17
+ // Synthetic observations and their least-squares fit, not measured performance.
18
+ const values = [34, 51, 39, 67, 53, 79, 61, 88, 77, 105, 94, 115]
19
+ const meanX = (values.length - 1) / 2
20
+ const meanY = values.reduce((sum, value) => sum + value, 0) / values.length
21
+ export const slope = values.reduce((sum, value, index) => sum + (index - meanX) * (value - meanY), 0)
22
+ / values.reduce((sum, _, index) => sum + (index - meanX) ** 2, 0)
23
+ const intercept = meanY - slope * meanX
24
+ const plot = { left: 136, top: 284, width: 1008, height: 286 }
25
+ const xAt = (index: number) => plot.left + index * plot.width / (values.length - 1)
26
+ const yAt = (value: number) => plot.top + plot.height - (value - 20) / 110 * plot.height
27
+ const trend = values.map((_, index) => ({ x: xAt(index), y: yAt(intercept + slope * index) }))
28
+
29
+ function buildFrame(theme: ThemeMode, state: State) {
30
+ const dark = theme === 'dark'
31
+ const c = dark
32
+ ? { bg: '#0a191e', surface: '#10272e', text: '#edf6ee', muted: '#a4bbbd', line: '#25434a', mint: '#a5f2c6', gold: '#f3ca79', orange: '#ffad8a' }
33
+ : { bg: '#f3f5ec', surface: '#e5ecdf', text: '#17353a', muted: '#506b6c', line: '#cad8ce', mint: '#19744d', gold: '#926317', orange: '#a84d32' }
34
+ const visible = tracePolyline(trend, state.trace)
35
+ const marker = pointAlongPath(trend, state.cursor)
36
+ const chartOpacity = (1 - state.outro) * Math.min(1, state.observations * 4)
37
+ const chapter = state.focus > 0.2 ? '03 / MAKE IT MEAN SOMETHING' : state.trace > 0 ? '02 / REVEAL THE RELATIONSHIP' : '01 / START WITH THE OBSERVATIONS'
38
+ const headline = state.focus > 0.2 ? 'A relationship you can see.' : state.trace > 0 ? 'Let the pattern emerge.' : 'Every point has a story.'
39
+
40
+ return (
41
+ <div style={{ display: 'flex', position: 'relative', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.text, fontFamily: 'Inter' }}>
42
+ <div style={{ display: 'flex', position: 'absolute', left: 760, top: 80, width: 520, height: 520, borderRadius: 520, backgroundImage: `radial-gradient(circle, ${c.surface}, ${c.bg})` }} />
43
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 38, right: 64, alignItems: 'center', justifyContent: 'space-between' }}>
44
+ <div style={{ display: 'flex', alignItems: 'center', gap: 12, fontSize: 18, fontWeight: 700, letterSpacing: -0.5 }}><span style={{ display: 'flex', width: 12, height: 12, borderRadius: 4, backgroundColor: c.mint, transform: 'rotate(-12deg)' }} />vizmatic</div>
45
+ <span style={{ color: c.muted, fontSize: 12, letterSpacing: 2, fontFamily: 'JetBrains Mono' }}>A STUDY IN MOTION / 001</span>
46
+ </div>
47
+
48
+ {state.intro > 0 && <div style={{ display: 'flex', position: 'absolute', left: 90, top: 176 - 24 * state.intro, flexDirection: 'column', opacity: state.intro }}>
49
+ <span style={{ color: c.mint, fontFamily: 'JetBrains Mono', fontSize: 14, letterSpacing: 3, marginBottom: 24 }}>FROM NOISE TO SIGNAL</span>
50
+ <div style={{ display: 'flex', flexDirection: 'column', fontSize: 104, fontWeight: 700, lineHeight: 1.06, letterSpacing: -6 }}><span>Make the</span><span style={{ color: c.mint }}>invisible click.</span></div>
51
+ <span style={{ color: c.muted, marginTop: 28, fontSize: 22 }}>One scene. A little math. A story that moves.</span>
52
+ </div>}
53
+
54
+ {chartOpacity > 0 && <div style={{ display: 'flex', position: 'absolute', inset: 0, opacity: chartOpacity, transform: `scale(${1 + state.camera * 0.035})` }}>
55
+ <div style={{ display: 'flex', position: 'absolute', left: 90, top: 124, flexDirection: 'column', gap: 16 }}>
56
+ <span style={{ color: c.mint, fontFamily: 'JetBrains Mono', fontSize: 13, letterSpacing: 2 }}>{chapter}</span>
57
+ <span style={{ fontSize: 47, fontWeight: 700, letterSpacing: -2 }}>{headline}</span>
58
+ </div>
59
+ {[20, 50, 80, 110].map((value) => <div key={value} style={{ display: 'flex', position: 'absolute', left: plot.left, top: yAt(value), width: plot.width, height: 1, backgroundColor: c.line }} />)}
60
+ {[20, 50, 80, 110].map((value) => <span key={`label-${value}`} style={{ position: 'absolute', left: 87, top: yAt(value) - 8, color: c.muted, fontSize: 12, fontFamily: 'JetBrains Mono' }}>{value}</span>)}
61
+ <span style={{ position: 'absolute', left: plot.left, top: 600, color: c.muted, fontSize: 12, fontFamily: 'JetBrains Mono' }}>01</span>
62
+ <span style={{ position: 'absolute', right: 136, top: 600, color: c.muted, fontSize: 12, fontFamily: 'JetBrains Mono' }}>12 OBSERVATIONS</span>
63
+ {values.map((value, index) => {
64
+ const arrival = smoothstep(Math.min(1, Math.max(0, state.observations * 1.9 - index * 0.075)))
65
+ return <div key={index} style={{ display: 'flex', position: 'absolute', left: xAt(index) - 7, top: yAt(value) - 7 + 52 * (1 - arrival), width: 14, height: 14, borderRadius: 14, backgroundColor: c.gold, opacity: arrival * (1 - state.focus * 0.35) }} />
66
+ })}
67
+ {visible.length > 1 && <svg style={{ position: 'absolute', left: 0, top: 0 }} width={width} height={height} viewBox={`0 0 ${width} ${height}`}><polyline points={visible.map(({ x, y }) => `${x},${y}`).join(' ')} fill="none" stroke={c.mint} strokeWidth="5" strokeLinecap="round" strokeLinejoin="round" /></svg>}
68
+ {state.trace > 0 && <div style={{ display: 'flex', position: 'absolute', left: marker.x - 9, top: marker.y - 9, width: 18, height: 18, borderRadius: 18, backgroundColor: c.mint, border: `4px solid ${c.bg}` }} />}
69
+ <div style={{ display: 'flex', position: 'absolute', left: 688, top: 488 - 12 * state.focus, flexDirection: 'column', gap: 9, padding: '18px 24px', borderRadius: 12, backgroundColor: c.surface, opacity: state.focus }}>
70
+ <span style={{ color: c.mint, fontSize: 28, fontWeight: 700 }}>+{slope.toFixed(1)} per observation</span>
71
+ <span style={{ color: c.muted, fontSize: 14 }}>Least-squares trend. Every point still visible.</span>
72
+ </div>
73
+ </div>}
74
+
75
+ {state.outro > 0 && <div style={{ display: 'flex', position: 'absolute', inset: 0, backgroundColor: c.bg, opacity: state.outro, alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
76
+ <span style={{ color: c.mint, fontFamily: 'JetBrains Mono', fontSize: 14, letterSpacing: 3, marginBottom: 26 }}>FROM CODE TO CLARITY</span>
77
+ <span style={{ fontSize: 85, fontWeight: 700, letterSpacing: -5 }}>Give your ideas</span>
78
+ <span style={{ color: c.mint, fontSize: 85, fontWeight: 700, letterSpacing: -5 }}>a little motion.</span>
79
+ <div style={{ display: 'flex', gap: 28, marginTop: 32, color: c.muted, fontSize: 17 }}><span>Editable TSX</span><span style={{ color: c.orange }}>→</span><span>Typed timelines</span><span style={{ color: c.orange }}>→</span><span>Your next film</span></div>
80
+ <span style={{ marginTop: 42, color: c.muted, fontFamily: 'JetBrains Mono', fontSize: 14 }}>vizmatic / bvolpato.github.io/vizmatic</span>
81
+ </div>}
82
+
83
+ <div style={{ display: 'flex', position: 'absolute', left: 64, right: 64, bottom: 32, justifyContent: 'space-between', alignItems: 'center', color: c.muted, fontFamily: 'JetBrains Mono', fontSize: 11 }}>
84
+ <span>DESIGNED IN CODE. RENDERED FRAME BY FRAME.</span><span>SYNTHETIC DATA / REAL MOTION</span>
85
+ </div>
86
+ </div>
87
+ )
88
+ }
89
+
90
+ export function createAnimation(theme: ThemeMode = 'dark') {
91
+ return defineAnimation<State>({
92
+ initial: { intro: 0, observations: 0, trace: 0, cursor: 0, focus: 0, camera: 0, outro: 0 },
93
+ timeline: [
94
+ tween({ intro: 1 }, { duration: 700, easing: 'ease-out' }),
95
+ hold(1300, 'Make the invisible click'),
96
+ parallel<State>({
97
+ intro: [tween(0, { duration: 650, easing: 'ease-in-out' })],
98
+ observations: [hold(350), tween(1, { duration: 2050, easing: 'ease-out' })],
99
+ }, 'Collect observations'),
100
+ hold(600),
101
+ parallel<State>({
102
+ trace: [tween(1, { duration: 3600, easing: 'ease-in-out' })],
103
+ cursor: [tween(1, { duration: 3600, easing: 'ease-in-out' })],
104
+ }, 'Reveal the trend'),
105
+ hold(800),
106
+ parallel<State>({
107
+ focus: [tween(1, { duration: 1000, easing: 'ease-out' })],
108
+ camera: [tween(1, { duration: 1600, easing: 'ease-in-out' })],
109
+ }, 'Explain the relationship'),
110
+ hold(2200),
111
+ parallel<State>({
112
+ camera: [tween(0, { duration: 1000, easing: 'ease-in-out' })],
113
+ outro: [hold(400), tween(1, { duration: 1200, easing: 'ease-in-out' })],
114
+ }, 'From code to clarity'),
115
+ hold(3200),
116
+ ],
117
+ fps: 20,
118
+ render: (state) => buildFrame(theme, state),
119
+ })
120
+ }
121
+
122
+ export function create(theme: ThemeMode = 'dark') {
123
+ return buildFrame(theme, { intro: 1, observations: 0, trace: 0, cursor: 0, focus: 0, camera: 0, outro: 0 })
124
+ }
125
+
126
+ export default create('dark')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vizmatic",
3
- "version": "0.3.2",
4
- "description": "Theme-aware visual primitives and a headless renderer for diagrams, figures, and presentation frames.",
3
+ "version": "0.4.0",
4
+ "description": "Theme-aware diagrams, charts, animations, and MP4 video from TSX.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Bruno Volpato",
@@ -27,6 +27,9 @@
27
27
  "react",
28
28
  "diagrams",
29
29
  "presentations",
30
+ "animation",
31
+ "video",
32
+ "mp4",
30
33
  "theme-aware",
31
34
  "ai-agents",
32
35
  "structured-visuals"
@@ -57,13 +60,18 @@
57
60
  "types": "./dist/index.d.cts",
58
61
  "default": "./dist/index.cjs"
59
62
  }
63
+ },
64
+ "./scene-runtime": {
65
+ "import": { "types": "./dist/scene-runtime.d.ts", "default": "./dist/scene-runtime.js" },
66
+ "require": { "types": "./dist/scene-runtime.d.cts", "default": "./dist/scene-runtime.cjs" }
60
67
  }
61
68
  },
62
69
  "bin": {
63
- "vizmatic": "dist/cli.js"
70
+ "vizmatic": "dist/cli.js",
71
+ "vizmatic-scene": "dist/scene-cli.js"
64
72
  },
65
73
  "scripts": {
66
- "build": "tsup src/index.ts --format esm --dts --target node20 --clean --external react && tsup src/index.ts --format cjs --dts --target node20 --external react --define.import.meta.url undefined && tsup src/cli.ts --format esm --dts --target node20 --external react --minify-whitespace",
74
+ "build": "tsup src/index.ts src/scene-runtime.ts --format esm --dts --target node20 --clean --external react && tsup src/index.ts src/scene-runtime.ts --format cjs --dts --target node20 --external react --define.import.meta.url undefined && tsup src/cli.ts src/scene-cli.ts --format esm --dts --target node20 --external react --minify-whitespace",
67
75
  "assets:emoji": "node scripts/build-emoji-bundle.mjs",
68
76
  "assets:check": "node scripts/build-emoji-bundle.mjs --check",
69
77
  "prepare": "pnpm build",
@@ -71,6 +79,7 @@
71
79
  "typecheck": "tsc --noEmit",
72
80
  "test": "pnpm build && vitest run",
73
81
  "render:examples": "pnpm build && tsx scripts/render-examples.ts && pnpm site:build",
82
+ "render:video": "pnpm build && tsx scripts/render-video-example.ts",
74
83
  "benchmark:quality": "pnpm build && tsx scripts/benchmark-quality.ts && pnpm site:build",
75
84
  "check:examples": "tsx scripts/check-examples.ts",
76
85
  "playground:build": "tsx scripts/build-playground.ts",
@@ -90,9 +99,12 @@
90
99
  "@dagrejs/dagre": "3.1.1",
91
100
  "@resvg/resvg-js": "^2.6.2",
92
101
  "gifenc": "^1.0.3",
102
+ "mathjax-full": "3.2.2",
93
103
  "parse-css-color": "0.2.1",
104
+ "quickjs-emscripten": "0.32.0",
94
105
  "react": "^19.2.8",
95
- "satori": "0.35.0",
106
+ "satori": "0.41.0",
107
+ "sucrase": "3.35.1",
96
108
  "tsx": "^4.23.12"
97
109
  },
98
110
  "peerDependencies": {
@@ -105,10 +117,9 @@
105
117
  "esbuild": "0.28.2",
106
118
  "github-actionlint": "1.7.12",
107
119
  "harfbuzzjs": "0.10.0",
108
- "playwright": "1.63.0",
120
+ "playwright": "1.64.0",
109
121
  "publint": "0.3.25",
110
122
  "shiki": "^4.5.0",
111
- "sucrase": "3.35.1",
112
123
  "tsup": "^8.5.1",
113
124
  "typescript": ">=6.0.3 <7",
114
125
  "vitest": "^5.0.3"