@tenphi/tasty 0.0.0-snapshot.da430e1 → 0.0.0-snapshot.db2ef70

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 (130) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-Dc5zghyE.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-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/{collector-BevHh16N.js → chunks/collector-Cb8ah2JF.js} +10 -127
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.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-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.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-D2Pu7Xhy.js +502 -0
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.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-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  29. package/dist/{merge-styles-BKfagXfV.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-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/{css-writer-BDPmetHV.js → chunks/zero-engine-DcwaCvFs.js} +65 -145
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/{collector-CLVr5_p3.d.ts → collector-D2OT6I2G.d.ts} +6 -5
  36. package/dist/{config-YsxGv4tq.d.ts → config-C4ftFxgI.d.ts} +181 -77
  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-CBK778ne.d.ts → index-DxQNRj50.d.ts} +308 -255
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -922
  43. package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-D39qBtox.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 +17 -17
  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-Cd45t5NM.d.ts → types-CYQIhUg1.d.ts} +868 -820
  76. package/dist/zero/babel.d.ts +73 -2
  77. package/dist/zero/babel.js +81 -144
  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 +68 -33
  88. package/docs/comparison.md +9 -8
  89. package/docs/configuration.md +204 -70
  90. package/docs/debug.md +21 -8
  91. package/docs/design-system.md +117 -15
  92. package/docs/dsl.md +307 -117
  93. package/docs/getting-started.md +81 -22
  94. package/docs/injector.md +105 -67
  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 +76 -11
  100. package/docs/runtime-benchmarks.md +282 -110
  101. package/docs/ssr.md +226 -80
  102. package/docs/styles.md +169 -33
  103. package/docs/tasty-static.md +176 -58
  104. package/package.json +108 -44
  105. package/tasty.config.ts +1 -0
  106. package/dist/astro-C_by9qPq.js +0 -307
  107. package/dist/astro-C_by9qPq.js.map +0 -1
  108. package/dist/async-storage-DKK-wTD4.js +0 -44
  109. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  110. package/dist/babel-BUQGeOXA.d.ts +0 -83
  111. package/dist/collector-BevHh16N.js.map +0 -1
  112. package/dist/config-NcdqU9PC.js +0 -12269
  113. package/dist/config-NcdqU9PC.js.map +0 -1
  114. package/dist/context-CA8YKeMn.js +0 -24
  115. package/dist/context-CA8YKeMn.js.map +0 -1
  116. package/dist/core-D7s7u-k1.js +0 -1566
  117. package/dist/core-D7s7u-k1.js.map +0 -1
  118. package/dist/css-writer-BDPmetHV.js.map +0 -1
  119. package/dist/format-global-rules-DklyaXv-.js +0 -22
  120. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  121. package/dist/format-rules-BQCn7JZH.js +0 -130
  122. package/dist/format-rules-BQCn7JZH.js.map +0 -1
  123. package/dist/hydrate-C3cfqlaQ.js +0 -37
  124. package/dist/hydrate-C3cfqlaQ.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/keyframes-ByhOtsXB.js +0 -493
  127. package/dist/keyframes-ByhOtsXB.js.map +0 -1
  128. package/dist/merge-styles-BKfagXfV.js.map +0 -1
  129. package/dist/resolve-recipes-vvygrWLw.js +0 -144
  130. package/dist/resolve-recipes-vvygrWLw.js.map +0 -1
@@ -8,30 +8,38 @@ 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+ or 8 | Babel plugin (`@tenphi/tasty/babel-plugin`) |
25
+ | `@babel/helper-plugin-utils` | 7.24+ or 8 | Babel plugin |
26
+ | `@babel/types` | 7.24+ or 8 | Babel plugin |
27
+ | `jiti` | >= 2.6 | `configFile` only (Babel plugin and Next.js wrapper) |
28
+ | `babel-loader` | any (10+ with Babel 8) | Next.js wrapper (`@tenphi/tasty/zero/next`) |
29
+
30
+ Install the three Babel packages from the same major. Babel 8 itself needs Node 22.18+ or 24.11+, and `babel-loader` accepts it from version 10.
26
31
 
27
- All of these are declared as optional peer dependencies of `@tenphi/tasty`. Install only what your setup requires:
32
+ 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
33
 
