zyzz 0.0.3 → 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 (247) 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 +15 -12
  7. package/dist/Style.d.ts.map +1 -1
  8. package/dist/Style.js +51 -26
  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 +8 -6
  21. package/dist/compiler/Source.d.ts.map +1 -1
  22. package/dist/compiler/Source.js +47 -14
  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 +58 -22
  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 +155 -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 +147 -2562
  72. package/dist/default.d.ts.map +1 -1
  73. package/dist/default.js +85 -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/{Theme.d.ts → internal/Theme.d.ts} +15 -13
  102. package/dist/internal/Theme.d.ts.map +1 -0
  103. package/dist/{Theme.js → internal/Theme.js} +39 -12
  104. package/dist/internal/Theme.js.map +1 -0
  105. package/dist/internal/Token.d.ts +46 -16
  106. package/dist/internal/Token.d.ts.map +1 -1
  107. package/dist/internal/Token.js +89 -5
  108. package/dist/internal/Token.js.map +1 -1
  109. package/dist/internal/Typography.d.ts +13 -5
  110. package/dist/internal/Typography.d.ts.map +1 -1
  111. package/dist/internal/Typography.js +42 -6
  112. package/dist/internal/Typography.js.map +1 -1
  113. package/dist/internal/Value.d.ts +6 -1
  114. package/dist/internal/Value.d.ts.map +1 -1
  115. package/dist/internal/Value.js.map +1 -1
  116. package/dist/internal/VariableSets.d.ts +20 -0
  117. package/dist/internal/VariableSets.d.ts.map +1 -0
  118. package/dist/internal/VariableSets.js +317 -0
  119. package/dist/internal/VariableSets.js.map +1 -0
  120. package/dist/next/loader.js +15 -5
  121. package/dist/next/loader.js.map +1 -1
  122. package/dist/node/Host.d.ts.map +1 -1
  123. package/dist/node/Host.js +1 -1
  124. package/dist/node/Host.js.map +1 -1
  125. package/dist/react-native/Host.d.ts +2 -2
  126. package/dist/react-native/Host.d.ts.map +1 -1
  127. package/dist/react-native/Host.js +4 -4
  128. package/dist/react-native/Host.js.map +1 -1
  129. package/dist/react-native/StyleSheet.d.ts +9 -8
  130. package/dist/react-native/StyleSheet.d.ts.map +1 -1
  131. package/dist/react-native/StyleSheet.js +29 -23
  132. package/dist/react-native/StyleSheet.js.map +1 -1
  133. package/dist/react-native/Variants.d.ts +3 -3
  134. package/dist/react-native/Variants.d.ts.map +1 -1
  135. package/dist/react-native/Variants.js +2 -2
  136. package/dist/react-native/react.d.ts +1 -1
  137. package/dist/react-native/react.d.ts.map +1 -1
  138. package/dist/react-native/react.js +5 -5
  139. package/dist/react-native/react.js.map +1 -1
  140. package/dist/rollup/index.d.ts +3 -0
  141. package/dist/rollup/index.d.ts.map +1 -0
  142. package/dist/rollup/index.js +5 -0
  143. package/dist/rollup/index.js.map +1 -0
  144. package/dist/runtime/Appearance.d.ts +7 -7
  145. package/dist/runtime/Appearance.d.ts.map +1 -1
  146. package/dist/runtime/Appearance.js +15 -15
  147. package/dist/runtime/Appearance.js.map +1 -1
  148. package/dist/runtime/Dynamic.d.ts.map +1 -1
  149. package/dist/runtime/Dynamic.js +4 -1
  150. package/dist/runtime/Dynamic.js.map +1 -1
  151. package/dist/runtime/NativeContext.d.ts +4 -4
  152. package/dist/runtime/NativeContext.d.ts.map +1 -1
  153. package/dist/runtime/NativeContext.js +5 -5
  154. package/dist/runtime/NativeContext.js.map +1 -1
  155. package/dist/runtime/NativeDynamic.d.ts +1 -1
  156. package/dist/runtime/NativeDynamic.d.ts.map +1 -1
  157. package/dist/runtime/NativeDynamic.js.map +1 -1
  158. package/dist/runtime/Props.d.ts +1 -1
  159. package/dist/runtime/Props.js +3 -3
  160. package/dist/runtime/Props.js.map +1 -1
  161. package/dist/runtime/Selection.d.ts +14 -10
  162. package/dist/runtime/Selection.d.ts.map +1 -1
  163. package/dist/runtime/Selection.js +19 -18
  164. package/dist/runtime/Selection.js.map +1 -1
  165. package/dist/styleFunction.d.ts +14 -14
  166. package/dist/styleFunction.d.ts.map +1 -1
  167. package/dist/styleFunction.js.map +1 -1
  168. package/dist/unplugin/index.d.ts +20 -0
  169. package/dist/unplugin/index.d.ts.map +1 -0
  170. package/dist/unplugin/index.js +498 -0
  171. package/dist/unplugin/index.js.map +1 -0
  172. package/dist/variants.d.ts +3 -3
  173. package/dist/variants.d.ts.map +1 -1
  174. package/dist/variants.js.map +1 -1
  175. package/dist/vite/index.d.ts.map +1 -1
  176. package/dist/vite/index.js +6 -3
  177. package/dist/vite/index.js.map +1 -1
  178. package/dist/web/Css.d.ts +4 -3
  179. package/dist/web/Css.d.ts.map +1 -1
  180. package/dist/web/Css.js +4 -4
  181. package/dist/web/Css.js.map +1 -1
  182. package/dist/web/internal/Themes.d.ts +3 -2
  183. package/dist/web/internal/Themes.d.ts.map +1 -1
  184. package/dist/web/internal/Themes.js +42 -6
  185. package/dist/web/internal/Themes.js.map +1 -1
  186. package/dist/webpack/index.d.ts +3 -0
  187. package/dist/webpack/index.d.ts.map +1 -0
  188. package/dist/webpack/index.js +5 -0
  189. package/dist/webpack/index.js.map +1 -0
  190. package/package.json +23 -2
  191. package/src/Config.ts +43 -685
  192. package/src/Style.ts +97 -34
  193. package/src/Vars.ts +299 -0
  194. package/src/compiler/Graph.ts +14 -9
  195. package/src/compiler/Native.ts +29 -32
  196. package/src/compiler/Source.ts +59 -21
  197. package/src/compiler/Transform.ts +73 -23
  198. package/src/compiler/internal/Compositions.ts +36 -3
  199. package/src/compiler/internal/Configurations.ts +83 -11
  200. package/src/compiler/internal/Contract.ts +207 -15
  201. package/src/compiler/internal/Contributions.ts +1 -1
  202. package/src/compiler/internal/Dynamic.ts +1 -1
  203. package/src/compiler/internal/Expression.ts +26 -0
  204. package/src/compiler/internal/Identifiers.ts +2 -1
  205. package/src/compiler/internal/NativeBindings.ts +3 -3
  206. package/src/compiler/internal/PackedStyles.ts +22 -26
  207. package/src/compiler/internal/Recipes.ts +1 -1
  208. package/src/compiler/internal/Selectors.ts +1 -1
  209. package/src/compiler/internal/Themes.ts +266 -57
  210. package/src/compiler/internal/{Variables.ts → Vars.ts} +2 -2
  211. package/src/default.ts +173 -154
  212. package/src/esbuild/index.ts +5 -0
  213. package/src/index.ts +4 -4
  214. package/src/internal/Authoring.ts +5 -7
  215. package/src/internal/Binding.ts +1 -1
  216. package/src/internal/Completion.ts +42 -0
  217. package/src/internal/Condition.ts +31 -1
  218. package/src/internal/Configuration.ts +970 -0
  219. package/src/{Theme.ts → internal/Theme.ts} +75 -20
  220. package/src/internal/Token.ts +258 -85
  221. package/src/internal/Typography.ts +71 -16
  222. package/src/internal/Value.ts +45 -26
  223. package/src/internal/VariableSets.ts +458 -0
  224. package/src/next/loader.ts +19 -5
  225. package/src/node/Host.ts +1 -2
  226. package/src/react-native/Host.ts +6 -6
  227. package/src/react-native/StyleSheet.ts +49 -42
  228. package/src/react-native/Variants.ts +3 -3
  229. package/src/react-native/react.ts +6 -6
  230. package/src/rollup/index.ts +5 -0
  231. package/src/runtime/Appearance.ts +20 -20
  232. package/src/runtime/Dynamic.ts +4 -1
  233. package/src/runtime/NativeContext.ts +8 -8
  234. package/src/runtime/NativeDynamic.ts +2 -4
  235. package/src/runtime/Props.ts +3 -3
  236. package/src/runtime/Selection.ts +44 -33
  237. package/src/styleFunction.ts +22 -19
  238. package/src/unplugin/index.ts +600 -0
  239. package/src/variants.ts +7 -5
  240. package/src/vite/index.ts +5 -4
  241. package/src/web/Css.ts +10 -7
  242. package/src/web/internal/Themes.ts +52 -9
  243. package/src/webpack/index.ts +5 -0
  244. package/dist/Theme.d.ts.map +0 -1
  245. package/dist/Theme.js.map +0 -1
  246. package/dist/compiler/internal/Variables.d.ts.map +0 -1
  247. package/dist/compiler/internal/Variables.js.map +0 -1
