Video Figure Design Plan — Shared Infrastructure
Status: Superseded by Video Player Overhaul
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Establish the shared infrastructure (runtime, VTT utilities, pub/sub contracts, cache-busting) needed before decomposing the video-figure.js monolith into three figure components.
Depends on: Nothing (this is Plan 1 of 2).
Task 1: Shared VTT utilities
Files: assets/js/figures/vtt.js, assets/js/figures/tests/vtt.test.js
Extract from assets/js/video-figure.js (lines 991-1058):
- parseVTT(text) — minimal WebVTT parser
- fetchVTT(url) — fetch + parse (promisified)
- formatTime(seconds) — format as m:ss
- escapeHtml(text) — safe HTML escaping (string-based, no DOM)
- parseTimeFragment(str) — parse #t=1m30s to seconds
TDD: 24 unit tests using node:test. Covers multi-cue VTT, JSON cue text,
multi-line cues, comma decimals, \r\n endings, hour timestamps, formatTime
edge cases, escapeHtml XSS, parseTimeFragment variants.
Commit: 8e4999f Extract shared VTT utilities from video-figure.js
Task 2: Shared runtime with config support
Files: assets/js/figures/runtime.js, assets/js/figures/tests/runtime.test.js
Based on regolith version with HTMX cleanup. Changes:
- initFigures(config) accepts optional { base } for manifest + asset resolution
- resolveModuleUrl(modulePath, base, tags) — exported helper for absolute vs relative paths
- propagateTags(importMetaUrl) — exported helper for cache-bust tag extraction
- Tag propagation: /static/ imports get ?tag= from import.meta.url
Commit: Shared figures runtime with config support
Task 3: Pub/sub capability topic contract
Files: assets/js/figures/tests/capabilities.test.js
Contract tests defining the seven topic shapes before implementation:
- Sticky pub/sub for capability objects (late subscriber delivery)
- video.control: { seek, play, pause }
- video.overlay: { drawShape→removeHandle, clearShapes, getAnchor, marginsAvailable }
- video.settings: { addSection(heading, buildFn) }
- video.timeline: { addMarkerLayer, getTrackBounds }
- Data topics: video.playback, video.cues, video.chapters
- Cross-cutting: wireCapabilities delivers capabilities between figures
Commit: Capability topic contract tests for video figures
Task 4: Cache-busting for import() in article markdown
Files: src/almnck/units/views.py, src/tests/test_render_markdown.py
Add one re.sub call to render_markdown() to cache-bust import('/static/js/...')
patterns. The existing regex handles src= and href= attributes; this new regex
handles dynamic import() calls in inline scripts.
Pattern: (import\s*\(\s*['"](/static/js/[^'"?]+))
Commit: Cache-bust import() patterns in article markdown
Task 5: Kropotkin article manifest
Files: editorial/articles/kropotkins-funeral/assets/figures/manifest.json
Declares three figures (video-player, video-annotations, video-scenes),
seven topics, and their publish/subscribe wiring. Configuration only — no code.
Commit: 3f18fa5 Add figure manifest for Kropotkin's Funeral article