From 462972e736b49ca368e67e541b68c80289ab87ef Mon Sep 17 00:00:00 2001 From: Rahim Date: Thu, 30 Oct 2025 02:55:32 +0000 Subject: [PATCH] chore(root): update architecture docs --- README.md | 2 +- docs/ARCHITECTURE.md | 1290 +--------------------- docs/PLAYBACK_ENGINE_FRAMEWORK_VISION.md | 981 ---------------- 3 files changed, 45 insertions(+), 2228 deletions(-) delete mode 100644 docs/PLAYBACK_ENGINE_FRAMEWORK_VISION.md diff --git a/README.md b/README.md index f32e6525..576f4897 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Modern, modular, and composable media player framework for Web and React. Thanks for checking out the project! It's in its early stages and currently a mix of protoyping and early structure pointing in the direction we want to go with Video.js v10 (so be kind 🙏). +- Read our early [architecture goals](./docs/architecture.md). - Read the [v10 discussion topic](https://github.com/videojs/video.js/discussions/9035) - Watch [Heff's recent presentation](https://players.brightcove.net/3737230800001/eyILA5XG7K_default/index.html?videoId=6379311036112) -- More roadmap and architecture docs to come... ## Documentation diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index d75a2a82..e3ff3d48 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -1,1260 +1,58 @@ -# VJS-10 Architecture & Design Philosophy +# Video.js 10 Architecture -## How to Read This Document +**Status:** Technical Preview (initial working showcase for Demuxed) -This document describes VJS-10's **architectural principles and patterns**, not implementation chronology. +- Current codebase is an early push by the team to have a working showcase for Demuxed. +- Architecture and patterns will evolve as we refine and plan the long‑term structure. -**Status Indicators:** +## Early Goals -- ✅ **Implemented** - Currently exists in codebase with code references -- 🚧 **In Progress** - Partially implemented, under active development -- 📋 **Planned** - Architectural vision, not yet started +- Establish a common, TanStack‑based core for consistent state management across supported platforms and frameworks. +- Ensure composition and compound patterns are first‑class. +- Adopt TypeScript throughout for safety and DX. +- Design for modularity, tree‑shaking, and performance. +- Fully support SSR / hydration. +- Create a compiler to handle transformation and output across multiple JS and CSS frameworks. -**Code References:** +## Core Principles -- File paths link to actual implementation locations -- Examples show real patterns from working code -- Sections without status indicators describe foundational principles +- **Common Core:** TanStack state-driven architecture; DOM lives in a separate package; maps to web, React, and React Native. +- **Composition-first:** Compound component and functional patterns. E.g., React has `render(attrs, state)` prop to allow full control of element type or animations. +- **TypeScript everywhere.** +- **Modular & tree-shakeable.** +- **Performance-focused:** Minimal bundle size and payload, smooth 60+ FPS target. +- **SSR + hydration safe/optimized.** ---- +## Accessibility -## Overview +- Non-negotiable. +- Core owns ARIA roles, labels, navigation, and focus. +- Captions, keyboard navigation/shortcuts, and focus management. +- Meets WCAG 2.2 / CVAA standards out‑of‑box. -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. +## State & Reactivity -## Architectural Influences & Inspirations +- State hooks and components support **controlled/uncontrolled** mode (`value` / `onChange`). +- State-driven architecture powers Web, React, and React‑Native. +- Maintain 16 ms frame budget. +- Offload heavy style computations to CSS. +- Minimal playback engine per user case. +- Stream + lazy caption parsing for large files. +- SSR: preload rendition segments in document head, ship parsed manifest, minimal composed-playback engine for faster TTF (time‑to‑first‑frame). -### Media Elements: Platform-Agnostic HTMLMediaElement Contract +## Styling -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. +- **Style‑agnostic core:** No CSS shipped in Core or Primitives. +- **Style‑ready hooks:** Stable `data-*` attrs and CSS vars for easy theming. +- Default skins in separate exports (optional entry points). +- Primitives avoid Shadow DOM; themed skins may opt in. +- DOM trees stay one level deep per component part (Root, Thumb, Track, etc.). +- No internal JS animations. +- Components toggle data attributes (`data-open`, `data-starting-style`, etc.) for CSS or Motion libraries to hook into. -#### 1. Extended HTMLMediaElement Contract Foundation +## Cross‑Browser Compatibility -**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 `