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
@@ -13,7 +13,7 @@ import type * as Ast from '@oxc-project/types'
13
13
  import * as Parser from 'oxc-parser'
14
14
  import * as Syntax from './internal/Syntax.js'
15
15
  import * as Walker from 'oxc-walker'
16
- import type * as Theme from '../Theme.js'
16
+ import type * as Theme from '../internal/Theme.js'
17
17
  import * as Token from '../internal/Token.js'
18
18
  import * as Contract from './internal/Contract.js'
19
19
  import * as Relative from './internal/Relative.js'
@@ -135,7 +135,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
135
135
  Object.keys(options.native ?? {}).length ||
136
136
  Object.entries(cache?.native ?? {}).some(([key, value]) => {
137
137
  const next = Reflect.get(options.native ?? {}, key)
138
- if (key !== 'fonts' && key !== 'themes' && key !== 'units')
138
+ if (key !== 'fonts' && key !== 'vars' && key !== 'units')
139
139
  return value !== next
140
140
 
141
141
  return (
@@ -961,7 +961,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
961
961
  source: options.modules[moduleId]!,
962
962
  }
963
963
 
964
- Object.assign(themes, result.themes)
964
+ Object.assign(themes, result.vars)
965
965
  visiting.delete(moduleId)
966
966
 
967
967
  return result
@@ -1060,7 +1060,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
1060
1060
  native: {
1061
1061
  ...options.native,
1062
1062
  ...(options.native.fonts && { fonts: { ...options.native.fonts } }),
1063
- ...(options.native.themes && { themes: { ...options.native.themes } }),
1063
+ ...(options.native.vars && { vars: { ...options.native.vars } }),
1064
1064
  ...(options.native.units && { units: { ...options.native.units } }),
1065
1065
  },
1066
1066
  resolutions: Object.freeze(resolutions),
@@ -1121,7 +1121,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
1121
1121
  ? ''
1122
1122
  : (Css.compile({
1123
1123
  styles: { styles: [] },
1124
- themes: sharedThemes,
1124
+ vars: sharedThemes,
1125
1125
  contributions: [contribution],
1126
1126
  }).contributionCss ?? ''),
1127
1127
  layers: contribution.kind === 'layers' ? [contribution.names] : [],
@@ -1345,7 +1345,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
1345
1345
  )
1346
1346
  identities.set(name, signature)
1347
1347
  }
