openpencil/packages
Danila Poyarkov b7d9c02ebc
fix(fig): give every exported layer its own order key, and keep the imported ones
* fix(fig): give every layer on an exported canvas its own order key

Figma orders siblings by `parentIndex.position`. Shared styles, the
variable records and a canvas's own layers are written in three passes,
all landing on the internal canvas, and each numbered from the first
key — so up to five siblings claimed `!`. Exporting gold-preview left
402 records under one canvas with keys repeating up to five times.

Each pass now continues the keys already written for that canvas.
Counting them per canvas also covers the ordinary pages, whose layers
are written after the internal resources.

* fix(fig): keep the order keys a layer was imported with

Saving a document renumbered every sibling from the first key, so a
round trip rewrote positions Figma had assigned even where nothing
moved. A layer now keeps its imported key where that still orders it
after the previous sibling, and takes a key between its neighbours
otherwise.

Canvas children are excluded: shared styles and variable records are
written to the internal canvas by other passes that continue the keys
already there, so an imported key could collide with one of theirs.

Co-authored-by: mrhard9090 <74858909+mrhard9090@users.noreply.github.com>

* refactor(fig): look a sibling's order key up by id

`exportOrderKey` runs once per child and scanned the sibling list for
the node, so a parent with many layers cost O(n²) to export. The cached
entry now maps id to key directly.

Covers all three writers in the canvas test as well: an internal canvas
with its own layers, a shared style, and two variable collections, so
the pass boundaries that restarted a sequence are exercised rather than
only the page and variable passes.

* refactor(core): name the GUID type in the canvas order key test

---------

Co-authored-by: mrhard9090 <74858909+mrhard9090@users.noreply.github.com>
2026-10-01 14:57:46 +04:00
..
cli feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
core fix(fig): give every exported layer its own order key, and keep the imported ones 2026-10-01 14:57:46 +04:00
demos
design-jsx feat: preview streamed JSX on the canvas (#692) 2026-10-01 10:52:36 +04:00
docs feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
dom-css refactor(dom-css): group sources into import, export, and runtime (#789) 2026-09-30 09:44:52 +04:00
fig fix(fig): give every exported layer its own order key, and keep the imported ones 2026-10-01 14:57:46 +04:00
harness docs: route contributors through per-domain guides and ship npm license text (#785) 2026-09-29 01:02:06 +04:00
kiwi feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
mcp refactor(design-jsx): extract design JSX into its own package (#793) 2026-09-30 20:55:27 +04:00
pen fix(figma-api): validate effects like Figma (#794) 2026-09-30 21:18:20 +04:00
scene-graph test(core): move the fig round-trip suite home, and stop test imports drilling 2026-10-01 14:11:53 +04:00
vue docs: route contributors through per-domain guides and ship npm license text (#785) 2026-09-29 01:02:06 +04:00