@hyperframes/studio 0.4.36 → 0.4.38
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/index-18P_dZeo.js +93 -0
- package/dist/assets/index-BLrgRQSu.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/src/App.tsx +130 -51
- package/src/components/nle/NLELayout.tsx +43 -8
- package/src/components/sidebar/LeftSidebar.tsx +26 -0
- package/src/icons/SystemIcons.tsx +2 -0
- package/src/player/components/PlayerControls.tsx +3 -44
- package/src/player/components/timelineTheme.ts +3 -3
- package/src/player/hooks/useTimelinePlayer.ts +2 -2
- package/src/player/lib/time.test.ts +11 -1
- package/src/player/lib/time.ts +6 -0
- package/src/utils/frameCapture.test.ts +26 -0
- package/src/utils/frameCapture.ts +38 -0
- package/dist/assets/index-Bj3m6A02.js +0 -93
- package/dist/assets/index-_h8opaGY.css +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { buildFrameCaptureFilename, buildFrameCaptureUrl } from "./frameCapture";
|
|
3
|
+
|
|
4
|
+
describe("frame capture utilities", () => {
|
|
5
|
+
it("builds a PNG capture URL for the master composition", () => {
|
|
6
|
+
vi.useFakeTimers();
|
|
7
|
+
vi.setSystemTime(new Date("2026-04-29T12:00:00Z"));
|
|
8
|
+
|
|
9
|
+
expect(
|
|
10
|
+
buildFrameCaptureUrl({
|
|
11
|
+
projectId: "demo project",
|
|
12
|
+
compositionPath: null,
|
|
13
|
+
currentTime: 1.23456,
|
|
14
|
+
origin: "http://localhost:5194",
|
|
15
|
+
}),
|
|
16
|
+
).toBe(
|
|
17
|
+
"http://localhost:5194/api/projects/demo%20project/thumbnail/index.html?t=1.235&format=png&v=1777464000000",
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
vi.useRealTimers();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("builds a safe filename from a nested composition path", () => {
|
|
24
|
+
expect(buildFrameCaptureFilename("compositions/intro.html", 2.5)).toBe("intro-2-500s.png");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface FrameCaptureRequest {
|
|
2
|
+
projectId: string;
|
|
3
|
+
compositionPath: string | null;
|
|
4
|
+
currentTime: number;
|
|
5
|
+
origin?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function normalizeCompositionPath(compositionPath: string | null): string {
|
|
9
|
+
return compositionPath && compositionPath !== "master" ? compositionPath : "index.html";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function buildFrameCaptureUrl({
|
|
13
|
+
projectId,
|
|
14
|
+
compositionPath,
|
|
15
|
+
currentTime,
|
|
16
|
+
origin = window.location.origin,
|
|
17
|
+
}: FrameCaptureRequest): string {
|
|
18
|
+
const compPath = normalizeCompositionPath(compositionPath);
|
|
19
|
+
const url = new URL(
|
|
20
|
+
`/api/projects/${encodeURIComponent(projectId)}/thumbnail/${encodeURIComponent(compPath)}`,
|
|
21
|
+
origin,
|
|
22
|
+
);
|
|
23
|
+
url.searchParams.set("t", Math.max(0, currentTime).toFixed(3));
|
|
24
|
+
url.searchParams.set("format", "png");
|
|
25
|
+
url.searchParams.set("v", String(Date.now()));
|
|
26
|
+
return url.toString();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function buildFrameCaptureFilename(compositionPath: string | null, currentTime: number) {
|
|
30
|
+
const compPath = normalizeCompositionPath(compositionPath);
|
|
31
|
+
const base =
|
|
32
|
+
compPath
|
|
33
|
+
.split("/")
|
|
34
|
+
.pop()
|
|
35
|
+
?.replace(/\.html$/i, "") || "frame";
|
|
36
|
+
const frameTime = Math.max(0, currentTime).toFixed(3).replace(".", "-");
|
|
37
|
+
return `${base}-${frameTime}s.png`;
|
|
38
|
+
}
|