@hyperframes/studio 0.8.123 → 0.8.124
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-yABdb6yk.js → hyperframes-player-ColOZ_78.js} +1 -1
- package/dist/assets/{index-Dt7lWtY7.js → index-BuSTrK-Z.js} +112 -112
- package/dist/assets/{index-DWjF2Kxw.js → index-CVuUfURE.js} +1 -1
- package/dist/assets/{index-LrNlT5Tg.css → index-D11atkBt.css} +1 -1
- package/dist/assets/{index-D77MIjSJ.js → index-jQEqFKMk.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/index.js +70 -49
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +8 -8
- package/src/components/OpenInDesktopButton.dom.test.tsx +27 -10
- package/src/components/OpenInDesktopButton.tsx +22 -15
- package/src/player/components/AudibleVideoClipContent.test.tsx +67 -0
- package/src/player/components/AudibleVideoClipContent.tsx +5 -4
- package/src/player/components/AudioWaveform.tsx +2 -1
- package/src/player/components/ClipPeakMarks.tsx +5 -2
- package/src/player/components/OutOfSyncBadge.tsx +1 -1
- package/src/player/components/Timeline.trackPadding.test.tsx +1 -3
- package/src/player/components/TimelineCanvas.tsx +1 -0
- package/src/player/components/TimelineClip.filmstrip.test.tsx +27 -0
- package/src/player/components/TimelineClipFades.test.tsx +2 -1
- package/src/player/components/timelineClipDragPreview.test.ts +31 -0
- package/src/player/components/timelineClipDragPreview.ts +42 -37
- package/src/player/hooks/useTimelinePlayer.seek.test.ts +11 -0
- package/src/styles/components.css +33 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/studio",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.124",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"dockview-react": "8.3.1",
|
|
61
61
|
"gsap": "^3.13.0",
|
|
62
62
|
"mediabunny": "^1.45.3",
|
|
63
|
-
"@hyperframes/core": "0.8.
|
|
64
|
-
"@hyperframes/
|
|
65
|
-
"@hyperframes/
|
|
66
|
-
"@hyperframes/
|
|
67
|
-
"@hyperframes/shader-transitions": "0.8.
|
|
68
|
-
"@hyperframes/studio-server": "0.8.
|
|
63
|
+
"@hyperframes/core": "0.8.124",
|
|
64
|
+
"@hyperframes/player": "0.8.124",
|
|
65
|
+
"@hyperframes/sdk": "0.8.124",
|
|
66
|
+
"@hyperframes/parsers": "0.8.124",
|
|
67
|
+
"@hyperframes/shader-transitions": "0.8.124",
|
|
68
|
+
"@hyperframes/studio-server": "0.8.124"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"vite": "^6.4.2",
|
|
82
82
|
"vitest": "^4.1.11",
|
|
83
83
|
"zustand": "^5.0.0",
|
|
84
|
-
"@hyperframes/producer": "0.8.
|
|
84
|
+
"@hyperframes/producer": "0.8.124"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"react": "19",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @vitest-environment happy-dom
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* "Edit with Framey": shown
|
|
4
|
+
* "Edit with Framey": shown where the preview server has the app or its download to offer; a press opens the project in the app,
|
|
5
5
|
* or introduces Framey with the download while the app cannot take it or is missing.
|
|
6
6
|
*/
|
|
7
7
|
import React, { act } from "react";
|
|
@@ -45,7 +45,7 @@ async function mount(): Promise<HTMLElement> {
|
|
|
45
45
|
|
|
46
46
|
const downloadHref = () =>
|
|
47
47
|
[...document.querySelectorAll("a")]
|
|
48
|
-
.find((a) => a.textContent?.includes("Get
|
|
48
|
+
.find((a) => a.textContent?.includes("Get the desktop app"))
|
|
49
49
|
?.getAttribute("href");
|
|
50
50
|
|
|
51
51
|
const button = () =>
|
|
@@ -68,31 +68,48 @@ it("stays hidden where the server has no hand-off (the desktop's own Studio)", a
|
|
|
68
68
|
expect(button()).toBeNull();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
it("stays hidden when the
|
|
72
|
-
serve(Response.json({ available: false }));
|
|
71
|
+
it("stays hidden when the app has no build for this machine (Windows)", async () => {
|
|
72
|
+
serve(Response.json({ available: false, handoff: true, downloadUrl: null }));
|
|
73
73
|
await mount();
|
|
74
74
|
expect(button()).toBeNull();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
it("with the app installed but no download (Windows), shows only once the app can take the project", async () => {
|
|
78
|
+
serve(Response.json({ available: true, handoff: false, downloadUrl: null }));
|
|
79
|
+
await mount();
|
|
80
|
+
expect(button()).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("opens the project in an installed app that has no download (Windows)", async () => {
|
|
84
|
+
serve(Response.json({ available: true, handoff: true, downloadUrl: null }), {
|
|
85
|
+
opened: true,
|
|
86
|
+
app: "the HyperFrames desktop app",
|
|
87
|
+
});
|
|
88
|
+
await mount();
|
|
89
|
+
await act(async () => button()!.click());
|
|
90
|
+
expect(posts).toBe(1);
|
|
91
|
+
});
|
|
92
|
+
|
|
77
93
|
it("while the app cannot take a project yet, introduces Framey with the download and opens nothing", async () => {
|
|
78
|
-
|
|
94
|
+
const linux = `${DOWNLOAD}?os=linux`;
|
|
95
|
+
serve(Response.json({ available: true, handoff: false, downloadUrl: linux }), { opened: true });
|
|
79
96
|
await mount();
|
|
80
97
|
await act(async () => button()!.click());
|
|
81
98
|
expect(posts).toBe(0);
|
|
82
99
|
expect(document.body.textContent).toContain("Meet Framey");
|
|
83
|
-
expect(downloadHref()).toBe(
|
|
100
|
+
expect(downloadHref()).toBe(linux);
|
|
84
101
|
});
|
|
85
102
|
|
|
86
103
|
it("opens the project in the app and says so", async () => {
|
|
87
|
-
serve(Response.json({ available: true, handoff: true }), {
|
|
104
|
+
serve(Response.json({ available: true, handoff: true, downloadUrl: DOWNLOAD }), {
|
|
88
105
|
opened: true,
|
|
89
|
-
|
|
106
|
+
app: "the HyperFrames desktop app",
|
|
90
107
|
});
|
|
91
108
|
await mount();
|
|
92
109
|
await act(async () => button()!.click());
|
|
93
110
|
expect(posts).toBe(1);
|
|
94
111
|
expect(showToast).toHaveBeenCalledWith(
|
|
95
|
-
"Framey is opening this project in HyperFrames
|
|
112
|
+
"Framey is opening this project in the HyperFrames desktop app",
|
|
96
113
|
"info",
|
|
97
114
|
);
|
|
98
115
|
expect(button()!.dataset.opening).toBe("true");
|
|
@@ -100,7 +117,7 @@ it("opens the project in the app and says so", async () => {
|
|
|
100
117
|
});
|
|
101
118
|
|
|
102
119
|
it("introduces Framey and offers the download when the app is missing", async () => {
|
|
103
|
-
serve(Response.json({ available: true, handoff: true }), {
|
|
120
|
+
serve(Response.json({ available: true, handoff: true, downloadUrl: DOWNLOAD }), {
|
|
104
121
|
opened: false,
|
|
105
122
|
reason: "not-installed",
|
|
106
123
|
downloadUrl: DOWNLOAD,
|
|
@@ -8,7 +8,6 @@ import { Button, buttonBase, buttonSizes, buttonVariants, cn, Popover } from "./
|
|
|
8
8
|
// "Edit with Framey": the preview server (`/api/open-in-desktop`) says whether to show it and whether the app can
|
|
9
9
|
// take the project yet (its gate is the CLI's HANDOFF_READY); until then a press introduces Framey with the download.
|
|
10
10
|
const ROUTE = "/api/open-in-desktop";
|
|
11
|
-
const DOWNLOAD_URL = "https://hyperframes.dev/studio/download";
|
|
12
11
|
/** How far the pupils travel towards the pointer, in the glyph's own units. */
|
|
13
12
|
const GAZE = 2.2;
|
|
14
13
|
/** Long enough for the flight to finish before the label comes back. */
|
|
@@ -16,15 +15,20 @@ const OPENING_MS = 1600;
|
|
|
16
15
|
|
|
17
16
|
type OpenResult = { opened: true } | { opened: false; reason: string; downloadUrl: string };
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
type DesktopRoute = { handoff: boolean; downloadUrl: string | null };
|
|
19
|
+
|
|
20
|
+
/** Null hides the button: no route (the app's own Studio), or nothing here to open or download. */
|
|
21
|
+
function useDesktopRoute(): DesktopRoute | null {
|
|
22
|
+
const [route, setRoute] = useState<DesktopRoute | null>(null);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
let live = true;
|
|
24
25
|
studioApiFetch(ROUTE)
|
|
25
26
|
.then((res) => (res.ok ? res.json() : null))
|
|
26
|
-
.then((body: { available?: unknown; handoff?: unknown } | null) => {
|
|
27
|
-
if (live
|
|
27
|
+
.then((body: { available?: unknown; handoff?: unknown; downloadUrl?: unknown } | null) => {
|
|
28
|
+
if (!live || body?.available !== true) return;
|
|
29
|
+
const handoff = body.handoff === true;
|
|
30
|
+
const downloadUrl = typeof body.downloadUrl === "string" ? body.downloadUrl : null;
|
|
31
|
+
if (handoff || downloadUrl) setRoute({ handoff, downloadUrl });
|
|
28
32
|
})
|
|
29
33
|
.catch(() => {});
|
|
30
34
|
return () => {
|
|
@@ -74,7 +78,7 @@ export function OpenInDesktopButton() {
|
|
|
74
78
|
const open = async () => {
|
|
75
79
|
if (!route.handoff) {
|
|
76
80
|
trackStudioEvent("toolbar_action", { action: "open_in_desktop" });
|
|
77
|
-
setDownloadUrl(
|
|
81
|
+
setDownloadUrl(route.downloadUrl);
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
if (opening) return;
|
|
@@ -84,7 +88,7 @@ export function OpenInDesktopButton() {
|
|
|
84
88
|
const res = await studioApiFetch(ROUTE, { method: "POST" });
|
|
85
89
|
const result = (await res.json()) as OpenResult;
|
|
86
90
|
if (result.opened) {
|
|
87
|
-
showToast("Framey is opening this project in HyperFrames
|
|
91
|
+
showToast("Framey is opening this project in the HyperFrames desktop app", "info");
|
|
88
92
|
await new Promise((done) => setTimeout(done, OPENING_MS));
|
|
89
93
|
} else setDownloadUrl(result.downloadUrl);
|
|
90
94
|
} catch {
|
|
@@ -114,11 +118,16 @@ export function OpenInDesktopButton() {
|
|
|
114
118
|
variant="ghost"
|
|
115
119
|
data-testid="header-open-in-desktop"
|
|
116
120
|
data-opening={opening || undefined}
|
|
117
|
-
title="Open this project in HyperFrames
|
|
118
|
-
className="hf-framey-trigger gap-1.5 pl-1
|
|
119
|
-
icon={<FrameyGlyph size={
|
|
121
|
+
title="Open this project in the HyperFrames desktop app and edit it with Framey"
|
|
122
|
+
className="hf-framey-trigger gap-1.5 border border-accent/40 bg-accent/10 pl-1 font-semibold text-text-0 enabled:hover:bg-accent/20"
|
|
123
|
+
icon={<FrameyGlyph size={24} className="hf-framey" eyeRef={eye} />}
|
|
120
124
|
>
|
|
121
125
|
{opening ? "Opening in the app…" : "Edit with Framey"}
|
|
126
|
+
{!opening && (
|
|
127
|
+
<span className="rounded-full bg-accent px-1.5 text-[10px] leading-4 font-bold text-on-accent">
|
|
128
|
+
New
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
122
131
|
</Button>
|
|
123
132
|
}
|
|
124
133
|
>
|
|
@@ -126,9 +135,7 @@ export function OpenInDesktopButton() {
|
|
|
126
135
|
<FrameyGlyph size={36} />
|
|
127
136
|
<p className="text-step-12 font-medium text-text-0">Meet Framey</p>
|
|
128
137
|
</div>
|
|
129
|
-
<p className="mt-2 text-text-3">
|
|
130
|
-
I live in HyperFrames Studio, the free desktop app for macOS:
|
|
131
|
-
</p>
|
|
138
|
+
<p className="mt-2 text-balance text-text-3">I live in the free HyperFrames desktop app:</p>
|
|
132
139
|
<ul className="mt-1.5 grid gap-1 text-text-1">
|
|
133
140
|
<li>Chat to change anything in the video</li>
|
|
134
141
|
<li>Draw on a frame to point at it</li>
|
|
@@ -145,7 +152,7 @@ export function OpenInDesktopButton() {
|
|
|
145
152
|
className={cn(buttonBase, buttonVariants.primary, buttonSizes.md)}
|
|
146
153
|
onClick={() => trackStudioEvent("toolbar_action", { action: "get_desktop_app" })}
|
|
147
154
|
>
|
|
148
|
-
Get
|
|
155
|
+
Get the desktop app
|
|
149
156
|
</a>
|
|
150
157
|
</div>
|
|
151
158
|
</Popover>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { act, type ReactNode } from "react";
|
|
6
|
+
import { compile } from "tailwindcss";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { createHappyDomRootHarness } from "./testRootHarness";
|
|
9
|
+
import { AudibleVideoClipContent } from "./AudibleVideoClipContent";
|
|
10
|
+
|
|
11
|
+
const harness = createHappyDomRootHarness();
|
|
12
|
+
const STYLES_DIR = path.resolve(__dirname, "../../styles");
|
|
13
|
+
const TAILWIND_DIR = path.dirname(
|
|
14
|
+
createRequire(import.meta.url).resolve("tailwindcss/package.json"),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
async function studioCss() {
|
|
18
|
+
const load = async (id: string, base: string) => {
|
|
19
|
+
const file =
|
|
20
|
+
id === "tailwindcss" ? path.join(TAILWIND_DIR, "index.css") : path.resolve(base, id);
|
|
21
|
+
return { path: file, base: path.dirname(file), content: readFileSync(file, "utf8") };
|
|
22
|
+
};
|
|
23
|
+
const compiled = await compile(readFileSync(path.join(STYLES_DIR, "studio.css"), "utf8"), {
|
|
24
|
+
base: STYLES_DIR,
|
|
25
|
+
loadStylesheet: load,
|
|
26
|
+
});
|
|
27
|
+
return compiled.build([]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function renderStrip(wave: ReactNode) {
|
|
31
|
+
const host = document.createElement("div");
|
|
32
|
+
document.body.appendChild(host);
|
|
33
|
+
await act(async () => {
|
|
34
|
+
harness
|
|
35
|
+
.mount(host)
|
|
36
|
+
.render(<AudibleVideoClipContent thumbnail={<span>frames</span>} waveform={wave} />);
|
|
37
|
+
});
|
|
38
|
+
return host;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe("AudibleVideoClipContent", () => {
|
|
42
|
+
it("draws the sound on the audio clip's own surface, under half the clip", async () => {
|
|
43
|
+
const host = await renderStrip(<span>wave</span>);
|
|
44
|
+
const strip = host.querySelector<HTMLElement>('[data-testid="audible-video-wave"]');
|
|
45
|
+
expect(strip?.textContent).toBe("wave");
|
|
46
|
+
expect(strip?.style.backgroundColor).toBe("var(--timeline-clip-audio-bg)");
|
|
47
|
+
expect(strip?.style.height).toBe("50%");
|
|
48
|
+
expect(strip?.previousElementSibling?.getAttribute("style")).toContain("bottom: 50%");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("keeps only the peak mark in the strip, above the waveform canvas layer", async () => {
|
|
52
|
+
const style = document.createElement("style");
|
|
53
|
+
style.textContent = await studioCss();
|
|
54
|
+
document.head.appendChild(style);
|
|
55
|
+
const host = await renderStrip(
|
|
56
|
+
<span data-peak-badge>
|
|
57
|
+
▲<span data-peak-text> peaks +0.7 dBFS</span>
|
|
58
|
+
</span>,
|
|
59
|
+
);
|
|
60
|
+
const badge = host.querySelector<HTMLElement>("[data-peak-badge]")!;
|
|
61
|
+
const text = host.querySelector<HTMLElement>("[data-peak-text]")!;
|
|
62
|
+
expect(getComputedStyle(text).display).toBe("none");
|
|
63
|
+
// The waveform canvas sits in a z-index 10 layer (AudioWaveform).
|
|
64
|
+
expect(Number(getComputedStyle(badge).zIndex)).toBeGreaterThan(10);
|
|
65
|
+
style.remove();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
/** Share of the clip height the sound strip takes under a video's thumbnails. */
|
|
4
|
-
const AUDIBLE_VIDEO_WAVE_SHARE = 0.
|
|
3
|
+
/** Share of the clip height the sound strip takes under a video's thumbnails: tall enough for the bars to read. */
|
|
4
|
+
const AUDIBLE_VIDEO_WAVE_SHARE = 0.5;
|
|
5
|
+
const AUDIO_CLIP_SURFACE = "var(--timeline-clip-audio-bg)";
|
|
5
6
|
|
|
6
7
|
/** A video that carries sound: thumbnails on top, its waveform strip along the bottom. */
|
|
7
8
|
export function AudibleVideoClipContent({
|
|
@@ -18,9 +19,9 @@ export function AudibleVideoClipContent({
|
|
|
18
19
|
{thumbnail}
|
|
19
20
|
</div>
|
|
20
21
|
<div
|
|
21
|
-
className="absolute inset-x-0 bottom-0
|
|
22
|
+
className="audible-video-wave absolute inset-x-0 bottom-0"
|
|
22
23
|
data-testid="audible-video-wave"
|
|
23
|
-
style={{ height: waveHeight }}
|
|
24
|
+
style={{ height: waveHeight, backgroundColor: AUDIO_CLIP_SURFACE }}
|
|
24
25
|
>
|
|
25
26
|
{waveform}
|
|
26
27
|
</div>
|
|
@@ -26,6 +26,7 @@ const BAR_STEP = 3;
|
|
|
26
26
|
|
|
27
27
|
export const rendersWaveform = (el: { tag: string }) => el.tag === "audio";
|
|
28
28
|
const FADE_GHOST_OPACITY = 0.27;
|
|
29
|
+
export const WAVEFORM_LAYER_Z = 10;
|
|
29
30
|
|
|
30
31
|
type BarGeometry = { x: number; width: number; height: number; gain: number };
|
|
31
32
|
|
|
@@ -236,7 +237,7 @@ export const AudioWaveform = memo(function AudioWaveform({
|
|
|
236
237
|
|
|
237
238
|
return (
|
|
238
239
|
<div ref={rootRef} className="absolute inset-0">
|
|
239
|
-
<div className="absolute inset-0 overflow-hidden" style={{ zIndex:
|
|
240
|
+
<div className="absolute inset-0 overflow-hidden" style={{ zIndex: WAVEFORM_LAYER_Z }}>
|
|
240
241
|
<canvas
|
|
241
242
|
ref={setCanvasRef}
|
|
242
243
|
className="absolute inset-x-0 bottom-0 w-full"
|
|
@@ -49,8 +49,11 @@ export function ClipPeakMarks({
|
|
|
49
49
|
}}
|
|
50
50
|
/>
|
|
51
51
|
))}
|
|
52
|
-
<span
|
|
53
|
-
|
|
52
|
+
<span
|
|
53
|
+
className="absolute top-0 right-1 font-mono text-[9px] leading-none text-red-400"
|
|
54
|
+
data-peak-badge
|
|
55
|
+
>
|
|
56
|
+
▲<span data-peak-text> peaks {dbText(peakDbfs)}</span>
|
|
54
57
|
</span>
|
|
55
58
|
</div>
|
|
56
59
|
)}
|
|
@@ -105,7 +105,7 @@ export const OutOfSyncBadge = memo(function OutOfSyncBadge({ el }: { el: Timelin
|
|
|
105
105
|
aria-label={`Out of sync with ${partnerName} by ${label} frames`}
|
|
106
106
|
title={`Out of sync with ${partnerName} by ${label} — click for Move or Slip into Sync`}
|
|
107
107
|
data-testid="out-of-sync-badge"
|
|
108
|
-
className="absolute bottom-0.5 left-1 z-[
|
|
108
|
+
className="absolute bottom-0.5 left-1 z-[12] cursor-pointer rounded-[3px] bg-red-600 px-1 font-mono text-[9px] leading-[14px] text-white tabular-nums"
|
|
109
109
|
onPointerDown={stop}
|
|
110
110
|
onDoubleClick={stop}
|
|
111
111
|
onClick={open}
|
|
@@ -99,9 +99,7 @@ describe("Timeline trackPadding", () => {
|
|
|
99
99
|
const clip = host.querySelector('[data-clip][data-el-id="c0"]')!;
|
|
100
100
|
pointer(clip, "pointerdown", RULER_H + TRACK_H / 2);
|
|
101
101
|
pointer(window, "pointermove", ROW1_MID);
|
|
102
|
-
const ghost =
|
|
103
|
-
host.querySelectorAll<HTMLElement>(".absolute.pointer-events-none"),
|
|
104
|
-
).find((el) => el.style.zIndex === "30" && !el.dataset.testid);
|
|
102
|
+
const ghost = host.querySelector<HTMLElement>('[data-testid="timeline-drag-landing"]');
|
|
105
103
|
expect(top(ghost)).toBe(`${RULER_H + TRACK_H + CLIP_Y}px`);
|
|
106
104
|
pointer(window, "pointermove", RULER_H + 3 * TRACK_H + TRACK_H / 2);
|
|
107
105
|
const lane = host.querySelector<HTMLElement>("[data-timeline-new-track-lane]");
|
|
@@ -134,6 +134,7 @@ export const TimelineCanvas = memo(function TimelineCanvas() {
|
|
|
134
134
|
lane + snapped start), parallel to the ghost. Hidden in insert mode. */}
|
|
135
135
|
{draggedClip?.started && draggedClip.insertRow == null && draggedRowIndex >= 0 && (
|
|
136
136
|
<div
|
|
137
|
+
data-testid="timeline-drag-landing"
|
|
137
138
|
className="absolute pointer-events-none"
|
|
138
139
|
style={{
|
|
139
140
|
top: props.rowGeometry.getRowTop(draggedRowIndex) + CLIP_Y,
|
|
@@ -6,6 +6,7 @@ import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
|
6
6
|
import { loadStylesheet, STYLES_DIR } from "../../styles/styleSources";
|
|
7
7
|
import { cleanupMounted, trackedRoot } from "../../components/ui/mountHost.testHelpers";
|
|
8
8
|
import { TimelineClip } from "./TimelineClip";
|
|
9
|
+
import { WAVEFORM_LAYER_Z } from "./AudioWaveform";
|
|
9
10
|
import { renderClipChildren } from "./timelineClipChildren";
|
|
10
11
|
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
11
12
|
|
|
@@ -23,6 +24,7 @@ beforeAll(async () => {
|
|
|
23
24
|
afterEach(() => {
|
|
24
25
|
cleanupMounted();
|
|
25
26
|
usePlayerStore.getState().setLintFindingsByElement(new Map());
|
|
27
|
+
usePlayerStore.getState().setElements([]);
|
|
26
28
|
document.body.innerHTML = "";
|
|
27
29
|
});
|
|
28
30
|
|
|
@@ -153,4 +155,29 @@ describe("Filmstrip clips", () => {
|
|
|
153
155
|
);
|
|
154
156
|
expect(css).toMatch(/\.timeline-clip:not\(\.is-audio\)\s*\{\s*border-width:\s*0;/);
|
|
155
157
|
});
|
|
158
|
+
|
|
159
|
+
const audioPillZ = () =>
|
|
160
|
+
Number(
|
|
161
|
+
css.match(/\.timeline-clip\.is-audio \.timeline-clip__label\s*\{[^}]*z-index:\s*(\d+)/)?.[1],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
it("draws an audio clip's name pill over its waveform", () => {
|
|
165
|
+
expect(audioPillZ()).toBeGreaterThan(WAVEFORM_LAYER_Z);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("keeps the out-of-sync badge over the audio name pill", () => {
|
|
169
|
+
const audio = {
|
|
170
|
+
id: "clip",
|
|
171
|
+
domId: "clip",
|
|
172
|
+
label: "City",
|
|
173
|
+
tag: "audio",
|
|
174
|
+
start: 1.7,
|
|
175
|
+
duration: 4,
|
|
176
|
+
};
|
|
177
|
+
const synced = { ...audio, track: 1, playbackStart: 0, syncOrigin: "lk-1" };
|
|
178
|
+
const video = { ...synced, id: "talk", domId: "talk", tag: "video", start: 1, track: 0 };
|
|
179
|
+
usePlayerStore.getState().setElements([video, synced]);
|
|
180
|
+
const badge = render("audio", synced, false).querySelector('[data-testid="out-of-sync-badge"]');
|
|
181
|
+
expect(Number(badge?.className.match(/\bz-\[(\d+)\]/)?.[1])).toBeGreaterThan(audioPillZ());
|
|
182
|
+
});
|
|
156
183
|
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React, { act } from "react";
|
|
4
4
|
import { createRoot, type Root } from "react-dom/client";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { WAVEFORM_LAYER_Z } from "./AudioWaveform";
|
|
6
7
|
import { usePlayerStore, type TimelineElement } from "../store/playerStore";
|
|
7
8
|
import { TimelineClipFades, useClipFadeDraft } from "./TimelineClipFades";
|
|
8
9
|
import { TimelineEditProvider } from "../../contexts/TimelineEditContext";
|
|
@@ -298,7 +299,7 @@ describe("TimelineClipFades", () => {
|
|
|
298
299
|
it("paints the handles above the clip's waveform and thumbnail layers", () => {
|
|
299
300
|
const { host } = render(clip);
|
|
300
301
|
const layer = host.querySelector<HTMLElement>('[data-testid="clip"]')?.firstElementChild;
|
|
301
|
-
expect(Number((layer as HTMLElement).style.zIndex)).toBeGreaterThan(
|
|
302
|
+
expect(Number((layer as HTMLElement).style.zIndex)).toBeGreaterThan(WAVEFORM_LAYER_Z);
|
|
302
303
|
});
|
|
303
304
|
|
|
304
305
|
it("splits a clip narrower than two targets between the handles", () => {
|
|
@@ -321,6 +321,20 @@ describe("guideIfSaved — a guide only where the clip saves", () => {
|
|
|
321
321
|
expect(guideIfSaved(el, { start: 2.217 }, edge, 1440)).toBeNull();
|
|
322
322
|
});
|
|
323
323
|
|
|
324
|
+
it("keeps the pointer's start when a move's snap would save off the target", () => {
|
|
325
|
+
// 1440 px/s: a 31/30 s clip whose end snaps to 3.25s would save at 2.22s and jump 4px on release.
|
|
326
|
+
const el = clip("a", 0, 1, 31 / 30, 0, "div");
|
|
327
|
+
const { drag } = horizontalDrag(el, 0.5, 0);
|
|
328
|
+
const context = {
|
|
329
|
+
...ctx(undefined, [el]),
|
|
330
|
+
pps: 1440,
|
|
331
|
+
buildSnapTargets: () => [{ time: 3.25, type: "clip-edge" as const }],
|
|
332
|
+
};
|
|
333
|
+
const x = drag.originClientX + 1.22 * 1440;
|
|
334
|
+
const next = computeDragPreview(drag, x, drag.originClientY, context);
|
|
335
|
+
expect(next).toMatchObject({ previewStart: 2.22, snapTime: null, snapType: null });
|
|
336
|
+
});
|
|
337
|
+
|
|
324
338
|
it("draws no guide for a move whose saved start misses the target", () => {
|
|
325
339
|
const nested = { ...moodboard, parentCompositionStart: 1 / 30 };
|
|
326
340
|
const { drag } = horizontalDrag(nested, 0.5, 0);
|
|
@@ -388,6 +402,23 @@ describe("computeResizePreview — composition source continuity", () => {
|
|
|
388
402
|
expect(result).toMatchObject({ previewStart: 1.03, snapTime: null, snapType: null });
|
|
389
403
|
});
|
|
390
404
|
|
|
405
|
+
it("keeps the pointer's end when a tail snap would save off the target", () => {
|
|
406
|
+
// 1440 px/s: snapping 1.125s + 2.12s to 3.25s needs a 2.125s duration, which saves 7px off.
|
|
407
|
+
const result = computeResizePreview(
|
|
408
|
+
{
|
|
409
|
+
element: clip("a", 0, 1.125, 2, 0, "div"),
|
|
410
|
+
edge: "end",
|
|
411
|
+
originClientX: 0,
|
|
412
|
+
previewStart: 1.125,
|
|
413
|
+
previewDuration: 2,
|
|
414
|
+
started: true,
|
|
415
|
+
},
|
|
416
|
+
173,
|
|
417
|
+
{ scroll: fakeScroll(), pps: 1440, buildSnapTargets: () => [{ time: 3.25, type: "grid" }] },
|
|
418
|
+
);
|
|
419
|
+
expect(result).toMatchObject({ previewDuration: 2.12, snapTime: null, snapType: null });
|
|
420
|
+
});
|
|
421
|
+
|
|
391
422
|
it("does not let a tail snap shrink a clip below the drag's minimum duration", () => {
|
|
392
423
|
const result = computeResizePreview(
|
|
393
424
|
{
|
|
@@ -241,7 +241,7 @@ export function computeDragPreview(
|
|
|
241
241
|
drag.element.key ?? drag.element.id,
|
|
242
242
|
!isMusicTrack(drag.element),
|
|
243
243
|
);
|
|
244
|
-
const
|
|
244
|
+
const snapped = snapMoveToTargets(
|
|
245
245
|
nextMove.start,
|
|
246
246
|
drag.element.duration,
|
|
247
247
|
targets,
|
|
@@ -251,6 +251,11 @@ export function computeDragPreview(
|
|
|
251
251
|
dragMaxStart + drag.element.duration,
|
|
252
252
|
ctx.gridStep,
|
|
253
253
|
);
|
|
254
|
+
// A snap the saved clip would miss jumps on release, so the clip stays where the pointer put it.
|
|
255
|
+
const target = snapTarget(snapped);
|
|
256
|
+
const missed =
|
|
257
|
+
target !== null && !guideIfSaved(drag.element, { start: snapped.start }, target, pps);
|
|
258
|
+
const snap = missed ? { start: nextMove.start, snapTime: null, snapType: null } : snapped;
|
|
254
259
|
// A group moves rigidly: the grabbed clip stops where any mover would cross its host's start.
|
|
255
260
|
const group = resolveGroupDrag(drag, ctx);
|
|
256
261
|
const dragKey = drag.element.key ?? drag.element.id;
|
|
@@ -268,11 +273,7 @@ export function computeDragPreview(
|
|
|
268
273
|
return { ...drag, started: true };
|
|
269
274
|
}
|
|
270
275
|
const { track: previewTrack, insertRow } = placement;
|
|
271
|
-
const
|
|
272
|
-
placement.start === snap.start && snap.snapTime !== null && snap.snapType !== null
|
|
273
|
-
? { time: snap.snapTime, type: snap.snapType }
|
|
274
|
-
: null;
|
|
275
|
-
const guide = guideIfSaved(drag.element, { start: snap.start }, target, pps);
|
|
276
|
+
const guide = placement.start === snap.start ? snapTarget(snap) : null;
|
|
276
277
|
return {
|
|
277
278
|
...drag,
|
|
278
279
|
started: true,
|
|
@@ -289,6 +290,9 @@ export function computeDragPreview(
|
|
|
289
290
|
};
|
|
290
291
|
}
|
|
291
292
|
|
|
293
|
+
const snapTarget = (s: { snapTime: number | null; snapType: TimelineSnapType | null }) =>
|
|
294
|
+
s.snapTime !== null && s.snapType !== null ? { time: s.snapTime, type: s.snapType } : null;
|
|
295
|
+
|
|
292
296
|
/** A snap's guide, kept only when the clip's edge as its file will save it is within a pixel of it. */
|
|
293
297
|
export function guideIfSaved(
|
|
294
298
|
element: TimelineElement,
|
|
@@ -392,37 +396,38 @@ export function computeResizePreview(
|
|
|
392
396
|
);
|
|
393
397
|
const gridStep = ctx.gridStep ?? 0;
|
|
394
398
|
let snap: TimelineSnapTarget | null = null;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
399
|
+
const snapSecs = TIMELINE_SNAP_PX / Math.max(pps, 1);
|
|
400
|
+
if (resize.edge === "end") {
|
|
401
|
+
const edgeTime = nextResize.start + nextResize.duration;
|
|
402
|
+
const { time: snapped, target } = snapTimelineTime(edgeTime, trimTargets, snapSecs, gridStep);
|
|
403
|
+
// Stay within [start+minDuration, maxEnd] so the snap can't create a
|
|
404
|
+
// degenerate clip or run past the source/composition limit.
|
|
405
|
+
const snappedDuration = Math.round((snapped - nextResize.start) * 1000) / 1000;
|
|
406
|
+
if (
|
|
407
|
+
target &&
|
|
408
|
+
snapped <= maxEnd + 1e-6 &&
|
|
409
|
+
snappedDuration >= resolveTimelineMinDuration() - 1e-6
|
|
410
|
+
) {
|
|
411
|
+
const onTarget =
|
|
412
|
+
snapped === edgeTime ? nextResize : { ...nextResize, duration: snappedDuration };
|
|
413
|
+
snap = guideIfSaved(resize.element, onTarget, target, pps);
|
|
414
|
+
if (snap) nextResize = onTarget;
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
const { time: snapped, target } = snapTimelineTime(
|
|
418
|
+
nextResize.start,
|
|
419
|
+
trimTargets,
|
|
420
|
+
snapSecs,
|
|
421
|
+
gridStep,
|
|
422
|
+
);
|
|
423
|
+
const clip = { ...nextResize, playbackRate: resize.element.playbackRate };
|
|
424
|
+
const delta = snapped - nextResize.start;
|
|
425
|
+
const bounds = clipStartTrimDeltaBounds(clip, minStart, resolveTimelineMinDuration());
|
|
426
|
+
if (target && delta >= bounds.minDelta - 1e-6 && delta <= bounds.maxDelta + 1e-6) {
|
|
427
|
+
const onTarget =
|
|
428
|
+
snapped === nextResize.start ? nextResize : applyClipStartTrimDelta(clip, delta);
|
|
429
|
+
snap = guideIfSaved(resize.element, onTarget, target, pps);
|
|
430
|
+
if (snap) nextResize = onTarget;
|
|
426
431
|
}
|
|
427
432
|
}
|
|
428
433
|
|
|
@@ -406,6 +406,17 @@ describe("useTimelinePlayer preview frame (a trim's dragged edge)", () => {
|
|
|
406
406
|
unmountWithAct(root);
|
|
407
407
|
});
|
|
408
408
|
|
|
409
|
+
it("reads the playing transport's own time, not the playhead's, under a preview frame", () => {
|
|
410
|
+
const { api, root, adapter } = renderAttachedTimelinePlayer();
|
|
411
|
+
seekWithAct(api, 2);
|
|
412
|
+
setStorePlaying();
|
|
413
|
+
previewFrame(5);
|
|
414
|
+
adapter.seek(7);
|
|
415
|
+
act(() => api.pause());
|
|
416
|
+
expect(usePlayerStore.getState().currentTime).toBe(7);
|
|
417
|
+
unmountWithAct(root);
|
|
418
|
+
});
|
|
419
|
+
|
|
409
420
|
it("leaves live playback alone", () => {
|
|
410
421
|
const { api, root, adapter } = renderAttachedTimelinePlayer();
|
|
411
422
|
seekWithAct(api, 2);
|