@tenphi/tasty 0.0.0-snapshot.2dc73be → 0.0.0-snapshot.2f5d166
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.
- package/README.md +288 -250
- package/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/chunks/cacheKey.d.ts +1 -0
- package/dist/chunks/cacheKey.js +17 -10
- package/dist/chunks/cacheKey.js.map +1 -1
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +2 -3
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/chunks/index.d.ts +1 -0
- package/dist/chunks/renderChunk.d.ts +1 -0
- package/dist/chunks/renderChunk.js +32 -34
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/compute-styles.d.ts +31 -0
- package/dist/compute-styles.js +335 -0
- package/dist/compute-styles.js.map +1 -0
- package/dist/config.d.ts +109 -30
- package/dist/config.js +142 -57
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +12 -11
- package/dist/core/index.js +10 -9
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +357 -637
- package/dist/debug.js.map +1 -1
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useCounterStyle.d.ts +52 -0
- package/dist/hooks/useCounterStyle.js +43 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +45 -0
- package/dist/hooks/useFontFace.js +68 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +18 -2
- package/dist/hooks/useGlobalStyles.js +50 -46
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.d.ts +4 -2
- package/dist/hooks/useKeyframes.js +32 -57
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.d.ts +4 -2
- package/dist/hooks/useProperty.js +29 -45
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.d.ts +8 -44
- package/dist/hooks/useRawCSS.js +82 -27
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.d.ts +4 -9
- package/dist/hooks/useStyles.js +7 -226
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +15 -12
- package/dist/index.js +13 -10
- package/dist/injector/index.d.ts +36 -19
- package/dist/injector/index.js +42 -19
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +48 -3
- package/dist/injector/injector.js +144 -16
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.d.ts +9 -13
- package/dist/injector/sheet-manager.js +39 -70
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +103 -19
- package/dist/keyframes/index.js +1 -1
- package/dist/parser/classify.js +6 -6
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +30 -3
- package/dist/parser/const.js.map +1 -1
- package/dist/parser/lru.js +1 -1
- package/dist/parser/lru.js.map +1 -1
- package/dist/parser/parser.js +2 -3
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +1 -1
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/types.js +1 -1
- package/dist/parser/types.js.map +1 -1
- package/dist/pipeline/conditions.js +1 -1
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/exclusive.js +1 -2
- package/dist/pipeline/exclusive.js.map +1 -1
- package/dist/pipeline/index.d.ts +3 -1
- package/dist/pipeline/index.js +80 -32
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +329 -82
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.d.ts +1 -1
- package/dist/pipeline/parseStateKey.js +3 -8
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/pipeline/simplify.js +1 -2
- package/dist/pipeline/simplify.js.map +1 -1
- package/dist/pipeline/warnings.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/okhsl-plugin.js +3 -277
- package/dist/plugins/okhsl-plugin.js.map +1 -1
- package/dist/plugins/types.d.ts +9 -2
- package/dist/properties/index.js +3 -17
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/property-type-resolver.js +5 -2
- package/dist/properties/property-type-resolver.js.map +1 -1
- package/dist/rsc-cache.js +70 -0
- package/dist/rsc-cache.js.map +1 -0
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +24 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +15 -0
- package/dist/ssr/astro-middleware.js +19 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +85 -8
- package/dist/ssr/astro.js +111 -22
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/async-storage.js +1 -2
- package/dist/ssr/async-storage.js.map +1 -1
- package/dist/ssr/collect-auto-properties.js +29 -11
- package/dist/ssr/collect-auto-properties.js.map +1 -1
- package/dist/ssr/collector.d.ts +17 -0
- package/dist/ssr/collector.js +60 -14
- package/dist/ssr/collector.js.map +1 -1
- package/dist/ssr/format-global-rules.js +1 -1
- package/dist/ssr/format-keyframes.js +1 -2
- package/dist/ssr/format-keyframes.js.map +1 -1
- package/dist/ssr/format-property.js +10 -9
- package/dist/ssr/format-property.js.map +1 -1
- package/dist/ssr/format-rules.js +8 -5
- package/dist/ssr/format-rules.js.map +1 -1
- package/dist/ssr/hydrate.js +1 -2
- package/dist/ssr/hydrate.js.map +1 -1
- package/dist/ssr/index.d.ts +2 -3
- package/dist/ssr/index.js +2 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -3
- package/dist/ssr/next.js +10 -7
- package/dist/ssr/next.js.map +1 -1
- package/dist/ssr/ssr-collector-ref.js +1 -1
- package/dist/states/index.js +13 -259
- package/dist/states/index.js.map +1 -1
- package/dist/static/index.js +1 -2
- package/dist/static/inject.d.ts +5 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/static/tastyStatic.js +1 -2
- package/dist/static/tastyStatic.js.map +1 -1
- package/dist/static/types.js +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/border.js +30 -24
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/color.d.ts +1 -1
- package/dist/styles/color.js +11 -8
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/const.js +17 -0
- package/dist/styles/const.js.map +1 -0
- package/dist/styles/createStyle.js +28 -26
- package/dist/styles/createStyle.js.map +1 -1
- package/dist/styles/dimension.js +15 -3
- package/dist/styles/dimension.js.map +1 -1
- package/dist/styles/directional.js +133 -0
- package/dist/styles/directional.js.map +1 -0
- package/dist/styles/display.d.ts +3 -10
- package/dist/styles/display.js +45 -39
- package/dist/styles/display.js.map +1 -1
- package/dist/styles/fade.d.ts +1 -1
- package/dist/styles/fade.js +9 -5
- package/dist/styles/fade.js.map +1 -1
- package/dist/styles/fill.d.ts +2 -2
- package/dist/styles/fill.js +3 -4
- package/dist/styles/fill.js.map +1 -1
- package/dist/styles/flow.js +1 -1
- package/dist/styles/gap.d.ts +1 -1
- package/dist/styles/gap.js +4 -3
- package/dist/styles/gap.js.map +1 -1
- package/dist/styles/height.d.ts +1 -1
- package/dist/styles/height.js +1 -2
- package/dist/styles/height.js.map +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +3 -4
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/inset.d.ts +1 -29
- package/dist/styles/inset.js +19 -135
- package/dist/styles/inset.js.map +1 -1
- package/dist/styles/list.d.ts +5 -5
- package/dist/styles/list.js +4 -2
- package/dist/styles/list.js.map +1 -1
- package/dist/styles/margin.d.ts +1 -1
- package/dist/styles/margin.js +17 -89
- package/dist/styles/margin.js.map +1 -1
- package/dist/styles/outline.d.ts +1 -1
- package/dist/styles/outline.js +6 -16
- package/dist/styles/outline.js.map +1 -1
- package/dist/styles/padding.d.ts +1 -1
- package/dist/styles/padding.js +17 -89
- package/dist/styles/padding.js.map +1 -1
- package/dist/styles/placement.d.ts +37 -0
- package/dist/styles/placement.js +74 -0
- package/dist/styles/placement.js.map +1 -0
- package/dist/styles/predefined.d.ts +4 -4
- package/dist/styles/predefined.js +9 -10
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +6 -1
- package/dist/styles/preset.js +54 -53
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/radius.d.ts +1 -3
- package/dist/styles/radius.js +38 -6
- package/dist/styles/radius.js.map +1 -1
- package/dist/styles/scrollMargin.d.ts +24 -0
- package/dist/styles/scrollMargin.js +32 -0
- package/dist/styles/scrollMargin.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +1 -1
- package/dist/styles/scrollbar.js +8 -5
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/shadow.d.ts +1 -1
- package/dist/styles/shadow.js +4 -3
- package/dist/styles/shadow.js.map +1 -1
- package/dist/styles/shared.js +17 -0
- package/dist/styles/shared.js.map +1 -0
- package/dist/styles/transition.d.ts +1 -1
- package/dist/styles/transition.js +5 -4
- package/dist/styles/transition.js.map +1 -1
- package/dist/styles/types.d.ts +84 -15
- package/dist/styles/width.d.ts +1 -1
- package/dist/styles/width.js +1 -2
- package/dist/styles/width.js.map +1 -1
- package/dist/tasty.d.ts +46 -893
- package/dist/tasty.js +96 -59
- package/dist/tasty.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/cache-wrapper.js +4 -9
- package/dist/utils/cache-wrapper.js.map +1 -1
- package/dist/utils/case-converter.js +1 -1
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +228 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.js +3 -2
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/dotize.js +1 -1
- package/dist/utils/dotize.js.map +1 -1
- package/dist/utils/filter-base-props.d.ts +1 -1
- package/dist/utils/filter-base-props.js +1 -1
- package/dist/utils/filter-base-props.js.map +1 -1
- package/dist/utils/get-display-name.js +1 -1
- package/dist/utils/has-keys.js +13 -0
- package/dist/utils/has-keys.js.map +1 -0
- package/dist/utils/hash.js +14 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/is-dev-env.js +1 -1
- package/dist/utils/is-dev-env.js.map +1 -1
- package/dist/utils/is-valid-element-type.js +1 -1
- package/dist/utils/merge-styles.js +1 -2
- package/dist/utils/merge-styles.js.map +1 -1
- package/dist/utils/mod-attrs.d.ts +0 -2
- package/dist/utils/mod-attrs.js +3 -4
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.d.ts +3 -17
- package/dist/utils/process-tokens.js +19 -107
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/resolve-recipes.js +1 -2
- package/dist/utils/resolve-recipes.js.map +1 -1
- package/dist/utils/selector-transform.js +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/styles.d.ts +3 -81
- package/dist/utils/styles.js +29 -539
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.d.ts +24 -13
- package/dist/utils/typography.js +15 -17
- package/dist/utils/typography.js.map +1 -1
- package/dist/utils/warnings.js +1 -1
- package/dist/zero/babel.d.ts +63 -8
- package/dist/zero/babel.js +163 -44
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/css-writer.js +1 -2
- package/dist/zero/css-writer.js.map +1 -1
- package/dist/zero/extractor.js +54 -3
- package/dist/zero/extractor.js.map +1 -1
- package/dist/zero/index.js +1 -2
- package/dist/zero/next.d.ts +28 -1
- package/dist/zero/next.js +70 -15
- package/dist/zero/next.js.map +1 -1
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +296 -0
- package/docs/comparison.md +420 -0
- package/docs/configuration.md +127 -12
- package/docs/debug.md +152 -339
- package/docs/design-system.md +424 -0
- package/docs/{usage.md → dsl.md} +379 -386
- package/docs/getting-started.md +217 -0
- package/docs/injector.md +43 -27
- package/docs/methodology.md +616 -0
- package/docs/runtime.md +575 -0
- package/docs/ssr.md +144 -81
- package/docs/styles.md +48 -26
- package/docs/tasty-static.md +166 -22
- package/package.json +27 -12
- package/dist/ssr/context.d.ts +0 -8
- package/dist/ssr/context.js +0 -14
- package/dist/ssr/context.js.map +0 -1
- package/dist/styles/align.d.ts +0 -15
- package/dist/styles/align.js +0 -14
- package/dist/styles/align.js.map +0 -1
- package/dist/styles/justify.d.ts +0 -15
- package/dist/styles/justify.js +0 -14
- package/dist/styles/justify.js.map +0 -1
- package/dist/tokens/typography.d.ts +0 -19
- package/dist/tokens/typography.js +0 -237
- package/dist/tokens/typography.js.map +0 -1
- package/dist/utils/hsl-to-rgb.js +0 -38
- package/dist/utils/hsl-to-rgb.js.map +0 -1
- package/dist/utils/okhsl-to-rgb.js +0 -296
- package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/docs/tasty-static.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Zero Runtime Mode (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.
|
|
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).
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -11,9 +11,30 @@
|
|
|
11
11
|
- **Performance-critical pages** — Zero runtime overhead for styling
|
|
12
12
|
- **Landing pages** — Minimal bundle size with pre-generated CSS
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
The zero-runtime mode is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
|
|
17
|
+
|
|
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 |
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# For any Babel-based setup (Vite, custom Babel config, etc.)
|
|
29
|
+
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
|
|
30
|
+
|
|
31
|
+
# For Next.js with TypeScript config file
|
|
32
|
+
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
17
38
|
|
|
18
39
|
### Basic Usage
|
|
19
40
|
|
|
@@ -109,6 +130,8 @@ module.exports = {
|
|
|
109
130
|
};
|
|
110
131
|
```
|
|
111
132
|
|
|
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.
|
|
134
|
+
|
|
112
135
|
### With Configuration
|
|
113
136
|
|
|
114
137
|
```javascript
|
|
@@ -120,7 +143,7 @@ module.exports = {
|
|
|
120
143
|
states: {
|
|
121
144
|
'@mobile': '@media(w < 768px)',
|
|
122
145
|
'@tablet': '@media(w < 1024px)',
|
|
123
|
-
'@dark': '@root(
|
|
146
|
+
'@dark': '@root(schema=dark)',
|
|
124
147
|
},
|
|
125
148
|
devMode: true,
|
|
126
149
|
},
|
|
@@ -134,9 +157,15 @@ module.exports = {
|
|
|
134
157
|
| Option | Type | Default | Description |
|
|
135
158
|
|--------|------|---------|-------------|
|
|
136
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) |
|
|
137
164
|
| `config.states` | `Record<string, string>` | `{}` | Predefined state aliases |
|
|
138
165
|
| `config.devMode` | `boolean` | `false` | Add source comments to CSS |
|
|
139
166
|
| `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
|
|
167
|
+
| `config.fontFace` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
|
|
168
|
+
| `config.counterStyle` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
|
|
140
169
|
|
|
141
170
|
---
|
|
142
171
|
|
|
@@ -176,31 +205,52 @@ const card = tastyStatic({
|
|
|
176
205
|
|
|
177
206
|
## Next.js Integration
|
|
178
207
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
208
|
+
The `withTastyZero` wrapper configures both **webpack** and **Turbopack** automatically. No `--webpack` flag is needed — it works with whichever bundler Next.js uses.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// next.config.ts
|
|
212
|
+
import { withTastyZero } from '@tenphi/tasty/next';
|
|
182
213
|
|
|
183
|
-
|
|
214
|
+
export default withTastyZero({
|
|
184
215
|
output: 'public/tasty.css',
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
'@mobile': '@media(w < 768px)',
|
|
188
|
-
},
|
|
189
|
-
devMode: process.env.NODE_ENV === 'development',
|
|
190
|
-
},
|
|
216
|
+
configFile: './app/tasty-zero.config.ts',
|
|
217
|
+
configDeps: ['./app/theme.ts'],
|
|
191
218
|
})({
|
|
192
219
|
reactStrictMode: true,
|
|
193
220
|
});
|
|
194
221
|
```
|
|
195
222
|
|
|
196
|
-
###
|
|
223
|
+
### `withTastyZero` Options
|
|
197
224
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
225
|
+
| Option | Type | Default | Description |
|
|
226
|
+
|--------|------|---------|-------------|
|
|
227
|
+
| `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
|
|
228
|
+
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
|
|
229
|
+
| `enabled` | `boolean` | `true` | Enable/disable the plugin |
|
|
230
|
+
| `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
|
|
231
|
+
| `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
|
|
232
|
+
| `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
|
|
233
|
+
|
|
234
|
+
### Turbopack Support
|
|
235
|
+
|
|
236
|
+
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.
|
|
237
|
+
|
|
238
|
+
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.
|
|
239
|
+
|
|
240
|
+
**Requirements**: `babel-loader` must be installed in your project:
|
|
201
241
|
|
|
202
|
-
|
|
203
|
-
|
|
242
|
+
```bash
|
|
243
|
+
pnpm add babel-loader
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### CSS Injection
|
|
247
|
+
|
|
248
|
+
`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.
|
|
249
|
+
|
|
250
|
+
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`:
|
|
251
|
+
|
|
252
|
+
```gitignore
|
|
253
|
+
public/tasty.css
|
|
204
254
|
```
|
|
205
255
|
|
|
206
256
|
---
|
|
@@ -285,6 +335,91 @@ export const Button = () => <button className={button}>Click</button>;
|
|
|
285
335
|
|
|
286
336
|
---
|
|
287
337
|
|
|
338
|
+
## Inject Mode
|
|
339
|
+
|
|
340
|
+
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.
|
|
341
|
+
|
|
342
|
+
This is ideal for **reusable components**, **extensions**, and **libraries** where consumers shouldn't need to manage an external CSS file.
|
|
343
|
+
|
|
344
|
+
### How It Works
|
|
345
|
+
|
|
346
|
+
1. The Babel plugin extracts CSS at build time (same pipeline as file mode).
|
|
347
|
+
2. Instead of writing to a `.css` file, the CSS is embedded as string literals in the JS output.
|
|
348
|
+
3. The `@tenphi/tasty/static` import is rewritten to `@tenphi/tasty/static/inject`.
|
|
349
|
+
4. Each `tastyStatic` call becomes a self-contained expression that injects its CSS and evaluates to a `StaticStyle` object.
|
|
350
|
+
|
|
351
|
+
### Configuration
|
|
352
|
+
|
|
353
|
+
```javascript
|
|
354
|
+
// babel.config.js
|
|
355
|
+
module.exports = {
|
|
356
|
+
plugins: [
|
|
357
|
+
['@tenphi/tasty/babel-plugin', {
|
|
358
|
+
mode: 'inject',
|
|
359
|
+
config: {
|
|
360
|
+
states: { '@mobile': '@media(w < 768px)' },
|
|
361
|
+
},
|
|
362
|
+
}]
|
|
363
|
+
]
|
|
364
|
+
};
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
With Next.js:
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
// next.config.ts
|
|
371
|
+
import { withTastyZero } from '@tenphi/tasty/next';
|
|
372
|
+
|
|
373
|
+
export default withTastyZero({
|
|
374
|
+
mode: 'inject',
|
|
375
|
+
configFile: './app/tasty-zero.config.ts',
|
|
376
|
+
})({
|
|
377
|
+
reactStrictMode: true,
|
|
378
|
+
});
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
When `mode` is `'inject'`, the `output` and `injectImport` options are ignored.
|
|
382
|
+
|
|
383
|
+
### Build Transformation (inject mode)
|
|
384
|
+
|
|
385
|
+
**Before:**
|
|
386
|
+
|
|
387
|
+
```tsx
|
|
388
|
+
import { tastyStatic } from '@tenphi/tasty/static';
|
|
389
|
+
|
|
390
|
+
const button = tastyStatic({
|
|
391
|
+
padding: '2x 4x',
|
|
392
|
+
fill: '#purple',
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
tastyStatic('.heading', { preset: 'h1' });
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**After:**
|
|
399
|
+
|
|
400
|
+
```tsx
|
|
401
|
+
import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
|
|
402
|
+
|
|
403
|
+
const button = (_$i("ts3f2a1b ts8c4d2e", ".ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}"), {
|
|
404
|
+
className: 'ts3f2a1b ts8c4d2e',
|
|
405
|
+
styles: { padding: '2x 4x', fill: '#purple' },
|
|
406
|
+
toString() { return this.className; }
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
_$i(".heading", ".heading{font-size:2.5rem;font-weight:700;line-height:1.2}");
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Dev Mode / HMR
|
|
413
|
+
|
|
414
|
+
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.
|
|
415
|
+
|
|
416
|
+
### Limitations (inject mode)
|
|
417
|
+
|
|
418
|
+
- **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()`.
|
|
419
|
+
- **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
288
423
|
## Style Extension
|
|
289
424
|
|
|
290
425
|
```tsx
|
|
@@ -366,11 +501,20 @@ const card = tastyStatic({
|
|
|
366
501
|
2. **Use selector mode** for global/body styles
|
|
367
502
|
3. **Enable devMode** in development for easier debugging
|
|
368
503
|
4. **Configure states** for consistent responsive breakpoints
|
|
369
|
-
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Common Issues
|
|
508
|
+
|
|
509
|
+
- 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.
|
|
510
|
+
- 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()`.
|
|
511
|
+
- Turbopack config behaves inconsistently: prefer `configFile` over inline functions so the setup stays JSON-serializable.
|
|
370
512
|
|
|
371
513
|
---
|
|
372
514
|
|
|
373
515
|
## Related
|
|
374
516
|
|
|
375
|
-
- [
|
|
517
|
+
- [Docs Hub](README.md) — Choose the right guide by task or rendering mode
|
|
518
|
+
- [Style DSL](dsl.md) — State maps, tokens, units, extending semantics (shared by runtime and static)
|
|
519
|
+
- [Runtime API](runtime.md) — Runtime styling: `tasty()` factory, component props, variants, sub-elements, style functions
|
|
376
520
|
- [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/tasty",
|
|
3
|
-
"version": "0.0.0-snapshot.
|
|
3
|
+
"version": "0.0.0-snapshot.2f5d166",
|
|
4
4
|
"description": "A design-system-integrated styling system and DSL for concise, state-aware UI styling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"import": "./dist/static/index.js",
|
|
18
18
|
"default": "./dist/static/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./static/inject": {
|
|
21
|
+
"types": "./dist/static/inject.d.ts",
|
|
22
|
+
"import": "./dist/static/inject.js",
|
|
23
|
+
"default": "./dist/static/inject.js"
|
|
24
|
+
},
|
|
20
25
|
"./babel-plugin": {
|
|
21
26
|
"types": "./dist/zero/babel.d.ts",
|
|
22
27
|
"import": "./dist/zero/babel.js",
|
|
@@ -52,6 +57,11 @@
|
|
|
52
57
|
"import": "./dist/ssr/astro.js",
|
|
53
58
|
"default": "./dist/ssr/astro.js"
|
|
54
59
|
},
|
|
60
|
+
"./ssr/astro-client": {
|
|
61
|
+
"types": "./dist/ssr/astro-client.d.ts",
|
|
62
|
+
"import": "./dist/ssr/astro-client.js",
|
|
63
|
+
"default": "./dist/ssr/astro-client.js"
|
|
64
|
+
},
|
|
55
65
|
"./tasty.config": "./tasty.config.ts"
|
|
56
66
|
},
|
|
57
67
|
"files": [
|
|
@@ -62,7 +72,8 @@
|
|
|
62
72
|
"sideEffects": [
|
|
63
73
|
"./dist/ssr/index.js",
|
|
64
74
|
"./dist/ssr/next.js",
|
|
65
|
-
"./dist/ssr/astro.js"
|
|
75
|
+
"./dist/ssr/astro.js",
|
|
76
|
+
"./dist/ssr/astro-client.js"
|
|
66
77
|
],
|
|
67
78
|
"engines": {
|
|
68
79
|
"node": ">=20"
|
|
@@ -78,6 +89,7 @@
|
|
|
78
89
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
79
90
|
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
|
|
80
91
|
"size": "size-limit",
|
|
92
|
+
"bench": "vitest bench",
|
|
81
93
|
"prepublishOnly": "pnpm run build",
|
|
82
94
|
"changeset": "changeset",
|
|
83
95
|
"version": "changeset version",
|
|
@@ -110,6 +122,7 @@
|
|
|
110
122
|
"@babel/core": "^7.24.0",
|
|
111
123
|
"@babel/helper-plugin-utils": "^7.24.0",
|
|
112
124
|
"@babel/types": "^7.24.0",
|
|
125
|
+
"jiti": "^2.6.1",
|
|
113
126
|
"react": "^18.0.0 || ^19.0.0"
|
|
114
127
|
},
|
|
115
128
|
"peerDependenciesMeta": {
|
|
@@ -124,15 +137,17 @@
|
|
|
124
137
|
},
|
|
125
138
|
"react": {
|
|
126
139
|
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"jiti": {
|
|
142
|
+
"optional": true
|
|
127
143
|
}
|
|
128
144
|
},
|
|
129
145
|
"dependencies": {
|
|
130
|
-
"csstype": "^3.1.0"
|
|
131
|
-
"jiti": "^2.6.1"
|
|
146
|
+
"csstype": "^3.1.0"
|
|
132
147
|
},
|
|
133
148
|
"devDependencies": {
|
|
134
149
|
"@babel/core": "^7.24.0",
|
|
135
|
-
"@changesets/changelog-github": "^0.
|
|
150
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
136
151
|
"@changesets/cli": "^2.29.8",
|
|
137
152
|
"@eslint/js": "^10.0.1",
|
|
138
153
|
"@size-limit/esbuild": "^12.0.0",
|
|
@@ -146,11 +161,11 @@
|
|
|
146
161
|
"@vitest/runner": "^4.0.18",
|
|
147
162
|
"eslint": "^10.0.0",
|
|
148
163
|
"eslint-config-prettier": "^10.1.8",
|
|
149
|
-
"jsdom": "^
|
|
164
|
+
"jsdom": "^29.0.1",
|
|
150
165
|
"prettier": "^3.8.1",
|
|
151
166
|
"react": "^19.0.0",
|
|
152
167
|
"size-limit": "^12.0.0",
|
|
153
|
-
"tsdown": "^0.
|
|
168
|
+
"tsdown": "^0.21.7",
|
|
154
169
|
"typescript": "^5.9.3",
|
|
155
170
|
"typescript-eslint": "^8.56.0",
|
|
156
171
|
"vitest": "^4.0.18"
|
|
@@ -160,19 +175,19 @@
|
|
|
160
175
|
"esbuild"
|
|
161
176
|
]
|
|
162
177
|
},
|
|
163
|
-
"packageManager": "pnpm@10.
|
|
178
|
+
"packageManager": "pnpm@10.32.1",
|
|
164
179
|
"size-limit": [
|
|
165
180
|
{
|
|
166
181
|
"name": "main (import *)",
|
|
167
182
|
"path": "dist/index.js",
|
|
168
183
|
"import": "*",
|
|
169
|
-
"limit": "
|
|
184
|
+
"limit": "48 kB"
|
|
170
185
|
},
|
|
171
186
|
{
|
|
172
187
|
"name": "core (import *)",
|
|
173
188
|
"path": "dist/core/index.js",
|
|
174
189
|
"import": "*",
|
|
175
|
-
"limit": "
|
|
190
|
+
"limit": "46 kB"
|
|
176
191
|
},
|
|
177
192
|
{
|
|
178
193
|
"name": "static",
|
|
@@ -189,7 +204,7 @@
|
|
|
189
204
|
"path",
|
|
190
205
|
"crypto"
|
|
191
206
|
],
|
|
192
|
-
"limit": "
|
|
207
|
+
"limit": "28.5 kB"
|
|
193
208
|
},
|
|
194
209
|
{
|
|
195
210
|
"name": "babel-plugin",
|
|
@@ -200,7 +215,7 @@
|
|
|
200
215
|
"path",
|
|
201
216
|
"crypto"
|
|
202
217
|
],
|
|
203
|
-
"limit": "
|
|
218
|
+
"limit": "42 kB"
|
|
204
219
|
}
|
|
205
220
|
]
|
|
206
221
|
}
|
package/dist/ssr/context.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ServerStyleCollector } from "./collector.js";
|
|
2
|
-
import * as react from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/ssr/context.d.ts
|
|
5
|
-
declare const TastySSRContext: react.Context<ServerStyleCollector | null>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { TastySSRContext };
|
|
8
|
-
//# sourceMappingURL=context.d.ts.map
|
package/dist/ssr/context.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
//#region src/ssr/context.ts
|
|
4
|
-
/**
|
|
5
|
-
* React context for SSR collector discovery.
|
|
6
|
-
*
|
|
7
|
-
* Used by Next.js TastyRegistry to provide the ServerStyleCollector
|
|
8
|
-
* to useStyles() via React context (the streaming-compatible path).
|
|
9
|
-
*/
|
|
10
|
-
const TastySSRContext = createContext(null);
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { TastySSRContext };
|
|
14
|
-
//# sourceMappingURL=context.js.map
|
package/dist/ssr/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * React context for SSR collector discovery.\n *\n * Used by Next.js TastyRegistry to provide the ServerStyleCollector\n * to useStyles() via React context (the streaming-compatible path).\n */\n\nimport { createContext } from 'react';\n\nimport type { ServerStyleCollector } from './collector';\n\nexport const TastySSRContext = createContext<ServerStyleCollector | null>(null);\n"],"mappings":";;;;;;;;;AAWA,MAAa,kBAAkB,cAA2C,KAAK"}
|
package/dist/styles/align.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/styles/align.d.ts
|
|
2
|
-
declare function alignStyle({
|
|
3
|
-
align
|
|
4
|
-
}: {
|
|
5
|
-
align?: string;
|
|
6
|
-
}): {
|
|
7
|
-
'align-items': string;
|
|
8
|
-
'align-content': string;
|
|
9
|
-
} | undefined;
|
|
10
|
-
declare namespace alignStyle {
|
|
11
|
-
var __lookupStyles: string[];
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { alignStyle };
|
|
15
|
-
//# sourceMappingURL=align.d.ts.map
|
package/dist/styles/align.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/styles/align.ts
|
|
2
|
-
function alignStyle({ align }) {
|
|
3
|
-
if (typeof align !== "string") return;
|
|
4
|
-
if (!align) return;
|
|
5
|
-
return {
|
|
6
|
-
"align-items": align,
|
|
7
|
-
"align-content": align
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
alignStyle.__lookupStyles = ["align"];
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { alignStyle };
|
|
14
|
-
//# sourceMappingURL=align.js.map
|
package/dist/styles/align.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"align.js","names":[],"sources":["../../src/styles/align.ts"],"sourcesContent":["export function alignStyle({ align }: { align?: string }) {\n if (typeof align !== 'string') return;\n\n if (!align) return;\n\n return {\n 'align-items': align,\n 'align-content': align,\n };\n}\n\nalignStyle.__lookupStyles = ['align'];\n"],"mappings":";AAAA,SAAgB,WAAW,EAAE,SAA6B;AACxD,KAAI,OAAO,UAAU,SAAU;AAE/B,KAAI,CAAC,MAAO;AAEZ,QAAO;EACL,eAAe;EACf,iBAAiB;EAClB;;AAGH,WAAW,iBAAiB,CAAC,QAAQ"}
|
package/dist/styles/justify.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/styles/justify.d.ts
|
|
2
|
-
declare function justifyStyle({
|
|
3
|
-
justify
|
|
4
|
-
}: {
|
|
5
|
-
justify?: string;
|
|
6
|
-
}): {
|
|
7
|
-
'justify-items': string;
|
|
8
|
-
'justify-content': string;
|
|
9
|
-
} | undefined;
|
|
10
|
-
declare namespace justifyStyle {
|
|
11
|
-
var __lookupStyles: string[];
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { justifyStyle };
|
|
15
|
-
//# sourceMappingURL=justify.d.ts.map
|
package/dist/styles/justify.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/styles/justify.ts
|
|
2
|
-
function justifyStyle({ justify }) {
|
|
3
|
-
if (typeof justify !== "string") return;
|
|
4
|
-
if (!justify) return;
|
|
5
|
-
return {
|
|
6
|
-
"justify-items": justify,
|
|
7
|
-
"justify-content": justify
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
justifyStyle.__lookupStyles = ["justify"];
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { justifyStyle };
|
|
14
|
-
//# sourceMappingURL=justify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"justify.js","names":[],"sources":["../../src/styles/justify.ts"],"sourcesContent":["export function justifyStyle({ justify }: { justify?: string }) {\n if (typeof justify !== 'string') return;\n\n if (!justify) return;\n\n return {\n 'justify-items': justify,\n 'justify-content': justify,\n };\n}\n\njustifyStyle.__lookupStyles = ['justify'];\n"],"mappings":";AAAA,SAAgB,aAAa,EAAE,WAAiC;AAC9D,KAAI,OAAO,YAAY,SAAU;AAEjC,KAAI,CAAC,QAAS;AAEd,QAAO;EACL,iBAAiB;EACjB,mBAAmB;EACpB;;AAGH,aAAa,iBAAiB,CAAC,UAAU"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/tokens/typography.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Typography preset configuration.
|
|
4
|
-
* Each preset defines font properties that get expanded into CSS custom properties.
|
|
5
|
-
*/
|
|
6
|
-
interface TypographyPreset {
|
|
7
|
-
fontSize: string;
|
|
8
|
-
lineHeight: string;
|
|
9
|
-
letterSpacing?: string;
|
|
10
|
-
fontWeight: string | number;
|
|
11
|
-
boldFontWeight?: string | number;
|
|
12
|
-
iconSize?: string;
|
|
13
|
-
textTransform?: string;
|
|
14
|
-
fontFamily?: string;
|
|
15
|
-
fontStyle?: string;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { TypographyPreset };
|
|
19
|
-
//# sourceMappingURL=typography.d.ts.map
|