@tenphi/tasty 0.0.0-snapshot.b6cc3cd → 0.0.0-snapshot.b7bfdb1

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 (67) hide show
  1. package/README.md +147 -129
  2. package/dist/{babel-D8dm92E_.d.ts → babel-Brsw7Ax_.d.ts} +2 -2
  3. package/dist/{collector-BFuqdF2F.d.ts → collector-0YO-P1vW.d.ts} +2 -2
  4. package/dist/{collector-Di3C8btw.js → collector-DJqx7XO0.js} +3 -3
  5. package/dist/{collector-Di3C8btw.js.map → collector-DJqx7XO0.js.map} +1 -1
  6. package/dist/{config-DH7I0Ggx.d.ts → config-CscQCTAM.d.ts} +133 -40
  7. package/dist/{config-BrDt11hO.js → config-DsqqkmUs.js} +496 -1009
  8. package/dist/config-DsqqkmUs.js.map +1 -0
  9. package/dist/core/index.d.ts +5 -5
  10. package/dist/core/index.js +6 -6
  11. package/dist/{core-YWn1zgh4.js → core-KVEKOhEi.js} +145 -105
  12. package/dist/core-KVEKOhEi.js.map +1 -0
  13. package/dist/{css-writer-CQYbT4g_.js → css-writer-Cdrh5gHj.js} +3 -3
  14. package/dist/{css-writer-CQYbT4g_.js.map → css-writer-Cdrh5gHj.js.map} +1 -1
  15. package/dist/{format-rules-DdmLdntR.js → format-rules-CHNmNGhw.js} +5 -20
  16. package/dist/format-rules-CHNmNGhw.js.map +1 -0
  17. package/dist/{hydrate-D2ivfS-B.js → hydrate-DJhwbWq4.js} +3 -3
  18. package/dist/{hydrate-D2ivfS-B.js.map → hydrate-DJhwbWq4.js.map} +1 -1
  19. package/dist/{index-DljBkZhV.d.ts → index-BR9as3qn.d.ts} +52 -22
  20. package/dist/{index-LC3O3Jj4.d.ts → index-BmogEzTo.d.ts} +75 -16
  21. package/dist/index.d.ts +5 -5
  22. package/dist/index.js +9 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/{keyframes-CoLLjBcd.js → keyframes-CQY-i8dO.js} +110 -21
  25. package/dist/keyframes-CQY-i8dO.js.map +1 -0
  26. package/dist/{merge-styles-Cx_6ySBv.d.ts → merge-styles-BcLl1u_d.d.ts} +2 -2
  27. package/dist/{merge-styles-bdh7-1uh.js → merge-styles-voA8J__3.js} +2 -2
  28. package/dist/{merge-styles-bdh7-1uh.js.map → merge-styles-voA8J__3.js.map} +1 -1
  29. package/dist/{resolve-recipes-9JYSgubn.js → resolve-recipes-BP2NqOtQ.js} +3 -3
  30. package/dist/{resolve-recipes-9JYSgubn.js.map → resolve-recipes-BP2NqOtQ.js.map} +1 -1
  31. package/dist/ssr/astro-client.js +1 -1
  32. package/dist/ssr/astro.js +3 -3
  33. package/dist/ssr/index.d.ts +1 -1
  34. package/dist/ssr/index.js +3 -3
  35. package/dist/ssr/next.d.ts +1 -1
  36. package/dist/ssr/next.js +4 -4
  37. package/dist/static/index.d.ts +2 -2
  38. package/dist/static/index.js +1 -1
  39. package/dist/zero/babel.d.ts +1 -1
  40. package/dist/zero/babel.js +4 -4
  41. package/dist/zero/index.d.ts +1 -1
  42. package/dist/zero/index.js +1 -1
  43. package/dist/zero/next.d.ts +1 -1
  44. package/docs/README.md +13 -8
  45. package/docs/adoption.md +56 -31
  46. package/docs/ai-agents.md +78 -77
  47. package/docs/comparison.md +69 -40
  48. package/docs/configuration.md +164 -101
  49. package/docs/debug.md +4 -2
  50. package/docs/design-system.md +41 -22
  51. package/docs/dsl.md +263 -198
  52. package/docs/getting-started.md +60 -39
  53. package/docs/injector.md +63 -26
  54. package/docs/methodology.md +43 -37
  55. package/docs/migration-v3.md +49 -49
  56. package/docs/pipeline.md +1 -4
  57. package/docs/plugins.md +37 -33
  58. package/docs/react-api.md +66 -45
  59. package/docs/runtime-benchmarks.md +178 -0
  60. package/docs/ssr.md +56 -57
  61. package/docs/styles.md +9 -2
  62. package/docs/tasty-static.md +137 -104
  63. package/package.json +12 -7
  64. package/dist/config-BrDt11hO.js.map +0 -1
  65. package/dist/core-YWn1zgh4.js.map +0 -1
  66. package/dist/format-rules-DdmLdntR.js.map +0 -1
  67. package/dist/keyframes-CoLLjBcd.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';
