@waveform-playlist/browser 17.0.0-next.0 → 17.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.d.mts +145 -126
- package/dist/index.d.ts +145 -126
- package/dist/index.js +987 -820
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -637
- package/dist/index.mjs.map +1 -1
- package/dist/tone.d.mts +0 -6
- package/dist/tone.d.ts +0 -6
- package/dist/tone.js +18 -2
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +18 -2
- package/dist/tone.mjs.map +1 -1
- package/package.json +13 -11
package/dist/index.js
CHANGED
|
@@ -148,6 +148,7 @@ __export(index_exports, {
|
|
|
148
148
|
useClipDragHandlers: () => useClipDragHandlers,
|
|
149
149
|
useClipInteractionEnabled: () => useClipInteractionEnabled,
|
|
150
150
|
useClipSplitting: () => useClipSplitting,
|
|
151
|
+
useCreateAnnotationStore: () => useCreateAnnotationStore,
|
|
151
152
|
useCreateArrangement: () => useCreateArrangement,
|
|
152
153
|
useCurrentTime: () => useCurrentTime,
|
|
153
154
|
useDragSensors: () => useDragSensors,
|
|
@@ -171,6 +172,7 @@ __export(index_exports, {
|
|
|
171
172
|
useSelectedTrackId: () => useSelectedTrackId,
|
|
172
173
|
useSelection: () => useSelection,
|
|
173
174
|
useSpectrogramIntegration: () => useSpectrogramIntegration,
|
|
175
|
+
useStoredAnnotations: () => useStoredAnnotations,
|
|
174
176
|
useTimeFormat: () => useTimeFormat,
|
|
175
177
|
useTrack: () => useTrack,
|
|
176
178
|
useTrackReorderHandle: () => useTrackReorderHandle,
|
|
@@ -181,8 +183,11 @@ __export(index_exports, {
|
|
|
181
183
|
});
|
|
182
184
|
module.exports = __toCommonJS(index_exports);
|
|
183
185
|
|
|
186
|
+
// <define:__INSTALL_SPECS__>
|
|
187
|
+
var define_INSTALL_SPECS_default = { "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@dnd-kit/abstract": "@dnd-kit/abstract@^0.5.0", "@dnd-kit/dom": "@dnd-kit/dom@^0.5.0", "@dnd-kit/react": "@dnd-kit/react@^0.5.0", "@waveform-playlist/annotations": "@waveform-playlist/annotations@^14.0.0-next.6", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.4", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.4", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.6", react: "react@^19.0.0", "react-dom": "react-dom@^19.0.0", "styled-components": "styled-components@^6.0.0", tone: "tone@^15.0.0", "@waveform-playlist/spectrogram": "@waveform-playlist/spectrogram@^15.0.0-next.4" };
|
|
188
|
+
|
|
184
189
|
// src/WaveformPlaylistContext.tsx
|
|
185
|
-
var
|
|
190
|
+
var import_react35 = require("react");
|
|
186
191
|
var import_styled_components = require("styled-components");
|
|
187
192
|
|
|
188
193
|
// src/soundFontSync.ts
|
|
@@ -536,7 +541,8 @@ var PlaylistMixerContext = slot();
|
|
|
536
541
|
var TrackReorderPreviewContext = slot();
|
|
537
542
|
var TrimPreviewContext = slot();
|
|
538
543
|
var TrimPreviewPeaksContext = slot();
|
|
539
|
-
var
|
|
544
|
+
var DragGuardContext = slot();
|
|
545
|
+
var RecordingTrackContext = slot();
|
|
540
546
|
var PlaybackRateContext = slot();
|
|
541
547
|
var MediaElementTrackContext = slot();
|
|
542
548
|
function useSlot(context, hookName, needs) {
|
|
@@ -574,7 +580,7 @@ var useUndoRedo = () => useSlot(UndoRedoContext, "useUndoRedo", WEB_AUDIO);
|
|
|
574
580
|
var usePlaylistTimeline = () => useSlot(PlaylistTimelineContext, "usePlaylistTimeline", WEB_AUDIO);
|
|
575
581
|
var usePlaylistMixer = () => useSlot(PlaylistMixerContext, "usePlaylistMixer", WEB_AUDIO);
|
|
576
582
|
var useTrackReorderPreview = () => useSlot(TrackReorderPreviewContext, "useTrackReorderPreview", WEB_AUDIO);
|
|
577
|
-
var
|
|
583
|
+
var useRecordingTrack = () => useSlot(RecordingTrackContext, "useRecordingTrack", WEB_AUDIO);
|
|
578
584
|
var usePlaybackRate = () => useSlot(PlaybackRateContext, "usePlaybackRate", MEDIA_ELEMENT);
|
|
579
585
|
var useMediaElementTrack = () => useSlot(MediaElementTrackContext, "useMediaElementTrack", MEDIA_ELEMENT);
|
|
580
586
|
var useWebAudioProviderOnly = (hookName) => {
|
|
@@ -589,6 +595,7 @@ var usePlaylistViewOptional = () => orNull((0, import_react7.use)(PlaylistViewCo
|
|
|
589
595
|
var usePlaylistZoomOptional = () => orNull((0, import_react7.use)(PlaylistZoomContext));
|
|
590
596
|
var useTrimPreviewOptional = () => orNull((0, import_react7.use)(TrimPreviewContext));
|
|
591
597
|
var useTrimPreviewPeaksOptional = () => orNull((0, import_react7.use)(TrimPreviewPeaksContext));
|
|
598
|
+
var useDragGuardOptional = () => orNull((0, import_react7.use)(DragGuardContext));
|
|
592
599
|
|
|
593
600
|
// src/hooks/useClipDragHandlers.ts
|
|
594
601
|
function trimOrderFor(clips, clip) {
|
|
@@ -651,6 +658,14 @@ function useClipDragHandlers({
|
|
|
651
658
|
const trimDragRef = import_react8.default.useRef(null);
|
|
652
659
|
const lastBoundaryDeltaRef = import_react8.default.useRef(0);
|
|
653
660
|
const moveDragRef = import_react8.default.useRef(null);
|
|
661
|
+
const dragGuard = useDragGuardOptional();
|
|
662
|
+
const endGuardRef = import_react8.default.useRef(null);
|
|
663
|
+
const endGuard = import_react8.default.useCallback(() => {
|
|
664
|
+
var _a;
|
|
665
|
+
(_a = endGuardRef.current) == null ? void 0 : _a.call(endGuardRef);
|
|
666
|
+
endGuardRef.current = null;
|
|
667
|
+
}, []);
|
|
668
|
+
import_react8.default.useEffect(() => endGuard, [endGuard]);
|
|
654
669
|
import_react8.default.useEffect(() => {
|
|
655
670
|
if (!preview) return;
|
|
656
671
|
return () => {
|
|
@@ -662,9 +677,11 @@ function useClipDragHandlers({
|
|
|
662
677
|
}, [preview]);
|
|
663
678
|
const onDragStart = import_react8.default.useCallback(
|
|
664
679
|
(event) => {
|
|
665
|
-
var _a;
|
|
680
|
+
var _a, _b;
|
|
666
681
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
667
682
|
if (!data || data.kind === "track-reorder") return;
|
|
683
|
+
endGuard();
|
|
684
|
+
endGuardRef.current = (_b = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _b : null;
|
|
668
685
|
trimDragRef.current = null;
|
|
669
686
|
trimOrderRef.current = null;
|
|
670
687
|
moveDragRef.current = null;
|
|
@@ -690,7 +707,7 @@ function useClipDragHandlers({
|
|
|
690
707
|
};
|
|
691
708
|
trimOrderRef.current = trimOrderFor(clips, clip);
|
|
692
709
|
},
|
|
693
|
-
[arrangement]
|
|
710
|
+
[arrangement, dragGuard, endGuard]
|
|
694
711
|
);
|
|
695
712
|
const onDragMove = import_react8.default.useCallback(
|
|
696
713
|
(event) => {
|
|
@@ -742,6 +759,7 @@ function useClipDragHandlers({
|
|
|
742
759
|
var _a, _b;
|
|
743
760
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
744
761
|
if ((data == null ? void 0 : data.kind) === "track-reorder") return;
|
|
762
|
+
endGuard();
|
|
745
763
|
const drag = trimDragRef.current;
|
|
746
764
|
const move = moveDragRef.current;
|
|
747
765
|
const delta = lastBoundaryDeltaRef.current;
|
|
@@ -774,7 +792,7 @@ function useClipDragHandlers({
|
|
|
774
792
|
arrangement.moveClip(track.id, clipId, Math.floor(sampleDelta));
|
|
775
793
|
}
|
|
776
794
|
},
|
|
777
|
-
[samplesPerPixel, arrangement, preview, commitTrim]
|
|
795
|
+
[samplesPerPixel, arrangement, preview, commitTrim, endGuard]
|
|
778
796
|
);
|
|
779
797
|
return {
|
|
780
798
|
onDragStart,
|
|
@@ -787,9 +805,21 @@ function useClipDragHandlers({
|
|
|
787
805
|
var import_react9 = __toESM(require("react"));
|
|
788
806
|
var import_react_dom = require("react-dom");
|
|
789
807
|
var import_core2 = require("@waveform-playlist/core");
|
|
808
|
+
function touchedChanges(drag) {
|
|
809
|
+
return [...drag.touched.values()];
|
|
810
|
+
}
|
|
811
|
+
function snapshotBounds(drag) {
|
|
812
|
+
const before = new Map(drag.snapshot.map((a) => [a.id, a]));
|
|
813
|
+
return [...drag.touched.keys()].flatMap((id) => {
|
|
814
|
+
const old = before.get(id);
|
|
815
|
+
return old ? [{ id, start: old.start, end: old.end }] : [];
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
function shownDuringDrag(drag) {
|
|
819
|
+
return (0, import_core2.applyAnnotationBounds)(drag.store.getAnnotations(), touchedChanges(drag));
|
|
820
|
+
}
|
|
790
821
|
function useAnnotationDragHandlers({
|
|
791
|
-
|
|
792
|
-
onAnnotationsChange,
|
|
822
|
+
store,
|
|
793
823
|
samplesPerPixel,
|
|
794
824
|
// Default mirrors the engine default; the providers always pass the real rate from context (#510).
|
|
795
825
|
sampleRate = 48e3,
|
|
@@ -798,81 +828,132 @@ function useAnnotationDragHandlers({
|
|
|
798
828
|
preview
|
|
799
829
|
}) {
|
|
800
830
|
const dragRef = import_react9.default.useRef(null);
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
const
|
|
804
|
-
|
|
831
|
+
const storeRef = import_react9.default.useRef(store);
|
|
832
|
+
storeRef.current = store;
|
|
833
|
+
const previewRef = import_react9.default.useRef(preview);
|
|
834
|
+
previewRef.current = preview;
|
|
835
|
+
const abandon = import_react9.default.useCallback(() => {
|
|
836
|
+
var _a;
|
|
837
|
+
if (!dragRef.current) return;
|
|
838
|
+
dragRef.current = null;
|
|
839
|
+
(_a = previewRef.current) == null ? void 0 : _a.publish(null);
|
|
840
|
+
}, []);
|
|
805
841
|
import_react9.default.useEffect(() => {
|
|
806
|
-
if (!
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
842
|
+
if (!store) return;
|
|
843
|
+
const unsubscribe = store.subscribe(() => {
|
|
844
|
+
const drag = dragRef.current;
|
|
845
|
+
if (!drag || drag.store !== store) return;
|
|
846
|
+
if (!store.getAnnotations().some((a) => a.id === drag.draggedId)) {
|
|
847
|
+
abandon();
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
const shown = previewRef.current;
|
|
851
|
+
if (shown && shown.source.getSnapshot() !== null) {
|
|
852
|
+
shown.publish(shownDuringDrag(drag));
|
|
811
853
|
}
|
|
854
|
+
});
|
|
855
|
+
return () => {
|
|
856
|
+
unsubscribe();
|
|
857
|
+
abandon();
|
|
812
858
|
};
|
|
813
|
-
}, [
|
|
859
|
+
}, [store, abandon]);
|
|
860
|
+
import_react9.default.useEffect(() => abandon, [preview, abandon]);
|
|
814
861
|
const onDragStart = import_react9.default.useCallback((event) => {
|
|
815
862
|
var _a;
|
|
816
863
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
864
|
+
const owner = storeRef.current;
|
|
865
|
+
if (!owner || !data) {
|
|
866
|
+
dragRef.current = null;
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
const snapshot = owner.getAnnotations();
|
|
870
|
+
const annotation = data.annotationIndex === void 0 ? void 0 : snapshot[data.annotationIndex];
|
|
871
|
+
dragRef.current = annotation ? {
|
|
872
|
+
store: owner,
|
|
820
873
|
snapshot,
|
|
874
|
+
touched: /* @__PURE__ */ new Map(),
|
|
875
|
+
draggedId: annotation.id,
|
|
876
|
+
edge: data.edge,
|
|
821
877
|
start: annotation.start,
|
|
822
|
-
end: annotation.end
|
|
823
|
-
annotationIndex: data.annotationIndex
|
|
878
|
+
end: annotation.end
|
|
824
879
|
} : null;
|
|
825
880
|
}, []);
|
|
826
881
|
const onDragMove = import_react9.default.useCallback(
|
|
827
882
|
(event) => {
|
|
828
|
-
var _a, _b
|
|
883
|
+
var _a, _b;
|
|
829
884
|
const drag = dragRef.current;
|
|
830
|
-
if (!drag)
|
|
885
|
+
if (!drag) return;
|
|
886
|
+
if (drag.store !== storeRef.current) {
|
|
887
|
+
abandon();
|
|
831
888
|
return;
|
|
832
889
|
}
|
|
833
|
-
const
|
|
834
|
-
if (!data) return;
|
|
835
|
-
const { edge, annotationIndex } = data;
|
|
836
|
-
const currentX = (_c = (_b = event.to) == null ? void 0 : _b.x) != null ? _c : event.operation.position.current.x;
|
|
890
|
+
const currentX = (_b = (_a = event.to) == null ? void 0 : _a.x) != null ? _b : event.operation.position.current.x;
|
|
837
891
|
const rawDeltaX = currentX - event.operation.position.initial.x;
|
|
838
892
|
const timeDelta = rawDeltaX * samplesPerPixel / sampleRate;
|
|
839
|
-
const newTime = edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
840
|
-
const
|
|
893
|
+
const newTime = drag.edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
894
|
+
const base = shownDuringDrag(drag);
|
|
895
|
+
const annotationIndex = base.findIndex((a) => a.id === drag.draggedId);
|
|
896
|
+
if (annotationIndex < 0) {
|
|
897
|
+
abandon();
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
const updated = (0, import_core2.updateAnnotationBoundaries)({
|
|
841
901
|
annotationIndex,
|
|
842
902
|
newTime,
|
|
843
|
-
isDraggingStart: edge === "start",
|
|
844
|
-
annotations:
|
|
903
|
+
isDraggingStart: drag.edge === "start",
|
|
904
|
+
annotations: base,
|
|
845
905
|
duration,
|
|
846
906
|
linkEndpoints
|
|
847
907
|
});
|
|
908
|
+
updated.forEach((annotation, i) => {
|
|
909
|
+
const was = base[i];
|
|
910
|
+
if (drag.touched.has(annotation.id) || was.start !== annotation.start || was.end !== annotation.end) {
|
|
911
|
+
drag.touched.set(annotation.id, {
|
|
912
|
+
id: annotation.id,
|
|
913
|
+
start: annotation.start,
|
|
914
|
+
end: annotation.end
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
});
|
|
848
918
|
if (preview) {
|
|
849
|
-
preview.publish(
|
|
919
|
+
preview.publish(updated);
|
|
850
920
|
} else {
|
|
851
|
-
|
|
921
|
+
const changes = touchedChanges(drag);
|
|
922
|
+
drag.store.update((current) => (0, import_core2.applyAnnotationBounds)(current, changes));
|
|
852
923
|
}
|
|
853
924
|
},
|
|
854
|
-
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview]
|
|
925
|
+
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview, abandon]
|
|
855
926
|
);
|
|
856
927
|
const onDragEnd = import_react9.default.useCallback(
|
|
857
928
|
(event) => {
|
|
858
929
|
const drag = dragRef.current;
|
|
859
930
|
dragRef.current = null;
|
|
860
931
|
if (!drag) return;
|
|
932
|
+
if (drag.store !== storeRef.current) {
|
|
933
|
+
preview == null ? void 0 : preview.publish(null);
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
861
936
|
if (!preview) {
|
|
862
|
-
if (event.canceled
|
|
863
|
-
|
|
937
|
+
if (event.canceled) {
|
|
938
|
+
const restore = snapshotBounds(drag);
|
|
939
|
+
drag.store.update((current) => (0, import_core2.applyAnnotationBounds)(current, restore));
|
|
864
940
|
}
|
|
865
941
|
return;
|
|
866
942
|
}
|
|
867
|
-
|
|
868
|
-
if (result === null) return;
|
|
943
|
+
if (preview.source.getSnapshot() === null) return;
|
|
869
944
|
if (event.canceled) {
|
|
870
945
|
preview.publish(null);
|
|
871
946
|
return;
|
|
872
947
|
}
|
|
873
948
|
(0, import_react_dom.flushSync)(() => {
|
|
874
|
-
|
|
875
|
-
|
|
949
|
+
try {
|
|
950
|
+
const changes = touchedChanges(drag);
|
|
951
|
+
drag.store.update(
|
|
952
|
+
(current) => current.some((a) => a.id === drag.draggedId) ? (0, import_core2.applyAnnotationBounds)(current, changes) : current
|
|
953
|
+
);
|
|
954
|
+
} finally {
|
|
955
|
+
preview.publish(null);
|
|
956
|
+
}
|
|
876
957
|
});
|
|
877
958
|
},
|
|
878
959
|
[preview]
|
|
@@ -990,18 +1071,17 @@ var import_react13 = require("react");
|
|
|
990
1071
|
var import_core3 = require("@waveform-playlist/core");
|
|
991
1072
|
var useKeyboardShortcuts = (options) => {
|
|
992
1073
|
const { shortcuts, enabled = true } = options;
|
|
993
|
-
const
|
|
994
|
-
(0, import_react13.
|
|
995
|
-
|
|
1074
|
+
const latest = (0, import_react13.useRef)({ shortcuts, enabled });
|
|
1075
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
1076
|
+
latest.current = { shortcuts, enabled };
|
|
996
1077
|
});
|
|
997
|
-
(0, import_react13.
|
|
998
|
-
|
|
999
|
-
const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, shortcutsRef.current, true);
|
|
1078
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
1079
|
+
const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, latest.current.shortcuts, latest.current.enabled);
|
|
1000
1080
|
window.addEventListener("keydown", handleKeyDown);
|
|
1001
1081
|
return () => {
|
|
1002
1082
|
window.removeEventListener("keydown", handleKeyDown);
|
|
1003
1083
|
};
|
|
1004
|
-
}, [
|
|
1084
|
+
}, []);
|
|
1005
1085
|
};
|
|
1006
1086
|
|
|
1007
1087
|
// src/hooks/usePlaybackShortcuts.ts
|
|
@@ -1016,7 +1096,7 @@ function usePlayFromSelectionOrCursor() {
|
|
|
1016
1096
|
const isLoopEnabled = (_b = (_a = useLoopOptional()) == null ? void 0 : _a.isLoopEnabled) != null ? _b : false;
|
|
1017
1097
|
const { play } = usePlaybackControls();
|
|
1018
1098
|
const latest = (0, import_react14.useRef)({ selectionStart, selectionEnd, isLoopEnabled });
|
|
1019
|
-
(0, import_react14.
|
|
1099
|
+
(0, import_react14.useLayoutEffect)(() => {
|
|
1020
1100
|
latest.current = { selectionStart, selectionEnd, isLoopEnabled };
|
|
1021
1101
|
});
|
|
1022
1102
|
return (0, import_react14.useCallback)(() => __async(null, null, function* () {
|
|
@@ -1089,12 +1169,94 @@ var usePlaybackShortcuts = (options = {}) => {
|
|
|
1089
1169
|
|
|
1090
1170
|
// src/hooks/useAnnotationKeyboardControls.ts
|
|
1091
1171
|
var import_react16 = require("react");
|
|
1172
|
+
|
|
1173
|
+
// src/utils/annotationBoundaryKeys.ts
|
|
1092
1174
|
var LINK_THRESHOLD = 0.01;
|
|
1175
|
+
var MIN_LENGTH = 0.1;
|
|
1176
|
+
function unlessUnchanged(list, updated) {
|
|
1177
|
+
const same = updated.every((a, i) => a.start === list[i].start && a.end === list[i].end);
|
|
1178
|
+
return same ? list : updated;
|
|
1179
|
+
}
|
|
1180
|
+
function moveAnnotationStart(list, index, delta, { linkEndpoints }) {
|
|
1181
|
+
const annotation = list[index];
|
|
1182
|
+
const newStart = Math.max(0, Math.min(annotation.end - MIN_LENGTH, annotation.start + delta));
|
|
1183
|
+
const actualDelta = newStart - annotation.start;
|
|
1184
|
+
const updated = [...list];
|
|
1185
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { start: newStart });
|
|
1186
|
+
if (linkEndpoints && index > 0) {
|
|
1187
|
+
const prev = updated[index - 1];
|
|
1188
|
+
if (Math.abs(prev.end - annotation.start) < LINK_THRESHOLD) {
|
|
1189
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), {
|
|
1190
|
+
end: Math.max(prev.start + MIN_LENGTH, prev.end + actualDelta)
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
} else if (!linkEndpoints && index > 0) {
|
|
1194
|
+
const prev = updated[index - 1];
|
|
1195
|
+
if (newStart < prev.end) {
|
|
1196
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), { end: newStart });
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return unlessUnchanged(list, updated);
|
|
1200
|
+
}
|
|
1201
|
+
function moveAnnotationEnd(list, index, delta, { linkEndpoints, duration }) {
|
|
1202
|
+
const annotation = list[index];
|
|
1203
|
+
const newEnd = Math.max(
|
|
1204
|
+
annotation.start + MIN_LENGTH,
|
|
1205
|
+
Math.min(duration, annotation.end + delta)
|
|
1206
|
+
);
|
|
1207
|
+
const actualDelta = newEnd - annotation.end;
|
|
1208
|
+
const updated = [...list];
|
|
1209
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { end: newEnd });
|
|
1210
|
+
if (linkEndpoints && index < list.length - 1) {
|
|
1211
|
+
const next = updated[index + 1];
|
|
1212
|
+
if (Math.abs(next.start - annotation.end) < LINK_THRESHOLD) {
|
|
1213
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1214
|
+
start: Math.min(next.end - MIN_LENGTH, next.start + actualDelta)
|
|
1215
|
+
});
|
|
1216
|
+
let current = index + 1;
|
|
1217
|
+
while (current < updated.length - 1) {
|
|
1218
|
+
const moved = updated[current];
|
|
1219
|
+
const following = updated[current + 1];
|
|
1220
|
+
if (Math.abs(following.start - list[current].end) < LINK_THRESHOLD) {
|
|
1221
|
+
const nextDelta = moved.end - list[current].end;
|
|
1222
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), {
|
|
1223
|
+
start: Math.min(following.end - MIN_LENGTH, following.start + nextDelta)
|
|
1224
|
+
});
|
|
1225
|
+
current++;
|
|
1226
|
+
} else {
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
} else if (!linkEndpoints && index < list.length - 1) {
|
|
1232
|
+
const next = updated[index + 1];
|
|
1233
|
+
if (newEnd > next.start) {
|
|
1234
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), { start: newEnd });
|
|
1235
|
+
let current = index + 1;
|
|
1236
|
+
while (current < updated.length - 1) {
|
|
1237
|
+
const pushed = updated[current];
|
|
1238
|
+
const following = updated[current + 1];
|
|
1239
|
+
if (pushed.end > following.start) {
|
|
1240
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), { start: pushed.end });
|
|
1241
|
+
current++;
|
|
1242
|
+
} else {
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return unlessUnchanged(list, updated);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// src/hooks/useAnnotationKeyboardControls.ts
|
|
1093
1252
|
var TIME_DELTA = 0.01;
|
|
1253
|
+
var NO_ANNOTATIONS = Object.freeze([]);
|
|
1254
|
+
var noSubscription = () => () => {
|
|
1255
|
+
};
|
|
1256
|
+
var noAnnotations = () => NO_ANNOTATIONS;
|
|
1094
1257
|
function useAnnotationKeyboardControls({
|
|
1095
|
-
|
|
1258
|
+
store,
|
|
1096
1259
|
activeAnnotationId,
|
|
1097
|
-
onAnnotationsChange,
|
|
1098
1260
|
onActiveAnnotationChange,
|
|
1099
1261
|
duration,
|
|
1100
1262
|
linkEndpoints,
|
|
@@ -1105,6 +1267,15 @@ function useAnnotationKeyboardControls({
|
|
|
1105
1267
|
samplesPerPixel: samplesPerPixelProp,
|
|
1106
1268
|
sampleRate: sampleRateProp
|
|
1107
1269
|
}) {
|
|
1270
|
+
const source = (0, import_react16.useMemo)(
|
|
1271
|
+
() => store ? {
|
|
1272
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1273
|
+
getSnapshot: () => store.getAnnotations()
|
|
1274
|
+
} : { subscribe: noSubscription, getSnapshot: noAnnotations },
|
|
1275
|
+
[store]
|
|
1276
|
+
);
|
|
1277
|
+
const stored = (0, import_react16.useSyncExternalStore)(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1278
|
+
const annotations = stored;
|
|
1108
1279
|
const playlistView = usePlaylistViewOptional();
|
|
1109
1280
|
const playlistZoom = usePlaylistZoomOptional();
|
|
1110
1281
|
const samplesPerPixel = samplesPerPixelProp != null ? samplesPerPixelProp : playlistZoom == null ? void 0 : playlistZoom.samplesPerPixel;
|
|
@@ -1143,92 +1314,21 @@ function useAnnotationKeyboardControls({
|
|
|
1143
1314
|
}, [activeAnnotationId, scrollToAnnotation, scrollContainerRef, samplesPerPixel, sampleRate]);
|
|
1144
1315
|
const moveStartBoundary = (0, import_react16.useCallback)(
|
|
1145
1316
|
(delta) => {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const actualDelta = newStart - annotation.start;
|
|
1150
|
-
const updatedAnnotations = [...annotations];
|
|
1151
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1152
|
-
start: newStart
|
|
1317
|
+
store == null ? void 0 : store.update((current) => {
|
|
1318
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1319
|
+
return index < 0 ? current : moveAnnotationStart(current, index, delta, { linkEndpoints });
|
|
1153
1320
|
});
|
|
1154
|
-
if (linkEndpoints && activeIndex > 0) {
|
|
1155
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1156
|
-
if (Math.abs(prevAnnotation.end - annotation.start) < LINK_THRESHOLD) {
|
|
1157
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1158
|
-
end: Math.max(prevAnnotation.start + 0.1, prevAnnotation.end + actualDelta)
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
} else if (!linkEndpoints && activeIndex > 0) {
|
|
1162
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1163
|
-
if (newStart < prevAnnotation.end) {
|
|
1164
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1165
|
-
end: newStart
|
|
1166
|
-
});
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1170
1321
|
},
|
|
1171
|
-
[
|
|
1322
|
+
[store, activeAnnotationId, linkEndpoints]
|
|
1172
1323
|
);
|
|
1173
1324
|
const moveEndBoundary = (0, import_react16.useCallback)(
|
|
1174
1325
|
(delta) => {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
const actualDelta = newEnd - annotation.end;
|
|
1179
|
-
const updatedAnnotations = [...annotations];
|
|
1180
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1181
|
-
end: newEnd
|
|
1326
|
+
store == null ? void 0 : store.update((current) => {
|
|
1327
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1328
|
+
return index < 0 ? current : moveAnnotationEnd(current, index, delta, { linkEndpoints, duration });
|
|
1182
1329
|
});
|
|
1183
|
-
if (linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1184
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1185
|
-
if (Math.abs(nextAnnotation.start - annotation.end) < LINK_THRESHOLD) {
|
|
1186
|
-
const newNextStart = Math.min(
|
|
1187
|
-
nextAnnotation.end - 0.1,
|
|
1188
|
-
nextAnnotation.start + actualDelta
|
|
1189
|
-
);
|
|
1190
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1191
|
-
start: newNextStart
|
|
1192
|
-
});
|
|
1193
|
-
let currentIndex = activeIndex + 1;
|
|
1194
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1195
|
-
const current = updatedAnnotations[currentIndex];
|
|
1196
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1197
|
-
if (Math.abs(next.start - annotations[currentIndex].end) < LINK_THRESHOLD) {
|
|
1198
|
-
const nextDelta = current.end - annotations[currentIndex].end;
|
|
1199
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1200
|
-
start: Math.min(next.end - 0.1, next.start + nextDelta)
|
|
1201
|
-
});
|
|
1202
|
-
currentIndex++;
|
|
1203
|
-
} else {
|
|
1204
|
-
break;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
} else if (!linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1209
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1210
|
-
if (newEnd > nextAnnotation.start) {
|
|
1211
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1212
|
-
start: newEnd
|
|
1213
|
-
});
|
|
1214
|
-
let currentIndex = activeIndex + 1;
|
|
1215
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1216
|
-
const current = updatedAnnotations[currentIndex];
|
|
1217
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1218
|
-
if (current.end > next.start) {
|
|
1219
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1220
|
-
start: current.end
|
|
1221
|
-
});
|
|
1222
|
-
currentIndex++;
|
|
1223
|
-
} else {
|
|
1224
|
-
break;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1230
1330
|
},
|
|
1231
|
-
[
|
|
1331
|
+
[store, activeAnnotationId, duration, linkEndpoints]
|
|
1232
1332
|
);
|
|
1233
1333
|
const selectPrevious = (0, import_react16.useCallback)(() => {
|
|
1234
1334
|
if (!onActiveAnnotationChange || annotations.length === 0) return;
|
|
@@ -1772,6 +1872,36 @@ function useArrangementSources(arrangement) {
|
|
|
1772
1872
|
return (0, import_react21.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1773
1873
|
}
|
|
1774
1874
|
|
|
1875
|
+
// src/hooks/useCreateAnnotationStore.ts
|
|
1876
|
+
var import_react22 = require("react");
|
|
1877
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
1878
|
+
function useCreateAnnotationStore(init, options) {
|
|
1879
|
+
const beforeChange = options == null ? void 0 : options.beforeChange;
|
|
1880
|
+
const ruleRef = (0, import_react22.useRef)(beforeChange);
|
|
1881
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
1882
|
+
ruleRef.current = beforeChange;
|
|
1883
|
+
}, [beforeChange]);
|
|
1884
|
+
const [store] = (0, import_react22.useState)(
|
|
1885
|
+
() => (0, import_core4.createAnnotationStore)(init == null ? void 0 : init(), {
|
|
1886
|
+
beforeChange: (next, current) => ruleRef.current ? ruleRef.current(next, current) : next
|
|
1887
|
+
})
|
|
1888
|
+
);
|
|
1889
|
+
return store;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// src/hooks/useStoredAnnotations.ts
|
|
1893
|
+
var import_react23 = require("react");
|
|
1894
|
+
function useStoredAnnotations(store) {
|
|
1895
|
+
const source = (0, import_react23.useMemo)(
|
|
1896
|
+
() => ({
|
|
1897
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1898
|
+
getSnapshot: () => store.getAnnotations()
|
|
1899
|
+
}),
|
|
1900
|
+
[store]
|
|
1901
|
+
);
|
|
1902
|
+
return (0, import_react23.useSyncExternalStore)(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1775
1905
|
// src/providerInternals/followAnnotations.ts
|
|
1776
1906
|
function followAnnotations({
|
|
1777
1907
|
annotations,
|
|
@@ -1802,8 +1932,8 @@ function followAnnotations({
|
|
|
1802
1932
|
}
|
|
1803
1933
|
|
|
1804
1934
|
// src/providerInternals/useAnnotationState.ts
|
|
1805
|
-
var
|
|
1806
|
-
var
|
|
1935
|
+
var import_react24 = require("react");
|
|
1936
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
1807
1937
|
|
|
1808
1938
|
// src/utils/annotationLookup.ts
|
|
1809
1939
|
var contains = (annotation, time) => time >= annotation.start && time < annotation.end;
|
|
@@ -1858,20 +1988,11 @@ function createAnnotationLookup() {
|
|
|
1858
1988
|
};
|
|
1859
1989
|
}
|
|
1860
1990
|
|
|
1861
|
-
// src/utils/isDevelopmentBuild.ts
|
|
1862
|
-
function isDevelopmentBuild() {
|
|
1863
|
-
try {
|
|
1864
|
-
return process.env.NODE_ENV !== "production";
|
|
1865
|
-
} catch (e) {
|
|
1866
|
-
return false;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
1991
|
// src/providerInternals/useAnnotationState.ts
|
|
1871
1992
|
function useFollowedOption(prop) {
|
|
1872
1993
|
const wanted = prop != null ? prop : false;
|
|
1873
|
-
const [value, setValue] = (0,
|
|
1874
|
-
const [seen, setSeen] = (0,
|
|
1994
|
+
const [value, setValue] = (0, import_react24.useState)(wanted);
|
|
1995
|
+
const [seen, setSeen] = (0, import_react24.useState)(wanted);
|
|
1875
1996
|
if (seen !== wanted) {
|
|
1876
1997
|
setSeen(wanted);
|
|
1877
1998
|
setValue(wanted);
|
|
@@ -1879,39 +2000,45 @@ function useFollowedOption(prop) {
|
|
|
1879
2000
|
}
|
|
1880
2001
|
return [value, setValue];
|
|
1881
2002
|
}
|
|
2003
|
+
var NO_ANNOTATIONS2 = Object.freeze([]);
|
|
2004
|
+
var noSubscription2 = () => () => {
|
|
2005
|
+
};
|
|
2006
|
+
var noAnnotations2 = () => NO_ANNOTATIONS2;
|
|
1882
2007
|
function useAnnotationState({
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
providerName
|
|
2008
|
+
annotationStore,
|
|
2009
|
+
annotationList
|
|
1886
2010
|
}) {
|
|
1887
|
-
const
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
const
|
|
2011
|
+
const source = (0, import_react24.useMemo)(
|
|
2012
|
+
() => annotationStore ? {
|
|
2013
|
+
subscribe: (listener) => annotationStore.subscribe(listener),
|
|
2014
|
+
getSnapshot: () => annotationStore.getAnnotations()
|
|
2015
|
+
} : { subscribe: noSubscription2, getSnapshot: noAnnotations2 },
|
|
2016
|
+
[annotationStore]
|
|
2017
|
+
);
|
|
2018
|
+
const annotations = (0, import_react24.useSyncExternalStore)(
|
|
2019
|
+
source.subscribe,
|
|
2020
|
+
source.getSnapshot,
|
|
2021
|
+
source.getSnapshot
|
|
2022
|
+
);
|
|
2023
|
+
const storeRef = (0, import_react24.useRef)(annotationStore);
|
|
2024
|
+
storeRef.current = annotationStore;
|
|
2025
|
+
const getAnnotations = (0, import_react24.useCallback)(
|
|
2026
|
+
() => storeRef.current ? storeRef.current.getAnnotations() : NO_ANNOTATIONS2,
|
|
2027
|
+
[]
|
|
2028
|
+
);
|
|
2029
|
+
const [annotationLookup] = (0, import_react24.useState)(() => createAnnotationLookup());
|
|
2030
|
+
const [activeAnnotationId, setActiveAnnotationIdState] = (0, import_react24.useState)(null);
|
|
2031
|
+
const activeAnnotationIdRef = (0, import_react24.useRef)(null);
|
|
2032
|
+
const setActiveAnnotationId = (0, import_react24.useCallback)((value) => {
|
|
1906
2033
|
activeAnnotationIdRef.current = value;
|
|
1907
2034
|
setActiveAnnotationIdState(value);
|
|
1908
2035
|
}, []);
|
|
1909
2036
|
const [continuousPlay, setContinuousPlayState] = useFollowedOption(
|
|
1910
2037
|
annotationList == null ? void 0 : annotationList.isContinuousPlay
|
|
1911
2038
|
);
|
|
1912
|
-
const continuousPlayRef = (0,
|
|
2039
|
+
const continuousPlayRef = (0, import_react24.useRef)(continuousPlay);
|
|
1913
2040
|
continuousPlayRef.current = continuousPlay;
|
|
1914
|
-
const setContinuousPlay = (0,
|
|
2041
|
+
const setContinuousPlay = (0, import_react24.useCallback)(
|
|
1915
2042
|
(value) => {
|
|
1916
2043
|
continuousPlayRef.current = value;
|
|
1917
2044
|
setContinuousPlayState(value);
|
|
@@ -1920,36 +2047,18 @@ function useAnnotationState({
|
|
|
1920
2047
|
);
|
|
1921
2048
|
const [editable, setAnnotationsEditable] = useFollowedOption(annotationList == null ? void 0 : annotationList.editable);
|
|
1922
2049
|
const [linkEndpoints, setLinkEndpoints] = useFollowedOption(annotationList == null ? void 0 : annotationList.linkEndpoints);
|
|
1923
|
-
const annotationsValue = (0,
|
|
1924
|
-
const annotationOptionsValue = (0,
|
|
2050
|
+
const annotationsValue = (0, import_react24.useMemo)(() => ({ annotations }), [annotations]);
|
|
2051
|
+
const annotationOptionsValue = (0, import_react24.useMemo)(
|
|
1925
2052
|
() => ({ editable, linkEndpoints, continuousPlay }),
|
|
1926
2053
|
[editable, linkEndpoints, continuousPlay]
|
|
1927
2054
|
);
|
|
1928
|
-
const [annotationPreview] = (0,
|
|
1929
|
-
() => (0,
|
|
1930
|
-
);
|
|
1931
|
-
const onAnnotationsChangeRef = (0, import_react22.useRef)(onAnnotationsChange);
|
|
1932
|
-
onAnnotationsChangeRef.current = onAnnotationsChange;
|
|
1933
|
-
const setAnnotations = (0, import_react22.useCallback)(
|
|
1934
|
-
(action) => {
|
|
1935
|
-
const updated = typeof action === "function" ? action(annotationsRef.current) : action;
|
|
1936
|
-
if (!onAnnotationsChangeRef.current) {
|
|
1937
|
-
if (isDevelopmentBuild()) {
|
|
1938
|
-
console.warn(
|
|
1939
|
-
"waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to " + providerName + " to handle annotation updates."
|
|
1940
|
-
);
|
|
1941
|
-
}
|
|
1942
|
-
return;
|
|
1943
|
-
}
|
|
1944
|
-
onAnnotationsChangeRef.current(updated);
|
|
1945
|
-
},
|
|
1946
|
-
[providerName]
|
|
2055
|
+
const [annotationPreview] = (0, import_react24.useState)(
|
|
2056
|
+
() => (0, import_core5.createValueSource)(null)
|
|
1947
2057
|
);
|
|
1948
2058
|
return {
|
|
1949
2059
|
annotations,
|
|
1950
|
-
|
|
2060
|
+
getAnnotations,
|
|
1951
2061
|
annotationLookup,
|
|
1952
|
-
setAnnotations,
|
|
1953
2062
|
annotationPreview,
|
|
1954
2063
|
activeAnnotationId,
|
|
1955
2064
|
activeAnnotationIdRef,
|
|
@@ -1965,16 +2074,16 @@ function useAnnotationState({
|
|
|
1965
2074
|
}
|
|
1966
2075
|
|
|
1967
2076
|
// src/providerInternals/useFrameCallbacks.ts
|
|
1968
|
-
var
|
|
2077
|
+
var import_react25 = require("react");
|
|
1969
2078
|
function useFrameCallbacks() {
|
|
1970
|
-
const callbacksRef = (0,
|
|
1971
|
-
const registerFrameCallback = (0,
|
|
2079
|
+
const callbacksRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
2080
|
+
const registerFrameCallback = (0, import_react25.useCallback)((id, cb) => {
|
|
1972
2081
|
callbacksRef.current.set(id, cb);
|
|
1973
2082
|
}, []);
|
|
1974
|
-
const unregisterFrameCallback = (0,
|
|
2083
|
+
const unregisterFrameCallback = (0, import_react25.useCallback)((id) => {
|
|
1975
2084
|
callbacksRef.current.delete(id);
|
|
1976
2085
|
}, []);
|
|
1977
|
-
const runFrameCallbacks = (0,
|
|
2086
|
+
const runFrameCallbacks = (0, import_react25.useCallback)((data) => {
|
|
1978
2087
|
for (const cb of callbacksRef.current.values()) {
|
|
1979
2088
|
cb(data);
|
|
1980
2089
|
}
|
|
@@ -1983,19 +2092,19 @@ function useFrameCallbacks() {
|
|
|
1983
2092
|
}
|
|
1984
2093
|
|
|
1985
2094
|
// src/providerInternals/useScrollFollow.ts
|
|
1986
|
-
var
|
|
2095
|
+
var import_react26 = require("react");
|
|
1987
2096
|
function centrePlayhead(container, time, sampleRate, samplesPerPixel) {
|
|
1988
2097
|
const pixelPosition = time * sampleRate / samplesPerPixel;
|
|
1989
2098
|
container.scrollLeft = Math.round(Math.max(0, pixelPosition - container.clientWidth / 2));
|
|
1990
2099
|
}
|
|
1991
2100
|
function useScrollFollow(initialAutomaticScroll) {
|
|
1992
|
-
const scrollContainerRef = (0,
|
|
1993
|
-
const [isAutomaticScroll, setIsAutomaticScroll] = (0,
|
|
1994
|
-
const isAutomaticScrollRef = (0,
|
|
1995
|
-
const setScrollContainer = (0,
|
|
2101
|
+
const scrollContainerRef = (0, import_react26.useRef)(null);
|
|
2102
|
+
const [isAutomaticScroll, setIsAutomaticScroll] = (0, import_react26.useState)(initialAutomaticScroll);
|
|
2103
|
+
const isAutomaticScrollRef = (0, import_react26.useRef)(initialAutomaticScroll);
|
|
2104
|
+
const setScrollContainer = (0, import_react26.useCallback)((element) => {
|
|
1996
2105
|
scrollContainerRef.current = element;
|
|
1997
2106
|
}, []);
|
|
1998
|
-
const setAutomaticScroll = (0,
|
|
2107
|
+
const setAutomaticScroll = (0, import_react26.useCallback)((enabled) => {
|
|
1999
2108
|
isAutomaticScrollRef.current = enabled;
|
|
2000
2109
|
setIsAutomaticScroll(enabled);
|
|
2001
2110
|
}, []);
|
|
@@ -2009,11 +2118,11 @@ function useScrollFollow(initialAutomaticScroll) {
|
|
|
2009
2118
|
}
|
|
2010
2119
|
|
|
2011
2120
|
// src/providerInternals/useMergedTheme.ts
|
|
2012
|
-
var
|
|
2121
|
+
var import_react28 = require("react");
|
|
2013
2122
|
var import_ui_components2 = require("@waveform-playlist/ui-components");
|
|
2014
2123
|
|
|
2015
2124
|
// src/hooks/useShallowStable.ts
|
|
2016
|
-
var
|
|
2125
|
+
var import_react27 = require("react");
|
|
2017
2126
|
function shallowEqual(a, b) {
|
|
2018
2127
|
if (a === b) return true;
|
|
2019
2128
|
const aKeys = Object.keys(a);
|
|
@@ -2026,7 +2135,7 @@ function shallowEqual(a, b) {
|
|
|
2026
2135
|
);
|
|
2027
2136
|
}
|
|
2028
2137
|
function useShallowStable(value) {
|
|
2029
|
-
const ref = (0,
|
|
2138
|
+
const ref = (0, import_react27.useRef)(value);
|
|
2030
2139
|
const previous = ref.current;
|
|
2031
2140
|
if (previous !== value) {
|
|
2032
2141
|
if (previous === void 0 || value === void 0 || !shallowEqual(previous, value)) {
|
|
@@ -2039,12 +2148,12 @@ function useShallowStable(value) {
|
|
|
2039
2148
|
// src/providerInternals/useMergedTheme.ts
|
|
2040
2149
|
function useMergedTheme(themeProp) {
|
|
2041
2150
|
const userTheme = useShallowStable(themeProp);
|
|
2042
|
-
return (0,
|
|
2151
|
+
return (0, import_react28.useMemo)(() => __spreadValues(__spreadValues({}, import_ui_components2.defaultTheme), userTheme), [userTheme]);
|
|
2043
2152
|
}
|
|
2044
2153
|
|
|
2045
2154
|
// src/providerInternals/useTrimPreview.ts
|
|
2046
|
-
var
|
|
2047
|
-
var
|
|
2155
|
+
var import_react29 = require("react");
|
|
2156
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
2048
2157
|
|
|
2049
2158
|
// src/waveformDataLoader.ts
|
|
2050
2159
|
var import_waveform_data2 = __toESM(require("waveform-data"));
|
|
@@ -2342,23 +2451,35 @@ function previewedClipPeaks(preview, { tracks, peaksOptions, peaksCacheRef }) {
|
|
|
2342
2451
|
return clipPeaksFor(previewed, track.name, peaksOptions, previous).clipPeaks;
|
|
2343
2452
|
}
|
|
2344
2453
|
function useTrimPreview(inputs) {
|
|
2345
|
-
const [trimPreview] = (0,
|
|
2346
|
-
() => (0,
|
|
2454
|
+
const [trimPreview] = (0, import_react29.useState)(
|
|
2455
|
+
() => (0, import_core6.createValueSource)(null)
|
|
2347
2456
|
);
|
|
2348
|
-
const inputsRef = (0,
|
|
2457
|
+
const inputsRef = (0, import_react29.useRef)(inputs);
|
|
2349
2458
|
inputsRef.current = inputs;
|
|
2350
|
-
const [trimPreviewPeaks] = (0,
|
|
2459
|
+
const [trimPreviewPeaks] = (0, import_react29.useState)(() => ({
|
|
2351
2460
|
peaksFor: (preview) => previewedClipPeaks(preview, inputsRef.current)
|
|
2352
2461
|
}));
|
|
2353
2462
|
return { trimPreview, trimPreviewPeaks };
|
|
2354
2463
|
}
|
|
2355
2464
|
|
|
2356
2465
|
// src/providerInternals/useEngineLifetime.ts
|
|
2357
|
-
var
|
|
2466
|
+
var import_react30 = require("react");
|
|
2358
2467
|
var import_engine4 = require("@waveform-playlist/engine");
|
|
2359
2468
|
|
|
2469
|
+
// src/utils/installCommand.ts
|
|
2470
|
+
var BUILT_SPECS = typeof define_INSTALL_SPECS_default === "undefined" ? {} : define_INSTALL_SPECS_default;
|
|
2471
|
+
function formatInstallCommand(specs, names) {
|
|
2472
|
+
return "npm install " + names.map((name) => {
|
|
2473
|
+
var _a;
|
|
2474
|
+
return `"${(_a = specs[name]) != null ? _a : name}"`;
|
|
2475
|
+
}).join(" ");
|
|
2476
|
+
}
|
|
2477
|
+
function installCommand(...names) {
|
|
2478
|
+
return formatInstallCommand(BUILT_SPECS, names);
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2360
2481
|
// src/playout/resolvePlayoutAdapter.ts
|
|
2361
|
-
var
|
|
2482
|
+
var installHint = () => "@waveform-playlist/playout (and its peer `tone`) is required for the default WebAudio engine. Install with: " + installCommand("@waveform-playlist/playout", "tone") + " \u2014 or pass a custom `createAdapter`.";
|
|
2362
2483
|
function resolvePlayoutAdapter(opts) {
|
|
2363
2484
|
return __async(this, null, function* () {
|
|
2364
2485
|
if (opts.createAdapter) {
|
|
@@ -2371,7 +2492,7 @@ function resolvePlayoutAdapter(opts) {
|
|
|
2371
2492
|
console.warn(
|
|
2372
2493
|
"[waveform-playlist] @waveform-playlist/playout dynamic import failed: " + String(originalErr)
|
|
2373
2494
|
);
|
|
2374
|
-
throw new Error(
|
|
2495
|
+
throw new Error(installHint());
|
|
2375
2496
|
}
|
|
2376
2497
|
if (opts.sampleRate !== void 0) {
|
|
2377
2498
|
try {
|
|
@@ -2465,30 +2586,30 @@ function reportBuildFailure(ctx, run, engine, error) {
|
|
|
2465
2586
|
onError == null ? void 0 : onError(error instanceof Error ? error : new Error(String(error)));
|
|
2466
2587
|
}
|
|
2467
2588
|
function useKnownSampleRate(sampleRateProp) {
|
|
2468
|
-
const [sampleRate, setSampleRateState] = (0,
|
|
2589
|
+
const [sampleRate, setSampleRateState] = (0, import_react30.useState)(
|
|
2469
2590
|
() => sampleRateProp != null ? sampleRateProp : PROVISIONAL_SAMPLE_RATE
|
|
2470
2591
|
);
|
|
2471
|
-
const [isSampleRateKnown, setIsSampleRateKnown] = (0,
|
|
2472
|
-
const setSampleRate = (0,
|
|
2592
|
+
const [isSampleRateKnown, setIsSampleRateKnown] = (0, import_react30.useState)(() => sampleRateProp !== void 0);
|
|
2593
|
+
const setSampleRate = (0, import_react30.useCallback)((rate) => {
|
|
2473
2594
|
setSampleRateState(rate);
|
|
2474
2595
|
setIsSampleRateKnown(true);
|
|
2475
2596
|
}, []);
|
|
2476
2597
|
return { sampleRate, isSampleRateKnown, setSampleRate };
|
|
2477
2598
|
}
|
|
2478
2599
|
function useDecodeContext(arrangement, adapterRef) {
|
|
2479
|
-
const arrivalRef = (0,
|
|
2480
|
-
const getDecodeContext = (0,
|
|
2600
|
+
const arrivalRef = (0, import_react30.useRef)(null);
|
|
2601
|
+
const getDecodeContext = (0, import_react30.useCallback)(() => __async(null, null, function* () {
|
|
2481
2602
|
var _a;
|
|
2482
2603
|
const adapter = adapterRef.current;
|
|
2483
2604
|
if (adapter) return adapter.audioContext;
|
|
2484
2605
|
(_a = arrivalRef.current) != null ? _a : arrivalRef.current = deferred();
|
|
2485
2606
|
return arrivalRef.current.promise;
|
|
2486
2607
|
}), [adapterRef]);
|
|
2487
|
-
(0,
|
|
2608
|
+
(0, import_react30.useEffect)(
|
|
2488
2609
|
() => (0, import_engine4.attachDecodeContext)(arrangement, getDecodeContext),
|
|
2489
2610
|
[arrangement, getDecodeContext]
|
|
2490
2611
|
);
|
|
2491
|
-
return (0,
|
|
2612
|
+
return (0, import_react30.useCallback)((adapter) => {
|
|
2492
2613
|
const arrival = arrivalRef.current;
|
|
2493
2614
|
arrivalRef.current = null;
|
|
2494
2615
|
arrival == null ? void 0 : arrival.resolve(adapter.audioContext);
|
|
@@ -2496,7 +2617,7 @@ function useDecodeContext(arrangement, adapterRef) {
|
|
|
2496
2617
|
}
|
|
2497
2618
|
function useDisposeKeepingPlayback(refs) {
|
|
2498
2619
|
const { engineRef, adapterRef, pendingResumeRef, latest } = refs;
|
|
2499
|
-
return (0,
|
|
2620
|
+
return (0, import_react30.useCallback)(() => {
|
|
2500
2621
|
var _a;
|
|
2501
2622
|
const engine = engineRef.current;
|
|
2502
2623
|
if (!engine) return;
|
|
@@ -2513,23 +2634,23 @@ function useDisposeKeepingPlayback(refs) {
|
|
|
2513
2634
|
}
|
|
2514
2635
|
function useEngineLifetime(options) {
|
|
2515
2636
|
const { arrangement, effects, zoomLevels, sampleRateProp } = options;
|
|
2516
|
-
const latest = (0,
|
|
2517
|
-
(0,
|
|
2637
|
+
const latest = (0, import_react30.useRef)(options);
|
|
2638
|
+
(0, import_react30.useLayoutEffect)(() => {
|
|
2518
2639
|
latest.current = options;
|
|
2519
2640
|
});
|
|
2520
|
-
const stableZoomLevels = (0,
|
|
2641
|
+
const stableZoomLevels = (0, import_react30.useMemo)(
|
|
2521
2642
|
() => zoomLevels,
|
|
2522
2643
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2523
2644
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2524
2645
|
);
|
|
2525
|
-
const engineRef = (0,
|
|
2526
|
-
const adapterRef = (0,
|
|
2527
|
-
const engineBuildInFlightRef = (0,
|
|
2528
|
-
const pendingResumeRef = (0,
|
|
2529
|
-
const audioInitializedRef = (0,
|
|
2530
|
-
const [engineEpoch, setEngineEpoch] = (0,
|
|
2531
|
-
const [isEngineAttached, setIsEngineAttached] = (0,
|
|
2532
|
-
const bumpEngineEpoch = (0,
|
|
2646
|
+
const engineRef = (0, import_react30.useRef)(null);
|
|
2647
|
+
const adapterRef = (0, import_react30.useRef)(null);
|
|
2648
|
+
const engineBuildInFlightRef = (0, import_react30.useRef)(false);
|
|
2649
|
+
const pendingResumeRef = (0, import_react30.useRef)(null);
|
|
2650
|
+
const audioInitializedRef = (0, import_react30.useRef)(false);
|
|
2651
|
+
const [engineEpoch, setEngineEpoch] = (0, import_react30.useState)(0);
|
|
2652
|
+
const [isEngineAttached, setIsEngineAttached] = (0, import_react30.useState)(false);
|
|
2653
|
+
const bumpEngineEpoch = (0, import_react30.useCallback)(() => setEngineEpoch((epoch) => epoch + 1), []);
|
|
2533
2654
|
const { sampleRate, isSampleRateKnown, setSampleRate } = useKnownSampleRate(sampleRateProp);
|
|
2534
2655
|
const onAssigned = useDecodeContext(arrangement, adapterRef);
|
|
2535
2656
|
const disposeEngineKeepingPlayback = useDisposeKeepingPlayback({
|
|
@@ -2538,7 +2659,7 @@ function useEngineLifetime(options) {
|
|
|
2538
2659
|
pendingResumeRef,
|
|
2539
2660
|
latest
|
|
2540
2661
|
});
|
|
2541
|
-
(0,
|
|
2662
|
+
(0, import_react30.useEffect)(() => {
|
|
2542
2663
|
const run = { cancelled: false };
|
|
2543
2664
|
engineBuildInFlightRef.current = true;
|
|
2544
2665
|
setIsEngineAttached(false);
|
|
@@ -2597,8 +2718,8 @@ function useEngineLifetime(options) {
|
|
|
2597
2718
|
}
|
|
2598
2719
|
|
|
2599
2720
|
// src/providerInternals/useArrangementView.ts
|
|
2600
|
-
var
|
|
2601
|
-
var
|
|
2721
|
+
var import_react31 = require("react");
|
|
2722
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
2602
2723
|
|
|
2603
2724
|
// src/utils/placeholderPeaks.ts
|
|
2604
2725
|
var memo = /* @__PURE__ */ new WeakMap();
|
|
@@ -2689,11 +2810,11 @@ var EMPTY_STATES = { byTrackId: /* @__PURE__ */ new Map(), result: [] };
|
|
|
2689
2810
|
var DEFAULT_MIX = { volume: 1, muted: false, soloed: false, pan: 0 };
|
|
2690
2811
|
function rowFor(track, index, inputs) {
|
|
2691
2812
|
const loadedRow = inputs.loadedPeaks.result[index];
|
|
2692
|
-
if (!track.clips.some(
|
|
2813
|
+
if (!track.clips.some(import_core7.isLoadingClip)) return loadedRow;
|
|
2693
2814
|
const rate = inputs.placeholderSampleRate;
|
|
2694
2815
|
const row = [];
|
|
2695
2816
|
for (const clip of track.clips) {
|
|
2696
|
-
if (!(0,
|
|
2817
|
+
if (!(0, import_core7.isLoadingClip)(clip)) {
|
|
2697
2818
|
const entry = inputs.loadedPeaks.clips.get(clip.id);
|
|
2698
2819
|
if (entry) row.push(entry.clipPeaks);
|
|
2699
2820
|
continue;
|
|
@@ -2719,19 +2840,20 @@ function deriveRows(tracks, inputs, previous) {
|
|
|
2719
2840
|
});
|
|
2720
2841
|
return { byTrackId, result: sameItems(previous.result, rows) ? previous.result : rows };
|
|
2721
2842
|
}
|
|
2722
|
-
function sameState(a, name, mix) {
|
|
2723
|
-
return a.name === name && a.volume === mix.volume && a.muted ===
|
|
2843
|
+
function sameState(a, name, mix, muted) {
|
|
2844
|
+
return a.name === name && a.volume === mix.volume && a.muted === muted && a.soloed === mix.soloed && a.pan === mix.pan;
|
|
2724
2845
|
}
|
|
2725
|
-
function deriveTrackStates(tracks, mixer, previous) {
|
|
2846
|
+
function deriveTrackStates(tracks, mixer, recordingTrackIds, previous) {
|
|
2726
2847
|
const byTrackId = /* @__PURE__ */ new Map();
|
|
2727
2848
|
const states = tracks.map((track) => {
|
|
2728
2849
|
var _a;
|
|
2729
2850
|
const mix = (_a = mixer.get(track.id)) != null ? _a : DEFAULT_MIX;
|
|
2851
|
+
const muted = mix.muted || recordingTrackIds.has(track.id);
|
|
2730
2852
|
const before = previous.byTrackId.get(track.id);
|
|
2731
|
-
const state = before && sameState(before, track.name, mix) ? before : {
|
|
2853
|
+
const state = before && sameState(before, track.name, mix, muted) ? before : {
|
|
2732
2854
|
name: track.name,
|
|
2733
2855
|
volume: mix.volume,
|
|
2734
|
-
muted
|
|
2856
|
+
muted,
|
|
2735
2857
|
soloed: mix.soloed,
|
|
2736
2858
|
pan: mix.pan
|
|
2737
2859
|
};
|
|
@@ -2741,55 +2863,62 @@ function deriveTrackStates(tracks, mixer, previous) {
|
|
|
2741
2863
|
return { byTrackId, result: sameItems(previous.result, states) ? previous.result : states };
|
|
2742
2864
|
}
|
|
2743
2865
|
function useArrangementValue(arrangement, read) {
|
|
2744
|
-
const store = (0,
|
|
2866
|
+
const store = (0, import_react31.useMemo)(
|
|
2745
2867
|
() => ({
|
|
2746
2868
|
subscribe: (listener) => arrangement.subscribe(listener),
|
|
2747
2869
|
getSnapshot: () => read(arrangement)
|
|
2748
2870
|
}),
|
|
2749
2871
|
[arrangement, read]
|
|
2750
2872
|
);
|
|
2751
|
-
return (0,
|
|
2873
|
+
return (0, import_react31.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2752
2874
|
}
|
|
2753
2875
|
var readMixer = (arrangement) => arrangement.getMixer();
|
|
2876
|
+
var readRecordingTrackIds = (arrangement) => arrangement.recordingTrackIds;
|
|
2754
2877
|
var readCanUndo = (arrangement) => arrangement.canUndo;
|
|
2755
2878
|
var readCanRedo = (arrangement) => arrangement.canRedo;
|
|
2756
2879
|
function useArrangementView(arrangement, options) {
|
|
2757
2880
|
const { samplesPerPixel, mono, baseScale, placeholderSampleRate } = options;
|
|
2758
2881
|
const arrangementTracks = useArrangementTracks(arrangement);
|
|
2759
2882
|
const mixer = useArrangementValue(arrangement, readMixer);
|
|
2883
|
+
const recordingTrackIds = useArrangementValue(arrangement, readRecordingTrackIds);
|
|
2760
2884
|
const canUndo = useArrangementValue(arrangement, readCanUndo);
|
|
2761
2885
|
const canRedo = useArrangementValue(arrangement, readCanRedo);
|
|
2762
|
-
const loadedCacheRef = (0,
|
|
2763
|
-
const tracks = (0,
|
|
2886
|
+
const loadedCacheRef = (0, import_react31.useRef)(EMPTY_LOADED_TRACKS);
|
|
2887
|
+
const tracks = (0, import_react31.useMemo)(() => {
|
|
2764
2888
|
const next = loadedTracks(arrangementTracks, loadedCacheRef.current);
|
|
2765
2889
|
loadedCacheRef.current = next.cache;
|
|
2766
2890
|
return next.tracks;
|
|
2767
2891
|
}, [arrangementTracks]);
|
|
2768
2892
|
const { getWaveformData, version } = useWaveformDataCache(tracks, baseScale);
|
|
2769
|
-
const peaksOptions = (0,
|
|
2893
|
+
const peaksOptions = (0, import_react31.useMemo)(
|
|
2770
2894
|
() => ({ samplesPerPixel, mono, getGeneratedWaveformData: getWaveformData }),
|
|
2771
2895
|
[samplesPerPixel, mono, getWaveformData]
|
|
2772
2896
|
);
|
|
2773
|
-
const peaksCacheRef = (0,
|
|
2774
|
-
const loadedPeaks = (0,
|
|
2897
|
+
const peaksCacheRef = (0, import_react31.useRef)(EMPTY_PEAKS_CACHE);
|
|
2898
|
+
const loadedPeaks = (0, import_react31.useMemo)(() => {
|
|
2775
2899
|
const next = derivePeaks(tracks, peaksOptions, peaksCacheRef.current);
|
|
2776
2900
|
peaksCacheRef.current = next;
|
|
2777
2901
|
return next;
|
|
2778
2902
|
}, [tracks, peaksOptions, version]);
|
|
2779
|
-
const rowsCacheRef = (0,
|
|
2780
|
-
const peaksDataArray = (0,
|
|
2903
|
+
const rowsCacheRef = (0, import_react31.useRef)(EMPTY_ROWS);
|
|
2904
|
+
const peaksDataArray = (0, import_react31.useMemo)(() => {
|
|
2781
2905
|
const inputs = { loadedPeaks, samplesPerPixel, mono, placeholderSampleRate };
|
|
2782
2906
|
const next = deriveRows(arrangementTracks, inputs, rowsCacheRef.current);
|
|
2783
2907
|
rowsCacheRef.current = next;
|
|
2784
2908
|
return next.result;
|
|
2785
2909
|
}, [arrangementTracks, loadedPeaks, samplesPerPixel, mono, placeholderSampleRate]);
|
|
2786
|
-
const duration = (0,
|
|
2787
|
-
const statesCacheRef = (0,
|
|
2788
|
-
const trackStates = (0,
|
|
2789
|
-
const next = deriveTrackStates(
|
|
2910
|
+
const duration = (0, import_react31.useMemo)(() => timelineDuration(tracks), [tracks]);
|
|
2911
|
+
const statesCacheRef = (0, import_react31.useRef)(EMPTY_STATES);
|
|
2912
|
+
const trackStates = (0, import_react31.useMemo)(() => {
|
|
2913
|
+
const next = deriveTrackStates(
|
|
2914
|
+
arrangementTracks,
|
|
2915
|
+
mixer,
|
|
2916
|
+
recordingTrackIds,
|
|
2917
|
+
statesCacheRef.current
|
|
2918
|
+
);
|
|
2790
2919
|
statesCacheRef.current = next;
|
|
2791
2920
|
return next.result;
|
|
2792
|
-
}, [arrangementTracks, mixer]);
|
|
2921
|
+
}, [arrangementTracks, mixer, recordingTrackIds]);
|
|
2793
2922
|
return {
|
|
2794
2923
|
tracks,
|
|
2795
2924
|
peaksDataArray,
|
|
@@ -2803,7 +2932,18 @@ function useArrangementView(arrangement, options) {
|
|
|
2803
2932
|
}
|
|
2804
2933
|
|
|
2805
2934
|
// src/providerInternals/useReadyOnce.ts
|
|
2806
|
-
var
|
|
2935
|
+
var import_react32 = require("react");
|
|
2936
|
+
|
|
2937
|
+
// src/utils/isDevelopmentBuild.ts
|
|
2938
|
+
function isDevelopmentBuild() {
|
|
2939
|
+
try {
|
|
2940
|
+
return process.env.NODE_ENV !== "production";
|
|
2941
|
+
} catch (e) {
|
|
2942
|
+
return false;
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
// src/providerInternals/useReadyOnce.ts
|
|
2807
2947
|
var READY_EVENT = "waveform-playlist:ready";
|
|
2808
2948
|
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().";
|
|
2809
2949
|
function callOnReady({
|
|
@@ -2822,15 +2962,15 @@ function callOnReady({
|
|
|
2822
2962
|
function useReadyOnce(options) {
|
|
2823
2963
|
const { isEngineAttached, arrangement, onReadyRef, onErrorRef, trackCount, duration } = options;
|
|
2824
2964
|
const { pendingCount } = useArrangementSources(arrangement);
|
|
2825
|
-
const [hasBeenReady, setHasBeenReady] = (0,
|
|
2826
|
-
const firedRef = (0,
|
|
2965
|
+
const [hasBeenReady, setHasBeenReady] = (0, import_react32.useState)(false);
|
|
2966
|
+
const firedRef = (0, import_react32.useRef)(false);
|
|
2827
2967
|
const isReady = isEngineAttached && (hasBeenReady || pendingCount === 0);
|
|
2828
|
-
const firstReadyRef = (0,
|
|
2829
|
-
const warnedPlayRef = (0,
|
|
2830
|
-
(0,
|
|
2968
|
+
const firstReadyRef = (0, import_react32.useRef)(false);
|
|
2969
|
+
const warnedPlayRef = (0, import_react32.useRef)(false);
|
|
2970
|
+
(0, import_react32.useInsertionEffect)(() => {
|
|
2831
2971
|
if (isReady) firstReadyRef.current = true;
|
|
2832
2972
|
}, [isReady]);
|
|
2833
|
-
const refusePlayBeforeFirstReady = (0,
|
|
2973
|
+
const refusePlayBeforeFirstReady = (0, import_react32.useCallback)(() => {
|
|
2834
2974
|
if (firstReadyRef.current) return false;
|
|
2835
2975
|
if (!warnedPlayRef.current && isDevelopmentBuild()) {
|
|
2836
2976
|
warnedPlayRef.current = true;
|
|
@@ -2838,7 +2978,7 @@ function useReadyOnce(options) {
|
|
|
2838
2978
|
}
|
|
2839
2979
|
return true;
|
|
2840
2980
|
}, []);
|
|
2841
|
-
(0,
|
|
2981
|
+
(0, import_react32.useEffect)(() => {
|
|
2842
2982
|
if (!isReady || firedRef.current) return;
|
|
2843
2983
|
firedRef.current = true;
|
|
2844
2984
|
setHasBeenReady(true);
|
|
@@ -2850,8 +2990,7 @@ function useReadyOnce(options) {
|
|
|
2850
2990
|
}
|
|
2851
2991
|
|
|
2852
2992
|
// src/providerInternals/useArrangementEditing.ts
|
|
2853
|
-
var
|
|
2854
|
-
var import_core7 = require("@waveform-playlist/core");
|
|
2993
|
+
var import_react33 = require("react");
|
|
2855
2994
|
|
|
2856
2995
|
// src/components/partWarnings.ts
|
|
2857
2996
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -2871,73 +3010,85 @@ function isTrackId(setter, trackId) {
|
|
|
2871
3010
|
);
|
|
2872
3011
|
return false;
|
|
2873
3012
|
}
|
|
3013
|
+
var readRecordingTrackId = (arrangement) => {
|
|
3014
|
+
for (const id of arrangement.recordingTrackIds) return id;
|
|
3015
|
+
return null;
|
|
3016
|
+
};
|
|
3017
|
+
function clearRecordingTracks(arrangement, keep = null) {
|
|
3018
|
+
for (const id of [...arrangement.recordingTrackIds]) {
|
|
3019
|
+
if (id !== keep) arrangement.setTrackRecording(id, false);
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
2874
3022
|
function useRecordingActive(arrangement) {
|
|
2875
|
-
const recordingActiveRef = (0,
|
|
2876
|
-
const
|
|
2877
|
-
|
|
2878
|
-
(active, armedTrackId2) => {
|
|
2879
|
-
var _a, _b;
|
|
3023
|
+
const recordingActiveRef = (0, import_react33.useRef)(false);
|
|
3024
|
+
const setRecordingActive = (0, import_react33.useCallback)(
|
|
3025
|
+
(active, recordingTrackId2) => {
|
|
2880
3026
|
recordingActiveRef.current = active;
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
armed.publish({ trackId: armedTrackId2, prevMuted });
|
|
2887
|
-
arrangement.setTrackMute(armedTrackId2, true);
|
|
2888
|
-
} else if (!active && current) {
|
|
2889
|
-
arrangement.setTrackMute(current.trackId, current.prevMuted);
|
|
2890
|
-
armed.publish(null);
|
|
3027
|
+
if (active && recordingTrackId2) {
|
|
3028
|
+
clearRecordingTracks(arrangement, recordingTrackId2);
|
|
3029
|
+
arrangement.setTrackRecording(recordingTrackId2, true);
|
|
3030
|
+
} else if (!active) {
|
|
3031
|
+
clearRecordingTracks(arrangement);
|
|
2891
3032
|
}
|
|
2892
3033
|
},
|
|
2893
|
-
[arrangement
|
|
3034
|
+
[arrangement]
|
|
2894
3035
|
);
|
|
2895
|
-
(0,
|
|
3036
|
+
(0, import_react33.useEffect)(
|
|
2896
3037
|
() => () => {
|
|
2897
|
-
if (
|
|
3038
|
+
if (arrangement.recordingTrackIds.size > 0) setRecordingActive(false);
|
|
2898
3039
|
},
|
|
2899
|
-
[
|
|
3040
|
+
[arrangement, setRecordingActive]
|
|
2900
3041
|
);
|
|
2901
|
-
const
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
const
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
3042
|
+
const subscribe = (0, import_react33.useCallback)(
|
|
3043
|
+
(listener) => arrangement.subscribe(listener),
|
|
3044
|
+
[arrangement]
|
|
3045
|
+
);
|
|
3046
|
+
const getRecordingTrackId = (0, import_react33.useCallback)(() => readRecordingTrackId(arrangement), [arrangement]);
|
|
3047
|
+
const recordingTrackId = (0, import_react33.useSyncExternalStore)(
|
|
3048
|
+
subscribe,
|
|
3049
|
+
getRecordingTrackId,
|
|
3050
|
+
getRecordingTrackId
|
|
3051
|
+
);
|
|
3052
|
+
const recordingTrack = (0, import_react33.useMemo)(() => ({ recordingTrackId }), [recordingTrackId]);
|
|
3053
|
+
return { setRecordingActive, recordingActiveRef, recordingTrack };
|
|
3054
|
+
}
|
|
3055
|
+
function useArrangementEditing(arrangement, dragGuard) {
|
|
3056
|
+
const setTrackMute = (0, import_react33.useCallback)(
|
|
3057
|
+
(trackId, muted, options) => {
|
|
3058
|
+
if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted, options);
|
|
2913
3059
|
},
|
|
2914
3060
|
[arrangement]
|
|
2915
3061
|
);
|
|
2916
|
-
const setTrackSolo = (0,
|
|
2917
|
-
(trackId, soloed) => {
|
|
2918
|
-
if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed);
|
|
3062
|
+
const setTrackSolo = (0, import_react33.useCallback)(
|
|
3063
|
+
(trackId, soloed, options) => {
|
|
3064
|
+
if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed, options);
|
|
2919
3065
|
},
|
|
2920
3066
|
[arrangement]
|
|
2921
3067
|
);
|
|
2922
|
-
const setTrackVolume = (0,
|
|
2923
|
-
(trackId, volume) => {
|
|
2924
|
-
if (isTrackId("setTrackVolume", trackId))
|
|
3068
|
+
const setTrackVolume = (0, import_react33.useCallback)(
|
|
3069
|
+
(trackId, volume, options) => {
|
|
3070
|
+
if (isTrackId("setTrackVolume", trackId))
|
|
3071
|
+
arrangement.setTrackVolume(trackId, volume, options);
|
|
2925
3072
|
},
|
|
2926
3073
|
[arrangement]
|
|
2927
3074
|
);
|
|
2928
|
-
const setTrackPan = (0,
|
|
2929
|
-
(trackId, pan) => {
|
|
2930
|
-
if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan);
|
|
3075
|
+
const setTrackPan = (0, import_react33.useCallback)(
|
|
3076
|
+
(trackId, pan, options) => {
|
|
3077
|
+
if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan, options);
|
|
2931
3078
|
},
|
|
2932
3079
|
[arrangement]
|
|
2933
3080
|
);
|
|
2934
|
-
const reorderTrack = (0,
|
|
3081
|
+
const reorderTrack = (0, import_react33.useCallback)(
|
|
2935
3082
|
(trackId, toIndex) => arrangement.reorderTrack(trackId, toIndex),
|
|
2936
3083
|
[arrangement]
|
|
2937
3084
|
);
|
|
2938
|
-
const undo = (0,
|
|
2939
|
-
|
|
2940
|
-
|
|
3085
|
+
const undo = (0, import_react33.useCallback)(() => {
|
|
3086
|
+
if (!dragGuard.active) arrangement.undo();
|
|
3087
|
+
}, [arrangement, dragGuard]);
|
|
3088
|
+
const redo = (0, import_react33.useCallback)(() => {
|
|
3089
|
+
if (!dragGuard.active) arrangement.redo();
|
|
3090
|
+
}, [arrangement, dragGuard]);
|
|
3091
|
+
const { setRecordingActive, recordingActiveRef, recordingTrack } = useRecordingActive(arrangement);
|
|
2941
3092
|
return {
|
|
2942
3093
|
setTrackMute,
|
|
2943
3094
|
setTrackSolo,
|
|
@@ -2948,12 +3099,31 @@ function useArrangementEditing(arrangement) {
|
|
|
2948
3099
|
redo,
|
|
2949
3100
|
setRecordingActive,
|
|
2950
3101
|
recordingActiveRef,
|
|
2951
|
-
|
|
3102
|
+
recordingTrack
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
// src/providerInternals/dragGuard.ts
|
|
3107
|
+
function createDragGuard() {
|
|
3108
|
+
let count = 0;
|
|
3109
|
+
return {
|
|
3110
|
+
begin() {
|
|
3111
|
+
count++;
|
|
3112
|
+
let ended = false;
|
|
3113
|
+
return () => {
|
|
3114
|
+
if (ended) return;
|
|
3115
|
+
ended = true;
|
|
3116
|
+
count--;
|
|
3117
|
+
};
|
|
3118
|
+
},
|
|
3119
|
+
get active() {
|
|
3120
|
+
return count > 0;
|
|
3121
|
+
}
|
|
2952
3122
|
};
|
|
2953
3123
|
}
|
|
2954
3124
|
|
|
2955
3125
|
// src/providerInternals/arrangementIdentity.ts
|
|
2956
|
-
var
|
|
3126
|
+
var import_react34 = require("react");
|
|
2957
3127
|
var arrangementKeys = /* @__PURE__ */ new WeakMap();
|
|
2958
3128
|
var lastArrangementKey = 0;
|
|
2959
3129
|
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";
|
|
@@ -2972,9 +3142,9 @@ function keyOf(arrangement) {
|
|
|
2972
3142
|
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.";
|
|
2973
3143
|
function useArrangementKey(arrangement) {
|
|
2974
3144
|
const key = keyOf(arrangement);
|
|
2975
|
-
const firstKeyRef = (0,
|
|
2976
|
-
const warnedRef = (0,
|
|
2977
|
-
(0,
|
|
3145
|
+
const firstKeyRef = (0, import_react34.useRef)(key);
|
|
3146
|
+
const warnedRef = (0, import_react34.useRef)(false);
|
|
3147
|
+
(0, import_react34.useEffect)(() => {
|
|
2978
3148
|
if (key === firstKeyRef.current || warnedRef.current) return;
|
|
2979
3149
|
warnedRef.current = true;
|
|
2980
3150
|
if (isDevelopmentBuild()) console.warn(NEW_ARRANGEMENT_WARNING);
|
|
@@ -2998,12 +3168,12 @@ var ProviderOnArrangement = ({
|
|
|
2998
3168
|
zoomLevels,
|
|
2999
3169
|
automaticScroll = false,
|
|
3000
3170
|
theme: userThemeProp,
|
|
3171
|
+
annotationStore,
|
|
3001
3172
|
annotationList,
|
|
3002
3173
|
effects,
|
|
3003
3174
|
trackEffects,
|
|
3004
3175
|
onReady,
|
|
3005
3176
|
onError,
|
|
3006
|
-
onAnnotationsChange,
|
|
3007
3177
|
soundFontCache,
|
|
3008
3178
|
indefinitePlayback = false,
|
|
3009
3179
|
sampleRate: sampleRateProp,
|
|
@@ -3011,15 +3181,14 @@ var ProviderOnArrangement = ({
|
|
|
3011
3181
|
children
|
|
3012
3182
|
}) => {
|
|
3013
3183
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3014
|
-
const stableZoomLevels = (0,
|
|
3184
|
+
const stableZoomLevels = (0, import_react35.useMemo)(
|
|
3015
3185
|
() => zoomLevels,
|
|
3016
3186
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3017
3187
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
3018
3188
|
);
|
|
3019
3189
|
const {
|
|
3020
|
-
|
|
3190
|
+
getAnnotations,
|
|
3021
3191
|
annotationLookup,
|
|
3022
|
-
setAnnotations,
|
|
3023
3192
|
annotationPreview,
|
|
3024
3193
|
activeAnnotationId,
|
|
3025
3194
|
activeAnnotationIdRef,
|
|
@@ -3032,9 +3201,8 @@ var ProviderOnArrangement = ({
|
|
|
3032
3201
|
annotationsValue,
|
|
3033
3202
|
annotationOptionsValue
|
|
3034
3203
|
} = useAnnotationState({
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
providerName: "WaveformPlaylistProvider"
|
|
3204
|
+
annotationStore,
|
|
3205
|
+
annotationList
|
|
3038
3206
|
});
|
|
3039
3207
|
const {
|
|
3040
3208
|
scrollContainerRef,
|
|
@@ -3044,71 +3212,69 @@ var ProviderOnArrangement = ({
|
|
|
3044
3212
|
setAutomaticScroll
|
|
3045
3213
|
} = useScrollFollow(automaticScroll);
|
|
3046
3214
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
3047
|
-
const [isPlaying, setIsPlaying] = (0,
|
|
3048
|
-
const [currentTime, setCurrentTime] = (0,
|
|
3049
|
-
const [
|
|
3050
|
-
const
|
|
3051
|
-
const indefinitePlaybackRef = (0, import_react33.useRef)(indefinitePlayback);
|
|
3215
|
+
const [isPlaying, setIsPlaying] = (0, import_react35.useState)(false);
|
|
3216
|
+
const [currentTime, setCurrentTime] = (0, import_react35.useState)(0);
|
|
3217
|
+
const [trackDragPreview, setTrackDragPreview] = (0, import_react35.useState)(null);
|
|
3218
|
+
const indefinitePlaybackRef = (0, import_react35.useRef)(indefinitePlayback);
|
|
3052
3219
|
indefinitePlaybackRef.current = indefinitePlayback;
|
|
3053
|
-
const isPlayingRef = (0,
|
|
3220
|
+
const isPlayingRef = (0, import_react35.useRef)(false);
|
|
3054
3221
|
isPlayingRef.current = isPlaying;
|
|
3055
|
-
const playStartPositionRef = (0,
|
|
3056
|
-
const currentTimeRef = (0,
|
|
3057
|
-
const visualTimeRef = (0,
|
|
3058
|
-
const soundFontCacheRef = (0,
|
|
3222
|
+
const playStartPositionRef = (0, import_react35.useRef)(0);
|
|
3223
|
+
const currentTimeRef = (0, import_react35.useRef)(0);
|
|
3224
|
+
const visualTimeRef = (0, import_react35.useRef)(0);
|
|
3225
|
+
const soundFontCacheRef = (0, import_react35.useRef)(soundFontCache);
|
|
3059
3226
|
soundFontCacheRef.current = soundFontCache;
|
|
3060
|
-
const trackEffectsRef = (0,
|
|
3227
|
+
const trackEffectsRef = (0, import_react35.useRef)(trackEffects);
|
|
3061
3228
|
trackEffectsRef.current = trackEffects;
|
|
3062
|
-
const resolveTrackEffects = (0,
|
|
3229
|
+
const resolveTrackEffects = (0, import_react35.useCallback)(
|
|
3063
3230
|
(trackId) => {
|
|
3064
3231
|
var _a;
|
|
3065
3232
|
return (_a = trackEffectsRef.current) == null ? void 0 : _a.call(trackEffectsRef, trackId);
|
|
3066
3233
|
},
|
|
3067
3234
|
[]
|
|
3068
3235
|
);
|
|
3069
|
-
const onReadyRef = (0,
|
|
3070
|
-
const onErrorRef = (0,
|
|
3071
|
-
(0,
|
|
3236
|
+
const onReadyRef = (0, import_react35.useRef)(onReady);
|
|
3237
|
+
const onErrorRef = (0, import_react35.useRef)(onError);
|
|
3238
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
3072
3239
|
onReadyRef.current = onReady;
|
|
3073
3240
|
onErrorRef.current = onError;
|
|
3074
3241
|
});
|
|
3075
|
-
const playbackStartTimeRef = (0,
|
|
3076
|
-
const audioStartPositionRef = (0,
|
|
3077
|
-
const playbackEndTimeRef = (0,
|
|
3078
|
-
const suppressEngineStopMirrorRef = (0,
|
|
3079
|
-
const samplesPerPixelRef = (0,
|
|
3080
|
-
const
|
|
3081
|
-
const
|
|
3242
|
+
const playbackStartTimeRef = (0, import_react35.useRef)(0);
|
|
3243
|
+
const audioStartPositionRef = (0, import_react35.useRef)(0);
|
|
3244
|
+
const playbackEndTimeRef = (0, import_react35.useRef)(null);
|
|
3245
|
+
const suppressEngineStopMirrorRef = (0, import_react35.useRef)(false);
|
|
3246
|
+
const samplesPerPixelRef = (0, import_react35.useRef)(initialSamplesPerPixel);
|
|
3247
|
+
const engineSamplesPerPixelRef = (0, import_react35.useRef)(initialSamplesPerPixel);
|
|
3248
|
+
const isSelectionPlayRef = (0, import_react35.useRef)(false);
|
|
3249
|
+
const playRequestIdRef = (0, import_react35.useRef)(0);
|
|
3082
3250
|
const { animationFrameRef, startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3083
|
-
const onBuildFailure = (0,
|
|
3251
|
+
const onBuildFailure = (0, import_react35.useCallback)(() => {
|
|
3084
3252
|
if (!isPlayingRef.current) return;
|
|
3085
3253
|
setIsPlaying(false);
|
|
3086
3254
|
stopAnimationFrameLoop();
|
|
3087
3255
|
visualTimeRef.current = toVisualTime(currentTimeRef.current);
|
|
3088
3256
|
setCurrentTime(currentTimeRef.current);
|
|
3089
3257
|
}, [stopAnimationFrameLoop]);
|
|
3090
|
-
const followersRef = (0,
|
|
3091
|
-
const seedEngine = (0,
|
|
3258
|
+
const followersRef = (0, import_react35.useRef)(null);
|
|
3259
|
+
const seedEngine = (0, import_react35.useCallback)(
|
|
3092
3260
|
(engine) => {
|
|
3093
3261
|
var _a;
|
|
3094
3262
|
return (_a = followersRef.current) == null ? void 0 : _a.seed(engine);
|
|
3095
3263
|
},
|
|
3096
3264
|
[]
|
|
3097
3265
|
);
|
|
3098
|
-
const onEngine = (0,
|
|
3266
|
+
const onEngine = (0, import_react35.useCallback)(
|
|
3099
3267
|
(engine) => {
|
|
3100
3268
|
var _a;
|
|
3101
3269
|
return (_a = followersRef.current) == null ? void 0 : _a.follow(engine);
|
|
3102
3270
|
},
|
|
3103
3271
|
[]
|
|
3104
3272
|
);
|
|
3105
|
-
const onEngineState = (0,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
[]
|
|
3111
|
-
);
|
|
3273
|
+
const onEngineState = (0, import_react35.useCallback)((state) => {
|
|
3274
|
+
var _a;
|
|
3275
|
+
engineSamplesPerPixelRef.current = state.samplesPerPixel;
|
|
3276
|
+
(_a = followersRef.current) == null ? void 0 : _a.mirror(state);
|
|
3277
|
+
}, []);
|
|
3112
3278
|
const {
|
|
3113
3279
|
engineRef,
|
|
3114
3280
|
adapterRef,
|
|
@@ -3128,7 +3294,7 @@ var ProviderOnArrangement = ({
|
|
|
3128
3294
|
soundFontCacheRef,
|
|
3129
3295
|
sampleRateProp,
|
|
3130
3296
|
zoomLevels,
|
|
3131
|
-
samplesPerPixelRef,
|
|
3297
|
+
samplesPerPixelRef: engineSamplesPerPixelRef,
|
|
3132
3298
|
playbackEndTimeRef,
|
|
3133
3299
|
seedEngine,
|
|
3134
3300
|
onEngine,
|
|
@@ -3137,7 +3303,7 @@ var ProviderOnArrangement = ({
|
|
|
3137
3303
|
onErrorRef,
|
|
3138
3304
|
onBuildFailure
|
|
3139
3305
|
});
|
|
3140
|
-
const sampleRateRef = (0,
|
|
3306
|
+
const sampleRateRef = (0, import_react35.useRef)(sampleRate);
|
|
3141
3307
|
sampleRateRef.current = sampleRate;
|
|
3142
3308
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3143
3309
|
const zoom = useZoomControls({ engineRef, initialSamplesPerPixel });
|
|
@@ -3175,7 +3341,7 @@ var ProviderOnArrangement = ({
|
|
|
3175
3341
|
onEngineState: onSelectedTrackEngineState,
|
|
3176
3342
|
selectedTrackIdRef
|
|
3177
3343
|
} = useSelectedTrack({ engineRef });
|
|
3178
|
-
const baseScale = (0,
|
|
3344
|
+
const baseScale = (0, import_react35.useMemo)(
|
|
3179
3345
|
() => Math.min(...stableZoomLevels != null ? stableZoomLevels : [256, 512, 1024, 2048, 4096, 8192]),
|
|
3180
3346
|
[stableZoomLevels]
|
|
3181
3347
|
);
|
|
@@ -3186,7 +3352,7 @@ var ProviderOnArrangement = ({
|
|
|
3186
3352
|
placeholderSampleRate: isSampleRateKnown ? sampleRate : null
|
|
3187
3353
|
});
|
|
3188
3354
|
const { tracks, duration } = view;
|
|
3189
|
-
const durationRef = (0,
|
|
3355
|
+
const durationRef = (0, import_react35.useRef)(duration);
|
|
3190
3356
|
durationRef.current = duration;
|
|
3191
3357
|
const { isReady, refusePlayBeforeFirstReady } = useReadyOnce({
|
|
3192
3358
|
isEngineAttached,
|
|
@@ -3201,9 +3367,10 @@ var ProviderOnArrangement = ({
|
|
|
3201
3367
|
peaksOptions: view.peaksOptions,
|
|
3202
3368
|
peaksCacheRef: view.peaksCacheRef
|
|
3203
3369
|
});
|
|
3204
|
-
const
|
|
3370
|
+
const [dragGuard] = (0, import_react35.useState)(createDragGuard);
|
|
3371
|
+
const editing = useArrangementEditing(arrangement, dragGuard);
|
|
3205
3372
|
const { recordingActiveRef } = editing;
|
|
3206
|
-
const setLoopRegionFromSelection = (0,
|
|
3373
|
+
const setLoopRegionFromSelection = (0, import_react35.useCallback)(() => {
|
|
3207
3374
|
var _a, _b;
|
|
3208
3375
|
const start = (_a = selectionStartRef.current) != null ? _a : 0;
|
|
3209
3376
|
const end = (_b = selectionEndRef.current) != null ? _b : 0;
|
|
@@ -3211,7 +3378,7 @@ var ProviderOnArrangement = ({
|
|
|
3211
3378
|
setLoopRegion(start, end);
|
|
3212
3379
|
}
|
|
3213
3380
|
}, [setLoopRegion, selectionStartRef, selectionEndRef]);
|
|
3214
|
-
(0,
|
|
3381
|
+
(0, import_react35.useEffect)(() => {
|
|
3215
3382
|
if (!scrollContainerRef.current || duration === 0) return;
|
|
3216
3383
|
const container = scrollContainerRef.current;
|
|
3217
3384
|
const oldSamplesPerPixel = samplesPerPixelRef.current;
|
|
@@ -3227,10 +3394,10 @@ var ProviderOnArrangement = ({
|
|
|
3227
3394
|
container.scrollLeft = newScrollLeft;
|
|
3228
3395
|
samplesPerPixelRef.current = newSamplesPerPixel;
|
|
3229
3396
|
}, [samplesPerPixel, duration, scrollContainerRef]);
|
|
3230
|
-
(0,
|
|
3397
|
+
(0, import_react35.useEffect)(() => {
|
|
3231
3398
|
syncSoundFontCacheToAdapter(adapterRef.current, soundFontCache);
|
|
3232
3399
|
}, [soundFontCache, adapterRef]);
|
|
3233
|
-
(0,
|
|
3400
|
+
(0, import_react35.useEffect)(() => {
|
|
3234
3401
|
for (const track of tracks) {
|
|
3235
3402
|
for (const clip of track.clips) {
|
|
3236
3403
|
if (!clip.audioBuffer && !clip.waveformData && !clip.midiNotes) {
|
|
@@ -3239,15 +3406,15 @@ var ProviderOnArrangement = ({
|
|
|
3239
3406
|
}
|
|
3240
3407
|
}
|
|
3241
3408
|
}, [tracks]);
|
|
3242
|
-
const getAudioContextTime = (0,
|
|
3409
|
+
const getAudioContextTime = (0, import_react35.useCallback)(
|
|
3243
3410
|
() => {
|
|
3244
3411
|
var _a, _b;
|
|
3245
3412
|
return (_b = (_a = adapterRef.current) == null ? void 0 : _a.audioContext.currentTime) != null ? _b : 0;
|
|
3246
3413
|
},
|
|
3247
3414
|
[adapterRef]
|
|
3248
3415
|
);
|
|
3249
|
-
const getPlaybackTimeFallbackWarnedRef = (0,
|
|
3250
|
-
const getPlaybackTime = (0,
|
|
3416
|
+
const getPlaybackTimeFallbackWarnedRef = (0, import_react35.useRef)(false);
|
|
3417
|
+
const getPlaybackTime = (0, import_react35.useCallback)(() => {
|
|
3251
3418
|
var _a, _b;
|
|
3252
3419
|
if (engineRef.current) {
|
|
3253
3420
|
return engineRef.current.getCurrentTime();
|
|
@@ -3261,20 +3428,20 @@ var ProviderOnArrangement = ({
|
|
|
3261
3428
|
const elapsed = getAudioContextTime() - ((_a = playbackStartTimeRef.current) != null ? _a : 0);
|
|
3262
3429
|
return ((_b = audioStartPositionRef.current) != null ? _b : 0) + elapsed;
|
|
3263
3430
|
}, [getAudioContextTime, engineRef]);
|
|
3264
|
-
const setCurrentTimeRefs = (0,
|
|
3431
|
+
const setCurrentTimeRefs = (0, import_react35.useCallback)((rawTime) => {
|
|
3265
3432
|
currentTimeRef.current = rawTime;
|
|
3266
3433
|
visualTimeRef.current = toVisualTime(rawTime);
|
|
3267
3434
|
}, []);
|
|
3268
|
-
const getLookAhead = (0,
|
|
3435
|
+
const getLookAhead = (0, import_react35.useCallback)(() => {
|
|
3269
3436
|
var _a, _b;
|
|
3270
3437
|
return (_b = (_a = engineRef.current) == null ? void 0 : _a.lookAhead) != null ? _b : 0;
|
|
3271
3438
|
}, [engineRef]);
|
|
3272
|
-
const getOutputLatency = (0,
|
|
3439
|
+
const getOutputLatency = (0, import_react35.useCallback)(() => {
|
|
3273
3440
|
var _a;
|
|
3274
3441
|
const audioCtx = (_a = adapterRef.current) == null ? void 0 : _a.audioContext;
|
|
3275
3442
|
return audioCtx && "outputLatency" in audioCtx ? audioCtx.outputLatency : 0;
|
|
3276
3443
|
}, [adapterRef]);
|
|
3277
|
-
const mirrorEngineStop = (0,
|
|
3444
|
+
const mirrorEngineStop = (0, import_react35.useCallback)(
|
|
3278
3445
|
(engine) => {
|
|
3279
3446
|
if (suppressEngineStopMirrorRef.current) return;
|
|
3280
3447
|
setIsPlaying(false);
|
|
@@ -3289,7 +3456,7 @@ var ProviderOnArrangement = ({
|
|
|
3289
3456
|
},
|
|
3290
3457
|
[stopAnimationFrameLoop, setCurrentTimeRefs]
|
|
3291
3458
|
);
|
|
3292
|
-
(0,
|
|
3459
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
3293
3460
|
const mirror = (state) => {
|
|
3294
3461
|
onSelectionEngineState(state);
|
|
3295
3462
|
onLoopEngineState(state);
|
|
@@ -3307,13 +3474,13 @@ var ProviderOnArrangement = ({
|
|
|
3307
3474
|
if (selectedTrackIdRef.current) engine.selectTrack(selectedTrackIdRef.current);
|
|
3308
3475
|
},
|
|
3309
3476
|
follow: (engine) => {
|
|
3310
|
-
engine.on("statechange",
|
|
3477
|
+
engine.on("statechange", onEngineState);
|
|
3311
3478
|
engine.on("stop", () => mirrorEngineStop(engine));
|
|
3312
3479
|
},
|
|
3313
3480
|
mirror
|
|
3314
3481
|
};
|
|
3315
3482
|
});
|
|
3316
|
-
const startAnimationLoop = (0,
|
|
3483
|
+
const startAnimationLoop = (0, import_react35.useCallback)(() => {
|
|
3317
3484
|
const updateTime = () => {
|
|
3318
3485
|
const time = getPlaybackTime();
|
|
3319
3486
|
currentTimeRef.current = time;
|
|
@@ -3330,7 +3497,7 @@ var ProviderOnArrangement = ({
|
|
|
3330
3497
|
};
|
|
3331
3498
|
runFrameCallbacks(frameData);
|
|
3332
3499
|
const activeAnnotationEnded = followAnnotations({
|
|
3333
|
-
annotations:
|
|
3500
|
+
annotations: getAnnotations(),
|
|
3334
3501
|
lookup: annotationLookup,
|
|
3335
3502
|
time,
|
|
3336
3503
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -3382,7 +3549,7 @@ var ProviderOnArrangement = ({
|
|
|
3382
3549
|
annotationLookup,
|
|
3383
3550
|
// Refs and a stable function from the shared provider hooks: they never
|
|
3384
3551
|
// change, and are listed because the linter cannot see that.
|
|
3385
|
-
|
|
3552
|
+
getAnnotations,
|
|
3386
3553
|
activeAnnotationIdRef,
|
|
3387
3554
|
continuousPlayRef,
|
|
3388
3555
|
isAutomaticScrollRef,
|
|
@@ -3392,8 +3559,8 @@ var ProviderOnArrangement = ({
|
|
|
3392
3559
|
recordingActiveRef
|
|
3393
3560
|
]);
|
|
3394
3561
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
3395
|
-
const prevContinuousPlayRef = (0,
|
|
3396
|
-
(0,
|
|
3562
|
+
const prevContinuousPlayRef = (0, import_react35.useRef)(continuousPlay);
|
|
3563
|
+
(0, import_react35.useEffect)(() => {
|
|
3397
3564
|
const continuousPlayTurnedOn = continuousPlay && !prevContinuousPlayRef.current && !isSelectionPlayRef.current;
|
|
3398
3565
|
prevContinuousPlayRef.current = continuousPlay;
|
|
3399
3566
|
const reschedulePlayback = () => __async(null, null, function* () {
|
|
@@ -3409,7 +3576,7 @@ var ProviderOnArrangement = ({
|
|
|
3409
3576
|
audioStartPositionRef.current = currentPos;
|
|
3410
3577
|
const boundedEnd = playbackEndTimeRef.current;
|
|
3411
3578
|
const activeId = activeAnnotationIdRef.current;
|
|
3412
|
-
const activeAnnotation = activeId ? annotationLookup.byId(
|
|
3579
|
+
const activeAnnotation = activeId ? annotationLookup.byId(getAnnotations(), activeId) : void 0;
|
|
3413
3580
|
const endsWithAnnotation = boundedEnd !== null && activeAnnotation !== void 0 && Math.abs(boundedEnd - activeAnnotation.end) < 1e-6;
|
|
3414
3581
|
const endTime = endsWithAnnotation ? null : boundedEnd;
|
|
3415
3582
|
playbackEndTimeRef.current = endTime;
|
|
@@ -3434,11 +3601,11 @@ var ProviderOnArrangement = ({
|
|
|
3434
3601
|
animationFrameRef,
|
|
3435
3602
|
getAudioContextTime,
|
|
3436
3603
|
annotationLookup,
|
|
3437
|
-
|
|
3604
|
+
getAnnotations,
|
|
3438
3605
|
activeAnnotationIdRef,
|
|
3439
3606
|
engineRef
|
|
3440
3607
|
]);
|
|
3441
|
-
(0,
|
|
3608
|
+
(0, import_react35.useEffect)(() => {
|
|
3442
3609
|
const resumePlayback = () => __async(null, null, function* () {
|
|
3443
3610
|
const engine = engineRef.current;
|
|
3444
3611
|
const request = pendingResumeRef.current;
|
|
@@ -3473,7 +3640,7 @@ var ProviderOnArrangement = ({
|
|
|
3473
3640
|
pendingResumeRef,
|
|
3474
3641
|
audioInitializedRef
|
|
3475
3642
|
]);
|
|
3476
|
-
const play = (0,
|
|
3643
|
+
const play = (0, import_react35.useCallback)(
|
|
3477
3644
|
(startTime, playDuration) => __async(null, null, function* () {
|
|
3478
3645
|
var _a, _b;
|
|
3479
3646
|
if (refusePlayBeforeFirstReady()) return;
|
|
@@ -3548,7 +3715,7 @@ var ProviderOnArrangement = ({
|
|
|
3548
3715
|
refusePlayBeforeFirstReady
|
|
3549
3716
|
]
|
|
3550
3717
|
);
|
|
3551
|
-
const pause = (0,
|
|
3718
|
+
const pause = (0, import_react35.useCallback)(() => {
|
|
3552
3719
|
pendingResumeRef.current = null;
|
|
3553
3720
|
playRequestIdRef.current += 1;
|
|
3554
3721
|
const engine = engineRef.current;
|
|
@@ -3559,7 +3726,7 @@ var ProviderOnArrangement = ({
|
|
|
3559
3726
|
setCurrentTimeRefs(pauseTime);
|
|
3560
3727
|
setCurrentTime(pauseTime);
|
|
3561
3728
|
}, [stopAnimationLoop, getPlaybackTime, setCurrentTimeRefs, engineRef, pendingResumeRef]);
|
|
3562
|
-
const stop = (0,
|
|
3729
|
+
const stop = (0, import_react35.useCallback)(() => {
|
|
3563
3730
|
var _a, _b;
|
|
3564
3731
|
pendingResumeRef.current = null;
|
|
3565
3732
|
playRequestIdRef.current += 1;
|
|
@@ -3571,7 +3738,7 @@ var ProviderOnArrangement = ({
|
|
|
3571
3738
|
setCurrentTime(playStartPositionRef.current);
|
|
3572
3739
|
setActiveAnnotationId(null);
|
|
3573
3740
|
}, [stopAnimationLoop, setActiveAnnotationId, setCurrentTimeRefs, engineRef, pendingResumeRef]);
|
|
3574
|
-
const seekTo = (0,
|
|
3741
|
+
const seekTo = (0, import_react35.useCallback)(
|
|
3575
3742
|
(time) => {
|
|
3576
3743
|
const pastEndAllowed = Number.isFinite(time) && (indefinitePlaybackRef.current || recordingActiveRef.current);
|
|
3577
3744
|
const upperLimit = pastEndAllowed ? Infinity : durationRef.current;
|
|
@@ -3584,10 +3751,7 @@ var ProviderOnArrangement = ({
|
|
|
3584
3751
|
},
|
|
3585
3752
|
[play, setCurrentTimeRefs, recordingActiveRef]
|
|
3586
3753
|
);
|
|
3587
|
-
const
|
|
3588
|
-
setTrackReorderEpoch((epoch) => epoch + 1);
|
|
3589
|
-
}, []);
|
|
3590
|
-
const setSelection = (0, import_react33.useCallback)(
|
|
3754
|
+
const setSelection = (0, import_react35.useCallback)(
|
|
3591
3755
|
(start, end) => {
|
|
3592
3756
|
var _a;
|
|
3593
3757
|
setSelectionEngine(start, end);
|
|
@@ -3635,8 +3799,8 @@ var ProviderOnArrangement = ({
|
|
|
3635
3799
|
pendingResumeRef
|
|
3636
3800
|
]
|
|
3637
3801
|
);
|
|
3638
|
-
const isPlayingValue = (0,
|
|
3639
|
-
const refsValue = (0,
|
|
3802
|
+
const isPlayingValue = (0, import_react35.useMemo)(() => ({ isPlaying }), [isPlaying]);
|
|
3803
|
+
const refsValue = (0, import_react35.useMemo)(
|
|
3640
3804
|
() => ({
|
|
3641
3805
|
currentTimeRef,
|
|
3642
3806
|
visualTimeRef,
|
|
@@ -3645,7 +3809,7 @@ var ProviderOnArrangement = ({
|
|
|
3645
3809
|
}),
|
|
3646
3810
|
[currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback]
|
|
3647
3811
|
);
|
|
3648
|
-
const engineRefsValue = (0,
|
|
3812
|
+
const engineRefsValue = (0, import_react35.useMemo)(
|
|
3649
3813
|
() => ({
|
|
3650
3814
|
playbackStartTimeRef,
|
|
3651
3815
|
audioStartPositionRef,
|
|
@@ -3665,36 +3829,36 @@ var ProviderOnArrangement = ({
|
|
|
3665
3829
|
engineRef
|
|
3666
3830
|
]
|
|
3667
3831
|
);
|
|
3668
|
-
const loopValue = (0,
|
|
3832
|
+
const loopValue = (0, import_react35.useMemo)(
|
|
3669
3833
|
() => ({ isLoopEnabled, loopStart, loopEnd }),
|
|
3670
3834
|
[isLoopEnabled, loopStart, loopEnd]
|
|
3671
3835
|
);
|
|
3672
|
-
const selectedTrackIdValue = (0,
|
|
3836
|
+
const selectedTrackIdValue = (0, import_react35.useMemo)(
|
|
3673
3837
|
() => ({ selectedTrackId }),
|
|
3674
3838
|
[selectedTrackId]
|
|
3675
3839
|
);
|
|
3676
3840
|
const { canUndo, canRedo } = view;
|
|
3677
|
-
const undoRedoValue = (0,
|
|
3841
|
+
const undoRedoValue = (0, import_react35.useMemo)(
|
|
3678
3842
|
() => ({ canUndo, canRedo }),
|
|
3679
3843
|
[canUndo, canRedo]
|
|
3680
3844
|
);
|
|
3681
|
-
const selectionValue = (0,
|
|
3845
|
+
const selectionValue = (0, import_react35.useMemo)(
|
|
3682
3846
|
() => ({ selectionStart, selectionEnd }),
|
|
3683
3847
|
[selectionStart, selectionEnd]
|
|
3684
3848
|
);
|
|
3685
|
-
const currentTimeValue = (0,
|
|
3686
|
-
const activeAnnotationValue = (0,
|
|
3849
|
+
const currentTimeValue = (0, import_react35.useMemo)(() => ({ currentTime }), [currentTime]);
|
|
3850
|
+
const activeAnnotationValue = (0, import_react35.useMemo)(
|
|
3687
3851
|
() => ({ activeAnnotationId }),
|
|
3688
3852
|
[activeAnnotationId]
|
|
3689
3853
|
);
|
|
3690
|
-
const setCurrentTimeControl = (0,
|
|
3854
|
+
const setCurrentTimeControl = (0, import_react35.useCallback)(
|
|
3691
3855
|
(time) => {
|
|
3692
3856
|
setCurrentTimeRefs(time);
|
|
3693
3857
|
setCurrentTime(time);
|
|
3694
3858
|
},
|
|
3695
3859
|
[setCurrentTimeRefs]
|
|
3696
3860
|
);
|
|
3697
|
-
const playAnnotation = (0,
|
|
3861
|
+
const playAnnotation = (0, import_react35.useCallback)(
|
|
3698
3862
|
(annotation) => {
|
|
3699
3863
|
if (refusePlayBeforeFirstReady()) return;
|
|
3700
3864
|
setActiveAnnotationId(annotation.id);
|
|
@@ -3707,7 +3871,7 @@ var ProviderOnArrangement = ({
|
|
|
3707
3871
|
},
|
|
3708
3872
|
[play, setActiveAnnotationId, continuousPlayRef, refusePlayBeforeFirstReady]
|
|
3709
3873
|
);
|
|
3710
|
-
const controlsValue = (0,
|
|
3874
|
+
const controlsValue = (0, import_react35.useMemo)(
|
|
3711
3875
|
() => ({
|
|
3712
3876
|
play,
|
|
3713
3877
|
pause,
|
|
@@ -3721,8 +3885,8 @@ var ProviderOnArrangement = ({
|
|
|
3721
3885
|
setContinuousPlay,
|
|
3722
3886
|
setAnnotationsEditable,
|
|
3723
3887
|
setLinkEndpoints,
|
|
3724
|
-
setAnnotations,
|
|
3725
3888
|
annotationPreview,
|
|
3889
|
+
annotationStore,
|
|
3726
3890
|
setActiveAnnotationId,
|
|
3727
3891
|
playAnnotation
|
|
3728
3892
|
}),
|
|
@@ -3739,13 +3903,13 @@ var ProviderOnArrangement = ({
|
|
|
3739
3903
|
setContinuousPlay,
|
|
3740
3904
|
setAnnotationsEditable,
|
|
3741
3905
|
setLinkEndpoints,
|
|
3742
|
-
setAnnotations,
|
|
3743
3906
|
annotationPreview,
|
|
3907
|
+
annotationStore,
|
|
3744
3908
|
setActiveAnnotationId,
|
|
3745
3909
|
playAnnotation
|
|
3746
3910
|
]
|
|
3747
3911
|
);
|
|
3748
|
-
const editorControlsValue = (0,
|
|
3912
|
+
const editorControlsValue = (0, import_react35.useMemo)(
|
|
3749
3913
|
() => ({
|
|
3750
3914
|
setCurrentTime: setCurrentTimeControl,
|
|
3751
3915
|
// Track controls (the arrangement's mix and order)
|
|
@@ -3754,7 +3918,6 @@ var ProviderOnArrangement = ({
|
|
|
3754
3918
|
setTrackVolume: editing.setTrackVolume,
|
|
3755
3919
|
setTrackPan: editing.setTrackPan,
|
|
3756
3920
|
reorderTrack: editing.reorderTrack,
|
|
3757
|
-
bumpTrackReorderEpoch,
|
|
3758
3921
|
setTrackDragPreview,
|
|
3759
3922
|
setSelectedTrackId: setSelectedTrackIdControl,
|
|
3760
3923
|
// Zoom
|
|
@@ -3780,7 +3943,6 @@ var ProviderOnArrangement = ({
|
|
|
3780
3943
|
editing.setTrackVolume,
|
|
3781
3944
|
editing.setTrackPan,
|
|
3782
3945
|
editing.reorderTrack,
|
|
3783
|
-
bumpTrackReorderEpoch,
|
|
3784
3946
|
setTrackDragPreview,
|
|
3785
3947
|
setSelectedTrackIdControl,
|
|
3786
3948
|
zoom.zoomIn,
|
|
@@ -3795,7 +3957,7 @@ var ProviderOnArrangement = ({
|
|
|
3795
3957
|
editing.setRecordingActive
|
|
3796
3958
|
]
|
|
3797
3959
|
);
|
|
3798
|
-
const viewValue = (0,
|
|
3960
|
+
const viewValue = (0, import_react35.useMemo)(
|
|
3799
3961
|
() => ({
|
|
3800
3962
|
sampleRate,
|
|
3801
3963
|
mono,
|
|
@@ -3803,54 +3965,60 @@ var ProviderOnArrangement = ({
|
|
|
3803
3965
|
}),
|
|
3804
3966
|
[sampleRate, mono, indefinitePlayback]
|
|
3805
3967
|
);
|
|
3806
|
-
const settingsValue = (0,
|
|
3968
|
+
const settingsValue = (0, import_react35.useMemo)(
|
|
3807
3969
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
3808
3970
|
[timeFormat, isAutomaticScroll]
|
|
3809
3971
|
);
|
|
3810
|
-
const zoomValue = (0,
|
|
3972
|
+
const zoomValue = (0, import_react35.useMemo)(
|
|
3811
3973
|
() => ({ samplesPerPixel, canZoomIn: zoom.canZoomIn, canZoomOut: zoom.canZoomOut }),
|
|
3812
3974
|
[samplesPerPixel, zoom.canZoomIn, zoom.canZoomOut]
|
|
3813
3975
|
);
|
|
3814
3976
|
const { peaksDataArray, trackStates } = view;
|
|
3815
|
-
const timelineValue = (0,
|
|
3977
|
+
const timelineValue = (0, import_react35.useMemo)(
|
|
3816
3978
|
() => ({ tracks, peaksDataArray, duration, isReady }),
|
|
3817
3979
|
[tracks, peaksDataArray, duration, isReady]
|
|
3818
3980
|
);
|
|
3819
|
-
const mixerValue = (0,
|
|
3981
|
+
const mixerValue = (0, import_react35.useMemo)(
|
|
3820
3982
|
() => ({ trackStates, masterVolume }),
|
|
3821
3983
|
[trackStates, masterVolume]
|
|
3822
3984
|
);
|
|
3823
|
-
const reorderPreviewValue = (0,
|
|
3824
|
-
() => ({ trackDragPreview
|
|
3825
|
-
[trackDragPreview
|
|
3985
|
+
const reorderPreviewValue = (0, import_react35.useMemo)(
|
|
3986
|
+
() => ({ trackDragPreview }),
|
|
3987
|
+
[trackDragPreview]
|
|
3826
3988
|
);
|
|
3827
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled_components.ThemeProvider, { theme: mergedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRateContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaElementTrackContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrangementContext, { value: arrangement, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRefsContext, { value: refsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineRefsContext, { value: engineRefsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3828
|
-
|
|
3989
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled_components.ThemeProvider, { theme: mergedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRateContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaElementTrackContext, { value: BLOCKED, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrangementContext, { value: arrangement, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackRefsContext, { value: refsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EngineRefsContext, { value: engineRefsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DragGuardContext, { value: dragGuard, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrimPreviewContext, { value: trimPreview, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrimPreviewPeaksContext, { value: trimPreviewPeaks, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaybackControlsContext, { value: controlsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EditorControlsContext, { value: editorControlsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistViewContext, { value: viewValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistSettingsContext, { value: settingsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistZoomContext, { value: zoomValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UndoRedoContext, { value: undoRedoValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectedTrackIdContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectedRowContext, { value: selectedTrackIdValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoopContext, { value: loopValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnnotationOptionsContext, { value: annotationOptionsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnnotationsContext, { value: annotationsValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IsPlayingContext, { value: isPlayingValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3990
|
+
ActiveAnnotationContext,
|
|
3829
3991
|
{
|
|
3830
|
-
value:
|
|
3831
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3832
|
-
|
|
3992
|
+
value: activeAnnotationValue,
|
|
3993
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectionContext, { value: selectionValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3994
|
+
TrackReorderPreviewContext,
|
|
3833
3995
|
{
|
|
3834
|
-
value:
|
|
3835
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3836
|
-
|
|
3996
|
+
value: reorderPreviewValue,
|
|
3997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlaylistMixerContext, { value: mixerValue, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3998
|
+
PlaylistTimelineContext,
|
|
3837
3999
|
{
|
|
3838
|
-
value:
|
|
3839
|
-
children
|
|
4000
|
+
value: timelineValue,
|
|
4001
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
4002
|
+
RecordingTrackContext,
|
|
4003
|
+
{
|
|
4004
|
+
value: editing.recordingTrack,
|
|
4005
|
+
children
|
|
4006
|
+
}
|
|
4007
|
+
)
|
|
3840
4008
|
}
|
|
3841
|
-
)
|
|
4009
|
+
) })
|
|
3842
4010
|
}
|
|
3843
|
-
) })
|
|
4011
|
+
) }) })
|
|
3844
4012
|
}
|
|
3845
|
-
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
|
|
4013
|
+
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
3846
4014
|
};
|
|
3847
4015
|
|
|
3848
4016
|
// src/MediaElementPlaylistContext.tsx
|
|
3849
|
-
var
|
|
4017
|
+
var import_react36 = require("react");
|
|
3850
4018
|
var import_styled_components2 = require("styled-components");
|
|
3851
4019
|
|
|
3852
4020
|
// src/playout/resolveMediaElementPlayout.ts
|
|
3853
|
-
var
|
|
4021
|
+
var installHint2 = () => "@waveform-playlist/media-element-playout is required for the default MediaElement engine. Install with: " + installCommand("@waveform-playlist/media-element-playout") + " \u2014 or pass a custom `createPlayout`.";
|
|
3854
4022
|
function resolveMediaElementPlayout(opts) {
|
|
3855
4023
|
return __async(this, null, function* () {
|
|
3856
4024
|
if (opts.createPlayout) {
|
|
@@ -3863,7 +4031,7 @@ function resolveMediaElementPlayout(opts) {
|
|
|
3863
4031
|
console.warn(
|
|
3864
4032
|
"[waveform-playlist] @waveform-playlist/media-element-playout dynamic import failed: " + String(originalErr)
|
|
3865
4033
|
);
|
|
3866
|
-
throw new Error(
|
|
4034
|
+
throw new Error(installHint2());
|
|
3867
4035
|
}
|
|
3868
4036
|
return new mod.MediaElementPlayout({
|
|
3869
4037
|
playbackRate: opts.playbackRate,
|
|
@@ -3882,40 +4050,39 @@ var MediaElementPlaylistProvider = ({
|
|
|
3882
4050
|
preservesPitch = true,
|
|
3883
4051
|
automaticScroll = false,
|
|
3884
4052
|
theme: userThemeProp,
|
|
4053
|
+
annotationStore,
|
|
3885
4054
|
annotationList,
|
|
3886
4055
|
audioContext,
|
|
3887
|
-
onAnnotationsChange,
|
|
3888
4056
|
onReady,
|
|
3889
4057
|
onError,
|
|
3890
4058
|
createPlayout,
|
|
3891
4059
|
children
|
|
3892
4060
|
}) => {
|
|
3893
4061
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3894
|
-
const [isPlaying, setIsPlayingState] = (0,
|
|
3895
|
-
const isPlayingRef = (0,
|
|
3896
|
-
const setIsPlaying = (0,
|
|
4062
|
+
const [isPlaying, setIsPlayingState] = (0, import_react36.useState)(false);
|
|
4063
|
+
const isPlayingRef = (0, import_react36.useRef)(false);
|
|
4064
|
+
const setIsPlaying = (0, import_react36.useCallback)((playing) => {
|
|
3897
4065
|
isPlayingRef.current = playing;
|
|
3898
4066
|
setIsPlayingState(playing);
|
|
3899
4067
|
}, []);
|
|
3900
|
-
const [currentTime, setCurrentTime] = (0,
|
|
3901
|
-
const [isReady, setIsReady] = (0,
|
|
3902
|
-
const [playbackRate, setPlaybackRateState] = (0,
|
|
3903
|
-
const [ratePropSeen, setRatePropSeen] = (0,
|
|
4068
|
+
const [currentTime, setCurrentTime] = (0, import_react36.useState)(0);
|
|
4069
|
+
const [isReady, setIsReady] = (0, import_react36.useState)(false);
|
|
4070
|
+
const [playbackRate, setPlaybackRateState] = (0, import_react36.useState)(initialPlaybackRate);
|
|
4071
|
+
const [ratePropSeen, setRatePropSeen] = (0, import_react36.useState)(initialPlaybackRate);
|
|
3904
4072
|
if (!Object.is(ratePropSeen, initialPlaybackRate)) {
|
|
3905
4073
|
setRatePropSeen(initialPlaybackRate);
|
|
3906
4074
|
setPlaybackRateState(initialPlaybackRate);
|
|
3907
4075
|
}
|
|
3908
|
-
const playbackRateRef = (0,
|
|
3909
|
-
const ratePropAppliedRef = (0,
|
|
3910
|
-
(0,
|
|
4076
|
+
const playbackRateRef = (0, import_react36.useRef)(initialPlaybackRate);
|
|
4077
|
+
const ratePropAppliedRef = (0, import_react36.useRef)(initialPlaybackRate);
|
|
4078
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
3911
4079
|
if (Object.is(ratePropAppliedRef.current, initialPlaybackRate)) return;
|
|
3912
4080
|
ratePropAppliedRef.current = initialPlaybackRate;
|
|
3913
4081
|
playbackRateRef.current = initialPlaybackRate;
|
|
3914
4082
|
}, [initialPlaybackRate]);
|
|
3915
4083
|
const {
|
|
3916
|
-
|
|
4084
|
+
getAnnotations,
|
|
3917
4085
|
annotationLookup,
|
|
3918
|
-
setAnnotations,
|
|
3919
4086
|
annotationPreview,
|
|
3920
4087
|
activeAnnotationId,
|
|
3921
4088
|
activeAnnotationIdRef,
|
|
@@ -3927,9 +4094,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3927
4094
|
annotationsValue,
|
|
3928
4095
|
annotationOptionsValue
|
|
3929
4096
|
} = useAnnotationState({
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
providerName: "MediaElementPlaylistProvider"
|
|
4097
|
+
annotationStore,
|
|
4098
|
+
annotationList
|
|
3933
4099
|
});
|
|
3934
4100
|
const {
|
|
3935
4101
|
scrollContainerRef,
|
|
@@ -3939,27 +4105,27 @@ var MediaElementPlaylistProvider = ({
|
|
|
3939
4105
|
setAutomaticScroll
|
|
3940
4106
|
} = useScrollFollow(automaticScroll);
|
|
3941
4107
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
3942
|
-
const [selection, setSelectionState] = (0,
|
|
4108
|
+
const [selection, setSelectionState] = (0, import_react36.useState)({
|
|
3943
4109
|
selectionStart: 0,
|
|
3944
4110
|
selectionEnd: 0
|
|
3945
4111
|
});
|
|
3946
|
-
const selectionRef = (0,
|
|
3947
|
-
const [samplesPerPixel] = (0,
|
|
4112
|
+
const selectionRef = (0, import_react36.useRef)(selection);
|
|
4113
|
+
const [samplesPerPixel] = (0, import_react36.useState)(initialSamplesPerPixel);
|
|
3948
4114
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3949
|
-
const playoutRef = (0,
|
|
3950
|
-
const currentTimeRef = (0,
|
|
3951
|
-
const samplesPerPixelRef = (0,
|
|
4115
|
+
const playoutRef = (0, import_react36.useRef)(null);
|
|
4116
|
+
const currentTimeRef = (0, import_react36.useRef)(0);
|
|
4117
|
+
const samplesPerPixelRef = (0, import_react36.useRef)(initialSamplesPerPixel);
|
|
3952
4118
|
const { startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3953
|
-
const playStartPositionRef = (0,
|
|
3954
|
-
const playbackEndTimeRef = (0,
|
|
3955
|
-
const isSelectionPlayRef = (0,
|
|
3956
|
-
const pendingPlayRef = (0,
|
|
3957
|
-
const playoutInFlightRef = (0,
|
|
4119
|
+
const playStartPositionRef = (0, import_react36.useRef)(0);
|
|
4120
|
+
const playbackEndTimeRef = (0, import_react36.useRef)(null);
|
|
4121
|
+
const isSelectionPlayRef = (0, import_react36.useRef)(false);
|
|
4122
|
+
const pendingPlayRef = (0, import_react36.useRef)(null);
|
|
4123
|
+
const playoutInFlightRef = (0, import_react36.useRef)(true);
|
|
3958
4124
|
const sampleRate = track.waveformData.sample_rate;
|
|
3959
4125
|
const duration = track.waveformData.duration;
|
|
3960
4126
|
const trackName = track.name;
|
|
3961
4127
|
const trackWaveformData = track.waveformData;
|
|
3962
|
-
const trackPeaks = (0,
|
|
4128
|
+
const trackPeaks = (0, import_react36.useMemo)(() => {
|
|
3963
4129
|
try {
|
|
3964
4130
|
const durationSamples = Math.ceil(trackWaveformData.duration * sampleRate);
|
|
3965
4131
|
const extractedPeaks = extractPeaksFromWaveformData(
|
|
@@ -3988,7 +4154,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
3988
4154
|
}, [trackWaveformData, samplesPerPixel, sampleRate]);
|
|
3989
4155
|
const trackFadeIn = useShallowStable(track.fadeIn);
|
|
3990
4156
|
const trackFadeOut = useShallowStable(track.fadeOut);
|
|
3991
|
-
const peaksDataArray = (0,
|
|
4157
|
+
const peaksDataArray = (0, import_react36.useMemo)(() => {
|
|
3992
4158
|
if (!trackPeaks) return [];
|
|
3993
4159
|
const clipPeaks = {
|
|
3994
4160
|
clipId: "media-element-clip",
|
|
@@ -4002,11 +4168,11 @@ var MediaElementPlaylistProvider = ({
|
|
|
4002
4168
|
};
|
|
4003
4169
|
return [[clipPeaks]];
|
|
4004
4170
|
}, [trackPeaks, trackName, trackFadeIn, trackFadeOut]);
|
|
4005
|
-
const latestAudioRef = (0,
|
|
4006
|
-
(0,
|
|
4171
|
+
const latestAudioRef = (0, import_react36.useRef)({ source: track.source, waveformData: track.waveformData });
|
|
4172
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
4007
4173
|
latestAudioRef.current = { source: track.source, waveformData: track.waveformData };
|
|
4008
4174
|
}, [track.source, track.waveformData]);
|
|
4009
|
-
const restAt = (0,
|
|
4175
|
+
const restAt = (0, import_react36.useCallback)(
|
|
4010
4176
|
(cursor) => {
|
|
4011
4177
|
const playout = playoutRef.current;
|
|
4012
4178
|
if (playout) {
|
|
@@ -4022,10 +4188,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
4022
4188
|
},
|
|
4023
4189
|
[stopAnimationFrameLoop, setIsPlaying]
|
|
4024
4190
|
);
|
|
4025
|
-
const startAnimationLoopRef = (0,
|
|
4191
|
+
const startAnimationLoopRef = (0, import_react36.useRef)(() => {
|
|
4026
4192
|
});
|
|
4027
|
-
const endPlaybackIfDueRef = (0,
|
|
4028
|
-
(0,
|
|
4193
|
+
const endPlaybackIfDueRef = (0, import_react36.useRef)(() => false);
|
|
4194
|
+
(0, import_react36.useEffect)(() => {
|
|
4029
4195
|
let cancelled = false;
|
|
4030
4196
|
let createdPlayout = null;
|
|
4031
4197
|
const source = track.source;
|
|
@@ -4151,10 +4317,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
4151
4317
|
restAt,
|
|
4152
4318
|
createPlayout
|
|
4153
4319
|
]);
|
|
4154
|
-
const endPlaybackIfDue = (0,
|
|
4320
|
+
const endPlaybackIfDue = (0, import_react36.useCallback)(
|
|
4155
4321
|
(time) => {
|
|
4156
4322
|
const activeAnnotationEnded = followAnnotations({
|
|
4157
|
-
annotations:
|
|
4323
|
+
annotations: getAnnotations(),
|
|
4158
4324
|
lookup: annotationLookup,
|
|
4159
4325
|
time,
|
|
4160
4326
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -4177,7 +4343,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4177
4343
|
return false;
|
|
4178
4344
|
},
|
|
4179
4345
|
[
|
|
4180
|
-
|
|
4346
|
+
getAnnotations,
|
|
4181
4347
|
annotationLookup,
|
|
4182
4348
|
activeAnnotationIdRef,
|
|
4183
4349
|
continuousPlayRef,
|
|
@@ -4185,7 +4351,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4185
4351
|
restAt
|
|
4186
4352
|
]
|
|
4187
4353
|
);
|
|
4188
|
-
const startAnimationLoop = (0,
|
|
4354
|
+
const startAnimationLoop = (0, import_react36.useCallback)(() => {
|
|
4189
4355
|
const updateTime = () => {
|
|
4190
4356
|
var _a, _b;
|
|
4191
4357
|
const time = (_b = (_a = playoutRef.current) == null ? void 0 : _a.getCurrentTime()) != null ? _b : 0;
|
|
@@ -4211,12 +4377,12 @@ var MediaElementPlaylistProvider = ({
|
|
|
4211
4377
|
runFrameCallbacks,
|
|
4212
4378
|
endPlaybackIfDue
|
|
4213
4379
|
]);
|
|
4214
|
-
(0,
|
|
4380
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
4215
4381
|
startAnimationLoopRef.current = startAnimationLoop;
|
|
4216
4382
|
endPlaybackIfDueRef.current = endPlaybackIfDue;
|
|
4217
4383
|
}, [startAnimationLoop, endPlaybackIfDue]);
|
|
4218
4384
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
4219
|
-
const play = (0,
|
|
4385
|
+
const play = (0, import_react36.useCallback)(
|
|
4220
4386
|
(startTime, playDuration) => __async(null, null, function* () {
|
|
4221
4387
|
const actualStartTime = startTime != null ? startTime : currentTimeRef.current;
|
|
4222
4388
|
const endTime = playDuration !== void 0 ? actualStartTime + playDuration : void 0;
|
|
@@ -4238,7 +4404,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4238
4404
|
}),
|
|
4239
4405
|
[startAnimationLoop, setIsPlaying]
|
|
4240
4406
|
);
|
|
4241
|
-
const pause = (0,
|
|
4407
|
+
const pause = (0, import_react36.useCallback)(() => {
|
|
4242
4408
|
pendingPlayRef.current = null;
|
|
4243
4409
|
if (!playoutRef.current) {
|
|
4244
4410
|
setCurrentTime(currentTimeRef.current);
|
|
@@ -4249,12 +4415,12 @@ var MediaElementPlaylistProvider = ({
|
|
|
4249
4415
|
stopAnimationLoop();
|
|
4250
4416
|
setCurrentTime(playoutRef.current.getCurrentTime());
|
|
4251
4417
|
}, [stopAnimationLoop, setIsPlaying]);
|
|
4252
|
-
const stop = (0,
|
|
4418
|
+
const stop = (0, import_react36.useCallback)(() => {
|
|
4253
4419
|
pendingPlayRef.current = null;
|
|
4254
4420
|
restAt(playStartPositionRef.current);
|
|
4255
4421
|
setActiveAnnotationId(null);
|
|
4256
4422
|
}, [restAt, setActiveAnnotationId]);
|
|
4257
|
-
const seekTo = (0,
|
|
4423
|
+
const seekTo = (0, import_react36.useCallback)((time) => {
|
|
4258
4424
|
if (Number.isNaN(time)) return;
|
|
4259
4425
|
const trackDuration = latestAudioRef.current.waveformData.duration;
|
|
4260
4426
|
const clampedTime = Math.max(0, Math.min(time, trackDuration));
|
|
@@ -4276,7 +4442,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4276
4442
|
playout.seekTo(clampedTime);
|
|
4277
4443
|
}
|
|
4278
4444
|
}, []);
|
|
4279
|
-
const setSelection = (0,
|
|
4445
|
+
const setSelection = (0, import_react36.useCallback)(
|
|
4280
4446
|
(requestedStart, requestedEnd) => {
|
|
4281
4447
|
const length = latestAudioRef.current.waveformData.duration;
|
|
4282
4448
|
const clamp = (time) => Math.max(0, Math.min(time, length));
|
|
@@ -4317,7 +4483,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4317
4483
|
},
|
|
4318
4484
|
[activeAnnotationIdRef, setActiveAnnotationId]
|
|
4319
4485
|
);
|
|
4320
|
-
const setPlaybackRate = (0,
|
|
4486
|
+
const setPlaybackRate = (0, import_react36.useCallback)((rate) => {
|
|
4321
4487
|
if (Number.isNaN(rate)) return;
|
|
4322
4488
|
const clampedRate = Math.max(0.5, Math.min(2, rate));
|
|
4323
4489
|
playbackRateRef.current = clampedRate;
|
|
@@ -4326,17 +4492,17 @@ var MediaElementPlaylistProvider = ({
|
|
|
4326
4492
|
playoutRef.current.setPlaybackRate(clampedRate);
|
|
4327
4493
|
}
|
|
4328
4494
|
}, []);
|
|
4329
|
-
const isPlayingValue = (0,
|
|
4330
|
-
const currentTimeValue = (0,
|
|
4331
|
-
const activeAnnotationValue = (0,
|
|
4495
|
+
const isPlayingValue = (0, import_react36.useMemo)(() => ({ isPlaying }), [isPlaying]);
|
|
4496
|
+
const currentTimeValue = (0, import_react36.useMemo)(() => ({ currentTime }), [currentTime]);
|
|
4497
|
+
const activeAnnotationValue = (0, import_react36.useMemo)(
|
|
4332
4498
|
() => ({ activeAnnotationId }),
|
|
4333
4499
|
[activeAnnotationId]
|
|
4334
4500
|
);
|
|
4335
|
-
const settingsValue = (0,
|
|
4501
|
+
const settingsValue = (0, import_react36.useMemo)(
|
|
4336
4502
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
4337
4503
|
[timeFormat, isAutomaticScroll]
|
|
4338
4504
|
);
|
|
4339
|
-
const refsValue = (0,
|
|
4505
|
+
const refsValue = (0, import_react36.useMemo)(
|
|
4340
4506
|
() => ({
|
|
4341
4507
|
currentTimeRef,
|
|
4342
4508
|
visualTimeRef: currentTimeRef,
|
|
@@ -4345,7 +4511,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4345
4511
|
}),
|
|
4346
4512
|
[registerFrameCallback, unregisterFrameCallback]
|
|
4347
4513
|
);
|
|
4348
|
-
const playAnnotation = (0,
|
|
4514
|
+
const playAnnotation = (0, import_react36.useCallback)(
|
|
4349
4515
|
(annotation) => {
|
|
4350
4516
|
setActiveAnnotationId(annotation.id);
|
|
4351
4517
|
play(annotation.start).catch((err) => {
|
|
@@ -4356,7 +4522,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4356
4522
|
},
|
|
4357
4523
|
[play, setActiveAnnotationId]
|
|
4358
4524
|
);
|
|
4359
|
-
const controlsValue = (0,
|
|
4525
|
+
const controlsValue = (0, import_react36.useMemo)(
|
|
4360
4526
|
() => ({
|
|
4361
4527
|
play,
|
|
4362
4528
|
pause,
|
|
@@ -4370,8 +4536,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
4370
4536
|
setContinuousPlay,
|
|
4371
4537
|
setAnnotationsEditable,
|
|
4372
4538
|
setLinkEndpoints,
|
|
4373
|
-
setAnnotations,
|
|
4374
4539
|
annotationPreview,
|
|
4540
|
+
annotationStore,
|
|
4375
4541
|
setActiveAnnotationId,
|
|
4376
4542
|
playAnnotation
|
|
4377
4543
|
}),
|
|
@@ -4388,25 +4554,25 @@ var MediaElementPlaylistProvider = ({
|
|
|
4388
4554
|
setContinuousPlay,
|
|
4389
4555
|
setAnnotationsEditable,
|
|
4390
4556
|
setLinkEndpoints,
|
|
4391
|
-
setAnnotations,
|
|
4392
4557
|
annotationPreview,
|
|
4558
|
+
annotationStore,
|
|
4393
4559
|
setActiveAnnotationId,
|
|
4394
4560
|
playAnnotation
|
|
4395
4561
|
]
|
|
4396
4562
|
);
|
|
4397
|
-
const viewValue = (0,
|
|
4563
|
+
const viewValue = (0, import_react36.useMemo)(
|
|
4398
4564
|
() => ({ sampleRate, mono: false, indefinitePlayback: false }),
|
|
4399
4565
|
[sampleRate]
|
|
4400
4566
|
);
|
|
4401
|
-
const zoomValue = (0,
|
|
4567
|
+
const zoomValue = (0, import_react36.useMemo)(
|
|
4402
4568
|
() => ({ samplesPerPixel, canZoomIn: false, canZoomOut: false }),
|
|
4403
4569
|
[samplesPerPixel]
|
|
4404
4570
|
);
|
|
4405
|
-
const playbackRateValue = (0,
|
|
4571
|
+
const playbackRateValue = (0, import_react36.useMemo)(
|
|
4406
4572
|
() => ({ playbackRate, setPlaybackRate }),
|
|
4407
4573
|
[playbackRate, setPlaybackRate]
|
|
4408
4574
|
);
|
|
4409
|
-
const trackValue = (0,
|
|
4575
|
+
const trackValue = (0, import_react36.useMemo)(
|
|
4410
4576
|
() => ({
|
|
4411
4577
|
duration,
|
|
4412
4578
|
isReady,
|
|
@@ -4421,13 +4587,13 @@ var MediaElementPlaylistProvider = ({
|
|
|
4421
4587
|
ActiveAnnotationContext,
|
|
4422
4588
|
{
|
|
4423
4589
|
value: activeAnnotationValue,
|
|
4424
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SelectionContext, { value: selection, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SelectedRowContext, { value: ONLY_ROW_SELECTED, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
4590
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CurrentTimeContext, { value: currentTimeValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SelectionContext, { value: selection, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SelectedRowContext, { value: ONLY_ROW_SELECTED, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RecordingTrackContext, { value: BLOCKED, children }) }) }) })
|
|
4425
4591
|
}
|
|
4426
4592
|
) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
4427
4593
|
};
|
|
4428
4594
|
|
|
4429
4595
|
// src/components/PlaybackControls.tsx
|
|
4430
|
-
var
|
|
4596
|
+
var import_react37 = require("react");
|
|
4431
4597
|
var import_ui_components3 = require("@waveform-playlist/ui-components");
|
|
4432
4598
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
4433
4599
|
var PlayButton = ({ className }) => {
|
|
@@ -4532,7 +4698,7 @@ var ClearAllButton = ({
|
|
|
4532
4698
|
className
|
|
4533
4699
|
}) => {
|
|
4534
4700
|
const { stop } = usePlaybackControls();
|
|
4535
|
-
const handleClick = (0,
|
|
4701
|
+
const handleClick = (0, import_react37.useCallback)(() => {
|
|
4536
4702
|
stop();
|
|
4537
4703
|
onClearAll();
|
|
4538
4704
|
}, [stop, onClearAll]);
|
|
@@ -4560,7 +4726,7 @@ var ZoomOutButton = ({
|
|
|
4560
4726
|
};
|
|
4561
4727
|
|
|
4562
4728
|
// src/components/ContextualControls.tsx
|
|
4563
|
-
var
|
|
4729
|
+
var import_react38 = require("react");
|
|
4564
4730
|
var import_ui_components5 = require("@waveform-playlist/ui-components");
|
|
4565
4731
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
4566
4732
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -4593,13 +4759,13 @@ var PositionDisplay = import_styled_components3.default.span`
|
|
|
4593
4759
|
`;
|
|
4594
4760
|
var AudioPosition = ({ className }) => {
|
|
4595
4761
|
var _a;
|
|
4596
|
-
const timeRef = (0,
|
|
4762
|
+
const timeRef = (0, import_react38.useRef)(null);
|
|
4597
4763
|
const { currentTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
4598
4764
|
const { isPlaying } = useIsPlaying();
|
|
4599
4765
|
useCurrentTime();
|
|
4600
4766
|
const { timeFormat: format } = usePlaylistSettings();
|
|
4601
|
-
const id = (0,
|
|
4602
|
-
(0,
|
|
4767
|
+
const id = (0, import_react38.useId)();
|
|
4768
|
+
(0, import_react38.useEffect)(() => {
|
|
4603
4769
|
if (isPlaying) {
|
|
4604
4770
|
registerFrameCallback(id, ({ time }) => {
|
|
4605
4771
|
if (timeRef.current) {
|
|
@@ -4609,7 +4775,7 @@ var AudioPosition = ({ className }) => {
|
|
|
4609
4775
|
}
|
|
4610
4776
|
return () => unregisterFrameCallback(id);
|
|
4611
4777
|
}, [id, isPlaying, format, registerFrameCallback, unregisterFrameCallback]);
|
|
4612
|
-
(0,
|
|
4778
|
+
(0, import_react38.useEffect)(() => {
|
|
4613
4779
|
var _a2;
|
|
4614
4780
|
if (!isPlaying && timeRef.current) {
|
|
4615
4781
|
timeRef.current.textContent = (0, import_ui_components5.formatTime)((_a2 = currentTimeRef.current) != null ? _a2 : 0, format);
|
|
@@ -4661,9 +4827,9 @@ var AutomaticScrollCheckbox = ({ className }) => {
|
|
|
4661
4827
|
};
|
|
4662
4828
|
|
|
4663
4829
|
// src/components/WaveformRoot.tsx
|
|
4664
|
-
var
|
|
4830
|
+
var import_react60 = require("react");
|
|
4665
4831
|
var import_react_dom2 = require("react-dom");
|
|
4666
|
-
var
|
|
4832
|
+
var import_ui_components15 = require("@waveform-playlist/ui-components");
|
|
4667
4833
|
|
|
4668
4834
|
// src/utils/trackOrderPreview.ts
|
|
4669
4835
|
function applyTrackOrderPreview(tracks, preview) {
|
|
@@ -4699,10 +4865,10 @@ function trackIdAtOffset(orderedIds, layout, heightById, y) {
|
|
|
4699
4865
|
}
|
|
4700
4866
|
|
|
4701
4867
|
// src/hooks/useTrailingActive.ts
|
|
4702
|
-
var
|
|
4868
|
+
var import_react39 = require("react");
|
|
4703
4869
|
function useTrailingActive(active, trailingMs) {
|
|
4704
|
-
const [trailing, setTrailing] = (0,
|
|
4705
|
-
(0,
|
|
4870
|
+
const [trailing, setTrailing] = (0, import_react39.useState)(active);
|
|
4871
|
+
(0, import_react39.useEffect)(() => {
|
|
4706
4872
|
if (active) {
|
|
4707
4873
|
setTrailing(true);
|
|
4708
4874
|
return void 0;
|
|
@@ -4714,7 +4880,7 @@ function useTrailingActive(active, trailingMs) {
|
|
|
4714
4880
|
}
|
|
4715
4881
|
|
|
4716
4882
|
// src/hooks/useRecordingLayout.ts
|
|
4717
|
-
var
|
|
4883
|
+
var import_react40 = require("react");
|
|
4718
4884
|
var RECORDING_EXTENT_STEP_SECONDS = 10;
|
|
4719
4885
|
function recordingDisplayEnd(takeEndSeconds) {
|
|
4720
4886
|
const step = RECORDING_EXTENT_STEP_SECONDS;
|
|
@@ -4723,31 +4889,31 @@ function recordingDisplayEnd(takeEndSeconds) {
|
|
|
4723
4889
|
var subscribeToNothing = () => () => {
|
|
4724
4890
|
};
|
|
4725
4891
|
function useRecordingLayout(progress, startSample, sampleRate) {
|
|
4726
|
-
const subscribe = (0,
|
|
4892
|
+
const subscribe = (0, import_react40.useCallback)(
|
|
4727
4893
|
(onChange) => progress ? progress.subscribe(onChange) : subscribeToNothing(),
|
|
4728
4894
|
[progress]
|
|
4729
4895
|
);
|
|
4730
|
-
const getChannelCount = (0,
|
|
4896
|
+
const getChannelCount = (0, import_react40.useCallback)(
|
|
4731
4897
|
() => progress ? progress.getSnapshot().peaks.length : 0,
|
|
4732
4898
|
[progress]
|
|
4733
4899
|
);
|
|
4734
|
-
const getDisplayEnd = (0,
|
|
4900
|
+
const getDisplayEnd = (0, import_react40.useCallback)(
|
|
4735
4901
|
() => progress && sampleRate > 0 ? recordingDisplayEnd(startSample / sampleRate + progress.getSnapshot().duration) : 0,
|
|
4736
4902
|
[progress, startSample, sampleRate]
|
|
4737
4903
|
);
|
|
4738
|
-
const channelCount = (0,
|
|
4739
|
-
const displayEndSeconds = (0,
|
|
4904
|
+
const channelCount = (0, import_react40.useSyncExternalStore)(subscribe, getChannelCount, getChannelCount);
|
|
4905
|
+
const displayEndSeconds = (0, import_react40.useSyncExternalStore)(subscribe, getDisplayEnd, getDisplayEnd);
|
|
4740
4906
|
return { channelCount, displayEndSeconds };
|
|
4741
4907
|
}
|
|
4742
4908
|
|
|
4743
4909
|
// src/hooks/useTrimPreviewView.ts
|
|
4744
|
-
var
|
|
4910
|
+
var import_react41 = require("react");
|
|
4745
4911
|
var TRIM_EXTENT_STEP_SECONDS = RECORDING_EXTENT_STEP_SECONDS;
|
|
4746
4912
|
var NO_UNSUBSCRIBE = () => {
|
|
4747
4913
|
};
|
|
4748
4914
|
var subscribeToNothing2 = () => NO_UNSUBSCRIBE;
|
|
4749
4915
|
function useSubscribe(source) {
|
|
4750
|
-
return (0,
|
|
4916
|
+
return (0, import_react41.useMemo)(
|
|
4751
4917
|
() => source ? (onChange) => source.subscribe(onChange) : subscribeToNothing2,
|
|
4752
4918
|
[source]
|
|
4753
4919
|
);
|
|
@@ -4758,13 +4924,13 @@ function usePreviewedClipPeaks(clip, trackId) {
|
|
|
4758
4924
|
const peaks = useTrimPreviewPeaksOptional();
|
|
4759
4925
|
const subscribe = useSubscribe(source);
|
|
4760
4926
|
const clipId = clip.clipId;
|
|
4761
|
-
const getSnapshot = (0,
|
|
4927
|
+
const getSnapshot = (0, import_react41.useCallback)(() => {
|
|
4762
4928
|
var _a2;
|
|
4763
4929
|
const preview2 = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4764
4930
|
return preview2 !== null && preview2.clipId === clipId && preview2.trackId === trackId ? preview2 : null;
|
|
4765
4931
|
}, [source, clipId, trackId]);
|
|
4766
|
-
const preview = (0,
|
|
4767
|
-
return (0,
|
|
4932
|
+
const preview = (0, import_react41.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
4933
|
+
return (0, import_react41.useMemo)(
|
|
4768
4934
|
() => {
|
|
4769
4935
|
var _a2;
|
|
4770
4936
|
return preview && peaks ? (_a2 = peaks.peaksFor(preview)) != null ? _a2 : clip : clip;
|
|
@@ -4776,7 +4942,7 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4776
4942
|
var _a;
|
|
4777
4943
|
const source = (_a = useTrimPreviewOptional()) == null ? void 0 : _a.source;
|
|
4778
4944
|
const subscribe = useSubscribe(source);
|
|
4779
|
-
const getSnapshot = (0,
|
|
4945
|
+
const getSnapshot = (0, import_react41.useCallback)(() => {
|
|
4780
4946
|
var _a2;
|
|
4781
4947
|
const preview = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4782
4948
|
if (preview === null || !(sampleRate > 0)) return 0;
|
|
@@ -4784,21 +4950,21 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4784
4950
|
if (endSeconds <= durationSeconds) return 0;
|
|
4785
4951
|
return Math.ceil(endSeconds / TRIM_EXTENT_STEP_SECONDS) * TRIM_EXTENT_STEP_SECONDS;
|
|
4786
4952
|
}, [source, sampleRate, durationSeconds]);
|
|
4787
|
-
return (0,
|
|
4953
|
+
return (0, import_react41.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
4788
4954
|
}
|
|
4789
4955
|
|
|
4790
4956
|
// src/components/WaveformRoot.tsx
|
|
4791
|
-
var
|
|
4957
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
4792
4958
|
|
|
4793
4959
|
// src/SpectrogramIntegrationContext.tsx
|
|
4794
|
-
var
|
|
4795
|
-
var SpectrogramIntegrationContext = (0,
|
|
4960
|
+
var import_react42 = require("react");
|
|
4961
|
+
var SpectrogramIntegrationContext = (0, import_react42.createContext)(null);
|
|
4796
4962
|
var SpectrogramIntegrationProvider = SpectrogramIntegrationContext.Provider;
|
|
4797
4963
|
function useSpectrogramIntegration() {
|
|
4798
|
-
const context = (0,
|
|
4964
|
+
const context = (0, import_react42.use)(SpectrogramIntegrationContext);
|
|
4799
4965
|
if (!context) {
|
|
4800
4966
|
throw new Error(
|
|
4801
|
-
"useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram and wrap your app with <SpectrogramProvider>."
|
|
4967
|
+
"useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram (" + installCommand("@waveform-playlist/spectrogram") + ") and wrap your app with <SpectrogramProvider>."
|
|
4802
4968
|
);
|
|
4803
4969
|
}
|
|
4804
4970
|
return context;
|
|
@@ -4830,6 +4996,7 @@ var TrackRowPositioner = import_styled_components4.default.div.attrs((props) =>
|
|
|
4830
4996
|
transition: none;
|
|
4831
4997
|
}
|
|
4832
4998
|
`;
|
|
4999
|
+
var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
|
|
4833
5000
|
var ControlSlot = import_styled_components4.default.div.attrs((props) => ({
|
|
4834
5001
|
style: {
|
|
4835
5002
|
height: `${props.$height}px`,
|
|
@@ -4848,6 +5015,7 @@ var ControlSlot = import_styled_components4.default.div.attrs((props) => ({
|
|
|
4848
5015
|
transition: background 0.15s ease-in-out;
|
|
4849
5016
|
}
|
|
4850
5017
|
${(props) => props.$isSelected && `background: ${props.theme.selectedTrackControlsBackground};`}
|
|
5018
|
+
${(props) => props.$isDragSource && `background: ${props.theme.selectedTrackControlsBackground}; box-shadow: ${DRAG_SOURCE_SHADOW};`}
|
|
4851
5019
|
`;
|
|
4852
5020
|
function getTrackChannelCount(trackClipPeaks, recordingChannels) {
|
|
4853
5021
|
const clipChannels = trackClipPeaks.length > 0 ? Math.max(1, ...trackClipPeaks.map((clip) => clip.peaks.data.length)) : 1;
|
|
@@ -4855,15 +5023,15 @@ function getTrackChannelCount(trackClipPeaks, recordingChannels) {
|
|
|
4855
5023
|
}
|
|
4856
5024
|
|
|
4857
5025
|
// src/components/waveformFrame.tsx
|
|
4858
|
-
var
|
|
4859
|
-
var
|
|
5026
|
+
var import_react59 = __toESM(require("react"));
|
|
5027
|
+
var import_ui_components14 = require("@waveform-playlist/ui-components");
|
|
4860
5028
|
|
|
4861
5029
|
// src/hooks/useSelectionDrag.ts
|
|
4862
|
-
var
|
|
5030
|
+
var import_react44 = require("react");
|
|
4863
5031
|
var import_core9 = require("@waveform-playlist/core");
|
|
4864
5032
|
|
|
4865
5033
|
// src/hooks/useWindowDrag.ts
|
|
4866
|
-
var
|
|
5034
|
+
var import_react43 = require("react");
|
|
4867
5035
|
var activeDrags = 0;
|
|
4868
5036
|
var userSelectBeforeDrags = "";
|
|
4869
5037
|
var webkitUserSelectBeforeDrags = "";
|
|
@@ -4885,11 +5053,11 @@ function suspendTextSelection() {
|
|
|
4885
5053
|
};
|
|
4886
5054
|
}
|
|
4887
5055
|
function useWindowDrag(active, onMove, onEnd) {
|
|
4888
|
-
const callbacksRef = (0,
|
|
4889
|
-
(0,
|
|
5056
|
+
const callbacksRef = (0, import_react43.useRef)({ onMove, onEnd });
|
|
5057
|
+
(0, import_react43.useLayoutEffect)(() => {
|
|
4890
5058
|
callbacksRef.current = { onMove, onEnd };
|
|
4891
5059
|
});
|
|
4892
|
-
(0,
|
|
5060
|
+
(0, import_react43.useEffect)(() => {
|
|
4893
5061
|
if (!active) return;
|
|
4894
5062
|
const move = (event) => {
|
|
4895
5063
|
if ((event.buttons & 1) === 0) {
|
|
@@ -4922,15 +5090,15 @@ function clampedOffsetX(element, clientX) {
|
|
|
4922
5090
|
}
|
|
4923
5091
|
|
|
4924
5092
|
// src/hooks/useSelectionDrag.ts
|
|
4925
|
-
var SelectionPreviewContext = (0,
|
|
5093
|
+
var SelectionPreviewContext = (0, import_react44.createContext)(
|
|
4926
5094
|
null
|
|
4927
5095
|
);
|
|
4928
5096
|
var MIN_RANGE_SECONDS = 0.1;
|
|
4929
|
-
var AutomaticScrollFlag = (0,
|
|
5097
|
+
var AutomaticScrollFlag = (0, import_react44.memo)(function AutomaticScrollFlag2({
|
|
4930
5098
|
flagRef
|
|
4931
5099
|
}) {
|
|
4932
5100
|
const { isAutomaticScroll } = usePlaylistSettings();
|
|
4933
|
-
(0,
|
|
5101
|
+
(0, import_react44.useLayoutEffect)(() => {
|
|
4934
5102
|
flagRef.current = isAutomaticScroll;
|
|
4935
5103
|
});
|
|
4936
5104
|
return null;
|
|
@@ -4943,12 +5111,12 @@ function useSelectionDrag({
|
|
|
4943
5111
|
}) {
|
|
4944
5112
|
const { isPlaying } = useIsPlaying();
|
|
4945
5113
|
const { setSelection } = usePlaybackControls();
|
|
4946
|
-
const [isSelecting, setIsSelecting] = (0,
|
|
4947
|
-
const automaticScrollRef = (0,
|
|
4948
|
-
const previewHandle = (0,
|
|
4949
|
-
const pressTimeRef = (0,
|
|
4950
|
-
const wroteSelectionRef = (0,
|
|
4951
|
-
const dragElementRef = (0,
|
|
5114
|
+
const [isSelecting, setIsSelecting] = (0, import_react44.useState)(false);
|
|
5115
|
+
const automaticScrollRef = (0, import_react44.useRef)(false);
|
|
5116
|
+
const previewHandle = (0, import_react44.useMemo)(() => (0, import_core9.createValueSource)(null), []);
|
|
5117
|
+
const pressTimeRef = (0, import_react44.useRef)(0);
|
|
5118
|
+
const wroteSelectionRef = (0, import_react44.useRef)(false);
|
|
5119
|
+
const dragElementRef = (0, import_react44.useRef)(null);
|
|
4952
5120
|
const timeAt = (clientX) => {
|
|
4953
5121
|
const element = dragElementRef.current;
|
|
4954
5122
|
const x = element ? clampedOffsetX(element, clientX) : null;
|
|
@@ -5016,54 +5184,54 @@ function useSelectionDrag({
|
|
|
5016
5184
|
}
|
|
5017
5185
|
|
|
5018
5186
|
// src/components/waveformLayoutContext.ts
|
|
5019
|
-
var
|
|
5020
|
-
var WaveformPartPlaceContext = (0,
|
|
5021
|
-
var RootSeesRecordingPreviewContext = (0,
|
|
5022
|
-
var WaveformExtentContext = (0,
|
|
5023
|
-
var WaveformRowsContext = (0,
|
|
5187
|
+
var import_react45 = require("react");
|
|
5188
|
+
var WaveformPartPlaceContext = (0, import_react45.createContext)("tracks");
|
|
5189
|
+
var RootSeesRecordingPreviewContext = (0, import_react45.createContext)(false);
|
|
5190
|
+
var WaveformExtentContext = (0, import_react45.createContext)(null);
|
|
5191
|
+
var WaveformRowsContext = (0, import_react45.createContext)(null);
|
|
5024
5192
|
function required(value, part) {
|
|
5025
5193
|
if (value === null) {
|
|
5026
5194
|
throw new Error(`${part} must be rendered inside the waveform root`);
|
|
5027
5195
|
}
|
|
5028
5196
|
return value;
|
|
5029
5197
|
}
|
|
5030
|
-
var useWaveformExtent = (part) => required((0,
|
|
5031
|
-
var useWaveformRows = (part) => required((0,
|
|
5198
|
+
var useWaveformExtent = (part) => required((0, import_react45.use)(WaveformExtentContext), part);
|
|
5199
|
+
var useWaveformRows = (part) => required((0, import_react45.use)(WaveformRowsContext), part);
|
|
5032
5200
|
|
|
5033
5201
|
// src/components/waveformParts.tsx
|
|
5034
|
-
var
|
|
5035
|
-
var
|
|
5202
|
+
var import_react58 = __toESM(require("react"));
|
|
5203
|
+
var import_ui_components13 = require("@waveform-playlist/ui-components");
|
|
5036
5204
|
|
|
5037
5205
|
// src/components/TrackRows.tsx
|
|
5038
|
-
var
|
|
5206
|
+
var import_react48 = __toESM(require("react"));
|
|
5039
5207
|
var import_ui_components7 = require("@waveform-playlist/ui-components");
|
|
5040
5208
|
var import_core11 = require("@waveform-playlist/core");
|
|
5041
5209
|
|
|
5042
5210
|
// src/contexts/ClipInteractionContext.tsx
|
|
5043
|
-
var
|
|
5211
|
+
var import_react46 = require("react");
|
|
5044
5212
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
5045
5213
|
var NO_CLIP_INTERACTION = { enabled: false, touchOptimized: false };
|
|
5046
|
-
var ClipInteractionContext = (0,
|
|
5214
|
+
var ClipInteractionContext = (0, import_react46.createContext)(NO_CLIP_INTERACTION);
|
|
5047
5215
|
var ClipInteractionOptions = ({
|
|
5048
5216
|
enabled: enabledProp,
|
|
5049
5217
|
touchOptimized: touchOptimizedProp,
|
|
5050
5218
|
children
|
|
5051
5219
|
}) => {
|
|
5052
|
-
const inherited = (0,
|
|
5220
|
+
const inherited = (0, import_react46.use)(ClipInteractionContext);
|
|
5053
5221
|
const enabled = enabledProp != null ? enabledProp : inherited.enabled;
|
|
5054
5222
|
const touchOptimized = touchOptimizedProp != null ? touchOptimizedProp : inherited.touchOptimized;
|
|
5055
|
-
const value = (0,
|
|
5223
|
+
const value = (0, import_react46.useMemo)(() => ({ enabled, touchOptimized }), [enabled, touchOptimized]);
|
|
5056
5224
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClipInteractionContext, { value, children });
|
|
5057
5225
|
};
|
|
5058
5226
|
function useClipInteraction() {
|
|
5059
|
-
return (0,
|
|
5227
|
+
return (0, import_react46.use)(ClipInteractionContext);
|
|
5060
5228
|
}
|
|
5061
5229
|
function useClipInteractionEnabled() {
|
|
5062
|
-
return (0,
|
|
5230
|
+
return (0, import_react46.use)(ClipInteractionContext).enabled;
|
|
5063
5231
|
}
|
|
5064
5232
|
|
|
5065
5233
|
// src/components/ChannelWithProgress.tsx
|
|
5066
|
-
var
|
|
5234
|
+
var import_react47 = require("react");
|
|
5067
5235
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
5068
5236
|
var import_core10 = require("@waveform-playlist/core");
|
|
5069
5237
|
var import_ui_components6 = require("@waveform-playlist/ui-components");
|
|
@@ -5120,8 +5288,8 @@ var ClipProgress = ({
|
|
|
5120
5288
|
height,
|
|
5121
5289
|
top
|
|
5122
5290
|
}) => {
|
|
5123
|
-
const progressRef = (0,
|
|
5124
|
-
const callbackId = (0,
|
|
5291
|
+
const progressRef = (0, import_react47.useRef)(null);
|
|
5292
|
+
const callbackId = (0, import_react47.useId)();
|
|
5125
5293
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
5126
5294
|
const { isPlaying } = useIsPlaying();
|
|
5127
5295
|
useCurrentTime();
|
|
@@ -5132,7 +5300,7 @@ var ClipProgress = ({
|
|
|
5132
5300
|
clipDurationSamples,
|
|
5133
5301
|
samplesPerPixel
|
|
5134
5302
|
);
|
|
5135
|
-
(0,
|
|
5303
|
+
(0, import_react47.useEffect)(() => {
|
|
5136
5304
|
if (isPlaying) {
|
|
5137
5305
|
registerFrameCallback(callbackId, ({ visualTime, sampleRate: sr }) => {
|
|
5138
5306
|
if (progressRef.current) {
|
|
@@ -5150,7 +5318,7 @@ var ClipProgress = ({
|
|
|
5150
5318
|
registerFrameCallback,
|
|
5151
5319
|
unregisterFrameCallback
|
|
5152
5320
|
]);
|
|
5153
|
-
(0,
|
|
5321
|
+
(0, import_react47.useEffect)(() => {
|
|
5154
5322
|
var _a, _b;
|
|
5155
5323
|
if (!isPlaying && progressRef.current) {
|
|
5156
5324
|
const currentTime = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -5252,8 +5420,8 @@ var ChannelWithProgress = (_a) => {
|
|
|
5252
5420
|
|
|
5253
5421
|
// src/components/TrackRows.tsx
|
|
5254
5422
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
5255
|
-
var ClipDisplayContext = (0,
|
|
5256
|
-
var ClipView =
|
|
5423
|
+
var ClipDisplayContext = (0, import_react48.createContext)(null);
|
|
5424
|
+
var ClipView = import_react48.default.memo(function ClipView2({
|
|
5257
5425
|
clip: committedClip,
|
|
5258
5426
|
trackId,
|
|
5259
5427
|
trackIndex,
|
|
@@ -5270,13 +5438,13 @@ var ClipView = import_react46.default.memo(function ClipView2({
|
|
|
5270
5438
|
selectTrack,
|
|
5271
5439
|
registerSpectrogramCanvas,
|
|
5272
5440
|
unregisterSpectrogramCanvas
|
|
5273
|
-
} = (0,
|
|
5441
|
+
} = (0, import_react48.use)(ClipDisplayContext);
|
|
5274
5442
|
const { enabled: interactiveClips, touchOptimized } = useClipInteraction();
|
|
5275
5443
|
const clip = usePreviewedClipPeaks(committedClip, trackId);
|
|
5276
5444
|
const peaksData = clip.peaks;
|
|
5277
5445
|
const width = peaksData.length;
|
|
5278
5446
|
const drawsBody = clip.isPlaceholder && width === 0;
|
|
5279
|
-
const handleMouseDown = (0,
|
|
5447
|
+
const handleMouseDown = (0, import_react48.useCallback)(
|
|
5280
5448
|
(e) => {
|
|
5281
5449
|
const target = e.target;
|
|
5282
5450
|
if (target.closest('[role="button"][aria-roledescription="draggable"]')) {
|
|
@@ -5354,9 +5522,9 @@ var RecordingPreviewClip = ({
|
|
|
5354
5522
|
var _a;
|
|
5355
5523
|
const { getLookAhead, getOutputLatency } = useEngineRefs();
|
|
5356
5524
|
const source = recordingState.progress;
|
|
5357
|
-
const subscribe = (0,
|
|
5358
|
-
const getSnapshot = (0,
|
|
5359
|
-
const progress = (0,
|
|
5525
|
+
const subscribe = (0, import_react48.useCallback)((onChange) => source.subscribe(onChange), [source]);
|
|
5526
|
+
const getSnapshot = (0, import_react48.useCallback)(() => source.getSnapshot(), [source]);
|
|
5527
|
+
const progress = (0, import_react48.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
5360
5528
|
const durationSamples = Math.floor(progress.duration * sampleRate);
|
|
5361
5529
|
const latencyOffsetSamples = (0, import_core11.resolveRecordingOffsetSamples)({
|
|
5362
5530
|
overrideSeconds: recordingState.latencyOffset,
|
|
@@ -5401,7 +5569,7 @@ var RecordingPreviewClip = ({
|
|
|
5401
5569
|
}
|
|
5402
5570
|
);
|
|
5403
5571
|
};
|
|
5404
|
-
var TrackRow =
|
|
5572
|
+
var TrackRow = import_react48.default.memo(function TrackRow2({
|
|
5405
5573
|
trackId,
|
|
5406
5574
|
trackIndex,
|
|
5407
5575
|
trackClipPeaks,
|
|
@@ -5515,13 +5683,13 @@ function scanTracksParts(children) {
|
|
|
5515
5683
|
recordingState: void 0
|
|
5516
5684
|
};
|
|
5517
5685
|
const visit = (node) => {
|
|
5518
|
-
|
|
5519
|
-
if (!
|
|
5686
|
+
import_react48.default.Children.forEach(node, (child) => {
|
|
5687
|
+
if (!import_react48.default.isValidElement(child)) return;
|
|
5520
5688
|
if (child.type === WaveformClipHeaders) found.showClipHeaders = true;
|
|
5521
5689
|
else if (child.type === WaveformFades) found.showFades = true;
|
|
5522
5690
|
else if (child.type === WaveformRecordingPreview) {
|
|
5523
5691
|
found.recordingState = child.props.recordingState;
|
|
5524
|
-
} else if (child.type ===
|
|
5692
|
+
} else if (child.type === import_react48.default.Fragment) {
|
|
5525
5693
|
visit(child.props.children);
|
|
5526
5694
|
} else {
|
|
5527
5695
|
warnMisplacedPart(
|
|
@@ -5540,8 +5708,8 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5540
5708
|
const { sampleRate, mono } = usePlaylistView();
|
|
5541
5709
|
const { waveHeight } = (0, import_ui_components7.usePlaylistInfo)();
|
|
5542
5710
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
5543
|
-
const spectrogram = (0,
|
|
5544
|
-
const rootSeesRecordingPreview = (0,
|
|
5711
|
+
const spectrogram = (0, import_react48.use)(SpectrogramIntegrationContext);
|
|
5712
|
+
const rootSeesRecordingPreview = (0, import_react48.use)(RootSeesRecordingPreviewContext);
|
|
5545
5713
|
const scanned = scanTracksParts(children);
|
|
5546
5714
|
const { showFades, recordingState } = scanned;
|
|
5547
5715
|
const {
|
|
@@ -5566,7 +5734,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5566
5734
|
const { selectTrack } = rows;
|
|
5567
5735
|
const registerSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.registerSpectrogramCanvas;
|
|
5568
5736
|
const unregisterSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.unregisterSpectrogramCanvas;
|
|
5569
|
-
const clipDisplay = (0,
|
|
5737
|
+
const clipDisplay = (0, import_react48.useMemo)(
|
|
5570
5738
|
() => ({
|
|
5571
5739
|
gainScaledWaveforms: gainScaled,
|
|
5572
5740
|
showFades,
|
|
@@ -5580,8 +5748,8 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5580
5748
|
var _a, _b;
|
|
5581
5749
|
const track = rowList[trackIndex];
|
|
5582
5750
|
if (!track) return null;
|
|
5583
|
-
const
|
|
5584
|
-
const recordingChannels =
|
|
5751
|
+
const isRecordingTrack = (recordingState == null ? void 0 : recordingState.isRecording) === true && recordingState.trackId === track.id;
|
|
5752
|
+
const recordingChannels = isRecordingTrack ? recordingChannelCount : 0;
|
|
5585
5753
|
const helpers = spectrogramHelpersById.get(track.id);
|
|
5586
5754
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5587
5755
|
TrackRow,
|
|
@@ -5599,7 +5767,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5599
5767
|
numChannels: getTrackChannelCount(trackClipPeaks, recordingChannels),
|
|
5600
5768
|
waveHeight,
|
|
5601
5769
|
mono,
|
|
5602
|
-
recordingState:
|
|
5770
|
+
recordingState: isRecordingTrack ? recordingState : void 0,
|
|
5603
5771
|
spectrogramConfig: helpers == null ? void 0 : helpers.config,
|
|
5604
5772
|
frequencyScaleFn: helpers == null ? void 0 : helpers.frequencyScaleFn,
|
|
5605
5773
|
samplesPerPixel,
|
|
@@ -5612,23 +5780,23 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5612
5780
|
};
|
|
5613
5781
|
|
|
5614
5782
|
// src/components/TrackControlsColumn.tsx
|
|
5615
|
-
var
|
|
5616
|
-
var import_ui_components10 = require("@waveform-playlist/ui-components");
|
|
5783
|
+
var import_react54 = __toESM(require("react"));
|
|
5617
5784
|
|
|
5618
5785
|
// src/components/DefaultTrackControls.tsx
|
|
5619
|
-
var
|
|
5786
|
+
var import_react52 = __toESM(require("react"));
|
|
5620
5787
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
5621
5788
|
var import_ui_components9 = require("@waveform-playlist/ui-components");
|
|
5622
5789
|
|
|
5623
5790
|
// src/components/TrackControlPieces.tsx
|
|
5624
|
-
var
|
|
5791
|
+
var import_react51 = require("react");
|
|
5792
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
5625
5793
|
var import_ui_components8 = require("@waveform-playlist/ui-components");
|
|
5626
5794
|
|
|
5627
5795
|
// src/components/trackContext.ts
|
|
5628
|
-
var
|
|
5629
|
-
var TrackContext = (0,
|
|
5796
|
+
var import_react49 = require("react");
|
|
5797
|
+
var TrackContext = (0, import_react49.createContext)(null);
|
|
5630
5798
|
function useTrack() {
|
|
5631
|
-
const value = (0,
|
|
5799
|
+
const value = (0, import_react49.use)(TrackContext);
|
|
5632
5800
|
if (value === null) {
|
|
5633
5801
|
throw new Error(
|
|
5634
5802
|
"useTrack must be used within <WaveformTrackControls>: it reads the track whose control panel is being drawn, so the component that calls it (a built-in piece such as <TrackMuteButton />, or your own) must be among the children of <WaveformTrackControls>. Elsewhere, use usePlaylistMixer() and the setters of useEditorControls(), which take a track id."
|
|
@@ -5636,11 +5804,11 @@ function useTrack() {
|
|
|
5636
5804
|
}
|
|
5637
5805
|
return value;
|
|
5638
5806
|
}
|
|
5639
|
-
var TrackControlsSharedContext = (0,
|
|
5640
|
-
var TrackSlotWiringContext = (0,
|
|
5807
|
+
var TrackControlsSharedContext = (0, import_react49.createContext)(null);
|
|
5808
|
+
var TrackSlotWiringContext = (0, import_react49.createContext)(null);
|
|
5641
5809
|
|
|
5642
5810
|
// src/hooks/useTrackReorderHandle.ts
|
|
5643
|
-
var
|
|
5811
|
+
var import_react50 = require("react");
|
|
5644
5812
|
var import_sortable = require("@dnd-kit/react/sortable");
|
|
5645
5813
|
var import_modifiers = require("@dnd-kit/abstract/modifiers");
|
|
5646
5814
|
var import_dom2 = require("@dnd-kit/dom");
|
|
@@ -5673,11 +5841,11 @@ function createDragPopoverHealer(element) {
|
|
|
5673
5841
|
}
|
|
5674
5842
|
|
|
5675
5843
|
// src/hooks/useTrackReorderHandle.ts
|
|
5676
|
-
var MOVE_FEEDBACK = import_dom2.Feedback.configure({ feedback: "move" });
|
|
5844
|
+
var MOVE_FEEDBACK = import_dom2.Feedback.configure({ feedback: "move", dropAnimation: null });
|
|
5677
5845
|
var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
|
|
5678
5846
|
function useTrackReorderHandle() {
|
|
5679
5847
|
const { id, index } = useTrack();
|
|
5680
|
-
const wiring = (0,
|
|
5848
|
+
const wiring = (0, import_react50.use)(TrackSlotWiringContext);
|
|
5681
5849
|
const { ref, handleRef, isDragSource } = (0, import_sortable.useSortable)({
|
|
5682
5850
|
id: `track-reorder-${id}`,
|
|
5683
5851
|
index,
|
|
@@ -5700,10 +5868,9 @@ function useTrackReorderHandle() {
|
|
|
5700
5868
|
// `placeholder.replaceWith(element)` on drop) — confirmed via
|
|
5701
5869
|
// MutationObserver instrumentation to relocate the React-owned row 6
|
|
5702
5870
|
// times during a single one-slot drag, leaving its final parent/sibling
|
|
5703
|
-
// different from what React's fiber tree still believes.
|
|
5704
|
-
//
|
|
5705
|
-
//
|
|
5706
|
-
// for these rows. The placeholder splice is created only when
|
|
5871
|
+
// different from what React's fiber tree still believes. (Measured when
|
|
5872
|
+
// the registered element was one level inside the keyed slot, before
|
|
5873
|
+
// #796; not re-run with the slot itself.) The placeholder splice is created only when
|
|
5707
5874
|
// `feedback !== 'move'` (@dnd-kit/dom Feedback.ts) — 'move' keeps the
|
|
5708
5875
|
// dragged element in the live DOM (no clone/placeholder) while still
|
|
5709
5876
|
// running the *unconditional* `dragOperation.shape = ...` assignment.
|
|
@@ -5715,15 +5882,18 @@ function useTrackReorderHandle() {
|
|
|
5715
5882
|
// drag-based reordering silently never commits. Boundary trims don't hit
|
|
5716
5883
|
// this because they're plain useDraggable (no collision-based commit) —
|
|
5717
5884
|
// sortables need shape. `isDragSource` is a reactive signal, unaffected
|
|
5718
|
-
// either way.
|
|
5885
|
+
// either way. OptimisticSortingPlugin still moves the element during the
|
|
5886
|
+
// drag (`insertAdjacentElement` next to the item it is dragged over);
|
|
5887
|
+
// that is safe only because the element is the keyed slot (#796, below).
|
|
5888
|
+
// See browser/notes/track-controls-and-reorder.md "Track Reordering".
|
|
5719
5889
|
plugins: withMoveFeedback
|
|
5720
5890
|
});
|
|
5721
|
-
(0,
|
|
5891
|
+
(0, import_react50.useEffect)(() => {
|
|
5722
5892
|
if (!wiring) return void 0;
|
|
5723
5893
|
ref(wiring.elementRef.current);
|
|
5724
5894
|
return () => ref(null);
|
|
5725
5895
|
}, [ref, wiring]);
|
|
5726
|
-
(0,
|
|
5896
|
+
(0, import_react50.useEffect)(() => {
|
|
5727
5897
|
if (!wiring) return void 0;
|
|
5728
5898
|
const { handleCount } = wiring;
|
|
5729
5899
|
handleCount.current += 1;
|
|
@@ -5736,12 +5906,12 @@ function useTrackReorderHandle() {
|
|
|
5736
5906
|
handleCount.current -= 1;
|
|
5737
5907
|
};
|
|
5738
5908
|
}, [wiring]);
|
|
5739
|
-
(0,
|
|
5909
|
+
(0, import_react50.useEffect)(() => {
|
|
5740
5910
|
if (!wiring) return void 0;
|
|
5741
5911
|
wiring.setDragSource(isDragSource);
|
|
5742
5912
|
return () => wiring.setDragSource(false);
|
|
5743
5913
|
}, [isDragSource, wiring]);
|
|
5744
|
-
(0,
|
|
5914
|
+
(0, import_react50.useEffect)(() => {
|
|
5745
5915
|
const element = wiring == null ? void 0 : wiring.elementRef.current;
|
|
5746
5916
|
if (!isDragSource || !element) return void 0;
|
|
5747
5917
|
return createDragPopoverHealer(element);
|
|
@@ -5764,13 +5934,13 @@ var TrackName = () => {
|
|
|
5764
5934
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-track-name": "", style: NAME_STYLE, children: name });
|
|
5765
5935
|
};
|
|
5766
5936
|
var TrackMuteButton = () => {
|
|
5767
|
-
const { muted, setMuted,
|
|
5937
|
+
const { muted, setMuted, isRecording } = useTrack();
|
|
5768
5938
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
5769
5939
|
import_ui_components8.Button,
|
|
5770
5940
|
{
|
|
5771
5941
|
$variant: muted ? "danger" : "outline",
|
|
5772
5942
|
"aria-pressed": muted,
|
|
5773
|
-
disabled:
|
|
5943
|
+
disabled: isRecording,
|
|
5774
5944
|
onClick: () => setMuted(!muted),
|
|
5775
5945
|
children: "Mute"
|
|
5776
5946
|
}
|
|
@@ -5788,8 +5958,18 @@ var TrackSoloButton = () => {
|
|
|
5788
5958
|
}
|
|
5789
5959
|
);
|
|
5790
5960
|
};
|
|
5961
|
+
function useSliderGesture() {
|
|
5962
|
+
const [gesture] = (0, import_react51.useState)(import_core12.createMixerGesture);
|
|
5963
|
+
const ref = (0, import_react51.useRef)(null);
|
|
5964
|
+
(0, import_react51.useEffect)(() => {
|
|
5965
|
+
const input = ref.current;
|
|
5966
|
+
return input ? gesture.attach(input) : void 0;
|
|
5967
|
+
}, [gesture]);
|
|
5968
|
+
return { gesture, ref };
|
|
5969
|
+
}
|
|
5791
5970
|
var TrackVolumeSlider = () => {
|
|
5792
5971
|
const { volume, setVolume } = useTrack();
|
|
5972
|
+
const { gesture, ref } = useSliderGesture();
|
|
5793
5973
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui_components8.SliderWrapper, { children: [
|
|
5794
5974
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui_components8.VolumeDownIcon, {}),
|
|
5795
5975
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -5798,9 +5978,10 @@ var TrackVolumeSlider = () => {
|
|
|
5798
5978
|
min: "0",
|
|
5799
5979
|
max: "1",
|
|
5800
5980
|
step: "0.01",
|
|
5981
|
+
ref,
|
|
5801
5982
|
value: volume,
|
|
5802
5983
|
"aria-label": "Volume",
|
|
5803
|
-
onChange: (e) => setVolume(parseFloat(e.target.value))
|
|
5984
|
+
onChange: (e) => setVolume(parseFloat(e.target.value), { gesture: gesture.id })
|
|
5804
5985
|
}
|
|
5805
5986
|
),
|
|
5806
5987
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_ui_components8.VolumeUpIcon, {})
|
|
@@ -5808,6 +5989,7 @@ var TrackVolumeSlider = () => {
|
|
|
5808
5989
|
};
|
|
5809
5990
|
var TrackPanSlider = () => {
|
|
5810
5991
|
const { pan, setPan } = useTrack();
|
|
5992
|
+
const { gesture, ref } = useSliderGesture();
|
|
5811
5993
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_ui_components8.SliderWrapper, { children: [
|
|
5812
5994
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "L" }),
|
|
5813
5995
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
@@ -5816,9 +5998,10 @@ var TrackPanSlider = () => {
|
|
|
5816
5998
|
min: "-1",
|
|
5817
5999
|
max: "1",
|
|
5818
6000
|
step: "0.01",
|
|
6001
|
+
ref,
|
|
5819
6002
|
value: pan,
|
|
5820
6003
|
"aria-label": "Pan",
|
|
5821
|
-
onChange: (e) => setPan(parseFloat(e.target.value))
|
|
6004
|
+
onChange: (e) => setPan(parseFloat(e.target.value), { gesture: gesture.id })
|
|
5822
6005
|
}
|
|
5823
6006
|
),
|
|
5824
6007
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: "R" })
|
|
@@ -5826,7 +6009,7 @@ var TrackPanSlider = () => {
|
|
|
5826
6009
|
};
|
|
5827
6010
|
var TrackMenuButton = () => {
|
|
5828
6011
|
const { renderMode, hasSpectrogram, setRenderMode, openSpectrogramSettings } = useTrack();
|
|
5829
|
-
const shared = (0,
|
|
6012
|
+
const shared = (0, import_react51.use)(TrackControlsSharedContext);
|
|
5830
6013
|
if (!shared || !shared.menuAvailable || !hasSpectrogram) return null;
|
|
5831
6014
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
5832
6015
|
import_ui_components8.TrackMenu,
|
|
@@ -5906,10 +6089,10 @@ function DefaultTrackControlsImpl({ children }) {
|
|
|
5906
6089
|
children
|
|
5907
6090
|
] });
|
|
5908
6091
|
}
|
|
5909
|
-
var DefaultTrackControls =
|
|
6092
|
+
var DefaultTrackControls = import_react52.default.memo(DefaultTrackControlsImpl);
|
|
5910
6093
|
|
|
5911
6094
|
// src/utils/stableTemplate.ts
|
|
5912
|
-
var
|
|
6095
|
+
var import_react53 = require("react");
|
|
5913
6096
|
function sameStyle(a, b) {
|
|
5914
6097
|
if (Object.is(a, b)) return true;
|
|
5915
6098
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
@@ -5923,7 +6106,7 @@ function sameTemplate(a, b) {
|
|
|
5923
6106
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
5924
6107
|
return a.length === b.length && a.every((item, index) => sameTemplate(item, b[index]));
|
|
5925
6108
|
}
|
|
5926
|
-
if ((0,
|
|
6109
|
+
if ((0, import_react53.isValidElement)(a) && (0, import_react53.isValidElement)(b)) {
|
|
5927
6110
|
if (a.type !== b.type || a.key !== b.key) return false;
|
|
5928
6111
|
const one = a.props;
|
|
5929
6112
|
const other = b.props;
|
|
@@ -5939,7 +6122,7 @@ function sameTemplate(a, b) {
|
|
|
5939
6122
|
return false;
|
|
5940
6123
|
}
|
|
5941
6124
|
function useStableTemplate(template) {
|
|
5942
|
-
const kept = (0,
|
|
6125
|
+
const kept = (0, import_react53.useRef)(template);
|
|
5943
6126
|
if (!sameTemplate(kept.current, template)) {
|
|
5944
6127
|
kept.current = template;
|
|
5945
6128
|
}
|
|
@@ -5950,7 +6133,6 @@ function useStableTemplate(template) {
|
|
|
5950
6133
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
5951
6134
|
var DEFAULT_TRACK_CONTROLS_WIDTH = 200;
|
|
5952
6135
|
var DEFAULT_TEMPLATE = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DefaultTrackControls, {});
|
|
5953
|
-
var DRAG_SOURCE_SHADOW = "0 4px 12px rgba(0, 0, 0, 0.35)";
|
|
5954
6136
|
var SLOT_BODY_STYLE = { height: "100%" };
|
|
5955
6137
|
function TrackControlsSlotImpl({
|
|
5956
6138
|
trackId,
|
|
@@ -5966,7 +6148,7 @@ function TrackControlsSlotImpl({
|
|
|
5966
6148
|
isLast,
|
|
5967
6149
|
renderMode,
|
|
5968
6150
|
hasSpectrogram,
|
|
5969
|
-
|
|
6151
|
+
isRecording,
|
|
5970
6152
|
height,
|
|
5971
6153
|
top,
|
|
5972
6154
|
animate,
|
|
@@ -5980,16 +6162,15 @@ function TrackControlsSlotImpl({
|
|
|
5980
6162
|
reorderTrack,
|
|
5981
6163
|
setSelectedTrackId
|
|
5982
6164
|
} = useEditorControls();
|
|
5983
|
-
const
|
|
5984
|
-
const
|
|
5985
|
-
const indexRef = (0, import_react52.useRef)(index);
|
|
6165
|
+
const shared = (0, import_react54.use)(TrackControlsSharedContext);
|
|
6166
|
+
const indexRef = (0, import_react54.useRef)(index);
|
|
5986
6167
|
indexRef.current = index;
|
|
5987
|
-
const actions = (0,
|
|
6168
|
+
const actions = (0, import_react54.useMemo)(
|
|
5988
6169
|
() => ({
|
|
5989
|
-
setMuted: (value2) => setTrackMute(trackId, value2),
|
|
5990
|
-
setSoloed: (value2) => setTrackSolo(trackId, value2),
|
|
5991
|
-
setVolume: (value2) => setTrackVolume(trackId, value2),
|
|
5992
|
-
setPan: (value2) => setTrackPan(trackId, value2),
|
|
6170
|
+
setMuted: (value2, options) => setTrackMute(trackId, value2, options),
|
|
6171
|
+
setSoloed: (value2, options) => setTrackSolo(trackId, value2, options),
|
|
6172
|
+
setVolume: (value2, options) => setTrackVolume(trackId, value2, options),
|
|
6173
|
+
setPan: (value2, options) => setTrackPan(trackId, value2, options),
|
|
5993
6174
|
select: () => setSelectedTrackId(trackId),
|
|
5994
6175
|
// The engine clamps the target and ignores a move to the same place.
|
|
5995
6176
|
moveUp: () => reorderTrack(trackId, indexRef.current - 1),
|
|
@@ -6008,7 +6189,7 @@ function TrackControlsSlotImpl({
|
|
|
6008
6189
|
shared
|
|
6009
6190
|
]
|
|
6010
6191
|
);
|
|
6011
|
-
const value = (0,
|
|
6192
|
+
const value = (0, import_react54.useMemo)(
|
|
6012
6193
|
() => __spreadValues({
|
|
6013
6194
|
id: trackId,
|
|
6014
6195
|
kind,
|
|
@@ -6023,7 +6204,7 @@ function TrackControlsSlotImpl({
|
|
|
6023
6204
|
isFirst,
|
|
6024
6205
|
isLast,
|
|
6025
6206
|
hasSpectrogram,
|
|
6026
|
-
|
|
6207
|
+
isRecording
|
|
6027
6208
|
}, actions),
|
|
6028
6209
|
[
|
|
6029
6210
|
trackId,
|
|
@@ -6039,44 +6220,31 @@ function TrackControlsSlotImpl({
|
|
|
6039
6220
|
isFirst,
|
|
6040
6221
|
isLast,
|
|
6041
6222
|
hasSpectrogram,
|
|
6042
|
-
|
|
6223
|
+
isRecording,
|
|
6043
6224
|
actions
|
|
6044
6225
|
]
|
|
6045
6226
|
);
|
|
6046
|
-
const elementRef = (0,
|
|
6047
|
-
const [isDragSource, setDragSource] = (0,
|
|
6048
|
-
const wiring = (0,
|
|
6227
|
+
const elementRef = (0, import_react54.useRef)(null);
|
|
6228
|
+
const [isDragSource, setDragSource] = (0, import_react54.useState)(false);
|
|
6229
|
+
const wiring = (0, import_react54.useMemo)(
|
|
6049
6230
|
() => ({ elementRef, setDragSource, handleCount: { current: 0 } }),
|
|
6050
6231
|
[]
|
|
6051
6232
|
);
|
|
6052
6233
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6053
6234
|
ControlSlot,
|
|
6054
6235
|
{
|
|
6236
|
+
ref: elementRef,
|
|
6055
6237
|
$height: height,
|
|
6056
6238
|
$top: top,
|
|
6057
6239
|
$animate: animate,
|
|
6058
6240
|
$isSelected: isSelected,
|
|
6241
|
+
$isDragSource: isDragSource,
|
|
6059
6242
|
onClick: actions.select,
|
|
6060
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6061
|
-
"div",
|
|
6062
|
-
{
|
|
6063
|
-
ref: elementRef,
|
|
6064
|
-
"data-track-controls": trackId,
|
|
6065
|
-
style: isDragSource ? __spreadProps(__spreadValues({}, SLOT_BODY_STYLE), {
|
|
6066
|
-
boxShadow: DRAG_SOURCE_SHADOW,
|
|
6067
|
-
// Opaque background for the floating (top-layer, popover-based)
|
|
6068
|
-
// drag-source row — without it the row underneath shows through.
|
|
6069
|
-
// onDragStart selects the dragged track, so its slot always shows
|
|
6070
|
-
// the selected-track background while lifted.
|
|
6071
|
-
background: theme.selectedTrackControlsBackground
|
|
6072
|
-
}) : SLOT_BODY_STYLE,
|
|
6073
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackContext, { value, children: template }) })
|
|
6074
|
-
}
|
|
6075
|
-
)
|
|
6243
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "data-track-controls": trackId, style: SLOT_BODY_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackSlotWiringContext, { value: wiring, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackContext, { value, children: template }) }) })
|
|
6076
6244
|
}
|
|
6077
6245
|
);
|
|
6078
6246
|
}
|
|
6079
|
-
var TrackControlsSlot =
|
|
6247
|
+
var TrackControlsSlot = import_react54.default.memo(TrackControlsSlotImpl);
|
|
6080
6248
|
function WaveformTrackControlsImpl({ children }) {
|
|
6081
6249
|
const {
|
|
6082
6250
|
rows: tracks,
|
|
@@ -6084,23 +6252,23 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6084
6252
|
trackLayout,
|
|
6085
6253
|
trackHeightById,
|
|
6086
6254
|
animateTrackLayout,
|
|
6255
|
+
dragSourceTrackId,
|
|
6087
6256
|
setSettingsModalTrackId
|
|
6088
6257
|
} = useWaveformRows("The track controls");
|
|
6089
|
-
if ((0,
|
|
6258
|
+
if ((0, import_react54.use)(WaveformPartPlaceContext) !== "controls") {
|
|
6090
6259
|
warnMisplacedPart(
|
|
6091
6260
|
"<WaveformTrackControls> is drawn among the tracks, not in the controls column: the root recognises a part by its element type, so it must be a child of the root (a fragment is fine), not wrapped in another component."
|
|
6092
6261
|
);
|
|
6093
6262
|
}
|
|
6094
6263
|
const { selectedTrackId } = useSelectedTrackId();
|
|
6095
|
-
const {
|
|
6096
|
-
const
|
|
6097
|
-
const spectrogram = (0, import_react52.use)(SpectrogramIntegrationContext);
|
|
6264
|
+
const { recordingTrackId } = useRecordingTrack();
|
|
6265
|
+
const spectrogram = (0, import_react54.use)(SpectrogramIntegrationContext);
|
|
6098
6266
|
const { trackStates } = usePlaylistMixer();
|
|
6099
6267
|
const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
|
|
6100
|
-
const spectrogramRef = (0,
|
|
6268
|
+
const spectrogramRef = (0, import_react54.useRef)(spectrogram);
|
|
6101
6269
|
spectrogramRef.current = spectrogram;
|
|
6102
6270
|
const menuAvailable = Boolean(spectrogram == null ? void 0 : spectrogram.renderMenuItems);
|
|
6103
|
-
const shared = (0,
|
|
6271
|
+
const shared = (0, import_react54.useMemo)(
|
|
6104
6272
|
() => ({
|
|
6105
6273
|
menuAvailable,
|
|
6106
6274
|
menuItems: (args) => {
|
|
@@ -6120,49 +6288,42 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6120
6288
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TrackControlsSharedContext, { value: shared, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TracksLayout, { $height: trackLayout.totalHeight, children: tracks.map((track, trackIndex) => {
|
|
6121
6289
|
var _a, _b, _c;
|
|
6122
6290
|
const state = trackStates[trackIndex];
|
|
6123
|
-
return (
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
|
|
6147
|
-
top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
|
|
6148
|
-
animate: animateTrackLayout,
|
|
6149
|
-
template
|
|
6150
|
-
},
|
|
6151
|
-
`${track.id}-${trackReorderEpoch}`
|
|
6152
|
-
)
|
|
6291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6292
|
+
TrackControlsSlot,
|
|
6293
|
+
{
|
|
6294
|
+
trackId: track.id,
|
|
6295
|
+
index: trackIndex,
|
|
6296
|
+
kind: track.kind,
|
|
6297
|
+
name: state.name,
|
|
6298
|
+
muted: state.muted,
|
|
6299
|
+
soloed: state.soloed,
|
|
6300
|
+
volume: state.volume,
|
|
6301
|
+
pan: state.pan,
|
|
6302
|
+
isSelected: track.id === selectedTrackId,
|
|
6303
|
+
isFirst: trackIndex === 0,
|
|
6304
|
+
isLast: trackIndex === tracks.length - 1,
|
|
6305
|
+
renderMode: (_a = renderModeById.get(track.id)) != null ? _a : "waveform",
|
|
6306
|
+
hasSpectrogram: spectrogram !== null && track.kind !== "midi",
|
|
6307
|
+
isRecording: track.id === recordingTrackId,
|
|
6308
|
+
height: (_b = trackHeightById.get(track.id)) != null ? _b : 0,
|
|
6309
|
+
top: (_c = trackLayout.topById.get(track.id)) != null ? _c : 0,
|
|
6310
|
+
animate: animateTrackLayout && dragSourceTrackId !== null,
|
|
6311
|
+
template
|
|
6312
|
+
},
|
|
6313
|
+
track.id
|
|
6153
6314
|
);
|
|
6154
6315
|
}) }) });
|
|
6155
6316
|
}
|
|
6156
|
-
var WaveformTrackControls =
|
|
6317
|
+
var WaveformTrackControls = import_react54.default.memo(WaveformTrackControlsImpl);
|
|
6157
6318
|
|
|
6158
6319
|
// src/components/VisualizationOverlays.tsx
|
|
6159
|
-
var
|
|
6160
|
-
var
|
|
6320
|
+
var import_react56 = __toESM(require("react"));
|
|
6321
|
+
var import_ui_components11 = require("@waveform-playlist/ui-components");
|
|
6161
6322
|
|
|
6162
6323
|
// src/components/AnimatedPlayhead.tsx
|
|
6163
|
-
var
|
|
6324
|
+
var import_react55 = require("react");
|
|
6164
6325
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
6165
|
-
var
|
|
6326
|
+
var import_ui_components10 = require("@waveform-playlist/ui-components");
|
|
6166
6327
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
6167
6328
|
var PlayheadLine = import_styled_components7.default.div.attrs((props) => ({
|
|
6168
6329
|
style: {
|
|
@@ -6179,15 +6340,15 @@ var PlayheadLine = import_styled_components7.default.div.attrs((props) => ({
|
|
|
6179
6340
|
will-change: transform;
|
|
6180
6341
|
`;
|
|
6181
6342
|
var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
6182
|
-
const playheadRef = (0,
|
|
6183
|
-
const frameCallbackId = (0,
|
|
6343
|
+
const playheadRef = (0, import_react55.useRef)(null);
|
|
6344
|
+
const frameCallbackId = (0, import_react55.useId)();
|
|
6184
6345
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
6185
6346
|
const { isPlaying } = useIsPlaying();
|
|
6186
6347
|
useCurrentTime();
|
|
6187
6348
|
const { sampleRate } = usePlaylistView();
|
|
6188
|
-
const { progressBarWidth } = (0,
|
|
6349
|
+
const { progressBarWidth } = (0, import_ui_components10.usePlaylistInfo)();
|
|
6189
6350
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6190
|
-
(0,
|
|
6351
|
+
(0, import_react55.useEffect)(() => {
|
|
6191
6352
|
if (isPlaying) {
|
|
6192
6353
|
registerFrameCallback(
|
|
6193
6354
|
frameCallbackId,
|
|
@@ -6201,7 +6362,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6201
6362
|
}
|
|
6202
6363
|
return () => unregisterFrameCallback(frameCallbackId);
|
|
6203
6364
|
}, [isPlaying, frameCallbackId, registerFrameCallback, unregisterFrameCallback]);
|
|
6204
|
-
(0,
|
|
6365
|
+
(0, import_react55.useEffect)(() => {
|
|
6205
6366
|
var _a, _b;
|
|
6206
6367
|
if (!isPlaying && playheadRef.current) {
|
|
6207
6368
|
const time = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -6217,13 +6378,13 @@ var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
|
6217
6378
|
var subscribeToNothing3 = () => () => {
|
|
6218
6379
|
};
|
|
6219
6380
|
var noPreview = () => null;
|
|
6220
|
-
var WaveformSelection =
|
|
6221
|
-
const theme = (0,
|
|
6381
|
+
var WaveformSelection = import_react56.default.memo(function WaveformSelection2() {
|
|
6382
|
+
const theme = (0, import_ui_components11.useTheme)();
|
|
6222
6383
|
const { selectionStart, selectionEnd } = useSelection();
|
|
6223
6384
|
const { sampleRate } = usePlaylistView();
|
|
6224
6385
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6225
|
-
const previewSource = (0,
|
|
6226
|
-
const preview = (0,
|
|
6386
|
+
const previewSource = (0, import_react56.use)(SelectionPreviewContext);
|
|
6387
|
+
const preview = (0, import_react56.useSyncExternalStore)(
|
|
6227
6388
|
previewSource ? (onChange) => previewSource.subscribe(onChange) : subscribeToNothing3,
|
|
6228
6389
|
previewSource ? () => previewSource.getSnapshot() : noPreview,
|
|
6229
6390
|
previewSource ? () => previewSource.getSnapshot() : noPreview
|
|
@@ -6232,7 +6393,7 @@ var WaveformSelection = import_react54.default.memo(function WaveformSelection2(
|
|
|
6232
6393
|
const end = preview ? preview.end : Math.max(selectionStart, selectionEnd);
|
|
6233
6394
|
if (start === end) return null;
|
|
6234
6395
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6235
|
-
|
|
6396
|
+
import_ui_components11.Selection,
|
|
6236
6397
|
{
|
|
6237
6398
|
startPosition: start * sampleRate / samplesPerPixel,
|
|
6238
6399
|
endPosition: end * sampleRate / samplesPerPixel,
|
|
@@ -6257,7 +6418,7 @@ var CustomPlayhead = ({ renderPlayhead, color, samplesPerPixel, sampleRate }) =>
|
|
|
6257
6418
|
});
|
|
6258
6419
|
};
|
|
6259
6420
|
var WaveformPlayhead = ({ renderPlayhead }) => {
|
|
6260
|
-
const theme = (0,
|
|
6421
|
+
const theme = (0, import_ui_components11.useTheme)();
|
|
6261
6422
|
const { isPlaying } = useIsPlaying();
|
|
6262
6423
|
const { selectionStart, selectionEnd } = useSelection();
|
|
6263
6424
|
const { sampleRate } = usePlaylistView();
|
|
@@ -6273,21 +6434,21 @@ var WaveformPlayhead = ({ renderPlayhead }) => {
|
|
|
6273
6434
|
}
|
|
6274
6435
|
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AnimatedPlayhead, { color: theme.playheadColor });
|
|
6275
6436
|
};
|
|
6276
|
-
var WaveformLoopRegion =
|
|
6437
|
+
var WaveformLoopRegion = import_react56.default.memo(function WaveformLoopRegion2() {
|
|
6277
6438
|
const { tracksFullWidth: maxPosition } = useWaveformExtent("The loop region");
|
|
6278
|
-
if ((0,
|
|
6439
|
+
if ((0, import_react56.use)(WaveformPartPlaceContext) !== "timescale") {
|
|
6279
6440
|
warnMisplacedPart(
|
|
6280
6441
|
"<WaveformLoopRegion> is drawn among the tracks, not in the timescale strip: the root recognises a part by its element type, so it must be a child of the root (a fragment is fine), not wrapped in another component."
|
|
6281
6442
|
);
|
|
6282
6443
|
}
|
|
6283
|
-
const theme = (0,
|
|
6444
|
+
const theme = (0, import_ui_components11.useTheme)();
|
|
6284
6445
|
const { isLoopEnabled, loopStart, loopEnd } = useLoop();
|
|
6285
6446
|
const { setLoopRegion } = useEditorControls();
|
|
6286
6447
|
const { sampleRate } = usePlaylistView();
|
|
6287
6448
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6288
6449
|
if (!isLoopEnabled) return null;
|
|
6289
6450
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
6290
|
-
|
|
6451
|
+
import_ui_components11.TimescaleLoopRegion,
|
|
6291
6452
|
{
|
|
6292
6453
|
startPosition: Math.min(loopStart, loopEnd) * sampleRate / samplesPerPixel,
|
|
6293
6454
|
endPosition: Math.max(loopStart, loopEnd) * sampleRate / samplesPerPixel,
|
|
@@ -6305,11 +6466,11 @@ var WaveformLoopRegion = import_react54.default.memo(function WaveformLoopRegion
|
|
|
6305
6466
|
});
|
|
6306
6467
|
|
|
6307
6468
|
// src/components/WaveformViewOptions.tsx
|
|
6308
|
-
var
|
|
6309
|
-
var
|
|
6469
|
+
var import_react57 = require("react");
|
|
6470
|
+
var import_ui_components12 = require("@waveform-playlist/ui-components");
|
|
6310
6471
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
6311
6472
|
var NO_OPTIONS = {};
|
|
6312
|
-
var WaveformViewOptionsContext = (0,
|
|
6473
|
+
var WaveformViewOptionsContext = (0, import_react57.createContext)(NO_OPTIONS);
|
|
6313
6474
|
var WaveformViewOptions = ({
|
|
6314
6475
|
children,
|
|
6315
6476
|
waveHeight: ownWaveHeight,
|
|
@@ -6319,14 +6480,14 @@ var WaveformViewOptions = ({
|
|
|
6319
6480
|
progressBarWidth: ownProgressBarWidth,
|
|
6320
6481
|
fillViewport: ownFillViewport
|
|
6321
6482
|
}) => {
|
|
6322
|
-
const above = (0,
|
|
6483
|
+
const above = (0, import_react57.use)(WaveformViewOptionsContext);
|
|
6323
6484
|
const waveHeight = ownWaveHeight != null ? ownWaveHeight : above.waveHeight;
|
|
6324
6485
|
const barWidth = ownBarWidth != null ? ownBarWidth : above.barWidth;
|
|
6325
6486
|
const barGap = ownBarGap != null ? ownBarGap : above.barGap;
|
|
6326
6487
|
const roundedBars = ownRoundedBars != null ? ownRoundedBars : above.roundedBars;
|
|
6327
6488
|
const progressBarWidth = ownProgressBarWidth != null ? ownProgressBarWidth : above.progressBarWidth;
|
|
6328
6489
|
const fillViewport = ownFillViewport != null ? ownFillViewport : above.fillViewport;
|
|
6329
|
-
const value = (0,
|
|
6490
|
+
const value = (0, import_react57.useMemo)(
|
|
6330
6491
|
() => ({ waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport }),
|
|
6331
6492
|
[waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport]
|
|
6332
6493
|
);
|
|
@@ -6335,29 +6496,29 @@ var WaveformViewOptions = ({
|
|
|
6335
6496
|
var isPositive = (value) => value > 0;
|
|
6336
6497
|
function useResolvedViewOptions() {
|
|
6337
6498
|
var _a, _b, _c, _d, _e, _f;
|
|
6338
|
-
const options = (0,
|
|
6339
|
-
let waveHeight = (_a = options.waveHeight) != null ? _a :
|
|
6340
|
-
let barWidth = (_b = options.barWidth) != null ? _b :
|
|
6341
|
-
let barGap = (_c = options.barGap) != null ? _c :
|
|
6499
|
+
const options = (0, import_react57.use)(WaveformViewOptionsContext);
|
|
6500
|
+
let waveHeight = (_a = options.waveHeight) != null ? _a : import_ui_components12.DEFAULT_WAVE_HEIGHT;
|
|
6501
|
+
let barWidth = (_b = options.barWidth) != null ? _b : import_ui_components12.DEFAULT_BAR_WIDTH;
|
|
6502
|
+
let barGap = (_c = options.barGap) != null ? _c : import_ui_components12.DEFAULT_BAR_GAP;
|
|
6342
6503
|
const roundedBars = (_d = options.roundedBars) != null ? _d : false;
|
|
6343
6504
|
const fillViewport = (_e = options.fillViewport) != null ? _e : false;
|
|
6344
6505
|
if (!isPositive(waveHeight)) {
|
|
6345
6506
|
warnOnce(
|
|
6346
|
-
`<WaveformViewOptions waveHeight> must be a positive number of pixels: ${String(waveHeight)} is replaced by ${
|
|
6507
|
+
`<WaveformViewOptions waveHeight> must be a positive number of pixels: ${String(waveHeight)} is replaced by ${import_ui_components12.DEFAULT_WAVE_HEIGHT}.`
|
|
6347
6508
|
);
|
|
6348
|
-
waveHeight =
|
|
6509
|
+
waveHeight = import_ui_components12.DEFAULT_WAVE_HEIGHT;
|
|
6349
6510
|
}
|
|
6350
6511
|
if (!isPositive(barWidth)) {
|
|
6351
6512
|
warnOnce(
|
|
6352
|
-
`<WaveformViewOptions barWidth> must be a positive number of pixels: ${String(barWidth)} is replaced by ${
|
|
6513
|
+
`<WaveformViewOptions barWidth> must be a positive number of pixels: ${String(barWidth)} is replaced by ${import_ui_components12.DEFAULT_BAR_WIDTH}.`
|
|
6353
6514
|
);
|
|
6354
|
-
barWidth =
|
|
6515
|
+
barWidth = import_ui_components12.DEFAULT_BAR_WIDTH;
|
|
6355
6516
|
}
|
|
6356
6517
|
if (Number.isNaN(barGap)) {
|
|
6357
6518
|
warnOnce(
|
|
6358
|
-
`<WaveformViewOptions barGap> must be a number of pixels: ${String(barGap)} is replaced by ${
|
|
6519
|
+
`<WaveformViewOptions barGap> must be a number of pixels: ${String(barGap)} is replaced by ${import_ui_components12.DEFAULT_BAR_GAP}.`
|
|
6359
6520
|
);
|
|
6360
|
-
barGap =
|
|
6521
|
+
barGap = import_ui_components12.DEFAULT_BAR_GAP;
|
|
6361
6522
|
}
|
|
6362
6523
|
if (!(barWidth + barGap >= 1)) {
|
|
6363
6524
|
const raised = 1 - barWidth;
|
|
@@ -6379,16 +6540,16 @@ function useResolvedViewOptions() {
|
|
|
6379
6540
|
// src/components/waveformParts.tsx
|
|
6380
6541
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
6381
6542
|
var DEFAULT_TIMESCALE_HEIGHT = 30;
|
|
6382
|
-
var WaveformTimescale =
|
|
6543
|
+
var WaveformTimescale = import_react58.default.memo(function WaveformTimescale2({
|
|
6383
6544
|
renderTick
|
|
6384
6545
|
}) {
|
|
6385
6546
|
const { displayDuration } = useWaveformExtent("The timescale");
|
|
6386
|
-
if ((0,
|
|
6547
|
+
if ((0, import_react58.use)(WaveformPartPlaceContext) !== "timescale") {
|
|
6387
6548
|
warnMisplacedPart(
|
|
6388
6549
|
"<WaveformTimescale> is drawn among the tracks, not in the timescale strip: the root recognises a part by its element type, so it must be a child of the root (a fragment is fine), not wrapped in another component."
|
|
6389
6550
|
);
|
|
6390
6551
|
}
|
|
6391
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
6552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_ui_components13.SmartScale, { durationMs: displayDuration * 1e3, renderTick });
|
|
6392
6553
|
});
|
|
6393
6554
|
var TIMESCALE_PARTS = /* @__PURE__ */ new Set([WaveformTimescale, WaveformLoopRegion]);
|
|
6394
6555
|
var CONTROLS_PARTS = /* @__PURE__ */ new Set([WaveformTrackControls]);
|
|
@@ -6404,9 +6565,9 @@ function sortWaveformParts(children) {
|
|
|
6404
6565
|
let timescaleHeightGiven = false;
|
|
6405
6566
|
let tracksParts = 0;
|
|
6406
6567
|
const visit = (node) => {
|
|
6407
|
-
|
|
6408
|
-
if (
|
|
6409
|
-
if (child.type ===
|
|
6568
|
+
import_react58.default.Children.forEach(node, (child) => {
|
|
6569
|
+
if (import_react58.default.isValidElement(child)) {
|
|
6570
|
+
if (child.type === import_react58.default.Fragment) {
|
|
6410
6571
|
visit(child.props.children);
|
|
6411
6572
|
return;
|
|
6412
6573
|
}
|
|
@@ -6475,12 +6636,12 @@ var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
|
6475
6636
|
function keyedByKind(parts) {
|
|
6476
6637
|
const seen = { timescale: 0, loop: 0 };
|
|
6477
6638
|
return parts.map((part) => {
|
|
6478
|
-
const kind =
|
|
6479
|
-
return (0,
|
|
6639
|
+
const kind = import_react59.default.isValidElement(part) && part.type === WaveformTimescale ? "timescale" : "loop";
|
|
6640
|
+
return (0, import_react59.createElement)(import_react59.Fragment, { key: `${kind}-${seen[kind]++}` }, part);
|
|
6480
6641
|
});
|
|
6481
6642
|
}
|
|
6482
6643
|
function useWaveformParts(children) {
|
|
6483
|
-
return (0,
|
|
6644
|
+
return (0, import_react59.useMemo)(() => {
|
|
6484
6645
|
const sorted = sortWaveformParts(children);
|
|
6485
6646
|
return {
|
|
6486
6647
|
// One element per place. The tracks-area and controls parts are its
|
|
@@ -6488,9 +6649,9 @@ function useWaveformParts(children) {
|
|
|
6488
6649
|
// by kind (`keyedByKind`).
|
|
6489
6650
|
timescale: sorted.timescale.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "timescale", children: keyedByKind(sorted.timescale) }) : null,
|
|
6490
6651
|
controls: sorted.controls.length > 0 ? [
|
|
6491
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "controls", children: (0,
|
|
6652
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "controls", children: (0, import_react59.createElement)(import_react59.Fragment, null, ...sorted.controls) }, "controls")
|
|
6492
6653
|
] : void 0,
|
|
6493
|
-
content: (0,
|
|
6654
|
+
content: (0, import_react59.createElement)(import_react59.Fragment, null, ...sorted.content),
|
|
6494
6655
|
tracksOptions: sorted.tracksOptions,
|
|
6495
6656
|
controlsWidth: sorted.controlsWidth,
|
|
6496
6657
|
timescaleHeight: sorted.timescaleHeight
|
|
@@ -6510,13 +6671,13 @@ function useWaveformFrame({
|
|
|
6510
6671
|
onClickWhileStopped
|
|
6511
6672
|
}) {
|
|
6512
6673
|
var _a;
|
|
6513
|
-
const theme = (0,
|
|
6674
|
+
const theme = (0, import_ui_components14.useTheme)();
|
|
6514
6675
|
const { setScrollContainer } = usePlaybackControls();
|
|
6515
6676
|
const { sampleRate } = usePlaylistView();
|
|
6516
6677
|
const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
|
|
6517
6678
|
const timeScaleHeight = parts.timescaleHeight;
|
|
6518
6679
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6519
|
-
const handleScrollContainerRef = (0,
|
|
6680
|
+
const handleScrollContainerRef = (0, import_react59.useCallback)(
|
|
6520
6681
|
(element) => {
|
|
6521
6682
|
onScrollContainer == null ? void 0 : onScrollContainer(element);
|
|
6522
6683
|
setScrollContainer(element);
|
|
@@ -6530,7 +6691,7 @@ function useWaveformFrame({
|
|
|
6530
6691
|
preview: selectionPreview,
|
|
6531
6692
|
automaticScrollRef
|
|
6532
6693
|
} = useSelectionDrag({ samplesPerPixel, sampleRate, onPress, onClickWhileStopped });
|
|
6533
|
-
const playlistInfo = (0,
|
|
6694
|
+
const playlistInfo = (0, import_react59.useMemo)(
|
|
6534
6695
|
() => ({
|
|
6535
6696
|
samplesPerPixel,
|
|
6536
6697
|
sampleRate,
|
|
@@ -6552,22 +6713,22 @@ function useWaveformFrame({
|
|
|
6552
6713
|
progressBarWidth
|
|
6553
6714
|
]
|
|
6554
6715
|
);
|
|
6555
|
-
const extent = (0,
|
|
6716
|
+
const extent = (0, import_react59.useMemo)(
|
|
6556
6717
|
() => ({ displayDuration, tracksFullWidth }),
|
|
6557
6718
|
[displayDuration, tracksFullWidth]
|
|
6558
6719
|
);
|
|
6559
6720
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
6560
6721
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AutomaticScrollFlag, { flagRef: automaticScrollRef }),
|
|
6561
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6722
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_components14.PlaylistInfoContext, { value: playlistInfo, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformExtentContext, { value: extent, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformRowsContext, { value: rows, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6562
6723
|
RootSeesRecordingPreviewContext,
|
|
6563
6724
|
{
|
|
6564
6725
|
value: parts.tracksOptions.recordingState !== void 0,
|
|
6565
6726
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SelectionPreviewContext, { value: selectionPreview, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
6566
|
-
|
|
6727
|
+
import_ui_components14.Playlist,
|
|
6567
6728
|
{
|
|
6568
6729
|
className,
|
|
6569
6730
|
theme,
|
|
6570
|
-
backgroundColor: theme.playlistBackgroundColor || (0,
|
|
6731
|
+
backgroundColor: theme.playlistBackgroundColor || (0, import_ui_components14.waveformColorToCss)(theme.waveOutlineColor),
|
|
6571
6732
|
timescaleBackgroundColor: theme.timescaleBackgroundColor,
|
|
6572
6733
|
timescaleWidth: tracksFullWidth,
|
|
6573
6734
|
tracksWidth: tracksFullWidth,
|
|
@@ -6600,10 +6761,10 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6600
6761
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6601
6762
|
const { peaksDataArray, tracks, duration, isReady } = usePlaylistTimeline();
|
|
6602
6763
|
const { trackDragPreview } = useTrackReorderPreview();
|
|
6603
|
-
const spectrogram = (0,
|
|
6764
|
+
const spectrogram = (0, import_react60.use)(SpectrogramIntegrationContext);
|
|
6604
6765
|
const parts = useWaveformParts(children);
|
|
6605
6766
|
const { showClipHeaders, recordingState } = parts.tracksOptions;
|
|
6606
|
-
const spectrogramHelpersById = (0,
|
|
6767
|
+
const spectrogramHelpersById = (0, import_react60.useMemo)(() => {
|
|
6607
6768
|
const helpers = /* @__PURE__ */ new Map();
|
|
6608
6769
|
if (!spectrogram) return helpers;
|
|
6609
6770
|
tracks.forEach((track) => {
|
|
@@ -6624,7 +6785,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6624
6785
|
});
|
|
6625
6786
|
return helpers;
|
|
6626
6787
|
}, [tracks, spectrogram]);
|
|
6627
|
-
const renderModeById = (0,
|
|
6788
|
+
const renderModeById = (0, import_react60.useMemo)(() => {
|
|
6628
6789
|
const modes = /* @__PURE__ */ new Map();
|
|
6629
6790
|
tracks.forEach((track) => {
|
|
6630
6791
|
var _a2;
|
|
@@ -6644,12 +6805,12 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6644
6805
|
const recordingTrackId = (recordingState == null ? void 0 : recordingState.isRecording) ? recordingState.trackId : null;
|
|
6645
6806
|
const trimPreviewEnd = useTrimPreviewExtent(sampleRate, duration);
|
|
6646
6807
|
const recordingChannelCount = recordingProgress ? mono ? 1 : recordingLayout.channelCount : 0;
|
|
6647
|
-
const [settingsModalTrackId, setSettingsModalTrackId] = (0,
|
|
6648
|
-
const closeSettingsModal = (0,
|
|
6649
|
-
const [scrollContainerElement, setScrollContainerElement] = (0,
|
|
6808
|
+
const [settingsModalTrackId, setSettingsModalTrackId] = (0, import_react60.useState)(null);
|
|
6809
|
+
const closeSettingsModal = (0, import_react60.useCallback)(() => setSettingsModalTrackId(null), []);
|
|
6810
|
+
const [scrollContainerElement, setScrollContainerElement] = (0, import_react60.useState)(null);
|
|
6650
6811
|
const fillsContainer = indefinitePlayback || fillViewport;
|
|
6651
|
-
const [scrollContainerWidth, setScrollContainerWidth] = (0,
|
|
6652
|
-
(0,
|
|
6812
|
+
const [scrollContainerWidth, setScrollContainerWidth] = (0, import_react60.useState)(0);
|
|
6813
|
+
(0, import_react60.useLayoutEffect)(() => {
|
|
6653
6814
|
if (!fillsContainer || !scrollContainerElement) return;
|
|
6654
6815
|
const measure = () => setScrollContainerWidth(scrollContainerElement.clientWidth);
|
|
6655
6816
|
measure();
|
|
@@ -6658,7 +6819,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6658
6819
|
observer.observe(scrollContainerElement);
|
|
6659
6820
|
return () => observer.disconnect();
|
|
6660
6821
|
}, [fillsContainer, scrollContainerElement]);
|
|
6661
|
-
const placeholdersEndSeconds = (0,
|
|
6822
|
+
const placeholdersEndSeconds = (0, import_react60.useMemo)(() => placeholdersEnd(peaksDataArray), [peaksDataArray]);
|
|
6662
6823
|
let displayDuration = Math.max(
|
|
6663
6824
|
duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION,
|
|
6664
6825
|
placeholdersEndSeconds
|
|
@@ -6671,9 +6832,9 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6671
6832
|
displayDuration = Math.max(displayDuration, recordingLayout.displayEndSeconds);
|
|
6672
6833
|
}
|
|
6673
6834
|
displayDuration = Math.max(displayDuration, trimPreviewEnd);
|
|
6674
|
-
const tracksRef = (0,
|
|
6835
|
+
const tracksRef = (0, import_react60.useRef)(tracks);
|
|
6675
6836
|
tracksRef.current = tracks;
|
|
6676
|
-
const selectTrack = (0,
|
|
6837
|
+
const selectTrack = (0, import_react60.useCallback)(
|
|
6677
6838
|
(trackIndex) => {
|
|
6678
6839
|
const track = tracksRef.current[trackIndex];
|
|
6679
6840
|
if (track) {
|
|
@@ -6682,7 +6843,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6682
6843
|
},
|
|
6683
6844
|
[setSelectedTrackId]
|
|
6684
6845
|
);
|
|
6685
|
-
const trackHeightById = (0,
|
|
6846
|
+
const trackHeightById = (0, import_react60.useMemo)(() => {
|
|
6686
6847
|
const m = /* @__PURE__ */ new Map();
|
|
6687
6848
|
peaksDataArray.forEach((trackClipPeaks, trackIndex) => {
|
|
6688
6849
|
const track = tracks[trackIndex];
|
|
@@ -6691,7 +6852,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6691
6852
|
trackClipPeaks,
|
|
6692
6853
|
track.id === recordingTrackId ? recordingChannelCount : 0
|
|
6693
6854
|
);
|
|
6694
|
-
m.set(track.id, waveHeight * maxChannels + (showClipHeaders ?
|
|
6855
|
+
m.set(track.id, waveHeight * maxChannels + (showClipHeaders ? import_ui_components15.CLIP_HEADER_HEIGHT : 0));
|
|
6695
6856
|
});
|
|
6696
6857
|
return m;
|
|
6697
6858
|
}, [
|
|
@@ -6702,21 +6863,21 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6702
6863
|
waveHeight,
|
|
6703
6864
|
showClipHeaders
|
|
6704
6865
|
]);
|
|
6705
|
-
const displayOrderIds = (0,
|
|
6866
|
+
const displayOrderIds = (0, import_react60.useMemo)(
|
|
6706
6867
|
() => applyTrackOrderPreview(tracks, trackDragPreview).map((t) => t.id),
|
|
6707
6868
|
[tracks, trackDragPreview]
|
|
6708
6869
|
);
|
|
6709
|
-
const trackLayout = (0,
|
|
6870
|
+
const trackLayout = (0, import_react60.useMemo)(
|
|
6710
6871
|
() => computeTrackLayout(displayOrderIds, trackHeightById),
|
|
6711
6872
|
[displayOrderIds, trackHeightById]
|
|
6712
6873
|
);
|
|
6713
6874
|
const animateTrackLayout = useTrailingActive(trackDragPreview !== null, 200);
|
|
6714
|
-
const rowList = (0,
|
|
6715
|
-
() => tracks.map((track) => ({ id: track.id, kind: (0,
|
|
6875
|
+
const rowList = (0, import_react60.useMemo)(
|
|
6876
|
+
() => tracks.map((track) => ({ id: track.id, kind: (0, import_core13.trackKind)(track) })),
|
|
6716
6877
|
[tracks]
|
|
6717
6878
|
);
|
|
6718
6879
|
const dragSourceTrackId = (_b = trackDragPreview == null ? void 0 : trackDragPreview.trackId) != null ? _b : null;
|
|
6719
|
-
const rows = (0,
|
|
6880
|
+
const rows = (0, import_react60.useMemo)(
|
|
6720
6881
|
() => ({
|
|
6721
6882
|
rows: rowList,
|
|
6722
6883
|
peaksDataArray,
|
|
@@ -6767,7 +6928,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6767
6928
|
},
|
|
6768
6929
|
onClickWhileStopped: setCurrentTime
|
|
6769
6930
|
});
|
|
6770
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
6931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_components15.DevicePixelRatioProvider, { children: [
|
|
6771
6932
|
frame,
|
|
6772
6933
|
(spectrogram == null ? void 0 : spectrogram.SettingsModal) && typeof document !== "undefined" && (0, import_react_dom2.createPortal)(
|
|
6773
6934
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
@@ -6790,29 +6951,29 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6790
6951
|
};
|
|
6791
6952
|
|
|
6792
6953
|
// src/components/WaveformAnnotationBoxes.tsx
|
|
6793
|
-
var
|
|
6794
|
-
var
|
|
6954
|
+
var import_react63 = __toESM(require("react"));
|
|
6955
|
+
var import_react64 = require("@dnd-kit/react");
|
|
6795
6956
|
var import_modifiers2 = require("@dnd-kit/abstract/modifiers");
|
|
6796
|
-
var
|
|
6957
|
+
var import_ui_components16 = require("@waveform-playlist/ui-components");
|
|
6797
6958
|
|
|
6798
6959
|
// src/AnnotationIntegrationContext.tsx
|
|
6799
|
-
var
|
|
6800
|
-
var AnnotationIntegrationContext = (0,
|
|
6960
|
+
var import_react61 = require("react");
|
|
6961
|
+
var AnnotationIntegrationContext = (0, import_react61.createContext)(null);
|
|
6801
6962
|
var AnnotationIntegrationProvider = AnnotationIntegrationContext.Provider;
|
|
6802
6963
|
function useAnnotationIntegration() {
|
|
6803
|
-
const context = (0,
|
|
6964
|
+
const context = (0, import_react61.use)(AnnotationIntegrationContext);
|
|
6804
6965
|
if (!context) {
|
|
6805
6966
|
throw new Error(
|
|
6806
|
-
"useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations and wrap your app with <AnnotationProvider>. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6967
|
+
"useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations (" + installCommand("@waveform-playlist/annotations") + ") and wrap your app with <AnnotationProvider>. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6807
6968
|
);
|
|
6808
6969
|
}
|
|
6809
6970
|
return context;
|
|
6810
6971
|
}
|
|
6811
6972
|
|
|
6812
6973
|
// src/components/AnnotationBoxes.tsx
|
|
6813
|
-
var
|
|
6974
|
+
var import_react62 = __toESM(require("react"));
|
|
6814
6975
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
6815
|
-
var AnnotationBoxItem =
|
|
6976
|
+
var AnnotationBoxItem = import_react62.default.memo(function AnnotationBoxItem2({
|
|
6816
6977
|
AnnotationBox,
|
|
6817
6978
|
annotation,
|
|
6818
6979
|
index,
|
|
@@ -6851,7 +7012,7 @@ var AnnotationBoxes = ({
|
|
|
6851
7012
|
getLabel,
|
|
6852
7013
|
onSelect
|
|
6853
7014
|
}) => {
|
|
6854
|
-
const annotationIntegration = (0,
|
|
7015
|
+
const annotationIntegration = (0, import_react62.use)(AnnotationIntegrationContext);
|
|
6855
7016
|
if (annotations.length === 0 || !annotationIntegration) return null;
|
|
6856
7017
|
const { AnnotationBox, AnnotationBoxesWrapper } = annotationIntegration;
|
|
6857
7018
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AnnotationBoxesWrapper, { height, width, children: annotations.map((annotation, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -6876,25 +7037,24 @@ var AnnotationBoxes = ({
|
|
|
6876
7037
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6877
7038
|
var HORIZONTAL_ONLY = [import_modifiers2.RestrictToHorizontalAxis];
|
|
6878
7039
|
var DEFAULT_ANNOTATION_BOXES_HEIGHT = 30;
|
|
6879
|
-
var WaveformAnnotationBoxes =
|
|
7040
|
+
var WaveformAnnotationBoxes = import_react63.default.memo(function WaveformAnnotationBoxes2({
|
|
6880
7041
|
getLabel,
|
|
6881
7042
|
height = DEFAULT_ANNOTATION_BOXES_HEIGHT
|
|
6882
7043
|
}) {
|
|
6883
7044
|
const { tracksFullWidth: width, displayDuration } = useWaveformExtent("The annotation boxes");
|
|
6884
|
-
const integration = (0,
|
|
7045
|
+
const integration = (0, import_react63.use)(AnnotationIntegrationContext);
|
|
6885
7046
|
const { annotations } = useAnnotations();
|
|
6886
7047
|
const { editable, linkEndpoints } = useAnnotationOptions();
|
|
6887
7048
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6888
|
-
const {
|
|
7049
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6889
7050
|
const { sampleRate } = usePlaylistView();
|
|
6890
7051
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6891
7052
|
const { touchOptimized } = useClipInteraction();
|
|
6892
|
-
const theme = (0,
|
|
7053
|
+
const theme = (0, import_ui_components16.useTheme)();
|
|
6893
7054
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6894
7055
|
const sensors = useDragSensors({ touchOptimized });
|
|
6895
7056
|
const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
|
|
6896
|
-
|
|
6897
|
-
onAnnotationsChange: setAnnotations,
|
|
7057
|
+
store: annotationStore,
|
|
6898
7058
|
preview: annotationPreview,
|
|
6899
7059
|
samplesPerPixel,
|
|
6900
7060
|
sampleRate,
|
|
@@ -6903,7 +7063,7 @@ var WaveformAnnotationBoxes = import_react61.default.memo(function WaveformAnnot
|
|
|
6903
7063
|
});
|
|
6904
7064
|
if (annotations.length === 0 || !integration) return null;
|
|
6905
7065
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6906
|
-
|
|
7066
|
+
import_react64.DragDropProvider,
|
|
6907
7067
|
{
|
|
6908
7068
|
sensors,
|
|
6909
7069
|
onDragStart,
|
|
@@ -6930,7 +7090,7 @@ var WaveformAnnotationBoxes = import_react61.default.memo(function WaveformAnnot
|
|
|
6930
7090
|
});
|
|
6931
7091
|
|
|
6932
7092
|
// src/components/AnnotationList.tsx
|
|
6933
|
-
var
|
|
7093
|
+
var import_react65 = require("react");
|
|
6934
7094
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6935
7095
|
var AnnotationList = ({
|
|
6936
7096
|
height,
|
|
@@ -6939,20 +7099,20 @@ var AnnotationList = ({
|
|
|
6939
7099
|
scrollActiveContainer = "nearest",
|
|
6940
7100
|
children
|
|
6941
7101
|
}) => {
|
|
6942
|
-
const integration = (0,
|
|
7102
|
+
const integration = (0, import_react65.use)(AnnotationIntegrationContext);
|
|
6943
7103
|
const { annotations } = useAnnotations();
|
|
6944
7104
|
const { editable, linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
6945
7105
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6946
|
-
const {
|
|
7106
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6947
7107
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6948
|
-
const actionOptions = (0,
|
|
7108
|
+
const actionOptions = (0, import_react65.useMemo)(
|
|
6949
7109
|
() => ({ linkEndpoints, continuousPlay }),
|
|
6950
7110
|
[linkEndpoints, continuousPlay]
|
|
6951
7111
|
);
|
|
6952
7112
|
if (annotations.length === 0) return null;
|
|
6953
7113
|
if (!integration) {
|
|
6954
7114
|
warnOnce(
|
|
6955
|
-
"<AnnotationList> draws nothing without the annotation components: install @waveform-playlist/annotations and render <AnnotationProvider> above it. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
7115
|
+
"<AnnotationList> draws nothing without the annotation components: install @waveform-playlist/annotations (" + installCommand("@waveform-playlist/annotations") + ") and render <AnnotationProvider> above it. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
6956
7116
|
);
|
|
6957
7117
|
return null;
|
|
6958
7118
|
}
|
|
@@ -6971,7 +7131,7 @@ var AnnotationList = ({
|
|
|
6971
7131
|
annotationListConfig: actionOptions,
|
|
6972
7132
|
height,
|
|
6973
7133
|
onAnnotationClick: playAnnotation,
|
|
6974
|
-
|
|
7134
|
+
store: annotationStore,
|
|
6975
7135
|
renderAnnotationItem: children
|
|
6976
7136
|
}
|
|
6977
7137
|
);
|
|
@@ -7009,8 +7169,8 @@ var Waveform = (props) => composeWaveform(__spreadProps(__spreadValues({}, props
|
|
|
7009
7169
|
var WaveformEditor = (props) => composeWaveform(__spreadProps(__spreadValues({}, props), { tracks: TRACKS_WITH_HEADERS_AND_FADES }));
|
|
7010
7170
|
|
|
7011
7171
|
// src/components/MediaElementWaveformRoot.tsx
|
|
7012
|
-
var
|
|
7013
|
-
var
|
|
7172
|
+
var import_react66 = require("react");
|
|
7173
|
+
var import_ui_components17 = require("@waveform-playlist/ui-components");
|
|
7014
7174
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7015
7175
|
var ONE_ROW = [{ id: MEDIA_ELEMENT_TRACK_ID, kind: "audio" }];
|
|
7016
7176
|
var ONE_EMPTY_ROW = [[]];
|
|
@@ -7033,7 +7193,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7033
7193
|
);
|
|
7034
7194
|
}
|
|
7035
7195
|
const { showClipHeaders } = parts.tracksOptions;
|
|
7036
|
-
const rows = (0,
|
|
7196
|
+
const rows = (0, import_react66.useMemo)(() => {
|
|
7037
7197
|
const rowList = ONE_ROW;
|
|
7038
7198
|
const rowPeaks = peaksDataArray.length > 0 ? peaksDataArray : ONE_EMPTY_ROW;
|
|
7039
7199
|
const trackHeightById = /* @__PURE__ */ new Map();
|
|
@@ -7041,7 +7201,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7041
7201
|
const channels = getTrackChannelCount(rowPeaks[index], 0);
|
|
7042
7202
|
trackHeightById.set(
|
|
7043
7203
|
row.id,
|
|
7044
|
-
waveHeight * channels + (showClipHeaders ?
|
|
7204
|
+
waveHeight * channels + (showClipHeaders ? import_ui_components17.CLIP_HEADER_HEIGHT : 0)
|
|
7045
7205
|
);
|
|
7046
7206
|
});
|
|
7047
7207
|
return {
|
|
@@ -7062,7 +7222,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7062
7222
|
dragSourceTrackId: null
|
|
7063
7223
|
};
|
|
7064
7224
|
}, [peaksDataArray, waveHeight, showClipHeaders]);
|
|
7065
|
-
const collapseSelectionAt = (0,
|
|
7225
|
+
const collapseSelectionAt = (0, import_react66.useCallback)(
|
|
7066
7226
|
(time) => setSelection(time, time),
|
|
7067
7227
|
[setSelection]
|
|
7068
7228
|
);
|
|
@@ -7078,7 +7238,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7078
7238
|
controlsWidth: 0,
|
|
7079
7239
|
onClickWhileStopped: collapseSelectionAt
|
|
7080
7240
|
});
|
|
7081
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
7241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_ui_components17.DevicePixelRatioProvider, { children: frame });
|
|
7082
7242
|
};
|
|
7083
7243
|
|
|
7084
7244
|
// src/components/MediaElementWaveform.tsx
|
|
@@ -7113,7 +7273,7 @@ var KeyboardShortcuts = ({
|
|
|
7113
7273
|
const { annotations: annotationList } = useAnnotations();
|
|
7114
7274
|
const { linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
7115
7275
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
7116
|
-
const {
|
|
7276
|
+
const { annotationStore, setActiveAnnotationId, scrollContainerRef, play } = usePlaybackControls();
|
|
7117
7277
|
const { undo, redo } = useEditorControls();
|
|
7118
7278
|
const { splitClipAtPlayhead } = useClipSplitting({ samplesPerPixel });
|
|
7119
7279
|
const allAdditional = [];
|
|
@@ -7140,9 +7300,8 @@ var KeyboardShortcuts = ({
|
|
|
7140
7300
|
enabled: playback || allAdditional.length > 0
|
|
7141
7301
|
}, playback ? { additionalShortcuts: allAdditional } : { shortcuts: allAdditional }));
|
|
7142
7302
|
useAnnotationKeyboardControls({
|
|
7143
|
-
|
|
7303
|
+
store: annotationStore,
|
|
7144
7304
|
activeAnnotationId,
|
|
7145
|
-
onAnnotationsChange: setAnnotations,
|
|
7146
7305
|
onActiveAnnotationChange: setActiveAnnotationId,
|
|
7147
7306
|
duration,
|
|
7148
7307
|
linkEndpoints,
|
|
@@ -7155,24 +7314,24 @@ var KeyboardShortcuts = ({
|
|
|
7155
7314
|
};
|
|
7156
7315
|
|
|
7157
7316
|
// src/hooks/useRecordingSession.ts
|
|
7158
|
-
var
|
|
7317
|
+
var import_react67 = require("react");
|
|
7159
7318
|
function useRecordingSession({ isRecording, trackId }) {
|
|
7160
7319
|
const { setRecordingActive } = useEditorControls();
|
|
7161
|
-
const
|
|
7162
|
-
(0,
|
|
7320
|
+
const recordingTrackId = trackId != null ? trackId : null;
|
|
7321
|
+
(0, import_react67.useEffect)(() => {
|
|
7163
7322
|
if (!isRecording) return void 0;
|
|
7164
|
-
setRecordingActive(true,
|
|
7323
|
+
setRecordingActive(true, recordingTrackId);
|
|
7165
7324
|
return () => setRecordingActive(false);
|
|
7166
|
-
}, [isRecording,
|
|
7325
|
+
}, [isRecording, recordingTrackId, setRecordingActive]);
|
|
7167
7326
|
}
|
|
7168
7327
|
|
|
7169
7328
|
// src/components/ClipInteractionProvider.tsx
|
|
7170
|
-
var
|
|
7329
|
+
var import_react68 = __toESM(require("react"));
|
|
7171
7330
|
var import_react_dom3 = require("react-dom");
|
|
7172
|
-
var
|
|
7331
|
+
var import_react69 = require("@dnd-kit/react");
|
|
7173
7332
|
var import_modifiers3 = require("@dnd-kit/abstract/modifiers");
|
|
7174
|
-
var
|
|
7175
|
-
var
|
|
7333
|
+
var import_core15 = require("@waveform-playlist/core");
|
|
7334
|
+
var import_ui_components18 = require("@waveform-playlist/ui-components");
|
|
7176
7335
|
|
|
7177
7336
|
// src/modifiers/ClipCollisionModifier.ts
|
|
7178
7337
|
var import_abstract = require("@dnd-kit/abstract");
|
|
@@ -7201,7 +7360,7 @@ var ClipCollisionModifier = _ClipCollisionModifier;
|
|
|
7201
7360
|
|
|
7202
7361
|
// src/modifiers/SnapToGridModifier.ts
|
|
7203
7362
|
var import_abstract2 = require("@dnd-kit/abstract");
|
|
7204
|
-
var
|
|
7363
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
7205
7364
|
var _SnapToGridModifier = class _SnapToGridModifier extends import_abstract2.Modifier {
|
|
7206
7365
|
apply(operation) {
|
|
7207
7366
|
const { transform, source } = operation;
|
|
@@ -7222,18 +7381,18 @@ var _SnapToGridModifier = class _SnapToGridModifier extends import_abstract2.Mod
|
|
|
7222
7381
|
}
|
|
7223
7382
|
const { snapTo, bpm, timeSignature, sampleRate } = this.options;
|
|
7224
7383
|
if (snapTo === "off") return transform;
|
|
7225
|
-
const gridTicks = snapTo === "bar" ? (0,
|
|
7384
|
+
const gridTicks = snapTo === "bar" ? (0, import_core14.ticksPerBar)(timeSignature) : (0, import_core14.ticksPerBeat)(timeSignature);
|
|
7226
7385
|
if (startSample !== void 0) {
|
|
7227
7386
|
const proposedSamples = startSample + transform.x * samplesPerPixel;
|
|
7228
|
-
const proposedTicks = (0,
|
|
7229
|
-
const snappedTicks2 = (0,
|
|
7230
|
-
const snappedSamples2 = (0,
|
|
7387
|
+
const proposedTicks = (0, import_core14.samplesToTicks)(proposedSamples, bpm, sampleRate);
|
|
7388
|
+
const snappedTicks2 = (0, import_core14.snapToGrid)(proposedTicks, gridTicks);
|
|
7389
|
+
const snappedSamples2 = (0, import_core14.ticksToSamples)(snappedTicks2, bpm, sampleRate);
|
|
7231
7390
|
return { x: (snappedSamples2 - startSample) / samplesPerPixel, y: 0 };
|
|
7232
7391
|
}
|
|
7233
7392
|
const deltaSamples = transform.x * samplesPerPixel;
|
|
7234
|
-
const deltaTicks = (0,
|
|
7235
|
-
const snappedTicks = (0,
|
|
7236
|
-
const snappedSamples = (0,
|
|
7393
|
+
const deltaTicks = (0, import_core14.samplesToTicks)(deltaSamples, bpm, sampleRate);
|
|
7394
|
+
const snappedTicks = (0, import_core14.snapToGrid)(deltaTicks, gridTicks);
|
|
7395
|
+
const snappedSamples = (0, import_core14.ticksToSamples)(snappedTicks, bpm, sampleRate);
|
|
7237
7396
|
return { x: snappedSamples / samplesPerPixel, y: 0 };
|
|
7238
7397
|
}
|
|
7239
7398
|
};
|
|
@@ -7252,42 +7411,50 @@ var ClipInteractionProvider = ({
|
|
|
7252
7411
|
const { sampleRate } = usePlaylistView();
|
|
7253
7412
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
7254
7413
|
const { tracks } = usePlaylistTimeline();
|
|
7255
|
-
const { setSelectedTrackId, reorderTrack,
|
|
7256
|
-
const beatsAndBars = (0,
|
|
7414
|
+
const { setSelectedTrackId, reorderTrack, setTrackDragPreview } = useEditorControls();
|
|
7415
|
+
const beatsAndBars = (0, import_ui_components18.useBeatsAndBars)();
|
|
7257
7416
|
const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
|
|
7258
7417
|
const useTimescaleSnap = snap && !useBeatsSnap;
|
|
7259
|
-
const snapSamplePosition = (0,
|
|
7418
|
+
const snapSamplePosition = (0, import_react68.useMemo)(() => {
|
|
7260
7419
|
if (useBeatsSnap && beatsAndBars) {
|
|
7261
7420
|
const { bpm, timeSignature, snapTo } = beatsAndBars;
|
|
7262
|
-
const gridTicks = snapTo === "bar" ? (0,
|
|
7421
|
+
const gridTicks = snapTo === "bar" ? (0, import_core15.ticksPerBar)(timeSignature) : (0, import_core15.ticksPerBeat)(timeSignature);
|
|
7263
7422
|
return (samplePos) => {
|
|
7264
|
-
const ticks = (0,
|
|
7265
|
-
const snapped = (0,
|
|
7266
|
-
return (0,
|
|
7423
|
+
const ticks = (0, import_core15.samplesToTicks)(samplePos, bpm, sampleRate);
|
|
7424
|
+
const snapped = (0, import_core15.snapToGrid)(ticks, gridTicks);
|
|
7425
|
+
return (0, import_core15.ticksToSamples)(snapped, bpm, sampleRate);
|
|
7267
7426
|
};
|
|
7268
7427
|
}
|
|
7269
7428
|
if (useTimescaleSnap) {
|
|
7270
|
-
const gridSamples = Math.round((0,
|
|
7429
|
+
const gridSamples = Math.round((0, import_ui_components18.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate);
|
|
7271
7430
|
return (samplePos) => Math.round(samplePos / gridSamples) * gridSamples;
|
|
7272
7431
|
}
|
|
7273
7432
|
return void 0;
|
|
7274
7433
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, sampleRate, samplesPerPixel]);
|
|
7275
|
-
const tracksRef = (0,
|
|
7434
|
+
const tracksRef = (0, import_react68.useRef)(tracks);
|
|
7276
7435
|
tracksRef.current = tracks;
|
|
7277
|
-
const getTracks = (0,
|
|
7436
|
+
const getTracks = (0, import_react68.useCallback)(() => tracksRef.current, []);
|
|
7278
7437
|
const sensors = useDragSensors({ touchOptimized });
|
|
7279
7438
|
const {
|
|
7280
7439
|
onDragStart: handleDragStart,
|
|
7281
7440
|
onDragMove,
|
|
7282
7441
|
onDragEnd
|
|
7283
7442
|
} = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
|
|
7284
|
-
const
|
|
7285
|
-
const
|
|
7443
|
+
const dragGuard = useDragGuardOptional();
|
|
7444
|
+
const endReorderGuardRef = (0, import_react68.useRef)(null);
|
|
7445
|
+
const endReorderGuard = (0, import_react68.useCallback)(() => {
|
|
7446
|
+
var _a;
|
|
7447
|
+
(_a = endReorderGuardRef.current) == null ? void 0 : _a.call(endReorderGuardRef);
|
|
7448
|
+
endReorderGuardRef.current = null;
|
|
7449
|
+
}, []);
|
|
7450
|
+
import_react68.default.useEffect(() => endReorderGuard, [endReorderGuard]);
|
|
7451
|
+
const onDragStart = import_react68.default.useCallback(
|
|
7286
7452
|
(event) => {
|
|
7287
|
-
var _a, _b;
|
|
7453
|
+
var _a, _b, _c;
|
|
7288
7454
|
const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
|
|
7289
7455
|
if ((data == null ? void 0 : data.kind) === "track-reorder") {
|
|
7290
|
-
|
|
7456
|
+
endReorderGuard();
|
|
7457
|
+
endReorderGuardRef.current = (_c = dragGuard == null ? void 0 : dragGuard.begin()) != null ? _c : null;
|
|
7291
7458
|
if (data.trackId) setSelectedTrackId(data.trackId);
|
|
7292
7459
|
return;
|
|
7293
7460
|
}
|
|
@@ -7298,14 +7465,13 @@ var ClipInteractionProvider = ({
|
|
|
7298
7465
|
}
|
|
7299
7466
|
handleDragStart(event);
|
|
7300
7467
|
},
|
|
7301
|
-
[handleDragStart, setSelectedTrackId]
|
|
7468
|
+
[handleDragStart, setSelectedTrackId, dragGuard, endReorderGuard]
|
|
7302
7469
|
);
|
|
7303
|
-
const handleDragOver =
|
|
7470
|
+
const handleDragOver = import_react68.default.useCallback(
|
|
7304
7471
|
(event) => {
|
|
7305
7472
|
var _a;
|
|
7306
7473
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
7307
7474
|
if ((data == null ? void 0 : data.kind) !== "track-reorder" || !data.trackId) return;
|
|
7308
|
-
if (!trackReorderDragActiveRef.current) return;
|
|
7309
7475
|
const sortable = event.operation.source.sortable;
|
|
7310
7476
|
if (!sortable) return;
|
|
7311
7477
|
const trackId = data.trackId;
|
|
@@ -7316,17 +7482,16 @@ var ClipInteractionProvider = ({
|
|
|
7316
7482
|
},
|
|
7317
7483
|
[setTrackDragPreview]
|
|
7318
7484
|
);
|
|
7319
|
-
const handleDragEnd =
|
|
7485
|
+
const handleDragEnd = import_react68.default.useCallback(
|
|
7320
7486
|
(event) => {
|
|
7321
7487
|
var _a;
|
|
7322
7488
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
7323
7489
|
if ((data == null ? void 0 : data.kind) === "track-reorder") {
|
|
7324
|
-
|
|
7490
|
+
endReorderGuard();
|
|
7325
7491
|
const sortable = event.operation.source.sortable;
|
|
7326
7492
|
const trackId = data.trackId;
|
|
7327
7493
|
const moves = !event.canceled && trackId && sortable && sortable.index !== sortable.initialIndex;
|
|
7328
7494
|
(0, import_react_dom3.flushSync)(() => {
|
|
7329
|
-
bumpTrackReorderEpoch();
|
|
7330
7495
|
setTrackDragPreview(null);
|
|
7331
7496
|
if (moves) reorderTrack(trackId, sortable.index);
|
|
7332
7497
|
});
|
|
@@ -7334,9 +7499,9 @@ var ClipInteractionProvider = ({
|
|
|
7334
7499
|
}
|
|
7335
7500
|
onDragEnd(event);
|
|
7336
7501
|
},
|
|
7337
|
-
[onDragEnd, reorderTrack,
|
|
7502
|
+
[onDragEnd, reorderTrack, setTrackDragPreview, endReorderGuard]
|
|
7338
7503
|
);
|
|
7339
|
-
const modifiers = (0,
|
|
7504
|
+
const modifiers = (0, import_react68.useMemo)(() => {
|
|
7340
7505
|
const mods = [import_modifiers3.RestrictToHorizontalAxis];
|
|
7341
7506
|
if (useBeatsSnap && beatsAndBars) {
|
|
7342
7507
|
mods.push(
|
|
@@ -7353,7 +7518,7 @@ var ClipInteractionProvider = ({
|
|
|
7353
7518
|
mods.push(
|
|
7354
7519
|
SnapToGridModifier.configure({
|
|
7355
7520
|
mode: "timescale",
|
|
7356
|
-
gridSamples: Math.round((0,
|
|
7521
|
+
gridSamples: Math.round((0, import_ui_components18.getScaleInfo)(samplesPerPixel).smallStep / 1e3 * sampleRate),
|
|
7357
7522
|
samplesPerPixel
|
|
7358
7523
|
})
|
|
7359
7524
|
);
|
|
@@ -7362,7 +7527,7 @@ var ClipInteractionProvider = ({
|
|
|
7362
7527
|
return mods;
|
|
7363
7528
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, getTracks, samplesPerPixel, sampleRate]);
|
|
7364
7529
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ClipInteractionOptions, { enabled: true, touchOptimized, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7365
|
-
|
|
7530
|
+
import_react69.DragDropProvider,
|
|
7366
7531
|
{
|
|
7367
7532
|
sensors,
|
|
7368
7533
|
onDragStart,
|
|
@@ -7445,6 +7610,7 @@ var ClipInteractionProvider = ({
|
|
|
7445
7610
|
useClipDragHandlers,
|
|
7446
7611
|
useClipInteractionEnabled,
|
|
7447
7612
|
useClipSplitting,
|
|
7613
|
+
useCreateAnnotationStore,
|
|
7448
7614
|
useCreateArrangement,
|
|
7449
7615
|
useCurrentTime,
|
|
7450
7616
|
useDragSensors,
|
|
@@ -7468,6 +7634,7 @@ var ClipInteractionProvider = ({
|
|
|
7468
7634
|
useSelectedTrackId,
|
|
7469
7635
|
useSelection,
|
|
7470
7636
|
useSpectrogramIntegration,
|
|
7637
|
+
useStoredAnnotations,
|
|
7471
7638
|
useTimeFormat,
|
|
7472
7639
|
useTrack,
|
|
7473
7640
|
useTrackReorderHandle,
|