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

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
@@ -3046,7 +3046,6 @@ var ProviderOnArrangement = ({
3046
3046
  const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
3047
3047
  const [isPlaying, setIsPlaying] = useState16(false);
3048
3048
  const [currentTime, setCurrentTime] = useState16(0);
3049
- const [trackReorderEpoch, setTrackReorderEpoch] = useState16(0);
3050
3049
  const [trackDragPreview, setTrackDragPreview] = useState16(null);
3051
3050
  const indefinitePlaybackRef = useRef21(indefinitePlayback);
3052
3051
  indefinitePlaybackRef.current = indefinitePlayback;
@@ -3584,9 +3583,6 @@ var ProviderOnArrangement = ({
3584
3583
  },
3585
3584
  [play, setCurrentTimeRefs, recordingActiveRef]
3586
3585
  );
3587
- const bumpTrackReorderEpoch = useCallback19(() => {
3588
- setTrackReorderEpoch((epoch) => epoch + 1);
3589
- }, []);
3590
3586
  const setSelection = useCallback19(
3591
3587
  (start, end) => {
3592
3588
  var _a;
@@ -3754,7 +3750,6 @@ var ProviderOnArrangement = ({
3754
3750
  setTrackVolume: editing.setTrackVolume,
3755
3751
  setTrackPan: editing.setTrackPan,
3756
3752
  reorderTrack: editing.reorderTrack,
3757
- bumpTrackReorderEpoch,
3758
3753
  setTrackDragPreview,
3759
3754
  setSelectedTrackId: setSelectedTrackIdControl,
3760
3755
  // Zoom
@@ -3780,7 +3775,6 @@ var ProviderOnArrangement = ({
3780
3775
  editing.setTrackVolume,
3781
3776
  editing.setTrackPan,
3782
3777
  editing.reorderTrack,
3783
- bumpTrackReorderEpoch,
3784
3778
  setTrackDragPreview,
3785
3779
  setSelectedTrackIdControl,
3786
3780
  zoom.zoomIn,
@@ -3821,8 +3815,8 @@ var ProviderOnArrangement = ({
3821
3815
  [trackStates, masterVolume]
3822
3816
  );
3823
3817
  const reorderPreviewValue = useMemo11(
3824
- () => ({ trackDragPreview, trackReorderEpoch }),
3825
- [trackDragPreview, trackReorderEpoch]
3818
+ () => ({ trackDragPreview }),
3819
+ [trackDragPreview]
3826
3820
  );
3827
3821
  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
3822
  TrackReorderPreviewContext,
@@ -4849,6 +4843,7 @@ var TrackRowPositioner = styled2.div.attrs((props) => ({
4849
4843
  transition: none;
4850
4844
  }
4851
4845
  `;
4846
+ var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
4852
4847
  var ControlSlot = styled2.div.attrs((props) => ({
4853
4848
  style: {
4854
4849
  height: `${props.$height}px`,
@@ -4867,6 +4862,7 @@ var ControlSlot = styled2.div.attrs((props) => ({
4867
4862
  transition: background 0.15s ease-in-out;
4868
4863
  }
4869
4864
  ${(props) => props.$isSelected && `background: ${props.theme.selectedTrackControlsBackground};`}
4865
+ ${(props) => props.$isDragSource && `background: ${props.theme.selectedTrackControlsBackground}; box-shadow: ${DRAG_SOURCE_SHADOW};`}
4870
4866
  `;
4871
4867
  function getTrackChannelCount(trackClipPeaks, recordingChannels) {
4872
4868
  const clipChannels = trackClipPeaks.length > 0 ? Math.max(1, ...trackClipPeaks.map((clip) => clip.peaks.data.length)) : 1;
@@ -4883,7 +4879,7 @@ import React17, {
4883
4879
  import {
4884
4880
  Playlist,
4885
4881
  PlaylistInfoContext,
4886
- useTheme as useTheme5,
4882
+ useTheme as useTheme4,
4887
4883
  waveformColorToCss as waveformColorToCss3
4888
4884
  } from "@waveform-playlist/ui-components";
4889
4885
 
@@ -5665,7 +5661,6 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
5665
5661
 
5666
5662
  // src/components/TrackControlsColumn.tsx
5667
5663
  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";
5669
5664
 
5670
5665
  // src/components/DefaultTrackControls.tsx
5671
5666
  import React11 from "react";
@@ -5734,7 +5729,7 @@ function createDragPopoverHealer(element) {
5734
5729
  }
5735
5730
 
5736
5731
  // src/hooks/useTrackReorderHandle.ts
5737
- var MOVE_FEEDBACK = Feedback.configure({ feedback: "move" });
5732
+ var MOVE_FEEDBACK = Feedback.configure({ feedback: "move", dropAnimation: null });
5738
5733
  var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
5739
5734
  function useTrackReorderHandle() {
5740
5735
  const { id, index } = useTrack();
@@ -5761,10 +5756,9 @@ function useTrackReorderHandle() {
5761
5756
  // `placeholder.replaceWith(element)` on drop) — confirmed via
5762
5757
  // MutationObserver instrumentation to relocate the React-owned row 6
5763
5758
  // 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
5759
+ // different from what React's fiber tree still believes. (Measured when
5760
+ // the registered element was one level inside the keyed slot, before
5761
+ // #796; not re-run with the slot itself.) The placeholder splice is created only when
5768
5762
  // `feedback !== 'move'` (@dnd-kit/dom Feedback.ts) — 'move' keeps the
5769
5763
  // dragged element in the live DOM (no clone/placeholder) while still
5770
5764
  // running the *unconditional* `dragOperation.shape = ...` assignment.
@@ -5776,7 +5770,10 @@ function useTrackReorderHandle() {
5776
5770
  // drag-based reordering silently never commits. Boundary trims don't hit
5777
5771
  // this because they're plain useDraggable (no collision-based commit) —
5778
5772
  // sortables need shape. `isDragSource` is a reactive signal, unaffected
5779
- // either way. See browser/CLAUDE.md "Track Reordering".
5773
+ // either way. OptimisticSortingPlugin still moves the element during the
5774
+ // drag (`insertAdjacentElement` next to the item it is dragged over);
5775
+ // that is safe only because the element is the keyed slot (#796, below).
5776
+ // See browser/notes/track-controls-and-reorder.md "Track Reordering".
5780
5777
  plugins: withMoveFeedback
5781
5778
  });
5782
5779
  useEffect14(() => {
@@ -6011,7 +6008,6 @@ function useStableTemplate(template) {
6011
6008
  import { jsx as jsx11 } from "react/jsx-runtime";
6012
6009
  var DEFAULT_TRACK_CONTROLS_WIDTH = 200;
6013
6010
  var DEFAULT_TEMPLATE = /* @__PURE__ */ jsx11(DefaultTrackControls, {});
6014
- var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
6015
6011
  var SLOT_BODY_STYLE = { height: "100%" };
6016
6012
  function TrackControlsSlotImpl({
6017
6013
  trackId,
@@ -6041,7 +6037,6 @@ function TrackControlsSlotImpl({
6041
6037
  reorderTrack,
6042
6038
  setSelectedTrackId
6043
6039
  } = useEditorControls();
6044
- const theme = useTheme3();
6045
6040
  const shared = use9(TrackControlsSharedContext);
6046
6041
  const indexRef = useRef28(index);
6047
6042
  indexRef.current = index;
@@ -6113,27 +6108,14 @@ function TrackControlsSlotImpl({
6113
6108
  return /* @__PURE__ */ jsx11(
6114
6109
  ControlSlot,
6115
6110
  {
6111
+ ref: elementRef,
6116
6112
  $height: height,
6117
6113
  $top: top,
6118
6114
  $animate: animate,
6119
6115
  $isSelected: isSelected,
6116
+ $isDragSource: isDragSource,
6120
6117
  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
- )
6118
+ 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
6119
  }
6138
6120
  );
6139
6121
  }
@@ -6145,6 +6127,7 @@ function WaveformTrackControlsImpl({ children }) {
6145
6127
  trackLayout,
6146
6128
  trackHeightById,
6147
6129
  animateTrackLayout,
6130
+ dragSourceTrackId,
6148
6131
  setSettingsModalTrackId
6149
6132
  } = useWaveformRows("The track controls");
6150
6133
  if (use9(WaveformPartPlaceContext) !== "controls") {
@@ -6154,7 +6137,6 @@ function WaveformTrackControlsImpl({ children }) {
6154
6137
  }
6155
6138
  const { selectedTrackId } = useSelectedTrackId();
6156
6139
  const { armedTrackId } = useRecordingArm();
6157
- const { trackReorderEpoch } = useTrackReorderPreview();
6158
6140
  const spectrogram = use9(SpectrogramIntegrationContext);
6159
6141
  const { trackStates } = usePlaylistMixer();
6160
6142
  const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
@@ -6181,36 +6163,29 @@ function WaveformTrackControlsImpl({ children }) {
6181
6163
  return /* @__PURE__ */ jsx11(TrackControlsSharedContext, { value: shared, children: /* @__PURE__ */ jsx11(TracksLayout, { $height: trackLayout.totalHeight, children: tracks.map((track, trackIndex) => {
6182
6164
  var _a, _b, _c;
6183
6165
  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
- )
6166
+ return /* @__PURE__ */ jsx11(
6167
+ TrackControlsSlot,
6168
+ {
6169
+ trackId: track.id,
6170
+ index: trackIndex,
6171
+ kind: track.kind,
6172
+ name: state.name,
6173
+ muted: state.muted,
6174
+ soloed: state.soloed,
6175
+ volume: state.volume,
6176
+ pan: state.pan,
6177
+ isSelected: track.id === selectedTrackId,
6178
+ isFirst: trackIndex === 0,
6179
+ isLast: trackIndex === tracks.length - 1,
6180
+ renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
6181
+ hasSpectrogram: spectrogram !== null && track.kind !== "midi",
6182
+ isRecordingArmed: track.id === armedTrackId,
6183
+ height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
6184
+ top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
6185
+ animate: animateTrackLayout && dragSourceTrackId !== null,
6186
+ template
6187
+ },
6188
+ track.id
6214
6189
  );
6215
6190
  }) }) });
6216
6191
  }
@@ -6221,7 +6196,7 @@ import React14, { use as use10, useSyncExternalStore as useSyncExternalStore12 }
6221
6196
  import {
6222
6197
  Selection,
6223
6198
  TimescaleLoopRegion,
6224
- useTheme as useTheme4
6199
+ useTheme as useTheme3
6225
6200
  } from "@waveform-playlist/ui-components";
6226
6201
 
6227
6202
  // src/components/AnimatedPlayhead.tsx
@@ -6283,7 +6258,7 @@ var subscribeToNothing3 = () => () => {
6283
6258
  };
6284
6259
  var noPreview = () => null;
6285
6260
  var WaveformSelection = React14.memo(function WaveformSelection2() {
6286
- const theme = useTheme4();
6261
+ const theme = useTheme3();
6287
6262
  const { selectionStart, selectionEnd } = useSelection();
6288
6263
  const { sampleRate } = usePlaylistView();
6289
6264
  const { samplesPerPixel } = usePlaylistZoom();
@@ -6322,7 +6297,7 @@ var CustomPlayhead = ({ renderPlayhead, color, samplesPerPixel, sampleRate }) =>
6322
6297
  });
6323
6298
  };
6324
6299
  var WaveformPlayhead = ({ renderPlayhead }) => {
6325
- const theme = useTheme4();
6300
+ const theme = useTheme3();
6326
6301
  const { isPlaying } = useIsPlaying();
6327
6302
  const { selectionStart, selectionEnd } = useSelection();
6328
6303
  const { sampleRate } = usePlaylistView();
@@ -6345,7 +6320,7 @@ var WaveformLoopRegion = React14.memo(function WaveformLoopRegion2() {
6345
6320
  "<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
6321
  );
6347
6322
  }
6348
- const theme = useTheme4();
6323
+ const theme = useTheme3();
6349
6324
  const { isLoopEnabled, loopStart, loopEnd } = useLoop();
6350
6325
  const { setLoopRegion } = useEditorControls();
6351
6326
  const { sampleRate } = usePlaylistView();
@@ -6579,7 +6554,7 @@ function useWaveformFrame({
6579
6554
  onClickWhileStopped
6580
6555
  }) {
6581
6556
  var _a;
6582
- const theme = useTheme5();
6557
+ const theme = useTheme4();
6583
6558
  const { setScrollContainer } = usePlaybackControls();
6584
6559
  const { sampleRate } = usePlaylistView();
6585
6560
  const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
@@ -6862,7 +6837,7 @@ var WaveformRoot = ({ className, children }) => {
6862
6837
  import React20, { use as use16 } from "react";
6863
6838
  import { DragDropProvider } from "@dnd-kit/react";
6864
6839
  import { RestrictToHorizontalAxis } from "@dnd-kit/abstract/modifiers";
6865
- import { useTheme as useTheme6 } from "@waveform-playlist/ui-components";
6840
+ import { useTheme as useTheme5 } from "@waveform-playlist/ui-components";
6866
6841
 
6867
6842
  // src/AnnotationIntegrationContext.tsx
6868
6843
  import { createContext as createContext9, use as use14 } from "react";
@@ -6958,7 +6933,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
6958
6933
  const { sampleRate } = usePlaylistView();
6959
6934
  const { samplesPerPixel } = usePlaylistZoom();
6960
6935
  const { touchOptimized } = useClipInteraction();
6961
- const theme = useTheme6();
6936
+ const theme = useTheme5();
6962
6937
  const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
6963
6938
  const sensors = useDragSensors({ touchOptimized });
6964
6939
  const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
@@ -7337,7 +7312,7 @@ var ClipInteractionProvider = ({
7337
7312
  const { sampleRate } = usePlaylistView();
7338
7313
  const { samplesPerPixel } = usePlaylistZoom();
7339
7314
  const { tracks } = usePlaylistTimeline();
7340
- const { setSelectedTrackId, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview } = useEditorControls();
7315
+ const { setSelectedTrackId, reorderTrack, setTrackDragPreview } = useEditorControls();
7341
7316
  const beatsAndBars = useBeatsAndBars();
7342
7317
  const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
7343
7318
  const useTimescaleSnap = snap && !useBeatsSnap;
@@ -7366,13 +7341,11 @@ var ClipInteractionProvider = ({
7366
7341
  onDragMove,
7367
7342
  onDragEnd
7368
7343
  } = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
7369
- const trackReorderDragActiveRef = React23.useRef(false);
7370
7344
  const onDragStart = React23.useCallback(
7371
7345
  (event) => {
7372
7346
  var _a, _b;
7373
7347
  const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
7374
7348
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7375
- trackReorderDragActiveRef.current = true;
7376
7349
  if (data.trackId) setSelectedTrackId(data.trackId);
7377
7350
  return;
7378
7351
  }
@@ -7390,7 +7363,6 @@ var ClipInteractionProvider = ({
7390
7363
  var _a;
7391
7364
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7392
7365
  if ((data == null ? void 0 : data.kind) !== "track-reorder" || !data.trackId) return;
7393
- if (!trackReorderDragActiveRef.current) return;
7394
7366
  const sortable = event.operation.source.sortable;
7395
7367
  if (!sortable) return;
7396
7368
  const trackId = data.trackId;
@@ -7406,12 +7378,10 @@ var ClipInteractionProvider = ({
7406
7378
  var _a;
7407
7379
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7408
7380
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7409
- trackReorderDragActiveRef.current = false;
7410
7381
  const sortable = event.operation.source.sortable;
7411
7382
  const trackId = data.trackId;
7412
7383
  const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
7413
7384
  flushSync2(() => {
7414
- bumpTrackReorderEpoch();
7415
7385
  setTrackDragPreview(null);
7416
7386
  if (moves) reorderTrack(trackId, sortable.index);
7417
7387
  });
@@ -7419,7 +7389,7 @@ var ClipInteractionProvider = ({
7419
7389
  }
7420
7390
  onDragEnd(event);
7421
7391
  },
7422
- [onDragEnd, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview]
7392
+ [onDragEnd, reorderTrack, setTrackDragPreview]
7423
7393
  );
7424
7394
  const modifiers = useMemo23(() => {
7425
7395
  const mods = [RestrictToHorizontalAxis2];