@@ -90,10 +90,11 @@ async function compile(context: Context, source: string) {
90
90
 
91
91
  const specifier = node.source.value
92
92
  links[specifier] = null
93
+ // Next owns this virtual module, which has no physical stylesheet contract.
94
+ if (specifier === 'next/root-params') continue
93
95
  if (
94
96
  specifier === 'zyzz' ||
95
- (specifier.startsWith('zyzz/') &&
96
- specifier !== 'zyzz/default') ||
97
+ (specifier.startsWith('zyzz/') && specifier !== 'zyzz/default') ||
97
98
  specifier.startsWith('node:')
98
99
  )
99
100
  continue
@@ -288,15 +289,28 @@ async function compile(context: Context, source: string) {
288
289
  )
289
290
  .split(Path.sep)
290
291
  .join('/')
292
+ // Turbopack appends the output extension to loader-transformed resource paths.
293
+ const resource = await Fs.stat(context.resourcePath).then(
294
+ () => context.resourcePath,
295
+ async (error: NodeJS.ErrnoException) => {
296
+ if (error.code !== 'ENOENT') throw error
297
+ const original = context.resourcePath.slice(
298
+ 0,
299
+ -Path.extname(context.resourcePath).length,
300
+ )
301
+ await Fs.access(original)
302
+ return original
303
+ },
304
+ )
291
305
  const requests = [
292
306
  ...(graph.sharedCss
293
307
  ? [
294
- `import ${JSON.stringify(sharedFile.startsWith('.') ? sharedFile : `./${sharedFile}`)};`,
308
+ `import ${JSON.stringify(sharedFile.startsWith('../') ? sharedFile : `./${sharedFile}`)};`,
295
309
  ]
296
310
  : []),
297
311
  ...(output.css
298
312
  ? [
299
- `import ${JSON.stringify(`./${Path.basename(context.resourcePath)}?zyzz-style`)};`,
313
+ `import ${JSON.stringify(`./${Path.basename(resource)}?zyzz-style`)};`,
300
314
  ]
301
315
  : []),
302
316
  ]
@@ -326,7 +340,7 @@ async function compile(context: Context, source: string) {
326
340
  .split(Path.sep)
327
341
  .join('/')
328
342
  requests.push(
329
- `import ${JSON.stringify(relative.startsWith('.') ? relative : `./${relative}`)};`,
343
+ `import ${JSON.stringify(relative.startsWith('../') ? relative : `./${relative}`)};`,
330
344
  )
331
345
  }
332
346
 
package/src/node/Host.ts CHANGED
@@ -54,8 +54,7 @@ export async function create(options: create.Options): Promise<Runtime> {
54
54
  fonts:
55
55
  options.native.fonts && Object.freeze({ ...options.native.fonts }),
56
56
  // Theme definitions are immutable. Only the caller-owned catalog needs copying.
57
- themes:
58
- options.native.themes && Object.freeze({ ...options.native.themes }),
57
+ vars: options.native.vars && Object.freeze({ ...options.native.vars }),
59
58
  units:
60
59
  options.native.units && Object.freeze({ ...options.native.units }),
61
60
  })
