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

Function readDeclaredDefaults

packages/core/src/runtime/getVariables.ts:39–60  ·  view source on GitHub ↗
(root: Element | null)

Source from the content-addressed store, hash-verified

37 * compositionLoader can compute the same defaults map for sub-comp instances.
38 */
39export function readDeclaredDefaults(root: Element | null): Record<string, unknown> {
40 if (!root) return {};
41 const raw = root.getAttribute("data-composition-variables");
42 if (!raw) return {};
43
44 let parsed: unknown;
45 try {
46 parsed = JSON.parse(raw);
47 } catch {
48 return {};
49 }
50 if (!Array.isArray(parsed)) return {};
51
52 const out: Record<string, unknown> = {};
53 for (const entry of parsed) {
54 if (!entry || typeof entry !== "object") continue;
55 const e = entry as Record<string, unknown>;
56 if (typeof e.id !== "string" || !("default" in e)) continue;
57 out[e.id] = e.default;
58 }
59 return out;
60}
61
62function readOverrides(): Record<string, unknown> {
63 if (typeof window === "undefined") return {};

Callers 3

loadExternalCompositionsFunction · 0.90
getVariablesFunction · 0.85

Calls 1

getAttributeMethod · 0.65

Tested by

no test coverage detected