Commit graph

462 commits

Author SHA1 Message Date
Joseph Cumines c4073dc284 fix(kiwi): repair .fig roundtrip - missing nodes, schema mismatch, GUID collisions
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.
2026-05-24 18:29:14 +10:00
Danila Poyarkov c337905a02 fix(canvas): preserve text OpenType toggles 2026-05-23 01:43:00 +03:00
Danila Poyarkov f36d6b94b7 fix(canvas): apply affine image fill transforms 2026-05-23 01:31:04 +03:00
Danila Poyarkov 762c86e094 Revert "perf(canvas): defer backing rebuilds while zooming"
This reverts commit 21a79d4cd5.
2026-05-23 01:17:48 +03:00
Danila Poyarkov 21a79d4cd5 perf(canvas): defer backing rebuilds while zooming 2026-05-23 01:17:07 +03:00
Danila Poyarkov 0d5db35147 perf(canvas): bound blend and text mask layers 2026-05-23 01:10:24 +03:00
Danila Poyarkov f07d26c50b perf(canvas): bound effect render layers 2026-05-23 01:01:38 +03:00
Danila Poyarkov 7184bc1b06 Revert "perf(canvas): cap retained backing size"
This reverts commit 7b62c8acca.
2026-05-23 00:45:13 +03:00
Danila Poyarkov 7b62c8acca perf(canvas): cap retained backing size 2026-05-23 00:30:30 +03:00
Danila Poyarkov 054199ac15 fix(kiwi): preserve edited font variation axes 2026-05-23 00:26:58 +03:00
Danila Poyarkov 8c85d2b953 fix(canvas): improve Figma mask and text fidelity 2026-05-23 00:18:33 +03:00
Danila Poyarkov 5b12b1597f test(canvas): make luminance tile fixture visible 2026-05-22 23:55:20 +03:00
Danila Poyarkov ea08ea1370 test(canvas): cover luminance masks and tile transforms 2026-05-22 23:52:47 +03:00
Danila Poyarkov 3dc0904466 fix(canvas): support luminance masks and tile transforms 2026-05-22 23:44:10 +03:00
Danila Poyarkov f8db73949e test(canvas): cover renderer showcase visuals 2026-05-22 23:24:26 +03:00
Danila Poyarkov e65d53c9d3 test(canvas): add visual blend and mask fixtures 2026-05-22 23:13:46 +03:00
Danila Poyarkov ad0b984057 test(canvas): cover smoothed corner visuals 2026-05-22 23:09:55 +03:00
Danila Poyarkov 98616c8610 fix(canvas): render Figma-style corner smoothing 2026-05-22 23:05:24 +03:00
Danila Poyarkov 76ee122dee fix(canvas): render smoothed corners and effect blend modes 2026-05-22 22:50:58 +03:00
Danila Poyarkov 0ce57ea0fa fix(canvas): render Figma mask stacks 2026-05-22 21:05:35 +03:00
Danila Poyarkov 8e1d5d40e7 fix(canvas): render Figma blend modes 2026-05-22 21:00:34 +03:00
Danila Poyarkov 11c3cfe73e test(canvas): drop brittle shadow source check
- Rely on behavioral effect tests for stroked container shadow coverage
2026-05-22 14:44:16 +03:00
Danila Poyarkov 8f4f7a47e9 fix(canvas): filter retained backing previews
- Keep stale scene backings available during zoom for smooth interaction

- Draw scaled backings with linear filtering to avoid blocky text artifacts
2026-05-22 14:44:16 +03:00
Danila Poyarkov a49f626e3e fix(canvas): render stroked container shadows from bounds
- Use container bounds for stroked frames with drop shadows

- Keep stroke-geometry shadows for childless stroke-only shapes

- Cover the shadcn dropdown menu case
2026-05-22 13:39:29 +03:00
Danila Poyarkov 1c22b3f7a9 test(canvas): align shadow cleanup checks
- Keep explicit color filter deletion checks compatible with cleanup guards

- Verify text inner-shadow restore balancing through the restore-count loop

Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
2026-05-22 13:17:04 +03:00
Danila Poyarkov f6e31be707 fix(canvas): delete renderer label resources
- Dispose parent outline paint during renderer teardown

- Dispose section and component label fonts with other renderer-owned fonts

- Cover renderer teardown for label resources

Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
2026-05-22 13:15:35 +03:00
Danila Poyarkov 420c61e004 fix(canvas): guard retained backing surfaces
- Fall back to live rendering when CanvasKit cannot allocate the backing surface

- Match retained backing metadata against the current graph preview version

- Cover null-surface and stale-preview backing regressions

Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
2026-05-22 12:51:00 +03:00
Danila Poyarkov 9f67a1086d fix(canvas): restore shadow render state on errors
- Restore canvas save layers and shared paints from shadow effect paths when rendering fails

- Delete temporary paths and color filters through error paths without suppressing failures

- Cover drop-shadow and text inner-shadow cleanup regressions

Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
2026-05-22 12:47:33 +03:00
Danila Poyarkov 0b4fcc9f77 fix(canvas): render shadows from path shapes
- Use polygon, star, and vector paths for shadows when geometry blobs are unavailable
- Apply shadow spread to copied geometry paths without mutating caches
- Clip and cut out inner shadows with the same path geometry

