Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
HyperFrames pages: the timeline registry made before their scripts, the size read from the root element
Leonardo Gonzalez8a365c13bef5
diff --git a/runtime/js/src/html_page.rs b/runtime/js/src/html_page.rsindex 4d1624e2..09ff59b2 100644--- a/runtime/js/src/html_page.rs+++ b/runtime/js/src/html_page.rs@@ -95,7 +95,15 @@ fn listing(dir: &Path) -> Vec<String> {/// The root composition's size as its markup gives it (data-width / data-height of the first composition), before/// the page runs.fn size_of(src: &str) -> (u32, u32) {- let at = src.find("data-composition-id").unwrap_or(0);+ // the first element carrying data-composition-id: an attribute (whitespace before, `=` after), not the name in a+ // stylesheet's selector (`[data-composition-id="main"] > div`), which comes first in a page's <head> and sized a+ // 1080 x 1920 page at the 1920 x 1080 default+ let key = "data-composition-id";+ let at = src+ .match_indices(key)+ .map(|(i, _)| i)+ .find(|&i| i > 0 && src.as_bytes()[i - 1].is_ascii_whitespace() && src[i + key.len()..].trim_start().starts_with('='))+ .unwrap_or(0);let tag_start = src[..at].rfind('<').unwrap_or(0);let tag_end = src[at..].find('>').map(|i| at + i).unwrap_or(src.len());let tag = &src[tag_start..tag_end];@@ -182,3 +190,13 @@ pub fn videos_of(done: &Value) -> Vec<VideoAt> {.unwrap_or_default()}+#[cfg(test)]+mod tests {+ #[test]+ fn size_comes_from_the_root_element_not_a_selector() {+ let page = r#"<html><head><style>[data-composition-id="main"] > div { position: absolute; }</style></head>+<body><div id="root" data-composition-id="main" data-start="0" data-width="1080" data-height="1920"></div></body></html>"#;+ assert_eq!(super::size_of(page), (1080, 1920));+ assert_eq!(super::size_of("<div data-composition-id='m'></div>"), (1920, 1080));+ }+}diff --git a/sdk/ui/src/html/page/load.ts b/sdk/ui/src/html/page/load.tsindex dea76144..04568409 100644--- a/sdk/ui/src/html/page/load.ts+++ b/sdk/ui/src/html/page/load.ts@@ -58,6 +58,9 @@ async function load() {// (a host that never lays out, as the test host, is waited for a moment only)for (let i = 0; i < 3; i++) await new Promise((r) => (g.requestAnimationFrame(r), setTimeout(r, 200)));namedAccess();+ // the registry a page's scripts put their timelines in (window.__timelines["main"] = tl), made before they run as+ // HyperFrames' own runtime makes it: without it every such script threw at that line and the page never moved+ g.__timelines ??= {};for (let i = 0; i < compiled.scripts.length; i++) await runScript(compiled.scripts[i], i);try {document.dispatchEvent(new g.Event("DOMContentLoaded", { bubbles: true }));