@waveform-playlist/browser 8.1.0 → 9.0.1

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.ts CHANGED
@@ -1,23 +1,25 @@
1
1
  import { Analyser } from 'tone';
2
2
  import { default as default_2 } from 'react';
3
3
  import { default as default_3 } from 'waveform-data';
4
- import { DragCancelEvent } from '@dnd-kit/core';
5
- import { DragEndEvent } from '@dnd-kit/core';
6
- import { DragMoveEvent } from '@dnd-kit/core';
7
- import { DragStartEvent } from '@dnd-kit/core';
4
+ import { DragDropManager } from '@dnd-kit/abstract';
5
+ import { DragEndEvent } from '@dnd-kit/abstract';
6
+ import { DragMoveEvent } from '@dnd-kit/abstract';
7
+ import { DragOperation } from '@dnd-kit/abstract';
8
+ import { DragStartEvent } from '@dnd-kit/abstract';
8
9
  import { EngineState } from '@waveform-playlist/engine';
9
10
  import { Gain } from 'tone';
10
11
  import { InputNode } from 'tone';
11
12
  import { MediaElementPlayout } from '@waveform-playlist/media-element-playout';
12
- import { Modifier } from '@dnd-kit/core';
13
+ import { Modifier } from '@dnd-kit/abstract';
13
14
  import { MutableRefObject } from 'react';
14
15
  import { PlaylistEngine } from '@waveform-playlist/engine';
16
+ import { PluginDescriptor } from '@dnd-kit/abstract';
17
+ import { Plugins } from '@dnd-kit/abstract';
18
+ import { PointerSensor } from '@dnd-kit/dom';
15
19
  import { Provider } from 'react';
16
20
  import react__default from 'react';
17
21
  import { ReactNode } from 'react';
18
22
  import { RefObject } from 'react';
19
- import { SensorDescriptor } from '@dnd-kit/core';
20
- import { SensorOptions } from '@dnd-kit/core';
21
23
  import * as Tone from 'tone';
22
24
  import { ToneAudioNode } from 'tone';
23
25
  import { Volume } from 'tone';
