figma-console-mcp 1.12.1 → 1.12.2
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.
- package/figma-desktop-bridge/code.js +56 -47
- package/package.json +1 -1
|
@@ -781,12 +781,13 @@ figma.ui.onmessage = async (msg) => {
|
|
|
781
781
|
componentPropertyDefinitions: (node.type === 'COMPONENT_SET' || (node.type === 'COMPONENT' && !isVariant))
|
|
782
782
|
? node.componentPropertyDefinitions
|
|
783
783
|
: undefined,
|
|
784
|
-
// Get children info (lightweight)
|
|
785
|
-
children: node.children ? node.children.
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
784
|
+
// Get children info (lightweight) — skip unresolvable slot sublayers
|
|
785
|
+
children: node.children ? node.children.reduce((acc, child) => {
|
|
786
|
+
try {
|
|
787
|
+
acc.push({ id: child.id, name: child.name, type: child.type });
|
|
788
|
+
} catch (e) { /* slot sublayer or table cell — skip */ }
|
|
789
|
+
return acc;
|
|
790
|
+
}, []) : undefined
|
|
790
791
|
}
|
|
791
792
|
};
|
|
792
793
|
|
|
@@ -856,40 +857,42 @@ figma.ui.onmessage = async (msg) => {
|
|
|
856
857
|
var variantAxes = {};
|
|
857
858
|
var variants = [];
|
|
858
859
|
|
|
859
|
-
// Parse variant properties from children names
|
|
860
|
+
// Parse variant properties from children names — skip unresolvable slot sublayers
|
|
860
861
|
if (node.children) {
|
|
861
862
|
node.children.forEach(function(child) {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
variantAxes[key]
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
variantAxes[key].
|
|
863
|
+
try {
|
|
864
|
+
if (child.type === 'COMPONENT') {
|
|
865
|
+
// Parse variant name (e.g., "Size=md, State=default")
|
|
866
|
+
var variantProps = {};
|
|
867
|
+
var parts = child.name.split(',').map(function(p) { return p.trim(); });
|
|
868
|
+
parts.forEach(function(part) {
|
|
869
|
+
var kv = part.split('=');
|
|
870
|
+
if (kv.length === 2) {
|
|
871
|
+
var key = kv[0].trim();
|
|
872
|
+
var value = kv[1].trim();
|
|
873
|
+
variantProps[key] = value;
|
|
874
|
+
|
|
875
|
+
// Track all values for each axis
|
|
876
|
+
if (!variantAxes[key]) {
|
|
877
|
+
variantAxes[key] = [];
|
|
878
|
+
}
|
|
879
|
+
if (variantAxes[key].indexOf(value) === -1) {
|
|
880
|
+
variantAxes[key].push(value);
|
|
881
|
+
}
|
|
879
882
|
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
}
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
variants.push({
|
|
886
|
+
key: child.key,
|
|
887
|
+
nodeId: child.id,
|
|
888
|
+
name: child.name,
|
|
889
|
+
description: child.description || null,
|
|
890
|
+
variantProperties: variantProps,
|
|
891
|
+
width: child.width,
|
|
892
|
+
height: child.height
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
} catch (e) { /* slot sublayer — skip */ }
|
|
893
896
|
});
|
|
894
897
|
}
|
|
895
898
|
|
|
@@ -937,10 +940,10 @@ figma.ui.onmessage = async (msg) => {
|
|
|
937
940
|
}
|
|
938
941
|
}
|
|
939
942
|
|
|
940
|
-
// Recurse into children
|
|
943
|
+
// Recurse into children — skip unresolvable slot sublayers
|
|
941
944
|
if (node.children) {
|
|
942
945
|
node.children.forEach(function(child) {
|
|
943
|
-
findComponents(child);
|
|
946
|
+
try { findComponents(child); } catch (e) { /* slot sublayer — skip */ }
|
|
944
947
|
});
|
|
945
948
|
}
|
|
946
949
|
}
|
|
@@ -2236,14 +2239,20 @@ figma.loadAllPagesAsync().then(function() {
|
|
|
2236
2239
|
var selection = figma.currentPage.selection;
|
|
2237
2240
|
var selectedNodes = [];
|
|
2238
2241
|
for (var i = 0; i < Math.min(selection.length, 50); i++) {
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2242
|
+
try {
|
|
2243
|
+
var node = selection[i];
|
|
2244
|
+
selectedNodes.push({
|
|
2245
|
+
id: node.id,
|
|
2246
|
+
name: node.name,
|
|
2247
|
+
type: node.type,
|
|
2248
|
+
width: node.width,
|
|
2249
|
+
height: node.height
|
|
2250
|
+
});
|
|
2251
|
+
} catch (e) {
|
|
2252
|
+
// Slot sublayers and table cells may not be fully resolvable —
|
|
2253
|
+
// accessing .name throws "does not exist" for these node types.
|
|
2254
|
+
// Skip silently rather than crashing the plugin.
|
|
2255
|
+
}
|
|
2247
2256
|
}
|
|
2248
2257
|
figma.ui.postMessage({
|
|
2249
2258
|
type: 'SELECTION_CHANGE',
|
package/package.json
CHANGED