@tenphi/tasty 0.0.0-snapshot.da430e1 → 0.0.0-snapshot.db2ef70

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 (130) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/{collector-BevHh16N.js → chunks/collector-Cb8ah2JF.js} +10 -127
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-D2Pu7Xhy.js +502 -0
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  29. package/dist/{merge-styles-BKfagXfV.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/{css-writer-BDPmetHV.js → chunks/zero-engine-DcwaCvFs.js} +65 -145
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/{collector-CLVr5_p3.d.ts → collector-D2OT6I2G.d.ts} +6 -5
  36. package/dist/{config-YsxGv4tq.d.ts → config-C4ftFxgI.d.ts} +181 -77
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-CBK778ne.d.ts → index-DxQNRj50.d.ts} +308 -255
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -922
  43. package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
  48. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  49. package/dist/ssr/astro-middleware-extract.d.ts +1 -2
  50. package/dist/ssr/astro-middleware-extract.js +1 -1
  51. package/dist/ssr/astro-middleware-static.d.ts +1 -2
  52. package/dist/ssr/astro-middleware-static.js +1 -12
  53. package/dist/ssr/astro-middleware-static.js.map +1 -1
  54. package/dist/ssr/astro-middleware.d.ts +1 -2
  55. package/dist/ssr/astro-middleware.js +1 -13
  56. package/dist/ssr/astro-middleware.js.map +1 -1
  57. package/dist/ssr/astro.d.ts +17 -17
  58. package/dist/ssr/astro.js +220 -1
  59. package/dist/ssr/astro.js.map +1 -0
  60. package/dist/ssr/client.d.ts +2 -0
  61. package/dist/ssr/client.js +2 -0
  62. package/dist/ssr/index.d.ts +5 -25
  63. package/dist/ssr/index.js +5 -5
  64. package/dist/ssr/index.js.map +1 -1
  65. package/dist/ssr/next-config.d.ts +64 -0
  66. package/dist/ssr/next-config.js +123 -0
  67. package/dist/ssr/next-config.js.map +1 -0
  68. package/dist/ssr/next.d.ts +9 -8
  69. package/dist/ssr/next.js +29 -43
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/static/index.d.ts +8 -9
  72. package/dist/static/index.js +4 -22
  73. package/dist/static/index.js.map +1 -1
  74. package/dist/static/inject.d.ts +1 -2
  75. package/dist/{index-Cd45t5NM.d.ts → types-CYQIhUg1.d.ts} +868 -820
  76. package/dist/zero/babel.d.ts +73 -2
  77. package/dist/zero/babel.js +81 -144
  78. package/dist/zero/babel.js.map +1 -1
  79. package/dist/zero/index.d.ts +63 -8
  80. package/dist/zero/index.js +25 -2
  81. package/dist/zero/index.js.map +1 -0
  82. package/dist/zero/next.d.ts +4 -5
  83. package/dist/zero/next.js +3 -38
  84. package/dist/zero/next.js.map +1 -1
  85. package/docs/README.md +4 -1
  86. package/docs/adoption.md +25 -17
  87. package/docs/ai-agents.md +68 -33
  88. package/docs/comparison.md +9 -8
  89. package/docs/configuration.md +204 -70
  90. package/docs/debug.md +21 -8
  91. package/docs/design-system.md +117 -15
  92. package/docs/dsl.md +307 -117
  93. package/docs/getting-started.md +81 -22
  94. package/docs/injector.md +105 -67
  95. package/docs/methodology.md +48 -23
  96. package/docs/migration-v3.md +3 -3
  97. package/docs/pipeline.md +54 -27
  98. package/docs/plugins.md +22 -42
  99. package/docs/react-api.md +76 -11
  100. package/docs/runtime-benchmarks.md +282 -110
  101. package/docs/ssr.md +226 -80
  102. package/docs/styles.md +169 -33
  103. package/docs/tasty-static.md +176 -58
  104. package/package.json +108 -44
  105. package/tasty.config.ts +1 -0
  106. package/dist/astro-C_by9qPq.js +0 -307
  107. package/dist/astro-C_by9qPq.js.map +0 -1
  108. package/dist/async-storage-DKK-wTD4.js +0 -44
  109. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  110. package/dist/babel-BUQGeOXA.d.ts +0 -83
  111. package/dist/collector-BevHh16N.js.map +0 -1
  112. package/dist/config-NcdqU9PC.js +0 -12269
  113. package/dist/config-NcdqU9PC.js.map +0 -1
  114. package/dist/context-CA8YKeMn.js +0 -24
  115. package/dist/context-CA8YKeMn.js.map +0 -1
  116. package/dist/core-D7s7u-k1.js +0 -1566
  117. package/dist/core-D7s7u-k1.js.map +0 -1
  118. package/dist/css-writer-BDPmetHV.js.map +0 -1
  119. package/dist/format-global-rules-DklyaXv-.js +0 -22
  120. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  121. package/dist/format-rules-BQCn7JZH.js +0 -130
  122. package/dist/format-rules-BQCn7JZH.js.map +0 -1
  123. package/dist/hydrate-C3cfqlaQ.js +0 -37
  124. package/dist/hydrate-C3cfqlaQ.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/keyframes-ByhOtsXB.js +0 -493
  127. package/dist/keyframes-ByhOtsXB.js.map +0 -1
  128. package/dist/merge-styles-BKfagXfV.js.map +0 -1
  129. package/dist/resolve-recipes-vvygrWLw.js +0 -144
  130. package/dist/resolve-recipes-vvygrWLw.js.map +0 -1
