@waveform-playlist/ui-components 12.1.0 → 13.0.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.d.mts +19 -14
- package/dist/index.d.ts +19 -14
- package/dist/index.js +36 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2350,28 +2350,28 @@ var SpectrogramChannel = ({
|
|
|
2350
2350
|
waveHeight,
|
|
2351
2351
|
devicePixelRatio = 1,
|
|
2352
2352
|
samplesPerPixel: _samplesPerPixel,
|
|
2353
|
-
workerApi,
|
|
2354
2353
|
clipId,
|
|
2355
|
-
|
|
2354
|
+
onCanvasRegister,
|
|
2355
|
+
onCanvasUnregister
|
|
2356
2356
|
}) => {
|
|
2357
2357
|
const channelIndex = channelIndexProp ?? index;
|
|
2358
2358
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2359
2359
|
const registeredIdsRef = useRef7([]);
|
|
2360
2360
|
const transferredCanvasesRef = useRef7(/* @__PURE__ */ new WeakSet());
|
|
2361
|
-
const
|
|
2362
|
-
const
|
|
2361
|
+
const onCanvasRegisterRef = useRef7(onCanvasRegister);
|
|
2362
|
+
const onCanvasUnregisterRef = useRef7(onCanvasUnregister);
|
|
2363
2363
|
const clipOriginX = useClipViewportOrigin();
|
|
2364
2364
|
const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH3, clipOriginX);
|
|
2365
2365
|
useEffect6(() => {
|
|
2366
|
-
|
|
2367
|
-
}, [
|
|
2366
|
+
onCanvasRegisterRef.current = onCanvasRegister;
|
|
2367
|
+
}, [onCanvasRegister]);
|
|
2368
2368
|
useEffect6(() => {
|
|
2369
|
-
|
|
2370
|
-
}, [
|
|
2369
|
+
onCanvasUnregisterRef.current = onCanvasUnregister;
|
|
2370
|
+
}, [onCanvasUnregister]);
|
|
2371
2371
|
useEffect6(() => {
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
const
|
|
2372
|
+
if (!clipId) return;
|
|
2373
|
+
const unregister = onCanvasUnregisterRef.current;
|
|
2374
|
+
const register = onCanvasRegisterRef.current;
|
|
2375
2375
|
const remaining = [];
|
|
2376
2376
|
for (const id of registeredIdsRef.current) {
|
|
2377
2377
|
const match = id.match(/chunk(\d+)$/);
|
|
@@ -2385,14 +2385,13 @@ var SpectrogramChannel = ({
|
|
|
2385
2385
|
remaining.push(id);
|
|
2386
2386
|
} else {
|
|
2387
2387
|
try {
|
|
2388
|
-
|
|
2388
|
+
unregister(id);
|
|
2389
2389
|
} catch (err) {
|
|
2390
|
-
console.warn(`[spectrogram]
|
|
2390
|
+
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
2394
2394
|
registeredIdsRef.current = remaining;
|
|
2395
|
-
const newIds = [];
|
|
2396
2395
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
2397
2396
|
if (transferredCanvasesRef.current.has(canvas)) continue;
|
|
2398
2397
|
const canvasId = `${clipId}-ch${channelIndex}-chunk${canvasIdx}`;
|
|
@@ -2404,41 +2403,31 @@ var SpectrogramChannel = ({
|
|
|
2404
2403
|
continue;
|
|
2405
2404
|
}
|
|
2406
2405
|
transferredCanvasesRef.current.add(canvas);
|
|
2406
|
+
const widthPx = Math.min(length - canvasIdx * MAX_CANVAS_WIDTH3, MAX_CANVAS_WIDTH3);
|
|
2407
2407
|
try {
|
|
2408
|
-
|
|
2409
|
-
|
|
2408
|
+
register({
|
|
2409
|
+
canvasId,
|
|
2410
|
+
canvas: offscreen,
|
|
2411
|
+
clipId,
|
|
2412
|
+
channelIndex,
|
|
2413
|
+
chunkIndex: canvasIdx,
|
|
2414
|
+
widthPx,
|
|
2415
|
+
heightPx: waveHeight
|
|
2416
|
+
});
|
|
2417
|
+
registeredIdsRef.current.push(canvasId);
|
|
2410
2418
|
} catch (err) {
|
|
2411
|
-
console.warn(`[spectrogram]
|
|
2412
|
-
continue;
|
|
2419
|
+
console.warn(`[spectrogram] register failed for ${canvasId}:`, err);
|
|
2413
2420
|
}
|
|
2414
2421
|
}
|
|
2415
|
-
|
|
2416
|
-
registeredIdsRef.current = [...registeredIdsRef.current, ...newIds];
|
|
2417
|
-
}
|
|
2418
|
-
const canvasSetChanged = newIds.length > 0 || remaining.length < previousCount;
|
|
2419
|
-
if (canvasSetChanged) {
|
|
2420
|
-
const allIds = registeredIdsRef.current;
|
|
2421
|
-
const allWidths = allIds.map((id) => {
|
|
2422
|
-
const match = id.match(/chunk(\d+)$/);
|
|
2423
|
-
if (!match) {
|
|
2424
|
-
console.warn(`[spectrogram] Unexpected canvas ID format: ${id}`);
|
|
2425
|
-
return MAX_CANVAS_WIDTH3;
|
|
2426
|
-
}
|
|
2427
|
-
const chunkIdx = parseInt(match[1], 10);
|
|
2428
|
-
return Math.min(length - chunkIdx * MAX_CANVAS_WIDTH3, MAX_CANVAS_WIDTH3);
|
|
2429
|
-
});
|
|
2430
|
-
onCanvasesReadyRef.current?.(allIds, allWidths);
|
|
2431
|
-
}
|
|
2432
|
-
}, [canvasMapRef, clipId, channelIndex, length, visibleChunkIndices]);
|
|
2422
|
+
}, [canvasMapRef, clipId, channelIndex, length, waveHeight, visibleChunkIndices]);
|
|
2433
2423
|
useEffect6(() => {
|
|
2434
2424
|
return () => {
|
|
2435
|
-
const
|
|
2436
|
-
if (!api) return;
|
|
2425
|
+
const unregister = onCanvasUnregisterRef.current;
|
|
2437
2426
|
for (const id of registeredIdsRef.current) {
|
|
2438
2427
|
try {
|
|
2439
|
-
|
|
2428
|
+
unregister(id);
|
|
2440
2429
|
} catch (err) {
|
|
2441
|
-
console.warn(`[spectrogram]
|
|
2430
|
+
console.warn(`[spectrogram] unregister failed for ${id}:`, err);
|
|
2442
2431
|
}
|
|
2443
2432
|
}
|
|
2444
2433
|
registeredIdsRef.current = [];
|
|
@@ -2471,9 +2460,9 @@ var SmartChannel = ({
|
|
|
2471
2460
|
transparentBackground,
|
|
2472
2461
|
renderMode = "waveform",
|
|
2473
2462
|
samplesPerPixel: sppProp,
|
|
2474
|
-
spectrogramWorkerApi,
|
|
2475
2463
|
spectrogramClipId,
|
|
2476
|
-
|
|
2464
|
+
spectrogramOnCanvasRegister,
|
|
2465
|
+
spectrogramOnCanvasUnregister,
|
|
2477
2466
|
midiNotes,
|
|
2478
2467
|
sampleRate: sampleRateProp,
|
|
2479
2468
|
clipOffsetSeconds,
|
|
@@ -2492,7 +2481,7 @@ var SmartChannel = ({
|
|
|
2492
2481
|
const waveOutlineColor = isSelected && theme ? theme.selectedWaveOutlineColor : theme?.waveOutlineColor;
|
|
2493
2482
|
const waveFillColor = isSelected && theme ? theme.selectedWaveFillColor : theme?.waveFillColor;
|
|
2494
2483
|
const drawMode = theme?.waveformDrawMode || "inverted";
|
|
2495
|
-
const hasSpectrogram =
|
|
2484
|
+
const hasSpectrogram = spectrogramClipId && spectrogramOnCanvasRegister && spectrogramOnCanvasUnregister;
|
|
2496
2485
|
if (renderMode === "spectrogram" && hasSpectrogram) {
|
|
2497
2486
|
return /* @__PURE__ */ jsx24(
|
|
2498
2487
|
SpectrogramChannel,
|
|
@@ -2502,9 +2491,9 @@ var SmartChannel = ({
|
|
|
2502
2491
|
waveHeight,
|
|
2503
2492
|
devicePixelRatio,
|
|
2504
2493
|
samplesPerPixel,
|
|
2505
|
-
workerApi: spectrogramWorkerApi,
|
|
2506
2494
|
clipId: spectrogramClipId,
|
|
2507
|
-
|
|
2495
|
+
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2496
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2508
2497
|
}
|
|
2509
2498
|
);
|
|
2510
2499
|
}
|
|
@@ -2520,9 +2509,9 @@ var SmartChannel = ({
|
|
|
2520
2509
|
waveHeight: halfHeight,
|
|
2521
2510
|
devicePixelRatio,
|
|
2522
2511
|
samplesPerPixel,
|
|
2523
|
-
workerApi: spectrogramWorkerApi,
|
|
2524
2512
|
clipId: spectrogramClipId,
|
|
2525
|
-
|
|
2513
|
+
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2514
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2526
2515
|
}
|
|
2527
2516
|
),
|
|
2528
2517
|
/* @__PURE__ */ jsx24(
|