@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.js
CHANGED
|
@@ -2232,6 +2232,37 @@ function AvatarEditorDialog({
|
|
|
2232
2232
|
] }) })
|
|
2233
2233
|
] });
|
|
2234
2234
|
}
|
|
2235
|
+
var DEFAULT_LABELS2 = {
|
|
2236
|
+
play: "Play",
|
|
2237
|
+
tapToUnmute: "Tap to unmute",
|
|
2238
|
+
mute: "Mute",
|
|
2239
|
+
unmute: "Unmute"
|
|
2240
|
+
};
|
|
2241
|
+
var CURTAIN_VIDEO_STYLE = `
|
|
2242
|
+
.livo-curtain-video::-webkit-media-controls-start-playback-button {
|
|
2243
|
+
display: none !important;
|
|
2244
|
+
-webkit-appearance: none;
|
|
2245
|
+
}
|
|
2246
|
+
.livo-curtain-video::-webkit-media-controls {
|
|
2247
|
+
display: none !important;
|
|
2248
|
+
}
|
|
2249
|
+
`;
|
|
2250
|
+
function isAudioTrackList(value) {
|
|
2251
|
+
return typeof value === "object" && value !== null && typeof value.getTrackById === "function";
|
|
2252
|
+
}
|
|
2253
|
+
function probeVideoAudio(el) {
|
|
2254
|
+
const video = el;
|
|
2255
|
+
if (typeof video.mozHasAudio === "boolean") {
|
|
2256
|
+
return video.mozHasAudio ? "yes" : "no";
|
|
2257
|
+
}
|
|
2258
|
+
if (typeof video.webkitAudioDecodedByteCount === "number" && video.webkitAudioDecodedByteCount > 0) {
|
|
2259
|
+
return "yes";
|
|
2260
|
+
}
|
|
2261
|
+
if (isAudioTrackList(video.audioTracks)) {
|
|
2262
|
+
return video.audioTracks.length > 0 ? "yes" : "no";
|
|
2263
|
+
}
|
|
2264
|
+
return "unknown";
|
|
2265
|
+
}
|
|
2235
2266
|
function usePrefersReducedMotion() {
|
|
2236
2267
|
const [reduced, setReduced] = React7.useState(false);
|
|
2237
2268
|
React7.useEffect(() => {
|
|
@@ -2243,39 +2274,154 @@ function usePrefersReducedMotion() {
|
|
|
2243
2274
|
}, []);
|
|
2244
2275
|
return reduced;
|
|
2245
2276
|
}
|
|
2246
|
-
function
|
|
2247
|
-
kind,
|
|
2277
|
+
function CurtainVideo({
|
|
2248
2278
|
url,
|
|
2249
|
-
alt
|
|
2279
|
+
alt,
|
|
2250
2280
|
className,
|
|
2251
|
-
|
|
2281
|
+
freeze,
|
|
2282
|
+
allowSound,
|
|
2283
|
+
labels
|
|
2252
2284
|
}) {
|
|
2253
|
-
const
|
|
2254
|
-
const
|
|
2255
|
-
|
|
2256
|
-
|
|
2285
|
+
const videoRef = React7.useRef(null);
|
|
2286
|
+
const [playback, setPlayback] = React7.useState("pending");
|
|
2287
|
+
const [muted, setMuted] = React7.useState(true);
|
|
2288
|
+
const [audio, setAudio] = React7.useState("unknown");
|
|
2289
|
+
React7.useEffect(() => {
|
|
2290
|
+
const el = videoRef.current;
|
|
2291
|
+
if (!el) return;
|
|
2292
|
+
el.setAttribute("webkit-playsinline", "");
|
|
2293
|
+
el.muted = true;
|
|
2294
|
+
setMuted(true);
|
|
2295
|
+
setAudio("unknown");
|
|
2296
|
+
setPlayback("pending");
|
|
2297
|
+
if (freeze) {
|
|
2298
|
+
el.pause();
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
let cancelled = false;
|
|
2302
|
+
const applyAudio = () => {
|
|
2303
|
+
const next = probeVideoAudio(el);
|
|
2304
|
+
if (next !== "unknown") setAudio(next);
|
|
2305
|
+
};
|
|
2306
|
+
const tryPlay = () => {
|
|
2307
|
+
if (cancelled) return;
|
|
2308
|
+
void el.play().then(
|
|
2309
|
+
() => {
|
|
2310
|
+
if (cancelled) return;
|
|
2311
|
+
setPlayback("playing");
|
|
2312
|
+
applyAudio();
|
|
2313
|
+
},
|
|
2314
|
+
() => {
|
|
2315
|
+
if (!cancelled && el.paused) setPlayback("blocked");
|
|
2316
|
+
}
|
|
2317
|
+
);
|
|
2318
|
+
};
|
|
2319
|
+
tryPlay();
|
|
2320
|
+
el.addEventListener("canplay", tryPlay);
|
|
2321
|
+
el.addEventListener("timeupdate", applyAudio);
|
|
2322
|
+
el.addEventListener("loadedmetadata", applyAudio);
|
|
2323
|
+
return () => {
|
|
2324
|
+
cancelled = true;
|
|
2325
|
+
el.removeEventListener("canplay", tryPlay);
|
|
2326
|
+
el.removeEventListener("timeupdate", applyAudio);
|
|
2327
|
+
el.removeEventListener("loadedmetadata", applyAudio);
|
|
2328
|
+
};
|
|
2329
|
+
}, [url, freeze]);
|
|
2330
|
+
const startPlayback = React7.useCallback(() => {
|
|
2331
|
+
const el = videoRef.current;
|
|
2332
|
+
if (!el) return;
|
|
2333
|
+
el.muted = true;
|
|
2334
|
+
setMuted(true);
|
|
2335
|
+
void el.play().then(
|
|
2336
|
+
() => {
|
|
2337
|
+
setPlayback("playing");
|
|
2338
|
+
const next = probeVideoAudio(el);
|
|
2339
|
+
if (next !== "unknown") setAudio(next);
|
|
2340
|
+
},
|
|
2341
|
+
() => {
|
|
2342
|
+
if (el.paused) setPlayback("blocked");
|
|
2343
|
+
}
|
|
2344
|
+
);
|
|
2345
|
+
}, []);
|
|
2346
|
+
const setVideoMuted = React7.useCallback((next) => {
|
|
2347
|
+
const el = videoRef.current;
|
|
2348
|
+
if (el) el.muted = next;
|
|
2349
|
+
setMuted(next);
|
|
2350
|
+
}, []);
|
|
2351
|
+
const showUnmute = allowSound && !freeze && playback === "playing" && muted && audio !== "no";
|
|
2352
|
+
const showMute = allowSound && !freeze && playback === "playing" && !muted;
|
|
2353
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative h-full w-full", className), children: [
|
|
2354
|
+
/* @__PURE__ */ jsx("style", { children: CURTAIN_VIDEO_STYLE }),
|
|
2355
|
+
/* @__PURE__ */ jsx(
|
|
2257
2356
|
"video",
|
|
2258
2357
|
{
|
|
2358
|
+
ref: videoRef,
|
|
2259
2359
|
src: url,
|
|
2260
|
-
className:
|
|
2261
|
-
autoPlay:
|
|
2262
|
-
muted
|
|
2263
|
-
loop:
|
|
2360
|
+
className: "livo-curtain-video h-full w-full object-cover",
|
|
2361
|
+
autoPlay: !freeze,
|
|
2362
|
+
muted,
|
|
2363
|
+
loop: !freeze,
|
|
2264
2364
|
playsInline: true,
|
|
2365
|
+
preload: freeze ? "metadata" : void 0,
|
|
2265
2366
|
"aria-hidden": alt ? void 0 : true
|
|
2266
2367
|
}
|
|
2267
|
-
)
|
|
2268
|
-
|
|
2269
|
-
|
|
2368
|
+
),
|
|
2369
|
+
playback === "blocked" && !freeze ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
|
|
2370
|
+
"button",
|
|
2371
|
+
{
|
|
2372
|
+
type: "button",
|
|
2373
|
+
"aria-label": labels.play,
|
|
2374
|
+
onClick: startPlayback,
|
|
2375
|
+
className: "flex size-16 items-center justify-center rounded-full bg-white/20 backdrop-blur-sm transition hover:bg-white/30",
|
|
2376
|
+
children: /* @__PURE__ */ jsx(Play, { className: "size-8 translate-x-0.5", fill: "currentColor" })
|
|
2377
|
+
}
|
|
2378
|
+
) }) : null,
|
|
2379
|
+
showUnmute ? /* @__PURE__ */ jsxs(
|
|
2380
|
+
"button",
|
|
2381
|
+
{
|
|
2382
|
+
type: "button",
|
|
2383
|
+
onClick: () => setVideoMuted(false),
|
|
2384
|
+
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",
|
|
2385
|
+
children: [
|
|
2386
|
+
/* @__PURE__ */ jsx(VolumeX, { className: "size-4" }),
|
|
2387
|
+
labels.tapToUnmute
|
|
2388
|
+
]
|
|
2389
|
+
}
|
|
2390
|
+
) : null,
|
|
2391
|
+
showMute ? /* @__PURE__ */ jsx(
|
|
2392
|
+
"button",
|
|
2393
|
+
{
|
|
2394
|
+
type: "button",
|
|
2395
|
+
"aria-label": labels.mute,
|
|
2396
|
+
onClick: () => setVideoMuted(true),
|
|
2397
|
+
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",
|
|
2398
|
+
children: /* @__PURE__ */ jsx(Volume2, { className: "size-4" })
|
|
2399
|
+
}
|
|
2400
|
+
) : null
|
|
2401
|
+
] });
|
|
2402
|
+
}
|
|
2403
|
+
function CurtainStage({
|
|
2404
|
+
kind,
|
|
2405
|
+
url,
|
|
2406
|
+
alt = "",
|
|
2407
|
+
className,
|
|
2408
|
+
reducedMotion,
|
|
2409
|
+
allowSound = false,
|
|
2410
|
+
labels
|
|
2411
|
+
}) {
|
|
2412
|
+
const prefersReduced = usePrefersReducedMotion();
|
|
2413
|
+
const freeze = reducedMotion ?? prefersReduced;
|
|
2414
|
+
const copy = { ...DEFAULT_LABELS2, ...labels };
|
|
2415
|
+
if (kind === "video") {
|
|
2270
2416
|
return /* @__PURE__ */ jsx(
|
|
2271
|
-
|
|
2417
|
+
CurtainVideo,
|
|
2272
2418
|
{
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2419
|
+
url,
|
|
2420
|
+
alt,
|
|
2421
|
+
className,
|
|
2422
|
+
freeze,
|
|
2423
|
+
allowSound,
|
|
2424
|
+
labels: copy
|
|
2279
2425
|
}
|
|
2280
2426
|
);
|
|
2281
2427
|
}
|
|
@@ -2328,13 +2474,14 @@ function CurtainPreview({
|
|
|
2328
2474
|
url,
|
|
2329
2475
|
alt = "",
|
|
2330
2476
|
className,
|
|
2331
|
-
playWhenVisible = true
|
|
2477
|
+
playWhenVisible = true,
|
|
2478
|
+
frozen = false
|
|
2332
2479
|
}) {
|
|
2333
2480
|
const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
|
|
2334
2481
|
const video = isVideoKind(kind);
|
|
2335
|
-
const observe = playWhenVisible && video && !prefersReduced;
|
|
2482
|
+
const observe = !frozen && playWhenVisible && video && !prefersReduced;
|
|
2336
2483
|
const [setNode, inView] = useElementInView(observe);
|
|
2337
|
-
const shouldPlay = video && !prefersReduced && (!playWhenVisible || inView);
|
|
2484
|
+
const shouldPlay = !frozen && video && !prefersReduced && (!playWhenVisible || inView);
|
|
2338
2485
|
if (!url) {
|
|
2339
2486
|
return /* @__PURE__ */ jsx(
|
|
2340
2487
|
"div",
|
|
@@ -2416,13 +2563,43 @@ function groupHeading(group, copy) {
|
|
|
2416
2563
|
return headings[group];
|
|
2417
2564
|
}
|
|
2418
2565
|
function gridClass(variant) {
|
|
2419
|
-
return variant === "compact" ? "grid
|
|
2566
|
+
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";
|
|
2567
|
+
}
|
|
2568
|
+
function selectionRing(selectable) {
|
|
2569
|
+
return selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2";
|
|
2570
|
+
}
|
|
2571
|
+
function resolvePreviewItem(selectedId, ready, allowNone) {
|
|
2572
|
+
if (selectedId) {
|
|
2573
|
+
return ready.find((curtain) => curtain.id === selectedId) ?? ready[0] ?? null;
|
|
2574
|
+
}
|
|
2575
|
+
if (allowNone) return null;
|
|
2576
|
+
return ready[0] ?? null;
|
|
2577
|
+
}
|
|
2578
|
+
function itemActions(item, onMakeDefault, onDelete, canMakeDefault, canDelete) {
|
|
2579
|
+
if (!item) return {};
|
|
2580
|
+
return {
|
|
2581
|
+
onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
|
|
2582
|
+
onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
|
|
2583
|
+
};
|
|
2420
2584
|
}
|
|
2421
2585
|
function CurtainPickerSkeleton({
|
|
2422
2586
|
count = 6,
|
|
2423
2587
|
variant = "default",
|
|
2424
2588
|
className
|
|
2425
2589
|
}) {
|
|
2590
|
+
if (variant === "compact") {
|
|
2591
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-4", className), "aria-hidden": "true", children: [
|
|
2592
|
+
/* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
|
|
2593
|
+
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2594
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
|
|
2595
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-skeleton" })
|
|
2596
|
+
] }),
|
|
2597
|
+
/* @__PURE__ */ jsx("ul", { className: gridClass("compact"), children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-1.5 rounded-lg border p-1.5", children: [
|
|
2598
|
+
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2599
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 w-3/4 rounded bg-skeleton" })
|
|
2600
|
+
] }, index)) })
|
|
2601
|
+
] });
|
|
2602
|
+
}
|
|
2426
2603
|
return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
|
|
2427
2604
|
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
|
|
2428
2605
|
/* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
|
|
@@ -2449,9 +2626,20 @@ function CurtainPicker({
|
|
|
2449
2626
|
const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
|
|
2450
2627
|
const groupName = React7.useId();
|
|
2451
2628
|
const selectable = typeof onChange === "function";
|
|
2629
|
+
const compact = variant === "compact";
|
|
2452
2630
|
const selectedId = value === "" ? null : value ?? null;
|
|
2453
2631
|
const ready = curtains.filter((curtain) => curtain.publicUrl);
|
|
2454
2632
|
const showEmpty = ready.length === 0 && !allowNone;
|
|
2633
|
+
const previewItem = resolvePreviewItem(selectedId, ready, allowNone);
|
|
2634
|
+
const selectedItem = selectedId ? ready.find((curtain) => curtain.id === selectedId) ?? null : null;
|
|
2635
|
+
const actionTarget = selectedItem ?? (!selectable ? previewItem : null);
|
|
2636
|
+
const compactActions = compact ? itemActions(
|
|
2637
|
+
actionTarget,
|
|
2638
|
+
onMakeDefault,
|
|
2639
|
+
onDelete,
|
|
2640
|
+
canMakeDefault,
|
|
2641
|
+
canDelete
|
|
2642
|
+
) : {};
|
|
2455
2643
|
const grouped = React7.useMemo(() => {
|
|
2456
2644
|
if (!groupByOwner) {
|
|
2457
2645
|
return [{ group: null, items: ready }];
|
|
@@ -2479,46 +2667,174 @@ function CurtainPicker({
|
|
|
2479
2667
|
checked: selectedId === null,
|
|
2480
2668
|
disabled,
|
|
2481
2669
|
copy,
|
|
2670
|
+
compact,
|
|
2482
2671
|
onSelect: () => onChange(null)
|
|
2483
2672
|
}
|
|
2484
2673
|
) : null;
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2674
|
+
const sections = grouped.length === 0 && noneTile ? [{ group: null, items: [] }] : grouped;
|
|
2675
|
+
return /* @__PURE__ */ jsxs("div", { className: cn(compact ? "space-y-4" : "space-y-6", className), children: [
|
|
2676
|
+
compact ? /* @__PURE__ */ jsx(
|
|
2677
|
+
SelectedPreview,
|
|
2678
|
+
{
|
|
2679
|
+
item: previewItem,
|
|
2680
|
+
copy,
|
|
2681
|
+
disabled,
|
|
2682
|
+
actionsPending,
|
|
2683
|
+
onMakeDefault: compactActions.onMakeDefault,
|
|
2684
|
+
onDelete: compactActions.onDelete
|
|
2685
|
+
}
|
|
2686
|
+
) : null,
|
|
2687
|
+
sections.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
|
|
2688
|
+
section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
|
|
2689
|
+
/* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
|
|
2690
|
+
index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
|
|
2691
|
+
section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
2692
|
+
CurtainPickerCard,
|
|
2693
|
+
{
|
|
2694
|
+
item,
|
|
2695
|
+
name: groupName,
|
|
2696
|
+
selectable,
|
|
2697
|
+
checked: selectedId === item.id,
|
|
2698
|
+
disabled,
|
|
2699
|
+
actionsPending,
|
|
2700
|
+
copy,
|
|
2701
|
+
compact,
|
|
2702
|
+
onSelect: onChange ? () => onChange(item.id) : void 0,
|
|
2703
|
+
onMakeDefault: compact ? void 0 : itemActions(
|
|
2704
|
+
item,
|
|
2705
|
+
onMakeDefault,
|
|
2706
|
+
onDelete,
|
|
2707
|
+
canMakeDefault,
|
|
2708
|
+
canDelete
|
|
2709
|
+
).onMakeDefault,
|
|
2710
|
+
onDelete: compact ? void 0 : itemActions(
|
|
2711
|
+
item,
|
|
2712
|
+
onMakeDefault,
|
|
2713
|
+
onDelete,
|
|
2714
|
+
canMakeDefault,
|
|
2715
|
+
canDelete
|
|
2716
|
+
).onDelete
|
|
2717
|
+
}
|
|
2718
|
+
) }, item.id))
|
|
2719
|
+
] })
|
|
2720
|
+
] }, section.group ?? "all"))
|
|
2721
|
+
] });
|
|
2722
|
+
}
|
|
2723
|
+
function SelectedPreview({
|
|
2724
|
+
item,
|
|
2725
|
+
copy,
|
|
2726
|
+
disabled,
|
|
2727
|
+
actionsPending,
|
|
2728
|
+
onMakeDefault,
|
|
2729
|
+
onDelete
|
|
2730
|
+
}) {
|
|
2731
|
+
const owner = item ? ownerLabel(item.ownerType, copy) : null;
|
|
2732
|
+
return /* @__PURE__ */ jsxs("div", { className: "max-w-sm space-y-3", children: [
|
|
2733
|
+
item ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2734
|
+
/* @__PURE__ */ jsx(
|
|
2735
|
+
CurtainPreview,
|
|
2494
2736
|
{
|
|
2495
|
-
item,
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
disabled,
|
|
2500
|
-
actionsPending,
|
|
2501
|
-
copy,
|
|
2502
|
-
onSelect: onChange ? () => onChange(item.id) : void 0,
|
|
2503
|
-
onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
|
|
2504
|
-
onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
|
|
2737
|
+
kind: item.kind,
|
|
2738
|
+
url: item.publicUrl,
|
|
2739
|
+
alt: "",
|
|
2740
|
+
className: "pointer-events-none"
|
|
2505
2741
|
}
|
|
2506
|
-
)
|
|
2507
|
-
|
|
2508
|
-
|
|
2742
|
+
),
|
|
2743
|
+
/* @__PURE__ */ jsx(
|
|
2744
|
+
ItemMeta,
|
|
2745
|
+
{
|
|
2746
|
+
title: item.title,
|
|
2747
|
+
detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
|
|
2748
|
+
isDefault: item.isDefault,
|
|
2749
|
+
defaultBadge: copy.defaultBadge
|
|
2750
|
+
}
|
|
2751
|
+
)
|
|
2752
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2753
|
+
/* @__PURE__ */ jsx(
|
|
2754
|
+
"div",
|
|
2755
|
+
{
|
|
2756
|
+
className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950",
|
|
2757
|
+
"aria-hidden": "true"
|
|
2758
|
+
}
|
|
2759
|
+
),
|
|
2760
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2761
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
|
|
2762
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
|
|
2763
|
+
] })
|
|
2764
|
+
] }),
|
|
2765
|
+
/* @__PURE__ */ jsx(
|
|
2766
|
+
ManageActions,
|
|
2767
|
+
{
|
|
2768
|
+
disabled,
|
|
2769
|
+
actionsPending,
|
|
2770
|
+
copy,
|
|
2771
|
+
onMakeDefault,
|
|
2772
|
+
onDelete
|
|
2773
|
+
}
|
|
2774
|
+
)
|
|
2775
|
+
] });
|
|
2776
|
+
}
|
|
2777
|
+
function ItemMeta({
|
|
2778
|
+
title,
|
|
2779
|
+
detail,
|
|
2780
|
+
isDefault,
|
|
2781
|
+
defaultBadge
|
|
2782
|
+
}) {
|
|
2783
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
2784
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
2785
|
+
/* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: title }),
|
|
2786
|
+
detail ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: detail }) : null
|
|
2787
|
+
] }),
|
|
2788
|
+
isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: defaultBadge }) : null
|
|
2789
|
+
] });
|
|
2790
|
+
}
|
|
2791
|
+
function ManageActions({
|
|
2792
|
+
disabled,
|
|
2793
|
+
actionsPending,
|
|
2794
|
+
copy,
|
|
2795
|
+
onMakeDefault,
|
|
2796
|
+
onDelete
|
|
2797
|
+
}) {
|
|
2798
|
+
if (!onMakeDefault && !onDelete) return null;
|
|
2799
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
2800
|
+
onMakeDefault ? /* @__PURE__ */ jsx(
|
|
2801
|
+
Button,
|
|
2802
|
+
{
|
|
2803
|
+
type: "button",
|
|
2804
|
+
size: "sm",
|
|
2805
|
+
variant: "secondary",
|
|
2806
|
+
disabled: disabled || actionsPending,
|
|
2807
|
+
onClick: onMakeDefault,
|
|
2808
|
+
children: copy.makeDefault
|
|
2809
|
+
}
|
|
2810
|
+
) : null,
|
|
2811
|
+
onDelete ? /* @__PURE__ */ jsx(
|
|
2812
|
+
Button,
|
|
2813
|
+
{
|
|
2814
|
+
type: "button",
|
|
2815
|
+
size: "sm",
|
|
2816
|
+
variant: "destructive",
|
|
2817
|
+
disabled: disabled || actionsPending,
|
|
2818
|
+
onClick: onDelete,
|
|
2819
|
+
children: copy.delete
|
|
2820
|
+
}
|
|
2821
|
+
) : null
|
|
2822
|
+
] });
|
|
2509
2823
|
}
|
|
2510
2824
|
function NoneTile({
|
|
2511
2825
|
name,
|
|
2512
2826
|
checked,
|
|
2513
2827
|
disabled,
|
|
2514
2828
|
copy,
|
|
2829
|
+
compact,
|
|
2515
2830
|
onSelect
|
|
2516
2831
|
}) {
|
|
2517
2832
|
return /* @__PURE__ */ jsxs(
|
|
2518
2833
|
"label",
|
|
2519
2834
|
{
|
|
2520
2835
|
className: cn(
|
|
2521
|
-
"block cursor-pointer
|
|
2836
|
+
"block cursor-pointer transition-shadow",
|
|
2837
|
+
compact ? "flex min-h-11 flex-col gap-1.5 rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
|
|
2522
2838
|
"has-[:checked]:ring-ring has-[:checked]:ring-2",
|
|
2523
2839
|
"has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
|
|
2524
2840
|
disabled && "pointer-events-none opacity-50"
|
|
@@ -2537,7 +2853,7 @@ function NoneTile({
|
|
|
2537
2853
|
}
|
|
2538
2854
|
),
|
|
2539
2855
|
/* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
2540
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2856
|
+
compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: copy.none }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
2541
2857
|
/* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
|
|
2542
2858
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
|
|
2543
2859
|
] })
|
|
@@ -2553,25 +2869,36 @@ function CurtainPickerCard({
|
|
|
2553
2869
|
disabled,
|
|
2554
2870
|
actionsPending,
|
|
2555
2871
|
copy,
|
|
2872
|
+
compact,
|
|
2556
2873
|
onSelect,
|
|
2557
2874
|
onMakeDefault,
|
|
2558
2875
|
onDelete
|
|
2559
2876
|
}) {
|
|
2560
2877
|
const owner = ownerLabel(item.ownerType, copy);
|
|
2561
|
-
const media = /* @__PURE__ */ jsx(
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2878
|
+
const media = /* @__PURE__ */ jsx(
|
|
2879
|
+
CurtainPreview,
|
|
2880
|
+
{
|
|
2881
|
+
kind: item.kind,
|
|
2882
|
+
url: item.publicUrl,
|
|
2883
|
+
alt: item.title,
|
|
2884
|
+
frozen: compact
|
|
2885
|
+
}
|
|
2886
|
+
);
|
|
2887
|
+
const meta = compact ? /* @__PURE__ */ jsx("p", { className: "truncate text-xs font-medium", children: item.title }) : /* @__PURE__ */ jsx(
|
|
2888
|
+
ItemMeta,
|
|
2889
|
+
{
|
|
2890
|
+
title: item.title,
|
|
2891
|
+
detail: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 "),
|
|
2892
|
+
isDefault: item.isDefault,
|
|
2893
|
+
defaultBadge: copy.defaultBadge
|
|
2894
|
+
}
|
|
2895
|
+
);
|
|
2569
2896
|
return /* @__PURE__ */ jsxs(
|
|
2570
2897
|
"div",
|
|
2571
2898
|
{
|
|
2572
2899
|
className: cn(
|
|
2573
|
-
"space-y-3 rounded-xl border p-4",
|
|
2574
|
-
selectable
|
|
2900
|
+
compact ? "rounded-lg border p-1.5" : "space-y-3 rounded-xl border p-4",
|
|
2901
|
+
selectionRing(selectable),
|
|
2575
2902
|
disabled && "opacity-50"
|
|
2576
2903
|
),
|
|
2577
2904
|
children: [
|
|
@@ -2579,7 +2906,7 @@ function CurtainPickerCard({
|
|
|
2579
2906
|
"label",
|
|
2580
2907
|
{
|
|
2581
2908
|
className: cn(
|
|
2582
|
-
"block space-y-3",
|
|
2909
|
+
compact ? "flex min-h-11 flex-col gap-1.5" : "block space-y-3",
|
|
2583
2910
|
disabled ? "pointer-events-none" : "cursor-pointer"
|
|
2584
2911
|
),
|
|
2585
2912
|
children: [
|
|
@@ -2599,34 +2926,20 @@ function CurtainPickerCard({
|
|
|
2599
2926
|
meta
|
|
2600
2927
|
]
|
|
2601
2928
|
}
|
|
2602
|
-
) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2929
|
+
) : /* @__PURE__ */ jsxs("div", { className: compact ? "space-y-1.5" : "space-y-3", children: [
|
|
2603
2930
|
media,
|
|
2604
2931
|
meta
|
|
2605
2932
|
] }),
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
}
|
|
2617
|
-
) : null,
|
|
2618
|
-
onDelete ? /* @__PURE__ */ jsx(
|
|
2619
|
-
Button,
|
|
2620
|
-
{
|
|
2621
|
-
type: "button",
|
|
2622
|
-
size: "sm",
|
|
2623
|
-
variant: "destructive",
|
|
2624
|
-
disabled: disabled || actionsPending,
|
|
2625
|
-
onClick: onDelete,
|
|
2626
|
-
children: copy.delete
|
|
2627
|
-
}
|
|
2628
|
-
) : null
|
|
2629
|
-
] }) : null
|
|
2933
|
+
compact ? null : /* @__PURE__ */ jsx(
|
|
2934
|
+
ManageActions,
|
|
2935
|
+
{
|
|
2936
|
+
disabled,
|
|
2937
|
+
actionsPending,
|
|
2938
|
+
copy,
|
|
2939
|
+
onMakeDefault,
|
|
2940
|
+
onDelete
|
|
2941
|
+
}
|
|
2942
|
+
)
|
|
2630
2943
|
]
|
|
2631
2944
|
}
|
|
2632
2945
|
);
|
|
@@ -2676,6 +2989,7 @@ function WaitingRoom({
|
|
|
2676
2989
|
{
|
|
2677
2990
|
kind: curtain.kind,
|
|
2678
2991
|
url: curtain.url,
|
|
2992
|
+
allowSound: true,
|
|
2679
2993
|
className: "absolute inset-0"
|
|
2680
2994
|
}
|
|
2681
2995
|
) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
|
|
@@ -3232,7 +3546,7 @@ function useHlsPlayback({
|
|
|
3232
3546
|
retry
|
|
3233
3547
|
};
|
|
3234
3548
|
}
|
|
3235
|
-
var
|
|
3549
|
+
var DEFAULT_LABELS3 = {
|
|
3236
3550
|
play: "Play",
|
|
3237
3551
|
pause: "Pause",
|
|
3238
3552
|
mute: "Mute",
|
|
@@ -3300,7 +3614,7 @@ function VideoPlayer({
|
|
|
3300
3614
|
fit = "aspect-video",
|
|
3301
3615
|
className
|
|
3302
3616
|
}) {
|
|
3303
|
-
const t = { ...
|
|
3617
|
+
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
3304
3618
|
const containerRef = React7.useRef(null);
|
|
3305
3619
|
const firstPlayFiredRef = React7.useRef(false);
|
|
3306
3620
|
const [userStarted, setUserStarted] = React7.useState(false);
|
|
@@ -4055,6 +4369,434 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
|
|
|
4055
4369
|
return stats;
|
|
4056
4370
|
}
|
|
4057
4371
|
|
|
4372
|
+
// src/components/upload/part-math.ts
|
|
4373
|
+
function partRanges(fileSize, partSize) {
|
|
4374
|
+
if (partSize <= 0) {
|
|
4375
|
+
throw new Error("partSize must be greater than 0");
|
|
4376
|
+
}
|
|
4377
|
+
if (fileSize <= 0) {
|
|
4378
|
+
return [{ partNumber: 1, start: 0, end: 0 }];
|
|
4379
|
+
}
|
|
4380
|
+
const count = Math.ceil(fileSize / partSize);
|
|
4381
|
+
return Array.from({ length: count }, (_, index) => {
|
|
4382
|
+
const start = index * partSize;
|
|
4383
|
+
return {
|
|
4384
|
+
partNumber: index + 1,
|
|
4385
|
+
start,
|
|
4386
|
+
end: Math.min(fileSize, start + partSize)
|
|
4387
|
+
};
|
|
4388
|
+
});
|
|
4389
|
+
}
|
|
4390
|
+
function progressFromBytes(loaded, total) {
|
|
4391
|
+
const safeTotal = Math.max(0, total);
|
|
4392
|
+
const safeLoaded = Math.min(Math.max(0, loaded), safeTotal);
|
|
4393
|
+
const percent = safeTotal > 0 ? Math.round(safeLoaded / safeTotal * 100) : 0;
|
|
4394
|
+
return { loaded: safeLoaded, total: safeTotal, percent };
|
|
4395
|
+
}
|
|
4396
|
+
function fileMatchesAccept(file, accept) {
|
|
4397
|
+
if (!accept?.trim()) return true;
|
|
4398
|
+
const type = file.type.toLowerCase();
|
|
4399
|
+
const name = file.name.toLowerCase();
|
|
4400
|
+
return accept.split(",").some((token) => {
|
|
4401
|
+
const trimmed = token.trim().toLowerCase();
|
|
4402
|
+
if (!trimmed) return false;
|
|
4403
|
+
if (trimmed.endsWith("/*")) {
|
|
4404
|
+
return type.startsWith(trimmed.slice(0, -1));
|
|
4405
|
+
}
|
|
4406
|
+
if (trimmed.startsWith(".")) {
|
|
4407
|
+
return name.endsWith(trimmed);
|
|
4408
|
+
}
|
|
4409
|
+
return type === trimmed;
|
|
4410
|
+
});
|
|
4411
|
+
}
|
|
4412
|
+
|
|
4413
|
+
// src/components/upload/types.ts
|
|
4414
|
+
var DEFAULT_FILE_DROPZONE_LABELS = {
|
|
4415
|
+
idle: "Drop a file here or browse",
|
|
4416
|
+
hint: "Click or press Enter to choose a file",
|
|
4417
|
+
browse: "Browse",
|
|
4418
|
+
rejectType: "This file type is not allowed",
|
|
4419
|
+
rejectSize: "This file is too large"
|
|
4420
|
+
};
|
|
4421
|
+
var DEFAULT_FILE_UPLOAD_TRAY_LABELS = {
|
|
4422
|
+
title: "Uploads",
|
|
4423
|
+
pause: "Pause",
|
|
4424
|
+
resume: "Resume",
|
|
4425
|
+
cancel: "Cancel",
|
|
4426
|
+
uploading: "Uploading",
|
|
4427
|
+
paused: "Paused",
|
|
4428
|
+
completing: "Finishing",
|
|
4429
|
+
completed: "Uploaded",
|
|
4430
|
+
cancelled: "Cancelled",
|
|
4431
|
+
error: "Failed"
|
|
4432
|
+
};
|
|
4433
|
+
var DEFAULT_FILE_UPLOAD_LABELS = {
|
|
4434
|
+
dropzone: DEFAULT_FILE_DROPZONE_LABELS,
|
|
4435
|
+
tray: DEFAULT_FILE_UPLOAD_TRAY_LABELS
|
|
4436
|
+
};
|
|
4437
|
+
function FileDropzone({
|
|
4438
|
+
accept,
|
|
4439
|
+
maxSize,
|
|
4440
|
+
disabled = false,
|
|
4441
|
+
labels: labelOverrides,
|
|
4442
|
+
onFile,
|
|
4443
|
+
onReject,
|
|
4444
|
+
className
|
|
4445
|
+
}) {
|
|
4446
|
+
const labels = { ...DEFAULT_FILE_DROPZONE_LABELS, ...labelOverrides };
|
|
4447
|
+
const inputId = useId();
|
|
4448
|
+
const inputRef = useRef(null);
|
|
4449
|
+
const [dragging, setDragging] = useState(false);
|
|
4450
|
+
const [message, setMessage] = useState(null);
|
|
4451
|
+
function takeFile(file) {
|
|
4452
|
+
if (!file || disabled) return;
|
|
4453
|
+
if (!fileMatchesAccept(file, accept)) {
|
|
4454
|
+
setMessage(labels.rejectType);
|
|
4455
|
+
onReject?.("type");
|
|
4456
|
+
return;
|
|
4457
|
+
}
|
|
4458
|
+
if (maxSize != null && file.size > maxSize) {
|
|
4459
|
+
setMessage(labels.rejectSize);
|
|
4460
|
+
onReject?.("size");
|
|
4461
|
+
return;
|
|
4462
|
+
}
|
|
4463
|
+
setMessage(null);
|
|
4464
|
+
onFile(file);
|
|
4465
|
+
}
|
|
4466
|
+
function onDrop(event) {
|
|
4467
|
+
event.preventDefault();
|
|
4468
|
+
setDragging(false);
|
|
4469
|
+
takeFile(event.dataTransfer.files[0]);
|
|
4470
|
+
}
|
|
4471
|
+
function onKeyDown(event) {
|
|
4472
|
+
if (disabled) return;
|
|
4473
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
4474
|
+
event.preventDefault();
|
|
4475
|
+
inputRef.current?.click();
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4478
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("grid gap-2", className), children: [
|
|
4479
|
+
/* @__PURE__ */ jsxs(
|
|
4480
|
+
"div",
|
|
4481
|
+
{
|
|
4482
|
+
role: "button",
|
|
4483
|
+
tabIndex: disabled ? -1 : 0,
|
|
4484
|
+
"aria-disabled": disabled,
|
|
4485
|
+
"aria-describedby": message ? `${inputId}-message` : `${inputId}-hint`,
|
|
4486
|
+
"aria-controls": inputId,
|
|
4487
|
+
"data-dragging": dragging || void 0,
|
|
4488
|
+
className: cn(
|
|
4489
|
+
"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]",
|
|
4490
|
+
dragging && "border-primary bg-primary/5",
|
|
4491
|
+
disabled && "pointer-events-none opacity-50"
|
|
4492
|
+
),
|
|
4493
|
+
onClick: () => {
|
|
4494
|
+
if (!disabled) inputRef.current?.click();
|
|
4495
|
+
},
|
|
4496
|
+
onKeyDown,
|
|
4497
|
+
onDragEnter: (event) => {
|
|
4498
|
+
event.preventDefault();
|
|
4499
|
+
if (!disabled) setDragging(true);
|
|
4500
|
+
},
|
|
4501
|
+
onDragOver: (event) => {
|
|
4502
|
+
event.preventDefault();
|
|
4503
|
+
},
|
|
4504
|
+
onDragLeave: (event) => {
|
|
4505
|
+
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
4506
|
+
return;
|
|
4507
|
+
}
|
|
4508
|
+
setDragging(false);
|
|
4509
|
+
},
|
|
4510
|
+
onDrop,
|
|
4511
|
+
children: [
|
|
4512
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: labels.idle }),
|
|
4513
|
+
/* @__PURE__ */ jsx(
|
|
4514
|
+
"p",
|
|
4515
|
+
{
|
|
4516
|
+
id: `${inputId}-hint`,
|
|
4517
|
+
className: "text-muted-foreground mt-1 text-xs",
|
|
4518
|
+
children: labels.hint
|
|
4519
|
+
}
|
|
4520
|
+
),
|
|
4521
|
+
/* @__PURE__ */ jsx("span", { className: "text-primary mt-3 inline-flex text-sm font-medium underline-offset-4", children: labels.browse })
|
|
4522
|
+
]
|
|
4523
|
+
}
|
|
4524
|
+
),
|
|
4525
|
+
/* @__PURE__ */ jsx(
|
|
4526
|
+
"input",
|
|
4527
|
+
{
|
|
4528
|
+
id: inputId,
|
|
4529
|
+
ref: inputRef,
|
|
4530
|
+
type: "file",
|
|
4531
|
+
accept,
|
|
4532
|
+
disabled,
|
|
4533
|
+
"aria-label": labels.browse,
|
|
4534
|
+
className: "sr-only",
|
|
4535
|
+
onChange: (event) => {
|
|
4536
|
+
takeFile(event.target.files?.[0]);
|
|
4537
|
+
event.target.value = "";
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
),
|
|
4541
|
+
message ? /* @__PURE__ */ jsx(
|
|
4542
|
+
"p",
|
|
4543
|
+
{
|
|
4544
|
+
id: `${inputId}-message`,
|
|
4545
|
+
role: "alert",
|
|
4546
|
+
className: "text-destructive text-sm",
|
|
4547
|
+
children: message
|
|
4548
|
+
}
|
|
4549
|
+
) : null
|
|
4550
|
+
] });
|
|
4551
|
+
}
|
|
4552
|
+
function statusLabel(status, labels) {
|
|
4553
|
+
switch (status) {
|
|
4554
|
+
case "uploading":
|
|
4555
|
+
return labels.uploading;
|
|
4556
|
+
case "paused":
|
|
4557
|
+
return labels.paused;
|
|
4558
|
+
case "completing":
|
|
4559
|
+
return labels.completing;
|
|
4560
|
+
case "completed":
|
|
4561
|
+
return labels.completed;
|
|
4562
|
+
case "cancelled":
|
|
4563
|
+
return labels.cancelled;
|
|
4564
|
+
case "error":
|
|
4565
|
+
return labels.error;
|
|
4566
|
+
default: {
|
|
4567
|
+
const _exhaustive = status;
|
|
4568
|
+
return _exhaustive;
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
function FileUploadTray({
|
|
4573
|
+
jobs,
|
|
4574
|
+
labels: labelOverrides,
|
|
4575
|
+
onPause,
|
|
4576
|
+
onResume,
|
|
4577
|
+
onCancel,
|
|
4578
|
+
className
|
|
4579
|
+
}) {
|
|
4580
|
+
const labels = { ...DEFAULT_FILE_UPLOAD_TRAY_LABELS, ...labelOverrides };
|
|
4581
|
+
const visible = jobs.filter((job) => job.status !== "cancelled");
|
|
4582
|
+
if (visible.length === 0) return null;
|
|
4583
|
+
return /* @__PURE__ */ jsxs(
|
|
4584
|
+
"section",
|
|
4585
|
+
{
|
|
4586
|
+
"aria-label": labels.title,
|
|
4587
|
+
className: cn(
|
|
4588
|
+
"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",
|
|
4589
|
+
className
|
|
4590
|
+
),
|
|
4591
|
+
children: [
|
|
4592
|
+
/* @__PURE__ */ jsx("h2", { className: "mb-2 text-sm font-medium", children: labels.title }),
|
|
4593
|
+
/* @__PURE__ */ jsx("ul", { className: "grid gap-3", children: visible.map((job) => {
|
|
4594
|
+
const active = job.status === "uploading" || job.status === "completing";
|
|
4595
|
+
const canPause = job.status === "uploading";
|
|
4596
|
+
const canResume = job.status === "paused";
|
|
4597
|
+
const canCancel = job.status === "uploading" || job.status === "paused" || job.status === "error";
|
|
4598
|
+
return /* @__PURE__ */ jsxs("li", { className: "grid gap-1.5", children: [
|
|
4599
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4600
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: job.name }),
|
|
4601
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: statusLabel(job.status, labels) }),
|
|
4602
|
+
canPause ? /* @__PURE__ */ jsx(
|
|
4603
|
+
Button,
|
|
4604
|
+
{
|
|
4605
|
+
type: "button",
|
|
4606
|
+
variant: "ghost",
|
|
4607
|
+
size: "icon-sm",
|
|
4608
|
+
"aria-label": `${labels.pause} ${job.name}`,
|
|
4609
|
+
onClick: () => onPause(job.id),
|
|
4610
|
+
children: /* @__PURE__ */ jsx(Pause, {})
|
|
4611
|
+
}
|
|
4612
|
+
) : null,
|
|
4613
|
+
canResume ? /* @__PURE__ */ jsx(
|
|
4614
|
+
Button,
|
|
4615
|
+
{
|
|
4616
|
+
type: "button",
|
|
4617
|
+
variant: "ghost",
|
|
4618
|
+
size: "icon-sm",
|
|
4619
|
+
"aria-label": `${labels.resume} ${job.name}`,
|
|
4620
|
+
onClick: () => onResume(job.id),
|
|
4621
|
+
children: /* @__PURE__ */ jsx(Play, {})
|
|
4622
|
+
}
|
|
4623
|
+
) : null,
|
|
4624
|
+
canCancel ? /* @__PURE__ */ jsx(
|
|
4625
|
+
Button,
|
|
4626
|
+
{
|
|
4627
|
+
type: "button",
|
|
4628
|
+
variant: "ghost",
|
|
4629
|
+
size: "icon-sm",
|
|
4630
|
+
"aria-label": `${labels.cancel} ${job.name}`,
|
|
4631
|
+
onClick: () => onCancel(job.id),
|
|
4632
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
4633
|
+
}
|
|
4634
|
+
) : null
|
|
4635
|
+
] }),
|
|
4636
|
+
/* @__PURE__ */ jsx(
|
|
4637
|
+
"div",
|
|
4638
|
+
{
|
|
4639
|
+
role: "progressbar",
|
|
4640
|
+
"aria-valuemin": 0,
|
|
4641
|
+
"aria-valuemax": 100,
|
|
4642
|
+
"aria-valuenow": job.percent,
|
|
4643
|
+
"aria-label": job.name,
|
|
4644
|
+
className: "bg-muted h-2 overflow-hidden rounded-full",
|
|
4645
|
+
children: /* @__PURE__ */ jsx(
|
|
4646
|
+
"div",
|
|
4647
|
+
{
|
|
4648
|
+
className: cn(
|
|
4649
|
+
"bg-primary h-full",
|
|
4650
|
+
active && "motion-safe:transition-[width]"
|
|
4651
|
+
),
|
|
4652
|
+
style: { width: `${job.percent}%` }
|
|
4653
|
+
}
|
|
4654
|
+
)
|
|
4655
|
+
}
|
|
4656
|
+
),
|
|
4657
|
+
job.error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-destructive text-xs", children: job.error }) : null
|
|
4658
|
+
] }, job.id);
|
|
4659
|
+
}) })
|
|
4660
|
+
]
|
|
4661
|
+
}
|
|
4662
|
+
);
|
|
4663
|
+
}
|
|
4664
|
+
|
|
4665
|
+
// src/components/upload/createMultipartUploadController.ts
|
|
4666
|
+
function readEtag(xhr) {
|
|
4667
|
+
const raw = xhr.getResponseHeader("ETag") ?? xhr.getResponseHeader("etag") ?? "";
|
|
4668
|
+
const etag = raw.trim();
|
|
4669
|
+
if (!etag) {
|
|
4670
|
+
throw new Error("Upload part missing ETag");
|
|
4671
|
+
}
|
|
4672
|
+
return etag;
|
|
4673
|
+
}
|
|
4674
|
+
function putPart(input) {
|
|
4675
|
+
return new Promise((resolve, reject) => {
|
|
4676
|
+
input.xhr.open("PUT", input.url);
|
|
4677
|
+
input.xhr.upload.onprogress = (event) => {
|
|
4678
|
+
input.onProgress(event.loaded);
|
|
4679
|
+
};
|
|
4680
|
+
input.xhr.onload = () => {
|
|
4681
|
+
if (input.xhr.status >= 200 && input.xhr.status < 300) {
|
|
4682
|
+
try {
|
|
4683
|
+
resolve(readEtag(input.xhr));
|
|
4684
|
+
} catch (error) {
|
|
4685
|
+
reject(error);
|
|
4686
|
+
}
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4689
|
+
reject(new Error(`Upload failed (${input.xhr.status})`));
|
|
4690
|
+
};
|
|
4691
|
+
input.xhr.onerror = () => {
|
|
4692
|
+
reject(new Error("Upload failed"));
|
|
4693
|
+
};
|
|
4694
|
+
input.xhr.onabort = () => {
|
|
4695
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
4696
|
+
};
|
|
4697
|
+
input.xhr.send(input.body);
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4700
|
+
function createMultipartUploadController(options) {
|
|
4701
|
+
const ranges = partRanges(options.file.size, options.partSize);
|
|
4702
|
+
const completed = [];
|
|
4703
|
+
const state = { status: "idle" };
|
|
4704
|
+
let currentXhr = null;
|
|
4705
|
+
let run = null;
|
|
4706
|
+
let resumeIndex = 0;
|
|
4707
|
+
function currentStatus() {
|
|
4708
|
+
return state.status;
|
|
4709
|
+
}
|
|
4710
|
+
function isStopped() {
|
|
4711
|
+
const status = currentStatus();
|
|
4712
|
+
return status === "paused" || status === "cancelled";
|
|
4713
|
+
}
|
|
4714
|
+
function emitProgress(currentPartLoaded = 0) {
|
|
4715
|
+
const completedBytes = completed.reduce((sum, part) => {
|
|
4716
|
+
const range = ranges[part.partNumber - 1];
|
|
4717
|
+
return sum + (range ? range.end - range.start : 0);
|
|
4718
|
+
}, 0);
|
|
4719
|
+
options.onProgress?.(
|
|
4720
|
+
progressFromBytes(completedBytes + currentPartLoaded, options.file.size)
|
|
4721
|
+
);
|
|
4722
|
+
}
|
|
4723
|
+
async function uploadFrom(startIndex) {
|
|
4724
|
+
state.status = "uploading";
|
|
4725
|
+
for (let index = startIndex; index < ranges.length; index += 1) {
|
|
4726
|
+
if (state.status !== "uploading") return;
|
|
4727
|
+
resumeIndex = index;
|
|
4728
|
+
const range = ranges[index];
|
|
4729
|
+
if (!range) continue;
|
|
4730
|
+
const url = await options.adapter.requestPartUrl(range.partNumber);
|
|
4731
|
+
if (state.status !== "uploading") return;
|
|
4732
|
+
const xhr = options.xhrFactory ? options.xhrFactory() : new XMLHttpRequest();
|
|
4733
|
+
currentXhr = xhr;
|
|
4734
|
+
const body = options.file.slice(range.start, range.end);
|
|
4735
|
+
try {
|
|
4736
|
+
const etag = await putPart({
|
|
4737
|
+
url,
|
|
4738
|
+
body,
|
|
4739
|
+
xhr,
|
|
4740
|
+
onProgress: (loaded) => emitProgress(loaded)
|
|
4741
|
+
});
|
|
4742
|
+
completed.push({ partNumber: range.partNumber, etag });
|
|
4743
|
+
emitProgress(0);
|
|
4744
|
+
} catch (error) {
|
|
4745
|
+
currentXhr = null;
|
|
4746
|
+
if (isStopped()) return;
|
|
4747
|
+
state.status = "error";
|
|
4748
|
+
throw error;
|
|
4749
|
+
} finally {
|
|
4750
|
+
if (currentXhr === xhr) currentXhr = null;
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
if (state.status !== "uploading") return;
|
|
4754
|
+
state.status = "completing";
|
|
4755
|
+
await options.adapter.complete([...completed]);
|
|
4756
|
+
state.status = "completed";
|
|
4757
|
+
emitProgress(0);
|
|
4758
|
+
}
|
|
4759
|
+
async function start() {
|
|
4760
|
+
if (run) return run;
|
|
4761
|
+
run = uploadFrom(0).catch((error) => {
|
|
4762
|
+
if (isStopped()) return;
|
|
4763
|
+
state.status = "error";
|
|
4764
|
+
throw error;
|
|
4765
|
+
});
|
|
4766
|
+
return run;
|
|
4767
|
+
}
|
|
4768
|
+
function pause() {
|
|
4769
|
+
if (state.status !== "uploading") return;
|
|
4770
|
+
state.status = "paused";
|
|
4771
|
+
currentXhr?.abort();
|
|
4772
|
+
}
|
|
4773
|
+
async function resume() {
|
|
4774
|
+
if (state.status !== "paused") return;
|
|
4775
|
+
run = uploadFrom(resumeIndex).catch((error) => {
|
|
4776
|
+
if (isStopped()) return;
|
|
4777
|
+
state.status = "error";
|
|
4778
|
+
throw error;
|
|
4779
|
+
});
|
|
4780
|
+
return run;
|
|
4781
|
+
}
|
|
4782
|
+
async function cancel() {
|
|
4783
|
+
if (state.status === "completed" || state.status === "cancelled" || state.status === "idle") {
|
|
4784
|
+
state.status = "cancelled";
|
|
4785
|
+
return;
|
|
4786
|
+
}
|
|
4787
|
+
state.status = "cancelled";
|
|
4788
|
+
currentXhr?.abort();
|
|
4789
|
+
await options.adapter.abort?.();
|
|
4790
|
+
}
|
|
4791
|
+
return {
|
|
4792
|
+
start,
|
|
4793
|
+
pause,
|
|
4794
|
+
resume,
|
|
4795
|
+
cancel,
|
|
4796
|
+
getStatus: () => state.status
|
|
4797
|
+
};
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4058
4800
|
// src/lib/avatar.ts
|
|
4059
4801
|
var EMPTY_COLORS = {
|
|
4060
4802
|
backgroundColor: "#9ca3af",
|
|
@@ -4136,6 +4878,6 @@ function avatarFallbackStyle(name) {
|
|
|
4136
4878
|
return getAvatarColors(name);
|
|
4137
4879
|
}
|
|
4138
4880
|
|
|
4139
|
-
export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
|
|
4881
|
+
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, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, FileDropzone, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, 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 };
|
|
4140
4882
|
//# sourceMappingURL=index.js.map
|
|
4141
4883
|
//# sourceMappingURL=index.js.map
|