@tenphi/tasty 0.0.0-snapshot.b2ad8a7 → 0.0.0-snapshot.b317d64

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 (119) hide show
  1. package/README.md +6 -6
  2. package/dist/babel-types-C_7kRP38.d.ts +18 -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-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/{collector-DCI2yzwx.js → chunks/collector-DqcB0UUT.js} +25 -119
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  12. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-Dy36S1sU.js +502 -0
  16. package/dist/chunks/debug-Dy36S1sU.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.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-BljxMd6C.js +582 -0
  22. package/dist/chunks/react-runtime-BljxMd6C.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CPYI2bA8.js +2415 -0
  24. package/dist/chunks/runtime-engine-CPYI2bA8.js.map +1 -0
  25. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  26. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  27. package/dist/{merge-styles-CzVxdtav.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  30. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  31. package/dist/{css-writer-Cq0fg5v8.js → chunks/zero-engine-b--JCZad.js} +51 -146
  32. package/dist/chunks/zero-engine-b--JCZad.js.map +1 -0
  33. package/dist/{collector-CQDeU7WS.d.ts → collector-w4mBj5gd.d.ts} +23 -4
  34. package/dist/{config-CwRr6-fG.d.ts → config-CrZOfNJ5.d.ts} +110 -96
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-C0W21Qcb.d.ts → index-CYJtAI9a.d.ts} +243 -281
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -998
  40. package/dist/{merge-styles-Bpwfy1CS.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
  41. package/dist/ssr/astro-client.d.ts +1 -1
  42. package/dist/ssr/astro-client.js +1 -14
  43. package/dist/ssr/astro-client.js.map +1 -1
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +3 -2
  51. package/dist/ssr/astro-middleware-static.js +0 -11
  52. package/dist/ssr/astro-middleware-static.js.map +1 -1
  53. package/dist/ssr/astro-middleware.d.ts +3 -2
  54. package/dist/ssr/astro-middleware.js +0 -12
  55. package/dist/ssr/astro-middleware.js.map +1 -1
  56. package/dist/ssr/astro.d.ts +40 -6
  57. package/dist/ssr/astro.js +157 -93
  58. package/dist/ssr/astro.js.map +1 -1
  59. package/dist/ssr/index.d.ts +10 -11
  60. package/dist/ssr/index.js +4 -4
  61. package/dist/ssr/index.js.map +1 -1
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +134 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +9 -8
  66. package/dist/ssr/next.js +29 -43
  67. package/dist/ssr/next.js.map +1 -1
  68. package/dist/static/index.d.ts +8 -9
  69. package/dist/static/index.js +4 -22
  70. package/dist/static/index.js.map +1 -1
  71. package/dist/static/inject.d.ts +1 -2
  72. package/dist/{index-DpykQKO8.d.ts → types-JEY8PVYP.d.ts} +986 -972
  73. package/dist/zero/babel.d.ts +67 -2
  74. package/dist/zero/babel.js +57 -131
  75. package/dist/zero/babel.js.map +1 -1
  76. package/dist/zero/index.d.ts +44 -8
  77. package/dist/zero/index.js +24 -2
  78. package/dist/zero/index.js.map +1 -0
  79. package/dist/zero/next.d.ts +4 -5
  80. package/dist/zero/next.js +0 -31
  81. package/dist/zero/next.js.map +1 -1
  82. package/docs/ai-agents.md +31 -5
  83. package/docs/configuration.md +18 -2
  84. package/docs/debug.md +15 -5
  85. package/docs/dsl.md +56 -8
  86. package/docs/getting-started.md +13 -11
  87. package/docs/injector.md +21 -7
  88. package/docs/methodology.md +5 -5
  89. package/docs/pipeline.md +34 -10
  90. package/docs/plugins.md +1 -1
  91. package/docs/react-api.md +9 -0
  92. package/docs/runtime-benchmarks.md +282 -110
  93. package/docs/ssr.md +179 -20
  94. package/docs/styles.md +89 -19
  95. package/docs/tasty-static.md +34 -1
  96. package/package.json +101 -36
  97. package/dist/async-storage-DKK-wTD4.js +0 -44
  98. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  99. package/dist/babel-B_P8t-f0.d.ts +0 -83
  100. package/dist/collector-DCI2yzwx.js.map +0 -1
  101. package/dist/config-B97n_EIv.js +0 -12612
  102. package/dist/config-B97n_EIv.js.map +0 -1
  103. package/dist/context-CA8YKeMn.js +0 -24
  104. package/dist/context-CA8YKeMn.js.map +0 -1
  105. package/dist/core-DWrUWxog.js +0 -1645
  106. package/dist/core-DWrUWxog.js.map +0 -1
  107. package/dist/css-writer-Cq0fg5v8.js.map +0 -1
  108. package/dist/format-global-rules-DklyaXv-.js +0 -22
  109. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  110. package/dist/format-rules-Wb7dJOoL.js +0 -130
  111. package/dist/format-rules-Wb7dJOoL.js.map +0 -1
  112. package/dist/hydrate-gFTLBDK9.js +0 -37
  113. package/dist/hydrate-gFTLBDK9.js.map +0 -1
  114. package/dist/index.js.map +0 -1
  115. package/dist/merge-styles-CzVxdtav.js.map +0 -1
  116. package/dist/renderChunk-COXABoQz.js +0 -290
  117. package/dist/renderChunk-COXABoQz.js.map +0 -1
  118. package/dist/resolve-recipes-BnrUEjWV.js +0 -144
  119. package/dist/resolve-recipes-BnrUEjWV.js.map +0 -1
@@ -549,7 +549,23 @@ configure({
549
549
  });
550
550
  ```
551
551
 
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.
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.
553
569
 
554
570
  For how to apply, compose, and override recipes in components, see [Recipes](dsl.md#recipes) in the Style DSL reference.
555
571
 
@@ -615,7 +631,7 @@ configure({
615
631
  });
616
632
  ```
617
633
 
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.
634
+ 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
635
 
620
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).
621
637
 
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
@@ -264,7 +274,7 @@ tastyDebug.help();
264
274
 
