Exporting a .fig from OpenPencil and reimporting lost most nodes
(38323 to 57 on gold-preview.fig) and the same files wouldn't open
in Figma. gold-preview.fig now roundtrips into Figma. I haven't
traced each symptom to a specific fix with confidence, but the
changes address the underlying causes:
- fractionalPosition overflow past 94 siblings produced characters
outside Figma's printable ASCII range (33-126); gold-preview.fig
has nodes with 492 children so this hit immediately. New telescoping
~-prefix scheme matches Figma's own encoding.
- re-export used OpenPencil's subset kiwi schema, likely producing
field IDs misaligned with the embedded schema. Preserve and use
the original schema (graph.figSchemaDeflated) instead.
- variable GUIDs assigned before canvas entries could collide with
source.id-derived canvas GUIDs. Reversed the order, scan all
imported GUIDs to advance the counter.
- auto-layout child sort ignored parentIndex.position, using only
transform position which may not reflect original tree order for
imported nodes. Sort by position first, transform as tiebreaker.
- Object.assign of rawNodeFields overwrote explicit serialization.
Materialize with paint variables, apply blocklist, skip keys
already set on nc.
Also fixes: strokeWeight defaulting on strokeless nodes, colorVar
assetRef to guid conversion, per-corner radii emission, textAlignVertical
hardcoding, textAutoResize override for imported nodes, stackReverseZIndex
roundtrip, variable key/version preservation, blendMode on effects,
textCase emission.
Adds exhaustive roundtrip test comparing G0 to G1 to G2 across schema
bytes, node count, tree paths, scene props, and raw node fields.