From 401991669d67c8a75f273b1921441cef9cfd2d85 Mon Sep 17 00:00:00 2001 From: zhengqiuyang <54101044+zhengqiuyang@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:08:08 +0000 Subject: [PATCH] fix(lint): derive the root duration with the parser's timing reader (#8032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(lint): derive the root duration with the parser's timing reader `deriveDurationFromClips` read `data-start` with a raw `Number()`, so a clip authored at `data-start="-2"` produced an end of `-1`. `resolveCompositionDuration` only counts positive ends, so the clip vanished from the derivation and the composition was reported as having no duration source at all — a hard error that blocks strict renders, even though the parser clamps the same start to zero and renders the clip for its full length. Read the start through `readClipTiming`, the same contract parser the renderer uses, and keep the media-duration default for untimed images. * fix(lint): derive the root duration with the parser's timing reader `deriveDurationFromClips` read `data-start` with a raw `Number()`, so a clip authored at `data-start="-2"` produced a negative end and vanished from the derivation. Read the start through `readClipTiming`, which clamps it to zero, and keep `readAuthoredDurationSeconds` for the authored length so a valid `data-end` still backs an unparseable `data-duration`. --- packages/lint/src/rules/composition.test.ts | 26 +++++++++++++++++++++ packages/lint/src/rules/composition.ts | 12 +++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/lint/src/rules/composition.test.ts b/packages/lint/src/rules/composition.test.ts index 97498b5137..c546cea634 100644 --- a/packages/lint/src/rules/composition.test.ts +++ b/packages/lint/src/rules/composition.test.ts @@ -1978,6 +1978,32 @@ ${Array.from({ length: 10 }, (_, i) => `
{ + const html = ` +
+
+
+ `; + const result = await lintHyperframeHtml(html); + expect(find(result.findings)).toBeUndefined(); + expect( + result.findings.find((f) => f.code === "root_composition_duration_derived")?.message, + ).toContain("at least 4s"); + }); + + it("derives from a negative start like the parser does", async () => { + const html = ` +
+
+
+ `; + const result = await lintHyperframeHtml(html); + expect(find(result.findings)).toBeUndefined(); + expect( + result.findings.find((f) => f.code === "root_composition_duration_derived")?.message, + ).toContain("at least 1s"); + }); + it("does not count a clip whose data-end is before its start", async () => { const html = `
diff --git a/packages/lint/src/rules/composition.ts b/packages/lint/src/rules/composition.ts index 4fb2f9a95c..0ceb0eda5d 100644 --- a/packages/lint/src/rules/composition.ts +++ b/packages/lint/src/rules/composition.ts @@ -1975,15 +1975,15 @@ function deriveDurationFromClips(tags: OpenTag[], rootTag: OpenTag) { const clipEnds: Array = []; for (const tag of tags) { if (tag === rootTag) continue; - const startRaw = readAttr(tag.raw, "data-start"); - if (startRaw === null) continue; - const start = Number(startRaw); - // A reference start ("intro+2") is resolved by the runtime; here it is a clip of unknown end. - if (!Number.isFinite(start)) { + const getAttr = (name: string) => readAttr(tag.raw, name); + if (getAttr("data-start") === null) continue; + const timing = readTagTiming(tag.raw); + // A reference start is resolved by the runtime; here it is a clip of unknown end. + if (timing.start === null) { clipEnds.push(null); continue; } - const getAttr = (name: string) => readAttr(tag.raw, name); + const start = timing.start; const authored = readAuthoredDurationSeconds(getAttr, start); if (CLIP_MEDIA_TAGS.has(tag.name)) { const { seconds } = resolveMediaDuration({