zyzz 0.0.2 → 0.0.5

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 (252) hide show
  1. package/README.md +34 -19
  2. package/dist/Config.d.ts +16 -167
  3. package/dist/Config.d.ts.map +1 -1
  4. package/dist/Config.js +7 -246
  5. package/dist/Config.js.map +1 -1
  6. package/dist/Style.d.ts +19 -13
  7. package/dist/Style.d.ts.map +1 -1
  8. package/dist/Style.js +73 -7
  9. package/dist/Style.js.map +1 -1
  10. package/dist/Vars.d.ts +114 -0
  11. package/dist/Vars.d.ts.map +1 -0
  12. package/dist/Vars.js +42 -0
  13. package/dist/Vars.js.map +1 -0
  14. package/dist/compiler/Graph.js +11 -8
  15. package/dist/compiler/Graph.js.map +1 -1
  16. package/dist/compiler/Native.d.ts +5 -5
  17. package/dist/compiler/Native.d.ts.map +1 -1
  18. package/dist/compiler/Native.js +21 -21
  19. package/dist/compiler/Native.js.map +1 -1
  20. package/dist/compiler/Source.d.ts +10 -6
  21. package/dist/compiler/Source.d.ts.map +1 -1
  22. package/dist/compiler/Source.js +66 -11
  23. package/dist/compiler/Source.js.map +1 -1
  24. package/dist/compiler/Transform.d.ts +1 -1
  25. package/dist/compiler/Transform.d.ts.map +1 -1
  26. package/dist/compiler/Transform.js +59 -21
  27. package/dist/compiler/Transform.js.map +1 -1
  28. package/dist/compiler/internal/Compositions.d.ts +5 -0
  29. package/dist/compiler/internal/Compositions.d.ts.map +1 -1
  30. package/dist/compiler/internal/Compositions.js +22 -3
  31. package/dist/compiler/internal/Compositions.js.map +1 -1
  32. package/dist/compiler/internal/Configurations.d.ts.map +1 -1
  33. package/dist/compiler/internal/Configurations.js +73 -12
  34. package/dist/compiler/internal/Configurations.js.map +1 -1
  35. package/dist/compiler/internal/Contract.d.ts +1 -1
  36. package/dist/compiler/internal/Contract.d.ts.map +1 -1
  37. package/dist/compiler/internal/Contract.js +162 -13
  38. package/dist/compiler/internal/Contract.js.map +1 -1
  39. package/dist/compiler/internal/Contributions.js +1 -1
  40. package/dist/compiler/internal/Contributions.js.map +1 -1
  41. package/dist/compiler/internal/Dynamic.js +1 -1
  42. package/dist/compiler/internal/Dynamic.js.map +1 -1
  43. package/dist/compiler/internal/Expression.d.ts +3 -0
  44. package/dist/compiler/internal/Expression.d.ts.map +1 -1
  45. package/dist/compiler/internal/Expression.js +21 -0
  46. package/dist/compiler/internal/Expression.js.map +1 -1
  47. package/dist/compiler/internal/Identifiers.d.ts +1 -1
  48. package/dist/compiler/internal/Identifiers.d.ts.map +1 -1
  49. package/dist/compiler/internal/Identifiers.js +2 -2
  50. package/dist/compiler/internal/Identifiers.js.map +1 -1
  51. package/dist/compiler/internal/NativeBindings.d.ts +1 -1
  52. package/dist/compiler/internal/NativeBindings.d.ts.map +1 -1
  53. package/dist/compiler/internal/NativeBindings.js +3 -3
  54. package/dist/compiler/internal/NativeBindings.js.map +1 -1
  55. package/dist/compiler/internal/PackedStyles.d.ts +1 -1
  56. package/dist/compiler/internal/PackedStyles.d.ts.map +1 -1
  57. package/dist/compiler/internal/PackedStyles.js +15 -25
  58. package/dist/compiler/internal/PackedStyles.js.map +1 -1
  59. package/dist/compiler/internal/Recipes.js +1 -1
  60. package/dist/compiler/internal/Recipes.js.map +1 -1
  61. package/dist/compiler/internal/Selectors.js +1 -1
  62. package/dist/compiler/internal/Selectors.js.map +1 -1
  63. package/dist/compiler/internal/Themes.d.ts +12 -3
  64. package/dist/compiler/internal/Themes.d.ts.map +1 -1
  65. package/dist/compiler/internal/Themes.js +192 -52
  66. package/dist/compiler/internal/Themes.js.map +1 -1
  67. package/dist/compiler/internal/{Variables.d.ts → Vars.d.ts} +1 -1
  68. package/dist/compiler/internal/Vars.d.ts.map +1 -0
  69. package/dist/compiler/internal/{Variables.js → Vars.js} +3 -3
  70. package/dist/compiler/internal/Vars.js.map +1 -0
  71. package/dist/default.d.ts +451 -1649
  72. package/dist/default.d.ts.map +1 -1
  73. package/dist/default.js +389 -80
  74. package/dist/default.js.map +2 -2
  75. package/dist/default.js.zyzz.json +1 -1
  76. package/dist/esbuild/index.d.ts +3 -0
  77. package/dist/esbuild/index.d.ts.map +1 -0
  78. package/dist/esbuild/index.js +5 -0
  79. package/dist/esbuild/index.js.map +1 -0
  80. package/dist/index.d.ts +4 -4
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +4 -4
  83. package/dist/index.js.map +1 -1
  84. package/dist/internal/Authoring.d.ts +1 -1
  85. package/dist/internal/Authoring.d.ts.map +1 -1
  86. package/dist/internal/Authoring.js +4 -4
  87. package/dist/internal/Authoring.js.map +1 -1
  88. package/dist/internal/Binding.d.ts +1 -1
  89. package/dist/internal/Binding.d.ts.map +1 -1
  90. package/dist/internal/Completion.d.ts +19 -0
  91. package/dist/internal/Completion.d.ts.map +1 -0
  92. package/dist/internal/Completion.js +2 -0
  93. package/dist/internal/Completion.js.map +1 -0
  94. package/dist/internal/Condition.d.ts +3 -1
  95. package/dist/internal/Condition.d.ts.map +1 -1
  96. package/dist/internal/Condition.js.map +1 -1
  97. package/dist/internal/Configuration.d.ts +248 -0
  98. package/dist/internal/Configuration.d.ts.map +1 -0
  99. package/dist/internal/Configuration.js +343 -0
  100. package/dist/internal/Configuration.js.map +1 -0
  101. package/dist/internal/Shorthands.d.ts +1 -1
  102. package/dist/internal/Shorthands.d.ts.map +1 -1
  103. package/dist/internal/Shorthands.js +1 -0
  104. package/dist/internal/Shorthands.js.map +1 -1
  105. package/dist/{Theme.d.ts → internal/Theme.d.ts} +24 -19
  106. package/dist/internal/Theme.d.ts.map +1 -0
  107. package/dist/{Theme.js → internal/Theme.js} +57 -14
  108. package/dist/internal/Theme.js.map +1 -0
  109. package/dist/internal/Token.d.ts +46 -16
  110. package/dist/internal/Token.d.ts.map +1 -1
  111. package/dist/internal/Token.js +89 -5
  112. package/dist/internal/Token.js.map +1 -1
  113. package/dist/internal/Typography.d.ts +31 -0
  114. package/dist/internal/Typography.d.ts.map +1 -0
  115. package/dist/internal/Typography.js +54 -0
  116. package/dist/internal/Typography.js.map +1 -0
  117. package/dist/internal/Value.d.ts +6 -1
  118. package/dist/internal/Value.d.ts.map +1 -1
  119. package/dist/internal/Value.js.map +1 -1
  120. package/dist/internal/VariableSets.d.ts +20 -0
  121. package/dist/internal/VariableSets.d.ts.map +1 -0
  122. package/dist/internal/VariableSets.js +317 -0
  123. package/dist/internal/VariableSets.js.map +1 -0
  124. package/dist/next/loader.js +15 -5
  125. package/dist/next/loader.js.map +1 -1
  126. package/dist/node/Host.d.ts.map +1 -1
  127. package/dist/node/Host.js +1 -1
  128. package/dist/node/Host.js.map +1 -1
  129. package/dist/react-native/Host.d.ts +2 -2
  130. package/dist/react-native/Host.d.ts.map +1 -1
  131. package/dist/react-native/Host.js +4 -4
  132. package/dist/react-native/Host.js.map +1 -1
  133. package/dist/react-native/StyleSheet.d.ts +9 -8
  134. package/dist/react-native/StyleSheet.d.ts.map +1 -1
  135. package/dist/react-native/StyleSheet.js +29 -23
  136. package/dist/react-native/StyleSheet.js.map +1 -1
  137. package/dist/react-native/Variants.d.ts +3 -3
  138. package/dist/react-native/Variants.d.ts.map +1 -1
  139. package/dist/react-native/Variants.js +2 -2
  140. package/dist/react-native/react.d.ts +1 -1
  141. package/dist/react-native/react.d.ts.map +1 -1
  142. package/dist/react-native/react.js +5 -5
  143. package/dist/react-native/react.js.map +1 -1
  144. package/dist/rollup/index.d.ts +3 -0
  145. package/dist/rollup/index.d.ts.map +1 -0
  146. package/dist/rollup/index.js +5 -0
  147. package/dist/rollup/index.js.map +1 -0
  148. package/dist/runtime/Appearance.d.ts +7 -7
  149. package/dist/runtime/Appearance.d.ts.map +1 -1
  150. package/dist/runtime/Appearance.js +15 -15
  151. package/dist/runtime/Appearance.js.map +1 -1
  152. package/dist/runtime/Dynamic.d.ts.map +1 -1
  153. package/dist/runtime/Dynamic.js +4 -1
  154. package/dist/runtime/Dynamic.js.map +1 -1
  155. package/dist/runtime/NativeContext.d.ts +4 -4
  156. package/dist/runtime/NativeContext.d.ts.map +1 -1
  157. package/dist/runtime/NativeContext.js +5 -5
  158. package/dist/runtime/NativeContext.js.map +1 -1
  159. package/dist/runtime/NativeDynamic.d.ts +1 -1
  160. package/dist/runtime/NativeDynamic.d.ts.map +1 -1
  161. package/dist/runtime/NativeDynamic.js.map +1 -1
  162. package/dist/runtime/Props.d.ts +1 -1
  163. package/dist/runtime/Props.js +3 -3
  164. package/dist/runtime/Props.js.map +1 -1
  165. package/dist/runtime/Selection.d.ts +14 -10
  166. package/dist/runtime/Selection.d.ts.map +1 -1
  167. package/dist/runtime/Selection.js +19 -18
  168. package/dist/runtime/Selection.js.map +1 -1
  169. package/dist/styleFunction.d.ts +14 -14
  170. package/dist/styleFunction.d.ts.map +1 -1
  171. package/dist/styleFunction.js.map +1 -1
  172. package/dist/unplugin/index.d.ts +20 -0
  173. package/dist/unplugin/index.d.ts.map +1 -0
  174. package/dist/unplugin/index.js +498 -0
  175. package/dist/unplugin/index.js.map +1 -0
  176. package/dist/variants.d.ts +3 -3
  177. package/dist/variants.d.ts.map +1 -1
  178. package/dist/variants.js.map +1 -1
  179. package/dist/vite/index.d.ts.map +1 -1
  180. package/dist/vite/index.js +6 -3
  181. package/dist/vite/index.js.map +1 -1
  182. package/dist/web/Css.d.ts +4 -3
  183. package/dist/web/Css.d.ts.map +1 -1
  184. package/dist/web/Css.js +4 -4
  185. package/dist/web/Css.js.map +1 -1
  186. package/dist/web/internal/Themes.d.ts +3 -2
  187. package/dist/web/internal/Themes.d.ts.map +1 -1
  188. package/dist/web/internal/Themes.js +42 -6
  189. package/dist/web/internal/Themes.js.map +1 -1
  190. package/dist/webpack/index.d.ts +3 -0
  191. package/dist/webpack/index.d.ts.map +1 -0
  192. package/dist/webpack/index.js +5 -0
  193. package/dist/webpack/index.js.map +1 -0
  194. package/package.json +23 -2
  195. package/src/Config.ts +43 -684
  196. package/src/Style.ts +167 -40
  197. package/src/Vars.ts +299 -0
  198. package/src/compiler/Graph.ts +14 -9
  199. package/src/compiler/Native.ts +29 -32
  200. package/src/compiler/Source.ts +85 -18
  201. package/src/compiler/Transform.ts +78 -22
  202. package/src/compiler/internal/Compositions.ts +36 -3
  203. package/src/compiler/internal/Configurations.ts +83 -11
  204. package/src/compiler/internal/Contract.ts +223 -17
  205. package/src/compiler/internal/Contributions.ts +1 -1
  206. package/src/compiler/internal/Dynamic.ts +1 -1
  207. package/src/compiler/internal/Expression.ts +26 -0
  208. package/src/compiler/internal/Identifiers.ts +2 -1
  209. package/src/compiler/internal/NativeBindings.ts +3 -3
  210. package/src/compiler/internal/PackedStyles.ts +22 -26
  211. package/src/compiler/internal/Recipes.ts +1 -1
  212. package/src/compiler/internal/Selectors.ts +1 -1
  213. package/src/compiler/internal/Themes.ts +266 -57
  214. package/src/compiler/internal/{Variables.ts → Vars.ts} +2 -2
  215. package/src/default.ts +868 -156
  216. package/src/esbuild/index.ts +5 -0
  217. package/src/index.ts +4 -4
  218. package/src/internal/Authoring.ts +5 -7
  219. package/src/internal/Binding.ts +1 -1
  220. package/src/internal/Completion.ts +42 -0
  221. package/src/internal/Condition.ts +31 -1
  222. package/src/internal/Configuration.ts +970 -0
  223. package/src/internal/Shorthands.ts +2 -0
  224. package/src/{Theme.ts → internal/Theme.ts} +174 -48
  225. package/src/internal/Token.ts +258 -85
  226. package/src/internal/Typography.ts +106 -0
  227. package/src/internal/Value.ts +45 -26
  228. package/src/internal/VariableSets.ts +458 -0
  229. package/src/next/loader.ts +19 -5
  230. package/src/node/Host.ts +1 -2
  231. package/src/react-native/Host.ts +6 -6
  232. package/src/react-native/StyleSheet.ts +49 -42
  233. package/src/react-native/Variants.ts +3 -3
  234. package/src/react-native/react.ts +6 -6
  235. package/src/rollup/index.ts +5 -0
  236. package/src/runtime/Appearance.ts +20 -20
  237. package/src/runtime/Dynamic.ts +4 -1
  238. package/src/runtime/NativeContext.ts +8 -8
  239. package/src/runtime/NativeDynamic.ts +2 -4
  240. package/src/runtime/Props.ts +3 -3
  241. package/src/runtime/Selection.ts +44 -33
  242. package/src/styleFunction.ts +22 -19
  243. package/src/unplugin/index.ts +600 -0
  244. package/src/variants.ts +7 -5
  245. package/src/vite/index.ts +5 -4
  246. package/src/web/Css.ts +10 -7
  247. package/src/web/internal/Themes.ts +52 -9
  248. package/src/webpack/index.ts +5 -0
  249. package/dist/Theme.d.ts.map +0 -1
  250. package/dist/Theme.js.map +0 -1
  251. package/dist/compiler/internal/Variables.d.ts.map +0 -1
  252. package/dist/compiler/internal/Variables.js.map +0 -1