29
34
  ```bash
30
- # For any Babel-based setup (Vite, custom Babel config, etc.)
35
+ # Any Babel-based setup (Vite, custom Babel config, etc.)
31
36
  pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types
32
37
 
33
- # For Next.js with TypeScript config file
34
- pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types jiti
38
+ # Next.js
39
+ pnpm add -D @babel/core @babel/helper-plugin-utils @babel/types babel-loader
40
+
41
+ # Either, with configFile
42
+ pnpm add -D jiti
35
43
  ```
36
44
 
37
45
  ---
@@ -52,13 +60,15 @@ const button = tastyStatic({
52
60
  radius: '1r',
53
61
  });
54
62
 
55
- // Use in JSX - works via toString() coercion
56
- <button className={button}>Click me</button>
63
+ // Use in JSX
64
+ <button className={button.className}>Click me</button>;
57
65
 
58
- // Or access className explicitly
59
- <button className={button.className}>Click me</button>
66
+ // toString() returns the class name, for template strings and plain JS
67
+ element.className = `${button} is-active`;
60
68
  ```
61
69
 
70
+ In TSX, pass `button.className`: React types `className` as `string`, so passing the `StaticStyle` object fails type-checking even though it works at runtime.
71
+
62
72
  ---
63
73
 
64
74
  ## API Reference
@@ -105,6 +115,8 @@ tastyStatic('body', {
105
115
  });
106
116
  ```
107
117
 
118
+ 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)`.
119
+
108
120
  ---
109
121
 
110
122
  ## StaticStyle Object
@@ -166,7 +178,7 @@ module.exports = {
166
178
  | -------------------------- | ------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
167
179
  | `output` | `string` | `'tasty.css'` | Path for generated CSS file |
168
180
  | `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. |
181
+ | `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
182
  | `config` | `TastyZeroConfig \| () => TastyZeroConfig` | `{}` | Inline config object or factory function. Takes precedence over `configFile`. |
171
183
  | `configDeps` | `string[]` | `[]` | Absolute file paths that affect config (for cache invalidation) |
172
184
  | `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 +190,8 @@ module.exports = {
178
190
  | `config.keyframes` | `Record<string, KeyframesSteps>` | — | Global `@keyframes` definitions available to all `tastyStatic` calls |
179
191
  | `config.fontFaces` | `Record<string, FontFaceInput>` | — | Global `@font-face` definitions |
180
192
  | `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' }` |
193
+ | `config.properties` | `Record<string, PropertyDefinition>` | — | Global `@property` definitions, written with Tasty's [default properties](dsl.md#default-properties) |
194
+ | `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
195
  | `config.functions` | `Record<string, FunctionDefinition \| Function>` | — | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
183
196
  | `config.polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills. `functions: true` inlines `@function` calls into plain CSS at build time |
184
197
  | `config.plugins` | `TastyPlugin[]` | — | Plugins that extend tasty with custom functions, units, states, and handlers |
@@ -242,7 +255,7 @@ const card = tastyStatic({
242
255
  color: '#text',
243
256
  });
244
257
 
245
- <div className={card}>Styled card</div>;
258
+ <div className={card.className}>Styled card</div>;
246
259
  ```
247
260
 
248
261
  ---
@@ -279,12 +292,12 @@ export default withTastyZero({
279
292
 
280
293
  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
294
 
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.
295
+ 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
296
 
284
- **Requirements**: `babel-loader` must be installed in your project:
297
+ **Requirements**: `babel-loader` must be installed in your project (see [Requirements](#requirements)):
285
298
 
286
299
  ```bash
287
- pnpm add babel-loader
300
+ pnpm add -D babel-loader
288
301
  ```
289
302
 
290
303
  ### CSS Injection
@@ -299,34 +312,107 @@ public/tasty.css
299
312
 
300
313
  ---
301
314
 
315
+ ## Programmatic API
316
+
317
+ `@tenphi/tasty/zero` turns styles into CSS in Node without Babel or React — for build scripts, or CSS shipped to other frameworks:
318
+
319
+ ```ts
320
+ import {
321
+ configure,
322
+ extractStylesForSelector,
323
+ extractStylesWithChunks,
324
+ } from '@tenphi/tasty/zero';
325
+
326
+ configure({
327
+ units: { u: 'var(--unit)' },
328
+ states: { '@dark': '@root(schema=dark)' },
329
+ });
330
+
331
+ extractStylesForSelector('.card', { padding: '2u', fill: '#surface' }).css;
332
+ // → '.card { padding: calc(2 * var(--unit)); background-color: … }'
333
+
334
+ extractStylesWithChunks({ display: 'flex', gap: '1u' });
335
+ // → [{ className: 'ts…', css: '.ts….ts… { … }' }]
336
+ ```
337
+
338
+ `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)`.
339
+
340
+ `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.
341
+
342
+ 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.
343
+
344
+ `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.
345
+
346
+ `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:
347
+
348
+ ```ts
349
+ import { extractStylesForSelector, mergeStyles } from '@tenphi/tasty/zero';
350
+
351
+ const styles = mergeStyles(checkboxStyles, {
352
+ Indicator: { radius: '0.5r' },
353
+ });
354
+
355
+ extractStylesForSelector('.checkbox', styles).css;
356
+ ```
357
+
358
+ 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:
359
+
360
+ ```ts
361
+ import {
362
+ createCSSWriter,
363
+ extractConfigProperties,
364
+ extractStylesWithChunks,
365
+ } from '@tenphi/tasty/zero';
366
+
367
+ const writer = createCSSWriter('dist/tasty.css', { devMode: true });
368
+
369
+ for (const prop of extractConfigProperties()) {
370
+ writer.add(`@property:${prop.name}`, prop.css);
371
+ }
372
+
373
+ for (const chunk of extractStylesWithChunks({ display: 'flex', gap: '1u' })) {
374
+ writer.add(chunk.className, chunk.css, 'src/card.ts'); // source is a devMode comment
375
+ }
376
+
377
+ writer.write(); // also: has(key), getCSS(), clear(), getOutputPath()
378
+ ```
379
+
380
+ ---
381
+
302
382
  ## Vite Integration
