@muloka/figma-console-mcp 0.6.4 → 0.6.6
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/README.md +18 -6
- package/dist/apps/design-system-dashboard/mcp-app.html +20 -20
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/accessibility.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/accessibility.js.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.js.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js.map +1 -1
- package/dist/apps/design-system-dashboard/server.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/server.js +2 -1
- package/dist/apps/design-system-dashboard/server.js.map +1 -1
- package/dist/core/annotation-tools.d.ts.map +1 -1
- package/dist/core/annotation-tools.js +7 -6
- package/dist/core/annotation-tools.js.map +1 -1
- package/dist/core/cache-invalidation.d.ts +18 -2
- package/dist/core/cache-invalidation.d.ts.map +1 -1
- package/dist/core/cache-invalidation.js +51 -0
- package/dist/core/cache-invalidation.js.map +1 -1
- package/dist/core/call-context.d.ts +13 -0
- package/dist/core/call-context.d.ts.map +1 -0
- package/dist/core/call-context.js +20 -0
- package/dist/core/call-context.js.map +1 -0
- package/dist/core/comment-tools.d.ts.map +1 -1
- package/dist/core/comment-tools.js +4 -3
- package/dist/core/comment-tools.js.map +1 -1
- package/dist/core/deep-component-tools.d.ts.map +1 -1
- package/dist/core/deep-component-tools.js +5 -4
- package/dist/core/deep-component-tools.js.map +1 -1
- package/dist/core/design-code-tools.d.ts.map +1 -1
- package/dist/core/design-code-tools.js +4 -3
- package/dist/core/design-code-tools.js.map +1 -1
- package/dist/core/design-system-manifest.d.ts +7 -3
- package/dist/core/design-system-manifest.d.ts.map +1 -1
- package/dist/core/design-system-manifest.js +14 -5
- package/dist/core/design-system-manifest.js.map +1 -1
- package/dist/core/design-system-tools.d.ts.map +1 -1
- package/dist/core/design-system-tools.js +2 -1
- package/dist/core/design-system-tools.js.map +1 -1
- package/dist/core/diagnose-tool.d.ts +2 -0
- package/dist/core/diagnose-tool.d.ts.map +1 -1
- package/dist/core/diagnose-tool.js +6 -5
- package/dist/core/diagnose-tool.js.map +1 -1
- package/dist/core/figjam-tools.d.ts.map +1 -1
- package/dist/core/figjam-tools.js +5 -4
- package/dist/core/figjam-tools.js.map +1 -1
- package/dist/core/figma-api.d.ts +12 -0
- package/dist/core/figma-api.d.ts.map +1 -1
- package/dist/core/figma-api.js +17 -1
- package/dist/core/figma-api.js.map +1 -1
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +42 -53
- package/dist/core/figma-tools.js.map +1 -1
- package/dist/core/library-tools.d.ts.map +1 -1
- package/dist/core/library-tools.js +7 -6
- package/dist/core/library-tools.js.map +1 -1
- package/dist/core/logger.d.ts +11 -0
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +13 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/plugin-import-dir.d.ts +9 -0
- package/dist/core/plugin-import-dir.d.ts.map +1 -0
- package/dist/core/plugin-import-dir.js +47 -0
- package/dist/core/plugin-import-dir.js.map +1 -0
- package/dist/core/plugin-name.d.ts +26 -0
- package/dist/core/plugin-name.d.ts.map +1 -0
- package/dist/core/plugin-name.js +35 -0
- package/dist/core/plugin-name.js.map +1 -0
- package/dist/core/port-discovery.d.ts +2 -2
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +8 -6
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/slides-tools.d.ts.map +1 -1
- package/dist/core/slides-tools.js +2 -1
- package/dist/core/slides-tools.js.map +1 -1
- package/dist/core/slot-tools.d.ts.map +1 -1
- package/dist/core/slot-tools.js +3 -2
- package/dist/core/slot-tools.js.map +1 -1
- package/dist/core/tokens/schemas.d.ts +1 -1
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +2 -1
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/core/variable-resolver.d.ts.map +1 -1
- package/dist/core/variable-resolver.js +3 -2
- package/dist/core/variable-resolver.js.map +1 -1
- package/dist/core/version-tools.d.ts.map +1 -1
- package/dist/core/version-tools.js +9 -8
- package/dist/core/version-tools.js.map +1 -1
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-connector.js +3 -2
- package/dist/core/websocket-connector.js.map +1 -1
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +8 -5
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +283 -232
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +114 -190
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/README.md +15 -63
- package/figma-desktop-bridge/code.js +31 -29
- package/figma-desktop-bridge/manifest.json +5 -9
- package/figma-desktop-bridge/ui.html +768 -924
- package/package.json +1 -1
package/dist/core/write-tools.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PLUGIN_NAME, PLUGIN_NAME_WITH_OLD } from "./plugin-name.js";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { createChildLogger } from "./logger.js";
|
|
3
4
|
const logger = createChildLogger({ component: "write-tools" });
|
|
@@ -10,7 +11,7 @@ const fileKeyArg = z
|
|
|
10
11
|
.string()
|
|
11
12
|
.optional()
|
|
12
13
|
.describe("Run in this file (its fileKey, as figma_list_open_files reports it) instead of the active file. " +
|
|
13
|
-
"Fails if
|
|
14
|
+
"Fails if the " + PLUGIN_NAME + " plugin is not connected in that file; never falls back to the active file. " +
|
|
14
15
|
"Ignores the active file and the target lock. Leave it out to use the active file.");
|
|
15
16
|
/**
|
|
16
17
|
* Figma's own alias value ({ type: 'VARIABLE_ALIAS', id }), accepted wherever a
|
|
@@ -74,7 +75,7 @@ export function registerWriteTools(server, getDesktopConnector, options) {
|
|
|
74
75
|
// EXECUTION TOOL
|
|
75
76
|
// ============================================================================
|
|
76
77
|
server.registerTool("figma_execute", {
|
|
77
|
-
description: `Execute arbitrary JavaScript in Figma's plugin context with full access to the figma API. Use for complex operations not covered by other tools. Requires
|
|
78
|
+
description: `Execute arbitrary JavaScript in Figma's plugin context with full access to the figma API. Use for complex operations not covered by other tools. Requires the ${PLUGIN_NAME} plugin. CAUTION: Can modify your document.
|
|
78
79
|
|
|
79
80
|
**COMPONENT INSTANCES:** For instances (node.type === 'INSTANCE'), use figma_set_instance_properties — direct text editing FAILS SILENTLY. Check instance.componentProperties for available props (may have #nodeId suffixes).
|
|
80
81
|
|
|
@@ -139,7 +140,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
139
140
|
text: JSON.stringify({
|
|
140
141
|
error: error instanceof Error ? error.message : String(error),
|
|
141
142
|
message: "Failed to execute code in Figma plugin context",
|
|
142
|
-
hint: "Make sure the
|
|
143
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in Figma",
|
|
143
144
|
}),
|
|
144
145
|
},
|
|
145
146
|
],
|
|
@@ -152,7 +153,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
152
153
|
// ============================================================================
|
|
153
154
|
// Tool: Update a variable's value
|
|
154
155
|
server.registerTool("figma_update_variable", {
|
|
155
|
-
description: "Update a single variable's value and/or its description. Pass modeId+value to change the value in a mode; pass description to set the 'How to use this variable' text shown in the Variables panel (and exported as DTCG $description). At least one of {modeId+value} or {description} is required. For many value updates at once, use figma_batch_update_variables (10-50x faster). Use figma_get_variables first for IDs. COLOR: hex '#FF0000', FLOAT: number, STRING: text, BOOLEAN: true/false. Requires
|
|
156
|
+
description: "Update a single variable's value and/or its description. Pass modeId+value to change the value in a mode; pass description to set the 'How to use this variable' text shown in the Variables panel (and exported as DTCG $description). At least one of {modeId+value} or {description} is required. For many value updates at once, use figma_batch_update_variables (10-50x faster). Use figma_get_variables first for IDs. COLOR: hex '#FF0000', FLOAT: number, STRING: text, BOOLEAN: true/false. Requires the " + PLUGIN_NAME + " plugin.",
|
|
156
157
|
inputSchema: z.object({
|
|
157
158
|
variableId: z
|
|
158
159
|
.string()
|
|
@@ -229,7 +230,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
229
230
|
text: JSON.stringify({
|
|
230
231
|
error: error instanceof Error ? error.message : String(error),
|
|
231
232
|
message: "Failed to update variable",
|
|
232
|
-
hint: "Make sure the
|
|
233
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the variable ID is correct",
|
|
233
234
|
}),
|
|
234
235
|
},
|
|
235
236
|
],
|
|
@@ -239,7 +240,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
239
240
|
});
|
|
240
241
|
// Tool: Create a new variable
|
|
241
242
|
server.registerTool("figma_create_variable", {
|
|
242
|
-
description: "Create a single Figma variable. For multiple variables, use figma_batch_create_variables instead (10-50x faster). Use figma_get_variables first to get collection IDs. Supports COLOR, FLOAT, STRING, BOOLEAN. Requires
|
|
243
|
+
description: "Create a single Figma variable. For multiple variables, use figma_batch_create_variables instead (10-50x faster). Use figma_get_variables first to get collection IDs. Supports COLOR, FLOAT, STRING, BOOLEAN. Requires the " + PLUGIN_NAME + " plugin.",
|
|
243
244
|
inputSchema: z.object({
|
|
244
245
|
name: z
|
|
245
246
|
.string()
|
|
@@ -295,7 +296,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
295
296
|
text: JSON.stringify({
|
|
296
297
|
error: error instanceof Error ? error.message : String(error),
|
|
297
298
|
message: "Failed to create variable",
|
|
298
|
-
hint: "Make sure the
|
|
299
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the collection ID is correct",
|
|
299
300
|
}),
|
|
300
301
|
},
|
|
301
302
|
],
|
|
@@ -305,7 +306,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
305
306
|
});
|
|
306
307
|
// Tool: Create a new variable collection
|
|
307
308
|
server.registerTool("figma_create_variable_collection", {
|
|
308
|
-
description: "Create an empty variable collection. To create a collection WITH variables and modes in one step, use figma_setup_design_tokens instead. Requires
|
|
309
|
+
description: "Create an empty variable collection. To create a collection WITH variables and modes in one step, use figma_setup_design_tokens instead. Requires the " + PLUGIN_NAME + " plugin.",
|
|
309
310
|
inputSchema: z.object({
|
|
310
311
|
name: z
|
|
311
312
|
.string()
|
|
@@ -354,7 +355,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
354
355
|
text: JSON.stringify({
|
|
355
356
|
error: error instanceof Error ? error.message : String(error),
|
|
356
357
|
message: "Failed to create variable collection",
|
|
357
|
-
hint: "Make sure the
|
|
358
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in Figma",
|
|
358
359
|
}),
|
|
359
360
|
},
|
|
360
361
|
],
|
|
@@ -364,7 +365,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
364
365
|
});
|
|
365
366
|
// Tool: Delete a variable
|
|
366
367
|
server.registerTool("figma_delete_variable", {
|
|
367
|
-
description: "Delete a Figma variable. WARNING: This is a destructive operation that cannot be undone (except with Figma's undo). Use figma_get_variables first to get variable IDs. Requires the
|
|
368
|
+
description: "Delete a Figma variable. WARNING: This is a destructive operation that cannot be undone (except with Figma's undo). Use figma_get_variables first to get variable IDs. Requires the " + PLUGIN_NAME + " plugin to be running.",
|
|
368
369
|
inputSchema: z.object({
|
|
369
370
|
variableId: z
|
|
370
371
|
.string()
|
|
@@ -403,7 +404,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
403
404
|
text: JSON.stringify({
|
|
404
405
|
error: error instanceof Error ? error.message : String(error),
|
|
405
406
|
message: "Failed to delete variable",
|
|
406
|
-
hint: "Make sure the
|
|
407
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the variable ID is correct",
|
|
407
408
|
}),
|
|
408
409
|
},
|
|
409
410
|
],
|
|
@@ -413,7 +414,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
413
414
|
});
|
|
414
415
|
// Tool: Delete a variable collection
|
|
415
416
|
server.registerTool("figma_delete_variable_collection", {
|
|
416
|
-
description: "Delete a Figma variable collection and ALL its variables. WARNING: This is a destructive operation that deletes all variables in the collection and cannot be undone (except with Figma's undo). Requires the
|
|
417
|
+
description: "Delete a Figma variable collection and ALL its variables. WARNING: This is a destructive operation that deletes all variables in the collection and cannot be undone (except with Figma's undo). Requires the " + PLUGIN_NAME + " plugin to be running.",
|
|
417
418
|
inputSchema: z.object({
|
|
418
419
|
collectionId: z
|
|
419
420
|
.string()
|
|
@@ -452,7 +453,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
452
453
|
text: JSON.stringify({
|
|
453
454
|
error: error instanceof Error ? error.message : String(error),
|
|
454
455
|
message: "Failed to delete variable collection",
|
|
455
|
-
hint: "Make sure the
|
|
456
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the collection ID is correct",
|
|
456
457
|
}),
|
|
457
458
|
},
|
|
458
459
|
],
|
|
@@ -462,7 +463,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
462
463
|
});
|
|
463
464
|
// Tool: Rename a variable
|
|
464
465
|
server.registerTool("figma_rename_variable", {
|
|
465
|
-
description: "Rename an existing Figma variable. This updates the variable's name while preserving all its values and settings. Requires the
|
|
466
|
+
description: "Rename an existing Figma variable. This updates the variable's name while preserving all its values and settings. Requires the " + PLUGIN_NAME + " plugin to be running.",
|
|
466
467
|
inputSchema: z.object({
|
|
467
468
|
variableId: z
|
|
468
469
|
.string()
|
|
@@ -504,7 +505,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
504
505
|
text: JSON.stringify({
|
|
505
506
|
error: error instanceof Error ? error.message : String(error),
|
|
506
507
|
message: "Failed to rename variable",
|
|
507
|
-
hint: "Make sure the
|
|
508
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the variable ID is correct",
|
|
508
509
|
}),
|
|
509
510
|
},
|
|
510
511
|
],
|
|
@@ -514,7 +515,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
514
515
|
});
|
|
515
516
|
// Tool: Add a mode to a collection
|
|
516
517
|
server.registerTool("figma_add_mode", {
|
|
517
|
-
description: "Add a new mode to an existing Figma variable collection. Modes allow variables to have different values for different contexts (e.g., Light/Dark themes, device sizes). Requires the
|
|
518
|
+
description: "Add a new mode to an existing Figma variable collection. Modes allow variables to have different values for different contexts (e.g., Light/Dark themes, device sizes). Requires the " + PLUGIN_NAME + " plugin to be running.",
|
|
518
519
|
inputSchema: z.object({
|
|
519
520
|
collectionId: z
|
|
520
521
|
.string()
|
|
@@ -558,7 +559,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
558
559
|
text: JSON.stringify({
|
|
559
560
|
error: error instanceof Error ? error.message : String(error),
|
|
560
561
|
message: "Failed to add mode to collection",
|
|
561
|
-
hint: "Make sure the
|
|
562
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running, the collection ID is correct, and you haven't exceeded Figma's mode limit",
|
|
562
563
|
}),
|
|
563
564
|
},
|
|
564
565
|
],
|
|
@@ -568,7 +569,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
568
569
|
});
|
|
569
570
|
// Tool: Rename a mode in a collection
|
|
570
571
|
server.registerTool("figma_rename_mode", {
|
|
571
|
-
description: "Rename an existing mode in a Figma variable collection. Requires the
|
|
572
|
+
description: "Rename an existing mode in a Figma variable collection. Requires the " + PLUGIN_NAME + " plugin to be running.",
|
|
572
573
|
inputSchema: z.object({
|
|
573
574
|
collectionId: z
|
|
574
575
|
.string()
|
|
@@ -613,7 +614,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
613
614
|
text: JSON.stringify({
|
|
614
615
|
error: error instanceof Error ? error.message : String(error),
|
|
615
616
|
message: "Failed to rename mode",
|
|
616
|
-
hint: "Make sure the
|
|
617
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running, the collection ID and mode ID are correct",
|
|
617
618
|
}),
|
|
618
619
|
},
|
|
619
620
|
],
|
|
@@ -629,7 +630,7 @@ Layers: If your code creates helper frames, placeholder nodes, or intermediate l
|
|
|
629
630
|
// Use these instead of calling individual tools repeatedly.
|
|
630
631
|
// Tool: Batch create variables
|
|
631
632
|
server.registerTool("figma_batch_create_variables", {
|
|
632
|
-
description: "Create multiple variables in one operation. Use instead of calling figma_create_variable repeatedly — up to 50x faster for bulk operations. Get collection IDs from figma_get_variables first. Requires
|
|
633
|
+
description: "Create multiple variables in one operation. Use instead of calling figma_create_variable repeatedly — up to 50x faster for bulk operations. Get collection IDs from figma_get_variables first. Requires the " + PLUGIN_NAME + " plugin.",
|
|
633
634
|
inputSchema: z.object({
|
|
634
635
|
collectionId: z
|
|
635
636
|
.string()
|
|
@@ -710,7 +711,7 @@ return {
|
|
|
710
711
|
text: JSON.stringify({
|
|
711
712
|
error: result.error,
|
|
712
713
|
message: "Batch create failed during execution",
|
|
713
|
-
hint: "Check that the collection ID is valid and the
|
|
714
|
+
hint: "Check that the collection ID is valid and the " + PLUGIN_NAME_WITH_OLD + " plugin is running",
|
|
714
715
|
}),
|
|
715
716
|
},
|
|
716
717
|
],
|
|
@@ -743,7 +744,7 @@ return {
|
|
|
743
744
|
? error.message
|
|
744
745
|
: String(error),
|
|
745
746
|
message: "Failed to batch create variables",
|
|
746
|
-
hint: "Make sure the
|
|
747
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and the collection ID is correct",
|
|
747
748
|
}),
|
|
748
749
|
},
|
|
749
750
|
],
|
|
@@ -753,7 +754,7 @@ return {
|
|
|
753
754
|
});
|
|
754
755
|
// Tool: Batch update variables
|
|
755
756
|
server.registerTool("figma_batch_update_variables", {
|
|
756
|
-
description: "Update multiple variable values in one operation. Use instead of calling figma_update_variable repeatedly — up to 50x faster for bulk updates. Get variable/mode IDs from figma_get_variables first. Requires
|
|
757
|
+
description: "Update multiple variable values in one operation. Use instead of calling figma_update_variable repeatedly — up to 50x faster for bulk updates. Get variable/mode IDs from figma_get_variables first. Requires the " + PLUGIN_NAME + " plugin.",
|
|
757
758
|
inputSchema: z.object({
|
|
758
759
|
updates: z
|
|
759
760
|
.array(z.object({
|
|
@@ -847,7 +848,7 @@ return {
|
|
|
847
848
|
? error.message
|
|
848
849
|
: String(error),
|
|
849
850
|
message: "Failed to batch update variables",
|
|
850
|
-
hint: "Make sure the
|
|
851
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and variable/mode IDs are correct",
|
|
851
852
|
}),
|
|
852
853
|
},
|
|
853
854
|
],
|
|
@@ -857,7 +858,7 @@ return {
|
|
|
857
858
|
});
|
|
858
859
|
// Tool: Setup design tokens (collection + modes + variables atomically)
|
|
859
860
|
server.registerTool("figma_setup_design_tokens", {
|
|
860
|
-
description: "Create a complete design token structure in one operation: collection, modes, and all variables. Ideal for importing CSS custom properties or design tokens into Figma. Values may be literals OR DTCG-style brace references ('{color.blue.600}', or set-qualified '{primitives.color.blue.600}') that resolve to variable ALIASES — first against variables created in this same call, then against existing local variables. Unresolvable references skip that value with a per-item warning (the rest of the batch still applies), so semantic collections referencing primitives no longer need raw figma_execute. Requires
|
|
861
|
+
description: "Create a complete design token structure in one operation: collection, modes, and all variables. Ideal for importing CSS custom properties or design tokens into Figma. Values may be literals OR DTCG-style brace references ('{color.blue.600}', or set-qualified '{primitives.color.blue.600}') that resolve to variable ALIASES — first against variables created in this same call, then against existing local variables. Unresolvable references skip that value with a per-item warning (the rest of the batch still applies), so semantic collections referencing primitives no longer need raw figma_execute. Requires the " + PLUGIN_NAME + " plugin.",
|
|
861
862
|
inputSchema: z.object({
|
|
862
863
|
collectionName: z
|
|
863
864
|
.string()
|
|
@@ -1071,7 +1072,7 @@ return {
|
|
|
1071
1072
|
text: JSON.stringify({
|
|
1072
1073
|
error: result.error,
|
|
1073
1074
|
message: "Design token setup failed during execution",
|
|
1074
|
-
hint: "Check the token definitions and ensure the
|
|
1075
|
+
hint: "Check the token definitions and ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is running",
|
|
1075
1076
|
}),
|
|
1076
1077
|
},
|
|
1077
1078
|
],
|
|
@@ -1132,7 +1133,7 @@ return {
|
|
|
1132
1133
|
? error.message
|
|
1133
1134
|
: String(error),
|
|
1134
1135
|
message: "Failed to setup design tokens",
|
|
1135
|
-
hint: "Make sure the
|
|
1136
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in Figma",
|
|
1136
1137
|
}),
|
|
1137
1138
|
},
|
|
1138
1139
|
],
|
|
@@ -1229,7 +1230,7 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1229
1230
|
text: JSON.stringify({
|
|
1230
1231
|
error: error instanceof Error ? error.message : String(error),
|
|
1231
1232
|
message: "Failed to instantiate component",
|
|
1232
|
-
hint: "Make sure the component key is correct and the
|
|
1233
|
+
hint: "Make sure the component key is correct and the " + PLUGIN_NAME_WITH_OLD + " plugin is running",
|
|
1233
1234
|
}),
|
|
1234
1235
|
},
|
|
1235
1236
|
],
|
|
@@ -1643,7 +1644,7 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
1643
1644
|
server.registerTool("figma_set_image_fill", {
|
|
1644
1645
|
description: "Set an image fill on one or more Figma nodes. The imageData parameter accepts a base64-encoded " +
|
|
1645
1646
|
"image string (JPEG/PNG). The image is decoded in the browser bridge and passed " +
|
|
1646
|
-
"as raw bytes to the Figma plugin. Requires
|
|
1647
|
+
"as raw bytes to the Figma plugin. Requires the " + PLUGIN_NAME + " plugin.",
|
|
1647
1648
|
inputSchema: z.object({
|
|
1648
1649
|
nodeIds: z.array(z.string()).describe("Array of node IDs to apply the image fill to"),
|
|
1649
1650
|
imageData: z.string().describe("Base64-encoded image data (JPEG/PNG)"),
|
|
@@ -2003,6 +2004,7 @@ After instantiating components, use figma_take_screenshot to verify the result l
|
|
|
2003
2004
|
const buildArrangeComponentSetCode = (componentSetId, componentSetName, options,
|
|
2004
2005
|
// figma_create_component_set sets it: its new set has no container of its own
|
|
2005
2006
|
{ freshSet = false } = {}) => `
|
|
2007
|
+
// Arrange component set
|
|
2006
2008
|
// ============================================================================
|
|
2007
2009
|
// COMPONENT SET ARRANGEMENT WITH PROPER LABELS AND CONTAINER
|
|
2008
2010
|
// Creates: White container frame -> Row labels (left) -> Column headers (top) -> Component set (center)
|
|
@@ -2299,211 +2301,251 @@ componentSet.resize(csWidth, csHeight);
|
|
|
2299
2301
|
// STEP 4: Create white container frame with proper structure
|
|
2300
2302
|
// ============================================================================
|
|
2301
2303
|
|
|
2302
|
-
//
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
containerFrame.paddingRight = CONTAINER_PADDING;
|
|
2312
|
-
containerFrame.paddingBottom = CONTAINER_PADDING;
|
|
2313
|
-
containerFrame.paddingLeft = CONTAINER_PADDING;
|
|
2314
|
-
containerFrame.itemSpacing = 24;
|
|
2315
|
-
|
|
2316
|
-
// Add title
|
|
2317
|
-
const titleText = figma.createText();
|
|
2318
|
-
titleText.name = "Title";
|
|
2319
|
-
titleText.characters = csOriginalName;
|
|
2320
|
-
titleText.fontSize = TITLE_FONT_SIZE;
|
|
2321
|
-
titleText.fontName = { family: "Inter", style: "Semi Bold" };
|
|
2322
|
-
titleText.fills = [{ type: 'SOLID', color: TITLE_COLOR }];
|
|
2323
|
-
// Append to parent FIRST, then set layoutSizing
|
|
2324
|
-
containerFrame.appendChild(titleText);
|
|
2325
|
-
titleText.layoutSizingHorizontal = 'HUG';
|
|
2326
|
-
titleText.layoutSizingVertical = 'HUG';
|
|
2327
|
-
|
|
2328
|
-
// Create content row (horizontal: row labels + grid column)
|
|
2329
|
-
const contentRow = figma.createFrame();
|
|
2330
|
-
contentRow.name = "Content Row";
|
|
2331
|
-
contentRow.fills = []; // Transparent
|
|
2332
|
-
contentRow.layoutMode = 'HORIZONTAL';
|
|
2333
|
-
contentRow.primaryAxisSizingMode = 'AUTO';
|
|
2334
|
-
contentRow.counterAxisSizingMode = 'AUTO';
|
|
2335
|
-
contentRow.itemSpacing = LABEL_GAP;
|
|
2336
|
-
contentRow.counterAxisAlignItems = 'MIN'; // Align to top
|
|
2337
|
-
containerFrame.appendChild(contentRow);
|
|
2338
|
-
|
|
2339
|
-
// ============================================================================
|
|
2340
|
-
// STEP 5: Create row labels column (left side)
|
|
2341
|
-
// ============================================================================
|
|
2342
|
-
const rowLabelsFrame = figma.createFrame();
|
|
2343
|
-
rowLabelsFrame.name = "Row Labels";
|
|
2344
|
-
rowLabelsFrame.fills = []; // Transparent
|
|
2345
|
-
rowLabelsFrame.layoutMode = 'VERTICAL';
|
|
2346
|
-
rowLabelsFrame.primaryAxisSizingMode = 'AUTO';
|
|
2347
|
-
rowLabelsFrame.counterAxisSizingMode = 'AUTO';
|
|
2348
|
-
rowLabelsFrame.counterAxisAlignItems = 'MAX'; // Right-align text
|
|
2349
|
-
rowLabelsFrame.itemSpacing = 0; // No spacing - we'll use fixed heights
|
|
2350
|
-
|
|
2351
|
-
// Add spacer for column headers alignment
|
|
2352
|
-
// Must account for: column header height + gap + component set's internal edgePadding
|
|
2353
|
-
const rowLabelSpacer = figma.createFrame();
|
|
2354
|
-
rowLabelSpacer.name = "Spacer";
|
|
2355
|
-
rowLabelSpacer.fills = [];
|
|
2356
|
-
rowLabelSpacer.resize(10, COLUMN_HEADER_HEIGHT + gap + edgePadding); // Align with first row inside component set
|
|
2357
|
-
rowLabelsFrame.appendChild(rowLabelSpacer);
|
|
2358
|
-
// IMPORTANT: Set layoutSizing AFTER appendChild (node must be in auto-layout parent first)
|
|
2359
|
-
rowLabelSpacer.layoutSizingVertical = 'FIXED';
|
|
2360
|
-
|
|
2361
|
-
// Create row labels - each with VERTICAL layout for direct vertical centering
|
|
2362
|
-
// Using VERTICAL layout: primaryAxis = vertical, counterAxis = horizontal
|
|
2363
|
-
// So primaryAxisAlignItems = 'CENTER' directly controls vertical centering
|
|
2364
|
-
for (let i = 0; i < rowCombinations.length; i++) {
|
|
2365
|
-
const combo = rowCombinations[i];
|
|
2366
|
-
const labelText = rowProps.map(p => combo[p]).join(" / ");
|
|
2367
|
-
const isLastRow = (i === rowCombinations.length - 1);
|
|
2368
|
-
|
|
2369
|
-
// Create a frame to hold the label with VERTICAL layout
|
|
2370
|
-
const rowLabelContainer = figma.createFrame();
|
|
2371
|
-
rowLabelContainer.name = "Row: " + labelText;
|
|
2372
|
-
rowLabelContainer.fills = [];
|
|
2373
|
-
rowLabelContainer.layoutMode = 'VERTICAL'; // VERTICAL so primaryAxis controls Y
|
|
2374
|
-
rowLabelContainer.primaryAxisSizingMode = 'FIXED'; // CRITICAL: Don't hug content, maintain fixed height
|
|
2375
|
-
rowLabelContainer.primaryAxisAlignItems = 'CENTER'; // CENTER = vertically centered within fixed height
|
|
2376
|
-
rowLabelContainer.counterAxisAlignItems = 'MAX'; // MAX = right-aligned horizontally
|
|
2377
|
-
|
|
2378
|
-
// Fixed height = cellHeight only (gap handled separately below)
|
|
2379
|
-
rowLabelContainer.resize(10, cellHeight);
|
|
2380
|
-
|
|
2381
|
-
const label = figma.createText();
|
|
2382
|
-
label.characters = labelText;
|
|
2383
|
-
label.fontSize = LABEL_FONT_SIZE;
|
|
2384
|
-
label.fontName = { family: "Inter", style: "Regular" };
|
|
2385
|
-
label.fills = [{ type: 'SOLID', color: LABEL_COLOR }];
|
|
2386
|
-
label.textAlignHorizontal = 'RIGHT';
|
|
2387
|
-
rowLabelContainer.appendChild(label);
|
|
2388
|
-
|
|
2389
|
-
// Append to parent FIRST, then set layoutSizing properties
|
|
2390
|
-
rowLabelsFrame.appendChild(rowLabelContainer);
|
|
2391
|
-
rowLabelContainer.layoutSizingHorizontal = 'HUG';
|
|
2392
|
-
rowLabelContainer.layoutSizingVertical = 'FIXED';
|
|
2393
|
-
|
|
2394
|
-
// Add gap spacer AFTER the row label (except for the last row)
|
|
2395
|
-
// This separates the gap from the centering calculation entirely
|
|
2396
|
-
if (!isLastRow) {
|
|
2397
|
-
const gapSpacer = figma.createFrame();
|
|
2398
|
-
gapSpacer.name = "Row Gap";
|
|
2399
|
-
gapSpacer.fills = [];
|
|
2400
|
-
gapSpacer.resize(1, gap);
|
|
2401
|
-
rowLabelsFrame.appendChild(gapSpacer);
|
|
2402
|
-
// Plain frames can only use FIXED or FILL (not HUG)
|
|
2403
|
-
gapSpacer.layoutSizingHorizontal = 'FIXED';
|
|
2404
|
-
gapSpacer.layoutSizingVertical = 'FIXED';
|
|
2405
|
-
}
|
|
2304
|
+
// Everything this run creates is tracked. If anything throws before the set has
|
|
2305
|
+
// moved into its wrapper, those layers are removed again; the component set keeps
|
|
2306
|
+
// the changes earlier steps made to it (layout, stroke, variant positions,
|
|
2307
|
+
// resize). Once the set is in the wrapper nothing is removed, because
|
|
2308
|
+
// removing the container would delete the person's component set.
|
|
2309
|
+
const created = [];
|
|
2310
|
+
function track(node) {
|
|
2311
|
+
created.push(node);
|
|
2312
|
+
return node;
|
|
2406
2313
|
}
|
|
2314
|
+
let containerFrame = null;
|
|
2315
|
+
let componentSetWrapper = null;
|
|
2316
|
+
|
|
2317
|
+
try {
|
|
2318
|
+
// Create the main container frame (white background)
|
|
2319
|
+
containerFrame = track(figma.createFrame());
|
|
2320
|
+
containerFrame.name = "Component Container";
|
|
2321
|
+
containerFrame.fills = [{ type: 'SOLID', color: { r: 1, g: 1, b: 1 } }]; // White
|
|
2322
|
+
containerFrame.cornerRadius = 8;
|
|
2323
|
+
containerFrame.layoutMode = 'VERTICAL';
|
|
2324
|
+
containerFrame.primaryAxisSizingMode = 'AUTO';
|
|
2325
|
+
containerFrame.counterAxisSizingMode = 'AUTO';
|
|
2326
|
+
containerFrame.paddingTop = CONTAINER_PADDING;
|
|
2327
|
+
containerFrame.paddingRight = CONTAINER_PADDING;
|
|
2328
|
+
containerFrame.paddingBottom = CONTAINER_PADDING;
|
|
2329
|
+
containerFrame.paddingLeft = CONTAINER_PADDING;
|
|
2330
|
+
containerFrame.itemSpacing = 24;
|
|
2331
|
+
|
|
2332
|
+
// Add title
|
|
2333
|
+
const titleText = track(figma.createText());
|
|
2334
|
+
titleText.name = "Title";
|
|
2335
|
+
titleText.characters = csOriginalName;
|
|
2336
|
+
titleText.fontSize = TITLE_FONT_SIZE;
|
|
2337
|
+
titleText.fontName = { family: "Inter", style: "Semi Bold" };
|
|
2338
|
+
titleText.fills = [{ type: 'SOLID', color: TITLE_COLOR }];
|
|
2339
|
+
// Append to parent FIRST, then set layoutSizing
|
|
2340
|
+
containerFrame.appendChild(titleText);
|
|
2341
|
+
titleText.layoutSizingHorizontal = 'HUG';
|
|
2342
|
+
titleText.layoutSizingVertical = 'HUG';
|
|
2343
|
+
|
|
2344
|
+
// Create content row (horizontal: row labels + grid column)
|
|
2345
|
+
const contentRow = track(figma.createFrame());
|
|
2346
|
+
contentRow.name = "Content Row";
|
|
2347
|
+
contentRow.fills = []; // Transparent
|
|
2348
|
+
contentRow.layoutMode = 'HORIZONTAL';
|
|
2349
|
+
contentRow.primaryAxisSizingMode = 'AUTO';
|
|
2350
|
+
contentRow.counterAxisSizingMode = 'AUTO';
|
|
2351
|
+
contentRow.itemSpacing = LABEL_GAP;
|
|
2352
|
+
contentRow.counterAxisAlignItems = 'MIN'; // Align to top
|
|
2353
|
+
containerFrame.appendChild(contentRow);
|
|
2354
|
+
|
|
2355
|
+
// ============================================================================
|
|
2356
|
+
// STEP 5: Create row labels column (left side)
|
|
2357
|
+
// ============================================================================
|
|
2358
|
+
const rowLabelsFrame = track(figma.createFrame());
|
|
2359
|
+
rowLabelsFrame.name = "Row Labels";
|
|
2360
|
+
rowLabelsFrame.fills = []; // Transparent
|
|
2361
|
+
rowLabelsFrame.layoutMode = 'VERTICAL';
|
|
2362
|
+
rowLabelsFrame.primaryAxisSizingMode = 'AUTO';
|
|
2363
|
+
rowLabelsFrame.counterAxisSizingMode = 'AUTO';
|
|
2364
|
+
rowLabelsFrame.counterAxisAlignItems = 'MAX'; // Right-align text
|
|
2365
|
+
rowLabelsFrame.itemSpacing = 0; // No spacing - we'll use fixed heights
|
|
2366
|
+
|
|
2367
|
+
// Add spacer for column headers alignment
|
|
2368
|
+
// Must account for: column header height + gap + component set's internal edgePadding
|
|
2369
|
+
const rowLabelSpacer = track(figma.createFrame());
|
|
2370
|
+
rowLabelSpacer.name = "Spacer";
|
|
2371
|
+
rowLabelSpacer.fills = [];
|
|
2372
|
+
rowLabelSpacer.resize(10, COLUMN_HEADER_HEIGHT + gap + edgePadding); // Align with first row inside component set
|
|
2373
|
+
rowLabelsFrame.appendChild(rowLabelSpacer);
|
|
2374
|
+
// IMPORTANT: Set layoutSizing AFTER appendChild (node must be in auto-layout parent first)
|
|
2375
|
+
rowLabelSpacer.layoutSizingVertical = 'FIXED';
|
|
2376
|
+
|
|
2377
|
+
// Create row labels - each with VERTICAL layout for direct vertical centering
|
|
2378
|
+
// Using VERTICAL layout: primaryAxis = vertical, counterAxis = horizontal
|
|
2379
|
+
// So primaryAxisAlignItems = 'CENTER' directly controls vertical centering
|
|
2380
|
+
for (let i = 0; i < rowCombinations.length; i++) {
|
|
2381
|
+
const combo = rowCombinations[i];
|
|
2382
|
+
const labelText = rowProps.map(p => combo[p]).join(" / ");
|
|
2383
|
+
const isLastRow = (i === rowCombinations.length - 1);
|
|
2384
|
+
|
|
2385
|
+
// Create a frame to hold the label with VERTICAL layout
|
|
2386
|
+
const rowLabelContainer = track(figma.createFrame());
|
|
2387
|
+
rowLabelContainer.name = "Row: " + labelText;
|
|
2388
|
+
rowLabelContainer.fills = [];
|
|
2389
|
+
rowLabelContainer.layoutMode = 'VERTICAL'; // VERTICAL so primaryAxis controls Y
|
|
2390
|
+
rowLabelContainer.primaryAxisSizingMode = 'FIXED'; // CRITICAL: Don't hug content, maintain fixed height
|
|
2391
|
+
rowLabelContainer.primaryAxisAlignItems = 'CENTER'; // CENTER = vertically centered within fixed height
|
|
2392
|
+
rowLabelContainer.counterAxisAlignItems = 'MAX'; // MAX = right-aligned horizontally
|
|
2393
|
+
|
|
2394
|
+
// Fixed height = cellHeight only (gap handled separately below)
|
|
2395
|
+
rowLabelContainer.resize(10, cellHeight);
|
|
2396
|
+
|
|
2397
|
+
const label = track(figma.createText());
|
|
2398
|
+
label.characters = labelText;
|
|
2399
|
+
label.fontSize = LABEL_FONT_SIZE;
|
|
2400
|
+
label.fontName = { family: "Inter", style: "Regular" };
|
|
2401
|
+
label.fills = [{ type: 'SOLID', color: LABEL_COLOR }];
|
|
2402
|
+
label.textAlignHorizontal = 'RIGHT';
|
|
2403
|
+
rowLabelContainer.appendChild(label);
|
|
2404
|
+
|
|
2405
|
+
// Append to parent FIRST, then set layoutSizing properties
|
|
2406
|
+
rowLabelsFrame.appendChild(rowLabelContainer);
|
|
2407
|
+
rowLabelContainer.layoutSizingHorizontal = 'HUG';
|
|
2408
|
+
rowLabelContainer.layoutSizingVertical = 'FIXED';
|
|
2409
|
+
|
|
2410
|
+
// Add gap spacer AFTER the row label (except for the last row)
|
|
2411
|
+
// This separates the gap from the centering calculation entirely
|
|
2412
|
+
if (!isLastRow) {
|
|
2413
|
+
const gapSpacer = track(figma.createFrame());
|
|
2414
|
+
gapSpacer.name = "Row Gap";
|
|
2415
|
+
gapSpacer.fills = [];
|
|
2416
|
+
gapSpacer.resize(1, gap);
|
|
2417
|
+
rowLabelsFrame.appendChild(gapSpacer);
|
|
2418
|
+
// Plain frames can only use FIXED or FILL (not HUG)
|
|
2419
|
+
gapSpacer.layoutSizingHorizontal = 'FIXED';
|
|
2420
|
+
gapSpacer.layoutSizingVertical = 'FIXED';
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2407
2423
|
|
|
2408
|
-
contentRow.appendChild(rowLabelsFrame);
|
|
2424
|
+
contentRow.appendChild(rowLabelsFrame);
|
|
2425
|
+
|
|
2426
|
+
// ============================================================================
|
|
2427
|
+
// STEP 6: Create grid column (column headers + component set)
|
|
2428
|
+
// ============================================================================
|
|
2429
|
+
const gridColumn = track(figma.createFrame());
|
|
2430
|
+
gridColumn.name = "Grid Column";
|
|
2431
|
+
gridColumn.fills = []; // Transparent
|
|
2432
|
+
gridColumn.layoutMode = 'VERTICAL';
|
|
2433
|
+
gridColumn.primaryAxisSizingMode = 'AUTO';
|
|
2434
|
+
gridColumn.counterAxisSizingMode = 'AUTO';
|
|
2435
|
+
gridColumn.itemSpacing = gap;
|
|
2436
|
+
|
|
2437
|
+
// Create column headers row
|
|
2438
|
+
const columnHeadersRow = track(figma.createFrame());
|
|
2439
|
+
columnHeadersRow.name = "Column Headers";
|
|
2440
|
+
columnHeadersRow.fills = [];
|
|
2441
|
+
columnHeadersRow.layoutMode = 'HORIZONTAL';
|
|
2442
|
+
columnHeadersRow.resize(csWidth, COLUMN_HEADER_HEIGHT);
|
|
2443
|
+
columnHeadersRow.itemSpacing = 0; // No spacing - we control widths precisely
|
|
2444
|
+
columnHeadersRow.paddingLeft = edgePadding; // Match component set edge padding
|
|
2445
|
+
columnHeadersRow.paddingRight = edgePadding;
|
|
2446
|
+
|
|
2447
|
+
// Create column header labels - each with width matching cell + gap
|
|
2448
|
+
for (let i = 0; i < columnValues.length; i++) {
|
|
2449
|
+
const colValue = columnValues[i];
|
|
2450
|
+
const isLastCol = (i === columnValues.length - 1);
|
|
2451
|
+
|
|
2452
|
+
const colHeaderContainer = track(figma.createFrame());
|
|
2453
|
+
colHeaderContainer.name = "Col: " + colValue;
|
|
2454
|
+
colHeaderContainer.fills = [];
|
|
2455
|
+
colHeaderContainer.layoutMode = 'HORIZONTAL';
|
|
2456
|
+
colHeaderContainer.primaryAxisAlignItems = 'CENTER'; // Center horizontally
|
|
2457
|
+
colHeaderContainer.counterAxisAlignItems = 'MAX'; // Align to bottom
|
|
2458
|
+
|
|
2459
|
+
// Set width to match cell + gap (except last column)
|
|
2460
|
+
// Use paddingRight to push the gap to the RIGHT of the centered text area
|
|
2461
|
+
const colWidth = isLastCol ? cellWidth : cellWidth + gap;
|
|
2462
|
+
colHeaderContainer.resize(colWidth, COLUMN_HEADER_HEIGHT);
|
|
2463
|
+
if (!isLastCol) {
|
|
2464
|
+
colHeaderContainer.paddingRight = gap; // Gap goes right, text centers in cellWidth
|
|
2465
|
+
}
|
|
2409
2466
|
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
const columnHeadersRow = figma.createFrame();
|
|
2423
|
-
columnHeadersRow.name = "Column Headers";
|
|
2424
|
-
columnHeadersRow.fills = [];
|
|
2425
|
-
columnHeadersRow.layoutMode = 'HORIZONTAL';
|
|
2426
|
-
columnHeadersRow.resize(csWidth, COLUMN_HEADER_HEIGHT);
|
|
2427
|
-
columnHeadersRow.itemSpacing = 0; // No spacing - we control widths precisely
|
|
2428
|
-
columnHeadersRow.paddingLeft = edgePadding; // Match component set edge padding
|
|
2429
|
-
columnHeadersRow.paddingRight = edgePadding;
|
|
2430
|
-
|
|
2431
|
-
// Create column header labels - each with width matching cell + gap
|
|
2432
|
-
for (let i = 0; i < columnValues.length; i++) {
|
|
2433
|
-
const colValue = columnValues[i];
|
|
2434
|
-
const isLastCol = (i === columnValues.length - 1);
|
|
2435
|
-
|
|
2436
|
-
const colHeaderContainer = figma.createFrame();
|
|
2437
|
-
colHeaderContainer.name = "Col: " + colValue;
|
|
2438
|
-
colHeaderContainer.fills = [];
|
|
2439
|
-
colHeaderContainer.layoutMode = 'HORIZONTAL';
|
|
2440
|
-
colHeaderContainer.primaryAxisAlignItems = 'CENTER'; // Center horizontally
|
|
2441
|
-
colHeaderContainer.counterAxisAlignItems = 'MAX'; // Align to bottom
|
|
2442
|
-
|
|
2443
|
-
// Set width to match cell + gap (except last column)
|
|
2444
|
-
// Use paddingRight to push the gap to the RIGHT of the centered text area
|
|
2445
|
-
const colWidth = isLastCol ? cellWidth : cellWidth + gap;
|
|
2446
|
-
colHeaderContainer.resize(colWidth, COLUMN_HEADER_HEIGHT);
|
|
2447
|
-
if (!isLastCol) {
|
|
2448
|
-
colHeaderContainer.paddingRight = gap; // Gap goes right, text centers in cellWidth
|
|
2467
|
+
const label = track(figma.createText());
|
|
2468
|
+
label.characters = colValue;
|
|
2469
|
+
label.fontSize = LABEL_FONT_SIZE;
|
|
2470
|
+
label.fontName = { family: "Inter", style: "Regular" };
|
|
2471
|
+
label.fills = [{ type: 'SOLID', color: LABEL_COLOR }];
|
|
2472
|
+
label.textAlignHorizontal = 'CENTER';
|
|
2473
|
+
colHeaderContainer.appendChild(label);
|
|
2474
|
+
|
|
2475
|
+
// Append to parent FIRST, then set layoutSizing
|
|
2476
|
+
columnHeadersRow.appendChild(colHeaderContainer);
|
|
2477
|
+
colHeaderContainer.layoutSizingHorizontal = 'FIXED';
|
|
2478
|
+
colHeaderContainer.layoutSizingVertical = 'FILL';
|
|
2449
2479
|
}
|
|
2450
2480
|
|
|
2451
|
-
const label = figma.createText();
|
|
2452
|
-
label.characters = colValue;
|
|
2453
|
-
label.fontSize = LABEL_FONT_SIZE;
|
|
2454
|
-
label.fontName = { family: "Inter", style: "Regular" };
|
|
2455
|
-
label.fills = [{ type: 'SOLID', color: LABEL_COLOR }];
|
|
2456
|
-
label.textAlignHorizontal = 'CENTER';
|
|
2457
|
-
colHeaderContainer.appendChild(label);
|
|
2458
|
-
|
|
2459
2481
|
// Append to parent FIRST, then set layoutSizing
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
// Append to parent FIRST, then set layoutSizing
|
|
2466
|
-
gridColumn.appendChild(columnHeadersRow);
|
|
2467
|
-
columnHeadersRow.layoutSizingHorizontal = 'FIXED';
|
|
2468
|
-
columnHeadersRow.layoutSizingVertical = 'FIXED';
|
|
2482
|
+
gridColumn.appendChild(columnHeadersRow);
|
|
2483
|
+
columnHeadersRow.layoutSizingHorizontal = 'FIXED';
|
|
2484
|
+
columnHeadersRow.layoutSizingVertical = 'FIXED';
|
|
2469
2485
|
|
|
2470
|
-
// Create a wrapper frame to hold the component set (since component sets don't work well in auto-layout)
|
|
2471
|
-
|
|
2472
|
-
componentSetWrapper.name = "Component Set Wrapper";
|
|
2473
|
-
componentSetWrapper.fills = [];
|
|
2474
|
-
componentSetWrapper.resize(csWidth, csHeight);
|
|
2486
|
+
// Create a wrapper frame to hold the component set (since component sets don't work well in auto-layout)
|
|
2487
|
+
componentSetWrapper = track(figma.createFrame());
|
|
2488
|
+
componentSetWrapper.name = "Component Set Wrapper";
|
|
2489
|
+
componentSetWrapper.fills = [];
|
|
2490
|
+
componentSetWrapper.resize(csWidth, csHeight);
|
|
2475
2491
|
|
|
2476
|
-
// Append to parent FIRST, then set layoutSizing
|
|
2477
|
-
gridColumn.appendChild(componentSetWrapper);
|
|
2478
|
-
componentSetWrapper.layoutSizingHorizontal = 'FIXED';
|
|
2479
|
-
componentSetWrapper.layoutSizingVertical = 'FIXED';
|
|
2480
|
-
|
|
2481
|
-
contentRow.appendChild(gridColumn);
|
|
2492
|
+
// Append to parent FIRST, then set layoutSizing
|
|
2493
|
+
gridColumn.appendChild(componentSetWrapper);
|
|
2494
|
+
componentSetWrapper.layoutSizingHorizontal = 'FIXED';
|
|
2495
|
+
componentSetWrapper.layoutSizingVertical = 'FIXED';
|
|
2496
|
+
|
|
2497
|
+
contentRow.appendChild(gridColumn);
|
|
2498
|
+
|
|
2499
|
+
// ============================================================================
|
|
2500
|
+
// STEP 7: Place the container
|
|
2501
|
+
// On a re-run it goes in the old container's parent, directly above it in the
|
|
2502
|
+
// layer list (children[0] is the bottom layer): it takes the old one's index
|
|
2503
|
+
// and x/y once the old one is removed. Beside a kept container it sits to the
|
|
2504
|
+
// right of the width recorded before the set moved out.
|
|
2505
|
+
// On a first run it goes on the set's own page, at the set's original location.
|
|
2506
|
+
// ============================================================================
|
|
2507
|
+
if (oldContainer) {
|
|
2508
|
+
oldParent.insertChild(oldIndex + 1, containerFrame);
|
|
2509
|
+
containerFrame.x = keptReason ? oldX + oldWidth + KEPT_CONTAINER_GAP : oldX;
|
|
2510
|
+
containerFrame.y = oldY;
|
|
2511
|
+
} else {
|
|
2512
|
+
page.appendChild(containerFrame);
|
|
2513
|
+
containerFrame.x = csAbsX - CONTAINER_PADDING - 120; // Account for row labels width
|
|
2514
|
+
containerFrame.y = csAbsY - CONTAINER_PADDING - TITLE_FONT_SIZE - 24 - COLUMN_HEADER_HEIGHT - gap;
|
|
2515
|
+
}
|
|
2482
2516
|
|
|
2483
|
-
// ============================================================================
|
|
2484
|
-
// STEP
|
|
2485
|
-
//
|
|
2486
|
-
|
|
2487
|
-
//
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2517
|
+
// ============================================================================
|
|
2518
|
+
// STEP 8: Move the set into its wrapper, then remove the old container
|
|
2519
|
+
// ============================================================================
|
|
2520
|
+
|
|
2521
|
+
// Reparenting preserves the node ID — placed instances are unaffected
|
|
2522
|
+
componentSetWrapper.appendChild(componentSet);
|
|
2523
|
+
} catch (e) {
|
|
2524
|
+
if (componentSet.parent !== componentSetWrapper) {
|
|
2525
|
+
let k = 0;
|
|
2526
|
+
let n = 0;
|
|
2527
|
+
for (let i = created.length - 1; i >= 0; i--) {
|
|
2528
|
+
const node = created[i];
|
|
2529
|
+
try {
|
|
2530
|
+
if (!node.removed) {
|
|
2531
|
+
node.remove();
|
|
2532
|
+
k++;
|
|
2533
|
+
}
|
|
2534
|
+
} catch (removeError) {
|
|
2535
|
+
n++;
|
|
2536
|
+
console.warn("arrange cleanup: could not remove a layer this run created", removeError);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
const msg = (e && e.message) ? e.message : String(e);
|
|
2540
|
+
const layers = (count) => count + (count === 1 ? " layer" : " layers");
|
|
2541
|
+
let note = "";
|
|
2542
|
+
if (k > 0) note = "removed the " + layers(k) + " this run created" + (n > 0 ? "; " + n + " could not be removed" : "");
|
|
2543
|
+
else if (n > 0) note = layers(n) + " this run created could not be removed";
|
|
2544
|
+
throw new Error(note ? msg + " (" + note + ")" : msg);
|
|
2545
|
+
}
|
|
2546
|
+
throw e;
|
|
2499
2547
|
}
|
|
2500
2548
|
|
|
2501
|
-
// ============================================================================
|
|
2502
|
-
// STEP 8: Move the set into its wrapper, then remove the old container
|
|
2503
|
-
// ============================================================================
|
|
2504
|
-
|
|
2505
|
-
// Reparenting preserves the node ID — placed instances are unaffected
|
|
2506
|
-
componentSetWrapper.appendChild(componentSet);
|
|
2507
2549
|
componentSet.x = 0;
|
|
2508
2550
|
componentSet.y = 0;
|
|
2509
2551
|
|
|
@@ -2516,9 +2558,18 @@ if (oldContainer && !keptReason) {
|
|
|
2516
2558
|
|
|
2517
2559
|
// Select on the set's own page (each page keeps its own selection); zoom only
|
|
2518
2560
|
// when that page is the one in view
|
|
2519
|
-
|
|
2561
|
+
// The arrange is done; a failure here must not undo or fail it
|
|
2562
|
+
try {
|
|
2563
|
+
page.selection = [containerFrame];
|
|
2564
|
+
} catch (selectError) {
|
|
2565
|
+
console.warn("arrange: could not select the new container", selectError);
|
|
2566
|
+
}
|
|
2520
2567
|
if (onCurrentPage) {
|
|
2521
|
-
|
|
2568
|
+
try {
|
|
2569
|
+
figma.viewport.scrollAndZoomIntoView([containerFrame]);
|
|
2570
|
+
} catch (zoomError) {
|
|
2571
|
+
console.warn("arrange: could not zoom to the new container", zoomError);
|
|
2572
|
+
}
|
|
2522
2573
|
}
|
|
2523
2574
|
|
|
2524
2575
|
return {
|
|
@@ -2617,7 +2668,7 @@ Arranges variants in a labeled grid (columns = last property like State, rows =
|
|
|
2617
2668
|
type: "text",
|
|
2618
2669
|
text: JSON.stringify({
|
|
2619
2670
|
error: error instanceof Error ? error.message : String(error),
|
|
2620
|
-
hint: "Make sure the
|
|
2671
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running and a component set exists.",
|
|
2621
2672
|
}),
|
|
2622
2673
|
},
|
|
2623
2674
|
],
|
|
@@ -2636,7 +2687,7 @@ Two modes:
|
|
|
2636
2687
|
|
|
2637
2688
|
Figma derives the variant property definitions from the names; they live on the SET (componentPropertyDefinitions), not on individual variants. The result includes each variant's key — instantiate with a VARIANT's key/nodeId via figma_instantiate_component, not the set's key.
|
|
2638
2689
|
|
|
2639
|
-
Set autoArrange:true to lay the new set out as a labeled grid inside a white container (same layout as figma_arrange_component_set). Requires
|
|
2690
|
+
Set autoArrange:true to lay the new set out as a labeled grid inside a white container (same layout as figma_arrange_component_set). Requires the ${PLUGIN_NAME} plugin.
|
|
2640
2691
|
|
|
2641
2692
|
SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count (~1.2s/variant, 30s floor / 2min cap), but above ~40 variants the single-pass clone+combine gets slow and heavy base components may still push the limit — prefer splitting large matrices into multiple sets (e.g. one set per Size).`,
|
|
2642
2693
|
inputSchema: z.object({
|
|
@@ -2786,7 +2837,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2786
2837
|
type: "text",
|
|
2787
2838
|
text: JSON.stringify({
|
|
2788
2839
|
error: error instanceof Error ? error.message : String(error),
|
|
2789
|
-
hint: "Make sure the
|
|
2840
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running. baseComponentId/componentIds must reference COMPONENT nodes that are not already inside a component set. Node IDs are session-specific — re-search components if they may be stale.",
|
|
2790
2841
|
}),
|
|
2791
2842
|
},
|
|
2792
2843
|
],
|
|
@@ -2807,7 +2858,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2807
2858
|
"Default audit runs WCAG + design-system + layout (best-practice hints excluded). " +
|
|
2808
2859
|
"Returns categorized findings with severity levels (critical/warning/info) and WCAG conformance level (a/aa/aaa/best-practice) so teams can filter by target level. " +
|
|
2809
2860
|
"Use natural language like 'check my design for accessibility issues' or 'lint this page'. " +
|
|
2810
|
-
"Requires
|
|
2861
|
+
"Requires the " + PLUGIN_NAME + " plugin.",
|
|
2811
2862
|
inputSchema: z.object({
|
|
2812
2863
|
nodeId: z.string().optional().describe("Node ID to lint (defaults to current page)"),
|
|
2813
2864
|
rules: z.array(z.string()).optional().describe("Rule filter. Default (omitted) = ['wcag','design-system','layout'] — real WCAG conformance plus quality checks, with best-practice hints excluded. Groups: ['wcag'] (10 conformance rules), ['best-practice'] (text-size, line-height, letter-spacing, paragraph-spacing), ['all'] (everything incl. best-practice), ['design-system'], ['layout']. Or specific rule IDs like ['wcag-contrast', 'wcag-focus-indicator', 'wcag-disabled-no-context']."),
|
|
@@ -2839,7 +2890,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2839
2890
|
type: "text",
|
|
2840
2891
|
text: JSON.stringify({
|
|
2841
2892
|
error: error instanceof Error ? error.message : String(error),
|
|
2842
|
-
hint: "Make sure the
|
|
2893
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in your Figma file.",
|
|
2843
2894
|
}),
|
|
2844
2895
|
},
|
|
2845
2896
|
],
|
|
@@ -2854,7 +2905,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2854
2905
|
"non-color differentiation (WCAG 1.4.1), target size consistency (WCAG 2.5.8), annotation completeness, " +
|
|
2855
2906
|
"and color-blind simulation (protanopia/deuteranopia/tritanopia). Returns per-category scores (0-100) " +
|
|
2856
2907
|
"and prioritized recommendations. Use after designing a component to validate accessibility before handoff. " +
|
|
2857
|
-
"Requires
|
|
2908
|
+
"Requires the " + PLUGIN_NAME + " plugin.",
|
|
2858
2909
|
inputSchema: z.object({
|
|
2859
2910
|
nodeId: z.string().optional().describe("Node ID of a COMPONENT_SET, COMPONENT, or INSTANCE to audit. Falls back to current selection if omitted."),
|
|
2860
2911
|
targetSize: z.number().optional().describe("Minimum touch target size in px (default: 24 per WCAG 2.5.8). Use 44 for iOS or 48 for Android guidelines."),
|
|
@@ -2884,7 +2935,7 @@ SIZE GUIDANCE: hard cap 100 variants. The timeout auto-scales with variant count
|
|
|
2884
2935
|
type: "text",
|
|
2885
2936
|
text: JSON.stringify({
|
|
2886
2937
|
error: error instanceof Error ? error.message : String(error),
|
|
2887
|
-
hint: "Make sure the
|
|
2938
|
+
hint: "Make sure the " + PLUGIN_NAME_WITH_OLD + " plugin is running. Provide a COMPONENT_SET nodeId or select one in Figma.",
|
|
2888
2939
|
}),
|
|
2889
2940
|
},
|
|
2890
2941
|
],
|