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

Function extractDimensions

packages/sdk/src/document.ts:176–189  ·  view source on GitHub ↗
(doc: Document)

Source from the content-addressed store, hash-verified

174// and mutations agree on which element is the composition root.
175// fallow-ignore-next-line complexity
176function extractDimensions(doc: Document): { width: number | null; height: number | null } {
177 const stage = findRoot(doc);
178 if (!stage) return { width: null, height: null };
179 // data-width/data-height are the runtime's forced override — prefer them.
180 const wAttr = stage.getAttribute("data-width");
181 const hAttr = stage.getAttribute("data-height");
182 const style = (stage as HTMLElement).getAttribute?.("style") ?? "";
183 const wm = /width:\s*(\d+)px/.exec(style);
184 const hm = /height:\s*(\d+)px/.exec(style);
185 return {
186 width: wAttr !== null ? parseInt(wAttr, 10) : wm ? parseInt(wm[1] ?? "", 10) : null,
187 height: hAttr !== null ? parseInt(hAttr, 10) : hm ? parseInt(hm[1] ?? "", 10) : null,
188 };
189}
190
191function extractDuration(doc: Document): number | null {
192 const root = findRoot(doc) ?? doc.body;

Callers 1

buildDocumentFunction · 0.85

Calls 2

findRootFunction · 0.85
getAttributeMethod · 0.65

Tested by

no test coverage detected