@livo-tv/blocks 1.3.0 → 1.5.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 +840 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -4
- package/dist/index.d.ts +158 -4
- package/dist/index.js +830 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9,9 +9,9 @@ var classVarianceAuthority = require('class-variance-authority');
|
|
|
9
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
10
|
var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
|
|
11
11
|
var reactSlot = require('@radix-ui/react-slot');
|
|
12
|
+
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
12
13
|
var nextThemes = require('next-themes');
|
|
13
14
|
var framerMotion = require('framer-motion');
|
|
14
|
-
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
15
15
|
var SliderPrimitive = require('@radix-ui/react-slider');
|
|
16
16
|
var TogglePrimitive = require('@radix-ui/react-toggle');
|
|
17
17
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
@@ -443,6 +443,179 @@ function ConfirmDestructiveDialog({
|
|
|
443
443
|
] })
|
|
444
444
|
] }) });
|
|
445
445
|
}
|
|
446
|
+
var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
|
|
447
|
+
var miniMenuContentDefaults = {
|
|
448
|
+
sideOffset: 8,
|
|
449
|
+
collisionPadding: 12
|
|
450
|
+
};
|
|
451
|
+
function DropdownMenu({
|
|
452
|
+
...props
|
|
453
|
+
}) {
|
|
454
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
|
|
455
|
+
}
|
|
456
|
+
function DropdownMenuTrigger({
|
|
457
|
+
...props
|
|
458
|
+
}) {
|
|
459
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
460
|
+
DropdownMenuPrimitive__namespace.Trigger,
|
|
461
|
+
{
|
|
462
|
+
"data-slot": "dropdown-menu-trigger",
|
|
463
|
+
...props
|
|
464
|
+
}
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
function DropdownMenuContent({
|
|
468
|
+
className,
|
|
469
|
+
sideOffset = 4,
|
|
470
|
+
...props
|
|
471
|
+
}) {
|
|
472
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
473
|
+
DropdownMenuPrimitive__namespace.Content,
|
|
474
|
+
{
|
|
475
|
+
"data-slot": "dropdown-menu-content",
|
|
476
|
+
sideOffset,
|
|
477
|
+
className: cn(
|
|
478
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[200] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
|
479
|
+
className
|
|
480
|
+
),
|
|
481
|
+
...props
|
|
482
|
+
}
|
|
483
|
+
) });
|
|
484
|
+
}
|
|
485
|
+
function DropdownMenuItem({
|
|
486
|
+
className,
|
|
487
|
+
inset,
|
|
488
|
+
variant = "default",
|
|
489
|
+
...props
|
|
490
|
+
}) {
|
|
491
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
492
|
+
DropdownMenuPrimitive__namespace.Item,
|
|
493
|
+
{
|
|
494
|
+
"data-slot": "dropdown-menu-item",
|
|
495
|
+
"data-inset": inset,
|
|
496
|
+
"data-variant": variant,
|
|
497
|
+
className: cn(
|
|
498
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[highlighted]:[&_svg:not([class*='text-'])]:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:[&_svg:not([class*='text-'])]:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:data-[highlighted]:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 dark:data-[variant=destructive]:data-[highlighted]:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:data-[highlighted]:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
499
|
+
className
|
|
500
|
+
),
|
|
501
|
+
...props
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
var DEFAULT_NOTIFICATION_BELL_LABELS = {
|
|
506
|
+
title: "Notifications",
|
|
507
|
+
empty: "You're all caught up.",
|
|
508
|
+
viewAll: "View all"
|
|
509
|
+
};
|
|
510
|
+
function formatUnreadBadge(count) {
|
|
511
|
+
return count > 9 ? "9+" : String(count);
|
|
512
|
+
}
|
|
513
|
+
function defaultFormatTime(iso) {
|
|
514
|
+
const date = new Date(iso);
|
|
515
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
516
|
+
return date.toLocaleString(void 0, {
|
|
517
|
+
dateStyle: "short",
|
|
518
|
+
timeStyle: "short"
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function NotificationListSkeleton({ rows = 3 }) {
|
|
522
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col", "aria-hidden": "true", children: Array.from({ length: rows }, (_, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
523
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 px-4 py-3", children: [
|
|
524
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
"data-slot": "skeleton",
|
|
528
|
+
className: "bg-muted h-4 w-36 animate-pulse rounded-md motion-reduce:animate-none"
|
|
529
|
+
}
|
|
530
|
+
),
|
|
531
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
532
|
+
"div",
|
|
533
|
+
{
|
|
534
|
+
"data-slot": "skeleton",
|
|
535
|
+
className: "bg-muted h-3 w-full animate-pulse rounded-md motion-reduce:animate-none"
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
539
|
+
"div",
|
|
540
|
+
{
|
|
541
|
+
"data-slot": "skeleton",
|
|
542
|
+
className: "bg-muted h-3 w-20 animate-pulse rounded-md motion-reduce:animate-none"
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
] }),
|
|
546
|
+
index < rows - 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px" }) : null
|
|
547
|
+
] }, index)) });
|
|
548
|
+
}
|
|
549
|
+
function NotificationBell({
|
|
550
|
+
items,
|
|
551
|
+
unreadCount,
|
|
552
|
+
isLoading = false,
|
|
553
|
+
labels: labelOverrides,
|
|
554
|
+
viewAllHref,
|
|
555
|
+
formatTime: formatTime2 = defaultFormatTime,
|
|
556
|
+
onOpenChange,
|
|
557
|
+
align = "end",
|
|
558
|
+
className
|
|
559
|
+
}) {
|
|
560
|
+
const labels = { ...DEFAULT_NOTIFICATION_BELL_LABELS, ...labelOverrides };
|
|
561
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { modal: false, onOpenChange, children: [
|
|
562
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
563
|
+
Button,
|
|
564
|
+
{
|
|
565
|
+
type: "button",
|
|
566
|
+
variant: "ghost",
|
|
567
|
+
size: "icon",
|
|
568
|
+
className: cn("relative size-9", className),
|
|
569
|
+
"aria-label": labels.title,
|
|
570
|
+
children: [
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bell, { className: "size-4" }),
|
|
572
|
+
unreadCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-destructive text-destructive-foreground absolute -top-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full text-[10px] leading-none font-medium tabular-nums", children: formatUnreadBadge(unreadCount) }) : null
|
|
573
|
+
]
|
|
574
|
+
}
|
|
575
|
+
) }),
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align, className: "w-80 p-0", children: [
|
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold", children: labels.title }) }),
|
|
578
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-80 overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(NotificationListSkeleton, {}) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-4 py-8 text-center text-sm", children: labels.empty }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col", children: items.map((item, index) => {
|
|
579
|
+
const body = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-1", children: [
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm leading-none font-medium", children: item.title }),
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground line-clamp-2 text-xs", children: item.message }),
|
|
582
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground/70 text-xs", children: formatTime2(item.createdAt) })
|
|
583
|
+
] });
|
|
584
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
585
|
+
item.href ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
586
|
+
"a",
|
|
587
|
+
{
|
|
588
|
+
href: item.href,
|
|
589
|
+
className: cn(
|
|
590
|
+
"hover:bg-muted/50 flex gap-3 px-4 py-3 motion-safe:transition-colors",
|
|
591
|
+
!item.read && "bg-muted/30"
|
|
592
|
+
),
|
|
593
|
+
children: body
|
|
594
|
+
}
|
|
595
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
596
|
+
"div",
|
|
597
|
+
{
|
|
598
|
+
className: cn(
|
|
599
|
+
"flex gap-3 px-4 py-3",
|
|
600
|
+
!item.read && "bg-muted/30"
|
|
601
|
+
),
|
|
602
|
+
children: body
|
|
603
|
+
}
|
|
604
|
+
),
|
|
605
|
+
index < items.length - 1 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-border h-px" }) : null
|
|
606
|
+
] }, item.id);
|
|
607
|
+
}) }) }),
|
|
608
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
609
|
+
"a",
|
|
610
|
+
{
|
|
611
|
+
href: viewAllHref,
|
|
612
|
+
className: "text-primary block text-center text-sm font-medium hover:underline",
|
|
613
|
+
children: labels.viewAll
|
|
614
|
+
}
|
|
615
|
+
) })
|
|
616
|
+
] })
|
|
617
|
+
] });
|
|
618
|
+
}
|
|
446
619
|
|
|
447
620
|
// src/components/editable/types.ts
|
|
448
621
|
var DEFAULT_EDITABLE_SECTION_LABELS = {
|
|
@@ -824,65 +997,6 @@ function SafeImage({
|
|
|
824
997
|
}
|
|
825
998
|
);
|
|
826
999
|
}
|
|
827
|
-
var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
|
|
828
|
-
var miniMenuContentDefaults = {
|
|
829
|
-
sideOffset: 8,
|
|
830
|
-
collisionPadding: 12
|
|
831
|
-
};
|
|
832
|
-
function DropdownMenu({
|
|
833
|
-
...props
|
|
834
|
-
}) {
|
|
835
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
|
|
836
|
-
}
|
|
837
|
-
function DropdownMenuTrigger({
|
|
838
|
-
...props
|
|
839
|
-
}) {
|
|
840
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
841
|
-
DropdownMenuPrimitive__namespace.Trigger,
|
|
842
|
-
{
|
|
843
|
-
"data-slot": "dropdown-menu-trigger",
|
|
844
|
-
...props
|
|
845
|
-
}
|
|
846
|
-
);
|
|
847
|
-
}
|
|
848
|
-
function DropdownMenuContent({
|
|
849
|
-
className,
|
|
850
|
-
sideOffset = 4,
|
|
851
|
-
...props
|
|
852
|
-
}) {
|
|
853
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
854
|
-
DropdownMenuPrimitive__namespace.Content,
|
|
855
|
-
{
|
|
856
|
-
"data-slot": "dropdown-menu-content",
|
|
857
|
-
sideOffset,
|
|
858
|
-
className: cn(
|
|
859
|
-
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[200] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
|
860
|
-
className
|
|
861
|
-
),
|
|
862
|
-
...props
|
|
863
|
-
}
|
|
864
|
-
) });
|
|
865
|
-
}
|
|
866
|
-
function DropdownMenuItem({
|
|
867
|
-
className,
|
|
868
|
-
inset,
|
|
869
|
-
variant = "default",
|
|
870
|
-
...props
|
|
871
|
-
}) {
|
|
872
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
873
|
-
DropdownMenuPrimitive__namespace.Item,
|
|
874
|
-
{
|
|
875
|
-
"data-slot": "dropdown-menu-item",
|
|
876
|
-
"data-inset": inset,
|
|
877
|
-
"data-variant": variant,
|
|
878
|
-
className: cn(
|
|
879
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[highlighted]:[&_svg:not([class*='text-'])]:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:[&_svg:not([class*='text-'])]:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:data-[highlighted]:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 dark:data-[variant=destructive]:data-[highlighted]:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:data-[highlighted]:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
880
|
-
className
|
|
881
|
-
),
|
|
882
|
-
...props
|
|
883
|
-
}
|
|
884
|
-
);
|
|
885
|
-
}
|
|
886
1000
|
var defaultLabels = {
|
|
887
1001
|
theme: "Theme",
|
|
888
1002
|
system: "System",
|
|
@@ -2258,6 +2372,37 @@ function AvatarEditorDialog({
|
|
|
2258
2372
|
] }) })
|
|
2259
2373
|
] });
|
|
2260
2374
|
}
|
|
2375
|
+
var DEFAULT_LABELS2 = {
|
|
2376
|
+
play: "Play",
|
|
2377
|
+
tapToUnmute: "Tap to unmute",
|
|
2378
|
+
mute: "Mute",
|
|
2379
|
+
unmute: "Unmute"
|
|
2380
|
+
};
|
|
2381
|
+
var CURTAIN_VIDEO_STYLE = `
|
|
2382
|
+
.livo-curtain-video::-webkit-media-controls-start-playback-button {
|
|
2383
|
+
display: none !important;
|
|
2384
|
+
-webkit-appearance: none;
|
|
2385
|
+
}
|
|
2386
|
+
.livo-curtain-video::-webkit-media-controls {
|
|
2387
|
+
display: none !important;
|
|
2388
|
+
}
|
|
2389
|
+
`;
|
|
2390
|
+
function isAudioTrackList(value) {
|
|
2391
|
+
return typeof value === "object" && value !== null && typeof value.getTrackById === "function";
|
|
2392
|
+
}
|
|
2393
|
+
function probeVideoAudio(el) {
|
|
2394
|
+
const video = el;
|
|
2395
|
+
if (typeof video.mozHasAudio === "boolean") {
|
|
2396
|
+
return video.mozHasAudio ? "yes" : "no";
|
|
2397
|
+
}
|
|
2398
|
+
if (typeof video.webkitAudioDecodedByteCount === "number" && video.webkitAudioDecodedByteCount > 0) {
|
|
2399
|
+
return "yes";
|
|
2400
|
+
}
|
|
2401
|
+
if (isAudioTrackList(video.audioTracks)) {
|
|
2402
|
+
return video.audioTracks.length > 0 ? "yes" : "no";
|
|
2403
|
+
}
|
|
2404
|
+
return "unknown";
|
|
2405
|
+
}
|
|
2261
2406
|
function usePrefersReducedMotion() {
|
|
2262
2407
|
const [reduced, setReduced] = React7__namespace.useState(false);
|
|
2263
2408
|
React7__namespace.useEffect(() => {
|
|
@@ -2269,39 +2414,154 @@ function usePrefersReducedMotion() {
|
|
|
2269
2414
|
}, []);
|
|
2270
2415
|
return reduced;
|
|
2271
2416
|
}
|
|
2272
|
-
function
|
|
2273
|
-
kind,
|
|
2417
|
+
function CurtainVideo({
|
|
2274
2418
|
url,
|
|
2275
|
-
alt
|
|
2419
|
+
alt,
|
|
2276
2420
|
className,
|
|
2277
|
-
|
|
2421
|
+
freeze,
|
|
2422
|
+
allowSound,
|
|
2423
|
+
labels
|
|
2278
2424
|
}) {
|
|
2279
|
-
const
|
|
2280
|
-
const
|
|
2281
|
-
|
|
2282
|
-
|
|
2425
|
+
const videoRef = React7__namespace.useRef(null);
|
|
2426
|
+
const [playback, setPlayback] = React7__namespace.useState("pending");
|
|
2427
|
+
const [muted, setMuted] = React7__namespace.useState(true);
|
|
2428
|
+
const [audio, setAudio] = React7__namespace.useState("unknown");
|
|
2429
|
+
React7__namespace.useEffect(() => {
|
|
2430
|
+
const el = videoRef.current;
|
|
2431
|
+
if (!el) return;
|
|
2432
|
+
el.setAttribute("webkit-playsinline", "");
|
|
2433
|
+
el.muted = true;
|
|
2434
|
+
setMuted(true);
|
|
2435
|
+
setAudio("unknown");
|
|
2436
|
+
setPlayback("pending");
|
|
2437
|
+
if (freeze) {
|
|
2438
|
+
el.pause();
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
let cancelled = false;
|
|
2442
|
+
const applyAudio = () => {
|
|
2443
|
+
const next = probeVideoAudio(el);
|
|
2444
|
+
if (next !== "unknown") setAudio(next);
|
|
2445
|
+
};
|
|
2446
|
+
const tryPlay = () => {
|
|
2447
|
+
if (cancelled) return;
|
|
2448
|
+
void el.play().then(
|
|
2449
|
+
() => {
|
|
2450
|
+
if (cancelled) return;
|
|
2451
|
+
setPlayback("playing");
|
|
2452
|
+
applyAudio();
|
|
2453
|
+
},
|
|
2454
|
+
() => {
|
|
2455
|
+
if (!cancelled && el.paused) setPlayback("blocked");
|
|
2456
|
+
}
|
|
2457
|
+
);
|
|
2458
|
+
};
|
|
2459
|
+
tryPlay();
|
|
2460
|
+
el.addEventListener("canplay", tryPlay);
|
|
2461
|
+
el.addEventListener("timeupdate", applyAudio);
|
|
2462
|
+
el.addEventListener("loadedmetadata", applyAudio);
|
|
2463
|
+
return () => {
|
|
2464
|
+
cancelled = true;
|
|
2465
|
+
el.removeEventListener("canplay", tryPlay);
|
|
2466
|
+
el.removeEventListener("timeupdate", applyAudio);
|
|
2467
|
+
el.removeEventListener("loadedmetadata", applyAudio);
|
|
2468
|
+
};
|
|
2469
|
+
}, [url, freeze]);
|
|
2470
|
+
const startPlayback = React7__namespace.useCallback(() => {
|
|
2471
|
+
const el = videoRef.current;
|
|
2472
|
+
if (!el) return;
|
|
2473
|
+
el.muted = true;
|
|
2474
|
+
setMuted(true);
|
|
2475
|
+
void el.play().then(
|
|
2476
|
+
() => {
|
|
2477
|
+
setPlayback("playing");
|
|
2478
|
+
const next = probeVideoAudio(el);
|
|
2479
|
+
if (next !== "unknown") setAudio(next);
|
|
2480
|
+
},
|
|
2481
|
+
() => {
|
|
2482
|
+
if (el.paused) setPlayback("blocked");
|
|
2483
|
+
}
|
|
2484
|
+
);
|
|
2485
|
+
}, []);
|
|
2486
|
+
const setVideoMuted = React7__namespace.useCallback((next) => {
|
|
2487
|
+
const el = videoRef.current;
|
|
2488
|
+
if (el) el.muted = next;
|
|
2489
|
+
setMuted(next);
|
|
2490
|
+
}, []);
|
|
2491
|
+
const showUnmute = allowSound && !freeze && playback === "playing" && muted && audio !== "no";
|
|
2492
|
+
const showMute = allowSound && !freeze && playback === "playing" && !muted;
|
|
2493
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative h-full w-full", className), children: [
|
|
2494
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: CURTAIN_VIDEO_STYLE }),
|
|
2495
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2283
2496
|
"video",
|
|
2284
2497
|
{
|
|
2498
|
+
ref: videoRef,
|
|
2285
2499
|
src: url,
|
|
2286
|
-
className:
|
|
2287
|
-
autoPlay:
|
|
2288
|
-
muted
|
|
2289
|
-
loop:
|
|
2500
|
+
className: "livo-curtain-video h-full w-full object-cover",
|
|
2501
|
+
autoPlay: !freeze,
|
|
2502
|
+
muted,
|
|
2503
|
+
loop: !freeze,
|
|
2290
2504
|
playsInline: true,
|
|
2505
|
+
preload: freeze ? "metadata" : void 0,
|
|
2291
2506
|
"aria-hidden": alt ? void 0 : true
|
|
2292
2507
|
}
|
|
2293
|
-
)
|
|
2294
|
-
|
|
2295
|
-
|
|
2508
|
+
),
|
|
2509
|
+
playback === "blocked" && !freeze ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2510
|
+
"button",
|
|
2511
|
+
{
|
|
2512
|
+
type: "button",
|
|
2513
|
+
"aria-label": labels.play,
|
|
2514
|
+
onClick: startPlayback,
|
|
2515
|
+
className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
|
|
2516
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
|
|
2517
|
+
}
|
|
2518
|
+
) }) : null,
|
|
2519
|
+
showUnmute ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2520
|
+
"button",
|
|
2521
|
+
{
|
|
2522
|
+
type: "button",
|
|
2523
|
+
onClick: () => setVideoMuted(false),
|
|
2524
|
+
className: "absolute top-3 right-3 z-20 flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur-sm transition hover:bg-black/90",
|
|
2525
|
+
children: [
|
|
2526
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { className: "size-4" }),
|
|
2527
|
+
labels.tapToUnmute
|
|
2528
|
+
]
|
|
2529
|
+
}
|
|
2530
|
+
) : null,
|
|
2531
|
+
showMute ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2532
|
+
"button",
|
|
2533
|
+
{
|
|
2534
|
+
type: "button",
|
|
2535
|
+
"aria-label": labels.mute,
|
|
2536
|
+
onClick: () => setVideoMuted(true),
|
|
2537
|
+
className: "absolute top-3 right-3 z-20 flex items-center gap-1.5 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur-sm transition hover:bg-black/90",
|
|
2538
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "size-4" })
|
|
2539
|
+
}
|
|
2540
|
+
) : null
|
|
2541
|
+
] });
|
|
2542
|
+
}
|
|
2543
|
+
function CurtainStage({
|
|
2544
|
+
kind,
|
|
2545
|
+
url,
|
|
2546
|
+
alt = "",
|
|
2547
|
+
className,
|
|
2548
|
+
reducedMotion,
|
|
2549
|
+
allowSound = false,
|
|
2550
|
+
labels
|
|
2551
|
+
}) {
|
|
2552
|
+
const prefersReduced = usePrefersReducedMotion();
|
|
2553
|
+
const freeze = reducedMotion ?? prefersReduced;
|
|
2554
|
+
const copy = { ...DEFAULT_LABELS2, ...labels };
|
|
2555
|
+
if (kind === "video") {
|
|
2296
2556
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2297
|
-
|
|
2557
|
+
CurtainVideo,
|
|
2298
2558
|
{
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2559
|
+
url,
|
|
2560
|
+
alt,
|
|
2561
|
+
className,
|
|
2562
|
+
freeze,
|
|
2563
|
+
allowSound,
|
|
2564
|
+
labels: copy
|
|
2305
2565
|
}
|
|
2306
2566
|
);
|
|
2307
2567
|
}
|
|
@@ -2869,6 +3129,7 @@ function WaitingRoom({
|
|
|
2869
3129
|
{
|
|
2870
3130
|
kind: curtain.kind,
|
|
2871
3131
|
url: curtain.url,
|
|
3132
|
+
allowSound: true,
|
|
2872
3133
|
className: "absolute inset-0"
|
|
2873
3134
|
}
|
|
2874
3135
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
@@ -3425,7 +3686,7 @@ function useHlsPlayback({
|
|
|
3425
3686
|
retry
|
|
3426
3687
|
};
|
|
3427
3688
|
}
|
|
3428
|
-
var
|
|
3689
|
+
var DEFAULT_LABELS3 = {
|
|
3429
3690
|
play: "Play",
|
|
3430
3691
|
pause: "Pause",
|
|
3431
3692
|
mute: "Mute",
|
|
@@ -3493,7 +3754,7 @@ function VideoPlayer({
|
|
|
3493
3754
|
fit = "aspect-video",
|
|
3494
3755
|
className
|
|
3495
3756
|
}) {
|
|
3496
|
-
const t = { ...
|
|
3757
|
+
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
3497
3758
|
const containerRef = React7__namespace.useRef(null);
|
|
3498
3759
|
const firstPlayFiredRef = React7__namespace.useRef(false);
|
|
3499
3760
|
const [userStarted, setUserStarted] = React7__namespace.useState(false);
|
|
@@ -4248,6 +4509,489 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4248
4509
|
return stats;
|
|
4249
4510
|
}
|
|
4250
4511
|
|
|
4512
|
+
// src/components/upload/part-math.ts
|
|
4513
|
+
function partRanges(fileSize, partSize) {
|
|
4514
|
+
if (partSize <= 0) {
|
|
4515
|
+
throw new Error("partSize must be greater than 0");
|
|
4516
|
+
}
|
|
4517
|
+
if (fileSize <= 0) {
|
|
4518
|
+
return [{ partNumber: 1, start: 0, end: 0 }];
|
|
4519
|
+
}
|
|
4520
|
+
const count = Math.ceil(fileSize / partSize);
|
|
4521
|
+
return Array.from({ length: count }, (_, index) => {
|
|
4522
|
+
const start = index * partSize;
|
|
4523
|
+
return {
|
|
4524
|
+
partNumber: index + 1,
|
|
4525
|
+
start,
|
|
4526
|
+
end: Math.min(fileSize, start + partSize)
|
|
4527
|
+
};
|
|
4528
|
+
});
|
|
4529
|
+
}
|
|
4530
|
+
function progressFromBytes(loaded, total) {
|
|
4531
|
+
const safeTotal = Math.max(0, total);
|
|
4532
|
+
const safeLoaded = Math.min(Math.max(0, loaded), safeTotal);
|
|
4533
|
+
const percent = safeTotal > 0 ? Math.round(safeLoaded / safeTotal * 100) : 0;
|
|
4534
|
+
return { loaded: safeLoaded, total: safeTotal, percent };
|
|
4535
|
+
}
|
|
4536
|
+
function fileMatchesAccept(file, accept) {
|
|
4537
|
+
if (!accept?.trim()) return true;
|
|
4538
|
+
const type = file.type.toLowerCase();
|
|
4539
|
+
const name = file.name.toLowerCase();
|
|
4540
|
+
return accept.split(",").some((token) => {
|
|
4541
|
+
const trimmed = token.trim().toLowerCase();
|
|
4542
|
+
if (!trimmed) return false;
|
|
4543
|
+
if (trimmed.endsWith("/*")) {
|
|
4544
|
+
return type.startsWith(trimmed.slice(0, -1));
|
|
4545
|
+
}
|
|
4546
|
+
if (trimmed.startsWith(".")) {
|
|
4547
|
+
return name.endsWith(trimmed);
|
|
4548
|
+
}
|
|
4549
|
+
return type === trimmed;
|
|
4550
|
+
});
|
|
4551
|
+
}
|
|
4552
|
+
|
|
4553
|
+
// src/components/upload/types.ts
|
|
4554
|
+
var DEFAULT_FILE_DROPZONE_LABELS = {
|
|
4555
|
+
idle: "Drop a file here or browse",
|
|
4556
|
+
hint: "Click or press Enter to choose a file",
|
|
4557
|
+
browse: "Browse",
|
|
4558
|
+
rejectType: "This file type is not allowed",
|
|
4559
|
+
rejectSize: "This file is too large"
|
|
4560
|
+
};
|
|
4561
|
+
var DEFAULT_FILE_UPLOAD_TRAY_LABELS = {
|
|
4562
|
+
title: "Uploads",
|
|
4563
|
+
pause: "Pause",
|
|
4564
|
+
resume: "Resume",
|
|
4565
|
+
cancel: "Cancel",
|
|
4566
|
+
uploading: "Uploading",
|
|
4567
|
+
paused: "Paused",
|
|
4568
|
+
completing: "Finishing",
|
|
4569
|
+
completed: "Uploaded",
|
|
4570
|
+
cancelled: "Cancelled",
|
|
4571
|
+
error: "Failed"
|
|
4572
|
+
};
|
|
4573
|
+
var DEFAULT_FILE_UPLOAD_LABELS = {
|
|
4574
|
+
dropzone: DEFAULT_FILE_DROPZONE_LABELS,
|
|
4575
|
+
tray: DEFAULT_FILE_UPLOAD_TRAY_LABELS
|
|
4576
|
+
};
|
|
4577
|
+
function FileDropzone({
|
|
4578
|
+
accept,
|
|
4579
|
+
maxSize,
|
|
4580
|
+
disabled = false,
|
|
4581
|
+
labels: labelOverrides,
|
|
4582
|
+
onFile,
|
|
4583
|
+
onReject,
|
|
4584
|
+
className
|
|
4585
|
+
}) {
|
|
4586
|
+
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
4587
|
+
const inputId = React7.useId();
|
|
4588
|
+
const inputRef = React7.useRef(null);
|
|
4589
|
+
const [dragging, setDragging] = React7.useState(false);
|
|
4590
|
+
const [message, setMessage] = React7.useState(null);
|
|
4591
|
+
function takeFile(file) {
|
|
4592
|
+
if (!file || disabled) return;
|
|
4593
|
+
if (!fileMatchesAccept(file, accept)) {
|
|
4594
|
+
setMessage(labels.rejectType);
|
|
4595
|
+
onReject?.("type");
|
|
4596
|
+
return;
|
|
4597
|
+
}
|
|
4598
|
+
if (maxSize != null && file.size > maxSize) {
|
|
4599
|
+
setMessage(labels.rejectSize);
|
|
4600
|
+
onReject?.("size");
|
|
4601
|
+
return;
|
|
4602
|
+
}
|
|
4603
|
+
setMessage(null);
|
|
4604
|
+
onFile(file);
|
|
4605
|
+
}
|
|
4606
|
+
function onDrop(event) {
|
|
4607
|
+
event.preventDefault();
|
|
4608
|
+
setDragging(false);
|
|
4609
|
+
takeFile(event.dataTransfer.files[0]);
|
|
4610
|
+
}
|
|
4611
|
+
function onKeyDown(event) {
|
|
4612
|
+
if (disabled) return;
|
|
4613
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
4614
|
+
event.preventDefault();
|
|
4615
|
+
inputRef.current?.click();
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4618
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid gap-2", className), children: [
|
|
4619
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4620
|
+
"div",
|
|
4621
|
+
{
|
|
4622
|
+
role: "button",
|
|
4623
|
+
tabIndex: disabled ? -1 : 0,
|
|
4624
|
+
"aria-disabled": disabled,
|
|
4625
|
+
"aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
|
|
4626
|
+
"aria-controls": inputId,
|
|
4627
|
+
"data-dragging": dragging || void 0,
|
|
4628
|
+
className: cn(
|
|
4629
|
+
"border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 rounded-lg border border-dashed px-4 py-8 text-center outline-none focus-visible:ring-[3px]",
|
|
4630
|
+
dragging && "border-primary bg-primary/5",
|
|
4631
|
+
disabled && "pointer-events-none opacity-50"
|
|
4632
|
+
),
|
|
4633
|
+
onClick: () => {
|
|
4634
|
+
if (!disabled) inputRef.current?.click();
|
|
4635
|
+
},
|
|
4636
|
+
onKeyDown,
|
|
4637
|
+
onDragEnter: (event) => {
|
|
4638
|
+
event.preventDefault();
|
|
4639
|
+
if (!disabled) setDragging(true);
|
|
4640
|
+
},
|
|
4641
|
+
onDragOver: (event) => {
|
|
4642
|
+
event.preventDefault();
|
|
4643
|
+
},
|
|
4644
|
+
onDragLeave: (event) => {
|
|
4645
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
4646
|
+
return;
|
|
4647
|
+
}
|
|
4648
|
+
setDragging(false);
|
|
4649
|
+
},
|
|
4650
|
+
onDrop,
|
|
4651
|
+
children: [
|
|
4652
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: labels.idle }),
|
|
4653
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4654
|
+
"p",
|
|
4655
|
+
{
|
|
4656
|
+
id: `${inputId}-hint`,
|
|
4657
|
+
className: "text-muted-foreground mt-1 text-xs",
|
|
4658
|
+
children: labels.hint
|
|
4659
|
+
}
|
|
4660
|
+
),
|
|
4661
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
|
|
4662
|
+
]
|
|
4663
|
+
}
|
|
4664
|
+
),
|
|
4665
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4666
|
+
"input",
|
|
4667
|
+
{
|
|
4668
|
+
id: inputId,
|
|
4669
|
+
ref: inputRef,
|
|
4670
|
+
type: "file",
|
|
4671
|
+
accept,
|
|
4672
|
+
disabled,
|
|
4673
|
+
"aria-label": labels.browse,
|
|
4674
|
+
className: "sr-only",
|
|
4675
|
+
onChange: (event) => {
|
|
4676
|
+
takeFile(event.target.files?.[0]);
|
|
4677
|
+
event.target.value = "";
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
),
|
|
4681
|
+
message ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4682
|
+
"p",
|
|
4683
|
+
{
|
|
4684
|
+
id: `${inputId}-message`,
|
|
4685
|
+
role: "alert",
|
|
4686
|
+
className: "text-destructive text-sm",
|
|
4687
|
+
children: message
|
|
4688
|
+
}
|
|
4689
|
+
) : null
|
|
4690
|
+
] });
|
|
4691
|
+
}
|
|
4692
|
+
function statusLabel(status, labels) {
|
|
4693
|
+
switch (status) {
|
|
4694
|
+
case "uploading":
|
|
4695
|
+
return labels.uploading;
|
|
4696
|
+
case "paused":
|
|
4697
|
+
return labels.paused;
|
|
4698
|
+
case "completing":
|
|
4699
|
+
return labels.completing;
|
|
4700
|
+
case "completed":
|
|
4701
|
+
return labels.completed;
|
|
4702
|
+
case "cancelled":
|
|
4703
|
+
return labels.cancelled;
|
|
4704
|
+
case "error":
|
|
4705
|
+
return labels.error;
|
|
4706
|
+
default: {
|
|
4707
|
+
const _exhaustive = status;
|
|
4708
|
+
return _exhaustive;
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
function FileUploadTray({
|
|
4713
|
+
jobs,
|
|
4714
|
+
labels: labelOverrides,
|
|
4715
|
+
onPause,
|
|
4716
|
+
onResume,
|
|
4717
|
+
onCancel,
|
|
4718
|
+
className
|
|
4719
|
+
}) {
|
|
4720
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4721
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4722
|
+
if (visible.length === 0) return null;
|
|
4723
|
+
return /* @__PURE__ */ jsxRuntime.jsx("section", { "aria-label": labels.title, className: cn("grid gap-3", className), children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid gap-3", children: visible.map((job) => {
|
|
4724
|
+
const active = job.status === "uploading" || job.status === "completing";
|
|
4725
|
+
const canPause = job.status === "uploading";
|
|
4726
|
+
const canResume = job.status === "paused";
|
|
4727
|
+
const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
|
|
4728
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "grid gap-1.5", children: [
|
|
4729
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4730
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: job.name }),
|
|
4731
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: statusLabel(job.status, labels) }),
|
|
4732
|
+
canPause ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4733
|
+
Button,
|
|
4734
|
+
{
|
|
4735
|
+
type: "button",
|
|
4736
|
+
variant: "ghost",
|
|
4737
|
+
size: "icon-sm",
|
|
4738
|
+
"aria-label": `${labels.pause} ${job.name}`,
|
|
4739
|
+
onClick: () => onPause(job.id),
|
|
4740
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, {})
|
|
4741
|
+
}
|
|
4742
|
+
) : null,
|
|
4743
|
+
canResume ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4744
|
+
Button,
|
|
4745
|
+
{
|
|
4746
|
+
type: "button",
|
|
4747
|
+
variant: "ghost",
|
|
4748
|
+
size: "icon-sm",
|
|
4749
|
+
"aria-label": `${labels.resume} ${job.name}`,
|
|
4750
|
+
onClick: () => onResume(job.id),
|
|
4751
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, {})
|
|
4752
|
+
}
|
|
4753
|
+
) : null,
|
|
4754
|
+
canCancel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4755
|
+
Button,
|
|
4756
|
+
{
|
|
4757
|
+
type: "button",
|
|
4758
|
+
variant: "ghost",
|
|
4759
|
+
size: "icon-sm",
|
|
4760
|
+
"aria-label": `${labels.cancel} ${job.name}`,
|
|
4761
|
+
onClick: () => onCancel(job.id),
|
|
4762
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
4763
|
+
}
|
|
4764
|
+
) : null
|
|
4765
|
+
] }),
|
|
4766
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4767
|
+
"div",
|
|
4768
|
+
{
|
|
4769
|
+
role: "progressbar",
|
|
4770
|
+
"aria-valuemin": 0,
|
|
4771
|
+
"aria-valuemax": 100,
|
|
4772
|
+
"aria-valuenow": job.percent,
|
|
4773
|
+
"aria-label": job.name,
|
|
4774
|
+
className: "bg-muted h-2 overflow-hidden rounded-full",
|
|
4775
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4776
|
+
"div",
|
|
4777
|
+
{
|
|
4778
|
+
className: cn(
|
|
4779
|
+
"bg-primary h-full",
|
|
4780
|
+
active && "motion-safe:transition-[width]"
|
|
4781
|
+
),
|
|
4782
|
+
style: { width: `${job.percent}%` }
|
|
4783
|
+
}
|
|
4784
|
+
)
|
|
4785
|
+
}
|
|
4786
|
+
),
|
|
4787
|
+
job.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
|
|
4788
|
+
] }, job.id);
|
|
4789
|
+
}) }) });
|
|
4790
|
+
}
|
|
4791
|
+
function formatActiveBadge(count) {
|
|
4792
|
+
return count > 9 ? "9+" : String(count);
|
|
4793
|
+
}
|
|
4794
|
+
function isActiveStatus(status) {
|
|
4795
|
+
return status === "uploading" || status === "paused" || status === "completing";
|
|
4796
|
+
}
|
|
4797
|
+
function FileUploadMenu({
|
|
4798
|
+
jobs,
|
|
4799
|
+
labels: labelOverrides,
|
|
4800
|
+
onPause,
|
|
4801
|
+
onResume,
|
|
4802
|
+
onCancel,
|
|
4803
|
+
open,
|
|
4804
|
+
onOpenChange,
|
|
4805
|
+
align = "end",
|
|
4806
|
+
className
|
|
4807
|
+
}) {
|
|
4808
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4809
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4810
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React7.useState(false);
|
|
4811
|
+
const isControlled = open !== void 0;
|
|
4812
|
+
const resolvedOpen = isControlled ? open : uncontrolledOpen;
|
|
4813
|
+
function setResolvedOpen(next) {
|
|
4814
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
4815
|
+
onOpenChange?.(next);
|
|
4816
|
+
}
|
|
4817
|
+
if (visible.length === 0) return null;
|
|
4818
|
+
const activeCount = visible.filter(
|
|
4819
|
+
(job) => isActiveStatus(job.status)
|
|
4820
|
+
).length;
|
|
4821
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4822
|
+
DropdownMenu,
|
|
4823
|
+
{
|
|
4824
|
+
modal: false,
|
|
4825
|
+
open: resolvedOpen,
|
|
4826
|
+
onOpenChange: setResolvedOpen,
|
|
4827
|
+
children: [
|
|
4828
|
+
/* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4829
|
+
Button,
|
|
4830
|
+
{
|
|
4831
|
+
type: "button",
|
|
4832
|
+
variant: "ghost",
|
|
4833
|
+
size: "icon",
|
|
4834
|
+
className: cn("relative size-9", className),
|
|
4835
|
+
"aria-label": labels.title,
|
|
4836
|
+
children: [
|
|
4837
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "size-4" }),
|
|
4838
|
+
activeCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-destructive text-destructive-foreground absolute -top-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full text-[10px] leading-none font-medium tabular-nums", children: formatActiveBadge(activeCount) }) : null
|
|
4839
|
+
]
|
|
4840
|
+
}
|
|
4841
|
+
) }),
|
|
4842
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuContent, { align, className: "w-80 p-0", children: [
|
|
4843
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold", children: labels.title }) }),
|
|
4844
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-80 overflow-y-auto p-3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4845
|
+
FileUploadTray,
|
|
4846
|
+
{
|
|
4847
|
+
jobs: visible,
|
|
4848
|
+
labels,
|
|
4849
|
+
onPause,
|
|
4850
|
+
onResume,
|
|
4851
|
+
onCancel
|
|
4852
|
+
}
|
|
4853
|
+
) })
|
|
4854
|
+
] })
|
|
4855
|
+
]
|
|
4856
|
+
}
|
|
4857
|
+
);
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
// src/components/upload/createMultipartUploadController.ts
|
|
4861
|
+
function readEtag(xhr) {
|
|
4862
|
+
const raw = xhr.getResponseHeader("ETag") ?? xhr.getResponseHeader("etag") ?? "";
|
|
4863
|
+
const etag = raw.trim();
|
|
4864
|
+
if (!etag) {
|
|
4865
|
+
throw new Error("Upload part missing ETag");
|
|
4866
|
+
}
|
|
4867
|
+
return etag;
|
|
4868
|
+
}
|
|
4869
|
+
function putPart(input) {
|
|
4870
|
+
return new Promise((resolve, reject) => {
|
|
4871
|
+
input.xhr.open("PUT", input.url);
|
|
4872
|
+
input.xhr.upload.onprogress = (event) => {
|
|
4873
|
+
input.onProgress(event.loaded);
|
|
4874
|
+
};
|
|
4875
|
+
input.xhr.onload = () => {
|
|
4876
|
+
if (input.xhr.status >= 200 && input.xhr.status < 300) {
|
|
4877
|
+
try {
|
|
4878
|
+
resolve(readEtag(input.xhr));
|
|
4879
|
+
} catch (error) {
|
|
4880
|
+
reject(error);
|
|
4881
|
+
}
|
|
4882
|
+
return;
|
|
4883
|
+
}
|
|
4884
|
+
reject(new Error(`Upload failed (${input.xhr.status})`));
|
|
4885
|
+
};
|
|
4886
|
+
input.xhr.onerror = () => {
|
|
4887
|
+
reject(new Error("Upload failed"));
|
|
4888
|
+
};
|
|
4889
|
+
input.xhr.onabort = () => {
|
|
4890
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
4891
|
+
};
|
|
4892
|
+
input.xhr.send(input.body);
|
|
4893
|
+
});
|
|
4894
|
+
}
|
|
4895
|
+
function createMultipartUploadController(options) {
|
|
4896
|
+
const ranges = partRanges(options.file.size, options.partSize);
|
|
4897
|
+
const completed = [];
|
|
4898
|
+
const state = { status: "idle" };
|
|
4899
|
+
let currentXhr = null;
|
|
4900
|
+
let run = null;
|
|
4901
|
+
let resumeIndex = 0;
|
|
4902
|
+
function currentStatus() {
|
|
4903
|
+
return state.status;
|
|
4904
|
+
}
|
|
4905
|
+
function isStopped() {
|
|
4906
|
+
const status = currentStatus();
|
|
4907
|
+
return status === "paused" || status === "cancelled";
|
|
4908
|
+
}
|
|
4909
|
+
function emitProgress(currentPartLoaded = 0) {
|
|
4910
|
+
const completedBytes = completed.reduce((sum, part) => {
|
|
4911
|
+
const range = ranges[part.partNumber - 1];
|
|
4912
|
+
return sum + (range ? range.end - range.start : 0);
|
|
4913
|
+
}, 0);
|
|
4914
|
+
options.onProgress?.(
|
|
4915
|
+
progressFromBytes(completedBytes + currentPartLoaded, options.file.size)
|
|
4916
|
+
);
|
|
4917
|
+
}
|
|
4918
|
+
async function uploadFrom(startIndex) {
|
|
4919
|
+
state.status = "uploading";
|
|
4920
|
+
for (let index = startIndex; index < ranges.length; index += 1) {
|
|
4921
|
+
if (state.status !== "uploading") return;
|
|
4922
|
+
resumeIndex = index;
|
|
4923
|
+
const range = ranges[index];
|
|
4924
|
+
if (!range) continue;
|
|
4925
|
+
const url = await options.adapter.requestPartUrl(range.partNumber);
|
|
4926
|
+
if (state.status !== "uploading") return;
|
|
4927
|
+
const xhr = options.xhrFactory ? options.xhrFactory() : new XMLHttpRequest();
|
|
4928
|
+
currentXhr = xhr;
|
|
4929
|
+
const body = options.file.slice(range.start, range.end);
|
|
4930
|
+
try {
|
|
4931
|
+
const etag = await putPart({
|
|
4932
|
+
url,
|
|
4933
|
+
body,
|
|
4934
|
+
xhr,
|
|
4935
|
+
onProgress: (loaded) => emitProgress(loaded)
|
|
4936
|
+
});
|
|
4937
|
+
completed.push({ partNumber: range.partNumber, etag });
|
|
4938
|
+
emitProgress(0);
|
|
4939
|
+
} catch (error) {
|
|
4940
|
+
currentXhr = null;
|
|
4941
|
+
if (isStopped()) return;
|
|
4942
|
+
state.status = "error";
|
|
4943
|
+
throw error;
|
|
4944
|
+
} finally {
|
|
4945
|
+
if (currentXhr === xhr) currentXhr = null;
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
if (state.status !== "uploading") return;
|
|
4949
|
+
state.status = "completing";
|
|
4950
|
+
await options.adapter.complete([...completed]);
|
|
4951
|
+
state.status = "completed";
|
|
4952
|
+
emitProgress(0);
|
|
4953
|
+
}
|
|
4954
|
+
async function start() {
|
|
4955
|
+
if (run) return run;
|
|
4956
|
+
run = uploadFrom(0).catch((error) => {
|
|
4957
|
+
if (isStopped()) return;
|
|
4958
|
+
state.status = "error";
|
|
4959
|
+
throw error;
|
|
4960
|
+
});
|
|
4961
|
+
return run;
|
|
4962
|
+
}
|
|
4963
|
+
function pause() {
|
|
4964
|
+
if (state.status !== "uploading") return;
|
|
4965
|
+
state.status = "paused";
|
|
4966
|
+
currentXhr?.abort();
|
|
4967
|
+
}
|
|
4968
|
+
async function resume() {
|
|
4969
|
+
if (state.status !== "paused") return;
|
|
4970
|
+
run = uploadFrom(resumeIndex).catch((error) => {
|
|
4971
|
+
if (isStopped()) return;
|
|
4972
|
+
state.status = "error";
|
|
4973
|
+
throw error;
|
|
4974
|
+
});
|
|
4975
|
+
return run;
|
|
4976
|
+
}
|
|
4977
|
+
async function cancel() {
|
|
4978
|
+
if (state.status === "completed" || state.status === "cancelled" || state.status === "idle") {
|
|
4979
|
+
state.status = "cancelled";
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
state.status = "cancelled";
|
|
4983
|
+
currentXhr?.abort();
|
|
4984
|
+
await options.adapter.abort?.();
|
|
4985
|
+
}
|
|
4986
|
+
return {
|
|
4987
|
+
start,
|
|
4988
|
+
pause,
|
|
4989
|
+
resume,
|
|
4990
|
+
cancel,
|
|
4991
|
+
getStatus: () => state.status
|
|
4992
|
+
};
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4251
4995
|
// src/lib/avatar.ts
|
|
4252
4996
|
var EMPTY_COLORS = {
|
|
4253
4997
|
backgroundColor: "#9ca3af",
|
|
@@ -4338,6 +5082,10 @@ exports.CurtainPreview = CurtainPreview;
|
|
|
4338
5082
|
exports.CurtainStage = CurtainStage;
|
|
4339
5083
|
exports.DEFAULT_CURTAIN_PICKER_LABELS = DEFAULT_CURTAIN_PICKER_LABELS;
|
|
4340
5084
|
exports.DEFAULT_EDITABLE_SECTION_LABELS = DEFAULT_EDITABLE_SECTION_LABELS;
|
|
5085
|
+
exports.DEFAULT_FILE_DROPZONE_LABELS = DEFAULT_FILE_DROPZONE_LABELS;
|
|
5086
|
+
exports.DEFAULT_FILE_UPLOAD_LABELS = DEFAULT_FILE_UPLOAD_LABELS;
|
|
5087
|
+
exports.DEFAULT_FILE_UPLOAD_TRAY_LABELS = DEFAULT_FILE_UPLOAD_TRAY_LABELS;
|
|
5088
|
+
exports.DEFAULT_NOTIFICATION_BELL_LABELS = DEFAULT_NOTIFICATION_BELL_LABELS;
|
|
4341
5089
|
exports.DataList = DataList;
|
|
4342
5090
|
exports.DataListItem = DataListItem;
|
|
4343
5091
|
exports.EditableSection = EditableSection;
|
|
@@ -4351,9 +5099,13 @@ exports.EmptyTitle = EmptyTitle;
|
|
|
4351
5099
|
exports.ErrorState = ErrorState;
|
|
4352
5100
|
exports.FeedVideoPlayer = FeedVideoPlayer;
|
|
4353
5101
|
exports.FieldMessage = FieldMessage;
|
|
5102
|
+
exports.FileDropzone = FileDropzone;
|
|
5103
|
+
exports.FileUploadMenu = FileUploadMenu;
|
|
5104
|
+
exports.FileUploadTray = FileUploadTray;
|
|
4354
5105
|
exports.LanguageContext = LanguageContext;
|
|
4355
5106
|
exports.LanguageSwitcher = LanguageSwitcher;
|
|
4356
5107
|
exports.LoadingState = LoadingState;
|
|
5108
|
+
exports.NotificationBell = NotificationBell;
|
|
4357
5109
|
exports.SafeImage = SafeImage;
|
|
4358
5110
|
exports.ThemeSwitcher = ThemeSwitcher;
|
|
4359
5111
|
exports.VideoPlayer = VideoPlayer;
|
|
@@ -4362,13 +5114,17 @@ exports.avatarFallbackStyle = avatarFallbackStyle;
|
|
|
4362
5114
|
exports.castHlsUrl = castHlsUrl;
|
|
4363
5115
|
exports.cn = cn;
|
|
4364
5116
|
exports.createLiveHlsConfig = createLiveHlsConfig;
|
|
5117
|
+
exports.createMultipartUploadController = createMultipartUploadController;
|
|
4365
5118
|
exports.createVodHlsConfig = createVodHlsConfig;
|
|
4366
5119
|
exports.defaultLanguages = defaultLanguages;
|
|
4367
5120
|
exports.describeAvResync = describeAvResync;
|
|
4368
5121
|
exports.describePlaybackError = describePlaybackError;
|
|
5122
|
+
exports.fileMatchesAccept = fileMatchesAccept;
|
|
4369
5123
|
exports.getAvatarColors = getAvatarColors;
|
|
4370
5124
|
exports.getInitials = getInitials;
|
|
4371
5125
|
exports.loadCastSender = loadCastSender;
|
|
5126
|
+
exports.partRanges = partRanges;
|
|
5127
|
+
exports.progressFromBytes = progressFromBytes;
|
|
4372
5128
|
exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
|
|
4373
5129
|
exports.useEditableSection = useEditableSection;
|
|
4374
5130
|
exports.useFeedExclusivePlayback = useFeedExclusivePlayback;
|