AI-native design editor. Open-source Figma alternative.
refactor(kiwi)!: drop the colorVariableBinding paint field
Danila Poyarkovd1159a7d0732
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 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.tsindex 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.tsindex 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.tsindex 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)) returnlet declared = falsefor (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?.aliasif (!alias) continueconst 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.tsindex 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 } = paintreturn unbound}return {diff --git a/packages/fig/src/node-change/plugin-data.ts b/packages/fig/src/node-change/plugin-data.tsindex 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<string, string> {}}nc.fillPaints?.forEach((paint, i) => {- const variableGuid =- paint.colorVariableBinding?.variableID ?? paint.colorVar?.value?.alias?.guid+ const variableGuid = paint.colorVar?.value?.alias?.guidif (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?.guidif (variableGuid) bindings[`strokes/${i}/color`] = guidToString(variableGuid)})return bindingsdiff --git a/packages/kiwi/src/fig/codec.ts b/packages/kiwi/src/fig/codec.tsindex 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 | Uint8Arrayname?: string@@ -150,7 +146,6 @@ export interface Paint {density?: numbernoiseSize?: VectorcustomEffectId?: { guid?: GUID }- colorVariableBinding?: VariableBindingcolorVar?: {value?: {alias?: {