(html: string)
| 218 | * Uses linkedom — node-safe (works in agents, CI, server-side). |
| 219 | */ |
| 220 | export function buildDocument(html: string): SdkDocument { |
| 221 | const stamped = ensureHfIds(html); |
| 222 | |
| 223 | const hasShell = /<!doctype|<html[\s>]/i.test(stamped); |
| 224 | const wrapped = !hasShell; |
| 225 | const { document } = wrapped |
| 226 | ? parseHTML(`<!DOCTYPE html><html><head></head><body>${stamped}</body></html>`) |
| 227 | : parseHTML(stamped); |
| 228 | |
| 229 | const dims = extractDimensions(document); |
| 230 | |
| 231 | return { |
| 232 | roots: buildRoots(document), |
| 233 | gsapScript: extractGsapScript(document), |
| 234 | styles: extractStyles(document), |
| 235 | width: dims.width, |
| 236 | height: dims.height, |
| 237 | compositionDuration: extractDuration(document), |
| 238 | html: stamped, |
| 239 | }; |
| 240 | } |
| 241 | |
| 242 | /** Flat walk of the element tree — returns every element in document order */ |
| 243 | export function flatElements(roots: readonly HyperFramesElement[]): HyperFramesElement[] { |
nothing calls this directly
no test coverage detected