@tenphi/tasty 0.0.0-snapshot.8dc3efa → 0.0.0-snapshot.8efdc31

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 (130) hide show
  1. package/README.md +440 -372
  2. package/dist/babel-types-docs8f4c.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-DmSCYjYl.js +60 -0
  6. package/dist/chunks/build-config-DmSCYjYl.js.map +1 -0
  7. package/dist/{collector-CBddDz-s.js → chunks/collector-8w5r-xFl.js} +68 -101
  8. package/dist/chunks/collector-8w5r-xFl.js.map +1 -0
  9. package/dist/chunks/config-engine-DjRv6Axa.js +272 -0
  10. package/dist/chunks/config-engine-DjRv6Axa.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-_UidGa56.js +910 -0
  14. package/dist/chunks/css-definitions-_UidGa56.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-B6dZq3uH.js +502 -0
  18. package/dist/chunks/debug-B6dZq3uH.js.map +1 -0
  19. package/dist/chunks/dsl-rgu6XQcD.js +1386 -0
  20. package/dist/chunks/dsl-rgu6XQcD.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-DS1cEAMK.js +689 -0
  24. package/dist/chunks/react-runtime-DS1cEAMK.js.map +1 -0
  25. package/dist/chunks/runtime-engine-DFCZN1nF.js +2432 -0
  26. package/dist/chunks/runtime-engine-DFCZN1nF.js.map +1 -0
  27. package/dist/chunks/runtime-state-C8MzPjBR.js +152 -0
  28. package/dist/chunks/runtime-state-C8MzPjBR.js.map +1 -0
  29. package/dist/{merge-styles-CWRl0mKF.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-DoGrZPBB.js +5576 -0
  32. package/dist/chunks/style-engine-DoGrZPBB.js.map +1 -0
  33. package/dist/{css-writer-DPR4cAyK.js → chunks/zero-engine-CiVidroC.js} +95 -136
  34. package/dist/chunks/zero-engine-CiVidroC.js.map +1 -0
  35. package/dist/{collector-osfWTeRd.d.ts → collector-CTU-nl0g.d.ts} +64 -8
  36. package/dist/{config-BoZDUHW5.d.ts → config-DDY7NlZ1.d.ts} +514 -92
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-B_k47mc_.d.ts → index-DOxyS72p.d.ts} +714 -407
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  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 +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +163 -91
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -32
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  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 +9 -9
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/static/inject.js.map +1 -1
  78. package/dist/{index-tcHuMPFt.d.ts → types-DJEM_BOJ.d.ts} +879 -598
  79. package/dist/zero/babel.d.ts +12 -20
  80. package/dist/zero/babel.js +97 -156
  81. package/dist/zero/babel.js.map +1 -1
  82. package/dist/zero/index.d.ts +76 -7
  83. package/dist/zero/index.js +25 -2
  84. package/dist/zero/index.js.map +1 -0
  85. package/dist/zero/next.d.ts +4 -5
  86. package/dist/zero/next.js +3 -38
  87. package/dist/zero/next.js.map +1 -1
  88. package/docs/README.md +20 -9
  89. package/docs/adoption.md +69 -36
  90. package/docs/ai-agents.md +258 -0
  91. package/docs/comparison.md +77 -47
  92. package/docs/configuration.md +617 -98
  93. package/docs/debug.md +28 -15
  94. package/docs/design-system.md +154 -33
  95. package/docs/dsl.md +663 -194
  96. package/docs/getting-started.md +130 -50
  97. package/docs/injector.md +160 -69
  98. package/docs/methodology.md +82 -51
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +102 -33
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +213 -48
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -118
  105. package/docs/styles.md +177 -40
  106. package/docs/tasty-static.md +289 -136
  107. package/package.json +146 -41
  108. package/tasty.config.ts +5 -0
  109. package/dist/async-storage-B7_o6FKt.js +0 -44
  110. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  111. package/dist/collector-CBddDz-s.js.map +0 -1
  112. package/dist/config-dkNtxY1j.js +0 -10462
  113. package/dist/config-dkNtxY1j.js.map +0 -1
  114. package/dist/context-CkSg-kDT.js +0 -24
  115. package/dist/context-CkSg-kDT.js.map +0 -1
  116. package/dist/core-CWJ4JX5P.js +0 -1598
  117. package/dist/core-CWJ4JX5P.js.map +0 -1
  118. package/dist/css-writer-DPR4cAyK.js.map +0 -1
  119. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  120. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  121. package/dist/format-rules-BnfFVBQE.js +0 -143
  122. package/dist/format-rules-BnfFVBQE.js.map +0 -1
  123. package/dist/hydrate-Chagc_CN.js +0 -45
  124. package/dist/hydrate-Chagc_CN.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/keyframes-Dbe0HQAg.js +0 -588
  127. package/dist/keyframes-Dbe0HQAg.js.map +0 -1
  128. package/dist/merge-styles-CWRl0mKF.js.map +0 -1
  129. package/dist/resolve-recipes-DZBMeDib.js +0 -144
  130. package/dist/resolve-recipes-DZBMeDib.js.map +0 -1
