@waveform-playlist/ui-components 14.0.0 → 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 +11 -11
package/dist/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.tsx
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
AudioPosition: () => AudioPosition,
|
|
34
33
|
AutomaticScrollCheckbox: () => AutomaticScrollCheckbox,
|
|
35
34
|
BaseButton: () => BaseButton,
|
|
36
35
|
BaseCheckbox: () => BaseCheckbox,
|
|
@@ -54,9 +53,14 @@ __export(index_exports, {
|
|
|
54
53
|
ClipBoundary: () => ClipBoundary,
|
|
55
54
|
ClipHeader: () => ClipHeader,
|
|
56
55
|
ClipHeaderPresentational: () => ClipHeaderPresentational,
|
|
56
|
+
ClipPlaceholderBody: () => ClipPlaceholderBody,
|
|
57
57
|
ClipViewportOriginProvider: () => ClipViewportOriginProvider,
|
|
58
58
|
CloseButton: () => CloseButton,
|
|
59
59
|
Controls: () => Controls,
|
|
60
|
+
DEFAULT_BAR_GAP: () => DEFAULT_BAR_GAP,
|
|
61
|
+
DEFAULT_BAR_WIDTH: () => DEFAULT_BAR_WIDTH,
|
|
62
|
+
DEFAULT_PLAYBACK_RATES: () => DEFAULT_PLAYBACK_RATES,
|
|
63
|
+
DEFAULT_WAVE_HEIGHT: () => DEFAULT_WAVE_HEIGHT,
|
|
60
64
|
DevicePixelRatioProvider: () => DevicePixelRatioProvider,
|
|
61
65
|
DotsIcon: () => DotsIcon,
|
|
62
66
|
FadeOverlay: () => FadeOverlay,
|
|
@@ -69,12 +73,12 @@ __export(index_exports, {
|
|
|
69
73
|
MoveDownIcon: () => MoveDownIcon,
|
|
70
74
|
MoveUpIcon: () => MoveUpIcon,
|
|
71
75
|
PianoRollChannel: () => PianoRollChannel,
|
|
76
|
+
PlaybackRateSelect: () => PlaybackRateSelect,
|
|
72
77
|
Playhead: () => Playhead,
|
|
73
78
|
PlayheadWithMarker: () => PlayheadWithMarker,
|
|
74
79
|
Playlist: () => Playlist,
|
|
75
80
|
PlaylistErrorBoundary: () => PlaylistErrorBoundary,
|
|
76
81
|
PlaylistInfoContext: () => PlaylistInfoContext,
|
|
77
|
-
PlayoutProvider: () => PlayoutProvider,
|
|
78
82
|
ReorderRail: () => ReorderRail,
|
|
79
83
|
ScreenReaderOnly: () => ScreenReaderOnly,
|
|
80
84
|
ScrollViewportProvider: () => ScrollViewportProvider,
|
|
@@ -94,7 +98,6 @@ __export(index_exports, {
|
|
|
94
98
|
TimeScale: () => TimeScale,
|
|
95
99
|
TimescaleLoopRegion: () => TimescaleLoopRegion,
|
|
96
100
|
Track: () => Track,
|
|
97
|
-
TrackControlsContext: () => TrackControlsContext,
|
|
98
101
|
TrackMenu: () => TrackMenu,
|
|
99
102
|
TrashIcon: () => TrashIcon,
|
|
100
103
|
VolumeDownIcon: () => VolumeDownIcon,
|
|
@@ -105,44 +108,26 @@ __export(index_exports, {
|
|
|
105
108
|
getScaleInfo: () => getScaleInfo,
|
|
106
109
|
isWaveformGradient: () => isWaveformGradient,
|
|
107
110
|
parseTime: () => parseTime,
|
|
108
|
-
pixelsToSamples: () => pixelsToSamples,
|
|
109
|
-
pixelsToSeconds: () => pixelsToSeconds,
|
|
110
|
-
samplesToPixels: () => samplesToPixels2,
|
|
111
|
-
samplesToSeconds: () => samplesToSeconds,
|
|
112
|
-
secondsToPixels: () => secondsToPixels2,
|
|
113
|
-
secondsToSamples: () => secondsToSamples,
|
|
114
111
|
useBeatsAndBars: () => useBeatsAndBars,
|
|
115
112
|
useClipViewportOrigin: () => useClipViewportOrigin,
|
|
116
113
|
useDevicePixelRatio: () => useDevicePixelRatio,
|
|
114
|
+
useMeterLevels: () => useMeterLevels,
|
|
117
115
|
usePlaylistInfo: () => usePlaylistInfo,
|
|
118
|
-
usePlayoutStatus: () => usePlayoutStatus,
|
|
119
|
-
usePlayoutStatusUpdate: () => usePlayoutStatusUpdate,
|
|
120
116
|
useScrollViewport: () => useScrollViewport,
|
|
121
117
|
useScrollViewportSelector: () => useScrollViewportSelector,
|
|
122
118
|
useTheme: () => useTheme2,
|
|
123
|
-
|
|
119
|
+
useThrottledValue: () => useThrottledValue,
|
|
124
120
|
useVisibleChunkIndices: () => useVisibleChunkIndices,
|
|
125
121
|
waveformColorToCss: () => waveformColorToCss
|
|
126
122
|
});
|
|
127
123
|
module.exports = __toCommonJS(index_exports);
|
|
128
124
|
|
|
129
|
-
// src/components/
|
|
130
|
-
var
|
|
131
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
132
|
-
var PositionDisplay = import_styled_components.default.span`
|
|
133
|
-
font-family: 'Courier New', Monaco, monospace;
|
|
134
|
-
font-size: 1rem;
|
|
135
|
-
font-weight: 600;
|
|
136
|
-
color: ${(props) => props.theme?.textColor || "#333"};
|
|
137
|
-
user-select: none;
|
|
138
|
-
`;
|
|
139
|
-
var AudioPosition = ({ formattedTime, className }) => {
|
|
140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PositionDisplay, { className, "aria-label": "Audio position", children: formattedTime });
|
|
141
|
-
};
|
|
125
|
+
// src/components/AutomaticScrollCheckbox.tsx
|
|
126
|
+
var import_react = require("react");
|
|
142
127
|
|
|
143
128
|
// src/styled/BaseButton.tsx
|
|
144
|
-
var
|
|
145
|
-
var BaseButton =
|
|
129
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
130
|
+
var BaseButton = import_styled_components.default.button`
|
|
146
131
|
display: inline-flex;
|
|
147
132
|
align-items: center;
|
|
148
133
|
justify-content: center;
|
|
@@ -174,16 +159,16 @@ var BaseButton = import_styled_components2.default.button`
|
|
|
174
159
|
cursor: not-allowed;
|
|
175
160
|
}
|
|
176
161
|
`;
|
|
177
|
-
var BaseButtonSmall = (0,
|
|
162
|
+
var BaseButtonSmall = (0, import_styled_components.default)(BaseButton)`
|
|
178
163
|
padding: 0.25rem 0.5rem;
|
|
179
164
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
180
165
|
`;
|
|
181
|
-
var IconButton = (0,
|
|
166
|
+
var IconButton = (0, import_styled_components.default)(BaseButton)`
|
|
182
167
|
padding: 0.5rem;
|
|
183
168
|
min-width: 2.25rem;
|
|
184
169
|
min-height: 2.25rem;
|
|
185
170
|
`;
|
|
186
|
-
var IconButtonSmall = (0,
|
|
171
|
+
var IconButtonSmall = (0, import_styled_components.default)(BaseButton)`
|
|
187
172
|
padding: 0.25rem;
|
|
188
173
|
min-width: 1.75rem;
|
|
189
174
|
min-height: 1.75rem;
|
|
@@ -191,13 +176,13 @@ var IconButtonSmall = (0, import_styled_components2.default)(BaseButton)`
|
|
|
191
176
|
`;
|
|
192
177
|
|
|
193
178
|
// src/styled/BaseCheckbox.tsx
|
|
194
|
-
var
|
|
195
|
-
var BaseCheckboxWrapper =
|
|
179
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
180
|
+
var BaseCheckboxWrapper = import_styled_components2.default.div`
|
|
196
181
|
display: inline-flex;
|
|
197
182
|
align-items: center;
|
|
198
183
|
gap: 0.5rem;
|
|
199
184
|
`;
|
|
200
|
-
var BaseCheckbox =
|
|
185
|
+
var BaseCheckbox = import_styled_components2.default.input`
|
|
201
186
|
cursor: pointer;
|
|
202
187
|
accent-color: ${(props) => props.theme.inputFocusBorder};
|
|
203
188
|
|
|
@@ -205,7 +190,7 @@ var BaseCheckbox = import_styled_components3.default.input`
|
|
|
205
190
|
cursor: not-allowed;
|
|
206
191
|
}
|
|
207
192
|
`;
|
|
208
|
-
var BaseCheckboxLabel =
|
|
193
|
+
var BaseCheckboxLabel = import_styled_components2.default.label`
|
|
209
194
|
margin: 0;
|
|
210
195
|
cursor: pointer;
|
|
211
196
|
user-select: none;
|
|
@@ -215,8 +200,8 @@ var BaseCheckboxLabel = import_styled_components3.default.label`
|
|
|
215
200
|
`;
|
|
216
201
|
|
|
217
202
|
// src/styled/BaseControlButton.tsx
|
|
218
|
-
var
|
|
219
|
-
var BaseControlButton =
|
|
203
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
204
|
+
var BaseControlButton = import_styled_components3.default.button`
|
|
220
205
|
padding: 0.5rem 1rem;
|
|
221
206
|
background: ${(props) => props.theme.buttonBackground || "#007bff"};
|
|
222
207
|
color: ${(props) => props.theme.buttonText || "white"};
|
|
@@ -245,8 +230,8 @@ var BaseControlButton = import_styled_components4.default.button`
|
|
|
245
230
|
`;
|
|
246
231
|
|
|
247
232
|
// src/styled/BaseInput.tsx
|
|
248
|
-
var
|
|
249
|
-
var BaseInput =
|
|
233
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
234
|
+
var BaseInput = import_styled_components4.default.input`
|
|
250
235
|
padding: 0.5rem 0.75rem;
|
|
251
236
|
font-family: ${(props) => props.theme.fontFamily};
|
|
252
237
|
font-size: ${(props) => props.theme.fontSize};
|
|
@@ -273,14 +258,14 @@ var BaseInput = import_styled_components5.default.input`
|
|
|
273
258
|
cursor: not-allowed;
|
|
274
259
|
}
|
|
275
260
|
`;
|
|
276
|
-
var BaseInputSmall = (0,
|
|
261
|
+
var BaseInputSmall = (0, import_styled_components4.default)(BaseInput)`
|
|
277
262
|
padding: 0.25rem 0.5rem;
|
|
278
263
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
279
264
|
`;
|
|
280
265
|
|
|
281
266
|
// src/styled/BaseLabel.tsx
|
|
282
|
-
var
|
|
283
|
-
var BaseLabel =
|
|
267
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
268
|
+
var BaseLabel = import_styled_components5.default.label`
|
|
284
269
|
font-family: ${(props) => props.theme.fontFamily};
|
|
285
270
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
286
271
|
font-weight: 500;
|
|
@@ -288,7 +273,7 @@ var BaseLabel = import_styled_components6.default.label`
|
|
|
288
273
|
margin-bottom: 0.25rem;
|
|
289
274
|
display: block;
|
|
290
275
|
`;
|
|
291
|
-
var InlineLabel =
|
|
276
|
+
var InlineLabel = import_styled_components5.default.label`
|
|
292
277
|
font-family: ${(props) => props.theme.fontFamily};
|
|
293
278
|
font-size: ${(props) => props.theme.fontSize};
|
|
294
279
|
color: ${(props) => props.theme.textColor};
|
|
@@ -297,7 +282,7 @@ var InlineLabel = import_styled_components6.default.label`
|
|
|
297
282
|
gap: 0.5rem;
|
|
298
283
|
cursor: pointer;
|
|
299
284
|
`;
|
|
300
|
-
var ScreenReaderOnly =
|
|
285
|
+
var ScreenReaderOnly = import_styled_components5.default.span`
|
|
301
286
|
position: absolute;
|
|
302
287
|
width: 1px;
|
|
303
288
|
height: 1px;
|
|
@@ -310,8 +295,8 @@ var ScreenReaderOnly = import_styled_components6.default.span`
|
|
|
310
295
|
`;
|
|
311
296
|
|
|
312
297
|
// src/styled/BaseSelect.tsx
|
|
313
|
-
var
|
|
314
|
-
var BaseSelect =
|
|
298
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
299
|
+
var BaseSelect = import_styled_components6.default.select`
|
|
315
300
|
padding: 0.5rem 2rem 0.5rem 0.75rem;
|
|
316
301
|
font-family: ${(props) => props.theme.fontFamily};
|
|
317
302
|
font-size: ${(props) => props.theme.fontSize};
|
|
@@ -345,14 +330,14 @@ var BaseSelect = import_styled_components7.default.select`
|
|
|
345
330
|
background-color: ${(props) => props.theme.inputBackground};
|
|
346
331
|
}
|
|
347
332
|
`;
|
|
348
|
-
var BaseSelectSmall = (0,
|
|
333
|
+
var BaseSelectSmall = (0, import_styled_components6.default)(BaseSelect)`
|
|
349
334
|
padding: 0.25rem 1.75rem 0.25rem 0.5rem;
|
|
350
335
|
font-size: ${(props) => props.theme.fontSizeSmall};
|
|
351
336
|
`;
|
|
352
337
|
|
|
353
338
|
// src/styled/BaseSlider.tsx
|
|
354
|
-
var
|
|
355
|
-
var BaseSlider =
|
|
339
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
340
|
+
var BaseSlider = import_styled_components7.default.input.attrs({ type: "range" })`
|
|
356
341
|
-webkit-appearance: none;
|
|
357
342
|
appearance: none;
|
|
358
343
|
width: 100%;
|
|
@@ -435,35 +420,36 @@ var BaseSlider = import_styled_components8.default.input.attrs({ type: "range" }
|
|
|
435
420
|
`;
|
|
436
421
|
|
|
437
422
|
// src/components/AutomaticScrollCheckbox.tsx
|
|
438
|
-
var
|
|
423
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
439
424
|
var AutomaticScrollCheckbox = ({
|
|
440
425
|
checked,
|
|
441
426
|
onChange,
|
|
442
427
|
disabled = false,
|
|
443
428
|
className
|
|
444
429
|
}) => {
|
|
430
|
+
const id = (0, import_react.useId)();
|
|
445
431
|
const handleChange = (e) => {
|
|
446
432
|
onChange(e.target.checked);
|
|
447
433
|
};
|
|
448
|
-
return /* @__PURE__ */ (0,
|
|
449
|
-
/* @__PURE__ */ (0,
|
|
434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(BaseCheckboxWrapper, { className, children: [
|
|
435
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
436
|
BaseCheckbox,
|
|
451
437
|
{
|
|
452
438
|
type: "checkbox",
|
|
453
|
-
id
|
|
439
|
+
id,
|
|
454
440
|
className: "automatic-scroll",
|
|
455
441
|
checked,
|
|
456
442
|
onChange: handleChange,
|
|
457
443
|
disabled
|
|
458
444
|
}
|
|
459
445
|
),
|
|
460
|
-
/* @__PURE__ */ (0,
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseCheckboxLabel, { htmlFor: id, children: "Automatic Scroll" })
|
|
461
447
|
] });
|
|
462
448
|
};
|
|
463
449
|
|
|
464
450
|
// src/components/Channel.tsx
|
|
465
|
-
var
|
|
466
|
-
var
|
|
451
|
+
var import_react6 = require("react");
|
|
452
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
467
453
|
|
|
468
454
|
// src/wfpl-theme.ts
|
|
469
455
|
function isWaveformGradient(color) {
|
|
@@ -540,10 +526,12 @@ var defaultTheme = {
|
|
|
540
526
|
annotationResizeHandleColor: "rgba(0, 0, 0, 0.4)",
|
|
541
527
|
annotationResizeHandleActiveColor: "rgba(0, 0, 0, 0.8)",
|
|
542
528
|
annotationTextItemHoverBackground: "rgba(0, 0, 0, 0.03)",
|
|
529
|
+
annotationTextItemActiveColor: "#ff9800",
|
|
543
530
|
// Piano roll colors
|
|
544
531
|
pianoRollNoteColor: "#2a7070",
|
|
545
532
|
pianoRollSelectedNoteColor: "#3d9e9e",
|
|
546
533
|
pianoRollBackgroundColor: "#1a1a2e",
|
|
534
|
+
spectrogramBackgroundColor: "#000",
|
|
547
535
|
// Spacing and sizing
|
|
548
536
|
borderRadius: "4px",
|
|
549
537
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',
|
|
@@ -617,16 +605,18 @@ var darkTheme = {
|
|
|
617
605
|
annotationBoxBackground: "rgba(40, 32, 24, 0.9)",
|
|
618
606
|
annotationBoxActiveBackground: "rgba(50, 40, 30, 0.95)",
|
|
619
607
|
annotationBoxHoverBackground: "rgba(60, 48, 36, 0.98)",
|
|
620
|
-
annotationBoxBorder: "#
|
|
608
|
+
annotationBoxBorder: "#ff9800",
|
|
621
609
|
annotationBoxActiveBorder: "#d4a87c",
|
|
622
610
|
annotationLabelColor: "#d8c0a8",
|
|
623
611
|
annotationResizeHandleColor: "rgba(200, 160, 120, 0.5)",
|
|
624
612
|
annotationResizeHandleActiveColor: "rgba(220, 180, 140, 0.8)",
|
|
625
613
|
annotationTextItemHoverBackground: "rgba(200, 160, 120, 0.08)",
|
|
614
|
+
annotationTextItemActiveColor: "#ff9800",
|
|
626
615
|
// Piano roll colors
|
|
627
616
|
pianoRollNoteColor: "#c49a6c",
|
|
628
617
|
pianoRollSelectedNoteColor: "#e8c090",
|
|
629
618
|
pianoRollBackgroundColor: "#0d0d14",
|
|
619
|
+
spectrogramBackgroundColor: "#000",
|
|
630
620
|
// Spacing and sizing
|
|
631
621
|
borderRadius: "4px",
|
|
632
622
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif',
|
|
@@ -635,8 +625,8 @@ var darkTheme = {
|
|
|
635
625
|
};
|
|
636
626
|
|
|
637
627
|
// src/contexts/ScrollViewport.tsx
|
|
638
|
-
var
|
|
639
|
-
var
|
|
628
|
+
var import_react2 = require("react");
|
|
629
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
640
630
|
var ViewportStore = class {
|
|
641
631
|
constructor(containerEl) {
|
|
642
632
|
this._listeners = /* @__PURE__ */ new Set();
|
|
@@ -689,33 +679,33 @@ var ViewportStore = class {
|
|
|
689
679
|
}
|
|
690
680
|
}
|
|
691
681
|
};
|
|
692
|
-
var ViewportStoreContext = (0,
|
|
682
|
+
var ViewportStoreContext = (0, import_react2.createContext)(null);
|
|
693
683
|
var EMPTY_SUBSCRIBE = () => () => {
|
|
694
684
|
};
|
|
695
685
|
var NULL_SNAPSHOT = () => null;
|
|
696
686
|
var ScrollViewportProvider = ({ containerRef, children }) => {
|
|
697
|
-
const storeRef = (0,
|
|
687
|
+
const storeRef = (0, import_react2.useRef)(null);
|
|
698
688
|
if (storeRef.current === null) {
|
|
699
689
|
storeRef.current = new ViewportStore(containerRef.current);
|
|
700
690
|
}
|
|
701
691
|
const store = storeRef.current;
|
|
702
|
-
const rafIdRef = (0,
|
|
703
|
-
const measure = (0,
|
|
692
|
+
const rafIdRef = (0, import_react2.useRef)(null);
|
|
693
|
+
const measure = (0, import_react2.useCallback)(() => {
|
|
704
694
|
const el = containerRef.current;
|
|
705
695
|
if (!el) return;
|
|
706
696
|
store.update(el.scrollLeft, el.clientWidth);
|
|
707
697
|
}, [containerRef, store]);
|
|
708
|
-
const scheduleUpdate = (0,
|
|
698
|
+
const scheduleUpdate = (0, import_react2.useCallback)(() => {
|
|
709
699
|
if (rafIdRef.current !== null) return;
|
|
710
700
|
rafIdRef.current = requestAnimationFrame(() => {
|
|
711
701
|
rafIdRef.current = null;
|
|
712
702
|
measure();
|
|
713
703
|
});
|
|
714
704
|
}, [measure]);
|
|
715
|
-
(0,
|
|
705
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
716
706
|
measure();
|
|
717
707
|
}, [measure]);
|
|
718
|
-
(0,
|
|
708
|
+
(0, import_react2.useEffect)(() => {
|
|
719
709
|
const el = containerRef.current;
|
|
720
710
|
if (!el) return;
|
|
721
711
|
el.addEventListener("scroll", scheduleUpdate, { passive: true });
|
|
@@ -733,19 +723,19 @@ var ScrollViewportProvider = ({ containerRef, children }) => {
|
|
|
733
723
|
store.cancelPendingNotification();
|
|
734
724
|
};
|
|
735
725
|
}, [containerRef, scheduleUpdate, store]);
|
|
736
|
-
return /* @__PURE__ */ (0,
|
|
726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ViewportStoreContext, { value: store, children });
|
|
737
727
|
};
|
|
738
728
|
var useScrollViewport = () => {
|
|
739
|
-
const store = (0,
|
|
740
|
-
return (0,
|
|
729
|
+
const store = (0, import_react2.use)(ViewportStoreContext);
|
|
730
|
+
return (0, import_react2.useSyncExternalStore)(
|
|
741
731
|
store ? store.subscribe : EMPTY_SUBSCRIBE,
|
|
742
732
|
store ? store.getSnapshot : NULL_SNAPSHOT,
|
|
743
733
|
NULL_SNAPSHOT
|
|
744
734
|
);
|
|
745
735
|
};
|
|
746
736
|
function useScrollViewportSelector(selector) {
|
|
747
|
-
const store = (0,
|
|
748
|
-
return (0,
|
|
737
|
+
const store = (0, import_react2.use)(ViewportStoreContext);
|
|
738
|
+
return (0, import_react2.useSyncExternalStore)(
|
|
749
739
|
store ? store.subscribe : EMPTY_SUBSCRIBE,
|
|
750
740
|
() => selector(store ? store.getSnapshot() : null),
|
|
751
741
|
() => selector(null)
|
|
@@ -769,33 +759,33 @@ function useVisibleChunkIndices(totalWidth, chunkWidth, originX = 0) {
|
|
|
769
759
|
}
|
|
770
760
|
return indices.join(",");
|
|
771
761
|
});
|
|
772
|
-
return (0,
|
|
762
|
+
return (0, import_react2.useMemo)(
|
|
773
763
|
() => visibleChunkKey ? visibleChunkKey.split(",").map(Number) : [],
|
|
774
764
|
[visibleChunkKey]
|
|
775
765
|
);
|
|
776
766
|
}
|
|
777
767
|
|
|
778
768
|
// src/contexts/ClipViewportOrigin.tsx
|
|
779
|
-
var
|
|
780
|
-
var
|
|
781
|
-
var ClipViewportOriginContext = (0,
|
|
769
|
+
var import_react3 = require("react");
|
|
770
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
771
|
+
var ClipViewportOriginContext = (0, import_react3.createContext)(0);
|
|
782
772
|
var ClipViewportOriginProvider = ({
|
|
783
773
|
originX,
|
|
784
774
|
children
|
|
785
|
-
}) => /* @__PURE__ */ (0,
|
|
786
|
-
var useClipViewportOrigin = () => (0,
|
|
775
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ClipViewportOriginContext, { value: originX, children });
|
|
776
|
+
var useClipViewportOrigin = () => (0, import_react3.use)(ClipViewportOriginContext);
|
|
787
777
|
|
|
788
778
|
// src/hooks/useChunkedCanvasRefs.ts
|
|
789
|
-
var
|
|
779
|
+
var import_react4 = require("react");
|
|
790
780
|
function useChunkedCanvasRefs() {
|
|
791
|
-
const canvasMapRef = (0,
|
|
792
|
-
const canvasRef = (0,
|
|
781
|
+
const canvasMapRef = (0, import_react4.useRef)(/* @__PURE__ */ new Map());
|
|
782
|
+
const canvasRef = (0, import_react4.useCallback)((canvas) => {
|
|
793
783
|
if (canvas !== null) {
|
|
794
784
|
const idx = parseInt(canvas.dataset.index, 10);
|
|
795
785
|
canvasMapRef.current.set(idx, canvas);
|
|
796
786
|
}
|
|
797
787
|
}, []);
|
|
798
|
-
(0,
|
|
788
|
+
(0, import_react4.useEffect)(() => {
|
|
799
789
|
const map = canvasMapRef.current;
|
|
800
790
|
for (const [idx, canvas] of map.entries()) {
|
|
801
791
|
if (!canvas.isConnected) {
|
|
@@ -806,6 +796,18 @@ function useChunkedCanvasRefs() {
|
|
|
806
796
|
return { canvasRef, canvasMapRef };
|
|
807
797
|
}
|
|
808
798
|
|
|
799
|
+
// src/hooks/useIdentityVersion.ts
|
|
800
|
+
var import_react5 = require("react");
|
|
801
|
+
function useIdentityVersion(value) {
|
|
802
|
+
const versionRef = (0, import_react5.useRef)(0);
|
|
803
|
+
const previousRef = (0, import_react5.useRef)(value);
|
|
804
|
+
if (previousRef.current !== value) {
|
|
805
|
+
versionRef.current += 1;
|
|
806
|
+
previousRef.current = value;
|
|
807
|
+
}
|
|
808
|
+
return versionRef.current;
|
|
809
|
+
}
|
|
810
|
+
|
|
809
811
|
// src/components/Channel.tsx
|
|
810
812
|
var import_core = require("@waveform-playlist/core");
|
|
811
813
|
|
|
@@ -826,6 +828,19 @@ function aggregatePeaks(data, bits, startIndex, endIndex) {
|
|
|
826
828
|
}
|
|
827
829
|
return { min: minPeak, max: maxPeak };
|
|
828
830
|
}
|
|
831
|
+
function clampToFullScale(value) {
|
|
832
|
+
return Math.max(-1, Math.min(1, value));
|
|
833
|
+
}
|
|
834
|
+
function scalePeakByGain(peak, gain) {
|
|
835
|
+
if (gain === 1 || !Number.isFinite(gain)) {
|
|
836
|
+
return peak;
|
|
837
|
+
}
|
|
838
|
+
const factor = Math.abs(gain);
|
|
839
|
+
return {
|
|
840
|
+
min: clampToFullScale(peak.min * factor),
|
|
841
|
+
max: clampToFullScale(peak.max * factor)
|
|
842
|
+
};
|
|
843
|
+
}
|
|
829
844
|
function calculateBarRects(x, barWidth, halfHeight, minPeak, maxPeak, drawMode) {
|
|
830
845
|
const min = Math.abs(minPeak * halfHeight);
|
|
831
846
|
const max = Math.abs(maxPeak * halfHeight);
|
|
@@ -847,9 +862,13 @@ function addBarToPath(ctx, rect, radius) {
|
|
|
847
862
|
function calculateFirstBarPosition(canvasStartGlobal, barWidth, step) {
|
|
848
863
|
return Math.floor((canvasStartGlobal - barWidth + step) / step) * step;
|
|
849
864
|
}
|
|
865
|
+
function barStep(barWidth, barGap) {
|
|
866
|
+
const step = barWidth + barGap;
|
|
867
|
+
return step >= 1 ? step : 1;
|
|
868
|
+
}
|
|
850
869
|
|
|
851
870
|
// src/components/Channel.tsx
|
|
852
|
-
var
|
|
871
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
853
872
|
function createCanvasFillStyle(ctx, color, width, height) {
|
|
854
873
|
if (!isWaveformGradient(color)) {
|
|
855
874
|
return color;
|
|
@@ -865,7 +884,7 @@ function createCanvasFillStyle(ctx, color, width, height) {
|
|
|
865
884
|
}
|
|
866
885
|
return gradient;
|
|
867
886
|
}
|
|
868
|
-
var Waveform =
|
|
887
|
+
var Waveform = import_styled_components8.default.canvas.attrs((props) => ({
|
|
869
888
|
style: {
|
|
870
889
|
width: `${props.$cssWidth}px`,
|
|
871
890
|
height: `${props.$waveHeight}px`,
|
|
@@ -878,7 +897,7 @@ var Waveform = import_styled_components9.default.canvas.attrs((props) => ({
|
|
|
878
897
|
image-rendering: pixelated;
|
|
879
898
|
image-rendering: crisp-edges;
|
|
880
899
|
`;
|
|
881
|
-
var Wrapper =
|
|
900
|
+
var Wrapper = import_styled_components8.default.div.attrs((props) => ({
|
|
882
901
|
style: {
|
|
883
902
|
top: `${props.$waveHeight * props.$index}px`,
|
|
884
903
|
width: `${props.$cssWidth}px`,
|
|
@@ -905,21 +924,17 @@ var Channel = (props) => {
|
|
|
905
924
|
barWidth = 1,
|
|
906
925
|
barGap = 0,
|
|
907
926
|
roundedBars = false,
|
|
927
|
+
gain = 1,
|
|
908
928
|
transparentBackground = false,
|
|
909
929
|
drawMode = "inverted"
|
|
910
930
|
} = props;
|
|
911
931
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
912
932
|
const clipOriginX = useClipViewportOrigin();
|
|
913
933
|
const visibleChunkIndices = useVisibleChunkIndices(length, import_core.MAX_CANVAS_WIDTH, clipOriginX);
|
|
914
|
-
const
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
prevDataRef.current = data;
|
|
919
|
-
}
|
|
920
|
-
const drawVersion = `${dataVersionRef.current}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${roundedBars}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
|
|
921
|
-
(0, import_react4.useLayoutEffect)(() => {
|
|
922
|
-
const step = barWidth + barGap;
|
|
934
|
+
const dataVersion = useIdentityVersion(data);
|
|
935
|
+
const drawVersion = `${dataVersion}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${roundedBars}-${gain}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
|
|
936
|
+
(0, import_react6.useLayoutEffect)(() => {
|
|
937
|
+
const step = barStep(barWidth, barGap);
|
|
923
938
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
924
939
|
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
925
940
|
const globalPixelOffset = canvasIdx * import_core.MAX_CANVAS_WIDTH;
|
|
@@ -954,8 +969,9 @@ var Channel = (props) => {
|
|
|
954
969
|
const x = barGlobal - canvasStartGlobal;
|
|
955
970
|
if (x + barWidth <= 0) continue;
|
|
956
971
|
const peakEnd = Math.min(barGlobal + step, length);
|
|
957
|
-
const
|
|
958
|
-
if (
|
|
972
|
+
const sourcePeak = aggregatePeaks(data, bits, barGlobal, peakEnd);
|
|
973
|
+
if (sourcePeak) {
|
|
974
|
+
const peak = scalePeakByGain(sourcePeak, gain);
|
|
959
975
|
const rects = calculateBarRects(x, barWidth, h2, peak.min, peak.max, rectMode);
|
|
960
976
|
for (const rect of rects) {
|
|
961
977
|
if (roundedBars) {
|
|
@@ -986,6 +1002,7 @@ var Channel = (props) => {
|
|
|
986
1002
|
barWidth,
|
|
987
1003
|
barGap,
|
|
988
1004
|
roundedBars,
|
|
1005
|
+
gain,
|
|
989
1006
|
drawVersion,
|
|
990
1007
|
drawMode,
|
|
991
1008
|
visibleChunkIndices,
|
|
@@ -994,7 +1011,7 @@ var Channel = (props) => {
|
|
|
994
1011
|
const waveforms = visibleChunkIndices.map((i) => {
|
|
995
1012
|
const chunkLeft = i * import_core.MAX_CANVAS_WIDTH;
|
|
996
1013
|
const currentWidth = Math.min(length - chunkLeft, import_core.MAX_CANVAS_WIDTH);
|
|
997
|
-
return /* @__PURE__ */ (0,
|
|
1014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
998
1015
|
Waveform,
|
|
999
1016
|
{
|
|
1000
1017
|
$cssWidth: currentWidth,
|
|
@@ -1010,7 +1027,7 @@ var Channel = (props) => {
|
|
|
1010
1027
|
});
|
|
1011
1028
|
const bgColor = waveFillColor;
|
|
1012
1029
|
const backgroundCss = transparentBackground ? "transparent" : waveformColorToCss(bgColor);
|
|
1013
|
-
return /* @__PURE__ */ (0,
|
|
1030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1014
1031
|
Wrapper,
|
|
1015
1032
|
{
|
|
1016
1033
|
$index: index,
|
|
@@ -1024,8 +1041,8 @@ var Channel = (props) => {
|
|
|
1024
1041
|
};
|
|
1025
1042
|
|
|
1026
1043
|
// src/components/ErrorBoundary.tsx
|
|
1027
|
-
var
|
|
1028
|
-
var
|
|
1044
|
+
var import_react7 = __toESM(require("react"));
|
|
1045
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1029
1046
|
var errorContainerStyle = {
|
|
1030
1047
|
padding: "16px",
|
|
1031
1048
|
background: "#1a1a2e",
|
|
@@ -1039,7 +1056,7 @@ var errorContainerStyle = {
|
|
|
1039
1056
|
alignItems: "center",
|
|
1040
1057
|
justifyContent: "center"
|
|
1041
1058
|
};
|
|
1042
|
-
var PlaylistErrorBoundary = class extends
|
|
1059
|
+
var PlaylistErrorBoundary = class extends import_react7.default.Component {
|
|
1043
1060
|
constructor(props) {
|
|
1044
1061
|
super(props);
|
|
1045
1062
|
this.state = { hasError: false, error: null };
|
|
@@ -1055,22 +1072,22 @@ var PlaylistErrorBoundary = class extends import_react5.default.Component {
|
|
|
1055
1072
|
if (this.props.fallback) {
|
|
1056
1073
|
return this.props.fallback;
|
|
1057
1074
|
}
|
|
1058
|
-
return /* @__PURE__ */ (0,
|
|
1075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: errorContainerStyle, children: "Waveform playlist encountered an error. Check console for details." });
|
|
1059
1076
|
}
|
|
1060
1077
|
return this.props.children;
|
|
1061
1078
|
}
|
|
1062
1079
|
};
|
|
1063
1080
|
|
|
1064
1081
|
// src/components/Clip.tsx
|
|
1065
|
-
var
|
|
1066
|
-
var
|
|
1082
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
1083
|
+
var import_react9 = require("@dnd-kit/react");
|
|
1067
1084
|
var import_dom = require("@dnd-kit/dom");
|
|
1068
1085
|
|
|
1069
1086
|
// src/components/ClipHeader.tsx
|
|
1070
|
-
var
|
|
1071
|
-
var
|
|
1087
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
1088
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1072
1089
|
var CLIP_HEADER_HEIGHT = 22;
|
|
1073
|
-
var HeaderContainer =
|
|
1090
|
+
var HeaderContainer = import_styled_components9.default.div`
|
|
1074
1091
|
position: relative;
|
|
1075
1092
|
height: ${CLIP_HEADER_HEIGHT}px;
|
|
1076
1093
|
background: ${(props) => props.$isSelected ? props.theme.selectedClipHeaderBackgroundColor : props.theme.clipHeaderBackgroundColor};
|
|
@@ -1095,7 +1112,7 @@ var HeaderContainer = import_styled_components10.default.div`
|
|
|
1095
1112
|
}
|
|
1096
1113
|
`}
|
|
1097
1114
|
`;
|
|
1098
|
-
var TrackName =
|
|
1115
|
+
var TrackName = import_styled_components9.default.span`
|
|
1099
1116
|
font-size: 11px;
|
|
1100
1117
|
font-weight: 600;
|
|
1101
1118
|
font-family: ${(props) => props.theme.clipHeaderFontFamily};
|
|
@@ -1108,7 +1125,7 @@ var ClipHeaderPresentational = ({
|
|
|
1108
1125
|
trackName,
|
|
1109
1126
|
isSelected = false
|
|
1110
1127
|
}) => {
|
|
1111
|
-
return /* @__PURE__ */ (0,
|
|
1128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HeaderContainer, { $interactive: false, $isSelected: isSelected, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TrackName, { title: trackName, children: trackName }) });
|
|
1112
1129
|
};
|
|
1113
1130
|
var ClipHeader = ({
|
|
1114
1131
|
clipId,
|
|
@@ -1120,28 +1137,27 @@ var ClipHeader = ({
|
|
|
1120
1137
|
dragHandleProps
|
|
1121
1138
|
}) => {
|
|
1122
1139
|
if (disableDrag || !dragHandleProps) {
|
|
1123
|
-
return /* @__PURE__ */ (0,
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClipHeaderPresentational, { trackName, isSelected });
|
|
1124
1141
|
}
|
|
1125
1142
|
const { handleRef } = dragHandleProps;
|
|
1126
|
-
return /* @__PURE__ */ (0,
|
|
1143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1127
1144
|
HeaderContainer,
|
|
1128
1145
|
{
|
|
1129
1146
|
ref: handleRef,
|
|
1130
1147
|
"data-clip-id": clipId,
|
|
1131
1148
|
$interactive: true,
|
|
1132
1149
|
$isSelected: isSelected,
|
|
1133
|
-
children: /* @__PURE__ */ (0,
|
|
1150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TrackName, { title: trackName, children: trackName })
|
|
1134
1151
|
}
|
|
1135
1152
|
);
|
|
1136
1153
|
};
|
|
1137
1154
|
|
|
1138
1155
|
// src/components/ClipBoundary.tsx
|
|
1139
|
-
var
|
|
1140
|
-
var
|
|
1141
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1156
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
1157
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1142
1158
|
var CLIP_BOUNDARY_WIDTH = 8;
|
|
1143
1159
|
var CLIP_BOUNDARY_WIDTH_TOUCH = 24;
|
|
1144
|
-
var BoundaryContainer =
|
|
1160
|
+
var BoundaryContainer = import_styled_components10.default.div`
|
|
1145
1161
|
position: absolute;
|
|
1146
1162
|
${(props) => props.$edge === "left" ? "left: 0;" : "right: 0;"}
|
|
1147
1163
|
top: 0;
|
|
@@ -1153,10 +1169,10 @@ var BoundaryContainer = import_styled_components11.default.div`
|
|
|
1153
1169
|
pointer-events: auto; /* Re-enable pointer events (parent ClipContainer has pointer-events: none) */
|
|
1154
1170
|
touch-action: none; /* Prevent browser scroll during drag on touch devices */
|
|
1155
1171
|
|
|
1156
|
-
/* Invisible by default
|
|
1157
|
-
background: ${(props) => props.$isDragging ? "rgba(255, 255, 255, 0.4)" :
|
|
1172
|
+
/* Invisible by default; the :hover and :active rules below make it visible */
|
|
1173
|
+
background: ${(props) => props.$isDragging ? "rgba(255, 255, 255, 0.4)" : "transparent"};
|
|
1158
1174
|
|
|
1159
|
-
${(props) => props.$edge === "left" ? `border-left: 2px solid ${props.$isDragging ? "rgba(255, 255, 255, 0.8)" :
|
|
1175
|
+
${(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"};`}
|
|
1160
1176
|
|
|
1161
1177
|
transition: background 0.15s ease, border-color 0.15s ease;
|
|
1162
1178
|
|
|
@@ -1178,12 +1194,11 @@ var ClipBoundary = ({
|
|
|
1178
1194
|
dragHandleProps,
|
|
1179
1195
|
touchOptimized = false
|
|
1180
1196
|
}) => {
|
|
1181
|
-
const [isHovered, setIsHovered] = import_react6.default.useState(false);
|
|
1182
1197
|
if (!dragHandleProps) {
|
|
1183
1198
|
return null;
|
|
1184
1199
|
}
|
|
1185
1200
|
const { ref: boundaryRef, isDragging } = dragHandleProps;
|
|
1186
|
-
return /* @__PURE__ */ (0,
|
|
1201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1187
1202
|
BoundaryContainer,
|
|
1188
1203
|
{
|
|
1189
1204
|
ref: boundaryRef,
|
|
@@ -1191,18 +1206,16 @@ var ClipBoundary = ({
|
|
|
1191
1206
|
"data-boundary-edge": edge,
|
|
1192
1207
|
$edge: edge,
|
|
1193
1208
|
$isDragging: isDragging,
|
|
1194
|
-
$
|
|
1195
|
-
$touchOptimized: touchOptimized,
|
|
1196
|
-
onMouseEnter: () => setIsHovered(true),
|
|
1197
|
-
onMouseLeave: () => setIsHovered(false)
|
|
1209
|
+
$touchOptimized: touchOptimized
|
|
1198
1210
|
}
|
|
1199
1211
|
);
|
|
1200
1212
|
};
|
|
1201
1213
|
|
|
1202
1214
|
// src/components/FadeOverlay.tsx
|
|
1203
|
-
var
|
|
1204
|
-
var
|
|
1205
|
-
var
|
|
1215
|
+
var import_react8 = require("react");
|
|
1216
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
1217
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1218
|
+
var FadeContainer = import_styled_components11.default.div.attrs((props) => ({
|
|
1206
1219
|
style: {
|
|
1207
1220
|
left: `${props.$left}px`,
|
|
1208
1221
|
width: `${props.$width}px`
|
|
@@ -1214,13 +1227,17 @@ var FadeContainer = import_styled_components12.default.div.attrs((props) => ({
|
|
|
1214
1227
|
pointer-events: none;
|
|
1215
1228
|
z-index: 50;
|
|
1216
1229
|
`;
|
|
1217
|
-
var FadeSvg =
|
|
1230
|
+
var FadeSvg = import_styled_components11.default.svg`
|
|
1218
1231
|
width: 100%;
|
|
1219
1232
|
height: 100%;
|
|
1220
1233
|
display: block;
|
|
1221
1234
|
/* Flip horizontally for fadeOut - makes it mirror of fadeIn */
|
|
1222
1235
|
transform: ${(props) => props.$type === "fadeOut" ? "scaleX(-1)" : "none"};
|
|
1223
1236
|
`;
|
|
1237
|
+
var FADE_PATH_HEIGHT = 100;
|
|
1238
|
+
function round2(value) {
|
|
1239
|
+
return Math.round(value * 100) / 100;
|
|
1240
|
+
}
|
|
1224
1241
|
function generateFadePath(width, height, curveType = "logarithmic") {
|
|
1225
1242
|
const points = [];
|
|
1226
1243
|
const numPoints = Math.max(20, Math.min(width, 100));
|
|
@@ -1244,7 +1261,7 @@ function generateFadePath(width, height, curveType = "logarithmic") {
|
|
|
1244
1261
|
break;
|
|
1245
1262
|
}
|
|
1246
1263
|
const y = (1 - curvedProgress) * height;
|
|
1247
|
-
points.push(`${x},${y}`);
|
|
1264
|
+
points.push(`${round2(x)},${round2(y)}`);
|
|
1248
1265
|
}
|
|
1249
1266
|
return `M 0,${height} L ${points.join(" L ")} L ${width},0 L 0,0 Z`;
|
|
1250
1267
|
}
|
|
@@ -1255,18 +1272,43 @@ var FadeOverlay = ({
|
|
|
1255
1272
|
curveType = "logarithmic",
|
|
1256
1273
|
color
|
|
1257
1274
|
}) => {
|
|
1258
|
-
const theme = (0,
|
|
1275
|
+
const theme = (0, import_styled_components11.useTheme)();
|
|
1276
|
+
const path = (0, import_react8.useMemo)(
|
|
1277
|
+
() => width < 1 ? "" : generateFadePath(width, FADE_PATH_HEIGHT, curveType),
|
|
1278
|
+
[width, curveType]
|
|
1279
|
+
);
|
|
1259
1280
|
if (width < 1) return null;
|
|
1260
1281
|
const fillColor = color || theme?.fadeOverlayColor || "rgba(0, 0, 0, 0.4)";
|
|
1261
|
-
return /* @__PURE__ */ (0,
|
|
1282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FadeContainer, { $left: left, $width: width, $type: type, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FadeSvg, { $type: type, viewBox: `0 0 ${width} ${FADE_PATH_HEIGHT}`, preserveAspectRatio: "none", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: path, fill: fillColor }) }) });
|
|
1262
1283
|
};
|
|
1263
1284
|
|
|
1264
1285
|
// src/components/Clip.tsx
|
|
1265
1286
|
var import_core2 = require("@waveform-playlist/core");
|
|
1266
|
-
var
|
|
1287
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1288
|
+
var DEFAULT_PLACEHOLDER_CLIP_OPACITY = 0.5;
|
|
1289
|
+
function placeholderOpacity(theme) {
|
|
1290
|
+
const value = theme?.placeholderClipOpacity;
|
|
1291
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1 ? value : DEFAULT_PLACEHOLDER_CLIP_OPACITY;
|
|
1292
|
+
}
|
|
1267
1293
|
var CLIP_MOVE_PLUGINS = [import_dom.Feedback.configure({ dropAnimation: null })];
|
|
1268
1294
|
var TRIM_HANDLE_PLUGINS = [import_dom.Feedback.configure({ feedback: "none" })];
|
|
1269
|
-
|
|
1295
|
+
function clipDraggableIds(trackId, clipId, trackIndex, clipIndex) {
|
|
1296
|
+
if (trackId === void 0) {
|
|
1297
|
+
const at = `${trackIndex}-${clipIndex}`;
|
|
1298
|
+
return {
|
|
1299
|
+
move: `clip-${at}`,
|
|
1300
|
+
left: `clip-boundary-left-${at}`,
|
|
1301
|
+
right: `clip-boundary-right-${at}`
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
const key = `${encodeURIComponent(trackId)}/${encodeURIComponent(clipId)}`;
|
|
1305
|
+
return {
|
|
1306
|
+
move: `clip/${key}`,
|
|
1307
|
+
left: `clip-boundary-left/${key}`,
|
|
1308
|
+
right: `clip-boundary-right/${key}`
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
var ClipContainer = import_styled_components12.default.div.attrs((props) => ({
|
|
1270
1312
|
style: props.$isOverlay ? {} : {
|
|
1271
1313
|
left: `${props.$left}px`,
|
|
1272
1314
|
width: `${props.$width}px`
|
|
@@ -1280,8 +1322,11 @@ var ClipContainer = import_styled_components13.default.div.attrs((props) => ({
|
|
|
1280
1322
|
flex-direction: column;
|
|
1281
1323
|
z-index: 10; /* Above progress overlay (z-index: 2) but below controls/playhead */
|
|
1282
1324
|
pointer-events: none; /* Let clicks pass through to ClickOverlay for playhead positioning */
|
|
1325
|
+
${(props) => props.$isPlaceholder ? import_styled_components12.css`
|
|
1326
|
+
opacity: ${placeholderOpacity(props.theme)};
|
|
1327
|
+
` : ""}
|
|
1283
1328
|
`;
|
|
1284
|
-
var ChannelsWrapper =
|
|
1329
|
+
var ChannelsWrapper = import_styled_components12.default.div`
|
|
1285
1330
|
flex: 1;
|
|
1286
1331
|
position: relative;
|
|
1287
1332
|
overflow: ${(props) => props.$isOverlay ? "visible" : "hidden"};
|
|
@@ -1306,38 +1351,38 @@ var Clip = ({
|
|
|
1306
1351
|
fadeOut,
|
|
1307
1352
|
sampleRate = 44100,
|
|
1308
1353
|
showFades = false,
|
|
1309
|
-
touchOptimized = false
|
|
1354
|
+
touchOptimized = false,
|
|
1355
|
+
isPlaceholder = false
|
|
1310
1356
|
}) => {
|
|
1311
1357
|
const left = Math.floor(startSample / samplesPerPixel);
|
|
1312
1358
|
const width = (0, import_core2.clipPixelWidth)(startSample, durationSamples, samplesPerPixel);
|
|
1313
|
-
const
|
|
1314
|
-
const
|
|
1359
|
+
const headerDragDisabled = disableHeaderDrag || isPlaceholder;
|
|
1360
|
+
const enableDrag = showHeader && !headerDragDisabled && !isOverlay;
|
|
1361
|
+
const ids = clipDraggableIds(trackId, clipId, trackIndex, clipIndex);
|
|
1315
1362
|
const {
|
|
1316
1363
|
ref: clipRef,
|
|
1317
1364
|
handleRef,
|
|
1318
1365
|
isDragSource
|
|
1319
|
-
} = (0,
|
|
1320
|
-
id:
|
|
1366
|
+
} = (0, import_react9.useDraggable)({
|
|
1367
|
+
id: ids.move,
|
|
1321
1368
|
data: { clipId, trackIndex, clipIndex, startSample, durationSamples },
|
|
1322
1369
|
disabled: !enableDrag,
|
|
1323
1370
|
plugins: CLIP_MOVE_PLUGINS
|
|
1324
1371
|
});
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1327
|
-
id: leftBoundaryId,
|
|
1372
|
+
const { ref: leftBoundaryRef, isDragSource: isLeftBoundaryDragging } = (0, import_react9.useDraggable)({
|
|
1373
|
+
id: ids.left,
|
|
1328
1374
|
data: { clipId, trackIndex, clipIndex, boundary: "left", startSample, durationSamples },
|
|
1329
1375
|
disabled: !enableDrag,
|
|
1330
1376
|
plugins: TRIM_HANDLE_PLUGINS
|
|
1331
1377
|
});
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
id: rightBoundaryId,
|
|
1378
|
+
const { ref: rightBoundaryRef, isDragSource: isRightBoundaryDragging } = (0, import_react9.useDraggable)({
|
|
1379
|
+
id: ids.right,
|
|
1335
1380
|
data: { clipId, trackIndex, clipIndex, boundary: "right", startSample, durationSamples },
|
|
1336
1381
|
disabled: !enableDrag,
|
|
1337
1382
|
plugins: TRIM_HANDLE_PLUGINS
|
|
1338
1383
|
});
|
|
1339
1384
|
const style = isDragSource ? { zIndex: 100 } : void 0;
|
|
1340
|
-
return /* @__PURE__ */ (0,
|
|
1385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1341
1386
|
ClipContainer,
|
|
1342
1387
|
{
|
|
1343
1388
|
ref: clipRef,
|
|
@@ -1346,12 +1391,14 @@ var Clip = ({
|
|
|
1346
1391
|
$left: left,
|
|
1347
1392
|
$width: width,
|
|
1348
1393
|
$isOverlay: isOverlay,
|
|
1394
|
+
$isPlaceholder: isPlaceholder,
|
|
1349
1395
|
"data-clip-container": "true",
|
|
1396
|
+
"data-clip-placeholder": isPlaceholder ? "true" : void 0,
|
|
1350
1397
|
"data-track-id": trackId,
|
|
1351
1398
|
onMouseDown,
|
|
1352
1399
|
tabIndex: -1,
|
|
1353
1400
|
children: [
|
|
1354
|
-
showHeader && /* @__PURE__ */ (0,
|
|
1401
|
+
showHeader && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1355
1402
|
ClipHeader,
|
|
1356
1403
|
{
|
|
1357
1404
|
clipId,
|
|
@@ -1359,13 +1406,13 @@ var Clip = ({
|
|
|
1359
1406
|
clipIndex,
|
|
1360
1407
|
trackName,
|
|
1361
1408
|
isSelected,
|
|
1362
|
-
disableDrag:
|
|
1409
|
+
disableDrag: headerDragDisabled,
|
|
1363
1410
|
dragHandleProps: enableDrag ? { handleRef } : void 0
|
|
1364
1411
|
}
|
|
1365
1412
|
),
|
|
1366
|
-
/* @__PURE__ */ (0,
|
|
1413
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ClipViewportOriginProvider, { originX: left, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ChannelsWrapper, { $isOverlay: isOverlay, children: [
|
|
1367
1414
|
children,
|
|
1368
|
-
showFades && fadeIn && fadeIn.duration > 0 && /* @__PURE__ */ (0,
|
|
1415
|
+
showFades && fadeIn && fadeIn.duration > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1369
1416
|
FadeOverlay,
|
|
1370
1417
|
{
|
|
1371
1418
|
left: 0,
|
|
@@ -1374,7 +1421,7 @@ var Clip = ({
|
|
|
1374
1421
|
curveType: fadeIn.type
|
|
1375
1422
|
}
|
|
1376
1423
|
),
|
|
1377
|
-
showFades && fadeOut && fadeOut.duration > 0 && /* @__PURE__ */ (0,
|
|
1424
|
+
showFades && fadeOut && fadeOut.duration > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1378
1425
|
FadeOverlay,
|
|
1379
1426
|
{
|
|
1380
1427
|
left: width - Math.floor(fadeOut.duration * sampleRate / samplesPerPixel),
|
|
@@ -1384,8 +1431,8 @@ var Clip = ({
|
|
|
1384
1431
|
}
|
|
1385
1432
|
)
|
|
1386
1433
|
] }) }),
|
|
1387
|
-
showHeader && !
|
|
1388
|
-
/* @__PURE__ */ (0,
|
|
1434
|
+
showHeader && !headerDragDisabled && !isOverlay && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1389
1436
|
ClipBoundary,
|
|
1390
1437
|
{
|
|
1391
1438
|
clipId,
|
|
@@ -1399,7 +1446,7 @@ var Clip = ({
|
|
|
1399
1446
|
}
|
|
1400
1447
|
}
|
|
1401
1448
|
),
|
|
1402
|
-
/* @__PURE__ */ (0,
|
|
1449
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1403
1450
|
ClipBoundary,
|
|
1404
1451
|
{
|
|
1405
1452
|
clipId,
|
|
@@ -1419,19 +1466,133 @@ var Clip = ({
|
|
|
1419
1466
|
);
|
|
1420
1467
|
};
|
|
1421
1468
|
|
|
1422
|
-
// src/components/
|
|
1469
|
+
// src/components/ClipPlaceholderBody.tsx
|
|
1423
1470
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
1471
|
+
|
|
1472
|
+
// src/contexts/BeatsAndBars.tsx
|
|
1473
|
+
var import_react10 = require("react");
|
|
1474
|
+
var import_core3 = require("@waveform-playlist/core");
|
|
1475
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1476
|
+
var BeatsAndBarsContext = (0, import_react10.createContext)(null);
|
|
1477
|
+
function BeatsAndBarsProvider({
|
|
1478
|
+
bpm,
|
|
1479
|
+
timeSignature,
|
|
1480
|
+
snapTo,
|
|
1481
|
+
scaleMode = "beats",
|
|
1482
|
+
children
|
|
1483
|
+
}) {
|
|
1484
|
+
const [numerator, denominator] = timeSignature;
|
|
1485
|
+
const value = (0, import_react10.useMemo)(() => {
|
|
1486
|
+
const ts = [numerator, denominator];
|
|
1487
|
+
const tpBeat = (0, import_core3.ticksPerBeat)(ts);
|
|
1488
|
+
const tpBar = (0, import_core3.ticksPerBar)(ts);
|
|
1489
|
+
return {
|
|
1490
|
+
bpm,
|
|
1491
|
+
timeSignature: ts,
|
|
1492
|
+
snapTo,
|
|
1493
|
+
scaleMode,
|
|
1494
|
+
ticksPerBeat: tpBeat,
|
|
1495
|
+
ticksPerBar: tpBar
|
|
1496
|
+
};
|
|
1497
|
+
}, [bpm, numerator, denominator, snapTo, scaleMode]);
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BeatsAndBarsContext, { value, children });
|
|
1499
|
+
}
|
|
1500
|
+
function useBeatsAndBars() {
|
|
1501
|
+
return (0, import_react10.use)(BeatsAndBarsContext);
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// src/contexts/DevicePixelRatio.tsx
|
|
1505
|
+
var import_react11 = require("react");
|
|
1424
1506
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1425
|
-
|
|
1507
|
+
function getScale() {
|
|
1508
|
+
return typeof window === "undefined" ? 1 : window.devicePixelRatio;
|
|
1509
|
+
}
|
|
1510
|
+
var DevicePixelRatioContext = (0, import_react11.createContext)(null);
|
|
1511
|
+
var DevicePixelRatioProvider = ({ children }) => {
|
|
1512
|
+
const [scale, setScale] = (0, import_react11.useState)(getScale);
|
|
1513
|
+
(0, import_react11.useEffect)(() => {
|
|
1514
|
+
const current = getScale();
|
|
1515
|
+
if (current !== scale) {
|
|
1516
|
+
setScale(current);
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
if (typeof matchMedia !== "function") return;
|
|
1520
|
+
const query = matchMedia(`(resolution: ${scale}dppx)`);
|
|
1521
|
+
const handleChange = () => setScale(getScale());
|
|
1522
|
+
query.addEventListener("change", handleChange);
|
|
1523
|
+
return () => query.removeEventListener("change", handleChange);
|
|
1524
|
+
}, [scale]);
|
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DevicePixelRatioContext, { value: Math.ceil(scale), children });
|
|
1526
|
+
};
|
|
1527
|
+
var useDevicePixelRatio = () => (0, import_react11.use)(DevicePixelRatioContext) ?? getScale();
|
|
1528
|
+
|
|
1529
|
+
// src/contexts/PlaylistInfo.tsx
|
|
1530
|
+
var import_react12 = require("react");
|
|
1531
|
+
var DEFAULT_WAVE_HEIGHT = 80;
|
|
1532
|
+
var DEFAULT_BAR_WIDTH = 1;
|
|
1533
|
+
var DEFAULT_BAR_GAP = 0;
|
|
1534
|
+
var PlaylistInfoContext = (0, import_react12.createContext)({
|
|
1535
|
+
sampleRate: 48e3,
|
|
1536
|
+
samplesPerPixel: 1e3,
|
|
1537
|
+
waveHeight: DEFAULT_WAVE_HEIGHT,
|
|
1538
|
+
timeScaleHeight: 15,
|
|
1539
|
+
barWidth: DEFAULT_BAR_WIDTH,
|
|
1540
|
+
barGap: DEFAULT_BAR_GAP,
|
|
1541
|
+
roundedBars: false,
|
|
1542
|
+
progressBarWidth: DEFAULT_BAR_WIDTH + DEFAULT_BAR_GAP
|
|
1543
|
+
});
|
|
1544
|
+
var usePlaylistInfo = () => (0, import_react12.use)(PlaylistInfoContext);
|
|
1545
|
+
|
|
1546
|
+
// src/contexts/Theme.tsx
|
|
1547
|
+
var import_react13 = require("react");
|
|
1548
|
+
var import_styled_components13 = require("styled-components");
|
|
1549
|
+
var useTheme2 = () => (0, import_react13.use)(import_styled_components13.ThemeContext);
|
|
1550
|
+
|
|
1551
|
+
// src/components/ClipPlaceholderBody.tsx
|
|
1552
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1553
|
+
var FALLBACK_BODY_COLOR = "grey";
|
|
1554
|
+
function colorToCss(color) {
|
|
1555
|
+
if (typeof color === "string") return color === "" ? void 0 : color;
|
|
1556
|
+
const gradient = color;
|
|
1557
|
+
if (isWaveformGradient(gradient) && Array.isArray(gradient.stops)) {
|
|
1558
|
+
return waveformColorToCss(gradient);
|
|
1559
|
+
}
|
|
1560
|
+
return void 0;
|
|
1561
|
+
}
|
|
1562
|
+
function barColor(theme, isSelected) {
|
|
1563
|
+
const selected = isSelected ? colorToCss(theme?.selectedWaveFillColor) : void 0;
|
|
1564
|
+
return selected ?? colorToCss(theme?.waveFillColor) ?? FALLBACK_BODY_COLOR;
|
|
1565
|
+
}
|
|
1566
|
+
var Body = import_styled_components14.default.div.attrs((props) => ({
|
|
1567
|
+
style: { background: props.$color }
|
|
1568
|
+
}))`
|
|
1569
|
+
position: absolute;
|
|
1570
|
+
top: 0;
|
|
1571
|
+
left: 0;
|
|
1572
|
+
width: 100%;
|
|
1573
|
+
height: 100%;
|
|
1574
|
+
`;
|
|
1575
|
+
var ClipPlaceholderBody = ({
|
|
1576
|
+
isSelected = false
|
|
1577
|
+
}) => {
|
|
1578
|
+
const theme = useTheme2();
|
|
1579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Body, { $color: barColor(theme, isSelected), "data-clip-placeholder-body": "true" });
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
// src/components/MasterVolumeControl.tsx
|
|
1583
|
+
var import_react14 = require("react");
|
|
1584
|
+
var import_styled_components15 = __toESM(require("styled-components"));
|
|
1585
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1586
|
+
var VolumeContainer = import_styled_components15.default.div`
|
|
1426
1587
|
display: inline-flex;
|
|
1427
1588
|
align-items: center;
|
|
1428
1589
|
gap: 0.5rem;
|
|
1429
1590
|
`;
|
|
1430
|
-
var VolumeLabel = (0,
|
|
1591
|
+
var VolumeLabel = (0, import_styled_components15.default)(BaseLabel)`
|
|
1431
1592
|
margin: 0;
|
|
1432
1593
|
white-space: nowrap;
|
|
1433
1594
|
`;
|
|
1434
|
-
var VolumeSlider = (0,
|
|
1595
|
+
var VolumeSlider = (0, import_styled_components15.default)(BaseSlider)`
|
|
1435
1596
|
width: 120px;
|
|
1436
1597
|
`;
|
|
1437
1598
|
var MasterVolumeControl = ({
|
|
@@ -1440,12 +1601,13 @@ var MasterVolumeControl = ({
|
|
|
1440
1601
|
disabled = false,
|
|
1441
1602
|
className
|
|
1442
1603
|
}) => {
|
|
1604
|
+
const id = (0, import_react14.useId)();
|
|
1443
1605
|
const handleChange = (e) => {
|
|
1444
1606
|
onChange(parseFloat(e.target.value) / 100);
|
|
1445
1607
|
};
|
|
1446
|
-
return /* @__PURE__ */ (0,
|
|
1447
|
-
/* @__PURE__ */ (0,
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
1608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(VolumeContainer, { className, children: [
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VolumeLabel, { htmlFor: id, children: "Master Volume" }),
|
|
1610
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1449
1611
|
VolumeSlider,
|
|
1450
1612
|
{
|
|
1451
1613
|
min: "0",
|
|
@@ -1453,18 +1615,18 @@ var MasterVolumeControl = ({
|
|
|
1453
1615
|
value: volume * 100,
|
|
1454
1616
|
onChange: handleChange,
|
|
1455
1617
|
disabled,
|
|
1456
|
-
id
|
|
1618
|
+
id
|
|
1457
1619
|
}
|
|
1458
1620
|
)
|
|
1459
1621
|
] });
|
|
1460
1622
|
};
|
|
1461
1623
|
|
|
1462
1624
|
// src/components/PianoRollChannel.tsx
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1465
|
-
var
|
|
1466
|
-
var
|
|
1467
|
-
var NoteCanvas =
|
|
1625
|
+
var import_react15 = require("react");
|
|
1626
|
+
var import_styled_components16 = __toESM(require("styled-components"));
|
|
1627
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
1628
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1629
|
+
var NoteCanvas = import_styled_components16.default.canvas.attrs((props) => ({
|
|
1468
1630
|
style: {
|
|
1469
1631
|
width: `${props.$cssWidth}px`,
|
|
1470
1632
|
height: `${props.$waveHeight}px`,
|
|
@@ -1476,7 +1638,7 @@ var NoteCanvas = import_styled_components15.default.canvas.attrs((props) => ({
|
|
|
1476
1638
|
image-rendering: pixelated;
|
|
1477
1639
|
image-rendering: crisp-edges;
|
|
1478
1640
|
`;
|
|
1479
|
-
var Wrapper2 =
|
|
1641
|
+
var Wrapper2 = import_styled_components16.default.div.attrs((props) => ({
|
|
1480
1642
|
style: {
|
|
1481
1643
|
top: `${props.$waveHeight * props.$index}px`,
|
|
1482
1644
|
width: `${props.$cssWidth}px`,
|
|
@@ -1505,8 +1667,8 @@ var PianoRollChannel = ({
|
|
|
1505
1667
|
}) => {
|
|
1506
1668
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
1507
1669
|
const clipOriginX = useClipViewportOrigin();
|
|
1508
|
-
const visibleChunkIndices = useVisibleChunkIndices(length,
|
|
1509
|
-
const { minMidi, maxMidi } = (0,
|
|
1670
|
+
const visibleChunkIndices = useVisibleChunkIndices(length, import_core4.MAX_CANVAS_WIDTH, clipOriginX);
|
|
1671
|
+
const { minMidi, maxMidi } = (0, import_react15.useMemo)(() => {
|
|
1510
1672
|
if (midiNotes.length === 0) return { minMidi: 0, maxMidi: 127 };
|
|
1511
1673
|
let min = 127, max = 0;
|
|
1512
1674
|
for (const note of midiNotes) {
|
|
@@ -1516,12 +1678,15 @@ var PianoRollChannel = ({
|
|
|
1516
1678
|
return { minMidi: Math.max(0, min - 1), maxMidi: Math.min(127, max + 1) };
|
|
1517
1679
|
}, [midiNotes]);
|
|
1518
1680
|
const color = isSelected ? selectedNoteColor : noteColor;
|
|
1519
|
-
|
|
1681
|
+
const notesVersion = useIdentityVersion(midiNotes);
|
|
1682
|
+
const drawVersion = `${notesVersion}-${waveHeight}-${devicePixelRatio}-${samplesPerPixel}-${sampleRate}-${clipOffsetSeconds}-${color}-${minMidi}-${maxMidi}-${length}`;
|
|
1683
|
+
(0, import_react15.useLayoutEffect)(() => {
|
|
1520
1684
|
const noteRange = maxMidi - minMidi + 1;
|
|
1521
1685
|
const noteHeight = Math.max(2, waveHeight / noteRange);
|
|
1522
1686
|
const pixelsPerSecond = sampleRate / samplesPerPixel;
|
|
1523
1687
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
1524
|
-
|
|
1688
|
+
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
1689
|
+
const chunkPixelStart = canvasIdx * import_core4.MAX_CANVAS_WIDTH;
|
|
1525
1690
|
const canvasWidth = canvas.width / devicePixelRatio;
|
|
1526
1691
|
const ctx = canvas.getContext("2d");
|
|
1527
1692
|
if (!ctx) continue;
|
|
@@ -1547,6 +1712,7 @@ var PianoRollChannel = ({
|
|
|
1547
1712
|
ctx.fill();
|
|
1548
1713
|
}
|
|
1549
1714
|
ctx.globalAlpha = 1;
|
|
1715
|
+
canvas.dataset.drawVersion = drawVersion;
|
|
1550
1716
|
}
|
|
1551
1717
|
}, [
|
|
1552
1718
|
canvasMapRef,
|
|
@@ -1561,12 +1727,13 @@ var PianoRollChannel = ({
|
|
|
1561
1727
|
maxMidi,
|
|
1562
1728
|
length,
|
|
1563
1729
|
visibleChunkIndices,
|
|
1564
|
-
index
|
|
1730
|
+
index,
|
|
1731
|
+
drawVersion
|
|
1565
1732
|
]);
|
|
1566
1733
|
const canvases = visibleChunkIndices.map((i) => {
|
|
1567
|
-
const chunkLeft = i *
|
|
1568
|
-
const currentWidth = Math.min(length - chunkLeft,
|
|
1569
|
-
return /* @__PURE__ */ (0,
|
|
1734
|
+
const chunkLeft = i * import_core4.MAX_CANVAS_WIDTH;
|
|
1735
|
+
const currentWidth = Math.min(length - chunkLeft, import_core4.MAX_CANVAS_WIDTH);
|
|
1736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1570
1737
|
NoteCanvas,
|
|
1571
1738
|
{
|
|
1572
1739
|
$cssWidth: currentWidth,
|
|
@@ -1581,14 +1748,24 @@ var PianoRollChannel = ({
|
|
|
1581
1748
|
);
|
|
1582
1749
|
});
|
|
1583
1750
|
const bgColor = transparentBackground ? "transparent" : backgroundColor;
|
|
1584
|
-
return /* @__PURE__ */ (0,
|
|
1751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1752
|
+
Wrapper2,
|
|
1753
|
+
{
|
|
1754
|
+
"data-piano-roll": "",
|
|
1755
|
+
$index: index,
|
|
1756
|
+
$cssWidth: length,
|
|
1757
|
+
$waveHeight: waveHeight,
|
|
1758
|
+
$backgroundColor: bgColor,
|
|
1759
|
+
children: canvases
|
|
1760
|
+
}
|
|
1761
|
+
);
|
|
1585
1762
|
};
|
|
1586
1763
|
|
|
1587
1764
|
// src/components/Playhead.tsx
|
|
1588
|
-
var
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
1591
|
-
var PlayheadLine =
|
|
1765
|
+
var import_react16 = require("react");
|
|
1766
|
+
var import_styled_components17 = __toESM(require("styled-components"));
|
|
1767
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1768
|
+
var PlayheadLine = import_styled_components17.default.div.attrs((props) => ({
|
|
1592
1769
|
style: {
|
|
1593
1770
|
transform: `translate3d(${props.$position}px, 0, 0)`
|
|
1594
1771
|
}
|
|
@@ -1604,9 +1781,9 @@ var PlayheadLine = import_styled_components16.default.div.attrs((props) => ({
|
|
|
1604
1781
|
will-change: transform;
|
|
1605
1782
|
`;
|
|
1606
1783
|
var Playhead = ({ position, color = "#ff0000" }) => {
|
|
1607
|
-
return /* @__PURE__ */ (0,
|
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PlayheadLine, { $position: position, $color: color });
|
|
1608
1785
|
};
|
|
1609
|
-
var PlayheadWithMarkerContainer =
|
|
1786
|
+
var PlayheadWithMarkerContainer = import_styled_components17.default.div`
|
|
1610
1787
|
position: absolute;
|
|
1611
1788
|
top: 0;
|
|
1612
1789
|
left: 0;
|
|
@@ -1615,7 +1792,7 @@ var PlayheadWithMarkerContainer = import_styled_components16.default.div`
|
|
|
1615
1792
|
pointer-events: none;
|
|
1616
1793
|
will-change: transform;
|
|
1617
1794
|
`;
|
|
1618
|
-
var MarkerTriangle =
|
|
1795
|
+
var MarkerTriangle = import_styled_components17.default.div`
|
|
1619
1796
|
position: absolute;
|
|
1620
1797
|
top: -10px;
|
|
1621
1798
|
left: -6px;
|
|
@@ -1625,7 +1802,7 @@ var MarkerTriangle = import_styled_components16.default.div`
|
|
|
1625
1802
|
border-right: 7px solid transparent;
|
|
1626
1803
|
border-top: 10px solid ${(props) => props.$color};
|
|
1627
1804
|
`;
|
|
1628
|
-
var MarkerLine =
|
|
1805
|
+
var MarkerLine = import_styled_components17.default.div`
|
|
1629
1806
|
position: absolute;
|
|
1630
1807
|
top: 0;
|
|
1631
1808
|
left: 0;
|
|
@@ -1638,35 +1815,16 @@ var PlayheadWithMarker = ({
|
|
|
1638
1815
|
isPlaying,
|
|
1639
1816
|
currentTimeRef,
|
|
1640
1817
|
visualTimeRef,
|
|
1641
|
-
playbackStartTimeRef,
|
|
1642
|
-
audioStartPositionRef,
|
|
1643
1818
|
samplesPerPixel,
|
|
1644
|
-
sampleRate
|
|
1645
|
-
controlsOffset = 0,
|
|
1646
|
-
getAudioContextTime,
|
|
1647
|
-
getPlaybackTime
|
|
1819
|
+
sampleRate
|
|
1648
1820
|
}) => {
|
|
1649
|
-
const containerRef = (0,
|
|
1650
|
-
const animationFrameRef = (0,
|
|
1651
|
-
(0,
|
|
1821
|
+
const containerRef = (0, import_react16.useRef)(null);
|
|
1822
|
+
const animationFrameRef = (0, import_react16.useRef)(null);
|
|
1823
|
+
(0, import_react16.useEffect)(() => {
|
|
1652
1824
|
const updatePosition = () => {
|
|
1653
1825
|
if (containerRef.current) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
time = visualTimeRef.current;
|
|
1657
|
-
} else if (isPlaying) {
|
|
1658
|
-
if (getPlaybackTime) {
|
|
1659
|
-
time = getPlaybackTime();
|
|
1660
|
-
} else if (getAudioContextTime) {
|
|
1661
|
-
const elapsed = getAudioContextTime() - (playbackStartTimeRef.current ?? 0);
|
|
1662
|
-
time = (audioStartPositionRef.current ?? 0) + elapsed;
|
|
1663
|
-
} else {
|
|
1664
|
-
time = currentTimeRef.current ?? 0;
|
|
1665
|
-
}
|
|
1666
|
-
} else {
|
|
1667
|
-
time = currentTimeRef.current ?? 0;
|
|
1668
|
-
}
|
|
1669
|
-
const pos = time * sampleRate / samplesPerPixel + controlsOffset;
|
|
1826
|
+
const time = visualTimeRef.current ?? currentTimeRef.current ?? 0;
|
|
1827
|
+
const pos = time * sampleRate / samplesPerPixel;
|
|
1670
1828
|
containerRef.current.style.transform = `translate3d(${pos}px, 0, 0)`;
|
|
1671
1829
|
}
|
|
1672
1830
|
if (isPlaying) {
|
|
@@ -1684,63 +1842,52 @@ var PlayheadWithMarker = ({
|
|
|
1684
1842
|
animationFrameRef.current = null;
|
|
1685
1843
|
}
|
|
1686
1844
|
};
|
|
1687
|
-
}, [
|
|
1688
|
-
|
|
1689
|
-
sampleRate,
|
|
1690
|
-
samplesPerPixel,
|
|
1691
|
-
controlsOffset,
|
|
1692
|
-
currentTimeRef,
|
|
1693
|
-
visualTimeRef,
|
|
1694
|
-
playbackStartTimeRef,
|
|
1695
|
-
audioStartPositionRef,
|
|
1696
|
-
getAudioContextTime,
|
|
1697
|
-
getPlaybackTime
|
|
1698
|
-
]);
|
|
1699
|
-
(0, import_react9.useEffect)(() => {
|
|
1845
|
+
}, [isPlaying, sampleRate, samplesPerPixel, currentTimeRef, visualTimeRef]);
|
|
1846
|
+
(0, import_react16.useEffect)(() => {
|
|
1700
1847
|
if (!isPlaying && containerRef.current) {
|
|
1701
|
-
const time = visualTimeRef
|
|
1702
|
-
const pos = time * sampleRate / samplesPerPixel
|
|
1848
|
+
const time = visualTimeRef.current ?? currentTimeRef.current ?? 0;
|
|
1849
|
+
const pos = time * sampleRate / samplesPerPixel;
|
|
1703
1850
|
containerRef.current.style.transform = `translate3d(${pos}px, 0, 0)`;
|
|
1704
1851
|
}
|
|
1705
1852
|
});
|
|
1706
|
-
return /* @__PURE__ */ (0,
|
|
1707
|
-
/* @__PURE__ */ (0,
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(PlayheadWithMarkerContainer, { ref: containerRef, $color: color, children: [
|
|
1854
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MarkerTriangle, { $color: color }),
|
|
1855
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MarkerLine, { $color: color })
|
|
1709
1856
|
] });
|
|
1710
1857
|
};
|
|
1711
1858
|
|
|
1712
1859
|
// src/components/Playlist.tsx
|
|
1713
|
-
var
|
|
1714
|
-
var
|
|
1715
|
-
var
|
|
1716
|
-
var Wrapper3 =
|
|
1860
|
+
var import_styled_components18 = __toESM(require("styled-components"));
|
|
1861
|
+
var import_react17 = require("react");
|
|
1862
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1863
|
+
var Wrapper3 = import_styled_components18.default.div`
|
|
1717
1864
|
display: flex;
|
|
1718
1865
|
overflow-y: hidden;
|
|
1719
1866
|
position: relative;
|
|
1720
1867
|
`;
|
|
1721
|
-
var ControlsColumn =
|
|
1868
|
+
var ControlsColumn = import_styled_components18.default.div.attrs((props) => ({
|
|
1722
1869
|
style: { width: `${props.$width}px` }
|
|
1723
1870
|
}))`
|
|
1724
1871
|
flex-shrink: 0;
|
|
1725
1872
|
overflow: hidden;
|
|
1726
1873
|
`;
|
|
1727
|
-
var TimescaleGap =
|
|
1874
|
+
var TimescaleGap = import_styled_components18.default.div.attrs((props) => ({
|
|
1728
1875
|
style: { height: `${props.$height}px` }
|
|
1729
1876
|
}))``;
|
|
1730
|
-
var ScrollArea =
|
|
1877
|
+
var ScrollArea = import_styled_components18.default.div`
|
|
1731
1878
|
overflow-x: auto;
|
|
1732
1879
|
overflow-y: hidden;
|
|
1733
1880
|
overflow-anchor: none;
|
|
1734
1881
|
flex: 1;
|
|
1735
1882
|
position: relative;
|
|
1736
1883
|
`;
|
|
1737
|
-
var ScrollContainerInner =
|
|
1884
|
+
var ScrollContainerInner = import_styled_components18.default.div.attrs((props) => ({
|
|
1738
1885
|
style: props.$width !== void 0 ? { width: `${props.$width}px` } : {}
|
|
1739
1886
|
}))`
|
|
1740
1887
|
position: relative;
|
|
1741
1888
|
background: ${(props) => props.$backgroundColor || "transparent"};
|
|
1742
1889
|
`;
|
|
1743
|
-
var TimescaleWrapper =
|
|
1890
|
+
var TimescaleWrapper = import_styled_components18.default.div.attrs((props) => ({
|
|
1744
1891
|
style: props.$width ? { minWidth: `${props.$width}px` } : {}
|
|
1745
1892
|
}))`
|
|
1746
1893
|
background: ${(props) => props.$backgroundColor || "white"};
|
|
@@ -1748,14 +1895,14 @@ var TimescaleWrapper = import_styled_components17.default.div.attrs((props) => (
|
|
|
1748
1895
|
position: relative;
|
|
1749
1896
|
overflow: hidden; /* Constrain loop region to timescale area */
|
|
1750
1897
|
`;
|
|
1751
|
-
var TracksContainer =
|
|
1898
|
+
var TracksContainer = import_styled_components18.default.div.attrs((props) => ({
|
|
1752
1899
|
style: props.$width !== void 0 ? { minWidth: `${props.$width}px` } : {}
|
|
1753
1900
|
}))`
|
|
1754
1901
|
position: relative;
|
|
1755
1902
|
background: ${(props) => props.$backgroundColor || "transparent"};
|
|
1756
1903
|
width: 100%;
|
|
1757
1904
|
`;
|
|
1758
|
-
var ClickOverlay =
|
|
1905
|
+
var ClickOverlay = import_styled_components18.default.div`
|
|
1759
1906
|
position: absolute;
|
|
1760
1907
|
top: 0;
|
|
1761
1908
|
left: 0;
|
|
@@ -1781,10 +1928,11 @@ var Playlist = ({
|
|
|
1781
1928
|
isSelecting,
|
|
1782
1929
|
"data-playlist-state": playlistState,
|
|
1783
1930
|
trackControlsSlots,
|
|
1784
|
-
timescaleGapHeight = 0
|
|
1931
|
+
timescaleGapHeight = 0,
|
|
1932
|
+
className
|
|
1785
1933
|
}) => {
|
|
1786
|
-
const scrollAreaRef = (0,
|
|
1787
|
-
const handleRef = (0,
|
|
1934
|
+
const scrollAreaRef = (0, import_react17.useRef)(null);
|
|
1935
|
+
const handleRef = (0, import_react17.useCallback)(
|
|
1788
1936
|
(el) => {
|
|
1789
1937
|
scrollAreaRef.current = el;
|
|
1790
1938
|
scrollContainerRef?.(el);
|
|
@@ -1792,16 +1940,16 @@ var Playlist = ({
|
|
|
1792
1940
|
[scrollContainerRef]
|
|
1793
1941
|
);
|
|
1794
1942
|
const showControls = controlsWidth !== void 0 && controlsWidth > 0;
|
|
1795
|
-
return /* @__PURE__ */ (0,
|
|
1796
|
-
showControls && /* @__PURE__ */ (0,
|
|
1797
|
-
timescaleGapHeight > 0 && /* @__PURE__ */ (0,
|
|
1943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Wrapper3, { className, "data-playlist-state": playlistState, children: [
|
|
1944
|
+
showControls && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ControlsColumn, { $width: controlsWidth, children: [
|
|
1945
|
+
timescaleGapHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TimescaleGap, { $height: timescaleGapHeight }),
|
|
1798
1946
|
trackControlsSlots
|
|
1799
1947
|
] }),
|
|
1800
|
-
/* @__PURE__ */ (0,
|
|
1801
|
-
timescale && /* @__PURE__ */ (0,
|
|
1802
|
-
/* @__PURE__ */ (0,
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ScrollArea, { "data-scroll-container": "true", ref: handleRef, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ScrollViewportProvider, { containerRef: scrollAreaRef, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(ScrollContainerInner, { $backgroundColor: backgroundColor, $width: tracksWidth, children: [
|
|
1949
|
+
timescale && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TimescaleWrapper, { $width: timescaleWidth, $backgroundColor: timescaleBackgroundColor, children: timescale }),
|
|
1950
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(TracksContainer, { $width: tracksWidth, $backgroundColor: backgroundColor, children: [
|
|
1803
1951
|
children,
|
|
1804
|
-
(onTracksClick || onTracksMouseDown) && /* @__PURE__ */ (0,
|
|
1952
|
+
(onTracksClick || onTracksMouseDown) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1805
1953
|
ClickOverlay,
|
|
1806
1954
|
{
|
|
1807
1955
|
$isSelecting: isSelecting,
|
|
@@ -1815,12 +1963,12 @@ var Playlist = ({
|
|
|
1815
1963
|
] }) }) })
|
|
1816
1964
|
] });
|
|
1817
1965
|
};
|
|
1818
|
-
var StyledPlaylist = (0,
|
|
1966
|
+
var StyledPlaylist = (0, import_styled_components18.withTheme)(Playlist);
|
|
1819
1967
|
|
|
1820
1968
|
// src/components/Selection.tsx
|
|
1821
|
-
var
|
|
1822
|
-
var
|
|
1823
|
-
var SelectionOverlay =
|
|
1969
|
+
var import_styled_components19 = __toESM(require("styled-components"));
|
|
1970
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1971
|
+
var SelectionOverlay = import_styled_components19.default.div.attrs((props) => ({
|
|
1824
1972
|
style: {
|
|
1825
1973
|
left: `${props.$left}px`,
|
|
1826
1974
|
width: `${props.$width}px`
|
|
@@ -1843,14 +1991,14 @@ var Selection = ({
|
|
|
1843
1991
|
if (width <= 0) {
|
|
1844
1992
|
return null;
|
|
1845
1993
|
}
|
|
1846
|
-
return /* @__PURE__ */ (0,
|
|
1994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SelectionOverlay, { $left: startPosition, $width: width, $color: color, "data-selection": true });
|
|
1847
1995
|
};
|
|
1848
1996
|
|
|
1849
1997
|
// src/components/LoopRegion.tsx
|
|
1850
|
-
var
|
|
1851
|
-
var
|
|
1852
|
-
var
|
|
1853
|
-
var LoopRegionOverlayDiv =
|
|
1998
|
+
var import_react18 = require("react");
|
|
1999
|
+
var import_styled_components20 = __toESM(require("styled-components"));
|
|
2000
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2001
|
+
var LoopRegionOverlayDiv = import_styled_components20.default.div.attrs((props) => ({
|
|
1854
2002
|
style: {
|
|
1855
2003
|
left: `${props.$left}px`,
|
|
1856
2004
|
width: `${props.$width}px`
|
|
@@ -1863,7 +2011,7 @@ var LoopRegionOverlayDiv = import_styled_components19.default.div.attrs((props)
|
|
|
1863
2011
|
z-index: 55; /* Between clips (z-index: 50) and selection (z-index: 60) */
|
|
1864
2012
|
pointer-events: none;
|
|
1865
2013
|
`;
|
|
1866
|
-
var LoopMarker =
|
|
2014
|
+
var LoopMarker = import_styled_components20.default.div.attrs((props) => ({
|
|
1867
2015
|
style: {
|
|
1868
2016
|
left: `${props.$left}px`
|
|
1869
2017
|
}
|
|
@@ -1898,8 +2046,8 @@ var LoopRegion = ({
|
|
|
1898
2046
|
if (width <= 0) {
|
|
1899
2047
|
return null;
|
|
1900
2048
|
}
|
|
1901
|
-
return /* @__PURE__ */ (0,
|
|
1902
|
-
/* @__PURE__ */ (0,
|
|
2049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1903
2051
|
LoopRegionOverlayDiv,
|
|
1904
2052
|
{
|
|
1905
2053
|
$left: startPosition,
|
|
@@ -1908,7 +2056,7 @@ var LoopRegion = ({
|
|
|
1908
2056
|
"data-loop-region": true
|
|
1909
2057
|
}
|
|
1910
2058
|
),
|
|
1911
|
-
/* @__PURE__ */ (0,
|
|
2059
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1912
2060
|
LoopMarker,
|
|
1913
2061
|
{
|
|
1914
2062
|
$left: startPosition,
|
|
@@ -1917,7 +2065,7 @@ var LoopRegion = ({
|
|
|
1917
2065
|
"data-loop-marker": "start"
|
|
1918
2066
|
}
|
|
1919
2067
|
),
|
|
1920
|
-
/* @__PURE__ */ (0,
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1921
2069
|
LoopMarker,
|
|
1922
2070
|
{
|
|
1923
2071
|
$left: endPosition - 2,
|
|
@@ -1928,7 +2076,7 @@ var LoopRegion = ({
|
|
|
1928
2076
|
)
|
|
1929
2077
|
] });
|
|
1930
2078
|
};
|
|
1931
|
-
var DraggableMarkerHandle =
|
|
2079
|
+
var DraggableMarkerHandle = import_styled_components20.default.div.attrs((props) => ({
|
|
1932
2080
|
style: {
|
|
1933
2081
|
left: `${props.$left}px`
|
|
1934
2082
|
}
|
|
@@ -1970,7 +2118,7 @@ var DraggableMarkerHandle = import_styled_components19.default.div.attrs((props)
|
|
|
1970
2118
|
opacity: 1;
|
|
1971
2119
|
}
|
|
1972
2120
|
`;
|
|
1973
|
-
var TimescaleLoopShade =
|
|
2121
|
+
var TimescaleLoopShade = import_styled_components20.default.div.attrs((props) => ({
|
|
1974
2122
|
style: {
|
|
1975
2123
|
left: `${props.$left}px`,
|
|
1976
2124
|
width: `${props.$width}px`
|
|
@@ -1998,12 +2146,12 @@ var LoopRegionMarkers = ({
|
|
|
1998
2146
|
minPosition = 0,
|
|
1999
2147
|
maxPosition = Infinity
|
|
2000
2148
|
}) => {
|
|
2001
|
-
const [draggingMarker, setDraggingMarker] = (0,
|
|
2002
|
-
const dragStartX = (0,
|
|
2003
|
-
const dragStartPosition = (0,
|
|
2004
|
-
const dragStartEnd = (0,
|
|
2149
|
+
const [draggingMarker, setDraggingMarker] = (0, import_react18.useState)(null);
|
|
2150
|
+
const dragStartX = (0, import_react18.useRef)(0);
|
|
2151
|
+
const dragStartPosition = (0, import_react18.useRef)(0);
|
|
2152
|
+
const dragStartEnd = (0, import_react18.useRef)(0);
|
|
2005
2153
|
const width = Math.max(0, endPosition - startPosition);
|
|
2006
|
-
const handleMarkerMouseDown = (0,
|
|
2154
|
+
const handleMarkerMouseDown = (0, import_react18.useCallback)(
|
|
2007
2155
|
(e, marker) => {
|
|
2008
2156
|
e.preventDefault();
|
|
2009
2157
|
e.stopPropagation();
|
|
@@ -2031,7 +2179,7 @@ var LoopRegionMarkers = ({
|
|
|
2031
2179
|
},
|
|
2032
2180
|
[startPosition, endPosition, minPosition, maxPosition, onLoopStartChange, onLoopEndChange]
|
|
2033
2181
|
);
|
|
2034
|
-
const handleRegionMouseDown = (0,
|
|
2182
|
+
const handleRegionMouseDown = (0, import_react18.useCallback)(
|
|
2035
2183
|
(e) => {
|
|
2036
2184
|
e.preventDefault();
|
|
2037
2185
|
e.stopPropagation();
|
|
@@ -2067,8 +2215,8 @@ var LoopRegionMarkers = ({
|
|
|
2067
2215
|
if (width <= 0) {
|
|
2068
2216
|
return null;
|
|
2069
2217
|
}
|
|
2070
|
-
return /* @__PURE__ */ (0,
|
|
2071
|
-
/* @__PURE__ */ (0,
|
|
2218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2219
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2072
2220
|
TimescaleLoopShade,
|
|
2073
2221
|
{
|
|
2074
2222
|
$left: startPosition,
|
|
@@ -2079,7 +2227,7 @@ var LoopRegionMarkers = ({
|
|
|
2079
2227
|
"data-loop-region-timescale": true
|
|
2080
2228
|
}
|
|
2081
2229
|
),
|
|
2082
|
-
/* @__PURE__ */ (0,
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2083
2231
|
DraggableMarkerHandle,
|
|
2084
2232
|
{
|
|
2085
2233
|
$left: startPosition,
|
|
@@ -2090,7 +2238,7 @@ var LoopRegionMarkers = ({
|
|
|
2090
2238
|
"data-loop-marker-handle": "start"
|
|
2091
2239
|
}
|
|
2092
2240
|
),
|
|
2093
|
-
/* @__PURE__ */ (0,
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2094
2242
|
DraggableMarkerHandle,
|
|
2095
2243
|
{
|
|
2096
2244
|
$left: endPosition,
|
|
@@ -2103,7 +2251,7 @@ var LoopRegionMarkers = ({
|
|
|
2103
2251
|
)
|
|
2104
2252
|
] });
|
|
2105
2253
|
};
|
|
2106
|
-
var TimescaleLoopCreator =
|
|
2254
|
+
var TimescaleLoopCreator = import_styled_components20.default.div`
|
|
2107
2255
|
position: absolute;
|
|
2108
2256
|
top: 0;
|
|
2109
2257
|
left: 0;
|
|
@@ -2121,11 +2269,11 @@ var TimescaleLoopRegion = ({
|
|
|
2121
2269
|
minPosition = 0,
|
|
2122
2270
|
maxPosition = Infinity
|
|
2123
2271
|
}) => {
|
|
2124
|
-
const [, setIsCreating] = (0,
|
|
2125
|
-
const createStartX = (0,
|
|
2126
|
-
const containerRef = (0,
|
|
2272
|
+
const [, setIsCreating] = (0, import_react18.useState)(false);
|
|
2273
|
+
const createStartX = (0, import_react18.useRef)(0);
|
|
2274
|
+
const containerRef = (0, import_react18.useRef)(null);
|
|
2127
2275
|
const hasLoopRegion = endPosition > startPosition;
|
|
2128
|
-
const handleBackgroundMouseDown = (0,
|
|
2276
|
+
const handleBackgroundMouseDown = (0, import_react18.useCallback)(
|
|
2129
2277
|
(e) => {
|
|
2130
2278
|
const target = e.target;
|
|
2131
2279
|
if (target.closest("[data-loop-marker-handle]") || target.closest("[data-loop-region-timescale]")) {
|
|
@@ -2156,13 +2304,13 @@ var TimescaleLoopRegion = ({
|
|
|
2156
2304
|
},
|
|
2157
2305
|
[minPosition, maxPosition, onLoopRegionChange]
|
|
2158
2306
|
);
|
|
2159
|
-
return /* @__PURE__ */ (0,
|
|
2307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2160
2308
|
TimescaleLoopCreator,
|
|
2161
2309
|
{
|
|
2162
2310
|
ref: containerRef,
|
|
2163
2311
|
onMouseDown: handleBackgroundMouseDown,
|
|
2164
2312
|
"data-timescale-loop-creator": true,
|
|
2165
|
-
children: hasLoopRegion && /* @__PURE__ */ (0,
|
|
2313
|
+
children: hasLoopRegion && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2166
2314
|
LoopRegionMarkers,
|
|
2167
2315
|
{
|
|
2168
2316
|
startPosition,
|
|
@@ -2181,10 +2329,10 @@ var TimescaleLoopRegion = ({
|
|
|
2181
2329
|
};
|
|
2182
2330
|
|
|
2183
2331
|
// src/components/SelectionTimeInputs.tsx
|
|
2184
|
-
var
|
|
2332
|
+
var import_react20 = require("react");
|
|
2185
2333
|
|
|
2186
2334
|
// src/components/TimeInput.tsx
|
|
2187
|
-
var
|
|
2335
|
+
var import_react19 = require("react");
|
|
2188
2336
|
|
|
2189
2337
|
// src/utils/timeFormat.ts
|
|
2190
2338
|
function clockFormat(seconds, decimals) {
|
|
@@ -2234,40 +2382,36 @@ function parseTime(timeStr, format) {
|
|
|
2234
2382
|
}
|
|
2235
2383
|
|
|
2236
2384
|
// src/components/TimeInput.tsx
|
|
2237
|
-
var
|
|
2385
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2238
2386
|
var TimeInput = ({
|
|
2239
2387
|
id,
|
|
2240
|
-
label,
|
|
2388
|
+
label: label2,
|
|
2241
2389
|
value,
|
|
2242
2390
|
format,
|
|
2243
2391
|
className,
|
|
2244
2392
|
onChange,
|
|
2245
2393
|
readOnly = false
|
|
2246
2394
|
}) => {
|
|
2247
|
-
const [
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
setDisplayValue(formatted);
|
|
2251
|
-
}, [value, format, id]);
|
|
2395
|
+
const [draft, setDraft] = (0, import_react19.useState)(null);
|
|
2396
|
+
const activeDraft = draft?.format === format ? draft : null;
|
|
2397
|
+
const displayValue = activeDraft?.text ?? formatTime(value, format);
|
|
2252
2398
|
const handleChange = (e) => {
|
|
2253
|
-
|
|
2254
|
-
setDisplayValue(newDisplayValue);
|
|
2399
|
+
setDraft({ text: e.target.value, format });
|
|
2255
2400
|
};
|
|
2256
2401
|
const handleBlur = () => {
|
|
2257
|
-
if (
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
setDisplayValue(formatTime(value, format));
|
|
2402
|
+
if (draft === null) return;
|
|
2403
|
+
setDraft(null);
|
|
2404
|
+
if (activeDraft === null) return;
|
|
2405
|
+
onChange?.(parseTime(activeDraft.text, format));
|
|
2262
2406
|
};
|
|
2263
2407
|
const handleKeyDown = (e) => {
|
|
2264
2408
|
if (e.key === "Enter") {
|
|
2265
2409
|
e.currentTarget.blur();
|
|
2266
2410
|
}
|
|
2267
2411
|
};
|
|
2268
|
-
return /* @__PURE__ */ (0,
|
|
2269
|
-
/* @__PURE__ */ (0,
|
|
2270
|
-
/* @__PURE__ */ (0,
|
|
2412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
2413
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ScreenReaderOnly, { as: "label", htmlFor: id, children: label2 }),
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2271
2415
|
BaseInput,
|
|
2272
2416
|
{
|
|
2273
2417
|
type: "text",
|
|
@@ -2284,29 +2428,15 @@ var TimeInput = ({
|
|
|
2284
2428
|
};
|
|
2285
2429
|
|
|
2286
2430
|
// src/components/SelectionTimeInputs.tsx
|
|
2287
|
-
var
|
|
2431
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2288
2432
|
var SelectionTimeInputs = ({
|
|
2289
2433
|
selectionStart,
|
|
2290
2434
|
selectionEnd,
|
|
2291
2435
|
onSelectionChange,
|
|
2436
|
+
format = "hh:mm:ss.uuu",
|
|
2292
2437
|
className
|
|
2293
2438
|
}) => {
|
|
2294
|
-
const
|
|
2295
|
-
(0, import_react13.useEffect)(() => {
|
|
2296
|
-
const timeFormatSelect = document.querySelector(".time-format");
|
|
2297
|
-
const handleFormatChange = () => {
|
|
2298
|
-
if (timeFormatSelect) {
|
|
2299
|
-
setTimeFormat(timeFormatSelect.value);
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
2302
|
-
if (timeFormatSelect) {
|
|
2303
|
-
setTimeFormat(timeFormatSelect.value);
|
|
2304
|
-
timeFormatSelect.addEventListener("change", handleFormatChange);
|
|
2305
|
-
}
|
|
2306
|
-
return () => {
|
|
2307
|
-
timeFormatSelect?.removeEventListener("change", handleFormatChange);
|
|
2308
|
-
};
|
|
2309
|
-
}, []);
|
|
2439
|
+
const id = (0, import_react20.useId)();
|
|
2310
2440
|
const handleStartChange = (value) => {
|
|
2311
2441
|
if (onSelectionChange) {
|
|
2312
2442
|
onSelectionChange(value, selectionEnd);
|
|
@@ -2317,25 +2447,25 @@ var SelectionTimeInputs = ({
|
|
|
2317
2447
|
onSelectionChange(selectionStart, value);
|
|
2318
2448
|
}
|
|
2319
2449
|
};
|
|
2320
|
-
return /* @__PURE__ */ (0,
|
|
2321
|
-
/* @__PURE__ */ (0,
|
|
2450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className, children: [
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2322
2452
|
TimeInput,
|
|
2323
2453
|
{
|
|
2324
|
-
id:
|
|
2454
|
+
id: `${id}-start`,
|
|
2325
2455
|
label: "Start of audio selection",
|
|
2326
2456
|
value: selectionStart,
|
|
2327
|
-
format
|
|
2457
|
+
format,
|
|
2328
2458
|
className: "audio-start form-control mr-sm-2",
|
|
2329
2459
|
onChange: handleStartChange
|
|
2330
2460
|
}
|
|
2331
2461
|
),
|
|
2332
|
-
/* @__PURE__ */ (0,
|
|
2462
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2333
2463
|
TimeInput,
|
|
2334
2464
|
{
|
|
2335
|
-
id:
|
|
2465
|
+
id: `${id}-end`,
|
|
2336
2466
|
label: "End of audio selection",
|
|
2337
2467
|
value: selectionEnd,
|
|
2338
|
-
format
|
|
2468
|
+
format,
|
|
2339
2469
|
className: "audio-end form-control mr-sm-2",
|
|
2340
2470
|
onChange: handleEndChange
|
|
2341
2471
|
}
|
|
@@ -2343,129 +2473,11 @@ var SelectionTimeInputs = ({
|
|
|
2343
2473
|
] });
|
|
2344
2474
|
};
|
|
2345
2475
|
|
|
2346
|
-
// src/contexts/BeatsAndBars.tsx
|
|
2347
|
-
var import_react14 = require("react");
|
|
2348
|
-
var import_core4 = require("@waveform-playlist/core");
|
|
2349
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2350
|
-
var BeatsAndBarsContext = (0, import_react14.createContext)(null);
|
|
2351
|
-
function BeatsAndBarsProvider({
|
|
2352
|
-
bpm,
|
|
2353
|
-
timeSignature,
|
|
2354
|
-
snapTo,
|
|
2355
|
-
scaleMode = "beats",
|
|
2356
|
-
children
|
|
2357
|
-
}) {
|
|
2358
|
-
const [numerator, denominator] = timeSignature;
|
|
2359
|
-
const value = (0, import_react14.useMemo)(() => {
|
|
2360
|
-
const ts = [numerator, denominator];
|
|
2361
|
-
const tpBeat = (0, import_core4.ticksPerBeat)(ts);
|
|
2362
|
-
const tpBar = (0, import_core4.ticksPerBar)(ts);
|
|
2363
|
-
return {
|
|
2364
|
-
bpm,
|
|
2365
|
-
timeSignature: ts,
|
|
2366
|
-
snapTo,
|
|
2367
|
-
scaleMode,
|
|
2368
|
-
ticksPerBeat: tpBeat,
|
|
2369
|
-
ticksPerBar: tpBar
|
|
2370
|
-
};
|
|
2371
|
-
}, [bpm, numerator, denominator, snapTo, scaleMode]);
|
|
2372
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BeatsAndBarsContext.Provider, { value, children });
|
|
2373
|
-
}
|
|
2374
|
-
function useBeatsAndBars() {
|
|
2375
|
-
return (0, import_react14.useContext)(BeatsAndBarsContext);
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
// src/contexts/DevicePixelRatio.tsx
|
|
2379
|
-
var import_react15 = require("react");
|
|
2380
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2381
|
-
function getScale() {
|
|
2382
|
-
return window.devicePixelRatio;
|
|
2383
|
-
}
|
|
2384
|
-
var DevicePixelRatioContext = (0, import_react15.createContext)(getScale());
|
|
2385
|
-
var DevicePixelRatioProvider = ({ children }) => {
|
|
2386
|
-
const [scale, setScale] = (0, import_react15.useState)(getScale());
|
|
2387
|
-
matchMedia(`(resolution: ${getScale()}dppx)`).addEventListener(
|
|
2388
|
-
"change",
|
|
2389
|
-
() => {
|
|
2390
|
-
setScale(getScale());
|
|
2391
|
-
},
|
|
2392
|
-
{ once: true }
|
|
2393
|
-
);
|
|
2394
|
-
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DevicePixelRatioContext.Provider, { value: Math.ceil(scale), children });
|
|
2395
|
-
};
|
|
2396
|
-
var useDevicePixelRatio = () => (0, import_react15.useContext)(DevicePixelRatioContext);
|
|
2397
|
-
|
|
2398
|
-
// src/contexts/PlaylistInfo.tsx
|
|
2399
|
-
var import_react16 = require("react");
|
|
2400
|
-
var PlaylistInfoContext = (0, import_react16.createContext)({
|
|
2401
|
-
sampleRate: 48e3,
|
|
2402
|
-
samplesPerPixel: 1e3,
|
|
2403
|
-
zoomLevels: [1e3, 1500, 2e3, 2500],
|
|
2404
|
-
waveHeight: 80,
|
|
2405
|
-
timeScaleHeight: 15,
|
|
2406
|
-
controls: {
|
|
2407
|
-
show: false,
|
|
2408
|
-
width: 150
|
|
2409
|
-
},
|
|
2410
|
-
duration: 3e4,
|
|
2411
|
-
barWidth: 1,
|
|
2412
|
-
barGap: 0,
|
|
2413
|
-
roundedBars: false
|
|
2414
|
-
});
|
|
2415
|
-
var usePlaylistInfo = () => (0, import_react16.useContext)(PlaylistInfoContext);
|
|
2416
|
-
|
|
2417
|
-
// src/contexts/Theme.tsx
|
|
2418
|
-
var import_react17 = require("react");
|
|
2419
|
-
var import_styled_components20 = require("styled-components");
|
|
2420
|
-
var useTheme2 = () => (0, import_react17.useContext)(import_styled_components20.ThemeContext);
|
|
2421
|
-
|
|
2422
|
-
// src/contexts/TrackControls.tsx
|
|
2423
|
-
var import_react18 = require("react");
|
|
2424
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2425
|
-
var TrackControlsContext = (0, import_react18.createContext)(/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react18.Fragment, {}));
|
|
2426
|
-
var useTrackControls = () => (0, import_react18.useContext)(TrackControlsContext);
|
|
2427
|
-
|
|
2428
|
-
// src/contexts/Playout.tsx
|
|
2429
|
-
var import_react19 = require("react");
|
|
2430
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2431
|
-
var defaultProgress = 0;
|
|
2432
|
-
var defaultIsPlaying = false;
|
|
2433
|
-
var defaultSelectionStart = 0;
|
|
2434
|
-
var defaultSelectionEnd = 0;
|
|
2435
|
-
var defaultPlayout = {
|
|
2436
|
-
progress: defaultProgress,
|
|
2437
|
-
isPlaying: defaultIsPlaying,
|
|
2438
|
-
selectionStart: defaultSelectionStart,
|
|
2439
|
-
selectionEnd: defaultSelectionEnd
|
|
2440
|
-
};
|
|
2441
|
-
var PlayoutStatusContext = (0, import_react19.createContext)(defaultPlayout);
|
|
2442
|
-
var PlayoutStatusUpdateContext = (0, import_react19.createContext)({
|
|
2443
|
-
setIsPlaying: () => {
|
|
2444
|
-
},
|
|
2445
|
-
setProgress: () => {
|
|
2446
|
-
},
|
|
2447
|
-
setSelection: () => {
|
|
2448
|
-
}
|
|
2449
|
-
});
|
|
2450
|
-
var PlayoutProvider = ({ children }) => {
|
|
2451
|
-
const [isPlaying, setIsPlaying] = (0, import_react19.useState)(defaultIsPlaying);
|
|
2452
|
-
const [progress, setProgress] = (0, import_react19.useState)(defaultProgress);
|
|
2453
|
-
const [selectionStart, setSelectionStart] = (0, import_react19.useState)(defaultSelectionStart);
|
|
2454
|
-
const [selectionEnd, setSelectionEnd] = (0, import_react19.useState)(defaultSelectionEnd);
|
|
2455
|
-
const setSelection = (start, end) => {
|
|
2456
|
-
setSelectionStart(start);
|
|
2457
|
-
setSelectionEnd(end);
|
|
2458
|
-
};
|
|
2459
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PlayoutStatusUpdateContext.Provider, { value: { setIsPlaying, setProgress, setSelection }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PlayoutStatusContext.Provider, { value: { isPlaying, progress, selectionStart, selectionEnd }, children }) });
|
|
2460
|
-
};
|
|
2461
|
-
var usePlayoutStatus = () => (0, import_react19.useContext)(PlayoutStatusContext);
|
|
2462
|
-
var usePlayoutStatusUpdate = () => (0, import_react19.useContext)(PlayoutStatusUpdateContext);
|
|
2463
|
-
|
|
2464
2476
|
// src/components/SpectrogramChannel.tsx
|
|
2465
|
-
var
|
|
2477
|
+
var import_react21 = require("react");
|
|
2466
2478
|
var import_styled_components21 = __toESM(require("styled-components"));
|
|
2467
2479
|
var import_core5 = require("@waveform-playlist/core");
|
|
2468
|
-
var
|
|
2480
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2469
2481
|
var Wrapper4 = import_styled_components21.default.div.attrs((props) => ({
|
|
2470
2482
|
style: {
|
|
2471
2483
|
top: `${props.$waveHeight * props.$index}px`,
|
|
@@ -2474,7 +2486,8 @@ var Wrapper4 = import_styled_components21.default.div.attrs((props) => ({
|
|
|
2474
2486
|
}
|
|
2475
2487
|
}))`
|
|
2476
2488
|
position: absolute;
|
|
2477
|
-
|
|
2489
|
+
/* Shown until the worker has drawn, and where a chunk is not mounted. */
|
|
2490
|
+
background: ${(props) => props.theme?.spectrogramBackgroundColor ?? "#000"};
|
|
2478
2491
|
transform: translateZ(0);
|
|
2479
2492
|
backface-visibility: hidden;
|
|
2480
2493
|
`;
|
|
@@ -2499,23 +2512,25 @@ var SpectrogramChannel = ({
|
|
|
2499
2512
|
samplesPerPixel: _samplesPerPixel,
|
|
2500
2513
|
clipId,
|
|
2501
2514
|
onCanvasRegister,
|
|
2502
|
-
onCanvasUnregister
|
|
2515
|
+
onCanvasUnregister,
|
|
2516
|
+
offsetSamples,
|
|
2517
|
+
durationSamples
|
|
2503
2518
|
}) => {
|
|
2504
2519
|
const channelIndex = channelIndexProp ?? index;
|
|
2505
2520
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2506
|
-
const registeredIdsRef = (0,
|
|
2507
|
-
const transferredCanvasesRef = (0,
|
|
2508
|
-
const onCanvasRegisterRef = (0,
|
|
2509
|
-
const onCanvasUnregisterRef = (0,
|
|
2521
|
+
const registeredIdsRef = (0, import_react21.useRef)([]);
|
|
2522
|
+
const transferredCanvasesRef = (0, import_react21.useRef)(/* @__PURE__ */ new WeakSet());
|
|
2523
|
+
const onCanvasRegisterRef = (0, import_react21.useRef)(onCanvasRegister);
|
|
2524
|
+
const onCanvasUnregisterRef = (0, import_react21.useRef)(onCanvasUnregister);
|
|
2510
2525
|
const clipOriginX = useClipViewportOrigin();
|
|
2511
2526
|
const visibleChunkIndices = useVisibleChunkIndices(length, import_core5.MAX_CANVAS_WIDTH, clipOriginX);
|
|
2512
|
-
(0,
|
|
2527
|
+
(0, import_react21.useEffect)(() => {
|
|
2513
2528
|
onCanvasRegisterRef.current = onCanvasRegister;
|
|
2514
2529
|
}, [onCanvasRegister]);
|
|
2515
|
-
(0,
|
|
2530
|
+
(0, import_react21.useEffect)(() => {
|
|
2516
2531
|
onCanvasUnregisterRef.current = onCanvasUnregister;
|
|
2517
2532
|
}, [onCanvasUnregister]);
|
|
2518
|
-
(0,
|
|
2533
|
+
(0, import_react21.useEffect)(() => {
|
|
2519
2534
|
if (!clipId) return;
|
|
2520
2535
|
const unregister = onCanvasUnregisterRef.current;
|
|
2521
2536
|
const register = onCanvasRegisterRef.current;
|
|
@@ -2559,15 +2574,26 @@ var SpectrogramChannel = ({
|
|
|
2559
2574
|
channelIndex,
|
|
2560
2575
|
chunkIndex: canvasIdx,
|
|
2561
2576
|
widthPx,
|
|
2562
|
-
heightPx: waveHeight
|
|
2577
|
+
heightPx: waveHeight,
|
|
2578
|
+
...offsetSamples !== void 0 ? { offsetSamples } : {},
|
|
2579
|
+
...durationSamples !== void 0 ? { durationSamples } : {}
|
|
2563
2580
|
});
|
|
2564
2581
|
registeredIdsRef.current.push(canvasId);
|
|
2565
2582
|
} catch (err) {
|
|
2566
2583
|
console.warn(`[spectrogram] register failed for ${canvasId}:`, err);
|
|
2567
2584
|
}
|
|
2568
2585
|
}
|
|
2569
|
-
}, [
|
|
2570
|
-
|
|
2586
|
+
}, [
|
|
2587
|
+
canvasMapRef,
|
|
2588
|
+
clipId,
|
|
2589
|
+
channelIndex,
|
|
2590
|
+
length,
|
|
2591
|
+
waveHeight,
|
|
2592
|
+
offsetSamples,
|
|
2593
|
+
durationSamples,
|
|
2594
|
+
visibleChunkIndices
|
|
2595
|
+
]);
|
|
2596
|
+
(0, import_react21.useEffect)(() => {
|
|
2571
2597
|
return () => {
|
|
2572
2598
|
const unregister = onCanvasUnregisterRef.current;
|
|
2573
2599
|
for (const id of registeredIdsRef.current) {
|
|
@@ -2583,7 +2609,7 @@ var SpectrogramChannel = ({
|
|
|
2583
2609
|
const canvases = visibleChunkIndices.map((i) => {
|
|
2584
2610
|
const chunkLeft = i * import_core5.MAX_CANVAS_WIDTH;
|
|
2585
2611
|
const currentWidth = Math.min(length - chunkLeft, import_core5.MAX_CANVAS_WIDTH);
|
|
2586
|
-
return /* @__PURE__ */ (0,
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2587
2613
|
SpectrogramCanvas,
|
|
2588
2614
|
{
|
|
2589
2615
|
$cssWidth: currentWidth,
|
|
@@ -2594,14 +2620,14 @@ var SpectrogramChannel = ({
|
|
|
2594
2620
|
"data-index": i,
|
|
2595
2621
|
ref: canvasRef
|
|
2596
2622
|
},
|
|
2597
|
-
`${length}-${i}`
|
|
2623
|
+
`${length}-${waveHeight}-${offsetSamples ?? ""}-${durationSamples ?? ""}-${i}`
|
|
2598
2624
|
);
|
|
2599
2625
|
});
|
|
2600
|
-
return /* @__PURE__ */ (0,
|
|
2626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Wrapper4, { $index: index, $cssWidth: length, $waveHeight: waveHeight, children: canvases });
|
|
2601
2627
|
};
|
|
2602
2628
|
|
|
2603
2629
|
// src/components/SmartChannel.tsx
|
|
2604
|
-
var
|
|
2630
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2605
2631
|
var SmartChannel = ({
|
|
2606
2632
|
isSelected,
|
|
2607
2633
|
transparentBackground,
|
|
@@ -2610,6 +2636,8 @@ var SmartChannel = ({
|
|
|
2610
2636
|
spectrogramClipId,
|
|
2611
2637
|
spectrogramOnCanvasRegister,
|
|
2612
2638
|
spectrogramOnCanvasUnregister,
|
|
2639
|
+
spectrogramOffsetSamples,
|
|
2640
|
+
spectrogramDurationSamples,
|
|
2613
2641
|
midiNotes,
|
|
2614
2642
|
sampleRate: sampleRateProp,
|
|
2615
2643
|
clipOffsetSeconds,
|
|
@@ -2629,9 +2657,29 @@ var SmartChannel = ({
|
|
|
2629
2657
|
const waveOutlineColor = isSelected && theme ? theme.selectedWaveOutlineColor : theme?.waveOutlineColor;
|
|
2630
2658
|
const waveFillColor = isSelected && theme ? theme.selectedWaveFillColor : theme?.waveFillColor;
|
|
2631
2659
|
const drawMode = theme?.waveformDrawMode || "inverted";
|
|
2660
|
+
if (midiNotes != null) {
|
|
2661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2662
|
+
PianoRollChannel,
|
|
2663
|
+
{
|
|
2664
|
+
index: props.index,
|
|
2665
|
+
midiNotes,
|
|
2666
|
+
length: props.length,
|
|
2667
|
+
waveHeight,
|
|
2668
|
+
devicePixelRatio,
|
|
2669
|
+
samplesPerPixel,
|
|
2670
|
+
sampleRate: sampleRateProp ?? contextSampleRate,
|
|
2671
|
+
clipOffsetSeconds: clipOffsetSeconds ?? 0,
|
|
2672
|
+
noteColor: theme?.pianoRollNoteColor,
|
|
2673
|
+
selectedNoteColor: theme?.pianoRollSelectedNoteColor,
|
|
2674
|
+
isSelected,
|
|
2675
|
+
transparentBackground,
|
|
2676
|
+
backgroundColor: theme?.pianoRollBackgroundColor
|
|
2677
|
+
}
|
|
2678
|
+
);
|
|
2679
|
+
}
|
|
2632
2680
|
const hasSpectrogram = spectrogramClipId && spectrogramOnCanvasRegister && spectrogramOnCanvasUnregister;
|
|
2633
2681
|
if (renderMode === "spectrogram" && hasSpectrogram) {
|
|
2634
|
-
return /* @__PURE__ */ (0,
|
|
2682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2635
2683
|
SpectrogramChannel,
|
|
2636
2684
|
{
|
|
2637
2685
|
index: props.index,
|
|
@@ -2641,14 +2689,16 @@ var SmartChannel = ({
|
|
|
2641
2689
|
samplesPerPixel,
|
|
2642
2690
|
clipId: spectrogramClipId,
|
|
2643
2691
|
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2644
|
-
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2692
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister,
|
|
2693
|
+
offsetSamples: spectrogramOffsetSamples,
|
|
2694
|
+
durationSamples: spectrogramDurationSamples
|
|
2645
2695
|
}
|
|
2646
2696
|
);
|
|
2647
2697
|
}
|
|
2648
2698
|
if (renderMode === "both" && hasSpectrogram) {
|
|
2649
2699
|
const halfHeight = Math.floor(waveHeight / 2);
|
|
2650
|
-
return /* @__PURE__ */ (0,
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2701
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2652
2702
|
SpectrogramChannel,
|
|
2653
2703
|
{
|
|
2654
2704
|
index: props.index * 2,
|
|
@@ -2659,10 +2709,12 @@ var SmartChannel = ({
|
|
|
2659
2709
|
samplesPerPixel,
|
|
2660
2710
|
clipId: spectrogramClipId,
|
|
2661
2711
|
onCanvasRegister: spectrogramOnCanvasRegister,
|
|
2662
|
-
onCanvasUnregister: spectrogramOnCanvasUnregister
|
|
2712
|
+
onCanvasUnregister: spectrogramOnCanvasUnregister,
|
|
2713
|
+
offsetSamples: spectrogramOffsetSamples,
|
|
2714
|
+
durationSamples: spectrogramDurationSamples
|
|
2663
2715
|
}
|
|
2664
2716
|
),
|
|
2665
|
-
/* @__PURE__ */ (0,
|
|
2717
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2666
2718
|
"div",
|
|
2667
2719
|
{
|
|
2668
2720
|
style: {
|
|
@@ -2671,7 +2723,7 @@ var SmartChannel = ({
|
|
|
2671
2723
|
width: props.length,
|
|
2672
2724
|
height: halfHeight
|
|
2673
2725
|
},
|
|
2674
|
-
children: /* @__PURE__ */ (0,
|
|
2726
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2675
2727
|
Channel,
|
|
2676
2728
|
{
|
|
2677
2729
|
...props,
|
|
@@ -2691,27 +2743,7 @@ var SmartChannel = ({
|
|
|
2691
2743
|
)
|
|
2692
2744
|
] });
|
|
2693
2745
|
}
|
|
2694
|
-
|
|
2695
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2696
|
-
PianoRollChannel,
|
|
2697
|
-
{
|
|
2698
|
-
index: props.index,
|
|
2699
|
-
midiNotes: midiNotes ?? [],
|
|
2700
|
-
length: props.length,
|
|
2701
|
-
waveHeight,
|
|
2702
|
-
devicePixelRatio,
|
|
2703
|
-
samplesPerPixel,
|
|
2704
|
-
sampleRate: sampleRateProp ?? contextSampleRate,
|
|
2705
|
-
clipOffsetSeconds: clipOffsetSeconds ?? 0,
|
|
2706
|
-
noteColor: theme?.pianoRollNoteColor,
|
|
2707
|
-
selectedNoteColor: theme?.pianoRollSelectedNoteColor,
|
|
2708
|
-
isSelected,
|
|
2709
|
-
transparentBackground,
|
|
2710
|
-
backgroundColor: theme?.pianoRollBackgroundColor
|
|
2711
|
-
}
|
|
2712
|
-
);
|
|
2713
|
-
}
|
|
2714
|
-
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2715
2747
|
Channel,
|
|
2716
2748
|
{
|
|
2717
2749
|
...props,
|
|
@@ -2729,9 +2761,9 @@ var SmartChannel = ({
|
|
|
2729
2761
|
};
|
|
2730
2762
|
|
|
2731
2763
|
// src/components/SpectrogramLabels.tsx
|
|
2732
|
-
var
|
|
2764
|
+
var import_react22 = require("react");
|
|
2733
2765
|
var import_styled_components22 = __toESM(require("styled-components"));
|
|
2734
|
-
var
|
|
2766
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2735
2767
|
var LABELS_WIDTH = 72;
|
|
2736
2768
|
var LabelsStickyWrapper = import_styled_components22.default.div`
|
|
2737
2769
|
position: sticky;
|
|
@@ -2781,12 +2813,12 @@ var SpectrogramLabels = ({
|
|
|
2781
2813
|
renderMode = "spectrogram",
|
|
2782
2814
|
hasClipHeaders = false
|
|
2783
2815
|
}) => {
|
|
2784
|
-
const canvasRef = (0,
|
|
2816
|
+
const canvasRef = (0, import_react22.useRef)(null);
|
|
2785
2817
|
const devicePixelRatio = useDevicePixelRatio();
|
|
2786
2818
|
const spectrogramHeight = renderMode === "both" ? Math.floor(waveHeight / 2) : waveHeight;
|
|
2787
2819
|
const totalHeight = numChannels * waveHeight;
|
|
2788
2820
|
const clipHeaderOffset = hasClipHeaders ? 22 : 0;
|
|
2789
|
-
(0,
|
|
2821
|
+
(0, import_react22.useLayoutEffect)(() => {
|
|
2790
2822
|
const canvas = canvasRef.current;
|
|
2791
2823
|
if (!canvas) return;
|
|
2792
2824
|
const ctx = canvas.getContext("2d");
|
|
@@ -2824,7 +2856,7 @@ var SpectrogramLabels = ({
|
|
|
2824
2856
|
spectrogramHeight,
|
|
2825
2857
|
clipHeaderOffset
|
|
2826
2858
|
]);
|
|
2827
|
-
return /* @__PURE__ */ (0,
|
|
2859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LabelsStickyWrapper, { $height: totalHeight + clipHeaderOffset, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2828
2860
|
"canvas",
|
|
2829
2861
|
{
|
|
2830
2862
|
ref: canvasRef,
|
|
@@ -2840,14 +2872,14 @@ var SpectrogramLabels = ({
|
|
|
2840
2872
|
};
|
|
2841
2873
|
|
|
2842
2874
|
// src/components/SmartScale.tsx
|
|
2843
|
-
var
|
|
2875
|
+
var import_react24 = __toESM(require("react"));
|
|
2844
2876
|
var import_styled_components24 = __toESM(require("styled-components"));
|
|
2845
2877
|
|
|
2846
2878
|
// src/components/TimeScale.tsx
|
|
2847
|
-
var
|
|
2879
|
+
var import_react23 = require("react");
|
|
2848
2880
|
var import_styled_components23 = __toESM(require("styled-components"));
|
|
2849
2881
|
var import_core6 = require("@waveform-playlist/core");
|
|
2850
|
-
var
|
|
2882
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2851
2883
|
var PlaylistTimeScaleScroll = import_styled_components23.default.div.attrs((props) => ({
|
|
2852
2884
|
style: {
|
|
2853
2885
|
width: `${props.$cssWidth}px`,
|
|
@@ -2869,20 +2901,30 @@ var TimeTickChunk = import_styled_components23.default.canvas.attrs((props) => (
|
|
|
2869
2901
|
position: absolute;
|
|
2870
2902
|
bottom: 0;
|
|
2871
2903
|
`;
|
|
2904
|
+
function firstTickAtOrAfter(ticks, pixel) {
|
|
2905
|
+
let low = 0;
|
|
2906
|
+
let high = ticks.length;
|
|
2907
|
+
while (low < high) {
|
|
2908
|
+
const mid = low + high >>> 1;
|
|
2909
|
+
if (ticks[mid][0] < pixel) low = mid + 1;
|
|
2910
|
+
else high = mid;
|
|
2911
|
+
}
|
|
2912
|
+
return low;
|
|
2913
|
+
}
|
|
2872
2914
|
var TimeScale = (props) => {
|
|
2873
2915
|
const {
|
|
2874
2916
|
theme: { timeColor },
|
|
2875
2917
|
tickData
|
|
2876
2918
|
} = props;
|
|
2877
2919
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
2878
|
-
const { timeScaleHeight } = (0,
|
|
2920
|
+
const { timeScaleHeight } = (0, import_react23.use)(PlaylistInfoContext);
|
|
2879
2921
|
const devicePixelRatio = useDevicePixelRatio();
|
|
2880
2922
|
const { widthX, canvasInfo, timeMarkersWithPositions } = tickData;
|
|
2881
2923
|
const visibleChunkIndices = useVisibleChunkIndices(widthX, import_core6.MAX_CANVAS_WIDTH);
|
|
2882
2924
|
const visibleChunks = visibleChunkIndices.map((i) => {
|
|
2883
2925
|
const chunkLeft = i * import_core6.MAX_CANVAS_WIDTH;
|
|
2884
2926
|
const chunkWidth = Math.min(widthX - chunkLeft, import_core6.MAX_CANVAS_WIDTH);
|
|
2885
|
-
return /* @__PURE__ */ (0,
|
|
2927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2886
2928
|
TimeTickChunk,
|
|
2887
2929
|
{
|
|
2888
2930
|
$cssWidth: chunkWidth,
|
|
@@ -2899,26 +2941,41 @@ var TimeScale = (props) => {
|
|
|
2899
2941
|
const firstChunkLeft = visibleChunkIndices.length > 0 ? visibleChunkIndices[0] * import_core6.MAX_CANVAS_WIDTH : 0;
|
|
2900
2942
|
const lastChunkRight = visibleChunkIndices.length > 0 ? (visibleChunkIndices[visibleChunkIndices.length - 1] + 1) * import_core6.MAX_CANVAS_WIDTH : Infinity;
|
|
2901
2943
|
const visibleMarkers = visibleChunkIndices.length > 0 ? timeMarkersWithPositions.filter(({ pix }) => pix >= firstChunkLeft && pix < lastChunkRight).map(({ element }) => element) : timeMarkersWithPositions.map(({ element }) => element);
|
|
2902
|
-
(0,
|
|
2944
|
+
const sortedTicks = (0, import_react23.useMemo)(
|
|
2945
|
+
() => Array.from(canvasInfo.entries()).sort((a, b) => a[0] - b[0]),
|
|
2946
|
+
[canvasInfo]
|
|
2947
|
+
);
|
|
2948
|
+
const ticksVersion = useIdentityVersion(canvasInfo);
|
|
2949
|
+
const drawVersion = `${ticksVersion}-${widthX}-${devicePixelRatio}-${timeColor}-${timeScaleHeight}`;
|
|
2950
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
2903
2951
|
for (const [chunkIdx, canvas] of canvasMapRef.current.entries()) {
|
|
2952
|
+
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
2904
2953
|
const ctx = canvas.getContext("2d");
|
|
2905
2954
|
if (!ctx) continue;
|
|
2906
2955
|
const chunkLeft = chunkIdx * import_core6.MAX_CANVAS_WIDTH;
|
|
2907
|
-
const
|
|
2956
|
+
const chunkRight = chunkLeft + canvas.width / devicePixelRatio;
|
|
2908
2957
|
ctx.resetTransform();
|
|
2909
2958
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2910
2959
|
ctx.imageSmoothingEnabled = false;
|
|
2911
2960
|
ctx.fillStyle = timeColor;
|
|
2912
2961
|
ctx.scale(devicePixelRatio, devicePixelRatio);
|
|
2913
|
-
for (
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
ctx.fillRect(localX, scaleY, 1, scaleHeight);
|
|
2962
|
+
for (let i = firstTickAtOrAfter(sortedTicks, chunkLeft); i < sortedTicks.length; i++) {
|
|
2963
|
+
const [pixLeft, scaleHeight] = sortedTicks[i];
|
|
2964
|
+
if (pixLeft >= chunkRight) break;
|
|
2965
|
+
ctx.fillRect(pixLeft - chunkLeft, timeScaleHeight - scaleHeight, 1, scaleHeight);
|
|
2918
2966
|
}
|
|
2967
|
+
canvas.dataset.drawVersion = drawVersion;
|
|
2919
2968
|
}
|
|
2920
|
-
}, [
|
|
2921
|
-
|
|
2969
|
+
}, [
|
|
2970
|
+
canvasMapRef,
|
|
2971
|
+
devicePixelRatio,
|
|
2972
|
+
timeColor,
|
|
2973
|
+
timeScaleHeight,
|
|
2974
|
+
sortedTicks,
|
|
2975
|
+
drawVersion,
|
|
2976
|
+
visibleChunkIndices
|
|
2977
|
+
]);
|
|
2978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(PlaylistTimeScaleScroll, { $cssWidth: widthX, $timeScaleHeight: timeScaleHeight, children: [
|
|
2922
2979
|
visibleMarkers,
|
|
2923
2980
|
visibleChunks
|
|
2924
2981
|
] });
|
|
@@ -2927,7 +2984,7 @@ var StyledTimeScale = (0, import_styled_components23.withTheme)(TimeScale);
|
|
|
2927
2984
|
|
|
2928
2985
|
// src/components/SmartScale.tsx
|
|
2929
2986
|
var import_core7 = require("@waveform-playlist/core");
|
|
2930
|
-
var
|
|
2987
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2931
2988
|
function ticksToBarBeatLabel(ticks, timeSignature, ppqn = import_core7.PPQN) {
|
|
2932
2989
|
const barTicks = (0, import_core7.ticksPerBar)(timeSignature, ppqn);
|
|
2933
2990
|
const beatTicks = (0, import_core7.ticksPerBeat)(timeSignature, ppqn);
|
|
@@ -2976,15 +3033,18 @@ var TimeStamp = import_styled_components24.default.div.attrs((props) => ({
|
|
|
2976
3033
|
white-space: nowrap; /* Prevent text wrapping */
|
|
2977
3034
|
color: ${(props) => props.theme.timeColor}; /* Use theme color instead of inheriting */
|
|
2978
3035
|
`;
|
|
2979
|
-
var SmartScale = ({
|
|
2980
|
-
|
|
3036
|
+
var SmartScale = ({
|
|
3037
|
+
durationMs: duration,
|
|
3038
|
+
renderTick
|
|
3039
|
+
}) => {
|
|
3040
|
+
const { samplesPerPixel, sampleRate, timeScaleHeight } = (0, import_react24.use)(PlaylistInfoContext);
|
|
2981
3041
|
const beatsAndBars = useBeatsAndBars();
|
|
2982
|
-
const
|
|
3042
|
+
const tickLayout = (0, import_react24.useMemo)(() => {
|
|
2983
3043
|
const widthX = (0, import_core7.secondsToPixels)(duration / 1e3, samplesPerPixel, sampleRate);
|
|
2984
3044
|
if (beatsAndBars && beatsAndBars.scaleMode === "beats") {
|
|
2985
3045
|
const { bpm, timeSignature, ticksPerBar: tpBar, ticksPerBeat: tpBeat } = beatsAndBars;
|
|
2986
3046
|
const canvasInfo2 = /* @__PURE__ */ new Map();
|
|
2987
|
-
const
|
|
3047
|
+
const labels2 = [];
|
|
2988
3048
|
const durationSeconds = duration / 1e3;
|
|
2989
3049
|
const totalTicks = Math.ceil(durationSeconds * bpm * import_core7.PPQN / 60);
|
|
2990
3050
|
const pixelsPerBeat = (0, import_core7.ticksToSamples)(tpBeat, bpm, sampleRate) / samplesPerPixel;
|
|
@@ -3018,37 +3078,31 @@ var SmartScale = ({ renderTick }) => {
|
|
|
3018
3078
|
const tickHeight = isBarLine ? timeScaleHeight : isLabelTick ? Math.floor(timeScaleHeight / 2) : Math.floor(timeScaleHeight / 5);
|
|
3019
3079
|
canvasInfo2.set(pix, tickHeight);
|
|
3020
3080
|
if (isLabelTick) {
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
left: `${pix + 4}px`,
|
|
3028
|
-
fontSize: "0.75rem",
|
|
3029
|
-
whiteSpace: "nowrap"
|
|
3030
|
-
},
|
|
3031
|
-
children: label
|
|
3032
|
-
},
|
|
3033
|
-
`bb-${tick}`
|
|
3034
|
-
);
|
|
3035
|
-
timeMarkersWithPositions2.push({ pix, element });
|
|
3081
|
+
labels2.push({
|
|
3082
|
+
id: `bb-${tick}`,
|
|
3083
|
+
pix,
|
|
3084
|
+
text: ticksToBarBeatLabel(tick, timeSignature),
|
|
3085
|
+
mode: "beats"
|
|
3086
|
+
});
|
|
3036
3087
|
}
|
|
3037
3088
|
}
|
|
3038
|
-
return { widthX, canvasInfo: canvasInfo2,
|
|
3089
|
+
return { widthX, canvasInfo: canvasInfo2, labels: labels2 };
|
|
3039
3090
|
}
|
|
3040
3091
|
const config = getScaleInfo(samplesPerPixel);
|
|
3041
3092
|
const { marker, bigStep, smallStep } = config;
|
|
3042
3093
|
const canvasInfo = /* @__PURE__ */ new Map();
|
|
3043
|
-
const
|
|
3094
|
+
const labels = [];
|
|
3044
3095
|
const pixPerSec = sampleRate / samplesPerPixel;
|
|
3045
3096
|
let counter = 0;
|
|
3046
3097
|
for (let i = 0; i < widthX; i += pixPerSec * smallStep / 1e3) {
|
|
3047
3098
|
const pix = Math.floor(i);
|
|
3048
3099
|
if (counter % marker === 0) {
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3100
|
+
labels.push({
|
|
3101
|
+
id: `timestamp-${counter}`,
|
|
3102
|
+
pix,
|
|
3103
|
+
text: formatTime2(counter),
|
|
3104
|
+
mode: "temporal"
|
|
3105
|
+
});
|
|
3052
3106
|
canvasInfo.set(pix, timeScaleHeight);
|
|
3053
3107
|
} else if (counter % bigStep === 0) {
|
|
3054
3108
|
canvasInfo.set(pix, Math.floor(timeScaleHeight / 2));
|
|
@@ -3057,14 +3111,37 @@ var SmartScale = ({ renderTick }) => {
|
|
|
3057
3111
|
}
|
|
3058
3112
|
counter += smallStep;
|
|
3059
3113
|
}
|
|
3060
|
-
return { widthX, canvasInfo,
|
|
3061
|
-
}, [beatsAndBars, duration, samplesPerPixel, sampleRate, timeScaleHeight
|
|
3062
|
-
|
|
3114
|
+
return { widthX, canvasInfo, labels };
|
|
3115
|
+
}, [beatsAndBars, duration, samplesPerPixel, sampleRate, timeScaleHeight]);
|
|
3116
|
+
const tickData = (0, import_react24.useMemo)(
|
|
3117
|
+
() => ({
|
|
3118
|
+
widthX: tickLayout.widthX,
|
|
3119
|
+
canvasInfo: tickLayout.canvasInfo,
|
|
3120
|
+
timeMarkersWithPositions: tickLayout.labels.map(({ id, pix, text, mode }) => ({
|
|
3121
|
+
pix,
|
|
3122
|
+
element: renderTick ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react24.default.Fragment, { children: renderTick(text, pix) }, id) : mode === "beats" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3123
|
+
"div",
|
|
3124
|
+
{
|
|
3125
|
+
style: {
|
|
3126
|
+
position: "absolute",
|
|
3127
|
+
left: `${pix + 4}px`,
|
|
3128
|
+
fontSize: "0.75rem",
|
|
3129
|
+
whiteSpace: "nowrap"
|
|
3130
|
+
},
|
|
3131
|
+
children: text
|
|
3132
|
+
},
|
|
3133
|
+
id
|
|
3134
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimeStamp, { $left: pix, children: text }, id)
|
|
3135
|
+
}))
|
|
3136
|
+
}),
|
|
3137
|
+
[tickLayout, renderTick]
|
|
3138
|
+
);
|
|
3139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(StyledTimeScale, { tickData });
|
|
3063
3140
|
};
|
|
3064
3141
|
|
|
3065
3142
|
// src/components/TimeFormatSelect.tsx
|
|
3066
3143
|
var import_styled_components25 = __toESM(require("styled-components"));
|
|
3067
|
-
var
|
|
3144
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3068
3145
|
var SelectWrapper = import_styled_components25.default.div`
|
|
3069
3146
|
display: inline-flex;
|
|
3070
3147
|
align-items: center;
|
|
@@ -3087,7 +3164,7 @@ var TimeFormatSelect = ({
|
|
|
3087
3164
|
const handleChange = (e) => {
|
|
3088
3165
|
onChange(e.target.value);
|
|
3089
3166
|
};
|
|
3090
|
-
return /* @__PURE__ */ (0,
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SelectWrapper, { className, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3091
3168
|
BaseSelect,
|
|
3092
3169
|
{
|
|
3093
3170
|
className: "time-format",
|
|
@@ -3095,23 +3172,57 @@ var TimeFormatSelect = ({
|
|
|
3095
3172
|
onChange: handleChange,
|
|
3096
3173
|
disabled,
|
|
3097
3174
|
"aria-label": "Time format selection",
|
|
3098
|
-
children: TIME_FORMAT_OPTIONS.map((option) => /* @__PURE__ */ (0,
|
|
3175
|
+
children: TIME_FORMAT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("option", { value: option.value, children: option.label }, option.value))
|
|
3099
3176
|
}
|
|
3100
3177
|
) });
|
|
3101
3178
|
};
|
|
3102
3179
|
|
|
3103
|
-
// src/components/
|
|
3180
|
+
// src/components/PlaybackRateSelect.tsx
|
|
3104
3181
|
var import_styled_components26 = __toESM(require("styled-components"));
|
|
3105
|
-
var
|
|
3106
|
-
var
|
|
3182
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3183
|
+
var SelectWrapper2 = import_styled_components26.default.div`
|
|
3184
|
+
display: inline-flex;
|
|
3185
|
+
align-items: center;
|
|
3186
|
+
gap: 0.5rem;
|
|
3187
|
+
`;
|
|
3188
|
+
var DEFAULT_PLAYBACK_RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
3189
|
+
var label = (rate) => `${rate}\xD7`;
|
|
3190
|
+
var PlaybackRateSelect = ({
|
|
3191
|
+
value,
|
|
3192
|
+
onChange,
|
|
3193
|
+
rates = DEFAULT_PLAYBACK_RATES,
|
|
3194
|
+
disabled = false,
|
|
3195
|
+
className
|
|
3196
|
+
}) => {
|
|
3197
|
+
const handleChange = (e) => {
|
|
3198
|
+
onChange(Number(e.target.value));
|
|
3199
|
+
};
|
|
3200
|
+
const options = rates.includes(value) ? rates : [...rates, value].sort((a, b) => a - b);
|
|
3201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SelectWrapper2, { className, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3202
|
+
BaseSelect,
|
|
3203
|
+
{
|
|
3204
|
+
className: "playback-rate",
|
|
3205
|
+
value: String(value),
|
|
3206
|
+
onChange: handleChange,
|
|
3207
|
+
disabled,
|
|
3208
|
+
"aria-label": "Playback speed",
|
|
3209
|
+
children: options.map((rate) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: String(rate), children: label(rate) }, rate))
|
|
3210
|
+
}
|
|
3211
|
+
) });
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
// src/components/Track.tsx
|
|
3215
|
+
var import_styled_components27 = __toESM(require("styled-components"));
|
|
3216
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3217
|
+
var Container = import_styled_components27.default.div.attrs((props) => ({
|
|
3107
3218
|
style: {
|
|
3108
|
-
height: `${props.$waveHeight * props.$numChannels + (props.$hasClipHeaders ? CLIP_HEADER_HEIGHT : 0)}px
|
|
3219
|
+
height: `${props.$waveHeight * props.$numChannels + (props.$hasClipHeaders ? CLIP_HEADER_HEIGHT : 0)}px`,
|
|
3220
|
+
width: props.$width !== void 0 ? `${props.$width}px` : void 0
|
|
3109
3221
|
}
|
|
3110
3222
|
}))`
|
|
3111
3223
|
position: relative;
|
|
3112
|
-
${(props) => props.$width !== void 0 && `width: ${props.$width}px;`}
|
|
3113
3224
|
`;
|
|
3114
|
-
var ChannelContainer =
|
|
3225
|
+
var ChannelContainer = import_styled_components27.default.div.attrs((props) => ({
|
|
3115
3226
|
style: {
|
|
3116
3227
|
paddingLeft: `${props.$offset || 0}px`
|
|
3117
3228
|
}
|
|
@@ -3138,7 +3249,7 @@ var Track = ({
|
|
|
3138
3249
|
isSelected = false
|
|
3139
3250
|
}) => {
|
|
3140
3251
|
const { waveHeight } = usePlaylistInfo();
|
|
3141
|
-
return /* @__PURE__ */ (0,
|
|
3252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3142
3253
|
Container,
|
|
3143
3254
|
{
|
|
3144
3255
|
$numChannels: numChannels,
|
|
@@ -3146,7 +3257,7 @@ var Track = ({
|
|
|
3146
3257
|
$waveHeight: waveHeight,
|
|
3147
3258
|
$width: width,
|
|
3148
3259
|
$hasClipHeaders: hasClipHeaders,
|
|
3149
|
-
children: /* @__PURE__ */ (0,
|
|
3260
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3150
3261
|
ChannelContainer,
|
|
3151
3262
|
{
|
|
3152
3263
|
$backgroundColor: backgroundColor,
|
|
@@ -3162,8 +3273,8 @@ var Track = ({
|
|
|
3162
3273
|
};
|
|
3163
3274
|
|
|
3164
3275
|
// src/components/TrackControls/Button.tsx
|
|
3165
|
-
var
|
|
3166
|
-
var Button =
|
|
3276
|
+
var import_styled_components28 = __toESM(require("styled-components"));
|
|
3277
|
+
var Button = import_styled_components28.default.button.attrs({
|
|
3167
3278
|
type: "button"
|
|
3168
3279
|
})`
|
|
3169
3280
|
display: inline-block;
|
|
@@ -3183,6 +3294,11 @@ var Button = import_styled_components27.default.button.attrs({
|
|
|
3183
3294
|
box-shadow 0.15s ease-in-out;
|
|
3184
3295
|
cursor: pointer;
|
|
3185
3296
|
|
|
3297
|
+
&:disabled {
|
|
3298
|
+
opacity: 0.5;
|
|
3299
|
+
cursor: not-allowed;
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3186
3302
|
${(props) => {
|
|
3187
3303
|
if (props.$variant === "danger") {
|
|
3188
3304
|
return `
|
|
@@ -3238,8 +3354,8 @@ var Button = import_styled_components27.default.button.attrs({
|
|
|
3238
3354
|
`;
|
|
3239
3355
|
|
|
3240
3356
|
// src/components/TrackControls/ButtonGroup.tsx
|
|
3241
|
-
var
|
|
3242
|
-
var ButtonGroup =
|
|
3357
|
+
var import_styled_components29 = __toESM(require("styled-components"));
|
|
3358
|
+
var ButtonGroup = import_styled_components29.default.div`
|
|
3243
3359
|
margin-bottom: 0.3rem;
|
|
3244
3360
|
|
|
3245
3361
|
button:not(:first-child) {
|
|
@@ -3254,10 +3370,10 @@ var ButtonGroup = import_styled_components28.default.div`
|
|
|
3254
3370
|
`;
|
|
3255
3371
|
|
|
3256
3372
|
// src/components/TrackControls/CloseButton.tsx
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3259
|
-
var
|
|
3260
|
-
var StyledCloseButton =
|
|
3373
|
+
var import_styled_components30 = __toESM(require("styled-components"));
|
|
3374
|
+
var import_react25 = require("@phosphor-icons/react");
|
|
3375
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3376
|
+
var StyledCloseButton = import_styled_components30.default.button`
|
|
3261
3377
|
position: absolute;
|
|
3262
3378
|
left: 0;
|
|
3263
3379
|
top: 0;
|
|
@@ -3280,11 +3396,11 @@ var StyledCloseButton = import_styled_components29.default.button`
|
|
|
3280
3396
|
color: #dc3545;
|
|
3281
3397
|
}
|
|
3282
3398
|
`;
|
|
3283
|
-
var CloseButton = ({ onClick, title = "Remove track" }) => /* @__PURE__ */ (0,
|
|
3399
|
+
var CloseButton = ({ onClick, title = "Remove track" }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(StyledCloseButton, { onClick, title, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react25.X, { size: 12, weight: "bold" }) });
|
|
3284
3400
|
|
|
3285
3401
|
// src/components/TrackControls/Controls.tsx
|
|
3286
|
-
var
|
|
3287
|
-
var Controls =
|
|
3402
|
+
var import_styled_components31 = __toESM(require("styled-components"));
|
|
3403
|
+
var Controls = import_styled_components31.default.div`
|
|
3288
3404
|
background: transparent;
|
|
3289
3405
|
width: 100%;
|
|
3290
3406
|
height: 100%;
|
|
@@ -3300,8 +3416,8 @@ var Controls = import_styled_components30.default.div`
|
|
|
3300
3416
|
`;
|
|
3301
3417
|
|
|
3302
3418
|
// src/components/TrackControls/Header.tsx
|
|
3303
|
-
var
|
|
3304
|
-
var Header =
|
|
3419
|
+
var import_styled_components32 = __toESM(require("styled-components"));
|
|
3420
|
+
var Header = import_styled_components32.default.header`
|
|
3305
3421
|
overflow: hidden;
|
|
3306
3422
|
height: 26px;
|
|
3307
3423
|
width: 100%;
|
|
@@ -3315,44 +3431,44 @@ var Header = import_styled_components31.default.header`
|
|
|
3315
3431
|
`;
|
|
3316
3432
|
|
|
3317
3433
|
// src/components/TrackControls/VolumeDownIcon.tsx
|
|
3318
|
-
var
|
|
3319
|
-
var
|
|
3320
|
-
var VolumeDownIcon = (props) => /* @__PURE__ */ (0,
|
|
3434
|
+
var import_react26 = require("@phosphor-icons/react");
|
|
3435
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3436
|
+
var VolumeDownIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react26.SpeakerLowIcon, { weight: "light", ...props });
|
|
3321
3437
|
|
|
3322
3438
|
// src/components/TrackControls/VolumeUpIcon.tsx
|
|
3323
|
-
var
|
|
3324
|
-
var
|
|
3325
|
-
var VolumeUpIcon = (props) => /* @__PURE__ */ (0,
|
|
3439
|
+
var import_react27 = require("@phosphor-icons/react");
|
|
3440
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3441
|
+
var VolumeUpIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react27.SpeakerHighIcon, { weight: "light", ...props });
|
|
3326
3442
|
|
|
3327
3443
|
// src/components/TrackControls/TrashIcon.tsx
|
|
3328
|
-
var
|
|
3329
|
-
var
|
|
3330
|
-
var TrashIcon = (props) => /* @__PURE__ */ (0,
|
|
3444
|
+
var import_react28 = require("@phosphor-icons/react");
|
|
3445
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3446
|
+
var TrashIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react28.TrashIcon, { weight: "light", ...props });
|
|
3331
3447
|
|
|
3332
3448
|
// src/components/TrackControls/DotsIcon.tsx
|
|
3333
|
-
var
|
|
3334
|
-
var
|
|
3335
|
-
var DotsIcon = (props) => /* @__PURE__ */ (0,
|
|
3449
|
+
var import_react29 = require("@phosphor-icons/react");
|
|
3450
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3451
|
+
var DotsIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react29.DotsThreeIcon, { weight: "bold", ...props });
|
|
3336
3452
|
|
|
3337
3453
|
// src/components/TrackControls/GripIcon.tsx
|
|
3338
|
-
var
|
|
3339
|
-
var
|
|
3340
|
-
var GripIcon = (props) => /* @__PURE__ */ (0,
|
|
3454
|
+
var import_react30 = require("@phosphor-icons/react");
|
|
3455
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3456
|
+
var GripIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react30.DotsSixVerticalIcon, { weight: "bold", ...props });
|
|
3341
3457
|
|
|
3342
3458
|
// src/components/TrackControls/MoveUpIcon.tsx
|
|
3343
|
-
var
|
|
3344
|
-
var
|
|
3345
|
-
var MoveUpIcon = (props) => /* @__PURE__ */ (0,
|
|
3459
|
+
var import_react31 = require("@phosphor-icons/react");
|
|
3460
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3461
|
+
var MoveUpIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react31.CaretUpIcon, { weight: "bold", ...props });
|
|
3346
3462
|
|
|
3347
3463
|
// src/components/TrackControls/MoveDownIcon.tsx
|
|
3348
|
-
var
|
|
3349
|
-
var
|
|
3350
|
-
var MoveDownIcon = (props) => /* @__PURE__ */ (0,
|
|
3464
|
+
var import_react32 = require("@phosphor-icons/react");
|
|
3465
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3466
|
+
var MoveDownIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react32.CaretDownIcon, { weight: "bold", ...props });
|
|
3351
3467
|
|
|
3352
3468
|
// src/components/TrackControls/ReorderRail.tsx
|
|
3353
|
-
var
|
|
3354
|
-
var
|
|
3355
|
-
var Rail =
|
|
3469
|
+
var import_styled_components33 = __toESM(require("styled-components"));
|
|
3470
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3471
|
+
var Rail = import_styled_components33.default.div`
|
|
3356
3472
|
display: flex;
|
|
3357
3473
|
flex-direction: column;
|
|
3358
3474
|
align-items: center;
|
|
@@ -3366,7 +3482,7 @@ var Rail = import_styled_components32.default.div`
|
|
|
3366
3482
|
opacity: 1;
|
|
3367
3483
|
}
|
|
3368
3484
|
`;
|
|
3369
|
-
var RailButton =
|
|
3485
|
+
var RailButton = import_styled_components33.default.button.attrs({ type: "button" })`
|
|
3370
3486
|
border: none;
|
|
3371
3487
|
background: transparent;
|
|
3372
3488
|
color: inherit;
|
|
@@ -3381,7 +3497,7 @@ var RailButton = import_styled_components32.default.button.attrs({ type: "button
|
|
|
3381
3497
|
box-shadow: 0 0 0 0.2rem ${(props) => props.theme.inputFocusBorder}33;
|
|
3382
3498
|
}
|
|
3383
3499
|
`;
|
|
3384
|
-
var ChevronButton = (0,
|
|
3500
|
+
var ChevronButton = (0, import_styled_components33.default)(RailButton)`
|
|
3385
3501
|
width: 16px;
|
|
3386
3502
|
height: 14px;
|
|
3387
3503
|
cursor: pointer;
|
|
@@ -3395,7 +3511,7 @@ var ChevronButton = (0, import_styled_components32.default)(RailButton)`
|
|
|
3395
3511
|
cursor: default;
|
|
3396
3512
|
}
|
|
3397
3513
|
`;
|
|
3398
|
-
var GripButton = (0,
|
|
3514
|
+
var GripButton = (0, import_styled_components33.default)(RailButton)`
|
|
3399
3515
|
width: 16px;
|
|
3400
3516
|
height: 20px;
|
|
3401
3517
|
cursor: grab;
|
|
@@ -3413,24 +3529,24 @@ var ReorderRail = ({
|
|
|
3413
3529
|
gripRef,
|
|
3414
3530
|
onGripClick,
|
|
3415
3531
|
style
|
|
3416
|
-
}) => /* @__PURE__ */ (0,
|
|
3417
|
-
/* @__PURE__ */ (0,
|
|
3418
|
-
/* @__PURE__ */ (0,
|
|
3532
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Rail, { style, children: [
|
|
3533
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronButton, { "aria-label": "Move track up", disabled: upDisabled, onClick: onMoveUp, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(MoveUpIcon, { size: 12 }) }),
|
|
3534
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3419
3535
|
GripButton,
|
|
3420
3536
|
{
|
|
3421
3537
|
ref: gripRef,
|
|
3422
3538
|
"aria-label": "Drag to reorder track",
|
|
3423
3539
|
title: "Drag to reorder track",
|
|
3424
3540
|
onClick: onGripClick,
|
|
3425
|
-
children: /* @__PURE__ */ (0,
|
|
3541
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(GripIcon, { size: 14 })
|
|
3426
3542
|
}
|
|
3427
3543
|
),
|
|
3428
|
-
/* @__PURE__ */ (0,
|
|
3544
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ChevronButton, { "aria-label": "Move track down", disabled: downDisabled, onClick: onMoveDown, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(MoveDownIcon, { size: 12 }) })
|
|
3429
3545
|
] });
|
|
3430
3546
|
|
|
3431
3547
|
// src/components/TrackControls/Slider.tsx
|
|
3432
|
-
var
|
|
3433
|
-
var Slider = (0,
|
|
3548
|
+
var import_styled_components34 = __toESM(require("styled-components"));
|
|
3549
|
+
var Slider = (0, import_styled_components34.default)(BaseSlider)`
|
|
3434
3550
|
width: 75%;
|
|
3435
3551
|
height: 5px;
|
|
3436
3552
|
background: ${(props) => props.theme.sliderTrackColor};
|
|
@@ -3464,6 +3580,19 @@ var Slider = (0, import_styled_components33.default)(BaseSlider)`
|
|
|
3464
3580
|
border-radius: 3px;
|
|
3465
3581
|
}
|
|
3466
3582
|
|
|
3583
|
+
&:disabled {
|
|
3584
|
+
opacity: 0.5;
|
|
3585
|
+
cursor: not-allowed;
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
&:disabled::-webkit-slider-thumb {
|
|
3589
|
+
cursor: not-allowed;
|
|
3590
|
+
}
|
|
3591
|
+
|
|
3592
|
+
&:disabled::-moz-range-thumb {
|
|
3593
|
+
cursor: not-allowed;
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3467
3596
|
&:focus::-webkit-slider-runnable-track {
|
|
3468
3597
|
background: ${(props) => props.theme.inputBorder};
|
|
3469
3598
|
}
|
|
@@ -3482,8 +3611,8 @@ var Slider = (0, import_styled_components33.default)(BaseSlider)`
|
|
|
3482
3611
|
`;
|
|
3483
3612
|
|
|
3484
3613
|
// src/components/TrackControls/SliderWrapper.tsx
|
|
3485
|
-
var
|
|
3486
|
-
var SliderWrapper =
|
|
3614
|
+
var import_styled_components35 = __toESM(require("styled-components"));
|
|
3615
|
+
var SliderWrapper = import_styled_components35.default.label`
|
|
3487
3616
|
width: 100%;
|
|
3488
3617
|
display: flex;
|
|
3489
3618
|
justify-content: space-between;
|
|
@@ -3494,15 +3623,15 @@ var SliderWrapper = import_styled_components34.default.label`
|
|
|
3494
3623
|
`;
|
|
3495
3624
|
|
|
3496
3625
|
// src/components/TrackMenu.tsx
|
|
3497
|
-
var
|
|
3626
|
+
var import_react33 = __toESM(require("react"));
|
|
3498
3627
|
var import_react_dom = require("react-dom");
|
|
3499
|
-
var
|
|
3500
|
-
var
|
|
3501
|
-
var MenuContainer =
|
|
3628
|
+
var import_styled_components36 = __toESM(require("styled-components"));
|
|
3629
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3630
|
+
var MenuContainer = import_styled_components36.default.div`
|
|
3502
3631
|
position: relative;
|
|
3503
3632
|
display: inline-block;
|
|
3504
3633
|
`;
|
|
3505
|
-
var MenuButton =
|
|
3634
|
+
var MenuButton = import_styled_components36.default.button`
|
|
3506
3635
|
background: none;
|
|
3507
3636
|
border: none;
|
|
3508
3637
|
cursor: pointer;
|
|
@@ -3518,10 +3647,10 @@ var MenuButton = import_styled_components35.default.button`
|
|
|
3518
3647
|
}
|
|
3519
3648
|
`;
|
|
3520
3649
|
var DROPDOWN_MIN_WIDTH = 180;
|
|
3521
|
-
var Dropdown =
|
|
3650
|
+
var Dropdown = import_styled_components36.default.div.attrs((p) => ({
|
|
3651
|
+
style: { top: `${p.$top}px`, left: `${p.$left}px` }
|
|
3652
|
+
}))`
|
|
3522
3653
|
position: fixed;
|
|
3523
|
-
top: ${(p) => p.$top}px;
|
|
3524
|
-
left: ${(p) => p.$left}px;
|
|
3525
3654
|
z-index: 10000;
|
|
3526
3655
|
background: ${(p) => p.theme.timescaleBackgroundColor ?? "#222"};
|
|
3527
3656
|
color: ${(p) => p.theme.textColor ?? "inherit"};
|
|
@@ -3531,19 +3660,19 @@ var Dropdown = import_styled_components35.default.div`
|
|
|
3531
3660
|
min-width: ${DROPDOWN_MIN_WIDTH}px;
|
|
3532
3661
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
3533
3662
|
`;
|
|
3534
|
-
var Divider =
|
|
3663
|
+
var Divider = import_styled_components36.default.hr`
|
|
3535
3664
|
border: none;
|
|
3536
3665
|
border-top: 1px solid rgba(128, 128, 128, 0.3);
|
|
3537
3666
|
margin: 0.35rem 0;
|
|
3538
3667
|
`;
|
|
3539
3668
|
var TrackMenu = ({ items: itemsProp }) => {
|
|
3540
|
-
const [open, setOpen] = (0,
|
|
3541
|
-
const close = (0,
|
|
3669
|
+
const [open, setOpen] = (0, import_react33.useState)(false);
|
|
3670
|
+
const close = (0, import_react33.useCallback)(() => setOpen(false), []);
|
|
3542
3671
|
const items = typeof itemsProp === "function" ? itemsProp(close) : itemsProp;
|
|
3543
|
-
const [dropdownPos, setDropdownPos] = (0,
|
|
3544
|
-
const buttonRef = (0,
|
|
3545
|
-
const dropdownRef = (0,
|
|
3546
|
-
const updatePosition = (0,
|
|
3672
|
+
const [dropdownPos, setDropdownPos] = (0, import_react33.useState)({ top: 0, left: 0 });
|
|
3673
|
+
const buttonRef = (0, import_react33.useRef)(null);
|
|
3674
|
+
const dropdownRef = (0, import_react33.useRef)(null);
|
|
3675
|
+
const updatePosition = (0, import_react33.useCallback)(() => {
|
|
3547
3676
|
if (!buttonRef.current) return;
|
|
3548
3677
|
const rect = buttonRef.current.getBoundingClientRect();
|
|
3549
3678
|
const vw = window.innerWidth;
|
|
@@ -3558,23 +3687,30 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3558
3687
|
if (top + dropHeight > vh - 4) {
|
|
3559
3688
|
top = Math.max(4, rect.bottom - dropHeight);
|
|
3560
3689
|
}
|
|
3561
|
-
setDropdownPos({ top, left });
|
|
3690
|
+
setDropdownPos((prev) => prev.top === top && prev.left === left ? prev : { top, left });
|
|
3562
3691
|
}, []);
|
|
3563
|
-
(0,
|
|
3692
|
+
(0, import_react33.useEffect)(() => {
|
|
3564
3693
|
if (!open) return;
|
|
3565
3694
|
updatePosition();
|
|
3566
|
-
|
|
3567
|
-
const
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3695
|
+
let frameId = null;
|
|
3696
|
+
const scheduleUpdate = () => {
|
|
3697
|
+
if (frameId !== null) return;
|
|
3698
|
+
frameId = requestAnimationFrame(() => {
|
|
3699
|
+
frameId = null;
|
|
3700
|
+
updatePosition();
|
|
3701
|
+
});
|
|
3702
|
+
};
|
|
3703
|
+
scheduleUpdate();
|
|
3704
|
+
const scrollOptions = { capture: true, passive: true };
|
|
3705
|
+
window.addEventListener("scroll", scheduleUpdate, scrollOptions);
|
|
3706
|
+
window.addEventListener("resize", scheduleUpdate);
|
|
3571
3707
|
return () => {
|
|
3572
|
-
cancelAnimationFrame(
|
|
3573
|
-
window.removeEventListener("scroll",
|
|
3574
|
-
window.removeEventListener("resize",
|
|
3708
|
+
if (frameId !== null) cancelAnimationFrame(frameId);
|
|
3709
|
+
window.removeEventListener("scroll", scheduleUpdate, scrollOptions);
|
|
3710
|
+
window.removeEventListener("resize", scheduleUpdate);
|
|
3575
3711
|
};
|
|
3576
3712
|
}, [open, updatePosition]);
|
|
3577
|
-
(0,
|
|
3713
|
+
(0, import_react33.useEffect)(() => {
|
|
3578
3714
|
if (!open) return;
|
|
3579
3715
|
const handleClick = (e) => {
|
|
3580
3716
|
const target = e.target;
|
|
@@ -3594,8 +3730,8 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3594
3730
|
document.removeEventListener("keydown", handleKeyDown);
|
|
3595
3731
|
};
|
|
3596
3732
|
}, [open]);
|
|
3597
|
-
return /* @__PURE__ */ (0,
|
|
3598
|
-
/* @__PURE__ */ (0,
|
|
3733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(MenuContainer, { children: [
|
|
3734
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3599
3735
|
MenuButton,
|
|
3600
3736
|
{
|
|
3601
3737
|
ref: buttonRef,
|
|
@@ -3606,19 +3742,19 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3606
3742
|
onMouseDown: (e) => e.stopPropagation(),
|
|
3607
3743
|
title: "Track menu",
|
|
3608
3744
|
"aria-label": "Track menu",
|
|
3609
|
-
children: /* @__PURE__ */ (0,
|
|
3745
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DotsIcon, { size: 16 })
|
|
3610
3746
|
}
|
|
3611
3747
|
),
|
|
3612
3748
|
open && typeof document !== "undefined" && (0, import_react_dom.createPortal)(
|
|
3613
|
-
/* @__PURE__ */ (0,
|
|
3749
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3614
3750
|
Dropdown,
|
|
3615
3751
|
{
|
|
3616
3752
|
ref: dropdownRef,
|
|
3617
3753
|
$top: dropdownPos.top,
|
|
3618
3754
|
$left: dropdownPos.left,
|
|
3619
3755
|
onMouseDown: (e) => e.stopPropagation(),
|
|
3620
|
-
children: items.map((item, index) => /* @__PURE__ */ (0,
|
|
3621
|
-
index > 0 && /* @__PURE__ */ (0,
|
|
3756
|
+
children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_react33.default.Fragment, { children: [
|
|
3757
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Divider, {}),
|
|
3622
3758
|
item.content
|
|
3623
3759
|
] }, item.id))
|
|
3624
3760
|
}
|
|
@@ -3629,10 +3765,10 @@ var TrackMenu = ({ items: itemsProp }) => {
|
|
|
3629
3765
|
};
|
|
3630
3766
|
|
|
3631
3767
|
// src/components/SegmentedVUMeter.tsx
|
|
3632
|
-
var
|
|
3633
|
-
var
|
|
3768
|
+
var import_react34 = __toESM(require("react"));
|
|
3769
|
+
var import_styled_components37 = __toESM(require("styled-components"));
|
|
3634
3770
|
var import_core8 = require("@waveform-playlist/core");
|
|
3635
|
-
var
|
|
3771
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3636
3772
|
var DEFAULT_COLOR_STOPS = [
|
|
3637
3773
|
{ dB: 2, color: "#ff0000" },
|
|
3638
3774
|
{ dB: -1, color: "#e74c3c" },
|
|
@@ -3660,6 +3796,29 @@ function getColorForDb(dB, colorStops) {
|
|
|
3660
3796
|
}
|
|
3661
3797
|
return colorStops[colorStops.length - 1].color;
|
|
3662
3798
|
}
|
|
3799
|
+
function closestThresholdIndex(thresholds, dB) {
|
|
3800
|
+
let index = -1;
|
|
3801
|
+
let minDist = Infinity;
|
|
3802
|
+
for (let i = 0; i < thresholds.length; i++) {
|
|
3803
|
+
const dist = Math.abs(thresholds[i] - dB);
|
|
3804
|
+
if (dist < minDist) {
|
|
3805
|
+
minDist = dist;
|
|
3806
|
+
index = i;
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
return index;
|
|
3810
|
+
}
|
|
3811
|
+
function segmentVisual(active, isPeak, color, coloredInactive) {
|
|
3812
|
+
return {
|
|
3813
|
+
backgroundColor: isPeak ? PEAK_COLOR : active || coloredInactive ? color : INACTIVE_COLOR,
|
|
3814
|
+
opacity: isPeak || active ? "1" : coloredInactive ? String(INACTIVE_OPACITY) : "1",
|
|
3815
|
+
boxShadow: active || isPeak ? `0 0 4px ${isPeak ? PEAK_COLOR : color}40` : "none"
|
|
3816
|
+
};
|
|
3817
|
+
}
|
|
3818
|
+
var NO_LEVELS = [];
|
|
3819
|
+
var subscribeToNothing = () => () => {
|
|
3820
|
+
};
|
|
3821
|
+
var NO_METER = -1;
|
|
3663
3822
|
function computeThresholds(segmentCount, dBRange) {
|
|
3664
3823
|
const safeCount = Math.max(2, segmentCount);
|
|
3665
3824
|
const [minDb, maxDb] = dBRange;
|
|
@@ -3669,48 +3828,46 @@ function computeThresholds(segmentCount, dBRange) {
|
|
|
3669
3828
|
function formatDbLabel(dB) {
|
|
3670
3829
|
return Math.round(dB).toString();
|
|
3671
3830
|
}
|
|
3672
|
-
var MeterContainer =
|
|
3831
|
+
var MeterContainer = import_styled_components37.default.div`
|
|
3673
3832
|
display: inline-flex;
|
|
3674
3833
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "column" : "row"};
|
|
3675
3834
|
gap: 4px;
|
|
3676
3835
|
font-family: 'Courier New', monospace;
|
|
3677
3836
|
`;
|
|
3678
|
-
var ChannelColumn =
|
|
3837
|
+
var ChannelColumn = import_styled_components37.default.div`
|
|
3679
3838
|
display: flex;
|
|
3680
3839
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "row" : "column"};
|
|
3681
3840
|
align-items: center;
|
|
3682
3841
|
gap: 4px;
|
|
3683
3842
|
`;
|
|
3684
|
-
var SegmentStack =
|
|
3843
|
+
var SegmentStack = import_styled_components37.default.div`
|
|
3685
3844
|
display: flex;
|
|
3686
3845
|
flex-direction: ${(props) => props.$orientation === "horizontal" ? "row" : "column"};
|
|
3687
3846
|
`;
|
|
3688
|
-
var Segment =
|
|
3847
|
+
var Segment = import_styled_components37.default.div.attrs((props) => ({
|
|
3689
3848
|
style: {
|
|
3690
3849
|
width: `${props.$width}px`,
|
|
3691
3850
|
height: `${props.$height}px`,
|
|
3692
3851
|
...props.$orientation === "horizontal" ? { marginRight: `${props.$gap}px` } : { marginBottom: `${props.$gap}px` },
|
|
3693
|
-
|
|
3694
|
-
opacity: props.$isPeak || props.$active ? 1 : props.$coloredInactive ? INACTIVE_OPACITY : 1,
|
|
3695
|
-
boxShadow: props.$active || props.$isPeak ? `0 0 4px ${props.$isPeak ? PEAK_COLOR : props.$color}40` : "none"
|
|
3852
|
+
...segmentVisual(props.$active, props.$isPeak, props.$color, props.$coloredInactive)
|
|
3696
3853
|
}
|
|
3697
3854
|
}))`
|
|
3698
3855
|
border-radius: 1px;
|
|
3699
3856
|
`;
|
|
3700
3857
|
var DEFAULT_LABEL_COLOR = "#888";
|
|
3701
|
-
var ChannelLabel =
|
|
3858
|
+
var ChannelLabel = import_styled_components37.default.div`
|
|
3702
3859
|
color: ${(props) => props.$labelColor};
|
|
3703
3860
|
font-size: 10px;
|
|
3704
3861
|
text-align: center;
|
|
3705
3862
|
user-select: none;
|
|
3706
3863
|
`;
|
|
3707
|
-
var ScaleColumn =
|
|
3864
|
+
var ScaleColumn = import_styled_components37.default.div`
|
|
3708
3865
|
display: flex;
|
|
3709
3866
|
flex-direction: column;
|
|
3710
3867
|
position: relative;
|
|
3711
3868
|
min-width: 28px;
|
|
3712
3869
|
`;
|
|
3713
|
-
var ScaleLabel =
|
|
3870
|
+
var ScaleLabel = import_styled_components37.default.div.attrs((props) => ({
|
|
3714
3871
|
style: {
|
|
3715
3872
|
top: `${props.$top}px`,
|
|
3716
3873
|
color: props.$labelColor
|
|
@@ -3724,19 +3881,19 @@ var ScaleLabel = import_styled_components36.default.div.attrs((props) => ({
|
|
|
3724
3881
|
transform: translate(-50%, -50%);
|
|
3725
3882
|
user-select: none;
|
|
3726
3883
|
`;
|
|
3727
|
-
var HorizontalScaleWrapper =
|
|
3884
|
+
var HorizontalScaleWrapper = import_styled_components37.default.div`
|
|
3728
3885
|
display: flex;
|
|
3729
3886
|
flex-direction: row;
|
|
3730
3887
|
align-items: center;
|
|
3731
3888
|
gap: 4px;
|
|
3732
3889
|
`;
|
|
3733
|
-
var ScaleRow =
|
|
3890
|
+
var ScaleRow = import_styled_components37.default.div`
|
|
3734
3891
|
display: flex;
|
|
3735
3892
|
flex-direction: row;
|
|
3736
3893
|
position: relative;
|
|
3737
3894
|
min-height: 16px;
|
|
3738
3895
|
`;
|
|
3739
|
-
var ScaleLabelHorizontal =
|
|
3896
|
+
var ScaleLabelHorizontal = import_styled_components37.default.div.attrs((props) => ({
|
|
3740
3897
|
style: {
|
|
3741
3898
|
left: `${props.$left}px`,
|
|
3742
3899
|
color: props.$labelColor
|
|
@@ -3751,8 +3908,9 @@ var ScaleLabelHorizontal = import_styled_components36.default.div.attrs((props)
|
|
|
3751
3908
|
user-select: none;
|
|
3752
3909
|
`;
|
|
3753
3910
|
var SegmentedVUMeterInner = ({
|
|
3754
|
-
|
|
3755
|
-
|
|
3911
|
+
meter,
|
|
3912
|
+
levels: levelsProp,
|
|
3913
|
+
peakLevels: peakLevelsProp,
|
|
3756
3914
|
channelLabels,
|
|
3757
3915
|
orientation = "vertical",
|
|
3758
3916
|
segmentCount = 24,
|
|
@@ -3766,9 +3924,28 @@ var SegmentedVUMeterInner = ({
|
|
|
3766
3924
|
labelColor,
|
|
3767
3925
|
className
|
|
3768
3926
|
}) => {
|
|
3769
|
-
const
|
|
3927
|
+
const subscribeToMeter = (0, import_react34.useCallback)(
|
|
3928
|
+
(onChange) => meter ? meter.subscribe(onChange) : subscribeToNothing(),
|
|
3929
|
+
[meter]
|
|
3930
|
+
);
|
|
3931
|
+
const getMeterChannelCount = (0, import_react34.useCallback)(
|
|
3932
|
+
() => meter ? meter.getSnapshot().levels.length : NO_METER,
|
|
3933
|
+
[meter]
|
|
3934
|
+
);
|
|
3935
|
+
const meterChannelCount = (0, import_react34.useSyncExternalStore)(
|
|
3936
|
+
subscribeToMeter,
|
|
3937
|
+
getMeterChannelCount,
|
|
3938
|
+
getMeterChannelCount
|
|
3939
|
+
);
|
|
3940
|
+
const meterSnapshot = meter ? meter.getSnapshot() : null;
|
|
3941
|
+
const levels = meterSnapshot ? meterSnapshot.levels : levelsProp ?? NO_LEVELS;
|
|
3942
|
+
const peakLevels = meterSnapshot ? meterSnapshot.peakLevels : peakLevelsProp;
|
|
3943
|
+
const containerRef = (0, import_react34.useRef)(null);
|
|
3944
|
+
const redrawRef = (0, import_react34.useRef)(null);
|
|
3945
|
+
const sourceKey = meter ? "meter" : "props";
|
|
3946
|
+
const channelCount = meter ? meterChannelCount : levels.length;
|
|
3947
|
+
const labels = channelLabels ?? getDefaultLabels(channelCount);
|
|
3770
3948
|
const resolvedLabelColor = labelColor ?? DEFAULT_LABEL_COLOR;
|
|
3771
|
-
const channelCount = levels.length;
|
|
3772
3949
|
if (process.env.NODE_ENV !== "production" && peakLevels != null && peakLevels.length !== channelCount) {
|
|
3773
3950
|
console.warn(
|
|
3774
3951
|
`[waveform-playlist] SegmentedVUMeter: peakLevels length (${peakLevels.length}) does not match levels length (${channelCount})`
|
|
@@ -3777,11 +3954,11 @@ var SegmentedVUMeterInner = ({
|
|
|
3777
3954
|
const isMultiChannel = channelCount >= 2;
|
|
3778
3955
|
const segmentTotalHeight = segmentHeight + segmentGap;
|
|
3779
3956
|
const [dBMin, dBMax] = dBRange;
|
|
3780
|
-
const thresholds = (0,
|
|
3957
|
+
const thresholds = (0, import_react34.useMemo)(
|
|
3781
3958
|
() => computeThresholds(segmentCount, [dBMin, dBMax]),
|
|
3782
3959
|
[segmentCount, dBMin, dBMax]
|
|
3783
3960
|
);
|
|
3784
|
-
const scaleLabels = (0,
|
|
3961
|
+
const scaleLabels = (0, import_react34.useMemo)(() => {
|
|
3785
3962
|
const totalSize = segmentCount * segmentTotalHeight - segmentGap;
|
|
3786
3963
|
const minDb = dBMin;
|
|
3787
3964
|
const maxDb = dBMax;
|
|
@@ -3801,32 +3978,67 @@ var SegmentedVUMeterInner = ({
|
|
|
3801
3978
|
}
|
|
3802
3979
|
return labels2;
|
|
3803
3980
|
}, [orientation, segmentCount, segmentTotalHeight, segmentGap, dBMin, dBMax]);
|
|
3804
|
-
const renderThresholds = (0,
|
|
3981
|
+
const renderThresholds = (0, import_react34.useMemo)(
|
|
3805
3982
|
() => orientation === "horizontal" ? [...thresholds].reverse() : thresholds,
|
|
3806
3983
|
[thresholds, orientation]
|
|
3807
3984
|
);
|
|
3808
|
-
const
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3985
|
+
const segmentColors = (0, import_react34.useMemo)(
|
|
3986
|
+
() => renderThresholds.map((threshold) => getColorForDb(threshold, colorStops)),
|
|
3987
|
+
[renderThresholds, colorStops]
|
|
3988
|
+
);
|
|
3989
|
+
(0, import_react34.useLayoutEffect)(() => {
|
|
3990
|
+
const container = containerRef.current;
|
|
3991
|
+
if (!meter || !container) return;
|
|
3992
|
+
const channels = Array.from(container.querySelectorAll("[data-channel]")).map(
|
|
3993
|
+
(channel) => Array.from(channel.querySelectorAll("[data-segment]"))
|
|
3994
|
+
);
|
|
3995
|
+
const drawn = channels.map((segments) => new Uint8Array(segments.length).fill(255));
|
|
3996
|
+
const draw = (value) => {
|
|
3997
|
+
for (let ch = 0; ch < channels.length; ch++) {
|
|
3998
|
+
const segments = channels[ch];
|
|
3999
|
+
const levelDb = (0, import_core8.normalizedToDb)(value.levels[ch] ?? 0);
|
|
4000
|
+
const peak = value.peakLevels[ch];
|
|
4001
|
+
const peakIndex = peak === void 0 ? -1 : closestThresholdIndex(renderThresholds, (0, import_core8.normalizedToDb)(peak));
|
|
4002
|
+
for (let i = 0; i < segments.length; i++) {
|
|
4003
|
+
const active = levelDb >= renderThresholds[i];
|
|
4004
|
+
const isPeak = i === peakIndex;
|
|
4005
|
+
const state = (active ? 1 : 0) | (isPeak ? 2 : 0);
|
|
4006
|
+
if (drawn[ch][i] === state) continue;
|
|
4007
|
+
drawn[ch][i] = state;
|
|
4008
|
+
const segment = segments[i];
|
|
4009
|
+
const visual = segmentVisual(active, isPeak, segmentColors[i], coloredInactive);
|
|
4010
|
+
segment.style.backgroundColor = visual.backgroundColor;
|
|
4011
|
+
segment.style.opacity = visual.opacity;
|
|
4012
|
+
segment.style.boxShadow = visual.boxShadow;
|
|
4013
|
+
segment.toggleAttribute("data-peak", isPeak);
|
|
3820
4014
|
}
|
|
3821
4015
|
}
|
|
3822
|
-
}
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
4016
|
+
};
|
|
4017
|
+
redrawRef.current = () => {
|
|
4018
|
+
for (const states of drawn) states.fill(255);
|
|
4019
|
+
draw(meter.getSnapshot());
|
|
4020
|
+
};
|
|
4021
|
+
const unsubscribe = meter.subscribe((value) => draw(value));
|
|
4022
|
+
return () => {
|
|
4023
|
+
unsubscribe();
|
|
4024
|
+
redrawRef.current = null;
|
|
4025
|
+
};
|
|
4026
|
+
}, [meter, channelCount, renderThresholds, segmentColors, coloredInactive, orientation]);
|
|
4027
|
+
(0, import_react34.useLayoutEffect)(() => {
|
|
4028
|
+
redrawRef.current?.();
|
|
4029
|
+
});
|
|
4030
|
+
const renderChannel = (channelIndex) => {
|
|
4031
|
+
const level = levels[channelIndex] ?? 0;
|
|
4032
|
+
const levelDb = (0, import_core8.normalizedToDb)(level);
|
|
4033
|
+
const peak = peakLevels?.[channelIndex];
|
|
4034
|
+
const peakSegmentIndex = peak === void 0 ? -1 : closestThresholdIndex(renderThresholds, (0, import_core8.normalizedToDb)(peak));
|
|
4035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(ChannelColumn, { $orientation: orientation, "data-channel": true, children: [
|
|
4036
|
+
orientation === "horizontal" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChannelLabel, { $labelColor: resolvedLabelColor, children: labels[channelIndex] }),
|
|
4037
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SegmentStack, { $orientation: orientation, children: renderThresholds.map((threshold, segIdx) => {
|
|
3826
4038
|
const active = levelDb >= threshold;
|
|
3827
4039
|
const isPeak = segIdx === peakSegmentIndex;
|
|
3828
|
-
const color =
|
|
3829
|
-
return /* @__PURE__ */ (0,
|
|
4040
|
+
const color = segmentColors[segIdx];
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3830
4042
|
Segment,
|
|
3831
4043
|
{
|
|
3832
4044
|
$width: orientation === "horizontal" ? segmentHeight : segmentWidth,
|
|
@@ -3838,30 +4050,31 @@ var SegmentedVUMeterInner = ({
|
|
|
3838
4050
|
$orientation: orientation,
|
|
3839
4051
|
$coloredInactive: coloredInactive,
|
|
3840
4052
|
"data-segment": true,
|
|
3841
|
-
...isPeak ? { "data-peak":
|
|
4053
|
+
...isPeak ? { "data-peak": "" } : {}
|
|
3842
4054
|
},
|
|
3843
4055
|
segIdx
|
|
3844
4056
|
);
|
|
3845
4057
|
}) }),
|
|
3846
|
-
orientation === "vertical" && /* @__PURE__ */ (0,
|
|
4058
|
+
orientation === "vertical" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChannelLabel, { $labelColor: resolvedLabelColor, children: labels[channelIndex] })
|
|
3847
4059
|
] }, channelIndex);
|
|
3848
4060
|
};
|
|
3849
4061
|
const renderScale = () => {
|
|
3850
4062
|
if (orientation === "horizontal") {
|
|
3851
4063
|
const totalWidth = segmentCount * segmentTotalHeight - segmentGap;
|
|
3852
|
-
return /* @__PURE__ */ (0,
|
|
3853
|
-
/* @__PURE__ */ (0,
|
|
3854
|
-
/* @__PURE__ */ (0,
|
|
4064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(HorizontalScaleWrapper, { children: [
|
|
4065
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ChannelLabel, { $labelColor: resolvedLabelColor, style: { visibility: "hidden" }, children: "L" }),
|
|
4066
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ScaleRow, { style: { width: `${totalWidth}px` }, children: scaleLabels.map(({ position, label: label2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ScaleLabelHorizontal, { $left: position, $labelColor: resolvedLabelColor, children: label2 }, i)) })
|
|
3855
4067
|
] });
|
|
3856
4068
|
}
|
|
3857
4069
|
const totalHeight = segmentCount * segmentTotalHeight - segmentGap;
|
|
3858
|
-
return /* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ScaleColumn, { style: { height: `${totalHeight}px` }, children: scaleLabels.map(({ position, label: label2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ScaleLabel, { $top: position, $labelColor: resolvedLabelColor, children: label2 }, i)) });
|
|
3859
4071
|
};
|
|
3860
4072
|
if (isMultiChannel) {
|
|
3861
4073
|
if (orientation === "horizontal") {
|
|
3862
|
-
return /* @__PURE__ */ (0,
|
|
4074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
3863
4075
|
MeterContainer,
|
|
3864
4076
|
{
|
|
4077
|
+
ref: containerRef,
|
|
3865
4078
|
className,
|
|
3866
4079
|
$orientation: orientation,
|
|
3867
4080
|
"data-meter-orientation": orientation,
|
|
@@ -3869,15 +4082,17 @@ var SegmentedVUMeterInner = ({
|
|
|
3869
4082
|
Array.from({ length: channelCount }, (_, i) => renderChannel(i)),
|
|
3870
4083
|
showScale && renderScale()
|
|
3871
4084
|
]
|
|
3872
|
-
}
|
|
4085
|
+
},
|
|
4086
|
+
sourceKey
|
|
3873
4087
|
);
|
|
3874
4088
|
}
|
|
3875
4089
|
const midpoint = Math.ceil(channelCount / 2);
|
|
3876
4090
|
const leftChannels = Array.from({ length: midpoint }, (_, i) => i);
|
|
3877
4091
|
const rightChannels = Array.from({ length: channelCount - midpoint }, (_, i) => midpoint + i);
|
|
3878
|
-
return /* @__PURE__ */ (0,
|
|
4092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
3879
4093
|
MeterContainer,
|
|
3880
4094
|
{
|
|
4095
|
+
ref: containerRef,
|
|
3881
4096
|
className,
|
|
3882
4097
|
$orientation: orientation,
|
|
3883
4098
|
"data-meter-orientation": orientation,
|
|
@@ -3886,12 +4101,14 @@ var SegmentedVUMeterInner = ({
|
|
|
3886
4101
|
showScale && renderScale(),
|
|
3887
4102
|
rightChannels.map(renderChannel)
|
|
3888
4103
|
]
|
|
3889
|
-
}
|
|
4104
|
+
},
|
|
4105
|
+
sourceKey
|
|
3890
4106
|
);
|
|
3891
4107
|
}
|
|
3892
|
-
return /* @__PURE__ */ (0,
|
|
4108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
3893
4109
|
MeterContainer,
|
|
3894
4110
|
{
|
|
4111
|
+
ref: containerRef,
|
|
3895
4112
|
className,
|
|
3896
4113
|
$orientation: orientation,
|
|
3897
4114
|
"data-meter-orientation": orientation,
|
|
@@ -3899,33 +4116,56 @@ var SegmentedVUMeterInner = ({
|
|
|
3899
4116
|
renderChannel(0),
|
|
3900
4117
|
showScale && renderScale()
|
|
3901
4118
|
]
|
|
3902
|
-
}
|
|
4119
|
+
},
|
|
4120
|
+
sourceKey
|
|
3903
4121
|
);
|
|
3904
4122
|
};
|
|
3905
|
-
var SegmentedVUMeter =
|
|
4123
|
+
var SegmentedVUMeter = import_react34.default.memo(SegmentedVUMeterInner);
|
|
3906
4124
|
|
|
3907
|
-
// src/
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
}
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
4125
|
+
// src/hooks/useThrottledValue.ts
|
|
4126
|
+
var import_react35 = require("react");
|
|
4127
|
+
var DEFAULT_UPDATE_RATE = 10;
|
|
4128
|
+
function useThrottledValue(source, options = {}) {
|
|
4129
|
+
const { updateRate = DEFAULT_UPDATE_RATE } = options;
|
|
4130
|
+
const [state, setState] = (0, import_react35.useState)(() => ({
|
|
4131
|
+
source,
|
|
4132
|
+
value: source.getSnapshot()
|
|
4133
|
+
}));
|
|
4134
|
+
(0, import_react35.useEffect)(() => {
|
|
4135
|
+
const interval = 1e3 / (updateRate > 0 ? updateRate : 1);
|
|
4136
|
+
let lastUpdate = -Infinity;
|
|
4137
|
+
let timer = null;
|
|
4138
|
+
const flush = () => {
|
|
4139
|
+
timer = null;
|
|
4140
|
+
lastUpdate = performance.now();
|
|
4141
|
+
const value = source.getSnapshot();
|
|
4142
|
+
setState(
|
|
4143
|
+
(prev) => prev.source === source && prev.value === value ? prev : { source, value }
|
|
4144
|
+
);
|
|
4145
|
+
};
|
|
4146
|
+
const unsubscribe = source.subscribe(() => {
|
|
4147
|
+
if (timer !== null) return;
|
|
4148
|
+
const wait = interval - (performance.now() - lastUpdate);
|
|
4149
|
+
if (wait <= 0) {
|
|
4150
|
+
flush();
|
|
4151
|
+
} else {
|
|
4152
|
+
timer = setTimeout(flush, wait);
|
|
4153
|
+
}
|
|
4154
|
+
});
|
|
4155
|
+
flush();
|
|
4156
|
+
lastUpdate = -Infinity;
|
|
4157
|
+
return () => {
|
|
4158
|
+
unsubscribe();
|
|
4159
|
+
if (timer !== null) clearTimeout(timer);
|
|
4160
|
+
};
|
|
4161
|
+
}, [source, updateRate]);
|
|
4162
|
+
return state.source === source ? state.value : source.getSnapshot();
|
|
3922
4163
|
}
|
|
3923
|
-
function
|
|
3924
|
-
return
|
|
4164
|
+
function useMeterLevels(meter, options = {}) {
|
|
4165
|
+
return useThrottledValue(meter, options);
|
|
3925
4166
|
}
|
|
3926
4167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3927
4168
|
0 && (module.exports = {
|
|
3928
|
-
AudioPosition,
|
|
3929
4169
|
AutomaticScrollCheckbox,
|
|
3930
4170
|
BaseButton,
|
|
3931
4171
|
BaseCheckbox,
|
|
@@ -3949,9 +4189,14 @@ function secondsToPixels2(seconds, samplesPerPixel, sampleRate) {
|
|
|
3949
4189
|
ClipBoundary,
|
|
3950
4190
|
ClipHeader,
|
|
3951
4191
|
ClipHeaderPresentational,
|
|
4192
|
+
ClipPlaceholderBody,
|
|
3952
4193
|
ClipViewportOriginProvider,
|
|
3953
4194
|
CloseButton,
|
|
3954
4195
|
Controls,
|
|
4196
|
+
DEFAULT_BAR_GAP,
|
|
4197
|
+
DEFAULT_BAR_WIDTH,
|
|
4198
|
+
DEFAULT_PLAYBACK_RATES,
|
|
4199
|
+
DEFAULT_WAVE_HEIGHT,
|
|
3955
4200
|
DevicePixelRatioProvider,
|
|
3956
4201
|
DotsIcon,
|
|
3957
4202
|
FadeOverlay,
|
|
@@ -3964,12 +4209,12 @@ function secondsToPixels2(seconds, samplesPerPixel, sampleRate) {
|
|
|
3964
4209
|
MoveDownIcon,
|
|
3965
4210
|
MoveUpIcon,
|
|
3966
4211
|
PianoRollChannel,
|
|
4212
|
+
PlaybackRateSelect,
|
|
3967
4213
|
Playhead,
|
|
3968
4214
|
PlayheadWithMarker,
|
|
3969
4215
|
Playlist,
|
|
3970
4216
|
PlaylistErrorBoundary,
|
|
3971
4217
|
PlaylistInfoContext,
|
|
3972
|
-
PlayoutProvider,
|
|
3973
4218
|
ReorderRail,
|
|
3974
4219
|
ScreenReaderOnly,
|
|
3975
4220
|
ScrollViewportProvider,
|
|
@@ -3989,7 +4234,6 @@ function secondsToPixels2(seconds, samplesPerPixel, sampleRate) {
|
|
|
3989
4234
|
TimeScale,
|
|
3990
4235
|
TimescaleLoopRegion,
|
|
3991
4236
|
Track,
|
|
3992
|
-
TrackControlsContext,
|
|
3993
4237
|
TrackMenu,
|
|
3994
4238
|
TrashIcon,
|
|
3995
4239
|
VolumeDownIcon,
|
|
@@ -4000,22 +4244,15 @@ function secondsToPixels2(seconds, samplesPerPixel, sampleRate) {
|
|
|
4000
4244
|
getScaleInfo,
|
|
4001
4245
|
isWaveformGradient,
|
|
4002
4246
|
parseTime,
|
|
4003
|
-
pixelsToSamples,
|
|
4004
|
-
pixelsToSeconds,
|
|
4005
|
-
samplesToPixels,
|
|
4006
|
-
samplesToSeconds,
|
|
4007
|
-
secondsToPixels,
|
|
4008
|
-
secondsToSamples,
|
|
4009
4247
|
useBeatsAndBars,
|
|
4010
4248
|
useClipViewportOrigin,
|
|
4011
4249
|
useDevicePixelRatio,
|
|
4250
|
+
useMeterLevels,
|
|
4012
4251
|
usePlaylistInfo,
|
|
4013
|
-
usePlayoutStatus,
|
|
4014
|
-
usePlayoutStatusUpdate,
|
|
4015
4252
|
useScrollViewport,
|
|
4016
4253
|
useScrollViewportSelector,
|
|
4017
4254
|
useTheme,
|
|
4018
|
-
|
|
4255
|
+
useThrottledValue,
|
|
4019
4256
|
useVisibleChunkIndices,
|
|
4020
4257
|
waveformColorToCss
|
|
4021
4258
|
});
|