@tenphi/tasty 0.0.0-snapshot.047dfbb → 0.0.0-snapshot.05197cf

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 (121) hide show
  1. package/README.md +181 -136
  2. package/dist/babel-C5mN2_fA.d.ts +83 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-Tkr_Z48w.js +42 -0
  6. package/dist/chunks/build-config-Tkr_Z48w.js.map +1 -0
  7. package/dist/{collector-J6LwZR0N.js → chunks/collector-BG-HTHSz.js} +64 -99
  8. package/dist/chunks/collector-BG-HTHSz.js.map +1 -0
  9. package/dist/chunks/config-engine-B9pEqzzU.js +267 -0
  10. package/dist/chunks/config-engine-B9pEqzzU.js.map +1 -0
  11. package/dist/chunks/css-definitions-BAtJQ_tP.js +875 -0
  12. package/dist/chunks/css-definitions-BAtJQ_tP.js.map +1 -0
  13. package/dist/chunks/css-resources-BN8apgxt.js +142 -0
  14. package/dist/chunks/css-resources-BN8apgxt.js.map +1 -0
  15. package/dist/chunks/debug-B7TmqIlz.js +501 -0
  16. package/dist/chunks/debug-B7TmqIlz.js.map +1 -0
  17. package/dist/chunks/dsl-C5yuAn41.js +1373 -0
  18. package/dist/chunks/dsl-C5yuAn41.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-5owaaB5Y.js +557 -0
  22. package/dist/chunks/react-runtime-5owaaB5Y.js.map +1 -0
  23. package/dist/chunks/runtime-engine-B3JcRKeS.js +2438 -0
  24. package/dist/chunks/runtime-engine-B3JcRKeS.js.map +1 -0
  25. package/dist/chunks/runtime-state-DDnx6lOJ.js +127 -0
  26. package/dist/chunks/runtime-state-DDnx6lOJ.js.map +1 -0
  27. package/dist/{merge-styles-CAdKaHxh.js → chunks/shared-utils-DWA4LjIa.js} +55 -54
  28. package/dist/chunks/shared-utils-DWA4LjIa.js.map +1 -0
  29. package/dist/chunks/style-engine-CnQoWtc_.js +5202 -0
  30. package/dist/chunks/style-engine-CnQoWtc_.js.map +1 -0
  31. package/dist/{css-writer-IC7tdnIf.js → chunks/zero-engine-B36DCc0X.js} +34 -112
  32. package/dist/chunks/zero-engine-B36DCc0X.js.map +1 -0
  33. package/dist/{collector-CddJZDOr.d.ts → collector-CViSMO84.d.ts} +64 -7
  34. package/dist/{config-C3SKYuxY.d.ts → config-CbDtZzZy.d.ts} +491 -78
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-ByBYTH9l.d.ts → index-CmrdZ8ay.d.ts} +421 -252
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -732
  40. package/dist/{merge-styles-CvUi7SOD.d.ts → merge-styles-Dp3eKkK9.d.ts} +2 -2
  41. package/dist/ssr/astro-client.js +1 -14
  42. package/dist/ssr/astro-client.js.map +1 -1
  43. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  44. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  45. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  46. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  47. package/dist/ssr/astro-middleware-extract.js +9 -0
  48. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  49. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  50. package/dist/ssr/astro-middleware-static.js +7 -0
  51. package/dist/ssr/astro-middleware-static.js.map +1 -0
  52. package/dist/ssr/astro-middleware.d.ts +11 -7
  53. package/dist/ssr/astro-middleware.js +2 -14
  54. package/dist/ssr/astro-middleware.js.map +1 -1
  55. package/dist/ssr/astro.d.ts +45 -7
  56. package/dist/ssr/astro.js +159 -86
  57. package/dist/ssr/astro.js.map +1 -1
  58. package/dist/ssr/index.d.ts +7 -14
  59. package/dist/ssr/index.js +5 -5
  60. package/dist/ssr/index.js.map +1 -1
  61. package/dist/ssr/next-config.d.ts +66 -0
  62. package/dist/ssr/next-config.js +124 -0
  63. package/dist/ssr/next-config.js.map +1 -0
  64. package/dist/ssr/next.d.ts +9 -2
  65. package/dist/ssr/next.js +27 -43
  66. package/dist/ssr/next.js.map +1 -1
  67. package/dist/static/index.d.ts +2 -2
  68. package/dist/static/index.js +4 -22
  69. package/dist/static/index.js.map +1 -1
  70. package/dist/{index-C5owZ15q.d.ts → types-Ji9PGExW.d.ts} +873 -546
  71. package/dist/zero/babel.d.ts +2 -80
  72. package/dist/zero/babel.js +42 -109
  73. package/dist/zero/babel.js.map +1 -1
  74. package/dist/zero/index.d.ts +16 -2
  75. package/dist/zero/index.js +2 -2
  76. package/dist/zero/next.d.ts +1 -1
  77. package/dist/zero/next.js +0 -31
  78. package/dist/zero/next.js.map +1 -1
  79. package/docs/README.md +17 -9
  80. package/docs/adoption.md +56 -31
  81. package/docs/ai-agents.md +250 -0
  82. package/docs/comparison.md +69 -40
  83. package/docs/configuration.md +486 -85
  84. package/docs/debug.md +26 -14
  85. package/docs/design-system.md +43 -24
  86. package/docs/dsl.md +455 -189
  87. package/docs/getting-started.md +64 -41
  88. package/docs/injector.md +120 -30
  89. package/docs/methodology.md +46 -40
  90. package/docs/migration-v3.md +285 -0
  91. package/docs/pipeline.md +36 -15
  92. package/docs/plugins.md +353 -0
  93. package/docs/react-api.md +142 -42
  94. package/docs/runtime-benchmarks.md +388 -0
  95. package/docs/ssr.md +252 -86
  96. package/docs/styles.md +126 -24
  97. package/docs/tasty-static.md +141 -106
  98. package/package.json +103 -20
  99. package/tasty.config.ts +4 -0
  100. package/dist/async-storage-DKK-wTD4.js +0 -44
  101. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  102. package/dist/collector-J6LwZR0N.js.map +0 -1
  103. package/dist/config-C3F4Ogo1.js +0 -10993
  104. package/dist/config-C3F4Ogo1.js.map +0 -1
  105. package/dist/context-CA8YKeMn.js +0 -24
  106. package/dist/context-CA8YKeMn.js.map +0 -1
  107. package/dist/core-DxHmF6S9.js +0 -1598
  108. package/dist/core-DxHmF6S9.js.map +0 -1
  109. package/dist/css-writer-IC7tdnIf.js.map +0 -1
  110. package/dist/format-global-rules-DklyaXv-.js +0 -22
  111. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  112. package/dist/format-rules-DTLY39Hm.js +0 -143
  113. package/dist/format-rules-DTLY39Hm.js.map +0 -1
  114. package/dist/hydrate-8Zglgy_C.js +0 -45
  115. package/dist/hydrate-8Zglgy_C.js.map +0 -1
  116. package/dist/index.js.map +0 -1
  117. package/dist/keyframes-DgGkipNK.js +0 -595
  118. package/dist/keyframes-DgGkipNK.js.map +0 -1
  119. package/dist/merge-styles-CAdKaHxh.js.map +0 -1
  120. package/dist/resolve-recipes-BQNdunBd.js +0 -144
  121. package/dist/resolve-recipes-BQNdunBd.js.map +0 -1
