@waveform-playlist/browser 15.1.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/dist/index.mjs CHANGED
@@ -1793,19 +1793,19 @@ var WaveformPlaylistProvider = ({
1793
1793
  onAnnotationsChange,
1794
1794
  barWidth = 1,
1795
1795
  barGap = 0,
1796
+ roundedBars = false,
1796
1797
  progressBarWidth: progressBarWidthProp,
1797
1798
  onTracksChange,
1798
1799
  soundFontCache,
1799
1800
  deferEngineRebuild = false,
1800
1801
  indefinitePlayback = false,
1802
+ fillViewport = false,
1801
1803
  sampleRate: sampleRateProp,
1802
1804
  createAdapter,
1803
1805
  children
1804
1806
  }) => {
1805
1807
  var _a, _b, _c, _d;
1806
1808
  const progressBarWidth = progressBarWidthProp != null ? progressBarWidthProp : barWidth + barGap;
1807
- const indefinitePlaybackRef = useRef9(indefinitePlayback);
1808
- indefinitePlaybackRef.current = indefinitePlayback;
1809
1809
  const stableZoomLevels = useMemo3(
1810
1810
  () => zoomLevels,
1811
1811
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -1843,6 +1843,28 @@ var WaveformPlaylistProvider = ({
1843
1843
  const engineRef = useRef9(null);
1844
1844
  const adapterRef = useRef9(null);
1845
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
+ }, []);
1846
1868
  const isPlayingRef = useRef9(false);
1847
1869
  isPlayingRef.current = isPlaying;
1848
1870
  const playStartPositionRef = useRef9(0);
@@ -2434,7 +2456,7 @@ var WaveformPlaylistProvider = ({
2434
2456
  playbackEndTimeRef.current = null;
2435
2457
  return;
2436
2458
  }
2437
- if (time >= duration && !indefinitePlaybackRef.current) {
2459
+ if (time >= duration && !indefinitePlaybackRef.current && !recordingActiveRef.current) {
2438
2460
  if (engineRef.current) {
2439
2461
  engineRef.current.stop();
2440
2462
  }
@@ -2705,6 +2727,7 @@ var WaveformPlaylistProvider = ({
2705
2727
  loopStart,
2706
2728
  loopEnd,
2707
2729
  indefinitePlayback,
2730
+ fillViewport,
2708
2731
  canUndo,
2709
2732
  canRedo
2710
2733
  }),
@@ -2722,6 +2745,7 @@ var WaveformPlaylistProvider = ({
2722
2745
  loopStart,
2723
2746
  loopEnd,
2724
2747
  indefinitePlayback,
2748
+ fillViewport,
2725
2749
  canUndo,
2726
2750
  canRedo
2727
2751
  ]
@@ -2777,7 +2801,9 @@ var WaveformPlaylistProvider = ({
2777
2801
  clearLoopRegion,
2778
2802
  // Undo/redo
2779
2803
  undo,
2780
- redo
2804
+ redo,
2805
+ // Recording
2806
+ setRecordingActive
2781
2807
  }),
2782
2808
  [
2783
2809
  play,
@@ -2809,7 +2835,8 @@ var WaveformPlaylistProvider = ({
2809
2835
  setLoopRegionFromSelection,
2810
2836
  clearLoopRegion,
2811
2837
  undo,
2812
- redo
2838
+ redo,
2839
+ setRecordingActive
2813
2840
  ]
2814
2841
  );
2815
2842
  const dataValue = useMemo3(
@@ -2832,6 +2859,7 @@ var WaveformPlaylistProvider = ({
2832
2859
  canZoomOut: zoom.canZoomOut,
2833
2860
  barWidth,
2834
2861
  barGap,
2862
+ roundedBars,
2835
2863
  progressBarWidth,
2836
2864
  isReady,
2837
2865
  mono,
@@ -2857,6 +2885,7 @@ var WaveformPlaylistProvider = ({
2857
2885
  zoom.canZoomOut,
2858
2886
  barWidth,
2859
2887
  barGap,
2888
+ roundedBars,
2860
2889
  progressBarWidth,
2861
2890
  isReady,
2862
2891
  mono,
@@ -2952,6 +2981,7 @@ var MediaElementPlaylistProvider = ({
2952
2981
  annotationList,
2953
2982
  barWidth = 1,
2954
2983
  barGap = 0,
2984
+ roundedBars = false,
2955
2985
  progressBarWidth: progressBarWidthProp,
2956
2986
  audioContext,
2957
2987
  onAnnotationsChange,
@@ -3274,6 +3304,7 @@ var MediaElementPlaylistProvider = ({
3274
3304
  controls,
3275
3305
  barWidth,
3276
3306
  barGap,
3307
+ roundedBars,
3277
3308
  progressBarWidth,
3278
3309
  fadeIn: track.fadeIn,
3279
3310
  fadeOut: track.fadeOut
@@ -3288,6 +3319,7 @@ var MediaElementPlaylistProvider = ({
3288
3319
  controls,
3289
3320
  barWidth,
3290
3321
  barGap,
3322
+ roundedBars,
3291
3323
  progressBarWidth,
3292
3324
  track.fadeIn,
3293
3325
  track.fadeOut
@@ -3629,7 +3661,14 @@ function useClipInteractionEnabled() {
3629
3661
  }
3630
3662
 
3631
3663
  // src/components/PlaylistVisualization.tsx
3632
- import { useContext as useContext6, useRef as useRef14, useState as useState11, useMemo as useMemo5, useCallback as useCallback16 } from "react";
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";
3633
3672
  import { createPortal } from "react-dom";
3634
3673
  import styled4 from "styled-components";
3635
3674
  import {
@@ -3977,7 +4016,7 @@ var PlaylistVisualization = ({
3977
4016
  onRemoveTrack,
3978
4017
  recordingState
3979
4018
  }) => {
3980
- 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;
3981
4020
  const theme = useTheme2();
3982
4021
  const { isPlaying, getLookAhead, getOutputLatency } = usePlaybackAnimation();
3983
4022
  const {
@@ -3992,7 +4031,8 @@ var PlaylistVisualization = ({
3992
4031
  loopStart,
3993
4032
  loopEnd,
3994
4033
  isLoopEnabled,
3995
- indefinitePlayback
4034
+ indefinitePlayback,
4035
+ fillViewport
3996
4036
  } = usePlaylistState();
3997
4037
  const annotationIntegration = useContext6(AnnotationIntegrationContext);
3998
4038
  const {
@@ -4007,7 +4047,8 @@ var PlaylistVisualization = ({
4007
4047
  setScrollContainer,
4008
4048
  setSelectedTrackId,
4009
4049
  setCurrentTime,
4010
- setLoopRegion
4050
+ setLoopRegion,
4051
+ setRecordingActive
4011
4052
  } = usePlaylistControls();
4012
4053
  const {
4013
4054
  peaksDataArray,
@@ -4021,10 +4062,18 @@ var PlaylistVisualization = ({
4021
4062
  controls,
4022
4063
  barWidth,
4023
4064
  barGap,
4065
+ roundedBars,
4024
4066
  isReady,
4025
4067
  mono
4026
4068
  } = usePlaylistData();
4027
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]);
4028
4077
  const perTrackSpectrogramHelpers = useMemo5(() => {
4029
4078
  if (!spectrogram)
4030
4079
  return /* @__PURE__ */ new Map();
@@ -4062,8 +4111,8 @@ var PlaylistVisualization = ({
4062
4111
  }, max);
4063
4112
  }, 0);
4064
4113
  let displayDuration = tracksMaxDuration > 0 ? tracksMaxDuration : duration > 0 ? duration : DEFAULT_EMPTY_TRACK_DURATION;
4065
- if (indefinitePlayback) {
4066
- const containerWidth = (_b = (_a = scrollContainerRef.current) == null ? void 0 : _a.clientWidth) != null ? _b : 0;
4114
+ if (indefinitePlayback || fillViewport) {
4115
+ const containerWidth = (_c = (_b = scrollContainerRef.current) == null ? void 0 : _b.clientWidth) != null ? _c : 0;
4067
4116
  const minContainerDuration = containerWidth * samplesPerPixel / sampleRate;
4068
4117
  displayDuration = Math.max(displayDuration, minContainerDuration);
4069
4118
  }
@@ -4279,7 +4328,8 @@ var PlaylistVisualization = ({
4279
4328
  duration: displayDuration * 1e3,
4280
4329
  controls,
4281
4330
  barWidth,
4282
- barGap
4331
+ barGap,
4332
+ roundedBars
4283
4333
  },
4284
4334
  children: /* @__PURE__ */ jsx9(
4285
4335
  Playlist,
@@ -4520,8 +4570,8 @@ var PlaylistVisualization = ({
4520
4570
  {
4521
4571
  open: settingsModalTrackId !== null,
4522
4572
  onClose: () => setSettingsModalTrackId(null),
4523
- config: settingsModalTrackId !== null ? (_g = (_f = (_e = (_c = spectrogram.trackSpectrogramOverrides.get(settingsModalTrackId)) == null ? void 0 : _c.config) != null ? _e : (_d = tracks.find((t) => t.id === settingsModalTrackId)) == null ? void 0 : _d.spectrogramConfig) != null ? _f : spectrogram.spectrogramConfig) != null ? _g : {} : {},
4524
- colorMap: settingsModalTrackId !== null ? (_l = (_k = (_j = (_h = spectrogram.trackSpectrogramOverrides.get(settingsModalTrackId)) == null ? void 0 : _h.colorMap) != null ? _j : (_i = tracks.find((t) => t.id === settingsModalTrackId)) == null ? void 0 : _i.spectrogramColorMap) != null ? _k : spectrogram.spectrogramColorMap) != null ? _l : "viridis" : "viridis",
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",
4525
4575
  onApply: (newConfig, newColorMap) => {
4526
4576
  if (settingsModalTrackId !== null) {
4527
4577
  spectrogram.setTrackSpectrogramConfig(settingsModalTrackId, newConfig, newColorMap);
@@ -4670,7 +4720,7 @@ var noDropAnimationPlugins = (defaults) => {
4670
4720
  };
4671
4721
 
4672
4722
  // src/components/AnimatedMediaElementPlayhead.tsx
4673
- import { useRef as useRef15, useEffect as useEffect10 } from "react";
4723
+ import { useRef as useRef15, useEffect as useEffect11 } from "react";
4674
4724
  import styled5 from "styled-components";
4675
4725
  import { jsx as jsx12 } from "react/jsx-runtime";
4676
4726
  var PlayheadLine2 = styled5.div`
@@ -4691,7 +4741,7 @@ var AnimatedMediaElementPlayhead = ({
4691
4741
  const animationFrameRef = useRef15(null);
4692
4742
  const { isPlaying, currentTimeRef } = useMediaElementAnimation();
4693
4743
  const { samplesPerPixel, sampleRate, progressBarWidth } = useMediaElementData();
4694
- useEffect10(() => {
4744
+ useEffect11(() => {
4695
4745
  const updatePosition = () => {
4696
4746
  var _a;
4697
4747
  if (playheadRef.current) {
@@ -4715,7 +4765,7 @@ var AnimatedMediaElementPlayhead = ({
4715
4765
  }
4716
4766
  };
4717
4767
  }, [isPlaying, sampleRate, samplesPerPixel, currentTimeRef]);
4718
- useEffect10(() => {
4768
+ useEffect11(() => {
4719
4769
  var _a;
4720
4770
  if (!isPlaying && playheadRef.current) {
4721
4771
  const time = (_a = currentTimeRef.current) != null ? _a : 0;
@@ -4727,7 +4777,7 @@ var AnimatedMediaElementPlayhead = ({
4727
4777
  };
4728
4778
 
4729
4779
  // src/components/ChannelWithMediaElementProgress.tsx
4730
- import { useRef as useRef16, useEffect as useEffect11 } from "react";
4780
+ import { useRef as useRef16, useEffect as useEffect12 } from "react";
4731
4781
  import styled6 from "styled-components";
4732
4782
  import {
4733
4783
  SmartChannel as SmartChannel2,
@@ -4779,7 +4829,7 @@ var ChannelWithMediaElementProgress = (_a) => {
4779
4829
  const { isPlaying, currentTimeRef } = useMediaElementAnimation();
4780
4830
  const { samplesPerPixel, sampleRate } = useMediaElementData();
4781
4831
  const progressColor = (theme == null ? void 0 : theme.waveProgressColor) || "rgba(0, 0, 0, 0.1)";
4782
- useEffect11(() => {
4832
+ useEffect12(() => {
4783
4833
  const updateProgress = () => {
4784
4834
  var _a2;
4785
4835
  if (progressRef.current) {
@@ -4821,7 +4871,7 @@ var ChannelWithMediaElementProgress = (_a) => {
4821
4871
  smartChannelProps.length,
4822
4872
  currentTimeRef
4823
4873
  ]);
4824
- useEffect11(() => {
4874
+ useEffect12(() => {
4825
4875
  var _a2;
4826
4876
  if (!isPlaying && progressRef.current) {
4827
4877
  const currentTime = (_a2 = currentTimeRef.current) != null ? _a2 : 0;
@@ -4913,6 +4963,7 @@ var MediaElementPlaylist = ({
4913
4963
  playoutRef,
4914
4964
  barWidth,
4915
4965
  barGap,
4966
+ roundedBars,
4916
4967
  fadeIn,
4917
4968
  fadeOut
4918
4969
  } = useMediaElementData();
@@ -5024,7 +5075,8 @@ var MediaElementPlaylist = ({
5024
5075
  duration: duration * 1e3,
5025
5076
  controls,
5026
5077
  barWidth,
5027
- barGap
5078
+ barGap,
5079
+ roundedBars
5028
5080
  },
5029
5081
  children: /* @__PURE__ */ jsx14(
5030
5082
  Playlist2,
@@ -5312,7 +5364,7 @@ var KeyboardShortcuts = ({
5312
5364
  };
5313
5365
 
5314
5366
  // src/components/ClipInteractionProvider.tsx
5315
- import React16, { useEffect as useEffect12, useMemo as useMemo6 } from "react";
5367
+ import React16, { useEffect as useEffect13, useMemo as useMemo6 } from "react";
5316
5368
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
5317
5369
  import { RestrictToHorizontalAxis as RestrictToHorizontalAxis2 } from "@dnd-kit/abstract/modifiers";
5318
5370
  import {
@@ -5415,7 +5467,7 @@ var ClipInteractionProvider = ({
5415
5467
  const beatsAndBars = useBeatsAndBars();
5416
5468
  const useBeatsSnap = snap && beatsAndBars != null && beatsAndBars.scaleMode === "beats" && beatsAndBars.snapTo !== "off";
5417
5469
  const useTimescaleSnap = snap && !useBeatsSnap;
5418
- useEffect12(() => {
5470
+ useEffect13(() => {
5419
5471
  if (onTracksChange == null) {
5420
5472
  console.warn(
5421
5473
  "[waveform-playlist] ClipInteractionProvider: onTracksChange is not set on WaveformPlaylistProvider. Drag and trim edits will not be persisted."