figma-console-mcp 1.27.1 β 1.28.0
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 +7 -5
- package/dist/core/tokens/formatters/json.d.ts +34 -2
- package/dist/core/tokens/formatters/json.d.ts.map +1 -1
- package/dist/core/tokens/formatters/json.js +176 -5
- package/dist/core/tokens/formatters/json.js.map +1 -1
- package/dist/core/tokens/formatters/scss.d.ts +23 -1
- package/dist/core/tokens/formatters/scss.d.ts.map +1 -1
- package/dist/core/tokens/formatters/scss.js +251 -3
- package/dist/core/tokens/formatters/scss.js.map +1 -1
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts +42 -1
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts.map +1 -1
- package/dist/core/tokens/formatters/style-dictionary-v3.js +206 -3
- package/dist/core/tokens/formatters/style-dictionary-v3.js.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v3.d.ts +34 -1
- package/dist/core/tokens/formatters/tailwind-v3.d.ts.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v3.js +222 -3
- package/dist/core/tokens/formatters/tailwind-v3.js.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v4.d.ts +38 -1
- package/dist/core/tokens/formatters/tailwind-v4.d.ts.map +1 -1
- package/dist/core/tokens/formatters/tailwind-v4.js +313 -3
- package/dist/core/tokens/formatters/tailwind-v4.js.map +1 -1
- package/dist/core/tokens/formatters/tokens-studio.d.ts +41 -1
- package/dist/core/tokens/formatters/tokens-studio.d.ts.map +1 -1
- package/dist/core/tokens/formatters/tokens-studio.js +249 -3
- package/dist/core/tokens/formatters/tokens-studio.js.map +1 -1
- package/dist/core/tokens/formatters/ts-module.d.ts +32 -1
- package/dist/core/tokens/formatters/ts-module.d.ts.map +1 -1
- package/dist/core/tokens/formatters/ts-module.js +190 -3
- package/dist/core/tokens/formatters/ts-module.js.map +1 -1
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +12 -2
- package/dist/core/tokens-tools.js.map +1 -1
- package/figma-desktop-bridge/code.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **Your design system as an API.** Model Context Protocol server that bridges design and developmentβgiving AI assistants complete access to Figma for **extraction**, **creation**, **debugging**, and **bidirectional token sync**.
|
|
10
10
|
|
|
11
|
-
> **π
|
|
11
|
+
> **π Token Sync β Full Formatter Coverage (v1.28.0):** `figma_export_tokens` now ships **10 fully-implemented output formats**: DTCG JSON (canonical), CSS custom properties, Tailwind v4 `@theme inline`, Tailwind v3 config, SCSS, TypeScript module, JSON (flat + nested), Style Dictionary v3, and Tokens Studio multi-file. Pull Figma variables and emit code in whatever styling flavor your project uses β no Style Dictionary or Tokens Studio install required. Diff-aware merge for round-trip; one Figma API call per changed value, not full rewrites. 103 tools total. [See what's new β](CHANGELOG.md#1280---2026-05-18)
|
|
12
12
|
|
|
13
13
|
## What is this?
|
|
14
14
|
|
|
@@ -55,7 +55,7 @@ Figma Console MCP connects AI assistants (like Claude) to Figma, enabling:
|
|
|
55
55
|
| Real-time monitoring (console, selection) | β
| β | β |
|
|
56
56
|
| Desktop Bridge plugin | β
| β
| β |
|
|
57
57
|
| Requires Node.js | Yes | **No** | No |
|
|
58
|
-
| **Total tools available** | **103** | **
|
|
58
|
+
| **Total tools available** | **103** | **95** | **9** |
|
|
59
59
|
|
|
60
60
|
> **Bottom line:** Remote SSE is **read-only** with ~38% of the tools. **Cloud Mode** unlocks write access from web AI clients without Node.js. NPX/Local Git gives the full 103 tools with real-time monitoring.
|
|
61
61
|
|
|
@@ -308,7 +308,7 @@ AI Client β Cloud MCP Server β Durable Object Relay β Desktop Bridge Plugi
|
|
|
308
308
|
| Feature | NPX (Recommended) | Cloud Mode | Local Git | Remote SSE |
|
|
309
309
|
|---------|-------------------|------------|-----------|------------|
|
|
310
310
|
| **Setup time** | ~10 minutes | ~5 minutes | ~15 minutes | ~2 minutes |
|
|
311
|
-
| **Total tools** | **103** | **
|
|
311
|
+
| **Total tools** | **103** | **95** | **103** | **9** (read-only) |
|
|
312
312
|
| **Design creation** | β
| β
| β
| β |
|
|
313
313
|
| **Variable management** | β
| β
| β
| β |
|
|
314
314
|
| **Component instantiation** | β
| β
| β
| β |
|
|
@@ -802,9 +802,11 @@ The architecture supports adding new apps with minimal boilerplate β each app
|
|
|
802
802
|
|
|
803
803
|
## π€οΈ Roadmap
|
|
804
804
|
|
|
805
|
-
**Current Status:** v1.
|
|
805
|
+
**Current Status:** v1.28.0 (Stable) - Production-ready with 10-format token export pipeline (DTCG, CSS, Tailwind v4, Tailwind v3, SCSS, TS module, JSON flat/nested, Style Dictionary v3, Tokens Studio), bidirectional Figmaβcode token sync, version history & time-series awareness, FigJam + Slides support, Cloud Write Relay, Design System Kit, WebSocket-only connectivity, smart multi-file tracking, **103 tools** (Local) / **95 tools** (Cloud) / **9 tools** (Remote read-only), Comments API, cross-MCP identity disambiguation, and MCP Apps.
|
|
806
806
|
|
|
807
807
|
**Recent Releases:**
|
|
808
|
+
- [x] **v1.28.0** - Full formatter coverage for `figma_export_tokens`. Seven new output formats: Tailwind v4 `@theme inline`, Tailwind v3 config, SCSS variables, TypeScript module, JSON flat/nested, Style Dictionary v3, Tokens Studio multi-file. Combined with DTCG + CSS variables, ships **10 fully-implemented output formats** with zero third-party build-tool dependencies. Tool description updated, docs/tools.md table all-green. 22 new Jest tests, 1151 total passing.
|
|
809
|
+
- [x] **v1.27.1** - Documentation patch. No code behavior changes. Sweeps stale "Phase 1 ships with DTCG only" claims across tool descriptions, error messages, and internal comments after CSS variables formatter and the apply phase shipped during the v1.27.0 dev cycle. Refreshes README banner + capability bullets + roadmap. Adds `Phase 3.5: Stale-Content Audit` to the release runbook so future releases get a strict pre-publish grep sweep across banners, tool descriptions, error messages, source comments, and tool-count consistency.
|
|
808
810
|
- [x] **v1.27.0** - Bidirectional token sync: `figma_export_tokens` + `figma_import_tokens` replace Style Dictionary and Tokens Studio's export pipeline. Canonical DTCG JSON + CSS custom properties. Diff-aware merge with round-trip ID preservation via `$extensions["figma-console-mcp"]`. Apply phase pushes hex-value edits back to Figma via the plugin bridge. Verified end-to-end against 713-token + 280-token design systems.
|
|
809
811
|
- [x] **v1.26.0** - Internal cleanup + cross-MCP identity: Local-mode CDP/Puppeteer transport removed entirely (WebSocket-only). `figma_diagnose` tool for designer-readable health checks. Every response tagged `_mcp: "figma-console-mcp"`; errors prefixed `[figma-console-mcp]` so attribution is unambiguous when running multiple Figma MCPs. Plugin status pill now reads `Local Β· ready` / `Cloud Β· ready` / `Local + Cloud Β· ready`. Net diff: β7,299 lines, plugin re-import optional.
|
|
810
812
|
- [x] **v1.25.0** - Description + Dev Mode annotation tracking in `figma_diff_versions` via plugin session buffer. Description and annotation edits made during a session now appear in diff output (REST API doesn't return these β bridged through the plugin's `documentchange` listener).
|
|
@@ -820,7 +822,7 @@ The architecture supports adding new apps with minimal boilerplate β each app
|
|
|
820
822
|
- [x] **v1.7.0** - MCP Apps (Token Browser, Design System Dashboard), batch variable operations, design-code parity tools.
|
|
821
823
|
|
|
822
824
|
**Coming Next:**
|
|
823
|
-
- [ ] **Token sync
|
|
825
|
+
- [ ] **Token sync β parsers + import-side apply expansion** - Parsers for non-DTCG input (Tokens Studio, CSS vars, Tailwind v4, Tailwind v3 config, SCSS, Style Dictionary v3, JSON flat/nested). Plus `toCreate` apply orchestration, `toDelete` for `replace` strategy, alias-target updates, and cross-library variable resolution via `getVariableByIdAsync` so cross-library aliases render as real `var(--target)` references instead of comments.
|
|
824
826
|
- [ ] **Component template library** - Common UI pattern generation
|
|
825
827
|
- [ ] **Visual regression testing** - Screenshot diff capabilities
|
|
826
828
|
- [ ] **Design linting** - Automated compliance and accessibility checks
|
|
@@ -1,5 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plain JSON formatters β flat and nested.
|
|
3
|
+
*
|
|
4
|
+
* These are dumps without the DTCG `$type`/`$value` envelope, for custom
|
|
5
|
+
* build scripts that just need a key-value map of resolved tokens.
|
|
6
|
+
*
|
|
7
|
+
* Flat shape:
|
|
8
|
+
*
|
|
9
|
+
* {
|
|
10
|
+
* "ds-color-primary": "#4085F2",
|
|
11
|
+
* "ds-spacing-md": "16px",
|
|
12
|
+
* "ds-color-bg--dark": "#0A0A0A"
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* Multi-mode tokens flatten with `--<mode>` suffix (primary mode keeps
|
|
16
|
+
* the bare name; other modes get suffixed).
|
|
17
|
+
*
|
|
18
|
+
* Nested shape:
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* "color": {
|
|
22
|
+
* "primary": "#4085F2",
|
|
23
|
+
* "brand": { "primary": "#FF00AA" }
|
|
24
|
+
* },
|
|
25
|
+
* "spacing": { "md": "16px" }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* Multi-mode tokens become objects: `{ Light: "...", Dark: "..." }`.
|
|
29
|
+
*
|
|
30
|
+
* Aliases resolve to the literal value where possible; cross-library
|
|
31
|
+
* aliases get a `null` (caller can decide how to fill those in).
|
|
32
|
+
*/
|
|
1
33
|
import type { TokenDocument } from "../types.js";
|
|
2
34
|
import type { FormatOptions, FormatResult } from "./index.js";
|
|
3
|
-
export declare function formatJsonFlat(
|
|
4
|
-
export declare function formatJsonNested(
|
|
35
|
+
export declare function formatJsonFlat(doc: TokenDocument, opts: FormatOptions): FormatResult;
|
|
36
|
+
export declare function formatJsonNested(doc: TokenDocument, opts: FormatOptions): FormatResult;
|
|
5
37
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAS,aAAa,EAAwB,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,GAClB,YAAY,CAsBd;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,GAClB,YAAY,CAqBd"}
|
|
@@ -1,8 +1,179 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Plain JSON formatters β flat and nested.
|
|
3
|
+
*
|
|
4
|
+
* These are dumps without the DTCG `$type`/`$value` envelope, for custom
|
|
5
|
+
* build scripts that just need a key-value map of resolved tokens.
|
|
6
|
+
*
|
|
7
|
+
* Flat shape:
|
|
8
|
+
*
|
|
9
|
+
* {
|
|
10
|
+
* "ds-color-primary": "#4085F2",
|
|
11
|
+
* "ds-spacing-md": "16px",
|
|
12
|
+
* "ds-color-bg--dark": "#0A0A0A"
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* Multi-mode tokens flatten with `--<mode>` suffix (primary mode keeps
|
|
16
|
+
* the bare name; other modes get suffixed).
|
|
17
|
+
*
|
|
18
|
+
* Nested shape:
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* "color": {
|
|
22
|
+
* "primary": "#4085F2",
|
|
23
|
+
* "brand": { "primary": "#FF00AA" }
|
|
24
|
+
* },
|
|
25
|
+
* "spacing": { "md": "16px" }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* Multi-mode tokens become objects: `{ Light: "...", Dark: "..." }`.
|
|
29
|
+
*
|
|
30
|
+
* Aliases resolve to the literal value where possible; cross-library
|
|
31
|
+
* aliases get a `null` (caller can decide how to fill those in).
|
|
32
|
+
*/
|
|
33
|
+
export function formatJsonFlat(doc, opts) {
|
|
34
|
+
const warnings = [];
|
|
35
|
+
const files = [];
|
|
36
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
37
|
+
const prefix = opts.target.prefix ?? "";
|
|
38
|
+
if (splitByCollection) {
|
|
39
|
+
for (const set of doc.sets) {
|
|
40
|
+
files.push({
|
|
41
|
+
path: filenameFor(opts, set, "flat"),
|
|
42
|
+
content: renderFlat([set], prefix, warnings),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
files.push({
|
|
48
|
+
path: filenameFor(opts, undefined, "flat"),
|
|
49
|
+
content: renderFlat(doc.sets, prefix, warnings),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return { files, warnings };
|
|
4
53
|
}
|
|
5
|
-
export function formatJsonNested(
|
|
6
|
-
|
|
54
|
+
export function formatJsonNested(doc, opts) {
|
|
55
|
+
const warnings = [];
|
|
56
|
+
const files = [];
|
|
57
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
58
|
+
if (splitByCollection) {
|
|
59
|
+
for (const set of doc.sets) {
|
|
60
|
+
files.push({
|
|
61
|
+
path: filenameFor(opts, set, "nested"),
|
|
62
|
+
content: renderNested([set], warnings),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
files.push({
|
|
68
|
+
path: filenameFor(opts, undefined, "nested"),
|
|
69
|
+
content: renderNested(doc.sets, warnings),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return { files, warnings };
|
|
73
|
+
}
|
|
74
|
+
function filenameFor(opts, set, shape) {
|
|
75
|
+
if (opts.target.filename)
|
|
76
|
+
return opts.target.filename;
|
|
77
|
+
const parts = [];
|
|
78
|
+
if (set)
|
|
79
|
+
parts.push(slugify(set.name));
|
|
80
|
+
parts.push(`tokens.${shape}`);
|
|
81
|
+
return `${parts.join(".")}.json`;
|
|
82
|
+
}
|
|
83
|
+
function slugify(s) {
|
|
84
|
+
return s
|
|
85
|
+
.trim()
|
|
86
|
+
.toLowerCase()
|
|
87
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
88
|
+
.replace(/^-+|-+$/g, "");
|
|
89
|
+
}
|
|
90
|
+
function renderFlat(sets, prefix, warnings) {
|
|
91
|
+
const out = {};
|
|
92
|
+
for (const set of sets) {
|
|
93
|
+
const primaryMode = pickPrimaryMode(set.modes);
|
|
94
|
+
for (const token of set.tokens) {
|
|
95
|
+
const baseName = `${prefix}${token.path.map(slugify).join("-")}`;
|
|
96
|
+
for (const [modeName, value] of Object.entries(token.values)) {
|
|
97
|
+
const key = modeName === primaryMode
|
|
98
|
+
? baseName
|
|
99
|
+
: `${baseName}--${slugify(modeName)}`;
|
|
100
|
+
const resolved = resolveValue(value, token, warnings);
|
|
101
|
+
if (resolved !== undefined)
|
|
102
|
+
out[key] = resolved;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Sort keys for deterministic output.
|
|
107
|
+
const sorted = Object.fromEntries(Object.entries(out).sort(([a], [b]) => a.localeCompare(b)));
|
|
108
|
+
return JSON.stringify(sorted, null, 2) + "\n";
|
|
109
|
+
}
|
|
110
|
+
function renderNested(sets, warnings) {
|
|
111
|
+
const out = {};
|
|
112
|
+
for (const set of sets) {
|
|
113
|
+
const isMultiMode = set.modes.length > 1;
|
|
114
|
+
for (const token of set.tokens) {
|
|
115
|
+
let cursor = out;
|
|
116
|
+
for (let i = 0; i < token.path.length - 1; i++) {
|
|
117
|
+
const segment = token.path[i];
|
|
118
|
+
if (!cursor[segment] ||
|
|
119
|
+
typeof cursor[segment] !== "object" ||
|
|
120
|
+
Array.isArray(cursor[segment])) {
|
|
121
|
+
cursor[segment] = {};
|
|
122
|
+
}
|
|
123
|
+
cursor = cursor[segment];
|
|
124
|
+
}
|
|
125
|
+
const leafKey = token.path[token.path.length - 1];
|
|
126
|
+
if (isMultiMode) {
|
|
127
|
+
const modeValues = {};
|
|
128
|
+
for (const [modeName, value] of Object.entries(token.values)) {
|
|
129
|
+
const resolved = resolveValue(value, token, warnings);
|
|
130
|
+
if (resolved !== undefined)
|
|
131
|
+
modeValues[modeName] = resolved;
|
|
132
|
+
}
|
|
133
|
+
cursor[leafKey] = modeValues;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const onlyValue = Object.values(token.values)[0];
|
|
137
|
+
if (onlyValue) {
|
|
138
|
+
const resolved = resolveValue(onlyValue, token, warnings);
|
|
139
|
+
if (resolved !== undefined)
|
|
140
|
+
cursor[leafKey] = resolved;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return JSON.stringify(sortKeys(out), null, 2) + "\n";
|
|
146
|
+
}
|
|
147
|
+
function pickPrimaryMode(modes) {
|
|
148
|
+
return modes.find((m) => /^(default|light|value)$/i.test(m)) ?? modes[0];
|
|
149
|
+
}
|
|
150
|
+
function resolveValue(value, token, warnings) {
|
|
151
|
+
if (value.reference) {
|
|
152
|
+
const bare = value.reference.replace(/^\{|\}$/g, "");
|
|
153
|
+
if (bare.startsWith("__library:") || bare === "unknown") {
|
|
154
|
+
warnings.push(`Skipped ${token.path.join(".")} in JSON β cross-library alias unresolved.`);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
// Local alias: emit as the reference path. Caller can resolve.
|
|
158
|
+
return `{${bare}}`;
|
|
159
|
+
}
|
|
160
|
+
if (value.literal === undefined || value.literal === null)
|
|
161
|
+
return undefined;
|
|
162
|
+
if (typeof value.literal === "number") {
|
|
163
|
+
if (token.type === "dimension")
|
|
164
|
+
return `${value.literal}px`;
|
|
165
|
+
return value.literal;
|
|
166
|
+
}
|
|
167
|
+
return value.literal;
|
|
168
|
+
}
|
|
169
|
+
function sortKeys(obj) {
|
|
170
|
+
if (obj === null || typeof obj !== "object" || Array.isArray(obj))
|
|
171
|
+
return obj;
|
|
172
|
+
const sorted = {};
|
|
173
|
+
const keys = Object.keys(obj).sort();
|
|
174
|
+
for (const k of keys) {
|
|
175
|
+
sorted[k] = sortKeys(obj[k]);
|
|
176
|
+
}
|
|
177
|
+
return sorted;
|
|
7
178
|
}
|
|
8
179
|
//# sourceMappingURL=json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,MAAM,UAAU,cAAc,CAC5B,GAAkB,EAClB,IAAmB;IAEnB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,IAAI,KAAK,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAExC,IAAI,iBAAiB,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC;gBACT,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC;gBACpC,OAAO,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC;aAC7C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC;YAC1C,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;SAChD,CAAC,CAAC;IACL,CAAC;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
|
11
|
+
* $ds-colors: (
|
|
12
|
+
* "primary": $ds-color-primary,
|
|
13
|
+
* ...
|
|
14
|
+
* );
|
|
15
|
+
*
|
|
16
|
+
* Modes: SCSS doesn't have CSS's runtime cascading, so multi-mode output
|
|
17
|
+
* either emits one file per mode (splitByMode: true) or generates SCSS
|
|
18
|
+
* maps keyed by mode name that consumers can `map-get` from.
|
|
19
|
+
*
|
|
20
|
+
* Composite tokens (typography, shadow) expand into multiple primitive
|
|
21
|
+
* variables since SCSS variables hold a single value.
|
|
22
|
+
*/
|
|
1
23
|
import type { TokenDocument } from "../types.js";
|
|
2
24
|
import type { FormatOptions, FormatResult } from "./index.js";
|
|
3
|
-
export declare function formatScss(
|
|
25
|
+
export declare function formatScss(doc: TokenDocument, opts: FormatOptions): FormatResult;
|
|
4
26
|
//# sourceMappingURL=scss.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scss.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/scss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"scss.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/scss.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAS,aAAa,EAAwB,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,UAAU,CACxB,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,aAAa,GAClB,YAAY,CA0Cd"}
|
|
@@ -1,5 +1,253 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SCSS variables formatter.
|
|
3
|
+
*
|
|
4
|
+
* Output shape:
|
|
5
|
+
*
|
|
6
|
+
* // tokens.scss
|
|
7
|
+
* $ds-color-primary: #4085F2;
|
|
8
|
+
* $ds-spacing-md: 16px;
|
|
9
|
+
*
|
|
10
|
+
* // map for runtime mode access
|
|
11
|
+
* $ds-colors: (
|
|
12
|
+
* "primary": $ds-color-primary,
|
|
13
|
+
* ...
|
|
14
|
+
* );
|
|
15
|
+
*
|
|
16
|
+
* Modes: SCSS doesn't have CSS's runtime cascading, so multi-mode output
|
|
17
|
+
* either emits one file per mode (splitByMode: true) or generates SCSS
|
|
18
|
+
* maps keyed by mode name that consumers can `map-get` from.
|
|
19
|
+
*
|
|
20
|
+
* Composite tokens (typography, shadow) expand into multiple primitive
|
|
21
|
+
* variables since SCSS variables hold a single value.
|
|
22
|
+
*/
|
|
23
|
+
export function formatScss(doc, opts) {
|
|
24
|
+
const warnings = [];
|
|
25
|
+
const files = [];
|
|
26
|
+
const splitByMode = opts.target.splitByMode ?? false;
|
|
27
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
28
|
+
const prefix = opts.target.prefix ?? "";
|
|
29
|
+
if (splitByMode && splitByCollection) {
|
|
30
|
+
for (const set of doc.sets) {
|
|
31
|
+
for (const mode of set.modes) {
|
|
32
|
+
files.push({
|
|
33
|
+
path: filenameFor(opts, set, mode),
|
|
34
|
+
content: renderSingleMode([set], mode, prefix, warnings),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (splitByMode) {
|
|
40
|
+
const allModes = new Set();
|
|
41
|
+
for (const set of doc.sets)
|
|
42
|
+
for (const m of set.modes)
|
|
43
|
+
allModes.add(m);
|
|
44
|
+
for (const mode of allModes) {
|
|
45
|
+
const sets = doc.sets.filter((s) => s.modes.includes(mode));
|
|
46
|
+
files.push({
|
|
47
|
+
path: filenameFor(opts, undefined, mode),
|
|
48
|
+
content: renderSingleMode(sets, mode, prefix, warnings),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (splitByCollection) {
|
|
53
|
+
for (const set of doc.sets) {
|
|
54
|
+
files.push({
|
|
55
|
+
path: filenameFor(opts, set),
|
|
56
|
+
content: renderAllModes([set], prefix, warnings),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
files.push({
|
|
62
|
+
path: filenameFor(opts),
|
|
63
|
+
content: renderAllModes(doc.sets, prefix, warnings),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return { files, warnings };
|
|
67
|
+
}
|
|
68
|
+
function filenameFor(opts, set, mode) {
|
|
69
|
+
if (opts.target.filename)
|
|
70
|
+
return opts.target.filename;
|
|
71
|
+
const parts = [];
|
|
72
|
+
if (set)
|
|
73
|
+
parts.push(slugify(set.name));
|
|
74
|
+
if (mode)
|
|
75
|
+
parts.push(slugify(mode));
|
|
76
|
+
if (parts.length === 0)
|
|
77
|
+
parts.push("tokens");
|
|
78
|
+
return `_${parts.join(".")}.scss`;
|
|
79
|
+
}
|
|
80
|
+
function slugify(s) {
|
|
81
|
+
return s
|
|
82
|
+
.trim()
|
|
83
|
+
.toLowerCase()
|
|
84
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
85
|
+
.replace(/^-+|-+$/g, "");
|
|
86
|
+
}
|
|
87
|
+
function varName(path, prefix) {
|
|
88
|
+
return `$${prefix}${path.map(slugify).join("-")}`;
|
|
89
|
+
}
|
|
90
|
+
function renderSingleMode(sets, mode, prefix, warnings) {
|
|
91
|
+
const lines = [];
|
|
92
|
+
lines.push("// Generated by figma-console-mcp β do not edit by hand");
|
|
93
|
+
lines.push(`// Mode: ${mode}`);
|
|
94
|
+
lines.push("");
|
|
95
|
+
for (const set of sets) {
|
|
96
|
+
if (!set.modes.includes(mode))
|
|
97
|
+
continue;
|
|
98
|
+
lines.push(`// β ${set.name} β`);
|
|
99
|
+
for (const token of set.tokens) {
|
|
100
|
+
const value = token.values[mode];
|
|
101
|
+
if (!value)
|
|
102
|
+
continue;
|
|
103
|
+
emitSassLines(token, value, prefix, lines, warnings);
|
|
104
|
+
}
|
|
105
|
+
lines.push("");
|
|
106
|
+
}
|
|
107
|
+
return lines.join("\n");
|
|
108
|
+
}
|
|
109
|
+
function renderAllModes(sets, prefix, warnings) {
|
|
110
|
+
const lines = [];
|
|
111
|
+
lines.push("// Generated by figma-console-mcp β do not edit by hand");
|
|
112
|
+
lines.push("");
|
|
113
|
+
// For multi-mode sets, emit a primary variable + a mode-keyed map.
|
|
114
|
+
// Single-mode sets emit straight variables.
|
|
115
|
+
for (const set of sets) {
|
|
116
|
+
lines.push(`// β ${set.name} β`);
|
|
117
|
+
const isMultiMode = set.modes.length > 1;
|
|
118
|
+
const primaryMode = pickPrimaryMode(set.modes);
|
|
119
|
+
for (const token of set.tokens) {
|
|
120
|
+
// Primary value as the bare variable.
|
|
121
|
+
const primary = token.values[primaryMode];
|
|
122
|
+
if (primary)
|
|
123
|
+
emitSassLines(token, primary, prefix, lines, warnings);
|
|
124
|
+
// Other modes as a map: $ds-color-primary--modes: ("Dark": #..., "Vibrant": #...)
|
|
125
|
+
if (isMultiMode) {
|
|
126
|
+
const otherModes = set.modes.filter((m) => m !== primaryMode);
|
|
127
|
+
const entries = [];
|
|
128
|
+
for (const mode of otherModes) {
|
|
129
|
+
const v = token.values[mode];
|
|
130
|
+
if (!v)
|
|
131
|
+
continue;
|
|
132
|
+
const formatted = scssValueFor(v, token, prefix, warnings);
|
|
133
|
+
if (formatted !== null) {
|
|
134
|
+
entries.push(` "${mode}": ${formatted}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (entries.length > 0) {
|
|
138
|
+
const mapName = `${varName(token.path, prefix)}--modes`;
|
|
139
|
+
lines.push(`${mapName}: (`);
|
|
140
|
+
lines.push(entries.join(",\n"));
|
|
141
|
+
lines.push(`);`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
lines.push("");
|
|
146
|
+
}
|
|
147
|
+
return lines.join("\n");
|
|
148
|
+
}
|
|
149
|
+
function pickPrimaryMode(modes) {
|
|
150
|
+
return modes.find((m) => /^(default|light|value)$/i.test(m)) ?? modes[0];
|
|
151
|
+
}
|
|
152
|
+
function emitSassLines(token, value, prefix, out, warnings) {
|
|
153
|
+
const sassName = varName(token.path, prefix);
|
|
154
|
+
if (value.reference) {
|
|
155
|
+
const bareRef = value.reference.replace(/^\{|\}$/g, "");
|
|
156
|
+
const libMatch = bareRef.match(/^__library:(.+)$/);
|
|
157
|
+
if (libMatch || bareRef === "unknown") {
|
|
158
|
+
const originalId = libMatch ? libMatch[1] : "unknown";
|
|
159
|
+
warnings.push(`Skipped ${token.path.join(".")} in SCSS β cross-library variable ${originalId}.`);
|
|
160
|
+
out.push(`// ${sassName}: skipped β cross-library alias to ${originalId}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const refPath = bareRef.split(".");
|
|
164
|
+
out.push(`${sassName}: ${varName(refPath, prefix)};`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (value.literal === undefined || value.literal === null) {
|
|
168
|
+
warnings.push(`Token ${token.path.join(".")} has no value.`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (token.type === "typography" && typeof value.literal === "object") {
|
|
172
|
+
const t = value.literal;
|
|
173
|
+
for (const sub of ["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing"]) {
|
|
174
|
+
if (t[sub] !== undefined) {
|
|
175
|
+
out.push(`${sassName}-${kebab(sub)}: ${formatScssLiteral(t[sub], token.type)};`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (token.type === "shadow" && typeof value.literal === "object") {
|
|
181
|
+
const css = renderShadow(value.literal);
|
|
182
|
+
if (css)
|
|
183
|
+
out.push(`${sassName}: ${css};`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
out.push(`${sassName}: ${formatScssLiteral(value.literal, token.type)};`);
|
|
187
|
+
}
|
|
188
|
+
function scssValueFor(value, token, prefix, _warnings) {
|
|
189
|
+
if (value.reference) {
|
|
190
|
+
const bareRef = value.reference.replace(/^\{|\}$/g, "");
|
|
191
|
+
if (bareRef.startsWith("__library:") || bareRef === "unknown")
|
|
192
|
+
return null;
|
|
193
|
+
return varName(bareRef.split("."), prefix);
|
|
194
|
+
}
|
|
195
|
+
if (value.literal === undefined || value.literal === null)
|
|
196
|
+
return null;
|
|
197
|
+
return formatScssLiteral(value.literal, token.type);
|
|
198
|
+
}
|
|
199
|
+
function kebab(s) {
|
|
200
|
+
return s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
201
|
+
}
|
|
202
|
+
function formatScssLiteral(value, type) {
|
|
203
|
+
if (typeof value === "number") {
|
|
204
|
+
if (type === "dimension")
|
|
205
|
+
return `${value}px`;
|
|
206
|
+
return String(value);
|
|
207
|
+
}
|
|
208
|
+
if (typeof value === "string") {
|
|
209
|
+
if (type === "color")
|
|
210
|
+
return value;
|
|
211
|
+
if (type === "fontFamily" || type === "string") {
|
|
212
|
+
return needsQuoting(value) ? JSON.stringify(value) : value;
|
|
213
|
+
}
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
if (typeof value === "boolean")
|
|
217
|
+
return String(value);
|
|
218
|
+
return JSON.stringify(value);
|
|
219
|
+
}
|
|
220
|
+
function needsQuoting(s) {
|
|
221
|
+
if (/^["']/.test(s))
|
|
222
|
+
return false;
|
|
223
|
+
if (/^[\d.]+([a-z%]+)?$/.test(s))
|
|
224
|
+
return false;
|
|
225
|
+
if (/^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(s))
|
|
226
|
+
return false;
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
function renderShadow(shadow) {
|
|
230
|
+
if (Array.isArray(shadow)) {
|
|
231
|
+
return shadow.map(renderShadow).filter(Boolean).join(", ");
|
|
232
|
+
}
|
|
233
|
+
if (!shadow || typeof shadow !== "object")
|
|
234
|
+
return null;
|
|
235
|
+
const s = shadow;
|
|
236
|
+
const inset = s.inset ? "inset " : "";
|
|
237
|
+
const x = withPx(s.offsetX);
|
|
238
|
+
const y = withPx(s.offsetY);
|
|
239
|
+
const blur = withPx(s.blur);
|
|
240
|
+
const spread = s.spread !== undefined ? ` ${withPx(s.spread)}` : "";
|
|
241
|
+
const color = s.color;
|
|
242
|
+
if (!x || !y || !blur || typeof color !== "string")
|
|
243
|
+
return null;
|
|
244
|
+
return `${inset}${x} ${y} ${blur}${spread} ${color}`;
|
|
245
|
+
}
|
|
246
|
+
function withPx(v) {
|
|
247
|
+
if (typeof v === "number")
|
|
248
|
+
return `${v}px`;
|
|
249
|
+
if (typeof v === "string")
|
|
250
|
+
return v;
|
|
251
|
+
return "";
|
|
4
252
|
}
|
|
5
253
|
//# sourceMappingURL=scss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scss.js","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/scss.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scss.js","sourceRoot":"","sources":["../../../../src/core/tokens/formatters/scss.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,MAAM,UAAU,UAAU,CACxB,GAAkB,EAClB,IAAmB;IAEnB,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,KAAK,GAA0B,EAAE,CAAC;IAExC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,KAAK,CAAC;IACrD,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,IAAI,KAAK,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAExC,IAAI,WAAW,IAAI,iBAAiB,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBAC7B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,IAAI,CAAC,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAChE,OAAO,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,MAAM,CAAC,CAAU;IACxB,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAC3C,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,4 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Dictionary v3 source-format JSON formatter.
|
|
3
|
+
*
|
|
4
|
+
* SD v3 uses bare `value` / `type` fields (no `$` prefix, that's the DTCG
|
|
5
|
+
* convention SD v4 adopted). Output is structurally similar to DTCG but
|
|
6
|
+
* without the dollar signs, and groups have no special meta β just
|
|
7
|
+
* nested objects.
|
|
8
|
+
*
|
|
9
|
+
* Output shape:
|
|
10
|
+
*
|
|
11
|
+
* {
|
|
12
|
+
* "color": {
|
|
13
|
+
* "primary": {
|
|
14
|
+
* "value": "#4085F2",
|
|
15
|
+
* "type": "color",
|
|
16
|
+
* "comment": "Primary brand color"
|
|
17
|
+
* },
|
|
18
|
+
* "brand": {
|
|
19
|
+
* "blue": { "value": "#0066FF", "type": "color" }
|
|
20
|
+
* }
|
|
21
|
+
* },
|
|
22
|
+
* "spacing": {
|
|
23
|
+
* "md": { "value": "16px", "type": "size" }
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* SD v3 type names differ slightly from DTCG:
|
|
28
|
+
*
|
|
29
|
+
* DTCG type β SD v3 type
|
|
30
|
+
* ----------------------------
|
|
31
|
+
* dimension β size (or spacing for spacing tokens)
|
|
32
|
+
* color β color
|
|
33
|
+
* fontFamily β string
|
|
34
|
+
* fontWeight β number
|
|
35
|
+
*
|
|
36
|
+
* Aliases use SD v3's `{path.to.token}` syntax (same as DTCG, which copied
|
|
37
|
+
* it from SD).
|
|
38
|
+
*
|
|
39
|
+
* For back-compat with cbds-components / blocks / czi-edu / eddie-design-system
|
|
40
|
+
* which still use SD v3's bare-key source format.
|
|
41
|
+
*/
|
|
1
42
|
import type { TokenDocument } from "../types.js";
|
|
2
43
|
import type { FormatOptions, FormatResult } from "./index.js";
|
|
3
|
-
export declare function formatStyleDictionaryV3(
|
|
44
|
+
export declare function formatStyleDictionaryV3(doc: TokenDocument, opts: FormatOptions): FormatResult;
|
|
4
45
|
//# sourceMappingURL=style-dictionary-v3.d.ts.map
|