Initial Commit
This commit is contained in:
82
openspec/changes/enterprise-react-video/proposal.md
Normal file
82
openspec/changes/enterprise-react-video/proposal.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# OpenSpec Change: enterprise-react-video
|
||||
|
||||
- **Change ID**: enterprise-react-video
|
||||
- **Package**: `@suaveplan/react-video`
|
||||
- **Category**: react
|
||||
- **Target path**: `react/media/react-video`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/react-video.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/react-video` on genesis from scratch at enterprise quality. Thin React wrapper around the HTML `<video>` element: `VideoPlayer` (multi-source, custom controls, keyboard shortcuts), `VideoControls` (play/pause, scrubber, volume, speed), `VideoPlaylist`, and `useVideoPlayer` hook. Genesis adds accessibility improvements (keyboard shortcuts, `aria-*` on controls), subtitles/captions support, fullscreen API, OTel instrumentation, Storybook stories, and Playwright E2E.
|
||||
|
||||
---
|
||||
|
||||
## Current-state audit (genesis)
|
||||
|
||||
Package does not exist on genesis — fresh build.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps on genesis
|
||||
|
||||
| Package | Role |
|
||||
|---|---|
|
||||
| `@suaveplan/error` (`workspace:^`) | `VideoError` |
|
||||
| `@suaveplan/react-translate` (`workspace:^`) | i18n for control labels |
|
||||
| `zod` (`catalog:forms`) | Source/playlist schemas |
|
||||
| `@opentelemetry/api` (`catalog:observability`) | `video.play` / `video.error` spans |
|
||||
|
||||
External: `tslib catalog:build`. React 18 peer.
|
||||
|
||||
---
|
||||
|
||||
## Preserved public API surface
|
||||
|
||||
```ts
|
||||
VideoPlayer, VideoControls, VideoPlaylist
|
||||
useVideoPlayer (+ UseVideoPlayerReturn)
|
||||
formatTime
|
||||
|
||||
// Types
|
||||
VideoSource, PlaylistItem, PlaylistProps, VideoControlsProps, VideoPlayerProps
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## New additions for genesis
|
||||
|
||||
1. **`VideoError`** — codes: `VIDEO_LOAD_FAILED`, `VIDEO_PLAYBACK_ERROR`.
|
||||
2. **Subtitles/captions** — `VideoPlayer` accepts `tracks?: VideoTrack[]` (WebVTT via `<track>` element).
|
||||
3. **Fullscreen API** — `useVideoPlayer` exposes `enterFullscreen()` / `exitFullscreen()` / `isFullscreen`.
|
||||
4. **Keyboard shortcuts** — Space (play/pause), Left/Right (seek ±5s), Up/Down (volume ±10%), F (fullscreen).
|
||||
5. **OTel spans** — `video.play`, `video.pause`, `video.error`.
|
||||
6. **Stories** — `VideoPlayer` default, with-playlist, with-subtitles, fullscreen, playground.
|
||||
7. **Playwright E2E** — play/pause, seek, playlist navigation.
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
react/media/react-video/
|
||||
package.json
|
||||
tsconfig.json
|
||||
vitest.config.ts
|
||||
src/
|
||||
index.ts
|
||||
components/
|
||||
video-player/ video-controls/ video-playlist/
|
||||
hooks/
|
||||
use-video-player/
|
||||
utils/
|
||||
format-time/
|
||||
types/
|
||||
react-video.types.ts
|
||||
e2e/
|
||||
video.spec.ts
|
||||
```
|
||||
83
openspec/changes/enterprise-react-video/tasks.md
Normal file
83
openspec/changes/enterprise-react-video/tasks.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# 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 status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in 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.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
|
||||
|
||||
## 1. Scaffold
|
||||
|
||||
- [ ] Create directory tree. Write `package.json` at `0.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 `VideoSourceSchema` Zod 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 `keydown` listener on the container ref.
|
||||
- [ ] OTel `video.play` / `video.pause` spans. Throws `VideoError(VIDEO_PLAYBACK_ERROR)` on `error` event.
|
||||
- [ ] 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-label` on all controls via `useTranslation`.
|
||||
- [ ] Write test, stories (default, minimal, playground), md.
|
||||
|
||||
### VideoPlayer
|
||||
|
||||
- [ ] Renders `<video>` with `source` elements; wires `useVideoPlayer`; optionally renders `VideoControls`; accepts `tracks` for `<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 `VideoPlayer` with mock src, click play → `isPlaying` true.
|
||||
- Press Space → pause; Left arrow → seek back.
|
||||
- Render `VideoPlaylist`, click second item → source changes.
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
Reference in New Issue
Block a user