@tenphi/tasty 0.0.0-snapshot.a8b4749 → 0.0.0-snapshot.a8da86e

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 (125) hide show
  1. package/README.md +181 -136
  2. package/dist/babel-types-C_7kRP38.d.ts +18 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-Betc6IB6.js +60 -0
  6. package/dist/chunks/build-config-Betc6IB6.js.map +1 -0
  7. package/dist/{collector-C-keQH9m.js → chunks/collector-DqqisglQ.js} +68 -101
  8. package/dist/chunks/collector-DqqisglQ.js.map +1 -0
  9. package/dist/chunks/config-engine-BPeROwq2.js +272 -0
  10. package/dist/chunks/config-engine-BPeROwq2.js.map +1 -0
  11. package/dist/chunks/css-definitions-IeuyJTGk.js +899 -0
  12. package/dist/chunks/css-definitions-IeuyJTGk.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-P1E2jkj7.js +502 -0
  16. package/dist/chunks/debug-P1E2jkj7.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-XMBbGRes.js +582 -0
  22. package/dist/chunks/react-runtime-XMBbGRes.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CsIMtulO.js +2415 -0
  24. package/dist/chunks/runtime-engine-CsIMtulO.js.map +1 -0
  25. package/dist/chunks/runtime-state-CyKzDioI.js +141 -0
  26. package/dist/chunks/runtime-state-CyKzDioI.js.map +1 -0
  27. package/dist/{merge-styles-Cd2vBl9b.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-RbokDN6A.js +5427 -0
  30. package/dist/chunks/style-engine-RbokDN6A.js.map +1 -0
  31. package/dist/{css-writer-BWvwQzz0.js → chunks/zero-engine-DbtjMsfo.js} +81 -137
  32. package/dist/chunks/zero-engine-DbtjMsfo.js.map +1 -0
  33. package/dist/{collector-osfWTeRd.d.ts → collector-w4mBj5gd.d.ts} +64 -8
  34. package/dist/{config-BoZDUHW5.d.ts → config-CrZOfNJ5.d.ts} +489 -85
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-B_k47mc_.d.ts → index-CYJtAI9a.d.ts} +664 -399
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -732
  40. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
  41. package/dist/ssr/astro-client.d.ts +1 -1
  42. package/dist/ssr/astro-client.js +1 -14
  43. package/dist/ssr/astro-client.js.map +1 -1
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +11 -8
  54. package/dist/ssr/astro-middleware.js +2 -14
  55. package/dist/ssr/astro-middleware.js.map +1 -1
  56. package/dist/ssr/astro.d.ts +40 -10
  57. package/dist/ssr/astro.js +163 -91
  58. package/dist/ssr/astro.js.map +1 -1
  59. package/dist/ssr/index.d.ts +10 -18
  60. package/dist/ssr/index.js +5 -5
  61. package/dist/ssr/index.js.map +1 -1
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +134 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +9 -9
  66. package/dist/ssr/next.js +29 -44
  67. package/dist/ssr/next.js.map +1 -1
  68. package/dist/static/index.d.ts +8 -9
  69. package/dist/static/index.js +4 -22
  70. package/dist/static/index.js.map +1 -1
  71. package/dist/static/inject.d.ts +1 -2
  72. package/dist/static/inject.js.map +1 -1
  73. package/dist/{index-tcHuMPFt.d.ts → types-JEY8PVYP.d.ts} +874 -593
  74. package/dist/zero/babel.d.ts +5 -19
  75. package/dist/zero/babel.js +74 -144
  76. package/dist/zero/babel.js.map +1 -1
  77. package/dist/zero/index.d.ts +57 -7
  78. package/dist/zero/index.js +24 -2
  79. package/dist/zero/index.js.map +1 -0
  80. package/dist/zero/next.d.ts +4 -5
  81. package/dist/zero/next.js +0 -31
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +17 -9
  84. package/docs/adoption.md +56 -31
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +69 -40
  87. package/docs/configuration.md +487 -86
  88. package/docs/debug.md +26 -14
  89. package/docs/design-system.md +43 -24
  90. package/docs/dsl.md +558 -181
  91. package/docs/getting-started.md +64 -41
  92. package/docs/injector.md +120 -30
  93. package/docs/methodology.md +46 -40
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +87 -21
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +151 -42
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +252 -86
  100. package/docs/styles.md +142 -25
  101. package/docs/tasty-static.md +174 -106
  102. package/package.json +127 -35
  103. package/tasty.config.ts +5 -0
  104. package/dist/async-storage-B7_o6FKt.js +0 -44
  105. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  106. package/dist/collector-C-keQH9m.js.map +0 -1
  107. package/dist/config-BBiyxMCe.js +0 -10559
  108. package/dist/config-BBiyxMCe.js.map +0 -1
  109. package/dist/context-CkSg-kDT.js +0 -24
  110. package/dist/context-CkSg-kDT.js.map +0 -1
  111. package/dist/core-BO4319td.js +0 -1598
  112. package/dist/core-BO4319td.js.map +0 -1
  113. package/dist/css-writer-BWvwQzz0.js.map +0 -1
  114. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  115. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  116. package/dist/format-rules-BSjeH4Z7.js +0 -143
  117. package/dist/format-rules-BSjeH4Z7.js.map +0 -1
  118. package/dist/hydrate-CcvrP4qJ.js +0 -45
  119. package/dist/hydrate-CcvrP4qJ.js.map +0 -1
  120. package/dist/index.js.map +0 -1
  121. package/dist/keyframes-BUQhdOSJ.js +0 -588
  122. package/dist/keyframes-BUQhdOSJ.js.map +0 -1
  123. package/dist/merge-styles-Cd2vBl9b.js.map +0 -1
  124. package/dist/resolve-recipes-C1nrvnYh.js +0 -144
  125. package/dist/resolve-recipes-C1nrvnYh.js.map +0 -1