@@ -23,9 +23,8 @@ configure({
23
23
 
24
24
  // Custom units (merged with built-in units)
25
25
  units: {
26
- vh: 'vh',
27
- vw: 'vw',
28
- custom: (n) => `${n * 10}px`, // Function-based unit
26
+ gu: '4px', // `2gu` → `8px`
27
+ cols: (n) => `calc(${n} * var(--col-width))`, // function-based unit
29
28
  },
30
29
 
31
30
  // Custom functions — a single map for both flavors, discriminated by value type:
@@ -47,35 +46,35 @@ These docs use `data-schema="dark"` in examples. If your app already standardize
47
46
 
48
47
  ## Options
49
48
 
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). |
49
+ | Option | Type | Default | Description |
50
+ | -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
51
+ | `nonce` | `string` | - | CSP nonce for style elements |
52
+ | `maxRulesPerSheet` | `number` | `8192` | Maximum rules per injected stylesheet |
53
+ | `forceTextInjection` | `boolean` | `false` (`true` in test environments only while `configure()` has never been called) | Force text-node CSS injection instead of constructable stylesheets. Set it explicitly in test setup |
54
+ | `devMode` | `boolean` | auto | Enable development-mode features: performance metrics and debug info. Does not turn on dev warnings; those follow `NODE_ENV` (or `localStorage.TASTY_DEBUG = 'true'` in a browser) |
55
+ | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
56
+ | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
57
+ | `units` | `Record<string, string \| UnitHandler>` | Built-in | Custom units (merged with built-in). See [built-in units](dsl.md#built-in-units) |
58
+ | `functions` | `Record<string, FunctionDefinition \| Function>` | - | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
59
+ | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in). See [Custom Style Handlers](#custom-style-handlers) |
60
+ | `propHandlers` | `Record<string, PropHandlerDefinition>` | - | Props middleware for every component — props in, props out. See [Props Middleware](#props-middleware) |
61
+ | `baseStyleProps` | `readonly string[]` | - | Style names exposed as props on **every** component. See [Base Style Props](#base-style-props) |
62
+ | `tokens` | `Record<string, value \| stateMap>` | - | Design tokens injected as `:root` CSS custom properties |
63
+ | `replaceTokens` | `Record<string, string \| number \| boolean>` | `{ '#clear': 'transparent' }` | Parse-time token substitution (inline replacement). `boolean` is allowed for `#` color tokens |
64
+ | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
65
+ | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
66
+ | `fontFaces` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
67
+ | `counterStyles` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
68
+ | `polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills for not-yet-baseline features. `functions: true` inlines `@function` calls into plain CSS at parse time |
69
+ | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
70
+ | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
71
+ | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
72
+ | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
73
+ | `plugins` | `TastyPlugin[]` | - | Plugins that bundle `functions`, `units`, `states`, `handlers`, `propHandlers`, `baseStyleProps`, `tokens`, `replaceTokens`, `recipes`, `presets`, `globalStyles`, `properties`, `keyframes`, `fontFaces`, and `counterStyles` (processed in order; later override earlier, and direct config wins over all). See [Plugins](plugins.md) |
74
+ | `gc` | `GCConfig` | - | Turns on automatic collection of unused styles: `{ touchInterval?, capacity?, grace? }` (defaults `1000`, `1000`, `10000` ms). Without it nothing is collected automatically; call `gc()` yourself |
75
+ | `batchInjection` | `boolean \| 'always'` | `false` | Defer stylesheet writes and apply them in one batch. See [Batched injection](#batched-injection) |
76
+ | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | - | **Deprecated** — no longer has any effect. See [Color space](#color-space) |
77
+ | `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
78
 
80
79
  ---
81
80
 
@@ -213,9 +212,9 @@ useLayoutEffect(() => {
213
212
  A `#name` token's value used to be rewritten into a configured color space, so
214
213
  `#brand: '#ff8800'` declared `--brand-color: oklch(0.75 0.16 55)`. That existed
215
214
  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.
215
+ into. Opacity now mixes the token with `transparent` —
216
+ `color-mix(in oklab, var(--brand-color) 50%, transparent)` — which the browser
217
+ resolves against any color, so there is nothing left for the setting to decide.
219
218
 
220
219
  A color is emitted exactly as authored:
221
220
 
@@ -236,9 +235,10 @@ background: oklch(from var(--brand-color) calc(l * 1.2) c h);
236
235
  ```
237
236
 
238
237
  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.
238
+ have evaluated, and `oklch` is unbounded, so a wide-gamut color survives a round
239
+ trip a narrower space would clamp. Relative color syntax is Baseline 2024 (Chrome
240
+ 125, Firefox 128, Safari 18), so the [opacity suffix](dsl.md#color-tokens--opacity)
241
+ uses the widely available `color-mix()` instead.
242
242
 
243
243
  ### Migrating off `colorSpace`
244
244
 
@@ -271,14 +271,15 @@ color: oklch(var(--brand-color-oklch) / 0.5);
271
271
  background: oklch(var(--brand-color-oklch));
272
272
 
273
273
  /* after */
274
- color: oklch(from var(--brand-color) l c h / 0.5);
274
+ color: color-mix(in oklab, var(--brand-color) 50%, transparent);
275
275
  background: var(--brand-color);
276
276
  ```
277
277
 
278
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.
279
+ decomposed for a color the engine could evaluate at build time, while
280
+ `color-mix()` works on every `<color>`, including a `color-mix()`, a
281
+ `light-dark()`, and a variable Tasty never defined. It is also what
282
+ `#brand.5` emits.
282
283
 
283
284
  ---
284
285
 
@@ -334,8 +335,7 @@ Tokens support state maps for responsive or theme-aware values:
334
335
  ```jsx
335
336
  configure({
336
337
  tokens: {
337
- $gap: '4px',
338
- $radius: '6px',
338
+ '$sidebar-width': '280px',
339
339
  '#primary': {
340
340
  '': '#purple',
341
341
  '@dark': '#light-purple',
@@ -350,9 +350,10 @@ configure({
350
350
 
351
351
  - `$name` keys become `--name` CSS custom properties
352
352
  - `#name` keys become `--name-color` custom properties
353
+ - Tokens do not change units: `2x` stays `16px` whatever `$gap` is. To drive a unit from a token, point the unit at it: `units: { x: 'var(--gap)' }` makes `2x` compile to `calc(2 * var(--gap))`
353
354
  - 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.
354
355
 
355
- Tokens are automatically emitted in all delivery modes: client rendering, server rendering, and build-time extraction with the Babel plugin.
356
+ Tokens are emitted by the client injector, by the SSR collector (`TastyRegistry`, `tastyIntegration()`, `runWithCollector()`), by the `withTastyNext()` shared stylesheet, and by the Babel plugin. The inline React Server Component path without a collector does not emit them — see [Server-Side Rendering](ssr.md).
356
357
 
357
358
  ---
358
359
 
@@ -375,6 +376,17 @@ configure({
375
376
 
376
377
  When a component uses `padding: '$card-padding'`, the parser replaces it with `'4x'` before generating CSS. When a component uses `fill: '#accent'`, it is replaced with `'#purple'`, which in turn resolves to `var(--purple-color)`.
377
378
 
379
+ Tasty includes `'#clear': 'transparent'` as a default replace token, available
380
+ without calling `configure()`. It survives `resetConfig()`, and explicit
381
+ `replaceTokens` entries can override it. A replace token resolving to the literal
382
+ `transparent` ignores numeric and custom-property opacity suffixes:
383
+ `#clear`, `#clear.5`, and `#clear.$opacity` all emit `transparent`.
384
+
385
+ `#clear` no longer reads `--clear-color`, and Tasty no longer registers that
386
+ property by default. If you previously customized `#clear` through `tokens`,
387
+ local token definitions, or CSS, use a different color token or explicitly
388
+ override `replaceTokens['#clear']` instead.
389
+
378
390
  See [Replace Tokens](dsl.md#replace-tokens) in the Style DSL reference.
379
391
 
380
392
  ---
@@ -471,7 +483,7 @@ See [Functions (`@function`)](dsl.md#functions-function) for inline usage inside
471
483
 
472
484
  ### Custom color functions
473
485
 
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.
486
+ 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, `parseColor`, and the `#token.alpha` opacity suffix, which calls the function with a `/ alpha` part appended (read `groups[0].parts[1]`, as below) — with no extra registration. This is the same mechanism the built-in `okhsl`/`okhst` plugins use; they are ordinary plugins registered by default.
475
487
 
476
488
  ```ts
477
489
  import { configure, createColorFunc } from '@tenphi/tasty';
@@ -482,8 +494,12 @@ const myColorPlugin = () => ({
482
494
  functions: {
483
495
  // Hand-written parse function:
484
496
  mycolor: (groups) => {
485
- const [r, g, b] = groups[0].all;
486
- return `rgb(${r} ${g} ${b})`;
497
+ // `mycolor(255 0 0 / .5)` and `#brand.5` both arrive as two parts
498
+ const [main, alpha] = groups[0].parts;
499
+ const [r, g, b] = main.all;
500
+ return alpha?.all.length
501
+ ? `rgb(${r} ${g} ${b} / ${alpha.output})`
502
+ : `rgb(${r} ${g} ${b})`;
487
503
  },
488
504
  },
489
505
  });
@@ -549,7 +565,23 @@ configure({
549
565
  });
550
566
  ```
551
567
 
552
- Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@property`. Recipes cannot reference other recipes.
568
+ Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@property`.
569
+
570
+ **Recipes cannot reference other recipes.** A `recipe` key inside a configured recipe's value is not recursively resolved:
571
+
572
+ ```jsx
573
+ // Unsupported: applying 'elevatedCard' does not expand 'card elevated'.
574
+ configure({
575
+ recipes: {
576
+ elevatedCard: {
577
+ recipe: 'card elevated',
578
+ padding: '6x',
579
+ },
580
+ },
581
+ });
582
+ ```
583
+
584
+ 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.
553
585
 
554
586
  For how to apply, compose, and override recipes in components, see [Recipes](dsl.md#recipes) in the Style DSL reference.
555
587
 
@@ -615,7 +647,7 @@ configure({
615
647
  });
616
648
  ```
617
649
 
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.
650
+ Each key is a CSS selector (a list such as `'.uni-checkbox, uni-checkbox'` styles every item), and each value is a Tasty `Styles` object supporting the full style syntax including style properties, tokens, state maps, `@keyframes`, 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.
619
651
 
620
652
  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).
621
653
 
@@ -674,10 +706,16 @@ Override or extend the built-in style property handlers. A handler definition ca
674
706
  | Single dep | `['styleName', handler]` | Triggered by the specified style property |
675
707
  | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
676
708
 
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`.
709
+ 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). A handler whose dependencies include a built-in style takes over that style's whole group — see [Replacing a built-in handler](#replacing-a-built-in-handler). 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`.
678
710
 
679
711
  ```jsx
680
- import { configure, defineHandler, styleHandlers } from '@tenphi/tasty';
712
+ import {
713
+ configure,
714
+ defineHandler,
715
+ parseColor,
716
+ parseStyle,
717
+ styleHandlers,
718
+ } from '@tenphi/tasty';
681
719
 
682
720
  configure({
683
721
  handlers: {
@@ -701,6 +739,10 @@ configure({
701
739
  'backgroundPosition',
702
740
  'backgroundSize',
703
741
  'backgroundRepeat',
742
+ 'backgroundAttachment',
743
+ 'backgroundOrigin',
744
+ 'backgroundClip',
745
+ 'background',
704
746
  ],
705
747
  (props) => {
706
748
  if (
@@ -713,12 +755,18 @@ configure({
713
755
  },
714
756
  ),
715
757
 
716
- // Multi dep — handler reads multiple style properties
717
- gap: defineHandler(['display', 'flow', 'gap'], ({ display, flow, gap }) => {
718
- if (!gap) return;
719
- const isGrid = String(display ?? '').includes('grid');
720
- return { gap: isGrid ? gap : `/* custom logic for ${flow} */` };
721
- }),
758
+ // Multi dep — triggered by either name, receives both
759
+ stripe: defineHandler(
760
+ ['stripe', 'stripeColor'],
761
+ ({ stripe, stripeColor }) => {
762
+ if (!stripe) return;
763
+ const width = parseStyle(String(stripe)).output;
764
+ const color = stripeColor
765
+ ? parseColor(String(stripeColor)).color
766
+ : 'currentcolor';
767
+ return { 'border-left': `${width} solid ${color}` };
768
+ },
769
+ ),
722
770
  },
723
771
  });
724
772
  ```
@@ -729,6 +777,7 @@ A handler returns a `CSSMap`, an array of them, or nothing:
729
777
 
730
778
  - 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.
731
779
  - Values are stringified, so numbers are fine (`{ '-webkit-line-clamp': 3 }`).
780
+ - An array value emits one declaration per entry, in order, so the browser keeps the last one it supports: `{ width: ['-webkit-fill-available', '-moz-available', 'stretch'] }` emits three `width` declarations.
732
781
  - 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.
733
782
  - Return an array of maps to emit several declaration sets, each with its own `$`.
734
783
 
@@ -740,12 +789,17 @@ Built-in handlers are shared across several style names. Registering a handler f
740
789
 
741
790
  The shared groups worth knowing:
742
791
 
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 |
792
+ | Registering a handler for | Also takes over |
793
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
794
+ | `fill` | `backgroundColor`, `image`, `backgroundImage`, `backgroundPosition`, `backgroundSize`, `backgroundRepeat`, `backgroundAttachment`, `backgroundOrigin`, `backgroundClip`, `background` |
795
+ | `display` | `hide`, `whiteSpace`, `textOverflow`, `flow`, `gap` |
796
+ | `flow` | `gap` |
797
+ | `preset` | `font`, `fontFamily`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform` |
798
+ | `padding` / `margin` | their `Top`/`Right`/`Bottom`/`Left` longhands (`paddingTop`, `marginLeft`, …) |
799
+ | `inset` | `top`, `right`, `bottom`, `left` |
800
+ | `width` / `height` | `minWidth`/`maxWidth`, `minHeight`/`maxHeight` |
801
+
802
+ A multi-dep handler takes over every group its dependencies touch: `defineHandler(['display', 'flow', 'gap'], …)` takes over `display`, `flow`, and `gap` together, so it must emit `display` and `flex-flow` itself.
749
803
 
750
804
  Either declare the whole group and delegate the rest to `styleHandlers.*`, or pick a name that isn't shared.
751
805
 
@@ -806,18 +860,98 @@ Each name costs one property check per render of every component, and the effect
806
860
 
807
861
  ---
808
862
 
809
- ## Extending Style Types (TypeScript)
863
+ ## TypeScript
810
864
 
811
- Use module augmentation to extend the `StylesInterface`:
865
+ Component props are typed from the `tasty()` definition with no setup. Module augmentation adds the names your design system defines and the extensions your plugins add.
866
+
867
+ ### Component props
868
+
869
+ | In `tasty({ … })` | Adds the props |
870
+ | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
871
+ | `styleProps: ['gap', 'padding'] as const` | `gap`, `padding`, each typed like the style: a value or a state map |
872
+ | `modProps: { isLoading: Boolean, size: ['sm', 'md', 'lg'] as const }` | `isLoading?: boolean`, `size?: 'sm' \| 'md' \| 'lg'` (`String` gives `string`, `Number` gives `number`) |
873
+ | `modProps: ['isLoading'] as const` | `isLoading?: ModValue` |
874
+ | `tokenProps: ['progress', 'accentColor'] as const` | `progress?: TokenValue`, `accentColor?: TokenValue` |
875
+ | `variants: { default: {…}, danger: {…} }` | `variant?: 'default' \| 'danger'` |
876
+ | `elements: { Title: 'h3' }` | `Card.Title`, with the `h3` props plus `qa`, `qaVal`, `mods`, `tokens`, `isDisabled`, `isHidden`, `isChecked`, and a `ref` typed as `HTMLHeadingElement`; no `styles` |
877
+ | `as: SomeComponent` | `SomeComponent`'s own props, required ones still required |
878
+
879
+ Write the array forms with `as const`. Without it, `modProps: ['isLoading']` widens to `string[]` and every prop on the component is typed `ModValue`, so an `onClick` handler no longer type-checks. A `modProps` value list without `as const` widens to `string`.
880
+
881
+ `tasty(Base, { … })` keeps `Base`'s prop types and sub-elements, and adds the props and sub-elements its own options above declare. Its `variant` accepts both its own variant names and `Base`'s. See [Extend an existing component](react-api.md#extend-an-existing-component).
882
+
883
+ ### Registering your names and extensions
884
+
885
+ ```ts
886
+ // tasty.d.ts — keep the import: it makes this file a module, so the block
887
+ // below extends '@tenphi/tasty' instead of replacing it.
888
+ import '@tenphi/tasty';
812
889
 
813
- ```tsx
814
- // tasty.d.ts
815
890
  declare module '@tenphi/tasty' {
891
+ interface TastyNamedColors {
892
+ surface: true;
893
+ text: true;
894
+ primary: true;
895
+ }
896
+ interface TastyPresetNames {
897
+ h1: true;
898
+ t2: true;
899
+ }
900
+ interface TastyThemeNames {
901
+ danger: true;
902
+ success: true;
903
+ }
816
904
  interface StylesInterface {
817
- elevation?: string;
818
- gradient?: string;
905
+ stripe?: string;
906
+ }
907
+ interface TastyCustomProps {
908
+ glaze: 'soft' | 'strong' | { tone: string; intensity?: number };
909
+ }
910
+ interface TastyBaseStylePropNames {
911
+ radius: true;
912
+ stripe: true;
819
913
  }
820
914
  }
821
915
  ```
822
916
 
917
+ | Interface | Register | What it types |
918
+ | ------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------ |
919
+ | `TastyNamedColors` | Color token names from `tokens` and `replaceTokens`, without the `#` | Suggestions for `#name` and `#name.50` in `fill`, `color`, and `svgFill` |
920
+ | `TastyPresetNames` | `presets` names | The `preset` style and prop |
921
+ | `TastyThemeNames` | Theme names | The `theme` prop (rendered as `data-theme`) |
922
+ | `StylesInterface` | Style properties added with `handlers` | Their value type in `styles`, `styleProps`, and base style props |
923
+ | `TastyCustomProps` | Props added with `propHandlers` | An optional prop on every `tasty()` component (not on sub-elements) |
924
+ | `TastyBaseStylePropNames` | Names passed to `baseStyleProps` | A prop on every component, typed like the style it names |
925
+
926
+ - The first three add autocomplete, not checking: any other string still type-checks (`preset: 'h9'` compiles). The ESLint plugin is what reports unknown names.
927
+ - In `StylesInterface`, declare the plain value type (`stripe?: string`). Tasty adds state-map support itself, as it does for built-in styles.
928
+ - A custom style name in `styles` type-checks without augmentation, but `styleProps` and `TastyBaseStylePropNames` accept only names in `StylesInterface`. A base style prop name missing from it adds no prop.
929
+ - `TastyCustomProps` types the component prop, not the handler. A prop handler receives `Record<string, unknown>`, so cast inside it (`rest.styles as Styles`).
930
+ - State keys, `$` value tokens, units, and recipe names have no TypeScript types. The ESLint plugin checks them against `tasty.config.ts`.
931
+
932
+ ### `tasty.config.ts`
933
+
934
+ TypeScript augmentation does not reach the linter or the editor. [`@tenphi/eslint-plugin-tasty`](https://github.com/tenphi/eslint-plugin-tasty) and the Tasty VS Code extension read a `tasty.config.ts` (or `.js`, `.json`) at the project root instead. It only lists names: it is not passed to `configure()`, and it is unrelated to the Babel plugin's `configFile` (such as `tasty-zero.config.ts`).
935
+
936
+ ```ts
937
+ // tasty.config.ts
938
+ import type { TastyExtensionConfig } from '@tenphi/tasty';
939
+ import type { TastyValidationConfig } from '@tenphi/eslint-plugin-tasty';
940
+
941
+ export default {
942
+ tokens: ['#surface', '#text', '#primary', '$sidebar-width'],
943
+ units: ['cols'],
944
+ states: ['@mobile', '@dark'],
945
+ presets: ['h1', 't2'],
946
+ recipes: ['card', 'elevated'],
947
+ styles: ['stripe'],
948
+ importSources: ['@my-org/ui'],
949
+ presetDescriptions: { h1: 'Heading 1 (32px, bold)' },
950
+ } satisfies TastyExtensionConfig & TastyValidationConfig;
951
+ ```
952
+
953
+ `TastyExtensionConfig` from `@tenphi/tasty` types the fields the VS Code extension reads: `extends`, `tokens`, `units`, `functions`, `states`, `presets`, `styles`, `presetDescriptions`, and `stateDescriptions`. It has no `recipes`, `importSources`, `ownedSources`, or `styleFunctions`, so annotating the file with it alone rejects those ESLint fields; intersect it with the plugin's `TastyValidationConfig`, as above. An omitted list is not checked; `tokens: false`, `units: false`, or `functions: false` turns a check off even when an `extends` parent sets it.
954
+
955
+ Keep it in step with `configure()`: token names with their `#` or `$`, custom units, parse-function names, state aliases, presets, recipes, and custom style names.
956
+
823
957
  See [Style DSL](dsl.md) for state maps, tokens, units, and extending semantics, and [React API](react-api.md) for `tasty()`, style functions, and component props.
package/docs/debug.md CHANGED
@@ -6,9 +6,7 @@ Runtime CSS inspection and diagnostics for the Tasty styling system. Inspect inj
6
6
 
7
7
  ## Overview
8
8
 
9
- `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use but can be manually installed in production for debugging.
10
-
11
- In development mode (`isDevEnv()` returns `true`), `tastyDebug` is automatically installed on `window.tastyDebug`. In production, install it manually when needed.
9
+ `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use and can be installed on `window` explicitly when needed.
12
10
 
13
11
  All methods **log to the console by default**. Pass `{ raw: true }` to suppress logging and only return data.
14
12
 
@@ -19,7 +17,6 @@ All methods **log to the console by default**. Pass `{ raw: true }` to suppress
19
17
  ## Quick Start
20
18
 
21
19
  ```typescript
22
- // Auto-installed in dev mode. Otherwise:
23
20
  import { tastyDebug } from '@tenphi/tasty';
24
21
  tastyDebug.install();
25
22
 
@@ -54,6 +51,19 @@ interface DebugOptions {
54
51
 
55
52
  When `raw` is `false` (the default), results are logged to the console **and** returned. When `raw` is `true`, results are returned silently.
56
53
 
54
+ ### Environments Without a DOM
55
+
56
+ `tastyDebug` reads the document, so on a server — SSR, a Node REPL, a test
57
+ runner in the `node` environment — there is nothing for it to read. Every
58
+ method returns its empty result (`''`, an empty `InspectResult`, a summary of
59
+ zeroes, `metrics: null`) instead of throwing, and explains itself once with a
60
+ console warning. `{ raw: true }` suppresses that warning along with the rest of
61
+ the logging.
62
+
63
+ To see the styles a server render produced, read the `ServerStyleCollector`
64
+ instead — `collector.getCSS()` and `collector.getRenderedClassNames()`. See
65
+ [SSR](./ssr.md).
66
+
57
67
  ---
58
68
 
59
69
  ## API Reference
@@ -68,7 +78,7 @@ Retrieves CSS text for a given target. Logs the result with rule count and size.
68
78
  |---|---|
69
79
  | `'all'` | All tasty CSS (component + global + raw) |
70
80
  | `'active'` | CSS for classes currently in the DOM |
71
- | `'unused'` | CSS with refCount = 0 (cached but not used) |
81
+ | `'unused'` | CSS for classes `gc({ force: true })` would delete now — not rendered, not pinned, past the `gc.grace` window |
72
82
  | `'global'` | Only global CSS (from `injectGlobal`) |
73
83
  | `'page'` | All CSS on the page (including non-tasty) |
74
84
  | `'t3a5f'` | CSS for a specific tasty class (class names are `t` + base36 hash) |
@@ -144,7 +154,8 @@ One-shot overview of the entire Tasty CSS state. Logs a compact report.
144
154
  ```typescript
145
155
  interface Summary {
146
156
  activeClasses: string[];
147
- unusedClasses: string[];
157
+ unusedClasses: string[]; // classes gc({ force: true }) would delete now
158
+ hotClasses: string[]; // not rendered, but pinned or inside gc.grace — not yet collectable
148
159
  totalStyledClasses: string[];
149
160
 
150
161
  activeCSSSize: number;
@@ -241,7 +252,9 @@ tastyDebug.cache();
241
252
 
242
253
  ### `cleanup(opts?): void`
243
254
 
244
- Forces immediate cleanup of all unused styles (those with `refCount = 0`).
255
+ Removes every injected style that is neither carried by an element nor pinned by
256
+ an outstanding `inject()` handle — the same set `summary()` reports as unused.
257
+ Equivalent to `gc({ force: true })`.
245
258
 
246
259
  ```typescript
247
260
  tastyDebug.cleanup();
@@ -262,7 +275,7 @@ tastyDebug.help();
262
275
 
263
276
  ### `install(): void`
264
277
 
265
- Attaches `tastyDebug` to `window.tastyDebug`. Called automatically in development mode.
278
+ Attaches `tastyDebug` to `window.tastyDebug`.
266
279
 
267
280
  ```typescript
268
281
  import { tastyDebug } from '@tenphi/tasty';