@lostgradient/cinder 0.27.1 → 0.28.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 (261) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/components.json +1 -1
  3. package/dist/_internal/code-highlighter-context.d.ts +28 -0
  4. package/dist/cli/index.js +12 -8
  5. package/dist/components/approval-card/index.js +4 -4
  6. package/dist/components/button/button.css +25 -0
  7. package/dist/components/calendar/calendar.css +14 -0
  8. package/dist/components/capability-gate/capability-gate.css +5 -0
  9. package/dist/components/checkbox/checkbox.css +19 -0
  10. package/dist/components/chip/chip.css +14 -0
  11. package/dist/components/code-block/code-block.d.svelte.ts +1 -1
  12. package/dist/components/code-block/code-block.examples.json +1 -1
  13. package/dist/components/code-block/code-block.schema.js +3 -3
  14. package/dist/components/code-block/code-block.svelte.d.ts +1 -1
  15. package/dist/components/code-block/code-block.types.d.ts +14 -12
  16. package/dist/components/code-block/index.js +2 -2
  17. package/dist/components/color-picker/color-picker.css +2 -0
  18. package/dist/components/combobox/combobox.css +9 -1
  19. package/dist/components/command-palette/command-palette.css +7 -5
  20. package/dist/components/file-upload/file-upload.css +2 -1
  21. package/dist/components/guidance-region/index.css +1 -1
  22. package/dist/components/image/image.examples.json +1 -1
  23. package/dist/components/input/input.css +20 -6
  24. package/dist/components/json-schema-editor/index.js +5 -5
  25. package/dist/components/json-schema-editor/json-view-highlighter.d.ts +14 -0
  26. package/dist/components/key-value-editor/index.css +1 -1
  27. package/dist/components/modal-region/index.css +1 -1
  28. package/dist/components/multi-select/multi-select.css +9 -0
  29. package/dist/components/pagination/pagination.css +12 -0
  30. package/dist/components/pin-input/pin-input.css +9 -1
  31. package/dist/components/radio-group/radio-group.css +16 -0
  32. package/dist/components/run-step-timeline/index.js +2 -2
  33. package/dist/components/schema-form/index.js +2 -2
  34. package/dist/components/schema-form/schema-form.css +9 -0
  35. package/dist/components/segmented-control/segmented-control.css +3 -3
  36. package/dist/components/selection-popover/selection-popover.css +7 -1
  37. package/dist/components/tag-input/tag-input.css +10 -1
  38. package/dist/components/terminal-frame/index.js +2 -2
  39. package/dist/components/terminal-frame/terminal-frame.schema.js +2 -2
  40. package/dist/components/terminal-frame/terminal-frame.types.d.ts +8 -0
  41. package/dist/components/textarea/textarea.css +1 -1
  42. package/dist/components/toggle/toggle.css +16 -0
  43. package/dist/components/tree/tree.examples.json +1 -1
  44. package/dist/components/virtual-list/index.js +2 -2
  45. package/dist/components/virtual-list/virtual-list.css +42 -9
  46. package/dist/highlighters/shiki/default.d.ts +13 -1
  47. package/dist/highlighters/shiki/default.js +2 -2
  48. package/dist/highlighters/shiki/index.d.ts +20 -12
  49. package/dist/highlighters/shiki/index.js +2 -2
  50. package/dist/index.browser.css +1 -1
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +23 -23
  53. package/dist/scripts/knowledge/index.d.ts +5 -1
  54. package/dist/server/components/approval-card/index.js +1 -1
  55. package/dist/server/components/code-block/index.js +1 -1
  56. package/dist/server/components/color-field/index.js +2 -2
  57. package/dist/server/components/color-picker/index.js +2 -2
  58. package/dist/server/components/json-schema-editor/index.js +2 -2
  59. package/dist/server/components/run-step-timeline/index.js +1 -1
  60. package/dist/server/components/terminal-frame/index.js +1 -1
  61. package/dist/server/components/virtual-list/index.js +1 -1
  62. package/dist/server/github-dark-e7nywpbe.js +3 -0
  63. package/dist/server/github-light-bqtmm1zq.js +3 -0
  64. package/dist/server/highlighters/shiki/default.js +2 -2
  65. package/dist/server/highlighters/shiki/index.js +2 -2
  66. package/dist/server/index.js +6 -6
  67. package/dist/server/{index.server-4qyyw4y5.js → index.server-043cfznf.js} +1 -1
  68. package/dist/server/{index.server-p46tn4eb.js → index.server-09tjs48p.js} +2 -2
  69. package/dist/server/index.server-0hyvdf74.js +8 -0
  70. package/dist/server/{index.server-dxgkh9tk.js → index.server-17thvpd3.js} +1 -1
  71. package/dist/server/index.server-19z6hqd6.js +4 -0
  72. package/dist/server/index.server-31020qgk.js +3 -0
  73. package/dist/server/{index.server-w3nqzde5.js → index.server-45wmvjrn.js} +3 -3
  74. package/dist/server/{index.server-3tkgm2gn.js → index.server-6mb7w5g4.js} +2 -2
  75. package/dist/server/{index.server-2vxmn7x1.js → index.server-c5yajkkc.js} +4 -4
  76. package/dist/server/index.server-e6fknxd9.js +4 -0
  77. package/dist/server/index.server-fev4kwm0.js +4 -0
  78. package/dist/server/index.server-k4vjk75r.js +4 -0
  79. package/dist/server/index.server-mjbtd1gs.js +7 -0
  80. package/dist/server/{index.server-2bfkhzzq.js → index.server-rkp4py5n.js} +2 -2
  81. package/dist/server/index.server-wdz9tsq4.js +3 -0
  82. package/dist/server/index.server-zj9909hd.js +4 -0
  83. package/dist/server/json-68twtta3.js +3 -0
  84. package/dist/server/tokens/registry.generated.js +1 -1
  85. package/dist/server/tokens/runtime/index.js +92 -0
  86. package/dist/styles/check-token-contrast-test-values.d.ts +1 -3
  87. package/dist/styles/token-contrast-test-readers.d.ts +1 -1
  88. package/dist/tokens/registry.generated.js +2 -2
  89. package/dist/tokens/resolved/dark-reduced-motion.json +104 -43
  90. package/dist/tokens/resolved/dark.json +104 -43
  91. package/dist/tokens/resolved/light-reduced-motion.json +104 -43
  92. package/dist/tokens/resolved/light.json +104 -43
  93. package/dist/tokens/runtime/authoring-catalogue.d.ts +19 -0
  94. package/dist/tokens/runtime/authoring-catalogue.generated.d.ts +8 -0
  95. package/dist/tokens/runtime/authoring-palette.d.ts +25 -0
  96. package/dist/tokens/runtime/authoring-profiles.d.ts +48 -0
  97. package/dist/tokens/runtime/authoring-provenance.d.ts +31 -0
  98. package/dist/tokens/runtime/authoring-types.d.ts +182 -0
  99. package/dist/tokens/runtime/base-corpus.d.ts +29 -0
  100. package/dist/tokens/runtime/base-corpus.generated.d.ts +8 -0
  101. package/dist/tokens/runtime/context-order.d.ts +60 -0
  102. package/dist/tokens/runtime/context-stack.d.ts +11 -0
  103. package/dist/tokens/runtime/contrast/color-difference.d.ts +16 -0
  104. package/dist/{styles/color-contrast-utilities.d.ts → tokens/runtime/contrast/color-math.d.ts} +2 -17
  105. package/dist/tokens/runtime/contrast/color-mix.d.ts +3 -0
  106. package/dist/tokens/runtime/contrast/css-color.d.ts +29 -0
  107. package/dist/tokens/runtime/contrast/index.d.ts +7 -0
  108. package/dist/tokens/runtime/contrast/measure.d.ts +45 -0
  109. package/dist/tokens/runtime/contrast/pairings.d.ts +36 -0
  110. package/dist/tokens/runtime/contrast/thresholds.d.ts +47 -0
  111. package/dist/tokens/runtime/corpus-documents.d.ts +36 -0
  112. package/dist/tokens/runtime/corpus-validation.d.ts +10 -0
  113. package/dist/tokens/runtime/corpus.d.ts +35 -0
  114. package/dist/tokens/runtime/css-configuration.d.ts +1 -0
  115. package/dist/tokens/runtime/css-stylelint.d.ts +2 -0
  116. package/dist/tokens/runtime/css-support.d.ts +110 -0
  117. package/dist/tokens/runtime/evaluate.d.ts +95 -0
  118. package/dist/tokens/runtime/evaluated-provenance.d.ts +36 -0
  119. package/dist/tokens/runtime/index.d.ts +38 -0
  120. package/dist/tokens/runtime/index.js +95 -0
  121. package/dist/tokens/runtime/package-version.generated.d.ts +9 -0
  122. package/dist/tokens/runtime/projection.d.ts +32 -0
  123. package/dist/tokens/runtime/registry.d.ts +125 -0
  124. package/dist/tokens/runtime/resolve-extends.d.ts +30 -0
  125. package/dist/tokens/runtime/resolve-references.d.ts +49 -0
  126. package/dist/tokens/runtime/resolve-shared.d.ts +34 -0
  127. package/dist/tokens/runtime/resolve.d.ts +44 -0
  128. package/dist/tokens/runtime/resolver-order.d.ts +89 -0
  129. package/dist/tokens/runtime/source-digest.d.ts +20 -0
  130. package/dist/tokens/runtime/stylesheet-skeleton.d.ts +31 -0
  131. package/dist/tokens/runtime/theme-runtime.test-support.d.ts +24 -0
  132. package/dist/tokens/runtime/theme-sources.d.ts +46 -0
  133. package/dist/tokens/runtime/theme-stylesheet.d.ts +31 -0
  134. package/dist/tokens/runtime/types.d.ts +115 -0
  135. package/dist/tokens/runtime/validate-resolver.d.ts +31 -0
  136. package/dist/tokens/runtime/validate-schema.d.ts +22 -0
  137. package/dist/tokens/runtime/validate-tokens.d.ts +25 -0
  138. package/dist/tokens/runtime/validate-values.d.ts +33 -0
  139. package/dist/tokens/runtime/validate.d.ts +3 -0
  140. package/dist/tokens/runtime/value-color-parse.d.ts +128 -0
  141. package/dist/tokens/runtime/value-color.d.ts +85 -0
  142. package/dist/tokens/runtime/value-entry.d.ts +3 -0
  143. package/dist/tokens/runtime/value-formatters.d.ts +59 -0
  144. package/dist/tokens/sets/colors.tokens.json +65 -13
  145. package/dist/tokens/sets/foundation.tokens.json +23 -0
  146. package/dist/tokens/sets/semantic.tokens.json +136 -30
  147. package/dist/utilities/highlighter.d.ts +5 -5
  148. package/dist/utilities/retrying-loader-cache.d.ts +3 -6
  149. package/package.json +15 -3
  150. package/src/_internal/code-highlighter-context.ts +41 -0
  151. package/src/components/button/button.css +25 -0
  152. package/src/components/calendar/calendar.css +14 -0
  153. package/src/components/capability-gate/capability-gate.css +5 -0
  154. package/src/components/checkbox/checkbox.css +19 -0
  155. package/src/components/chip/chip.css +14 -0
  156. package/src/components/code-block/code-block.examples.json +1 -1
  157. package/src/components/code-block/code-block.schema.json +2 -2
  158. package/src/components/code-block/code-block.schema.ts +2 -2
  159. package/src/components/code-block/code-block.svelte +15 -19
  160. package/src/components/code-block/code-block.types.ts +14 -12
  161. package/src/components/color-picker/color-picker.css +2 -0
  162. package/src/components/combobox/combobox.css +9 -1
  163. package/src/components/command-palette/command-palette.css +7 -5
  164. package/src/components/file-upload/file-upload.css +2 -1
  165. package/src/components/image/image.examples.json +1 -1
  166. package/src/components/input/input.css +20 -6
  167. package/src/components/json-schema-editor/json-view-highlighter.ts +23 -0
  168. package/src/components/json-schema-editor/json-view.svelte +2 -0
  169. package/src/components/multi-select/multi-select.css +9 -0
  170. package/src/components/pagination/pagination.css +12 -0
  171. package/src/components/pin-input/pin-input.css +9 -1
  172. package/src/components/radio-group/radio-group.css +16 -0
  173. package/src/components/schema-form/schema-form.css +9 -0
  174. package/src/components/segmented-control/segmented-control.css +3 -3
  175. package/src/components/selection-popover/selection-popover.css +7 -1
  176. package/src/components/tag-input/tag-input.css +10 -1
  177. package/src/components/terminal-frame/terminal-frame.schema.json +5 -0
  178. package/src/components/terminal-frame/terminal-frame.schema.ts +6 -0
  179. package/src/components/terminal-frame/terminal-frame.svelte +6 -2
  180. package/src/components/terminal-frame/terminal-frame.types.ts +8 -0
  181. package/src/components/textarea/textarea.css +1 -1
  182. package/src/components/toggle/toggle.css +16 -0
  183. package/src/components/tree/tree.examples.json +1 -1
  184. package/src/components/virtual-list/virtual-list.css +42 -9
  185. package/src/components/virtual-list/virtual-list.svelte +54 -20
  186. package/src/highlighters/shiki/default.ts +13 -1
  187. package/src/highlighters/shiki/index.ts +20 -12
  188. package/src/index.ts +5 -0
  189. package/src/styles/foundation.css +33 -1
  190. package/src/styles/tokens-base.css +4 -4
  191. package/src/tokens/registry.generated.json +3 -3
  192. package/src/tokens/resolved/dark-reduced-motion.json +104 -43
  193. package/src/tokens/resolved/dark.json +104 -43
  194. package/src/tokens/resolved/light-reduced-motion.json +104 -43
  195. package/src/tokens/resolved/light.json +104 -43
  196. package/src/tokens/runtime/authoring-catalogue.generated.ts +19300 -0
  197. package/src/tokens/runtime/authoring-catalogue.ts +256 -0
  198. package/src/tokens/runtime/authoring-palette.ts +100 -0
  199. package/src/tokens/runtime/authoring-profiles.ts +288 -0
  200. package/src/tokens/runtime/authoring-provenance.ts +290 -0
  201. package/src/tokens/runtime/authoring-types.ts +199 -0
  202. package/src/tokens/runtime/base-corpus.generated.ts +10 -0
  203. package/src/tokens/runtime/base-corpus.ts +78 -0
  204. package/src/tokens/runtime/context-order.ts +182 -0
  205. package/src/tokens/runtime/context-stack.ts +52 -0
  206. package/src/tokens/runtime/contrast/color-difference.ts +114 -0
  207. package/src/tokens/runtime/contrast/color-math.ts +89 -0
  208. package/src/tokens/runtime/contrast/color-mix.ts +20 -0
  209. package/src/tokens/runtime/contrast/css-color.ts +312 -0
  210. package/src/tokens/runtime/contrast/index.ts +7 -0
  211. package/src/tokens/runtime/contrast/measure.ts +185 -0
  212. package/src/tokens/runtime/contrast/pairings.ts +324 -0
  213. package/src/tokens/runtime/contrast/thresholds.ts +81 -0
  214. package/src/tokens/runtime/corpus-documents.ts +289 -0
  215. package/src/tokens/runtime/corpus-validation.ts +336 -0
  216. package/src/tokens/runtime/corpus.ts +179 -0
  217. package/src/tokens/runtime/css-configuration.ts +1 -0
  218. package/src/tokens/runtime/css-stylelint.ts +15 -0
  219. package/src/tokens/runtime/css-support.ts +407 -0
  220. package/src/tokens/runtime/evaluate.ts +262 -0
  221. package/src/tokens/runtime/evaluated-provenance.ts +116 -0
  222. package/src/tokens/runtime/format-validator.generated.d.ts +18 -0
  223. package/src/tokens/runtime/format-validator.generated.js +13029 -0
  224. package/src/tokens/runtime/index.ts +78 -0
  225. package/src/tokens/runtime/package-version.generated.ts +9 -0
  226. package/src/tokens/runtime/projection.ts +65 -0
  227. package/src/tokens/runtime/registry.ts +365 -0
  228. package/src/tokens/runtime/resolve-extends.ts +211 -0
  229. package/src/tokens/runtime/resolve-references.ts +313 -0
  230. package/src/tokens/runtime/resolve-shared.ts +186 -0
  231. package/src/tokens/runtime/resolve.ts +246 -0
  232. package/src/tokens/runtime/resolver-order.ts +326 -0
  233. package/src/tokens/runtime/resolver-validator.generated.d.ts +18 -0
  234. package/src/tokens/runtime/resolver-validator.generated.js +15492 -0
  235. package/src/tokens/runtime/source-digest.ts +49 -0
  236. package/src/tokens/runtime/stylesheet-skeleton.ts +123 -0
  237. package/src/tokens/runtime/theme-sources.ts +121 -0
  238. package/src/tokens/runtime/theme-stylesheet.ts +177 -0
  239. package/src/tokens/runtime/types.ts +140 -0
  240. package/src/tokens/runtime/validate-resolver.ts +338 -0
  241. package/src/tokens/runtime/validate-schema.ts +269 -0
  242. package/src/tokens/runtime/validate-tokens.ts +181 -0
  243. package/src/tokens/runtime/validate-values.ts +396 -0
  244. package/src/tokens/runtime/validate.ts +57 -0
  245. package/src/tokens/runtime/value-color-parse.ts +309 -0
  246. package/src/tokens/runtime/value-color.ts +217 -0
  247. package/src/tokens/runtime/value-entry.ts +52 -0
  248. package/src/tokens/runtime/value-formatters.ts +414 -0
  249. package/src/tokens/sets/colors.tokens.json +65 -13
  250. package/src/tokens/sets/foundation.tokens.json +23 -0
  251. package/src/tokens/sets/semantic.tokens.json +136 -30
  252. package/src/utilities/highlighter.ts +5 -5
  253. package/src/utilities/retrying-loader-cache.ts +3 -6
  254. package/dist/components/code-block/code-block-default-highlighter.d.ts +0 -40
  255. package/dist/server/index.server-298z43yn.js +0 -4
  256. package/dist/server/index.server-3h11wjyh.js +0 -8
  257. package/dist/server/index.server-a3aerbfr.js +0 -4
  258. package/dist/server/index.server-kge3zp6n.js +0 -4
  259. package/dist/server/index.server-syf81nwz.js +0 -6
  260. package/dist/server/index.server-zs08f5te.js +0 -3
  261. package/src/components/code-block/code-block-default-highlighter.ts +0 -63
