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

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
@@ -184,7 +184,7 @@ __export(index_exports, {
184
184
  module.exports = __toCommonJS(index_exports);
185
185
 
186
186
  // <define:__INSTALL_SPECS__>
187
- 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" };
187
+ 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.6", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.4", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.4", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.6", 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.4" };
188
188
 
189
189
  // src/WaveformPlaylistContext.tsx
190
190
  var import_react35 = require("react");
@@ -541,6 +541,7 @@ var PlaylistMixerContext = slot();
541
541
  var TrackReorderPreviewContext = slot();
542
542
  var TrimPreviewContext = slot();
543
543
  var TrimPreviewPeaksContext = slot();
544
+ var DragGuardContext = slot();
544
545
  var RecordingTrackContext = slot();
545
546
  var PlaybackRateContext = slot();
546
547
  var MediaElementTrackContext = slot();
@@ -594,6 +595,7 @@ var usePlaylistViewOptional = () => orNull((0, import_react7.use)(PlaylistViewCo
594
595
  var usePlaylistZoomOptional = () => orNull((0, import_react7.use)(PlaylistZoomContext));
595
596
  var useTrimPreviewOptional = () => orNull((0, import_react7.use)(TrimPreviewContext));
596
597
  var useTrimPreviewPeaksOptional = () => orNull((0, import_react7.use)(TrimPreviewPeaksContext));
598
+ var useDragGuardOptional = () => orNull((0, import_react7.use)(DragGuardContext));
597
599
 
598
600
  // src/hooks/useClipDragHandlers.ts
599
601
  function trimOrderFor(clips, clip) {
@@ -656,6 +658,14 @@ function useClipDragHandlers({
656
658
  const trimDragRef = import_react8.default.useRef(null);
657
659
  const lastBoundaryDeltaRef = import_react8.default.useRef(0);
658
660
  const moveDragRef = import_react8.default.useRef(null);
661
+ const dragGuard = useDragGuardOptional();
662
+ const endGuardRef = import_react8.default.useRef(null);
663
+ const endGuard = import_react8.default.useCallback(() => {
664
+ var _a;
665
+ (_a = endGuardRef.current) == null ? void 0 : _a.call(endGuardRef);
666
+ endGuardRef.current = null;
667
+ }, []);
668
+ import_react8.default.useEffect(() => endGuard, [endGuard]);
659
669
  import_react8.default.useEffect(() => {
660
670
  if (!preview) return;
661
671
  return () => {
@@ -667,9 +677,11 @@ function useClipDragHandlers({
667
677
  }, [preview]);
668
678
  const onDragStart = import_react8.default.useCallback(
669
679
  (event) => {
670
- var _a;
680
+ var _a, _b;
671
681
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
672
682
  if (!data || data.kind === "track-reorder") return;
683
+ endGuard();
684
+ endGuardRef.current = (_b = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _b : null;
673
685
  trimDragRef.current = null;
674
686
  trimOrderRef.current = null;
675
687
  moveDragRef.current = null;
@@ -695,7 +707,7 @@ function useClipDragHandlers({
695
707
  };
696
708
  trimOrderRef.current = trimOrderFor(clips, clip);
697
709
  },
698
- [arrangement]
710
+ [arrangement, dragGuard, endGuard]
699
711
  );
700
712
  const onDragMove = import_react8.default.useCallback(
701
713
  (event) => {
@@ -747,6 +759,7 @@ function useClipDragHandlers({
747
759
  var _a, _b;
748
760
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
749
761
  if ((data == null ? void 0 : data.kind) === "track-reorder") return;
762
+ endGuard();
750
763
  const drag = trimDragRef.current;
751
764
  const move = moveDragRef.current;
752
765
  const delta = lastBoundaryDeltaRef.current;
@@ -779,7 +792,7 @@ function useClipDragHandlers({
779
792
  arrangement.moveClip(track.id, clipId, Math.floor(sampleDelta));
780
793
  }
781
794
  },
782
- [samplesPerPixel, arrangement, preview, commitTrim]
795
+ [samplesPerPixel, arrangement, preview, commitTrim, endGuard]
783
796
  );
784
797
  return {
785
798
  onDragStart,
@@ -3039,7 +3052,7 @@ function useRecordingActive(arrangement) {
3039
3052
  const recordingTrack = (0, import_react33.useMemo)(() => ({ recordingTrackId }), [recordingTrackId]);
3040
3053
  return { setRecordingActive, recordingActiveRef, recordingTrack };
3041
3054
  }
3042
- function useArrangementEditing(arrangement) {
3055
+ function useArrangementEditing(arrangement, dragGuard) {
3043
3056
  const setTrackMute = (0, import_react33.useCallback)(
3044
3057
  (trackId, muted, options) => {
3045
3058
  if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted, options);
@@ -3069,8 +3082,12 @@ function useArrangementEditing(arrangement) {
3069
3082
  (trackId, toIndex) => arrangement.reorderTrack(trackId, toIndex),
3070
3083
  [arrangement]
3071
3084
  );
3072
- const undo = (0, import_react33.useCallback)(() => arrangement.undo(), [arrangement]);
3073
- const redo = (0, import_react33.useCallback)(() => arrangement.redo(), [arrangement]);
3085
+ const undo = (0, import_react33.useCallback)(() => {
3086
+ if (!dragGuard.active) arrangement.undo();
3087
+ }, [arrangement, dragGuard]);
3088
+ const redo = (0, import_react33.useCallback)(() => {
3089
+ if (!dragGuard.active) arrangement.redo();
3090
+ }, [arrangement, dragGuard]);
3074
3091
  const { setRecordingActive, recordingActiveRef, recordingTrack } = useRecordingActive(arrangement);
3075
3092
  return {
3076
3093
  setTrackMute,
@@ -3086,6 +3103,25 @@ function useArrangementEditing(arrangement) {
3086
3103
  };
3087
3104
  }
3088
3105
 
3106
+ // src/providerInternals/dragGuard.ts
3107
+ function createDragGuard() {
3108
+ let count = 0;
3109
+ return {
3110
+ begin() {
3111
+ count++;
3112
+ let ended = false;
3113
+ return () => {
3114
+ if (ended) return;
3115
+ ended = true;
3116
+ count--;
3117
+ };
3118
+ },
3119
+ get active() {
3120
+ return count > 0;
3121
+ }
3122
+ };
3123
+ }
3124
+
3089
3125
  // src/providerInternals/arrangementIdentity.ts
3090
3126
  var import_react34 = require("react");
3091
3127
  var arrangementKeys = /* @__PURE__ */ new WeakMap();
@@ -3332,7 +3368,8 @@ var ProviderOnArrangement = ({
3332
3368
  peaksOptions: view.peaksOptions,
3333
3369
  peaksCacheRef: view.peaksCacheRef
3334
3370
  });
3335
- const editing = useArrangementEditing(arrangement);
3371
+ const [dragGuard] = (0, import_react35.useState)(createDragGuard);
3372
+ const editing = useArrangementEditing(arrangement, dragGuard);
3336
3373
  const { recordingActiveRef } = editing;
3337
3374
  const setLoopRegionFromSelection = (0, import_react35.useCallback)(() => {
3338
3375
  var _a, _b;
@@ -3950,25 +3987,31 @@ var ProviderOnArrangement = ({
3950
3987
  () => ({ trackDragPreview }),
3951
3988
  [trackDragPreview]
3952
3989
  );
3953
- 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)(
3954
- TrackReorderPreviewContext,
3990
+ 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)(DragGuardContext, { value: dragGuard, 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)(
3991
+ ActiveAnnotationContext,
3955
3992
  {
3956
- value: reorderPreviewValue,
3957
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistMixerContext, { value: mixerValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3958
- PlaylistTimelineContext,
3993
+ value: activeAnnotationValue,
3994
+ 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)(
3995
+ TrackReorderPreviewContext,
3959
3996
  {
3960
- value: timelineValue,
3961
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3962
- RecordingTrackContext,
3997
+ value: reorderPreviewValue,
3998
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistMixerContext, { value: mixerValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
3999
+ PlaylistTimelineContext,
3963
4000
  {
3964
- value: editing.recordingTrack,
3965
- children
4001
+ value: timelineValue,
4002
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4003
+ RecordingTrackContext,
4004
+ {
4005
+ value: editing.recordingTrack,
4006
+ children
4007
+ }
4008
+ )
3966
4009
  }
3967
- )
4010
+ ) })
3968
4011
  }
3969
- ) })
4012
+ ) }) })
3970
4013
  }
3971
- ) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
4014
+ ) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
3972
4015
  };
3973
4016
 
3974
4017
  // src/MediaElementPlaylistContext.tsx
@@ -7398,11 +7441,21 @@ var ClipInteractionProvider = ({
7398
7441
  onDragMove,
7399
7442
  onDragEnd
7400
7443
  } = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
7444
+ const dragGuard = useDragGuardOptional();
7445
+ const endReorderGuardRef = (0, import_react68.useRef)(null);
7446
+ const endReorderGuard = (0, import_react68.useCallback)(() => {
7447
+ var _a;
7448
+ (_a = endReorderGuardRef.current) == null ? void 0 : _a.call(endReorderGuardRef);
7449
+ endReorderGuardRef.current = null;
7450
+ }, []);
7451
+ import_react68.default.useEffect(() => endReorderGuard, [endReorderGuard]);
7401
7452
  const onDragStart = import_react68.default.useCallback(
7402
7453
  (event) => {
7403
- var _a, _b;
7454
+ var _a, _b, _c;
7404
7455
  const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
7405
7456
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7457
+ endReorderGuard();
7458
+ endReorderGuardRef.current = (_c = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _c : null;
7406
7459
  if (data.trackId) setSelectedTrackId(data.trackId);
7407
7460
  return;
7408
7461
  }
@@ -7413,7 +7466,7 @@ var ClipInteractionProvider = ({
7413
7466
  }
7414
7467
  handleDragStart(event);
7415
7468
  },
7416
- [handleDragStart, setSelectedTrackId]
7469
+ [handleDragStart, setSelectedTrackId, dragGuard, endReorderGuard]
7417
7470
  );
7418
7471
  const handleDragOver = import_react68.default.useCallback(
7419
7472
  (event) => {
@@ -7435,6 +7488,7 @@ var ClipInteractionProvider = ({
7435
7488
  var _a;
7436
7489
  const data = (_a = event.operation.source) == null ? void 0 : _a.data;
7437
7490
  if ((data == null ? void 0 : data.kind) === "track-reorder") {
7491
+ endReorderGuard();
7438
7492
  const sortable = event.operation.source.sortable;
7439
7493
  const trackId = data.trackId;
7440
7494
  const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
@@ -7446,7 +7500,7 @@ var ClipInteractionProvider = ({
7446
7500
  }
7447
7501
  onDragEnd(event);
7448
7502
  },
7449
- [onDragEnd, reorderTrack, setTrackDragPreview]
7503
+ [onDragEnd, reorderTrack, setTrackDragPreview, endReorderGuard]
7450
7504
  );
7451
7505
  const modifiers = (0, import_react68.useMemo)(() => {
7452
7506
  const mods = [import_modifiers3.RestrictToHorizontalAxis];