@waveform-playlist/browser 17.0.0-next.1 → 17.0.0-next.10
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/README.md +5 -5
- package/dist/index.d.mts +145 -126
- package/dist/index.d.ts +145 -126
- package/dist/index.js +987 -820
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -637
- package/dist/index.mjs.map +1 -1
- package/dist/tone.d.mts +0 -6
- package/dist/tone.d.ts +0 -6
- package/dist/tone.js +18 -2
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +18 -2
- package/dist/tone.mjs.map +1 -1
- package/package.json +11 -9
package/dist/index.mjs
CHANGED
|
@@ -50,14 +50,17 @@ var __async = (__this, __arguments, generator) => {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
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.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" };
|
|
55
|
+
|
|
53
56
|
// src/WaveformPlaylistContext.tsx
|
|
54
57
|
import {
|
|
55
58
|
useState as useState15,
|
|
56
|
-
useEffect as
|
|
57
|
-
useLayoutEffect as
|
|
58
|
-
useRef as
|
|
59
|
+
useEffect as useEffect8,
|
|
60
|
+
useLayoutEffect as useLayoutEffect5,
|
|
61
|
+
useRef as useRef21,
|
|
59
62
|
useCallback as useCallback19,
|
|
60
|
-
useMemo as
|
|
63
|
+
useMemo as useMemo11
|
|
61
64
|
} from "react";
|
|
62
65
|
import { ThemeProvider } from "styled-components";
|
|
63
66
|
|
|
@@ -415,7 +418,8 @@ var PlaylistMixerContext = slot();
|
|
|
415
418
|
var TrackReorderPreviewContext = slot();
|
|
416
419
|
var TrimPreviewContext = slot();
|
|
417
420
|
var TrimPreviewPeaksContext = slot();
|
|
418
|
-
var
|
|
421
|
+
var DragGuardContext = slot();
|
|
422
|
+
var RecordingTrackContext = slot();
|
|
419
423
|
var PlaybackRateContext = slot();
|
|
420
424
|
var MediaElementTrackContext = slot();
|
|
421
425
|
function useSlot(context, hookName, needs) {
|
|
@@ -453,7 +457,7 @@ var useUndoRedo = () => useSlot(UndoRedoContext, "useUndoRedo", WEB_AUDIO);
|
|
|
453
457
|
var usePlaylistTimeline = () => useSlot(PlaylistTimelineContext, "usePlaylistTimeline", WEB_AUDIO);
|
|
454
458
|
var usePlaylistMixer = () => useSlot(PlaylistMixerContext, "usePlaylistMixer", WEB_AUDIO);
|
|
455
459
|
var useTrackReorderPreview = () => useSlot(TrackReorderPreviewContext, "useTrackReorderPreview", WEB_AUDIO);
|
|
456
|
-
var
|
|
460
|
+
var useRecordingTrack = () => useSlot(RecordingTrackContext, "useRecordingTrack", WEB_AUDIO);
|
|
457
461
|
var usePlaybackRate = () => useSlot(PlaybackRateContext, "usePlaybackRate", MEDIA_ELEMENT);
|
|
458
462
|
var useMediaElementTrack = () => useSlot(MediaElementTrackContext, "useMediaElementTrack", MEDIA_ELEMENT);
|
|
459
463
|
var useWebAudioProviderOnly = (hookName) => {
|
|
@@ -468,6 +472,7 @@ var usePlaylistViewOptional = () => orNull(use(PlaylistViewContext));
|
|
|
468
472
|
var usePlaylistZoomOptional = () => orNull(use(PlaylistZoomContext));
|
|
469
473
|
var useTrimPreviewOptional = () => orNull(use(TrimPreviewContext));
|
|
470
474
|
var useTrimPreviewPeaksOptional = () => orNull(use(TrimPreviewPeaksContext));
|
|
475
|
+
var useDragGuardOptional = () => orNull(use(DragGuardContext));
|
|
471
476
|
|
|
472
477
|
// src/hooks/useClipDragHandlers.ts
|
|
473
478
|
function trimOrderFor(clips, clip) {
|
|
@@ -530,6 +535,14 @@ function useClipDragHandlers({
|
|
|
530
535
|
const trimDragRef = React.useRef(null);
|
|
531
536
|
const lastBoundaryDeltaRef = React.useRef(0);
|
|
532
537
|
const moveDragRef = React.useRef(null);
|
|
538
|
+
const dragGuard = useDragGuardOptional();
|
|
539
|
+
const endGuardRef = React.useRef(null);
|
|
540
|
+
const endGuard = React.useCallback(() => {
|
|
541
|
+
var _a;
|
|
542
|
+
(_a = endGuardRef.current) == null ? void 0 : _a.call(endGuardRef);
|
|
543
|
+
endGuardRef.current = null;
|
|
544
|
+
}, []);
|
|
545
|
+
React.useEffect(() => endGuard, [endGuard]);
|
|
533
546
|
React.useEffect(() => {
|
|
534
547
|
if (!preview) return;
|
|
535
548
|
return () => {
|
|
@@ -541,9 +554,11 @@ function useClipDragHandlers({
|
|
|
541
554
|
}, [preview]);
|
|
542
555
|
const onDragStart = React.useCallback(
|
|
543
556
|
(event) => {
|
|
544
|
-
var _a;
|
|
557
|
+
var _a, _b;
|
|
545
558
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
546
559
|
if (!data || data.kind === "track-reorder") return;
|
|
560
|
+
endGuard();
|
|
561
|
+
endGuardRef.current = (_b = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _b : null;
|
|
547
562
|
trimDragRef.current = null;
|
|
548
563
|
trimOrderRef.current = null;
|
|
549
564
|
moveDragRef.current = null;
|
|
@@ -569,7 +584,7 @@ function useClipDragHandlers({
|
|
|
569
584
|
};
|
|
570
585
|
trimOrderRef.current = trimOrderFor(clips, clip);
|
|
571
586
|
},
|
|
572
|
-
[arrangement]
|
|
587
|
+
[arrangement, dragGuard, endGuard]
|
|
573
588
|
);
|
|
574
589
|
const onDragMove = React.useCallback(
|
|
575
590
|
(event) => {
|
|
@@ -621,6 +636,7 @@ function useClipDragHandlers({
|
|
|
621
636
|
var _a, _b;
|
|
622
637
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
623
638
|
if ((data == null ? void 0 : data.kind) === "track-reorder") return;
|
|
639
|
+
endGuard();
|
|
624
640
|
const drag = trimDragRef.current;
|
|
625
641
|
const move = moveDragRef.current;
|
|
626
642
|
const delta = lastBoundaryDeltaRef.current;
|
|
@@ -653,7 +669,7 @@ function useClipDragHandlers({
|
|
|
653
669
|
arrangement.moveClip(track.id, clipId, Math.floor(sampleDelta));
|
|
654
670
|
}
|
|
655
671
|
},
|
|
656
|
-
[samplesPerPixel, arrangement, preview, commitTrim]
|
|
672
|
+
[samplesPerPixel, arrangement, preview, commitTrim, endGuard]
|
|
657
673
|
);
|
|
658
674
|
return {
|
|
659
675
|
onDragStart,
|
|
@@ -666,11 +682,24 @@ function useClipDragHandlers({
|
|
|
666
682
|
import React2 from "react";
|
|
667
683
|
import { flushSync } from "react-dom";
|
|
668
684
|
import {
|
|
685
|
+
applyAnnotationBounds,
|
|
669
686
|
updateAnnotationBoundaries
|
|
670
687
|
} from "@waveform-playlist/core";
|
|
688
|
+
function touchedChanges(drag) {
|
|
689
|
+
return [...drag.touched.values()];
|
|
690
|
+
}
|
|
691
|
+
function snapshotBounds(drag) {
|
|
692
|
+
const before = new Map(drag.snapshot.map((a) => [a.id, a]));
|
|
693
|
+
return [...drag.touched.keys()].flatMap((id) => {
|
|
694
|
+
const old = before.get(id);
|
|
695
|
+
return old ? [{ id, start: old.start, end: old.end }] : [];
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
function shownDuringDrag(drag) {
|
|
699
|
+
return applyAnnotationBounds(drag.store.getAnnotations(), touchedChanges(drag));
|
|
700
|
+
}
|
|
671
701
|
function useAnnotationDragHandlers({
|
|
672
|
-
|
|
673
|
-
onAnnotationsChange,
|
|
702
|
+
store,
|
|
674
703
|
samplesPerPixel,
|
|
675
704
|
// Default mirrors the engine default; the providers always pass the real rate from context (#510).
|
|
676
705
|
sampleRate = 48e3,
|
|
@@ -679,81 +708,132 @@ function useAnnotationDragHandlers({
|
|
|
679
708
|
preview
|
|
680
709
|
}) {
|
|
681
710
|
const dragRef = React2.useRef(null);
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
const
|
|
685
|
-
|
|
711
|
+
const storeRef = React2.useRef(store);
|
|
712
|
+
storeRef.current = store;
|
|
713
|
+
const previewRef = React2.useRef(preview);
|
|
714
|
+
previewRef.current = preview;
|
|
715
|
+
const abandon = React2.useCallback(() => {
|
|
716
|
+
var _a;
|
|
717
|
+
if (!dragRef.current) return;
|
|
718
|
+
dragRef.current = null;
|
|
719
|
+
(_a = previewRef.current) == null ? void 0 : _a.publish(null);
|
|
720
|
+
}, []);
|
|
686
721
|
React2.useEffect(() => {
|
|
687
|
-
if (!
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
722
|
+
if (!store) return;
|
|
723
|
+
const unsubscribe = store.subscribe(() => {
|
|
724
|
+
const drag = dragRef.current;
|
|
725
|
+
if (!drag || drag.store !== store) return;
|
|
726
|
+
if (!store.getAnnotations().some((a) => a.id === drag.draggedId)) {
|
|
727
|
+
abandon();
|
|
728
|
+
return;
|
|
692
729
|
}
|
|
730
|
+
const shown = previewRef.current;
|
|
731
|
+
if (shown && shown.source.getSnapshot() !== null) {
|
|
732
|
+
shown.publish(shownDuringDrag(drag));
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
return () => {
|
|
736
|
+
unsubscribe();
|
|
737
|
+
abandon();
|
|
693
738
|
};
|
|
694
|
-
}, [
|
|
739
|
+
}, [store, abandon]);
|
|
740
|
+
React2.useEffect(() => abandon, [preview, abandon]);
|
|
695
741
|
const onDragStart = React2.useCallback((event) => {
|
|
696
742
|
var _a;
|
|
697
743
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
744
|
+
const owner = storeRef.current;
|
|
745
|
+
if (!owner || !data) {
|
|
746
|
+
dragRef.current = null;
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const snapshot = owner.getAnnotations();
|
|
750
|
+
const annotation = data.annotationIndex === void 0 ? void 0 : snapshot[data.annotationIndex];
|
|
751
|
+
dragRef.current = annotation ? {
|
|
752
|
+
store: owner,
|
|
701
753
|
snapshot,
|
|
754
|
+
touched: /* @__PURE__ */ new Map(),
|
|
755
|
+
draggedId: annotation.id,
|
|
756
|
+
edge: data.edge,
|
|
702
757
|
start: annotation.start,
|
|
703
|
-
end: annotation.end
|
|
704
|
-
annotationIndex: data.annotationIndex
|
|
758
|
+
end: annotation.end
|
|
705
759
|
} : null;
|
|
706
760
|
}, []);
|
|
707
761
|
const onDragMove = React2.useCallback(
|
|
708
762
|
(event) => {
|
|
709
|
-
var _a, _b
|
|
763
|
+
var _a, _b;
|
|
710
764
|
const drag = dragRef.current;
|
|
711
|
-
if (!drag)
|
|
765
|
+
if (!drag) return;
|
|
766
|
+
if (drag.store !== storeRef.current) {
|
|
767
|
+
abandon();
|
|
712
768
|
return;
|
|
713
769
|
}
|
|
714
|
-
const
|
|
715
|
-
if (!data) return;
|
|
716
|
-
const { edge, annotationIndex } = data;
|
|
717
|
-
const currentX = (_c = (_b = event.to) == null ? void 0 : _b.x) != null ? _c : event.operation.position.current.x;
|
|
770
|
+
const currentX = (_b = (_a = event.to) == null ? void 0 : _a.x) != null ? _b : event.operation.position.current.x;
|
|
718
771
|
const rawDeltaX = currentX - event.operation.position.initial.x;
|
|
719
772
|
const timeDelta = rawDeltaX * samplesPerPixel / sampleRate;
|
|
720
|
-
const newTime = edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
721
|
-
const
|
|
773
|
+
const newTime = drag.edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
774
|
+
const base = shownDuringDrag(drag);
|
|
775
|
+
const annotationIndex = base.findIndex((a) => a.id === drag.draggedId);
|
|
776
|
+
if (annotationIndex < 0) {
|
|
777
|
+
abandon();
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const updated = updateAnnotationBoundaries({
|
|
722
781
|
annotationIndex,
|
|
723
782
|
newTime,
|
|
724
|
-
isDraggingStart: edge === "start",
|
|
725
|
-
annotations:
|
|
783
|
+
isDraggingStart: drag.edge === "start",
|
|
784
|
+
annotations: base,
|
|
726
785
|
duration,
|
|
727
786
|
linkEndpoints
|
|
728
787
|
});
|
|
788
|
+
updated.forEach((annotation, i) => {
|
|
789
|
+
const was = base[i];
|
|
790
|
+
if (drag.touched.has(annotation.id) || was.start !== annotation.start || was.end !== annotation.end) {
|
|
791
|
+
drag.touched.set(annotation.id, {
|
|
792
|
+
id: annotation.id,
|
|
793
|
+
start: annotation.start,
|
|
794
|
+
end: annotation.end
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
});
|
|
729
798
|
if (preview) {
|
|
730
|
-
preview.publish(
|
|
799
|
+
preview.publish(updated);
|
|
731
800
|
} else {
|
|
732
|
-
|
|
801
|
+
const changes = touchedChanges(drag);
|
|
802
|
+
drag.store.update((current) => applyAnnotationBounds(current, changes));
|
|
733
803
|
}
|
|
734
804
|
},
|
|
735
|
-
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview]
|
|
805
|
+
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview, abandon]
|
|
736
806
|
);
|
|
737
807
|
const onDragEnd = React2.useCallback(
|
|
738
808
|
(event) => {
|
|
739
809
|
const drag = dragRef.current;
|
|
740
810
|
dragRef.current = null;
|
|
741
811
|
if (!drag) return;
|
|
812
|
+
if (drag.store !== storeRef.current) {
|
|
813
|
+
preview == null ? void 0 : preview.publish(null);
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
742
816
|
if (!preview) {
|
|
743
|
-
if (event.canceled
|
|
744
|
-
|
|
817
|
+
if (event.canceled) {
|
|
818
|
+
const restore = snapshotBounds(drag);
|
|
819
|
+
drag.store.update((current) => applyAnnotationBounds(current, restore));
|
|
745
820
|
}
|
|
746
821
|
return;
|
|
747
822
|
}
|
|
748
|
-
|
|
749
|
-
if (result === null) return;
|
|
823
|
+
if (preview.source.getSnapshot() === null) return;
|
|
750
824
|
if (event.canceled) {
|
|
751
825
|
preview.publish(null);
|
|
752
826
|
return;
|
|
753
827
|
}
|
|
754
828
|
flushSync(() => {
|
|
755
|
-
|
|
756
|
-
|
|
829
|
+
try {
|
|
830
|
+
const changes = touchedChanges(drag);
|
|
831
|
+
drag.store.update(
|
|
832
|
+
(current) => current.some((a) => a.id === drag.draggedId) ? applyAnnotationBounds(current, changes) : current
|
|
833
|
+
);
|
|
834
|
+
} finally {
|
|
835
|
+
preview.publish(null);
|
|
836
|
+
}
|
|
757
837
|
});
|
|
758
838
|
},
|
|
759
839
|
[preview]
|
|
@@ -867,29 +947,28 @@ var useClipSplitting = (options) => {
|
|
|
867
947
|
};
|
|
868
948
|
|
|
869
949
|
// src/hooks/useKeyboardShortcuts.ts
|
|
870
|
-
import {
|
|
950
|
+
import { useLayoutEffect, useRef as useRef6 } from "react";
|
|
871
951
|
import { handleKeyboardEvent } from "@waveform-playlist/core";
|
|
872
952
|
var useKeyboardShortcuts = (options) => {
|
|
873
953
|
const { shortcuts, enabled = true } = options;
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
|
|
954
|
+
const latest = useRef6({ shortcuts, enabled });
|
|
955
|
+
useLayoutEffect(() => {
|
|
956
|
+
latest.current = { shortcuts, enabled };
|
|
877
957
|
});
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const handleKeyDown = (event) => handleKeyboardEvent(event, shortcutsRef.current, true);
|
|
958
|
+
useLayoutEffect(() => {
|
|
959
|
+
const handleKeyDown = (event) => handleKeyboardEvent(event, latest.current.shortcuts, latest.current.enabled);
|
|
881
960
|
window.addEventListener("keydown", handleKeyDown);
|
|
882
961
|
return () => {
|
|
883
962
|
window.removeEventListener("keydown", handleKeyDown);
|
|
884
963
|
};
|
|
885
|
-
}, [
|
|
964
|
+
}, []);
|
|
886
965
|
};
|
|
887
966
|
|
|
888
967
|
// src/hooks/usePlaybackShortcuts.ts
|
|
889
968
|
import { useCallback as useCallback9 } from "react";
|
|
890
969
|
|
|
891
970
|
// src/hooks/usePlayFromSelectionOrCursor.ts
|
|
892
|
-
import { useCallback as useCallback8,
|
|
971
|
+
import { useCallback as useCallback8, useLayoutEffect as useLayoutEffect2, useRef as useRef7 } from "react";
|
|
893
972
|
function usePlayFromSelectionOrCursor() {
|
|
894
973
|
var _a, _b;
|
|
895
974
|
const { currentTimeRef } = usePlaybackRefs();
|
|
@@ -897,7 +976,7 @@ function usePlayFromSelectionOrCursor() {
|
|
|
897
976
|
const isLoopEnabled = (_b = (_a = useLoopOptional()) == null ? void 0 : _a.isLoopEnabled) != null ? _b : false;
|
|
898
977
|
const { play } = usePlaybackControls();
|
|
899
978
|
const latest = useRef7({ selectionStart, selectionEnd, isLoopEnabled });
|
|
900
|
-
|
|
979
|
+
useLayoutEffect2(() => {
|
|
901
980
|
latest.current = { selectionStart, selectionEnd, isLoopEnabled };
|
|
902
981
|
});
|
|
903
982
|
return useCallback8(() => __async(null, null, function* () {
|
|
@@ -969,13 +1048,95 @@ var usePlaybackShortcuts = (options = {}) => {
|
|
|
969
1048
|
};
|
|
970
1049
|
|
|
971
1050
|
// src/hooks/useAnnotationKeyboardControls.ts
|
|
972
|
-
import { useCallback as useCallback10, useMemo as useMemo2, useEffect as
|
|
1051
|
+
import { useCallback as useCallback10, useMemo as useMemo2, useEffect, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
1052
|
+
|
|
1053
|
+
// src/utils/annotationBoundaryKeys.ts
|
|
973
1054
|
var LINK_THRESHOLD = 0.01;
|
|
1055
|
+
var MIN_LENGTH = 0.1;
|
|
1056
|
+
function unlessUnchanged(list, updated) {
|
|
1057
|
+
const same = updated.every((a, i) => a.start === list[i].start && a.end === list[i].end);
|
|
1058
|
+
return same ? list : updated;
|
|
1059
|
+
}
|
|
1060
|
+
function moveAnnotationStart(list, index, delta, { linkEndpoints }) {
|
|
1061
|
+
const annotation = list[index];
|
|
1062
|
+
const newStart = Math.max(0, Math.min(annotation.end - MIN_LENGTH, annotation.start + delta));
|
|
1063
|
+
const actualDelta = newStart - annotation.start;
|
|
1064
|
+
const updated = [...list];
|
|
1065
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { start: newStart });
|
|
1066
|
+
if (linkEndpoints && index > 0) {
|
|
1067
|
+
const prev = updated[index - 1];
|
|
1068
|
+
if (Math.abs(prev.end - annotation.start) < LINK_THRESHOLD) {
|
|
1069
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), {
|
|
1070
|
+
end: Math.max(prev.start + MIN_LENGTH, prev.end + actualDelta)
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
} else if (!linkEndpoints && index > 0) {
|
|
1074
|
+
const prev = updated[index - 1];
|
|
1075
|
+
if (newStart < prev.end) {
|
|
1076
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), { end: newStart });
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
return unlessUnchanged(list, updated);
|
|
1080
|
+
}
|
|
1081
|
+
function moveAnnotationEnd(list, index, delta, { linkEndpoints, duration }) {
|
|
1082
|
+
const annotation = list[index];
|
|
1083
|
+
const newEnd = Math.max(
|
|
1084
|
+
annotation.start + MIN_LENGTH,
|
|
1085
|
+
Math.min(duration, annotation.end + delta)
|
|
1086
|
+
);
|
|
1087
|
+
const actualDelta = newEnd - annotation.end;
|
|
1088
|
+
const updated = [...list];
|
|
1089
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { end: newEnd });
|
|
1090
|
+
if (linkEndpoints && index < list.length - 1) {
|
|
1091
|
+
const next = updated[index + 1];
|
|
1092
|
+
if (Math.abs(next.start - annotation.end) < LINK_THRESHOLD) {
|
|
1093
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1094
|
+
start: Math.min(next.end - MIN_LENGTH, next.start + actualDelta)
|
|
1095
|
+
});
|
|
1096
|
+
let current = index + 1;
|
|
1097
|
+
while (current < updated.length - 1) {
|
|
1098
|
+
const moved = updated[current];
|
|
1099
|
+
const following = updated[current + 1];
|
|
1100
|
+
if (Math.abs(following.start - list[current].end) < LINK_THRESHOLD) {
|
|
1101
|
+
const nextDelta = moved.end - list[current].end;
|
|
1102
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), {
|
|
1103
|
+
start: Math.min(following.end - MIN_LENGTH, following.start + nextDelta)
|
|
1104
|
+
});
|
|
1105
|
+
current++;
|
|
1106
|
+
} else {
|
|
1107
|
+
break;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
} else if (!linkEndpoints && index < list.length - 1) {
|
|
1112
|
+
const next = updated[index + 1];
|
|
1113
|
+
if (newEnd > next.start) {
|
|
1114
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), { start: newEnd });
|
|
1115
|
+
let current = index + 1;
|
|
1116
|
+
while (current < updated.length - 1) {
|
|
1117
|
+
const pushed = updated[current];
|
|
1118
|
+
const following = updated[current + 1];
|
|
1119
|
+
if (pushed.end > following.start) {
|
|
1120
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), { start: pushed.end });
|
|
1121
|
+
current++;
|
|
1122
|
+
} else {
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return unlessUnchanged(list, updated);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// src/hooks/useAnnotationKeyboardControls.ts
|
|
974
1132
|
var TIME_DELTA = 0.01;
|
|
1133
|
+
var NO_ANNOTATIONS = Object.freeze([]);
|
|
1134
|
+
var noSubscription = () => () => {
|
|
1135
|
+
};
|
|
1136
|
+
var noAnnotations = () => NO_ANNOTATIONS;
|
|
975
1137
|
function useAnnotationKeyboardControls({
|
|
976
|
-
|
|
1138
|
+
store,
|
|
977
1139
|
activeAnnotationId,
|
|
978
|
-
onAnnotationsChange,
|
|
979
1140
|
onActiveAnnotationChange,
|
|
980
1141
|
duration,
|
|
981
1142
|
linkEndpoints,
|
|
@@ -986,6 +1147,15 @@ function useAnnotationKeyboardControls({
|
|
|
986
1147
|
samplesPerPixel: samplesPerPixelProp,
|
|
987
1148
|
sampleRate: sampleRateProp
|
|
988
1149
|
}) {
|
|
1150
|
+
const source = useMemo2(
|
|
1151
|
+
() => store ? {
|
|
1152
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1153
|
+
getSnapshot: () => store.getAnnotations()
|
|
1154
|
+
} : { subscribe: noSubscription, getSnapshot: noAnnotations },
|
|
1155
|
+
[store]
|
|
1156
|
+
);
|
|
1157
|
+
const stored = useSyncExternalStore2(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1158
|
+
const annotations = stored;
|
|
989
1159
|
const playlistView = usePlaylistViewOptional();
|
|
990
1160
|
const playlistZoom = usePlaylistZoomOptional();
|
|
991
1161
|
const samplesPerPixel = samplesPerPixelProp != null ? samplesPerPixelProp : playlistZoom == null ? void 0 : playlistZoom.samplesPerPixel;
|
|
@@ -1017,99 +1187,28 @@ function useAnnotationKeyboardControls({
|
|
|
1017
1187
|
},
|
|
1018
1188
|
[annotations, scrollContainerRef, samplesPerPixel, sampleRate]
|
|
1019
1189
|
);
|
|
1020
|
-
|
|
1190
|
+
useEffect(() => {
|
|
1021
1191
|
if (activeAnnotationId && (scrollContainerRef == null ? void 0 : scrollContainerRef.current) && samplesPerPixel && sampleRate) {
|
|
1022
1192
|
scrollToAnnotation(activeAnnotationId);
|
|
1023
1193
|
}
|
|
1024
1194
|
}, [activeAnnotationId, scrollToAnnotation, scrollContainerRef, samplesPerPixel, sampleRate]);
|
|
1025
1195
|
const moveStartBoundary = useCallback10(
|
|
1026
1196
|
(delta) => {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
const actualDelta = newStart - annotation.start;
|
|
1031
|
-
const updatedAnnotations = [...annotations];
|
|
1032
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1033
|
-
start: newStart
|
|
1197
|
+
store == null ? void 0 : store.update((current) => {
|
|
1198
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1199
|
+
return index < 0 ? current : moveAnnotationStart(current, index, delta, { linkEndpoints });
|
|
1034
1200
|
});
|
|
1035
|
-
if (linkEndpoints && activeIndex > 0) {
|
|
1036
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1037
|
-
if (Math.abs(prevAnnotation.end - annotation.start) < LINK_THRESHOLD) {
|
|
1038
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1039
|
-
end: Math.max(prevAnnotation.start + 0.1, prevAnnotation.end + actualDelta)
|
|
1040
|
-
});
|
|
1041
|
-
}
|
|
1042
|
-
} else if (!linkEndpoints && activeIndex > 0) {
|
|
1043
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1044
|
-
if (newStart < prevAnnotation.end) {
|
|
1045
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1046
|
-
end: newStart
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1051
1201
|
},
|
|
1052
|
-
[
|
|
1202
|
+
[store, activeAnnotationId, linkEndpoints]
|
|
1053
1203
|
);
|
|
1054
1204
|
const moveEndBoundary = useCallback10(
|
|
1055
1205
|
(delta) => {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
const actualDelta = newEnd - annotation.end;
|
|
1060
|
-
const updatedAnnotations = [...annotations];
|
|
1061
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1062
|
-
end: newEnd
|
|
1206
|
+
store == null ? void 0 : store.update((current) => {
|
|
1207
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1208
|
+
return index < 0 ? current : moveAnnotationEnd(current, index, delta, { linkEndpoints, duration });
|
|
1063
1209
|
});
|
|
1064
|
-
if (linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1065
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1066
|
-
if (Math.abs(nextAnnotation.start - annotation.end) < LINK_THRESHOLD) {
|
|
1067
|
-
const newNextStart = Math.min(
|
|
1068
|
-
nextAnnotation.end - 0.1,
|
|
1069
|
-
nextAnnotation.start + actualDelta
|
|
1070
|
-
);
|
|
1071
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1072
|
-
start: newNextStart
|
|
1073
|
-
});
|
|
1074
|
-
let currentIndex = activeIndex + 1;
|
|
1075
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1076
|
-
const current = updatedAnnotations[currentIndex];
|
|
1077
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1078
|
-
if (Math.abs(next.start - annotations[currentIndex].end) < LINK_THRESHOLD) {
|
|
1079
|
-
const nextDelta = current.end - annotations[currentIndex].end;
|
|
1080
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1081
|
-
start: Math.min(next.end - 0.1, next.start + nextDelta)
|
|
1082
|
-
});
|
|
1083
|
-
currentIndex++;
|
|
1084
|
-
} else {
|
|
1085
|
-
break;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
} else if (!linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1090
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1091
|
-
if (newEnd > nextAnnotation.start) {
|
|
1092
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1093
|
-
start: newEnd
|
|
1094
|
-
});
|
|
1095
|
-
let currentIndex = activeIndex + 1;
|
|
1096
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1097
|
-
const current = updatedAnnotations[currentIndex];
|
|
1098
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1099
|
-
if (current.end > next.start) {
|
|
1100
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1101
|
-
start: current.end
|
|
1102
|
-
});
|
|
1103
|
-
currentIndex++;
|
|
1104
|
-
} else {
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1111
1210
|
},
|
|
1112
|
-
[
|
|
1211
|
+
[store, activeAnnotationId, duration, linkEndpoints]
|
|
1113
1212
|
);
|
|
1114
1213
|
const selectPrevious = useCallback10(() => {
|
|
1115
1214
|
if (!onActiveAnnotationChange || annotations.length === 0) return;
|
|
@@ -1251,7 +1350,7 @@ function useAnnotationKeyboardControls({
|
|
|
1251
1350
|
}
|
|
1252
1351
|
|
|
1253
1352
|
// src/hooks/useAnimationFrameLoop.ts
|
|
1254
|
-
import { useCallback as useCallback11, useEffect as
|
|
1353
|
+
import { useCallback as useCallback11, useEffect as useEffect2, useRef as useRef8 } from "react";
|
|
1255
1354
|
var useAnimationFrameLoop = () => {
|
|
1256
1355
|
const animationFrameRef = useRef8(null);
|
|
1257
1356
|
const stopAnimationFrameLoop = useCallback11(() => {
|
|
@@ -1267,7 +1366,7 @@ var useAnimationFrameLoop = () => {
|
|
|
1267
1366
|
},
|
|
1268
1367
|
[stopAnimationFrameLoop]
|
|
1269
1368
|
);
|
|
1270
|
-
|
|
1369
|
+
useEffect2(() => {
|
|
1271
1370
|
return () => {
|
|
1272
1371
|
stopAnimationFrameLoop();
|
|
1273
1372
|
};
|
|
@@ -1280,7 +1379,7 @@ var useAnimationFrameLoop = () => {
|
|
|
1280
1379
|
};
|
|
1281
1380
|
|
|
1282
1381
|
// src/hooks/useWaveformDataCache.ts
|
|
1283
|
-
import { useState as useState7, useEffect as
|
|
1382
|
+
import { useState as useState7, useEffect as useEffect3, useRef as useRef9, useCallback as useCallback12 } from "react";
|
|
1284
1383
|
|
|
1285
1384
|
// src/workers/peaksWorker.ts
|
|
1286
1385
|
import WaveformData from "waveform-data";
|
|
@@ -1551,7 +1650,7 @@ function useWaveformDataCache(tracks, baseScale) {
|
|
|
1551
1650
|
(audioBuffer) => generatedByBufferRef.current.get(audioBuffer),
|
|
1552
1651
|
[]
|
|
1553
1652
|
);
|
|
1554
|
-
|
|
1653
|
+
useEffect3(() => {
|
|
1555
1654
|
const generatedByBuffer = generatedByBufferRef.current;
|
|
1556
1655
|
const inflightByBuffer = inflightByBufferRef.current;
|
|
1557
1656
|
const session = mountSessionRef.current;
|
|
@@ -1601,7 +1700,7 @@ function useWaveformDataCache(tracks, baseScale) {
|
|
|
1601
1700
|
inflightByBuffer.set(audioBuffer, job);
|
|
1602
1701
|
}
|
|
1603
1702
|
}, [tracks, baseScale, getWorker]);
|
|
1604
|
-
|
|
1703
|
+
useEffect3(() => {
|
|
1605
1704
|
return () => {
|
|
1606
1705
|
var _a;
|
|
1607
1706
|
mountSessionRef.current += 1;
|
|
@@ -1628,7 +1727,7 @@ function useCreateArrangement(init, options) {
|
|
|
1628
1727
|
}
|
|
1629
1728
|
|
|
1630
1729
|
// src/hooks/useArrangementTracks.ts
|
|
1631
|
-
import { useMemo as useMemo3, useSyncExternalStore as
|
|
1730
|
+
import { useMemo as useMemo3, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1632
1731
|
function useArrangementTracks(arrangement) {
|
|
1633
1732
|
const store = useMemo3(
|
|
1634
1733
|
() => ({
|
|
@@ -1637,11 +1736,11 @@ function useArrangementTracks(arrangement) {
|
|
|
1637
1736
|
}),
|
|
1638
1737
|
[arrangement]
|
|
1639
1738
|
);
|
|
1640
|
-
return
|
|
1739
|
+
return useSyncExternalStore3(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1641
1740
|
}
|
|
1642
1741
|
|
|
1643
1742
|
// src/hooks/useArrangementSources.ts
|
|
1644
|
-
import { useMemo as useMemo4, useSyncExternalStore as
|
|
1743
|
+
import { useMemo as useMemo4, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
1645
1744
|
function useArrangementSources(arrangement) {
|
|
1646
1745
|
const store = useMemo4(
|
|
1647
1746
|
() => ({
|
|
@@ -1650,7 +1749,37 @@ function useArrangementSources(arrangement) {
|
|
|
1650
1749
|
}),
|
|
1651
1750
|
[arrangement]
|
|
1652
1751
|
);
|
|
1653
|
-
return
|
|
1752
|
+
return useSyncExternalStore4(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/hooks/useCreateAnnotationStore.ts
|
|
1756
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef10, useState as useState9 } from "react";
|
|
1757
|
+
import { createAnnotationStore } from "@waveform-playlist/core";
|
|
1758
|
+
function useCreateAnnotationStore(init, options) {
|
|
1759
|
+
const beforeChange = options == null ? void 0 : options.beforeChange;
|
|
1760
|
+
const ruleRef = useRef10(beforeChange);
|
|
1761
|
+
useLayoutEffect3(() => {
|
|
1762
|
+
ruleRef.current = beforeChange;
|
|
1763
|
+
}, [beforeChange]);
|
|
1764
|
+
const [store] = useState9(
|
|
1765
|
+
() => createAnnotationStore(init == null ? void 0 : init(), {
|
|
1766
|
+
beforeChange: (next, current) => ruleRef.current ? ruleRef.current(next, current) : next
|
|
1767
|
+
})
|
|
1768
|
+
);
|
|
1769
|
+
return store;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// src/hooks/useStoredAnnotations.ts
|
|
1773
|
+
import { useMemo as useMemo5, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
1774
|
+
function useStoredAnnotations(store) {
|
|
1775
|
+
const source = useMemo5(
|
|
1776
|
+
() => ({
|
|
1777
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1778
|
+
getSnapshot: () => store.getAnnotations()
|
|
1779
|
+
}),
|
|
1780
|
+
[store]
|
|
1781
|
+
);
|
|
1782
|
+
return useSyncExternalStore5(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1654
1783
|
}
|
|
1655
1784
|
|
|
1656
1785
|
// src/providerInternals/followAnnotations.ts
|
|
@@ -1683,7 +1812,7 @@ function followAnnotations({
|
|
|
1683
1812
|
}
|
|
1684
1813
|
|
|
1685
1814
|
// src/providerInternals/useAnnotationState.ts
|
|
1686
|
-
import { useCallback as useCallback13, useMemo as
|
|
1815
|
+
import { useCallback as useCallback13, useMemo as useMemo6, useRef as useRef11, useState as useState10, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1687
1816
|
import { createValueSource } from "@waveform-playlist/core";
|
|
1688
1817
|
|
|
1689
1818
|
// src/utils/annotationLookup.ts
|
|
@@ -1739,20 +1868,11 @@ function createAnnotationLookup() {
|
|
|
1739
1868
|
};
|
|
1740
1869
|
}
|
|
1741
1870
|
|
|
1742
|
-
// src/utils/isDevelopmentBuild.ts
|
|
1743
|
-
function isDevelopmentBuild() {
|
|
1744
|
-
try {
|
|
1745
|
-
return process.env.NODE_ENV !== "production";
|
|
1746
|
-
} catch (e) {
|
|
1747
|
-
return false;
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1871
|
// src/providerInternals/useAnnotationState.ts
|
|
1752
1872
|
function useFollowedOption(prop) {
|
|
1753
1873
|
const wanted = prop != null ? prop : false;
|
|
1754
|
-
const [value, setValue] =
|
|
1755
|
-
const [seen, setSeen] =
|
|
1874
|
+
const [value, setValue] = useState10(wanted);
|
|
1875
|
+
const [seen, setSeen] = useState10(wanted);
|
|
1756
1876
|
if (seen !== wanted) {
|
|
1757
1877
|
setSeen(wanted);
|
|
1758
1878
|
setValue(wanted);
|
|
@@ -1760,29 +1880,35 @@ function useFollowedOption(prop) {
|
|
|
1760
1880
|
}
|
|
1761
1881
|
return [value, setValue];
|
|
1762
1882
|
}
|
|
1883
|
+
var NO_ANNOTATIONS2 = Object.freeze([]);
|
|
1884
|
+
var noSubscription2 = () => () => {
|
|
1885
|
+
};
|
|
1886
|
+
var noAnnotations2 = () => NO_ANNOTATIONS2;
|
|
1763
1887
|
function useAnnotationState({
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
providerName
|
|
1888
|
+
annotationStore,
|
|
1889
|
+
annotationList
|
|
1767
1890
|
}) {
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1891
|
+
const source = useMemo6(
|
|
1892
|
+
() => annotationStore ? {
|
|
1893
|
+
subscribe: (listener) => annotationStore.subscribe(listener),
|
|
1894
|
+
getSnapshot: () => annotationStore.getAnnotations()
|
|
1895
|
+
} : { subscribe: noSubscription2, getSnapshot: noAnnotations2 },
|
|
1896
|
+
[annotationStore]
|
|
1897
|
+
);
|
|
1898
|
+
const annotations = useSyncExternalStore6(
|
|
1899
|
+
source.subscribe,
|
|
1900
|
+
source.getSnapshot,
|
|
1901
|
+
source.getSnapshot
|
|
1902
|
+
);
|
|
1903
|
+
const storeRef = useRef11(annotationStore);
|
|
1904
|
+
storeRef.current = annotationStore;
|
|
1905
|
+
const getAnnotations = useCallback13(
|
|
1906
|
+
() => storeRef.current ? storeRef.current.getAnnotations() : NO_ANNOTATIONS2,
|
|
1907
|
+
[]
|
|
1908
|
+
);
|
|
1909
|
+
const [annotationLookup] = useState10(() => createAnnotationLookup());
|
|
1910
|
+
const [activeAnnotationId, setActiveAnnotationIdState] = useState10(null);
|
|
1911
|
+
const activeAnnotationIdRef = useRef11(null);
|
|
1786
1912
|
const setActiveAnnotationId = useCallback13((value) => {
|
|
1787
1913
|
activeAnnotationIdRef.current = value;
|
|
1788
1914
|
setActiveAnnotationIdState(value);
|
|
@@ -1790,7 +1916,7 @@ function useAnnotationState({
|
|
|
1790
1916
|
const [continuousPlay, setContinuousPlayState] = useFollowedOption(
|
|
1791
1917
|
annotationList == null ? void 0 : annotationList.isContinuousPlay
|
|
1792
1918
|
);
|
|
1793
|
-
const continuousPlayRef =
|
|
1919
|
+
const continuousPlayRef = useRef11(continuousPlay);
|
|
1794
1920
|
continuousPlayRef.current = continuousPlay;
|
|
1795
1921
|
const setContinuousPlay = useCallback13(
|
|
1796
1922
|
(value) => {
|
|
@@ -1801,36 +1927,18 @@ function useAnnotationState({
|
|
|
1801
1927
|
);
|
|
1802
1928
|
const [editable, setAnnotationsEditable] = useFollowedOption(annotationList == null ? void 0 : annotationList.editable);
|
|
1803
1929
|
const [linkEndpoints, setLinkEndpoints] = useFollowedOption(annotationList == null ? void 0 : annotationList.linkEndpoints);
|
|
1804
|
-
const annotationsValue =
|
|
1805
|
-
const annotationOptionsValue =
|
|
1930
|
+
const annotationsValue = useMemo6(() => ({ annotations }), [annotations]);
|
|
1931
|
+
const annotationOptionsValue = useMemo6(
|
|
1806
1932
|
() => ({ editable, linkEndpoints, continuousPlay }),
|
|
1807
1933
|
[editable, linkEndpoints, continuousPlay]
|
|
1808
1934
|
);
|
|
1809
|
-
const [annotationPreview] =
|
|
1935
|
+
const [annotationPreview] = useState10(
|
|
1810
1936
|
() => createValueSource(null)
|
|
1811
1937
|
);
|
|
1812
|
-
const onAnnotationsChangeRef = useRef10(onAnnotationsChange);
|
|
1813
|
-
onAnnotationsChangeRef.current = onAnnotationsChange;
|
|
1814
|
-
const setAnnotations = useCallback13(
|
|
1815
|
-
(action) => {
|
|
1816
|
-
const updated = typeof action === "function" ? action(annotationsRef.current) : action;
|
|
1817
|
-
if (!onAnnotationsChangeRef.current) {
|
|
1818
|
-
if (isDevelopmentBuild()) {
|
|
1819
|
-
console.warn(
|
|
1820
|
-
"waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to " + providerName + " to handle annotation updates."
|
|
1821
|
-
);
|
|
1822
|
-
}
|
|
1823
|
-
return;
|
|
1824
|
-
}
|
|
1825
|
-
onAnnotationsChangeRef.current(updated);
|
|
1826
|
-
},
|
|
1827
|
-
[providerName]
|
|
1828
|
-
);
|
|
1829
1938
|
return {
|
|
1830
1939
|
annotations,
|
|
1831
|
-
|
|
1940
|
+
getAnnotations,
|
|
1832
1941
|
annotationLookup,
|
|
1833
|
-
setAnnotations,
|
|
1834
1942
|
annotationPreview,
|
|
1835
1943
|
activeAnnotationId,
|
|
1836
1944
|
activeAnnotationIdRef,
|
|
@@ -1846,9 +1954,9 @@ function useAnnotationState({
|
|
|
1846
1954
|
}
|
|
1847
1955
|
|
|
1848
1956
|
// src/providerInternals/useFrameCallbacks.ts
|
|
1849
|
-
import { useCallback as useCallback14, useRef as
|
|
1957
|
+
import { useCallback as useCallback14, useRef as useRef12 } from "react";
|
|
1850
1958
|
function useFrameCallbacks() {
|
|
1851
|
-
const callbacksRef =
|
|
1959
|
+
const callbacksRef = useRef12(/* @__PURE__ */ new Map());
|
|
1852
1960
|
const registerFrameCallback = useCallback14((id, cb) => {
|
|
1853
1961
|
callbacksRef.current.set(id, cb);
|
|
1854
1962
|
}, []);
|
|
@@ -1864,15 +1972,15 @@ function useFrameCallbacks() {
|
|
|
1864
1972
|
}
|
|
1865
1973
|
|
|
1866
1974
|
// src/providerInternals/useScrollFollow.ts
|
|
1867
|
-
import { useCallback as useCallback15, useRef as
|
|
1975
|
+
import { useCallback as useCallback15, useRef as useRef13, useState as useState11 } from "react";
|
|
1868
1976
|
function centrePlayhead(container, time, sampleRate, samplesPerPixel) {
|
|
1869
1977
|
const pixelPosition = time * sampleRate / samplesPerPixel;
|
|
1870
1978
|
container.scrollLeft = Math.round(Math.max(0, pixelPosition - container.clientWidth / 2));
|
|
1871
1979
|
}
|
|
1872
1980
|
function useScrollFollow(initialAutomaticScroll) {
|
|
1873
|
-
const scrollContainerRef =
|
|
1874
|
-
const [isAutomaticScroll, setIsAutomaticScroll] =
|
|
1875
|
-
const isAutomaticScrollRef =
|
|
1981
|
+
const scrollContainerRef = useRef13(null);
|
|
1982
|
+
const [isAutomaticScroll, setIsAutomaticScroll] = useState11(initialAutomaticScroll);
|
|
1983
|
+
const isAutomaticScrollRef = useRef13(initialAutomaticScroll);
|
|
1876
1984
|
const setScrollContainer = useCallback15((element) => {
|
|
1877
1985
|
scrollContainerRef.current = element;
|
|
1878
1986
|
}, []);
|
|
@@ -1890,11 +1998,11 @@ function useScrollFollow(initialAutomaticScroll) {
|
|
|
1890
1998
|
}
|
|
1891
1999
|
|
|
1892
2000
|
// src/providerInternals/useMergedTheme.ts
|
|
1893
|
-
import { useMemo as
|
|
2001
|
+
import { useMemo as useMemo7 } from "react";
|
|
1894
2002
|
import { defaultTheme } from "@waveform-playlist/ui-components";
|
|
1895
2003
|
|
|
1896
2004
|
// src/hooks/useShallowStable.ts
|
|
1897
|
-
import { useRef as
|
|
2005
|
+
import { useRef as useRef14 } from "react";
|
|
1898
2006
|
function shallowEqual(a, b) {
|
|
1899
2007
|
if (a === b) return true;
|
|
1900
2008
|
const aKeys = Object.keys(a);
|
|
@@ -1907,7 +2015,7 @@ function shallowEqual(a, b) {
|
|
|
1907
2015
|
);
|
|
1908
2016
|
}
|
|
1909
2017
|
function useShallowStable(value) {
|
|
1910
|
-
const ref =
|
|
2018
|
+
const ref = useRef14(value);
|
|
1911
2019
|
const previous = ref.current;
|
|
1912
2020
|
if (previous !== value) {
|
|
1913
2021
|
if (previous === void 0 || value === void 0 || !shallowEqual(previous, value)) {
|
|
@@ -1920,11 +2028,11 @@ function useShallowStable(value) {
|
|
|
1920
2028
|
// src/providerInternals/useMergedTheme.ts
|
|
1921
2029
|
function useMergedTheme(themeProp) {
|
|
1922
2030
|
const userTheme = useShallowStable(themeProp);
|
|
1923
|
-
return
|
|
2031
|
+
return useMemo7(() => __spreadValues(__spreadValues({}, defaultTheme), userTheme), [userTheme]);
|
|
1924
2032
|
}
|
|
1925
2033
|
|
|
1926
2034
|
// src/providerInternals/useTrimPreview.ts
|
|
1927
|
-
import { useRef as
|
|
2035
|
+
import { useRef as useRef15, useState as useState12 } from "react";
|
|
1928
2036
|
import { createValueSource as createValueSource2 } from "@waveform-playlist/core";
|
|
1929
2037
|
|
|
1930
2038
|
// src/waveformDataLoader.ts
|
|
@@ -2223,26 +2331,38 @@ function previewedClipPeaks(preview, { tracks, peaksOptions, peaksCacheRef }) {
|
|
|
2223
2331
|
return clipPeaksFor(previewed, track.name, peaksOptions, previous).clipPeaks;
|
|
2224
2332
|
}
|
|
2225
2333
|
function useTrimPreview(inputs) {
|
|
2226
|
-
const [trimPreview] =
|
|
2334
|
+
const [trimPreview] = useState12(
|
|
2227
2335
|
() => createValueSource2(null)
|
|
2228
2336
|
);
|
|
2229
|
-
const inputsRef =
|
|
2337
|
+
const inputsRef = useRef15(inputs);
|
|
2230
2338
|
inputsRef.current = inputs;
|
|
2231
|
-
const [trimPreviewPeaks] =
|
|
2339
|
+
const [trimPreviewPeaks] = useState12(() => ({
|
|
2232
2340
|
peaksFor: (preview) => previewedClipPeaks(preview, inputsRef.current)
|
|
2233
2341
|
}));
|
|
2234
2342
|
return { trimPreview, trimPreviewPeaks };
|
|
2235
2343
|
}
|
|
2236
2344
|
|
|
2237
2345
|
// src/providerInternals/useEngineLifetime.ts
|
|
2238
|
-
import { useCallback as useCallback16, useEffect as
|
|
2346
|
+
import { useCallback as useCallback16, useEffect as useEffect4, useLayoutEffect as useLayoutEffect4, useMemo as useMemo8, useRef as useRef16, useState as useState13 } from "react";
|
|
2239
2347
|
import {
|
|
2240
2348
|
attachDecodeContext,
|
|
2241
2349
|
PlaylistEngine
|
|
2242
2350
|
} from "@waveform-playlist/engine";
|
|
2243
2351
|
|
|
2352
|
+
// src/utils/installCommand.ts
|
|
2353
|
+
var BUILT_SPECS = typeof define_INSTALL_SPECS_default === "undefined" ? {} : define_INSTALL_SPECS_default;
|
|
2354
|
+
function formatInstallCommand(specs, names) {
|
|
2355
|
+
return "npm install " + names.map((name) => {
|
|
2356
|
+
var _a;
|
|
2357
|
+
return `"${(_a = specs[name]) != null ? _a : name}"`;
|
|
2358
|
+
}).join(" ");
|
|
2359
|
+
}
|
|
2360
|
+
function installCommand(...names) {
|
|
2361
|
+
return formatInstallCommand(BUILT_SPECS, names);
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2244
2364
|
// src/playout/resolvePlayoutAdapter.ts
|
|
2245
|
-
var
|
|
2365
|
+
var installHint = () => "@waveform-playlist/playout (and its peer `tone`) is required for the default WebAudio engine. Install with: " + installCommand("@waveform-playlist/playout", "tone") + " \u2014 or pass a custom `createAdapter`.";
|
|
2246
2366
|
function resolvePlayoutAdapter(opts) {
|
|
2247
2367
|
return __async(this, null, function* () {
|
|
2248
2368
|
if (opts.createAdapter) {
|
|
@@ -2255,7 +2375,7 @@ function resolvePlayoutAdapter(opts) {
|
|
|
2255
2375
|
console.warn(
|
|
2256
2376
|
"[waveform-playlist] @waveform-playlist/playout dynamic import failed: " + String(originalErr)
|
|
2257
2377
|
);
|
|
2258
|
-
throw new Error(
|
|
2378
|
+
throw new Error(installHint());
|
|
2259
2379
|
}
|
|
2260
2380
|
if (opts.sampleRate !== void 0) {
|
|
2261
2381
|
try {
|
|
@@ -2349,10 +2469,10 @@ function reportBuildFailure(ctx, run, engine, error) {
|
|
|
2349
2469
|
onError == null ? void 0 : onError(error instanceof Error ? error : new Error(String(error)));
|
|
2350
2470
|
}
|
|
2351
2471
|
function useKnownSampleRate(sampleRateProp) {
|
|
2352
|
-
const [sampleRate, setSampleRateState] =
|
|
2472
|
+
const [sampleRate, setSampleRateState] = useState13(
|
|
2353
2473
|
() => sampleRateProp != null ? sampleRateProp : PROVISIONAL_SAMPLE_RATE
|
|
2354
2474
|
);
|
|
2355
|
-
const [isSampleRateKnown, setIsSampleRateKnown] =
|
|
2475
|
+
const [isSampleRateKnown, setIsSampleRateKnown] = useState13(() => sampleRateProp !== void 0);
|
|
2356
2476
|
const setSampleRate = useCallback16((rate) => {
|
|
2357
2477
|
setSampleRateState(rate);
|
|
2358
2478
|
setIsSampleRateKnown(true);
|
|
@@ -2360,7 +2480,7 @@ function useKnownSampleRate(sampleRateProp) {
|
|
|
2360
2480
|
return { sampleRate, isSampleRateKnown, setSampleRate };
|
|
2361
2481
|
}
|
|
2362
2482
|
function useDecodeContext(arrangement, adapterRef) {
|
|
2363
|
-
const arrivalRef =
|
|
2483
|
+
const arrivalRef = useRef16(null);
|
|
2364
2484
|
const getDecodeContext = useCallback16(() => __async(null, null, function* () {
|
|
2365
2485
|
var _a;
|
|
2366
2486
|
const adapter = adapterRef.current;
|
|
@@ -2368,7 +2488,7 @@ function useDecodeContext(arrangement, adapterRef) {
|
|
|
2368
2488
|
(_a = arrivalRef.current) != null ? _a : arrivalRef.current = deferred();
|
|
2369
2489
|
return arrivalRef.current.promise;
|
|
2370
2490
|
}), [adapterRef]);
|
|
2371
|
-
|
|
2491
|
+
useEffect4(
|
|
2372
2492
|
() => attachDecodeContext(arrangement, getDecodeContext),
|
|
2373
2493
|
[arrangement, getDecodeContext]
|
|
2374
2494
|
);
|
|
@@ -2397,22 +2517,22 @@ function useDisposeKeepingPlayback(refs) {
|
|
|
2397
2517
|
}
|
|
2398
2518
|
function useEngineLifetime(options) {
|
|
2399
2519
|
const { arrangement, effects, zoomLevels, sampleRateProp } = options;
|
|
2400
|
-
const latest =
|
|
2401
|
-
|
|
2520
|
+
const latest = useRef16(options);
|
|
2521
|
+
useLayoutEffect4(() => {
|
|
2402
2522
|
latest.current = options;
|
|
2403
2523
|
});
|
|
2404
|
-
const stableZoomLevels =
|
|
2524
|
+
const stableZoomLevels = useMemo8(
|
|
2405
2525
|
() => zoomLevels,
|
|
2406
2526
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2407
2527
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2408
2528
|
);
|
|
2409
|
-
const engineRef =
|
|
2410
|
-
const adapterRef =
|
|
2411
|
-
const engineBuildInFlightRef =
|
|
2412
|
-
const pendingResumeRef =
|
|
2413
|
-
const audioInitializedRef =
|
|
2414
|
-
const [engineEpoch, setEngineEpoch] =
|
|
2415
|
-
const [isEngineAttached, setIsEngineAttached] =
|
|
2529
|
+
const engineRef = useRef16(null);
|
|
2530
|
+
const adapterRef = useRef16(null);
|
|
2531
|
+
const engineBuildInFlightRef = useRef16(false);
|
|
2532
|
+
const pendingResumeRef = useRef16(null);
|
|
2533
|
+
const audioInitializedRef = useRef16(false);
|
|
2534
|
+
const [engineEpoch, setEngineEpoch] = useState13(0);
|
|
2535
|
+
const [isEngineAttached, setIsEngineAttached] = useState13(false);
|
|
2416
2536
|
const bumpEngineEpoch = useCallback16(() => setEngineEpoch((epoch) => epoch + 1), []);
|
|
2417
2537
|
const { sampleRate, isSampleRateKnown, setSampleRate } = useKnownSampleRate(sampleRateProp);
|
|
2418
2538
|
const onAssigned = useDecodeContext(arrangement, adapterRef);
|
|
@@ -2422,7 +2542,7 @@ function useEngineLifetime(options) {
|
|
|
2422
2542
|
pendingResumeRef,
|
|
2423
2543
|
latest
|
|
2424
2544
|
});
|
|
2425
|
-
|
|
2545
|
+
useEffect4(() => {
|
|
2426
2546
|
const run = { cancelled: false };
|
|
2427
2547
|
engineBuildInFlightRef.current = true;
|
|
2428
2548
|
setIsEngineAttached(false);
|
|
@@ -2481,7 +2601,7 @@ function useEngineLifetime(options) {
|
|
|
2481
2601
|
}
|
|
2482
2602
|
|
|
2483
2603
|
// src/providerInternals/useArrangementView.ts
|
|
2484
|
-
import { useMemo as
|
|
2604
|
+
import { useMemo as useMemo9, useRef as useRef17, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
2485
2605
|
import { isLoadingClip as isLoadingClip2 } from "@waveform-playlist/core";
|
|
2486
2606
|
|
|
2487
2607
|
// src/utils/placeholderPeaks.ts
|
|
@@ -2603,19 +2723,20 @@ function deriveRows(tracks, inputs, previous) {
|
|
|
2603
2723
|
});
|
|
2604
2724
|
return { byTrackId, result: sameItems(previous.result, rows) ? previous.result : rows };
|
|
2605
2725
|
}
|
|
2606
|
-
function sameState(a, name, mix) {
|
|
2607
|
-
return a.name === name && a.volume === mix.volume && a.muted ===
|
|
2726
|
+
function sameState(a, name, mix, muted) {
|
|
2727
|
+
return a.name === name && a.volume === mix.volume && a.muted === muted && a.soloed === mix.soloed && a.pan === mix.pan;
|
|
2608
2728
|
}
|
|
2609
|
-
function deriveTrackStates(tracks, mixer, previous) {
|
|
2729
|
+
function deriveTrackStates(tracks, mixer, recordingTrackIds, previous) {
|
|
2610
2730
|
const byTrackId = /* @__PURE__ */ new Map();
|
|
2611
2731
|
const states = tracks.map((track) => {
|
|
2612
2732
|
var _a;
|
|
2613
2733
|
const mix = (_a = mixer.get(track.id)) != null ? _a : DEFAULT_MIX;
|
|
2734
|
+
const muted = mix.muted || recordingTrackIds.has(track.id);
|
|
2614
2735
|
const before = previous.byTrackId.get(track.id);
|
|
2615
|
-
const state = before && sameState(before, track.name, mix) ? before : {
|
|
2736
|
+
const state = before && sameState(before, track.name, mix, muted) ? before : {
|
|
2616
2737
|
name: track.name,
|
|
2617
2738
|
volume: mix.volume,
|
|
2618
|
-
muted
|
|
2739
|
+
muted,
|
|
2619
2740
|
soloed: mix.soloed,
|
|
2620
2741
|
pan: mix.pan
|
|
2621
2742
|
};
|
|
@@ -2625,55 +2746,62 @@ function deriveTrackStates(tracks, mixer, previous) {
|
|
|
2625
2746
|
return { byTrackId, result: sameItems(previous.result, states) ? previous.result : states };
|
|
2626
2747
|
}
|
|
2627
2748
|
function useArrangementValue(arrangement, read) {
|
|
2628
|
-
const store =
|
|
2749
|
+
const store = useMemo9(
|
|
2629
2750
|
() => ({
|
|
2630
2751
|
subscribe: (listener) => arrangement.subscribe(listener),
|
|
2631
2752
|
getSnapshot: () => read(arrangement)
|
|
2632
2753
|
}),
|
|
2633
2754
|
[arrangement, read]
|
|
2634
2755
|
);
|
|
2635
|
-
return
|
|
2756
|
+
return useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2636
2757
|
}
|
|
2637
2758
|
var readMixer = (arrangement) => arrangement.getMixer();
|
|
2759
|
+
var readRecordingTrackIds = (arrangement) => arrangement.recordingTrackIds;
|
|
2638
2760
|
var readCanUndo = (arrangement) => arrangement.canUndo;
|
|
2639
2761
|
var readCanRedo = (arrangement) => arrangement.canRedo;
|
|
2640
2762
|
function useArrangementView(arrangement, options) {
|
|
2641
2763
|
const { samplesPerPixel, mono, baseScale, placeholderSampleRate } = options;
|
|
2642
2764
|
const arrangementTracks = useArrangementTracks(arrangement);
|
|
2643
2765
|
const mixer = useArrangementValue(arrangement, readMixer);
|
|
2766
|
+
const recordingTrackIds = useArrangementValue(arrangement, readRecordingTrackIds);
|
|
2644
2767
|
const canUndo = useArrangementValue(arrangement, readCanUndo);
|
|
2645
2768
|
const canRedo = useArrangementValue(arrangement, readCanRedo);
|
|
2646
|
-
const loadedCacheRef =
|
|
2647
|
-
const tracks =
|
|
2769
|
+
const loadedCacheRef = useRef17(EMPTY_LOADED_TRACKS);
|
|
2770
|
+
const tracks = useMemo9(() => {
|
|
2648
2771
|
const next = loadedTracks(arrangementTracks, loadedCacheRef.current);
|
|
2649
2772
|
loadedCacheRef.current = next.cache;
|
|
2650
2773
|
return next.tracks;
|
|
2651
2774
|
}, [arrangementTracks]);
|
|
2652
2775
|
const { getWaveformData, version } = useWaveformDataCache(tracks, baseScale);
|
|
2653
|
-
const peaksOptions =
|
|
2776
|
+
const peaksOptions = useMemo9(
|
|
2654
2777
|
() => ({ samplesPerPixel, mono, getGeneratedWaveformData: getWaveformData }),
|
|
2655
2778
|
[samplesPerPixel, mono, getWaveformData]
|
|
2656
2779
|
);
|
|
2657
|
-
const peaksCacheRef =
|
|
2658
|
-
const loadedPeaks =
|
|
2780
|
+
const peaksCacheRef = useRef17(EMPTY_PEAKS_CACHE);
|
|
2781
|
+
const loadedPeaks = useMemo9(() => {
|
|
2659
2782
|
const next = derivePeaks(tracks, peaksOptions, peaksCacheRef.current);
|
|
2660
2783
|
peaksCacheRef.current = next;
|
|
2661
2784
|
return next;
|
|
2662
2785
|
}, [tracks, peaksOptions, version]);
|
|
2663
|
-
const rowsCacheRef =
|
|
2664
|
-
const peaksDataArray =
|
|
2786
|
+
const rowsCacheRef = useRef17(EMPTY_ROWS);
|
|
2787
|
+
const peaksDataArray = useMemo9(() => {
|
|
2665
2788
|
const inputs = { loadedPeaks, samplesPerPixel, mono, placeholderSampleRate };
|
|
2666
2789
|
const next = deriveRows(arrangementTracks, inputs, rowsCacheRef.current);
|
|
2667
2790
|
rowsCacheRef.current = next;
|
|
2668
2791
|
return next.result;
|
|
2669
2792
|
}, [arrangementTracks, loadedPeaks, samplesPerPixel, mono, placeholderSampleRate]);
|
|
2670
|
-
const duration =
|
|
2671
|
-
const statesCacheRef =
|
|
2672
|
-
const trackStates =
|
|
2673
|
-
const next = deriveTrackStates(
|
|
2793
|
+
const duration = useMemo9(() => timelineDuration(tracks), [tracks]);
|
|
2794
|
+
const statesCacheRef = useRef17(EMPTY_STATES);
|
|
2795
|
+
const trackStates = useMemo9(() => {
|
|
2796
|
+
const next = deriveTrackStates(
|
|
2797
|
+
arrangementTracks,
|
|
2798
|
+
mixer,
|
|
2799
|
+
recordingTrackIds,
|
|
2800
|
+
statesCacheRef.current
|
|
2801
|
+
);
|
|
2674
2802
|
statesCacheRef.current = next;
|
|
2675
2803
|
return next.result;
|
|
2676
|
-
}, [arrangementTracks, mixer]);
|
|
2804
|
+
}, [arrangementTracks, mixer, recordingTrackIds]);
|
|
2677
2805
|
return {
|
|
2678
2806
|
tracks,
|
|
2679
2807
|
peaksDataArray,
|
|
@@ -2687,7 +2815,18 @@ function useArrangementView(arrangement, options) {
|
|
|
2687
2815
|
}
|
|
2688
2816
|
|
|
2689
2817
|
// src/providerInternals/useReadyOnce.ts
|
|
2690
|
-
import { useCallback as useCallback17, useEffect as
|
|
2818
|
+
import { useCallback as useCallback17, useEffect as useEffect5, useInsertionEffect, useRef as useRef18, useState as useState14 } from "react";
|
|
2819
|
+
|
|
2820
|
+
// src/utils/isDevelopmentBuild.ts
|
|
2821
|
+
function isDevelopmentBuild() {
|
|
2822
|
+
try {
|
|
2823
|
+
return process.env.NODE_ENV !== "production";
|
|
2824
|
+
} catch (e) {
|
|
2825
|
+
return false;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
// src/providerInternals/useReadyOnce.ts
|
|
2691
2830
|
var READY_EVENT = "waveform-playlist:ready";
|
|
2692
2831
|
var PLAY_BEFORE_READY_WARNING = "[waveform-playlist] play() was called before the playlist was ready and did nothing: playback starts once the playlist is ready. Wait for `isReady` (usePlaylistTimeline) or the `onReady` callback before calling play().";
|
|
2693
2832
|
function callOnReady({
|
|
@@ -2706,11 +2845,11 @@ function callOnReady({
|
|
|
2706
2845
|
function useReadyOnce(options) {
|
|
2707
2846
|
const { isEngineAttached, arrangement, onReadyRef, onErrorRef, trackCount, duration } = options;
|
|
2708
2847
|
const { pendingCount } = useArrangementSources(arrangement);
|
|
2709
|
-
const [hasBeenReady, setHasBeenReady] =
|
|
2710
|
-
const firedRef =
|
|
2848
|
+
const [hasBeenReady, setHasBeenReady] = useState14(false);
|
|
2849
|
+
const firedRef = useRef18(false);
|
|
2711
2850
|
const isReady = isEngineAttached && (hasBeenReady || pendingCount === 0);
|
|
2712
|
-
const firstReadyRef =
|
|
2713
|
-
const warnedPlayRef =
|
|
2851
|
+
const firstReadyRef = useRef18(false);
|
|
2852
|
+
const warnedPlayRef = useRef18(false);
|
|
2714
2853
|
useInsertionEffect(() => {
|
|
2715
2854
|
if (isReady) firstReadyRef.current = true;
|
|
2716
2855
|
}, [isReady]);
|
|
@@ -2722,7 +2861,7 @@ function useReadyOnce(options) {
|
|
|
2722
2861
|
}
|
|
2723
2862
|
return true;
|
|
2724
2863
|
}, []);
|
|
2725
|
-
|
|
2864
|
+
useEffect5(() => {
|
|
2726
2865
|
if (!isReady || firedRef.current) return;
|
|
2727
2866
|
firedRef.current = true;
|
|
2728
2867
|
setHasBeenReady(true);
|
|
@@ -2734,8 +2873,7 @@ function useReadyOnce(options) {
|
|
|
2734
2873
|
}
|
|
2735
2874
|
|
|
2736
2875
|
// src/providerInternals/useArrangementEditing.ts
|
|
2737
|
-
import { useCallback as useCallback18, useEffect as
|
|
2738
|
-
import { createValueSource as createValueSource3 } from "@waveform-playlist/core";
|
|
2876
|
+
import { useCallback as useCallback18, useEffect as useEffect6, useMemo as useMemo10, useRef as useRef19, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
2739
2877
|
|
|
2740
2878
|
// src/components/partWarnings.ts
|
|
2741
2879
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -2755,63 +2893,71 @@ function isTrackId(setter, trackId) {
|
|
|
2755
2893
|
);
|
|
2756
2894
|
return false;
|
|
2757
2895
|
}
|
|
2896
|
+
var readRecordingTrackId = (arrangement) => {
|
|
2897
|
+
for (const id of arrangement.recordingTrackIds) return id;
|
|
2898
|
+
return null;
|
|
2899
|
+
};
|
|
2900
|
+
function clearRecordingTracks(arrangement, keep = null) {
|
|
2901
|
+
for (const id of [...arrangement.recordingTrackIds]) {
|
|
2902
|
+
if (id !== keep) arrangement.setTrackRecording(id, false);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2758
2905
|
function useRecordingActive(arrangement) {
|
|
2759
|
-
const recordingActiveRef =
|
|
2760
|
-
const [armed] = useState14(() => createValueSource3(null));
|
|
2906
|
+
const recordingActiveRef = useRef19(false);
|
|
2761
2907
|
const setRecordingActive = useCallback18(
|
|
2762
|
-
(active,
|
|
2763
|
-
var _a, _b;
|
|
2908
|
+
(active, recordingTrackId2) => {
|
|
2764
2909
|
recordingActiveRef.current = active;
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
armed.publish({ trackId: armedTrackId2, prevMuted });
|
|
2771
|
-
arrangement.setTrackMute(armedTrackId2, true);
|
|
2772
|
-
} else if (!active && current) {
|
|
2773
|
-
arrangement.setTrackMute(current.trackId, current.prevMuted);
|
|
2774
|
-
armed.publish(null);
|
|
2910
|
+
if (active && recordingTrackId2) {
|
|
2911
|
+
clearRecordingTracks(arrangement, recordingTrackId2);
|
|
2912
|
+
arrangement.setTrackRecording(recordingTrackId2, true);
|
|
2913
|
+
} else if (!active) {
|
|
2914
|
+
clearRecordingTracks(arrangement);
|
|
2775
2915
|
}
|
|
2776
2916
|
},
|
|
2777
|
-
[arrangement
|
|
2917
|
+
[arrangement]
|
|
2778
2918
|
);
|
|
2779
|
-
|
|
2919
|
+
useEffect6(
|
|
2780
2920
|
() => () => {
|
|
2781
|
-
if (
|
|
2921
|
+
if (arrangement.recordingTrackIds.size > 0) setRecordingActive(false);
|
|
2782
2922
|
},
|
|
2783
|
-
[
|
|
2923
|
+
[arrangement, setRecordingActive]
|
|
2784
2924
|
);
|
|
2785
|
-
const
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
const
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2925
|
+
const subscribe = useCallback18(
|
|
2926
|
+
(listener) => arrangement.subscribe(listener),
|
|
2927
|
+
[arrangement]
|
|
2928
|
+
);
|
|
2929
|
+
const getRecordingTrackId = useCallback18(() => readRecordingTrackId(arrangement), [arrangement]);
|
|
2930
|
+
const recordingTrackId = useSyncExternalStore8(
|
|
2931
|
+
subscribe,
|
|
2932
|
+
getRecordingTrackId,
|
|
2933
|
+
getRecordingTrackId
|
|
2934
|
+
);
|
|
2935
|
+
const recordingTrack = useMemo10(() => ({ recordingTrackId }), [recordingTrackId]);
|
|
2936
|
+
return { setRecordingActive, recordingActiveRef, recordingTrack };
|
|
2792
2937
|
}
|
|
2793
|
-
function useArrangementEditing(arrangement) {
|
|
2938
|
+
function useArrangementEditing(arrangement, dragGuard) {
|
|
2794
2939
|
const setTrackMute = useCallback18(
|
|
2795
|
-
(trackId, muted) => {
|
|
2796
|
-
if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted);
|
|
2940
|
+
(trackId, muted, options) => {
|
|
2941
|
+
if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted, options);
|
|
2797
2942
|
},
|
|
2798
2943
|
[arrangement]
|
|
2799
2944
|
);
|
|
2800
2945
|
const setTrackSolo = useCallback18(
|
|
2801
|
-
(trackId, soloed) => {
|
|
2802
|
-
if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed);
|
|
2946
|
+
(trackId, soloed, options) => {
|
|
2947
|
+
if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed, options);
|
|
2803
2948
|
},
|
|
2804
2949
|
[arrangement]
|
|
2805
2950
|
);
|
|
2806
2951
|
const setTrackVolume = useCallback18(
|
|
2807
|
-
(trackId, volume) => {
|
|
2808
|
-
if (isTrackId("setTrackVolume", trackId))
|
|
2952
|
+
(trackId, volume, options) => {
|
|
2953
|
+
if (isTrackId("setTrackVolume", trackId))
|
|
2954
|
+
arrangement.setTrackVolume(trackId, volume, options);
|
|
2809
2955
|
},
|
|
2810
2956
|
[arrangement]
|
|
2811
2957
|
);
|
|
2812
2958
|
const setTrackPan = useCallback18(
|
|
2813
|
-
(trackId, pan) => {
|
|
2814
|
-
if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan);
|
|
2959
|
+
(trackId, pan, options) => {
|
|
2960
|
+
if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan, options);
|
|
2815
2961
|
},
|
|
2816
2962
|
[arrangement]
|
|
2817
2963
|
);
|
|
@@ -2819,9 +2965,13 @@ function useArrangementEditing(arrangement) {
|
|
|
2819
2965
|
(trackId, toIndex) => arrangement.reorderTrack(trackId, toIndex),
|
|
2820
2966
|
[arrangement]
|
|
2821
2967
|
);
|
|
2822
|
-
const undo = useCallback18(() =>
|
|
2823
|
-
|
|
2824
|
-
|
|
2968
|
+
const undo = useCallback18(() => {
|
|
2969
|
+
if (!dragGuard.active) arrangement.undo();
|
|
2970
|
+
}, [arrangement, dragGuard]);
|
|
2971
|
+
const redo = useCallback18(() => {
|
|
2972
|
+
if (!dragGuard.active) arrangement.redo();
|
|
2973
|
+
}, [arrangement, dragGuard]);
|
|
2974
|
+
const { setRecordingActive, recordingActiveRef, recordingTrack } = useRecordingActive(arrangement);
|
|
2825
2975
|
return {
|
|
2826
2976
|
setTrackMute,
|
|
2827
2977
|
setTrackSolo,
|
|
@@ -2832,12 +2982,31 @@ function useArrangementEditing(arrangement) {
|
|
|
2832
2982
|
redo,
|
|
2833
2983
|
setRecordingActive,
|
|
2834
2984
|
recordingActiveRef,
|
|
2835
|
-
|
|
2985
|
+
recordingTrack
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
// src/providerInternals/dragGuard.ts
|
|
2990
|
+
function createDragGuard() {
|
|
2991
|
+
let count = 0;
|
|
2992
|
+
return {
|
|
2993
|
+
begin() {
|
|
2994
|
+
count++;
|
|
2995
|
+
let ended = false;
|
|
2996
|
+
return () => {
|
|
2997
|
+
if (ended) return;
|
|
2998
|
+
ended = true;
|
|
2999
|
+
count--;
|
|
3000
|
+
};
|
|
3001
|
+
},
|
|
3002
|
+
get active() {
|
|
3003
|
+
return count > 0;
|
|
3004
|
+
}
|
|
2836
3005
|
};
|
|
2837
3006
|
}
|
|
2838
3007
|
|
|
2839
3008
|
// src/providerInternals/arrangementIdentity.ts
|
|
2840
|
-
import { useEffect as
|
|
3009
|
+
import { useEffect as useEffect7, useRef as useRef20 } from "react";
|
|
2841
3010
|
var arrangementKeys = /* @__PURE__ */ new WeakMap();
|
|
2842
3011
|
var lastArrangementKey = 0;
|
|
2843
3012
|
var MISSING_ARRANGEMENT_ERROR = "[waveform-playlist] WaveformPlaylistProvider needs an `arrangement` prop: an arrangement made with `useCreateArrangement`, which owns the tracks. The `tracks` and `onTracksChange` props were removed. See https://naomiaro.github.io/waveform-playlist/docs/react/upgrading";
|
|
@@ -2856,9 +3025,9 @@ function keyOf(arrangement) {
|
|
|
2856
3025
|
var NEW_ARRANGEMENT_WARNING = "[waveform-playlist] WaveformPlaylistProvider was given a new `arrangement` prop: everything below it mounts again (a new engine, the view and its state). Keep one arrangement for the life of the playlist (`useCreateArrangement`) and change it through its methods.";
|
|
2857
3026
|
function useArrangementKey(arrangement) {
|
|
2858
3027
|
const key = keyOf(arrangement);
|
|
2859
|
-
const firstKeyRef =
|
|
2860
|
-
const warnedRef =
|
|
2861
|
-
|
|
3028
|
+
const firstKeyRef = useRef20(key);
|
|
3029
|
+
const warnedRef = useRef20(false);
|
|
3030
|
+
useEffect7(() => {
|
|
2862
3031
|
if (key === firstKeyRef.current || warnedRef.current) return;
|
|
2863
3032
|
warnedRef.current = true;
|
|
2864
3033
|
if (isDevelopmentBuild()) console.warn(NEW_ARRANGEMENT_WARNING);
|
|
@@ -2882,12 +3051,12 @@ var ProviderOnArrangement = ({
|
|
|
2882
3051
|
zoomLevels,
|
|
2883
3052
|
automaticScroll = false,
|
|
2884
3053
|
theme: userThemeProp,
|
|
3054
|
+
annotationStore,
|
|
2885
3055
|
annotationList,
|
|
2886
3056
|
effects,
|
|
2887
3057
|
trackEffects,
|
|
2888
3058
|
onReady,
|
|
2889
3059
|
onError,
|
|
2890
|
-
onAnnotationsChange,
|
|
2891
3060
|
soundFontCache,
|
|
2892
3061
|
indefinitePlayback = false,
|
|
2893
3062
|
sampleRate: sampleRateProp,
|
|
@@ -2895,15 +3064,14 @@ var ProviderOnArrangement = ({
|
|
|
2895
3064
|
children
|
|
2896
3065
|
}) => {
|
|
2897
3066
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
2898
|
-
const stableZoomLevels =
|
|
3067
|
+
const stableZoomLevels = useMemo11(
|
|
2899
3068
|
() => zoomLevels,
|
|
2900
3069
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2901
3070
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2902
3071
|
);
|
|
2903
3072
|
const {
|
|
2904
|
-
|
|
3073
|
+
getAnnotations,
|
|
2905
3074
|
annotationLookup,
|
|
2906
|
-
setAnnotations,
|
|
2907
3075
|
annotationPreview,
|
|
2908
3076
|
activeAnnotationId,
|
|
2909
3077
|
activeAnnotationIdRef,
|
|
@@ -2916,9 +3084,8 @@ var ProviderOnArrangement = ({
|
|
|
2916
3084
|
annotationsValue,
|
|
2917
3085
|
annotationOptionsValue
|
|
2918
3086
|
} = useAnnotationState({
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
providerName: "WaveformPlaylistProvider"
|
|
3087
|
+
annotationStore,
|
|
3088
|
+
annotationList
|
|
2922
3089
|
});
|
|
2923
3090
|
const {
|
|
2924
3091
|
scrollContainerRef,
|
|
@@ -2930,18 +3097,17 @@ var ProviderOnArrangement = ({
|
|
|
2930
3097
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
2931
3098
|
const [isPlaying, setIsPlaying] = useState15(false);
|
|
2932
3099
|
const [currentTime, setCurrentTime] = useState15(0);
|
|
2933
|
-
const [trackReorderEpoch, setTrackReorderEpoch] = useState15(0);
|
|
2934
3100
|
const [trackDragPreview, setTrackDragPreview] = useState15(null);
|
|
2935
|
-
const indefinitePlaybackRef =
|
|
3101
|
+
const indefinitePlaybackRef = useRef21(indefinitePlayback);
|
|
2936
3102
|
indefinitePlaybackRef.current = indefinitePlayback;
|
|
2937
|
-
const isPlayingRef =
|
|
3103
|
+
const isPlayingRef = useRef21(false);
|
|
2938
3104
|
isPlayingRef.current = isPlaying;
|
|
2939
|
-
const playStartPositionRef =
|
|
2940
|
-
const currentTimeRef =
|
|
2941
|
-
const visualTimeRef =
|
|
2942
|
-
const soundFontCacheRef =
|
|
3105
|
+
const playStartPositionRef = useRef21(0);
|
|
3106
|
+
const currentTimeRef = useRef21(0);
|
|
3107
|
+
const visualTimeRef = useRef21(0);
|
|
3108
|
+
const soundFontCacheRef = useRef21(soundFontCache);
|
|
2943
3109
|
soundFontCacheRef.current = soundFontCache;
|
|
2944
|
-
const trackEffectsRef =
|
|
3110
|
+
const trackEffectsRef = useRef21(trackEffects);
|
|
2945
3111
|
trackEffectsRef.current = trackEffects;
|
|
2946
3112
|
const resolveTrackEffects = useCallback19(
|
|
2947
3113
|
(trackId) => {
|
|
@@ -2950,19 +3116,20 @@ var ProviderOnArrangement = ({
|
|
|
2950
3116
|
},
|
|
2951
3117
|
[]
|
|
2952
3118
|
);
|
|
2953
|
-
const onReadyRef =
|
|
2954
|
-
const onErrorRef =
|
|
2955
|
-
|
|
3119
|
+
const onReadyRef = useRef21(onReady);
|
|
3120
|
+
const onErrorRef = useRef21(onError);
|
|
3121
|
+
useLayoutEffect5(() => {
|
|
2956
3122
|
onReadyRef.current = onReady;
|
|
2957
3123
|
onErrorRef.current = onError;
|
|
2958
3124
|
});
|
|
2959
|
-
const playbackStartTimeRef =
|
|
2960
|
-
const audioStartPositionRef =
|
|
2961
|
-
const playbackEndTimeRef =
|
|
2962
|
-
const suppressEngineStopMirrorRef =
|
|
2963
|
-
const samplesPerPixelRef =
|
|
2964
|
-
const
|
|
2965
|
-
const
|
|
3125
|
+
const playbackStartTimeRef = useRef21(0);
|
|
3126
|
+
const audioStartPositionRef = useRef21(0);
|
|
3127
|
+
const playbackEndTimeRef = useRef21(null);
|
|
3128
|
+
const suppressEngineStopMirrorRef = useRef21(false);
|
|
3129
|
+
const samplesPerPixelRef = useRef21(initialSamplesPerPixel);
|
|
3130
|
+
const engineSamplesPerPixelRef = useRef21(initialSamplesPerPixel);
|
|
3131
|
+
const isSelectionPlayRef = useRef21(false);
|
|
3132
|
+
const playRequestIdRef = useRef21(0);
|
|
2966
3133
|
const { animationFrameRef, startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
2967
3134
|
const onBuildFailure = useCallback19(() => {
|
|
2968
3135
|
if (!isPlayingRef.current) return;
|
|
@@ -2971,7 +3138,7 @@ var ProviderOnArrangement = ({
|
|
|
2971
3138
|
visualTimeRef.current = toVisualTime(currentTimeRef.current);
|
|
2972
3139
|
setCurrentTime(currentTimeRef.current);
|
|
2973
3140
|
}, [stopAnimationFrameLoop]);
|
|
2974
|
-
const followersRef =
|
|
3141
|
+
const followersRef = useRef21(null);
|
|
2975
3142
|
const seedEngine = useCallback19(
|
|
2976
3143
|
(engine) => {
|
|
2977
3144
|
var _a;
|
|
@@ -2986,13 +3153,11 @@ var ProviderOnArrangement = ({
|
|
|
2986
3153
|
},
|
|
2987
3154
|
[]
|
|
2988
3155
|
);
|
|
2989
|
-
const onEngineState = useCallback19(
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
[]
|
|
2995
|
-
);
|
|
3156
|
+
const onEngineState = useCallback19((state) => {
|
|
3157
|
+
var _a;
|
|
3158
|
+
engineSamplesPerPixelRef.current = state.samplesPerPixel;
|
|
3159
|
+
(_a = followersRef.current) == null ? void 0 : _a.mirror(state);
|
|
3160
|
+
}, []);
|
|
2996
3161
|
const {
|
|
2997
3162
|
engineRef,
|
|
2998
3163
|
adapterRef,
|
|
@@ -3012,7 +3177,7 @@ var ProviderOnArrangement = ({
|
|
|
3012
3177
|
soundFontCacheRef,
|
|
3013
3178
|
sampleRateProp,
|
|
3014
3179
|
zoomLevels,
|
|
3015
|
-
samplesPerPixelRef,
|
|
3180
|
+
samplesPerPixelRef: engineSamplesPerPixelRef,
|
|
3016
3181
|
playbackEndTimeRef,
|
|
3017
3182
|
seedEngine,
|
|
3018
3183
|
onEngine,
|
|
@@ -3021,7 +3186,7 @@ var ProviderOnArrangement = ({
|
|
|
3021
3186
|
onErrorRef,
|
|
3022
3187
|
onBuildFailure
|
|
3023
3188
|
});
|
|
3024
|
-
const sampleRateRef =
|
|
3189
|
+
const sampleRateRef = useRef21(sampleRate);
|
|
3025
3190
|
sampleRateRef.current = sampleRate;
|
|
3026
3191
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3027
3192
|
const zoom = useZoomControls({ engineRef, initialSamplesPerPixel });
|
|
@@ -3059,7 +3224,7 @@ var ProviderOnArrangement = ({
|
|
|
3059
3224
|
onEngineState: onSelectedTrackEngineState,
|
|
3060
3225
|
selectedTrackIdRef
|
|
3061
3226
|
} = useSelectedTrack({ engineRef });
|
|
3062
|
-
const baseScale =
|
|
3227
|
+
const baseScale = useMemo11(
|
|
3063
3228
|
() => Math.min(...stableZoomLevels != null ? stableZoomLevels : [256, 512, 1024, 2048, 4096, 8192]),
|
|
3064
3229
|
[stableZoomLevels]
|
|
3065
3230
|
);
|
|
@@ -3070,7 +3235,7 @@ var ProviderOnArrangement = ({
|
|
|
3070
3235
|
placeholderSampleRate: isSampleRateKnown ? sampleRate : null
|
|
3071
3236
|
});
|
|
3072
3237
|
const { tracks, duration } = view;
|
|
3073
|
-
const durationRef =
|
|
3238
|
+
const durationRef = useRef21(duration);
|
|
3074
3239
|
durationRef.current = duration;
|
|
3075
3240
|
const { isReady, refusePlayBeforeFirstReady } = useReadyOnce({
|
|
3076
3241
|
isEngineAttached,
|
|
@@ -3085,7 +3250,8 @@ var ProviderOnArrangement = ({
|
|
|
3085
3250
|
peaksOptions: view.peaksOptions,
|
|
3086
3251
|
peaksCacheRef: view.peaksCacheRef
|
|
3087
3252
|
});
|
|
3088
|
-
const
|
|
3253
|
+
const [dragGuard] = useState15(createDragGuard);
|
|
3254
|
+
const editing = useArrangementEditing(arrangement, dragGuard);
|
|
3089
3255
|
const { recordingActiveRef } = editing;
|
|
3090
3256
|
const setLoopRegionFromSelection = useCallback19(() => {
|
|
3091
3257
|
var _a, _b;
|
|
@@ -3095,7 +3261,7 @@ var ProviderOnArrangement = ({
|
|
|
3095
3261
|
setLoopRegion(start, end);
|
|
3096
3262
|
}
|
|
3097
3263
|
}, [setLoopRegion, selectionStartRef, selectionEndRef]);
|
|
3098
|
-
|
|
3264
|
+
useEffect8(() => {
|
|
3099
3265
|
if (!scrollContainerRef.current || duration === 0) return;
|
|
3100
3266
|
const container = scrollContainerRef.current;
|
|
3101
3267
|
const oldSamplesPerPixel = samplesPerPixelRef.current;
|
|
@@ -3111,10 +3277,10 @@ var ProviderOnArrangement = ({
|
|
|
3111
3277
|
container.scrollLeft = newScrollLeft;
|
|
3112
3278
|
samplesPerPixelRef.current = newSamplesPerPixel;
|
|
3113
3279
|
}, [samplesPerPixel, duration, scrollContainerRef]);
|
|
3114
|
-
|
|
3280
|
+
useEffect8(() => {
|
|
3115
3281
|
syncSoundFontCacheToAdapter(adapterRef.current, soundFontCache);
|
|
3116
3282
|
}, [soundFontCache, adapterRef]);
|
|
3117
|
-
|
|
3283
|
+
useEffect8(() => {
|
|
3118
3284
|
for (const track of tracks) {
|
|
3119
3285
|
for (const clip of track.clips) {
|
|
3120
3286
|
if (!clip.audioBuffer && !clip.waveformData && !clip.midiNotes) {
|
|
@@ -3130,7 +3296,7 @@ var ProviderOnArrangement = ({
|
|
|
3130
3296
|
},
|
|
3131
3297
|
[adapterRef]
|
|
3132
3298
|
);
|
|
3133
|
-
const getPlaybackTimeFallbackWarnedRef =
|
|
3299
|
+
const getPlaybackTimeFallbackWarnedRef = useRef21(false);
|
|
3134
3300
|
const getPlaybackTime = useCallback19(() => {
|
|
3135
3301
|
var _a, _b;
|
|
3136
3302
|
if (engineRef.current) {
|
|
@@ -3173,7 +3339,7 @@ var ProviderOnArrangement = ({
|
|
|
3173
3339
|
},
|
|
3174
3340
|
[stopAnimationFrameLoop, setCurrentTimeRefs]
|
|
3175
3341
|
);
|
|
3176
|
-
|
|
3342
|
+
useLayoutEffect5(() => {
|
|
3177
3343
|
const mirror = (state) => {
|
|
3178
3344
|
onSelectionEngineState(state);
|
|
3179
3345
|
onLoopEngineState(state);
|
|
@@ -3191,7 +3357,7 @@ var ProviderOnArrangement = ({
|
|
|
3191
3357
|
if (selectedTrackIdRef.current) engine.selectTrack(selectedTrackIdRef.current);
|
|
3192
3358
|
},
|
|
3193
3359
|
follow: (engine) => {
|
|
3194
|
-
engine.on("statechange",
|
|
3360
|
+
engine.on("statechange", onEngineState);
|
|
3195
3361
|
engine.on("stop", () => mirrorEngineStop(engine));
|
|
3196
3362
|
},
|
|
3197
3363
|
mirror
|
|
@@ -3214,7 +3380,7 @@ var ProviderOnArrangement = ({
|
|
|
3214
3380
|
};
|
|
3215
3381
|
runFrameCallbacks(frameData);
|
|
3216
3382
|
const activeAnnotationEnded = followAnnotations({
|
|
3217
|
-
annotations:
|
|
3383
|
+
annotations: getAnnotations(),
|
|
3218
3384
|
lookup: annotationLookup,
|
|
3219
3385
|
time,
|
|
3220
3386
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -3266,7 +3432,7 @@ var ProviderOnArrangement = ({
|
|
|
3266
3432
|
annotationLookup,
|
|
3267
3433
|
// Refs and a stable function from the shared provider hooks: they never
|
|
3268
3434
|
// change, and are listed because the linter cannot see that.
|
|
3269
|
-
|
|
3435
|
+
getAnnotations,
|
|
3270
3436
|
activeAnnotationIdRef,
|
|
3271
3437
|
continuousPlayRef,
|
|
3272
3438
|
isAutomaticScrollRef,
|
|
@@ -3276,8 +3442,8 @@ var ProviderOnArrangement = ({
|
|
|
3276
3442
|
recordingActiveRef
|
|
3277
3443
|
]);
|
|
3278
3444
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
3279
|
-
const prevContinuousPlayRef =
|
|
3280
|
-
|
|
3445
|
+
const prevContinuousPlayRef = useRef21(continuousPlay);
|
|
3446
|
+
useEffect8(() => {
|
|
3281
3447
|
const continuousPlayTurnedOn = continuousPlay && !prevContinuousPlayRef.current && !isSelectionPlayRef.current;
|
|
3282
3448
|
prevContinuousPlayRef.current = continuousPlay;
|
|
3283
3449
|
const reschedulePlayback = () => __async(null, null, function* () {
|
|
@@ -3293,7 +3459,7 @@ var ProviderOnArrangement = ({
|
|
|
3293
3459
|
audioStartPositionRef.current = currentPos;
|
|
3294
3460
|
const boundedEnd = playbackEndTimeRef.current;
|
|
3295
3461
|
const activeId = activeAnnotationIdRef.current;
|
|
3296
|
-
const activeAnnotation = activeId ? annotationLookup.byId(
|
|
3462
|
+
const activeAnnotation = activeId ? annotationLookup.byId(getAnnotations(), activeId) : void 0;
|
|
3297
3463
|
const endsWithAnnotation = boundedEnd !== null && activeAnnotation !== void 0 && Math.abs(boundedEnd - activeAnnotation.end) < 1e-6;
|
|
3298
3464
|
const endTime = endsWithAnnotation ? null : boundedEnd;
|
|
3299
3465
|
playbackEndTimeRef.current = endTime;
|
|
@@ -3318,11 +3484,11 @@ var ProviderOnArrangement = ({
|
|
|
3318
3484
|
animationFrameRef,
|
|
3319
3485
|
getAudioContextTime,
|
|
3320
3486
|
annotationLookup,
|
|
3321
|
-
|
|
3487
|
+
getAnnotations,
|
|
3322
3488
|
activeAnnotationIdRef,
|
|
3323
3489
|
engineRef
|
|
3324
3490
|
]);
|
|
3325
|
-
|
|
3491
|
+
useEffect8(() => {
|
|
3326
3492
|
const resumePlayback = () => __async(null, null, function* () {
|
|
3327
3493
|
const engine = engineRef.current;
|
|
3328
3494
|
const request = pendingResumeRef.current;
|
|
@@ -3468,9 +3634,6 @@ var ProviderOnArrangement = ({
|
|
|
3468
3634
|
},
|
|
3469
3635
|
[play, setCurrentTimeRefs, recordingActiveRef]
|
|
3470
3636
|
);
|
|
3471
|
-
const bumpTrackReorderEpoch = useCallback19(() => {
|
|
3472
|
-
setTrackReorderEpoch((epoch) => epoch + 1);
|
|
3473
|
-
}, []);
|
|
3474
3637
|
const setSelection = useCallback19(
|
|
3475
3638
|
(start, end) => {
|
|
3476
3639
|
var _a;
|
|
@@ -3519,8 +3682,8 @@ var ProviderOnArrangement = ({
|
|
|
3519
3682
|
pendingResumeRef
|
|
3520
3683
|
]
|
|
3521
3684
|
);
|
|
3522
|
-
const isPlayingValue =
|
|
3523
|
-
const refsValue =
|
|
3685
|
+
const isPlayingValue = useMemo11(() => ({ isPlaying }), [isPlaying]);
|
|
3686
|
+
const refsValue = useMemo11(
|
|
3524
3687
|
() => ({
|
|
3525
3688
|
currentTimeRef,
|
|
3526
3689
|
visualTimeRef,
|
|
@@ -3529,7 +3692,7 @@ var ProviderOnArrangement = ({
|
|
|
3529
3692
|
}),
|
|
3530
3693
|
[currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback]
|
|
3531
3694
|
);
|
|
3532
|
-
const engineRefsValue =
|
|
3695
|
+
const engineRefsValue = useMemo11(
|
|
3533
3696
|
() => ({
|
|
3534
3697
|
playbackStartTimeRef,
|
|
3535
3698
|
audioStartPositionRef,
|
|
@@ -3549,25 +3712,25 @@ var ProviderOnArrangement = ({
|
|
|
3549
3712
|
engineRef
|
|
3550
3713
|
]
|
|
3551
3714
|
);
|
|
3552
|
-
const loopValue =
|
|
3715
|
+
const loopValue = useMemo11(
|
|
3553
3716
|
() => ({ isLoopEnabled, loopStart, loopEnd }),
|
|
3554
3717
|
[isLoopEnabled, loopStart, loopEnd]
|
|
3555
3718
|
);
|
|
3556
|
-
const selectedTrackIdValue =
|
|
3719
|
+
const selectedTrackIdValue = useMemo11(
|
|
3557
3720
|
() => ({ selectedTrackId }),
|
|
3558
3721
|
[selectedTrackId]
|
|
3559
3722
|
);
|
|
3560
3723
|
const { canUndo, canRedo } = view;
|
|
3561
|
-
const undoRedoValue =
|
|
3724
|
+
const undoRedoValue = useMemo11(
|
|
3562
3725
|
() => ({ canUndo, canRedo }),
|
|
3563
3726
|
[canUndo, canRedo]
|
|
3564
3727
|
);
|
|
3565
|
-
const selectionValue =
|
|
3728
|
+
const selectionValue = useMemo11(
|
|
3566
3729
|
() => ({ selectionStart, selectionEnd }),
|
|
3567
3730
|
[selectionStart, selectionEnd]
|
|
3568
3731
|
);
|
|
3569
|
-
const currentTimeValue =
|
|
3570
|
-
const activeAnnotationValue =
|
|
3732
|
+
const currentTimeValue = useMemo11(() => ({ currentTime }), [currentTime]);
|
|
3733
|
+
const activeAnnotationValue = useMemo11(
|
|
3571
3734
|
() => ({ activeAnnotationId }),
|
|
3572
3735
|
[activeAnnotationId]
|
|
3573
3736
|
);
|
|
@@ -3591,7 +3754,7 @@ var ProviderOnArrangement = ({
|
|
|
3591
3754
|
},
|
|
3592
3755
|
[play, setActiveAnnotationId, continuousPlayRef, refusePlayBeforeFirstReady]
|
|
3593
3756
|
);
|
|
3594
|
-
const controlsValue =
|
|
3757
|
+
const controlsValue = useMemo11(
|
|
3595
3758
|
() => ({
|
|
3596
3759
|
play,
|
|
3597
3760
|
pause,
|
|
@@ -3605,8 +3768,8 @@ var ProviderOnArrangement = ({
|
|
|
3605
3768
|
setContinuousPlay,
|
|
3606
3769
|
setAnnotationsEditable,
|
|
3607
3770
|
setLinkEndpoints,
|
|
3608
|
-
setAnnotations,
|
|
3609
3771
|
annotationPreview,
|
|
3772
|
+
annotationStore,
|
|
3610
3773
|
setActiveAnnotationId,
|
|
3611
3774
|
playAnnotation
|
|
3612
3775
|
}),
|
|
@@ -3623,13 +3786,13 @@ var ProviderOnArrangement = ({
|
|
|
3623
3786
|
setContinuousPlay,
|
|
3624
3787
|
setAnnotationsEditable,
|
|
3625
3788
|
setLinkEndpoints,
|
|
3626
|
-
setAnnotations,
|
|
3627
3789
|
annotationPreview,
|
|
3790
|
+
annotationStore,
|
|
3628
3791
|
setActiveAnnotationId,
|
|
3629
3792
|
playAnnotation
|
|
3630
3793
|
]
|
|
3631
3794
|
);
|
|
3632
|
-
const editorControlsValue =
|
|
3795
|
+
const editorControlsValue = useMemo11(
|
|
3633
3796
|
() => ({
|
|
3634
3797
|
setCurrentTime: setCurrentTimeControl,
|
|
3635
3798
|
// Track controls (the arrangement's mix and order)
|
|
@@ -3638,7 +3801,6 @@ var ProviderOnArrangement = ({
|
|
|
3638
3801
|
setTrackVolume: editing.setTrackVolume,
|
|
3639
3802
|
setTrackPan: editing.setTrackPan,
|
|
3640
3803
|
reorderTrack: editing.reorderTrack,
|
|
3641
|
-
bumpTrackReorderEpoch,
|
|
3642
3804
|
setTrackDragPreview,
|
|
3643
3805
|
setSelectedTrackId: setSelectedTrackIdControl,
|
|
3644
3806
|
// Zoom
|
|
@@ -3664,7 +3826,6 @@ var ProviderOnArrangement = ({
|
|
|
3664
3826
|
editing.setTrackVolume,
|
|
3665
3827
|
editing.setTrackPan,
|
|
3666
3828
|
editing.reorderTrack,
|
|
3667
|
-
bumpTrackReorderEpoch,
|
|
3668
3829
|
setTrackDragPreview,
|
|
3669
3830
|
setSelectedTrackIdControl,
|
|
3670
3831
|
zoom.zoomIn,
|
|
@@ -3679,7 +3840,7 @@ var ProviderOnArrangement = ({
|
|
|
3679
3840
|
editing.setRecordingActive
|
|
3680
3841
|
]
|
|
3681
3842
|
);
|
|
3682
|
-
const viewValue =
|
|
3843
|
+
const viewValue = useMemo11(
|
|
3683
3844
|
() => ({
|
|
3684
3845
|
sampleRate,
|
|
3685
3846
|
mono,
|
|
@@ -3687,61 +3848,67 @@ var ProviderOnArrangement = ({
|
|
|
3687
3848
|
}),
|
|
3688
3849
|
[sampleRate, mono, indefinitePlayback]
|
|
3689
3850
|
);
|
|
3690
|
-
const settingsValue =
|
|
3851
|
+
const settingsValue = useMemo11(
|
|
3691
3852
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
3692
3853
|
[timeFormat, isAutomaticScroll]
|
|
3693
3854
|
);
|
|
3694
|
-
const zoomValue =
|
|
3855
|
+
const zoomValue = useMemo11(
|
|
3695
3856
|
() => ({ samplesPerPixel, canZoomIn: zoom.canZoomIn, canZoomOut: zoom.canZoomOut }),
|
|
3696
3857
|
[samplesPerPixel, zoom.canZoomIn, zoom.canZoomOut]
|
|
3697
3858
|
);
|
|
3698
3859
|
const { peaksDataArray, trackStates } = view;
|
|
3699
|
-
const timelineValue =
|
|
3860
|
+
const timelineValue = useMemo11(
|
|
3700
3861
|
() => ({ tracks, peaksDataArray, duration, isReady }),
|
|
3701
3862
|
[tracks, peaksDataArray, duration, isReady]
|
|
3702
3863
|
);
|
|
3703
|
-
const mixerValue =
|
|
3864
|
+
const mixerValue = useMemo11(
|
|
3704
3865
|
() => ({ trackStates, masterVolume }),
|
|
3705
3866
|
[trackStates, masterVolume]
|
|
3706
3867
|
);
|
|
3707
|
-
const reorderPreviewValue =
|
|
3708
|
-
() => ({ trackDragPreview
|
|
3709
|
-
[trackDragPreview
|
|
3868
|
+
const reorderPreviewValue = useMemo11(
|
|
3869
|
+
() => ({ trackDragPreview }),
|
|
3870
|
+
[trackDragPreview]
|
|
3710
3871
|
);
|
|
3711
|
-
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(
|
|
3712
|
-
|
|
3872
|
+
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(DragGuardContext, { value: dragGuard, 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(
|
|
3873
|
+
ActiveAnnotationContext,
|
|
3713
3874
|
{
|
|
3714
|
-
value:
|
|
3715
|
-
children: /* @__PURE__ */ jsx(
|
|
3716
|
-
|
|
3875
|
+
value: activeAnnotationValue,
|
|
3876
|
+
children: /* @__PURE__ */ jsx(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ jsx(SelectionContext, { value: selectionValue, children: /* @__PURE__ */ jsx(
|
|
3877
|
+
TrackReorderPreviewContext,
|
|
3717
3878
|
{
|
|
3718
|
-
value:
|
|
3719
|
-
children: /* @__PURE__ */ jsx(
|
|
3720
|
-
|
|
3879
|
+
value: reorderPreviewValue,
|
|
3880
|
+
children: /* @__PURE__ */ jsx(PlaylistMixerContext, { value: mixerValue, children: /* @__PURE__ */ jsx(
|
|
3881
|
+
PlaylistTimelineContext,
|
|
3721
3882
|
{
|
|
3722
|
-
value:
|
|
3723
|
-
children
|
|
3883
|
+
value: timelineValue,
|
|
3884
|
+
children: /* @__PURE__ */ jsx(
|
|
3885
|
+
RecordingTrackContext,
|
|
3886
|
+
{
|
|
3887
|
+
value: editing.recordingTrack,
|
|
3888
|
+
children
|
|
3889
|
+
}
|
|
3890
|
+
)
|
|
3724
3891
|
}
|
|
3725
|
-
)
|
|
3892
|
+
) })
|
|
3726
3893
|
}
|
|
3727
|
-
) })
|
|
3894
|
+
) }) })
|
|
3728
3895
|
}
|
|
3729
|
-
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
|
|
3896
|
+
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
3730
3897
|
};
|
|
3731
3898
|
|
|
3732
3899
|
// src/MediaElementPlaylistContext.tsx
|
|
3733
3900
|
import {
|
|
3734
3901
|
useState as useState16,
|
|
3735
|
-
useEffect as
|
|
3736
|
-
useLayoutEffect as
|
|
3737
|
-
useRef as
|
|
3902
|
+
useEffect as useEffect9,
|
|
3903
|
+
useLayoutEffect as useLayoutEffect6,
|
|
3904
|
+
useRef as useRef22,
|
|
3738
3905
|
useCallback as useCallback20,
|
|
3739
|
-
useMemo as
|
|
3906
|
+
useMemo as useMemo12
|
|
3740
3907
|
} from "react";
|
|
3741
3908
|
import { ThemeProvider as ThemeProvider2 } from "styled-components";
|
|
3742
3909
|
|
|
3743
3910
|
// src/playout/resolveMediaElementPlayout.ts
|
|
3744
|
-
var
|
|
3911
|
+
var installHint2 = () => "@waveform-playlist/media-element-playout is required for the default MediaElement engine. Install with: " + installCommand("@waveform-playlist/media-element-playout") + " \u2014 or pass a custom `createPlayout`.";
|
|
3745
3912
|
function resolveMediaElementPlayout(opts) {
|
|
3746
3913
|
return __async(this, null, function* () {
|
|
3747
3914
|
if (opts.createPlayout) {
|
|
@@ -3754,7 +3921,7 @@ function resolveMediaElementPlayout(opts) {
|
|
|
3754
3921
|
console.warn(
|
|
3755
3922
|
"[waveform-playlist] @waveform-playlist/media-element-playout dynamic import failed: " + String(originalErr)
|
|
3756
3923
|
);
|
|
3757
|
-
throw new Error(
|
|
3924
|
+
throw new Error(installHint2());
|
|
3758
3925
|
}
|
|
3759
3926
|
return new mod.MediaElementPlayout({
|
|
3760
3927
|
playbackRate: opts.playbackRate,
|
|
@@ -3773,9 +3940,9 @@ var MediaElementPlaylistProvider = ({
|
|
|
3773
3940
|
preservesPitch = true,
|
|
3774
3941
|
automaticScroll = false,
|
|
3775
3942
|
theme: userThemeProp,
|
|
3943
|
+
annotationStore,
|
|
3776
3944
|
annotationList,
|
|
3777
3945
|
audioContext,
|
|
3778
|
-
onAnnotationsChange,
|
|
3779
3946
|
onReady,
|
|
3780
3947
|
onError,
|
|
3781
3948
|
createPlayout,
|
|
@@ -3783,7 +3950,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
3783
3950
|
}) => {
|
|
3784
3951
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3785
3952
|
const [isPlaying, setIsPlayingState] = useState16(false);
|
|
3786
|
-
const isPlayingRef =
|
|
3953
|
+
const isPlayingRef = useRef22(false);
|
|
3787
3954
|
const setIsPlaying = useCallback20((playing) => {
|
|
3788
3955
|
isPlayingRef.current = playing;
|
|
3789
3956
|
setIsPlayingState(playing);
|
|
@@ -3796,17 +3963,16 @@ var MediaElementPlaylistProvider = ({
|
|
|
3796
3963
|
setRatePropSeen(initialPlaybackRate);
|
|
3797
3964
|
setPlaybackRateState(initialPlaybackRate);
|
|
3798
3965
|
}
|
|
3799
|
-
const playbackRateRef =
|
|
3800
|
-
const ratePropAppliedRef =
|
|
3801
|
-
|
|
3966
|
+
const playbackRateRef = useRef22(initialPlaybackRate);
|
|
3967
|
+
const ratePropAppliedRef = useRef22(initialPlaybackRate);
|
|
3968
|
+
useLayoutEffect6(() => {
|
|
3802
3969
|
if (Object.is(ratePropAppliedRef.current, initialPlaybackRate)) return;
|
|
3803
3970
|
ratePropAppliedRef.current = initialPlaybackRate;
|
|
3804
3971
|
playbackRateRef.current = initialPlaybackRate;
|
|
3805
3972
|
}, [initialPlaybackRate]);
|
|
3806
3973
|
const {
|
|
3807
|
-
|
|
3974
|
+
getAnnotations,
|
|
3808
3975
|
annotationLookup,
|
|
3809
|
-
setAnnotations,
|
|
3810
3976
|
annotationPreview,
|
|
3811
3977
|
activeAnnotationId,
|
|
3812
3978
|
activeAnnotationIdRef,
|
|
@@ -3818,9 +3984,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3818
3984
|
annotationsValue,
|
|
3819
3985
|
annotationOptionsValue
|
|
3820
3986
|
} = useAnnotationState({
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
providerName: "MediaElementPlaylistProvider"
|
|
3987
|
+
annotationStore,
|
|
3988
|
+
annotationList
|
|
3824
3989
|
});
|
|
3825
3990
|
const {
|
|
3826
3991
|
scrollContainerRef,
|
|
@@ -3834,23 +3999,23 @@ var MediaElementPlaylistProvider = ({
|
|
|
3834
3999
|
selectionStart: 0,
|
|
3835
4000
|
selectionEnd: 0
|
|
3836
4001
|
});
|
|
3837
|
-
const selectionRef =
|
|
4002
|
+
const selectionRef = useRef22(selection);
|
|
3838
4003
|
const [samplesPerPixel] = useState16(initialSamplesPerPixel);
|
|
3839
4004
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3840
|
-
const playoutRef =
|
|
3841
|
-
const currentTimeRef =
|
|
3842
|
-
const samplesPerPixelRef =
|
|
4005
|
+
const playoutRef = useRef22(null);
|
|
4006
|
+
const currentTimeRef = useRef22(0);
|
|
4007
|
+
const samplesPerPixelRef = useRef22(initialSamplesPerPixel);
|
|
3843
4008
|
const { startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3844
|
-
const playStartPositionRef =
|
|
3845
|
-
const playbackEndTimeRef =
|
|
3846
|
-
const isSelectionPlayRef =
|
|
3847
|
-
const pendingPlayRef =
|
|
3848
|
-
const playoutInFlightRef =
|
|
4009
|
+
const playStartPositionRef = useRef22(0);
|
|
4010
|
+
const playbackEndTimeRef = useRef22(null);
|
|
4011
|
+
const isSelectionPlayRef = useRef22(false);
|
|
4012
|
+
const pendingPlayRef = useRef22(null);
|
|
4013
|
+
const playoutInFlightRef = useRef22(true);
|
|
3849
4014
|
const sampleRate = track.waveformData.sample_rate;
|
|
3850
4015
|
const duration = track.waveformData.duration;
|
|
3851
4016
|
const trackName = track.name;
|
|
3852
4017
|
const trackWaveformData = track.waveformData;
|
|
3853
|
-
const trackPeaks =
|
|
4018
|
+
const trackPeaks = useMemo12(() => {
|
|
3854
4019
|
try {
|
|
3855
4020
|
const durationSamples = Math.ceil(trackWaveformData.duration * sampleRate);
|
|
3856
4021
|
const extractedPeaks = extractPeaksFromWaveformData(
|
|
@@ -3879,7 +4044,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
3879
4044
|
}, [trackWaveformData, samplesPerPixel, sampleRate]);
|
|
3880
4045
|
const trackFadeIn = useShallowStable(track.fadeIn);
|
|
3881
4046
|
const trackFadeOut = useShallowStable(track.fadeOut);
|
|
3882
|
-
const peaksDataArray =
|
|
4047
|
+
const peaksDataArray = useMemo12(() => {
|
|
3883
4048
|
if (!trackPeaks) return [];
|
|
3884
4049
|
const clipPeaks = {
|
|
3885
4050
|
clipId: "media-element-clip",
|
|
@@ -3893,8 +4058,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3893
4058
|
};
|
|
3894
4059
|
return [[clipPeaks]];
|
|
3895
4060
|
}, [trackPeaks, trackName, trackFadeIn, trackFadeOut]);
|
|
3896
|
-
const latestAudioRef =
|
|
3897
|
-
|
|
4061
|
+
const latestAudioRef = useRef22({ source: track.source, waveformData: track.waveformData });
|
|
4062
|
+
useLayoutEffect6(() => {
|
|
3898
4063
|
latestAudioRef.current = { source: track.source, waveformData: track.waveformData };
|
|
3899
4064
|
}, [track.source, track.waveformData]);
|
|
3900
4065
|
const restAt = useCallback20(
|
|
@@ -3913,10 +4078,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
3913
4078
|
},
|
|
3914
4079
|
[stopAnimationFrameLoop, setIsPlaying]
|
|
3915
4080
|
);
|
|
3916
|
-
const startAnimationLoopRef =
|
|
4081
|
+
const startAnimationLoopRef = useRef22(() => {
|
|
3917
4082
|
});
|
|
3918
|
-
const endPlaybackIfDueRef =
|
|
3919
|
-
|
|
4083
|
+
const endPlaybackIfDueRef = useRef22(() => false);
|
|
4084
|
+
useEffect9(() => {
|
|
3920
4085
|
let cancelled = false;
|
|
3921
4086
|
let createdPlayout = null;
|
|
3922
4087
|
const source = track.source;
|
|
@@ -4045,7 +4210,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4045
4210
|
const endPlaybackIfDue = useCallback20(
|
|
4046
4211
|
(time) => {
|
|
4047
4212
|
const activeAnnotationEnded = followAnnotations({
|
|
4048
|
-
annotations:
|
|
4213
|
+
annotations: getAnnotations(),
|
|
4049
4214
|
lookup: annotationLookup,
|
|
4050
4215
|
time,
|
|
4051
4216
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -4068,7 +4233,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4068
4233
|
return false;
|
|
4069
4234
|
},
|
|
4070
4235
|
[
|
|
4071
|
-
|
|
4236
|
+
getAnnotations,
|
|
4072
4237
|
annotationLookup,
|
|
4073
4238
|
activeAnnotationIdRef,
|
|
4074
4239
|
continuousPlayRef,
|
|
@@ -4102,7 +4267,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4102
4267
|
runFrameCallbacks,
|
|
4103
4268
|
endPlaybackIfDue
|
|
4104
4269
|
]);
|
|
4105
|
-
|
|
4270
|
+
useLayoutEffect6(() => {
|
|
4106
4271
|
startAnimationLoopRef.current = startAnimationLoop;
|
|
4107
4272
|
endPlaybackIfDueRef.current = endPlaybackIfDue;
|
|
4108
4273
|
}, [startAnimationLoop, endPlaybackIfDue]);
|
|
@@ -4217,17 +4382,17 @@ var MediaElementPlaylistProvider = ({
|
|
|
4217
4382
|
playoutRef.current.setPlaybackRate(clampedRate);
|
|
4218
4383
|
}
|
|
4219
4384
|
}, []);
|
|
4220
|
-
const isPlayingValue =
|
|
4221
|
-
const currentTimeValue =
|
|
4222
|
-
const activeAnnotationValue =
|
|
4385
|
+
const isPlayingValue = useMemo12(() => ({ isPlaying }), [isPlaying]);
|
|
4386
|
+
const currentTimeValue = useMemo12(() => ({ currentTime }), [currentTime]);
|
|
4387
|
+
const activeAnnotationValue = useMemo12(
|
|
4223
4388
|
() => ({ activeAnnotationId }),
|
|
4224
4389
|
[activeAnnotationId]
|
|
4225
4390
|
);
|
|
4226
|
-
const settingsValue =
|
|
4391
|
+
const settingsValue = useMemo12(
|
|
4227
4392
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
4228
4393
|
[timeFormat, isAutomaticScroll]
|
|
4229
4394
|
);
|
|
4230
|
-
const refsValue =
|
|
4395
|
+
const refsValue = useMemo12(
|
|
4231
4396
|
() => ({
|
|
4232
4397
|
currentTimeRef,
|
|
4233
4398
|
visualTimeRef: currentTimeRef,
|
|
@@ -4247,7 +4412,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4247
4412
|
},
|
|
4248
4413
|
[play, setActiveAnnotationId]
|
|
4249
4414
|
);
|
|
4250
|
-
const controlsValue =
|
|
4415
|
+
const controlsValue = useMemo12(
|
|
4251
4416
|
() => ({
|
|
4252
4417
|
play,
|
|
4253
4418
|
pause,
|
|
@@ -4261,8 +4426,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
4261
4426
|
setContinuousPlay,
|
|
4262
4427
|
setAnnotationsEditable,
|
|
4263
4428
|
setLinkEndpoints,
|
|
4264
|
-
setAnnotations,
|
|
4265
4429
|
annotationPreview,
|
|
4430
|
+
annotationStore,
|
|
4266
4431
|
setActiveAnnotationId,
|
|
4267
4432
|
playAnnotation
|
|
4268
4433
|
}),
|
|
@@ -4279,25 +4444,25 @@ var MediaElementPlaylistProvider = ({
|
|
|
4279
4444
|
setContinuousPlay,
|
|
4280
4445
|
setAnnotationsEditable,
|
|
4281
4446
|
setLinkEndpoints,
|
|
4282
|
-
setAnnotations,
|
|
4283
4447
|
annotationPreview,
|
|
4448
|
+
annotationStore,
|
|
4284
4449
|
setActiveAnnotationId,
|
|
4285
4450
|
playAnnotation
|
|
4286
4451
|
]
|
|
4287
4452
|
);
|
|
4288
|
-
const viewValue =
|
|
4453
|
+
const viewValue = useMemo12(
|
|
4289
4454
|
() => ({ sampleRate, mono: false, indefinitePlayback: false }),
|
|
4290
4455
|
[sampleRate]
|
|
4291
4456
|
);
|
|
4292
|
-
const zoomValue =
|
|
4457
|
+
const zoomValue = useMemo12(
|
|
4293
4458
|
() => ({ samplesPerPixel, canZoomIn: false, canZoomOut: false }),
|
|
4294
4459
|
[samplesPerPixel]
|
|
4295
4460
|
);
|
|
4296
|
-
const playbackRateValue =
|
|
4461
|
+
const playbackRateValue = useMemo12(
|
|
4297
4462
|
() => ({ playbackRate, setPlaybackRate }),
|
|
4298
4463
|
[playbackRate, setPlaybackRate]
|
|
4299
4464
|
);
|
|
4300
|
-
const trackValue =
|
|
4465
|
+
const trackValue = useMemo12(
|
|
4301
4466
|
() => ({
|
|
4302
4467
|
duration,
|
|
4303
4468
|
isReady,
|
|
@@ -4312,7 +4477,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4312
4477
|
ActiveAnnotationContext,
|
|
4313
4478
|
{
|
|
4314
4479
|
value: activeAnnotationValue,
|
|
4315
|
-
children: /* @__PURE__ */ jsx2(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ jsx2(SelectionContext, { value: selection, children: /* @__PURE__ */ jsx2(SelectedRowContext, { value: ONLY_ROW_SELECTED, children: /* @__PURE__ */ jsx2(
|
|
4480
|
+
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 }) }) }) })
|
|
4316
4481
|
}
|
|
4317
4482
|
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
4318
4483
|
};
|
|
@@ -4451,7 +4616,7 @@ var ZoomOutButton = ({
|
|
|
4451
4616
|
};
|
|
4452
4617
|
|
|
4453
4618
|
// src/components/ContextualControls.tsx
|
|
4454
|
-
import { useRef as
|
|
4619
|
+
import { useRef as useRef23, useEffect as useEffect10, useId } from "react";
|
|
4455
4620
|
import {
|
|
4456
4621
|
MasterVolumeControl as BaseMasterVolumeControl,
|
|
4457
4622
|
TimeFormatSelect as BaseTimeFormatSelect,
|
|
@@ -4491,13 +4656,13 @@ var PositionDisplay = styled.span`
|
|
|
4491
4656
|
`;
|
|
4492
4657
|
var AudioPosition = ({ className }) => {
|
|
4493
4658
|
var _a;
|
|
4494
|
-
const timeRef =
|
|
4659
|
+
const timeRef = useRef23(null);
|
|
4495
4660
|
const { currentTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
4496
4661
|
const { isPlaying } = useIsPlaying();
|
|
4497
4662
|
useCurrentTime();
|
|
4498
4663
|
const { timeFormat: format } = usePlaylistSettings();
|
|
4499
4664
|
const id = useId();
|
|
4500
|
-
|
|
4665
|
+
useEffect10(() => {
|
|
4501
4666
|
if (isPlaying) {
|
|
4502
4667
|
registerFrameCallback(id, ({ time }) => {
|
|
4503
4668
|
if (timeRef.current) {
|
|
@@ -4507,7 +4672,7 @@ var AudioPosition = ({ className }) => {
|
|
|
4507
4672
|
}
|
|
4508
4673
|
return () => unregisterFrameCallback(id);
|
|
4509
4674
|
}, [id, isPlaying, format, registerFrameCallback, unregisterFrameCallback]);
|
|
4510
|
-
|
|
4675
|
+
useEffect10(() => {
|
|
4511
4676
|
var _a2;
|
|
4512
4677
|
if (!isPlaying && timeRef.current) {
|
|
4513
4678
|
timeRef.current.textContent = formatTime((_a2 = currentTimeRef.current) != null ? _a2 : 0, format);
|
|
@@ -4561,10 +4726,10 @@ var AutomaticScrollCheckbox = ({ className }) => {
|
|
|
4561
4726
|
// src/components/WaveformRoot.tsx
|
|
4562
4727
|
import {
|
|
4563
4728
|
use as use13,
|
|
4564
|
-
useLayoutEffect as
|
|
4565
|
-
useRef as
|
|
4566
|
-
useState as
|
|
4567
|
-
useMemo as
|
|
4729
|
+
useLayoutEffect as useLayoutEffect9,
|
|
4730
|
+
useRef as useRef31,
|
|
4731
|
+
useState as useState21,
|
|
4732
|
+
useMemo as useMemo20,
|
|
4568
4733
|
useCallback as useCallback26
|
|
4569
4734
|
} from "react";
|
|
4570
4735
|
import { createPortal } from "react-dom";
|
|
@@ -4604,10 +4769,10 @@ function trackIdAtOffset(orderedIds, layout, heightById, y) {
|
|
|
4604
4769
|
}
|
|
4605
4770
|
|
|
4606
4771
|
// src/hooks/useTrailingActive.ts
|
|
4607
|
-
import { useEffect as
|
|
4772
|
+
import { useEffect as useEffect11, useState as useState17 } from "react";
|
|
4608
4773
|
function useTrailingActive(active, trailingMs) {
|
|
4609
4774
|
const [trailing, setTrailing] = useState17(active);
|
|
4610
|
-
|
|
4775
|
+
useEffect11(() => {
|
|
4611
4776
|
if (active) {
|
|
4612
4777
|
setTrailing(true);
|
|
4613
4778
|
return void 0;
|
|
@@ -4619,7 +4784,7 @@ function useTrailingActive(active, trailingMs) {
|
|
|
4619
4784
|
}
|
|
4620
4785
|
|
|
4621
4786
|
// src/hooks/useRecordingLayout.ts
|
|
4622
|
-
import { useCallback as useCallback22, useSyncExternalStore as
|
|
4787
|
+
import { useCallback as useCallback22, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
4623
4788
|
var RECORDING_EXTENT_STEP_SECONDS = 10;
|
|
4624
4789
|
function recordingDisplayEnd(takeEndSeconds) {
|
|
4625
4790
|
const step = RECORDING_EXTENT_STEP_SECONDS;
|
|
@@ -4640,19 +4805,19 @@ function useRecordingLayout(progress, startSample, sampleRate) {
|
|
|
4640
4805
|
() => progress && sampleRate > 0 ? recordingDisplayEnd(startSample / sampleRate + progress.getSnapshot().duration) : 0,
|
|
4641
4806
|
[progress, startSample, sampleRate]
|
|
4642
4807
|
);
|
|
4643
|
-
const channelCount =
|
|
4644
|
-
const displayEndSeconds =
|
|
4808
|
+
const channelCount = useSyncExternalStore9(subscribe, getChannelCount, getChannelCount);
|
|
4809
|
+
const displayEndSeconds = useSyncExternalStore9(subscribe, getDisplayEnd, getDisplayEnd);
|
|
4645
4810
|
return { channelCount, displayEndSeconds };
|
|
4646
4811
|
}
|
|
4647
4812
|
|
|
4648
4813
|
// src/hooks/useTrimPreviewView.ts
|
|
4649
|
-
import { useCallback as useCallback23, useMemo as
|
|
4814
|
+
import { useCallback as useCallback23, useMemo as useMemo13, useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
4650
4815
|
var TRIM_EXTENT_STEP_SECONDS = RECORDING_EXTENT_STEP_SECONDS;
|
|
4651
4816
|
var NO_UNSUBSCRIBE = () => {
|
|
4652
4817
|
};
|
|
4653
4818
|
var subscribeToNothing2 = () => NO_UNSUBSCRIBE;
|
|
4654
4819
|
function useSubscribe(source) {
|
|
4655
|
-
return
|
|
4820
|
+
return useMemo13(
|
|
4656
4821
|
() => source ? (onChange) => source.subscribe(onChange) : subscribeToNothing2,
|
|
4657
4822
|
[source]
|
|
4658
4823
|
);
|
|
@@ -4668,8 +4833,8 @@ function usePreviewedClipPeaks(clip, trackId) {
|
|
|
4668
4833
|
const preview2 = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4669
4834
|
return preview2 !== null && preview2.clipId === clipId && preview2.trackId === trackId ? preview2 : null;
|
|
4670
4835
|
}, [source, clipId, trackId]);
|
|
4671
|
-
const preview =
|
|
4672
|
-
return
|
|
4836
|
+
const preview = useSyncExternalStore10(subscribe, getSnapshot, getSnapshot);
|
|
4837
|
+
return useMemo13(
|
|
4673
4838
|
() => {
|
|
4674
4839
|
var _a2;
|
|
4675
4840
|
return preview && peaks ? (_a2 = peaks.peaksFor(preview)) != null ? _a2 : clip : clip;
|
|
@@ -4689,7 +4854,7 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4689
4854
|
if (endSeconds <= durationSeconds) return 0;
|
|
4690
4855
|
return Math.ceil(endSeconds / TRIM_EXTENT_STEP_SECONDS) * TRIM_EXTENT_STEP_SECONDS;
|
|
4691
4856
|
}, [source, sampleRate, durationSeconds]);
|
|
4692
|
-
return
|
|
4857
|
+
return useSyncExternalStore10(subscribe, getSnapshot, getSnapshot);
|
|
4693
4858
|
}
|
|
4694
4859
|
|
|
4695
4860
|
// src/components/WaveformRoot.tsx
|
|
@@ -4703,7 +4868,7 @@ function useSpectrogramIntegration() {
|
|
|
4703
4868
|
const context = use2(SpectrogramIntegrationContext);
|
|
4704
4869
|
if (!context) {
|
|
4705
4870
|
throw new Error(
|
|
4706
|
-
"useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>."
|
|
4871
|
+
"useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram (" + installCommand("@waveform-playlist/spectrogram") + ") and wrap your app with <SpectrogramProvider>."
|
|
4707
4872
|
);
|
|
4708
4873
|
}
|
|
4709
4874
|
return context;
|
|
@@ -4735,6 +4900,7 @@ var TrackRowPositioner = styled2.div.attrs((props) => ({
|
|
|
4735
4900
|
transition: none;
|
|
4736
4901
|
}
|
|
4737
4902
|
`;
|
|
4903
|
+
var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
|
|
4738
4904
|
var ControlSlot = styled2.div.attrs((props) => ({
|
|
4739
4905
|
style: {
|
|
4740
4906
|
height: `${props.$height}px`,
|
|
@@ -4753,6 +4919,7 @@ var ControlSlot = styled2.div.attrs((props) => ({
|
|
|
4753
4919
|
transition: background 0.15s ease-in-out;
|
|
4754
4920
|
}
|
|
4755
4921
|
${(props) => props.$isSelected && `background: ${props.theme.selectedTrackControlsBackground};`}
|
|
4922
|
+
${(props) => props.$isDragSource && `background: ${props.theme.selectedTrackControlsBackground}; box-shadow: ${DRAG_SOURCE_SHADOW};`}
|
|
4756
4923
|
`;
|
|
4757
4924
|
function getTrackChannelCount(trackClipPeaks, recordingChannels) {
|
|
4758
4925
|
const clipChannels = trackClipPeaks.length > 0 ? Math.max(1, ...trackClipPeaks.map((clip) => clip.peaks.data.length)) : 1;
|
|
@@ -4764,21 +4931,21 @@ import React17, {
|
|
|
4764
4931
|
createElement,
|
|
4765
4932
|
Fragment as Fragment2,
|
|
4766
4933
|
useCallback as useCallback25,
|
|
4767
|
-
useMemo as
|
|
4934
|
+
useMemo as useMemo19
|
|
4768
4935
|
} from "react";
|
|
4769
4936
|
import {
|
|
4770
4937
|
Playlist,
|
|
4771
4938
|
PlaylistInfoContext,
|
|
4772
|
-
useTheme as
|
|
4939
|
+
useTheme as useTheme4,
|
|
4773
4940
|
waveformColorToCss as waveformColorToCss3
|
|
4774
4941
|
} from "@waveform-playlist/ui-components";
|
|
4775
4942
|
|
|
4776
4943
|
// src/hooks/useSelectionDrag.ts
|
|
4777
|
-
import { createContext as createContext3, memo as memo2, useLayoutEffect as
|
|
4778
|
-
import { createValueSource as
|
|
4944
|
+
import { createContext as createContext3, memo as memo2, useLayoutEffect as useLayoutEffect8, useMemo as useMemo14, useRef as useRef25, useState as useState18 } from "react";
|
|
4945
|
+
import { createValueSource as createValueSource3 } from "@waveform-playlist/core";
|
|
4779
4946
|
|
|
4780
4947
|
// src/hooks/useWindowDrag.ts
|
|
4781
|
-
import { useEffect as
|
|
4948
|
+
import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect7, useRef as useRef24 } from "react";
|
|
4782
4949
|
var activeDrags = 0;
|
|
4783
4950
|
var userSelectBeforeDrags = "";
|
|
4784
4951
|
var webkitUserSelectBeforeDrags = "";
|
|
@@ -4800,11 +4967,11 @@ function suspendTextSelection() {
|
|
|
4800
4967
|
};
|
|
4801
4968
|
}
|
|
4802
4969
|
function useWindowDrag(active, onMove, onEnd) {
|
|
4803
|
-
const callbacksRef =
|
|
4804
|
-
|
|
4970
|
+
const callbacksRef = useRef24({ onMove, onEnd });
|
|
4971
|
+
useLayoutEffect7(() => {
|
|
4805
4972
|
callbacksRef.current = { onMove, onEnd };
|
|
4806
4973
|
});
|
|
4807
|
-
|
|
4974
|
+
useEffect12(() => {
|
|
4808
4975
|
if (!active) return;
|
|
4809
4976
|
const move = (event) => {
|
|
4810
4977
|
if ((event.buttons & 1) === 0) {
|
|
@@ -4845,7 +5012,7 @@ var AutomaticScrollFlag = memo2(function AutomaticScrollFlag2({
|
|
|
4845
5012
|
flagRef
|
|
4846
5013
|
}) {
|
|
4847
5014
|
const { isAutomaticScroll } = usePlaylistSettings();
|
|
4848
|
-
|
|
5015
|
+
useLayoutEffect8(() => {
|
|
4849
5016
|
flagRef.current = isAutomaticScroll;
|
|
4850
5017
|
});
|
|
4851
5018
|
return null;
|
|
@@ -4859,11 +5026,11 @@ function useSelectionDrag({
|
|
|
4859
5026
|
const { isPlaying } = useIsPlaying();
|
|
4860
5027
|
const { setSelection } = usePlaybackControls();
|
|
4861
5028
|
const [isSelecting, setIsSelecting] = useState18(false);
|
|
4862
|
-
const automaticScrollRef =
|
|
4863
|
-
const previewHandle =
|
|
4864
|
-
const pressTimeRef =
|
|
4865
|
-
const wroteSelectionRef =
|
|
4866
|
-
const dragElementRef =
|
|
5029
|
+
const automaticScrollRef = useRef25(false);
|
|
5030
|
+
const previewHandle = useMemo14(() => createValueSource3(null), []);
|
|
5031
|
+
const pressTimeRef = useRef25(0);
|
|
5032
|
+
const wroteSelectionRef = useRef25(false);
|
|
5033
|
+
const dragElementRef = useRef25(null);
|
|
4867
5034
|
const timeAt = (clientX) => {
|
|
4868
5035
|
const element = dragElementRef.current;
|
|
4869
5036
|
const x = element ? clampedOffsetX(element, clientX) : null;
|
|
@@ -4954,8 +5121,8 @@ import React9, {
|
|
|
4954
5121
|
createContext as createContext6,
|
|
4955
5122
|
useCallback as useCallback24,
|
|
4956
5123
|
use as use5,
|
|
4957
|
-
useMemo as
|
|
4958
|
-
useSyncExternalStore as
|
|
5124
|
+
useMemo as useMemo16,
|
|
5125
|
+
useSyncExternalStore as useSyncExternalStore11
|
|
4959
5126
|
} from "react";
|
|
4960
5127
|
import {
|
|
4961
5128
|
Track as TrackComponent,
|
|
@@ -4971,7 +5138,7 @@ import {
|
|
|
4971
5138
|
} from "@waveform-playlist/core";
|
|
4972
5139
|
|
|
4973
5140
|
// src/contexts/ClipInteractionContext.tsx
|
|
4974
|
-
import { createContext as createContext5, use as use4, useMemo as
|
|
5141
|
+
import { createContext as createContext5, use as use4, useMemo as useMemo15 } from "react";
|
|
4975
5142
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
4976
5143
|
var NO_CLIP_INTERACTION = { enabled: false, touchOptimized: false };
|
|
4977
5144
|
var ClipInteractionContext = createContext5(NO_CLIP_INTERACTION);
|
|
@@ -4983,7 +5150,7 @@ var ClipInteractionOptions = ({
|
|
|
4983
5150
|
const inherited = use4(ClipInteractionContext);
|
|
4984
5151
|
const enabled = enabledProp != null ? enabledProp : inherited.enabled;
|
|
4985
5152
|
const touchOptimized = touchOptimizedProp != null ? touchOptimizedProp : inherited.touchOptimized;
|
|
4986
|
-
const value =
|
|
5153
|
+
const value = useMemo15(() => ({ enabled, touchOptimized }), [enabled, touchOptimized]);
|
|
4987
5154
|
return /* @__PURE__ */ jsx6(ClipInteractionContext, { value, children });
|
|
4988
5155
|
};
|
|
4989
5156
|
function useClipInteraction() {
|
|
@@ -4994,7 +5161,7 @@ function useClipInteractionEnabled() {
|
|
|
4994
5161
|
}
|
|
4995
5162
|
|
|
4996
5163
|
// src/components/ChannelWithProgress.tsx
|
|
4997
|
-
import { useId as useId2, useRef as
|
|
5164
|
+
import { useId as useId2, useRef as useRef26, useEffect as useEffect13 } from "react";
|
|
4998
5165
|
import styled3 from "styled-components";
|
|
4999
5166
|
import {
|
|
5000
5167
|
clipPixelWidth as computeClipPixelWidth
|
|
@@ -5058,7 +5225,7 @@ var ClipProgress = ({
|
|
|
5058
5225
|
height,
|
|
5059
5226
|
top
|
|
5060
5227
|
}) => {
|
|
5061
|
-
const progressRef =
|
|
5228
|
+
const progressRef = useRef26(null);
|
|
5062
5229
|
const callbackId = useId2();
|
|
5063
5230
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
5064
5231
|
const { isPlaying } = useIsPlaying();
|
|
@@ -5070,7 +5237,7 @@ var ClipProgress = ({
|
|
|
5070
5237
|
clipDurationSamples,
|
|
5071
5238
|
samplesPerPixel
|
|
5072
5239
|
);
|
|
5073
|
-
|
|
5240
|
+
useEffect13(() => {
|
|
5074
5241
|
if (isPlaying) {
|
|
5075
5242
|
registerFrameCallback(callbackId, ({ visualTime, sampleRate: sr }) => {
|
|
5076
5243
|
if (progressRef.current) {
|
|
@@ -5088,7 +5255,7 @@ var ClipProgress = ({
|
|
|
5088
5255
|
registerFrameCallback,
|
|
5089
5256
|
unregisterFrameCallback
|
|
5090
5257
|
]);
|
|
5091
|
-
|
|
5258
|
+
useEffect13(() => {
|
|
5092
5259
|
var _a, _b;
|
|
5093
5260
|
if (!isPlaying && progressRef.current) {
|
|
5094
5261
|
const currentTime = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -5294,7 +5461,7 @@ var RecordingPreviewClip = ({
|
|
|
5294
5461
|
const source = recordingState.progress;
|
|
5295
5462
|
const subscribe = useCallback24((onChange) => source.subscribe(onChange), [source]);
|
|
5296
5463
|
const getSnapshot = useCallback24(() => source.getSnapshot(), [source]);
|
|
5297
|
-
const progress =
|
|
5464
|
+
const progress = useSyncExternalStore11(subscribe, getSnapshot, getSnapshot);
|
|
5298
5465
|
const durationSamples = Math.floor(progress.duration * sampleRate);
|
|
5299
5466
|
const latencyOffsetSamples = resolveRecordingOffsetSamples({
|
|
5300
5467
|
overrideSeconds: recordingState.latencyOffset,
|
|
@@ -5504,7 +5671,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5504
5671
|
const { selectTrack } = rows;
|
|
5505
5672
|
const registerSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.registerSpectrogramCanvas;
|
|
5506
5673
|
const unregisterSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.unregisterSpectrogramCanvas;
|
|
5507
|
-
const clipDisplay =
|
|
5674
|
+
const clipDisplay = useMemo16(
|
|
5508
5675
|
() => ({
|
|
5509
5676
|
gainScaledWaveforms: gainScaled,
|
|
5510
5677
|
showFades,
|
|
@@ -5518,8 +5685,8 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5518
5685
|
var _a, _b;
|
|
5519
5686
|
const track = rowList[trackIndex];
|
|
5520
5687
|
if (!track) return null;
|
|
5521
|
-
const
|
|
5522
|
-
const recordingChannels =
|
|
5688
|
+
const isRecordingTrack = (recordingState == null ? void 0 : recordingState.isRecording) === true && recordingState.trackId === track.id;
|
|
5689
|
+
const recordingChannels = isRecordingTrack ? recordingChannelCount : 0;
|
|
5523
5690
|
const helpers = spectrogramHelpersById.get(track.id);
|
|
5524
5691
|
return /* @__PURE__ */ jsx8(
|
|
5525
5692
|
TrackRow,
|
|
@@ -5537,7 +5704,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5537
5704
|
numChannels: getTrackChannelCount(trackClipPeaks, recordingChannels),
|
|
5538
5705
|
waveHeight,
|
|
5539
5706
|
mono,
|
|
5540
|
-
recordingState:
|
|
5707
|
+
recordingState: isRecordingTrack ? recordingState : void 0,
|
|
5541
5708
|
spectrogramConfig: helpers == null ? void 0 : helpers.config,
|
|
5542
5709
|
frequencyScaleFn: helpers == null ? void 0 : helpers.frequencyScaleFn,
|
|
5543
5710
|
samplesPerPixel,
|
|
@@ -5550,8 +5717,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5550
5717
|
};
|
|
5551
5718
|
|
|
5552
5719
|
// src/components/TrackControlsColumn.tsx
|
|
5553
|
-
import React12, { use as use9, useMemo as
|
|
5554
|
-
import { useTheme as useTheme3 } from "@waveform-playlist/ui-components";
|
|
5720
|
+
import React12, { use as use9, useMemo as useMemo17, useRef as useRef29, useState as useState20 } from "react";
|
|
5555
5721
|
|
|
5556
5722
|
// src/components/DefaultTrackControls.tsx
|
|
5557
5723
|
import React11 from "react";
|
|
@@ -5559,7 +5725,8 @@ import styled4 from "styled-components";
|
|
|
5559
5725
|
import { ButtonGroup, Controls, Header } from "@waveform-playlist/ui-components";
|
|
5560
5726
|
|
|
5561
5727
|
// src/components/TrackControlPieces.tsx
|
|
5562
|
-
import { use as use8 } from "react";
|
|
5728
|
+
import { use as use8, useEffect as useEffect15, useRef as useRef27, useState as useState19 } from "react";
|
|
5729
|
+
import { createMixerGesture } from "@waveform-playlist/core";
|
|
5563
5730
|
import {
|
|
5564
5731
|
Button,
|
|
5565
5732
|
CloseButton,
|
|
@@ -5587,7 +5754,7 @@ var TrackControlsSharedContext = createContext7(null);
|
|
|
5587
5754
|
var TrackSlotWiringContext = createContext7(null);
|
|
5588
5755
|
|
|
5589
5756
|
// src/hooks/useTrackReorderHandle.ts
|
|
5590
|
-
import { use as use7, useEffect as
|
|
5757
|
+
import { use as use7, useEffect as useEffect14 } from "react";
|
|
5591
5758
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
5592
5759
|
import { RestrictToVerticalAxis } from "@dnd-kit/abstract/modifiers";
|
|
5593
5760
|
import { Feedback } from "@dnd-kit/dom";
|
|
@@ -5620,7 +5787,7 @@ function createDragPopoverHealer(element) {
|
|
|
5620
5787
|
}
|
|
5621
5788
|
|
|
5622
5789
|
// src/hooks/useTrackReorderHandle.ts
|
|
5623
|
-
var MOVE_FEEDBACK = Feedback.configure({ feedback: "move" });
|
|
5790
|
+
var MOVE_FEEDBACK = Feedback.configure({ feedback: "move", dropAnimation: null });
|
|
5624
5791
|
var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
|
|
5625
5792
|
function useTrackReorderHandle() {
|
|
5626
5793
|
const { id, index } = useTrack();
|
|
@@ -5647,10 +5814,9 @@ function useTrackReorderHandle() {
|
|
|
5647
5814
|
// `placeholder.replaceWith(element)` on drop) — confirmed via
|
|
5648
5815
|
// MutationObserver instrumentation to relocate the React-owned row 6
|
|
5649
5816
|
// times during a single one-slot drag, leaving its final parent/sibling
|
|
5650
|
-
// different from what React's fiber tree still believes.
|
|
5651
|
-
//
|
|
5652
|
-
//
|
|
5653
|
-
// for these rows. The placeholder splice is created only when
|
|
5817
|
+
// different from what React's fiber tree still believes. (Measured when
|
|
5818
|
+
// the registered element was one level inside the keyed slot, before
|
|
5819
|
+
// #796; not re-run with the slot itself.) The placeholder splice is created only when
|
|
5654
5820
|
// `feedback !== 'move'` (@dnd-kit/dom Feedback.ts) — 'move' keeps the
|
|
5655
5821
|
// dragged element in the live DOM (no clone/placeholder) while still
|
|
5656
5822
|
// running the *unconditional* `dragOperation.shape = ...` assignment.
|
|
@@ -5662,15 +5828,18 @@ function useTrackReorderHandle() {
|
|
|
5662
5828
|
// drag-based reordering silently never commits. Boundary trims don't hit
|
|
5663
5829
|
// this because they're plain useDraggable (no collision-based commit) —
|
|
5664
5830
|
// sortables need shape. `isDragSource` is a reactive signal, unaffected
|
|
5665
|
-
// either way.
|
|
5831
|
+
// either way. OptimisticSortingPlugin still moves the element during the
|
|
5832
|
+
// drag (`insertAdjacentElement` next to the item it is dragged over);
|
|
5833
|
+
// that is safe only because the element is the keyed slot (#796, below).
|
|
5834
|
+
// See browser/notes/track-controls-and-reorder.md "Track Reordering".
|
|
5666
5835
|
plugins: withMoveFeedback
|
|
5667
5836
|
});
|
|
5668
|
-
|
|
5837
|
+
useEffect14(() => {
|
|
5669
5838
|
if (!wiring) return void 0;
|
|
5670
5839
|
ref(wiring.elementRef.current);
|
|
5671
5840
|
return () => ref(null);
|
|
5672
5841
|
}, [ref, wiring]);
|
|
5673
|
-
|
|
5842
|
+
useEffect14(() => {
|
|
5674
5843
|
if (!wiring) return void 0;
|
|
5675
5844
|
const { handleCount } = wiring;
|
|
5676
5845
|
handleCount.current += 1;
|
|
@@ -5683,12 +5852,12 @@ function useTrackReorderHandle() {
|
|
|
5683
5852
|
handleCount.current -= 1;
|
|
5684
5853
|
};
|
|
5685
5854
|
}, [wiring]);
|
|
5686
|
-
|
|
5855
|
+
useEffect14(() => {
|
|
5687
5856
|
if (!wiring) return void 0;
|
|
5688
5857
|
wiring.setDragSource(isDragSource);
|
|
5689
5858
|
return () => wiring.setDragSource(false);
|
|
5690
5859
|
}, [isDragSource, wiring]);
|
|
5691
|
-
|
|
5860
|
+
useEffect14(() => {
|
|
5692
5861
|
const element = wiring == null ? void 0 : wiring.elementRef.current;
|
|
5693
5862
|
if (!isDragSource || !element) return void 0;
|
|
5694
5863
|
return createDragPopoverHealer(element);
|
|
@@ -5711,13 +5880,13 @@ var TrackName = () => {
|
|
|
5711
5880
|
return /* @__PURE__ */ jsx9("span", { "data-track-name": "", style: NAME_STYLE, children: name });
|
|
5712
5881
|
};
|
|
5713
5882
|
var TrackMuteButton = () => {
|
|
5714
|
-
const { muted, setMuted,
|
|
5883
|
+
const { muted, setMuted, isRecording } = useTrack();
|
|
5715
5884
|
return /* @__PURE__ */ jsx9(
|
|
5716
5885
|
Button,
|
|
5717
5886
|
{
|
|
5718
5887
|
$variant: muted ? "danger" : "outline",
|
|
5719
5888
|
"aria-pressed": muted,
|
|
5720
|
-
disabled:
|
|
5889
|
+
disabled: isRecording,
|
|
5721
5890
|
onClick: () => setMuted(!muted),
|
|
5722
5891
|
children: "Mute"
|
|
5723
5892
|
}
|
|
@@ -5735,8 +5904,18 @@ var TrackSoloButton = () => {
|
|
|
5735
5904
|
}
|
|
5736
5905
|
);
|
|
5737
5906
|
};
|
|
5907
|
+
function useSliderGesture() {
|
|
5908
|
+
const [gesture] = useState19(createMixerGesture);
|
|
5909
|
+
const ref = useRef27(null);
|
|
5910
|
+
useEffect15(() => {
|
|
5911
|
+
const input = ref.current;
|
|
5912
|
+
return input ? gesture.attach(input) : void 0;
|
|
5913
|
+
}, [gesture]);
|
|
5914
|
+
return { gesture, ref };
|
|
5915
|
+
}
|
|
5738
5916
|
var TrackVolumeSlider = () => {
|
|
5739
5917
|
const { volume, setVolume } = useTrack();
|
|
5918
|
+
const { gesture, ref } = useSliderGesture();
|
|
5740
5919
|
return /* @__PURE__ */ jsxs3(SliderWrapper, { children: [
|
|
5741
5920
|
/* @__PURE__ */ jsx9(VolumeDownIcon, {}),
|
|
5742
5921
|
/* @__PURE__ */ jsx9(
|
|
@@ -5745,9 +5924,10 @@ var TrackVolumeSlider = () => {
|
|
|
5745
5924
|
min: "0",
|
|
5746
5925
|
max: "1",
|
|
5747
5926
|
step: "0.01",
|
|
5927
|
+
ref,
|
|
5748
5928
|
value: volume,
|
|
5749
5929
|
"aria-label": "Volume",
|
|
5750
|
-
onChange: (e) => setVolume(parseFloat(e.target.value))
|
|
5930
|
+
onChange: (e) => setVolume(parseFloat(e.target.value), { gesture: gesture.id })
|
|
5751
5931
|
}
|
|
5752
5932
|
),
|
|
5753
5933
|
/* @__PURE__ */ jsx9(VolumeUpIcon, {})
|
|
@@ -5755,6 +5935,7 @@ var TrackVolumeSlider = () => {
|
|
|
5755
5935
|
};
|
|
5756
5936
|
var TrackPanSlider = () => {
|
|
5757
5937
|
const { pan, setPan } = useTrack();
|
|
5938
|
+
const { gesture, ref } = useSliderGesture();
|
|
5758
5939
|
return /* @__PURE__ */ jsxs3(SliderWrapper, { children: [
|
|
5759
5940
|
/* @__PURE__ */ jsx9("span", { children: "L" }),
|
|
5760
5941
|
/* @__PURE__ */ jsx9(
|
|
@@ -5763,9 +5944,10 @@ var TrackPanSlider = () => {
|
|
|
5763
5944
|
min: "-1",
|
|
5764
5945
|
max: "1",
|
|
5765
5946
|
step: "0.01",
|
|
5947
|
+
ref,
|
|
5766
5948
|
value: pan,
|
|
5767
5949
|
"aria-label": "Pan",
|
|
5768
|
-
onChange: (e) => setPan(parseFloat(e.target.value))
|
|
5950
|
+
onChange: (e) => setPan(parseFloat(e.target.value), { gesture: gesture.id })
|
|
5769
5951
|
}
|
|
5770
5952
|
),
|
|
5771
5953
|
/* @__PURE__ */ jsx9("span", { children: "R" })
|
|
@@ -5856,7 +6038,7 @@ function DefaultTrackControlsImpl({ children }) {
|
|
|
5856
6038
|
var DefaultTrackControls = React11.memo(DefaultTrackControlsImpl);
|
|
5857
6039
|
|
|
5858
6040
|
// src/utils/stableTemplate.ts
|
|
5859
|
-
import { isValidElement, useRef as
|
|
6041
|
+
import { isValidElement, useRef as useRef28 } from "react";
|
|
5860
6042
|
function sameStyle(a, b) {
|
|
5861
6043
|
if (Object.is(a, b)) return true;
|
|
5862
6044
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
@@ -5886,7 +6068,7 @@ function sameTemplate(a, b) {
|
|
|
5886
6068
|
return false;
|
|
5887
6069
|
}
|
|
5888
6070
|
function useStableTemplate(template) {
|
|
5889
|
-
const kept =
|
|
6071
|
+
const kept = useRef28(template);
|
|
5890
6072
|
if (!sameTemplate(kept.current, template)) {
|
|
5891
6073
|
kept.current = template;
|
|
5892
6074
|
}
|
|
@@ -5897,7 +6079,6 @@ function useStableTemplate(template) {
|
|
|
5897
6079
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
5898
6080
|
var DEFAULT_TRACK_CONTROLS_WIDTH = 200;
|
|
5899
6081
|
var DEFAULT_TEMPLATE = /* @__PURE__ */ jsx11(DefaultTrackControls, {});
|
|
5900
|
-
var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
|
|
5901
6082
|
var SLOT_BODY_STYLE = { height: "100%" };
|
|
5902
6083
|
function TrackControlsSlotImpl({
|
|
5903
6084
|
trackId,
|
|
@@ -5913,7 +6094,7 @@ function TrackControlsSlotImpl({
|
|
|
5913
6094
|
isLast,
|
|
5914
6095
|
renderMode,
|
|
5915
6096
|
hasSpectrogram,
|
|
5916
|
-
|
|
6097
|
+
isRecording,
|
|
5917
6098
|
height,
|
|
5918
6099
|
top,
|
|
5919
6100
|
animate,
|
|
@@ -5927,16 +6108,15 @@ function TrackControlsSlotImpl({
|
|
|
5927
6108
|
reorderTrack,
|
|
5928
6109
|
setSelectedTrackId
|
|
5929
6110
|
} = useEditorControls();
|
|
5930
|
-
const theme = useTheme3();
|
|
5931
6111
|
const shared = use9(TrackControlsSharedContext);
|
|
5932
|
-
const indexRef =
|
|
6112
|
+
const indexRef = useRef29(index);
|
|
5933
6113
|
indexRef.current = index;
|
|
5934
|
-
const actions =
|
|
6114
|
+
const actions = useMemo17(
|
|
5935
6115
|
() => ({
|
|
5936
|
-
setMuted: (value2) => setTrackMute(trackId, value2),
|
|
5937
|
-
setSoloed: (value2) => setTrackSolo(trackId, value2),
|
|
5938
|
-
setVolume: (value2) => setTrackVolume(trackId, value2),
|
|
5939
|
-
setPan: (value2) => setTrackPan(trackId, value2),
|
|
6116
|
+
setMuted: (value2, options) => setTrackMute(trackId, value2, options),
|
|
6117
|
+
setSoloed: (value2, options) => setTrackSolo(trackId, value2, options),
|
|
6118
|
+
setVolume: (value2, options) => setTrackVolume(trackId, value2, options),
|
|
6119
|
+
setPan: (value2, options) => setTrackPan(trackId, value2, options),
|
|
5940
6120
|
select: () => setSelectedTrackId(trackId),
|
|
5941
6121
|
// The engine clamps the target and ignores a move to the same place.
|
|
5942
6122
|
moveUp: () => reorderTrack(trackId, indexRef.current - 1),
|
|
@@ -5955,7 +6135,7 @@ function TrackControlsSlotImpl({
|
|
|
5955
6135
|
shared
|
|
5956
6136
|
]
|
|
5957
6137
|
);
|
|
5958
|
-
const value =
|
|
6138
|
+
const value = useMemo17(
|
|
5959
6139
|
() => __spreadValues({
|
|
5960
6140
|
id: trackId,
|
|
5961
6141
|
kind,
|
|
@@ -5970,7 +6150,7 @@ function TrackControlsSlotImpl({
|
|
|
5970
6150
|
isFirst,
|
|
5971
6151
|
isLast,
|
|
5972
6152
|
hasSpectrogram,
|
|
5973
|
-
|
|
6153
|
+
isRecording
|
|
5974
6154
|
}, actions),
|
|
5975
6155
|
[
|
|
5976
6156
|
trackId,
|
|
@@ -5986,40 +6166,27 @@ function TrackControlsSlotImpl({
|
|
|
5986
6166
|
isFirst,
|
|
5987
6167
|
isLast,
|
|
5988
6168
|
hasSpectrogram,
|
|
5989
|
-
|
|
6169
|
+
isRecording,
|
|
5990
6170
|
actions
|
|
5991
6171
|
]
|
|
5992
6172
|
);
|
|
5993
|
-
const elementRef =
|
|
5994
|
-
const [isDragSource, setDragSource] =
|
|
5995
|
-
const wiring =
|
|
6173
|
+
const elementRef = useRef29(null);
|
|
6174
|
+
const [isDragSource, setDragSource] = useState20(false);
|
|
6175
|
+
const wiring = useMemo17(
|
|
5996
6176
|
() => ({ elementRef, setDragSource, handleCount: { current: 0 } }),
|
|
5997
6177
|
[]
|
|
5998
6178
|
);
|
|
5999
6179
|
return /* @__PURE__ */ jsx11(
|
|
6000
6180
|
ControlSlot,
|
|
6001
6181
|
{
|
|
6182
|
+
ref: elementRef,
|
|
6002
6183
|
$height: height,
|
|
6003
6184
|
$top: top,
|
|
6004
6185
|
$animate: animate,
|
|
6005
6186
|
$isSelected: isSelected,
|
|
6187
|
+
$isDragSource: isDragSource,
|
|
6006
6188
|
onClick: actions.select,
|
|
6007
|
-
children: /* @__PURE__ */ jsx11(
|
|
6008
|
-
"div",
|
|
6009
|
-
{
|
|
6010
|
-
ref: elementRef,
|
|
6011
|
-
"data-track-controls": trackId,
|
|
6012
|
-
style: isDragSource ? __spreadProps(__spreadValues({}, SLOT_BODY_STYLE), {
|
|
6013
|
-
boxShadow: DRAG_SOURCE_SHADOW,
|
|
6014
|
-
// Opaque background for the floating (top-layer, popover-based)
|
|
6015
|
-
// drag-source row — without it the row underneath shows through.
|
|
6016
|
-
// onDragStart selects the dragged track, so its slot always shows
|
|
6017
|
-
// the selected-track background while lifted.
|
|
6018
|
-
background: theme.selectedTrackControlsBackground
|
|
6019
|
-
}) : SLOT_BODY_STYLE,
|
|
6020
|
-
children: /* @__PURE__ */ jsx11(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ jsx11(TrackContext, { value, children: template }) })
|
|
6021
|
-
}
|
|
6022
|
-
)
|
|
6189
|
+
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 }) }) })
|
|
6023
6190
|
}
|
|
6024
6191
|
);
|
|
6025
6192
|
}
|
|
@@ -6031,6 +6198,7 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6031
6198
|
trackLayout,
|
|
6032
6199
|
trackHeightById,
|
|
6033
6200
|
animateTrackLayout,
|
|
6201
|
+
dragSourceTrackId,
|
|
6034
6202
|
setSettingsModalTrackId
|
|
6035
6203
|
} = useWaveformRows("The track controls");
|
|
6036
6204
|
if (use9(WaveformPartPlaceContext) !== "controls") {
|
|
@@ -6039,15 +6207,14 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6039
6207
|
);
|
|
6040
6208
|
}
|
|
6041
6209
|
const { selectedTrackId } = useSelectedTrackId();
|
|
6042
|
-
const {
|
|
6043
|
-
const { trackReorderEpoch } = useTrackReorderPreview();
|
|
6210
|
+
const { recordingTrackId } = useRecordingTrack();
|
|
6044
6211
|
const spectrogram = use9(SpectrogramIntegrationContext);
|
|
6045
6212
|
const { trackStates } = usePlaylistMixer();
|
|
6046
6213
|
const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
|
|
6047
|
-
const spectrogramRef =
|
|
6214
|
+
const spectrogramRef = useRef29(spectrogram);
|
|
6048
6215
|
spectrogramRef.current = spectrogram;
|
|
6049
6216
|
const menuAvailable = Boolean(spectrogram == null ? void 0 : spectrogram.renderMenuItems);
|
|
6050
|
-
const shared =
|
|
6217
|
+
const shared = useMemo17(
|
|
6051
6218
|
() => ({
|
|
6052
6219
|
menuAvailable,
|
|
6053
6220
|
menuItems: (args) => {
|
|
@@ -6067,51 +6234,44 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6067
6234
|
return /* @__PURE__ */ jsx11(TrackControlsSharedContext, { value: shared, children: /* @__PURE__ */ jsx11(TracksLayout, { $height: trackLayout.totalHeight, children: tracks.map((track, trackIndex) => {
|
|
6068
6235
|
var _a, _b, _c;
|
|
6069
6236
|
const state = trackStates[trackIndex];
|
|
6070
|
-
return (
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
|
|
6094
|
-
top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
|
|
6095
|
-
animate: animateTrackLayout,
|
|
6096
|
-
template
|
|
6097
|
-
},
|
|
6098
|
-
`${track.id}-${trackReorderEpoch}`
|
|
6099
|
-
)
|
|
6237
|
+
return /* @__PURE__ */ jsx11(
|
|
6238
|
+
TrackControlsSlot,
|
|
6239
|
+
{
|
|
6240
|
+
trackId: track.id,
|
|
6241
|
+
index: trackIndex,
|
|
6242
|
+
kind: track.kind,
|
|
6243
|
+
name: state.name,
|
|
6244
|
+
muted: state.muted,
|
|
6245
|
+
soloed: state.soloed,
|
|
6246
|
+
volume: state.volume,
|
|
6247
|
+
pan: state.pan,
|
|
6248
|
+
isSelected: track.id === selectedTrackId,
|
|
6249
|
+
isFirst: trackIndex === 0,
|
|
6250
|
+
isLast: trackIndex === tracks.length - 1,
|
|
6251
|
+
renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
|
|
6252
|
+
hasSpectrogram: spectrogram !== null && track.kind !== "midi",
|
|
6253
|
+
isRecording: track.id === recordingTrackId,
|
|
6254
|
+
height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
|
|
6255
|
+
top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
|
|
6256
|
+
animate: animateTrackLayout && dragSourceTrackId !== null,
|
|
6257
|
+
template
|
|
6258
|
+
},
|
|
6259
|
+
track.id
|
|
6100
6260
|
);
|
|
6101
6261
|
}) }) });
|
|
6102
6262
|
}
|
|
6103
6263
|
var WaveformTrackControls = React12.memo(WaveformTrackControlsImpl);
|
|
6104
6264
|
|
|
6105
6265
|
// src/components/VisualizationOverlays.tsx
|
|
6106
|
-
import React14, { use as use10, useSyncExternalStore as
|
|
6266
|
+
import React14, { use as use10, useSyncExternalStore as useSyncExternalStore12 } from "react";
|
|
6107
6267
|
import {
|
|
6108
6268
|
Selection,
|
|
6109
6269
|
TimescaleLoopRegion,
|
|
6110
|
-
useTheme as
|
|
6270
|
+
useTheme as useTheme3
|
|
6111
6271
|
} from "@waveform-playlist/ui-components";
|
|
6112
6272
|
|
|
6113
6273
|
// src/components/AnimatedPlayhead.tsx
|
|
6114
|
-
import { useRef as
|
|
6274
|
+
import { useRef as useRef30, useEffect as useEffect16, useId as useId3 } from "react";
|
|
6115
6275
|
import styled5 from "styled-components";
|
|
6116
6276
|
import { usePlaylistInfo as usePlaylistInfo3 } from "@waveform-playlist/ui-components";
|
|
6117
6277
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
@@ -6130,7 +6290,7 @@ var PlayheadLine = styled5.div.attrs((props) => ({
|
|
|
6130
6290
|
will-change: transform;
|
|
6131
6291
|
`;
|
|
6132
6292
|
var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
6133
|
-
const playheadRef =
|
|
6293
|
+
const playheadRef = useRef30(null);
|
|
6134
6294
|
const frameCallbackId = useId3();
|
|
6135
6295
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
6136
6296
|
const { isPlaying } = useIsPlaying();
|
|
@@ -6138,7 +6298,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6138
6298
|
const { sampleRate } = usePlaylistView();
|
|
6139
6299
|
const { progressBarWidth } = usePlaylistInfo3();
|
|
6140
6300
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6141
|
-
|
|
6301
|
+
useEffect16(() => {
|
|
6142
6302
|
if (isPlaying) {
|
|
6143
6303
|
registerFrameCallback(
|
|
6144
6304
|
frameCallbackId,
|
|
@@ -6152,7 +6312,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6152
6312
|
}
|
|
6153
6313
|
return () => unregisterFrameCallback(frameCallbackId);
|
|
6154
6314
|
}, [isPlaying, frameCallbackId, registerFrameCallback, unregisterFrameCallback]);
|
|
6155
|
-
|
|
6315
|
+
useEffect16(() => {
|
|
6156
6316
|
var _a, _b;
|
|
6157
6317
|
if (!isPlaying && playheadRef.current) {
|
|
6158
6318
|
const time = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -6169,12 +6329,12 @@ var subscribeToNothing3 = () => () => {
|
|
|
6169
6329
|
};
|
|
6170
6330
|
var noPreview = () => null;
|
|
6171
6331
|
var WaveformSelection = React14.memo(function WaveformSelection2() {
|
|
6172
|
-
const theme =
|
|
6332
|
+
const theme = useTheme3();
|
|
6173
6333
|
const { selectionStart, selectionEnd } = useSelection();
|
|
6174
6334
|
const { sampleRate } = usePlaylistView();
|
|
6175
6335
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6176
6336
|
const previewSource = use10(SelectionPreviewContext);
|
|
6177
|
-
const preview =
|
|
6337
|
+
const preview = useSyncExternalStore12(
|
|
6178
6338
|
previewSource ? (onChange) => previewSource.subscribe(onChange) : subscribeToNothing3,
|
|
6179
6339
|
previewSource ? () => previewSource.getSnapshot() : noPreview,
|
|
6180
6340
|
previewSource ? () => previewSource.getSnapshot() : noPreview
|
|
@@ -6208,7 +6368,7 @@ var CustomPlayhead = ({ renderPlayhead, color, samplesPerPixel, sampleRate }) =>
|
|
|
6208
6368
|
});
|
|
6209
6369
|
};
|
|
6210
6370
|
var WaveformPlayhead = ({ renderPlayhead }) => {
|
|
6211
|
-
const theme =
|
|
6371
|
+
const theme = useTheme3();
|
|
6212
6372
|
const { isPlaying } = useIsPlaying();
|
|
6213
6373
|
const { selectionStart, selectionEnd } = useSelection();
|
|
6214
6374
|
const { sampleRate } = usePlaylistView();
|
|
@@ -6231,7 +6391,7 @@ var WaveformLoopRegion = React14.memo(function WaveformLoopRegion2() {
|
|
|
6231
6391
|
"<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."
|
|
6232
6392
|
);
|
|
6233
6393
|
}
|
|
6234
|
-
const theme =
|
|
6394
|
+
const theme = useTheme3();
|
|
6235
6395
|
const { isLoopEnabled, loopStart, loopEnd } = useLoop();
|
|
6236
6396
|
const { setLoopRegion } = useEditorControls();
|
|
6237
6397
|
const { sampleRate } = usePlaylistView();
|
|
@@ -6256,7 +6416,7 @@ var WaveformLoopRegion = React14.memo(function WaveformLoopRegion2() {
|
|
|
6256
6416
|
});
|
|
6257
6417
|
|
|
6258
6418
|
// src/components/WaveformViewOptions.tsx
|
|
6259
|
-
import { createContext as createContext8, use as use11, useMemo as
|
|
6419
|
+
import { createContext as createContext8, use as use11, useMemo as useMemo18 } from "react";
|
|
6260
6420
|
import {
|
|
6261
6421
|
DEFAULT_BAR_GAP,
|
|
6262
6422
|
DEFAULT_BAR_WIDTH,
|
|
@@ -6281,7 +6441,7 @@ var WaveformViewOptions = ({
|
|
|
6281
6441
|
const roundedBars = ownRoundedBars != null ? ownRoundedBars : above.roundedBars;
|
|
6282
6442
|
const progressBarWidth = ownProgressBarWidth != null ? ownProgressBarWidth : above.progressBarWidth;
|
|
6283
6443
|
const fillViewport = ownFillViewport != null ? ownFillViewport : above.fillViewport;
|
|
6284
|
-
const value =
|
|
6444
|
+
const value = useMemo18(
|
|
6285
6445
|
() => ({ waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport }),
|
|
6286
6446
|
[waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport]
|
|
6287
6447
|
);
|
|
@@ -6435,7 +6595,7 @@ function keyedByKind(parts) {
|
|
|
6435
6595
|
});
|
|
6436
6596
|
}
|
|
6437
6597
|
function useWaveformParts(children) {
|
|
6438
|
-
return
|
|
6598
|
+
return useMemo19(() => {
|
|
6439
6599
|
const sorted = sortWaveformParts(children);
|
|
6440
6600
|
return {
|
|
6441
6601
|
// One element per place. The tracks-area and controls parts are its
|
|
@@ -6465,7 +6625,7 @@ function useWaveformFrame({
|
|
|
6465
6625
|
onClickWhileStopped
|
|
6466
6626
|
}) {
|
|
6467
6627
|
var _a;
|
|
6468
|
-
const theme =
|
|
6628
|
+
const theme = useTheme4();
|
|
6469
6629
|
const { setScrollContainer } = usePlaybackControls();
|
|
6470
6630
|
const { sampleRate } = usePlaylistView();
|
|
6471
6631
|
const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
|
|
@@ -6485,7 +6645,7 @@ function useWaveformFrame({
|
|
|
6485
6645
|
preview: selectionPreview,
|
|
6486
6646
|
automaticScrollRef
|
|
6487
6647
|
} = useSelectionDrag({ samplesPerPixel, sampleRate, onPress, onClickWhileStopped });
|
|
6488
|
-
const playlistInfo =
|
|
6648
|
+
const playlistInfo = useMemo19(
|
|
6489
6649
|
() => ({
|
|
6490
6650
|
samplesPerPixel,
|
|
6491
6651
|
sampleRate,
|
|
@@ -6507,7 +6667,7 @@ function useWaveformFrame({
|
|
|
6507
6667
|
progressBarWidth
|
|
6508
6668
|
]
|
|
6509
6669
|
);
|
|
6510
|
-
const extent =
|
|
6670
|
+
const extent = useMemo19(
|
|
6511
6671
|
() => ({ displayDuration, tracksFullWidth }),
|
|
6512
6672
|
[displayDuration, tracksFullWidth]
|
|
6513
6673
|
);
|
|
@@ -6558,7 +6718,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6558
6718
|
const spectrogram = use13(SpectrogramIntegrationContext);
|
|
6559
6719
|
const parts = useWaveformParts(children);
|
|
6560
6720
|
const { showClipHeaders, recordingState } = parts.tracksOptions;
|
|
6561
|
-
const spectrogramHelpersById =
|
|
6721
|
+
const spectrogramHelpersById = useMemo20(() => {
|
|
6562
6722
|
const helpers = /* @__PURE__ */ new Map();
|
|
6563
6723
|
if (!spectrogram) return helpers;
|
|
6564
6724
|
tracks.forEach((track) => {
|
|
@@ -6579,7 +6739,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6579
6739
|
});
|
|
6580
6740
|
return helpers;
|
|
6581
6741
|
}, [tracks, spectrogram]);
|
|
6582
|
-
const renderModeById =
|
|
6742
|
+
const renderModeById = useMemo20(() => {
|
|
6583
6743
|
const modes = /* @__PURE__ */ new Map();
|
|
6584
6744
|
tracks.forEach((track) => {
|
|
6585
6745
|
var _a2;
|
|
@@ -6599,12 +6759,12 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6599
6759
|
const recordingTrackId = (recordingState == null ? void 0 : recordingState.isRecording) ? recordingState.trackId : null;
|
|
6600
6760
|
const trimPreviewEnd = useTrimPreviewExtent(sampleRate, duration);
|
|
6601
6761
|
const recordingChannelCount = recordingProgress ? mono ? 1 : recordingLayout.channelCount : 0;
|
|
6602
|
-
const [settingsModalTrackId, setSettingsModalTrackId] =
|
|
6762
|
+
const [settingsModalTrackId, setSettingsModalTrackId] = useState21(null);
|
|
6603
6763
|
const closeSettingsModal = useCallback26(() => setSettingsModalTrackId(null), []);
|
|
6604
|
-
const [scrollContainerElement, setScrollContainerElement] =
|
|
6764
|
+
const [scrollContainerElement, setScrollContainerElement] = useState21(null);
|
|
6605
6765
|
const fillsContainer = indefinitePlayback || fillViewport;
|
|
6606
|
-
const [scrollContainerWidth, setScrollContainerWidth] =
|
|
6607
|
-
|
|
6766
|
+
const [scrollContainerWidth, setScrollContainerWidth] = useState21(0);
|
|
6767
|
+
useLayoutEffect9(() => {
|
|
6608
6768
|
if (!fillsContainer || !scrollContainerElement) return;
|
|
6609
6769
|
const measure = () => setScrollContainerWidth(scrollContainerElement.clientWidth);
|
|
6610
6770
|
measure();
|
|
@@ -6613,7 +6773,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6613
6773
|
observer.observe(scrollContainerElement);
|
|
6614
6774
|
return () => observer.disconnect();
|
|
6615
6775
|
}, [fillsContainer, scrollContainerElement]);
|
|
6616
|
-
const placeholdersEndSeconds =
|
|
6776
|
+
const placeholdersEndSeconds = useMemo20(() => placeholdersEnd(peaksDataArray), [peaksDataArray]);
|
|
6617
6777
|
let displayDuration = Math.max(
|
|
6618
6778
|
duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION,
|
|
6619
6779
|
placeholdersEndSeconds
|
|
@@ -6626,7 +6786,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6626
6786
|
displayDuration = Math.max(displayDuration, recordingLayout.displayEndSeconds);
|
|
6627
6787
|
}
|
|
6628
6788
|
displayDuration = Math.max(displayDuration, trimPreviewEnd);
|
|
6629
|
-
const tracksRef =
|
|
6789
|
+
const tracksRef = useRef31(tracks);
|
|
6630
6790
|
tracksRef.current = tracks;
|
|
6631
6791
|
const selectTrack = useCallback26(
|
|
6632
6792
|
(trackIndex) => {
|
|
@@ -6637,7 +6797,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6637
6797
|
},
|
|
6638
6798
|
[setSelectedTrackId]
|
|
6639
6799
|
);
|
|
6640
|
-
const trackHeightById =
|
|
6800
|
+
const trackHeightById = useMemo20(() => {
|
|
6641
6801
|
const m = /* @__PURE__ */ new Map();
|
|
6642
6802
|
peaksDataArray.forEach((trackClipPeaks, trackIndex) => {
|
|
6643
6803
|
const track = tracks[trackIndex];
|
|
@@ -6657,21 +6817,21 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6657
6817
|
waveHeight,
|
|
6658
6818
|
showClipHeaders
|
|
6659
6819
|
]);
|
|
6660
|
-
const displayOrderIds =
|
|
6820
|
+
const displayOrderIds = useMemo20(
|
|
6661
6821
|
() => applyTrackOrderPreview(tracks, trackDragPreview).map((t) => t.id),
|
|
6662
6822
|
[tracks, trackDragPreview]
|
|
6663
6823
|
);
|
|
6664
|
-
const trackLayout =
|
|
6824
|
+
const trackLayout = useMemo20(
|
|
6665
6825
|
() => computeTrackLayout(displayOrderIds, trackHeightById),
|
|
6666
6826
|
[displayOrderIds, trackHeightById]
|
|
6667
6827
|
);
|
|
6668
6828
|
const animateTrackLayout = useTrailingActive(trackDragPreview !== null, 200);
|
|
6669
|
-
const rowList =
|
|
6829
|
+
const rowList = useMemo20(
|
|
6670
6830
|
() => tracks.map((track) => ({ id: track.id, kind: trackKind2(track) })),
|
|
6671
6831
|
[tracks]
|
|
6672
6832
|
);
|
|
6673
6833
|
const dragSourceTrackId = (_b = trackDragPreview == null ? void 0 : trackDragPreview.trackId) != null ? _b : null;
|
|
6674
|
-
const rows =
|
|
6834
|
+
const rows = useMemo20(
|
|
6675
6835
|
() => ({
|
|
6676
6836
|
rows: rowList,
|
|
6677
6837
|
peaksDataArray,
|
|
@@ -6748,7 +6908,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6748
6908
|
import React20, { use as use16 } from "react";
|
|
6749
6909
|
import { DragDropProvider } from "@dnd-kit/react";
|
|
6750
6910
|
import { RestrictToHorizontalAxis } from "@dnd-kit/abstract/modifiers";
|
|
6751
|
-
import { useTheme as
|
|
6911
|
+
import { useTheme as useTheme5 } from "@waveform-playlist/ui-components";
|
|
6752
6912
|
|
|
6753
6913
|
// src/AnnotationIntegrationContext.tsx
|
|
6754
6914
|
import { createContext as createContext9, use as use14 } from "react";
|
|
@@ -6758,7 +6918,7 @@ function useAnnotationIntegration() {
|
|
|
6758
6918
|
const context = use14(AnnotationIntegrationContext);
|
|
6759
6919
|
if (!context) {
|
|
6760
6920
|
throw new Error(
|
|
6761
|
-
"useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations and wrap your app with <AnnotationProvider>. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6921
|
+
"useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations (" + installCommand("@waveform-playlist/annotations") + ") and wrap your app with <AnnotationProvider>. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6762
6922
|
);
|
|
6763
6923
|
}
|
|
6764
6924
|
return context;
|
|
@@ -6840,16 +7000,15 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
|
|
|
6840
7000
|
const { annotations } = useAnnotations();
|
|
6841
7001
|
const { editable, linkEndpoints } = useAnnotationOptions();
|
|
6842
7002
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6843
|
-
const {
|
|
7003
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6844
7004
|
const { sampleRate } = usePlaylistView();
|
|
6845
7005
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6846
7006
|
const { touchOptimized } = useClipInteraction();
|
|
6847
|
-
const theme =
|
|
7007
|
+
const theme = useTheme5();
|
|
6848
7008
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6849
7009
|
const sensors = useDragSensors({ touchOptimized });
|
|
6850
7010
|
const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
|
|
6851
|
-
|
|
6852
|
-
onAnnotationsChange: setAnnotations,
|
|
7011
|
+
store: annotationStore,
|
|
6853
7012
|
preview: annotationPreview,
|
|
6854
7013
|
samplesPerPixel,
|
|
6855
7014
|
sampleRate,
|
|
@@ -6885,7 +7044,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
|
|
|
6885
7044
|
});
|
|
6886
7045
|
|
|
6887
7046
|
// src/components/AnnotationList.tsx
|
|
6888
|
-
import { use as use17, useMemo as
|
|
7047
|
+
import { use as use17, useMemo as useMemo21 } from "react";
|
|
6889
7048
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
6890
7049
|
var AnnotationList = ({
|
|
6891
7050
|
height,
|
|
@@ -6898,16 +7057,16 @@ var AnnotationList = ({
|
|
|
6898
7057
|
const { annotations } = useAnnotations();
|
|
6899
7058
|
const { editable, linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
6900
7059
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6901
|
-
const {
|
|
7060
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6902
7061
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6903
|
-
const actionOptions =
|
|
7062
|
+
const actionOptions = useMemo21(
|
|
6904
7063
|
() => ({ linkEndpoints, continuousPlay }),
|
|
6905
7064
|
[linkEndpoints, continuousPlay]
|
|
6906
7065
|
);
|
|
6907
7066
|
if (annotations.length === 0) return null;
|
|
6908
7067
|
if (!integration) {
|
|
6909
7068
|
warnOnce(
|
|
6910
|
-
"<AnnotationList> draws nothing without the annotation components: install @waveform-playlist/annotations and render <AnnotationProvider> above it. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
7069
|
+
"<AnnotationList> draws nothing without the annotation components: install @waveform-playlist/annotations (" + installCommand("@waveform-playlist/annotations") + ") and render <AnnotationProvider> above it. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6911
7070
|
);
|
|
6912
7071
|
return null;
|
|
6913
7072
|
}
|
|
@@ -6926,7 +7085,7 @@ var AnnotationList = ({
|
|
|
6926
7085
|
annotationListConfig: actionOptions,
|
|
6927
7086
|
height,
|
|
6928
7087
|
onAnnotationClick: playAnnotation,
|
|
6929
|
-
|
|
7088
|
+
store: annotationStore,
|
|
6930
7089
|
renderAnnotationItem: children
|
|
6931
7090
|
}
|
|
6932
7091
|
);
|
|
@@ -6964,7 +7123,7 @@ var Waveform = (props) => composeWaveform(__spreadProps(__spreadValues({}, props
|
|
|
6964
7123
|
var WaveformEditor = (props) => composeWaveform(__spreadProps(__spreadValues({}, props), { tracks: TRACKS_WITH_HEADERS_AND_FADES }));
|
|
6965
7124
|
|
|
6966
7125
|
// src/components/MediaElementWaveformRoot.tsx
|
|
6967
|
-
import { useCallback as useCallback27, useMemo as
|
|
7126
|
+
import { useCallback as useCallback27, useMemo as useMemo22 } from "react";
|
|
6968
7127
|
import { DevicePixelRatioProvider as DevicePixelRatioProvider2, CLIP_HEADER_HEIGHT as CLIP_HEADER_HEIGHT2 } from "@waveform-playlist/ui-components";
|
|
6969
7128
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6970
7129
|
var ONE_ROW = [{ id: MEDIA_ELEMENT_TRACK_ID, kind: "audio" }];
|
|
@@ -6988,7 +7147,7 @@ var MediaElementWaveformRoot = ({
|
|
|
6988
7147
|
);
|
|
6989
7148
|
}
|
|
6990
7149
|
const { showClipHeaders } = parts.tracksOptions;
|
|
6991
|
-
const rows =
|
|
7150
|
+
const rows = useMemo22(() => {
|
|
6992
7151
|
const rowList = ONE_ROW;
|
|
6993
7152
|
const rowPeaks = peaksDataArray.length > 0 ? peaksDataArray : ONE_EMPTY_ROW;
|
|
6994
7153
|
const trackHeightById = /* @__PURE__ */ new Map();
|
|
@@ -7068,7 +7227,7 @@ var KeyboardShortcuts = ({
|
|
|
7068
7227
|
const { annotations: annotationList } = useAnnotations();
|
|
7069
7228
|
const { linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
7070
7229
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
7071
|
-
const {
|
|
7230
|
+
const { annotationStore, setActiveAnnotationId, scrollContainerRef, play } = usePlaybackControls();
|
|
7072
7231
|
const { undo, redo } = useEditorControls();
|
|
7073
7232
|
const { splitClipAtPlayhead } = useClipSplitting({ samplesPerPixel });
|
|
7074
7233
|
const allAdditional = [];
|
|
@@ -7095,9 +7254,8 @@ var KeyboardShortcuts = ({
|
|
|
7095
7254
|
enabled: playback || allAdditional.length > 0
|
|
7096
7255
|
}, playback ? { additionalShortcuts: allAdditional } : { shortcuts: allAdditional }));
|
|
7097
7256
|
useAnnotationKeyboardControls({
|
|
7098
|
-
|
|
7257
|
+
store: annotationStore,
|
|
7099
7258
|
activeAnnotationId,
|
|
7100
|
-
onAnnotationsChange: setAnnotations,
|
|
7101
7259
|
onActiveAnnotationChange: setActiveAnnotationId,
|
|
7102
7260
|
duration,
|
|
7103
7261
|
linkEndpoints,
|
|
@@ -7110,19 +7268,19 @@ var KeyboardShortcuts = ({
|
|
|
7110
7268
|
};
|
|
7111
7269
|
|
|
7112
7270
|
// src/hooks/useRecordingSession.ts
|
|
7113
|
-
import { useEffect as
|
|
7271
|
+
import { useEffect as useEffect17 } from "react";
|
|
7114
7272
|
function useRecordingSession({ isRecording, trackId }) {
|
|
7115
7273
|
const { setRecordingActive } = useEditorControls();
|
|
7116
|
-
const
|
|
7117
|
-
|
|
7274
|
+
const recordingTrackId = trackId != null ? trackId : null;
|
|
7275
|
+
useEffect17(() => {
|
|
7118
7276
|
if (!isRecording) return void 0;
|
|
7119
|
-
setRecordingActive(true,
|
|
7277
|
+
setRecordingActive(true, recordingTrackId);
|
|
7120
7278
|
return () => setRecordingActive(false);
|
|
7121
|
-
}, [isRecording,
|
|
7279
|
+
}, [isRecording, recordingTrackId, setRecordingActive]);
|
|
7122
7280
|
}
|
|
7123
7281
|
|
|
7124
7282
|
// src/components/ClipInteractionProvider.tsx
|
|
7125
|
-
import React23, { useCallback as useCallback28, useMemo as
|
|
7283
|
+
import React23, { useCallback as useCallback28, useMemo as useMemo23, useRef as useRef32 } from "react";
|
|
7126
7284
|
import { flushSync as flushSync2 } from "react-dom";
|
|
7127
7285
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
|
7128
7286
|
import { RestrictToHorizontalAxis as RestrictToHorizontalAxis2 } from "@dnd-kit/abstract/modifiers";
|
|
@@ -7225,11 +7383,11 @@ var ClipInteractionProvider = ({
|
|
|
7225
7383
|
const { sampleRate } = usePlaylistView();
|
|
7226
7384
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
7227
7385
|
const { tracks } = usePlaylistTimeline();
|
|
7228
|
-
const { setSelectedTrackId, reorderTrack,
|
|
7386
|
+
const { setSelectedTrackId, reorderTrack, setTrackDragPreview } = useEditorControls();
|
|
7229
7387
|
const beatsAndBars = useBeatsAndBars();
|
|
7230
7388
|
const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
|
|
7231
7389
|
const useTimescaleSnap = snap && !useBeatsSnap;
|
|
7232
|
-
const snapSamplePosition =
|
|
7390
|
+
const snapSamplePosition = useMemo23(() => {
|
|
7233
7391
|
if (useBeatsSnap && beatsAndBars) {
|
|
7234
7392
|
const { bpm, timeSignature, snapTo } = beatsAndBars;
|
|
7235
7393
|
const gridTicks = snapTo === "bar" ? ticksPerBar2(timeSignature) : ticksPerBeat2(timeSignature);
|
|
@@ -7245,7 +7403,7 @@ var ClipInteractionProvider = ({
|
|
|
7245
7403
|
}
|
|
7246
7404
|
return void 0;
|
|
7247
7405
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, sampleRate, samplesPerPixel]);
|
|
7248
|
-
const tracksRef =
|
|
7406
|
+
const tracksRef = useRef32(tracks);
|
|
7249
7407
|
tracksRef.current = tracks;
|
|
7250
7408
|
const getTracks = useCallback28(() => tracksRef.current, []);
|
|
7251
7409
|
const sensors = useDragSensors({ touchOptimized });
|
|
@@ -7254,13 +7412,21 @@ var ClipInteractionProvider = ({
|
|
|
7254
7412
|
onDragMove,
|
|
7255
7413
|
onDragEnd
|
|
7256
7414
|
} = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
|
|
7257
|
-
const
|
|
7415
|
+
const dragGuard = useDragGuardOptional();
|
|
7416
|
+
const endReorderGuardRef = useRef32(null);
|
|
7417
|
+
const endReorderGuard = useCallback28(() => {
|
|
7418
|
+
var _a;
|
|
7419
|
+
(_a = endReorderGuardRef.current) == null ? void 0 : _a.call(endReorderGuardRef);
|
|
7420
|
+
endReorderGuardRef.current = null;
|
|
7421
|
+
}, []);
|
|
7422
|
+
React23.useEffect(() => endReorderGuard, [endReorderGuard]);
|
|
7258
7423
|
const onDragStart = React23.useCallback(
|
|
7259
7424
|
(event) => {
|
|
7260
|
-
var _a, _b;
|
|
7425
|
+
var _a, _b, _c;
|
|
7261
7426
|
const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
|
|
7262
7427
|
if ((data == null ? void 0 : data.kind) === "track-reorder") {
|
|
7263
|
-
|
|
7428
|
+
endReorderGuard();
|
|
7429
|
+
endReorderGuardRef.current = (_c = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _c : null;
|
|
7264
7430
|
if (data.trackId) setSelectedTrackId(data.trackId);
|
|
7265
7431
|
return;
|
|
7266
7432
|
}
|
|
@@ -7271,14 +7437,13 @@ var ClipInteractionProvider = ({
|
|
|
7271
7437
|
}
|
|
7272
7438
|
handleDragStart(event);
|
|
7273
7439
|
},
|
|
7274
|
-
[handleDragStart, setSelectedTrackId]
|
|
7440
|
+
[handleDragStart, setSelectedTrackId, dragGuard, endReorderGuard]
|
|
7275
7441
|
);
|
|
7276
7442
|
const handleDragOver = React23.useCallback(
|
|
7277
7443
|
(event) => {
|
|
7278
7444
|
var _a;
|
|
7279
7445
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
7280
7446
|
if ((data == null ? void 0 : data.kind) !== "track-reorder" || !data.trackId) return;
|
|
7281
|
-
if (!trackReorderDragActiveRef.current) return;
|
|
7282
7447
|
const sortable = event.operation.source.sortable;
|
|
7283
7448
|
if (!sortable) return;
|
|
7284
7449
|
const trackId = data.trackId;
|
|
@@ -7294,12 +7459,11 @@ var ClipInteractionProvider = ({
|
|
|
7294
7459
|
var _a;
|
|
7295
7460
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
7296
7461
|
if ((data == null ? void 0 : data.kind) === "track-reorder") {
|
|
7297
|
-
|
|
7462
|
+
endReorderGuard();
|
|
7298
7463
|
const sortable = event.operation.source.sortable;
|
|
7299
7464
|
const trackId = data.trackId;
|
|
7300
7465
|
const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
|
|
7301
7466
|
flushSync2(() => {
|
|
7302
|
-
bumpTrackReorderEpoch();
|
|
7303
7467
|
setTrackDragPreview(null);
|
|
7304
7468
|
if (moves) reorderTrack(trackId, sortable.index);
|
|
7305
7469
|
});
|
|
@@ -7307,9 +7471,9 @@ var ClipInteractionProvider = ({
|
|
|
7307
7471
|
}
|
|
7308
7472
|
onDragEnd(event);
|
|
7309
7473
|
},
|
|
7310
|
-
[onDragEnd, reorderTrack,
|
|
7474
|
+
[onDragEnd, reorderTrack, setTrackDragPreview, endReorderGuard]
|
|
7311
7475
|
);
|
|
7312
|
-
const modifiers =
|
|
7476
|
+
const modifiers = useMemo23(() => {
|
|
7313
7477
|
const mods = [RestrictToHorizontalAxis2];
|
|
7314
7478
|
if (useBeatsSnap && beatsAndBars) {
|
|
7315
7479
|
mods.push(
|
|
@@ -7417,6 +7581,7 @@ export {
|
|
|
7417
7581
|
useClipDragHandlers,
|
|
7418
7582
|
useClipInteractionEnabled,
|
|
7419
7583
|
useClipSplitting,
|
|
7584
|
+
useCreateAnnotationStore,
|
|
7420
7585
|
useCreateArrangement,
|
|
7421
7586
|
useCurrentTime,
|
|
7422
7587
|
useDragSensors,
|
|
@@ -7440,6 +7605,7 @@ export {
|
|
|
7440
7605
|
useSelectedTrackId,
|
|
7441
7606
|
useSelection,
|
|
7442
7607
|
useSpectrogramIntegration,
|
|
7608
|
+
useStoredAnnotations,
|
|
7443
7609
|
useTimeFormat,
|
|
7444
7610
|
useTrack,
|
|
7445
7611
|
useTrackReorderHandle,
|