@@ -1,6 +1,8 @@
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
 
@@ -8,19 +10,19 @@
8
10
 
9
11
  - **Static site generation (SSG)** — Pre-render all styles at build time
10
12
  - **No-JavaScript websites** — CSS works without any JS runtime
11
- - **Performance-critical pages** — Zero runtime overhead for styling
13
+ - **Performance-critical pages** — CSS extracted before the application renders
12
14
  - **Landing pages** — Minimal bundle size with pre-generated CSS
13
15
 
14
16
  ## Requirements
15
17
 
16
- The zero-runtime mode is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
18
+ Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
17
19
 
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 |
20
+ | Dependency | Version | Required for |
21
+ | ---------------------------- | ------- | -------------------------------------------------------------------------- |
22
+ | `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
23
+ | `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin |
24
+ | `@babel/types` | >= 7.24 | Babel plugin |
25
+ | `jiti` | >= 2.6 | Next.js wrapper (`@tenphi/tasty/zero/next`) when using `configFile` option |
24
26
 
25
27
  All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
26
28
 
@@ -103,15 +105,17 @@ tastyStatic('body', {
103
105
  });
104
106
  ```
105
107
 
108
+ 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)`.
109
+
106
110
  ---
107
111
 
108
112
  ## StaticStyle Object
109
113
 
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 |
114
+ | Property | Type | Description |
115
+ | ------------ | -------------- | ------------------------------------------ |
116
+ | `className` | `string` | Space-separated class names for use in JSX |
117
+ | `styles` | `Styles` | The original (or merged) styles object |
118
+ | `toString()` | `() => string` | Returns `className` for string coercion |
115
119
 
116
120
  ---
117
121
 
@@ -123,66 +127,73 @@ tastyStatic('body', {
123
127
  // babel.config.js
124
128
  module.exports = {
125
129
  plugins: [
126
- ['@tenphi/tasty/babel-plugin', {
127
- output: 'public/tasty.css',
128
- }]
129
- ]
130
+ [
131
+ '@tenphi/tasty/babel-plugin',
132
+ {
133
+ output: 'public/tasty.css',
134
+ },
135
+ ],
136
+ ],
130
137
  };
131
138
  ```
132
139
 
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.
140
+ 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
141
 
135
142
  ### With Configuration
136
143
 
137
144
  ```javascript
138
145
  module.exports = {
139
146
  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)',
147
+ [
148
+ '@tenphi/tasty/babel-plugin',
149
+ {
150
+ output: 'public/tasty.css',
151
+ config: {
152
+ states: {
153
+ '@mobile': '@media(w < 768px)',
154
+ '@tablet': '@media(w < 1024px)',
155
+ '@dark': '@root(schema=dark)',
156
+ },
157
+ devMode: true,
147
158
  },
148
- devMode: true,
149
159
  },
150
- }]
151
- ]
160
+ ],
161
+ ],
152
162
  };