@@ -262,6 +264,28 @@ export declare const AutomaticScrollCheckbox: default_2.FC<{
262
264
  */
263
265
  declare type Bits = 8 | 16;
264
266
 
267
+ /**
268
+ * Modifier that constrains clip drag movement to prevent overlaps.
269
+ *
270
+ * For clip move operations: constrains horizontal transform to valid positions
271
+ * using the engine's collision detection.
272
+ *
273
+ * For boundary trim operations: returns zero transform because visual feedback
274
+ * comes from React state updates resizing the clip, not from CSS translate.
275
+ */
276
+ export declare class ClipCollisionModifier extends Modifier<DragDropManager<any, any>, ClipCollisionOptions> {
277
+ apply(operation: DragOperation): {
278
+ x: number;
279
+ y: number;
280
+ };
281
+ static configure: (options: ClipCollisionOptions) => PluginDescriptor<any, any, typeof ClipCollisionModifier>;
282
+ }
283
+
284
+ declare interface ClipCollisionOptions {
285
+ tracks: ClipTrack[];
286
+ samplesPerPixel: number;
287
+ }
288
+
265
289
  declare interface ClipPeaks {
266
290
  clipId: string;
267
291
  trackName: string;
@@ -344,17 +368,11 @@ export declare const DownloadAnnotationsButton: default_2.FC<{
344
368
  className?: string;
345
369
  }>;
346
370
 
347
- /**
348
- * Hook for configuring @dnd-kit sensors for clip dragging
349
- *
350
- * Provides consistent drag activation behavior across all examples.
351
- * Supports both desktop (immediate feedback) and mobile (delay-based) interactions.
352
- */
353
371
  declare interface DragSensorOptions {
354
372
  /**
355
373
  * Enable mobile-optimized touch handling with delay-based activation.
356
- * When true, uses TouchSensor with 250ms delay to distinguish drag from scroll.
357
- * When false (default), uses PointerSensor with 1px activation for immediate feedback.
374
+ * When true, touch events get delay-based activation while mouse/pen get distance-based.
375
+ * When false (default), all pointer types use distance-based activation (1px).
358
376
  */
359
377
  touchOptimized?: boolean;
360
378
  /**
@@ -843,6 +861,19 @@ export declare interface MediaElementWaveformProps {
843
861
  className?: string;
844
862
  }
845
863
 
864
+ /**
865
+ * DragDropProvider plugins customizer that disables the Feedback plugin's drop animation.
866
+ *
867
+ * Without this, the Feedback plugin animates the dragged element back to its original
868
+ * position on drop, causing a visual snap-back before React re-renders at the new position.
869
+ *
870
+ * Usage:
871
+ * ```tsx
872
+ * <DragDropProvider plugins={noDropAnimationPlugins} ...>
873
+ * ```
874
+ */
875
+ export declare const noDropAnimationPlugins: (defaults: Plugins) => Plugins;
876
+
846
877
  /**
847
878
  * Callback when annotations are updated (e.g., boundaries dragged).
848
879
  * Called with the full updated annotations array.
@@ -1336,7 +1367,7 @@ declare interface TrackState_2 {
1336
1367
  /**
1337
1368
  * Custom hook for handling annotation drag operations (boundary trimming)
1338
1369
  *
1339
- * Provides drag handlers for use with @dnd-kit/core DndContext.
1370
+ * Provides drag handlers for use with @dnd-kit/react DragDropProvider.
1340
1371
  * Handles annotation boundary resizing with linked endpoints support.
1341
1372
  *
1342
1373
  * @example
@@ -1351,21 +1382,21 @@ declare interface TrackState_2 {
1351
1382
  * });
1352
1383
  *
1353
1384
  * return (
1354
- * <DndContext
1385
+ * <DragDropProvider
1355
1386
  * onDragStart={onDragStart}
1356
1387
  * onDragMove={onDragMove}
1357
1388
  * onDragEnd={onDragEnd}
1358
- * modifiers={[restrictToHorizontalAxis]}
1389
+ * modifiers={[RestrictToHorizontalAxis]}
1359
1390
  * >
1360
1391
  * {renderAnnotations()}
1361
- * </DndContext>
1392
+ * </DragDropProvider>
1362
1393
  * );
1363
1394
  * ```
1364
1395
  */
1365
1396
  export declare function useAnnotationDragHandlers({ annotations, onAnnotationsChange, samplesPerPixel, sampleRate, duration, linkEndpoints, }: UseAnnotationDragHandlersOptions): {
1366
- onDragStart: (event: DragStartEvent) => void;
1367
- onDragMove: (event: DragMoveEvent) => void;
1368
- onDragEnd: () => void;
1397
+ onDragStart: (event: Parameters<DragStartEvent>[0]) => void;
1398
+ onDragMove: (event: Parameters<DragMoveEvent>[0]) => void;
1399
+ onDragEnd: (event: Parameters<DragEndEvent>[0]) => void;
1369
1400
  };
1370
1401
 
1371
1402
  declare interface UseAnnotationDragHandlersOptions {
@@ -1515,9 +1546,11 @@ declare interface UseAudioTracksOptions {
1515
1546
  /**
1516
1547
  * Custom hook for handling clip drag operations (movement and trimming)
1517
1548
  *
1518
- * Provides drag handlers and collision modifier for use with @dnd-kit/core DndContext.
1549
+ * Provides drag handlers for use with @dnd-kit/react DragDropProvider.
1519
1550
  * Handles both clip movement (dragging entire clips) and boundary trimming (adjusting clip edges).
1520
1551
  *
1552
+ * Collision detection for clip moves is handled by `ClipCollisionModifier` (passed to DragDropProvider).
1553
+ *
1521
1554
  * **Move:** `onDragEnd` delegates to `engine.moveClip()` in one shot.
1522
1555
  *
1523
1556
  * **Trim:** `onDragMove` updates React state per-frame via `onTracksChange` for smooth
@@ -1527,7 +1560,7 @@ declare interface UseAudioTracksOptions {
1527
1560
  *
1528
1561
  * @example
1529
1562
  * ```tsx
1530
- * const { onDragStart, onDragMove, onDragEnd, onDragCancel, collisionModifier } = useClipDragHandlers({
1563
+ * const { onDragStart, onDragMove, onDragEnd } = useClipDragHandlers({
1531
1564
  * tracks,
1532
1565
  * onTracksChange: setTracks,
1533
1566
  * samplesPerPixel,
@@ -1537,29 +1570,21 @@ declare interface UseAudioTracksOptions {
1537
1570
  * });
1538
1571
  *
1539
1572
  * return (
1540
- * <DndContext
1573
+ * <DragDropProvider
1541
1574
  * onDragStart={onDragStart}
1542
1575
  * onDragMove={onDragMove}
1543
1576
  * onDragEnd={onDragEnd}
1544
- * onDragCancel={onDragCancel}
1545
- * modifiers={[restrictToHorizontalAxis, collisionModifier]}
1577
+ * modifiers={[RestrictToHorizontalAxis, ClipCollisionModifier.configure({ tracks, samplesPerPixel })]}
1546
1578
  * >
1547
1579
  * <Waveform showClipHeaders={true} />
1548
- * </DndContext>
1580
+ * </DragDropProvider>
1549
1581
  * );
1550
1582
  * ```
1551
1583
  */
1552
1584
  export declare function useClipDragHandlers({ tracks, onTracksChange, samplesPerPixel, sampleRate, engineRef, isDraggingRef, }: UseClipDragHandlersOptions): {
1553
- onDragStart: (event: DragStartEvent) => void;
1554
- onDragMove: (event: DragMoveEvent) => void;
1555
- onDragEnd: (event: DragEndEvent) => void;
1556
- onDragCancel: (_event: DragCancelEvent) => void;
1557
- collisionModifier: (args: Parameters<Modifier>[0]) => {
1558
- scaleX: number;
1559
- scaleY: number;
1560
- x: number;
1561
- y: number;
1562
- };
1585
+ onDragStart: (event: Parameters<DragStartEvent>[0]) => void;
1586
+ onDragMove: (event: Parameters<DragMoveEvent>[0]) => void;
1587
+ onDragEnd: (event: Parameters<DragEndEvent>[0]) => void;
1563
1588
  };
1564
1589
 
1565
1590
  declare interface UseClipDragHandlersOptions {
@@ -1619,25 +1644,17 @@ declare interface UseClipSplittingResult {
1619
1644
  * Returns configured sensors for @dnd-kit drag operations
1620
1645
  *
1621
1646
  * @param options - Configuration options for drag sensors
1622
- * @returns Configured sensors appropriate for the interaction mode
1647
+ * @returns Array of sensor constructors/descriptors for DragDropProvider's sensors prop
1623
1648
  *
1624
1649
  * @example
1625
- * // Desktop-optimized (default)
1650
+ * // Desktop-optimized (default — 1px distance activation for all pointer types)
1626
1651
  * const sensors = useDragSensors();
1627
1652
  *
1628
1653
  * @example
1629
- * // Mobile-optimized with touch delay
1630
- * const sensors = useDragSensors({ touchOptimized: true });
1631
- *
1632
- * @example
1633
- * // Custom touch settings
1634
- * const sensors = useDragSensors({
1635
- * touchOptimized: true,
1636
- * touchDelay: 300,
1637
- * touchTolerance: 8
1638
- * });
1654
+ * // Mobile-optimized with custom touch delay
1655
+ * const sensors = useDragSensors({ touchOptimized: true, touchDelay: 300 });
1639
1656
  */
1640
- export declare function useDragSensors(options?: DragSensorOptions): SensorDescriptor<SensorOptions>[];
1657
+ export declare function useDragSensors(options?: DragSensorOptions): (typeof PointerSensor | PluginDescriptor<any, any, any>)[];
1641
1658
 
1642
1659
  /**
1643
1660
  * Hook for managing a dynamic chain of audio effects with real-time parameter updates