@hyperframes/studio 0.4.37 → 0.4.39
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-BLrgRQSu.css +1 -0
- package/dist/assets/index-D4-n3yWG.js +93 -0
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/src/App.tsx +139 -56
- 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/Timeline.tsx +5 -2
- package/src/player/components/TimelineClip.tsx +2 -1
- package/src/player/components/timelineTheme.test.ts +19 -0
- package/src/player/components/timelineTheme.ts +8 -4
- package/src/player/hooks/useTimelinePlayer.test.ts +198 -0
- package/src/player/hooks/useTimelinePlayer.ts +263 -108
- package/src/player/lib/time.test.ts +11 -1
- package/src/player/lib/time.ts +6 -0
- package/src/player/store/playerStore.ts +1 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { formatFrameTime, frameToSeconds, secondsToFrame, formatTime } from "./time";
|
|
2
|
+
import { formatFrameTime, frameToSeconds, secondsToFrame, stepFrameTime, formatTime } from "./time";
|
|
3
3
|
|
|
4
4
|
describe("formatTime", () => {
|
|
5
5
|
it("formats zero seconds", () => {
|
|
@@ -72,4 +72,14 @@ describe("frame helpers", () => {
|
|
|
72
72
|
it("formats current and total frame display", () => {
|
|
73
73
|
expect(formatFrameTime(1, 5)).toBe("30f / 150f");
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it("steps from a truncated runtime time by integer frame index", () => {
|
|
77
|
+
expect(stepFrameTime(0.0333333, 1)).toBe(2 / 30);
|
|
78
|
+
expect(stepFrameTime(0.0666666, 1)).toBe(3 / 30);
|
|
79
|
+
expect(stepFrameTime(0.0666666, -1)).toBe(1 / 30);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("clamps frame stepping at zero", () => {
|
|
83
|
+
expect(stepFrameTime(0, -1)).toBe(0);
|
|
84
|
+
});
|
|
75
85
|
});
|
package/src/player/lib/time.ts
CHANGED
|
@@ -19,6 +19,12 @@ export function frameToSeconds(frame: number, fps = STUDIO_PREVIEW_FPS): number
|
|
|
19
19
|
return frame / fps;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export function stepFrameTime(time: number, deltaFrames: number, fps = STUDIO_PREVIEW_FPS): number {
|
|
23
|
+
const currentFrame = secondsToFrame(time, fps);
|
|
24
|
+
const nextFrame = Math.max(0, currentFrame + deltaFrames);
|
|
25
|
+
return frameToSeconds(nextFrame, fps);
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
export function formatFrameTime(time: number, duration: number, fps = STUDIO_PREVIEW_FPS): string {
|
|
23
29
|
const currentFrame = secondsToFrame(time, fps);
|
|
24
30
|
const totalFrames = secondsToFrame(duration, fps);
|
|
@@ -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
|
+
}
|