@@ -1,35 +1,45 @@
1
- # Zero Runtime Mode (tastyStatic)
1
+ # Build-Time Extraction (`tastyStatic`)
2
2
 
3
- `tastyStatic` is a build-time utility for generating CSS with zero runtime overhead. It's designed for static sites, no-JS websites, and performance-critical applications where you want to eliminate all runtime styling code. For the broader docs map, see the [Docs Hub](README.md).
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).
4
6
 
5
7
  ---
6
8
 
7
9
  ## When to Use
8
10
 
9
- - **Static site generation (SSG)** — Pre-render all styles at build time
10
- - **No-JavaScript websites** — CSS works without any JS runtime
11
- - **Performance-critical pages** — Zero runtime overhead for styling
12
- - **Landing pages** — Minimal bundle size with pre-generated CSS
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)).
13
17
 
14
18
  ## Requirements
15
19
 
16
- The zero-runtime mode is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
20
+ Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
17
21
 
18
- | Dependency | Version | Required for |
19
- |---|---|---|
20
- | `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
21
- | `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin |
22
- | `@babel/types` | >= 7.24 | Babel plugin |
23
- | `jiti` | >= 2.6 | Next.js wrapper (`@tenphi/tasty/next`) when using `configFile` option |
22
+ | Dependency | Version | Required for |
23
+ | ---------------------------- | ---------------------- | ---------------------------------------------------- |
24
+ | `@babel/core` | 7.24+ or 8 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
25
+ | `@babel/helper-plugin-utils` | 7.24+ or 8 | Babel plugin |
26
+ | `@babel/types` | 7.24+ or 8 | Babel plugin |
27
+ | `jiti` | >= 2.6 | `configFile` only (Babel plugin and Next.js wrapper) |
28
+ | `babel-loader` | any (10+ with Babel 8) | Next.js wrapper (`@tenphi/tasty/zero/next`) |
24
29
 
25
- All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
30
+ Install the three Babel packages from the same major. Babel 8 itself needs Node 22.18+ or 24.11+, and `babel-loader` accepts it from version 10.
31
+
32
+ The Babel packages and `jiti` are optional peer dependencies of `@tenphi/tasty`; `babel-loader` is resolved from your project. `jiti` is loaded only to read a `configFile`, so a setup that passes `config` directly does not need it; without it, `configFile` fails with an error that says to install it. Install what your setup requires:
26
33
 
27
34
  ```bash
28
- # For any Babel-based setup (Vite, custom Babel config, etc.)
35
+ # Any Babel-based setup (Vite, custom Babel config, etc.)
29
36
  pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
30
37
 
31
- # For Next.js with TypeScript config file
32
- pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
38
+ # Next.js
39
+ pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types babel-loader
40
+
41
+ # Either, with configFile
42
+ pnpm add -D jiti
33
43
  ```
34
44
 
35
45
  ---
@@ -50,13 +60,15 @@ const button = tastyStatic({
50
60
  radius: '1r',
51
61
  });
52
62
 
53
- // Use in JSX - works via toString() coercion
54
- <button className={button}>Click me</button>
63
+ // Use in JSX
64
+ <button className={button.className}>Click me</button>;
55
65
 
