@waveform-playlist/browser 15.2.0 → 15.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/dist/index.d.mts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +47 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -21
- package/dist/index.mjs.map +1 -1
- package/dist/tone.js +5 -4
- package/dist/tone.js.map +1 -1
- package/dist/tone.mjs +5 -4
- package/dist/tone.mjs.map +1 -1
- package/package.json +8 -9
package/dist/index.mjs
CHANGED
|
@@ -1799,14 +1799,13 @@ var WaveformPlaylistProvider = ({
|
|
|
1799
1799
|
soundFontCache,
|
|
1800
1800
|
deferEngineRebuild = false,
|
|
1801
1801
|
indefinitePlayback = false,
|
|
1802
|
+
fillViewport = false,
|
|
1802
1803
|
sampleRate: sampleRateProp,
|
|
1803
1804
|
createAdapter,
|
|
1804
1805
|
children
|
|
1805
1806
|
}) => {
|
|
1806
1807
|
var _a, _b, _c, _d;
|
|
1807
1808
|
const progressBarWidth = progressBarWidthProp != null ? progressBarWidthProp : barWidth + barGap;
|
|
1808
|
-
const indefinitePlaybackRef = useRef9(indefinitePlayback);
|
|
1809
|
-
indefinitePlaybackRef.current = indefinitePlayback;
|
|
1810
1809
|
const stableZoomLevels = useMemo3(
|
|
1811
1810
|
() => zoomLevels,
|
|
1812
1811
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1844,6 +1843,28 @@ var WaveformPlaylistProvider = ({
|
|
|
1844
1843
|
const engineRef = useRef9(null);
|
|
1845
1844
|
const adapterRef = useRef9(null);
|
|
1846
1845
|
const audioInitializedRef = useRef9(false);
|
|
1846
|
+
const indefinitePlaybackRef = useRef9(indefinitePlayback);
|
|
1847
|
+
indefinitePlaybackRef.current = indefinitePlayback;
|
|
1848
|
+
const recordingActiveRef = useRef9(false);
|
|
1849
|
+
const armedTrackMuteRef = useRef9(null);
|
|
1850
|
+
const setRecordingActive = useCallback13((active, armedTrackId) => {
|
|
1851
|
+
var _a2, _b2, _c2;
|
|
1852
|
+
recordingActiveRef.current = active;
|
|
1853
|
+
const engine = engineRef.current;
|
|
1854
|
+
if (!engine) return;
|
|
1855
|
+
if (active && armedTrackId) {
|
|
1856
|
+
if (((_a2 = armedTrackMuteRef.current) == null ? void 0 : _a2.trackId) === armedTrackId) return;
|
|
1857
|
+
if (armedTrackMuteRef.current) {
|
|
1858
|
+
engine.setTrackMute(armedTrackMuteRef.current.trackId, armedTrackMuteRef.current.prevMuted);
|
|
1859
|
+
}
|
|
1860
|
+
const prevMuted = (_c2 = (_b2 = engine.getState().tracks.find((t) => t.id === armedTrackId)) == null ? void 0 : _b2.muted) != null ? _c2 : false;
|
|
1861
|
+
armedTrackMuteRef.current = { trackId: armedTrackId, prevMuted };
|
|
1862
|
+
engine.setTrackMute(armedTrackId, true);
|
|
1863
|
+
} else if (!active && armedTrackMuteRef.current) {
|
|
1864
|
+
engine.setTrackMute(armedTrackMuteRef.current.trackId, armedTrackMuteRef.current.prevMuted);
|
|
1865
|
+
armedTrackMuteRef.current = null;
|
|
1866
|
+
}
|
|
1867
|
+
}, []);
|
|
1847
1868
|
const isPlayingRef = useRef9(false);
|
|
1848
1869
|
isPlayingRef.current = isPlaying;
|
|
1849
1870
|
const playStartPositionRef = useRef9(0);
|
|
@@ -2435,7 +2456,7 @@ var WaveformPlaylistProvider = ({
|
|
|
2435
2456
|
playbackEndTimeRef.current = null;
|
|
2436
2457
|
return;
|
|
2437
2458
|
}
|
|
2438
|
-
if (time >= duration && !indefinitePlaybackRef.current) {
|
|
2459
|
+
if (time >= duration && !indefinitePlaybackRef.current && !recordingActiveRef.current) {
|
|
2439
2460
|
if (engineRef.current) {
|
|
2440
2461
|
engineRef.current.stop();
|
|
2441
2462
|
}
|
|
@@ -2706,6 +2727,7 @@ var WaveformPlaylistProvider = ({
|
|
|
2706
2727
|
loopStart,
|
|
2707
2728
|
loopEnd,
|
|
2708
2729
|
indefinitePlayback,
|
|
2730
|
+
fillViewport,
|
|
2709
2731
|
canUndo,
|
|
2710
2732
|
canRedo
|
|
2711
2733
|
}),
|
|
@@ -2723,6 +2745,7 @@ var WaveformPlaylistProvider = ({
|
|
|
2723
2745
|
loopStart,
|
|
2724
2746
|
loopEnd,
|
|
2725
2747
|
indefinitePlayback,
|
|
2748
|
+
fillViewport,
|
|
2726
2749
|
canUndo,
|
|
2727
2750
|
canRedo
|
|
2728
2751
|
]
|
|
@@ -2778,7 +2801,9 @@ var WaveformPlaylistProvider = ({
|
|
|
2778
2801
|
clearLoopRegion,
|
|
2779
2802
|
// Undo/redo
|
|
2780
2803
|
undo,
|
|
2781
|
-
redo
|
|
2804
|
+
redo,
|
|
2805
|
+
// Recording
|
|
2806
|
+
setRecordingActive
|
|
2782
2807
|
}),
|
|
2783
2808
|
[
|
|
2784
2809
|
play,
|
|
@@ -2810,7 +2835,8 @@ var WaveformPlaylistProvider = ({
|
|
|
2810
2835
|
setLoopRegionFromSelection,
|
|
2811
2836
|
clearLoopRegion,
|
|
2812
2837
|
undo,
|
|
2813
|
-
redo
|
|
2838
|
+
redo,
|
|
2839
|
+
setRecordingActive
|
|
2814
2840
|
]
|
|
2815
2841
|
);
|
|
2816
2842
|
const dataValue = useMemo3(
|
|
@@ -3635,7 +3661,14 @@ function useClipInteractionEnabled() {
|
|
|
3635
3661
|
}
|
|
3636
3662
|
|
|
3637
3663
|
// src/components/PlaylistVisualization.tsx
|
|
3638
|
-
import {
|
|
3664
|
+
import {
|
|
3665
|
+
useContext as useContext6,
|
|
3666
|
+
useEffect as useEffect10,
|
|
3667
|
+
useRef as useRef14,
|
|
3668
|
+
useState as useState11,
|
|
3669
|
+
useMemo as useMemo5,
|
|
3670
|
+
useCallback as useCallback16
|
|
3671
|
+
} from "react";
|
|
3639
3672
|
import { createPortal } from "react-dom";
|
|
3640
3673
|
import styled4 from "styled-components";
|
|
3641
3674
|
import {
|
|
@@ -3983,7 +4016,7 @@ var PlaylistVisualization = ({
|
|
|
3983
4016
|
onRemoveTrack,
|
|
3984
4017
|
recordingState
|
|
3985
4018
|
}) => {
|
|
3986
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
4019
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3987
4020
|
const theme = useTheme2();
|
|
3988
4021
|
const { isPlaying, getLookAhead, getOutputLatency } = usePlaybackAnimation();
|
|
3989
4022
|
const {
|
|
@@ -3998,7 +4031,8 @@ var PlaylistVisualization = ({
|
|
|
3998
4031
|
loopStart,
|
|
3999
4032
|
loopEnd,
|
|
4000
4033
|
isLoopEnabled,
|
|
4001
|
-
indefinitePlayback
|
|
4034
|
+
indefinitePlayback,
|
|
4035
|
+
fillViewport
|
|
4002
4036
|
} = usePlaylistState();
|
|
4003
4037
|
const annotationIntegration = useContext6(AnnotationIntegrationContext);
|
|
4004
4038
|
const {
|
|
@@ -4013,7 +4047,8 @@ var PlaylistVisualization = ({
|
|
|
4013
4047
|
setScrollContainer,
|
|
4014
4048
|
setSelectedTrackId,
|
|
4015
4049
|
setCurrentTime,
|
|
4016
|
-
setLoopRegion
|
|
4050
|
+
setLoopRegion,
|
|
4051
|
+
setRecordingActive
|
|
4017
4052
|
} = usePlaylistControls();
|
|
4018
4053
|
const {
|
|
4019
4054
|
peaksDataArray,
|
|
@@ -4032,6 +4067,13 @@ var PlaylistVisualization = ({
|
|
|
4032
4067
|
mono
|
|
4033
4068
|
} = usePlaylistData();
|
|
4034
4069
|
const spectrogram = useContext6(SpectrogramIntegrationContext);
|
|
4070
|
+
const recordingActive = !!(recordingState == null ? void 0 : recordingState.isRecording);
|
|
4071
|
+
const armedTrackId = (_a = recordingState == null ? void 0 : recordingState.trackId) != null ? _a : null;
|
|
4072
|
+
useEffect10(() => {
|
|
4073
|
+
if (!recordingActive) return void 0;
|
|
4074
|
+
setRecordingActive(true, armedTrackId);
|
|
4075
|
+
return () => setRecordingActive(false);
|
|
4076
|
+
}, [recordingActive, armedTrackId, setRecordingActive]);
|
|
4035
4077
|
const perTrackSpectrogramHelpers = useMemo5(() => {
|
|
4036
4078
|
if (!spectrogram)
|
|
4037
4079
|
return /* @__PURE__ */ new Map();
|
|
@@ -4069,8 +4111,8 @@ var PlaylistVisualization = ({
|
|
|
4069
4111
|
}, max);
|
|
4070
4112
|
}, 0);
|
|
4071
4113
|
let displayDuration = tracksMaxDuration > 0 ? tracksMaxDuration : duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION;
|
|
4072
|
-
if (indefinitePlayback) {
|
|
4073
|
-
const containerWidth = (
|
|
4114
|
+
if (indefinitePlayback || fillViewport) {
|
|
4115
|
+
const containerWidth = (_c = (_b = scrollContainerRef.current) == null ? void 0 : _b.clientWidth) != null ? _c : 0;
|
|
4074
4116
|
const minContainerDuration = containerWidth * samplesPerPixel / sampleRate;
|
|
4075
4117
|
displayDuration = Math.max(displayDuration, minContainerDuration);
|
|
4076
4118
|
}
|
|
@@ -4528,8 +4570,8 @@ var PlaylistVisualization = ({
|
|
|
4528
4570
|
{
|
|
4529
4571
|
open: settingsModalTrackId !== null,
|
|
4530
4572
|
onClose: () => setSettingsModalTrackId(null),
|
|
4531
|
-
config: settingsModalTrackId !== null ? (
|
|
4532
|
-
colorMap: settingsModalTrackId !== null ? (
|
|
4573
|
+
config: settingsModalTrackId !== null ? (_h = (_g = (_f = (_d = spectrogram.trackSpectrogramOverrides.get(settingsModalTrackId)) == null ? void 0 : _d.config) != null ? _f : (_e = tracks.find((t) => t.id === settingsModalTrackId)) == null ? void 0 : _e.spectrogramConfig) != null ? _g : spectrogram.spectrogramConfig) != null ? _h : {} : {},
|
|
4574
|
+
colorMap: settingsModalTrackId !== null ? (_m = (_l = (_k = (_i = spectrogram.trackSpectrogramOverrides.get(settingsModalTrackId)) == null ? void 0 : _i.colorMap) != null ? _k : (_j = tracks.find((t) => t.id === settingsModalTrackId)) == null ? void 0 : _j.spectrogramColorMap) != null ? _l : spectrogram.spectrogramColorMap) != null ? _m : "viridis" : "viridis",
|
|
4533
4575
|
onApply: (newConfig, newColorMap) => {
|
|
4534
4576
|
if (settingsModalTrackId !== null) {
|
|
4535
4577
|
spectrogram.setTrackSpectrogramConfig(settingsModalTrackId, newConfig, newColorMap);
|
|
@@ -4678,7 +4720,7 @@ var noDropAnimationPlugins = (defaults) => {
|
|
|
4678
4720
|
};
|
|
4679
4721
|
|
|
4680
4722
|
// src/components/AnimatedMediaElementPlayhead.tsx
|
|
4681
|
-
import { useRef as useRef15, useEffect as
|
|
4723
|
+
import { useRef as useRef15, useEffect as useEffect11 } from "react";
|
|
4682
4724
|
import styled5 from "styled-components";
|
|
4683
4725
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
4684
4726
|
var PlayheadLine2 = styled5.div`
|
|
@@ -4699,7 +4741,7 @@ var AnimatedMediaElementPlayhead = ({
|
|
|
4699
4741
|
const animationFrameRef = useRef15(null);
|
|
4700
4742
|
const { isPlaying, currentTimeRef } = useMediaElementAnimation();
|
|
4701
4743
|
const { samplesPerPixel, sampleRate, progressBarWidth } = useMediaElementData();
|
|
4702
|
-
|
|
4744
|
+
useEffect11(() => {
|
|
4703
4745
|
const updatePosition = () => {
|
|
4704
4746
|
var _a;
|
|
4705
4747
|
if (playheadRef.current) {
|
|
@@ -4723,7 +4765,7 @@ var AnimatedMediaElementPlayhead = ({
|
|
|
4723
4765
|
}
|
|
4724
4766
|
};
|
|
4725
4767
|
}, [isPlaying, sampleRate, samplesPerPixel, currentTimeRef]);
|
|
4726
|
-
|
|
4768
|
+
useEffect11(() => {
|
|
4727
4769
|
var _a;
|
|
4728
4770
|
if (!isPlaying && playheadRef.current) {
|
|
4729
4771
|
const time = (_a = currentTimeRef.current) != null ? _a : 0;
|
|
@@ -4735,7 +4777,7 @@ var AnimatedMediaElementPlayhead = ({
|
|
|
4735
4777
|
};
|
|
4736
4778
|
|
|
4737
4779
|
// src/components/ChannelWithMediaElementProgress.tsx
|
|
4738
|
-
import { useRef as useRef16, useEffect as
|
|
4780
|
+
import { useRef as useRef16, useEffect as useEffect12 } from "react";
|
|
4739
4781
|
import styled6 from "styled-components";
|
|
4740
4782
|
import {
|
|
4741
4783
|
SmartChannel as SmartChannel2,
|
|
@@ -4787,7 +4829,7 @@ var ChannelWithMediaElementProgress = (_a) => {
|
|
|
4787
4829
|
const { isPlaying, currentTimeRef } = useMediaElementAnimation();
|
|
4788
4830
|
const { samplesPerPixel, sampleRate } = useMediaElementData();
|
|
4789
4831
|
const progressColor = (theme == null ? void 0 : theme.waveProgressColor) || "rgba(0, 0, 0, 0.1)";
|
|
4790
|
-
|
|
4832
|
+
useEffect12(() => {
|
|
4791
4833
|
const updateProgress = () => {
|
|
4792
4834
|
var _a2;
|
|
4793
4835
|
if (progressRef.current) {
|
|
@@ -4829,7 +4871,7 @@ var ChannelWithMediaElementProgress = (_a) => {
|
|
|
4829
4871
|
smartChannelProps.length,
|
|
4830
4872
|
currentTimeRef
|
|
4831
4873
|
]);
|
|
4832
|
-
|
|
4874
|
+
useEffect12(() => {
|
|
4833
4875
|
var _a2;
|
|
4834
4876
|
if (!isPlaying && progressRef.current) {
|
|
4835
4877
|
const currentTime = (_a2 = currentTimeRef.current) != null ? _a2 : 0;
|
|
@@ -5322,7 +5364,7 @@ var KeyboardShortcuts = ({
|
|
|
5322
5364
|
};
|
|
5323
5365
|
|
|
5324
5366
|
// src/components/ClipInteractionProvider.tsx
|
|
5325
|
-
import React16, { useEffect as
|
|
5367
|
+
import React16, { useEffect as useEffect13, useMemo as useMemo6 } from "react";
|
|
5326
5368
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
|
5327
5369
|
import { RestrictToHorizontalAxis as RestrictToHorizontalAxis2 } from "@dnd-kit/abstract/modifiers";
|
|
5328
5370
|
import {
|
|
@@ -5425,7 +5467,7 @@ var ClipInteractionProvider = ({
|
|
|
5425
5467
|
const beatsAndBars = useBeatsAndBars();
|
|
5426
5468
|
const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
|
|
5427
5469
|
const useTimescaleSnap = snap && !useBeatsSnap;
|
|
5428
|
-
|
|
5470
|
+
useEffect13(() => {
|
|
5429
5471
|
if (onTracksChange == null) {
|
|
5430
5472
|
console.warn(
|
|
5431
5473
|
"[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted."
|