@waveform-playlist/ui-components 14.0.1 → 15.0.0-next.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/README.md +44 -0
- package/dist/index.d.mts +241 -163
- package/dist/index.d.ts +241 -163
- package/dist/index.js +947 -710
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +830 -593
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
// src/components/
|
|
2
|
-
import
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var PositionDisplay = styled.span`
|
|
5
|
-
font-family: 'Courier New', Monaco, monospace;
|
|
6
|
-
font-size: 1rem;
|
|
7
|
-
font-weight: 600;
|
|
8
|
-
color: ${(props) => props.theme?.textColor || "#333"};
|
|
9
|
-
user-select: none;
|
|
10
|
-
`;
|
|
11
|
-
var AudioPosition = ({ formattedTime, className }) => {
|
|
12
|
-
return /* @__PURE__ */ jsx(PositionDisplay, { className, "aria-label": "Audio position", children: formattedTime });
|
|
13
|
-
};
|
|
1
|
+
// src/components/AutomaticScrollCheckbox.tsx
|
|
2
|
+
import { useId } from "react";
|
|
14
3
|
|
|
15
4
|
// src/styled/BaseButton.tsx
|
|
16
|
-
import
|
|
17
|
-
var BaseButton =
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
var BaseButton = styled.button`
|
|
18
7
|
display: inline-flex;
|
|
19
8
|
align-items: center;
|
|
20
9
|
justify-content: center;
|
|
@@ -46,16 +35,16 @@ var BaseButton = styled2.button`
|
|
|
46
35
|
cursor: not-allowed;
|
|
47
36
|
}
|
|
48
37
|
`;
|
|
49
|
-
var BaseButtonSmall =
|
|
38
|
+
var BaseButtonSmall = styled(BaseButton)`
|
|
50
39
|
padding: 0.25rem 0.5rem;
|
|
51
40
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
52
41
|
`;
|
|
53
|
-
var IconButton =
|
|
42
|
+
var IconButton = styled(BaseButton)`
|
|
54
43
|
padding: 0.5rem;
|
|
55
44
|
min-width: 2.25rem;
|
|
56
45
|
min-height: 2.25rem;
|
|
57
46
|
`;
|
|
58
|
-
var IconButtonSmall =
|
|
47
|
+
var IconButtonSmall = styled(BaseButton)`
|
|
59
48
|
padding: 0.25rem;
|
|
60
49
|
min-width: 1.75rem;
|
|
61
50
|
min-height: 1.75rem;
|
|
@@ -63,13 +52,13 @@ var IconButtonSmall = styled2(BaseButton)`
|
|
|
63
52
|
`;
|
|
64
53
|
|
|
65
54
|
// src/styled/BaseCheckbox.tsx
|
|
66
|
-
import
|
|
67
|
-
var BaseCheckboxWrapper =
|
|
55
|
+
import styled2 from "styled-components";
|
|
56
|
+
var BaseCheckboxWrapper = styled2.div`
|
|
68
57
|
display: inline-flex;
|
|
69
58
|
align-items: center;
|
|
70
59
|
gap: 0.5rem;
|
|
71
60
|
`;
|
|
72
|
-
var BaseCheckbox =
|
|
61
|
+
var BaseCheckbox = styled2.input`
|
|
73
62
|
cursor: pointer;
|
|
74
63
|
accent-color: ${(props) => props.theme.inputFocusBorder};
|
|
75
64
|
|
|
@@ -77,7 +66,7 @@ var BaseCheckbox = styled3.input`
|
|
|
77
66
|
cursor: not-allowed;
|
|
78
67
|
}
|
|
79
68
|
`;
|
|
80
|
-
var BaseCheckboxLabel =
|
|
69
|
+
var BaseCheckboxLabel = styled2.label`
|
|
81
70
|
margin: 0;
|
|
82
71
|
cursor: pointer;
|
|
83
72
|
user-select: none;
|
|
@@ -87,8 +76,8 @@ var BaseCheckboxLabel = styled3.label`
|
|
|
87
76
|
`;
|
|
88
77
|
|
|
89
78
|
// src/styled/BaseControlButton.tsx
|
|
90
|
-
import
|
|
91
|
-
var BaseControlButton =
|
|
79
|
+
import styled3 from "styled-components";
|
|
80
|
+
var BaseControlButton = styled3.button`
|
|
92
81
|
padding: 0.5rem 1rem;
|
|
93
82
|
background: ${(props) => props.theme.buttonBackground || "#007bff"};
|
|
94
83
|
color: ${(props) => props.theme.buttonText || "white"};
|
|
@@ -117,8 +106,8 @@ var BaseControlButton = styled4.button`
|
|
|
117
106
|
`;
|
|
118
107
|
|
|
119
108
|
// src/styled/BaseInput.tsx
|
|
120
|
-
import
|
|
121
|
-
var BaseInput =
|
|
109
|
+
import styled4 from "styled-components";
|
|
110
|
+
var BaseInput = styled4.input`
|
|
122
111
|
padding: 0.5rem 0.75rem;
|
|
123
112
|
font-family: ${(props) => props.theme.fontFamily};
|
|
124
113
|
font-size: ${(props) => props.theme.fontSize};
|
|
@@ -145,14 +134,14 @@ var BaseInput = styled5.input`
|
|
|
145
134
|
cursor: not-allowed;
|
|
146
135
|
}
|
|
147
136
|
`;
|
|
148
|
-
var BaseInputSmall =
|
|
137
|
+
var BaseInputSmall = styled4(BaseInput)`
|
|
149
138
|
padding: 0.25rem 0.5rem;
|
|
150
139
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
151
140
|
`;
|
|
152
141
|
|
|
153
142
|
// src/styled/BaseLabel.tsx
|
|
154
|
-
import
|
|
155
|
-
var BaseLabel =
|
|
143
|
+
import styled5 from "styled-components";
|
|
144
|
+
var BaseLabel = styled5.label`
|
|
156
145
|
font-family: ${(props) => props.theme.fontFamily};
|
|
157
146
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
158
147
|
font-weight: 500;
|
|
@@ -160,7 +149,7 @@ var BaseLabel = styled6.label`
|
|
|
160
149
|
margin-bottom: 0.25rem;
|
|
161
150
|
display: block;
|
|
162
151
|
`;
|
|
163
|
-
var InlineLabel =
|
|
152
|
+
var InlineLabel = styled5.label`
|
|
164
153
|
font-family: ${(props) => props.theme.fontFamily};
|
|
165
154
|
font-size: ${(props) => props.theme.fontSize};
|
|
166
155
|
color: ${(props) => props.theme.textColor};
|
|
@@ -169,7 +158,7 @@ var InlineLabel = styled6.label`
|
|
|
169
158
|
gap: 0.5rem;
|
|
170
159
|
cursor: pointer;
|
|
171
160
|
`;
|
|
172
|
-
var ScreenReaderOnly =
|
|
161
|
+
var ScreenReaderOnly = styled5.span`
|
|
173
162
|
position: absolute;
|
|
174
163
|
width: 1px;
|
|
175
164
|
height: 1px;
|
|
@@ -182,8 +171,8 @@ var ScreenReaderOnly = styled6.span`
|
|
|
182
171
|
`;
|
|
183
172
|
|
|
184
173
|
// src/styled/BaseSelect.tsx
|
|
185
|
-
import
|
|
186
|
-
var BaseSelect =
|
|
174
|
+
import styled6 from "styled-components";
|
|
175
|
+
var BaseSelect = styled6.select`
|
|
187
176
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
188
177
|
font-family: ${(props) => props.theme.fontFamily};
|
|
189
178
|
font-size: ${(props) => props.theme.fontSize};
|
|
@@ -217,14 +206,14 @@ var BaseSelect = styled7.select`
|
|
|
217
206
|
background-color: ${(props) => props.theme.inputBackground};
|
|
218
207
|
}
|
|
219
208
|
`;
|
|
220
|
-
var BaseSelectSmall =
|
|
209
|
+
var BaseSelectSmall = styled6(BaseSelect)`
|
|
221
210
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
222
211
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
223
212
|
`;
|
|
224
213
|
|
|
225
214
|
// src/styled/BaseSlider.tsx
|
|
226
|
-
import
|
|
227
|
-
var BaseSlider =
|
|
215
|
+
import styled7 from "styled-components";
|
|
216
|
+
var BaseSlider = styled7.input.attrs({ type: "range" })`
|
|
228
217
|
-webkit-appearance: none;
|
|
229
218
|
appearance: none;
|
|
230
219
|
width: 100%;
|
|
@@ -307,35 +296,36 @@ var BaseSlider = styled8.input.attrs({ type: "range" })`
|
|
|
307
296
|
`;
|
|
308
297
|
|
|
309
298
|
// src/components/AutomaticScrollCheckbox.tsx
|
|
310
|
-
import { jsx
|
|
299
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
311
300
|
var AutomaticScrollCheckbox = ({
|
|
312
301
|
checked,
|
|
313
302
|
onChange,
|
|
314
303
|
disabled = false,
|
|
315
304
|
className
|
|
316
305
|
}) => {
|
|
306
|
+
const id = useId();
|
|
317
307
|
const handleChange = (e) => {
|
|
318
308
|
onChange(e.target.checked);
|
|
319
309
|
};
|
|
320
310
|
return /* @__PURE__ */ jsxs(BaseCheckboxWrapper, { className, children: [
|
|
321
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ jsx(
|
|
322
312
|
BaseCheckbox,
|
|
323
313
|
{
|
|
324
314
|
type: "checkbox",
|
|
325
|
-
id
|
|
315
|
+
id,
|
|
326
316
|
className: "automatic-scroll",
|
|
327
317
|
checked,
|
|
328
318
|
onChange: handleChange,
|
|
329
319
|
disabled
|
|
330
320
|
}
|
|
331
321
|
),
|
|
332
|
-
/* @__PURE__ */
|
|
322
|
+
/* @__PURE__ */ jsx(BaseCheckboxLabel, { htmlFor: id, children: "Automatic Scroll" })
|
|
333
323
|
] });
|
|
334
324
|
};
|
|
335
325
|
|
|
336
326
|
// src/components/Channel.tsx
|
|
337
|
-
import { useLayoutEffect as useLayoutEffect2
|
|
338
|
-
import
|
|
327
|
+
import { useLayoutEffect as useLayoutEffect2 } from "react";
|
|
328
|
+
import styled8 from "styled-components";
|
|
339
329
|
|
|
340
330
|
// src/wfpl-theme.ts
|
|
341
331
|
function isWaveformGradient(color) {
|
|
@@ -412,10 +402,12 @@ var defaultTheme = {
|
|
|
412
402
|
annotationResizeHandleColor: "rgba(0, 0, 0, 0.4)",
|
|
413
403
|
annotationResizeHandleActiveColor: "rgba(0, 0, 0, 0.8)",
|
|
414
404
|
annotationTextItemHoverBackground: "rgba(0, 0, 0, 0.03)",
|
|
405
|
+
annotationTextItemActiveColor: "#ff9800",
|
|
415
406
|
// Piano roll colors
|
|
416
407
|
pianoRollNoteColor: "#2a7070",
|
|
417
408
|
pianoRollSelectedNoteColor: "#3d9e9e",
|
|
418
409
|
pianoRollBackgroundColor: "#1a1a2e",
|
|
410
|
+
spectrogramBackgroundColor: "#000",
|
|
419
411
|
// Spacing and sizing
|
|
420
412
|
borderRadius: "4px",
|
|
421
413
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',
|
|
@@ -489,16 +481,18 @@ var darkTheme = {
|
|
|
489
481
|
annotationBoxBackground: "rgba(40, 32, 24, 0.9)",
|
|
490
482
|
annotationBoxActiveBackground: "rgba(50, 40, 30, 0.95)",
|
|
491
483
|
annotationBoxHoverBackground: "rgba(60, 48, 36, 0.98)",
|
|
492
|
-
annotationBoxBorder: "#
|
|
484
|
+
annotationBoxBorder: "#ff9800",
|
|
493
485
|
annotationBoxActiveBorder: "#d4a87c",
|
|
494
486
|
annotationLabelColor: "#d8c0a8",
|
|
495
487
|
annotationResizeHandleColor: "rgba(200, 160, 120, 0.5)",
|
|
496
488
|
annotationResizeHandleActiveColor: "rgba(220, 180, 140, 0.8)",
|
|
497
489
|
annotationTextItemHoverBackground: "rgba(200, 160, 120, 0.08)",
|
|
490
|
+
annotationTextItemActiveColor: "#ff9800",
|
|
498
491
|
// Piano roll colors
|
|
499
492
|
pianoRollNoteColor: "#c49a6c",
|
|
500
493
|
pianoRollSelectedNoteColor: "#e8c090",
|
|
501
494
|
pianoRollBackgroundColor: "#0d0d14",
|
|
495
|
+
spectrogramBackgroundColor: "#000",
|
|
502
496
|
// Spacing and sizing
|
|
503
497
|
borderRadius: "4px",
|
|
504
498
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',
|
|
@@ -509,7 +503,7 @@ var darkTheme = {
|
|
|
509
503
|
// src/contexts/ScrollViewport.tsx
|
|
510
504
|
import {
|
|
511
505
|
createContext,
|
|
512
|
-
|
|
506
|
+
use,
|
|
513
507
|
useEffect,
|
|
514
508
|
useLayoutEffect,
|
|
515
509
|
useCallback,
|
|
@@ -517,7 +511,7 @@ import {
|
|
|
517
511
|
useRef,
|
|
518
512
|
useSyncExternalStore
|
|
519
513
|
} from "react";
|
|
520
|
-
import { jsx as
|
|
514
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
521
515
|
var ViewportStore = class {
|
|
522
516
|
constructor(containerEl) {
|
|
523
517
|
this._listeners = /* @__PURE__ */ new Set();
|
|
@@ -614,10 +608,10 @@ var ScrollViewportProvider = ({ containerRef, children }) => {
|
|
|
614
608
|
store.cancelPendingNotification();
|
|
615
609
|
};
|
|
616
610
|
}, [containerRef, scheduleUpdate, store]);
|
|
617
|
-
return /* @__PURE__ */
|
|
611
|
+
return /* @__PURE__ */ jsx2(ViewportStoreContext, { value: store, children });
|
|
618
612
|
};
|
|
619
613
|
var useScrollViewport = () => {
|
|
620
|
-
const store =
|
|
614
|
+
const store = use(ViewportStoreContext);
|
|
621
615
|
return useSyncExternalStore(
|
|
622
616
|
store ? store.subscribe : EMPTY_SUBSCRIBE,
|
|
623
617
|
store ? store.getSnapshot : NULL_SNAPSHOT,
|
|
@@ -625,7 +619,7 @@ var useScrollViewport = () => {
|
|
|
625
619
|
);
|
|
626
620
|
};
|
|
627
621
|
function useScrollViewportSelector(selector) {
|
|
628
|
-
const store =
|
|
622
|
+
const store = use(ViewportStoreContext);
|
|
629
623
|
return useSyncExternalStore(
|
|
630
624
|
store ? store.subscribe : EMPTY_SUBSCRIBE,
|
|
631
625
|
() => selector(store ? store.getSnapshot() : null),
|
|
@@ -657,14 +651,14 @@ function useVisibleChunkIndices(totalWidth, chunkWidth, originX = 0) {
|
|
|
657
651
|
}
|
|
658
652
|
|
|
659
653
|
// src/contexts/ClipViewportOrigin.tsx
|
|
660
|
-
import { createContext as createContext2,
|
|
661
|
-
import { jsx as
|
|
654
|
+
import { createContext as createContext2, use as use2 } from "react";
|
|
655
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
662
656
|
var ClipViewportOriginContext = createContext2(0);
|
|
663
657
|
var ClipViewportOriginProvider = ({
|
|
664
658
|
originX,
|
|
665
659
|
children
|
|
666
|
-
}) => /* @__PURE__ */
|
|
667
|
-
var useClipViewportOrigin = () =>
|
|
660
|
+
}) => /* @__PURE__ */ jsx3(ClipViewportOriginContext, { value: originX, children });
|
|
661
|
+
var useClipViewportOrigin = () => use2(ClipViewportOriginContext);
|
|
668
662
|
|
|
669
663
|
// src/hooks/useChunkedCanvasRefs.ts
|
|
670
664
|
import { useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
@@ -687,6 +681,18 @@ function useChunkedCanvasRefs() {
|
|
|
687
681
|
return { canvasRef, canvasMapRef };
|
|
688
682
|
}
|
|
689
683
|
|
|
684
|
+
// src/hooks/useIdentityVersion.ts
|
|
685
|
+
import { useRef as useRef3 } from "react";
|
|
686
|
+
function useIdentityVersion(value) {
|
|
687
|
+
const versionRef = useRef3(0);
|
|
688
|
+
const previousRef = useRef3(value);
|
|
689
|
+
if (previousRef.current !== value) {
|
|
690
|
+
versionRef.current += 1;
|
|
691
|
+
previousRef.current = value;
|
|
692
|
+
}
|
|
693
|
+
return versionRef.current;
|
|
694
|
+
}
|
|
695
|
+
|
|
690
696
|
// src/components/Channel.tsx
|
|
691
697
|
import { MAX_CANVAS_WIDTH } from "@waveform-playlist/core";
|
|
692
698
|
|
|
@@ -707,6 +713,19 @@ function aggregatePeaks(data, bits, startIndex, endIndex) {
|
|
|
707
713
|
}
|
|
708
714
|
return { min: minPeak, max: maxPeak };
|
|
709
715
|
}
|
|
716
|
+
function clampToFullScale(value) {
|
|
717
|
+
return Math.max(-1, Math.min(1, value));
|
|
718
|
+
}
|
|
719
|
+
function scalePeakByGain(peak, gain) {
|
|
720
|
+
if (gain === 1 || !Number.isFinite(gain)) {
|
|
721
|
+
return peak;
|
|
722
|
+
}
|
|
723
|
+
const factor = Math.abs(gain);
|
|
724
|
+
return {
|
|
725
|
+
min: clampToFullScale(peak.min * factor),
|
|
726
|
+
max: clampToFullScale(peak.max * factor)
|
|
727
|
+
};
|
|
728
|
+
}
|
|
710
729
|
function calculateBarRects(x, barWidth, halfHeight, minPeak, maxPeak, drawMode) {
|
|
711
730
|
const min = Math.abs(minPeak * halfHeight);
|
|
712
731
|
const max = Math.abs(maxPeak * halfHeight);
|
|
@@ -728,9 +747,13 @@ function addBarToPath(ctx, rect, radius) {
|
|
|
728
747
|
function calculateFirstBarPosition(canvasStartGlobal, barWidth, step) {
|
|
729
748
|
return Math.floor((canvasStartGlobal - barWidth + step) / step) * step;
|
|
730
749
|
}
|
|
750
|
+
function barStep(barWidth, barGap) {
|
|
751
|
+
const step = barWidth + barGap;
|
|
752
|
+
return step >= 1 ? step : 1;
|
|
753
|
+
}
|
|
731
754
|
|
|
732
755
|
// src/components/Channel.tsx
|
|
733
|
-
import { jsx as
|
|
756
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
734
757
|
function createCanvasFillStyle(ctx, color, width, height) {
|
|
735
758
|
if (!isWaveformGradient(color)) {
|
|
736
759
|
return color;
|
|
@@ -746,7 +769,7 @@ function createCanvasFillStyle(ctx, color, width, height) {
|
|
|
746
769
|
}
|
|
747
770
|
return gradient;
|
|
748
771
|
}
|
|
749
|
-
var Waveform =
|
|
772
|
+
var Waveform = styled8.canvas.attrs((props) => ({
|
|
750
773
|
style: {
|
|
751
774
|
width: `${props.$cssWidth}px`,
|
|
752
775
|
height: `${props.$waveHeight}px`,
|
|
@@ -759,7 +782,7 @@ var Waveform = styled9.canvas.attrs((props) => ({
|
|
|
759
782
|
image-rendering: pixelated;
|
|
760
783
|
image-rendering: crisp-edges;
|
|
761
784
|
`;
|
|
762
|
-
var Wrapper =
|
|
785
|
+
var Wrapper = styled8.div.attrs((props) => ({
|
|
763
786
|
style: {
|
|
764
787
|
top: `${props.$waveHeight * props.$index}px`,
|
|
765
788
|
width: `${props.$cssWidth}px`,
|
|
@@ -786,21 +809,17 @@ var Channel = (props) => {
|
|
|
786
809
|
barWidth = 1,
|
|
787
810
|
barGap = 0,
|
|
788
811
|
roundedBars = false,
|
|
812
|
+
gain = 1,
|
|
789
813
|
transparentBackground = false,
|
|
790
814
|
drawMode = "inverted"
|
|
791
815
|
} = props;
|
|
792
816
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
793
817
|
const clipOriginX = useClipViewportOrigin();
|
|
794
818
|
const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH, clipOriginX);
|
|
795
|
-
const
|
|
796
|
-
const
|
|
797
|
-
if (prevDataRef.current !== data) {
|
|
798
|
-
dataVersionRef.current += 1;
|
|
799
|
-
prevDataRef.current = data;
|
|
800
|
-
}
|
|
801
|
-
const drawVersion = `${dataVersionRef.current}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${roundedBars}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
|
|
819
|
+
const dataVersion = useIdentityVersion(data);
|
|
820
|
+
const drawVersion = `${dataVersion}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${roundedBars}-${gain}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
|
|
802
821
|
useLayoutEffect2(() => {
|
|
803
|
-
const step = barWidth
|
|
822
|
+
const step = barStep(barWidth, barGap);
|
|
804
823
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
805
824
|
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
806
825
|
const globalPixelOffset = canvasIdx * MAX_CANVAS_WIDTH;
|
|
@@ -835,8 +854,9 @@ var Channel = (props) => {
|
|
|
835
854
|
const x = barGlobal - canvasStartGlobal;
|
|
836
855
|
if (x + barWidth <= 0) continue;
|
|
837
856
|
const peakEnd = Math.min(barGlobal + step, length);
|
|
838
|
-
const
|
|
839
|
-
if (
|
|
857
|
+
const sourcePeak = aggregatePeaks(data, bits, barGlobal, peakEnd);
|
|
858
|
+
if (sourcePeak) {
|
|
859
|
+
const peak = scalePeakByGain(sourcePeak, gain);
|
|
840
860
|
const rects = calculateBarRects(x, barWidth, h2, peak.min, peak.max, rectMode);
|
|
841
861
|
for (const rect of rects) {
|
|
842
862
|
if (roundedBars) {
|
|
@@ -867,6 +887,7 @@ var Channel = (props) => {
|
|
|
867
887
|
barWidth,
|
|
868
888
|
barGap,
|
|
869
889
|
roundedBars,
|
|
890
|
+
gain,
|
|
870
891
|
drawVersion,
|
|
871
892
|
drawMode,
|
|
872
893
|
visibleChunkIndices,
|
|
@@ -875,7 +896,7 @@ var Channel = (props) => {
|
|
|
875
896
|
const waveforms = visibleChunkIndices.map((i) => {
|
|
876
897
|
const chunkLeft = i * MAX_CANVAS_WIDTH;
|
|
877
898
|
const currentWidth = Math.min(length - chunkLeft, MAX_CANVAS_WIDTH);
|
|
878
|
-
return /* @__PURE__ */
|
|
899
|
+
return /* @__PURE__ */ jsx4(
|
|
879
900
|
Waveform,
|
|
880
901
|
{
|
|
881
902
|
$cssWidth: currentWidth,
|
|
@@ -891,7 +912,7 @@ var Channel = (props) => {
|
|
|
891
912
|
});
|
|
892
913
|
const bgColor = waveFillColor;
|
|
893
914
|
const backgroundCss = transparentBackground ? "transparent" : waveformColorToCss(bgColor);
|
|
894
|
-
return /* @__PURE__ */
|
|
915
|
+
return /* @__PURE__ */ jsx4(
|
|
895
916
|
Wrapper,
|
|
896
917
|
{
|
|
897
918
|
$index: index,
|
|
@@ -905,8 +926,8 @@ var Channel = (props) => {
|
|
|
905
926
|
};
|
|
906
927
|
|
|
907
928
|
// src/components/ErrorBoundary.tsx
|
|
908
|
-
import
|
|
909
|
-
import { jsx as
|
|
929
|
+
import React5 from "react";
|
|
930
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
910
931
|
var errorContainerStyle = {
|
|
911
932
|
padding: "16px",
|
|
912
933
|
background: "#1a1a2e",
|
|
@@ -920,7 +941,7 @@ var errorContainerStyle = {
|
|
|
920
941
|
alignItems: "center",
|
|
921
942
|
justifyContent: "center"
|
|
922
943
|
};
|
|
923
|
-
var PlaylistErrorBoundary = class extends
|
|
944
|
+
var PlaylistErrorBoundary = class extends React5.Component {
|
|
924
945
|
constructor(props) {
|
|
925
946
|
super(props);
|
|
926
947
|
this.state = { hasError: false, error: null };
|
|
@@ -936,22 +957,22 @@ var PlaylistErrorBoundary = class extends React4.Component {
|
|
|
936
957
|
if (this.props.fallback) {
|
|
937
958
|
return this.props.fallback;
|
|
938
959
|
}
|
|
939
|
-
return /* @__PURE__ */
|
|
960
|
+
return /* @__PURE__ */ jsx5("div", { style: errorContainerStyle, children: "Waveform playlist encountered an error. Check console for details." });
|
|
940
961
|
}
|
|
941
962
|
return this.props.children;
|
|
942
963
|
}
|
|
943
964
|
};
|
|
944
965
|
|
|
945
966
|
// src/components/Clip.tsx
|
|
946
|
-
import
|
|
967
|
+
import styled12, { css } from "styled-components";
|
|
947
968
|
import { useDraggable } from "@dnd-kit/react";
|
|
948
969
|
import { Feedback } from "@dnd-kit/dom";
|
|
949
970
|
|
|
950
971
|
// src/components/ClipHeader.tsx
|
|
951
|
-
import
|
|
952
|
-
import { jsx as
|
|
972
|
+
import styled9 from "styled-components";
|
|
973
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
953
974
|
var CLIP_HEADER_HEIGHT = 22;
|
|
954
|
-
var HeaderContainer =
|
|
975
|
+
var HeaderContainer = styled9.div`
|
|
955
976
|
position: relative;
|
|
956
977
|
height: ${CLIP_HEADER_HEIGHT}px;
|
|
957
978
|
background: ${(props) => props.$isSelected ? props.theme.selectedClipHeaderBackgroundColor : props.theme.clipHeaderBackgroundColor};
|
|
@@ -976,7 +997,7 @@ var HeaderContainer = styled10.div`
|
|
|
976
997
|
}
|
|
977
998
|
`}
|
|
978
999
|
`;
|
|
979
|
-
var TrackName =
|
|
1000
|
+
var TrackName = styled9.span`
|
|
980
1001
|
font-size: 11px;
|
|
981
1002
|
font-weight: 600;
|
|
982
1003
|
font-family: ${(props) => props.theme.clipHeaderFontFamily};
|
|
@@ -989,7 +1010,7 @@ var ClipHeaderPresentational = ({
|
|
|
989
1010
|
trackName,
|
|
990
1011
|
isSelected = false
|
|
991
1012
|
}) => {
|
|
992
|
-
return /* @__PURE__ */
|
|
1013
|
+
return /* @__PURE__ */ jsx6(HeaderContainer, { $interactive: false, $isSelected: isSelected, children: /* @__PURE__ */ jsx6(TrackName, { title: trackName, children: trackName }) });
|
|
993
1014
|
};
|
|
994
1015
|
var ClipHeader = ({
|
|
995
1016
|
clipId,
|
|
@@ -1001,28 +1022,27 @@ var ClipHeader = ({
|
|
|
1001
1022
|
dragHandleProps
|
|
1002
1023
|
}) => {
|
|
1003
1024
|
if (disableDrag || !dragHandleProps) {
|
|
1004
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ jsx6(ClipHeaderPresentational, { trackName, isSelected });
|
|
1005
1026
|
}
|
|
1006
1027
|
const { handleRef } = dragHandleProps;
|
|
1007
|
-
return /* @__PURE__ */
|
|
1028
|
+
return /* @__PURE__ */ jsx6(
|
|
1008
1029
|
HeaderContainer,
|
|
1009
1030
|
{
|
|
1010
1031
|
ref: handleRef,
|
|
1011
1032
|
"data-clip-id": clipId,
|
|
1012
1033
|
$interactive: true,
|
|
1013
1034
|
$isSelected: isSelected,
|
|
1014
|
-
children: /* @__PURE__ */
|
|
1035
|
+
children: /* @__PURE__ */ jsx6(TrackName, { title: trackName, children: trackName })
|
|
1015
1036
|
}
|
|
1016
1037
|
);
|
|
1017
1038
|
};
|
|
1018
1039
|
|
|
1019
1040
|
// src/components/ClipBoundary.tsx
|
|
1020
|
-
import
|
|
1021
|
-
import
|
|
1022
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1041
|
+
import styled10 from "styled-components";
|
|
1042
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1023
1043
|
var CLIP_BOUNDARY_WIDTH = 8;
|
|
1024
1044
|
var CLIP_BOUNDARY_WIDTH_TOUCH = 24;
|
|
1025
|
-
var BoundaryContainer =
|
|
1045
|
+
var BoundaryContainer = styled10.div`
|
|
1026
1046
|
position: absolute;
|
|
1027
1047
|
${(props) => props.$edge === "left" ? "left: 0;" : "right: 0;"}
|
|
1028
1048
|
top: 0;
|
|
@@ -1034,10 +1054,10 @@ var BoundaryContainer = styled11.div`
|
|
|
1034
1054
|
pointer-events: auto; /* Re-enable pointer events (parent ClipContainer has pointer-events: none) */
|
|
1035
1055
|
touch-action: none; /* Prevent browser scroll during drag on touch devices */
|
|
1036
1056
|
|
|
1037
|
-
/* Invisible by default
|
|
1038
|
-
background: ${(props) => props.$isDragging ? "rgba(255, 255, 255, 0.4)" :
|
|
1057
|
+
/* Invisible by default; the :hover and :active rules below make it visible */
|
|
1058
|
+
background: ${(props) => props.$isDragging ? "rgba(255, 255, 255, 0.4)" : "transparent"};
|
|
1039
1059
|
|
|
1040
|
-
${(props) => props.$edge === "left" ? `border-left: 2px solid ${props.$isDragging ? "rgba(255, 255, 255, 0.8)" :
|
|
1060
|
+
${(props) => props.$edge === "left" ? `border-left: 2px solid ${props.$isDragging ? "rgba(255, 255, 255, 0.8)" : "transparent"};` : `border-right: 2px solid ${props.$isDragging ? "rgba(255, 255, 255, 0.8)" : "transparent"};`}
|
|
1041
1061
|
|
|
1042
1062
|
transition: background 0.15s ease, border-color 0.15s ease;
|
|
1043
1063
|
|
|
@@ -1059,12 +1079,11 @@ var ClipBoundary = ({
|
|
|
1059
1079
|
dragHandleProps,
|
|
1060
1080
|
touchOptimized = false
|
|
1061
1081
|
}) => {
|
|
1062
|
-
const [isHovered, setIsHovered] = React5.useState(false);
|
|
1063
1082
|
if (!dragHandleProps) {
|
|
1064
1083
|
return null;
|
|
1065
1084
|
}
|
|
1066
1085
|
const { ref: boundaryRef, isDragging } = dragHandleProps;
|
|
1067
|
-
return /* @__PURE__ */
|
|
1086
|
+
return /* @__PURE__ */ jsx7(
|
|
1068
1087
|
BoundaryContainer,
|
|
1069
1088
|
{
|
|
1070
1089
|
ref: boundaryRef,
|
|
@@ -1072,18 +1091,16 @@ var ClipBoundary = ({
|
|
|
1072
1091
|
"data-boundary-edge": edge,
|
|
1073
1092
|
$edge: edge,
|
|
1074
1093
|
$isDragging: isDragging,
|
|
1075
|
-
$
|
|
1076
|
-
$touchOptimized: touchOptimized,
|
|
1077
|
-
onMouseEnter: () => setIsHovered(true),
|
|
1078
|
-
onMouseLeave: () => setIsHovered(false)
|
|
1094
|
+
$touchOptimized: touchOptimized
|
|
1079
1095
|
}
|
|
1080
1096
|
);
|
|
1081
1097
|
};
|
|
1082
1098
|
|
|
1083
1099
|
// src/components/FadeOverlay.tsx
|
|
1084
|
-
import
|
|
1085
|
-
import {
|
|
1086
|
-
|
|
1100
|
+
import { useMemo as useMemo2 } from "react";
|
|
1101
|
+
import styled11, { useTheme } from "styled-components";
|
|
1102
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1103
|
+
var FadeContainer = styled11.div.attrs((props) => ({
|
|
1087
1104
|
style: {
|
|
1088
1105
|
left: `${props.$left}px`,
|
|
1089
1106
|
width: `${props.$width}px`
|
|
@@ -1095,13 +1112,17 @@ var FadeContainer = styled12.div.attrs((props) => ({
|
|
|
1095
1112
|
pointer-events: none;
|
|
1096
1113
|
z-index: 50;
|
|
1097
1114
|
`;
|
|
1098
|
-
var FadeSvg =
|
|
1115
|
+
var FadeSvg = styled11.svg`
|
|
1099
1116
|
width: 100%;
|
|
1100
1117
|
height: 100%;
|
|
1101
1118
|
display: block;
|
|
1102
1119
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
1103
1120
|
transform: ${(props) => props.$type === "fadeOut" ? "scaleX(-1)" : "none"};
|
|
1104
1121
|
`;
|
|
1122
|
+
var FADE_PATH_HEIGHT = 100;
|
|
1123
|
+
function round2(value) {
|
|
1124
|
+
return Math.round(value * 100) / 100;
|
|
1125
|
+
}
|
|
1105
1126
|
function generateFadePath(width, height, curveType = "logarithmic") {
|
|
1106
1127
|
const points = [];
|
|
1107
1128
|
const numPoints = Math.max(20, Math.min(width, 100));
|
|
@@ -1125,7 +1146,7 @@ function generateFadePath(width, height, curveType = "logarithmic") {
|
|
|
1125
1146
|
break;
|
|
1126
1147
|
}
|
|
1127
1148
|
const y = (1 - curvedProgress) * height;
|
|
1128
|
-
points.push(`${x},${y}`);
|
|
1149
|
+
points.push(`${round2(x)},${round2(y)}`);
|
|
1129
1150
|
}
|
|
1130
1151
|
return `M 0,${height} L ${points.join(" L ")} L ${width},0 L 0,0 Z`;
|
|
1131
1152
|
}
|
|
@@ -1137,17 +1158,42 @@ var FadeOverlay = ({
|
|
|
1137
1158
|
color
|
|
1138
1159
|
}) => {
|
|
1139
1160
|
const theme = useTheme();
|
|
1161
|
+
const path = useMemo2(
|
|
1162
|
+
() => width < 1 ? "" : generateFadePath(width, FADE_PATH_HEIGHT, curveType),
|
|
1163
|
+
[width, curveType]
|
|
1164
|
+
);
|
|
1140
1165
|
if (width < 1) return null;
|
|
1141
1166
|
const fillColor = color || theme?.fadeOverlayColor || "rgba(0, 0, 0, 0.4)";
|
|
1142
|
-
return /* @__PURE__ */
|
|
1167
|
+
return /* @__PURE__ */ jsx8(FadeContainer, { $left: left, $width: width, $type: type, children: /* @__PURE__ */ jsx8(FadeSvg, { $type: type, viewBox: `0 0 ${width} ${FADE_PATH_HEIGHT}`, preserveAspectRatio: "none", children: /* @__PURE__ */ jsx8("path", { d: path, fill: fillColor }) }) });
|
|
1143
1168
|
};
|
|
1144
1169
|
|
|
1145
1170
|
// src/components/Clip.tsx
|
|
1146
1171
|
import { clipPixelWidth } from "@waveform-playlist/core";
|
|
1147
|
-
import { Fragment, jsx as
|
|
1172
|
+
import { Fragment, jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1173
|
+
var DEFAULT_PLACEHOLDER_CLIP_OPACITY = 0.5;
|
|
1174
|
+
function placeholderOpacity(theme) {
|
|
1175
|
+
const value = theme?.placeholderClipOpacity;
|
|
1176
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1 ? value : DEFAULT_PLACEHOLDER_CLIP_OPACITY;
|
|
1177
|
+
}
|
|
1148
1178
|
var CLIP_MOVE_PLUGINS = [Feedback.configure({ dropAnimation: null })];
|
|
1149
1179
|
var TRIM_HANDLE_PLUGINS = [Feedback.configure({ feedback: "none" })];
|
|
1150
|
-
|
|
1180
|
+
function clipDraggableIds(trackId, clipId, trackIndex, clipIndex) {
|
|
1181
|
+
if (trackId === void 0) {
|
|
1182
|
+
const at = `${trackIndex}-${clipIndex}`;
|
|
1183
|
+
return {
|
|
1184
|
+
move: `clip-${at}`,
|
|
1185
|
+
left: `clip-boundary-left-${at}`,
|
|
1186
|
+
right: `clip-boundary-right-${at}`
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
const key = `${encodeURIComponent(trackId)}/${encodeURIComponent(clipId)}`;
|
|
1190
|
+
return {
|
|
1191
|
+
move: `clip/${key}`,
|
|
1192
|
+
left: `clip-boundary-left/${key}`,
|
|
1193
|
+
right: `clip-boundary-right/${key}`
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
var ClipContainer = styled12.div.attrs((props) => ({
|
|
1151
1197
|
style: props.$isOverlay ? {} : {
|
|
1152
1198
|
left: `${props.$left}px`,
|
|
1153
1199
|
width: `${props.$width}px`
|
|
@@ -1161,8 +1207,11 @@ var ClipContainer = styled13.div.attrs((props) => ({
|
|
|
1161
1207
|
flex-direction: column;
|
|
1162
1208
|
z-index: 10; /* Above progress overlay (z-index: 2) but below controls/playhead */
|
|
1163
1209
|
pointer-events: none; /* Let clicks pass through to ClickOverlay for playhead positioning */
|
|
1210
|
+
${(props) => props.$isPlaceholder ? css`
|
|
1211
|
+
opacity: ${placeholderOpacity(props.theme)};
|
|
1212
|
+
` : ""}
|
|
1164
1213
|
`;
|
|
1165
|
-
var ChannelsWrapper =
|
|
1214
|
+
var ChannelsWrapper = styled12.div`
|
|
1166
1215
|
flex: 1;
|
|
1167
1216
|
position: relative;
|
|
1168
1217
|
overflow: ${(props) => props.$isOverlay ? "visible" : "hidden"};
|
|
@@ -1187,32 +1236,32 @@ var Clip = ({
|
|
|
1187
1236
|
fadeOut,
|
|
1188
1237
|
sampleRate = 44100,
|
|
1189
1238
|
showFades = false,
|
|
1190
|
-
touchOptimized = false
|
|
1239
|
+
touchOptimized = false,
|
|
1240
|
+
isPlaceholder = false
|
|
1191
1241
|
}) => {
|
|
1192
1242
|
const left = Math.floor(startSample / samplesPerPixel);
|
|
1193
1243
|
const width = clipPixelWidth(startSample, durationSamples, samplesPerPixel);
|
|
1194
|
-
const
|
|
1195
|
-
const
|
|
1244
|
+
const headerDragDisabled = disableHeaderDrag || isPlaceholder;
|
|
1245
|
+
const enableDrag = showHeader && !headerDragDisabled && !isOverlay;
|
|
1246
|
+
const ids = clipDraggableIds(trackId, clipId, trackIndex, clipIndex);
|
|
1196
1247
|
const {
|
|
1197
1248
|
ref: clipRef,
|
|
1198
1249
|
handleRef,
|
|
1199
1250
|
isDragSource
|
|
1200
1251
|
} = useDraggable({
|
|
1201
|
-
id:
|
|
1252
|
+
id: ids.move,
|
|
1202
1253
|
data: { clipId, trackIndex, clipIndex, startSample, durationSamples },
|
|
1203
1254
|
disabled: !enableDrag,
|
|
1204
1255
|
plugins: CLIP_MOVE_PLUGINS
|
|
1205
1256
|
});
|
|
1206
|
-
const leftBoundaryId = `clip-boundary-left-${trackIndex}-${clipIndex}`;
|
|
1207
1257
|
const { ref: leftBoundaryRef, isDragSource: isLeftBoundaryDragging } = useDraggable({
|
|
1208
|
-
id:
|
|
1258
|
+
id: ids.left,
|
|
1209
1259
|
data: { clipId, trackIndex, clipIndex, boundary: "left", startSample, durationSamples },
|
|
1210
1260
|
disabled: !enableDrag,
|
|
1211
1261
|
plugins: TRIM_HANDLE_PLUGINS
|
|
1212
1262
|
});
|
|
1213
|
-
const rightBoundaryId = `clip-boundary-right-${trackIndex}-${clipIndex}`;
|
|
1214
1263
|
const { ref: rightBoundaryRef, isDragSource: isRightBoundaryDragging } = useDraggable({
|
|
1215
|
-
id:
|
|
1264
|
+
id: ids.right,
|
|
1216
1265
|
data: { clipId, trackIndex, clipIndex, boundary: "right", startSample, durationSamples },
|
|
1217
1266
|
disabled: !enableDrag,
|
|
1218
1267
|
plugins: TRIM_HANDLE_PLUGINS
|
|
@@ -1227,12 +1276,14 @@ var Clip = ({
|
|
|
1227
1276
|
$left: left,
|
|
1228
1277
|
$width: width,
|
|
1229
1278
|
$isOverlay: isOverlay,
|
|
1279
|
+
$isPlaceholder: isPlaceholder,
|
|
1230
1280
|
"data-clip-container": "true",
|
|
1281
|
+
"data-clip-placeholder": isPlaceholder ? "true" : void 0,
|
|
1231
1282
|
"data-track-id": trackId,
|
|
1232
1283
|
onMouseDown,
|
|
1233
1284
|
tabIndex: -1,
|
|
1234
1285
|
children: [
|
|
1235
|
-
showHeader && /* @__PURE__ */
|
|
1286
|
+
showHeader && /* @__PURE__ */ jsx9(
|
|
1236
1287
|
ClipHeader,
|
|
1237
1288
|
{
|
|
1238
1289
|
clipId,
|
|
@@ -1240,13 +1291,13 @@ var Clip = ({
|
|
|
1240
1291
|
clipIndex,
|
|
1241
1292
|
trackName,
|
|
1242
1293
|
isSelected,
|
|
1243
|
-
disableDrag:
|
|
1294
|
+
disableDrag: headerDragDisabled,
|
|
1244
1295
|
dragHandleProps: enableDrag ? { handleRef } : void 0
|
|
1245
1296
|
}
|
|
1246
1297
|
),
|
|
1247
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ jsx9(ClipViewportOriginProvider, { originX: left, children: /* @__PURE__ */ jsxs2(ChannelsWrapper, { $isOverlay: isOverlay, children: [
|
|
1248
1299
|
children,
|
|
1249
|
-
showFades && fadeIn && fadeIn.duration > 0 && /* @__PURE__ */
|
|
1300
|
+
showFades && fadeIn && fadeIn.duration > 0 && /* @__PURE__ */ jsx9(
|
|
1250
1301
|
FadeOverlay,
|
|
1251
1302
|
{
|
|
1252
1303
|
left: 0,
|
|
@@ -1255,7 +1306,7 @@ var Clip = ({
|
|
|
1255
1306
|
curveType: fadeIn.type
|
|
1256
1307
|
}
|
|
1257
1308
|
),
|
|
1258
|
-
showFades && fadeOut && fadeOut.duration > 0 && /* @__PURE__ */
|
|
1309
|
+
showFades && fadeOut && fadeOut.duration > 0 && /* @__PURE__ */ jsx9(
|
|
1259
1310
|
FadeOverlay,
|
|
1260
1311
|
{
|
|
1261
1312
|
left: width - Math.floor(fadeOut.duration * sampleRate / samplesPerPixel),
|
|
@@ -1265,8 +1316,8 @@ var Clip = ({
|
|
|
1265
1316
|
}
|
|
1266
1317
|
)
|
|
1267
1318
|
] }) }),
|
|
1268
|
-
showHeader && !
|
|
1269
|
-
/* @__PURE__ */
|
|
1319
|
+
showHeader && !headerDragDisabled && !isOverlay && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1320
|
+
/* @__PURE__ */ jsx9(
|
|
1270
1321
|
ClipBoundary,
|
|
1271
1322
|
{
|
|
1272
1323
|
clipId,
|
|
@@ -1280,7 +1331,7 @@ var Clip = ({
|
|
|
1280
1331
|
}
|
|
1281
1332
|
}
|
|
1282
1333
|
),
|
|
1283
|
-
/* @__PURE__ */
|
|
1334
|
+
/* @__PURE__ */ jsx9(
|
|
1284
1335
|
ClipBoundary,
|
|
1285
1336
|
{
|
|
1286
1337
|
clipId,
|
|
@@ -1300,9 +1351,123 @@ var Clip = ({
|
|
|
1300
1351
|
);
|
|
1301
1352
|
};
|
|
1302
1353
|
|
|
1354
|
+
// src/components/ClipPlaceholderBody.tsx
|
|
1355
|
+
import styled13 from "styled-components";
|
|
1356
|
+
|
|
1357
|
+
// src/contexts/BeatsAndBars.tsx
|
|
1358
|
+
import { createContext as createContext3, use as use3, useMemo as useMemo3 } from "react";
|
|
1359
|
+
import { ticksPerBeat, ticksPerBar } from "@waveform-playlist/core";
|
|
1360
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1361
|
+
var BeatsAndBarsContext = createContext3(null);
|
|
1362
|
+
function BeatsAndBarsProvider({
|
|
1363
|
+
bpm,
|
|
1364
|
+
timeSignature,
|
|
1365
|
+
snapTo,
|
|
1366
|
+
scaleMode = "beats",
|
|
1367
|
+
children
|
|
1368
|
+
}) {
|
|
1369
|
+
const [numerator, denominator] = timeSignature;
|
|
1370
|
+
const value = useMemo3(() => {
|
|
1371
|
+
const ts = [numerator, denominator];
|
|
1372
|
+
const tpBeat = ticksPerBeat(ts);
|
|
1373
|
+
const tpBar = ticksPerBar(ts);
|
|
1374
|
+
return {
|
|
1375
|
+
bpm,
|
|
1376
|
+
timeSignature: ts,
|
|
1377
|
+
snapTo,
|
|
1378
|
+
scaleMode,
|
|
1379
|
+
ticksPerBeat: tpBeat,
|
|
1380
|
+
ticksPerBar: tpBar
|
|
1381
|
+
};
|
|
1382
|
+
}, [bpm, numerator, denominator, snapTo, scaleMode]);
|
|
1383
|
+
return /* @__PURE__ */ jsx10(BeatsAndBarsContext, { value, children });
|
|
1384
|
+
}
|
|
1385
|
+
function useBeatsAndBars() {
|
|
1386
|
+
return use3(BeatsAndBarsContext);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// src/contexts/DevicePixelRatio.tsx
|
|
1390
|
+
import { useState, useEffect as useEffect3, createContext as createContext4, use as use4 } from "react";
|
|
1391
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1392
|
+
function getScale() {
|
|
1393
|
+
return typeof window === "undefined" ? 1 : window.devicePixelRatio;
|
|
1394
|
+
}
|
|
1395
|
+
var DevicePixelRatioContext = createContext4(null);
|
|
1396
|
+
var DevicePixelRatioProvider = ({ children }) => {
|
|
1397
|
+
const [scale, setScale] = useState(getScale);
|
|
1398
|
+
useEffect3(() => {
|
|
1399
|
+
const current = getScale();
|
|
1400
|
+
if (current !== scale) {
|
|
1401
|
+
setScale(current);
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
if (typeof matchMedia !== "function") return;
|
|
1405
|
+
const query = matchMedia(`(resolution: ${scale}dppx)`);
|
|
1406
|
+
const handleChange = () => setScale(getScale());
|
|
1407
|
+
query.addEventListener("change", handleChange);
|
|
1408
|
+
return () => query.removeEventListener("change", handleChange);
|
|
1409
|
+
}, [scale]);
|
|
1410
|
+
return /* @__PURE__ */ jsx11(DevicePixelRatioContext, { value: Math.ceil(scale), children });
|
|
1411
|
+
};
|
|
1412
|
+
var useDevicePixelRatio = () => use4(DevicePixelRatioContext) ?? getScale();
|
|
1413
|
+
|
|
1414
|
+
// src/contexts/PlaylistInfo.tsx
|
|
1415
|
+
import { createContext as createContext5, use as use5 } from "react";
|
|
1416
|
+
var DEFAULT_WAVE_HEIGHT = 80;
|
|
1417
|
+
var DEFAULT_BAR_WIDTH = 1;
|
|
1418
|
+
var DEFAULT_BAR_GAP = 0;
|
|
1419
|
+
var PlaylistInfoContext = createContext5({
|
|
1420
|
+
sampleRate: 48e3,
|
|
1421
|
+
samplesPerPixel: 1e3,
|
|
1422
|
+
waveHeight: DEFAULT_WAVE_HEIGHT,
|
|
1423
|
+
timeScaleHeight: 15,
|
|
1424
|
+
barWidth: DEFAULT_BAR_WIDTH,
|
|
1425
|
+
barGap: DEFAULT_BAR_GAP,
|
|
1426
|
+
roundedBars: false,
|
|
1427
|
+
progressBarWidth: DEFAULT_BAR_WIDTH + DEFAULT_BAR_GAP
|
|
1428
|
+
});
|
|
1429
|
+
var usePlaylistInfo = () => use5(PlaylistInfoContext);
|
|
1430
|
+
|
|
1431
|
+
// src/contexts/Theme.tsx
|
|
1432
|
+
import { use as use6 } from "react";
|
|
1433
|
+
import { ThemeContext } from "styled-components";
|
|
1434
|
+
var useTheme2 = () => use6(ThemeContext);
|
|
1435
|
+
|
|
1436
|
+
// src/components/ClipPlaceholderBody.tsx
|
|
1437
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1438
|
+
var FALLBACK_BODY_COLOR = "grey";
|
|
1439
|
+
function colorToCss(color) {
|
|
1440
|
+
if (typeof color === "string") return color === "" ? void 0 : color;
|
|
1441
|
+
const gradient = color;
|
|
1442
|
+
if (isWaveformGradient(gradient) && Array.isArray(gradient.stops)) {
|
|
1443
|
+
return waveformColorToCss(gradient);
|
|
1444
|
+
}
|
|
1445
|
+
return void 0;
|
|
1446
|
+
}
|
|
1447
|
+
function barColor(theme, isSelected) {
|
|
1448
|
+
const selected = isSelected ? colorToCss(theme?.selectedWaveFillColor) : void 0;
|
|
1449
|
+
return selected ?? colorToCss(theme?.waveFillColor) ?? FALLBACK_BODY_COLOR;
|
|
1450
|
+
}
|
|
1451
|
+
var Body = styled13.div.attrs((props) => ({
|
|
1452
|
+
style: { background: props.$color }
|
|
1453
|
+
}))`
|
|
1454
|
+
position: absolute;
|
|
1455
|
+
top: 0;
|
|
1456
|
+
left: 0;
|
|
1457
|
+
width: 100%;
|
|
1458
|
+
height: 100%;
|
|
1459
|
+
`;
|
|
1460
|
+
var ClipPlaceholderBody = ({
|
|
1461
|
+
isSelected = false
|
|
1462
|
+
}) => {
|
|
1463
|
+
const theme = useTheme2();
|
|
1464
|
+
return /* @__PURE__ */ jsx12(Body, { $color: barColor(theme, isSelected), "data-clip-placeholder-body": "true" });
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1303
1467
|
// src/components/MasterVolumeControl.tsx
|
|
1468
|
+
import { useId as useId2 } from "react";
|
|
1304
1469
|
import styled14 from "styled-components";
|
|
1305
|
-
import { jsx as
|
|
1470
|
+
import { jsx as jsx13, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1306
1471
|
var VolumeContainer = styled14.div`
|
|
1307
1472
|
display: inline-flex;
|
|
1308
1473
|
align-items: center;
|
|
@@ -1321,12 +1486,13 @@ var MasterVolumeControl = ({
|
|
|
1321
1486
|
disabled = false,
|
|
1322
1487
|
className
|
|
1323
1488
|
}) => {
|
|
1489
|
+
const id = useId2();
|
|
1324
1490
|
const handleChange = (e) => {
|
|
1325
1491
|
onChange(parseFloat(e.target.value) / 100);
|
|
1326
1492
|
};
|
|
1327
1493
|
return /* @__PURE__ */ jsxs3(VolumeContainer, { className, children: [
|
|
1328
|
-
/* @__PURE__ */
|
|
1329
|
-
/* @__PURE__ */
|
|
1494
|
+
/* @__PURE__ */ jsx13(VolumeLabel, { htmlFor: id, children: "Master Volume" }),
|
|
1495
|
+
/* @__PURE__ */ jsx13(
|
|
1330
1496
|
VolumeSlider,
|
|
1331
1497
|
{
|
|
1332
1498
|
min: "0",
|
|
@@ -1334,17 +1500,17 @@ var MasterVolumeControl = ({
|
|
|
1334
1500
|
value: volume * 100,
|
|
1335
1501
|
onChange: handleChange,
|
|
1336
1502
|
disabled,
|
|
1337
|
-
id
|
|
1503
|
+
id
|
|
1338
1504
|
}
|
|
1339
1505
|
)
|
|
1340
1506
|
] });
|
|
1341
1507
|
};
|
|
1342
1508
|
|
|
1343
1509
|
// src/components/PianoRollChannel.tsx
|
|
1344
|
-
import { useLayoutEffect as useLayoutEffect3, useMemo as
|
|
1510
|
+
import { useLayoutEffect as useLayoutEffect3, useMemo as useMemo4 } from "react";
|
|
1345
1511
|
import styled15 from "styled-components";
|
|
1346
1512
|
import { MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH2 } from "@waveform-playlist/core";
|
|
1347
|
-
import { jsx as
|
|
1513
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1348
1514
|
var NoteCanvas = styled15.canvas.attrs((props) => ({
|
|
1349
1515
|
style: {
|
|
1350
1516
|
width: `${props.$cssWidth}px`,
|
|
@@ -1387,7 +1553,7 @@ var PianoRollChannel = ({
|
|
|
1387
1553
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
1388
1554
|
const clipOriginX = useClipViewportOrigin();
|
|
1389
1555
|
const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH2, clipOriginX);
|
|
1390
|
-
const { minMidi, maxMidi } =
|
|
1556
|
+
const { minMidi, maxMidi } = useMemo4(() => {
|
|
1391
1557
|
if (midiNotes.length === 0) return { minMidi: 0, maxMidi: 127 };
|
|
1392
1558
|
let min = 127, max = 0;
|
|
1393
1559
|
for (const note of midiNotes) {
|
|
@@ -1397,11 +1563,14 @@ var PianoRollChannel = ({
|
|
|
1397
1563
|
return { minMidi: Math.max(0, min - 1), maxMidi: Math.min(127, max + 1) };
|
|
1398
1564
|
}, [midiNotes]);
|
|
1399
1565
|
const color = isSelected ? selectedNoteColor : noteColor;
|
|
1566
|
+
const notesVersion = useIdentityVersion(midiNotes);
|
|
1567
|
+
const drawVersion = `${notesVersion}-${waveHeight}-${devicePixelRatio}-${samplesPerPixel}-${sampleRate}-${clipOffsetSeconds}-${color}-${minMidi}-${maxMidi}-${length}`;
|
|
1400
1568
|
useLayoutEffect3(() => {
|
|
1401
1569
|
const noteRange = maxMidi - minMidi + 1;
|
|
1402
1570
|
const noteHeight = Math.max(2, waveHeight / noteRange);
|
|
1403
1571
|
const pixelsPerSecond = sampleRate / samplesPerPixel;
|
|
1404
1572
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
1573
|
+
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
1405
1574
|
const chunkPixelStart = canvasIdx * MAX_CANVAS_WIDTH2;
|
|
1406
1575
|
const canvasWidth = canvas.width / devicePixelRatio;
|
|
1407
1576
|
const ctx = canvas.getContext("2d");
|
|
@@ -1428,6 +1597,7 @@ var PianoRollChannel = ({
|
|
|
1428
1597
|
ctx.fill();
|
|
1429
1598
|
}
|
|
1430
1599
|
ctx.globalAlpha = 1;
|
|
1600
|
+
canvas.dataset.drawVersion = drawVersion;
|
|
1431
1601
|
}
|
|
1432
1602
|
}, [
|
|
1433
1603
|
canvasMapRef,
|
|
@@ -1442,12 +1612,13 @@ var PianoRollChannel = ({
|
|
|
1442
1612
|
maxMidi,
|
|
1443
1613
|
length,
|
|
1444
1614
|
visibleChunkIndices,
|
|
1445
|
-
index
|
|
1615
|
+
index,
|
|
1616
|
+
drawVersion
|
|
1446
1617
|
]);
|
|
1447
1618
|
const canvases = visibleChunkIndices.map((i) => {
|
|
1448
1619
|
const chunkLeft = i * MAX_CANVAS_WIDTH2;
|
|
1449
1620
|
const currentWidth = Math.min(length - chunkLeft, MAX_CANVAS_WIDTH2);
|
|
1450
|
-
return /* @__PURE__ */
|
|
1621
|
+
return /* @__PURE__ */ jsx14(
|
|
1451
1622
|
NoteCanvas,
|
|
1452
1623
|
{
|
|
1453
1624
|
$cssWidth: currentWidth,
|
|
@@ -1462,13 +1633,23 @@ var PianoRollChannel = ({
|
|
|
1462
1633
|
);
|
|
1463
1634
|
});
|
|
1464
1635
|
const bgColor = transparentBackground ? "transparent" : backgroundColor;
|
|
1465
|
-
return /* @__PURE__ */
|
|
1636
|
+
return /* @__PURE__ */ jsx14(
|
|
1637
|
+
Wrapper2,
|
|
1638
|
+
{
|
|
1639
|
+
"data-piano-roll": "",
|
|
1640
|
+
$index: index,
|
|
1641
|
+
$cssWidth: length,
|
|
1642
|
+
$waveHeight: waveHeight,
|
|
1643
|
+
$backgroundColor: bgColor,
|
|
1644
|
+
children: canvases
|
|
1645
|
+
}
|
|
1646
|
+
);
|
|
1466
1647
|
};
|
|
1467
1648
|
|
|
1468
1649
|
// src/components/Playhead.tsx
|
|
1469
|
-
import { useRef as useRef4, useEffect as
|
|
1650
|
+
import { useRef as useRef4, useEffect as useEffect4 } from "react";
|
|
1470
1651
|
import styled16 from "styled-components";
|
|
1471
|
-
import { jsx as
|
|
1652
|
+
import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1472
1653
|
var PlayheadLine = styled16.div.attrs((props) => ({
|
|
1473
1654
|
style: {
|
|
1474
1655
|
transform: `translate3d(${props.$position}px, 0, 0)`
|
|
@@ -1485,7 +1666,7 @@ var PlayheadLine = styled16.div.attrs((props) => ({
|
|
|
1485
1666
|
will-change: transform;
|
|
1486
1667
|
`;
|
|
1487
1668
|
var Playhead = ({ position, color = "#ff0000" }) => {
|
|
1488
|
-
return /* @__PURE__ */
|
|
1669
|
+
return /* @__PURE__ */ jsx15(PlayheadLine, { $position: position, $color: color });
|
|
1489
1670
|
};
|
|
1490
1671
|
var PlayheadWithMarkerContainer = styled16.div`
|
|
1491
1672
|
position: absolute;
|
|
@@ -1519,35 +1700,16 @@ var PlayheadWithMarker = ({
|
|
|
1519
1700
|
isPlaying,
|
|
1520
1701
|
currentTimeRef,
|
|
1521
1702
|
visualTimeRef,
|
|
1522
|
-
playbackStartTimeRef,
|
|
1523
|
-
audioStartPositionRef,
|
|
1524
1703
|
samplesPerPixel,
|
|
1525
|
-
sampleRate
|
|
1526
|
-
controlsOffset = 0,
|
|
1527
|
-
getAudioContextTime,
|
|
1528
|
-
getPlaybackTime
|
|
1704
|
+
sampleRate
|
|
1529
1705
|
}) => {
|
|
1530
1706
|
const containerRef = useRef4(null);
|
|
1531
1707
|
const animationFrameRef = useRef4(null);
|
|
1532
|
-
|
|
1708
|
+
useEffect4(() => {
|
|
1533
1709
|
const updatePosition = () => {
|
|
1534
1710
|
if (containerRef.current) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
time = visualTimeRef.current;
|
|
1538
|
-
} else if (isPlaying) {
|
|
1539
|
-
if (getPlaybackTime) {
|
|
1540
|
-
time = getPlaybackTime();
|
|
1541
|
-
} else if (getAudioContextTime) {
|
|
1542
|
-
const elapsed = getAudioContextTime() - (playbackStartTimeRef.current ?? 0);
|
|
1543
|
-
time = (audioStartPositionRef.current ?? 0) + elapsed;
|
|
1544
|
-
} else {
|
|
1545
|
-
time = currentTimeRef.current ?? 0;
|
|
1546
|
-
}
|
|
1547
|
-
} else {
|
|
1548
|
-
time = currentTimeRef.current ?? 0;
|
|
1549
|
-
}
|
|
1550
|
-
const pos = time * sampleRate / samplesPerPixel + controlsOffset;
|
|
1711
|
+
const time = visualTimeRef.current ?? currentTimeRef.current ?? 0;
|
|
1712
|
+
const pos = time * sampleRate / samplesPerPixel;
|
|
1551
1713
|
containerRef.current.style.transform = `translate3d(${pos}px, 0, 0)`;
|
|
1552
1714
|
}
|
|
1553
1715
|
if (isPlaying) {
|
|
@@ -1565,35 +1727,24 @@ var PlayheadWithMarker = ({
|
|
|
1565
1727
|
animationFrameRef.current = null;
|
|
1566
1728
|
}
|
|
1567
1729
|
};
|
|
1568
|
-
}, [
|
|
1569
|
-
|
|
1570
|
-
sampleRate,
|
|
1571
|
-
samplesPerPixel,
|
|
1572
|
-
controlsOffset,
|
|
1573
|
-
currentTimeRef,
|
|
1574
|
-
visualTimeRef,
|
|
1575
|
-
playbackStartTimeRef,
|
|
1576
|
-
audioStartPositionRef,
|
|
1577
|
-
getAudioContextTime,
|
|
1578
|
-
getPlaybackTime
|
|
1579
|
-
]);
|
|
1580
|
-
useEffect3(() => {
|
|
1730
|
+
}, [isPlaying, sampleRate, samplesPerPixel, currentTimeRef, visualTimeRef]);
|
|
1731
|
+
useEffect4(() => {
|
|
1581
1732
|
if (!isPlaying && containerRef.current) {
|
|
1582
|
-
const time = visualTimeRef
|
|
1583
|
-
const pos = time * sampleRate / samplesPerPixel
|
|
1733
|
+
const time = visualTimeRef.current ?? currentTimeRef.current ?? 0;
|
|
1734
|
+
const pos = time * sampleRate / samplesPerPixel;
|
|
1584
1735
|
containerRef.current.style.transform = `translate3d(${pos}px, 0, 0)`;
|
|
1585
1736
|
}
|
|
1586
1737
|
});
|
|
1587
1738
|
return /* @__PURE__ */ jsxs4(PlayheadWithMarkerContainer, { ref: containerRef, $color: color, children: [
|
|
1588
|
-
/* @__PURE__ */
|
|
1589
|
-
/* @__PURE__ */
|
|
1739
|
+
/* @__PURE__ */ jsx15(MarkerTriangle, { $color: color }),
|
|
1740
|
+
/* @__PURE__ */ jsx15(MarkerLine, { $color: color })
|
|
1590
1741
|
] });
|
|
1591
1742
|
};
|
|
1592
1743
|
|
|
1593
1744
|
// src/components/Playlist.tsx
|
|
1594
1745
|
import styled17, { withTheme } from "styled-components";
|
|
1595
1746
|
import { useRef as useRef5, useCallback as useCallback3 } from "react";
|
|
1596
|
-
import { jsx as
|
|
1747
|
+
import { jsx as jsx16, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1597
1748
|
var Wrapper3 = styled17.div`
|
|
1598
1749
|
display: flex;
|
|
1599
1750
|
overflow-y: hidden;
|
|
@@ -1662,7 +1813,8 @@ var Playlist = ({
|
|
|
1662
1813
|
isSelecting,
|
|
1663
1814
|
"data-playlist-state": playlistState,
|
|
1664
1815
|
trackControlsSlots,
|
|
1665
|
-
timescaleGapHeight = 0
|
|
1816
|
+
timescaleGapHeight = 0,
|
|
1817
|
+
className
|
|
1666
1818
|
}) => {
|
|
1667
1819
|
const scrollAreaRef = useRef5(null);
|
|
1668
1820
|
const handleRef = useCallback3(
|
|
@@ -1673,16 +1825,16 @@ var Playlist = ({
|
|
|
1673
1825
|
[scrollContainerRef]
|
|
1674
1826
|
);
|
|
1675
1827
|
const showControls = controlsWidth !== void 0 && controlsWidth > 0;
|
|
1676
|
-
return /* @__PURE__ */ jsxs5(Wrapper3, { "data-playlist-state": playlistState, children: [
|
|
1828
|
+
return /* @__PURE__ */ jsxs5(Wrapper3, { className, "data-playlist-state": playlistState, children: [
|
|
1677
1829
|
showControls && /* @__PURE__ */ jsxs5(ControlsColumn, { $width: controlsWidth, children: [
|
|
1678
|
-
timescaleGapHeight > 0 && /* @__PURE__ */
|
|
1830
|
+
timescaleGapHeight > 0 && /* @__PURE__ */ jsx16(TimescaleGap, { $height: timescaleGapHeight }),
|
|
1679
1831
|
trackControlsSlots
|
|
1680
1832
|
] }),
|
|
1681
|
-
/* @__PURE__ */
|
|
1682
|
-
timescale && /* @__PURE__ */
|
|
1833
|
+
/* @__PURE__ */ jsx16(ScrollArea, { "data-scroll-container": "true", ref: handleRef, children: /* @__PURE__ */ jsx16(ScrollViewportProvider, { containerRef: scrollAreaRef, children: /* @__PURE__ */ jsxs5(ScrollContainerInner, { $backgroundColor: backgroundColor, $width: tracksWidth, children: [
|
|
1834
|
+
timescale && /* @__PURE__ */ jsx16(TimescaleWrapper, { $width: timescaleWidth, $backgroundColor: timescaleBackgroundColor, children: timescale }),
|
|
1683
1835
|
/* @__PURE__ */ jsxs5(TracksContainer, { $width: tracksWidth, $backgroundColor: backgroundColor, children: [
|
|
1684
1836
|
children,
|
|
1685
|
-
(onTracksClick || onTracksMouseDown) && /* @__PURE__ */
|
|
1837
|
+
(onTracksClick || onTracksMouseDown) && /* @__PURE__ */ jsx16(
|
|
1686
1838
|
ClickOverlay,
|
|
1687
1839
|
{
|
|
1688
1840
|
$isSelecting: isSelecting,
|
|
@@ -1700,7 +1852,7 @@ var StyledPlaylist = withTheme(Playlist);
|
|
|
1700
1852
|
|
|
1701
1853
|
// src/components/Selection.tsx
|
|
1702
1854
|
import styled18 from "styled-components";
|
|
1703
|
-
import { jsx as
|
|
1855
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1704
1856
|
var SelectionOverlay = styled18.div.attrs((props) => ({
|
|
1705
1857
|
style: {
|
|
1706
1858
|
left: `${props.$left}px`,
|
|
@@ -1724,13 +1876,13 @@ var Selection = ({
|
|
|
1724
1876
|
if (width <= 0) {
|
|
1725
1877
|
return null;
|
|
1726
1878
|
}
|
|
1727
|
-
return /* @__PURE__ */
|
|
1879
|
+
return /* @__PURE__ */ jsx17(SelectionOverlay, { $left: startPosition, $width: width, $color: color, "data-selection": true });
|
|
1728
1880
|
};
|
|
1729
1881
|
|
|
1730
1882
|
// src/components/LoopRegion.tsx
|
|
1731
|
-
import { useCallback as useCallback4, useRef as useRef6, useState } from "react";
|
|
1883
|
+
import { useCallback as useCallback4, useRef as useRef6, useState as useState2 } from "react";
|
|
1732
1884
|
import styled19 from "styled-components";
|
|
1733
|
-
import { Fragment as Fragment2, jsx as
|
|
1885
|
+
import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1734
1886
|
var LoopRegionOverlayDiv = styled19.div.attrs((props) => ({
|
|
1735
1887
|
style: {
|
|
1736
1888
|
left: `${props.$left}px`,
|
|
@@ -1780,7 +1932,7 @@ var LoopRegion = ({
|
|
|
1780
1932
|
return null;
|
|
1781
1933
|
}
|
|
1782
1934
|
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1783
|
-
/* @__PURE__ */
|
|
1935
|
+
/* @__PURE__ */ jsx18(
|
|
1784
1936
|
LoopRegionOverlayDiv,
|
|
1785
1937
|
{
|
|
1786
1938
|
$left: startPosition,
|
|
@@ -1789,7 +1941,7 @@ var LoopRegion = ({
|
|
|
1789
1941
|
"data-loop-region": true
|
|
1790
1942
|
}
|
|
1791
1943
|
),
|
|
1792
|
-
/* @__PURE__ */
|
|
1944
|
+
/* @__PURE__ */ jsx18(
|
|
1793
1945
|
LoopMarker,
|
|
1794
1946
|
{
|
|
1795
1947
|
$left: startPosition,
|
|
@@ -1798,7 +1950,7 @@ var LoopRegion = ({
|
|
|
1798
1950
|
"data-loop-marker": "start"
|
|
1799
1951
|
}
|
|
1800
1952
|
),
|
|
1801
|
-
/* @__PURE__ */
|
|
1953
|
+
/* @__PURE__ */ jsx18(
|
|
1802
1954
|
LoopMarker,
|
|
1803
1955
|
{
|
|
1804
1956
|
$left: endPosition - 2,
|
|
@@ -1879,7 +2031,7 @@ var LoopRegionMarkers = ({
|
|
|
1879
2031
|
minPosition = 0,
|
|
1880
2032
|
maxPosition = Infinity
|
|
1881
2033
|
}) => {
|
|
1882
|
-
const [draggingMarker, setDraggingMarker] =
|
|
2034
|
+
const [draggingMarker, setDraggingMarker] = useState2(null);
|
|
1883
2035
|
const dragStartX = useRef6(0);
|
|
1884
2036
|
const dragStartPosition = useRef6(0);
|
|
1885
2037
|
const dragStartEnd = useRef6(0);
|
|
@@ -1949,7 +2101,7 @@ var LoopRegionMarkers = ({
|
|
|
1949
2101
|
return null;
|
|
1950
2102
|
}
|
|
1951
2103
|
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
1952
|
-
/* @__PURE__ */
|
|
2104
|
+
/* @__PURE__ */ jsx18(
|
|
1953
2105
|
TimescaleLoopShade,
|
|
1954
2106
|
{
|
|
1955
2107
|
$left: startPosition,
|
|
@@ -1960,7 +2112,7 @@ var LoopRegionMarkers = ({
|
|
|
1960
2112
|
"data-loop-region-timescale": true
|
|
1961
2113
|
}
|
|
1962
2114
|
),
|
|
1963
|
-
/* @__PURE__ */
|
|
2115
|
+
/* @__PURE__ */ jsx18(
|
|
1964
2116
|
DraggableMarkerHandle,
|
|
1965
2117
|
{
|
|
1966
2118
|
$left: startPosition,
|
|
@@ -1971,7 +2123,7 @@ var LoopRegionMarkers = ({
|
|
|
1971
2123
|
"data-loop-marker-handle": "start"
|
|
1972
2124
|
}
|
|
1973
2125
|
),
|
|
1974
|
-
/* @__PURE__ */
|
|
2126
|
+
/* @__PURE__ */ jsx18(
|
|
1975
2127
|
DraggableMarkerHandle,
|
|
1976
2128
|
{
|
|
1977
2129
|
$left: endPosition,
|
|
@@ -2002,7 +2154,7 @@ var TimescaleLoopRegion = ({
|
|
|
2002
2154
|
minPosition = 0,
|
|
2003
2155
|
maxPosition = Infinity
|
|
2004
2156
|
}) => {
|
|
2005
|
-
const [, setIsCreating] =
|
|
2157
|
+
const [, setIsCreating] = useState2(false);
|
|
2006
2158
|
const createStartX = useRef6(0);
|
|
2007
2159
|
const containerRef = useRef6(null);
|
|
2008
2160
|
const hasLoopRegion = endPosition > startPosition;
|
|
@@ -2037,13 +2189,13 @@ var TimescaleLoopRegion = ({
|
|
|
2037
2189
|
},
|
|
2038
2190
|
[minPosition, maxPosition, onLoopRegionChange]
|
|
2039
2191
|
);
|
|
2040
|
-
return /* @__PURE__ */
|
|
2192
|
+
return /* @__PURE__ */ jsx18(
|
|
2041
2193
|
TimescaleLoopCreator,
|
|
2042
2194
|
{
|
|
2043
2195
|
ref: containerRef,
|
|
2044
2196
|
onMouseDown: handleBackgroundMouseDown,
|
|
2045
2197
|
"data-timescale-loop-creator": true,
|
|
2046
|
-
children: hasLoopRegion && /* @__PURE__ */
|
|
2198
|
+
children: hasLoopRegion && /* @__PURE__ */ jsx18(
|
|
2047
2199
|
LoopRegionMarkers,
|
|
2048
2200
|
{
|
|
2049
2201
|
startPosition,
|
|
@@ -2062,10 +2214,10 @@ var TimescaleLoopRegion = ({
|
|
|
2062
2214
|
};
|
|
2063
2215
|
|
|
2064
2216
|
// src/components/SelectionTimeInputs.tsx
|
|
2065
|
-
import {
|
|
2217
|
+
import { useId as useId3 } from "react";
|
|
2066
2218
|
|
|
2067
2219
|
// src/components/TimeInput.tsx
|
|
2068
|
-
import {
|
|
2220
|
+
import { useState as useState3 } from "react";
|
|
2069
2221
|
|
|
2070
2222
|
// src/utils/timeFormat.ts
|
|
2071
2223
|
function clockFormat(seconds, decimals) {
|
|
@@ -2115,31 +2267,27 @@ function parseTime(timeStr, format) {
|
|
|
2115
2267
|
}
|
|
2116
2268
|
|
|
2117
2269
|
// src/components/TimeInput.tsx
|
|
2118
|
-
import { Fragment as Fragment3, jsx as
|
|
2270
|
+
import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2119
2271
|
var TimeInput = ({
|
|
2120
2272
|
id,
|
|
2121
|
-
label,
|
|
2273
|
+
label: label2,
|
|
2122
2274
|
value,
|
|
2123
2275
|
format,
|
|
2124
2276
|
className,
|
|
2125
2277
|
onChange,
|
|
2126
2278
|
readOnly = false
|
|
2127
2279
|
}) => {
|
|
2128
|
-
const [
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
setDisplayValue(formatted);
|
|
2132
|
-
}, [value, format, id]);
|
|
2280
|
+
const [draft, setDraft] = useState3(null);
|
|
2281
|
+
const activeDraft = draft?.format === format ? draft : null;
|
|
2282
|
+
const displayValue = activeDraft?.text ?? formatTime(value, format);
|
|
2133
2283
|
const handleChange = (e) => {
|
|
2134
|
-
|
|
2135
|
-
setDisplayValue(newDisplayValue);
|
|
2284
|
+
setDraft({ text: e.target.value, format });
|
|
2136
2285
|
};
|
|
2137
2286
|
const handleBlur = () => {
|
|
2138
|
-
if (
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
setDisplayValue(formatTime(value, format));
|
|
2287
|
+
if (draft === null) return;
|
|
2288
|
+
setDraft(null);
|
|
2289
|
+
if (activeDraft === null) return;
|
|
2290
|
+
onChange?.(parseTime(activeDraft.text, format));
|
|
2143
2291
|
};
|
|
2144
2292
|
const handleKeyDown = (e) => {
|
|
2145
2293
|
if (e.key === "Enter") {
|
|
@@ -2147,8 +2295,8 @@ var TimeInput = ({
|
|
|
2147
2295
|
}
|
|
2148
2296
|
};
|
|
2149
2297
|
return /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
2150
|
-
/* @__PURE__ */
|
|
2151
|
-
/* @__PURE__ */
|
|
2298
|
+
/* @__PURE__ */ jsx19(ScreenReaderOnly, { as: "label", htmlFor: id, children: label2 }),
|
|
2299
|
+
/* @__PURE__ */ jsx19(
|
|
2152
2300
|
BaseInput,
|
|
2153
2301
|
{
|
|
2154
2302
|
type: "text",
|
|
@@ -2165,29 +2313,15 @@ var TimeInput = ({
|
|
|
2165
2313
|
};
|
|
2166
2314
|
|
|
2167
2315
|
// src/components/SelectionTimeInputs.tsx
|
|
2168
|
-
import { jsx as
|
|
2316
|
+
import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2169
2317
|
var SelectionTimeInputs = ({
|
|
2170
2318
|
selectionStart,
|
|
2171
2319
|
selectionEnd,
|
|
2172
2320
|
onSelectionChange,
|
|
2321
|
+
format = "hh:mm:ss.uuu",
|
|
2173
2322
|
className
|
|
2174
2323
|
}) => {
|
|
2175
|
-
const
|
|
2176
|
-
useEffect5(() => {
|
|
2177
|
-
const timeFormatSelect = document.querySelector(".time-format");
|
|
2178
|
-
const handleFormatChange = () => {
|
|
2179
|
-
if (timeFormatSelect) {
|
|
2180
|
-
setTimeFormat(timeFormatSelect.value);
|
|
2181
|
-
}
|
|
2182
|
-
};
|
|
2183
|
-
if (timeFormatSelect) {
|
|
2184
|
-
setTimeFormat(timeFormatSelect.value);
|
|
2185
|
-
timeFormatSelect.addEventListener("change", handleFormatChange);
|
|
2186
|
-
}
|
|
2187
|
-
return () => {
|
|
2188
|
-
timeFormatSelect?.removeEventListener("change", handleFormatChange);
|
|
2189
|
-
};
|
|
2190
|
-
}, []);
|
|
2324
|
+
const id = useId3();
|
|
2191
2325
|
const handleStartChange = (value) => {
|
|
2192
2326
|
if (onSelectionChange) {
|
|
2193
2327
|
onSelectionChange(value, selectionEnd);
|
|
@@ -2199,24 +2333,24 @@ var SelectionTimeInputs = ({
|
|
|
2199
2333
|
}
|
|
2200
2334
|
};
|
|
2201
2335
|
return /* @__PURE__ */ jsxs8("div", { className, children: [
|
|
2202
|
-
/* @__PURE__ */
|
|
2336
|
+
/* @__PURE__ */ jsx20(
|
|
2203
2337
|
TimeInput,
|
|
2204
2338
|
{
|
|
2205
|
-
id:
|
|
2339
|
+
id: `${id}-start`,
|
|
2206
2340
|
label: "Start of audio selection",
|
|
2207
2341
|
value: selectionStart,
|
|
2208
|
-
format
|
|
2342
|
+
format,
|
|
2209
2343
|
className: "audio-start form-control mr-sm-2",
|
|
2210
2344
|
onChange: handleStartChange
|
|
2211
2345
|
}
|
|
2212
2346
|
),
|
|
2213
|
-
/* @__PURE__ */
|
|
2347
|
+
/* @__PURE__ */ jsx20(
|
|
2214
2348
|
TimeInput,
|
|
2215
2349
|
{
|
|
2216
|
-
id:
|
|
2350
|
+
id: `${id}-end`,
|
|
2217
2351
|
label: "End of audio selection",
|
|
2218
2352
|
value: selectionEnd,
|
|
2219
|
-
format
|
|
2353
|
+
format,
|
|
2220
2354
|
className: "audio-end form-control mr-sm-2",
|
|
2221
2355
|
onChange: handleEndChange
|
|
2222
2356
|
}
|
|
@@ -2224,137 +2358,15 @@ var SelectionTimeInputs = ({
|
|
|
2224
2358
|
] });
|
|
2225
2359
|
};
|
|
2226
2360
|
|
|
2227
|
-
// src/contexts/BeatsAndBars.tsx
|
|
2228
|
-
import { createContext as createContext3, useContext as useContext3, useMemo as useMemo3 } from "react";
|
|
2229
|
-
import { ticksPerBeat, ticksPerBar } from "@waveform-playlist/core";
|
|
2230
|
-
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2231
|
-
var BeatsAndBarsContext = createContext3(null);
|
|
2232
|
-
function BeatsAndBarsProvider({
|
|
2233
|
-
bpm,
|
|
2234
|
-
timeSignature,
|
|
2235
|
-
snapTo,
|
|
2236
|
-
scaleMode = "beats",
|
|
2237
|
-
children
|
|
2238
|
-
}) {
|
|
2239
|
-
const [numerator, denominator] = timeSignature;
|
|
2240
|
-
const value = useMemo3(() => {
|
|
2241
|
-
const ts = [numerator, denominator];
|
|
2242
|
-
const tpBeat = ticksPerBeat(ts);
|
|
2243
|
-
const tpBar = ticksPerBar(ts);
|
|
2244
|
-
return {
|
|
2245
|
-
bpm,
|
|
2246
|
-
timeSignature: ts,
|
|
2247
|
-
snapTo,
|
|
2248
|
-
scaleMode,
|
|
2249
|
-
ticksPerBeat: tpBeat,
|
|
2250
|
-
ticksPerBar: tpBar
|
|
2251
|
-
};
|
|
2252
|
-
}, [bpm, numerator, denominator, snapTo, scaleMode]);
|
|
2253
|
-
return /* @__PURE__ */ jsx19(BeatsAndBarsContext.Provider, { value, children });
|
|
2254
|
-
}
|
|
2255
|
-
function useBeatsAndBars() {
|
|
2256
|
-
return useContext3(BeatsAndBarsContext);
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
// src/contexts/DevicePixelRatio.tsx
|
|
2260
|
-
import { useState as useState4, createContext as createContext4, useContext as useContext4 } from "react";
|
|
2261
|
-
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2262
|
-
function getScale() {
|
|
2263
|
-
return window.devicePixelRatio;
|
|
2264
|
-
}
|
|
2265
|
-
var DevicePixelRatioContext = createContext4(getScale());
|
|
2266
|
-
var DevicePixelRatioProvider = ({ children }) => {
|
|
2267
|
-
const [scale, setScale] = useState4(getScale());
|
|
2268
|
-
matchMedia(`(resolution: ${getScale()}dppx)`).addEventListener(
|
|
2269
|
-
"change",
|
|
2270
|
-
() => {
|
|
2271
|
-
setScale(getScale());
|
|
2272
|
-
},
|
|
2273
|
-
{ once: true }
|
|
2274
|
-
);
|
|
2275
|
-
return /* @__PURE__ */ jsx20(DevicePixelRatioContext.Provider, { value: Math.ceil(scale), children });
|
|
2276
|
-
};
|
|
2277
|
-
var useDevicePixelRatio = () => useContext4(DevicePixelRatioContext);
|
|
2278
|
-
|
|
2279
|
-
// src/contexts/PlaylistInfo.tsx
|
|
2280
|
-
import { createContext as createContext5, useContext as useContext5 } from "react";
|
|
2281
|
-
var PlaylistInfoContext = createContext5({
|
|
2282
|
-
sampleRate: 48e3,
|
|
2283
|
-
samplesPerPixel: 1e3,
|
|
2284
|
-
zoomLevels: [1e3, 1500, 2e3, 2500],
|
|
2285
|
-
waveHeight: 80,
|
|
2286
|
-
timeScaleHeight: 15,
|
|
2287
|
-
controls: {
|
|
2288
|
-
show: false,
|
|
2289
|
-
width: 150
|
|
2290
|
-
},
|
|
2291
|
-
duration: 3e4,
|
|
2292
|
-
barWidth: 1,
|
|
2293
|
-
barGap: 0,
|
|
2294
|
-
roundedBars: false
|
|
2295
|
-
});
|
|
2296
|
-
var usePlaylistInfo = () => useContext5(PlaylistInfoContext);
|
|
2297
|
-
|
|
2298
|
-
// src/contexts/Theme.tsx
|
|
2299
|
-
import { useContext as useContext6 } from "react";
|
|
2300
|
-
import { ThemeContext } from "styled-components";
|
|
2301
|
-
var useTheme2 = () => useContext6(ThemeContext);
|
|
2302
|
-
|
|
2303
|
-
// src/contexts/TrackControls.tsx
|
|
2304
|
-
import { createContext as createContext6, useContext as useContext7, Fragment as Fragment4 } from "react";
|
|
2305
|
-
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2306
|
-
var TrackControlsContext = createContext6(/* @__PURE__ */ jsx21(Fragment4, {}));
|
|
2307
|
-
var useTrackControls = () => useContext7(TrackControlsContext);
|
|
2308
|
-
|
|
2309
|
-
// src/contexts/Playout.tsx
|
|
2310
|
-
import {
|
|
2311
|
-
useState as useState5,
|
|
2312
|
-
createContext as createContext7,
|
|
2313
|
-
useContext as useContext8
|
|
2314
|
-
} from "react";
|
|
2315
|
-
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
2316
|
-
var defaultProgress = 0;
|
|
2317
|
-
var defaultIsPlaying = false;
|
|
2318
|
-
var defaultSelectionStart = 0;
|
|
2319
|
-
var defaultSelectionEnd = 0;
|
|
2320
|
-
var defaultPlayout = {
|
|
2321
|
-
progress: defaultProgress,
|
|
2322
|
-
isPlaying: defaultIsPlaying,
|
|
2323
|
-
selectionStart: defaultSelectionStart,
|
|
2324
|
-
selectionEnd: defaultSelectionEnd
|
|
2325
|
-
};
|
|
2326
|
-
var PlayoutStatusContext = createContext7(defaultPlayout);
|
|
2327
|
-
var PlayoutStatusUpdateContext = createContext7({
|
|
2328
|
-
setIsPlaying: () => {
|
|
2329
|
-
},
|
|
2330
|
-
setProgress: () => {
|
|
2331
|
-
},
|
|
2332
|
-
setSelection: () => {
|
|
2333
|
-
}
|
|
2334
|
-
});
|
|
2335
|
-
var PlayoutProvider = ({ children }) => {
|
|
2336
|
-
const [isPlaying, setIsPlaying] = useState5(defaultIsPlaying);
|
|
2337
|
-
const [progress, setProgress] = useState5(defaultProgress);
|
|
2338
|
-
const [selectionStart, setSelectionStart] = useState5(defaultSelectionStart);
|
|
2339
|
-
const [selectionEnd, setSelectionEnd] = useState5(defaultSelectionEnd);
|
|
2340
|
-
const setSelection = (start, end) => {
|
|
2341
|
-
setSelectionStart(start);
|
|
2342
|
-
setSelectionEnd(end);
|
|
2343
|
-
};
|
|
2344
|
-
return /* @__PURE__ */ jsx22(PlayoutStatusUpdateContext.Provider, { value: { setIsPlaying, setProgress, setSelection }, children: /* @__PURE__ */ jsx22(PlayoutStatusContext.Provider, { value: { isPlaying, progress, selectionStart, selectionEnd }, children }) });
|
|
2345
|
-
};
|
|
2346
|
-
var usePlayoutStatus = () => useContext8(PlayoutStatusContext);
|
|
2347
|
-
var usePlayoutStatusUpdate = () => useContext8(PlayoutStatusUpdateContext);
|
|
2348
|
-
|
|
2349
2361
|
// src/components/SpectrogramChannel.tsx
|
|
2350
|
-
import { useRef as useRef7, useEffect as
|
|
2362
|
+
import { useRef as useRef7, useEffect as useEffect5 } from "react";
|
|
2351
2363
|
import styled20 from "styled-components";
|
|
2352
2364
|
import {
|
|
2353
2365
|
MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH3,
|
|
2354
2366
|
buildSpectrogramCanvasId,
|
|
2355
2367
|
parseSpectrogramCanvasId
|
|
2356
2368
|
} from "@waveform-playlist/core";
|
|
2357
|
-
import { jsx as
|
|
2369
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2358
2370
|
var Wrapper4 = styled20.div.attrs((props) => ({
|
|
2359
2371
|
style: {
|
|
2360
2372
|
top: `${props.$waveHeight * props.$index}px`,
|
|
@@ -2363,7 +2375,8 @@ var Wrapper4 = styled20.div.attrs((props) => ({
|
|
|
2363
2375
|
}
|
|
2364
2376
|
}))`
|
|
2365
2377
|
position: absolute;
|
|
2366
|
-
|
|
2378
|
+
/* Shown until the worker has drawn, and where a chunk is not mounted. */
|
|
2379
|
+
background: ${(props) => props.theme?.spectrogramBackgroundColor ?? "#000"};
|
|
2367
2380
|
transform: translateZ(0);
|
|
2368
2381
|
backface-visibility: hidden;
|
|
2369
2382
|
`;
|
|
@@ -2388,7 +2401,9 @@ var SpectrogramChannel = ({
|
|
|
2388
2401
|
samplesPerPixel: _samplesPerPixel,
|
|
2389
2402
|
clipId,
|
|
2390
2403
|
onCanvasRegister,
|
|
2391
|
-
onCanvasUnregister
|
|
2404
|
+
onCanvasUnregister,
|
|
2405
|
+
offsetSamples,
|
|
2406
|
+
durationSamples
|
|
2392
2407
|
}) => {
|
|
2393
2408
|
const channelIndex = channelIndexProp ?? index;
|
|
2394
2409
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
@@ -2398,13 +2413,13 @@ var SpectrogramChannel = ({
|
|
|
2398
2413
|
const onCanvasUnregisterRef = useRef7(onCanvasUnregister);
|
|
2399
2414
|
const clipOriginX = useClipViewportOrigin();
|
|
2400
2415
|
const visibleChunkIndices = useVisibleChunkIndices(length, MAX_CANVAS_WIDTH3, clipOriginX);
|
|
2401
|
-
|
|
2416
|
+
useEffect5(() => {
|
|
2402
2417
|
onCanvasRegisterRef.current = onCanvasRegister;
|
|
2403
2418
|
}, [onCanvasRegister]);
|
|
2404
|
-
|
|
2419
|
+
useEffect5(() => {
|
|
2405
2420
|
onCanvasUnregisterRef.current = onCanvasUnregister;
|
|
2406
2421
|
}, [onCanvasUnregister]);
|
|
2407
|
-
|
|
2422
|
+
useEffect5(() => {
|
|
2408
2423
|
if (!clipId) return;
|
|
2409
2424
|
const unregister = onCanvasUnregisterRef.current;
|
|
2410
2425
|
const register = onCanvasRegisterRef.current;
|
|
@@ -2448,15 +2463,26 @@ var SpectrogramChannel = ({
|
|
|
2448
2463
|
channelIndex,
|
|
2449
2464
|
chunkIndex: canvasIdx,
|
|
2450
2465
|
widthPx,
|
|
2451
|
-
heightPx: waveHeight
|
|
2466
|
+
heightPx: waveHeight,
|
|
2467
|
+
...offsetSamples !== void 0 ? { offsetSamples } : {},
|
|
2468
|
+
...durationSamples !== void 0 ? { durationSamples } : {}
|
|
2452
2469
|
});
|
|
2453
2470
|
registeredIdsRef.current.push(canvasId);
|
|
2454
2471
|
} catch (err) {
|
|
2455
2472
|
console.warn(`[spectrogram] register failed for ${canvasId}:`, err);
|
|
2456
2473
|
}
|
|
2457
2474
|
}
|
|
2458
|
-
}, [
|
|
2459
|
-
|
|
2475
|
+
}, [
|
|
2476
|
+
canvasMapRef,
|
|
2477
|
+
clipId,
|
|
2478
|
+
channelIndex,
|
|
2479
|
+
length,
|
|
2480
|
+
waveHeight,
|
|
2481
|
+
offsetSamples,
|
|
2482
|
+
durationSamples,
|
|
2483
|
+
visibleChunkIndices
|
|
2484
|
+
]);
|
|
2485
|
+
useEffect5(() => {
|
|
2460
2486
|
return () => {
|
|
2461
2487
|
const unregister = onCanvasUnregisterRef.current;
|
|
2462
2488
|
for (const id of registeredIdsRef.current) {
|
|
@@ -2472,7 +2498,7 @@ var SpectrogramChannel = ({
|
|
|
2472
2498
|
const canvases = visibleChunkIndices.map((i) => {
|
|
2473
2499
|
const chunkLeft = i * MAX_CANVAS_WIDTH3;
|
|
2474
2500
|
const currentWidth = Math.min(length - chunkLeft, MAX_CANVAS_WIDTH3);
|
|
2475
|
-
return /* @__PURE__ */
|
|
2501
|
+
return /* @__PURE__ */ jsx21(
|
|
2476
2502
|
SpectrogramCanvas,
|
|
2477
2503
|
{
|
|
2478
2504
|
$cssWidth: currentWidth,
|
|
@@ -2483,14 +2509,14 @@ var SpectrogramChannel = ({
|
|
|
2483
2509
|
"data-index": i,
|
|
2484
2510
|
ref: canvasRef
|
|
2485
2511
|
},
|
|
2486
|
-
`${length}-${i}`
|
|
2512
|
+
`${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2487
2513
|
);
|
|
2488
2514
|
});
|
|
2489
|
-
return /* @__PURE__ */
|
|
2515
|
+
return /* @__PURE__ */ jsx21(Wrapper4, { $index: index, $cssWidth: length, $waveHeight: waveHeight, children: canvases });
|
|
2490
2516
|
};
|
|
2491
2517
|
|
|
2492
2518
|
// src/components/SmartChannel.tsx
|
|
2493
|
-
import { Fragment as
|
|
2519
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2494
2520
|
var SmartChannel = ({
|
|
2495
2521
|
isSelected,
|
|
2496
2522
|
transparentBackground,
|
|
@@ -2499,6 +2525,8 @@ var SmartChannel = ({
|
|
|
2499
2525
|
spectrogramClipId,
|
|
2500
2526
|
spectrogramOnCanvasRegister,
|
|
2501
2527
|
spectrogramOnCanvasUnregister,
|
|
2528
|
+
spectrogramOffsetSamples,
|
|
2529
|
+
spectrogramDurationSamples,
|
|
2502
2530
|
midiNotes,
|
|
2503
2531
|
sampleRate: sampleRateProp,
|
|
2504
2532
|
clipOffsetSeconds,
|
|
@@ -2518,9 +2546,29 @@ var SmartChannel = ({
|
|
|
2518
2546
|
const waveOutlineColor = isSelected && theme ? theme.selectedWaveOutlineColor : theme?.waveOutlineColor;
|
|
2519
2547
|
const waveFillColor = isSelected && theme ? theme.selectedWaveFillColor : theme?.waveFillColor;
|
|
2520
2548
|
const drawMode = theme?.waveformDrawMode || "inverted";
|
|
2549
|
+
if (midiNotes != null) {
|
|
2550
|
+
return /* @__PURE__ */ jsx22(
|
|
2551
|
+
PianoRollChannel,
|
|
2552
|
+
{
|
|
2553
|
+
index: props.index,
|
|
2554
|
+
midiNotes,
|
|
2555
|
+
length: props.length,
|
|
2556
|
+
waveHeight,
|
|
2557
|
+
devicePixelRatio,
|
|
2558
|
+
samplesPerPixel,
|
|
2559
|
+
sampleRate: sampleRateProp ?? contextSampleRate,
|
|
2560
|
+
clipOffsetSeconds: clipOffsetSeconds ?? 0,
|
|
2561
|
+
noteColor: theme?.pianoRollNoteColor,
|
|
2562
|
+
selectedNoteColor: theme?.pianoRollSelectedNoteColor,
|
|
2563
|
+
isSelected,
|
|
2564
|
+
transparentBackground,
|
|
2565
|
+
backgroundColor: theme?.pianoRollBackgroundColor
|
|
2566
|
+
}
|
|
2567
|
+
);
|
|
2568
|
+
}
|
|
2521
2569
|
const hasSpectrogram = spectrogramClipId && spectrogramOnCanvasRegister && spectrogramOnCanvasUnregister;
|
|
2522
2570
|
if (renderMode === "spectrogram" && hasSpectrogram) {
|
|
2523
|
-
return /* @__PURE__ */
|
|
2571
|
+
return /* @__PURE__ */ jsx22(
|
|
2524
2572
|
SpectrogramChannel,
|
|
2525
2573
|
{
|
|
2526
2574
|
index: props.index,
|
|
@@ -2530,14 +2578,16 @@ var SmartChannel = ({
|
|
|
2530
2578
|
samplesPerPixel,
|
|
2531
2579
|
clipId: spectrogramClipId,
|
|
2532
2580
|
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2533
|
-
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2581
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister,
|
|
2582
|
+
offsetSamples: spectrogramOffsetSamples,
|
|
2583
|
+
durationSamples: spectrogramDurationSamples
|
|
2534
2584
|
}
|
|
2535
2585
|
);
|
|
2536
2586
|
}
|
|
2537
2587
|
if (renderMode === "both" && hasSpectrogram) {
|
|
2538
2588
|
const halfHeight = Math.floor(waveHeight / 2);
|
|
2539
|
-
return /* @__PURE__ */ jsxs9(
|
|
2540
|
-
/* @__PURE__ */
|
|
2589
|
+
return /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
2590
|
+
/* @__PURE__ */ jsx22(
|
|
2541
2591
|
SpectrogramChannel,
|
|
2542
2592
|
{
|
|
2543
2593
|
index: props.index * 2,
|
|
@@ -2548,10 +2598,12 @@ var SmartChannel = ({
|
|
|
2548
2598
|
samplesPerPixel,
|
|
2549
2599
|
clipId: spectrogramClipId,
|
|
2550
2600
|
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2551
|
-
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2601
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister,
|
|
2602
|
+
offsetSamples: spectrogramOffsetSamples,
|
|
2603
|
+
durationSamples: spectrogramDurationSamples
|
|
2552
2604
|
}
|
|
2553
2605
|
),
|
|
2554
|
-
/* @__PURE__ */
|
|
2606
|
+
/* @__PURE__ */ jsx22(
|
|
2555
2607
|
"div",
|
|
2556
2608
|
{
|
|
2557
2609
|
style: {
|
|
@@ -2560,7 +2612,7 @@ var SmartChannel = ({
|
|
|
2560
2612
|
width: props.length,
|
|
2561
2613
|
height: halfHeight
|
|
2562
2614
|
},
|
|
2563
|
-
children: /* @__PURE__ */
|
|
2615
|
+
children: /* @__PURE__ */ jsx22(
|
|
2564
2616
|
Channel,
|
|
2565
2617
|
{
|
|
2566
2618
|
...props,
|
|
@@ -2580,27 +2632,7 @@ var SmartChannel = ({
|
|
|
2580
2632
|
)
|
|
2581
2633
|
] });
|
|
2582
2634
|
}
|
|
2583
|
-
|
|
2584
|
-
return /* @__PURE__ */ jsx24(
|
|
2585
|
-
PianoRollChannel,
|
|
2586
|
-
{
|
|
2587
|
-
index: props.index,
|
|
2588
|
-
midiNotes: midiNotes ?? [],
|
|
2589
|
-
length: props.length,
|
|
2590
|
-
waveHeight,
|
|
2591
|
-
devicePixelRatio,
|
|
2592
|
-
samplesPerPixel,
|
|
2593
|
-
sampleRate: sampleRateProp ?? contextSampleRate,
|
|
2594
|
-
clipOffsetSeconds: clipOffsetSeconds ?? 0,
|
|
2595
|
-
noteColor: theme?.pianoRollNoteColor,
|
|
2596
|
-
selectedNoteColor: theme?.pianoRollSelectedNoteColor,
|
|
2597
|
-
isSelected,
|
|
2598
|
-
transparentBackground,
|
|
2599
|
-
backgroundColor: theme?.pianoRollBackgroundColor
|
|
2600
|
-
}
|
|
2601
|
-
);
|
|
2602
|
-
}
|
|
2603
|
-
return /* @__PURE__ */ jsx24(
|
|
2635
|
+
return /* @__PURE__ */ jsx22(
|
|
2604
2636
|
Channel,
|
|
2605
2637
|
{
|
|
2606
2638
|
...props,
|
|
@@ -2620,7 +2652,7 @@ var SmartChannel = ({
|
|
|
2620
2652
|
// src/components/SpectrogramLabels.tsx
|
|
2621
2653
|
import { useRef as useRef8, useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2622
2654
|
import styled21 from "styled-components";
|
|
2623
|
-
import { jsx as
|
|
2655
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
2624
2656
|
var LABELS_WIDTH = 72;
|
|
2625
2657
|
var LabelsStickyWrapper = styled21.div`
|
|
2626
2658
|
position: sticky;
|
|
@@ -2713,7 +2745,7 @@ var SpectrogramLabels = ({
|
|
|
2713
2745
|
spectrogramHeight,
|
|
2714
2746
|
clipHeaderOffset
|
|
2715
2747
|
]);
|
|
2716
|
-
return /* @__PURE__ */
|
|
2748
|
+
return /* @__PURE__ */ jsx23(LabelsStickyWrapper, { $height: totalHeight + clipHeaderOffset, children: /* @__PURE__ */ jsx23(
|
|
2717
2749
|
"canvas",
|
|
2718
2750
|
{
|
|
2719
2751
|
ref: canvasRef,
|
|
@@ -2729,14 +2761,14 @@ var SpectrogramLabels = ({
|
|
|
2729
2761
|
};
|
|
2730
2762
|
|
|
2731
2763
|
// src/components/SmartScale.tsx
|
|
2732
|
-
import React19, {
|
|
2764
|
+
import React19, { use as use8, useMemo as useMemo6 } from "react";
|
|
2733
2765
|
import styled23 from "styled-components";
|
|
2734
2766
|
|
|
2735
2767
|
// src/components/TimeScale.tsx
|
|
2736
|
-
import { useLayoutEffect as useLayoutEffect5,
|
|
2768
|
+
import { useLayoutEffect as useLayoutEffect5, use as use7, useMemo as useMemo5 } from "react";
|
|
2737
2769
|
import styled22, { withTheme as withTheme2 } from "styled-components";
|
|
2738
2770
|
import { MAX_CANVAS_WIDTH as MAX_CANVAS_WIDTH4 } from "@waveform-playlist/core";
|
|
2739
|
-
import { jsx as
|
|
2771
|
+
import { jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2740
2772
|
var PlaylistTimeScaleScroll = styled22.div.attrs((props) => ({
|
|
2741
2773
|
style: {
|
|
2742
2774
|
width: `${props.$cssWidth}px`,
|
|
@@ -2758,20 +2790,30 @@ var TimeTickChunk = styled22.canvas.attrs((props) => ({
|
|
|
2758
2790
|
position: absolute;
|
|
2759
2791
|
bottom: 0;
|
|
2760
2792
|
`;
|
|
2793
|
+
function firstTickAtOrAfter(ticks, pixel) {
|
|
2794
|
+
let low = 0;
|
|
2795
|
+
let high = ticks.length;
|
|
2796
|
+
while (low < high) {
|
|
2797
|
+
const mid = low + high >>> 1;
|
|
2798
|
+
if (ticks[mid][0] < pixel) low = mid + 1;
|
|
2799
|
+
else high = mid;
|
|
2800
|
+
}
|
|
2801
|
+
return low;
|
|
2802
|
+
}
|
|
2761
2803
|
var TimeScale = (props) => {
|
|
2762
2804
|
const {
|
|
2763
2805
|
theme: { timeColor },
|
|
2764
2806
|
tickData
|
|
2765
2807
|
} = props;
|
|
2766
2808
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2767
|
-
const { timeScaleHeight } =
|
|
2809
|
+
const { timeScaleHeight } = use7(PlaylistInfoContext);
|
|
2768
2810
|
const devicePixelRatio = useDevicePixelRatio();
|
|
2769
2811
|
const { widthX, canvasInfo, timeMarkersWithPositions } = tickData;
|
|
2770
2812
|
const visibleChunkIndices = useVisibleChunkIndices(widthX, MAX_CANVAS_WIDTH4);
|
|
2771
2813
|
const visibleChunks = visibleChunkIndices.map((i) => {
|
|
2772
2814
|
const chunkLeft = i * MAX_CANVAS_WIDTH4;
|
|
2773
2815
|
const chunkWidth = Math.min(widthX - chunkLeft, MAX_CANVAS_WIDTH4);
|
|
2774
|
-
return /* @__PURE__ */
|
|
2816
|
+
return /* @__PURE__ */ jsx24(
|
|
2775
2817
|
TimeTickChunk,
|
|
2776
2818
|
{
|
|
2777
2819
|
$cssWidth: chunkWidth,
|
|
@@ -2788,25 +2830,40 @@ var TimeScale = (props) => {
|
|
|
2788
2830
|
const firstChunkLeft = visibleChunkIndices.length > 0 ? visibleChunkIndices[0] * MAX_CANVAS_WIDTH4 : 0;
|
|
2789
2831
|
const lastChunkRight = visibleChunkIndices.length > 0 ? (visibleChunkIndices[visibleChunkIndices.length - 1] + 1) * MAX_CANVAS_WIDTH4 : Infinity;
|
|
2790
2832
|
const visibleMarkers = visibleChunkIndices.length > 0 ? timeMarkersWithPositions.filter(({ pix }) => pix >= firstChunkLeft && pix < lastChunkRight).map(({ element }) => element) : timeMarkersWithPositions.map(({ element }) => element);
|
|
2833
|
+
const sortedTicks = useMemo5(
|
|
2834
|
+
() => Array.from(canvasInfo.entries()).sort((a, b) => a[0] - b[0]),
|
|
2835
|
+
[canvasInfo]
|
|
2836
|
+
);
|
|
2837
|
+
const ticksVersion = useIdentityVersion(canvasInfo);
|
|
2838
|
+
const drawVersion = `${ticksVersion}-${widthX}-${devicePixelRatio}-${timeColor}-${timeScaleHeight}`;
|
|
2791
2839
|
useLayoutEffect5(() => {
|
|
2792
2840
|
for (const [chunkIdx, canvas] of canvasMapRef.current.entries()) {
|
|
2841
|
+
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
2793
2842
|
const ctx = canvas.getContext("2d");
|
|
2794
2843
|
if (!ctx) continue;
|
|
2795
2844
|
const chunkLeft = chunkIdx * MAX_CANVAS_WIDTH4;
|
|
2796
|
-
const
|
|
2845
|
+
const chunkRight = chunkLeft + canvas.width / devicePixelRatio;
|
|
2797
2846
|
ctx.resetTransform();
|
|
2798
2847
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2799
2848
|
ctx.imageSmoothingEnabled = false;
|
|
2800
2849
|
ctx.fillStyle = timeColor;
|
|
2801
2850
|
ctx.scale(devicePixelRatio, devicePixelRatio);
|
|
2802
|
-
for (
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
ctx.fillRect(localX, scaleY, 1, scaleHeight);
|
|
2851
|
+
for (let i = firstTickAtOrAfter(sortedTicks, chunkLeft); i < sortedTicks.length; i++) {
|
|
2852
|
+
const [pixLeft, scaleHeight] = sortedTicks[i];
|
|
2853
|
+
if (pixLeft >= chunkRight) break;
|
|
2854
|
+
ctx.fillRect(pixLeft - chunkLeft, timeScaleHeight - scaleHeight, 1, scaleHeight);
|
|
2807
2855
|
}
|
|
2856
|
+
canvas.dataset.drawVersion = drawVersion;
|
|
2808
2857
|
}
|
|
2809
|
-
}, [
|
|
2858
|
+
}, [
|
|
2859
|
+
canvasMapRef,
|
|
2860
|
+
devicePixelRatio,
|
|
2861
|
+
timeColor,
|
|
2862
|
+
timeScaleHeight,
|
|
2863
|
+
sortedTicks,
|
|
2864
|
+
drawVersion,
|
|
2865
|
+
visibleChunkIndices
|
|
2866
|
+
]);
|
|
2810
2867
|
return /* @__PURE__ */ jsxs10(PlaylistTimeScaleScroll, { $cssWidth: widthX, $timeScaleHeight: timeScaleHeight, children: [
|
|
2811
2868
|
visibleMarkers,
|
|
2812
2869
|
visibleChunks
|
|
@@ -2823,7 +2880,7 @@ import {
|
|
|
2823
2880
|
samplesToPixels,
|
|
2824
2881
|
secondsToPixels
|
|
2825
2882
|
} from "@waveform-playlist/core";
|
|
2826
|
-
import { jsx as
|
|
2883
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
2827
2884
|
function ticksToBarBeatLabel(ticks, timeSignature, ppqn = PPQN) {
|
|
2828
2885
|
const barTicks = ticksPerBar2(timeSignature, ppqn);
|
|
2829
2886
|
const beatTicks = ticksPerBeat2(timeSignature, ppqn);
|
|
@@ -2872,15 +2929,18 @@ var TimeStamp = styled23.div.attrs((props) => ({
|
|
|
2872
2929
|
white-space: nowrap; /* Prevent text wrapping */
|
|
2873
2930
|
color: ${(props) => props.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
2874
2931
|
`;
|
|
2875
|
-
var SmartScale = ({
|
|
2876
|
-
|
|
2932
|
+
var SmartScale = ({
|
|
2933
|
+
durationMs: duration,
|
|
2934
|
+
renderTick
|
|
2935
|
+
}) => {
|
|
2936
|
+
const { samplesPerPixel, sampleRate, timeScaleHeight } = use8(PlaylistInfoContext);
|
|
2877
2937
|
const beatsAndBars = useBeatsAndBars();
|
|
2878
|
-
const
|
|
2938
|
+
const tickLayout = useMemo6(() => {
|
|
2879
2939
|
const widthX = secondsToPixels(duration / 1e3, samplesPerPixel, sampleRate);
|
|
2880
2940
|
if (beatsAndBars && beatsAndBars.scaleMode === "beats") {
|
|
2881
2941
|
const { bpm, timeSignature, ticksPerBar: tpBar, ticksPerBeat: tpBeat } = beatsAndBars;
|
|
2882
2942
|
const canvasInfo2 = /* @__PURE__ */ new Map();
|
|
2883
|
-
const
|
|
2943
|
+
const labels2 = [];
|
|
2884
2944
|
const durationSeconds = duration / 1e3;
|
|
2885
2945
|
const totalTicks = Math.ceil(durationSeconds * bpm * PPQN / 60);
|
|
2886
2946
|
const pixelsPerBeat = ticksToSamples(tpBeat, bpm, sampleRate) / samplesPerPixel;
|
|
@@ -2914,37 +2974,31 @@ var SmartScale = ({ renderTick }) => {
|
|
|
2914
2974
|
const tickHeight = isBarLine ? timeScaleHeight : isLabelTick ? Math.floor(timeScaleHeight / 2) : Math.floor(timeScaleHeight / 5);
|
|
2915
2975
|
canvasInfo2.set(pix, tickHeight);
|
|
2916
2976
|
if (isLabelTick) {
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
left: `${pix + 4}px`,
|
|
2924
|
-
fontSize: "0.75rem",
|
|
2925
|
-
whiteSpace: "nowrap"
|
|
2926
|
-
},
|
|
2927
|
-
children: label
|
|
2928
|
-
},
|
|
2929
|
-
`bb-${tick}`
|
|
2930
|
-
);
|
|
2931
|
-
timeMarkersWithPositions2.push({ pix, element });
|
|
2977
|
+
labels2.push({
|
|
2978
|
+
id: `bb-${tick}`,
|
|
2979
|
+
pix,
|
|
2980
|
+
text: ticksToBarBeatLabel(tick, timeSignature),
|
|
2981
|
+
mode: "beats"
|
|
2982
|
+
});
|
|
2932
2983
|
}
|
|
2933
2984
|
}
|
|
2934
|
-
return { widthX, canvasInfo: canvasInfo2,
|
|
2985
|
+
return { widthX, canvasInfo: canvasInfo2, labels: labels2 };
|
|
2935
2986
|
}
|
|
2936
2987
|
const config = getScaleInfo(samplesPerPixel);
|
|
2937
2988
|
const { marker, bigStep, smallStep } = config;
|
|
2938
2989
|
const canvasInfo = /* @__PURE__ */ new Map();
|
|
2939
|
-
const
|
|
2990
|
+
const labels = [];
|
|
2940
2991
|
const pixPerSec = sampleRate / samplesPerPixel;
|
|
2941
2992
|
let counter = 0;
|
|
2942
2993
|
for (let i = 0; i < widthX; i += pixPerSec * smallStep / 1e3) {
|
|
2943
2994
|
const pix = Math.floor(i);
|
|
2944
2995
|
if (counter % marker === 0) {
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2996
|
+
labels.push({
|
|
2997
|
+
id: `timestamp-${counter}`,
|
|
2998
|
+
pix,
|
|
2999
|
+
text: formatTime2(counter),
|
|
3000
|
+
mode: "temporal"
|
|
3001
|
+
});
|
|
2948
3002
|
canvasInfo.set(pix, timeScaleHeight);
|
|
2949
3003
|
} else if (counter % bigStep === 0) {
|
|
2950
3004
|
canvasInfo.set(pix, Math.floor(timeScaleHeight / 2));
|
|
@@ -2953,14 +3007,37 @@ var SmartScale = ({ renderTick }) => {
|
|
|
2953
3007
|
}
|
|
2954
3008
|
counter += smallStep;
|
|
2955
3009
|
}
|
|
2956
|
-
return { widthX, canvasInfo,
|
|
2957
|
-
}, [beatsAndBars, duration, samplesPerPixel, sampleRate, timeScaleHeight
|
|
2958
|
-
|
|
3010
|
+
return { widthX, canvasInfo, labels };
|
|
3011
|
+
}, [beatsAndBars, duration, samplesPerPixel, sampleRate, timeScaleHeight]);
|
|
3012
|
+
const tickData = useMemo6(
|
|
3013
|
+
() => ({
|
|
3014
|
+
widthX: tickLayout.widthX,
|
|
3015
|
+
canvasInfo: tickLayout.canvasInfo,
|
|
3016
|
+
timeMarkersWithPositions: tickLayout.labels.map(({ id, pix, text, mode }) => ({
|
|
3017
|
+
pix,
|
|
3018
|
+
element: renderTick ? /* @__PURE__ */ jsx25(React19.Fragment, { children: renderTick(text, pix) }, id) : mode === "beats" ? /* @__PURE__ */ jsx25(
|
|
3019
|
+
"div",
|
|
3020
|
+
{
|
|
3021
|
+
style: {
|
|
3022
|
+
position: "absolute",
|
|
3023
|
+
left: `${pix + 4}px`,
|
|
3024
|
+
fontSize: "0.75rem",
|
|
3025
|
+
whiteSpace: "nowrap"
|
|
3026
|
+
},
|
|
3027
|
+
children: text
|
|
3028
|
+
},
|
|
3029
|
+
id
|
|
3030
|
+
) : /* @__PURE__ */ jsx25(TimeStamp, { $left: pix, children: text }, id)
|
|
3031
|
+
}))
|
|
3032
|
+
}),
|
|
3033
|
+
[tickLayout, renderTick]
|
|
3034
|
+
);
|
|
3035
|
+
return /* @__PURE__ */ jsx25(StyledTimeScale, { tickData });
|
|
2959
3036
|
};
|
|
2960
3037
|
|
|
2961
3038
|
// src/components/TimeFormatSelect.tsx
|
|
2962
3039
|
import styled24 from "styled-components";
|
|
2963
|
-
import { jsx as
|
|
3040
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2964
3041
|
var SelectWrapper = styled24.div`
|
|
2965
3042
|
display: inline-flex;
|
|
2966
3043
|
align-items: center;
|
|
@@ -2983,7 +3060,7 @@ var TimeFormatSelect = ({
|
|
|
2983
3060
|
const handleChange = (e) => {
|
|
2984
3061
|
onChange(e.target.value);
|
|
2985
3062
|
};
|
|
2986
|
-
return /* @__PURE__ */
|
|
3063
|
+
return /* @__PURE__ */ jsx26(SelectWrapper, { className, children: /* @__PURE__ */ jsx26(
|
|
2987
3064
|
BaseSelect,
|
|
2988
3065
|
{
|
|
2989
3066
|
className: "time-format",
|
|
@@ -2991,23 +3068,57 @@ var TimeFormatSelect = ({
|
|
|
2991
3068
|
onChange: handleChange,
|
|
2992
3069
|
disabled,
|
|
2993
3070
|
"aria-label": "Time format selection",
|
|
2994
|
-
children: TIME_FORMAT_OPTIONS.map((option) => /* @__PURE__ */
|
|
3071
|
+
children: TIME_FORMAT_OPTIONS.map((option) => /* @__PURE__ */ jsx26("option", { value: option.value, children: option.label }, option.value))
|
|
2995
3072
|
}
|
|
2996
3073
|
) });
|
|
2997
3074
|
};
|
|
2998
3075
|
|
|
2999
|
-
// src/components/
|
|
3076
|
+
// src/components/PlaybackRateSelect.tsx
|
|
3000
3077
|
import styled25 from "styled-components";
|
|
3001
|
-
import { jsx as
|
|
3002
|
-
var
|
|
3078
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
3079
|
+
var SelectWrapper2 = styled25.div`
|
|
3080
|
+
display: inline-flex;
|
|
3081
|
+
align-items: center;
|
|
3082
|
+
gap: 0.5rem;
|
|
3083
|
+
`;
|
|
3084
|
+
var DEFAULT_PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
3085
|
+
var label = (rate) => `${rate}\xD7`;
|
|
3086
|
+
var PlaybackRateSelect = ({
|
|
3087
|
+
value,
|
|
3088
|
+
onChange,
|
|
3089
|
+
rates = DEFAULT_PLAYBACK_RATES,
|
|
3090
|
+
disabled = false,
|
|
3091
|
+
className
|
|
3092
|
+
}) => {
|
|
3093
|
+
const handleChange = (e) => {
|
|
3094
|
+
onChange(Number(e.target.value));
|
|
3095
|
+
};
|
|
3096
|
+
const options = rates.includes(value) ? rates : [...rates, value].sort((a, b) => a - b);
|
|
3097
|
+
return /* @__PURE__ */ jsx27(SelectWrapper2, { className, children: /* @__PURE__ */ jsx27(
|
|
3098
|
+
BaseSelect,
|
|
3099
|
+
{
|
|
3100
|
+
className: "playback-rate",
|
|
3101
|
+
value: String(value),
|
|
3102
|
+
onChange: handleChange,
|
|
3103
|
+
disabled,
|
|
3104
|
+
"aria-label": "Playback speed",
|
|
3105
|
+
children: options.map((rate) => /* @__PURE__ */ jsx27("option", { value: String(rate), children: label(rate) }, rate))
|
|
3106
|
+
}
|
|
3107
|
+
) });
|
|
3108
|
+
};
|
|
3109
|
+
|
|
3110
|
+
// src/components/Track.tsx
|
|
3111
|
+
import styled26 from "styled-components";
|
|
3112
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3113
|
+
var Container = styled26.div.attrs((props) => ({
|
|
3003
3114
|
style: {
|
|
3004
|
-
height: `${props.$waveHeight * props.$numChannels + (props.$hasClipHeaders ? CLIP_HEADER_HEIGHT : 0)}px
|
|
3115
|
+
height: `${props.$waveHeight * props.$numChannels + (props.$hasClipHeaders ? CLIP_HEADER_HEIGHT : 0)}px`,
|
|
3116
|
+
width: props.$width !== void 0 ? `${props.$width}px` : void 0
|
|
3005
3117
|
}
|
|
3006
3118
|
}))`
|
|
3007
3119
|
position: relative;
|
|
3008
|
-
${(props) => props.$width !== void 0 && `width: ${props.$width}px;`}
|
|
3009
3120
|
`;
|
|
3010
|
-
var ChannelContainer =
|
|
3121
|
+
var ChannelContainer = styled26.div.attrs((props) => ({
|
|
3011
3122
|
style: {
|
|
3012
3123
|
paddingLeft: `${props.$offset || 0}px`
|
|
3013
3124
|
}
|
|
@@ -3034,7 +3145,7 @@ var Track = ({
|
|
|
3034
3145
|
isSelected = false
|
|
3035
3146
|
}) => {
|
|
3036
3147
|
const { waveHeight } = usePlaylistInfo();
|
|
3037
|
-
return /* @__PURE__ */
|
|
3148
|
+
return /* @__PURE__ */ jsx28(
|
|
3038
3149
|
Container,
|
|
3039
3150
|
{
|
|
3040
3151
|
$numChannels: numChannels,
|
|
@@ -3042,7 +3153,7 @@ var Track = ({
|
|
|
3042
3153
|
$waveHeight: waveHeight,
|
|
3043
3154
|
$width: width,
|
|
3044
3155
|
$hasClipHeaders: hasClipHeaders,
|
|
3045
|
-
children: /* @__PURE__ */
|
|
3156
|
+
children: /* @__PURE__ */ jsx28(
|
|
3046
3157
|
ChannelContainer,
|
|
3047
3158
|
{
|
|
3048
3159
|
$backgroundColor: backgroundColor,
|
|
@@ -3058,8 +3169,8 @@ var Track = ({
|
|
|
3058
3169
|
};
|
|
3059
3170
|
|
|
3060
3171
|
// src/components/TrackControls/Button.tsx
|
|
3061
|
-
import
|
|
3062
|
-
var Button =
|
|
3172
|
+
import styled27 from "styled-components";
|
|
3173
|
+
var Button = styled27.button.attrs({
|
|
3063
3174
|
type: "button"
|
|
3064
3175
|
})`
|
|
3065
3176
|
display: inline-block;
|
|
@@ -3079,6 +3190,11 @@ var Button = styled26.button.attrs({
|
|
|
3079
3190
|
box-shadow 0.15s ease-in-out;
|
|
3080
3191
|
cursor: pointer;
|
|
3081
3192
|
|
|
3193
|
+
&:disabled {
|
|
3194
|
+
opacity: 0.5;
|
|
3195
|
+
cursor: not-allowed;
|
|
3196
|
+
}
|
|
3197
|
+
|
|
3082
3198
|
${(props) => {
|
|
3083
3199
|
if (props.$variant === "danger") {
|
|
3084
3200
|
return `
|
|
@@ -3134,8 +3250,8 @@ var Button = styled26.button.attrs({
|
|
|
3134
3250
|
`;
|
|
3135
3251
|
|
|
3136
3252
|
// src/components/TrackControls/ButtonGroup.tsx
|
|
3137
|
-
import
|
|
3138
|
-
var ButtonGroup =
|
|
3253
|
+
import styled28 from "styled-components";
|
|
3254
|
+
var ButtonGroup = styled28.div`
|
|
3139
3255
|
margin-bottom: 0.3rem;
|
|
3140
3256
|
|
|
3141
3257
|
button:not(:first-child) {
|
|
@@ -3150,10 +3266,10 @@ var ButtonGroup = styled27.div`
|
|
|
3150
3266
|
`;
|
|
3151
3267
|
|
|
3152
3268
|
// src/components/TrackControls/CloseButton.tsx
|
|
3153
|
-
import
|
|
3269
|
+
import styled29 from "styled-components";
|
|
3154
3270
|
import { X as XIcon } from "@phosphor-icons/react";
|
|
3155
|
-
import { jsx as
|
|
3156
|
-
var StyledCloseButton =
|
|
3271
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
3272
|
+
var StyledCloseButton = styled29.button`
|
|
3157
3273
|
position: absolute;
|
|
3158
3274
|
left: 0;
|
|
3159
3275
|
top: 0;
|
|
@@ -3176,11 +3292,11 @@ var StyledCloseButton = styled28.button`
|
|
|
3176
3292
|
color: #dc3545;
|
|
3177
3293
|
}
|
|
3178
3294
|
`;
|
|
3179
|
-
var CloseButton = ({ onClick, title = "Remove track" }) => /* @__PURE__ */
|
|
3295
|
+
var CloseButton = ({ onClick, title = "Remove track" }) => /* @__PURE__ */ jsx29(StyledCloseButton, { onClick, title, children: /* @__PURE__ */ jsx29(XIcon, { size: 12, weight: "bold" }) });
|
|
3180
3296
|
|
|
3181
3297
|
// src/components/TrackControls/Controls.tsx
|
|
3182
|
-
import
|
|
3183
|
-
var Controls =
|
|
3298
|
+
import styled30 from "styled-components";
|
|
3299
|
+
var Controls = styled30.div`
|
|
3184
3300
|
background: transparent;
|
|
3185
3301
|
width: 100%;
|
|
3186
3302
|
height: 100%;
|
|
@@ -3196,8 +3312,8 @@ var Controls = styled29.div`
|
|
|
3196
3312
|
`;
|
|
3197
3313
|
|
|
3198
3314
|
// src/components/TrackControls/Header.tsx
|
|
3199
|
-
import
|
|
3200
|
-
var Header =
|
|
3315
|
+
import styled31 from "styled-components";
|
|
3316
|
+
var Header = styled31.header`
|
|
3201
3317
|
overflow: hidden;
|
|
3202
3318
|
height: 26px;
|
|
3203
3319
|
width: 100%;
|
|
@@ -3212,43 +3328,43 @@ var Header = styled30.header`
|
|
|
3212
3328
|
|
|
3213
3329
|
// src/components/TrackControls/VolumeDownIcon.tsx
|
|
3214
3330
|
import { SpeakerLowIcon } from "@phosphor-icons/react";
|
|
3215
|
-
import { jsx as
|
|
3216
|
-
var VolumeDownIcon = (props) => /* @__PURE__ */
|
|
3331
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
3332
|
+
var VolumeDownIcon = (props) => /* @__PURE__ */ jsx30(SpeakerLowIcon, { weight: "light", ...props });
|
|
3217
3333
|
|
|
3218
3334
|
// src/components/TrackControls/VolumeUpIcon.tsx
|
|
3219
3335
|
import { SpeakerHighIcon } from "@phosphor-icons/react";
|
|
3220
|
-
import { jsx as
|
|
3221
|
-
var VolumeUpIcon = (props) => /* @__PURE__ */
|
|
3336
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3337
|
+
var VolumeUpIcon = (props) => /* @__PURE__ */ jsx31(SpeakerHighIcon, { weight: "light", ...props });
|
|
3222
3338
|
|
|
3223
3339
|
// src/components/TrackControls/TrashIcon.tsx
|
|
3224
3340
|
import { TrashIcon as PhosphorTrashIcon } from "@phosphor-icons/react";
|
|
3225
|
-
import { jsx as
|
|
3226
|
-
var TrashIcon = (props) => /* @__PURE__ */
|
|
3341
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
3342
|
+
var TrashIcon = (props) => /* @__PURE__ */ jsx32(PhosphorTrashIcon, { weight: "light", ...props });
|
|
3227
3343
|
|
|
3228
3344
|
// src/components/TrackControls/DotsIcon.tsx
|
|
3229
3345
|
import { DotsThreeIcon } from "@phosphor-icons/react";
|
|
3230
|
-
import { jsx as
|
|
3231
|
-
var DotsIcon = (props) => /* @__PURE__ */
|
|
3346
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
3347
|
+
var DotsIcon = (props) => /* @__PURE__ */ jsx33(DotsThreeIcon, { weight: "bold", ...props });
|
|
3232
3348
|
|
|
3233
3349
|
// src/components/TrackControls/GripIcon.tsx
|
|
3234
3350
|
import { DotsSixVerticalIcon } from "@phosphor-icons/react";
|
|
3235
|
-
import { jsx as
|
|
3236
|
-
var GripIcon = (props) => /* @__PURE__ */
|
|
3351
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
3352
|
+
var GripIcon = (props) => /* @__PURE__ */ jsx34(DotsSixVerticalIcon, { weight: "bold", ...props });
|
|
3237
3353
|
|
|
3238
3354
|
// src/components/TrackControls/MoveUpIcon.tsx
|
|
3239
3355
|
import { CaretUpIcon } from "@phosphor-icons/react";
|
|
3240
|
-
import { jsx as
|
|
3241
|
-
var MoveUpIcon = (props) => /* @__PURE__ */
|
|
3356
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
3357
|
+
var MoveUpIcon = (props) => /* @__PURE__ */ jsx35(CaretUpIcon, { weight: "bold", ...props });
|
|
3242
3358
|
|
|
3243
3359
|
// src/components/TrackControls/MoveDownIcon.tsx
|
|
3244
3360
|
import { CaretDownIcon } from "@phosphor-icons/react";
|
|
3245
|
-
import { jsx as
|
|
3246
|
-
var MoveDownIcon = (props) => /* @__PURE__ */
|
|
3361
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
3362
|
+
var MoveDownIcon = (props) => /* @__PURE__ */ jsx36(CaretDownIcon, { weight: "bold", ...props });
|
|
3247
3363
|
|
|
3248
3364
|
// src/components/TrackControls/ReorderRail.tsx
|
|
3249
|
-
import
|
|
3250
|
-
import { jsx as
|
|
3251
|
-
var Rail =
|
|
3365
|
+
import styled32 from "styled-components";
|
|
3366
|
+
import { jsx as jsx37, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3367
|
+
var Rail = styled32.div`
|
|
3252
3368
|
display: flex;
|
|
3253
3369
|
flex-direction: column;
|
|
3254
3370
|
align-items: center;
|
|
@@ -3262,7 +3378,7 @@ var Rail = styled31.div`
|
|
|
3262
3378
|
opacity: 1;
|
|
3263
3379
|
}
|
|
3264
3380
|
`;
|
|
3265
|
-
var RailButton =
|
|
3381
|
+
var RailButton = styled32.button.attrs({ type: "button" })`
|
|
3266
3382
|
border: none;
|
|
3267
3383
|
background: transparent;
|
|
3268
3384
|
color: inherit;
|
|
@@ -3277,7 +3393,7 @@ var RailButton = styled31.button.attrs({ type: "button" })`
|
|
|
3277
3393
|
box-shadow: 0 0 0 0.2rem ${(props) => props.theme.inputFocusBorder}33;
|
|
3278
3394
|
}
|
|
3279
3395
|
`;
|
|
3280
|
-
var ChevronButton =
|
|
3396
|
+
var ChevronButton = styled32(RailButton)`
|
|
3281
3397
|
width: 16px;
|
|
3282
3398
|
height: 14px;
|
|
3283
3399
|
cursor: pointer;
|
|
@@ -3291,7 +3407,7 @@ var ChevronButton = styled31(RailButton)`
|
|
|
3291
3407
|
cursor: default;
|
|
3292
3408
|
}
|
|
3293
3409
|
`;
|
|
3294
|
-
var GripButton =
|
|
3410
|
+
var GripButton = styled32(RailButton)`
|
|
3295
3411
|
width: 16px;
|
|
3296
3412
|
height: 20px;
|
|
3297
3413
|
cursor: grab;
|
|
@@ -3310,23 +3426,23 @@ var ReorderRail = ({
|
|
|
3310
3426
|
onGripClick,
|
|
3311
3427
|
style
|
|
3312
3428
|
}) => /* @__PURE__ */ jsxs11(Rail, { style, children: [
|
|
3313
|
-
/* @__PURE__ */
|
|
3314
|
-
/* @__PURE__ */
|
|
3429
|
+
/* @__PURE__ */ jsx37(ChevronButton, { "aria-label": "Move track up", disabled: upDisabled, onClick: onMoveUp, children: /* @__PURE__ */ jsx37(MoveUpIcon, { size: 12 }) }),
|
|
3430
|
+
/* @__PURE__ */ jsx37(
|
|
3315
3431
|
GripButton,
|
|
3316
3432
|
{
|
|
3317
3433
|
ref: gripRef,
|
|
3318
3434
|
"aria-label": "Drag to reorder track",
|
|
3319
3435
|
title: "Drag to reorder track",
|
|
3320
3436
|
onClick: onGripClick,
|
|
3321
|
-
children: /* @__PURE__ */
|
|
3437
|
+
children: /* @__PURE__ */ jsx37(GripIcon, { size: 14 })
|
|
3322
3438
|
}
|
|
3323
3439
|
),
|
|
3324
|
-
/* @__PURE__ */
|
|
3440
|
+
/* @__PURE__ */ jsx37(ChevronButton, { "aria-label": "Move track down", disabled: downDisabled, onClick: onMoveDown, children: /* @__PURE__ */ jsx37(MoveDownIcon, { size: 12 }) })
|
|
3325
3441
|
] });
|
|
3326
3442
|
|
|
3327
3443
|
// src/components/TrackControls/Slider.tsx
|
|
3328
|
-
import
|
|
3329
|
-
var Slider =
|
|
3444
|
+
import styled33 from "styled-components";
|
|
3445
|
+
var Slider = styled33(BaseSlider)`
|
|
3330
3446
|
width: 75%;
|
|
3331
3447
|
height: 5px;
|
|
3332
3448
|
background: ${(props) => props.theme.sliderTrackColor};
|
|
@@ -3360,6 +3476,19 @@ var Slider = styled32(BaseSlider)`
|
|
|
3360
3476
|
border-radius: 3px;
|
|
3361
3477
|
}
|
|
3362
3478
|
|
|
3479
|
+
&:disabled {
|
|
3480
|
+
opacity: 0.5;
|
|
3481
|
+
cursor: not-allowed;
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
&:disabled::-webkit-slider-thumb {
|
|
3485
|
+
cursor: not-allowed;
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3488
|
+
&:disabled::-moz-range-thumb {
|
|
3489
|
+
cursor: not-allowed;
|
|
3490
|
+
}
|
|
3491
|
+
|
|
3363
3492
|
&:focus::-webkit-slider-runnable-track {
|
|
3364
3493
|
background: ${(props) => props.theme.inputBorder};
|
|
3365
3494
|
}
|
|
@@ -3378,8 +3507,8 @@ var Slider = styled32(BaseSlider)`
|
|
|
3378
3507
|
`;
|
|
3379
3508
|
|
|
3380
3509
|
// src/components/TrackControls/SliderWrapper.tsx
|
|
3381
|
-
import
|
|
3382
|
-
var SliderWrapper =
|
|
3510
|
+
import styled34 from "styled-components";
|
|
3511
|
+
var SliderWrapper = styled34.label`
|
|
3383
3512
|
width: 100%;
|
|
3384
3513
|
display: flex;
|
|
3385
3514
|
justify-content: space-between;
|
|
@@ -3390,15 +3519,15 @@ var SliderWrapper = styled33.label`
|
|
|
3390
3519
|
`;
|
|
3391
3520
|
|
|
3392
3521
|
// src/components/TrackMenu.tsx
|
|
3393
|
-
import React20, { useState as
|
|
3522
|
+
import React20, { useState as useState4, useEffect as useEffect6, useRef as useRef9, useCallback as useCallback5 } from "react";
|
|
3394
3523
|
import { createPortal } from "react-dom";
|
|
3395
|
-
import
|
|
3396
|
-
import { jsx as
|
|
3397
|
-
var MenuContainer =
|
|
3524
|
+
import styled35 from "styled-components";
|
|
3525
|
+
import { jsx as jsx38, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3526
|
+
var MenuContainer = styled35.div`
|
|
3398
3527
|
position: relative;
|
|
3399
3528
|
display: inline-block;
|
|
3400
3529
|
`;
|
|
3401
|
-
var MenuButton =
|
|
3530
|
+
var MenuButton = styled35.button`
|
|
3402
3531
|
background: none;
|
|
3403
3532
|
border: none;
|
|
3404
3533
|
cursor: pointer;
|
|
@@ -3414,10 +3543,10 @@ var MenuButton = styled34.button`
|
|
|
3414
3543
|
}
|
|
3415
3544
|
`;
|
|
3416
3545
|
var DROPDOWN_MIN_WIDTH = 180;
|
|
3417
|
-
var Dropdown =
|
|
3546
|
+
var Dropdown = styled35.div.attrs((p) => ({
|
|
3547
|
+
style: { top: `${p.$top}px`, left: `${p.$left}px` }
|
|
3548
|
+
}))`
|
|
3418
3549
|
position: fixed;
|
|
3419
|
-
top: ${(p) => p.$top}px;
|
|
3420
|
-
left: ${(p) => p.$left}px;
|
|
3421
3550
|
z-index: 10000;
|
|
3422
3551
|
background: ${(p) => p.theme.timescaleBackgroundColor ?? "#222"};
|
|
3423
3552
|
color: ${(p) => p.theme.textColor ?? "inherit"};
|
|
@@ -3427,16 +3556,16 @@ var Dropdown = styled34.div`
|
|
|
3427
3556
|
min-width: ${DROPDOWN_MIN_WIDTH}px;
|
|
3428
3557
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
3429
3558
|
`;
|
|
3430
|
-
var Divider =
|
|
3559
|
+
var Divider = styled35.hr`
|
|
3431
3560
|
border: none;
|
|
3432
3561
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
3433
3562
|
margin: 0.35rem 0;
|
|
3434
3563
|
`;
|
|
3435
3564
|
var TrackMenu = ({ items: itemsProp }) => {
|
|
3436
|
-
const [open, setOpen] =
|
|
3565
|
+
const [open, setOpen] = useState4(false);
|
|
3437
3566
|
const close = useCallback5(() => setOpen(false), []);
|
|
3438
3567
|
const items = typeof itemsProp === "function" ? itemsProp(close) : itemsProp;
|
|
3439
|
-
const [dropdownPos, setDropdownPos] =
|
|
3568
|
+
const [dropdownPos, setDropdownPos] = useState4({ top: 0, left: 0 });
|
|
3440
3569
|
const buttonRef = useRef9(null);
|
|
3441
3570
|
const dropdownRef = useRef9(null);
|
|
3442
3571
|
const updatePosition = useCallback5(() => {
|
|
@@ -3454,23 +3583,30 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3454
3583
|
if (top + dropHeight > vh - 4) {
|
|
3455
3584
|
top = Math.max(4, rect.bottom - dropHeight);
|
|
3456
3585
|
}
|
|
3457
|
-
setDropdownPos({ top, left });
|
|
3586
|
+
setDropdownPos((prev) => prev.top === top && prev.left === left ? prev : { top, left });
|
|
3458
3587
|
}, []);
|
|
3459
|
-
|
|
3588
|
+
useEffect6(() => {
|
|
3460
3589
|
if (!open) return;
|
|
3461
3590
|
updatePosition();
|
|
3462
|
-
|
|
3463
|
-
const
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3591
|
+
let frameId = null;
|
|
3592
|
+
const scheduleUpdate = () => {
|
|
3593
|
+
if (frameId !== null) return;
|
|
3594
|
+
frameId = requestAnimationFrame(() => {
|
|
3595
|
+
frameId = null;
|
|
3596
|
+
updatePosition();
|
|
3597
|
+
});
|
|
3598
|
+
};
|
|
3599
|
+
scheduleUpdate();
|
|
3600
|
+
const scrollOptions = { capture: true, passive: true };
|
|
3601
|
+
window.addEventListener("scroll", scheduleUpdate, scrollOptions);
|
|
3602
|
+
window.addEventListener("resize", scheduleUpdate);
|
|
3467
3603
|
return () => {
|
|
3468
|
-
cancelAnimationFrame(
|
|
3469
|
-
window.removeEventListener("scroll",
|
|
3470
|
-
window.removeEventListener("resize",
|
|
3604
|
+
if (frameId !== null) cancelAnimationFrame(frameId);
|
|
3605
|
+
window.removeEventListener("scroll", scheduleUpdate, scrollOptions);
|
|
3606
|
+
window.removeEventListener("resize", scheduleUpdate);
|
|
3471
3607
|
};
|
|
3472
3608
|
}, [open, updatePosition]);
|
|
3473
|
-
|
|
3609
|
+
useEffect6(() => {
|
|
3474
3610
|
if (!open) return;
|
|
3475
3611
|
const handleClick = (e) => {
|
|
3476
3612
|
const target = e.target;
|
|
@@ -3491,7 +3627,7 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3491
3627
|
};
|
|
3492
3628
|
}, [open]);
|
|
3493
3629
|
return /* @__PURE__ */ jsxs12(MenuContainer, { children: [
|
|
3494
|
-
/* @__PURE__ */
|
|
3630
|
+
/* @__PURE__ */ jsx38(
|
|
3495
3631
|
MenuButton,
|
|
3496
3632
|
{
|
|
3497
3633
|
ref: buttonRef,
|
|
@@ -3502,11 +3638,11 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3502
3638
|
onMouseDown: (e) => e.stopPropagation(),
|
|
3503
3639
|
title: "Track menu",
|
|
3504
3640
|
"aria-label": "Track menu",
|
|
3505
|
-
children: /* @__PURE__ */
|
|
3641
|
+
children: /* @__PURE__ */ jsx38(DotsIcon, { size: 16 })
|
|
3506
3642
|
}
|
|
3507
3643
|
),
|
|
3508
3644
|
open && typeof document !== "undefined" && createPortal(
|
|
3509
|
-
/* @__PURE__ */
|
|
3645
|
+
/* @__PURE__ */ jsx38(
|
|
3510
3646
|
Dropdown,
|
|
3511
3647
|
{
|
|
3512
3648
|
ref: dropdownRef,
|
|
@@ -3514,7 +3650,7 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3514
3650
|
$left: dropdownPos.left,
|
|
3515
3651
|
onMouseDown: (e) => e.stopPropagation(),
|
|
3516
3652
|
children: items.map((item, index) => /* @__PURE__ */ jsxs12(React20.Fragment, { children: [
|
|
3517
|
-
index > 0 && /* @__PURE__ */
|
|
3653
|
+
index > 0 && /* @__PURE__ */ jsx38(Divider, {}),
|
|
3518
3654
|
item.content
|
|
3519
3655
|
] }, item.id))
|
|
3520
3656
|
}
|
|
@@ -3525,10 +3661,10 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3525
3661
|
};
|
|
3526
3662
|
|
|
3527
3663
|
// src/components/SegmentedVUMeter.tsx
|
|
3528
|
-
import React21, { useMemo as
|
|
3529
|
-
import
|
|
3664
|
+
import React21, { useCallback as useCallback6, useLayoutEffect as useLayoutEffect6, useMemo as useMemo7, useRef as useRef10, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
3665
|
+
import styled36 from "styled-components";
|
|
3530
3666
|
import { normalizedToDb } from "@waveform-playlist/core";
|
|
3531
|
-
import { jsx as
|
|
3667
|
+
import { jsx as jsx39, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3532
3668
|
var DEFAULT_COLOR_STOPS = [
|
|
3533
3669
|
{ dB: 2, color: "#ff0000" },
|
|
3534
3670
|
{ dB: -1, color: "#e74c3c" },
|
|
@@ -3556,6 +3692,29 @@ function getColorForDb(dB, colorStops) {
|
|
|
3556
3692
|
}
|
|
3557
3693
|
return colorStops[colorStops.length - 1].color;
|
|
3558
3694
|
}
|
|
3695
|
+
function closestThresholdIndex(thresholds, dB) {
|
|
3696
|
+
let index = -1;
|
|
3697
|
+
let minDist = Infinity;
|
|
3698
|
+
for (let i = 0; i < thresholds.length; i++) {
|
|
3699
|
+
const dist = Math.abs(thresholds[i] - dB);
|
|
3700
|
+
if (dist < minDist) {
|
|
3701
|
+
minDist = dist;
|
|
3702
|
+
index = i;
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
return index;
|
|
3706
|
+
}
|
|
3707
|
+
function segmentVisual(active, isPeak, color, coloredInactive) {
|
|
3708
|
+
return {
|
|
3709
|
+
backgroundColor: isPeak ? PEAK_COLOR : active || coloredInactive ? color : INACTIVE_COLOR,
|
|
3710
|
+
opacity: isPeak || active ? "1" : coloredInactive ? String(INACTIVE_OPACITY) : "1",
|
|
3711
|
+
boxShadow: active || isPeak ? `0 0 4px ${isPeak ? PEAK_COLOR : color}40` : "none"
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
var NO_LEVELS = [];
|
|
3715
|
+
var subscribeToNothing = () => () => {
|
|
3716
|
+
};
|
|
3717
|
+
var NO_METER = -1;
|
|
3559
3718
|
function computeThresholds(segmentCount, dBRange) {
|
|
3560
3719
|
const safeCount = Math.max(2, segmentCount);
|
|
3561
3720
|
const [minDb, maxDb] = dBRange;
|
|
@@ -3565,48 +3724,46 @@ function computeThresholds(segmentCount, dBRange) {
|
|
|
3565
3724
|
function formatDbLabel(dB) {
|
|
3566
3725
|
return Math.round(dB).toString();
|
|
3567
3726
|
}
|
|
3568
|
-
var MeterContainer =
|
|
3727
|
+
var MeterContainer = styled36.div`
|
|
3569
3728
|
display: inline-flex;
|
|
3570
3729
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "column" : "row"};
|
|
3571
3730
|
gap: 4px;
|
|
3572
3731
|
font-family: 'Courier New', monospace;
|
|
3573
3732
|
`;
|
|
3574
|
-
var ChannelColumn =
|
|
3733
|
+
var ChannelColumn = styled36.div`
|
|
3575
3734
|
display: flex;
|
|
3576
3735
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "row" : "column"};
|
|
3577
3736
|
align-items: center;
|
|
3578
3737
|
gap: 4px;
|
|
3579
3738
|
`;
|
|
3580
|
-
var SegmentStack =
|
|
3739
|
+
var SegmentStack = styled36.div`
|
|
3581
3740
|
display: flex;
|
|
3582
3741
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "row" : "column"};
|
|
3583
3742
|
`;
|
|
3584
|
-
var Segment =
|
|
3743
|
+
var Segment = styled36.div.attrs((props) => ({
|
|
3585
3744
|
style: {
|
|
3586
3745
|
width: `${props.$width}px`,
|
|
3587
3746
|
height: `${props.$height}px`,
|
|
3588
3747
|
...props.$orientation === "horizontal" ? { marginRight: `${props.$gap}px` } : { marginBottom: `${props.$gap}px` },
|
|
3589
|
-
|
|
3590
|
-
opacity: props.$isPeak || props.$active ? 1 : props.$coloredInactive ? INACTIVE_OPACITY : 1,
|
|
3591
|
-
boxShadow: props.$active || props.$isPeak ? `0 0 4px ${props.$isPeak ? PEAK_COLOR : props.$color}40` : "none"
|
|
3748
|
+
...segmentVisual(props.$active, props.$isPeak, props.$color, props.$coloredInactive)
|
|
3592
3749
|
}
|
|
3593
3750
|
}))`
|
|
3594
3751
|
border-radius: 1px;
|
|
3595
3752
|
`;
|
|
3596
3753
|
var DEFAULT_LABEL_COLOR = "#888";
|
|
3597
|
-
var ChannelLabel =
|
|
3754
|
+
var ChannelLabel = styled36.div`
|
|
3598
3755
|
color: ${(props) => props.$labelColor};
|
|
3599
3756
|
font-size: 10px;
|
|
3600
3757
|
text-align: center;
|
|
3601
3758
|
user-select: none;
|
|
3602
3759
|
`;
|
|
3603
|
-
var ScaleColumn =
|
|
3760
|
+
var ScaleColumn = styled36.div`
|
|
3604
3761
|
display: flex;
|
|
3605
3762
|
flex-direction: column;
|
|
3606
3763
|
position: relative;
|
|
3607
3764
|
min-width: 28px;
|
|
3608
3765
|
`;
|
|
3609
|
-
var ScaleLabel =
|
|
3766
|
+
var ScaleLabel = styled36.div.attrs((props) => ({
|
|
3610
3767
|
style: {
|
|
3611
3768
|
top: `${props.$top}px`,
|
|
3612
3769
|
color: props.$labelColor
|
|
@@ -3620,19 +3777,19 @@ var ScaleLabel = styled35.div.attrs((props) => ({
|
|
|
3620
3777
|
transform: translate(-50%, -50%);
|
|
3621
3778
|
user-select: none;
|
|
3622
3779
|
`;
|
|
3623
|
-
var HorizontalScaleWrapper =
|
|
3780
|
+
var HorizontalScaleWrapper = styled36.div`
|
|
3624
3781
|
display: flex;
|
|
3625
3782
|
flex-direction: row;
|
|
3626
3783
|
align-items: center;
|
|
3627
3784
|
gap: 4px;
|
|
3628
3785
|
`;
|
|
3629
|
-
var ScaleRow =
|
|
3786
|
+
var ScaleRow = styled36.div`
|
|
3630
3787
|
display: flex;
|
|
3631
3788
|
flex-direction: row;
|
|
3632
3789
|
position: relative;
|
|
3633
3790
|
min-height: 16px;
|
|
3634
3791
|
`;
|
|
3635
|
-
var ScaleLabelHorizontal =
|
|
3792
|
+
var ScaleLabelHorizontal = styled36.div.attrs((props) => ({
|
|
3636
3793
|
style: {
|
|
3637
3794
|
left: `${props.$left}px`,
|
|
3638
3795
|
color: props.$labelColor
|
|
@@ -3647,8 +3804,9 @@ var ScaleLabelHorizontal = styled35.div.attrs((props) => ({
|
|
|
3647
3804
|
user-select: none;
|
|
3648
3805
|
`;
|
|
3649
3806
|
var SegmentedVUMeterInner = ({
|
|
3650
|
-
|
|
3651
|
-
|
|
3807
|
+
meter,
|
|
3808
|
+
levels: levelsProp,
|
|
3809
|
+
peakLevels: peakLevelsProp,
|
|
3652
3810
|
channelLabels,
|
|
3653
3811
|
orientation = "vertical",
|
|
3654
3812
|
segmentCount = 24,
|
|
@@ -3662,9 +3820,28 @@ var SegmentedVUMeterInner = ({
|
|
|
3662
3820
|
labelColor,
|
|
3663
3821
|
className
|
|
3664
3822
|
}) => {
|
|
3665
|
-
const
|
|
3823
|
+
const subscribeToMeter = useCallback6(
|
|
3824
|
+
(onChange) => meter ? meter.subscribe(onChange) : subscribeToNothing(),
|
|
3825
|
+
[meter]
|
|
3826
|
+
);
|
|
3827
|
+
const getMeterChannelCount = useCallback6(
|
|
3828
|
+
() => meter ? meter.getSnapshot().levels.length : NO_METER,
|
|
3829
|
+
[meter]
|
|
3830
|
+
);
|
|
3831
|
+
const meterChannelCount = useSyncExternalStore2(
|
|
3832
|
+
subscribeToMeter,
|
|
3833
|
+
getMeterChannelCount,
|
|
3834
|
+
getMeterChannelCount
|
|
3835
|
+
);
|
|
3836
|
+
const meterSnapshot = meter ? meter.getSnapshot() : null;
|
|
3837
|
+
const levels = meterSnapshot ? meterSnapshot.levels : levelsProp ?? NO_LEVELS;
|
|
3838
|
+
const peakLevels = meterSnapshot ? meterSnapshot.peakLevels : peakLevelsProp;
|
|
3839
|
+
const containerRef = useRef10(null);
|
|
3840
|
+
const redrawRef = useRef10(null);
|
|
3841
|
+
const sourceKey = meter ? "meter" : "props";
|
|
3842
|
+
const channelCount = meter ? meterChannelCount : levels.length;
|
|
3843
|
+
const labels = channelLabels ?? getDefaultLabels(channelCount);
|
|
3666
3844
|
const resolvedLabelColor = labelColor ?? DEFAULT_LABEL_COLOR;
|
|
3667
|
-
const channelCount = levels.length;
|
|
3668
3845
|
if (process.env.NODE_ENV !== "production" && peakLevels != null && peakLevels.length !== channelCount) {
|
|
3669
3846
|
console.warn(
|
|
3670
3847
|
`[waveform-playlist] SegmentedVUMeter: peakLevels length (${peakLevels.length}) does not match levels length (${channelCount})`
|
|
@@ -3673,11 +3850,11 @@ var SegmentedVUMeterInner = ({
|
|
|
3673
3850
|
const isMultiChannel = channelCount >= 2;
|
|
3674
3851
|
const segmentTotalHeight = segmentHeight + segmentGap;
|
|
3675
3852
|
const [dBMin, dBMax] = dBRange;
|
|
3676
|
-
const thresholds =
|
|
3853
|
+
const thresholds = useMemo7(
|
|
3677
3854
|
() => computeThresholds(segmentCount, [dBMin, dBMax]),
|
|
3678
3855
|
[segmentCount, dBMin, dBMax]
|
|
3679
3856
|
);
|
|
3680
|
-
const scaleLabels =
|
|
3857
|
+
const scaleLabels = useMemo7(() => {
|
|
3681
3858
|
const totalSize = segmentCount * segmentTotalHeight - segmentGap;
|
|
3682
3859
|
const minDb = dBMin;
|
|
3683
3860
|
const maxDb = dBMax;
|
|
@@ -3697,32 +3874,67 @@ var SegmentedVUMeterInner = ({
|
|
|
3697
3874
|
}
|
|
3698
3875
|
return labels2;
|
|
3699
3876
|
}, [orientation, segmentCount, segmentTotalHeight, segmentGap, dBMin, dBMax]);
|
|
3700
|
-
const renderThresholds =
|
|
3877
|
+
const renderThresholds = useMemo7(
|
|
3701
3878
|
() => orientation === "horizontal" ? [...thresholds].reverse() : thresholds,
|
|
3702
3879
|
[thresholds, orientation]
|
|
3703
3880
|
);
|
|
3704
|
-
const
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3881
|
+
const segmentColors = useMemo7(
|
|
3882
|
+
() => renderThresholds.map((threshold) => getColorForDb(threshold, colorStops)),
|
|
3883
|
+
[renderThresholds, colorStops]
|
|
3884
|
+
);
|
|
3885
|
+
useLayoutEffect6(() => {
|
|
3886
|
+
const container = containerRef.current;
|
|
3887
|
+
if (!meter || !container) return;
|
|
3888
|
+
const channels = Array.from(container.querySelectorAll("[data-channel]")).map(
|
|
3889
|
+
(channel) => Array.from(channel.querySelectorAll("[data-segment]"))
|
|
3890
|
+
);
|
|
3891
|
+
const drawn = channels.map((segments) => new Uint8Array(segments.length).fill(255));
|
|
3892
|
+
const draw = (value) => {
|
|
3893
|
+
for (let ch = 0; ch < channels.length; ch++) {
|
|
3894
|
+
const segments = channels[ch];
|
|
3895
|
+
const levelDb = normalizedToDb(value.levels[ch] ?? 0);
|
|
3896
|
+
const peak = value.peakLevels[ch];
|
|
3897
|
+
const peakIndex = peak === void 0 ? -1 : closestThresholdIndex(renderThresholds, normalizedToDb(peak));
|
|
3898
|
+
for (let i = 0; i < segments.length; i++) {
|
|
3899
|
+
const active = levelDb >= renderThresholds[i];
|
|
3900
|
+
const isPeak = i === peakIndex;
|
|
3901
|
+
const state = (active ? 1 : 0) | (isPeak ? 2 : 0);
|
|
3902
|
+
if (drawn[ch][i] === state) continue;
|
|
3903
|
+
drawn[ch][i] = state;
|
|
3904
|
+
const segment = segments[i];
|
|
3905
|
+
const visual = segmentVisual(active, isPeak, segmentColors[i], coloredInactive);
|
|
3906
|
+
segment.style.backgroundColor = visual.backgroundColor;
|
|
3907
|
+
segment.style.opacity = visual.opacity;
|
|
3908
|
+
segment.style.boxShadow = visual.boxShadow;
|
|
3909
|
+
segment.toggleAttribute("data-peak", isPeak);
|
|
3716
3910
|
}
|
|
3717
3911
|
}
|
|
3718
|
-
}
|
|
3912
|
+
};
|
|
3913
|
+
redrawRef.current = () => {
|
|
3914
|
+
for (const states of drawn) states.fill(255);
|
|
3915
|
+
draw(meter.getSnapshot());
|
|
3916
|
+
};
|
|
3917
|
+
const unsubscribe = meter.subscribe((value) => draw(value));
|
|
3918
|
+
return () => {
|
|
3919
|
+
unsubscribe();
|
|
3920
|
+
redrawRef.current = null;
|
|
3921
|
+
};
|
|
3922
|
+
}, [meter, channelCount, renderThresholds, segmentColors, coloredInactive, orientation]);
|
|
3923
|
+
useLayoutEffect6(() => {
|
|
3924
|
+
redrawRef.current?.();
|
|
3925
|
+
});
|
|
3926
|
+
const renderChannel = (channelIndex) => {
|
|
3927
|
+
const level = levels[channelIndex] ?? 0;
|
|
3928
|
+
const levelDb = normalizedToDb(level);
|
|
3929
|
+
const peak = peakLevels?.[channelIndex];
|
|
3930
|
+
const peakSegmentIndex = peak === void 0 ? -1 : closestThresholdIndex(renderThresholds, normalizedToDb(peak));
|
|
3719
3931
|
return /* @__PURE__ */ jsxs13(ChannelColumn, { $orientation: orientation, "data-channel": true, children: [
|
|
3720
|
-
orientation === "horizontal" && /* @__PURE__ */
|
|
3721
|
-
/* @__PURE__ */
|
|
3932
|
+
orientation === "horizontal" && /* @__PURE__ */ jsx39(ChannelLabel, { $labelColor: resolvedLabelColor, children: labels[channelIndex] }),
|
|
3933
|
+
/* @__PURE__ */ jsx39(SegmentStack, { $orientation: orientation, children: renderThresholds.map((threshold, segIdx) => {
|
|
3722
3934
|
const active = levelDb >= threshold;
|
|
3723
3935
|
const isPeak = segIdx === peakSegmentIndex;
|
|
3724
|
-
const color =
|
|
3725
|
-
return /* @__PURE__ */
|
|
3936
|
+
const color = segmentColors[segIdx];
|
|
3937
|
+
return /* @__PURE__ */ jsx39(
|
|
3726
3938
|
Segment,
|
|
3727
3939
|
{
|
|
3728
3940
|
$width: orientation === "horizontal" ? segmentHeight : segmentWidth,
|
|
@@ -3734,30 +3946,31 @@ var SegmentedVUMeterInner = ({
|
|
|
3734
3946
|
$orientation: orientation,
|
|
3735
3947
|
$coloredInactive: coloredInactive,
|
|
3736
3948
|
"data-segment": true,
|
|
3737
|
-
...isPeak ? { "data-peak":
|
|
3949
|
+
...isPeak ? { "data-peak": "" } : {}
|
|
3738
3950
|
},
|
|
3739
3951
|
segIdx
|
|
3740
3952
|
);
|
|
3741
3953
|
}) }),
|
|
3742
|
-
orientation === "vertical" && /* @__PURE__ */
|
|
3954
|
+
orientation === "vertical" && /* @__PURE__ */ jsx39(ChannelLabel, { $labelColor: resolvedLabelColor, children: labels[channelIndex] })
|
|
3743
3955
|
] }, channelIndex);
|
|
3744
3956
|
};
|
|
3745
3957
|
const renderScale = () => {
|
|
3746
3958
|
if (orientation === "horizontal") {
|
|
3747
3959
|
const totalWidth = segmentCount * segmentTotalHeight - segmentGap;
|
|
3748
3960
|
return /* @__PURE__ */ jsxs13(HorizontalScaleWrapper, { children: [
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
/* @__PURE__ */
|
|
3961
|
+
/* @__PURE__ */ jsx39(ChannelLabel, { $labelColor: resolvedLabelColor, style: { visibility: "hidden" }, children: "L" }),
|
|
3962
|
+
/* @__PURE__ */ jsx39(ScaleRow, { style: { width: `${totalWidth}px` }, children: scaleLabels.map(({ position, label: label2 }, i) => /* @__PURE__ */ jsx39(ScaleLabelHorizontal, { $left: position, $labelColor: resolvedLabelColor, children: label2 }, i)) })
|
|
3751
3963
|
] });
|
|
3752
3964
|
}
|
|
3753
3965
|
const totalHeight = segmentCount * segmentTotalHeight - segmentGap;
|
|
3754
|
-
return /* @__PURE__ */
|
|
3966
|
+
return /* @__PURE__ */ jsx39(ScaleColumn, { style: { height: `${totalHeight}px` }, children: scaleLabels.map(({ position, label: label2 }, i) => /* @__PURE__ */ jsx39(ScaleLabel, { $top: position, $labelColor: resolvedLabelColor, children: label2 }, i)) });
|
|
3755
3967
|
};
|
|
3756
3968
|
if (isMultiChannel) {
|
|
3757
3969
|
if (orientation === "horizontal") {
|
|
3758
3970
|
return /* @__PURE__ */ jsxs13(
|
|
3759
3971
|
MeterContainer,
|
|
3760
3972
|
{
|
|
3973
|
+
ref: containerRef,
|
|
3761
3974
|
className,
|
|
3762
3975
|
$orientation: orientation,
|
|
3763
3976
|
"data-meter-orientation": orientation,
|
|
@@ -3765,7 +3978,8 @@ var SegmentedVUMeterInner = ({
|
|
|
3765
3978
|
Array.from({ length: channelCount }, (_, i) => renderChannel(i)),
|
|
3766
3979
|
showScale && renderScale()
|
|
3767
3980
|
]
|
|
3768
|
-
}
|
|
3981
|
+
},
|
|
3982
|
+
sourceKey
|
|
3769
3983
|
);
|
|
3770
3984
|
}
|
|
3771
3985
|
const midpoint = Math.ceil(channelCount / 2);
|
|
@@ -3774,6 +3988,7 @@ var SegmentedVUMeterInner = ({
|
|
|
3774
3988
|
return /* @__PURE__ */ jsxs13(
|
|
3775
3989
|
MeterContainer,
|
|
3776
3990
|
{
|
|
3991
|
+
ref: containerRef,
|
|
3777
3992
|
className,
|
|
3778
3993
|
$orientation: orientation,
|
|
3779
3994
|
"data-meter-orientation": orientation,
|
|
@@ -3782,12 +3997,14 @@ var SegmentedVUMeterInner = ({
|
|
|
3782
3997
|
showScale && renderScale(),
|
|
3783
3998
|
rightChannels.map(renderChannel)
|
|
3784
3999
|
]
|
|
3785
|
-
}
|
|
4000
|
+
},
|
|
4001
|
+
sourceKey
|
|
3786
4002
|
);
|
|
3787
4003
|
}
|
|
3788
4004
|
return /* @__PURE__ */ jsxs13(
|
|
3789
4005
|
MeterContainer,
|
|
3790
4006
|
{
|
|
4007
|
+
ref: containerRef,
|
|
3791
4008
|
className,
|
|
3792
4009
|
$orientation: orientation,
|
|
3793
4010
|
"data-meter-orientation": orientation,
|
|
@@ -3795,32 +4012,55 @@ var SegmentedVUMeterInner = ({
|
|
|
3795
4012
|
renderChannel(0),
|
|
3796
4013
|
showScale && renderScale()
|
|
3797
4014
|
]
|
|
3798
|
-
}
|
|
4015
|
+
},
|
|
4016
|
+
sourceKey
|
|
3799
4017
|
);
|
|
3800
4018
|
};
|
|
3801
4019
|
var SegmentedVUMeter = React21.memo(SegmentedVUMeterInner);
|
|
3802
4020
|
|
|
3803
|
-
// src/
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
4021
|
+
// src/hooks/useThrottledValue.ts
|
|
4022
|
+
import { useEffect as useEffect7, useState as useState5 } from "react";
|
|
4023
|
+
var DEFAULT_UPDATE_RATE = 10;
|
|
4024
|
+
function useThrottledValue(source, options = {}) {
|
|
4025
|
+
const { updateRate = DEFAULT_UPDATE_RATE } = options;
|
|
4026
|
+
const [state, setState] = useState5(() => ({
|
|
4027
|
+
source,
|
|
4028
|
+
value: source.getSnapshot()
|
|
4029
|
+
}));
|
|
4030
|
+
useEffect7(() => {
|
|
4031
|
+
const interval = 1e3 / (updateRate > 0 ? updateRate : 1);
|
|
4032
|
+
let lastUpdate = -Infinity;
|
|
4033
|
+
let timer = null;
|
|
4034
|
+
const flush = () => {
|
|
4035
|
+
timer = null;
|
|
4036
|
+
lastUpdate = performance.now();
|
|
4037
|
+
const value = source.getSnapshot();
|
|
4038
|
+
setState(
|
|
4039
|
+
(prev) => prev.source === source && prev.value === value ? prev : { source, value }
|
|
4040
|
+
);
|
|
4041
|
+
};
|
|
4042
|
+
const unsubscribe = source.subscribe(() => {
|
|
4043
|
+
if (timer !== null) return;
|
|
4044
|
+
const wait = interval - (performance.now() - lastUpdate);
|
|
4045
|
+
if (wait <= 0) {
|
|
4046
|
+
flush();
|
|
4047
|
+
} else {
|
|
4048
|
+
timer = setTimeout(flush, wait);
|
|
4049
|
+
}
|
|
4050
|
+
});
|
|
4051
|
+
flush();
|
|
4052
|
+
lastUpdate = -Infinity;
|
|
4053
|
+
return () => {
|
|
4054
|
+
unsubscribe();
|
|
4055
|
+
if (timer !== null) clearTimeout(timer);
|
|
4056
|
+
};
|
|
4057
|
+
}, [source, updateRate]);
|
|
4058
|
+
return state.source === source ? state.value : source.getSnapshot();
|
|
3818
4059
|
}
|
|
3819
|
-
function
|
|
3820
|
-
return
|
|
4060
|
+
function useMeterLevels(meter, options = {}) {
|
|
4061
|
+
return useThrottledValue(meter, options);
|
|
3821
4062
|
}
|
|
3822
4063
|
export {
|
|
3823
|
-
AudioPosition,
|
|
3824
4064
|
AutomaticScrollCheckbox,
|
|
3825
4065
|
BaseButton,
|
|
3826
4066
|
BaseCheckbox,
|
|
@@ -3844,9 +4084,14 @@ export {
|
|
|
3844
4084
|
ClipBoundary,
|
|
3845
4085
|
ClipHeader,
|
|
3846
4086
|
ClipHeaderPresentational,
|
|
4087
|
+
ClipPlaceholderBody,
|
|
3847
4088
|
ClipViewportOriginProvider,
|
|
3848
4089
|
CloseButton,
|
|
3849
4090
|
Controls,
|
|
4091
|
+
DEFAULT_BAR_GAP,
|
|
4092
|
+
DEFAULT_BAR_WIDTH,
|
|
4093
|
+
DEFAULT_PLAYBACK_RATES,
|
|
4094
|
+
DEFAULT_WAVE_HEIGHT,
|
|
3850
4095
|
DevicePixelRatioProvider,
|
|
3851
4096
|
DotsIcon,
|
|
3852
4097
|
FadeOverlay,
|
|
@@ -3859,12 +4104,12 @@ export {
|
|
|
3859
4104
|
MoveDownIcon,
|
|
3860
4105
|
MoveUpIcon,
|
|
3861
4106
|
PianoRollChannel,
|
|
4107
|
+
PlaybackRateSelect,
|
|
3862
4108
|
Playhead,
|
|
3863
4109
|
PlayheadWithMarker,
|
|
3864
4110
|
Playlist,
|
|
3865
4111
|
PlaylistErrorBoundary,
|
|
3866
4112
|
PlaylistInfoContext,
|
|
3867
|
-
PlayoutProvider,
|
|
3868
4113
|
ReorderRail,
|
|
3869
4114
|
ScreenReaderOnly,
|
|
3870
4115
|
ScrollViewportProvider,
|
|
@@ -3884,7 +4129,6 @@ export {
|
|
|
3884
4129
|
TimeScale,
|
|
3885
4130
|
TimescaleLoopRegion,
|
|
3886
4131
|
Track,
|
|
3887
|
-
TrackControlsContext,
|
|
3888
4132
|
TrackMenu,
|
|
3889
4133
|
TrashIcon,
|
|
3890
4134
|
VolumeDownIcon,
|
|
@@ -3895,22 +4139,15 @@ export {
|
|
|
3895
4139
|
getScaleInfo,
|
|
3896
4140
|
isWaveformGradient,
|
|
3897
4141
|
parseTime,
|
|
3898
|
-
pixelsToSamples,
|
|
3899
|
-
pixelsToSeconds,
|
|
3900
|
-
samplesToPixels2 as samplesToPixels,
|
|
3901
|
-
samplesToSeconds,
|
|
3902
|
-
secondsToPixels2 as secondsToPixels,
|
|
3903
|
-
secondsToSamples,
|
|
3904
4142
|
useBeatsAndBars,
|
|
3905
4143
|
useClipViewportOrigin,
|
|
3906
4144
|
useDevicePixelRatio,
|
|
4145
|
+
useMeterLevels,
|
|
3907
4146
|
usePlaylistInfo,
|
|
3908
|
-
usePlayoutStatus,
|
|
3909
|
-
usePlayoutStatusUpdate,
|
|
3910
4147
|
useScrollViewport,
|
|
3911
4148
|
useScrollViewportSelector,
|
|
3912
4149
|
useTheme2 as useTheme,
|
|
3913
|
-
|
|
4150
|
+
useThrottledValue,
|
|
3914
4151
|
useVisibleChunkIndices,
|
|
3915
4152
|
waveformColorToCss
|
|
3916
4153
|
};
|