MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / buildDocument

Function buildDocument

packages/sdk/src/document.ts:220–240  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

218 * Uses linkedom — node-safe (works in agents, CI, server-side).
219 */
220export 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 */
243export function flatElements(roots: readonly HyperFramesElement[]): HyperFramesElement[] {

Callers

nothing calls this directly

Calls 6

ensureHfIdsFunction · 0.85
extractDimensionsFunction · 0.85
buildRootsFunction · 0.85
extractStylesFunction · 0.85
extractDurationFunction · 0.85
extractGsapScriptFunction · 0.70

Tested by

no test coverage detected