@waveform-playlist/ui-components 11.1.0 → 11.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
@@ -334,7 +334,7 @@ var AutomaticScrollCheckbox = ({
334
334
  };
335
335
 
336
336
  // src/components/Channel.tsx
337
- import { useLayoutEffect as useLayoutEffect2 } from "react";
337
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef3 } from "react";
338
338
  import styled9 from "styled-components";
339
339
 
340
340
  // src/wfpl-theme.ts
@@ -784,9 +784,17 @@ var Channel = (props) => {
784
784
  const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
785
785
  const clipOriginX = useClipViewportOrigin();
786
786
  const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH, clipOriginX);
787
+ const dataVersionRef = useRef3(0);
788
+ const prevDataRef = useRef3(data);
789
+ if (prevDataRef.current !== data) {
790
+ dataVersionRef.current += 1;
791
+ prevDataRef.current = data;
792
+ }
793
+ const drawVersion = `${dataVersionRef.current}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
787
794
  useLayoutEffect2(() => {
788
795
  const step = barWidth + barGap;
789
796
  for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
797
+ if (canvas.dataset.drawVersion === drawVersion) continue;
790
798
  const globalPixelOffset = canvasIdx * MAX_CANVAS_WIDTH;
791
799
  const ctx = canvas.getContext("2d");
792
800
  const h2 = Math.floor(waveHeight / 2);
@@ -818,6 +826,7 @@ var Channel = (props) => {
818
826
  }
819
827
  }
820
828
  }
829
+ canvas.dataset.drawVersion = drawVersion;
821
830
  }
822
831
  }
823
832
  }, [
@@ -831,6 +840,7 @@ var Channel = (props) => {
831
840
  length,
832
841
  barWidth,
833
842
  barGap,
843
+ drawVersion,
834
844
  drawMode,
835
845
  visibleChunkIndices,
836
846
  index
@@ -1425,7 +1435,7 @@ var PianoRollChannel = ({
1425
1435
  };
1426
1436
 
1427
1437
  // src/components/Playhead.tsx
1428
- import { useRef as useRef3, useEffect as useEffect3 } from "react";
1438
+ import { useRef as useRef4, useEffect as useEffect3 } from "react";
1429
1439
  import styled16 from "styled-components";
1430
1440
  import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
1431
1441
  var PlayheadLine = styled16.div.attrs((props) => ({
@@ -1485,8 +1495,8 @@ var PlayheadWithMarker = ({
1485
1495
  getAudioContextTime,
1486
1496
  getPlaybackTime
1487
1497
  }) => {
1488
- const containerRef = useRef3(null);
1489
- const animationFrameRef = useRef3(null);
1498
+ const containerRef = useRef4(null);
1499
+ const animationFrameRef = useRef4(null);
1490
1500
  useEffect3(() => {
1491
1501
  const updatePosition = () => {
1492
1502
  if (containerRef.current) {
@@ -1547,7 +1557,7 @@ var PlayheadWithMarker = ({
1547
1557
 
1548
1558
  // src/components/Playlist.tsx
1549
1559
  import styled17, { withTheme } from "styled-components";
1550
- import { useRef as useRef4, useCallback as useCallback3 } from "react";
1560
+ import { useRef as useRef5, useCallback as useCallback3 } from "react";
1551
1561
  import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
1552
1562
  var Wrapper3 = styled17.div`
1553
1563
  display: flex;