265
275
  ### `install(): void`
266
276
 
267
- Attaches `tastyDebug` to `window.tastyDebug`. Called automatically in development mode.
277
+ Attaches `tastyDebug` to `window.tastyDebug`.
268
278
 
269
279
  ```typescript
270
280
  import { tastyDebug } from '@tenphi/tasty';
package/docs/dsl.md CHANGED
@@ -54,6 +54,8 @@ fill: {
54
54
  }
55
55
  ```
56
56
 
57
+ Modifier and class names start with a letter and may be a single letter (`x` → `[data-x]`, `.x`). Tasty emits an `INVALID_STATE_KEY` warning for a key it cannot fully read and skips the unreadable parts. That covers characters outside the notation (`1st`, or `@media (w < 600px)` with a space before the parenthesis), an operator missing a state (`hovered &`), and two states with no operator between them (`hovered focused`). A partly read key can apply in states you did not mean, so fix the key rather than rely on what it produces.
58
+
57
59
  #### Default State Ordering
58
60
 
59
61
  Key order sets priority — later keys win and turn off earlier ones via negation. The bare default (`''`) is the lowest-priority state, so it **must be the first key**. If it appears after other states, Tasty moves it to the front and emits a dev warning (`MISPLACED_DEFAULT_STATE`); otherwise it would override every state above it.
@@ -341,6 +343,26 @@ const ElevatedCard = tasty({
341
343
  });
342
344
  ```
343
345
 
346
+ **Where recipes resolve:**
347
+
348
+ The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
349
+
350
+ ```jsx
351
+ const CardWithPanel = tasty({
352
+ styles: {
353
+ recipe: 'card',
354
+ Panel: {
355
+ recipe: 'card elevated',
356
+ padding: '2x', // Overrides the panel's base recipe padding
357
+ },
358
+ },
359
+ });
360
+ ```
361
+
362
+ At each level, base recipes are collected in name order (later recipes replace earlier values for the same property), then local styles are merged, then post recipes are merged. The merges with local styles and post recipes follow the [state-map extension and replacement rules](#extending-vs-replacing-state-maps).
363
+
364
+ Recipe definitions themselves cannot contain a `recipe` reference to another recipe: there is no recursive expansion or recipe inheritance. Compose names in the root or sub-element `recipe` property instead. See [Configuration — Recipes](configuration.md#recipes) for an unsupported nesting example.
365
+
344
366
  **Post-merge recipes (`/` separator):**
345
367
 
346
368
  Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
@@ -499,6 +521,8 @@ fill: {
499
521
 
500
522
  Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
501
523
 
524
+ Units are only converted in features that take a length: `width`, `height`, `inline-size`, and `block-size`, with or without `min-`/`max-` (`@media(min-width: 40x)` converts too). Every other feature keeps its value as written, so `@media(min-resolution: 2x)` and `@media(resolution >= 2x)` reach the browser unchanged: there `x` is CSS's own resolution unit, an alias of `dppx`.
525
+
502
526
  In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
503
527
 
504
528
  ### `@(...)` — Container Queries
@@ -536,13 +560,16 @@ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which map
536
560
 
537
561
  ### `@supports(...)` — Feature Queries
538
562
 
539
- Feature queries test CSS property support. Use `$` as the first argument to test selector support:
563
+ Feature queries test CSS property support and accept CSS support functions such
564
+ as `at-rule()`. Use `$` as the first argument to test selector support:
540
565
 
541
- | Tasty syntax | CSS output |
542
- | --------------------------- | --------------------------------- |
543
- | `@supports(display: grid)` | `@supports (display: grid)` |
544
- | `@supports($, :has(*))` | `@supports selector(:has(*))` |
545
- | `!@supports(display: grid)` | `@supports (not (display: grid))` |
566
+ | Tasty syntax | CSS output |
567
+ | ---------------------------- | ---------------------------------- |
568
+ | `@supports(display: grid)` | `@supports (display: grid)` |
569
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
570
+ | `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
571
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
572
+ | `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
546
573
 
547
574
  ```jsx
