@muloka/figma-console-mcp 0.5.0 → 0.5.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.
Files changed (111) hide show
  1. package/README.md +3 -1
  2. package/dist/core/port-discovery.d.ts +9 -0
  3. package/dist/core/port-discovery.d.ts.map +1 -1
  4. package/dist/core/port-discovery.js +40 -14
  5. package/dist/core/port-discovery.js.map +1 -1
  6. package/dist/core/websocket-connector.d.ts +2 -1
  7. package/dist/core/websocket-connector.d.ts.map +1 -1
  8. package/dist/core/websocket-connector.js +17 -2
  9. package/dist/core/websocket-connector.js.map +1 -1
  10. package/dist/core/websocket-server.d.ts +8 -1
  11. package/dist/core/websocket-server.d.ts.map +1 -1
  12. package/dist/core/websocket-server.js +18 -2
  13. package/dist/core/websocket-server.js.map +1 -1
  14. package/dist/core/write-tools.d.ts +3 -1
  15. package/dist/core/write-tools.d.ts.map +1 -1
  16. package/dist/core/write-tools.js +34 -14
  17. package/dist/core/write-tools.js.map +1 -1
  18. package/dist/local.d.ts +2 -1
  19. package/dist/local.d.ts.map +1 -1
  20. package/dist/local.js +10 -14
  21. package/dist/local.js.map +1 -1
  22. package/package.json +1 -1
  23. package/dist/apps/design-system-dashboard/mcp-app.html +0 -521
  24. package/dist/apps/token-browser/mcp-app.html +0 -410
  25. package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +0 -277
  26. package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +0 -357
  27. package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +0 -341
  28. package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +0 -230
  29. package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +0 -92
  30. package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +0 -308
  31. package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +0 -349
  32. package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +0 -40
  33. package/dist/cloudflare/apps/design-system-dashboard/server.js +0 -159
  34. package/dist/cloudflare/apps/token-browser/server.js +0 -136
  35. package/dist/cloudflare/browser-manager.js +0 -157
  36. package/dist/cloudflare/core/accessibility-tools.js +0 -361
  37. package/dist/cloudflare/core/annotation-tools.js +0 -230
  38. package/dist/cloudflare/core/cloud-websocket-connector.js +0 -419
  39. package/dist/cloudflare/core/cloud-websocket-relay.js +0 -198
  40. package/dist/cloudflare/core/comment-tools.js +0 -292
  41. package/dist/cloudflare/core/config.js +0 -153
  42. package/dist/cloudflare/core/console-monitor.js +0 -427
  43. package/dist/cloudflare/core/deep-component-tools.js +0 -128
  44. package/dist/cloudflare/core/design-code-tools.js +0 -2793
  45. package/dist/cloudflare/core/design-system-manifest.js +0 -265
  46. package/dist/cloudflare/core/design-system-tools.js +0 -882
  47. package/dist/cloudflare/core/diagnose-tool.js +0 -100
  48. package/dist/cloudflare/core/diff/changelog-formatter.js +0 -275
  49. package/dist/cloudflare/core/diff/diff-engine.js +0 -334
  50. package/dist/cloudflare/core/diff/property-compare.js +0 -36
  51. package/dist/cloudflare/core/diff/version-cache.js +0 -74
  52. package/dist/cloudflare/core/enrichment/enrichment-service.js +0 -374
  53. package/dist/cloudflare/core/enrichment/index.js +0 -7
  54. package/dist/cloudflare/core/enrichment/relationship-mapper.js +0 -351
  55. package/dist/cloudflare/core/enrichment/style-resolver.js +0 -346
  56. package/dist/cloudflare/core/figjam-tools.js +0 -547
  57. package/dist/cloudflare/core/figma-api.js +0 -509
  58. package/dist/cloudflare/core/figma-connector.js +0 -7
  59. package/dist/cloudflare/core/figma-reconstruction-spec.js +0 -402
  60. package/dist/cloudflare/core/figma-style-extractor.js +0 -311
  61. package/dist/cloudflare/core/figma-tools.js +0 -3353
  62. package/dist/cloudflare/core/identity.js +0 -96
  63. package/dist/cloudflare/core/library-tools.js +0 -580
  64. package/dist/cloudflare/core/logger.js +0 -53
  65. package/dist/cloudflare/core/port-discovery.js +0 -935
  66. package/dist/cloudflare/core/resolve-package-root.js +0 -11
  67. package/dist/cloudflare/core/slides-tools.js +0 -714
  68. package/dist/cloudflare/core/slot-tools.js +0 -334
  69. package/dist/cloudflare/core/snippet-injector.js +0 -96
  70. package/dist/cloudflare/core/tokens/alias-resolver.js +0 -205
  71. package/dist/cloudflare/core/tokens/config.js +0 -294
  72. package/dist/cloudflare/core/tokens/dialect.js +0 -232
  73. package/dist/cloudflare/core/tokens/figma-converter.js +0 -323
  74. package/dist/cloudflare/core/tokens/formatters/css-vars.js +0 -338
  75. package/dist/cloudflare/core/tokens/formatters/dtcg.js +0 -376
  76. package/dist/cloudflare/core/tokens/formatters/index.js +0 -45
  77. package/dist/cloudflare/core/tokens/formatters/json.js +0 -205
  78. package/dist/cloudflare/core/tokens/formatters/less.js +0 -4
  79. package/dist/cloudflare/core/tokens/formatters/scss.js +0 -258
  80. package/dist/cloudflare/core/tokens/formatters/stubs.js +0 -13
  81. package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +0 -213
  82. package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +0 -237
  83. package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +0 -335
  84. package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +0 -256
  85. package/dist/cloudflare/core/tokens/formatters/ts-module.js +0 -198
  86. package/dist/cloudflare/core/tokens/index.js +0 -16
  87. package/dist/cloudflare/core/tokens/parsers/css-vars.js +0 -4
  88. package/dist/cloudflare/core/tokens/parsers/dtcg.js +0 -280
  89. package/dist/cloudflare/core/tokens/parsers/index.js +0 -138
  90. package/dist/cloudflare/core/tokens/parsers/json.js +0 -7
  91. package/dist/cloudflare/core/tokens/parsers/scss.js +0 -4
  92. package/dist/cloudflare/core/tokens/parsers/stubs.js +0 -20
  93. package/dist/cloudflare/core/tokens/parsers/style-dictionary-v3.js +0 -4
  94. package/dist/cloudflare/core/tokens/parsers/tailwind-v3.js +0 -4
  95. package/dist/cloudflare/core/tokens/parsers/tailwind-v4.js +0 -4
  96. package/dist/cloudflare/core/tokens/parsers/tokens-studio.js +0 -4
  97. package/dist/cloudflare/core/tokens/schemas.js +0 -152
  98. package/dist/cloudflare/core/tokens/transforms/color.js +0 -12
  99. package/dist/cloudflare/core/tokens/transforms/index.js +0 -29
  100. package/dist/cloudflare/core/tokens/transforms/size.js +0 -7
  101. package/dist/cloudflare/core/tokens/types.js +0 -18
  102. package/dist/cloudflare/core/tokens-tools.js +0 -1788
  103. package/dist/cloudflare/core/types/design-code.js +0 -4
  104. package/dist/cloudflare/core/types/enriched.js +0 -5
  105. package/dist/cloudflare/core/types/index.js +0 -4
  106. package/dist/cloudflare/core/variable-resolver.js +0 -85
  107. package/dist/cloudflare/core/version-tools.js +0 -1199
  108. package/dist/cloudflare/core/websocket-connector.js +0 -436
  109. package/dist/cloudflare/core/websocket-server.js +0 -1009
  110. package/dist/cloudflare/core/write-tools.js +0 -2506
  111. package/dist/cloudflare/index.js +0 -3010
