@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fc19da9

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 (330) hide show
  1. package/README.md +497 -266
  2. package/dist/babel-types-DpUCD2L_.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/chunks/collector-DqcB0UUT.js +210 -0
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  14. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-BzYPQ0H2.js +502 -0
  18. package/dist/chunks/debug-BzYPQ0H2.js.map +1 -0
  19. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  20. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B2e-Wha-.js +689 -0
  24. package/dist/chunks/react-runtime-B2e-Wha-.js.map +1 -0
  25. package/dist/chunks/runtime-engine-yeyCAx2e.js +2431 -0
  26. package/dist/chunks/runtime-engine-yeyCAx2e.js.map +1 -0
  27. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  28. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  32. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  33. package/dist/chunks/zero-engine-DpkieEPZ.js +310 -0
  34. package/dist/chunks/zero-engine-DpkieEPZ.js.map +1 -0
  35. package/dist/collector-D4POJ53X.d.ts +164 -0
  36. package/dist/config-DvPUj4cw.d.ts +1364 -0
  37. package/dist/core/index.d.ts +5 -33
  38. package/dist/core/index.js +9 -26
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DC4q-xDq.d.ts +1946 -0
  41. package/dist/index.d.ts +5 -40
  42. package/dist/index.js +11 -33
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +127 -0
  60. package/dist/ssr/astro.js +221 -0
  61. package/dist/ssr/astro.js.map +1 -0
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -0
  65. package/dist/ssr/index.js +10 -0
  66. package/dist/ssr/index.js.map +1 -0
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +46 -0
  71. package/dist/ssr/next.js +60 -0
  72. package/dist/ssr/next.js.map +1 -0
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-ZbF2_6LV.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +49 -90
  81. package/dist/zero/babel.js +252 -119
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +117 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +58 -33
  87. package/dist/zero/next.js +89 -59
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +42 -0
  90. package/docs/adoption.md +331 -0
  91. package/docs/ai-agents.md +252 -0
  92. package/docs/comparison.md +449 -0
  93. package/docs/configuration.md +943 -0
  94. package/docs/debug.md +333 -0
  95. package/docs/design-system.md +557 -0
  96. package/docs/dsl.md +1093 -0
  97. package/docs/getting-started.md +297 -0
  98. package/docs/injector.md +633 -0
  99. package/docs/methodology.md +673 -0
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +703 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +630 -0
  106. package/docs/styles.md +725 -0
  107. package/docs/tasty-static.md +659 -0
  108. package/package.json +238 -50
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -70
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -260
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -61
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -280
  119. package/dist/config.js +0 -403
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -204
  122. package/dist/debug.js +0 -733
  123. package/dist/debug.js.map +0 -1
  124. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  125. package/dist/hooks/useGlobalStyles.js +0 -56
  126. package/dist/hooks/useGlobalStyles.js.map +0 -1
  127. package/dist/hooks/useKeyframes.d.ts +0 -56
  128. package/dist/hooks/useKeyframes.js +0 -54
  129. package/dist/hooks/useKeyframes.js.map +0 -1
  130. package/dist/hooks/useProperty.d.ts +0 -79
  131. package/dist/hooks/useProperty.js +0 -91
  132. package/dist/hooks/useProperty.js.map +0 -1
  133. package/dist/hooks/useRawCSS.d.ts +0 -53
  134. package/dist/hooks/useRawCSS.js +0 -28
  135. package/dist/hooks/useRawCSS.js.map +0 -1
  136. package/dist/hooks/useStyles.d.ts +0 -40
  137. package/dist/hooks/useStyles.js +0 -169
  138. package/dist/hooks/useStyles.js.map +0 -1
  139. package/dist/injector/index.d.ts +0 -157
  140. package/dist/injector/index.js +0 -154
  141. package/dist/injector/index.js.map +0 -1
  142. package/dist/injector/injector.d.ts +0 -139
  143. package/dist/injector/injector.js +0 -404
  144. package/dist/injector/injector.js.map +0 -1
  145. package/dist/injector/sheet-manager.d.ts +0 -127
  146. package/dist/injector/sheet-manager.js +0 -714
  147. package/dist/injector/sheet-manager.js.map +0 -1
  148. package/dist/injector/types.d.ts +0 -135
  149. package/dist/keyframes/index.js +0 -206
  150. package/dist/keyframes/index.js.map +0 -1
  151. package/dist/parser/classify.js +0 -319
  152. package/dist/parser/classify.js.map +0 -1
  153. package/dist/parser/const.js +0 -33
  154. package/dist/parser/const.js.map +0 -1
  155. package/dist/parser/lru.js +0 -109
  156. package/dist/parser/lru.js.map +0 -1
  157. package/dist/parser/parser.d.ts +0 -25
  158. package/dist/parser/parser.js +0 -116
  159. package/dist/parser/parser.js.map +0 -1
  160. package/dist/parser/tokenizer.js +0 -69
  161. package/dist/parser/tokenizer.js.map +0 -1
  162. package/dist/parser/types.d.ts +0 -51
  163. package/dist/parser/types.js +0 -46
  164. package/dist/parser/types.js.map +0 -1
  165. package/dist/pipeline/conditions.d.ts +0 -134
  166. package/dist/pipeline/conditions.js +0 -400
  167. package/dist/pipeline/conditions.js.map +0 -1
  168. package/dist/pipeline/exclusive.js +0 -231
  169. package/dist/pipeline/exclusive.js.map +0 -1
  170. package/dist/pipeline/index.d.ts +0 -53
  171. package/dist/pipeline/index.js +0 -641
  172. package/dist/pipeline/index.js.map +0 -1
  173. package/dist/pipeline/materialize.js +0 -908
  174. package/dist/pipeline/materialize.js.map +0 -1
  175. package/dist/pipeline/parseStateKey.d.ts +0 -15
  176. package/dist/pipeline/parseStateKey.js +0 -430
  177. package/dist/pipeline/parseStateKey.js.map +0 -1
  178. package/dist/pipeline/simplify.js +0 -557
  179. package/dist/pipeline/simplify.js.map +0 -1
  180. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  181. package/dist/plugins/okhsl-plugin.js +0 -371
  182. package/dist/plugins/okhsl-plugin.js.map +0 -1
  183. package/dist/plugins/types.d.ts +0 -69
  184. package/dist/properties/index.js +0 -158
  185. package/dist/properties/index.js.map +0 -1
  186. package/dist/states/index.d.ts +0 -49
  187. package/dist/states/index.js +0 -416
  188. package/dist/states/index.js.map +0 -1
  189. package/dist/static/tastyStatic.d.ts +0 -46
  190. package/dist/static/tastyStatic.js +0 -31
  191. package/dist/static/tastyStatic.js.map +0 -1
  192. package/dist/static/types.d.ts +0 -49
  193. package/dist/static/types.js +0 -24
  194. package/dist/static/types.js.map +0 -1
  195. package/dist/styles/align.d.ts +0 -15
  196. package/dist/styles/align.js +0 -14
  197. package/dist/styles/align.js.map +0 -1
  198. package/dist/styles/border.d.ts +0 -25
  199. package/dist/styles/border.js +0 -114
  200. package/dist/styles/border.js.map +0 -1
  201. package/dist/styles/color.d.ts +0 -14
  202. package/dist/styles/color.js +0 -23
  203. package/dist/styles/color.js.map +0 -1
  204. package/dist/styles/createStyle.js +0 -77
  205. package/dist/styles/createStyle.js.map +0 -1
  206. package/dist/styles/dimension.js +0 -97
  207. package/dist/styles/dimension.js.map +0 -1
  208. package/dist/styles/display.d.ts +0 -37
  209. package/dist/styles/display.js +0 -67
  210. package/dist/styles/display.js.map +0 -1
  211. package/dist/styles/fade.d.ts +0 -15
  212. package/dist/styles/fade.js +0 -58
  213. package/dist/styles/fade.js.map +0 -1
  214. package/dist/styles/fill.d.ts +0 -44
  215. package/dist/styles/fill.js +0 -51
  216. package/dist/styles/fill.js.map +0 -1
  217. package/dist/styles/flow.d.ts +0 -16
  218. package/dist/styles/flow.js +0 -12
  219. package/dist/styles/flow.js.map +0 -1
  220. package/dist/styles/gap.d.ts +0 -31
  221. package/dist/styles/gap.js +0 -37
  222. package/dist/styles/gap.js.map +0 -1
  223. package/dist/styles/height.d.ts +0 -17
  224. package/dist/styles/height.js +0 -20
  225. package/dist/styles/height.js.map +0 -1
  226. package/dist/styles/index.d.ts +0 -2
  227. package/dist/styles/index.js +0 -9
  228. package/dist/styles/index.js.map +0 -1
  229. package/dist/styles/inset.d.ts +0 -52
  230. package/dist/styles/inset.js +0 -150
  231. package/dist/styles/inset.js.map +0 -1
  232. package/dist/styles/justify.d.ts +0 -15
  233. package/dist/styles/justify.js +0 -14
  234. package/dist/styles/justify.js.map +0 -1
  235. package/dist/styles/list.d.ts +0 -16
  236. package/dist/styles/list.js +0 -98
  237. package/dist/styles/list.js.map +0 -1
  238. package/dist/styles/margin.d.ts +0 -24
  239. package/dist/styles/margin.js +0 -104
  240. package/dist/styles/margin.js.map +0 -1
  241. package/dist/styles/outline.d.ts +0 -29
  242. package/dist/styles/outline.js +0 -65
  243. package/dist/styles/outline.js.map +0 -1
  244. package/dist/styles/padding.d.ts +0 -24
  245. package/dist/styles/padding.js +0 -104
  246. package/dist/styles/padding.js.map +0 -1
  247. package/dist/styles/predefined.d.ts +0 -73
  248. package/dist/styles/predefined.js +0 -241
  249. package/dist/styles/predefined.js.map +0 -1
  250. package/dist/styles/preset.d.ts +0 -47
  251. package/dist/styles/preset.js +0 -126
  252. package/dist/styles/preset.js.map +0 -1
  253. package/dist/styles/radius.d.ts +0 -14
  254. package/dist/styles/radius.js +0 -51
  255. package/dist/styles/radius.js.map +0 -1
  256. package/dist/styles/scrollbar.d.ts +0 -21
  257. package/dist/styles/scrollbar.js +0 -105
  258. package/dist/styles/scrollbar.js.map +0 -1
  259. package/dist/styles/shadow.d.ts +0 -14
  260. package/dist/styles/shadow.js +0 -24
  261. package/dist/styles/shadow.js.map +0 -1
  262. package/dist/styles/styledScrollbar.d.ts +0 -47
  263. package/dist/styles/styledScrollbar.js +0 -38
  264. package/dist/styles/styledScrollbar.js.map +0 -1
  265. package/dist/styles/transition.d.ts +0 -14
  266. package/dist/styles/transition.js +0 -158
  267. package/dist/styles/transition.js.map +0 -1
  268. package/dist/styles/types.d.ts +0 -498
  269. package/dist/styles/width.d.ts +0 -17
  270. package/dist/styles/width.js +0 -20
  271. package/dist/styles/width.js.map +0 -1
  272. package/dist/tasty.d.ts +0 -982
  273. package/dist/tasty.js +0 -191
  274. package/dist/tasty.js.map +0 -1
  275. package/dist/tokens/typography.d.ts +0 -19
  276. package/dist/tokens/typography.js +0 -237
  277. package/dist/tokens/typography.js.map +0 -1
  278. package/dist/types.d.ts +0 -184
  279. package/dist/utils/cache-wrapper.js +0 -26
  280. package/dist/utils/cache-wrapper.js.map +0 -1
  281. package/dist/utils/case-converter.js +0 -8
  282. package/dist/utils/case-converter.js.map +0 -1
  283. package/dist/utils/colors.d.ts +0 -5
  284. package/dist/utils/colors.js +0 -9
  285. package/dist/utils/colors.js.map +0 -1
  286. package/dist/utils/css-types.d.ts +0 -7
  287. package/dist/utils/dotize.d.ts +0 -26
  288. package/dist/utils/dotize.js +0 -122
  289. package/dist/utils/dotize.js.map +0 -1
  290. package/dist/utils/filter-base-props.d.ts +0 -15
  291. package/dist/utils/filter-base-props.js +0 -45
  292. package/dist/utils/filter-base-props.js.map +0 -1
  293. package/dist/utils/get-display-name.d.ts +0 -7
  294. package/dist/utils/get-display-name.js +0 -10
  295. package/dist/utils/get-display-name.js.map +0 -1
  296. package/dist/utils/hsl-to-rgb.js +0 -38
  297. package/dist/utils/hsl-to-rgb.js.map +0 -1
  298. package/dist/utils/is-dev-env.js +0 -19
  299. package/dist/utils/is-dev-env.js.map +0 -1
  300. package/dist/utils/is-valid-element-type.js +0 -15
  301. package/dist/utils/is-valid-element-type.js.map +0 -1
  302. package/dist/utils/merge-styles.js.map +0 -1
  303. package/dist/utils/mod-attrs.d.ts +0 -8
  304. package/dist/utils/mod-attrs.js +0 -21
  305. package/dist/utils/mod-attrs.js.map +0 -1
  306. package/dist/utils/okhsl-to-rgb.js +0 -296
  307. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  308. package/dist/utils/process-tokens.d.ts +0 -31
  309. package/dist/utils/process-tokens.js +0 -171
  310. package/dist/utils/process-tokens.js.map +0 -1
  311. package/dist/utils/resolve-recipes.d.ts +0 -17
  312. package/dist/utils/resolve-recipes.js +0 -147
  313. package/dist/utils/resolve-recipes.js.map +0 -1
  314. package/dist/utils/string.js +0 -8
  315. package/dist/utils/string.js.map +0 -1
  316. package/dist/utils/styles.d.ts +0 -183
  317. package/dist/utils/styles.js +0 -585
  318. package/dist/utils/styles.js.map +0 -1
  319. package/dist/utils/typography.d.ts +0 -36
  320. package/dist/utils/typography.js +0 -53
  321. package/dist/utils/typography.js.map +0 -1
  322. package/dist/utils/warnings.d.ts +0 -16
  323. package/dist/utils/warnings.js +0 -16
  324. package/dist/utils/warnings.js.map +0 -1
  325. package/dist/zero/css-writer.d.ts +0 -45
  326. package/dist/zero/css-writer.js +0 -74
  327. package/dist/zero/css-writer.js.map +0 -1
  328. package/dist/zero/extractor.d.ts +0 -24
  329. package/dist/zero/extractor.js +0 -150
  330. package/dist/zero/extractor.js.map +0 -1