56
- // Or access className explicitly
57
- <button className={button.className}>Click me</button>
66
+ // toString() returns the class name, for template strings and plain JS
67
+ element.className = `${button} is-active`;
58
68
  ```
59
69
 
70
+ In TSX, pass `button.className`: React types `className` as `string`, so passing the `StaticStyle` object fails type-checking even though it works at runtime.
71
+
60
72
  ---
61
73
 
62
74
  ## API Reference
@@ -103,15 +115,17 @@ tastyStatic('body', {
103
115
  });
104
116
  ```
105
117
 
118
+ 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)`.
119
+
106
120
  ---
107
121
 
108
122
  ## StaticStyle Object
109
123
 
110
- | Property | Type | Description |
111
- |----------|------|-------------|
112
- | `className` | `string` | Space-separated class names for use in JSX |
113
- | `styles` | `Styles` | The original (or merged) styles object |
114
- | `toString()` | `() => string` | Returns `className` for string coercion |
124
+ | Property | Type | Description |
125
+ | ------------ | -------------- | ------------------------------------------ |
126
+ | `className` | `string` | Space-separated class names for use in JSX |
127
+ | `styles` | `Styles` | The original (or merged) styles object |
128
+ | `toString()` | `() => string` | Returns `className` for string coercion |
115
129
 
116
130
  ---
117
131
 
@@ -123,66 +137,74 @@ tastyStatic('body', {
123
137
  // babel.config.js
124
138
  module.exports = {
125
139
  plugins: [
126
- ['@tenphi/tasty/babel-plugin', {
127
- output: 'public/tasty.css',
128
- }]
129
- ]
140
+ [
141
+ '@tenphi/tasty/babel-plugin',
142
+ {
143
+ output: 'public/tasty.css',
144
+ },
145
+ ],
146
+ ],
130
147
  };
131
148
  ```
132
149
 
133
- 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 zero-runtime config.
150
+ 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.
134
151
 
135
152
  ### With Configuration
136
153
 
137
154
  ```javascript
138
155
  module.exports = {
139
156
  plugins: [
140
- ['@tenphi/tasty/babel-plugin', {
141
- output: 'public/tasty.css',
142
- config: {
143
- states: {
144
- '@mobile': '@media(w < 768px)',
145
- '@tablet': '@media(w < 1024px)',
146
- '@dark': '@root(schema=dark)',
157
+ [
158
+ '@tenphi/tasty/babel-plugin',
159
+ {
160
+ output: 'public/tasty.css',
161
+ config: {
162
+ states: {
163
+ '@mobile': '@media(w < 768px)',
164
+ '@tablet': '@media(w < 1024px)',
165
+ '@dark': '@root(schema=dark)',
166
+ },
167
+ devMode: true,
147
168
  },
148
- devMode: true,
149
169
  },
150
- }]
151
- ]
170
+ ],
171
+ ],
152
172
  };
153
173
  ```
154
174
 
155
175
  ### Plugin Options
156
176
 
157
- | Option | Type | Default | Description |
158
- |--------|------|---------|-------------|
159
- | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
160
- | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
161
- | `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. |
162
- | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
163
- | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
164
- | `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
165
- | `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
166
- | `config.devMode` | `boolean` | `false` | Add source comments to CSS |
167
- | `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. |
168
- | `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
169
- | `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
170
- | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
171
- | `config.fontFace` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
172
- | `config.counterStyle` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
173
- | `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ em: 'em', vw: 'vw' }` |
174
- | `config.funcs` | `Record<string, Function>` | — | Custom functions for the style parser (merged with existing) |
175
- | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
176
- | `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
177
- | `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
178
- | `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
179
- | `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
180
- | `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
181
- | `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). |
182
-
183
- ### Coexisting with runtime tasty
184
-
185
- When a page mixes `tastyStatic` with runtime `tasty`, both must use **different** `namePrefix` values. The defaults handle this automatically (`'t'` for runtime, `'ts'` for zero-runtime). If you customize one, customize the other:
177
+ | Option | Type | Default | Description |
178
+ | -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
179
+ | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
180
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
181
+ | `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. Loaded with the optional `jiti` peer. |
182
+ | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
183
+ | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
184
+ | `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
185
+ | `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
186
+ | `config.devMode` | `boolean` | `false` | Add source comments to CSS |
187
+ | `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. |
188
+ | `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
189
+ | `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
190
+ | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
191
+ | `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
192
+ | `config.counterStyles` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
193
+ | `config.properties` | `Record<string, PropertyDefinition>` | — | Global `@property` definitions, written with Tasty's [default properties](dsl.md#default-properties) |
194
+ | `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ u: 'var(--u)' }` makes `2u` compile to `calc(2 * var(--u))`. Native CSS units need no entry |
195
+ | `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
196
+ | `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
197
+ | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
198
+ | `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
199
+ | `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
200
+ | `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
201
+ | `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
202
+ | `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
203
+ | `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). |
204
+
205
+ ### Coexisting with `tasty()`
206
+
207
+ 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:
186
208
 
187
209
  ```ts