@@ -1,256 +0,0 @@
1
- /**
2
- * Tokens Studio for Figma JSON formatter.
3
- *
4
- * Tokens Studio uses a multi-file layout:
5
- *
6
- * $themes.json — array of theme definitions with selectedTokenSets
7
- * $metadata.json — list of token set names + tokenSetOrder
8
- * primitives.json — one file per token set
9
- * semantic.json
10
- * theme/light.json
11
- * theme/dark.json
12
- *
13
- * Each per-set file holds tokens with the Tokens Studio shape:
14
- *
15
- * {
16
- * "color": {
17
- * "primary": {
18
- * "value": "#4085F2",
19
- * "type": "color",
20
- * "description": "Primary brand color"
21
- * }
22
- * }
23
- * }
24
- *
25
- * Tokens Studio uses bare `value` / `type` (no `$` prefix — same as
26
- * Style Dictionary v3, which the plugin's format is based on). Aliases
27
- * use `{path.to.token}` syntax.
28
- *
29
- * `$themes.json` carries the Figma collection/mode bindings that make
30
- * Tokens Studio's "send to Figma" feature work — preserved here for
31
- * round-trip with Tokens Studio plugin users (notably Altitude).
32
- *
33
- * Output strategy:
34
- * - One file per TokenSet, named after the set (slugified).
35
- * - Multi-mode sets emit one file per (set, mode) pair (Tokens Studio
36
- * convention).
37
- * - `$metadata.json` enumerates the token set names in order.
38
- * - `$themes.json` builds a theme entry per mode with selectedTokenSets
39
- * and the figma-console-mcp metadata stamped onto it.
40
- */
41
- import { FIGMA_MCP_EXTENSION_KEY } from "../types.js";
42
- import { buildTokenIndex, referenceTargetPath } from "../alias-resolver.js";
43
- export function formatTokensStudio(doc, opts) {
44
- const warnings = [];
45
- const files = [];
46
- // Whole-document index so set-qualified alias references resolve to the
47
- // target token's own path (Tokens Studio references are set-relative).
48
- const tokenIndex = buildTokenIndex(doc, warnings);
49
- // Track which (setName, mode) → filename pairs exist so $metadata + $themes
50
- // can reference them.
51
- const setNamesByMode = [];
52
- // 1. Per-set per-mode token files.
53
- for (const set of doc.sets) {
54
- for (const mode of set.modes) {
55
- const fileSetName = set.modes.length > 1 ? `${slugify(set.name)}/${slugify(mode)}` : slugify(set.name);
56
- const filename = `${fileSetName}.json`;
57
- setNamesByMode.push({ setName: fileSetName, mode, filename });
58
- files.push({
59
- path: filename,
60
- content: renderSetFile(set, mode, tokenIndex, warnings),
61
- });
62
- }
63
- }
64
- // 2. $metadata.json — ordered list of token sets.
65
- const tokenSetOrder = setNamesByMode.map((e) => e.setName);
66
- files.push({
67
- path: "$metadata.json",
68
- content: JSON.stringify({ tokenSetOrder }, null, 2) + "\n",
69
- });
70
- // 3. $themes.json — one theme entry per mode, with figma-console-mcp
71
- // metadata so the Tokens Studio plugin's Figma sync features know
72
- // which Figma collection/mode each theme maps to.
73
- const themes = buildThemes(doc, setNamesByMode);
74
- files.push({
75
- path: "$themes.json",
76
- content: JSON.stringify(themes, null, 2) + "\n",
77
- });
78
- return { files, warnings };
79
- }
80
- function slugify(s) {
81
- return s
82
- .trim()
83
- .toLowerCase()
84
- .replace(/[^a-z0-9]+/g, "-")
85
- .replace(/^-+|-+$/g, "");
86
- }
87
- /**
88
- * Render a single set's tokens for a specific mode in Tokens Studio's
89
- * bare-key JSON format.
90
- */
91
- function renderSetFile(set, mode, tokenIndex, warnings) {
92
- const tree = {};
93
- for (const token of set.tokens) {
94
- const value = token.values[mode];
95
- if (!value)
96
- continue;
97
- const tsValue = tsValueFor(value, token, tokenIndex, warnings);
98
- if (tsValue === undefined)
99
- continue;
100
- // Walk path creating nested groups.
101
- let cursor = tree;
102
- for (let i = 0; i < token.path.length - 1; i++) {
103
- const segment = token.path[i];
104
- if (!cursor[segment] || typeof cursor[segment] !== "object") {
105
- cursor[segment] = {};
106
- }
107
- cursor = cursor[segment];
108
- }
109
- const leafKey = token.path[token.path.length - 1];
110
- const leaf = {
111
- value: tsValue,
112
- type: tsTypeFor(token),
113
- };
114
- if (token.description)
115
- leaf.description = token.description;
116
- cursor[leafKey] = leaf;
117
- }
118
- return JSON.stringify(sortKeys(tree), null, 2) + "\n";
119
- }
120
- /**
121
- * Build the $themes.json structure. One theme entry per (set, mode) tuple.
122
- * For multi-mode sets, the theme name combines set + mode.
123
- */
124
- function buildThemes(doc, setNamesByMode) {
125
- const themes = [];
126
- // Group by mode so each mode gets one theme entry pulling in the
127
- // appropriate set files.
128
- const allModes = new Set();
129
- for (const e of setNamesByMode)
130
- allModes.add(e.mode);
131
- for (const mode of allModes) {
132
- const selectedTokenSets = {};
133
- for (const e of setNamesByMode) {
134
- if (e.mode === mode) {
135
- selectedTokenSets[e.setName] = "enabled";
136
- }
137
- else {
138
- // Other-mode sets are disabled in this theme (Tokens Studio
139
- // convention: only one mode of each set is "enabled" per theme).
140
- selectedTokenSets[e.setName] = "source";
141
- }
142
- }
143
- // Find the Figma collection + mode IDs for this mode (preserved
144
- // from the export converter's $extensions metadata).
145
- const figmaCollectionId = findCollectionIdForMode(doc, mode);
146
- const figmaModeId = findModeId(doc, mode);
147
- const theme = {
148
- id: `${slugify(mode)}-${Math.random().toString(36).slice(2, 10)}`,
149
- name: mode,
150
- selectedTokenSets,
151
- };
152
- // Stash Figma metadata for round-trip with Tokens Studio plugin.
153
- if (figmaCollectionId)
154
- theme.$figmaCollectionId = figmaCollectionId;
155
- if (figmaModeId)
156
- theme.$figmaModeId = figmaModeId;
157
- // Also stash our own extension namespace for tools that read it.
158
- if (figmaCollectionId || figmaModeId) {
159
- theme.$extensions = {
160
- [FIGMA_MCP_EXTENSION_KEY]: {
161
- ...(figmaCollectionId ? { figmaCollectionId } : {}),
162
- ...(figmaModeId ? { figmaModeId } : {}),
163
- },
164
- };
165
- }
166
- themes.push(theme);
167
- }
168
- return themes;
169
- }
170
- function findCollectionIdForMode(doc, _mode) {
171
- // The mode-to-collection mapping requires knowing which set the mode
172
- // belongs to. For simplicity, return the first collection ID we find;
173
- // multi-collection support requires per-set theme entries which the
174
- // Tokens Studio plugin does support.
175
- for (const set of doc.sets) {
176
- if (set.meta?.figmaCollectionId)
177
- return set.meta.figmaCollectionId;
178
- }
179
- return undefined;
180
- }
181
- function findModeId(_doc, _mode) {
182
- // We don't carry Figma's modeId through the internal model in this
183
- // version — it's computed lazily during apply via the
184
- // (collectionId, modeName) lookup map. Future enhancement: stash the
185
- // modeId in TokenSet.meta during export so it round-trips through
186
- // Tokens Studio.
187
- return undefined;
188
- }
189
- /**
190
- * Map DTCG types to Tokens Studio's type names. Tokens Studio uses SD-style
191
- * type names with some additions (e.g. "sizing", "borderRadius",
192
- * "boxShadow", "typography", "opacity", "fontFamilies", "fontWeights").
193
- */
194
- function tsTypeFor(token) {
195
- if (token.type === "color")
196
- return "color";
197
- if (token.type === "fontFamily")
198
- return "fontFamilies";
199
- if (token.type === "fontWeight")
200
- return "fontWeights";
201
- if (token.type === "typography")
202
- return "typography";
203
- if (token.type === "shadow")
204
- return "boxShadow";
205
- if (token.type === "duration")
206
- return "time";
207
- if (token.type === "dimension") {
208
- const lower = token.path[0]?.toLowerCase() ?? "";
209
- if (lower.includes("border") || lower.includes("radius"))
210
- return "borderRadius";
211
- if (lower.startsWith("space") || lower.startsWith("spacing"))
212
- return "spacing";
213
- if (lower.includes("size") || lower.includes("width") || lower.includes("height"))
214
- return "sizing";
215
- return "sizing";
216
- }
217
- return token.type;
218
- }
219
- function tsValueFor(value, token, tokenIndex, warnings) {
220
- if (value.reference) {
221
- const bare = value.reference.replace(/^\{|\}$/g, "");
222
- if (bare.startsWith("__library:") || bare === "unknown") {
223
- warnings.push(`Skipped ${token.path.join(".")} in Tokens Studio — cross-library alias unresolved.`);
224
- return undefined;
225
- }
226
- // Tokens Studio references are token-path based (no set qualifier) —
227
- // resolve set-qualified references to the target token's own path.
228
- return `{${referenceTargetPath(value.reference, tokenIndex).join(".")}}`;
229
- }
230
- if (value.literal === undefined || value.literal === null)
231
- return undefined;
232
- if (typeof value.literal === "number" && token.type === "dimension") {
233
- return `${value.literal}px`;
234
- }
235
- return value.literal;
236
- }
237
- function sortKeys(node) {
238
- if (node === null || typeof node !== "object" || Array.isArray(node)) {
239
- return node;
240
- }
241
- const obj = node;
242
- const sorted = {};
243
- // $-prefixed keys first (matches Tokens Studio convention), then alphabetical.
244
- const keys = Object.keys(obj).sort((a, b) => {
245
- const aDollar = a.startsWith("$");
246
- const bDollar = b.startsWith("$");
247
- if (aDollar && !bDollar)
248
- return -1;
249
- if (!aDollar && bDollar)
250
- return 1;
251
- return a.localeCompare(b);
252
- });
253
- for (const k of keys)
254
- sorted[k] = sortKeys(obj[k]);
255
- return sorted;
256
- }
@@ -1,198 +0,0 @@
1
- /**
2
- * TypeScript module formatter.
3
- *
4
- * Output shape:
5
- *
6
- * // tokens.ts
7
- * export const tokens = {
8
- * color: {
9
- * primary: "#4085F2",
10
- * brand: { primary: "#FF00AA" }
11
- * },
12
- * spacing: {
13
- * md: "16px"
14
- * }
15
- * } as const;
16
- *
17
- * export type Tokens = typeof tokens;
18
- *
19
- * Multi-mode tokens emit as nested objects keyed by mode name:
20
- *
21
- * export const tokens = {
22
- * mode: {
23
- * primary: { Light: "#FFFFFF", Dark: "#000000" }
24
- * }
25
- * } as const;
26
- *
27
- * Aliases get resolved at write time to the literal value (TypeScript
28
- * can't natively express references). Cross-library aliases get emitted
29
- * as `null` with a "TODO: cross-library alias unresolved" comment so
30
- * consumers see the gap.
31
- */
32
- import { buildTokenIndex, resolveAliasChain } from "../alias-resolver.js";
33
- export function formatTsModule(doc, opts) {
34
- const warnings = [];
35
- const files = [];
36
- const splitByCollection = opts.target.splitByCollection ?? false;
37
- // splitByMode doesn't make conceptual sense for a TypeScript module
38
- // (the value is held in-memory at runtime, not selected by CSS cascade).
39
- // TypeScript modules can't natively express alias references — runtime
40
- // code reading tokens.color.X gets a string at runtime, no resolution
41
- // logic. Build a document-wide token index so aliases resolve to their
42
- // literal target at export time. The index spans every set even when
43
- // splitByCollection writes single-set files, because aliases often
44
- // cross set boundaries (semantic → primitives).
45
- const tokenIndex = buildTokenIndex(doc);
46
- if (splitByCollection) {
47
- for (const set of doc.sets) {
48
- files.push({
49
- path: filenameFor(opts, set),
50
- content: renderTsFile([set], opts, tokenIndex, warnings),
51
- });
52
- }
53
- }
54
- else {
55
- files.push({
56
- path: filenameFor(opts),
57
- content: renderTsFile(doc.sets, opts, tokenIndex, warnings),
58
- });
59
- }
60
- return { files, warnings };
61
- }
62
- function filenameFor(opts, set) {
63
- if (opts.target.filename)
64
- return opts.target.filename;
65
- if (set)
66
- return `${slugify(set.name)}.tokens.ts`;
67
- return "tokens.ts";
68
- }
69
- function slugify(s) {
70
- return s
71
- .trim()
72
- .toLowerCase()
73
- .replace(/[^a-z0-9]+/g, "-")
74
- .replace(/^-+|-+$/g, "");
75
- }
76
- /**
77
- * Convert a path segment to a valid JS identifier or quoted-key form.
78
- * Numeric leading chars, hyphens, etc. → quoted string key.
79
- */
80
- function jsKey(segment) {
81
- if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(segment))
82
- return segment;
83
- return JSON.stringify(segment);
84
- }
85
- function renderTsFile(sets, opts, tokenIndex, warnings) {
86
- const prefix = opts.target.prefix ?? "";
87
- const lines = [];
88
- lines.push("/**");
89
- lines.push(" * Generated by figma-console-mcp — do not edit by hand.");
90
- lines.push(" * Regenerate with: figma_export_tokens (or your npm tokens:export script)");
91
- lines.push(" */");
92
- lines.push("");
93
- const constName = prefix
94
- ? `${prefix.replace(/-+$/, "").replace(/-(\w)/g, (_, c) => c.toUpperCase())}Tokens`
95
- : "tokens";
96
- // Build the nested object structure by walking each set's tokens.
97
- const tree = {};
98
- for (const set of sets) {
99
- for (const token of set.tokens) {
100
- writeTokenIntoTree(tree, token, set, tokenIndex, warnings);
101
- }
102
- }
103
- lines.push(`export const ${constName} = ${renderTree(tree, 0)} as const;`);
104
- lines.push("");
105
- lines.push(`export type ${constName[0].toUpperCase()}${constName.slice(1)} = typeof ${constName};`);
106
- lines.push("");
107
- return lines.join("\n");
108
- }
109
- function writeTokenIntoTree(tree, token, set, tokenIndex, warnings) {
110
- let cursor = tree;
111
- for (let i = 0; i < token.path.length - 1; i++) {
112
- const segment = token.path[i];
113
- let next = cursor[segment];
114
- if (!next || isLeaf(next)) {
115
- next = {};
116
- cursor[segment] = next;
117
- }
118
- cursor = next;
119
- }
120
- const leafKey = token.path[token.path.length - 1];
121
- const isMulti = set.modes.length > 1;
122
- const resolvedValues = {};
123
- for (const [modeName, value] of Object.entries(token.values)) {
124
- let effective = value;
125
- if (value.reference) {
126
- effective = resolveAliasChain(value, modeName, tokenIndex);
127
- if (!effective) {
128
- const bare = value.reference.replace(/^\{|\}$/g, "");
129
- const reason = bare.startsWith("__library:") || bare === "unknown"
130
- ? "cross-library alias"
131
- : "alias target not found";
132
- warnings.push(`Skipped ${token.path.join(".")} (mode "${modeName}") in TS module — ${reason}: ${value.reference}.`);
133
- resolvedValues[modeName] = null;
134
- continue;
135
- }
136
- }
137
- if (!effective || effective.literal === undefined || effective.literal === null)
138
- continue;
139
- resolvedValues[modeName] = formatLiteral(effective.literal, token.type);
140
- }
141
- cursor[leafKey] = {
142
- __leaf: true,
143
- values: resolvedValues,
144
- type: token.type,
145
- isMultiMode: isMulti,
146
- description: token.description,
147
- };
148
- }
149
- function isLeaf(node) {
150
- return node.__leaf === true;
151
- }
152
- function renderTree(tree, indent) {
153
- const ind = " ".repeat(indent);
154
- const innerInd = " ".repeat(indent + 1);
155
- const entries = [];
156
- for (const [key, value] of Object.entries(tree)) {
157
- const k = jsKey(key);
158
- if (isLeaf(value)) {
159
- const leaf = value;
160
- if (leaf.isMultiMode) {
161
- // Emit as { Mode: value } object
162
- const modeEntries = [];
163
- for (const [m, v] of Object.entries(leaf.values)) {
164
- modeEntries.push(`${jsKey(m)}: ${renderValue(v)}`);
165
- }
166
- entries.push(`${innerInd}${k}: { ${modeEntries.join(", ")} }`);
167
- }
168
- else {
169
- // Single-mode: emit value directly
170
- const onlyValue = Object.values(leaf.values)[0];
171
- entries.push(`${innerInd}${k}: ${renderValue(onlyValue)}`);
172
- }
173
- }
174
- else {
175
- entries.push(`${innerInd}${k}: ${renderTree(value, indent + 1)}`);
176
- }
177
- }
178
- if (entries.length === 0)
179
- return "{}";
180
- return `{\n${entries.join(",\n")},\n${ind}}`;
181
- }
182
- function renderValue(v) {
183
- if (v === null)
184
- return "null /* TODO: cross-library alias unresolved */";
185
- if (typeof v === "string")
186
- return JSON.stringify(v);
187
- if (typeof v === "number" || typeof v === "boolean")
188
- return String(v);
189
- return JSON.stringify(v);
190
- }
191
- function formatLiteral(value, type) {
192
- if (typeof value === "number") {
193
- if (type === "dimension")
194
- return `${value}px`;
195
- return value;
196
- }
197
- return value;
198
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Public surface of the token sync engine.
3
- *
4
- * Re-exports the canonical types, the parser/formatter dispatchers, the
5
- * config loader, the alias resolver, and the Figma converter. External
6
- * callers (tools, tests) should import from here rather than reaching into
7
- * subdirectories.
8
- */
9
- export { FIGMA_MCP_EXTENSION_KEY } from "./types.js";
10
- export { TokensConfigSchema, loadTokensConfig, findTokensConfig, DEFAULT_TOKENS_CONFIG, buildSuggestedScaffold, resolveOutputTargets, resolveConflictStrategy, } from "./config.js";
11
- export { ExportTokensInputSchema, ImportTokensInputSchema, ExportFormatSchema, ImportFormatSchema, SyncStrategySchema, ConflictResolutionSchema, } from "./schemas.js";
12
- export { parse, detectFormat, } from "./parsers/index.js";
13
- export { format, } from "./formatters/index.js";
14
- export { buildTokenIndex, buildTokenLookup, resolveReference, resolveAliasChain, validateAliases, formatDtcgReference, parseDtcgReference, referenceTargetPath, slugifySetName, } from "./alias-resolver.js";
15
- export { convertFigmaVariablesToDocument, } from "./figma-converter.js";
16
- export { canonicalizeTokenValueForComparison, colorLiteralToCanonicalHex, colorValueTo2025, dimensionLiteralTo2025, hexToRawRgba, stripRawColorFromValues, clamp01, } from "./dialect.js";
@@ -1,4 +0,0 @@
1
- import { TokenFormatNotImplementedError } from "./stubs.js";
2
- export function parseCssVars(_input) {
3
- throw new TokenFormatNotImplementedError("CSS custom properties", "parser");
4
- }