@waveform-playlist/browser 15.3.3 → 15.4.0

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/dist/index.d.mts CHANGED
@@ -13,6 +13,17 @@ import { DragStartEvent, DragMoveEvent, DragEndEvent, PluginDescriptor, Modifier
13
13
  import { PointerSensor } from '@dnd-kit/dom';
14
14
  import WaveformData from 'waveform-data';
15
15
 
16
+ /**
17
+ * Pure helpers for the track-reorder drag preview.
18
+ *
19
+ * The preview is view-level only: it produces a DISPLAY order/geometry while
20
+ * the engine's committed `tracks` order stays untouched until drop.
21
+ */
22
+ interface TrackDragPreview {
23
+ trackId: string;
24
+ toIndex: number;
25
+ }
26
+
16
27
  interface ClipPeaks {
17
28
  clipId: string;
18
29
  trackName: string;
@@ -26,6 +37,7 @@ interface ClipPeaks {
26
37
  offsetSamples?: number;
27
38
  }
28
39
  type TrackClipPeaks = ClipPeaks[];
40
+
29
41
  interface WaveformTrack {
30
42
  src: string | AudioBuffer;
31
43
  name?: string;
@@ -115,6 +127,20 @@ interface PlaylistControlsContextValue {
115
127
  setTrackSolo: (trackIndex: number, soloed: boolean) => void;
116
128
  setTrackVolume: (trackIndex: number, volume: number) => void;
117
129
  setTrackPan: (trackIndex: number, pan: number) => void;
130
+ /** Move a track to a new index in the vertical track order. Purely
131
+ * organizational — playback is not interrupted. The reordered tracks
132
+ * array flows back through onTracksChange. */
133
+ reorderTrack: (trackId: string, toIndex: number) => void;
134
+ /** Internal: call after every track-reorder DRAG interaction ends
135
+ * (committed or canceled) to force PlaylistVisualization to remount the
136
+ * track-controls slots, discarding any @dnd-kit sortable-plugin DOM
137
+ * corruption. Not needed for button-driven reorderTrack calls (they never
138
+ * touch dnd-kit's DOM). See bumpTrackReorderEpoch in the provider. */
139
+ bumpTrackReorderEpoch: () => void;
140
+ /** INTERNAL wiring for ClipInteractionProvider: publishes/clears the live
141
+ * track-reorder drag preview. Custom drag integrations may call it, but
142
+ * most consumers only ever READ trackDragPreview from usePlaylistData(). */
143
+ setTrackDragPreview: React__default.Dispatch<React__default.SetStateAction<TrackDragPreview | null>>;
118
144
  setSelection: (start: number, end: number) => void;
119
145
  setSelectedTrackId: (trackId: string | null) => void;
120
146
  setTimeFormat: (format: TimeFormat) => void;
@@ -175,6 +201,16 @@ interface PlaylistDataContextValue {
175
201
  progressBarWidth: number;
176
202
  /** Whether the playlist has finished loading all tracks */
177
203
  isReady: boolean;
204
+ /** Internal: incremented after every track-reorder drag interaction ends.
205
+ * PlaylistVisualization folds this into the track-controls slot `key` to
206
+ * force a remount, working around @dnd-kit sortable-plugin DOM corruption
207
+ * (see bumpTrackReorderEpoch in PlaylistControlsContextValue). */
208
+ trackReorderEpoch: number;
209
+ /** Non-null while a track-reorder drag is live: the dragged track and the
210
+ * index it would drop at. Both playlist columns derive their display
211
+ * layout from it; custom renderTrackControls consumers can read it to
212
+ * mirror the preview in their own UI. */
213
+ trackDragPreview: TrackDragPreview | null;
178
214
  /** Whether tracks are rendered in mono mode */
179
215
  mono: boolean;
180
216
  /** Ref set by useClipDragHandlers during boundary trim drags.
@@ -984,6 +1020,10 @@ interface WaveformProps {
984
1020
  touchOptimized?: boolean;
985
1021
  /** Callback when a track's close button is clicked. Only renders close button when provided. */
986
1022
  onRemoveTrack?: (trackIndex: number) => void;
1023
+ /** Enable vertical track reordering: a drag grip + move up/down buttons on
1024
+ * each default track control panel. Drag requires ClipInteractionProvider
1025
+ * (the ambient DragDropProvider); the buttons work regardless. Default: false. */
1026
+ trackReordering?: boolean;
987
1027
  recordingState?: {
988
1028
  isRecording: boolean;
989
1029
  trackId: string;
@@ -1159,6 +1199,10 @@ interface PlaylistVisualizationProps {
1159
1199
  */
1160
1200
  latencyOffset?: number;
1161
1201
  };
1202
+ /** Enable vertical track reordering: a drag grip + move up/down buttons on
1203
+ * each default track control panel. Drag requires ClipInteractionProvider
1204
+ * (the ambient DragDropProvider); the buttons work regardless. Default: false. */
1205
+ trackReordering?: boolean;
1162
1206
  }
1163
1207
  /**
1164
1208
  * Standalone playlist visualization component (WebAudio version).
@@ -1234,6 +1278,28 @@ interface KeyboardShortcutsProps {
1234
1278
  */
1235
1279
  declare const KeyboardShortcuts: React__default.FC<KeyboardShortcutsProps>;
1236
1280
 
1281
+ interface SortableTrackControlsRenderProps {
1282
+ /** Attach to the slot wrapper element (the sortable item). */
1283
+ ref: (element: Element | null) => void;
1284
+ /** Attach to the drag grip element. */
1285
+ handleRef: (element: Element | null) => void;
1286
+ isDragSource: boolean;
1287
+ }
1288
+ interface SortableTrackControlsProps {
1289
+ trackId: string;
1290
+ index: number;
1291
+ disabled?: boolean;
1292
+ children: (props: SortableTrackControlsRenderProps) => React__default.ReactNode;
1293
+ }
1294
+ /**
1295
+ * Registers a track-controls row as a vertical sortable item in the ambient
1296
+ * DragDropProvider (ClipInteractionProvider). The per-source modifiers
1297
+ * REPLACE the provider's clip modifiers for this operation, so track drags
1298
+ * are vertical-only and skip clip collision/snap. Data kind 'track-reorder'
1299
+ * is the discriminator the shared drag handlers branch on.
1300
+ */
1301
+ declare const SortableTrackControls: React__default.FC<SortableTrackControlsProps>;
1302
+
1237
1303
  /**
1238
1304
  * Props the browser package passes to the AnnotationText component.
1239
1305
  * Mirrors what PlaylistAnnotationList and MediaElementAnnotationList actually use.
@@ -1508,4 +1574,4 @@ declare function getWaveformDataMetadata(src: string): Promise<{
1508
1574
  bits: 8 | 16;
1509
1575
  }>;
1510
1576
 
1511
- export { type AnnotationIntegration, AnnotationIntegrationProvider, AudioPosition, AutomaticScrollCheckbox, ClearAllButton, type ClearAllButtonProps, ClipCollisionModifier, ClipInteractionProvider, type ClipInteractionProviderProps, ContinuousPlayCheckbox, DownloadAnnotationsButton, EditableCheckbox, FastForwardButton, type FrameData, type GetAnnotationBoxLabelFn, KeyboardShortcuts, type KeyboardShortcutsProps, LinkEndpointsCheckbox, LoopButton, MasterVolumeControl, type MasterVolumeControls, type MediaElementAnimationContextValue, MediaElementAnnotationList, type MediaElementAnnotationListProps, type MediaElementControlsContextValue, type MediaElementDataContextValue, MediaElementPlaylist, type MediaElementPlaylistProps, MediaElementPlaylistProvider, type MediaElementStateContextValue, type MediaElementTrackConfig, MediaElementWaveform, type MediaElementWaveformProps, type OnAnnotationUpdateFn, PauseButton, PlayButton, PlaylistAnnotationList, type PlaylistAnnotationListProps, PlaylistVisualization, type PlaylistVisualizationProps, RewindButton, SelectionTimeInputs, SetLoopRegionButton, SkipBackwardButton, SkipForwardButton, SnapToGridModifier, type SpectrogramCanvasRegistration, type SpectrogramIntegration, SpectrogramIntegrationProvider, StopButton, type TimeFormatControls, TimeFormatSelect, type TrackState, type UsePlaybackShortcutsOptions, type UsePlaybackShortcutsReturn, Waveform, WaveformPlaylistProvider, type WaveformProps, type WaveformTrack, type ZoomControls, ZoomInButton, ZoomOutButton, getWaveformDataMetadata, loadPeaksFromWaveformData, loadWaveformData, noDropAnimationPlugins, useAnnotationDragHandlers, useAnnotationIntegration, useAnnotationKeyboardControls, useClipDragHandlers, useClipInteractionEnabled, useClipSplitting, useDragSensors, useKeyboardShortcuts, useMasterVolume, useMediaElementAnimation, useMediaElementControls, useMediaElementData, useMediaElementState, usePlaybackAnimation, usePlaybackShortcuts, usePlaylistControls, usePlaylistData, usePlaylistDataOptional, usePlaylistState, useSpectrogramIntegration, useTimeFormat, useZoomControls, waveformDataToPeaks };
1577
+ export { type AnnotationIntegration, AnnotationIntegrationProvider, AudioPosition, AutomaticScrollCheckbox, ClearAllButton, type ClearAllButtonProps, ClipCollisionModifier, ClipInteractionProvider, type ClipInteractionProviderProps, ContinuousPlayCheckbox, DownloadAnnotationsButton, EditableCheckbox, FastForwardButton, type FrameData, type GetAnnotationBoxLabelFn, KeyboardShortcuts, type KeyboardShortcutsProps, LinkEndpointsCheckbox, LoopButton, MasterVolumeControl, type MasterVolumeControls, type MediaElementAnimationContextValue, MediaElementAnnotationList, type MediaElementAnnotationListProps, type MediaElementControlsContextValue, type MediaElementDataContextValue, MediaElementPlaylist, type MediaElementPlaylistProps, MediaElementPlaylistProvider, type MediaElementStateContextValue, type MediaElementTrackConfig, MediaElementWaveform, type MediaElementWaveformProps, type OnAnnotationUpdateFn, PauseButton, PlayButton, PlaylistAnnotationList, type PlaylistAnnotationListProps, PlaylistVisualization, type PlaylistVisualizationProps, RewindButton, SelectionTimeInputs, SetLoopRegionButton, SkipBackwardButton, SkipForwardButton, SnapToGridModifier, SortableTrackControls, type SortableTrackControlsProps, type SortableTrackControlsRenderProps, type SpectrogramCanvasRegistration, type SpectrogramIntegration, SpectrogramIntegrationProvider, StopButton, type TimeFormatControls, TimeFormatSelect, type TrackState, type UsePlaybackShortcutsOptions, type UsePlaybackShortcutsReturn, Waveform, WaveformPlaylistProvider, type WaveformProps, type WaveformTrack, type ZoomControls, ZoomInButton, ZoomOutButton, getWaveformDataMetadata, loadPeaksFromWaveformData, loadWaveformData, noDropAnimationPlugins, useAnnotationDragHandlers, useAnnotationIntegration, useAnnotationKeyboardControls, useClipDragHandlers, useClipInteractionEnabled, useClipSplitting, useDragSensors, useKeyboardShortcuts, useMasterVolume, useMediaElementAnimation, useMediaElementControls, useMediaElementData, useMediaElementState, usePlaybackAnimation, usePlaybackShortcuts, usePlaylistControls, usePlaylistData, usePlaylistDataOptional, usePlaylistState, useSpectrogramIntegration, useTimeFormat, useZoomControls, waveformDataToPeaks };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,17 @@ import { DragStartEvent, DragMoveEvent, DragEndEvent, PluginDescriptor, Modifier
13
13
  import { PointerSensor } from '@dnd-kit/dom';
14
14
  import WaveformData from 'waveform-data';
15
15
 
16
+ /**
17
+ * Pure helpers for the track-reorder drag preview.
18
+ *
19
+ * The preview is view-level only: it produces a DISPLAY order/geometry while
20
+ * the engine's committed `tracks` order stays untouched until drop.
21
+ */
22
+ interface TrackDragPreview {
23
+ trackId: string;
24
+ toIndex: number;
25
+ }
26
+
16
27
  interface ClipPeaks {
17
28
  clipId: string;
18
29
  trackName: string;
@@ -26,6 +37,7 @@ interface ClipPeaks {
26
37
  offsetSamples?: number;
27
38
  }
28
39
  type TrackClipPeaks = ClipPeaks[];
40
+
29
41
  interface WaveformTrack {
30
42
  src: string | AudioBuffer;
31
43
  name?: string;
@@ -115,6 +127,20 @@ interface PlaylistControlsContextValue {
115
127
  setTrackSolo: (trackIndex: number, soloed: boolean) => void;
116
128
  setTrackVolume: (trackIndex: number, volume: number) => void;
117
129
  setTrackPan: (trackIndex: number, pan: number) => void;
130
+ /** Move a track to a new index in the vertical track order. Purely
131
+ * organizational — playback is not interrupted. The reordered tracks
132
+ * array flows back through onTracksChange. */
133
+ reorderTrack: (trackId: string, toIndex: number) => void;
134
+ /** Internal: call after every track-reorder DRAG interaction ends
135
+ * (committed or canceled) to force PlaylistVisualization to remount the
136
+ * track-controls slots, discarding any @dnd-kit sortable-plugin DOM
137
+ * corruption. Not needed for button-driven reorderTrack calls (they never
138
+ * touch dnd-kit's DOM). See bumpTrackReorderEpoch in the provider. */
139
+ bumpTrackReorderEpoch: () => void;
140
+ /** INTERNAL wiring for ClipInteractionProvider: publishes/clears the live
141
+ * track-reorder drag preview. Custom drag integrations may call it, but
142
+ * most consumers only ever READ trackDragPreview from usePlaylistData(). */
143
+ setTrackDragPreview: React__default.Dispatch<React__default.SetStateAction<TrackDragPreview | null>>;
118
144
  setSelection: (start: number, end: number) => void;
119
145
  setSelectedTrackId: (trackId: string | null) => void;
120
146
  setTimeFormat: (format: TimeFormat) => void;
@@ -175,6 +201,16 @@ interface PlaylistDataContextValue {
175
201
  progressBarWidth: number;
176
202
  /** Whether the playlist has finished loading all tracks */
177
203
  isReady: boolean;
204
+ /** Internal: incremented after every track-reorder drag interaction ends.
205
+ * PlaylistVisualization folds this into the track-controls slot `key` to
206
+ * force a remount, working around @dnd-kit sortable-plugin DOM corruption
207
+ * (see bumpTrackReorderEpoch in PlaylistControlsContextValue). */
208
+ trackReorderEpoch: number;
209
+ /** Non-null while a track-reorder drag is live: the dragged track and the
210
+ * index it would drop at. Both playlist columns derive their display
211
+ * layout from it; custom renderTrackControls consumers can read it to
212
+ * mirror the preview in their own UI. */
213
+ trackDragPreview: TrackDragPreview | null;
178
214
  /** Whether tracks are rendered in mono mode */
179
215
  mono: boolean;
180
216
  /** Ref set by useClipDragHandlers during boundary trim drags.
@@ -984,6 +1020,10 @@ interface WaveformProps {
984
1020
  touchOptimized?: boolean;
985
1021
  /** Callback when a track's close button is clicked. Only renders close button when provided. */
986
1022
  onRemoveTrack?: (trackIndex: number) => void;
1023
+ /** Enable vertical track reordering: a drag grip + move up/down buttons on
1024
+ * each default track control panel. Drag requires ClipInteractionProvider
1025
+ * (the ambient DragDropProvider); the buttons work regardless. Default: false. */
1026
+ trackReordering?: boolean;
987
1027
  recordingState?: {
988
1028
  isRecording: boolean;
989
1029
  trackId: string;
@@ -1159,6 +1199,10 @@ interface PlaylistVisualizationProps {
1159
1199
  */
1160
1200
  latencyOffset?: number;
1161
1201
  };
1202
+ /** Enable vertical track reordering: a drag grip + move up/down buttons on
1203
+ * each default track control panel. Drag requires ClipInteractionProvider
1204
+ * (the ambient DragDropProvider); the buttons work regardless. Default: false. */
1205
+ trackReordering?: boolean;
1162
1206
  }
1163
1207
  /**
1164
1208
  * Standalone playlist visualization component (WebAudio version).
@@ -1234,6 +1278,28 @@ interface KeyboardShortcutsProps {
1234
1278
  */
1235
1279
  declare const KeyboardShortcuts: React__default.FC<KeyboardShortcutsProps>;
1236
1280
 
1281
+ interface SortableTrackControlsRenderProps {
1282
+ /** Attach to the slot wrapper element (the sortable item). */
1283
+ ref: (element: Element | null) => void;
1284
+ /** Attach to the drag grip element. */
1285
+ handleRef: (element: Element | null) => void;
1286
+ isDragSource: boolean;
1287
+ }
1288
+ interface SortableTrackControlsProps {
1289
+ trackId: string;
1290
+ index: number;
1291
+ disabled?: boolean;
1292
+ children: (props: SortableTrackControlsRenderProps) => React__default.ReactNode;
1293
+ }
1294
+ /**
1295
+ * Registers a track-controls row as a vertical sortable item in the ambient
1296
+ * DragDropProvider (ClipInteractionProvider). The per-source modifiers
1297
+ * REPLACE the provider's clip modifiers for this operation, so track drags
1298
+ * are vertical-only and skip clip collision/snap. Data kind 'track-reorder'
1299
+ * is the discriminator the shared drag handlers branch on.
1300
+ */
1301
+ declare const SortableTrackControls: React__default.FC<SortableTrackControlsProps>;
1302
+
1237
1303
  /**
1238
1304
  * Props the browser package passes to the AnnotationText component.
1239
1305
  * Mirrors what PlaylistAnnotationList and MediaElementAnnotationList actually use.
@@ -1508,4 +1574,4 @@ declare function getWaveformDataMetadata(src: string): Promise<{
1508
1574
  bits: 8 | 16;
1509
1575
  }>;
1510
1576
 
1511
- export { type AnnotationIntegration, AnnotationIntegrationProvider, AudioPosition, AutomaticScrollCheckbox, ClearAllButton, type ClearAllButtonProps, ClipCollisionModifier, ClipInteractionProvider, type ClipInteractionProviderProps, ContinuousPlayCheckbox, DownloadAnnotationsButton, EditableCheckbox, FastForwardButton, type FrameData, type GetAnnotationBoxLabelFn, KeyboardShortcuts, type KeyboardShortcutsProps, LinkEndpointsCheckbox, LoopButton, MasterVolumeControl, type MasterVolumeControls, type MediaElementAnimationContextValue, MediaElementAnnotationList, type MediaElementAnnotationListProps, type MediaElementControlsContextValue, type MediaElementDataContextValue, MediaElementPlaylist, type MediaElementPlaylistProps, MediaElementPlaylistProvider, type MediaElementStateContextValue, type MediaElementTrackConfig, MediaElementWaveform, type MediaElementWaveformProps, type OnAnnotationUpdateFn, PauseButton, PlayButton, PlaylistAnnotationList, type PlaylistAnnotationListProps, PlaylistVisualization, type PlaylistVisualizationProps, RewindButton, SelectionTimeInputs, SetLoopRegionButton, SkipBackwardButton, SkipForwardButton, SnapToGridModifier, type SpectrogramCanvasRegistration, type SpectrogramIntegration, SpectrogramIntegrationProvider, StopButton, type TimeFormatControls, TimeFormatSelect, type TrackState, type UsePlaybackShortcutsOptions, type UsePlaybackShortcutsReturn, Waveform, WaveformPlaylistProvider, type WaveformProps, type WaveformTrack, type ZoomControls, ZoomInButton, ZoomOutButton, getWaveformDataMetadata, loadPeaksFromWaveformData, loadWaveformData, noDropAnimationPlugins, useAnnotationDragHandlers, useAnnotationIntegration, useAnnotationKeyboardControls, useClipDragHandlers, useClipInteractionEnabled, useClipSplitting, useDragSensors, useKeyboardShortcuts, useMasterVolume, useMediaElementAnimation, useMediaElementControls, useMediaElementData, useMediaElementState, usePlaybackAnimation, usePlaybackShortcuts, usePlaylistControls, usePlaylistData, usePlaylistDataOptional, usePlaylistState, useSpectrogramIntegration, useTimeFormat, useZoomControls, waveformDataToPeaks };
1577
+ export { type AnnotationIntegration, AnnotationIntegrationProvider, AudioPosition, AutomaticScrollCheckbox, ClearAllButton, type ClearAllButtonProps, ClipCollisionModifier, ClipInteractionProvider, type ClipInteractionProviderProps, ContinuousPlayCheckbox, DownloadAnnotationsButton, EditableCheckbox, FastForwardButton, type FrameData, type GetAnnotationBoxLabelFn, KeyboardShortcuts, type KeyboardShortcutsProps, LinkEndpointsCheckbox, LoopButton, MasterVolumeControl, type MasterVolumeControls, type MediaElementAnimationContextValue, MediaElementAnnotationList, type MediaElementAnnotationListProps, type MediaElementControlsContextValue, type MediaElementDataContextValue, MediaElementPlaylist, type MediaElementPlaylistProps, MediaElementPlaylistProvider, type MediaElementStateContextValue, type MediaElementTrackConfig, MediaElementWaveform, type MediaElementWaveformProps, type OnAnnotationUpdateFn, PauseButton, PlayButton, PlaylistAnnotationList, type PlaylistAnnotationListProps, PlaylistVisualization, type PlaylistVisualizationProps, RewindButton, SelectionTimeInputs, SetLoopRegionButton, SkipBackwardButton, SkipForwardButton, SnapToGridModifier, SortableTrackControls, type SortableTrackControlsProps, type SortableTrackControlsRenderProps, type SpectrogramCanvasRegistration, type SpectrogramIntegration, SpectrogramIntegrationProvider, StopButton, type TimeFormatControls, TimeFormatSelect, type TrackState, type UsePlaybackShortcutsOptions, type UsePlaybackShortcutsReturn, Waveform, WaveformPlaylistProvider, type WaveformProps, type WaveformTrack, type ZoomControls, ZoomInButton, ZoomOutButton, getWaveformDataMetadata, loadPeaksFromWaveformData, loadWaveformData, noDropAnimationPlugins, useAnnotationDragHandlers, useAnnotationIntegration, useAnnotationKeyboardControls, useClipDragHandlers, useClipInteractionEnabled, useClipSplitting, useDragSensors, useKeyboardShortcuts, useMasterVolume, useMediaElementAnimation, useMediaElementControls, useMediaElementData, useMediaElementState, usePlaybackAnimation, usePlaybackShortcuts, usePlaylistControls, usePlaylistData, usePlaylistDataOptional, usePlaylistState, useSpectrogramIntegration, useTimeFormat, useZoomControls, waveformDataToPeaks };