@mp3wizard/figma-console-mcp 1.23.1 → 1.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -33
- package/dist/cloudflare/core/config.js +0 -8
- package/dist/cloudflare/core/console-monitor.js +3 -3
- package/dist/cloudflare/core/diagnose-tool.js +96 -0
- package/dist/cloudflare/core/figma-tools.js +69 -229
- package/dist/cloudflare/core/identity.js +96 -0
- package/dist/cloudflare/core/tokens/alias-resolver.js +98 -0
- package/dist/cloudflare/core/tokens/config.js +284 -0
- package/dist/cloudflare/core/tokens/figma-converter.js +195 -0
- package/dist/cloudflare/core/tokens/formatters/css-vars.js +329 -0
- package/dist/cloudflare/core/tokens/formatters/dtcg.js +300 -0
- package/dist/cloudflare/core/tokens/formatters/index.js +45 -0
- package/dist/cloudflare/core/tokens/formatters/json.js +7 -0
- package/dist/cloudflare/core/tokens/formatters/less.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/scss.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/stubs.js +11 -0
- package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +4 -0
- package/dist/cloudflare/core/tokens/formatters/ts-module.js +4 -0
- package/dist/cloudflare/core/tokens/index.js +15 -0
- package/dist/cloudflare/core/tokens/parsers/css-vars.js +4 -0
- package/dist/cloudflare/core/tokens/parsers/dtcg.js +253 -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 +13 -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 +148 -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 +849 -0
- package/dist/cloudflare/core/version-tools.js +151 -7
- package/dist/cloudflare/core/websocket-server.js +77 -55
- package/dist/cloudflare/index.js +37 -26
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +0 -8
- package/dist/core/config.js.map +1 -1
- package/dist/core/console-monitor.d.ts +2 -2
- package/dist/core/console-monitor.d.ts.map +1 -1
- package/dist/core/console-monitor.js +3 -3
- package/dist/core/console-monitor.js.map +1 -1
- package/dist/core/diagnose-tool.d.ts +33 -0
- package/dist/core/diagnose-tool.d.ts.map +1 -0
- package/dist/core/diagnose-tool.js +97 -0
- package/dist/core/diagnose-tool.js.map +1 -0
- package/dist/core/diff/diff-engine.d.ts +14 -0
- package/dist/core/diff/diff-engine.d.ts.map +1 -1
- package/dist/core/diff/diff-engine.js.map +1 -1
- package/dist/core/figma-connector.d.ts +1 -1
- package/dist/core/figma-connector.d.ts.map +1 -1
- package/dist/core/figma-tools.d.ts +1 -2
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +69 -229
- package/dist/core/figma-tools.js.map +1 -1
- 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/tokens/alias-resolver.d.ts +40 -0
- package/dist/core/tokens/alias-resolver.d.ts.map +1 -0
- package/dist/core/tokens/alias-resolver.js +99 -0
- package/dist/core/tokens/alias-resolver.js.map +1 -0
- package/dist/core/tokens/config.d.ts +352 -0
- package/dist/core/tokens/config.d.ts.map +1 -0
- package/dist/core/tokens/config.js +285 -0
- package/dist/core/tokens/config.js.map +1 -0
- package/dist/core/tokens/figma-converter.d.ts +81 -0
- package/dist/core/tokens/figma-converter.d.ts.map +1 -0
- package/dist/core/tokens/figma-converter.js +196 -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 +330 -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 +301 -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 +5 -0
- package/dist/core/tokens/formatters/json.d.ts.map +1 -0
- package/dist/core/tokens/formatters/json.js +8 -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 +4 -0
- package/dist/core/tokens/formatters/scss.d.ts.map +1 -0
- package/dist/core/tokens/formatters/scss.js +5 -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 +12 -0
- package/dist/core/tokens/formatters/stubs.js.map +1 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts +4 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.d.ts.map +1 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.js +5 -0
- package/dist/core/tokens/formatters/style-dictionary-v3.js.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v3.d.ts +4 -0
- package/dist/core/tokens/formatters/tailwind-v3.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v3.js +5 -0
- package/dist/core/tokens/formatters/tailwind-v3.js.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v4.d.ts +4 -0
- package/dist/core/tokens/formatters/tailwind-v4.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tailwind-v4.js +5 -0
- package/dist/core/tokens/formatters/tailwind-v4.js.map +1 -0
- package/dist/core/tokens/formatters/tokens-studio.d.ts +4 -0
- package/dist/core/tokens/formatters/tokens-studio.d.ts.map +1 -0
- package/dist/core/tokens/formatters/tokens-studio.js +5 -0
- package/dist/core/tokens/formatters/tokens-studio.js.map +1 -0
- package/dist/core/tokens/formatters/ts-module.d.ts +4 -0
- package/dist/core/tokens/formatters/ts-module.d.ts.map +1 -0
- package/dist/core/tokens/formatters/ts-module.js +5 -0
- package/dist/core/tokens/formatters/ts-module.js.map +1 -0
- package/dist/core/tokens/index.d.ts +17 -0
- package/dist/core/tokens/index.d.ts.map +1 -0
- package/dist/core/tokens/index.js +16 -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 +254 -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 +11 -0
- package/dist/core/tokens/parsers/stubs.d.ts.map +1 -0
- package/dist/core/tokens/parsers/stubs.js +14 -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 +152 -0
- package/dist/core/tokens/schemas.d.ts.map +1 -0
- package/dist/core/tokens/schemas.js +149 -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 +228 -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 +42 -0
- package/dist/core/tokens-tools.d.ts.map +1 -0
- package/dist/core/tokens-tools.js +850 -0
- package/dist/core/tokens-tools.js.map +1 -0
- package/dist/core/types/index.d.ts +0 -8
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/version-tools.d.ts +30 -1
- package/dist/core/version-tools.d.ts.map +1 -1
- package/dist/core/version-tools.js +151 -7
- package/dist/core/version-tools.js.map +1 -1
- package/dist/core/websocket-connector.d.ts +1 -1
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-server.d.ts +47 -3
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +77 -55
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/local.d.ts +0 -12
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +967 -3406
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/code.js +59 -63
- package/figma-desktop-bridge/ui.html +85 -11
- package/package.json +12 -30
- package/figma-desktop-bridge/ui-full.html +0 -1353
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the figma_export_tokens and figma_import_tokens MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Kept in a dedicated file because they're the AI-facing surface of the token
|
|
5
|
+
* sync engine — the descriptions matter for prompt comprehension, and they
|
|
6
|
+
* need to stay in sync with `src/core/tokens/types.ts` (the internal model).
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
/**
|
|
10
|
+
* Output format enum mirrors `ExportFormat` from `./types.ts`. Listed in the
|
|
11
|
+
* same priority order — DTCG and Tokens Studio first as the canonical JSON
|
|
12
|
+
* outputs, then CSS-family formats, then code modules, then back-compat.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ExportFormatSchema: z.ZodEnum<["dtcg", "tokens-studio", "css-vars", "tailwind-v4", "tailwind-v3", "scss", "less", "ts-module", "json-flat", "json-nested", "style-dictionary-v3"]>;
|
|
15
|
+
export declare const ImportFormatSchema: z.ZodEnum<["auto", "dtcg", "tokens-studio", "css-vars", "tailwind-v4", "tailwind-v3-config", "scss", "style-dictionary-v3", "json-flat", "json-nested"]>;
|
|
16
|
+
export declare const SyncStrategySchema: z.ZodEnum<["merge", "replace", "dry-run"]>;
|
|
17
|
+
export declare const ConflictResolutionSchema: z.ZodEnum<["ask", "figma-wins", "code-wins", "skip"]>;
|
|
18
|
+
/**
|
|
19
|
+
* Schema for figma_export_tokens. Most fields are optional — the typical call
|
|
20
|
+
* is zero-arg, picking everything up from `tokens.config.json` autodiscovery.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ExportTokensInputSchema: z.ZodObject<{
|
|
23
|
+
scope: z.ZodOptional<z.ZodEnum<["file", "collection"]>>;
|
|
24
|
+
collectionIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
|
+
modes: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodLiteral<"all">]>>;
|
|
26
|
+
format: z.ZodOptional<z.ZodEnum<["dtcg", "tokens-studio", "css-vars", "tailwind-v4", "tailwind-v3", "scss", "less", "ts-module", "json-flat", "json-nested", "style-dictionary-v3"]>>;
|
|
27
|
+
outputPath: z.ZodOptional<z.ZodString>;
|
|
28
|
+
configPath: z.ZodOptional<z.ZodString>;
|
|
29
|
+
strategy: z.ZodOptional<z.ZodEnum<["merge", "replace", "dry-run"]>>;
|
|
30
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
31
|
+
resolveAliases: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
splitByMode: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
splitByCollection: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
colorFormat: z.ZodOptional<z.ZodEnum<["hex", "hex8", "rgba", "oklch", "hsl"]>>;
|
|
35
|
+
sizeUnit: z.ZodOptional<z.ZodEnum<["px", "rem", "pt", "dp"]>>;
|
|
36
|
+
remBase: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "tailwind-v3" | "scss" | "less" | "ts-module" | "json-flat" | "json-nested" | "style-dictionary-v3" | undefined;
|
|
39
|
+
resolveAliases?: boolean | undefined;
|
|
40
|
+
outputPath?: string | undefined;
|
|
41
|
+
modes?: string[] | "all" | undefined;
|
|
42
|
+
prefix?: string | undefined;
|
|
43
|
+
splitByMode?: boolean | undefined;
|
|
44
|
+
splitByCollection?: boolean | undefined;
|
|
45
|
+
colorFormat?: "hex" | "hex8" | "rgba" | "oklch" | "hsl" | undefined;
|
|
46
|
+
sizeUnit?: "px" | "rem" | "pt" | "dp" | undefined;
|
|
47
|
+
remBase?: number | undefined;
|
|
48
|
+
configPath?: string | undefined;
|
|
49
|
+
scope?: "collection" | "file" | undefined;
|
|
50
|
+
collectionIds?: string[] | undefined;
|
|
51
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "tailwind-v3" | "scss" | "less" | "ts-module" | "json-flat" | "json-nested" | "style-dictionary-v3" | undefined;
|
|
54
|
+
resolveAliases?: boolean | undefined;
|
|
55
|
+
outputPath?: string | undefined;
|
|
56
|
+
modes?: string[] | "all" | undefined;
|
|
57
|
+
prefix?: string | undefined;
|
|
58
|
+
splitByMode?: boolean | undefined;
|
|
59
|
+
splitByCollection?: boolean | undefined;
|
|
60
|
+
colorFormat?: "hex" | "hex8" | "rgba" | "oklch" | "hsl" | undefined;
|
|
61
|
+
sizeUnit?: "px" | "rem" | "pt" | "dp" | undefined;
|
|
62
|
+
remBase?: number | undefined;
|
|
63
|
+
configPath?: string | undefined;
|
|
64
|
+
scope?: "collection" | "file" | undefined;
|
|
65
|
+
collectionIds?: string[] | undefined;
|
|
66
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
export type ExportTokensInput = z.infer<typeof ExportTokensInputSchema>;
|
|
69
|
+
/**
|
|
70
|
+
* Schema for figma_import_tokens. Mirrors export's shape on the inverse
|
|
71
|
+
* direction: instead of producing files, this consumes payloads or files and
|
|
72
|
+
* pushes the diff to Figma.
|
|
73
|
+
*/
|
|
74
|
+
export declare const ImportTokensInputSchema: z.ZodEffects<z.ZodObject<{
|
|
75
|
+
format: z.ZodOptional<z.ZodEnum<["auto", "dtcg", "tokens-studio", "css-vars", "tailwind-v4", "tailwind-v3-config", "scss", "style-dictionary-v3", "json-flat", "json-nested"]>>;
|
|
76
|
+
payload: z.ZodOptional<z.ZodString>;
|
|
77
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
78
|
+
path: z.ZodString;
|
|
79
|
+
content: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
content: string;
|
|
82
|
+
path: string;
|
|
83
|
+
}, {
|
|
84
|
+
content: string;
|
|
85
|
+
path: string;
|
|
86
|
+
}>, "many">>;
|
|
87
|
+
configPath: z.ZodOptional<z.ZodString>;
|
|
88
|
+
strategy: z.ZodOptional<z.ZodEnum<["merge", "replace", "dry-run"]>>;
|
|
89
|
+
collectionMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
90
|
+
modeMapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
91
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
92
|
+
onConflict: z.ZodOptional<z.ZodEnum<["ask", "figma-wins", "code-wins", "skip"]>>;
|
|
93
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "scss" | "json-flat" | "json-nested" | "style-dictionary-v3" | "auto" | "tailwind-v3-config" | undefined;
|
|
96
|
+
payload?: string | undefined;
|
|
97
|
+
prefix?: string | undefined;
|
|
98
|
+
configPath?: string | undefined;
|
|
99
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
100
|
+
files?: {
|
|
101
|
+
content: string;
|
|
102
|
+
path: string;
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
collectionMapping?: Record<string, string> | undefined;
|
|
105
|
+
modeMapping?: Record<string, string> | undefined;
|
|
106
|
+
onConflict?: "ask" | "figma-wins" | "code-wins" | "skip" | undefined;
|
|
107
|
+
dryRun?: boolean | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "scss" | "json-flat" | "json-nested" | "style-dictionary-v3" | "auto" | "tailwind-v3-config" | undefined;
|
|
110
|
+
payload?: string | undefined;
|
|
111
|
+
prefix?: string | undefined;
|
|
112
|
+
configPath?: string | undefined;
|
|
113
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
114
|
+
files?: {
|
|
115
|
+
content: string;
|
|
116
|
+
path: string;
|
|
117
|
+
}[] | undefined;
|
|
118
|
+
collectionMapping?: Record<string, string> | undefined;
|
|
119
|
+
modeMapping?: Record<string, string> | undefined;
|
|
120
|
+
onConflict?: "ask" | "figma-wins" | "code-wins" | "skip" | undefined;
|
|
121
|
+
dryRun?: boolean | undefined;
|
|
122
|
+
}>, {
|
|
123
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "scss" | "json-flat" | "json-nested" | "style-dictionary-v3" | "auto" | "tailwind-v3-config" | undefined;
|
|
124
|
+
payload?: string | undefined;
|
|
125
|
+
prefix?: string | undefined;
|
|
126
|
+
configPath?: string | undefined;
|
|
127
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
128
|
+
files?: {
|
|
129
|
+
content: string;
|
|
130
|
+
path: string;
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
collectionMapping?: Record<string, string> | undefined;
|
|
133
|
+
modeMapping?: Record<string, string> | undefined;
|
|
134
|
+
onConflict?: "ask" | "figma-wins" | "code-wins" | "skip" | undefined;
|
|
135
|
+
dryRun?: boolean | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
format?: "dtcg" | "tokens-studio" | "css-vars" | "tailwind-v4" | "scss" | "json-flat" | "json-nested" | "style-dictionary-v3" | "auto" | "tailwind-v3-config" | undefined;
|
|
138
|
+
payload?: string | undefined;
|
|
139
|
+
prefix?: string | undefined;
|
|
140
|
+
configPath?: string | undefined;
|
|
141
|
+
strategy?: "replace" | "merge" | "dry-run" | undefined;
|
|
142
|
+
files?: {
|
|
143
|
+
content: string;
|
|
144
|
+
path: string;
|
|
145
|
+
}[] | undefined;
|
|
146
|
+
collectionMapping?: Record<string, string> | undefined;
|
|
147
|
+
modeMapping?: Record<string, string> | undefined;
|
|
148
|
+
onConflict?: "ask" | "figma-wins" | "code-wins" | "skip" | undefined;
|
|
149
|
+
dryRun?: boolean | undefined;
|
|
150
|
+
}>;
|
|
151
|
+
export type ImportTokensInput = z.infer<typeof ImportTokensInputSchema>;
|
|
152
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/core/tokens/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,gKAY7B,CAAC;AAEH,eAAO,MAAM,kBAAkB,0JAW7B,CAAC;AAEH,eAAO,MAAM,kBAAkB,4CAA0C,CAAC;AAE1E,eAAO,MAAM,wBAAwB,uDAKnC,CAAC;AAKH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0ElC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwEjC,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the figma_export_tokens and figma_import_tokens MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Kept in a dedicated file because they're the AI-facing surface of the token
|
|
5
|
+
* sync engine — the descriptions matter for prompt comprehension, and they
|
|
6
|
+
* need to stay in sync with `src/core/tokens/types.ts` (the internal model).
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
/**
|
|
10
|
+
* Output format enum mirrors `ExportFormat` from `./types.ts`. Listed in the
|
|
11
|
+
* same priority order — DTCG and Tokens Studio first as the canonical JSON
|
|
12
|
+
* outputs, then CSS-family formats, then code modules, then back-compat.
|
|
13
|
+
*/
|
|
14
|
+
export const ExportFormatSchema = z.enum([
|
|
15
|
+
"dtcg",
|
|
16
|
+
"tokens-studio",
|
|
17
|
+
"css-vars",
|
|
18
|
+
"tailwind-v4",
|
|
19
|
+
"tailwind-v3",
|
|
20
|
+
"scss",
|
|
21
|
+
"less",
|
|
22
|
+
"ts-module",
|
|
23
|
+
"json-flat",
|
|
24
|
+
"json-nested",
|
|
25
|
+
"style-dictionary-v3",
|
|
26
|
+
]);
|
|
27
|
+
export const ImportFormatSchema = z.enum([
|
|
28
|
+
"auto",
|
|
29
|
+
"dtcg",
|
|
30
|
+
"tokens-studio",
|
|
31
|
+
"css-vars",
|
|
32
|
+
"tailwind-v4",
|
|
33
|
+
"tailwind-v3-config",
|
|
34
|
+
"scss",
|
|
35
|
+
"style-dictionary-v3",
|
|
36
|
+
"json-flat",
|
|
37
|
+
"json-nested",
|
|
38
|
+
]);
|
|
39
|
+
export const SyncStrategySchema = z.enum(["merge", "replace", "dry-run"]);
|
|
40
|
+
export const ConflictResolutionSchema = z.enum([
|
|
41
|
+
"ask",
|
|
42
|
+
"figma-wins",
|
|
43
|
+
"code-wins",
|
|
44
|
+
"skip",
|
|
45
|
+
]);
|
|
46
|
+
const ColorFormatSchema = z.enum(["hex", "hex8", "rgba", "oklch", "hsl"]);
|
|
47
|
+
const SizeUnitSchema = z.enum(["px", "rem", "pt", "dp"]);
|
|
48
|
+
/**
|
|
49
|
+
* Schema for figma_export_tokens. Most fields are optional — the typical call
|
|
50
|
+
* is zero-arg, picking everything up from `tokens.config.json` autodiscovery.
|
|
51
|
+
*/
|
|
52
|
+
export const ExportTokensInputSchema = z.object({
|
|
53
|
+
scope: z
|
|
54
|
+
.enum(["file", "collection"])
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Whether to export the entire file's variables ('file', default) or just specific collections via collectionIds."),
|
|
57
|
+
collectionIds: z
|
|
58
|
+
.array(z.string())
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Specific Figma collection IDs to export. Required when scope is 'collection'. Use figma_get_variables to enumerate available collections."),
|
|
61
|
+
modes: z
|
|
62
|
+
.union([z.array(z.string()), z.literal("all")])
|
|
63
|
+
.optional()
|
|
64
|
+
.describe("Modes to include in the output. 'all' (default) exports every mode in every collection. Pass an array like ['Light', 'Dark'] to filter."),
|
|
65
|
+
format: ExportFormatSchema.optional().describe("Specific output format to emit. When omitted, formats come from tokens.config.json's generated.formats list. Common starting choices: 'dtcg' for the canonical JSON, 'css-vars' for runtime CSS custom properties, 'tailwind-v4' for Tailwind v4 @theme blocks."),
|
|
66
|
+
outputPath: z
|
|
67
|
+
.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe("Filesystem path to write the output file(s) to. Relative paths resolve against the project root (the directory containing tokens.config.json) or cwd if no config. When omitted, the output is returned inline in the response (suitable for the AI to inspect or write via its own file tools)."),
|
|
70
|
+
configPath: z
|
|
71
|
+
.string()
|
|
72
|
+
.optional()
|
|
73
|
+
.describe("Explicit path to a tokens.config.json file. When omitted, the tool walks up from cwd looking for one — typical case is zero-arg."),
|
|
74
|
+
strategy: SyncStrategySchema.optional().describe("How to handle existing output files. 'merge' (default) diffs against current contents and writes only changed tokens, preserving code-only additions. 'replace' wipes and rewrites. 'dry-run' computes the diff and reports what would change without writing."),
|
|
75
|
+
prefix: z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Prefix prepended to every output token name (e.g. 'ds-', 'al-'). Only affects formatters that emit named tokens — DTCG and JSON outputs use unmodified paths."),
|
|
79
|
+
resolveAliases: z
|
|
80
|
+
.boolean()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("If true, alias references are resolved to literal values in the output. Default is false for JSON formats (preserves alias semantics) and true for CSS/SCSS/Tailwind/etc. (which can't natively express aliases)."),
|
|
83
|
+
splitByMode: z
|
|
84
|
+
.boolean()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("Emit one file per mode (e.g. tokens-light.css, tokens-dark.css). Default false (single file with all modes)."),
|
|
87
|
+
splitByCollection: z
|
|
88
|
+
.boolean()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe("Emit one file per Figma collection. Default false. Useful when collections map to different runtime themes."),
|
|
91
|
+
colorFormat: ColorFormatSchema.optional().describe("Color value format in the output. Default: 'hex'. Use 'oklch' for modern Tailwind v4 charts."),
|
|
92
|
+
sizeUnit: SizeUnitSchema.optional().describe("Unit for dimension tokens. Default: 'rem' for web outputs, 'pt' for iOS, 'dp' for Android."),
|
|
93
|
+
remBase: z
|
|
94
|
+
.number()
|
|
95
|
+
.positive()
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Base font size in pixels for px→rem conversion. Default: 16."),
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Schema for figma_import_tokens. Mirrors export's shape on the inverse
|
|
101
|
+
* direction: instead of producing files, this consumes payloads or files and
|
|
102
|
+
* pushes the diff to Figma.
|
|
103
|
+
*/
|
|
104
|
+
export const ImportTokensInputSchema = z
|
|
105
|
+
.object({
|
|
106
|
+
format: ImportFormatSchema.optional().describe("Format of the input payload. 'auto' (default) detects from payload shape or file extension. Pass an explicit format if auto-detection misfires."),
|
|
107
|
+
payload: z
|
|
108
|
+
.string()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe("Single-file content to import. Use this for one-shot imports without setting up tokens.config.json. Mutually exclusive with `files` and `configPath`."),
|
|
111
|
+
files: z
|
|
112
|
+
.array(z.object({
|
|
113
|
+
path: z.string().describe("Relative or absolute filesystem path."),
|
|
114
|
+
content: z.string().describe("File contents."),
|
|
115
|
+
}))
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Multi-file import (used for Tokens Studio's split-set format, or for projects with many DTCG source files). Mutually exclusive with `payload` and `configPath`."),
|
|
118
|
+
configPath: z
|
|
119
|
+
.string()
|
|
120
|
+
.optional()
|
|
121
|
+
.describe("Explicit path to tokens.config.json. When omitted, the tool autodiscovers and uses the config's source.dir to find files. Mutually exclusive with `payload` and `files`."),
|
|
122
|
+
strategy: SyncStrategySchema.optional().describe("How to apply changes. 'merge' (default) diffs against current Figma state and applies only deltas, preserving Figma-only variables. 'replace' wipes the target collections and rewrites. 'dry-run' computes the diff and reports without touching Figma."),
|
|
123
|
+
collectionMapping: z
|
|
124
|
+
.record(z.string())
|
|
125
|
+
.optional()
|
|
126
|
+
.describe("Map input token set names to Figma collection names. Example: {'primitives': 'Primitive Tokens'}. When omitted, set names map 1:1 to collection names."),
|
|
127
|
+
modeMapping: z
|
|
128
|
+
.record(z.string())
|
|
129
|
+
.optional()
|
|
130
|
+
.describe("Map input mode names to Figma mode names. Useful when source uses 'light'/'dark' and Figma uses 'Light'/'Dark'. Defaults to 1:1 mapping with case preservation."),
|
|
131
|
+
prefix: z
|
|
132
|
+
.string()
|
|
133
|
+
.optional()
|
|
134
|
+
.describe("Prefix to strip from input token names on import. E.g. with prefix 'ds-', a token named '--ds-color-primary' becomes 'color/primary'."),
|
|
135
|
+
onConflict: ConflictResolutionSchema.optional().describe("How to resolve true two-sided conflicts (both Figma and code changed the same token since last sync). 'ask' (default) surfaces the conflict and writes nothing. 'figma-wins' / 'code-wins' apply the corresponding side. 'skip' leaves conflicted tokens alone but proceeds with the rest."),
|
|
136
|
+
dryRun: z
|
|
137
|
+
.boolean()
|
|
138
|
+
.optional()
|
|
139
|
+
.describe("Shorthand for strategy: 'dry-run'. Computes the diff and returns a preview without applying any changes to Figma."),
|
|
140
|
+
})
|
|
141
|
+
.refine((data) => {
|
|
142
|
+
// Exactly one of payload / files / configPath should be set (or none,
|
|
143
|
+
// which triggers tokens.config.json autodiscovery).
|
|
144
|
+
const sources = [data.payload, data.files, data.configPath].filter((x) => x !== undefined);
|
|
145
|
+
return sources.length <= 1;
|
|
146
|
+
}, {
|
|
147
|
+
message: "Pass at most one of: payload, files, configPath. (Or none, to autodiscover tokens.config.json.)",
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","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O,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CACP,mHAAmH,CACpH;CACJ,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE;IACP,sEAAsE;IACtE,oDAAoD;IACpD,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAChE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CACvB,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;AAC7B,CAAC,EACD;IACE,OAAO,EACL,iGAAiG;CACpG,CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color value transforms. Convert between hex, hex8 (with alpha), rgba, oklch,
|
|
3
|
+
* and hsl representations. Stub — DTCG and CSS-vars output preserve source
|
|
4
|
+
* values; format-specific transforms will land alongside the Tailwind v4 /
|
|
5
|
+
* SCSS formatters.
|
|
6
|
+
*/
|
|
7
|
+
import type { Transform } from "./index.js";
|
|
8
|
+
export declare const colorToFormat: Transform;
|
|
9
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,aAAa,EAAE,SAS3B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color value transforms. Convert between hex, hex8 (with alpha), rgba, oklch,
|
|
3
|
+
* and hsl representations. Stub — DTCG and CSS-vars output preserve source
|
|
4
|
+
* values; format-specific transforms will land alongside the Tailwind v4 /
|
|
5
|
+
* SCSS formatters.
|
|
6
|
+
*/
|
|
7
|
+
export const colorToFormat = (value, _token, _opts) => {
|
|
8
|
+
// Pass through. The DTCG and CSS-vars formatters don't need transforms —
|
|
9
|
+
// they preserve / format source values inline. Hex↔oklch↔rgba etc. will be
|
|
10
|
+
// implemented when format-specific output requires conversion.
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAC,MAAM,aAAa,GAAc,CACtC,KAAiB,EACjB,MAAa,EACb,KAAuB,EACvB,EAAE;IACF,yEAAyE;IACzE,2EAA2E;IAC3E,+DAA+D;IAC/D,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token-value transforms. Each transform is a pure function that takes a
|
|
3
|
+
* TokenValue (and an options bag) and returns a transformed TokenValue.
|
|
4
|
+
*
|
|
5
|
+
* Transforms are composable — formatters call them in a pipeline appropriate
|
|
6
|
+
* for the output format (e.g. CSS variables need px→rem and string color
|
|
7
|
+
* normalization; DTCG output skips transforms entirely since it preserves the
|
|
8
|
+
* source representation).
|
|
9
|
+
*
|
|
10
|
+
* Currently ships stubs that pass values through unchanged. The DTCG and
|
|
11
|
+
* CSS variables formatters don't need transforms because they handle their
|
|
12
|
+
* own value formatting inline. Transforms will be implemented when the
|
|
13
|
+
* Tailwind v4 / SCSS / TS module formatters land.
|
|
14
|
+
*/
|
|
15
|
+
import type { Token, TokenValue } from "../types.js";
|
|
16
|
+
export interface TransformOptions {
|
|
17
|
+
/** Desired color output format. Defaults to "hex". */
|
|
18
|
+
colorFormat?: "hex" | "hex8" | "rgba" | "oklch" | "hsl";
|
|
19
|
+
/** Desired dimension unit. Defaults to "rem" for web. */
|
|
20
|
+
sizeUnit?: "px" | "rem" | "pt" | "dp";
|
|
21
|
+
/** Base font size for px↔rem conversion. Defaults to 16. */
|
|
22
|
+
remBase?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface Transform {
|
|
25
|
+
/**
|
|
26
|
+
* Apply the transform to a single token value. Returns a new value
|
|
27
|
+
* (transforms are pure).
|
|
28
|
+
*/
|
|
29
|
+
(value: TokenValue, token: Token, opts: TransformOptions): TokenValue;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Run a pipeline of transforms on a token's value(s). Iterates every mode
|
|
33
|
+
* and applies each transform in order.
|
|
34
|
+
*/
|
|
35
|
+
export declare function runTransforms(token: Token, transforms: Transform[], opts: TransformOptions): Token;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;IACxD,yDAAyD;IACzD,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,CAAC;IACtC,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,UAAU,CAAC;CACvE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,SAAS,EAAE,EACvB,IAAI,EAAE,gBAAgB,GACrB,KAAK,CAUP"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token-value transforms. Each transform is a pure function that takes a
|
|
3
|
+
* TokenValue (and an options bag) and returns a transformed TokenValue.
|
|
4
|
+
*
|
|
5
|
+
* Transforms are composable — formatters call them in a pipeline appropriate
|
|
6
|
+
* for the output format (e.g. CSS variables need px→rem and string color
|
|
7
|
+
* normalization; DTCG output skips transforms entirely since it preserves the
|
|
8
|
+
* source representation).
|
|
9
|
+
*
|
|
10
|
+
* Currently ships stubs that pass values through unchanged. The DTCG and
|
|
11
|
+
* CSS variables formatters don't need transforms because they handle their
|
|
12
|
+
* own value formatting inline. Transforms will be implemented when the
|
|
13
|
+
* Tailwind v4 / SCSS / TS module formatters land.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Run a pipeline of transforms on a token's value(s). Iterates every mode
|
|
17
|
+
* and applies each transform in order.
|
|
18
|
+
*/
|
|
19
|
+
export function runTransforms(token, transforms, opts) {
|
|
20
|
+
const newValues = {};
|
|
21
|
+
for (const [mode, value] of Object.entries(token.values)) {
|
|
22
|
+
let result = value;
|
|
23
|
+
for (const transform of transforms) {
|
|
24
|
+
result = transform(result, token, opts);
|
|
25
|
+
}
|
|
26
|
+
newValues[mode] = result;
|
|
27
|
+
}
|
|
28
|
+
return { ...token, values: newValues };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAqBH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAY,EACZ,UAAuB,EACvB,IAAsB;IAEtB,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACzD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;QACD,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dimension/size value transforms. Convert px ↔ rem ↔ pt ↔ dp. Stub —
|
|
3
|
+
* to be implemented when Tailwind v4 / SCSS / TS formatters ship.
|
|
4
|
+
*/
|
|
5
|
+
import type { Transform } from "./index.js";
|
|
6
|
+
export declare const sizeToUnit: Transform;
|
|
7
|
+
//# sourceMappingURL=size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/size.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,UAAU,EAAE,SAMxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../../../src/core/tokens/transforms/size.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,CAAC,MAAM,UAAU,GAAc,CACnC,KAAiB,EACjB,MAAa,EACb,KAAuB,EACvB,EAAE;IACF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|