@waveform-playlist/browser 17.0.0-next.6 → 17.0.0-next.8

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.mjs CHANGED
@@ -51,11 +51,11 @@ var __async = (__this, __arguments, generator) => {
51
51
  };
52
52
 
53
53
  // <define:__INSTALL_SPECS__>
54
- var define_INSTALL_SPECS_default = { "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@dnd-kit/abstract": "@dnd-kit/abstract@^0.5.0", "@dnd-kit/dom": "@dnd-kit/dom@^0.5.0", "@dnd-kit/react": "@dnd-kit/react@^0.5.0", "@waveform-playlist/annotations": "@waveform-playlist/annotations@^14.0.0-next.4", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.2", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.2", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.4", react: "react@^19.0.0", "react-dom": "react-dom@^19.0.0", "styled-components": "styled-components@^6.0.0", tone: "tone@^15.0.0", "@waveform-playlist/spectrogram": "@waveform-playlist/spectrogram@^15.0.0-next.2" };
54
+ var define_INSTALL_SPECS_default = { "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@dnd-kit/abstract": "@dnd-kit/abstract@^0.5.0", "@dnd-kit/dom": "@dnd-kit/dom@^0.5.0", "@dnd-kit/react": "@dnd-kit/react@^0.5.0", "@waveform-playlist/annotations": "@waveform-playlist/annotations@^14.0.0-next.5", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.3", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.3", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.5", react: "react@^19.0.0", "react-dom": "react-dom@^19.0.0", "styled-components": "styled-components@^6.0.0", tone: "tone@^15.0.0", "@waveform-playlist/spectrogram": "@waveform-playlist/spectrogram@^15.0.0-next.3" };
55
55
 
56
56
  // src/WaveformPlaylistContext.tsx
57
57
  import {
58
- useState as useState16,
58
+ useState as useState15,
59
59
  useEffect as useEffect8,
60
60
  useLayoutEffect as useLayoutEffect5,
61
61
  useRef as useRef21,
@@ -418,7 +418,7 @@ var PlaylistMixerContext = slot();
418
418
  var TrackReorderPreviewContext = slot();
419
419
  var TrimPreviewContext = slot();
420
420
  var TrimPreviewPeaksContext = slot();
421
- var RecordingArmContext = slot();
421
+ var RecordingTrackContext = slot();
422
422
  var PlaybackRateContext = slot();
423
423
  var MediaElementTrackContext = slot();
424
424
  function useSlot(context, hookName, needs) {
@@ -456,7 +456,7 @@ var useUndoRedo = () => useSlot(UndoRedoContext, "useUndoRedo", WEB_AUDIO);
456
456
  var usePlaylistTimeline = () => useSlot(PlaylistTimelineContext, "usePlaylistTimeline", WEB_AUDIO);
457
457
  var usePlaylistMixer = () => useSlot(PlaylistMixerContext, "usePlaylistMixer", WEB_AUDIO);
458
458
  var useTrackReorderPreview = () => useSlot(TrackReorderPreviewContext, "useTrackReorderPreview", WEB_AUDIO);
459
- var useRecordingArm = () => useSlot(RecordingArmContext, "useRecordingArm", WEB_AUDIO);
459
+ var useRecordingTrack = () => useSlot(RecordingTrackContext, "useRecordingTrack", WEB_AUDIO);
460
460
  var usePlaybackRate = () => useSlot(PlaybackRateContext, "usePlaybackRate", MEDIA_ELEMENT);
461
461
  var useMediaElementTrack = () => useSlot(MediaElementTrackContext, "useMediaElementTrack", MEDIA_ELEMENT);
462
462
  var useWebAudioProviderOnly = (hookName) => {
@@ -2710,19 +2710,20 @@ function deriveRows(tracks, inputs, previous) {
2710
2710
  });
2711
2711
  return { byTrackId, result: sameItems(previous.result, rows) ? previous.result : rows };
2712
2712
  }
2713
- function sameState(a, name, mix) {
2714
- return a.name === name && a.volume === mix.volume && a.muted === mix.muted && a.soloed === mix.soloed && a.pan === mix.pan;
2713
+ function sameState(a, name, mix, muted) {
2714
+ return a.name === name && a.volume === mix.volume && a.muted === muted && a.soloed === mix.soloed && a.pan === mix.pan;
2715
2715
  }
2716
- function deriveTrackStates(tracks, mixer, previous) {
2716
+ function deriveTrackStates(tracks, mixer, recordingTrackIds, previous) {
2717
2717
  const byTrackId = /* @__PURE__ */ new Map();
2718
2718
  const states = tracks.map((track) => {
2719
2719
  var _a;
2720
2720
  const mix = (_a = mixer.get(track.id)) != null ? _a : DEFAULT_MIX;
2721
+ const muted = mix.muted || recordingTrackIds.has(track.id);
2721
2722
  const before = previous.byTrackId.get(track.id);
2722
- const state = before && sameState(before, track.name, mix) ? before : {
2723
+ const state = before && sameState(before, track.name, mix, muted) ? before : {
2723
2724
  name: track.name,
2724
2725
  volume: mix.volume,
2725
- muted: mix.muted,
2726
+ muted,
2726
2727
  soloed: mix.soloed,
2727
2728
  pan: mix.pan
2728
2729
  };
@@ -2742,12 +2743,14 @@ function useArrangementValue(arrangement, read) {
2742
2743
  return useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getSnapshot);
2743
2744
  }
2744
2745
  var readMixer = (arrangement) => arrangement.getMixer();
2746
+ var readRecordingTrackIds = (arrangement) => arrangement.recordingTrackIds;
2745
2747
  var readCanUndo = (arrangement) => arrangement.canUndo;
2746
2748
  var readCanRedo = (arrangement) => arrangement.canRedo;
2747
2749
  function useArrangementView(arrangement, options) {
2748
2750
  const { samplesPerPixel, mono, baseScale, placeholderSampleRate } = options;
2749
2751
  const arrangementTracks = useArrangementTracks(arrangement);
2750
2752
  const mixer = useArrangementValue(arrangement, readMixer);
2753
+ const recordingTrackIds = useArrangementValue(arrangement, readRecordingTrackIds);
2751
2754
  const canUndo = useArrangementValue(arrangement, readCanUndo);
2752
2755
  const canRedo = useArrangementValue(arrangement, readCanRedo);
2753
2756
  const loadedCacheRef = useRef17(EMPTY_LOADED_TRACKS);
@@ -2777,10 +2780,15 @@ function useArrangementView(arrangement, options) {
2777
2780
  const duration = useMemo9(() => timelineDuration(tracks), [tracks]);
2778
2781
  const statesCacheRef = useRef17(EMPTY_STATES);
2779
2782
  const trackStates = useMemo9(() => {
2780
- const next = deriveTrackStates(arrangementTracks, mixer, statesCacheRef.current);
2783
+ const next = deriveTrackStates(
2784
+ arrangementTracks,
2785
+ mixer,
2786
+ recordingTrackIds,
2787
+ statesCacheRef.current
2788
+ );
2781
2789
  statesCacheRef.current = next;
2782
2790
  return next.result;
2783
- }, [arrangementTracks, mixer]);
2791
+ }, [arrangementTracks, mixer, recordingTrackIds]);
2784
2792
  return {
2785
2793
  tracks,
2786
2794
  peaksDataArray,
@@ -2852,8 +2860,7 @@ function useReadyOnce(options) {
2852
2860
  }
2853
2861
 
2854
2862
  // src/providerInternals/useArrangementEditing.ts
2855
- import { useCallback as useCallback18, useEffect as useEffect6, useMemo as useMemo10, useRef as useRef19, useState as useState15, useSyncExternalStore as useSyncExternalStore8 } from "react";
2856
- import { createValueSource as createValueSource3 } from "@waveform-playlist/core";
2863
+ import { useCallback as useCallback18, useEffect as useEffect6, useMemo as useMemo10, useRef as useRef19, useSyncExternalStore as useSyncExternalStore8 } from "react";
2857
2864
 
2858
2865
  // src/components/partWarnings.ts
2859
2866
  var warned = /* @__PURE__ */ new Set();
@@ -2873,63 +2880,71 @@ function isTrackId(setter, trackId) {
2873
2880
  );
2874
2881
  return false;
2875
2882
  }
2883
+ var readRecordingTrackId = (arrangement) => {
2884
+ for (const id of arrangement.recordingTrackIds) return id;
2885
+ return null;
2886
+ };
2887
+ function clearRecordingTracks(arrangement, keep = null) {
2888
+ for (const id of [...arrangement.recordingTrackIds]) {
2889
+ if (id !== keep) arrangement.setTrackRecording(id, false);
2890
+ }
2891
+ }
2876
2892
  function useRecordingActive(arrangement) {
2877
2893
  const recordingActiveRef = useRef19(false);
2878
- const [armed] = useState15(() => createValueSource3(null));
2879
2894
  const setRecordingActive = useCallback18(
2880
- (active, armedTrackId2) => {
2881
- var _a, _b;
2895
+ (active, recordingTrackId2) => {
2882
2896
  recordingActiveRef.current = active;
2883
- const current = armed.source.getSnapshot();
2884
- if (active && armedTrackId2) {
2885
- if ((current == null ? void 0 : current.trackId) === armedTrackId2) return;
2886
- if (current) arrangement.setTrackMute(current.trackId, current.prevMuted);
2887
- const prevMuted = (_b = (_a = arrangement.getMixer().get(armedTrackId2)) == null ? void 0 : _a.muted) != null ? _b : false;
2888
- armed.publish({ trackId: armedTrackId2, prevMuted });
2889
- arrangement.setTrackMute(armedTrackId2, true);
2890
- } else if (!active && current) {
2891
- arrangement.setTrackMute(current.trackId, current.prevMuted);
2892
- armed.publish(null);
2897
+ if (active && recordingTrackId2) {
2898
+ clearRecordingTracks(arrangement, recordingTrackId2);
2899
+ arrangement.setTrackRecording(recordingTrackId2, true);
2900
+ } else if (!active) {
2901
+ clearRecordingTracks(arrangement);
2893
2902
  }
2894
2903
  },
2895
- [arrangement, armed]
2904
+ [arrangement]
2896
2905
  );
2897
2906
  useEffect6(
2898
2907
  () => () => {
2899
- if (armed.source.getSnapshot()) setRecordingActive(false);
2908
+ if (arrangement.recordingTrackIds.size > 0) setRecordingActive(false);
2900
2909
  },
2901
- [armed, setRecordingActive]
2910
+ [arrangement, setRecordingActive]
2902
2911
  );
2903
- const getArmedTrackId = useCallback18(() => {
2904
- var _a, _b;
2905
- return (_b = (_a = armed.source.getSnapshot()) == null ? void 0 : _a.trackId) != null ? _b : null;
2906
- }, [armed]);
2907
- const armedTrackId = useSyncExternalStore8(armed.source.subscribe, getArmedTrackId);
2908
- const recordingArm = useMemo10(() => ({ armedTrackId }), [armedTrackId]);
2909
- return { setRecordingActive, recordingActiveRef, recordingArm };
2912
+ const subscribe = useCallback18(
2913
+ (listener) => arrangement.subscribe(listener),
2914
+ [arrangement]
2915
+ );
2916
+ const getRecordingTrackId = useCallback18(() => readRecordingTrackId(arrangement), [arrangement]);
2917
+ const recordingTrackId = useSyncExternalStore8(
2918
+ subscribe,
2919
+ getRecordingTrackId,
2920
+ getRecordingTrackId
2921
+ );
2922
+ const recordingTrack = useMemo10(() => ({ recordingTrackId }), [recordingTrackId]);
2923
+ return { setRecordingActive, recordingActiveRef, recordingTrack };
2910
2924
  }
2911
2925
  function useArrangementEditing(arrangement) {
2912
2926
  const setTrackMute = useCallback18(
2913
- (trackId, muted) => {
2914
- if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted);
2927
+ (trackId, muted, options) => {
2928
+ if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted, options);
2915
2929
  },
2916
2930
  [arrangement]
2917
2931
  );
2918
2932
  const setTrackSolo = useCallback18(
2919
- (trackId, soloed) => {
2920
- if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed);
2933
+ (trackId, soloed, options) => {
2934
+ if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed, options);
2921
2935
  },
2922
2936
  [arrangement]
2923
2937
  );
2924
2938
  const setTrackVolume = useCallback18(
2925
- (trackId, volume) => {
2926
- if (isTrackId("setTrackVolume", trackId)) arrangement.setTrackVolume(trackId, volume);
2939
+ (trackId, volume, options) => {
2940
+ if (isTrackId("setTrackVolume", trackId))
2941
+ arrangement.setTrackVolume(trackId, volume, options);
2927
2942
  },
2928
2943
  [arrangement]
2929
2944
  );
2930
2945
  const setTrackPan = useCallback18(
2931
- (trackId, pan) => {
2932
- if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan);
2946
+ (trackId, pan, options) => {
2947
+ if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan, options);
2933
2948
  },
2934
2949
  [arrangement]
2935
2950
  );
@@ -2939,7 +2954,7 @@ function useArrangementEditing(arrangement) {
2939
2954
  );
2940
2955
  const undo = useCallback18(() => arrangement.undo(), [arrangement]);
2941
2956
  const redo = useCallback18(() => arrangement.redo(), [arrangement]);
2942
- const { setRecordingActive, recordingActiveRef, recordingArm } = useRecordingActive(arrangement);
2957
+ const { setRecordingActive, recordingActiveRef, recordingTrack } = useRecordingActive(arrangement);
2943
2958
  return {
2944
2959
  setTrackMute,
2945
2960
  setTrackSolo,
@@ -2950,7 +2965,7 @@ function useArrangementEditing(arrangement) {
2950
2965
  redo,
2951
2966
  setRecordingActive,
2952
2967
  recordingActiveRef,
2953
- recordingArm
2968
+ recordingTrack
2954
2969
  };
2955
2970
  }
2956
2971
 
@@ -3044,10 +3059,9 @@ var ProviderOnArrangement = ({
3044
3059
  setAutomaticScroll
3045
3060
  } = useScrollFollow(automaticScroll);
3046
3061
  const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
3047
- const [isPlaying, setIsPlaying] = useState16(false);
3048
- const [currentTime, setCurrentTime] = useState16(0);
3049
- const [trackReorderEpoch, setTrackReorderEpoch] = useState16(0);
3050
- const [trackDragPreview, setTrackDragPreview] = useState16(null);
3062
+ const [isPlaying, setIsPlaying] = useState15(false);
3063
+ const [currentTime, setCurrentTime] = useState15(0);
3064
+ const [trackDragPreview, setTrackDragPreview] = useState15(null);
3051
3065
  const indefinitePlaybackRef = useRef21(indefinitePlayback);
3052
3066
  indefinitePlaybackRef.current = indefinitePlayback;
3053
3067
  const isPlayingRef = useRef21(false);
@@ -3584,9 +3598,6 @@ var ProviderOnArrangement = ({
3584
3598
  },
3585
3599
  [play, setCurrentTimeRefs, recordingActiveRef]
3586
3600
  );
3587
- const bumpTrackReorderEpoch = useCallback19(() => {
3588
- setTrackReorderEpoch((epoch) => epoch + 1);
3589
- }, []);
3590
3601
  const setSelection = useCallback19(
3591
3602
  (start, end) => {
3592
3603
  var _a;
@@ -3754,7 +3765,6 @@ var ProviderOnArrangement = ({
3754
3765
  setTrackVolume: editing.setTrackVolume,
3755
3766
  setTrackPan: editing.setTrackPan,
3756
3767
  reorderTrack: editing.reorderTrack,
3757
- bumpTrackReorderEpoch,
3758
3768
  setTrackDragPreview,
3759
3769
  setSelectedTrackId: setSelectedTrackIdControl,
3760
3770
  // Zoom
@@ -3780,7 +3790,6 @@ var ProviderOnArrangement = ({
3780
3790
  editing.setTrackVolume,
3781
3791
  editing.setTrackPan,
3782
3792
  editing.reorderTrack,
3783
- bumpTrackReorderEpoch,
3784
3793
  setTrackDragPreview,
3785
3794
  setSelectedTrackIdControl,
3786
3795
  zoom.zoomIn,
@@ -3821,8 +3830,8 @@ var ProviderOnArrangement = ({
3821
3830
  [trackStates, masterVolume]
3822
3831
  );
3823
3832
  const reorderPreviewValue = useMemo11(
3824
- () => ({ trackDragPreview, trackReorderEpoch }),
3825
- [trackDragPreview, trackReorderEpoch]
3833
+ () => ({ trackDragPreview }),
3834
+ [trackDragPreview]
3826
3835
  );
3827
3836
  return /* @__PURE__ */ jsx(ThemeProvider, { theme: mergedTheme, children: /* @__PURE__ */ jsx(PlaybackRateContext, { value: BLOCKED, children: /* @__PURE__ */ jsx(MediaElementTrackContext, { value: BLOCKED, children: /* @__PURE__ */ jsx(ArrangementContext, { value: arrangement, children: /* @__PURE__ */ jsx(PlaybackRefsContext, { value: refsValue, children: /* @__PURE__ */ jsx(EngineRefsContext, { value: engineRefsValue, children: /* @__PURE__ */ jsx(TrimPreviewContext, { value: trimPreview, children: /* @__PURE__ */ jsx(TrimPreviewPeaksContext, { value: trimPreviewPeaks, children: /* @__PURE__ */ jsx(PlaybackControlsContext, { value: controlsValue, children: /* @__PURE__ */ jsx(EditorControlsContext, { value: editorControlsValue, children: /* @__PURE__ */ jsx(PlaylistViewContext, { value: viewValue, children: /* @__PURE__ */ jsx(PlaylistSettingsContext, { value: settingsValue, children: /* @__PURE__ */ jsx(PlaylistZoomContext, { value: zoomValue, children: /* @__PURE__ */ jsx(UndoRedoContext, { value: undoRedoValue, children: /* @__PURE__ */ jsx(SelectedTrackIdContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ jsx(SelectedRowContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ jsx(LoopContext, { value: loopValue, children: /* @__PURE__ */ jsx(AnnotationOptionsContext, { value: annotationOptionsValue, children: /* @__PURE__ */ jsx(AnnotationsContext, { value: annotationsValue, children: /* @__PURE__ */ jsx(IsPlayingContext, { value: isPlayingValue, children: /* @__PURE__ */ jsx(ActiveAnnotationContext, { value: activeAnnotationValue, children: /* @__PURE__ */ jsx(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ jsx(SelectionContext, { value: selectionValue, children: /* @__PURE__ */ jsx(
3828
3837
  TrackReorderPreviewContext,
@@ -3833,9 +3842,9 @@ var ProviderOnArrangement = ({
3833
3842
  {
3834
3843
  value: timelineValue,
3835
3844
  children: /* @__PURE__ */ jsx(
3836
- RecordingArmContext,
3845
+ RecordingTrackContext,
3837
3846
  {
3838
- value: editing.recordingArm,
3847
+ value: editing.recordingTrack,
3839
3848
  children
3840
3849
  }
3841
3850
  )
@@ -3847,7 +3856,7 @@ var ProviderOnArrangement = ({
3847
3856
 
3848
3857
  // src/MediaElementPlaylistContext.tsx
3849
3858
  import {
3850
- useState as useState17,
3859
+ useState as useState16,
3851
3860
  useEffect as useEffect9,
3852
3861
  useLayoutEffect as useLayoutEffect6,
3853
3862
  useRef as useRef22,
@@ -3898,16 +3907,16 @@ var MediaElementPlaylistProvider = ({
3898
3907
  children
3899
3908
  }) => {
3900
3909
  const mergedTheme = useMergedTheme(userThemeProp);
3901
- const [isPlaying, setIsPlayingState] = useState17(false);
3910
+ const [isPlaying, setIsPlayingState] = useState16(false);
3902
3911
  const isPlayingRef = useRef22(false);
3903
3912
  const setIsPlaying = useCallback20((playing) => {
3904
3913
  isPlayingRef.current = playing;
3905
3914
  setIsPlayingState(playing);
3906
3915
  }, []);
3907
- const [currentTime, setCurrentTime] = useState17(0);
3908
- const [isReady, setIsReady] = useState17(false);
3909
- const [playbackRate, setPlaybackRateState] = useState17(initialPlaybackRate);
3910
- const [ratePropSeen, setRatePropSeen] = useState17(initialPlaybackRate);
3916
+ const [currentTime, setCurrentTime] = useState16(0);
3917
+ const [isReady, setIsReady] = useState16(false);
3918
+ const [playbackRate, setPlaybackRateState] = useState16(initialPlaybackRate);
3919
+ const [ratePropSeen, setRatePropSeen] = useState16(initialPlaybackRate);
3911
3920
  if (!Object.is(ratePropSeen, initialPlaybackRate)) {
3912
3921
  setRatePropSeen(initialPlaybackRate);
3913
3922
  setPlaybackRateState(initialPlaybackRate);
@@ -3944,12 +3953,12 @@ var MediaElementPlaylistProvider = ({
3944
3953
  setAutomaticScroll
3945
3954
  } = useScrollFollow(automaticScroll);
3946
3955
  const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
3947
- const [selection, setSelectionState] = useState17({
3956
+ const [selection, setSelectionState] = useState16({
3948
3957
  selectionStart: 0,
3949
3958
  selectionEnd: 0
3950
3959
  });
3951
3960
  const selectionRef = useRef22(selection);
3952
- const [samplesPerPixel] = useState17(initialSamplesPerPixel);
3961
+ const [samplesPerPixel] = useState16(initialSamplesPerPixel);
3953
3962
  const { timeFormat, setTimeFormat } = useTimeFormat();
3954
3963
  const playoutRef = useRef22(null);
3955
3964
  const currentTimeRef = useRef22(0);
@@ -4426,7 +4435,7 @@ var MediaElementPlaylistProvider = ({
4426
4435
  ActiveAnnotationContext,
4427
4436
  {
4428
4437
  value: activeAnnotationValue,
4429
- children: /* @__PURE__ */ jsx2(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ jsx2(SelectionContext, { value: selection, children: /* @__PURE__ */ jsx2(SelectedRowContext, { value: ONLY_ROW_SELECTED, children: /* @__PURE__ */ jsx2(RecordingArmContext, { value: BLOCKED, children }) }) }) })
4438
+ children: /* @__PURE__ */ jsx2(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ jsx2(SelectionContext, { value: selection, children: /* @__PURE__ */ jsx2(SelectedRowContext, { value: ONLY_ROW_SELECTED, children: /* @__PURE__ */ jsx2(RecordingTrackContext, { value: BLOCKED, children }) }) }) })
4430
4439
  }
4431
4440
  ) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
4432
4441
  };
@@ -4676,7 +4685,7 @@ var AutomaticScrollCheckbox = ({ className }) => {
4676
4685
  import {
4677
4686
  use as use13,
4678
4687
  useLayoutEffect as useLayoutEffect9,
4679
- useRef as useRef30,
4688
+ useRef as useRef31,
4680
4689
  useState as useState21,
4681
4690
  useMemo as useMemo20,
4682
4691
  useCallback as useCallback26
@@ -4718,9 +4727,9 @@ function trackIdAtOffset(orderedIds, layout, heightById, y) {
4718
4727
  }
4719
4728
 
4720
4729
  // src/hooks/useTrailingActive.ts
4721
- import { useEffect as useEffect11, useState as useState18 } from "react";
4730
+ import { useEffect as useEffect11, useState as useState17 } from "react";
4722
4731
  function useTrailingActive(active, trailingMs) {
4723
- const [trailing, setTrailing] = useState18(active);
4732
+ const [trailing, setTrailing] = useState17(active);
4724
4733
  useEffect11(() => {
4725
4734
  if (active) {
4726
4735
  setTrailing(true);
@@ -4849,6 +4858,7 @@ var TrackRowPositioner = styled2.div.attrs((props) => ({
4849
4858
  transition: none;
4850
4859
  }
4851
4860
  `;
4861
+ var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
4852
4862
  var ControlSlot = styled2.div.attrs((props) => ({
4853
4863
  style: {
4854
4864
  height: `${props.$height}px`,
@@ -4867,6 +4877,7 @@ var ControlSlot = styled2.div.attrs((props) => ({
4867
4877
  transition: background 0.15s ease-in-out;
4868
4878
  }
4869
4879
  ${(props) => props.$isSelected && `background: ${props.theme.selectedTrackControlsBackground};`}
4880
+ ${(props) => props.$isDragSource && `background: ${props.theme.selectedTrackControlsBackground}; box-shadow: ${DRAG_SOURCE_SHADOW};`}
4870
4881
  `;
4871
4882
  function getTrackChannelCount(trackClipPeaks, recordingChannels) {
4872
4883
  const clipChannels = trackClipPeaks.length > 0 ? Math.max(1, ...trackClipPeaks.map((clip) => clip.peaks.data.length)) : 1;
@@ -4883,13 +4894,13 @@ import React17, {
4883
4894
  import {
4884
4895
  Playlist,
4885
4896
  PlaylistInfoContext,
4886
- useTheme as useTheme5,
4897
+ useTheme as useTheme4,
4887
4898
  waveformColorToCss as waveformColorToCss3
4888
4899
  } from "@waveform-playlist/ui-components";
4889
4900
 
4890
4901
  // src/hooks/useSelectionDrag.ts
4891
- import { createContext as createContext3, memo as memo2, useLayoutEffect as useLayoutEffect8, useMemo as useMemo14, useRef as useRef25, useState as useState19 } from "react";
4892
- import { createValueSource as createValueSource4 } from "@waveform-playlist/core";
4902
+ import { createContext as createContext3, memo as memo2, useLayoutEffect as useLayoutEffect8, useMemo as useMemo14, useRef as useRef25, useState as useState18 } from "react";
4903
+ import { createValueSource as createValueSource3 } from "@waveform-playlist/core";
4893
4904
 
4894
4905
  // src/hooks/useWindowDrag.ts
4895
4906
  import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect7, useRef as useRef24 } from "react";
@@ -4972,9 +4983,9 @@ function useSelectionDrag({
4972
4983
  }) {
4973
4984
  const { isPlaying } = useIsPlaying();
4974
4985
  const { setSelection } = usePlaybackControls();
4975
- const [isSelecting, setIsSelecting] = useState19(false);
4986
+ const [isSelecting, setIsSelecting] = useState18(false);
4976
4987
  const automaticScrollRef = useRef25(false);
4977
- const previewHandle = useMemo14(() => createValueSource4(null), []);
4988
+ const previewHandle = useMemo14(() => createValueSource3(null), []);
4978
4989
  const pressTimeRef = useRef25(0);
4979
4990
  const wroteSelectionRef = useRef25(false);
4980
4991
  const dragElementRef = useRef25(null);
@@ -5632,8 +5643,8 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
5632
5643
  var _a, _b;
5633
5644
  const track = rowList[trackIndex];
5634
5645
  if (!track) return null;
5635
- const isArmed = (recordingState == null ? void 0 : recordingState.isRecording) === true && recordingState.trackId === track.id;
5636
- const recordingChannels = isArmed ? recordingChannelCount : 0;
5646
+ const isRecordingTrack = (recordingState == null ? void 0 : recordingState.isRecording) === true && recordingState.trackId === track.id;
5647
+ const recordingChannels = isRecordingTrack ? recordingChannelCount : 0;
5637
5648
  const helpers = spectrogramHelpersById.get(track.id);
5638
5649
  return /* @__PURE__ */ jsx8(
5639
5650
  TrackRow,
@@ -5651,7 +5662,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
5651
5662
  numChannels: getTrackChannelCount(trackClipPeaks, recordingChannels),
5652
5663
  waveHeight,
5653
5664
  mono,
5654
- recordingState: isArmed ? recordingState : void 0,
5665
+ recordingState: isRecordingTrack ? recordingState : void 0,
5655
5666
  spectrogramConfig: helpers == null ? void 0 : helpers.config,
5656
5667
  frequencyScaleFn: helpers == null ? void 0 : helpers.frequencyScaleFn,
5657
5668
  samplesPerPixel,
@@ -5664,8 +5675,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
5664
5675
  };
5665
5676
 
5666
5677
  // src/components/TrackControlsColumn.tsx
5667
- import React12, { use as use9, useMemo as useMemo17, useRef as useRef28, useState as useState20 } from "react";
5668
- import { useTheme as useTheme3 } from "@waveform-playlist/ui-components";
5678
+ import React12, { use as use9, useMemo as useMemo17, useRef as useRef29, useState as useState20 } from "react";
5669
5679
 
5670
5680
  // src/components/DefaultTrackControls.tsx
5671
5681
  import React11 from "react";
@@ -5673,7 +5683,8 @@ import styled4 from "styled-components";
5673
5683
  import { ButtonGroup, Controls, Header } from "@waveform-playlist/ui-components";
5674
5684
 
5675
5685
  // src/components/TrackControlPieces.tsx
5676
- import { use as use8 } from "react";
5686
+ import { use as use8, useEffect as useEffect15, useRef as useRef27, useState as useState19 } from "react";
5687
+ import { createMixerGesture } from "@waveform-playlist/core";
5677
5688
  import {
5678
5689
  Button,
5679
5690
  CloseButton,
@@ -5734,7 +5745,7 @@ function createDragPopoverHealer(element) {
5734
5745
  }
5735
5746
 
5736
5747
  // src/hooks/useTrackReorderHandle.ts
5737
- var MOVE_FEEDBACK = Feedback.configure({ feedback: "move" });
5748
+ var MOVE_FEEDBACK = Feedback.configure({ feedback: "move", dropAnimation: null });
5738
5749
  var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
5739
5750
  function useTrackReorderHandle() {
5740
5751
  const { id, index } = useTrack();
@@ -5761,10 +5772,9 @@ function useTrackReorderHandle() {
5761
5772
  // `placeholder.replaceWith(element)` on drop) — confirmed via
5762
5773
  // MutationObserver instrumentation to relocate the React-owned row 6
5763
5774
  // times during a single one-slot drag, leaving its final parent/sibling
5764
- // different from what React's fiber tree still believes. That desync is
5765
- // permanent for the session: every later React-driven reorder (button OR
5766
- // drag) computes the correct data but silently fails to update the DOM
5767
- // for these rows. The placeholder splice is created only when
5775
+ // different from what React's fiber tree still believes. (Measured when
5776
+ // the registered element was one level inside the keyed slot, before
5777
+ // #796; not re-run with the slot itself.) The placeholder splice is created only when
5768
5778
  // `feedback !== 'move'` (@dnd-kit/dom Feedback.ts) — 'move' keeps the
5769
5779
  // dragged element in the live DOM (no clone/placeholder) while still
5770
5780
  // running the *unconditional* `dragOperation.shape = ...` assignment.
@@ -5776,7 +5786,10 @@ function useTrackReorderHandle() {
5776
5786
  // drag-based reordering silently never commits. Boundary trims don't hit
5777
5787
  // this because they're plain useDraggable (no collision-based commit) —
5778
5788
  // sortables need shape. `isDragSource` is a reactive signal, unaffected
5779
- // either way. See browser/CLAUDE.md "Track Reordering".
5789
+ // either way. OptimisticSortingPlugin still moves the element during the
5790
+ // drag (`insertAdjacentElement` next to the item it is dragged over);
5791
+ // that is safe only because the element is the keyed slot (#796, below).
5792
+ // See browser/notes/track-controls-and-reorder.md "Track Reordering".
5780
5793
  plugins: withMoveFeedback
5781
5794
  });
5782
5795
  useEffect14(() => {
@@ -5825,13 +5838,13 @@ var TrackName = () => {
5825
5838
  return /* @__PURE__ */ jsx9("span", { "data-track-name": "", style: NAME_STYLE, children: name });
5826
5839
  };
5827
5840
  var TrackMuteButton = () => {
5828
- const { muted, setMuted, isRecordingArmed } = useTrack();
5841
+ const { muted, setMuted, isRecording } = useTrack();
5829
5842
  return /* @__PURE__ */ jsx9(
5830
5843
  Button,
5831
5844
  {
5832
5845
  $variant: muted ? "danger" : "outline",
5833
5846
  "aria-pressed": muted,
5834
- disabled: isRecordingArmed,
5847
+ disabled: isRecording,
5835
5848
  onClick: () => setMuted(!muted),
5836
5849
  children: "Mute"
5837
5850
  }
@@ -5849,8 +5862,18 @@ var TrackSoloButton = () => {
5849
5862
  }
5850
5863
  );
5851
5864
  };
5865
+ function useSliderGesture() {
5866
+ const [gesture] = useState19(createMixerGesture);
5867
+ const ref = useRef27(null);
5868
+ useEffect15(() => {
5869
+ const input = ref.current;
5870
+ return input ? gesture.attach(input) : void 0;
5871
+ }, [gesture]);
5872
+ return { gesture, ref };
5873
+ }
5852
5874
  var TrackVolumeSlider = () => {
5853
5875
  const { volume, setVolume } = useTrack();
5876
+ const { gesture, ref } = useSliderGesture();
5854
5877
  return /* @__PURE__ */ jsxs3(SliderWrapper, { children: [
5855
5878
  /* @__PURE__ */ jsx9(VolumeDownIcon, {}),
5856
5879
  /* @__PURE__ */ jsx9(
@@ -5859,9 +5882,10 @@ var TrackVolumeSlider = () => {
5859
5882
  min: "0",
5860
5883
  max: "1",
5861
5884
  step: "0.01",
5885
+ ref,
5862
5886
  value: volume,
5863
5887
  "aria-label": "Volume",
5864
- onChange: (e) => setVolume(parseFloat(e.target.value))
5888
+ onChange: (e) => setVolume(parseFloat(e.target.value), { gesture: gesture.id })
5865
5889
  }
5866
5890
  ),
5867
5891
  /* @__PURE__ */ jsx9(VolumeUpIcon, {})
@@ -5869,6 +5893,7 @@ var TrackVolumeSlider = () => {
5869
5893
  };
5870
5894
  var TrackPanSlider = () => {
5871
5895
  const { pan, setPan } = useTrack();
5896
+ const { gesture, ref } = useSliderGesture();
5872
5897
  return /* @__PURE__ */ jsxs3(SliderWrapper, { children: [
5873
5898
  /* @__PURE__ */ jsx9("span", { children: "L" }),
5874
5899
  /* @__PURE__ */ jsx9(
@@ -5877,9 +5902,10 @@ var TrackPanSlider = () => {
5877
5902
  min: "-1",
5878
5903
  max: "1",
5879
5904
  step: "0.01",
5905
+ ref,
5880
5906
  value: pan,
5881
5907
  "aria-label": "Pan",
5882
- onChange: (e) => setPan(parseFloat(e.target.value))
5908
+ onChange: (e) => setPan(parseFloat(e.target.value), { gesture: gesture.id })
5883
5909
  }
5884
5910
  ),
5885
5911
  /* @__PURE__ */ jsx9("span", { children: "R" })
@@ -5970,7 +5996,7 @@ function DefaultTrackControlsImpl({ children }) {
5970
5996
  var DefaultTrackControls = React11.memo(DefaultTrackControlsImpl);
5971
5997
 
5972
5998
  // src/utils/stableTemplate.ts
5973
- import { isValidElement, useRef as useRef27 } from "react";
5999
+ import { isValidElement, useRef as useRef28 } from "react";
5974
6000
  function sameStyle(a, b) {
5975
6001
  if (Object.is(a, b)) return true;
5976
6002
  if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
@@ -6000,7 +6026,7 @@ function sameTemplate(a, b) {
6000
6026
  return false;
6001
6027
  }
6002
6028
  function useStableTemplate(template) {
6003
- const kept = useRef27(template);
6029
+ const kept = useRef28(template);
6004
6030
  if (!sameTemplate(kept.current, template)) {
6005
6031
  kept.current = template;
6006
6032
  }
@@ -6011,7 +6037,6 @@ function useStableTemplate(template) {
6011
6037
  import { jsx as jsx11 } from "react/jsx-runtime";
6012
6038
  var DEFAULT_TRACK_CONTROLS_WIDTH = 200;
6013
6039
  var DEFAULT_TEMPLATE = /* @__PURE__ */ jsx11(DefaultTrackControls, {});
6014
- var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
6015
6040
  var SLOT_BODY_STYLE = { height: "100%" };
6016
6041
  function TrackControlsSlotImpl({
6017
6042
  trackId,
@@ -6027,7 +6052,7 @@ function TrackControlsSlotImpl({
6027
6052
  isLast,
6028
6053
  renderMode,
6029
6054
  hasSpectrogram,
6030
- isRecordingArmed,
6055
+ isRecording,
6031
6056
  height,
6032
6057
  top,
6033
6058
  animate,
@@ -6041,16 +6066,15 @@ function TrackControlsSlotImpl({
6041
6066
  reorderTrack,
6042
6067
  setSelectedTrackId
6043
6068
  } = useEditorControls();
6044
- const theme = useTheme3();
6045
6069
  const shared = use9(TrackControlsSharedContext);
6046
- const indexRef = useRef28(index);
6070
+ const indexRef = useRef29(index);
6047
6071
  indexRef.current = index;
6048
6072
  const actions = useMemo17(
6049
6073
  () => ({
6050
- setMuted: (value2) => setTrackMute(trackId, value2),
6051
- setSoloed: (value2) => setTrackSolo(trackId, value2),
6052
- setVolume: (value2) => setTrackVolume(trackId, value2),
6053
- setPan: (value2) => setTrackPan(trackId, value2),
6074
+ setMuted: (value2, options) => setTrackMute(trackId, value2, options),
6075
+ setSoloed: (value2, options) => setTrackSolo(trackId, value2, options),
6076
+ setVolume: (value2, options) => setTrackVolume(trackId, value2, options),
6077
+ setPan: (value2, options) => setTrackPan(trackId, value2, options),
6054
6078
  select: () => setSelectedTrackId(trackId),
6055
6079
  // The engine clamps the target and ignores a move to the same place.
6056
6080
  moveUp: () => reorderTrack(trackId, indexRef.current - 1),
@@ -6084,7 +6108,7 @@ function TrackControlsSlotImpl({
6084
6108
  isFirst,
6085
6109
  isLast,
6086
6110
  hasSpectrogram,
6087
- isRecordingArmed
6111
+ isRecording
6088
6112
  }, actions),
6089
6113
  [
6090
6114
  trackId,
@@ -6100,11 +6124,11 @@ function TrackControlsSlotImpl({
6100
6124
  isFirst,
6101
6125
  isLast,
6102
6126
  hasSpectrogram,
6103
- isRecordingArmed,
6127
+ isRecording,
6104
6128
  actions
6105
6129
  ]
6106
6130
  );
6107
- const elementRef = useRef28(null);
6131
+ const elementRef = useRef29(null);
6108
6132
  const [isDragSource, setDragSource] = useState20(false);
6109
6133
  const wiring = useMemo17(
6110
6134
  () => ({ elementRef, setDragSource, handleCount: { current: 0 } }),
@@ -6113,27 +6137,14 @@ function TrackControlsSlotImpl({
6113
6137
  return /* @__PURE__ */ jsx11(
6114
6138
  ControlSlot,
6115
6139
  {
6140
+ ref: elementRef,
6116
6141
  $height: height,
6117
6142
  $top: top,
6118
6143
  $animate: animate,
6119
6144
  $isSelected: isSelected,
6145
+ $isDragSource: isDragSource,
6120
6146
  onClick: actions.select,
6121
- children: /* @__PURE__ */ jsx11(
6122
- "div",
6123
- {
6124
- ref: elementRef,
6125
- "data-track-controls": trackId,
6126
- style: isDragSource ? __spreadProps(__spreadValues({}, SLOT_BODY_STYLE), {
6127
- boxShadow: DRAG_SOURCE_SHADOW,
6128
- // Opaque background for the floating (top-layer, popover-based)
6129
- // drag-source row — without it the row underneath shows through.
6130
- // onDragStart selects the dragged track, so its slot always shows
6131
- // the selected-track background while lifted.
6132
- background: theme.selectedTrackControlsBackground
6133
- }) : SLOT_BODY_STYLE,
6134
- children: /* @__PURE__ */ jsx11(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ jsx11(TrackContext, { value, children: template }) })
6135
- }
6136
- )
6147
+ children: /* @__PURE__ */ jsx11("div", { "data-track-controls": trackId, style: SLOT_BODY_STYLE, children: /* @__PURE__ */ jsx11(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ jsx11(TrackContext, { value, children: template }) }) })
6137
6148
  }
6138
6149
  );
6139
6150
  }
@@ -6145,6 +6156,7 @@ function WaveformTrackControlsImpl({ children }) {
6145
6156
  trackLayout,
6146
6157
  trackHeightById,
6147
6158
  animateTrackLayout,
6159
+ dragSourceTrackId,
6148
6160
  setSettingsModalTrackId
6149
6161
  } = useWaveformRows("The track controls");
6150
6162
  if (use9(WaveformPartPlaceContext) !== "controls") {
@@ -6153,12 +6165,11 @@ function WaveformTrackControlsImpl({ children }) {
6153
6165
  );
6154
6166
  }
6155
6167
  const { selectedTrackId } = useSelectedTrackId();
6156
- const { armedTrackId } = useRecordingArm();
6157
- const { trackReorderEpoch } = useTrackReorderPreview();
6168
+ const { recordingTrackId } = useRecordingTrack();
6158
6169
  const spectrogram = use9(SpectrogramIntegrationContext);
6159
6170
  const { trackStates } = usePlaylistMixer();
6160
6171
  const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
6161
- const spectrogramRef = useRef28(spectrogram);
6172
+ const spectrogramRef = useRef29(spectrogram);
6162
6173
  spectrogramRef.current = spectrogram;
6163
6174
  const menuAvailable = Boolean(spectrogram == null ? void 0 : spectrogram.renderMenuItems);
6164
6175
  const shared = useMemo17(
@@ -6181,36 +6192,29 @@ function WaveformTrackControlsImpl({ children }) {
6181
6192
  return /* @__PURE__ */ jsx11(TrackControlsSharedContext, { value: shared, children: /* @__PURE__ */ jsx11(TracksLayout, { $height: trackLayout.totalHeight, children: tracks.map((track, trackIndex) => {
6182
6193
  var _a, _b, _c;
6183
6194
  const state = trackStates[trackIndex];
6184
- return (
6185
- // key includes trackReorderEpoch: forces a remount after every
6186
- // track-reorder drag, discarding @dnd-kit sortable-plugin DOM
6187
- // corruption (see bumpTrackReorderEpoch's doc comment in
6188
- // WaveformPlaylistContext). Stays at `-0` — a no-op suffix — for
6189
- // consumers that never render a reorder handle.
6190
- /* @__PURE__ */ jsx11(
6191
- TrackControlsSlot,
6192
- {
6193
- trackId: track.id,
6194
- index: trackIndex,
6195
- kind: track.kind,
6196
- name: state.name,
6197
- muted: state.muted,
6198
- soloed: state.soloed,
6199
- volume: state.volume,
6200
- pan: state.pan,
6201
- isSelected: track.id === selectedTrackId,
6202
- isFirst: trackIndex === 0,
6203
- isLast: trackIndex === tracks.length - 1,
6204
- renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
6205
- hasSpectrogram: spectrogram !== null && track.kind !== "midi",
6206
- isRecordingArmed: track.id === armedTrackId,
6207
- height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
6208
- top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
6209
- animate: animateTrackLayout,
6210
- template
6211
- },
6212
- `${track.id}-${trackReorderEpoch}`
6213
- )
6195
+ return /* @__PURE__ */ jsx11(
6196
+ TrackControlsSlot,
6197
+ {
6198
+ trackId: track.id,
6199
+ index: trackIndex,
6200
+ kind: track.kind,
6201
+ name: state.name,
6202
+ muted: state.muted,
6203
+ soloed: state.soloed,
6204
+ volume: state.volume,
6205
+ pan: state.pan,
6206
+ isSelected: track.id === selectedTrackId,
6207
+ isFirst: trackIndex === 0,
6208
+ isLast: trackIndex === tracks.length - 1,
6209
+ renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
6210
+ hasSpectrogram: spectrogram !== null && track.kind !== "midi",
6211
+ isRecording: track.id === recordingTrackId,
6212
+ height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
6213
+ top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
6214
+ animate: animateTrackLayout && dragSourceTrackId !== null,
6215
+ template
6216
+ },
6217
+ track.id
6214
6218
  );
6215
6219
  }) }) });
6216
6220
  }
@@ -6221,11 +6225,11 @@ import React14, { use as use10, useSyncExternalStore as useSyncExternalStore12 }
6221
6225
  import {
6222
6226
  Selection,
6223
6227
  TimescaleLoopRegion,
6224
- useTheme as useTheme4
6228
+ useTheme as useTheme3
6225
6229
  } from "@waveform-playlist/ui-components";
6226
6230
 
6227
6231
  // src/components/AnimatedPlayhead.tsx
6228
- import { useRef as useRef29, useEffect as useEffect15, useId as useId3 } from "react";
6232
+ import { useRef as useRef30, useEffect as useEffect16, useId as useId3 } from "react";
6229
6233
  import styled5 from "styled-components";
6230
6234
  import { usePlaylistInfo as usePlaylistInfo3 } from "@waveform-playlist/ui-components";
6231
6235
  import { jsx as jsx12 } from "react/jsx-runtime";
@@ -6244,7 +6248,7 @@ var PlayheadLine = styled5.div.attrs((props) => ({
6244
6248
  will-change: transform;
6245
6249
  `;
6246
6250
  var AnimatedPlayhead = ({ color = "#ff0000" }) => {
6247
- const playheadRef = useRef29(null);
6251
+ const playheadRef = useRef30(null);
6248
6252
  const frameCallbackId = useId3();
6249
6253
  const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
6250
6254
  const { isPlaying } = useIsPlaying();
@@ -6252,7 +6256,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
6252
6256
  const { sampleRate } = usePlaylistView();
6253
6257
  const { progressBarWidth } = usePlaylistInfo3();
6254
6258
  const { samplesPerPixel } = usePlaylistZoom();
6255
- useEffect15(() => {
6259
+ useEffect16(() => {
6256
6260
  if (isPlaying) {
6257
6261
  registerFrameCallback(
6258
6262
  frameCallbackId,
@@ -6266,7 +6270,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
6266
6270
  }
6267
6271
  return () => unregisterFrameCallback(frameCallbackId);
6268
6272
  }, [isPlaying, frameCallbackId, registerFrameCallback, unregisterFrameCallback]);
6269
- useEffect15(() => {
6273
+ useEffect16(() => {
6270
6274
  var _a, _b;
6271
6275
  if (!isPlaying && playheadRef.current) {
6272
6276
  const time = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
@@ -6283,7 +6287,7 @@ var subscribeToNothing3 = () => () => {
6283
6287
  };
6284
6288
  var noPreview = () => null;
6285
6289
  var WaveformSelection = React14.memo(function WaveformSelection2() {
6286
- const theme = useTheme4();
6290
+ const theme = useTheme3();
6287
6291
  const { selectionStart, selectionEnd } = useSelection();
6288
6292
  const { sampleRate } = usePlaylistView();
6289
6293
  const { samplesPerPixel } = usePlaylistZoom();
@@ -6322,7 +6326,7 @@ var CustomPlayhead = ({ renderPlayhead, color, samplesPerPixel, sampleRate }) =>
6322
6326
  });
6323
6327
  };
6324
6328
  var WaveformPlayhead = ({ renderPlayhead }) => {
6325
- const theme = useTheme4();
6329
+ const theme = useTheme3();
6326
6330
  const { isPlaying } = useIsPlaying();
6327
6331
  const { selectionStart, selectionEnd } = useSelection();
6328
6332
  const { sampleRate } = usePlaylistView();
@@ -6345,7 +6349,7 @@ var WaveformLoopRegion = React14.memo(function WaveformLoopRegion2() {
6345
6349
  "<WaveformLoopRegion> is drawn among the tracks, not in the timescale strip: the root recognises a part by its element type, so it must be a child of the root (a fragment is fine), not wrapped in another component."
6346
6350
  );
6347
6351
  }
6348
- const theme = useTheme4();
6352
+ const theme = useTheme3();
6349
6353
  const { isLoopEnabled, loopStart, loopEnd } = useLoop();
6350
6354
  const { setLoopRegion } = useEditorControls();
6351
6355
  const { sampleRate } = usePlaylistView();
@@ -6579,7 +6583,7 @@ function useWaveformFrame({
6579
6583
  onClickWhileStopped
6580
6584
  }) {
6581
6585
  var _a;
6582
- const theme = useTheme5();
6586
+ const theme = useTheme4();
6583
6587
  const { setScrollContainer } = usePlaybackControls();
6584
6588
  const { sampleRate } = usePlaylistView();
6585
6589
  const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
@@ -6740,7 +6744,7 @@ var WaveformRoot = ({ className, children }) => {
6740
6744
  displayDuration = Math.max(displayDuration, recordingLayout.displayEndSeconds);
6741
6745
  }
6742
6746
  displayDuration = Math.max(displayDuration, trimPreviewEnd);
6743
- const tracksRef = useRef30(tracks);
6747
+ const tracksRef = useRef31(tracks);
6744
6748
  tracksRef.current = tracks;
6745
6749
  const selectTrack = useCallback26(
6746
6750
  (trackIndex) => {
@@ -6862,7 +6866,7 @@ var WaveformRoot = ({ className, children }) => {
6862
6866
  import React20, { use as use16 } from "react";
6863
6867
  import { DragDropProvider } from "@dnd-kit/react";
6864
6868
  import { RestrictToHorizontalAxis } from "@dnd-kit/abstract/modifiers";
6865
- import { useTheme as useTheme6 } from "@waveform-playlist/ui-components";
6869
+ import { useTheme as useTheme5 } from "@waveform-playlist/ui-components";
6866
6870
 
6867
6871
  // src/AnnotationIntegrationContext.tsx
6868
6872
  import { createContext as createContext9, use as use14 } from "react";
@@ -6958,7 +6962,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
6958
6962
  const { sampleRate } = usePlaylistView();
6959
6963
  const { samplesPerPixel } = usePlaylistZoom();
6960
6964
  const { touchOptimized } = useClipInteraction();
6961
- const theme = useTheme6();
6965
+ const theme = useTheme5();
6962
6966
  const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
6963
6967
  const sensors = useDragSensors({ touchOptimized });
6964
6968
  const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
@@ -7222,19 +7226,19 @@ var KeyboardShortcuts = ({
7222
7226
  };
7223
7227
 
7224
7228
  // src/hooks/useRecordingSession.ts
7225
- import { useEffect as useEffect16 } from "react";
7229
+ import { useEffect as useEffect17 } from "react";
7226
7230
  function useRecordingSession({ isRecording, trackId }) {
7227
7231
  const { setRecordingActive } = useEditorControls();
7228
- const armedTrackId = trackId != null ? trackId : null;
7229
- useEffect16(() => {
7232
+ const recordingTrackId = trackId != null ? trackId : null;
7233
+ useEffect17(() => {
7230
7234
  if (!isRecording) return void 0;
7231
- setRecordingActive(true, armedTrackId);
7235
+ setRecordingActive(true, recordingTrackId);
7232
7236
  return () => setRecordingActive(false);
7233
- }, [isRecording, armedTrackId, setRecordingActive]);
7237
+ }, [isRecording, recordingTrackId, setRecordingActive]);
7234
7238
  }
7235
7239
 
7236
7240
  // src/components/ClipInteractionProvider.tsx
7237
- import React23, { useCallback as useCallback28, useMemo as useMemo23, useRef as useRef31 } from "react";
7241
+ import React23, { useCallback as useCallback28, useMemo as useMemo23, useRef as useRef32 } from "react";
7238
7242
  import { flushSync as flushSync2 } from "react-dom";
7239
7243
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
7240
7244
  import { RestrictToHorizontalAxis as RestrictToHorizontalAxis2 } from "@dnd-kit/abstract/modifiers";
@@ -7337,7 +7341,7 @@ var ClipInteractionProvider = ({
7337
7341
  const { sampleRate } = usePlaylistView();
7338
7342
  const { samplesPerPixel } = usePlaylistZoom();
7339
7343
  const { tracks } = usePlaylistTimeline();
7340
- const { setSelectedTrackId, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview } = useEditorControls();
7344
+ const { setSelectedTrackId, reorderTrack, setTrackDragPreview } = useEditorControls();
7341
7345
  const beatsAndBars = useBeatsAndBars();
7342
7346
  const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
7343
7347
  const useTimescaleSnap = snap && !useBeatsSnap;
@@ -7357,7 +7361,7 @@ var ClipInteractionProvider = ({
7357
7361
  }
7358
7362
  return void 0;
7359
7363
  }, [useBeatsSnap, useTimescaleSnap, beatsAndBars, sampleRate, samplesPerPixel]);
7360
- const tracksRef = useRef31(tracks);
7364
+ const tracksRef = useRef32(tracks);
7361
7365
  tracksRef.current = tracks;
7362
7366
  const getTracks = useCallback28(() => tracksRef.current, []);
7363
7367
  const sensors = useDragSensors({ touchOptimized });
@@ -7366,13 +7370,11 @@ var ClipInteractionProvider = ({
7366
7370
  onDragMove,
7367
7371
  onDragEnd
7368
7372
  } = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
7369
- const trackReorderDragActiveRef = React23.useRef(false);
7370
7373
  const onDragStart = React23.useCallback(
7371
7374
  (event) => {
7372
7375
  var _a, _b;
7373
7376
  const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
7374
7377
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7375
- trackReorderDragActiveRef.current = true;
7376
7378
  if (data.trackId) setSelectedTrackId(data.trackId);
7377
7379
  return;
7378
7380
  }
@@ -7390,7 +7392,6 @@ var ClipInteractionProvider = ({
7390
7392
  var _a;
7391
7393
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7392
7394
  if ((data == null ? void 0 : data.kind) !== "track-reorder" || !data.trackId) return;
7393
- if (!trackReorderDragActiveRef.current) return;
7394
7395
  const sortable = event.operation.source.sortable;
7395
7396
  if (!sortable) return;
7396
7397
  const trackId = data.trackId;
@@ -7406,12 +7407,10 @@ var ClipInteractionProvider = ({
7406
7407
  var _a;
7407
7408
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7408
7409
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7409
- trackReorderDragActiveRef.current = false;
7410
7410
  const sortable = event.operation.source.sortable;
7411
7411
  const trackId = data.trackId;
7412
7412
  const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
7413
7413
  flushSync2(() => {
7414
- bumpTrackReorderEpoch();
7415
7414
  setTrackDragPreview(null);
7416
7415
  if (moves) reorderTrack(trackId, sortable.index);
7417
7416
  });
@@ -7419,7 +7418,7 @@ var ClipInteractionProvider = ({
7419
7418
  }
7420
7419
  onDragEnd(event);
7421
7420
  },
7422
- [onDragEnd, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview]
7421
+ [onDragEnd, reorderTrack, setTrackDragPreview]
7423
7422
  );
7424
7423
  const modifiers = useMemo23(() => {
7425
7424
  const mods = [RestrictToHorizontalAxis2];