@muloka/figma-console-mcp 0.1.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/LICENSE +21 -0
- package/README.md +898 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.js +278 -0
- package/dist/apps/design-system-dashboard/scoring/accessibility.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.d.ts +29 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.js +358 -0
- package/dist/apps/design-system-dashboard/scoring/component-metadata.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.js +342 -0
- package/dist/apps/design-system-dashboard/scoring/consistency.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.js +231 -0
- package/dist/apps/design-system-dashboard/scoring/coverage.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/engine.d.ts +27 -0
- package/dist/apps/design-system-dashboard/scoring/engine.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/engine.js +93 -0
- package/dist/apps/design-system-dashboard/scoring/engine.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.js +309 -0
- package/dist/apps/design-system-dashboard/scoring/naming-semantics.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts +14 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js +350 -0
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/types.d.ts +89 -0
- package/dist/apps/design-system-dashboard/scoring/types.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/scoring/types.js +41 -0
- package/dist/apps/design-system-dashboard/scoring/types.js.map +1 -0
- package/dist/apps/design-system-dashboard/server.d.ts +24 -0
- package/dist/apps/design-system-dashboard/server.d.ts.map +1 -0
- package/dist/apps/design-system-dashboard/server.js +160 -0
- package/dist/apps/design-system-dashboard/server.js.map +1 -0
- package/dist/apps/token-browser/server.d.ts +26 -0
- package/dist/apps/token-browser/server.d.ts.map +1 -0
- package/dist/apps/token-browser/server.js +137 -0
- package/dist/apps/token-browser/server.js.map +1 -0
- package/dist/browser/base.d.ts +58 -0
- package/dist/browser/base.d.ts.map +1 -0
- package/dist/browser/base.js +6 -0
- package/dist/browser/base.js.map +1 -0
- package/dist/browser/local.d.ts +87 -0
- package/dist/browser/local.d.ts.map +1 -0
- package/dist/browser/local.js +318 -0
- package/dist/browser/local.js.map +1 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +277 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +357 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +341 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +230 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +92 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +308 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +349 -0
- package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +40 -0
- package/dist/cloudflare/apps/design-system-dashboard/server.js +159 -0
- package/dist/cloudflare/apps/token-browser/server.js +136 -0
- package/dist/cloudflare/browser-manager.js +157 -0
- package/dist/cloudflare/core/accessibility-tools.js +361 -0
- package/dist/cloudflare/core/annotation-tools.js +230 -0
- package/dist/cloudflare/core/cloud-websocket-connector.js +419 -0
- package/dist/cloudflare/core/cloud-websocket-relay.js +198 -0
- package/dist/cloudflare/core/comment-tools.js +292 -0
- package/dist/cloudflare/core/config.js +153 -0
- package/dist/cloudflare/core/console-monitor.js +427 -0
- package/dist/cloudflare/core/deep-component-tools.js +128 -0
- package/dist/cloudflare/core/design-code-tools.js +2793 -0
- package/dist/cloudflare/core/design-system-manifest.js +265 -0
- package/dist/cloudflare/core/design-system-tools.js +882 -0
- package/dist/cloudflare/core/diagnose-tool.js +100 -0
- package/dist/cloudflare/core/diff/changelog-formatter.js +275 -0
- package/dist/cloudflare/core/diff/diff-engine.js +334 -0
- package/dist/cloudflare/core/diff/property-compare.js +36 -0
- package/dist/cloudflare/core/diff/version-cache.js +74 -0
- package/dist/cloudflare/core/enrichment/enrichment-service.js +374 -0
- package/dist/cloudflare/core/enrichment/index.js +7 -0
- package/dist/cloudflare/core/enrichment/relationship-mapper.js +351 -0
- package/dist/cloudflare/core/enrichment/style-resolver.js +346 -0
- package/dist/cloudflare/core/figjam-tools.js +547 -0
- package/dist/cloudflare/core/figma-api.js +509 -0
- package/dist/cloudflare/core/figma-connector.js +7 -0
- package/dist/cloudflare/core/figma-reconstruction-spec.js +402 -0
- package/dist/cloudflare/core/figma-style-extractor.js +311 -0
- package/dist/cloudflare/core/figma-tools.js +3302 -0
- package/dist/cloudflare/core/identity.js +96 -0
- package/dist/cloudflare/core/library-tools.js +580 -0
- package/dist/cloudflare/core/logger.js +53 -0
- package/dist/cloudflare/core/port-discovery.js +935 -0
- package/dist/cloudflare/core/resolve-package-root.js +11 -0
- package/dist/cloudflare/core/slides-tools.js +714 -0
- package/dist/cloudflare/core/slot-tools.js +334 -0
- package/dist/cloudflare/core/snippet-injector.js +96 -0
- package/dist/cloudflare/core/tokens/alias-resolver.js +205 -0
- package/dist/cloudflare/core/tokens/config.js +294 -0
- package/dist/cloudflare/core/tokens/dialect.js +232 -0
- package/dist/cloudflare/core/tokens/figma-converter.js +323 -0
- package/dist/cloudflare/core/tokens/formatters/css-vars.js +338 -0
- package/dist/cloudflare/core/tokens/formatters/dtcg.js +376 -0
- package/dist/cloudflare/core/tokens/formatters/index.js +45 -0
- package/dist/cloudflare/core/tokens/formatters/json.js +205 -0
- package/dist/cloudflare/core/tokens/formatters/less.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/scss.js +258 -0
- package/dist/cloudflare/core/tokens/formatters/stubs.js +13 -0
- package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +213 -0
- package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +237 -0
- package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +335 -0
- package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +256 -0
- package/dist/cloudflare/core/tokens/formatters/ts-module.js +198 -0
- package/dist/cloudflare/core/tokens/index.js +16 -0
- package/dist/cloudflare/core/tokens/parsers/css-vars.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/dtcg.js +280 -0
- package/dist/cloudflare/core/tokens/parsers/index.js +138 -0
- package/dist/cloudflare/core/tokens/parsers/json.js +7 -0
- package/dist/cloudflare/core/tokens/parsers/scss.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/stubs.js +20 -0
- package/dist/cloudflare/core/tokens/parsers/style-dictionary-v3.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/tailwind-v3.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/tailwind-v4.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/tokens-studio.js +4 -0
- package/dist/cloudflare/core/tokens/schemas.js +152 -0
- package/dist/cloudflare/core/tokens/transforms/color.js +12 -0
- package/dist/cloudflare/core/tokens/transforms/index.js +29 -0
- package/dist/cloudflare/core/tokens/transforms/size.js +7 -0
- package/dist/cloudflare/core/tokens/types.js +18 -0
- package/dist/cloudflare/core/tokens-tools.js +1788 -0
- package/dist/cloudflare/core/types/design-code.js +4 -0
- package/dist/cloudflare/core/types/enriched.js +5 -0
- package/dist/cloudflare/core/types/index.js +4 -0
- package/dist/cloudflare/core/variable-resolver.js +85 -0
- package/dist/cloudflare/core/version-tools.js +1199 -0
- package/dist/cloudflare/core/websocket-connector.js +436 -0
- package/dist/cloudflare/core/websocket-server.js +956 -0
- package/dist/cloudflare/core/write-tools.js +2506 -0
- package/dist/cloudflare/index.js +3010 -0
- package/dist/core/accessibility-tools.d.ts +21 -0
- package/dist/core/accessibility-tools.d.ts.map +1 -0
- package/dist/core/accessibility-tools.js +362 -0
- package/dist/core/accessibility-tools.js.map +1 -0
- package/dist/core/annotation-tools.d.ts +14 -0
- package/dist/core/annotation-tools.d.ts.map +1 -0
- package/dist/core/annotation-tools.js +231 -0
- package/dist/core/annotation-tools.js.map +1 -0
- package/dist/core/comment-tools.d.ts +11 -0
- package/dist/core/comment-tools.d.ts.map +1 -0
- package/dist/core/comment-tools.js +293 -0
- package/dist/core/comment-tools.js.map +1 -0
- package/dist/core/config.d.ts +17 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +154 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/console-monitor.d.ts +82 -0
- package/dist/core/console-monitor.d.ts.map +1 -0
- package/dist/core/console-monitor.js +428 -0
- package/dist/core/console-monitor.js.map +1 -0
- package/dist/core/deep-component-tools.d.ts +14 -0
- package/dist/core/deep-component-tools.d.ts.map +1 -0
- package/dist/core/deep-component-tools.js +129 -0
- package/dist/core/deep-component-tools.js.map +1 -0
- package/dist/core/design-code-tools.d.ts +116 -0
- package/dist/core/design-code-tools.d.ts.map +1 -0
- package/dist/core/design-code-tools.js +2794 -0
- package/dist/core/design-code-tools.js.map +1 -0
- package/dist/core/design-system-manifest.d.ts +273 -0
- package/dist/core/design-system-manifest.d.ts.map +1 -0
- package/dist/core/design-system-manifest.js +266 -0
- package/dist/core/design-system-manifest.js.map +1 -0
- package/dist/core/design-system-tools.d.ts +67 -0
- package/dist/core/design-system-tools.d.ts.map +1 -0
- package/dist/core/design-system-tools.js +883 -0
- package/dist/core/design-system-tools.js.map +1 -0
- package/dist/core/diagnose-tool.d.ts +41 -0
- package/dist/core/diagnose-tool.d.ts.map +1 -0
- package/dist/core/diagnose-tool.js +101 -0
- package/dist/core/diagnose-tool.js.map +1 -0
- package/dist/core/diff/changelog-formatter.d.ts +35 -0
- package/dist/core/diff/changelog-formatter.d.ts.map +1 -0
- package/dist/core/diff/changelog-formatter.js +276 -0
- package/dist/core/diff/changelog-formatter.js.map +1 -0
- package/dist/core/diff/diff-engine.d.ts +127 -0
- package/dist/core/diff/diff-engine.d.ts.map +1 -0
- package/dist/core/diff/diff-engine.js +335 -0
- package/dist/core/diff/diff-engine.js.map +1 -0
- package/dist/core/diff/property-compare.d.ts +19 -0
- package/dist/core/diff/property-compare.d.ts.map +1 -0
- package/dist/core/diff/property-compare.js +37 -0
- package/dist/core/diff/property-compare.js.map +1 -0
- package/dist/core/diff/version-cache.d.ts +40 -0
- package/dist/core/diff/version-cache.d.ts.map +1 -0
- package/dist/core/diff/version-cache.js +75 -0
- package/dist/core/diff/version-cache.js.map +1 -0
- package/dist/core/enrichment/enrichment-service.d.ts +52 -0
- package/dist/core/enrichment/enrichment-service.d.ts.map +1 -0
- package/dist/core/enrichment/enrichment-service.js +375 -0
- package/dist/core/enrichment/enrichment-service.js.map +1 -0
- package/dist/core/enrichment/index.d.ts +8 -0
- package/dist/core/enrichment/index.d.ts.map +1 -0
- package/dist/core/enrichment/index.js +8 -0
- package/dist/core/enrichment/index.js.map +1 -0
- package/dist/core/enrichment/relationship-mapper.d.ts +106 -0
- package/dist/core/enrichment/relationship-mapper.d.ts.map +1 -0
- package/dist/core/enrichment/relationship-mapper.js +352 -0
- package/dist/core/enrichment/relationship-mapper.js.map +1 -0
- package/dist/core/enrichment/style-resolver.d.ts +85 -0
- package/dist/core/enrichment/style-resolver.d.ts.map +1 -0
- package/dist/core/enrichment/style-resolver.js +347 -0
- package/dist/core/enrichment/style-resolver.js.map +1 -0
- package/dist/core/figjam-tools.d.ts +8 -0
- package/dist/core/figjam-tools.d.ts.map +1 -0
- package/dist/core/figjam-tools.js +548 -0
- package/dist/core/figjam-tools.js.map +1 -0
- package/dist/core/figma-api.d.ts +254 -0
- package/dist/core/figma-api.d.ts.map +1 -0
- package/dist/core/figma-api.js +510 -0
- package/dist/core/figma-api.js.map +1 -0
- package/dist/core/figma-connector.d.ts +214 -0
- package/dist/core/figma-connector.d.ts.map +1 -0
- package/dist/core/figma-connector.js +8 -0
- package/dist/core/figma-connector.js.map +1 -0
- package/dist/core/figma-desktop-connector.d.ts +312 -0
- package/dist/core/figma-desktop-connector.d.ts.map +1 -0
- package/dist/core/figma-desktop-connector.js +1298 -0
- package/dist/core/figma-desktop-connector.js.map +1 -0
- package/dist/core/figma-reconstruction-spec.d.ts +166 -0
- package/dist/core/figma-reconstruction-spec.d.ts.map +1 -0
- package/dist/core/figma-reconstruction-spec.js +403 -0
- package/dist/core/figma-reconstruction-spec.js.map +1 -0
- package/dist/core/figma-style-extractor.d.ts +76 -0
- package/dist/core/figma-style-extractor.d.ts.map +1 -0
- package/dist/core/figma-style-extractor.js +312 -0
- package/dist/core/figma-style-extractor.js.map +1 -0
- package/dist/core/figma-tools.d.ts +22 -0
- package/dist/core/figma-tools.d.ts.map +1 -0
- package/dist/core/figma-tools.js +3303 -0
- package/dist/core/figma-tools.js.map +1 -0
- package/dist/core/identity.d.ts +41 -0
- package/dist/core/identity.d.ts.map +1 -0
- package/dist/core/identity.js +97 -0
- package/dist/core/identity.js.map +1 -0
- package/dist/core/library-tools.d.ts +17 -0
- package/dist/core/library-tools.d.ts.map +1 -0
- package/dist/core/library-tools.js +581 -0
- package/dist/core/library-tools.js.map +1 -0
- package/dist/core/logger.d.ts +22 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +54 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/port-discovery.d.ts +211 -0
- package/dist/core/port-discovery.d.ts.map +1 -0
- package/dist/core/port-discovery.js +936 -0
- package/dist/core/port-discovery.js.map +1 -0
- package/dist/core/resolve-package-root.d.ts +2 -0
- package/dist/core/resolve-package-root.d.ts.map +1 -0
- package/dist/core/resolve-package-root.js +12 -0
- package/dist/core/resolve-package-root.js.map +1 -0
- package/dist/core/slides-tools.d.ts +8 -0
- package/dist/core/slides-tools.d.ts.map +1 -0
- package/dist/core/slides-tools.js +715 -0
- package/dist/core/slides-tools.js.map +1 -0
- package/dist/core/slot-tools.d.ts +7 -0
- package/dist/core/slot-tools.d.ts.map +1 -0
- package/dist/core/slot-tools.js +335 -0
- package/dist/core/slot-tools.js.map +1 -0
- package/dist/core/snippet-injector.d.ts +24 -0
- package/dist/core/snippet-injector.d.ts.map +1 -0
- package/dist/core/snippet-injector.js +97 -0
- package/dist/core/snippet-injector.js.map +1 -0
- package/dist/core/tokens/alias-resolver.d.ts +97 -0
- package/dist/core/tokens/alias-resolver.d.ts.map +1 -0
- package/dist/core/tokens/alias-resolver.js +206 -0
- package/dist/core/tokens/alias-resolver.js.map +1 -0
- package/dist/core/tokens/config.d.ts +380 -0
- package/dist/core/tokens/config.d.ts.map +1 -0
- package/dist/core/tokens/config.js +295 -0
- package/dist/core/tokens/config.js.map +1 -0
- 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 +102 -0
- package/dist/core/tokens/figma-converter.d.ts.map +1 -0
- package/dist/core/tokens/figma-converter.js +324 -0
- package/dist/core/tokens/figma-converter.js.map +1 -0
- package/dist/core/tokens/formatters/css-vars.d.ts +24 -0
- package/dist/core/tokens/formatters/css-vars.d.ts.map +1 -0
- package/dist/core/tokens/formatters/css-vars.js +339 -0
- package/dist/core/tokens/formatters/css-vars.js.map +1 -0
- package/dist/core/tokens/formatters/dtcg.d.ts +28 -0
- package/dist/core/tokens/formatters/dtcg.d.ts.map +1 -0
- package/dist/core/tokens/formatters/dtcg.js +377 -0
- package/dist/core/tokens/formatters/dtcg.js.map +1 -0
- package/dist/core/tokens/formatters/index.d.ts +30 -0
- package/dist/core/tokens/formatters/index.d.ts.map +1 -0
- package/dist/core/tokens/formatters/index.js +46 -0
- package/dist/core/tokens/formatters/index.js.map +1 -0
- package/dist/core/tokens/formatters/json.d.ts +37 -0
- package/dist/core/tokens/formatters/json.d.ts.map +1 -0
- package/dist/core/tokens/formatters/json.js +206 -0
- package/dist/core/tokens/formatters/json.js.map +1 -0
- package/dist/core/tokens/formatters/less.d.ts +4 -0
- package/dist/core/tokens/formatters/less.d.ts.map +1 -0
- package/dist/core/tokens/formatters/less.js +5 -0
- package/dist/core/tokens/formatters/less.js.map +1 -0
- package/dist/core/tokens/formatters/scss.d.ts +26 -0
- package/dist/core/tokens/formatters/scss.d.ts.map +1 -0
- package/dist/core/tokens/formatters/scss.js +259 -0
- package/dist/core/tokens/formatters/scss.js.map +1 -0
- package/dist/core/tokens/formatters/stubs.d.ts +9 -0
- package/dist/core/tokens/formatters/stubs.d.ts.map +1 -0
- package/dist/core/tokens/formatters/stubs.js +14 -0
- package/dist/core/tokens/formatters/stubs.js.map +1 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts +45 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts.map +1 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.js +214 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.js.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v3.d.ts +37 -0
- package/dist/core/tokens/formatters/tailwind-v3.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v3.js +238 -0
- package/dist/core/tokens/formatters/tailwind-v3.js.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v4.d.ts +41 -0
- package/dist/core/tokens/formatters/tailwind-v4.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v4.js +336 -0
- package/dist/core/tokens/formatters/tailwind-v4.js.map +1 -0
- package/dist/core/tokens/formatters/tokens-studio.d.ts +44 -0
- package/dist/core/tokens/formatters/tokens-studio.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tokens-studio.js +257 -0
- package/dist/core/tokens/formatters/tokens-studio.js.map +1 -0
- package/dist/core/tokens/formatters/ts-module.d.ts +35 -0
- package/dist/core/tokens/formatters/ts-module.d.ts.map +1 -0
- package/dist/core/tokens/formatters/ts-module.js +199 -0
- package/dist/core/tokens/formatters/ts-module.js.map +1 -0
- package/dist/core/tokens/index.d.ts +18 -0
- package/dist/core/tokens/index.d.ts.map +1 -0
- package/dist/core/tokens/index.js +17 -0
- package/dist/core/tokens/index.js.map +1 -0
- package/dist/core/tokens/parsers/css-vars.d.ts +3 -0
- package/dist/core/tokens/parsers/css-vars.d.ts.map +1 -0
- package/dist/core/tokens/parsers/css-vars.js +5 -0
- package/dist/core/tokens/parsers/css-vars.js.map +1 -0
- package/dist/core/tokens/parsers/dtcg.d.ts +21 -0
- package/dist/core/tokens/parsers/dtcg.d.ts.map +1 -0
- package/dist/core/tokens/parsers/dtcg.js +281 -0
- package/dist/core/tokens/parsers/dtcg.js.map +1 -0
- package/dist/core/tokens/parsers/index.d.ts +37 -0
- package/dist/core/tokens/parsers/index.d.ts.map +1 -0
- package/dist/core/tokens/parsers/index.js +139 -0
- package/dist/core/tokens/parsers/index.js.map +1 -0
- package/dist/core/tokens/parsers/json.d.ts +4 -0
- package/dist/core/tokens/parsers/json.d.ts.map +1 -0
- package/dist/core/tokens/parsers/json.js +8 -0
- package/dist/core/tokens/parsers/json.js.map +1 -0
- package/dist/core/tokens/parsers/scss.d.ts +3 -0
- package/dist/core/tokens/parsers/scss.d.ts.map +1 -0
- package/dist/core/tokens/parsers/scss.js +5 -0
- package/dist/core/tokens/parsers/scss.js.map +1 -0
- package/dist/core/tokens/parsers/stubs.d.ts +15 -0
- package/dist/core/tokens/parsers/stubs.d.ts.map +1 -0
- package/dist/core/tokens/parsers/stubs.js +21 -0
- package/dist/core/tokens/parsers/stubs.js.map +1 -0
- package/dist/core/tokens/parsers/style-dictionary-v3.d.ts +3 -0
- package/dist/core/tokens/parsers/style-dictionary-v3.d.ts.map +1 -0
- package/dist/core/tokens/parsers/style-dictionary-v3.js +5 -0
- package/dist/core/tokens/parsers/style-dictionary-v3.js.map +1 -0
- package/dist/core/tokens/parsers/tailwind-v3.d.ts +3 -0
- package/dist/core/tokens/parsers/tailwind-v3.d.ts.map +1 -0
- package/dist/core/tokens/parsers/tailwind-v3.js +5 -0
- package/dist/core/tokens/parsers/tailwind-v3.js.map +1 -0
- package/dist/core/tokens/parsers/tailwind-v4.d.ts +3 -0
- package/dist/core/tokens/parsers/tailwind-v4.d.ts.map +1 -0
- package/dist/core/tokens/parsers/tailwind-v4.js +5 -0
- package/dist/core/tokens/parsers/tailwind-v4.js.map +1 -0
- package/dist/core/tokens/parsers/tokens-studio.d.ts +3 -0
- package/dist/core/tokens/parsers/tokens-studio.d.ts.map +1 -0
- package/dist/core/tokens/parsers/tokens-studio.js +5 -0
- package/dist/core/tokens/parsers/tokens-studio.js.map +1 -0
- package/dist/core/tokens/schemas.d.ts +155 -0
- package/dist/core/tokens/schemas.d.ts.map +1 -0
- package/dist/core/tokens/schemas.js +153 -0
- package/dist/core/tokens/schemas.js.map +1 -0
- package/dist/core/tokens/transforms/color.d.ts +9 -0
- package/dist/core/tokens/transforms/color.d.ts.map +1 -0
- package/dist/core/tokens/transforms/color.js +13 -0
- package/dist/core/tokens/transforms/color.js.map +1 -0
- package/dist/core/tokens/transforms/index.d.ts +36 -0
- package/dist/core/tokens/transforms/index.d.ts.map +1 -0
- package/dist/core/tokens/transforms/index.js +30 -0
- package/dist/core/tokens/transforms/index.js.map +1 -0
- package/dist/core/tokens/transforms/size.d.ts +7 -0
- package/dist/core/tokens/transforms/size.d.ts.map +1 -0
- package/dist/core/tokens/transforms/size.js +8 -0
- package/dist/core/tokens/transforms/size.js.map +1 -0
- package/dist/core/tokens/types.d.ts +284 -0
- package/dist/core/tokens/types.d.ts.map +1 -0
- package/dist/core/tokens/types.js +19 -0
- package/dist/core/tokens/types.js.map +1 -0
- package/dist/core/tokens-tools.d.ts +285 -0
- package/dist/core/tokens-tools.d.ts.map +1 -0
- package/dist/core/tokens-tools.js +1789 -0
- package/dist/core/tokens-tools.js.map +1 -0
- package/dist/core/types/design-code.d.ts +271 -0
- package/dist/core/types/design-code.d.ts.map +1 -0
- package/dist/core/types/design-code.js +5 -0
- package/dist/core/types/design-code.js.map +1 -0
- package/dist/core/types/enriched.d.ts +213 -0
- package/dist/core/types/enriched.d.ts.map +1 -0
- package/dist/core/types/enriched.js +6 -0
- package/dist/core/types/enriched.js.map +1 -0
- package/dist/core/types/index.d.ts +104 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +5 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/variable-resolver.d.ts +45 -0
- package/dist/core/variable-resolver.d.ts.map +1 -0
- package/dist/core/variable-resolver.js +86 -0
- package/dist/core/variable-resolver.js.map +1 -0
- package/dist/core/version-tools.d.ts +59 -0
- package/dist/core/version-tools.d.ts.map +1 -0
- package/dist/core/version-tools.js +1200 -0
- package/dist/core/version-tools.js.map +1 -0
- package/dist/core/websocket-connector.d.ts +247 -0
- package/dist/core/websocket-connector.d.ts.map +1 -0
- package/dist/core/websocket-connector.js +437 -0
- package/dist/core/websocket-connector.js.map +1 -0
- package/dist/core/websocket-server.d.ts +290 -0
- package/dist/core/websocket-server.d.ts.map +1 -0
- package/dist/core/websocket-server.js +957 -0
- package/dist/core/websocket-server.js.map +1 -0
- package/dist/core/write-tools.d.ts +7 -0
- package/dist/core/write-tools.d.ts.map +1 -0
- package/dist/core/write-tools.js +2507 -0
- package/dist/core/write-tools.js.map +1 -0
- package/dist/local.d.ts +105 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +3314 -0
- package/dist/local.js.map +1 -0
- package/figma-desktop-bridge/README.md +365 -0
- package/figma-desktop-bridge/code.js +7359 -0
- package/figma-desktop-bridge/icon.png +0 -0
- package/figma-desktop-bridge/manifest.json +67 -0
- package/figma-desktop-bridge/ui.html +2783 -0
- package/package.json +103 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DTCG (Design Tokens Community Group) JSON formatter.
|
|
3
|
+
*
|
|
4
|
+
* Produces W3C-spec DTCG output (https://tr.designtokens.org/format/) with
|
|
5
|
+
* three nuances:
|
|
6
|
+
*
|
|
7
|
+
* 1. Multi-mode tokens. The DTCG v1 spec doesn't natively express modes;
|
|
8
|
+
* we use a separate file per mode (driven by `splitByMode: true`) or a
|
|
9
|
+
* single file with values keyed by mode under a vendor extension when
|
|
10
|
+
* splitByMode is false. The split-file approach is the recommended
|
|
11
|
+
* pattern in the broader DTCG community and is what Style Dictionary
|
|
12
|
+
* v4, Tokens Studio, and Figma's announced native export all use.
|
|
13
|
+
*
|
|
14
|
+
* 2. $extensions["figma-console-mcp"]. We stash Figma variable IDs and
|
|
15
|
+
* last-synced values here for non-destructive round-trip. Other DTCG
|
|
16
|
+
* tools preserve $extensions verbatim.
|
|
17
|
+
*
|
|
18
|
+
* 3. Composite tokens (typography, shadow, gradient) emit DTCG's
|
|
19
|
+
* structured $value form. Aliases emit `"$value": "{path.to.target}"`.
|
|
20
|
+
*
|
|
21
|
+
* This formatter is the canonical output — the format every other
|
|
22
|
+
* formatter (CSS variables, Tailwind v4/v3, SCSS, TS module, JSON
|
|
23
|
+
* flat/nested, Style Dictionary v3, Tokens Studio) ultimately derives from.
|
|
24
|
+
*/
|
|
25
|
+
import { FIGMA_MCP_EXTENSION_KEY } from "../types.js";
|
|
26
|
+
import { formatDtcgReference } from "../alias-resolver.js";
|
|
27
|
+
import { colorValueTo2025, dimensionLiteralTo2025, } from "../dialect.js";
|
|
28
|
+
export function formatDtcg(doc, opts) {
|
|
29
|
+
const warnings = [];
|
|
30
|
+
const files = [];
|
|
31
|
+
// Figure out which sets and modes to emit, and how they map to files.
|
|
32
|
+
// Three layout strategies:
|
|
33
|
+
// 1. splitByMode + splitByCollection → one file per (set, mode) pair
|
|
34
|
+
// 2. splitByMode → one file per mode, all sets merged
|
|
35
|
+
// 3. splitByCollection → one file per set, all modes in one tree
|
|
36
|
+
// 4. neither → one file with everything
|
|
37
|
+
const splitByMode = opts.target.splitByMode ?? false;
|
|
38
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
39
|
+
// Value-encoding dialect. 'legacy' (default) is byte-identical to the
|
|
40
|
+
// historical output; '2025' opts into DTCG 2025.10 object colors/dimensions.
|
|
41
|
+
const dialect = opts.target.dtcgDialect ?? "legacy";
|
|
42
|
+
if (splitByMode && splitByCollection) {
|
|
43
|
+
for (const set of doc.sets) {
|
|
44
|
+
for (const mode of set.modes) {
|
|
45
|
+
const fileTokens = set.tokens
|
|
46
|
+
.map((t) => projectTokenToMode(t, mode, warnings))
|
|
47
|
+
.filter((t) => t !== null);
|
|
48
|
+
files.push({
|
|
49
|
+
path: filenameFor(opts, set, mode),
|
|
50
|
+
content: serializeAsDtcg({ sets: [{ ...set, modes: [mode], tokens: fileTokens }], meta: doc.meta }, warnings, dialect, mode),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (splitByMode) {
|
|
56
|
+
const allModes = new Set();
|
|
57
|
+
for (const set of doc.sets)
|
|
58
|
+
for (const m of set.modes)
|
|
59
|
+
allModes.add(m);
|
|
60
|
+
for (const mode of allModes) {
|
|
61
|
+
const fileSets = doc.sets
|
|
62
|
+
.filter((s) => s.modes.includes(mode))
|
|
63
|
+
.map((s) => ({
|
|
64
|
+
...s,
|
|
65
|
+
modes: [mode],
|
|
66
|
+
tokens: s.tokens
|
|
67
|
+
.map((t) => projectTokenToMode(t, mode, warnings))
|
|
68
|
+
.filter((t) => t !== null),
|
|
69
|
+
}));
|
|
70
|
+
files.push({
|
|
71
|
+
path: filenameFor(opts, undefined, mode),
|
|
72
|
+
content: serializeAsDtcg({ sets: fileSets, meta: doc.meta }, warnings, dialect, mode),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (splitByCollection) {
|
|
77
|
+
for (const set of doc.sets) {
|
|
78
|
+
files.push({
|
|
79
|
+
path: filenameFor(opts, set),
|
|
80
|
+
content: serializeAsDtcg({ sets: [set], meta: doc.meta }, warnings, dialect),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
files.push({
|
|
86
|
+
path: filenameFor(opts),
|
|
87
|
+
content: serializeAsDtcg(doc, warnings, dialect),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return { files, warnings };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Project a token's values down to a single mode. Returns null if the token
|
|
94
|
+
* has no value for the requested mode (skip rather than emit a blank).
|
|
95
|
+
*/
|
|
96
|
+
function projectTokenToMode(token, mode, warnings) {
|
|
97
|
+
const value = token.values[mode];
|
|
98
|
+
if (!value) {
|
|
99
|
+
// Token wasn't defined for this mode. Could happen when sets share tokens
|
|
100
|
+
// but only some have multi-mode values. Skip silently — not an error.
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return { ...token, values: { [mode]: value } };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compute the output filename for a given (set?, mode?) tuple based on the
|
|
107
|
+
* target options.
|
|
108
|
+
*/
|
|
109
|
+
function filenameFor(opts, set, mode) {
|
|
110
|
+
// Caller-specified filename wins.
|
|
111
|
+
if (opts.target.filename)
|
|
112
|
+
return opts.target.filename;
|
|
113
|
+
const parts = [];
|
|
114
|
+
if (set)
|
|
115
|
+
parts.push(slugify(set.name));
|
|
116
|
+
if (mode)
|
|
117
|
+
parts.push(slugify(mode));
|
|
118
|
+
if (parts.length === 0)
|
|
119
|
+
parts.push("tokens");
|
|
120
|
+
return `${parts.join(".")}.tokens.json`;
|
|
121
|
+
}
|
|
122
|
+
function slugify(s) {
|
|
123
|
+
return s
|
|
124
|
+
.trim()
|
|
125
|
+
.toLowerCase()
|
|
126
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
127
|
+
.replace(/^-+|-+$/g, "");
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Serialize a TokenDocument as DTCG JSON. Returns a pretty-printed JSON string
|
|
131
|
+
* with stable key order so git diffs stay minimal across runs.
|
|
132
|
+
*
|
|
133
|
+
* When `fileMode` is provided (splitByMode output), it's stamped into
|
|
134
|
+
* document-level $extensions so the parser can recover which mode this
|
|
135
|
+
* file represents — otherwise the parser sees only `$value` literals and
|
|
136
|
+
* labels them "Default", which breaks round-trip diffs on multi-mode files.
|
|
137
|
+
*/
|
|
138
|
+
function serializeAsDtcg(doc, warnings, dialect, fileMode) {
|
|
139
|
+
// Build the nested DTCG group tree by walking every token's path and
|
|
140
|
+
// building groups along the way.
|
|
141
|
+
const tree = {};
|
|
142
|
+
// Document-level $extensions: stash file-level metadata (Figma file key,
|
|
143
|
+
// export timestamp, MCP version, optionally the file's mode for
|
|
144
|
+
// splitByMode output) so round-trip preserves it.
|
|
145
|
+
const mcpDocMeta = {};
|
|
146
|
+
if (doc.meta?.figmaFileKey)
|
|
147
|
+
mcpDocMeta.figmaFileKey = doc.meta.figmaFileKey;
|
|
148
|
+
if (doc.meta?.exportedAt)
|
|
149
|
+
mcpDocMeta.exportedAt = doc.meta.exportedAt;
|
|
150
|
+
if (doc.meta?.mcpVersion)
|
|
151
|
+
mcpDocMeta.mcpVersion = doc.meta.mcpVersion;
|
|
152
|
+
if (fileMode)
|
|
153
|
+
mcpDocMeta.fileMode = fileMode;
|
|
154
|
+
if (Object.keys(mcpDocMeta).length > 0) {
|
|
155
|
+
tree.$extensions = { [FIGMA_MCP_EXTENSION_KEY]: mcpDocMeta };
|
|
156
|
+
}
|
|
157
|
+
for (const set of doc.sets) {
|
|
158
|
+
// Each set lives under a top-level group named after the set. Set-level
|
|
159
|
+
// metadata (Figma collection ID, original name, etc.) goes in that
|
|
160
|
+
// group's $extensions so round-trip recovers the original name even
|
|
161
|
+
// after we slugify it for the JSON key.
|
|
162
|
+
const setKey = setKeyFor(set);
|
|
163
|
+
let setGroup = tree[setKey];
|
|
164
|
+
if (!setGroup) {
|
|
165
|
+
setGroup = {};
|
|
166
|
+
if (set.description)
|
|
167
|
+
setGroup.$description = set.description;
|
|
168
|
+
const mcpMeta = {};
|
|
169
|
+
if (set.meta?.figmaCollectionId) {
|
|
170
|
+
mcpMeta.figmaCollectionId = set.meta.figmaCollectionId;
|
|
171
|
+
}
|
|
172
|
+
// Always stash the original name when it differs from the slug — this
|
|
173
|
+
// is what makes diff matching work after round-trip.
|
|
174
|
+
if (set.name !== setKey) {
|
|
175
|
+
mcpMeta.originalName = set.name;
|
|
176
|
+
}
|
|
177
|
+
if (Object.keys(mcpMeta).length > 0) {
|
|
178
|
+
setGroup.$extensions = { [FIGMA_MCP_EXTENSION_KEY]: mcpMeta };
|
|
179
|
+
}
|
|
180
|
+
tree[setKey] = setGroup;
|
|
181
|
+
}
|
|
182
|
+
for (const token of set.tokens) {
|
|
183
|
+
writeTokenIntoTree(setGroup, token, set.modes, warnings, dialect, fileMode);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return JSON.stringify(sortKeys(tree), null, 2) + "\n";
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Key used for the top-level set group in DTCG. We slugify the set name to
|
|
190
|
+
* keep it a valid JSON key under any consumer's expectations. The original
|
|
191
|
+
* (un-slugged) name is preserved in the set's $extensions so round-trip
|
|
192
|
+
* recovers it.
|
|
193
|
+
*/
|
|
194
|
+
function setKeyFor(set) {
|
|
195
|
+
return slugify(set.name);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Insert a token into the DTCG group tree at the right nested path.
|
|
199
|
+
* Creates intermediate groups as needed.
|
|
200
|
+
*
|
|
201
|
+
* Leaf/group name conflicts (a variable named "color" alongside
|
|
202
|
+
* "color/primary") are kept — the leaf is emitted under the reserved "@"
|
|
203
|
+
* key inside the group, flagged with `leafRemap: true` in its
|
|
204
|
+
* figma-console-mcp $extensions so the parser can restore the original
|
|
205
|
+
* name on round-trip. A warning names both sides of the conflict.
|
|
206
|
+
*/
|
|
207
|
+
function writeTokenIntoTree(root, token, setModes, warnings, dialect, fileMode) {
|
|
208
|
+
let cursor = root;
|
|
209
|
+
for (let i = 0; i < token.path.length - 1; i++) {
|
|
210
|
+
const segment = token.path[i];
|
|
211
|
+
let next = cursor[segment];
|
|
212
|
+
if (next && isToken(next)) {
|
|
213
|
+
// A leaf token already occupies this segment and we need a group
|
|
214
|
+
// here. Keep both: demote the existing leaf to the reserved "@" key
|
|
215
|
+
// inside the new group.
|
|
216
|
+
const conflictPath = token.path.slice(0, i + 1).join("/");
|
|
217
|
+
warnings.push(`Name conflict: "${conflictPath}" is both a token and a group (needed by "${token.path.join("/")}"). Kept both — the leaf token "${conflictPath}" was emitted under "${conflictPath}/@" and round-trips back to its original name.`);
|
|
218
|
+
const group = { "@": markLeafRemap(next) };
|
|
219
|
+
cursor[segment] = group;
|
|
220
|
+
next = group;
|
|
221
|
+
}
|
|
222
|
+
else if (!next) {
|
|
223
|
+
next = {};
|
|
224
|
+
cursor[segment] = next;
|
|
225
|
+
}
|
|
226
|
+
cursor = next;
|
|
227
|
+
}
|
|
228
|
+
const leafKey = token.path[token.path.length - 1];
|
|
229
|
+
const rendered = renderToken(token, setModes, warnings, dialect, fileMode);
|
|
230
|
+
const existing = cursor[leafKey];
|
|
231
|
+
if (existing &&
|
|
232
|
+
typeof existing === "object" &&
|
|
233
|
+
!isToken(existing)) {
|
|
234
|
+
// A group already exists at this name (some other token nests under
|
|
235
|
+
// it). Keep both: emit this leaf under the reserved "@" key.
|
|
236
|
+
const conflictPath = token.path.join("/");
|
|
237
|
+
warnings.push(`Name conflict: token "${conflictPath}" collides with the group "${conflictPath}" (created by tokens nested under it). Kept both — the leaf was emitted under "${conflictPath}/@" and round-trips back to its original name.`);
|
|
238
|
+
existing["@"] = markLeafRemap(rendered);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
cursor[leafKey] = rendered;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Flag a rendered leaf token as remapped under the reserved "@" key so the
|
|
245
|
+
* parser can strip that synthetic path segment on round-trip.
|
|
246
|
+
*/
|
|
247
|
+
function markLeafRemap(tok) {
|
|
248
|
+
const existing = tok.$extensions?.[FIGMA_MCP_EXTENSION_KEY] ?? {};
|
|
249
|
+
tok.$extensions ??= {};
|
|
250
|
+
tok.$extensions[FIGMA_MCP_EXTENSION_KEY] = { ...existing, leafRemap: true };
|
|
251
|
+
return tok;
|
|
252
|
+
}
|
|
253
|
+
function isToken(node) {
|
|
254
|
+
return "$value" in node;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert an internal Token to its DTCG-encoded leaf form.
|
|
258
|
+
*
|
|
259
|
+
* Single-mode token: emits `{ $value, $type, ... }`.
|
|
260
|
+
* Multi-mode token: emits the primary mode as `$value` and stashes BOTH the
|
|
261
|
+
* primary mode's name (`primaryMode`) and the remaining mode values
|
|
262
|
+
* (`modes`) under `$extensions["figma-console-mcp"]`, because vanilla DTCG
|
|
263
|
+
* doesn't have a native multi-mode encoding. The parser reads the same keys
|
|
264
|
+
* back, so a Light/Dark collection round-trips losslessly even without
|
|
265
|
+
* splitByMode. Callers who want one-file-per-mode should set splitByMode at
|
|
266
|
+
* the formatter level.
|
|
267
|
+
*/
|
|
268
|
+
function renderToken(token, setModes, warnings, dialect, fileMode) {
|
|
269
|
+
const result = {
|
|
270
|
+
$value: "",
|
|
271
|
+
$type: token.type,
|
|
272
|
+
};
|
|
273
|
+
if (token.description)
|
|
274
|
+
result.$description = token.description;
|
|
275
|
+
const modeKeys = Object.keys(token.values);
|
|
276
|
+
const isSingleMode = modeKeys.length === 1;
|
|
277
|
+
// Pick the primary mode: the set's first mode when the token has a value
|
|
278
|
+
// for it, otherwise the token's first mode.
|
|
279
|
+
const primaryMode = setModes[0] in token.values ? setModes[0] : modeKeys[0];
|
|
280
|
+
result.$value = encodeValue(token.values[primaryMode], token, warnings, dialect);
|
|
281
|
+
const otherModes = {};
|
|
282
|
+
if (!isSingleMode) {
|
|
283
|
+
for (const m of modeKeys) {
|
|
284
|
+
if (m === primaryMode)
|
|
285
|
+
continue;
|
|
286
|
+
otherModes[m] = encodeValue(token.values[m], token, warnings, dialect);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Preserve any pre-existing extensions (e.g. studio.tokens, our own metadata).
|
|
290
|
+
if (token.extensions) {
|
|
291
|
+
for (const [vendor, payload] of Object.entries(token.extensions)) {
|
|
292
|
+
if (vendor === FIGMA_MCP_EXTENSION_KEY) {
|
|
293
|
+
mergeExtension(result, vendor, payload);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
mergeExtension(result, vendor, payload);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Mode round-trip metadata goes under OUR extension key (merged on top of
|
|
301
|
+
// any preserved figma-console-mcp payload so variableId etc. survive):
|
|
302
|
+
// - `primaryMode` whenever the parser couldn't otherwise recover the
|
|
303
|
+
// primary mode's name (i.e. it isn't covered by the file-level
|
|
304
|
+
// fileMode stamp and isn't the "Default" fallback).
|
|
305
|
+
// - `modes` with every non-primary mode's value for multi-mode tokens.
|
|
306
|
+
const needsPrimaryStash = primaryMode !== (fileMode ?? "Default");
|
|
307
|
+
const hasOtherModes = Object.keys(otherModes).length > 0;
|
|
308
|
+
if (needsPrimaryStash || hasOtherModes) {
|
|
309
|
+
const existing = result.$extensions?.[FIGMA_MCP_EXTENSION_KEY] ?? {};
|
|
310
|
+
mergeExtension(result, FIGMA_MCP_EXTENSION_KEY, {
|
|
311
|
+
...existing,
|
|
312
|
+
primaryMode,
|
|
313
|
+
...(hasOtherModes ? { modes: otherModes } : {}),
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
function encodeValue(value, token, warnings, dialect) {
|
|
319
|
+
if (!value) {
|
|
320
|
+
warnings.push(`Token ${token.path.join(".")} has no mode values — emitting empty string.`);
|
|
321
|
+
return "";
|
|
322
|
+
}
|
|
323
|
+
if (value.reference) {
|
|
324
|
+
return formatDtcgReference(value.reference.replace(/^\{|\}$/g, "").split("."));
|
|
325
|
+
}
|
|
326
|
+
if (value.literal === undefined) {
|
|
327
|
+
warnings.push(`Token ${token.path.join(".")} has neither literal nor reference — emitting empty string.`);
|
|
328
|
+
return "";
|
|
329
|
+
}
|
|
330
|
+
// DTCG 2025.10 dialect: colors emit the object form (components from the
|
|
331
|
+
// converter's full-precision rawColor floats, hex kept as the interop
|
|
332
|
+
// courtesy field); dimension-typed bare numbers emit { value, unit: "px" }.
|
|
333
|
+
// duration already emits { value, unit: "ms" } in both dialects. Anything
|
|
334
|
+
// the encoders don't recognize keeps the legacy rendering.
|
|
335
|
+
if (dialect === "2025") {
|
|
336
|
+
if (token.type === "color") {
|
|
337
|
+
const encoded = colorValueTo2025(value);
|
|
338
|
+
if (encoded)
|
|
339
|
+
return encoded;
|
|
340
|
+
}
|
|
341
|
+
else if (token.type === "dimension") {
|
|
342
|
+
const encoded = dimensionLiteralTo2025(value.literal);
|
|
343
|
+
if (encoded)
|
|
344
|
+
return encoded;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return value.literal;
|
|
348
|
+
}
|
|
349
|
+
function mergeExtension(token, key, payload) {
|
|
350
|
+
token.$extensions ??= {};
|
|
351
|
+
token.$extensions[key] = payload;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Recursively sort object keys for stable serialization (so git diffs only
|
|
355
|
+
* show meaningful changes). $-prefixed keys come first (DTCG convention),
|
|
356
|
+
* then alphabetical.
|
|
357
|
+
*/
|
|
358
|
+
function sortKeys(node) {
|
|
359
|
+
if (node === null || typeof node !== "object" || Array.isArray(node)) {
|
|
360
|
+
return node;
|
|
361
|
+
}
|
|
362
|
+
const obj = node;
|
|
363
|
+
const sorted = {};
|
|
364
|
+
const keys = Object.keys(obj).sort((a, b) => {
|
|
365
|
+
const aDollar = a.startsWith("$");
|
|
366
|
+
const bDollar = b.startsWith("$");
|
|
367
|
+
if (aDollar && !bDollar)
|
|
368
|
+
return -1;
|
|
369
|
+
if (!aDollar && bDollar)
|
|
370
|
+
return 1;
|
|
371
|
+
return a.localeCompare(b);
|
|
372
|
+
});
|
|
373
|
+
for (const k of keys)
|
|
374
|
+
sorted[k] = sortKeys(obj[k]);
|
|
375
|
+
return sorted;
|
|
376
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter dispatcher. Each formatter converts our canonical internal
|
|
3
|
+
* TokenDocument into a specific output format (DTCG JSON, CSS custom
|
|
4
|
+
* properties, Tailwind v4 @theme, SCSS, etc.).
|
|
5
|
+
*/
|
|
6
|
+
import { formatDtcg } from "./dtcg.js";
|
|
7
|
+
import { formatTokensStudio } from "./tokens-studio.js";
|
|
8
|
+
import { formatCssVars } from "./css-vars.js";
|
|
9
|
+
import { formatTailwindV4 } from "./tailwind-v4.js";
|
|
10
|
+
import { formatTailwindV3 } from "./tailwind-v3.js";
|
|
11
|
+
import { formatScss } from "./scss.js";
|
|
12
|
+
import { formatLess } from "./less.js";
|
|
13
|
+
import { formatTsModule } from "./ts-module.js";
|
|
14
|
+
import { formatJsonFlat, formatJsonNested } from "./json.js";
|
|
15
|
+
import { formatStyleDictionaryV3 } from "./style-dictionary-v3.js";
|
|
16
|
+
export function format(doc, options) {
|
|
17
|
+
switch (options.target.format) {
|
|
18
|
+
case "dtcg":
|
|
19
|
+
return formatDtcg(doc, options);
|
|
20
|
+
case "tokens-studio":
|
|
21
|
+
return formatTokensStudio(doc, options);
|
|
22
|
+
case "css-vars":
|
|
23
|
+
return formatCssVars(doc, options);
|
|
24
|
+
case "tailwind-v4":
|
|
25
|
+
return formatTailwindV4(doc, options);
|
|
26
|
+
case "tailwind-v3":
|
|
27
|
+
return formatTailwindV3(doc, options);
|
|
28
|
+
case "scss":
|
|
29
|
+
return formatScss(doc, options);
|
|
30
|
+
case "less":
|
|
31
|
+
return formatLess(doc, options);
|
|
32
|
+
case "ts-module":
|
|
33
|
+
return formatTsModule(doc, options);
|
|
34
|
+
case "json-flat":
|
|
35
|
+
return formatJsonFlat(doc, options);
|
|
36
|
+
case "json-nested":
|
|
37
|
+
return formatJsonNested(doc, options);
|
|
38
|
+
case "style-dictionary-v3":
|
|
39
|
+
return formatStyleDictionaryV3(doc, options);
|
|
40
|
+
default: {
|
|
41
|
+
const _exhaustive = options.target.format;
|
|
42
|
+
throw new Error(`[figma-console-mcp] Unknown export format: ${_exhaustive}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
import { buildTokenIndex, resolveAliasChain } from "../alias-resolver.js";
|
|
34
|
+
import { colorValueTo2025, dimensionLiteralTo2025, } from "../dialect.js";
|
|
35
|
+
export function formatJsonFlat(doc, opts) {
|
|
36
|
+
const warnings = [];
|
|
37
|
+
const files = [];
|
|
38
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
39
|
+
const prefix = opts.target.prefix ?? "";
|
|
40
|
+
const dialect = opts.target.dtcgDialect ?? "legacy";
|
|
41
|
+
// Plain JSON has no native alias mechanism — resolve aliases to their
|
|
42
|
+
// literal target so consumers get usable values, not opaque `{ref}` strings.
|
|
43
|
+
const tokenIndex = buildTokenIndex(doc);
|
|
44
|
+
if (splitByCollection) {
|
|
45
|
+
for (const set of doc.sets) {
|
|
46
|
+
files.push({
|
|
47
|
+
path: filenameFor(opts, set, "flat"),
|
|
48
|
+
content: renderFlat([set], prefix, tokenIndex, warnings, dialect),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
files.push({
|
|
54
|
+
path: filenameFor(opts, undefined, "flat"),
|
|
55
|
+
content: renderFlat(doc.sets, prefix, tokenIndex, warnings, dialect),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return { files, warnings };
|
|
59
|
+
}
|
|
60
|
+
export function formatJsonNested(doc, opts) {
|
|
61
|
+
const warnings = [];
|
|
62
|
+
const files = [];
|
|
63
|
+
const splitByCollection = opts.target.splitByCollection ?? false;
|
|
64
|
+
const dialect = opts.target.dtcgDialect ?? "legacy";
|
|
65
|
+
const tokenIndex = buildTokenIndex(doc);
|
|
66
|
+
if (splitByCollection) {
|
|
67
|
+
for (const set of doc.sets) {
|
|
68
|
+
files.push({
|
|
69
|
+
path: filenameFor(opts, set, "nested"),
|
|
70
|
+
content: renderNested([set], tokenIndex, warnings, dialect),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
files.push({
|
|
76
|
+
path: filenameFor(opts, undefined, "nested"),
|
|
77
|
+
content: renderNested(doc.sets, tokenIndex, warnings, dialect),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return { files, warnings };
|
|
81
|
+
}
|
|
82
|
+
function filenameFor(opts, set, shape) {
|
|
83
|
+
if (opts.target.filename)
|
|
84
|
+
return opts.target.filename;
|
|
85
|
+
const parts = [];
|
|
86
|
+
if (set)
|
|
87
|
+
parts.push(slugify(set.name));
|
|
88
|
+
parts.push(`tokens.${shape}`);
|
|
89
|
+
return `${parts.join(".")}.json`;
|
|
90
|
+
}
|
|
91
|
+
function slugify(s) {
|
|
92
|
+
return s
|
|
93
|
+
.trim()
|
|
94
|
+
.toLowerCase()
|
|
95
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
96
|
+
.replace(/^-+|-+$/g, "");
|
|
97
|
+
}
|
|
98
|
+
function renderFlat(sets, prefix, tokenIndex, warnings, dialect) {
|
|
99
|
+
const out = {};
|
|
100
|
+
for (const set of sets) {
|
|
101
|
+
const primaryMode = pickPrimaryMode(set.modes);
|
|
102
|
+
for (const token of set.tokens) {
|
|
103
|
+
const baseName = `${prefix}${token.path.map(slugify).join("-")}`;
|
|
104
|
+
for (const [modeName, value] of Object.entries(token.values)) {
|
|
105
|
+
const key = modeName === primaryMode
|
|
106
|
+
? baseName
|
|
107
|
+
: `${baseName}--${slugify(modeName)}`;
|
|
108
|
+
const resolved = resolveValue(value, token, modeName, tokenIndex, warnings, dialect);
|
|
109
|
+
if (resolved !== undefined)
|
|
110
|
+
out[key] = resolved;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Sort keys for deterministic output.
|
|
115
|
+
const sorted = Object.fromEntries(Object.entries(out).sort(([a], [b]) => a.localeCompare(b)));
|
|
116
|
+
return JSON.stringify(sorted, null, 2) + "\n";
|
|
117
|
+
}
|
|
118
|
+
function renderNested(sets, tokenIndex, warnings, dialect) {
|
|
119
|
+
const out = {};
|
|
120
|
+
for (const set of sets) {
|
|
121
|
+
const isMultiMode = set.modes.length > 1;
|
|
122
|
+
for (const token of set.tokens) {
|
|
123
|
+
let cursor = out;
|
|
124
|
+
for (let i = 0; i < token.path.length - 1; i++) {
|
|
125
|
+
const segment = token.path[i];
|
|
126
|
+
if (!cursor[segment] ||
|
|
127
|
+
typeof cursor[segment] !== "object" ||
|
|
128
|
+
Array.isArray(cursor[segment])) {
|
|
129
|
+
cursor[segment] = {};
|
|
130
|
+
}
|
|
131
|
+
cursor = cursor[segment];
|
|
132
|
+
}
|
|
133
|
+
const leafKey = token.path[token.path.length - 1];
|
|
134
|
+
if (isMultiMode) {
|
|
135
|
+
const modeValues = {};
|
|
136
|
+
for (const [modeName, value] of Object.entries(token.values)) {
|
|
137
|
+
const resolved = resolveValue(value, token, modeName, tokenIndex, warnings, dialect);
|
|
138
|
+
if (resolved !== undefined)
|
|
139
|
+
modeValues[modeName] = resolved;
|
|
140
|
+
}
|
|
141
|
+
cursor[leafKey] = modeValues;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const [onlyModeName, onlyValue] = Object.entries(token.values)[0] ?? [];
|
|
145
|
+
if (onlyValue) {
|
|
146
|
+
const resolved = resolveValue(onlyValue, token, onlyModeName, tokenIndex, warnings, dialect);
|
|
147
|
+
if (resolved !== undefined)
|
|
148
|
+
cursor[leafKey] = resolved;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return JSON.stringify(sortKeys(out), null, 2) + "\n";
|
|
154
|
+
}
|
|
155
|
+
function pickPrimaryMode(modes) {
|
|
156
|
+
return modes.find((m) => /^(default|light|value)$/i.test(m)) ?? modes[0];
|
|
157
|
+
}
|
|
158
|
+
function resolveValue(value, token, mode, tokenIndex, warnings, dialect) {
|
|
159
|
+
let effective = value;
|
|
160
|
+
if (value.reference) {
|
|
161
|
+
effective = resolveAliasChain(value, mode, tokenIndex);
|
|
162
|
+
if (!effective) {
|
|
163
|
+
const bare = value.reference.replace(/^\{|\}$/g, "");
|
|
164
|
+
const reason = bare.startsWith("__library:") || bare === "unknown"
|
|
165
|
+
? "cross-library alias"
|
|
166
|
+
: "alias target not found";
|
|
167
|
+
warnings.push(`Skipped ${token.path.join(".")} in JSON — ${reason}: ${value.reference}.`);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!effective || effective.literal === undefined || effective.literal === null) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
// DTCG 2025.10 dialect (opt-in): colors emit the object form, dimensions
|
|
175
|
+
// emit { value, unit: "px" }. Legacy (default) keeps hex strings and
|
|
176
|
+
// "16px" strings — byte-identical to historical output.
|
|
177
|
+
if (dialect === "2025") {
|
|
178
|
+
if (token.type === "color") {
|
|
179
|
+
const encoded = colorValueTo2025(effective);
|
|
180
|
+
if (encoded)
|
|
181
|
+
return encoded;
|
|
182
|
+
}
|
|
183
|
+
else if (token.type === "dimension") {
|
|
184
|
+
const encoded = dimensionLiteralTo2025(effective.literal);
|
|
185
|
+
if (encoded)
|
|
186
|
+
return encoded;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (typeof effective.literal === "number") {
|
|
190
|
+
if (token.type === "dimension")
|
|
191
|
+
return `${effective.literal}px`;
|
|
192
|
+
return effective.literal;
|
|
193
|
+
}
|
|
194
|
+
return effective.literal;
|
|
195
|
+
}
|
|
196
|
+
function sortKeys(obj) {
|
|
197
|
+
if (obj === null || typeof obj !== "object" || Array.isArray(obj))
|
|
198
|
+
return obj;
|
|
199
|
+
const sorted = {};
|
|
200
|
+
const keys = Object.keys(obj).sort();
|
|
201
|
+
for (const k of keys) {
|
|
202
|
+
sorted[k] = sortKeys(obj[k]);
|
|
203
|
+
}
|
|
204
|
+
return sorted;
|
|
205
|
+
}
|