@tenphi/tasty 0.0.0-snapshot.2dc73be → 0.0.0-snapshot.2ea241d

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 (326) hide show
  1. package/README.md +298 -250
  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/collector-Crs9kGJW.js +243 -0
  5. package/dist/collector-Crs9kGJW.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-osfWTeRd.d.ts} +38 -15
  7. package/dist/config-BaxtQMS3.js +10464 -0
  8. package/dist/config-BaxtQMS3.js.map +1 -0
  9. package/dist/config-BoZDUHW5.d.ts +945 -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 -33
  13. package/dist/core/index.js +6 -26
  14. package/dist/core-CmxaoZ-N.js +1598 -0
  15. package/dist/core-CmxaoZ-N.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-CPy_cbFJ.js} +149 -13
  17. package/dist/css-writer-CPy_cbFJ.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-CPirO_Mj.js +143 -0
  21. package/dist/format-rules-CPirO_Mj.js.map +1 -0
  22. package/dist/hydrate-CVn-A_3y.js +45 -0
  23. package/dist/hydrate-CVn-A_3y.js.map +1 -0
  24. package/dist/index-B_k47mc_.d.ts +1655 -0
  25. package/dist/index-tcHuMPFt.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -48
  27. package/dist/index.js +731 -32
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-vpzoVdUR.js +588 -0
  30. package/dist/keyframes-vpzoVdUR.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BMWcH6MF.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-BzQutdAK.js} +4 -6
  33. package/dist/merge-styles-BzQutdAK.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-DgH8A3Nn.js} +5 -8
  35. package/dist/resolve-recipes-DgH8A3Nn.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 +78 -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 +49 -95
  58. package/dist/zero/babel.js +203 -48
  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 +28 -1
  63. package/dist/zero/next.js +70 -15
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +31 -0
  66. package/docs/adoption.md +298 -0
  67. package/docs/comparison.md +419 -0
  68. package/docs/configuration.md +239 -12
  69. package/docs/debug.md +155 -340
  70. package/docs/design-system.md +436 -0
  71. package/docs/dsl.md +690 -0
  72. package/docs/getting-started.md +217 -0
  73. package/docs/injector.md +45 -29
  74. package/docs/methodology.md +642 -0
  75. package/docs/pipeline.md +699 -0
  76. package/docs/react-api.md +581 -0
  77. package/docs/ssr.md +156 -84
  78. package/docs/styles.md +50 -26
  79. package/docs/tasty-static.md +194 -23
  80. package/package.json +30 -14
  81. package/tasty.config.ts +1 -0
  82. package/dist/_virtual/_rolldown/runtime.js +0 -8
  83. package/dist/chunks/cacheKey.js +0 -70
  84. package/dist/chunks/cacheKey.js.map +0 -1
  85. package/dist/chunks/definitions.d.ts +0 -37
  86. package/dist/chunks/definitions.js +0 -259
  87. package/dist/chunks/definitions.js.map +0 -1
  88. package/dist/chunks/renderChunk.js +0 -61
  89. package/dist/chunks/renderChunk.js.map +0 -1
  90. package/dist/config.d.ts +0 -288
  91. package/dist/config.js +0 -417
  92. package/dist/config.js.map +0 -1
  93. package/dist/debug.d.ts +0 -204
  94. package/dist/debug.js +0 -733
  95. package/dist/debug.js.map +0 -1
  96. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  97. package/dist/hooks/useGlobalStyles.js +0 -83
  98. package/dist/hooks/useGlobalStyles.js.map +0 -1
  99. package/dist/hooks/useKeyframes.d.ts +0 -56
  100. package/dist/hooks/useKeyframes.js +0 -69
  101. package/dist/hooks/useKeyframes.js.map +0 -1
  102. package/dist/hooks/useProperty.d.ts +0 -79
  103. package/dist/hooks/useProperty.js +0 -114
  104. package/dist/hooks/useProperty.js.map +0 -1
  105. package/dist/hooks/useRawCSS.d.ts +0 -53
  106. package/dist/hooks/useRawCSS.js +0 -40
  107. package/dist/hooks/useRawCSS.js.map +0 -1
  108. package/dist/hooks/useStyles.d.ts +0 -45
  109. package/dist/hooks/useStyles.js +0 -248
  110. package/dist/hooks/useStyles.js.map +0 -1
  111. package/dist/injector/index.d.ts +0 -165
  112. package/dist/injector/index.js +0 -162
  113. package/dist/injector/index.js.map +0 -1
  114. package/dist/injector/injector.d.ts +0 -148
  115. package/dist/injector/injector.js +0 -436
  116. package/dist/injector/injector.js.map +0 -1
  117. package/dist/injector/sheet-manager.d.ts +0 -136
  118. package/dist/injector/sheet-manager.js +0 -729
  119. package/dist/injector/sheet-manager.js.map +0 -1
  120. package/dist/injector/types.d.ts +0 -144
  121. package/dist/keyframes/index.js +0 -206
  122. package/dist/keyframes/index.js.map +0 -1
  123. package/dist/parser/classify.js +0 -319
  124. package/dist/parser/classify.js.map +0 -1
  125. package/dist/parser/const.js +0 -33
  126. package/dist/parser/const.js.map +0 -1
  127. package/dist/parser/lru.js +0 -109
  128. package/dist/parser/lru.js.map +0 -1
  129. package/dist/parser/parser.d.ts +0 -25
  130. package/dist/parser/parser.js +0 -116
  131. package/dist/parser/parser.js.map +0 -1
  132. package/dist/parser/tokenizer.js +0 -69
  133. package/dist/parser/tokenizer.js.map +0 -1
  134. package/dist/parser/types.d.ts +0 -51
  135. package/dist/parser/types.js +0 -46
  136. package/dist/parser/types.js.map +0 -1
  137. package/dist/pipeline/conditions.d.ts +0 -134
  138. package/dist/pipeline/conditions.js +0 -406
  139. package/dist/pipeline/conditions.js.map +0 -1
  140. package/dist/pipeline/exclusive.js +0 -231
  141. package/dist/pipeline/exclusive.js.map +0 -1
  142. package/dist/pipeline/index.d.ts +0 -53
  143. package/dist/pipeline/index.js +0 -660
  144. package/dist/pipeline/index.js.map +0 -1
  145. package/dist/pipeline/materialize.js +0 -856
  146. package/dist/pipeline/materialize.js.map +0 -1
  147. package/dist/pipeline/parseStateKey.d.ts +0 -15
  148. package/dist/pipeline/parseStateKey.js +0 -451
  149. package/dist/pipeline/parseStateKey.js.map +0 -1
  150. package/dist/pipeline/simplify.js +0 -516
  151. package/dist/pipeline/simplify.js.map +0 -1
  152. package/dist/pipeline/warnings.js +0 -18
  153. package/dist/pipeline/warnings.js.map +0 -1
  154. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  155. package/dist/plugins/okhsl-plugin.js +0 -371
  156. package/dist/plugins/okhsl-plugin.js.map +0 -1
  157. package/dist/plugins/types.d.ts +0 -69
  158. package/dist/properties/index.js +0 -236
  159. package/dist/properties/index.js.map +0 -1
  160. package/dist/properties/property-type-resolver.d.ts +0 -24
  161. package/dist/properties/property-type-resolver.js +0 -87
  162. package/dist/properties/property-type-resolver.js.map +0 -1
  163. package/dist/ssr/async-storage.d.ts +0 -17
  164. package/dist/ssr/async-storage.js.map +0 -1
  165. package/dist/ssr/collect-auto-properties.js +0 -40
  166. package/dist/ssr/collect-auto-properties.js.map +0 -1
  167. package/dist/ssr/collector.js +0 -173
  168. package/dist/ssr/collector.js.map +0 -1
  169. package/dist/ssr/context.d.ts +0 -8
  170. package/dist/ssr/context.js +0 -14
  171. package/dist/ssr/context.js.map +0 -1
  172. package/dist/ssr/format-global-rules.js.map +0 -1
  173. package/dist/ssr/format-keyframes.js +0 -70
  174. package/dist/ssr/format-keyframes.js.map +0 -1
  175. package/dist/ssr/format-property.js +0 -48
  176. package/dist/ssr/format-property.js.map +0 -1
  177. package/dist/ssr/format-rules.js +0 -70
  178. package/dist/ssr/format-rules.js.map +0 -1
  179. package/dist/ssr/hydrate.d.ts +0 -22
  180. package/dist/ssr/hydrate.js +0 -50
  181. package/dist/ssr/hydrate.js.map +0 -1
  182. package/dist/ssr/ssr-collector-ref.js +0 -12
  183. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  184. package/dist/states/index.d.ts +0 -49
  185. package/dist/states/index.js +0 -416
  186. package/dist/states/index.js.map +0 -1
  187. package/dist/static/tastyStatic.d.ts +0 -46
  188. package/dist/static/tastyStatic.js +0 -31
  189. package/dist/static/tastyStatic.js.map +0 -1
  190. package/dist/static/types.d.ts +0 -49
  191. package/dist/static/types.js +0 -24
  192. package/dist/static/types.js.map +0 -1
  193. package/dist/styles/align.d.ts +0 -15
  194. package/dist/styles/align.js +0 -14
  195. package/dist/styles/align.js.map +0 -1
  196. package/dist/styles/border.d.ts +0 -25
  197. package/dist/styles/border.js +0 -114
  198. package/dist/styles/border.js.map +0 -1
  199. package/dist/styles/color.d.ts +0 -14
  200. package/dist/styles/color.js +0 -23
  201. package/dist/styles/color.js.map +0 -1
  202. package/dist/styles/createStyle.js +0 -77
  203. package/dist/styles/createStyle.js.map +0 -1
  204. package/dist/styles/dimension.js +0 -97
  205. package/dist/styles/dimension.js.map +0 -1
  206. package/dist/styles/display.d.ts +0 -37
  207. package/dist/styles/display.js +0 -67
  208. package/dist/styles/display.js.map +0 -1
  209. package/dist/styles/fade.d.ts +0 -15
  210. package/dist/styles/fade.js +0 -58
  211. package/dist/styles/fade.js.map +0 -1
  212. package/dist/styles/fill.d.ts +0 -42
  213. package/dist/styles/fill.js +0 -52
  214. package/dist/styles/fill.js.map +0 -1
  215. package/dist/styles/flow.d.ts +0 -16
  216. package/dist/styles/flow.js +0 -12
  217. package/dist/styles/flow.js.map +0 -1
  218. package/dist/styles/gap.d.ts +0 -31
  219. package/dist/styles/gap.js +0 -37
  220. package/dist/styles/gap.js.map +0 -1
  221. package/dist/styles/height.d.ts +0 -17
  222. package/dist/styles/height.js +0 -20
  223. package/dist/styles/height.js.map +0 -1
  224. package/dist/styles/index.d.ts +0 -2
  225. package/dist/styles/index.js +0 -9
  226. package/dist/styles/index.js.map +0 -1
  227. package/dist/styles/inset.d.ts +0 -52
  228. package/dist/styles/inset.js +0 -150
  229. package/dist/styles/inset.js.map +0 -1
  230. package/dist/styles/justify.d.ts +0 -15
  231. package/dist/styles/justify.js +0 -14
  232. package/dist/styles/justify.js.map +0 -1
  233. package/dist/styles/list.d.ts +0 -16
  234. package/dist/styles/list.js +0 -98
  235. package/dist/styles/list.js.map +0 -1
  236. package/dist/styles/margin.d.ts +0 -24
  237. package/dist/styles/margin.js +0 -104
  238. package/dist/styles/margin.js.map +0 -1
  239. package/dist/styles/outline.d.ts +0 -29
  240. package/dist/styles/outline.js +0 -65
  241. package/dist/styles/outline.js.map +0 -1
  242. package/dist/styles/padding.d.ts +0 -24
  243. package/dist/styles/padding.js +0 -104
  244. package/dist/styles/padding.js.map +0 -1
  245. package/dist/styles/predefined.d.ts +0 -71
  246. package/dist/styles/predefined.js +0 -238
  247. package/dist/styles/predefined.js.map +0 -1
  248. package/dist/styles/preset.d.ts +0 -47
  249. package/dist/styles/preset.js +0 -126
  250. package/dist/styles/preset.js.map +0 -1
  251. package/dist/styles/radius.d.ts +0 -14
  252. package/dist/styles/radius.js +0 -51
  253. package/dist/styles/radius.js.map +0 -1
  254. package/dist/styles/scrollbar.d.ts +0 -25
  255. package/dist/styles/scrollbar.js +0 -48
  256. package/dist/styles/scrollbar.js.map +0 -1
  257. package/dist/styles/shadow.d.ts +0 -14
  258. package/dist/styles/shadow.js +0 -24
  259. package/dist/styles/shadow.js.map +0 -1
  260. package/dist/styles/transition.d.ts +0 -14
  261. package/dist/styles/transition.js +0 -158
  262. package/dist/styles/transition.js.map +0 -1
  263. package/dist/styles/types.d.ts +0 -495
  264. package/dist/styles/width.d.ts +0 -17
  265. package/dist/styles/width.js +0 -20
  266. package/dist/styles/width.js.map +0 -1
  267. package/dist/tasty.d.ts +0 -981
  268. package/dist/tasty.js +0 -206
  269. package/dist/tasty.js.map +0 -1
  270. package/dist/tokens/typography.d.ts +0 -19
  271. package/dist/tokens/typography.js +0 -237
  272. package/dist/tokens/typography.js.map +0 -1
  273. package/dist/types.d.ts +0 -184
  274. package/dist/utils/cache-wrapper.js +0 -26
  275. package/dist/utils/cache-wrapper.js.map +0 -1
  276. package/dist/utils/case-converter.js +0 -8
  277. package/dist/utils/case-converter.js.map +0 -1
  278. package/dist/utils/colors.d.ts +0 -5
  279. package/dist/utils/colors.js +0 -9
  280. package/dist/utils/colors.js.map +0 -1
  281. package/dist/utils/css-types.d.ts +0 -7
  282. package/dist/utils/dotize.d.ts +0 -26
  283. package/dist/utils/dotize.js +0 -122
  284. package/dist/utils/dotize.js.map +0 -1
  285. package/dist/utils/filter-base-props.d.ts +0 -15
  286. package/dist/utils/filter-base-props.js +0 -45
  287. package/dist/utils/filter-base-props.js.map +0 -1
  288. package/dist/utils/get-display-name.d.ts +0 -7
  289. package/dist/utils/get-display-name.js +0 -10
  290. package/dist/utils/get-display-name.js.map +0 -1
  291. package/dist/utils/hsl-to-rgb.js +0 -38
  292. package/dist/utils/hsl-to-rgb.js.map +0 -1
  293. package/dist/utils/is-dev-env.js +0 -19
  294. package/dist/utils/is-dev-env.js.map +0 -1
  295. package/dist/utils/is-valid-element-type.js +0 -15
  296. package/dist/utils/is-valid-element-type.js.map +0 -1
  297. package/dist/utils/merge-styles.js.map +0 -1
  298. package/dist/utils/mod-attrs.d.ts +0 -8
  299. package/dist/utils/mod-attrs.js +0 -21
  300. package/dist/utils/mod-attrs.js.map +0 -1
  301. package/dist/utils/okhsl-to-rgb.js +0 -296
  302. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  303. package/dist/utils/process-tokens.d.ts +0 -31
  304. package/dist/utils/process-tokens.js +0 -171
  305. package/dist/utils/process-tokens.js.map +0 -1
  306. package/dist/utils/resolve-recipes.d.ts +0 -17
  307. package/dist/utils/resolve-recipes.js.map +0 -1
  308. package/dist/utils/selector-transform.js +0 -32
  309. package/dist/utils/selector-transform.js.map +0 -1
  310. package/dist/utils/string.js +0 -8
  311. package/dist/utils/string.js.map +0 -1
  312. package/dist/utils/styles.d.ts +0 -177
  313. package/dist/utils/styles.js +0 -730
  314. package/dist/utils/styles.js.map +0 -1
  315. package/dist/utils/typography.d.ts +0 -36
  316. package/dist/utils/typography.js +0 -53
  317. package/dist/utils/typography.js.map +0 -1
  318. package/dist/utils/warnings.d.ts +0 -16
  319. package/dist/utils/warnings.js +0 -16
  320. package/dist/utils/warnings.js.map +0 -1
  321. package/dist/zero/css-writer.d.ts +0 -45
  322. package/dist/zero/css-writer.js +0 -74
  323. package/dist/zero/css-writer.js.map +0 -1
  324. package/dist/zero/extractor.d.ts +0 -24
  325. package/dist/zero/extractor.js.map +0 -1
  326. package/docs/usage.md +0 -695
