ZenFG TypeScript API / snapshot / root / decodeFrameGraphSnapshot
Function: decodeFrameGraphSnapshot()
decodeFrameGraphSnapshot(
value):FrameGraphSnapshotDecodeResult
Defined in: packages/snapshot/src/codec.ts:95
Decodes an already-parsed value into a canonical Snapshot 1.2 document.
Parameters
value
unknown
Returns
FrameGraphSnapshotDecodeResult
Remarks
Snapshot 1.1 is strictly validated before upgrading. Supported Legacy V0 and Legacy Candidate V1 captures are migrated before validation. Successful results identify the source format and carry migration warnings; unsupported, malformed, or semantically invalid values return { ok: false, issues } and do not throw. Decoding and migration do not mutate the input value. Returned JSON objects (including extensions) have null prototypes; arrays use the current realm's Array prototype. Use Object.hasOwn(object, key) instead of inherited object methods. Input properties are inspected through data descriptors, so getters and toJSON hooks are never invoked. Extension object/array nesting is limited by FRAME_GRAPH_SNAPSHOT_MAX_EXTENSION_DEPTH.
Example
const result = decodeFrameGraphSnapshot(untrustedValue);
if (result.ok) console.log(result.snapshot.graph.nodes.length);
else console.error(result.issues);