mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* feat(studio): show clip speed in the clip name as [150%] or [ramp] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): one fx badge per clip replaces the per-tool and link badges Grey with no effects, white with any. The tooltip lists look, voice, other fx, crop and ducking; a click opens the clip menu. The volume badge stays when volume is off 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): premiere-style audio gain dialog on G Set Gain to, Adjust Gain by, Normalize Max Peak to, Normalize All Peaks to and Normalize loudness to -16 LUFS, with the selection's peak amplitude read from the peak map. Writes data-volume on every selected clip with sound as one undo step. The clip menu's Normalize loudness becomes Audio Gain... (G). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): use a theme blue for the audio gain OK button Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): keep shortcuts out of the audio gain modal; refuse while recording Keys pressed inside an aria-modal dialog no longer reach the global hotkeys, so Delete on the focused OK button cannot delete the clips the dialog edits. The multi-clip write refuses during a recording like the single-clip one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): offer link for any unlinked video and audio pair Link no longer requires the same file and identical timing, matching Premiere. Same-file pairs get a sync origin so a trimmed or moved audio shows its offset; different files link without one. Merge back is disabled until the pair is in sync. Linked moves keep the offset, and a trim only carries to a partner whose edge is at the same time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): shift and cmd-click add timeline clips to the selection A modifier click on a clip replaced the selection, so a video and an audio could never both be selected and Link never appeared. Shift, Cmd and Ctrl now toggle the clip (and its link partners unless Alt) in the selection; Shift no longer turns a clip click into a time-range popover. Right-clicking a lone unlinked video or audio offers Link when exactly one opposite-kind clip from the same file sits on another track. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): keep audio inside its partner video and make cmd-click add in every host A modifier click passed the toggle as an argument to an optional onSelectElement call, so hosts without that handler (desktop) never ran it. An audio clip linked to a video, or sharing its sync origin, now stays inside that video's span while dragged or trimmed, Alt edits included, unless the video moves or trims in the same gesture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): hold the drag actor at the partner-video clamp The dragged audio's ghost followed the pointer past the video's end while the landing stayed clamped; it now stops where the clip will land. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): preview a look on hover in the clip menu before applying it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(studio): trim comments the clip-link names already carry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): unlinking clears the timeline selection After Unlink both clips stayed selected, so the next edge trim ran the multi-select group resize and the former partner still followed. Unlink from the menu, the shortcut or an Alt edit now leaves nothing selected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sdk): keep a linked partner's end when a trim changes the grabbed duration Copying the grabbed clip's duration to a partner that starts later pushed the partner's end past the clip both ended on. The partner's duration is now the shared new end minus its own start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): keep every moving detached audio inside its video, after placement too The containment clamp ran before collision placement and only for the grabbed clip, so a drop pushed past an obstacle, or audio carried along in a multi-selection, could land outside its video. The allowed shift is now the intersection over every moving audio, and a placement outside it is rejected. Link partners are matched within their source file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): carry the normalize refusal and save outcomes into the gain dialog Normalize moved from the clip menu into the Audio Gain dialog here, so the volume-lane refusal and the saved/refused/failed checks go with it: a lane owned clip is refused, and a failed single or multi-clip save rejects instead of reporting success. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(studio): trim comments the gain and multiselect layer added Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(sdk): split the linked partner's duration out of partnerTiming Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sdk): refuse a linked trim whose new end would cross the partner's start With linked video [2,8] and audio [3,8], setTiming(video, {duration: 0.5}) computed a partner duration of -0.5, skipped it, and committed the video alone, leaving the audio outside its video. The partner edits are now planned before any mutation; a non-positive partner duration throws ("Linked audio would start after the new end — unlink or trim the audio first.") and can() reports E_LINKED_PARTNER_CROSSED, so nothing is written and the undo stack is untouched. In Studio the refusal fails the cutover (never declines into the legacy path) and the timeline resize toast shows the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sdk): key a linked edit's grabbed baselines by composition scope planLinkedTiming stored each target's timing under its raw data-link id, while linkedPartnerIds scopes link ids to their host composition. One setTiming naming a root video and a nested video that both use lk-1 kept only the nested baseline, so the root audio was skipped and left past its trimmed video. Baselines are now keyed by host scope and link id, the same rule linkedPartnerIds uses, for both the partner trim and the crossing refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(sdk): run the two-scope grabbed-baseline cases on an inline composition too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
252 lines
12 KiB
TypeScript
252 lines
12 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { openComposition } from "./session.js";
|
|
|
|
const LINKED_HTML = `
|
|
<div data-hf-id="hf-stage" data-hf-root style="width:1280px;height:720px" data-duration="10">
|
|
<video data-hf-id="hf-talk" src="talk.mp4" muted data-link="lk-1" data-start="2" data-duration="6" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-talk-audio" src="talk.mp4" data-link="lk-1" data-start="2" data-duration="6" data-track-index="2"></audio>
|
|
<audio data-hf-id="hf-music" src="bgm.mp3" data-start="0" data-duration="10" data-track-index="3"></audio>
|
|
</div>
|
|
`.trim();
|
|
|
|
function attr(html: string, hfId: string, name: string): string | null {
|
|
const tag = new RegExp(`<[^>]*data-hf-id="${hfId}"[^>]*>`).exec(html)?.[0] ?? "";
|
|
return new RegExp(`\\b${name}="([^"]*)"`).exec(tag)?.[1] ?? null;
|
|
}
|
|
|
|
describe("setTiming on linked clips", () => {
|
|
it("moves link partners by default, each keeping its own track", async () => {
|
|
const comp = await openComposition(LINKED_HTML);
|
|
comp.setTiming("hf-talk", { start: 3, trackIndex: 1 });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-start")).toBe("3");
|
|
expect(attr(html, "hf-talk-audio", "data-start")).toBe("3");
|
|
expect(attr(html, "hf-talk", "data-track-index")).toBe("1");
|
|
expect(attr(html, "hf-talk-audio", "data-track-index")).toBe("2");
|
|
expect(attr(html, "hf-music", "data-start")).toBe("0");
|
|
});
|
|
|
|
it("trims partners to the same duration, and one undo reverts both", async () => {
|
|
const comp = await openComposition(LINKED_HTML);
|
|
comp.setTiming("hf-talk-audio", { duration: 4 });
|
|
expect(attr(comp.serialize(), "hf-talk", "data-duration")).toBe("4");
|
|
comp.undo();
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-duration")).toBe("6");
|
|
expect(attr(html, "hf-talk-audio", "data-duration")).toBe("6");
|
|
});
|
|
|
|
it("moves a misaligned pair by the same delta, preserving the offset", async () => {
|
|
const html = LINKED_HTML.replace(
|
|
'src="talk.mp4" data-link="lk-1" data-start="2"',
|
|
'src="talk.mp4" data-link="lk-1" data-start="3"',
|
|
);
|
|
const comp = await openComposition(html);
|
|
comp.setTiming("hf-talk", { start: 5 });
|
|
const out = comp.serialize();
|
|
expect(attr(out, "hf-talk", "data-start")).toBe("5");
|
|
expect(attr(out, "hf-talk-audio", "data-start")).toBe("6");
|
|
});
|
|
|
|
it("keeps a common end when partners start at different times", async () => {
|
|
const offset = LINKED_HTML.replace(
|
|
'data-hf-id="hf-talk-audio" src="talk.mp4" data-link="lk-1" data-start="2" data-duration="6"',
|
|
'data-hf-id="hf-talk-audio" src="talk.mp4" data-link="lk-1" data-start="3" data-duration="5"',
|
|
);
|
|
const comp = await openComposition(offset);
|
|
comp.setTiming("hf-talk", { duration: 4 });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-duration")).toBe("4");
|
|
expect(attr(html, "hf-talk-audio", "data-start")).toBe("3");
|
|
expect(attr(html, "hf-talk-audio", "data-duration")).toBe("3");
|
|
});
|
|
|
|
it("{ linked: false } edits one member and unlinks the pair", async () => {
|
|
const comp = await openComposition(LINKED_HTML);
|
|
comp.setTiming("hf-talk", { start: 5 }, { linked: false });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-start")).toBe("5");
|
|
expect(attr(html, "hf-talk-audio", "data-start")).toBe("2");
|
|
expect(attr(html, "hf-talk", "data-link")).toBeNull();
|
|
expect(attr(html, "hf-talk-audio", "data-link")).toBeNull();
|
|
comp.undo();
|
|
expect(attr(comp.serialize(), "hf-talk", "data-link")).toBe("lk-1");
|
|
});
|
|
|
|
it("a batch naming both members stays in sync", async () => {
|
|
const comp = await openComposition(LINKED_HTML);
|
|
comp.setElementTiming({ "hf-talk": { start: 4 }, "hf-talk-audio": { start: 4 } });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-start")).toBe("4");
|
|
expect(attr(html, "hf-talk-audio", "data-start")).toBe("4");
|
|
});
|
|
|
|
it.each([
|
|
'data-composition-id="child" data-composition-file="child.html"',
|
|
'data-composition-file="child.html"',
|
|
])("keeps a link group inside its own composition (host %s)", async (host) => {
|
|
const comp = await openComposition(
|
|
`
|
|
<div data-hf-id="hf-stage" data-hf-root style="width:1280px;height:720px" data-duration="10">
|
|
<video data-hf-id="hf-v" src="talk.mp4" muted data-link="lk-1" data-start="0" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-a" src="talk.mp4" data-link="lk-1" data-start="0" data-duration="4" data-track-index="1"></audio>
|
|
<div data-hf-id="hf-host" ${host} data-start="0" data-duration="10" data-track-index="2">
|
|
<video data-hf-id="hf-cv" src="b.mp4" muted data-link="lk-1" data-start="0" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-ca" src="b.mp4" data-link="lk-1" data-start="0" data-duration="4" data-track-index="1"></audio>
|
|
</div>
|
|
</div>`.trim(),
|
|
);
|
|
comp.setTiming("hf-v", { start: 2 });
|
|
let html = comp.serialize();
|
|
expect(attr(html, "hf-a", "data-start")).toBe("2");
|
|
expect(attr(html, "hf-cv", "data-start")).toBe("0");
|
|
expect(attr(html, "hf-ca", "data-start")).toBe("0");
|
|
comp.setTiming("hf-host/hf-cv", { start: 1 });
|
|
html = comp.serialize();
|
|
expect(attr(html, "hf-ca", "data-start")).toBe("1");
|
|
expect(attr(html, "hf-v", "data-start")).toBe("2");
|
|
expect(attr(html, "hf-a", "data-start")).toBe("2");
|
|
});
|
|
|
|
it("keeps a link group inside an inline composition that reuses the id", async () => {
|
|
const comp = await openComposition(
|
|
`
|
|
<div data-hf-id="hf-stage" data-hf-root style="width:1280px;height:720px" data-duration="10">
|
|
<video data-hf-id="hf-v" src="talk.mp4" muted data-link="lk-1" data-start="0" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-a" src="talk.mp4" data-link="lk-1" data-start="0" data-duration="4" data-track-index="1"></audio>
|
|
<div data-hf-id="hf-child" data-composition-id="child" data-start="0" data-duration="10" data-track-index="2">
|
|
<video data-hf-id="hf-cv" src="b.mp4" muted data-link="lk-1" data-start="5" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-ca" src="b.mp4" data-link="lk-1" data-start="5" data-duration="4" data-track-index="1"></audio>
|
|
</div>
|
|
</div>`.trim(),
|
|
);
|
|
comp.setTiming("hf-v", { start: 2 });
|
|
let html = comp.serialize();
|
|
expect(attr(html, "hf-a", "data-start")).toBe("2");
|
|
expect(attr(html, "hf-cv", "data-start")).toBe("5");
|
|
expect(attr(html, "hf-ca", "data-start")).toBe("5");
|
|
comp.setTiming("hf-cv", { start: 6 });
|
|
html = comp.serialize();
|
|
expect(attr(html, "hf-ca", "data-start")).toBe("6");
|
|
expect(attr(html, "hf-v", "data-start")).toBe("2");
|
|
comp.setTiming("hf-ca", { start: 7 }, { linked: false });
|
|
html = comp.serialize();
|
|
expect(attr(html, "hf-cv", "data-link")).toBeNull();
|
|
expect(attr(html, "hf-v", "data-link")).toBe("lk-1");
|
|
expect(attr(html, "hf-a", "data-link")).toBe("lk-1");
|
|
});
|
|
|
|
it("refuses to edit a link partner whose id also names a root clip", async () => {
|
|
const html = `
|
|
<div data-hf-id="hf-stage" data-hf-root style="width:1280px;height:720px" data-duration="10">
|
|
<audio data-hf-id="hf-a" src="bgm.mp3" data-start="0" data-duration="10" data-track-index="1"></audio>
|
|
<div data-hf-id="hf-child" data-composition-id="child" data-start="0" data-duration="10" data-track-index="2">
|
|
<video data-hf-id="hf-cv" src="b.mp4" muted data-link="lk-1" data-start="5" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-a" src="b.mp4" data-link="lk-1" data-start="5" data-duration="4" data-track-index="1"></audio>
|
|
</div>
|
|
</div>`.trim();
|
|
const comp = await openComposition(html);
|
|
expect(() => comp.setTiming("hf-cv", { start: 2 })).toThrow(/not uniquely addressable/);
|
|
expect(() => comp.setTiming("hf-cv", { start: 2 }, { linked: false })).toThrow(
|
|
/not uniquely addressable/,
|
|
);
|
|
expect(comp.serialize()).toBe((await openComposition(html)).serialize());
|
|
});
|
|
|
|
describe("a duration edit whose new end would cross a linked partner's start", () => {
|
|
const OFFSET_HTML = LINKED_HTML.replace(
|
|
'data-hf-id="hf-talk-audio" src="talk.mp4" data-link="lk-1" data-start="2" data-duration="6"',
|
|
'data-hf-id="hf-talk-audio" src="talk.mp4" data-link="lk-1" data-start="3" data-duration="5"',
|
|
);
|
|
|
|
it.each([1, 0.5])("refuses duration %s atomically, before any mutation", async (duration) => {
|
|
const comp = await openComposition(OFFSET_HTML);
|
|
comp.setTiming("hf-music", { start: 1 });
|
|
const before = comp.serialize();
|
|
expect(comp.can({ type: "setTiming", target: "hf-talk", duration })).toMatchObject({
|
|
ok: false,
|
|
code: "E_LINKED_PARTNER_CROSSED",
|
|
});
|
|
expect(() => comp.setTiming("hf-talk", { duration })).toThrow(
|
|
/linked audio would start after the new end/i,
|
|
);
|
|
expect(comp.serialize()).toBe(before);
|
|
comp.undo();
|
|
expect(attr(comp.serialize(), "hf-music", "data-start")).toBe("0");
|
|
expect(comp.canUndo()).toBe(false);
|
|
});
|
|
|
|
it("trims the partner to the shared end while that end stays after its start", async () => {
|
|
const comp = await openComposition(OFFSET_HTML);
|
|
expect(comp.can({ type: "setTiming", target: "hf-talk", duration: 1.5 }).ok).toBe(true);
|
|
comp.setTiming("hf-talk", { duration: 1.5 });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-duration")).toBe("1.5");
|
|
expect(attr(html, "hf-talk-audio", "data-start")).toBe("3");
|
|
expect(attr(html, "hf-talk-audio", "data-duration")).toBe("0.5");
|
|
});
|
|
|
|
it("allows the same edit once the pair is unlinked", async () => {
|
|
const comp = await openComposition(OFFSET_HTML);
|
|
comp.setTiming("hf-talk", { duration: 0.5 }, { linked: false });
|
|
const html = comp.serialize();
|
|
expect(attr(html, "hf-talk", "data-duration")).toBe("0.5");
|
|
expect(attr(html, "hf-talk-audio", "data-duration")).toBe("5");
|
|
});
|
|
});
|
|
|
|
describe.each([
|
|
{ host: 'data-composition-id="child" data-composition-file="child.html"', cv: "hf-host/hf-cv" },
|
|
{ host: 'data-composition-id="child"', cv: "hf-cv" },
|
|
])(
|
|
"one edit naming linked clips in two compositions that reuse a link id ($host)",
|
|
({ host, cv }) => {
|
|
const TWO_SCOPES_HTML = `
|
|
<div data-hf-id="hf-stage" data-hf-root style="width:1280px;height:720px" data-duration="10">
|
|
<video data-hf-id="hf-v" src="talk.mp4" muted data-link="lk-1" data-start="2" data-duration="6" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-a" src="talk.mp4" data-link="lk-1" data-start="2" data-duration="6" data-track-index="1"></audio>
|
|
<div data-hf-id="hf-host" ${host} data-start="0" data-duration="10" data-track-index="2">
|
|
<video data-hf-id="hf-cv" src="b.mp4" muted data-link="lk-1" data-start="0" data-duration="4" data-track-index="0"></video>
|
|
<audio data-hf-id="hf-ca" src="b.mp4" data-link="lk-1" data-start="0" data-duration="4" data-track-index="1"></audio>
|
|
</div>
|
|
</div>`.trim();
|
|
|
|
it("trims each audio against its own video's baseline", async () => {
|
|
const comp = await openComposition(TWO_SCOPES_HTML);
|
|
comp.dispatch({ type: "setTiming", target: ["hf-v", cv], duration: 0.5 });
|
|
const html = comp.serialize();
|
|
expect([attr(html, "hf-v", "data-start"), attr(html, "hf-v", "data-duration")]).toEqual([
|
|
"2",
|
|
"0.5",
|
|
]);
|
|
expect([attr(html, "hf-a", "data-start"), attr(html, "hf-a", "data-duration")]).toEqual([
|
|
"2",
|
|
"0.5",
|
|
]);
|
|
expect([attr(html, "hf-cv", "data-start"), attr(html, "hf-cv", "data-duration")]).toEqual([
|
|
"0",
|
|
"0.5",
|
|
]);
|
|
expect([attr(html, "hf-ca", "data-start"), attr(html, "hf-ca", "data-duration")]).toEqual([
|
|
"0",
|
|
"0.5",
|
|
]);
|
|
});
|
|
|
|
it("refuses against the scoped baseline when one scope's audio would cross its video's end", async () => {
|
|
const crossing = TWO_SCOPES_HTML.replace(
|
|
'data-hf-id="hf-a" src="talk.mp4" data-link="lk-1" data-start="2" data-duration="6"',
|
|
'data-hf-id="hf-a" src="talk.mp4" data-link="lk-1" data-start="3" data-duration="5"',
|
|
);
|
|
const comp = await openComposition(crossing);
|
|
const before = comp.serialize();
|
|
const op = { type: "setTiming" as const, target: ["hf-v", cv], duration: 0.5 };
|
|
expect(comp.can(op)).toMatchObject({ ok: false, code: "E_LINKED_PARTNER_CROSSED" });
|
|
expect(() => comp.dispatch(op)).toThrow(/linked audio would start after the new end/i);
|
|
expect(comp.serialize()).toBe(before);
|
|
expect(comp.canUndo()).toBe(false);
|
|
});
|
|
},
|
|
);
|
|
});
|