Fix: useAnnotationKeyboardControls works without WaveformPlaylistProvider (#509)
Fixes a crash when using useAnnotationKeyboardControls outside a WaveformPlaylistProvider — e.g. the MediaElement path (MediaElementPlaylistProvider). PR #509.
Published packages
| Package | Version |
|---|---|
@waveform-playlist/browser |
13.1.3 |
What changed
useAnnotationKeyboardControls called usePlaylistData() unconditionally to read samplesPerPixel / sampleRate (a v11 "read from context" refactor). usePlaylistData() throws outside WaveformPlaylistProvider, so any MediaElement consumer wiring keyboard annotation controls crashed on mount with usePlaylistData must be used within WaveformPlaylistProvider.
- Added
usePlaylistDataOptional()— returnsnullinstead of throwing when there is noWaveformPlaylistProviderancestor. Exported for MediaElement-path consumers. useAnnotationKeyboardControlsnow accepts optionalsamplesPerPixel/sampleRateprops (restoring the pre-v11 API the MediaElement path relies on) and falls back to the WaveformPlaylist context when omitted. These values feed only optional auto-scroll, so the hook degrades gracefully when neither source is present.
Regression tests: the hook renders and navigates without a WaveformPlaylistProvider, plus a peerDependencies guard that fails if any package uses workspace:* in peerDependencies (the exact-pin footgun fixed in #508).