@livo-tv/blocks 1.2.0 → 1.4.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 +1 -1
- package/dist/index.cjs +839 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -6
- package/dist/index.d.ts +122 -6
- package/dist/index.js +831 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2258,6 +2258,37 @@ function AvatarEditorDialog({
|
|
|
2258
2258
|
] }) })
|
|
2259
2259
|
] });
|
|
2260
2260
|
}
|
|
2261
|
+
var DEFAULT_LABELS2 = {
|
|
2262
|
+
play: "Play",
|
|
2263
|
+
tapToUnmute: "Tap to unmute",
|
|
2264
|
+
mute: "Mute",
|
|
2265
|
+
unmute: "Unmute"
|
|
2266
|
+
};
|
|
2267
|
+
var CURTAIN_VIDEO_STYLE = `
|
|
2268
|
+
.livo-curtain-video::-webkit-media-controls-start-playback-button {
|
|
2269
|
+
display: none !important;
|
|
2270
|
+
-webkit-appearance: none;
|
|
2271
|
+
}
|
|
2272
|
+
.livo-curtain-video::-webkit-media-controls {
|
|
2273
|
+
display: none !important;
|
|
2274
|
+
}
|
|
2275
|
+
`;
|
|
2276
|
+
function isAudioTrackList(value) {
|
|
2277
|
+
return typeof value === "object" && value !== null && typeof value.getTrackById === "function";
|
|
2278
|
+
}
|
|
2279
|
+
function probeVideoAudio(el) {
|
|
2280
|
+
const video = el;
|
|
2281
|
+
if (typeof video.mozHasAudio === "boolean") {
|
|
2282
|
+
return video.mozHasAudio ? "yes" : "no";
|
|
2283
|
+
}
|
|
2284
|
+
if (typeof video.webkitAudioDecodedByteCount === "number" && video.webkitAudioDecodedByteCount > 0) {
|
|
2285
|
+
return "yes";
|
|
2286
|
+
}
|
|
2287
|
+
if (isAudioTrackList(video.audioTracks)) {
|
|
2288
|
+
return video.audioTracks.length > 0 ? "yes" : "no";
|
|
2289
|
+
}
|
|
2290
|
+
return "unknown";
|
|
2291
|
+
}
|
|
2261
2292
|
function usePrefersReducedMotion() {
|
|
2262
2293
|
const [reduced, setReduced] = React7__namespace.useState(false);
|
|
2263
2294
|
React7__namespace.useEffect(() => {
|
|
@@ -2269,39 +2300,154 @@ function usePrefersReducedMotion() {
|
|
|
2269
2300
|
}, []);
|
|
2270
2301
|
return reduced;
|
|
2271
2302
|
}
|
|
2272
|
-
function
|
|
2273
|
-
kind,
|
|
2303
|
+
function CurtainVideo({
|
|
2274
2304
|
url,
|
|
2275
|
-
alt
|
|
2305
|
+
alt,
|
|
2276
2306
|
className,
|
|
2277
|
-
|
|
2307
|
+
freeze,
|
|
2308
|
+
allowSound,
|
|
2309
|
+
labels
|
|
2278
2310
|
}) {
|
|
2279
|
-
const
|
|
2280
|
-
const
|
|
2281
|
-
|
|
2282
|
-
|
|
2311
|
+
const videoRef = React7__namespace.useRef(null);
|
|
2312
|
+
const [playback, setPlayback] = React7__namespace.useState("pending");
|
|
2313
|
+
const [muted, setMuted] = React7__namespace.useState(true);
|
|
2314
|
+
const [audio, setAudio] = React7__namespace.useState("unknown");
|
|
2315
|
+
React7__namespace.useEffect(() => {
|
|
2316
|
+
const el = videoRef.current;
|
|
2317
|
+
if (!el) return;
|
|
2318
|
+
el.setAttribute("webkit-playsinline", "");
|
|
2319
|
+
el.muted = true;
|
|
2320
|
+
setMuted(true);
|
|
2321
|
+
setAudio("unknown");
|
|
2322
|
+
setPlayback("pending");
|
|
2323
|
+
if (freeze) {
|
|
2324
|
+
el.pause();
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
let cancelled = false;
|
|
2328
|
+
const applyAudio = () => {
|
|
2329
|
+
const next = probeVideoAudio(el);
|
|
2330
|
+
if (next !== "unknown") setAudio(next);
|
|
2331
|
+
};
|
|
2332
|
+
const tryPlay = () => {
|
|
2333
|
+
if (cancelled) return;
|
|
2334
|
+
void el.play().then(
|
|
2335
|
+
() => {
|
|
2336
|
+
if (cancelled) return;
|
|
2337
|
+
setPlayback("playing");
|
|
2338
|
+
applyAudio();
|
|
2339
|
+
},
|
|
2340
|
+
() => {
|
|
2341
|
+
if (!cancelled && el.paused) setPlayback("blocked");
|
|
2342
|
+
}
|
|
2343
|
+
);
|
|
2344
|
+
};
|
|
2345
|
+
tryPlay();
|
|
2346
|
+
el.addEventListener("canplay", tryPlay);
|
|
2347
|
+
el.addEventListener("timeupdate", applyAudio);
|
|
2348
|
+
el.addEventListener("loadedmetadata", applyAudio);
|
|
2349
|
+
return () => {
|
|
2350
|
+
cancelled = true;
|
|
2351
|
+
el.removeEventListener("canplay", tryPlay);
|
|
2352
|
+
el.removeEventListener("timeupdate", applyAudio);
|
|
2353
|
+
el.removeEventListener("loadedmetadata", applyAudio);
|
|
2354
|
+
};
|
|
2355
|
+
}, [url, freeze]);
|
|
2356
|
+
const startPlayback = React7__namespace.useCallback(() => {
|
|
2357
|
+
const el = videoRef.current;
|
|
2358
|
+
if (!el) return;
|
|
2359
|
+
el.muted = true;
|
|
2360
|
+
setMuted(true);
|
|
2361
|
+
void el.play().then(
|
|
2362
|
+
() => {
|
|
2363
|
+
setPlayback("playing");
|
|
2364
|
+
const next = probeVideoAudio(el);
|
|
2365
|
+
if (next !== "unknown") setAudio(next);
|
|
2366
|
+
},
|
|
2367
|
+
() => {
|
|
2368
|
+
if (el.paused) setPlayback("blocked");
|
|
2369
|
+
}
|
|
2370
|
+
);
|
|
2371
|
+
}, []);
|
|
2372
|
+
const setVideoMuted = React7__namespace.useCallback((next) => {
|
|
2373
|
+
const el = videoRef.current;
|
|
2374
|
+
if (el) el.muted = next;
|
|
2375
|
+
setMuted(next);
|
|
2376
|
+
}, []);
|
|
2377
|
+
const showUnmute = allowSound && !freeze && playback === "playing" && muted && audio !== "no";
|
|
2378
|
+
const showMute = allowSound && !freeze && playback === "playing" && !muted;
|
|
2379
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative h-full w-full", className), children: [
|
|
2380
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: CURTAIN_VIDEO_STYLE }),
|
|
2381
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2283
2382
|
"video",
|
|
2284
2383
|
{
|
|
2384
|
+
ref: videoRef,
|
|
2285
2385
|
src: url,
|
|
2286
|
-
className:
|
|
2287
|
-
autoPlay:
|
|
2288
|
-
muted
|
|
2289
|
-
loop:
|
|
2386
|
+
className: "livo-curtain-video h-full w-full object-cover",
|
|
2387
|
+
autoPlay: !freeze,
|
|
2388
|
+
muted,
|
|
2389
|
+
loop: !freeze,
|
|
2290
2390
|
playsInline: true,
|
|
2391
|
+
preload: freeze ? "metadata" : void 0,
|
|
2291
2392
|
"aria-hidden": alt ? void 0 : true
|
|
2292
2393
|
}
|
|
2293
|
-
)
|
|
2294
|
-
|
|
2295
|
-
|
|
2394
|
+
),
|
|
2395
|
+
playback === "blocked" && !freeze ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2396
|
+
"button",
|
|
2397
|
+
{
|
|
2398
|
+
type: "button",
|
|
2399
|
+
"aria-label": labels.play,
|
|
2400
|
+
onClick: startPlayback,
|
|
2401
|
+
className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
|
|
2402
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
|
|
2403
|
+
}
|
|
2404
|
+
) }) : null,
|
|
2405
|
+
showUnmute ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2406
|
+
"button",
|
|
2407
|
+
{
|
|
2408
|
+
type: "button",
|
|
2409
|
+
onClick: () => setVideoMuted(false),
|
|
2410
|
+
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",
|
|
2411
|
+
children: [
|
|
2412
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { className: "size-4" }),
|
|
2413
|
+
labels.tapToUnmute
|
|
2414
|
+
]
|
|
2415
|
+
}
|
|
2416
|
+
) : null,
|
|
2417
|
+
showMute ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2418
|
+
"button",
|
|
2419
|
+
{
|
|
2420
|
+
type: "button",
|
|
2421
|
+
"aria-label": labels.mute,
|
|
2422
|
+
onClick: () => setVideoMuted(true),
|
|
2423
|
+
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",
|
|
2424
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "size-4" })
|
|
2425
|
+
}
|
|
2426
|
+
) : null
|
|
2427
|
+
] });
|
|
2428
|
+
}
|
|
2429
|
+
function CurtainStage({
|
|
2430
|
+
kind,
|
|
2431
|
+
url,
|
|
2432
|
+
alt = "",
|
|
2433
|
+
className,
|
|
2434
|
+
reducedMotion,
|
|
2435
|
+
allowSound = false,
|
|
2436
|
+
labels
|
|
2437
|
+
}) {
|
|
2438
|
+
const prefersReduced = usePrefersReducedMotion();
|
|
2439
|
+
const freeze = reducedMotion ?? prefersReduced;
|
|
2440
|
+
const copy = { ...DEFAULT_LABELS2, ...labels };
|
|
2441
|
+
if (kind === "video") {
|
|
2296
2442
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2297
|
-
|
|
2443
|
+
CurtainVideo,
|
|
2298
2444
|
{
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2445
|
+
url,
|
|
2446
|
+
alt,
|
|
2447
|
+
className,
|
|
2448
|
+
freeze,
|
|
2449
|
+
allowSound,
|
|
2450
|
+
labels: copy
|
|
2305
2451
|
}
|
|
2306
2452
|
);
|
|
2307
2453
|
}
|
|
@@ -2354,13 +2500,14 @@ function CurtainPreview({
|
|
|
2354
2500
|
url,
|
|
2355
2501
|
alt = "",
|
|
2356
2502
|
className,
|
|
2357
|
-
playWhenVisible = true
|
|
2503
|
+
playWhenVisible = true,
|
|
2504
|
+
frozen = false
|
|
2358
2505
|
}) {
|
|
2359
2506
|
const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
|
|
2360
2507
|
const video = isVideoKind(kind);
|
|
2361
|
-
const observe = playWhenVisible && video && !prefersReduced;
|
|
2508
|
+
const observe = !frozen && playWhenVisible && video && !prefersReduced;
|
|
2362
2509
|
const [setNode, inView] = useElementInView(observe);
|
|
2363
|
-
const shouldPlay = video && !prefersReduced && (!playWhenVisible || inView);
|
|
2510
|
+
const shouldPlay = !frozen && video && !prefersReduced && (!playWhenVisible || inView);
|
|
2364
2511
|
if (!url) {
|
|
2365
2512
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2366
2513
|
"div",
|
|
@@ -2442,13 +2589,43 @@ function groupHeading(group, copy) {
|
|
|
2442
2589
|
return headings[group];
|
|
2443
2590
|
}
|
|
2444
2591
|
function gridClass(variant) {
|
|
2445
|
-
return variant === "compact" ? "grid
|
|
2592
|
+
return variant === "compact" ? "grid grid-cols-3 gap-2 sm:grid-cols-4 lg:grid-cols-6" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
|
|
2593
|
+
}
|
|
2594
|
+
function selectionRing(selectable) {
|
|
2595
|
+
return selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2";
|
|
2596
|
+
}
|
|
2597
|
+
function resolvePreviewItem(selectedId, ready, allowNone) {
|
|
2598
|
+
if (selectedId) {
|
|
2599
|
+
return ready.find((curtain) => curtain.id === selectedId) ?? ready[0] ?? null;
|
|
2600
|
+
}
|
|
2601
|
+
if (allowNone) return null;
|
|
2602
|
+
return ready[0] ?? null;
|
|
2603
|
+
}
|
|
2604
|
+
function itemActions(item, onMakeDefault, onDelete, canMakeDefault, canDelete) {
|
|
2605
|
+
if (!item) return {};
|
|
2606
|
+
return {
|
|
2607
|
+
onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
|
|
2608
|
+
onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
|
|
2609
|
+
};
|
|
2446
2610
|
}
|
|
2447
2611
|
function CurtainPickerSkeleton({
|
|
2448
2612
|
count = 6,
|
|
2449
2613
|
variant = "default",
|
|
2450
2614
|
className
|
|
2451
2615
|
}) {
|
|
2616
|
+
if (variant === "compact") {
|
|
2617
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-4", className), "aria-hidden": "true", children: [
|
|
2618
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-sm space-y-3", children: [
|
|
2619
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2620
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
|
|
2621
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-1/2 rounded bg-skeleton" })
|
|
2622
|
+
] }),
|
|
2623
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: gridClass("compact"), children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "space-y-1.5 rounded-lg border p-1.5", children: [
|
|
2624
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2625
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-3/4 rounded bg-skeleton" })
|
|
2626
|
+
] }, index)) })
|
|
2627
|
+
] });
|
|
2628
|
+
}
|
|
2452
2629
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
|
|
2453
2630
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2454
2631
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
|
|
@@ -2475,9 +2652,20 @@ function CurtainPicker({
|
|
|
2475
2652
|
const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
|
|
2476
2653
|
const groupName = React7__namespace.useId();
|
|
2477
2654
|
const selectable = typeof onChange === "function";
|
|
2655
|
+
const compact = variant === "compact";
|
|
2478
2656
|
const selectedId = value === "" ? null : value ?? null;
|
|
2479
2657
|
const ready = curtains.filter((curtain) => curtain.publicUrl);
|
|
2480
2658
|
const showEmpty = ready.length === 0 && !allowNone;
|
|
2659
|
+
const previewItem = resolvePreviewItem(selectedId, ready, allowNone);
|
|
2660
|
+
const selectedItem = selectedId ? ready.find((curtain) => curtain.id === selectedId) ?? null : null;
|
|
2661
|
+
const actionTarget = selectedItem ?? (!selectable ? previewItem : null);
|
|
2662
|
+
const compactActions = compact ? itemActions(
|
|
2663
|
+
actionTarget,
|
|
2664
|
+
onMakeDefault,
|
|
2665
|
+
onDelete,
|
|
2666
|
+
canMakeDefault,
|
|
2667
|
+
canDelete
|
|
2668
|
+
) : {};
|
|
2481
2669
|
const grouped = React7__namespace.useMemo(() => {
|
|
2482
2670
|
if (!groupByOwner) {
|
|
2483
2671
|
return [{ group: null, items: ready }];
|
|
@@ -2505,46 +2693,174 @@ function CurtainPicker({
|
|
|
2505
2693
|
checked: selectedId === null,
|
|
2506
2694
|
disabled,
|
|
2507
2695
|
copy,
|
|
2696
|
+
compact,
|
|
2508
2697
|
onSelect: () => onChange(null)
|
|
2509
2698
|
}
|
|
2510
2699
|
) : null;
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2700
|
+
const sections = grouped.length === 0 && noneTile ? [{ group: null, items: [] }] : grouped;
|
|
2701
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(compact ? "space-y-4" : "space-y-6", className), children: [
|
|
2702
|
+
compact ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2703
|
+
SelectedPreview,
|
|
2704
|
+
{
|
|
2705
|
+
item: previewItem,
|
|
2706
|
+
copy,
|
|
2707
|
+
disabled,
|
|
2708
|
+
actionsPending,
|
|
2709
|
+
onMakeDefault: compactActions.onMakeDefault,
|
|
2710
|
+
onDelete: compactActions.onDelete
|
|
2711
|
+
}
|
|
2712
|
+
) : null,
|
|
2713
|
+
sections.map((section, index) => /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
|
|
2714
|
+
section.group ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
|
|
2715
|
+
/* @__PURE__ */ jsxRuntime.jsxs("ul", { className: gridClass(variant), children: [
|
|
2716
|
+
index === 0 && noneTile ? /* @__PURE__ */ jsxRuntime.jsx("li", { children: noneTile }) : null,
|
|
2717
|
+
section.items.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2718
|
+
CurtainPickerCard,
|
|
2719
|
+
{
|
|
2720
|
+
item,
|
|
2721
|
+
name: groupName,
|
|
2722
|
+
selectable,
|
|
2723
|
+
checked: selectedId === item.id,
|
|
2724
|
+
disabled,
|
|
2725
|
+
actionsPending,
|
|
2726
|
+
copy,
|
|
2727
|
+
compact,
|
|
2728
|
+
onSelect: onChange ? () => onChange(item.id) : void 0,
|
|
2729
|
+
onMakeDefault: compact ? void 0 : itemActions(
|
|
2730
|
+
item,
|
|
2731
|
+
onMakeDefault,
|
|
2732
|
+
onDelete,
|
|
2733
|
+
canMakeDefault,
|
|
2734
|
+
canDelete
|
|
2735
|
+
).onMakeDefault,
|
|
2736
|
+
onDelete: compact ? void 0 : itemActions(
|
|
2737
|
+
item,
|
|
2738
|
+
onMakeDefault,
|
|
2739
|
+
onDelete,
|
|
2740
|
+
canMakeDefault,
|
|
2741
|
+
canDelete
|
|
2742
|
+
).onDelete
|
|
2743
|
+
}
|
|
2744
|
+
) }, item.id))
|
|
2745
|
+
] })
|
|
2746
|
+
] }, section.group ?? "all"))
|
|
2747
|
+
] });
|
|
2748
|
+
}
|
|
2749
|
+
function SelectedPreview({
|
|
2750
|
+
item,
|
|
2751
|
+
copy,
|
|
2752
|
+
disabled,
|
|
2753
|
+
actionsPending,
|
|
2754
|
+
onMakeDefault,
|
|
2755
|
+
onDelete
|
|
2756
|
+
}) {
|
|
2757
|
+
const owner = item ? ownerLabel(item.ownerType, copy) : null;
|
|
2758
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-sm space-y-3", children: [
|
|
2759
|
+
item ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2760
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2761
|
+
CurtainPreview,
|
|
2520
2762
|
{
|
|
2521
|
-
item,
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
disabled,
|
|
2526
|
-
actionsPending,
|
|
2527
|
-
copy,
|
|
2528
|
-
onSelect: onChange ? () => onChange(item.id) : void 0,
|
|
2529
|
-
onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
|
|
2530
|
-
onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
|
|
2763
|
+
kind: item.kind,
|
|
2764
|
+
url: item.publicUrl,
|
|
2765
|
+
alt: "",
|
|
2766
|
+
className: "pointer-events-none"
|
|
2531
2767
|
}
|
|
2532
|
-
)
|
|
2533
|
-
|
|
2534
|
-
|
|
2768
|
+
),
|
|
2769
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2770
|
+
ItemMeta,
|
|
2771
|
+
{
|
|
2772
|
+
title: item.title,
|
|
2773
|
+
detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
|
|
2774
|
+
isDefault: item.isDefault,
|
|
2775
|
+
defaultBadge: copy.defaultBadge
|
|
2776
|
+
}
|
|
2777
|
+
)
|
|
2778
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2779
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2780
|
+
"div",
|
|
2781
|
+
{
|
|
2782
|
+
className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950",
|
|
2783
|
+
"aria-hidden": "true"
|
|
2784
|
+
}
|
|
2785
|
+
),
|
|
2786
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2787
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: copy.none }),
|
|
2788
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
|
|
2789
|
+
] })
|
|
2790
|
+
] }),
|
|
2791
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2792
|
+
ManageActions,
|
|
2793
|
+
{
|
|
2794
|
+
disabled,
|
|
2795
|
+
actionsPending,
|
|
2796
|
+
copy,
|
|
2797
|
+
onMakeDefault,
|
|
2798
|
+
onDelete
|
|
2799
|
+
}
|
|
2800
|
+
)
|
|
2801
|
+
] });
|
|
2802
|
+
}
|
|
2803
|
+
function ItemMeta({
|
|
2804
|
+
title,
|
|
2805
|
+
detail,
|
|
2806
|
+
isDefault,
|
|
2807
|
+
defaultBadge
|
|
2808
|
+
}) {
|
|
2809
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
2810
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
2811
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate font-medium", children: title }),
|
|
2812
|
+
detail ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: detail }) : null
|
|
2813
|
+
] }),
|
|
2814
|
+
isDefault ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: defaultBadge }) : null
|
|
2815
|
+
] });
|
|
2816
|
+
}
|
|
2817
|
+
function ManageActions({
|
|
2818
|
+
disabled,
|
|
2819
|
+
actionsPending,
|
|
2820
|
+
copy,
|
|
2821
|
+
onMakeDefault,
|
|
2822
|
+
onDelete
|
|
2823
|
+
}) {
|
|
2824
|
+
if (!onMakeDefault && !onDelete) return null;
|
|
2825
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
2826
|
+
onMakeDefault ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2827
|
+
Button,
|
|
2828
|
+
{
|
|
2829
|
+
type: "button",
|
|
2830
|
+
size: "sm",
|
|
2831
|
+
variant: "secondary",
|
|
2832
|
+
disabled: disabled || actionsPending,
|
|
2833
|
+
onClick: onMakeDefault,
|
|
2834
|
+
children: copy.makeDefault
|
|
2835
|
+
}
|
|
2836
|
+
) : null,
|
|
2837
|
+
onDelete ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2838
|
+
Button,
|
|
2839
|
+
{
|
|
2840
|
+
type: "button",
|
|
2841
|
+
size: "sm",
|
|
2842
|
+
variant: "destructive",
|
|
2843
|
+
disabled: disabled || actionsPending,
|
|
2844
|
+
onClick: onDelete,
|
|
2845
|
+
children: copy.delete
|
|
2846
|
+
}
|
|
2847
|
+
) : null
|
|
2848
|
+
] });
|
|
2535
2849
|
}
|
|
2536
2850
|
function NoneTile({
|
|
2537
2851
|
name,
|
|
2538
2852
|
checked,
|
|
2539
2853
|
disabled,
|
|
2540
2854
|
copy,
|
|
2855
|
+
compact,
|
|
2541
2856
|
onSelect
|
|
2542
2857
|
}) {
|
|
2543
2858
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2544
2859
|
"label",
|
|
2545
2860
|
{
|
|
2546
2861
|
className: cn(
|
|
2547
|
-
"block cursor-pointer
|
|
2862
|
+
"block cursor-pointer transition-shadow",
|
|
2863
|
+
compact ? "flex min-h-11 flex-col gap-1.5 rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
|
|
2548
2864
|
"has-[:checked]:ring-ring has-[:checked]:ring-2",
|
|
2549
2865
|
"has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
|
|
2550
2866
|
disabled && "pointer-events-none opacity-50"
|
|
@@ -2563,7 +2879,7 @@ function NoneTile({
|
|
|
2563
2879
|
}
|
|
2564
2880
|
),
|
|
2565
2881
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
2566
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2882
|
+
compact ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-xs font-medium", children: copy.none }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2567
2883
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: copy.none }),
|
|
2568
2884
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
|
|
2569
2885
|
] })
|
|
@@ -2579,25 +2895,36 @@ function CurtainPickerCard({
|
|
|
2579
2895
|
disabled,
|
|
2580
2896
|
actionsPending,
|
|
2581
2897
|
copy,
|
|
2898
|
+
compact,
|
|
2582
2899
|
onSelect,
|
|
2583
2900
|
onMakeDefault,
|
|
2584
2901
|
onDelete
|
|
2585
2902
|
}) {
|
|
2586
2903
|
const owner = ownerLabel(item.ownerType, copy);
|
|
2587
|
-
const media = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2904
|
+
const media = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2905
|
+
CurtainPreview,
|
|
2906
|
+
{
|
|
2907
|
+
kind: item.kind,
|
|
2908
|
+
url: item.publicUrl,
|
|
2909
|
+
alt: item.title,
|
|
2910
|
+
frozen: compact
|
|
2911
|
+
}
|
|
2912
|
+
);
|
|
2913
|
+
const meta = compact ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-xs font-medium", children: item.title }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2914
|
+
ItemMeta,
|
|
2915
|
+
{
|
|
2916
|
+
title: item.title,
|
|
2917
|
+
detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
|
|
2918
|
+
isDefault: item.isDefault,
|
|
2919
|
+
defaultBadge: copy.defaultBadge
|
|
2920
|
+
}
|
|
2921
|
+
);
|
|
2595
2922
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2596
2923
|
"div",
|
|
2597
2924
|
{
|
|
2598
2925
|
className: cn(
|
|
2599
|
-
"space-y-3 rounded-xl border p-4",
|
|
2600
|
-
selectable
|
|
2926
|
+
compact ? "rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
|
|
2927
|
+
selectionRing(selectable),
|
|
2601
2928
|
disabled && "opacity-50"
|
|
2602
2929
|
),
|
|
2603
2930
|
children: [
|
|
@@ -2605,7 +2932,7 @@ function CurtainPickerCard({
|
|
|
2605
2932
|
"label",
|
|
2606
2933
|
{
|
|
2607
2934
|
className: cn(
|
|
2608
|
-
"block space-y-3",
|
|
2935
|
+
compact ? "flex min-h-11 flex-col gap-1.5" : "block space-y-3",
|
|
2609
2936
|
disabled ? "pointer-events-none" : "cursor-pointer"
|
|
2610
2937
|
),
|
|
2611
2938
|
children: [
|
|
@@ -2625,34 +2952,20 @@ function CurtainPickerCard({
|
|
|
2625
2952
|
meta
|
|
2626
2953
|
]
|
|
2627
2954
|
}
|
|
2628
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
2955
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: compact ? "space-y-1.5" : "space-y-3", children: [
|
|
2629
2956
|
media,
|
|
2630
2957
|
meta
|
|
2631
2958
|
] }),
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
}
|
|
2643
|
-
) : null,
|
|
2644
|
-
onDelete ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2645
|
-
Button,
|
|
2646
|
-
{
|
|
2647
|
-
type: "button",
|
|
2648
|
-
size: "sm",
|
|
2649
|
-
variant: "destructive",
|
|
2650
|
-
disabled: disabled || actionsPending,
|
|
2651
|
-
onClick: onDelete,
|
|
2652
|
-
children: copy.delete
|
|
2653
|
-
}
|
|
2654
|
-
) : null
|
|
2655
|
-
] }) : null
|
|
2959
|
+
compact ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2960
|
+
ManageActions,
|
|
2961
|
+
{
|
|
2962
|
+
disabled,
|
|
2963
|
+
actionsPending,
|
|
2964
|
+
copy,
|
|
2965
|
+
onMakeDefault,
|
|
2966
|
+
onDelete
|
|
2967
|
+
}
|
|
2968
|
+
)
|
|
2656
2969
|
]
|
|
2657
2970
|
}
|
|
2658
2971
|
);
|
|
@@ -2702,6 +3015,7 @@ function WaitingRoom({
|
|
|
2702
3015
|
{
|
|
2703
3016
|
kind: curtain.kind,
|
|
2704
3017
|
url: curtain.url,
|
|
3018
|
+
allowSound: true,
|
|
2705
3019
|
className: "absolute inset-0"
|
|
2706
3020
|
}
|
|
2707
3021
|
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
@@ -3258,7 +3572,7 @@ function useHlsPlayback({
|
|
|
3258
3572
|
retry
|
|
3259
3573
|
};
|
|
3260
3574
|
}
|
|
3261
|
-
var
|
|
3575
|
+
var DEFAULT_LABELS3 = {
|
|
3262
3576
|
play: "Play",
|
|
3263
3577
|
pause: "Pause",
|
|
3264
3578
|
mute: "Mute",
|
|
@@ -3326,7 +3640,7 @@ function VideoPlayer({
|
|
|
3326
3640
|
fit = "aspect-video",
|
|
3327
3641
|
className
|
|
3328
3642
|
}) {
|
|
3329
|
-
const t = { ...
|
|
3643
|
+
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
3330
3644
|
const containerRef = React7__namespace.useRef(null);
|
|
3331
3645
|
const firstPlayFiredRef = React7__namespace.useRef(false);
|
|
3332
3646
|
const [userStarted, setUserStarted] = React7__namespace.useState(false);
|
|
@@ -4081,6 +4395,434 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4081
4395
|
return stats;
|
|
4082
4396
|
}
|
|
4083
4397
|
|
|
4398
|
+
// src/components/upload/part-math.ts
|
|
4399
|
+
function partRanges(fileSize, partSize) {
|
|
4400
|
+
if (partSize <= 0) {
|
|
4401
|
+
throw new Error("partSize must be greater than 0");
|
|
4402
|
+
}
|
|
4403
|
+
if (fileSize <= 0) {
|
|
4404
|
+
return [{ partNumber: 1, start: 0, end: 0 }];
|
|
4405
|
+
}
|
|
4406
|
+
const count = Math.ceil(fileSize / partSize);
|
|
4407
|
+
return Array.from({ length: count }, (_, index) => {
|
|
4408
|
+
const start = index * partSize;
|
|
4409
|
+
return {
|
|
4410
|
+
partNumber: index + 1,
|
|
4411
|
+
start,
|
|
4412
|
+
end: Math.min(fileSize, start + partSize)
|
|
4413
|
+
};
|
|
4414
|
+
});
|
|
4415
|
+
}
|
|
4416
|
+
function progressFromBytes(loaded, total) {
|
|
4417
|
+
const safeTotal = Math.max(0, total);
|
|
4418
|
+
const safeLoaded = Math.min(Math.max(0, loaded), safeTotal);
|
|
4419
|
+
const percent = safeTotal > 0 ? Math.round(safeLoaded / safeTotal * 100) : 0;
|
|
4420
|
+
return { loaded: safeLoaded, total: safeTotal, percent };
|
|
4421
|
+
}
|
|
4422
|
+
function fileMatchesAccept(file, accept) {
|
|
4423
|
+
if (!accept?.trim()) return true;
|
|
4424
|
+
const type = file.type.toLowerCase();
|
|
4425
|
+
const name = file.name.toLowerCase();
|
|
4426
|
+
return accept.split(",").some((token) => {
|
|
4427
|
+
const trimmed = token.trim().toLowerCase();
|
|
4428
|
+
if (!trimmed) return false;
|
|
4429
|
+
if (trimmed.endsWith("/*")) {
|
|
4430
|
+
return type.startsWith(trimmed.slice(0, -1));
|
|
4431
|
+
}
|
|
4432
|
+
if (trimmed.startsWith(".")) {
|
|
4433
|
+
return name.endsWith(trimmed);
|
|
4434
|
+
}
|
|
4435
|
+
return type === trimmed;
|
|
4436
|
+
});
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4439
|
+
// src/components/upload/types.ts
|
|
4440
|
+
var DEFAULT_FILE_DROPZONE_LABELS = {
|
|
4441
|
+
idle: "Drop a file here or browse",
|
|
4442
|
+
hint: "Click or press Enter to choose a file",
|
|
4443
|
+
browse: "Browse",
|
|
4444
|
+
rejectType: "This file type is not allowed",
|
|
4445
|
+
rejectSize: "This file is too large"
|
|
4446
|
+
};
|
|
4447
|
+
var DEFAULT_FILE_UPLOAD_TRAY_LABELS = {
|
|
4448
|
+
title: "Uploads",
|
|
4449
|
+
pause: "Pause",
|
|
4450
|
+
resume: "Resume",
|
|
4451
|
+
cancel: "Cancel",
|
|
4452
|
+
uploading: "Uploading",
|
|
4453
|
+
paused: "Paused",
|
|
4454
|
+
completing: "Finishing",
|
|
4455
|
+
completed: "Uploaded",
|
|
4456
|
+
cancelled: "Cancelled",
|
|
4457
|
+
error: "Failed"
|
|
4458
|
+
};
|
|
4459
|
+
var DEFAULT_FILE_UPLOAD_LABELS = {
|
|
4460
|
+
dropzone: DEFAULT_FILE_DROPZONE_LABELS,
|
|
4461
|
+
tray: DEFAULT_FILE_UPLOAD_TRAY_LABELS
|
|
4462
|
+
};
|
|
4463
|
+
function FileDropzone({
|
|
4464
|
+
accept,
|
|
4465
|
+
maxSize,
|
|
4466
|
+
disabled = false,
|
|
4467
|
+
labels: labelOverrides,
|
|
4468
|
+
onFile,
|
|
4469
|
+
onReject,
|
|
4470
|
+
className
|
|
4471
|
+
}) {
|
|
4472
|
+
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
4473
|
+
const inputId = React7.useId();
|
|
4474
|
+
const inputRef = React7.useRef(null);
|
|
4475
|
+
const [dragging, setDragging] = React7.useState(false);
|
|
4476
|
+
const [message, setMessage] = React7.useState(null);
|
|
4477
|
+
function takeFile(file) {
|
|
4478
|
+
if (!file || disabled) return;
|
|
4479
|
+
if (!fileMatchesAccept(file, accept)) {
|
|
4480
|
+
setMessage(labels.rejectType);
|
|
4481
|
+
onReject?.("type");
|
|
4482
|
+
return;
|
|
4483
|
+
}
|
|
4484
|
+
if (maxSize != null && file.size > maxSize) {
|
|
4485
|
+
setMessage(labels.rejectSize);
|
|
4486
|
+
onReject?.("size");
|
|
4487
|
+
return;
|
|
4488
|
+
}
|
|
4489
|
+
setMessage(null);
|
|
4490
|
+
onFile(file);
|
|
4491
|
+
}
|
|
4492
|
+
function onDrop(event) {
|
|
4493
|
+
event.preventDefault();
|
|
4494
|
+
setDragging(false);
|
|
4495
|
+
takeFile(event.dataTransfer.files[0]);
|
|
4496
|
+
}
|
|
4497
|
+
function onKeyDown(event) {
|
|
4498
|
+
if (disabled) return;
|
|
4499
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
4500
|
+
event.preventDefault();
|
|
4501
|
+
inputRef.current?.click();
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid gap-2", className), children: [
|
|
4505
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4506
|
+
"div",
|
|
4507
|
+
{
|
|
4508
|
+
role: "button",
|
|
4509
|
+
tabIndex: disabled ? -1 : 0,
|
|
4510
|
+
"aria-disabled": disabled,
|
|
4511
|
+
"aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
|
|
4512
|
+
"aria-controls": inputId,
|
|
4513
|
+
"data-dragging": dragging || void 0,
|
|
4514
|
+
className: cn(
|
|
4515
|
+
"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]",
|
|
4516
|
+
dragging && "border-primary bg-primary/5",
|
|
4517
|
+
disabled && "pointer-events-none opacity-50"
|
|
4518
|
+
),
|
|
4519
|
+
onClick: () => {
|
|
4520
|
+
if (!disabled) inputRef.current?.click();
|
|
4521
|
+
},
|
|
4522
|
+
onKeyDown,
|
|
4523
|
+
onDragEnter: (event) => {
|
|
4524
|
+
event.preventDefault();
|
|
4525
|
+
if (!disabled) setDragging(true);
|
|
4526
|
+
},
|
|
4527
|
+
onDragOver: (event) => {
|
|
4528
|
+
event.preventDefault();
|
|
4529
|
+
},
|
|
4530
|
+
onDragLeave: (event) => {
|
|
4531
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4534
|
+
setDragging(false);
|
|
4535
|
+
},
|
|
4536
|
+
onDrop,
|
|
4537
|
+
children: [
|
|
4538
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: labels.idle }),
|
|
4539
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4540
|
+
"p",
|
|
4541
|
+
{
|
|
4542
|
+
id: `${inputId}-hint`,
|
|
4543
|
+
className: "text-muted-foreground mt-1 text-xs",
|
|
4544
|
+
children: labels.hint
|
|
4545
|
+
}
|
|
4546
|
+
),
|
|
4547
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
|
|
4548
|
+
]
|
|
4549
|
+
}
|
|
4550
|
+
),
|
|
4551
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4552
|
+
"input",
|
|
4553
|
+
{
|
|
4554
|
+
id: inputId,
|
|
4555
|
+
ref: inputRef,
|
|
4556
|
+
type: "file",
|
|
4557
|
+
accept,
|
|
4558
|
+
disabled,
|
|
4559
|
+
"aria-label": labels.browse,
|
|
4560
|
+
className: "sr-only",
|
|
4561
|
+
onChange: (event) => {
|
|
4562
|
+
takeFile(event.target.files?.[0]);
|
|
4563
|
+
event.target.value = "";
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
),
|
|
4567
|
+
message ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4568
|
+
"p",
|
|
4569
|
+
{
|
|
4570
|
+
id: `${inputId}-message`,
|
|
4571
|
+
role: "alert",
|
|
4572
|
+
className: "text-destructive text-sm",
|
|
4573
|
+
children: message
|
|
4574
|
+
}
|
|
4575
|
+
) : null
|
|
4576
|
+
] });
|
|
4577
|
+
}
|
|
4578
|
+
function statusLabel(status, labels) {
|
|
4579
|
+
switch (status) {
|
|
4580
|
+
case "uploading":
|
|
4581
|
+
return labels.uploading;
|
|
4582
|
+
case "paused":
|
|
4583
|
+
return labels.paused;
|
|
4584
|
+
case "completing":
|
|
4585
|
+
return labels.completing;
|
|
4586
|
+
case "completed":
|
|
4587
|
+
return labels.completed;
|
|
4588
|
+
case "cancelled":
|
|
4589
|
+
return labels.cancelled;
|
|
4590
|
+
case "error":
|
|
4591
|
+
return labels.error;
|
|
4592
|
+
default: {
|
|
4593
|
+
const _exhaustive = status;
|
|
4594
|
+
return _exhaustive;
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
function FileUploadTray({
|
|
4599
|
+
jobs,
|
|
4600
|
+
labels: labelOverrides,
|
|
4601
|
+
onPause,
|
|
4602
|
+
onResume,
|
|
4603
|
+
onCancel,
|
|
4604
|
+
className
|
|
4605
|
+
}) {
|
|
4606
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4607
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4608
|
+
if (visible.length === 0) return null;
|
|
4609
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4610
|
+
"section",
|
|
4611
|
+
{
|
|
4612
|
+
"aria-label": labels.title,
|
|
4613
|
+
className: cn(
|
|
4614
|
+
"bg-background/95 supports-backdrop-filter:bg-background/80 fixed right-4 bottom-4 z-40 w-[min(100%-2rem,22rem)] rounded-xl border p-3 shadow-lg backdrop-blur",
|
|
4615
|
+
className
|
|
4616
|
+
),
|
|
4617
|
+
children: [
|
|
4618
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mb-2 text-sm font-medium", children: labels.title }),
|
|
4619
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid gap-3", children: visible.map((job) => {
|
|
4620
|
+
const active = job.status === "uploading" || job.status === "completing";
|
|
4621
|
+
const canPause = job.status === "uploading";
|
|
4622
|
+
const canResume = job.status === "paused";
|
|
4623
|
+
const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
|
|
4624
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "grid gap-1.5", children: [
|
|
4625
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4626
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: job.name }),
|
|
4627
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: statusLabel(job.status, labels) }),
|
|
4628
|
+
canPause ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4629
|
+
Button,
|
|
4630
|
+
{
|
|
4631
|
+
type: "button",
|
|
4632
|
+
variant: "ghost",
|
|
4633
|
+
size: "icon-sm",
|
|
4634
|
+
"aria-label": `${labels.pause} ${job.name}`,
|
|
4635
|
+
onClick: () => onPause(job.id),
|
|
4636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, {})
|
|
4637
|
+
}
|
|
4638
|
+
) : null,
|
|
4639
|
+
canResume ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4640
|
+
Button,
|
|
4641
|
+
{
|
|
4642
|
+
type: "button",
|
|
4643
|
+
variant: "ghost",
|
|
4644
|
+
size: "icon-sm",
|
|
4645
|
+
"aria-label": `${labels.resume} ${job.name}`,
|
|
4646
|
+
onClick: () => onResume(job.id),
|
|
4647
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, {})
|
|
4648
|
+
}
|
|
4649
|
+
) : null,
|
|
4650
|
+
canCancel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4651
|
+
Button,
|
|
4652
|
+
{
|
|
4653
|
+
type: "button",
|
|
4654
|
+
variant: "ghost",
|
|
4655
|
+
size: "icon-sm",
|
|
4656
|
+
"aria-label": `${labels.cancel} ${job.name}`,
|
|
4657
|
+
onClick: () => onCancel(job.id),
|
|
4658
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {})
|
|
4659
|
+
}
|
|
4660
|
+
) : null
|
|
4661
|
+
] }),
|
|
4662
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4663
|
+
"div",
|
|
4664
|
+
{
|
|
4665
|
+
role: "progressbar",
|
|
4666
|
+
"aria-valuemin": 0,
|
|
4667
|
+
"aria-valuemax": 100,
|
|
4668
|
+
"aria-valuenow": job.percent,
|
|
4669
|
+
"aria-label": job.name,
|
|
4670
|
+
className: "bg-muted h-2 overflow-hidden rounded-full",
|
|
4671
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4672
|
+
"div",
|
|
4673
|
+
{
|
|
4674
|
+
className: cn(
|
|
4675
|
+
"bg-primary h-full",
|
|
4676
|
+
active && "motion-safe:transition-[width]"
|
|
4677
|
+
),
|
|
4678
|
+
style: { width: `${job.percent}%` }
|
|
4679
|
+
}
|
|
4680
|
+
)
|
|
4681
|
+
}
|
|
4682
|
+
),
|
|
4683
|
+
job.error ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
|
|
4684
|
+
] }, job.id);
|
|
4685
|
+
}) })
|
|
4686
|
+
]
|
|
4687
|
+
}
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
|
|
4691
|
+
// src/components/upload/createMultipartUploadController.ts
|
|
4692
|
+
function readEtag(xhr) {
|
|
4693
|
+
const raw = xhr.getResponseHeader("ETag") ?? xhr.getResponseHeader("etag") ?? "";
|
|
4694
|
+
const etag = raw.trim();
|
|
4695
|
+
if (!etag) {
|
|
4696
|
+
throw new Error("Upload part missing ETag");
|
|
4697
|
+
}
|
|
4698
|
+
return etag;
|
|
4699
|
+
}
|
|
4700
|
+
function putPart(input) {
|
|
4701
|
+
return new Promise((resolve, reject) => {
|
|
4702
|
+
input.xhr.open("PUT", input.url);
|
|
4703
|
+
input.xhr.upload.onprogress = (event) => {
|
|
4704
|
+
input.onProgress(event.loaded);
|
|
4705
|
+
};
|
|
4706
|
+
input.xhr.onload = () => {
|
|
4707
|
+
if (input.xhr.status >= 200 && input.xhr.status < 300) {
|
|
4708
|
+
try {
|
|
4709
|
+
resolve(readEtag(input.xhr));
|
|
4710
|
+
} catch (error) {
|
|
4711
|
+
reject(error);
|
|
4712
|
+
}
|
|
4713
|
+
return;
|
|
4714
|
+
}
|
|
4715
|
+
reject(new Error(`Upload failed (${input.xhr.status})`));
|
|
4716
|
+
};
|
|
4717
|
+
input.xhr.onerror = () => {
|
|
4718
|
+
reject(new Error("Upload failed"));
|
|
4719
|
+
};
|
|
4720
|
+
input.xhr.onabort = () => {
|
|
4721
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
4722
|
+
};
|
|
4723
|
+
input.xhr.send(input.body);
|
|
4724
|
+
});
|
|
4725
|
+
}
|
|
4726
|
+
function createMultipartUploadController(options) {
|
|
4727
|
+
const ranges = partRanges(options.file.size, options.partSize);
|
|
4728
|
+
const completed = [];
|
|
4729
|
+
const state = { status: "idle" };
|
|
4730
|
+
let currentXhr = null;
|
|
4731
|
+
let run = null;
|
|
4732
|
+
let resumeIndex = 0;
|
|
4733
|
+
function currentStatus() {
|
|
4734
|
+
return state.status;
|
|
4735
|
+
}
|
|
4736
|
+
function isStopped() {
|
|
4737
|
+
const status = currentStatus();
|
|
4738
|
+
return status === "paused" || status === "cancelled";
|
|
4739
|
+
}
|
|
4740
|
+
function emitProgress(currentPartLoaded = 0) {
|
|
4741
|
+
const completedBytes = completed.reduce((sum, part) => {
|
|
4742
|
+
const range = ranges[part.partNumber - 1];
|
|
4743
|
+
return sum + (range ? range.end - range.start : 0);
|
|
4744
|
+
}, 0);
|
|
4745
|
+
options.onProgress?.(
|
|
4746
|
+
progressFromBytes(completedBytes + currentPartLoaded, options.file.size)
|
|
4747
|
+
);
|
|
4748
|
+
}
|
|
4749
|
+
async function uploadFrom(startIndex) {
|
|
4750
|
+
state.status = "uploading";
|
|
4751
|
+
for (let index = startIndex; index < ranges.length; index += 1) {
|
|
4752
|
+
if (state.status !== "uploading") return;
|
|
4753
|
+
resumeIndex = index;
|
|
4754
|
+
const range = ranges[index];
|
|
4755
|
+
if (!range) continue;
|
|
4756
|
+
const url = await options.adapter.requestPartUrl(range.partNumber);
|
|
4757
|
+
if (state.status !== "uploading") return;
|
|
4758
|
+
const xhr = options.xhrFactory ? options.xhrFactory() : new XMLHttpRequest();
|
|
4759
|
+
currentXhr = xhr;
|
|
4760
|
+
const body = options.file.slice(range.start, range.end);
|
|
4761
|
+
try {
|
|
4762
|
+
const etag = await putPart({
|
|
4763
|
+
url,
|
|
4764
|
+
body,
|
|
4765
|
+
xhr,
|
|
4766
|
+
onProgress: (loaded) => emitProgress(loaded)
|
|
4767
|
+
});
|
|
4768
|
+
completed.push({ partNumber: range.partNumber, etag });
|
|
4769
|
+
emitProgress(0);
|
|
4770
|
+
} catch (error) {
|
|
4771
|
+
currentXhr = null;
|
|
4772
|
+
if (isStopped()) return;
|
|
4773
|
+
state.status = "error";
|
|
4774
|
+
throw error;
|
|
4775
|
+
} finally {
|
|
4776
|
+
if (currentXhr === xhr) currentXhr = null;
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
if (state.status !== "uploading") return;
|
|
4780
|
+
state.status = "completing";
|
|
4781
|
+
await options.adapter.complete([...completed]);
|
|
4782
|
+
state.status = "completed";
|
|
4783
|
+
emitProgress(0);
|
|
4784
|
+
}
|
|
4785
|
+
async function start() {
|
|
4786
|
+
if (run) return run;
|
|
4787
|
+
run = uploadFrom(0).catch((error) => {
|
|
4788
|
+
if (isStopped()) return;
|
|
4789
|
+
state.status = "error";
|
|
4790
|
+
throw error;
|
|
4791
|
+
});
|
|
4792
|
+
return run;
|
|
4793
|
+
}
|
|
4794
|
+
function pause() {
|
|
4795
|
+
if (state.status !== "uploading") return;
|
|
4796
|
+
state.status = "paused";
|
|
4797
|
+
currentXhr?.abort();
|
|
4798
|
+
}
|
|
4799
|
+
async function resume() {
|
|
4800
|
+
if (state.status !== "paused") return;
|
|
4801
|
+
run = uploadFrom(resumeIndex).catch((error) => {
|
|
4802
|
+
if (isStopped()) return;
|
|
4803
|
+
state.status = "error";
|
|
4804
|
+
throw error;
|
|
4805
|
+
});
|
|
4806
|
+
return run;
|
|
4807
|
+
}
|
|
4808
|
+
async function cancel() {
|
|
4809
|
+
if (state.status === "completed" || state.status === "cancelled" || state.status === "idle") {
|
|
4810
|
+
state.status = "cancelled";
|
|
4811
|
+
return;
|
|
4812
|
+
}
|
|
4813
|
+
state.status = "cancelled";
|
|
4814
|
+
currentXhr?.abort();
|
|
4815
|
+
await options.adapter.abort?.();
|
|
4816
|
+
}
|
|
4817
|
+
return {
|
|
4818
|
+
start,
|
|
4819
|
+
pause,
|
|
4820
|
+
resume,
|
|
4821
|
+
cancel,
|
|
4822
|
+
getStatus: () => state.status
|
|
4823
|
+
};
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4084
4826
|
// src/lib/avatar.ts
|
|
4085
4827
|
var EMPTY_COLORS = {
|
|
4086
4828
|
backgroundColor: "#9ca3af",
|
|
@@ -4171,6 +4913,9 @@ exports.CurtainPreview = CurtainPreview;
|
|
|
4171
4913
|
exports.CurtainStage = CurtainStage;
|
|
4172
4914
|
exports.DEFAULT_CURTAIN_PICKER_LABELS = DEFAULT_CURTAIN_PICKER_LABELS;
|
|
4173
4915
|
exports.DEFAULT_EDITABLE_SECTION_LABELS = DEFAULT_EDITABLE_SECTION_LABELS;
|
|
4916
|
+
exports.DEFAULT_FILE_DROPZONE_LABELS = DEFAULT_FILE_DROPZONE_LABELS;
|
|
4917
|
+
exports.DEFAULT_FILE_UPLOAD_LABELS = DEFAULT_FILE_UPLOAD_LABELS;
|
|
4918
|
+
exports.DEFAULT_FILE_UPLOAD_TRAY_LABELS = DEFAULT_FILE_UPLOAD_TRAY_LABELS;
|
|
4174
4919
|
exports.DataList = DataList;
|
|
4175
4920
|
exports.DataListItem = DataListItem;
|
|
4176
4921
|
exports.EditableSection = EditableSection;
|
|
@@ -4184,6 +4929,8 @@ exports.EmptyTitle = EmptyTitle;
|
|
|
4184
4929
|
exports.ErrorState = ErrorState;
|
|
4185
4930
|
exports.FeedVideoPlayer = FeedVideoPlayer;
|
|
4186
4931
|
exports.FieldMessage = FieldMessage;
|
|
4932
|
+
exports.FileDropzone = FileDropzone;
|
|
4933
|
+
exports.FileUploadTray = FileUploadTray;
|
|
4187
4934
|
exports.LanguageContext = LanguageContext;
|
|
4188
4935
|
exports.LanguageSwitcher = LanguageSwitcher;
|
|
4189
4936
|
exports.LoadingState = LoadingState;
|
|
@@ -4195,13 +4942,17 @@ exports.avatarFallbackStyle = avatarFallbackStyle;
|
|
|
4195
4942
|
exports.castHlsUrl = castHlsUrl;
|
|
4196
4943
|
exports.cn = cn;
|
|
4197
4944
|
exports.createLiveHlsConfig = createLiveHlsConfig;
|
|
4945
|
+
exports.createMultipartUploadController = createMultipartUploadController;
|
|
4198
4946
|
exports.createVodHlsConfig = createVodHlsConfig;
|
|
4199
4947
|
exports.defaultLanguages = defaultLanguages;
|
|
4200
4948
|
exports.describeAvResync = describeAvResync;
|
|
4201
4949
|
exports.describePlaybackError = describePlaybackError;
|
|
4950
|
+
exports.fileMatchesAccept = fileMatchesAccept;
|
|
4202
4951
|
exports.getAvatarColors = getAvatarColors;
|
|
4203
4952
|
exports.getInitials = getInitials;
|
|
4204
4953
|
exports.loadCastSender = loadCastSender;
|
|
4954
|
+
exports.partRanges = partRanges;
|
|
4955
|
+
exports.progressFromBytes = progressFromBytes;
|
|
4205
4956
|
exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
|
|
4206
4957
|
exports.useEditableSection = useEditableSection;
|
|
4207
4958
|
exports.useFeedExclusivePlayback = useFeedExclusivePlayback;
|