@npo/player-types
v2.1.0
Published
TypeScript type definitions for NPO Player packages
Readme
@npo/player-types
TypeScript type definitions for NPO Player packages.
Overview
This package contains all shared type definitions used across the NPO Player ecosystem:
@npo/player@npo/player-ui-core@npo/player-audio-ui@npo/player-video-ui
Structure
@types/
├── enums.d.ts # Core enums (Modes, MediaStates, etc.)
├── constants.d.ts # Constants and configuration values
├── player/ # Player-related types
│ ├── api.d.ts # Player API interface
│ ├── config.d.ts # Configuration types
│ ├── state.d.ts # State management
│ ├── actions.d.ts # Time-bound actions
│ └── advert.d.ts # Advertisement types
├── stream/ # Stream-related types
│ ├── metadata.d.ts # Metadata structures
│ ├── assets.d.ts # Assets (subtitles, thumbnails)
│ └── stream.d.ts # Stream objects
├── ui/ # UI-related types
│ ├── factory.d.ts # UI Factory interfaces
│ ├── components.d.ts # Component types
│ ├── events.d.ts # Event handling
│ └── input.d.ts # Input handling
├── services/ # Service types
│ ├── error.d.ts # Error handling
│ ├── cast.d.ts # Chromecast
│ ├── airplay.d.ts # AirPlay
│ ├── drm.d.ts # DRM configuration
│ ├── thumbnails.d.ts # Thumbnail service
│ └── chapters.d.ts # Chapter handling
├── media/ # Media types
│ └── quality.d.ts # Video quality
├── tracking/ # Tracking types
│ └── npotag.d.ts # NPOTag analytics
└── external/ # External library types
└── shaka-player.d.ts # Shaka Player definitionsUsage
Import all types
import type { IPlayerApi, NpoPlayerConfig, Modes } from '@npo/player-types'Import from specific modules
import type { IPlayerApi } from '@npo/player-types/player'
import type { IStreamObject } from '@npo/player-types/stream'
import type { INpoPlayerUIFactory } from '@npo/player-types/ui'Development
This package only contains type definitions and has no runtime code. It is built with TypeScript's declaration file generation.
Build
npm run buildWatch mode
npm run devMigration from Legacy Types
Previously, types were scattered across multiple src/types/interfaces.ts files in each package. This centralized package provides:
- Single source of truth - No duplicate type definitions
- Better organization - Types grouped by domain
- Standard TypeScript modules - Following official TypeScript patterns
- Improved IDE support - Better autocomplete and type checking
- Easier maintenance - Changes in one place propagate everywhere
License
MIT
