You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(wavesurfer): promote peaks + duration to first-class props
Surface `peaks` (pre-computed waveform, untyped) and `duration` (Number) as
construction-time props so the render-without-decoding path (SSR / offline /
deterministic tests) is discoverable instead of buried in the `options` bag.
They override `options` ONLY when actually provided (conditional assignment),
so existing options.peaks callers — incl. the VR cell — keep working.
Surface now 27 props; compile ×6 / typecheck ×6 / build ×6 / surface 14/14 /
props-table validated / VR 6/6 re-validated on Linux.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lxeam8c3XSttraCZPxufKM
Copy file name to clipboardExpand all lines: docs/components/wavesurfer.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,8 @@ There are two **two-way** model props — `currentTime` and `regions` (bind eith
219
219
| Name | Type | Default | Two-way (model) | Runtime-updatable? | Description |
220
220
| --- | --- | --- | :---: | :---: | --- |
221
221
|`src`|`String`|`null`|| ✓ | The audio URL the waveform loads. Changing it calls `load(url)`. |
222
+
|`peaks`|`unknown`|`undefined`||| Pre-computed waveform peaks (array of channel sample arrays, or a single `number[]`) — render without downloading/decoding audio; pair with `duration`. **Construction-only.**|
223
+
|`duration`|`Number`|`null`||| Audio duration in seconds — required alongside `peaks` when there's no decodable `src`. **Construction-only.**|
222
224
|`height`|`Number`|`128`|| ✓ | The waveform height in pixels. Reconciled via `setOptions`. |
223
225
|`waveColor`|`String`|`"#8a2be2"`|| ✓ | Color of the unplayed portion of the waveform. Reconciled via `setOptions`. |
224
226
|`progressColor`|`String`|`"#5a189a"`|| ✓ | Color of the played (progress) portion. Reconciled via `setOptions`. |
@@ -308,8 +310,8 @@ When you drive `regions` as a controlled list, include a stable `id` on each des
308
310
309
311
### Offline / deterministic rendering
310
312
311
-
To render a waveform without decoding audio (CI, tests, SSR-adjacent), pass a pre-computed peaks array and a duration through `options`:
313
+
To render a waveform without decoding audio (CI, tests, SSR-adjacent), pass a pre-computed peaks array and a duration — no `src` needed:
* Pre-computed waveform peaks (an array of channel sample arrays, or a single `number[]`). Renders the waveform without downloading or decoding audio — pair with `duration`. Construction-only.
40
+
*/
41
+
peaks=input<unknown>(undefined);
42
+
/**
43
+
* The audio duration in seconds. Required alongside `peaks` when rendering without a decodable `src` (the timeline/ruler and region positions are derived from it). Construction-only.
44
+
*/
45
+
duration=input<(number)|null>(null);
38
46
/**
39
47
* The waveform height in pixels. Reconciled at runtime via `setOptions`.
40
48
*/
@@ -124,7 +132,7 @@ export class Waveform {
124
132
*/
125
133
regionColor=input<(string)|null>(null);
126
134
/**
127
-
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`peaks`, `duration`, `sampleRate`, `mediaControls`, `splitChannels`, …).
135
+
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`sampleRate`, `mediaControls`, `splitChannels`, `barHeight`, …).
* Pre-computed waveform peaks (an array of channel sample arrays, or a single `number[]`). Renders the waveform without downloading or decoding audio — pair with `duration`. Construction-only.
* The audio duration in seconds. Required alongside `peaks` when rendering without a decodable `src` (the timeline/ruler and region positions are derived from it). Construction-only.
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`peaks`, `duration`, `sampleRate`, `mediaControls`, `splitChannels`, …).
131
+
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`sampleRate`, `mediaControls`, `splitChannels`, `barHeight`, …).
* Pre-computed waveform peaks (an array of channel sample arrays, or a single `number[]`). Renders the waveform without downloading or decoding audio — pair with `duration`. Construction-only.
14
+
*/
15
+
peaks?: unknown;
16
+
/**
17
+
* The audio duration in seconds. Required alongside `peaks` when rendering without a decodable `src` (the timeline/ruler and region positions are derived from it). Construction-only.
18
+
*/
19
+
duration?: (number)|null;
12
20
/**
13
21
* The waveform height in pixels. Reconciled at runtime via `setOptions`.
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`peaks`, `duration`, `sampleRate`, `mediaControls`, `splitChannels`, …).
111
+
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`sampleRate`, `mediaControls`, `splitChannels`, `barHeight`, …).
* Pre-computed waveform peaks (an array of channel sample arrays, or a single `number[]`). Renders the waveform without downloading or decoding audio — pair with `duration`. Construction-only.
27
+
*/
28
+
peaks?: unknown;
29
+
/**
30
+
* The audio duration in seconds. Required alongside `peaks` when rendering without a decodable `src` (the timeline/ruler and region positions are derived from it). Construction-only.
31
+
*/
32
+
duration?: (number)|null;
25
33
/**
26
34
* The waveform height in pixels. Reconciled at runtime via `setOptions`.
27
35
*/
@@ -113,7 +121,7 @@ interface WaveformProps {
113
121
*/
114
122
regionColor?: (string)|null;
115
123
/**
116
-
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`peaks`, `duration`, `sampleRate`, `mediaControls`, `splitChannels`, …).
124
+
* Raw wavesurfer `WaveSurferOptions` passthrough — spread into `WaveSurfer.create()` before the curated keys (explicit props win). Use it for any v7 option not surfaced as a first-class prop (`sampleRate`, `mediaControls`, `splitChannels`, `barHeight`, …).
0 commit comments