11import React , { createContext , useContext , useState , useEffect , useRef , useCallback , useMemo , type ReactNode } from 'react' ;
22import { ThemeProvider } from 'styled-components' ;
33import { TonePlayout , type EffectsFunction , type TrackEffectsFunction } from '@waveform-playlist/playout' ;
4- import { type Track , type ClipTrack , type Fade } from '@waveform-playlist/core' ;
4+ import { type Track , type ClipTrack , type Fade , type AnnotationAction } from '@waveform-playlist/core' ;
55import { type TimeFormat , type WaveformPlaylistTheme , defaultTheme } from '@waveform-playlist/ui-components' ;
66import { getContext } from 'tone' ;
77import { generatePeaks } from './peaksUtil' ;
88
99import { extractPeaksFromWaveformData } from './waveformDataLoader' ;
10+ import type WaveformData from 'waveform-data' ;
1011import type { PeakData } from '@waveform-playlist/webaudio-peaks' ;
1112import type { AnnotationData } from '@waveform-playlist/core' ;
1213import { useTimeFormat , useZoomControls , useMasterVolume } from './hooks' ;
@@ -73,7 +74,7 @@ export interface WaveformPlaylistContextValue {
7374 setSelection : ( start : number , end : number ) => void ;
7475
7576 // Time format
76- timeFormat : string ;
77+ timeFormat : TimeFormat ;
7778 setTimeFormat : ( format : TimeFormat ) => void ;
7879 formatTime : ( seconds : number ) => string ;
7980
@@ -201,7 +202,7 @@ export interface PlaylistDataContextValue {
201202 controls : { show : boolean ; width : number } ;
202203 playoutRef : React . RefObject < TonePlayout | null > ;
203204 samplesPerPixel : number ;
204- timeFormat : string ;
205+ timeFormat : TimeFormat ;
205206 masterVolume : number ;
206207 canZoomIn : boolean ;
207208 canZoomOut : boolean ;
@@ -238,11 +239,11 @@ export interface WaveformPlaylistProviderProps {
238239 width : number ;
239240 } ;
240241 annotationList ?: {
241- annotations ?: any [ ] ;
242+ annotations ?: AnnotationData [ ] ;
242243 editable ?: boolean ;
243244 isContinuousPlay ?: boolean ;
244245 linkEndpoints ?: boolean ;
245- controls ?: any [ ] ;
246+ controls ?: AnnotationAction [ ] ;
246247 } ;
247248 effects ?: EffectsFunction ;
248249 onReady ?: ( ) => void ;
@@ -286,7 +287,7 @@ export const WaveformPlaylistProvider: React.FC<WaveformPlaylistProviderProps> =
286287 const annotations = useMemo ( ( ) => {
287288 if ( ! annotationList ?. annotations ) return [ ] ;
288289 if ( process . env . NODE_ENV !== 'production' && annotationList . annotations . length > 0 ) {
289- const first = annotationList . annotations [ 0 ] as Record < string , unknown > ;
290+ const first = annotationList . annotations [ 0 ] as unknown as Record < string , unknown > ;
290291 if ( typeof first . start !== 'number' || typeof first . end !== 'number' ) {
291292 console . error (
292293 '[waveform-playlist] Annotations must have numeric start/end values. ' +
@@ -296,7 +297,7 @@ export const WaveformPlaylistProvider: React.FC<WaveformPlaylistProviderProps> =
296297 return [ ] ;
297298 }
298299 }
299- return annotationList . annotations as AnnotationData [ ] ;
300+ return annotationList . annotations ;
300301 } , [ annotationList ?. annotations ] ) ;
301302
302303 // Ref for animation loop (avoids restarting loop on annotation change)
@@ -620,7 +621,7 @@ export const WaveformPlaylistProvider: React.FC<WaveformPlaylistProviderProps> =
620621 // Use waveform-data.js to resample and slice as needed
621622 // Pass sample values directly for accuracy
622623 const extractedPeaks = extractPeaksFromWaveformData (
623- clip . waveformData as any , // Cast to WaveformData type
624+ clip . waveformData as WaveformData ,
624625 samplesPerPixel ,
625626 0 , // channel index
626627 clip . offsetSamples ,
0 commit comments