1348
- for (const [name, theme] of Object.entries(module.themes)) {
1348
+ for (const [name, theme] of Object.entries(module.vars)) {
1349
1349
  const data = theme[Token.definition]
1350
1350
  if (data.contract[Token.identity]?.startsWith('id-'))
1351
1351
  register(`theme:${name}`, JSON.stringify(data.values))
@@ -1403,7 +1403,7 @@ function build(options: compile.Options, cache?: Cache): Cache {
1403
1403
  [Themes.context]: {
1404
1404
  extracted: Object.freeze({
1405
1405
  ...extracted.get(moduleId)!,
1406
- themes: sharedThemes,
1406
+ vars: sharedThemes,
1407
1407
  contributions: undefined,
1408
1408
  }),
1409
1409
  links: {},
@@ -1435,7 +1435,12 @@ function build(options: compile.Options, cache?: Cache): Cache {
1435
1435
  }
1436
1436
 
1437
1437
  for (const call of extracted.get(moduleId)!.calls)
1438
- if (call.identity)
1438
+ if (
1439
+ call.identity &&
1440
+ !call.composition &&
1441
+ !call.runtimeComposition &&
1442
+ !call.compositionCase
1443
+ )
1439
1444
  styleClasses[call.identity] = modules[moduleId]!.classes[call.name]!
1440
1445
  }
1441
1446
 
@@ -1581,6 +1586,6 @@ function nativeOutput(
1581
1586
  get map() {
1582
1587
  return (sourceMap ??= JSON.parse(output.map) as Mapping.EncodedSourceMap)
1583
1588
  },
1584
- themes: Object.freeze({}),
1589
+ vars: Object.freeze({}),
1585
1590
  })
1586
1591
  }
@@ -13,7 +13,7 @@ import * as Walker from 'oxc-walker'
13
13
 
14
14
  /**
15
15
  * Compiles local style and variants calls for an explicit native context.
16
- * @param options - Shared source, destination mappings, and selected theme/scheme.
16
+ * @param options - Shared source, destination mappings, and selected set/scheme.
17
17
  * @returns Native callables, source map, and static recipe tables.
18
18
  * @throws {Source.ExtractError} For invalid source authoring.
19
19
  * @throws {CompileError} For native features outside the static source boundary.
@@ -38,7 +38,7 @@ export function compile(options: compile.Options): compile.ReturnType {
38
38
  (extracted.themeAppearances?.length || extracted.themeScripts?.length))
39
39
  )
40
40
  throw new CompileError(
41
- 'Native static modules do not support CSS contributions, variables, or web theme controls.',
41
+ 'Native static modules do not support CSS contributions, variables, or web set controls.',
42
42
  )
43
43
  const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options)
44
44
  const names = new Set(options[Themes.context]?.identifiers)
@@ -93,10 +93,7 @@ export function compile(options: compile.Options): compile.ReturnType {
93
93
 
94
94
  const staticTables = new Map<Source.Call, Variants.Definition>()
95
95
  if (options.contextual) {
96
- const groups = new Map<
97
- StyleSheet.compile.Options['themes'],
98
- Source.Call[]
99
- >()
96
+ const groups = new Map<StyleSheet.compile.Options['vars'], Source.Call[]>()
100
97
  for (const call of extracted.calls) {
101
98
  if (
102
99
  call.recipe ||
@@ -106,12 +103,12 @@ export function compile(options: compile.Options): compile.ReturnType {
106
103
  call.output === 'html'
107
104
  )
108
105
  continue
109
- const themes = call.nativeContext?.themes ?? options.themes
110
- const group = groups.get(themes)
106
+ const vars = call.nativeContext?.vars ?? options.vars
107
+ const group = groups.get(vars)
111
108
  if (group) group.push(call)
112
- else groups.set(themes, [call])
109
+ else groups.set(vars, [call])
113
110
  }
114
- for (const [themes, calls] of groups) {
111
+ for (const [vars, calls] of groups) {
115
112
  if (calls.length < 2) continue
116
113
  try {
117
114
  const compiled = StyleSheet.compile({
@@ -126,13 +123,13 @@ export function compile(options: compile.Options): compile.ReturnType {
126
123
  })),
127
124
  })),
128
125
  },
129
- themes,
126
+ vars,
130
127
  units: options.units,
131
128
  })
132
129
  for (const call of calls) {
133
130
  const styles = Object.fromEntries(
134
- Object.entries(compiled.styles).map(([theme, schemes]) => [
135
- theme,
131
+ Object.entries(compiled.styles).map(([set, schemes]) => [
132
+ set,
136
133
  Object.freeze({
137
134
  light: Object.freeze({ '0': schemes.light[call.name]! }),
138
135
  dark: Object.freeze({ '0': schemes.dark[call.name]! }),
@@ -237,32 +234,32 @@ export function compile(options: compile.Options): compile.ReturnType {
237
234
  bindings?: ReturnType<typeof NativeBindings.prepare>,
238
235
  ): string {
239
236
  if (contextOptions.contextual) {
240
- const themes = call?.nativeContext?.themes ?? contextOptions.themes
237
+ const vars = call?.nativeContext?.vars ?? contextOptions.vars
241
238
  if (!call?.slots && !call?.recipe?.payloads?.length)
242
239
  compiled ??= Variants.compile({
243
240
  recipe,
244
241
  fonts: contextOptions.fonts,
245
242
  platform: contextOptions.platform,
246
- themes,
243
+ vars,
247
244
  units: contextOptions.units,
248
245
  })
249
246
  else {
250
247
  try {
251
248
  bindings = NativeBindings.prepare(recipe, call!, {
252
249
  ...contextOptions,
253
- themes,
250
+ vars,
254
251
  })
255
252
  } catch (error) {
256
253
  if (error instanceof StyleSheet.CompileError) throw error
257
254
  throw new CompileError((error as Error).message)
258
255
  }
259
256
  }
260
- const defaultTheme =
261
- call?.nativeContext?.defaultTheme ?? contextOptions.theme ?? 'default'
257
+ const defaultVars =
258
+ call?.nativeContext?.defaultVars ?? contextOptions.set ?? 'default'
262
259
  const tables = new Map<string, string>()
263
- const alternatives = (themes ? Object.keys(themes) : ['default']).map(
264
- (theme) => ({
265
- theme,
260
+ const alternatives = (vars ? Object.keys(vars) : ['default']).map(
261
+ (set) => ({
262
+ set,
266
263
  schemes: (['light', 'dark'] as const).map((colorScheme) => {
267
264
  const value = callable(
268
265
  recipe,
@@ -271,8 +268,8 @@ export function compile(options: compile.Options): compile.ReturnType {
271
268
  {
272
269
  ...contextOptions,
273
270
  contextual: false,
274
- themes,
275
- theme,
271
+ vars,
272
+ set,
276
273
  colorScheme,
277
274
  },
278
275
  compiled,
@@ -285,8 +282,8 @@ export function compile(options: compile.Options): compile.ReturnType {
285
282
  }),
286
283
  )
287
284
  const entries = alternatives.map(
288
- ({ theme, schemes }) =>
289
- `${JSON.stringify(theme)}:{${schemes.map(({ colorScheme, value }) => `${JSON.stringify(colorScheme)}:${tables.get(value)}`).join(',')}}`,
285
+ ({ set, schemes }) =>
286
+ `${JSON.stringify(set)}:{${schemes.map(({ colorScheme, value }) => `${JSON.stringify(colorScheme)}:${tables.get(value)}`).join(',')}}`,
290
287
  )
291
288
  const parameters = [...tables.values()].map((name, index) =>
292
289
  typed ? `${name}:T${index}` : name,
@@ -294,7 +291,7 @@ export function compile(options: compile.Options): compile.ReturnType {
294
291
  const types = typed
295
292
  ? `<${parameters.map((_, index) => `const T${index} extends (input:never)=>import('zyzz/runtime').Native.Props<object>`).join(',')},>`
296
293
  : ''
297
- const expression = `${types}(${parameters.join(',')})=>${helper}Context.create({${entries.join(',')}},${JSON.stringify(defaultTheme)})`
294
+ const expression = `${types}(${parameters.join(',')})=>${helper}Context.create({${entries.join(',')}},${JSON.stringify(defaultVars)})`
298
295
  let context = contexts.get(expression)
299
296
  if (!context) {
300
297
  context = `${helper}ContextFactory${contexts.size}`
@@ -351,12 +348,12 @@ export function compile(options: compile.Options): compile.ReturnType {
351
348
  recipe,
352
349
  fonts: contextOptions.fonts,
353
350
  platform: contextOptions.platform,
354
- themes: contextOptions.themes,
351
+ vars: contextOptions.vars,
355
352
  units: contextOptions.units,
356
353
  })
357
354
  recipes[name] = compiled
358
355
  const styles = StyleSheet.select(compiled.styles, {
359
- theme: contextOptions.theme ?? 'default',
356
+ set: contextOptions.set ?? 'default',
360
357
  colorScheme: contextOptions.colorScheme,
361
358
  })
362
359
  const cached = compiledCalls.get(compiled)
@@ -743,7 +740,7 @@ export declare namespace compile {
743
740
  readonly [Edits.runtime]?: boolean | undefined
744
741
  /** Compiler-owned graph context. */
745
742
  readonly [Themes.context]?: Themes.Context | undefined
746
- /** Retain every theme and scheme for render-local selection. */
743
+ /** Retain every set and scheme for render-local selection. */
747
744
  readonly contextual?: boolean | undefined
748
745
  /** Scheme compiled into this module's callables. Recompile to select another scheme. */
749
746
  readonly colorScheme: StyleSheet.ColorScheme
@@ -751,8 +748,8 @@ export declare namespace compile {
751
748
  readonly moduleId: string
752
749
  /** Shared local style and variants authoring. */
753
750
  readonly source: string
754
- /** Label selected from supplied themes. Defaults to the token-fallback default table. */
755
- readonly theme?: string | undefined
751
+ /** Label selected from supplied vars. Defaults to the token-fallback default table. */
752
+ readonly set?: string | undefined
756
753
  }
757
754
  /** Executable source with immutable recipe tables and authored source mappings. */
758
755
  type ReturnType = {
@@ -762,7 +759,7 @@ export declare namespace compile {
762
759
  readonly code: string
763
760
  /** Version-three source map encoded as JSON. */
764
761
  readonly map: string
765
- /** All theme/scheme tables for each extracted definition. */
762
+ /** All set/scheme tables for each extracted definition. */
766
763
  readonly recipes: Readonly<Record<string, Variants.Definition>>
767
764
  }
768
765
  }
@@ -27,11 +27,13 @@ import * as Scope from './internal/Scope.js'
27
27
  import type * as Shorthands from '../internal/Shorthands.js'
28
28
  import * as Static from './internal/Static.js'
29
29
  import * as Style from '../Style.js'
30
- import type * as Theme from '../Theme.js'
30
+ import type * as Theme from '../internal/Theme.js'
31
31
  import * as Themes from './internal/Themes.js'
32
32
  import * as ThemeValues from '../web/internal/Themes.js'
33
33
  import * as Token from '../internal/Token.js'
34
- import * as Variables from './internal/Variables.js'
34
+ import * as Typography from '../internal/Typography.js'
35
+ import * as Value from '../internal/Value.js'
36
+ import * as Vars from './internal/Vars.js'
35
37
  import * as Walker from 'oxc-walker'
36
38
 
37
39
  // JavaScript extraction supplies untyped values. Keep structural checks without
@@ -47,9 +49,9 @@ export type Call = {
47
49
  readonly nativeContext?:
48
50
  | {
49
51
  /** Default label selected when the provider omits its theme. */
50
- readonly defaultTheme: string
52
+ readonly defaultVars: string
51
53
  /** Compatible alternatives from the owning configuration. */
52
- readonly themes: Readonly<Record<string, Theme.Definition>>
54
+ readonly vars: Readonly<Record<string, Theme.Definition>>
53
55
  }
54
56
  | undefined
55
57
  /** Class identity available without source rewriting. */
@@ -97,6 +99,10 @@ export type Call = {
97
99
  readonly body?: Ast.ObjectExpression | undefined
98
100
  /** Alias targets retained for declaration source locations. */
99
101
  readonly shorthands?: Shorthands.Map | undefined
102
+ /** Emitted typography field counts keyed by authored property offsets. */
103
+ readonly typography?: ReadonlyMap<number, number> | undefined
104
+ /** Emitted typography query counts keyed by authored property offsets. */
105
+ readonly typographyQueries?: ReadonlyMap<number, number> | undefined
100
106
  /** Native HTML attribute output selected by the bound configuration. */
101
107
  readonly output?: 'html' | undefined
102
108
  /** Typed runtime slots for callback definitions. */
@@ -174,6 +180,27 @@ export function extract(options: extract.Options): extract.ReturnType {
174
180
 
175
181
  const namespace = identity(options.moduleId)
176
182
  const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options)
183
+ for (const node of parsed.program.body) {
184
+ if (node.type !== 'ImportDeclaration' || node.source.value !== 'zyzz')
185
+ continue
186
+ for (const specifier of node.specifiers) {
187
+ if (specifier.type !== 'ImportSpecifier') continue
188
+ const name =
189
+ specifier.imported.type === 'Identifier'
190
+ ? specifier.imported.name
191
+ : specifier.imported.value
192
+ if (name === 'Theme' || name === 'Variables')
193
+ throw new ExtractError([
194
+ {
195
+ code: 'unsupported_syntax',
196
+ message: `Import Vars instead of ${name}.`,
197
+ source: options.moduleId,
198
+ start: specifier.start,
199
+ end: specifier.end,
200
+ },
201
+ ])
202
+ }
203
+ }
177
204
 
178
205
  if (parsed.errors.length) {
179
206
  for (const error of parsed.errors) {
@@ -216,7 +243,7 @@ export function extract(options: extract.Options): extract.ReturnType {
216
243
 
217
244
  const variables = (() => {
218
245
  try {
219
- return Variables.collect(
246
+ return Vars.collect(
220
247
  program,
221
248
  namespace,
222
249
  scopeTracker,
@@ -290,7 +317,7 @@ export function extract(options: extract.Options): extract.ReturnType {
290
317
 
291
318
  const binding =
292
319
  node.type === 'Identifier'
293
- ? declaration ?? null
320
+ ? (declaration ?? null)
294
321
  : scopeTracker.getDeclaration(node.name)
295
322
 
296
323
  contributions.read(node, parent, binding)
@@ -344,6 +371,7 @@ export function extract(options: extract.Options): extract.ReturnType {
344
371
  name === 'cx' ||
345
372
  name === 'style' ||
346
373
  name === 'Theme' ||
374
+ name === 'Vars' ||
347
375
  name === 'variable' ||
348
376
  name === 'variants'
349
377
  )
@@ -640,6 +668,8 @@ export function extract(options: extract.Options): extract.ReturnType {
640
668
  }
641
669
  const name = `style-${namespace}-${call.start}`
642
670
  const locations: Style.SourceLocation[] = []
671
+ const typography = new Map<number, number>()
672
+ const typographyQueries = new Map<number, number>()
643
673
  const conditionKeys = new Map<string, Ast.Node>()
644
674
 
645
675
  function object(
@@ -690,7 +720,7 @@ export function extract(options: extract.Options): extract.ReturnType {
690
720
  ? entry.key.value
691
721
  : undefined
692
722
  : undefined
693
- if (key !== 'selectors' && key !== 'variables') {
723
+ if (key !== 'selectors' && key !== 'vars') {
694
724
  properties.push(entry)
695
725
  continue
696
726
  }
@@ -979,11 +1009,17 @@ export function extract(options: extract.Options): extract.ReturnType {
979
1009
  !(Binding.is(part)
980
1010
  ? (dynamicValues !== undefined &&
981
1011
  Object.values(dynamicValues.slots).includes(part)) ||
982
- targets.every((target) =>
983
- Binding.accepts(part.type, target),
1012
+ targets.every(
1013
+ (target) =>
1014
+ Binding.accepts(part.type, target) ||
1015
+ (part.type === 'color' &&
1016
+ Expression.acceptsColor(template, target)),
984
1017
  )
985
- : targets.every((target) =>
986
- Token.accepts(part.group, target),
1018
+ : targets.every(
1019
+ (target) =>
1020
+ Token.acceptsReference(part, target) ||
1021
+ (part.group === 'color' &&
1022
+ Expression.acceptsColor(template, target)),
987
1023
  ))
988
1024
  ) {
989
1025
  report(
@@ -1003,7 +1039,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1003
1039
  reference &&
1004
1040
  Token.is(reference) &&
1005
1041
  !targets.every((target) =>
1006
- Token.accepts(reference.group, target),
1042
+ Token.acceptsReference(reference, target),
1007
1043
  ) &&
1008
1044
  !targets.every((target) =>
1009
1045
  dynamicValues?.accepts(
@@ -1101,6 +1137,34 @@ export function extract(options: extract.Options): extract.ReturnType {
1101
1137
  values[key] = value(property.value, [name, ...prefix, key])
1102
1138
  }
1103
1139
 
1140
+ if (typeof values.typography === 'string') {
1141
+ const theme = themes?.styles.get(call.start)?.theme
1142
+ const mappings = theme?.[Token.definition].contract.shorthands
1143
+ const explicit = new Set(
1144
+ Object.keys(values).flatMap((key) => mappings?.[key] ?? [key]),
1145
+ )
1146
+ const parsed = Value.parse(values.typography, 'fontFamily')
1147
+ const keys = Typography.keys(
1148
+ theme,
1149
+ parsed && !('invalid' in parsed) ? parsed.value : values.typography,
1150
+ explicit,
1151
+ )
1152
+ const queries = keys.filter(Typography.condition).length
1153
+ for (const property of properties) {
1154
+ if (property.type !== 'Property') continue
1155
+ const key =
1156
+ property.key.type === 'Identifier'
1157
+ ? property.key.name
1158
+ : property.key.type === 'Literal'
1159
+ ? property.key.value
1160
+ : undefined
1161
+ if (key === 'typography') {
1162
+ typography.set(property.start, keys.length - queries)
1163
+ if (queries) typographyQueries.set(property.start, queries)
1164
+ }
1165
+ }
1166
+ }
1167
+
1104
1168
  return values
1105
1169
  }
1106
1170
 
@@ -1110,7 +1174,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1110
1174
  try {
1111
1175
  const definition = define(
1112
1176
  { [name]: values },
1113
- { locations, theme: themes?.styles.get(call.start)?.theme },
1177
+ { locations, vars: themes?.styles.get(call.start)?.theme },
1114
1178
  )
1115
1179
 
1116
1180
  function validate(style: Style.NamedStyle, path: readonly string[]) {
@@ -1166,7 +1230,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1166
1230
  matches,
1167
1231
  value: define(
1168
1232
  { [`${name}-${index}`]: object(value) },
1169
- { locations, theme: themes?.styles.get(call.start)?.theme },
1233
+ { locations, vars: themes?.styles.get(call.start)?.theme },
1170
1234
  ),
1171
1235
  })),
1172
1236
  }
@@ -1185,6 +1249,8 @@ export function extract(options: extract.Options): extract.ReturnType {
1185
1249
  ? { body: argument }
1186
1250
  : {}),
1187
1251
  ...(shorthands ? { shorthands } : {}),
1252
+ ...(typography.size ? { typography } : {}),
1253
+ ...(typographyQueries.size ? { typographyQueries } : {}),
1188
1254
  ...(themes?.styles.get(call.start)?.output
1189
1255
  ? { output: 'html' as const }
1190
1256
  : {}),
@@ -1239,6 +1305,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1239
1305
  identity: namespace,
1240
1306
  links: options[Themes.context]?.links,
1241
1307
  program,
1308
+ scopes: themes?.scopeApplications,
1242
1309
  source: options.source,
1243
1310
  styles,
1244
1311
  })) {
@@ -1315,7 +1382,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1315
1382
  const rendered = Css.compile({
1316
1383
  styles: { styles: [] },
1317
1384
  contributions: contributionData,
1318
- themes: themes?.themes,
1385
+ vars: themes?.themes,
1319
1386
  }).css
1320
1387
  AtRules.transform({
1321
1388
  filename: options.moduleId,
@@ -1453,7 +1520,7 @@ export function extract(options: extract.Options): extract.ReturnType {
1453
1520
  }
1454
1521
  : {}),
1455
1522
  themeReferences: Object.freeze(themes?.references ?? []),
1456
- themes: themes?.themes ?? Object.freeze({}),
1523
+ vars: themes?.themes ?? Object.freeze({}),
1457
1524
  })
1458
1525
  }
1459
1526
 
@@ -1485,7 +1552,7 @@ export declare namespace extract {
1485
1552
  readonly contributions?: readonly Css.Contribution[] | undefined
1486
1553
  readonly contributionCalls?: readonly Contributions.Call[] | undefined
1487
1554
  /** Explicit variable contracts replaced by fixed slot data. */
1488
- readonly variableCalls?: readonly Variables.Call[] | undefined
1555
+ readonly variableCalls?: readonly Vars.Call[] | undefined
1489
1556
  /** Direct calls in source order. */
1490
1557
  readonly calls: readonly Call[]
1491
1558
  /** Validated definitions accepted by Css.compile. */
@@ -1512,7 +1579,7 @@ export declare namespace extract {
1512
1579
  /** Resolved authoring exports when extracted as part of a source graph. */
1513
1580
  readonly themeExports?: Readonly<Record<string, Themes.Link>> | undefined
1514
1581
  /** Stable scope keys and validated local theme definitions. */
1515
- readonly themes: Readonly<Record<string, Theme.Definition>>
1582
+ readonly vars: Readonly<Record<string, Theme.Definition>>
1516
1583
  }
1517
1584
  }
1518
1585