Skip to content

AI-native design editor. Open-source Figma alternative.

fix(kiwi): use Figma mask schema fields

Danila Poyarkova53ab45e868e
diff --git a/packages/core/src/kiwi/fig/node-change/convert.ts b/packages/core/src/kiwi/fig/node-change/convert.ts
index 4ba182bfd..944291bc1 100644
--- a/packages/core/src/kiwi/fig/node-change/convert.ts
+++ b/packages/core/src/kiwi/fig/node-change/convert.ts
@@ -521,7 +521,7 @@ export function nodeChangeToProps(
maxWidth: (nc.maxWidth ?? null) as number | null,
minHeight: (nc.minHeight ?? null) as number | null,
maxHeight: (nc.maxHeight ?? null) as number | null,
- isMask: (nc.isMask ?? false) as boolean,
+ isMask: nc.mask ?? false,
maskType: (nc.maskType ?? 'ALPHA') as 'ALPHA' | 'VECTOR' | 'LUMINANCE',
expanded: true,
autoRename: (nc.autoRename ?? true) as boolean,
diff --git a/packages/core/src/kiwi/fig/node-change/serialize.ts b/packages/core/src/kiwi/fig/node-change/serialize.ts
index f729f56b6..bc988f122 100644
--- a/packages/core/src/kiwi/fig/node-change/serialize.ts
+++ b/packages/core/src/kiwi/fig/node-change/serialize.ts
@@ -400,6 +400,10 @@ function serializeLayoutProps(node: SceneNode, nc: KiwiNodeChange): void {
}
function serializeGeometry(node: SceneNode, nc: KiwiNodeChange, blobs: Uint8Array[]): void {
+ if (node.isMask) {
+ nc.mask = true
+ nc.maskType = node.maskType
+ }
if (node.vectorNetwork && node.type === 'VECTOR') {
const { table, mirroringToId } = buildStyleOverrideTable(node.vectorNetwork)
const blobIdx = blobs.length
diff --git a/packages/docs/development/roadmap.md b/packages/docs/development/roadmap.md
index e2c8fe81a..76340a1ed 100644
--- a/packages/docs/development/roadmap.md
+++ b/packages/docs/development/roadmap.md
@@ -139,7 +139,7 @@ Figma's design documentation groups features into these areas:
| Effect styles | ↩ | — | — | ↩ | — | Style IDs round-trip; no style manager. |
| Corner radius | ✅ | ✅ | ✅ | ✅ | ✅ | Uniform and independent radii supported. |
| Corner smoothing | ✅ | ✅ | — | ✅ | ✅ | Figma-style smoothed corners render for common uniform and independent-radius rectangles; exact parity still needs broader fixture tuning. |
-| Masks | ✅ | ◐ | — | ✅ | ✅ | Common sibling alpha/vector/luminance mask stacks render, including consecutive mask layers; UI controls and deeper Figma edge cases remain incomplete. |
+| Masks | ✅ | ◐ | — | ✅ | ✅ | Figma schema `mask` / `maskType` fields import and export; common sibling alpha/vector/luminance mask stacks render, including consecutive mask layers. UI controls and deeper Figma edge cases remain incomplete. |
| Auto layout: vertical/horizontal | ✅ | ✅ | ✅ | ✅ | ✅ | Yoga-backed layout. |
| Auto layout: wrap | ✅ | ✅ | ✅ | ✅ | ✅ | UI toggle exists. |
| Auto layout: grid | ✅ | ◐ | ◐ | ✅ | ✅ | CSS-grid-like support is partial; newer schema fields for grid child alignment and auto tracks are not fully exposed. |
diff --git a/tests/engine/io/fig/export/masks.test.ts b/tests/engine/io/fig/export/masks.test.ts
new file mode 100644
index 000000000..b6413ef1d
--- /dev/null
+++ b/tests/engine/io/fig/export/masks.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, test } from 'bun:test'
+
+import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
+import { SceneGraph } from '#core/scene-graph'
+
+describe('Figma mask export', () => {
+ test('exports schema mask fields', () => {
+ const graph = new SceneGraph()
+ const page = graph.getPages()[0]
+ const mask = graph.createNode('RECTANGLE', page.id, {
+ isMask: true,
+ maskType: 'LUMINANCE'
+ })
+
+ const changes = sceneNodeToKiwi(mask, { sessionID: 1, localID: 1 }, 0, { value: 2 }, graph, [])
+
+ expect(changes[0].mask).toBe(true)
+ expect(changes[0].maskType).toBe('LUMINANCE')
+ })
+})
diff --git a/tests/engine/io/fig/import/masks.test.ts b/tests/engine/io/fig/import/masks.test.ts
new file mode 100644
index 000000000..e93904938
--- /dev/null
+++ b/tests/engine/io/fig/import/masks.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, test } from 'bun:test'
+
+import type { NodeChange } from '#core/kiwi/fig/codec'
+import { nodeChangeToProps } from '#core/kiwi/fig/node-change/convert'
+
+describe('Figma mask import', () => {
+ test('imports schema mask fields', () => {
+ const props = nodeChangeToProps(
+ {
+ type: 'RECTANGLE',
+ mask: true,
+ maskType: 'LUMINANCE'
+ } as NodeChange,
+ []
+ )
+
+ expect(props.isMask).toBe(true)
+ expect(props.maskType).toBe('LUMINANCE')
+ })
+})