@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,115 @@
1
+ /** DTCG 2025.10 token names may not contain path or reference delimiters. */
2
+ export type TokenName = string;
3
+ export type ColorValue = {
4
+ colorSpace: string;
5
+ components: Array<number | 'none'>;
6
+ alpha?: number | 'none';
7
+ hex?: string;
8
+ };
9
+ export type DimensionValue = {
10
+ value: number;
11
+ unit: 'px' | 'rem';
12
+ };
13
+ export type DurationValue = {
14
+ value: number;
15
+ unit: 'ms' | 's';
16
+ };
17
+ export type StrokeStyleValue = string | {
18
+ dashArray: DimensionValue[];
19
+ lineCap: 'round' | 'butt' | 'square';
20
+ };
21
+ export type BorderValue = {
22
+ color: ColorValue | string;
23
+ width: DimensionValue | string;
24
+ style: StrokeStyleValue | string;
25
+ };
26
+ export type TransitionValue = {
27
+ duration: DurationValue | string;
28
+ delay: DurationValue | string;
29
+ timingFunction: [number, number, number, number] | string;
30
+ };
31
+ export type ShadowValue = {
32
+ color: ColorValue | string;
33
+ offsetX: DimensionValue | string;
34
+ offsetY: DimensionValue | string;
35
+ blur: DimensionValue | string;
36
+ spread: DimensionValue | string;
37
+ inset?: boolean;
38
+ };
39
+ export type GradientStop = {
40
+ color: ColorValue | string;
41
+ position: number | string;
42
+ };
43
+ export type TypographyValue = {
44
+ fontFamily: string[] | string;
45
+ fontSize: DimensionValue | string;
46
+ fontWeight: number | string;
47
+ letterSpacing: DimensionValue | string;
48
+ lineHeight: number | DimensionValue | string;
49
+ };
50
+ export type TokenValue = ColorValue | DimensionValue | DurationValue | StrokeStyleValue | BorderValue | TransitionValue | ShadowValue | GradientStop[] | TypographyValue | string | string[] | number | [number, number, number, number];
51
+ export declare const TOKEN_TYPES: readonly ["color", "dimension", "fontFamily", "fontWeight", "duration", "cubicBezier", "number", "strokeStyle", "border", "transition", "shadow", "gradient", "typography"];
52
+ export type TokenType = (typeof TOKEN_TYPES)[number];
53
+ export type TokenExtensions = Record<string, unknown>;
54
+ export type DesignToken = {
55
+ /**
56
+ * Parsed JSON remains unknown until it is validated for the token's $type.
57
+ * Optional because a DTCG 2025.10 `$ref` token declares `$ref` instead of
58
+ * `$value` -- the two are mutually exclusive (see CIN-463) -- and gains a
59
+ * `$value` only once `resolve.ts` resolves the alias.
60
+ */
61
+ $value?: unknown;
62
+ /**
63
+ * DTCG 2025.10 whole-token alias: a JSON Pointer to another token, in
64
+ * place of `$value`. `resolve.ts` deletes this once the token is resolved,
65
+ * so a fully resolved `DesignToken` never carries both `$ref` and `$value`.
66
+ */
67
+ $ref?: string;
68
+ $type?: TokenType;
69
+ $description?: string;
70
+ $deprecated?: boolean | string;
71
+ $extensions?: TokenExtensions;
72
+ };
73
+ export type TokenGroup = {
74
+ $type?: TokenType;
75
+ $description?: string;
76
+ $deprecated?: boolean | string;
77
+ $extensions?: TokenExtensions;
78
+ $root?: DesignToken;
79
+ $extends?: string;
80
+ [name: TokenName]: DesignToken | TokenGroup | string | boolean | TokenExtensions | undefined;
81
+ };
82
+ export type TokenDocument = TokenGroup & {
83
+ $schema?: string;
84
+ };
85
+ /**
86
+ * DTCG 2025.10 resolver reference object. Cinder only authors $ref entries
87
+ * (relative file paths for sources, #/sets/<name> or #/modifiers/<name> for
88
+ * resolutionOrder) -- the spec also allows inline set/modifier/token
89
+ * documents in these positions, which Cinder does not use.
90
+ */
91
+ export type ResolverReference = {
92
+ $ref: string;
93
+ };
94
+ export type ResolverSet = {
95
+ sources: ResolverReference[];
96
+ };
97
+ export type ResolverModifier = {
98
+ contexts: Record<string, ResolverReference[]>;
99
+ default?: string;
100
+ };
101
+ export type ResolverDocument = {
102
+ version: '2025.10';
103
+ sets: Record<string, ResolverSet>;
104
+ modifiers: Record<string, ResolverModifier>;
105
+ resolutionOrder: ResolverReference[];
106
+ };
107
+ export type ValidationIssue = {
108
+ path: string;
109
+ reason: string;
110
+ };
111
+ export declare class TokenValidationError extends Error {
112
+ readonly issues: ValidationIssue[];
113
+ readonly sourceOwned: boolean;
114
+ constructor(issues: ValidationIssue[], sourceOwned?: boolean);
115
+ }
@@ -0,0 +1,31 @@
1
+ import { type ResolverDocumentShape } from './validate-values.ts';
2
+ export declare function isResolverReference(value: unknown): value is {
3
+ $ref: string;
4
+ };
5
+ export declare function unknownReservedPropertyReason(key: string): string;
6
+ /**
7
+ * Parses a resolutionOrder entry's `$ref` (e.g. "#/sets/foundation" or
8
+ * "#/modifiers/theme") into its target kind and name. JSON Pointer
9
+ * tilde-escapes are decoded per RFC 6901; returns undefined for anything
10
+ * that isn't a well-formed pointer into `sets` or `modifiers`.
11
+ */
12
+ export declare function isResolverTargetKind(value: string): value is 'sets' | 'modifiers';
13
+ export declare function resolutionOrderTarget(ref: string): {
14
+ kind: 'sets' | 'modifiers';
15
+ name: string;
16
+ } | undefined;
17
+ /**
18
+ * Semantic checks the official DTCG 2025.10 resolver JSON Schema cannot
19
+ * express: `default` matching a live context key, resolutionOrder entries
20
+ * resolving to a set or modifier that actually exists (schema can only
21
+ * constrain the `$ref` string's shape, not cross-reference sibling `sets`/
22
+ * `modifiers` object keys), non-empty source/context arrays, and
23
+ * resolutionOrder covering every set and modifier exactly once -- EXCEPT a
24
+ * set that is reached only through a resolver-internal `#/sets/<name>`
25
+ * reference from another set's `sources` or a modifier context (CIN-464):
26
+ * that set contributes its documents at the position of whatever references
27
+ * it, so requiring it in resolutionOrder too would be redundant. Such a set
28
+ * MAY still appear in resolutionOrder as well -- nothing here forbids it --
29
+ * it is simply no longer REQUIRED to.
30
+ */
31
+ export declare function validateResolverDocument(document: ResolverDocumentShape): void;
@@ -0,0 +1,22 @@
1
+ export declare function assertSafeExtensionMetadata(value: unknown, path: string, source: string): void;
2
+ /** Validates a token document against the official DTCG 2025.10 format JSON Schema. */
3
+ export declare function validateTokenDocumentSchema(document: unknown, source?: string, lookupDocuments?: readonly unknown[], sourceByDocument?: ReadonlyMap<object, string>): unknown;
4
+ /**
5
+ * Validates a document against the official DTCG 2025.10 resolver JSON Schema.
6
+ *
7
+ * Wired into `assertValidResolverDocument` as its first-pass gate, alongside
8
+ * the token-document equivalent above.
9
+ *
10
+ * `cinder.resolver.json` previously used an array-of-`{name, source}` shape
11
+ * for `sets`/`modifiers` and a plain string array for `resolutionOrder`, while
12
+ * declaring the official schema's `$schema` URI. Those are genuinely different
13
+ * document models, not a naming quibble: the official schema keys `sets` and
14
+ * `modifiers` by name (`{ sources: [...] }` / `{ contexts: { [value]: sources[] } }`)
15
+ * and requires `resolutionOrder` entries to be `{ "$ref": "#/sets/..." }`
16
+ * reference objects -- see the `resolver/set.json`, `resolver/modifier.json`,
17
+ * and `resolver/resolutionOrder.json` definitions embedded in the vendored
18
+ * file. The document was migrated to the conformant shape rather than leaving
19
+ * this validator unwired, and a regression test pins the old shape as
20
+ * rejected so it cannot come back.
21
+ */
22
+ export declare function validateResolverDocumentSchema(document: unknown, source?: string): void;
@@ -0,0 +1,25 @@
1
+ import type { DesignToken, TokenType, ValidationIssue } from './types.ts';
2
+ import { type JsonObject } from './validate-values.ts';
3
+ export declare function tokenType(token: JsonObject, inheritedType: TokenType | undefined, path: string, issues: ValidationIssue[]): TokenType | undefined;
4
+ export declare function validateMetadata(node: JsonObject, path: string, issues: ValidationIssue[], isDocumentRoot?: boolean): void;
5
+ /**
6
+ * Validates a token-shaped node ($root's value, or an ordinary named leaf)
7
+ * once both callers in `validateGroup` agree it declares `$value` and/or
8
+ * `$ref` rather than nesting further groups.
9
+ *
10
+ * $type for a `$ref` token: unlike a `$value` token, `$ref` does not require
11
+ * a declared or inherited `$type` here -- the acceptance case for CIN-463
12
+ * (`{ copy: { $ref: "#/base" } }` at the document root, with no ancestor
13
+ * group typing it) has nowhere to inherit one from. `resolve.ts` fills the
14
+ * resolved `$type` in from the reference target when the `$ref` token
15
+ * declares none of its own; `validateResolvedToken` is what actually
16
+ * enforces "every resolved token has a $type", after that fallback has run.
17
+ * If a `$ref` token DOES declare its own `$type`, it is still checked here
18
+ * for membership in the known type set, just never used to check a value
19
+ * shape (there is no `$value` to check until resolution).
20
+ */
21
+ export declare function validateTokenNode(value: JsonObject, path: string, groupType: TokenType | undefined, mayInheritTypeThroughExtension: boolean, issues: ValidationIssue[], isRoot?: boolean): void;
22
+ export declare function validateGroup(group: JsonObject, path: string, inheritedType: TokenType | undefined, issues: ValidationIssue[], isDocumentRoot?: boolean, inheritsTypeThroughExtension?: boolean): void;
23
+ export declare function validateTokenDocument(document: unknown, source?: string): void;
24
+ /** Validates a fully resolved token so aliases cannot change its declared value shape. */
25
+ export declare function validateResolvedToken(token: DesignToken, path: string): void;
@@ -0,0 +1,33 @@
1
+ import type { TokenType, ValidationIssue } from './types.ts';
2
+ export declare const TOKEN_NAME_PATTERN: RegExp;
3
+ export declare const VENDOR_EXTENSION_PATTERN: RegExp;
4
+ export declare const TOKEN_TYPE_SET: Set<string>;
5
+ export declare const COLOR_SPACES: Set<string>;
6
+ export declare const HEX_COLOR_PATTERN: RegExp;
7
+ export declare const COLOR_MEMBERS: Set<string>;
8
+ export declare const DIMENSION_MEMBERS: Set<string>;
9
+ export type JsonObject = Record<string, unknown>;
10
+ export type ResolverDocumentShape = {
11
+ version: unknown;
12
+ sets: JsonObject;
13
+ modifiers: JsonObject;
14
+ resolutionOrder: unknown[];
15
+ };
16
+ export declare const GROUP_METADATA: Set<string>;
17
+ export declare const TOKEN_METADATA: Set<string>;
18
+ export declare function isObject(value: unknown): value is JsonObject;
19
+ export declare function isCubicBezier(value: unknown): value is [number, number, number, number];
20
+ export declare function isReference(value: unknown): value is string;
21
+ /**
22
+ * A node is token-shaped if it declares either the value form (`$value`) or
23
+ * the DTCG 2025.10 alias form (`$ref`) -- as opposed to a group, which
24
+ * declares neither and instead nests further named children. Checking both
25
+ * keys (rather than `$value` alone) is what CIN-463 fixes: previously a
26
+ * `$ref`-only node fell through to being validated as an (empty) group.
27
+ */
28
+ export declare function hasTokenValue(value: JsonObject): boolean;
29
+ export declare function addIssue(issues: ValidationIssue[], path: string, reason: string): void;
30
+ export declare function validateCompositeMembers(value: JsonObject, members: Readonly<Record<string, TokenType>>, path: string, issues: ValidationIssue[], optionalMembers?: ReadonlySet<string>): void;
31
+ export declare function validateValue(type: TokenType, value: unknown, path: string, issues: ValidationIssue[]): void;
32
+ export declare function isString(value: unknown): value is string;
33
+ export declare function isTokenType(value: unknown): value is TokenType;
@@ -0,0 +1,3 @@
1
+ import type { ResolverDocument, TokenDocument } from './types.ts';
2
+ export declare function assertValidTokenDocument(document: unknown, source?: string, lookupDocuments?: readonly unknown[], sourceByDocument?: ReadonlyMap<object, string>): asserts document is TokenDocument;
3
+ export declare function assertValidResolverDocument(document: unknown): asserts document is ResolverDocument;
@@ -0,0 +1,128 @@
1
+ import valueParser from 'postcss-value-parser';
2
+ /** A node from a parsed CSS value -- see `postcss-value-parser`'s `ParsedValue.nodes`. */
3
+ export type ColorValueNode = ReturnType<typeof valueParser>['nodes'][number];
4
+ /**
5
+ * CSS color functions that are a COMPLETE color on their own, so their body is
6
+ * never re-examined -- `oklch()`, `rgb()`, and the rest all take numbers (and,
7
+ * for `oklch(from … l c h)`, a nested relative-color source) as their own
8
+ * arguments, so descending into one would flag the bare component list it is
9
+ * SUPPOSED to contain.
10
+ *
11
+ * This is a CLOSED allowlist, drawn from the CSS Color Module functions plus
12
+ * every function the real corpus recipes a color with (verified by
13
+ * `generate.test.ts`'s "every color declaration the corpus emits" case, which
14
+ * runs {@link findBareColorComponents} over the committed `tokens-base.css`
15
+ * and fails if a real function name is missing here). CSS adds new color
16
+ * functions rarely and deliberately, so growing this set is a deliberate,
17
+ * reviewable edit -- unlike the open set this replaces, which treated ANY
18
+ * unrecognised function as a complete color and so silently accepted whatever
19
+ * CSS (or a typo) introduced next. Anything not in this set, and not one of
20
+ * the two functions below, is presumed NOT a complete color: fail closed.
21
+ */
22
+ export declare const COLOR_FUNCTIONS: Set<string>;
23
+ /**
24
+ * The two color functions whose ARGUMENTS are themselves `<color>` values, and
25
+ * so have to be checked recursively by {@link findBareColorComponents}.
26
+ */
27
+ export declare const COLOR_ARGUMENT_FUNCTIONS: Set<string>;
28
+ /**
29
+ * CSS math functions CAPABLE of standing in for the `<percentage>` mix weight
30
+ * in a `color-mix()` argument. `color-mix()` accepts a general `<percentage>`,
31
+ * not only a literal, and the weight may sit on either side of the color, so
32
+ * the weight has to be recognised in computed form too -- otherwise a recipe
33
+ * the browser accepts reads as a bare component list and fails generation.
34
+ *
35
+ * This set is deliberately narrower than "every CSS Values L4 math function":
36
+ * only the functions the spec defines as TYPE-PRESERVING (a `<percentage>`
37
+ * argument yields a `<percentage>` result, the same way a `<length>` argument
38
+ * yields a `<length>` result) belong here. `calc()`, `min()`, `max()`,
39
+ * `clamp()`, `round()`, `mod()`, `rem()`, and `abs()` are all type-preserving
40
+ * per the spec's calculation-type rules. `hypot()` is too -- its arguments
41
+ * "must be the same type... either <number>, <percentage>, or <dimension>"
42
+ * and the result matches that type, so `hypot(1%, 2%)` is itself a
43
+ * `<percentage>`, exactly like a `color-mix()` weight the browser accepts.
44
+ *
45
+ * Membership here says only that a CALL to the function is CAPABLE of
46
+ * producing a percentage -- it says nothing about any particular call, since
47
+ * every one of these functions produces whatever type its arguments do:
48
+ * `hypot(1px, 2px)` is a `<length>`, not a `<percentage>`, every bit as much
49
+ * as `hypot(1%, 2%)` is a percentage. Whether a given call actually resolves
50
+ * to a percentage is decided per-call by
51
+ * {@link mathFunctionType}, which is why this set alone is
52
+ * never enough to accept a node -- see {@link isUnambiguousPercentageNode}.
53
+ *
54
+ * `sign()` is deliberately EXCLUDED even though it takes the same argument
55
+ * types as `abs()`: unlike `abs()`, the spec defines `sign()`'s result as
56
+ * ALWAYS a plain `<number>` (1, -1, 0, or NaN), regardless of its argument's
57
+ * type -- `sign(-10%)` is `-1`, a number, never a percentage. Including it
58
+ * would make every call, not just a mistyped one, fail open.
59
+ *
60
+ * The exponential and trigonometric functions `pow()`, `sqrt()`, `log()`, and
61
+ * `exp()` are NOT included either: the spec requires their arguments (and
62
+ * result) to be a plain `<number>`, never a `<percentage>`, so they can never
63
+ * legitimately stand in for a mix weight. The trigonometric functions
64
+ * `sin()`, `cos()`, and `tan()` always return a `<number>`, and `asin()`,
65
+ * `acos()`, `atan()`, and `atan2()` always return an `<angle>` -- none of the
66
+ * seven ever produce a `<percentage>` either, so they are excluded for the
67
+ * same reason `sign()` is.
68
+ *
69
+ * `var()` is deliberately absent. A bare `var()` is ambiguous between the color
70
+ * and the weight, and reading it as the color is the safe direction: treating
71
+ * it as a weight would strip the only complete value out of the argument and
72
+ * flag what remains.
73
+ */
74
+ export declare const PERCENTAGE_FUNCTIONS: Set<string>;
75
+ /** `nodes` with every whitespace divider removed, so only meaningful tokens remain. */
76
+ export declare function stripSpaces(nodes: ColorValueNode[]): ColorValueNode[];
77
+ /**
78
+ * `nodes` split into top-level comma-separated argument groups. Nested
79
+ * function arguments stay whole automatically, because `postcss-value-parser`
80
+ * already parsed them into their own `FunctionNode.nodes` -- a comma inside
81
+ * `color-mix(...)` never appears in the outer array this walks.
82
+ */
83
+ export declare function splitArguments(nodes: ColorValueNode[]): ColorValueNode[][];
84
+ /**
85
+ * Everything in a `var()` call's nodes after its first top-level comma -- the
86
+ * fallback, verbatim, including any further commas it may itself contain
87
+ * (`var()`'s fallback is not re-parsed by CSS, so neither is it here). `undefined`
88
+ * when there is no fallback at all.
89
+ */
90
+ export declare function fallbackNodes(callNodes: ColorValueNode[]): ColorValueNode[] | undefined;
91
+ /** Unitless CSS calculation constants, such as the scalar in `calc(1% * pi)`. */
92
+ export declare const CALC_NUMBER_KEYWORDS: Set<string>;
93
+ export type MathValueType = number | 'variable' | null;
94
+ export declare function mathValueType(nodes: ColorValueNode[]): MathValueType;
95
+ export type MathParser = {
96
+ items: ColorValueNode[];
97
+ position: number;
98
+ };
99
+ export declare function mathExpression(parser: MathParser, original: ColorValueNode[]): MathValueType;
100
+ export declare function hasAddOperator(parser: MathParser): boolean;
101
+ export declare function isSpacedOperator(nodes: ColorValueNode[], index: number): boolean;
102
+ export declare function sameNumericType(left: MathValueType, right: MathValueType): boolean;
103
+ export declare function mathProduct(parser: MathParser): MathValueType;
104
+ export declare function hasProductOperator(parser: MathParser): boolean;
105
+ export declare function combineProduct(operator: string, left: MathValueType, right: MathValueType): MathValueType;
106
+ export declare function isVariablePercentagePair(left: MathValueType, right: MathValueType): boolean;
107
+ export declare function mathPrimary(parser: MathParser): MathValueType;
108
+ export declare function mathWordType(value: string): MathValueType;
109
+ export declare function mathVariableType(node: Extract<ColorValueNode, {
110
+ type: 'function';
111
+ }>): MathValueType;
112
+ export declare function mathFunctionType(node: Extract<ColorValueNode, {
113
+ type: 'function';
114
+ }>): MathValueType;
115
+ export declare function normalizedMathArguments(name: string, argumentGroups: ColorValueNode[][]): ColorValueNode[][];
116
+ export declare function mathArity(name: string): number | undefined;
117
+ export declare function roundMathType(nodes: ColorValueNode[]): MathValueType;
118
+ export declare function clampMathType(argumentGroups: ColorValueNode[][]): MathValueType;
119
+ export declare function uniformMathType(argumentGroups: ColorValueNode[][]): MathValueType;
120
+ /**
121
+ * A CSS `<percentage-token>`: a `<number-token>` followed by `%`, or a call to
122
+ * a {@link PERCENTAGE_FUNCTIONS} member whose arguments DEMONSTRABLY resolve
123
+ * to a percentage, including its operator types and argument count.
124
+ * `postcss-value-parser`'s `unit` helper implements the actual
125
+ * `<number-token>` grammar -- a number may be signed and may carry an
126
+ * exponent, so `+40%`, `-0%`, `.5%`, and `4e1%` are all valid weights, and a
127
+ * hand-rolled digits-and-dots pattern misses three of those four.
128
+ */
@@ -0,0 +1,85 @@
1
+ import type { CorpusEntry } from './corpus.ts';
2
+ import { type ColorValueNode } from './value-color-parse.ts';
3
+ export declare function wholeTokenIndexPath(reference: string): string;
4
+ export declare function resolveAlias(reference: string, baseIndex: Map<string, CorpusEntry>): string;
5
+ /**
6
+ * Whether `reference` names a whole token that `resolveAlias` can turn into a
7
+ * `var(--property)` reference -- used by `serializeEntryValue` to decide
8
+ * whether a `$ref` alias should take that path or fall through to typed
9
+ * serialization instead of throwing (see `serializeEntryValue`'s doc comment).
10
+ */
11
+ export declare function isWholeTokenAlias(reference: string, baseIndex: Map<string, CorpusEntry>): boolean;
12
+ export declare function isUnambiguousPercentageNode(node: ColorValueNode): boolean;
13
+ /**
14
+ * A `var()` node whose FALLBACK is a percentage, so the reference resolves to
15
+ * one either way: `var(--weight, 40%)`.
16
+ *
17
+ * In a `color-mix()` argument a bare `var()` is ambiguous between the color and
18
+ * the weight, and this is the case where it stops being ambiguous. Without it,
19
+ * checking the `var()` as a color position descends into the fallback and
20
+ * reports `40%` as a bare component list -- rejecting a recipe the browser
21
+ * accepts.
22
+ */
23
+ export declare function isPercentageValuedVarNode(node: ColorValueNode): boolean;
24
+ /**
25
+ * The node groups of a `color-mix()` argument that might be its `<color>`,
26
+ * each wrapped as its own single-node candidate.
27
+ *
28
+ * The argument is `<color> && <percentage>?` in either order, so the weight has
29
+ * to be set aside before the color can be checked. The safe way to do that is
30
+ * to drop only what CANNOT be a color -- a literal percentage or a math
31
+ * function -- and check everything else.
32
+ *
33
+ * Guessing which token is the weight is what went wrong before. An earlier
34
+ * version picked "whichever token is not a complete color", but the checker
35
+ * returned `undefined` (complete) for any function it did not recognise,
36
+ * `calc()` included, so a computed weight read as a complete color and the
37
+ * REAL color was discarded as the weight. That let the exact value CIN-242
38
+ * exists to reject --
39
+ * `color-mix(in oklch, calc(var(--w) * 1%) light-dark(100% 0 0, 0% 0 0), transparent)`
40
+ * -- through the gate untouched.
41
+ *
42
+ * Returning every candidate costs nothing: a `var()` passes the check anyway,
43
+ * so including an ambiguous one is free, while every genuine color is checked.
44
+ */
45
+ export declare function mixColorCandidates(argumentNodes: ColorValueNode[]): ColorValueNode[][];
46
+ /**
47
+ * The first color position within `nodes` that is not a complete CSS color, as
48
+ * the node group to report -- or `undefined` when every position is complete.
49
+ *
50
+ * A color position is complete when it is a single hex literal or bare keyword
51
+ * (`transparent`, `currentColor`), a single call to one of
52
+ * {@link COLOR_FUNCTIONS}, a `var()` whose fallback (if any) is itself
53
+ * complete, or a `light-dark()`/`color-mix()` whose own color arguments are
54
+ * all complete. A component list is more than one top-level token -- `0 0 0`
55
+ * is three -- or a call to any OTHER function, which this walker has never
56
+ * seen before and so cannot assume is a color: FAIL CLOSED. That is the one
57
+ * behavior change from the string-matching version this replaces, which
58
+ * treated an unrecognised function as automatically complete.
59
+ */
60
+ export declare function findBareInNodes(nodes: ColorValueNode[]): ColorValueNode[] | undefined;
61
+ /** {@link findBareInNodes} for a single function-call node. */
62
+ export declare function findBareInFunction(node: Extract<ColorValueNode, {
63
+ type: 'function';
64
+ }>): ColorValueNode[] | undefined;
65
+ export declare function findBareInArguments(name: string, args: ColorValueNode[][]): ColorValueNode[] | undefined;
66
+ export declare function findBareInColorArguments(isMix: boolean, colorArguments: ColorValueNode[][]): ColorValueNode[] | undefined;
67
+ /**
68
+ * The first fragment of `value` that sits in a `<color>` position but is not a
69
+ * complete CSS color -- or `undefined` when every color position is complete.
70
+ *
71
+ * This exists for one failure mode, from CIN-242's decision record: a token
72
+ * authored as a BARE OKLCH COMPONENT TRIPLET (`light-dark(0% 0 0, 100% 0 0)`,
73
+ * so a call site can staple its own alpha on with `oklch(var(--token) / 0.4)`)
74
+ * is not a color. Assigned directly to `color`/`background-color`/
75
+ * `border-color` it produces an invalid declaration, which CSS drops SILENTLY
76
+ * -- the element keeps its inherited or initial color and nothing anywhere
77
+ * reports a problem. A complete value that is mis-referenced instead paints a
78
+ * visibly wrong color, which is catchable. Hence: complete values only.
79
+ *
80
+ * Completeness is decided from a PARSED value tree (`postcss-value-parser`),
81
+ * not a function-name allowlist matched against text -- see
82
+ * {@link findBareInNodes} for the actual rule. A component list starts with a
83
+ * number, so it is exactly what falls through.
84
+ */
85
+ export declare function findBareColorComponents(value: string): string | undefined;
@@ -0,0 +1,3 @@
1
+ import type { CorpusEntry } from './corpus.ts';
2
+ import type { ValueResolver } from './resolve.ts';
3
+ export declare function serializeEntryValue(entry: CorpusEntry, baseIndex: Map<string, CorpusEntry>, resolveReferences?: ValueResolver): string;
@@ -0,0 +1,59 @@
1
+ import type { ValueResolver } from './resolve.ts';
2
+ import type { TokenType } from './types.ts';
3
+ export type DimensionOrDuration = {
4
+ value: number;
5
+ unit: string;
6
+ };
7
+ type ColorComponent = number | 'none';
8
+ /** `isColorValue` admits exactly three channels, so the formatters below can destructure them without a check. */
9
+ export type ColorValue = {
10
+ colorSpace: string;
11
+ components: [ColorComponent, ColorComponent, ColorComponent];
12
+ alpha?: number | 'none';
13
+ hex?: string;
14
+ };
15
+ export type ShadowLayer = {
16
+ color: ColorValue;
17
+ offsetX: DimensionOrDuration;
18
+ offsetY: DimensionOrDuration;
19
+ blur: DimensionOrDuration;
20
+ spread: DimensionOrDuration;
21
+ inset?: boolean;
22
+ };
23
+ /** Matches both DTCG alias syntaxes: curly-brace (`{a.b.c}`) and JSON Pointer (`#/a/b/c`), the same two forms `validate.ts`'s `isReference` accepts and `resolve.ts` resolves. */
24
+ export declare function isAliasReference(value: unknown): value is string;
25
+ /**
26
+ * `validate.ts` permits a reference (`{a.b.c}` or `#/a/b/c`) at any composite leaf position --
27
+ * a shadow layer's `color`, a color's individual `components`/`alpha`, a border's `width`, and
28
+ * so on -- alongside the whole-value alias `serializeEntryValue` already handles before this
29
+ * function is ever called. `resolveReferences` (identity by default, so existing callers that
30
+ * pass literal, already-resolved values are unaffected) resolves every such reference, at any
31
+ * depth, to its literal value before shape-checking and formatting proceed.
32
+ */
33
+ export declare function serializeTypedValue(type: TokenType, value: unknown, path: string, resolveReferences?: ValueResolver): string;
34
+ export {};
35
+ /**
36
+ * The `baseIndex` key a whole-token JSON Pointer alias names, beyond
37
+ * `tokenPathFromReference`'s plain dot-join.
38
+ *
39
+ * A property-FORM pointer whose last segment is literally `$value` (e.g.
40
+ * `#/dimension/hairline/$value`) names the referenced token's WHOLE value --
41
+ * resolve.ts's own `resolveReference` special-cases a trailing `$value`
42
+ * segment the same way (see resolve.test.ts's "resolves a property-level
43
+ * JSON Pointer reference" case, which targets a whole dimension token via
44
+ * `#/dimension/hairline/$value`). `tokenPathFromReference` has no such
45
+ * special case -- it just dot-joins every segment -- so without stripping it
46
+ * here, the exact-match `baseIndex` lookup misses the token entirely even
47
+ * though `tokens:validate` accepts the identical reference. Gated on `#/`
48
+ * (pointer syntax): a curly alias `{a.b.$value}` is a literal dotted path
49
+ * through the corpus, not resolve.ts's pointer special case, so stripping it
50
+ * there would just as wrongly make the generator and the validator disagree
51
+ * the other way.
52
+ *
53
+ * A `$root` segment is a REDIRECT to the group's own root token, which
54
+ * `collectEntries` indexes at the group's own path (`prefix`), not
55
+ * `prefix.$root` -- the same redirect resolve.ts's `refTargetIndexPath`
56
+ * applies for type inference. `#/group/$root` and `#/group/$root/$value`
57
+ * both name the root token's whole identity and must strip to `group`;
58
+ * `#/$root`/`#/$root/$value` strip to the document root's own path (`''`).
59
+ */