@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.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React7 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, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
|
|
4
|
+
import { Loader2, AlertTriangle, Inbox, Bell, 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';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
10
10
|
import { Slot } from '@radix-ui/react-slot';
|
|
11
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
11
12
|
import { useTheme } from 'next-themes';
|
|
12
13
|
import { useReducedMotion, AnimatePresence, motion } from 'framer-motion';
|
|
13
|
-
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
14
14
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
15
15
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
16
16
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
@@ -417,6 +417,179 @@ function ConfirmDestructiveDialog({
|
|
|
417
417
|
] })
|
|
418
418
|
] }) });
|
|
419
419
|
}
|
|
420
|
+
var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
|
|
421
|
+
var miniMenuContentDefaults = {
|
|
422
|
+
sideOffset: 8,
|
|
423
|
+
collisionPadding: 12
|
|
424
|
+
};
|
|
425
|
+
function DropdownMenu({
|
|
426
|
+
...props
|
|
427
|
+
}) {
|
|
428
|
+
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
|
|
429
|
+
}
|
|
430
|
+
function DropdownMenuTrigger({
|
|
431
|
+
...props
|
|
432
|
+
}) {
|
|
433
|
+
return /* @__PURE__ */ jsx(
|
|
434
|
+
DropdownMenuPrimitive.Trigger,
|
|
435
|
+
{
|
|
436
|
+
"data-slot": "dropdown-menu-trigger",
|
|
437
|
+
...props
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
function DropdownMenuContent({
|
|
442
|
+
className,
|
|
443
|
+
sideOffset = 4,
|
|
444
|
+
...props
|
|
445
|
+
}) {
|
|
446
|
+
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
447
|
+
DropdownMenuPrimitive.Content,
|
|
448
|
+
{
|
|
449
|
+
"data-slot": "dropdown-menu-content",
|
|
450
|
+
sideOffset,
|
|
451
|
+
className: cn(
|
|
452
|
+
"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",
|
|
453
|
+
className
|
|
454
|
+
),
|
|
455
|
+
...props
|
|
456
|
+
}
|
|
457
|
+
) });
|
|
458
|
+
}
|
|
459
|
+
function DropdownMenuItem({
|
|
460
|
+
className,
|
|
461
|
+
inset,
|
|
462
|
+
variant = "default",
|
|
463
|
+
...props
|
|
464
|
+
}) {
|
|
465
|
+
return /* @__PURE__ */ jsx(
|
|
466
|
+
DropdownMenuPrimitive.Item,
|
|
467
|
+
{
|
|
468
|
+
"data-slot": "dropdown-menu-item",
|
|
469
|
+
"data-inset": inset,
|
|
470
|
+
"data-variant": variant,
|
|
471
|
+
className: cn(
|
|
472
|
+
"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",
|
|
473
|
+
className
|
|
474
|
+
),
|
|
475
|
+
...props
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
var DEFAULT_NOTIFICATION_BELL_LABELS = {
|
|
480
|
+
title: "Notifications",
|
|
481
|
+
empty: "You're all caught up.",
|
|
482
|
+
viewAll: "View all"
|
|
483
|
+
};
|
|
484
|
+
function formatUnreadBadge(count) {
|
|
485
|
+
return count > 9 ? "9+" : String(count);
|
|
486
|
+
}
|
|
487
|
+
function defaultFormatTime(iso) {
|
|
488
|
+
const date = new Date(iso);
|
|
489
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
490
|
+
return date.toLocaleString(void 0, {
|
|
491
|
+
dateStyle: "short",
|
|
492
|
+
timeStyle: "short"
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
function NotificationListSkeleton({ rows = 3 }) {
|
|
496
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col", "aria-hidden": "true", children: Array.from({ length: rows }, (_, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
497
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 px-4 py-3", children: [
|
|
498
|
+
/* @__PURE__ */ jsx(
|
|
499
|
+
"div",
|
|
500
|
+
{
|
|
501
|
+
"data-slot": "skeleton",
|
|
502
|
+
className: "bg-muted h-4 w-36 animate-pulse rounded-md motion-reduce:animate-none"
|
|
503
|
+
}
|
|
504
|
+
),
|
|
505
|
+
/* @__PURE__ */ jsx(
|
|
506
|
+
"div",
|
|
507
|
+
{
|
|
508
|
+
"data-slot": "skeleton",
|
|
509
|
+
className: "bg-muted h-3 w-full animate-pulse rounded-md motion-reduce:animate-none"
|
|
510
|
+
}
|
|
511
|
+
),
|
|
512
|
+
/* @__PURE__ */ jsx(
|
|
513
|
+
"div",
|
|
514
|
+
{
|
|
515
|
+
"data-slot": "skeleton",
|
|
516
|
+
className: "bg-muted h-3 w-20 animate-pulse rounded-md motion-reduce:animate-none"
|
|
517
|
+
}
|
|
518
|
+
)
|
|
519
|
+
] }),
|
|
520
|
+
index < rows - 1 ? /* @__PURE__ */ jsx("div", { className: "bg-border h-px" }) : null
|
|
521
|
+
] }, index)) });
|
|
522
|
+
}
|
|
523
|
+
function NotificationBell({
|
|
524
|
+
items,
|
|
525
|
+
unreadCount,
|
|
526
|
+
isLoading = false,
|
|
527
|
+
labels: labelOverrides,
|
|
528
|
+
viewAllHref,
|
|
529
|
+
formatTime: formatTime2 = defaultFormatTime,
|
|
530
|
+
onOpenChange,
|
|
531
|
+
align = "end",
|
|
532
|
+
className
|
|
533
|
+
}) {
|
|
534
|
+
const labels = { ...DEFAULT_NOTIFICATION_BELL_LABELS, ...labelOverrides };
|
|
535
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { modal: false, onOpenChange, children: [
|
|
536
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
537
|
+
Button,
|
|
538
|
+
{
|
|
539
|
+
type: "button",
|
|
540
|
+
variant: "ghost",
|
|
541
|
+
size: "icon",
|
|
542
|
+
className: cn("relative size-9", className),
|
|
543
|
+
"aria-label": labels.title,
|
|
544
|
+
children: [
|
|
545
|
+
/* @__PURE__ */ jsx(Bell, { className: "size-4" }),
|
|
546
|
+
unreadCount > 0 ? /* @__PURE__ */ 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
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
) }),
|
|
550
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align, className: "w-80 p-0", children: [
|
|
551
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsx("h4", { className: "font-semibold", children: labels.title }) }),
|
|
552
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-80 overflow-y-auto", children: isLoading ? /* @__PURE__ */ jsx(NotificationListSkeleton, {}) : items.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground px-4 py-8 text-center text-sm", children: labels.empty }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: items.map((item, index) => {
|
|
553
|
+
const body = /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1", children: [
|
|
554
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm leading-none font-medium", children: item.title }),
|
|
555
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground line-clamp-2 text-xs", children: item.message }),
|
|
556
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground/70 text-xs", children: formatTime2(item.createdAt) })
|
|
557
|
+
] });
|
|
558
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
559
|
+
item.href ? /* @__PURE__ */ jsx(
|
|
560
|
+
"a",
|
|
561
|
+
{
|
|
562
|
+
href: item.href,
|
|
563
|
+
className: cn(
|
|
564
|
+
"hover:bg-muted/50 flex gap-3 px-4 py-3 motion-safe:transition-colors",
|
|
565
|
+
!item.read && "bg-muted/30"
|
|
566
|
+
),
|
|
567
|
+
children: body
|
|
568
|
+
}
|
|
569
|
+
) : /* @__PURE__ */ jsx(
|
|
570
|
+
"div",
|
|
571
|
+
{
|
|
572
|
+
className: cn(
|
|
573
|
+
"flex gap-3 px-4 py-3",
|
|
574
|
+
!item.read && "bg-muted/30"
|
|
575
|
+
),
|
|
576
|
+
children: body
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
index < items.length - 1 ? /* @__PURE__ */ jsx("div", { className: "bg-border h-px" }) : null
|
|
580
|
+
] }, item.id);
|
|
581
|
+
}) }) }),
|
|
582
|
+
/* @__PURE__ */ jsx("div", { className: "border-t px-4 py-2", children: /* @__PURE__ */ jsx(
|
|
583
|
+
"a",
|
|
584
|
+
{
|
|
585
|
+
href: viewAllHref,
|
|
586
|
+
className: "text-primary block text-center text-sm font-medium hover:underline",
|
|
587
|
+
children: labels.viewAll
|
|
588
|
+
}
|
|
589
|
+
) })
|
|
590
|
+
] })
|
|
591
|
+
] });
|
|
592
|
+
}
|
|
420
593
|
|
|
421
594
|
// src/components/editable/types.ts
|
|
422
595
|
var DEFAULT_EDITABLE_SECTION_LABELS = {
|
|
@@ -798,65 +971,6 @@ function SafeImage({
|
|
|
798
971
|
}
|
|
799
972
|
);
|
|
800
973
|
}
|
|
801
|
-
var miniMenuContentClassName = "max-h-none overflow-x-visible overflow-y-visible";
|
|
802
|
-
var miniMenuContentDefaults = {
|
|
803
|
-
sideOffset: 8,
|
|
804
|
-
collisionPadding: 12
|
|
805
|
-
};
|
|
806
|
-
function DropdownMenu({
|
|
807
|
-
...props
|
|
808
|
-
}) {
|
|
809
|
-
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
|
|
810
|
-
}
|
|
811
|
-
function DropdownMenuTrigger({
|
|
812
|
-
...props
|
|
813
|
-
}) {
|
|
814
|
-
return /* @__PURE__ */ jsx(
|
|
815
|
-
DropdownMenuPrimitive.Trigger,
|
|
816
|
-
{
|
|
817
|
-
"data-slot": "dropdown-menu-trigger",
|
|
818
|
-
...props
|
|
819
|
-
}
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
function DropdownMenuContent({
|
|
823
|
-
className,
|
|
824
|
-
sideOffset = 4,
|
|
825
|
-
...props
|
|
826
|
-
}) {
|
|
827
|
-
return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
828
|
-
DropdownMenuPrimitive.Content,
|
|
829
|
-
{
|
|
830
|
-
"data-slot": "dropdown-menu-content",
|
|
831
|
-
sideOffset,
|
|
832
|
-
className: cn(
|
|
833
|
-
"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",
|
|
834
|
-
className
|
|
835
|
-
),
|
|
836
|
-
...props
|
|
837
|
-
}
|
|
838
|
-
) });
|
|
839
|
-
}
|
|
840
|
-
function DropdownMenuItem({
|
|
841
|
-
className,
|
|
842
|
-
inset,
|
|
843
|
-
variant = "default",
|
|
844
|
-
...props
|
|
845
|
-
}) {
|
|
846
|
-
return /* @__PURE__ */ jsx(
|
|
847
|
-
DropdownMenuPrimitive.Item,
|
|
848
|
-
{
|
|
849
|
-
"data-slot": "dropdown-menu-item",
|
|
850
|
-
"data-inset": inset,
|
|
851
|
-
"data-variant": variant,
|
|
852
|
-
className: cn(
|
|
853
|
-
"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",
|
|
854
|
-
className
|
|
855
|
-
),
|
|
856
|
-
...props
|
|
857
|
-
}
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
974
|
var defaultLabels = {
|
|
861
975
|
theme: "Theme",
|
|
862
976
|
system: "System",
|
|
@@ -2232,6 +2346,37 @@ function AvatarEditorDialog({
|
|
|
2232
2346
|
] }) })
|
|
2233
2347
|
] });
|
|
2234
2348
|
}
|
|
2349
|
+
var DEFAULT_LABELS2 = {
|
|
2350
|
+
play: "Play",
|
|
2351
|
+
tapToUnmute: "Tap to unmute",
|
|
2352
|
+
mute: "Mute",
|
|
2353
|
+
unmute: "Unmute"
|
|
2354
|
+
};
|
|
2355
|
+
var CURTAIN_VIDEO_STYLE = `
|
|
2356
|
+
.livo-curtain-video::-webkit-media-controls-start-playback-button {
|
|
2357
|
+
display: none !important;
|
|
2358
|
+
-webkit-appearance: none;
|
|
2359
|
+
}
|
|
2360
|
+
.livo-curtain-video::-webkit-media-controls {
|
|
2361
|
+
display: none !important;
|
|
2362
|
+
}
|
|
2363
|
+
`;
|
|
2364
|
+
function isAudioTrackList(value) {
|
|
2365
|
+
return typeof value === "object" && value !== null && typeof value.getTrackById === "function";
|
|
2366
|
+
}
|
|
2367
|
+
function probeVideoAudio(el) {
|
|
2368
|
+
const video = el;
|
|
2369
|
+
if (typeof video.mozHasAudio === "boolean") {
|
|
2370
|
+
return video.mozHasAudio ? "yes" : "no";
|
|
2371
|
+
}
|
|
2372
|
+
if (typeof video.webkitAudioDecodedByteCount === "number" && video.webkitAudioDecodedByteCount > 0) {
|
|
2373
|
+
return "yes";
|
|
2374
|
+
}
|
|
2375
|
+
if (isAudioTrackList(video.audioTracks)) {
|
|
2376
|
+
return video.audioTracks.length > 0 ? "yes" : "no";
|
|
2377
|
+
}
|
|
2378
|
+
return "unknown";
|
|
2379
|
+
}
|
|
2235
2380
|
function usePrefersReducedMotion() {
|
|
2236
2381
|
const [reduced, setReduced] = React7.useState(false);
|
|
2237
2382
|
React7.useEffect(() => {
|
|
@@ -2243,39 +2388,154 @@ function usePrefersReducedMotion() {
|
|
|
2243
2388
|
}, []);
|
|
2244
2389
|
return reduced;
|
|
2245
2390
|
}
|
|
2246
|
-
function
|
|
2247
|
-
kind,
|
|
2391
|
+
function CurtainVideo({
|
|
2248
2392
|
url,
|
|
2249
|
-
alt
|
|
2393
|
+
alt,
|
|
2250
2394
|
className,
|
|
2251
|
-
|
|
2395
|
+
freeze,
|
|
2396
|
+
allowSound,
|
|
2397
|
+
labels
|
|
2252
2398
|
}) {
|
|
2253
|
-
const
|
|
2254
|
-
const
|
|
2255
|
-
|
|
2256
|
-
|
|
2399
|
+
const videoRef = React7.useRef(null);
|
|
2400
|
+
const [playback, setPlayback] = React7.useState("pending");
|
|
2401
|
+
const [muted, setMuted] = React7.useState(true);
|
|
2402
|
+
const [audio, setAudio] = React7.useState("unknown");
|
|
2403
|
+
React7.useEffect(() => {
|
|
2404
|
+
const el = videoRef.current;
|
|
2405
|
+
if (!el) return;
|
|
2406
|
+
el.setAttribute("webkit-playsinline", "");
|
|
2407
|
+
el.muted = true;
|
|
2408
|
+
setMuted(true);
|
|
2409
|
+
setAudio("unknown");
|
|
2410
|
+
setPlayback("pending");
|
|
2411
|
+
if (freeze) {
|
|
2412
|
+
el.pause();
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
let cancelled = false;
|
|
2416
|
+
const applyAudio = () => {
|
|
2417
|
+
const next = probeVideoAudio(el);
|
|
2418
|
+
if (next !== "unknown") setAudio(next);
|
|
2419
|
+
};
|
|
2420
|
+
const tryPlay = () => {
|
|
2421
|
+
if (cancelled) return;
|
|
2422
|
+
void el.play().then(
|
|
2423
|
+
() => {
|
|
2424
|
+
if (cancelled) return;
|
|
2425
|
+
setPlayback("playing");
|
|
2426
|
+
applyAudio();
|
|
2427
|
+
},
|
|
2428
|
+
() => {
|
|
2429
|
+
if (!cancelled && el.paused) setPlayback("blocked");
|
|
2430
|
+
}
|
|
2431
|
+
);
|
|
2432
|
+
};
|
|
2433
|
+
tryPlay();
|
|
2434
|
+
el.addEventListener("canplay", tryPlay);
|
|
2435
|
+
el.addEventListener("timeupdate", applyAudio);
|
|
2436
|
+
el.addEventListener("loadedmetadata", applyAudio);
|
|
2437
|
+
return () => {
|
|
2438
|
+
cancelled = true;
|
|
2439
|
+
el.removeEventListener("canplay", tryPlay);
|
|
2440
|
+
el.removeEventListener("timeupdate", applyAudio);
|
|
2441
|
+
el.removeEventListener("loadedmetadata", applyAudio);
|
|
2442
|
+
};
|
|
2443
|
+
}, [url, freeze]);
|
|
2444
|
+
const startPlayback = React7.useCallback(() => {
|
|
2445
|
+
const el = videoRef.current;
|
|
2446
|
+
if (!el) return;
|
|
2447
|
+
el.muted = true;
|
|
2448
|
+
setMuted(true);
|
|
2449
|
+
void el.play().then(
|
|
2450
|
+
() => {
|
|
2451
|
+
setPlayback("playing");
|
|
2452
|
+
const next = probeVideoAudio(el);
|
|
2453
|
+
if (next !== "unknown") setAudio(next);
|
|
2454
|
+
},
|
|
2455
|
+
() => {
|
|
2456
|
+
if (el.paused) setPlayback("blocked");
|
|
2457
|
+
}
|
|
2458
|
+
);
|
|
2459
|
+
}, []);
|
|
2460
|
+
const setVideoMuted = React7.useCallback((next) => {
|
|
2461
|
+
const el = videoRef.current;
|
|
2462
|
+
if (el) el.muted = next;
|
|
2463
|
+
setMuted(next);
|
|
2464
|
+
}, []);
|
|
2465
|
+
const showUnmute = allowSound && !freeze && playback === "playing" && muted && audio !== "no";
|
|
2466
|
+
const showMute = allowSound && !freeze && playback === "playing" && !muted;
|
|
2467
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative h-full w-full", className), children: [
|
|
2468
|
+
/* @__PURE__ */ jsx("style", { children: CURTAIN_VIDEO_STYLE }),
|
|
2469
|
+
/* @__PURE__ */ jsx(
|
|
2257
2470
|
"video",
|
|
2258
2471
|
{
|
|
2472
|
+
ref: videoRef,
|
|
2259
2473
|
src: url,
|
|
2260
|
-
className:
|
|
2261
|
-
autoPlay:
|
|
2262
|
-
muted
|
|
2263
|
-
loop:
|
|
2474
|
+
className: "livo-curtain-video h-full w-full object-cover",
|
|
2475
|
+
autoPlay: !freeze,
|
|
2476
|
+
muted,
|
|
2477
|
+
loop: !freeze,
|
|
2264
2478
|
playsInline: true,
|
|
2479
|
+
preload: freeze ? "metadata" : void 0,
|
|
2265
2480
|
"aria-hidden": alt ? void 0 : true
|
|
2266
2481
|
}
|
|
2267
|
-
)
|
|
2268
|
-
|
|
2269
|
-
|
|
2482
|
+
),
|
|
2483
|
+
playback === "blocked" && !freeze ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
|
|
2484
|
+
"button",
|
|
2485
|
+
{
|
|
2486
|
+
type: "button",
|
|
2487
|
+
"aria-label": labels.play,
|
|
2488
|
+
onClick: startPlayback,
|
|
2489
|
+
className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
|
|
2490
|
+
children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
|
|
2491
|
+
}
|
|
2492
|
+
) }) : null,
|
|
2493
|
+
showUnmute ? /* @__PURE__ */ jsxs(
|
|
2494
|
+
"button",
|
|
2495
|
+
{
|
|
2496
|
+
type: "button",
|
|
2497
|
+
onClick: () => setVideoMuted(false),
|
|
2498
|
+
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",
|
|
2499
|
+
children: [
|
|
2500
|
+
/* @__PURE__ */ jsx(VolumeX, { className: "size-4" }),
|
|
2501
|
+
labels.tapToUnmute
|
|
2502
|
+
]
|
|
2503
|
+
}
|
|
2504
|
+
) : null,
|
|
2505
|
+
showMute ? /* @__PURE__ */ jsx(
|
|
2506
|
+
"button",
|
|
2507
|
+
{
|
|
2508
|
+
type: "button",
|
|
2509
|
+
"aria-label": labels.mute,
|
|
2510
|
+
onClick: () => setVideoMuted(true),
|
|
2511
|
+
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",
|
|
2512
|
+
children: /* @__PURE__ */ jsx(Volume2, { className: "size-4" })
|
|
2513
|
+
}
|
|
2514
|
+
) : null
|
|
2515
|
+
] });
|
|
2516
|
+
}
|
|
2517
|
+
function CurtainStage({
|
|
2518
|
+
kind,
|
|
2519
|
+
url,
|
|
2520
|
+
alt = "",
|
|
2521
|
+
className,
|
|
2522
|
+
reducedMotion,
|
|
2523
|
+
allowSound = false,
|
|
2524
|
+
labels
|
|
2525
|
+
}) {
|
|
2526
|
+
const prefersReduced = usePrefersReducedMotion();
|
|
2527
|
+
const freeze = reducedMotion ?? prefersReduced;
|
|
2528
|
+
const copy = { ...DEFAULT_LABELS2, ...labels };
|
|
2529
|
+
if (kind === "video") {
|
|
2270
2530
|
return /* @__PURE__ */ jsx(
|
|
2271
|
-
|
|
2531
|
+
CurtainVideo,
|
|
2272
2532
|
{
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2533
|
+
url,
|
|
2534
|
+
alt,
|
|
2535
|
+
className,
|
|
2536
|
+
freeze,
|
|
2537
|
+
allowSound,
|
|
2538
|
+
labels: copy
|
|
2279
2539
|
}
|
|
2280
2540
|
);
|
|
2281
2541
|
}
|
|
@@ -2843,6 +3103,7 @@ function WaitingRoom({
|
|
|
2843
3103
|
{
|
|
2844
3104
|
kind: curtain.kind,
|
|
2845
3105
|
url: curtain.url,
|
|
3106
|
+
allowSound: true,
|
|
2846
3107
|
className: "absolute inset-0"
|
|
2847
3108
|
}
|
|
2848
3109
|
) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
@@ -3399,7 +3660,7 @@ function useHlsPlayback({
|
|
|
3399
3660
|
retry
|
|
3400
3661
|
};
|
|
3401
3662
|
}
|
|
3402
|
-
var
|
|
3663
|
+
var DEFAULT_LABELS3 = {
|
|
3403
3664
|
play: "Play",
|
|
3404
3665
|
pause: "Pause",
|
|
3405
3666
|
mute: "Mute",
|
|
@@ -3467,7 +3728,7 @@ function VideoPlayer({
|
|
|
3467
3728
|
fit = "aspect-video",
|
|
3468
3729
|
className
|
|
3469
3730
|
}) {
|
|
3470
|
-
const t = { ...
|
|
3731
|
+
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
3471
3732
|
const containerRef = React7.useRef(null);
|
|
3472
3733
|
const firstPlayFiredRef = React7.useRef(false);
|
|
3473
3734
|
const [userStarted, setUserStarted] = React7.useState(false);
|
|
@@ -4222,6 +4483,489 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4222
4483
|
return stats;
|
|
4223
4484
|
}
|
|
4224
4485
|
|
|
4486
|
+
// src/components/upload/part-math.ts
|
|
4487
|
+
function partRanges(fileSize, partSize) {
|
|
4488
|
+
if (partSize <= 0) {
|
|
4489
|
+
throw new Error("partSize must be greater than 0");
|
|
4490
|
+
}
|
|
4491
|
+
if (fileSize <= 0) {
|
|
4492
|
+
return [{ partNumber: 1, start: 0, end: 0 }];
|
|
4493
|
+
}
|
|
4494
|
+
const count = Math.ceil(fileSize / partSize);
|
|
4495
|
+
return Array.from({ length: count }, (_, index) => {
|
|
4496
|
+
const start = index * partSize;
|
|
4497
|
+
return {
|
|
4498
|
+
partNumber: index + 1,
|
|
4499
|
+
start,
|
|
4500
|
+
end: Math.min(fileSize, start + partSize)
|
|
4501
|
+
};
|
|
4502
|
+
});
|
|
4503
|
+
}
|
|
4504
|
+
function progressFromBytes(loaded, total) {
|
|
4505
|
+
const safeTotal = Math.max(0, total);
|
|
4506
|
+
const safeLoaded = Math.min(Math.max(0, loaded), safeTotal);
|
|
4507
|
+
const percent = safeTotal > 0 ? Math.round(safeLoaded / safeTotal * 100) : 0;
|
|
4508
|
+
return { loaded: safeLoaded, total: safeTotal, percent };
|
|
4509
|
+
}
|
|
4510
|
+
function fileMatchesAccept(file, accept) {
|
|
4511
|
+
if (!accept?.trim()) return true;
|
|
4512
|
+
const type = file.type.toLowerCase();
|
|
4513
|
+
const name = file.name.toLowerCase();
|
|
4514
|
+
return accept.split(",").some((token) => {
|
|
4515
|
+
const trimmed = token.trim().toLowerCase();
|
|
4516
|
+
if (!trimmed) return false;
|
|
4517
|
+
if (trimmed.endsWith("/*")) {
|
|
4518
|
+
return type.startsWith(trimmed.slice(0, -1));
|
|
4519
|
+
}
|
|
4520
|
+
if (trimmed.startsWith(".")) {
|
|
4521
|
+
return name.endsWith(trimmed);
|
|
4522
|
+
}
|
|
4523
|
+
return type === trimmed;
|
|
4524
|
+
});
|
|
4525
|
+
}
|
|
4526
|
+
|
|
4527
|
+
// src/components/upload/types.ts
|
|
4528
|
+
var DEFAULT_FILE_DROPZONE_LABELS = {
|
|
4529
|
+
idle: "Drop a file here or browse",
|
|
4530
|
+
hint: "Click or press Enter to choose a file",
|
|
4531
|
+
browse: "Browse",
|
|
4532
|
+
rejectType: "This file type is not allowed",
|
|
4533
|
+
rejectSize: "This file is too large"
|
|
4534
|
+
};
|
|
4535
|
+
var DEFAULT_FILE_UPLOAD_TRAY_LABELS = {
|
|
4536
|
+
title: "Uploads",
|
|
4537
|
+
pause: "Pause",
|
|
4538
|
+
resume: "Resume",
|
|
4539
|
+
cancel: "Cancel",
|
|
4540
|
+
uploading: "Uploading",
|
|
4541
|
+
paused: "Paused",
|
|
4542
|
+
completing: "Finishing",
|
|
4543
|
+
completed: "Uploaded",
|
|
4544
|
+
cancelled: "Cancelled",
|
|
4545
|
+
error: "Failed"
|
|
4546
|
+
};
|
|
4547
|
+
var DEFAULT_FILE_UPLOAD_LABELS = {
|
|
4548
|
+
dropzone: DEFAULT_FILE_DROPZONE_LABELS,
|
|
4549
|
+
tray: DEFAULT_FILE_UPLOAD_TRAY_LABELS
|
|
4550
|
+
};
|
|
4551
|
+
function FileDropzone({
|
|
4552
|
+
accept,
|
|
4553
|
+
maxSize,
|
|
4554
|
+
disabled = false,
|
|
4555
|
+
labels: labelOverrides,
|
|
4556
|
+
onFile,
|
|
4557
|
+
onReject,
|
|
4558
|
+
className
|
|
4559
|
+
}) {
|
|
4560
|
+
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
4561
|
+
const inputId = useId();
|
|
4562
|
+
const inputRef = useRef(null);
|
|
4563
|
+
const [dragging, setDragging] = useState(false);
|
|
4564
|
+
const [message, setMessage] = useState(null);
|
|
4565
|
+
function takeFile(file) {
|
|
4566
|
+
if (!file || disabled) return;
|
|
4567
|
+
if (!fileMatchesAccept(file, accept)) {
|
|
4568
|
+
setMessage(labels.rejectType);
|
|
4569
|
+
onReject?.("type");
|
|
4570
|
+
return;
|
|
4571
|
+
}
|
|
4572
|
+
if (maxSize != null && file.size > maxSize) {
|
|
4573
|
+
setMessage(labels.rejectSize);
|
|
4574
|
+
onReject?.("size");
|
|
4575
|
+
return;
|
|
4576
|
+
}
|
|
4577
|
+
setMessage(null);
|
|
4578
|
+
onFile(file);
|
|
4579
|
+
}
|
|
4580
|
+
function onDrop(event) {
|
|
4581
|
+
event.preventDefault();
|
|
4582
|
+
setDragging(false);
|
|
4583
|
+
takeFile(event.dataTransfer.files[0]);
|
|
4584
|
+
}
|
|
4585
|
+
function onKeyDown(event) {
|
|
4586
|
+
if (disabled) return;
|
|
4587
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
4588
|
+
event.preventDefault();
|
|
4589
|
+
inputRef.current?.click();
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
4592
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-2", className), children: [
|
|
4593
|
+
/* @__PURE__ */ jsxs(
|
|
4594
|
+
"div",
|
|
4595
|
+
{
|
|
4596
|
+
role: "button",
|
|
4597
|
+
tabIndex: disabled ? -1 : 0,
|
|
4598
|
+
"aria-disabled": disabled,
|
|
4599
|
+
"aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
|
|
4600
|
+
"aria-controls": inputId,
|
|
4601
|
+
"data-dragging": dragging || void 0,
|
|
4602
|
+
className: cn(
|
|
4603
|
+
"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]",
|
|
4604
|
+
dragging && "border-primary bg-primary/5",
|
|
4605
|
+
disabled && "pointer-events-none opacity-50"
|
|
4606
|
+
),
|
|
4607
|
+
onClick: () => {
|
|
4608
|
+
if (!disabled) inputRef.current?.click();
|
|
4609
|
+
},
|
|
4610
|
+
onKeyDown,
|
|
4611
|
+
onDragEnter: (event) => {
|
|
4612
|
+
event.preventDefault();
|
|
4613
|
+
if (!disabled) setDragging(true);
|
|
4614
|
+
},
|
|
4615
|
+
onDragOver: (event) => {
|
|
4616
|
+
event.preventDefault();
|
|
4617
|
+
},
|
|
4618
|
+
onDragLeave: (event) => {
|
|
4619
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
4620
|
+
return;
|
|
4621
|
+
}
|
|
4622
|
+
setDragging(false);
|
|
4623
|
+
},
|
|
4624
|
+
onDrop,
|
|
4625
|
+
children: [
|
|
4626
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: labels.idle }),
|
|
4627
|
+
/* @__PURE__ */ jsx(
|
|
4628
|
+
"p",
|
|
4629
|
+
{
|
|
4630
|
+
id: `${inputId}-hint`,
|
|
4631
|
+
className: "text-muted-foreground mt-1 text-xs",
|
|
4632
|
+
children: labels.hint
|
|
4633
|
+
}
|
|
4634
|
+
),
|
|
4635
|
+
/* @__PURE__ */ jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
|
|
4636
|
+
]
|
|
4637
|
+
}
|
|
4638
|
+
),
|
|
4639
|
+
/* @__PURE__ */ jsx(
|
|
4640
|
+
"input",
|
|
4641
|
+
{
|
|
4642
|
+
id: inputId,
|
|
4643
|
+
ref: inputRef,
|
|
4644
|
+
type: "file",
|
|
4645
|
+
accept,
|
|
4646
|
+
disabled,
|
|
4647
|
+
"aria-label": labels.browse,
|
|
4648
|
+
className: "sr-only",
|
|
4649
|
+
onChange: (event) => {
|
|
4650
|
+
takeFile(event.target.files?.[0]);
|
|
4651
|
+
event.target.value = "";
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
),
|
|
4655
|
+
message ? /* @__PURE__ */ jsx(
|
|
4656
|
+
"p",
|
|
4657
|
+
{
|
|
4658
|
+
id: `${inputId}-message`,
|
|
4659
|
+
role: "alert",
|
|
4660
|
+
className: "text-destructive text-sm",
|
|
4661
|
+
children: message
|
|
4662
|
+
}
|
|
4663
|
+
) : null
|
|
4664
|
+
] });
|
|
4665
|
+
}
|
|
4666
|
+
function statusLabel(status, labels) {
|
|
4667
|
+
switch (status) {
|
|
4668
|
+
case "uploading":
|
|
4669
|
+
return labels.uploading;
|
|
4670
|
+
case "paused":
|
|
4671
|
+
return labels.paused;
|
|
4672
|
+
case "completing":
|
|
4673
|
+
return labels.completing;
|
|
4674
|
+
case "completed":
|
|
4675
|
+
return labels.completed;
|
|
4676
|
+
case "cancelled":
|
|
4677
|
+
return labels.cancelled;
|
|
4678
|
+
case "error":
|
|
4679
|
+
return labels.error;
|
|
4680
|
+
default: {
|
|
4681
|
+
const _exhaustive = status;
|
|
4682
|
+
return _exhaustive;
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
function FileUploadTray({
|
|
4687
|
+
jobs,
|
|
4688
|
+
labels: labelOverrides,
|
|
4689
|
+
onPause,
|
|
4690
|
+
onResume,
|
|
4691
|
+
onCancel,
|
|
4692
|
+
className
|
|
4693
|
+
}) {
|
|
4694
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4695
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4696
|
+
if (visible.length === 0) return null;
|
|
4697
|
+
return /* @__PURE__ */ jsx("section", { "aria-label": labels.title, className: cn("grid gap-3", className), children: /* @__PURE__ */ jsx("ul", { className: "grid gap-3", children: visible.map((job) => {
|
|
4698
|
+
const active = job.status === "uploading" || job.status === "completing";
|
|
4699
|
+
const canPause = job.status === "uploading";
|
|
4700
|
+
const canResume = job.status === "paused";
|
|
4701
|
+
const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
|
|
4702
|
+
return /* @__PURE__ */ jsxs("li", { className: "grid gap-1.5", children: [
|
|
4703
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4704
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: job.name }),
|
|
4705
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: statusLabel(job.status, labels) }),
|
|
4706
|
+
canPause ? /* @__PURE__ */ jsx(
|
|
4707
|
+
Button,
|
|
4708
|
+
{
|
|
4709
|
+
type: "button",
|
|
4710
|
+
variant: "ghost",
|
|
4711
|
+
size: "icon-sm",
|
|
4712
|
+
"aria-label": `${labels.pause} ${job.name}`,
|
|
4713
|
+
onClick: () => onPause(job.id),
|
|
4714
|
+
children: /* @__PURE__ */ jsx(Pause, {})
|
|
4715
|
+
}
|
|
4716
|
+
) : null,
|
|
4717
|
+
canResume ? /* @__PURE__ */ jsx(
|
|
4718
|
+
Button,
|
|
4719
|
+
{
|
|
4720
|
+
type: "button",
|
|
4721
|
+
variant: "ghost",
|
|
4722
|
+
size: "icon-sm",
|
|
4723
|
+
"aria-label": `${labels.resume} ${job.name}`,
|
|
4724
|
+
onClick: () => onResume(job.id),
|
|
4725
|
+
children: /* @__PURE__ */ jsx(Play, {})
|
|
4726
|
+
}
|
|
4727
|
+
) : null,
|
|
4728
|
+
canCancel ? /* @__PURE__ */ jsx(
|
|
4729
|
+
Button,
|
|
4730
|
+
{
|
|
4731
|
+
type: "button",
|
|
4732
|
+
variant: "ghost",
|
|
4733
|
+
size: "icon-sm",
|
|
4734
|
+
"aria-label": `${labels.cancel} ${job.name}`,
|
|
4735
|
+
onClick: () => onCancel(job.id),
|
|
4736
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
4737
|
+
}
|
|
4738
|
+
) : null
|
|
4739
|
+
] }),
|
|
4740
|
+
/* @__PURE__ */ jsx(
|
|
4741
|
+
"div",
|
|
4742
|
+
{
|
|
4743
|
+
role: "progressbar",
|
|
4744
|
+
"aria-valuemin": 0,
|
|
4745
|
+
"aria-valuemax": 100,
|
|
4746
|
+
"aria-valuenow": job.percent,
|
|
4747
|
+
"aria-label": job.name,
|
|
4748
|
+
className: "bg-muted h-2 overflow-hidden rounded-full",
|
|
4749
|
+
children: /* @__PURE__ */ jsx(
|
|
4750
|
+
"div",
|
|
4751
|
+
{
|
|
4752
|
+
className: cn(
|
|
4753
|
+
"bg-primary h-full",
|
|
4754
|
+
active && "motion-safe:transition-[width]"
|
|
4755
|
+
),
|
|
4756
|
+
style: { width: `${job.percent}%` }
|
|
4757
|
+
}
|
|
4758
|
+
)
|
|
4759
|
+
}
|
|
4760
|
+
),
|
|
4761
|
+
job.error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
|
|
4762
|
+
] }, job.id);
|
|
4763
|
+
}) }) });
|
|
4764
|
+
}
|
|
4765
|
+
function formatActiveBadge(count) {
|
|
4766
|
+
return count > 9 ? "9+" : String(count);
|
|
4767
|
+
}
|
|
4768
|
+
function isActiveStatus(status) {
|
|
4769
|
+
return status === "uploading" || status === "paused" || status === "completing";
|
|
4770
|
+
}
|
|
4771
|
+
function FileUploadMenu({
|
|
4772
|
+
jobs,
|
|
4773
|
+
labels: labelOverrides,
|
|
4774
|
+
onPause,
|
|
4775
|
+
onResume,
|
|
4776
|
+
onCancel,
|
|
4777
|
+
open,
|
|
4778
|
+
onOpenChange,
|
|
4779
|
+
align = "end",
|
|
4780
|
+
className
|
|
4781
|
+
}) {
|
|
4782
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4783
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4784
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
4785
|
+
const isControlled = open !== void 0;
|
|
4786
|
+
const resolvedOpen = isControlled ? open : uncontrolledOpen;
|
|
4787
|
+
function setResolvedOpen(next) {
|
|
4788
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
4789
|
+
onOpenChange?.(next);
|
|
4790
|
+
}
|
|
4791
|
+
if (visible.length === 0) return null;
|
|
4792
|
+
const activeCount = visible.filter(
|
|
4793
|
+
(job) => isActiveStatus(job.status)
|
|
4794
|
+
).length;
|
|
4795
|
+
return /* @__PURE__ */ jsxs(
|
|
4796
|
+
DropdownMenu,
|
|
4797
|
+
{
|
|
4798
|
+
modal: false,
|
|
4799
|
+
open: resolvedOpen,
|
|
4800
|
+
onOpenChange: setResolvedOpen,
|
|
4801
|
+
children: [
|
|
4802
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
4803
|
+
Button,
|
|
4804
|
+
{
|
|
4805
|
+
type: "button",
|
|
4806
|
+
variant: "ghost",
|
|
4807
|
+
size: "icon",
|
|
4808
|
+
className: cn("relative size-9", className),
|
|
4809
|
+
"aria-label": labels.title,
|
|
4810
|
+
children: [
|
|
4811
|
+
/* @__PURE__ */ jsx(Upload, { className: "size-4" }),
|
|
4812
|
+
activeCount > 0 ? /* @__PURE__ */ 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
|
|
4813
|
+
]
|
|
4814
|
+
}
|
|
4815
|
+
) }),
|
|
4816
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { align, className: "w-80 p-0", children: [
|
|
4817
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border-b px-4 py-3", children: /* @__PURE__ */ jsx("h4", { className: "font-semibold", children: labels.title }) }),
|
|
4818
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-80 overflow-y-auto p-3", children: /* @__PURE__ */ jsx(
|
|
4819
|
+
FileUploadTray,
|
|
4820
|
+
{
|
|
4821
|
+
jobs: visible,
|
|
4822
|
+
labels,
|
|
4823
|
+
onPause,
|
|
4824
|
+
onResume,
|
|
4825
|
+
onCancel
|
|
4826
|
+
}
|
|
4827
|
+
) })
|
|
4828
|
+
] })
|
|
4829
|
+
]
|
|
4830
|
+
}
|
|
4831
|
+
);
|
|
4832
|
+
}
|
|
4833
|
+
|
|
4834
|
+
// src/components/upload/createMultipartUploadController.ts
|
|
4835
|
+
function readEtag(xhr) {
|
|
4836
|
+
const raw = xhr.getResponseHeader("ETag") ?? xhr.getResponseHeader("etag") ?? "";
|
|
4837
|
+
const etag = raw.trim();
|
|
4838
|
+
if (!etag) {
|
|
4839
|
+
throw new Error("Upload part missing ETag");
|
|
4840
|
+
}
|
|
4841
|
+
return etag;
|
|
4842
|
+
}
|
|
4843
|
+
function putPart(input) {
|
|
4844
|
+
return new Promise((resolve, reject) => {
|
|
4845
|
+
input.xhr.open("PUT", input.url);
|
|
4846
|
+
input.xhr.upload.onprogress = (event) => {
|
|
4847
|
+
input.onProgress(event.loaded);
|
|
4848
|
+
};
|
|
4849
|
+
input.xhr.onload = () => {
|
|
4850
|
+
if (input.xhr.status >= 200 && input.xhr.status < 300) {
|
|
4851
|
+
try {
|
|
4852
|
+
resolve(readEtag(input.xhr));
|
|
4853
|
+
} catch (error) {
|
|
4854
|
+
reject(error);
|
|
4855
|
+
}
|
|
4856
|
+
return;
|
|
4857
|
+
}
|
|
4858
|
+
reject(new Error(`Upload failed (${input.xhr.status})`));
|
|
4859
|
+
};
|
|
4860
|
+
input.xhr.onerror = () => {
|
|
4861
|
+
reject(new Error("Upload failed"));
|
|
4862
|
+
};
|
|
4863
|
+
input.xhr.onabort = () => {
|
|
4864
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
4865
|
+
};
|
|
4866
|
+
input.xhr.send(input.body);
|
|
4867
|
+
});
|
|
4868
|
+
}
|
|
4869
|
+
function createMultipartUploadController(options) {
|
|
4870
|
+
const ranges = partRanges(options.file.size, options.partSize);
|
|
4871
|
+
const completed = [];
|
|
4872
|
+
const state = { status: "idle" };
|
|
4873
|
+
let currentXhr = null;
|
|
4874
|
+
let run = null;
|
|
4875
|
+
let resumeIndex = 0;
|
|
4876
|
+
function currentStatus() {
|
|
4877
|
+
return state.status;
|
|
4878
|
+
}
|
|
4879
|
+
function isStopped() {
|
|
4880
|
+
const status = currentStatus();
|
|
4881
|
+
return status === "paused" || status === "cancelled";
|
|
4882
|
+
}
|
|
4883
|
+
function emitProgress(currentPartLoaded = 0) {
|
|
4884
|
+
const completedBytes = completed.reduce((sum, part) => {
|
|
4885
|
+
const range = ranges[part.partNumber - 1];
|
|
4886
|
+
return sum + (range ? range.end - range.start : 0);
|
|
4887
|
+
}, 0);
|
|
4888
|
+
options.onProgress?.(
|
|
4889
|
+
progressFromBytes(completedBytes + currentPartLoaded, options.file.size)
|
|
4890
|
+
);
|
|
4891
|
+
}
|
|
4892
|
+
async function uploadFrom(startIndex) {
|
|
4893
|
+
state.status = "uploading";
|
|
4894
|
+
for (let index = startIndex; index < ranges.length; index += 1) {
|
|
4895
|
+
if (state.status !== "uploading") return;
|
|
4896
|
+
resumeIndex = index;
|
|
4897
|
+
const range = ranges[index];
|
|
4898
|
+
if (!range) continue;
|
|
4899
|
+
const url = await options.adapter.requestPartUrl(range.partNumber);
|
|
4900
|
+
if (state.status !== "uploading") return;
|
|
4901
|
+
const xhr = options.xhrFactory ? options.xhrFactory() : new XMLHttpRequest();
|
|
4902
|
+
currentXhr = xhr;
|
|
4903
|
+
const body = options.file.slice(range.start, range.end);
|
|
4904
|
+
try {
|
|
4905
|
+
const etag = await putPart({
|
|
4906
|
+
url,
|
|
4907
|
+
body,
|
|
4908
|
+
xhr,
|
|
4909
|
+
onProgress: (loaded) => emitProgress(loaded)
|
|
4910
|
+
});
|
|
4911
|
+
completed.push({ partNumber: range.partNumber, etag });
|
|
4912
|
+
emitProgress(0);
|
|
4913
|
+
} catch (error) {
|
|
4914
|
+
currentXhr = null;
|
|
4915
|
+
if (isStopped()) return;
|
|
4916
|
+
state.status = "error";
|
|
4917
|
+
throw error;
|
|
4918
|
+
} finally {
|
|
4919
|
+
if (currentXhr === xhr) currentXhr = null;
|
|
4920
|
+
}
|
|
4921
|
+
}
|
|
4922
|
+
if (state.status !== "uploading") return;
|
|
4923
|
+
state.status = "completing";
|
|
4924
|
+
await options.adapter.complete([...completed]);
|
|
4925
|
+
state.status = "completed";
|
|
4926
|
+
emitProgress(0);
|
|
4927
|
+
}
|
|
4928
|
+
async function start() {
|
|
4929
|
+
if (run) return run;
|
|
4930
|
+
run = uploadFrom(0).catch((error) => {
|
|
4931
|
+
if (isStopped()) return;
|
|
4932
|
+
state.status = "error";
|
|
4933
|
+
throw error;
|
|
4934
|
+
});
|
|
4935
|
+
return run;
|
|
4936
|
+
}
|
|
4937
|
+
function pause() {
|
|
4938
|
+
if (state.status !== "uploading") return;
|
|
4939
|
+
state.status = "paused";
|
|
4940
|
+
currentXhr?.abort();
|
|
4941
|
+
}
|
|
4942
|
+
async function resume() {
|
|
4943
|
+
if (state.status !== "paused") return;
|
|
4944
|
+
run = uploadFrom(resumeIndex).catch((error) => {
|
|
4945
|
+
if (isStopped()) return;
|
|
4946
|
+
state.status = "error";
|
|
4947
|
+
throw error;
|
|
4948
|
+
});
|
|
4949
|
+
return run;
|
|
4950
|
+
}
|
|
4951
|
+
async function cancel() {
|
|
4952
|
+
if (state.status === "completed" || state.status === "cancelled" || state.status === "idle") {
|
|
4953
|
+
state.status = "cancelled";
|
|
4954
|
+
return;
|
|
4955
|
+
}
|
|
4956
|
+
state.status = "cancelled";
|
|
4957
|
+
currentXhr?.abort();
|
|
4958
|
+
await options.adapter.abort?.();
|
|
4959
|
+
}
|
|
4960
|
+
return {
|
|
4961
|
+
start,
|
|
4962
|
+
pause,
|
|
4963
|
+
resume,
|
|
4964
|
+
cancel,
|
|
4965
|
+
getStatus: () => state.status
|
|
4966
|
+
};
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4225
4969
|
// src/lib/avatar.ts
|
|
4226
4970
|
var EMPTY_COLORS = {
|
|
4227
4971
|
backgroundColor: "#9ca3af",
|
|
@@ -4303,6 +5047,6 @@ function avatarFallbackStyle(name) {
|
|
|
4303
5047
|
return getAvatarColors(name);
|
|
4304
5048
|
}
|
|
4305
5049
|
|
|
4306
|
-
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 };
|
|
5050
|
+
export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, NotificationBell, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, getAvatarColors, getInitials, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
|
|
4307
5051
|
//# sourceMappingURL=index.js.map
|
|
4308
5052
|
//# sourceMappingURL=index.js.map
|