@waveform-playlist/browser 8.0.0 → 9.0.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.ts +74 -53
- package/dist/index.js +142 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8045 -3207
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
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 {
|
|
5
|
-
import { DragEndEvent } from '@dnd-kit/
|
|
6
|
-
import { DragMoveEvent } from '@dnd-kit/
|
|
7
|
-
import {
|
|
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/
|
|
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,
|
|
357
|
-
* When false (default),
|
|
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.
|
|
@@ -882,6 +913,8 @@ declare interface PlaybackAnimationContextValue {
|
|
|
882
913
|
currentTimeRef: default_2.RefObject<number>;
|
|
883
914
|
playbackStartTimeRef: default_2.RefObject<number>;
|
|
884
915
|
audioStartPositionRef: default_2.RefObject<number>;
|
|
916
|
+
/** Returns current playback time from engine (auto-wraps at loop boundaries). */
|
|
917
|
+
getPlaybackTime: () => number;
|
|
885
918
|
}
|
|
886
919
|
|
|
887
920
|
export declare const PlayButton: default_2.FC<{
|
|
@@ -900,9 +933,9 @@ declare interface PlayheadProps {
|
|
|
900
933
|
isPlaying: boolean;
|
|
901
934
|
/** Ref to current time in seconds - use for smooth animation during playback */
|
|
902
935
|
currentTimeRef: react__default.RefObject<number>;
|
|
903
|
-
/** Audio context start time when playback began
|
|
936
|
+
/** Audio context start time when playback began. Fallback when getPlaybackTime is not provided. */
|
|
904
937
|
playbackStartTimeRef: react__default.RefObject<number>;
|
|
905
|
-
/** Audio position when playback started
|
|
938
|
+
/** Audio position when playback started. Fallback when getPlaybackTime is not provided. */
|
|
906
939
|
audioStartPositionRef: react__default.RefObject<number>;
|
|
907
940
|
/** Samples per pixel - for converting time to pixels */
|
|
908
941
|
samplesPerPixel: number;
|
|
@@ -912,6 +945,8 @@ declare interface PlayheadProps {
|
|
|
912
945
|
controlsOffset: number;
|
|
913
946
|
/** Function to get current audio context time - required for smooth animation */
|
|
914
947
|
getAudioContextTime?: () => number;
|
|
948
|
+
/** Returns current playback time (auto-wraps at loop boundaries). Preferred over manual elapsed calculation. */
|
|
949
|
+
getPlaybackTime?: () => number;
|
|
915
950
|
}
|
|
916
951
|
|
|
917
952
|
/**
|
|
@@ -1332,7 +1367,7 @@ declare interface TrackState_2 {
|
|
|
1332
1367
|
/**
|
|
1333
1368
|
* Custom hook for handling annotation drag operations (boundary trimming)
|
|
1334
1369
|
*
|
|
1335
|
-
* Provides drag handlers for use with @dnd-kit/
|
|
1370
|
+
* Provides drag handlers for use with @dnd-kit/react DragDropProvider.
|
|
1336
1371
|
* Handles annotation boundary resizing with linked endpoints support.
|
|
1337
1372
|
*
|
|
1338
1373
|
* @example
|
|
@@ -1347,21 +1382,21 @@ declare interface TrackState_2 {
|
|
|
1347
1382
|
* });
|
|
1348
1383
|
*
|
|
1349
1384
|
* return (
|
|
1350
|
-
* <
|
|
1385
|
+
* <DragDropProvider
|
|
1351
1386
|
* onDragStart={onDragStart}
|
|
1352
1387
|
* onDragMove={onDragMove}
|
|
1353
1388
|
* onDragEnd={onDragEnd}
|
|
1354
|
-
* modifiers={[
|
|
1389
|
+
* modifiers={[RestrictToHorizontalAxis]}
|
|
1355
1390
|
* >
|
|
1356
1391
|
* {renderAnnotations()}
|
|
1357
|
-
* </
|
|
1392
|
+
* </DragDropProvider>
|
|
1358
1393
|
* );
|
|
1359
1394
|
* ```
|
|
1360
1395
|
*/
|
|
1361
1396
|
export declare function useAnnotationDragHandlers({ annotations, onAnnotationsChange, samplesPerPixel, sampleRate, duration, linkEndpoints, }: UseAnnotationDragHandlersOptions): {
|
|
1362
|
-
onDragStart: (event: DragStartEvent) => void;
|
|
1363
|
-
onDragMove: (event: DragMoveEvent) => void;
|
|
1364
|
-
onDragEnd: () => void;
|
|
1397
|
+
onDragStart: (event: Parameters<DragStartEvent>[0]) => void;
|
|
1398
|
+
onDragMove: (event: Parameters<DragMoveEvent>[0]) => void;
|
|
1399
|
+
onDragEnd: (event: Parameters<DragEndEvent>[0]) => void;
|
|
1365
1400
|
};
|
|
1366
1401
|
|
|
1367
1402
|
declare interface UseAnnotationDragHandlersOptions {
|
|
@@ -1511,9 +1546,11 @@ declare interface UseAudioTracksOptions {
|
|
|
1511
1546
|
/**
|
|
1512
1547
|
* Custom hook for handling clip drag operations (movement and trimming)
|
|
1513
1548
|
*
|
|
1514
|
-
* Provides drag handlers
|
|
1549
|
+
* Provides drag handlers for use with @dnd-kit/react DragDropProvider.
|
|
1515
1550
|
* Handles both clip movement (dragging entire clips) and boundary trimming (adjusting clip edges).
|
|
1516
1551
|
*
|
|
1552
|
+
* Collision detection for clip moves is handled by `ClipCollisionModifier` (passed to DragDropProvider).
|
|
1553
|
+
*
|
|
1517
1554
|
* **Move:** `onDragEnd` delegates to `engine.moveClip()` in one shot.
|
|
1518
1555
|
*
|
|
1519
1556
|
* **Trim:** `onDragMove` updates React state per-frame via `onTracksChange` for smooth
|
|
@@ -1523,7 +1560,7 @@ declare interface UseAudioTracksOptions {
|
|
|
1523
1560
|
*
|
|
1524
1561
|
* @example
|
|
1525
1562
|
* ```tsx
|
|
1526
|
-
* const { onDragStart, onDragMove, onDragEnd
|
|
1563
|
+
* const { onDragStart, onDragMove, onDragEnd } = useClipDragHandlers({
|
|
1527
1564
|
* tracks,
|
|
1528
1565
|
* onTracksChange: setTracks,
|
|
1529
1566
|
* samplesPerPixel,
|
|
@@ -1533,29 +1570,21 @@ declare interface UseAudioTracksOptions {
|
|
|
1533
1570
|
* });
|
|
1534
1571
|
*
|
|
1535
1572
|
* return (
|
|
1536
|
-
* <
|
|
1573
|
+
* <DragDropProvider
|
|
1537
1574
|
* onDragStart={onDragStart}
|
|
1538
1575
|
* onDragMove={onDragMove}
|
|
1539
1576
|
* onDragEnd={onDragEnd}
|
|
1540
|
-
*
|
|
1541
|
-
* modifiers={[restrictToHorizontalAxis, collisionModifier]}
|
|
1577
|
+
* modifiers={[RestrictToHorizontalAxis, ClipCollisionModifier.configure({ tracks, samplesPerPixel })]}
|
|
1542
1578
|
* >
|
|
1543
1579
|
* <Waveform showClipHeaders={true} />
|
|
1544
|
-
* </
|
|
1580
|
+
* </DragDropProvider>
|
|
1545
1581
|
* );
|
|
1546
1582
|
* ```
|
|
1547
1583
|
*/
|
|
1548
1584
|
export declare function useClipDragHandlers({ tracks, onTracksChange, samplesPerPixel, sampleRate, engineRef, isDraggingRef, }: UseClipDragHandlersOptions): {
|
|
1549
|
-
onDragStart: (event: DragStartEvent) => void;
|
|
1550
|
-
onDragMove: (event: DragMoveEvent) => void;
|
|
1551
|
-
onDragEnd: (event: DragEndEvent) => void;
|
|
1552
|
-
onDragCancel: (_event: DragCancelEvent) => void;
|
|
1553
|
-
collisionModifier: (args: Parameters<Modifier>[0]) => {
|
|
1554
|
-
scaleX: number;
|
|
1555
|
-
scaleY: number;
|
|
1556
|
-
x: number;
|
|
1557
|
-
y: number;
|
|
1558
|
-
};
|
|
1585
|
+
onDragStart: (event: Parameters<DragStartEvent>[0]) => void;
|
|
1586
|
+
onDragMove: (event: Parameters<DragMoveEvent>[0]) => void;
|
|
1587
|
+
onDragEnd: (event: Parameters<DragEndEvent>[0]) => void;
|
|
1559
1588
|
};
|
|
1560
1589
|
|
|
1561
1590
|
declare interface UseClipDragHandlersOptions {
|
|
@@ -1615,25 +1644,17 @@ declare interface UseClipSplittingResult {
|
|
|
1615
1644
|
* Returns configured sensors for @dnd-kit drag operations
|
|
1616
1645
|
*
|
|
1617
1646
|
* @param options - Configuration options for drag sensors
|
|
1618
|
-
* @returns
|
|
1647
|
+
* @returns Array of sensor constructors/descriptors for DragDropProvider's sensors prop
|
|
1619
1648
|
*
|
|
1620
1649
|
* @example
|
|
1621
|
-
* // Desktop-optimized (default)
|
|
1650
|
+
* // Desktop-optimized (default — 1px distance activation for all pointer types)
|
|
1622
1651
|
* const sensors = useDragSensors();
|
|
1623
1652
|
*
|
|
1624
1653
|
* @example
|
|
1625
|
-
* // Mobile-optimized with touch delay
|
|
1626
|
-
* const sensors = useDragSensors({ touchOptimized: true });
|
|
1627
|
-
*
|
|
1628
|
-
* @example
|
|
1629
|
-
* // Custom touch settings
|
|
1630
|
-
* const sensors = useDragSensors({
|
|
1631
|
-
* touchOptimized: true,
|
|
1632
|
-
* touchDelay: 300,
|
|
1633
|
-
* touchTolerance: 8
|
|
1634
|
-
* });
|
|
1654
|
+
* // Mobile-optimized with custom touch delay
|
|
1655
|
+
* const sensors = useDragSensors({ touchOptimized: true, touchDelay: 300 });
|
|
1635
1656
|
*/
|
|
1636
|
-
export declare function useDragSensors(options?: DragSensorOptions):
|
|
1657
|
+
export declare function useDragSensors(options?: DragSensorOptions): (typeof PointerSensor | PluginDescriptor<any, any, any>)[];
|
|
1637
1658
|
|
|
1638
1659
|
/**
|
|
1639
1660
|
* Hook for managing a dynamic chain of audio effects with real-time parameter updates
|