Co-authored-by: Joseph Cumines <joeycumines@gmail.com>
2026-05-22 12:37:00 +03:00
Danila Poyarkov 24ac31d4ab fix(fig): restore lazy badge visibility overrides 2026-05-21 14:54:18 +03:00
Danila Poyarkov da9dbbb9c6 fix(editor): preserve edits over imported metadata 2026-05-21 14:54:17 +03:00
Danila Poyarkov b5451c354f fix(fig): preserve kiwi version in export worker 2026-05-21 14:54:17 +03:00
Danila Poyarkov a48b23129f fix(fig): stabilize engine test suite 2026-05-21 14:54:17 +03:00
Danila Poyarkov dfea52475c test(fig): cover source metadata roundtrips 2026-05-21 14:54:17 +03:00
Danila Poyarkov 749585d737 refactor(fig): group source roundtrip metadata 2026-05-21 14:54:17 +03:00
Danila Poyarkov 450ca16b28 fix(fig): preserve component prop default values
- Add ComponentPropDef.varValue to the static Kiwi schema
- Keep imported boolean component defaults instead of degrading them to empty strings
2026-05-21 14:54:14 +03:00
Danila Poyarkov 307b271259 fix(fig): mark exported canvases as design pages
- Add the current Figma pageType field and EditorType enum values
- Write pageType DESIGN on exported CANVAS records so Figma initializes design-mode page state
2026-05-21 14:54:13 +03:00
Danila Poyarkov 25430b1479 fix(kiwi): restore export-stable schema fields
- Keep live clipboard-derived numbers only for fields emitted by preserved payloads
- Restore unused glyph/layout fields to the schema shape Figma imports without triggering Slides state
2026-05-21 14:54:13 +03:00
Danila Poyarkov 213db6373a refactor(kiwi): group fig format internals
- Move codec, NodeChange conversion, and instance overrides under kiwi/fig
- Flatten the codec entrypoint to kiwi/fig/codec
- Keep schema-runtime as the generic Kiwi parser/compiler boundary
2026-05-21 14:54:13 +03:00
Danila Poyarkov 54310308dc refactor(kiwi): split schema text from runtime
- Move the Kiwi runtime under schema-runtime to match folder naming
- Load the Figma schema from a .kiwi text asset with static validation
- Assert Figma clipboard-derived field numbers for fragile layout/text fields
2026-05-21 14:54:12 +03:00
Danila Poyarkov 40ee1b83d4 fix(fig): preserve instance override payloads
- Keep imported Figma node guids so override paths and symbol references remain stable
- Serialize imported symbolOverrides and uniform scale factors for instances
- Strip unsupported variable consumption maps from preserved overrides before encoding
2026-05-21 14:54:11 +03:00
Danila Poyarkov 9a6e29cf6f fix(fig): preserve imported layout metadata
- Keep Figma stack sizing fields such as RESIZE_TO_FIT_WITH_IMPLICIT_SIZE
- Avoid writing default auto-layout fields onto imported instances when Figma omitted them
- Cover instance layout metadata roundtrips
2026-05-21 14:54:11 +03:00
Danila Poyarkov 68ebef5f9b fix(fig): omit populated instance children on export
- Match Figma files where INSTANCE node changes carry symbol refs, not child nodes
- Prevent exported roundtrips from expanding every populated instance subtree
- Tighten glyph blob preservation now that instance children are omitted
2026-05-21 14:54:11 +03:00
Danila Poyarkov 1c655f34ce fix(fig): preserve auto-layout child transforms
- Stop zeroing transforms for auto-layout children during .fig export
- Match real Figma files, which keep child transform offsets alongside layout data
- Update transform regression coverage to prevent collapsed roundtrips
2026-05-21 14:54:11 +03:00
Danila Poyarkov 4fe2b75dc8 fix(io): keep page descendants in fig exports
- Preserve the source document root when extracting export subgraphs
- Include page descendants when exporting a single page to .fig
- Cover page subgraph extraction so CLI .fig exports are not empty
2026-05-21 14:54:10 +03:00
Danila Poyarkov c1ddbf7039 fix(fig): deduplicate exported text glyph blobs
- Preserve imported Figma glyph outlines for fallback rendering
- Reuse identical glyph command blobs across exported text nodes
- Cover real fixture preservation and generated glyph deduplication
2026-05-21 14:54:10 +03:00
Danila Poyarkov 8542c1db65 fix(vue): ignore click jitter before moving selection
- Start selection moves only after a 4px screen-space threshold
- Keep click selection from previewing or committing 1px geometry changes
- Cover below-threshold and intentional move behavior
2026-05-21 14:54:10 +03:00
Danila Poyarkov e6da2736fe fix(fig): sync lazy link component overrides
- Carry resolved text styling and glyph data through component-property text clones
- Align lazy cloned child placement and hidden chevrons with their resolved source
- Cover the gold-preview dropzone link lazy import regression
2026-05-20 15:02:01 +03:00
Danila Poyarkov 957db338ba fix(fig): sync lazy instance override clones
- Re-propagate resolved overrides after lazy instance population
- Preserve Figma showShadowBehindNode on effects
- Mask unfilled stroke shadows behind their fill geometry
2026-05-20 13:12:16 +03:00
Danila Poyarkov 4603bbf81b fix(canvas): shadow stroked shapes without fills
- Use stroke geometry for drop shadows on unfilled stroked nodes
- Avoid filling the interior of outline-only image icons
2026-05-20 12:52:21 +03:00