@livo-tv/blocks 1.12.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +321 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +255 -120
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var React9 = require('react');
|
|
5
5
|
var lucideReact = require('lucide-react');
|
|
6
6
|
var clsx = require('clsx');
|
|
7
7
|
var tailwindMerge = require('tailwind-merge');
|
|
@@ -35,16 +35,16 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var React9__namespace = /*#__PURE__*/_interopNamespace(React9);
|
|
39
39
|
var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
|
|
40
40
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
41
41
|
var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
|
|
42
42
|
var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
|
|
43
43
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
44
44
|
|
|
45
|
-
var LanguageContext =
|
|
45
|
+
var LanguageContext = React9.createContext(null);
|
|
46
46
|
function useLanguageContext() {
|
|
47
|
-
return
|
|
47
|
+
return React9.useContext(LanguageContext);
|
|
48
48
|
}
|
|
49
49
|
function cn(...inputs) {
|
|
50
50
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
@@ -651,20 +651,20 @@ function useEditableSection({
|
|
|
651
651
|
...DEFAULT_EDITABLE_SECTION_LABELS,
|
|
652
652
|
...labels
|
|
653
653
|
};
|
|
654
|
-
const [mode, setMode] =
|
|
655
|
-
const [status, setStatus] =
|
|
656
|
-
const [confirmOpen, setConfirmOpen] =
|
|
657
|
-
const [minHeightPx, setMinHeightPx] =
|
|
658
|
-
const contentRef =
|
|
659
|
-
const editButtonRef =
|
|
660
|
-
const measuredHeightRef =
|
|
661
|
-
const shouldFocusEditRef =
|
|
662
|
-
const shouldFocusFirstFieldRef =
|
|
663
|
-
const editButtonId =
|
|
664
|
-
const contentFormId =
|
|
654
|
+
const [mode, setMode] = React9.useState("reading");
|
|
655
|
+
const [status, setStatus] = React9.useState(null);
|
|
656
|
+
const [confirmOpen, setConfirmOpen] = React9.useState(false);
|
|
657
|
+
const [minHeightPx, setMinHeightPx] = React9.useState(void 0);
|
|
658
|
+
const contentRef = React9.useRef(null);
|
|
659
|
+
const editButtonRef = React9.useRef(null);
|
|
660
|
+
const measuredHeightRef = React9.useRef(0);
|
|
661
|
+
const shouldFocusEditRef = React9.useRef(false);
|
|
662
|
+
const shouldFocusFirstFieldRef = React9.useRef(false);
|
|
663
|
+
const editButtonId = React9.useId();
|
|
664
|
+
const contentFormId = React9.useId();
|
|
665
665
|
const isEditing = mode === "editing" || mode === "saving";
|
|
666
666
|
const isSaving = mode === "saving";
|
|
667
|
-
|
|
667
|
+
React9.useEffect(() => {
|
|
668
668
|
if (mode === "reading" && shouldFocusEditRef.current) {
|
|
669
669
|
shouldFocusEditRef.current = false;
|
|
670
670
|
editButtonRef.current?.focus();
|
|
@@ -682,18 +682,18 @@ function useEditableSection({
|
|
|
682
682
|
focusFirstField(contentRef.current);
|
|
683
683
|
}
|
|
684
684
|
}, [mode]);
|
|
685
|
-
const exitToReading =
|
|
685
|
+
const exitToReading = React9.useCallback(() => {
|
|
686
686
|
setConfirmOpen(false);
|
|
687
687
|
shouldFocusEditRef.current = true;
|
|
688
688
|
setMode("reading");
|
|
689
689
|
onDiscard?.();
|
|
690
690
|
}, [onDiscard]);
|
|
691
|
-
const startEdit =
|
|
691
|
+
const startEdit = React9.useCallback(() => {
|
|
692
692
|
setStatus(null);
|
|
693
693
|
shouldFocusFirstFieldRef.current = true;
|
|
694
694
|
setMode("editing");
|
|
695
695
|
}, []);
|
|
696
|
-
const requestCancel =
|
|
696
|
+
const requestCancel = React9.useCallback(() => {
|
|
697
697
|
if (isSaving) return;
|
|
698
698
|
if (isDirty) {
|
|
699
699
|
setConfirmOpen(true);
|
|
@@ -701,7 +701,7 @@ function useEditableSection({
|
|
|
701
701
|
}
|
|
702
702
|
exitToReading();
|
|
703
703
|
}, [exitToReading, isDirty, isSaving]);
|
|
704
|
-
const handleSubmit =
|
|
704
|
+
const handleSubmit = React9.useCallback(
|
|
705
705
|
(event) => {
|
|
706
706
|
event.preventDefault();
|
|
707
707
|
if (isSaving) return;
|
|
@@ -721,7 +721,7 @@ function useEditableSection({
|
|
|
721
721
|
},
|
|
722
722
|
[isSaving, onSave, resolvedLabels.saved]
|
|
723
723
|
);
|
|
724
|
-
const handleFormKeyDown =
|
|
724
|
+
const handleFormKeyDown = React9.useCallback(
|
|
725
725
|
(event) => {
|
|
726
726
|
if (event.key !== "Escape") return;
|
|
727
727
|
event.preventDefault();
|
|
@@ -729,7 +729,7 @@ function useEditableSection({
|
|
|
729
729
|
},
|
|
730
730
|
[requestCancel]
|
|
731
731
|
);
|
|
732
|
-
|
|
732
|
+
React9.useEffect(() => {
|
|
733
733
|
if (!stableHeight || !isEditing) return;
|
|
734
734
|
const el = contentRef.current;
|
|
735
735
|
if (!el) return;
|
|
@@ -968,13 +968,13 @@ function SafeImage({
|
|
|
968
968
|
onError,
|
|
969
969
|
...imgProps
|
|
970
970
|
}) {
|
|
971
|
-
const [failed, setFailed] =
|
|
972
|
-
const imgRef =
|
|
971
|
+
const [failed, setFailed] = React9.useState(false);
|
|
972
|
+
const imgRef = React9.useRef(null);
|
|
973
973
|
const resolvedSrc = typeof src === "string" && src.length > 0 ? src : null;
|
|
974
|
-
|
|
974
|
+
React9.useLayoutEffect(() => {
|
|
975
975
|
setFailed(false);
|
|
976
976
|
}, [resolvedSrc]);
|
|
977
|
-
|
|
977
|
+
React9.useLayoutEffect(() => {
|
|
978
978
|
const img = imgRef.current;
|
|
979
979
|
if (img && isBrokenImage(img)) {
|
|
980
980
|
setFailed(true);
|
|
@@ -1045,18 +1045,18 @@ function ThemeSwitcher({
|
|
|
1045
1045
|
labels: userLabels
|
|
1046
1046
|
}) {
|
|
1047
1047
|
const { theme, setTheme } = nextThemes.useTheme();
|
|
1048
|
-
const [mounted, setMounted] =
|
|
1048
|
+
const [mounted, setMounted] = React9.useState(false);
|
|
1049
1049
|
const reduceMotion = framerMotion.useReducedMotion();
|
|
1050
1050
|
const sizes = sizeClasses[size];
|
|
1051
1051
|
const shapeClass = shapeClasses[shape];
|
|
1052
1052
|
const labels = { ...defaultLabels, ...userLabels };
|
|
1053
|
-
const handleThemeClick =
|
|
1053
|
+
const handleThemeClick = React9.useCallback(
|
|
1054
1054
|
(themeKey) => {
|
|
1055
1055
|
setTheme(themeKey);
|
|
1056
1056
|
},
|
|
1057
1057
|
[setTheme]
|
|
1058
1058
|
);
|
|
1059
|
-
|
|
1059
|
+
React9.useEffect(() => {
|
|
1060
1060
|
setMounted(true);
|
|
1061
1061
|
}, []);
|
|
1062
1062
|
if (!mounted) {
|
|
@@ -1336,7 +1336,7 @@ function Slider({
|
|
|
1336
1336
|
max = 100,
|
|
1337
1337
|
...props
|
|
1338
1338
|
}) {
|
|
1339
|
-
const _values =
|
|
1339
|
+
const _values = React9__namespace.useMemo(
|
|
1340
1340
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1341
1341
|
[value, defaultValue, min, max]
|
|
1342
1342
|
);
|
|
@@ -1447,18 +1447,18 @@ function AvatarEditor({
|
|
|
1447
1447
|
labels
|
|
1448
1448
|
}) {
|
|
1449
1449
|
const t = { ...DEFAULT_LABELS, ...labels };
|
|
1450
|
-
const canvasRef =
|
|
1451
|
-
const fileInputRef =
|
|
1452
|
-
const containerRef =
|
|
1453
|
-
const [image, setImage] =
|
|
1454
|
-
const [imageLoaded, setImageLoaded] =
|
|
1455
|
-
const [zoom, setZoom] =
|
|
1456
|
-
const [rotation, setRotation] =
|
|
1457
|
-
const [position, setPosition] =
|
|
1458
|
-
const [isDragging, setIsDragging] =
|
|
1459
|
-
const [dragStart, setDragStart] =
|
|
1460
|
-
const [showGrid, setShowGrid] =
|
|
1461
|
-
const generateOutput =
|
|
1450
|
+
const canvasRef = React9.useRef(null);
|
|
1451
|
+
const fileInputRef = React9.useRef(null);
|
|
1452
|
+
const containerRef = React9.useRef(null);
|
|
1453
|
+
const [image, setImage] = React9.useState(null);
|
|
1454
|
+
const [imageLoaded, setImageLoaded] = React9.useState(false);
|
|
1455
|
+
const [zoom, setZoom] = React9.useState(1);
|
|
1456
|
+
const [rotation, setRotation] = React9.useState(0);
|
|
1457
|
+
const [position, setPosition] = React9.useState({ x: 0, y: 0 });
|
|
1458
|
+
const [isDragging, setIsDragging] = React9.useState(false);
|
|
1459
|
+
const [dragStart, setDragStart] = React9.useState({ x: 0, y: 0 });
|
|
1460
|
+
const [showGrid, setShowGrid] = React9.useState(initialShowGrid);
|
|
1461
|
+
const generateOutput = React9.useCallback(() => {
|
|
1462
1462
|
if (!canvasRef.current || !image) return null;
|
|
1463
1463
|
const outputCanvas = document.createElement("canvas");
|
|
1464
1464
|
outputCanvas.width = outputSize;
|
|
@@ -1469,7 +1469,7 @@ function AvatarEditor({
|
|
|
1469
1469
|
const mimeType = `image/${outputFormat}`;
|
|
1470
1470
|
return outputCanvas.toDataURL(mimeType, outputQuality);
|
|
1471
1471
|
}, [image, outputSize, outputFormat, outputQuality]);
|
|
1472
|
-
|
|
1472
|
+
React9.useEffect(() => {
|
|
1473
1473
|
if (!canvasRef.current || !image || !imageLoaded) return;
|
|
1474
1474
|
const canvas = canvasRef.current;
|
|
1475
1475
|
const ctx = canvas.getContext("2d");
|
|
@@ -1513,12 +1513,12 @@ function AvatarEditor({
|
|
|
1513
1513
|
generateOutput,
|
|
1514
1514
|
onChange
|
|
1515
1515
|
]);
|
|
1516
|
-
const resetTransforms =
|
|
1516
|
+
const resetTransforms = React9.useCallback(() => {
|
|
1517
1517
|
setZoom(1);
|
|
1518
1518
|
setRotation(0);
|
|
1519
1519
|
setPosition({ x: 0, y: 0 });
|
|
1520
1520
|
}, []);
|
|
1521
|
-
const handleFileSelect =
|
|
1521
|
+
const handleFileSelect = React9.useCallback(
|
|
1522
1522
|
(e) => {
|
|
1523
1523
|
const file = e.target.files?.[0];
|
|
1524
1524
|
if (!file) return;
|
|
@@ -1537,7 +1537,7 @@ function AvatarEditor({
|
|
|
1537
1537
|
},
|
|
1538
1538
|
[resetTransforms]
|
|
1539
1539
|
);
|
|
1540
|
-
const handleMouseDown =
|
|
1540
|
+
const handleMouseDown = React9.useCallback(
|
|
1541
1541
|
(e) => {
|
|
1542
1542
|
if (!imageLoaded) return;
|
|
1543
1543
|
setIsDragging(true);
|
|
@@ -1545,7 +1545,7 @@ function AvatarEditor({
|
|
|
1545
1545
|
},
|
|
1546
1546
|
[imageLoaded, position]
|
|
1547
1547
|
);
|
|
1548
|
-
const handleMouseMove =
|
|
1548
|
+
const handleMouseMove = React9.useCallback(
|
|
1549
1549
|
(e) => {
|
|
1550
1550
|
if (!isDragging) return;
|
|
1551
1551
|
setPosition({
|
|
@@ -1555,10 +1555,10 @@ function AvatarEditor({
|
|
|
1555
1555
|
},
|
|
1556
1556
|
[isDragging, dragStart]
|
|
1557
1557
|
);
|
|
1558
|
-
const handleMouseUp =
|
|
1558
|
+
const handleMouseUp = React9.useCallback(() => {
|
|
1559
1559
|
setIsDragging(false);
|
|
1560
1560
|
}, []);
|
|
1561
|
-
const handleTouchStart =
|
|
1561
|
+
const handleTouchStart = React9.useCallback(
|
|
1562
1562
|
(e) => {
|
|
1563
1563
|
if (!imageLoaded) return;
|
|
1564
1564
|
const touch = e.touches[0];
|
|
@@ -1570,7 +1570,7 @@ function AvatarEditor({
|
|
|
1570
1570
|
},
|
|
1571
1571
|
[imageLoaded, position]
|
|
1572
1572
|
);
|
|
1573
|
-
const handleTouchMove =
|
|
1573
|
+
const handleTouchMove = React9.useCallback(
|
|
1574
1574
|
(e) => {
|
|
1575
1575
|
if (!isDragging) return;
|
|
1576
1576
|
const touch = e.touches[0];
|
|
@@ -1581,7 +1581,7 @@ function AvatarEditor({
|
|
|
1581
1581
|
},
|
|
1582
1582
|
[isDragging, dragStart]
|
|
1583
1583
|
);
|
|
1584
|
-
const handleDiscard =
|
|
1584
|
+
const handleDiscard = React9.useCallback(() => {
|
|
1585
1585
|
setImage(null);
|
|
1586
1586
|
setImageLoaded(false);
|
|
1587
1587
|
resetTransforms();
|
|
@@ -2149,8 +2149,8 @@ function DrawerTitle({
|
|
|
2149
2149
|
);
|
|
2150
2150
|
}
|
|
2151
2151
|
function useMediaQuery(query) {
|
|
2152
|
-
const [matches, setMatches] =
|
|
2153
|
-
|
|
2152
|
+
const [matches, setMatches] = React9.useState(false);
|
|
2153
|
+
React9.useEffect(() => {
|
|
2154
2154
|
const media = window.matchMedia(query);
|
|
2155
2155
|
if (media.matches !== matches) {
|
|
2156
2156
|
setMatches(media.matches);
|
|
@@ -2180,17 +2180,17 @@ function AvatarEditorDialog({
|
|
|
2180
2180
|
className,
|
|
2181
2181
|
editorLabels
|
|
2182
2182
|
}) {
|
|
2183
|
-
const [isOpen, setIsOpen] =
|
|
2184
|
-
const [editedValue, setEditedValue] =
|
|
2185
|
-
const [displaySrc, setDisplaySrc] =
|
|
2186
|
-
const [isSaving, setIsSaving] =
|
|
2187
|
-
const [feedback, setFeedback] =
|
|
2188
|
-
|
|
2183
|
+
const [isOpen, setIsOpen] = React9.useState(false);
|
|
2184
|
+
const [editedValue, setEditedValue] = React9.useState(value ?? null);
|
|
2185
|
+
const [displaySrc, setDisplaySrc] = React9.useState(value ?? null);
|
|
2186
|
+
const [isSaving, setIsSaving] = React9.useState(false);
|
|
2187
|
+
const [feedback, setFeedback] = React9.useState(null);
|
|
2188
|
+
React9.useEffect(() => {
|
|
2189
2189
|
setDisplaySrc(value ?? null);
|
|
2190
2190
|
}, [value]);
|
|
2191
2191
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
2192
2192
|
const caption = (placeholder ?? "").trim();
|
|
2193
|
-
const handleOpenChange =
|
|
2193
|
+
const handleOpenChange = React9.useCallback(
|
|
2194
2194
|
(open) => {
|
|
2195
2195
|
if (open) {
|
|
2196
2196
|
setEditedValue(value ?? null);
|
|
@@ -2200,7 +2200,7 @@ function AvatarEditorDialog({
|
|
|
2200
2200
|
},
|
|
2201
2201
|
[value]
|
|
2202
2202
|
);
|
|
2203
|
-
const handleAccept =
|
|
2203
|
+
const handleAccept = React9.useCallback(async () => {
|
|
2204
2204
|
if (!editedValue) return;
|
|
2205
2205
|
setIsSaving(true);
|
|
2206
2206
|
setFeedback(null);
|
|
@@ -2404,8 +2404,8 @@ function probeVideoAudio(el) {
|
|
|
2404
2404
|
return "unknown";
|
|
2405
2405
|
}
|
|
2406
2406
|
function usePrefersReducedMotion() {
|
|
2407
|
-
const [reduced, setReduced] =
|
|
2408
|
-
|
|
2407
|
+
const [reduced, setReduced] = React9__namespace.useState(false);
|
|
2408
|
+
React9__namespace.useEffect(() => {
|
|
2409
2409
|
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2410
2410
|
const sync = () => setReduced(media.matches);
|
|
2411
2411
|
sync();
|
|
@@ -2422,11 +2422,11 @@ function CurtainVideo({
|
|
|
2422
2422
|
allowSound,
|
|
2423
2423
|
labels
|
|
2424
2424
|
}) {
|
|
2425
|
-
const videoRef =
|
|
2426
|
-
const [playback, setPlayback] =
|
|
2427
|
-
const [muted, setMuted] =
|
|
2428
|
-
const [audio, setAudio] =
|
|
2429
|
-
|
|
2425
|
+
const videoRef = React9__namespace.useRef(null);
|
|
2426
|
+
const [playback, setPlayback] = React9__namespace.useState("pending");
|
|
2427
|
+
const [muted, setMuted] = React9__namespace.useState(true);
|
|
2428
|
+
const [audio, setAudio] = React9__namespace.useState("unknown");
|
|
2429
|
+
React9__namespace.useEffect(() => {
|
|
2430
2430
|
const el = videoRef.current;
|
|
2431
2431
|
if (!el) return;
|
|
2432
2432
|
el.setAttribute("webkit-playsinline", "");
|
|
@@ -2467,7 +2467,7 @@ function CurtainVideo({
|
|
|
2467
2467
|
el.removeEventListener("loadedmetadata", applyAudio);
|
|
2468
2468
|
};
|
|
2469
2469
|
}, [url, freeze]);
|
|
2470
|
-
const startPlayback =
|
|
2470
|
+
const startPlayback = React9__namespace.useCallback(() => {
|
|
2471
2471
|
const el = videoRef.current;
|
|
2472
2472
|
if (!el) return;
|
|
2473
2473
|
el.muted = true;
|
|
@@ -2483,7 +2483,7 @@ function CurtainVideo({
|
|
|
2483
2483
|
}
|
|
2484
2484
|
);
|
|
2485
2485
|
}, []);
|
|
2486
|
-
const setVideoMuted =
|
|
2486
|
+
const setVideoMuted = React9__namespace.useCallback((next) => {
|
|
2487
2487
|
const el = videoRef.current;
|
|
2488
2488
|
if (el) el.muted = next;
|
|
2489
2489
|
setMuted(next);
|
|
@@ -2575,8 +2575,8 @@ function CurtainStage({
|
|
|
2575
2575
|
);
|
|
2576
2576
|
}
|
|
2577
2577
|
function useMediaQuery2(query) {
|
|
2578
|
-
const [matches, setMatches] =
|
|
2579
|
-
|
|
2578
|
+
const [matches, setMatches] = React9.useState(false);
|
|
2579
|
+
React9.useEffect(() => {
|
|
2580
2580
|
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
2581
2581
|
const mql = window.matchMedia(query);
|
|
2582
2582
|
const onChange = () => setMatches(mql.matches);
|
|
@@ -2590,9 +2590,9 @@ function isVideoKind(kind) {
|
|
|
2590
2590
|
return kind === "video";
|
|
2591
2591
|
}
|
|
2592
2592
|
function useElementInView(enabled) {
|
|
2593
|
-
const [node, setNode] =
|
|
2594
|
-
const [inView, setInView] =
|
|
2595
|
-
|
|
2593
|
+
const [node, setNode] = React9__namespace.useState(null);
|
|
2594
|
+
const [inView, setInView] = React9__namespace.useState(false);
|
|
2595
|
+
React9__namespace.useEffect(() => {
|
|
2596
2596
|
if (!enabled || !node || typeof IntersectionObserver === "undefined") {
|
|
2597
2597
|
setInView(false);
|
|
2598
2598
|
return;
|
|
@@ -2764,7 +2764,7 @@ function CurtainPicker({
|
|
|
2764
2764
|
actionsPending = false
|
|
2765
2765
|
}) {
|
|
2766
2766
|
const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
|
|
2767
|
-
const groupName =
|
|
2767
|
+
const groupName = React9__namespace.useId();
|
|
2768
2768
|
const selectable = typeof onChange === "function";
|
|
2769
2769
|
const compact = variant === "compact";
|
|
2770
2770
|
const selectedId = value === "" ? null : value ?? null;
|
|
@@ -2780,7 +2780,7 @@ function CurtainPicker({
|
|
|
2780
2780
|
canMakeDefault,
|
|
2781
2781
|
canDelete
|
|
2782
2782
|
) : {};
|
|
2783
|
-
const grouped =
|
|
2783
|
+
const grouped = React9__namespace.useMemo(() => {
|
|
2784
2784
|
if (!groupByOwner) {
|
|
2785
2785
|
return [{ group: null, items: ready }];
|
|
2786
2786
|
}
|
|
@@ -3105,8 +3105,8 @@ function WaitingRoom({
|
|
|
3105
3105
|
labels,
|
|
3106
3106
|
className
|
|
3107
3107
|
}) {
|
|
3108
|
-
const [now, setNow] =
|
|
3109
|
-
|
|
3108
|
+
const [now, setNow] = React9__namespace.useState(nowMs ?? Date.now());
|
|
3109
|
+
React9__namespace.useEffect(() => {
|
|
3110
3110
|
if (nowMs != null) {
|
|
3111
3111
|
setNow(nowMs);
|
|
3112
3112
|
return;
|
|
@@ -3288,22 +3288,22 @@ function SeekBar({
|
|
|
3288
3288
|
onSeek,
|
|
3289
3289
|
formatTime: formatTime2
|
|
3290
3290
|
}) {
|
|
3291
|
-
const trackRef =
|
|
3292
|
-
const [hoverTime, setHoverTime] =
|
|
3293
|
-
const [cues, setCues] =
|
|
3294
|
-
const loadedSrc =
|
|
3295
|
-
|
|
3291
|
+
const trackRef = React9__namespace.useRef(null);
|
|
3292
|
+
const [hoverTime, setHoverTime] = React9__namespace.useState(null);
|
|
3293
|
+
const [cues, setCues] = React9__namespace.useState(null);
|
|
3294
|
+
const loadedSrc = React9__namespace.useRef(null);
|
|
3295
|
+
React9__namespace.useEffect(() => {
|
|
3296
3296
|
setCues(null);
|
|
3297
3297
|
loadedSrc.current = null;
|
|
3298
3298
|
}, [src]);
|
|
3299
|
-
const ensureCues =
|
|
3299
|
+
const ensureCues = React9__namespace.useCallback(() => {
|
|
3300
3300
|
if (loadedSrc.current === src) return;
|
|
3301
3301
|
loadedSrc.current = src;
|
|
3302
3302
|
void loadThumbnailsVtt(src).then((next) => {
|
|
3303
3303
|
setCues(next);
|
|
3304
3304
|
});
|
|
3305
3305
|
}, [src]);
|
|
3306
|
-
const updateHover =
|
|
3306
|
+
const updateHover = React9__namespace.useCallback(
|
|
3307
3307
|
(clientX) => {
|
|
3308
3308
|
const rect = trackRef.current?.getBoundingClientRect();
|
|
3309
3309
|
if (!rect) return;
|
|
@@ -3560,27 +3560,27 @@ function useHlsPlayback({
|
|
|
3560
3560
|
onError,
|
|
3561
3561
|
onPlayingChange
|
|
3562
3562
|
}) {
|
|
3563
|
-
const videoRef =
|
|
3564
|
-
const hlsRef =
|
|
3565
|
-
const [state, setState] =
|
|
3566
|
-
const [qualities, setQualities] =
|
|
3567
|
-
const [activeLevel, setActiveLevel] =
|
|
3568
|
-
const [autoplayState, setAutoplayState] =
|
|
3569
|
-
const [error, setError] =
|
|
3570
|
-
const [reloadKey, setReloadKey] =
|
|
3571
|
-
const onErrorRef =
|
|
3572
|
-
const onPlayingChangeRef =
|
|
3573
|
-
|
|
3563
|
+
const videoRef = React9__namespace.useRef(null);
|
|
3564
|
+
const hlsRef = React9__namespace.useRef(null);
|
|
3565
|
+
const [state, setState] = React9__namespace.useState("idle");
|
|
3566
|
+
const [qualities, setQualities] = React9__namespace.useState([]);
|
|
3567
|
+
const [activeLevel, setActiveLevel] = React9__namespace.useState(-1);
|
|
3568
|
+
const [autoplayState, setAutoplayState] = React9__namespace.useState("none");
|
|
3569
|
+
const [error, setError] = React9__namespace.useState(null);
|
|
3570
|
+
const [reloadKey, setReloadKey] = React9__namespace.useState(0);
|
|
3571
|
+
const onErrorRef = React9__namespace.useRef(onError);
|
|
3572
|
+
const onPlayingChangeRef = React9__namespace.useRef(onPlayingChange);
|
|
3573
|
+
React9__namespace.useEffect(() => {
|
|
3574
3574
|
onErrorRef.current = onError;
|
|
3575
3575
|
onPlayingChangeRef.current = onPlayingChange;
|
|
3576
3576
|
}, [onError, onPlayingChange]);
|
|
3577
|
-
const retry =
|
|
3577
|
+
const retry = React9__namespace.useCallback(() => {
|
|
3578
3578
|
setError(null);
|
|
3579
3579
|
setState("loading");
|
|
3580
3580
|
setAutoplayState("none");
|
|
3581
3581
|
setReloadKey((k) => k + 1);
|
|
3582
3582
|
}, []);
|
|
3583
|
-
|
|
3583
|
+
React9__namespace.useEffect(() => {
|
|
3584
3584
|
const media = videoRef.current;
|
|
3585
3585
|
if (!media || !src || !active) {
|
|
3586
3586
|
setState("idle");
|
|
@@ -3866,7 +3866,7 @@ function useHlsPlayback({
|
|
|
3866
3866
|
destroyHls();
|
|
3867
3867
|
};
|
|
3868
3868
|
}, [src, mode, active, autoPlay, muted, reloadKey]);
|
|
3869
|
-
const setLevel =
|
|
3869
|
+
const setLevel = React9__namespace.useCallback((index) => {
|
|
3870
3870
|
const hls = hlsRef.current;
|
|
3871
3871
|
if (!hls) return;
|
|
3872
3872
|
hls.nextLevel = index;
|
|
@@ -3886,7 +3886,8 @@ function useHlsPlayback({
|
|
|
3886
3886
|
|
|
3887
3887
|
// src/components/video/captions.ts
|
|
3888
3888
|
var CAPTION_LOCALES = ["en", "es", "pt"];
|
|
3889
|
-
var
|
|
3889
|
+
var LIVE_CUE_EXTRA_LAG_MS = 2e3;
|
|
3890
|
+
var LIVE_STACK_MAX_CUES = 150;
|
|
3890
3891
|
var LIVE_LAG_SPIKE_MS = 2500;
|
|
3891
3892
|
function stabilizeLiveLagMs(previous, next) {
|
|
3892
3893
|
if (previous == null || !Number.isFinite(previous)) return next;
|
|
@@ -3897,6 +3898,22 @@ function stabilizeLiveLagMs(previous, next) {
|
|
|
3897
3898
|
function isCaptionLocale(value) {
|
|
3898
3899
|
return CAPTION_LOCALES.includes(value);
|
|
3899
3900
|
}
|
|
3901
|
+
function isLivePlaylistSrc(src) {
|
|
3902
|
+
return /\/live\//i.test(src);
|
|
3903
|
+
}
|
|
3904
|
+
function zeroAnchorCaptionCues(cues) {
|
|
3905
|
+
if (cues.length === 0) return cues;
|
|
3906
|
+
let origin = Number.POSITIVE_INFINITY;
|
|
3907
|
+
for (const cue of cues) {
|
|
3908
|
+
if (Number.isFinite(cue.start) && cue.start < origin) origin = cue.start;
|
|
3909
|
+
}
|
|
3910
|
+
if (!Number.isFinite(origin) || origin <= 0) return cues;
|
|
3911
|
+
return cues.map((cue) => ({
|
|
3912
|
+
...cue,
|
|
3913
|
+
start: Math.max(0, cue.start - origin),
|
|
3914
|
+
end: Math.max(0, cue.end - origin)
|
|
3915
|
+
}));
|
|
3916
|
+
}
|
|
3900
3917
|
function captionsVttUrlFromPlayback(src, locale) {
|
|
3901
3918
|
const trimmed = src.trim();
|
|
3902
3919
|
if (!trimmed) return null;
|
|
@@ -3937,26 +3954,49 @@ function captionAtTime(cues, time, options) {
|
|
|
3937
3954
|
if (matched) return matched;
|
|
3938
3955
|
return null;
|
|
3939
3956
|
}
|
|
3940
|
-
function
|
|
3941
|
-
|
|
3957
|
+
function liveCuesDue(cues, now, lagMs, extraLagMs = LIVE_CUE_EXTRA_LAG_MS) {
|
|
3958
|
+
if (lagMs == null || !Number.isFinite(lagMs) || lagMs < 0) return [];
|
|
3959
|
+
const threshold = lagMs + extraLagMs;
|
|
3960
|
+
return cues.filter(
|
|
3961
|
+
(cue) => Number.isFinite(cue.receivedAt) && now - cue.receivedAt >= threshold
|
|
3962
|
+
).sort((left, right) => left.receivedAt - right.receivedAt);
|
|
3963
|
+
}
|
|
3964
|
+
function normalizeLiveCaptionText(text) {
|
|
3965
|
+
return text.trim().replace(/\s+/g, " ").toLowerCase();
|
|
3966
|
+
}
|
|
3967
|
+
function coalesceLiveCaptionCues(cues) {
|
|
3968
|
+
const out = [];
|
|
3942
3969
|
for (const cue of cues) {
|
|
3943
|
-
|
|
3944
|
-
if (
|
|
3945
|
-
|
|
3970
|
+
const text = cue.text.trim();
|
|
3971
|
+
if (!text) continue;
|
|
3972
|
+
const last = out[out.length - 1];
|
|
3973
|
+
if (!last) {
|
|
3974
|
+
out.push({ text, receivedAt: cue.receivedAt });
|
|
3975
|
+
continue;
|
|
3976
|
+
}
|
|
3977
|
+
const lastNorm = normalizeLiveCaptionText(last.text);
|
|
3978
|
+
const nextNorm = normalizeLiveCaptionText(text);
|
|
3979
|
+
if (lastNorm === nextNorm) continue;
|
|
3980
|
+
if (nextNorm.startsWith(lastNorm) || lastNorm.startsWith(nextNorm)) {
|
|
3981
|
+
out[out.length - 1] = {
|
|
3982
|
+
text: nextNorm.length >= lastNorm.length ? text : last.text,
|
|
3983
|
+
receivedAt: cue.receivedAt
|
|
3984
|
+
};
|
|
3985
|
+
continue;
|
|
3986
|
+
}
|
|
3987
|
+
out.push({ text, receivedAt: cue.receivedAt });
|
|
3946
3988
|
}
|
|
3947
|
-
return
|
|
3948
|
-
}
|
|
3949
|
-
function
|
|
3950
|
-
|
|
3951
|
-
const
|
|
3952
|
-
|
|
3953
|
-
if (dueInHold && (!previous || dueInHold.receivedAt > previous.cue.receivedAt)) {
|
|
3954
|
-
return { cue: dueInHold, shownAt: now, lagMs };
|
|
3989
|
+
return out;
|
|
3990
|
+
}
|
|
3991
|
+
function mergeLiveCaptionCues(existing, incoming, cap = LIVE_STACK_MAX_CUES) {
|
|
3992
|
+
const map = /* @__PURE__ */ new Map();
|
|
3993
|
+
for (const cue of existing) {
|
|
3994
|
+
if (Number.isFinite(cue.receivedAt)) map.set(cue.receivedAt, cue);
|
|
3955
3995
|
}
|
|
3956
|
-
|
|
3957
|
-
|
|
3996
|
+
for (const cue of incoming) {
|
|
3997
|
+
if (Number.isFinite(cue.receivedAt)) map.set(cue.receivedAt, cue);
|
|
3958
3998
|
}
|
|
3959
|
-
return
|
|
3999
|
+
return [...map.values()].sort((left, right) => left.receivedAt - right.receivedAt).slice(-Math.max(1, cap));
|
|
3960
4000
|
}
|
|
3961
4001
|
async function loadCaptionVtt(url) {
|
|
3962
4002
|
try {
|
|
@@ -3995,6 +4035,107 @@ async function loadLiveCaptions(url) {
|
|
|
3995
4035
|
return { ok: false, cues: [] };
|
|
3996
4036
|
}
|
|
3997
4037
|
}
|
|
4038
|
+
var NEAR_BOTTOM_PX = 24;
|
|
4039
|
+
function LiveCaptionStack({ cues, latestLabel }) {
|
|
4040
|
+
const scrollerRef = React9__namespace.useRef(null);
|
|
4041
|
+
const followRef = React9__namespace.useRef(true);
|
|
4042
|
+
const ignoreScrollRef = React9__namespace.useRef(false);
|
|
4043
|
+
const [following, setFollowing] = React9__namespace.useState(true);
|
|
4044
|
+
const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
|
|
4045
|
+
const lastReceivedAt = cues[cues.length - 1]?.receivedAt;
|
|
4046
|
+
const scrollToLatest = React9__namespace.useCallback(() => {
|
|
4047
|
+
const scroller = scrollerRef.current;
|
|
4048
|
+
if (!scroller) return;
|
|
4049
|
+
ignoreScrollRef.current = true;
|
|
4050
|
+
scroller.scrollTo({
|
|
4051
|
+
top: scroller.scrollHeight,
|
|
4052
|
+
behavior: prefersReduced ? "auto" : "smooth"
|
|
4053
|
+
});
|
|
4054
|
+
followRef.current = true;
|
|
4055
|
+
setFollowing(true);
|
|
4056
|
+
window.requestAnimationFrame(() => {
|
|
4057
|
+
window.requestAnimationFrame(() => {
|
|
4058
|
+
ignoreScrollRef.current = false;
|
|
4059
|
+
});
|
|
4060
|
+
});
|
|
4061
|
+
}, [prefersReduced]);
|
|
4062
|
+
React9__namespace.useLayoutEffect(() => {
|
|
4063
|
+
if (!followRef.current) return;
|
|
4064
|
+
const scroller = scrollerRef.current;
|
|
4065
|
+
if (!scroller) return;
|
|
4066
|
+
ignoreScrollRef.current = true;
|
|
4067
|
+
scroller.scrollTo({
|
|
4068
|
+
top: scroller.scrollHeight,
|
|
4069
|
+
behavior: prefersReduced ? "auto" : "smooth"
|
|
4070
|
+
});
|
|
4071
|
+
window.requestAnimationFrame(() => {
|
|
4072
|
+
window.requestAnimationFrame(() => {
|
|
4073
|
+
ignoreScrollRef.current = false;
|
|
4074
|
+
});
|
|
4075
|
+
});
|
|
4076
|
+
}, [lastReceivedAt, prefersReduced, cues.length]);
|
|
4077
|
+
if (cues.length === 0) return null;
|
|
4078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4079
|
+
"div",
|
|
4080
|
+
{
|
|
4081
|
+
className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
|
|
4082
|
+
"data-slot": "video-captions",
|
|
4083
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full max-w-[90%]", children: [
|
|
4084
|
+
!following && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4085
|
+
"button",
|
|
4086
|
+
{
|
|
4087
|
+
type: "button",
|
|
4088
|
+
className: "pointer-events-auto absolute -top-8 right-0 rounded-sm bg-black/70 px-2 py-0.5 text-xs font-medium text-white shadow-sm",
|
|
4089
|
+
onClick: scrollToLatest,
|
|
4090
|
+
children: latestLabel
|
|
4091
|
+
}
|
|
4092
|
+
),
|
|
4093
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4094
|
+
"div",
|
|
4095
|
+
{
|
|
4096
|
+
ref: scrollerRef,
|
|
4097
|
+
role: "log",
|
|
4098
|
+
"aria-relevant": "additions",
|
|
4099
|
+
className: "pointer-events-auto max-h-[4.5rem] overflow-x-hidden overflow-y-auto rounded-sm bg-black/70 px-3 py-1.5 text-sm font-medium text-white shadow-sm",
|
|
4100
|
+
onScroll: (event) => {
|
|
4101
|
+
if (ignoreScrollRef.current) return;
|
|
4102
|
+
const scroller = event.currentTarget;
|
|
4103
|
+
const nearBottom = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight < NEAR_BOTTOM_PX;
|
|
4104
|
+
followRef.current = nearBottom;
|
|
4105
|
+
setFollowing(nearBottom);
|
|
4106
|
+
},
|
|
4107
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4108
|
+
"p",
|
|
4109
|
+
{
|
|
4110
|
+
className: cn(
|
|
4111
|
+
"text-justify [text-align-last:left] leading-5 break-words",
|
|
4112
|
+
!prefersReduced && "transition-opacity"
|
|
4113
|
+
),
|
|
4114
|
+
children: cues.map((cue, index) => {
|
|
4115
|
+
const fromEnd = cues.length - 1 - index;
|
|
4116
|
+
const opacity = fromEnd === 0 ? 1 : fromEnd === 1 ? 0.75 : 0.45;
|
|
4117
|
+
const newest = fromEnd === 0;
|
|
4118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4119
|
+
"span",
|
|
4120
|
+
{
|
|
4121
|
+
style: { opacity },
|
|
4122
|
+
"aria-live": newest ? "polite" : void 0,
|
|
4123
|
+
children: [
|
|
4124
|
+
index > 0 ? " " : "",
|
|
4125
|
+
cue.text
|
|
4126
|
+
]
|
|
4127
|
+
},
|
|
4128
|
+
cue.receivedAt
|
|
4129
|
+
);
|
|
4130
|
+
})
|
|
4131
|
+
}
|
|
4132
|
+
)
|
|
4133
|
+
}
|
|
4134
|
+
)
|
|
4135
|
+
] })
|
|
4136
|
+
}
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
3998
4139
|
var DEFAULT_LABELS3 = {
|
|
3999
4140
|
play: "Play",
|
|
4000
4141
|
pause: "Pause",
|
|
@@ -4023,7 +4164,8 @@ var DEFAULT_LABELS3 = {
|
|
|
4023
4164
|
captionsOff: "Off",
|
|
4024
4165
|
captionsEn: "English",
|
|
4025
4166
|
captionsEs: "Espa\xF1ol",
|
|
4026
|
-
captionsPt: "Portugu\xEAs"
|
|
4167
|
+
captionsPt: "Portugu\xEAs",
|
|
4168
|
+
captionsLatest: "Latest"
|
|
4027
4169
|
};
|
|
4028
4170
|
var PLAYBACK_RATES = [0.75, 1, 1.25, 1.5, 2];
|
|
4029
4171
|
var CONTROLS_HIDE_MS = 3e3;
|
|
@@ -4085,12 +4227,12 @@ function VideoPlayer({
|
|
|
4085
4227
|
liveCaptionsBaseUrl
|
|
4086
4228
|
}) {
|
|
4087
4229
|
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
4088
|
-
const containerRef =
|
|
4089
|
-
const firstPlayFiredRef =
|
|
4090
|
-
const [userStarted, setUserStarted] =
|
|
4230
|
+
const containerRef = React9__namespace.useRef(null);
|
|
4231
|
+
const firstPlayFiredRef = React9__namespace.useRef(false);
|
|
4232
|
+
const [userStarted, setUserStarted] = React9__namespace.useState(false);
|
|
4091
4233
|
const active = autoPlay || !poster || userStarted;
|
|
4092
4234
|
const autoplayActive = autoPlay || userStarted;
|
|
4093
|
-
const handlePlayingChange =
|
|
4235
|
+
const handlePlayingChange = React9__namespace.useCallback(
|
|
4094
4236
|
(playing) => {
|
|
4095
4237
|
setIsPlaying(playing);
|
|
4096
4238
|
if (playing && !firstPlayFiredRef.current) {
|
|
@@ -4119,30 +4261,29 @@ function VideoPlayer({
|
|
|
4119
4261
|
onError,
|
|
4120
4262
|
onPlayingChange: handlePlayingChange
|
|
4121
4263
|
});
|
|
4122
|
-
const [isPlaying, setIsPlaying] =
|
|
4123
|
-
const [isMuted, setIsMuted] =
|
|
4124
|
-
const isMutedRef =
|
|
4264
|
+
const [isPlaying, setIsPlaying] = React9__namespace.useState(false);
|
|
4265
|
+
const [isMuted, setIsMuted] = React9__namespace.useState(muted);
|
|
4266
|
+
const isMutedRef = React9__namespace.useRef(isMuted);
|
|
4125
4267
|
isMutedRef.current = isMuted;
|
|
4126
|
-
const [volume, setVolume] =
|
|
4127
|
-
const [currentTime, setCurrentTime] =
|
|
4128
|
-
const [duration, setDuration] =
|
|
4129
|
-
const [buffered, setBuffered] =
|
|
4130
|
-
const [isFullscreen, setIsFullscreen] =
|
|
4131
|
-
const [pipActive, setPipActive] =
|
|
4132
|
-
const [controlsVisible, setControlsVisible] =
|
|
4133
|
-
const [playbackRate, setPlaybackRate] =
|
|
4134
|
-
const [openMenu, setOpenMenu] =
|
|
4135
|
-
const [captionLocale, setCaptionLocale] =
|
|
4136
|
-
const [captionCues, setCaptionCues] =
|
|
4137
|
-
const [liveCaptionCues, setLiveCaptionCues] =
|
|
4138
|
-
const [liveLagMs, setLiveLagMs] =
|
|
4139
|
-
const
|
|
4140
|
-
const [
|
|
4141
|
-
const
|
|
4142
|
-
const hideTimerRef = React8__namespace.useRef(null);
|
|
4268
|
+
const [volume, setVolume] = React9__namespace.useState(1);
|
|
4269
|
+
const [currentTime, setCurrentTime] = React9__namespace.useState(0);
|
|
4270
|
+
const [duration, setDuration] = React9__namespace.useState(0);
|
|
4271
|
+
const [buffered, setBuffered] = React9__namespace.useState(0);
|
|
4272
|
+
const [isFullscreen, setIsFullscreen] = React9__namespace.useState(false);
|
|
4273
|
+
const [pipActive, setPipActive] = React9__namespace.useState(false);
|
|
4274
|
+
const [controlsVisible, setControlsVisible] = React9__namespace.useState(true);
|
|
4275
|
+
const [playbackRate, setPlaybackRate] = React9__namespace.useState(1);
|
|
4276
|
+
const [openMenu, setOpenMenu] = React9__namespace.useState(null);
|
|
4277
|
+
const [captionLocale, setCaptionLocale] = React9__namespace.useState(defaultCaptionLocale ?? "off");
|
|
4278
|
+
const [captionCues, setCaptionCues] = React9__namespace.useState([]);
|
|
4279
|
+
const [liveCaptionCues, setLiveCaptionCues] = React9__namespace.useState([]);
|
|
4280
|
+
const [liveLagMs, setLiveLagMs] = React9__namespace.useState(null);
|
|
4281
|
+
const [behindLive, setBehindLive] = React9__namespace.useState(false);
|
|
4282
|
+
const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React9__namespace.useState(false);
|
|
4283
|
+
const hideTimerRef = React9__namespace.useRef(null);
|
|
4143
4284
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
4144
4285
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
|
|
4145
|
-
|
|
4286
|
+
React9__namespace.useEffect(() => {
|
|
4146
4287
|
const video = videoRef.current;
|
|
4147
4288
|
if (!video || !active) return;
|
|
4148
4289
|
const onTimeUpdate = () => {
|
|
@@ -4184,25 +4325,25 @@ function VideoPlayer({
|
|
|
4184
4325
|
video.removeEventListener("playing", onPlaying);
|
|
4185
4326
|
};
|
|
4186
4327
|
}, [videoRef, active, mode, liveCaptionsBaseUrl]);
|
|
4187
|
-
|
|
4328
|
+
React9__namespace.useLayoutEffect(() => {
|
|
4188
4329
|
const video = videoRef.current;
|
|
4189
4330
|
if (video) video.muted = isMuted;
|
|
4190
4331
|
}, [isMuted, active, videoRef]);
|
|
4191
|
-
|
|
4332
|
+
React9__namespace.useEffect(() => {
|
|
4192
4333
|
const video = videoRef.current;
|
|
4193
4334
|
if (!paused || !video || !isPlaying) return;
|
|
4194
4335
|
video.pause();
|
|
4195
4336
|
}, [paused, videoRef, isPlaying]);
|
|
4196
|
-
|
|
4337
|
+
React9__namespace.useEffect(() => {
|
|
4197
4338
|
setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
|
|
4198
4339
|
videoRef.current?.setAttribute("x-webkit-airplay", "allow");
|
|
4199
4340
|
}, [videoRef, active]);
|
|
4200
|
-
|
|
4341
|
+
React9__namespace.useEffect(() => {
|
|
4201
4342
|
const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
4202
4343
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
4203
4344
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
4204
4345
|
}, []);
|
|
4205
|
-
|
|
4346
|
+
React9__namespace.useEffect(() => {
|
|
4206
4347
|
const video = asWebkitVideo(videoRef.current);
|
|
4207
4348
|
if (!video) return;
|
|
4208
4349
|
const onBegin = () => setIsFullscreen(true);
|
|
@@ -4214,7 +4355,7 @@ function VideoPlayer({
|
|
|
4214
4355
|
video.removeEventListener("webkitendfullscreen", onEnd);
|
|
4215
4356
|
};
|
|
4216
4357
|
}, [videoRef, active]);
|
|
4217
|
-
|
|
4358
|
+
React9__namespace.useEffect(() => {
|
|
4218
4359
|
const video = videoRef.current;
|
|
4219
4360
|
if (!video) return;
|
|
4220
4361
|
const onEnter = () => setPipActive(true);
|
|
@@ -4226,29 +4367,29 @@ function VideoPlayer({
|
|
|
4226
4367
|
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
4227
4368
|
};
|
|
4228
4369
|
}, [videoRef]);
|
|
4229
|
-
const scheduleHide =
|
|
4370
|
+
const scheduleHide = React9__namespace.useCallback(() => {
|
|
4230
4371
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
4231
4372
|
hideTimerRef.current = setTimeout(() => {
|
|
4232
4373
|
setControlsVisible(false);
|
|
4233
4374
|
setOpenMenu(null);
|
|
4234
4375
|
}, CONTROLS_HIDE_MS);
|
|
4235
4376
|
}, []);
|
|
4236
|
-
const revealControls =
|
|
4377
|
+
const revealControls = React9__namespace.useCallback(() => {
|
|
4237
4378
|
setControlsVisible(true);
|
|
4238
4379
|
scheduleHide();
|
|
4239
4380
|
}, [scheduleHide]);
|
|
4240
|
-
|
|
4381
|
+
React9__namespace.useEffect(() => {
|
|
4241
4382
|
return () => {
|
|
4242
4383
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
4243
4384
|
};
|
|
4244
4385
|
}, []);
|
|
4245
|
-
|
|
4386
|
+
React9__namespace.useEffect(() => {
|
|
4246
4387
|
if (captionLocale === "off") {
|
|
4247
4388
|
setCaptionCues([]);
|
|
4248
4389
|
setLiveCaptionCues([]);
|
|
4249
|
-
liveCaptionLatchRef.current = null;
|
|
4250
4390
|
return;
|
|
4251
4391
|
}
|
|
4392
|
+
setLiveCaptionCues([]);
|
|
4252
4393
|
let cancelled = false;
|
|
4253
4394
|
const load = async () => {
|
|
4254
4395
|
const liveBase = liveCaptionsBaseUrl?.trim();
|
|
@@ -4256,7 +4397,9 @@ function VideoPlayer({
|
|
|
4256
4397
|
const loaded = await loadLiveCaptions(
|
|
4257
4398
|
liveCaptionsUrl(liveBase, captionLocale)
|
|
4258
4399
|
);
|
|
4259
|
-
if (!cancelled && loaded.ok)
|
|
4400
|
+
if (!cancelled && loaded.ok) {
|
|
4401
|
+
setLiveCaptionCues((prev) => mergeLiveCaptionCues(prev, loaded.cues));
|
|
4402
|
+
}
|
|
4260
4403
|
return;
|
|
4261
4404
|
}
|
|
4262
4405
|
const url = captionsVttUrlFromPlayback(src, captionLocale);
|
|
@@ -4265,7 +4408,8 @@ function VideoPlayer({
|
|
|
4265
4408
|
return;
|
|
4266
4409
|
}
|
|
4267
4410
|
const cues = await loadCaptionVtt(url);
|
|
4268
|
-
|
|
4411
|
+
const next = isLivePlaylistSrc(src) ? zeroAnchorCaptionCues(cues) : cues;
|
|
4412
|
+
if (!cancelled) setCaptionCues(next);
|
|
4269
4413
|
};
|
|
4270
4414
|
void load();
|
|
4271
4415
|
if (!liveCaptionsBaseUrl) return;
|
|
@@ -4275,20 +4419,10 @@ function VideoPlayer({
|
|
|
4275
4419
|
window.clearInterval(timer);
|
|
4276
4420
|
};
|
|
4277
4421
|
}, [captionLocale, liveCaptionsBaseUrl, src]);
|
|
4278
|
-
const
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
liveCaptionLatchRef.current = null;
|
|
4283
|
-
}
|
|
4284
|
-
const liveLatch = liveCaptionsBaseUrl ? captionAtLiveLag(
|
|
4285
|
-
liveCaptionCues,
|
|
4286
|
-
Date.now(),
|
|
4287
|
-
liveLagMs,
|
|
4288
|
-
liveCaptionLatchRef.current
|
|
4289
|
-
) : null;
|
|
4290
|
-
liveCaptionLatchRef.current = liveLatch;
|
|
4291
|
-
const activeCaption = liveCaptionsBaseUrl ? liveLatch?.cue ?? null : captionAtTime(captionCues, currentTime);
|
|
4422
|
+
const liveDueCues = liveCaptionsBaseUrl ? coalesceLiveCaptionCues(
|
|
4423
|
+
liveCuesDue(liveCaptionCues, Date.now(), liveLagMs)
|
|
4424
|
+
) : [];
|
|
4425
|
+
const activeCaption = liveCaptionsBaseUrl ? null : captionAtTime(captionCues, currentTime);
|
|
4292
4426
|
function togglePlay() {
|
|
4293
4427
|
const video = videoRef.current;
|
|
4294
4428
|
if (!video) return;
|
|
@@ -4518,7 +4652,8 @@ function VideoPlayer({
|
|
|
4518
4652
|
] }),
|
|
4519
4653
|
typeof stats?.viewers === "number" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded bg-black/60 px-2 py-0.5 text-xs", children: t.formatViewers ? t.formatViewers(stats.viewers) : `\u{1F441} ${stats.viewers}` })
|
|
4520
4654
|
] }),
|
|
4521
|
-
|
|
4655
|
+
liveCaptionsBaseUrl && captionLocale !== "off" && /* @__PURE__ */ jsxRuntime.jsx(LiveCaptionStack, { cues: liveDueCues, latestLabel: t.captionsLatest }),
|
|
4656
|
+
!liveCaptionsBaseUrl && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4522
4657
|
"div",
|
|
4523
4658
|
{
|
|
4524
4659
|
className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
|
|
@@ -4811,16 +4946,16 @@ function videoInPictureInPicture(container) {
|
|
|
4811
4946
|
return container.contains(pip);
|
|
4812
4947
|
}
|
|
4813
4948
|
function useFeedExclusivePlayback(playbackId) {
|
|
4814
|
-
const containerRef =
|
|
4815
|
-
const [forcePaused, setForcePaused] =
|
|
4816
|
-
const requestPause =
|
|
4949
|
+
const containerRef = React9__namespace.useRef(null);
|
|
4950
|
+
const [forcePaused, setForcePaused] = React9__namespace.useState(false);
|
|
4951
|
+
const requestPause = React9__namespace.useCallback(() => {
|
|
4817
4952
|
if (videoInPictureInPicture(containerRef.current)) return;
|
|
4818
4953
|
setForcePaused(true);
|
|
4819
4954
|
}, []);
|
|
4820
|
-
|
|
4955
|
+
React9__namespace.useEffect(() => {
|
|
4821
4956
|
return registerFeedPlayer(playbackId, requestPause);
|
|
4822
4957
|
}, [playbackId, requestPause]);
|
|
4823
|
-
|
|
4958
|
+
React9__namespace.useEffect(() => {
|
|
4824
4959
|
const node = containerRef.current;
|
|
4825
4960
|
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
4826
4961
|
const observer = new IntersectionObserver(
|
|
@@ -4836,14 +4971,14 @@ function useFeedExclusivePlayback(playbackId) {
|
|
|
4836
4971
|
observer.observe(node);
|
|
4837
4972
|
return () => observer.disconnect();
|
|
4838
4973
|
}, [requestPause]);
|
|
4839
|
-
|
|
4974
|
+
React9__namespace.useEffect(() => {
|
|
4840
4975
|
const onVisibility = () => {
|
|
4841
4976
|
if (document.hidden) requestPause();
|
|
4842
4977
|
};
|
|
4843
4978
|
document.addEventListener("visibilitychange", onVisibility);
|
|
4844
4979
|
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
4845
4980
|
}, [requestPause]);
|
|
4846
|
-
const onPlayingChange =
|
|
4981
|
+
const onPlayingChange = React9__namespace.useCallback(
|
|
4847
4982
|
(playing) => {
|
|
4848
4983
|
if (!playing) return;
|
|
4849
4984
|
setForcePaused(false);
|
|
@@ -4870,7 +5005,7 @@ function FeedVideoPlayer({
|
|
|
4870
5005
|
paused: exclusivePaused,
|
|
4871
5006
|
onPlayingChange: onExclusivePlayingChange
|
|
4872
5007
|
} = useFeedExclusivePlayback(playbackId);
|
|
4873
|
-
const handlePlayingChange =
|
|
5008
|
+
const handlePlayingChange = React9__namespace.useCallback(
|
|
4874
5009
|
(playing) => {
|
|
4875
5010
|
onExclusivePlayingChange(playing);
|
|
4876
5011
|
onPlayingChange?.(playing);
|
|
@@ -4897,8 +5032,8 @@ function FeedVideoPlayer({
|
|
|
4897
5032
|
);
|
|
4898
5033
|
}
|
|
4899
5034
|
function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
|
|
4900
|
-
const [stats, setStats] =
|
|
4901
|
-
|
|
5035
|
+
const [stats, setStats] = React9__namespace.useState({});
|
|
5036
|
+
React9__namespace.useEffect(() => {
|
|
4902
5037
|
if (!statsUrl || !enabled) return;
|
|
4903
5038
|
let cancelled = false;
|
|
4904
5039
|
const controller = new AbortController();
|
|
@@ -5021,10 +5156,10 @@ function FileDropzone({
|
|
|
5021
5156
|
className
|
|
5022
5157
|
}) {
|
|
5023
5158
|
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
5024
|
-
const inputId =
|
|
5025
|
-
const inputRef =
|
|
5026
|
-
const [dragging, setDragging] =
|
|
5027
|
-
const [message, setMessage] =
|
|
5159
|
+
const inputId = React9.useId();
|
|
5160
|
+
const inputRef = React9.useRef(null);
|
|
5161
|
+
const [dragging, setDragging] = React9.useState(false);
|
|
5162
|
+
const [message, setMessage] = React9.useState(null);
|
|
5028
5163
|
function takeFile(file) {
|
|
5029
5164
|
if (!file || disabled) return;
|
|
5030
5165
|
if (!fileMatchesAccept(file, accept)) {
|
|
@@ -5272,7 +5407,7 @@ function FileUploadMenu({
|
|
|
5272
5407
|
}) {
|
|
5273
5408
|
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
5274
5409
|
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
5275
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
5410
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React9.useState(false);
|
|
5276
5411
|
const isControlled = open !== void 0;
|
|
5277
5412
|
const resolvedOpen = isControlled ? open : uncontrolledOpen;
|
|
5278
5413
|
function setResolvedOpen(next) {
|