@vivix-labs/media-tools 1.0.0-beta.6 → 1.0.0-beta.9
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/assets/crop-5JXWHIPN.svg +6 -0
- package/dist/assets/trim-LQMHHN2M.svg +9 -0
- package/dist/client.bundle.js +466 -138
- package/dist/client.css +383 -38
- package/dist/server.d.ts +1 -1
- package/dist/shared.d.ts +36 -2
- package/package.json +1 -1
package/dist/client.bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/media-tools/src/client.tsx
|
|
2
|
-
import * as
|
|
2
|
+
import * as React8 from "react";
|
|
3
3
|
|
|
4
4
|
// packages/media-tools/src/shared.ts
|
|
5
5
|
import { z, PluginError } from "vivix-studio/sdk/shared";
|
|
@@ -245,6 +245,8 @@ var iconGeometry = {
|
|
|
245
245
|
slot: 18
|
|
246
246
|
},
|
|
247
247
|
"select-items": { width: 13.8681, height: 13.8667, slot: 16 },
|
|
248
|
+
trim: { width: 14.85, height: 14.85, slot: 16 },
|
|
249
|
+
crop: { width: 16.25, height: 16.25, slot: 16 },
|
|
248
250
|
filter: { width: 13.2, height: 13.2, slot: 16 },
|
|
249
251
|
select: {
|
|
250
252
|
width: 14.6298,
|
|
@@ -389,6 +391,8 @@ var buttonVariants = {
|
|
|
389
391
|
"text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
|
|
390
392
|
"text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
|
|
391
393
|
"text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
|
|
394
|
+
"text-plain-sm": { size: 32, appearance: "plain", shape: "text" },
|
|
395
|
+
"text-link-sm": { size: 32, appearance: "link", shape: "text" },
|
|
392
396
|
"text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
|
|
393
397
|
"text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
|
|
394
398
|
// The medium recipes are shared by all dialog footer actions.
|
|
@@ -439,14 +443,20 @@ function SegmentedControl({ label, items, value, onValueChange, size = "medium",
|
|
|
439
443
|
return _jsx3("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs2("label", { children: [_jsx3("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs2("span", { className: "vx-segment-item", children: [item.icon && _jsx3(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
|
|
440
444
|
}
|
|
441
445
|
|
|
446
|
+
// packages/ui-system/dist/input.js
|
|
447
|
+
import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
|
|
448
|
+
function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", ...props }) {
|
|
449
|
+
return _jsxs3("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx4("span", { children: label }), _jsx4("input", { ...props, type: "text", value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
|
|
450
|
+
}
|
|
451
|
+
|
|
442
452
|
// packages/ui-system/dist/tag.js
|
|
443
|
-
import { jsx as
|
|
453
|
+
import { jsx as _jsx5 } from "react/jsx-runtime";
|
|
444
454
|
function Tag({ children, variant = "overlay", className }) {
|
|
445
|
-
return
|
|
455
|
+
return _jsx5("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
|
|
446
456
|
}
|
|
447
457
|
|
|
448
458
|
// packages/ui-system/dist/frame-range.js
|
|
449
|
-
import { jsx as
|
|
459
|
+
import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment } from "react/jsx-runtime";
|
|
450
460
|
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
451
461
|
function timeLabel(seconds) {
|
|
452
462
|
const whole = Math.floor(seconds);
|
|
@@ -485,12 +495,12 @@ function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant =
|
|
|
485
495
|
event.preventDefault();
|
|
486
496
|
move(edge, next);
|
|
487
497
|
}
|
|
488
|
-
return
|
|
498
|
+
return _jsxs4("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
|
|
489
499
|
"--vx-range-start": `${start / length * 100}%`,
|
|
490
500
|
"--vx-range-end": `${end / length * 100}%`
|
|
491
|
-
} : void 0, children: [frames?.length && length > 0 ?
|
|
501
|
+
} : void 0, children: [frames?.length && length > 0 ? _jsx6("div", { className: "vx-frame-filmstrip", children: frames.map((src, index) => _jsx6("img", { src, alt: "" }, index)) }) : thumbnail && length > 0 && _jsx6("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs4(_Fragment, { children: [_jsx6("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs4(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
|
|
492
502
|
const current = edge === "start" ? start : end;
|
|
493
|
-
return
|
|
503
|
+
return _jsx6("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
|
|
494
504
|
if (event.button !== 0)
|
|
495
505
|
return;
|
|
496
506
|
event.currentTarget.focus();
|
|
@@ -500,7 +510,7 @@ function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant =
|
|
|
500
510
|
}
|
|
501
511
|
|
|
502
512
|
// packages/ui-system/dist/dialog.js
|
|
503
|
-
import { jsx as
|
|
513
|
+
import { jsx as _jsx7, jsxs as _jsxs5, Fragment as _Fragment2 } from "react/jsx-runtime";
|
|
504
514
|
import { useId as useId2, useLayoutEffect, useRef, useState } from "react";
|
|
505
515
|
import { createPortal } from "react-dom";
|
|
506
516
|
|
|
@@ -553,7 +563,7 @@ function createDialogSurface(anchor) {
|
|
|
553
563
|
}
|
|
554
564
|
|
|
555
565
|
// packages/ui-system/dist/dialog.js
|
|
556
|
-
function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
|
|
566
|
+
function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default", focusTitleOnOpen = variant === "welcome" }) {
|
|
557
567
|
const ref = useRef(null);
|
|
558
568
|
const anchor = useRef(null);
|
|
559
569
|
const [surface, setSurface] = useState();
|
|
@@ -583,25 +593,45 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
|
|
|
583
593
|
dialog2.close();
|
|
584
594
|
};
|
|
585
595
|
}, [open, surface]);
|
|
586
|
-
const
|
|
596
|
+
const welcome = variant === "welcome";
|
|
597
|
+
const closeButton = _jsx7(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) });
|
|
598
|
+
const dialog = _jsxs5("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
|
|
587
599
|
event.preventDefault();
|
|
588
600
|
event.stopPropagation();
|
|
589
601
|
onOpenChange(false);
|
|
590
602
|
}, onClose: (event) => {
|
|
591
603
|
if (open && event.currentTarget.isConnected && !event.currentTarget.open)
|
|
592
604
|
onOpenChange(false);
|
|
593
|
-
}, children: [
|
|
594
|
-
return
|
|
605
|
+
}, children: [_jsxs5("header", { children: [_jsx7("h2", { id: heading, tabIndex: focusTitleOnOpen ? -1 : void 0, autoFocus: focusTitleOnOpen, children: title }), !welcome && closeButton] }), _jsx7("div", { className: "vx-dialog-body", children }), (actions || welcome) && _jsxs5("footer", { children: [actions, welcome && closeButton] })] });
|
|
606
|
+
return _jsxs5(_Fragment2, { children: [_jsx7("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
|
|
595
607
|
}
|
|
596
608
|
|
|
597
609
|
// packages/ui-system/dist/menu.js
|
|
598
|
-
import { jsx as
|
|
610
|
+
import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
599
611
|
import { useEffect, useId as useId3, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
600
612
|
import { createPortal as createPortal2 } from "react-dom";
|
|
613
|
+
function MenuPreview({ children }) {
|
|
614
|
+
const ref = useRef2(null);
|
|
615
|
+
const [visible, setVisible] = useState2(false);
|
|
616
|
+
useEffect(() => {
|
|
617
|
+
const node = ref.current;
|
|
618
|
+
if (!node)
|
|
619
|
+
return;
|
|
620
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
621
|
+
if (entry?.isIntersecting) {
|
|
622
|
+
setVisible(true);
|
|
623
|
+
observer.disconnect();
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
observer.observe(node);
|
|
627
|
+
return () => observer.disconnect();
|
|
628
|
+
}, []);
|
|
629
|
+
return _jsx8("span", { ref, className: "vx-menu-preview", "aria-hidden": "true", children: visible && children });
|
|
630
|
+
}
|
|
601
631
|
function isEnabled(item) {
|
|
602
632
|
return !item.disabled && item.items?.length !== 0;
|
|
603
633
|
}
|
|
604
|
-
function Menu({ label, items, triggerIcon, floating = false, cascading = false }) {
|
|
634
|
+
function Menu({ label, items, triggerIcon, textTrigger = "dropdown", floating = false, cascading = false }) {
|
|
605
635
|
const id = useId3();
|
|
606
636
|
const trigger = useRef2(null);
|
|
607
637
|
const popup = useRef2(null);
|
|
@@ -783,29 +813,29 @@ function Menu({ label, items, triggerIcon, floating = false, cascading = false }
|
|
|
783
813
|
focusOnOpen.current = false;
|
|
784
814
|
setPath(next);
|
|
785
815
|
}
|
|
786
|
-
const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null :
|
|
816
|
+
const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx8("div", { ref: !cascade || depth === 0 ? popup : (el) => {
|
|
787
817
|
if (el)
|
|
788
818
|
children.current.set(depth, el);
|
|
789
819
|
else
|
|
790
820
|
children.current.delete(depth);
|
|
791
|
-
}, className: "vx-action-menu-items", role: "menu", id: !cascade || !depth ? id : id + "-" + depth, "aria-label": menuLabel2, hidden: !path, onKeyDown: (e) => handleKey(e, depth), "data-floating": floating || void 0, style: floating && portalRoot ? cascade && depth ? {
|
|
821
|
+
}, className: "vx-action-menu-items", role: "menu", id: !cascade || !depth ? id : id + "-" + depth, "aria-label": menuLabel2, hidden: !path, onKeyDown: (e) => handleKey(e, depth), "data-with-previews": entries2.some((item) => item.preview) || void 0, "data-floating": floating || void 0, style: floating && portalRoot ? cascade && depth ? {
|
|
792
822
|
position: "fixed",
|
|
793
823
|
insetInlineStart: "auto",
|
|
794
824
|
visibility: "hidden",
|
|
795
825
|
maxHeight: "min(480px, calc(100dvh - 16px))",
|
|
796
826
|
zIndex: 100 + depth
|
|
797
|
-
} : placement : void 0, children: entries2.map((item) =>
|
|
827
|
+
} : placement : void 0, children: entries2.map((item) => _jsxs6("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-key": item.id, "aria-expanded": cascade && item.items ? path?.[depth] === item.id : void 0, onPointerEnter: cascade ? (e) => {
|
|
798
828
|
if (e.pointerType !== "touch")
|
|
799
829
|
hover(item, depth);
|
|
800
|
-
} : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon &&
|
|
801
|
-
return
|
|
830
|
+
} : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx8(Icon, { name: item.icon }), path && item.preview && _jsx8(MenuPreview, { children: item.preview }), _jsx8("span", { className: "vx-menu-label", children: item.label }), item.checked && _jsx8(Icon, { name: "check" }), item.items?.length ? _jsx8(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
|
|
831
|
+
return _jsxs6("div", { className: "vx-action-menu", onBlur: (event) => {
|
|
802
832
|
if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
|
|
803
833
|
setPath(null);
|
|
804
|
-
}, children: [triggerIcon ?
|
|
834
|
+
}, children: [triggerIcon ? _jsx8(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx8(Button, { ref: trigger, label, variant: textTrigger === "plain" ? "text-plain-sm" : "text-tonal-sm", trailingIcon: textTrigger === "dropdown" ? "chevron-down" : void 0, "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
|
|
805
835
|
}
|
|
806
836
|
|
|
807
837
|
// packages/ui-system/dist/video-player.js
|
|
808
|
-
import { jsx as
|
|
838
|
+
import { jsx as _jsx9, jsxs as _jsxs7, Fragment as _Fragment3 } from "react/jsx-runtime";
|
|
809
839
|
import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
|
|
810
840
|
function timeLabel2(seconds, padMinutes = false) {
|
|
811
841
|
const whole = Math.floor(seconds);
|
|
@@ -813,14 +843,14 @@ function timeLabel2(seconds, padMinutes = false) {
|
|
|
813
843
|
return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
|
|
814
844
|
}
|
|
815
845
|
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreenLabel = "Toggle fullscreen", actions, appearance = "on-content", timeDisplay = "combined" }) {
|
|
816
|
-
return
|
|
846
|
+
return _jsxs7("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-appearance": appearance, style: {
|
|
817
847
|
"--vx-playback-progress": `${duration > 0 ? Math.min(100, Math.max(0, time / duration * 100)) : 0}%`
|
|
818
|
-
}, children: [
|
|
848
|
+
}, children: [_jsx9(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx9("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), _jsx9("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsx9("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx9(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx9(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, onClick: onFullscreen })] });
|
|
819
849
|
}
|
|
820
850
|
function VideoPlayer(props) {
|
|
821
|
-
return
|
|
851
|
+
return _jsx9(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
|
|
822
852
|
}
|
|
823
|
-
function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, controlsSize, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
853
|
+
function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, showCoverInfo = true, showCoverPlay = true, fitExpandedContent = false, controlsSize, controlsAppearance, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
824
854
|
const root = useRef3(null);
|
|
825
855
|
const video = useRef3(null);
|
|
826
856
|
const position = useRef3(0);
|
|
@@ -832,6 +862,13 @@ function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version
|
|
|
832
862
|
const [muted, setMuted] = useState3(defaultMuted);
|
|
833
863
|
const [expanded, setExpanded] = useState3(false);
|
|
834
864
|
const [inlineHeight, setInlineHeight] = useState3();
|
|
865
|
+
const restoreFocus = useRef3(false);
|
|
866
|
+
useEffect2(() => {
|
|
867
|
+
if (!expanded && restoreFocus.current) {
|
|
868
|
+
restoreFocus.current = false;
|
|
869
|
+
root.current?.querySelector('button[aria-label="Expand video"]')?.focus();
|
|
870
|
+
}
|
|
871
|
+
}, [expanded]);
|
|
835
872
|
const restore = useRef3(void 0);
|
|
836
873
|
const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
|
|
837
874
|
const duration = src ? metadataDuration : stillDuration;
|
|
@@ -928,17 +965,20 @@ function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version
|
|
|
928
965
|
};
|
|
929
966
|
if (next)
|
|
930
967
|
setInlineHeight(root.current?.getBoundingClientRect().height);
|
|
968
|
+
else
|
|
969
|
+
restoreFocus.current = true;
|
|
931
970
|
element?.pause();
|
|
932
971
|
setExpanded(next);
|
|
933
972
|
}
|
|
934
|
-
const
|
|
973
|
+
const fitted = fitContent || expanded && fitExpandedContent;
|
|
974
|
+
const player = _jsxs7("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-fit": fitted ? "content" : void 0, style: fitted ? { "--vx-video-ratio": aspectRatio ?? ratio } : void 0, "data-placement": controlsPlacement, "data-controls-size": controlsSize, "data-state": state, children: [_jsxs7("div", { className: "vx-video-stage", style: aspectRatio ? { aspectRatio } : void 0, children: [src ? _jsx9("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onResize: (event) => {
|
|
935
975
|
const { videoWidth, videoHeight } = event.currentTarget;
|
|
936
|
-
if (
|
|
976
|
+
if (videoWidth && videoHeight)
|
|
937
977
|
setRatio(videoWidth / videoHeight);
|
|
938
978
|
}, onLoadedMetadata: (event) => {
|
|
939
979
|
const element = event.currentTarget;
|
|
940
980
|
const { videoWidth, videoHeight } = element;
|
|
941
|
-
if (
|
|
981
|
+
if (videoWidth && videoHeight)
|
|
942
982
|
setRatio(videoWidth / videoHeight);
|
|
943
983
|
const previous = restore.current;
|
|
944
984
|
if (!previous)
|
|
@@ -961,8 +1001,11 @@ function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version
|
|
|
961
1001
|
}, onTimeUpdate: (event) => {
|
|
962
1002
|
if (!restore.current)
|
|
963
1003
|
updateTime(event.currentTarget.currentTime);
|
|
964
|
-
}, onEnded, onError: (event) =>
|
|
965
|
-
|
|
1004
|
+
}, onEnded, onError: (event) => {
|
|
1005
|
+
if (event.currentTarget.error)
|
|
1006
|
+
onError?.(event.currentTarget.error);
|
|
1007
|
+
} }) : poster && _jsx9("img", { src: poster, alt: "" }), overlay, state === "cover" && !fitted && _jsxs7("div", { className: "vx-video-cover", "data-plain": !showCoverInfo || void 0, children: [showCoverInfo && _jsxs7("div", { className: "vx-video-info", children: [_jsxs7("div", { className: "vx-video-title", children: [_jsx9("strong", { title, children: title }), version && _jsx9(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs7("div", { className: "vx-video-meta", children: [durationLabel && _jsx9("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx9("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx9("span", { children: sceneLabel })] })] }), showCoverPlay && (src || duration > 0) && _jsx9(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx9(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, appearance: controlsAppearance, timeDisplay, actions: controlsActions, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen && !(expanded && fitExpandedContent) ? () => void toggleFullscreen() : void 0, fullscreenLabel: fullscreenMode === "dialog" ? expanded ? "Close expanded video" : "Expand video" : void 0 })] });
|
|
1008
|
+
return _jsxs7(_Fragment3, { children: [expanded ? _jsx9("div", { "aria-hidden": "true", style: { height: inlineHeight } }) : player, _jsx9(Dialog, { title, open: expanded, onOpenChange: changeExpanded, className: fitExpandedContent ? "vx-video-dialog vx-video-dialog-fit" : "vx-video-dialog", children: expanded && player })] });
|
|
966
1009
|
}
|
|
967
1010
|
|
|
968
1011
|
// packages/media-tools/src/ui/recipe-player.tsx
|
|
@@ -1581,8 +1624,259 @@ function VideoEditor({ input, mode, onApply, onClose }) {
|
|
|
1581
1624
|
);
|
|
1582
1625
|
}
|
|
1583
1626
|
|
|
1584
|
-
// packages/media-tools/src/ui/
|
|
1627
|
+
// packages/media-tools/src/ui/export-dialog.tsx
|
|
1585
1628
|
import * as React5 from "react";
|
|
1629
|
+
import { useEffect as useEffect6, useRef as useRef6, useState as useState7 } from "react";
|
|
1630
|
+
var terminal = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled", "interrupted"]);
|
|
1631
|
+
function VideoExport({
|
|
1632
|
+
title,
|
|
1633
|
+
preview,
|
|
1634
|
+
aspectRatio,
|
|
1635
|
+
canvas: canvas2,
|
|
1636
|
+
issue,
|
|
1637
|
+
legacyTracking,
|
|
1638
|
+
prepare,
|
|
1639
|
+
resolveDownload,
|
|
1640
|
+
onClose
|
|
1641
|
+
}) {
|
|
1642
|
+
const { client, instanceId } = useMediaClient();
|
|
1643
|
+
const storageKey = `studio-video-export:${client.project.id}:${instanceId}`;
|
|
1644
|
+
const [tracking, setTracking] = useState7(() => {
|
|
1645
|
+
try {
|
|
1646
|
+
const raw = localStorage.getItem(storageKey);
|
|
1647
|
+
const stored = raw ? JSON.parse(raw) : legacyTracking;
|
|
1648
|
+
const parsed = mediaRequest.safeParse(stored?.pending?.request);
|
|
1649
|
+
return {
|
|
1650
|
+
jobId: typeof stored?.jobId === "string" ? stored.jobId : void 0,
|
|
1651
|
+
pending: typeof stored?.pending?.key === "string" && parsed.success ? { key: stored.pending.key, request: parsed.data } : void 0,
|
|
1652
|
+
recoverIntent: raw ? void 0 : legacyTracking?.recoverIntent
|
|
1653
|
+
};
|
|
1654
|
+
} catch {
|
|
1655
|
+
return { jobId: void 0, pending: void 0, recoverIntent: void 0 };
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
const [name, setName] = useState7(title.slice(0, 196));
|
|
1659
|
+
const [job, setJob] = useState7();
|
|
1660
|
+
const [error, setError] = useState7("");
|
|
1661
|
+
const [pollError, setPollError] = useState7("");
|
|
1662
|
+
const [busy, setBusy] = useState7(false);
|
|
1663
|
+
const lock = useRef6(false);
|
|
1664
|
+
const cancelKey = useRef6(void 0);
|
|
1665
|
+
const { jobId, pending, recoverIntent } = tracking;
|
|
1666
|
+
const unresolved = Boolean(pending || recoverIntent);
|
|
1667
|
+
const active = Boolean(jobId && (!job || !terminal.has(job.state)));
|
|
1668
|
+
useEffect6(() => setName(title.slice(0, 196)), [title]);
|
|
1669
|
+
useEffect6(() => {
|
|
1670
|
+
if (!jobId || job && job.jobId === jobId && terminal.has(job.state)) return;
|
|
1671
|
+
let live = true;
|
|
1672
|
+
let timer;
|
|
1673
|
+
async function poll(id) {
|
|
1674
|
+
try {
|
|
1675
|
+
const result = await client.invoke(
|
|
1676
|
+
{ instanceId, operationId: "jobs.get" },
|
|
1677
|
+
{ jobId: id }
|
|
1678
|
+
);
|
|
1679
|
+
if (!live) return;
|
|
1680
|
+
updateJob(result);
|
|
1681
|
+
setPollError("");
|
|
1682
|
+
if (terminal.has(result.state)) return;
|
|
1683
|
+
} catch (error2) {
|
|
1684
|
+
if (live) setPollError(readableError(error2));
|
|
1685
|
+
}
|
|
1686
|
+
if (live) timer = setTimeout(() => void poll(id), 750);
|
|
1687
|
+
}
|
|
1688
|
+
void poll(jobId);
|
|
1689
|
+
return () => {
|
|
1690
|
+
live = false;
|
|
1691
|
+
clearTimeout(timer);
|
|
1692
|
+
};
|
|
1693
|
+
}, [client, instanceId, jobId, job?.state]);
|
|
1694
|
+
function updateJob(result) {
|
|
1695
|
+
setJob(
|
|
1696
|
+
(current) => current?.jobId === result.jobId && current.revision > result.revision ? current : result
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
function track(next) {
|
|
1700
|
+
try {
|
|
1701
|
+
localStorage.setItem(storageKey, JSON.stringify(next));
|
|
1702
|
+
} catch {
|
|
1703
|
+
}
|
|
1704
|
+
setTracking({ ...next, recoverIntent: void 0 });
|
|
1705
|
+
}
|
|
1706
|
+
async function act(run) {
|
|
1707
|
+
if (lock.current) return;
|
|
1708
|
+
lock.current = true;
|
|
1709
|
+
setBusy(true);
|
|
1710
|
+
setError("");
|
|
1711
|
+
try {
|
|
1712
|
+
await run();
|
|
1713
|
+
} catch (error2) {
|
|
1714
|
+
setError(readableError(error2));
|
|
1715
|
+
} finally {
|
|
1716
|
+
lock.current = false;
|
|
1717
|
+
setBusy(false);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
async function submit(intent) {
|
|
1721
|
+
track({ jobId, pending: intent });
|
|
1722
|
+
try {
|
|
1723
|
+
const result = await client.invoke(
|
|
1724
|
+
{ instanceId, operationId: intent.request.operation },
|
|
1725
|
+
intent.request.input,
|
|
1726
|
+
{ requestKey: intent.key }
|
|
1727
|
+
);
|
|
1728
|
+
setJob(void 0);
|
|
1729
|
+
track({ jobId: result.jobId, pending: void 0 });
|
|
1730
|
+
} catch (error2) {
|
|
1731
|
+
const code = error2 && typeof error2 === "object" && "code" in error2 ? error2.code : void 0;
|
|
1732
|
+
if (typeof code === "string" && !["EXECUTION_UNKNOWN", "OPERATION_CONTRACT_CHANGED", "TRANSPORT_UNKNOWN"].includes(code))
|
|
1733
|
+
track({ jobId, pending: void 0 });
|
|
1734
|
+
throw error2;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
async function findOriginal() {
|
|
1738
|
+
const original = pending ?? await recoverIntent?.();
|
|
1739
|
+
if (!original) return;
|
|
1740
|
+
const found = await client.invoke(
|
|
1741
|
+
{ instanceId, operationId: "jobs.list" },
|
|
1742
|
+
{
|
|
1743
|
+
request: {
|
|
1744
|
+
operation: original.request.operation,
|
|
1745
|
+
requestKey: original.key,
|
|
1746
|
+
intent: original.request.input
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
);
|
|
1750
|
+
if (!found.items[0]) throw Error("No accepted export was found. No new task was submitted.");
|
|
1751
|
+
updateJob(found.items[0]);
|
|
1752
|
+
track({ jobId: found.items[0].jobId, pending: void 0 });
|
|
1753
|
+
}
|
|
1754
|
+
async function exportVideo() {
|
|
1755
|
+
const outputName2 = name.trim().replace(/\.mp4$/i, "") + ".mp4";
|
|
1756
|
+
const input = await prepare();
|
|
1757
|
+
await submit({
|
|
1758
|
+
key: crypto.randomUUID(),
|
|
1759
|
+
request: { operation: "sequence.process", input: { ...input, outputName: outputName2 } }
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
const settings = [
|
|
1763
|
+
["Format", "MP4 \xB7 H.264"],
|
|
1764
|
+
["Aspect ratio", aspectRatio || (canvas2 ? `${canvas2.width}:${canvas2.height}` : "Match source")],
|
|
1765
|
+
["Resolution", canvas2 ? `${canvas2.width} \xD7 ${canvas2.height}` : "Match source"],
|
|
1766
|
+
["Frame rate", "Match source"],
|
|
1767
|
+
["Quality", "High"],
|
|
1768
|
+
["Audio", "Include source audio"]
|
|
1769
|
+
];
|
|
1770
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1771
|
+
Dialog,
|
|
1772
|
+
{
|
|
1773
|
+
open: true,
|
|
1774
|
+
title: "Export Settings",
|
|
1775
|
+
className: "mt-export-dialog",
|
|
1776
|
+
onOpenChange: (open) => {
|
|
1777
|
+
if (!open && !lock.current) onClose();
|
|
1778
|
+
},
|
|
1779
|
+
actions: /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
1780
|
+
Button,
|
|
1781
|
+
{
|
|
1782
|
+
label: jobId || unresolved ? "Close" : "Cancel",
|
|
1783
|
+
variant: "text-tonal-lg",
|
|
1784
|
+
width: "hug",
|
|
1785
|
+
onClick: onClose,
|
|
1786
|
+
disabled: busy
|
|
1787
|
+
}
|
|
1788
|
+
), /* @__PURE__ */ React5.createElement(
|
|
1789
|
+
Button,
|
|
1790
|
+
{
|
|
1791
|
+
label: "Export",
|
|
1792
|
+
variant: "text-filled-lg",
|
|
1793
|
+
width: "hug",
|
|
1794
|
+
disabled: busy || active || Boolean(unresolved || issue) || !name.trim().replace(/\.mp4$/i, "").trim(),
|
|
1795
|
+
onClick: () => void act(exportVideo)
|
|
1796
|
+
}
|
|
1797
|
+
))
|
|
1798
|
+
},
|
|
1799
|
+
/* @__PURE__ */ React5.createElement("div", { className: "mt-export-layout" }, /* @__PURE__ */ React5.createElement("div", { className: "mt-export-preview" }, preview), /* @__PURE__ */ React5.createElement("div", { className: "mt-export-options" }, /* @__PURE__ */ React5.createElement(
|
|
1800
|
+
TextInput,
|
|
1801
|
+
{
|
|
1802
|
+
label: "Title",
|
|
1803
|
+
maxLength: 196,
|
|
1804
|
+
value: name,
|
|
1805
|
+
onValueChange: setName,
|
|
1806
|
+
disabled: busy
|
|
1807
|
+
}
|
|
1808
|
+
), /* @__PURE__ */ React5.createElement("dl", null, settings.map(([label, value]) => /* @__PURE__ */ React5.createElement("div", { key: label }, /* @__PURE__ */ React5.createElement("dt", null, label), /* @__PURE__ */ React5.createElement("dd", null, value)))))),
|
|
1809
|
+
issue && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice" }, issue),
|
|
1810
|
+
busy && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-notice", role: "status" }, "Working\u2026"),
|
|
1811
|
+
unresolved && !busy && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, "Export outcome has not been confirmed.", /* @__PURE__ */ React5.createElement(
|
|
1812
|
+
Button,
|
|
1813
|
+
{
|
|
1814
|
+
label: "Find original export",
|
|
1815
|
+
variant: "text-ghost-sm",
|
|
1816
|
+
onClick: () => void act(findOriginal)
|
|
1817
|
+
}
|
|
1818
|
+
)),
|
|
1819
|
+
job && !unresolved && /* @__PURE__ */ React5.createElement("div", { className: "mt-export-status" }, /* @__PURE__ */ React5.createElement("span", { role: "status" }, "Export: ", job.state, active && job.progress != null ? ` \xB7 ${Math.min(99, Math.round(job.progress * 100))}%` : ""), active && /* @__PURE__ */ React5.createElement(
|
|
1820
|
+
Button,
|
|
1821
|
+
{
|
|
1822
|
+
label: "Cancel export",
|
|
1823
|
+
variant: "text-ghost-sm",
|
|
1824
|
+
disabled: busy || job.cancelRequested,
|
|
1825
|
+
onClick: () => void act(async () => {
|
|
1826
|
+
if (cancelKey.current?.jobId !== job.jobId)
|
|
1827
|
+
cancelKey.current = { jobId: job.jobId, key: crypto.randomUUID() };
|
|
1828
|
+
updateJob(
|
|
1829
|
+
await client.invoke(
|
|
1830
|
+
{ instanceId, operationId: "jobs.cancel" },
|
|
1831
|
+
{ jobId: job.jobId },
|
|
1832
|
+
{ requestKey: cancelKey.current.key }
|
|
1833
|
+
)
|
|
1834
|
+
);
|
|
1835
|
+
})
|
|
1836
|
+
}
|
|
1837
|
+
), !active && job.state !== "succeeded" && /* @__PURE__ */ React5.createElement(
|
|
1838
|
+
Button,
|
|
1839
|
+
{
|
|
1840
|
+
label: "Retry export",
|
|
1841
|
+
variant: "text-ghost-sm",
|
|
1842
|
+
disabled: busy || job.cleanupPending,
|
|
1843
|
+
onClick: () => void act(() => submit({ key: crypto.randomUUID(), request: job.retryRequest }))
|
|
1844
|
+
}
|
|
1845
|
+
), job.state === "succeeded" && job.result && /* @__PURE__ */ React5.createElement(
|
|
1846
|
+
Button,
|
|
1847
|
+
{
|
|
1848
|
+
label: "Download exported video",
|
|
1849
|
+
variant: "text-ghost-sm",
|
|
1850
|
+
disabled: busy,
|
|
1851
|
+
onClick: (event) => {
|
|
1852
|
+
const doc = event.currentTarget.ownerDocument;
|
|
1853
|
+
void act(async () => {
|
|
1854
|
+
const url = await resolveDownload(job.result);
|
|
1855
|
+
if (!url) throw Error("The exported video is unavailable.");
|
|
1856
|
+
const link = doc.createElement("a");
|
|
1857
|
+
link.href = url;
|
|
1858
|
+
link.download = job.outputName;
|
|
1859
|
+
link.click();
|
|
1860
|
+
});
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
), job.error && /* @__PURE__ */ React5.createElement("span", { className: "mt-export-error", role: "alert" }, job.error.message)),
|
|
1864
|
+
(error || pollError) && /* @__PURE__ */ React5.createElement("p", { className: "mt-export-error", role: "alert" }, error || pollError)
|
|
1865
|
+
);
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// packages/media-tools/src/ui/compare.tsx
|
|
1869
|
+
import * as React6 from "react";
|
|
1870
|
+
function inputKey(input) {
|
|
1871
|
+
const ref = input.kind === "source" ? input.file.source : input.editRef;
|
|
1872
|
+
return JSON.stringify([
|
|
1873
|
+
input.kind,
|
|
1874
|
+
ref.storeId,
|
|
1875
|
+
ref.objectId,
|
|
1876
|
+
ref.versionId,
|
|
1877
|
+
input.kind === "source" ? input.file.fileId : null
|
|
1878
|
+
]);
|
|
1879
|
+
}
|
|
1586
1880
|
function formatLabel(width, height) {
|
|
1587
1881
|
let a = width, b = height;
|
|
1588
1882
|
while (b) {
|
|
@@ -1600,12 +1894,12 @@ function Candidate({
|
|
|
1600
1894
|
emptyState
|
|
1601
1895
|
}) {
|
|
1602
1896
|
const { resolve } = useMediaClient();
|
|
1603
|
-
const [video, setVideo] =
|
|
1604
|
-
const [error, setError] =
|
|
1605
|
-
const [revision, setRevision] =
|
|
1897
|
+
const [video, setVideo] = React6.useState(null);
|
|
1898
|
+
const [error, setError] = React6.useState("");
|
|
1899
|
+
const [revision, setRevision] = React6.useState(0);
|
|
1606
1900
|
const title = slot.context?.shotName?.trim() || video?.name || "Video";
|
|
1607
1901
|
const identity = JSON.stringify(slot.input);
|
|
1608
|
-
|
|
1902
|
+
React6.useEffect(() => {
|
|
1609
1903
|
let active = true;
|
|
1610
1904
|
setVideo(null);
|
|
1611
1905
|
setError("");
|
|
@@ -1619,15 +1913,15 @@ function Candidate({
|
|
|
1619
1913
|
active = false;
|
|
1620
1914
|
};
|
|
1621
1915
|
}, [resolve, identity, revision]);
|
|
1622
|
-
return /* @__PURE__ */
|
|
1916
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("div", { className: "mt-compare-preview" }, replacing ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Choosing replacement\u2026") : !slot.input ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty" }, /* @__PURE__ */ React6.createElement("p", null, "No video selected."), emptyState ?? /* @__PURE__ */ React6.createElement(
|
|
1623
1917
|
Button,
|
|
1624
1918
|
{
|
|
1625
|
-
label: "
|
|
1626
|
-
variant: "text-
|
|
1919
|
+
label: "Select a shot",
|
|
1920
|
+
variant: "text-plain-sm",
|
|
1627
1921
|
width: "hug",
|
|
1628
1922
|
onClick: onChoose
|
|
1629
1923
|
}
|
|
1630
|
-
))
|
|
1924
|
+
)) : error ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "alert" }, /* @__PURE__ */ React6.createElement("p", null, error), /* @__PURE__ */ React6.createElement(
|
|
1631
1925
|
Button,
|
|
1632
1926
|
{
|
|
1633
1927
|
label: "Reload preview",
|
|
@@ -1635,29 +1929,30 @@ function Candidate({
|
|
|
1635
1929
|
width: "hug",
|
|
1636
1930
|
onClick: () => setRevision(revision + 1)
|
|
1637
1931
|
}
|
|
1638
|
-
)) : !video ? /* @__PURE__ */
|
|
1932
|
+
)) : !video ? /* @__PURE__ */ React6.createElement("div", { className: "mt-empty", role: "status" }, "Loading fixed video\u2026") : video.edited ? /* @__PURE__ */ React6.createElement(RecipePlayer, { video }) : /* @__PURE__ */ React6.createElement(
|
|
1639
1933
|
VideoPlayer,
|
|
1640
1934
|
{
|
|
1641
1935
|
src: video.previewUrl,
|
|
1642
1936
|
title,
|
|
1937
|
+
showCoverInfo: false,
|
|
1643
1938
|
controlsPlacement: "overlay",
|
|
1644
1939
|
onError: () => setError("This video could not be played. Reload its fixed preview.")
|
|
1645
1940
|
}
|
|
1646
|
-
)), /* @__PURE__ */
|
|
1941
|
+
)), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-caption" }, /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-heading" }, /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("strong", null, slot.input ? title : "Candidate"), video && /* @__PURE__ */ React6.createElement("span", null, "Variant ", video.versionNumber, video.edited ? " \xB7 Edited" : "")), menu), video?.colorInterpretation === "assumed-bt709" && /* @__PURE__ */ React6.createElement("span", null, "Color information is missing. Standard SDR colors are assumed; export may differ slightly.")), /* @__PURE__ */ React6.createElement("div", { className: "mt-candidate-context" }, slot.input && (video || slot.context?.spokenLine || slot.context?.hook || slot.context?.cta) && /* @__PURE__ */ React6.createElement("dl", null, slot.context?.spokenLine && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Spoken line"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.spokenLine)), slot.context?.hook && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Opening Hook"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.hook)), slot.context && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "CTA"), /* @__PURE__ */ React6.createElement("dd", null, slot.context.cta || "None")), video && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("dt", null, "Format"), /* @__PURE__ */ React6.createElement("dd", null, formatLabel(video.geometry.pixelRect.width, video.geometry.pixelRect.height)), /* @__PURE__ */ React6.createElement("dt", null, "Duration"), /* @__PURE__ */ React6.createElement("dd", null, Number((video.effectiveDurationMs / 1e3).toFixed(2)), "s")))));
|
|
1647
1942
|
}
|
|
1648
1943
|
function VideoCompare(props) {
|
|
1649
|
-
const [generation, setGeneration] =
|
|
1650
|
-
const [replacing, setReplacing] =
|
|
1651
|
-
const [error, setError] =
|
|
1652
|
-
const active =
|
|
1653
|
-
|
|
1944
|
+
const [generation, setGeneration] = React6.useState(0);
|
|
1945
|
+
const [replacing, setReplacing] = React6.useState(null);
|
|
1946
|
+
const [error, setError] = React6.useState("");
|
|
1947
|
+
const active = React6.useRef(true);
|
|
1948
|
+
React6.useEffect(() => {
|
|
1654
1949
|
active.current = true;
|
|
1655
1950
|
return () => {
|
|
1656
1951
|
active.current = false;
|
|
1657
1952
|
};
|
|
1658
1953
|
}, []);
|
|
1659
1954
|
if (props.slots.length < 2 || props.slots.length > 4 || new Set(props.slots.map((slot) => slot.id)).size !== props.slots.length)
|
|
1660
|
-
return /* @__PURE__ */
|
|
1955
|
+
return /* @__PURE__ */ React6.createElement("p", { role: "alert" }, "Compare requires two to four uniquely identified columns.");
|
|
1661
1956
|
const remove = (slot) => props.onSlotsChange(
|
|
1662
1957
|
props.slots.length > 2 ? props.slots.filter((value) => value.id !== slot.id) : props.slots.map((value) => value.id === slot.id ? { ...value, input: null } : value)
|
|
1663
1958
|
);
|
|
@@ -1677,91 +1972,118 @@ function VideoCompare(props) {
|
|
|
1677
1972
|
if (active.current) setReplacing(null);
|
|
1678
1973
|
}
|
|
1679
1974
|
}
|
|
1975
|
+
const slotKeys = props.slots.map(({ input }) => input && inputKey(input));
|
|
1680
1976
|
function candidateChoices(slot) {
|
|
1681
|
-
return (props.candidates || []).
|
|
1682
|
-
(candidate)
|
|
1683
|
-
|
|
1684
|
-
)
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1977
|
+
return (props.candidates || []).flatMap((candidate) => {
|
|
1978
|
+
const key = inputKey(candidate.input);
|
|
1979
|
+
const occupied = props.slots[slotKeys.indexOf(key)];
|
|
1980
|
+
if (occupied && (props.allowCandidateSwap ? occupied.id === slot.id : occupied.id !== slot.id))
|
|
1981
|
+
return [];
|
|
1982
|
+
return [
|
|
1983
|
+
{
|
|
1984
|
+
id: key,
|
|
1985
|
+
label: props.allowCandidateSwap && occupied ? "Swap with " + candidate.label : candidate.label,
|
|
1986
|
+
preview: candidate.preview,
|
|
1987
|
+
onSelect: () => props.onSlotsChange(
|
|
1988
|
+
props.slots.map((column) => {
|
|
1989
|
+
if (column.id === slot.id)
|
|
1990
|
+
return { ...column, input: candidate.input, context: candidate.context };
|
|
1991
|
+
if (column.id === occupied?.id)
|
|
1992
|
+
return { ...column, input: slot.input, context: slot.context };
|
|
1993
|
+
return column;
|
|
1994
|
+
})
|
|
1995
|
+
)
|
|
1996
|
+
}
|
|
1997
|
+
];
|
|
1998
|
+
});
|
|
1694
1999
|
}
|
|
1695
|
-
return /* @__PURE__ */
|
|
2000
|
+
return /* @__PURE__ */ React6.createElement("section", { className: "mt-compare", "aria-label": "Compare videos" }, error && /* @__PURE__ */ React6.createElement("p", { role: "alert", className: "mt-error" }, error), /* @__PURE__ */ React6.createElement(
|
|
1696
2001
|
"div",
|
|
1697
2002
|
{
|
|
1698
2003
|
className: "mt-compare-columns",
|
|
1699
2004
|
style: { gridTemplateColumns: `repeat(${props.slots.length}, minmax(240px,1fr))` }
|
|
1700
2005
|
},
|
|
1701
|
-
props.slots.map((slot, index) =>
|
|
1702
|
-
|
|
1703
|
-
{
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
2006
|
+
props.slots.map((slot, index) => {
|
|
2007
|
+
const replacements = candidateChoices(slot);
|
|
2008
|
+
return /* @__PURE__ */ React6.createElement("article", { className: "mt-compare-column", key: slot.id, "aria-label": `Video ${index + 1}` }, /* @__PURE__ */ React6.createElement(
|
|
2009
|
+
Candidate,
|
|
2010
|
+
{
|
|
2011
|
+
key: JSON.stringify([slot.id, slot.input, generation]),
|
|
2012
|
+
slot,
|
|
2013
|
+
replacing: replacing === slot.id,
|
|
2014
|
+
onChoose: () => void replace(slot),
|
|
2015
|
+
emptyState: props.candidates ? replacements.length || props.allowCandidateSwap ? /* @__PURE__ */ React6.createElement(
|
|
2016
|
+
Menu,
|
|
2017
|
+
{
|
|
2018
|
+
label: "Select a shot",
|
|
2019
|
+
textTrigger: "plain",
|
|
2020
|
+
floating: true,
|
|
2021
|
+
items: replacements
|
|
2022
|
+
}
|
|
2023
|
+
) : /* @__PURE__ */ React6.createElement("p", null, "No other candidates yet.") : void 0,
|
|
2024
|
+
menu: /* @__PURE__ */ React6.createElement(
|
|
2025
|
+
Menu,
|
|
2026
|
+
{
|
|
2027
|
+
label: `Options for video ${index + 1}`,
|
|
2028
|
+
triggerIcon: "more",
|
|
2029
|
+
cascading: props.allowCandidateSwap,
|
|
2030
|
+
floating: true,
|
|
2031
|
+
items: [
|
|
2032
|
+
...props.slotMenuItems?.(slot) ?? [],
|
|
2033
|
+
...props.candidates ? [
|
|
2034
|
+
{
|
|
2035
|
+
id: "replace",
|
|
2036
|
+
label: "Choose video",
|
|
2037
|
+
disabled: replacements.length === 0,
|
|
2038
|
+
items: replacements
|
|
2039
|
+
}
|
|
2040
|
+
] : [
|
|
2041
|
+
{
|
|
2042
|
+
id: "replace",
|
|
2043
|
+
label: slot.input ? "Replace" : "Choose video",
|
|
2044
|
+
disabled: replacing !== null,
|
|
2045
|
+
onSelect: () => void replace(slot)
|
|
2046
|
+
}
|
|
2047
|
+
],
|
|
2048
|
+
...slot.input ? [
|
|
2049
|
+
{
|
|
2050
|
+
id: "details",
|
|
2051
|
+
label: "Details",
|
|
2052
|
+
onSelect: () => {
|
|
2053
|
+
setGeneration((value) => value + 1);
|
|
2054
|
+
props.onOpenDetails(slot.input, {
|
|
2055
|
+
slots: props.slots,
|
|
2056
|
+
origin: props.origin
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
] : [],
|
|
1725
2061
|
{
|
|
1726
|
-
id: "
|
|
1727
|
-
label:
|
|
1728
|
-
disabled:
|
|
1729
|
-
onSelect: () =>
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
2062
|
+
id: "add-column",
|
|
2063
|
+
label: "Add column",
|
|
2064
|
+
disabled: props.slots.length >= 4,
|
|
2065
|
+
onSelect: () => props.onSlotsChange([
|
|
2066
|
+
...props.slots,
|
|
2067
|
+
{ id: crypto.randomUUID(), input: null }
|
|
2068
|
+
])
|
|
2069
|
+
},
|
|
1733
2070
|
{
|
|
1734
|
-
id: "
|
|
1735
|
-
label: "
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
props.onOpenDetails(slot.input, {
|
|
1739
|
-
slots: props.slots,
|
|
1740
|
-
origin: props.origin
|
|
1741
|
-
});
|
|
1742
|
-
}
|
|
2071
|
+
id: "remove",
|
|
2072
|
+
label: "Remove",
|
|
2073
|
+
tone: "danger",
|
|
2074
|
+
onSelect: () => remove(slot)
|
|
1743
2075
|
}
|
|
1744
|
-
]
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
...props.slots,
|
|
1751
|
-
{ id: crypto.randomUUID(), input: null }
|
|
1752
|
-
])
|
|
1753
|
-
},
|
|
1754
|
-
{ id: "remove", label: "Remove", onSelect: () => remove(slot) }
|
|
1755
|
-
]
|
|
1756
|
-
}
|
|
1757
|
-
)
|
|
1758
|
-
}
|
|
1759
|
-
), slot.input && props.renderSlotActions && /* @__PURE__ */ React5.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot))))
|
|
2076
|
+
]
|
|
2077
|
+
}
|
|
2078
|
+
)
|
|
2079
|
+
}
|
|
2080
|
+
), slot.input && props.renderSlotActions && /* @__PURE__ */ React6.createElement("div", { className: "mt-column-actions" }, props.renderSlotActions(slot)));
|
|
2081
|
+
})
|
|
1760
2082
|
));
|
|
1761
2083
|
}
|
|
1762
2084
|
|
|
1763
2085
|
// packages/media-tools/src/ui/jobs.tsx
|
|
1764
|
-
import * as
|
|
2086
|
+
import * as React7 from "react";
|
|
1765
2087
|
var labels = {
|
|
1766
2088
|
queued: "Queued",
|
|
1767
2089
|
running: "Processing",
|
|
@@ -1773,20 +2095,20 @@ var labels = {
|
|
|
1773
2095
|
};
|
|
1774
2096
|
function MediaJobs({ onOpenResult }) {
|
|
1775
2097
|
const { client, instanceId } = useMediaClient();
|
|
1776
|
-
const [page, setPage] =
|
|
1777
|
-
const [offset, setOffset] =
|
|
1778
|
-
const [refresh, setRefresh] =
|
|
1779
|
-
const [error, setError] =
|
|
1780
|
-
const [pending, setPending] =
|
|
1781
|
-
const keys =
|
|
1782
|
-
const live =
|
|
1783
|
-
|
|
2098
|
+
const [page, setPage] = React7.useState({ items: [], nextOffset: null });
|
|
2099
|
+
const [offset, setOffset] = React7.useState(0);
|
|
2100
|
+
const [refresh, setRefresh] = React7.useState(0);
|
|
2101
|
+
const [error, setError] = React7.useState("");
|
|
2102
|
+
const [pending, setPending] = React7.useState(null);
|
|
2103
|
+
const keys = React7.useRef(/* @__PURE__ */ new Map());
|
|
2104
|
+
const live = React7.useRef(true);
|
|
2105
|
+
React7.useEffect(() => {
|
|
1784
2106
|
live.current = true;
|
|
1785
2107
|
return () => {
|
|
1786
2108
|
live.current = false;
|
|
1787
2109
|
};
|
|
1788
2110
|
}, []);
|
|
1789
|
-
|
|
2111
|
+
React7.useEffect(() => {
|
|
1790
2112
|
let active = true, timer;
|
|
1791
2113
|
async function poll() {
|
|
1792
2114
|
try {
|
|
@@ -1836,7 +2158,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1836
2158
|
if (live.current) setPending(null);
|
|
1837
2159
|
}
|
|
1838
2160
|
}
|
|
1839
|
-
return /* @__PURE__ */
|
|
2161
|
+
return /* @__PURE__ */ React7.createElement("section", { className: "mt-jobs", "aria-label": "Media tasks" }, /* @__PURE__ */ React7.createElement("div", { className: "mt-toolbar" }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h2", null, "Media tasks"), /* @__PURE__ */ React7.createElement("p", { className: "mt-help" }, "Processing continues when this page closes.")), /* @__PURE__ */ React7.createElement(
|
|
1840
2162
|
Button,
|
|
1841
2163
|
{
|
|
1842
2164
|
label: "Refresh tasks",
|
|
@@ -1844,14 +2166,14 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1844
2166
|
width: "hug",
|
|
1845
2167
|
onClick: () => setRefresh(refresh + 1)
|
|
1846
2168
|
}
|
|
1847
|
-
)), error && /* @__PURE__ */
|
|
2169
|
+
)), error && /* @__PURE__ */ React7.createElement("p", { role: "alert", className: "mt-error" }, error), !page.items.length && /* @__PURE__ */ React7.createElement("p", { className: "mt-empty" }, "No media tasks on this page."), page.items.map((job) => /* @__PURE__ */ React7.createElement("article", { className: "mt-job", key: job.jobId }, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("strong", null, job.outputName), /* @__PURE__ */ React7.createElement("p", null, job.kind === "sequence" ? "Sequence export" : "Video processing", " \xB7", " ", job.cancelRequested && !["succeeded", "failed", "canceled", "interrupted"].includes(job.state) ? "Stopping\u2026" : labels[job.state]), job.cleanupPending && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, "Cleanup is pending. New processing is blocked until the old process is confirmed stopped."), job.error && /* @__PURE__ */ React7.createElement("p", { className: "mt-error" }, job.error.message)), /* @__PURE__ */ React7.createElement("div", { className: "mt-job-progress" }, /* @__PURE__ */ React7.createElement(
|
|
1848
2170
|
"progress",
|
|
1849
2171
|
{
|
|
1850
2172
|
"aria-label": `Progress for ${job.outputName}`,
|
|
1851
2173
|
max: 1,
|
|
1852
2174
|
value: job.state === "succeeded" ? 1 : job.progress === null ? void 0 : Math.min(0.99, job.progress)
|
|
1853
2175
|
}
|
|
1854
|
-
), /* @__PURE__ */
|
|
2176
|
+
), /* @__PURE__ */ React7.createElement("span", null, job.state === "succeeded" ? "100%" : job.progress === null ? "Unknown progress" : `${Math.floor(Math.min(0.99, job.progress) * 100)}%`)), /* @__PURE__ */ React7.createElement("div", { className: "mt-column-actions" }, ["queued", "running", "saving"].includes(job.state) && /* @__PURE__ */ React7.createElement(
|
|
1855
2177
|
Button,
|
|
1856
2178
|
{
|
|
1857
2179
|
label: "Cancel task",
|
|
@@ -1860,7 +2182,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1860
2182
|
disabled: pending !== null || job.cancelRequested,
|
|
1861
2183
|
onClick: () => void act(job, "cancel")
|
|
1862
2184
|
}
|
|
1863
|
-
), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */
|
|
2185
|
+
), ["failed", "canceled", "interrupted"].includes(job.state) && /* @__PURE__ */ React7.createElement(
|
|
1864
2186
|
Button,
|
|
1865
2187
|
{
|
|
1866
2188
|
label: "Retry task",
|
|
@@ -1869,7 +2191,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1869
2191
|
disabled: pending !== null || job.cleanupPending,
|
|
1870
2192
|
onClick: () => void act(job, "retry")
|
|
1871
2193
|
}
|
|
1872
|
-
), job.result && onOpenResult && /* @__PURE__ */
|
|
2194
|
+
), job.result && onOpenResult && /* @__PURE__ */ React7.createElement(Button, { label: "Open result", width: "hug", onClick: () => onOpenResult(job.result) }), /* @__PURE__ */ React7.createElement("details", null, /* @__PURE__ */ React7.createElement("summary", null, "Task identity"), /* @__PURE__ */ React7.createElement("code", null, job.jobId))))), /* @__PURE__ */ React7.createElement("div", { className: "mt-pagination" }, /* @__PURE__ */ React7.createElement(
|
|
1873
2195
|
Button,
|
|
1874
2196
|
{
|
|
1875
2197
|
label: "Previous tasks",
|
|
@@ -1877,7 +2199,7 @@ function MediaJobs({ onOpenResult }) {
|
|
|
1877
2199
|
disabled: offset === 0,
|
|
1878
2200
|
onClick: () => setOffset(Math.max(0, offset - 50))
|
|
1879
2201
|
}
|
|
1880
|
-
), /* @__PURE__ */
|
|
2202
|
+
), /* @__PURE__ */ React7.createElement(
|
|
1881
2203
|
Button,
|
|
1882
2204
|
{
|
|
1883
2205
|
label: "Next tasks",
|
|
@@ -1935,30 +2257,36 @@ async function activate(client) {
|
|
|
1935
2257
|
component: Component,
|
|
1936
2258
|
props
|
|
1937
2259
|
}) {
|
|
1938
|
-
const ready =
|
|
2260
|
+
const ready = React8.useSyncExternalStore(
|
|
1939
2261
|
subscribe,
|
|
1940
2262
|
() => active,
|
|
1941
2263
|
() => active
|
|
1942
2264
|
);
|
|
1943
|
-
return ready ? /* @__PURE__ */
|
|
2265
|
+
return ready ? /* @__PURE__ */ React8.createElement(MediaContext.Provider, { value: { client, instanceId, resolve } }, /* @__PURE__ */ React8.createElement("div", { className: "mt-root" }, /* @__PURE__ */ React8.createElement(Component, { ...props }))) : null;
|
|
1944
2266
|
}
|
|
1945
2267
|
client.registerUI({
|
|
1946
2268
|
id: "media.video-editor",
|
|
1947
2269
|
title: "Video editor",
|
|
1948
2270
|
kind: "component",
|
|
1949
|
-
component: (props) => /* @__PURE__ */
|
|
2271
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoEditor, props })
|
|
2272
|
+
});
|
|
2273
|
+
client.registerUI({
|
|
2274
|
+
id: "media.video-export",
|
|
2275
|
+
title: "Export settings",
|
|
2276
|
+
kind: "component",
|
|
2277
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoExport, props })
|
|
1950
2278
|
});
|
|
1951
2279
|
client.registerUI({
|
|
1952
2280
|
id: "media.video-compare",
|
|
1953
2281
|
title: "Video comparison",
|
|
1954
2282
|
kind: "component",
|
|
1955
|
-
component: (props) => /* @__PURE__ */
|
|
2283
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: VideoCompare, props })
|
|
1956
2284
|
});
|
|
1957
2285
|
client.registerUI({
|
|
1958
2286
|
id: "media.jobs",
|
|
1959
2287
|
title: "Media tasks",
|
|
1960
2288
|
kind: "component",
|
|
1961
|
-
component: (props) => /* @__PURE__ */
|
|
2289
|
+
component: (props) => /* @__PURE__ */ React8.createElement(Bound, { component: MediaJobs, props })
|
|
1962
2290
|
});
|
|
1963
2291
|
client.onDispose(() => {
|
|
1964
2292
|
active = false;
|