@@ -0,0 +1,659 @@
1
+ # Build-Time Extraction (`tastyStatic`)
2
+
3
+ `tastyStatic` is Tasty's framework-agnostic build-time utility for extracting CSS before rendering. It produces no client styling runtime in file mode, but it is not the only way to achieve zero-runtime delivery: server-only `tasty()` also ships no Tasty runtime to the browser while retaining the full React component API. Astro's `tastyIntegration({ islands: false })` is the clearest example; the same architecture applies to server-only Next.js RSC.
4
+
5
+ Choose `tastyStatic` specifically when styles must be generated during the build, when the consumer is not React, or when you want static class-name objects instead of components. For the broader docs map, see the [Docs Hub](README.md).
6
+
7
+ ---
8
+
9
+ ## When to Use
10
+
11
+ - **CSS that must exist before anything renders** — static sites, landing pages, and HTML served from a CDN get one stylesheet generated at build time
12
+ - **No React at runtime** — `tastyStatic` returns class names, so plain DOM code or any templating that sets `class` can use them; the [Programmatic API](#programmatic-api) covers frameworks Babel does not process
13
+ - **Class-name objects instead of components** — extend them with `tastyStatic(base, styles)` and pass them wherever a `className` goes
14
+ - **Self-contained packages** — [inject mode](#inject-mode) embeds the CSS in the JavaScript, so consumers have no stylesheet to wire up
15
+
16
+ If the styles depend on props, keep `tasty()`: rendered only on the server, it also ships no styling runtime (see [Server-Side Rendering](ssr.md)).
17
+
18
+ ## Requirements
19
+
20
+ Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
21
+
22
+ | Dependency | Version | Required for |
23
+ | ---------------------------- | ------- | ------------------------------------------------------------------------------ |
24
+ | `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
25
+ | `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin |
26
+ | `@babel/types` | >= 7.24 | Babel plugin |
27
+ | `jiti` | >= 2.6 | Babel plugin and Next.js wrapper (imported on load, even without `configFile`) |
28
+ | `babel-loader` | any | Next.js wrapper (`@tenphi/tasty/zero/next`) |
29
+
30
+ The Babel packages and `jiti` are optional peer dependencies of `@tenphi/tasty`; `babel-loader` is resolved from your project. Install what your setup requires:
31
+
32
+ ```bash
33
+ # Any Babel-based setup (Vite, custom Babel config, etc.)
34
+ pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
35
+
36
+ # Next.js
37
+ pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti babel-loader
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Quick Start
43
+
44
+ ### Basic Usage
45
+
46
+ ```tsx
47
+ import { tastyStatic } from '@tenphi/tasty/static';
48
+
49
+ // Define styles - returns StaticStyle object
50
+ const button = tastyStatic({
51
+ display: 'inline-flex',
52
+ padding: '2x 4x',
53
+ fill: '#purple',
54
+ color: '#white',
55
+ radius: '1r',
56
+ });
57
+
58
+ // Use in JSX
59
+ <button className={button.className}>Click me</button>;
60
+
61
+ // toString() returns the class name, for template strings and plain JS
62
+ element.className = `${button} is-active`;
63
+ ```
64
+
65
+ In TSX, pass `button.className`: React types `className` as `string`, so passing the `StaticStyle` object fails type-checking even though it works at runtime.
66
+
67
+ ---
68
+
69
+ ## API Reference
70
+
71
+ ### tastyStatic(styles)
72
+
73
+ Creates a `StaticStyle` object from a styles definition.
74
+
75
+ ```tsx
76
+ const card = tastyStatic({
77
+ padding: '4x',
78
+ fill: '#white',
79
+ border: true,
80
+ radius: true,
81
+ });
82
+ ```
83
+
84
+ ### tastyStatic(base, styles)
85
+
86
+ Extends an existing `StaticStyle` with additional styles. Uses `mergeStyles` internally for proper nested selector handling.
87
+
88
+ ```tsx
89
+ const button = tastyStatic({
90
+ padding: '2x 4x',
91
+ fill: '#blue',
92
+ Icon: { color: '#white' },
93
+ });
94
+
95
+ const primaryButton = tastyStatic(button, {
96
+ fill: '#purple',
97
+ Icon: { opacity: 0.8 },
98
+ });
99
+ ```
100
+
101
+ ### tastyStatic(selector, styles)
102
+
103
+ Generates global styles for a CSS selector. The call is removed from the bundle after transformation.
104
+
105
+ ```tsx
106
+ tastyStatic('body', {
107
+ fill: '#surface',
108
+ color: '#text',
109
+ preset: 't3',
110
+ });
111
+ ```
112
+
113
+ The selector can be a list (`'.uni-checkbox, uni-checkbox'`): every item gets the states and sub-elements. Local `@keyframes` and `@starting` states work as in `tastyStatic(styles)`.
114
+
115
+ ---
116
+
117
+ ## StaticStyle Object
118
+
119
+ | Property | Type | Description |
120
+ | ------------ | -------------- | ------------------------------------------ |
121
+ | `className` | `string` | Space-separated class names for use in JSX |
122
+ | `styles` | `Styles` | The original (or merged) styles object |
123
+ | `toString()` | `() => string` | Returns `className` for string coercion |
124
+
125
+ ---
126
+
127
+ ## Babel Plugin Configuration
128
+
129
+ ### Basic Configuration
130
+
131
+ ```javascript
132
+ // babel.config.js
133
+ module.exports = {
134
+ plugins: [
135
+ [
136
+ '@tenphi/tasty/babel-plugin',
137
+ {
138
+ output: 'public/tasty.css',
139
+ },
140
+ ],
141
+ ],
142
+ };
143
+ ```
144
+
145
+ These examples use `data-schema="dark"` as the root-state convention. If your app already uses a different root attribute such as `data-theme`, keep the same alias pattern and swap the attribute name consistently in your build-time config.
146
+
147
+ ### With Configuration
148
+
149
+ ```javascript
150
+ module.exports = {
151
+ plugins: [
152
+ [
153
+ '@tenphi/tasty/babel-plugin',
154
+ {
155
+ output: 'public/tasty.css',
156
+ config: {
157
+ states: {
158
+ '@mobile': '@media(w < 768px)',
159
+ '@tablet': '@media(w < 1024px)',
160
+ '@dark': '@root(schema=dark)',
161
+ },
162
+ devMode: true,
163
+ },
164
+ },
165
+ ],
166
+ ],
167
+ };
168
+ ```
169
+
170
+ ### Plugin Options
171
+
172
+ | Option | Type | Default | Description |
173
+ | -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
174
+ | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
175
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
176
+ | `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. |
177
+ | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
178
+ | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
179
+ | `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
180
+ | `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
181
+ | `config.devMode` | `boolean` | `false` | Add source comments to CSS |
182
+ | `config.tokens` | `ConfigTokens` | — | Design tokens injected as CSS custom properties on `:root`. Values are parsed through the Tasty DSL. Supports state maps for responsive/themed tokens. |
183
+ | `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
184
+ | `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
185
+ | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
186
+ | `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
187
+ | `config.counterStyles` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
188
+ | `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ em: 'em', vw: 'vw' }` |
189
+ | `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
190
+ | `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
191
+ | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
192
+ | `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
193
+ | `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
194
+ | `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
195
+ | `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
196
+ | `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
197
+ | `config.namePrefix` | `string` | `'ts'` | Prefix prepended to every generated identifier. Defaults to `'ts'` so static classes never collide with runtime (`'t'`) classes. See [Configuration: Name prefix](configuration.md#name-prefix). |
198
+
199
+ ### Coexisting with `tasty()`
200
+
201
+ When a page mixes `tastyStatic` with `tasty`, both must use **different** `namePrefix` values. The defaults handle this automatically (`'t'` for React rendering, `'ts'` for build-time extraction). If you customize one, customize the other:
202
+
203
+ ```ts
204
+ // tasty-zero.config.ts (Babel plugin)
205
+ export default { namePrefix: 'mbs' };
206
+ ```
207
+
208
+ ```ts
209
+ // app entry (`tasty()` configure)
210
+ configure({ namePrefix: 'mb' });
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Recipes
216
+
217
+ Recipes work with `tastyStatic` the same way as with runtime `tasty`:
218
+
219
+ ```javascript
220
+ // babel.config.js
221
+ module.exports = {
222
+ plugins: [
223
+ [
224
+ '@tenphi/tasty/babel-plugin',
225
+ {
226
+ output: 'public/tasty.css',
227
+ config: {
228
+ recipes: {
229
+ card: {
230
+ padding: '4x',
231
+ fill: '#surface',
232
+ radius: '1r',
233
+ border: true,
234
+ },
235
+ elevated: { shadow: '2x 2x 4x #shadow' },
236
+ },
237
+ },
238
+ },
239
+ ],
240
+ ],
241
+ };
242
+ ```
243
+
244
+ ```tsx
245
+ import { tastyStatic } from '@tenphi/tasty/static';
246
+
247
+ const card = tastyStatic({
248
+ recipe: 'card elevated',
249
+ color: '#text',
250
+ });
251
+
252
+ <div className={card.className}>Styled card</div>;
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Next.js Integration
258
+
259
+ The `withTastyZero` wrapper configures both **webpack** and **Turbopack** automatically. No `--webpack` flag is needed — it works with whichever bundler Next.js uses.
260
+
261
+ ```typescript
262
+ // next.config.ts
263
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
264
+
265
+ export default withTastyZero({
266
+ output: 'public/tasty.css',
267
+ configFile: './app/tasty-zero.config.ts',
268
+ configDeps: ['./app/theme.ts'],
269
+ })({
270
+ reactStrictMode: true,
271
+ });
272
+ ```
273
+
274
+ ### `withTastyZero` Options
275
+
276
+ | Option | Type | Default | Description |
277
+ | ------------ | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------- |
278
+ | `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
279
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
280
+ | `enabled` | `boolean` | `true` | Enable/disable the plugin |
281
+ | `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
282
+ | `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
283
+ | `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
284
+
285
+ ### Turbopack Support
286
+
287
+ Starting with Next.js 16, Turbopack is the default bundler. `withTastyZero` supports it out of the box by injecting `turbopack.rules` with `babel-loader` and JSON-serializable options.
288
+
289
+ The `configFile` option is key for Turbopack — it passes a file path (JSON-serializable) instead of a function, and the Babel plugin loads the config internally via jiti.
290
+
291
+ **Requirements**: `babel-loader` must be installed in your project (see [Requirements](#requirements)):
292
+
293
+ ```bash
294
+ pnpm add -D babel-loader
295
+ ```
296
+
297
+ ### CSS Injection
298
+
299
+ `withTastyZero` automatically injects the generated CSS into your app. Every file that imports from `@tenphi/tasty/static` gets its import replaced with an import of the output CSS file at build time. No manual CSS import is needed.
300
+
301
+ The generated CSS file (e.g. `public/tasty.css`) is created as an empty stub before the first build if it doesn't exist, so there's no chicken-and-egg problem with fresh clones or CI builds. Add it to `.gitignore`:
302
+
303
+ ```gitignore
304
+ public/tasty.css
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Programmatic API
310
+
311
+ `@tenphi/tasty/zero` turns styles into CSS in Node without Babel or React — for build scripts, or CSS shipped to other frameworks:
312
+
313
+ ```ts
314
+ import {
315
+ configure,
316
+ extractStylesForSelector,
317
+ extractStylesWithChunks,
318
+ } from '@tenphi/tasty/zero';
319
+
320
+ configure({
321
+ units: { u: 'var(--unit)' },
322
+ states: { '@dark': '@root(schema=dark)' },
323
+ });
324
+
325
+ extractStylesForSelector('.card', { padding: '2u', fill: '#surface' }).css;
326
+ // → '.card { padding: calc(2 * var(--unit)); background-color: … }'
327
+
328
+ extractStylesWithChunks({ display: 'flex', gap: '1u' });
329
+ // → [{ className: 'ts…', css: '.ts….ts… { … }' }]
330
+ ```
331
+
332
+ `configure()` takes the same options as the Babel plugin's `config` (see [Plugin Options](#plugin-options)) and replaces the previous configuration on each call; `resetConfig()` returns to the defaults. Options that shape the extracted rules apply — `states`, `units`, parse `functions`, `handlers`, `replaceTokens`, `recipes`, `plugins`, `namePrefix`. Definitions that become at-rules or global CSS of their own are not emitted: `tokens`, `globalStyles`, `fontFaces`, `counterStyles`, `properties` and `$$` `@function` definitions. Render tokens and global styles with `extractStylesForSelector(':root', tokens)` and `extractStylesForSelector(selector, styles)`.
333
+
334
+ The configuration is process-wide and shared with the Babel plugin and the runtime `configure()` from `@tenphi/tasty`. The extractors re-apply their own configuration when the Babel plugin replaced it, but not after a runtime `configure()` — don't mix the runtime and build-time configuration in one process.
335
+
336
+ `extractStylesForSelector()` output starts with the `@keyframes` its rules animate — local `@keyframes` and configured `keyframes` — under hashed names the `animation` declarations are rewritten to. `extractStylesWithChunks()` returns class rules only.
337
+
338
+ To write the results to a file the way the Babel plugin does, use `createCSSWriter()`. It deduplicates blocks by key and prepends the generated-file header:
339
+
340
+ ```ts
341
+ import { createCSSWriter, extractStylesWithChunks } from '@tenphi/tasty/zero';
342
+
343
+ const writer = createCSSWriter('dist/tasty.css', { devMode: true });
344
+
345
+ for (const chunk of extractStylesWithChunks({ display: 'flex', gap: '1u' })) {
346
+ writer.add(chunk.className, chunk.css, 'src/card.ts'); // source is a devMode comment
347
+ }
348
+
349
+ writer.write(); // also: has(key), getCSS(), clear(), getOutputPath()
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Vite Integration
355
+
356
+ `@vitejs/plugin-react` 6 no longer runs Babel; add it with `@rolldown/plugin-babel` (`pnpm add -D @rolldown/plugin-babel`):
357
+
358
+ ```typescript
359
+ // vite.config.ts
360
+ import { defineConfig } from 'vite';
361
+ import react from '@vitejs/plugin-react';
362
+ import babel from '@rolldown/plugin-babel';
363
+
364
+ export default defineConfig({
365
+ plugins: [
366
+ react(),
367
+ babel({
368
+ plugins: [
369
+ [
370
+ '@tenphi/tasty/babel-plugin',
371
+ {
372
+ output: 'src/tasty.css',
373
+ config: {
374
+ states: { '@mobile': '@media(w < 768px)' },
375
+ },
376
+ },
377
+ ],
378
+ ],
379
+ }),
380
+ ],
381
+ });
382
+ ```
383
+
384
+ With `@vitejs/plugin-react` 5 or older, pass the same `plugins` array to `react({ babel: { plugins } })` instead.
385
+
386
+ Keep `output` outside `public/`: the plugin replaces each `@tenphi/tasty/static` import with an import of the generated file, and Vite does not let JavaScript import files from `public/`. Vite then bundles the CSS like any other stylesheet.
387
+
388
+ ---
389
+
390
+ ## Build Transformation
391
+
392
+ ### Before (Source Code)
393
+
394
+ ```tsx
395
+ import { tastyStatic } from '@tenphi/tasty/static';
396
+
397
+ const button = tastyStatic({
398
+ padding: '2x 4x',
399
+ fill: '#purple',
400
+ color: '#white',
401
+ });
402
+
403
+ tastyStatic('.heading', { preset: 'h1' });
404
+
405
+ export const Button = () => <button className={button.className}>Click</button>;
406
+ ```
407
+
408
+ ### After (Production Build)
409
+
410
+ ```tsx
411
+ import './tasty.css';
412
+
413
+ const button = {
414
+ className: 'ts3f783b ts070801',
415
+ styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
416
+ toString() {
417
+ return this.className;
418
+ },
419
+ };
420
+
421
+ export const Button = () => <button className={button.className}>Click</button>;
422
+ ```
423
+
424
+ The `@tenphi/tasty/static` import becomes an import of the generated file (relative to the source file), and the selector-mode call is removed.
425
+
426
+ ### Generated CSS (tasty.css)
427
+
428
+ ```css
429
+ /* Generated by @tenphi/tasty/zero - DO NOT EDIT */
430
+
431
+ @property --current-color {
432
+ syntax: '<color>';
433
+ inherits: true;
434
+ initial-value: transparent;
435
+ }
436
+
437
+ .ts3f783b.ts3f783b {
438
+ color: var(--white-color);
439
+ --current-color: var(--white-color);
440
+ }
441
+
442
+ .ts3f783b.ts3f783b {
443
+ background-color: var(--purple-color);
444
+ }
445
+
446
+ .ts070801.ts070801 {
447
+ padding: 16px 32px;
448
+ }
449
+
450
+ .heading {
451
+ font-size: var(--h1-font-size, var(--default-font-size));
452
+ /* …line-height, letter-spacing, font-weight, and the rest of the h1 preset */
453
+ }
454
+ ```
455
+
456
+ Styles are split into chunks (here appearance and spacing), each with its own class. Color tokens compile to custom properties: `#purple` becomes `var(--purple-color)`. Define it in `config.tokens` and the plugin writes it to `:root` at the top of the same file. Units are literal (`2x` is `16px`). Selector-mode rules use the selector as written, without the doubled specificity of class rules.
457
+
458
+ ---
459
+
460
+ ## Inject Mode
461
+
462
+ By default the Babel plugin writes CSS to a file (`mode: 'file'`). **Inject mode** (`mode: 'inject'`) embeds CSS inline in your JavaScript and injects it at runtime via a tiny injector. No CSS file is produced.
463
+
464
+ This is ideal for **reusable components**, **extensions**, and **libraries** where consumers shouldn't need to manage an external CSS file.
465
+
466
+ ### How It Works
467
+
468
+ 1. The Babel plugin extracts CSS at build time (same pipeline as file mode).
469
+ 2. Instead of writing to a `.css` file, the CSS is embedded as string literals in the JS output.
470
+ 3. The `@tenphi/tasty/static` import is rewritten to `@tenphi/tasty/static/inject`.
471
+ 4. Each `tastyStatic` call becomes a self-contained expression that injects its CSS and evaluates to a `StaticStyle` object.
472
+
473
+ ### Configuration
474
+
475
+ ```javascript
476
+ // babel.config.js
477
+ module.exports = {
478
+ plugins: [
479
+ [
480
+ '@tenphi/tasty/babel-plugin',
481
+ {
482
+ mode: 'inject',
483
+ config: {
484
+ states: { '@mobile': '@media(w < 768px)' },
485
+ },
486
+ },
487
+ ],
488
+ ],
489
+ };
490
+ ```
491
+
492
+ With Next.js:
493
+
494
+ ```typescript
495
+ // next.config.ts
496
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
497
+
498
+ export default withTastyZero({
499
+ mode: 'inject',
500
+ configFile: './app/tasty-zero.config.ts',
501
+ })({
502
+ reactStrictMode: true,
503
+ });
504
+ ```
505
+
506
+ When `mode` is `'inject'`, the `output` and `injectImport` options are ignored.
507
+
508
+ ### Build Transformation (inject mode)
509
+
510
+ **Before:**
511
+
512
+ ```tsx
513
+ import { tastyStatic } from '@tenphi/tasty/static';
514
+
515
+ const button = tastyStatic({
516
+ padding: '2x 4x',
517
+ fill: '#purple',
518
+ });
519
+
520
+ tastyStatic('.heading', { preset: 'h1' });
521
+ ```
522
+
523
+ **After:**
524
+
525
+ ```tsx
526
+ import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
527
+
528
+ const button =
529
+ (_$i(
530
+ 'tsa903d6 ts070801',
531
+ '.tsa903d6.tsa903d6 { background-color: var(--purple-color); }\n.ts070801.ts070801 { padding: 16px 32px; }',
532
+ ),
533
+ {
534
+ className: 'tsa903d6 ts070801',
535
+ styles: { padding: '2x 4x', fill: '#purple' },
536
+ toString() {
537
+ return this.className;
538
+ },
539
+ });
540
+
541
+ _$i('.heading', '.heading { font-size: var(--h1-font-size, …); … }');
542
+ ```
543
+
544
+ ### Dev Mode / HMR
545
+
546
+ Class names are content-hashed (`ts` + MD5). When styles change, a new hash produces a new `_$i` call that injects fresh CSS. The injector deduplicates by id, so unchanged styles are skipped. Old CSS stays in the DOM but is harmless since no elements reference those class names.
547
+
548
+ ### Limitations (inject mode)
549
+
550
+ - **Client-side only** — Styles are injected via the DOM, so they are not available during SSR. For server-rendered apps, use `mode: 'file'` or React `tasty()`.
551
+ - **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
552
+
553
+ ---
554
+
555
+ ## Style Extension
556
+
557
+ ```tsx
558
+ // Base button
559
+ const button = tastyStatic({
560
+ display: 'inline-flex',
561
+ padding: '2x 4x',
562
+ radius: '1r',
563
+ fill: '#gray.20',
564
+ color: '#text',
565
+ transition: 'fill',
566
+ });
567
+
568
+ // Variants
569
+ const primaryButton = tastyStatic(button, {
570
+ fill: '#purple',
571
+ color: '#white',
572
+ });
573
+
574
+ const dangerButton = tastyStatic(button, {
575
+ fill: '#danger',
576
+ color: '#white',
577
+ });
578
+ ```
579
+
580
+ ---
581
+
582
+ ## State-based Styling
583
+
584
+ ```tsx
585
+ const card = tastyStatic({
586
+ padding: {
587
+ '': '4x',
588
+ '@mobile': '2x',
589
+ },
590
+ display: {
591
+ '': 'flex',
592
+ '@mobile': 'block',
593
+ },
594
+ });
595
+ ```
596
+
597
+ ---
598
+
599
+ ## Extending Style Types (TypeScript)
600
+
601
+ If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [TypeScript](configuration.md#typescript) in the configuration docs.
602
+
603
+ ---
604
+
605
+ ## Limitations
606
+
607
+ 1. **Static values only** — All style values must be known at build time
608
+ 2. **No runtime props** — Cannot use `styleProps` or dynamic `styles` prop
609
+ 3. **No mods at runtime** — Modifiers must be defined statically
610
+ 4. **Build-time transformation required** — Babel plugin must process files
611
+ 5. **No built-in token defaults** — The runtime registers fallbacks for `#white`, `#black`, `#clear`, `#border`, `$gap`, `$radius`, `$border-width`, `$outline-width`, and a few others as `@property` initial values. The Babel plugin does not emit them, so define every token your styles reference in `config.tokens`.
612
+ 6. **`config.properties` is ignored** — It type-checks, but no `@property` rules are generated from it. Automatically inferred properties (`autoPropertyTypes`) are emitted.
613
+
614
+ ### Workarounds
615
+
616
+ For dynamic styling needs, combine with regular CSS or CSS variables:
617
+
618
+ ```tsx
619
+ const card = tastyStatic({
620
+ padding: '4x',
621
+ fill: '($card-bg, #white)',
622
+ });
623
+
624
+ <div
625
+ className={card.className}
626
+ style={
627
+ {
628
+ '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
629
+ } as React.CSSProperties
630
+ }
631
+ />;
632
+ ```
633
+
634
+ ---
635
+
636
+ ## Best Practices
637
+
638
+ 1. **Define base styles** for common patterns, then extend for variants
639
+ 2. **Use selector mode** for global/body styles
640
+ 3. **Enable devMode** in development for easier debugging
641
+ 4. **Configure states** for consistent responsive breakpoints
642
+
643
+ ---
644
+
645
+ ## Common Issues
646
+
647
+ - No CSS file is generated: make sure the Babel plugin actually runs for files importing `@tenphi/tasty/static`, and verify the `output` path is writable.
648
+ - Styles stay dynamic by mistake: `tastyStatic()` only supports build-time-known values. Move dynamic values to CSS variables or switch that component to React `tasty()`.
649
+ - Turbopack config behaves inconsistently: prefer `configFile` over inline functions so the setup stays JSON-serializable.
650
+
651
+ ---
652
+
653
+ ## Related
654
+
655
+ - [Docs Hub](README.md) — Choose the right guide by task or CSS delivery model
656
+ - [Style DSL](dsl.md) — State maps, tokens, units, extending semantics (shared by runtime and static)
657
+ - [React API](react-api.md) — Client or server rendering with `tasty()`: component props, variants, sub-elements, and style functions
658
+ - [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
659
+ - [Plugins & Extension Points](plugins.md) — Which extension points work at build time (`functions`, `units`, `states`, `handlers`, `recipes`) and which do not (`propHandlers` — `tastyStatic()` takes styles objects, not props)