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

Function readDecls

packages/sdk/src/engine/variableModel.ts:17–30  ·  view source on GitHub ↗

Parse the variable declaration array, or null when absent/invalid.

(document: Document)

Source from the content-addressed store, hash-verified

15
16/** Parse the variable declaration array, or null when absent/invalid. */
17function readDecls(document: Document): { htmlEl: Element; arr: VariableDecl[] } | null {
18 const htmlEl = getHtmlEl(document);
19 if (!htmlEl) return null;
20 const raw = htmlEl.getAttribute("data-composition-variables");
21 if (!raw) return null;
22 let parsed: unknown;
23 try {
24 parsed = JSON.parse(raw);
25 } catch {
26 return null;
27 }
28 if (!Array.isArray(parsed)) return null;
29 return { htmlEl, arr: parsed as VariableDecl[] };
30}
31
32function indexOfId(arr: VariableDecl[], id: string): number {
33 return arr.findIndex((v) => typeof v === "object" && v !== null && v.id === id);

Callers 3

readVariableDefaultFunction · 0.85
writeVariableDefaultFunction · 0.85
clearVariableDefaultFunction · 0.85

Calls 2

getHtmlElFunction · 0.85
getAttributeMethod · 0.65

Tested by

no test coverage detected