@mp3wizard/figma-console-mcp 1.32.2 → 1.34.1
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 +26 -17
- package/dist/cloudflare/core/cloud-websocket-connector.js +18 -0
- package/dist/cloudflare/core/design-code-tools.js +60 -17
- package/dist/cloudflare/core/design-system-manifest.js +19 -14
- package/dist/cloudflare/core/design-system-tools.js +43 -34
- package/dist/cloudflare/core/diagnose-tool.js +4 -0
- package/dist/cloudflare/core/enrichment/enrichment-service.js +11 -5
- package/dist/cloudflare/core/enrichment/style-resolver.js +38 -18
- package/dist/cloudflare/core/figma-api.js +118 -54
- package/dist/cloudflare/core/figma-tools.js +179 -63
- package/dist/cloudflare/core/port-discovery.js +404 -31
- package/dist/cloudflare/core/tokens/alias-resolver.js +75 -5
- package/dist/cloudflare/core/tokens/config.js +10 -0
- package/dist/cloudflare/core/tokens/dialect.js +232 -0
- package/dist/cloudflare/core/tokens/figma-converter.js +144 -16
- package/dist/cloudflare/core/tokens/formatters/css-vars.js +21 -12
- package/dist/cloudflare/core/tokens/formatters/dtcg.js +106 -30
- package/dist/cloudflare/core/tokens/formatters/json.js +28 -10
- package/dist/cloudflare/core/tokens/formatters/scss.js +19 -13
- package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +15 -9
- package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +14 -9
- package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +11 -5
- package/dist/cloudflare/core/tokens/index.js +2 -1
- package/dist/cloudflare/core/tokens/parsers/dtcg.js +32 -5
- package/dist/cloudflare/core/tokens/schemas.js +4 -0
- package/dist/cloudflare/core/tokens-tools.js +1017 -88
- package/dist/cloudflare/core/version-tools.js +44 -3
- package/dist/cloudflare/core/websocket-connector.js +42 -0
- package/dist/cloudflare/core/websocket-server.js +99 -8
- package/dist/cloudflare/core/write-tools.js +355 -86
- package/dist/cloudflare/index.js +7 -7
- package/dist/core/design-code-tools.d.ts.map +1 -1
- package/dist/core/design-code-tools.js +60 -17
- package/dist/core/design-code-tools.js.map +1 -1
- package/dist/core/design-system-manifest.d.ts +1 -0
- package/dist/core/design-system-manifest.d.ts.map +1 -1
- package/dist/core/design-system-manifest.js +19 -14
- 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 +43 -34
- package/dist/core/design-system-tools.js.map +1 -1
- package/dist/core/diagnose-tool.d.ts +8 -0
- package/dist/core/diagnose-tool.d.ts.map +1 -1
- package/dist/core/diagnose-tool.js +4 -0
- package/dist/core/diagnose-tool.js.map +1 -1
- package/dist/core/enrichment/enrichment-service.d.ts.map +1 -1
- package/dist/core/enrichment/enrichment-service.js +11 -5
- package/dist/core/enrichment/enrichment-service.js.map +1 -1
- package/dist/core/enrichment/style-resolver.d.ts +7 -2
- package/dist/core/enrichment/style-resolver.d.ts.map +1 -1
- package/dist/core/enrichment/style-resolver.js +38 -18
- package/dist/core/enrichment/style-resolver.js.map +1 -1
- package/dist/core/figma-api.d.ts +18 -9
- package/dist/core/figma-api.d.ts.map +1 -1
- package/dist/core/figma-api.js +118 -54
- package/dist/core/figma-api.js.map +1 -1
- package/dist/core/figma-connector.d.ts +12 -0
- package/dist/core/figma-connector.d.ts.map +1 -1
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +179 -63
- package/dist/core/figma-tools.js.map +1 -1
- package/dist/core/port-discovery.d.ts +40 -0
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +404 -31
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/tokens/alias-resolver.d.ts +45 -3
- package/dist/core/tokens/alias-resolver.d.ts.map +1 -1
- package/dist/core/tokens/alias-resolver.js +75 -5
- package/dist/core/tokens/alias-resolver.js.map +1 -1
- package/dist/core/tokens/config.d.ts +28 -0
- package/dist/core/tokens/config.d.ts.map +1 -1
- package/dist/core/tokens/config.js +10 -0
- package/dist/core/tokens/config.js.map +1 -1
- package/dist/core/tokens/dialect.d.ts +107 -0
- package/dist/core/tokens/dialect.d.ts.map +1 -0
- package/dist/core/tokens/dialect.js +233 -0
- package/dist/core/tokens/dialect.js.map +1 -0
- package/dist/core/tokens/figma-converter.d.ts +23 -2
- package/dist/core/tokens/figma-converter.d.ts.map +1 -1
- package/dist/core/tokens/figma-converter.js +144 -16
- package/dist/core/tokens/figma-converter.js.map +1 -1
- package/dist/core/tokens/formatters/css-vars.d.ts.map +1 -1
- package/dist/core/tokens/formatters/css-vars.js +21 -12
- package/dist/core/tokens/formatters/css-vars.js.map +1 -1
- package/dist/core/tokens/formatters/dtcg.d.ts +2 -2
- package/dist/core/tokens/formatters/dtcg.d.ts.map +1 -1
- package/dist/core/tokens/formatters/dtcg.js +106 -30
- package/dist/core/tokens/formatters/dtcg.js.map +1 -1
- package/dist/core/tokens/formatters/json.d.ts.map +1 -1
- package/dist/core/tokens/formatters/json.js +28 -10
- package/dist/core/tokens/formatters/json.js.map +1 -1
- package/dist/core/tokens/formatters/scss.d.ts.map +1 -1
- package/dist/core/tokens/formatters/scss.js +19 -13
- package/dist/core/tokens/formatters/scss.js.map +1 -1
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts.map +1 -1
- package/dist/core/tokens/formatters/style-dictionary-v3.js +15 -9
- package/dist/core/tokens/formatters/style-dictionary-v3.js.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v4.d.ts.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v4.js +14 -9
- package/dist/core/tokens/formatters/tailwind-v4.js.map +1 -1
- package/dist/core/tokens/formatters/tokens-studio.d.ts.map +1 -1
- package/dist/core/tokens/formatters/tokens-studio.js +11 -5
- package/dist/core/tokens/formatters/tokens-studio.js.map +1 -1
- package/dist/core/tokens/index.d.ts +2 -1
- package/dist/core/tokens/index.d.ts.map +1 -1
- package/dist/core/tokens/index.js +2 -1
- package/dist/core/tokens/index.js.map +1 -1
- package/dist/core/tokens/parsers/dtcg.js +32 -5
- package/dist/core/tokens/parsers/dtcg.js.map +1 -1
- package/dist/core/tokens/schemas.d.ts +3 -0
- package/dist/core/tokens/schemas.d.ts.map +1 -1
- package/dist/core/tokens/schemas.js +4 -0
- package/dist/core/tokens/schemas.js.map +1 -1
- package/dist/core/tokens/types.d.ts +57 -1
- package/dist/core/tokens/types.d.ts.map +1 -1
- package/dist/core/tokens/types.js.map +1 -1
- package/dist/core/tokens-tools.d.ts +250 -7
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +1017 -88
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/core/version-tools.d.ts.map +1 -1
- package/dist/core/version-tools.js +44 -3
- package/dist/core/version-tools.js.map +1 -1
- package/dist/core/websocket-connector.d.ts +38 -0
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-connector.js +42 -0
- package/dist/core/websocket-connector.js.map +1 -1
- package/dist/core/websocket-server.d.ts +23 -0
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +99 -8
- 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 +355 -86
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +0 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +253 -63
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/code.js +382 -28
- package/figma-desktop-bridge/ui.html +578 -292
- package/package.json +2 -2
|
@@ -477,7 +477,7 @@ function buildAnatomyLines(node, lines, prefix, isLast, depth, maxDepth) {
|
|
|
477
477
|
/**
|
|
478
478
|
* Collect spacing tokens with their bound variable names.
|
|
479
479
|
*/
|
|
480
|
-
function collectSpacingTokens(node) {
|
|
480
|
+
function collectSpacingTokens(node, varNameMap = new Map()) {
|
|
481
481
|
const tokens = [];
|
|
482
482
|
const boundVars = node.boundVariables || {};
|
|
483
483
|
const spacingProps = [
|
|
@@ -493,7 +493,11 @@ function collectSpacingTokens(node) {
|
|
|
493
493
|
const value = node[key];
|
|
494
494
|
if (value !== undefined && value !== null) {
|
|
495
495
|
const varBinding = boundVars[key];
|
|
496
|
-
|
|
496
|
+
// Bound spacing variables expose their id as boundVariables[key].id.
|
|
497
|
+
// Resolve it to a friendly token name (e.g. `spacing/1`) when the caller
|
|
498
|
+
// supplied a name map; fall back to the raw id so the binding stays visible.
|
|
499
|
+
const varId = typeof varBinding?.id === "string" ? varBinding.id : undefined;
|
|
500
|
+
const varName = varId ? varNameMap.get(varId) || varId : undefined;
|
|
497
501
|
tokens.push({
|
|
498
502
|
property: label,
|
|
499
503
|
value,
|
|
@@ -843,20 +847,26 @@ function compareTokens(enrichedData, codeSpec, discrepancies) {
|
|
|
843
847
|
});
|
|
844
848
|
}
|
|
845
849
|
}
|
|
846
|
-
// Cross-reference design variables with code tokens
|
|
850
|
+
// Cross-reference design variables with code tokens.
|
|
851
|
+
// enrichment entries key off variableName (NOT name); reading `.name` here left
|
|
852
|
+
// every comparison undefined (and would throw on .toLowerCase()). Use variableName
|
|
853
|
+
// and skip any entries that never resolved to a real token name.
|
|
847
854
|
if (enrichedData.variables_used && ct.usedTokens) {
|
|
848
|
-
const
|
|
855
|
+
const designTokens = enrichedData.variables_used
|
|
856
|
+
.map((v) => v.variableName)
|
|
857
|
+
.filter((n) => typeof n === "string" && n.length > 0);
|
|
858
|
+
const designTokenNames = designTokens.map((n) => n.toLowerCase());
|
|
849
859
|
const codeTokenNames = ct.usedTokens.map((t) => t.toLowerCase());
|
|
850
|
-
for (const
|
|
851
|
-
const normalizedName =
|
|
860
|
+
for (const tokenName of designTokens) {
|
|
861
|
+
const normalizedName = tokenName.toLowerCase();
|
|
852
862
|
if (!codeTokenNames.some((ct) => ct.includes(normalizedName) || normalizedName.includes(ct))) {
|
|
853
863
|
discrepancies.push({
|
|
854
864
|
category: "tokens",
|
|
855
|
-
property: `token:${
|
|
865
|
+
property: `token:${tokenName}`,
|
|
856
866
|
severity: "minor",
|
|
857
|
-
designValue:
|
|
867
|
+
designValue: tokenName,
|
|
858
868
|
codeValue: null,
|
|
859
|
-
message: `Design uses token "${
|
|
869
|
+
message: `Design uses token "${tokenName}" but code doesn't reference it`,
|
|
860
870
|
suggestion: `Add token reference in code`,
|
|
861
871
|
});
|
|
862
872
|
}
|
|
@@ -1680,13 +1690,16 @@ function deduplicateColors(colors) {
|
|
|
1680
1690
|
}
|
|
1681
1691
|
return Array.from(seen.values());
|
|
1682
1692
|
}
|
|
1683
|
-
function generateVisualSpecsSection(node, enrichedData, variantData) {
|
|
1693
|
+
function generateVisualSpecsSection(node, enrichedData, variantData, varNameMap = new Map()) {
|
|
1684
1694
|
const lines = ["", "## Token Specification", ""];
|
|
1685
|
-
//
|
|
1686
|
-
|
|
1695
|
+
// Fill any gaps in the caller-supplied name map from enrichment data.
|
|
1696
|
+
// enrichment entries key off variableId/variableName (NOT id/name), and only
|
|
1697
|
+
// carry a useful name when it actually resolved (not the raw VariableID).
|
|
1687
1698
|
if (enrichedData?.variables_used) {
|
|
1688
1699
|
for (const v of enrichedData.variables_used) {
|
|
1689
|
-
|
|
1700
|
+
if (v.variableId && v.variableName && v.variableName !== v.variableId && !varNameMap.has(v.variableId)) {
|
|
1701
|
+
varNameMap.set(v.variableId, v.variableName);
|
|
1702
|
+
}
|
|
1690
1703
|
}
|
|
1691
1704
|
}
|
|
1692
1705
|
// Per-variant color token table
|
|
@@ -1740,7 +1753,7 @@ function generateVisualSpecsSection(node, enrichedData, variantData) {
|
|
|
1740
1753
|
}
|
|
1741
1754
|
// Spacing tokens with variable names
|
|
1742
1755
|
const visualNode = resolveVisualNode(node);
|
|
1743
|
-
const spacingTokens = collectSpacingTokens(visualNode);
|
|
1756
|
+
const spacingTokens = collectSpacingTokens(visualNode, varNameMap);
|
|
1744
1757
|
if (spacingTokens.length > 0) {
|
|
1745
1758
|
lines.push("### Spacing Tokens");
|
|
1746
1759
|
lines.push("");
|
|
@@ -2565,11 +2578,41 @@ export function registerDesignCodeTools(server, getFigmaAPI, getCurrentUrl, vari
|
|
|
2565
2578
|
logger.warn("Enrichment failed, proceeding without token data");
|
|
2566
2579
|
}
|
|
2567
2580
|
}
|
|
2568
|
-
// Build variable name lookup for per-variant color
|
|
2581
|
+
// Build variable name lookup (id → token name) for per-variant color
|
|
2582
|
+
// AND spacing collection. Two sources, in order of authority:
|
|
2583
|
+
// 1. Desktop Bridge local variables (Plugin API getLocalVariablesAsync) —
|
|
2584
|
+
// works on EVERY Figma plan and is the only reliable id→name source.
|
|
2585
|
+
// The REST /files/:key/variables/local endpoint is Enterprise-only
|
|
2586
|
+
// (returns 403 on all other plans), so enrichment's variable map is
|
|
2587
|
+
// almost always empty and bound colors would otherwise render as raw
|
|
2588
|
+
// hex / raw VariableIDs.
|
|
2589
|
+
// 2. Enrichment variables_used — fallback for non-bridge (Cloud/Remote)
|
|
2590
|
+
// paths. NOTE: entries key off variableId/variableName (NOT id/name),
|
|
2591
|
+
// and their name is only useful when it actually resolved to a token
|
|
2592
|
+
// name (not the raw VariableID).
|
|
2569
2593
|
const varNameMap = new Map();
|
|
2570
2594
|
if (enrichedData?.variables_used) {
|
|
2571
2595
|
for (const v of enrichedData.variables_used) {
|
|
2572
|
-
|
|
2596
|
+
if (v.variableId && v.variableName && v.variableName !== v.variableId) {
|
|
2597
|
+
varNameMap.set(v.variableId, v.variableName);
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
if (getDesktopConnector) {
|
|
2602
|
+
try {
|
|
2603
|
+
const connector = await getDesktopConnector();
|
|
2604
|
+
const varsResult = await connector.getVariables();
|
|
2605
|
+
const varList = varsResult?.variables || varsResult?.result?.variables;
|
|
2606
|
+
if (Array.isArray(varList)) {
|
|
2607
|
+
for (const v of varList) {
|
|
2608
|
+
if (v?.id && v?.name)
|
|
2609
|
+
varNameMap.set(v.id, v.name);
|
|
2610
|
+
}
|
|
2611
|
+
logger.info({ count: varList.length }, "Resolved variable names via Desktop Bridge for docs");
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
catch {
|
|
2615
|
+
logger.warn("Could not load bridge variables for doc token names — colors may fall back to hex");
|
|
2573
2616
|
}
|
|
2574
2617
|
}
|
|
2575
2618
|
// Collect per-variant color/icon data
|
|
@@ -2657,7 +2700,7 @@ export function registerDesignCodeTools(server, getFigmaAPI, getCurrentUrl, vari
|
|
|
2657
2700
|
}
|
|
2658
2701
|
}
|
|
2659
2702
|
if (s.visualSpecs) {
|
|
2660
|
-
parts.push(generateVisualSpecsSection(nodeForVisual, enrichedData, variantData));
|
|
2703
|
+
parts.push(generateVisualSpecsSection(nodeForVisual, enrichedData, variantData, varNameMap));
|
|
2661
2704
|
includedSections.push("visualSpecs");
|
|
2662
2705
|
}
|
|
2663
2706
|
if (s.typography) {
|