mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 19:46:11 +00:00
* fix(studio): serve files whose name has a bare percent sign A browser sends src="100%.png" with the % unescaped, and decoding the whole path threw, so Studio answered 500. Only well-formed escapes are decoded now. * fix(cli): serve files with a bare percent sign from the check and snapshot server One shared decode rule for request paths; the image thumbnail route's malformed-escape 400 could no longer fire, so a name that is not a file is a 404. * fix(cli): name a failed file with a bare percent sign in check * fix(studio): keep apostrophes and dollar signs in file names when editing attributes An attribute value is matched by its own quote kind, so src="it's.png" is replaced instead of duplicated, and every insert uses a function replacer, so $1 or $& in a file name is written as is. * fix(studio): rename references spelled with %20 or & and read quoted media sources WIP: not yet tested; see the resume note. * fix(studio): match whole attribute names when editing media sources * fix(studio): compare decoded names and escape replacement references * fix(studio): preserve file references across URL and string consumers * docs: clarify raw file references and URL fields * fix(studio): keep raw path identity distinct from URL spelling * fix: share attribute grammar and decode media URLs at their readers * fix: preserve local filename identity in HTML URL output * fix: decode entity references before rename candidate matching * style: format rename entity handling and regressions * fix: preserve platform file identity when renaming references * fix(core): decode CSS escapes before rebasing asset URLs * fix(core): consume CSS continuations before URL encoding * fix(core): preserve CSS URL identity and escape rebased suffixes * fix(core): express CSS suffix controls with Unicode categories * fix(core): preserve URL backslash identity while rebasing * test(core): respect platform backslash filename semantics * fix(studio): a dropped file with %, # or ? in its name loads, and an encoded reference renames * fix(studio): read an authored src as a URL so dropped files with spaces, %, # or ? load * fix(studio): media routes find files named with ? or #, and the probe reads a src as a URL * fix(studio-server): one rule for request file paths, so loudness finds files named with %, # or ? * chore: drop the design note from the change * fix(core): rename replaced clips whose src is URL-encoded
103 lines
3.9 KiB
TypeScript
103 lines
3.9 KiB
TypeScript
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { compileHtml } from "./htmlCompiler.js";
|
|
|
|
describe("compileHtml", () => {
|
|
it("decodes HTML source attributes before interpreting their URL suffixes", async () => {
|
|
const project = mkdtempSync(join(tmpdir(), "hf-entity-media-"));
|
|
writeFileSync(join(project, "it's&a.wav"), "duration witness");
|
|
try {
|
|
const compiled = await compileHtml(
|
|
`<audio id="clip" title="src='wrong.wav' >" src="it's&a.wav">`,
|
|
project,
|
|
async (path) => {
|
|
expect(path).toBe(join(project, "it's&a.wav"));
|
|
expect(readFileSync(path, "utf8")).toBe("duration witness");
|
|
return 2;
|
|
},
|
|
);
|
|
expect(compiled).toContain('data-duration="2"');
|
|
} finally {
|
|
rmSync(project, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("passes a decoded local media URL to the duration prober", async () => {
|
|
const project = mkdtempSync(join(tmpdir(), "hf-encoded-media-"));
|
|
writeFileSync(join(project, "clip%20#.mp4"), "duration witness");
|
|
try {
|
|
const compiled = await compileHtml(
|
|
'<video id="clip" src="clip%2520%23.mp4?cache=1" data-start="0">',
|
|
project,
|
|
async (path) => {
|
|
expect(path).toBe(join(project, "clip%20#.mp4"));
|
|
expect(readFileSync(path, "utf8")).toBe("duration witness");
|
|
return 2;
|
|
},
|
|
);
|
|
expect(compiled).toContain('data-duration="2"');
|
|
} finally {
|
|
rmSync(project, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("preserves explicit looped media durations that exceed source duration", async () => {
|
|
const html =
|
|
'<video id="hero" src="hero.webm" data-start="0" data-duration="4" data-end="4" loop>';
|
|
|
|
const compiled = await compileHtml(html, "/project", async () => 3.125);
|
|
|
|
expect(compiled).toContain('data-duration="4"');
|
|
expect(compiled).toContain('data-end="4"');
|
|
});
|
|
|
|
it("preserves an explicit non-looping video slot past source end", async () => {
|
|
const html = '<video id="hero" src="hero.webm" data-start="0" data-duration="4" data-end="4">';
|
|
|
|
const compiled = await compileHtml(html, "/project", async () => 3.125);
|
|
|
|
expect(compiled).toContain('data-duration="4"');
|
|
expect(compiled).toContain('data-end="4"');
|
|
});
|
|
|
|
it("uses natural duration for a video without an explicit slot inside a composition", async () => {
|
|
const html =
|
|
'<div data-composition-id="root" data-start="0" data-duration="5">' +
|
|
'<video id="hero" src="hero.webm" data-start="0">' +
|
|
"</div>";
|
|
|
|
const compiled = await compileHtml(html, "/project", async () => 1);
|
|
|
|
expect(compiled).toContain('data-duration="1"');
|
|
expect(compiled).toContain('data-end="1"');
|
|
});
|
|
|
|
it("uses natural duration for a standalone video without a composition window", async () => {
|
|
const html = '<video id="hero" src="hero.webm" data-start="0">';
|
|
const compiled = await compileHtml(html, "/project", async () => 1);
|
|
expect(compiled).toContain('data-duration="1"');
|
|
expect(compiled).toContain('data-end="1"');
|
|
});
|
|
|
|
it("still clamps non-looping audio durations to source duration", async () => {
|
|
const html = '<audio id="voice" src="voice.wav" data-start="0" data-duration="4" data-end="4">';
|
|
|
|
const compiled = await compileHtml(html, "/project", async () => 3.125);
|
|
|
|
expect(compiled).toContain('data-duration="3.125"');
|
|
expect(compiled).toContain('data-end="3.125"');
|
|
});
|
|
|
|
it("preserves explicit media durations when probe precision differs slightly", async () => {
|
|
const html =
|
|
'<audio id="click" src="click.mp3" data-start="0" data-duration="1.044898" data-end="1.044898">';
|
|
|
|
const compiled = await compileHtml(html, "/project", async () => 1);
|
|
|
|
expect(compiled).toContain('data-duration="1.044898"');
|
|
expect(compiled).toContain('data-end="1.044898"');
|
|
});
|
|
});
|