mcp-figma-toolkit 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/plugin/plugin.js +58 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-figma-toolkit",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "MCP server that enables AI agents to manipulate Figma documents - create shapes, text, styles, components, variables, and more",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
package/plugin/plugin.js CHANGED
@@ -27,16 +27,73 @@ function serializePaints(paints) {
27
27
  base.hex = rgbToHex(p.color);
28
28
  } else if (p.type && p.type.indexOf("GRADIENT") === 0 && p.gradientStops) {
29
29
  base.gradientStops = p.gradientStops.map(function(s) {
30
- return {
30
+ var stop = {
31
31
  position: s.position,
32
32
  hex: s.color ? rgbToHex(s.color) : null,
33
33
  opacity: s.color && s.color.a != null ? s.color.a : 1
34
34
  };
35
+ if (s.boundVariables) {
36
+ var sbv = {};
37
+ var stopBVKeys = ["color"];
38
+ for (var sk in s.boundVariables) {
39
+ var sb = s.boundVariables[sk];
40
+ if (sb && sb.id) {
41
+ sbv[sk] = { type: sb.type, id: sb.id };
42
+ try {
43
+ var sv = figma.variables.getVariableById(sb.id);
44
+ if (sv) { sbv[sk].name = sv.name; sbv[sk].resolvedType = sv.resolvedType; }
45
+ } catch (_) {}
46
+ }
47
+ }
48
+ for (var si = 0; si < stopBVKeys.length; si++) {
49
+ var spk = stopBVKeys[si];
50
+ if (!(spk in sbv)) {
51
+ try {
52
+ var spb = s.boundVariables[spk];
53
+ if (spb && spb.id) {
54
+ sbv[spk] = { type: spb.type, id: spb.id };
55
+ var spv = figma.variables.getVariableById(spb.id);
56
+ if (spv) { sbv[spk].name = spv.name; sbv[spk].resolvedType = spv.resolvedType; }
57
+ }
58
+ } catch (_) {}
59
+ }
60
+ }
61
+ if (Object.keys(sbv).length > 0) stop.boundVariables = sbv;
62
+ }
63
+ return stop;
35
64
  });
36
65
  } else if (p.type === "IMAGE") {
37
66
  base.scaleMode = p.scaleMode;
38
67
  base.imageHash = p.imageHash;
39
68
  }
69
+ if (p.boundVariables) {
70
+ var pbv = {};
71
+ var paintBVKeys = ["color", "opacity"];
72
+ for (var pk in p.boundVariables) {
73
+ var pb = p.boundVariables[pk];
74
+ if (pb && pb.id) {
75
+ pbv[pk] = { type: pb.type, id: pb.id };
76
+ try {
77
+ var pv = figma.variables.getVariableById(pb.id);
78
+ if (pv) { pbv[pk].name = pv.name; pbv[pk].resolvedType = pv.resolvedType; }
79
+ } catch (_) {}
80
+ }
81
+ }
82
+ for (var pi = 0; pi < paintBVKeys.length; pi++) {
83
+ var ppk = paintBVKeys[pi];
84
+ if (!(ppk in pbv)) {
85
+ try {
86
+ var ppb = p.boundVariables[ppk];
87
+ if (ppb && ppb.id) {
88
+ pbv[ppk] = { type: ppb.type, id: ppb.id };
89
+ var ppv = figma.variables.getVariableById(ppb.id);
90
+ if (ppv) { pbv[ppk].name = ppv.name; pbv[ppk].resolvedType = ppv.resolvedType; }
91
+ }
92
+ } catch (_) {}
93
+ }
94
+ }
95
+ if (Object.keys(pbv).length > 0) base.boundVariables = pbv;
96
+ }
40
97
  return base;
41
98
  });
42
99
  }