mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 23:00:03 +00:00
fix(lint): recognize compiler-derived data-end as legitimate
`bundleToSingleHtml` compiles `data-duration` into `data-end` (in `compileTimingAttrs`), then calls `validateHyperframeHtmlContract` against the compiled HTML. The linter's `deprecated_data_end` rule fired on the compiler's own consistent output — `<audio data-start="0" data-duration="18" data-end="18">` — because `diagnoseDerivedEnd` unconditionally emitted a `deprecated-end` diagnostic whenever both attributes were present, ignoring whether the derived value matched. Reporters routed this as "raw-source lint passes with 0 errors and 0 warnings, but `check --strict` still logs StaticGuard noise about data-end without data-duration." Field cluster: cli-feedback crons 61-68, n=25+ across darwin/arm64, darwin/x64, linux/x64, win32/x64, and versions 0.7.56 through 0.7.64. L3 reporter cite (ts=1784519869): "bundleToSingleHtml compiles data-duration into data-end, then validates the compiled HTML and reports its own generated data-end as deprecated." Fix: `diagnoseDerivedEnd` now stays silent when the paired `data-end` matches `data-start + data-duration` (within a 1ns epsilon to absorb IEEE-754 residuals like `0.1 + 0.2 = 0.30000000000000004`). Truly-legacy authoring shapes — `data-end` alone with no `data-duration`, or a `data-end` that disagrees with `data-duration` — still fire `deprecated_data_end`, with a refined message that names the drift on the conflicting variant. Facets covered: (a) validator treats compiler-derived `data-end` as legal when paired with `data-duration`, and (e) recognizes the compile-time rewrite site (`bundleToSingleHtml` → `compileHtml` → `compileTimingAttrs`). Facets (b) stderr gating, (c) terminal JSON verdict, and (d) audio-not- dropped are unblocked transitively — StaticGuard's `console.warn` is already gated on `!isValid` and never drops audio; the check command already emits JSON on every terminal path; so once the false-positive diagnostic stops firing on compiler output, the noisy stderr line and the misleading "check appears to fail" reporter framing both go away without further wiring. Co-Authored-By: Via <noreply@heygen.com>
This commit is contained in:
@@ -1345,4 +1345,46 @@ describe("bundleToSingleHtml", () => {
|
||||
);
|
||||
expect(styleEls[0]?.parentElement?.tagName.toLowerCase()).toBe("head");
|
||||
});
|
||||
|
||||
// Regression: cli-feedback field cluster (crons 61-68, n=25+, cross-OS,
|
||||
// versions 0.7.56-0.7.64). Reporter L3 cite (ts=1784519869):
|
||||
// "bundleToSingleHtml compiles data-duration into data-end, then validates
|
||||
// the compiled HTML and reports its own generated data-end as deprecated.
|
||||
// Raw-source lint passes with 0 errors and 0 warnings." The end-to-end
|
||||
// guarantee: source authored with only data-duration must round-trip through
|
||||
// bundle + StaticGuard without producing a StaticGuard warning on the
|
||||
// compiler's own consistent data-end. Facet-(a)/(e) fix.
|
||||
it("does not emit a StaticGuard warning for source-authored data-duration on media", async () => {
|
||||
const dir = makeTempProject({
|
||||
"index.html": `<!doctype html>
|
||||
<html>
|
||||
<head><title>t</title></head>
|
||||
<body>
|
||||
<div data-composition-id="root" data-width="1920" data-height="1080" data-start="0" data-duration="18">
|
||||
<audio id="bgm" src="bgm.mp3" data-start="0" data-duration="18"></audio>
|
||||
<audio id="narration" src="narr.mp3" data-start="5" data-duration="10"></audio>
|
||||
</div>
|
||||
<script>window.__timelines = window.__timelines || {}; window.__timelines.root = { duration: () => 18, seek() {}, pause() {} };</script>
|
||||
</body></html>`,
|
||||
"bgm.mp3": "",
|
||||
"narr.mp3": "",
|
||||
});
|
||||
|
||||
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
try {
|
||||
const bundled = await bundleToSingleHtml(dir);
|
||||
// Sanity: the compiler MUST have emitted data-end for both audio elements,
|
||||
// so the linter is actually seeing the compiled shape (not the raw source).
|
||||
expect(bundled).toContain('id="bgm"');
|
||||
expect(bundled).toMatch(/id="bgm"[^>]*data-end="18"|data-end="18"[^>]*id="bgm"/);
|
||||
expect(bundled).toMatch(/id="narration"[^>]*data-end="15"|data-end="15"[^>]*id="narration"/);
|
||||
|
||||
const staticGuardWarnings = warnSpy.mock.calls
|
||||
.map((call) => String(call[0] ?? ""))
|
||||
.filter((line) => line.includes("[StaticGuard]"));
|
||||
expect(staticGuardWarnings).toEqual([]);
|
||||
} finally {
|
||||
warnSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user