@hyperframes/studio 0.8.204 → 0.8.206
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/hyperframes-player-lCVwx9d3.js +478 -0
- package/dist/assets/{index-DpxSurnJ.js → index-BNuxGFZK.js} +1 -1
- package/dist/assets/{index-DmST2bTJ.js → index-CwreIGoq.js} +132 -132
- package/dist/{chunk-Z5NKM57J.js → chunk-3EAFE522.js} +8 -4
- package/dist/{chunk-2YCKGJFD.js → chunk-DAZTBGYM.js} +1 -1
- package/dist/{chunk-T43DM7Q6.js → chunk-OGIOFEC7.js} +4 -2
- package/dist/{domEditingLayers-WMDSHU5P.js → domEditingLayers-7Z6J4UOK.js} +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.html +1 -1
- package/dist/index.js +699 -554
- package/dist/player.js +2 -2
- package/package.json +8 -8
- package/src/components/DesktopGuideCard.tsx +1 -1
- package/src/components/MediaPreview.test.tsx +69 -0
- package/src/components/MediaPreview.tsx +10 -5
- package/src/components/OpenInDesktopButton.dom.test.tsx +27 -5
- package/src/components/editor/domEditLayerWalkCache.test.ts +48 -0
- package/src/components/editor/domEditLayerWalkCache.ts +6 -0
- package/src/components/editor/domEditingLayers.ts +3 -2
- package/src/components/renders/GifLoopInput.tsx +40 -0
- package/src/components/renders/GpuEncodingToggle.tsx +1 -1
- package/src/components/renders/RenderDurationNote.tsx +19 -0
- package/src/components/renders/RenderPreview.tsx +41 -0
- package/src/components/renders/RenderQueue.test.tsx +77 -0
- package/src/components/renders/RenderQueue.tsx +46 -41
- package/src/components/renders/RenderQueueInfo.tsx +61 -0
- package/src/components/renders/RenderQueueItem.test.tsx +46 -0
- package/src/components/renders/RenderQueueItem.tsx +10 -80
- package/src/components/renders/RenderQueuePanel.tsx +2 -1
- package/src/components/renders/renderSettings.ts +61 -2
- package/src/components/renders/useRenderQueue.ts +10 -2
- package/src/components/renders/useRenderQueueComposition.test.tsx +13 -0
- package/src/components/sidebar/PromptPreviewModal.test.tsx +22 -0
- package/src/components/sidebar/PromptPreviewModal.tsx +1 -0
- package/src/player/hooks/previewMessageRouter.test.ts +34 -0
- package/src/player/hooks/previewMessageRouter.ts +14 -3
- package/src/utils/sourceScopedSelectorIndex.ts +5 -2
- package/dist/assets/hyperframes-player-CttA4PW7.js +0 -478
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memo, useState, useRef, useEffect, useLayoutEffect, useId } from "react";
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
3
|
import { CANVAS_DIMENSIONS } from "@hyperframes/parsers";
|
|
4
|
+
import { RenderDurationNote } from "./RenderDurationNote";
|
|
4
5
|
import { RenderQueueItem } from "./RenderQueueItem";
|
|
5
6
|
import { FfmpegRequiredNotice } from "./FfmpegRequiredNotice";
|
|
6
7
|
import type { FfmpegStatus } from "./useFfmpegStatus";
|
|
@@ -10,8 +11,18 @@ import { Select, type SelectOption } from "../ui/Select";
|
|
|
10
11
|
import { Tooltip } from "../ui/Tooltip";
|
|
11
12
|
import { resolveFloatingPanelPosition, type FloatingPosition } from "../editor/floatingPanel";
|
|
12
13
|
import type { RenderJob, ResolutionPreset } from "./useRenderQueue";
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
FORMAT_INFO,
|
|
16
|
+
resolveRenderFps,
|
|
17
|
+
getRenderFpsOptions,
|
|
18
|
+
getPersistedRenderSettings,
|
|
19
|
+
persistRenderSettings,
|
|
20
|
+
resolveRenderFormat,
|
|
21
|
+
startConfiguredRender,
|
|
22
|
+
isRenderExportBlocked,
|
|
23
|
+
} from "./renderSettings";
|
|
14
24
|
import { GpuEncodingToggle } from "./GpuEncodingToggle";
|
|
25
|
+
import { GifLoopInput, isInvalidGifLoop } from "./GifLoopInput";
|
|
15
26
|
import { trackStudioEvent } from "../../utils/studioTelemetry";
|
|
16
27
|
|
|
17
28
|
export interface CompositionDimensions {
|
|
@@ -20,11 +31,12 @@ export interface CompositionDimensions {
|
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export type StartRenderHandler = (
|
|
23
|
-
format: "mp4" | "webm" | "mov",
|
|
34
|
+
format: "mp4" | "webm" | "mov" | "gif",
|
|
24
35
|
quality: "draft" | "standard" | "high",
|
|
25
36
|
resolution: ResolutionPreset | "auto",
|
|
26
37
|
fps: 24 | 30 | 60,
|
|
27
38
|
gpu?: boolean,
|
|
39
|
+
gifLoop?: number,
|
|
28
40
|
) => void | Promise<void>;
|
|
29
41
|
|
|
30
42
|
export interface RenderQueueProps {
|
|
@@ -136,21 +148,9 @@ function scaleOptionLabel(
|
|
|
136
148
|
return base;
|
|
137
149
|
}
|
|
138
150
|
|
|
139
|
-
const FORMAT_INFO: Record<"mp4" | "webm" | "mov", { label: string; desc: string }> = {
|
|
140
|
-
mp4: { label: "MP4", desc: "Best for general use. Smallest file, universal playback." },
|
|
141
|
-
mov: {
|
|
142
|
-
label: "MOV (ProRes 4444)",
|
|
143
|
-
desc: "Transparent video. Works in Final Cut Pro, DaVinci Resolve, and most video editors. Large files.",
|
|
144
|
-
},
|
|
145
|
-
webm: {
|
|
146
|
-
label: "WebM (VP9)",
|
|
147
|
-
desc: "Transparent video for web. Smaller than MOV but limited editor support.",
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
|
|
151
151
|
// Estimated, like COLOR_PICKER_SIZE in propertyPanelColor: only the flip
|
|
152
152
|
// decision uses the height, and the clamp keeps the panel on screen either way.
|
|
153
|
-
const FORMAT_PANEL_SIZE = { width: 208, height:
|
|
153
|
+
const FORMAT_PANEL_SIZE = { width: 208, height: 210 };
|
|
154
154
|
|
|
155
155
|
// Rich format guidance in a keyboard-reachable disclosure: the trigger is a
|
|
156
156
|
// real button (focusable, labelled), the panel is tied to it via
|
|
@@ -158,7 +158,7 @@ const FORMAT_PANEL_SIZE = { width: 208, height: 150 };
|
|
|
158
158
|
// for the one-line ui/Tooltip primitive, so this stays a local popover.
|
|
159
159
|
// It renders in a portal because the right panel is overflow-hidden: an
|
|
160
160
|
// in-flow absolute panel gets clipped at the panel edge.
|
|
161
|
-
function FormatInfoTooltip({ format }: { format: "mp4" | "webm" | "mov" }) {
|
|
161
|
+
function FormatInfoTooltip({ format }: { format: "mp4" | "webm" | "mov" | "gif" }) {
|
|
162
162
|
const [open, setOpen] = useState(false);
|
|
163
163
|
const [position, setPosition] = useState<FloatingPosition | null>(null);
|
|
164
164
|
const triggerRef = useRef<HTMLDivElement>(null);
|
|
@@ -243,7 +243,7 @@ function FormatInfoTooltip({ format }: { format: "mp4" | "webm" | "mov" }) {
|
|
|
243
243
|
<p className="text-step-10 font-semibold text-text-1 mb-0.5">{info.label}</p>
|
|
244
244
|
<p className="text-step-9 text-text-3 leading-tight">{info.desc}</p>
|
|
245
245
|
<div className="mt-1.5 pt-1.5 border-t border-border">
|
|
246
|
-
{(["mp4", "mov", "webm"] as const)
|
|
246
|
+
{(["mp4", "mov", "webm", "gif"] as const)
|
|
247
247
|
.filter((f) => f !== format)
|
|
248
248
|
.map((f) => (
|
|
249
249
|
<p key={f} className="text-step-9 text-text-4 leading-relaxed">
|
|
@@ -264,6 +264,7 @@ const FORMAT_OPTIONS: SelectOption[] = [
|
|
|
264
264
|
{ value: "mp4", label: "MP4" },
|
|
265
265
|
{ value: "mov", label: "MOV (ProRes)" },
|
|
266
266
|
{ value: "webm", label: "WebM" },
|
|
267
|
+
{ value: "gif", label: "GIF" },
|
|
267
268
|
];
|
|
268
269
|
|
|
269
270
|
const QUALITY_OPTIONS: SelectOption[] = [
|
|
@@ -272,17 +273,6 @@ const QUALITY_OPTIONS: SelectOption[] = [
|
|
|
272
273
|
{ value: "high", label: "High Quality" },
|
|
273
274
|
];
|
|
274
275
|
|
|
275
|
-
const FPS_OPTIONS: SelectOption[] = [
|
|
276
|
-
{ value: "24", label: "24 fps" },
|
|
277
|
-
{ value: "30", label: "30 fps" },
|
|
278
|
-
{ value: "60", label: "60 fps" },
|
|
279
|
-
];
|
|
280
|
-
|
|
281
|
-
function formatEta(ms: number): string {
|
|
282
|
-
const s = Math.round(ms / 1000);
|
|
283
|
-
return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
276
|
function FormatExportButton({
|
|
287
277
|
onStartRender,
|
|
288
278
|
isRendering,
|
|
@@ -301,17 +291,22 @@ function FormatExportButton({
|
|
|
301
291
|
onRecheckFfmpeg: () => void;
|
|
302
292
|
}) {
|
|
303
293
|
const persisted = getPersistedRenderSettings();
|
|
304
|
-
const [format, setFormat] = useState<"mp4" | "webm" | "mov">(persisted.format);
|
|
294
|
+
const [format, setFormat] = useState<"mp4" | "webm" | "mov" | "gif">(persisted.format);
|
|
305
295
|
const [quality, setQuality] = useState<"draft" | "standard" | "high">(persisted.quality);
|
|
306
296
|
const [resolution, setResolution] = useState<RenderScale>("auto");
|
|
307
|
-
const [
|
|
297
|
+
const [requestedFps, setFps] = useState<24 | 30 | 60>(persisted.fps);
|
|
298
|
+
const fps = resolveRenderFps(format, requestedFps);
|
|
308
299
|
const [gpu, setGpu] = useState(persisted.gpu);
|
|
300
|
+
const [gifLoop, setGifLoop] = useState("0");
|
|
301
|
+
const loopCount = Number(gifLoop);
|
|
302
|
+
const invalidGifLoop = isInvalidGifLoop(format, gifLoop);
|
|
309
303
|
|
|
310
304
|
// Only a definite "not installed" blocks Export. A null status means the
|
|
311
305
|
// probe gave no answer, and refusing to export on no answer would break
|
|
312
306
|
// setups that are perfectly fine. Holding the narrowed value rather than a
|
|
313
307
|
// boolean keeps the notice from re-testing what this line already decided.
|
|
314
308
|
const missingFfmpeg = ffmpeg && !ffmpeg.ok ? ffmpeg : null;
|
|
309
|
+
const exportBlocked = isRenderExportBlocked(isRendering, missingFfmpeg !== null, invalidGifLoop);
|
|
315
310
|
|
|
316
311
|
// MOV (ProRes) is a fixed-quality codec — quality selector has no effect.
|
|
317
312
|
const showQuality = format !== "mov";
|
|
@@ -337,9 +332,9 @@ function FormatExportButton({
|
|
|
337
332
|
options={FORMAT_OPTIONS}
|
|
338
333
|
disabled={isRendering}
|
|
339
334
|
onCommit={(next) => {
|
|
340
|
-
const v = next
|
|
335
|
+
const v = resolveRenderFormat(next);
|
|
341
336
|
setFormat(v);
|
|
342
|
-
persistRenderSettings(v, quality,
|
|
337
|
+
persistRenderSettings(v, quality, resolveRenderFps(v, requestedFps));
|
|
343
338
|
}}
|
|
344
339
|
/>
|
|
345
340
|
</div>
|
|
@@ -362,7 +357,7 @@ function FormatExportButton({
|
|
|
362
357
|
<Select
|
|
363
358
|
label="Frame rate"
|
|
364
359
|
value={String(fps)}
|
|
365
|
-
options={
|
|
360
|
+
options={getRenderFpsOptions(format)}
|
|
366
361
|
disabled={isRendering}
|
|
367
362
|
onCommit={(next) => {
|
|
368
363
|
const v = Number(next) as 24 | 30 | 60;
|
|
@@ -388,6 +383,13 @@ function FormatExportButton({
|
|
|
388
383
|
</div>
|
|
389
384
|
)}
|
|
390
385
|
</div>
|
|
386
|
+
<GifLoopInput
|
|
387
|
+
format={format}
|
|
388
|
+
value={gifLoop}
|
|
389
|
+
disabled={isRendering}
|
|
390
|
+
invalid={invalidGifLoop}
|
|
391
|
+
onChange={setGifLoop}
|
|
392
|
+
/>
|
|
391
393
|
<GpuEncodingToggle
|
|
392
394
|
format={format}
|
|
393
395
|
checked={gpu}
|
|
@@ -402,15 +404,22 @@ function FormatExportButton({
|
|
|
402
404
|
size="md"
|
|
403
405
|
data-testid="renders-export"
|
|
404
406
|
loading={isRendering}
|
|
405
|
-
disabled={
|
|
407
|
+
disabled={exportBlocked}
|
|
406
408
|
title={missingFfmpeg ? "Install FFmpeg to export. See the note above." : undefined}
|
|
407
409
|
onClick={() => {
|
|
408
410
|
// loading already disables the button; this guard also stops a
|
|
409
411
|
// double-click in the same frame from enqueueing two renders.
|
|
410
|
-
if (
|
|
412
|
+
if (exportBlocked) return;
|
|
411
413
|
const outputResolution = resolveResolution(resolution, compositionDimensions);
|
|
412
414
|
trackStudioEvent("render_start", { format, quality, resolution: outputResolution, fps });
|
|
413
|
-
void onStartRender
|
|
415
|
+
void startConfiguredRender(onStartRender, {
|
|
416
|
+
format,
|
|
417
|
+
quality,
|
|
418
|
+
resolution: outputResolution,
|
|
419
|
+
fps,
|
|
420
|
+
gpu,
|
|
421
|
+
gifLoop: loopCount,
|
|
422
|
+
});
|
|
414
423
|
}}
|
|
415
424
|
// Width only. A type size or a weight here would win the merge against
|
|
416
425
|
// the size recipe and leave this Export a step away from the header's
|
|
@@ -419,11 +428,7 @@ function FormatExportButton({
|
|
|
419
428
|
>
|
|
420
429
|
{isRendering ? "Rendering…" : "Export"}
|
|
421
430
|
</Button>
|
|
422
|
-
{lastRenderDurationMs
|
|
423
|
-
<p className="text-step-9 text-text-5 text-center -mt-1.5">
|
|
424
|
-
Last render took {formatEta(lastRenderDurationMs)}
|
|
425
|
-
</p>
|
|
426
|
-
)}
|
|
431
|
+
<RenderDurationNote durationMs={lastRenderDurationMs} isRendering={isRendering} />
|
|
427
432
|
</div>
|
|
428
433
|
);
|
|
429
434
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { RenderJob } from "./useRenderQueue";
|
|
2
|
+
|
|
3
|
+
function formatDuration(ms: number): string {
|
|
4
|
+
if (ms < 1000) return `${ms}ms`;
|
|
5
|
+
const s = Math.round(ms / 1000);
|
|
6
|
+
return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function formatTimeAgo(timestamp: number): string {
|
|
10
|
+
const diff = Date.now() - timestamp;
|
|
11
|
+
if (diff < 60000) return "just now";
|
|
12
|
+
if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;
|
|
13
|
+
return `${Math.floor(diff / 3600000)}h ago`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function RenderQueueInfo({ job }: { job: RenderJob }) {
|
|
17
|
+
const isRendering = job.status === "rendering";
|
|
18
|
+
return (
|
|
19
|
+
<div className="flex-1 min-w-0">
|
|
20
|
+
<div className="flex items-center gap-1.5">
|
|
21
|
+
<span className="text-step-11 font-medium text-text-2 truncate">{job.filename}</span>
|
|
22
|
+
{job.durationMs && (
|
|
23
|
+
<span className="text-step-9 text-text-5 shrink-0">{formatDuration(job.durationMs)}</span>
|
|
24
|
+
)}
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
{isRendering && (
|
|
28
|
+
<div className="mt-1">
|
|
29
|
+
<div className="flex items-center justify-between mb-0.5">
|
|
30
|
+
<span className="text-step-9 text-text-4">{job.stage || "Rendering"}</span>
|
|
31
|
+
<span className="text-step-9 font-mono text-accent-ink">{job.progress}%</span>
|
|
32
|
+
</div>
|
|
33
|
+
<div
|
|
34
|
+
className="w-full h-1 bg-border rounded-full overflow-hidden"
|
|
35
|
+
role="progressbar"
|
|
36
|
+
aria-valuenow={job.progress}
|
|
37
|
+
aria-valuemin={0}
|
|
38
|
+
aria-valuemax={100}
|
|
39
|
+
aria-label={`Render progress: ${job.progress}%`}
|
|
40
|
+
>
|
|
41
|
+
<div
|
|
42
|
+
className="h-full bg-accent rounded-full transition-all duration-300"
|
|
43
|
+
style={{ width: `${job.progress}%` }}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
|
|
49
|
+
{job.status === "failed" && job.error && (
|
|
50
|
+
<span className="text-step-9 text-danger-ink mt-0.5 block">{job.error}</span>
|
|
51
|
+
)}
|
|
52
|
+
{job.status === "cancelled" && (
|
|
53
|
+
<span className="text-step-9 text-text-4 mt-0.5 block">Cancelled</span>
|
|
54
|
+
)}
|
|
55
|
+
|
|
56
|
+
{!isRendering && (
|
|
57
|
+
<span className="text-step-9 text-text-5">{formatTimeAgo(job.createdAt)}</span>
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { RenderQueueItem } from "./RenderQueueItem";
|
|
6
|
+
|
|
7
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
8
|
+
|
|
9
|
+
describe("GIF render preview", () => {
|
|
10
|
+
it("uses an image instead of video playback, with open, download and delete actions", () => {
|
|
11
|
+
const host = document.createElement("div");
|
|
12
|
+
document.body.append(host);
|
|
13
|
+
const root = createRoot(host);
|
|
14
|
+
const onDelete = vi.fn();
|
|
15
|
+
try {
|
|
16
|
+
act(() =>
|
|
17
|
+
root.render(
|
|
18
|
+
<RenderQueueItem
|
|
19
|
+
job={{ id: "j1", filename: "j1.gif", status: "complete", progress: 100, createdAt: 0 }}
|
|
20
|
+
projectId="demo"
|
|
21
|
+
onDelete={onDelete}
|
|
22
|
+
onCancel={vi.fn()}
|
|
23
|
+
/>,
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
expect(host.querySelector("img")?.getAttribute("src")).toBe(
|
|
27
|
+
"/api/projects/demo/renders/file/j1.gif",
|
|
28
|
+
);
|
|
29
|
+
expect(host.querySelector("video")).toBeNull();
|
|
30
|
+
expect(host.querySelector('[aria-label="Open j1.gif in a new tab"]')).not.toBeNull();
|
|
31
|
+
expect(
|
|
32
|
+
host.querySelector<HTMLButtonElement>('[aria-label="Download j1.gif"]')?.disabled,
|
|
33
|
+
).toBe(false);
|
|
34
|
+
const deleteButton = host.querySelector<HTMLButtonElement>('[aria-label="Delete j1.gif"]');
|
|
35
|
+
act(() => deleteButton?.click());
|
|
36
|
+
const confirm = Array.from(host.querySelectorAll("button")).find(
|
|
37
|
+
(button) => button.textContent === "Delete?",
|
|
38
|
+
);
|
|
39
|
+
act(() => confirm?.click());
|
|
40
|
+
expect(onDelete).toHaveBeenCalledOnce();
|
|
41
|
+
} finally {
|
|
42
|
+
act(() => root.unmount());
|
|
43
|
+
host.remove();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildProjectApiPath } from "../../utils/projectRouting";
|
|
2
2
|
import { memo, useCallback, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { RenderQueueInfo } from "./RenderQueueInfo";
|
|
4
|
+
import { RenderPreview } from "./RenderPreview";
|
|
4
5
|
import { Button } from "../ui/Button";
|
|
5
6
|
import { IconButton } from "../ui/IconButton";
|
|
6
7
|
import { Tooltip } from "../ui/Tooltip";
|
|
@@ -13,19 +14,6 @@ interface RenderQueueItemProps {
|
|
|
13
14
|
onCancel: () => void;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
function formatDuration(ms: number): string {
|
|
17
|
-
if (ms < 1000) return `${ms}ms`;
|
|
18
|
-
const s = Math.round(ms / 1000);
|
|
19
|
-
return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function formatTimeAgo(timestamp: number): string {
|
|
23
|
-
const diff = Date.now() - timestamp;
|
|
24
|
-
if (diff < 60000) return "just now";
|
|
25
|
-
if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;
|
|
26
|
-
return `${Math.floor(diff / 3600000)}h ago`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
/** Static frame extracted once via hidden video + canvas. */
|
|
30
18
|
|
|
31
19
|
export const RenderQueueItem = memo(function RenderQueueItem({
|
|
@@ -85,28 +73,13 @@ export const RenderQueueItem = memo(function RenderQueueItem({
|
|
|
85
73
|
].join(" ")}
|
|
86
74
|
>
|
|
87
75
|
{isComplete && (
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
loop
|
|
96
|
-
playsInline
|
|
97
|
-
onCanPlay={() => setVideoReady(true)}
|
|
98
|
-
className="absolute inset-0 w-full h-full object-contain transition-opacity duration-150"
|
|
99
|
-
style={{ opacity: videoReady ? 1 : 0 }}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
|
-
{/* Static frame — visible when not hovering */}
|
|
103
|
-
<div
|
|
104
|
-
className="absolute inset-0 transition-opacity duration-150"
|
|
105
|
-
style={{ opacity: hovered && videoReady ? 0 : 1 }}
|
|
106
|
-
>
|
|
107
|
-
<VideoFrameThumbnail src={viewSrc} />
|
|
108
|
-
</div>
|
|
109
|
-
</>
|
|
76
|
+
<RenderPreview
|
|
77
|
+
filename={job.filename}
|
|
78
|
+
src={viewSrc}
|
|
79
|
+
hovered={hovered}
|
|
80
|
+
ready={videoReady}
|
|
81
|
+
onReady={() => setVideoReady(true)}
|
|
82
|
+
/>
|
|
110
83
|
)}
|
|
111
84
|
{isRendering && (
|
|
112
85
|
<div className="w-full h-full flex items-center justify-center">
|
|
@@ -125,50 +98,7 @@ export const RenderQueueItem = memo(function RenderQueueItem({
|
|
|
125
98
|
)}
|
|
126
99
|
</button>
|
|
127
100
|
|
|
128
|
-
{
|
|
129
|
-
<div className="flex-1 min-w-0">
|
|
130
|
-
<div className="flex items-center gap-1.5">
|
|
131
|
-
<span className="text-step-11 font-medium text-text-2 truncate">{job.filename}</span>
|
|
132
|
-
{job.durationMs && (
|
|
133
|
-
<span className="text-step-9 text-text-5 shrink-0">
|
|
134
|
-
{formatDuration(job.durationMs)}
|
|
135
|
-
</span>
|
|
136
|
-
)}
|
|
137
|
-
</div>
|
|
138
|
-
|
|
139
|
-
{isRendering && (
|
|
140
|
-
<div className="mt-1">
|
|
141
|
-
<div className="flex items-center justify-between mb-0.5">
|
|
142
|
-
<span className="text-step-9 text-text-4">{job.stage || "Rendering"}</span>
|
|
143
|
-
<span className="text-step-9 font-mono text-accent-ink">{job.progress}%</span>
|
|
144
|
-
</div>
|
|
145
|
-
<div
|
|
146
|
-
className="w-full h-1 bg-border rounded-full overflow-hidden"
|
|
147
|
-
role="progressbar"
|
|
148
|
-
aria-valuenow={job.progress}
|
|
149
|
-
aria-valuemin={0}
|
|
150
|
-
aria-valuemax={100}
|
|
151
|
-
aria-label={`Render progress: ${job.progress}%`}
|
|
152
|
-
>
|
|
153
|
-
<div
|
|
154
|
-
className="h-full bg-accent rounded-full transition-all duration-300"
|
|
155
|
-
style={{ width: `${job.progress}%` }}
|
|
156
|
-
/>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
)}
|
|
160
|
-
|
|
161
|
-
{job.status === "failed" && job.error && (
|
|
162
|
-
<span className="text-step-9 text-danger-ink mt-0.5 block">{job.error}</span>
|
|
163
|
-
)}
|
|
164
|
-
{job.status === "cancelled" && (
|
|
165
|
-
<span className="text-step-9 text-text-4 mt-0.5 block">Cancelled</span>
|
|
166
|
-
)}
|
|
167
|
-
|
|
168
|
-
{!isRendering && (
|
|
169
|
-
<span className="text-step-9 text-text-5">{formatTimeAgo(job.createdAt)}</span>
|
|
170
|
-
)}
|
|
171
|
-
</div>
|
|
101
|
+
<RenderQueueInfo job={job} />
|
|
172
102
|
|
|
173
103
|
{/* Actions — always visible to prevent layout shifts */}
|
|
174
104
|
<div className="flex items-center gap-1.5 shrink-0">
|
|
@@ -29,7 +29,7 @@ export const RenderQueuePanel = memo(function RenderQueuePanel() {
|
|
|
29
29
|
ffmpeg={renderQueue.ffmpeg}
|
|
30
30
|
ffmpegChecking={renderQueue.ffmpegChecking}
|
|
31
31
|
onRecheckFfmpeg={renderQueue.recheckFfmpeg}
|
|
32
|
-
onStartRender={async (format, quality, resolution, fps, gpu) => {
|
|
32
|
+
onStartRender={async (format, quality, resolution, fps, gpu, gifLoop) => {
|
|
33
33
|
await waitForPendingDomEditSaves();
|
|
34
34
|
// No `composition`: startRender targets the active one by default.
|
|
35
35
|
await renderQueue.startRender({
|
|
@@ -38,6 +38,7 @@ export const RenderQueuePanel = memo(function RenderQueuePanel() {
|
|
|
38
38
|
format,
|
|
39
39
|
resolution,
|
|
40
40
|
gpu,
|
|
41
|
+
gifLoop,
|
|
41
42
|
// Render what the user is previewing: active variable overrides
|
|
42
43
|
// from the Variables panel ride along (undefined = defaults).
|
|
43
44
|
variables: usePreviewVariablesStore.getState().values ?? undefined,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { SelectOption } from "../ui/Select";
|
|
2
|
+
import type { StartRenderHandler } from "./RenderQueue";
|
|
3
|
+
import type { ResolutionPreset } from "./useRenderQueue";
|
|
4
|
+
|
|
1
5
|
const RENDER_SETTINGS_KEY = "hf-studio-render-settings";
|
|
2
6
|
|
|
3
7
|
export interface PersistedRenderSettings {
|
|
4
|
-
format: "mp4" | "webm" | "mov";
|
|
8
|
+
format: "mp4" | "webm" | "mov" | "gif";
|
|
5
9
|
quality: "draft" | "standard" | "high";
|
|
6
10
|
fps: 24 | 30 | 60;
|
|
7
11
|
gpu: boolean;
|
|
@@ -13,7 +17,7 @@ export function getPersistedRenderSettings(): PersistedRenderSettings {
|
|
|
13
17
|
if (raw) {
|
|
14
18
|
const parsed = JSON.parse(raw);
|
|
15
19
|
return {
|
|
16
|
-
format: ["mp4", "webm", "mov"].includes(parsed.format) ? parsed.format : "mp4",
|
|
20
|
+
format: ["mp4", "webm", "mov", "gif"].includes(parsed.format) ? parsed.format : "mp4",
|
|
17
21
|
quality: ["draft", "standard", "high"].includes(parsed.quality)
|
|
18
22
|
? parsed.quality
|
|
19
23
|
: "standard",
|
|
@@ -39,3 +43,58 @@ export function persistRenderSettings(
|
|
|
39
43
|
/* ignore */
|
|
40
44
|
}
|
|
41
45
|
}
|
|
46
|
+
|
|
47
|
+
export function resolveRenderFormat(value: string): PersistedRenderSettings["format"] {
|
|
48
|
+
return (["mp4", "webm", "mov", "gif"] as const).find((format) => format === value) ?? "mp4";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function startConfiguredRender(
|
|
52
|
+
onStartRender: StartRenderHandler,
|
|
53
|
+
settings: PersistedRenderSettings & { resolution: ResolutionPreset | "auto"; gifLoop: number },
|
|
54
|
+
): void | Promise<void> {
|
|
55
|
+
const { format, quality, resolution, fps, gpu, gifLoop } = settings;
|
|
56
|
+
if (format === "gif") return onStartRender(format, quality, resolution, fps, false, gifLoop);
|
|
57
|
+
return onStartRender(format, quality, resolution, fps, gpu);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isRenderExportBlocked(
|
|
61
|
+
isRendering: boolean,
|
|
62
|
+
missingFfmpeg: boolean,
|
|
63
|
+
invalidGifLoop: boolean,
|
|
64
|
+
): boolean {
|
|
65
|
+
return isRendering || missingFfmpeg || invalidGifLoop;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const FORMAT_INFO: Record<"mp4" | "webm" | "mov" | "gif", { label: string; desc: string }> =
|
|
69
|
+
{
|
|
70
|
+
gif: { label: "GIF", desc: "Animated image for docs and chat. No audio; up to 30 fps." },
|
|
71
|
+
mp4: { label: "MP4", desc: "Best for general use. Smallest file, universal playback." },
|
|
72
|
+
mov: {
|
|
73
|
+
label: "MOV (ProRes 4444)",
|
|
74
|
+
desc: "Transparent video. Works in Final Cut Pro, DaVinci Resolve, and most video editors. Large files.",
|
|
75
|
+
},
|
|
76
|
+
webm: {
|
|
77
|
+
label: "WebM (VP9)",
|
|
78
|
+
desc: "Transparent video for web. Smaller than MOV but limited editor support.",
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const FPS_OPTIONS: SelectOption[] = [
|
|
83
|
+
{ value: "24", label: "24 fps" },
|
|
84
|
+
{ value: "30", label: "30 fps" },
|
|
85
|
+
{ value: "60", label: "60 fps" },
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
export function resolveRenderFps(
|
|
89
|
+
format: PersistedRenderSettings["format"],
|
|
90
|
+
fps: PersistedRenderSettings["fps"],
|
|
91
|
+
): PersistedRenderSettings["fps"] {
|
|
92
|
+
return format === "gif" && fps === 60 ? 30 : fps;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getRenderFpsOptions(format: PersistedRenderSettings["format"]): SelectOption[] {
|
|
96
|
+
return FPS_OPTIONS.map((option) => ({
|
|
97
|
+
...option,
|
|
98
|
+
disabled: format === "gif" && option.value === "60",
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
@@ -29,10 +29,11 @@ export type ResolutionPreset = CanvasResolution;
|
|
|
29
29
|
export interface StartRenderOptions {
|
|
30
30
|
fps?: number;
|
|
31
31
|
quality?: "draft" | "standard" | "high";
|
|
32
|
-
format?: "mp4" | "webm" | "mov";
|
|
32
|
+
format?: "mp4" | "webm" | "mov" | "gif";
|
|
33
33
|
/** `"auto"` (default) renders at the composition's authored dimensions. */
|
|
34
34
|
resolution?: ResolutionPreset | "auto";
|
|
35
35
|
gpu?: boolean;
|
|
36
|
+
gifLoop?: number;
|
|
36
37
|
/**
|
|
37
38
|
* Render a specific composition file. Omit it to render the composition the
|
|
38
39
|
* user currently has open — only the sidebar's per-composition Render button
|
|
@@ -236,6 +237,7 @@ export function useRenderQueue(
|
|
|
236
237
|
composition?: string;
|
|
237
238
|
variables?: Record<string, unknown>;
|
|
238
239
|
gpu?: boolean;
|
|
240
|
+
gifLoop?: number;
|
|
239
241
|
telemetryDistinctId?: string;
|
|
240
242
|
telemetryOptOut?: boolean;
|
|
241
243
|
} = {
|
|
@@ -261,6 +263,7 @@ export function useRenderQueue(
|
|
|
261
263
|
if (resolution && resolution !== "auto") body.resolution = resolution;
|
|
262
264
|
if (composition) body.composition = composition;
|
|
263
265
|
if (opts.gpu) body.gpu = true;
|
|
266
|
+
if (format === "gif" && opts.gifLoop !== undefined) body.gifLoop = opts.gifLoop;
|
|
264
267
|
if (opts.variables && Object.keys(opts.variables).length > 0) {
|
|
265
268
|
body.variables = opts.variables;
|
|
266
269
|
}
|
|
@@ -304,7 +307,12 @@ export function useRenderQueue(
|
|
|
304
307
|
}
|
|
305
308
|
const { jobId } = await res.json();
|
|
306
309
|
|
|
307
|
-
const FORMAT_EXT: Record<string, string> = {
|
|
310
|
+
const FORMAT_EXT: Record<string, string> = {
|
|
311
|
+
mp4: ".mp4",
|
|
312
|
+
webm: ".webm",
|
|
313
|
+
mov: ".mov",
|
|
314
|
+
gif: ".gif",
|
|
315
|
+
};
|
|
308
316
|
const ext = FORMAT_EXT[format] ?? ".mp4";
|
|
309
317
|
const job: RenderJob = {
|
|
310
318
|
id: jobId,
|
|
@@ -65,3 +65,16 @@ describe("GPU encoding", () => {
|
|
|
65
65
|
expect(body["gpu"]).toBeUndefined();
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
describe("GIF export transport", () => {
|
|
70
|
+
it.each([0, 3, 65535])("forwards loop count %i and creates a GIF queue item", async (gifLoop) => {
|
|
71
|
+
const body = await renderBody(null, { format: "gif", gifLoop });
|
|
72
|
+
expect(body).toMatchObject({ format: "gif", gifLoop });
|
|
73
|
+
expect(queue?.api().jobs).toEqual([expect.objectContaining({ filename: "j1.gif" })]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("omits GIF options for video exports", async () => {
|
|
77
|
+
const body = await renderBody(null, { format: "mp4", gifLoop: 3 });
|
|
78
|
+
expect(body).not.toHaveProperty("gifLoop");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
4
|
+
import { PromptPreviewModal } from "./PromptPreviewModal";
|
|
5
|
+
import { cleanupMounted, mountHost } from "../ui/mountHost.testHelpers";
|
|
6
|
+
|
|
7
|
+
afterEach(cleanupMounted);
|
|
8
|
+
|
|
9
|
+
describe("PromptPreviewModal", () => {
|
|
10
|
+
it("gives the prompt editor a stable accessible name", () => {
|
|
11
|
+
const prompt = "Change the title";
|
|
12
|
+
const title = "Example";
|
|
13
|
+
const host = mountHost(<PromptPreviewModal title={title} prompt={prompt} onClose={() => {}} />);
|
|
14
|
+
const dialog = host.querySelector('[role="dialog"]');
|
|
15
|
+
const textarea = host.querySelector("textarea");
|
|
16
|
+
|
|
17
|
+
expect(dialog?.getAttribute("aria-label")).toBe("Ask agent: Example");
|
|
18
|
+
expect(textarea?.getAttribute("aria-label")).toBe("Prompt");
|
|
19
|
+
expect(textarea?.getAttribute("aria-label")).not.toBe(prompt);
|
|
20
|
+
expect(textarea?.getAttribute("aria-label")).not.toBe(dialog?.getAttribute("aria-label"));
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -23,6 +23,40 @@ describe("preview state messages", () => {
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
describe("preview state messages while a scrub posts them", () => {
|
|
27
|
+
it("re-reads the preview for missing compositions at most every 500 ms", () => {
|
|
28
|
+
vi.useFakeTimers();
|
|
29
|
+
try {
|
|
30
|
+
vi.setSystemTime(10_000);
|
|
31
|
+
const enrich = vi.fn();
|
|
32
|
+
const handle = createPreviewMessageHandler({
|
|
33
|
+
iframeRef: { current: null },
|
|
34
|
+
processTimelineMessageRef: { current: vi.fn() },
|
|
35
|
+
enrichMissingCompositionsRef: { current: enrich },
|
|
36
|
+
lastTimelineMessageRef: { current: 0 },
|
|
37
|
+
getAdapter: () => null,
|
|
38
|
+
syncTimelineElements: vi.fn(),
|
|
39
|
+
});
|
|
40
|
+
const state = () =>
|
|
41
|
+
handle(
|
|
42
|
+
new MessageEvent("message", {
|
|
43
|
+
data: { source: "hf-preview", type: "state", isPlaying: false },
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
state();
|
|
47
|
+
vi.advanceTimersByTime(100);
|
|
48
|
+
state();
|
|
49
|
+
state();
|
|
50
|
+
expect(enrich).toHaveBeenCalledTimes(1);
|
|
51
|
+
vi.advanceTimersByTime(500);
|
|
52
|
+
state();
|
|
53
|
+
expect(enrich).toHaveBeenCalledTimes(2);
|
|
54
|
+
} finally {
|
|
55
|
+
vi.useRealTimers();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
26
60
|
describe("preview quality messages", () => {
|
|
27
61
|
function routeMessage(data: unknown, frame?: { postMessage: (message: unknown) => void }) {
|
|
28
62
|
const iframe = frame ? ({ contentWindow: frame } as unknown as HTMLIFrameElement) : null;
|