From d1159a7d0732faf69ce2a73d14a2ff20fc1e9b16 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Thu, 1 Oct 2026 23:47:51 +0400 Subject: [PATCH] refactor(kiwi)!: drop the colorVariableBinding paint field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `fig.kiwi` never defined the field, so nothing Figma writes carries one and nothing OpenPencil writes has since `colorVar` replaced it. What remained were readers kept so that files written by earlier OpenPencil builds still restored their bindings — a compatibility path the project does not keep before 1.0. The field, the `VariableBinding` type and both readers are gone. Reopening one of those files leaves the paint's colour unbound; binding it again records it the way Figma does. --- CHANGELOG.md | 1 + packages/core/src/index.ts | 1 - packages/core/src/kiwi/index.ts | 1 - packages/fig/src/instance-overrides/materialize-instance.ts | 2 +- packages/fig/src/node-change/export/context.ts | 4 ++-- packages/fig/src/node-change/plugin-data.ts | 6 ++---- packages/kiwi/src/fig/codec.ts | 5 ----- 7 files changed, 6 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b64169f8..878385d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Breaking changes +- `VariableBinding` and the `colorVariableBinding` paint field are gone from `@open-pencil/core`, `@open-pencil/core/kiwi`, and the Kiwi `Paint` type. `fig.kiwi` never defined the field, so only `.fig` files OpenPencil itself wrote before `colorVar` contain one; reopening such a file leaves the paint's colour unbound, and binding it again records it the way Figma does. - `encodeNodeChangeWithVariables`, `encodePaintWithVariableBinding`, and `encodeVarint` are removed from `@open-pencil/core` and `@open-pencil/core/kiwi`. They spliced a colour-variable binding into encoded bytes because the field had no schema entry; exports now write `colorVar`, which `fig.kiwi` defines, so nothing needs them. `parseVariableId` is unchanged. - The desktop app now requires macOS 13 or later; the web app supports Chrome 111, Edge 111, Firefox 128, and Safari 16.4 or later. - `.fig` reading moved to one reader, so the previous importer's exports are gone. `importNodeChanges` (`@open-pencil/core` and `@open-pencil/core/kiwi`) and `importClipboardNodes` (`@open-pencil/fig/clipboard`) are replaced by `parseFigFile` and `parseFigmaClipboard`; `populateLazyFigImportRoots` and `populateAllLazyFigImportRoots` (`@open-pencil/core/kiwi`) are replaced by `populateFigPage` and `populateAllFigPages` on `@open-pencil/core/io/formats/fig`; `populateAndApplyOverrides` (`@open-pencil/fig/instance-overrides`) is replaced by `interpretInstance` with `materializeInstance`. `FIG_PACKAGE_STATUS` now reads `document-reader`, and `assertFigPackageReady()` is gone, because `@open-pencil/fig` reads an archive into a SceneGraph itself rather than directing callers to Core. diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 35906104c..306b21c8a 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -341,7 +341,6 @@ export { type Color as KiwiColor, type Paint as KiwiPaint, type Effect as KiwiEffect, - type VariableBinding, type ParentIndex, type FigmaMessage, MESSAGE_TYPES, diff --git a/packages/core/src/kiwi/index.ts b/packages/core/src/kiwi/index.ts index ea65b1944..e9f894772 100644 --- a/packages/core/src/kiwi/index.ts +++ b/packages/core/src/kiwi/index.ts @@ -19,7 +19,6 @@ export { type Color, type Paint, type Effect, - type VariableBinding, type VariableAnyValue, type VariableDataEntry, type VariableConsumptionEntry, diff --git a/packages/fig/src/instance-overrides/materialize-instance.ts b/packages/fig/src/instance-overrides/materialize-instance.ts index 061d00a7b..e621d272f 100644 --- a/packages/fig/src/instance-overrides/materialize-instance.ts +++ b/packages/fig/src/instance-overrides/materialize-instance.ts @@ -185,7 +185,7 @@ function recordPaintBindingClaims( if (!Array.isArray(paints)) return let declared = false for (const [index, paint] of paints.entries()) { - const alias = (paint as Paint).colorVar?.value?.alias ?? (paint as Paint).colorVariableBinding + const alias = (paint as Paint).colorVar?.value?.alias if (!alias) continue const field = `boundVariables/${scene}/${index}/color` setInstanceOverride( diff --git a/packages/fig/src/node-change/export/context.ts b/packages/fig/src/node-change/export/context.ts index 8ea06ff44..5210c9d8a 100644 --- a/packages/fig/src/node-change/export/context.ts +++ b/packages/fig/src/node-change/export/context.ts @@ -181,8 +181,8 @@ export function applyColorVariableBinding( // An imported paint carries the binding it arrived with. Unbinding the field has to clear // it, or the export hands Figma back a variable the document no longer references. if (!variableId) { - if (!paint.colorVar && !paint.colorVariableBinding) return paint - const { colorVar: _unbound, colorVariableBinding: _legacy, ...unbound } = paint + if (!paint.colorVar) return paint + const { colorVar: _cleared, ...unbound } = paint return unbound } return { diff --git a/packages/fig/src/node-change/plugin-data.ts b/packages/fig/src/node-change/plugin-data.ts index 437762253..0ebe7a080 100644 --- a/packages/fig/src/node-change/plugin-data.ts +++ b/packages/fig/src/node-change/plugin-data.ts @@ -141,13 +141,11 @@ export function extractBoundVariables(nc: NodeChange): Record { } } nc.fillPaints?.forEach((paint, i) => { - const variableGuid = - paint.colorVariableBinding?.variableID ?? paint.colorVar?.value?.alias?.guid + const variableGuid = paint.colorVar?.value?.alias?.guid if (variableGuid) bindings[`fills/${i}/color`] = guidToString(variableGuid) }) nc.strokePaints?.forEach((paint, i) => { - const variableGuid = - paint.colorVariableBinding?.variableID ?? paint.colorVar?.value?.alias?.guid + const variableGuid = paint.colorVar?.value?.alias?.guid if (variableGuid) bindings[`strokes/${i}/color`] = guidToString(variableGuid) }) return bindings diff --git a/packages/kiwi/src/fig/codec.ts b/packages/kiwi/src/fig/codec.ts index 280e6c35d..6c203b170 100644 --- a/packages/kiwi/src/fig/codec.ts +++ b/packages/kiwi/src/fig/codec.ts @@ -105,10 +105,6 @@ export interface ParentIndex { position: string } -export interface VariableBinding { - variableID: GUID -} - export interface ImageSource { hash: string | Uint8Array name?: string @@ -150,7 +146,6 @@ export interface Paint { density?: number noiseSize?: Vector customEffectId?: { guid?: GUID } - colorVariableBinding?: VariableBinding colorVar?: { value?: { alias?: {