3.4 KiB
3.4 KiB
Tasks: enterprise-react-video
Change ID: enterprise-react-video
Package: @suaveplan/react-video
Target path: react/media/react-video
Prerequisite packages on Verdaccio: @suaveplan/error, @suaveplan/react-translate
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Scaffold
- Create directory tree. Write
package.jsonat0.1.0,tsconfig.json,vitest.config.ts, scripts. - Dependencies:
@suaveplan/error workspace:^,@suaveplan/react-translate workspace:^,zod catalog:forms,@opentelemetry/api catalog:observability,tslib catalog:build.
2. Error codes and types
- Define
VideoError; codes:VIDEO_LOAD_FAILED,VIDEO_PLAYBACK_ERROR. - Define
VideoSource,VideoTrack,PlaylistItem,PlaylistProps,VideoControlsProps,VideoPlayerProps. - Write
VideoSourceSchemaZod schema.
3. Utils — formatTime
formatTime(seconds: number): string→'m:ss'or'h:mm:ss'.- Write test + md.
4. Hook — useVideoPlayer
- Manages
videoRef,isPlaying,currentTime,duration,volume,playbackRate,isMuted,isFullscreen. play(),pause(),seek(time),setVolume(vol),setPlaybackRate(rate),mute(),unmute(),enterFullscreen(),exitFullscreen().- Keyboard shortcuts (Space, Left/Right, Up/Down, F) via
keydownlistener on the container ref. - OTel
video.play/video.pausespans. ThrowsVideoError(VIDEO_PLAYBACK_ERROR)onerrorevent. - Write
use-video-player.test.ts(≤500 lines): play/pause/seek/volume/fullscreen/keyboard.{ timeout: 10000 }. - Write
use-video-player.md.
5. Components
VideoControls
- Play/pause button, scrubber (
<input type="range">), volume slider, speed selector, fullscreen button. aria-labelon all controls viauseTranslation.- Write test, stories (default, minimal, playground), md.
VideoPlayer
- Renders
<video>withsourceelements; wiresuseVideoPlayer; optionally rendersVideoControls; acceptstracksfor<track>WebVTT subtitles. - Write test, stories (default, with-playlist, with-subtitles, fullscreen, playground), md.
VideoPlaylist
- Renders playlist items; highlights current; click to switch source.
- Write test, stories, md.
6. E2E
e2e/video.spec.ts— Playwright:- Render
VideoPlayerwith mock src, click play →isPlayingtrue. - Press Space → pause; Left arrow → seek back.
- Render
VideoPlaylist, click second item → source changes.
- Render
7. Verify and publish
bunx turbo lint typecheck test --filter=@suaveplan/react-video— green.bunx turbo test:coverage --filter=@suaveplan/react-video— 100%.bun scripts/publish.ts --package @suaveplan/react-video.- Archive change folder.