diff --git a/.claude/plans/player-api/architecture.md b/.claude/plans/player-api/architecture.md new file mode 100644 index 00000000..aa676bd0 --- /dev/null +++ b/.claude/plans/player-api/architecture.md @@ -0,0 +1,301 @@ +# Architecture + +Internal structure of the Player API. + +## Overview + +``` + createPlayer() + config: presets.website | { features: [...] } + │ + filters by feature.type + │ + ┌───────────────┴───────────────┐ + ▼ ▼ + ┌────────────────────────┐ ┌────────────────────────┐ + │ createStore() │ │ createStore() │ + │ type: 'media' │ │ type: 'player' │ + └────────────────────────┘ └────────────────────────┘ + │ │ + ▼ ▼ + ┌────────────────────────┐ ┌────────────────────────┐ + │ Media Store │◄─────│ Player Store │ + │ target: MediaTarget │ │ target: PlayerTarget │ + │ │ │ │ + │ state: paused, volume │ │ state: isFullscreen │ + │ request: play, pause │ │ request: toggleFS │ + └────────────────────────┘ └────────────────────────┘ + │ + target.media.getFeature() + │ + ┌───────────┴───────────┐ + ▼ ▼ + Read media state Call media requests + (iOS fallback) (keyboard shortcuts) +``` + +**Key insight:** Player Store's target includes a reference to the Media Store. This enables coordination without tight coupling. + +## Two Stores + +### Why Two Stores + +| Reason | Explanation | +| --------------------- | --------------------------------------------------------------------------------------------------- | +| **Different targets** | Media features target `MediaTarget`. Player features target `PlayerTarget`. | +| **Attachment timing** | `