fix(cli): read actual data-width/data-height in info command#122
fix(cli): read actual data-width/data-height in info command#122miguel-heygen wants to merge 1 commit intomainfrom
Conversation
c73ca1b to
154e762
Compare
miguel-heygen
left a comment
There was a problem hiding this comment.
Two issues:
1. Regex matches the wrong element
The regex /data-width\s*=\s*["'](\d+)["']/ matches the first occurrence of data-width anywhere in the raw HTML. In HyperFrames, data-width/data-height appear on every composition element, not just the root. For example, play-mode/index.html has data-width on the root at line 95 but also on child compositions at lines 104, 138, 198, 208, 218. If source order ever changes, or a script/style block contains the string, this returns wrong dimensions.
compositions.ts already solves this correctly with DOM queries:
const width = parseInt(div.getAttribute("data-width") ?? "1920", 10);
const height = parseInt(div.getAttribute("data-height") ?? "1080", 10);2. Dimension parsing belongs in parseHtml / ParsedHtml
The info command already calls parseHtml(html) which creates a full DOM document internally. Rather than duplicating dimension extraction via regex in the CLI, extend ParsedHtml in @hyperframes/core with width and height fields, populated by DOM-based attribute reads from the root composition element. This makes the core parser the single source of truth.
Also: the JSON output schema changed — resolution went from a "landscape"/"portrait" enum to a "1920x1080" string. This is a breaking change for consumers of hyperframes info --json.
The info command was hardcoding dimensions based on portrait/landscape detection, which defaulted to portrait because parseHtml() doesn't read data-width/data-height from composition root elements. Now reads the actual attribute values from the HTML. Reproducer: npx hyperframes init test --template blank --non-interactive cd test && npx hyperframes info # Shows "1080x1920" (portrait) but index.html has data-width="1920" data-height="1080"
154e762 to
8ae935e
Compare
miguel-heygen
left a comment
There was a problem hiding this comment.
Addressed: replaced regex with DOM query via doc.querySelector("[data-composition-id]") (same approach as compositions.ts). Preserved resolution as landscape/portrait enum in JSON for backward compat.
|
Consolidated into fix/cli-polish. |

PR Stack
Summary
infocommand was hardcoding dimensions based on portrait/landscape detection, which always defaulted to "portrait" becauseparseHtml()doesn't readdata-width/data-heightfrom composition root elementsReproducer
Stack
1/8 — This is part of a stack of bug fixes found during automated new-user testing.
🤖 Generated with Claude Code