@tenphi/tasty 0.0.0-snapshot.b2ad8a7 → 0.0.0-snapshot.b317d64
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 +6 -6
- package/dist/babel-types-C_7kRP38.d.ts +18 -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-BDLYGmKn.js +60 -0
- package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
- package/dist/{collector-DCI2yzwx.js → chunks/collector-DqcB0UUT.js} +25 -119
- package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
- package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
- package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
- package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
- package/dist/chunks/css-definitions-BibU6ZnP.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-Dy36S1sU.js +502 -0
- package/dist/chunks/debug-Dy36S1sU.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-BljxMd6C.js +582 -0
- package/dist/chunks/react-runtime-BljxMd6C.js.map +1 -0
- package/dist/chunks/runtime-engine-CPYI2bA8.js +2415 -0
- package/dist/chunks/runtime-engine-CPYI2bA8.js.map +1 -0
- package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
- package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
- package/dist/{merge-styles-CzVxdtav.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
- package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
- package/dist/{css-writer-Cq0fg5v8.js → chunks/zero-engine-b--JCZad.js} +51 -146
- package/dist/chunks/zero-engine-b--JCZad.js.map +1 -0
- package/dist/{collector-CQDeU7WS.d.ts → collector-w4mBj5gd.d.ts} +23 -4
- package/dist/{config-CwRr6-fG.d.ts → config-CrZOfNJ5.d.ts} +110 -96
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/{index-C0W21Qcb.d.ts → index-CYJtAI9a.d.ts} +243 -281
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -998
- package/dist/{merge-styles-Bpwfy1CS.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- 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 +3 -2
- package/dist/ssr/astro-middleware-static.js +0 -11
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -2
- package/dist/ssr/astro-middleware.js +0 -12
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -6
- package/dist/ssr/astro.js +157 -93
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +10 -11
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +134 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -8
- package/dist/ssr/next.js +29 -43
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -22
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/{index-DpykQKO8.d.ts → types-JEY8PVYP.d.ts} +986 -972
- package/dist/zero/babel.d.ts +67 -2
- package/dist/zero/babel.js +57 -131
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +44 -8
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +0 -31
- package/dist/zero/next.js.map +1 -1
- package/docs/ai-agents.md +31 -5
- package/docs/configuration.md +18 -2
- package/docs/debug.md +15 -5
- package/docs/dsl.md +56 -8
- package/docs/getting-started.md +13 -11
- package/docs/injector.md +21 -7
- package/docs/methodology.md +5 -5
- package/docs/pipeline.md +34 -10
- package/docs/plugins.md +1 -1
- package/docs/react-api.md +9 -0
- package/docs/runtime-benchmarks.md +282 -110
- package/docs/ssr.md +179 -20
- package/docs/styles.md +89 -19
- package/docs/tasty-static.md +34 -1
- package/package.json +101 -36
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/babel-B_P8t-f0.d.ts +0 -83
- package/dist/collector-DCI2yzwx.js.map +0 -1
- package/dist/config-B97n_EIv.js +0 -12612
- package/dist/config-B97n_EIv.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-DWrUWxog.js +0 -1645
- package/dist/core-DWrUWxog.js.map +0 -1
- package/dist/css-writer-Cq0fg5v8.js.map +0 -1
- package/dist/format-global-rules-DklyaXv-.js +0 -22
- package/dist/format-global-rules-DklyaXv-.js.map +0 -1
- package/dist/format-rules-Wb7dJOoL.js +0 -130
- package/dist/format-rules-Wb7dJOoL.js.map +0 -1
- package/dist/hydrate-gFTLBDK9.js +0 -37
- package/dist/hydrate-gFTLBDK9.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/merge-styles-CzVxdtav.js.map +0 -1
- package/dist/renderChunk-COXABoQz.js +0 -290
- package/dist/renderChunk-COXABoQz.js.map +0 -1
- package/dist/resolve-recipes-BnrUEjWV.js +0 -144
- package/dist/resolve-recipes-BnrUEjWV.js.map +0 -1
package/docs/ssr.md
CHANGED
|
@@ -86,6 +86,92 @@ export default function RootLayout({
|
|
|
86
86
|
|
|
87
87
|
That's it. All `tasty()` components inside the tree automatically get SSR support. No per-component changes needed.
|
|
88
88
|
|
|
89
|
+
### Optional shared globals stylesheet
|
|
90
|
+
|
|
91
|
+
By default, configured global CSS is included in the streamed Tasty style tag
|
|
92
|
+
for every route. `withTastyNext()` can move that stable CSS into one
|
|
93
|
+
content-hashed stylesheet shared by all routes while leaving component and hook
|
|
94
|
+
styles in the normal streaming path.
|
|
95
|
+
|
|
96
|
+
Keep the Tasty config in a side-effect-free module:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// app/tasty.config.ts
|
|
100
|
+
import type { TastyConfig } from '@tenphi/tasty';
|
|
101
|
+
|
|
102
|
+
const config: TastyConfig = {
|
|
103
|
+
tokens: { $gap: '8px', '#brand': 'rebeccapurple' },
|
|
104
|
+
globalStyles: { body: { margin: '0', color: '#brand' } },
|
|
105
|
+
fontFaces: {
|
|
106
|
+
Brand: { src: 'url("/fonts/brand.woff2") format("woff2")' },
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default config;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use it from the Next config:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// next.config.ts
|
|
117
|
+
import { withTastyNext } from '@tenphi/tasty/ssr/next-config';
|
|
118
|
+
import config from './app/tasty.config';
|
|
119
|
+
|
|
120
|
+
export default withTastyNext({
|
|
121
|
+
config,
|
|
122
|
+
})({
|
|
123
|
+
// your Next.js config
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The runtime must receive the same config. Import and configure it before the
|
|
128
|
+
registry renders:
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
// app/tasty-registry.tsx
|
|
132
|
+
'use client';
|
|
133
|
+
|
|
134
|
+
import { configure } from '@tenphi/tasty';
|
|
135
|
+
import { TastyRegistry } from '@tenphi/tasty/ssr/next';
|
|
136
|
+
import config from './tasty.config';
|
|
137
|
+
|
|
138
|
+
configure(config);
|
|
139
|
+
|
|
140
|
+
export default function TastyStyleRegistry({ children }) {
|
|
141
|
+
return <TastyRegistry>{children}</TastyRegistry>;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The generated file contains eager configuration artifacts: built-in and custom
|
|
146
|
+
`@property` rules, tokens and presets, `@font-face`, `@counter-style`, native
|
|
147
|
+
CSS `@function` definitions, and `globalStyles`. Route-dependent component
|
|
148
|
+
rules and calls to `useGlobalStyles`, `useRawCSS`, `useKeyframes`,
|
|
149
|
+
`useProperty`, `useFontFace`, `useCounterStyle`, and `useFunction` remain
|
|
150
|
+
route-specific. Configured keyframes also remain lazy and are streamed only
|
|
151
|
+
when a route references them.
|
|
152
|
+
|
|
153
|
+
The default output directory is `public/_tasty`. The wrapper adds the generated
|
|
154
|
+
URL to `TastyRegistry`, respects `basePath`, preserves existing `env` and
|
|
155
|
+
`headers` config, and serves the content-hashed file with an immutable one-year
|
|
156
|
+
cache header on Next server deployments. Static exports keep the content-hashed
|
|
157
|
+
URL and leave cache headers to the hosting provider. Older hashes are not
|
|
158
|
+
deleted automatically, so rolling deployments cannot break pages from the
|
|
159
|
+
previous build; clean the generated directory as part of a clean deployment if
|
|
160
|
+
needed. Page-relative CSS resources such as
|
|
161
|
+
`url(../fonts/brand.woff2)` are rejected because moving them would change their
|
|
162
|
+
meaning; use root-relative, absolute, or data URLs.
|
|
163
|
+
|
|
164
|
+
`withTastyNext()` options:
|
|
165
|
+
|
|
166
|
+
| Option | Type | Default | Description |
|
|
167
|
+
| ------------ | ------------- | ------------------------- | ---------------------------------------------------------------------- |
|
|
168
|
+
| `config` | `TastyConfig` | — | Config object; takes precedence over `configFile` |
|
|
169
|
+
| `configFile` | `string` | — | Project-relative config module path; requires the optional `jiti` peer |
|
|
170
|
+
| `rootDir` | `string` | current directory | Next app root when the build runs from a monorepo root |
|
|
171
|
+
| `outputDir` | `string` | `public/_tasty` | Filesystem output directory |
|
|
172
|
+
| `publicPath` | `string` | inferred from `outputDir` | Root-relative URL; required when output is outside `public` |
|
|
173
|
+
| `enabled` | `boolean` | `true` | Disable generation without changing wrapper composition |
|
|
174
|
+
|
|
89
175
|
### How it works
|
|
90
176
|
|
|
91
177
|
- `TastyRegistry` is a `'use client'` component, but Next.js still server-renders it on initial page load. The `'use client'` boundary is required solely to access `useServerInsertedHTML` — **not** because `tasty()` components need the client.
|
|
@@ -128,13 +214,15 @@ The nonce is automatically applied to all `<style>` and `<script>` tags injected
|
|
|
128
214
|
|
|
129
215
|
## Astro
|
|
130
216
|
|
|
131
|
-
Tasty offers
|
|
217
|
+
Tasty offers several levels of Astro integration. Choose the one that matches your needs:
|
|
132
218
|
|
|
133
|
-
| Setup
|
|
134
|
-
|
|
|
135
|
-
| Zero setup
|
|
136
|
-
| `tastyIntegration({ islands: false })`
|
|
137
|
-
| `tastyIntegration()`
|
|
219
|
+
| Setup | Config needed | Deduplication | Hooks work | Client JS |
|
|
220
|
+
| ---------------------------------------------------------------- | ------------- | ------------------------- | ---------------------- | -------------- |
|
|
221
|
+
| Zero setup | None | Per render tree | Yes (within each tree) | None |
|
|
222
|
+
| `tastyIntegration({ islands: false })` | One line | Cross-tree | Yes | None |
|
|
223
|
+
| `tastyIntegration()` | One line | Cross-tree | Yes | Auto-hydration |
|
|
224
|
+
| `tastyIntegration({ css: { mode: 'extract' } })` | One line | Cross-tree and cross-page | Yes | Auto-hydration |
|
|
225
|
+
| `tastyIntegration({ islands: false, css: { mode: 'extract' } })` | One line | Cross-tree and cross-page | Yes | None |
|
|
138
226
|
|
|
139
227
|
### Zero setup (static pages)
|
|
140
228
|
|
|
@@ -231,6 +319,63 @@ export default defineConfig({
|
|
|
231
319
|
|
|
232
320
|
This gives the same middleware deduplication and hook support, but ships zero client-side JavaScript. No class-list `<script>` is emitted.
|
|
233
321
|
|
|
322
|
+
#### Build-wide CSS extraction
|
|
323
|
+
|
|
324
|
+
Static Astro builds can move Tasty CSS into content-hashed, browser-cacheable
|
|
325
|
+
shared and page assets:
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
export default defineConfig({
|
|
329
|
+
integrations: [
|
|
330
|
+
react(),
|
|
331
|
+
tastyIntegration({
|
|
332
|
+
islands: false,
|
|
333
|
+
css: {
|
|
334
|
+
mode: 'extract',
|
|
335
|
+
},
|
|
336
|
+
}),
|
|
337
|
+
],
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
`css.mode` defaults to `'inline'`, so existing projects keep their current
|
|
342
|
+
output. Extraction requires Astro 5 or newer and only applies to prerendered
|
|
343
|
+
production pages. Development, preview-time SSR, and on-demand routes continue
|
|
344
|
+
to receive the normal inline `<style data-tasty-ssr>` output.
|
|
345
|
+
|
|
346
|
+
Extraction writes every artifact emitted by all styled pages to a shared
|
|
347
|
+
stylesheet. Each page's strict set difference is written to a separate page
|
|
348
|
+
stylesheet. The shared link comes first and the page link follows, so shared
|
|
349
|
+
styles form the base cascade and page-only styles can override them. A fully
|
|
350
|
+
shared page omits the empty page stylesheet. If generated pages have no common
|
|
351
|
+
artifacts, each page receives only its page stylesheet.
|
|
352
|
+
|
|
353
|
+
The shared-base/page-override order is the extraction-mode cascade contract.
|
|
354
|
+
It does not preserve an inline artifact order where a page-only rule originally
|
|
355
|
+
appeared before a shared rule. Use shared styles for defaults and page-only
|
|
356
|
+
styles for overrides.
|
|
357
|
+
|
|
358
|
+
Extracted CSS preserves resource URLs verbatim. Relative URLs in an inline
|
|
359
|
+
style resolve from the page, but in an extracted stylesheet they resolve from
|
|
360
|
+
the asset directory. Use absolute URLs or data URLs when extraction is enabled.
|
|
361
|
+
Root-relative URLs such as `url(/fonts/brand.woff2)` are also safe while the
|
|
362
|
+
stylesheet stays on the page's origin. The build fails with a clear error if an
|
|
363
|
+
artifact contains a page-relative or fragment-only URL, including URL strings
|
|
364
|
+
in `image-set()`, `image()`, `src()`, and `@import`.
|
|
365
|
+
|
|
366
|
+
Assets are written under Astro's configured `build.assets` directory (for
|
|
367
|
+
example, `/_astro/tasty.shared.a1b2c3.css` and
|
|
368
|
+
`/_astro/tasty.page.d4e5f6.css`). Links include the configured Astro `base`, so
|
|
369
|
+
nested routes do not need relative-path handling. Content hashes and output are
|
|
370
|
+
deterministic for identical builds. If `build.assetsPrefix` is configured,
|
|
371
|
+
Tasty uses its CSS-specific prefix (or `fallback`) just like Astro-generated
|
|
372
|
+
stylesheets. When that prefix points to a different origin, root-relative
|
|
373
|
+
resources would resolve against the asset origin rather than the page's origin,
|
|
374
|
+
so the build rejects them as well. Tasty compares the prefix with Astro's `site`
|
|
375
|
+
when it is configured; without `site`, an absolute or protocol-relative prefix
|
|
376
|
+
is treated conservatively as cross-origin. Use a fully absolute resource URL in
|
|
377
|
+
that configuration.
|
|
378
|
+
|
|
234
379
|
### Manual middleware (advanced)
|
|
235
380
|
|
|
236
381
|
If you need to compose Tasty's middleware with other middleware (e.g., via `sequence()`), use `tastyMiddleware()` directly:
|
|
@@ -263,10 +408,15 @@ Astro's `@astrojs/react` renderer calls `renderToString()` for each React compon
|
|
|
263
408
|
- **Static components** (no `client:*`): Styles are collected during `renderToString` and injected into `</head>` as a single `<style>` tag. No JavaScript is shipped.
|
|
264
409
|
- **Islands** (`client:load`, `client:visible`, etc.): Styles are collected during SSR the same way. On the client, the hydration script (auto-injected by `tastyIntegration()` or manually via `@tenphi/tasty/ssr/astro-client`) reads the class list from `window.__TASTY__` and pre-populates the injector's rules map. The island's `computeStyles()` calls see the class names as already registered and skip the pipeline during hydration.
|
|
265
410
|
- The middleware reads the full response body, then injects the collected CSS into `</head>` before sending the final HTML.
|
|
411
|
+
- In extraction mode, prerendered responses also carry temporary structured
|
|
412
|
+
artifact metadata. `astro:build:done` uses those collector-provided
|
|
413
|
+
boundaries to write shared and page assets and rewrite generated HTML, then
|
|
414
|
+
removes the metadata. Artifact boundaries are never inferred by splitting or
|
|
415
|
+
reparsing the generated CSS.
|
|
266
416
|
|
|
267
417
|
### CSP nonce
|
|
268
418
|
|
|
269
|
-
Call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected `<style>` and `<script>` tags.
|
|
419
|
+
Call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected `<style>` and `<script>` tags. In extraction mode, the external stylesheet links retain the nonce.
|
|
270
420
|
|
|
271
421
|
---
|
|
272
422
|
|
|
@@ -349,13 +499,14 @@ const stream = await runWithCollector(collector, () =>
|
|
|
349
499
|
|
|
350
500
|
### Entry points
|
|
351
501
|
|
|
352
|
-
| Import path
|
|
353
|
-
|
|
|
354
|
-
| `@tenphi/tasty/ssr`
|
|
355
|
-
| `@tenphi/tasty/ssr/next`
|
|
356
|
-
| `@tenphi/tasty/ssr/
|
|
357
|
-
| `@tenphi/tasty/ssr/astro
|
|
358
|
-
| `@tenphi/tasty/ssr/astro-
|
|
502
|
+
| Import path | Description |
|
|
503
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
504
|
+
| `@tenphi/tasty/ssr` | Core SSR API: `ServerStyleCollector`, `createServerStyleCollector`, `runWithCollector`, `hydrateTastyClasses` |
|
|
505
|
+
| `@tenphi/tasty/ssr/next` | Next.js App Router: `TastyRegistry` component |
|
|
506
|
+
| `@tenphi/tasty/ssr/next-config` | Next.js config wrapper: shared, content-hashed global stylesheet |
|
|
507
|
+
| `@tenphi/tasty/ssr/astro` | Astro: `tastyIntegration`, `tastyMiddleware` |
|
|
508
|
+
| `@tenphi/tasty/ssr/astro-client` | Astro: client-side cache hydration (auto-injected by integration, or import manually) |
|
|
509
|
+
| `@tenphi/tasty/ssr/astro-middleware`<br />`@tenphi/tasty/ssr/astro-middleware-static`<br />`@tenphi/tasty/ssr/astro-middleware-extract`<br />`@tenphi/tasty/ssr/astro-middleware-extract-static` | Astro: the middleware entrypoints `tastyIntegration()` registers via `addMiddleware()`. Exported so Astro can resolve them by specifier; you should not import them. For manual setups use `tastyMiddleware()`. |
|
|
359
510
|
|
|
360
511
|
### `ServerStyleCollector`
|
|
361
512
|
|
|
@@ -375,7 +526,7 @@ Constructor: `new ServerStyleCollector(namePrefix?)`, or use the `createServerSt
|
|
|
375
526
|
| `allocateCounterStyleName(providedName?)` | Allocate a counter-style name. Returns `providedName` if given, otherwise generates one using `${namePrefix}c${counter}` (e.g. `tc0`, `tc1`, ...). |
|
|
376
527
|
| `collectGlobalStyles(key, css)` | Record global styles (from `useGlobalStyles`). Deduplicated by key. |
|
|
377
528
|
| `collectRawCSS(key, css)` | Record raw CSS text (from `useRawCSS`). Deduplicated by key. |
|
|
378
|
-
| `collectInternals()` | Collect
|
|
529
|
+
| `collectInternals()` | Collect eager configured globals: `@property`, `:root` tokens and presets, `@font-face`, `@counter-style`, `@function`, and `globalStyles`. Called automatically on first chunk collection; idempotent. |
|
|
379
530
|
| `getCSS()` | Get all collected CSS as a single string. For non-streaming SSR. |
|
|
380
531
|
| `flushCSS()` | Get only CSS collected since the last flush. For streaming SSR. |
|
|
381
532
|
| `getRenderedClassNames()` | Get the list of class names rendered so far. Serialized to `window.__TASTY__` for client hydration via `hydrateTastyClasses()`. |
|
|
@@ -384,10 +535,18 @@ Constructor: `new ServerStyleCollector(namePrefix?)`, or use the `createServerSt
|
|
|
384
535
|
|
|
385
536
|
Next.js App Router component. Props:
|
|
386
537
|
|
|
387
|
-
| Prop
|
|
388
|
-
|
|
|
389
|
-
| `children`
|
|
390
|
-
| `transferCache`
|
|
538
|
+
| Prop | Type | Default | Description |
|
|
539
|
+
| ------------------ | ----------------- | --------- | ------------------------------------------------------------------------- |
|
|
540
|
+
| `children` | `ReactNode` | required | Application tree |
|
|
541
|
+
| `transferCache` | `boolean` | `true` | Embed cache state script for zero-cost hydration |
|
|
542
|
+
| `sharedStylesheet` | `string \| false` | generated | Override the shared URL, or disable generated shared CSS for the registry |
|
|
543
|
+
|
|
544
|
+
### `withTastyNext(options)`
|
|
545
|
+
|
|
546
|
+
Next.js configuration wrapper exported from
|
|
547
|
+
`@tenphi/tasty/ssr/next-config`. It generates a shared stylesheet from eager
|
|
548
|
+
Tasty configuration artifacts and wires its URL and immutable cache header
|
|
549
|
+
into the Next config. Route-specific CSS continues through `TastyRegistry`.
|
|
391
550
|
|
|
392
551
|
### `tastyIntegration(options?)`
|
|
393
552
|
|
|
@@ -429,7 +588,7 @@ Class names are also derived from the _resolved_ styles, so the server and the c
|
|
|
429
588
|
|
|
430
589
|
### Styles duplicated after hydration
|
|
431
590
|
|
|
432
|
-
**Global CSS** (`:root` tokens, `@property`, `globalStyles`, `@font-face`, `@counter-style`) configured via `configure()` is automatically deduplicated. When Tasty detects
|
|
591
|
+
**Global CSS** (`:root` tokens, `@property`, `globalStyles`, `@font-face`, `@counter-style`, `@function`) configured via `configure()` is automatically deduplicated. When Tasty detects an inline or extracted `[data-tasty-ssr]` stylesheet in the document, it skips client-side injection of globals that were already rendered by the SSR collector. This means `configure()` can be called with the full config on both server and client — no `typeof window === 'undefined'` guard is needed.
|
|
433
592
|
|
|
434
593
|
**Component CSS**: SSR `<style data-tasty-ssr>` tags remain in the DOM. The client injector creates separate `<style>` elements for any new styles. SSR styles are never modified or removed by the client. If this is a concern for very large apps, you can remove the SSR style tags and hydration scripts manually after hydration:
|
|
435
594
|
|
package/docs/styles.md
CHANGED
|
@@ -20,9 +20,10 @@ Use these instead of their raw CSS counterparts:
|
|
|
20
20
|
|-----|------------|
|
|
21
21
|
| `fill` | `backgroundColor`, `background` |
|
|
22
22
|
| `image` | `backgroundImage` |
|
|
23
|
-
| `padding` (with direction modifiers) | `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft` |
|
|
24
|
-
| `margin` (with direction modifiers) | `marginTop`, `marginRight`, `marginBottom`, `marginLeft` |
|
|
25
|
-
|
|
|
23
|
+
| `padding` (with physical direction modifiers) | `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft` |
|
|
24
|
+
| `margin` (with physical direction modifiers) | `marginTop`, `marginRight`, `marginBottom`, `marginLeft` |
|
|
25
|
+
| Logical block/inline category styles (with `start`/`end` modifiers) | Native logical axis/edge declarations |
|
|
26
|
+
| `width` / `blockSize` / `inlineSize` (with `min`/`max` modifiers) | Their separate min/max declarations when one state map is sufficient |
|
|
26
27
|
| `height` (with `min`/`max` modifiers) | `minHeight`, `maxHeight` |
|
|
27
28
|
| `border` | `borderColor`, `borderWidth`, `borderStyle` |
|
|
28
29
|
| `radius` | `borderRadius` |
|
|
@@ -36,6 +37,24 @@ Use these instead of their raw CSS counterparts:
|
|
|
36
37
|
|
|
37
38
|
## Layout
|
|
38
39
|
|
|
40
|
+
### `overscrollBehavior`
|
|
41
|
+
|
|
42
|
+
The native `overscrollBehavior` shorthand and its `overscrollBehaviorBlock`,
|
|
43
|
+
`overscrollBehaviorInline`, `overscrollBehaviorX`, and `overscrollBehaviorY`
|
|
44
|
+
longhands support `auto`, `contain`, `none`, and `chain`. The shorthand can set
|
|
45
|
+
separate X and Y values, for example `overscrollBehavior: 'chain contain'`.
|
|
46
|
+
|
|
47
|
+
`chain` allows scroll chaining to another scrollable area while suppressing
|
|
48
|
+
boundary effects such as bounce. It requires browser support; use a feature
|
|
49
|
+
query and a fallback floor when targeting browsers without it:
|
|
50
|
+
|
|
51
|
+
```jsx
|
|
52
|
+
overscrollBehaviorBlock: {
|
|
53
|
+
_: 'auto',
|
|
54
|
+
'@supports(overscroll-behavior-block: chain)': 'chain',
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
39
58
|
### `display`
|
|
40
59
|
|
|
41
60
|
Standard CSS display values. Handled together with `hide`, `textOverflow`, `overflow`, and `whiteSpace` for priority resolution.
|
|
@@ -125,9 +144,7 @@ A group that names *no* direction keeps plain CSS shorthand order, which is unam
|
|
|
125
144
|
|
|
126
145
|
Later comma-separated groups override earlier groups for conflicting directions.
|
|
127
146
|
|
|
128
|
-
Individual props `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft
|
|
129
|
-
|
|
130
|
-
**Priority:** `padding` < `paddingBlock`/`paddingInline` < `paddingTop`/`paddingRight`/`paddingBottom`/`paddingLeft`
|
|
147
|
+
Individual physical props `paddingTop`, `paddingRight`, `paddingBottom`, and `paddingLeft` are supported, but `padding` with modifiers is recommended. Use `blockPadding` or `inlinePadding` for an enhanced logical-axis shorthand; native declarations such as `paddingInlineStart` remain ordinary CSS properties. See [Logical properties](#logical-properties).
|
|
131
148
|
|
|
132
149
|
### `margin`
|
|
133
150
|
|
|
@@ -153,9 +170,7 @@ The [one-value-per-directional-group rule](#padding) from `padding` applies here
|
|
|
153
170
|
|
|
154
171
|
Later comma-separated groups override earlier groups for conflicting directions.
|
|
155
172
|
|
|
156
|
-
Individual props `marginTop`, `marginRight`, `marginBottom`, `marginLeft
|
|
157
|
-
|
|
158
|
-
**Priority:** `margin` < `marginBlock`/`marginInline` < `marginTop`/`marginRight`/`marginBottom`/`marginLeft`
|
|
173
|
+
Individual physical props `marginTop`, `marginRight`, `marginBottom`, and `marginLeft` are supported, but `margin` with modifiers is recommended. Use `blockMargin` or `inlineMargin` for an enhanced logical-axis shorthand; native declarations such as `marginInlineStart` remain ordinary CSS properties. See [Logical properties](#logical-properties).
|
|
159
174
|
|
|
160
175
|
### `width`
|
|
161
176
|
|
|
@@ -234,9 +249,44 @@ second to every side they span.
|
|
|
234
249
|
|
|
235
250
|
Later comma-separated groups override earlier groups for conflicting directions.
|
|
236
251
|
|
|
237
|
-
Individual props `top`, `right`, `bottom`, `left
|
|
252
|
+
Individual physical props `top`, `right`, `bottom`, and `left` are supported. When only those props are used (without `inset`), individual CSS properties are output for correct cascade behavior with state overrides. Use `blockInset` or `inlineInset` for logical axes; native declarations such as `insetInlineStart` remain ordinary CSS properties.
|
|
253
|
+
|
|
254
|
+
### Logical properties
|
|
255
|
+
|
|
256
|
+
Tasty provides one enhanced handler for each logical axis/category pair. Each handler emits native logical CSS instead of converting values to `top`, `right`, `bottom`, `left`, `width`, or `height`. The browser therefore resolves `block`, `inline`, `start`, and `end` from the element's `writingMode` and `direction`.
|
|
257
|
+
|
|
258
|
+
```jsx
|
|
259
|
+
styles: {
|
|
260
|
+
direction: 'rtl',
|
|
261
|
+
inlinePadding: '1x start, 2x end',
|
|
262
|
+
inlineBorder: '1bw solid #accent start',
|
|
263
|
+
blockInset: '0 end',
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
An axis handler accepts one value for both edges or two values in logical **start/end** order. Use `start` and `end` modifiers, with comma-separated groups for different edge values. Unspecified padding, margin, and scroll edges reset to `0`; unspecified inset edges reset to `auto`. The `longhand` modifier emits the two native start/end declarations.
|
|
268
|
+
|
|
269
|
+
| Category | Block axis | Inline axis |
|
|
270
|
+
|----------|------------|-------------|
|
|
271
|
+
| Size | `blockSize` | `inlineSize` |
|
|
272
|
+
| Padding | `blockPadding` | `inlinePadding` |
|
|
273
|
+
| Margin | `blockMargin` | `inlineMargin` |
|
|
274
|
+
| Inset | `blockInset` | `inlineInset` |
|
|
275
|
+
| Scroll margin | `blockScrollMargin` | `inlineScrollMargin` |
|
|
276
|
+
| Scroll padding | `blockScrollPadding` | `inlineScrollPadding` |
|
|
277
|
+
| Border | `blockBorder` | `inlineBorder` |
|
|
278
|
+
|
|
279
|
+
`blockSize` and `inlineSize` use the same enhanced one/two/three-value and `min`/`max`/`fixed` syntax as `width`. Separate `minBlockSize`, `maxBlockSize`, `minInlineSize`, and `maxInlineSize` declarations override constraints produced by that shorthand.
|
|
280
|
+
|
|
281
|
+
`blockBorder` and `inlineBorder` use the same width/style/color parsing and defaults as `border`, including `1bw`, color tokens, and `true`. Logical padding, margin, scroll margin, and scroll padding default to `1x` for `true`; logical inset defaults to `0`.
|
|
282
|
+
|
|
283
|
+
Native logical CSS names—such as `paddingInlineStart`, `borderBlockColor`, and `borderStartStartRadius`—remain available as ordinary CSS properties. They support Tasty tokens and units through the normal value parser, but do not get category defaults or directional shorthand behavior.
|
|
238
284
|
|
|
239
|
-
|
|
285
|
+
The physical `scrollMargin` and `scrollPadding` shorthands support the same values and physical direction modifiers as `padding`. Their logical counterparts stay in separate axis handlers.
|
|
286
|
+
|
|
287
|
+
`writingMode`, `direction`, and `textOrientation` are standard CSS control properties. They use Tasty's normal value parser and need no special handler.
|
|
288
|
+
|
|
289
|
+
Avoid setting physical and logical declarations that resolve to the same edge in one style block. Tasty keeps them separate and lets the native CSS cascade resolve the overlap, whose result also depends on writing mode and direction.
|
|
240
290
|
|
|
241
291
|
---
|
|
242
292
|
|
|
@@ -318,7 +368,7 @@ Border shorthand with directional and multi-group support. Use **comma-separated
|
|
|
318
368
|
|
|
319
369
|
**Syntax:** `[width] [style] [color] [directions...]` — comma-separated for multiple groups
|
|
320
370
|
|
|
321
|
-
**Defaults:** width = `1bw`, style = `solid`, color = `#border`
|
|
371
|
+
**Defaults:** width = `1bw`, style = `solid`, color = `#border`, which is the text color (`currentColor`) until your tokens define `#border`
|
|
322
372
|
|
|
323
373
|
**Styles:** `none`, `hidden`, `dotted`, `dashed`, `solid`, `double`, `groove`, `ridge`, `inset`, `outset`
|
|
324
374
|
|
|
@@ -383,7 +433,7 @@ Outline with inline offset support.
|
|
|
383
433
|
|
|
384
434
|
**Syntax:** `[width] [style] [color] / [offset]`
|
|
385
435
|
|
|
386
|
-
**Defaults:** width = `1ow`, style = `solid`, color = `#outline`
|
|
436
|
+
**Defaults:** width = `1ow`, style = `solid`, color = `#outline`, which is the text color (`currentColor`) until your tokens define `#outline`
|
|
387
437
|
|
|
388
438
|
**Styles:** Same as `border` (`none`, `dotted`, `dashed`, `solid`, etc.)
|
|
389
439
|
|
|
@@ -430,7 +480,7 @@ Use `/` to separate the preset name from one or more space-separated modifiers.
|
|
|
430
480
|
|
|
431
481
|
| Modifier | Effect |
|
|
432
482
|
|----------|--------|
|
|
433
|
-
| `strong` (or `bold`) | Sets `font-weight` to bold (from `$bold-font-weight` token) |
|
|
483
|
+
| `strong` (or `bold`) | Sets `font-weight` to bold (from `$bold-font-weight` token, `700` until your tokens define it) |
|
|
434
484
|
| `italic` | Sets `font-style: italic` |
|
|
435
485
|
| `icon` | Sets font-size and line-height to icon size |
|
|
436
486
|
| `tight` | Sets line-height equal to font-size |
|
|
@@ -534,15 +584,17 @@ When easing is provided without a duration, the default timing variable is used
|
|
|
534
584
|
| `zIndex` | `z-index` |
|
|
535
585
|
| `inset` | `inset`, `top`, `right`, `bottom`, `left` |
|
|
536
586
|
|
|
537
|
-
|
|
587
|
+
When two entries cover the same property, an entry that names that one property wins over a group such as `theme`, in either order: `opacity 120ms ease-in-out, theme` keeps the opacity timing. Otherwise the later entry wins, as in CSS.
|
|
588
|
+
|
|
589
|
+
Default timing: `$transition` (or `${name}-transition` with `$transition` fallback per semantic name). `$transition` is `80ms` until your tokens define it. Prefer omitting the duration or using a duration token instead of repeating raw time values across components. Explicit zero can disable motion.
|
|
538
590
|
|
|
539
591
|
```jsx
|
|
540
|
-
transition="theme
|
|
541
|
-
transition="fill
|
|
542
|
-
transition="fade
|
|
592
|
+
transition="theme"
|
|
593
|
+
transition="fill, radius"
|
|
594
|
+
transition="fade $transition ease-in"
|
|
543
595
|
transition="fill ease-in" // easing without duration (uses default timing)
|
|
544
596
|
transition="radius ease-in-out" // easing keyword only
|
|
545
|
-
transition="$$custom-prop
|
|
597
|
+
transition="$$custom-prop" // custom property transition
|
|
546
598
|
```
|
|
547
599
|
|
|
548
600
|
**Recognized easing keywords:** `ease`, `ease-in`, `ease-out`, `ease-in-out`, `linear`, `step-start`, `step-end`. CSS easing functions (`cubic-bezier(...)`, `steps(...)`, `linear(...)`) are also recognized.
|
|
@@ -551,6 +603,24 @@ If the name is not a semantic name, it is used as a literal CSS property name.
|
|
|
551
603
|
|
|
552
604
|
---
|
|
553
605
|
|
|
606
|
+
### `animation`
|
|
607
|
+
|
|
608
|
+
`animation` is the native CSS shorthand. Tasty parses tokens in its value and
|
|
609
|
+
tracks local `@keyframes` names referenced by it, so it needs no custom style
|
|
610
|
+
handler. Define a complete animation with the shorthand, using a configured
|
|
611
|
+
duration token where appropriate (for example,
|
|
612
|
+
`animation: 'pulse $animation-duration ease-in infinite'`).
|
|
613
|
+
|
|
614
|
+
Use `animationDuration`, `animationTimeline`, `animationRange`, and other CSS
|
|
615
|
+
longhands when changing just one part of an existing animation in a state or
|
|
616
|
+
component extension. Setting `animation` resets omitted parts, including its
|
|
617
|
+
timeline and range. The same principle applies to `transitionDuration` and
|
|
618
|
+
other transition longhands when a base `transition` is already defined.
|
|
619
|
+
`transitionBehavior` remains a separate CSS longhand; Tasty's semantic
|
|
620
|
+
`transition` syntax covers name, timing, easing, and delay.
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
554
624
|
## Scrollbar & Overflow
|
|
555
625
|
|
|
556
626
|
### `scrollbar`
|
package/docs/tasty-static.md
CHANGED
|
@@ -105,6 +105,8 @@ tastyStatic('body', {
|
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
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
|
+
|
|
108
110
|
---
|
|
109
111
|
|
|
110
112
|
## StaticStyle Object
|
|
@@ -299,6 +301,37 @@ public/tasty.css
|
|
|
299
301
|
|
|
300
302
|
---
|
|
301
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
|
+
|
|
302
335
|
## Vite Integration
|
|
303
336
|
|
|
304
337
|
```typescript
|
|
@@ -489,7 +522,7 @@ const button = tastyStatic({
|
|
|
489
522
|
radius: '1r',
|
|
490
523
|
fill: '#gray.20',
|
|
491
524
|
color: '#text',
|
|
492
|
-
transition: 'fill
|
|
525
|
+
transition: 'fill',
|
|
493
526
|
});
|
|
494
527
|
|
|
495
528
|
// Variants
|