The WebGL visualizer registry is now fully auto-generated from a single JSON metadata file, eliminating manual duplication and ensuring type safety.
webgl-metadata.json ← Single source of truth
↓
scripts/generate-webgl-registry.ts ← Generator script
↓
src/_generated/webgl/
├── registry.ts ← WebGLVisualiserId type + WEBGL_VISUALIZERS object
└── index.ts ← Barrel export
↓
src/components/Visualisers/WebGLVisualiser.tsx ← Imports generated type
src/webgl/registry.ts ← Imports generated registry
- Add entry to
webgl-metadata.json:
{
"visualizers": {
"myneweffect": {
"displayName": "My New Effect",
"category": "Original Effects",
"description": "Amazing new visualization",
"aliases": ["amazing", "new"],
"tags": ["3d", "particle", "audio-reactive"]
}
}
}- Regenerate types:
pnpm generate:webgl
# or just
pnpm generate # (runs both schema + webgl generators)- Implement shader:
Add shader to src/engines/webgl/shaders/effects.ts and export from index.ts.
- Add case to WebGLVisualiser.tsx:
case 'myneweffect':
drawCustom(gl, smoothedData, width, height)
breakThat's it! TypeScript will enforce type safety everywhere.
Exports:
WebGLVisualiserId- Union type of all visualizer IDsWebGLVisualizerMetadata- Interface for metadata structureWEBGL_VISUALIZERS- Const object with all metadatagetWebGLVisualizerIds()- Get all IDs as arraygetWebGLVisualizerMetadata(id)- Get metadata by IDisWebGLVisualizer(id)- Type guard
Each visualizer entry requires:
{
displayName: string // Human-readable name
category: string // Category for grouping
description: string // Brief description
aliases?: string[] // Alternative names for search
tags?: string[] // Searchable tags
}Current categories:
- Original Effects - Custom frontend shaders (10)
- 2D Effects - Simple 2D visualizations (4)
- Matrix Effects - LED matrix effects (14)
The generator runs automatically during:
pnpm dev(via predev hook)pnpm build(via prebuild hook)pnpm generate(manually)pnpm generate:webgl(webgl only)
Before Auto-Generation:
- 🔴 Manual
WEBGL_VISUALIZERSobject (44 lines) - 🔴 Manual
WebGLVisualisationTypeunion (28 lines) - 🔴 Hardcoded aliases in
createDisplayNameMap() ⚠️ Easy to get out of sync
After Auto-Generation:
- ✅ Single JSON source of truth
- ✅ Generated types & registry
- ✅ Automatic alias handling
- ✅ Never out of sync
- ✅ 28 visualizers tracked
- ✅ 3 categories
- ✅ Extensible with metadata
- Single Source of Truth - Edit one JSON file
- Type Safety - TypeScript enforces correctness
- Auto-Sync - Types always match metadata
- Rich Metadata - Categories, tags, descriptions, aliases
- Searchability - Aliases auto-registered for search
- Documentation - Self-documenting via metadata
- Consistency - Same pattern as schema-first visualizers
This complements the existing auto-generation systems:
- Schema-First Visualizers (10) →
schemas/*.schema.ts→src/_generated/ - Backend Twod Effects (17) → GitHub API →
src/_generated/webgl/ - WebGL Visualizers (28) →
webgl-metadata.json→src/_generated/webgl/
Total: 55 visualizers with zero manual duplication! 🎉
- GENERATORS.md - Overview of all 3 generator systems
- BACKEND-SCHEMA-GENERATION.md - Backend effect generation
- ARCHITECTURE.md - Overall project architecture