@@ -0,0 +1,336 @@
1
+ import { mergeAndExpandExtends, resolveDocuments } from './resolve.ts';
2
+ import {
3
+ expandContextSources,
4
+ expandSetSources,
5
+ internalSetNames,
6
+ normalizeSourcePath,
7
+ parseResolutionOrder,
8
+ reachableSetNames,
9
+ } from './resolver-order.ts';
10
+ import { TokenValidationError, type ResolverDocument, type TokenDocument } from './types.ts';
11
+
12
+ export function validateModifierSetExpansionOrder(
13
+ resolver: ResolverDocument,
14
+ documentsByPath?: Map<string, TokenDocument>,
15
+ ): void {
16
+ const order = parseResolutionOrder(resolver);
17
+ const basePositions = new Map<string, number>();
18
+ const baseDocumentSets = new Map<string, Set<string>>();
19
+ for (const [position, entry] of order.entries()) {
20
+ if (entry.kind !== 'sets') continue;
21
+ for (const setName of reachableSetNames(resolver, entry.name)) {
22
+ basePositions.set(setName, position);
23
+ for (const source of expandSetSources(resolver, setName)) {
24
+ const path = normalizeSourcePath(source.$ref);
25
+ const setNames = baseDocumentSets.get(path) ?? new Set<string>();
26
+ setNames.add(setName);
27
+ baseDocumentSets.set(path, setNames);
28
+ }
29
+ }
30
+ }
31
+ const baseDocuments = documentsByPath
32
+ ? order
33
+ .filter((entry) => entry.kind === 'sets')
34
+ .flatMap((entry) =>
35
+ expandSetSources(resolver, entry.name).map((source) =>
36
+ documentsByPath.get(normalizeSourcePath(source.$ref))!,
37
+ ),
38
+ )
39
+ : [];
40
+
41
+ const issues = [];
42
+ for (const [position, entry] of order.entries()) {
43
+ if (entry.kind !== 'modifiers') continue;
44
+ const modifier = resolver.modifiers[entry.name];
45
+ if (!modifier) continue;
46
+ for (const [contextName, sources] of Object.entries(modifier.contexts)) {
47
+ const internallyReferencedSetNames = new Set(
48
+ internalSetNames(sources).flatMap((setName) => [...reachableSetNames(resolver, setName)]),
49
+ );
50
+ const referencedSetNames = new Set(internallyReferencedSetNames);
51
+ for (const source of expandContextSources(resolver, entry.name, contextName)) {
52
+ for (const setName of baseDocumentSets.get(normalizeSourcePath(source.$ref)) ?? []) {
53
+ referencedSetNames.add(setName);
54
+ }
55
+ }
56
+ for (const setName of referencedSetNames) {
57
+ const basePosition = basePositions.get(setName);
58
+ if (basePosition === undefined) continue;
59
+ const setTokenPaths = new Set<string>();
60
+ if (documentsByPath) {
61
+ const expandedContextSources = expandContextSources(resolver, entry.name, contextName);
62
+ const contextDocuments = expandedContextSources.map((source) =>
63
+ documentsByPath.get(normalizeSourcePath(source.$ref))!,
64
+ );
65
+ const resetSourcePaths = new Set(
66
+ expandSetSources(resolver, setName).map((source) => normalizeSourcePath(source.$ref)),
67
+ );
68
+ // A set can contain multiple source documents, and a context can
69
+ // re-expand only some of them. Track each token's reset position
70
+ // independently instead of using one last index for the whole set.
71
+ const resetPositions = new Map<string, number>();
72
+ for (const [sourceIndex, source] of expandedContextSources.entries()) {
73
+ const sourcePath = normalizeSourcePath(source.$ref);
74
+ if (!resetSourcePaths.has(sourcePath)) continue;
75
+ const sourcePaths = new Set<string>();
76
+ collectDeclaredTokenPaths(
77
+ mergeAndExpandExtends(
78
+ [documentsByPath.get(sourcePath)!],
79
+ [...baseDocuments, ...contextDocuments.slice(0, sourceIndex + 1)],
80
+ ),
81
+ '',
82
+ sourcePaths,
83
+ );
84
+ for (const tokenPath of sourcePaths) {
85
+ resetPositions.set(tokenPath, sourceIndex);
86
+ }
87
+ }
88
+ const expandedSuffixPaths = (startIndex: number): Set<string> => {
89
+ const suffixPaths = new Set<string>();
90
+ const suffixDocuments = contextDocuments.slice(startIndex);
91
+ if (suffixDocuments.length === 0) return suffixPaths;
92
+ collectDeclaredTokenPaths(
93
+ mergeAndExpandExtends(suffixDocuments, [...baseDocuments, ...contextDocuments]),
94
+ '',
95
+ suffixPaths,
96
+ );
97
+ return suffixPaths;
98
+ };
99
+ for (const [tokenPath, resetIndex] of resetPositions) {
100
+ if (!expandedSuffixPaths(resetIndex + 1).has(tokenPath)) setTokenPaths.add(tokenPath);
101
+ }
102
+ }
103
+ const interveningModifier = order.slice(basePosition + 1, position).find((candidate) => {
104
+ if (candidate.kind !== 'modifiers') return false;
105
+ if (!documentsByPath) return true;
106
+ const candidateModifier = resolver.modifiers[candidate.name];
107
+ if (!candidateModifier) return false;
108
+ return Object.keys(candidateModifier.contexts).some((candidateContext) => {
109
+ const affectedPaths = new Set<string>();
110
+ const candidateDocuments = expandContextSources(
111
+ resolver,
112
+ candidate.name,
113
+ candidateContext,
114
+ ).map((candidateSource) =>
115
+ documentsByPath.get(normalizeSourcePath(candidateSource.$ref))!,
116
+ );
117
+ collectDeclaredTokenPaths(
118
+ mergeAndExpandExtends(candidateDocuments, [...baseDocuments, ...candidateDocuments]),
119
+ '',
120
+ affectedPaths,
121
+ );
122
+ // Resolve this modifier in the scope established by the ordered
123
+ // entries before it. A candidate may reference a token changed by
124
+ // an earlier modifier; comparing against base-only would miss the
125
+ // resulting effective-value reset.
126
+ const precedingModifierNames = order
127
+ .slice(0, order.indexOf(candidate))
128
+ .filter((preceding) => preceding.kind === 'modifiers')
129
+ .map((preceding) => preceding.name);
130
+ const prefixContextCombinations = precedingModifierNames.reduce<
131
+ Array<Map<string, string>>
132
+ >(
133
+ (selections, modifierName) =>
134
+ selections.flatMap((selection) =>
135
+ Object.keys(resolver.modifiers[modifierName]!.contexts).map(
136
+ (precedingContextName) => {
137
+ const next = new Map(selection);
138
+ next.set(modifierName, precedingContextName);
139
+ return next;
140
+ },
141
+ ),
142
+ ),
143
+ [new Map()],
144
+ );
145
+ return prefixContextCombinations.some((contextSelection) => {
146
+ const precedingDocuments = order
147
+ .slice(0, order.indexOf(candidate))
148
+ .flatMap((preceding) => {
149
+ if (preceding.kind === 'sets') return expandSetSources(resolver, preceding.name);
150
+ const precedingContext = contextSelection.get(preceding.name);
151
+ return precedingContext === undefined
152
+ ? []
153
+ : expandContextSources(resolver, preceding.name, precedingContext);
154
+ })
155
+ .map((source) => documentsByPath.get(normalizeSourcePath(source.$ref))!);
156
+ const before = resolveDocuments(precedingDocuments);
157
+ const after = resolveDocuments([...precedingDocuments, ...candidateDocuments]);
158
+ return [...affectedPaths].some(
159
+ (path) =>
160
+ setTokenPaths.has(path) &&
161
+ JSON.stringify(canonicalizeJson(before[path])) !==
162
+ JSON.stringify(canonicalizeJson(after[path])),
163
+ );
164
+ });
165
+ });
166
+ });
167
+ if (!interveningModifier) continue;
168
+ issues.push({
169
+ path: `$.modifiers.${entry.name}.contexts.${contextName}`,
170
+ reason:
171
+ `set "${setName}" is re-expanded after modifier "${interveningModifier.name}" ` +
172
+ 'and would reset its intervening overrides',
173
+ });
174
+ }
175
+ }
176
+ }
177
+ if (issues.length > 0) throw new TokenValidationError(issues);
178
+ }
179
+
180
+ export function collectDeclaredTokenPaths(
181
+ value: unknown,
182
+ prefix: string,
183
+ paths: Set<string>,
184
+ ): void {
185
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return;
186
+ if ('$value' in value || '$ref' in value) {
187
+ paths.add(prefix);
188
+ return;
189
+ }
190
+ for (const [name, child] of Object.entries(value)) {
191
+ if (name.startsWith('$')) {
192
+ if (name === '$root') collectDeclaredTokenPaths(child, prefix, paths);
193
+ continue;
194
+ }
195
+ collectDeclaredTokenPaths(child, prefix ? `${prefix}.${name}` : name, paths);
196
+ }
197
+ }
198
+
199
+ export function collectSemanticGroupMetadataPaths(
200
+ value: unknown,
201
+ prefix: string,
202
+ paths: Set<string>,
203
+ ): void {
204
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return;
205
+ if ('$value' in value || '$ref' in value) return;
206
+ if ('$type' in value || '$deprecated' in value || '$extensions' in value) paths.add(prefix);
207
+ for (const [name, child] of Object.entries(value)) {
208
+ if (name.startsWith('$')) continue;
209
+ collectSemanticGroupMetadataPaths(child, prefix ? `${prefix}.${name}` : name, paths);
210
+ }
211
+ }
212
+
213
+ export function isRecord(value: unknown): value is Record<string, unknown> {
214
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
215
+ }
216
+
217
+ export function canonicalizeJson(value: unknown): unknown {
218
+ if (Array.isArray(value)) return value.map(canonicalizeJson);
219
+ if (!isRecord(value)) return value;
220
+ return Object.fromEntries(
221
+ Object.entries(value)
222
+ .toSorted(([left], [right]) => left.localeCompare(right))
223
+ .map(([key, child]) => [key, canonicalizeJson(child)]),
224
+ );
225
+ }
226
+
227
+ export function mergeMetadataValue(base: unknown, override: unknown): unknown {
228
+ if (!isRecord(base) || !isRecord(override)) return override;
229
+ const merged = { ...base };
230
+ for (const [key, value] of Object.entries(override)) {
231
+ merged[key] = mergeMetadataValue(base[key], value);
232
+ }
233
+ return merged;
234
+ }
235
+
236
+ export function semanticGroupMetadataByPath(value: unknown): Map<string, Record<string, unknown>> {
237
+ const metadata = new Map<string, Record<string, unknown>>();
238
+ const visit = (node: unknown, prefix: string, inherited: Record<string, unknown> = {}): void => {
239
+ if (!isRecord(node)) return;
240
+ if ('$value' in node || '$ref' in node) return;
241
+ const effective = {
242
+ $type: node['$type'] ?? inherited['$type'],
243
+ $deprecated: node['$deprecated'] ?? inherited['$deprecated'],
244
+ $extensions: node['$extensions'] ?? inherited['$extensions'],
245
+ };
246
+ metadata.set(prefix, effective);
247
+ for (const [name, child] of Object.entries(node)) {
248
+ if (name.startsWith('$')) continue;
249
+ visit(child, prefix ? `${prefix}.${name}` : name, effective);
250
+ }
251
+ };
252
+ visit(value, '');
253
+ return metadata;
254
+ }
255
+
256
+ /** Validates modifier declarations against the token paths contributed by ordered base sets. */
257
+ export function validateModifierTokenPaths(
258
+ resolver: ResolverDocument,
259
+ documentsByPath: Map<string, TokenDocument>,
260
+ ): void {
261
+ const baseDocuments = parseResolutionOrder(resolver)
262
+ .filter((entry) => entry.kind === 'sets')
263
+ .flatMap((entry) =>
264
+ expandSetSources(resolver, entry.name).map((source) =>
265
+ documentsByPath.get(normalizeSourcePath(source.$ref))!,
266
+ ),
267
+ );
268
+ const basePaths = new Set<string>();
269
+ // Expand the same `$extends` inheritance used by the resolver and generator
270
+ // before collecting paths. Otherwise a modifier that overrides an inherited
271
+ // member is reported as having no matching base token.
272
+ collectDeclaredTokenPaths(mergeAndExpandExtends(baseDocuments), '', basePaths);
273
+ const baseMetadata = semanticGroupMetadataByPath(mergeAndExpandExtends(baseDocuments));
274
+ const issues = [];
275
+ for (const [modifierName, modifier] of Object.entries(resolver.modifiers)) {
276
+ for (const contextName of Object.keys(modifier.contexts)) {
277
+ const declaredPaths = new Set<string>();
278
+ const contextDocuments = expandContextSources(resolver, modifierName, contextName).map(
279
+ (source) => documentsByPath.get(normalizeSourcePath(source.$ref))!,
280
+ );
281
+ const explicitlyDeclaredPaths = new Set<string>();
282
+ const semanticGroupMetadataPaths = new Set<string>();
283
+ const expandedContext = mergeAndExpandExtends(contextDocuments, [
284
+ ...baseDocuments,
285
+ ...contextDocuments,
286
+ ]);
287
+ collectDeclaredTokenPaths(expandedContext, '', declaredPaths);
288
+ // `$extends` can contribute the effective token leaves of an override
289
+ // context. Treat those expanded paths as explicit too, otherwise group
290
+ // metadata validation reports inherited members as unoverridden.
291
+ collectDeclaredTokenPaths(expandedContext, '', explicitlyDeclaredPaths);
292
+ collectSemanticGroupMetadataPaths(expandedContext, '', semanticGroupMetadataPaths);
293
+ const contextMetadata = semanticGroupMetadataByPath(expandedContext);
294
+ for (const tokenPath of declaredPaths) {
295
+ if (basePaths.has(tokenPath)) continue;
296
+ issues.push({
297
+ path: `$.modifiers.${modifierName}.contexts.${contextName}.${tokenPath}`,
298
+ reason: `override token "${tokenPath}" has no matching base token`,
299
+ });
300
+ }
301
+ for (const groupPath of semanticGroupMetadataPaths) {
302
+ const baseEffective = baseMetadata.get(groupPath) ?? {};
303
+ const contextEffective = contextMetadata.get(groupPath) ?? {};
304
+ const overlaidEffective = {
305
+ ...baseEffective,
306
+ ...Object.fromEntries(
307
+ Object.entries(contextEffective)
308
+ .filter(([, metadataValue]) => metadataValue !== undefined)
309
+ .map(([metadataName, metadataValue]) => [
310
+ metadataName,
311
+ mergeMetadataValue(baseEffective[metadataName], metadataValue),
312
+ ]),
313
+ ),
314
+ };
315
+ if (
316
+ JSON.stringify(canonicalizeJson(overlaidEffective)) ===
317
+ JSON.stringify(canonicalizeJson(baseEffective))
318
+ )
319
+ continue;
320
+ const unoverriddenBasePath = [...basePaths].find(
321
+ (basePath) =>
322
+ (groupPath === '' || basePath === groupPath || basePath.startsWith(`${groupPath}.`)) &&
323
+ !explicitlyDeclaredPaths.has(basePath),
324
+ );
325
+ if (unoverriddenBasePath === undefined) continue;
326
+ issues.push({
327
+ path: `$.modifiers.${modifierName}.contexts.${contextName}.${groupPath || '$root'}`,
328
+ reason:
329
+ `group metadata affects base token "${unoverriddenBasePath}" without an explicit override; ` +
330
+ 'resolved token semantics would diverge from generated CSS',
331
+ });
332
+ }
333
+ }
334
+ }
335
+ if (issues.length > 0) throw new TokenValidationError(issues);
336
+ }
@@ -0,0 +1,179 @@
1
+ import type { DesignToken, TokenGroup, TokenType } from './types.ts';
2
+
3
+ // Collects every `$value`-bearing node in a merged
4
+ // document into a flat `path -> entry` map, preserving RAW (unresolved)
5
+ // values -- alias references stay as `{a.b.c}` strings rather than being
6
+ // resolved to a literal, since a raw alias tells us to emit `var(...)`
7
+ // against the referenced token's OWN `cssProperty`, matching how
8
+ // tokens-base.css is hand-authored today. This mirrors resolve.ts's
9
+ // `collectTokens` (group `$root` handling, `$type` inheritance through
10
+ // nested groups) but deliberately stops short of alias resolution.
11
+
12
+ export type CorpusEntry = {
13
+ path: string;
14
+ value: unknown;
15
+ type: TokenType | undefined;
16
+ description: string | undefined;
17
+ cssProperty: string | undefined;
18
+ cssRecipe: string | undefined;
19
+ /**
20
+ * The remaining `com.lostgradient.cinder` extension fields and the DTCG
21
+ * `$deprecated` flag, carried through purely for {@link registry.ts}'s
22
+ * `buildTokenRegistry` -- CSS generation in this file never reads them.
23
+ * Kept on `CorpusEntry` itself (rather than a second, parallel tree walk)
24
+ * so the registry reuses the exact same `collectEntries` traversal that
25
+ * produces `tokens-base.css`, instead of re-deriving corpus structure.
26
+ */
27
+ public?: boolean | undefined;
28
+ category?: string | undefined;
29
+ component?: string | undefined;
30
+ deprecated?: boolean | string | undefined;
31
+ /**
32
+ * True when `value` came from `$ref` rather than `$value`. `$ref` is a
33
+ * generic JSON Pointer with no DTCG requirement that its target be a whole
34
+ * token -- unlike an ordinary bare alias `$value`, which this generator has
35
+ * always required to name a whole token (a deliberate, pre-existing
36
+ * restriction; see `resolveAlias`'s own comment). `serializeEntryValue`
37
+ * uses this flag to allow a `$ref` alone to fall through to typed
38
+ * serialization when it targets a property rather than a whole token,
39
+ * without loosening that restriction for ordinary `$value` aliases.
40
+ */
41
+ isRefAlias?: boolean | undefined;
42
+ };
43
+
44
+ export function isPlainObject(value: unknown): value is Record<string, unknown> {
45
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
46
+ }
47
+
48
+ function isToken(value: unknown): value is DesignToken {
49
+ // Mirrors resolve.ts's `isToken`: a DTCG 2025.10 `$ref` whole-token alias
50
+ // is mutually exclusive with `$value`, so a node declaring either is
51
+ // token-shaped. This walker classifies the RAW, unresolved corpus (see the
52
+ // module doc above) -- checking `$value` alone was the CIN-463 "live trap"
53
+ // recurring a third time here, independent of resolve.ts's own copy: a
54
+ // `$ref`-only node fell through to `isTokenGroup`, was walked as an empty
55
+ // group, and silently vanished from `tokens-base.css` and the generated
56
+ // registry (both of which reuse `collectEntries` below) even though it
57
+ // validated and resolved correctly.
58
+ return isPlainObject(value) && ('$value' in value || '$ref' in value);
59
+ }
60
+
61
+ function isTokenGroup(value: unknown): value is TokenGroup {
62
+ return isPlainObject(value) && !isToken(value);
63
+ }
64
+
65
+ export function cinderExtensions(token: DesignToken): Record<string, unknown> | undefined {
66
+ const extensions = token.$extensions;
67
+ if (!isPlainObject(extensions)) return undefined;
68
+ const own = extensions['com.lostgradient.cinder'];
69
+ return isPlainObject(own) ? own : undefined;
70
+ }
71
+
72
+ function extensionString(
73
+ extensions: Record<string, unknown> | undefined,
74
+ name: string,
75
+ ): string | undefined {
76
+ const value = extensions?.[name];
77
+ return typeof value === 'string' ? value : undefined;
78
+ }
79
+
80
+ function extensionBoolean(
81
+ extensions: Record<string, unknown> | undefined,
82
+ name: string,
83
+ ): boolean | undefined {
84
+ const value = extensions?.[name];
85
+ return typeof value === 'boolean' ? value : undefined;
86
+ }
87
+
88
+ function deprecatedValue(
89
+ token: DesignToken | TokenGroup,
90
+ fallback: boolean | string | undefined,
91
+ ): boolean | string | undefined {
92
+ return typeof token.$deprecated === 'boolean' || typeof token.$deprecated === 'string'
93
+ ? token.$deprecated
94
+ : fallback;
95
+ }
96
+
97
+ function toEntry(
98
+ path: string,
99
+ token: DesignToken,
100
+ inheritedType: TokenType | undefined,
101
+ inheritedDeprecated: boolean | string | undefined,
102
+ ): CorpusEntry {
103
+ const extensions = cinderExtensions(token);
104
+ const cssProperty = extensionString(extensions, 'cssProperty');
105
+ const cssRecipe = extensionString(extensions, 'cssRecipe');
106
+ const category = extensionString(extensions, 'category');
107
+ const component = extensionString(extensions, 'component');
108
+ const isPublic = extensionBoolean(extensions, 'public');
109
+ // DTCG makes `$deprecated` inheritable the same way `$type` is, and the
110
+ // flattened corpus keeps no group records -- so without carrying the
111
+ // ancestor state down, a `$deprecated` group whose children do not repeat the
112
+ // field loses it entirely and every descendant is reported `deprecated:
113
+ // false`, letting registry consumers surface a deprecated group's tokens as
114
+ // current. A token's own `$deprecated` still wins: a group can deprecate its
115
+ // children, and a child can carry its own (more specific) reason string.
116
+ const deprecated = deprecatedValue(token, inheritedDeprecated);
117
+ // A `$ref` whole-token alias has no `$value` of its own -- the reference
118
+ // string ITSELF is the raw, unresolved value this walker records (mirroring
119
+ // how an ordinary embedded `{a.b.c}`/`#/a/b/c` alias is kept raw rather than
120
+ // resolved here; see the module doc above). `isAliasReference` in
121
+ // `serializeEntryValue` recognizes both forms identically, so a `$ref`
122
+ // token flows through the exact same `var(--referenced-property)` emission
123
+ // path as an ordinary aliased `$value`, rather than a second alias-handling
124
+ // code path.
125
+ const value = token.$ref ?? token.$value;
126
+ return {
127
+ path,
128
+ value,
129
+ type: token.$type ?? inheritedType,
130
+ description: token.$description,
131
+ cssProperty,
132
+ cssRecipe,
133
+ public: isPublic,
134
+ category,
135
+ component,
136
+ deprecated,
137
+ isRefAlias: token.$ref !== undefined,
138
+ };
139
+ }
140
+
141
+ export function collectEntries(
142
+ group: TokenGroup,
143
+ prefix: string,
144
+ inheritedType: TokenType | undefined,
145
+ into: Map<string, CorpusEntry>,
146
+ inheritedDeprecated?: boolean | string,
147
+ ): void {
148
+ const groupType = group.$type ?? inheritedType;
149
+ // `false` on a group is a real value, not an absence: it un-deprecates a
150
+ // subtree beneath a deprecated ancestor, so `??` rather than `||` here.
151
+ const groupDeprecated = deprecatedValue(group, inheritedDeprecated);
152
+ collectRootEntry(group, prefix, groupType, groupDeprecated, into);
153
+ collectChildEntries(group, prefix, groupType, groupDeprecated, into);
154
+ }
155
+
156
+ function collectRootEntry(
157
+ group: TokenGroup,
158
+ prefix: string,
159
+ type: TokenType | undefined,
160
+ deprecated: boolean | string | undefined,
161
+ into: Map<string, CorpusEntry>,
162
+ ): void {
163
+ if (isToken(group.$root)) into.set(prefix, toEntry(prefix, group.$root, type, deprecated));
164
+ }
165
+
166
+ function collectChildEntries(
167
+ group: TokenGroup,
168
+ prefix: string,
169
+ type: TokenType | undefined,
170
+ deprecated: boolean | string | undefined,
171
+ into: Map<string, CorpusEntry>,
172
+ ): void {
173
+ for (const [name, value] of Object.entries(group)) {
174
+ if (name.startsWith('$') || !isPlainObject(value)) continue;
175
+ const path = prefix ? `${prefix}.${name}` : name;
176
+ if (isToken(value)) into.set(path, toEntry(path, value, type, deprecated));
177
+ else if (isTokenGroup(value)) collectEntries(value, path, type, into, deprecated);
178
+ }
179
+ }
@@ -0,0 +1 @@
1
+ export const DEFERRED_COMPONENT_ALIAS_FAMILIES = new Set<string>([]);
@@ -0,0 +1,15 @@
1
+ const STYLELINT_STATUS_COLOR_MIX_PATTERN =
2
+ /color-mix\([\s\S]*?var\(\s*--cinder-(?:info|success|warning|danger)\s*(?:[,)])/;
3
+
4
+ export function stylelintDisableCommentFor(value: string): string | undefined {
5
+ if (!STYLELINT_STATUS_COLOR_MIX_PATTERN.test(value)) return undefined;
6
+ return (
7
+ '/* stylelint-disable-next-line declaration-property-value-disallowed-list -- ' +
8
+ 'canonical status-mixing formula, the intentional shared contract; component CSS ' +
9
+ 'must still use the named tier instead of recreating it. */'
10
+ );
11
+ }
12
+
13
+ export function sanitizeComment(description: string): string {
14
+ return description.replaceAll('*/', '*\\/').replaceAll(/\s+/g, ' ').trim();
15
+ }