@tenphi/tasty 0.0.0-snapshot.1c5dff6 → 0.0.0-snapshot.1f1c00a
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 +377 -238
- package/dist/babel-rZcEwPLM.d.ts +82 -0
- package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
- package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
- package/dist/chunks/build-config-CL4eRu2z.js +42 -0
- package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
- package/dist/chunks/collector-D2ARGT2L.js +208 -0
- package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
- package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
- package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
- package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
- package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/chunks/debug-D8pg9RGI.js +502 -0
- package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
- package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
- package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
- package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
- package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
- package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
- package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
- package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
- package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
- package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
- package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
- package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
- package/dist/collector-w4mBj5gd.d.ts +164 -0
- package/dist/config-CZWCzBr6.d.ts +1349 -0
- package/dist/core/index.d.ts +5 -33
- package/dist/core/index.js +9 -26
- package/dist/index-G9JuwM9p.d.ts +1920 -0
- package/dist/index.d.ts +5 -48
- package/dist/index.js +11 -33
- package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
- package/dist/ssr/astro-client.d.ts +1 -0
- package/dist/ssr/astro-client.js +6 -0
- package/dist/ssr/astro-client.js.map +1 -0
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +17 -0
- package/dist/ssr/astro-middleware-static.js +7 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +18 -0
- package/dist/ssr/astro-middleware.js +7 -0
- package/dist/ssr/astro-middleware.js.map +1 -0
- package/dist/ssr/astro.d.ts +127 -0
- package/dist/ssr/astro.js +221 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/index.d.ts +36 -0
- package/dist/ssr/index.js +10 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +128 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +46 -0
- package/dist/ssr/next.js +60 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/static/index.d.ts +90 -5
- package/dist/static/index.js +31 -4
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.d.ts +4 -0
- package/dist/static/inject.js +17 -0
- package/dist/static/inject.js.map +1 -0
- package/dist/types-JEY8PVYP.d.ts +1567 -0
- package/dist/zero/babel.d.ts +2 -113
- package/dist/zero/babel.js +230 -106
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +80 -3
- package/dist/zero/index.js +2 -4
- package/dist/zero/next.d.ts +57 -33
- package/dist/zero/next.js +93 -59
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +39 -0
- package/docs/adoption.md +323 -0
- package/docs/ai-agents.md +250 -0
- package/docs/comparison.md +448 -0
- package/docs/configuration.md +684 -56
- package/docs/debug.md +170 -343
- package/docs/design-system.md +455 -0
- package/docs/dsl.md +1065 -0
- package/docs/getting-started.md +240 -0
- package/docs/injector.md +159 -53
- package/docs/methodology.md +648 -0
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +765 -0
- package/docs/plugins.md +353 -0
- package/docs/react-api.md +683 -0
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +610 -0
- package/docs/styles.md +211 -63
- package/docs/tasty-static.md +273 -67
- package/package.json +182 -58
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -8
- package/dist/chunks/cacheKey.js +0 -70
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -260
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/renderChunk.js +0 -61
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/config.d.ts +0 -288
- package/dist/config.js +0 -403
- package/dist/config.js.map +0 -1
- package/dist/debug.d.ts +0 -204
- package/dist/debug.js +0 -733
- package/dist/debug.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -27
- package/dist/hooks/useGlobalStyles.js +0 -56
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -56
- package/dist/hooks/useKeyframes.js +0 -54
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -79
- package/dist/hooks/useProperty.js +0 -91
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -53
- package/dist/hooks/useRawCSS.js +0 -28
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -169
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -157
- package/dist/injector/index.js +0 -154
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -139
- package/dist/injector/injector.js +0 -417
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -135
- package/dist/injector/sheet-manager.js +0 -728
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -144
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -33
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -116
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -231
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -53
- package/dist/pipeline/index.js +0 -660
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -856
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -451
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -516
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -371
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -69
- package/dist/properties/index.js +0 -221
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -83
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -416
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -31
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.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/border.d.ts +0 -25
- package/dist/styles/border.js +0 -114
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -23
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/createStyle.js +0 -77
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -97
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/display.d.ts +0 -37
- package/dist/styles/display.js +0 -67
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -58
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -52
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -37
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -20
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -2
- package/dist/styles/index.js +0 -9
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -52
- package/dist/styles/inset.js +0 -150
- package/dist/styles/inset.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/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -98
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -104
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -65
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -104
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -73
- package/dist/styles/predefined.js +0 -241
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -47
- package/dist/styles/preset.js +0 -126
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -14
- package/dist/styles/radius.js +0 -51
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -23
- package/dist/styles/scrollbar.js +0 -34
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -24
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/styledScrollbar.d.ts +0 -47
- package/dist/styles/styledScrollbar.js +0 -38
- package/dist/styles/styledScrollbar.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -158
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -498
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -20
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -982
- package/dist/tasty.js +0 -206
- package/dist/tasty.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/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -26
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -9
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.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/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -8
- package/dist/utils/mod-attrs.js +0 -21
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/okhsl-to-rgb.js +0 -296
- package/dist/utils/okhsl-to-rgb.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -31
- package/dist/utils/process-tokens.js +0 -171
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js +0 -147
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -177
- package/dist/utils/styles.js +0 -730
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -36
- package/dist/utils/typography.js +0 -53
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -74
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
- package/docs/usage.md +0 -695
package/docs/tasty-static.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Build-Time Extraction (`tastyStatic`)
|
|
2
2
|
|
|
3
|
-
`tastyStatic` is
|
|
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,12 +10,33 @@
|
|
|
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** —
|
|
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
|
|
17
|
+
|
|
18
|
+
Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
|
|
19
|
+
|
|
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 |
|
|
26
|
+
|
|
27
|
+
All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# For any Babel-based setup (Vite, custom Babel config, etc.)
|
|
31
|
+
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
# For Next.js with TypeScript config file
|
|
34
|
+
pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
17
40
|
|
|
18
41
|
### Basic Usage
|
|
19
42
|
|
|
@@ -86,11 +109,11 @@ tastyStatic('body', {
|
|
|
86
109
|
|
|
87
110
|
## StaticStyle Object
|
|
88
111
|
|
|
89
|
-
| Property
|
|
90
|
-
|
|
91
|
-
| `className`
|
|
92
|
-
| `styles`
|
|
93
|
-
| `toString()` | `() => string` | Returns `className` for string coercion
|
|
112
|
+
| Property | Type | Description |
|
|
113
|
+
| ------------ | -------------- | ------------------------------------------ |
|
|
114
|
+
| `className` | `string` | Space-separated class names for use in JSX |
|
|
115
|
+
| `styles` | `Styles` | The original (or merged) styles object |
|
|
116
|
+
| `toString()` | `() => string` | Returns `className` for string coercion |
|
|
94
117
|
|
|
95
118
|
---
|
|
96
119
|
|
|
@@ -102,41 +125,83 @@ tastyStatic('body', {
|
|
|
102
125
|
// babel.config.js
|
|
103
126
|
module.exports = {
|
|
104
127
|
plugins: [
|
|
105
|
-
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
128
|
+
[
|
|
129
|
+
'@tenphi/tasty/babel-plugin',
|
|
130
|
+
{
|
|
131
|
+
output: 'public/tasty.css',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
],
|
|
109
135
|
};
|
|
110
136
|
```
|
|
111
137
|
|
|
138
|
+
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.
|
|
139
|
+
|
|
112
140
|
### With Configuration
|
|
113
141
|
|
|
114
142
|
```javascript
|
|
115
143
|
module.exports = {
|
|
116
144
|
plugins: [
|
|
117
|
-
[
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
[
|
|
146
|
+
'@tenphi/tasty/babel-plugin',
|
|
147
|
+
{
|
|
148
|
+
output: 'public/tasty.css',
|
|
149
|
+
config: {
|
|
150
|
+
states: {
|
|
151
|
+
'@mobile': '@media(w < 768px)',
|
|
152
|
+
'@tablet': '@media(w < 1024px)',
|
|
153
|
+
'@dark': '@root(schema=dark)',
|
|
154
|
+
},
|
|
155
|
+
devMode: true,
|
|
124
156
|
},
|
|
125
|
-
devMode: true,
|
|
126
157
|
},
|
|
127
|
-
|
|
128
|
-
]
|
|
158
|
+
],
|
|
159
|
+
],
|
|
129
160
|
};
|
|
130
161
|
```
|
|
131
162
|
|
|
132
163
|
### Plugin Options
|
|
133
164
|
|
|
134
|
-
| Option
|
|
135
|
-
|
|
136
|
-
| `output`
|
|
137
|
-
| `
|
|
138
|
-
| `
|
|
139
|
-
| `config
|
|
165
|
+
| Option | Type | Default | Description |
|
|
166
|
+
| -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
167
|
+
| `output` | `string` | `'tasty.css'` | Path for generated CSS file |
|
|
168
|
+
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS (see [Inject Mode](#inject-mode)) |
|
|
169
|
+
| `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. |
|
|
170
|
+
| `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
|
|
171
|
+
| `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
|
|
172
|
+
| `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
|
|
173
|
+
| `config.states` | `Record<string, string>` | `{}` | Predefined state aliases (e.g. `{ '@mobile': '@media(w < 768px)' }`) |
|
|
174
|
+
| `config.devMode` | `boolean` | `false` | Add source comments to CSS |
|
|
175
|
+
| `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. |
|
|
176
|
+
| `config.replaceTokens` | `Record<string, string \| number>` | — | Parse-time token substitution. Keys use `$name` for custom properties and `#name` for color tokens. |
|
|
177
|
+
| `config.recipes` | `Record<string, RecipeStyles>` | `{}` | Predefined style recipes |
|
|
178
|
+
| `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
|
|
179
|
+
| `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
|
|
180
|
+
| `config.counterStyles` | `Record<string, CounterStyleDescriptors>` | — | Global `@counter-style` definitions |
|
|
181
|
+
| `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ em: 'em', vw: 'vw' }` |
|
|
182
|
+
| `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
|
|
183
|
+
| `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
|
|
184
|
+
| `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
|
|
185
|
+
| `config.handlers` | `Record<string, StyleHandlerDefinition>` | — | Custom style handlers that transform style properties into CSS declarations |
|
|
186
|
+
| `config.presets` | `Record<string, TypographyPreset>` | — | Typography presets — shorthand for `generateTypographyTokens()`. Generated tokens merge under explicit `tokens`. |
|
|
187
|
+
| `config.globalStyles` | `Record<string, Styles>` | — | Global Tasty styles keyed by CSS selector. Supports the full style syntax. |
|
|
188
|
+
| `config.autoPropertyTypes` | `boolean` | `true` | Automatically infer and register CSS `@property` declarations from values |
|
|
189
|
+
| `config.parserCacheSize` | `number` | `1000` | Parser LRU cache size. Larger values improve performance for builds with many unique style values |
|
|
190
|
+
| `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). |
|
|
191
|
+
|
|
192
|
+
### Coexisting with `tasty()`
|
|
193
|
+
|
|
194
|
+
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:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
// tasty-zero.config.ts (Babel plugin)
|
|
198
|
+
export default { namePrefix: 'mbs' };
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
// app entry (`tasty()` configure)
|
|
203
|
+
configure({ namePrefix: 'mb' });
|
|
204
|
+
```
|
|
140
205
|
|
|
141
206
|
---
|
|
142
207
|
|
|
@@ -148,16 +213,24 @@ Recipes work with `tastyStatic` the same way as with runtime `tasty`:
|
|
|
148
213
|
// babel.config.js
|
|
149
214
|
module.exports = {
|
|
150
215
|
plugins: [
|
|
151
|
-
[
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
216
|
+
[
|
|
217
|
+
'@tenphi/tasty/babel-plugin',
|
|
218
|
+
{
|
|
219
|
+
output: 'public/tasty.css',
|
|
220
|
+
config: {
|
|
221
|
+
recipes: {
|
|
222
|
+
card: {
|
|
223
|
+
padding: '4x',
|
|
224
|
+
fill: '#surface',
|
|
225
|
+
radius: '1r',
|
|
226
|
+
border: true,
|
|
227
|
+
},
|
|
228
|
+
elevated: { shadow: '2x 2x 4x #shadow' },
|
|
229
|
+
},
|
|
157
230
|
},
|
|
158
231
|
},
|
|
159
|
-
|
|
160
|
-
]
|
|
232
|
+
],
|
|
233
|
+
],
|
|
161
234
|
};
|
|
162
235
|
```
|
|
163
236
|
|
|
@@ -169,38 +242,59 @@ const card = tastyStatic({
|
|
|
169
242
|
color: '#text',
|
|
170
243
|
});
|
|
171
244
|
|
|
172
|
-
<div className={card}>Styled card</div
|
|
245
|
+
<div className={card}>Styled card</div>;
|
|
173
246
|
```
|
|
174
247
|
|
|
175
248
|
---
|
|
176
249
|
|
|
177
250
|
## Next.js Integration
|
|
178
251
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
252
|
+
The `withTastyZero` wrapper configures both **webpack** and **Turbopack** automatically. No `--webpack` flag is needed — it works with whichever bundler Next.js uses.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
// next.config.ts
|
|
256
|
+
import { withTastyZero } from '@tenphi/tasty/zero/next';
|
|
182
257
|
|
|
183
|
-
|
|
258
|
+
export default withTastyZero({
|
|
184
259
|
output: 'public/tasty.css',
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
'@mobile': '@media(w < 768px)',
|
|
188
|
-
},
|
|
189
|
-
devMode: process.env.NODE_ENV === 'development',
|
|
190
|
-
},
|
|
260
|
+
configFile: './app/tasty-zero.config.ts',
|
|
261
|
+
configDeps: ['./app/theme.ts'],
|
|
191
262
|
})({
|
|
192
263
|
reactStrictMode: true,
|
|
193
264
|
});
|
|
194
265
|
```
|
|
195
266
|
|
|
196
|
-
###
|
|
267
|
+
### `withTastyZero` Options
|
|
197
268
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
269
|
+
| Option | Type | Default | Description |
|
|
270
|
+
| ------------ | -------------------- | -------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
271
|
+
| `output` | `string` | `'public/tasty.css'` | Output path for CSS relative to project root |
|
|
272
|
+
| `mode` | `'file' \| 'inject'` | `'file'` | `'file'` writes CSS to disk; `'inject'` embeds CSS inline in JS |
|
|
273
|
+
| `enabled` | `boolean` | `true` | Enable/disable the plugin |
|
|
274
|
+
| `configFile` | `string` | — | Path to a TS/JS module that default-exports `TastyZeroConfig`. Recommended for Turbopack compatibility. |
|
|
275
|
+
| `config` | `TastyZeroConfig` | — | Inline config object. For static configs that don't change during dev. |
|
|
276
|
+
| `configDeps` | `string[]` | `[]` | Extra files the config depends on (for cache invalidation) |
|
|
277
|
+
|
|
278
|
+
### Turbopack Support
|
|
279
|
+
|
|
280
|
+
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.
|
|
281
|
+
|
|
282
|
+
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.
|
|
283
|
+
|
|
284
|
+
**Requirements**: `babel-loader` must be installed in your project:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
pnpm add babel-loader
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### CSS Injection
|
|
291
|
+
|
|
292
|
+
`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.
|
|
201
293
|
|
|
202
|
-
|
|
203
|
-
|
|
294
|
+
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`:
|
|
295
|
+
|
|
296
|
+
```gitignore
|
|
297
|
+
public/tasty.css
|
|
204
298
|
```
|
|
205
299
|
|
|
206
300
|
---
|
|
@@ -217,12 +311,15 @@ export default defineConfig({
|
|
|
217
311
|
react({
|
|
218
312
|
babel: {
|
|
219
313
|
plugins: [
|
|
220
|
-
[
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
314
|
+
[
|
|
315
|
+
'@tenphi/tasty/babel-plugin',
|
|
316
|
+
{
|
|
317
|
+
output: 'public/tasty.css',
|
|
318
|
+
config: {
|
|
319
|
+
states: { '@mobile': '@media(w < 768px)' },
|
|
320
|
+
},
|
|
224
321
|
},
|
|
225
|
-
|
|
322
|
+
],
|
|
226
323
|
],
|
|
227
324
|
},
|
|
228
325
|
}),
|
|
@@ -256,7 +353,9 @@ export const Button = () => <button className={button}>Click</button>;
|
|
|
256
353
|
const button = {
|
|
257
354
|
className: 'ts3f2a1b ts8c4d2e',
|
|
258
355
|
styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
|
|
259
|
-
toString() {
|
|
356
|
+
toString() {
|
|
357
|
+
return this.className;
|
|
358
|
+
},
|
|
260
359
|
};
|
|
261
360
|
|
|
262
361
|
export const Button = () => <button className={button}>Click</button>;
|
|
@@ -285,6 +384,101 @@ export const Button = () => <button className={button}>Click</button>;
|
|
|
285
384
|
|
|
286
385
|
---
|
|
287
386
|
|
|
387
|
+
## Inject Mode
|
|
388
|
+
|
|
389
|
+
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.
|
|
390
|
+
|
|
391
|
+
This is ideal for **reusable components**, **extensions**, and **libraries** where consumers shouldn't need to manage an external CSS file.
|
|
392
|
+
|
|
393
|
+
### How It Works
|
|
394
|
+
|
|
395
|
+
1. The Babel plugin extracts CSS at build time (same pipeline as file mode).
|
|
396
|
+
2. Instead of writing to a `.css` file, the CSS is embedded as string literals in the JS output.
|
|
397
|
+
3. The `@tenphi/tasty/static` import is rewritten to `@tenphi/tasty/static/inject`.
|
|
398
|
+
4. Each `tastyStatic` call becomes a self-contained expression that injects its CSS and evaluates to a `StaticStyle` object.
|
|
399
|
+
|
|
400
|
+
### Configuration
|
|
401
|
+
|
|
402
|
+
```javascript
|
|
403
|
+
// babel.config.js
|
|
404
|
+
module.exports = {
|
|
405
|
+
plugins: [
|
|
406
|
+
[
|
|
407
|
+
'@tenphi/tasty/babel-plugin',
|
|
408
|
+
{
|
|
409
|
+
mode: 'inject',
|
|
410
|
+
config: {
|
|
411
|
+
states: { '@mobile': '@media(w < 768px)' },
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
],
|
|
416
|
+
};
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
With Next.js:
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// next.config.ts
|
|
423
|
+
import { withTastyZero } from '@tenphi/tasty/zero/next';
|
|
424
|
+
|
|
425
|
+
export default withTastyZero({
|
|
426
|
+
mode: 'inject',
|
|
427
|
+
configFile: './app/tasty-zero.config.ts',
|
|
428
|
+
})({
|
|
429
|
+
reactStrictMode: true,
|
|
430
|
+
});
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
When `mode` is `'inject'`, the `output` and `injectImport` options are ignored.
|
|
434
|
+
|
|
435
|
+
### Build Transformation (inject mode)
|
|
436
|
+
|
|
437
|
+
**Before:**
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import { tastyStatic } from '@tenphi/tasty/static';
|
|
441
|
+
|
|
442
|
+
const button = tastyStatic({
|
|
443
|
+
padding: '2x 4x',
|
|
444
|
+
fill: '#purple',
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
tastyStatic('.heading', { preset: 'h1' });
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**After:**
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
|
|
454
|
+
|
|
455
|
+
const button =
|
|
456
|
+
(_$i(
|
|
457
|
+
'ts3f2a1b ts8c4d2e',
|
|
458
|
+
'.ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}',
|
|
459
|
+
),
|
|
460
|
+
{
|
|
461
|
+
className: 'ts3f2a1b ts8c4d2e',
|
|
462
|
+
styles: { padding: '2x 4x', fill: '#purple' },
|
|
463
|
+
toString() {
|
|
464
|
+
return this.className;
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
_$i('.heading', '.heading{font-size:2.5rem;font-weight:700;line-height:1.2}');
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Dev Mode / HMR
|
|
472
|
+
|
|
473
|
+
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.
|
|
474
|
+
|
|
475
|
+
### Limitations (inject mode)
|
|
476
|
+
|
|
477
|
+
- **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()`.
|
|
478
|
+
- **Larger JS bundle** — CSS is embedded in JavaScript, increasing bundle size. Best suited for components and extensions, not full-app styling.
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
288
482
|
## Style Extension
|
|
289
483
|
|
|
290
484
|
```tsx
|
|
@@ -295,7 +489,7 @@ const button = tastyStatic({
|
|
|
295
489
|
radius: '1r',
|
|
296
490
|
fill: '#gray.20',
|
|
297
491
|
color: '#text',
|
|
298
|
-
transition: 'fill
|
|
492
|
+
transition: 'fill',
|
|
299
493
|
});
|
|
300
494
|
|
|
301
495
|
// Variants
|
|
@@ -349,13 +543,15 @@ For dynamic styling needs, combine with regular CSS or CSS variables:
|
|
|
349
543
|
```tsx
|
|
350
544
|
const card = tastyStatic({
|
|
351
545
|
padding: '4x',
|
|
352
|
-
fill: '
|
|
546
|
+
fill: '($card-bg, #white)',
|
|
353
547
|
});
|
|
354
548
|
|
|
355
549
|
<div
|
|
356
550
|
className={card}
|
|
357
|
-
style={{
|
|
358
|
-
|
|
551
|
+
style={{
|
|
552
|
+
'--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
|
|
553
|
+
}}
|
|
554
|
+
/>;
|
|
359
555
|
```
|
|
360
556
|
|
|
361
557
|
---
|
|
@@ -366,11 +562,21 @@ const card = tastyStatic({
|
|
|
366
562
|
2. **Use selector mode** for global/body styles
|
|
367
563
|
3. **Enable devMode** in development for easier debugging
|
|
368
564
|
4. **Configure states** for consistent responsive breakpoints
|
|
369
|
-
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## Common Issues
|
|
569
|
+
|
|
570
|
+
- 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.
|
|
571
|
+
- 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()`.
|
|
572
|
+
- Turbopack config behaves inconsistently: prefer `configFile` over inline functions so the setup stays JSON-serializable.
|
|
370
573
|
|
|
371
574
|
---
|
|
372
575
|
|
|
373
576
|
## Related
|
|
374
577
|
|
|
375
|
-
- [
|
|
578
|
+
- [Docs Hub](README.md) — Choose the right guide by task or CSS delivery model
|
|
579
|
+
- [Style DSL](dsl.md) — State maps, tokens, units, extending semantics (shared by runtime and static)
|
|
580
|
+
- [React API](react-api.md) — Client or server rendering with `tasty()`: component props, variants, sub-elements, and style functions
|
|
376
581
|
- [Configuration](configuration.md) — Global configuration: tokens, recipes, custom units, and style handlers
|
|
582
|
+
- [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)
|