@@ -28,7 +28,7 @@ export function create<
28
28
  'highContrast',
29
29
  'reducedMotion',
30
30
  'rtl',
31
- 'theme',
31
+ 'set',
32
32
  ] as const
33
33
  const bindings = new Set<(context: Snapshot) => () => void>()
34
34
  const listeners = new Set<(context: Snapshot) => void>()
@@ -45,8 +45,8 @@ export function create<
45
45
  (key) => !keys.includes(key as (typeof keys)[number]),
46
46
  ) ||
47
47
  (values.colorScheme !== 'light' && values.colorScheme !== 'dark') ||
48
- typeof values.theme !== 'string' ||
49
- !values.theme.trim() ||
48
+ typeof values.set !== 'string' ||
49
+ !values.set.trim() ||
50
50
  typeof values.density !== 'number' ||
51
51
  !Number.isFinite(values.density) ||
52
52
  values.density <= 0 ||
@@ -58,7 +58,7 @@ export function create<
58
58
  typeof values.rtl !== 'boolean'
59
59
  )
60
60
  throw new InputError(
61
- 'Provide a theme, resolved scheme, positive finite scales, and boolean accessibility inputs.',
61
+ 'Provide a set, resolved scheme, positive finite scales, and boolean accessibility inputs.',
62
62
  )
63
63
  const hairlineWidth =
64
64
  Math.round(0.4 * values.density) / values.density || 1 / values.density
@@ -265,8 +265,8 @@ export type Inputs = {
265
265
  readonly reducedMotion: boolean
266
266
  /** Whether layout follows a right-to-left direction. */
267
267
  readonly rtl: boolean
268
- /** Compiled theme label selected by binding factories. */
269
- readonly theme: string
268
+ /** Compiled set label selected by binding factories. */
269
+ readonly set: string
270
270
  }
