@texturehq/edges 1.33.2 → 1.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +57 -3
  2. package/dist/{RichTextEditor-CxrunTg7.d.cts → RichTextEditor-diZqy_s1.d.cts} +1 -1
  3. package/dist/{RichTextEditor-CxrunTg7.d.ts → RichTextEditor-diZqy_s1.d.ts} +1 -1
  4. package/dist/{TimeField-DRQshIHX.d.ts → TimeField-7pTUPh11.d.ts} +32 -17
  5. package/dist/{TimeField-WCmeiLu3.d.cts → TimeField-CqmVrAdn.d.cts} +32 -17
  6. package/dist/{colors-Cgs2MGZ8.d.ts → colors-CoULWZ5j.d.ts} +53 -18
  7. package/dist/{colors-DGRiGzgj.d.cts → colors-upTGgIQe.d.cts} +53 -18
  8. package/dist/form/index.cjs +1 -1
  9. package/dist/form/index.cjs.map +1 -1
  10. package/dist/form/index.d.cts +1 -1
  11. package/dist/form/index.d.ts +1 -1
  12. package/dist/form/index.js +1 -1
  13. package/dist/form/index.js.map +1 -1
  14. package/dist/{index-BqpWEc_N.d.ts → index-dofSwYId.d.cts} +5 -5
  15. package/dist/{index-BqpWEc_N.d.cts → index-dofSwYId.d.ts} +5 -5
  16. package/dist/index.cjs +10 -10
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +161 -41
  19. package/dist/index.d.ts +161 -41
  20. package/dist/index.js +10 -10
  21. package/dist/index.js.map +1 -1
  22. package/dist/prose.css +202 -0
  23. package/dist/rhf/index.cjs +1 -1
  24. package/dist/rhf/index.cjs.map +1 -1
  25. package/dist/rhf/index.d.cts +2 -2
  26. package/dist/rhf/index.d.ts +2 -2
  27. package/dist/rhf/index.js +1 -1
  28. package/dist/rhf/index.js.map +1 -1
  29. package/dist/server.cjs +2 -2
  30. package/dist/server.cjs.map +1 -1
  31. package/dist/server.d.cts +2 -2
  32. package/dist/server.d.ts +2 -2
  33. package/dist/server.js +2 -2
  34. package/dist/server.js.map +1 -1
  35. package/dist/styles/computed.css +2 -2
  36. package/dist/styles/responsive-typography.css +9 -7
  37. package/dist/styles/theme-light-override.css +26 -15
  38. package/dist/styles.css +2122 -820
  39. package/dist/theme.css +20 -7
  40. package/dist/typography.css +150 -0
  41. package/package.json +13 -14
  42. package/scripts/check-legacy-action-variants.mjs +96 -0
  43. package/scripts/check-legacy-font-colors.mjs +92 -0
  44. package/scripts/copy-assets.js +12 -0
  45. package/scripts/generate-color-utilities.mjs +163 -0
  46. package/templates/claude-rules/.claude +5 -5
  47. package/templates/claude-rules/claude.md +5 -5
  48. package/templates/codex-rules/codex.md +5 -5
  49. package/dist/generated/tailwind-tokens-dark.css +0 -397
  50. package/dist/generated/tailwind-tokens-light.css +0 -611
  51. package/dist/generated/viz-runtime.css +0 -243
  52. package/scripts/generate-viz-runtime.js +0 -107
  53. package/scripts/validate-tokens.js +0 -176