188
210
  // tasty-zero.config.ts (Babel plugin)
@@ -190,7 +212,7 @@ export default { namePrefix: 'mbs' };
190
212
  ```
191
213
 
192
214
  ```ts
193
- // app entry (runtime configure)
215
+ // app entry (`tasty()` configure)
194
216
  configure({ namePrefix: 'mb' });
195
217
  ```
196
218
 
@@ -204,16 +226,24 @@ Recipes work with `tastyStatic` the same way as with runtime `tasty`:
204
226
  // babel.config.js
205
227
  module.exports = {
206
228
  plugins: [
207
- ['@tenphi/tasty/babel-plugin', {
208
- output: 'public/tasty.css',
209
- config: {
210
- recipes: {
211
- card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
212
- elevated: { shadow: '2x 2x 4x #shadow' },
229
+ [
230
+ '@tenphi/tasty/babel-plugin',
231
+ {
232
+ output: 'public/tasty.css',
233
+ config: {
234
+ recipes: {
235
+ card: {
236
+ padding: '4x',
237
+ fill: '#surface',
238
+ radius: '1r',
239
+ border: true,
240
+ },
241
+ elevated: { shadow: '2x 2x 4x #shadow' },
242
+ },
213
243
  },
214
244
  },
215
- }]
216
- ]
245
+ ],
246
+ ],
217
247
  };
218
248
  ```
219
249
 
@@ -225,7 +255,7 @@ const card = tastyStatic({
225
255
  color: '#text',
226
256
  });
227
257
 
228
- <div className={card}>Styled card</div>
258
+ <div className={card.className}>Styled card</div>;
229
259
  ```
230
260
 
231
261
  ---
@@ -236,7 +266,7 @@ The `withTastyZero` wrapper configures both **webpack** and **Turbopack** automa
236
266
 
237
267
  ```typescript
238
268
  // next.config.ts
239
- import { withTastyZero } from '@tenphi/tasty/next';
269
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
240
270
 