153
163
  ```
154
164
 
155
165
  ### Plugin Options
156
166
 
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:
167
+ | Option | Type | Default | Description |
168
+ | -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
169
+ | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
170
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
171
+ | `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. |
172
+ | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
173
+ | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
174
+ | `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
175
+ | `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
176
+ | `config.devMode` | `boolean` | `false` | Add source comments to CSS |
177
+ | `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. |
178
+ | `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
179
+ | `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
180
+ | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
181
+ | `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
182
+ | `config.counterStyles` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
183
+ | `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ em: 'em', vw: 'vw' }` |
184
+ | `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
185
+ | `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
186
+ | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
187
+ | `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
188
+ | `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
189
+ | `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
190
+ | `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
191
+ | `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
192
+ | `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). |
193
+
194
+ ### Coexisting with `tasty()`
195
+
196
+ 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
197
 
187
198
  ```ts
188
199
  // tasty-zero.config.ts (Babel plugin)
@@ -190,7 +201,7 @@ export default { namePrefix: 'mbs' };
190
201
  ```
191
202
 
192
203
  ```ts
193
- // app entry (runtime configure)
204
+ // app entry (`tasty()` configure)
194
205
  configure({ namePrefix: 'mb' });
195
206
  ```
196
207
 
@@ -204,16 +215,24 @@ Recipes work with `tastyStatic` the same way as with runtime `tasty`:
204
215
  // babel.config.js
205
216
  module.exports = {
206
217
  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' },
218
+ [
219
+ '@tenphi/tasty/babel-plugin',
220
+ {
221
+ output: 'public/tasty.css',
222
+ config: {
223
+ recipes: {
224
+ card: {
225
+ padding: '4x',
226
+ fill: '#surface',
227
+ radius: '1r',
228
+ border: true,
229
+ },
230
+ elevated: { shadow: '2x 2x 4x #shadow' },
231
+ },
213
232
  },
214
233
  },
215
- }]
216
- ]
234
+ ],
235
+ ],
217
236
  };
218
237
  ```
219
238
 
@@ -225,7 +244,7 @@ const card = tastyStatic({
225
244
  color: '#text',
226
245
  });
227
246
 
228
- <div className={card}>Styled card</div>
247
+ <div className={card}>Styled card</div>;
229
248
  ```
230
249
 
231
250
  ---
@@ -236,7 +255,7 @@ The `withTastyZero` wrapper configures both **webpack** and **Turbopack** automa
236
255
 
237
256
  ```typescript
238
257
  // next.config.ts
239
- import { withTastyZero } from '@tenphi/tasty/next';
258
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
240
259
 
241
260
  export default withTastyZero({
242
261
  output: 'public/tasty.css',
@@ -249,14 +268,14 @@ export default withTastyZero({
249
268
 
250
269
  ### `withTastyZero` Options
251
270
 
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) |
271
+ | Option | Type | Default | Description |
272
+ | ------------ | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------- |
273
+ | `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
274
+ | `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
275
+ | `enabled` | `boolean` | `true` | Enable/disable the plugin |
276
+ | `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
277
+ | `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
278
+ | `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
260
279
 
261
280
  ### Turbopack Support
262
281
 
@@ -282,6 +301,37 @@ public/tasty.css
282
301
 
283
302
  ---
284
303
 
304
+ ## Programmatic API
305
+
306
+ `@tenphi/tasty/zero` turns styles into CSS in Node without Babel or React — for build scripts, or CSS shipped to other frameworks:
307
+
308
+ ```ts
309
+ import {
310
+ configure,
311
+ extractStylesForSelector,
312
+ extractStylesWithChunks,
313
+ } from '@tenphi/tasty/zero';
314
+
315
+ configure({
316
+ units: { u: 'var(--unit)' },
317
+ states: { '@dark': '@root(schema=dark)' },
318
+ });
319
+
320
+ extractStylesForSelector('.card', { padding: '2u', fill: '#surface' }).css;
321
+ // → '.card { padding: calc(2 * var(--unit)); background-color: … }'
322
+
323
+ extractStylesWithChunks({ display: 'flex', gap: '1u' });
324
+ // → [{ className: 'ts…', css: '.ts….ts… { … }' }]
325
+ ```
326
+
327
+ `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)`.
328
+
329
+ 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.
330
+
331
+ `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.
332
+
333
+ ---
334
+
285
335
  ## Vite Integration
286
336
 
287
337
  ```typescript
