# VJS-10 Architecture & Design Philosophy ## How to Read This Document This document describes VJS-10's **architectural principles and patterns**, not implementation chronology. **Status Indicators:** - βœ… **Implemented** - Currently exists in codebase with code references - 🚧 **In Progress** - Partially implemented, under active development - πŸ“‹ **Planned** - Architectural vision, not yet started **Code References:** - File paths link to actual implementation locations - Examples show real patterns from working code - Sections without status indicators describe foundational principles --- ## Overview VJS-10 is a media player component library that prioritizes platform-native development experiences while maintaining shared core logic. This document outlines the design philosophy, architectural influences, and key decisions that shape the VJS-10 ecosystem. ## Architectural Influences & Inspirations ### Media Elements: Platform-Agnostic HTMLMediaElement Contract VJS-10's media state management architecture uses patterns from the [media-elements monorepo](https://github.com/muxinc/media-elements) for creating HTMLMediaElement-compatible elements that work across different media providers while maintaining consistent interfaces. #### 1. Extended HTMLMediaElement Contract Foundation **Media Elements Pattern**: The media-elements monorepo established the pattern of creating custom elements that "look like" HTMLMediaElement but can be extended for different media providers (HLS, DASH, YouTube, Vimeo, etc.). **Core Architecture Pattern**: ```typescript // Media Elements: CustomVideoElement extends HTMLElement, wraps native video // (Safari doesn't support extending built-in elements like HTMLVideoElement) export class CustomVideoElement extends HTMLElement { readonly nativeEl: HTMLVideoElement; // Wrapped native element in shadow DOM // Proxies HTMLMediaElement properties to wrapped native element get currentTime() { return this.nativeEl?.currentTime ?? 0; } set currentTime(val) { if (this.nativeEl) this.nativeEl.currentTime = val; } play(): Promise { return this.nativeEl?.play() ?? Promise.resolve(); } pause(): void { this.nativeEl?.pause(); } } // Provider-specific implementations class HlsVideoElement extends CustomVideoElement { api: Hls | null = null; async load() { if (Hls.isSupported()) { this.api = new Hls(this.config); this.api.loadSource(this.src); this.api.attachMedia(this.nativeEl); // Native video wrapped in shadow DOM } } } ``` **Key Architectural Assumptions**: - Must extend `HTMLElement` (Safari limitation prevents extending built-in elements) - Wraps native `