@waveform-playlist/browser 17.0.0-next.4 → 17.0.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +94 -74
- package/dist/index.d.ts +94 -74
- package/dist/index.js +730 -630
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +574 -475
- package/dist/index.mjs.map +1 -1
- package/dist/tone.js +1 -1
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +1 -1
- package/dist/tone.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.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,
|
|
@@ -182,10 +184,10 @@ __export(index_exports, {
|
|
|
182
184
|
module.exports = __toCommonJS(index_exports);
|
|
183
185
|
|
|
184
186
|
// <define:__INSTALL_SPECS__>
|
|
185
|
-
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.
|
|
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.4", "@waveform-playlist/media-element-playout": "@waveform-playlist/media-element-playout@^12.4.0-next.2", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.2", "@waveform-playlist/recording": "@waveform-playlist/recording@^14.0.0-next.4", react: "react@^19.0.0", "react-dom": "react-dom@^19.0.0", "styled-components": "styled-components@^6.0.0", tone: "tone@^15.0.0", "@waveform-playlist/spectrogram": "@waveform-playlist/spectrogram@^15.0.0-next.2" };
|
|
186
188
|
|
|
187
189
|
// src/WaveformPlaylistContext.tsx
|
|
188
|
-
var
|
|
190
|
+
var import_react35 = require("react");
|
|
189
191
|
var import_styled_components = require("styled-components");
|
|
190
192
|
|
|
191
193
|
// src/soundFontSync.ts
|
|
@@ -790,9 +792,21 @@ function useClipDragHandlers({
|
|
|
790
792
|
var import_react9 = __toESM(require("react"));
|
|
791
793
|
var import_react_dom = require("react-dom");
|
|
792
794
|
var import_core2 = require("@waveform-playlist/core");
|
|
795
|
+
function touchedChanges(drag) {
|
|
796
|
+
return [...drag.touched.values()];
|
|
797
|
+
}
|
|
798
|
+
function snapshotBounds(drag) {
|
|
799
|
+
const before = new Map(drag.snapshot.map((a) => [a.id, a]));
|
|
800
|
+
return [...drag.touched.keys()].flatMap((id) => {
|
|
801
|
+
const old = before.get(id);
|
|
802
|
+
return old ? [{ id, start: old.start, end: old.end }] : [];
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
function shownDuringDrag(drag) {
|
|
806
|
+
return (0, import_core2.applyAnnotationBounds)(drag.store.getAnnotations(), touchedChanges(drag));
|
|
807
|
+
}
|
|
793
808
|
function useAnnotationDragHandlers({
|
|
794
|
-
|
|
795
|
-
onAnnotationsChange,
|
|
809
|
+
store,
|
|
796
810
|
samplesPerPixel,
|
|
797
811
|
// Default mirrors the engine default; the providers always pass the real rate from context (#510).
|
|
798
812
|
sampleRate = 48e3,
|
|
@@ -801,81 +815,132 @@ function useAnnotationDragHandlers({
|
|
|
801
815
|
preview
|
|
802
816
|
}) {
|
|
803
817
|
const dragRef = import_react9.default.useRef(null);
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
|
|
818
|
+
const storeRef = import_react9.default.useRef(store);
|
|
819
|
+
storeRef.current = store;
|
|
820
|
+
const previewRef = import_react9.default.useRef(preview);
|
|
821
|
+
previewRef.current = preview;
|
|
822
|
+
const abandon = import_react9.default.useCallback(() => {
|
|
823
|
+
var _a;
|
|
824
|
+
if (!dragRef.current) return;
|
|
825
|
+
dragRef.current = null;
|
|
826
|
+
(_a = previewRef.current) == null ? void 0 : _a.publish(null);
|
|
827
|
+
}, []);
|
|
808
828
|
import_react9.default.useEffect(() => {
|
|
809
|
-
if (!
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
829
|
+
if (!store) return;
|
|
830
|
+
const unsubscribe = store.subscribe(() => {
|
|
831
|
+
const drag = dragRef.current;
|
|
832
|
+
if (!drag || drag.store !== store) return;
|
|
833
|
+
if (!store.getAnnotations().some((a) => a.id === drag.draggedId)) {
|
|
834
|
+
abandon();
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const shown = previewRef.current;
|
|
838
|
+
if (shown && shown.source.getSnapshot() !== null) {
|
|
839
|
+
shown.publish(shownDuringDrag(drag));
|
|
814
840
|
}
|
|
841
|
+
});
|
|
842
|
+
return () => {
|
|
843
|
+
unsubscribe();
|
|
844
|
+
abandon();
|
|
815
845
|
};
|
|
816
|
-
}, [
|
|
846
|
+
}, [store, abandon]);
|
|
847
|
+
import_react9.default.useEffect(() => abandon, [preview, abandon]);
|
|
817
848
|
const onDragStart = import_react9.default.useCallback((event) => {
|
|
818
849
|
var _a;
|
|
819
850
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
820
|
-
const
|
|
821
|
-
|
|
822
|
-
|
|
851
|
+
const owner = storeRef.current;
|
|
852
|
+
if (!owner || !data) {
|
|
853
|
+
dragRef.current = null;
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
const snapshot = owner.getAnnotations();
|
|
857
|
+
const annotation = data.annotationIndex === void 0 ? void 0 : snapshot[data.annotationIndex];
|
|
858
|
+
dragRef.current = annotation ? {
|
|
859
|
+
store: owner,
|
|
823
860
|
snapshot,
|
|
861
|
+
touched: /* @__PURE__ */ new Map(),
|
|
862
|
+
draggedId: annotation.id,
|
|
863
|
+
edge: data.edge,
|
|
824
864
|
start: annotation.start,
|
|
825
|
-
end: annotation.end
|
|
826
|
-
annotationIndex: data.annotationIndex
|
|
865
|
+
end: annotation.end
|
|
827
866
|
} : null;
|
|
828
867
|
}, []);
|
|
829
868
|
const onDragMove = import_react9.default.useCallback(
|
|
830
869
|
(event) => {
|
|
831
|
-
var _a, _b
|
|
870
|
+
var _a, _b;
|
|
832
871
|
const drag = dragRef.current;
|
|
833
|
-
if (!drag)
|
|
872
|
+
if (!drag) return;
|
|
873
|
+
if (drag.store !== storeRef.current) {
|
|
874
|
+
abandon();
|
|
834
875
|
return;
|
|
835
876
|
}
|
|
836
|
-
const
|
|
837
|
-
if (!data) return;
|
|
838
|
-
const { edge, annotationIndex } = data;
|
|
839
|
-
const currentX = (_c = (_b = event.to) == null ? void 0 : _b.x) != null ? _c : event.operation.position.current.x;
|
|
877
|
+
const currentX = (_b = (_a = event.to) == null ? void 0 : _a.x) != null ? _b : event.operation.position.current.x;
|
|
840
878
|
const rawDeltaX = currentX - event.operation.position.initial.x;
|
|
841
879
|
const timeDelta = rawDeltaX * samplesPerPixel / sampleRate;
|
|
842
|
-
const newTime = edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
843
|
-
const
|
|
880
|
+
const newTime = drag.edge === "start" ? drag.start + timeDelta : drag.end + timeDelta;
|
|
881
|
+
const base = shownDuringDrag(drag);
|
|
882
|
+
const annotationIndex = base.findIndex((a) => a.id === drag.draggedId);
|
|
883
|
+
if (annotationIndex < 0) {
|
|
884
|
+
abandon();
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const updated = (0, import_core2.updateAnnotationBoundaries)({
|
|
844
888
|
annotationIndex,
|
|
845
889
|
newTime,
|
|
846
|
-
isDraggingStart: edge === "start",
|
|
847
|
-
annotations:
|
|
890
|
+
isDraggingStart: drag.edge === "start",
|
|
891
|
+
annotations: base,
|
|
848
892
|
duration,
|
|
849
893
|
linkEndpoints
|
|
850
894
|
});
|
|
895
|
+
updated.forEach((annotation, i) => {
|
|
896
|
+
const was = base[i];
|
|
897
|
+
if (drag.touched.has(annotation.id) || was.start !== annotation.start || was.end !== annotation.end) {
|
|
898
|
+
drag.touched.set(annotation.id, {
|
|
899
|
+
id: annotation.id,
|
|
900
|
+
start: annotation.start,
|
|
901
|
+
end: annotation.end
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
});
|
|
851
905
|
if (preview) {
|
|
852
|
-
preview.publish(
|
|
906
|
+
preview.publish(updated);
|
|
853
907
|
} else {
|
|
854
|
-
|
|
908
|
+
const changes = touchedChanges(drag);
|
|
909
|
+
drag.store.update((current) => (0, import_core2.applyAnnotationBounds)(current, changes));
|
|
855
910
|
}
|
|
856
911
|
},
|
|
857
|
-
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview]
|
|
912
|
+
[samplesPerPixel, sampleRate, duration, linkEndpoints, preview, abandon]
|
|
858
913
|
);
|
|
859
914
|
const onDragEnd = import_react9.default.useCallback(
|
|
860
915
|
(event) => {
|
|
861
916
|
const drag = dragRef.current;
|
|
862
917
|
dragRef.current = null;
|
|
863
918
|
if (!drag) return;
|
|
919
|
+
if (drag.store !== storeRef.current) {
|
|
920
|
+
preview == null ? void 0 : preview.publish(null);
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
864
923
|
if (!preview) {
|
|
865
|
-
if (event.canceled
|
|
866
|
-
|
|
924
|
+
if (event.canceled) {
|
|
925
|
+
const restore = snapshotBounds(drag);
|
|
926
|
+
drag.store.update((current) => (0, import_core2.applyAnnotationBounds)(current, restore));
|
|
867
927
|
}
|
|
868
928
|
return;
|
|
869
929
|
}
|
|
870
|
-
|
|
871
|
-
if (result === null) return;
|
|
930
|
+
if (preview.source.getSnapshot() === null) return;
|
|
872
931
|
if (event.canceled) {
|
|
873
932
|
preview.publish(null);
|
|
874
933
|
return;
|
|
875
934
|
}
|
|
876
935
|
(0, import_react_dom.flushSync)(() => {
|
|
877
|
-
|
|
878
|
-
|
|
936
|
+
try {
|
|
937
|
+
const changes = touchedChanges(drag);
|
|
938
|
+
drag.store.update(
|
|
939
|
+
(current) => current.some((a) => a.id === drag.draggedId) ? (0, import_core2.applyAnnotationBounds)(current, changes) : current
|
|
940
|
+
);
|
|
941
|
+
} finally {
|
|
942
|
+
preview.publish(null);
|
|
943
|
+
}
|
|
879
944
|
});
|
|
880
945
|
},
|
|
881
946
|
[preview]
|
|
@@ -993,18 +1058,17 @@ var import_react13 = require("react");
|
|
|
993
1058
|
var import_core3 = require("@waveform-playlist/core");
|
|
994
1059
|
var useKeyboardShortcuts = (options) => {
|
|
995
1060
|
const { shortcuts, enabled = true } = options;
|
|
996
|
-
const
|
|
997
|
-
(0, import_react13.
|
|
998
|
-
|
|
1061
|
+
const latest = (0, import_react13.useRef)({ shortcuts, enabled });
|
|
1062
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
1063
|
+
latest.current = { shortcuts, enabled };
|
|
999
1064
|
});
|
|
1000
|
-
(0, import_react13.
|
|
1001
|
-
|
|
1002
|
-
const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, shortcutsRef.current, true);
|
|
1065
|
+
(0, import_react13.useLayoutEffect)(() => {
|
|
1066
|
+
const handleKeyDown = (event) => (0, import_core3.handleKeyboardEvent)(event, latest.current.shortcuts, latest.current.enabled);
|
|
1003
1067
|
window.addEventListener("keydown", handleKeyDown);
|
|
1004
1068
|
return () => {
|
|
1005
1069
|
window.removeEventListener("keydown", handleKeyDown);
|
|
1006
1070
|
};
|
|
1007
|
-
}, [
|
|
1071
|
+
}, []);
|
|
1008
1072
|
};
|
|
1009
1073
|
|
|
1010
1074
|
// src/hooks/usePlaybackShortcuts.ts
|
|
@@ -1019,7 +1083,7 @@ function usePlayFromSelectionOrCursor() {
|
|
|
1019
1083
|
const isLoopEnabled = (_b = (_a = useLoopOptional()) == null ? void 0 : _a.isLoopEnabled) != null ? _b : false;
|
|
1020
1084
|
const { play } = usePlaybackControls();
|
|
1021
1085
|
const latest = (0, import_react14.useRef)({ selectionStart, selectionEnd, isLoopEnabled });
|
|
1022
|
-
(0, import_react14.
|
|
1086
|
+
(0, import_react14.useLayoutEffect)(() => {
|
|
1023
1087
|
latest.current = { selectionStart, selectionEnd, isLoopEnabled };
|
|
1024
1088
|
});
|
|
1025
1089
|
return (0, import_react14.useCallback)(() => __async(null, null, function* () {
|
|
@@ -1092,12 +1156,94 @@ var usePlaybackShortcuts = (options = {}) => {
|
|
|
1092
1156
|
|
|
1093
1157
|
// src/hooks/useAnnotationKeyboardControls.ts
|
|
1094
1158
|
var import_react16 = require("react");
|
|
1159
|
+
|
|
1160
|
+
// src/utils/annotationBoundaryKeys.ts
|
|
1095
1161
|
var LINK_THRESHOLD = 0.01;
|
|
1162
|
+
var MIN_LENGTH = 0.1;
|
|
1163
|
+
function unlessUnchanged(list, updated) {
|
|
1164
|
+
const same = updated.every((a, i) => a.start === list[i].start && a.end === list[i].end);
|
|
1165
|
+
return same ? list : updated;
|
|
1166
|
+
}
|
|
1167
|
+
function moveAnnotationStart(list, index, delta, { linkEndpoints }) {
|
|
1168
|
+
const annotation = list[index];
|
|
1169
|
+
const newStart = Math.max(0, Math.min(annotation.end - MIN_LENGTH, annotation.start + delta));
|
|
1170
|
+
const actualDelta = newStart - annotation.start;
|
|
1171
|
+
const updated = [...list];
|
|
1172
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { start: newStart });
|
|
1173
|
+
if (linkEndpoints && index > 0) {
|
|
1174
|
+
const prev = updated[index - 1];
|
|
1175
|
+
if (Math.abs(prev.end - annotation.start) < LINK_THRESHOLD) {
|
|
1176
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), {
|
|
1177
|
+
end: Math.max(prev.start + MIN_LENGTH, prev.end + actualDelta)
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
} else if (!linkEndpoints && index > 0) {
|
|
1181
|
+
const prev = updated[index - 1];
|
|
1182
|
+
if (newStart < prev.end) {
|
|
1183
|
+
updated[index - 1] = __spreadProps(__spreadValues({}, prev), { end: newStart });
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return unlessUnchanged(list, updated);
|
|
1187
|
+
}
|
|
1188
|
+
function moveAnnotationEnd(list, index, delta, { linkEndpoints, duration }) {
|
|
1189
|
+
const annotation = list[index];
|
|
1190
|
+
const newEnd = Math.max(
|
|
1191
|
+
annotation.start + MIN_LENGTH,
|
|
1192
|
+
Math.min(duration, annotation.end + delta)
|
|
1193
|
+
);
|
|
1194
|
+
const actualDelta = newEnd - annotation.end;
|
|
1195
|
+
const updated = [...list];
|
|
1196
|
+
updated[index] = __spreadProps(__spreadValues({}, annotation), { end: newEnd });
|
|
1197
|
+
if (linkEndpoints && index < list.length - 1) {
|
|
1198
|
+
const next = updated[index + 1];
|
|
1199
|
+
if (Math.abs(next.start - annotation.end) < LINK_THRESHOLD) {
|
|
1200
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1201
|
+
start: Math.min(next.end - MIN_LENGTH, next.start + actualDelta)
|
|
1202
|
+
});
|
|
1203
|
+
let current = index + 1;
|
|
1204
|
+
while (current < updated.length - 1) {
|
|
1205
|
+
const moved = updated[current];
|
|
1206
|
+
const following = updated[current + 1];
|
|
1207
|
+
if (Math.abs(following.start - list[current].end) < LINK_THRESHOLD) {
|
|
1208
|
+
const nextDelta = moved.end - list[current].end;
|
|
1209
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), {
|
|
1210
|
+
start: Math.min(following.end - MIN_LENGTH, following.start + nextDelta)
|
|
1211
|
+
});
|
|
1212
|
+
current++;
|
|
1213
|
+
} else {
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
} else if (!linkEndpoints && index < list.length - 1) {
|
|
1219
|
+
const next = updated[index + 1];
|
|
1220
|
+
if (newEnd > next.start) {
|
|
1221
|
+
updated[index + 1] = __spreadProps(__spreadValues({}, next), { start: newEnd });
|
|
1222
|
+
let current = index + 1;
|
|
1223
|
+
while (current < updated.length - 1) {
|
|
1224
|
+
const pushed = updated[current];
|
|
1225
|
+
const following = updated[current + 1];
|
|
1226
|
+
if (pushed.end > following.start) {
|
|
1227
|
+
updated[current + 1] = __spreadProps(__spreadValues({}, following), { start: pushed.end });
|
|
1228
|
+
current++;
|
|
1229
|
+
} else {
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return unlessUnchanged(list, updated);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// src/hooks/useAnnotationKeyboardControls.ts
|
|
1096
1239
|
var TIME_DELTA = 0.01;
|
|
1240
|
+
var NO_ANNOTATIONS = Object.freeze([]);
|
|
1241
|
+
var noSubscription = () => () => {
|
|
1242
|
+
};
|
|
1243
|
+
var noAnnotations = () => NO_ANNOTATIONS;
|
|
1097
1244
|
function useAnnotationKeyboardControls({
|
|
1098
|
-
|
|
1245
|
+
store,
|
|
1099
1246
|
activeAnnotationId,
|
|
1100
|
-
onAnnotationsChange,
|
|
1101
1247
|
onActiveAnnotationChange,
|
|
1102
1248
|
duration,
|
|
1103
1249
|
linkEndpoints,
|
|
@@ -1108,6 +1254,15 @@ function useAnnotationKeyboardControls({
|
|
|
1108
1254
|
samplesPerPixel: samplesPerPixelProp,
|
|
1109
1255
|
sampleRate: sampleRateProp
|
|
1110
1256
|
}) {
|
|
1257
|
+
const source = (0, import_react16.useMemo)(
|
|
1258
|
+
() => store ? {
|
|
1259
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1260
|
+
getSnapshot: () => store.getAnnotations()
|
|
1261
|
+
} : { subscribe: noSubscription, getSnapshot: noAnnotations },
|
|
1262
|
+
[store]
|
|
1263
|
+
);
|
|
1264
|
+
const stored = (0, import_react16.useSyncExternalStore)(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1265
|
+
const annotations = stored;
|
|
1111
1266
|
const playlistView = usePlaylistViewOptional();
|
|
1112
1267
|
const playlistZoom = usePlaylistZoomOptional();
|
|
1113
1268
|
const samplesPerPixel = samplesPerPixelProp != null ? samplesPerPixelProp : playlistZoom == null ? void 0 : playlistZoom.samplesPerPixel;
|
|
@@ -1146,92 +1301,21 @@ function useAnnotationKeyboardControls({
|
|
|
1146
1301
|
}, [activeAnnotationId, scrollToAnnotation, scrollContainerRef, samplesPerPixel, sampleRate]);
|
|
1147
1302
|
const moveStartBoundary = (0, import_react16.useCallback)(
|
|
1148
1303
|
(delta) => {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const actualDelta = newStart - annotation.start;
|
|
1153
|
-
const updatedAnnotations = [...annotations];
|
|
1154
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1155
|
-
start: newStart
|
|
1304
|
+
store == null ? void 0 : store.update((current) => {
|
|
1305
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1306
|
+
return index < 0 ? current : moveAnnotationStart(current, index, delta, { linkEndpoints });
|
|
1156
1307
|
});
|
|
1157
|
-
if (linkEndpoints && activeIndex > 0) {
|
|
1158
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1159
|
-
if (Math.abs(prevAnnotation.end - annotation.start) < LINK_THRESHOLD) {
|
|
1160
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1161
|
-
end: Math.max(prevAnnotation.start + 0.1, prevAnnotation.end + actualDelta)
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
} else if (!linkEndpoints && activeIndex > 0) {
|
|
1165
|
-
const prevAnnotation = updatedAnnotations[activeIndex - 1];
|
|
1166
|
-
if (newStart < prevAnnotation.end) {
|
|
1167
|
-
updatedAnnotations[activeIndex - 1] = __spreadProps(__spreadValues({}, prevAnnotation), {
|
|
1168
|
-
end: newStart
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1173
1308
|
},
|
|
1174
|
-
[
|
|
1309
|
+
[store, activeAnnotationId, linkEndpoints]
|
|
1175
1310
|
);
|
|
1176
1311
|
const moveEndBoundary = (0, import_react16.useCallback)(
|
|
1177
1312
|
(delta) => {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
const actualDelta = newEnd - annotation.end;
|
|
1182
|
-
const updatedAnnotations = [...annotations];
|
|
1183
|
-
updatedAnnotations[activeIndex] = __spreadProps(__spreadValues({}, annotation), {
|
|
1184
|
-
end: newEnd
|
|
1313
|
+
store == null ? void 0 : store.update((current) => {
|
|
1314
|
+
const index = current.findIndex((a) => a.id === activeAnnotationId);
|
|
1315
|
+
return index < 0 ? current : moveAnnotationEnd(current, index, delta, { linkEndpoints, duration });
|
|
1185
1316
|
});
|
|
1186
|
-
if (linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1187
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1188
|
-
if (Math.abs(nextAnnotation.start - annotation.end) < LINK_THRESHOLD) {
|
|
1189
|
-
const newNextStart = Math.min(
|
|
1190
|
-
nextAnnotation.end - 0.1,
|
|
1191
|
-
nextAnnotation.start + actualDelta
|
|
1192
|
-
);
|
|
1193
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1194
|
-
start: newNextStart
|
|
1195
|
-
});
|
|
1196
|
-
let currentIndex = activeIndex + 1;
|
|
1197
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1198
|
-
const current = updatedAnnotations[currentIndex];
|
|
1199
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1200
|
-
if (Math.abs(next.start - annotations[currentIndex].end) < LINK_THRESHOLD) {
|
|
1201
|
-
const nextDelta = current.end - annotations[currentIndex].end;
|
|
1202
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1203
|
-
start: Math.min(next.end - 0.1, next.start + nextDelta)
|
|
1204
|
-
});
|
|
1205
|
-
currentIndex++;
|
|
1206
|
-
} else {
|
|
1207
|
-
break;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
} else if (!linkEndpoints && activeIndex < annotations.length - 1) {
|
|
1212
|
-
const nextAnnotation = updatedAnnotations[activeIndex + 1];
|
|
1213
|
-
if (newEnd > nextAnnotation.start) {
|
|
1214
|
-
updatedAnnotations[activeIndex + 1] = __spreadProps(__spreadValues({}, nextAnnotation), {
|
|
1215
|
-
start: newEnd
|
|
1216
|
-
});
|
|
1217
|
-
let currentIndex = activeIndex + 1;
|
|
1218
|
-
while (currentIndex < updatedAnnotations.length - 1) {
|
|
1219
|
-
const current = updatedAnnotations[currentIndex];
|
|
1220
|
-
const next = updatedAnnotations[currentIndex + 1];
|
|
1221
|
-
if (current.end > next.start) {
|
|
1222
|
-
updatedAnnotations[currentIndex + 1] = __spreadProps(__spreadValues({}, next), {
|
|
1223
|
-
start: current.end
|
|
1224
|
-
});
|
|
1225
|
-
currentIndex++;
|
|
1226
|
-
} else {
|
|
1227
|
-
break;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
onAnnotationsChange(updatedAnnotations);
|
|
1233
1317
|
},
|
|
1234
|
-
[
|
|
1318
|
+
[store, activeAnnotationId, duration, linkEndpoints]
|
|
1235
1319
|
);
|
|
1236
1320
|
const selectPrevious = (0, import_react16.useCallback)(() => {
|
|
1237
1321
|
if (!onActiveAnnotationChange || annotations.length === 0) return;
|
|
@@ -1775,6 +1859,36 @@ function useArrangementSources(arrangement) {
|
|
|
1775
1859
|
return (0, import_react21.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1776
1860
|
}
|
|
1777
1861
|
|
|
1862
|
+
// src/hooks/useCreateAnnotationStore.ts
|
|
1863
|
+
var import_react22 = require("react");
|
|
1864
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
1865
|
+
function useCreateAnnotationStore(init, options) {
|
|
1866
|
+
const beforeChange = options == null ? void 0 : options.beforeChange;
|
|
1867
|
+
const ruleRef = (0, import_react22.useRef)(beforeChange);
|
|
1868
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
1869
|
+
ruleRef.current = beforeChange;
|
|
1870
|
+
}, [beforeChange]);
|
|
1871
|
+
const [store] = (0, import_react22.useState)(
|
|
1872
|
+
() => (0, import_core4.createAnnotationStore)(init == null ? void 0 : init(), {
|
|
1873
|
+
beforeChange: (next, current) => ruleRef.current ? ruleRef.current(next, current) : next
|
|
1874
|
+
})
|
|
1875
|
+
);
|
|
1876
|
+
return store;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/hooks/useStoredAnnotations.ts
|
|
1880
|
+
var import_react23 = require("react");
|
|
1881
|
+
function useStoredAnnotations(store) {
|
|
1882
|
+
const source = (0, import_react23.useMemo)(
|
|
1883
|
+
() => ({
|
|
1884
|
+
subscribe: (listener) => store.subscribe(listener),
|
|
1885
|
+
getSnapshot: () => store.getAnnotations()
|
|
1886
|
+
}),
|
|
1887
|
+
[store]
|
|
1888
|
+
);
|
|
1889
|
+
return (0, import_react23.useSyncExternalStore)(source.subscribe, source.getSnapshot, source.getSnapshot);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1778
1892
|
// src/providerInternals/followAnnotations.ts
|
|
1779
1893
|
function followAnnotations({
|
|
1780
1894
|
annotations,
|
|
@@ -1805,8 +1919,8 @@ function followAnnotations({
|
|
|
1805
1919
|
}
|
|
1806
1920
|
|
|
1807
1921
|
// src/providerInternals/useAnnotationState.ts
|
|
1808
|
-
var
|
|
1809
|
-
var
|
|
1922
|
+
var import_react24 = require("react");
|
|
1923
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
1810
1924
|
|
|
1811
1925
|
// src/utils/annotationLookup.ts
|
|
1812
1926
|
var contains = (annotation, time) => time >= annotation.start && time < annotation.end;
|
|
@@ -1861,20 +1975,11 @@ function createAnnotationLookup() {
|
|
|
1861
1975
|
};
|
|
1862
1976
|
}
|
|
1863
1977
|
|
|
1864
|
-
// src/utils/isDevelopmentBuild.ts
|
|
1865
|
-
function isDevelopmentBuild() {
|
|
1866
|
-
try {
|
|
1867
|
-
return process.env.NODE_ENV !== "production";
|
|
1868
|
-
} catch (e) {
|
|
1869
|
-
return false;
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
1978
|
// src/providerInternals/useAnnotationState.ts
|
|
1874
1979
|
function useFollowedOption(prop) {
|
|
1875
1980
|
const wanted = prop != null ? prop : false;
|
|
1876
|
-
const [value, setValue] = (0,
|
|
1877
|
-
const [seen, setSeen] = (0,
|
|
1981
|
+
const [value, setValue] = (0, import_react24.useState)(wanted);
|
|
1982
|
+
const [seen, setSeen] = (0, import_react24.useState)(wanted);
|
|
1878
1983
|
if (seen !== wanted) {
|
|
1879
1984
|
setSeen(wanted);
|
|
1880
1985
|
setValue(wanted);
|
|
@@ -1882,39 +1987,45 @@ function useFollowedOption(prop) {
|
|
|
1882
1987
|
}
|
|
1883
1988
|
return [value, setValue];
|
|
1884
1989
|
}
|
|
1990
|
+
var NO_ANNOTATIONS2 = Object.freeze([]);
|
|
1991
|
+
var noSubscription2 = () => () => {
|
|
1992
|
+
};
|
|
1993
|
+
var noAnnotations2 = () => NO_ANNOTATIONS2;
|
|
1885
1994
|
function useAnnotationState({
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
providerName
|
|
1995
|
+
annotationStore,
|
|
1996
|
+
annotationList
|
|
1889
1997
|
}) {
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
const
|
|
1998
|
+
const source = (0, import_react24.useMemo)(
|
|
1999
|
+
() => annotationStore ? {
|
|
2000
|
+
subscribe: (listener) => annotationStore.subscribe(listener),
|
|
2001
|
+
getSnapshot: () => annotationStore.getAnnotations()
|
|
2002
|
+
} : { subscribe: noSubscription2, getSnapshot: noAnnotations2 },
|
|
2003
|
+
[annotationStore]
|
|
2004
|
+
);
|
|
2005
|
+
const annotations = (0, import_react24.useSyncExternalStore)(
|
|
2006
|
+
source.subscribe,
|
|
2007
|
+
source.getSnapshot,
|
|
2008
|
+
source.getSnapshot
|
|
2009
|
+
);
|
|
2010
|
+
const storeRef = (0, import_react24.useRef)(annotationStore);
|
|
2011
|
+
storeRef.current = annotationStore;
|
|
2012
|
+
const getAnnotations = (0, import_react24.useCallback)(
|
|
2013
|
+
() => storeRef.current ? storeRef.current.getAnnotations() : NO_ANNOTATIONS2,
|
|
2014
|
+
[]
|
|
2015
|
+
);
|
|
2016
|
+
const [annotationLookup] = (0, import_react24.useState)(() => createAnnotationLookup());
|
|
2017
|
+
const [activeAnnotationId, setActiveAnnotationIdState] = (0, import_react24.useState)(null);
|
|
2018
|
+
const activeAnnotationIdRef = (0, import_react24.useRef)(null);
|
|
2019
|
+
const setActiveAnnotationId = (0, import_react24.useCallback)((value) => {
|
|
1909
2020
|
activeAnnotationIdRef.current = value;
|
|
1910
2021
|
setActiveAnnotationIdState(value);
|
|
1911
2022
|
}, []);
|
|
1912
2023
|
const [continuousPlay, setContinuousPlayState] = useFollowedOption(
|
|
1913
2024
|
annotationList == null ? void 0 : annotationList.isContinuousPlay
|
|
1914
2025
|
);
|
|
1915
|
-
const continuousPlayRef = (0,
|
|
2026
|
+
const continuousPlayRef = (0, import_react24.useRef)(continuousPlay);
|
|
1916
2027
|
continuousPlayRef.current = continuousPlay;
|
|
1917
|
-
const setContinuousPlay = (0,
|
|
2028
|
+
const setContinuousPlay = (0, import_react24.useCallback)(
|
|
1918
2029
|
(value) => {
|
|
1919
2030
|
continuousPlayRef.current = value;
|
|
1920
2031
|
setContinuousPlayState(value);
|
|
@@ -1923,36 +2034,18 @@ function useAnnotationState({
|
|
|
1923
2034
|
);
|
|
1924
2035
|
const [editable, setAnnotationsEditable] = useFollowedOption(annotationList == null ? void 0 : annotationList.editable);
|
|
1925
2036
|
const [linkEndpoints, setLinkEndpoints] = useFollowedOption(annotationList == null ? void 0 : annotationList.linkEndpoints);
|
|
1926
|
-
const annotationsValue = (0,
|
|
1927
|
-
const annotationOptionsValue = (0,
|
|
2037
|
+
const annotationsValue = (0, import_react24.useMemo)(() => ({ annotations }), [annotations]);
|
|
2038
|
+
const annotationOptionsValue = (0, import_react24.useMemo)(
|
|
1928
2039
|
() => ({ editable, linkEndpoints, continuousPlay }),
|
|
1929
2040
|
[editable, linkEndpoints, continuousPlay]
|
|
1930
2041
|
);
|
|
1931
|
-
const [annotationPreview] = (0,
|
|
1932
|
-
() => (0,
|
|
1933
|
-
);
|
|
1934
|
-
const onAnnotationsChangeRef = (0, import_react22.useRef)(onAnnotationsChange);
|
|
1935
|
-
onAnnotationsChangeRef.current = onAnnotationsChange;
|
|
1936
|
-
const setAnnotations = (0, import_react22.useCallback)(
|
|
1937
|
-
(action) => {
|
|
1938
|
-
const updated = typeof action === "function" ? action(annotationsRef.current) : action;
|
|
1939
|
-
if (!onAnnotationsChangeRef.current) {
|
|
1940
|
-
if (isDevelopmentBuild()) {
|
|
1941
|
-
console.warn(
|
|
1942
|
-
"waveform-playlist: setAnnotations was called but no onAnnotationsChange callback is provided. Annotation edits will not persist. Pass onAnnotationsChange to " + providerName + " to handle annotation updates."
|
|
1943
|
-
);
|
|
1944
|
-
}
|
|
1945
|
-
return;
|
|
1946
|
-
}
|
|
1947
|
-
onAnnotationsChangeRef.current(updated);
|
|
1948
|
-
},
|
|
1949
|
-
[providerName]
|
|
2042
|
+
const [annotationPreview] = (0, import_react24.useState)(
|
|
2043
|
+
() => (0, import_core5.createValueSource)(null)
|
|
1950
2044
|
);
|
|
1951
2045
|
return {
|
|
1952
2046
|
annotations,
|
|
1953
|
-
|
|
2047
|
+
getAnnotations,
|
|
1954
2048
|
annotationLookup,
|
|
1955
|
-
setAnnotations,
|
|
1956
2049
|
annotationPreview,
|
|
1957
2050
|
activeAnnotationId,
|
|
1958
2051
|
activeAnnotationIdRef,
|
|
@@ -1968,16 +2061,16 @@ function useAnnotationState({
|
|
|
1968
2061
|
}
|
|
1969
2062
|
|
|
1970
2063
|
// src/providerInternals/useFrameCallbacks.ts
|
|
1971
|
-
var
|
|
2064
|
+
var import_react25 = require("react");
|
|
1972
2065
|
function useFrameCallbacks() {
|
|
1973
|
-
const callbacksRef = (0,
|
|
1974
|
-
const registerFrameCallback = (0,
|
|
2066
|
+
const callbacksRef = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
2067
|
+
const registerFrameCallback = (0, import_react25.useCallback)((id, cb) => {
|
|
1975
2068
|
callbacksRef.current.set(id, cb);
|
|
1976
2069
|
}, []);
|
|
1977
|
-
const unregisterFrameCallback = (0,
|
|
2070
|
+
const unregisterFrameCallback = (0, import_react25.useCallback)((id) => {
|
|
1978
2071
|
callbacksRef.current.delete(id);
|
|
1979
2072
|
}, []);
|
|
1980
|
-
const runFrameCallbacks = (0,
|
|
2073
|
+
const runFrameCallbacks = (0, import_react25.useCallback)((data) => {
|
|
1981
2074
|
for (const cb of callbacksRef.current.values()) {
|
|
1982
2075
|
cb(data);
|
|
1983
2076
|
}
|
|
@@ -1986,19 +2079,19 @@ function useFrameCallbacks() {
|
|
|
1986
2079
|
}
|
|
1987
2080
|
|
|
1988
2081
|
// src/providerInternals/useScrollFollow.ts
|
|
1989
|
-
var
|
|
2082
|
+
var import_react26 = require("react");
|
|
1990
2083
|
function centrePlayhead(container, time, sampleRate, samplesPerPixel) {
|
|
1991
2084
|
const pixelPosition = time * sampleRate / samplesPerPixel;
|
|
1992
2085
|
container.scrollLeft = Math.round(Math.max(0, pixelPosition - container.clientWidth / 2));
|
|
1993
2086
|
}
|
|
1994
2087
|
function useScrollFollow(initialAutomaticScroll) {
|
|
1995
|
-
const scrollContainerRef = (0,
|
|
1996
|
-
const [isAutomaticScroll, setIsAutomaticScroll] = (0,
|
|
1997
|
-
const isAutomaticScrollRef = (0,
|
|
1998
|
-
const setScrollContainer = (0,
|
|
2088
|
+
const scrollContainerRef = (0, import_react26.useRef)(null);
|
|
2089
|
+
const [isAutomaticScroll, setIsAutomaticScroll] = (0, import_react26.useState)(initialAutomaticScroll);
|
|
2090
|
+
const isAutomaticScrollRef = (0, import_react26.useRef)(initialAutomaticScroll);
|
|
2091
|
+
const setScrollContainer = (0, import_react26.useCallback)((element) => {
|
|
1999
2092
|
scrollContainerRef.current = element;
|
|
2000
2093
|
}, []);
|
|
2001
|
-
const setAutomaticScroll = (0,
|
|
2094
|
+
const setAutomaticScroll = (0, import_react26.useCallback)((enabled) => {
|
|
2002
2095
|
isAutomaticScrollRef.current = enabled;
|
|
2003
2096
|
setIsAutomaticScroll(enabled);
|
|
2004
2097
|
}, []);
|
|
@@ -2012,11 +2105,11 @@ function useScrollFollow(initialAutomaticScroll) {
|
|
|
2012
2105
|
}
|
|
2013
2106
|
|
|
2014
2107
|
// src/providerInternals/useMergedTheme.ts
|
|
2015
|
-
var
|
|
2108
|
+
var import_react28 = require("react");
|
|
2016
2109
|
var import_ui_components2 = require("@waveform-playlist/ui-components");
|
|
2017
2110
|
|
|
2018
2111
|
// src/hooks/useShallowStable.ts
|
|
2019
|
-
var
|
|
2112
|
+
var import_react27 = require("react");
|
|
2020
2113
|
function shallowEqual(a, b) {
|
|
2021
2114
|
if (a === b) return true;
|
|
2022
2115
|
const aKeys = Object.keys(a);
|
|
@@ -2029,7 +2122,7 @@ function shallowEqual(a, b) {
|
|
|
2029
2122
|
);
|
|
2030
2123
|
}
|
|
2031
2124
|
function useShallowStable(value) {
|
|
2032
|
-
const ref = (0,
|
|
2125
|
+
const ref = (0, import_react27.useRef)(value);
|
|
2033
2126
|
const previous = ref.current;
|
|
2034
2127
|
if (previous !== value) {
|
|
2035
2128
|
if (previous === void 0 || value === void 0 || !shallowEqual(previous, value)) {
|
|
@@ -2042,12 +2135,12 @@ function useShallowStable(value) {
|
|
|
2042
2135
|
// src/providerInternals/useMergedTheme.ts
|
|
2043
2136
|
function useMergedTheme(themeProp) {
|
|
2044
2137
|
const userTheme = useShallowStable(themeProp);
|
|
2045
|
-
return (0,
|
|
2138
|
+
return (0, import_react28.useMemo)(() => __spreadValues(__spreadValues({}, import_ui_components2.defaultTheme), userTheme), [userTheme]);
|
|
2046
2139
|
}
|
|
2047
2140
|
|
|
2048
2141
|
// src/providerInternals/useTrimPreview.ts
|
|
2049
|
-
var
|
|
2050
|
-
var
|
|
2142
|
+
var import_react29 = require("react");
|
|
2143
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
2051
2144
|
|
|
2052
2145
|
// src/waveformDataLoader.ts
|
|
2053
2146
|
var import_waveform_data2 = __toESM(require("waveform-data"));
|
|
@@ -2345,19 +2438,19 @@ function previewedClipPeaks(preview, { tracks, peaksOptions, peaksCacheRef }) {
|
|
|
2345
2438
|
return clipPeaksFor(previewed, track.name, peaksOptions, previous).clipPeaks;
|
|
2346
2439
|
}
|
|
2347
2440
|
function useTrimPreview(inputs) {
|
|
2348
|
-
const [trimPreview] = (0,
|
|
2349
|
-
() => (0,
|
|
2441
|
+
const [trimPreview] = (0, import_react29.useState)(
|
|
2442
|
+
() => (0, import_core6.createValueSource)(null)
|
|
2350
2443
|
);
|
|
2351
|
-
const inputsRef = (0,
|
|
2444
|
+
const inputsRef = (0, import_react29.useRef)(inputs);
|
|
2352
2445
|
inputsRef.current = inputs;
|
|
2353
|
-
const [trimPreviewPeaks] = (0,
|
|
2446
|
+
const [trimPreviewPeaks] = (0, import_react29.useState)(() => ({
|
|
2354
2447
|
peaksFor: (preview) => previewedClipPeaks(preview, inputsRef.current)
|
|
2355
2448
|
}));
|
|
2356
2449
|
return { trimPreview, trimPreviewPeaks };
|
|
2357
2450
|
}
|
|
2358
2451
|
|
|
2359
2452
|
// src/providerInternals/useEngineLifetime.ts
|
|
2360
|
-
var
|
|
2453
|
+
var import_react30 = require("react");
|
|
2361
2454
|
var import_engine4 = require("@waveform-playlist/engine");
|
|
2362
2455
|
|
|
2363
2456
|
// src/utils/installCommand.ts
|
|
@@ -2480,30 +2573,30 @@ function reportBuildFailure(ctx, run, engine, error) {
|
|
|
2480
2573
|
onError == null ? void 0 : onError(error instanceof Error ? error : new Error(String(error)));
|
|
2481
2574
|
}
|
|
2482
2575
|
function useKnownSampleRate(sampleRateProp) {
|
|
2483
|
-
const [sampleRate, setSampleRateState] = (0,
|
|
2576
|
+
const [sampleRate, setSampleRateState] = (0, import_react30.useState)(
|
|
2484
2577
|
() => sampleRateProp != null ? sampleRateProp : PROVISIONAL_SAMPLE_RATE
|
|
2485
2578
|
);
|
|
2486
|
-
const [isSampleRateKnown, setIsSampleRateKnown] = (0,
|
|
2487
|
-
const setSampleRate = (0,
|
|
2579
|
+
const [isSampleRateKnown, setIsSampleRateKnown] = (0, import_react30.useState)(() => sampleRateProp !== void 0);
|
|
2580
|
+
const setSampleRate = (0, import_react30.useCallback)((rate) => {
|
|
2488
2581
|
setSampleRateState(rate);
|
|
2489
2582
|
setIsSampleRateKnown(true);
|
|
2490
2583
|
}, []);
|
|
2491
2584
|
return { sampleRate, isSampleRateKnown, setSampleRate };
|
|
2492
2585
|
}
|
|
2493
2586
|
function useDecodeContext(arrangement, adapterRef) {
|
|
2494
|
-
const arrivalRef = (0,
|
|
2495
|
-
const getDecodeContext = (0,
|
|
2587
|
+
const arrivalRef = (0, import_react30.useRef)(null);
|
|
2588
|
+
const getDecodeContext = (0, import_react30.useCallback)(() => __async(null, null, function* () {
|
|
2496
2589
|
var _a;
|
|
2497
2590
|
const adapter = adapterRef.current;
|
|
2498
2591
|
if (adapter) return adapter.audioContext;
|
|
2499
2592
|
(_a = arrivalRef.current) != null ? _a : arrivalRef.current = deferred();
|
|
2500
2593
|
return arrivalRef.current.promise;
|
|
2501
2594
|
}), [adapterRef]);
|
|
2502
|
-
(0,
|
|
2595
|
+
(0, import_react30.useEffect)(
|
|
2503
2596
|
() => (0, import_engine4.attachDecodeContext)(arrangement, getDecodeContext),
|
|
2504
2597
|
[arrangement, getDecodeContext]
|
|
2505
2598
|
);
|
|
2506
|
-
return (0,
|
|
2599
|
+
return (0, import_react30.useCallback)((adapter) => {
|
|
2507
2600
|
const arrival = arrivalRef.current;
|
|
2508
2601
|
arrivalRef.current = null;
|
|
2509
2602
|
arrival == null ? void 0 : arrival.resolve(adapter.audioContext);
|
|
@@ -2511,7 +2604,7 @@ function useDecodeContext(arrangement, adapterRef) {
|
|
|
2511
2604
|
}
|
|
2512
2605
|
function useDisposeKeepingPlayback(refs) {
|
|
2513
2606
|
const { engineRef, adapterRef, pendingResumeRef, latest } = refs;
|
|
2514
|
-
return (0,
|
|
2607
|
+
return (0, import_react30.useCallback)(() => {
|
|
2515
2608
|
var _a;
|
|
2516
2609
|
const engine = engineRef.current;
|
|
2517
2610
|
if (!engine) return;
|
|
@@ -2528,23 +2621,23 @@ function useDisposeKeepingPlayback(refs) {
|
|
|
2528
2621
|
}
|
|
2529
2622
|
function useEngineLifetime(options) {
|
|
2530
2623
|
const { arrangement, effects, zoomLevels, sampleRateProp } = options;
|
|
2531
|
-
const latest = (0,
|
|
2532
|
-
(0,
|
|
2624
|
+
const latest = (0, import_react30.useRef)(options);
|
|
2625
|
+
(0, import_react30.useLayoutEffect)(() => {
|
|
2533
2626
|
latest.current = options;
|
|
2534
2627
|
});
|
|
2535
|
-
const stableZoomLevels = (0,
|
|
2628
|
+
const stableZoomLevels = (0, import_react30.useMemo)(
|
|
2536
2629
|
() => zoomLevels,
|
|
2537
2630
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2538
2631
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
2539
2632
|
);
|
|
2540
|
-
const engineRef = (0,
|
|
2541
|
-
const adapterRef = (0,
|
|
2542
|
-
const engineBuildInFlightRef = (0,
|
|
2543
|
-
const pendingResumeRef = (0,
|
|
2544
|
-
const audioInitializedRef = (0,
|
|
2545
|
-
const [engineEpoch, setEngineEpoch] = (0,
|
|
2546
|
-
const [isEngineAttached, setIsEngineAttached] = (0,
|
|
2547
|
-
const bumpEngineEpoch = (0,
|
|
2633
|
+
const engineRef = (0, import_react30.useRef)(null);
|
|
2634
|
+
const adapterRef = (0, import_react30.useRef)(null);
|
|
2635
|
+
const engineBuildInFlightRef = (0, import_react30.useRef)(false);
|
|
2636
|
+
const pendingResumeRef = (0, import_react30.useRef)(null);
|
|
2637
|
+
const audioInitializedRef = (0, import_react30.useRef)(false);
|
|
2638
|
+
const [engineEpoch, setEngineEpoch] = (0, import_react30.useState)(0);
|
|
2639
|
+
const [isEngineAttached, setIsEngineAttached] = (0, import_react30.useState)(false);
|
|
2640
|
+
const bumpEngineEpoch = (0, import_react30.useCallback)(() => setEngineEpoch((epoch) => epoch + 1), []);
|
|
2548
2641
|
const { sampleRate, isSampleRateKnown, setSampleRate } = useKnownSampleRate(sampleRateProp);
|
|
2549
2642
|
const onAssigned = useDecodeContext(arrangement, adapterRef);
|
|
2550
2643
|
const disposeEngineKeepingPlayback = useDisposeKeepingPlayback({
|
|
@@ -2553,7 +2646,7 @@ function useEngineLifetime(options) {
|
|
|
2553
2646
|
pendingResumeRef,
|
|
2554
2647
|
latest
|
|
2555
2648
|
});
|
|
2556
|
-
(0,
|
|
2649
|
+
(0, import_react30.useEffect)(() => {
|
|
2557
2650
|
const run = { cancelled: false };
|
|
2558
2651
|
engineBuildInFlightRef.current = true;
|
|
2559
2652
|
setIsEngineAttached(false);
|
|
@@ -2612,8 +2705,8 @@ function useEngineLifetime(options) {
|
|
|
2612
2705
|
}
|
|
2613
2706
|
|
|
2614
2707
|
// src/providerInternals/useArrangementView.ts
|
|
2615
|
-
var
|
|
2616
|
-
var
|
|
2708
|
+
var import_react31 = require("react");
|
|
2709
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
2617
2710
|
|
|
2618
2711
|
// src/utils/placeholderPeaks.ts
|
|
2619
2712
|
var memo = /* @__PURE__ */ new WeakMap();
|
|
@@ -2704,11 +2797,11 @@ var EMPTY_STATES = { byTrackId: /* @__PURE__ */ new Map(), result: [] };
|
|
|
2704
2797
|
var DEFAULT_MIX = { volume: 1, muted: false, soloed: false, pan: 0 };
|
|
2705
2798
|
function rowFor(track, index, inputs) {
|
|
2706
2799
|
const loadedRow = inputs.loadedPeaks.result[index];
|
|
2707
|
-
if (!track.clips.some(
|
|
2800
|
+
if (!track.clips.some(import_core7.isLoadingClip)) return loadedRow;
|
|
2708
2801
|
const rate = inputs.placeholderSampleRate;
|
|
2709
2802
|
const row = [];
|
|
2710
2803
|
for (const clip of track.clips) {
|
|
2711
|
-
if (!(0,
|
|
2804
|
+
if (!(0, import_core7.isLoadingClip)(clip)) {
|
|
2712
2805
|
const entry = inputs.loadedPeaks.clips.get(clip.id);
|
|
2713
2806
|
if (entry) row.push(entry.clipPeaks);
|
|
2714
2807
|
continue;
|
|
@@ -2756,14 +2849,14 @@ function deriveTrackStates(tracks, mixer, previous) {
|
|
|
2756
2849
|
return { byTrackId, result: sameItems(previous.result, states) ? previous.result : states };
|
|
2757
2850
|
}
|
|
2758
2851
|
function useArrangementValue(arrangement, read) {
|
|
2759
|
-
const store = (0,
|
|
2852
|
+
const store = (0, import_react31.useMemo)(
|
|
2760
2853
|
() => ({
|
|
2761
2854
|
subscribe: (listener) => arrangement.subscribe(listener),
|
|
2762
2855
|
getSnapshot: () => read(arrangement)
|
|
2763
2856
|
}),
|
|
2764
2857
|
[arrangement, read]
|
|
2765
2858
|
);
|
|
2766
|
-
return (0,
|
|
2859
|
+
return (0, import_react31.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2767
2860
|
}
|
|
2768
2861
|
var readMixer = (arrangement) => arrangement.getMixer();
|
|
2769
2862
|
var readCanUndo = (arrangement) => arrangement.canUndo;
|
|
@@ -2774,33 +2867,33 @@ function useArrangementView(arrangement, options) {
|
|
|
2774
2867
|
const mixer = useArrangementValue(arrangement, readMixer);
|
|
2775
2868
|
const canUndo = useArrangementValue(arrangement, readCanUndo);
|
|
2776
2869
|
const canRedo = useArrangementValue(arrangement, readCanRedo);
|
|
2777
|
-
const loadedCacheRef = (0,
|
|
2778
|
-
const tracks = (0,
|
|
2870
|
+
const loadedCacheRef = (0, import_react31.useRef)(EMPTY_LOADED_TRACKS);
|
|
2871
|
+
const tracks = (0, import_react31.useMemo)(() => {
|
|
2779
2872
|
const next = loadedTracks(arrangementTracks, loadedCacheRef.current);
|
|
2780
2873
|
loadedCacheRef.current = next.cache;
|
|
2781
2874
|
return next.tracks;
|
|
2782
2875
|
}, [arrangementTracks]);
|
|
2783
2876
|
const { getWaveformData, version } = useWaveformDataCache(tracks, baseScale);
|
|
2784
|
-
const peaksOptions = (0,
|
|
2877
|
+
const peaksOptions = (0, import_react31.useMemo)(
|
|
2785
2878
|
() => ({ samplesPerPixel, mono, getGeneratedWaveformData: getWaveformData }),
|
|
2786
2879
|
[samplesPerPixel, mono, getWaveformData]
|
|
2787
2880
|
);
|
|
2788
|
-
const peaksCacheRef = (0,
|
|
2789
|
-
const loadedPeaks = (0,
|
|
2881
|
+
const peaksCacheRef = (0, import_react31.useRef)(EMPTY_PEAKS_CACHE);
|
|
2882
|
+
const loadedPeaks = (0, import_react31.useMemo)(() => {
|
|
2790
2883
|
const next = derivePeaks(tracks, peaksOptions, peaksCacheRef.current);
|
|
2791
2884
|
peaksCacheRef.current = next;
|
|
2792
2885
|
return next;
|
|
2793
2886
|
}, [tracks, peaksOptions, version]);
|
|
2794
|
-
const rowsCacheRef = (0,
|
|
2795
|
-
const peaksDataArray = (0,
|
|
2887
|
+
const rowsCacheRef = (0, import_react31.useRef)(EMPTY_ROWS);
|
|
2888
|
+
const peaksDataArray = (0, import_react31.useMemo)(() => {
|
|
2796
2889
|
const inputs = { loadedPeaks, samplesPerPixel, mono, placeholderSampleRate };
|
|
2797
2890
|
const next = deriveRows(arrangementTracks, inputs, rowsCacheRef.current);
|
|
2798
2891
|
rowsCacheRef.current = next;
|
|
2799
2892
|
return next.result;
|
|
2800
2893
|
}, [arrangementTracks, loadedPeaks, samplesPerPixel, mono, placeholderSampleRate]);
|
|
2801
|
-
const duration = (0,
|
|
2802
|
-
const statesCacheRef = (0,
|
|
2803
|
-
const trackStates = (0,
|
|
2894
|
+
const duration = (0, import_react31.useMemo)(() => timelineDuration(tracks), [tracks]);
|
|
2895
|
+
const statesCacheRef = (0, import_react31.useRef)(EMPTY_STATES);
|
|
2896
|
+
const trackStates = (0, import_react31.useMemo)(() => {
|
|
2804
2897
|
const next = deriveTrackStates(arrangementTracks, mixer, statesCacheRef.current);
|
|
2805
2898
|
statesCacheRef.current = next;
|
|
2806
2899
|
return next.result;
|
|
@@ -2818,7 +2911,18 @@ function useArrangementView(arrangement, options) {
|
|
|
2818
2911
|
}
|
|
2819
2912
|
|
|
2820
2913
|
// src/providerInternals/useReadyOnce.ts
|
|
2821
|
-
var
|
|
2914
|
+
var import_react32 = require("react");
|
|
2915
|
+
|
|
2916
|
+
// src/utils/isDevelopmentBuild.ts
|
|
2917
|
+
function isDevelopmentBuild() {
|
|
2918
|
+
try {
|
|
2919
|
+
return process.env.NODE_ENV !== "production";
|
|
2920
|
+
} catch (e) {
|
|
2921
|
+
return false;
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
// src/providerInternals/useReadyOnce.ts
|
|
2822
2926
|
var READY_EVENT = "waveform-playlist:ready";
|
|
2823
2927
|
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().";
|
|
2824
2928
|
function callOnReady({
|
|
@@ -2837,15 +2941,15 @@ function callOnReady({
|
|
|
2837
2941
|
function useReadyOnce(options) {
|
|
2838
2942
|
const { isEngineAttached, arrangement, onReadyRef, onErrorRef, trackCount, duration } = options;
|
|
2839
2943
|
const { pendingCount } = useArrangementSources(arrangement);
|
|
2840
|
-
const [hasBeenReady, setHasBeenReady] = (0,
|
|
2841
|
-
const firedRef = (0,
|
|
2944
|
+
const [hasBeenReady, setHasBeenReady] = (0, import_react32.useState)(false);
|
|
2945
|
+
const firedRef = (0, import_react32.useRef)(false);
|
|
2842
2946
|
const isReady = isEngineAttached && (hasBeenReady || pendingCount === 0);
|
|
2843
|
-
const firstReadyRef = (0,
|
|
2844
|
-
const warnedPlayRef = (0,
|
|
2845
|
-
(0,
|
|
2947
|
+
const firstReadyRef = (0, import_react32.useRef)(false);
|
|
2948
|
+
const warnedPlayRef = (0, import_react32.useRef)(false);
|
|
2949
|
+
(0, import_react32.useInsertionEffect)(() => {
|
|
2846
2950
|
if (isReady) firstReadyRef.current = true;
|
|
2847
2951
|
}, [isReady]);
|
|
2848
|
-
const refusePlayBeforeFirstReady = (0,
|
|
2952
|
+
const refusePlayBeforeFirstReady = (0, import_react32.useCallback)(() => {
|
|
2849
2953
|
if (firstReadyRef.current) return false;
|
|
2850
2954
|
if (!warnedPlayRef.current && isDevelopmentBuild()) {
|
|
2851
2955
|
warnedPlayRef.current = true;
|
|
@@ -2853,7 +2957,7 @@ function useReadyOnce(options) {
|
|
|
2853
2957
|
}
|
|
2854
2958
|
return true;
|
|
2855
2959
|
}, []);
|
|
2856
|
-
(0,
|
|
2960
|
+
(0, import_react32.useEffect)(() => {
|
|
2857
2961
|
if (!isReady || firedRef.current) return;
|
|
2858
2962
|
firedRef.current = true;
|
|
2859
2963
|
setHasBeenReady(true);
|
|
@@ -2865,8 +2969,8 @@ function useReadyOnce(options) {
|
|
|
2865
2969
|
}
|
|
2866
2970
|
|
|
2867
2971
|
// src/providerInternals/useArrangementEditing.ts
|
|
2868
|
-
var
|
|
2869
|
-
var
|
|
2972
|
+
var import_react33 = require("react");
|
|
2973
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
2870
2974
|
|
|
2871
2975
|
// src/components/partWarnings.ts
|
|
2872
2976
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -2887,9 +2991,9 @@ function isTrackId(setter, trackId) {
|
|
|
2887
2991
|
return false;
|
|
2888
2992
|
}
|
|
2889
2993
|
function useRecordingActive(arrangement) {
|
|
2890
|
-
const recordingActiveRef = (0,
|
|
2891
|
-
const [armed] = (0,
|
|
2892
|
-
const setRecordingActive = (0,
|
|
2994
|
+
const recordingActiveRef = (0, import_react33.useRef)(false);
|
|
2995
|
+
const [armed] = (0, import_react33.useState)(() => (0, import_core8.createValueSource)(null));
|
|
2996
|
+
const setRecordingActive = (0, import_react33.useCallback)(
|
|
2893
2997
|
(active, armedTrackId2) => {
|
|
2894
2998
|
var _a, _b;
|
|
2895
2999
|
recordingActiveRef.current = active;
|
|
@@ -2907,51 +3011,51 @@ function useRecordingActive(arrangement) {
|
|
|
2907
3011
|
},
|
|
2908
3012
|
[arrangement, armed]
|
|
2909
3013
|
);
|
|
2910
|
-
(0,
|
|
3014
|
+
(0, import_react33.useEffect)(
|
|
2911
3015
|
() => () => {
|
|
2912
3016
|
if (armed.source.getSnapshot()) setRecordingActive(false);
|
|
2913
3017
|
},
|
|
2914
3018
|
[armed, setRecordingActive]
|
|
2915
3019
|
);
|
|
2916
|
-
const getArmedTrackId = (0,
|
|
3020
|
+
const getArmedTrackId = (0, import_react33.useCallback)(() => {
|
|
2917
3021
|
var _a, _b;
|
|
2918
3022
|
return (_b = (_a = armed.source.getSnapshot()) == null ? void 0 : _a.trackId) != null ? _b : null;
|
|
2919
3023
|
}, [armed]);
|
|
2920
|
-
const armedTrackId = (0,
|
|
2921
|
-
const recordingArm = (0,
|
|
3024
|
+
const armedTrackId = (0, import_react33.useSyncExternalStore)(armed.source.subscribe, getArmedTrackId);
|
|
3025
|
+
const recordingArm = (0, import_react33.useMemo)(() => ({ armedTrackId }), [armedTrackId]);
|
|
2922
3026
|
return { setRecordingActive, recordingActiveRef, recordingArm };
|
|
2923
3027
|
}
|
|
2924
3028
|
function useArrangementEditing(arrangement) {
|
|
2925
|
-
const setTrackMute = (0,
|
|
3029
|
+
const setTrackMute = (0, import_react33.useCallback)(
|
|
2926
3030
|
(trackId, muted) => {
|
|
2927
3031
|
if (isTrackId("setTrackMute", trackId)) arrangement.setTrackMute(trackId, muted);
|
|
2928
3032
|
},
|
|
2929
3033
|
[arrangement]
|
|
2930
3034
|
);
|
|
2931
|
-
const setTrackSolo = (0,
|
|
3035
|
+
const setTrackSolo = (0, import_react33.useCallback)(
|
|
2932
3036
|
(trackId, soloed) => {
|
|
2933
3037
|
if (isTrackId("setTrackSolo", trackId)) arrangement.setTrackSolo(trackId, soloed);
|
|
2934
3038
|
},
|
|
2935
3039
|
[arrangement]
|
|
2936
3040
|
);
|
|
2937
|
-
const setTrackVolume = (0,
|
|
3041
|
+
const setTrackVolume = (0, import_react33.useCallback)(
|
|
2938
3042
|
(trackId, volume) => {
|
|
2939
3043
|
if (isTrackId("setTrackVolume", trackId)) arrangement.setTrackVolume(trackId, volume);
|
|
2940
3044
|
},
|
|
2941
3045
|
[arrangement]
|
|
2942
3046
|
);
|
|
2943
|
-
const setTrackPan = (0,
|
|
3047
|
+
const setTrackPan = (0, import_react33.useCallback)(
|
|
2944
3048
|
(trackId, pan) => {
|
|
2945
3049
|
if (isTrackId("setTrackPan", trackId)) arrangement.setTrackPan(trackId, pan);
|
|
2946
3050
|
},
|
|
2947
3051
|
[arrangement]
|
|
2948
3052
|
);
|
|
2949
|
-
const reorderTrack = (0,
|
|
3053
|
+
const reorderTrack = (0, import_react33.useCallback)(
|
|
2950
3054
|
(trackId, toIndex) => arrangement.reorderTrack(trackId, toIndex),
|
|
2951
3055
|
[arrangement]
|
|
2952
3056
|
);
|
|
2953
|
-
const undo = (0,
|
|
2954
|
-
const redo = (0,
|
|
3057
|
+
const undo = (0, import_react33.useCallback)(() => arrangement.undo(), [arrangement]);
|
|
3058
|
+
const redo = (0, import_react33.useCallback)(() => arrangement.redo(), [arrangement]);
|
|
2955
3059
|
const { setRecordingActive, recordingActiveRef, recordingArm } = useRecordingActive(arrangement);
|
|
2956
3060
|
return {
|
|
2957
3061
|
setTrackMute,
|
|
@@ -2968,7 +3072,7 @@ function useArrangementEditing(arrangement) {
|
|
|
2968
3072
|
}
|
|
2969
3073
|
|
|
2970
3074
|
// src/providerInternals/arrangementIdentity.ts
|
|
2971
|
-
var
|
|
3075
|
+
var import_react34 = require("react");
|
|
2972
3076
|
var arrangementKeys = /* @__PURE__ */ new WeakMap();
|
|
2973
3077
|
var lastArrangementKey = 0;
|
|
2974
3078
|
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";
|
|
@@ -2987,9 +3091,9 @@ function keyOf(arrangement) {
|
|
|
2987
3091
|
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.";
|
|
2988
3092
|
function useArrangementKey(arrangement) {
|
|
2989
3093
|
const key = keyOf(arrangement);
|
|
2990
|
-
const firstKeyRef = (0,
|
|
2991
|
-
const warnedRef = (0,
|
|
2992
|
-
(0,
|
|
3094
|
+
const firstKeyRef = (0, import_react34.useRef)(key);
|
|
3095
|
+
const warnedRef = (0, import_react34.useRef)(false);
|
|
3096
|
+
(0, import_react34.useEffect)(() => {
|
|
2993
3097
|
if (key === firstKeyRef.current || warnedRef.current) return;
|
|
2994
3098
|
warnedRef.current = true;
|
|
2995
3099
|
if (isDevelopmentBuild()) console.warn(NEW_ARRANGEMENT_WARNING);
|
|
@@ -3013,12 +3117,12 @@ var ProviderOnArrangement = ({
|
|
|
3013
3117
|
zoomLevels,
|
|
3014
3118
|
automaticScroll = false,
|
|
3015
3119
|
theme: userThemeProp,
|
|
3120
|
+
annotationStore,
|
|
3016
3121
|
annotationList,
|
|
3017
3122
|
effects,
|
|
3018
3123
|
trackEffects,
|
|
3019
3124
|
onReady,
|
|
3020
3125
|
onError,
|
|
3021
|
-
onAnnotationsChange,
|
|
3022
3126
|
soundFontCache,
|
|
3023
3127
|
indefinitePlayback = false,
|
|
3024
3128
|
sampleRate: sampleRateProp,
|
|
@@ -3026,15 +3130,14 @@ var ProviderOnArrangement = ({
|
|
|
3026
3130
|
children
|
|
3027
3131
|
}) => {
|
|
3028
3132
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3029
|
-
const stableZoomLevels = (0,
|
|
3133
|
+
const stableZoomLevels = (0, import_react35.useMemo)(
|
|
3030
3134
|
() => zoomLevels,
|
|
3031
3135
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3032
3136
|
[zoomLevels == null ? void 0 : zoomLevels.join(",")]
|
|
3033
3137
|
);
|
|
3034
3138
|
const {
|
|
3035
|
-
|
|
3139
|
+
getAnnotations,
|
|
3036
3140
|
annotationLookup,
|
|
3037
|
-
setAnnotations,
|
|
3038
3141
|
annotationPreview,
|
|
3039
3142
|
activeAnnotationId,
|
|
3040
3143
|
activeAnnotationIdRef,
|
|
@@ -3047,9 +3150,8 @@ var ProviderOnArrangement = ({
|
|
|
3047
3150
|
annotationsValue,
|
|
3048
3151
|
annotationOptionsValue
|
|
3049
3152
|
} = useAnnotationState({
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
providerName: "WaveformPlaylistProvider"
|
|
3153
|
+
annotationStore,
|
|
3154
|
+
annotationList
|
|
3053
3155
|
});
|
|
3054
3156
|
const {
|
|
3055
3157
|
scrollContainerRef,
|
|
@@ -3059,65 +3161,65 @@ var ProviderOnArrangement = ({
|
|
|
3059
3161
|
setAutomaticScroll
|
|
3060
3162
|
} = useScrollFollow(automaticScroll);
|
|
3061
3163
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
3062
|
-
const [isPlaying, setIsPlaying] = (0,
|
|
3063
|
-
const [currentTime, setCurrentTime] = (0,
|
|
3064
|
-
const [trackReorderEpoch, setTrackReorderEpoch] = (0,
|
|
3065
|
-
const [trackDragPreview, setTrackDragPreview] = (0,
|
|
3066
|
-
const indefinitePlaybackRef = (0,
|
|
3164
|
+
const [isPlaying, setIsPlaying] = (0, import_react35.useState)(false);
|
|
3165
|
+
const [currentTime, setCurrentTime] = (0, import_react35.useState)(0);
|
|
3166
|
+
const [trackReorderEpoch, setTrackReorderEpoch] = (0, import_react35.useState)(0);
|
|
3167
|
+
const [trackDragPreview, setTrackDragPreview] = (0, import_react35.useState)(null);
|
|
3168
|
+
const indefinitePlaybackRef = (0, import_react35.useRef)(indefinitePlayback);
|
|
3067
3169
|
indefinitePlaybackRef.current = indefinitePlayback;
|
|
3068
|
-
const isPlayingRef = (0,
|
|
3170
|
+
const isPlayingRef = (0, import_react35.useRef)(false);
|
|
3069
3171
|
isPlayingRef.current = isPlaying;
|
|
3070
|
-
const playStartPositionRef = (0,
|
|
3071
|
-
const currentTimeRef = (0,
|
|
3072
|
-
const visualTimeRef = (0,
|
|
3073
|
-
const soundFontCacheRef = (0,
|
|
3172
|
+
const playStartPositionRef = (0, import_react35.useRef)(0);
|
|
3173
|
+
const currentTimeRef = (0, import_react35.useRef)(0);
|
|
3174
|
+
const visualTimeRef = (0, import_react35.useRef)(0);
|
|
3175
|
+
const soundFontCacheRef = (0, import_react35.useRef)(soundFontCache);
|
|
3074
3176
|
soundFontCacheRef.current = soundFontCache;
|
|
3075
|
-
const trackEffectsRef = (0,
|
|
3177
|
+
const trackEffectsRef = (0, import_react35.useRef)(trackEffects);
|
|
3076
3178
|
trackEffectsRef.current = trackEffects;
|
|
3077
|
-
const resolveTrackEffects = (0,
|
|
3179
|
+
const resolveTrackEffects = (0, import_react35.useCallback)(
|
|
3078
3180
|
(trackId) => {
|
|
3079
3181
|
var _a;
|
|
3080
3182
|
return (_a = trackEffectsRef.current) == null ? void 0 : _a.call(trackEffectsRef, trackId);
|
|
3081
3183
|
},
|
|
3082
3184
|
[]
|
|
3083
3185
|
);
|
|
3084
|
-
const onReadyRef = (0,
|
|
3085
|
-
const onErrorRef = (0,
|
|
3086
|
-
(0,
|
|
3186
|
+
const onReadyRef = (0, import_react35.useRef)(onReady);
|
|
3187
|
+
const onErrorRef = (0, import_react35.useRef)(onError);
|
|
3188
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
3087
3189
|
onReadyRef.current = onReady;
|
|
3088
3190
|
onErrorRef.current = onError;
|
|
3089
3191
|
});
|
|
3090
|
-
const playbackStartTimeRef = (0,
|
|
3091
|
-
const audioStartPositionRef = (0,
|
|
3092
|
-
const playbackEndTimeRef = (0,
|
|
3093
|
-
const suppressEngineStopMirrorRef = (0,
|
|
3094
|
-
const samplesPerPixelRef = (0,
|
|
3095
|
-
const isSelectionPlayRef = (0,
|
|
3096
|
-
const playRequestIdRef = (0,
|
|
3192
|
+
const playbackStartTimeRef = (0, import_react35.useRef)(0);
|
|
3193
|
+
const audioStartPositionRef = (0, import_react35.useRef)(0);
|
|
3194
|
+
const playbackEndTimeRef = (0, import_react35.useRef)(null);
|
|
3195
|
+
const suppressEngineStopMirrorRef = (0, import_react35.useRef)(false);
|
|
3196
|
+
const samplesPerPixelRef = (0, import_react35.useRef)(initialSamplesPerPixel);
|
|
3197
|
+
const isSelectionPlayRef = (0, import_react35.useRef)(false);
|
|
3198
|
+
const playRequestIdRef = (0, import_react35.useRef)(0);
|
|
3097
3199
|
const { animationFrameRef, startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3098
|
-
const onBuildFailure = (0,
|
|
3200
|
+
const onBuildFailure = (0, import_react35.useCallback)(() => {
|
|
3099
3201
|
if (!isPlayingRef.current) return;
|
|
3100
3202
|
setIsPlaying(false);
|
|
3101
3203
|
stopAnimationFrameLoop();
|
|
3102
3204
|
visualTimeRef.current = toVisualTime(currentTimeRef.current);
|
|
3103
3205
|
setCurrentTime(currentTimeRef.current);
|
|
3104
3206
|
}, [stopAnimationFrameLoop]);
|
|
3105
|
-
const followersRef = (0,
|
|
3106
|
-
const seedEngine = (0,
|
|
3207
|
+
const followersRef = (0, import_react35.useRef)(null);
|
|
3208
|
+
const seedEngine = (0, import_react35.useCallback)(
|
|
3107
3209
|
(engine) => {
|
|
3108
3210
|
var _a;
|
|
3109
3211
|
return (_a = followersRef.current) == null ? void 0 : _a.seed(engine);
|
|
3110
3212
|
},
|
|
3111
3213
|
[]
|
|
3112
3214
|
);
|
|
3113
|
-
const onEngine = (0,
|
|
3215
|
+
const onEngine = (0, import_react35.useCallback)(
|
|
3114
3216
|
(engine) => {
|
|
3115
3217
|
var _a;
|
|
3116
3218
|
return (_a = followersRef.current) == null ? void 0 : _a.follow(engine);
|
|
3117
3219
|
},
|
|
3118
3220
|
[]
|
|
3119
3221
|
);
|
|
3120
|
-
const onEngineState = (0,
|
|
3222
|
+
const onEngineState = (0, import_react35.useCallback)(
|
|
3121
3223
|
(state) => {
|
|
3122
3224
|
var _a;
|
|
3123
3225
|
return (_a = followersRef.current) == null ? void 0 : _a.mirror(state);
|
|
@@ -3152,7 +3254,7 @@ var ProviderOnArrangement = ({
|
|
|
3152
3254
|
onErrorRef,
|
|
3153
3255
|
onBuildFailure
|
|
3154
3256
|
});
|
|
3155
|
-
const sampleRateRef = (0,
|
|
3257
|
+
const sampleRateRef = (0, import_react35.useRef)(sampleRate);
|
|
3156
3258
|
sampleRateRef.current = sampleRate;
|
|
3157
3259
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3158
3260
|
const zoom = useZoomControls({ engineRef, initialSamplesPerPixel });
|
|
@@ -3190,7 +3292,7 @@ var ProviderOnArrangement = ({
|
|
|
3190
3292
|
onEngineState: onSelectedTrackEngineState,
|
|
3191
3293
|
selectedTrackIdRef
|
|
3192
3294
|
} = useSelectedTrack({ engineRef });
|
|
3193
|
-
const baseScale = (0,
|
|
3295
|
+
const baseScale = (0, import_react35.useMemo)(
|
|
3194
3296
|
() => Math.min(...stableZoomLevels != null ? stableZoomLevels : [256, 512, 1024, 2048, 4096, 8192]),
|
|
3195
3297
|
[stableZoomLevels]
|
|
3196
3298
|
);
|
|
@@ -3201,7 +3303,7 @@ var ProviderOnArrangement = ({
|
|
|
3201
3303
|
placeholderSampleRate: isSampleRateKnown ? sampleRate : null
|
|
3202
3304
|
});
|
|
3203
3305
|
const { tracks, duration } = view;
|
|
3204
|
-
const durationRef = (0,
|
|
3306
|
+
const durationRef = (0, import_react35.useRef)(duration);
|
|
3205
3307
|
durationRef.current = duration;
|
|
3206
3308
|
const { isReady, refusePlayBeforeFirstReady } = useReadyOnce({
|
|
3207
3309
|
isEngineAttached,
|
|
@@ -3218,7 +3320,7 @@ var ProviderOnArrangement = ({
|
|
|
3218
3320
|
});
|
|
3219
3321
|
const editing = useArrangementEditing(arrangement);
|
|
3220
3322
|
const { recordingActiveRef } = editing;
|
|
3221
|
-
const setLoopRegionFromSelection = (0,
|
|
3323
|
+
const setLoopRegionFromSelection = (0, import_react35.useCallback)(() => {
|
|
3222
3324
|
var _a, _b;
|
|
3223
3325
|
const start = (_a = selectionStartRef.current) != null ? _a : 0;
|
|
3224
3326
|
const end = (_b = selectionEndRef.current) != null ? _b : 0;
|
|
@@ -3226,7 +3328,7 @@ var ProviderOnArrangement = ({
|
|
|
3226
3328
|
setLoopRegion(start, end);
|
|
3227
3329
|
}
|
|
3228
3330
|
}, [setLoopRegion, selectionStartRef, selectionEndRef]);
|
|
3229
|
-
(0,
|
|
3331
|
+
(0, import_react35.useEffect)(() => {
|
|
3230
3332
|
if (!scrollContainerRef.current || duration === 0) return;
|
|
3231
3333
|
const container = scrollContainerRef.current;
|
|
3232
3334
|
const oldSamplesPerPixel = samplesPerPixelRef.current;
|
|
@@ -3242,10 +3344,10 @@ var ProviderOnArrangement = ({
|
|
|
3242
3344
|
container.scrollLeft = newScrollLeft;
|
|
3243
3345
|
samplesPerPixelRef.current = newSamplesPerPixel;
|
|
3244
3346
|
}, [samplesPerPixel, duration, scrollContainerRef]);
|
|
3245
|
-
(0,
|
|
3347
|
+
(0, import_react35.useEffect)(() => {
|
|
3246
3348
|
syncSoundFontCacheToAdapter(adapterRef.current, soundFontCache);
|
|
3247
3349
|
}, [soundFontCache, adapterRef]);
|
|
3248
|
-
(0,
|
|
3350
|
+
(0, import_react35.useEffect)(() => {
|
|
3249
3351
|
for (const track of tracks) {
|
|
3250
3352
|
for (const clip of track.clips) {
|
|
3251
3353
|
if (!clip.audioBuffer && !clip.waveformData && !clip.midiNotes) {
|
|
@@ -3254,15 +3356,15 @@ var ProviderOnArrangement = ({
|
|
|
3254
3356
|
}
|
|
3255
3357
|
}
|
|
3256
3358
|
}, [tracks]);
|
|
3257
|
-
const getAudioContextTime = (0,
|
|
3359
|
+
const getAudioContextTime = (0, import_react35.useCallback)(
|
|
3258
3360
|
() => {
|
|
3259
3361
|
var _a, _b;
|
|
3260
3362
|
return (_b = (_a = adapterRef.current) == null ? void 0 : _a.audioContext.currentTime) != null ? _b : 0;
|
|
3261
3363
|
},
|
|
3262
3364
|
[adapterRef]
|
|
3263
3365
|
);
|
|
3264
|
-
const getPlaybackTimeFallbackWarnedRef = (0,
|
|
3265
|
-
const getPlaybackTime = (0,
|
|
3366
|
+
const getPlaybackTimeFallbackWarnedRef = (0, import_react35.useRef)(false);
|
|
3367
|
+
const getPlaybackTime = (0, import_react35.useCallback)(() => {
|
|
3266
3368
|
var _a, _b;
|
|
3267
3369
|
if (engineRef.current) {
|
|
3268
3370
|
return engineRef.current.getCurrentTime();
|
|
@@ -3276,20 +3378,20 @@ var ProviderOnArrangement = ({
|
|
|
3276
3378
|
const elapsed = getAudioContextTime() - ((_a = playbackStartTimeRef.current) != null ? _a : 0);
|
|
3277
3379
|
return ((_b = audioStartPositionRef.current) != null ? _b : 0) + elapsed;
|
|
3278
3380
|
}, [getAudioContextTime, engineRef]);
|
|
3279
|
-
const setCurrentTimeRefs = (0,
|
|
3381
|
+
const setCurrentTimeRefs = (0, import_react35.useCallback)((rawTime) => {
|
|
3280
3382
|
currentTimeRef.current = rawTime;
|
|
3281
3383
|
visualTimeRef.current = toVisualTime(rawTime);
|
|
3282
3384
|
}, []);
|
|
3283
|
-
const getLookAhead = (0,
|
|
3385
|
+
const getLookAhead = (0, import_react35.useCallback)(() => {
|
|
3284
3386
|
var _a, _b;
|
|
3285
3387
|
return (_b = (_a = engineRef.current) == null ? void 0 : _a.lookAhead) != null ? _b : 0;
|
|
3286
3388
|
}, [engineRef]);
|
|
3287
|
-
const getOutputLatency = (0,
|
|
3389
|
+
const getOutputLatency = (0, import_react35.useCallback)(() => {
|
|
3288
3390
|
var _a;
|
|
3289
3391
|
const audioCtx = (_a = adapterRef.current) == null ? void 0 : _a.audioContext;
|
|
3290
3392
|
return audioCtx && "outputLatency" in audioCtx ? audioCtx.outputLatency : 0;
|
|
3291
3393
|
}, [adapterRef]);
|
|
3292
|
-
const mirrorEngineStop = (0,
|
|
3394
|
+
const mirrorEngineStop = (0, import_react35.useCallback)(
|
|
3293
3395
|
(engine) => {
|
|
3294
3396
|
if (suppressEngineStopMirrorRef.current) return;
|
|
3295
3397
|
setIsPlaying(false);
|
|
@@ -3304,7 +3406,7 @@ var ProviderOnArrangement = ({
|
|
|
3304
3406
|
},
|
|
3305
3407
|
[stopAnimationFrameLoop, setCurrentTimeRefs]
|
|
3306
3408
|
);
|
|
3307
|
-
(0,
|
|
3409
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
3308
3410
|
const mirror = (state) => {
|
|
3309
3411
|
onSelectionEngineState(state);
|
|
3310
3412
|
onLoopEngineState(state);
|
|
@@ -3328,7 +3430,7 @@ var ProviderOnArrangement = ({
|
|
|
3328
3430
|
mirror
|
|
3329
3431
|
};
|
|
3330
3432
|
});
|
|
3331
|
-
const startAnimationLoop = (0,
|
|
3433
|
+
const startAnimationLoop = (0, import_react35.useCallback)(() => {
|
|
3332
3434
|
const updateTime = () => {
|
|
3333
3435
|
const time = getPlaybackTime();
|
|
3334
3436
|
currentTimeRef.current = time;
|
|
@@ -3345,7 +3447,7 @@ var ProviderOnArrangement = ({
|
|
|
3345
3447
|
};
|
|
3346
3448
|
runFrameCallbacks(frameData);
|
|
3347
3449
|
const activeAnnotationEnded = followAnnotations({
|
|
3348
|
-
annotations:
|
|
3450
|
+
annotations: getAnnotations(),
|
|
3349
3451
|
lookup: annotationLookup,
|
|
3350
3452
|
time,
|
|
3351
3453
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -3397,7 +3499,7 @@ var ProviderOnArrangement = ({
|
|
|
3397
3499
|
annotationLookup,
|
|
3398
3500
|
// Refs and a stable function from the shared provider hooks: they never
|
|
3399
3501
|
// change, and are listed because the linter cannot see that.
|
|
3400
|
-
|
|
3502
|
+
getAnnotations,
|
|
3401
3503
|
activeAnnotationIdRef,
|
|
3402
3504
|
continuousPlayRef,
|
|
3403
3505
|
isAutomaticScrollRef,
|
|
@@ -3407,8 +3509,8 @@ var ProviderOnArrangement = ({
|
|
|
3407
3509
|
recordingActiveRef
|
|
3408
3510
|
]);
|
|
3409
3511
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
3410
|
-
const prevContinuousPlayRef = (0,
|
|
3411
|
-
(0,
|
|
3512
|
+
const prevContinuousPlayRef = (0, import_react35.useRef)(continuousPlay);
|
|
3513
|
+
(0, import_react35.useEffect)(() => {
|
|
3412
3514
|
const continuousPlayTurnedOn = continuousPlay && !prevContinuousPlayRef.current && !isSelectionPlayRef.current;
|
|
3413
3515
|
prevContinuousPlayRef.current = continuousPlay;
|
|
3414
3516
|
const reschedulePlayback = () => __async(null, null, function* () {
|
|
@@ -3424,7 +3526,7 @@ var ProviderOnArrangement = ({
|
|
|
3424
3526
|
audioStartPositionRef.current = currentPos;
|
|
3425
3527
|
const boundedEnd = playbackEndTimeRef.current;
|
|
3426
3528
|
const activeId = activeAnnotationIdRef.current;
|
|
3427
|
-
const activeAnnotation = activeId ? annotationLookup.byId(
|
|
3529
|
+
const activeAnnotation = activeId ? annotationLookup.byId(getAnnotations(), activeId) : void 0;
|
|
3428
3530
|
const endsWithAnnotation = boundedEnd !== null && activeAnnotation !== void 0 && Math.abs(boundedEnd - activeAnnotation.end) < 1e-6;
|
|
3429
3531
|
const endTime = endsWithAnnotation ? null : boundedEnd;
|
|
3430
3532
|
playbackEndTimeRef.current = endTime;
|
|
@@ -3449,11 +3551,11 @@ var ProviderOnArrangement = ({
|
|
|
3449
3551
|
animationFrameRef,
|
|
3450
3552
|
getAudioContextTime,
|
|
3451
3553
|
annotationLookup,
|
|
3452
|
-
|
|
3554
|
+
getAnnotations,
|
|
3453
3555
|
activeAnnotationIdRef,
|
|
3454
3556
|
engineRef
|
|
3455
3557
|
]);
|
|
3456
|
-
(0,
|
|
3558
|
+
(0, import_react35.useEffect)(() => {
|
|
3457
3559
|
const resumePlayback = () => __async(null, null, function* () {
|
|
3458
3560
|
const engine = engineRef.current;
|
|
3459
3561
|
const request = pendingResumeRef.current;
|
|
@@ -3488,7 +3590,7 @@ var ProviderOnArrangement = ({
|
|
|
3488
3590
|
pendingResumeRef,
|
|
3489
3591
|
audioInitializedRef
|
|
3490
3592
|
]);
|
|
3491
|
-
const play = (0,
|
|
3593
|
+
const play = (0, import_react35.useCallback)(
|
|
3492
3594
|
(startTime, playDuration) => __async(null, null, function* () {
|
|
3493
3595
|
var _a, _b;
|
|
3494
3596
|
if (refusePlayBeforeFirstReady()) return;
|
|
@@ -3563,7 +3665,7 @@ var ProviderOnArrangement = ({
|
|
|
3563
3665
|
refusePlayBeforeFirstReady
|
|
3564
3666
|
]
|
|
3565
3667
|
);
|
|
3566
|
-
const pause = (0,
|
|
3668
|
+
const pause = (0, import_react35.useCallback)(() => {
|
|
3567
3669
|
pendingResumeRef.current = null;
|
|
3568
3670
|
playRequestIdRef.current += 1;
|
|
3569
3671
|
const engine = engineRef.current;
|
|
@@ -3574,7 +3676,7 @@ var ProviderOnArrangement = ({
|
|
|
3574
3676
|
setCurrentTimeRefs(pauseTime);
|
|
3575
3677
|
setCurrentTime(pauseTime);
|
|
3576
3678
|
}, [stopAnimationLoop, getPlaybackTime, setCurrentTimeRefs, engineRef, pendingResumeRef]);
|
|
3577
|
-
const stop = (0,
|
|
3679
|
+
const stop = (0, import_react35.useCallback)(() => {
|
|
3578
3680
|
var _a, _b;
|
|
3579
3681
|
pendingResumeRef.current = null;
|
|
3580
3682
|
playRequestIdRef.current += 1;
|
|
@@ -3586,7 +3688,7 @@ var ProviderOnArrangement = ({
|
|
|
3586
3688
|
setCurrentTime(playStartPositionRef.current);
|
|
3587
3689
|
setActiveAnnotationId(null);
|
|
3588
3690
|
}, [stopAnimationLoop, setActiveAnnotationId, setCurrentTimeRefs, engineRef, pendingResumeRef]);
|
|
3589
|
-
const seekTo = (0,
|
|
3691
|
+
const seekTo = (0, import_react35.useCallback)(
|
|
3590
3692
|
(time) => {
|
|
3591
3693
|
const pastEndAllowed = Number.isFinite(time) && (indefinitePlaybackRef.current || recordingActiveRef.current);
|
|
3592
3694
|
const upperLimit = pastEndAllowed ? Infinity : durationRef.current;
|
|
@@ -3599,10 +3701,10 @@ var ProviderOnArrangement = ({
|
|
|
3599
3701
|
},
|
|
3600
3702
|
[play, setCurrentTimeRefs, recordingActiveRef]
|
|
3601
3703
|
);
|
|
3602
|
-
const bumpTrackReorderEpoch = (0,
|
|
3704
|
+
const bumpTrackReorderEpoch = (0, import_react35.useCallback)(() => {
|
|
3603
3705
|
setTrackReorderEpoch((epoch) => epoch + 1);
|
|
3604
3706
|
}, []);
|
|
3605
|
-
const setSelection = (0,
|
|
3707
|
+
const setSelection = (0, import_react35.useCallback)(
|
|
3606
3708
|
(start, end) => {
|
|
3607
3709
|
var _a;
|
|
3608
3710
|
setSelectionEngine(start, end);
|
|
@@ -3650,8 +3752,8 @@ var ProviderOnArrangement = ({
|
|
|
3650
3752
|
pendingResumeRef
|
|
3651
3753
|
]
|
|
3652
3754
|
);
|
|
3653
|
-
const isPlayingValue = (0,
|
|
3654
|
-
const refsValue = (0,
|
|
3755
|
+
const isPlayingValue = (0, import_react35.useMemo)(() => ({ isPlaying }), [isPlaying]);
|
|
3756
|
+
const refsValue = (0, import_react35.useMemo)(
|
|
3655
3757
|
() => ({
|
|
3656
3758
|
currentTimeRef,
|
|
3657
3759
|
visualTimeRef,
|
|
@@ -3660,7 +3762,7 @@ var ProviderOnArrangement = ({
|
|
|
3660
3762
|
}),
|
|
3661
3763
|
[currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback]
|
|
3662
3764
|
);
|
|
3663
|
-
const engineRefsValue = (0,
|
|
3765
|
+
const engineRefsValue = (0, import_react35.useMemo)(
|
|
3664
3766
|
() => ({
|
|
3665
3767
|
playbackStartTimeRef,
|
|
3666
3768
|
audioStartPositionRef,
|
|
@@ -3680,36 +3782,36 @@ var ProviderOnArrangement = ({
|
|
|
3680
3782
|
engineRef
|
|
3681
3783
|
]
|
|
3682
3784
|
);
|
|
3683
|
-
const loopValue = (0,
|
|
3785
|
+
const loopValue = (0, import_react35.useMemo)(
|
|
3684
3786
|
() => ({ isLoopEnabled, loopStart, loopEnd }),
|
|
3685
3787
|
[isLoopEnabled, loopStart, loopEnd]
|
|
3686
3788
|
);
|
|
3687
|
-
const selectedTrackIdValue = (0,
|
|
3789
|
+
const selectedTrackIdValue = (0, import_react35.useMemo)(
|
|
3688
3790
|
() => ({ selectedTrackId }),
|
|
3689
3791
|
[selectedTrackId]
|
|
3690
3792
|
);
|
|
3691
3793
|
const { canUndo, canRedo } = view;
|
|
3692
|
-
const undoRedoValue = (0,
|
|
3794
|
+
const undoRedoValue = (0, import_react35.useMemo)(
|
|
3693
3795
|
() => ({ canUndo, canRedo }),
|
|
3694
3796
|
[canUndo, canRedo]
|
|
3695
3797
|
);
|
|
3696
|
-
const selectionValue = (0,
|
|
3798
|
+
const selectionValue = (0, import_react35.useMemo)(
|
|
3697
3799
|
() => ({ selectionStart, selectionEnd }),
|
|
3698
3800
|
[selectionStart, selectionEnd]
|
|
3699
3801
|
);
|
|
3700
|
-
const currentTimeValue = (0,
|
|
3701
|
-
const activeAnnotationValue = (0,
|
|
3802
|
+
const currentTimeValue = (0, import_react35.useMemo)(() => ({ currentTime }), [currentTime]);
|
|
3803
|
+
const activeAnnotationValue = (0, import_react35.useMemo)(
|
|
3702
3804
|
() => ({ activeAnnotationId }),
|
|
3703
3805
|
[activeAnnotationId]
|
|
3704
3806
|
);
|
|
3705
|
-
const setCurrentTimeControl = (0,
|
|
3807
|
+
const setCurrentTimeControl = (0, import_react35.useCallback)(
|
|
3706
3808
|
(time) => {
|
|
3707
3809
|
setCurrentTimeRefs(time);
|
|
3708
3810
|
setCurrentTime(time);
|
|
3709
3811
|
},
|
|
3710
3812
|
[setCurrentTimeRefs]
|
|
3711
3813
|
);
|
|
3712
|
-
const playAnnotation = (0,
|
|
3814
|
+
const playAnnotation = (0, import_react35.useCallback)(
|
|
3713
3815
|
(annotation) => {
|
|
3714
3816
|
if (refusePlayBeforeFirstReady()) return;
|
|
3715
3817
|
setActiveAnnotationId(annotation.id);
|
|
@@ -3722,7 +3824,7 @@ var ProviderOnArrangement = ({
|
|
|
3722
3824
|
},
|
|
3723
3825
|
[play, setActiveAnnotationId, continuousPlayRef, refusePlayBeforeFirstReady]
|
|
3724
3826
|
);
|
|
3725
|
-
const controlsValue = (0,
|
|
3827
|
+
const controlsValue = (0, import_react35.useMemo)(
|
|
3726
3828
|
() => ({
|
|
3727
3829
|
play,
|
|
3728
3830
|
pause,
|
|
@@ -3736,8 +3838,8 @@ var ProviderOnArrangement = ({
|
|
|
3736
3838
|
setContinuousPlay,
|
|
3737
3839
|
setAnnotationsEditable,
|
|
3738
3840
|
setLinkEndpoints,
|
|
3739
|
-
setAnnotations,
|
|
3740
3841
|
annotationPreview,
|
|
3842
|
+
annotationStore,
|
|
3741
3843
|
setActiveAnnotationId,
|
|
3742
3844
|
playAnnotation
|
|
3743
3845
|
}),
|
|
@@ -3754,13 +3856,13 @@ var ProviderOnArrangement = ({
|
|
|
3754
3856
|
setContinuousPlay,
|
|
3755
3857
|
setAnnotationsEditable,
|
|
3756
3858
|
setLinkEndpoints,
|
|
3757
|
-
setAnnotations,
|
|
3758
3859
|
annotationPreview,
|
|
3860
|
+
annotationStore,
|
|
3759
3861
|
setActiveAnnotationId,
|
|
3760
3862
|
playAnnotation
|
|
3761
3863
|
]
|
|
3762
3864
|
);
|
|
3763
|
-
const editorControlsValue = (0,
|
|
3865
|
+
const editorControlsValue = (0, import_react35.useMemo)(
|
|
3764
3866
|
() => ({
|
|
3765
3867
|
setCurrentTime: setCurrentTimeControl,
|
|
3766
3868
|
// Track controls (the arrangement's mix and order)
|
|
@@ -3810,7 +3912,7 @@ var ProviderOnArrangement = ({
|
|
|
3810
3912
|
editing.setRecordingActive
|
|
3811
3913
|
]
|
|
3812
3914
|
);
|
|
3813
|
-
const viewValue = (0,
|
|
3915
|
+
const viewValue = (0, import_react35.useMemo)(
|
|
3814
3916
|
() => ({
|
|
3815
3917
|
sampleRate,
|
|
3816
3918
|
mono,
|
|
@@ -3818,24 +3920,24 @@ var ProviderOnArrangement = ({
|
|
|
3818
3920
|
}),
|
|
3819
3921
|
[sampleRate, mono, indefinitePlayback]
|
|
3820
3922
|
);
|
|
3821
|
-
const settingsValue = (0,
|
|
3923
|
+
const settingsValue = (0, import_react35.useMemo)(
|
|
3822
3924
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
3823
3925
|
[timeFormat, isAutomaticScroll]
|
|
3824
3926
|
);
|
|
3825
|
-
const zoomValue = (0,
|
|
3927
|
+
const zoomValue = (0, import_react35.useMemo)(
|
|
3826
3928
|
() => ({ samplesPerPixel, canZoomIn: zoom.canZoomIn, canZoomOut: zoom.canZoomOut }),
|
|
3827
3929
|
[samplesPerPixel, zoom.canZoomIn, zoom.canZoomOut]
|
|
3828
3930
|
);
|
|
3829
3931
|
const { peaksDataArray, trackStates } = view;
|
|
3830
|
-
const timelineValue = (0,
|
|
3932
|
+
const timelineValue = (0, import_react35.useMemo)(
|
|
3831
3933
|
() => ({ tracks, peaksDataArray, duration, isReady }),
|
|
3832
3934
|
[tracks, peaksDataArray, duration, isReady]
|
|
3833
3935
|
);
|
|
3834
|
-
const mixerValue = (0,
|
|
3936
|
+
const mixerValue = (0, import_react35.useMemo)(
|
|
3835
3937
|
() => ({ trackStates, masterVolume }),
|
|
3836
3938
|
[trackStates, masterVolume]
|
|
3837
3939
|
);
|
|
3838
|
-
const reorderPreviewValue = (0,
|
|
3940
|
+
const reorderPreviewValue = (0, import_react35.useMemo)(
|
|
3839
3941
|
() => ({ trackDragPreview, trackReorderEpoch }),
|
|
3840
3942
|
[trackDragPreview, trackReorderEpoch]
|
|
3841
3943
|
);
|
|
@@ -3861,7 +3963,7 @@ var ProviderOnArrangement = ({
|
|
|
3861
3963
|
};
|
|
3862
3964
|
|
|
3863
3965
|
// src/MediaElementPlaylistContext.tsx
|
|
3864
|
-
var
|
|
3966
|
+
var import_react36 = require("react");
|
|
3865
3967
|
var import_styled_components2 = require("styled-components");
|
|
3866
3968
|
|
|
3867
3969
|
// src/playout/resolveMediaElementPlayout.ts
|
|
@@ -3897,40 +3999,39 @@ var MediaElementPlaylistProvider = ({
|
|
|
3897
3999
|
preservesPitch = true,
|
|
3898
4000
|
automaticScroll = false,
|
|
3899
4001
|
theme: userThemeProp,
|
|
4002
|
+
annotationStore,
|
|
3900
4003
|
annotationList,
|
|
3901
4004
|
audioContext,
|
|
3902
|
-
onAnnotationsChange,
|
|
3903
4005
|
onReady,
|
|
3904
4006
|
onError,
|
|
3905
4007
|
createPlayout,
|
|
3906
4008
|
children
|
|
3907
4009
|
}) => {
|
|
3908
4010
|
const mergedTheme = useMergedTheme(userThemeProp);
|
|
3909
|
-
const [isPlaying, setIsPlayingState] = (0,
|
|
3910
|
-
const isPlayingRef = (0,
|
|
3911
|
-
const setIsPlaying = (0,
|
|
4011
|
+
const [isPlaying, setIsPlayingState] = (0, import_react36.useState)(false);
|
|
4012
|
+
const isPlayingRef = (0, import_react36.useRef)(false);
|
|
4013
|
+
const setIsPlaying = (0, import_react36.useCallback)((playing) => {
|
|
3912
4014
|
isPlayingRef.current = playing;
|
|
3913
4015
|
setIsPlayingState(playing);
|
|
3914
4016
|
}, []);
|
|
3915
|
-
const [currentTime, setCurrentTime] = (0,
|
|
3916
|
-
const [isReady, setIsReady] = (0,
|
|
3917
|
-
const [playbackRate, setPlaybackRateState] = (0,
|
|
3918
|
-
const [ratePropSeen, setRatePropSeen] = (0,
|
|
4017
|
+
const [currentTime, setCurrentTime] = (0, import_react36.useState)(0);
|
|
4018
|
+
const [isReady, setIsReady] = (0, import_react36.useState)(false);
|
|
4019
|
+
const [playbackRate, setPlaybackRateState] = (0, import_react36.useState)(initialPlaybackRate);
|
|
4020
|
+
const [ratePropSeen, setRatePropSeen] = (0, import_react36.useState)(initialPlaybackRate);
|
|
3919
4021
|
if (!Object.is(ratePropSeen, initialPlaybackRate)) {
|
|
3920
4022
|
setRatePropSeen(initialPlaybackRate);
|
|
3921
4023
|
setPlaybackRateState(initialPlaybackRate);
|
|
3922
4024
|
}
|
|
3923
|
-
const playbackRateRef = (0,
|
|
3924
|
-
const ratePropAppliedRef = (0,
|
|
3925
|
-
(0,
|
|
4025
|
+
const playbackRateRef = (0, import_react36.useRef)(initialPlaybackRate);
|
|
4026
|
+
const ratePropAppliedRef = (0, import_react36.useRef)(initialPlaybackRate);
|
|
4027
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
3926
4028
|
if (Object.is(ratePropAppliedRef.current, initialPlaybackRate)) return;
|
|
3927
4029
|
ratePropAppliedRef.current = initialPlaybackRate;
|
|
3928
4030
|
playbackRateRef.current = initialPlaybackRate;
|
|
3929
4031
|
}, [initialPlaybackRate]);
|
|
3930
4032
|
const {
|
|
3931
|
-
|
|
4033
|
+
getAnnotations,
|
|
3932
4034
|
annotationLookup,
|
|
3933
|
-
setAnnotations,
|
|
3934
4035
|
annotationPreview,
|
|
3935
4036
|
activeAnnotationId,
|
|
3936
4037
|
activeAnnotationIdRef,
|
|
@@ -3942,9 +4043,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
3942
4043
|
annotationsValue,
|
|
3943
4044
|
annotationOptionsValue
|
|
3944
4045
|
} = useAnnotationState({
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
providerName: "MediaElementPlaylistProvider"
|
|
4046
|
+
annotationStore,
|
|
4047
|
+
annotationList
|
|
3948
4048
|
});
|
|
3949
4049
|
const {
|
|
3950
4050
|
scrollContainerRef,
|
|
@@ -3954,27 +4054,27 @@ var MediaElementPlaylistProvider = ({
|
|
|
3954
4054
|
setAutomaticScroll
|
|
3955
4055
|
} = useScrollFollow(automaticScroll);
|
|
3956
4056
|
const { registerFrameCallback, unregisterFrameCallback, runFrameCallbacks } = useFrameCallbacks();
|
|
3957
|
-
const [selection, setSelectionState] = (0,
|
|
4057
|
+
const [selection, setSelectionState] = (0, import_react36.useState)({
|
|
3958
4058
|
selectionStart: 0,
|
|
3959
4059
|
selectionEnd: 0
|
|
3960
4060
|
});
|
|
3961
|
-
const selectionRef = (0,
|
|
3962
|
-
const [samplesPerPixel] = (0,
|
|
4061
|
+
const selectionRef = (0, import_react36.useRef)(selection);
|
|
4062
|
+
const [samplesPerPixel] = (0, import_react36.useState)(initialSamplesPerPixel);
|
|
3963
4063
|
const { timeFormat, setTimeFormat } = useTimeFormat();
|
|
3964
|
-
const playoutRef = (0,
|
|
3965
|
-
const currentTimeRef = (0,
|
|
3966
|
-
const samplesPerPixelRef = (0,
|
|
4064
|
+
const playoutRef = (0, import_react36.useRef)(null);
|
|
4065
|
+
const currentTimeRef = (0, import_react36.useRef)(0);
|
|
4066
|
+
const samplesPerPixelRef = (0, import_react36.useRef)(initialSamplesPerPixel);
|
|
3967
4067
|
const { startAnimationFrameLoop, stopAnimationFrameLoop } = useAnimationFrameLoop();
|
|
3968
|
-
const playStartPositionRef = (0,
|
|
3969
|
-
const playbackEndTimeRef = (0,
|
|
3970
|
-
const isSelectionPlayRef = (0,
|
|
3971
|
-
const pendingPlayRef = (0,
|
|
3972
|
-
const playoutInFlightRef = (0,
|
|
4068
|
+
const playStartPositionRef = (0, import_react36.useRef)(0);
|
|
4069
|
+
const playbackEndTimeRef = (0, import_react36.useRef)(null);
|
|
4070
|
+
const isSelectionPlayRef = (0, import_react36.useRef)(false);
|
|
4071
|
+
const pendingPlayRef = (0, import_react36.useRef)(null);
|
|
4072
|
+
const playoutInFlightRef = (0, import_react36.useRef)(true);
|
|
3973
4073
|
const sampleRate = track.waveformData.sample_rate;
|
|
3974
4074
|
const duration = track.waveformData.duration;
|
|
3975
4075
|
const trackName = track.name;
|
|
3976
4076
|
const trackWaveformData = track.waveformData;
|
|
3977
|
-
const trackPeaks = (0,
|
|
4077
|
+
const trackPeaks = (0, import_react36.useMemo)(() => {
|
|
3978
4078
|
try {
|
|
3979
4079
|
const durationSamples = Math.ceil(trackWaveformData.duration * sampleRate);
|
|
3980
4080
|
const extractedPeaks = extractPeaksFromWaveformData(
|
|
@@ -4003,7 +4103,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4003
4103
|
}, [trackWaveformData, samplesPerPixel, sampleRate]);
|
|
4004
4104
|
const trackFadeIn = useShallowStable(track.fadeIn);
|
|
4005
4105
|
const trackFadeOut = useShallowStable(track.fadeOut);
|
|
4006
|
-
const peaksDataArray = (0,
|
|
4106
|
+
const peaksDataArray = (0, import_react36.useMemo)(() => {
|
|
4007
4107
|
if (!trackPeaks) return [];
|
|
4008
4108
|
const clipPeaks = {
|
|
4009
4109
|
clipId: "media-element-clip",
|
|
@@ -4017,11 +4117,11 @@ var MediaElementPlaylistProvider = ({
|
|
|
4017
4117
|
};
|
|
4018
4118
|
return [[clipPeaks]];
|
|
4019
4119
|
}, [trackPeaks, trackName, trackFadeIn, trackFadeOut]);
|
|
4020
|
-
const latestAudioRef = (0,
|
|
4021
|
-
(0,
|
|
4120
|
+
const latestAudioRef = (0, import_react36.useRef)({ source: track.source, waveformData: track.waveformData });
|
|
4121
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
4022
4122
|
latestAudioRef.current = { source: track.source, waveformData: track.waveformData };
|
|
4023
4123
|
}, [track.source, track.waveformData]);
|
|
4024
|
-
const restAt = (0,
|
|
4124
|
+
const restAt = (0, import_react36.useCallback)(
|
|
4025
4125
|
(cursor) => {
|
|
4026
4126
|
const playout = playoutRef.current;
|
|
4027
4127
|
if (playout) {
|
|
@@ -4037,10 +4137,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
4037
4137
|
},
|
|
4038
4138
|
[stopAnimationFrameLoop, setIsPlaying]
|
|
4039
4139
|
);
|
|
4040
|
-
const startAnimationLoopRef = (0,
|
|
4140
|
+
const startAnimationLoopRef = (0, import_react36.useRef)(() => {
|
|
4041
4141
|
});
|
|
4042
|
-
const endPlaybackIfDueRef = (0,
|
|
4043
|
-
(0,
|
|
4142
|
+
const endPlaybackIfDueRef = (0, import_react36.useRef)(() => false);
|
|
4143
|
+
(0, import_react36.useEffect)(() => {
|
|
4044
4144
|
let cancelled = false;
|
|
4045
4145
|
let createdPlayout = null;
|
|
4046
4146
|
const source = track.source;
|
|
@@ -4166,10 +4266,10 @@ var MediaElementPlaylistProvider = ({
|
|
|
4166
4266
|
restAt,
|
|
4167
4267
|
createPlayout
|
|
4168
4268
|
]);
|
|
4169
|
-
const endPlaybackIfDue = (0,
|
|
4269
|
+
const endPlaybackIfDue = (0, import_react36.useCallback)(
|
|
4170
4270
|
(time) => {
|
|
4171
4271
|
const activeAnnotationEnded = followAnnotations({
|
|
4172
|
-
annotations:
|
|
4272
|
+
annotations: getAnnotations(),
|
|
4173
4273
|
lookup: annotationLookup,
|
|
4174
4274
|
time,
|
|
4175
4275
|
activeId: activeAnnotationIdRef.current,
|
|
@@ -4192,7 +4292,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4192
4292
|
return false;
|
|
4193
4293
|
},
|
|
4194
4294
|
[
|
|
4195
|
-
|
|
4295
|
+
getAnnotations,
|
|
4196
4296
|
annotationLookup,
|
|
4197
4297
|
activeAnnotationIdRef,
|
|
4198
4298
|
continuousPlayRef,
|
|
@@ -4200,7 +4300,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4200
4300
|
restAt
|
|
4201
4301
|
]
|
|
4202
4302
|
);
|
|
4203
|
-
const startAnimationLoop = (0,
|
|
4303
|
+
const startAnimationLoop = (0, import_react36.useCallback)(() => {
|
|
4204
4304
|
const updateTime = () => {
|
|
4205
4305
|
var _a, _b;
|
|
4206
4306
|
const time = (_b = (_a = playoutRef.current) == null ? void 0 : _a.getCurrentTime()) != null ? _b : 0;
|
|
@@ -4226,12 +4326,12 @@ var MediaElementPlaylistProvider = ({
|
|
|
4226
4326
|
runFrameCallbacks,
|
|
4227
4327
|
endPlaybackIfDue
|
|
4228
4328
|
]);
|
|
4229
|
-
(0,
|
|
4329
|
+
(0, import_react36.useLayoutEffect)(() => {
|
|
4230
4330
|
startAnimationLoopRef.current = startAnimationLoop;
|
|
4231
4331
|
endPlaybackIfDueRef.current = endPlaybackIfDue;
|
|
4232
4332
|
}, [startAnimationLoop, endPlaybackIfDue]);
|
|
4233
4333
|
const stopAnimationLoop = stopAnimationFrameLoop;
|
|
4234
|
-
const play = (0,
|
|
4334
|
+
const play = (0, import_react36.useCallback)(
|
|
4235
4335
|
(startTime, playDuration) => __async(null, null, function* () {
|
|
4236
4336
|
const actualStartTime = startTime != null ? startTime : currentTimeRef.current;
|
|
4237
4337
|
const endTime = playDuration !== void 0 ? actualStartTime + playDuration : void 0;
|
|
@@ -4253,7 +4353,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4253
4353
|
}),
|
|
4254
4354
|
[startAnimationLoop, setIsPlaying]
|
|
4255
4355
|
);
|
|
4256
|
-
const pause = (0,
|
|
4356
|
+
const pause = (0, import_react36.useCallback)(() => {
|
|
4257
4357
|
pendingPlayRef.current = null;
|
|
4258
4358
|
if (!playoutRef.current) {
|
|
4259
4359
|
setCurrentTime(currentTimeRef.current);
|
|
@@ -4264,12 +4364,12 @@ var MediaElementPlaylistProvider = ({
|
|
|
4264
4364
|
stopAnimationLoop();
|
|
4265
4365
|
setCurrentTime(playoutRef.current.getCurrentTime());
|
|
4266
4366
|
}, [stopAnimationLoop, setIsPlaying]);
|
|
4267
|
-
const stop = (0,
|
|
4367
|
+
const stop = (0, import_react36.useCallback)(() => {
|
|
4268
4368
|
pendingPlayRef.current = null;
|
|
4269
4369
|
restAt(playStartPositionRef.current);
|
|
4270
4370
|
setActiveAnnotationId(null);
|
|
4271
4371
|
}, [restAt, setActiveAnnotationId]);
|
|
4272
|
-
const seekTo = (0,
|
|
4372
|
+
const seekTo = (0, import_react36.useCallback)((time) => {
|
|
4273
4373
|
if (Number.isNaN(time)) return;
|
|
4274
4374
|
const trackDuration = latestAudioRef.current.waveformData.duration;
|
|
4275
4375
|
const clampedTime = Math.max(0, Math.min(time, trackDuration));
|
|
@@ -4291,7 +4391,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4291
4391
|
playout.seekTo(clampedTime);
|
|
4292
4392
|
}
|
|
4293
4393
|
}, []);
|
|
4294
|
-
const setSelection = (0,
|
|
4394
|
+
const setSelection = (0, import_react36.useCallback)(
|
|
4295
4395
|
(requestedStart, requestedEnd) => {
|
|
4296
4396
|
const length = latestAudioRef.current.waveformData.duration;
|
|
4297
4397
|
const clamp = (time) => Math.max(0, Math.min(time, length));
|
|
@@ -4332,7 +4432,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4332
4432
|
},
|
|
4333
4433
|
[activeAnnotationIdRef, setActiveAnnotationId]
|
|
4334
4434
|
);
|
|
4335
|
-
const setPlaybackRate = (0,
|
|
4435
|
+
const setPlaybackRate = (0, import_react36.useCallback)((rate) => {
|
|
4336
4436
|
if (Number.isNaN(rate)) return;
|
|
4337
4437
|
const clampedRate = Math.max(0.5, Math.min(2, rate));
|
|
4338
4438
|
playbackRateRef.current = clampedRate;
|
|
@@ -4341,17 +4441,17 @@ var MediaElementPlaylistProvider = ({
|
|
|
4341
4441
|
playoutRef.current.setPlaybackRate(clampedRate);
|
|
4342
4442
|
}
|
|
4343
4443
|
}, []);
|
|
4344
|
-
const isPlayingValue = (0,
|
|
4345
|
-
const currentTimeValue = (0,
|
|
4346
|
-
const activeAnnotationValue = (0,
|
|
4444
|
+
const isPlayingValue = (0, import_react36.useMemo)(() => ({ isPlaying }), [isPlaying]);
|
|
4445
|
+
const currentTimeValue = (0, import_react36.useMemo)(() => ({ currentTime }), [currentTime]);
|
|
4446
|
+
const activeAnnotationValue = (0, import_react36.useMemo)(
|
|
4347
4447
|
() => ({ activeAnnotationId }),
|
|
4348
4448
|
[activeAnnotationId]
|
|
4349
4449
|
);
|
|
4350
|
-
const settingsValue = (0,
|
|
4450
|
+
const settingsValue = (0, import_react36.useMemo)(
|
|
4351
4451
|
() => ({ timeFormat, isAutomaticScroll }),
|
|
4352
4452
|
[timeFormat, isAutomaticScroll]
|
|
4353
4453
|
);
|
|
4354
|
-
const refsValue = (0,
|
|
4454
|
+
const refsValue = (0, import_react36.useMemo)(
|
|
4355
4455
|
() => ({
|
|
4356
4456
|
currentTimeRef,
|
|
4357
4457
|
visualTimeRef: currentTimeRef,
|
|
@@ -4360,7 +4460,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4360
4460
|
}),
|
|
4361
4461
|
[registerFrameCallback, unregisterFrameCallback]
|
|
4362
4462
|
);
|
|
4363
|
-
const playAnnotation = (0,
|
|
4463
|
+
const playAnnotation = (0, import_react36.useCallback)(
|
|
4364
4464
|
(annotation) => {
|
|
4365
4465
|
setActiveAnnotationId(annotation.id);
|
|
4366
4466
|
play(annotation.start).catch((err) => {
|
|
@@ -4371,7 +4471,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4371
4471
|
},
|
|
4372
4472
|
[play, setActiveAnnotationId]
|
|
4373
4473
|
);
|
|
4374
|
-
const controlsValue = (0,
|
|
4474
|
+
const controlsValue = (0, import_react36.useMemo)(
|
|
4375
4475
|
() => ({
|
|
4376
4476
|
play,
|
|
4377
4477
|
pause,
|
|
@@ -4385,8 +4485,8 @@ var MediaElementPlaylistProvider = ({
|
|
|
4385
4485
|
setContinuousPlay,
|
|
4386
4486
|
setAnnotationsEditable,
|
|
4387
4487
|
setLinkEndpoints,
|
|
4388
|
-
setAnnotations,
|
|
4389
4488
|
annotationPreview,
|
|
4489
|
+
annotationStore,
|
|
4390
4490
|
setActiveAnnotationId,
|
|
4391
4491
|
playAnnotation
|
|
4392
4492
|
}),
|
|
@@ -4403,25 +4503,25 @@ var MediaElementPlaylistProvider = ({
|
|
|
4403
4503
|
setContinuousPlay,
|
|
4404
4504
|
setAnnotationsEditable,
|
|
4405
4505
|
setLinkEndpoints,
|
|
4406
|
-
setAnnotations,
|
|
4407
4506
|
annotationPreview,
|
|
4507
|
+
annotationStore,
|
|
4408
4508
|
setActiveAnnotationId,
|
|
4409
4509
|
playAnnotation
|
|
4410
4510
|
]
|
|
4411
4511
|
);
|
|
4412
|
-
const viewValue = (0,
|
|
4512
|
+
const viewValue = (0, import_react36.useMemo)(
|
|
4413
4513
|
() => ({ sampleRate, mono: false, indefinitePlayback: false }),
|
|
4414
4514
|
[sampleRate]
|
|
4415
4515
|
);
|
|
4416
|
-
const zoomValue = (0,
|
|
4516
|
+
const zoomValue = (0, import_react36.useMemo)(
|
|
4417
4517
|
() => ({ samplesPerPixel, canZoomIn: false, canZoomOut: false }),
|
|
4418
4518
|
[samplesPerPixel]
|
|
4419
4519
|
);
|
|
4420
|
-
const playbackRateValue = (0,
|
|
4520
|
+
const playbackRateValue = (0, import_react36.useMemo)(
|
|
4421
4521
|
() => ({ playbackRate, setPlaybackRate }),
|
|
4422
4522
|
[playbackRate, setPlaybackRate]
|
|
4423
4523
|
);
|
|
4424
|
-
const trackValue = (0,
|
|
4524
|
+
const trackValue = (0, import_react36.useMemo)(
|
|
4425
4525
|
() => ({
|
|
4426
4526
|
duration,
|
|
4427
4527
|
isReady,
|
|
@@ -4442,7 +4542,7 @@ var MediaElementPlaylistProvider = ({
|
|
|
4442
4542
|
};
|
|
4443
4543
|
|
|
4444
4544
|
// src/components/PlaybackControls.tsx
|
|
4445
|
-
var
|
|
4545
|
+
var import_react37 = require("react");
|
|
4446
4546
|
var import_ui_components3 = require("@waveform-playlist/ui-components");
|
|
4447
4547
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
4448
4548
|
var PlayButton = ({ className }) => {
|
|
@@ -4547,7 +4647,7 @@ var ClearAllButton = ({
|
|
|
4547
4647
|
className
|
|
4548
4648
|
}) => {
|
|
4549
4649
|
const { stop } = usePlaybackControls();
|
|
4550
|
-
const handleClick = (0,
|
|
4650
|
+
const handleClick = (0, import_react37.useCallback)(() => {
|
|
4551
4651
|
stop();
|
|
4552
4652
|
onClearAll();
|
|
4553
4653
|
}, [stop, onClearAll]);
|
|
@@ -4575,7 +4675,7 @@ var ZoomOutButton = ({
|
|
|
4575
4675
|
};
|
|
4576
4676
|
|
|
4577
4677
|
// src/components/ContextualControls.tsx
|
|
4578
|
-
var
|
|
4678
|
+
var import_react38 = require("react");
|
|
4579
4679
|
var import_ui_components5 = require("@waveform-playlist/ui-components");
|
|
4580
4680
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
4581
4681
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -4608,13 +4708,13 @@ var PositionDisplay = import_styled_components3.default.span`
|
|
|
4608
4708
|
`;
|
|
4609
4709
|
var AudioPosition = ({ className }) => {
|
|
4610
4710
|
var _a;
|
|
4611
|
-
const timeRef = (0,
|
|
4711
|
+
const timeRef = (0, import_react38.useRef)(null);
|
|
4612
4712
|
const { currentTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
4613
4713
|
const { isPlaying } = useIsPlaying();
|
|
4614
4714
|
useCurrentTime();
|
|
4615
4715
|
const { timeFormat: format } = usePlaylistSettings();
|
|
4616
|
-
const id = (0,
|
|
4617
|
-
(0,
|
|
4716
|
+
const id = (0, import_react38.useId)();
|
|
4717
|
+
(0, import_react38.useEffect)(() => {
|
|
4618
4718
|
if (isPlaying) {
|
|
4619
4719
|
registerFrameCallback(id, ({ time }) => {
|
|
4620
4720
|
if (timeRef.current) {
|
|
@@ -4624,7 +4724,7 @@ var AudioPosition = ({ className }) => {
|
|
|
4624
4724
|
}
|
|
4625
4725
|
return () => unregisterFrameCallback(id);
|
|
4626
4726
|
}, [id, isPlaying, format, registerFrameCallback, unregisterFrameCallback]);
|
|
4627
|
-
(0,
|
|
4727
|
+
(0, import_react38.useEffect)(() => {
|
|
4628
4728
|
var _a2;
|
|
4629
4729
|
if (!isPlaying && timeRef.current) {
|
|
4630
4730
|
timeRef.current.textContent = (0, import_ui_components5.formatTime)((_a2 = currentTimeRef.current) != null ? _a2 : 0, format);
|
|
@@ -4676,7 +4776,7 @@ var AutomaticScrollCheckbox = ({ className }) => {
|
|
|
4676
4776
|
};
|
|
4677
4777
|
|
|
4678
4778
|
// src/components/WaveformRoot.tsx
|
|
4679
|
-
var
|
|
4779
|
+
var import_react60 = require("react");
|
|
4680
4780
|
var import_react_dom2 = require("react-dom");
|
|
4681
4781
|
var import_ui_components16 = require("@waveform-playlist/ui-components");
|
|
4682
4782
|
|
|
@@ -4714,10 +4814,10 @@ function trackIdAtOffset(orderedIds, layout, heightById, y) {
|
|
|
4714
4814
|
}
|
|
4715
4815
|
|
|
4716
4816
|
// src/hooks/useTrailingActive.ts
|
|
4717
|
-
var
|
|
4817
|
+
var import_react39 = require("react");
|
|
4718
4818
|
function useTrailingActive(active, trailingMs) {
|
|
4719
|
-
const [trailing, setTrailing] = (0,
|
|
4720
|
-
(0,
|
|
4819
|
+
const [trailing, setTrailing] = (0, import_react39.useState)(active);
|
|
4820
|
+
(0, import_react39.useEffect)(() => {
|
|
4721
4821
|
if (active) {
|
|
4722
4822
|
setTrailing(true);
|
|
4723
4823
|
return void 0;
|
|
@@ -4729,7 +4829,7 @@ function useTrailingActive(active, trailingMs) {
|
|
|
4729
4829
|
}
|
|
4730
4830
|
|
|
4731
4831
|
// src/hooks/useRecordingLayout.ts
|
|
4732
|
-
var
|
|
4832
|
+
var import_react40 = require("react");
|
|
4733
4833
|
var RECORDING_EXTENT_STEP_SECONDS = 10;
|
|
4734
4834
|
function recordingDisplayEnd(takeEndSeconds) {
|
|
4735
4835
|
const step = RECORDING_EXTENT_STEP_SECONDS;
|
|
@@ -4738,31 +4838,31 @@ function recordingDisplayEnd(takeEndSeconds) {
|
|
|
4738
4838
|
var subscribeToNothing = () => () => {
|
|
4739
4839
|
};
|
|
4740
4840
|
function useRecordingLayout(progress, startSample, sampleRate) {
|
|
4741
|
-
const subscribe = (0,
|
|
4841
|
+
const subscribe = (0, import_react40.useCallback)(
|
|
4742
4842
|
(onChange) => progress ? progress.subscribe(onChange) : subscribeToNothing(),
|
|
4743
4843
|
[progress]
|
|
4744
4844
|
);
|
|
4745
|
-
const getChannelCount = (0,
|
|
4845
|
+
const getChannelCount = (0, import_react40.useCallback)(
|
|
4746
4846
|
() => progress ? progress.getSnapshot().peaks.length : 0,
|
|
4747
4847
|
[progress]
|
|
4748
4848
|
);
|
|
4749
|
-
const getDisplayEnd = (0,
|
|
4849
|
+
const getDisplayEnd = (0, import_react40.useCallback)(
|
|
4750
4850
|
() => progress && sampleRate > 0 ? recordingDisplayEnd(startSample / sampleRate + progress.getSnapshot().duration) : 0,
|
|
4751
4851
|
[progress, startSample, sampleRate]
|
|
4752
4852
|
);
|
|
4753
|
-
const channelCount = (0,
|
|
4754
|
-
const displayEndSeconds = (0,
|
|
4853
|
+
const channelCount = (0, import_react40.useSyncExternalStore)(subscribe, getChannelCount, getChannelCount);
|
|
4854
|
+
const displayEndSeconds = (0, import_react40.useSyncExternalStore)(subscribe, getDisplayEnd, getDisplayEnd);
|
|
4755
4855
|
return { channelCount, displayEndSeconds };
|
|
4756
4856
|
}
|
|
4757
4857
|
|
|
4758
4858
|
// src/hooks/useTrimPreviewView.ts
|
|
4759
|
-
var
|
|
4859
|
+
var import_react41 = require("react");
|
|
4760
4860
|
var TRIM_EXTENT_STEP_SECONDS = RECORDING_EXTENT_STEP_SECONDS;
|
|
4761
4861
|
var NO_UNSUBSCRIBE = () => {
|
|
4762
4862
|
};
|
|
4763
4863
|
var subscribeToNothing2 = () => NO_UNSUBSCRIBE;
|
|
4764
4864
|
function useSubscribe(source) {
|
|
4765
|
-
return (0,
|
|
4865
|
+
return (0, import_react41.useMemo)(
|
|
4766
4866
|
() => source ? (onChange) => source.subscribe(onChange) : subscribeToNothing2,
|
|
4767
4867
|
[source]
|
|
4768
4868
|
);
|
|
@@ -4773,13 +4873,13 @@ function usePreviewedClipPeaks(clip, trackId) {
|
|
|
4773
4873
|
const peaks = useTrimPreviewPeaksOptional();
|
|
4774
4874
|
const subscribe = useSubscribe(source);
|
|
4775
4875
|
const clipId = clip.clipId;
|
|
4776
|
-
const getSnapshot = (0,
|
|
4876
|
+
const getSnapshot = (0, import_react41.useCallback)(() => {
|
|
4777
4877
|
var _a2;
|
|
4778
4878
|
const preview2 = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4779
4879
|
return preview2 !== null && preview2.clipId === clipId && preview2.trackId === trackId ? preview2 : null;
|
|
4780
4880
|
}, [source, clipId, trackId]);
|
|
4781
|
-
const preview = (0,
|
|
4782
|
-
return (0,
|
|
4881
|
+
const preview = (0, import_react41.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
4882
|
+
return (0, import_react41.useMemo)(
|
|
4783
4883
|
() => {
|
|
4784
4884
|
var _a2;
|
|
4785
4885
|
return preview && peaks ? (_a2 = peaks.peaksFor(preview)) != null ? _a2 : clip : clip;
|
|
@@ -4791,7 +4891,7 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4791
4891
|
var _a;
|
|
4792
4892
|
const source = (_a = useTrimPreviewOptional()) == null ? void 0 : _a.source;
|
|
4793
4893
|
const subscribe = useSubscribe(source);
|
|
4794
|
-
const getSnapshot = (0,
|
|
4894
|
+
const getSnapshot = (0, import_react41.useCallback)(() => {
|
|
4795
4895
|
var _a2;
|
|
4796
4896
|
const preview = (_a2 = source == null ? void 0 : source.getSnapshot()) != null ? _a2 : null;
|
|
4797
4897
|
if (preview === null || !(sampleRate > 0)) return 0;
|
|
@@ -4799,18 +4899,18 @@ function useTrimPreviewExtent(sampleRate, durationSeconds) {
|
|
|
4799
4899
|
if (endSeconds <= durationSeconds) return 0;
|
|
4800
4900
|
return Math.ceil(endSeconds / TRIM_EXTENT_STEP_SECONDS) * TRIM_EXTENT_STEP_SECONDS;
|
|
4801
4901
|
}, [source, sampleRate, durationSeconds]);
|
|
4802
|
-
return (0,
|
|
4902
|
+
return (0, import_react41.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
4803
4903
|
}
|
|
4804
4904
|
|
|
4805
4905
|
// src/components/WaveformRoot.tsx
|
|
4806
|
-
var
|
|
4906
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
4807
4907
|
|
|
4808
4908
|
// src/SpectrogramIntegrationContext.tsx
|
|
4809
|
-
var
|
|
4810
|
-
var SpectrogramIntegrationContext = (0,
|
|
4909
|
+
var import_react42 = require("react");
|
|
4910
|
+
var SpectrogramIntegrationContext = (0, import_react42.createContext)(null);
|
|
4811
4911
|
var SpectrogramIntegrationProvider = SpectrogramIntegrationContext.Provider;
|
|
4812
4912
|
function useSpectrogramIntegration() {
|
|
4813
|
-
const context = (0,
|
|
4913
|
+
const context = (0, import_react42.use)(SpectrogramIntegrationContext);
|
|
4814
4914
|
if (!context) {
|
|
4815
4915
|
throw new Error(
|
|
4816
4916
|
"useSpectrogramIntegration must be used within <SpectrogramProvider>. Install @waveform-playlist/spectrogram (" + installCommand("@waveform-playlist/spectrogram") + ") and wrap your app with <SpectrogramProvider>."
|
|
@@ -4820,10 +4920,10 @@ function useSpectrogramIntegration() {
|
|
|
4820
4920
|
}
|
|
4821
4921
|
|
|
4822
4922
|
// src/utils/trackRenderMode.ts
|
|
4823
|
-
var
|
|
4923
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
4824
4924
|
function trackRenderMode(track, override) {
|
|
4825
4925
|
var _a;
|
|
4826
|
-
if ((0,
|
|
4926
|
+
if ((0, import_core9.trackKind)(track) === "midi") return "waveform";
|
|
4827
4927
|
return (_a = override != null ? override : track.renderMode) != null ? _a : "waveform";
|
|
4828
4928
|
}
|
|
4829
4929
|
|
|
@@ -4870,15 +4970,15 @@ function getTrackChannelCount(trackClipPeaks, recordingChannels) {
|
|
|
4870
4970
|
}
|
|
4871
4971
|
|
|
4872
4972
|
// src/components/waveformFrame.tsx
|
|
4873
|
-
var
|
|
4973
|
+
var import_react59 = __toESM(require("react"));
|
|
4874
4974
|
var import_ui_components15 = require("@waveform-playlist/ui-components");
|
|
4875
4975
|
|
|
4876
4976
|
// src/hooks/useSelectionDrag.ts
|
|
4877
|
-
var
|
|
4878
|
-
var
|
|
4977
|
+
var import_react44 = require("react");
|
|
4978
|
+
var import_core10 = require("@waveform-playlist/core");
|
|
4879
4979
|
|
|
4880
4980
|
// src/hooks/useWindowDrag.ts
|
|
4881
|
-
var
|
|
4981
|
+
var import_react43 = require("react");
|
|
4882
4982
|
var activeDrags = 0;
|
|
4883
4983
|
var userSelectBeforeDrags = "";
|
|
4884
4984
|
var webkitUserSelectBeforeDrags = "";
|
|
@@ -4900,11 +5000,11 @@ function suspendTextSelection() {
|
|
|
4900
5000
|
};
|
|
4901
5001
|
}
|
|
4902
5002
|
function useWindowDrag(active, onMove, onEnd) {
|
|
4903
|
-
const callbacksRef = (0,
|
|
4904
|
-
(0,
|
|
5003
|
+
const callbacksRef = (0, import_react43.useRef)({ onMove, onEnd });
|
|
5004
|
+
(0, import_react43.useLayoutEffect)(() => {
|
|
4905
5005
|
callbacksRef.current = { onMove, onEnd };
|
|
4906
5006
|
});
|
|
4907
|
-
(0,
|
|
5007
|
+
(0, import_react43.useEffect)(() => {
|
|
4908
5008
|
if (!active) return;
|
|
4909
5009
|
const move = (event) => {
|
|
4910
5010
|
if ((event.buttons & 1) === 0) {
|
|
@@ -4937,15 +5037,15 @@ function clampedOffsetX(element, clientX) {
|
|
|
4937
5037
|
}
|
|
4938
5038
|
|
|
4939
5039
|
// src/hooks/useSelectionDrag.ts
|
|
4940
|
-
var SelectionPreviewContext = (0,
|
|
5040
|
+
var SelectionPreviewContext = (0, import_react44.createContext)(
|
|
4941
5041
|
null
|
|
4942
5042
|
);
|
|
4943
5043
|
var MIN_RANGE_SECONDS = 0.1;
|
|
4944
|
-
var AutomaticScrollFlag = (0,
|
|
5044
|
+
var AutomaticScrollFlag = (0, import_react44.memo)(function AutomaticScrollFlag2({
|
|
4945
5045
|
flagRef
|
|
4946
5046
|
}) {
|
|
4947
5047
|
const { isAutomaticScroll } = usePlaylistSettings();
|
|
4948
|
-
(0,
|
|
5048
|
+
(0, import_react44.useLayoutEffect)(() => {
|
|
4949
5049
|
flagRef.current = isAutomaticScroll;
|
|
4950
5050
|
});
|
|
4951
5051
|
return null;
|
|
@@ -4958,12 +5058,12 @@ function useSelectionDrag({
|
|
|
4958
5058
|
}) {
|
|
4959
5059
|
const { isPlaying } = useIsPlaying();
|
|
4960
5060
|
const { setSelection } = usePlaybackControls();
|
|
4961
|
-
const [isSelecting, setIsSelecting] = (0,
|
|
4962
|
-
const automaticScrollRef = (0,
|
|
4963
|
-
const previewHandle = (0,
|
|
4964
|
-
const pressTimeRef = (0,
|
|
4965
|
-
const wroteSelectionRef = (0,
|
|
4966
|
-
const dragElementRef = (0,
|
|
5061
|
+
const [isSelecting, setIsSelecting] = (0, import_react44.useState)(false);
|
|
5062
|
+
const automaticScrollRef = (0, import_react44.useRef)(false);
|
|
5063
|
+
const previewHandle = (0, import_react44.useMemo)(() => (0, import_core10.createValueSource)(null), []);
|
|
5064
|
+
const pressTimeRef = (0, import_react44.useRef)(0);
|
|
5065
|
+
const wroteSelectionRef = (0, import_react44.useRef)(false);
|
|
5066
|
+
const dragElementRef = (0, import_react44.useRef)(null);
|
|
4967
5067
|
const timeAt = (clientX) => {
|
|
4968
5068
|
const element = dragElementRef.current;
|
|
4969
5069
|
const x = element ? clampedOffsetX(element, clientX) : null;
|
|
@@ -5031,56 +5131,56 @@ function useSelectionDrag({
|
|
|
5031
5131
|
}
|
|
5032
5132
|
|
|
5033
5133
|
// src/components/waveformLayoutContext.ts
|
|
5034
|
-
var
|
|
5035
|
-
var WaveformPartPlaceContext = (0,
|
|
5036
|
-
var RootSeesRecordingPreviewContext = (0,
|
|
5037
|
-
var WaveformExtentContext = (0,
|
|
5038
|
-
var WaveformRowsContext = (0,
|
|
5134
|
+
var import_react45 = require("react");
|
|
5135
|
+
var WaveformPartPlaceContext = (0, import_react45.createContext)("tracks");
|
|
5136
|
+
var RootSeesRecordingPreviewContext = (0, import_react45.createContext)(false);
|
|
5137
|
+
var WaveformExtentContext = (0, import_react45.createContext)(null);
|
|
5138
|
+
var WaveformRowsContext = (0, import_react45.createContext)(null);
|
|
5039
5139
|
function required(value, part) {
|
|
5040
5140
|
if (value === null) {
|
|
5041
5141
|
throw new Error(`${part} must be rendered inside the waveform root`);
|
|
5042
5142
|
}
|
|
5043
5143
|
return value;
|
|
5044
5144
|
}
|
|
5045
|
-
var useWaveformExtent = (part) => required((0,
|
|
5046
|
-
var useWaveformRows = (part) => required((0,
|
|
5145
|
+
var useWaveformExtent = (part) => required((0, import_react45.use)(WaveformExtentContext), part);
|
|
5146
|
+
var useWaveformRows = (part) => required((0, import_react45.use)(WaveformRowsContext), part);
|
|
5047
5147
|
|
|
5048
5148
|
// src/components/waveformParts.tsx
|
|
5049
|
-
var
|
|
5149
|
+
var import_react58 = __toESM(require("react"));
|
|
5050
5150
|
var import_ui_components14 = require("@waveform-playlist/ui-components");
|
|
5051
5151
|
|
|
5052
5152
|
// src/components/TrackRows.tsx
|
|
5053
|
-
var
|
|
5153
|
+
var import_react48 = __toESM(require("react"));
|
|
5054
5154
|
var import_ui_components7 = require("@waveform-playlist/ui-components");
|
|
5055
|
-
var
|
|
5155
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
5056
5156
|
|
|
5057
5157
|
// src/contexts/ClipInteractionContext.tsx
|
|
5058
|
-
var
|
|
5158
|
+
var import_react46 = require("react");
|
|
5059
5159
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
5060
5160
|
var NO_CLIP_INTERACTION = { enabled: false, touchOptimized: false };
|
|
5061
|
-
var ClipInteractionContext = (0,
|
|
5161
|
+
var ClipInteractionContext = (0, import_react46.createContext)(NO_CLIP_INTERACTION);
|
|
5062
5162
|
var ClipInteractionOptions = ({
|
|
5063
5163
|
enabled: enabledProp,
|
|
5064
5164
|
touchOptimized: touchOptimizedProp,
|
|
5065
5165
|
children
|
|
5066
5166
|
}) => {
|
|
5067
|
-
const inherited = (0,
|
|
5167
|
+
const inherited = (0, import_react46.use)(ClipInteractionContext);
|
|
5068
5168
|
const enabled = enabledProp != null ? enabledProp : inherited.enabled;
|
|
5069
5169
|
const touchOptimized = touchOptimizedProp != null ? touchOptimizedProp : inherited.touchOptimized;
|
|
5070
|
-
const value = (0,
|
|
5170
|
+
const value = (0, import_react46.useMemo)(() => ({ enabled, touchOptimized }), [enabled, touchOptimized]);
|
|
5071
5171
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClipInteractionContext, { value, children });
|
|
5072
5172
|
};
|
|
5073
5173
|
function useClipInteraction() {
|
|
5074
|
-
return (0,
|
|
5174
|
+
return (0, import_react46.use)(ClipInteractionContext);
|
|
5075
5175
|
}
|
|
5076
5176
|
function useClipInteractionEnabled() {
|
|
5077
|
-
return (0,
|
|
5177
|
+
return (0, import_react46.use)(ClipInteractionContext).enabled;
|
|
5078
5178
|
}
|
|
5079
5179
|
|
|
5080
5180
|
// src/components/ChannelWithProgress.tsx
|
|
5081
|
-
var
|
|
5181
|
+
var import_react47 = require("react");
|
|
5082
5182
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
5083
|
-
var
|
|
5183
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
5084
5184
|
var import_ui_components6 = require("@waveform-playlist/ui-components");
|
|
5085
5185
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
5086
5186
|
var ChannelWrapper = import_styled_components5.default.div`
|
|
@@ -5135,19 +5235,19 @@ var ClipProgress = ({
|
|
|
5135
5235
|
height,
|
|
5136
5236
|
top
|
|
5137
5237
|
}) => {
|
|
5138
|
-
const progressRef = (0,
|
|
5139
|
-
const callbackId = (0,
|
|
5238
|
+
const progressRef = (0, import_react47.useRef)(null);
|
|
5239
|
+
const callbackId = (0, import_react47.useId)();
|
|
5140
5240
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
5141
5241
|
const { isPlaying } = useIsPlaying();
|
|
5142
5242
|
useCurrentTime();
|
|
5143
5243
|
const { sampleRate } = usePlaylistView();
|
|
5144
5244
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
5145
|
-
const clipPixelWidth = (0,
|
|
5245
|
+
const clipPixelWidth = (0, import_core11.clipPixelWidth)(
|
|
5146
5246
|
clipStartSample,
|
|
5147
5247
|
clipDurationSamples,
|
|
5148
5248
|
samplesPerPixel
|
|
5149
5249
|
);
|
|
5150
|
-
(0,
|
|
5250
|
+
(0, import_react47.useEffect)(() => {
|
|
5151
5251
|
if (isPlaying) {
|
|
5152
5252
|
registerFrameCallback(callbackId, ({ visualTime, sampleRate: sr }) => {
|
|
5153
5253
|
if (progressRef.current) {
|
|
@@ -5165,7 +5265,7 @@ var ClipProgress = ({
|
|
|
5165
5265
|
registerFrameCallback,
|
|
5166
5266
|
unregisterFrameCallback
|
|
5167
5267
|
]);
|
|
5168
|
-
(0,
|
|
5268
|
+
(0, import_react47.useEffect)(() => {
|
|
5169
5269
|
var _a, _b;
|
|
5170
5270
|
if (!isPlaying && progressRef.current) {
|
|
5171
5271
|
const currentTime = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -5267,8 +5367,8 @@ var ChannelWithProgress = (_a) => {
|
|
|
5267
5367
|
|
|
5268
5368
|
// src/components/TrackRows.tsx
|
|
5269
5369
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
5270
|
-
var ClipDisplayContext = (0,
|
|
5271
|
-
var ClipView =
|
|
5370
|
+
var ClipDisplayContext = (0, import_react48.createContext)(null);
|
|
5371
|
+
var ClipView = import_react48.default.memo(function ClipView2({
|
|
5272
5372
|
clip: committedClip,
|
|
5273
5373
|
trackId,
|
|
5274
5374
|
trackIndex,
|
|
@@ -5285,13 +5385,13 @@ var ClipView = import_react46.default.memo(function ClipView2({
|
|
|
5285
5385
|
selectTrack,
|
|
5286
5386
|
registerSpectrogramCanvas,
|
|
5287
5387
|
unregisterSpectrogramCanvas
|
|
5288
|
-
} = (0,
|
|
5388
|
+
} = (0, import_react48.use)(ClipDisplayContext);
|
|
5289
5389
|
const { enabled: interactiveClips, touchOptimized } = useClipInteraction();
|
|
5290
5390
|
const clip = usePreviewedClipPeaks(committedClip, trackId);
|
|
5291
5391
|
const peaksData = clip.peaks;
|
|
5292
5392
|
const width = peaksData.length;
|
|
5293
5393
|
const drawsBody = clip.isPlaceholder && width === 0;
|
|
5294
|
-
const handleMouseDown = (0,
|
|
5394
|
+
const handleMouseDown = (0, import_react48.useCallback)(
|
|
5295
5395
|
(e) => {
|
|
5296
5396
|
const target = e.target;
|
|
5297
5397
|
if (target.closest('[role="button"][aria-roledescription="draggable"]')) {
|
|
@@ -5369,11 +5469,11 @@ var RecordingPreviewClip = ({
|
|
|
5369
5469
|
var _a;
|
|
5370
5470
|
const { getLookAhead, getOutputLatency } = useEngineRefs();
|
|
5371
5471
|
const source = recordingState.progress;
|
|
5372
|
-
const subscribe = (0,
|
|
5373
|
-
const getSnapshot = (0,
|
|
5374
|
-
const progress = (0,
|
|
5472
|
+
const subscribe = (0, import_react48.useCallback)((onChange) => source.subscribe(onChange), [source]);
|
|
5473
|
+
const getSnapshot = (0, import_react48.useCallback)(() => source.getSnapshot(), [source]);
|
|
5474
|
+
const progress = (0, import_react48.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
5375
5475
|
const durationSamples = Math.floor(progress.duration * sampleRate);
|
|
5376
|
-
const latencyOffsetSamples = (0,
|
|
5476
|
+
const latencyOffsetSamples = (0, import_core12.resolveRecordingOffsetSamples)({
|
|
5377
5477
|
overrideSeconds: recordingState.latencyOffset,
|
|
5378
5478
|
outputLatency: getOutputLatency(),
|
|
5379
5479
|
lookAhead: getLookAhead(),
|
|
@@ -5416,7 +5516,7 @@ var RecordingPreviewClip = ({
|
|
|
5416
5516
|
}
|
|
5417
5517
|
);
|
|
5418
5518
|
};
|
|
5419
|
-
var TrackRow =
|
|
5519
|
+
var TrackRow = import_react48.default.memo(function TrackRow2({
|
|
5420
5520
|
trackId,
|
|
5421
5521
|
trackIndex,
|
|
5422
5522
|
trackClipPeaks,
|
|
@@ -5530,13 +5630,13 @@ function scanTracksParts(children) {
|
|
|
5530
5630
|
recordingState: void 0
|
|
5531
5631
|
};
|
|
5532
5632
|
const visit = (node) => {
|
|
5533
|
-
|
|
5534
|
-
if (!
|
|
5633
|
+
import_react48.default.Children.forEach(node, (child) => {
|
|
5634
|
+
if (!import_react48.default.isValidElement(child)) return;
|
|
5535
5635
|
if (child.type === WaveformClipHeaders) found.showClipHeaders = true;
|
|
5536
5636
|
else if (child.type === WaveformFades) found.showFades = true;
|
|
5537
5637
|
else if (child.type === WaveformRecordingPreview) {
|
|
5538
5638
|
found.recordingState = child.props.recordingState;
|
|
5539
|
-
} else if (child.type ===
|
|
5639
|
+
} else if (child.type === import_react48.default.Fragment) {
|
|
5540
5640
|
visit(child.props.children);
|
|
5541
5641
|
} else {
|
|
5542
5642
|
warnMisplacedPart(
|
|
@@ -5555,8 +5655,8 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5555
5655
|
const { sampleRate, mono } = usePlaylistView();
|
|
5556
5656
|
const { waveHeight } = (0, import_ui_components7.usePlaylistInfo)();
|
|
5557
5657
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
5558
|
-
const spectrogram = (0,
|
|
5559
|
-
const rootSeesRecordingPreview = (0,
|
|
5658
|
+
const spectrogram = (0, import_react48.use)(SpectrogramIntegrationContext);
|
|
5659
|
+
const rootSeesRecordingPreview = (0, import_react48.use)(RootSeesRecordingPreviewContext);
|
|
5560
5660
|
const scanned = scanTracksParts(children);
|
|
5561
5661
|
const { showFades, recordingState } = scanned;
|
|
5562
5662
|
const {
|
|
@@ -5581,7 +5681,7 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5581
5681
|
const { selectTrack } = rows;
|
|
5582
5682
|
const registerSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.registerSpectrogramCanvas;
|
|
5583
5683
|
const unregisterSpectrogramCanvas = spectrogram == null ? void 0 : spectrogram.unregisterSpectrogramCanvas;
|
|
5584
|
-
const clipDisplay = (0,
|
|
5684
|
+
const clipDisplay = (0, import_react48.useMemo)(
|
|
5585
5685
|
() => ({
|
|
5586
5686
|
gainScaledWaveforms: gainScaled,
|
|
5587
5687
|
showFades,
|
|
@@ -5627,23 +5727,23 @@ var WaveformTracks = ({ gainScaled = false, children }) => {
|
|
|
5627
5727
|
};
|
|
5628
5728
|
|
|
5629
5729
|
// src/components/TrackControlsColumn.tsx
|
|
5630
|
-
var
|
|
5730
|
+
var import_react54 = __toESM(require("react"));
|
|
5631
5731
|
var import_ui_components10 = require("@waveform-playlist/ui-components");
|
|
5632
5732
|
|
|
5633
5733
|
// src/components/DefaultTrackControls.tsx
|
|
5634
|
-
var
|
|
5734
|
+
var import_react52 = __toESM(require("react"));
|
|
5635
5735
|
var import_styled_components6 = __toESM(require("styled-components"));
|
|
5636
5736
|
var import_ui_components9 = require("@waveform-playlist/ui-components");
|
|
5637
5737
|
|
|
5638
5738
|
// src/components/TrackControlPieces.tsx
|
|
5639
|
-
var
|
|
5739
|
+
var import_react51 = require("react");
|
|
5640
5740
|
var import_ui_components8 = require("@waveform-playlist/ui-components");
|
|
5641
5741
|
|
|
5642
5742
|
// src/components/trackContext.ts
|
|
5643
|
-
var
|
|
5644
|
-
var TrackContext = (0,
|
|
5743
|
+
var import_react49 = require("react");
|
|
5744
|
+
var TrackContext = (0, import_react49.createContext)(null);
|
|
5645
5745
|
function useTrack() {
|
|
5646
|
-
const value = (0,
|
|
5746
|
+
const value = (0, import_react49.use)(TrackContext);
|
|
5647
5747
|
if (value === null) {
|
|
5648
5748
|
throw new Error(
|
|
5649
5749
|
"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."
|
|
@@ -5651,11 +5751,11 @@ function useTrack() {
|
|
|
5651
5751
|
}
|
|
5652
5752
|
return value;
|
|
5653
5753
|
}
|
|
5654
|
-
var TrackControlsSharedContext = (0,
|
|
5655
|
-
var TrackSlotWiringContext = (0,
|
|
5754
|
+
var TrackControlsSharedContext = (0, import_react49.createContext)(null);
|
|
5755
|
+
var TrackSlotWiringContext = (0, import_react49.createContext)(null);
|
|
5656
5756
|
|
|
5657
5757
|
// src/hooks/useTrackReorderHandle.ts
|
|
5658
|
-
var
|
|
5758
|
+
var import_react50 = require("react");
|
|
5659
5759
|
var import_sortable = require("@dnd-kit/react/sortable");
|
|
5660
5760
|
var import_modifiers = require("@dnd-kit/abstract/modifiers");
|
|
5661
5761
|
var import_dom2 = require("@dnd-kit/dom");
|
|
@@ -5692,7 +5792,7 @@ var MOVE_FEEDBACK = import_dom2.Feedback.configure({ feedback: "move" });
|
|
|
5692
5792
|
var withMoveFeedback = (defaults) => [...defaults, MOVE_FEEDBACK];
|
|
5693
5793
|
function useTrackReorderHandle() {
|
|
5694
5794
|
const { id, index } = useTrack();
|
|
5695
|
-
const wiring = (0,
|
|
5795
|
+
const wiring = (0, import_react50.use)(TrackSlotWiringContext);
|
|
5696
5796
|
const { ref, handleRef, isDragSource } = (0, import_sortable.useSortable)({
|
|
5697
5797
|
id: `track-reorder-${id}`,
|
|
5698
5798
|
index,
|
|
@@ -5733,12 +5833,12 @@ function useTrackReorderHandle() {
|
|
|
5733
5833
|
// either way. See browser/CLAUDE.md "Track Reordering".
|
|
5734
5834
|
plugins: withMoveFeedback
|
|
5735
5835
|
});
|
|
5736
|
-
(0,
|
|
5836
|
+
(0, import_react50.useEffect)(() => {
|
|
5737
5837
|
if (!wiring) return void 0;
|
|
5738
5838
|
ref(wiring.elementRef.current);
|
|
5739
5839
|
return () => ref(null);
|
|
5740
5840
|
}, [ref, wiring]);
|
|
5741
|
-
(0,
|
|
5841
|
+
(0, import_react50.useEffect)(() => {
|
|
5742
5842
|
if (!wiring) return void 0;
|
|
5743
5843
|
const { handleCount } = wiring;
|
|
5744
5844
|
handleCount.current += 1;
|
|
@@ -5751,12 +5851,12 @@ function useTrackReorderHandle() {
|
|
|
5751
5851
|
handleCount.current -= 1;
|
|
5752
5852
|
};
|
|
5753
5853
|
}, [wiring]);
|
|
5754
|
-
(0,
|
|
5854
|
+
(0, import_react50.useEffect)(() => {
|
|
5755
5855
|
if (!wiring) return void 0;
|
|
5756
5856
|
wiring.setDragSource(isDragSource);
|
|
5757
5857
|
return () => wiring.setDragSource(false);
|
|
5758
5858
|
}, [isDragSource, wiring]);
|
|
5759
|
-
(0,
|
|
5859
|
+
(0, import_react50.useEffect)(() => {
|
|
5760
5860
|
const element = wiring == null ? void 0 : wiring.elementRef.current;
|
|
5761
5861
|
if (!isDragSource || !element) return void 0;
|
|
5762
5862
|
return createDragPopoverHealer(element);
|
|
@@ -5841,7 +5941,7 @@ var TrackPanSlider = () => {
|
|
|
5841
5941
|
};
|
|
5842
5942
|
var TrackMenuButton = () => {
|
|
5843
5943
|
const { renderMode, hasSpectrogram, setRenderMode, openSpectrogramSettings } = useTrack();
|
|
5844
|
-
const shared = (0,
|
|
5944
|
+
const shared = (0, import_react51.use)(TrackControlsSharedContext);
|
|
5845
5945
|
if (!shared || !shared.menuAvailable || !hasSpectrogram) return null;
|
|
5846
5946
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
5847
5947
|
import_ui_components8.TrackMenu,
|
|
@@ -5921,10 +6021,10 @@ function DefaultTrackControlsImpl({ children }) {
|
|
|
5921
6021
|
children
|
|
5922
6022
|
] });
|
|
5923
6023
|
}
|
|
5924
|
-
var DefaultTrackControls =
|
|
6024
|
+
var DefaultTrackControls = import_react52.default.memo(DefaultTrackControlsImpl);
|
|
5925
6025
|
|
|
5926
6026
|
// src/utils/stableTemplate.ts
|
|
5927
|
-
var
|
|
6027
|
+
var import_react53 = require("react");
|
|
5928
6028
|
function sameStyle(a, b) {
|
|
5929
6029
|
if (Object.is(a, b)) return true;
|
|
5930
6030
|
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
@@ -5938,7 +6038,7 @@ function sameTemplate(a, b) {
|
|
|
5938
6038
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
5939
6039
|
return a.length === b.length && a.every((item, index) => sameTemplate(item, b[index]));
|
|
5940
6040
|
}
|
|
5941
|
-
if ((0,
|
|
6041
|
+
if ((0, import_react53.isValidElement)(a) && (0, import_react53.isValidElement)(b)) {
|
|
5942
6042
|
if (a.type !== b.type || a.key !== b.key) return false;
|
|
5943
6043
|
const one = a.props;
|
|
5944
6044
|
const other = b.props;
|
|
@@ -5954,7 +6054,7 @@ function sameTemplate(a, b) {
|
|
|
5954
6054
|
return false;
|
|
5955
6055
|
}
|
|
5956
6056
|
function useStableTemplate(template) {
|
|
5957
|
-
const kept = (0,
|
|
6057
|
+
const kept = (0, import_react53.useRef)(template);
|
|
5958
6058
|
if (!sameTemplate(kept.current, template)) {
|
|
5959
6059
|
kept.current = template;
|
|
5960
6060
|
}
|
|
@@ -5996,10 +6096,10 @@ function TrackControlsSlotImpl({
|
|
|
5996
6096
|
setSelectedTrackId
|
|
5997
6097
|
} = useEditorControls();
|
|
5998
6098
|
const theme = (0, import_ui_components10.useTheme)();
|
|
5999
|
-
const shared = (0,
|
|
6000
|
-
const indexRef = (0,
|
|
6099
|
+
const shared = (0, import_react54.use)(TrackControlsSharedContext);
|
|
6100
|
+
const indexRef = (0, import_react54.useRef)(index);
|
|
6001
6101
|
indexRef.current = index;
|
|
6002
|
-
const actions = (0,
|
|
6102
|
+
const actions = (0, import_react54.useMemo)(
|
|
6003
6103
|
() => ({
|
|
6004
6104
|
setMuted: (value2) => setTrackMute(trackId, value2),
|
|
6005
6105
|
setSoloed: (value2) => setTrackSolo(trackId, value2),
|
|
@@ -6023,7 +6123,7 @@ function TrackControlsSlotImpl({
|
|
|
6023
6123
|
shared
|
|
6024
6124
|
]
|
|
6025
6125
|
);
|
|
6026
|
-
const value = (0,
|
|
6126
|
+
const value = (0, import_react54.useMemo)(
|
|
6027
6127
|
() => __spreadValues({
|
|
6028
6128
|
id: trackId,
|
|
6029
6129
|
kind,
|
|
@@ -6058,9 +6158,9 @@ function TrackControlsSlotImpl({
|
|
|
6058
6158
|
actions
|
|
6059
6159
|
]
|
|
6060
6160
|
);
|
|
6061
|
-
const elementRef = (0,
|
|
6062
|
-
const [isDragSource, setDragSource] = (0,
|
|
6063
|
-
const wiring = (0,
|
|
6161
|
+
const elementRef = (0, import_react54.useRef)(null);
|
|
6162
|
+
const [isDragSource, setDragSource] = (0, import_react54.useState)(false);
|
|
6163
|
+
const wiring = (0, import_react54.useMemo)(
|
|
6064
6164
|
() => ({ elementRef, setDragSource, handleCount: { current: 0 } }),
|
|
6065
6165
|
[]
|
|
6066
6166
|
);
|
|
@@ -6091,7 +6191,7 @@ function TrackControlsSlotImpl({
|
|
|
6091
6191
|
}
|
|
6092
6192
|
);
|
|
6093
6193
|
}
|
|
6094
|
-
var TrackControlsSlot =
|
|
6194
|
+
var TrackControlsSlot = import_react54.default.memo(TrackControlsSlotImpl);
|
|
6095
6195
|
function WaveformTrackControlsImpl({ children }) {
|
|
6096
6196
|
const {
|
|
6097
6197
|
rows: tracks,
|
|
@@ -6101,7 +6201,7 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6101
6201
|
animateTrackLayout,
|
|
6102
6202
|
setSettingsModalTrackId
|
|
6103
6203
|
} = useWaveformRows("The track controls");
|
|
6104
|
-
if ((0,
|
|
6204
|
+
if ((0, import_react54.use)(WaveformPartPlaceContext) !== "controls") {
|
|
6105
6205
|
warnMisplacedPart(
|
|
6106
6206
|
"<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."
|
|
6107
6207
|
);
|
|
@@ -6109,13 +6209,13 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6109
6209
|
const { selectedTrackId } = useSelectedTrackId();
|
|
6110
6210
|
const { armedTrackId } = useRecordingArm();
|
|
6111
6211
|
const { trackReorderEpoch } = useTrackReorderPreview();
|
|
6112
|
-
const spectrogram = (0,
|
|
6212
|
+
const spectrogram = (0, import_react54.use)(SpectrogramIntegrationContext);
|
|
6113
6213
|
const { trackStates } = usePlaylistMixer();
|
|
6114
6214
|
const template = useStableTemplate(children != null ? children : DEFAULT_TEMPLATE);
|
|
6115
|
-
const spectrogramRef = (0,
|
|
6215
|
+
const spectrogramRef = (0, import_react54.useRef)(spectrogram);
|
|
6116
6216
|
spectrogramRef.current = spectrogram;
|
|
6117
6217
|
const menuAvailable = Boolean(spectrogram == null ? void 0 : spectrogram.renderMenuItems);
|
|
6118
|
-
const shared = (0,
|
|
6218
|
+
const shared = (0, import_react54.useMemo)(
|
|
6119
6219
|
() => ({
|
|
6120
6220
|
menuAvailable,
|
|
6121
6221
|
menuItems: (args) => {
|
|
@@ -6168,14 +6268,14 @@ function WaveformTrackControlsImpl({ children }) {
|
|
|
6168
6268
|
);
|
|
6169
6269
|
}) }) });
|
|
6170
6270
|
}
|
|
6171
|
-
var WaveformTrackControls =
|
|
6271
|
+
var WaveformTrackControls = import_react54.default.memo(WaveformTrackControlsImpl);
|
|
6172
6272
|
|
|
6173
6273
|
// src/components/VisualizationOverlays.tsx
|
|
6174
|
-
var
|
|
6274
|
+
var import_react56 = __toESM(require("react"));
|
|
6175
6275
|
var import_ui_components12 = require("@waveform-playlist/ui-components");
|
|
6176
6276
|
|
|
6177
6277
|
// src/components/AnimatedPlayhead.tsx
|
|
6178
|
-
var
|
|
6278
|
+
var import_react55 = require("react");
|
|
6179
6279
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
6180
6280
|
var import_ui_components11 = require("@waveform-playlist/ui-components");
|
|
6181
6281
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
@@ -6194,15 +6294,15 @@ var PlayheadLine = import_styled_components7.default.div.attrs((props) => ({
|
|
|
6194
6294
|
will-change: transform;
|
|
6195
6295
|
`;
|
|
6196
6296
|
var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
6197
|
-
const playheadRef = (0,
|
|
6198
|
-
const frameCallbackId = (0,
|
|
6297
|
+
const playheadRef = (0, import_react55.useRef)(null);
|
|
6298
|
+
const frameCallbackId = (0, import_react55.useId)();
|
|
6199
6299
|
const { currentTimeRef, visualTimeRef, registerFrameCallback, unregisterFrameCallback } = usePlaybackRefs();
|
|
6200
6300
|
const { isPlaying } = useIsPlaying();
|
|
6201
6301
|
useCurrentTime();
|
|
6202
6302
|
const { sampleRate } = usePlaylistView();
|
|
6203
6303
|
const { progressBarWidth } = (0, import_ui_components11.usePlaylistInfo)();
|
|
6204
6304
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6205
|
-
(0,
|
|
6305
|
+
(0, import_react55.useEffect)(() => {
|
|
6206
6306
|
if (isPlaying) {
|
|
6207
6307
|
registerFrameCallback(
|
|
6208
6308
|
frameCallbackId,
|
|
@@ -6216,7 +6316,7 @@ var AnimatedPlayhead = ({ color = "#ff0000" }) => {
|
|
|
6216
6316
|
}
|
|
6217
6317
|
return () => unregisterFrameCallback(frameCallbackId);
|
|
6218
6318
|
}, [isPlaying, frameCallbackId, registerFrameCallback, unregisterFrameCallback]);
|
|
6219
|
-
(0,
|
|
6319
|
+
(0, import_react55.useEffect)(() => {
|
|
6220
6320
|
var _a, _b;
|
|
6221
6321
|
if (!isPlaying && playheadRef.current) {
|
|
6222
6322
|
const time = (_b = (_a = visualTimeRef.current) != null ? _a : currentTimeRef.current) != null ? _b : 0;
|
|
@@ -6232,13 +6332,13 @@ var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
|
6232
6332
|
var subscribeToNothing3 = () => () => {
|
|
6233
6333
|
};
|
|
6234
6334
|
var noPreview = () => null;
|
|
6235
|
-
var WaveformSelection =
|
|
6335
|
+
var WaveformSelection = import_react56.default.memo(function WaveformSelection2() {
|
|
6236
6336
|
const theme = (0, import_ui_components12.useTheme)();
|
|
6237
6337
|
const { selectionStart, selectionEnd } = useSelection();
|
|
6238
6338
|
const { sampleRate } = usePlaylistView();
|
|
6239
6339
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6240
|
-
const previewSource = (0,
|
|
6241
|
-
const preview = (0,
|
|
6340
|
+
const previewSource = (0, import_react56.use)(SelectionPreviewContext);
|
|
6341
|
+
const preview = (0, import_react56.useSyncExternalStore)(
|
|
6242
6342
|
previewSource ? (onChange) => previewSource.subscribe(onChange) : subscribeToNothing3,
|
|
6243
6343
|
previewSource ? () => previewSource.getSnapshot() : noPreview,
|
|
6244
6344
|
previewSource ? () => previewSource.getSnapshot() : noPreview
|
|
@@ -6288,9 +6388,9 @@ var WaveformPlayhead = ({ renderPlayhead }) => {
|
|
|
6288
6388
|
}
|
|
6289
6389
|
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AnimatedPlayhead, { color: theme.playheadColor });
|
|
6290
6390
|
};
|
|
6291
|
-
var WaveformLoopRegion =
|
|
6391
|
+
var WaveformLoopRegion = import_react56.default.memo(function WaveformLoopRegion2() {
|
|
6292
6392
|
const { tracksFullWidth: maxPosition } = useWaveformExtent("The loop region");
|
|
6293
|
-
if ((0,
|
|
6393
|
+
if ((0, import_react56.use)(WaveformPartPlaceContext) !== "timescale") {
|
|
6294
6394
|
warnMisplacedPart(
|
|
6295
6395
|
"<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."
|
|
6296
6396
|
);
|
|
@@ -6320,11 +6420,11 @@ var WaveformLoopRegion = import_react54.default.memo(function WaveformLoopRegion
|
|
|
6320
6420
|
});
|
|
6321
6421
|
|
|
6322
6422
|
// src/components/WaveformViewOptions.tsx
|
|
6323
|
-
var
|
|
6423
|
+
var import_react57 = require("react");
|
|
6324
6424
|
var import_ui_components13 = require("@waveform-playlist/ui-components");
|
|
6325
6425
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
6326
6426
|
var NO_OPTIONS = {};
|
|
6327
|
-
var WaveformViewOptionsContext = (0,
|
|
6427
|
+
var WaveformViewOptionsContext = (0, import_react57.createContext)(NO_OPTIONS);
|
|
6328
6428
|
var WaveformViewOptions = ({
|
|
6329
6429
|
children,
|
|
6330
6430
|
waveHeight: ownWaveHeight,
|
|
@@ -6334,14 +6434,14 @@ var WaveformViewOptions = ({
|
|
|
6334
6434
|
progressBarWidth: ownProgressBarWidth,
|
|
6335
6435
|
fillViewport: ownFillViewport
|
|
6336
6436
|
}) => {
|
|
6337
|
-
const above = (0,
|
|
6437
|
+
const above = (0, import_react57.use)(WaveformViewOptionsContext);
|
|
6338
6438
|
const waveHeight = ownWaveHeight != null ? ownWaveHeight : above.waveHeight;
|
|
6339
6439
|
const barWidth = ownBarWidth != null ? ownBarWidth : above.barWidth;
|
|
6340
6440
|
const barGap = ownBarGap != null ? ownBarGap : above.barGap;
|
|
6341
6441
|
const roundedBars = ownRoundedBars != null ? ownRoundedBars : above.roundedBars;
|
|
6342
6442
|
const progressBarWidth = ownProgressBarWidth != null ? ownProgressBarWidth : above.progressBarWidth;
|
|
6343
6443
|
const fillViewport = ownFillViewport != null ? ownFillViewport : above.fillViewport;
|
|
6344
|
-
const value = (0,
|
|
6444
|
+
const value = (0, import_react57.useMemo)(
|
|
6345
6445
|
() => ({ waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport }),
|
|
6346
6446
|
[waveHeight, barWidth, barGap, roundedBars, progressBarWidth, fillViewport]
|
|
6347
6447
|
);
|
|
@@ -6350,7 +6450,7 @@ var WaveformViewOptions = ({
|
|
|
6350
6450
|
var isPositive = (value) => value > 0;
|
|
6351
6451
|
function useResolvedViewOptions() {
|
|
6352
6452
|
var _a, _b, _c, _d, _e, _f;
|
|
6353
|
-
const options = (0,
|
|
6453
|
+
const options = (0, import_react57.use)(WaveformViewOptionsContext);
|
|
6354
6454
|
let waveHeight = (_a = options.waveHeight) != null ? _a : import_ui_components13.DEFAULT_WAVE_HEIGHT;
|
|
6355
6455
|
let barWidth = (_b = options.barWidth) != null ? _b : import_ui_components13.DEFAULT_BAR_WIDTH;
|
|
6356
6456
|
let barGap = (_c = options.barGap) != null ? _c : import_ui_components13.DEFAULT_BAR_GAP;
|
|
@@ -6394,11 +6494,11 @@ function useResolvedViewOptions() {
|
|
|
6394
6494
|
// src/components/waveformParts.tsx
|
|
6395
6495
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
6396
6496
|
var DEFAULT_TIMESCALE_HEIGHT = 30;
|
|
6397
|
-
var WaveformTimescale =
|
|
6497
|
+
var WaveformTimescale = import_react58.default.memo(function WaveformTimescale2({
|
|
6398
6498
|
renderTick
|
|
6399
6499
|
}) {
|
|
6400
6500
|
const { displayDuration } = useWaveformExtent("The timescale");
|
|
6401
|
-
if ((0,
|
|
6501
|
+
if ((0, import_react58.use)(WaveformPartPlaceContext) !== "timescale") {
|
|
6402
6502
|
warnMisplacedPart(
|
|
6403
6503
|
"<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."
|
|
6404
6504
|
);
|
|
@@ -6419,9 +6519,9 @@ function sortWaveformParts(children) {
|
|
|
6419
6519
|
let timescaleHeightGiven = false;
|
|
6420
6520
|
let tracksParts = 0;
|
|
6421
6521
|
const visit = (node) => {
|
|
6422
|
-
|
|
6423
|
-
if (
|
|
6424
|
-
if (child.type ===
|
|
6522
|
+
import_react58.default.Children.forEach(node, (child) => {
|
|
6523
|
+
if (import_react58.default.isValidElement(child)) {
|
|
6524
|
+
if (child.type === import_react58.default.Fragment) {
|
|
6425
6525
|
visit(child.props.children);
|
|
6426
6526
|
return;
|
|
6427
6527
|
}
|
|
@@ -6490,12 +6590,12 @@ var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
|
6490
6590
|
function keyedByKind(parts) {
|
|
6491
6591
|
const seen = { timescale: 0, loop: 0 };
|
|
6492
6592
|
return parts.map((part) => {
|
|
6493
|
-
const kind =
|
|
6494
|
-
return (0,
|
|
6593
|
+
const kind = import_react59.default.isValidElement(part) && part.type === WaveformTimescale ? "timescale" : "loop";
|
|
6594
|
+
return (0, import_react59.createElement)(import_react59.Fragment, { key: `${kind}-${seen[kind]++}` }, part);
|
|
6495
6595
|
});
|
|
6496
6596
|
}
|
|
6497
6597
|
function useWaveformParts(children) {
|
|
6498
|
-
return (0,
|
|
6598
|
+
return (0, import_react59.useMemo)(() => {
|
|
6499
6599
|
const sorted = sortWaveformParts(children);
|
|
6500
6600
|
return {
|
|
6501
6601
|
// One element per place. The tracks-area and controls parts are its
|
|
@@ -6503,9 +6603,9 @@ function useWaveformParts(children) {
|
|
|
6503
6603
|
// by kind (`keyedByKind`).
|
|
6504
6604
|
timescale: sorted.timescale.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "timescale", children: keyedByKind(sorted.timescale) }) : null,
|
|
6505
6605
|
controls: sorted.controls.length > 0 ? [
|
|
6506
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "controls", children: (0,
|
|
6606
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(WaveformPartPlaceContext, { value: "controls", children: (0, import_react59.createElement)(import_react59.Fragment, null, ...sorted.controls) }, "controls")
|
|
6507
6607
|
] : void 0,
|
|
6508
|
-
content: (0,
|
|
6608
|
+
content: (0, import_react59.createElement)(import_react59.Fragment, null, ...sorted.content),
|
|
6509
6609
|
tracksOptions: sorted.tracksOptions,
|
|
6510
6610
|
controlsWidth: sorted.controlsWidth,
|
|
6511
6611
|
timescaleHeight: sorted.timescaleHeight
|
|
@@ -6531,7 +6631,7 @@ function useWaveformFrame({
|
|
|
6531
6631
|
const { waveHeight, barWidth, barGap, roundedBars, progressBarWidth } = viewOptions;
|
|
6532
6632
|
const timeScaleHeight = parts.timescaleHeight;
|
|
6533
6633
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6534
|
-
const handleScrollContainerRef = (0,
|
|
6634
|
+
const handleScrollContainerRef = (0, import_react59.useCallback)(
|
|
6535
6635
|
(element) => {
|
|
6536
6636
|
onScrollContainer == null ? void 0 : onScrollContainer(element);
|
|
6537
6637
|
setScrollContainer(element);
|
|
@@ -6545,7 +6645,7 @@ function useWaveformFrame({
|
|
|
6545
6645
|
preview: selectionPreview,
|
|
6546
6646
|
automaticScrollRef
|
|
6547
6647
|
} = useSelectionDrag({ samplesPerPixel, sampleRate, onPress, onClickWhileStopped });
|
|
6548
|
-
const playlistInfo = (0,
|
|
6648
|
+
const playlistInfo = (0, import_react59.useMemo)(
|
|
6549
6649
|
() => ({
|
|
6550
6650
|
samplesPerPixel,
|
|
6551
6651
|
sampleRate,
|
|
@@ -6567,7 +6667,7 @@ function useWaveformFrame({
|
|
|
6567
6667
|
progressBarWidth
|
|
6568
6668
|
]
|
|
6569
6669
|
);
|
|
6570
|
-
const extent = (0,
|
|
6670
|
+
const extent = (0, import_react59.useMemo)(
|
|
6571
6671
|
() => ({ displayDuration, tracksFullWidth }),
|
|
6572
6672
|
[displayDuration, tracksFullWidth]
|
|
6573
6673
|
);
|
|
@@ -6615,10 +6715,10 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6615
6715
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6616
6716
|
const { peaksDataArray, tracks, duration, isReady } = usePlaylistTimeline();
|
|
6617
6717
|
const { trackDragPreview } = useTrackReorderPreview();
|
|
6618
|
-
const spectrogram = (0,
|
|
6718
|
+
const spectrogram = (0, import_react60.use)(SpectrogramIntegrationContext);
|
|
6619
6719
|
const parts = useWaveformParts(children);
|
|
6620
6720
|
const { showClipHeaders, recordingState } = parts.tracksOptions;
|
|
6621
|
-
const spectrogramHelpersById = (0,
|
|
6721
|
+
const spectrogramHelpersById = (0, import_react60.useMemo)(() => {
|
|
6622
6722
|
const helpers = /* @__PURE__ */ new Map();
|
|
6623
6723
|
if (!spectrogram) return helpers;
|
|
6624
6724
|
tracks.forEach((track) => {
|
|
@@ -6639,7 +6739,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6639
6739
|
});
|
|
6640
6740
|
return helpers;
|
|
6641
6741
|
}, [tracks, spectrogram]);
|
|
6642
|
-
const renderModeById = (0,
|
|
6742
|
+
const renderModeById = (0, import_react60.useMemo)(() => {
|
|
6643
6743
|
const modes = /* @__PURE__ */ new Map();
|
|
6644
6744
|
tracks.forEach((track) => {
|
|
6645
6745
|
var _a2;
|
|
@@ -6659,12 +6759,12 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6659
6759
|
const recordingTrackId = (recordingState == null ? void 0 : recordingState.isRecording) ? recordingState.trackId : null;
|
|
6660
6760
|
const trimPreviewEnd = useTrimPreviewExtent(sampleRate, duration);
|
|
6661
6761
|
const recordingChannelCount = recordingProgress ? mono ? 1 : recordingLayout.channelCount : 0;
|
|
6662
|
-
const [settingsModalTrackId, setSettingsModalTrackId] = (0,
|
|
6663
|
-
const closeSettingsModal = (0,
|
|
6664
|
-
const [scrollContainerElement, setScrollContainerElement] = (0,
|
|
6762
|
+
const [settingsModalTrackId, setSettingsModalTrackId] = (0, import_react60.useState)(null);
|
|
6763
|
+
const closeSettingsModal = (0, import_react60.useCallback)(() => setSettingsModalTrackId(null), []);
|
|
6764
|
+
const [scrollContainerElement, setScrollContainerElement] = (0, import_react60.useState)(null);
|
|
6665
6765
|
const fillsContainer = indefinitePlayback || fillViewport;
|
|
6666
|
-
const [scrollContainerWidth, setScrollContainerWidth] = (0,
|
|
6667
|
-
(0,
|
|
6766
|
+
const [scrollContainerWidth, setScrollContainerWidth] = (0, import_react60.useState)(0);
|
|
6767
|
+
(0, import_react60.useLayoutEffect)(() => {
|
|
6668
6768
|
if (!fillsContainer || !scrollContainerElement) return;
|
|
6669
6769
|
const measure = () => setScrollContainerWidth(scrollContainerElement.clientWidth);
|
|
6670
6770
|
measure();
|
|
@@ -6673,7 +6773,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6673
6773
|
observer.observe(scrollContainerElement);
|
|
6674
6774
|
return () => observer.disconnect();
|
|
6675
6775
|
}, [fillsContainer, scrollContainerElement]);
|
|
6676
|
-
const placeholdersEndSeconds = (0,
|
|
6776
|
+
const placeholdersEndSeconds = (0, import_react60.useMemo)(() => placeholdersEnd(peaksDataArray), [peaksDataArray]);
|
|
6677
6777
|
let displayDuration = Math.max(
|
|
6678
6778
|
duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION,
|
|
6679
6779
|
placeholdersEndSeconds
|
|
@@ -6686,9 +6786,9 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6686
6786
|
displayDuration = Math.max(displayDuration, recordingLayout.displayEndSeconds);
|
|
6687
6787
|
}
|
|
6688
6788
|
displayDuration = Math.max(displayDuration, trimPreviewEnd);
|
|
6689
|
-
const tracksRef = (0,
|
|
6789
|
+
const tracksRef = (0, import_react60.useRef)(tracks);
|
|
6690
6790
|
tracksRef.current = tracks;
|
|
6691
|
-
const selectTrack = (0,
|
|
6791
|
+
const selectTrack = (0, import_react60.useCallback)(
|
|
6692
6792
|
(trackIndex) => {
|
|
6693
6793
|
const track = tracksRef.current[trackIndex];
|
|
6694
6794
|
if (track) {
|
|
@@ -6697,7 +6797,7 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6697
6797
|
},
|
|
6698
6798
|
[setSelectedTrackId]
|
|
6699
6799
|
);
|
|
6700
|
-
const trackHeightById = (0,
|
|
6800
|
+
const trackHeightById = (0, import_react60.useMemo)(() => {
|
|
6701
6801
|
const m = /* @__PURE__ */ new Map();
|
|
6702
6802
|
peaksDataArray.forEach((trackClipPeaks, trackIndex) => {
|
|
6703
6803
|
const track = tracks[trackIndex];
|
|
@@ -6717,21 +6817,21 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6717
6817
|
waveHeight,
|
|
6718
6818
|
showClipHeaders
|
|
6719
6819
|
]);
|
|
6720
|
-
const displayOrderIds = (0,
|
|
6820
|
+
const displayOrderIds = (0, import_react60.useMemo)(
|
|
6721
6821
|
() => applyTrackOrderPreview(tracks, trackDragPreview).map((t) => t.id),
|
|
6722
6822
|
[tracks, trackDragPreview]
|
|
6723
6823
|
);
|
|
6724
|
-
const trackLayout = (0,
|
|
6824
|
+
const trackLayout = (0, import_react60.useMemo)(
|
|
6725
6825
|
() => computeTrackLayout(displayOrderIds, trackHeightById),
|
|
6726
6826
|
[displayOrderIds, trackHeightById]
|
|
6727
6827
|
);
|
|
6728
6828
|
const animateTrackLayout = useTrailingActive(trackDragPreview !== null, 200);
|
|
6729
|
-
const rowList = (0,
|
|
6730
|
-
() => tracks.map((track) => ({ id: track.id, kind: (0,
|
|
6829
|
+
const rowList = (0, import_react60.useMemo)(
|
|
6830
|
+
() => tracks.map((track) => ({ id: track.id, kind: (0, import_core13.trackKind)(track) })),
|
|
6731
6831
|
[tracks]
|
|
6732
6832
|
);
|
|
6733
6833
|
const dragSourceTrackId = (_b = trackDragPreview == null ? void 0 : trackDragPreview.trackId) != null ? _b : null;
|
|
6734
|
-
const rows = (0,
|
|
6834
|
+
const rows = (0, import_react60.useMemo)(
|
|
6735
6835
|
() => ({
|
|
6736
6836
|
rows: rowList,
|
|
6737
6837
|
peaksDataArray,
|
|
@@ -6805,17 +6905,17 @@ var WaveformRoot = ({ className, children }) => {
|
|
|
6805
6905
|
};
|
|
6806
6906
|
|
|
6807
6907
|
// src/components/WaveformAnnotationBoxes.tsx
|
|
6808
|
-
var
|
|
6809
|
-
var
|
|
6908
|
+
var import_react63 = __toESM(require("react"));
|
|
6909
|
+
var import_react64 = require("@dnd-kit/react");
|
|
6810
6910
|
var import_modifiers2 = require("@dnd-kit/abstract/modifiers");
|
|
6811
6911
|
var import_ui_components17 = require("@waveform-playlist/ui-components");
|
|
6812
6912
|
|
|
6813
6913
|
// src/AnnotationIntegrationContext.tsx
|
|
6814
|
-
var
|
|
6815
|
-
var AnnotationIntegrationContext = (0,
|
|
6914
|
+
var import_react61 = require("react");
|
|
6915
|
+
var AnnotationIntegrationContext = (0, import_react61.createContext)(null);
|
|
6816
6916
|
var AnnotationIntegrationProvider = AnnotationIntegrationContext.Provider;
|
|
6817
6917
|
function useAnnotationIntegration() {
|
|
6818
|
-
const context = (0,
|
|
6918
|
+
const context = (0, import_react61.use)(AnnotationIntegrationContext);
|
|
6819
6919
|
if (!context) {
|
|
6820
6920
|
throw new Error(
|
|
6821
6921
|
"useAnnotationIntegration must be used within <AnnotationProvider>. Install @waveform-playlist/annotations (" + installCommand("@waveform-playlist/annotations") + ") and wrap your app with <AnnotationProvider>. See: https://naomiaro.github.io/waveform-playlist/docs/react/guides/annotations"
|
|
@@ -6825,9 +6925,9 @@ function useAnnotationIntegration() {
|
|
|
6825
6925
|
}
|
|
6826
6926
|
|
|
6827
6927
|
// src/components/AnnotationBoxes.tsx
|
|
6828
|
-
var
|
|
6928
|
+
var import_react62 = __toESM(require("react"));
|
|
6829
6929
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
6830
|
-
var AnnotationBoxItem =
|
|
6930
|
+
var AnnotationBoxItem = import_react62.default.memo(function AnnotationBoxItem2({
|
|
6831
6931
|
AnnotationBox,
|
|
6832
6932
|
annotation,
|
|
6833
6933
|
index,
|
|
@@ -6866,7 +6966,7 @@ var AnnotationBoxes = ({
|
|
|
6866
6966
|
getLabel,
|
|
6867
6967
|
onSelect
|
|
6868
6968
|
}) => {
|
|
6869
|
-
const annotationIntegration = (0,
|
|
6969
|
+
const annotationIntegration = (0, import_react62.use)(AnnotationIntegrationContext);
|
|
6870
6970
|
if (annotations.length === 0 || !annotationIntegration) return null;
|
|
6871
6971
|
const { AnnotationBox, AnnotationBoxesWrapper } = annotationIntegration;
|
|
6872
6972
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AnnotationBoxesWrapper, { height, width, children: annotations.map((annotation, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -6891,16 +6991,16 @@ var AnnotationBoxes = ({
|
|
|
6891
6991
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
6892
6992
|
var HORIZONTAL_ONLY = [import_modifiers2.RestrictToHorizontalAxis];
|
|
6893
6993
|
var DEFAULT_ANNOTATION_BOXES_HEIGHT = 30;
|
|
6894
|
-
var WaveformAnnotationBoxes =
|
|
6994
|
+
var WaveformAnnotationBoxes = import_react63.default.memo(function WaveformAnnotationBoxes2({
|
|
6895
6995
|
getLabel,
|
|
6896
6996
|
height = DEFAULT_ANNOTATION_BOXES_HEIGHT
|
|
6897
6997
|
}) {
|
|
6898
6998
|
const { tracksFullWidth: width, displayDuration } = useWaveformExtent("The annotation boxes");
|
|
6899
|
-
const integration = (0,
|
|
6999
|
+
const integration = (0, import_react63.use)(AnnotationIntegrationContext);
|
|
6900
7000
|
const { annotations } = useAnnotations();
|
|
6901
7001
|
const { editable, linkEndpoints } = useAnnotationOptions();
|
|
6902
7002
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6903
|
-
const {
|
|
7003
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6904
7004
|
const { sampleRate } = usePlaylistView();
|
|
6905
7005
|
const { samplesPerPixel } = usePlaylistZoom();
|
|
6906
7006
|
const { touchOptimized } = useClipInteraction();
|
|
@@ -6908,8 +7008,7 @@ var WaveformAnnotationBoxes = import_react61.default.memo(function WaveformAnnot
|
|
|
6908
7008
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6909
7009
|
const sensors = useDragSensors({ touchOptimized });
|
|
6910
7010
|
const { onDragStart, onDragMove, onDragEnd } = useAnnotationDragHandlers({
|
|
6911
|
-
|
|
6912
|
-
onAnnotationsChange: setAnnotations,
|
|
7011
|
+
store: annotationStore,
|
|
6913
7012
|
preview: annotationPreview,
|
|
6914
7013
|
samplesPerPixel,
|
|
6915
7014
|
sampleRate,
|
|
@@ -6918,7 +7017,7 @@ var WaveformAnnotationBoxes = import_react61.default.memo(function WaveformAnnot
|
|
|
6918
7017
|
});
|
|
6919
7018
|
if (annotations.length === 0 || !integration) return null;
|
|
6920
7019
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
6921
|
-
|
|
7020
|
+
import_react64.DragDropProvider,
|
|
6922
7021
|
{
|
|
6923
7022
|
sensors,
|
|
6924
7023
|
onDragStart,
|
|
@@ -6945,7 +7044,7 @@ var WaveformAnnotationBoxes = import_react61.default.memo(function WaveformAnnot
|
|
|
6945
7044
|
});
|
|
6946
7045
|
|
|
6947
7046
|
// src/components/AnnotationList.tsx
|
|
6948
|
-
var
|
|
7047
|
+
var import_react65 = require("react");
|
|
6949
7048
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
6950
7049
|
var AnnotationList = ({
|
|
6951
7050
|
height,
|
|
@@ -6954,13 +7053,13 @@ var AnnotationList = ({
|
|
|
6954
7053
|
scrollActiveContainer = "nearest",
|
|
6955
7054
|
children
|
|
6956
7055
|
}) => {
|
|
6957
|
-
const integration = (0,
|
|
7056
|
+
const integration = (0, import_react65.use)(AnnotationIntegrationContext);
|
|
6958
7057
|
const { annotations } = useAnnotations();
|
|
6959
7058
|
const { editable, linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
6960
7059
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
6961
|
-
const {
|
|
7060
|
+
const { annotationStore, annotationPreview, playAnnotation } = usePlaybackControls();
|
|
6962
7061
|
const shownAnnotations = useAnnotationsWithPreview(annotations, annotationPreview);
|
|
6963
|
-
const actionOptions = (0,
|
|
7062
|
+
const actionOptions = (0, import_react65.useMemo)(
|
|
6964
7063
|
() => ({ linkEndpoints, continuousPlay }),
|
|
6965
7064
|
[linkEndpoints, continuousPlay]
|
|
6966
7065
|
);
|
|
@@ -6986,7 +7085,7 @@ var AnnotationList = ({
|
|
|
6986
7085
|
annotationListConfig: actionOptions,
|
|
6987
7086
|
height,
|
|
6988
7087
|
onAnnotationClick: playAnnotation,
|
|
6989
|
-
|
|
7088
|
+
store: annotationStore,
|
|
6990
7089
|
renderAnnotationItem: children
|
|
6991
7090
|
}
|
|
6992
7091
|
);
|
|
@@ -7024,7 +7123,7 @@ var Waveform = (props) => composeWaveform(__spreadProps(__spreadValues({}, props
|
|
|
7024
7123
|
var WaveformEditor = (props) => composeWaveform(__spreadProps(__spreadValues({}, props), { tracks: TRACKS_WITH_HEADERS_AND_FADES }));
|
|
7025
7124
|
|
|
7026
7125
|
// src/components/MediaElementWaveformRoot.tsx
|
|
7027
|
-
var
|
|
7126
|
+
var import_react66 = require("react");
|
|
7028
7127
|
var import_ui_components18 = require("@waveform-playlist/ui-components");
|
|
7029
7128
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
7030
7129
|
var ONE_ROW = [{ id: MEDIA_ELEMENT_TRACK_ID, kind: "audio" }];
|
|
@@ -7048,7 +7147,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7048
7147
|
);
|
|
7049
7148
|
}
|
|
7050
7149
|
const { showClipHeaders } = parts.tracksOptions;
|
|
7051
|
-
const rows = (0,
|
|
7150
|
+
const rows = (0, import_react66.useMemo)(() => {
|
|
7052
7151
|
const rowList = ONE_ROW;
|
|
7053
7152
|
const rowPeaks = peaksDataArray.length > 0 ? peaksDataArray : ONE_EMPTY_ROW;
|
|
7054
7153
|
const trackHeightById = /* @__PURE__ */ new Map();
|
|
@@ -7077,7 +7176,7 @@ var MediaElementWaveformRoot = ({
|
|
|
7077
7176
|
dragSourceTrackId: null
|
|
7078
7177
|
};
|
|
7079
7178
|
}, [peaksDataArray, waveHeight, showClipHeaders]);
|
|
7080
|
-
const collapseSelectionAt = (0,
|
|
7179
|
+
const collapseSelectionAt = (0, import_react66.useCallback)(
|
|
7081
7180
|
(time) => setSelection(time, time),
|
|
7082
7181
|
[setSelection]
|
|
7083
7182
|
);
|
|
@@ -7128,7 +7227,7 @@ var KeyboardShortcuts = ({
|
|
|
7128
7227
|
const { annotations: annotationList } = useAnnotations();
|
|
7129
7228
|
const { linkEndpoints, continuousPlay } = useAnnotationOptions();
|
|
7130
7229
|
const { activeAnnotationId } = useActiveAnnotation();
|
|
7131
|
-
const {
|
|
7230
|
+
const { annotationStore, setActiveAnnotationId, scrollContainerRef, play } = usePlaybackControls();
|
|
7132
7231
|
const { undo, redo } = useEditorControls();
|
|
7133
7232
|
const { splitClipAtPlayhead } = useClipSplitting({ samplesPerPixel });
|
|
7134
7233
|
const allAdditional = [];
|
|
@@ -7155,9 +7254,8 @@ var KeyboardShortcuts = ({
|
|
|
7155
7254
|
enabled: playback || allAdditional.length > 0
|
|
7156
7255
|
}, playback ? { additionalShortcuts: allAdditional } : { shortcuts: allAdditional }));
|
|
7157
7256
|
useAnnotationKeyboardControls({
|
|
7158
|
-
|
|
7257
|
+
store: annotationStore,
|
|
7159
7258
|
activeAnnotationId,
|
|
7160
|
-
onAnnotationsChange: setAnnotations,
|
|
7161
7259
|
onActiveAnnotationChange: setActiveAnnotationId,
|
|
7162
7260
|
duration,
|
|
7163
7261
|
linkEndpoints,
|
|
@@ -7170,11 +7268,11 @@ var KeyboardShortcuts = ({
|
|
|
7170
7268
|
};
|
|
7171
7269
|
|
|
7172
7270
|
// src/hooks/useRecordingSession.ts
|
|
7173
|
-
var
|
|
7271
|
+
var import_react67 = require("react");
|
|
7174
7272
|
function useRecordingSession({ isRecording, trackId }) {
|
|
7175
7273
|
const { setRecordingActive } = useEditorControls();
|
|
7176
7274
|
const armedTrackId = trackId != null ? trackId : null;
|
|
7177
|
-
(0,
|
|
7275
|
+
(0, import_react67.useEffect)(() => {
|
|
7178
7276
|
if (!isRecording) return void 0;
|
|
7179
7277
|
setRecordingActive(true, armedTrackId);
|
|
7180
7278
|
return () => setRecordingActive(false);
|
|
@@ -7182,11 +7280,11 @@ function useRecordingSession({ isRecording, trackId }) {
|
|
|
7182
7280
|
}
|
|
7183
7281
|
|
|
7184
7282
|
// src/components/ClipInteractionProvider.tsx
|
|
7185
|
-
var
|
|
7283
|
+
var import_react68 = __toESM(require("react"));
|
|
7186
7284
|
var import_react_dom3 = require("react-dom");
|
|
7187
|
-
var
|
|
7285
|
+
var import_react69 = require("@dnd-kit/react");
|
|
7188
7286
|
var import_modifiers3 = require("@dnd-kit/abstract/modifiers");
|
|
7189
|
-
var
|
|
7287
|
+
var import_core15 = require("@waveform-playlist/core");
|
|
7190
7288
|
var import_ui_components19 = require("@waveform-playlist/ui-components");
|
|
7191
7289
|
|
|
7192
7290
|
// src/modifiers/ClipCollisionModifier.ts
|
|
@@ -7216,7 +7314,7 @@ var ClipCollisionModifier = _ClipCollisionModifier;
|
|
|
7216
7314
|
|
|
7217
7315
|
// src/modifiers/SnapToGridModifier.ts
|
|
7218
7316
|
var import_abstract2 = require("@dnd-kit/abstract");
|
|
7219
|
-
var
|
|
7317
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
7220
7318
|
var _SnapToGridModifier = class _SnapToGridModifier extends import_abstract2.Modifier {
|
|
7221
7319
|
apply(operation) {
|
|
7222
7320
|
const { transform, source } = operation;
|
|
@@ -7237,18 +7335,18 @@ var _SnapToGridModifier = class _SnapToGridModifier extends import_abstract2.Mod
|
|
|
7237
7335
|
}
|
|
7238
7336
|
const { snapTo, bpm, timeSignature, sampleRate } = this.options;
|
|
7239
7337
|
if (snapTo === "off") return transform;
|
|
7240
|
-
const gridTicks = snapTo === "bar" ? (0,
|
|
7338
|
+
const gridTicks = snapTo === "bar" ? (0, import_core14.ticksPerBar)(timeSignature) : (0, import_core14.ticksPerBeat)(timeSignature);
|
|
7241
7339
|
if (startSample !== void 0) {
|
|
7242
7340
|
const proposedSamples = startSample + transform.x * samplesPerPixel;
|
|
7243
|
-
const proposedTicks = (0,
|
|
7244
|
-
const snappedTicks2 = (0,
|
|
7245
|
-
const snappedSamples2 = (0,
|
|
7341
|
+
const proposedTicks = (0, import_core14.samplesToTicks)(proposedSamples, bpm, sampleRate);
|
|
7342
|
+
const snappedTicks2 = (0, import_core14.snapToGrid)(proposedTicks, gridTicks);
|
|
7343
|
+
const snappedSamples2 = (0, import_core14.ticksToSamples)(snappedTicks2, bpm, sampleRate);
|
|
7246
7344
|
return { x: (snappedSamples2 - startSample) / samplesPerPixel, y: 0 };
|
|
7247
7345
|
}
|
|
7248
7346
|
const deltaSamples = transform.x * samplesPerPixel;
|
|
7249
|
-
const deltaTicks = (0,
|
|
7250
|
-
const snappedTicks = (0,
|
|
7251
|
-
const snappedSamples = (0,
|
|
7347
|
+
const deltaTicks = (0, import_core14.samplesToTicks)(deltaSamples, bpm, sampleRate);
|
|
7348
|
+
const snappedTicks = (0, import_core14.snapToGrid)(deltaTicks, gridTicks);
|
|
7349
|
+
const snappedSamples = (0, import_core14.ticksToSamples)(snappedTicks, bpm, sampleRate);
|
|
7252
7350
|
return { x: snappedSamples / samplesPerPixel, y: 0 };
|
|
7253
7351
|
}
|
|
7254
7352
|
};
|
|
@@ -7271,14 +7369,14 @@ var ClipInteractionProvider = ({
|
|
|
7271
7369
|
const beatsAndBars = (0, import_ui_components19.useBeatsAndBars)();
|
|
7272
7370
|
const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
|
|
7273
7371
|
const useTimescaleSnap = snap && !useBeatsSnap;
|
|
7274
|
-
const snapSamplePosition = (0,
|
|
7372
|
+
const snapSamplePosition = (0, import_react68.useMemo)(() => {
|
|
7275
7373
|
if (useBeatsSnap && beatsAndBars) {
|
|
7276
7374
|
const { bpm, timeSignature, snapTo } = beatsAndBars;
|
|
7277
|
-
const gridTicks = snapTo === "bar" ? (0,
|
|
7375
|
+
const gridTicks = snapTo === "bar" ? (0, import_core15.ticksPerBar)(timeSignature) : (0, import_core15.ticksPerBeat)(timeSignature);
|
|
7278
7376
|
return (samplePos) => {
|
|
7279
|
-
const ticks = (0,
|
|
7280
|
-
const snapped = (0,
|
|
7281
|
-
return (0,
|
|
7377
|
+
const ticks = (0, import_core15.samplesToTicks)(samplePos, bpm, sampleRate);
|
|
7378
|
+
const snapped = (0, import_core15.snapToGrid)(ticks, gridTicks);
|
|
7379
|
+
return (0, import_core15.ticksToSamples)(snapped, bpm, sampleRate);
|
|
7282
7380
|
};
|
|
7283
7381
|
}
|
|
7284
7382
|
if (useTimescaleSnap) {
|
|
@@ -7287,17 +7385,17 @@ var ClipInteractionProvider = ({
|
|
|
7287
7385
|
}
|
|
7288
7386
|
return void 0;
|
|
7289
7387
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, sampleRate, samplesPerPixel]);
|
|
7290
|
-
const tracksRef = (0,
|
|
7388
|
+
const tracksRef = (0, import_react68.useRef)(tracks);
|
|
7291
7389
|
tracksRef.current = tracks;
|
|
7292
|
-
const getTracks = (0,
|
|
7390
|
+
const getTracks = (0, import_react68.useCallback)(() => tracksRef.current, []);
|
|
7293
7391
|
const sensors = useDragSensors({ touchOptimized });
|
|
7294
7392
|
const {
|
|
7295
7393
|
onDragStart: handleDragStart,
|
|
7296
7394
|
onDragMove,
|
|
7297
7395
|
onDragEnd
|
|
7298
7396
|
} = useClipDragHandlers({ samplesPerPixel, snapSamplePosition });
|
|
7299
|
-
const trackReorderDragActiveRef =
|
|
7300
|
-
const onDragStart =
|
|
7397
|
+
const trackReorderDragActiveRef = import_react68.default.useRef(false);
|
|
7398
|
+
const onDragStart = import_react68.default.useCallback(
|
|
7301
7399
|
(event) => {
|
|
7302
7400
|
var _a, _b;
|
|
7303
7401
|
const data = (_b = (_a = event.operation) == null ? void 0 : _a.source) == null ? void 0 : _b.data;
|
|
@@ -7315,7 +7413,7 @@ var ClipInteractionProvider = ({
|
|
|
7315
7413
|
},
|
|
7316
7414
|
[handleDragStart, setSelectedTrackId]
|
|
7317
7415
|
);
|
|
7318
|
-
const handleDragOver =
|
|
7416
|
+
const handleDragOver = import_react68.default.useCallback(
|
|
7319
7417
|
(event) => {
|
|
7320
7418
|
var _a;
|
|
7321
7419
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
@@ -7331,7 +7429,7 @@ var ClipInteractionProvider = ({
|
|
|
7331
7429
|
},
|
|
7332
7430
|
[setTrackDragPreview]
|
|
7333
7431
|
);
|
|
7334
|
-
const handleDragEnd =
|
|
7432
|
+
const handleDragEnd = import_react68.default.useCallback(
|
|
7335
7433
|
(event) => {
|
|
7336
7434
|
var _a;
|
|
7337
7435
|
const data = (_a = event.operation.source) == null ? void 0 : _a.data;
|
|
@@ -7351,7 +7449,7 @@ var ClipInteractionProvider = ({
|
|
|
7351
7449
|
},
|
|
7352
7450
|
[onDragEnd, reorderTrack, bumpTrackReorderEpoch, setTrackDragPreview]
|
|
7353
7451
|
);
|
|
7354
|
-
const modifiers = (0,
|
|
7452
|
+
const modifiers = (0, import_react68.useMemo)(() => {
|
|
7355
7453
|
const mods = [import_modifiers3.RestrictToHorizontalAxis];
|
|
7356
7454
|
if (useBeatsSnap && beatsAndBars) {
|
|
7357
7455
|
mods.push(
|
|
@@ -7377,7 +7475,7 @@ var ClipInteractionProvider = ({
|
|
|
7377
7475
|
return mods;
|
|
7378
7476
|
}, [useBeatsSnap, useTimescaleSnap, beatsAndBars, getTracks, samplesPerPixel, sampleRate]);
|
|
7379
7477
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ClipInteractionOptions, { enabled: true, touchOptimized, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
7380
|
-
|
|
7478
|
+
import_react69.DragDropProvider,
|
|
7381
7479
|
{
|
|
7382
7480
|
sensors,
|
|
7383
7481
|
onDragStart,
|
|
@@ -7460,6 +7558,7 @@ var ClipInteractionProvider = ({
|
|
|
7460
7558
|
useClipDragHandlers,
|
|
7461
7559
|
useClipInteractionEnabled,
|
|
7462
7560
|
useClipSplitting,
|
|
7561
|
+
useCreateAnnotationStore,
|
|
7463
7562
|
useCreateArrangement,
|
|
7464
7563
|
useCurrentTime,
|
|
7465
7564
|
useDragSensors,
|
|
@@ -7483,6 +7582,7 @@ var ClipInteractionProvider = ({
|
|
|
7483
7582
|
useSelectedTrackId,
|
|
7484
7583
|
useSelection,
|
|
7485
7584
|
useSpectrogramIntegration,
|
|
7585
|
+
useStoredAnnotations,
|
|
7486
7586
|
useTimeFormat,
|
|
7487
7587
|
useTrack,
|
|
7488
7588
|
useTrackReorderHandle,
|