271
271
 
272
272
  /** An operation attempted to change a disposed or currently updating host. */
@@ -1,6 +1,7 @@
1
- /** Compiles portable declarations into immutable native theme tables. @module */
1
+ /** Compiles portable declarations into immutable native set tables. @module */
2
2
  import type * as Style from '../Style.js'
3
- import type * as Theme from '../Theme.js'
3
+ import type * as Vars from '../Vars.js'
4
+ import type * as Theme from '../internal/Theme.js'
4
5
  import * as Token from '../internal/Token.js'
5
6
  import type * as Native from '../internal/NativeProperties.js'
6
7
  import * as Values from './internal/Values.js'
@@ -18,7 +19,7 @@ export const absoluteFill = Object.freeze({
18
19
  top: 0,
19
20
  } as const)
20
21
 
21
- /** Explicit theme alternative, never inferred from a device. */
22
+ /** Explicit set alternative, never inferred from a device. */
22
23
  export type ColorScheme = 'dark' | 'light'
23
24
 
24
25
  /** Failure to represent the supplied definitions on the native target. */
@@ -46,7 +47,7 @@ export class CompileError extends Error {
46
47
  }
47
48
 
48
49
  /**
49
- * Resolves portable tokens into two static scheme tables per supplied theme.
50
+ * Resolves portable tokens into two static scheme tables per supplied set.
50
51
  * px defaults to one native logical unit. rem and font families require mappings.
51
52
  * No device state, CSS parser, stylesheet registration, or runtime binding is used.
52
53
  * @throws {CompileError} For unsupported semantics or invalid conversion inputs.
@@ -63,7 +64,7 @@ export function compile<
63
64
  },
64
65
  ): compile.ReturnType<name, themeName, definition, platform> {
65
66
  for (const key of Object.keys(options))
66
- if (!['fonts', 'platform', 'styles', 'themes', 'units'].includes(key))
67
+ if (!['fonts', 'platform', 'styles', 'vars', 'units'].includes(key))
67
68
  fail('invalid_options', 'Unknown native compiler option.', [key])
68
69
 
69
70
  if (
@@ -137,15 +138,18 @@ export function compile<
137
138
  }
138
139
  }
139
140
 
140
- const themes: readonly (readonly [string, Theme.Definition | undefined])[] =
141
- options.themes === undefined
141
+ const vars: readonly (readonly [
142
+ string,
143
+ Theme.Definition | Vars.Definition | undefined,
144
+ ])[] =
145
+ options.vars === undefined
142
146
  ? [['default', undefined]]
143
- : Object.entries(options.themes)
144
- if (!themes.length)
147
+ : Object.entries(options.vars)
148
+ if (!vars.length)
145
149
  fail(
146
150
  'invalid_options',
147
- 'Supply at least one theme, or omit themes for a default table.',
148
- ['themes'],
151
+ 'Supply at least one set, or omit vars for a default table.',
152
+ ['vars'],
149
153
  )
150
154
 
151
155
  const tables: Record<
@@ -156,23 +160,19 @@ export function compile<
156
160
  const diagnostics: Diagnostic[] = []
157
161
  let independent: Readonly<Record<string, NativeStyle>> | undefined
158
162
 
159
- for (const [label, theme] of themes) {
163
+ for (const [label, set] of vars) {
160
164
  if (!label)
161
- fail('invalid_options', 'Theme labels must be nonempty.', [
162
- 'themes',
163
- label,
164
- ])
165
+ fail('invalid_options', 'Theme labels must be nonempty.', ['vars', label])
165
166
  const metadata =
166
- theme &&
167
- (Object.getOwnPropertyDescriptor(theme, Token.definition)?.value as
167
+ set &&
168
+ (Object.getOwnPropertyDescriptor(set, Token.definition)?.value as
168
169
  | Token.Metadata
169
170
  | undefined)
170
- if (options.themes !== undefined && !metadata)
171
- fail(
172
- 'invalid_options',
173
- 'Expected a Theme.define or Config theme handle.',
174
- ['themes', label],
175
- )
171
+ if (options.vars !== undefined && !metadata)
172
+ fail('invalid_options', 'Expected a Theme.define or Config set handle.', [
173
+ 'vars',
174
+ label,
175
+ ])
176
176
 
177
177
  const schemes = {} as Record<
178
178
  ColorScheme,
@@ -387,7 +387,9 @@ export declare namespace compile {
387
387
  /** Immutable shared definitions, also accepted by Css.compile. */
388
388
  readonly styles: Style.Definition<name>