548
575
  display: {
@@ -551,6 +578,25 @@ display: {
551
578
  }
552
579
  ```
553
580
 
581
+ `at-rule()` tests whether the browser supports the named at-rule. Its surrounding
582
+ parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
583
+ other states use the same syntax as property queries:
584
+
585
+ ```jsx
586
+ color: {
587
+ _: 'red',
588
+ '@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
589
+ }
590
+ ```
591
+
592
+ Use `_` to keep a base value when a browser cannot evaluate a query. A support
593
+ query only detects a browser feature; it does not add an API for authoring the
594
+ queried at-rule in a Tasty style object. For conditional stylesheet imports such
595
+ as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
596
+ stylesheet or document-level `useRawCSS()`. Put imports before other rules in
597
+ that stylesheet. Imports cannot be used in constructable stylesheets, including
598
+ Tasty's adopted-sheet mode for Shadow DOM.
599
+
554
600
  ### `_` — Fallback Floor
555
601
 
556
602
  By default Tasty makes states **mutually exclusive**: a higher-priority state
@@ -701,7 +747,7 @@ const FadeIn = tasty({
701
747
  styles: {
702
748
  opacity: { '': '1', '@starting': '0' },
703
749
  transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
704
- transition: 'opacity 0.3s, translate 0.3s',
750
+ transition: 'opacity, translate',
705
751
  },
706
752
  });
707
753
  ```
@@ -821,6 +867,8 @@ const Pulse = tasty({
821
867
  });
822
868
  ```
823
869
 
870
+ Keyframes names are case-sensitive and keep their authored case in `animation` and `animationName` (`fadeIn`, not `fadein`), so they match `@keyframes` defined here, in `configure({ keyframes })`, or in plain CSS. Everything else in the value — durations, timing functions, keywords — is parsed as usual.
871
+
824
872
  ---
825
873
 
826
874
  ## Properties (`@property`)
@@ -833,7 +881,7 @@ const AnimatedGradient = tasty({
833
881
  '$gradient-angle': '0deg',
834
882
  '#theme': 'okhst(280 80% 50%)',
835
883
  image: 'linear-gradient($gradient-angle, #theme, #clear)',
836
- transition: '$$gradient-angle 0.3s, ##theme 0.3s',
884
+ transition: '$$gradient-angle, ##theme',
837
885
  },
838
886
  });
839
887
  ```
@@ -169,20 +169,22 @@ export default [
169
169
 
170
170
  ### What `recommended` catches
171
171
 
172
- The `recommended` config enables 18 of the plugin's 27 total rules. It covers the most common issues without turning on the stricter governance rules:
173
-
174
- | Category | Rules | Examples |
175
- | ------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
176
- | Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element` | Flags typos like `pading` or invalid boolean usage |
177
- | Value validation | `valid-value`, `valid-color-token`, `valid-custom-unit` | Catches `#nonexistent` tokens, bad unit syntax |
178
- | State validation | `valid-state-key`, `no-nested-state-map`, `require-default-state` | Validates state key syntax, ensures `''` default exists |
179
- | Structure | `valid-styles-structure`, `no-important`, `no-nested-selector` | Prevents `!important`, invalid nesting |
180
- | Static mode | `static-no-dynamic-values`, `static-valid-selector` | Enforces build-time constraints in `tastyStatic()` |
181
- | Style properties | `valid-preset`, `valid-recipe`, `valid-transition`, `valid-directional-modifier`, `valid-radius-shape` | Validates preset names, recipe references, transition syntax |
172
+ The `recommended` config covers common correctness and style issues:
173
+
174
+ | Category | Rules | Examples |
175
+ | ------------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
176
+ | Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element` | Flags typos like `pading` or invalid boolean usage |
177
+ | Value validation | `valid-value`, `valid-color-token`, `valid-custom-unit` | Catches `#nonexistent` tokens, bad unit syntax |
178
+ | State validation | `valid-state-key`, `no-nested-state-map`, `require-default-state` | Validates state key syntax, ensures `''` default exists |
179
+ | Structure | `valid-styles-structure`, `no-important`, `no-nested-selector` | Prevents `!important`, invalid nesting |
180
+ | Static mode | `static-no-dynamic-values`, `static-valid-selector` | Enforces build-time constraints in `tastyStatic()` |
181
+ | Style properties | `valid-preset`, `valid-recipe`, `valid-transition`, `valid-directional-modifier`, `valid-radius-shape` | Validates preset names, recipe references, transition syntax |
182
+ | Motion guidance | `no-raw-transition-duration` | Suggests timing tokens or the default timing for transition durations |
183
+ | Dynamic styles | `no-runtime-styles-mutation`, `no-style-spread` | Warns on JavaScript values and spreads inside runtime style objects |
182
184
 
183
185
  ### Strict config
184
186
 
185
- For stricter governance, use `tasty.configs.strict`. It adds rules that enforce best practices like preferring shorthand properties, consistent token usage, and flagging direct `styles` prop usage:
187
+ For stricter governance, use `tasty.configs.strict`. It adds rules that flag direct `styles` prop usage and other patterns:
186
188
 
187
189
  ```js
188
190
  export default [tasty.configs.strict];
package/docs/injector.md CHANGED
@@ -251,11 +251,26 @@ Dispose, ref-counted cleanup and GC therefore behave identically in every mode.
251
251
  - Most options have sensible defaults and auto-detection
252
252
  - `configure()` is optional - the injector works with defaults
253
253
  - **Configuration is locked after styles are generated** - calling `configure()` after first render will emit a warning and be ignored
254
- - `gc.releaseInterval`: Number of releases between collection passes. A component unmounting releases one entry per chunk it carried. When the counter reaches this value, a pass is scheduled via `requestIdleCallback`.
254
+ - `gc.touchInterval`: Number of renders between sweeps. When the counter reaches this value, a sweep is scheduled via `requestIdleCallback`; without idle callbacks nothing is collected automatically.
255
+ - `gc.grace`: How long a class is left alone after collection first notices nothing is carrying it, in milliseconds (default `10000`).
255
256
 
256
- > **Why collecting early is safe.** Rendering is not commit-aware: a concurrent render can yield between the render that names a class and the commit that mounts it, for any number of turns, and from outside React that is indistinguishable from a class that is finished. So collection does not try to tell them apart. A managed render writes nothing to a sheet — it resolves the class name and records the CSS it stands for — and the component's insertion effect inserts it on commit, re-creating anything that was collected in the meantime, before any layout effect runs. Deleting a rule early costs a re-insert, never a missing style.
257
+ **What a sweep does.** Everything the injector holds falls into one of five bands, and only the last is ever deleted:
258
+
259
+ | Band | | Deleted |
260
+ |---|---|---|
261
+ | 1 | **Rendered** — some element carries the class right now | never |
262
+ | 2 | **Not ours** — queued for a batched write, pre-allocated, or server-rendered | never |
263
+ | 3 | **Hot** — nothing carries it, but that was noticed less than `grace` ago | never |
264
+ | 4 | **Cached** — cold, but within `capacity` when ordered by when it went cold | never |
265
+ | 5 | Everything else | on every sweep |
266
+
267
+ `gc({ force: true })` and `cleanup()` take bands 4 and 5 together, ignoring capacity. Band 3 is spared even then: an explicit cleanup is still no reason to take rules from a render that has not committed yet.
268
+
269
+ > **Why band 3 exists.** Rendering is not commit-aware: a render can resolve a class and commit it a little later, and in between nothing on the page carries it. From outside React that is indistinguishable from a class that is finished, so collection does not try to tell them apart — it leaves alone anything only just noticed to be cold. A render would have to stay pending for the whole window to lose its rules, and it gets them back on its next render.
270
+ >
271
+ > The clock starts when a sweep *notices*, not when the element actually left — nothing observes that moment, so starting it at the sighting is what gives every class the same full window however long ago it went.
257
272
  >
258
- > A bare `computeStyles()` has no commit to put its rules back, so it injects during the call and pins the class: never collected, and unaffected by any of this.
273
+ > This is also why collection costs nothing to run: the timestamps are written by the sweep's own DOM scan, so rendering tracks nothing per class.
259
274
  - `gc.capacity`: Maximum number of unused styles (not in the DOM, not pinned) to retain. When exceeded, the least recently used are evicted first. Rendered and pinned styles don't count against this limit.
260
275
 
261
276
  ---
@@ -388,10 +403,9 @@ gc({ force: true });
388
403
  // cleanup() is the same thing:
389
404
  cleanup();
390
405
 
391
- // Collection follows React commits. A styled component takes up its classes in
392
- // useInsertionEffect when it mounts and gives them back when it unmounts; every
393
- // `releaseInterval` releases, a pass runs in idle time and deletes whatever is
394
- // still unheld, keeping the `capacity` most recently released.
406
+ // Every `touchInterval` renders, a sweep is scheduled in idle time. It scans
407
+ // the DOM for the classes actually on the page and sorts everything the
408
+ // injector holds into five bands — only the last one is deleted. See below.
395
409
 
396
410
  // Benefits:
397
411
  // - Activity-proportional: busy apps trigger GC more often
@@ -122,10 +122,10 @@ Tasty exports predefined style prop lists that group properties by role. Use the
122
122
  | Preset | Properties | Typical use |
123
123
  | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
124
124
  | `FLOW_STYLES` | flow, gap, columnGap, rowGap, align, justify, placeItems, placeContent, alignItems, alignContent, justifyItems, justifyContent, gridColumns, gridRows, gridTemplate, gridAreas | Layout containers (`Space`, `Grid`) |
125
- | `POSITION_STYLES` | gridArea, gridColumn, gridRow, order, placeSelf, alignSelf, justifySelf, zIndex, margin, inset, position | Positioned elements (`Button`, `Badge`) |
126
- | `DIMENSION_STYLES` | width, height, flexBasis, flexGrow, flexShrink, flex | Sized elements |
125
+ | `POSITION_STYLES` | gridArea, gridColumn, gridRow, order, placeSelf, alignSelf, justifySelf, zIndex, physical/logical margin, inset, scroll margin/padding, position | Positioned elements (`Button`, `Badge`) |
126
+ | `DIMENSION_STYLES` | width, height, blockSize, inlineSize, flexBasis, flexGrow, flexShrink, flex | Sized elements |
127
127
  | `COLOR_STYLES` | color, fill, fade, image | Color-customizable elements |
128
- | `BLOCK_STYLES` | padding, paddingInline, paddingBlock, overflow, scrollbar, textAlign, border, radius, shadow, outline | Block-level containers |
128
+ | `BLOCK_STYLES` | padding, blockPadding, inlinePadding, overflow, scrollbar, textAlign, border, blockBorder, inlineBorder, radius, shadow, outline | Block-level containers |
129
129
  | `CONTAINER_STYLES` | All of the above combined (+ BASE_STYLES) | Fully flexible containers |
130
130
  | `OUTER_STYLES` | POSITION_STYLES + DIMENSION_STYLES + block outer (border, radius, shadow, outline) | Components whose outer shell is customizable |
131
131
  | `INNER_STYLES` | BASE_STYLES + COLOR_STYLES + block inner (padding, overflow, scrollbar) + FLOW_STYLES | Components whose inner layout is customizable |
@@ -236,7 +236,7 @@ const ProgressBar = tasty({
236
236
  width: '$progress',
237
237
  height: '100%',
238
238
  fill: '#primary',
239
- transition: 'width 0.3s',
239
+ transition: 'width',
240
240
  },
241
241
  },
242
242
  elements: { Bar: 'div' },
@@ -534,7 +534,7 @@ See [Configuration](configuration.md) for the full `configure()` API.
534
534
 
535
535
  - **Create styled wrappers** instead of passing `styles` directly — faster, composable, inspectable
536
536
  - **Use design tokens and custom units** (`#text`, `2x`, `1r`) instead of raw CSS values
537
- - **Use semantic transition names** (`transition: 'theme 0.3s'`) instead of listing CSS properties
537
+ - **Use semantic transition names** (`transition: 'theme'`) instead of listing CSS properties; omit the duration to use the motion tokens
538
538
  - **Use `elements` prop** to declare typed sub-components for compound components
539
539
  - **Use `styleProps`** to define what product engineers can customize
540
540
  - **Use `modProps`** to expose known modifier states as clean component props
package/docs/pipeline.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This document describes the style rendering pipeline that transforms style objects into CSS rules. The pipeline ensures that each style value is applied to exactly one condition through exclusive condition building, boolean simplification, and intelligent CSS generation.
4
4
 
5
- **Implementation:** [`src/pipeline/`](../src/pipeline/) — TypeScript file names below are relative to that directory.
5
+ **Implementation:** [`src/pipeline/`](https://github.com/tenphi/tasty/tree/main/src/pipeline) — TypeScript file names below are relative to that directory.
6
6
 
7
7
  ## Overview
8
8
 
@@ -86,18 +86,22 @@ Output: CSSRule[]
86
86
 
87
87
  ### What It Does
88
88
 
89
- Runs on each style's value map **before** any parsing. If a compound AND state key shares a value with the "atom absent" variant, the atom is a don't-care and every key is simplified by dropping it. Duplicate keys collapse.
89
+ Runs on each style's value map **before** any parsing, when the map has at least three keys and one of them uses `&`. An atom is a **don't-care** when flipping it never changes which value the map resolves to; every key that mentions a don't-care atom is dropped.
90
90
 
91
91
  ### How It Works
92
92
 
93
- 1. Gather the unique set of top-level AND atoms across all keys.
94
- 2. An atom is **redundant** when every entry that contains it has a same-value partner with the atom absent and the rest of the atoms identical.
95
- 3. Keys containing `|`, `^`, or `,` at top level are treated as opaque single atoms (they don't participate in atom-level extraction).
96
- 4. Drop redundant atoms from every key; collapse duplicates.
93
+ 1. Split each key into its top-level `&` atoms. Keys containing `|`, `^`, or `,` at top level are a single opaque atom. The `_` floor (and a misused `_` key) is kept verbatim and left out of the analysis.
94
+ 2. Treat the map as the cascade it is: the last authored key whose atoms all hold wins, and `''` is always the lowest priority.
95
+ 3. An atom is a don't-care when, in every state, the cascade resolves to the same value with the atom present as with it absent. Only the states `(K₁ minus the atom) ∪ K₀`, for every key `K₁` that contains the atom and every key `K₀` that does not (or none), can tell the two apart, so the check is quadratic in the number of keys rather than exponential in atoms.
96
+ 4. Drop every key that contains a don't-care atom. With the atom forced absent those keys never match, and by definition the result is unchanged.
97
+
98
+ The check is over the cascade, not over pairs of keys. In `{ '': A, checked: B, 'invalid & checked': C, disabled: A }`, `disabled` has the default's value, but it outranks `checked`: a checked, disabled element gets `A`, so `disabled` is not a don't-care. (An earlier pairwise rule — "every key with the atom has a same-value partner without it" — folded `disabled` into `''` here and lost that priority.)
99
+
100
+ Atoms are compared as strings and treated as independent. Real atoms can be related (`theme=dark` vs `theme=light`, nested media ranges); that only rules states out, so a don't-care over independent atoms is one for every real state too. Two guards keep the rewrite safe: a map with more than 32 distinct atoms is left unreduced, and a reduction that would leave the `_` floor alone with `''` (which means "use the floor", see Stage 1) is skipped.
97
101
 
98
102
  ### Why
99
103
 
100
- Removing don't-care dimensions before parsing prevents combinatorial blowup in later stages. `mergeEntriesByValue`, `buildExclusiveConditions`, and materialization all see fewer entries and fewer spurious conditions. Implemented as part of the Apr 2026 fix for overlapping CSS rules (commit 7cd9dbe).
104
+ Removing don't-care dimensions before parsing prevents combinatorial blowup in later stages. `mergeEntriesByValue`, `buildExclusiveConditions`, and materialization all see fewer entries and fewer spurious conditions.
101
105
 
102
106
  ### Example
103
107
 
@@ -197,6 +201,8 @@ The merge is safe iff for every entry `e_m` strictly between them in priority wi
197
201
 
198
202
  i.e. there is no scenario where the intermediate state could have matched, the lower same-value entry would also have matched, and the higher one would not. This is the only way the merge could leak through and shadow the intermediate state.
199
203
 
204
+ An intermediate whose condition always holds (a tautological key, or same-value keys that already merged into one, like `beta | !beta`) is checked like any other. Only the `''` default and the `_` floor are exempt from the check, and they are always the lowest priorities, so they are never intermediates.
205
+
200
206
  ### Why
201
207
 
202
208
  Without this pass a value map like `{ '@dark': 'red', '@dark & @hc': 'red' }` would create two separate entries that later produce two CSS rules with identical output. Merging before exclusive building keeps the exclusive condition algebra small and avoids duplicate CSS. The safety check ensures we never break the cascade in service of this optimization.
@@ -293,7 +299,9 @@ B: B & !A (applies only when A doesn't)
293
299
  C: C & !A & !B (applies only when neither A nor B)
294
300
  ```
295
301
 
296
- Each exclusive condition is passed through `simplifyCondition`. Entries that simplify to `FALSE` (impossible) are filtered out. The default state (`''` → `TrueCondition`) is not added to the “prior” list for negation (see `buildExclusiveConditions`).
302
+ Each exclusive condition is passed through `simplifyCondition`. Entries that simplify to `FALSE` (impossible) are filtered out.
303
+
304
+ Every entry is added to the "prior" list, including one whose condition is `TRUE`. That can be a tautological key, or same-value keys that merged into one in Stage 1b (`alpha: X, '!alpha': X` → `TRUE`). Such an entry always applies at its priority, so negating it correctly makes every lower entry `FALSE`. The bare `''` default is `TRUE` too, but it is always the lowest priority, so no entry comes after it.
297
305
 
298
306
  ### `_` fallback floor
299
307
 
@@ -383,7 +391,7 @@ The pre-build Stage 2a pass doesn't need this because user-authored ORs aren't p
383
391
 
384
392
  ### Example (conceptual)
385
393
 
386
- See the comment block in `exclusive.ts:500-523`: a default value whose higher-priority sibling is `@supports(...) & :has(...)` gets an exclusive of `!@supports | !:has`. Expansion yields one branch under `@supports (not ...)` and another under `@supports (...) { :not(:has()) }` instead of a bare `:not(:has())` rule.
394
+ See the comment block on `expandExclusiveOrs` in `exclusive.ts`: a default value whose higher-priority sibling is `@supports(...) & :has(...)` gets an exclusive of `!@supports | !:has`. Expansion yields one branch under `@supports (not ...)` and another under `@supports (...) { :not(:has()) }` instead of a bare `:not(:has())` rule.
387
395
 
388
396
  ---
389
397
 
@@ -395,6 +403,8 @@ See the comment block in `exclusive.ts:500-523`: a default value whose higher-pr
395
403
 
396
404
  Computes the Cartesian product of all style entries for a handler, creating snapshots of which value each style has for each possible state combination.
397
405
 
406
+ When every input is a direct value rather than a state map, the pipeline skips stages 0–4 and passes one unconditional snapshot directly to the handler. This avoids building exclusive entries and a Cartesian product for ordinary state-free styles.
407
+
398
408
  ### How It Works
399
409
 
400
410
  1. Collect exclusive entries for each style the handler uses
@@ -454,6 +464,7 @@ Style handlers encapsulate the logic for translating design tokens (like `'2x'`)
454
464
  ### What It Does
455
465
 
456
466
  Combines rules that have identical CSS output into a single rule with an OR condition.
467
+ Zero- and one-rule inputs return unchanged because no merge is possible.
457
468
 
458
469
  ### How It Works
459
470
 
@@ -511,7 +522,7 @@ Converts condition trees into actual CSS selectors and at-rules.
511
522
  - the flat root modifiers + pseudos and the root element's `:is()`/`:not()` groups are combined into one `:where(...)` (`buildSelectorFromVariant`);
512
523
  - the sub-element (`@own`) groups are wrapped in a **separate** `:where(...)` so the sub-element's structural `[data-element="X"]` specificity is preserved while its states are zeroed;
513
524
  - `@parent` ancestors (`parentGroupsToCSS`) become `:where(... *)` / `:where(:not(... *))`;
514
- - the `@root` context prefix (`rootGroupsToCSS`) becomes `:where(:root...)` (zeroing the `:root` pseudo too).
525
+ - the `@root` context prefix (`rootStateToPrefix`) becomes `:where(:root...)` (zeroing the `:root` pseudo too). When a direct selector can only match the root itself (`:root`, `html`, `:where(:root)`), the state segment joins it instead — `:root:where([data-schema="dark"])` — since an ancestor prefix would ask for a `:root` inside the root.
515
526
 
516
527
  The only specificity anchors that remain are the doubled component class (`.tXX.tXX`, added by the injector) and sub-element `[data-element]` attributes. Because Stage 2b already makes ordinary rules mutually exclusive, zeroing specificity never changes *which* rule matches — it only makes additive layering (`_` fallback floor, `@starting-style`) resolve deterministically by source order (see the post-pass). Canonical sorting/dedup/subsumption still run first; `:where()` is only the final wrapper, and both output paths (injector and direct-selector / SSR) consume the same wrapped fragments.
517
528
 
@@ -739,3 +750,16 @@ Impossible combinations are detected at multiple levels (simplification, variant
739
750
  ### 4. Aggressive Caching
740
751
 
741
752
  Parse, simplify, condition-to-CSS, and full-pipeline results are cached independently, enabling fast re-rendering when only parts of the style object change.
753
+
754
+ Cache keys must respect key order where it carries meaning. A state map resolves by key order, so `{ '': A, checked: B, disabled: C }` and `{ '': A, disabled: C, checked: B }` are different styles and must get different keys (and classes). Only the style keys of a styles object, including a sub-element's, are order-insensitive, so they may be sorted. `stringifyStyles` (pipeline cache) and `generateChunkCacheKey` (class allocation) both follow this rule.
755
+
756
+ ---
757
+
758
+ ## Testing Priority
759
+
760
+ Every stage above is an optimization that must leave one thing unchanged: in any state, the value that applies is the value of the last authored key whose condition holds. `src/test/state-oracle.ts` states that rule directly, with none of the pipeline's machinery, and two suites compare the pipeline against it:
761
+
762
+ - `src/pipeline/exclusive.test.ts` (Node) evaluates the conditions after each of Stages 0–3 on thousands of generated maps, and names the stage that disagrees.
763
+ - `src/pipeline/state-priority.test.ts` (browser) renders hand-written, permuted, and generated maps to CSS, applies every combination of states (modifiers, value modifiers, `:has()`, `@root`, `@parent`, `@own`, media, supports), and compares what the browser computes against the oracle. It also checks that rules stay mutually exclusive, which a correct computed value alone can hide. It runs through the pipeline, the runtime injector, and the SSR collector, with all maps mounted at once so a cache-key collision shows up.
764
+
765
+ A change to any stage should keep both green. When a generated map fails, the message includes the map, the failing states, and the CSS; the map is usually worth adding to the hand-written cases once it is reduced.
package/docs/plugins.md CHANGED
@@ -246,7 +246,7 @@ function glazeStyles(value: GlazeValue): Styles {
246
246
  styles = Object.freeze({
247
247
  '#glaze-bg': `#${tone}.${intensity}`,
248
248
  fill: '#glaze-bg',
249
- transition: 'fill 0.2s',
249
+ transition: 'fill',
250
250
  }) as Styles;
251
251
  cache.set(key, styles);
252
252
  }
package/docs/react-api.md CHANGED
@@ -70,6 +70,8 @@ const Span = tasty({
70
70
 
71
71
  The wrapped component only needs to forward `className` (and ideally `style`/`ref`). Tasty-specific props (`qa`, `qaVal`, `mods`, `tokens`, `styleProps`, `modProps`, `tokenProps`) are consumed by Tasty and never leak to the DOM.
72
72
 
73
+ Props forwarded to the `as` component keep their declared types and requiredness. For example, a component with `position: 'top-right' | 'bottom-left'` accepts those values through `tasty({ as: Component })`; CSS positioning can still be set through `styles.position`. A prop explicitly listed in `styleProps` is consumed as a style value instead. The always-available base style props below are also consumed by Tasty, so keep component-specific prop names separate from those reserved names.
74
+
73
75
  ---
74
76
 
75
77
  ## Style Props
@@ -445,6 +447,13 @@ function ThemeStyles() {
445
447
  }
446
448
  ```
447
449
 
450
+ The selector can be a list (`'.uni-checkbox, uni-checkbox'`) — every item gets
451
+ the states and sub-elements, with no `:is()` wrapping needed. Root states
452
+ (`@root(...)`) on a selector that is the root itself (`:root`, `html`) apply to
453
+ that element. Local `@keyframes` are injected with the rules, under the same
454
+ resolved names `tasty()` components use, and `@starting` states emit
455
+ `@starting-style`.
456
+
448
457
  A slot — the `id`, or the selector when no `id` is given — holds exactly one
449
458
  injection **per `root`**. So:
450
459