How eatdesignlove/react-video-timestone works
Project type and purpose
• This is a React component library (“react-video-timestone”) that provides a multi‐video timeline component with built-in preloading, marker system, reverse/forward control, and blob caching.
• It includes a demo application (in src/) built with Vite to showcase the library.
File structure
• Top-level directories:
• lib/ – compiled distribution code organized into submodules: model, ui, types, utils
• src/ – demo application source (React + CSS-in-JS)
• public/ – static assets (video files for the demo)
• Config and build files:
• package.json, tsconfig*.json, vite.config.ts, eslint.config.js
• .changeset/ and CHANGELOG.md for release management
Key insights from README
• Core architecture revolves around:
• VideoTimestone component (entry point in lib/index.ts)
• Internal state management (context + reducer) under lib/model
• UI subcomponents under lib/ui (video, controls, timeline markers)
• Utility routines for preloading and blob conversion in lib/utils
• Runtime flow: load URLs → preload into blobs → dispatch state events → render video(s) + controls → handle markers and callbacks.
Main components
a. Library Source
– Model module: preload-videos, state context, reducer, hooks
– UI module: Video, controls (play/pause/seek), timeline markers
– Utils module: blob conversion, marker setup
– Types module: shared TypeScript interfaces/constants
b. Build & Packaging
– TypeScript compiler & bundler (Vite during demo, Rollup/TS for npm build)
– Output: ES modules / CommonJS under lib/ → published to npm
c. Demo Application
– Vite host (index.html, main.tsx)
– App components (header, hero, package-guide, footer, etc.) under src/ui
– Static assets loader (public/demo*.mp4)
d. External Consumers
– Any React project importing ‘react-video-timestone’ from npm
Relationships and interactions
• Source modules interlink: Model → UI renders based on model’s state/context → Utils support model
• Build pipeline transforms lib source into distributable package
• Demo app imports built library from lib/ (or via npm)
• At runtime, VideoTimestone instantiates HTMLVideoElements, uses blob URLs from Utils, drives UI via Model state
• Application code (demo or third-party) interacts via props, marker callbacks, and ref methods
Architectural patterns & design principles
• Modular separation: core logic (model), presentation (ui), utilities
• React Context + Reducer pattern for state management
• Composition: top-level VideoTimestone composes multiple subcomponents
• CSS-in-JS for scoped styling under lib/ui/*.css.ts
• Blob caching for zero-buffer navigation
Detail
• Where marker callbacks plug in
• That CSS-in-JS styling is bundled with UI components