figma-console-mcp 1.40.0 → 1.40.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/README.md +4 -2
- package/dist/cloudflare/core/design-code-tools.js +388 -52
- package/dist/cloudflare/core/design-system-manifest.js +18 -0
- package/dist/cloudflare/core/tokens/schemas.js +2 -2
- package/dist/cloudflare/core/tokens-tools.js +472 -22
- package/dist/cloudflare/index.js +3 -3
- package/dist/core/design-code-tools.d.ts +87 -19
- package/dist/core/design-code-tools.d.ts.map +1 -1
- package/dist/core/design-code-tools.js +388 -52
- package/dist/core/design-code-tools.js.map +1 -1
- package/dist/core/design-system-manifest.d.ts +10 -0
- package/dist/core/design-system-manifest.d.ts.map +1 -1
- package/dist/core/design-system-manifest.js +18 -0
- package/dist/core/design-system-manifest.js.map +1 -1
- package/dist/core/tokens/schemas.js +2 -2
- package/dist/core/tokens/schemas.js.map +1 -1
- package/dist/core/tokens-tools.d.ts +94 -1
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +472 -22
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +27 -2
- package/dist/local.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
7
|
import type { FigmaAPI } from "./figma-api.js";
|
|
8
|
+
import type { EnrichedComponent } from "./types/enriched.js";
|
|
8
9
|
import type { CompanyDocsContentEntry } from "./types/design-code.js";
|
|
9
10
|
export { figmaRGBAToHex, normalizeColor, numericClose } from "./diff/property-compare.js";
|
|
10
11
|
/** Calculate parity score from discrepancy counts */
|
|
@@ -42,32 +43,55 @@ interface ParsedDescription {
|
|
|
42
43
|
* Handles markdown-formatted descriptions with headers, bullet points, etc.
|
|
43
44
|
*/
|
|
44
45
|
export declare function parseComponentDescription(description: string): ParsedDescription;
|
|
46
|
+
/** A single solid color found on a node, with its bound token when there is one */
|
|
47
|
+
interface VariantColorEntry {
|
|
48
|
+
hex: string;
|
|
49
|
+
nodeName: string;
|
|
50
|
+
variableId?: string;
|
|
51
|
+
variableName?: string;
|
|
52
|
+
/** For icon artwork: layer name of the icon instance this color belongs to */
|
|
53
|
+
iconLabel?: string;
|
|
54
|
+
}
|
|
45
55
|
/** Color data collected from a specific variant */
|
|
46
56
|
interface VariantColorData {
|
|
47
57
|
variantName: string;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
nodeName: string;
|
|
63
|
-
variableId?: string;
|
|
64
|
-
variableName?: string;
|
|
65
|
-
}>;
|
|
58
|
+
/**
|
|
59
|
+
* BACKGROUND fills only: the variant root's own fills or, when the root is
|
|
60
|
+
* transparent, a full-bleed background layer (see `backgroundLayer`). Never a
|
|
61
|
+
* descendant's color — an empty array means the variant has no background.
|
|
62
|
+
*/
|
|
63
|
+
fills: VariantColorEntry[];
|
|
64
|
+
/** Layer name the background came from when it isn't the variant root itself */
|
|
65
|
+
backgroundLayer?: string;
|
|
66
|
+
/** Fills on non-text descendants that are neither the background nor part of an icon */
|
|
67
|
+
descendantFills: VariantColorEntry[];
|
|
68
|
+
/** Fills and strokes found inside a detected icon instance */
|
|
69
|
+
iconColors: VariantColorEntry[];
|
|
70
|
+
strokes: VariantColorEntry[];
|
|
71
|
+
textColors: VariantColorEntry[];
|
|
66
72
|
icons: Array<{
|
|
73
|
+
/** Main component name when resolvable, else the cleaned layer name */
|
|
67
74
|
name: string;
|
|
68
75
|
type: string;
|
|
76
|
+
layerName?: string;
|
|
77
|
+
/** INSTANCE_SWAP property driving this instance — the icon is a default, not fixed */
|
|
78
|
+
swapProperty?: string;
|
|
69
79
|
}>;
|
|
70
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Component metadata that ships alongside a REST `getNodes` document
|
|
83
|
+
* (`nodes[id].components` / `.componentSets`), keyed by node id. Lets us name
|
|
84
|
+
* the main component behind an INSTANCE without a Plugin API round-trip.
|
|
85
|
+
*/
|
|
86
|
+
export interface ComponentLookup {
|
|
87
|
+
components?: Record<string, {
|
|
88
|
+
name?: string;
|
|
89
|
+
componentSetId?: string;
|
|
90
|
+
} | undefined>;
|
|
91
|
+
componentSets?: Record<string, {
|
|
92
|
+
name?: string;
|
|
93
|
+
} | undefined>;
|
|
94
|
+
}
|
|
71
95
|
/** Typography data from a text node */
|
|
72
96
|
interface TextStyleData {
|
|
73
97
|
nodeName: string;
|
|
@@ -79,11 +103,16 @@ interface TextStyleData {
|
|
|
79
103
|
letterSpacing: number;
|
|
80
104
|
variableBindings?: Record<string, string>;
|
|
81
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Human-readable name of the main component behind an instance/component id.
|
|
108
|
+
* Variants resolve to "Set name (Value / Value)" since a bare "Size=16" is useless.
|
|
109
|
+
*/
|
|
110
|
+
export declare function resolveMainComponentName(componentId: string | undefined, lookup?: ComponentLookup): string | undefined;
|
|
82
111
|
/**
|
|
83
112
|
* Collect color data from all variants in a COMPONENT_SET.
|
|
84
113
|
* For single COMPONENTs, returns data for just that component.
|
|
85
114
|
*/
|
|
86
|
-
export declare function collectAllVariantData(node: any, varNameMap: Map<string, string
|
|
115
|
+
export declare function collectAllVariantData(node: any, varNameMap: Map<string, string>, lookup?: ComponentLookup): VariantColorData[];
|
|
87
116
|
/**
|
|
88
117
|
* Collect typography data from all text nodes in a component tree.
|
|
89
118
|
*/
|
|
@@ -93,6 +122,41 @@ export declare function collectTypographyData(node: any, depth?: number, maxDept
|
|
|
93
122
|
* Returns a formatted string showing the component's nested structure.
|
|
94
123
|
*/
|
|
95
124
|
export declare function buildAnatomyTree(node: any, depth?: number, maxDepth?: number): string;
|
|
125
|
+
/** Parse "Size=lg, State=hover" into ordered [property, value] pairs */
|
|
126
|
+
export declare function parseVariantProperties(rawName: string): Array<[string, string]>;
|
|
127
|
+
/** One row of the cross-variant spacing table */
|
|
128
|
+
export interface VariantSpacingRow {
|
|
129
|
+
property: string;
|
|
130
|
+
/** True when every variant has the same value AND the same variable binding */
|
|
131
|
+
uniform: boolean;
|
|
132
|
+
/** Markdown for the "Figma Variable" cell */
|
|
133
|
+
variableCell: string;
|
|
134
|
+
/** Markdown for the "Value" cell */
|
|
135
|
+
valueCell: string;
|
|
136
|
+
}
|
|
137
|
+
export interface VariantSpacingComparison {
|
|
138
|
+
variantCount: number;
|
|
139
|
+
rows: VariantSpacingRow[];
|
|
140
|
+
/** Human-readable findings worth a maintainer's attention (binding asymmetry) */
|
|
141
|
+
inconsistencies: string[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Compare spacing across EVERY variant of a COMPONENT_SET instead of reporting
|
|
145
|
+
* the first child as if it spoke for the whole set.
|
|
146
|
+
*
|
|
147
|
+
* - all variants agree → one plain row, same as a single component
|
|
148
|
+
* - they differ along one variant
|
|
149
|
+
* property (e.g. Size) → "varies by Size: sm 4px · md 8px"
|
|
150
|
+
* - they differ with no pattern → "varies: 0px ×8, 55px (Primary / Default)"
|
|
151
|
+
*
|
|
152
|
+
* Separately flags any property bound to a variable on some variants and left
|
|
153
|
+
* hardcoded on others with NO variant property accounting for the split — a
|
|
154
|
+
* reliable fingerprint of an accidental edit.
|
|
155
|
+
*
|
|
156
|
+
* The REST API omits zero-valued spacing fields, so a property missing on one
|
|
157
|
+
* variant but present on another is compared as 0, not skipped.
|
|
158
|
+
*/
|
|
159
|
+
export declare function collectSpacingAcrossVariants(setNode: any, varNameMap?: Map<string, string>): VariantSpacingComparison;
|
|
96
160
|
/**
|
|
97
161
|
* Resolve the node to use for visual/spacing/typography comparisons.
|
|
98
162
|
* COMPONENT_SET frames have container-level styling (Figma's purple dashed stroke,
|
|
@@ -105,6 +169,10 @@ export declare function resolveVisualNode(node: any): any;
|
|
|
105
169
|
export declare function isVariantName(name: string): boolean;
|
|
106
170
|
/** Sanitize a component name for use as a file path */
|
|
107
171
|
export declare function sanitizeComponentName(name: string): string;
|
|
172
|
+
export declare function generateStatesAndVariantsSection(node: any, variantData?: VariantColorData[], lookup?: ComponentLookup): string;
|
|
173
|
+
export declare function generateVisualSpecsSection(node: any, enrichedData: EnrichedComponent | null, variantData?: VariantColorData[], varNameMap?: Map<string, string>,
|
|
174
|
+
/** The full COMPONENT_SET when `node` is its default variant — enables cross-variant spacing comparison */
|
|
175
|
+
setNode?: any): string;
|
|
108
176
|
/** Convert generated markdown into a CompanyDocsMCP-compatible content entry */
|
|
109
177
|
export declare function toCompanyDocsEntry(markdown: string, componentName: string, figmaUrl: string, systemName?: string): CompanyDocsContentEntry;
|
|
110
178
|
export declare function registerDesignCodeTools(server: McpServer, getFigmaAPI: () => Promise<FigmaAPI>, getCurrentUrl: () => string | null, variablesCache?: Map<string, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-code-tools.d.ts","sourceRoot":"","sources":["../../src/core/design-code-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"design-code-tools.d.ts","sourceRoot":"","sources":["../../src/core/design-code-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAUX,uBAAuB,EACvB,MAAM,wBAAwB,CAAC;AAuBhC,OAAO,EAAE,cAAc,EAAE,cAAc,EA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