@@ -1,6 +1,8 @@
1
1
  # Configuration
2
2
 
3
- Configure the Tasty style system before your app renders using the `configure()` function. Configuration must be done **before any styles are generated** (before first render). For a higher-level docs map, see the [Docs Hub](README.md).
3
+ Tasty works without upfront configuration. Use `configure()` when your app or design system is ready to define shared tokens, state aliases, units, recipes, presets, or extension points.
4
+
5
+ Call it **before any styles are generated** (before first render). For a guided setup, see [Getting Started](getting-started.md). For the higher-level docs map, see the [Docs Hub](README.md).
4
6
 
5
7
  ```jsx
6
8
  import { configure } from '@tenphi/tasty';
@@ -26,12 +28,15 @@ configure({
26
28
  custom: (n) => `${n * 10}px`, // Function-based unit
27
29
  },
28
30
 
29
- // Custom functions for the parser
30
- funcs: {
31
+ // Custom functions — a single map for both flavors, discriminated by value type:
32
+ functions: {
33
+ // Bare key + function value → parse-time function, called as `double(...)`
31
34
  double: (groups) => {
32
35
  const value = parseFloat(groups[0]?.output || '0');
33
36
  return `${value * 2}px`;
34
37
  },
38
+ // `$$name` key + object value → declarative CSS @function, called as `$$negative(...)`
39
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
35
40
  },
36
41
  });
37
42
  ```
@@ -42,52 +47,244 @@ These docs use `data-schema="dark"` in examples. If your app already standardize
42
47
 
43
48
  ## Options
44
49
 
