@tenphi/tasty 0.0.0-snapshot.eef6937 → 0.0.0-snapshot.ef55afd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-BKDTT4--.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BZMGNb_I.js +60 -0
  6. package/dist/chunks/build-config-BZMGNb_I.js.map +1 -0
  7. package/dist/{collector-C6TtL8HJ.js → chunks/collector-CPiziP8g.js} +10 -127
  8. package/dist/chunks/collector-CPiziP8g.js.map +1 -0
  9. package/dist/chunks/config-engine-WjJNcZ-C.js +272 -0
  10. package/dist/chunks/config-engine-WjJNcZ-C.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BmiT9P4x.js +910 -0
  14. package/dist/chunks/css-definitions-BmiT9P4x.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-B2zJjf2X.js +502 -0
  18. package/dist/chunks/debug-B2zJjf2X.js.map +1 -0
  19. package/dist/chunks/dsl-BKtRQR_O.js +1399 -0
  20. package/dist/chunks/dsl-BKtRQR_O.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B5Xn6hwM.js +689 -0
  24. package/dist/chunks/react-runtime-B5Xn6hwM.js.map +1 -0
  25. package/dist/chunks/runtime-engine-fT0CiDZU.js +2432 -0
  26. package/dist/chunks/runtime-engine-fT0CiDZU.js.map +1 -0
  27. package/dist/chunks/runtime-state-D-UAVby0.js +152 -0
  28. package/dist/chunks/runtime-state-D-UAVby0.js.map +1 -0
  29. package/dist/{merge-styles-DuoZEsm9.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-CguKjOki.js +5576 -0
  32. package/dist/chunks/style-engine-CguKjOki.js.map +1 -0
  33. package/dist/{css-writer-Bgowobbx.js → chunks/zero-engine-CP7TnjOl.js} +65 -145
  34. package/dist/chunks/zero-engine-CP7TnjOl.js.map +1 -0
  35. package/dist/{collector-BTVXj2hS.d.ts → collector-CTU-nl0g.d.ts} +6 -5
  36. package/dist/{config-LfIDmVHx.d.ts → config-CcxqSZI2.d.ts} +45 -40
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-Bm9ltvdH.d.ts → index-C5hbbo0t.d.ts} +272 -243
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -922
  43. package/dist/{merge-styles-BcLl1u_d.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
  48. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  49. package/dist/ssr/astro-middleware-extract.d.ts +1 -2
  50. package/dist/ssr/astro-middleware-extract.js +1 -1
  51. package/dist/ssr/astro-middleware-static.d.ts +1 -2
  52. package/dist/ssr/astro-middleware-static.js +1 -12
  53. package/dist/ssr/astro-middleware-static.js.map +1 -1
  54. package/dist/ssr/astro-middleware.d.ts +1 -2
  55. package/dist/ssr/astro-middleware.js +1 -13
  56. package/dist/ssr/astro-middleware.js.map +1 -1
  57. package/dist/ssr/astro.d.ts +13 -18
  58. package/dist/ssr/astro.js +220 -1
  59. package/dist/ssr/astro.js.map +1 -0
  60. package/dist/ssr/client.d.ts +2 -0
  61. package/dist/ssr/client.js +2 -0
  62. package/dist/ssr/index.d.ts +5 -25
  63. package/dist/ssr/index.js +5 -5
  64. package/dist/ssr/index.js.map +1 -1
  65. package/dist/ssr/next-config.d.ts +64 -0
  66. package/dist/ssr/next-config.js +123 -0
  67. package/dist/ssr/next-config.js.map +1 -0
  68. package/dist/ssr/next.d.ts +9 -8
  69. package/dist/ssr/next.js +29 -43
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/static/index.d.ts +8 -9
  72. package/dist/static/index.js +4 -22
  73. package/dist/static/index.js.map +1 -1
  74. package/dist/static/inject.d.ts +1 -2
  75. package/dist/{index-BmogEzTo.d.ts → types-DJEM_BOJ.d.ts} +852 -860
  76. package/dist/zero/babel.d.ts +67 -2
  77. package/dist/zero/babel.js +77 -140
  78. package/dist/zero/babel.js.map +1 -1
  79. package/dist/zero/index.d.ts +63 -8
  80. package/dist/zero/index.js +25 -2
  81. package/dist/zero/index.js.map +1 -0
  82. package/dist/zero/next.d.ts +4 -5
  83. package/dist/zero/next.js +3 -38
  84. package/dist/zero/next.js.map +1 -1
  85. package/docs/README.md +4 -1
  86. package/docs/adoption.md +25 -17
  87. package/docs/ai-agents.md +67 -33
  88. package/docs/comparison.md +9 -8
  89. package/docs/configuration.md +192 -60
  90. package/docs/debug.md +18 -7
  91. package/docs/design-system.md +117 -15
  92. package/docs/dsl.md +235 -82
  93. package/docs/getting-started.md +81 -22
  94. package/docs/injector.md +41 -40
  95. package/docs/methodology.md +48 -23
  96. package/docs/migration-v3.md +3 -3
  97. package/docs/pipeline.md +54 -27
  98. package/docs/plugins.md +22 -42
  99. package/docs/react-api.md +74 -9
  100. package/docs/runtime-benchmarks.md +257 -47
  101. package/docs/ssr.md +202 -74
  102. package/docs/styles.md +121 -31
  103. package/docs/tasty-static.md +174 -58
  104. package/package.json +103 -37
  105. package/dist/astro-Bql0oF64.js +0 -321
  106. package/dist/astro-Bql0oF64.js.map +0 -1
  107. package/dist/async-storage-DKK-wTD4.js +0 -44
  108. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  109. package/dist/babel-DWCsafYw.d.ts +0 -83
  110. package/dist/collector-C6TtL8HJ.js.map +0 -1
  111. package/dist/config-B3gPdCqd.js +0 -12421
  112. package/dist/config-B3gPdCqd.js.map +0 -1
  113. package/dist/context-CA8YKeMn.js +0 -24
  114. package/dist/context-CA8YKeMn.js.map +0 -1
  115. package/dist/core-Bq7w2kti.js +0 -1686
  116. package/dist/core-Bq7w2kti.js.map +0 -1
  117. package/dist/css-writer-Bgowobbx.js.map +0 -1
  118. package/dist/format-global-rules-DklyaXv-.js +0 -22
  119. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  120. package/dist/format-rules-rCZ37rqY.js +0 -130
  121. package/dist/format-rules-rCZ37rqY.js.map +0 -1
  122. package/dist/hydrate-CNOmZprz.js +0 -37
  123. package/dist/hydrate-CNOmZprz.js.map +0 -1
  124. package/dist/index.js.map +0 -1
  125. package/dist/keyframes-DE-OE76F.js +0 -535
  126. package/dist/keyframes-DE-OE76F.js.map +0 -1
  127. package/dist/merge-styles-DuoZEsm9.js.map +0 -1
  128. package/dist/resolve-recipes-H9NqOQuP.js +0 -144
  129. package/dist/resolve-recipes-H9NqOQuP.js.map +0 -1
@@ -8,30 +8,36 @@ Choose `tastyStatic` specifically when styles must be generated during the build
8
8
 
9
9
  ## When to Use
10
10
 
11
- - **Static site generation (SSG)** — Pre-render all styles at build time
12
- - **No-JavaScript websites** — CSS works without any JS runtime
13
- - **Performance-critical pages** — CSS extracted before the application renders
14
- - **Landing pages** — Minimal bundle size with pre-generated CSS
11
+ - **CSS that must exist before anything renders** — static sites, landing pages, and HTML served from a CDN get one stylesheet generated at build time
12
+ - **No React at runtime** — `tastyStatic` returns class names, so plain DOM code or any templating that sets `class` can use them; the [Programmatic API](#programmatic-api) covers frameworks Babel does not process
13
+ - **Class-name objects instead of components** — extend them with `tastyStatic(base, styles)` and pass them wherever a `className` goes
14
+ - **Self-contained packages** — [inject mode](#inject-mode) embeds the CSS in the JavaScript, so consumers have no stylesheet to wire up
15
+
16
+ If the styles depend on props, keep `tasty()`: rendered only on the server, it also ships no styling runtime (see [Server-Side Rendering](ssr.md)).
15
17
 
16
18
  ## Requirements
17
19
 
18
20
  Build-time extraction is part of the main `@tenphi/tasty` package but requires additional peer dependencies depending on your setup:
19
21
 
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 |
22
+ | Dependency | Version | Required for |
23
+ | ---------------------------- | ------- | ---------------------------------------------------- |
24
+ | `@babel/core` | >= 7.24 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
25
+ | `@babel/helper-plugin-utils` | >= 7.24 | Babel plugin |
26
+ | `@babel/types` | >= 7.24 | Babel plugin |
27
+ | `jiti` | >= 2.6 | `configFile` only (Babel plugin and Next.js wrapper) |
28
+ | `babel-loader` | any | Next.js wrapper (`@tenphi/tasty/zero/next`) |
26
29
 
27
- All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
30
+ The Babel packages and `jiti` are optional peer dependencies of `@tenphi/tasty`; `babel-loader` is resolved from your project. `jiti` is loaded only to read a `configFile`, so a setup that passes `config` directly does not need it; without it, `configFile` fails with an error that says to install it. Install what your setup requires:
28
31
 
29
32
  ```bash
30
- # For any Babel-based setup (Vite, custom Babel config, etc.)
33
+ # Any Babel-based setup (Vite, custom Babel config, etc.)
31
34
  pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
32
35
 
33
- # For Next.js with TypeScript config file
34
- pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
36
+ # Next.js
37
+ pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types babel-loader
38
+
39
+ # Either, with configFile
40
+ pnpm add -D jiti
35
41
  ```
36
42
 
37
43
  ---
@@ -52,13 +58,15 @@ const button = tastyStatic({
52
58
  radius: '1r',
53
59
  });
54
60
 
55
- // Use in JSX - works via toString() coercion
56
- <button className={button}>Click me</button>
61
+ // Use in JSX
62
+ <button className={button.className}>Click me</button>;
57
63
 
58
- // Or access className explicitly
59
- <button className={button.className}>Click me</button>
64
+ // toString() returns the class name, for template strings and plain JS
65
+ element.className = `${button} is-active`;
60
66
  ```
61
67
 
68
+ In TSX, pass `button.className`: React types `className` as `string`, so passing the `StaticStyle` object fails type-checking even though it works at runtime.
69
+
62
70
  ---
63
71
 
64
72
  ## API Reference
@@ -105,6 +113,8 @@ tastyStatic('body', {
105
113
  });
106
114
  ```
107
115
 
116
+ 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)`.
117
+
108
118
  ---
109
119
 
110
120
  ## StaticStyle Object
@@ -166,7 +176,7 @@ module.exports = {
166
176
  | -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
167
177
  | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
168
178
  | `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. |
179
+ | `configFile` | `string` | — | Absolute path to a TS/JS module that default-exports a `TastyZeroConfig` object. JSON-serializable alternative to `config` — required for Turbopack. Loaded with the optional `jiti` peer. |
170
180
  | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
171
181
  | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
172
182
  | `injectImport` | `boolean` | `true` | Replace `@tenphi/tasty/static` imports with an import of the generated CSS file. Set to `false` to manage CSS imports manually. |
@@ -178,7 +188,8 @@ module.exports = {
178
188
  | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
179
189
  | `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
180
190
  | `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' }` |
191
+ | `config.properties` | `Record<string, PropertyDefinition>` | — | Global `@property` definitions, written with Tasty's [default properties](dsl.md#default-properties) |
192
+ | `config.units` | `Record<string, string \| UnitHandler>` | — | Custom units for the style parser (merged with built-ins). E.g. `{ u: 'var(--u)' }` makes `2u` compile to `calc(2 * var(--u))`. Native CSS units need no entry |
182
193
  | `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
183
194
  | `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
184
195
  | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
@@ -242,7 +253,7 @@ const card = tastyStatic({
242
253
  color: '#text',
243
254
  });
244
255
 
245
- <div className={card}>Styled card</div>;
256
+ <div className={card.className}>Styled card</div>;
246
257
  ```
247
258
 
248
259
  ---
@@ -279,12 +290,12 @@ export default withTastyZero({
279
290
 
280
291
  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
292
 
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.
293
+ The `configFile` option is key for Turbopack — it passes a file path (JSON-serializable) instead of a function, and the Babel plugin loads the config internally via `jiti`, which must be installed.
283
294
 
284
- **Requirements**: `babel-loader` must be installed in your project:
295
+ **Requirements**: `babel-loader` must be installed in your project (see [Requirements](#requirements)):
285
296
 
286
297
  ```bash
287
- pnpm add babel-loader
298
+ pnpm add -D babel-loader
288
299
  ```
289
300
 
290
301
  ### CSS Injection
@@ -299,34 +310,107 @@ public/tasty.css
299
310
 
300
311
  ---
301
312
 
313
+ ## Programmatic API
314
+
315
+ `@tenphi/tasty/zero` turns styles into CSS in Node without Babel or React — for build scripts, or CSS shipped to other frameworks:
316
+
317
+ ```ts
318
+ import {
319
+ configure,
320
+ extractStylesForSelector,
321
+ extractStylesWithChunks,
322
+ } from '@tenphi/tasty/zero';
323
+
324
+ configure({
325
+ units: { u: 'var(--unit)' },
326
+ states: { '@dark': '@root(schema=dark)' },
327
+ });
328
+
329
+ extractStylesForSelector('.card', { padding: '2u', fill: '#surface' }).css;
330
+ // → '.card { padding: calc(2 * var(--unit)); background-color: … }'
331
+
332
+ extractStylesWithChunks({ display: 'flex', gap: '1u' });
333
+ // → [{ className: 'ts…', css: '.ts….ts… { … }' }]
334
+ ```
335
+
336
+ `configure()` takes the same options as the Babel plugin's `config` (see [Plugin Options](#plugin-options)) and replaces the previous configuration on each call; `resetConfig()` returns to the defaults. Options that shape the extracted rules apply — `states`, `units`, parse `functions`, `handlers`, `replaceTokens`, `recipes`, `plugins`, `namePrefix`. Definitions that become at-rules or global CSS of their own are not emitted with the rules: `tokens`, `globalStyles`, `fontFaces`, `counterStyles`, `properties` and `$$` `@function` definitions. Render tokens and global styles with `extractStylesForSelector(':root', tokens)` and `extractStylesForSelector(selector, styles)`.
337
+
338
+ `extractConfigProperties()` returns the `@property` rules the Babel plugin writes at the top of its output: Tasty's [default set](dsl.md#default-properties) (`#border`, `#outline`, `$gap`, `$radius`, `$transition`, …) overlaid with the configured `properties`, or with the `properties` map you pass it. Emit them once per stylesheet. Style handlers read several of these tokens with no fallback of their own (`border: true` reads `#border`, `transition` reads `$transition`), so without them those declarations resolve to nothing.
339
+
340
+ 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.
341
+
342
+ `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.
343
+
344
+ `mergeStyles()` merges style objects with the rules `tasty(Base, { styles })` extends by — state maps with and without a `''` key, `null`, `false`, `'@inherit'` and sub-elements (see [Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps)) — so a build script can layer overrides onto source styles before extracting them, without React:
345
+
346
+ ```ts
347
+ import { extractStylesForSelector, mergeStyles } from '@tenphi/tasty/zero';
348
+
349
+ const styles = mergeStyles(checkboxStyles, {
350
+ Indicator: { radius: '0.5r' },
351
+ });
352
+
353
+ extractStylesForSelector('.checkbox', styles).css;
354
+ ```
355
+
356
+ To write the results to a file the way the Babel plugin does, use `createCSSWriter()`. It deduplicates blocks by key and prepends the generated-file header:
357
+
358
+ ```ts
359
+ import {
360
+ createCSSWriter,
361
+ extractConfigProperties,
362
+ extractStylesWithChunks,
363
+ } from '@tenphi/tasty/zero';
364
+
365
+ const writer = createCSSWriter('dist/tasty.css', { devMode: true });
366
+
367
+ for (const prop of extractConfigProperties()) {
368
+ writer.add(`@property:${prop.name}`, prop.css);
369
+ }
370
+
371
+ for (const chunk of extractStylesWithChunks({ display: 'flex', gap: '1u' })) {
372
+ writer.add(chunk.className, chunk.css, 'src/card.ts'); // source is a devMode comment
373
+ }
374
+
375
+ writer.write(); // also: has(key), getCSS(), clear(), getOutputPath()
376
+ ```
377
+
378
+ ---
379
+
302
380
  ## Vite Integration
303
381
 
382
+ `@vitejs/plugin-react` 6 no longer runs Babel; add it with `@rolldown/plugin-babel` (`pnpm add -D @rolldown/plugin-babel`):
383
+
304
384
  ```typescript
305
385
  // vite.config.ts
306
386
  import { defineConfig } from 'vite';
307
387
  import react from '@vitejs/plugin-react';
388
+ import babel from '@rolldown/plugin-babel';
308
389
 
309
390
  export default defineConfig({
310
391
  plugins: [
311
- react({
312
- babel: {
313
- plugins: [
314
- [
315
- '@tenphi/tasty/babel-plugin',
316
- {
317
- output: 'public/tasty.css',
318
- config: {
319
- states: { '@mobile': '@media(w < 768px)' },
320
- },
392
+ react(),
393
+ babel({
394
+ plugins: [
395
+ [
396
+ '@tenphi/tasty/babel-plugin',
397
+ {
398
+ output: 'src/tasty.css',
399
+ config: {
400
+ states: { '@mobile': '@media(w < 768px)' },
321
401
  },
322
- ],
402
+ },
323
403
  ],
324
- },
404
+ ],
325
405
  }),
326
406
  ],
327
407
  });
328
408
  ```
329
409
 
410
+ With `@vitejs/plugin-react` 5 or older, pass the same `plugins` array to `react({ babel: { plugins } })` instead.
411
+
412
+ Keep `output` outside `public/`: the plugin replaces each `@tenphi/tasty/static` import with an import of the generated file, and Vite does not let JavaScript import files from `public/`. Vite then bundles the CSS like any other stylesheet.
413
+
330
414
  ---
331
415
 
332
416
  ## Build Transformation
@@ -344,44 +428,67 @@ const button = tastyStatic({
344
428
 
345
429
  tastyStatic('.heading', { preset: 'h1' });
346
430
 
347
- export const Button = () => <button className={button}>Click</button>;
431
+ export const Button = () => <button className={button.className}>Click</button>;
348
432
  ```
349
433
 
350
434
  ### After (Production Build)
351
435
 
352
436
  ```tsx
437
+ import './tasty.css';
438
+
353
439
  const button = {
354
- className: 'ts3f2a1b ts8c4d2e',
440
+ className: 'ts3f783b ts070801',
355
441
  styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
356
442
  toString() {
357
443
  return this.className;
358
444
  },
359
445
  };
360
446
 
361
- export const Button = () => <button className={button}>Click</button>;
447
+ export const Button = () => <button className={button.className}>Click</button>;
362
448
  ```
363
449
 
450
+ The `@tenphi/tasty/static` import becomes an import of the generated file (relative to the source file), and the selector-mode call is removed.
451
+
364
452
  ### Generated CSS (tasty.css)
365
453
 
366
454
  ```css
367
455
  /* Generated by @tenphi/tasty/zero - DO NOT EDIT */
368
456
 
369
- .ts3f2a1b.ts3f2a1b {
370
- padding: 16px 32px;
457
+ @property --tasty-second-fill-color {
458
+ syntax: '<color>';
459
+ inherits: false;
460
+ initial-value: transparent;
371
461
  }
372
462
 
373
- .ts8c4d2e.ts8c4d2e {
374
- background: #9370db;
375
- color: #fff;
463
+ @property --current-color {
464
+ syntax: '<color>';
465
+ inherits: true;
466
+ initial-value: currentcolor;
376
467
  }
377
468
 
378
- .heading.heading {
379
- font-size: 2.5rem;
380
- font-weight: 700;
381
- line-height: 1.2;
469
+ /* …the rest of Tasty's default @property rules (--white-color, --border-color, --gap, --transition, …), then config.properties */
470
+
471
+ .ts3f783b.ts3f783b {
472
+ color: var(--white-color);
473
+ --current-color: var(--white-color);
474
+ }
475
+
476
+ .ts3f783b.ts3f783b {
477
+ background-color: var(--purple-color);
478
+ }
479
+
480
+ .ts070801.ts070801 {
481
+ padding: 16px 32px;
482
+ }
483
+
484
+ .heading {
485
+ font-size: var(--h1-font-size, var(--default-font-size));
486
+ /* …line-height, letter-spacing, font-weight, and the rest of the h1 preset */
382
487
  }
383
488
  ```
384
489
 
490
+ The file starts with Tasty's [default `@property` rules](dsl.md#default-properties) and your `config.properties`, written once. Styles are split into chunks (here appearance and spacing), each with its own class. Color tokens compile to custom properties: `#purple` becomes `var(--purple-color)`. Define it in `config.tokens` and the plugin writes it to `:root` at the top of the same file. Units are literal (`2x` is `16px`). Selector-mode rules use the selector as written, without the doubled specificity of class rules.
491
+
385
492
  ---
386
493
 
387
494
  ## Inject Mode
@@ -452,22 +559,29 @@ tastyStatic('.heading', { preset: 'h1' });
452
559
  ```tsx
453
560
  import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
454
561
 
562
+ _$i(
563
+ '@property',
564
+ '@property --tasty-second-fill-color { … }\n@property --current-color { … }\n…',
565
+ );
566
+
455
567
  const button =
456
568
  (_$i(
457
- 'ts3f2a1b ts8c4d2e',
458
- '.ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}',
569
+ 'tsa903d6 ts070801',
570
+ '.tsa903d6.tsa903d6 { background-color: var(--purple-color); }\n.ts070801.ts070801 { padding: 16px 32px; }',
459
571
  ),
460
572
  {
461
- className: 'ts3f2a1b ts8c4d2e',
573
+ className: 'tsa903d6 ts070801',
462
574
  styles: { padding: '2x 4x', fill: '#purple' },
463
575
  toString() {
464
576
  return this.className;
465
577
  },
466
578
  });
467
579
 
468
- _$i('.heading', '.heading{font-size:2.5rem;font-weight:700;line-height:1.2}');
580
+ _$i('.heading', '.heading { font-size: var(--h1-font-size, …); … }');
469
581
  ```
470
582
 
583
+ Each file that calls `tastyStatic()` starts by injecting Tasty's default `@property` rules and your `config.properties` under the `@property` id. `injectCSS()` skips an id it has already injected, so the page gets them once.
584
+
471
585
  ### Dev Mode / HMR
472
586
 
473
587
  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.
@@ -489,7 +603,7 @@ const button = tastyStatic({
489
603
  radius: '1r',
490
604
  fill: '#gray.20',
491
605
  color: '#text',
492
- transition: 'fill 0.15s',
606
+ transition: 'fill',
493
607
  });
494
608
 
495
609
  // Variants
@@ -525,7 +639,7 @@ const card = tastyStatic({
525
639
 
526
640
  ## Extending Style Types (TypeScript)
527
641
 
528
- If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [Extending Style Types](configuration.md#extending-style-types-typescript) in the configuration docs.
642
+ If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [TypeScript](configuration.md#typescript) in the configuration docs.
529
643
 
530
644
  ---
531
645
 
@@ -547,10 +661,12 @@ const card = tastyStatic({
547
661
  });
548
662
 
549
663
  <div
550
- className={card}
551
- style={{
552
- '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
553
- }}
664
+ className={card.className}
665
+ style={
666
+ {
667
+ '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
668
+ } as React.CSSProperties
669
+ }
554
670
  />;
555
671
  ```
556
672
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/tasty",
3
- "version": "0.0.0-snapshot.eef6937",
3
+ "version": "0.0.0-snapshot.ef55afd",
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",
@@ -52,11 +52,21 @@
52
52
  "import": "./dist/ssr/next.js",
53
53
  "default": "./dist/ssr/next.js"
54
54
  },
55
+ "./ssr/next-config": {
56
+ "types": "./dist/ssr/next-config.d.ts",
57
+ "import": "./dist/ssr/next-config.js",
58
+ "default": "./dist/ssr/next-config.js"
59
+ },
55
60
  "./ssr/astro": {
56
61
  "types": "./dist/ssr/astro.d.ts",
57
62
  "import": "./dist/ssr/astro.js",
58
63
  "default": "./dist/ssr/astro.js"
59
64
  },
65
+ "./ssr/client": {
66
+ "types": "./dist/ssr/client.d.ts",
67
+ "import": "./dist/ssr/client.js",
68
+ "default": "./dist/ssr/client.js"
69
+ },
60
70
  "./ssr/astro-client": {
61
71
  "types": "./dist/ssr/astro-client.d.ts",
62
72
  "import": "./dist/ssr/astro-client.js",
@@ -120,11 +130,16 @@
120
130
  "bench:browser": "vitest bench --project browser",
121
131
  "bench:overhead": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-overhead.bench.tsx",
122
132
  "bench:injection": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-injection.bench.ts",
133
+ "bench:interaction": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-interaction.bench.tsx",
134
+ "bench:tree": "vitest bench --config vitest.production-browser-bench.config.ts src/tasty-tree.bench.tsx",
135
+ "bench:cold-start": "node scripts/cold-start/index.mjs",
123
136
  "prepublishOnly": "pnpm run build",
124
137
  "changeset": "changeset",
125
138
  "version": "changeset version",
126
139
  "release": "changeset publish",
127
140
  "knip": "knip",
141
+ "check:build": "node scripts/check-built-entries.mjs",
142
+ "check:react-compat": "node scripts/check-react-compat.mjs",
128
143
  "check:test-only": "node scripts/check-test-only-code.mjs",
129
144
  "hygiene": "pnpm lint && pnpm format:check && pnpm typecheck",
130
145
  "hygiene:fix": "pnpm lint:fix && pnpm format && pnpm typecheck"
@@ -182,59 +197,84 @@
182
197
  "csstype": "^3.1.0"
183
198
  },
184
199
  "devDependencies": {
185
- "@astrojs/react": "^4.4.2",
186
- "@babel/core": "^7.24.0",
187
- "@babel/helper-plugin-utils": "^7.24.0",
188
- "@babel/types": "^7.24.0",
189
- "@changesets/changelog-github": "^0.7.0",
190
- "@changesets/cli": "^2.29.8",
200
+ "@astrojs/react": "^7.0.0",
201
+ "@babel/core": "^8.0.6",
202
+ "@babel/helper-plugin-utils": "^8.0.1",
203
+ "@babel/types": "^8.0.6",
204
+ "@changesets/changelog-github": "^1.0.1",
205
+ "@changesets/cli": "^3.0.3",
191
206
  "@eslint/js": "^10.0.1",
192
- "@size-limit/esbuild": "^12.0.0",
193
- "@size-limit/file": "^12.0.0",
194
- "@tenphi/eslint-plugin-tasty": "^1.0.5",
195
- "@testing-library/jest-dom": "^6.9.1",
196
- "@testing-library/react": "^16.3.2",
207
+ "@size-limit/esbuild": "^14.0.0",
208
+ "@size-limit/file": "^14.0.0",
209
+ "@tenphi/eslint-plugin-tasty": "^1.7.3",
210
+ "@testing-library/jest-dom": "^7.0.1",
211
+ "@testing-library/react": "^16.3.3",
197
212
  "@types/babel__core": "^7.20.5",
198
213
  "@types/babel__helper-plugin-utils": "^7.10.3",
199
- "@types/node": "^24.13.3",
200
- "@types/react": "^19.0.0",
201
- "@types/react-dom": "^19.0.0",
202
- "@vitest/browser-playwright": "^4.1.10",
203
- "astro": "^5.18.2",
204
- "eslint": "^10.0.0",
214
+ "@types/node": "^24.13.6",
215
+ "@types/react": "^19.3.0",
216
+ "@types/react-dom": "^19.3.0",
217
+ "@vitest/browser-playwright": "^4.1.11",
218
+ "astro": "^7.3.4",
219
+ "esbuild": "^0.28.2",
220
+ "eslint": "^10.11.0",
205
221
  "eslint-config-prettier": "^10.1.8",
206
- "jiti": "^2.6.1",
207
- "knip": "^5.61.3",
208
- "next": "^16.0.0",
209
- "playwright": "^1.62.1",
210
- "prettier": "^3.9.6",
211
- "react": "^19.0.0",
212
- "react-dom": "^19.0.0",
213
- "size-limit": "^12.0.0",
214
- "tsdown": "^0.22.0",
215
- "typescript": "^6.0.2",
216
- "typescript-eslint": "^8.56.0",
217
- "vitest": "^4.1.10"
222
+ "jiti": "^2.7.0",
223
+ "knip": "^6.38.0",
224
+ "next": "^16.3.6",
225
+ "playwright": "^1.63.0",
226
+ "prettier": "^3.9.9",
227
+ "react": "^19.3.0",
228
+ "react-dom": "^19.3.0",
229
+ "size-limit": "^14.0.0",
230
+ "tsdown": "^0.23.0",
231
+ "typescript": "^6.0.3",
232
+ "typescript-eslint": "^8.70.1",
233
+ "vitest": "^4.1.11"
218
234
  },
219
- "packageManager": "pnpm@11.24.0",
235
+ "packageManager": "pnpm@11.27.1",
220
236
  "size-limit": [
221
237
  {
222
238
  "name": "main (import *)",
223
239
  "path": "dist/index.js",
224
240
  "import": "*",
225
- "limit": "57.5 kB"
241
+ "limit": "60.79 kB"
242
+ },
243
+ {
244
+ "name": "main (tasty)",
245
+ "path": "dist/index.js",
246
+ "import": "{ tasty }",
247
+ "limit": "53.84 kB"
248
+ },
249
+ {
250
+ "name": "main (StyleParser)",
251
+ "path": "dist/index.js",
252
+ "import": "{ StyleParser }",
253
+ "limit": "8 kB"
254
+ },
255
+ {
256
+ "name": "main (parseColor)",
257
+ "path": "dist/index.js",
258
+ "import": "{ parseColor }",
259
+ "limit": "8.67 kB"
260
+ },
261
+ {
262
+ "name": "main (useRawCSS)",
263
+ "path": "dist/index.js",
264
+ "import": "{ useRawCSS }",
265
+ "limit": "32.48 kB"
226
266
  },
227
267
  {
228
268
  "name": "core (import *)",
229
269
  "path": "dist/core/index.js",
230
270
  "import": "*",
231
- "limit": "54.5 kB"
271
+ "limit": "56.29 kB"
232
272
  },
233
273
  {
234
274
  "name": "static",
235
275
  "path": "dist/static/index.js",
236
276
  "import": "*",
237
- "limit": "16.8 kB"
277
+ "limit": "1.08 kB"
238
278
  },
239
279
  {
240
280
  "name": "zero",
@@ -245,7 +285,7 @@
245
285
  "path",
246
286
  "crypto"
247
287
  ],
248
- "limit": "31.25 kB"
288
+ "limit": "40.16 kB"
249
289
  },
250
290
  {
251
291
  "name": "babel-plugin",
@@ -254,9 +294,35 @@
254
294
  "ignore": [
255
295
  "fs",
256
296
  "path",
257
- "crypto"
297
+ "crypto",
298
+ "node:module",
299
+ "node:path"
300
+ ],
301
+ "limit": "44.79 kB"
302
+ },
303
+ {
304
+ "name": "astro client",
305
+ "path": "dist/ssr/astro-client.js",
306
+ "import": "*",
307
+ "limit": "0.5 kB"
308
+ },
309
+ {
310
+ "name": "ssr client",
311
+ "path": "dist/ssr/client.js",
312
+ "import": "{ hydrateTastyClasses }",
313
+ "limit": "0.5 kB"
314
+ },
315
+ {
316
+ "name": "Next.js config",
317
+ "path": "dist/ssr/next-config.js",
318
+ "import": "{ withTastyNext }",
319
+ "ignore": [
320
+ "node:crypto",
321
+ "node:fs",
322
+ "node:module",
323
+ "node:path"
258
324
  ],
259
- "limit": "49.6 kB"
325
+ "limit": "40.18 kB"
260
326
  }
261
327
  ]
262
328
  }