mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
fix(lint): a video gets no timing from its wrapper, and the docs and hints stop implying it (#7210)
This commit is contained in:
@@ -354,6 +354,7 @@ describe("media rules", () => {
|
||||
expect(hint).toContain('id="wrap"');
|
||||
expect(hint).toContain('data-start="2"');
|
||||
expect(hint).not.toContain('data-start="0"');
|
||||
expect(hint).toContain("takes no timing from it");
|
||||
|
||||
// The hint's one step: the video leaves the wrapper and takes its timing.
|
||||
const followed = await codes(
|
||||
@@ -552,6 +553,21 @@ describe("media rules", () => {
|
||||
expect(found).toContain("video_audio_double_source");
|
||||
});
|
||||
|
||||
it("says a timed video inside a timed wrapper gets no timing from the wrapper, so the wrapper stays untimed", async () => {
|
||||
const result = await lintHyperframeHtml(`
|
||||
<html><body>
|
||||
<div id="root" data-composition-id="c1" data-width="1920" data-height="1080">
|
||||
<div id="wrap" class="clip" data-start="2" data-duration="3" data-track-index="0">
|
||||
<video id="nv" src="clip.mp4" data-start="2" data-duration="3" muted playsinline></video>
|
||||
</div>
|
||||
</div>
|
||||
<script>window.__timelines = window.__timelines || {}; window.__timelines["c1"] = gsap.timeline({ paused: true });</script>
|
||||
</body></html>`);
|
||||
const hint = result.findings.find((f) => f.code === "video_nested_in_timed_element")?.fixHint;
|
||||
expect(hint).toContain("takes no timing from its wrapper");
|
||||
expect(hint).not.toContain("wrapper OR the video");
|
||||
});
|
||||
|
||||
it("does NOT flag <video> as nested in a void element with data-start (regression)", async () => {
|
||||
// Regression: void elements like <img> have no closing tag, so the previous
|
||||
// implementation kept them on the parent stack indefinitely and flagged any
|
||||
|
||||
@@ -647,7 +647,7 @@ export const mediaRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> =
|
||||
message: `<video> with data-start is nested inside <${parent.name}${parent.id ? ` id="${parent.id}"` : ""}> which also has data-start. The frame extractor resolves the video's start from its own data-start without the wrapper's offset, while visibility uses the wrapper's window, so the two disagree: the clip shows the wrong source frames and then disappears partway through its slot.`,
|
||||
elementId: readAttr(tag.raw, "id") || undefined,
|
||||
fixHint:
|
||||
"Time the wrapper OR the video, never both: remove data-start from the wrapper (use it as a non-timed visual container), or move the <video> up to be a direct child of the stage.",
|
||||
"A <video> takes no timing from its wrapper: time the <video> and leave the wrapper untimed (remove its data-start; it only places or animates), or move the <video> up to be a direct child of the stage.",
|
||||
snippet: truncateSnippet(tag.raw),
|
||||
});
|
||||
}
|
||||
@@ -740,7 +740,7 @@ export const mediaRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> =
|
||||
message: `<${tag.name}${hasId ? ` id="${hasId}"` : ""}> has src but no data-start. HyperFrames cannot own playback for untimed media, so preview and render behavior can diverge.`,
|
||||
elementId: hasId || undefined,
|
||||
fixHint: wrapper
|
||||
? `This <${tag.name}> sits inside the timed <${wrapper.name}${wrapper.id ? ` id="${wrapper.id}"` : ""}> (data-start="${wrapper.start}"), and the wrapper's data-start would then clash. Move the <${tag.name}> out as a direct child of the stage and give it that wrapper's data-start="${wrapper.start}"${wrapper.duration ? ` and data-duration="${wrapper.duration}"` : ""}.`
|
||||
? `This <${tag.name}> sits inside the timed <${wrapper.name}${wrapper.id ? ` id="${wrapper.id}"` : ""}> (data-start="${wrapper.start}") and takes no timing from it, so without its own data-start it plays from composition time 0, and a data-start on it would clash with the wrapper's. Move the <${tag.name}> out as a direct child of the stage and give it that wrapper's data-start="${wrapper.start}"${wrapper.duration ? ` and data-duration="${wrapper.duration}"` : ""}.`
|
||||
: `Add data-start="0" (or the intended start time) and data-duration if the clip should stop before the source ends.`,
|
||||
snippet: truncateSnippet(tag.raw),
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"files": 2
|
||||
},
|
||||
"hyperframes": {
|
||||
"hash": "7e43b38bd9936270",
|
||||
"hash": "c8d63424db2726d3",
|
||||
"files": 77
|
||||
},
|
||||
"hyperframes-cli": {
|
||||
|
||||
@@ -26,7 +26,7 @@ Build what was asked: no voiceover or captions and no new aspect ratio unless th
|
||||
5. Never tween `display`, `visibility` or `autoAlpha` on a `.clip`; animate a child.
|
||||
6. No CSS `transform` on an element GSAP transforms; animate transforms, not `left`/`top`/`width`/`height`.
|
||||
7. Never `play()`, `pause()` or seek media. A `<video>` keeps its sound with `data-has-audio="true"`, else it is `muted`; music, voice, replacement sound and J/L cuts are a separate `<audio>`.
|
||||
8. Every `<audio>` has an `id` or it is left out of the mix. No `crossorigin` on media. Time a `<video>` or its wrapper, never both.
|
||||
8. Every `<audio>` has an `id` or it is left out of the mix. No `crossorigin` on media. Time the `<video>`, never its wrapper.
|
||||
9. Only the bundled fonts (`references/format.md`) resolve by name; any other family needs `@font-face` to a file in `assets/fonts/`.
|
||||
10. Asset paths: `assets/...` (no leading `/`), in sub-compositions too.
|
||||
11. Grades, grain, blur and vignettes on footage go through `npx hyperframes media-treatment` (`/media-use`), never CSS filters.
|
||||
|
||||
@@ -146,7 +146,7 @@ Studio's Detach audio writes a muted `<video>` and an `<audio>` of the same file
|
||||
| `video_missing_muted` | A timed `<video>` gets `data-has-audio="true"` or `muted` |
|
||||
| `gsap_css_transform_conflict` | Set the start inside the tween (`gsap.fromTo`) instead of a CSS `transform` |
|
||||
| `gsap_animates_clip_element` | Animate a child of the `.clip`, or its `opacity` |
|
||||
| `video_nested_in_timed_element` | Time the `<video>` or its wrapper, not both |
|
||||
| `video_nested_in_timed_element` | Time the `<video>`; its wrapper stays untimed and gives it no timing |
|
||||
| `media_missing_id`, `media_crossorigin_breaks_preview` | Give every `<audio>` an `id`; drop `crossorigin` |
|
||||
| `gsap_timeline_registered_before_async_build` | Register the timeline at the end of the async callback |
|
||||
| `standalone_composition_wrapped_in_template` | Only scene files use `<template>` |
|
||||
|
||||
Reference in New Issue
Block a user