@tenphi/tasty 0.0.0-snapshot.2705ab9 → 0.0.0-snapshot.27699f6

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 (336) hide show
  1. package/README.md +35 -27
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +17 -8
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/{ssr/collector.d.ts → collector-LuU1vZ68.d.ts} +11 -15
  5. package/dist/{ssr/collector.js → collector-QwpPODsy.js} +37 -34
  6. package/dist/collector-QwpPODsy.js.map +1 -0
  7. package/dist/config-rrijM-U2.js +10137 -0
  8. package/dist/config-rrijM-U2.js.map +1 -0
  9. package/dist/config-vuCRkBWX.d.ts +884 -0
  10. package/dist/context-CkSg-kDT.js +24 -0
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -34
  13. package/dist/core/index.js +6 -27
  14. package/dist/core-BvTG0J_M.js +1592 -0
  15. package/dist/core-BvTG0J_M.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-C7HJGEmN.js} +75 -13
  17. package/dist/css-writer-C7HJGEmN.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +3 -3
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-BvokPr1L.js +143 -0
  21. package/dist/format-rules-BvokPr1L.js.map +1 -0
  22. package/dist/hydrate-Dsv7Pwon.js +45 -0
  23. package/dist/hydrate-Dsv7Pwon.js.map +1 -0
  24. package/dist/index-ZRxZWzlj.d.ts +1602 -0
  25. package/dist/index-dUtwpOux.d.ts +1266 -0
  26. package/dist/index.d.ts +5 -51
  27. package/dist/index.js +731 -35
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-DDqRjwa9.js +587 -0
  30. package/dist/keyframes-DDqRjwa9.js.map +1 -0
  31. package/dist/{utils/merge-styles.js → merge-styles-B8jV6zu3.js} +4 -6
  32. package/dist/merge-styles-B8jV6zu3.js.map +1 -0
  33. package/dist/{utils/merge-styles.d.ts → merge-styles-CtDJMhpJ.d.ts} +3 -3
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-BnTZz2I_.js} +5 -8
  35. package/dist/resolve-recipes-BnTZz2I_.js.map +1 -0
  36. package/dist/ssr/astro-client.d.ts +1 -0
  37. package/dist/ssr/astro-client.js +19 -0
  38. package/dist/ssr/astro-client.js.map +1 -0
  39. package/dist/ssr/astro-middleware.d.ts +15 -0
  40. package/dist/ssr/astro-middleware.js +19 -0
  41. package/dist/ssr/astro-middleware.js.map +1 -0
  42. package/dist/ssr/astro.d.ts +89 -10
  43. package/dist/ssr/astro.js +116 -32
  44. package/dist/ssr/astro.js.map +1 -1
  45. package/dist/ssr/index.d.ts +44 -5
  46. package/dist/ssr/index.js +7 -9
  47. package/dist/ssr/index.js.map +1 -1
  48. package/dist/ssr/next.d.ts +7 -6
  49. package/dist/ssr/next.js +18 -14
  50. package/dist/ssr/next.js.map +1 -1
  51. package/dist/static/index.d.ts +91 -5
  52. package/dist/static/index.js +49 -4
  53. package/dist/static/index.js.map +1 -0
  54. package/dist/static/inject.d.ts +5 -0
  55. package/dist/static/inject.js +17 -0
  56. package/dist/static/inject.js.map +1 -0
  57. package/dist/zero/babel.d.ts +24 -110
  58. package/dist/zero/babel.js +139 -47
  59. package/dist/zero/babel.js.map +1 -1
  60. package/dist/zero/index.d.ts +67 -3
  61. package/dist/zero/index.js +2 -4
  62. package/dist/zero/next.d.ts +12 -0
  63. package/dist/zero/next.js +5 -4
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +4 -4
  66. package/docs/adoption.md +5 -3
  67. package/docs/comparison.md +24 -25
  68. package/docs/configuration.md +69 -1
  69. package/docs/debug.md +11 -9
  70. package/docs/design-system.md +22 -10
  71. package/docs/dsl.md +24 -8
  72. package/docs/getting-started.md +10 -10
  73. package/docs/injector.md +43 -27
  74. package/docs/methodology.md +52 -3
  75. package/docs/{PIPELINE.md → pipeline.md} +204 -50
  76. package/docs/{runtime.md → react-api.md} +104 -32
  77. package/docs/ssr.md +139 -81
  78. package/docs/styles.md +17 -0
  79. package/docs/tasty-static.md +101 -2
  80. package/package.json +23 -11
  81. package/dist/_virtual/_rolldown/runtime.js +0 -8
  82. package/dist/chunks/cacheKey.js +0 -78
  83. package/dist/chunks/cacheKey.js.map +0 -1
  84. package/dist/chunks/definitions.d.ts +0 -37
  85. package/dist/chunks/definitions.js +0 -259
  86. package/dist/chunks/definitions.js.map +0 -1
  87. package/dist/chunks/renderChunk.js +0 -60
  88. package/dist/chunks/renderChunk.js.map +0 -1
  89. package/dist/config.d.ts +0 -366
  90. package/dist/config.js +0 -504
  91. package/dist/config.js.map +0 -1
  92. package/dist/counter-style/index.js +0 -51
  93. package/dist/counter-style/index.js.map +0 -1
  94. package/dist/debug.d.ts +0 -89
  95. package/dist/debug.js +0 -454
  96. package/dist/debug.js.map +0 -1
  97. package/dist/font-face/index.js +0 -63
  98. package/dist/font-face/index.js.map +0 -1
  99. package/dist/hooks/resolve-ssr-collector.js +0 -15
  100. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  101. package/dist/hooks/useCounterStyle.d.ts +0 -50
  102. package/dist/hooks/useCounterStyle.js +0 -47
  103. package/dist/hooks/useCounterStyle.js.map +0 -1
  104. package/dist/hooks/useFontFace.d.ts +0 -43
  105. package/dist/hooks/useFontFace.js +0 -71
  106. package/dist/hooks/useFontFace.js.map +0 -1
  107. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  108. package/dist/hooks/useGlobalStyles.js +0 -79
  109. package/dist/hooks/useGlobalStyles.js.map +0 -1
  110. package/dist/hooks/useKeyframes.d.ts +0 -56
  111. package/dist/hooks/useKeyframes.js +0 -65
  112. package/dist/hooks/useKeyframes.js.map +0 -1
  113. package/dist/hooks/useProperty.d.ts +0 -79
  114. package/dist/hooks/useProperty.js +0 -110
  115. package/dist/hooks/useProperty.js.map +0 -1
  116. package/dist/hooks/useRawCSS.d.ts +0 -53
  117. package/dist/hooks/useRawCSS.js +0 -36
  118. package/dist/hooks/useRawCSS.js.map +0 -1
  119. package/dist/hooks/useStyles.d.ts +0 -45
  120. package/dist/hooks/useStyles.js +0 -238
  121. package/dist/hooks/useStyles.js.map +0 -1
  122. package/dist/injector/index.d.ts +0 -183
  123. package/dist/injector/index.js +0 -180
  124. package/dist/injector/index.js.map +0 -1
  125. package/dist/injector/injector.d.ts +0 -166
  126. package/dist/injector/injector.js +0 -465
  127. package/dist/injector/injector.js.map +0 -1
  128. package/dist/injector/sheet-manager.d.ts +0 -136
  129. package/dist/injector/sheet-manager.js +0 -734
  130. package/dist/injector/sheet-manager.js.map +0 -1
  131. package/dist/injector/types.d.ts +0 -204
  132. package/dist/keyframes/index.js +0 -206
  133. package/dist/keyframes/index.js.map +0 -1
  134. package/dist/parser/classify.js +0 -320
  135. package/dist/parser/classify.js.map +0 -1
  136. package/dist/parser/const.js +0 -49
  137. package/dist/parser/const.js.map +0 -1
  138. package/dist/parser/lru.js +0 -109
  139. package/dist/parser/lru.js.map +0 -1
  140. package/dist/parser/parser.d.ts +0 -25
  141. package/dist/parser/parser.js +0 -116
  142. package/dist/parser/parser.js.map +0 -1
  143. package/dist/parser/tokenizer.js +0 -69
  144. package/dist/parser/tokenizer.js.map +0 -1
  145. package/dist/parser/types.d.ts +0 -51
  146. package/dist/parser/types.js +0 -46
  147. package/dist/parser/types.js.map +0 -1
  148. package/dist/pipeline/conditions.d.ts +0 -134
  149. package/dist/pipeline/conditions.js +0 -406
  150. package/dist/pipeline/conditions.js.map +0 -1
  151. package/dist/pipeline/exclusive.js +0 -231
  152. package/dist/pipeline/exclusive.js.map +0 -1
  153. package/dist/pipeline/index.d.ts +0 -55
  154. package/dist/pipeline/index.js +0 -709
  155. package/dist/pipeline/index.js.map +0 -1
  156. package/dist/pipeline/materialize.js +0 -1104
  157. package/dist/pipeline/materialize.js.map +0 -1
  158. package/dist/pipeline/parseStateKey.d.ts +0 -15
  159. package/dist/pipeline/parseStateKey.js +0 -447
  160. package/dist/pipeline/parseStateKey.js.map +0 -1
  161. package/dist/pipeline/simplify.js +0 -516
  162. package/dist/pipeline/simplify.js.map +0 -1
  163. package/dist/pipeline/warnings.js +0 -18
  164. package/dist/pipeline/warnings.js.map +0 -1
  165. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  166. package/dist/plugins/okhsl-plugin.js +0 -98
  167. package/dist/plugins/okhsl-plugin.js.map +0 -1
  168. package/dist/plugins/types.d.ts +0 -76
  169. package/dist/properties/index.js +0 -223
  170. package/dist/properties/index.js.map +0 -1
  171. package/dist/properties/property-type-resolver.d.ts +0 -24
  172. package/dist/properties/property-type-resolver.js +0 -91
  173. package/dist/properties/property-type-resolver.js.map +0 -1
  174. package/dist/ssr/async-storage.d.ts +0 -17
  175. package/dist/ssr/async-storage.js.map +0 -1
  176. package/dist/ssr/collect-auto-properties.js +0 -40
  177. package/dist/ssr/collect-auto-properties.js.map +0 -1
  178. package/dist/ssr/collector.js.map +0 -1
  179. package/dist/ssr/context.d.ts +0 -8
  180. package/dist/ssr/context.js +0 -14
  181. package/dist/ssr/context.js.map +0 -1
  182. package/dist/ssr/format-global-rules.js.map +0 -1
  183. package/dist/ssr/format-keyframes.js +0 -70
  184. package/dist/ssr/format-keyframes.js.map +0 -1
  185. package/dist/ssr/format-property.js +0 -50
  186. package/dist/ssr/format-property.js.map +0 -1
  187. package/dist/ssr/format-rules.js +0 -73
  188. package/dist/ssr/format-rules.js.map +0 -1
  189. package/dist/ssr/hydrate.d.ts +0 -22
  190. package/dist/ssr/hydrate.js +0 -50
  191. package/dist/ssr/hydrate.js.map +0 -1
  192. package/dist/ssr/ssr-collector-ref.js +0 -12
  193. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  194. package/dist/states/index.d.ts +0 -49
  195. package/dist/states/index.js +0 -171
  196. package/dist/states/index.js.map +0 -1
  197. package/dist/static/tastyStatic.d.ts +0 -46
  198. package/dist/static/tastyStatic.js +0 -31
  199. package/dist/static/tastyStatic.js.map +0 -1
  200. package/dist/static/types.d.ts +0 -49
  201. package/dist/static/types.js +0 -24
  202. package/dist/static/types.js.map +0 -1
  203. package/dist/styles/align.d.ts +0 -15
  204. package/dist/styles/align.js +0 -14
  205. package/dist/styles/align.js.map +0 -1
  206. package/dist/styles/border.d.ts +0 -25
  207. package/dist/styles/border.js +0 -114
  208. package/dist/styles/border.js.map +0 -1
  209. package/dist/styles/color.d.ts +0 -14
  210. package/dist/styles/color.js +0 -27
  211. package/dist/styles/color.js.map +0 -1
  212. package/dist/styles/createStyle.js +0 -80
  213. package/dist/styles/createStyle.js.map +0 -1
  214. package/dist/styles/dimension.js +0 -97
  215. package/dist/styles/dimension.js.map +0 -1
  216. package/dist/styles/display.d.ts +0 -37
  217. package/dist/styles/display.js +0 -67
  218. package/dist/styles/display.js.map +0 -1
  219. package/dist/styles/fade.d.ts +0 -15
  220. package/dist/styles/fade.js +0 -58
  221. package/dist/styles/fade.js.map +0 -1
  222. package/dist/styles/fill.d.ts +0 -42
  223. package/dist/styles/fill.js +0 -52
  224. package/dist/styles/fill.js.map +0 -1
  225. package/dist/styles/flow.d.ts +0 -16
  226. package/dist/styles/flow.js +0 -12
  227. package/dist/styles/flow.js.map +0 -1
  228. package/dist/styles/gap.d.ts +0 -31
  229. package/dist/styles/gap.js +0 -37
  230. package/dist/styles/gap.js.map +0 -1
  231. package/dist/styles/height.d.ts +0 -17
  232. package/dist/styles/height.js +0 -20
  233. package/dist/styles/height.js.map +0 -1
  234. package/dist/styles/index.d.ts +0 -2
  235. package/dist/styles/index.js +0 -9
  236. package/dist/styles/index.js.map +0 -1
  237. package/dist/styles/inset.d.ts +0 -52
  238. package/dist/styles/inset.js +0 -150
  239. package/dist/styles/inset.js.map +0 -1
  240. package/dist/styles/justify.d.ts +0 -15
  241. package/dist/styles/justify.js +0 -14
  242. package/dist/styles/justify.js.map +0 -1
  243. package/dist/styles/list.d.ts +0 -16
  244. package/dist/styles/list.js +0 -98
  245. package/dist/styles/list.js.map +0 -1
  246. package/dist/styles/margin.d.ts +0 -24
  247. package/dist/styles/margin.js +0 -104
  248. package/dist/styles/margin.js.map +0 -1
  249. package/dist/styles/outline.d.ts +0 -29
  250. package/dist/styles/outline.js +0 -65
  251. package/dist/styles/outline.js.map +0 -1
  252. package/dist/styles/padding.d.ts +0 -24
  253. package/dist/styles/padding.js +0 -104
  254. package/dist/styles/padding.js.map +0 -1
  255. package/dist/styles/predefined.d.ts +0 -71
  256. package/dist/styles/predefined.js +0 -238
  257. package/dist/styles/predefined.js.map +0 -1
  258. package/dist/styles/preset.d.ts +0 -52
  259. package/dist/styles/preset.js +0 -127
  260. package/dist/styles/preset.js.map +0 -1
  261. package/dist/styles/radius.d.ts +0 -14
  262. package/dist/styles/radius.js +0 -51
  263. package/dist/styles/radius.js.map +0 -1
  264. package/dist/styles/scrollbar.d.ts +0 -25
  265. package/dist/styles/scrollbar.js +0 -48
  266. package/dist/styles/scrollbar.js.map +0 -1
  267. package/dist/styles/shadow.d.ts +0 -14
  268. package/dist/styles/shadow.js +0 -24
  269. package/dist/styles/shadow.js.map +0 -1
  270. package/dist/styles/transition.d.ts +0 -14
  271. package/dist/styles/transition.js +0 -158
  272. package/dist/styles/transition.js.map +0 -1
  273. package/dist/styles/types.d.ts +0 -547
  274. package/dist/styles/width.d.ts +0 -17
  275. package/dist/styles/width.js +0 -20
  276. package/dist/styles/width.js.map +0 -1
  277. package/dist/tasty.d.ts +0 -119
  278. package/dist/tasty.js +0 -232
  279. package/dist/tasty.js.map +0 -1
  280. package/dist/types.d.ts +0 -184
  281. package/dist/utils/cache-wrapper.js +0 -22
  282. package/dist/utils/cache-wrapper.js.map +0 -1
  283. package/dist/utils/case-converter.js +0 -8
  284. package/dist/utils/case-converter.js.map +0 -1
  285. package/dist/utils/color-math.d.ts +0 -46
  286. package/dist/utils/color-math.js +0 -749
  287. package/dist/utils/color-math.js.map +0 -1
  288. package/dist/utils/color-space.d.ts +0 -5
  289. package/dist/utils/color-space.js +0 -229
  290. package/dist/utils/color-space.js.map +0 -1
  291. package/dist/utils/colors.d.ts +0 -5
  292. package/dist/utils/colors.js +0 -11
  293. package/dist/utils/colors.js.map +0 -1
  294. package/dist/utils/css-types.d.ts +0 -7
  295. package/dist/utils/dotize.d.ts +0 -26
  296. package/dist/utils/dotize.js +0 -122
  297. package/dist/utils/dotize.js.map +0 -1
  298. package/dist/utils/filter-base-props.d.ts +0 -15
  299. package/dist/utils/filter-base-props.js +0 -45
  300. package/dist/utils/filter-base-props.js.map +0 -1
  301. package/dist/utils/get-display-name.d.ts +0 -7
  302. package/dist/utils/get-display-name.js +0 -10
  303. package/dist/utils/get-display-name.js.map +0 -1
  304. package/dist/utils/has-keys.js +0 -13
  305. package/dist/utils/has-keys.js.map +0 -1
  306. package/dist/utils/is-dev-env.js +0 -19
  307. package/dist/utils/is-dev-env.js.map +0 -1
  308. package/dist/utils/is-valid-element-type.js +0 -15
  309. package/dist/utils/is-valid-element-type.js.map +0 -1
  310. package/dist/utils/merge-styles.js.map +0 -1
  311. package/dist/utils/mod-attrs.d.ts +0 -8
  312. package/dist/utils/mod-attrs.js +0 -21
  313. package/dist/utils/mod-attrs.js.map +0 -1
  314. package/dist/utils/process-tokens.d.ts +0 -21
  315. package/dist/utils/process-tokens.js +0 -91
  316. package/dist/utils/process-tokens.js.map +0 -1
  317. package/dist/utils/resolve-recipes.d.ts +0 -17
  318. package/dist/utils/resolve-recipes.js.map +0 -1
  319. package/dist/utils/selector-transform.js +0 -32
  320. package/dist/utils/selector-transform.js.map +0 -1
  321. package/dist/utils/string.js +0 -8
  322. package/dist/utils/string.js.map +0 -1
  323. package/dist/utils/styles.d.ts +0 -99
  324. package/dist/utils/styles.js +0 -221
  325. package/dist/utils/styles.js.map +0 -1
  326. package/dist/utils/typography.d.ts +0 -47
  327. package/dist/utils/typography.js +0 -51
  328. package/dist/utils/typography.js.map +0 -1
  329. package/dist/utils/warnings.d.ts +0 -16
  330. package/dist/utils/warnings.js +0 -16
  331. package/dist/utils/warnings.js.map +0 -1
  332. package/dist/zero/css-writer.d.ts +0 -45
  333. package/dist/zero/css-writer.js +0 -74
  334. package/dist/zero/css-writer.js.map +0 -1
  335. package/dist/zero/extractor.d.ts +0 -24
  336. package/dist/zero/extractor.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  # Getting Started
