nuif-figcraft-nodes-0 FigCraft layer profile
Status: experimental executable profile in crates/nuif-figcraft (nodes
module), checked by cargo xtask gate-figcraft. Directions: import (layer
snapshot to NUIF) and export (NUIF to a command plan). Tested host:
figcraft-cli 0.18.1. It covers the subset of FigCraft layers that the
profile-0 model represents and carries every other layer opaquely, so that
re-imports refresh the same layers in place.
Host surfaces
- Snapshot: root layers as returned by
node.get {id}(one result, an array, or{"roots": [...]}).node.getreports the children of set variants and nested instances only aschildCount; a snapshot carries those layers as further results, whichcomplete_snapshotmerges into the tree.adapters/figcraft/fixtures/holds synthetic snapshots captured fromfigcraft-cli 0.18.1. - Plan:
node.set,node.create(withpropsandpluginData),node.reparent,node.reorderandedit.deletesteps forfigcraft-cli runor MCPbatch, applied as one undo step.
Mapping
| FigCraft | NUIF |
|---|---|
SECTION | freeform Container (a section with hidden contents reports unsupported) |
FRAME | Container; layout.mode vertical/horizontal → Stack column/row with gap, padding, crossAlign min/center/max, mainAlign and wrap; no auto layout → Freeform |
RECTANGLE, ELLIPSE | Shape(Rectangle), Shape(Ellipse) |
sizing fixed, hug, fill | Fixed(length), Auto, Fill |
x, y of root layers and children of non-auto-layout frames | authored position |
one plain solid fill #RRGGBB(AA) | fill (8-bit channels, exact in f32) |
visible, opacity, cornerRadius (number or four values), clip (frames) | visual.visible, visual.opacity, visual.corner_radius, visual.clip_content (RFC 0016) |
one plain solid stroke with strokeWeight, strokeAlign and optional strokeSides on box geometry | visual.stroke |
rotation that is a multiple of 90° on a fixed-size layer outside auto layout | visual.rotation (negated: FigCraft turns counter-clockwise) with the unrotated box position |
plain single-style TEXT (see below) | Text with a linked face (RFC 0017), approximated |
standalone COMPONENT with boolean and text properties (see below) | Component with a definition (RFC 0018) |
COMPONENT_SET with complete variant trees and compatible properties | one Component with enum parameters, property overrides and alternate variant trees |
INSTANCE of a mapped component or variant | Instance with parameter values and overrides |
| any other layer type (rich or styled text, non-fitting set, vector, group, …) | Unknown entity in namespace org.figcraft.node holding a fingerprint, unsupported |
Main-axis alignment maps packed and distributed values. Wrapped stacks
carry crossGap and contentAlign. Baseline alignment, reverse canvas
stacking and inside strokes included in auto layout keep a layer outside
this mapping. The synthetic native trial compares a fixed-size wrapped
stack against FigCraft child boxes and verifies the reread after editing
alignment and clearing per-side widths.
Text
A TEXT layer maps when it carries only characters, fontFamily,
fontStyle, fontSize, lineHeight, letterSpacing, textAlign,
textAutoResize, at most one plain solid fill and the common geometry,
visibility and opacity keys. Any other key (styled runs, decoration, list
settings, maximum lines, leading trim, variations, rotation, strokes, effects)
keeps the layer opaque.
| FigCraft | NUIF text |
|---|---|
fontFamily + fontStyle | one shared linked font asset per face (face_asset_id), no bytes; font_sha256 absent |
lineHeight Auto / "150%" / px | line_height_rule font_metrics / percent, or absolute line_height |
letterSpacing "-2%" / px | letter_spacing percent / px |
textAlign left/center/right | align left/center/right (justified stays opaque) |
textAutoResize widthAndHeight / height / none | wrap none / word / word with overflow: visible; truncate stays opaque |
fill #000000 / other / none | default colour / color / transparent color |
| (always) | leading: half_leading, line_height_snap: whole_pixel |
node.get does not report vertical alignment, letter case, paragraph spacing
and indent, or OpenType features, and no other read command reports all of
them. Imported text therefore records approximated at text: their defaults
are assumed, and plans never write them, so the host keeps its values. Plans
refuse a non-top vertical alignment because the result could not be verified.
FigCraft adds overrides: ["characters"] to a text whose characters were
edited, for instance swaps; that bookkeeping is ignored and never written.
Plans emit characters, the face, size, line height, letter spacing,
alignment, auto-resize mode and fill, create text with node.create {type: "text"}, and refuse text that requests exact bytes or a face without a style
name, logical (start/end) alignment, ascent-top leading or unsnapped line
pitches, sizing that contradicts the auto-resize mode, a text box fill, and
corner radii or strokes on text.
Components and instances
A COMPONENT maps when it is not in a component set, is reachable through
frames, is not inside another component and has only boolean, text and
instance-swap properties; its componentPropertyDefinitions become
parameters and its layers its definition tree. An instance-swap property
becomes a component parameter whose default (a host component id) must name
a mapped component or a variant of a mapped set, which resolves to that
set’s component. node.get does not report which layer a property
drives, so bindings are read from the saved file
(read_saved_supplement, --saved file.figcraft): its document.json
(format: "figcraft", version: 1, bounded to 64 MiB) records prop_refs
(characters → text content, visible → visibility, mainComponent → a
nested instance’s component). Without it the
component is reported approximated at componentPropertyDefinitions.
An INSTANCE of a mapped component becomes an Instance: its non-default
componentProperties are parameter values; its overrides groups and those
of its children (matched to the main component’s layers by order and type)
become overrides: fills (text colour for text), characters and
textStyle (the whole text), visible, opacity, corners, strokes,
size (children), and padding/gap/alignment (layout). Instance
position, size and name are its own placement. Other groups, overrides
inside opaque layers, and children that do not match keep the instance
opaque. A nested instance child maps its placement groups, and an explicit
swap (component group) or explicit values (props group) as component and
parameter overrides; a variable rebinding on an instance or its children is
a binding override, and the literal override it implies is dropped. When
validation rejects a component’s or instance’s overrides (for example an
override of a layer that stayed opaque), the import keeps that layer opaque
and repeats. Instance children are not imported: NUIF expands
the instance, and the import compares that expansion with the host’s
children, reporting differences approximated at children.
A COMPONENT_SET maps as one Component when every variant is a component
named Property=Value[, …] with compatible shared properties, the variants
set every variant property once and no configuration repeats. When the trees
correspond one to one, the adapter represents their differences as overrides. The first variant is the default: its values are the enum
defaults, its properties the component’s and its layers the definition
tree. Every other variant becomes a variant whose overrides are its
differences: fills, layout, corners, strokes, clipping, visibility,
opacity, child sizes, whole text, variable bindings (binding overrides), and
for nested instances another component (component override) or other
variant and property values (parameter overrides). Variants may use other
named styles; their references are kept with the component in the
org.figcraft.styles extension under variants. Differences in other properties or in
the positions of freeform children keep the set opaque. The set’s own frame
and variant arrangement are reported unsupported. An instance of a
variant maps to the set’s component with the variant’s values as enum
parameters; its children are matched to the variant’s layers and their
overrides addressed through the default variant’s corresponding layers.
Plans set changed instance properties with instance.setProperties
(removed values return to their defaults), move and resize instances with
node.set, and create instances with instance.create, node.set (identity
and placement) and instance.setProperties; a variant property value
switches the instance to that variant, and a set instantiates its default
variant first. Overrides are written with node.set on the instance (root)
or on the materialized child the definition layer corresponds to, and
removed with component.resetOverride for their groups; width and height
are overridden together, and a text layer’s colour is part of its text
override. Definition changes are planned before any instance step:
component.addProperty, deleteProperty and editProperty for boolean,
text and instance-swap properties (which FigCraft orders by name), and
component.bindProperty for bindings, recorded in the planned saved-file
supplement for verification. FigCraft gives instances a new property at its
default, keeps their shown value when a default changes, and sets a bound
layer to the property default; plans therefore re-set instance values whose
effective value would change and refuse a binding whose layer does not show
the default. They refuse variant and variant-property changes, creating
components, bindings without the saved file, component swaps,
overrides inside nested instances, rotation and clipping overrides,
overrides on new instances, structure changes inside components and deleting
components.
Instance-swap values are written as host component ids. Slot properties are
not mapped yet.
Named styles
A layer’s named styles (styles entries that are not null: text, fill,
stroke, …) stay in FigCraft: the layer maps with the values it shows, and
the references are kept in the org.figcraft.styles extension, reported
preserved_unrenderable. Text maps when one text style covers all of it
(textStyleRanges empty or one range from 0 to its UTF-16 length with the
styles.text id); several ranges are rich text and keep it opaque. Plans
refuse changes to the style references and to the properties a style
governs (font family, style, size, line height and letter spacing for a text
style; fills and strokes for paint styles), and keep characters edits, after
which FigCraft extends the style over the new text. Instances and variants
whose styles differ from their main or default variant stay opaque.
Variable bindings
With a variable.list snapshot (VariablesContext, --variables with
--variables-correspondence and --options), the document carries the
variables’ tokens and collections, and a layer’s boundVariables become
token bindings (RFC 0019): fill (text colour on text), stroke,
strokeWeight, cornerRadius, visible, gap, paddingHorizontal,
paddingVertical and per-side paddings, width, height, and on text
fontSize, lineHeight, letterSpacing and characters. Explicit variable
modes, which node.get does not report, come from the saved file’s
var_modes and become mode selections. A binding NUIF cannot map (an
unknown field, opacity, which FigCraft expresses in percent, an unmapped
variable) or whose host value differs from its token’s value in the layer’s
modes is kept in the org.figcraft.bindings extension; the latter is
reported approximated. Instances whose bindings differ from their main
component, and sets whose variants bind differently, stay opaque.
Plans write a changed binding with variable.bind after the literal, and
bind again every binding that a literal write would detach (for example the
horizontal padding when the top padding changes); paired paddings bound to
one variable use paddingHorizontal/paddingVertical. Plans refuse
documents whose tokens differ from the host’s variables (plan and apply the
variables first) and changes to variable modes.
Opaque layers
An opaque layer stays in FigCraft. Its Unknown payload is a SHA-256
fingerprint ({"sha256", "bytes"}) of its authored content: the node JSON
without its id, pluginData and the geometry FigCraft resolves from layout
(position, absolute bounds, and hug- or fill-sized lengths), so reflowing
auto layout does not change it. The fingerprint lets plans refuse any change
to the layer while large files stay within the profile-0 budgets; copying the
JSON itself would serve no other consumer and, in a production design-system
file of about ten thousand layers, exceeded the 512 KiB binary budget. It is
reported unsupported because NUIF holds no content for it. Positions of
auto-layout children are resolved by FigCraft and are not imported.
Identity
Each layer’s NUIF id is stored in pluginData["nuif.id"]. On import the
recorded correspondence wins, then pluginData, then a SHA-256-derived id.
pluginData survives save, reload and branch merge, but duplicate and
copy-paste copy it verbatim: when several layers claim one id, the recorded or
lowest-numbered layer keeps it and the others receive new ids. Layers whose id
was absent, malformed or reassigned are listed in repaired, and plans write
their id. NodeCorrespondence is persisted by the caller; bind_node_results
replaces the placeholder ids of created layers with host ids.
Unsupported and refused
Rotation: FigCraft turns a layer counter-clockwise about its box centre and
reports the rotated origin as x/y, rounded to 0.01 px for other angles.
A right-angle rotation of a layer outside auto layout converts exactly to
NUIF’s clockwise rotation and unrotated box position, and plans write the
rotation and the rotated origin together. Reported unsupported and retained
in the host: other angles, rotated children of auto layout (FigCraft lays out
their rotated bounds, NUIF rotates after layout), rotated text and instances, corner smoothing, per-side, dashed, multiple or non-solid strokes,
corner radii on ellipses, effects, blend modes, size limits, grid or wrapping auto layout, main-axis distribution, baseline
alignment, absolute children of auto layout, and fills other than one plain
solid paint. Plans refuse changes to opaque layers (including renames), kind
changes, rotations other than right angles of fixed-size freeform layers,
content clipping on non-frames, moving a layer to the page, sizing without a FigCraft form for the
layer (for example Auto on a rectangle), stretch alignment, colours that are
not 8-bit exact, and layers absent from the document unless retain_unmanaged
leaves them or allow_deletions deletes them. Every plan is applied to a
simulated snapshot and re-imported; it is returned only when the re-import
equals the document.
Command line
nuif figcraft nodes-import --snapshot layers.json --output layers.nuif.json \
[--correspondence c.json] [--correspondence-out c2.json] [--report r.json]
nuif figcraft nodes-plan --document layers.nuif.json --snapshot layers.json \
--script script.json --plan plan.json [--correspondence c.json] [--options o.json]
nuif figcraft nodes-bind --plan plan.json --results run.jsonl --correspondence-out c.json
Limits
16 MiB snapshot and 8,192 layers; duplicate layer ids are refused.
Evidence
crates/nuif-figcraft/src/tests.rs: import of the captured snapshot with independent expected values and fidelity; identity writes followed by a repair-free re-import and an empty plan; property updates, creation and reordering; duplicate repair; refused opaque-layer changes; refused and opt-in deletion.crates/nuif-cli/tests/token_commands.rschecks the command-line wiring.figcraft-variables-trialruns a layer scenario against the realfigcraft-cli run: identity writes, a host edit imported as exactly that change, repair of a designer duplicate, a NUIF-side addition with reordering, and a text restyle (content, size, percent line height, percent letter spacing, centre alignment, colour) with a new wrapping caption, each followed by an empty plan. Local runs withfigcraft-cli 0.18.1on macOS passed on 2026-11-20.- Style tests: a captured fully styled title maps with its style kept, a partly styled text stays opaque, a characters edit is planned and a size change is refused; the native trial edits a styled title’s characters.
- Binding tests: a captured themed card, text and a swatch in a Dark frame import with independent token bindings and the swatch’s dark value through the saved file’s mode; without the mode the swatch’s binding is kept as an extension; rebinding, unbinding, a rewritten padding and a bound creation plan the expected steps and re-import equal; token and mode changes are refused. The native trial runs the same scenario.
- Swap tests: a captured card whose nested badge follows an instance-swap
property imports with a component parameter, a binding and a swapped
instance whose expansion uses the other component; swapping back is one
instance.setPropertiesstep. The native trial swaps an instance’s badge and checks the host’s nested instance. - Set tests: the captured set imports as one component with an enum
parameter and a
Largevariant whose overrides are its padding and label size; variant instances import their values and expand to the host’s children; a variant switch and a creation from the set are planned and re-import equal; a set whose variants differ in structure stays opaque. The native trial runs the same set scenario againstfigcraft-cli run. - Component tests: the captured component and instances import with independent expected values and bindings from a reduced saved document (also read from a zip archive; other versions are refused); without it the bindings are reported; property changes, resets and instance creation plan the expected commands; definition, override and structure edits are refused; unsupported components and instances stay opaque. The native trial builds a component with bound properties and two instances, imports it with the saved file (expansion equal to the host’s children), writes identity, changes an instance property and creates an instance, sets and resets overrides, and changes a default and deletes a bound property, each re-read equal with an empty plan.
- Text tests: the captured label imports with independent expected values; edits emit exactly the changed keys; creation; each plan refusal; seven out-of-profile text shapes stay opaque; the edit bookkeeping is ignored.
Structural variants and slots
The adapter retains an alternate tree when a fully observed variant’s layers differ in type, non-instance name, order or cardinality. Instances can select those configurations. The host plan refuses edits to the definitions of structurally varied sets.
A slot’s declared preferences and target frame map to a slot parameter and binding. Replacement children map when they are distinct unmodified default instances of mapped components. Plans insert the selected list or restore default content. Slot declaration and frame binding edits stay on the host. The native trial verifies insertion, reread, an empty follow-up plan, and reset to the authored default.
Not covered
Rich text runs, text decoration, case, lists, features, variations, arbitrary
slot content, vector geometry, effects and
rotation other than right angles remain outside the mapping. Linked faces
use estimated layout metrics and a bundled Noto Sans preview subset. The
render scene reports the substitution as approximated.