303
383
 
384
+ `@vitejs/plugin-react` 6 no longer runs Babel; add it with `@rolldown/plugin-babel` (`pnpm add -D @rolldown/plugin-babel`):
385
+
304
386
  ```typescript
305
387
  // vite.config.ts
306
388
  import { defineConfig } from 'vite';
307
389
  import react from '@vitejs/plugin-react';
390
+ import babel from '@rolldown/plugin-babel';
308
391
 
309
392
  export default defineConfig({
310
393
  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
- },
394
+ react(),
395
+ babel({
396
+ plugins: [
397
+ [
398
+ '@tenphi/tasty/babel-plugin',
399
+ {
400
+ output: 'src/tasty.css',
401
+ config: {
402
+ states: { '@mobile': '@media(w < 768px)' },
321
403
  },
322
- ],
404
+ },
323
405
  ],
324
- },
406
+ ],
325
407
  }),
326
408
  ],
327
409
  });
328
410
  ```
329
411
 
412
+ With `@vitejs/plugin-react` 5 or older, pass the same `plugins` array to `react({ babel: { plugins } })` instead.
413
+
414
+ 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.
415
+
330
416
  ---
331
417
 
332
418
  ## Build Transformation
@@ -344,44 +430,67 @@ const button = tastyStatic({
344
430
 
345
431
  tastyStatic('.heading', { preset: 'h1' });
346
432
 
347
- export const Button = () => <button className={button}>Click</button>;
433
+ export const Button = () => <button className={button.className}>Click</button>;
348
434
  ```
349
435
 
350
436
  ### After (Production Build)
351
437
 
352
438
  ```tsx
439
+ import './tasty.css';
440
+
353
441
  const button = {
354
- className: 'ts3f2a1b ts8c4d2e',
442
+ className: 'ts3f783b ts070801',
355
443
  styles: { padding: '2x 4x', fill: '#purple', color: '#white' },
356
444
  toString() {
357
445
  return this.className;
358
446
  },
359
447
  };
360
448
 
361
- export const Button = () => <button className={button}>Click</button>;
449
+ export const Button = () => <button className={button.className}>Click</button>;
362
450
  ```
363
451
 
452
+ The `@tenphi/tasty/static` import becomes an import of the generated file (relative to the source file), and the selector-mode call is removed.
453
+
364
454
  ### Generated CSS (tasty.css)
365
455
 
366
456
  ```css
367
457
  /* Generated by @tenphi/tasty/zero - DO NOT EDIT */
368
458
 
369
- .ts3f2a1b.ts3f2a1b {
370
- padding: 16px 32px;
459
+ @property --tasty-second-fill-color {
460
+ syntax: '<color>';
461
+ inherits: false;
462
+ initial-value: transparent;
371
463
  }
372
464
 
373
- .ts8c4d2e.ts8c4d2e {
374
- background: #9370db;
375
- color: #fff;
465
+ @property --current-color {
466
+ syntax: '<color>';
467
+ inherits: true;
468
+ initial-value: currentcolor;
376
469
  }
377
470
 
378
- .heading.heading {
379
- font-size: 2.5rem;
380
- font-weight: 700;
381
- line-height: 1.2;
471
+ /* …the rest of Tasty's default @property rules (--white-color, --border-color, --gap, --transition, …), then config.properties */
472
+
473
+ .ts3f783b.ts3f783b {
474
+ color: var(--white-color);
475
+ --current-color: var(--white-color);
476
+ }
477
+
478
+ .ts3f783b.ts3f783b {
479
+ background-color: var(--purple-color);
480
+ }
481
+
482
+ .ts070801.ts070801 {
483
+ padding: 16px 32px;
484
+ }
485
+
486
+ .heading {
487
+ font-size: var(--h1-font-size, var(--default-font-size));
488
+ /* …line-height, letter-spacing, font-weight, and the rest of the h1 preset */
382
489
  }
383
490
  ```
384
491
 
492
+ 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.
493
+
385
494
  ---
386
495
 
387
496
  ## Inject Mode
@@ -452,22 +561,29 @@ tastyStatic('.heading', { preset: 'h1' });
452
561
  ```tsx
453
562
  import { injectCSS as _$i } from '@tenphi/tasty/static/inject';
454
563
 
564
+ _$i(
565
+ '@property',
566
+ '@property --tasty-second-fill-color { … }\n@property --current-color { … }\n…',
567
+ );
568
+
455
569
  const button =
456
570
  (_$i(
457
- 'ts3f2a1b ts8c4d2e',
458
- '.ts3f2a1b.ts3f2a1b{padding:16px 32px}\n.ts8c4d2e.ts8c4d2e{background:#9370db}',
571
+ 'tsa903d6 ts070801',
572
+ '.tsa903d6.tsa903d6 { background-color: var(--purple-color); }\n.ts070801.ts070801 { padding: 16px 32px; }',
459
573
  ),
460
574
  {
461
- className: 'ts3f2a1b ts8c4d2e',
575
+ className: 'tsa903d6 ts070801',
462
576
  styles: { padding: '2x 4x', fill: '#purple' },
463
577
  toString() {
464
578
  return this.className;
465
579
  },
466
580
  });
467
581
 
468
- _$i('.heading', '.heading{font-size:2.5rem;font-weight:700;line-height:1.2}');
582
+ _$i('.heading', '.heading { font-size: var(--h1-font-size, …); … }');
469
583
  ```
470
584
 
585
+ 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.
586
+
471
587
  ### Dev Mode / HMR
472
588
 
473
589
  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 +605,7 @@ const button = tastyStatic({
489
605
  radius: '1r',
490
606
  fill: '#gray.20',
491
607
  color: '#text',
492
- transition: 'fill 0.15s',
608
+ transition: 'fill',
493
609
  });
494
610
 
495
611
  // Variants
@@ -525,7 +641,7 @@ const card = tastyStatic({
525
641
 
526
642
  ## Extending Style Types (TypeScript)
527
643
 
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.
644
+ If you add custom style properties, use module augmentation so `tastyStatic` recognizes them too. See [TypeScript](configuration.md#typescript) in the configuration docs.
529
645
 
530
646
  ---
531
647
 
@@ -547,10 +663,12 @@ const card = tastyStatic({
547
663
  });
548
664
 
549
665
  <div
550
- className={card}
551
- style={{
552
- '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
553
- }}
666
+ className={card.className}
667
+ style={
668
+ {
669
+ '--card-bg': isActive ? 'var(--purple-color)' : 'var(--white-color)',
670
+ } as React.CSSProperties
671
+ }
554
672
  />;
555
673
  ```
556
674
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/tasty",
3
- "version": "0.0.0-snapshot.da430e1",
3
+ "version": "0.0.0-snapshot.db2ef70",
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",
@@ -116,16 +126,21 @@
116
126
  "format": "prettier --write \"src/**/*.{ts,tsx}\"",
117
127
  "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
118
128
  "size": "size-limit",
119
- "bench": "vitest bench --project node",
120
- "bench:browser": "vitest bench --project browser",
129
+ "bench": "vitest bench --project \"node (bench)\"",
130
+ "bench:browser": "vitest bench --project \"browser (chromium) (bench)\"",
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",
123
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",
124
136
  "prepublishOnly": "pnpm run build",
125
137
  "changeset": "changeset",
126
138
  "version": "changeset version",
127
139
  "release": "changeset publish",
128
140
  "knip": "knip",
141
+ "check:build": "node scripts/check-built-entries.mjs",
142
+ "check:react-compat": "node scripts/check-react-compat.mjs",
143
+ "check:babel-compat": "node scripts/check-babel-compat.mjs",
129
144
  "check:test-only": "node scripts/check-test-only-code.mjs",
130
145
  "hygiene": "pnpm lint && pnpm format:check && pnpm typecheck",
131
146
  "hygiene:fix": "pnpm lint:fix && pnpm format && pnpm typecheck"
@@ -152,9 +167,9 @@
152
167
  },
153
168
  "homepage": "https://github.com/tenphi/tasty#readme",
154
169
  "peerDependencies": {
155
- "@babel/core": "^7.24.0",
156
- "@babel/helper-plugin-utils": "^7.24.0",
157
- "@babel/types": "^7.24.0",
170
+ "@babel/core": "^7.24.0 || ^8.0.0",
171
+ "@babel/helper-plugin-utils": "^7.24.0 || ^8.0.0",
172
+ "@babel/types": "^7.24.0 || ^8.0.0",
158
173
  "jiti": "^2.6.1",
159
174
  "next": ">=14.0.0",
160
175
  "react": "^18.0.0 || ^19.0.0"
@@ -183,59 +198,82 @@
183
198
  "csstype": "^3.1.0"
184
199
  },
185
200
  "devDependencies": {
186
- "@astrojs/react": "^4.4.2",
187
- "@babel/core": "^7.24.0",
188
- "@babel/helper-plugin-utils": "^7.24.0",
189
- "@babel/types": "^7.24.0",
190
- "@changesets/changelog-github": "^0.7.0",
191
- "@changesets/cli": "^2.29.8",
201
+ "@astrojs/react": "^7.0.1",
202
+ "@babel/core": "^8.0.6",
203
+ "@babel/helper-plugin-utils": "^8.0.1",
204
+ "@babel/types": "^8.0.6",
205
+ "@changesets/changelog-github": "^1.0.1",
206
+ "@changesets/cli": "^3.0.3",
192
207
  "@eslint/js": "^10.0.1",
193
- "@size-limit/esbuild": "^12.0.0",
194
- "@size-limit/file": "^12.0.0",
195
- "@tenphi/eslint-plugin-tasty": "^1.0.4",
196
- "@testing-library/jest-dom": "^6.9.1",
197
- "@testing-library/react": "^16.3.2",
198
- "@types/babel__core": "^7.20.5",
199
- "@types/babel__helper-plugin-utils": "^7.10.3",
200
- "@types/node": "^25.3.2",
201
- "@types/react": "^19.0.0",
202
- "@types/react-dom": "^19.0.0",
203
- "@vitest/browser-playwright": "^4.1.10",
204
- "astro": "^5.18.2",
205
- "eslint": "^10.0.0",
208
+ "@size-limit/esbuild": "^14.1.0",
209
+ "@size-limit/file": "^14.1.0",
210
+ "@tenphi/eslint-plugin-tasty": "^1.15.0",
211
+ "@testing-library/jest-dom": "^7.0.1",
212
+ "@testing-library/react": "^16.3.3",
213
+ "@types/node": "^24.19.1",
214
+ "@types/react": "^19.3.0",
215
+ "@types/react-dom": "^19.3.0",
216
+ "@vitest/browser-playwright": "^5.0.3",
217
+ "astro": "^7.3.6",
218
+ "esbuild": "^0.28.2",
219
+ "eslint": "^10.12.0",
206
220
  "eslint-config-prettier": "^10.1.8",
207
- "jiti": "^2.6.1",
208
- "knip": "^5.61.3",
209
- "next": "^16.0.0",
210
- "playwright": "^1.62.1",
211
- "prettier": "^3.8.1",
212
- "react": "^19.0.0",
213
- "react-dom": "^19.0.0",
214
- "size-limit": "^12.0.0",
215
- "tsdown": "^0.22.0",
216
- "typescript": "^6.0.2",
217
- "typescript-eslint": "^8.56.0",
218
- "vitest": "^4.1.10"
221
+ "jiti": "^2.7.0",
222
+ "knip": "^6.40.0",
223
+ "next": "^16.4.0",
224
+ "playwright": "^1.63.0",
225
+ "prettier": "^3.9.9",
226
+ "react": "^19.3.0",
227
+ "react-dom": "^19.3.0",
228
+ "size-limit": "^14.1.0",
229
+ "tsdown": "^0.23.0",
230
+ "typescript": "^6.0.3",
231
+ "typescript-eslint": "^8.71.1",
232
+ "vitest": "^5.0.3"
219
233
  },
220
- "packageManager": "pnpm@11.24.0",
234
+ "packageManager": "pnpm@11.27.1",
221
235
  "size-limit": [
222
236
  {
223
237
  "name": "main (import *)",
224
238
  "path": "dist/index.js",
225
239
  "import": "*",
226
- "limit": "56.6 kB"
240
+ "limit": "62.08 kB"
241
+ },
242
+ {
243
+ "name": "main (tasty)",
244
+ "path": "dist/index.js",
245
+ "import": "{ tasty }",
246
+ "limit": "54.99 kB"
247
+ },
248
+ {
249
+ "name": "main (StyleParser)",
250
+ "path": "dist/index.js",
251
+ "import": "{ StyleParser }",
252
+ "limit": "8 kB"
253
+ },
254
+ {
255
+ "name": "main (parseColor)",
256
+ "path": "dist/index.js",
257
+ "import": "{ parseColor }",
258
+ "limit": "8.67 kB"
259
+ },
260
+ {
261
+ "name": "main (useRawCSS)",
262
+ "path": "dist/index.js",
263
+ "import": "{ useRawCSS }",
264
+ "limit": "33.63 kB"
227
265
  },
228
266
  {
229
267
  "name": "core (import *)",
230
268
  "path": "dist/core/index.js",
231
269
  "import": "*",
232
- "limit": "53.65 kB"
270
+ "limit": "57.38 kB"
233
271
  },
234
272
  {
235
273
  "name": "static",
236
274
  "path": "dist/static/index.js",
237
275
  "import": "*",
238
- "limit": "16.8 kB"
276
+ "limit": "1.08 kB"
239
277
  },
240
278
  {
241
279
  "name": "zero",
@@ -246,7 +284,7 @@
246
284
  "path",
247
285
  "crypto"
248
286
  ],
249
- "limit": "31.25 kB"
287
+ "limit": "41.3 kB"
250
288
  },
251
289
  {
252
290
  "name": "babel-plugin",
@@ -255,9 +293,35 @@
255
293
  "ignore": [
256
294
  "fs",
257
295
  "path",
258
- "crypto"
296
+ "crypto",
297
+ "node:module",
298
+ "node:path"
299
+ ],
300
+ "limit": "45.95 kB"
301
+ },
302
+ {
303
+ "name": "astro client",
304
+ "path": "dist/ssr/astro-client.js",
305
+ "import": "*",
306
+ "limit": "0.5 kB"
307
+ },
308
+ {
309
+ "name": "ssr client",
310
+ "path": "dist/ssr/client.js",
311
+ "import": "{ hydrateTastyClasses }",
312
+ "limit": "0.5 kB"
313
+ },
314
+ {
315
+ "name": "Next.js config",
316
+ "path": "dist/ssr/next-config.js",
317
+ "import": "{ withTastyNext }",
318
+ "ignore": [
319
+ "node:crypto",
320
+ "node:fs",
321
+ "node:module",
322
+ "node:path"
259
323
  ],
260
- "limit": "49.35 kB"
324
+ "limit": "41.48 kB"
261
325
  }
262
326
  ]
263
327
  }
package/tasty.config.ts CHANGED
@@ -11,6 +11,7 @@ export default {
11
11
  '$transition',
12
12
  '$sharp-radius',
13
13
  '$bold-font-weight',
14
+ '$icon-size',
14
15
  ],
15
16
  styles: ['viewTransitionName'],
16
17
  // This repo imports its own API relatively, so the plugin's default