@waveform-playlist/ui-components 15.0.0-next.16 → 15.0.0-next.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/index.d.mts +24 -24
- package/dist/index.d.ts +24 -24
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ Used internally by [`@waveform-playlist/browser`](https://www.npmjs.com/package/
|
|
|
9
9
|
- **Canvas waveform rendering** — `Channel` draws peaks as bars, with an optional `roundedBars` mode
|
|
10
10
|
- **Spectrogram & piano-roll channels** — `SpectrogramChannel` and `PianoRollChannel` render alongside waveform as alternate track visualizations
|
|
11
11
|
- **Track controls** — mute/solo/volume, track menu, and other transport-adjacent controls
|
|
12
|
-
- **Theming** — `ThemeProvider` + `
|
|
12
|
+
- **Theming** — `ThemeProvider` + `WaveformTheme` (with `defaultTheme` and `darkTheme`) drive every styled component from a single theme object
|
|
13
13
|
- **Virtual scrolling** — chunked canvases and viewport tracking so long timelines don't render off-screen content
|
|
14
14
|
- **`SegmentedVUMeter`** — standalone level meter with configurable color stops, orientation, and scale
|
|
15
|
-
- **`
|
|
15
|
+
- **`WaveformErrorBoundary`** — catches render errors without depending on `ThemeProvider`
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -63,12 +63,12 @@ function PeakReadout({ meter }: { meter: MeterSource }) {
|
|
|
63
63
|
}
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
## The drawing context: `
|
|
66
|
+
## The drawing context: `useWaveformViewInfo()`
|
|
67
67
|
|
|
68
|
-
The drawing primitives (`Track`, `SmartChannel`, `SmartScale`, `TimeScale`) read what they need from the view they are drawn in through `
|
|
68
|
+
The drawing primitives (`Track`, `SmartChannel`, `SmartScale`, `TimeScale`) read what they need from the view they are drawn in through `WaveformViewInfoContext`. A root of `@waveform-playlist/browser` (`WaveformRoot`, `MediaElementWaveformRoot`) always publishes it for its view: the options of the `<WaveformViewOptions>` above it (the defaults for those not set), the provider's sample rate, the zoom and the height of the timescale strip. Only where there is no root above do the context's own defaults apply: `sampleRate` 48000, `samplesPerPixel` 1000, `waveHeight` 80, `timeScaleHeight` 15, `barWidth` 1, `barGap` 0, `roundedBars` false, `progressBarWidth` 1.
|
|
69
69
|
|
|
70
70
|
```tsx
|
|
71
|
-
import {
|
|
71
|
+
import { useWaveformViewInfo, type WaveformViewInfo } from '@waveform-playlist/ui-components';
|
|
72
72
|
|
|
73
73
|
const {
|
|
74
74
|
sampleRate,
|
|
@@ -79,10 +79,10 @@ const {
|
|
|
79
79
|
barGap, // default 0
|
|
80
80
|
roundedBars, // default false
|
|
81
81
|
progressBarWidth, // px of the playhead line; default barWidth + barGap
|
|
82
|
-
}:
|
|
82
|
+
}: WaveformViewInfo = useWaveformViewInfo();
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
If you render `<
|
|
85
|
+
If you render `<WaveformViewInfoContext value={…}>` yourself, give it every field of `WaveformViewInfo` (`roundedBars` and `progressBarWidth` are required; `controls` and `zoomLevels` are no longer part of it). `DEFAULT_WAVE_HEIGHT` (80), `DEFAULT_BAR_WIDTH` (1) and `DEFAULT_BAR_GAP` (0) are exported.
|
|
86
86
|
|
|
87
87
|
`Channel` never steps less than one pixel from one bar to the next: a `barWidth + barGap` under 1 is drawn with a step of 1.
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ A `Clip` given `isPlaceholder` (the clip's audio is still loading) is drawn with
|
|
|
92
92
|
|
|
93
93
|
## Theming
|
|
94
94
|
|
|
95
|
-
Wrap your tree in styled-components' `ThemeProvider` with a `
|
|
95
|
+
Wrap your tree in styled-components' `ThemeProvider` with a `WaveformTheme` object — `defaultTheme` and `darkTheme` are exported as starting points and can be partially overridden:
|
|
96
96
|
|
|
97
97
|
```tsx
|
|
98
98
|
import { ThemeProvider } from 'styled-components';
|
|
@@ -103,7 +103,7 @@ import { defaultTheme } from '@waveform-playlist/ui-components';
|
|
|
103
103
|
</ThemeProvider>;
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
`@waveform-playlist/browser`'s `
|
|
106
|
+
`@waveform-playlist/browser`'s `WebAudioProvider` sets this up for you via its own `theme` prop — you only need `ThemeProvider` directly when using `ui-components` outside that provider.
|
|
107
107
|
|
|
108
108
|
## Examples & Documentation
|
|
109
109
|
|
package/dist/index.d.mts
CHANGED
|
@@ -58,7 +58,7 @@ declare function waveformColorToCss(color: WaveformColor): string;
|
|
|
58
58
|
* waveOutlineColor is used as background. Good for gradient backgrounds.
|
|
59
59
|
*/
|
|
60
60
|
type WaveformDrawMode = 'inverted' | 'normal';
|
|
61
|
-
interface
|
|
61
|
+
interface WaveformTheme {
|
|
62
62
|
waveformDrawMode?: WaveformDrawMode;
|
|
63
63
|
waveOutlineColor: WaveformColor;
|
|
64
64
|
waveFillColor: WaveformColor;
|
|
@@ -110,7 +110,7 @@ interface WaveformPlaylistTheme {
|
|
|
110
110
|
* the key existed still type-checks; without it the colour is `#ff9800`.
|
|
111
111
|
*/
|
|
112
112
|
annotationTextItemActiveColor?: string;
|
|
113
|
-
|
|
113
|
+
tracksBackgroundColor?: string;
|
|
114
114
|
pianoRollNoteColor: string;
|
|
115
115
|
pianoRollSelectedNoteColor: string;
|
|
116
116
|
pianoRollBackgroundColor: string;
|
|
@@ -132,8 +132,8 @@ interface WaveformPlaylistTheme {
|
|
|
132
132
|
fontSize: string;
|
|
133
133
|
fontSizeSmall: string;
|
|
134
134
|
}
|
|
135
|
-
declare const defaultTheme:
|
|
136
|
-
declare const darkTheme:
|
|
135
|
+
declare const defaultTheme: WaveformTheme;
|
|
136
|
+
declare const darkTheme: WaveformTheme;
|
|
137
137
|
|
|
138
138
|
interface ChannelProps {
|
|
139
139
|
className?: string;
|
|
@@ -176,7 +176,7 @@ interface ChannelProps {
|
|
|
176
176
|
}
|
|
177
177
|
declare const Channel: FunctionComponent<ChannelProps>;
|
|
178
178
|
|
|
179
|
-
interface
|
|
179
|
+
interface WaveformErrorBoundaryProps {
|
|
180
180
|
children: react__default.ReactNode;
|
|
181
181
|
/** Custom fallback UI to show when an error occurs */
|
|
182
182
|
fallback?: react__default.ReactNode;
|
|
@@ -201,19 +201,19 @@ interface ErrorBoundaryState {
|
|
|
201
201
|
* function Editor() {
|
|
202
202
|
* const arrangement = useCreateArrangement(() => [audioTrack({ src: '/vocals.mp3' })]);
|
|
203
203
|
* return (
|
|
204
|
-
* <
|
|
204
|
+
* <WebAudioProvider arrangement={arrangement}>
|
|
205
205
|
* <Waveform />
|
|
206
|
-
* </
|
|
206
|
+
* </WebAudioProvider>
|
|
207
207
|
* );
|
|
208
208
|
* }
|
|
209
209
|
*
|
|
210
|
-
* <
|
|
210
|
+
* <WaveformErrorBoundary>
|
|
211
211
|
* <Editor />
|
|
212
|
-
* </
|
|
212
|
+
* </WaveformErrorBoundary>
|
|
213
213
|
* ```
|
|
214
214
|
*/
|
|
215
|
-
declare class
|
|
216
|
-
constructor(props:
|
|
215
|
+
declare class WaveformErrorBoundary extends react__default.Component<WaveformErrorBoundaryProps, ErrorBoundaryState> {
|
|
216
|
+
constructor(props: WaveformErrorBoundaryProps);
|
|
217
217
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
218
218
|
componentDidCatch(error: Error, errorInfo: react__default.ErrorInfo): void;
|
|
219
219
|
render(): react__default.ReactNode;
|
|
@@ -385,10 +385,10 @@ declare const PianoRollChannel: FunctionComponent<PianoRollChannelProps>;
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* Props passed to the default playhead component or custom render function.
|
|
388
|
-
* The same seven under `
|
|
389
|
-
* `
|
|
388
|
+
* The same seven under `WebAudioProvider` and
|
|
389
|
+
* `MediaElementProvider`. Engine values (`getPlaybackTime`,
|
|
390
390
|
* `getAudioContextTime`, `playbackStartTimeRef`, `audioStartPositionRef`) are
|
|
391
|
-
* not props: a playhead for `
|
|
391
|
+
* not props: a playhead for `WebAudioProvider` that needs them calls
|
|
392
392
|
* `useEngineRefs()` from `@waveform-playlist/browser`.
|
|
393
393
|
*/
|
|
394
394
|
interface PlayheadProps {
|
|
@@ -405,9 +405,9 @@ interface PlayheadProps {
|
|
|
405
405
|
currentTimeRef: react__default.RefObject<number>;
|
|
406
406
|
/**
|
|
407
407
|
* Ref to the time a playhead should be drawn at, in seconds. Under
|
|
408
|
-
* `
|
|
408
|
+
* `WebAudioProvider`, while playing, it is the audible time (raw
|
|
409
409
|
* minus output latency and look-ahead), and at rest the commanded position
|
|
410
|
-
* (seek, pause, stop). Under `
|
|
410
|
+
* (seek, pause, stop). Under `MediaElementProvider` it is the same
|
|
411
411
|
* ref as `currentTimeRef`. The provider keeps it current on every frame of
|
|
412
412
|
* playback, so a playhead that reads it stays in step with the progress fill.
|
|
413
413
|
*/
|
|
@@ -435,7 +435,7 @@ declare const Playhead: react__default.FC<PlayheadProps>;
|
|
|
435
435
|
*/
|
|
436
436
|
declare const PlayheadWithMarker: react__default.FC<PlayheadProps>;
|
|
437
437
|
|
|
438
|
-
interface
|
|
438
|
+
interface WaveformFrameProps {
|
|
439
439
|
readonly children?: react__default.ReactNode;
|
|
440
440
|
readonly backgroundColor?: string;
|
|
441
441
|
readonly timescaleBackgroundColor?: string;
|
|
@@ -451,7 +451,7 @@ interface PlaylistProps {
|
|
|
451
451
|
/** When true, selection is in progress - raises z-index to prevent clip boundary interference */
|
|
452
452
|
readonly isSelecting?: boolean;
|
|
453
453
|
/** Data attribute indicating playlist loading state ('loading' | 'ready') */
|
|
454
|
-
readonly 'data-
|
|
454
|
+
readonly 'data-waveform-state'?: 'loading' | 'ready';
|
|
455
455
|
/** Track control slots rendered in the controls column, one per track */
|
|
456
456
|
readonly trackControlsSlots?: react__default.ReactNode[];
|
|
457
457
|
/** Height of the timescale gap spacer in the controls column (matches timescale height) */
|
|
@@ -459,7 +459,7 @@ interface PlaylistProps {
|
|
|
459
459
|
/** Class name for the outermost element. */
|
|
460
460
|
readonly className?: string;
|
|
461
461
|
}
|
|
462
|
-
declare const
|
|
462
|
+
declare const WaveformFrame: FunctionComponent<WaveformFrameProps>;
|
|
463
463
|
|
|
464
464
|
interface SelectionProps {
|
|
465
465
|
startPosition: number;
|
|
@@ -635,7 +635,7 @@ declare const SpectrogramLabels: react__default.FC<SpectrogramLabelsProps>;
|
|
|
635
635
|
interface SmartScaleProps {
|
|
636
636
|
/**
|
|
637
637
|
* Length of the timeline the scale covers, in milliseconds. A prop and not a
|
|
638
|
-
* field of `
|
|
638
|
+
* field of `WaveformViewInfoContext` (#768): the length changes on every pointer
|
|
639
639
|
* move of a trim at the end of the timeline, and every channel and track
|
|
640
640
|
* reads that context.
|
|
641
641
|
*/
|
|
@@ -876,7 +876,7 @@ declare const useDevicePixelRatio: () => number;
|
|
|
876
876
|
* `TimeScale`) need from the view they are drawn in. The browser package's
|
|
877
877
|
* roots publish it once per view; without one above, the defaults apply.
|
|
878
878
|
*/
|
|
879
|
-
type
|
|
879
|
+
type WaveformViewInfo = {
|
|
880
880
|
sampleRate: number;
|
|
881
881
|
samplesPerPixel: number;
|
|
882
882
|
/** Height in pixels of one channel. Default: 80 */
|
|
@@ -895,8 +895,8 @@ type PlaylistInfo = {
|
|
|
895
895
|
declare const DEFAULT_WAVE_HEIGHT = 80;
|
|
896
896
|
declare const DEFAULT_BAR_WIDTH = 1;
|
|
897
897
|
declare const DEFAULT_BAR_GAP = 0;
|
|
898
|
-
declare const
|
|
899
|
-
declare const
|
|
898
|
+
declare const WaveformViewInfoContext: react.Context<WaveformViewInfo>;
|
|
899
|
+
declare const useWaveformViewInfo: () => WaveformViewInfo;
|
|
900
900
|
|
|
901
901
|
declare const useTheme: () => styled_components.DefaultTheme | undefined;
|
|
902
902
|
|
|
@@ -1069,4 +1069,4 @@ declare function useThrottledValue<T>(source: ValueSource<T>, options?: UseThrot
|
|
|
1069
1069
|
*/
|
|
1070
1070
|
declare function useMeterLevels(meter: MeterSource, options?: UseThrottledValueOptions): MeterLevels;
|
|
1071
1071
|
|
|
1072
|
-
export { AutomaticScrollCheckbox, type AutomaticScrollCheckboxProps, BaseButton, BaseCheckbox, BaseCheckboxLabel, BaseCheckboxWrapper, BaseControlButton, BaseInput, BaseInputSmall, BaseLabel, BaseSelect, BaseSelectSmall, BaseSlider, type BeatsAndBarsContextValue, BeatsAndBarsProvider, type BeatsAndBarsProviderProps, type BeatsAndBarsSnapTo, Button, ButtonGroup, CLIP_BOUNDARY_WIDTH, CLIP_BOUNDARY_WIDTH_TOUCH, CLIP_HEADER_HEIGHT, Channel, type ChannelProps, Clip, ClipBoundary, type ClipBoundaryProps, ClipHeader, ClipHeaderPresentational, type ClipHeaderPresentationalProps, type ClipHeaderProps, ClipPlaceholderBody, type ClipPlaceholderBodyProps, type ClipProps, ClipViewportOriginProvider, CloseButton, type CloseButtonProps, type ColorStop, Controls, DEFAULT_BAR_GAP, DEFAULT_BAR_WIDTH, DEFAULT_PLAYBACK_RATES, DEFAULT_WAVE_HEIGHT, DevicePixelRatioProvider, DotsIcon, type DragHandleProps, FadeOverlay, type FadeOverlayProps, type GradientStop, GripIcon, Header, InlineLabel, LoopRegionMarkers, type LoopRegionMarkersProps, MasterVolumeControl, type MasterVolumeControlProps, MoveDownIcon, MoveUpIcon, PianoRollChannel, type PianoRollChannelProps, PlaybackRateSelect, type PlaybackRateSelectProps, Playhead, type PlayheadProps, PlayheadWithMarker,
|
|
1072
|
+
export { AutomaticScrollCheckbox, type AutomaticScrollCheckboxProps, BaseButton, BaseCheckbox, BaseCheckboxLabel, BaseCheckboxWrapper, BaseControlButton, BaseInput, BaseInputSmall, BaseLabel, BaseSelect, BaseSelectSmall, BaseSlider, type BeatsAndBarsContextValue, BeatsAndBarsProvider, type BeatsAndBarsProviderProps, type BeatsAndBarsSnapTo, Button, ButtonGroup, CLIP_BOUNDARY_WIDTH, CLIP_BOUNDARY_WIDTH_TOUCH, CLIP_HEADER_HEIGHT, Channel, type ChannelProps, Clip, ClipBoundary, type ClipBoundaryProps, ClipHeader, ClipHeaderPresentational, type ClipHeaderPresentationalProps, type ClipHeaderProps, ClipPlaceholderBody, type ClipPlaceholderBodyProps, type ClipProps, ClipViewportOriginProvider, CloseButton, type CloseButtonProps, type ColorStop, Controls, DEFAULT_BAR_GAP, DEFAULT_BAR_WIDTH, DEFAULT_PLAYBACK_RATES, DEFAULT_WAVE_HEIGHT, DevicePixelRatioProvider, DotsIcon, type DragHandleProps, FadeOverlay, type FadeOverlayProps, type GradientStop, GripIcon, Header, InlineLabel, LoopRegionMarkers, type LoopRegionMarkersProps, MasterVolumeControl, type MasterVolumeControlProps, MoveDownIcon, MoveUpIcon, PianoRollChannel, type PianoRollChannelProps, PlaybackRateSelect, type PlaybackRateSelectProps, Playhead, type PlayheadProps, PlayheadWithMarker, type PrecomputedTickData, type RenderPlayheadFunction, ReorderRail, type ReorderRailProps, type ScaleMode, ScreenReaderOnly, type ScrollViewport, ScrollViewportProvider, SegmentedVUMeter, type SegmentedVUMeterProps, Selection, type SelectionProps, SelectionTimeInputs, type SelectionTimeInputsProps, Slider, SliderWrapper, SmartChannel, type SmartChannelProps, SmartScale, type SmartScaleProps, SpectrogramChannel, type SpectrogramChannelProps, SpectrogramLabels, type SpectrogramLabelsProps, StyledTimeScale, type TimeFormat, TimeFormatSelect, type TimeFormatSelectProps, TimeInput, type TimeInputProps, TimeScale, type TimeScaleProps, TimescaleLoopRegion, type TimescaleLoopRegionProps, Track, TrackMenu, type TrackMenuItem, type TrackMenuProps, type TrackProps, TrashIcon, type UseThrottledValueOptions, VolumeDownIcon, VolumeUpIcon, type WaveformColor, type WaveformDrawMode, WaveformErrorBoundary, type WaveformErrorBoundaryProps, WaveformFrame, type WaveformFrameProps, type WaveformGradient, type WaveformTheme, type WaveformViewInfo, WaveformViewInfoContext, darkTheme, defaultTheme, formatTime, getScaleInfo, isWaveformGradient, parseTime, useBeatsAndBars, useClipViewportOrigin, useDevicePixelRatio, useMeterLevels, useScrollViewport, useScrollViewportSelector, useTheme, useThrottledValue, useVisibleChunkIndices, useWaveformViewInfo, waveformColorToCss };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ declare function waveformColorToCss(color: WaveformColor): string;
|
|
|
58
58
|
* waveOutlineColor is used as background. Good for gradient backgrounds.
|
|
59
59
|
*/
|
|
60
60
|
type WaveformDrawMode = 'inverted' | 'normal';
|
|
61
|
-
interface
|
|
61
|
+
interface WaveformTheme {
|
|
62
62
|
waveformDrawMode?: WaveformDrawMode;
|
|
63
63
|
waveOutlineColor: WaveformColor;
|
|
64
64
|
waveFillColor: WaveformColor;
|
|
@@ -110,7 +110,7 @@ interface WaveformPlaylistTheme {
|
|
|
110
110
|
* the key existed still type-checks; without it the colour is `#ff9800`.
|
|
111
111
|
*/
|
|
112
112
|
annotationTextItemActiveColor?: string;
|
|
113
|
-
|
|
113
|
+
tracksBackgroundColor?: string;
|
|
114
114
|
pianoRollNoteColor: string;
|
|
115
115
|
pianoRollSelectedNoteColor: string;
|
|
116
116
|
pianoRollBackgroundColor: string;
|
|
@@ -132,8 +132,8 @@ interface WaveformPlaylistTheme {
|
|
|
132
132
|
fontSize: string;
|
|
133
133
|
fontSizeSmall: string;
|
|
134
134
|
}
|
|
135
|
-
declare const defaultTheme:
|
|
136
|
-
declare const darkTheme:
|
|
135
|
+
declare const defaultTheme: WaveformTheme;
|
|
136
|
+
declare const darkTheme: WaveformTheme;
|
|
137
137
|
|
|
138
138
|
interface ChannelProps {
|
|
139
139
|
className?: string;
|
|
@@ -176,7 +176,7 @@ interface ChannelProps {
|
|
|
176
176
|
}
|
|
177
177
|
declare const Channel: FunctionComponent<ChannelProps>;
|
|
178
178
|
|
|
179
|
-
interface
|
|
179
|
+
interface WaveformErrorBoundaryProps {
|
|
180
180
|
children: react__default.ReactNode;
|
|
181
181
|
/** Custom fallback UI to show when an error occurs */
|
|
182
182
|
fallback?: react__default.ReactNode;
|
|
@@ -201,19 +201,19 @@ interface ErrorBoundaryState {
|
|
|
201
201
|
* function Editor() {
|
|
202
202
|
* const arrangement = useCreateArrangement(() => [audioTrack({ src: '/vocals.mp3' })]);
|
|
203
203
|
* return (
|
|
204
|
-
* <
|
|
204
|
+
* <WebAudioProvider arrangement={arrangement}>
|
|
205
205
|
* <Waveform />
|
|
206
|
-
* </
|
|
206
|
+
* </WebAudioProvider>
|
|
207
207
|
* );
|
|
208
208
|
* }
|
|
209
209
|
*
|
|
210
|
-
* <
|
|
210
|
+
* <WaveformErrorBoundary>
|
|
211
211
|
* <Editor />
|
|
212
|
-
* </
|
|
212
|
+
* </WaveformErrorBoundary>
|
|
213
213
|
* ```
|
|
214
214
|
*/
|
|
215
|
-
declare class
|
|
216
|
-
constructor(props:
|
|
215
|
+
declare class WaveformErrorBoundary extends react__default.Component<WaveformErrorBoundaryProps, ErrorBoundaryState> {
|
|
216
|
+
constructor(props: WaveformErrorBoundaryProps);
|
|
217
217
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
218
218
|
componentDidCatch(error: Error, errorInfo: react__default.ErrorInfo): void;
|
|
219
219
|
render(): react__default.ReactNode;
|
|
@@ -385,10 +385,10 @@ declare const PianoRollChannel: FunctionComponent<PianoRollChannelProps>;
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* Props passed to the default playhead component or custom render function.
|
|
388
|
-
* The same seven under `
|
|
389
|
-
* `
|
|
388
|
+
* The same seven under `WebAudioProvider` and
|
|
389
|
+
* `MediaElementProvider`. Engine values (`getPlaybackTime`,
|
|
390
390
|
* `getAudioContextTime`, `playbackStartTimeRef`, `audioStartPositionRef`) are
|
|
391
|
-
* not props: a playhead for `
|
|
391
|
+
* not props: a playhead for `WebAudioProvider` that needs them calls
|
|
392
392
|
* `useEngineRefs()` from `@waveform-playlist/browser`.
|
|
393
393
|
*/
|
|
394
394
|
interface PlayheadProps {
|
|
@@ -405,9 +405,9 @@ interface PlayheadProps {
|
|
|
405
405
|
currentTimeRef: react__default.RefObject<number>;
|
|
406
406
|
/**
|
|
407
407
|
* Ref to the time a playhead should be drawn at, in seconds. Under
|
|
408
|
-
* `
|
|
408
|
+
* `WebAudioProvider`, while playing, it is the audible time (raw
|
|
409
409
|
* minus output latency and look-ahead), and at rest the commanded position
|
|
410
|
-
* (seek, pause, stop). Under `
|
|
410
|
+
* (seek, pause, stop). Under `MediaElementProvider` it is the same
|
|
411
411
|
* ref as `currentTimeRef`. The provider keeps it current on every frame of
|
|
412
412
|
* playback, so a playhead that reads it stays in step with the progress fill.
|
|
413
413
|
*/
|
|
@@ -435,7 +435,7 @@ declare const Playhead: react__default.FC<PlayheadProps>;
|
|
|
435
435
|
*/
|
|
436
436
|
declare const PlayheadWithMarker: react__default.FC<PlayheadProps>;
|
|
437
437
|
|
|
438
|
-
interface
|
|
438
|
+
interface WaveformFrameProps {
|
|
439
439
|
readonly children?: react__default.ReactNode;
|
|
440
440
|
readonly backgroundColor?: string;
|
|
441
441
|
readonly timescaleBackgroundColor?: string;
|
|
@@ -451,7 +451,7 @@ interface PlaylistProps {
|
|
|
451
451
|
/** When true, selection is in progress - raises z-index to prevent clip boundary interference */
|
|
452
452
|
readonly isSelecting?: boolean;
|
|
453
453
|
/** Data attribute indicating playlist loading state ('loading' | 'ready') */
|
|
454
|
-
readonly 'data-
|
|
454
|
+
readonly 'data-waveform-state'?: 'loading' | 'ready';
|
|
455
455
|
/** Track control slots rendered in the controls column, one per track */
|
|
456
456
|
readonly trackControlsSlots?: react__default.ReactNode[];
|
|
457
457
|
/** Height of the timescale gap spacer in the controls column (matches timescale height) */
|
|
@@ -459,7 +459,7 @@ interface PlaylistProps {
|
|
|
459
459
|
/** Class name for the outermost element. */
|
|
460
460
|
readonly className?: string;
|
|
461
461
|
}
|
|
462
|
-
declare const
|
|
462
|
+
declare const WaveformFrame: FunctionComponent<WaveformFrameProps>;
|
|
463
463
|
|
|
464
464
|
interface SelectionProps {
|
|
465
465
|
startPosition: number;
|
|
@@ -635,7 +635,7 @@ declare const SpectrogramLabels: react__default.FC<SpectrogramLabelsProps>;
|
|
|
635
635
|
interface SmartScaleProps {
|
|
636
636
|
/**
|
|
637
637
|
* Length of the timeline the scale covers, in milliseconds. A prop and not a
|
|
638
|
-
* field of `
|
|
638
|
+
* field of `WaveformViewInfoContext` (#768): the length changes on every pointer
|
|
639
639
|
* move of a trim at the end of the timeline, and every channel and track
|
|
640
640
|
* reads that context.
|
|
641
641
|
*/
|
|
@@ -876,7 +876,7 @@ declare const useDevicePixelRatio: () => number;
|
|
|
876
876
|
* `TimeScale`) need from the view they are drawn in. The browser package's
|
|
877
877
|
* roots publish it once per view; without one above, the defaults apply.
|
|
878
878
|
*/
|
|
879
|
-
type
|
|
879
|
+
type WaveformViewInfo = {
|
|
880
880
|
sampleRate: number;
|
|
881
881
|
samplesPerPixel: number;
|
|
882
882
|
/** Height in pixels of one channel. Default: 80 */
|
|
@@ -895,8 +895,8 @@ type PlaylistInfo = {
|
|
|
895
895
|
declare const DEFAULT_WAVE_HEIGHT = 80;
|
|
896
896
|
declare const DEFAULT_BAR_WIDTH = 1;
|
|
897
897
|
declare const DEFAULT_BAR_GAP = 0;
|
|
898
|
-
declare const
|
|
899
|
-
declare const
|
|
898
|
+
declare const WaveformViewInfoContext: react.Context<WaveformViewInfo>;
|
|
899
|
+
declare const useWaveformViewInfo: () => WaveformViewInfo;
|
|
900
900
|
|
|
901
901
|
declare const useTheme: () => styled_components.DefaultTheme | undefined;
|
|
902
902
|
|
|
@@ -1069,4 +1069,4 @@ declare function useThrottledValue<T>(source: ValueSource<T>, options?: UseThrot
|
|
|
1069
1069
|
*/
|
|
1070
1070
|
declare function useMeterLevels(meter: MeterSource, options?: UseThrottledValueOptions): MeterLevels;
|
|
1071
1071
|
|
|
1072
|
-
export { AutomaticScrollCheckbox, type AutomaticScrollCheckboxProps, BaseButton, BaseCheckbox, BaseCheckboxLabel, BaseCheckboxWrapper, BaseControlButton, BaseInput, BaseInputSmall, BaseLabel, BaseSelect, BaseSelectSmall, BaseSlider, type BeatsAndBarsContextValue, BeatsAndBarsProvider, type BeatsAndBarsProviderProps, type BeatsAndBarsSnapTo, Button, ButtonGroup, CLIP_BOUNDARY_WIDTH, CLIP_BOUNDARY_WIDTH_TOUCH, CLIP_HEADER_HEIGHT, Channel, type ChannelProps, Clip, ClipBoundary, type ClipBoundaryProps, ClipHeader, ClipHeaderPresentational, type ClipHeaderPresentationalProps, type ClipHeaderProps, ClipPlaceholderBody, type ClipPlaceholderBodyProps, type ClipProps, ClipViewportOriginProvider, CloseButton, type CloseButtonProps, type ColorStop, Controls, DEFAULT_BAR_GAP, DEFAULT_BAR_WIDTH, DEFAULT_PLAYBACK_RATES, DEFAULT_WAVE_HEIGHT, DevicePixelRatioProvider, DotsIcon, type DragHandleProps, FadeOverlay, type FadeOverlayProps, type GradientStop, GripIcon, Header, InlineLabel, LoopRegionMarkers, type LoopRegionMarkersProps, MasterVolumeControl, type MasterVolumeControlProps, MoveDownIcon, MoveUpIcon, PianoRollChannel, type PianoRollChannelProps, PlaybackRateSelect, type PlaybackRateSelectProps, Playhead, type PlayheadProps, PlayheadWithMarker,
|
|
1072
|
+
export { AutomaticScrollCheckbox, type AutomaticScrollCheckboxProps, BaseButton, BaseCheckbox, BaseCheckboxLabel, BaseCheckboxWrapper, BaseControlButton, BaseInput, BaseInputSmall, BaseLabel, BaseSelect, BaseSelectSmall, BaseSlider, type BeatsAndBarsContextValue, BeatsAndBarsProvider, type BeatsAndBarsProviderProps, type BeatsAndBarsSnapTo, Button, ButtonGroup, CLIP_BOUNDARY_WIDTH, CLIP_BOUNDARY_WIDTH_TOUCH, CLIP_HEADER_HEIGHT, Channel, type ChannelProps, Clip, ClipBoundary, type ClipBoundaryProps, ClipHeader, ClipHeaderPresentational, type ClipHeaderPresentationalProps, type ClipHeaderProps, ClipPlaceholderBody, type ClipPlaceholderBodyProps, type ClipProps, ClipViewportOriginProvider, CloseButton, type CloseButtonProps, type ColorStop, Controls, DEFAULT_BAR_GAP, DEFAULT_BAR_WIDTH, DEFAULT_PLAYBACK_RATES, DEFAULT_WAVE_HEIGHT, DevicePixelRatioProvider, DotsIcon, type DragHandleProps, FadeOverlay, type FadeOverlayProps, type GradientStop, GripIcon, Header, InlineLabel, LoopRegionMarkers, type LoopRegionMarkersProps, MasterVolumeControl, type MasterVolumeControlProps, MoveDownIcon, MoveUpIcon, PianoRollChannel, type PianoRollChannelProps, PlaybackRateSelect, type PlaybackRateSelectProps, Playhead, type PlayheadProps, PlayheadWithMarker, type PrecomputedTickData, type RenderPlayheadFunction, ReorderRail, type ReorderRailProps, type ScaleMode, ScreenReaderOnly, type ScrollViewport, ScrollViewportProvider, SegmentedVUMeter, type SegmentedVUMeterProps, Selection, type SelectionProps, SelectionTimeInputs, type SelectionTimeInputsProps, Slider, SliderWrapper, SmartChannel, type SmartChannelProps, SmartScale, type SmartScaleProps, SpectrogramChannel, type SpectrogramChannelProps, SpectrogramLabels, type SpectrogramLabelsProps, StyledTimeScale, type TimeFormat, TimeFormatSelect, type TimeFormatSelectProps, TimeInput, type TimeInputProps, TimeScale, type TimeScaleProps, TimescaleLoopRegion, type TimescaleLoopRegionProps, Track, TrackMenu, type TrackMenuItem, type TrackMenuProps, type TrackProps, TrashIcon, type UseThrottledValueOptions, VolumeDownIcon, VolumeUpIcon, type WaveformColor, type WaveformDrawMode, WaveformErrorBoundary, type WaveformErrorBoundaryProps, WaveformFrame, type WaveformFrameProps, type WaveformGradient, type WaveformTheme, type WaveformViewInfo, WaveformViewInfoContext, darkTheme, defaultTheme, formatTime, getScaleInfo, isWaveformGradient, parseTime, useBeatsAndBars, useClipViewportOrigin, useDevicePixelRatio, useMeterLevels, useScrollViewport, useScrollViewportSelector, useTheme, useThrottledValue, useVisibleChunkIndices, useWaveformViewInfo, waveformColorToCss };
|
package/dist/index.js
CHANGED
|
@@ -75,9 +75,6 @@ __export(index_exports, {
|
|
|
75
75
|
PlaybackRateSelect: () => PlaybackRateSelect,
|
|
76
76
|
Playhead: () => Playhead,
|
|
77
77
|
PlayheadWithMarker: () => PlayheadWithMarker,
|
|
78
|
-
Playlist: () => Playlist,
|
|
79
|
-
PlaylistErrorBoundary: () => PlaylistErrorBoundary,
|
|
80
|
-
PlaylistInfoContext: () => PlaylistInfoContext,
|
|
81
78
|
ReorderRail: () => ReorderRail,
|
|
82
79
|
ScreenReaderOnly: () => ScreenReaderOnly,
|
|
83
80
|
ScrollViewportProvider: () => ScrollViewportProvider,
|
|
@@ -100,6 +97,9 @@ __export(index_exports, {
|
|
|
100
97
|
TrashIcon: () => TrashIcon,
|
|
101
98
|
VolumeDownIcon: () => VolumeDownIcon,
|
|
102
99
|
VolumeUpIcon: () => VolumeUpIcon,
|
|
100
|
+
WaveformErrorBoundary: () => WaveformErrorBoundary,
|
|
101
|
+
WaveformFrame: () => WaveformFrame,
|
|
102
|
+
WaveformViewInfoContext: () => WaveformViewInfoContext,
|
|
103
103
|
darkTheme: () => darkTheme,
|
|
104
104
|
defaultTheme: () => defaultTheme,
|
|
105
105
|
formatTime: () => formatTime,
|
|
@@ -110,12 +110,12 @@ __export(index_exports, {
|
|
|
110
110
|
useClipViewportOrigin: () => useClipViewportOrigin,
|
|
111
111
|
useDevicePixelRatio: () => useDevicePixelRatio,
|
|
112
112
|
useMeterLevels: () => useMeterLevels,
|
|
113
|
-
usePlaylistInfo: () => usePlaylistInfo,
|
|
114
113
|
useScrollViewport: () => useScrollViewport,
|
|
115
114
|
useScrollViewportSelector: () => useScrollViewportSelector,
|
|
116
115
|
useTheme: () => useTheme2,
|
|
117
116
|
useThrottledValue: () => useThrottledValue,
|
|
118
117
|
useVisibleChunkIndices: () => useVisibleChunkIndices,
|
|
118
|
+
useWaveformViewInfo: () => useWaveformViewInfo,
|
|
119
119
|
waveformColorToCss: () => waveformColorToCss
|
|
120
120
|
});
|
|
121
121
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1039,7 +1039,7 @@ var errorContainerStyle = {
|
|
|
1039
1039
|
alignItems: "center",
|
|
1040
1040
|
justifyContent: "center"
|
|
1041
1041
|
};
|
|
1042
|
-
var
|
|
1042
|
+
var WaveformErrorBoundary = class extends import_react7.default.Component {
|
|
1043
1043
|
constructor(props) {
|
|
1044
1044
|
super(props);
|
|
1045
1045
|
this.state = { hasError: false, error: null };
|
|
@@ -1496,12 +1496,12 @@ var DevicePixelRatioProvider = ({ children }) => {
|
|
|
1496
1496
|
};
|
|
1497
1497
|
var useDevicePixelRatio = () => (0, import_react11.use)(DevicePixelRatioContext) ?? getScale();
|
|
1498
1498
|
|
|
1499
|
-
// src/contexts/
|
|
1499
|
+
// src/contexts/WaveformViewInfo.tsx
|
|
1500
1500
|
var import_react12 = require("react");
|
|
1501
1501
|
var DEFAULT_WAVE_HEIGHT = 80;
|
|
1502
1502
|
var DEFAULT_BAR_WIDTH = 1;
|
|
1503
1503
|
var DEFAULT_BAR_GAP = 0;
|
|
1504
|
-
var
|
|
1504
|
+
var WaveformViewInfoContext = (0, import_react12.createContext)({
|
|
1505
1505
|
sampleRate: 48e3,
|
|
1506
1506
|
samplesPerPixel: 1e3,
|
|
1507
1507
|
waveHeight: DEFAULT_WAVE_HEIGHT,
|
|
@@ -1511,7 +1511,7 @@ var PlaylistInfoContext = (0, import_react12.createContext)({
|
|
|
1511
1511
|
roundedBars: false,
|
|
1512
1512
|
progressBarWidth: DEFAULT_BAR_WIDTH + DEFAULT_BAR_GAP
|
|
1513
1513
|
});
|
|
1514
|
-
var
|
|
1514
|
+
var useWaveformViewInfo = () => (0, import_react12.use)(WaveformViewInfoContext);
|
|
1515
1515
|
|
|
1516
1516
|
// src/contexts/Theme.tsx
|
|
1517
1517
|
var import_react13 = require("react");
|
|
@@ -1826,7 +1826,7 @@ var PlayheadWithMarker = ({
|
|
|
1826
1826
|
] });
|
|
1827
1827
|
};
|
|
1828
1828
|
|
|
1829
|
-
// src/components/
|
|
1829
|
+
// src/components/WaveformFrame.tsx
|
|
1830
1830
|
var import_styled_components18 = __toESM(require("styled-components"));
|
|
1831
1831
|
var import_react17 = require("react");
|
|
1832
1832
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
@@ -1882,7 +1882,7 @@ var ClickOverlay = import_styled_components18.default.div`
|
|
|
1882
1882
|
/* When selecting, raise z-index above clip boundaries (z-index: 105) to prevent interference */
|
|
1883
1883
|
z-index: ${(props) => props.$isSelecting ? 110 : 1};
|
|
1884
1884
|
`;
|
|
1885
|
-
var
|
|
1885
|
+
var WaveformFrame = ({
|
|
1886
1886
|
children,
|
|
1887
1887
|
backgroundColor,
|
|
1888
1888
|
timescaleBackgroundColor,
|
|
@@ -1896,7 +1896,7 @@ var Playlist = ({
|
|
|
1896
1896
|
onTracksMouseUp,
|
|
1897
1897
|
scrollContainerRef,
|
|
1898
1898
|
isSelecting,
|
|
1899
|
-
"data-
|
|
1899
|
+
"data-waveform-state": waveformState,
|
|
1900
1900
|
trackControlsSlots,
|
|
1901
1901
|
timescaleGapHeight = 0,
|
|
1902
1902
|
className
|
|
@@ -1910,7 +1910,7 @@ var Playlist = ({
|
|
|
1910
1910
|
[scrollContainerRef]
|
|
1911
1911
|
);
|
|
1912
1912
|
const showControls = controlsWidth !== void 0 && controlsWidth > 0;
|
|
1913
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Wrapper3, { className, "data-
|
|
1913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Wrapper3, { className, "data-waveform-state": waveformState, children: [
|
|
1914
1914
|
showControls && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ControlsColumn, { $width: controlsWidth, children: [
|
|
1915
1915
|
timescaleGapHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TimescaleGap, { $height: timescaleGapHeight }),
|
|
1916
1916
|
trackControlsSlots
|
|
@@ -2585,7 +2585,7 @@ var SmartChannel = ({
|
|
|
2585
2585
|
roundedBars,
|
|
2586
2586
|
samplesPerPixel,
|
|
2587
2587
|
sampleRate: contextSampleRate
|
|
2588
|
-
} =
|
|
2588
|
+
} = useWaveformViewInfo();
|
|
2589
2589
|
const devicePixelRatio = useDevicePixelRatio();
|
|
2590
2590
|
const waveOutlineColor = isSelected && theme ? theme.selectedWaveOutlineColor : theme?.waveOutlineColor;
|
|
2591
2591
|
const waveFillColor = isSelected && theme ? theme.selectedWaveFillColor : theme?.waveFillColor;
|
|
@@ -2811,7 +2811,7 @@ var import_react23 = require("react");
|
|
|
2811
2811
|
var import_styled_components23 = __toESM(require("styled-components"));
|
|
2812
2812
|
var import_core6 = require("@waveform-playlist/core");
|
|
2813
2813
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2814
|
-
var
|
|
2814
|
+
var TimeScaleScroll = import_styled_components23.default.div.attrs((props) => ({
|
|
2815
2815
|
style: {
|
|
2816
2816
|
width: `${props.$cssWidth}px`,
|
|
2817
2817
|
height: `${props.$timeScaleHeight}px`
|
|
@@ -2848,7 +2848,7 @@ var TimeScale = (props) => {
|
|
|
2848
2848
|
tickData
|
|
2849
2849
|
} = props;
|
|
2850
2850
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2851
|
-
const { timeScaleHeight } = (0, import_react23.use)(
|
|
2851
|
+
const { timeScaleHeight } = (0, import_react23.use)(WaveformViewInfoContext);
|
|
2852
2852
|
const devicePixelRatio = useDevicePixelRatio();
|
|
2853
2853
|
const { widthX, canvasInfo, timeMarkersWithPositions } = tickData;
|
|
2854
2854
|
const visibleChunkIndices = useVisibleChunkIndices(widthX, import_core6.MAX_CANVAS_WIDTH);
|
|
@@ -2906,7 +2906,7 @@ var TimeScale = (props) => {
|
|
|
2906
2906
|
drawVersion,
|
|
2907
2907
|
visibleChunkIndices
|
|
2908
2908
|
]);
|
|
2909
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(TimeScaleScroll, { $cssWidth: widthX, $timeScaleHeight: timeScaleHeight, children: [
|
|
2910
2910
|
visibleMarkers,
|
|
2911
2911
|
visibleChunks
|
|
2912
2912
|
] });
|
|
@@ -2968,7 +2968,7 @@ var SmartScale = ({
|
|
|
2968
2968
|
durationMs: duration,
|
|
2969
2969
|
renderTick
|
|
2970
2970
|
}) => {
|
|
2971
|
-
const { samplesPerPixel, sampleRate, timeScaleHeight } = (0, import_react24.use)(
|
|
2971
|
+
const { samplesPerPixel, sampleRate, timeScaleHeight } = (0, import_react24.use)(WaveformViewInfoContext);
|
|
2972
2972
|
const beatsAndBars = useBeatsAndBars();
|
|
2973
2973
|
const tickLayout = (0, import_react24.useMemo)(() => {
|
|
2974
2974
|
const widthX = (0, import_core7.secondsToPixels)(duration / 1e3, samplesPerPixel, sampleRate);
|
|
@@ -3172,7 +3172,7 @@ var Track = ({
|
|
|
3172
3172
|
trackId,
|
|
3173
3173
|
isSelected = false
|
|
3174
3174
|
}) => {
|
|
3175
|
-
const { waveHeight } =
|
|
3175
|
+
const { waveHeight } = useWaveformViewInfo();
|
|
3176
3176
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3177
3177
|
Container,
|
|
3178
3178
|
{
|
|
@@ -4134,9 +4134,6 @@ function useMeterLevels(meter, options = {}) {
|
|
|
4134
4134
|
PlaybackRateSelect,
|
|
4135
4135
|
Playhead,
|
|
4136
4136
|
PlayheadWithMarker,
|
|
4137
|
-
Playlist,
|
|
4138
|
-
PlaylistErrorBoundary,
|
|
4139
|
-
PlaylistInfoContext,
|
|
4140
4137
|
ReorderRail,
|
|
4141
4138
|
ScreenReaderOnly,
|
|
4142
4139
|
ScrollViewportProvider,
|
|
@@ -4159,6 +4156,9 @@ function useMeterLevels(meter, options = {}) {
|
|
|
4159
4156
|
TrashIcon,
|
|
4160
4157
|
VolumeDownIcon,
|
|
4161
4158
|
VolumeUpIcon,
|
|
4159
|
+
WaveformErrorBoundary,
|
|
4160
|
+
WaveformFrame,
|
|
4161
|
+
WaveformViewInfoContext,
|
|
4162
4162
|
darkTheme,
|
|
4163
4163
|
defaultTheme,
|
|
4164
4164
|
formatTime,
|
|
@@ -4169,12 +4169,12 @@ function useMeterLevels(meter, options = {}) {
|
|
|
4169
4169
|
useClipViewportOrigin,
|
|
4170
4170
|
useDevicePixelRatio,
|
|
4171
4171
|
useMeterLevels,
|
|
4172
|
-
usePlaylistInfo,
|
|
4173
4172
|
useScrollViewport,
|
|
4174
4173
|
useScrollViewportSelector,
|
|
4175
4174
|
useTheme,
|
|
4176
4175
|
useThrottledValue,
|
|
4177
4176
|
useVisibleChunkIndices,
|
|
4177
|
+
useWaveformViewInfo,
|
|
4178
4178
|
waveformColorToCss
|
|
4179
4179
|
});
|
|
4180
4180
|
//# sourceMappingURL=index.js.map
|