@waveform-playlist/browser 17.0.0-next.4 → 17.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +94 -74
- package/dist/index.d.ts +94 -74
- package/dist/index.js +730 -630
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +574 -475
- package/dist/index.mjs.map +1 -1
- package/dist/tone.js +1 -1
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +1 -1
- package/dist/tone.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -51,16 +51,16 @@ var __async = (__this, __arguments, generator) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// <define:__INSTALL_SPECS__>
|
|
54
|
-
var define_INSTALL_SPECS_default = { "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@dnd-kit/abstract": "@dnd-kit/abstract@^0.5.0", "@dnd-kit/dom": "@dnd-kit/dom@^0.5.0", "@dnd-kit/react": "@dnd-kit/react@^0.5.0", "@waveform-playlist/annotations": "@waveform-playlist/annotations@^14.0.0-next.
|
|
54
|
+
var define_INSTALL_SPECS_default = { "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@dnd-kit/abstract": "@dnd-kit/abstract@^0.5.0", "@dnd-kit/dom": "@dnd-kit/dom@^0.5.0", "@dnd-kit/react": "@dnd-kit/react@^0.5.0", "@waveform-playlist/annotations": "@waveform-playlist/annotations@^14.0.0-next.4", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.2", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.2", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.4", react: "react@^19.0.0", "react-dom": "react-dom@^19.0.0", "styled-components": "styled-components@^6.0.0", tone: "tone@^15.0.0", "@waveform-playlist/spectrogram": "@waveform-playlist/spectrogram@^15.0.0-next.2" };
|
|
55
55
|
|
|
56
56
|
// src/WaveformPlaylistContext.tsx
|
|
57
57
|
import {
|
|
58
|
-
useState as
|
|
59
|
-
useEffect as
|
|
60
|
-
useLayoutEffect as
|
|
61
|
-
useRef as
|
|
58
|
+
useState as useState16,
|
|
59
|
+
useEffect as useEffect8,
|
|
60
|
+
useLayoutEffect as useLayoutEffect5,
|
|
61
|
+
useRef as useRef21,
|
|
62
62
|
useCallback as useCallback19,
|
|
63
|
-
useMemo as
|
|
63
|
+
useMemo as useMemo11
|
|
64
64
|
} from "react";
|
|
65
65
|
import { ThemeProvider } from "styled-components";
|
|
66
66
|
|
|
@@ -669,11 +669,24 @@ function useClipDragHandlers({
|
|
|
669
669
|
import React2 from "react";
|
|
670
670
|
import { flushSync } from "react-dom";
|
|
671
671
|
import {
|
|
672
|
+
applyAnnotationBounds,
|
|
672
673
|
updateAnnotationBoundaries
|
|
673
674
|
} from "@waveform-playlist/core";
|
|
675
|
+
function touchedChanges(drag) {
|
|
676
|
+
return [...drag.touched.values()];
|
|
677
|
+
}
|
|
678
|
+
function snapshotBounds(drag) {
|
|
679
|
+
const before = new Map(drag.snapshot.map((a) => [a.id, a]));
|
|
680
|
+
return [...drag.touched.keys()].flatMap((id) => {
|
|
681
|
+
const old = before.get(id);
|
|
682
|
+
return old ? [{ id, start: old.start, end: old.end }] : [];
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function shownDuringDrag(drag) {
|
|
686
|
+
return applyAnnotationBounds(drag.store.getAnnotations(), touchedChanges(drag));
|
|
687
|
+
}
|
|
674
688
|
function useAnnotationDragHandlers({
|
|
675
|
-
|
|
676
|
-
onAnnotationsChange,
|
|
689
|
+
store,
|
|
677
690
|
samplesPerPixel,
|
|
678
691
|
// Default mirrors the engine default; the providers always pass the real rate from context (#510).
|
|
679
692
|
sampleRate = 48e3,
|
|
@@ -682,81 +695,132 @@ function useAnnotationDragHandlers({
|
|
|
682
695
|
preview
|
|
683
696
|
}) {
|
|
684
697
|
const dragRef = React2.useRef(null);
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
698
|
+
const storeRef = React2.useRef(store);
|
|
699
|
+
storeRef.current = store;
|
|
700
|
+
const previewRef = React2.useRef(preview);
|
|
701
|
+
previewRef.current = preview;
|
|
702
|
+
const abandon = React2.useCallback(() => {
|
|
703
|
+
var _a;
|
|
704
|
+
if (!dragRef.current) return;
|
|
705
|
+
dragRef.current = null;
|
|
706
|
+
(_a = previewRef.current) == null ? void 0 : _a.publish(null);
|
|
707
|
+
}, []);
|
|
689
708
|
React2.useEffect(() => {
|
|
690
|
-
if (!
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
709
|
+
if (!store) return;
|
|
710
|
+
const unsubscribe = store.subscribe(() => {
|
|
711
|
+
const drag = dragRef.current;
|
|
712
|
+
if (!drag || drag.store !== store) return;
|
|
713
|
+
if (!store.getAnnotations().some((a) => a.id === drag.draggedId)) {
|
|
714
|
+
abandon();
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
const shown = previewRef.current;
|
|
718
|
+
if (shown && shown.source.getSnapshot() !== null) {
|
|
719
|
+
shown.publish(shownDuringDrag(drag));
|
|
695
720
|
}
|
|
721
|
+
});
|
|
722
|
+
return () => {
|
|
723
|
+
unsubscribe();
|
|
724
|
+
abandon();
|
|
696
725
|
};
|
|
697
|
-
}, [
|
|
726
|
+
}, [store, abandon]);
|
|
727
|
+
React2.useEffect(() => abandon, [preview, abandon]);
|
|
698
728
|
const onDragStart = React2.useCallback((event) => {
|
|
699
729
|
var _a;
|
|
700
730
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
731
|
+
const owner = storeRef.current;
|
|
732
|
+
if (!owner || !data) {
|
|
733
|
+
dragRef.current = null;
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
const snapshot = owner.getAnnotations();
|
|
737
|
+
const annotation = data.annotationIndex === void 0 ? void 0 : snapshot[data.annotationIndex];
|
|
738
|
+
dragRef.current = annotation ? {
|
|
739
|
+
store: owner,
|
|
704
740
|
snapshot,
|
|
741
|
+
touched: /* @__PURE__ */ new Map(),
|
|
742
|
+
draggedId: annotation.id,
|
|
743
|
+
edge: data.edge,
|
|
705
744
|
start: annotation.start,
|
|
706
|
-
end: annotation.end
|
|
707
|
-
annotationIndex: data.annotationIndex
|
|
745
|
+
end: annotation.end
|
|
708
746
|
} : null;
|
|
709
747
|
}, []);
|
|
710
748
|
const onDragMove = React2.useCallback(
|
|
711
749
|
(event) => {
|
|
712
|
-
var _a, _b
|
|
750
|
+
var _a, _b;
|
|
713
751
|
const drag = dragRef.current;
|
|
714
|
-
if (!drag)
|
|
752
|
+
if (!drag) return;
|
|
753
|
+
if (drag.store !== storeRef.current) {
|
|
754
|
+
abandon();
|
|
715
755
|
return;
|
|
716
756
|
}
|
|
717
|
-
const
|
|
718
|
-
if (!data) return;
|
|
719
|
-
const { edge, annotationIndex } = data;
|
|
720
|
-
const currentX = (_c = (_b = event.to) == null ? void 0 : _b.x) != null ? _c : event.operation.position.current.x;
|
|
757
|
+
const currentX = (_b = (_a = event.to) == null ? void 0 : _a.x) != null ? _b : event.operation.position.current.x;
|
|
721
758
|
const rawDeltaX = currentX - event.operation.position.initial.x;
|
|
722
759
|
const timeDelta = rawDeltaX * samplesPerPixel / sampleRate;
|
|
723
|
-
const newTime = edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
724
|
-
const
|
|
760
|
+
const newTime = drag.edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
761
|
+
const base = shownDuringDrag(drag);
|
|
762
|
+
const annotationIndex = base.findIndex((a) => a.id === drag.draggedId);
|
|
763
|
+
if (annotationIndex < 0) {
|
|
764
|
+
abandon();
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const updated = updateAnnotationBoundaries({
|
|
725
768
|
annotationIndex,
|
|
726
769
|
newTime,
|
|
727
|
-
isDraggingStart: edge === "start",
|
|
728
|
-
annotations:
|
|
770
|
+
isDraggingStart: drag.edge === "start",
|
|
771
|
+
annotations: base,
|
|
729
772
|
duration,
|
|
730
773
|
linkEndpoints
|
|
731
774
|
});
|
|
775
|
+
updated.forEach((annotation, i) => {
|
|
776
|
+
const was = base[i];
|
|
777
|
+
if (drag.touched.has(annotation.id) || was.start !== annotation.start || was.end !== annotation.end) {
|
|
778
|
+
drag.touched.set(annotation.id, {
|
|
779
|
+
id: annotation.id,
|
|
780
|
+
start: annotation.start,
|
|
781
|
+
end: annotation.end
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
});
|
|
732
785
|
if (preview) {
|
|
733
|
-
preview.publish(
|
|
786
|
+
preview.publish(updated);
|
|
734
787
|
} else {
|
|
735
|
-
|
|
788
|
+
const changes = touchedChanges(drag);
|
|
789
|
+
drag.store.update((current) => applyAnnotationBounds(current, changes));
|
|
736
790
|
}
|
|
737
791
|
},
|
|
738
|
-
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview]
|
|
792
|
+
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview, abandon]
|
|
739
793
|
);
|
|
740
794
|
const onDragEnd = React2.useCallback(
|
|
741
795
|
(event) => {
|
|
742
796
|
const drag = dragRef.current;
|
|
743
797
|
dragRef.current = null;
|
|
744
798
|
if (!drag) return;
|
|
799
|
+
if (drag.store !== storeRef.current) {
|
|
800
|
+
preview == null ? void 0 : preview.publish(null);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
745
803
|
if (!preview) {
|
|
746
|
-
if (event.canceled
|
|
747
|
-
|
|
804
|
+
if (event.canceled) {
|
|
805
|
+
const restore = snapshotBounds(drag);
|
|
806
|
+
drag.store.update((current) => applyAnnotationBounds(current, restore));
|
|
748
807
|
}
|
|
749
808
|
return;
|
|
750
809
|
}
|
|
751
|
-
|
|
752
|
-
if (result === null) return;
|
|
810
|
+
if (preview.source.getSnapshot() === null) return;
|
|
753
811
|
if (event.canceled) {
|
|
754
812
|
preview.publish(null);
|
|
755
813
|
return;
|
|
756
814
|
}
|
|
757
815
|
flushSync(() => {
|
|
758
|
-
|
|
759
|
-
|
|
816
|
+
try {
|
|
817
|
+
const changes = touchedChanges(drag);
|
|
818
|
+
drag.store.update(
|
|
819
|
+
(current) => current.some((a) => a.id === drag.draggedId) ? applyAnnotationBounds(current, changes) : current
|
|
820
|
+
);
|
|
821
|
+
} finally {
|
|
822
|
+
preview.publish(null);
|
|
823
|
+
}
|
|
760
824
|
});
|
|
761
825
|
},
|
|
762
826
|
[preview]
|
|
@@ -870,29 +934,28 @@ var useClipSplitting = (options) => {
|
|
|
870
934
|
};
|
|
871
935
|
|
|
872
936
|
// src/hooks/useKeyboardShortcuts.ts
|
|
873
|
-
import {
|
|
937
|
+
import { useLayoutEffect, useRef as useRef6 } from "react";
|
|
874
938
|
import { handleKeyboardEvent } from "@waveform-playlist/core";
|
|
875
939
|
var useKeyboardShortcuts = (options) => {
|
|
876
940
|
const { shortcuts, enabled = true } = options;
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
|
|
941
|
+
const latest = useRef6({ shortcuts, enabled });
|
|
942
|
+
useLayoutEffect(() => {
|
|
943
|
+
latest.current = { shortcuts, enabled };
|
|
880
944
|
});
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
const handleKeyDown = (event) => handleKeyboardEvent(event, shortcutsRef.current, true);
|
|
945
|
+
useLayoutEffect(() => {
|
|
946
|
+
const handleKeyDown = (event) => handleKeyboardEvent(event, latest.current.shortcuts, latest.current.enabled);
|
|
884
947
|
window.addEventListener("keydown", handleKeyDown);
|
|
885
948
|
return () => {
|
|
886
949
|
window.removeEventListener("keydown", handleKeyDown);
|
|
887
950
|
};
|
|
888
|
-
}, [
|
|
951
|
+
}, []);
|
|
889
952
|
};
|
|
890
953
|
|
|
891
954
|
// src/hooks/usePlaybackShortcuts.ts
|
|
892
955
|
import { useCallback as useCallback9 } from "react";
|
|
893
956
|
|
|
894
957
|
// src/hooks/usePlayFromSelectionOrCursor.ts
|
|
895
|
-
import { useCallback as useCallback8,
|
|
958
|
+
import { useCallback as useCallback8, useLayoutEffect as useLayoutEffect2, useRef as useRef7 } from "react";
|
|
896
959
|
function usePlayFromSelectionOrCursor() {
|
|
897
960
|
var _a, _b;
|
|
898
961
|
const { currentTimeRef } = usePlaybackRefs();
|
|
@@ -900,7 +963,7 @@ function usePlayFromSelectionOrCursor() {
|
|
|
900
963
|
const isLoopEnabled = (_b = (_a = useLoopOptional()) == null ? void 0 : _a.isLoopEnabled) != null ? _b : false;
|
|
901
964
|
const { play } = usePlaybackControls();
|
|
902
965
|
const latest = useRef7({ selectionStart, selectionEnd, isLoopEnabled });
|
|
903
|
-
|
|
966
|
+
useLayoutEffect2(() => {
|
|
904
967
|
latest.current = { selectionStart, selectionEnd, isLoopEnabled };
|
|
905
968
|
});
|
|
906
969
|
return useCallback8(() => __async(null, null, function* () {
|
|
@@ -972,13 +1035,95 @@ var usePlaybackShortcuts = (options = {}) => {
|
|
|
972
1035
|
};
|
|
973
1036
|
|
|
974
1037
|
// src/hooks/useAnnotationKeyboardControls.ts
|
|
975
|
-
import { useCallback as useCallback10, useMemo as useMemo2, useEffect as
|
|
1038
|
+
import { useCallback as useCallback10, useMemo as useMemo2, useEffect, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
1039
|
+
|
|
1040
|
+
// src/utils/annotationBoundaryKeys.ts
|
|
976
1041
|
var LINK_THRESHOLD = 0.01;
|
|
1042
|
+
var MIN_LENGTH = 0.1;
|
|
1043
|
+
function unlessUnchanged(list, updated) {
|
|
1044
|
+
const same = updated.every((a, i) => a.start === list[i].start && a.end === list[i].end);
|
|
1045
|
+
return same ? list : updated;
|
|
1046
|
+
}
|
|
1047
|
+
function moveAnnotationStart(list, index, delta, { linkEndpoints }) {
|
|
1048
|
+
const annotation = list[index];
|
|
1049
|
+
const newStart = Math.max(0, Math.min(annotation.end - MIN_LENGTH, annotation.start + delta));
|
|
1050
|
+
const actualDelta = newStart - annotation.start;
|
|
1051
|
+
const updated = [...list];
|
|
1052
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { start: newStart });
|
|
1053
|
+
if (linkEndpoints && index > 0) {
|
|
1054
|
+
const prev = updated[index - 1];
|
|
1055
|
+
if (Math.abs(prev.end - annotation.start) < LINK_THRESHOLD) {
|
|
1056
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), {
|
|
1057
|
+
end: Math.max(prev.start + MIN_LENGTH, prev.end + actualDelta)
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
} else if (!linkEndpoints && index > 0) {
|
|
1061
|
+
const prev = updated[index - 1];
|
|
1062
|
+
if (newStart < prev.end) {
|
|
1063
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), { end: newStart });
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return unlessUnchanged(list, updated);
|
|
1067
|
+
}
|
|
1068
|
+
function moveAnnotationEnd(list, index, delta, { linkEndpoints, duration }) {
|
|
1069
|
+
const annotation = list[index];
|
|
1070
|
+
const newEnd = Math.max(
|
|
1071
|
+
annotation.start + MIN_LENGTH,
|
|
1072
|
+
Math.min(duration, annotation.end + delta)
|
|
1073
|
+
);
|
|
1074
|
+
const actualDelta = newEnd - annotation.end;
|
|
1075
|
+
const updated = [...list];
|
|
1076
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { end: newEnd });
|
|
1077
|
+
if (linkEndpoints && index < list.length - 1) {
|
|
1078
|
+
const next = updated[index + 1];
|
|
1079
|
+
if (Math.abs(next.start - annotation.end) < LINK_THRESHOLD) {
|
|
1080
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1081
|
+
start: Math.min(next.end - MIN_LENGTH, next.start + actualDelta)
|
|
1082
|
+
});
|
|
1083
|
+
let current = index + 1;
|
|
1084
|
+
while (current < updated.length - 1) {
|
|
1085
|
+
const moved = updated[current];
|
|
1086
|
+
const following = updated[current + 1];
|
|
1087
|
+
if (Math.abs(following.start - list[current].end) < LINK_THRESHOLD) {
|
|
1088
|
+
const nextDelta = moved.end - list[current].end;
|
|
1089
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), {
|
|
1090
|
+
start: Math.min(following.end - MIN_LENGTH, following.start + nextDelta)
|
|
1091
|
+
});
|
|
1092
|
+
current++;
|
|
1093
|
+
} else {
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
} else if (!linkEndpoints && index < list.length - 1) {
|
|
1099
|
+
const next = updated[index + 1];
|
|
1100
|
+
if (newEnd > next.start) {
|
|
1101
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), { start: newEnd });
|
|
1102
|
+
let current = index + 1;
|
|
1103
|
+
while (current < updated.length - 1) {
|
|
1104
|
+
const pushed = updated[current];
|
|
1105
|
+
const following = updated[current + 1];
|
|
1106
|
+
if (pushed.end > following.start) {
|
|
1107
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), { start: pushed.end });
|
|
1108
|
+
current++;
|
|
1109
|
+
} else {
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return unlessUnchanged(list, updated);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// src/hooks/useAnnotationKeyboardControls.ts
|
|
977
1119
|
var TIME_DELTA = 0.01;
|
|
1120
|
+
var NO_ANNOTATIONS = Object.freeze([]);
|
|
1121
|
+
var noSubscription = () => () => {
|
|
1122
|
+
};
|
|
1123
|
+
var noAnnotations = () => NO_ANNOTATIONS;
|
|
978
1124
|
function useAnnotationKeyboardControls({
|
|
979
|
-
|
|
1125
|
+
store,
|
|
980
1126
|
activeAnnotationId,
|
|
981
|
-
onAnnotationsChange,
|
|
982
1127
|
onActiveAnnotationChange,
|
|
983
1128
|
duration,
|
|
984
1129
|
linkEndpoints,
|
|
@@ -989,6 +1134,15 @@ function useAnnotationKeyboardControls({
|
|
|
989
1134
|
samplesPerPixel: samplesPerPixelProp,
|
|
990
1135
|
sampleRate: sampleRateProp
|
|
991
1136
|
}) {
|
|
1137
|
+
const source = useMemo2(
|
|
1138
|
+
() => store ? {
|
|
1139
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1140
|
+
getSnapshot: () => store.getAnnotations()
|
|
1141
|
+
} : { subscribe: noSubscription, getSnapshot: noAnnotations },
|
|
1142
|
+
[store]
|
|
1143
|
+
);
|
|
1144
|
+
const stored = useSyncExternalStore2(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1145
|
+
const annotations = stored;
|
|
992
1146
|
const playlistView = usePlaylistViewOptional();
|
|
993
1147
|
const playlistZoom = usePlaylistZoomOptional();
|
|
994
1148
|
const samplesPerPixel = samplesPerPixelProp != null ? samplesPerPixelProp : playlistZoom == null ? void 0 : playlistZoom.samplesPerPixel;
|
|
@@ -1020,99 +1174,28 @@ function useAnnotationKeyboardControls({
|
|
|
1020
1174
|
},
|
|
1021
1175
|
[annotations, scrollContainerRef, samplesPerPixel, sampleRate]
|
|
1022
1176
|
);
|
|
1023
|
-
|
|
1177
|
+
useEffect(() => {
|
|
1024
1178
|
if (activeAnnotationId && (scrollContainerRef == null ? void 0 : scrollContainerRef.current) && samplesPerPixel && sampleRate) {
|
|
1025
1179
|
scrollToAnnotation(activeAnnotationId);
|
|
1026
1180
|
}
|
|
1027
1181
|
}, [activeAnnotationId, scrollToAnnotation, scrollContainerRef, samplesPerPixel, sampleRate]);
|
|
1028
1182
|
const moveStartBoundary = useCallback10(
|
|
1029
1183
|
(delta) => {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
const actualDelta = newStart - annotation.start;
|
|
1034
|
-
const updatedAnnotations = [...annotations];
|
|
1035
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1036
|
-
start: newStart
|
|
1184
|
+
store == null ? void 0 : store.update((current) => {
|
|
1185
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1186
|
+
return index < 0 ? current : moveAnnotationStart(current, index, delta, { linkEndpoints });
|
|
1037
1187
|
});
|
|
1038
|
-
if (linkEndpoints && activeIndex > 0) {
|
|
1039
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1040
|
-
if (Math.abs(prevAnnotation.end - annotation.start) < LINK_THRESHOLD) {
|
|
1041
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1042
|
-
end: Math.max(prevAnnotation.start + 0.1, prevAnnotation.end + actualDelta)
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
} else if (!linkEndpoints && activeIndex > 0) {
|
|
1046
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1047
|
-
if (newStart < prevAnnotation.end) {
|
|
1048
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1049
|
-
end: newStart
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1054
1188
|
},
|
|
1055
|
-
[
|
|
1189
|
+
[store, activeAnnotationId, linkEndpoints]
|
|
1056
1190
|
);
|
|
1057
1191
|
const moveEndBoundary = useCallback10(
|
|
1058
1192
|
(delta) => {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
const actualDelta = newEnd - annotation.end;
|
|
1063
|
-
const updatedAnnotations = [...annotations];
|
|
1064
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1065
|
-
end: newEnd
|
|
1193
|
+
store == null ? void 0 : store.update((current) => {
|
|
1194
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1195
|
+
return index < 0 ? current : moveAnnotationEnd(current, index, delta, { linkEndpoints, duration });
|
|
1066
1196
|
});
|
|
1067
|
-
if (linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1068
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1069
|
-
if (Math.abs(nextAnnotation.start - annotation.end) < LINK_THRESHOLD) {
|
|
1070
|
-
const newNextStart = Math.min(
|
|
1071
|
-
nextAnnotation.end - 0.1,
|
|
1072
|
-
nextAnnotation.start + actualDelta
|
|
1073
|
-
);
|
|
1074
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1075
|
-
start: newNextStart
|
|
1076
|
-
});
|
|
1077
|
-
let currentIndex = activeIndex + 1;
|
|
1078
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1079
|
-
const current = updatedAnnotations[currentIndex];
|
|
1080
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1081
|
-
if (Math.abs(next.start - annotations[currentIndex].end) < LINK_THRESHOLD) {
|
|
1082
|
-
const nextDelta = current.end - annotations[currentIndex].end;
|
|
1083
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1084
|
-
start: Math.min(next.end - 0.1, next.start + nextDelta)
|
|
1085
|
-
});
|
|
1086
|
-
currentIndex++;
|
|
1087
|
-
} else {
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
} else if (!linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1093
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1094
|
-
if (newEnd > nextAnnotation.start) {
|
|
1095
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1096
|
-
start: newEnd
|
|
1097
|
-
});
|
|
1098
|
-
let currentIndex = activeIndex + 1;
|
|
1099
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1100
|
-
const current = updatedAnnotations[currentIndex];
|
|
1101
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1102
|
-
if (current.end > next.start) {
|
|
1103
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1104
|
-
start: current.end
|
|
1105
|
-
});
|
|
1106
|
-
currentIndex++;
|
|
1107
|
-
} else {
|
|
1108
|
-
break;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1114
1197
|
},
|
|
1115
|
-
[
|
|
1198
|
+
[store, activeAnnotationId, duration, linkEndpoints]
|
|
1116
1199
|
);
|
|
1117
1200
|
const selectPrevious = useCallback10(() => {
|
|
1118
1201
|
if (!onActiveAnnotationChange || annotations.length === 0) return;
|
|
@@ -1254,7 +1337,7 @@ function useAnnotationKeyboardControls({
|
|
|
1254
1337
|
}
|
|
1255
1338
|
|
|
1256
1339
|
// src/hooks/useAnimationFrameLoop.ts
|
|
1257
|
-
import { useCallback as useCallback11, useEffect as
|
|
1340
|
+
import { useCallback as useCallback11, useEffect as useEffect2, useRef as useRef8 } from "react";
|
|
1258
1341
|
var useAnimationFrameLoop = () => {
|
|
1259
1342
|
const animationFrameRef = useRef8(null);
|
|
1260
1343
|
const stopAnimationFrameLoop = useCallback11(() => {
|
|
@@ -1270,7 +1353,7 @@ var useAnimationFrameLoop = () => {
|
|
|
1270
1353
|
},
|
|
1271
1354
|
[stopAnimationFrameLoop]
|
|
1272
1355
|
);
|
|
1273
|
-
|
|
1356
|
+
useEffect2(() => {
|
|
1274
1357
|
return () => {
|
|
1275
1358
|
stopAnimationFrameLoop();
|
|
1276
1359
|
};
|
|
@@ -1283,7 +1366,7 @@ var useAnimationFrameLoop = () => {
|
|
|
1283
1366
|
};
|
|
1284
1367
|
|
|
1285
1368
|
// src/hooks/useWaveformDataCache.ts
|
|
1286
|
-
import { useState as useState7, useEffect as
|
|
1369
|
+
import { useState as useState7, useEffect as useEffect3, useRef as useRef9, useCallback as useCallback12 } from "react";
|
|
1287
1370
|
|
|
1288
1371
|
// src/workers/peaksWorker.ts
|
|
1289
1372
|
import WaveformData from "waveform-data";
|
|
@@ -1554,7 +1637,7 @@ function useWaveformDataCache(tracks, baseScale) {
|
|
|
1554
1637
|
(audioBuffer) => generatedByBufferRef.current.get(audioBuffer),
|
|
1555
1638
|
[]
|
|
1556
1639
|
);
|
|
1557
|
-
|
|
1640
|
+
useEffect3(() => {
|
|
1558
1641
|
const generatedByBuffer = generatedByBufferRef.current;
|
|
1559
1642
|
const inflightByBuffer = inflightByBufferRef.current;
|
|
1560
1643
|
const session = mountSessionRef.current;
|
|
@@ -1604,7 +1687,7 @@ function useWaveformDataCache(tracks, baseScale) {
|
|
|
1604
1687
|
inflightByBuffer.set(audioBuffer, job);
|
|
1605
1688
|
}
|
|
1606
1689
|
}, [tracks, baseScale, getWorker]);
|
|
1607
|
-
|
|
1690
|
+
useEffect3(() => {
|
|
1608
1691
|
return () => {
|
|
1609
1692
|
var _a;
|
|
1610
1693
|
mountSessionRef.current += 1;
|
|
@@ -1631,7 +1714,7 @@ function useCreateArrangement(init, options) {
|
|
|
1631
1714
|
}
|
|
1632
1715
|
|
|
1633
1716
|
// src/hooks/useArrangementTracks.ts
|
|
1634
|
-
import { useMemo as useMemo3, useSyncExternalStore as
|
|
1717
|
+
import { useMemo as useMemo3, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1635
1718
|
function useArrangementTracks(arrangement) {
|
|
1636
1719
|
const store = useMemo3(
|
|
1637
1720
|
() => ({
|
|
@@ -1640,11 +1723,11 @@ function useArrangementTracks(arrangement) {
|
|
|
1640
1723
|
}),
|
|
1641
1724
|
[arrangement]
|
|
1642
1725
|
);
|
|
1643
|
-
return
|
|
1726
|
+
return useSyncExternalStore3(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1644
1727
|
}
|
|
1645
1728
|
|
|
1646
1729
|
// src/hooks/useArrangementSources.ts
|
|
1647
|
-
import { useMemo as useMemo4, useSyncExternalStore as
|
|
1730
|
+
import { useMemo as useMemo4, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
1648
1731
|
function useArrangementSources(arrangement) {
|
|
1649
1732
|
const store = useMemo4(
|
|
1650
1733
|
() => ({
|
|
@@ -1653,7 +1736,37 @@ function useArrangementSources(arrangement) {
|
|
|
1653
1736
|
}),
|
|
1654
1737
|
[arrangement]
|
|
1655
1738
|
);
|
|
1656
|
-
return
|
|
1739
|
+
return useSyncExternalStore4(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
// src/hooks/useCreateAnnotationStore.ts
|
|
1743
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef10, useState as useState9 } from "react";
|
|
1744
|
+
import { createAnnotationStore } from "@waveform-playlist/core";
|
|
1745
|
+
function useCreateAnnotationStore(init, options) {
|
|
1746
|
+
const beforeChange = options == null ? void 0 : options.beforeChange;
|
|
1747
|
+
const ruleRef = useRef10(beforeChange);
|
|
1748
|
+
useLayoutEffect3(() => {
|
|
1749
|
+
ruleRef.current = beforeChange;
|
|
1750
|
+
}, [beforeChange]);
|
|
1751
|
+
const [store] = useState9(
|
|
1752
|
+
() => createAnnotationStore(init == null ? void 0 : init(), {
|
|
1753
|
+
beforeChange: (next, current) => ruleRef.current ? ruleRef.current(next, current) : next
|
|
1754
|
+
})
|
|
1755
|
+
);
|
|
1756
|
+
return store;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
// src/hooks/useStoredAnnotations.ts
|
|
1760
|
+
import { useMemo as useMemo5, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
1761
|
+
function useStoredAnnotations(store) {
|
|
1762
|
+
const source = useMemo5(
|
|
1763
|
+
() => ({
|
|
1764
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1765
|
+
getSnapshot: () => store.getAnnotations()
|
|
1766
|
+
}),
|
|
1767
|
+
[store]
|
|
1768
|
+
);
|
|
1769
|
+
return useSyncExternalStore5(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1657
1770
|
}
|
|
1658
1771
|
|
|
1659
1772
|
// src/providerInternals/followAnnotations.ts
|
|
@@ -1686,7 +1799,7 @@ function followAnnotations({
|
|
|
1686
1799
|
}
|
|
1687
1800
|
|
|
1688
1801
|
// src/providerInternals/useAnnotationState.ts
|
|
1689
|
-
import { useCallback as useCallback13, useMemo as
|
|
1802
|
+
import { useCallback as useCallback13, useMemo as useMemo6, useRef as useRef11, useState as useState10, useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
1690
1803
|
import { createValueSource } from "@waveform-playlist/core";
|
|
1691
1804
|
|
|
1692
1805
|
// src/utils/annotationLookup.ts
|
|
@@ -1742,20 +1855,11 @@ function createAnnotationLookup() {
|
|
|
1742
1855
|
};
|
|
1743
1856
|
}
|
|
1744
1857
|
|
|
1745
|
-
// src/utils/isDevelopmentBuild.ts
|
|
1746
|
-
function isDevelopmentBuild() {
|
|
1747
|
-
try {
|
|
1748
|
-
return process.env.NODE_ENV !== "production";
|
|
1749
|
-
} catch (e) {
|
|
1750
|
-
return false;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
1858
|
// src/providerInternals/useAnnotationState.ts
|
|
1755
1859
|
function useFollowedOption(prop) {
|
|
1756
1860
|
const wanted = prop != null ? prop : false;
|
|
1757
|
-
const [value, setValue] =
|
|
1758
|
-
const [seen, setSeen] =
|
|
1861
|
+
const [value, setValue] = useState10(wanted);
|
|
1862
|
+
const [seen, setSeen] = useState10(wanted);
|
|
1759
1863
|
if (seen !== wanted) {
|
|
1760
1864
|
setSeen(wanted);
|
|
1761
1865
|
setValue(wanted);
|
|
@@ -1763,29 +1867,35 @@ function useFollowedOption(prop) {
|
|
|
1763
1867
|
}
|
|
1764
1868
|
return [value, setValue];
|
|
1765
1869
|
}
|
|
1870
|
+
var NO_ANNOTATIONS2 = Object.freeze([]);
|
|
1871
|
+
var noSubscription2 = () => () => {
|
|
1872
|
+
};
|
|
1873
|
+
var noAnnotations2 = () => NO_ANNOTATIONS2;
|
|
1766
1874
|
function useAnnotationState({
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
providerName
|
|
1875
|
+
annotationStore,
|
|
1876
|
+
annotationList
|
|
1770
1877
|
}) {
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1878
|
+
const source = useMemo6(
|
|
1879
|
+
() => annotationStore ? {
|
|
1880
|
+
subscribe: (listener) => annotationStore.subscribe(listener),
|
|
1881
|
+
getSnapshot: () => annotationStore.getAnnotations()
|
|
1882
|
+
} : { subscribe: noSubscription2, getSnapshot: noAnnotations2 },
|
|
1883
|
+
[annotationStore]
|
|
1884
|
+
);
|
|
1885
|
+
const annotations = useSyncExternalStore6(
|
|
1886
|
+
source.subscribe,
|
|
1887
|
+
source.getSnapshot,
|
|
1888
|
+
source.getSnapshot
|
|
1889
|
+
);
|
|
1890
|
+
const storeRef = useRef11(annotationStore);
|
|
1891
|
+
storeRef.current = annotationStore;
|
|
1892
|
+
const getAnnotations = useCallback13(
|
|
1893
|
+
() => storeRef.current ? storeRef.current.getAnnotations() : NO_ANNOTATIONS2,
|
|
1894
|
+
[]
|
|
1895
|
+
);
|
|
1896
|
+
const [annotationLookup] = useState10(() => createAnnotationLookup());
|
|
1897
|
+
const [activeAnnotationId, setActiveAnnotationIdState] = useState10(null);
|
|
1898
|
+
const activeAnnotationIdRef = useRef11(null);
|
|
1789
1899
|
const setActiveAnnotationId = useCallback13((value) => {
|
|
1790
1900
|
activeAnnotationIdRef.current = value;
|
|
1791
1901
|
setActiveAnnotationIdState(value);
|
|
@@ -1793,7 +1903,7 @@ function useAnnotationState({
|
|
|
1793
1903
|
const [continuousPlay, setContinuousPlayState] = useFollowedOption(
|
|
1794
1904
|
annotationList == null ? void 0 : annotationList.isContinuousPlay
|
|
1795
1905
|
);
|
|
1796
|
-
const continuousPlayRef =
|
|
1906
|
+
const continuousPlayRef = useRef11(continuousPlay);
|
|
1797
1907
|
continuousPlayRef.current = continuousPlay;
|
|
1798
1908
|
const setContinuousPlay = useCallback13(
|
|
1799
1909
|
(value) => {
|
|
@@ -1804,36 +1914,18 @@ function useAnnotationState({
|
|
|
1804
1914
|
);
|
|
1805
1915
|
const [editable, setAnnotationsEditable] = useFollowedOption(annotationList == null ? void 0 : annotationList.editable);
|
|
1806
1916
|
const [linkEndpoints, setLinkEndpoints] = useFollowedOption(annotationList == null ? void 0 : annotationList.linkEndpoints);
|
|
1807
|
-
const annotationsValue =
|
|
1808
|
-
const annotationOptionsValue =
|
|
1917
|
+
const annotationsValue = useMemo6(() => ({ annotations }), [annotations]);
|
|
1918
|
+
const annotationOptionsValue = useMemo6(
|
|
1809
1919
|
() => ({ editable, linkEndpoints, continuousPlay }),
|
|
1810
1920
|
[editable, linkEndpoints, continuousPlay]
|
|
1811
1921
|
);
|
|
1812
|
-
const [annotationPreview] =
|
|
1922
|
+
const [annotationPreview] = useState10(
|
|
1813
1923
|
() => createValueSource(null)
|
|
1814
1924
|
);
|
|
1815
|
-
const onAnnotationsChangeRef = useRef10(onAnnotationsChange);
|
|
1816
|
-
onAnnotationsChangeRef.current = onAnnotationsChange;
|
|
1817
|
-
const setAnnotations = useCallback13(
|
|
1818
|
-
(action) => {
|
|
1819
|
-
const updated = typeof action === "function" ? action(annotationsRef.current) : action;
|
|
1820
|
-
if (!onAnnotationsChangeRef.current) {
|
|
1821
|
-
if (isDevelopmentBuild()) {
|
|
1822
|
-
console.warn(
|
|
1823
|
-
"waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to " + providerName + " to handle annotation updates."
|
|
1824
|
-
);
|
|
1825
|
-
}
|
|
1826
|
-
return;
|
|
1827
|
-
}
|
|
1828
|
-
onAnnotationsChangeRef.current(updated);
|
|
1829
|
-
},
|
|
1830
|
-
[providerName]
|
|
1831
|
-
);
|
|
1832
1925
|
return {
|
|
1833
1926
|
annotations,
|
|
1834
|
-
|
|
1927
|
+
getAnnotations,
|
|
1835
1928
|
annotationLookup,
|
|
1836
|
-
setAnnotations,
|
|
1837
1929
|
annotationPreview,
|
|
1838
1930
|
activeAnnotationId,
|
|
1839
1931
|
activeAnnotationIdRef,
|
|
@@ -1849,9 +1941,9 @@ function useAnnotationState({
|
|
|
1849
1941
|
}
|
|
1850
1942
|
|
|
1851
1943
|
// src/providerInternals/useFrameCallbacks.ts
|
|
1852
|
-
import { useCallback as useCallback14, useRef as
|
|
1944
|
+
import { useCallback as useCallback14, useRef as useRef12 } from "react";
|
|
1853
1945
|
function useFrameCallbacks() {
|
|
1854
|
-
const callbacksRef =
|
|
1946
|
+
const callbacksRef = useRef12(/* @__PURE__ */ new Map());
|
|
1855
1947
|
const registerFrameCallback = useCallback14((id, cb) => {
|
|
1856
1948
|
callbacksRef.current.set(id, cb);
|
|
1857
1949
|
}, []);
|
|
@@ -1867,15 +1959,15 @@ function useFrameCallbacks() {
|
|
|
1867
1959
|
}
|
|
1868
1960
|
|
|
1869
1961
|
// src/providerInternals/useScrollFollow.ts
|
|
1870
|
-
import { useCallback as useCallback15, useRef as
|
|
1962
|
+
import { useCallback as useCallback15, useRef as useRef13, useState as useState11 } from "react";
|
|
1871
1963
|
function centrePlayhead(container, time, sampleRate, samplesPerPixel) {
|
|
1872
1964
|
const pixelPosition = time * sampleRate / samplesPerPixel;
|
|
1873
1965
|
container.scrollLeft = Math.round(Math.max(0, pixelPosition - container.clientWidth / 2));
|
|
1874
1966
|
}
|
|
1875
1967
|
function useScrollFollow(initialAutomaticScroll) {
|
|
1876
|
-
const scrollContainerRef =
|
|
1877
|
-
const [isAutomaticScroll, setIsAutomaticScroll] =
|
|
1878
|
-
const isAutomaticScrollRef =
|
|
1968
|
+
const scrollContainerRef = useRef13(null);
|
|
1969
|
+
const [isAutomaticScroll, setIsAutomaticScroll] = useState11(initialAutomaticScroll);
|
|
1970
|
+
const isAutomaticScrollRef = useRef13(initialAutomaticScroll);
|
|
1879
1971
|
const setScrollContainer = useCallback15((element) => {
|
|
1880
1972
|
scrollContainerRef.current = element;
|
|
1881
1973
|
}, []);
|
|
@@ -1893,11 +1985,11 @@ function useScrollFollow(initialAutomaticScroll) {
|
|
|
1893
1985
|
}
|
|
1894
1986
|
|
|
1895
1987
|
// src/providerInternals/useMergedTheme.ts
|
|
1896
|
-
import { useMemo as
|
|
1988
|
+
import { useMemo as useMemo7 } from "react";
|
|
1897
1989
|
import { defaultTheme } from "@waveform-playlist/ui-components";
|
|
1898
1990
|
|
|
1899
1991
|
// src/hooks/useShallowStable.ts
|
|
1900
|
-
import { useRef as
|
|
1992
|
+
import { useRef as useRef14 } from "react";
|
|
1901
1993
|
function shallowEqual(a, b) {
|
|
1902
1994
|
if (a === b) return true;
|
|
1903
1995
|
const aKeys = Object.keys(a);
|
|
@@ -1910,7 +2002,7 @@ function shallowEqual(a, b) {
|
|
|
1910
2002
|
);
|
|
1911
2003
|
}
|
|
1912
2004
|
function useShallowStable(value) {
|
|
1913
|
-
const ref =
|
|
2005
|
+
const ref = useRef14(value);
|
|
1914
2006
|
const previous = ref.current;
|
|
1915
2007
|
if (previous !== value) {
|
|
1916
2008
|
if (previous === void 0 || value === void 0 || !shallowEqual(previous, value)) {
|
|
@@ -1923,11 +2015,11 @@ function useShallowStable(value) {
|
|
|
1923
2015
|
// src/providerInternals/useMergedTheme.ts
|
|
1924
2016
|
function useMergedTheme(themeProp) {
|
|
1925
2017
|
const userTheme = useShallowStable(themeProp);
|
|
1926
|
-
return
|
|
2018
|
+
return useMemo7(() => __spreadValues(__spreadValues({}, defaultTheme), userTheme), [userTheme]);
|
|
1927
2019
|
}
|
|
1928
2020
|
|
|
1929
2021
|
// src/providerInternals/useTrimPreview.ts
|
|
1930
|
-
import { useRef as
|
|
2022
|
+
import { useRef as useRef15, useState as useState12 } from "react";
|
|
1931
2023
|
import { createValueSource as createValueSource2 } from "@waveform-playlist/core";
|
|
1932
2024
|
|
|
1933
2025
|
// src/waveformDataLoader.ts
|
|
@@ -2226,19 +2318,19 @@ function previewedClipPeaks(preview, { tracks, peaksOptions, peaksCacheRef }) {
|
|
|
2226
2318
|
return clipPeaksFor(previewed, track.name, peaksOptions, previous).clipPeaks;
|
|
2227
2319
|
}
|
|
2228
2320
|
function useTrimPreview(inputs) {
|
|
2229
|
-
const [trimPreview] =
|
|
2321
|
+
const [trimPreview] = useState12(
|
|
2230
2322
|
() => createValueSource2(null)
|
|
2231
2323
|
);
|
|
2232
|
-
const inputsRef =
|
|
2324
|
+
const inputsRef = useRef15(inputs);
|
|
2233
2325
|
inputsRef.current = inputs;
|
|
2234
|
-
const [trimPreviewPeaks] =
|
|
2326
|
+
const [trimPreviewPeaks] = useState12(() => ({
|
|
2235
2327
|
peaksFor: (preview) => previewedClipPeaks(preview, inputsRef.current)
|
|
2236
2328
|
}));
|
|
2237
2329
|
return { trimPreview, trimPreviewPeaks };
|
|
2238
2330
|
}
|
|
2239
2331
|
|
|
2240
2332
|
// src/providerInternals/useEngineLifetime.ts
|
|
2241
|
-
import { useCallback as useCallback16, useEffect as
|
|
2333
|
+
import { useCallback as useCallback16, useEffect as useEffect4, useLayoutEffect as useLayoutEffect4, useMemo as useMemo8, useRef as useRef16, useState as useState13 } from "react";
|
|
2242
2334
|
import {
|
|
2243
2335
|
attachDecodeContext,
|
|
2244
2336
|
PlaylistEngine
|
|
@@ -2364,10 +2456,10 @@ function reportBuildFailure(ctx, run, engine, error) {
|
|
|
2364
2456
|
onError == null ? void 0 : onError(error instanceof Error ? error : new Error(String(error)));
|
|
2365
2457
|
}
|
|
2366
2458
|
function useKnownSampleRate(sampleRateProp) {
|
|
2367
|
-
const [sampleRate, setSampleRateState] =
|
|
2459
|
+
const [sampleRate, setSampleRateState] = useState13(
|
|
2368
2460
|
() => sampleRateProp != null ? sampleRateProp : PROVISIONAL_SAMPLE_RATE
|
|
2369
2461
|
);
|
|
2370
|
-
const [isSampleRateKnown, setIsSampleRateKnown] =
|
|
2462
|
+
const [isSampleRateKnown, setIsSampleRateKnown] = useState13(() => sampleRateProp !== void 0);
|
|
2371
2463
|
const setSampleRate = useCallback16((rate) => {
|
|
2372
2464
|
setSampleRateState(rate);
|
|
2373
2465
|
setIsSampleRateKnown(true);
|
|
@@ -2375,7 +2467,7 @@ function useKnownSampleRate(sampleRateProp) {
|
|
|
2375
2467
|
return { sampleRate, isSampleRateKnown, setSampleRate };
|
|
2376
2468
|
}
|
|
2377
2469
|
function useDecodeContext(arrangement, adapterRef) {
|
|
2378
|
-
const arrivalRef =
|
|
2470
|
+
const arrivalRef = useRef16(null);
|
|
2379
2471
|
const getDecodeContext = useCallback16(() => __async(null, null, function* () {
|
|
2380
2472
|
var _a;
|
|
2381
2473
|
const adapter = adapterRef.current;
|
|
@@ -2383,7 +2475,7 @@ function useDecodeContext(arrangement, adapterRef) {
|
|
|
2383
2475
|
(_a = arrivalRef.current) != null ? _a : arrivalRef.current = deferred();
|
|
2384
2476
|
return arrivalRef.current.promise;
|
|
2385
2477
|
}), [adapterRef]);
|
|
2386
|
-
|
|
2478
|
+
useEffect4(
|
|
2387
2479
|
() => attachDecodeContext(arrangement, getDecodeContext),
|
|
2388
2480
|
[arrangement, getDecodeContext]
|
|
2389
2481
|
);
|
|
@@ -2412,22 +2504,22 @@ function useDisposeKeepingPlayback(refs) {
|
|
|
2412
2504
|
}
|
|
2413
2505
|
function useEngineLifetime(options) {
|
|
2414
2506
|
const { arrangement, effects, zoomLevels, sampleRateProp } = options;
|
|
2415
|
-
const latest =
|
|
2416
|
-
|
|
2507
|
+
const latest = useRef16(options);
|
|
2508
|
+
useLayoutEffect4(() => {
|
|
2417
2509
|
latest.current = options;
|
|
2418
2510
|
});
|
|
2419
|
-
const stableZoomLevels =
|
|
2511
|
+
const stableZoomLevels = useMemo8(
|
|
2420
2512
|
() => zoomLevels,
|
|
2421
2513
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2422
2514
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2423
2515
|
);
|
|
2424
|
-
const engineRef =
|
|
2425
|
-
const adapterRef =
|
|
2426
|
-
const engineBuildInFlightRef =
|
|
2427
|
-
const pendingResumeRef =
|
|
2428
|
-
const audioInitializedRef =
|
|
2429
|
-
const [engineEpoch, setEngineEpoch] =
|
|
2430
|
-
const [isEngineAttached, setIsEngineAttached] =
|
|
2516
|
+
const engineRef = useRef16(null);
|
|
2517
|
+
const adapterRef = useRef16(null);
|
|
2518
|
+
const engineBuildInFlightRef = useRef16(false);
|
|
2519
|
+
const pendingResumeRef = useRef16(null);
|
|
2520
|
+
const audioInitializedRef = useRef16(false);
|
|
2521
|
+
const [engineEpoch, setEngineEpoch] = useState13(0);
|
|
2522
|
+
const [isEngineAttached, setIsEngineAttached] = useState13(false);
|
|
2431
2523
|
const bumpEngineEpoch = useCallback16(() => setEngineEpoch((epoch) => epoch + 1), []);
|
|
2432
2524
|
const { sampleRate, isSampleRateKnown, setSampleRate } = useKnownSampleRate(sampleRateProp);
|
|
2433
2525
|
const onAssigned = useDecodeContext(arrangement, adapterRef);
|
|
@@ -2437,7 +2529,7 @@ function useEngineLifetime(options) {
|
|
|
2437
2529
|
pendingResumeRef,
|
|
2438
2530
|
latest
|
|
2439
2531
|
});
|
|
2440
|
-
|
|
2532
|
+
useEffect4(() => {
|
|
2441
2533
|
const run = { cancelled: false };
|
|
2442
2534
|
engineBuildInFlightRef.current = true;
|
|
2443
2535
|
setIsEngineAttached(false);
|
|
@@ -2496,7 +2588,7 @@ function useEngineLifetime(options) {
|
|
|
2496
2588
|
}
|
|
2497
2589
|
|
|
2498
2590
|
// src/providerInternals/useArrangementView.ts
|
|
2499
|
-
import { useMemo as
|
|
2591
|
+
import { useMemo as useMemo9, useRef as useRef17, useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
2500
2592
|
import { isLoadingClip as isLoadingClip2 } from "@waveform-playlist/core";
|
|
2501
2593
|
|
|
2502
2594
|
// src/utils/placeholderPeaks.ts
|
|
@@ -2640,14 +2732,14 @@ function deriveTrackStates(tracks, mixer, previous) {
|
|
|
2640
2732
|
return { byTrackId, result: sameItems(previous.result, states) ? previous.result : states };
|
|
2641
2733
|
}
|
|
2642
2734
|
function useArrangementValue(arrangement, read) {
|
|
2643
|
-
const store =
|
|
2735
|
+
const store = useMemo9(
|
|
2644
2736
|
() => ({
|
|
2645
2737
|
subscribe: (listener) => arrangement.subscribe(listener),
|
|
2646
2738
|
getSnapshot: () => read(arrangement)
|
|
2647
2739
|
}),
|
|
2648
2740
|
[arrangement, read]
|
|
2649
2741
|
);
|
|
2650
|
-
return
|
|
2742
|
+
return useSyncExternalStore7(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2651
2743
|
}
|
|
2652
2744
|
var readMixer = (arrangement) => arrangement.getMixer();
|
|
2653
2745
|
var readCanUndo = (arrangement) => arrangement.canUndo;
|
|
@@ -2658,33 +2750,33 @@ function useArrangementView(arrangement, options) {
|
|
|
2658
2750
|
const mixer = useArrangementValue(arrangement, readMixer);
|
|
2659
2751
|
const canUndo = useArrangementValue(arrangement, readCanUndo);
|
|
2660
2752
|
const canRedo = useArrangementValue(arrangement, readCanRedo);
|
|
2661
|
-
const loadedCacheRef =
|
|
2662
|
-
const tracks =
|
|
2753
|
+
const loadedCacheRef = useRef17(EMPTY_LOADED_TRACKS);
|
|
2754
|
+
const tracks = useMemo9(() => {
|
|
2663
2755
|
const next = loadedTracks(arrangementTracks, loadedCacheRef.current);
|
|
2664
2756
|
loadedCacheRef.current = next.cache;
|
|
2665
2757
|
return next.tracks;
|
|
2666
2758
|
}, [arrangementTracks]);
|
|
2667
2759
|
const { getWaveformData, version } = useWaveformDataCache(tracks, baseScale);
|
|
2668
|
-
const peaksOptions =
|
|
2760
|
+
const peaksOptions = useMemo9(
|
|
2669
2761
|
() => ({ samplesPerPixel, mono, getGeneratedWaveformData: getWaveformData }),
|
|
2670
2762
|
[samplesPerPixel, mono, getWaveformData]
|
|
2671
2763
|
);
|
|
2672
|
-
const peaksCacheRef =
|
|
2673
|
-
const loadedPeaks =
|
|
2764
|
+
const peaksCacheRef = useRef17(EMPTY_PEAKS_CACHE);
|
|
2765
|
+
const loadedPeaks = useMemo9(() => {
|
|
2674
2766
|
const next = derivePeaks(tracks, peaksOptions, peaksCacheRef.current);
|
|
2675
2767
|
peaksCacheRef.current = next;
|
|
2676
2768
|
return next;
|
|
2677
2769
|
}, [tracks, peaksOptions, version]);
|
|
2678
|
-
const rowsCacheRef =
|
|
2679
|
-
const peaksDataArray =
|
|
2770
|
+
const rowsCacheRef = useRef17(EMPTY_ROWS);
|
|
2771
|
+
const peaksDataArray = useMemo9(() => {
|
|
2680
2772
|
const inputs = { loadedPeaks, samplesPerPixel, mono, placeholderSampleRate };
|
|
2681
2773
|
const next = deriveRows(arrangementTracks, inputs, rowsCacheRef.current);
|
|
2682
2774
|
rowsCacheRef.current = next;
|
|
2683
2775
|
return next.result;
|
|
2684
2776
|
}, [arrangementTracks, loadedPeaks, samplesPerPixel, mono, placeholderSampleRate]);
|
|
2685
|
-
const duration =
|
|
2686
|
-
const statesCacheRef =
|
|
2687
|
-
const trackStates =
|
|
2777
|
+
const duration = useMemo9(() => timelineDuration(tracks), [tracks]);
|
|
2778
|
+
const statesCacheRef = useRef17(EMPTY_STATES);
|
|
2779
|
+
const trackStates = useMemo9(() => {
|
|
2688
2780
|
const next = deriveTrackStates(arrangementTracks, mixer, statesCacheRef.current);
|
|
2689
2781
|
statesCacheRef.current = next;
|
|
2690
2782
|
return next.result;
|
|
@@ -2702,7 +2794,18 @@ function useArrangementView(arrangement, options) {
|
|
|
2702
2794
|
}
|
|
2703
2795
|
|
|
2704
2796
|
// src/providerInternals/useReadyOnce.ts
|
|
2705
|
-
import { useCallback as useCallback17, useEffect as
|
|
2797
|
+
import { useCallback as useCallback17, useEffect as useEffect5, useInsertionEffect, useRef as useRef18, useState as useState14 } from "react";
|
|
2798
|
+
|
|
2799
|
+
// src/utils/isDevelopmentBuild.ts
|
|
2800
|
+
function isDevelopmentBuild() {
|
|
2801
|
+
try {
|
|
2802
|
+
return process.env.NODE_ENV !== "production";
|
|
2803
|
+
} catch (e) {
|
|
2804
|
+
return false;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
// src/providerInternals/useReadyOnce.ts
|
|
2706
2809
|
var READY_EVENT = "waveform-playlist:ready";
|
|
2707
2810
|
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().";
|
|
2708
2811
|
function callOnReady({
|
|
@@ -2721,11 +2824,11 @@ function callOnReady({
|
|
|
2721
2824
|
function useReadyOnce(options) {
|
|
2722
2825
|
const { isEngineAttached, arrangement, onReadyRef, onErrorRef, trackCount, duration } = options;
|
|
2723
2826
|
const { pendingCount } = useArrangementSources(arrangement);
|
|
2724
|
-
const [hasBeenReady, setHasBeenReady] =
|
|
2725
|
-
const firedRef =
|
|
2827
|
+
const [hasBeenReady, setHasBeenReady] = useState14(false);
|
|
2828
|
+
const firedRef = useRef18(false);
|
|
2726
2829
|
const isReady = isEngineAttached && (hasBeenReady || pendingCount === 0);
|
|
2727
|
-
const firstReadyRef =
|
|
2728
|
-
const warnedPlayRef =
|
|
2830
|
+
const firstReadyRef = useRef18(false);
|
|
2831
|
+
const warnedPlayRef = useRef18(false);
|
|
2729
2832
|
useInsertionEffect(() => {
|
|
2730
2833
|
if (isReady) firstReadyRef.current = true;
|
|
2731
2834
|
}, [isReady]);
|
|
@@ -2737,7 +2840,7 @@ function useReadyOnce(options) {
|
|
|
2737
2840
|
}
|
|
2738
2841
|
return true;
|
|
2739
2842
|
}, []);
|
|
2740
|
-
|
|
2843
|
+
useEffect5(() => {
|
|
2741
2844
|
if (!isReady || firedRef.current) return;
|
|
2742
2845
|
firedRef.current = true;
|
|
2743
2846
|
setHasBeenReady(true);
|
|
@@ -2749,7 +2852,7 @@ function useReadyOnce(options) {
|
|
|
2749
2852
|
}
|
|
2750
2853
|
|
|
2751
2854
|
// src/providerInternals/useArrangementEditing.ts
|
|
2752
|
-
import { useCallback as useCallback18, useEffect as
|
|
2855
|
+
import { useCallback as useCallback18, useEffect as useEffect6, useMemo as useMemo10, useRef as useRef19, useState as useState15, useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
2753
2856
|
import { createValueSource as createValueSource3 } from "@waveform-playlist/core";
|
|
2754
2857
|
|
|
2755
2858
|
// src/components/partWarnings.ts
|
|
@@ -2771,8 +2874,8 @@ function isTrackId(setter, trackId) {
|
|
|
2771
2874
|
return false;
|
|
2772
2875
|
}
|
|
2773
2876
|
function useRecordingActive(arrangement) {
|
|
2774
|
-
const recordingActiveRef =
|
|
2775
|
-
const [armed] =
|
|
2877
|
+
const recordingActiveRef = useRef19(false);
|
|
2878
|
+
const [armed] = useState15(() => createValueSource3(null));
|
|
2776
2879
|
const setRecordingActive = useCallback18(
|
|
2777
2880
|
(active, armedTrackId2) => {
|
|
2778
2881
|
var _a, _b;
|
|
@@ -2791,7 +2894,7 @@ function useRecordingActive(arrangement) {
|
|
|
2791
2894
|
},
|
|
2792
2895
|
[arrangement, armed]
|
|
2793
2896
|
);
|
|
2794
|
-
|
|
2897
|
+
useEffect6(
|
|
2795
2898
|
() => () => {
|
|
2796
2899
|
if (armed.source.getSnapshot()) setRecordingActive(false);
|
|
2797
2900
|
},
|
|
@@ -2801,8 +2904,8 @@ function useRecordingActive(arrangement) {
|
|
|
2801
2904
|
var _a, _b;
|
|
2802
2905
|
return (_b = (_a = armed.source.getSnapshot()) == null ? void 0 : _a.trackId) != null ? _b : null;
|
|
2803
2906
|
}, [armed]);
|
|
2804
|
-
const armedTrackId =
|
|
2805
|
-
const recordingArm =
|
|
2907
|
+
const armedTrackId = useSyncExternalStore8(armed.source.subscribe, getArmedTrackId);
|
|
2908
|
+
const recordingArm = useMemo10(() => ({ armedTrackId }), [armedTrackId]);
|
|
2806
2909
|
return { setRecordingActive, recordingActiveRef, recordingArm };
|
|
2807
2910
|
}
|
|
2808
2911
|
function useArrangementEditing(arrangement) {
|
|
@@ -2852,7 +2955,7 @@ function useArrangementEditing(arrangement) {
|
|
|
2852
2955
|
}
|
|
2853
2956
|
|
|
2854
2957
|
// src/providerInternals/arrangementIdentity.ts
|
|
2855
|
-
import { useEffect as
|
|
2958
|
+
import { useEffect as useEffect7, useRef as useRef20 } from "react";
|
|
2856
2959
|
var arrangementKeys = /* @__PURE__ */ new WeakMap();
|
|
2857
2960
|
var lastArrangementKey = 0;
|
|
2858
2961
|
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";
|
|
@@ -2871,9 +2974,9 @@ function keyOf(arrangement) {
|
|
|
2871
2974
|
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.";
|
|
2872
2975
|
function useArrangementKey(arrangement) {
|
|
2873
2976
|
const key = keyOf(arrangement);
|
|
2874
|
-
const firstKeyRef =
|
|
2875
|
-
const warnedRef =
|
|
2876
|
-
|
|
2977
|
+
const firstKeyRef = useRef20(key);
|
|
2978
|
+
const warnedRef = useRef20(false);
|
|
2979
|
+
useEffect7(() => {
|
|
2877
2980
|
if (key === firstKeyRef.current || warnedRef.current) return;
|
|
2878
2981
|
warnedRef.current = true;
|
|
2879
2982
|
if (isDevelopmentBuild()) console.warn(NEW_ARRANGEMENT_WARNING);
|
|
@@ -2897,12 +3000,12 @@ var ProviderOnArrangement = ({
|
|
|
2897
3000
|
zoomLevels,
|
|
2898
3001
|
automaticScroll = false,
|
|
2899
3002
|
theme: userThemeProp,
|
|
3003
|
+
annotationStore,
|
|
2900
3004
|
annotationList,
|
|
2901
3005
|
effects,
|
|
2902
3006
|
trackEffects,
|
|
2903
3007
|
onReady,
|
|
2904
3008
|
onError,
|
|
2905
|
-
onAnnotationsChange,
|
|
2906
3009
|
soundFontCache,
|
|
2907
3010
|
indefinitePlayback = false,
|
|
2908
3011
|
sampleRate: sampleRateProp,
|
|
@@ -2910,15 +3013,14 @@ var ProviderOnArrangement = ({
|
|
|
2910
3013
|
children
|
|
2911
3014
|
}) => {
|
|
2912
3015
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
2913
|
-
const stableZoomLevels =
|
|
3016
|
+
const stableZoomLevels = useMemo11(
|
|
2914
3017
|
() => zoomLevels,
|
|
2915
3018
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2916
3019
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2917
3020
|
);
|
|
2918
3021
|
const {
|
|
2919
|
-
|
|
3022
|
+
getAnnotations,
|
|
2920
3023
|
annotationLookup,
|
|
2921
|
-
setAnnotations,
|
|
2922
3024
|
annotationPreview,
|
|
2923
3025
|
activeAnnotationId,
|
|
2924
3026
|
activeAnnotationIdRef,
|
|
@@ -2931,9 +3033,8 @@ var ProviderOnArrangement = ({
|
|
|
2931
3033
|
annotationsValue,
|
|
2932
3034
|
annotationOptionsValue
|
|
2933
3035
|
} = useAnnotationState({
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
providerName: "WaveformPlaylistProvider"
|
|
3036
|
+
annotationStore,
|
|
3037
|
+
annotationList
|
|
2937
3038
|
});
|
|
2938
3039
|
const {
|
|
2939
3040
|
scrollContainerRef,
|
|
@@ -2943,20 +3044,20 @@ var ProviderOnArrangement = ({
|
|
|
2943
3044
|
setAutomaticScroll
|
|
2944
3045
|
} = useScrollFollow(automaticScroll);
|
|
2945
3046
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
2946
|
-
const [isPlaying, setIsPlaying] =
|
|
2947
|
-
const [currentTime, setCurrentTime] =
|
|
2948
|
-
const [trackReorderEpoch, setTrackReorderEpoch] =
|
|
2949
|
-
const [trackDragPreview, setTrackDragPreview] =
|
|
2950
|
-
const indefinitePlaybackRef =
|
|
3047
|
+
const [isPlaying, setIsPlaying] = useState16(false);
|
|
3048
|
+
const [currentTime, setCurrentTime] = useState16(0);
|
|
3049
|
+
const [trackReorderEpoch, setTrackReorderEpoch] = useState16(0);
|
|
3050
|
+
const [trackDragPreview, setTrackDragPreview] = useState16(null);
|
|
3051
|
+
const indefinitePlaybackRef = useRef21(indefinitePlayback);
|
|
2951
3052
|
indefinitePlaybackRef.current = indefinitePlayback;
|
|
2952
|
-
const isPlayingRef =
|
|
3053
|
+
const isPlayingRef = useRef21(false);
|
|
2953
3054
|
isPlayingRef.current = isPlaying;
|
|
2954
|
-
const playStartPositionRef =
|
|
2955
|
-
const currentTimeRef =
|
|
2956
|
-
const visualTimeRef =
|
|
2957
|
-
const soundFontCacheRef =
|
|
3055
|
+
const playStartPositionRef = useRef21(0);
|
|
3056
|
+
const currentTimeRef = useRef21(0);
|
|
3057
|
+
const visualTimeRef = useRef21(0);
|
|
3058
|
+
const soundFontCacheRef = useRef21(soundFontCache);
|
|
2958
3059
|
soundFontCacheRef.current = soundFontCache;
|
|
2959
|
-
const trackEffectsRef =
|
|
3060
|
+
const trackEffectsRef = useRef21(trackEffects);
|
|
2960
3061
|
trackEffectsRef.current = trackEffects;
|
|
2961
3062
|
const resolveTrackEffects = useCallback19(
|
|
2962
3063
|
(trackId) => {
|
|
@@ -2965,19 +3066,19 @@ var ProviderOnArrangement = ({
|
|
|
2965
3066
|
},
|
|
2966
3067
|
[]
|
|
2967
3068
|
);
|
|
2968
|
-
const onReadyRef =
|
|
2969
|
-
const onErrorRef =
|
|
2970
|
-
|
|
3069
|
+
const onReadyRef = useRef21(onReady);
|
|
3070
|
+
const onErrorRef = useRef21(onError);
|
|
3071
|
+
useLayoutEffect5(() => {
|
|
2971
3072
|
onReadyRef.current = onReady;
|
|
2972
3073
|
onErrorRef.current = onError;
|
|
2973
3074
|
});
|
|
2974
|
-
const playbackStartTimeRef =
|
|
2975
|
-
const audioStartPositionRef =
|
|
2976
|
-
const playbackEndTimeRef =
|
|
2977
|
-
const suppressEngineStopMirrorRef =
|
|
2978
|
-
const samplesPerPixelRef =
|
|
2979
|
-
const isSelectionPlayRef =
|
|
2980
|
-
const playRequestIdRef =
|
|
3075
|
+
const playbackStartTimeRef = useRef21(0);
|
|
3076
|
+
const audioStartPositionRef = useRef21(0);
|
|
3077
|
+
const playbackEndTimeRef = useRef21(null);
|
|
3078
|
+
const suppressEngineStopMirrorRef = useRef21(false);
|
|
3079
|
+
const samplesPerPixelRef = useRef21(initialSamplesPerPixel);
|
|
3080
|
+
const isSelectionPlayRef = useRef21(false);
|
|
3081
|
+
const playRequestIdRef = useRef21(0);
|
|
2981
3082
|
const { animationFrameRef, startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
2982
3083
|
const onBuildFailure = useCallback19(() => {
|
|
2983
3084
|
if (!isPlayingRef.current) return;
|
|
@@ -2986,7 +3087,7 @@ var ProviderOnArrangement = ({
|
|
|
2986
3087
|
visualTimeRef.current = toVisualTime(currentTimeRef.current);
|
|
2987
3088
|
setCurrentTime(currentTimeRef.current);
|
|
2988
3089
|
}, [stopAnimationFrameLoop]);
|
|
2989
|
-
const followersRef =
|
|
3090
|
+
const followersRef = useRef21(null);
|
|
2990
3091
|
const seedEngine = useCallback19(
|
|
2991
3092
|
(engine) => {
|
|
2992
3093
|
var _a;
|
|
@@ -3036,7 +3137,7 @@ var ProviderOnArrangement = ({
|
|
|
3036
3137
|
onErrorRef,
|
|
3037
3138
|
onBuildFailure
|
|
3038
3139
|
});
|
|
3039
|
-
const sampleRateRef =
|
|
3140
|
+
const sampleRateRef = useRef21(sampleRate);
|
|
3040
3141
|
sampleRateRef.current = sampleRate;
|
|
3041
3142
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3042
3143
|
const zoom = useZoomControls({ engineRef, initialSamplesPerPixel });
|
|
@@ -3074,7 +3175,7 @@ var ProviderOnArrangement = ({
|
|
|
3074
3175
|
onEngineState: onSelectedTrackEngineState,
|
|
3075
3176
|
selectedTrackIdRef
|
|
3076
3177
|
} = useSelectedTrack({ engineRef });
|
|
3077
|
-
const baseScale =
|
|
3178
|
+
const baseScale = useMemo11(
|
|
3078
3179
|
() => Math.min(...stableZoomLevels != null ? stableZoomLevels : [256, 512, 1024, 2048, 4096, 8192]),
|
|
3079
3180
|
[stableZoomLevels]
|
|
3080
3181
|
);
|
|
@@ -3085,7 +3186,7 @@ var ProviderOnArrangement = ({
|
|
|
3085
3186
|
placeholderSampleRate: isSampleRateKnown ? sampleRate : null
|
|
3086
3187
|
});
|
|
3087
3188
|
const { tracks, duration } = view;
|
|
3088
|
-
const durationRef =
|
|
3189
|
+
const durationRef = useRef21(duration);
|
|
3089
3190
|
durationRef.current = duration;
|
|
3090
3191
|
const { isReady, refusePlayBeforeFirstReady } = useReadyOnce({
|
|
3091
3192
|
isEngineAttached,
|
|
@@ -3110,7 +3211,7 @@ var ProviderOnArrangement = ({
|
|
|
3110
3211
|
setLoopRegion(start, end);
|
|
3111
3212
|
}
|
|
3112
3213
|
}, [setLoopRegion, selectionStartRef, selectionEndRef]);
|
|
3113
|
-
|
|
3214
|
+
useEffect8(() => {
|
|
3114
3215
|
if (!scrollContainerRef.current || duration === 0) return;
|
|
3115
3216
|
const container = scrollContainerRef.current;
|
|
3116
3217
|
const oldSamplesPerPixel = samplesPerPixelRef.current;
|
|
@@ -3126,10 +3227,10 @@ var ProviderOnArrangement = ({
|
|
|
3126
3227
|
container.scrollLeft = newScrollLeft;
|
|
3127
3228
|
samplesPerPixelRef.current = newSamplesPerPixel;
|
|
3128
3229
|
}, [samplesPerPixel, duration, scrollContainerRef]);
|
|
3129
|
-
|
|
3230
|
+
useEffect8(() => {
|
|
3130
3231
|
syncSoundFontCacheToAdapter(adapterRef.current, soundFontCache);
|
|
3131
3232
|
}, [soundFontCache, adapterRef]);
|
|
3132
|
-
|
|
3233
|
+
useEffect8(() => {
|
|
3133
3234
|
for (const track of tracks) {
|
|
3134
3235
|
for (const clip of track.clips) {
|
|
3135
3236
|
if (!clip.audioBuffer && !clip.waveformData && !clip.midiNotes) {
|
|
@@ -3145,7 +3246,7 @@ var ProviderOnArrangement = ({
|
|
|
3145
3246
|
},
|
|
3146
3247
|
[adapterRef]
|
|
3147
3248
|
);
|
|
3148
|
-
const getPlaybackTimeFallbackWarnedRef =
|
|
3249
|
+
const getPlaybackTimeFallbackWarnedRef = useRef21(false);
|
|
3149
3250
|
const getPlaybackTime = useCallback19(() => {
|
|
3150
3251
|
var _a, _b;
|
|
3151
3252
|
if (engineRef.current) {
|
|
@@ -3188,7 +3289,7 @@ var ProviderOnArrangement = ({
|
|
|
3188
3289
|
},
|
|
3189
3290
|
[stopAnimationFrameLoop, setCurrentTimeRefs]
|
|
3190
3291
|
);
|
|
3191
|
-
|
|
3292
|
+
useLayoutEffect5(() => {
|
|
3192
3293
|
const mirror = (state) => {
|
|
3193
3294
|
onSelectionEngineState(state);
|
|
3194
3295
|
onLoopEngineState(state);
|
|
@@ -3229,7 +3330,7 @@ var ProviderOnArrangement = ({
|
|
|
3229
3330
|
};
|
|
3230
3331
|
runFrameCallbacks(frameData);
|
|
3231
3332
|
const activeAnnotationEnded = followAnnotations({
|
|
3232
|
-
annotations:
|
|
3333
|
+
annotations: getAnnotations(),
|
|
3233
3334
|
lookup: annotationLookup,
|
|
3234
3335
|
time,
|
|
3235
3336
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -3281,7 +3382,7 @@ var ProviderOnArrangement = ({
|
|
|
3281
3382
|
annotationLookup,
|
|
3282
3383
|
// Refs and a stable function from the shared provider hooks: they never
|
|
3283
3384
|
// change, and are listed because the linter cannot see that.
|
|
3284
|
-
|
|
3385
|
+
getAnnotations,
|
|
3285
3386
|
activeAnnotationIdRef,
|
|
3286
3387
|
continuousPlayRef,
|
|
3287
3388
|
isAutomaticScrollRef,
|
|
@@ -3291,8 +3392,8 @@ var ProviderOnArrangement = ({
|
|
|
3291
3392
|
recordingActiveRef
|
|
3292
3393
|
]);
|
|
3293
3394
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
3294
|
-
const prevContinuousPlayRef =
|
|
3295
|
-
|
|
3395
|
+
const prevContinuousPlayRef = useRef21(continuousPlay);
|
|
3396
|
+
useEffect8(() => {
|
|
3296
3397
|
const continuousPlayTurnedOn = continuousPlay && !prevContinuousPlayRef.current && !isSelectionPlayRef.current;
|
|
3297
3398
|
prevContinuousPlayRef.current = continuousPlay;
|
|
3298
3399
|
const reschedulePlayback = () => __async(null, null, function* () {
|
|
@@ -3308,7 +3409,7 @@ var ProviderOnArrangement = ({
|
|
|
3308
3409
|
audioStartPositionRef.current = currentPos;
|
|
3309
3410
|
const boundedEnd = playbackEndTimeRef.current;
|
|
3310
3411
|
const activeId = activeAnnotationIdRef.current;
|
|
3311
|
-
const activeAnnotation = activeId ? annotationLookup.byId(
|
|
3412
|
+
const activeAnnotation = activeId ? annotationLookup.byId(getAnnotations(), activeId) : void 0;
|
|
3312
3413
|
const endsWithAnnotation = boundedEnd !== null && activeAnnotation !== void 0 && Math.abs(boundedEnd - activeAnnotation.end) < 1e-6;
|
|
3313
3414
|
const endTime = endsWithAnnotation ? null : boundedEnd;
|
|
3314
3415
|
playbackEndTimeRef.current = endTime;
|
|
@@ -3333,11 +3434,11 @@ var ProviderOnArrangement = ({
|
|
|
3333
3434
|
animationFrameRef,
|
|
3334
3435
|
getAudioContextTime,
|
|
3335
3436
|
annotationLookup,
|
|
3336
|
-
|
|
3437
|
+
getAnnotations,
|
|
3337
3438
|
activeAnnotationIdRef,
|
|
3338
3439
|
engineRef
|
|
3339
3440
|
]);
|
|
3340
|
-
|
|
3441
|
+
useEffect8(() => {
|
|
3341
3442
|
const resumePlayback = () => __async(null, null, function* () {
|
|
3342
3443
|
const engine = engineRef.current;
|
|
3343
3444
|
const request = pendingResumeRef.current;
|
|
@@ -3534,8 +3635,8 @@ var ProviderOnArrangement = ({
|
|
|
3534
3635
|
pendingResumeRef
|
|
3535
3636
|
]
|
|
3536
3637
|
);
|
|
3537
|
-
const isPlayingValue =
|
|
3538
|
-
const refsValue =
|
|
3638
|
+
const isPlayingValue = useMemo11(() => ({ isPlaying }), [isPlaying]);
|
|
3639
|
+
const refsValue = useMemo11(
|
|
3539
3640
|
() => ({
|
|
3540
3641
|
currentTimeRef,
|
|
3541
3642
|
visualTimeRef,
|
|
@@ -3544,7 +3645,7 @@ var ProviderOnArrangement = ({
|
|
|
3544
3645
|
}),
|
|
3545
3646
|
[currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback]
|
|
3546
3647
|
);
|
|
3547
|
-
const engineRefsValue =
|
|
3648
|
+
const engineRefsValue = useMemo11(
|
|
3548
3649
|
() => ({
|
|
3549
3650
|
playbackStartTimeRef,
|
|
3550
3651
|
audioStartPositionRef,
|
|
@@ -3564,25 +3665,25 @@ var ProviderOnArrangement = ({
|
|
|
3564
3665
|
engineRef
|
|
3565
3666
|
]
|
|
3566
3667
|
);
|
|
3567
|
-
const loopValue =
|
|
3668
|
+
const loopValue = useMemo11(
|
|
3568
3669
|
() => ({ isLoopEnabled, loopStart, loopEnd }),
|
|
3569
3670
|
[isLoopEnabled, loopStart, loopEnd]
|
|
3570
3671
|
);
|
|
3571
|
-
const selectedTrackIdValue =
|
|
3672
|
+
const selectedTrackIdValue = useMemo11(
|
|
3572
3673
|
() => ({ selectedTrackId }),
|
|
3573
3674
|
[selectedTrackId]
|
|
3574
3675
|
);
|
|
3575
3676
|
const { canUndo, canRedo } = view;
|
|
3576
|
-
const undoRedoValue =
|
|
3677
|
+
const undoRedoValue = useMemo11(
|
|
3577
3678
|
() => ({ canUndo, canRedo }),
|
|
3578
3679
|
[canUndo, canRedo]
|
|
3579
3680
|
);
|
|
3580
|
-
const selectionValue =
|
|
3681
|
+
const selectionValue = useMemo11(
|
|
3581
3682
|
() => ({ selectionStart, selectionEnd }),
|
|
3582
3683
|
[selectionStart, selectionEnd]
|
|
3583
3684
|
);
|
|
3584
|
-
const currentTimeValue =
|
|
3585
|
-
const activeAnnotationValue =
|
|
3685
|
+
const currentTimeValue = useMemo11(() => ({ currentTime }), [currentTime]);
|
|
3686
|
+
const activeAnnotationValue = useMemo11(
|
|
3586
3687
|
() => ({ activeAnnotationId }),
|
|
3587
3688
|
[activeAnnotationId]
|
|
3588
3689
|
);
|
|
@@ -3606,7 +3707,7 @@ var ProviderOnArrangement = ({
|
|
|
3606
3707
|
},
|
|
3607
3708
|
[play, setActiveAnnotationId, continuousPlayRef, refusePlayBeforeFirstReady]
|
|
3608
3709
|
);
|
|
3609
|
-
const controlsValue =
|
|
3710
|
+
const controlsValue = useMemo11(
|
|
3610
3711
|
() => ({
|
|
3611
3712
|
play,
|
|
3612
3713
|
pause,
|
|
@@ -3620,8 +3721,8 @@ var ProviderOnArrangement = ({
|
|
|
3620
3721
|
setContinuousPlay,
|
|
3621
3722
|
setAnnotationsEditable,
|
|
3622
3723
|
setLinkEndpoints,
|
|
3623
|
-
setAnnotations,
|
|
3624
3724
|
annotationPreview,
|
|
3725
|
+
annotationStore,
|
|
3625
3726
|
setActiveAnnotationId,
|
|
3626
3727
|
playAnnotation
|
|
3627
3728
|
}),
|
|
@@ -3638,13 +3739,13 @@ var ProviderOnArrangement = ({
|
|
|
3638
3739
|
setContinuousPlay,
|
|
3639
3740
|
setAnnotationsEditable,
|
|
3640
3741
|
setLinkEndpoints,
|
|
3641
|
-
setAnnotations,
|
|
3642
3742
|
annotationPreview,
|
|
3743
|
+
annotationStore,
|
|
3643
3744
|
setActiveAnnotationId,
|
|
3644
3745
|
playAnnotation
|
|
3645
3746
|
]
|
|
3646
3747
|
);
|
|
3647
|
-
const editorControlsValue =
|
|
3748
|
+
const editorControlsValue = useMemo11(
|
|
3648
3749
|
() => ({
|
|
3649
3750
|
setCurrentTime: setCurrentTimeControl,
|
|
3650
3751
|
// Track controls (the arrangement's mix and order)
|
|
@@ -3694,7 +3795,7 @@ var ProviderOnArrangement = ({
|
|
|
3694
3795
|
editing.setRecordingActive
|
|
3695
3796
|
]
|
|
3696
3797
|
);
|
|
3697
|
-
const viewValue =
|
|
3798
|
+
const viewValue = useMemo11(
|
|
3698
3799
|
() => ({
|
|
3699
3800
|
sampleRate,
|
|
3700
3801
|
mono,
|
|
@@ -3702,24 +3803,24 @@ var ProviderOnArrangement = ({
|
|
|
3702
3803
|
}),
|
|
3703
3804
|
[sampleRate, mono, indefinitePlayback]
|
|
3704
3805
|
);
|
|
3705
|
-
const settingsValue =
|
|
3806
|
+
const settingsValue = useMemo11(
|
|
3706
3807
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
3707
3808
|
[timeFormat, isAutomaticScroll]
|
|
3708
3809
|
);
|
|
3709
|
-
const zoomValue =
|
|
3810
|
+
const zoomValue = useMemo11(
|
|
3710
3811
|
() => ({ samplesPerPixel, canZoomIn: zoom.canZoomIn, canZoomOut: zoom.canZoomOut }),
|
|
3711
3812
|
[samplesPerPixel, zoom.canZoomIn, zoom.canZoomOut]
|
|
3712
3813
|
);
|
|
3713
3814
|
const { peaksDataArray, trackStates } = view;
|
|
3714
|
-
const timelineValue =
|
|
3815
|
+
const timelineValue = useMemo11(
|
|
3715
3816
|
() => ({ tracks, peaksDataArray, duration, isReady }),
|
|
3716
3817
|
[tracks, peaksDataArray, duration, isReady]
|
|
3717
3818
|
);
|
|
3718
|
-
const mixerValue =
|
|
3819
|
+
const mixerValue = useMemo11(
|
|
3719
3820
|
() => ({ trackStates, masterVolume }),
|
|
3720
3821
|
[trackStates, masterVolume]
|
|
3721
3822
|
);
|
|
3722
|
-
const reorderPreviewValue =
|
|
3823
|
+
const reorderPreviewValue = useMemo11(
|
|
3723
3824
|
() => ({ trackDragPreview, trackReorderEpoch }),
|
|
3724
3825
|
[trackDragPreview, trackReorderEpoch]
|
|
3725
3826
|
);
|
|
@@ -3746,12 +3847,12 @@ var ProviderOnArrangement = ({
|
|
|
3746
3847
|
|
|
3747
3848
|
// src/MediaElementPlaylistContext.tsx
|
|
3748
3849
|
import {
|
|
3749
|
-
useState as
|
|
3750
|
-
useEffect as
|
|
3751
|
-
useLayoutEffect as
|
|
3752
|
-
useRef as
|
|
3850
|
+
useState as useState17,
|
|
3851
|
+
useEffect as useEffect9,
|
|
3852
|
+
useLayoutEffect as useLayoutEffect6,
|
|
3853
|
+
useRef as useRef22,
|
|
3753
3854
|
useCallback as useCallback20,
|
|
3754
|
-
useMemo as
|
|
3855
|
+
useMemo as useMemo12
|
|
3755
3856
|
} from "react";
|
|
3756
3857
|
import { ThemeProvider as ThemeProvider2 } from "styled-components";
|
|
3757
3858
|
|
|
@@ -3788,40 +3889,39 @@ var MediaElementPlaylistProvider = ({
|
|
|
3788
3889
|
preservesPitch = true,
|
|
3789
3890
|
automaticScroll = false,
|
|
3790
3891
|
theme: userThemeProp,
|
|
3892
|
+
annotationStore,
|
|
3791
3893
|
annotationList,
|
|
3792
3894
|
audioContext,
|
|
3793
|
-
onAnnotationsChange,
|
|
3794
3895
|
onReady,
|
|
3795
3896
|
onError,
|
|
3796
3897
|
createPlayout,
|
|
3797
3898
|
children
|
|
3798
3899
|
}) => {
|
|
3799
3900
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3800
|
-
const [isPlaying, setIsPlayingState] =
|
|
3801
|
-
const isPlayingRef =
|
|
3901
|
+
const [isPlaying, setIsPlayingState] = useState17(false);
|
|
3902
|
+
const isPlayingRef = useRef22(false);
|
|
3802
3903
|
const setIsPlaying = useCallback20((playing) => {
|
|
3803
3904
|
isPlayingRef.current = playing;
|
|
3804
3905
|
setIsPlayingState(playing);
|
|
3805
3906
|
}, []);
|
|
3806
|
-
const [currentTime, setCurrentTime] =
|
|
3807
|
-
const [isReady, setIsReady] =
|
|
3808
|
-
const [playbackRate, setPlaybackRateState] =
|
|
3809
|
-
const [ratePropSeen, setRatePropSeen] =
|
|
3907
|
+
const [currentTime, setCurrentTime] = useState17(0);
|
|
3908
|
+
const [isReady, setIsReady] = useState17(false);
|
|
3909
|
+
const [playbackRate, setPlaybackRateState] = useState17(initialPlaybackRate);
|
|
3910
|
+
const [ratePropSeen, setRatePropSeen] = useState17(initialPlaybackRate);
|
|
3810
3911
|
if (!Object.is(ratePropSeen, initialPlaybackRate)) {
|
|
3811
3912
|
setRatePropSeen(initialPlaybackRate);
|
|
3812
3913
|
setPlaybackRateState(initialPlaybackRate);
|
|
3813
3914
|
}
|
|
3814
|
-
const playbackRateRef =
|
|
3815
|
-
const ratePropAppliedRef =
|
|
3816
|
-
|
|
3915
|
+
const playbackRateRef = useRef22(initialPlaybackRate);
|
|
3916
|
+
const ratePropAppliedRef = useRef22(initialPlaybackRate);
|
|
3917
|
+
useLayoutEffect6(() => {
|
|
3817
3918
|
if (Object.is(ratePropAppliedRef.current, initialPlaybackRate)) return;
|
|
3818
3919
|
ratePropAppliedRef.current = initialPlaybackRate;
|
|
3819
3920
|
playbackRateRef.current = initialPlaybackRate;
|
|
3820
3921
|
}, [initialPlaybackRate]);
|
|
3821
3922
|
const {
|
|
3822
|
-
|
|
3923
|
+
getAnnotations,
|
|
3823
3924
|
annotationLookup,
|
|
3824
|
-
setAnnotations,
|
|
3825
3925
|
annotationPreview,
|
|
3826
3926
|
activeAnnotationId,
|
|
3827
3927
|
activeAnnotationIdRef,
|
|
@@ -3833,9 +3933,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3833
3933
|
annotationsValue,
|
|
3834
3934
|
annotationOptionsValue
|
|
3835
3935
|
} = useAnnotationState({
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
providerName: "MediaElementPlaylistProvider"
|
|
3936
|
+
annotationStore,
|
|
3937
|
+
annotationList
|
|
3839
3938
|
});
|
|
3840
3939
|
const {
|
|
3841
3940
|
scrollContainerRef,
|
|
@@ -3845,27 +3944,27 @@ var MediaElementPlaylistProvider = ({
|
|
|
3845
3944
|
setAutomaticScroll
|
|
3846
3945
|
} = useScrollFollow(automaticScroll);
|
|
3847
3946
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
3848
|
-
const [selection, setSelectionState] =
|
|
3947
|
+
const [selection, setSelectionState] = useState17({
|
|
3849
3948
|
selectionStart: 0,
|
|
3850
3949
|
selectionEnd: 0
|
|
3851
3950
|
});
|
|
3852
|
-
const selectionRef =
|
|
3853
|
-
const [samplesPerPixel] =
|
|
3951
|
+
const selectionRef = useRef22(selection);
|
|
3952
|
+
const [samplesPerPixel] = useState17(initialSamplesPerPixel);
|
|
3854
3953
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3855
|
-
const playoutRef =
|
|
3856
|
-
const currentTimeRef =
|
|
3857
|
-
const samplesPerPixelRef =
|
|
3954
|
+
const playoutRef = useRef22(null);
|
|
3955
|
+
const currentTimeRef = useRef22(0);
|
|
3956
|
+
const samplesPerPixelRef = useRef22(initialSamplesPerPixel);
|
|
3858
3957
|
const { startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3859
|
-
const playStartPositionRef =
|
|
3860
|
-
const playbackEndTimeRef =
|
|
3861
|
-
const isSelectionPlayRef =
|
|
3862
|
-
const pendingPlayRef =
|
|
3863
|
-
const playoutInFlightRef =
|
|
3958
|
+
const playStartPositionRef = useRef22(0);
|
|
3959
|
+
const playbackEndTimeRef = useRef22(null);
|
|
3960
|
+
const isSelectionPlayRef = useRef22(false);
|
|
3961
|
+
const pendingPlayRef = useRef22(null);
|
|
3962
|
+
const playoutInFlightRef = useRef22(true);
|
|
3864
3963
|
const sampleRate = track.waveformData.sample_rate;
|
|
3865
3964
|
const duration = track.waveformData.duration;
|
|
3866
3965
|
const trackName = track.name;
|
|
3867
3966
|
const trackWaveformData = track.waveformData;
|
|
3868
|
-
const trackPeaks =
|
|
3967
|
+
const trackPeaks = useMemo12(() => {
|
|
3869
3968
|
try {
|
|
3870
3969
|
const durationSamples = Math.ceil(trackWaveformData.duration * sampleRate);
|
|
3871
3970
|
const extractedPeaks = extractPeaksFromWaveformData(
|
|
@@ -3894,7 +3993,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
3894
3993
|
}, [trackWaveformData, samplesPerPixel, sampleRate]);
|
|
3895
3994
|
const trackFadeIn = useShallowStable(track.fadeIn);
|
|
3896
3995
|
const trackFadeOut = useShallowStable(track.fadeOut);
|
|
3897
|
-
const peaksDataArray =
|
|
3996
|
+
const peaksDataArray = useMemo12(() => {
|
|
3898
3997
|
if (!trackPeaks) return [];
|
|
3899
3998
|
const clipPeaks = {
|
|
3900
3999
|
clipId: "media-element-clip",
|
|
@@ -3908,8 +4007,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3908
4007
|
};
|
|
3909
4008
|
return [[clipPeaks]];
|
|
3910
4009
|
}, [trackPeaks, trackName, trackFadeIn, trackFadeOut]);
|
|
3911
|
-
const latestAudioRef =
|
|
3912
|
-
|
|
4010
|
+
const latestAudioRef = useRef22({ source: track.source, waveformData: track.waveformData });
|
|
4011
|
+
useLayoutEffect6(() => {
|
|
3913
4012
|
latestAudioRef.current = { source: track.source, waveformData: track.waveformData };
|
|
3914
4013
|
}, [track.source, track.waveformData]);
|
|
3915
4014
|
const restAt = useCallback20(
|
|
@@ -3928,10 +4027,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
3928
4027
|
},
|
|
3929
4028
|
[stopAnimationFrameLoop, setIsPlaying]
|
|
3930
4029
|
);
|
|
3931
|
-
const startAnimationLoopRef =
|
|
4030
|
+
const startAnimationLoopRef = useRef22(() => {
|
|
3932
4031
|
});
|
|
3933
|
-
const endPlaybackIfDueRef =
|
|
3934
|
-
|
|
4032
|
+
const endPlaybackIfDueRef = useRef22(() => false);
|
|
4033
|
+
useEffect9(() => {
|
|
3935
4034
|
let cancelled = false;
|
|
3936
4035
|
let createdPlayout = null;
|
|
3937
4036
|
const source = track.source;
|
|
@@ -4060,7 +4159,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4060
4159
|
const endPlaybackIfDue = useCallback20(
|
|
4061
4160
|
(time) => {
|
|
4062
4161
|
const activeAnnotationEnded = followAnnotations({
|
|
4063
|
-
annotations:
|
|
4162
|
+
annotations: getAnnotations(),
|
|
4064
4163
|
lookup: annotationLookup,
|
|
4065
4164
|
time,
|
|
4066
4165
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -4083,7 +4182,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4083
4182
|
return false;
|
|
4084
4183
|
},
|
|
4085
4184
|
[
|
|
4086
|
-
|
|
4185
|
+
getAnnotations,
|
|
4087
4186
|
annotationLookup,
|
|
4088
4187
|
activeAnnotationIdRef,
|
|
4089
4188
|
continuousPlayRef,
|
|
@@ -4117,7 +4216,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4117
4216
|
runFrameCallbacks,
|
|
4118
4217
|
endPlaybackIfDue
|
|
4119
4218
|
]);
|
|
4120
|
-
|
|
4219
|
+
useLayoutEffect6(() => {
|
|
4121
4220
|
startAnimationLoopRef.current = startAnimationLoop;
|
|
4122
4221
|
endPlaybackIfDueRef.current = endPlaybackIfDue;
|
|
4123
4222
|
}, [startAnimationLoop, endPlaybackIfDue]);
|
|
@@ -4232,17 +4331,17 @@ var MediaElementPlaylistProvider = ({
|
|
|
4232
4331
|
playoutRef.current.setPlaybackRate(clampedRate);
|
|
4233
4332
|
}
|
|
4234
4333
|
}, []);
|
|
4235
|
-
const isPlayingValue =
|
|
4236
|
-
const currentTimeValue =
|
|
4237
|
-
const activeAnnotationValue =
|
|
4334
|
+
const isPlayingValue = useMemo12(() => ({ isPlaying }), [isPlaying]);
|
|
4335
|
+
const currentTimeValue = useMemo12(() => ({ currentTime }), [currentTime]);
|
|
4336
|
+
const activeAnnotationValue = useMemo12(
|
|
4238
4337
|
() => ({ activeAnnotationId }),
|
|
4239
4338
|
[activeAnnotationId]
|
|
4240
4339
|
);
|
|
4241
|
-
const settingsValue =
|
|
4340
|
+
const settingsValue = useMemo12(
|
|
4242
4341
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
4243
4342
|
[timeFormat, isAutomaticScroll]
|
|
4244
4343
|
);
|
|
4245
|
-
const refsValue =
|
|
4344
|
+
const refsValue = useMemo12(
|
|
4246
4345
|
() => ({
|
|
4247
4346
|
currentTimeRef,
|
|
4248
4347
|
visualTimeRef: currentTimeRef,
|
|
@@ -4262,7 +4361,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4262
4361
|
},
|
|
4263
4362
|
[play, setActiveAnnotationId]
|
|
4264
4363
|
);
|
|
4265
|
-
const controlsValue =
|
|
4364
|
+
const controlsValue = useMemo12(
|
|
4266
4365
|
() => ({
|
|
4267
4366
|
play,
|
|
4268
4367
|
pause,
|
|
@@ -4276,8 +4375,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
4276
4375
|
setContinuousPlay,
|
|
4277
4376
|
setAnnotationsEditable,
|
|
4278
4377
|
setLinkEndpoints,
|
|
4279
|
-
setAnnotations,
|
|
4280
4378
|
annotationPreview,
|
|
4379
|
+
annotationStore,
|
|
4281
4380
|
setActiveAnnotationId,
|
|
4282
4381
|
playAnnotation
|
|
4283
4382
|
}),
|
|
@@ -4294,25 +4393,25 @@ var MediaElementPlaylistProvider = ({
|
|
|
4294
4393
|
setContinuousPlay,
|
|
4295
4394
|
setAnnotationsEditable,
|
|
4296
4395
|
setLinkEndpoints,
|
|
4297
|
-
setAnnotations,
|
|
4298
4396
|
annotationPreview,
|
|
4397
|
+
annotationStore,
|
|
4299
4398
|
setActiveAnnotationId,
|
|
4300
4399
|
playAnnotation
|
|
4301
4400
|
]
|
|
4302
4401
|
);
|
|
4303
|
-
const viewValue =
|
|
4402
|
+
const viewValue = useMemo12(
|
|
4304
4403
|
() => ({ sampleRate, mono: false, indefinitePlayback: false }),
|
|
4305
4404
|
[sampleRate]
|
|
4306
4405
|
);
|
|
4307
|
-
const zoomValue =
|
|
4406
|
+
const zoomValue = useMemo12(
|
|
4308
4407
|
() => ({ samplesPerPixel, canZoomIn: false, canZoomOut: false }),
|
|
4309
4408
|
[samplesPerPixel]
|
|
4310
4409
|
);
|
|
4311
|
-
const playbackRateValue =
|
|
4410
|
+
const playbackRateValue = useMemo12(
|
|
4312
4411
|
() => ({ playbackRate, setPlaybackRate }),
|
|
4313
4412
|
[playbackRate, setPlaybackRate]
|
|
4314
4413
|
);
|
|
4315
|
-
const trackValue =
|
|
4414
|
+
const trackValue = useMemo12(
|
|
4316
4415
|
() => ({
|
|
4317
4416
|
duration,
|
|
4318
4417
|
isReady,
|
|
@@ -4466,7 +4565,7 @@ var ZoomOutButton = ({
|
|
|
4466
4565
|
};
|
|
4467
4566
|
|
|
4468
4567
|
// src/components/ContextualControls.tsx
|
|
4469
|
-
import { useRef as
|
|
4568
|
+
import { useRef as useRef23, useEffect as useEffect10, useId } from "react";
|
|
4470
4569
|
import {
|
|
4471
4570
|
MasterVolumeControl as BaseMasterVolumeControl,
|
|
4472
4571
|
TimeFormatSelect as BaseTimeFormatSelect,
|
|
@@ -4506,13 +4605,13 @@ var PositionDisplay = styled.span`
|
|
|
4506
4605
|
`;
|
|
4507
4606
|
var AudioPosition = ({ className }) => {
|
|
4508
4607
|
var _a;
|
|
4509
|
-
const timeRef =
|
|
4608
|
+
const timeRef = useRef23(null);
|
|
4510
4609
|
const { currentTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
4511
4610
|
const { isPlaying } = useIsPlaying();
|
|
4512
4611
|
useCurrentTime();
|
|
4513
4612
|
const { timeFormat: format } = usePlaylistSettings();
|
|
4514
4613
|
const id = useId();
|
|
4515
|
-
|
|
4614
|
+
useEffect10(() => {
|
|
4516
4615
|
if (isPlaying) {
|
|
4517
4616
|
registerFrameCallback(id, ({ time }) => {
|
|
4518
4617
|
if (timeRef.current) {
|
|
@@ -4522,7 +4621,7 @@ var AudioPosition = ({ className }) => {
|
|
|
4522
4621
|
}
|
|
4523
4622
|
return () => unregisterFrameCallback(id);
|
|
4524
4623
|
}, [id, isPlaying, format, registerFrameCallback, unregisterFrameCallback]);
|
|
4525
|
-
|
|
4624
|
+
useEffect10(() => {
|
|
4526
4625
|
var _a2;
|
|
4527
4626
|
if (!isPlaying && timeRef.current) {
|
|
4528
4627
|
timeRef.current.textContent = formatTime((_a2 = currentTimeRef.current) != null ? _a2 : 0, format);
|
|
@@ -4576,10 +4675,10 @@ var AutomaticScrollCheckbox = ({ className }) => {
|
|
|
4576
4675
|
// src/components/WaveformRoot.tsx
|
|
4577
4676
|
import {
|
|
4578
4677
|
use as use13,
|
|
4579
|
-
useLayoutEffect as
|
|
4580
|
-
useRef as
|
|
4581
|
-
useState as
|
|
4582
|
-
useMemo as
|
|
4678
|
+
useLayoutEffect as useLayoutEffect9,
|
|
4679
|
+
useRef as useRef30,
|
|
4680
|
+
useState as useState21,
|
|
4681
|
+
useMemo as useMemo20,
|
|
4583
4682
|
useCallback as useCallback26
|
|
4584
4683
|
} from "react";
|
|
4585
4684
|
import { createPortal } from "react-dom";
|
|
@@ -4619,10 +4718,10 @@ function trackIdAtOffset(orderedIds, layout, heightById, y) {
|
|
|
4619
4718
|
}
|
|
4620
4719
|
|
|
4621
4720
|
// src/hooks/useTrailingActive.ts
|
|
4622
|
-
import { useEffect as
|
|
4721
|
+
import { useEffect as useEffect11, useState as useState18 } from "react";
|
|
4623
4722
|
function useTrailingActive(active, trailingMs) {
|
|
4624
|
-
const [trailing, setTrailing] =
|
|
4625
|
-
|
|
4723
|
+
const [trailing, setTrailing] = useState18(active);
|
|
4724
|
+
useEffect11(() => {
|
|
4626
4725
|
if (active) {
|
|
4627
4726
|
setTrailing(true);
|
|
4628
4727
|
return void 0;
|
|
@@ -4634,7 +4733,7 @@ function useTrailingActive(active, trailingMs) {
|
|
|
4634
4733
|
}
|
|
4635
4734
|
|
|
4636
4735
|
// src/hooks/useRecordingLayout.ts
|
|
4637
|
-
import { useCallback as useCallback22, useSyncExternalStore as
|
|
4736
|
+
import { useCallback as useCallback22, useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
4638
4737
|
var RECORDING_EXTENT_STEP_SECONDS = 10;
|
|
4639
4738
|
function recordingDisplayEnd(takeEndSeconds) {
|
|
4640
4739
|
const step = RECORDING_EXTENT_STEP_SECONDS;
|
|
@@ -4655,19 +4754,19 @@ function useRecordingLayout(progress, startSample, sampleRate) {
|
|
|
4655
4754
|
() => progress && sampleRate > 0 ? recordingDisplayEnd(startSample / sampleRate + progress.getSnapshot().duration) : 0,
|
|
4656
4755
|
[progress, startSample, sampleRate]
|
|
4657
4756
|
);
|
|
4658
|
-
const channelCount =
|
|
4659
|
-
const displayEndSeconds =
|
|
4757
|
+
const channelCount = useSyncExternalStore9(subscribe, getChannelCount, getChannelCount);
|
|
4758
|
+
const displayEndSeconds = useSyncExternalStore9(subscribe, getDisplayEnd, getDisplayEnd);
|
|
4660
4759
|
return { channelCount, displayEndSeconds };
|
|
4661
4760
|
}
|
|
4662
4761
|
|
|
4663
4762
|
// src/hooks/useTrimPreviewView.ts
|
|
4664
|
-
import { useCallback as useCallback23, useMemo as
|
|
4763
|
+
import { useCallback as useCallback23, useMemo as useMemo13, useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
4665
4764
|
var TRIM_EXTENT_STEP_SECONDS = RECORDING_EXTENT_STEP_SECONDS;
|
|
4666
4765
|
var NO_UNSUBSCRIBE = () => {
|
|
4667
4766
|
};
|
|
4668
4767
|
var subscribeToNothing2 = () => NO_UNSUBSCRIBE;
|
|
4669
4768
|
function useSubscribe(source) {
|
|
4670
|
-
return
|
|
4769
|
+
return useMemo13(
|
|
4671
4770
|
() => source ? (onChange) => source.subscribe(onChange) : subscribeToNothing2,
|
|
4672
4771
|
[source]
|
|
4673
4772
|
);
|
|
@@ -4683,8 +4782,8 @@ function usePreviewedClipPeaks(clip, trackId) {
|
|
|
4683
4782
|
const preview2 = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4684
4783
|
return preview2 !== null && preview2.clipId === clipId && preview2.trackId === trackId ? preview2 : null;
|
|
4685
4784
|
}, [source, clipId, trackId]);
|
|
4686
|
-
const preview =
|
|
4687
|
-
return
|
|
4785
|
+
const preview = useSyncExternalStore10(subscribe, getSnapshot, getSnapshot);
|
|
4786
|
+
return useMemo13(
|
|
4688
4787
|
() => {
|
|
4689
4788
|
var _a2;
|
|
4690
4789
|
return preview && peaks ? (_a2 = peaks.peaksFor(preview)) != null ? _a2 : clip : clip;
|
|
@@ -4704,7 +4803,7 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4704
4803
|
if (endSeconds <= durationSeconds) return 0;
|
|
4705
4804
|
return Math.ceil(endSeconds / TRIM_EXTENT_STEP_SECONDS) * TRIM_EXTENT_STEP_SECONDS;
|
|
4706
4805
|
}, [source, sampleRate, durationSeconds]);
|
|
4707
|
-
return
|
|
4806
|
+
return useSyncExternalStore10(subscribe, getSnapshot, getSnapshot);
|
|
4708
4807
|
}
|
|
4709
4808
|
|
|
4710
4809
|
// src/components/WaveformRoot.tsx
|
|
@@ -4779,7 +4878,7 @@ import React17, {
|
|
|
4779
4878
|
createElement,
|
|
4780
4879
|
Fragment as Fragment2,
|
|
4781
4880
|
useCallback as useCallback25,
|
|
4782
|
-
useMemo as
|
|
4881
|
+
useMemo as useMemo19
|
|
4783
4882
|
} from "react";
|
|
4784
4883
|
import {
|
|
4785
4884
|
Playlist,
|
|
@@ -4789,11 +4888,11 @@ import {
|
|
|
4789
4888
|
} from "@waveform-playlist/ui-components";
|
|
4790
4889
|
|
|
4791
4890
|
// src/hooks/useSelectionDrag.ts
|
|
4792
|
-
import { createContext as createContext3, memo as memo2, useLayoutEffect as
|
|
4891
|
+
import { createContext as createContext3, memo as memo2, useLayoutEffect as useLayoutEffect8, useMemo as useMemo14, useRef as useRef25, useState as useState19 } from "react";
|
|
4793
4892
|
import { createValueSource as createValueSource4 } from "@waveform-playlist/core";
|
|
4794
4893
|
|
|
4795
4894
|
// src/hooks/useWindowDrag.ts
|
|
4796
|
-
import { useEffect as
|
|
4895
|
+
import { useEffect as useEffect12, useLayoutEffect as useLayoutEffect7, useRef as useRef24 } from "react";
|
|
4797
4896
|
var activeDrags = 0;
|
|
4798
4897
|
var userSelectBeforeDrags = "";
|
|
4799
4898
|
var webkitUserSelectBeforeDrags = "";
|
|
@@ -4815,11 +4914,11 @@ function suspendTextSelection() {
|
|
|
4815
4914
|
};
|
|
4816
4915
|
}
|
|
4817
4916
|
function useWindowDrag(active, onMove, onEnd) {
|
|
4818
|
-
const callbacksRef =
|
|
4819
|
-
|
|
4917
|
+
const callbacksRef = useRef24({ onMove, onEnd });
|
|
4918
|
+
useLayoutEffect7(() => {
|
|
4820
4919
|
callbacksRef.current = { onMove, onEnd };
|
|
4821
4920
|
});
|
|
4822
|
-
|
|
4921
|
+
useEffect12(() => {
|
|
4823
4922
|
if (!active) return;
|
|
4824
4923
|
const move = (event) => {
|
|
4825
4924
|
if ((event.buttons & 1) === 0) {
|
|
@@ -4860,7 +4959,7 @@ var AutomaticScrollFlag = memo2(function AutomaticScrollFlag2({
|
|
|
4860
4959
|
flagRef
|
|
4861
4960
|
}) {
|
|
4862
4961
|
const { isAutomaticScroll } = usePlaylistSettings();
|
|
4863
|
-
|
|
4962
|
+
useLayoutEffect8(() => {
|
|
4864
4963
|
flagRef.current = isAutomaticScroll;
|
|
4865
4964
|
});
|
|
4866
4965
|
return null;
|
|
@@ -4873,12 +4972,12 @@ function useSelectionDrag({
|
|
|
4873
4972
|
}) {
|
|
4874
4973
|
const { isPlaying } = useIsPlaying();
|
|
4875
4974
|
const { setSelection } = usePlaybackControls();
|
|
4876
|
-
const [isSelecting, setIsSelecting] =
|
|
4877
|
-
const automaticScrollRef =
|
|
4878
|
-
const previewHandle =
|
|
4879
|
-
const pressTimeRef =
|
|
4880
|
-
const wroteSelectionRef =
|
|
4881
|
-
const dragElementRef =
|
|
4975
|
+
const [isSelecting, setIsSelecting] = useState19(false);
|
|
4976
|
+
const automaticScrollRef = useRef25(false);
|
|
4977
|
+
const previewHandle = useMemo14(() => createValueSource4(null), []);
|
|
4978
|
+
const pressTimeRef = useRef25(0);
|
|
4979
|
+
const wroteSelectionRef = useRef25(false);
|
|
4980
|
+
const dragElementRef = useRef25(null);
|
|
4882
4981
|
const timeAt = (clientX) => {
|
|
4883
4982
|
const element = dragElementRef.current;
|
|
4884
4983
|
const x = element ? clampedOffsetX(element, clientX) : null;
|
|
@@ -4969,8 +5068,8 @@ import React9, {
|
|
|
4969
5068
|
createContext as createContext6,
|
|
4970
5069
|
useCallback as useCallback24,
|
|
4971
5070
|
use as use5,
|
|
4972
|
-
useMemo as
|
|
4973
|
-
useSyncExternalStore as
|
|
5071
|
+
useMemo as useMemo16,
|
|
5072
|
+
useSyncExternalStore as useSyncExternalStore11
|
|
4974
5073
|
} from "react";
|
|
4975
5074
|
import {
|
|
4976
5075
|
Track as TrackComponent,
|
|
@@ -4986,7 +5085,7 @@ import {
|
|
|
4986
5085
|
} from "@waveform-playlist/core";
|
|
4987
5086
|
|
|
4988
5087
|
// src/contexts/ClipInteractionContext.tsx
|
|
4989
|
-
import { createContext as createContext5, use as use4, useMemo as
|
|
5088
|
+
import { createContext as createContext5, use as use4, useMemo as useMemo15 } from "react";
|
|
4990
5089
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
4991
5090
|
var NO_CLIP_INTERACTION = { enabled: false, touchOptimized: false };
|
|
4992
5091
|
var ClipInteractionContext = createContext5(NO_CLIP_INTERACTION);
|
|
@@ -4998,7 +5097,7 @@ var ClipInteractionOptions = ({
|
|
|
4998
5097
|
const inherited = use4(ClipInteractionContext);
|
|
4999
5098
|
const enabled = enabledProp != null ? enabledProp : inherited.enabled;
|
|
5000
5099
|
const touchOptimized = touchOptimizedProp != null ? touchOptimizedProp : inherited.touchOptimized;
|
|
5001
|
-
const value =
|
|
5100
|
+
const value = useMemo15(() => ({ enabled, touchOptimized }), [enabled, touchOptimized]);
|
|
5002
5101
|
return /* @__PURE__ */ jsx6(ClipInteractionContext, { value, children });
|
|
5003
5102
|
};
|
|
5004
5103
|
function useClipInteraction() {
|
|
@@ -5009,7 +5108,7 @@ function useClipInteractionEnabled() {
|
|
|
5009
5108
|
}
|
|
5010
5109
|
|
|
5011
5110
|
// src/components/ChannelWithProgress.tsx
|
|
5012
|
-
import { useId as useId2, useRef as
|
|
5111
|
+
import { useId as useId2, useRef as useRef26, useEffect as useEffect13 } from "react";
|
|
5013
5112
|
import styled3 from "styled-components";
|
|
5014
5113
|
import {
|
|
5015
5114
|
clipPixelWidth as computeClipPixelWidth
|
|
@@ -5073,7 +5172,7 @@ var ClipProgress = ({
|
|
|
5073
5172
|
height,
|
|
5074
5173
|
top
|
|
5075
5174
|
}) => {
|
|
5076
|
-
const progressRef =
|
|
5175
|
+
const progressRef = useRef26(null);
|
|
5077
5176
|
const callbackId = useId2();
|
|
5078
5177
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
5079
5178
|
const { isPlaying } = useIsPlaying();
|
|
@@ -5085,7 +5184,7 @@ var ClipProgress = ({
|
|
|
5085
5184
|
clipDurationSamples,
|
|
5086
5185
|
samplesPerPixel
|
|
5087
5186
|
);
|
|
5088
|
-
|
|
5187
|
+
useEffect13(() => {
|
|
5089
5188
|
if (isPlaying) {
|
|
5090
5189
|
registerFrameCallback(callbackId, ({ visualTime, sampleRate: sr }) => {
|
|
5091
5190
|
if (progressRef.current) {
|
|
@@ -5103,7 +5202,7 @@ var ClipProgress = ({
|
|
|
5103
5202
|
registerFrameCallback,
|
|
5104
5203
|
unregisterFrameCallback
|
|
5105
5204
|
]);
|
|
5106
|
-
|
|
5205
|
+
useEffect13(() => {
|
|
5107
5206
|
var _a, _b;
|
|
5108
5207
|
if (!isPlaying && progressRef.current) {
|
|
5109
5208
|
const currentTime = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -5309,7 +5408,7 @@ var RecordingPreviewClip = ({
|
|
|
5309
5408
|
const source = recordingState.progress;
|
|
5310
5409
|
const subscribe = useCallback24((onChange) => source.subscribe(onChange), [source]);
|
|
5311
5410
|
const getSnapshot = useCallback24(() => source.getSnapshot(), [source]);
|
|
5312
|
-
const progress =
|
|
5411
|
+
const progress = useSyncExternalStore11(subscribe, getSnapshot, getSnapshot);
|
|
5313
5412
|
const durationSamples = Math.floor(progress.duration * sampleRate);
|
|
5314
5413
|
const latencyOffsetSamples = resolveRecordingOffsetSamples({
|
|
5315
5414
|
overrideSeconds: recordingState.latencyOffset,
|
|
@@ -5519,7 +5618,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5519
5618
|
const { selectTrack } = rows;
|
|
5520
5619
|
const registerSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.registerSpectrogramCanvas;
|
|
5521
5620
|
const unregisterSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.unregisterSpectrogramCanvas;
|
|
5522
|
-
const clipDisplay =
|
|
5621
|
+
const clipDisplay = useMemo16(
|
|
5523
5622
|
() => ({
|
|
5524
5623
|
gainScaledWaveforms: gainScaled,
|
|
5525
5624
|
showFades,
|
|
@@ -5565,7 +5664,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5565
5664
|
};
|
|
5566
5665
|
|
|
5567
5666
|
// src/components/TrackControlsColumn.tsx
|
|
5568
|
-
import React12, { use as use9, useMemo as
|
|
5667
|
+
import React12, { use as use9, useMemo as useMemo17, useRef as useRef28, useState as useState20 } from "react";
|
|
5569
5668
|
import { useTheme as useTheme3 } from "@waveform-playlist/ui-components";
|
|
5570
5669
|
|
|
5571
5670
|
// src/components/DefaultTrackControls.tsx
|
|
@@ -5602,7 +5701,7 @@ var TrackControlsSharedContext = createContext7(null);
|
|
|
5602
5701
|
var TrackSlotWiringContext = createContext7(null);
|
|
5603
5702
|
|
|
5604
5703
|
// src/hooks/useTrackReorderHandle.ts
|
|
5605
|
-
import { use as use7, useEffect as
|
|
5704
|
+
import { use as use7, useEffect as useEffect14 } from "react";
|
|
5606
5705
|
import { useSortable } from "@dnd-kit/react/sortable";
|
|
5607
5706
|
import { RestrictToVerticalAxis } from "@dnd-kit/abstract/modifiers";
|
|
5608
5707
|
import { Feedback } from "@dnd-kit/dom";
|
|
@@ -5680,12 +5779,12 @@ function useTrackReorderHandle() {
|
|
|
5680
5779
|
// either way. See browser/CLAUDE.md "Track Reordering".
|
|
5681
5780
|
plugins: withMoveFeedback
|
|
5682
5781
|
});
|
|
5683
|
-
|
|
5782
|
+
useEffect14(() => {
|
|
5684
5783
|
if (!wiring) return void 0;
|
|
5685
5784
|
ref(wiring.elementRef.current);
|
|
5686
5785
|
return () => ref(null);
|
|
5687
5786
|
}, [ref, wiring]);
|
|
5688
|
-
|
|
5787
|
+
useEffect14(() => {
|
|
5689
5788
|
if (!wiring) return void 0;
|
|
5690
5789
|
const { handleCount } = wiring;
|
|
5691
5790
|
handleCount.current += 1;
|
|
@@ -5698,12 +5797,12 @@ function useTrackReorderHandle() {
|
|
|
5698
5797
|
handleCount.current -= 1;
|
|
5699
5798
|
};
|
|
5700
5799
|
}, [wiring]);
|
|
5701
|
-
|
|
5800
|
+
useEffect14(() => {
|
|
5702
5801
|
if (!wiring) return void 0;
|
|
5703
5802
|
wiring.setDragSource(isDragSource);
|
|
5704
5803
|
return () => wiring.setDragSource(false);
|
|
5705
5804
|
}, [isDragSource, wiring]);
|
|
5706
|
-
|
|
5805
|
+
useEffect14(() => {
|
|
5707
5806
|
const element = wiring == null ? void 0 : wiring.elementRef.current;
|
|
5708
5807
|
if (!isDragSource || !element) return void 0;
|
|
5709
5808
|
return createDragPopoverHealer(element);
|
|
@@ -5871,7 +5970,7 @@ function DefaultTrackControlsImpl({ children }) {
|
|
|
5871
5970
|
var DefaultTrackControls = React11.memo(DefaultTrackControlsImpl);
|
|
5872
5971
|
|
|
5873
5972
|
// src/utils/stableTemplate.ts
|
|
5874
|
-
import { isValidElement, useRef as
|
|
5973
|
+
import { isValidElement, useRef as useRef27 } from "react";
|
|
5875
5974
|
function sameStyle(a, b) {
|
|
5876
5975
|
if (Object.is(a, b)) return true;
|
|
5877
5976
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
@@ -5901,7 +6000,7 @@ function sameTemplate(a, b) {
|
|
|
5901
6000
|
return false;
|
|
5902
6001
|
}
|
|
5903
6002
|
function useStableTemplate(template) {
|
|
5904
|
-
const kept =
|
|
6003
|
+
const kept = useRef27(template);
|
|
5905
6004
|
if (!sameTemplate(kept.current, template)) {
|
|
5906
6005
|
kept.current = template;
|
|
5907
6006
|
}
|
|
@@ -5944,9 +6043,9 @@ function TrackControlsSlotImpl({
|
|
|
5944
6043
|
} = useEditorControls();
|
|
5945
6044
|
const theme = useTheme3();
|
|
5946
6045
|
const shared = use9(TrackControlsSharedContext);
|
|
5947
|
-
const indexRef =
|
|
6046
|
+
const indexRef = useRef28(index);
|
|
5948
6047
|
indexRef.current = index;
|
|
5949
|
-
const actions =
|
|
6048
|
+
const actions = useMemo17(
|
|
5950
6049
|
() => ({
|
|
5951
6050
|
setMuted: (value2) => setTrackMute(trackId, value2),
|
|
5952
6051
|
setSoloed: (value2) => setTrackSolo(trackId, value2),
|
|
@@ -5970,7 +6069,7 @@ function TrackControlsSlotImpl({
|
|
|
5970
6069
|
shared
|
|
5971
6070
|
]
|
|
5972
6071
|
);
|
|
5973
|
-
const value =
|
|
6072
|
+
const value = useMemo17(
|
|
5974
6073
|
() => __spreadValues({
|
|
5975
6074
|
id: trackId,
|
|
5976
6075
|
kind,
|
|
@@ -6005,9 +6104,9 @@ function TrackControlsSlotImpl({
|
|
|
6005
6104
|
actions
|
|
6006
6105
|
]
|
|
6007
6106
|
);
|
|
6008
|
-
const elementRef =
|
|
6009
|
-
const [isDragSource, setDragSource] =
|
|
6010
|
-
const wiring =
|
|
6107
|
+
const elementRef = useRef28(null);
|
|
6108
|
+
const [isDragSource, setDragSource] = useState20(false);
|
|
6109
|
+
const wiring = useMemo17(
|
|
6011
6110
|
() => ({ elementRef, setDragSource, handleCount: { current: 0 } }),
|
|
6012
6111
|
[]
|
|
6013
6112
|
);
|
|
@@ -6059,10 +6158,10 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6059
6158
|
const spectrogram = use9(SpectrogramIntegrationContext);
|
|
6060
6159
|
const { trackStates } = usePlaylistMixer();
|
|
6061
6160
|
const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
|
|
6062
|
-
const spectrogramRef =
|
|
6161
|
+
const spectrogramRef = useRef28(spectrogram);
|
|
6063
6162
|
spectrogramRef.current = spectrogram;
|
|
6064
6163
|
const menuAvailable = Boolean(spectrogram == null ? void 0 : spectrogram.renderMenuItems);
|
|
6065
|
-
const shared =
|
|
6164
|
+
const shared = useMemo17(
|
|
6066
6165
|
() => ({
|
|
6067
6166
|
menuAvailable,
|
|
6068
6167
|
menuItems: (args) => {
|
|
@@ -6118,7 +6217,7 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6118
6217
|
var WaveformTrackControls = React12.memo(WaveformTrackControlsImpl);
|
|
6119
6218
|
|
|
6120
6219
|
// src/components/VisualizationOverlays.tsx
|
|
6121
|
-
import React14, { use as use10, useSyncExternalStore as
|
|
6220
|
+
import React14, { use as use10, useSyncExternalStore as useSyncExternalStore12 } from "react";
|
|
6122
6221
|
import {
|
|
6123
6222
|
Selection,
|
|
6124
6223
|
TimescaleLoopRegion,
|
|
@@ -6126,7 +6225,7 @@ import {
|
|
|
6126
6225
|
} from "@waveform-playlist/ui-components";
|
|
6127
6226
|
|
|
6128
6227
|
// src/components/AnimatedPlayhead.tsx
|
|
6129
|
-
import { useRef as
|
|
6228
|
+
import { useRef as useRef29, useEffect as useEffect15, useId as useId3 } from "react";
|
|
6130
6229
|
import styled5 from "styled-components";
|
|
6131
6230
|
import { usePlaylistInfo as usePlaylistInfo3 } from "@waveform-playlist/ui-components";
|
|
6132
6231
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
@@ -6145,7 +6244,7 @@ var PlayheadLine = styled5.div.attrs((props) => ({
|
|
|
6145
6244
|
will-change: transform;
|
|
6146
6245
|
`;
|
|
6147
6246
|
var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
6148
|
-
const playheadRef =
|
|
6247
|
+
const playheadRef = useRef29(null);
|
|
6149
6248
|
const frameCallbackId = useId3();
|
|
6150
6249
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
6151
6250
|
const { isPlaying } = useIsPlaying();
|
|
@@ -6153,7 +6252,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6153
6252
|
const { sampleRate } = usePlaylistView();
|
|
6154
6253
|
const { progressBarWidth } = usePlaylistInfo3();
|
|
6155
6254
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6156
|
-
|
|
6255
|
+
useEffect15(() => {
|
|
6157
6256
|
if (isPlaying) {
|
|
6158
6257
|
registerFrameCallback(
|
|
6159
6258
|
frameCallbackId,
|
|
@@ -6167,7 +6266,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6167
6266
|
}
|
|
6168
6267
|
return () => unregisterFrameCallback(frameCallbackId);
|
|
6169
6268
|
}, [isPlaying, frameCallbackId, registerFrameCallback, unregisterFrameCallback]);
|
|
6170
|
-
|
|
6269
|
+
useEffect15(() => {
|
|
6171
6270
|
var _a, _b;
|
|
6172
6271
|
if (!isPlaying && playheadRef.current) {
|
|
6173
6272
|
const time = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -6189,7 +6288,7 @@ var WaveformSelection = React14.memo(function WaveformSelection2() {
|
|
|
6189
6288
|
const { sampleRate } = usePlaylistView();
|
|
6190
6289
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6191
6290
|
const previewSource = use10(SelectionPreviewContext);
|
|
6192
|
-
const preview =
|
|
6291
|
+
const preview = useSyncExternalStore12(
|
|
6193
6292
|
previewSource ? (onChange) => previewSource.subscribe(onChange) : subscribeToNothing3,
|
|
6194
6293
|
previewSource ? () => previewSource.getSnapshot() : noPreview,
|
|
6195
6294
|
previewSource ? () => previewSource.getSnapshot() : noPreview
|
|
@@ -6271,7 +6370,7 @@ var WaveformLoopRegion = React14.memo(function WaveformLoopRegion2() {
|
|
|
6271
6370
|
});
|
|
6272
6371
|
|
|
6273
6372
|
// src/components/WaveformViewOptions.tsx
|
|
6274
|
-
import { createContext as createContext8, use as use11, useMemo as
|
|
6373
|
+
import { createContext as createContext8, use as use11, useMemo as useMemo18 } from "react";
|
|
6275
6374
|
import {
|
|
6276
6375
|
DEFAULT_BAR_GAP,
|
|
6277
6376
|
DEFAULT_BAR_WIDTH,
|
|
@@ -6296,7 +6395,7 @@ var WaveformViewOptions = ({
|
|
|
6296
6395
|
const roundedBars = ownRoundedBars != null ? ownRoundedBars : above.roundedBars;
|
|
6297
6396
|
const progressBarWidth = ownProgressBarWidth != null ? ownProgressBarWidth : above.progressBarWidth;
|
|
6298
6397
|
const fillViewport = ownFillViewport != null ? ownFillViewport : above.fillViewport;
|
|
6299
|
-
const value =
|
|
6398
|
+
const value = useMemo18(
|
|
6300
6399
|
() => ({ waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport }),
|
|
6301
6400
|
[waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport]
|
|
6302
6401
|
);
|
|
@@ -6450,7 +6549,7 @@ function keyedByKind(parts) {
|
|
|
6450
6549
|
});
|
|
6451
6550
|
}
|
|
6452
6551
|
function useWaveformParts(children) {
|
|
6453
|
-
return
|
|
6552
|
+
return useMemo19(() => {
|
|
6454
6553
|
const sorted = sortWaveformParts(children);
|
|
6455
6554
|
return {
|
|
6456
6555
|
// One element per place. The tracks-area and controls parts are its
|
|
@@ -6500,7 +6599,7 @@ function useWaveformFrame({
|
|
|
6500
6599
|
preview: selectionPreview,
|
|
6501
6600
|
automaticScrollRef
|
|
6502
6601
|
} = useSelectionDrag({ samplesPerPixel, sampleRate, onPress, onClickWhileStopped });
|
|
6503
|
-
const playlistInfo =
|
|
6602
|
+
const playlistInfo = useMemo19(
|
|
6504
6603
|
() => ({
|
|
6505
6604
|
samplesPerPixel,
|
|
6506
6605
|
sampleRate,
|
|
@@ -6522,7 +6621,7 @@ function useWaveformFrame({
|
|
|
6522
6621
|
progressBarWidth
|
|
6523
6622
|
]
|
|
6524
6623
|
);
|
|
6525
|
-
const extent =
|
|
6624
|
+
const extent = useMemo19(
|
|
6526
6625
|
() => ({ displayDuration, tracksFullWidth }),
|
|
6527
6626
|
[displayDuration, tracksFullWidth]
|
|
6528
6627
|
);
|
|
@@ -6573,7 +6672,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6573
6672
|
const spectrogram = use13(SpectrogramIntegrationContext);
|
|
6574
6673
|
const parts = useWaveformParts(children);
|
|
6575
6674
|
const { showClipHeaders, recordingState } = parts.tracksOptions;
|
|
6576
|
-
const spectrogramHelpersById =
|
|
6675
|
+
const spectrogramHelpersById = useMemo20(() => {
|
|
6577
6676
|
const helpers = /* @__PURE__ */ new Map();
|
|
6578
6677
|
if (!spectrogram) return helpers;
|
|
6579
6678
|
tracks.forEach((track) => {
|
|
@@ -6594,7 +6693,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6594
6693
|
});
|
|
6595
6694
|
return helpers;
|
|
6596
6695
|
}, [tracks, spectrogram]);
|
|
6597
|
-
const renderModeById =
|
|
6696
|
+
const renderModeById = useMemo20(() => {
|
|
6598
6697
|
const modes = /* @__PURE__ */ new Map();
|
|
6599
6698
|
tracks.forEach((track) => {
|
|
6600
6699
|
var _a2;
|
|
@@ -6614,12 +6713,12 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6614
6713
|
const recordingTrackId = (recordingState == null ? void 0 : recordingState.isRecording) ? recordingState.trackId : null;
|
|
6615
6714
|
const trimPreviewEnd = useTrimPreviewExtent(sampleRate, duration);
|
|
6616
6715
|
const recordingChannelCount = recordingProgress ? mono ? 1 : recordingLayout.channelCount : 0;
|
|
6617
|
-
const [settingsModalTrackId, setSettingsModalTrackId] =
|
|
6716
|
+
const [settingsModalTrackId, setSettingsModalTrackId] = useState21(null);
|
|
6618
6717
|
const closeSettingsModal = useCallback26(() => setSettingsModalTrackId(null), []);
|
|
6619
|
-
const [scrollContainerElement, setScrollContainerElement] =
|
|
6718
|
+
const [scrollContainerElement, setScrollContainerElement] = useState21(null);
|
|
6620
6719
|
const fillsContainer = indefinitePlayback || fillViewport;
|
|
6621
|
-
const [scrollContainerWidth, setScrollContainerWidth] =
|
|
6622
|
-
|
|
6720
|
+
const [scrollContainerWidth, setScrollContainerWidth] = useState21(0);
|
|
6721
|
+
useLayoutEffect9(() => {
|
|
6623
6722
|
if (!fillsContainer || !scrollContainerElement) return;
|
|
6624
6723
|
const measure = () => setScrollContainerWidth(scrollContainerElement.clientWidth);
|
|
6625
6724
|
measure();
|
|
@@ -6628,7 +6727,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6628
6727
|
observer.observe(scrollContainerElement);
|
|
6629
6728
|
return () => observer.disconnect();
|
|
6630
6729
|
}, [fillsContainer, scrollContainerElement]);
|
|
6631
|
-
const placeholdersEndSeconds =
|
|
6730
|
+
const placeholdersEndSeconds = useMemo20(() => placeholdersEnd(peaksDataArray), [peaksDataArray]);
|
|
6632
6731
|
let displayDuration = Math.max(
|
|
6633
6732
|
duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION,
|
|
6634
6733
|
placeholdersEndSeconds
|
|
@@ -6641,7 +6740,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6641
6740
|
displayDuration = Math.max(displayDuration, recordingLayout.displayEndSeconds);
|
|
6642
6741
|
}
|
|
6643
6742
|
displayDuration = Math.max(displayDuration, trimPreviewEnd);
|
|
6644
|
-
const tracksRef =
|
|
6743
|
+
const tracksRef = useRef30(tracks);
|
|
6645
6744
|
tracksRef.current = tracks;
|
|
6646
6745
|
const selectTrack = useCallback26(
|
|
6647
6746
|
(trackIndex) => {
|
|
@@ -6652,7 +6751,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6652
6751
|
},
|
|
6653
6752
|
[setSelectedTrackId]
|
|
6654
6753
|
);
|
|
6655
|
-
const trackHeightById =
|
|
6754
|
+
const trackHeightById = useMemo20(() => {
|
|
6656
6755
|
const m = /* @__PURE__ */ new Map();
|
|
6657
6756
|
peaksDataArray.forEach((trackClipPeaks, trackIndex) => {
|
|
6658
6757
|
const track = tracks[trackIndex];
|
|
@@ -6672,21 +6771,21 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6672
6771
|
waveHeight,
|
|
6673
6772
|
showClipHeaders
|
|
6674
6773
|
]);
|
|
6675
|
-
const displayOrderIds =
|
|
6774
|
+
const displayOrderIds = useMemo20(
|
|
6676
6775
|
() => applyTrackOrderPreview(tracks, trackDragPreview).map((t) => t.id),
|
|
6677
6776
|
[tracks, trackDragPreview]
|
|
6678
6777
|
);
|
|
6679
|
-
const trackLayout =
|
|
6778
|
+
const trackLayout = useMemo20(
|
|
6680
6779
|
() => computeTrackLayout(displayOrderIds, trackHeightById),
|
|
6681
6780
|
[displayOrderIds, trackHeightById]
|
|
6682
6781
|
);
|
|
6683
6782
|
const animateTrackLayout = useTrailingActive(trackDragPreview !== null, 200);
|
|
6684
|
-
const rowList =
|
|
6783
|
+
const rowList = useMemo20(
|
|
6685
6784
|
() => tracks.map((track) => ({ id: track.id, kind: trackKind2(track) })),
|
|
6686
6785
|
[tracks]
|
|
6687
6786
|
);
|
|
6688
6787
|
const dragSourceTrackId = (_b = trackDragPreview == null ? void 0 : trackDragPreview.trackId) != null ? _b : null;
|
|
6689
|
-
const rows =
|
|
6788
|
+
const rows = useMemo20(
|
|
6690
6789
|
() => ({
|
|
6691
6790
|
rows: rowList,
|
|
6692
6791
|
peaksDataArray,
|
|
@@ -6855,7 +6954,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
|
|
|
6855
6954
|
const { annotations } = useAnnotations();
|
|
6856
6955
|
const { editable, linkEndpoints } = useAnnotationOptions();
|
|
6857
6956
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6858
|
-
const {
|
|
6957
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6859
6958
|
const { sampleRate } = usePlaylistView();
|
|
6860
6959
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6861
6960
|
const { touchOptimized } = useClipInteraction();
|
|
@@ -6863,8 +6962,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
|
|
|
6863
6962
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6864
6963
|
const sensors = useDragSensors({ touchOptimized });
|
|
6865
6964
|
const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
|
|
6866
|
-
|
|
6867
|
-
onAnnotationsChange: setAnnotations,
|
|
6965
|
+
store: annotationStore,
|
|
6868
6966
|
preview: annotationPreview,
|
|
6869
6967
|
samplesPerPixel,
|
|
6870
6968
|
sampleRate,
|
|
@@ -6900,7 +6998,7 @@ var WaveformAnnotationBoxes = React20.memo(function WaveformAnnotationBoxes2({
|
|
|
6900
6998
|
});
|
|
6901
6999
|
|
|
6902
7000
|
// src/components/AnnotationList.tsx
|
|
6903
|
-
import { use as use17, useMemo as
|
|
7001
|
+
import { use as use17, useMemo as useMemo21 } from "react";
|
|
6904
7002
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
6905
7003
|
var AnnotationList = ({
|
|
6906
7004
|
height,
|
|
@@ -6913,9 +7011,9 @@ var AnnotationList = ({
|
|
|
6913
7011
|
const { annotations } = useAnnotations();
|
|
6914
7012
|
const { editable, linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
6915
7013
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6916
|
-
const {
|
|
7014
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6917
7015
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6918
|
-
const actionOptions =
|
|
7016
|
+
const actionOptions = useMemo21(
|
|
6919
7017
|
() => ({ linkEndpoints, continuousPlay }),
|
|
6920
7018
|
[linkEndpoints, continuousPlay]
|
|
6921
7019
|
);
|
|
@@ -6941,7 +7039,7 @@ var AnnotationList = ({
|
|
|
6941
7039
|
annotationListConfig: actionOptions,
|
|
6942
7040
|
height,
|
|
6943
7041
|
onAnnotationClick: playAnnotation,
|
|
6944
|
-
|
|
7042
|
+
store: annotationStore,
|
|
6945
7043
|
renderAnnotationItem: children
|
|
6946
7044
|
}
|
|
6947
7045
|
);
|
|
@@ -6979,7 +7077,7 @@ var Waveform = (props) => composeWaveform(__spreadProps(__spreadValues({}, props
|
|
|
6979
7077
|
var WaveformEditor = (props) => composeWaveform(__spreadProps(__spreadValues({}, props), { tracks: TRACKS_WITH_HEADERS_AND_FADES }));
|
|
6980
7078
|
|
|
6981
7079
|
// src/components/MediaElementWaveformRoot.tsx
|
|
6982
|
-
import { useCallback as useCallback27, useMemo as
|
|
7080
|
+
import { useCallback as useCallback27, useMemo as useMemo22 } from "react";
|
|
6983
7081
|
import { DevicePixelRatioProvider as DevicePixelRatioProvider2, CLIP_HEADER_HEIGHT as CLIP_HEADER_HEIGHT2 } from "@waveform-playlist/ui-components";
|
|
6984
7082
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
6985
7083
|
var ONE_ROW = [{ id: MEDIA_ELEMENT_TRACK_ID, kind: "audio" }];
|
|
@@ -7003,7 +7101,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7003
7101
|
);
|
|
7004
7102
|
}
|
|
7005
7103
|
const { showClipHeaders } = parts.tracksOptions;
|
|
7006
|
-
const rows =
|
|
7104
|
+
const rows = useMemo22(() => {
|
|
7007
7105
|
const rowList = ONE_ROW;
|
|
7008
7106
|
const rowPeaks = peaksDataArray.length > 0 ? peaksDataArray : ONE_EMPTY_ROW;
|
|
7009
7107
|
const trackHeightById = /* @__PURE__ */ new Map();
|
|
@@ -7083,7 +7181,7 @@ var KeyboardShortcuts = ({
|
|
|
7083
7181
|
const { annotations: annotationList } = useAnnotations();
|
|
7084
7182
|
const { linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
7085
7183
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
7086
|
-
const {
|
|
7184
|
+
const { annotationStore, setActiveAnnotationId, scrollContainerRef, play } = usePlaybackControls();
|
|
7087
7185
|
const { undo, redo } = useEditorControls();
|
|
7088
7186
|
const { splitClipAtPlayhead } = useClipSplitting({ samplesPerPixel });
|
|
7089
7187
|
const allAdditional = [];
|
|
@@ -7110,9 +7208,8 @@ var KeyboardShortcuts = ({
|
|
|
7110
7208
|
enabled: playback || allAdditional.length > 0
|
|
7111
7209
|
}, playback ? { additionalShortcuts: allAdditional } : { shortcuts: allAdditional }));
|
|
7112
7210
|
useAnnotationKeyboardControls({
|
|
7113
|
-
|
|
7211
|
+
store: annotationStore,
|
|
7114
7212
|
activeAnnotationId,
|
|
7115
|
-
onAnnotationsChange: setAnnotations,
|
|
7116
7213
|
onActiveAnnotationChange: setActiveAnnotationId,
|
|
7117
7214
|
duration,
|
|
7118
7215
|
linkEndpoints,
|
|
@@ -7125,11 +7222,11 @@ var KeyboardShortcuts = ({
|
|
|
7125
7222
|
};
|
|
7126
7223
|
|
|
7127
7224
|
// src/hooks/useRecordingSession.ts
|
|
7128
|
-
import { useEffect as
|
|
7225
|
+
import { useEffect as useEffect16 } from "react";
|
|
7129
7226
|
function useRecordingSession({ isRecording, trackId }) {
|
|
7130
7227
|
const { setRecordingActive } = useEditorControls();
|
|
7131
7228
|
const armedTrackId = trackId != null ? trackId : null;
|
|
7132
|
-
|
|
7229
|
+
useEffect16(() => {
|
|
7133
7230
|
if (!isRecording) return void 0;
|
|
7134
7231
|
setRecordingActive(true, armedTrackId);
|
|
7135
7232
|
return () => setRecordingActive(false);
|
|
@@ -7137,7 +7234,7 @@ function useRecordingSession({ isRecording, trackId }) {
|
|
|
7137
7234
|
}
|
|
7138
7235
|
|
|
7139
7236
|
// src/components/ClipInteractionProvider.tsx
|
|
7140
|
-
import React23, { useCallback as useCallback28, useMemo as
|
|
7237
|
+
import React23, { useCallback as useCallback28, useMemo as useMemo23, useRef as useRef31 } from "react";
|
|
7141
7238
|
import { flushSync as flushSync2 } from "react-dom";
|
|
7142
7239
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
|
7143
7240
|
import { RestrictToHorizontalAxis as RestrictToHorizontalAxis2 } from "@dnd-kit/abstract/modifiers";
|
|
@@ -7244,7 +7341,7 @@ var ClipInteractionProvider = ({
|
|
|
7244
7341
|
const beatsAndBars = useBeatsAndBars();
|
|
7245
7342
|
const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
|
|
7246
7343
|
const useTimescaleSnap = snap && !useBeatsSnap;
|
|
7247
|
-
const snapSamplePosition =
|
|
7344
|
+
const snapSamplePosition = useMemo23(() => {
|
|
7248
7345
|
if (useBeatsSnap && beatsAndBars) {
|
|
7249
7346
|
const { bpm, timeSignature, snapTo } = beatsAndBars;
|
|
7250
7347
|
const gridTicks = snapTo === "bar" ? ticksPerBar2(timeSignature) : ticksPerBeat2(timeSignature);
|
|
@@ -7260,7 +7357,7 @@ var ClipInteractionProvider = ({
|
|
|
7260
7357
|
}
|
|
7261
7358
|
return void 0;
|
|
7262
7359
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, sampleRate, samplesPerPixel]);
|
|
7263
|
-
const tracksRef =
|
|
7360
|
+
const tracksRef = useRef31(tracks);
|
|
7264
7361
|
tracksRef.current = tracks;
|
|
7265
7362
|
const getTracks = useCallback28(() => tracksRef.current, []);
|
|
7266
7363
|
const sensors = useDragSensors({ touchOptimized });
|
|
@@ -7324,7 +7421,7 @@ var ClipInteractionProvider = ({
|
|
|
7324
7421
|
},
|
|
7325
7422
|
[onDragEnd, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview]
|
|
7326
7423
|
);
|
|
7327
|
-
const modifiers =
|
|
7424
|
+
const modifiers = useMemo23(() => {
|
|
7328
7425
|
const mods = [RestrictToHorizontalAxis2];
|
|
7329
7426
|
if (useBeatsSnap && beatsAndBars) {
|
|
7330
7427
|
mods.push(
|
|
@@ -7432,6 +7529,7 @@ export {
|
|
|
7432
7529
|
useClipDragHandlers,
|
|
7433
7530
|
useClipInteractionEnabled,
|
|
7434
7531
|
useClipSplitting,
|
|
7532
|
+
useCreateAnnotationStore,
|
|
7435
7533
|
useCreateArrangement,
|
|
7436
7534
|
useCurrentTime,
|
|
7437
7535
|
useDragSensors,
|
|
@@ -7455,6 +7553,7 @@ export {
|
|
|
7455
7553
|
useSelectedTrackId,
|
|
7456
7554
|
useSelection,
|
|
7457
7555
|
useSpectrogramIntegration,
|
|
7556
|
+
useStoredAnnotations,
|
|
7458
7557
|
useTimeFormat,
|
|
7459
7558
|
useTrack,
|
|
7460
7559
|
useTrackReorderHandle,
|