@@ -1619,7 +1629,7 @@ var Playlist = ({
1619
1629
  trackControlsSlots,
1620
1630
  timescaleGapHeight = 0
1621
1631
  }) => {
1622
- const scrollAreaRef = useRef4(null);
1632
+ const scrollAreaRef = useRef5(null);
1623
1633
  const handleRef = useCallback3(
1624
1634
  (el) => {
1625
1635
  scrollAreaRef.current = el;
@@ -1683,7 +1693,7 @@ var Selection = ({
1683
1693
  };
1684
1694
 
1685
1695
  // src/components/LoopRegion.tsx
1686
- import { useCallback as useCallback4, useRef as useRef5, useState } from "react";
1696
+ import { useCallback as useCallback4, useRef as useRef6, useState } from "react";
1687
1697
  import styled19 from "styled-components";
1688
1698
  import { Fragment as Fragment2, jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
1689
1699
  var LoopRegionOverlayDiv = styled19.div.attrs((props) => ({
@@ -1835,9 +1845,9 @@ var LoopRegionMarkers = ({
1835
1845
  maxPosition = Infinity
1836
1846
  }) => {
1837
1847
  const [draggingMarker, setDraggingMarker] = useState(null);
1838
- const dragStartX = useRef5(0);
1839
- const dragStartPosition = useRef5(0);
1840
- const dragStartEnd = useRef5(0);
1848
+ const dragStartX = useRef6(0);
1849
+ const dragStartPosition = useRef6(0);
1850
+ const dragStartEnd = useRef6(0);
1841
1851
  const width = Math.max(0, endPosition - startPosition);
1842
1852
  const handleMarkerMouseDown = useCallback4(
1843
1853
  (e, marker) => {
@@ -1958,8 +1968,8 @@ var TimescaleLoopRegion = ({
1958
1968
  maxPosition = Infinity
1959
1969
  }) => {
1960
1970
  const [, setIsCreating] = useState(false);
1961
- const createStartX = useRef5(0);
1962
- const containerRef = useRef5(null);
1971
+ const createStartX = useRef6(0);
1972
+ const containerRef = useRef6(null);
1963
1973
  const hasLoopRegion = endPosition > startPosition;
1964
1974
  const handleBackgroundMouseDown = useCallback4(
1965
1975
  (e) => {
@@ -2301,7 +2311,7 @@ var usePlayoutStatus = () => useContext8(PlayoutStatusContext);
2301
2311
  var usePlayoutStatusUpdate = () => useContext8(PlayoutStatusUpdateContext);
2302
2312
 
2303
2313
  // src/components/SpectrogramChannel.tsx
2304
- import { useRef as useRef6, useEffect as useEffect6 } from "react";
2314
+ import { useRef as useRef7, useEffect as useEffect6 } from "react";
2305
2315
  import styled20 from "styled-components";
2306
2316
  import { MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH3 } from "@waveform-playlist/core";
2307
2317
  import { jsx as jsx23 } from "react/jsx-runtime";
@@ -2342,10 +2352,10 @@ var SpectrogramChannel = ({
2342
2352
  }) => {
2343
2353
  const channelIndex = channelIndexProp ?? index;
2344
2354
  const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
2345
- const registeredIdsRef = useRef6([]);
2346
- const transferredCanvasesRef = useRef6(/* @__PURE__ */ new WeakSet());
2347
- const workerApiRef = useRef6(workerApi);
2348
- const onCanvasesReadyRef = useRef6(onCanvasesReady);
2355
+ const registeredIdsRef = useRef7([]);
2356
+ const transferredCanvasesRef = useRef7(/* @__PURE__ */ new WeakSet());
2357
+ const workerApiRef = useRef7(workerApi);
2358
+ const onCanvasesReadyRef = useRef7(onCanvasesReady);
2349
2359
  const clipOriginX = useClipViewportOrigin();
2350
2360
  const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH3, clipOriginX);
2351
2361
  useEffect6(() => {
@@ -2576,7 +2586,7 @@ var SmartChannel = ({
2576
2586
  };
2577
2587
 
2578
2588
  // src/components/SpectrogramLabels.tsx
2579
- import { useRef as useRef7, useLayoutEffect as useLayoutEffect4 } from "react";
2589
+ import { useRef as useRef8, useLayoutEffect as useLayoutEffect4 } from "react";
2580
2590
  import styled21 from "styled-components";
2581
2591
  import { jsx as jsx25 } from "react/jsx-runtime";
2582
2592
  var LABELS_WIDTH = 72;
@@ -2628,7 +2638,7 @@ var SpectrogramLabels = ({
2628
2638
  renderMode = "spectrogram",
2629
2639
  hasClipHeaders = false
2630
2640
  }) => {
2631
- const canvasRef = useRef7(null);
2641
+ const canvasRef = useRef8(null);
2632
2642
  const devicePixelRatio = useDevicePixelRatio();
2633
2643
  const spectrogramHeight = renderMode === "both" ? Math.floor(waveHeight / 2) : waveHeight;
2634
2644
  const totalHeight = numChannels * waveHeight;
@@ -3245,7 +3255,7 @@ var SliderWrapper = styled32.label`
3245
3255
  `;
3246
3256
 
3247
3257
  // src/components/TrackMenu.tsx
3248
- import React20, { useState as useState6, useEffect as useEffect7, useRef as useRef8, useCallback as useCallback5 } from "react";
3258
+ import React20, { useState as useState6, useEffect as useEffect7, useRef as useRef9, useCallback as useCallback5 } from "react";
3249
3259
  import { createPortal } from "react-dom";
3250
3260
  import styled33 from "styled-components";
3251
3261
  import { jsx as jsx35, jsxs as jsxs11 } from "react/jsx-runtime";
@@ -3292,8 +3302,8 @@ var TrackMenu = ({ items: itemsProp }) => {
3292
3302
  const close = useCallback5(() => setOpen(false), []);
3293
3303
  const items = typeof itemsProp === "function" ? itemsProp(close) : itemsProp;
3294
3304
  const [dropdownPos, setDropdownPos] = useState6({ top: 0, left: 0 });
3295
- const buttonRef = useRef8(null);
3296
- const dropdownRef = useRef8(null);
3305
+ const buttonRef = useRef9(null);
3306
+ const dropdownRef = useRef9(null);
3297
3307
  const updatePosition = useCallback5(() => {
3298
3308
  if (!buttonRef.current) return;
3299
3309
  const rect = buttonRef.current.getBoundingClientRect();