389
389
  /** Explicit output labels. Omission creates the token-fallback default table. */
390
- readonly themes?: Readonly<Record<themeName, Theme.Definition>> | undefined
390
+ readonly vars?:
391
+ | Readonly<Record<themeName, Theme.Definition | Vars.Definition>>
392
+ | undefined
391
393
  /** Positive logical-unit scales. px defaults to one, rem has no default. */
392
394
  readonly units?:
393
395
  | { readonly px?: number | undefined; readonly rem?: number | undefined }
@@ -514,7 +516,7 @@ type Compiled<definition, platform, name extends string> =
514
516
 
515
517
  /** Optional native authoring constraint used with satisfies before Style.define. */
516
518
  export type Properties = {
517
- /** Portable literals or property-compatible scalar theme references. */
519
+ /** Portable literals or property-compatible scalar set references. */
518
520
  readonly [property in keyof typeof properties]?:
519
521
  | Atom<(typeof properties)[property]>
520
522
  | Reference<property>
@@ -522,7 +524,7 @@ export type Properties = {
522
524
 
523
525
  /**
524
526
  * Looks up an existing table without allocating or resolving device state.
525
- * @throws {SelectionError} For unknown own theme labels or color schemes.
527
+ * @throws {SelectionError} For unknown own set labels or color schemes.
526
528
  */
527
529
  export function select<const tables extends Tables>(
528
530
  styles: tables,
@@ -536,12 +538,12 @@ export function select<name extends string, themeName extends string>(
536
538
  !styles ||
537
539
  !options ||
538
540
  (options.colorScheme !== 'light' && options.colorScheme !== 'dark') ||
539
- !Object.hasOwn(styles, options.theme)
541
+ !Object.hasOwn(styles, options.set)
540
542
  )
541
543
  throw new SelectionError(
542
- 'Select an existing theme label and light or dark colorScheme.',
544
+ 'Select an existing set label and light or dark colorScheme.',
543
545
  )
544
- return styles[options.theme][options.colorScheme]
546
+ return styles[options.set][options.colorScheme]
545
547
  }
546
548
 
547
549
  /** Native lookup options. */
@@ -551,7 +553,7 @@ export declare namespace select {
551
553
  /** Precompiled color scheme. */
552
554
  readonly colorScheme: ColorScheme
553
555
  /** Own label in the compiled tables. */
554
- readonly theme: themeName
556
+ readonly set: themeName
555
557
  }
556
558
  }
557
559
 
@@ -771,23 +773,28 @@ function resolve(
771
773
  (metadata.contract === value.contract ||
772
774
  (metadata.contract[Token.identity] !== undefined &&
773
775
  metadata.contract[Token.identity] === value.contract[Token.identity]))
774
- const resolved = shared
776
+ let resolved = shared
775
777
  ? Object.hasOwn(metadata.values, value.path)
776
778
  ? metadata.values[value.path]
777
779
  : undefined
778
780
  : value.value
779
781
  if (resolved === undefined)
780
782
  fail('unsupported_value', 'Theme is missing a live token.', path)
781
- if (typeof resolved === 'object' && resolved.light !== resolved.dark)
782
- resolution.schemeIndependent = false
783
- const scalar = typeof resolved === 'object' ? resolved[scheme] : resolved
784
- if (typeof scalar !== 'string' && typeof scalar !== 'number')
785
- fail(
786
- 'unsupported_value',
787
- 'Expected a complete scalar color-scheme pair.',
788
- path,
789
- )
790
- return scalar
783
+ while (typeof resolved === 'object') {
784
+ if (Token.is(resolved)) {
785
+ resolved = resolved.value
786
+ continue
787
+ }
788
+ if ('default' in resolved)
789
+ fail(
790
+ 'unsupported_feature',
791
+ 'Media-conditioned variables require a web target.',
792
+ path,
793
+ )
794
+ if (resolved.light !== resolved.dark) resolution.schemeIndependent = false
795
+ resolved = resolved[scheme]
796
+ }
797
+ return resolved
791
798
  }
792
799
 
793
800
  type TransformValues = {
@@ -20,8 +20,8 @@ export type Definition<
20
20
 
21
21
  /**
22
22
  * Compiles every finite selection, including omitted axes, before application.
23
- * @param options - Static recipe, themes, and explicit native destination inputs.
24
- * @returns Immutable native tables with at most 256 selections per theme and scheme.
23
+ * @param options - Static recipe, vars, and explicit native destination inputs.
24
+ * @returns Immutable native tables with at most 256 selections per set and scheme.
25
25
  * @throws {CompileError} When recipe data is invalid or exceeds the selection budget.
26
26
  * @throws {StyleSheet.CompileError} When selected declarations cannot compile for native.
27
27
  */
@@ -108,7 +108,7 @@ export declare namespace compile {
108
108
  /** Validated static recipe retained by Source.extract. */
109
109
  readonly recipe: recipe
110
110
  }
111
- /** Immutable tables retaining recipe metadata and theme labels. */
111
+ /** Immutable tables retaining recipe metadata and set labels. */
112
112
  type ReturnType<
113
113
  recipe extends Recipe.Definition = Recipe.Definition,
114
114
  themeName extends string = string,
@@ -4,19 +4,19 @@ import * as NativeContext from '../runtime/NativeContext.js'
4
4
 
5
5
  const context = React.createContext(styles(undefined))
6
6
 
7
- /** Supplies theme and resolved device appearance to compiled native components. */
7
+ /** Supplies set and resolved device appearance to compiled native components. */
8
8
  export function Provider(props: Provider.Props) {
9
9
  if (
10
10
  (props.colorScheme !== 'light' && props.colorScheme !== 'dark') ||
11
- (props.theme !== undefined &&
12
- (typeof props.theme !== 'string' || !props.theme.trim()))
11
+ (props.set !== undefined &&
12
+ (typeof props.set !== 'string' || !props.set.trim()))
13
13
  )
14
14
  throw new Error(
15
- 'Native appearance requires a resolved light/dark scheme and a nonempty theme name.',
15
+ 'Native appearance requires a resolved light/dark scheme and a nonempty set name.',
16
16
  )
17
17
  const value = React.useMemo(
18
- () => styles({ colorScheme: props.colorScheme, theme: props.theme }),
19
- [props.colorScheme, props.theme],
18
+ () => styles({ colorScheme: props.colorScheme, set: props.set }),
19
+ [props.colorScheme, props.set],
20
20
  )
21
21
  return React.createElement(context.Provider, { value }, props.children)
22
22
  }
@@ -0,0 +1,5 @@
1
+ /** Exposes the Zyzz rollup build adapter. @module */
2
+ import { zyzz as unplugin } from '../unplugin/index.js'
3
+
4
+ /** Compiles project sources and emits `zyzz.css` into the bundler output directory. */
5
+ export const zyzz = unplugin.rollup
@@ -2,7 +2,7 @@
2
2
  import * as Scheme from '../internal/Scheme.js'
3
3
 
4
4
  /**
5
- * Binds an HTML-safe script factory to compiled named theme classes.
5
+ * Binds an HTML-safe script factory to compiled named set classes.
6
6
  * The factory is server-safe; only its returned JavaScript accesses the DOM.
7
7
  * A saved scheme swaps the stylesheet scheme class and sets the inline `color-scheme`;
8
8
  * a saved `null` scheme removes both so a cleared selection survives reloads.
@@ -19,7 +19,7 @@ export function create(
19
19
  const key = serialize(options.storageKey ?? 'zyzz')
20
20
  const schemes = serialize(Object.entries(Scheme.classes))
21
21
 
22
- return `(()=>{try{const value=JSON.parse(localStorage.getItem(${key})||"null");if(!value||typeof value!=="object"||Array.isArray(value))return;const root=document.documentElement;const catalog=new Map(${catalog});if(Object.hasOwn(value,"theme")&&typeof value.theme==="string"&&catalog.has(value.theme)){root.classList.remove(...catalog.values());root.classList.add(catalog.get(value.theme))}const schemes=new Map(${schemes});if(Object.hasOwn(value,"colorScheme")){if(value.colorScheme===null){root.classList.remove(...schemes.values());root.style.removeProperty("color-scheme")}else if(schemes.has(value.colorScheme)){root.classList.remove(...schemes.values());root.classList.add(schemes.get(value.colorScheme));root.style.colorScheme=value.colorScheme}}}catch{}})();`
22
+ return `(()=>{try{const value=JSON.parse(localStorage.getItem(${key})||"null");if(!value||typeof value!=="object"||Array.isArray(value))return;const root=document.documentElement;const catalog=new Map(${catalog});if(Object.hasOwn(value,"set")&&typeof value.set==="string"&&catalog.has(value.set)){root.classList.remove(...catalog.values());root.classList.add(catalog.get(value.set))}const schemes=new Map(${schemes});if(Object.hasOwn(value,"colorScheme")){if(value.colorScheme===null){root.classList.remove(...schemes.values());root.style.removeProperty("color-scheme")}else if(schemes.has(value.colorScheme)){root.classList.remove(...schemes.values());root.classList.add(schemes.get(value.colorScheme));root.style.colorScheme=value.colorScheme}}}catch{}})();`
23
23
  }
24
24
  }
25
25
 
@@ -33,11 +33,11 @@ export declare namespace create {
33
33
  }
34
34
 
35
35
  /**
36
- * Binds root selection controls to compiled named theme classes.
36
+ * Binds root selection controls to compiled named set classes.
37
37
  * Creation touches no browser state; `get` and `set` read and write
38
38
  * `document.documentElement` and the record the initialization script restores.
39
39
  * @param entries - Catalog names paired with compiled scope classes.
40
- * @param options - Default theme reported without a root class and the storage key.
40
+ * @param options - Default set reported without a root class and the storage key.
41
41
  * @returns Controls reading the applied root selection and applying saved changes.
42
42
  * @throws {TypeError} If a named catalog receives no default or one outside its entries.
43
43
  */
@@ -49,24 +49,24 @@ export function root<const name extends string>(
49
49
  const key = options.storageKey ?? 'zyzz'
50
50
  const schemes = Object.entries(Scheme.classes) as [Scheme.Name, string][]
51
51
 
52
- // Named catalogs always report a theme, so the fallback must be one of them.
52
+ // Named catalogs always report a set, so the fallback must be one of them.
53
53
  if (
54
54
  catalog.size &&
55
- (options.defaultTheme === undefined || !catalog.has(options.defaultTheme))
55
+ (options.defaultVars === undefined || !catalog.has(options.defaultVars))
56
56
  )
57
- throw new TypeError('defaultTheme must name a catalog theme.')
57
+ throw new TypeError('defaultVars must name a catalog set.')
58
58
 
59
59
  function get(): Selection<name> {
60
60
  const classes = document.documentElement.classList
61
- const theme =
61
+ const set =
62
62
  [...catalog].find(([, className]) => classes.contains(className))?.[0] ??
63
- options.defaultTheme
63
+ options.defaultVars
64
64
  const colorScheme = schemes.find(([, className]) =>
65
65
  classes.contains(className),
66
66
  )?.[0]
67
67
 
68
68
  return {
69
- ...(theme === undefined ? {} : { theme }),
69
+ ...(set === undefined ? {} : { set }),
70
70
  ...(colorScheme === undefined ? {} : { colorScheme }),
71
71
  } as Selection<name>
72
72
  }
@@ -75,20 +75,20 @@ export function root<const name extends string>(
75
75
  const element = document.documentElement
76
76
  const next = { ...get(), ...selection } as {
77
77
  colorScheme?: Scheme.Name | undefined
78
- theme?: string | undefined
78
+ set?: string | undefined
79
79
  }
80
80
  const scopeClass =
81
- next.theme === undefined ? undefined : catalog.get(next.theme)
81
+ next.set === undefined ? undefined : catalog.get(next.set)
82
82
 
83
83
  // Rejected input leaves the document and the saved record untouched.
84
- if (next.theme !== undefined && scopeClass === undefined)
85
- throw new TypeError('Invalid theme selection.')
84
+ if (next.set !== undefined && scopeClass === undefined)
85
+ throw new TypeError('Invalid set selection.')
86
86
 
87
87
  if (
88
88
  next.colorScheme !== undefined &&
89
89
  !Object.hasOwn(Scheme.classes, next.colorScheme)
90
90
  )
91
- throw new TypeError('Invalid theme selection.')
91
+ throw new TypeError('Invalid set selection.')
92
92
 
93
93
  element.classList.remove(
94
94
  ...catalog.values(),
@@ -105,7 +105,7 @@ export function root<const name extends string>(
105
105
  // The record mirrors the applied root, so a cleared scheme saves as null
106
106
  // and the script removes a server-rendered scheme on the next load.
107
107
  const record = {
108
- ...(next.theme === undefined ? {} : { theme: next.theme }),
108
+ ...(next.set === undefined ? {} : { set: next.set }),
109
109
  colorScheme: next.colorScheme ?? null,
110
110
  }
111
111
 
@@ -124,7 +124,7 @@ export declare namespace root {
124
124
  /** Catalog defaults and storage settings. */
125
125
  type Options<name extends string = string> = {
126
126
  /** Theme reported by `get` when the root carries no catalog class; required with a named catalog. */
127
- readonly defaultTheme?: NoInfer<name> | undefined
127
+ readonly defaultVars?: NoInfer<name> | undefined
128
128
  /** localStorage key shared with the initialization script; defaults to zyzz. */
129
129
  readonly storageKey?: string | undefined
130
130
  }
@@ -132,18 +132,18 @@ export declare namespace root {
132
132
 
133
133
  /** Live root selection controls. */
134
134
  export type Root<name extends string> = {
135
- /** Reads the theme and scheme classes the root carries. */
135
+ /** Reads the set and scheme classes the root carries. */
136
136
  readonly get: () => Selection<name>
137
137
  /** Applies fields over the current selection and saves the result. */
138
138
  readonly set: (selection: Partial<Selection<name>>) => void
139
139
  }
140
140
 
141
- /** A catalog theme with an optional scheme; an omitted scheme inherits. Token-free and single-theme configurations select only a scheme. */
141
+ /** A catalog set with an optional scheme; an omitted scheme inherits. Token-free and single-set configurations select only a scheme. */
142
142
  export type Selection<name extends string> = [name] extends [never]
143
143
  ? { readonly colorScheme?: Scheme.Name | undefined }
144
144
  : {
145
145
  readonly colorScheme?: Scheme.Name | undefined
146
- readonly theme: name
146
+ readonly set: name
147
147
  }
148
148
 
149
149
  function serialize(value: unknown): string {
@@ -15,7 +15,10 @@ export function create(
15
15
  return value === '' ? ' ' : value
16
16
  })
17
17
  const external = input.className
18
- const style = { ...input.variables, ...input.style }
18
+ const style: Record<string, string | number | undefined> = {
19
+ ...input.vars,
20
+ ...input.style,
21
+ }
19
22
 
20
23
  for (let index = 0; index < slots.length; index++)
21
24
  style[slots[index]![1].name] = values[index]!
@@ -3,12 +3,12 @@ import type * as Native from './Native.js'
3
3
 
4
4
  const binding = Symbol('zyzz.native.context')
5
5
 
6
- /** Render-local theme and resolved appearance. */
6
+ /** Render-local set and resolved appearance. */
7
7
  export type Context = {
8
8
  /** Resolved system appearance or an explicit override. */
9
9
  readonly colorScheme: 'dark' | 'light'
10
- /** Named compiled theme; omission uses each configuration default. */
11
- readonly theme?: string | undefined
10
+ /** Named compiled set; omission uses each configuration default. */
11
+ readonly set?: string | undefined
12
12
  }
13
13
 
14
14
  type Callable = (input: never) => Native.Props<object>
@@ -19,17 +19,17 @@ type Tables = Readonly<
19
19
  /** Retains compiled alternatives without selecting a device context at module evaluation. */
20
20
  export function create<const tables extends Tables>(
21
21
  tables: tables,
22
- defaultTheme: keyof tables & string,
22
+ defaultVars: keyof tables & string,
23
23
  ): tables[keyof tables]['light'] {
24
24
  const fallback =
25
- Object.keys(tables).length === 1 && defaultTheme === 'default'
25
+ Object.keys(tables).length === 1 && defaultVars === 'default'
26
26
  ? tables.default
27
27
  : undefined
28
28
 
29
29
  function select(context: Context, input?: never) {
30
- const theme = context.theme ?? defaultTheme
31
- const table = tables[theme] ?? fallback
32
- if (!table) throw new Error(`Unknown native theme: ${theme}.`)
30
+ const set = context.set ?? defaultVars
31
+ const table = tables[set] ?? fallback
32
+ if (!table) throw new Error(`Unknown native set: ${set}.`)
33
33
  return table[context.colorScheme](input!).style
34
34
  }
35
35
  function props(input?: never) {
@@ -27,10 +27,8 @@ export type RecipeCallable<input> = <
27
27
  /** Adapts a published web callable's payload to native styling overrides. */
28
28
  export type From<fn> = fn extends (...args: infer args) => unknown
29
29
  ? [] extends args
30
- ? RecipeCallable<
31
- Omit<NonNullable<args[0]>, 'style' | 'className' | 'variables'>
32
- >
33
- : Callable<Omit<NonNullable<args[0]>, 'style' | 'className' | 'variables'>>
30
+ ? RecipeCallable<Omit<NonNullable<args[0]>, 'style' | 'className' | 'vars'>>
31
+ : Callable<Omit<NonNullable<args[0]>, 'style' | 'className' | 'vars'>>
34
32
  : never
35
33
 
36
34
  /** Ordered static and dynamic assignments selected by finite recipe choices. */
@@ -8,14 +8,14 @@ import type { style } from '../styleFunction.js'
8
8
  * Binds compiled classes to the web styling override contract.
9
9
  * Returns fresh props; without variable assignments, inline styles retain their identity.
10
10
  * Never generates rules or changes the supplied overrides.
11
- * @returns A callable accepting className, style, and variables.
11
+ * @returns A callable accepting className, style, and vars.
12
12
  */
13
13
  export function create({ className }: create.Options): style.ReturnType {
14
14
  return ((overrides?: style.Options) => {
15
15
  if (!overrides) return { className }
16
16
 
17
- const { className: external, style, variables } = overrides
18
- const inline = variables ? { ...variables, ...style } : style
17
+ const { className: external, style, vars } = overrides
18
+ const inline = vars ? { ...vars, ...style } : style
19
19
  const merged =
20
20
  className && external ? `${className} ${external}` : external || className
21
21