@livo-tv/blocks 1.1.0 → 1.2.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 +23 -0
- package/dist/index.cjs +463 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +401 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import * as
|
|
2
|
+
import * as React7 from 'react';
|
|
3
3
|
import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
4
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';
|
|
@@ -1196,7 +1196,7 @@ function Slider({
|
|
|
1196
1196
|
max = 100,
|
|
1197
1197
|
...props
|
|
1198
1198
|
}) {
|
|
1199
|
-
const _values =
|
|
1199
|
+
const _values = React7.useMemo(
|
|
1200
1200
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
1201
1201
|
[value, defaultValue, min, max]
|
|
1202
1202
|
);
|
|
@@ -2233,8 +2233,8 @@ function AvatarEditorDialog({
|
|
|
2233
2233
|
] });
|
|
2234
2234
|
}
|
|
2235
2235
|
function usePrefersReducedMotion() {
|
|
2236
|
-
const [reduced, setReduced] =
|
|
2237
|
-
|
|
2236
|
+
const [reduced, setReduced] = React7.useState(false);
|
|
2237
|
+
React7.useEffect(() => {
|
|
2238
2238
|
const media = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2239
2239
|
const sync = () => setReduced(media.matches);
|
|
2240
2240
|
sync();
|
|
@@ -2288,6 +2288,349 @@ function CurtainStage({
|
|
|
2288
2288
|
}
|
|
2289
2289
|
);
|
|
2290
2290
|
}
|
|
2291
|
+
function useMediaQuery2(query) {
|
|
2292
|
+
const [matches, setMatches] = useState(false);
|
|
2293
|
+
useEffect(() => {
|
|
2294
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
2295
|
+
const mql = window.matchMedia(query);
|
|
2296
|
+
const onChange = () => setMatches(mql.matches);
|
|
2297
|
+
onChange();
|
|
2298
|
+
mql.addEventListener("change", onChange);
|
|
2299
|
+
return () => mql.removeEventListener("change", onChange);
|
|
2300
|
+
}, [query]);
|
|
2301
|
+
return matches;
|
|
2302
|
+
}
|
|
2303
|
+
function isVideoKind(kind) {
|
|
2304
|
+
return kind === "video";
|
|
2305
|
+
}
|
|
2306
|
+
function useElementInView(enabled) {
|
|
2307
|
+
const [node, setNode] = React7.useState(null);
|
|
2308
|
+
const [inView, setInView] = React7.useState(false);
|
|
2309
|
+
React7.useEffect(() => {
|
|
2310
|
+
if (!enabled || !node || typeof IntersectionObserver === "undefined") {
|
|
2311
|
+
setInView(false);
|
|
2312
|
+
return;
|
|
2313
|
+
}
|
|
2314
|
+
const observer = new IntersectionObserver(
|
|
2315
|
+
(entries) => {
|
|
2316
|
+
const entry = entries[0];
|
|
2317
|
+
setInView(Boolean(entry?.isIntersecting));
|
|
2318
|
+
},
|
|
2319
|
+
{ threshold: 0.35, rootMargin: "32px" }
|
|
2320
|
+
);
|
|
2321
|
+
observer.observe(node);
|
|
2322
|
+
return () => observer.disconnect();
|
|
2323
|
+
}, [enabled, node]);
|
|
2324
|
+
return [setNode, inView];
|
|
2325
|
+
}
|
|
2326
|
+
function CurtainPreview({
|
|
2327
|
+
kind,
|
|
2328
|
+
url,
|
|
2329
|
+
alt = "",
|
|
2330
|
+
className,
|
|
2331
|
+
playWhenVisible = true
|
|
2332
|
+
}) {
|
|
2333
|
+
const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
|
|
2334
|
+
const video = isVideoKind(kind);
|
|
2335
|
+
const observe = playWhenVisible && video && !prefersReduced;
|
|
2336
|
+
const [setNode, inView] = useElementInView(observe);
|
|
2337
|
+
const shouldPlay = video && !prefersReduced && (!playWhenVisible || inView);
|
|
2338
|
+
if (!url) {
|
|
2339
|
+
return /* @__PURE__ */ jsx(
|
|
2340
|
+
"div",
|
|
2341
|
+
{
|
|
2342
|
+
ref: setNode,
|
|
2343
|
+
className: cn("aspect-video rounded-md bg-skeleton", className),
|
|
2344
|
+
"aria-hidden": "true"
|
|
2345
|
+
}
|
|
2346
|
+
);
|
|
2347
|
+
}
|
|
2348
|
+
const stageKind = video ? "video" : "image";
|
|
2349
|
+
return /* @__PURE__ */ jsx(
|
|
2350
|
+
"div",
|
|
2351
|
+
{
|
|
2352
|
+
ref: setNode,
|
|
2353
|
+
className: cn(
|
|
2354
|
+
"aspect-video overflow-hidden rounded-md bg-black",
|
|
2355
|
+
className
|
|
2356
|
+
),
|
|
2357
|
+
children: /* @__PURE__ */ jsx(
|
|
2358
|
+
CurtainStage,
|
|
2359
|
+
{
|
|
2360
|
+
kind: stageKind,
|
|
2361
|
+
url,
|
|
2362
|
+
alt,
|
|
2363
|
+
reducedMotion: !shouldPlay,
|
|
2364
|
+
className: "h-full w-full"
|
|
2365
|
+
}
|
|
2366
|
+
)
|
|
2367
|
+
}
|
|
2368
|
+
);
|
|
2369
|
+
}
|
|
2370
|
+
var DEFAULT_CURTAIN_PICKER_LABELS = {
|
|
2371
|
+
select: "Curtain",
|
|
2372
|
+
none: "None",
|
|
2373
|
+
noneDescription: "Use the default curtain",
|
|
2374
|
+
defaultBadge: "Default",
|
|
2375
|
+
makeDefault: "Set as default",
|
|
2376
|
+
delete: "Delete",
|
|
2377
|
+
image: "Image",
|
|
2378
|
+
video: "Video",
|
|
2379
|
+
organization: "Organization",
|
|
2380
|
+
platform: "Catalog",
|
|
2381
|
+
groupOrganization: "Your curtains",
|
|
2382
|
+
groupPlatform: "Catalog",
|
|
2383
|
+
groupOther: "Other",
|
|
2384
|
+
emptyTitle: "No curtains yet",
|
|
2385
|
+
emptyDescription: "Upload an image or a short looping video."
|
|
2386
|
+
};
|
|
2387
|
+
var OWNER_GROUPS = [
|
|
2388
|
+
"organization",
|
|
2389
|
+
"platform",
|
|
2390
|
+
"other"
|
|
2391
|
+
];
|
|
2392
|
+
function ownerGroup(ownerType) {
|
|
2393
|
+
switch (ownerType) {
|
|
2394
|
+
case "organization":
|
|
2395
|
+
return "organization";
|
|
2396
|
+
case "platform":
|
|
2397
|
+
return "platform";
|
|
2398
|
+
default:
|
|
2399
|
+
return "other";
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
function kindLabel(kind, copy) {
|
|
2403
|
+
return kind === "video" ? copy.video : copy.image;
|
|
2404
|
+
}
|
|
2405
|
+
function ownerLabel(ownerType, copy) {
|
|
2406
|
+
if (ownerType === "organization") return copy.organization;
|
|
2407
|
+
if (ownerType === "platform") return copy.platform;
|
|
2408
|
+
return null;
|
|
2409
|
+
}
|
|
2410
|
+
function groupHeading(group, copy) {
|
|
2411
|
+
const headings = {
|
|
2412
|
+
organization: copy.groupOrganization,
|
|
2413
|
+
platform: copy.groupPlatform,
|
|
2414
|
+
other: copy.groupOther
|
|
2415
|
+
};
|
|
2416
|
+
return headings[group];
|
|
2417
|
+
}
|
|
2418
|
+
function gridClass(variant) {
|
|
2419
|
+
return variant === "compact" ? "grid gap-3 sm:grid-cols-2" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
|
|
2420
|
+
}
|
|
2421
|
+
function CurtainPickerSkeleton({
|
|
2422
|
+
count = 6,
|
|
2423
|
+
variant = "default",
|
|
2424
|
+
className
|
|
2425
|
+
}) {
|
|
2426
|
+
return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
|
|
2427
|
+
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2428
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
|
|
2429
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 w-1/3 rounded bg-skeleton" })
|
|
2430
|
+
] }, index)) });
|
|
2431
|
+
}
|
|
2432
|
+
function CurtainPicker({
|
|
2433
|
+
curtains,
|
|
2434
|
+
value = null,
|
|
2435
|
+
onChange,
|
|
2436
|
+
allowNone = false,
|
|
2437
|
+
disabled = false,
|
|
2438
|
+
variant = "default",
|
|
2439
|
+
groupByOwner = false,
|
|
2440
|
+
onMakeDefault,
|
|
2441
|
+
onDelete,
|
|
2442
|
+
canMakeDefault,
|
|
2443
|
+
canDelete,
|
|
2444
|
+
labels,
|
|
2445
|
+
emptyAction,
|
|
2446
|
+
className,
|
|
2447
|
+
actionsPending = false
|
|
2448
|
+
}) {
|
|
2449
|
+
const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
|
|
2450
|
+
const groupName = React7.useId();
|
|
2451
|
+
const selectable = typeof onChange === "function";
|
|
2452
|
+
const selectedId = value === "" ? null : value ?? null;
|
|
2453
|
+
const ready = curtains.filter((curtain) => curtain.publicUrl);
|
|
2454
|
+
const showEmpty = ready.length === 0 && !allowNone;
|
|
2455
|
+
const grouped = React7.useMemo(() => {
|
|
2456
|
+
if (!groupByOwner) {
|
|
2457
|
+
return [{ group: null, items: ready }];
|
|
2458
|
+
}
|
|
2459
|
+
return OWNER_GROUPS.map((group) => ({
|
|
2460
|
+
group,
|
|
2461
|
+
items: ready.filter((curtain) => ownerGroup(curtain.ownerType) === group)
|
|
2462
|
+
})).filter((section) => section.items.length > 0);
|
|
2463
|
+
}, [groupByOwner, ready]);
|
|
2464
|
+
if (showEmpty) {
|
|
2465
|
+
return /* @__PURE__ */ jsx(
|
|
2466
|
+
EmptyState,
|
|
2467
|
+
{
|
|
2468
|
+
title: copy.emptyTitle,
|
|
2469
|
+
description: copy.emptyDescription,
|
|
2470
|
+
action: emptyAction,
|
|
2471
|
+
className
|
|
2472
|
+
}
|
|
2473
|
+
);
|
|
2474
|
+
}
|
|
2475
|
+
const noneTile = allowNone && selectable ? /* @__PURE__ */ jsx(
|
|
2476
|
+
NoneTile,
|
|
2477
|
+
{
|
|
2478
|
+
name: groupName,
|
|
2479
|
+
checked: selectedId === null,
|
|
2480
|
+
disabled,
|
|
2481
|
+
copy,
|
|
2482
|
+
onSelect: () => onChange(null)
|
|
2483
|
+
}
|
|
2484
|
+
) : null;
|
|
2485
|
+
if (grouped.length === 0 && noneTile) {
|
|
2486
|
+
return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), children: /* @__PURE__ */ jsx("li", { children: noneTile }) });
|
|
2487
|
+
}
|
|
2488
|
+
return /* @__PURE__ */ jsx("div", { className: cn("space-y-6", className), children: grouped.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
2489
|
+
section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
|
|
2490
|
+
/* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
|
|
2491
|
+
index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
|
|
2492
|
+
section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
2493
|
+
CurtainPickerCard,
|
|
2494
|
+
{
|
|
2495
|
+
item,
|
|
2496
|
+
name: groupName,
|
|
2497
|
+
selectable,
|
|
2498
|
+
checked: selectedId === item.id,
|
|
2499
|
+
disabled,
|
|
2500
|
+
actionsPending,
|
|
2501
|
+
copy,
|
|
2502
|
+
onSelect: onChange ? () => onChange(item.id) : void 0,
|
|
2503
|
+
onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
|
|
2504
|
+
onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
|
|
2505
|
+
}
|
|
2506
|
+
) }, item.id))
|
|
2507
|
+
] })
|
|
2508
|
+
] }, section.group ?? "all")) });
|
|
2509
|
+
}
|
|
2510
|
+
function NoneTile({
|
|
2511
|
+
name,
|
|
2512
|
+
checked,
|
|
2513
|
+
disabled,
|
|
2514
|
+
copy,
|
|
2515
|
+
onSelect
|
|
2516
|
+
}) {
|
|
2517
|
+
return /* @__PURE__ */ jsxs(
|
|
2518
|
+
"label",
|
|
2519
|
+
{
|
|
2520
|
+
className: cn(
|
|
2521
|
+
"block cursor-pointer space-y-3 rounded-xl border p-4 transition-shadow",
|
|
2522
|
+
"has-[:checked]:ring-ring has-[:checked]:ring-2",
|
|
2523
|
+
"has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
|
|
2524
|
+
disabled && "pointer-events-none opacity-50"
|
|
2525
|
+
),
|
|
2526
|
+
children: [
|
|
2527
|
+
/* @__PURE__ */ jsx(
|
|
2528
|
+
"input",
|
|
2529
|
+
{
|
|
2530
|
+
type: "radio",
|
|
2531
|
+
name,
|
|
2532
|
+
value: "",
|
|
2533
|
+
checked,
|
|
2534
|
+
disabled,
|
|
2535
|
+
onChange: onSelect,
|
|
2536
|
+
className: "sr-only"
|
|
2537
|
+
}
|
|
2538
|
+
),
|
|
2539
|
+
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
2540
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2541
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
|
|
2542
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
|
|
2543
|
+
] })
|
|
2544
|
+
]
|
|
2545
|
+
}
|
|
2546
|
+
);
|
|
2547
|
+
}
|
|
2548
|
+
function CurtainPickerCard({
|
|
2549
|
+
item,
|
|
2550
|
+
name,
|
|
2551
|
+
selectable,
|
|
2552
|
+
checked,
|
|
2553
|
+
disabled,
|
|
2554
|
+
actionsPending,
|
|
2555
|
+
copy,
|
|
2556
|
+
onSelect,
|
|
2557
|
+
onMakeDefault,
|
|
2558
|
+
onDelete
|
|
2559
|
+
}) {
|
|
2560
|
+
const owner = ownerLabel(item.ownerType, copy);
|
|
2561
|
+
const media = /* @__PURE__ */ jsx(CurtainPreview, { kind: item.kind, url: item.publicUrl, alt: item.title });
|
|
2562
|
+
const meta = /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
2563
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
2564
|
+
/* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: item.title }),
|
|
2565
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 ") })
|
|
2566
|
+
] }),
|
|
2567
|
+
item.isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: copy.defaultBadge }) : null
|
|
2568
|
+
] });
|
|
2569
|
+
return /* @__PURE__ */ jsxs(
|
|
2570
|
+
"div",
|
|
2571
|
+
{
|
|
2572
|
+
className: cn(
|
|
2573
|
+
"space-y-3 rounded-xl border p-4",
|
|
2574
|
+
selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
|
|
2575
|
+
disabled && "opacity-50"
|
|
2576
|
+
),
|
|
2577
|
+
children: [
|
|
2578
|
+
selectable && onSelect ? /* @__PURE__ */ jsxs(
|
|
2579
|
+
"label",
|
|
2580
|
+
{
|
|
2581
|
+
className: cn(
|
|
2582
|
+
"block space-y-3",
|
|
2583
|
+
disabled ? "pointer-events-none" : "cursor-pointer"
|
|
2584
|
+
),
|
|
2585
|
+
children: [
|
|
2586
|
+
/* @__PURE__ */ jsx(
|
|
2587
|
+
"input",
|
|
2588
|
+
{
|
|
2589
|
+
type: "radio",
|
|
2590
|
+
name,
|
|
2591
|
+
value: item.id,
|
|
2592
|
+
checked,
|
|
2593
|
+
disabled,
|
|
2594
|
+
onChange: onSelect,
|
|
2595
|
+
className: "sr-only"
|
|
2596
|
+
}
|
|
2597
|
+
),
|
|
2598
|
+
media,
|
|
2599
|
+
meta
|
|
2600
|
+
]
|
|
2601
|
+
}
|
|
2602
|
+
) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2603
|
+
media,
|
|
2604
|
+
meta
|
|
2605
|
+
] }),
|
|
2606
|
+
onMakeDefault || onDelete ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
2607
|
+
onMakeDefault ? /* @__PURE__ */ jsx(
|
|
2608
|
+
Button,
|
|
2609
|
+
{
|
|
2610
|
+
type: "button",
|
|
2611
|
+
size: "sm",
|
|
2612
|
+
variant: "secondary",
|
|
2613
|
+
disabled: disabled || actionsPending,
|
|
2614
|
+
onClick: onMakeDefault,
|
|
2615
|
+
children: copy.makeDefault
|
|
2616
|
+
}
|
|
2617
|
+
) : null,
|
|
2618
|
+
onDelete ? /* @__PURE__ */ jsx(
|
|
2619
|
+
Button,
|
|
2620
|
+
{
|
|
2621
|
+
type: "button",
|
|
2622
|
+
size: "sm",
|
|
2623
|
+
variant: "destructive",
|
|
2624
|
+
disabled: disabled || actionsPending,
|
|
2625
|
+
onClick: onDelete,
|
|
2626
|
+
children: copy.delete
|
|
2627
|
+
}
|
|
2628
|
+
) : null
|
|
2629
|
+
] }) : null
|
|
2630
|
+
]
|
|
2631
|
+
}
|
|
2632
|
+
);
|
|
2633
|
+
}
|
|
2291
2634
|
function formatCountdown(ms) {
|
|
2292
2635
|
if (ms <= 0) return "0:00";
|
|
2293
2636
|
const total = Math.floor(ms / 1e3);
|
|
@@ -2309,8 +2652,8 @@ function WaitingRoom({
|
|
|
2309
2652
|
labels,
|
|
2310
2653
|
className
|
|
2311
2654
|
}) {
|
|
2312
|
-
const [now, setNow] =
|
|
2313
|
-
|
|
2655
|
+
const [now, setNow] = React7.useState(nowMs ?? Date.now());
|
|
2656
|
+
React7.useEffect(() => {
|
|
2314
2657
|
if (nowMs != null) {
|
|
2315
2658
|
setNow(nowMs);
|
|
2316
2659
|
return;
|
|
@@ -2582,27 +2925,27 @@ function useHlsPlayback({
|
|
|
2582
2925
|
onError,
|
|
2583
2926
|
onPlayingChange
|
|
2584
2927
|
}) {
|
|
2585
|
-
const videoRef =
|
|
2586
|
-
const hlsRef =
|
|
2587
|
-
const [state, setState] =
|
|
2588
|
-
const [qualities, setQualities] =
|
|
2589
|
-
const [activeLevel, setActiveLevel] =
|
|
2590
|
-
const [autoplayState, setAutoplayState] =
|
|
2591
|
-
const [error, setError] =
|
|
2592
|
-
const [reloadKey, setReloadKey] =
|
|
2593
|
-
const onErrorRef =
|
|
2594
|
-
const onPlayingChangeRef =
|
|
2595
|
-
|
|
2928
|
+
const videoRef = React7.useRef(null);
|
|
2929
|
+
const hlsRef = React7.useRef(null);
|
|
2930
|
+
const [state, setState] = React7.useState("idle");
|
|
2931
|
+
const [qualities, setQualities] = React7.useState([]);
|
|
2932
|
+
const [activeLevel, setActiveLevel] = React7.useState(-1);
|
|
2933
|
+
const [autoplayState, setAutoplayState] = React7.useState("none");
|
|
2934
|
+
const [error, setError] = React7.useState(null);
|
|
2935
|
+
const [reloadKey, setReloadKey] = React7.useState(0);
|
|
2936
|
+
const onErrorRef = React7.useRef(onError);
|
|
2937
|
+
const onPlayingChangeRef = React7.useRef(onPlayingChange);
|
|
2938
|
+
React7.useEffect(() => {
|
|
2596
2939
|
onErrorRef.current = onError;
|
|
2597
2940
|
onPlayingChangeRef.current = onPlayingChange;
|
|
2598
2941
|
}, [onError, onPlayingChange]);
|
|
2599
|
-
const retry =
|
|
2942
|
+
const retry = React7.useCallback(() => {
|
|
2600
2943
|
setError(null);
|
|
2601
2944
|
setState("loading");
|
|
2602
2945
|
setAutoplayState("none");
|
|
2603
2946
|
setReloadKey((k) => k + 1);
|
|
2604
2947
|
}, []);
|
|
2605
|
-
|
|
2948
|
+
React7.useEffect(() => {
|
|
2606
2949
|
const media = videoRef.current;
|
|
2607
2950
|
if (!media || !src || !active) {
|
|
2608
2951
|
setState("idle");
|
|
@@ -2872,7 +3215,7 @@ function useHlsPlayback({
|
|
|
2872
3215
|
destroyHls();
|
|
2873
3216
|
};
|
|
2874
3217
|
}, [src, mode, active, autoPlay, muted, reloadKey]);
|
|
2875
|
-
const setLevel =
|
|
3218
|
+
const setLevel = React7.useCallback((index) => {
|
|
2876
3219
|
const hls = hlsRef.current;
|
|
2877
3220
|
if (!hls) return;
|
|
2878
3221
|
hls.nextLevel = index;
|
|
@@ -2958,12 +3301,12 @@ function VideoPlayer({
|
|
|
2958
3301
|
className
|
|
2959
3302
|
}) {
|
|
2960
3303
|
const t = { ...DEFAULT_LABELS2, ...labels };
|
|
2961
|
-
const containerRef =
|
|
2962
|
-
const firstPlayFiredRef =
|
|
2963
|
-
const [userStarted, setUserStarted] =
|
|
3304
|
+
const containerRef = React7.useRef(null);
|
|
3305
|
+
const firstPlayFiredRef = React7.useRef(false);
|
|
3306
|
+
const [userStarted, setUserStarted] = React7.useState(false);
|
|
2964
3307
|
const active = autoPlay || !poster || userStarted;
|
|
2965
3308
|
const autoplayActive = autoPlay || userStarted;
|
|
2966
|
-
const handlePlayingChange =
|
|
3309
|
+
const handlePlayingChange = React7.useCallback(
|
|
2967
3310
|
(playing) => {
|
|
2968
3311
|
setIsPlaying(playing);
|
|
2969
3312
|
if (playing && !firstPlayFiredRef.current) {
|
|
@@ -2992,25 +3335,25 @@ function VideoPlayer({
|
|
|
2992
3335
|
onError,
|
|
2993
3336
|
onPlayingChange: handlePlayingChange
|
|
2994
3337
|
});
|
|
2995
|
-
const [isPlaying, setIsPlaying] =
|
|
2996
|
-
const [isMuted, setIsMuted] =
|
|
2997
|
-
const [volume, setVolume] =
|
|
2998
|
-
const [currentTime, setCurrentTime] =
|
|
2999
|
-
const [duration, setDuration] =
|
|
3000
|
-
const [buffered, setBuffered] =
|
|
3001
|
-
const [isFullscreen, setIsFullscreen] =
|
|
3002
|
-
const [pipActive, setPipActive] =
|
|
3003
|
-
const [controlsVisible, setControlsVisible] =
|
|
3004
|
-
const [playbackRate, setPlaybackRate] =
|
|
3005
|
-
const [openMenu, setOpenMenu] =
|
|
3338
|
+
const [isPlaying, setIsPlaying] = React7.useState(false);
|
|
3339
|
+
const [isMuted, setIsMuted] = React7.useState(muted);
|
|
3340
|
+
const [volume, setVolume] = React7.useState(1);
|
|
3341
|
+
const [currentTime, setCurrentTime] = React7.useState(0);
|
|
3342
|
+
const [duration, setDuration] = React7.useState(0);
|
|
3343
|
+
const [buffered, setBuffered] = React7.useState(0);
|
|
3344
|
+
const [isFullscreen, setIsFullscreen] = React7.useState(false);
|
|
3345
|
+
const [pipActive, setPipActive] = React7.useState(false);
|
|
3346
|
+
const [controlsVisible, setControlsVisible] = React7.useState(true);
|
|
3347
|
+
const [playbackRate, setPlaybackRate] = React7.useState(1);
|
|
3348
|
+
const [openMenu, setOpenMenu] = React7.useState(
|
|
3006
3349
|
null
|
|
3007
3350
|
);
|
|
3008
|
-
const [behindLive, setBehindLive] =
|
|
3009
|
-
const [webkitFullscreenSupported, setWebkitFullscreenSupported] =
|
|
3010
|
-
const hideTimerRef =
|
|
3351
|
+
const [behindLive, setBehindLive] = React7.useState(false);
|
|
3352
|
+
const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React7.useState(false);
|
|
3353
|
+
const hideTimerRef = React7.useRef(null);
|
|
3011
3354
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
3012
3355
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
|
|
3013
|
-
|
|
3356
|
+
React7.useEffect(() => {
|
|
3014
3357
|
const video = videoRef.current;
|
|
3015
3358
|
if (!video || !active) return;
|
|
3016
3359
|
const onTimeUpdate = () => {
|
|
@@ -3043,21 +3386,21 @@ function VideoPlayer({
|
|
|
3043
3386
|
video.removeEventListener("ratechange", onRate);
|
|
3044
3387
|
};
|
|
3045
3388
|
}, [videoRef, active, mode]);
|
|
3046
|
-
|
|
3389
|
+
React7.useEffect(() => {
|
|
3047
3390
|
const video = videoRef.current;
|
|
3048
3391
|
if (!paused || !video || !isPlaying) return;
|
|
3049
3392
|
video.pause();
|
|
3050
3393
|
}, [paused, videoRef, isPlaying]);
|
|
3051
|
-
|
|
3394
|
+
React7.useEffect(() => {
|
|
3052
3395
|
setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
|
|
3053
3396
|
videoRef.current?.setAttribute("x-webkit-airplay", "allow");
|
|
3054
3397
|
}, [videoRef, active]);
|
|
3055
|
-
|
|
3398
|
+
React7.useEffect(() => {
|
|
3056
3399
|
const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
3057
3400
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
3058
3401
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
3059
3402
|
}, []);
|
|
3060
|
-
|
|
3403
|
+
React7.useEffect(() => {
|
|
3061
3404
|
const video = asWebkitVideo(videoRef.current);
|
|
3062
3405
|
if (!video) return;
|
|
3063
3406
|
const onBegin = () => setIsFullscreen(true);
|
|
@@ -3069,7 +3412,7 @@ function VideoPlayer({
|
|
|
3069
3412
|
video.removeEventListener("webkitendfullscreen", onEnd);
|
|
3070
3413
|
};
|
|
3071
3414
|
}, [videoRef, active]);
|
|
3072
|
-
|
|
3415
|
+
React7.useEffect(() => {
|
|
3073
3416
|
const video = videoRef.current;
|
|
3074
3417
|
if (!video) return;
|
|
3075
3418
|
const onEnter = () => setPipActive(true);
|
|
@@ -3081,18 +3424,18 @@ function VideoPlayer({
|
|
|
3081
3424
|
video.removeEventListener("leavepictureinpicture", onLeave);
|
|
3082
3425
|
};
|
|
3083
3426
|
}, [videoRef]);
|
|
3084
|
-
const scheduleHide =
|
|
3427
|
+
const scheduleHide = React7.useCallback(() => {
|
|
3085
3428
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3086
3429
|
hideTimerRef.current = setTimeout(() => {
|
|
3087
3430
|
setControlsVisible(false);
|
|
3088
3431
|
setOpenMenu(null);
|
|
3089
3432
|
}, CONTROLS_HIDE_MS);
|
|
3090
3433
|
}, []);
|
|
3091
|
-
const revealControls =
|
|
3434
|
+
const revealControls = React7.useCallback(() => {
|
|
3092
3435
|
setControlsVisible(true);
|
|
3093
3436
|
scheduleHide();
|
|
3094
3437
|
}, [scheduleHide]);
|
|
3095
|
-
|
|
3438
|
+
React7.useEffect(() => {
|
|
3096
3439
|
return () => {
|
|
3097
3440
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
3098
3441
|
};
|
|
@@ -3595,16 +3938,16 @@ function videoInPictureInPicture(container) {
|
|
|
3595
3938
|
return container.contains(pip);
|
|
3596
3939
|
}
|
|
3597
3940
|
function useFeedExclusivePlayback(playbackId) {
|
|
3598
|
-
const containerRef =
|
|
3599
|
-
const [forcePaused, setForcePaused] =
|
|
3600
|
-
const requestPause =
|
|
3941
|
+
const containerRef = React7.useRef(null);
|
|
3942
|
+
const [forcePaused, setForcePaused] = React7.useState(false);
|
|
3943
|
+
const requestPause = React7.useCallback(() => {
|
|
3601
3944
|
if (videoInPictureInPicture(containerRef.current)) return;
|
|
3602
3945
|
setForcePaused(true);
|
|
3603
3946
|
}, []);
|
|
3604
|
-
|
|
3947
|
+
React7.useEffect(() => {
|
|
3605
3948
|
return registerFeedPlayer(playbackId, requestPause);
|
|
3606
3949
|
}, [playbackId, requestPause]);
|
|
3607
|
-
|
|
3950
|
+
React7.useEffect(() => {
|
|
3608
3951
|
const node = containerRef.current;
|
|
3609
3952
|
if (!node || typeof IntersectionObserver === "undefined") return;
|
|
3610
3953
|
const observer = new IntersectionObserver(
|
|
@@ -3620,14 +3963,14 @@ function useFeedExclusivePlayback(playbackId) {
|
|
|
3620
3963
|
observer.observe(node);
|
|
3621
3964
|
return () => observer.disconnect();
|
|
3622
3965
|
}, [requestPause]);
|
|
3623
|
-
|
|
3966
|
+
React7.useEffect(() => {
|
|
3624
3967
|
const onVisibility = () => {
|
|
3625
3968
|
if (document.hidden) requestPause();
|
|
3626
3969
|
};
|
|
3627
3970
|
document.addEventListener("visibilitychange", onVisibility);
|
|
3628
3971
|
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
3629
3972
|
}, [requestPause]);
|
|
3630
|
-
const onPlayingChange =
|
|
3973
|
+
const onPlayingChange = React7.useCallback(
|
|
3631
3974
|
(playing) => {
|
|
3632
3975
|
if (!playing) return;
|
|
3633
3976
|
setForcePaused(false);
|
|
@@ -3654,7 +3997,7 @@ function FeedVideoPlayer({
|
|
|
3654
3997
|
paused: exclusivePaused,
|
|
3655
3998
|
onPlayingChange: onExclusivePlayingChange
|
|
3656
3999
|
} = useFeedExclusivePlayback(playbackId);
|
|
3657
|
-
const handlePlayingChange =
|
|
4000
|
+
const handlePlayingChange = React7.useCallback(
|
|
3658
4001
|
(playing) => {
|
|
3659
4002
|
onExclusivePlayingChange(playing);
|
|
3660
4003
|
onPlayingChange?.(playing);
|
|
@@ -3681,8 +4024,8 @@ function FeedVideoPlayer({
|
|
|
3681
4024
|
);
|
|
3682
4025
|
}
|
|
3683
4026
|
function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
|
|
3684
|
-
const [stats, setStats] =
|
|
3685
|
-
|
|
4027
|
+
const [stats, setStats] = React7.useState({});
|
|
4028
|
+
React7.useEffect(() => {
|
|
3686
4029
|
if (!statsUrl || !enabled) return;
|
|
3687
4030
|
let cancelled = false;
|
|
3688
4031
|
const controller = new AbortController();
|
|
@@ -3711,18 +4054,6 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
3711
4054
|
}, [statsUrl, intervalMs, enabled]);
|
|
3712
4055
|
return stats;
|
|
3713
4056
|
}
|
|
3714
|
-
function useMediaQuery2(query) {
|
|
3715
|
-
const [matches, setMatches] = useState(false);
|
|
3716
|
-
useEffect(() => {
|
|
3717
|
-
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
3718
|
-
const mql = window.matchMedia(query);
|
|
3719
|
-
const onChange = () => setMatches(mql.matches);
|
|
3720
|
-
onChange();
|
|
3721
|
-
mql.addEventListener("change", onChange);
|
|
3722
|
-
return () => mql.removeEventListener("change", onChange);
|
|
3723
|
-
}, [query]);
|
|
3724
|
-
return matches;
|
|
3725
|
-
}
|
|
3726
4057
|
|
|
3727
4058
|
// src/lib/avatar.ts
|
|
3728
4059
|
var EMPTY_COLORS = {
|
|
@@ -3805,6 +4136,6 @@ function avatarFallbackStyle(name) {
|
|
|
3805
4136
|
return getAvatarColors(name);
|
|
3806
4137
|
}
|
|
3807
4138
|
|
|
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 };
|
|
4139
|
+
export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, 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 };
|
|
3809
4140
|
//# sourceMappingURL=index.js.map
|
|
3810
4141
|
//# sourceMappingURL=index.js.map
|