2
2
 
3
- This guide walks you from zero to a working Tasty component, then through the optional shared configuration and tooling layers. It is the right starting point when you already want to try Tasty in code. If you are still deciding whether Tasty fits your team, start with [Comparison](comparison.md) and [Adoption Guide](adoption.md) first. For a feature overview, see the [README](../README.md). For the full style language reference, see the [Style DSL](dsl.md). For the React API, see the [Runtime API](runtime.md). For the rest of the docs by role or task, see the [Docs Hub](README.md).
3
+ This guide walks you from zero to a working Tasty component, then through the optional shared configuration and tooling layers. It is the right starting point when you already want to try Tasty in code. If you are still deciding whether Tasty fits your team, start with [Comparison](comparison.md) and [Adoption Guide](adoption.md) first. For a feature overview, see the [README](../README.md). For the full style language reference, see the [Style DSL](dsl.md). For the React API, see the [React API](react-api.md). For the rest of the docs by role or task, see the [Docs Hub](README.md).
4
4
 
5
5
  ---
6
6
 
@@ -179,19 +179,19 @@ export default [
179
179
 
180
180
  ## Choosing a rendering mode
181
181
 
182
- Tasty has two styling approaches. Pick the one that fits your use case, then decide whether your runtime setup also needs server rendering support:
182
+ `tasty()` is the default for all React apps. All `tasty()` components and style functions are hook-free and work as React Server Components without `'use client'`. In server-only contexts, they produce zero client JavaScript with the full feature set.
183
183
 
184
184
  | Approach | Entry point | Best for | Trade-off |
185
185
  |------|-------------|----------|-----------|
186
- | **Runtime** | `tasty()` from `@tenphi/tasty` | Interactive apps with reusable stateful components, design systems | CSS generated at runtime; full feature set (styleProps, sub-elements, variants) |
187
- | **Zero-runtime** | `tastyStatic()` from `@tenphi/tasty/static` | Static sites, landing pages, SSG | Zero JS overhead; requires Babel plugin; no dynamic props |
186
+ | **Runtime (default)** | `tasty()` from `@tenphi/tasty` | All React apps — server-rendered by default, zero client JS until you need interactivity | Full feature set (styleProps, sub-elements, variants); CSS computed during rendering |
187
+ | **Runtime + SSR integration** | Add `@tenphi/tasty/ssr/*` | Apps with client-side hydration (Next.js client components, Astro islands) | Adds CSS batching, deduplication, FOUC prevention, and client cache hydration |
188
+ | **Zero-runtime** | `tastyStatic()` from `@tenphi/tasty/static` | Non-React frameworks or build-time extraction without React | Requires Babel plugin; no `styleProps` or runtime-only APIs |
188
189
 
189
- Both share the same DSL, tokens, units, and state mappings.
190
+ Both `tasty()` and `tastyStatic()` share the same DSL, tokens, units, and state mappings.
190
191
 
191
- - Runtime is the default and requires no extra setup beyond `@tenphi/tasty`.
192
- - If your framework can execute runtime code during server rendering, add SSR support on top of runtime with `@tenphi/tasty/ssr/next`, `@tenphi/tasty/ssr/astro`, or the core SSR API. This still uses `tasty()`; it just collects CSS on the server and hydrates the cache on the client.
193
- - Zero-runtime requires the Babel plugin and additional peer dependencies. See [Zero Runtime (tastyStatic)](tasty-static.md).
194
- - SSR works with existing `tasty()` components — wrap your app with a registry, middleware, or collector. See [Server-Side Rendering](ssr.md).
192
+ - **Runtime** is the default and requires no extra setup beyond `@tenphi/tasty`. In server-only contexts (Next.js RSC, Astro without `client:*` directives, SSG), `tasty()` produces static HTML + CSS with zero client JavaScript — the same end result as `tastyStatic()` but with the full feature set. For example, `tasty()` + `tastyIntegration()` in Astro without islands gives you the complete API with zero JS shipped.
193
+ - **SSR integration** is only needed when your app also has client-side rendering. Add `@tenphi/tasty/ssr/next`, `@tenphi/tasty/ssr/astro`, or the core SSR API to get CSS deduplication and cache hydration. See [Server-Side Rendering](ssr.md).
194
+ - **Zero-runtime** requires the Babel plugin and additional peer dependencies. Use it when you need build-time extraction without a React runtime. See [Zero Runtime (tastyStatic)](tasty-static.md).
195
195
 
196
196
  ---
197
197
 
@@ -200,7 +200,7 @@ Both share the same DSL, tokens, units, and state mappings.
200
200
  - **[Docs Hub](README.md)** — Pick the next guide by role, styling approach, or task
201
201
  - **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components: sub-elements, styleProps, tokens, extension
202
202
  - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
203
- - **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, hooks
203
+ - **[React API](react-api.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
204
204
  - **[Building a Design System](design-system.md)** — Practical guide to building a DS layer with Tasty: tokens, recipes, primitives, compound components
205
205
  - **[Adoption Guide](adoption.md)** — Roll out Tasty inside an existing design system or platform team
206
206
  - **[Comparison](comparison.md)** — Evaluate Tasty against other styling systems
package/docs/injector.md CHANGED
@@ -115,11 +115,13 @@ dispose();
115
115
 
116
116
  ### `useRawCSS(css, options?)` or `useRawCSS(factory, deps, options?)`
117
117
 
118
- React hook for injecting raw CSS. Uses `useInsertionEffect` for proper timing and cleanup.
118
+ Inject raw CSS without parsing. Hook-free — works in client components, SSR, and React Server Components.
119
119
 
120
120
  Supports two overloads:
121
- - **Static CSS**: `useRawCSS(cssString, options?)`
122
- - **Factory function**: `useRawCSS(() => cssString, deps, options?)` - re-evaluates when deps change (like `useMemo`)
121
+ - **Static CSS**: `useRawCSS(cssString, options?)` — content-based deduplication
122
+ - **Factory function**: `useRawCSS(() => cssString, deps, options?)` — factory called on every invocation, dedup handled internally
123
+
124
+ Use the `id` option for update tracking — when the CSS changes for the same id, the previous injection is replaced:
123
125
 
124
126
  ```tsx
125
127
  import { useRawCSS } from '@tenphi/tasty';
@@ -132,7 +134,7 @@ function GlobalReset() {
132
134
  return null;
133
135
  }
134
136
 
135
- // Dynamic CSS with factory function (like useMemo)
137
+ // Dynamic CSS with factory function and update tracking
136
138
  function ThemeStyles({ theme }: { theme: 'dark' | 'light' }) {
137
139
  useRawCSS(() => `
138
140
  body {
@@ -140,7 +142,7 @@ function ThemeStyles({ theme }: { theme: 'dark' | 'light' }) {
140
142
  background: ${theme === 'dark' ? '#000' : '#fff'};
141
143
  color: ${theme === 'dark' ? '#fff' : '#000'};
142
144
  }
143
- `, [theme]);
145
+ `, [theme], { id: 'theme-body' });
144
146
 
145
147
  return null;
146
148
  }
@@ -207,13 +209,12 @@ import { configure } from '@tenphi/tasty';
207
209
  configure({
208
210
  devMode: true, // Enable development features (auto-detected)
209
211
  maxRulesPerSheet: 8192, // Cap rules per stylesheet (default: 8192)
210
- unusedStylesThreshold: 500, // Trigger cleanup threshold (CSS rules only)
211
- bulkCleanupDelay: 5000, // Cleanup delay (ms) - ignored if idleCleanup is true
212
- idleCleanup: true, // Use requestIdleCallback for cleanup
213
- bulkCleanupBatchRatio: 0.5, // Clean up oldest 50% per batch
214
- unusedStylesMinAgeMs: 10000, // Minimum age before cleanup (ms)
215
212
  forceTextInjection: false, // Force textContent insertion (auto-detected for tests)
216
213
  nonce: 'csp-nonce', // CSP nonce for security
214
+ gc: { // Garbage collection for unused styles
215
+ touchInterval: 1000, // Touch events between GC cycles (default: 1000)
216
+ capacity: 1000, // Max unused styles to retain (default: 1000)
217
+ },
217
218
  states: { // Global predefined states for advanced state mapping
218
219
  '@mobile': '@media(w < 768px)',
219
220
  '@dark': '@root(schema=dark)',
@@ -223,13 +224,14 @@ configure({
223
224
 
224
225
  **Auto-Detection Features:**
225
226
  - `devMode`: Automatically enabled in development environments (detected via `isDevEnv()`)
226
- - `forceTextInjection`: Automatically enabled in test environments (Jest, Vitest, Mocha, jsdom)
227
+ - `forceTextInjection`: Automatically enabled in test environments (Jest, Vitest, Mocha, happy-dom, jsdom)
227
228
 
228
229
  **Configuration Notes:**
229
230
  - Most options have sensible defaults and auto-detection
230
231
  - `configure()` is optional - the injector works with defaults
231
232
  - **Configuration is locked after styles are generated** - calling `configure()` after first render will emit a warning and be ignored
232
- - `unusedStylesMinAgeMs`: Minimum time (ms) a style must remain unused before being eligible for cleanup. Helps prevent removal of styles that might be quickly reactivated.
233
+ - `gc.touchInterval`: Number of touch events between GC cycles. Each style render counts as a touch. When the counter reaches this value, GC is scheduled via `requestIdleCallback`.
234
+ - `gc.capacity`: Maximum number of unused styles (refCount = 0, not in DOM) to retain. When exceeded, the oldest are evicted first. Actively referenced styles don't count against this limit.
233
235
 
234
236
  ---
235
237
 
@@ -291,21 +293,34 @@ comp3.dispose(); // refCount: 1 → 0, eligible for bulk cleanup
291
293
  // Next inject() with same styles will increment refCount and reuse immediately
292
294
  ```
293
295
 
294
- ### Smart Cleanup System
296
+ ### Garbage Collection
295
297
 
296
298
  ```typescript
297
- import { configure } from '@tenphi/tasty';
299
+ import { configure, gc } from '@tenphi/tasty';
298
300
 
299
- // CSS rules: Not immediately deleted, marked for bulk cleanup (refCount = 0)
300
301
  // Keyframes: Disposed immediately when refCount = 0 (safer for global scope)
302
+ // CSS rules: Tracked by touch count and cleaned up via gc()
301
303
 
302
304
  configure({
303
- unusedStylesThreshold: 100, // Cleanup when 100+ unused CSS rules
304
- bulkCleanupBatchRatio: 0.3, // Remove oldest 30% each time
305
+ gc: {
306
+ touchInterval: 1000, // Schedule GC every 1000 touches
307
+ capacity: 1000, // Max unused styles to retain
308
+ },
305
309
  });
306
310
 
311
+ // Manual GC (synchronous, returns number of swept styles):
312
+ gc();
313
+
314
+ // Force-remove ALL unused styles (e.g. on route change or test teardown):
315
+ gc({ force: true });
316
+
317
+ // GC is also triggered automatically by touch count during rendering.
318
+ // Every `touchInterval` touches, GC is scheduled via requestIdleCallback.
319
+
307
320
  // Benefits:
308
- // - CSS rules: Batch cleanup prevents DOM manipulation overhead
321
+ // - Activity-proportional: busy apps trigger GC more often
322
+ // - DOM-safe: styles currently in the DOM are never evicted
323
+ // - Oldest-first: least recently used styles are evicted first
309
324
  // - Keyframes: Immediate cleanup prevents global namespace pollution
310
325
  // - Unused styles can be instantly reactivated (just increment refCount)
311
326
  ```
@@ -351,7 +366,7 @@ const componentCSS = getCssTextForNode(container);
351
366
  // Automatically detected test environments:
352
367
  // - NODE_ENV === 'test'
353
368
  // - Jest globals (jest, describe, it, expect)
354
- // - jsdom user agent
369
+ // - jsdom / HappyDOM user agent
355
370
  // - Vitest globals (vitest)
356
371
  // - Mocha globals (mocha)
357
372
 
@@ -462,13 +477,14 @@ injectGlobal([
462
477
  { selector: '.container', declarations: 'max-width: 1200px;' }
463
478
  ]);
464
479
 
465
- // ✅ Configure appropriate thresholds for your app (BEFORE first render!)
480
+ // ✅ Configure GC for your app (BEFORE first render!)
466
481
  import { configure } from '@tenphi/tasty';
467
482
 
468
483
  configure({
469
- unusedStylesThreshold: 500, // Default threshold (adjust based on app size)
470
- bulkCleanupBatchRatio: 0.5, // Default: clean oldest 50% per batch
471
- unusedStylesMinAgeMs: 10000, // Wait 10s before cleanup eligibility
484
+ gc: {
485
+ touchInterval: 1000, // Schedule GC every 1000 style touches
486
+ capacity: 1000, // Max unused styles to retain
487
+ },
472
488
  });
473
489
  ```
474
490
 
@@ -480,8 +496,8 @@ configure({
480
496
  // 1. Hash-based deduplication - same CSS = same className
481
497
  // 2. Reference counting - styles stay alive while in use (refCount > 0)
482
498
  // 3. Immediate keyframes cleanup - disposed instantly when refCount = 0
483
- // 4. Batch CSS cleanup - unused CSS rules (refCount = 0) cleaned in batches
484
- // 5. Non-stacking cleanups - prevents timeout accumulation
499
+ // 4. Touch-count GC - unused CSS rules are evicted oldest-first when over capacity
500
+ // 5. DOM safety guard - styles visible in the DOM are never evicted
485
501
 
486
502
  // Manual cleanup is rarely needed but available:
487
503
  cleanup(); // Force immediate cleanup of all unused CSS rules (refCount = 0)
@@ -511,7 +527,7 @@ const StyledButton = tasty({
511
527
  // 4. dispose() is called when component unmounts
512
528
  ```
513
529
 
514
- For most development, you'll use the [Runtime API](./runtime.md) rather than the injector directly. The injector provides the high-performance foundation that makes Tasty's declarative styling possible.
530
+ For most development, you'll use the [React API](./react-api.md) rather than the injector directly. The injector provides the high-performance foundation that makes Tasty's declarative styling possible.
515
531
 
516
532
  ---
517
533
 
@@ -525,4 +541,4 @@ Direct injector usage is recommended for:
525
541
  - **Performance-critical scenarios** where you need direct control
526
542
  - **Testing utilities** that need to inject or extract CSS
527
543
 
528
- For regular component styling, prefer the [`tasty()` API](./runtime.md) which provides a more developer-friendly interface.
544
+ For regular component styling, prefer the [`tasty()` API](./react-api.md) which provides a more developer-friendly interface.
@@ -214,7 +214,7 @@ The array form is simpler but types all values as `ModValue`:
214
214
  modProps: ['isLoading', 'isSelected'] as const,
215
215
  ```
216
216
 
217
- For the full API reference, see [Runtime — Mod Props](runtime.md#mod-props).
217
+ For the full API reference, see [Runtime — Mod Props](react-api.md#mod-props).
218
218
 
219
219
  ---
220
220
 
@@ -256,6 +256,54 @@ The `tokens` prop sets `style="--progress: 75%"` on the DOM element. The `$progr
256
256
 
257
257
  Design tokens (via `configure({ tokens })`) are injected as CSS custom properties on `:root`. Replace tokens (via `configure({ replaceTokens })`) are resolved at parse time and baked into the generated CSS. The `tokens` prop on components is resolved at render time via inline CSS custom properties. Use design tokens for design-system constants, replace tokens for value aliases, and the `tokens` prop for truly dynamic per-instance values.
258
258
 
259
+ ### tokenProps
260
+
261
+ `tokenProps` expose token keys as top-level component props — the token equivalent of `styleProps` and `modProps`. Use them when a component has a fixed set of known dynamic token values.
262
+
263
+ #### Array form
264
+
265
+ Prop names are plain camelCase identifiers. Names ending in `Color` map to `#` color tokens; everything else maps to `$` custom property tokens:
266
+
267
+ ```tsx
268
+ const ProgressBar = tasty({
269
+ tokenProps: ['progress', 'accentColor'] as const,
270
+ styles: { width: '$progress', fill: '#accent' },
271
+ });
272
+
273
+ // Clean prop API — no tokens object needed
274
+ <ProgressBar progress="75%" accentColor="#purple" />
275
+
276
+ // Conversion:
277
+ // 'progress' → $progress → --progress
278
+ // 'accentColor' → #accent → --accent-color + --accent-color-oklch
279
+ ```
280
+
281
+ #### Object form
282
+
283
+ Keys are prop names; values are `$`/`#`-prefixed token keys. No suffix convention needed — the prefix in the value is explicit:
284
+
285
+ ```tsx
286
+ const Card = tasty({
287
+ tokenProps: {
288
+ size: '$card-size',
289
+ color: '#card-accent',
290
+ },
291
+ styles: { padding: '$card-size', fill: '#card-accent' },
292
+ });
293
+
294
+ <Card size="4x" color="#purple" />
295
+ ```
296
+
297
+ #### Merge order
298
+
299
+ When all three token sources are present, values merge with increasing priority:
300
+
301
+ 1. `tokens` option in `tasty({...})` — default tokens (lowest)
302
+ 2. `tokens` prop on the component instance — runtime overrides
303
+ 3. `tokenProps`-derived values — highest priority (explicit named props win)
304
+
305
+ The `tokens` prop remains available for ad-hoc or dynamic tokens alongside `tokenProps`.
306
+
259
307
  ---
260
308
 
261
309
  ## styles prop vs style prop
@@ -458,7 +506,8 @@ See [Configuration](configuration.md) for the full `configure()` API.
458
506
  - **Use `elements` prop** to declare typed sub-components for compound components
459
507
  - **Use `styleProps`** to define what product engineers can customize
460
508
  - **Use `modProps`** to expose known modifier states as clean component props
461
- - **Use `tokens` prop** for per-instance dynamic values (progress, user color)
509
+ - **Use `tokenProps`** to expose known token keys as clean component props
510
+ - **Use `tokens` prop** for ad-hoc or dynamic per-instance token values (progress, user color)
462
511
  - **Use modifiers** (`mods` or `modProps`) for state-driven style changes instead of runtime `styles` prop changes
463
512
 
464
513
  ### Avoid
@@ -561,7 +610,7 @@ The `elements` prop gives you typed sub-components with automatic `data-element`
561
610
  - **[Getting Started](getting-started.md)** — Installation, first component, tooling setup
562
611
  - **[Building a Design System](design-system.md)** — Practical guide to building a DS layer with Tasty
563
612
  - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
564
- - **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, hooks
613
+ - **[React API](react-api.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
565
614
  - **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers
566
615
  - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
567
616
  - **[Adoption Guide](adoption.md)** — Who should adopt Tasty, incremental phases, what changes for product engineers