241
271
  export default withTastyZero({
242
272
  output: 'public/tasty.css',
@@ -249,25 +279,25 @@ export default withTastyZero({
249
279
 
250
280
  ### `withTastyZero` Options
251
281
 
252
- | Option | Type | Default | Description |
253
- |--------|------|---------|-------------|
254
- | `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
255
- | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
256
- | `enabled` | `boolean` | `true` | Enable/disable the plugin |
257
- | `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
258
- | `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
259
- | `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
282
+ | Option | Type | Default | Description |
283
+ | ------------ | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------- |
284
+ | `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
285
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
286
+ | `enabled` | `boolean` | `true` | Enable/disable the plugin |
287
+ | `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
288
+ | `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
289
+ | `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
260
290
 
261
291
  ### Turbopack Support
262
292
 
263
293
  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.
264
294
 
265
- 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.
295
+ 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`, which must be installed.
266
296
 
267
- **Requirements**: `babel-loader` must be installed in your project:
297
+ **Requirements**: `babel-loader` must be installed in your project (see [Requirements](#requirements)):
268
298
 
269
299
  ```bash
270
- pnpm add babel-loader
300
+ pnpm add -D babel-loader
271
301
  ```
272
302
 
273
303
  ### CSS Injection
@@ -282,31 +312,107 @@ public/tasty.css
282
312
 
283
313
  ---
284
314
 
315
+ ## Programmatic API
316
+
317
+ `@tenphi/tasty/zero` turns styles into CSS in Node without Babel or React — for build scripts, or CSS shipped to other frameworks:
318
+
319
+ ```ts
320
+ import {
321
+ configure,
322
+ extractStylesForSelector,
323
+ extractStylesWithChunks,
324
+ } from '@tenphi/tasty/zero';
325
+
326
+ configure({
327
+ units: { u: 'var(--unit)' },
328
+ states: { '@dark': '@root(schema=dark)' },
329
+ });
330
+
331
+ extractStylesForSelector('.card', { padding: '2u', fill: '#surface' }).css;
332
+ // → '.card { padding: calc(2 * var(--unit)); background-color: … }'
333
+
334
+ extractStylesWithChunks({ display: 'flex', gap: '1u' });
335
+ // → [{ className: 'ts…', css: '.ts….ts… { … }' }]
336
+ ```
337
+
338
+ `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 with the rules: `tokens`, `globalStyles`, `fontFaces`, `counterStyles`, `properties` and `$$` `@function` definitions. Render tokens and global styles with `extractStylesForSelector(':root', tokens)` and `extractStylesForSelector(selector, styles)`.
339
+
340
+ `extractConfigProperties()` returns the `@property` rules the Babel plugin writes at the top of its output: Tasty's [default set](dsl.md#default-properties) (`#border`, `#outline`, `$gap`, `$radius`, `$transition`, …) overlaid with the configured `properties`, or with the `properties` map you pass it. Emit them once per stylesheet. Style handlers read several of these tokens with no fallback of their own (`border: true` reads `#border`, `transition` reads `$transition`), so without them those declarations resolve to nothing.
341
+
342
+ 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.
343
+
344
+ `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.
345
+
346
+ `mergeStyles()` merges style objects with the rules `tasty(Base, { styles })` extends by — state maps with and without a `''` key, `null`, `false`, `'@inherit'` and sub-elements (see [Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps)) — so a build script can layer overrides onto source styles before extracting them, without React:
347
+
348
+ ```ts
349
+ import { extractStylesForSelector, mergeStyles } from '@tenphi/tasty/zero';
350
+
351
+ const styles = mergeStyles(checkboxStyles, {
352
+ Indicator: { radius: '0.5r' },
353
+ });
354
+
355
+ extractStylesForSelector('.checkbox', styles).css;
356
+ ```
357
+
358
+ 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:
359
+
360
+ ```ts
361
+ import {
362
+ createCSSWriter,
363
+ extractConfigProperties,
364
+ extractStylesWithChunks,
365
+ } from '@tenphi/tasty/zero';
366
+
367
+ const writer = createCSSWriter('dist/tasty.css', { devMode: true });
368
+
369
+ for (const prop of extractConfigProperties()) {
370
+ writer.add(`@property:${prop.name}`, prop.css);
371
+ }
372
+
373
+ for (const chunk of extractStylesWithChunks({ display: 'flex', gap: '1u' })) {
374
+ writer.add(chunk.className, chunk.css, 'src/card.ts'); // source is a devMode comment
375
+ }
376
+
377
+ writer.write(); // also: has(key), getCSS(), clear(), getOutputPath()
378
+ ```
379
+
380
+ ---
381
+
285
382
  ## Vite Integration
286
383
 
384
+ `@vitejs/plugin-react` 6 no longer runs Babel; add it with `@rolldown/plugin-babel` (`pnpm add -D @rolldown/plugin-babel`):
385
+
287
386
  ```typescript
288
387
  // vite.config.ts
289
388
  import { defineConfig } from 'vite';
290
389
  import react from '@vitejs/plugin-react';
390
+ import babel from '@rolldown/plugin-babel';
291
391
 
292
392
  export default defineConfig({
293
393
  plugins: [
294
- react({
295
- babel: {
296
- plugins: [
297
- ['@tenphi/tasty/babel-plugin', {
298
- output: 'public/tasty.css',
394
+ react(),
395
+ babel({
396
+ plugins: [
397
+ [
398
+ '@tenphi/tasty/babel-plugin',
399
+ {
400
+ output: 'src/tasty.css',
299
401
  config: {
300
402
  states: { '@mobile': '@media(w < 768px)' },
301
403
  },
302
- }],
404
+ },
303
405
  ],
304
- },
406
+ ],
305
407
  }),
306
408
  ],
307
409
  });
308
410
  ```
309
411
 
412
+ With `@vitejs/plugin-react` 5 or older, pass the same `plugins` array to `react({ babel: { plugins } })` instead.
413
+
414
+ 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.
415
+
310
416
  ---
311
417
 
312
418
  ## Build Transformation
@@ -324,42 +430,67 @@ const button = tastyStatic({
324
430
 
325
431
  tastyStatic('.heading', { preset: 'h1' });
326
432
 
327
- export const Button = () => <button className={button}>Click</button>;
433
+ export const Button = () => <button className={button.className}>Click</button>;
328
434
  ```
329
435
 
330
436
  ### After (Production Build)
331
437
 
332
438
  ```tsx
439
+ import './tasty.css';
440
+
333
441
  const button = {
334
- className: 'ts3f2a1b ts8c4d2e',
442
+ className: 'ts3f783b ts070801',
335
443
  styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
336
- toString() { return this.className; }
444
+ toString() {
445
+ return this.className;
446
+ },
337
447
  };
338
448
 
339
- export const Button = () => <button className={button}>Click</button>;
449
+ export const Button = () => <button className={button.className}>Click</button>;
340
450
  ```
341
451
 
452
+ The `@tenphi/tasty/static` import becomes an import of the generated file (relative to the source file), and the selector-mode call is removed.
453
+
342
454
  ### Generated CSS (tasty.css)
343
455
 
344
456
  ```css
345
457
  /* Generated by @tenphi/tasty/zero - DO NOT EDIT */
346
458
 
347
- .ts3f2a1b.ts3f2a1b {
348
- padding: 16px 32px;
459
+ @property --tasty-second-fill-color {
460
+ syntax: '<color>';
461
+ inherits: false;
462
+ initial-value: transparent;
463
+ }
464
+
465
+ @property --current-color {
466
+ syntax: '<color>';
467
+ inherits: true;
468
+ initial-value: currentcolor;
469
+ }
470
+
471
+ /* …the rest of Tasty's default @property rules (--white-color, --border-color, --gap, --transition, …), then config.properties */
472
+
473
+ .ts3f783b.ts3f783b {
474
+ color: var(--white-color);
475
+ --current-color: var(--white-color);
476
+ }
477
+
478
+ .ts3f783b.ts3f783b {
479
+ background-color: var(--purple-color);
349
480
  }
350
481
 
351
- .ts8c4d2e.ts8c4d2e {
352
- background: #9370db;
353
- color: #fff;
482
+ .ts070801.ts070801 {
483
+ padding: 16px 32px;
354
484
  }
355
485
 
356
- .heading.heading {
357
- font-size: 2.5rem;
358
- font-weight: 700;
359
- line-height: 1.2;
486
+ .heading {
487
+ font-size: var(--h1-font-size, var(--default-font-size));
488
+ /* …line-height, letter-spacing, font-weight, and the rest of the h1 preset */
360
489
  }
361
490
  ```
362
491
 
492
+ The file starts with Tasty's [default `@property` rules](dsl.md#default-properties) and your `config.properties`, written once. 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.
493
+
363
494
  ---
364
495
 
365
496
  ## Inject Mode
@@ -381,13 +512,16 @@ This is ideal for **reusable components**, **extensions**, and **libraries** whe
381
512
  // babel.config.js
382
513
  module.exports = {
383
514
  plugins: [
384
- ['@tenphi/tasty/babel-plugin', {
385
- mode: 'inject',
386
- config: {
387
- states: { '@mobile': '@media(w < 768px)' },
515
+ [
516
+ '@tenphi/tasty/babel-plugin',
517
+ {
518
+ mode: 'inject',
519
+ config: {
520
+ states: { '@mobile': '@media(w < 768px)' },
521
+ },
388
522
  },
389
- }]
390
- ]
523
+ ],
524
+ ],
391
525
  };
392
526
  ```
393
527
 
@@ -395,7 +529,7 @@ With Next.js:
395
529
 
396
530
  ```typescript
397
531
  // next.config.ts
398
- import { withTastyZero } from '@tenphi/tasty/next';
532
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
399
533
 
400
534
  export default withTastyZero({
401
535
  mode: 'inject',
@@ -427,22 +561,36 @@ tastyStatic('.heading', { preset: 'h1' });
427
561
  ```tsx
428
562
  import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
429
563
 
430
- const button = (_$i("ts3f2a1b ts8c4d2e", ".ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}"), {
431
- className: 'ts3f2a1b ts8c4d2e',
432
- styles: { padding: '2x 4x', fill: '#purple' },
433
- toString() { return this.className; }
434
- });
435
-
436
- _$i(".heading", ".heading{font-size:2.5rem;font-weight:700;line-height:1.2}");
564
+ _$i(
565
+ '@property',
566
+ '@property --tasty-second-fill-color { … }\n@property --current-color { … }\n…',
567
+ );
568
+
569
+ const button =
570
+ (_$i(
571
+ 'tsa903d6 ts070801',
572
+ '.tsa903d6.tsa903d6 { background-color: var(--purple-color); }\n.ts070801.ts070801 { padding: 16px 32px; }',
573
+ ),
574
+ {
575
+ className: 'tsa903d6 ts070801',
576
+ styles: { padding: '2x 4x', fill: '#purple' },
577
+ toString() {
578
+ return this.className;
579
+ },
580
+ });
581
+
582
+ _$i('.heading', '.heading { font-size: var(--h1-font-size, …); … }');
437
583
  ```
438
584
 
585
+ Each file that calls `tastyStatic()` starts by injecting Tasty's default `@property` rules and your `config.properties` under the `@property` id. `injectCSS()` skips an id it has already injected, so the page gets them once.
586
+
439
587
  ### Dev Mode / HMR
440
588
 
441
589
  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.
442
590
 
443
591
  ### Limitations (inject mode)
444
592
 
445
- - **Client-side only** — Styles are injected via the DOM, so they are not available during SSR. For server-rendered apps, use `mode: 'file'` or the runtime `tasty()`.
593
+ - **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()`.
446
594
  - **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
447
595
 
448
596
  ---
@@ -457,7 +605,7 @@ const button = tastyStatic({
457
605
  radius: '1r',
458
606
  fill: '#gray.20',
459
607
  color: '#text',
460
- transition: 'fill 0.15s',
608
+ transition: 'fill',
461
609
  });
462
610
 
463
611
  // Variants
@@ -493,7 +641,7 @@ const card = tastyStatic({
493
641
 
494
642
  ## Extending Style Types (TypeScript)
495
643
 
496
- If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [Extending Style Types](configuration.md#extending-style-types-typescript) in the configuration docs.
644
+ If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [TypeScript](configuration.md#typescript) in the configuration docs.
497
645
 
498
646
  ---
499
647
 
@@ -511,13 +659,17 @@ For dynamic styling needs, combine with regular CSS or CSS variables:
511
659
  ```tsx
512
660
  const card = tastyStatic({
513
661
  padding: '4x',
514
- fill: 'var(--card-bg, #white)',
662
+ fill: '($card-bg, #white)',
515
663
  });
516
664
 
517
665
  <div
518
- className={card}
519
- style={{ '--card-bg': isActive ? '#purple' : '#white' }}
520
- />
666
+ className={card.className}
667
+ style={
668
+ {
669
+ '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
670
+ } as React.CSSProperties
671
+ }
672
+ />;
521
673
  ```
522
674
 
523
675
  ---
@@ -534,14 +686,15 @@ const card = tastyStatic({
534
686
  ## Common Issues
535
687
 
536
688
  - 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.
537
- - Styles stay dynamic by mistake: `tastyStatic()` only supports build-time-known values. Move runtime values to CSS variables or switch that component to runtime `tasty()`.
689
+ - 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()`.
538
690
  - Turbopack config behaves inconsistently: prefer `configFile` over inline functions so the setup stays JSON-serializable.
539
691
 
540
692
  ---
541
693
 
542
694
  ## Related
543
695
 
544
- - [Docs Hub](README.md) — Choose the right guide by task or rendering mode
696
+ - [Docs Hub](README.md) — Choose the right guide by task or CSS delivery model
545
697
  - [Style DSL](dsl.md) — State maps, tokens, units, extending semantics (shared by runtime and static)
546
- - [React API](react-api.md) — Runtime styling: `tasty()` factory, component props, variants, sub-elements, style functions
698
+ - [React API](react-api.md) — Client or server rendering with `tasty()`: component props, variants, sub-elements, and style functions
547
699
  - [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
700
+ - [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)