@@ -45,35 +47,35 @@ These docs use `data-schema="dark"` in examples. If your app already standardize
45
47
 
46
48
  ## Options
47
49
 
48
- | Option | Type | Default | Description |
49
- |--------|------|---------|-------------|
50
- | `nonce` | `string` | - | CSP nonce for style elements |
51
- | `maxRulesPerSheet` | `number` | `8192` | Maximum rules per injected stylesheet |
52
- | `forceTextInjection` | `boolean` | auto (`true` in test envs) | Force text-node CSS injection instead of constructable stylesheets |
53
- | `devMode` | `boolean` | auto | Enable development-mode features: performance metrics and debug info |
54
- | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
55
- | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
56
- | `units` | `Record<string, string \| UnitHandler>` | Built-in | Custom units (merged with built-in). See [built-in units](dsl.md#built-in-units) |
57
- | `functions` | `Record<string, FunctionDefinition \| Function>` | - | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
58
- | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in). See [Custom Style Handlers](#custom-style-handlers) |
59
- | `propHandlers` | `Record<string, PropHandlerDefinition>` | - | Props middleware for every component — props in, props out. See [Props Middleware](#props-middleware) |
60
- | `baseStyleProps` | `readonly string[]` | - | Style names exposed as props on **every** component. See [Base Style Props](#base-style-props) |
61
- | `tokens` | `Record<string, value \| stateMap>` | - | Design tokens injected as `:root` CSS custom properties |
62
- | `replaceTokens` | `Record<string, string \| number \| boolean>` | - | Parse-time token substitution (inline replacement). `boolean` is allowed for `#` color tokens |
63
- | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
64
- | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
65
- | `fontFaces` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
66
- | `counterStyles` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
67
- | `polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills for not-yet-baseline features. `functions: true` inlines `@function` calls into plain CSS at parse time |
68
- | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
69
- | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
70
- | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
71
- | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
72
- | `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) |
73
- | `gc` | `GCConfig` | - | Garbage-collection tuning for unused styles (`{ touchInterval, capacity }`) |
74
- | `batchInjection` | `boolean \| 'always'` | `false` | Defer stylesheet writes and apply them in one batch. See [Batched injection](#batched-injection) |
75
- | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | `'oklch'` | Color space for decomposed color token companion variables |
76
- | `namePrefix` | `string` | `'t'` (runtime) / `'ts'` (zero-runtime) | 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). |
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). |
77
79
 
78
80
  ---
79
81
 
@@ -107,10 +109,10 @@ createRoot(el).render(
107
109
  ### Why the provider is required
108
110
 
109
111
  Deferring a write past React's layout phase would let a `useLayoutEffect`
110
- measure an element whose rules are not in the sheet yet and read its *unstyled*
112
+ measure an element whose rules are not in the sheet yet and read its _unstyled_
111
113
  box — a wrong number, not a stale one, so it never self-corrects.
112
114
 
113
- `TastyBatchProvider` closes that hole. It opens a *batch window* during its
115
+ `TastyBatchProvider` closes that hole. It opens a _batch window_ during its
114
116
  render and closes it — flushing — in `useInsertionEffect`, which React runs in
115
117
  the mutation phase, before any layout effect:
116
118
 
@@ -135,11 +137,11 @@ commits it takes part in.
135
137
 
136
138
  ### Modes
137
139
 
138
- | Value | Behaviour |
139
- |-------|-----------|
140
- | `false` (default) | One `insertRule()` per component, synchronously. |
141
- | `true` | Batch inside a provider window only. Cannot affect measurement. Without the provider nothing is batched, and dev mode says so once. |
142
- | `'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. |
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. |
143
145
 
144
146
  ### Ordering
145
147
 
@@ -148,7 +150,7 @@ All writes share one FIFO queue — component rules, global rules, raw CSS,
148
150
  Draining it in insertion order keeps the sheet byte-identical to unbatched
149
151
  output, which matters because equal-specificity rules resolve by document order.
150
152
 
151
- ### SSR, RSC and zero-runtime
153
+ ### Client rendering, server rendering, and build-time extraction
152
154
 
153
155
  **Server render — nothing to batch, safe to leave enabled.** SSR and RSC collect
154
156
  CSS as text through `ServerStyleCollector`; the runtime injector never runs
@@ -173,12 +175,12 @@ tasty components to be worth it. `'always'` needs no provider and covers every
173
175
  island, at the cost of the measurement hazard above. Either way, an island that
174
176
  only re-hydrates server-rendered classes has nothing to batch.
175
177
 
176
- **Zero-runtime (`tastyStatic`) — unaffected.** Build-time extraction never
178
+ **Build-time extraction (`tastyStatic`) — unaffected.** The Babel plugin never
177
179
  touches the injector: the babel plugin emits either a CSS file import or an
178
180
  `injectCSS()` call from `@tenphi/tasty/static/inject`, which appends text to a
179
181
  single `<style data-tasty-static>` element. `batchInjection` only defers CSSOM
180
- writes made by the runtime injector, so extracted styles are unchanged. In an app
181
- that mixes both, it still applies to the runtime half.
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.
182
184
 
183
185
  ### `flushStyles()`
184
186
 
@@ -205,31 +207,84 @@ useLayoutEffect(() => {
205
207
 
206
208
  ## Color Space
207
209
 
208
- Controls the CSS color space used for decomposed color token companion variables. When you define `#name` color tokens, tasty generates both `--name-color` (the color) and `--name-color-{suffix}` (its channels, decomposed).
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:
209
221
 
210
222
  ```jsx
211
- configure({
212
- colorSpace: 'oklch', // default
213
- });
223
+ configure({ tokens: { '#brand': '#ff8800' } });
224
+ // → --brand-color: #ff8800
214
225
  ```
215
226
 
216
- | Color Space | Suffix | Components Format | Channel Reference |
217
- |---|---|---|---|
218
- | `rgb` | `-rgb` | `255 128 0` | `rgb(var(--name-color-rgb))` |
219
- | `hsl` | `-hsl` | `300 100% 25%` | `hsl(var(--name-color-hsl))` |
220
- | `oklch` | `-oklch` | `0.42 0.16 328` | `oklch(var(--name-color-oklch))` |
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.
231
+
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`
221
244
 
222
- The `oklch` color space is the default because it provides perceptually uniform color manipulation — reaching for a channel to shift lightness or hue produces more natural-looking results.
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:
223
248
 
224
- The companion is there so you can *address the channels*: shift a lightness, animate a hue, build a derived color. It is not how the [opacity suffix](dsl.md#color-tokens--opacity) works — that sets the alpha on `--name-color` itself with relative color syntax, so it needs nothing from the companion and works on any color.
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
+ ```
225
277
 
226
- A color the engine cannot evaluate at build time — a `color-mix()`, a `light-dark()`, a `color()` in a space it has no conversion for — has no channels to decompose, so its companion is expressed *by reference* using CSS relative color syntax (`--name-color-oklch: from color-mix(…) l c h`). Reading a channel off it still works; the browser resolves them.
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.
227
282
 
228
283
  ---
229
284
 
230
285
  ## Name Prefix
231
286
 
232
- 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.
233
288
 
234
289
  ```jsx
235
290
  configure({
@@ -239,12 +294,12 @@ configure({
239
294
 
240
295
  The prefix is prepended verbatim to the hash, so include any separator inside the prefix string itself:
241
296
 
242
- | Setting | Class | Keyframe | Counter-style |
243
- |---|---|---|---|
244
- | `'t'` (runtime default) | `t1a2b3` | `tk1a2b3` | `tc1a2b3` |
245
- | `'ts'` (zero-runtime default) | `ts1a2b3` | `tsk1a2b3` | `tsc1a2b3` |
246
- | `'mb'` | `mb1a2b3` | `mbk1a2b3` | `mbc1a2b3` |
247
- | `'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` |
248
303
 
249
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.
250
305
 
@@ -254,12 +309,12 @@ The single-letter discriminators (`k` for keyframes, `c` for counter-styles) kee
254
309
  - Validated at `configure()` time; an invalid prefix throws synchronously rather than silently producing broken hydration.
255
310
  - Locked once styles have been generated, like all other config.
256
311
 
257
- ### Coexistence with the zero-runtime build
312
+ ### Coexistence with build-time extraction
258
313
 
259
- 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:
260
315
 
261
316
  ```jsx
262
- // app config (runtime / SSR / RSC)
317
+ // app config (client / SSR / RSC)
263
318
  configure({ namePrefix: 'mb' });
264
319
 
265
320
  // tasty-zero.config.ts (Babel plugin)
@@ -279,8 +334,8 @@ Tokens support state maps for responsive or theme-aware values:
279
334
  ```jsx
280
335
  configure({
281
336
  tokens: {
282
- '$gap': '4px',
283
- '$radius': '6px',
337
+ $gap: '4px',
338
+ $radius: '6px',
284
339
  '#primary': {
285
340
  '': '#purple',
286
341
  '@dark': '#light-purple',
@@ -294,10 +349,10 @@ configure({
294
349
  ```
295
350
 
296
351
  - `$name` keys become `--name` CSS custom properties
297
- - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties (suffix depends on `colorSpace`, default `oklch`)
352
+ - `#name` keys become `--name-color` custom properties
298
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.
299
354
 
300
- 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.
301
356
 
302
357
  ---
303
358
 
@@ -351,7 +406,7 @@ configure({
351
406
  });
352
407
  ```
353
408
 
354
- 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.
355
410
 
356
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.
357
412
 
@@ -408,7 +463,7 @@ configure({
408
463
  });
409
464
  ```
410
465
 
411
- Components then invoke parse functions as `double(...)` and CSS functions with the `$$name(...)` sugar, e.g. `marginTop: '$$negative(10px)'`.
466
+ Components then invoke parse functions as `double(...)` and CSS functions with the `$$name(...)` sugar, e.g. `margin: '$$negative(10px) top'`.
412
467
 
413
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**.
414
469
 
@@ -416,7 +471,7 @@ See [Functions (`@function`)](dsl.md#functions-function) for inline usage inside
416
471
 
417
472
  ### Custom color functions
418
473
 
419
- 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, token decomposition into the configured color space, 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.
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.
420
475
 
421
476
  ```ts
422
477
  import { configure, createColorFunc } from '@tenphi/tasty';
@@ -458,7 +513,7 @@ configure({
458
513
  },
459
514
  });
460
515
 
461
- // Now `marginTop: '$$negative(10px)'` renders `margin-top: calc(-1 * 10px)`
516
+ // Now `margin: '$$negative(10px) top'` renders `margin: calc(-1 * 10px) 0 0 0`
462
517
  // — no native @function rule is emitted.
463
518
  ```
464
519
 
@@ -551,7 +606,7 @@ configure({
551
606
  color: '#text',
552
607
  preset: 't2',
553
608
  margin: 0,
554
- fontFamily: 'system-ui, sans-serif',
609
+ font: 'system-ui, sans-serif',
555
610
  },
556
611
  html: {
557
612
  overflow: 'hidden',
@@ -562,7 +617,7 @@ configure({
562
617
 
563
618
  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.
564
619
 
565
- 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).
620
+ 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).
566
621
 
567
622
  ---
568
623
 
@@ -570,18 +625,18 @@ Global styles are automatically emitted in all rendering modes: runtime (client)
570
625
 
571
626
  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.
572
627
 
573
- 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.
628
+ 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.
574
629
 
575
630
  Supported types:
576
631
 
577
- | Detection | Inferred syntax |
578
- |-----------|-----------------|
579
- | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
580
- | `10px`, `2rem`, `100vw` (length units) | `<length>` |
581
- | `50%` | `<percentage>` |
582
- | `45deg`, `0.5turn` (angle units) | `<angle>` |
583
- | `300ms`, `1s` (time units) | `<time>` |
584
- | `#name` tokens (by naming convention) | `<color>` |
632
+ | Detection | Inferred syntax |
633
+ | -------------------------------------- | --------------- |
634
+ | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
635
+ | `10px`, `2rem`, `100vw` (length units) | `<length>` |
636
+ | `50%` | `<percentage>` |
637
+ | `45deg`, `0.5turn` (angle units) | `<angle>` |
638
+ | `300ms`, `1s` (time units) | `<time>` |
639
+ | `#name` tokens (by naming convention) | `<color>` |
585
640
 
586
641
  Auto-inferred properties use `inherits: true` (the CSS default). Use explicit `@property` when you need different settings:
587
642
 
@@ -613,11 +668,11 @@ configure({ autoPropertyTypes: false });
613
668
 
614
669
  Override or extend the built-in style property handlers. A handler definition can take three forms:
615
670
 
616
- | Form | Syntax | Description |
617
- |------|--------|-------------|
618
- | Function only | `handler` | Triggered by its key name; receives only that property |
619
- | Single dep | `['styleName', handler]` | Triggered by the specified style property |
620
- | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
671
+ | Form | Syntax | Description |
672
+ | ------------- | ---------------------------------- | --------------------------------------------------------------- |
673
+ | Function only | `handler` | Triggered by its key name; receives only that property |
674
+ | Single dep | `['styleName', handler]` | Triggered by the specified style property |
675
+ | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
621
676
 
622
677
  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`.
623
678
 
@@ -639,11 +694,19 @@ configure({
639
694
  // them all through, or the ones you leave out stop working (see below).
640
695
  fill: defineHandler(
641
696
  [
642
- 'fill', 'backgroundColor', 'image', 'backgroundImage',
643
- 'backgroundPosition', 'backgroundSize', 'backgroundRepeat',
697
+ 'fill',
698
+ 'backgroundColor',
699
+ 'image',
700
+ 'backgroundImage',
701
+ 'backgroundPosition',
702
+ 'backgroundSize',
703
+ 'backgroundRepeat',
644
704
  ],
645
705
  (props) => {
646
- if (typeof props.fill === 'string' && props.fill.startsWith('gradient:')) {
706
+ if (
707
+ typeof props.fill === 'string' &&
708
+ props.fill.startsWith('gradient:')
709
+ ) {
647
710
  return { background: props.fill.slice(9) };
648
711
  }
649
712
  return styleHandlers.fill(props);
@@ -677,18 +740,18 @@ Built-in handlers are shared across several style names. Registering a handler f
677
740
 
678
741
  The shared groups worth knowing:
679
742
 
680
- | Registering a handler for | Also takes over |
681
- |---|---|
682
- | `fill` | `backgroundColor`, `image`, `backgroundImage`, `backgroundPosition`, `backgroundSize`, `backgroundRepeat` |
683
- | `display` | `hide`, `overflow`, `whiteSpace`, `textOverflow`, `flow`, `gap` |
684
- | `preset` | `font`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform` |
685
- | `padding` / `margin` / `inset` | their `*Top`/`*Right`/`*Bottom`/`*Left`/`*Block`/`*Inline` longhands |
743
+ | Registering a handler for | Also takes over |
744
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------- |
745
+ | `fill` | `backgroundColor`, `image`, `backgroundImage`, `backgroundPosition`, `backgroundSize`, `backgroundRepeat` |
746
+ | `display` | `hide`, `overflow`, `whiteSpace`, `textOverflow`, `flow`, `gap` |
747
+ | `preset` | `font`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform` |
748
+ | `padding` / `margin` / `inset` | their `*Top`/`*Right`/`*Bottom`/`*Left`/`*Block`/`*Inline` longhands |
686
749
 
687
750
  Either declare the whole group and delegate the rest to `styleHandlers.*`, or pick a name that isn't shared.
688
751
 
689
752
  ### Chunk membership
690
753
 
691
- 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.
754
+ 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.
692
755
 
693
756
  `configure({ handlers })` must run before the first render, like every other config option.
694
757
 
@@ -696,7 +759,7 @@ Tasty renders and caches CSS in independent chunks, and a chunk's cache key cove
696
759
 
697
760
  ## Props Middleware
698
761
 
699
- `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.
762
+ `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.
700
763
 
701
764
  ```jsx
702
765
  import { configure, mergeStyles } from '@tenphi/tasty';
@@ -712,7 +775,7 @@ configure({
712
775
  },
713
776
  });
714
777
 
715
- <Element glaze="purple" />
778
+ <Element glaze="purple" />;
716
779
  ```
717
780
 
718
781
  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.
@@ -721,7 +784,7 @@ Handlers run at the very top of every component's render, before any prop is des
721
784
 
722
785
  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.
723
786
 
724
- 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 zero-runtime `tastyStatic()`, which has no props.
787
+ 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.
725
788
 
726
789
  See [Plugins → Props middleware](plugins.md#props-middleware) for the full contract and a worked example.
727
790
 
@@ -734,7 +797,7 @@ See [Plugins → Props middleware](plugins.md#props-middleware) for the full con
734
797
  ```jsx
735
798
  configure({ baseStyleProps: ['radius', 'shadow'] });
736
799
 
737
- <Card radius="1r" shadow />
800
+ <Card radius="1r" shadow />;
738
801
  ```
739
802
 
740
803
  `configure()` may run after your components are defined — each factory resolves its prop list lazily.
package/docs/debug.md CHANGED
@@ -68,7 +68,7 @@ Retrieves CSS text for a given target. Logs the result with rule count and size.
68
68
  |---|---|
69
69
  | `'all'` | All tasty CSS (component + global + raw) |
70
70
  | `'active'` | CSS for classes currently in the DOM |
71
- | `'unused'` | CSS with refCount = 0 (cached but not used) |
71
+ | `'unused'` | CSS for injected classes no element carries (cached but not rendered) |
72
72
  | `'global'` | Only global CSS (from `injectGlobal`) |
73
73
  | `'page'` | All CSS on the page (including non-tasty) |
74
74
  | `'t3a5f'` | CSS for a specific tasty class (class names are `t` + base36 hash) |
@@ -241,7 +241,9 @@ tastyDebug.cache();
241
241
 
242
242
  ### `cleanup(opts?): void`
243
243
 
244
- Forces immediate cleanup of all unused styles (those with `refCount = 0`).
244
+ Removes every injected style that is neither carried by an element nor pinned by
245
+ an outstanding `inject()` handle — the same set `summary()` reports as unused.
246
+ Equivalent to `gc({ force: true })`.
245
247
 
246
248
  ```typescript
247
249
  tastyDebug.cleanup();