@livo-tv/blocks 0.0.1 → 1.1.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 +6 -6
- package/dist/index.cjs +307 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -1
- package/dist/index.d.ts +82 -1
- package/dist/index.js +246 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import * as
|
|
2
|
+
import * as React5 from 'react';
|
|
3
3
|
import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
4
|
-
import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
|
|
4
|
+
import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
@@ -1196,7 +1196,7 @@ function Slider({
|
|
|
1196
1196
|
max = 100,
|
|
1197
1197
|
...props
|
|
1198
1198
|
}) {
|
|
1199
|
-
const _values =
|
|
1199
|
+
const _values = React5.useMemo(
|
|
1200
1200
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1201
1201
|
[value, defaultValue, min, max]
|
|
1202
1202
|
);
|
|
@@ -2042,8 +2042,12 @@ function AvatarEditorDialog({
|
|
|
2042
2042
|
}) {
|
|
2043
2043
|
const [isOpen, setIsOpen] = useState(false);
|
|
2044
2044
|
const [editedValue, setEditedValue] = useState(value ?? null);
|
|
2045
|
+
const [displaySrc, setDisplaySrc] = useState(value ?? null);
|
|
2045
2046
|
const [isSaving, setIsSaving] = useState(false);
|
|
2046
2047
|
const [feedback, setFeedback] = useState(null);
|
|
2048
|
+
useEffect(() => {
|
|
2049
|
+
setDisplaySrc(value ?? null);
|
|
2050
|
+
}, [value]);
|
|
2047
2051
|
const isMobile = useMediaQuery("(max-width: 640px)");
|
|
2048
2052
|
const caption = (placeholder ?? "").trim();
|
|
2049
2053
|
const handleOpenChange = useCallback(
|
|
@@ -2064,6 +2068,7 @@ function AvatarEditorDialog({
|
|
|
2064
2068
|
if (onSave) {
|
|
2065
2069
|
const result = await onSave(editedValue);
|
|
2066
2070
|
if (result) {
|
|
2071
|
+
setDisplaySrc(editedValue);
|
|
2067
2072
|
onChange?.(editedValue);
|
|
2068
2073
|
setFeedback({ type: "success", message: successMessage });
|
|
2069
2074
|
setTimeout(() => {
|
|
@@ -2074,6 +2079,7 @@ function AvatarEditorDialog({
|
|
|
2074
2079
|
setFeedback({ type: "error", message: errorMessage });
|
|
2075
2080
|
}
|
|
2076
2081
|
} else {
|
|
2082
|
+
setDisplaySrc(editedValue);
|
|
2077
2083
|
onChange?.(editedValue);
|
|
2078
2084
|
setFeedback({ type: "success", message: successMessage });
|
|
2079
2085
|
setTimeout(() => {
|
|
@@ -2101,9 +2107,9 @@ function AvatarEditorDialog({
|
|
|
2101
2107
|
children: /* @__PURE__ */ jsx(
|
|
2102
2108
|
SafeImage,
|
|
2103
2109
|
{
|
|
2104
|
-
src:
|
|
2110
|
+
src: displaySrc,
|
|
2105
2111
|
alt: "Avatar",
|
|
2106
|
-
className: "absolute object-cover",
|
|
2112
|
+
className: "absolute inset-0 h-full w-full object-cover",
|
|
2107
2113
|
fallback: /* @__PURE__ */ jsxs(
|
|
2108
2114
|
"div",
|
|
2109
2115
|
{
|
|
@@ -2226,6 +2232,177 @@ function AvatarEditorDialog({
|
|
|
2226
2232
|
] }) })
|
|
2227
2233
|
] });
|
|
2228
2234
|
}
|
|
2235
|
+
function usePrefersReducedMotion() {
|
|
2236
|
+
const [reduced, setReduced] = React5.useState(false);
|
|
2237
|
+
React5.useEffect(() => {
|
|
2238
|
+
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2239
|
+
const sync = () => setReduced(media.matches);
|
|
2240
|
+
sync();
|
|
2241
|
+
media.addEventListener("change", sync);
|
|
2242
|
+
return () => media.removeEventListener("change", sync);
|
|
2243
|
+
}, []);
|
|
2244
|
+
return reduced;
|
|
2245
|
+
}
|
|
2246
|
+
function CurtainStage({
|
|
2247
|
+
kind,
|
|
2248
|
+
url,
|
|
2249
|
+
alt = "",
|
|
2250
|
+
className,
|
|
2251
|
+
reducedMotion
|
|
2252
|
+
}) {
|
|
2253
|
+
const prefersReduced = usePrefersReducedMotion();
|
|
2254
|
+
const freeze = reducedMotion ?? prefersReduced;
|
|
2255
|
+
if (kind === "video" && !freeze) {
|
|
2256
|
+
return /* @__PURE__ */ jsx(
|
|
2257
|
+
"video",
|
|
2258
|
+
{
|
|
2259
|
+
src: url,
|
|
2260
|
+
className: cn("h-full w-full object-cover", className),
|
|
2261
|
+
autoPlay: true,
|
|
2262
|
+
muted: true,
|
|
2263
|
+
loop: true,
|
|
2264
|
+
playsInline: true,
|
|
2265
|
+
"aria-hidden": alt ? void 0 : true
|
|
2266
|
+
}
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
if (kind === "video" && freeze) {
|
|
2270
|
+
return /* @__PURE__ */ jsx(
|
|
2271
|
+
"video",
|
|
2272
|
+
{
|
|
2273
|
+
src: url,
|
|
2274
|
+
className: cn("h-full w-full object-cover", className),
|
|
2275
|
+
muted: true,
|
|
2276
|
+
playsInline: true,
|
|
2277
|
+
preload: "metadata",
|
|
2278
|
+
"aria-hidden": alt ? void 0 : true
|
|
2279
|
+
}
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
return /* @__PURE__ */ jsx(
|
|
2283
|
+
"img",
|
|
2284
|
+
{
|
|
2285
|
+
src: url,
|
|
2286
|
+
alt,
|
|
2287
|
+
className: cn("h-full w-full object-cover", className)
|
|
2288
|
+
}
|
|
2289
|
+
);
|
|
2290
|
+
}
|
|
2291
|
+
function formatCountdown(ms) {
|
|
2292
|
+
if (ms <= 0) return "0:00";
|
|
2293
|
+
const total = Math.floor(ms / 1e3);
|
|
2294
|
+
const h = Math.floor(total / 3600);
|
|
2295
|
+
const m = Math.floor(total % 3600 / 60);
|
|
2296
|
+
const s = total % 60;
|
|
2297
|
+
const mm = String(m).padStart(2, "0");
|
|
2298
|
+
const ss = String(s).padStart(2, "0");
|
|
2299
|
+
return h > 0 ? `${h}:${mm}:${ss}` : `${m}:${ss}`;
|
|
2300
|
+
}
|
|
2301
|
+
function WaitingRoom({
|
|
2302
|
+
title,
|
|
2303
|
+
organizationName,
|
|
2304
|
+
organizationImage,
|
|
2305
|
+
startsAt,
|
|
2306
|
+
durationSeconds,
|
|
2307
|
+
curtain,
|
|
2308
|
+
nowMs,
|
|
2309
|
+
labels,
|
|
2310
|
+
className
|
|
2311
|
+
}) {
|
|
2312
|
+
const [now, setNow] = React5.useState(nowMs ?? Date.now());
|
|
2313
|
+
React5.useEffect(() => {
|
|
2314
|
+
if (nowMs != null) {
|
|
2315
|
+
setNow(nowMs);
|
|
2316
|
+
return;
|
|
2317
|
+
}
|
|
2318
|
+
const timer = window.setInterval(() => setNow(Date.now()), 1e3);
|
|
2319
|
+
return () => window.clearInterval(timer);
|
|
2320
|
+
}, [nowMs]);
|
|
2321
|
+
const remaining = startsAt != null ? startsAt - now : null;
|
|
2322
|
+
const durationMinutes = durationSeconds != null ? Math.max(1, Math.round(durationSeconds / 60)) : null;
|
|
2323
|
+
return /* @__PURE__ */ jsxs(
|
|
2324
|
+
"div",
|
|
2325
|
+
{
|
|
2326
|
+
className: cn(
|
|
2327
|
+
"relative flex min-h-[16rem] w-full overflow-hidden rounded-lg bg-zinc-950 text-white",
|
|
2328
|
+
className
|
|
2329
|
+
),
|
|
2330
|
+
children: [
|
|
2331
|
+
curtain ? /* @__PURE__ */ jsx(
|
|
2332
|
+
CurtainStage,
|
|
2333
|
+
{
|
|
2334
|
+
kind: curtain.kind,
|
|
2335
|
+
url: curtain.url,
|
|
2336
|
+
className: "absolute inset-0"
|
|
2337
|
+
}
|
|
2338
|
+
) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
2339
|
+
/* @__PURE__ */ jsxs("div", { className: "relative z-10 flex w-full flex-col justify-end gap-3 bg-gradient-to-t from-black/70 via-black/30 to-transparent p-6", children: [
|
|
2340
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2341
|
+
organizationImage ? /* @__PURE__ */ jsx(
|
|
2342
|
+
"img",
|
|
2343
|
+
{
|
|
2344
|
+
src: organizationImage,
|
|
2345
|
+
alt: "",
|
|
2346
|
+
className: "size-10 rounded-lg object-cover"
|
|
2347
|
+
}
|
|
2348
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center rounded-lg bg-white/15 text-sm font-semibold", children: (organizationName ?? title).slice(0, 1).toUpperCase() }),
|
|
2349
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2350
|
+
/* @__PURE__ */ jsx("p", { className: "text-lg font-semibold tracking-tight", children: title }),
|
|
2351
|
+
organizationName ? /* @__PURE__ */ jsx("p", { className: "text-sm text-white/80", children: organizationName }) : null
|
|
2352
|
+
] })
|
|
2353
|
+
] }),
|
|
2354
|
+
remaining != null ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums", children: remaining > 0 ? `${labels?.startsIn ?? "Starts in"} ${formatCountdown(remaining)}` : labels?.started ?? "Starting soon" }) : null,
|
|
2355
|
+
durationMinutes != null ? /* @__PURE__ */ jsx("p", { className: "text-xs text-white/70", children: labels?.duration ? labels.duration(durationMinutes) : `${durationMinutes} min` }) : null
|
|
2356
|
+
] })
|
|
2357
|
+
]
|
|
2358
|
+
}
|
|
2359
|
+
);
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
// src/components/video/castHls.ts
|
|
2363
|
+
var CAST_SENDER_SRC = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
|
|
2364
|
+
var DEFAULT_RECEIVER_ID = "CC1AD845";
|
|
2365
|
+
var loadPromise = null;
|
|
2366
|
+
function loadCastSender() {
|
|
2367
|
+
if (typeof window === "undefined") return Promise.resolve();
|
|
2368
|
+
if (window.cast?.framework && window.chrome?.cast) return Promise.resolve();
|
|
2369
|
+
if (loadPromise) return loadPromise;
|
|
2370
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
2371
|
+
window.__onGCastApiAvailable = (available) => {
|
|
2372
|
+
if (available) resolve();
|
|
2373
|
+
else reject(new Error("Cast API unavailable"));
|
|
2374
|
+
};
|
|
2375
|
+
const existing = document.querySelector(`script[src="${CAST_SENDER_SRC}"]`);
|
|
2376
|
+
if (existing) return;
|
|
2377
|
+
const script = document.createElement("script");
|
|
2378
|
+
script.src = CAST_SENDER_SRC;
|
|
2379
|
+
script.async = true;
|
|
2380
|
+
script.onerror = () => reject(new Error("Cast sender failed to load"));
|
|
2381
|
+
document.head.appendChild(script);
|
|
2382
|
+
});
|
|
2383
|
+
return loadPromise;
|
|
2384
|
+
}
|
|
2385
|
+
async function castHlsUrl(hlsUrl) {
|
|
2386
|
+
await loadCastSender();
|
|
2387
|
+
const framework = window.cast?.framework;
|
|
2388
|
+
const chromeCast = window.chrome?.cast;
|
|
2389
|
+
if (!framework || !chromeCast) {
|
|
2390
|
+
throw new Error("Cast API unavailable");
|
|
2391
|
+
}
|
|
2392
|
+
const context = framework.CastContext.getInstance();
|
|
2393
|
+
context.setOptions({
|
|
2394
|
+
receiverApplicationId: chromeCast.media.DEFAULT_MEDIA_RECEIVER_APP_ID || DEFAULT_RECEIVER_ID,
|
|
2395
|
+
autoJoinPolicy: chromeCast.AutoJoinPolicy?.ORIGIN_SCOPED
|
|
2396
|
+
});
|
|
2397
|
+
if (!context.getCurrentSession()) {
|
|
2398
|
+
await context.requestSession();
|
|
2399
|
+
}
|
|
2400
|
+
const session = context.getCurrentSession();
|
|
2401
|
+
if (!session) throw new Error("No Cast session");
|
|
2402
|
+
const media = new chromeCast.media.MediaInfo(hlsUrl, "application/x-mpegURL");
|
|
2403
|
+
const request = new chromeCast.media.LoadRequest(media);
|
|
2404
|
+
await session.loadMedia(request);
|
|
2405
|
+
}
|
|
2229
2406
|
|
|
2230
2407
|
// src/components/video/hls-config.ts
|
|
2231
2408
|
function shouldRetryLiveEdge404(retryConfig, retryCount, _isTimeout, loaderResponse, defaultRetry) {
|
|
@@ -2405,27 +2582,27 @@ function useHlsPlayback({
|
|
|
2405
2582
|
onError,
|
|
2406
2583
|
onPlayingChange
|
|
2407
2584
|
}) {
|
|
2408
|
-
const videoRef =
|
|
2409
|
-
const hlsRef =
|
|
2410
|
-
const [state, setState] =
|
|
2411
|
-
const [qualities, setQualities] =
|
|
2412
|
-
const [activeLevel, setActiveLevel] =
|
|
2413
|
-
const [autoplayState, setAutoplayState] =
|
|
2414
|
-
const [error, setError] =
|
|
2415
|
-
const [reloadKey, setReloadKey] =
|
|
2416
|
-
const onErrorRef =
|
|
2417
|
-
const onPlayingChangeRef =
|
|
2418
|
-
|
|
2585
|
+
const videoRef = React5.useRef(null);
|
|
2586
|
+
const hlsRef = React5.useRef(null);
|
|
2587
|
+
const [state, setState] = React5.useState("idle");
|
|
2588
|
+
const [qualities, setQualities] = React5.useState([]);
|
|
2589
|
+
const [activeLevel, setActiveLevel] = React5.useState(-1);
|
|
2590
|
+
const [autoplayState, setAutoplayState] = React5.useState("none");
|
|
2591
|
+
const [error, setError] = React5.useState(null);
|
|
2592
|
+
const [reloadKey, setReloadKey] = React5.useState(0);
|
|
2593
|
+
const onErrorRef = React5.useRef(onError);
|
|
2594
|
+
const onPlayingChangeRef = React5.useRef(onPlayingChange);
|
|
2595
|
+
React5.useEffect(() => {
|
|
2419
2596
|
onErrorRef.current = onError;
|
|
2420
2597
|
onPlayingChangeRef.current = onPlayingChange;
|
|
2421
2598
|
}, [onError, onPlayingChange]);
|
|
2422
|
-
const retry =
|
|
2599
|
+
const retry = React5.useCallback(() => {
|
|
2423
2600
|
setError(null);
|
|
2424
2601
|
setState("loading");
|
|
2425
2602
|
setAutoplayState("none");
|
|
2426
2603
|
setReloadKey((k) => k + 1);
|
|
2427
2604
|
}, []);
|
|
2428
|
-
|
|
2605
|
+
React5.useEffect(() => {
|
|
2429
2606
|
const media = videoRef.current;
|
|
2430
2607
|
if (!media || !src || !active) {
|
|
2431
2608
|
setState("idle");
|
|
@@ -2695,7 +2872,7 @@ function useHlsPlayback({
|
|
|
2695
2872
|
destroyHls();
|
|
2696
2873
|
};
|
|
2697
2874
|
}, [src, mode, active, autoPlay, muted, reloadKey]);
|
|
2698
|
-
const setLevel =
|
|
2875
|
+
const setLevel = React5.useCallback((index) => {
|
|
2699
2876
|
const hls = hlsRef.current;
|
|
2700
2877
|
if (!hls) return;
|
|
2701
2878
|
hls.nextLevel = index;
|
|
@@ -2720,6 +2897,7 @@ var DEFAULT_LABELS2 = {
|
|
|
2720
2897
|
enterFullscreen: "Fullscreen",
|
|
2721
2898
|
exitFullscreen: "Exit fullscreen",
|
|
2722
2899
|
pictureInPicture: "Picture in picture",
|
|
2900
|
+
cast: "Cast",
|
|
2723
2901
|
settings: "Settings",
|
|
2724
2902
|
quality: "Quality",
|
|
2725
2903
|
auto: "Auto",
|
|
@@ -2780,12 +2958,12 @@ function VideoPlayer({
|
|
|
2780
2958
|
className
|
|
2781
2959
|
}) {
|
|
2782
2960
|
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
2783
|
-
const containerRef =
|
|
2784
|
-
const firstPlayFiredRef =
|
|
2785
|
-
const [userStarted, setUserStarted] =
|
|
2961
|
+
const containerRef = React5.useRef(null);
|
|
2962
|
+
const firstPlayFiredRef = React5.useRef(false);
|
|
2963
|
+
const [userStarted, setUserStarted] = React5.useState(false);
|
|
2786
2964
|
const active = autoPlay || !poster || userStarted;
|
|
2787
2965
|
const autoplayActive = autoPlay || userStarted;
|
|
2788
|
-
const handlePlayingChange =
|
|
2966
|
+
const handlePlayingChange = React5.useCallback(
|
|
2789
2967
|
(playing) => {
|
|
2790
2968
|
setIsPlaying(playing);
|
|
2791
2969
|
if (playing && !firstPlayFiredRef.current) {
|
|
@@ -2814,25 +2992,25 @@ function VideoPlayer({
|
|
|
2814
2992
|
onError,
|
|
2815
2993
|
onPlayingChange: handlePlayingChange
|
|
2816
2994
|
});
|
|
2817
|
-
const [isPlaying, setIsPlaying] =
|
|
2818
|
-
const [isMuted, setIsMuted] =
|
|
2819
|
-
const [volume, setVolume] =
|
|
2820
|
-
const [currentTime, setCurrentTime] =
|
|
2821
|
-
const [duration, setDuration] =
|
|
2822
|
-
const [buffered, setBuffered] =
|
|
2823
|
-
const [isFullscreen, setIsFullscreen] =
|
|
2824
|
-
const [pipActive, setPipActive] =
|
|
2825
|
-
const [controlsVisible, setControlsVisible] =
|
|
2826
|
-
const [playbackRate, setPlaybackRate] =
|
|
2827
|
-
const [openMenu, setOpenMenu] =
|
|
2995
|
+
const [isPlaying, setIsPlaying] = React5.useState(false);
|
|
2996
|
+
const [isMuted, setIsMuted] = React5.useState(muted);
|
|
2997
|
+
const [volume, setVolume] = React5.useState(1);
|
|
2998
|
+
const [currentTime, setCurrentTime] = React5.useState(0);
|
|
2999
|
+
const [duration, setDuration] = React5.useState(0);
|
|
3000
|
+
const [buffered, setBuffered] = React5.useState(0);
|
|
3001
|
+
const [isFullscreen, setIsFullscreen] = React5.useState(false);
|
|
3002
|
+
const [pipActive, setPipActive] = React5.useState(false);
|
|
3003
|
+
const [controlsVisible, setControlsVisible] = React5.useState(true);
|
|
3004
|
+
const [playbackRate, setPlaybackRate] = React5.useState(1);
|
|
3005
|
+
const [openMenu, setOpenMenu] = React5.useState(
|
|
2828
3006
|
null
|
|
2829
3007
|
);
|
|
2830
|
-
const [behindLive, setBehindLive] =
|
|
2831
|
-
const [webkitFullscreenSupported, setWebkitFullscreenSupported] =
|
|
2832
|
-
const hideTimerRef =
|
|
3008
|
+
const [behindLive, setBehindLive] = React5.useState(false);
|
|
3009
|
+
const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React5.useState(false);
|
|
3010
|
+
const hideTimerRef = React5.useRef(null);
|
|
2833
3011
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
2834
3012
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
|
|
2835
|
-
|
|
3013
|
+
React5.useEffect(() => {
|
|
2836
3014
|
const video = videoRef.current;
|
|
2837
3015
|
if (!video || !active) return;
|
|
2838
3016
|
const onTimeUpdate = () => {
|
|
@@ -2865,20 +3043,21 @@ function VideoPlayer({
|
|
|
2865
3043
|
video.removeEventListener("ratechange", onRate);
|
|
2866
3044
|
};
|
|
2867
3045
|
}, [videoRef, active, mode]);
|
|
2868
|
-
|
|
3046
|
+
React5.useEffect(() => {
|
|
2869
3047
|
const video = videoRef.current;
|
|
2870
3048
|
if (!paused || !video || !isPlaying) return;
|
|
2871
3049
|
video.pause();
|
|
2872
3050
|
}, [paused, videoRef, isPlaying]);
|
|
2873
|
-
|
|
3051
|
+
React5.useEffect(() => {
|
|
2874
3052
|
setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
|
|
3053
|
+
videoRef.current?.setAttribute("x-webkit-airplay", "allow");
|
|
2875
3054
|
}, [videoRef, active]);
|
|
2876
|
-
|
|
3055
|
+
React5.useEffect(() => {
|
|
2877
3056
|
const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
2878
3057
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
2879
3058
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
2880
3059
|
}, []);
|
|
2881
|
-
|
|
3060
|
+
React5.useEffect(() => {
|
|
2882
3061
|
const video = asWebkitVideo(videoRef.current);
|
|
2883
3062
|
if (!video) return;
|
|
2884
3063
|
const onBegin = () => setIsFullscreen(true);
|
|
@@ -2890,7 +3069,7 @@ function VideoPlayer({
|
|
|
2890
3069
|
video.removeEventListener("webkitendfullscreen", onEnd);
|
|
2891
3070
|
};
|
|
2892
3071
|
}, [videoRef, active]);
|
|
2893
|
-
|
|
3072
|
+
React5.useEffect(() => {
|
|
2894
3073
|
const video = videoRef.current;
|
|
2895
3074
|
if (!video) return;
|
|
2896
3075
|
const onEnter = () => setPipActive(true);
|
|
@@ -2902,18 +3081,18 @@ function VideoPlayer({
|
|
|
2902
3081
|
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
2903
3082
|
};
|
|
2904
3083
|
}, [videoRef]);
|
|
2905
|
-
const scheduleHide =
|
|
3084
|
+
const scheduleHide = React5.useCallback(() => {
|
|
2906
3085
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
2907
3086
|
hideTimerRef.current = setTimeout(() => {
|
|
2908
3087
|
setControlsVisible(false);
|
|
2909
3088
|
setOpenMenu(null);
|
|
2910
3089
|
}, CONTROLS_HIDE_MS);
|
|
2911
3090
|
}, []);
|
|
2912
|
-
const revealControls =
|
|
3091
|
+
const revealControls = React5.useCallback(() => {
|
|
2913
3092
|
setControlsVisible(true);
|
|
2914
3093
|
scheduleHide();
|
|
2915
3094
|
}, [scheduleHide]);
|
|
2916
|
-
|
|
3095
|
+
React5.useEffect(() => {
|
|
2917
3096
|
return () => {
|
|
2918
3097
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
2919
3098
|
};
|
|
@@ -3284,6 +3463,16 @@ function VideoPlayer({
|
|
|
3284
3463
|
]
|
|
3285
3464
|
}
|
|
3286
3465
|
),
|
|
3466
|
+
/* @__PURE__ */ jsx(
|
|
3467
|
+
ControlButton,
|
|
3468
|
+
{
|
|
3469
|
+
label: t.cast,
|
|
3470
|
+
onClick: () => {
|
|
3471
|
+
void castHlsUrl(src).catch(() => void 0);
|
|
3472
|
+
},
|
|
3473
|
+
children: /* @__PURE__ */ jsx(Cast, { className: "size-5" })
|
|
3474
|
+
}
|
|
3475
|
+
),
|
|
3287
3476
|
pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
|
|
3288
3477
|
PictureInPicture2,
|
|
3289
3478
|
{
|
|
@@ -3406,16 +3595,16 @@ function videoInPictureInPicture(container) {
|
|
|
3406
3595
|
return container.contains(pip);
|
|
3407
3596
|
}
|
|
3408
3597
|
function useFeedExclusivePlayback(playbackId) {
|
|
3409
|
-
const containerRef =
|
|
3410
|
-
const [forcePaused, setForcePaused] =
|
|
3411
|
-
const requestPause =
|
|
3598
|
+
const containerRef = React5.useRef(null);
|
|
3599
|
+
const [forcePaused, setForcePaused] = React5.useState(false);
|
|
3600
|
+
const requestPause = React5.useCallback(() => {
|
|
3412
3601
|
if (videoInPictureInPicture(containerRef.current)) return;
|
|
3413
3602
|
setForcePaused(true);
|
|
3414
3603
|
}, []);
|
|
3415
|
-
|
|
3604
|
+
React5.useEffect(() => {
|
|
3416
3605
|
return registerFeedPlayer(playbackId, requestPause);
|
|
3417
3606
|
}, [playbackId, requestPause]);
|
|
3418
|
-
|
|
3607
|
+
React5.useEffect(() => {
|
|
3419
3608
|
const node = containerRef.current;
|
|
3420
3609
|
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
3421
3610
|
const observer = new IntersectionObserver(
|
|
@@ -3431,14 +3620,14 @@ function useFeedExclusivePlayback(playbackId) {
|
|
|
3431
3620
|
observer.observe(node);
|
|
3432
3621
|
return () => observer.disconnect();
|
|
3433
3622
|
}, [requestPause]);
|
|
3434
|
-
|
|
3623
|
+
React5.useEffect(() => {
|
|
3435
3624
|
const onVisibility = () => {
|
|
3436
3625
|
if (document.hidden) requestPause();
|
|
3437
3626
|
};
|
|
3438
3627
|
document.addEventListener("visibilitychange", onVisibility);
|
|
3439
3628
|
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
3440
3629
|
}, [requestPause]);
|
|
3441
|
-
const onPlayingChange =
|
|
3630
|
+
const onPlayingChange = React5.useCallback(
|
|
3442
3631
|
(playing) => {
|
|
3443
3632
|
if (!playing) return;
|
|
3444
3633
|
setForcePaused(false);
|
|
@@ -3465,7 +3654,7 @@ function FeedVideoPlayer({
|
|
|
3465
3654
|
paused: exclusivePaused,
|
|
3466
3655
|
onPlayingChange: onExclusivePlayingChange
|
|
3467
3656
|
} = useFeedExclusivePlayback(playbackId);
|
|
3468
|
-
const handlePlayingChange =
|
|
3657
|
+
const handlePlayingChange = React5.useCallback(
|
|
3469
3658
|
(playing) => {
|
|
3470
3659
|
onExclusivePlayingChange(playing);
|
|
3471
3660
|
onPlayingChange?.(playing);
|
|
@@ -3492,8 +3681,8 @@ function FeedVideoPlayer({
|
|
|
3492
3681
|
);
|
|
3493
3682
|
}
|
|
3494
3683
|
function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
|
|
3495
|
-
const [stats, setStats] =
|
|
3496
|
-
|
|
3684
|
+
const [stats, setStats] = React5.useState({});
|
|
3685
|
+
React5.useEffect(() => {
|
|
3497
3686
|
if (!statsUrl || !enabled) return;
|
|
3498
3687
|
let cancelled = false;
|
|
3499
3688
|
const controller = new AbortController();
|
|
@@ -3616,6 +3805,6 @@ function avatarFallbackStyle(name) {
|
|
|
3616
3805
|
return getAvatarColors(name);
|
|
3617
3806
|
}
|
|
3618
3807
|
|
|
3619
|
-
export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, avatarFallbackStyle, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
|
|
3808
|
+
export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainStage, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
|
|
3620
3809
|
//# sourceMappingURL=index.js.map
|
|
3621
3810
|
//# sourceMappingURL=index.js.map
|