Files
hyperframes/packages/studio/src/utils/frameCapture.ts
T
Miguel Ángel 438ea9d59f perf(studio): manual edits stay under 8 ms per frame (#4898)
* ci(studio): measure any edit cases on quiet runners, five runs in parallel

* perf(studio): an undo or save stops re-rendering every panel

* test(studio): the edit bench types one key per frame, as a person does

* fix(studio): the edit bench measures frame work when a task outside the drag has no thread time

* refactor(studio): hooks hand back stable handlers themselves, keeping App.tsx under 600 lines

* test(studio): the edit bench says why a case's frame work is unknown

* fix(studio): the edit bench counts a task without thread time at its wall time

* perf(studio): draw toasts on an opaque surface without backdrop blur

* fix(studio): keep stable handlers bound to the project they were made in

* fix(studio): every stable handler names the project it belongs to

* style(studio): format the stable handler call sites

* refactor(studio): name the timeline editing handler objects before wrapping them
2026-10-02 21:15:19 +00:00

44 lines
1.3 KiB
TypeScript

import { buildProjectApiPath } from "./projectRouting";
export interface FrameCaptureRequest {
projectId: string;
compositionPath: string | null;
currentTime: number;
origin?: string;
version?: number;
}
function normalizeCompositionPath(compositionPath: string | null): string {
return compositionPath && compositionPath !== "master" ? compositionPath : "index.html";
}
export function buildFrameCaptureUrl({
projectId,
compositionPath,
currentTime,
origin = window.location.origin,
version = Date.now(),
}: FrameCaptureRequest): string {
const compPath = normalizeCompositionPath(compositionPath);
const url = new URL(
buildProjectApiPath(projectId, `/thumbnail/${encodeURIComponent(compPath)}`),
origin,
);
url.searchParams.set("t", Math.max(0, currentTime).toFixed(3));
url.searchParams.set("format", "png");
url.searchParams.set("output", "source");
url.searchParams.set("v", String(version));
return url.toString();
}
export function buildFrameCaptureFilename(compositionPath: string | null, currentTime: number) {
const compPath = normalizeCompositionPath(compositionPath);
const base =
compPath
.split("/")
.pop()
?.replace(/\.html$/i, "") || "frame";
const frameTime = Math.max(0, currentTime).toFixed(3).replace(".", "-");
return `${base}-${frameTime}s.png`;
}