@waveform-playlist/browser 17.0.0-next.5 → 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.js CHANGED
@@ -1058,18 +1058,17 @@ var import_react13 = require("react");
1058
1058
  var import_core3 = require("@waveform-playlist/core");
1059
1059
  var useKeyboardShortcuts = (options) => {
1060
1060
  const { shortcuts, enabled = true } = options;
1061
- const shortcutsRef = (0, import_react13.useRef)(shortcuts);
1062
- (0, import_react13.useEffect)(() => {
1063
- shortcutsRef.current = shortcuts;
1061
+ const latest = (0, import_react13.useRef)({ shortcuts, enabled });
1062
+ (0, import_react13.useLayoutEffect)(() => {
1063
+ latest.current = { shortcuts, enabled };
1064
1064
  });
1065
- (0, import_react13.useEffect)(() => {
1066
- if (!enabled) return;
1067
- const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, shortcutsRef.current, true);
1065
+ (0, import_react13.useLayoutEffect)(() => {
1066
+ const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, latest.current.shortcuts, latest.current.enabled);
1068
1067
  window.addEventListener("keydown", handleKeyDown);
1069
1068
  return () => {
1070
1069
  window.removeEventListener("keydown", handleKeyDown);
1071
1070
  };
1072
- }, [enabled]);
1071
+ }, []);
1073
1072
  };
1074
1073
 
1075
1074
  // src/hooks/usePlaybackShortcuts.ts
