@tenphi/tasty 0.0.0-snapshot.89ab060 → 0.0.0-snapshot.8c027cf

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 (276) hide show
  1. package/README.md +118 -244
  2. package/dist/_virtual/_rolldown/runtime.js +1 -2
  3. package/dist/chunks/cacheKey.d.ts +1 -0
  4. package/dist/chunks/cacheKey.js +1 -2
  5. package/dist/chunks/cacheKey.js.map +1 -1
  6. package/dist/chunks/definitions.d.ts +1 -1
  7. package/dist/chunks/definitions.js +2 -3
  8. package/dist/chunks/definitions.js.map +1 -1
  9. package/dist/chunks/index.d.ts +1 -0
  10. package/dist/chunks/renderChunk.d.ts +1 -0
  11. package/dist/chunks/renderChunk.js +1 -2
  12. package/dist/chunks/renderChunk.js.map +1 -1
  13. package/dist/compute-styles.d.ts +31 -0
  14. package/dist/compute-styles.js +357 -0
  15. package/dist/compute-styles.js.map +1 -0
  16. package/dist/config.d.ts +63 -20
  17. package/dist/config.js +85 -48
  18. package/dist/config.js.map +1 -1
  19. package/dist/core/index.d.ts +6 -6
  20. package/dist/core/index.js +7 -7
  21. package/dist/counter-style/index.js +51 -0
  22. package/dist/counter-style/index.js.map +1 -0
  23. package/dist/debug.js +1 -2
  24. package/dist/debug.js.map +1 -1
  25. package/dist/font-face/index.js +63 -0
  26. package/dist/font-face/index.js.map +1 -0
  27. package/dist/hooks/index.d.ts +7 -0
  28. package/dist/hooks/useCounterStyle.d.ts +50 -0
  29. package/dist/hooks/useCounterStyle.js +45 -0
  30. package/dist/hooks/useCounterStyle.js.map +1 -0
  31. package/dist/hooks/useFontFace.d.ts +43 -0
  32. package/dist/hooks/useFontFace.js +69 -0
  33. package/dist/hooks/useFontFace.js.map +1 -0
  34. package/dist/hooks/useGlobalStyles.js +5 -11
  35. package/dist/hooks/useGlobalStyles.js.map +1 -1
  36. package/dist/hooks/useKeyframes.js +3 -9
  37. package/dist/hooks/useKeyframes.js.map +1 -1
  38. package/dist/hooks/useProperty.js +3 -9
  39. package/dist/hooks/useProperty.js.map +1 -1
  40. package/dist/hooks/useRawCSS.js +3 -9
  41. package/dist/hooks/useRawCSS.js.map +1 -1
  42. package/dist/hooks/useStyles.d.ts +4 -9
  43. package/dist/hooks/useStyles.js +7 -227
  44. package/dist/hooks/useStyles.js.map +1 -1
  45. package/dist/index.d.ts +9 -7
  46. package/dist/index.js +10 -8
  47. package/dist/injector/index.d.ts +41 -19
  48. package/dist/injector/index.js +49 -19
  49. package/dist/injector/index.js.map +1 -1
  50. package/dist/injector/injector.d.ts +50 -3
  51. package/dist/injector/injector.js +166 -9
  52. package/dist/injector/injector.js.map +1 -1
  53. package/dist/injector/sheet-manager.d.ts +9 -13
  54. package/dist/injector/sheet-manager.js +38 -70
  55. package/dist/injector/sheet-manager.js.map +1 -1
  56. package/dist/injector/types.d.ts +110 -19
  57. package/dist/keyframes/index.js +1 -1
  58. package/dist/parser/classify.js +4 -5
  59. package/dist/parser/classify.js.map +1 -1
  60. package/dist/parser/const.js +30 -3
  61. package/dist/parser/const.js.map +1 -1
  62. package/dist/parser/lru.js +1 -1
  63. package/dist/parser/lru.js.map +1 -1
  64. package/dist/parser/parser.js +1 -2
  65. package/dist/parser/parser.js.map +1 -1
  66. package/dist/parser/tokenizer.js +1 -1
  67. package/dist/parser/tokenizer.js.map +1 -1
  68. package/dist/parser/types.js +1 -1
  69. package/dist/parser/types.js.map +1 -1
  70. package/dist/pipeline/conditions.js +1 -1
  71. package/dist/pipeline/conditions.js.map +1 -1
  72. package/dist/pipeline/exclusive.js +1 -2
  73. package/dist/pipeline/exclusive.js.map +1 -1
  74. package/dist/pipeline/index.d.ts +2 -0
  75. package/dist/pipeline/index.js +58 -20
  76. package/dist/pipeline/index.js.map +1 -1
  77. package/dist/pipeline/materialize.js +1 -3
  78. package/dist/pipeline/materialize.js.map +1 -1
  79. package/dist/pipeline/parseStateKey.js +1 -2
  80. package/dist/pipeline/parseStateKey.js.map +1 -1
  81. package/dist/pipeline/simplify.js +1 -2
  82. package/dist/pipeline/simplify.js.map +1 -1
  83. package/dist/pipeline/warnings.js +1 -1
  84. package/dist/plugins/index.d.ts +2 -0
  85. package/dist/plugins/okhsl-plugin.js +1 -2
  86. package/dist/plugins/okhsl-plugin.js.map +1 -1
  87. package/dist/properties/index.js +2 -3
  88. package/dist/properties/index.js.map +1 -1
  89. package/dist/properties/property-type-resolver.js +1 -2
  90. package/dist/properties/property-type-resolver.js.map +1 -1
  91. package/dist/ssr/astro.js +1 -2
  92. package/dist/ssr/astro.js.map +1 -1
  93. package/dist/ssr/async-storage.js +1 -2
  94. package/dist/ssr/async-storage.js.map +1 -1
  95. package/dist/ssr/collect-auto-properties.js +1 -2
  96. package/dist/ssr/collect-auto-properties.js.map +1 -1
  97. package/dist/ssr/collector.d.ts +17 -0
  98. package/dist/ssr/collector.js +53 -17
  99. package/dist/ssr/collector.js.map +1 -1
  100. package/dist/ssr/format-global-rules.js +1 -1
  101. package/dist/ssr/format-keyframes.js +1 -2
  102. package/dist/ssr/format-keyframes.js.map +1 -1
  103. package/dist/ssr/format-property.js +1 -2
  104. package/dist/ssr/format-property.js.map +1 -1
  105. package/dist/ssr/format-rules.js +8 -5
  106. package/dist/ssr/format-rules.js.map +1 -1
  107. package/dist/ssr/hydrate.js +1 -2
  108. package/dist/ssr/hydrate.js.map +1 -1
  109. package/dist/ssr/index.d.ts +1 -2
  110. package/dist/ssr/index.js +2 -4
  111. package/dist/ssr/index.js.map +1 -1
  112. package/dist/ssr/next.d.ts +1 -3
  113. package/dist/ssr/next.js +10 -7
  114. package/dist/ssr/next.js.map +1 -1
  115. package/dist/ssr/ssr-collector-ref.js +1 -1
  116. package/dist/states/index.js +3 -2
  117. package/dist/states/index.js.map +1 -1
  118. package/dist/static/index.js +1 -2
  119. package/dist/static/inject.d.ts +5 -0
  120. package/dist/static/inject.js +17 -0
  121. package/dist/static/inject.js.map +1 -0
  122. package/dist/static/tastyStatic.js +1 -2
  123. package/dist/static/tastyStatic.js.map +1 -1
  124. package/dist/static/types.js +1 -1
  125. package/dist/styles/border.d.ts +1 -1
  126. package/dist/styles/border.js +30 -24
  127. package/dist/styles/border.js.map +1 -1
  128. package/dist/styles/color.d.ts +1 -1
  129. package/dist/styles/color.js +2 -3
  130. package/dist/styles/color.js.map +1 -1
  131. package/dist/styles/const.js +17 -0
  132. package/dist/styles/const.js.map +1 -0
  133. package/dist/styles/createStyle.js +4 -5
  134. package/dist/styles/createStyle.js.map +1 -1
  135. package/dist/styles/dimension.js +15 -3
  136. package/dist/styles/dimension.js.map +1 -1
  137. package/dist/styles/directional.js +133 -0
  138. package/dist/styles/directional.js.map +1 -0
  139. package/dist/styles/display.d.ts +3 -10
  140. package/dist/styles/display.js +45 -39
  141. package/dist/styles/display.js.map +1 -1
  142. package/dist/styles/fade.d.ts +1 -1
  143. package/dist/styles/fade.js +9 -5
  144. package/dist/styles/fade.js.map +1 -1
  145. package/dist/styles/fill.d.ts +2 -2
  146. package/dist/styles/fill.js +3 -4
  147. package/dist/styles/fill.js.map +1 -1
  148. package/dist/styles/flow.js +1 -1
  149. package/dist/styles/gap.d.ts +1 -1
  150. package/dist/styles/gap.js +4 -3
  151. package/dist/styles/gap.js.map +1 -1
  152. package/dist/styles/height.d.ts +1 -1
  153. package/dist/styles/height.js +1 -2
  154. package/dist/styles/height.js.map +1 -1
  155. package/dist/styles/index.d.ts +0 -1
  156. package/dist/styles/index.js +3 -4
  157. package/dist/styles/index.js.map +1 -1
  158. package/dist/styles/inset.d.ts +1 -29
  159. package/dist/styles/inset.js +19 -135
  160. package/dist/styles/inset.js.map +1 -1
  161. package/dist/styles/list.d.ts +5 -5
  162. package/dist/styles/list.js +4 -2
  163. package/dist/styles/list.js.map +1 -1
  164. package/dist/styles/margin.d.ts +1 -1
  165. package/dist/styles/margin.js +17 -89
  166. package/dist/styles/margin.js.map +1 -1
  167. package/dist/styles/outline.d.ts +1 -1
  168. package/dist/styles/outline.js +6 -16
  169. package/dist/styles/outline.js.map +1 -1
  170. package/dist/styles/padding.d.ts +1 -1
  171. package/dist/styles/padding.js +17 -89
  172. package/dist/styles/padding.js.map +1 -1
  173. package/dist/styles/placement.d.ts +37 -0
  174. package/dist/styles/placement.js +74 -0
  175. package/dist/styles/placement.js.map +1 -0
  176. package/dist/styles/predefined.d.ts +4 -4
  177. package/dist/styles/predefined.js +8 -9
  178. package/dist/styles/predefined.js.map +1 -1
  179. package/dist/styles/preset.d.ts +6 -1
  180. package/dist/styles/preset.js +54 -53
  181. package/dist/styles/preset.js.map +1 -1
  182. package/dist/styles/radius.d.ts +1 -3
  183. package/dist/styles/radius.js +38 -6
  184. package/dist/styles/radius.js.map +1 -1
  185. package/dist/styles/scrollMargin.d.ts +24 -0
  186. package/dist/styles/scrollMargin.js +32 -0
  187. package/dist/styles/scrollMargin.js.map +1 -0
  188. package/dist/styles/scrollbar.d.ts +1 -1
  189. package/dist/styles/scrollbar.js +8 -5
  190. package/dist/styles/scrollbar.js.map +1 -1
  191. package/dist/styles/shadow.d.ts +1 -1
  192. package/dist/styles/shadow.js +4 -3
  193. package/dist/styles/shadow.js.map +1 -1
  194. package/dist/styles/shared.js +17 -0
  195. package/dist/styles/shared.js.map +1 -0
  196. package/dist/styles/transition.d.ts +1 -1
  197. package/dist/styles/transition.js +5 -4
  198. package/dist/styles/transition.js.map +1 -1
  199. package/dist/styles/types.d.ts +70 -14
  200. package/dist/styles/width.d.ts +1 -1
  201. package/dist/styles/width.js +1 -2
  202. package/dist/styles/width.js.map +1 -1
  203. package/dist/tasty.d.ts +46 -893
  204. package/dist/tasty.js +91 -67
  205. package/dist/tasty.js.map +1 -1
  206. package/dist/utils/cache-wrapper.js +1 -2
  207. package/dist/utils/cache-wrapper.js.map +1 -1
  208. package/dist/utils/case-converter.js +1 -1
  209. package/dist/utils/color-math.js +1 -1
  210. package/dist/utils/color-math.js.map +1 -1
  211. package/dist/utils/color-space.js +1 -2
  212. package/dist/utils/color-space.js.map +1 -1
  213. package/dist/utils/colors.js +1 -2
  214. package/dist/utils/colors.js.map +1 -1
  215. package/dist/utils/dotize.js +1 -1
  216. package/dist/utils/dotize.js.map +1 -1
  217. package/dist/utils/filter-base-props.d.ts +1 -1
  218. package/dist/utils/filter-base-props.js +1 -1
  219. package/dist/utils/filter-base-props.js.map +1 -1
  220. package/dist/utils/get-display-name.js +1 -1
  221. package/dist/utils/has-keys.js +1 -1
  222. package/dist/utils/is-dev-env.js +1 -1
  223. package/dist/utils/is-dev-env.js.map +1 -1
  224. package/dist/utils/is-valid-element-type.js +1 -1
  225. package/dist/utils/merge-styles.js +1 -2
  226. package/dist/utils/merge-styles.js.map +1 -1
  227. package/dist/utils/mod-attrs.d.ts +0 -2
  228. package/dist/utils/mod-attrs.js +1 -2
  229. package/dist/utils/mod-attrs.js.map +1 -1
  230. package/dist/utils/process-tokens.d.ts +1 -5
  231. package/dist/utils/process-tokens.js +3 -11
  232. package/dist/utils/process-tokens.js.map +1 -1
  233. package/dist/utils/resolve-recipes.js +1 -2
  234. package/dist/utils/resolve-recipes.js.map +1 -1
  235. package/dist/utils/selector-transform.js +1 -1
  236. package/dist/utils/string.js +1 -1
  237. package/dist/utils/styles.d.ts +1 -3
  238. package/dist/utils/styles.js +2 -5
  239. package/dist/utils/styles.js.map +1 -1
  240. package/dist/utils/typography.js +9 -1
  241. package/dist/utils/typography.js.map +1 -1
  242. package/dist/utils/warnings.js +1 -1
  243. package/dist/zero/babel.d.ts +31 -4
  244. package/dist/zero/babel.js +140 -48
  245. package/dist/zero/babel.js.map +1 -1
  246. package/dist/zero/css-writer.js +1 -2
  247. package/dist/zero/css-writer.js.map +1 -1
  248. package/dist/zero/extractor.js +54 -3
  249. package/dist/zero/extractor.js.map +1 -1
  250. package/dist/zero/index.js +1 -2
  251. package/dist/zero/next.d.ts +12 -0
  252. package/dist/zero/next.js +5 -4
  253. package/dist/zero/next.js.map +1 -1
  254. package/docs/README.md +5 -4
  255. package/docs/adoption.md +6 -4
  256. package/docs/comparison.md +9 -7
  257. package/docs/configuration.md +61 -0
  258. package/docs/design-system.md +26 -3
  259. package/docs/dsl.md +133 -2
  260. package/docs/getting-started.md +11 -9
  261. package/docs/injector.md +33 -18
  262. package/docs/methodology.md +121 -6
  263. package/docs/runtime.md +255 -24
  264. package/docs/ssr.md +22 -50
  265. package/docs/styles.md +45 -23
  266. package/docs/tasty-static.md +89 -0
  267. package/package.json +13 -8
  268. package/dist/ssr/context.d.ts +0 -8
  269. package/dist/ssr/context.js +0 -14
  270. package/dist/ssr/context.js.map +0 -1
  271. package/dist/styles/align.d.ts +0 -15
  272. package/dist/styles/align.js +0 -14
  273. package/dist/styles/align.js.map +0 -1
  274. package/dist/styles/justify.d.ts +0 -15
  275. package/dist/styles/justify.js +0 -14
  276. package/dist/styles/justify.js.map +0 -1