@@ -1,243 +0,0 @@
1
- /**
2
- * Data Visualization Color Palette - Runtime Override
3
- *
4
- * WORKAROUND: These variables are defined here instead of in tailwind-tokens-*.css
5
- * because Tailwind 4's @theme directive filters them out (similar issue as data-* prefix).
6
- *
7
- * Includes:
8
- * - Generic viz colors (--color-viz-*)
9
- * - Device state data viz colors (--color-state-*-data)
10
- *
11
- * AUTO-GENERATED by scripts/generate-viz-runtime.js
12
- * DO NOT EDIT MANUALLY - Edit theme-specific viz colors in:
13
- * - tokens/themes/light.json (light mode viz colors)
14
- * - tokens/themes/dark.json (dark mode viz colors)
15
- */
16
-
17
- /* Light theme (default) */
18
- :root {
19
- --color-viz-default: #0082ff;
20
- --color-viz-categorical-1: #a3eae4;
21
- --color-viz-categorical-2: #91a0ff;
22
- --color-viz-categorical-3: #ffd1a3;
23
- --color-viz-categorical-4: #ffabc8;
24
- --color-viz-categorical-5: #c1b8ff;
25
- --color-viz-categorical-6: #e0ffb8;
26
- --color-viz-sequential-viridis-1: #fafa37;
27
- --color-viz-sequential-viridis-2: #d6e654;
28
- --color-viz-sequential-viridis-3: #b2d373;
29
- --color-viz-sequential-viridis-4: #88be8c;
30
- --color-viz-sequential-viridis-5: #5fa2a4;
31
- --color-viz-sequential-viridis-6: #3d7eaa;
32
- --color-viz-sequential-viridis-7: #2a60b1;
33
- --color-viz-sequential-viridis-8: #1b3a99;
34
- --color-viz-sequential-viridis-9: #132353;
35
- --color-viz-sequential-viridis-10: #110f39;
36
- --color-viz-sequential-magma-1: #fcf5cd;
37
- --color-viz-sequential-magma-2: #f5db95;
38
- --color-viz-sequential-magma-3: #e9af7c;
39
- --color-viz-sequential-magma-4: #db7d70;
40
- --color-viz-sequential-magma-5: #b9577a;
41
- --color-viz-sequential-magma-6: #883482;
42
- --color-viz-sequential-magma-7: #6a1f78;
43
- --color-viz-sequential-magma-8: #4b1277;
44
- --color-viz-sequential-magma-9: #2d0b42;
45
- --color-viz-sequential-magma-10: #0b0511;
46
- --color-viz-sequential-rose-1: #fef3e7;
47
- --color-viz-sequential-rose-2: #f5c7e0;
48
- --color-viz-sequential-rose-3: #ec9bce;
49
- --color-viz-sequential-rose-4: #d86db0;
50
- --color-viz-sequential-rose-5: #be4a8b;
51
- --color-viz-sequential-rose-6: #9d2f76;
52
- --color-viz-sequential-rose-7: #78176c;
53
- --color-viz-sequential-rose-8: #56135c;
54
- --color-viz-sequential-rose-9: #371344;
55
- --color-viz-sequential-rose-10: #190b29;
56
- --color-viz-sequential-cerulean-1: #e2f7f2;
57
- --color-viz-sequential-cerulean-2: #b6e4e8;
58
- --color-viz-sequential-cerulean-3: #8bd3d7;
59
- --color-viz-sequential-cerulean-4: #60b2c7;
60
- --color-viz-sequential-cerulean-5: #3d91b6;
61
- --color-viz-sequential-cerulean-6: #22698e;
62
- --color-viz-sequential-cerulean-7: #0e486a;
63
- --color-viz-sequential-cerulean-8: #0a314d;
64
- --color-viz-sequential-cerulean-9: #081e33;
65
- --color-viz-sequential-cerulean-10: #030e1d;
66
- --color-viz-sequential-forest-1: #f4fad8;
67
- --color-viz-sequential-forest-2: #d6e6a5;
68
- --color-viz-sequential-forest-3: #b2cd73;
69
- --color-viz-sequential-forest-4: #88af52;
70
- --color-viz-sequential-forest-5: #5f8835;
71
- --color-viz-sequential-forest-6: #3d6426;
72
- --color-viz-sequential-forest-7: #2a461a;
73
- --color-viz-sequential-forest-8: #1b2e13;
74
- --color-viz-sequential-forest-9: #13200d;
75
- --color-viz-sequential-forest-10: #0b1305;
76
- --color-viz-sequential-red-yellow-green-1: #7f1d1d;
77
- --color-viz-sequential-red-yellow-green-2: #b91c1c;
78
- --color-viz-sequential-red-yellow-green-3: #ef4444;
79
- --color-viz-sequential-red-yellow-green-4: #fb923c;
80
- --color-viz-sequential-red-yellow-green-5: #f59e0b;
81
- --color-viz-sequential-red-yellow-green-6: #fbbf24;
82
- --color-viz-sequential-red-yellow-green-7: #a3e635;
83
- --color-viz-sequential-red-yellow-green-8: #4ade80;
84
- --color-viz-sequential-red-yellow-green-9: #10b981;
85
- --color-viz-sequential-red-yellow-green-10: #059669;
86
- --color-viz-diverging-orange-yellow-seafoam-1: #6b2c1a;
87
- --color-viz-diverging-orange-yellow-seafoam-2: #a24b1e;
88
- --color-viz-diverging-orange-yellow-seafoam-3: #cb7131;
89
- --color-viz-diverging-orange-yellow-seafoam-4: #e2a05d;
90
- --color-viz-diverging-orange-yellow-seafoam-5: #f3e1a3;
91
- --color-viz-diverging-orange-yellow-seafoam-6: #c1e4d2;
92
- --color-viz-diverging-orange-yellow-seafoam-7: #7eb8b1;
93
- --color-viz-diverging-orange-yellow-seafoam-8: #4c8c89;
94
- --color-viz-diverging-orange-yellow-seafoam-9: #2b6262;
95
- --color-viz-diverging-orange-yellow-seafoam-10: #1b3d3c;
96
- --color-viz-diverging-red-yellow-blue-1: #4e142d;
97
- --color-viz-diverging-red-yellow-blue-2: #8b2d4e;
98
- --color-viz-diverging-red-yellow-blue-3: #c15a4a;
99
- --color-viz-diverging-red-yellow-blue-4: #db8b6a;
100
- --color-viz-diverging-red-yellow-blue-5: #f3e1a3;
101
- --color-viz-diverging-red-yellow-blue-6: #bfd4c7;
102
- --color-viz-diverging-red-yellow-blue-7: #7c9eb9;
103
- --color-viz-diverging-red-yellow-blue-8: #4770a3;
104
- --color-viz-diverging-red-yellow-blue-9: #2e4d8c;
105
- --color-viz-diverging-red-yellow-blue-10: #18274e;
106
- --color-viz-diverging-red-blue-1: #4e142d;
107
- --color-viz-diverging-red-blue-2: #8b2d4e;
108
- --color-viz-diverging-red-blue-3: #c15a7a;
109
- --color-viz-diverging-red-blue-4: #db8b9e;
110
- --color-viz-diverging-red-blue-5: #f3e1f4;
111
- --color-viz-diverging-red-blue-6: #c7bfe2;
112
- --color-viz-diverging-red-blue-7: #9ea7ce;
113
- --color-viz-diverging-red-blue-8: #7080b5;
114
- --color-viz-diverging-red-blue-9: #4d5e99;
115
- --color-viz-diverging-red-blue-10: #2b3d70;
116
- --color-state-charging-data: #d9b6fd;
117
- --color-state-discharging-data: #fce380;
118
- --color-state-heat-data: #fba9a9;
119
- --color-state-cool-data: #9dc7fc;
120
- --color-state-eco-data: #88e9c5;
121
- --color-state-auto-data: #fed3a4;
122
- --color-state-circulate-data: #c4b5fd;
123
- --color-state-on-data: #7ce7d8;
124
- --color-state-idle-data: #c0c5cd;
125
- --color-state-off-data: #c0c5cd;
126
- --color-state-unknown-data: #e4e6e9;
127
- --color-state-importing-data: #8bb6fa;
128
- --color-state-exporting-data: #f9c869;
129
- }
130
-
131
- /* Dark theme */
132
- .theme-dark {
133
- --color-viz-default: #4da6ff;
134
- --color-viz-categorical-1: #7dd3c0;
135
- --color-viz-categorical-2: #a8b4ff;
136
- --color-viz-categorical-3: #ffd67a;
137
- --color-viz-categorical-4: #ffb3d9;
138
- --color-viz-categorical-5: #d4c4ff;
139
- --color-viz-categorical-6: #c8ff8e;
140
- --color-viz-sequential-viridis-1: #fde724;
141
- --color-viz-sequential-viridis-2: #b5de2b;
142
- --color-viz-sequential-viridis-3: #6ece58;
143
- --color-viz-sequential-viridis-4: #35b779;
144
- --color-viz-sequential-viridis-5: #1f9e89;
145
- --color-viz-sequential-viridis-6: #26828e;
146
- --color-viz-sequential-viridis-7: #31688e;
147
- --color-viz-sequential-viridis-8: #3e4a89;
148
- --color-viz-sequential-viridis-9: #482878;
149
- --color-viz-sequential-viridis-10: #440154;
150
- --color-viz-sequential-magma-1: #fcfdbf;
151
- --color-viz-sequential-magma-2: #feca8d;
152
- --color-viz-sequential-magma-3: #fd9668;
153
- --color-viz-sequential-magma-4: #f1605d;
154
- --color-viz-sequential-magma-5: #cd4071;
155
- --color-viz-sequential-magma-6: #9e2f7f;
156
- --color-viz-sequential-magma-7: #721f81;
157
- --color-viz-sequential-magma-8: #51127c;
158
- --color-viz-sequential-magma-9: #2c115f;
159
- --color-viz-sequential-magma-10: #0c0927;
160
- --color-viz-sequential-rose-1: #fff5ee;
161
- --color-viz-sequential-rose-2: #ffc9e8;
162
- --color-viz-sequential-rose-3: #ff95d5;
163
- --color-viz-sequential-rose-4: #eb5fb7;
164
- --color-viz-sequential-rose-5: #d13896;
165
- --color-viz-sequential-rose-6: #ac2681;
166
- --color-viz-sequential-rose-7: #841f78;
167
- --color-viz-sequential-rose-8: #631d67;
168
- --color-viz-sequential-rose-9: #3f1a4e;
169
- --color-viz-sequential-rose-10: #1e0f2e;
170
- --color-viz-sequential-cerulean-1: #e8fafd;
171
- --color-viz-sequential-cerulean-2: #b3e5f0;
172
- --color-viz-sequential-cerulean-3: #7fd4e8;
173
- --color-viz-sequential-cerulean-4: #4db8d8;
174
- --color-viz-sequential-cerulean-5: #2e9dc6;
175
- --color-viz-sequential-cerulean-6: #1a7ba3;
176
- --color-viz-sequential-cerulean-7: #0d5b7e;
177
- --color-viz-sequential-cerulean-8: #0a4263;
178
- --color-viz-sequential-cerulean-9: #072d47;
179
- --color-viz-sequential-cerulean-10: #041a2b;
180
- --color-viz-sequential-forest-1: #f7fcd4;
181
- --color-viz-sequential-forest-2: #d5ed99;
182
- --color-viz-sequential-forest-3: #afd66f;
183
- --color-viz-sequential-forest-4: #84ba4d;
184
- --color-viz-sequential-forest-5: #5a9b30;
185
- --color-viz-sequential-forest-6: #3a7a1e;
186
- --color-viz-sequential-forest-7: #285714;
187
- --color-viz-sequential-forest-8: #1a3c0d;
188
- --color-viz-sequential-forest-9: #0f2808;
189
- --color-viz-sequential-forest-10: #071403;
190
- --color-viz-sequential-red-yellow-green-1: #991b1b;
191
- --color-viz-sequential-red-yellow-green-2: #dc2626;
192
- --color-viz-sequential-red-yellow-green-3: #f87171;
193
- --color-viz-sequential-red-yellow-green-4: #fb923c;
194
- --color-viz-sequential-red-yellow-green-5: #fbbf24;
195
- --color-viz-sequential-red-yellow-green-6: #fde047;
196
- --color-viz-sequential-red-yellow-green-7: #bef264;
197
- --color-viz-sequential-red-yellow-green-8: #6ee7b7;
198
- --color-viz-sequential-red-yellow-green-9: #34d399;
199
- --color-viz-sequential-red-yellow-green-10: #10b981;
200
- --color-viz-diverging-orange-yellow-seafoam-1: #883a1f;
201
- --color-viz-diverging-orange-yellow-seafoam-2: #c25f27;
202
- --color-viz-diverging-orange-yellow-seafoam-3: #e8843d;
203
- --color-viz-diverging-orange-yellow-seafoam-4: #f5b774;
204
- --color-viz-diverging-orange-yellow-seafoam-5: #fef4c7;
205
- --color-viz-diverging-orange-yellow-seafoam-6: #b8e8d5;
206
- --color-viz-diverging-orange-yellow-seafoam-7: #73d4c5;
207
- --color-viz-diverging-orange-yellow-seafoam-8: #3db3a8;
208
- --color-viz-diverging-orange-yellow-seafoam-9: #1f8d82;
209
- --color-viz-diverging-orange-yellow-seafoam-10: #0d5d56;
210
- --color-viz-diverging-red-yellow-blue-1: #6b1e3c;
211
- --color-viz-diverging-red-yellow-blue-2: #a83b5e;
212
- --color-viz-diverging-red-yellow-blue-3: #d96e68;
213
- --color-viz-diverging-red-yellow-blue-4: #f0a487;
214
- --color-viz-diverging-red-yellow-blue-5: #fef4c7;
215
- --color-viz-diverging-red-yellow-blue-6: #b8ddd3;
216
- --color-viz-diverging-red-yellow-blue-7: #7bb8cf;
217
- --color-viz-diverging-red-yellow-blue-8: #4a8ec4;
218
- --color-viz-diverging-red-yellow-blue-9: #2d6bb0;
219
- --color-viz-diverging-red-yellow-blue-10: #1a4680;
220
- --color-viz-diverging-red-blue-1: #6b1e3c;
221
- --color-viz-diverging-red-blue-2: #a83b5e;
222
- --color-viz-diverging-red-blue-3: #d9668f;
223
- --color-viz-diverging-red-blue-4: #f09db8;
224
- --color-viz-diverging-red-blue-5: #f8e5f9;
225
- --color-viz-diverging-red-blue-6: #d4c9ed;
226
- --color-viz-diverging-red-blue-7: #b0b8df;
227
- --color-viz-diverging-red-blue-8: #8494ca;
228
- --color-viz-diverging-red-blue-9: #5d6fb0;
229
- --color-viz-diverging-red-blue-10: #374f88;
230
- --color-state-charging-data: #8038bf;
231
- --color-state-discharging-data: #b1740b;
232
- --color-state-heat-data: #b73030;
233
- --color-state-cool-data: #2c5ec0;
234
- --color-state-eco-data: #0b835e;
235
- --color-state-auto-data: #bb5f27;
236
- --color-state-circulate-data: #4f46e5;
237
- --color-state-on-data: #138378;
238
- --color-state-idle-data: #515968;
239
- --color-state-off-data: #515968;
240
- --color-state-unknown-data: #454d5b;
241
- --color-state-importing-data: #3f6fc2;
242
- --color-state-exporting-data: #b97a19;
243
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Generate viz-runtime.css from Style Dictionary output
3
- *
4
- * WORKAROUND: Tailwind 4's @theme directive filters out viz color variables,
5
- * so we extract them and create a separate runtime file with plain :root and
6
- * .theme-dark blocks.
7
- *
8
- * This script should run after Style Dictionary generates the token files.
9
- */
10
-
11
- import fs from "fs";
12
- import path from "path";
13
-
14
- const GENERATED_DIR = "src/generated";
15
- const LIGHT_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-light.css");
16
- const DARK_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-dark.css");
17
- const OUTPUT_FILE = path.join(GENERATED_DIR, "viz-runtime.css");
18
-
19
- /**
20
- * Extract viz color variables from a CSS file
21
- * Includes both --color-viz-* and --color-state-*-data variables
22
- */
23
- function extractVizColors(cssContent) {
24
- const vizColorRegex = /^\s*(--color-viz-[^:]+:\s*[^;]+;)\s*$/gm;
25
- const stateDataColorRegex = /^\s*(--color-state-[^:]*-data:\s*[^;]+;)\s*$/gm;
26
- const matches = [];
27
- let match;
28
-
29
- while ((match = vizColorRegex.exec(cssContent)) !== null) {
30
- matches.push(match[1]);
31
- }
32
-
33
- // Reset regex state
34
- stateDataColorRegex.lastIndex = 0;
35
-
36
- while ((match = stateDataColorRegex.exec(cssContent)) !== null) {
37
- matches.push(match[1]);
38
- }
39
-
40
- return matches;
41
- }
42
-
43
- /**
44
- * Generate the viz-runtime.css file
45
- */
46
- function generateVizRuntime() {
47
- console.log("🎨 Generating viz-runtime.css...");
48
-
49
- // Read token files
50
- const lightContent = fs.readFileSync(LIGHT_TOKENS, "utf8");
51
- const darkContent = fs.readFileSync(DARK_TOKENS, "utf8");
52
-
53
- // Extract viz colors
54
- const lightVizColors = extractVizColors(lightContent);
55
- const darkVizColors = extractVizColors(darkContent);
56
-
57
- if (lightVizColors.length === 0) {
58
- console.warn("⚠️ No viz colors found in light theme tokens");
59
- }
60
-
61
- if (darkVizColors.length === 0) {
62
- console.warn("⚠️ No viz colors found in dark theme tokens");
63
- }
64
-
65
- // Generate output
66
- const output = `/**
67
- * Data Visualization Color Palette - Runtime Override
68
- *
69
- * WORKAROUND: These variables are defined here instead of in tailwind-tokens-*.css
70
- * because Tailwind 4's @theme directive filters them out (similar issue as data-* prefix).
71
- *
72
- * Includes:
73
- * - Generic viz colors (--color-viz-*)
74
- * - Device state data viz colors (--color-state-*-data)
75
- *
76
- * AUTO-GENERATED by scripts/generate-viz-runtime.js
77
- * DO NOT EDIT MANUALLY - Edit theme-specific viz colors in:
78
- * - tokens/themes/light.json (light mode viz colors)
79
- * - tokens/themes/dark.json (dark mode viz colors)
80
- */
81
-
82
- /* Light theme (default) */
83
- :root {
84
- ${lightVizColors.map((color) => ` ${color}`).join("\n")}
85
- }
86
-
87
- /* Dark theme */
88
- .theme-dark {
89
- ${darkVizColors.map((color) => ` ${color}`).join("\n")}
90
- }
91
- `;
92
-
93
- // Write output
94
- fs.writeFileSync(OUTPUT_FILE, output, "utf8");
95
-
96
- console.log(`✅ Generated ${OUTPUT_FILE}`);
97
- console.log(` - Light theme: ${lightVizColors.length} variables`);
98
- console.log(` - Dark theme: ${darkVizColors.length} variables`);
99
- }
100
-
101
- // Run the script
102
- try {
103
- generateVizRuntime();
104
- } catch (error) {
105
- console.error("❌ Error generating viz-runtime.css:", error);
106
- process.exit(1);
107
- }
@@ -1,176 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Validates design tokens against DTCG (Design Tokens Community Group) spec
5
- * https://tr.designtokens.org/format/
6
- */
7
-
8
- import { readdirSync, readFileSync, statSync } from "fs";
9
- import { extname, join } from "path";
10
-
11
- const TOKENS_DIR = "./tokens";
12
- const _REQUIRED_SCHEMA = "https://tr.designtokens.org/format/0.1/";
13
-
14
- // DTCG spec required properties for different token types
15
- const TOKEN_TYPE_REQUIREMENTS = {
16
- color: ["$value"],
17
- dimension: ["$value"],
18
- fontFamily: ["$value"],
19
- fontWeight: ["$value"],
20
- duration: ["$value"],
21
- number: ["$value"],
22
- // Add more as needed
23
- };
24
-
25
- // Valid top-level properties
26
- const _VALID_TOP_LEVEL = ["$schema", "$name", "$description", "$type", "$value", "$extensions"];
27
-
28
- // Validation results
29
- const errors = [];
30
- const warnings = [];
31
- const successes = [];
32
-
33
- /**
34
- * Get all JSON files recursively
35
- */
36
- function getTokenFiles(dir) {
37
- const files = [];
38
- const items = readdirSync(dir);
39
-
40
- for (const item of items) {
41
- const path = join(dir, item);
42
- const stat = statSync(path);
43
-
44
- if (stat.isDirectory()) {
45
- files.push(...getTokenFiles(path));
46
- } else if (extname(path) === ".json") {
47
- files.push(path);
48
- }
49
- }
50
-
51
- return files;
52
- }
53
-
54
- /**
55
- * Validate a single token
56
- */
57
- function validateToken(token, path, parentType = null) {
58
- const type = token.$type || parentType;
59
-
60
- // Check for $value
61
- if (!token.$value && !hasNestedTokens(token)) {
62
- errors.push(`${path}: Token missing $value property`);
63
- return;
64
- }
65
-
66
- // If has $value, validate based on type
67
- if (token.$value && type) {
68
- const requirements = TOKEN_TYPE_REQUIREMENTS[type];
69
- if (requirements) {
70
- for (const req of requirements) {
71
- if (!(req in token)) {
72
- errors.push(`${path}: Token of type "${type}" missing required property "${req}"`);
73
- }
74
- }
75
- }
76
- }
77
-
78
- // Check for $description (recommended but not required)
79
- if (!token.$description && token.$value) {
80
- warnings.push(`${path}: Token missing $description (recommended)`);
81
- }
82
-
83
- // Validate nested tokens
84
- for (const key in token) {
85
- if (!key.startsWith("$") && typeof token[key] === "object") {
86
- validateToken(token[key], `${path}.${key}`, type);
87
- }
88
- }
89
- }
90
-
91
- /**
92
- * Check if object has nested tokens
93
- */
94
- function hasNestedTokens(obj) {
95
- for (const key in obj) {
96
- if (!key.startsWith("$") && typeof obj[key] === "object") {
97
- return true;
98
- }
99
- }
100
- return false;
101
- }
102
-
103
- /**
104
- * Validate a token file
105
- */
106
- function validateFile(filepath) {
107
- console.log(`\nValidating: ${filepath}`);
108
-
109
- try {
110
- const content = readFileSync(filepath, "utf8");
111
- const tokens = JSON.parse(content);
112
-
113
- // Check for $schema
114
- if (!tokens.$schema) {
115
- warnings.push(`${filepath}: Missing $schema declaration`);
116
- } else if (!tokens.$schema.includes("designtokens.org")) {
117
- warnings.push(`${filepath}: Non-standard schema: ${tokens.$schema}`);
118
- }
119
-
120
- // Check for $name
121
- if (!tokens.$name) {
122
- warnings.push(`${filepath}: Missing $name property (recommended)`);
123
- }
124
-
125
- // Validate all tokens
126
- for (const key in tokens) {
127
- if (!key.startsWith("$") && typeof tokens[key] === "object") {
128
- validateToken(tokens[key], `${filepath}:${key}`, tokens.$type);
129
- }
130
- }
131
-
132
- successes.push(`${filepath}: Valid DTCG token file`);
133
- } catch (error) {
134
- errors.push(`${filepath}: ${error.message}`);
135
- }
136
- }
137
-
138
- /**
139
- * Main validation
140
- */
141
- function main() {
142
- console.log("🔍 DTCG Token Validation\n");
143
- console.log("==========================");
144
-
145
- const files = getTokenFiles(TOKENS_DIR);
146
- console.log(`Found ${files.length} token files\n`);
147
-
148
- for (const file of files) {
149
- validateFile(file);
150
- }
151
-
152
- // Report results
153
- console.log("\n==========================");
154
- console.log("📊 Validation Results\n");
155
-
156
- if (successes.length > 0) {
157
- console.log("✅ Valid Files:");
158
- successes.forEach((s) => console.log(` ${s}`));
159
- }
160
-
161
- if (warnings.length > 0) {
162
- console.log("\n⚠️ Warnings:");
163
- warnings.forEach((w) => console.log(` ${w}`));
164
- }
165
-
166
- if (errors.length > 0) {
167
- console.log("\n❌ Errors:");
168
- errors.forEach((e) => console.log(` ${e}`));
169
- process.exit(1);
170
- } else {
171
- console.log("\n✨ All tokens are DTCG compliant!");
172
- }
173
- }
174
-
175
- // Run validation
176
- main();