@@ -34,6 +34,7 @@ export function read(value: unknown): Map {
34
34
  'style',
35
35
  'theme',
36
36
  'themes',
37
+ 'typography',
37
38
  'script',
38
39
  'variants',
39
40
  '__proto__',
@@ -98,6 +99,7 @@ export type Validated<mappings extends Map> = {
98
99
  | 'style'
99
100
  | 'theme'
100
101
  | 'themes'
102
+ | 'typography'
101
103
  | 'script'
102
104
  | 'variants'
103
105
  | '__proto__'
@@ -2,16 +2,18 @@
2
2
  * Defines typed token contracts and compatible immutable theme overrides.
3
3
  * @module
4
4
  */
5
- import { MissingTransformError, style } from './styleFunction.js'
6
- import * as Authoring from './internal/Authoring.js'
7
- import * as Identity from './internal/Identity.js'
8
- import { variants } from './variants.js'
9
- import type * as Binding from './internal/Binding.js'
10
- import type * as Literal from './internal/Literal.js'
11
- import * as Query from './internal/Query.js'
12
- import * as Token from './internal/Token.js'
13
- import type * as Value from './internal/Value.js'
14
- import type * as Style from './Style.js'
5
+ import { MissingTransformError, style } from '../styleFunction.js'
6
+ import * as Authoring from './Authoring.js'
7
+ import * as Identity from './Identity.js'
8
+ import { variants } from '../variants.js'
9
+ import type * as Binding from './Binding.js'
10
+ import type * as Literal from './Literal.js'
11
+ import * as Query from './Query.js'
12
+ import * as Token from './Token.js'
13
+ import * as Typography from './Typography.js'
14
+ import type * as Value from './Value.js'
15
+ import type * as Style from '../Style.js'
16
+ import * as Condition from './Condition.js'
15
17
 
16
18
  /** Complete color-scheme pair or a shared color. */
17
19
  export type Color =
@@ -51,7 +53,7 @@ export type StyleFactory<tokens extends Tokens> = {
51
53
  }
52
54
 
53
55
  /**
54
- * Defines scalar tokens without metadata, defaults, or environment access.
56
+ * Defines scalar tokens and typography sets without defaults or environment access.
55
57
  * Colors currently use the supported literal color grammar; spacing and radius
56
58
  * values use nonnegative literal lengths or zero. Nested palettes are supported.
57
59
  * @throws {InvalidError} If groups, paths, values, or data records are invalid.
@@ -95,7 +97,7 @@ export type Definition<
95
97
  /** Token-aware single-element recipe authoring. */
96
98
  readonly variants: boundVariants
97
99
  /** Web variable references; source templates retain their identity and fallback. */
98
- readonly vars: Token.Variables<References<tokens>>
100
+ readonly vars: Token.Vars<References<tokens>>
99
101
  }
100
102
 
101
103
  /**
@@ -127,6 +129,8 @@ export function extend<
127
129
  data.contract,
128
130
  data.values,
129
131
  data.queries,
132
+ undefined,
133
+ data.paths,
130
134
  ) as unknown as Definition<tokens, boundStyle, boundVariants>
131
135
  }
132
136
 
@@ -166,7 +170,16 @@ type OverrideTree<tree, group> = tree extends string | number
166
170
  ? Scalar<group>
167
171
  : tree extends { readonly dark: string; readonly light: string }
168
172
  ? Color
169
- : { readonly [key in keyof tree]?: OverrideTree<tree[key], group> }
173
+ : {
174
+ readonly [key in keyof tree]?: OverrideTree<
175
+ tree[key],
176
+ group extends 'typography'
177
+ ? key extends Typography.Property
178
+ ? key
179
+ : group
180
+ : group
181
+ >
182
+ }
170
183
 
171
184
  /** Nested palette or scale data. */
172
185
  export type Palette<leaf> = { readonly [key: string]: leaf | Palette<leaf> }
@@ -177,22 +190,38 @@ export type Reference<group extends Token.Group = Token.Group> =
177
190
 
178
191
  /** The inferred tree replaces scalar values and scheme pairs with references. */
179
192
  export type References<tokens> = {
180
- readonly [group in keyof tokens as group extends Token.Group
193
+ readonly [group in keyof tokens as group extends Token.Group | 'typography'
181
194
  ? group
182
- : never]: ReferenceTree<tokens[group], Extract<group, Token.Group>>
195
+ : never]: ReferenceTree<
196
+ tokens[group],
197
+ Extract<group, Token.Group | 'typography'>
198
+ >
183
199
  }
184
200
 
185
- type ReferenceTree<tree, group extends Token.Group> = tree extends
201
+ type ReferenceTree<
202
+ tree,
203
+ group extends Token.Group | 'typography',
204
+ > = tree extends
186
205
  | string
187
206
  | number
188
207
  | { readonly dark: string; readonly light: string }
189
- ? Reference<group>
190
- : { readonly [key in keyof tree]: ReferenceTree<tree[key], group> }
208
+ ? Reference<Extract<group, Token.Group>>
209
+ : {
210
+ readonly [key in keyof tree]: ReferenceTree<
211
+ tree[key],
212
+ group extends 'typography'
213
+ ? key extends Typography.Property
214
+ ? key
215
+ : group
216
+ : group
217
+ >
218
+ }
191
219
 
192
220
  /** Supported scalar groups; composite presets and query metadata follow separately. */
193
221
  type Scalar<group> = group extends
194
222
  | 'spacing'
195
223
  | 'borderRadius'
224
+ | 'borderWidth'
196
225
  | 'margin'
197
226
  | 'padding'
198
227
  ? Literal.Length
@@ -217,6 +246,10 @@ export type Tokens = {
217
246
  readonly borderColor?: Palette<Color> | undefined
218
247
  /** Nonnegative corner radii. */
219
248
  readonly borderRadius?: Palette<Literal.Length> | undefined
249
+ /** Nonnegative widths for physical and logical border declarations. */
250
+ readonly borderWidth?:
251
+ | Palette<Exclude<Literal.Length, `${number}%`>>
252
+ | undefined
220
253
  /** Compile-time viewport width thresholds. */
221
254
  readonly breakpoints?: Readonly<Record<string, Query.Length>> | undefined
222
255
  /** Shared colors available to every supported color property. */
@@ -253,6 +286,8 @@ export type Tokens = {
253
286
  readonly spacing?: Palette<Literal.Length> | undefined
254
287
  /** Colors available to text declarations. */
255
288
  readonly textColor?: Palette<Color> | undefined
289
+ /** Named sets of font family, size, weight, letter spacing, and line height. */
290
+ readonly typography?: Typography.Sets | undefined
256
291
  }
257
292
 
258
293
  function build(
@@ -261,6 +296,7 @@ function build(
261
296
  base?: Readonly<Record<string, Token.Value>>,
262
297
  baseQueries?: Query.Metadata,
263
298
  scope?: string,
299
+ basePaths?: Readonly<Record<string, readonly string[]>>,
264
300
  ) {
265
301
  const values: Record<string, Token.Value> = Object.assign(
266
302
  Object.create(null),
@@ -279,12 +315,26 @@ function build(
279
315
  ) as Record<string, string>,
280
316
  }
281
317
 
318
+ const paths: Record<string, readonly string[]> = { ...basePaths }
319
+ const conditions: (readonly string[])[] = []
320
+
282
321
  let hasQueries = !!baseQueries
283
322
  const active = new Set<object>()
284
323
 
285
- function visit(value: unknown, group: Token.Group, path: readonly string[]) {
324
+ function visit(
325
+ value: unknown,
326
+ group: Token.Group | 'typography',
327
+ path: readonly string[],
328
+ ) {
286
329
  const key = path.join('.')
330
+ if (path.some((part) => part.startsWith('@')))
331
+ paths[key] = Object.freeze([...path])
287
332
  const scalar = typeof value === 'string' || typeof value === 'number'
333
+ if (group === 'typography' && scalar)
334
+ throw new InvalidError(
335
+ path,
336
+ 'Expected a typography set or a nested set group.',
337
+ )
288
338
  const entries = scalar ? undefined : record(value, path)
289
339
  const pair =
290
340
  ['color', 'backgroundColor', 'borderColor', 'textColor'].includes(
@@ -338,6 +388,24 @@ function build(
338
388
 
339
389
  for (const [name, child] of entries!) {
340
390
  const next = [...path, name]
391
+ if (group === 'typography' && name.startsWith('@')) {
392
+ if (!Typography.condition(name))
393
+ throw new InvalidError(
394
+ next,
395
+ 'Typography conditions must be media or container queries.',
396
+ )
397
+ conditions.push(next)
398
+ }
399
+ if (
400
+ group === 'typography' &&
401
+ path.some((part) => part.startsWith('@')) &&
402
+ !Typography.condition(name) &&
403
+ !Typography.properties.includes(name as Typography.Property)
404
+ )
405
+ throw new InvalidError(
406
+ next,
407
+ 'Typography query blocks accept only typography fields and queries.',
408
+ )
341
409
  if (
342
410
  base &&
343
411
  !Object.keys(base).some(
@@ -347,7 +415,18 @@ function build(
347
415
  )
348
416
  throw new InvalidError(next, 'Extensions cannot add token paths.')
349
417
 
350
- visit(child, group, next)
418
+ const property =
419
+ group === 'typography' &&
420
+ Typography.properties.includes(name as Typography.Property)
421
+ ? (name as Typography.Property)
422
+ : undefined
423
+ if (property && typeof child !== 'string' && typeof child !== 'number')
424
+ throw new InvalidError(
425
+ next,
426
+ 'Typography properties require scalar values.',
427
+ )
428
+
429
+ visit(child, property ?? group, next)
351
430
  }
352
431
 
353
432
  active.delete(value as object)
@@ -435,6 +514,7 @@ function build(
435
514
  'backgroundColor',
436
515
  'borderColor',
437
516
  'borderRadius',
517
+ 'borderWidth',
438
518
  'color',
439
519
  'margin',
440
520
  'padding',
@@ -445,6 +525,7 @@ function build(
445
525
  'letterSpacing',
446
526
  'lineHeight',
447
527
  'textColor',
528
+ 'typography',
448
529
  ].includes(group)
449
530
  )
450
531
  throw new InvalidError([group], 'Unsupported token group.')
@@ -459,8 +540,26 @@ function build(
459
540
  if (!entries.length && !base)
460
541
  throw new InvalidError([group], 'Token palettes cannot be empty.')
461
542
 
462
- for (const [name, value] of entries)
463
- visit(value, group as Token.Group, [group, name])
543
+ for (const [name, value] of entries) {
544
+ if (
545
+ group === 'typography' &&
546
+ (Typography.properties.includes(name as Typography.Property) ||
547
+ name.startsWith('@'))
548
+ )
549
+ throw new InvalidError(
550
+ [group, name],
551
+ 'Typography properties require a named set.',
552
+ )
553
+ visit(value, group as Token.Group | 'typography', [group, name])
554
+ }
555
+ }
556
+
557
+ for (const path of conditions) {
558
+ try {
559
+ Condition.normalize(Query.resolve(path.at(-1)!, queries))
560
+ } catch (error) {
561
+ throw new InvalidError(path, (error as Error).message)
562
+ }
464
563
  }
465
564
 
466
565
  type Tree = { [key: string]: Tree | Token.Reference }
@@ -468,7 +567,7 @@ function build(
468
567
  const tokens: Tree = Object.create(null)
469
568
 
470
569
  for (const [path, value] of Object.entries(values)) {
471
- const parts = path.split('.')
570
+ const parts = paths[path] ?? path.split('.')
472
571
  let tree = tokens
473
572
 
474
573
  for (const part of parts.slice(0, -1))
@@ -476,7 +575,9 @@ function build(
476
575
 
477
576
  tree[parts.at(-1)!] = Token.create({
478
577
  contract,
479
- group: parts[0] as Token.Group,
578
+ group: (parts[0] === 'typography'
579
+ ? parts.at(-1)
580
+ : parts[0]) as Token.Group,
480
581
  path,
481
582
  value,
482
583
  })
@@ -518,6 +619,7 @@ function build(
518
619
  {
519
620
  value: Object.freeze({
520
621
  contract,
622
+ ...(Object.keys(paths).length ? { paths: Object.freeze(paths) } : {}),
521
623
  values: Object.freeze(values),
522
624
  ...(hasQueries
523
625
  ? {
@@ -568,7 +670,8 @@ function record(
568
670
  if (
569
671
  typeof key !== 'string' ||
570
672
  !key ||
571
- key.includes('.') ||
673
+ (key.includes('.') &&
674
+ !(path[0] === 'typography' && Typography.condition(key))) ||
572
675
  !descriptor.enumerable ||
573
676
  !('value' in descriptor)
574
677
  )
@@ -634,7 +737,11 @@ type ValidPalette<palette, group> = palette extends undefined
634
737
  : {
635
738
  [key in keyof palette]: key extends `${string}!${string}`
636
739
  ? never
637
- : ValidTree<palette[key], group>
740
+ : group extends 'typography'
741
+ ? key extends Typography.Property | `@${string}`
742
+ ? never
743
+ : ValidTree<palette[key], group>
744
+ : ValidTree<palette[key], group>
638
745
  }
639
746
 
640
747
  type WeightDigits<
@@ -671,27 +778,29 @@ type Weight<value> = value extends number
671
778
  : value
672
779
 
673
780
  type ValidTree<tree, group> = tree extends string | number
674
- ? tree extends Scalar<group>
675
- ? group extends 'breakpoints' | 'containers'
676
- ? tree extends `-${string}`
677
- ? never
678
- : Literal.Checked<tree>
679
- : group extends keyof Literal.Properties
680
- ? Literal.Checked<tree> &
681
- Value.Checked<Record<group, tree>>[group] &
682
- (group extends 'fontWeight' ? Weight<tree> : unknown) &
683
- (tree extends string
684
- ? Lowercase<tree> extends
685
- | 'inherit'
686
- | 'initial'
687
- | 'unset'
688
- | 'revert'
689
- | 'revert-layer'
690
- ? never
691
- : unknown
692
- : unknown)
693
- : Literal.Checked<tree>
694
- : never
781
+ ? group extends 'typography'
782
+ ? never
783
+ : tree extends Scalar<group>
784
+ ? group extends 'breakpoints' | 'containers'
785
+ ? tree extends `-${string}`
786
+ ? never
787
+ : Literal.Checked<tree>
788
+ : group extends keyof Literal.Properties
789
+ ? Literal.Checked<tree> &
790
+ Value.Checked<Record<group, tree>>[group] &
791
+ (group extends 'fontWeight' ? Weight<tree> : unknown) &
792
+ (tree extends string
793
+ ? Lowercase<tree> extends
794
+ | 'inherit'
795
+ | 'initial'
796
+ | 'unset'
797
+ | 'revert'
798
+ | 'revert-layer'
799
+ ? never
800
+ : unknown
801
+ : unknown)
802
+ : Literal.Checked<tree>
803
+ : never
695
804
  : Extract<
696
805
  keyof tree,
697
806
  group extends 'color' | 'backgroundColor' | 'borderColor' | 'textColor'
@@ -701,7 +810,24 @@ type ValidTree<tree, group> = tree extends string | number
701
810
  ? {
702
811
  [key in keyof tree]: key extends `${string}!${string}`
703
812
  ? never
704
- : ValidTree<tree[key], group>
813
+ : group extends 'typography'
814
+ ? key extends `@${string}`
815
+ ? key extends Typography.Condition
816
+ ? ValidTree<tree[key], group> &
817
+ Record<
818
+ Exclude<
819
+ keyof tree[key],
820
+ Typography.Property | Typography.Condition
821
+ >,
822
+ never
823
+ >
824
+ : never
825
+ : key extends Typography.Property
826
+ ? tree[key] extends string | number
827
+ ? ValidTree<tree[key], key>
828
+ : never
829
+ : ValidTree<tree[key], group>
830
+ : ValidTree<tree[key], group>
705
831
  }
706
832
  : group extends 'color' | 'backgroundColor' | 'borderColor' | 'textColor'
707
833
  ? {