package/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
  <h1 align="center">Tasty</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>The styling engine built for design systems.</strong><br>
9
- Deterministic CSS generation. State-aware DSL. Zero specificity conflicts. Ever.
8
+ <strong>Deterministic styling for stateful component systems.</strong><br>
9
+ A design-system styling engine that compiles component states into mutually exclusive selectors.
10
10
  </p>
11
11
 
12
12
  <p align="center">
@@ -17,23 +17,41 @@
17
17
 
18
18
  ---
19
19
 
20
- Most CSS-in-JS libraries emit rules that compete through cascade and specificity. Tasty emits **mutually exclusive CSS selectors** — for any component state combination, exactly one selector matches each property at a time. No cascade conflicts, no specificity wars, no `!important` escapes. Components compose and extend without breaking each other.
20
+ Tasty is a styling engine for design systems that generates deterministic CSS for stateful components.
21
21
 
22
- That guarantee unlocks a concise, CSS-like DSL where design tokens, custom units, responsive states, container queries, sub-element styling, and theming all compose without surprises — one coherent system that scales from a single component to an enterprise design system.
22
+ It compiles state maps into **mutually exclusive selectors**, so for a given property and component state, one branch wins by construction instead of competing through cascade and specificity.
23
+
24
+ That is the core guarantee: component styling resolves from declared state logic, not from source-order accidents or specificity fights.
25
+
26
+ Tasty fits best when you are building a design system or component library with intersecting states, variants, tokens, sub-elements, responsive rules, and extension semantics that need to stay predictable over time.
27
+
28
+ On top of that foundation, Tasty gives teams a governed styling model: a CSS-like DSL, tokens, recipes, typed style props, sub-elements, and multiple rendering modes.
29
+
30
+ - **New here?** Start with [Comparison](docs/comparison.md) if you are evaluating fit.
31
+ - **Adopting Tasty?** Read the [Adoption Guide](docs/adoption.md).
32
+ - **Want the mechanism first?** Jump to [How It Actually Works](#how-it-actually-works).
33
+ - **Ready to build?** Go to [Getting Started](docs/getting-started.md).
23
34
 
24
35
  ## Why Tasty
25
36
 
26
- - **Deterministic at any scale** — Exclusive selector generation eliminates the entire class of cascade/specificity bugs. Every state combination resolves to exactly one CSS rule per property. Refactor freely. See [How It Actually Works](#how-it-actually-works).
27
- - **AI-friendly by design** — Style definitions are declarative, self-contained, and structurally consistent. AI tools can read, understand, and refactor even advanced state bindings as confidently as a human — because there's no hidden cascade logic or implicit ordering to second-guess.
28
- - **DSL that feels like CSS** — Property names you already know (`padding`, `color`, `display`) with syntax sugar that removes boilerplate. Learn the DSL in minutes, not days. Start with the [Style DSL](docs/dsl.md), then use [Style Properties](docs/styles.md) as the handler reference.
29
- - **CSS properties as normal component props** — `styleProps` lets you expose selected styles as typed React props. Use `<Button placeSelf="end">` or `<Space flow="row" gap="2x">` without extra wrappers, utility classes, or `styles` overrides. The same props also accept state maps, so responsive values work with the same API. See [CSS properties as props](#css-properties-as-props).
30
- - **Design-system native** — Color tokens (`#primary`), spacing units (`2x`), typography presets (`h1`, `t2`), border radius (`1r`), and recipes are first-class primitives, not afterthoughts. Built-in units and standard color values work out of the box, and [Configuration](docs/configuration.md) lets teams define shared conventions on top.
31
- - **Near-complete modern CSS coverage** — Media queries, container queries, `@supports`, `:has()`, `@starting-style`, `@property`, `@keyframes`, etc. Some features that don't fit Tasty's component model (such as `@layer` and `!important`) are intentionally omitted, but real-world use cases are covered almost completely.
32
- - **Runtime, zero-runtime, or SSR — your call** — Use `tasty()` for dynamic React components with runtime injection, `tastyStatic()` with the Babel plugin for zero-runtime CSS extraction, or enable SSR with zero-cost client hydration for Next.js, Astro, or any React framework. Same DSL, same tokens, same output.
33
- - **Only generate what is used** — In runtime mode, Tasty injects CSS on demand for mounted components/variants, so your app avoids shipping style rules for UI states that are never rendered.
34
- - **Runtime performance that holds at scale** — The runtime path is tested against enterprise-scale applications and tuned with multi-level caching, chunk-level style reuse, style garbage collection, and a dedicated injector.
35
- - **Composable and extensible by design** — Extend any component's styles with proper merge semantics, and evolve built-in behavior through configuration and plugins.
36
- - **TypeScript-first** — Full type definitions, module augmentation for custom properties, and autocomplete for tokens, presets, and themes. See [Configuration](docs/configuration.md).
37
+ - **Deterministic composition, not cascade fights** — Stateful styles resolve from the state map you declared, not from selector competition. See [How It Actually Works](#how-it-actually-works).
38
+ - **Built for design-system teams** — Best fit for reusable component systems with complex state interactions.
39
+ - **A governed styling model, not just syntax sugar** — Design-system authors define the styling language product teams consume.
40
+ - **DSL that still feels like CSS** — Familiar property names, less selector boilerplate. Start with the [Style DSL](docs/dsl.md), then use [Style Properties](docs/styles.md) as the handler reference.
41
+
42
+ ### Supporting capabilities
43
+
44
+ - **Typed style props and mod props** — `styleProps` exposes selected CSS properties as typed React props (`<Space flow="row" gap="2x">`); `modProps` does the same for modifier keys (`<Button isLoading size="large">`). Both support state maps and full TypeScript autocomplete. See [Style Props](#style-props) and [Mod Props](#mod-props).
45
+ - **Runtime, SSR, and zero-runtime options** — Use `tasty()` for runtime React components, add SSR integrations when your framework renders that runtime on the server, or use `tastyStatic()` when you specifically want build-time extraction instead of runtime styling.
46
+ - **Broad modern CSS coverage** — Media queries, container queries, `@supports`, `:has()`, `@starting-style`, `@property`, `@keyframes`, and more. Features that do not fit the component model (such as `@layer` and `!important`) are intentionally left out.
47
+ - **Performance and caching** — Runtime mode injects CSS on demand, reuses chunks aggressively, and relies on multi-level caching so large component systems stay practical.
48
+ - **TypeScript-first and AI-friendly** — Style definitions are declarative, structurally consistent, and fully typed, which helps both humans and tooling understand advanced stateful styles without hidden cascade logic.
49
+
50
+ ## Why It Exists
51
+
52
+ Modern component styling becomes fragile when multiple selectors can still win for the same property. Hover, disabled, theme, breakpoint, parent state, and root state rules start competing through specificity and source order.
53
+
54
+ Tasty replaces that competition with explicit state-map resolution. Each property compiles into mutually exclusive branches, so component styling stays deterministic as systems grow. For the full mechanism, jump to [How It Actually Works](#how-it-actually-works).
37
55
 
38
56
  ## Installation
39
57
 
@@ -56,20 +74,15 @@ yarn add @tenphi/tasty
56
74
 
57
75
  ## Start Here
58
76
 
77
+ For the fuller docs map beyond the quick routes above, start here:
78
+
79
+ - **[Comparison](docs/comparison.md)** — read this first if you are evaluating whether Tasty fits your team's styling model
80
+ - **[Adoption Guide](docs/adoption.md)** — understand who Tasty is for, where it fits, and how to introduce it incrementally
59
81
  - **[Getting Started](docs/getting-started.md)** — the canonical onboarding path: install, first component, optional shared `configure()`, ESLint, editor tooling, and rendering mode selection
60
- - **[Docs Hub](docs/README.md)** — choose docs by role and task: runtime, zero-runtime, SSR, design-system authoring, internals, and debugging
82
+ - **[Style rendering pipeline](docs/PIPELINE.md)** — see the selector model behind deterministic style resolution
83
+ - **[Docs Hub](docs/README.md)** — choose docs by role and task: runtime, zero-runtime, runtime SSR integration, design-system authoring, internals, and debugging
61
84
  - **[Methodology](docs/methodology.md)** — the recommended component model and public API conventions for design-system code
62
85
 
63
- ## Choose a Rendering Mode
64
-
65
- | Mode | Entry point | Best for | Trade-off |
66
- |------|-------------|----------|-----------|
67
- | **Runtime** | `@tenphi/tasty` | Interactive apps and design systems | Full feature set; CSS is generated on demand at runtime |
68
- | **Zero-runtime** | `@tenphi/tasty/static` | Static sites, SSG, landing pages | Requires the Babel plugin; no component-level `styleProps` or runtime-only APIs |
69
- | **SSR** | `@tenphi/tasty/ssr/*` | Next.js, Astro, and other streaming React SSR setups | Uses runtime `tasty()` with server-collected CSS and hydration cache transfer |
70
-
71
- All three share the same DSL, tokens, units, and state mappings. See [Getting Started](docs/getting-started.md#choosing-a-rendering-mode), [Zero Runtime](docs/tasty-static.md), and [Server-Side Rendering](docs/ssr.md).
72
-
73
86
  ## Quick Start
74
87
 
75
88
  ### Create a styled component
@@ -82,12 +95,12 @@ const Card = tasty({
82
95
  styles: {
83
96
  display: 'flex',
84
97
  flow: 'column',
85
- padding: '4x',
86
- gap: '2x',
87
- fill: 'okhsl(98% 0.02 255)',
88
- color: 'okhsl(28% 0.03 255)',
89
- border: '1bw solid okhsl(88% 0.02 255)',
90
- radius: '1r',
98
+ padding: '24px',
99
+ gap: '12px',
100
+ fill: 'white',
101
+ color: '#222',
102
+ border: '1px solid #ddd',
103
+ radius: '12px',
91
104
  },
92
105
  });
93
106
 
@@ -95,7 +108,9 @@ const Card = tasty({
95
108
  <Card>Hello World</Card>
96
109
  ```
97
110
 
98
- Every value maps to CSS you'd recognize. This example is intentionally config-free: built-in units work immediately, and standard color values such as `rgb(...)`, `hsl(...)`, named colors, and `okhsl(...)` are all valid without setup. `okhsl(...)` is the recommended choice when you want a design-system-friendly color authoring path from day one.
111
+ Every value maps to CSS you'd recognize. This example is intentionally a simple first contact, not a tour of the whole DSL.
112
+
113
+ When you want a more design-system-shaped authoring model, Tasty also supports built-in units, tokens, recipes, state aliases, and color values such as `okhsl(...)` without extra runtime libraries.
99
114
 
100
115
  Use `configure()` when you want to define shared tokens, state aliases, recipes, or other conventions for your app or design system. For a fuller onboarding path, follow [Getting Started](docs/getting-started.md).
101
116
 
@@ -163,58 +178,28 @@ configure({
163
178
 
164
179
  Use `configure()` once when your app or design system needs shared aliases, tokens, recipes, or parser extensions. Predefined states turn complex selector logic into single tokens, so teams can write `@mobile` instead of repeating media query expressions in every component.
165
180
 
166
- ### CSS properties as props
167
-
168
- With `styleProps`, a component can expose the styles you choose as normal typed props. That means you can adjust layout, spacing, alignment, or positioning right where the component is used, instead of introducing wrapper elements or reaching for a separate styling API.
169
-
170
- This is especially good for prototyping and fast UI iteration: you can shape interfaces quickly, while still staying inside a typed, design-system-aware component API that scales to production.
171
-
172
- ```tsx
173
- import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
174
-
175
- const Space = tasty({
176
- styles: {
177
- display: 'flex',
178
- flow: 'column',
179
- gap: '1x',
180
- },
181
- styleProps: FLOW_STYLES,
182
- });
183
-
184
- const Button = tasty({
185
- as: 'button',
186
- styles: {
187
- padding: '1.5x 3x',
188
- fill: '#primary',
189
- color: '#primary-text',
190
- radius: true,
191
- },
192
- styleProps: POSITION_STYLES,
193
- });
194
- ```
181
+ ### Props as the public API
195
182
 
196
- Now you can compose layout and tweak component positioning directly in JSX:
183
+ `styleProps` exposes selected CSS properties as typed React props, and `modProps` does the same for modifier keys. Together they let design systems define a governed, typed component API without wrapper elements or `styles` overrides:
197
184
 
198
185
  ```tsx
199
186
  <Space flow="row" gap="2x" placeItems="center">
200
- <Title>Dashboard</Title>
201
- <Button placeSelf="end">Add Item</Button>
187
+ <Button isLoading size="large" placeSelf="end">Submit</Button>
202
188
  </Space>
203
189
  ```
204
190
 
205
- The same props also support state maps, so responsive values use the exact same API:
191
+ See [Style Props](#style-props) and [Mod Props](#mod-props) below, or the full reference in [Runtime API](docs/runtime.md#style-props).
206
192
 
207
- ```tsx
208
- <Space
209
- flow={{ '': 'column', '@tablet': 'row' }}
210
- gap={{ '': '2x', '@tablet': '4x' }}
211
- >
212
- <Sidebar />
213
- <Content />
214
- </Space>
215
- ```
193
+ ## Choose a Styling Approach
194
+
195
+ Once you understand the component model, pick the rendering mode that matches your app.
196
+
197
+ | Approach | Entry point | Best for | Trade-off |
198
+ |----------|-------------|----------|-----------|
199
+ | **Runtime** | `@tenphi/tasty` | Interactive apps with reusable stateful components and design systems | Full feature set; CSS is generated on demand at runtime |
200
+ | **Zero-runtime** | `@tenphi/tasty/static` | Static sites, SSG, landing pages | Requires the Babel plugin; no component-level `styleProps` or runtime-only APIs |
216
201
 
217
- Layout components can expose flow props. Buttons can expose positioning props. Each component can offer only the style props that make sense for its role, while still keeping tokens, custom units, and state maps fully typed. This works in runtime `tasty()` components, not in `tastyStatic()`.
202
+ If your framework can execute runtime React code on the server, you can also add **SSR on top of runtime** with `@tenphi/tasty/ssr/*`. This uses the same `tasty()` pipeline, but collects CSS during server rendering and hydrates the cache on the client. That is the model for Next.js, generic React SSR, and Astro islands. See [Getting Started](docs/getting-started.md#choosing-a-rendering-mode), [Zero Runtime](docs/tasty-static.md), and [Server-Side Rendering](docs/ssr.md).
218
203
 
219
204
  ## How It Actually Works
220
205
 
@@ -222,7 +207,7 @@ This is the core idea that makes everything else possible.
222
207
 
223
208
  For the end-to-end architecture — parsing state keys, building exclusive conditions, merging by output, and materializing selectors and at-rules — see **[Style rendering pipeline](docs/PIPELINE.md)**.
224
209
 
225
- Traditional CSS has two structural problems.
210
+ ### The structural problem with normal CSS
226
211
 
227
212
  First, the **cascade** resolves conflicts by specificity and source order: when multiple selectors match, the one with the highest specificity wins, or — if specificity is equal — the last one in source order wins. That makes styles inherently fragile. Reordering imports, adding a media query, or composing components from different libraries can silently break styling.
228
213
 
@@ -235,7 +220,11 @@ A small example makes this tangible. Two rules for a button's background:
235
220
 
236
221
  Both selectors have specificity `(0, 1, 1)`. When the button is hovered **and** disabled, both match — and the last rule in source order wins. Swap the two lines and a hovered disabled button silently turns blue instead of gray. This class of bug is invisible in code review because the logic is correct; only the ordering is wrong.
237
222
 
238
- Second, **authoring selectors that capture real-world state logic is fundamentally hard.** A single state like "dark mode" may depend on a root attribute, an OS preference, or both — each branch needing its own selector, proper negation of competing branches, and correct `@media` nesting. The example below shows the CSS you'd write by hand for just *one* property with *one* state. Scale that across dozens of properties, then add breakpoints and container queries, and the selector logic quickly becomes unmanageable.
223
+ ### Why real state logic is hard to author by hand
224
+
225
+ Authoring selectors that capture real-world state logic is fundamentally hard. A single state like "dark mode" may depend on a root attribute, an OS preference, or both — each branch needing its own selector, proper negation of competing branches, and correct `@media` nesting. The example below shows the CSS you'd write by hand for just *one* property with *one* state. Scale that across dozens of properties, then add breakpoints and container queries, and the selector logic quickly becomes unmanageable.
226
+
227
+ ### What Tasty generates instead
239
228
 
240
229
  Tasty solves both problems at once: **every state mapping compiles into mutually exclusive selectors.**
241
230
 
@@ -280,8 +269,6 @@ Better — but the bare `.t0` default still matches unconditionally. It matches
280
269
 
281
270
  This is just *one* property with *one* state, and getting it right already takes multiple iterations. The correct selectors require negating every other branch — which is exactly what Tasty generates automatically:
282
271
 
283
- Tasty generates the correct version automatically:
284
-
285
272
  ```css
286
273
  /* Branch 1: Explicit dark schema */
287
274
  :root[data-schema="dark"] .t0.t0 {
@@ -308,11 +295,13 @@ Tasty generates the correct version automatically:
308
295
  }
309
296
  ```
310
297
 
298
+ ### What guarantee that gives you
299
+
311
300
  Every rule is guarded by the negation of higher-priority rules. No two rules can match at the same time. No specificity arithmetic. No source-order dependence. Components compose and extend without collisions.
312
301
 
313
- By absorbing selector complexity, Tasty makes advanced CSS patterns practical again — nested container queries, multi-condition `@supports` gates, and combined root-state/media branches. You stay in pure CSS instead of relying on JavaScript workarounds, so the browser can optimize layout, painting, and transitions natively. Tasty doesn't limit CSS; it unlocks its full potential by removing the complexity that held teams back.
302
+ By absorbing selector complexity, Tasty makes advanced CSS patterns practical again — nested container queries, multi-condition `@supports` gates, and combined root-state/media branches. You stay in pure CSS instead of relying on JavaScript workarounds, so the browser can optimize layout, painting, and transitions natively. Tasty keeps the solution in CSS while removing much of the selector bookkeeping that is hard to maintain by hand.
314
303
 
315
- [Try it in the Cube UI Kit Storybook playground →](https://cube-ui-kit.vercel.app/?path=/story/getting-started-tasty-playground--playground)
304
+ [Try it in the playground →](https://tasty.style/playground)
316
305
 
317
306
  ## Capabilities
318
307
 
@@ -370,214 +359,99 @@ fill: {
370
359
 
371
360
  ### Sub-Element Styling
372
361
 
373
- Style inner elements from the parent component definition. No extra components, no CSS leakage:
362
+ Compound components can style inner parts from the parent definition with capitalized keys in `styles` and optional `elements` declarations, producing typed sub-components like `<Card.Title />` instead of separate wrapper components or ad hoc class naming.
374
363
 
375
- ```tsx
376
- const Card = tasty({
377
- styles: {
378
- padding: '4x',
379
- Title: { preset: 'h3', color: '#primary' },
380
- Content: { color: '#text', preset: 't2' },
381
- },
382
- elements: { Title: 'h2', Content: 'div' },
383
- });
364
+ Sub-elements share the root state context by default, so keys like `:hover`, modifiers, root states, and media queries resolve as one coordinated styling block. Use `@own(...)` when a sub-element should react to its own state, and use the `$` selector affix when you need precise descendant targeting.
384
365
 
385
- <Card>
386
- <Card.Title>Heading</Card.Title>
387
- <Card.Content>Body text</Card.Content>
388
- </Card>
389
- ```
366
+ See [Runtime API - Sub-element Styling](docs/runtime.md#sub-element-styling), [Style DSL - Advanced States](docs/dsl.md#advanced-states--prefix), and [Methodology](docs/methodology.md#component-architecture-root--sub-elements).
390
367
 
391
- Sub-elements use `data-element` attributes — no extra class names, no naming conventions.
368
+ ### Style Props
392
369
 
393
- By default, sub-elements participate in the same state context as the root component. That means mappings like `:hover`, `theme=danger`, `[role="button"]`, and other keys are evaluated as one unified block, which keeps styling logic predictable across the whole markup tree.
370
+ `styleProps` exposes selected CSS properties as typed React props. Components control which properties to open up; consumers get layout and composition knobs without `styles` overrides. Supports state maps for responsive values.
394
371
 
395
- Use `@own(...)` when a sub-element should react to its own state instead of the root state context.
372
+ ```tsx
373
+ const Space = tasty({
374
+ styles: { display: 'flex', flow: 'column', gap: '1x' },
375
+ styleProps: FLOW_STYLES,
376
+ });
396
377
 
397
- Class selectors are also supported, but modifiers/pseudo-classes are usually the better default in design-system code.
378
+ <Space flow="row" gap={{ '': '2x', '@tablet': '4x' }}>
379
+ ```
398
380
 
399
- Use the sub-element selector `$` when you need precise descendant targeting to avoid leakage in deeply nested component trees.
381
+ See [Runtime API - Style Props](docs/runtime.md#style-props) and [Methodology - styleProps](docs/methodology.md#styleprops-as-the-public-api).
400
382
 
401
- ### Variants
383
+ ### Mod Props
402
384
 
403
- Variants are designed to keep single-component CSS lean. Instead of generating dozens of static button classes up front, define all versions once and let runtime usage decide what CSS is actually emitted.
385
+ `modProps` exposes modifier keys as typed React props — the modifier equivalent of `styleProps`. Accepts an array of key names or an object with type descriptors (`Boolean`, `String`, `Number`, or enum arrays) for full TypeScript autocomplete.
404
386
 
405
387
  ```tsx
406
388
  const Button = tasty({
407
- styles: { padding: '2x 4x', radius: '1r' },
408
- variants: {
409
- default: { fill: '#primary', color: '#on-primary' },
410
- danger: { fill: '#danger', color: '#on-danger' },
411
- outline: { fill: 'transparent', border: '1bw solid #primary' },
389
+ as: 'button',
390
+ modProps: { isLoading: Boolean, size: ['sm', 'md', 'lg'] as const },
391
+ styles: {
392
+ fill: { '': '#primary', isLoading: '#primary.5' },
393
+ padding: { '': '2x 4x', 'size=sm': '1x 2x' },
412
394
  },
413
395
  });
414
396
 
415
- <Button variant="danger">Delete</Button>
397
+ <Button isLoading size="lg">Submit</Button>
416
398
  ```
417
399
 
418
- ### Recipes
400
+ See [Runtime API - Mod Props](docs/runtime.md#mod-props) and [Methodology - modProps](docs/methodology.md#modprops-and-mods).
419
401
 
420
- Recipes are predefined style sets that work like composable styling classes for Tasty. They can be pre-applied or post-applied to current styles, which lets you add reusable state logic while still allowing local style overrides.
402
+ ### Variants
421
403
 
422
- ```tsx
423
- configure({
424
- recipes: {
425
- card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
426
- elevated: { shadow: '0 2x 4x #shadow' },
427
- },
428
- });
404
+ Variants let one component expose named visual versions without pre-generating a separate class for every possible combination. In runtime mode, Tasty emits only the variant CSS that is actually used.
429
405
 
430
- const ProfileCard = tasty({
431
- styles: {
432
- recipe: 'card elevated',
433
- color: '#text',
434
- },
435
- });
436
- ```
406
+ See [Runtime API - Variants](docs/runtime.md#variants).
437
407
 
438
- Use `/` to post-apply recipes after local styles when you need recipe states/styles to win the final merge order. Use `none` to skip base recipes: `recipe: 'none / disabled'`.
408
+ ### Recipes
439
409
 
440
- ### Auto-Inferred `@property`
410
+ Recipes are reusable style bundles defined in `configure({ recipes })` and applied with the `recipe` style property. They are useful when your design system wants shared state logic or visual presets without forcing every component to repeat the same style map.
441
411
 
442
- CSS custom properties do not animate smoothly by default because the browser does not know how to interpolate their values. The [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property) at-rule fixes that by declaring a property's syntax, such as `<number>` or `<color>`.
412
+ Use `/` to post-apply recipes after local styles when recipe states should win the final merge order, and use `none` to skip base recipes entirely.
443
413
 
444
- In Tasty, you usually do not need to declare `@property` manually. When a custom property is assigned a concrete value, Tasty infers the syntax and registers the matching `@property` for you:
414
+ See [Style DSL - Recipes](docs/dsl.md#recipes) and [Configuration - recipes](docs/configuration.md#recipes).
445
415
 
446
- ```tsx
447
- const Pulse = tasty({
448
- styles: {
449
- animation: 'pulse 2s infinite',
450
- transform: 'scale($pulse-scale)',
451
- '@keyframes': {
452
- pulse: {
453
- '0%, 100%': { '$pulse-scale': 1 },
454
- '50%': { '$pulse-scale': 1.05 },
455
- },
456
- },
457
- },
458
- });
459
- ```
416
+ ### Auto-Inferred `@property`
417
+
418
+ Tasty usually removes the need to hand-author CSS [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property) rules. When a custom property receives a concrete value, Tasty infers its syntax and registers the matching `@property` automatically, which makes transitions and animations on custom properties work without extra boilerplate.
460
419
 
461
- Here, `$pulse-scale: 1` is inferred as `<number>`, so Tasty injects `@property --pulse-scale` automatically before using it in the animation. Numeric types (`<number>`, `<length>`, `<percentage>`, `<angle>`, `<time>`) are inferred from values; `<color>` is inferred from the `#name` token convention.
420
+ If you prefer explicit control, disable inference with `configure({ autoPropertyTypes: false })` or declare the properties yourself.
462
421
 
463
- If you prefer full manual control, disable auto-inference globally with `configure({ autoPropertyTypes: false })`.
422
+ See [Style DSL - Properties (`@property`)](docs/dsl.md#properties-property).
464
423
 
465
424
  ### Explicit `@properties`
466
425
 
467
- Declare `@properties` yourself only when you need to override the defaults, for example to set `inherits: false` or provide a custom `initialValue`:
426
+ Use explicit `@properties` only when you need to override defaults such as `inherits: false` or a custom `initialValue`.
468
427
 
469
- ```tsx
470
- '@properties': {
471
- '$pulse-scale': { syntax: '<number>', inherits: false, initialValue: 1 },
472
- },
473
- ```
428
+ See [Style DSL - Properties (`@property`)](docs/dsl.md#properties-property).
474
429
 
475
430
  ### React Hooks
476
431
 
477
- For cases where you don't need a full component:
478
-
479
- ```tsx
480
- import { useStyles, useGlobalStyles, useRawCSS } from '@tenphi/tasty';
432
+ When you do not need a full component wrapper, use the hooks directly: `useStyles` for local class names, `useGlobalStyles` for selector-scoped global CSS, `useRawCSS` for raw rules, plus `useKeyframes` and `useProperty` for animation and custom-property primitives.
481
433
 
482
- function App() {
483
- const { className } = useStyles({ padding: '2x', fill: '#surface' });
484
- useGlobalStyles('body', { margin: '0' });
485
- useRawCSS('@font-face { font-family: "Custom"; src: url(...); }');
486
-
487
- return <main className={className}>...</main>;
488
- }
489
- ```
434
+ See [Runtime API - Hooks](docs/runtime.md#hooks).
490
435
 
491
436
  ### Zero-Runtime Mode
492
437
 
493
- Extract all CSS at build time. Zero JavaScript overhead in production:
494
-
495
- ```tsx
496
- import { tastyStatic } from '@tenphi/tasty/static';
497
-
498
- const card = tastyStatic({
499
- padding: '4x',
500
- fill: '#surface',
501
- radius: '1r',
502
- color: { '': '#text', '@dark': '#text-on-dark' },
503
- });
504
-
505
- // card is a CSS class name string
506
- <div className={card}>Static styles, zero runtime</div>
507
- ```
508
-
509
- Configure the Babel plugin:
438
+ Use `tastyStatic` when you want the same DSL and state model, but with CSS extracted at build time and no styling runtime in the client bundle. It is a strong fit for static sites, landing pages, and other build-time-first setups.
510
439
 
511
- ```js
512
- module.exports = {
513
- plugins: [
514
- ['@tenphi/tasty/babel-plugin', {
515
- output: 'public/tasty.css',
516
- config: {
517
- states: { '@dark': '@root(schema=dark)' },
518
- },
519
- }],
520
- ],
521
- };
522
- ```
440
+ See [Zero Runtime (tastyStatic)](docs/tasty-static.md) and [Getting Started - Choosing a rendering mode](docs/getting-started.md#choosing-a-rendering-mode).
523
441
 
524
442
  ### `tasty` vs `tastyStatic`
525
443
 
526
- | | `tasty` (runtime) | `tastyStatic` (zero-runtime) |
527
- |---|---|---|
528
- | **Output** | React component | CSS class name |
529
- | **CSS injection** | Runtime `<style>` tags | Build-time extraction |
530
- | **Runtime cost** | Style generation on mount | None |
531
- | **Generated CSS scope** | Only styles/variants used at runtime | All extracted static styles at build time |
532
- | **Dynamic values** | Fully supported | Via CSS custom properties |
533
- | **Sub-elements** | Built-in (`<C.Title>`) | Manual (`data-element`) |
534
- | **Variants** | Built-in (`variants` option) | Separate static styles |
535
- | **Framework** | React | Any (requires Babel) |
536
- | **Best for** | Interactive apps, design systems | Static sites, SSG, landing pages |
444
+ `tasty()` returns React components and injects CSS on demand at runtime. `tastyStatic()` returns class names and extracts CSS during the build. Both share the same DSL, tokens, units, state mappings, and recipes, so the main choice is runtime flexibility versus build-time extraction.
537
445
 
538
- Both share the same DSL, tokens, units, state mappings, and recipes.
446
+ See [Zero Runtime (tastyStatic)](docs/tasty-static.md), [Runtime API](docs/runtime.md), and [Comparison - Build-time vs runtime](docs/comparison.md#build-time-vs-runtime).
539
447
 
540
448
  ### Server-Side Rendering
541
449
 
542
- SSR with zero-cost client hydration. Existing `tasty()` components work unchanged — SSR is opt-in and requires no per-component modifications. Supports Next.js (App Router with streaming), Astro (middleware + islands), and any React-based framework via the core API. Requires React 18+.
543
-
544
- **Next.js setup:**
545
-
546
- ```tsx
547
- // app/tasty-registry.tsx
548
- 'use client';
549
-
550
- import { TastyRegistry } from '@tenphi/tasty/ssr/next';
450
+ SSR layers on top of runtime `tasty()` rather than introducing a separate styling model. Existing components stay unchanged while Tasty collects CSS during server rendering and hydrates the cache on the client.
551
451
 
552
- export default function TastyStyleRegistry({
553
- children,
554
- }: {
555
- children: React.ReactNode;
556
- }) {
557
- return <TastyRegistry>{children}</TastyRegistry>;
558
- }
559
- ```
560
-
561
- ```tsx
562
- // app/layout.tsx
563
- import TastyStyleRegistry from './tasty-registry';
564
-
565
- export default function RootLayout({
566
- children,
567
- }: {
568
- children: React.ReactNode;
569
- }) {
570
- return (
571
- <html>
572
- <body>
573
- <TastyStyleRegistry>{children}</TastyStyleRegistry>
574
- </body>
575
- </html>
576
- );
577
- }
578
- ```
452
+ Use `@tenphi/tasty/ssr/next` for Next.js App Router, `@tenphi/tasty/ssr/astro` for Astro, or the core SSR API for other React SSR setups.
579
453
 
580
- See the [full SSR guide](docs/ssr.md) for Astro integration, streaming SSR, generic framework usage, troubleshooting, and the current requirements.
454
+ See the [full SSR guide](docs/ssr.md).
581
455
 
582
456
  ## Entry Points
583
457
 
@@ -714,9 +588,9 @@ Open-source React UI kit built on Tasty + React Aria. 100+ production components
714
588
 
715
589
  ## Documentation
716
590
 
717
- Start from the docs hub if you want the shortest path to the right guide for your role or rendering mode.
591
+ Start from the docs hub if you want the shortest path to the right guide for your role or styling approach.
718
592
 
719
- - **[Docs Hub](docs/README.md)** — audience-based navigation across onboarding, design-system authoring, runtime, zero-runtime, SSR, debugging, and internals
593
+ - **[Docs Hub](docs/README.md)** — audience-based navigation across onboarding, design-system authoring, runtime, zero-runtime, runtime SSR integration, debugging, and internals
720
594
 
721
595
  ### Start here
722
596
 
@@ -3,6 +3,5 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
3
3
  if (typeof require !== "undefined") return require.apply(this, arguments);
4
4
  throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
5
  });
6
-
7
6
  //#endregion
8
- export { __require };
7
+ export { __require };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,5 +1,4 @@
1
1
  import { extractLocalPredefinedStates, extractPredefinedStateRefs } from "../states/index.js";
2
-
3
2
  //#region src/chunks/cacheKey.ts
4
3
  /**
5
4
  * Chunk-specific cache key generation.
@@ -72,7 +71,7 @@ function generateChunkCacheKey(styles, chunkName, styleKeys) {
72
71
  }
73
72
  return parts.join("\0");
74
73
  }
75
-
76
74
  //#endregion
77
75
  export { generateChunkCacheKey };
76
+
78
77
  //# sourceMappingURL=cacheKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cacheKey.js","names":[],"sources":["../../src/chunks/cacheKey.ts"],"sourcesContent":["/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\nconst _stableStringifyCache = new WeakMap<object, string>();\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n * Uses a WeakMap cache for object values to avoid re-serializing the same references.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n\n const cached = _stableStringifyCache.get(value as object);\n if (cached !== undefined) return cached;\n\n let result: string;\n if (Array.isArray(value)) {\n result = '[' + value.map(stableStringify).join(',') + ']';\n } else {\n const obj = value as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of sortedKeys) {\n if (obj[key] !== undefined) {\n parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);\n }\n }\n result = '{' + parts.join(',') + '}';\n }\n\n _stableStringifyCache.set(value as object, result);\n return result;\n}\n\n/**\n * Generate a cache key for a specific chunk.\n *\n * Only includes the styles that belong to this chunk, allowing\n * chunks to be cached independently.\n *\n * Also includes relevant local predefined states that are referenced\n * by this chunk's styles.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns A stable cache key string\n */\nexport function generateChunkCacheKey(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): string {\n // Start with chunk name for namespace separation\n const parts: string[] = [chunkName];\n\n // styleKeys are already sorted by categorizeStyleKeys\n let chunkStylesStr = '';\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n // Use stable stringify for consistent serialization regardless of key order\n const serialized = stableStringify(value);\n parts.push(`${key}:${serialized}`);\n chunkStylesStr += serialized;\n }\n }\n\n // Extract local predefined states from the full styles object\n const localStates = extractLocalPredefinedStates(styles);\n\n // Only include local predefined states that are actually referenced in this chunk\n if (Object.keys(localStates).length > 0) {\n const referencedStates = extractPredefinedStateRefs(chunkStylesStr);\n const relevantLocalStates: string[] = [];\n\n for (const stateName of referencedStates) {\n if (localStates[stateName]) {\n relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);\n }\n }\n\n // Add relevant local states to the cache key (sorted for stability)\n if (relevantLocalStates.length > 0) {\n relevantLocalStates.sort();\n parts.unshift(`[states:${relevantLocalStates.join('|')}]`);\n }\n }\n\n // Use null character as separator (safe, not in JSON output)\n return parts.join('\\0');\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,wCAAwB,IAAI,SAAyB;;;;;;AAO3D,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,KACZ,QAAO;AAET,KAAI,UAAU,OACZ,QAAO;AAET,KAAI,OAAO,UAAU,SACnB,QAAO,KAAK,UAAU,MAAM;CAG9B,MAAM,SAAS,sBAAsB,IAAI,MAAgB;AACzD,KAAI,WAAW,OAAW,QAAO;CAEjC,IAAI;AACJ,KAAI,MAAM,QAAQ,MAAM,CACtB,UAAS,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,GAAG;MACjD;EACL,MAAM,MAAM;EACZ,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAC1C,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,OAAO,WAChB,KAAI,IAAI,SAAS,OACf,OAAM,KAAK,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,gBAAgB,IAAI,KAAK,GAAG;AAGrE,WAAS,MAAM,MAAM,KAAK,IAAI,GAAG;;AAGnC,uBAAsB,IAAI,OAAiB,OAAO;AAClD,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,sBACd,QACA,WACA,WACQ;CAER,MAAM,QAAkB,CAAC,UAAU;CAGnC,IAAI,iBAAiB;AAErB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,QAAW;GAEvB,MAAM,aAAa,gBAAgB,MAAM;AACzC,SAAM,KAAK,GAAG,IAAI,GAAG,aAAa;AAClC,qBAAkB;;;CAKtB,MAAM,cAAc,6BAA6B,OAAO;AAGxD,KAAI,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;EACvC,MAAM,mBAAmB,2BAA2B,eAAe;EACnE,MAAM,sBAAgC,EAAE;AAExC,OAAK,MAAM,aAAa,iBACtB,KAAI,YAAY,WACd,qBAAoB,KAAK,GAAG,UAAU,GAAG,YAAY,aAAa;AAKtE,MAAI,oBAAoB,SAAS,GAAG;AAClC,uBAAoB,MAAM;AAC1B,SAAM,QAAQ,WAAW,oBAAoB,KAAK,IAAI,CAAC,GAAG;;;AAK9D,QAAO,MAAM,KAAK,KAAK"}
1
+ {"version":3,"file":"cacheKey.js","names":[],"sources":["../../src/chunks/cacheKey.ts"],"sourcesContent":["/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\nconst _stableStringifyCache = new WeakMap<object, string>();\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n * Uses a WeakMap cache for object values to avoid re-serializing the same references.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n\n const cached = _stableStringifyCache.get(value as object);\n if (cached !== undefined) return cached;\n\n let result: string;\n if (Array.isArray(value)) {\n result = '[' + value.map(stableStringify).join(',') + ']';\n } else {\n const obj = value as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of sortedKeys) {\n if (obj[key] !== undefined) {\n parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);\n }\n }\n result = '{' + parts.join(',') + '}';\n }\n\n _stableStringifyCache.set(value as object, result);\n return result;\n}\n\n/**\n * Generate a cache key for a specific chunk.\n *\n * Only includes the styles that belong to this chunk, allowing\n * chunks to be cached independently.\n *\n * Also includes relevant local predefined states that are referenced\n * by this chunk's styles.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns A stable cache key string\n */\nexport function generateChunkCacheKey(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): string {\n // Start with chunk name for namespace separation\n const parts: string[] = [chunkName];\n\n // styleKeys are already sorted by categorizeStyleKeys\n let chunkStylesStr = '';\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n // Use stable stringify for consistent serialization regardless of key order\n const serialized = stableStringify(value);\n parts.push(`${key}:${serialized}`);\n chunkStylesStr += serialized;\n }\n }\n\n // Extract local predefined states from the full styles object\n const localStates = extractLocalPredefinedStates(styles);\n\n // Only include local predefined states that are actually referenced in this chunk\n if (Object.keys(localStates).length > 0) {\n const referencedStates = extractPredefinedStateRefs(chunkStylesStr);\n const relevantLocalStates: string[] = [];\n\n for (const stateName of referencedStates) {\n if (localStates[stateName]) {\n relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);\n }\n }\n\n // Add relevant local states to the cache key (sorted for stability)\n if (relevantLocalStates.length > 0) {\n relevantLocalStates.sort();\n parts.unshift(`[states:${relevantLocalStates.join('|')}]`);\n }\n }\n\n // Use null character as separator (safe, not in JSON output)\n return parts.join('\\0');\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,wCAAwB,IAAI,SAAyB;;;;;;AAO3D,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,KACZ,QAAO;AAET,KAAI,UAAU,KAAA,EACZ,QAAO;AAET,KAAI,OAAO,UAAU,SACnB,QAAO,KAAK,UAAU,MAAM;CAG9B,MAAM,SAAS,sBAAsB,IAAI,MAAgB;AACzD,KAAI,WAAW,KAAA,EAAW,QAAO;CAEjC,IAAI;AACJ,KAAI,MAAM,QAAQ,MAAM,CACtB,UAAS,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,GAAG;MACjD;EACL,MAAM,MAAM;EACZ,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAC1C,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,OAAO,WAChB,KAAI,IAAI,SAAS,KAAA,EACf,OAAM,KAAK,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,gBAAgB,IAAI,KAAK,GAAG;AAGrE,WAAS,MAAM,MAAM,KAAK,IAAI,GAAG;;AAGnC,uBAAsB,IAAI,OAAiB,OAAO;AAClD,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,sBACd,QACA,WACA,WACQ;CAER,MAAM,QAAkB,CAAC,UAAU;CAGnC,IAAI,iBAAiB;AAErB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,KAAA,GAAW;GAEvB,MAAM,aAAa,gBAAgB,MAAM;AACzC,SAAM,KAAK,GAAG,IAAI,GAAG,aAAa;AAClC,qBAAkB;;;CAKtB,MAAM,cAAc,6BAA6B,OAAO;AAGxD,KAAI,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;EACvC,MAAM,mBAAmB,2BAA2B,eAAe;EACnE,MAAM,sBAAgC,EAAE;AAExC,OAAK,MAAM,aAAa,iBACtB,KAAI,YAAY,WACd,qBAAoB,KAAK,GAAG,UAAU,GAAG,YAAY,aAAa;AAKtE,MAAI,oBAAoB,SAAS,GAAG;AAClC,uBAAoB,MAAM;AAC1B,SAAM,QAAQ,WAAW,oBAAoB,KAAK,IAAI,CAAC,GAAG;;;AAK9D,QAAO,MAAM,KAAK,KAAK"}
@@ -1,6 +1,6 @@
1
1
  //#region src/chunks/definitions.d.ts
2
2
  declare const CHUNK_NAMES: {
3
- /** Special chunk for styles that cannot be split (e.g., @starting-style) */readonly COMBINED: "combined";
3
+ /** Special chunk for styles that cannot be split */readonly COMBINED: "combined";
4
4
  readonly SUBCOMPONENTS: "subcomponents";
5
5
  readonly APPEARANCE: "appearance";
6
6
  readonly FONT: "font";
@@ -1,5 +1,4 @@
1
1
  import { isSelector } from "../pipeline/index.js";
2
-
3
2
  //#region src/chunks/definitions.ts
4
3
  /**
5
4
  * Style chunk definitions for CSS chunking optimization.
@@ -238,7 +237,7 @@ function categorizeStyleKeys(styles) {
238
237
  const chunkData = {};
239
238
  const keys = Object.keys(styles);
240
239
  for (const key of keys) {
241
- if (key === "$" || key === "@keyframes" || key === "@properties" || key === "recipe") continue;
240
+ if (key === "$" || key === "@keyframes" || key === "@properties" || key === "@fontFace" || key === "@counterStyle" || key === "recipe") continue;
242
241
  if (isSelector(key)) {
243
242
  if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];
244
243
  chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);
@@ -253,7 +252,7 @@ function categorizeStyleKeys(styles) {
253
252
  for (const chunkName of Object.keys(chunkData)) if (!orderedChunks.has(chunkName)) orderedChunks.set(chunkName, chunkData[chunkName].sort());
254
253
  return orderedChunks;
255
254
  }
256
-
257
255
  //#endregion
258
256
  export { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys };
257
+
259
258
  //# sourceMappingURL=definitions.js.map