@waveform-playlist/ui-components 15.0.0-next.5 → 15.0.0-next.7
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.js +33 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2359,7 +2359,7 @@ var SelectionTimeInputs = ({
|
|
|
2359
2359
|
};
|
|
2360
2360
|
|
|
2361
2361
|
// src/components/SpectrogramChannel.tsx
|
|
2362
|
-
import { useRef as useRef7, useEffect as useEffect5 } from "react";
|
|
2362
|
+
import { useRef as useRef7, useEffect as useEffect5, useState as useState4 } from "react";
|
|
2363
2363
|
import styled20 from "styled-components";
|
|
2364
2364
|
import {
|
|
2365
2365
|
MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH3,
|
|
@@ -2392,6 +2392,23 @@ var SpectrogramCanvas = styled20.canvas.attrs((props) => ({
|
|
|
2392
2392
|
image-rendering: pixelated;
|
|
2393
2393
|
image-rendering: crisp-edges;
|
|
2394
2394
|
`;
|
|
2395
|
+
function releaseUnmounted(ids, canvases, unregister) {
|
|
2396
|
+
const remaining = /* @__PURE__ */ new Set();
|
|
2397
|
+
for (const id of ids) {
|
|
2398
|
+
const parsed = parseSpectrogramCanvasId(id);
|
|
2399
|
+
const canvas = parsed ? canvases.get(parsed.chunkIndex) : void 0;
|
|
2400
|
+
if (canvas?.isConnected) {
|
|
2401
|
+
remaining.add(id);
|
|
2402
|
+
continue;
|
|
2403
|
+
}
|
|
2404
|
+
try {
|
|
2405
|
+
unregister(id);
|
|
2406
|
+
} catch (err) {
|
|
2407
|
+
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
return remaining;
|
|
2411
|
+
}
|
|
2395
2412
|
var SpectrogramChannel = ({
|
|
2396
2413
|
index,
|
|
2397
2414
|
channelIndex: channelIndexProp,
|
|
@@ -2407,10 +2424,12 @@ var SpectrogramChannel = ({
|
|
|
2407
2424
|
}) => {
|
|
2408
2425
|
const channelIndex = channelIndexProp ?? index;
|
|
2409
2426
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2410
|
-
const registeredIdsRef = useRef7(
|
|
2427
|
+
const registeredIdsRef = useRef7(/* @__PURE__ */ new Set());
|
|
2411
2428
|
const transferredCanvasesRef = useRef7(/* @__PURE__ */ new WeakSet());
|
|
2412
2429
|
const onCanvasRegisterRef = useRef7(onCanvasRegister);
|
|
2413
2430
|
const onCanvasUnregisterRef = useRef7(onCanvasUnregister);
|
|
2431
|
+
const releasedRef = useRef7(false);
|
|
2432
|
+
const [generation, setGeneration] = useState4(0);
|
|
2414
2433
|
const clipOriginX = useClipViewportOrigin();
|
|
2415
2434
|
const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH3, clipOriginX);
|
|
2416
2435
|
useEffect5(() => {
|
|
@@ -2421,28 +2440,10 @@ var SpectrogramChannel = ({
|
|
|
2421
2440
|
}, [onCanvasUnregister]);
|
|
2422
2441
|
useEffect5(() => {
|
|
2423
2442
|
if (!clipId) return;
|
|
2443
|
+
if (releasedRef.current) return;
|
|
2424
2444
|
const unregister = onCanvasUnregisterRef.current;
|
|
2425
2445
|
const register = onCanvasRegisterRef.current;
|
|
2426
|
-
const remaining =
|
|
2427
|
-
for (const id of registeredIdsRef.current) {
|
|
2428
|
-
const parsed = parseSpectrogramCanvasId(id);
|
|
2429
|
-
if (!parsed) {
|
|
2430
|
-
remaining.push(id);
|
|
2431
|
-
continue;
|
|
2432
|
-
}
|
|
2433
|
-
const chunkIdx = parsed.chunkIndex;
|
|
2434
|
-
const canvas = canvasMapRef.current.get(chunkIdx);
|
|
2435
|
-
if (canvas && canvas.isConnected) {
|
|
2436
|
-
remaining.push(id);
|
|
2437
|
-
} else {
|
|
2438
|
-
try {
|
|
2439
|
-
unregister(id);
|
|
2440
|
-
} catch (err) {
|
|
2441
|
-
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
registeredIdsRef.current = remaining;
|
|
2446
|
+
const remaining = releaseUnmounted(registeredIdsRef.current, canvasMapRef.current, unregister);
|
|
2446
2447
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
2447
2448
|
if (transferredCanvasesRef.current.has(canvas)) continue;
|
|
2448
2449
|
const canvasId = buildSpectrogramCanvasId({ clipId, channelIndex, chunkIndex: canvasIdx });
|
|
@@ -2467,11 +2468,12 @@ var SpectrogramChannel = ({
|
|
|
2467
2468
|
...offsetSamples !== void 0 ? { offsetSamples } : {},
|
|
2468
2469
|
...durationSamples !== void 0 ? { durationSamples } : {}
|
|
2469
2470
|
});
|
|
2470
|
-
|
|
2471
|
+
remaining.add(canvasId);
|
|
2471
2472
|
} catch (err) {
|
|
2472
2473
|
console.warn(`[spectrogram] register failed for ${canvasId}:`, err);
|
|
2473
2474
|
}
|
|
2474
2475
|
}
|
|
2476
|
+
registeredIdsRef.current = remaining;
|
|
2475
2477
|
}, [
|
|
2476
2478
|
canvasMapRef,
|
|
2477
2479
|
clipId,
|
|
@@ -2480,9 +2482,14 @@ var SpectrogramChannel = ({
|
|
|
2480
2482
|
waveHeight,
|
|
2481
2483
|
offsetSamples,
|
|
2482
2484
|
durationSamples,
|
|
2483
|
-
visibleChunkIndices
|
|
2485
|
+
visibleChunkIndices,
|
|
2486
|
+
generation
|
|
2484
2487
|
]);
|
|
2485
2488
|
useEffect5(() => {
|
|
2489
|
+
if (releasedRef.current) {
|
|
2490
|
+
releasedRef.current = false;
|
|
2491
|
+
setGeneration((g) => g + 1);
|
|
2492
|
+
}
|
|
2486
2493
|
return () => {
|
|
2487
2494
|
const unregister = onCanvasUnregisterRef.current;
|
|
2488
2495
|
for (const id of registeredIdsRef.current) {
|
|
@@ -2492,7 +2499,8 @@ var SpectrogramChannel = ({
|
|
|
2492
2499
|
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2493
2500
|
}
|
|
2494
2501
|
}
|
|
2495
|
-
registeredIdsRef.current =
|
|
2502
|
+
registeredIdsRef.current = /* @__PURE__ */ new Set();
|
|
2503
|
+
releasedRef.current = true;
|
|
2496
2504
|
};
|
|
2497
2505
|
}, []);
|
|
2498
2506
|
const canvases = visibleChunkIndices.map((i) => {
|
|
@@ -2509,7 +2517,7 @@ var SpectrogramChannel = ({
|
|
|
2509
2517
|
"data-index": i,
|
|
2510
2518
|
ref: canvasRef
|
|
2511
2519
|
},
|
|
2512
|
-
`${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2520
|
+
`${generation}-${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2513
2521
|
);
|
|
2514
2522
|
});
|
|
2515
2523
|
return /* @__PURE__ */ jsx21(Wrapper4, { $index: index, $cssWidth: length, $waveHeight: waveHeight, children: canvases });
|
|
@@ -3519,7 +3527,7 @@ var SliderWrapper = styled34.label`
|
|
|
3519
3527
|
`;
|
|
3520
3528
|
|
|
3521
3529
|
// src/components/TrackMenu.tsx
|
|
3522
|
-
import React20, { useState as
|
|
3530
|
+
import React20, { useState as useState5, useEffect as useEffect6, useRef as useRef9, useCallback as useCallback5 } from "react";
|
|
3523
3531
|
import { createPortal } from "react-dom";
|
|
3524
3532
|
import styled35 from "styled-components";
|
|
3525
3533
|
import { jsx as jsx38, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
@@ -3562,10 +3570,10 @@ var Divider = styled35.hr`
|
|
|
3562
3570
|
margin: 0.35rem 0;
|
|
3563
3571
|
`;
|
|
3564
3572
|
var TrackMenu = ({ items: itemsProp }) => {
|
|
3565
|
-
const [open, setOpen] =
|
|
3573
|
+
const [open, setOpen] = useState5(false);
|
|
3566
3574
|
const close = useCallback5(() => setOpen(false), []);
|
|
3567
3575
|
const items = typeof itemsProp === "function" ? itemsProp(close) : itemsProp;
|
|
3568
|
-
const [dropdownPos, setDropdownPos] =
|
|
3576
|
+
const [dropdownPos, setDropdownPos] = useState5({ top: 0, left: 0 });
|
|
3569
3577
|
const buttonRef = useRef9(null);
|
|
3570
3578
|
const dropdownRef = useRef9(null);
|
|
3571
3579
|
const updatePosition = useCallback5(() => {
|
|
@@ -4019,11 +4027,11 @@ var SegmentedVUMeterInner = ({
|
|
|
4019
4027
|
var SegmentedVUMeter = React21.memo(SegmentedVUMeterInner);
|
|
4020
4028
|
|
|
4021
4029
|
// src/hooks/useThrottledValue.ts
|
|
4022
|
-
import { useEffect as useEffect7, useState as
|
|
4030
|
+
import { useEffect as useEffect7, useState as useState6 } from "react";
|
|
4023
4031
|
var DEFAULT_UPDATE_RATE = 10;
|
|
4024
4032
|
function useThrottledValue(source, options = {}) {
|
|
4025
4033
|
const { updateRate = DEFAULT_UPDATE_RATE } = options;
|
|
4026
|
-
const [state, setState] =
|
|
4034
|
+
const [state, setState] = useState6(() => ({
|
|
4027
4035
|
source,
|
|
4028
4036
|
value: source.getSnapshot()
|
|
4029
4037
|
}));
|