@@ -294,12 +344,15 @@ export default defineConfig({
294
344
  react({
295
345
  babel: {
296
346
  plugins: [
297
- ['@tenphi/tasty/babel-plugin', {
298
- output: 'public/tasty.css',
299
- config: {
300
- states: { '@mobile': '@media(w < 768px)' },
347
+ [
348
+ '@tenphi/tasty/babel-plugin',
349
+ {
350
+ output: 'public/tasty.css',
351
+ config: {
352
+ states: { '@mobile': '@media(w < 768px)' },
353
+ },
301
354
  },
302
- }],
355
+ ],
303
356
  ],
304
357
  },
305
358
  }),
@@ -333,7 +386,9 @@ export const Button = () => <button className={button}>Click</button>;
333
386
  const button = {
334
387
  className: 'ts3f2a1b ts8c4d2e',
335
388
  styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
336
- toString() { return this.className; }
389
+ toString() {
390
+ return this.className;
391
+ },
337
392
  };
338
393
 
339
394
  export const Button = () => <button className={button}>Click</button>;
@@ -381,13 +436,16 @@ This is ideal for **reusable components**, **extensions**, and **libraries** whe
381
436
  // babel.config.js
382
437
  module.exports = {
383
438
  plugins: [
384
- ['@tenphi/tasty/babel-plugin', {
385
- mode: 'inject',
386
- config: {
387
- states: { '@mobile': '@media(w < 768px)' },
439
+ [
440
+ '@tenphi/tasty/babel-plugin',
441
+ {
442
+ mode: 'inject',
443
+ config: {
444
+ states: { '@mobile': '@media(w < 768px)' },
445
+ },
388
446
  },
389
- }]
390
- ]
447
+ ],
448
+ ],
391
449
  };
392
450
  ```
393
451
 
@@ -395,7 +453,7 @@ With Next.js:
395
453
 
396
454
  ```typescript
397
455
  // next.config.ts
398
- import { withTastyZero } from '@tenphi/tasty/next';
456
+ import { withTastyZero } from '@tenphi/tasty/zero/next';
399
457
 
400
458
  export default withTastyZero({
401
459
  mode: 'inject',
@@ -427,13 +485,20 @@ tastyStatic('.heading', { preset: 'h1' });
427
485
  ```tsx
428
486
  import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
429
487
 
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}");
488
+ const button =
489
+ (_$i(
490
+ 'ts3f2a1b ts8c4d2e',
491
+ '.ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}',
492
+ ),
493
+ {
494
+ className: 'ts3f2a1b ts8c4d2e',
495
+ styles: { padding: '2x 4x', fill: '#purple' },
496
+ toString() {
497
+ return this.className;
498
+ },
499
+ });
500
+
501
+ _$i('.heading', '.heading{font-size:2.5rem;font-weight:700;line-height:1.2}');
437
502
  ```
438
503
 
439
504
  ### Dev Mode / HMR
@@ -442,7 +507,7 @@ Class names are content-hashed (`ts` + MD5). When styles change, a new hash prod
442
507
 
443
508
  ### Limitations (inject mode)
444
509
 
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()`.
510
+ - **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
511
  - **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
447
512
 
448
513
  ---
@@ -457,7 +522,7 @@ const button = tastyStatic({
457
522
  radius: '1r',
458
523
  fill: '#gray.20',
459
524
  color: '#text',
460
- transition: 'fill 0.15s',
525
+ transition: 'fill',
461
526
  });
462
527
 
463
528
  // Variants
@@ -511,13 +576,15 @@ For dynamic styling needs, combine with regular CSS or CSS variables:
511
576
  ```tsx
512
577
  const card = tastyStatic({
513
578
  padding: '4x',
514
- fill: 'var(--card-bg, #white)',
579
+ fill: '($card-bg, #white)',
515
580
  });
516
581
 
517
582
  <div
518
583
  className={card}
519
- style={{ '--card-bg': isActive ? '#purple' : '#white' }}
520
- />
584
+ style={{
585
+ '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
586
+ }}
587
+ />;
521
588
  ```
522
589
 
523
590
  ---
@@ -534,14 +601,15 @@ const card = tastyStatic({
534
601
  ## Common Issues
535
602
 
536
603
  - 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()`.
604
+ - 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
605
  - Turbopack config behaves inconsistently: prefer `configFile` over inline functions so the setup stays JSON-serializable.
539
606
 
540
607
  ---
541
608
 
542
609
  ## Related
543
610
 
544
- - [Docs Hub](README.md) — Choose the right guide by task or rendering mode
611
+ - [Docs Hub](README.md) — Choose the right guide by task or CSS delivery model
545
612
  - [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
613
+ - [React API](react-api.md) — Client or server rendering with `tasty()`: component props, variants, sub-elements, and style functions
547
614
  - [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
615
+ - [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)