7.1 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
OrionTV is a React Native TVOS application for streaming video content, built with Expo and designed specifically for TV platforms (Apple TV and Android TV). This is a frontend-only application that connects to external APIs and includes a built-in remote control server for external device control.
Key Commands
Development Commands
TV Development (Apple TV & Android TV)
yarn start- Start Metro bundler in TV mode (EXPO_TV=1)yarn android- Build and run on Android TVyarn ios- Build and run on Apple TVyarn prebuild- Generate native project files for TV (run after dependency changes)yarn build- Build Android APK for TV release
Testing Commands
yarn test- Run Jest tests with watch modeyarn test-ci- Run Jest tests for CI with coverageyarn test utils- Run tests for specific directory/file patternyarn lint- Run ESLint checksyarn typecheck- Run TypeScript type checking
Build and Deployment
yarn copy-config- Copy TV-specific Android configurationsyarn build-debug- Build Android APK for debuggingyarn clean- Clean cache and build artifactsyarn clean-modules- Reinstall all node modules
Architecture Overview
Multi-Platform Responsive Design
OrionTV implements a sophisticated responsive architecture supporting multiple device types:
- Device Detection: Width-based breakpoints (mobile <768px, tablet 768-1023px, TV ≥1024px)
- Component Variants: Platform-specific files with
.tv.tsx,.mobile.tsx,.tablet.tsxextensions - Responsive Utilities:
DeviceUtilsandResponsiveStylesfor adaptive layouts and scaling - Adaptive Navigation: Different interaction patterns per device type (touch vs remote control)
State Management Architecture (Zustand)
Domain-specific stores with consistent patterns:
- homeStore.ts - Home screen content, categories, Douban API data, and play records
- playerStore.ts - Video player state, controls, and episode management
- settingsStore.ts - App settings, API configuration, and user preferences
- remoteControlStore.ts - Remote control server functionality and HTTP bridge
- authStore.ts - User authentication state
- updateStore.ts - Automatic update checking and version management
- favoritesStore.ts - User favorites management
Service Layer Pattern
Clean separation of concerns across service modules:
- api.ts - External API integration with error handling and caching
- storage.ts - AsyncStorage wrapper with typed interfaces
- remoteControlService.ts - TCP-based HTTP server for external device control
- updateService.ts - Automatic version checking and APK download management
- tcpHttpServer.ts - Low-level TCP server implementation
TV Remote Control System
Sophisticated TV interaction handling:
- useTVRemoteHandler - Centralized hook for TV remote event processing
- Hardware Events - HWEvent handling for TV-specific controls (play/pause, seek, menu)
- Focus Management - TV-specific focus states and navigation flows
- Gesture Support - Long press, directional seeking, auto-hide controls
Key Technologies
- React Native TVOS (0.74.x) - TV-optimized React Native with TV-specific event handling
- Expo SDK 51 - Development platform providing native capabilities and build tooling
- TypeScript - Complete type safety with
@/*path mapping configuration - Zustand - Lightweight state management for global application state
- Expo Router - File-based routing system with typed routes
- Expo AV - Video playback with TV-optimized controls
Development Workflow
TV-First Development Pattern
This project uses a TV-first approach with responsive adaptations:
- Primary Target: Apple TV and Android TV with remote control interaction
- Secondary Targets: Mobile and tablet with touch-optimized responsive design
- Build Environment:
EXPO_TV=1environment variable enables TV-specific features - Component Strategy: Shared components with platform-specific variants using file extensions
Testing Strategy
- Unit Tests: Comprehensive test coverage for utilities (
utils/__tests__/) - Jest Configuration: Expo preset with Babel transpilation
- Test Patterns: Mock-based testing for React Native modules and external dependencies
- Coverage Reporting: CI-compatible coverage reports with detailed metrics
Important Development Notes
- Run
yarn prebuildafter adding new dependencies for native builds - Use
yarn copy-configto apply TV-specific Android configurations - TV components require focus management and remote control support
- Test on both TV devices (Apple TV/Android TV) and responsive mobile/tablet layouts
- All API calls are centralized in
/servicesdirectory with error handling - Storage operations use AsyncStorage wrapper in
storage.tswith typed interfaces
Component Development Patterns
- Platform Variants: Use
.tv.tsx,.mobile.tsx,.tablet.tsxfor platform-specific implementations - Responsive Utilities: Leverage
DeviceUtils.getDeviceType()for responsive logic - TV Remote Handling: Use
useTVRemoteHandlerhook for TV-specific interactions - Focus Management: TV components must handle focus states for remote navigation
- Shared Logic: Place common logic in
/hooksdirectory for reusability
Common Development Tasks
Adding New Components
- Create base component in
/componentsdirectory - Add platform-specific variants (
.tv.tsx) if needed - Import and use responsive utilities from
@/utils/DeviceUtils - Test across device types for proper responsive behavior
Working with State
- Identify appropriate Zustand store in
/storesdirectory - Follow existing patterns for actions and state structure
- Use TypeScript interfaces for type safety
- Consider cross-store dependencies and data flow
API Integration
- Add new endpoints to
/services/api.ts - Implement proper error handling and loading states
- Use caching strategies for frequently accessed data
- Update relevant Zustand stores with API responses
File Structure Notes
/app- Expo Router screens and navigation/components- Reusable UI components (including.tv.tsxvariants)/stores- Zustand state management stores/services- API, storage, remote control, and update services/hooks- Custom React hooks includinguseTVRemoteHandler/constants- App constants, theme definitions, and update configuration/assets- Static assets including TV-specific icons and banners
important-instruction-reminders
Do what has been asked; nothing more, nothing less. NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one. NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User. ALWAYS When plan mode switches to edit, the contents of plan and todo need to be output as a document.