@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.js
CHANGED
|
@@ -2503,6 +2503,23 @@ var SpectrogramCanvas = import_styled_components21.default.canvas.attrs((props)
|
|
|
2503
2503
|
image-rendering: pixelated;
|
|
2504
2504
|
image-rendering: crisp-edges;
|
|
2505
2505
|
`;
|
|
2506
|
+
function releaseUnmounted(ids, canvases, unregister) {
|
|
2507
|
+
const remaining = /* @__PURE__ */ new Set();
|
|
2508
|
+
for (const id of ids) {
|
|
2509
|
+
const parsed = (0, import_core5.parseSpectrogramCanvasId)(id);
|
|
2510
|
+
const canvas = parsed ? canvases.get(parsed.chunkIndex) : void 0;
|
|
2511
|
+
if (canvas?.isConnected) {
|
|
2512
|
+
remaining.add(id);
|
|
2513
|
+
continue;
|
|
2514
|
+
}
|
|
2515
|
+
try {
|
|
2516
|
+
unregister(id);
|
|
2517
|
+
} catch (err) {
|
|
2518
|
+
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
return remaining;
|
|
2522
|
+
}
|
|
2506
2523
|
var SpectrogramChannel = ({
|
|
2507
2524
|
index,
|
|
2508
2525
|
channelIndex: channelIndexProp,
|
|
@@ -2518,10 +2535,12 @@ var SpectrogramChannel = ({
|
|
|
2518
2535
|
}) => {
|
|
2519
2536
|
const channelIndex = channelIndexProp ?? index;
|
|
2520
2537
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2521
|
-
const registeredIdsRef = (0, import_react21.useRef)(
|
|
2538
|
+
const registeredIdsRef = (0, import_react21.useRef)(/* @__PURE__ */ new Set());
|
|
2522
2539
|
const transferredCanvasesRef = (0, import_react21.useRef)(/* @__PURE__ */ new WeakSet());
|
|
2523
2540
|
const onCanvasRegisterRef = (0, import_react21.useRef)(onCanvasRegister);
|
|
2524
2541
|
const onCanvasUnregisterRef = (0, import_react21.useRef)(onCanvasUnregister);
|
|
2542
|
+
const releasedRef = (0, import_react21.useRef)(false);
|
|
2543
|
+
const [generation, setGeneration] = (0, import_react21.useState)(0);
|
|
2525
2544
|
const clipOriginX = useClipViewportOrigin();
|
|
2526
2545
|
const visibleChunkIndices = useVisibleChunkIndices(length, import_core5.MAX_CANVAS_WIDTH, clipOriginX);
|
|
2527
2546
|
(0, import_react21.useEffect)(() => {
|
|
@@ -2532,28 +2551,10 @@ var SpectrogramChannel = ({
|
|
|
2532
2551
|
}, [onCanvasUnregister]);
|
|
2533
2552
|
(0, import_react21.useEffect)(() => {
|
|
2534
2553
|
if (!clipId) return;
|
|
2554
|
+
if (releasedRef.current) return;
|
|
2535
2555
|
const unregister = onCanvasUnregisterRef.current;
|
|
2536
2556
|
const register = onCanvasRegisterRef.current;
|
|
2537
|
-
const remaining =
|
|
2538
|
-
for (const id of registeredIdsRef.current) {
|
|
2539
|
-
const parsed = (0, import_core5.parseSpectrogramCanvasId)(id);
|
|
2540
|
-
if (!parsed) {
|
|
2541
|
-
remaining.push(id);
|
|
2542
|
-
continue;
|
|
2543
|
-
}
|
|
2544
|
-
const chunkIdx = parsed.chunkIndex;
|
|
2545
|
-
const canvas = canvasMapRef.current.get(chunkIdx);
|
|
2546
|
-
if (canvas && canvas.isConnected) {
|
|
2547
|
-
remaining.push(id);
|
|
2548
|
-
} else {
|
|
2549
|
-
try {
|
|
2550
|
-
unregister(id);
|
|
2551
|
-
} catch (err) {
|
|
2552
|
-
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2553
|
-
}
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
registeredIdsRef.current = remaining;
|
|
2557
|
+
const remaining = releaseUnmounted(registeredIdsRef.current, canvasMapRef.current, unregister);
|
|
2557
2558
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
2558
2559
|
if (transferredCanvasesRef.current.has(canvas)) continue;
|
|
2559
2560
|
const canvasId = (0, import_core5.buildSpectrogramCanvasId)({ clipId, channelIndex, chunkIndex: canvasIdx });
|
|
@@ -2578,11 +2579,12 @@ var SpectrogramChannel = ({
|
|
|
2578
2579
|
...offsetSamples !== void 0 ? { offsetSamples } : {},
|
|
2579
2580
|
...durationSamples !== void 0 ? { durationSamples } : {}
|
|
2580
2581
|
});
|
|
2581
|
-
|
|
2582
|
+
remaining.add(canvasId);
|
|
2582
2583
|
} catch (err) {
|
|
2583
2584
|
console.warn(`[spectrogram] register failed for ${canvasId}:`, err);
|
|
2584
2585
|
}
|
|
2585
2586
|
}
|
|
2587
|
+
registeredIdsRef.current = remaining;
|
|
2586
2588
|
}, [
|
|
2587
2589
|
canvasMapRef,
|
|
2588
2590
|
clipId,
|
|
@@ -2591,9 +2593,14 @@ var SpectrogramChannel = ({
|
|
|
2591
2593
|
waveHeight,
|
|
2592
2594
|
offsetSamples,
|
|
2593
2595
|
durationSamples,
|
|
2594
|
-
visibleChunkIndices
|
|
2596
|
+
visibleChunkIndices,
|
|
2597
|
+
generation
|
|
2595
2598
|
]);
|
|
2596
2599
|
(0, import_react21.useEffect)(() => {
|
|
2600
|
+
if (releasedRef.current) {
|
|
2601
|
+
releasedRef.current = false;
|
|
2602
|
+
setGeneration((g) => g + 1);
|
|
2603
|
+
}
|
|
2597
2604
|
return () => {
|
|
2598
2605
|
const unregister = onCanvasUnregisterRef.current;
|
|
2599
2606
|
for (const id of registeredIdsRef.current) {
|
|
@@ -2603,7 +2610,8 @@ var SpectrogramChannel = ({
|
|
|
2603
2610
|
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2604
2611
|
}
|
|
2605
2612
|
}
|
|
2606
|
-
registeredIdsRef.current =
|
|
2613
|
+
registeredIdsRef.current = /* @__PURE__ */ new Set();
|
|
2614
|
+
releasedRef.current = true;
|
|
2607
2615
|
};
|
|
2608
2616
|
}, []);
|
|
2609
2617
|
const canvases = visibleChunkIndices.map((i) => {
|
|
@@ -2620,7 +2628,7 @@ var SpectrogramChannel = ({
|
|
|
2620
2628
|
"data-index": i,
|
|
2621
2629
|
ref: canvasRef
|
|
2622
2630
|
},
|
|
2623
|
-
`${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2631
|
+
`${generation}-${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2624
2632
|
);
|
|
2625
2633
|
});
|
|
2626
2634
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Wrapper4, { $index: index, $cssWidth: length, $waveHeight: waveHeight, children: canvases });
|