@@ -1084,7 +1083,7 @@ function usePlayFromSelectionOrCursor() {
1084
1083
  const isLoopEnabled = (_b = (_a = useLoopOptional()) == null ? void 0 : _a.isLoopEnabled) != null ? _b : false;
1085
1084
  const { play } = usePlaybackControls();
1086
1085
  const latest = (0, import_react14.useRef)({ selectionStart, selectionEnd, isLoopEnabled });
1087
- (0, import_react14.useEffect)(() => {
1086
+ (0, import_react14.useLayoutEffect)(() => {
1088
1087
  latest.current = { selectionStart, selectionEnd, isLoopEnabled };
1089
1088
  });
1090
1089
  return (0, import_react14.useCallback)(() => __async(null, null, function* () {
@@ -3164,7 +3163,6 @@ var ProviderOnArrangement = ({
3164
3163
  const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
3165
3164
  const [isPlaying, setIsPlaying] = (0, import_react35.useState)(false);
3166
3165
  const [currentTime, setCurrentTime] = (0, import_react35.useState)(0);
3167
- const [trackReorderEpoch, setTrackReorderEpoch] = (0, import_react35.useState)(0);
3168
3166
  const [trackDragPreview, setTrackDragPreview] = (0, import_react35.useState)(null);
3169
3167
  const indefinitePlaybackRef = (0, import_react35.useRef)(indefinitePlayback);
3170
3168
  indefinitePlaybackRef.current = indefinitePlayback;
@@ -3702,9 +3700,6 @@ var ProviderOnArrangement = ({
3702
3700
  },
3703
3701
  [play, setCurrentTimeRefs, recordingActiveRef]
3704
3702
  );
3705
- const bumpTrackReorderEpoch = (0, import_react35.useCallback)(() => {
3706
- setTrackReorderEpoch((epoch) => epoch + 1);
3707
- }, []);
3708
3703
  const setSelection = (0, import_react35.useCallback)(
3709
3704
  (start, end) => {
3710
3705
  var _a;
@@ -3872,7 +3867,6 @@ var ProviderOnArrangement = ({
3872
3867
  setTrackVolume: editing.setTrackVolume,
3873
3868
  setTrackPan: editing.setTrackPan,
3874
3869
  reorderTrack: editing.reorderTrack,
3875
- bumpTrackReorderEpoch,
3876
3870
  setTrackDragPreview,
3877
3871
  setSelectedTrackId: setSelectedTrackIdControl,
3878
3872
  // Zoom
@@ -3898,7 +3892,6 @@ var ProviderOnArrangement = ({
3898
3892
  editing.setTrackVolume,
3899
3893
  editing.setTrackPan,
3900
3894
  editing.reorderTrack,
3901
- bumpTrackReorderEpoch,
3902
3895
  setTrackDragPreview,
3903
3896
  setSelectedTrackIdControl,
3904
3897
  zoom.zoomIn,
@@ -3939,8 +3932,8 @@ var ProviderOnArrangement = ({
3939
3932
  [trackStates, masterVolume]
3940
3933
  );
3941
3934
  const reorderPreviewValue = (0, import_react35.useMemo)(
3942
- () => ({ trackDragPreview, trackReorderEpoch }),
3943
- [trackDragPreview, trackReorderEpoch]
3935
+ () => ({ trackDragPreview }),
3936
+ [trackDragPreview]
3944
3937
  );
3945
3938
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled_components.ThemeProvider, { theme: mergedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRateContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaElementTrackContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrangementContext, { value: arrangement, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRefsContext, { value: refsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineRefsContext, { value: engineRefsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrimPreviewContext, { value: trimPreview, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrimPreviewPeaksContext, { value: trimPreviewPeaks, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackControlsContext, { value: controlsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditorControlsContext, { value: editorControlsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistViewContext, { value: viewValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistSettingsContext, { value: settingsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistZoomContext, { value: zoomValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UndoRedoContext, { value: undoRedoValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectedTrackIdContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectedRowContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoopContext, { value: loopValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnnotationOptionsContext, { value: annotationOptionsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnnotationsContext, { value: annotationsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IsPlayingContext, { value: isPlayingValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveAnnotationContext, { value: activeAnnotationValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectionContext, { value: selectionValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3946
3939
  TrackReorderPreviewContext,
@@ -4779,7 +4772,7 @@ var AutomaticScrollCheckbox = ({ className }) => {
4779
4772
  // src/components/WaveformRoot.tsx
4780
4773
  var import_react60 = require("react");
4781
4774
  var import_react_dom2 = require("react-dom");
4782
- var import_ui_components16 = require("@waveform-playlist/ui-components");
4775
+ var import_ui_components15 = require("@waveform-playlist/ui-components");
4783
4776
 
4784
4777
  // src/utils/trackOrderPreview.ts
4785
4778
  function applyTrackOrderPreview(tracks, preview) {
@@ -4946,6 +4939,7 @@ var TrackRowPositioner = import_styled_components4.default.div.attrs((props) =>
4946
4939
  transition: none;
4947
4940
  }
4948
4941
  `;
4942
+ var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
4949
4943
  var ControlSlot = import_styled_components4.default.div.attrs((props) => ({
4950
4944
  style: {
4951
4945
  height: `${props.$height}px`,
@@ -4964,6 +4958,7 @@ var ControlSlot = import_styled_components4.default.div.attrs((props) => ({
4964
4958
  transition: background 0.15s ease-in-out;
4965
4959
  }
4966
4960
  ${(props) => props.$isSelected && `background: ${props.theme.selectedTrackControlsBackground};`}
4961
+ ${(props) => props.$isDragSource && `background: ${props.theme.selectedTrackControlsBackground}; box-shadow: ${DRAG_SOURCE_SHADOW};`}
4967
4962
  `;
4968
4963
  function getTrackChannelCount(trackClipPeaks, recordingChannels) {
4969
4964
  const clipChannels = trackClipPeaks.length > 0 ? Math.max(1, ...trackClipPeaks.map((clip) => clip.peaks.data.length)) : 1;
@@ -4972,7 +4967,7 @@ function getTrackChannelCount(trackClipPeaks, recordingChannels) {
4972
4967
 
4973
4968
  // src/components/waveformFrame.tsx
4974
4969
  var import_react59 = __toESM(require("react"));
4975
- var import_ui_components15 = require("@waveform-playlist/ui-components");
4970
+ var import_ui_components14 = require("@waveform-playlist/ui-components");
4976
4971
 
4977
4972
  // src/hooks/useSelectionDrag.ts
4978
4973
  var import_react44 = require("react");
@@ -5148,7 +5143,7 @@ var useWaveformRows = (part) => required((0, import_react45.use)(WaveformRowsCon
5148
5143
 
5149
5144
  // src/components/waveformParts.tsx
5150
5145
  var import_react58 = __toESM(require("react"));
5151
- var import_ui_components14 = require("@waveform-playlist/ui-components");
5146
+ var import_ui_components13 = require("@waveform-playlist/ui-components");
5152
5147
 
5153
5148
  // src/components/TrackRows.tsx
5154
5149
  var import_react48 = __toESM(require("react"));
@@ -5729,7 +5724,6 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
5729
5724
 
5730
5725
  // src/components/TrackControlsColumn.tsx
5731
5726
  var import_react54 = __toESM(require("react"));
5732
- var import_ui_components10 = require("@waveform-playlist/ui-components");
5733
5727
 
5734
5728
  // src/components/DefaultTrackControls.tsx
5735
5729
  var import_react52 = __toESM(require("react"));
@@ -5789,7 +5783,7 @@ function createDragPopoverHealer(element) {
5789
5783
  }
5790
5784
 
5791
5785
  // src/hooks/useTrackReorderHandle.ts
5792
- var MOVE_FEEDBACK = import_dom2.Feedback.configure({ feedback: "move" });
5786
+ var MOVE_FEEDBACK = import_dom2.Feedback.configure({ feedback: "move", dropAnimation: null });
5793
5787
  var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
5794
5788
  function useTrackReorderHandle() {
5795
5789
  const { id, index } = useTrack();
@@ -5816,10 +5810,9 @@ function useTrackReorderHandle() {
5816
5810
  // `placeholder.replaceWith(element)` on drop) — confirmed via
5817
5811
  // MutationObserver instrumentation to relocate the React-owned row 6
5818
5812
  // times during a single one-slot drag, leaving its final parent/sibling
5819
- // different from what React's fiber tree still believes. That desync is
5820
- // permanent for the session: every later React-driven reorder (button OR
5821
- // drag) computes the correct data but silently fails to update the DOM
5822
- // for these rows. The placeholder splice is created only when
5813
+ // different from what React's fiber tree still believes. (Measured when
5814
+ // the registered element was one level inside the keyed slot, before
5815
+ // #796; not re-run with the slot itself.) The placeholder splice is created only when
5823
5816
  // `feedback !== 'move'` (@dnd-kit/dom Feedback.ts) — 'move' keeps the
5824
5817
  // dragged element in the live DOM (no clone/placeholder) while still
5825
5818
  // running the *unconditional* `dragOperation.shape = ...` assignment.
@@ -5831,7 +5824,10 @@ function useTrackReorderHandle() {
5831
5824
  // drag-based reordering silently never commits. Boundary trims don't hit
5832
5825
  // this because they're plain useDraggable (no collision-based commit) —
5833
5826
  // sortables need shape. `isDragSource` is a reactive signal, unaffected
5834
- // either way. See browser/CLAUDE.md "Track Reordering".
5827
+ // either way. OptimisticSortingPlugin still moves the element during the
5828
+ // drag (`insertAdjacentElement` next to the item it is dragged over);
5829
+ // that is safe only because the element is the keyed slot (#796, below).
5830
+ // See browser/notes/track-controls-and-reorder.md "Track Reordering".
5835
5831
  plugins: withMoveFeedback
5836
5832
  });
5837
5833
  (0, import_react50.useEffect)(() => {
@@ -6066,7 +6062,6 @@ function useStableTemplate(template) {
6066
6062
  var import_jsx_runtime11 = require("react/jsx-runtime");
6067
6063
  var DEFAULT_TRACK_CONTROLS_WIDTH = 200;
6068
6064
  var DEFAULT_TEMPLATE = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultTrackControls, {});
6069
- var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
6070
6065
  var SLOT_BODY_STYLE = { height: "100%" };
6071
6066
  function TrackControlsSlotImpl({
6072
6067
  trackId,
@@ -6096,7 +6091,6 @@ function TrackControlsSlotImpl({
6096
6091
  reorderTrack,
6097
6092
  setSelectedTrackId
6098
6093
  } = useEditorControls();
6099
- const theme = (0, import_ui_components10.useTheme)();
6100
6094
  const shared = (0, import_react54.use)(TrackControlsSharedContext);
6101
6095
  const indexRef = (0, import_react54.useRef)(index);
6102
6096
  indexRef.current = index;
@@ -6168,27 +6162,14 @@ function TrackControlsSlotImpl({
6168
6162
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6169
6163
  ControlSlot,
6170
6164
  {
6165
+ ref: elementRef,
6171
6166
  $height: height,
6172
6167
  $top: top,
6173
6168
  $animate: animate,
6174
6169
  $isSelected: isSelected,
6170
+ $isDragSource: isDragSource,
6175
6171
  onClick: actions.select,
6176
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6177
- "div",
6178
- {
6179
- ref: elementRef,
6180
- "data-track-controls": trackId,
6181
- style: isDragSource ? __spreadProps(__spreadValues({}, SLOT_BODY_STYLE), {
6182
- boxShadow: DRAG_SOURCE_SHADOW,
6183
- // Opaque background for the floating (top-layer, popover-based)
6184
- // drag-source row — without it the row underneath shows through.
6185
- // onDragStart selects the dragged track, so its slot always shows
6186
- // the selected-track background while lifted.
6187
- background: theme.selectedTrackControlsBackground
6188
- }) : SLOT_BODY_STYLE,
6189
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackContext, { value, children: template }) })
6190
- }
6191
- )
6172
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "data-track-controls": trackId, style: SLOT_BODY_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackContext, { value, children: template }) }) })
6192
6173
  }
6193
6174
  );
6194
6175
  }
@@ -6200,6 +6181,7 @@ function WaveformTrackControlsImpl({ children }) {
6200
6181
  trackLayout,
6201
6182
  trackHeightById,
6202
6183
  animateTrackLayout,
6184
+ dragSourceTrackId,
6203
6185
  setSettingsModalTrackId
6204
6186
  } = useWaveformRows("The track controls");
6205
6187
  if ((0, import_react54.use)(WaveformPartPlaceContext) !== "controls") {
@@ -6209,7 +6191,6 @@ function WaveformTrackControlsImpl({ children }) {
6209
6191
  }
6210
6192
  const { selectedTrackId } = useSelectedTrackId();
6211
6193
  const { armedTrackId } = useRecordingArm();
6212
- const { trackReorderEpoch } = useTrackReorderPreview();
6213
6194
  const spectrogram = (0, import_react54.use)(SpectrogramIntegrationContext);
6214
6195
  const { trackStates } = usePlaylistMixer();
6215
6196
  const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
@@ -6236,36 +6217,29 @@ function WaveformTrackControlsImpl({ children }) {
6236
6217
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackControlsSharedContext, { value: shared, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TracksLayout, { $height: trackLayout.totalHeight, children: tracks.map((track, trackIndex) => {
6237
6218
  var _a, _b, _c;
6238
6219
  const state = trackStates[trackIndex];
6239
- return (
6240
- // key includes trackReorderEpoch: forces a remount after every
6241
- // track-reorder drag, discarding @dnd-kit sortable-plugin DOM
6242
- // corruption (see bumpTrackReorderEpoch's doc comment in
6243
- // WaveformPlaylistContext). Stays at `-0` — a no-op suffix — for
6244
- // consumers that never render a reorder handle.
6245
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6246
- TrackControlsSlot,
6247
- {
6248
- trackId: track.id,
6249
- index: trackIndex,
6250
- kind: track.kind,
6251
- name: state.name,
6252
- muted: state.muted,
6253
- soloed: state.soloed,
6254
- volume: state.volume,
6255
- pan: state.pan,
6256
- isSelected: track.id === selectedTrackId,
6257
- isFirst: trackIndex === 0,
6258
- isLast: trackIndex === tracks.length - 1,
6259
- renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
6260
- hasSpectrogram: spectrogram !== null && track.kind !== "midi",
6261
- isRecordingArmed: track.id === armedTrackId,
6262
- height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
6263
- top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
6264
- animate: animateTrackLayout,
6265
- template
6266
- },
6267
- `${track.id}-${trackReorderEpoch}`
6268
- )
6220
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6221
+ TrackControlsSlot,
6222
+ {
6223
+ trackId: track.id,
6224
+ index: trackIndex,
6225
+ kind: track.kind,
6226
+ name: state.name,
6227
+ muted: state.muted,
6228
+ soloed: state.soloed,
6229
+ volume: state.volume,
6230
+ pan: state.pan,
6231
+ isSelected: track.id === selectedTrackId,
6232
+ isFirst: trackIndex === 0,
6233
+ isLast: trackIndex === tracks.length - 1,
6234
+ renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
6235
+ hasSpectrogram: spectrogram !== null && track.kind !== "midi",
6236
+ isRecordingArmed: track.id === armedTrackId,
6237
+ height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
6238
+ top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
6239
+ animate: animateTrackLayout && dragSourceTrackId !== null,
6240
+ template
6241
+ },
6242
+ track.id
6269
6243
  );
6270
6244
  }) }) });
6271
6245
  }
@@ -6273,12 +6247,12 @@ var WaveformTrackControls = import_react54.default.memo(WaveformTrackControlsImp
6273
6247
 
6274
6248
  // src/components/VisualizationOverlays.tsx
6275
6249
  var import_react56 = __toESM(require("react"));
6276
- var import_ui_components12 = require("@waveform-playlist/ui-components");
6250
+ var import_ui_components11 = require("@waveform-playlist/ui-components");
6277
6251
 
6278
6252
  // src/components/AnimatedPlayhead.tsx
6279
6253
  var import_react55 = require("react");
6280
6254
  var import_styled_components7 = __toESM(require("styled-components"));
6281
- var import_ui_components11 = require("@waveform-playlist/ui-components");
6255
+ var import_ui_components10 = require("@waveform-playlist/ui-components");
6282
6256
  var import_jsx_runtime12 = require("react/jsx-runtime");
6283
6257
  var PlayheadLine = import_styled_components7.default.div.attrs((props) => ({
6284
6258
  style: {
@@ -6301,7 +6275,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
6301
6275
  const { isPlaying } = useIsPlaying();
6302
6276
  useCurrentTime();
6303
6277
  const { sampleRate } = usePlaylistView();
6304
- const { progressBarWidth } = (0, import_ui_components11.usePlaylistInfo)();
6278
+ const { progressBarWidth } = (0, import_ui_components10.usePlaylistInfo)();
6305
6279
  const { samplesPerPixel } = usePlaylistZoom();
6306
6280
  (0, import_react55.useEffect)(() => {
6307
6281
  if (isPlaying) {
@@ -6334,7 +6308,7 @@ var subscribeToNothing3 = () => () => {
6334
6308
  };
6335
6309
  var noPreview = () => null;
6336
6310
  var WaveformSelection = import_react56.default.memo(function WaveformSelection2() {
6337
- const theme = (0, import_ui_components12.useTheme)();
6311
+ const theme = (0, import_ui_components11.useTheme)();
6338
6312
  const { selectionStart, selectionEnd } = useSelection();
6339
6313
  const { sampleRate } = usePlaylistView();
6340
6314
  const { samplesPerPixel } = usePlaylistZoom();
@@ -6348,7 +6322,7 @@ var WaveformSelection = import_react56.default.memo(function WaveformSelection2(
6348
6322
  const end = preview ? preview.end : Math.max(selectionStart, selectionEnd);
6349
6323
  if (start === end) return null;
6350
6324
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6351
- import_ui_components12.Selection,
6325
+ import_ui_components11.Selection,
6352
6326
  {
6353
6327
  startPosition: start * sampleRate / samplesPerPixel,
6354
6328
  endPosition: end * sampleRate / samplesPerPixel,
@@ -6373,7 +6347,7 @@ var CustomPlayhead = ({ renderPlayhead, color, samplesPerPixel, sampleRate }) =>
6373
6347
  });
6374
6348
  };
6375
6349
  var WaveformPlayhead = ({ renderPlayhead }) => {
6376
- const theme = (0, import_ui_components12.useTheme)();
6350
+ const theme = (0, import_ui_components11.useTheme)();
6377
6351
  const { isPlaying } = useIsPlaying();
6378
6352
  const { selectionStart, selectionEnd } = useSelection();
6379
6353
  const { sampleRate } = usePlaylistView();
@@ -6396,14 +6370,14 @@ var WaveformLoopRegion = import_react56.default.memo(function WaveformLoopRegion
6396
6370
  "<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."
6397
6371
  );
6398
6372
  }
6399
- const theme = (0, import_ui_components12.useTheme)();
6373
+ const theme = (0, import_ui_components11.useTheme)();
6400
6374
  const { isLoopEnabled, loopStart, loopEnd } = useLoop();
6401
6375
  const { setLoopRegion } = useEditorControls();
6402
6376
  const { sampleRate } = usePlaylistView();
6403
6377
  const { samplesPerPixel } = usePlaylistZoom();
6404
6378
  if (!isLoopEnabled) return null;
6405
6379
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
6406
- import_ui_components12.TimescaleLoopRegion,
6380
+ import_ui_components11.TimescaleLoopRegion,
6407
6381
  {
6408
6382
  startPosition: Math.min(loopStart, loopEnd) * sampleRate / samplesPerPixel,
6409
6383
  endPosition: Math.max(loopStart, loopEnd) * sampleRate / samplesPerPixel,
@@ -6422,7 +6396,7 @@ var WaveformLoopRegion = import_react56.default.memo(function WaveformLoopRegion
6422
6396
 
6423
6397
  // src/components/WaveformViewOptions.tsx
6424
6398
  var import_react57 = require("react");
6425
- var import_ui_components13 = require("@waveform-playlist/ui-components");
6399
+ var import_ui_components12 = require("@waveform-playlist/ui-components");
6426
6400
  var import_jsx_runtime14 = require("react/jsx-runtime");
6427
6401
  var NO_OPTIONS = {};
6428
6402
  var WaveformViewOptionsContext = (0, import_react57.createContext)(NO_OPTIONS);
@@ -6452,28 +6426,28 @@ var isPositive = (value) => value > 0;
6452
6426
  function useResolvedViewOptions() {
6453
6427
  var _a, _b, _c, _d, _e, _f;
6454
6428
  const options = (0, import_react57.use)(WaveformViewOptionsContext);
6455
- let waveHeight = (_a = options.waveHeight) != null ? _a : import_ui_components13.DEFAULT_WAVE_HEIGHT;
6456
- let barWidth = (_b = options.barWidth) != null ? _b : import_ui_components13.DEFAULT_BAR_WIDTH;
6457
- let barGap = (_c = options.barGap) != null ? _c : import_ui_components13.DEFAULT_BAR_GAP;
6429
+ let waveHeight = (_a = options.waveHeight) != null ? _a : import_ui_components12.DEFAULT_WAVE_HEIGHT;
6430
+ let barWidth = (_b = options.barWidth) != null ? _b : import_ui_components12.DEFAULT_BAR_WIDTH;
6431
+ let barGap = (_c = options.barGap) != null ? _c : import_ui_components12.DEFAULT_BAR_GAP;
6458
6432
  const roundedBars = (_d = options.roundedBars) != null ? _d : false;
6459
6433
  const fillViewport = (_e = options.fillViewport) != null ? _e : false;
6460
6434
  if (!isPositive(waveHeight)) {
6461
6435
  warnOnce(
6462
- `<WaveformViewOptions waveHeight> must be a positive number of pixels: ${String(waveHeight)} is replaced by ${import_ui_components13.DEFAULT_WAVE_HEIGHT}.`
6436
+ `<WaveformViewOptions waveHeight> must be a positive number of pixels: ${String(waveHeight)} is replaced by ${import_ui_components12.DEFAULT_WAVE_HEIGHT}.`
6463
6437
  );
6464
- waveHeight = import_ui_components13.DEFAULT_WAVE_HEIGHT;
6438
+ waveHeight = import_ui_components12.DEFAULT_WAVE_HEIGHT;
6465
6439
  }
6466
6440
  if (!isPositive(barWidth)) {
6467
6441
  warnOnce(
6468
- `<WaveformViewOptions barWidth> must be a positive number of pixels: ${String(barWidth)} is replaced by ${import_ui_components13.DEFAULT_BAR_WIDTH}.`
6442
+ `<WaveformViewOptions barWidth> must be a positive number of pixels: ${String(barWidth)} is replaced by ${import_ui_components12.DEFAULT_BAR_WIDTH}.`
6469
6443
  );
6470
- barWidth = import_ui_components13.DEFAULT_BAR_WIDTH;
6444
+ barWidth = import_ui_components12.DEFAULT_BAR_WIDTH;
6471
6445
  }
6472
6446
  if (Number.isNaN(barGap)) {
6473
6447
  warnOnce(
6474
- `<WaveformViewOptions barGap> must be a number of pixels: ${String(barGap)} is replaced by ${import_ui_components13.DEFAULT_BAR_GAP}.`
6448
+ `<WaveformViewOptions barGap> must be a number of pixels: ${String(barGap)} is replaced by ${import_ui_components12.DEFAULT_BAR_GAP}.`
6475
6449
  );
6476
- barGap = import_ui_components13.DEFAULT_BAR_GAP;
6450
+ barGap = import_ui_components12.DEFAULT_BAR_GAP;
6477
6451
  }
6478
6452
  if (!(barWidth + barGap >= 1)) {
6479
6453
  const raised = 1 - barWidth;
@@ -6504,7 +6478,7 @@ var WaveformTimescale = import_react58.default.memo(function WaveformTimescale2(
6504
6478
  "<WaveformTimescale> 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."
6505
6479
  );
6506
6480
  }
6507
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_components14.SmartScale, { durationMs: displayDuration * 1e3, renderTick });
6481
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_components13.SmartScale, { durationMs: displayDuration * 1e3, renderTick });
6508
6482
  });
6509
6483
  var TIMESCALE_PARTS = /* @__PURE__ */ new Set([WaveformTimescale, WaveformLoopRegion]);
6510
6484
  var CONTROLS_PARTS = /* @__PURE__ */ new Set([WaveformTrackControls]);
@@ -6626,7 +6600,7 @@ function useWaveformFrame({
6626
6600
  onClickWhileStopped
6627
6601
  }) {
6628
6602
  var _a;
6629
- const theme = (0, import_ui_components15.useTheme)();
6603
+ const theme = (0, import_ui_components14.useTheme)();
6630
6604
  const { setScrollContainer } = usePlaybackControls();
6631
6605
  const { sampleRate } = usePlaylistView();
6632
6606
  const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
@@ -6674,16 +6648,16 @@ function useWaveformFrame({
6674
6648
  );
6675
6649
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
6676
6650
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AutomaticScrollFlag, { flagRef: automaticScrollRef }),
6677
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_components15.PlaylistInfoContext, { value: playlistInfo, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformExtentContext, { value: extent, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformRowsContext, { value: rows, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6651
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_components14.PlaylistInfoContext, { value: playlistInfo, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformExtentContext, { value: extent, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformRowsContext, { value: rows, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6678
6652
  RootSeesRecordingPreviewContext,
6679
6653
  {
6680
6654
  value: parts.tracksOptions.recordingState !== void 0,
6681
6655
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SelectionPreviewContext, { value: selectionPreview, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
6682
- import_ui_components15.Playlist,
6656
+ import_ui_components14.Playlist,
6683
6657
  {
6684
6658
  className,
6685
6659
  theme,
6686
- backgroundColor: theme.playlistBackgroundColor || (0, import_ui_components15.waveformColorToCss)(theme.waveOutlineColor),
6660
+ backgroundColor: theme.playlistBackgroundColor || (0, import_ui_components14.waveformColorToCss)(theme.waveOutlineColor),
6687
6661
  timescaleBackgroundColor: theme.timescaleBackgroundColor,
6688
6662
  timescaleWidth: tracksFullWidth,
6689
6663
  tracksWidth: tracksFullWidth,
@@ -6807,7 +6781,7 @@ var WaveformRoot = ({ className, children }) => {
6807
6781
  trackClipPeaks,
6808
6782
  track.id === recordingTrackId ? recordingChannelCount : 0
6809
6783
  );
6810
- m.set(track.id, waveHeight * maxChannels + (showClipHeaders ? import_ui_components16.CLIP_HEADER_HEIGHT : 0));
6784
+ m.set(track.id, waveHeight * maxChannels + (showClipHeaders ? import_ui_components15.CLIP_HEADER_HEIGHT : 0));
6811
6785
  });
6812
6786
  return m;
6813
6787
  }, [
@@ -6883,7 +6857,7 @@ var WaveformRoot = ({ className, children }) => {
6883
6857
  },
6884
6858
  onClickWhileStopped: setCurrentTime
6885
6859
  });
6886
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_components16.DevicePixelRatioProvider, { children: [
6860
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_components15.DevicePixelRatioProvider, { children: [
6887
6861
  frame,
6888
6862
  (spectrogram == null ? void 0 : spectrogram.SettingsModal) && typeof document !== "undefined" && (0, import_react_dom2.createPortal)(
6889
6863
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6909,7 +6883,7 @@ var WaveformRoot = ({ className, children }) => {
6909
6883
  var import_react63 = __toESM(require("react"));
6910
6884
  var import_react64 = require("@dnd-kit/react");
6911
6885
  var import_modifiers2 = require("@dnd-kit/abstract/modifiers");
6912
- var import_ui_components17 = require("@waveform-playlist/ui-components");
6886
+ var import_ui_components16 = require("@waveform-playlist/ui-components");
6913
6887
 
6914
6888
  // src/AnnotationIntegrationContext.tsx
6915
6889
  var import_react61 = require("react");
@@ -7005,7 +6979,7 @@ var WaveformAnnotationBoxes = import_react63.default.memo(function WaveformAnnot
7005
6979
  const { sampleRate } = usePlaylistView();
7006
6980
  const { samplesPerPixel } = usePlaylistZoom();
7007
6981
  const { touchOptimized } = useClipInteraction();
7008
- const theme = (0, import_ui_components17.useTheme)();
6982
+ const theme = (0, import_ui_components16.useTheme)();
7009
6983
  const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
7010
6984
  const sensors = useDragSensors({ touchOptimized });
7011
6985
  const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
@@ -7125,7 +7099,7 @@ var WaveformEditor = (props) => composeWaveform(__spreadProps(__spreadValues({},
7125
7099
 
7126
7100
  // src/components/MediaElementWaveformRoot.tsx
7127
7101
  var import_react66 = require("react");
7128
- var import_ui_components18 = require("@waveform-playlist/ui-components");
7102
+ var import_ui_components17 = require("@waveform-playlist/ui-components");
7129
7103
  var import_jsx_runtime22 = require("react/jsx-runtime");
7130
7104
  var ONE_ROW = [{ id: MEDIA_ELEMENT_TRACK_ID, kind: "audio" }];
7131
7105
  var ONE_EMPTY_ROW = [[]];
@@ -7156,7 +7130,7 @@ var MediaElementWaveformRoot = ({
7156
7130
  const channels = getTrackChannelCount(rowPeaks[index], 0);
7157
7131
  trackHeightById.set(
7158
7132
  row.id,
7159
- waveHeight * channels + (showClipHeaders ? import_ui_components18.CLIP_HEADER_HEIGHT : 0)
7133
+ waveHeight * channels + (showClipHeaders ? import_ui_components17.CLIP_HEADER_HEIGHT : 0)
7160
7134
  );
7161
7135
  });
7162
7136
  return {
@@ -7193,7 +7167,7 @@ var MediaElementWaveformRoot = ({
7193
7167
  controlsWidth: 0,
7194
7168
  onClickWhileStopped: collapseSelectionAt
7195
7169
  });
7196
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_ui_components18.DevicePixelRatioProvider, { children: frame });
7170
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_ui_components17.DevicePixelRatioProvider, { children: frame });
7197
7171
  };
7198
7172
 
7199
7173
  // src/components/MediaElementWaveform.tsx
@@ -7286,7 +7260,7 @@ var import_react_dom3 = require("react-dom");
7286
7260
  var import_react69 = require("@dnd-kit/react");
7287
7261
  var import_modifiers3 = require("@dnd-kit/abstract/modifiers");
7288
7262
  var import_core15 = require("@waveform-playlist/core");
7289
- var import_ui_components19 = require("@waveform-playlist/ui-components");
7263
+ var import_ui_components18 = require("@waveform-playlist/ui-components");
7290
7264
 
7291
7265
  // src/modifiers/ClipCollisionModifier.ts
7292
7266
  var import_abstract = require("@dnd-kit/abstract");
@@ -7366,8 +7340,8 @@ var ClipInteractionProvider = ({
7366
7340
  const { sampleRate } = usePlaylistView();
7367
7341
  const { samplesPerPixel } = usePlaylistZoom();
7368
7342
  const { tracks } = usePlaylistTimeline();
7369
- const { setSelectedTrackId, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview } = useEditorControls();
7370
- const beatsAndBars = (0, import_ui_components19.useBeatsAndBars)();
7343
+ const { setSelectedTrackId, reorderTrack, setTrackDragPreview } = useEditorControls();
7344
+ const beatsAndBars = (0, import_ui_components18.useBeatsAndBars)();
7371
7345
  const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
7372
7346
  const useTimescaleSnap = snap && !useBeatsSnap;
7373
7347
  const snapSamplePosition = (0, import_react68.useMemo)(() => {
@@ -7381,7 +7355,7 @@ var ClipInteractionProvider = ({
7381
7355
  };
7382
7356
  }
7383
7357
  if (useTimescaleSnap) {
7384
- const gridSamples = Math.round((0, import_ui_components19.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate);
7358
+ const gridSamples = Math.round((0, import_ui_components18.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate);
7385
7359
  return (samplePos) => Math.round(samplePos / gridSamples) * gridSamples;
7386
7360
  }
7387
7361
  return void 0;
@@ -7395,13 +7369,11 @@ var ClipInteractionProvider = ({
7395
7369
  onDragMove,
7396
7370
  onDragEnd
7397
7371
  } = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
7398
- const trackReorderDragActiveRef = import_react68.default.useRef(false);
7399
7372
  const onDragStart = import_react68.default.useCallback(
7400
7373
  (event) => {
7401
7374
  var _a, _b;
7402
7375
  const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
7403
7376
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7404
- trackReorderDragActiveRef.current = true;
7405
7377
  if (data.trackId) setSelectedTrackId(data.trackId);
7406
7378
  return;
7407
7379
  }
@@ -7419,7 +7391,6 @@ var ClipInteractionProvider = ({
7419
7391
  var _a;
7420
7392
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7421
7393
  if ((data == null ? void 0 : data.kind) !== "track-reorder" || !data.trackId) return;
7422
- if (!trackReorderDragActiveRef.current) return;
7423
7394
  const sortable = event.operation.source.sortable;
7424
7395
  if (!sortable) return;
7425
7396
  const trackId = data.trackId;
@@ -7435,12 +7406,10 @@ var ClipInteractionProvider = ({
7435
7406
  var _a;
7436
7407
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7437
7408
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7438
- trackReorderDragActiveRef.current = false;
7439
7409
  const sortable = event.operation.source.sortable;
7440
7410
  const trackId = data.trackId;
7441
7411
  const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
7442
7412
  (0, import_react_dom3.flushSync)(() => {
7443
- bumpTrackReorderEpoch();
7444
7413
  setTrackDragPreview(null);
7445
7414
  if (moves) reorderTrack(trackId, sortable.index);
7446
7415
  });
@@ -7448,7 +7417,7 @@ var ClipInteractionProvider = ({
7448
7417
  }
7449
7418
  onDragEnd(event);
7450
7419
  },
7451
- [onDragEnd, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview]
7420
+ [onDragEnd, reorderTrack, setTrackDragPreview]
7452
7421
  );
7453
7422
  const modifiers = (0, import_react68.useMemo)(() => {
7454
7423
  const mods = [import_modifiers3.RestrictToHorizontalAxis];
@@ -7467,7 +7436,7 @@ var ClipInteractionProvider = ({
7467
7436
  mods.push(
7468
7437
  SnapToGridModifier.configure({
7469
7438
  mode: "timescale",
7470
- gridSamples: Math.round((0, import_ui_components19.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate),
7439
+ gridSamples: Math.round((0, import_ui_components18.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate),
7471
7440
  samplesPerPixel
7472
7441
  })
7473
7442
  );