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