Skip to content

Commit f2a0799

Browse files
arraypressclaude
andcommitted
Adopt core's shipped types; drop drifting local duplicates
The core `@arraypress/waveform-player` v1.8.0 now ships a hand-authored `index.d.ts`, so this wrapper no longer needs to re-declare the shared option surface. - Delete `src/core-module-shim.d.ts` (the loose ambient module shim that existed only while the core had no types). - `src/types.ts`: re-export `WaveformStyle`, `ColorPreset`, `AudioMode`, `AudioPreload`, `ButtonAlign`, `WaveformMarker`, `WaveformPeaks` from the core, and make `WaveformPlayerProps extend Omit<WaveformPlayerOptions, url | callbacks>` instead of re-declaring every field. Callbacks and `WaveformPlayerHandle.instance` are now typed with the core's `WaveformPlayer` class. `accessibleSeek`, `seekLabel`, `barRadius`, and gradient-array colours are exposed for free. - `src/WaveformPlayer.tsx`: type the callback wrappers and `instance` getter with the (aliased) core class, and forward `accessibleSeek` / `seekLabel` through to the player. - Bump `@arraypress/waveform-player` peer + dev dependency to `^1.8.0`. - CHANGELOG: add Unreleased entry. typecheck, build (tsup), and the 19-test suite all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2398224 commit f2a0799

5 files changed

Lines changed: 111 additions & 257 deletions

File tree

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,38 @@ All notable changes to `@arraypress/waveform-player-react` are documented here.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Changed
11+
12+
- Public types are now adopted from the core
13+
`@arraypress/waveform-player` (v1.8.0+), which ships a hand-authored
14+
`index.d.ts`. The shared option surface (`WaveformStyle`,
15+
`ColorPreset`, `AudioMode`, `AudioPreload`, `ButtonAlign`,
16+
`WaveformMarker`, `WaveformPeaks`) is re-exported from the core, and
17+
`WaveformPlayerProps` now `extends` the core's `WaveformPlayerOptions`
18+
instead of re-declaring every field. The core is the single source of
19+
truth, so the wrapper's types can no longer drift out of sync. Bumped
20+
the `@arraypress/waveform-player` peer (and dev) dependency to
21+
`^1.8.0`.
22+
- Callback props (`onLoad`, `onPlay`, `onPause`, `onEnd`,
23+
`onTimeUpdate`, `onError`) and the `WaveformPlayerHandle.instance`
24+
accessor are now typed with the core's `WaveformPlayer` class instead
25+
of `unknown`.
26+
27+
### Added
28+
29+
- `accessibleSeek`, `seekLabel`, `barRadius`, and gradient-array
30+
waveform / progress colours (`string[]`) are now exposed as typed
31+
props — picked up for free by extending the core options and wired
32+
through to the underlying player.
33+
34+
### Removed
35+
36+
- Deleted `src/core-module-shim.d.ts`, the loose ambient
37+
`declare module '@arraypress/waveform-player'` shim that only existed
38+
while the core had no shipped types.
39+
840
## [0.1.1] — 2026-06-27
941

1042
### Changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
},
6060
"sideEffects": false,
6161
"peerDependencies": {
62-
"@arraypress/waveform-player": "^1.7.2",
62+
"@arraypress/waveform-player": "^1.8.0",
6363
"react": "^18.0.0 || ^19.0.0"
6464
},
6565
"scripts": {
@@ -71,7 +71,7 @@
7171
"prepublishOnly": "npm run build"
7272
},
7373
"devDependencies": {
74-
"@arraypress/waveform-player": "^1.7.2",
74+
"@arraypress/waveform-player": "^1.8.0",
7575
"@testing-library/jest-dom": "^6.9.1",
7676
"@testing-library/react": "^16.3.2",
7777
"@types/react": "^19.2.15",

src/WaveformPlayer.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ import {
5757
useRef,
5858
type ForwardedRef,
5959
} from 'react';
60+
// Aliased to avoid colliding with this file's own `WaveformPlayer`
61+
// component export. This is the core library's player class type.
62+
import type { WaveformPlayer as WaveformPlayerInstance } from '@arraypress/waveform-player';
6063
import type { WaveformPlayerHandle, WaveformPlayerProps } from './types';
6164

6265
/**
@@ -111,6 +114,10 @@ function buildLibraryOptions(props: WaveformPlayerProps): Record<string, unknown
111114
if (props.showBPM !== undefined) opts.showBPM = props.showBPM;
112115
if (props.buttonAlign !== undefined) opts.buttonAlign = props.buttonAlign;
113116

117+
/* Accessibility */
118+
if (props.accessibleSeek !== undefined) opts.accessibleSeek = props.accessibleSeek;
119+
if (props.seekLabel !== undefined) opts.seekLabel = props.seekLabel;
120+
114121
/* Markers */
115122
if (props.markers !== undefined) opts.markers = props.markers;
116123
if (props.showMarkers !== undefined) opts.showMarkers = props.showMarkers;
@@ -244,13 +251,13 @@ export const WaveformPlayer = forwardRef<WaveformPlayerHandle, WaveformPlayerPro
244251
* handler from `callbacksRef` — fixing the stale-closure
245252
* bug without re-mounting on callback changes. Signatures
246253
* mirror the core's option callbacks exactly. */
247-
opts.onLoad = (instance: unknown) => callbacksRef.current.onLoad?.(instance);
248-
opts.onPlay = (instance: unknown) => callbacksRef.current.onPlay?.(instance);
249-
opts.onPause = (instance: unknown) => callbacksRef.current.onPause?.(instance);
250-
opts.onEnd = (instance: unknown) => callbacksRef.current.onEnd?.(instance);
251-
opts.onTimeUpdate = (currentTime: number, duration: number, instance: unknown) =>
254+
opts.onLoad = (instance: WaveformPlayerInstance) => callbacksRef.current.onLoad?.(instance);
255+
opts.onPlay = (instance: WaveformPlayerInstance) => callbacksRef.current.onPlay?.(instance);
256+
opts.onPause = (instance: WaveformPlayerInstance) => callbacksRef.current.onPause?.(instance);
257+
opts.onEnd = (instance: WaveformPlayerInstance) => callbacksRef.current.onEnd?.(instance);
258+
opts.onTimeUpdate = (currentTime: number, duration: number, instance: WaveformPlayerInstance) =>
252259
callbacksRef.current.onTimeUpdate?.(currentTime, duration, instance);
253-
opts.onError = (error: Error, instance: unknown) =>
260+
opts.onError = (error: Error, instance: WaveformPlayerInstance) =>
254261
callbacksRef.current.onError?.(error, instance);
255262

256263
localInstance = new WaveformPlayerClass(container, opts);
@@ -307,6 +314,8 @@ export const WaveformPlayer = forwardRef<WaveformPlayerHandle, WaveformPlayerPro
307314
props.showHoverTime,
308315
props.showBPM,
309316
props.buttonAlign,
317+
props.accessibleSeek,
318+
props.seekLabel,
310319
props.markers,
311320
props.showMarkers,
312321
props.title,
@@ -381,7 +390,7 @@ export const WaveformPlayer = forwardRef<WaveformPlayerHandle, WaveformPlayerPro
381390
await inst.loadTrack(url, title, subtitle, options);
382391
},
383392
get instance() {
384-
return instanceRef.current;
393+
return instanceRef.current as WaveformPlayerInstance;
385394
},
386395
}),
387396
[]

src/core-module-shim.d.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)