Effective scene graph handle.
Figler.Scene.Index is the fast raw projection of Kiwi node records.
Figler.Scene.Graph is the surface for resolved Figma semantics: every
instance is expanded into its own occurrences with swaps, component property
assignments, symbol overrides, uniform scale, placed constraints, and saved
derived data applied.
Instances are resolved natively by an occurrence-scoped interpreter ported
from OpenPencil's reader, and the graph stays in a native resource: nodes and
records are read on demand with fetch/2, record/3, and records/3, or
enumerated, and to_map/2 materializes the parts a caller names. Layers
inside an expansion have clone GUIDs ("clone:<instance>/<source>/...") so
each use of a component is addressable on its own. Overrides that cannot be
resolved are reported by unresolved/2 rather than failing the build.
Malformed graph options and GUIDs raise Figler.Error with stable codes and
structured context.
Summary
Functions
Builds an effective scene graph handle.
Diffs effective graph nodes against their projected source nodes.
Diffs one raw index node against its graph counterpart.
Explains how a node appears in the effective graph.
Fetches the node at a GUID string.
Fetches the node at a GUID string, raising KeyError when the graph has none.
Returns instance-specific effective graph metadata for a node.
Profiles graph construction.
Returns the effective record of a graph node: the sparse NodeChange map
with every override resolved, or nil.
Returns the effective records of graph nodes by GUID string, leaving out GUIDs
the graph lacks. Takes the options of record/3.
Returns the projected source node a graph node was built from.
Returns graph build/runtime stats.
Materializes the parts of the graph named by only: as plain Elixir data,
keyed by internal graph GUIDs
Returns a resolved tree from the effective graph.
Returns diagnostics for overrides the graph could not resolve.
Types
Functions
@spec build( binary() | Figler.Scene.source() | Figler.Scene.Index.t() | reference() | t(), keyword() ) :: t()
Builds an effective scene graph handle.
Accepts the same binary inputs as Figler.Scene.index/1, a
Figler.Scene.source/0, or another graph. A %Figler.Scene.Index{}
or native index resource carries no override data, so it builds a projected
graph with instances left unexpanded.
Options:
:focus- one or more source GUIDs. Only their subtrees, ancestors, and the components they use are decoded and interpreted.:root- alias for:focus, useful for resolving one subtree.:resolve_variables-:knownresolves each layer's variable bindings in the modes it uses;falseor:preservekeeps the values the file saved. Defaults to:known.:fields- fields to project when building from an index.
Diffs effective graph nodes against their projected source nodes.
Returns only nodes whose projected source differs from the effective node.
Pass root: to diff a subtree.
@spec diff_node(Figler.Scene.Index.t() | reference(), t(), String.t()) :: map() | nil
Diffs one raw index node against its graph counterpart.
Explains how a node appears in the effective graph.
The explanation includes the resolved node, its projected source node, provenance, the property claims applied to it, and instance metadata for instance nodes.
graph = Figler.Scene.graph(fig_binary, root: "3740:112537")
Figler.Scene.Graph.explain(graph, "3740:112537")
@spec fetch(t(), String.t()) :: {:ok, Figler.Scene.Node.t()} | :error
Fetches the node at a GUID string.
{:ok, node} = Figler.Scene.Graph.fetch(graph, "3740:112537")
@spec fetch!(t(), String.t()) :: Figler.Scene.Node.t()
Fetches the node at a GUID string, raising KeyError when the graph has none.
Returns instance-specific effective graph metadata for a node.
Returns nil for non-instance nodes.
@spec profile( binary() | Figler.Scene.source(), keyword() ) :: map()
Profiles graph construction.
Returns the graph, the total time, and the time of each phase: :decode,
:index, and :interpret (which includes materializing the graph).
Options are the same as build/2.
Returns the effective record of a graph node: the sparse NodeChange map
with every override resolved, or nil.
Options:
:fields- the record fields to return, as atoms. Defaults to all.:as-:map(default) for a sparse map, or:structfor the generatedFigler.Schemastructs.
Returns the effective records of graph nodes by GUID string, leaving out GUIDs
the graph lacks. Takes the options of record/3.
@spec source_node(t(), String.t()) :: Figler.Scene.Node.t() | nil
Returns the projected source node a graph node was built from.
Returns graph build/runtime stats.
Materializes the parts of the graph named by only: as plain Elixir data,
keyed by internal graph GUIDs:
:nodes- scene nodes by GUID:records- effective records by GUID:children- each parent's child GUIDs, in order:roots- the source GUIDs the graph starts from:by_typeand:by_name- GUIDs by node type and by name:provenance- where each node that is not a plain source node came from:unresolved- the overrides the graph could not resolve
Records and nodes of a whole document are large; name only what is needed.
@spec tree( t(), keyword() ) :: [Figler.Scene.Node.t()] | Figler.Scene.Node.t() | nil
Returns a resolved tree from the effective graph.
Options:
:root- graph GUID string/tuple to use as root. Defaults to all roots.:depth- maximum child depth. Defaults to3.graph = Figler.Scene.graph(fig_binary, root: "3740:112537") Figler.Scene.Graph.tree(graph, root: "3740:112537", depth: 3)
Returns diagnostics for overrides the graph could not resolve.
{:unresolved_property, owner, main_component, path, reason}{:unresolved_assignment, owner, main_component, path, reason}{:missing_component, owner, component}{:missing_slot_content, slot, content}{:unsupported_variable_expression, variable, mode}
GUIDs are {session_id, local_id} tuples and reason is :missing_target
or :ambiguous_target.