45
- | Option | Type | Default | Description |
46
- |--------|------|---------|-------------|
47
- | `nonce` | `string` | - | CSP nonce for style elements |
48
- | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
49
- | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
50
- | `units` | `Record<string, string \| Function>` | Built-in | Custom units (merged with built-in). See [built-in units](dsl.md#built-in-units) |
51
- | `funcs` | `Record<string, Function>` | - | Custom parser functions (merged with existing) |
52
- | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in) |
53
- | `tokens` | `Record<string, value \| stateMap>` | - | Design tokens injected as `:root` CSS custom properties |
54
- | `replaceTokens` | `Record<string, string \| number>` | - | Parse-time token substitution (inline replacement) |
55
- | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
56
- | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
57
- | `fontFace` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
58
- | `counterStyle` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
59
- | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
60
- | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
61
- | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
62
- | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
63
- | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | `'oklch'` | Color space for decomposed color token companion variables |
64
- | `namePrefix` | `string` | `'t'` (runtime) / `'ts'` (zero-runtime) | Prefix prepended to every generated identifier (class, keyframe, counter-style names). See [Name prefix](#name-prefix). |
50
+ | Option | Type | Default | Description |
51
+ | -------------------- | ------------------------------------------------ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | `nonce` | `string` | - | CSP nonce for style elements |
53
+ | `maxRulesPerSheet` | `number` | `8192` | Maximum rules per injected stylesheet |
54
+ | `forceTextInjection` | `boolean` | auto (`true` in test envs) | Force text-node CSS injection instead of constructable stylesheets |
55
+ | `devMode` | `boolean` | auto | Enable development-mode features: performance metrics and debug info |
56
+ | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
57
+ | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
58
+ | `units` | `Record<string, string \| UnitHandler>` | Built-in | Custom units (merged with built-in). See [built-in units](dsl.md#built-in-units) |
59
+ | `functions` | `Record<string, FunctionDefinition \| Function>` | - | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
60
+ | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in). See [Custom Style Handlers](#custom-style-handlers) |
61
+ | `propHandlers` | `Record<string, PropHandlerDefinition>` | - | Props middleware for every component — props in, props out. See [Props Middleware](#props-middleware) |
62
+ | `baseStyleProps` | `readonly string[]` | - | Style names exposed as props on **every** component. See [Base Style Props](#base-style-props) |
63
+ | `tokens` | `Record<string, value \| stateMap>` | - | Design tokens injected as `:root` CSS custom properties |
64
+ | `replaceTokens` | `Record<string, string \| number \| boolean>` | - | Parse-time token substitution (inline replacement). `boolean` is allowed for `#` color tokens |
65
+ | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
66
+ | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
67
+ | `fontFaces` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
68
+ | `counterStyles` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
69
+ | `polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills for not-yet-baseline features. `functions: true` inlines `@function` calls into plain CSS at parse time |
70
+ | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
71
+ | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
72
+ | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
73
+ | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
74
+ | `plugins` | `TastyPlugin[]` | - | Plugins that bundle any of the above (processed in order; later override earlier, and direct config wins over all). See [Plugins](plugins.md) |
75
+ | `gc` | `GCConfig` | - | Garbage-collection tuning for unused styles (`{ touchInterval, capacity }`) |
76
+ | `batchInjection` | `boolean \| 'always'` | `false` | Defer stylesheet writes and apply them in one batch. See [Batched injection](#batched-injection) |
77
+ | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | - | **Deprecated** — no longer has any effect. See [Color space](#color-space) |
78
+ | `namePrefix` | `string` | `'t'` (`tasty`) / `'ts'` (build-time) | Prefix prepended to every generated identifier (class, keyframe, counter-style names). Must match `^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$`. See [Name prefix](#name-prefix). |
79
+
80
+ ---
81
+
82
+ ## Batched Injection
83
+
84
+ Every `insertRule()` on a live stylesheet invalidates style for that sheet's
85
+ scope. Components inject during React's render phase, and if anything else reads
86
+ layout in the same pass, the two interleave:
87
+
88
+ ```
89
+ inject -> read (forced style recalc) -> inject -> read (forced recalc) -> ...
90
+ ```
91
+
92
+ A UI kit that measures during render — popovers, autosizing inputs, virtualized
93
+ lists — can turn one mount into a dozen full-tree recalculations. `batchInjection`
94
+ queues the writes instead and applies them together, so the tree is invalidated
95
+ once per flush.
96
+
97
+ ```tsx
98
+ import { configure, TastyBatchProvider } from '@tenphi/tasty';
99
+
100
+ configure({ batchInjection: true });
101
+
102
+ createRoot(el).render(
103
+ <TastyBatchProvider>
104
+ <App />
105
+ </TastyBatchProvider>,
106
+ );
107
+ ```
108
+
109
+ ### Why the provider is required
110
+
111
+ Deferring a write past React's layout phase would let a `useLayoutEffect`
112
+ measure an element whose rules are not in the sheet yet and read its _unstyled_
113
+ box — a wrong number, not a stale one, so it never self-corrects.
114
+
115
+ `TastyBatchProvider` closes that hole. It opens a _batch window_ during its
116
+ render and closes it — flushing — in `useInsertionEffect`, which React runs in
117
+ the mutation phase, before any layout effect:
118
+
119
+ ```
120
+ provider renders -> window OPEN
121
+ children render -> injections queued
122
+ provider insertionEffect -> FLUSH, window CLOSED
123
+ layout effects run -> rules are in the sheet
124
+ ```
125
+
126
+ With `batchInjection: true` a write is only ever queued inside such a window, so
127
+ turning the flag on can make injection cheaper but can never make a measurement
128
+ wrong. Injections outside a window are written straight through, exactly as with
129
+ batching off:
130
+
131
+ - a deep update that did not re-render the provider
132
+ - an injection from a layout effect, an event handler or an async callback
133
+ - SSR and RSC, where there is no live sheet at all
134
+
135
+ Mount the provider as high in the tree as you can: batching applies to the
136
+ commits it takes part in.
137
+
138
+ ### Modes
139
+
140
+ | Value | Behaviour |
141
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
142
+ | `false` (default) | One `insertRule()` per component, synchronously. |
143
+ | `true` | Batch inside a provider window only. Cannot affect measurement. Without the provider nothing is batched, and dev mode says so once. |
144
+ | `'always'` | Batch every injection, flushing on a microtask when no window is open. Covers more commits; a `useLayoutEffect` measuring a freshly mounted element can read its unstyled box. Paint is unaffected — microtasks always drain before the browser paints. |
145
+
146
+ ### Ordering
147
+
148
+ All writes share one FIFO queue — component rules, global rules, raw CSS,
149
+ `@property`, `@keyframes`, `@font-face`, `@counter-style` and `@function`.
150
+ Draining it in insertion order keeps the sheet byte-identical to unbatched
151
+ output, which matters because equal-specificity rules resolve by document order.
152
+
153
+ ### Client rendering, server rendering, and build-time extraction
154
+
155
+ **Server render — nothing to batch, safe to leave enabled.** SSR and RSC collect
156
+ CSS as text through `ServerStyleCollector`; the runtime injector never runs
157
+ there, so `batchInjection` changes nothing either way. `<TastyBatchProvider>`
158
+ renders its children and does nothing else: the window it opens is a no-op
159
+ without a `document`, and the `useInsertionEffect` that would close it never
160
+ fires on the server. Configure the flag once in shared code — no environment
161
+ branching needed.
162
+
163
+ **Hydration — the better your SSR coverage, the less there is to batch.**
164
+ `hydrateTastyClasses()` (wired up for you by `@tenphi/tasty/ssr/next` and the
165
+ Astro integration) pre-populates the injector from `window.__TASTY__`, so
166
+ hydrating a server-rendered class is a cache hit that produces no sheet write at
167
+ all. Batching pays off on what SSR could not cover: client-only routes, styles
168
+ that first appear after hydration (a `styles` prop that changes on interaction, a
169
+ modal or popover mounting), and dynamic tokens.
170
+
171
+ **Astro islands — one provider per island, or `'always'`.** Every island is its
172
+ own React root, so a provider inside one island does not open a window for
173
+ another. With `batchInjection: true`, wrap each island root that renders enough
174
+ tasty components to be worth it. `'always'` needs no provider and covers every
175
+ island, at the cost of the measurement hazard above. Either way, an island that
176
+ only re-hydrates server-rendered classes has nothing to batch.
177
+
178
+ **Build-time extraction (`tastyStatic`) — unaffected.** The Babel plugin never
179
+ touches the injector: the babel plugin emits either a CSS file import or an
180
+ `injectCSS()` call from `@tenphi/tasty/static/inject`, which appends text to a
181
+ single `<style data-tasty-static>` element. `batchInjection` only defers CSSOM
182
+ writes made by the browser injector, so extracted styles are unchanged. In an app
183
+ that mixes both, it still applies to the `tasty()` half.
184
+
185
+ ### `flushStyles()`
186
+
187
+ Applies every pending write immediately. Every injector read API calls it for
188
+ you — `getCSSText`, `getCSSTextForClasses`, `getCSSTextForNode`,
189
+ `getRawCSSText`, `isPropertyDefined`, `getMetrics`, `cleanup`, `gc` and
190
+ `destroy` — so a read never observes a partial sheet.
191
+ Call it directly before measuring in code that runs outside a batch window under
192
+ `'always'`:
193
+
194
+ ```tsx
195
+ import { flushStyles } from '@tenphi/tasty';
196
+
197
+ useLayoutEffect(() => {
198
+ flushStyles();
199
+ const { width } = ref.current.getBoundingClientRect();
200
+ }, []);
201
+ ```
202
+
203
+ `hasPendingStyleWrites()` reports whether anything is queued, and
204
+ `resetStyleBatch()` drops the queue without applying it (tests only).
65
205
 
66
206
  ---
67
207
 
68
208
  ## Color Space
69
209
 
70
- Controls the CSS color space used for decomposed color token companion variables. When you define `#name` color tokens, tasty generates both `--name-color` (full color) and `--name-color-{suffix}` (decomposed components for alpha composition).
210
+ > **Deprecated.** `configure({ colorSpace })` no longer has any effect and will
211
+ > be removed in the next major. Setting it warns in development.
212
+
213
+ A `#name` token's value used to be rewritten into a configured color space, so
214
+ `#brand: '#ff8800'` declared `--brand-color: oklch(0.75 0.16 55)`. That existed
215
+ to serve the opacity suffix, which needed numeric channels to write an alpha
216
+ into. Opacity now uses CSS relative color syntax —
217
+ `oklch(from var(--brand-color) l c h / .5)` — which has the browser read the
218
+ channels, so there is nothing left for the setting to decide.
219
+
220
+ A color is emitted exactly as authored:
71
221
 
72
222
  ```jsx
73
- configure({
74
- colorSpace: 'oklch', // default
75
- });
223
+ configure({ tokens: { '#brand': '#ff8800' } });
224
+ // → --brand-color: #ff8800
76
225
  ```
77
226
 
78
- | Color Space | Suffix | Components Format | Alpha Syntax |
79
- |---|---|---|---|
80
- | `rgb` | `-rgb` | `255 128 0` | `rgb(var(--name-color-rgb) / .5)` |
81
- | `hsl` | `-hsl` | `300 100% 25%` | `hsl(var(--name-color-hsl) / .5)` |
82
- | `oklch` | `-oklch` | `0.42 0.16 328` | `oklch(var(--name-color-oklch) / .5)` |
227
+ That holds for every form: a hex literal, a native color function, a bare CSS
228
+ color name, a `color-mix()`, a `light-dark()`, a fallback chain. A `#token`
229
+ reference still resolves to its `var()` chain, and a plugin color function such
230
+ as `okhsl()` is still resolved by the parser to the color it denotes.
83
231
 
84
- The `oklch` color space is the default because it provides perceptually uniform color manipulation — alpha fading and color mixing produce more natural-looking results.
232
+ To address a token's channels, use relative color syntax against the token:
233
+
234
+ ```css
235
+ background: oklch(from var(--brand-color) calc(l * 1.2) c h);
236
+ ```
237
+
238
+ This works on any `<color>`, including the ones no build-time conversion could
239
+ have evaluated — and it is what the [opacity suffix](dsl.md#color-tokens--opacity)
240
+ itself uses. Its space is always `oklch`, which is unbounded, so a wide-gamut
241
+ color survives a round trip a narrower space would clamp.
242
+
243
+ ### Migrating off `colorSpace`
244
+
245
+ Drop the option. If you relied on the uniform output format, nothing in Tasty
246
+ needs it — author your tokens in the space you want them emitted in, since the
247
+ value now passes through untouched:
248
+
249
+ ```jsx
250
+ // before: any input, normalized to the configured space on the way out
251
+ configure({ colorSpace: 'oklch', tokens: { '#brand': '#ff8800' } });
252
+
253
+ // after: author it in the space you want
254
+ configure({ tokens: { '#brand': 'oklch(0.75 0.16 55)' } });
255
+ ```
256
+
257
+ ### Migrating off the channel companions
258
+
259
+ A `#name` token used to declare a second variable beside `--name-color` holding
260
+ its channels decomposed, suffixed with the configured space —
261
+ `--brand-color-oklch: 0.75 0.16 55` — and a `color` style emitted
262
+ `--current-color-{space}` beside `--current-color`. Both are gone, for the same
263
+ reason: they existed so an opacity suffix had channels to write an alpha into.
264
+
265
+ These were never part of the public API, but they were visible in the emitted
266
+ CSS, so hand-authored CSS may reference one. Address the token itself instead:
267
+
268
+ ```css
269
+ /* before */
270
+ color: oklch(var(--brand-color-oklch) / 0.5);
271
+ background: oklch(var(--brand-color-oklch));
272
+
273
+ /* after */
274
+ color: oklch(from var(--brand-color) l c h / 0.5);
275
+ background: var(--brand-color);
276
+ ```
277
+
278
+ The replacement is strictly more capable — the companion could only be
279
+ decomposed for a color the engine could evaluate at build time, while relative
280
+ color syntax works on every `<color>`, including a `color-mix()`, a
281
+ `light-dark()`, and a variable Tasty never defined.
85
282
 
86
283
  ---
87
284
 
88
285
  ## Name Prefix
89
286
 
90
- Every identifier Tasty generates — class names, keyframe names, counter-style names — starts with a configurable prefix. The runtime, SSR, and RSC paths default to `'t'`; the zero-runtime build path (`tastyStatic` via the Babel plugin) defaults to `'ts'` so static-extracted classes can never collide with runtime classes when both are loaded on the same page.
287
+ Every identifier Tasty generates — class names, keyframe names, counter-style names — starts with a configurable prefix. The `tasty()` client, SSR, and RSC paths default to `'t'`; the build-time extraction path (`tastyStatic` via the Babel plugin) defaults to `'ts'` so extracted classes can never collide with `tasty()` classes when both are loaded on the same page.
91
288
 
92
289
  ```jsx
93
290
  configure({
@@ -97,12 +294,12 @@ configure({
97
294
 
98
295
  The prefix is prepended verbatim to the hash, so include any separator inside the prefix string itself:
99
296
 
100
- | Setting | Class | Keyframe | Counter-style |
101
- |---|---|---|---|
102
- | `'t'` (runtime default) | `t1a2b3` | `tk1a2b3` | `tc1a2b3` |
103
- | `'ts'` (zero-runtime default) | `ts1a2b3` | `tsk1a2b3` | `tsc1a2b3` |
104
- | `'mb'` | `mb1a2b3` | `mbk1a2b3` | `mbc1a2b3` |
105
- | `'myapp-'` | `myapp-1a2b3` | `myapp-k1a2b3` | `myapp-c1a2b3` |
297
+ | Setting | Class | Keyframe | Counter-style |
298
+ | --------------------------- | ------------- | -------------- | -------------- |
299
+ | `'t'` (`tasty` default) | `t1a2b3` | `tk1a2b3` | `tc1a2b3` |
300
+ | `'ts'` (build-time default) | `ts1a2b3` | `tsk1a2b3` | `tsc1a2b3` |
301
+ | `'mb'` | `mb1a2b3` | `mbk1a2b3` | `mbc1a2b3` |
302
+ | `'myapp-'` | `myapp-1a2b3` | `myapp-k1a2b3` | `myapp-c1a2b3` |
106
303
 
107
304
  The single-letter discriminators (`k` for keyframes, `c` for counter-styles) keep the three kinds visually distinct in devtools — they are not required for correctness because CSS keeps these in separate namespaces.
108
305
 
@@ -112,12 +309,12 @@ The single-letter discriminators (`k` for keyframes, `c` for counter-styles) kee
112
309
  - Validated at `configure()` time; an invalid prefix throws synchronously rather than silently producing broken hydration.
113
310
  - Locked once styles have been generated, like all other config.
114
311
 
115
- ### Coexistence with the zero-runtime build
312
+ ### Coexistence with build-time extraction
116
313
 
117
- The runtime and zero-runtime builds **must use different prefixes** when both are loaded on the same page. Defaults already guarantee this; if you customize one, customize the other accordingly:
314
+ The `tasty()` and `tastyStatic()` paths **must use different prefixes** when both are loaded on the same page. Defaults already guarantee this; if you customize one, customize the other accordingly:
118
315
 
119
316
  ```jsx
120
- // app config (runtime / SSR / RSC)
317
+ // app config (client / SSR / RSC)
121
318
  configure({ namePrefix: 'mb' });
122
319
 
123
320
  // tasty-zero.config.ts (Babel plugin)
@@ -137,8 +334,8 @@ Tokens support state maps for responsive or theme-aware values:
137
334
  ```jsx
138
335
  configure({
139
336
  tokens: {
140
- '$gap': '4px',
141
- '$radius': '6px',
337
+ $gap: '4px',
338
+ $radius: '6px',
142
339
  '#primary': {
143
340
  '': '#purple',
144
341
  '@dark': '#light-purple',
@@ -152,9 +349,10 @@ configure({
152
349
  ```
153
350
 
154
351
  - `$name` keys become `--name` CSS custom properties
155
- - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties (suffix depends on `colorSpace`, default `oklch`)
352
+ - `#name` keys become `--name-color` custom properties
353
+ - Names keep their case, since CSS custom properties are case-sensitive: `$myVar` is `--myVar` and is referenced as `$myVar`. A leading capital is not supported and folds — `$Foo` and `#Purple` become `--foo` and `--purple-color` — so start names lowercase. Kebab-case (`$my-var`) remains the convention.
156
354
 
157
- Tokens are automatically emitted in all rendering modes: runtime (client), SSR, and zero-runtime (Babel plugin).
355
+ Tokens are automatically emitted in all delivery modes: client rendering, server rendering, and build-time extraction with the Babel plugin.
158
356
 
159
357
  ---
160
358
 
@@ -187,7 +385,7 @@ Register custom fonts globally so every component can reference them by family n
187
385
 
188
386
  ```ts
189
387
  configure({
190
- fontFace: {
388
+ fontFaces: {
191
389
  'Brand Sans': [
192
390
  {
193
391
  src: 'url("/fonts/brand-regular.woff2") format("woff2")',
@@ -208,9 +406,9 @@ configure({
208
406
  });
209
407
  ```
210
408
 
211
- Now any component can use `fontFamily: '"Brand Sans", sans-serif'` and the browser will already have the `@font-face` rules in the stylesheet.
409
+ Now any component can use `font: '"Brand Sans", sans-serif'` and the browser will already have the `@font-face` rules in the stylesheet.
212
410
 
213
- See [Font Face (`@fontFace`)](dsl.md#font-face-fontface) for inline usage inside component styles and the full list of supported descriptors.
411
+ See [Font Face (`@font-face`)](dsl.md#font-face-font-face) for inline usage inside component styles and the full list of supported descriptors.
214
412
 
215
413
  ---
216
414
 
@@ -220,7 +418,7 @@ Define custom list-marker algorithms globally. Rules are injected eagerly when s
220
418
 
221
419
  ```ts
222
420
  configure({
223
- counterStyle: {
421
+ counterStyles: {
224
422
  thumbs: {
225
423
  system: 'cyclic',
226
424
  symbols: '"👍"',
@@ -236,7 +434,98 @@ configure({
236
434
 
237
435
  Components can then reference `listStyleType: 'thumbs'` directly.
238
436
 
239
- See [Counter Style (`@counterStyle`)](dsl.md#counter-style-counterstyle) for inline usage inside component styles and the full list of supported descriptors.
437
+ See [Counter Style (`@counter-style`)](dsl.md#counter-style-counter-style) for inline usage inside component styles and the full list of supported descriptors.
438
+
439
+ ---
440
+
441
+ ## Functions
442
+
443
+ The single `functions` map holds both kinds of custom functions, discriminated by the value type:
444
+
445
+ - **Parse functions** — a **bare key** with a **function value** `(groups) => string`. Runs at parse time and is called as `name(...)`. Use these for computed/derived CSS that JavaScript produces (e.g. color-space conversions).
446
+ - **CSS `@function` definitions** — a **`$$name` key** with an **object value** (a [`FunctionDefinition`](https://developer.mozilla.org/en-US/docs/Web/CSS/@function)). Injected eagerly as a native `@function` rule and called as `$$name(...)` (→ `--name(...)`).
447
+
448
+ ```ts
449
+ configure({
450
+ functions: {
451
+ // Parse function — bare key, function value
452
+ double: (groups) => `calc(2 * ${groups[0]?.output ?? '0'})`,
453
+
454
+ // CSS @function — `$$` key, object value
455
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
456
+ $$shadow: {
457
+ args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
458
+ returns: '<color>',
459
+ $offset: '2px',
460
+ result: '$offset $offset ($shadow-color, black)',
461
+ },
462
+ },
463
+ });
464
+ ```
465
+
466
+ Components then invoke parse functions as `double(...)` and CSS functions with the `$$name(...)` sugar, e.g. `margin: '$$negative(10px) top'`.
467
+
468
+ > A key whose prefix doesn't match its value type (an object under a bare key, or a function under a `$$` key) is **ignored with a dev-mode warning**.
469
+
470
+ See [Functions (`@function`)](dsl.md#functions-function) for inline usage inside component styles, the full descriptor shape, and token conventions. `@function` is an experimental CSS feature — unsupported browsers safely ignore the native rule (see the polyfill below).
471
+
472
+ ### Custom color functions
473
+
474
+ A parse function whose output is an already-supported color (`rgb`, `hsl`, `#…`, `oklch`, …) is treated as a **color function**: it works everywhere a color is accepted — style values, `#token.alpha` opacity injection, and `parseColor` — with no extra registration. This is the same mechanism the built-in `okhsl`/`okhst` plugins use; they are ordinary plugins registered by default.
475
+
476
+ ```ts
477
+ import { configure, createColorFunc } from '@tenphi/tasty';
478
+
479
+ // A custom color space is just a `functions` entry.
480
+ const myColorPlugin = () => ({
481
+ name: 'mycolor',
482
+ functions: {
483
+ // Hand-written parse function:
484
+ mycolor: (groups) => {
485
+ const [r, g, b] = groups[0].all;
486
+ return `rgb(${r} ${g} ${b})`;
487
+ },
488
+ },
489
+ });
490
+
491
+ configure({ plugins: [myColorPlugin()] });
492
+
493
+ // Now `mycolor(...)` is a color in every context:
494
+ // fill: 'mycolor(255 0 0)'
495
+ // fill: '#brand.5' (with replaceTokens: { '#brand': 'mycolor(255 0 0)' })
496
+ ```
497
+
498
+ For HSL-style color spaces (a hue angle plus two percentages), the exported `createColorFunc(name, convert, label?)` helper handles angle/percentage parsing, clamping, alpha, and caching. `convert` returns sRGB `[r, g, b]` in 0-1; `label` is an optional string used only in dev warnings (e.g. `'H S L'`) and has no effect on output. This is exactly how `okhslPlugin`/`okhstPlugin` are implemented.
499
+
500
+ ---
501
+
502
+ ## Polyfills
503
+
504
+ `@function` only ships natively in Chromium 139+. To use CSS functions in browsers that don't support the at-rule yet (Firefox, Safari), enable the **functions polyfill**, which expands every `$$name(...)` call into plain CSS (`calc()`/`var()`/`color-mix()`) at parse time instead of emitting the native `@function` rule:
505
+
506
+ ```ts
507
+ configure({
508
+ polyfills: {
509
+ functions: true, // default: false
510
+ },
511
+ functions: {
512
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
513
+ },
514
+ });
515
+
516
+ // Now `margin: '$$negative(10px) top'` renders `margin: calc(-1 * 10px) 0 0 0`
517
+ // — no native @function rule is emitted.
518
+ ```
519
+
520
+ This works across all rendering modes (client, SSR/RSC, and `tastyStatic`) because expansion happens in the parser. Note `polyfills.functions` (the feature toggle) is distinct from the top-level `functions` (the definitions map).
521
+
522
+ **Decided limitations when the polyfill is on:**
523
+
524
+ - **No native fallback** — functions are always inlined; we do exactly what is configured.
525
+ - **Conditional results** (`@media`/`@supports`/`if()` inside `result`) are inlined verbatim; the conditional nuance is not resolved per-element.
526
+ - **Typed params / `returns`** are dropped (inlining is purely lexical substitution).
527
+ - **Param name collisions** are avoided by fully inlining argument values (no function-internal custom properties are emitted) and by namespacing the function's own variables.
528
+ - **Recursion** — self/mutually-recursive functions are not expanded; the cycle guard bails and leaves the call untouched.
240
529
 
241
530
  ---
242
531
 
@@ -260,7 +549,23 @@ configure({
260
549
  });
261
550
  ```
262
551
 
263
- Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@properties`. Recipes cannot reference other recipes.
552
+ Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@property`.
553
+
554
+ **Recipes cannot reference other recipes.** A `recipe` key inside a configured recipe's value is not recursively resolved:
555
+
556
+ ```jsx
557
+ // Unsupported: applying 'elevatedCard' does not expand 'card elevated'.
558
+ configure({
559
+ recipes: {
560
+ elevatedCard: {
561
+ recipe: 'card elevated',
562
+ padding: '6x',
563
+ },
564
+ },
565
+ });
566
+ ```
567
+
568
+ Instead, compose the names where you apply the styles: `styles: { recipe: 'card elevated', padding: '6x' }`. Recipe references are resolved on the component root and independently inside each sub-element's styles (for example, `styles: { Panel: { recipe: 'card elevated' } }`). This sub-element support does not allow one recipe definition to inherit another. Tasty warns in development when a recipe definition contains a `recipe` key.
264
569
 
265
570
  For how to apply, compose, and override recipes in components, see [Recipes](dsl.md#recipes) in the Style DSL reference.
266
571
 
@@ -317,7 +622,7 @@ configure({
317
622
  color: '#text',
318
623
  preset: 't2',
319
624
  margin: 0,
320
- fontFamily: 'system-ui, sans-serif',
625
+ font: 'system-ui, sans-serif',
321
626
  },
322
627
  html: {
323
628
  overflow: 'hidden',
@@ -328,7 +633,7 @@ configure({
328
633
 
329
634
  Each key is a CSS selector, and each value is a Tasty `Styles` object supporting the full style syntax including style properties, tokens, state maps, and selector-based sub-styling (e.g. `$: '> .app'` for elements outside React scope). Global styles are injected alongside `:root` tokens when the first style is rendered.
330
635
 
331
- Global styles are automatically emitted in all rendering modes: runtime (client), SSR, and zero-runtime (Babel plugin). Plugins can also provide `globalStyles`; they are merged per selector with config global styles (config wins on conflict).
636
+ Global styles are automatically emitted in all delivery modes: client rendering, server rendering, and build-time extraction with the Babel plugin. Plugins can also provide `globalStyles`; they are merged per selector with config global styles (config wins on conflict).
332
637
 
333
638
  ---
334
639
 
@@ -336,25 +641,25 @@ Global styles are automatically emitted in all rendering modes: runtime (client)
336
641
 
337
642
  CSS cannot transition or animate custom properties unless their type is declared via [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property). Tasty handles this automatically — when a custom property is assigned a concrete value (e.g. `'$scale': 1`, `'$gap': '10px'`, `'#accent': 'purple'`), the type is inferred and a `@property` rule is registered.
338
643
 
339
- This works across all declaration contexts: component styles, `@keyframes`, global config, and the zero-runtime Babel plugin. It also resolves `var()` chains — if `$a` references `var(--b)`, the type propagates once `--b` is resolved.
644
+ This works across all declaration contexts: component styles, `@keyframes`, global config, and build-time extraction with the Babel plugin. It also resolves `var()` chains — if `$a` references `var(--b)`, the type propagates once `--b` is resolved.
340
645
 
341
646
  Supported types:
342
647
 
343
- | Detection | Inferred syntax |
344
- |-----------|-----------------|
345
- | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
346
- | `10px`, `2rem`, `100vw` (length units) | `<length>` |
347
- | `50%` | `<percentage>` |
348
- | `45deg`, `0.5turn` (angle units) | `<angle>` |
349
- | `300ms`, `1s` (time units) | `<time>` |
350
- | `#name` tokens (by naming convention) | `<color>` |
648
+ | Detection | Inferred syntax |
649
+ | -------------------------------------- | --------------- |
650
+ | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
651
+ | `10px`, `2rem`, `100vw` (length units) | `<length>` |
652
+ | `50%` | `<percentage>` |
653
+ | `45deg`, `0.5turn` (angle units) | `<angle>` |
654
+ | `300ms`, `1s` (time units) | `<time>` |
655
+ | `#name` tokens (by naming convention) | `<color>` |
351
656
 
352
- Auto-inferred properties use `inherits: true` (the CSS default). Use explicit `@properties` when you need different settings:
657
+ Auto-inferred properties use `inherits: true` (the CSS default). Use explicit `@property` when you need different settings:
353
658
 
354
659
  ```jsx
355
660
  // In component styles
356
661
  styles: {
357
- '@properties': {
662
+ '@property': {
358
663
  '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
359
664
  },
360
665
  }
@@ -367,7 +672,7 @@ configure({
367
672
  });
368
673
  ```
369
674
 
370
- To disable auto-inference entirely (only explicit `@properties` will be used):
675
+ To disable auto-inference entirely (only explicit `@property` will be used):
371
676
 
372
677
  ```jsx
373
678
  configure({ autoPropertyTypes: false });
@@ -379,27 +684,19 @@ configure({ autoPropertyTypes: false });
379
684
 
380
685
  Override or extend the built-in style property handlers. A handler definition can take three forms:
381
686
 
382
- | Form | Syntax | Description |
383
- |------|--------|-------------|
384
- | Function only | `handler` | Triggered by its key name; receives only that property |
385
- | Single dep | `['styleName', handler]` | Triggered by the specified style property |
386
- | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
687
+ | Form | Syntax | Description |
688
+ | ------------- | ---------------------------------- | --------------------------------------------------------------- |
689
+ | Function only | `handler` | Triggered by its key name; receives only that property |
690
+ | Single dep | `['styleName', handler]` | Triggered by the specified style property |
691
+ | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
387
692
 
388
- The multi-dep form is useful when output depends on several style properties together (e.g., `gap` needs to know `display` and `flow` to decide the CSS strategy).
693
+ The multi-dep form is useful when output depends on several style properties together (e.g., `gap` needs to know `display` and `flow` to decide the CSS strategy). Use `defineHandler` for it and the dependency types are inferred from the dependency list, so a typo in the destructure is a type error instead of a silent `undefined`.
389
694
 
390
695
  ```jsx
391
- import { configure, styleHandlers } from '@tenphi/tasty';
696
+ import { configure, defineHandler, styleHandlers } from '@tenphi/tasty';
392
697
 
393
698
  configure({
394
699
  handlers: {
395
- // Function only — overrides built-in fill handler
396
- fill: ({ fill }) => {
397
- if (fill?.startsWith('gradient:')) {
398
- return { background: fill.slice(9) };
399
- }
400
- return styleHandlers.fill({ fill });
401
- },
402
-
403
700
  // Function only — new single-prop handler
404
701
  elevation: ({ elevation }) => {
405
702
  const level = parseInt(elevation) || 1;
@@ -409,16 +706,120 @@ configure({
409
706
  };
410
707
  },
411
708
 
709
+ // Overriding a built-in: declare every style the built-in handled and pass
710
+ // them all through, or the ones you leave out stop working (see below).
711
+ fill: defineHandler(
712
+ [
713
+ 'fill',
714
+ 'backgroundColor',
715
+ 'image',
716
+ 'backgroundImage',
717
+ 'backgroundPosition',
718
+ 'backgroundSize',
719
+ 'backgroundRepeat',
720
+ ],
721
+ (props) => {
722
+ if (
723
+ typeof props.fill === 'string' &&
724
+ props.fill.startsWith('gradient:')
725
+ ) {
726
+ return { background: props.fill.slice(9) };
727
+ }
728
+ return styleHandlers.fill(props);
729
+ },
730
+ ),
731
+
412
732
  // Multi dep — handler reads multiple style properties
413
- gap: [['display', 'flow', 'gap'], ({ display, flow, gap }) => {
733
+ gap: defineHandler(['display', 'flow', 'gap'], ({ display, flow, gap }) => {
414
734
  if (!gap) return;
415
- const isGrid = display?.includes('grid');
735
+ const isGrid = String(display ?? '').includes('grid');
416
736
  return { gap: isGrid ? gap : `/* custom logic for ${flow} */` };
417
- }],
737
+ }),
418
738
  },
419
739
  });
420
740
  ```
421
741
 
742
+ ### Return shape
743
+
744
+ A handler returns a `CSSMap`, an array of them, or nothing:
745
+
746
+ - Keys are **kebab-case** CSS property names (`'background-color'`, not `backgroundColor`) or `--custom-property` names. A camelCase key warns in development and is emitted verbatim, which the browser ignores.
747
+ - Values are stringified, so numbers are fine (`{ '-webkit-line-clamp': 3 }`).
748
+ - The reserved `$` key is a **selector suffix**: `{ $: '& > *:not(:last-child)', 'margin-right': gap }` applies the declarations to a nested selector. It accepts an array to fan out over several.
749
+ - Return an array of maps to emit several declaration sets, each with its own `$`.
750
+
751
+ Values arrive **state-resolved but unparsed** — the raw authored DSL string (`'2x'`, `'#purple.5'`, `true`, `4`). Call the exported `parseStyle()` / `parseColor()` yourself; nothing parses them for you.
752
+
753
+ ### Replacing a built-in handler
754
+
755
+ Built-in handlers are shared across several style names. Registering a handler for one of those names unregisters the built-in from **all** of them, and the displaced names then fall back to auto-generated CSS aliases — so `hide: true` starts emitting a literal `hide: true` declaration. A development-mode warning lists exactly what was displaced.
756
+
757
+ The shared groups worth knowing:
758
+
759
+ | Registering a handler for | Also takes over |
760
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------- |
761
+ | `fill` | `backgroundColor`, `image`, `backgroundImage`, `backgroundPosition`, `backgroundSize`, `backgroundRepeat` |
762
+ | `display` | `hide`, `overflow`, `whiteSpace`, `textOverflow`, `flow`, `gap` |
763
+ | `preset` | `font`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform` |
764
+ | `padding` / `margin` / `inset` | their `*Top`/`*Right`/`*Bottom`/`*Left`/`*Block`/`*Inline` longhands |
765
+
766
+ Either declare the whole group and delegate the rest to `styleHandlers.*`, or pick a name that isn't shared.
767
+
768
+ ### Chunk membership
769
+
770
+ Tasty renders and caches CSS in independent chunks, and a chunk's cache key covers only its own style values. All of a handler's dependencies must therefore live in one chunk. Custom style names are pulled into their handler's chunk automatically at registration; a handler whose dependencies span two _built-in_ chunks (say `fill` and `padding`) warns, because it would be invoked once per chunk with a subset of its inputs.
771
+
772
+ `configure({ handlers })` must run before the first render, like every other config option.
773
+
774
+ ---
775
+
776
+ ## Props Middleware
777
+
778
+ `propHandlers` are middleware over a component's props — props in, props out. Where a style _handler_ turns a style property into CSS declarations, a prop handler turns a **component prop** into other props, including `styles`. It is the extension point for props whose value isn't a style value.
779
+
780
+ ```jsx
781
+ import { configure, mergeStyles } from '@tenphi/tasty';
782
+
783
+ configure({
784
+ propHandlers: {
785
+ glaze: (props) => {
786
+ const { glaze, ...rest } = props;
787
+ if (!glaze) return rest;
788
+
789
+ return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
790
+ },
791
+ },
792
+ });
793
+
794
+ <Element glaze="purple" />;
795
+ ```
796
+
797
+ The map key is the handler's name and, by default, the prop that triggers it, so an absent prop costs one property check rather than a call. A tuple overrides that: `['glaze', fn]`, `[['glaze', 'tint'], fn]`, or `['*', fn]` for unconditional.
798
+
799
+ Handlers run at the very top of every component's render, before any prop is destructured, so one can rewrite `styles`, `mods`, `tokens`, `variant`, `as`, `element`, and `qa`. They run in registration order — plugins first, then direct config — each receiving the previous one's output.
800
+
801
+ Handlers must be **pure** and must not mutate their input, and should memoize the styles they build per input value: style values are cached by object identity, so mutating one in place yields stale CSS, and a reference-stable object avoids re-serializing on every render.
802
+
803
+ Injected styles occupy the `styles` slot, so they beat a component's own default styles and lose to a style prop at the call site. Prop handlers do not apply to sub-elements or to build-time `tastyStatic()`, which has no props.
804
+
805
+ See [Plugins → Props middleware](plugins.md#props-middleware) for the full contract and a worked example.
806
+
807
+ ---
808
+
809
+ ## Base Style Props
810
+
811
+ `baseStyleProps` exposes style properties as props on **every** `tasty()` component, on top of the built-in base styles (`display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, `transition`):
812
+
813
+ ```jsx
814
+ configure({ baseStyleProps: ['radius', 'shadow'] });
815
+
816
+ <Card radius="1r" shadow />;
817
+ ```
818
+
819
+ `configure()` may run after your components are defined — each factory resolves its prop list lazily.
820
+
821
+ Each name costs one property check per render of every component, and the effect is app-global, so keep the list short and use a factory's own `styleProps` for anything narrower. Avoid names that collide with real DOM or component props (`width`, `size`, `color`), since every component will then swallow them as styles.
822
+
422
823
  ---
423
824
 
424
825
  ## Extending Style Types (TypeScript)