openpencil/packages/core/src
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
..
cache refactor(canvas): share bounded resource cache bookkeeping 2026-09-15 21:28:16 +03:00
canvas feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
clipboard feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
design-jsx feat: preview streamed JSX on the canvas (#692) 2026-10-01 10:52:36 +04:00
editor feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
figma-api feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
geometry feat(editor): checkpoint live interaction improvements 2026-09-15 11:36:17 +03:00
icons refactor!: move shared primitives below dom-css and core (#771) 2026-09-26 11:39:11 +04:00
io fix(fig): give every exported layer its own order key, and keep the imported ones 2026-10-01 14:57:46 +04:00
kiwi feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
layout feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
library fix: preserve structured overrides across JSON boundaries 2026-09-01 13:35:09 +03:00
lint fix(tools): judge describe text contrast by WCAG ratio (#758) 2026-09-30 11:32:34 +04:00
profiler perf(canvas): rebuild navigation rendering (#591) 2026-08-31 13:39:40 +03:00
rpc refactor!: move shared primitives below dom-css and core (#771) 2026-09-26 11:39:11 +04:00
text refactor!: register HTML and Tailwind JSX as IO formats (#774) 2026-09-26 11:54:16 +04:00
tools feat: preview streamed JSX on the canvas (#692) 2026-10-01 10:52:36 +04:00
vector refactor!: move shared primitives below dom-css and core (#771) 2026-09-26 11:39:11 +04:00
canvaskit.ts fix(editor): preserve edits over imported metadata 2026-05-21 14:54:17 +03:00
clipboard.ts feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
constants.ts fix(canvas): keep labels readable and refine section badges 2026-09-15 19:54:04 +03:00
global.d.ts fix(figma-api): validate effects like Figma (#794) 2026-09-30 21:18:20 +04:00
index.ts feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
layout.ts feat(fig): occurrence-scoped instance interpretation as the single .fig reader 2026-10-01 11:20:27 +04:00
random.ts
xpath.ts feat: split SceneGraph and Pen packages 2026-06-30 10:54:32 +03:00