@@ -0,0 +1,217 @@
1
+ # Getting Started
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 [React API](react-api.md). For the rest of the docs by role or task, see the [Docs Hub](README.md).
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ - **Node.js** >= 20
10
+ - **React** >= 18 (peer dependency)
11
+ - **Package manager**: pnpm, npm, or yarn
12
+
13
+ Tasty can be used immediately in a React app, but it is most compelling for teams building reusable components with intersecting states, variants, tokens, and design-system conventions.
14
+
15
+ ---
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add @tenphi/tasty
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Your first component
26
+
27
+ ```tsx
28
+ import { tasty } from '@tenphi/tasty';
29
+
30
+ const Card = tasty({
31
+ as: 'div',
32
+ styles: {
33
+ display: 'flex',
34
+ flow: 'column',
35
+ padding: '4x',
36
+ gap: '2x',
37
+ fill: '#white',
38
+ border: true,
39
+ radius: true,
40
+ },
41
+ });
42
+
43
+ export default function App() {
44
+ return <Card>Hello, Tasty!</Card>;
45
+ }
46
+ ```
47
+
48
+ `tasty()` returns a normal React component. Values like `4x`, `#white`, `true`, and `1r` are Tasty DSL — they map to CSS custom properties, shorthand expansions, and design tokens. See [Style Properties](styles.md) for the full reference.
49
+
50
+ ---
51
+
52
+ ## Optional: add shared configuration
53
+
54
+ Use `configure()` once, before your app renders, when your app or design system needs shared state aliases, tokens, recipes, or parser extensions:
55
+
56
+ ```tsx
57
+ // src/tasty-config.ts
58
+ import { configure } from '@tenphi/tasty';
59
+
60
+ configure({
61
+ states: {
62
+ '@mobile': '@media(w < 768px)',
63
+ '@dark': '@root(schema=dark)',
64
+ },
65
+ });
66
+ ```
67
+
68
+ These examples use `data-schema="dark"` as the root-state convention. If your app already uses a different attribute such as `data-theme="dark"`, keep the pattern and swap the attribute name consistently across your config and components.
69
+
70
+ Import this file at the top of your app entry point so it runs before any component renders:
71
+
72
+ ```tsx
73
+ // src/main.tsx
74
+ import './tasty-config';
75
+ import { createRoot } from 'react-dom/client';
76
+ import App from './App';
77
+
78
+ createRoot(document.getElementById('root')!).render(<App />);
79
+ ```
80
+
81
+ ### Define shared tokens and override default unit values
82
+
83
+ Color tokens like `#primary` resolve to CSS custom properties at runtime (e.g. `var(--primary-color)`). Built-in units like `x`, `r`, and `bw` already work without setup and multiply CSS custom properties by default. Use `configure({ tokens })` when you want to define shared token values or override the defaults your app uses:
84
+
85
+ ```tsx
86
+ // src/tasty-config.ts
87
+ import { configure } from '@tenphi/tasty';
88
+
89
+ configure({
90
+ tokens: {
91
+ '#primary': 'oklch(55% 0.25 265)',
92
+ '#surface': '#fff',
93
+ '#text': '#111',
94
+ '$gap': '8px',
95
+ '$radius': '4px',
96
+ '$border-width': '1px',
97
+ '$outline-width': '2px',
98
+ },
99
+ });
100
+ ```
101
+
102
+ Tokens support state maps for responsive or theme-aware values:
103
+
104
+ ```tsx
105
+ configure({
106
+ tokens: {
107
+ '#primary': {
108
+ '': 'oklch(55% 0.25 265)',
109
+ '@dark': 'oklch(75% 0.2 265)',
110
+ },
111
+ },
112
+ });
113
+ ```
114
+
115
+ Every component using `#primary`, `2x`, or `1r` adjusts automatically. Tokens are injected as `:root` CSS custom properties when the first style is rendered. You can also use standard CSS color values such as `rgb(...)`, `hsl(...)`, and named colors directly; `okhsl(...)` is the recommended choice when you want authored colors that stay aligned with Tasty's design-system-oriented workflow.
116
+
117
+ > **Note:** `configure({ replaceTokens })` is a separate mechanism — it replaces tokens with literal values at parse time (baked into CSS). Use it for value aliases like `$card-padding: '4x'` that should be resolved during style generation, not for defining color or unit values. See [Configuration — Replace Tokens](configuration.md#replace-tokens-parse-time-substitution) for details.
118
+
119
+ See [Configuration](configuration.md) for the full `configure()` API — tokens, replace tokens, recipes, custom units, style handlers, and TypeScript extensions.
120
+
121
+ ---
122
+
123
+ ## ESLint plugin
124
+
125
+ The ESLint plugin catches invalid style properties, bad token references, malformed state keys, and other mistakes at lint time — before they reach the browser.
126
+
127
+ ### Install
128
+
129
+ ```bash
130
+ pnpm add -D @tenphi/eslint-plugin-tasty
131
+ ```
132
+
133
+ ### Configure
134
+
135
+ Add the plugin to your flat config:
136
+
137
+ ```js
138
+ // eslint.config.js
139
+ import tasty from '@tenphi/eslint-plugin-tasty';
140
+
141
+ export default [
142
+ // ...your other configs
143
+ tasty.configs.recommended,
144
+ ];
145
+ ```
146
+
147
+ ### What `recommended` catches
148
+
149
+ The `recommended` config enables 18 of the plugin's 27 total rules. It covers the most common issues without turning on the stricter governance rules:
150
+
151
+ | Category | Rules | Examples |
152
+ |----------|-------|---------|
153
+ | Property validation | `known-property`, `valid-boolean-property`, `valid-sub-element` | Flags typos like `pading` or invalid boolean usage |
154
+ | Value validation | `valid-value`, `valid-color-token`, `valid-custom-unit` | Catches `#nonexistent` tokens, bad unit syntax |
155
+ | State validation | `valid-state-key`, `no-nested-state-map`, `require-default-state` | Validates state key syntax, ensures `''` default exists |
156
+ | Structure | `valid-styles-structure`, `no-important`, `no-nested-selector` | Prevents `!important`, invalid nesting |
157
+ | Static mode | `static-no-dynamic-values`, `static-valid-selector` | Enforces build-time constraints in `tastyStatic()` |
158
+ | Style properties | `valid-preset`, `valid-recipe`, `valid-transition`, `valid-directional-modifier`, `valid-radius-shape` | Validates preset names, recipe references, transition syntax |
159
+
160
+ ### Strict config
161
+
162
+ For stricter governance, use `tasty.configs.strict`. It adds rules that enforce best practices like preferring shorthand properties, consistent token usage, and flagging direct `styles` prop usage:
163
+
164
+ ```js
165
+ export default [
166
+ tasty.configs.strict,
167
+ ];
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Editor support
173
+
174
+ **[VS Code Extension](https://github.com/tenphi/tasty-vscode-extension)** — Syntax highlighting for Tasty styles in TypeScript/TSX/JavaScript/JSX. Highlights color tokens, custom units, state keys, presets, and style properties inside `tasty()` and `tastyStatic()` calls. Install from the VS Code marketplace or from a `.vsix` file.
175
+
176
+ **[Glaze](https://github.com/tenphi/glaze)** — OKHSL-based color theme generator with automatic WCAG contrast solving. Generate light, dark, and high-contrast color palettes from a single hue and export them directly as Tasty color tokens. See the [Ecosystem section](../README.md#ecosystem) in the README.
177
+
178
+ ---
179
+
180
+ ## Choosing a rendering mode
181
+
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
+
184
+ | Approach | Entry point | Best for | Trade-off |
185
+ |------|-------------|----------|-----------|
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 |
189
+
190
+ Both `tasty()` and `tastyStatic()` share the same DSL, tokens, units, and state mappings.
191
+
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
+
196
+ ---
197
+
198
+ ## Next steps
199
+
200
+ - **[Docs Hub](README.md)** — Pick the next guide by role, styling approach, or task
201
+ - **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components: sub-elements, styleProps, tokens, extension
202
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
203
+ - **[React API](react-api.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
204
+ - **[Building a Design System](design-system.md)** — Practical guide to building a DS layer with Tasty: tokens, recipes, primitives, compound components
205
+ - **[Adoption Guide](adoption.md)** — Roll out Tasty inside an existing design system or platform team
206
+ - **[Comparison](comparison.md)** — Evaluate Tasty against other styling systems
207
+ - **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers, TypeScript extensions
208
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
209
+ - **[Debug Utilities](debug.md)** — Inspect generated CSS and debug runtime behavior when styles do not look right
210
+
211
+ ---
212
+
213
+ ## Common issues
214
+
215
+ - Styles are missing on first render: make sure the file that calls `configure()` is imported before any `tasty()` component renders.
216
+ - Token or unit values are not what you expect: check your `configure({ tokens, units })` setup, then inspect the generated CSS variables with [Debug Utilities](debug.md).
217
+ - You need build-time extraction or server-rendered CSS delivery: use [Zero Runtime (tastyStatic)](tasty-static.md) for extraction, or add [Server-Side Rendering](ssr.md) on top of runtime `tasty()` when your framework renders on the server.
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
  }
@@ -199,7 +201,7 @@ slideIn.dispose(); // Immediate keyframes deletion from DOM
199
201
 
200
202
  ### `configure(config): void`
201
203
 
202
- Configures the Tasty style system. Must be called **before** any styles are generated (before first render).
204
+ Configures the Tasty style system. `configure()` is optional, but if you use it, it must be called **before** any styles are generated (before first render).
203
205
 
204
206
  ```typescript
205
207
  import { configure } from '@tenphi/tasty';
@@ -207,29 +209,29 @@ 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
- '@dark': '@root(theme=dark)',
220
+ '@dark': '@root(schema=dark)',
220
221
  },
221
222
  });
222
223
  ```
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 [Tasty style system](./usage.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](./usage.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.