diff --git a/packages/core/src/compiler/index.ts b/packages/core/src/compiler/index.ts index ca49e97f073..8cfa872eb4d 100644 --- a/packages/core/src/compiler/index.ts +++ b/packages/core/src/compiler/index.ts @@ -16,12 +16,14 @@ export { injectDurations, extractResolvedMedia, clampDurations, + extendVideoSlotEnds, shouldClampMediaDuration, shouldClampResolvedMediaDuration, type UnresolvedElement, type ResolvedDuration, type ResolvedMediaElement, type CompilationResult, + type VideoSlotEnd, } from "./timingCompiler"; // HTML compiler (Node.js — requires fs) diff --git a/packages/core/src/compiler/timingCompiler.test.ts b/packages/core/src/compiler/timingCompiler.test.ts index 13f73fe0c8b..aae133f2e69 100644 --- a/packages/core/src/compiler/timingCompiler.test.ts +++ b/packages/core/src/compiler/timingCompiler.test.ts @@ -7,6 +7,7 @@ import { injectDurations, extractResolvedMedia, clampDurations, + extendVideoSlotEnds, shouldClampResolvedMediaDuration, } from "./timingCompiler.js"; @@ -474,6 +475,28 @@ describe("extractResolvedMedia", () => { }); }); +describe("extendVideoSlotEnds", () => { + it("keeps data-start and stretches a file-bounded data-duration past source EOF", () => { + const html = extendVideoSlotEnds( + ``, + [{ id: "wrap", end: 19, duration: 6 }], + ); + expect(html).toContain('data-start="13"'); + expect(html).toContain('data-end="19"'); + expect(html).toContain('data-duration="6"'); + expect(html).not.toContain("data-media-start"); + }); + + it("does not rewrite a video mentioned only in a comment", () => { + const html = extendVideoSlotEnds( + ``, + [{ id: "wrap", end: 19, duration: 6 }], + ); + expect(html).toContain(``); + expect(html).toContain('data-duration="6"'); + }); +}); + describe("clampDurations", () => { it("replaces data-duration and recomputes data-end", () => { const html = '