@tenphi/tasty 1.5.3 → 2.0.0

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 (83) hide show
  1. package/README.md +20 -15
  2. package/dist/compute-styles.js +13 -26
  3. package/dist/compute-styles.js.map +1 -1
  4. package/dist/config.d.ts +39 -1
  5. package/dist/config.js +64 -2
  6. package/dist/config.js.map +1 -1
  7. package/dist/core/index.d.ts +2 -2
  8. package/dist/core/index.js +1 -1
  9. package/dist/debug.js +4 -4
  10. package/dist/debug.js.map +1 -1
  11. package/dist/hooks/useCounterStyle.js +2 -1
  12. package/dist/hooks/useCounterStyle.js.map +1 -1
  13. package/dist/hooks/useGlobalStyles.js +2 -2
  14. package/dist/hooks/useKeyframes.js +2 -1
  15. package/dist/hooks/useKeyframes.js.map +1 -1
  16. package/dist/hooks/useRawCSS.js +1 -1
  17. package/dist/hooks/useStyles.d.ts +4 -4
  18. package/dist/hooks/useStyles.js +7 -5
  19. package/dist/hooks/useStyles.js.map +1 -1
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +1 -1
  22. package/dist/injector/index.js +1 -1
  23. package/dist/injector/index.js.map +1 -1
  24. package/dist/injector/injector.d.ts +5 -0
  25. package/dist/injector/injector.js +93 -6
  26. package/dist/injector/injector.js.map +1 -1
  27. package/dist/injector/sheet-manager.js +3 -2
  28. package/dist/injector/sheet-manager.js.map +1 -1
  29. package/dist/injector/types.d.ts +9 -2
  30. package/dist/pipeline/exclusive.js +57 -2
  31. package/dist/pipeline/exclusive.js.map +1 -1
  32. package/dist/pipeline/index.js +2 -2
  33. package/dist/pipeline/index.js.map +1 -1
  34. package/dist/pipeline/materialize.js +56 -2
  35. package/dist/pipeline/materialize.js.map +1 -1
  36. package/dist/pipeline/simplify.js +180 -5
  37. package/dist/pipeline/simplify.js.map +1 -1
  38. package/dist/plugins/types.d.ts +12 -1
  39. package/dist/rsc-cache.js +2 -4
  40. package/dist/rsc-cache.js.map +1 -1
  41. package/dist/ssr/astro-client.js +5 -10
  42. package/dist/ssr/astro-client.js.map +1 -1
  43. package/dist/ssr/astro.d.ts +4 -2
  44. package/dist/ssr/astro.js +4 -4
  45. package/dist/ssr/astro.js.map +1 -1
  46. package/dist/ssr/collector.d.ts +9 -13
  47. package/dist/ssr/collector.js +32 -16
  48. package/dist/ssr/collector.js.map +1 -1
  49. package/dist/ssr/context.js +16 -0
  50. package/dist/ssr/context.js.map +1 -0
  51. package/dist/ssr/hydrate.d.ts +20 -13
  52. package/dist/ssr/hydrate.js +24 -28
  53. package/dist/ssr/hydrate.js.map +1 -1
  54. package/dist/ssr/index.d.ts +3 -3
  55. package/dist/ssr/index.js +4 -4
  56. package/dist/ssr/index.js.map +1 -1
  57. package/dist/ssr/next.d.ts +7 -4
  58. package/dist/ssr/next.js +7 -6
  59. package/dist/ssr/next.js.map +1 -1
  60. package/dist/ssr/ssr-collector-ref.js +17 -1
  61. package/dist/ssr/ssr-collector-ref.js.map +1 -1
  62. package/dist/tasty.d.ts +1 -1
  63. package/dist/tasty.js +9 -4
  64. package/dist/tasty.js.map +1 -1
  65. package/dist/utils/typography.d.ts +21 -10
  66. package/dist/utils/typography.js +1 -1
  67. package/dist/utils/typography.js.map +1 -1
  68. package/dist/zero/babel.d.ts +7 -108
  69. package/dist/zero/babel.js +36 -12
  70. package/dist/zero/babel.js.map +1 -1
  71. package/docs/README.md +2 -2
  72. package/docs/adoption.md +5 -3
  73. package/docs/comparison.md +24 -25
  74. package/docs/configuration.md +69 -1
  75. package/docs/design-system.md +22 -10
  76. package/docs/dsl.md +3 -3
  77. package/docs/getting-started.md +10 -10
  78. package/docs/injector.md +2 -2
  79. package/docs/methodology.md +2 -2
  80. package/docs/{runtime.md → react-api.md} +5 -1
  81. package/docs/ssr.md +14 -7
  82. package/docs/tasty-static.md +14 -2
  83. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import { __require } from "../_virtual/_rolldown/runtime.js";
2
- import { configure, getGlobalConfigTokens, resetConfig } from "../config.js";
2
+ import { configure, getGlobalConfigTokens, getGlobalStyles, resetConfig } from "../config.js";
3
3
  import { mergeStyles } from "../utils/merge-styles.js";
4
4
  import { resolveRecipes } from "../utils/resolve-recipes.js";
5
5
  import { extractCounterStyleFromStyles, extractFontFaceFromStyles, extractKeyframesFromStyles, extractPropertiesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
@@ -87,10 +87,12 @@ var babel_default = declare((api, options) => {
87
87
  configure(resolvedConfig);
88
88
  const newWriter = new CSSWriter(outputPath, { devMode });
89
89
  if (mode !== "inject") {
90
- const tokenStyles = getGlobalConfigTokens();
91
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
92
- const result = extractStylesForSelector(":root", tokenStyles);
93
- if (result.css) newWriter.add(":root:tokens", result.css);
90
+ const tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
91
+ if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
92
+ const globalStyles = getGlobalStyles();
93
+ if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
94
+ const css = extractCSSFromStyles(selector, styles);
95
+ if (css) newWriter.add(`global:${selector}`, css);
94
96
  }
95
97
  }
96
98
  writerCache.set(resolvedOutputPath, {
@@ -106,11 +108,17 @@ var babel_default = declare((api, options) => {
106
108
  const config = entry.config;
107
109
  const devMode = config.devMode ?? false;
108
110
  let tokenCSS;
111
+ let globalStylesCSS;
109
112
  if (mode === "inject") {
110
- const tokenStyles = getGlobalConfigTokens();
111
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
112
- const result = extractStylesForSelector(":root", tokenStyles);
113
- if (result.css) tokenCSS = result.css;
113
+ tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
114
+ const gs = getGlobalStyles();
115
+ if (gs) {
116
+ globalStylesCSS = /* @__PURE__ */ new Map();
117
+ for (const [selector, styles] of Object.entries(gs)) {
118
+ const css = extractCSSFromStyles(selector, styles);
119
+ if (css) globalStylesCSS.set(selector, css);
120
+ }
121
+ if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
114
122
  }
115
123
  }
116
124
  return {
@@ -168,12 +176,20 @@ var babel_default = declare((api, options) => {
168
176
  },
169
177
  post() {
170
178
  if (mode === "inject") {
171
- if (this._fileAddedCSS && tokenCSS) {
179
+ if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
172
180
  const program = this.file.ast.program;
173
- const injectCall = createInjectCallAST(":root", tokenCSS);
174
181
  let insertIndex = 0;
175
182
  for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
176
- program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
183
+ if (tokenCSS) {
184
+ const injectCall = createInjectCallAST(":root", tokenCSS);
185
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
186
+ insertIndex++;
187
+ }
188
+ if (globalStylesCSS) for (const [selector, css] of globalStylesCSS) {
189
+ const injectCall = createInjectCallAST(selector, css);
190
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
191
+ insertIndex++;
192
+ }
177
193
  }
178
194
  return;
179
195
  }
@@ -318,6 +334,14 @@ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterSt
318
334
  }
319
335
  }
320
336
  /**
337
+ * Extract CSS for a selector from a styles/tokens object.
338
+ * Returns undefined when there are no styles or no CSS output.
339
+ */
340
+ function extractCSSFromStyles(selector, styles) {
341
+ if (!styles || Object.keys(styles).length === 0) return void 0;
342
+ return extractStylesForSelector(selector, styles).css || void 0;
343
+ }
344
+ /**
321
345
  * Create an `_$i(id, css)` call expression AST node for inject mode.
322
346
  */
323
347
  function createInjectCallAST(id, css) {
@@ -1 +1 @@
1
- {"version":3,"file":"babel.js","names":[],"sources":["../../src/zero/babel.ts"],"sourcesContent":["/**\n * Babel plugin for zero-runtime tasty static site generation.\n *\n * Transforms:\n * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }\n * - `tastyStatic(base, styles)` → StaticStyle object with merged styles\n * - `tastyStatic(selector, styles)` → removed entirely\n *\n * Usage:\n * ```javascript\n * // babel.config.js\n * module.exports = {\n * plugins: [\n * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]\n * ]\n * };\n * ```\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { declare } from '@babel/helper-plugin-utils';\nimport * as t from '@babel/types';\nimport { createJiti } from 'jiti';\n\nimport { configure, getGlobalConfigTokens, resetConfig } from '../config';\nimport type { RecipeStyles, Styles, ConfigTokens } from '../styles/types';\nimport { mergeStyles } from '../utils/merge-styles';\nimport { resolveRecipes } from '../utils/resolve-recipes';\nimport type { StyleHandlerDefinition } from '../utils/styles';\n\nimport { CSSWriter } from './css-writer';\nimport {\n extractCounterStyleFromStyles,\n extractFontFaceFromStyles,\n extractKeyframesFromStyles,\n extractPropertiesFromStyles,\n extractStylesForSelector,\n extractStylesWithChunks,\n} from './extractor';\nimport type {\n ExtractedChunk,\n ExtractedCounterStyle,\n ExtractedFontFace,\n ExtractedKeyframes,\n ExtractedProperty,\n} from './extractor';\n\nimport type { NodePath, PluginPass } from '@babel/core';\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n KeyframesSteps,\n} from '../injector/types';\nimport type { StyleDetails, UnitHandler } from '../parser/types';\nimport type { TastyPlugin } from '../plugins/types';\n\n/**\n * Build-time configuration for zero-runtime mode.\n * Subset of TastyConfig that applies at build time.\n */\nexport interface TastyZeroConfig {\n /**\n * Global predefined states for advanced state mapping.\n * Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }\n */\n states?: Record<string, string>;\n /**\n * Enable development mode features: source comments in generated CSS.\n * Default: false\n */\n devMode?: boolean;\n /**\n * Parser LRU cache size (default: 1000).\n * Larger values improve performance for builds with many unique style values.\n */\n parserCacheSize?: number;\n /**\n * Custom units for the style parser (merged with built-in units).\n * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.\n * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }\n */\n units?: Record<string, string | UnitHandler>;\n /**\n * Custom functions for the style parser (merged with existing).\n * Functions process parsed style groups and return CSS values.\n * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }\n */\n funcs?: Record<string, (groups: StyleDetails[]) => string>;\n /**\n * Plugins that extend tasty with custom functions, units, states, and handlers.\n * Plugins are processed in order, with later plugins overriding earlier ones.\n * @example\n * ```ts\n * import { okhslPlugin } from '@tenphi/tasty';\n *\n * // babel.config.js\n * module.exports = {\n * plugins: [\n * ['@tenphi/tasty/babel-plugin', {\n * config: { plugins: [okhslPlugin()] }\n * }]\n * ]\n * };\n * ```\n */\n plugins?: TastyPlugin[];\n /**\n * Global keyframes definitions for static extraction.\n * Keys are animation names, values are keyframes step definitions.\n * @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }\n */\n keyframes?: Record<string, KeyframesSteps>;\n /**\n * Global @font-face definitions for static extraction.\n * Keys are font-family names, values are descriptors or arrays of descriptors.\n */\n fontFace?: Record<string, FontFaceInput>;\n /**\n * Global @counter-style definitions for static extraction.\n * Keys are counter-style names, values are descriptor objects.\n */\n counterStyle?: Record<string, CounterStyleDescriptors>;\n /**\n * Custom style handlers that transform style properties into CSS declarations.\n * Handlers replace built-in handlers for the same style name.\n * @example\n * ```ts\n * handlers: {\n * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,\n * elevation: ({ elevation }) => ({\n * 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,\n * }),\n * }\n * ```\n */\n handlers?: Record<string, StyleHandlerDefinition>;\n /**\n * Design tokens injected as CSS custom properties on `:root`.\n * Values are parsed through the Tasty DSL. Supports state maps.\n * @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }\n */\n tokens?: ConfigTokens;\n /**\n * Predefined tokens replaced during style parsing (parse-time substitution).\n * Use `$name` for custom properties and `#name` for color tokens.\n * @example { $spacing: '2x', '#accent': '#purple' }\n */\n replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;\n /**\n * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.\n * Recipe values are flat tasty styles (no sub-element keys).\n * @example\n * ```ts\n * recipes: {\n * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },\n * elevated: { shadow: '2x 2x 4x #shadow' },\n * }\n * ```\n */\n recipes?: Record<string, RecipeStyles>;\n /**\n * Automatically infer and register CSS @property declarations from values.\n * @default true\n */\n autoPropertyTypes?: boolean;\n}\n\nexport interface TastyZeroBabelOptions {\n /** Output path for generated CSS (default: 'tasty.css') */\n output?: string;\n /**\n * Tasty configuration for build-time processing.\n * Can be a static object or a factory function that returns fresh config.\n * A factory is called on each plugin invocation, enabling hot reload\n * of config values that depend on external files (e.g. theme tokens).\n */\n config?: TastyZeroConfig | (() => TastyZeroConfig);\n /**\n * Absolute path to a TypeScript/JavaScript module that default-exports\n * a `TastyZeroConfig` object. The module is loaded via jiti on each\n * plugin invocation, enabling hot reload when the file changes.\n *\n * This option is JSON-serializable and is the primary way Turbopack\n * passes config to the Babel plugin (since Turbopack loader options\n * must be plain primitives/objects/arrays).\n *\n * When both `config` and `configFile` are set, `config` takes precedence.\n *\n * @example '/absolute/path/to/tasty-zero.config.ts'\n */\n configFile?: string;\n /**\n * Absolute file paths whose content affects the generated CSS.\n * When any of these files change, babel-loader invalidates its cache\n * and re-runs the plugin with fresh config values.\n *\n * Typically includes theme files that define Glaze palettes or token values.\n * Paths must be absolute (resolved by the Next.js wrapper).\n */\n configDeps?: string[];\n /**\n * Automatically replace `@tenphi/tasty/static` imports with an import\n * of the generated CSS file. This eliminates the need for users to\n * manually import the CSS in their app entry point.\n *\n * @default true\n */\n injectImport?: boolean;\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file and\n * the `@tenphi/tasty/static` import is rewritten to import that file.\n * - `'inject'`: CSS is embedded inline in the JS output and injected\n * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.\n * No CSS file is written. Each `tastyStatic` call becomes\n * self-contained. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` and `injectImport` are ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Registry to track StaticStyle objects by their variable names.\n * Used to resolve base styles when extending.\n */\ntype StaticStyleRegistry = Record<\n string,\n {\n styles: Styles;\n className: string;\n }\n>;\n\ninterface PluginState extends PluginPass {\n staticStyleRegistry: StaticStyleRegistry;\n /** Current source file path (for devMode source comments) */\n sourceFile?: string;\n /** Whether this file added CSS blocks to the writer (via tastyStatic calls) */\n _fileAddedCSS?: boolean;\n}\n\nfunction mtime(filePath: string): number | null {\n try {\n return fs.statSync(filePath).mtimeMs;\n } catch {\n return null;\n }\n}\n\nfunction clearRequireCacheTree(filePath: string): void {\n let resolved: string;\n\n try {\n resolved = require.resolve(filePath);\n } catch {\n return;\n }\n\n const mod = require.cache[resolved];\n\n if (!mod) return;\n\n const dir = resolved.substring(0, resolved.lastIndexOf('/'));\n\n if (mod.children) {\n for (const child of mod.children) {\n if (child.id.startsWith(dir) && !child.id.includes('node_modules')) {\n clearRequireCacheTree(child.id);\n }\n }\n }\n\n delete require.cache[resolved];\n}\n\n// Shared CSSWriter cache keyed by resolved output path.\n// Persists across per-file Babel invocations (Turbopack model) so that\n// CSS from all files accumulates instead of being overwritten.\ninterface WriterCacheEntry {\n writer: CSSWriter;\n configKey: string;\n registry: StaticStyleRegistry;\n config: TastyZeroConfig;\n}\nconst writerCache = new Map<string, WriterCacheEntry>();\n\n/** Clear the shared CSSWriter cache. Exposed for testing. */\nexport function clearWriterCache(): void {\n writerCache.clear();\n}\n\n// @ts-expect-error PluginState vs PluginPass type mismatch in @babel/helper-plugin-utils\nexport default declare<TastyZeroBabelOptions>((api, options) => {\n api.assertVersion(7);\n\n const mode = options.mode ?? 'file';\n const outputPath = options.output || 'tasty.css';\n const resolvedOutputPath = path.resolve(outputPath);\n const injectImport = options.injectImport ?? true;\n\n if (mode === 'file' && injectImport) {\n const dir = path.dirname(resolvedOutputPath);\n\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n if (!fs.existsSync(resolvedOutputPath)) {\n fs.writeFileSync(\n resolvedOutputPath,\n '/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\\n',\n );\n }\n }\n\n const configDeps = [\n ...(options.configFile ? [options.configFile] : []),\n ...(options.configDeps || []),\n ];\n\n // Fingerprint for config deps — used to detect config changes\n // and invalidate the shared CSSWriter cache.\n const configKey =\n configDeps.length > 0 ? configDeps.map(mtime).join(',') : '';\n\n // Register external dependencies for babel-loader cache invalidation.\n // When any configDeps file changes, babel-loader discards the cached\n // transform result and re-runs the plugin, picking up fresh config.\n if (configDeps.length > 0) {\n api.cache.using(() => configKey);\n\n for (const dep of configDeps) {\n try {\n (\n api as unknown as { addExternalDependency(path: string): void }\n ).addExternalDependency(dep);\n } catch {\n // addExternalDependency may not be available in all environments\n }\n }\n } else {\n api.cache.forever();\n }\n\n // When configDeps are set, clear the require cache so we get fresh values.\n if (configDeps.length > 0) {\n for (const dep of configDeps) {\n clearRequireCacheTree(dep);\n }\n }\n\n // Look up or create the shared CSSWriter for this output path.\n // When config deps change (different configKey), discard the old writer\n // and reset pipeline state so configure() can run again.\n const cached = writerCache.get(resolvedOutputPath);\n const configChanged = !cached || cached.configKey !== configKey;\n\n if (configChanged) {\n const configOption = options.config;\n let resolvedConfig: TastyZeroConfig;\n\n if (configOption) {\n resolvedConfig =\n typeof configOption === 'function' ? configOption() : configOption;\n } else if (options.configFile) {\n const jiti = createJiti(path.dirname(options.configFile), {\n moduleCache: false,\n });\n\n resolvedConfig = jiti(options.configFile) as TastyZeroConfig;\n } else {\n resolvedConfig = {};\n }\n\n const devMode = resolvedConfig.devMode ?? false;\n\n if (cached) {\n resetConfig();\n }\n\n configure(resolvedConfig);\n\n const newWriter = new CSSWriter(outputPath, { devMode });\n\n // Emit configured tokens as :root CSS custom properties (file mode only;\n // inject mode handles token injection per-file in the post hook).\n if (mode !== 'inject') {\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const result = extractStylesForSelector(':root', tokenStyles);\n if (result.css) {\n newWriter.add(':root:tokens', result.css);\n }\n }\n }\n\n writerCache.set(resolvedOutputPath, {\n writer: newWriter,\n configKey,\n registry: {},\n config: resolvedConfig,\n });\n }\n\n const entry = writerCache.get(resolvedOutputPath)!;\n const cssWriter = entry.writer;\n const globalRegistry = entry.registry;\n const config = entry.config;\n const devMode = config.devMode ?? false;\n\n // Precompute token CSS for inject mode\n let tokenCSS: string | undefined;\n if (mode === 'inject') {\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const result = extractStylesForSelector(':root', tokenStyles);\n if (result.css) {\n tokenCSS = result.css;\n }\n }\n }\n\n return {\n name: 'tasty-zero',\n\n pre(this: PluginState) {\n // Initialize per-file registry\n this.staticStyleRegistry = {};\n this._fileAddedCSS = false;\n // Extract source filename for devMode comments\n if (devMode && this.filename) {\n // Get relative path or just filename\n this.sourceFile = this.filename.split('/').pop() || this.filename;\n }\n },\n\n visitor: {\n ImportDeclaration(\n nodePath: NodePath<t.ImportDeclaration>,\n state: PluginState,\n ) {\n const source = nodePath.node.source.value;\n\n if (\n source === '@tenphi/tasty/static' ||\n source.endsWith('/tasty/static')\n ) {\n if (mode === 'inject') {\n nodePath.replaceWith(\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier('_$i'),\n t.identifier('injectCSS'),\n ),\n ],\n t.stringLiteral('@tenphi/tasty/static/inject'),\n ),\n );\n } else if (injectImport) {\n let importPath = resolvedOutputPath;\n\n if (state.filename) {\n const sourceDir = path.dirname(state.filename);\n importPath = path.relative(sourceDir, resolvedOutputPath);\n\n if (!importPath.startsWith('.')) {\n importPath = './' + importPath;\n }\n }\n\n nodePath.replaceWith(\n t.importDeclaration([], t.stringLiteral(importPath)),\n );\n } else {\n nodePath.remove();\n }\n }\n },\n\n // Transform tastyStatic() calls\n CallExpression(path: NodePath<t.CallExpression>, state: PluginState) {\n const callee = path.node.callee;\n\n // Match tastyStatic(...) calls\n if (!t.isIdentifier(callee, { name: 'tastyStatic' })) {\n return;\n }\n\n state._fileAddedCSS = true;\n\n const args = path.node.arguments;\n\n if (args.length === 0) {\n throw path.buildCodeFrameError(\n 'tastyStatic() requires at least one argument',\n );\n }\n\n const firstArg = args[0];\n\n if (t.isStringLiteral(firstArg)) {\n // Selector mode: tastyStatic(selector, styles)\n handleSelectorMode(\n path,\n args,\n cssWriter,\n mode,\n state.sourceFile,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else if (t.isObjectExpression(firstArg)) {\n // Styles mode: tastyStatic(styles)\n handleStylesMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n mode,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else if (t.isIdentifier(firstArg)) {\n // Extension mode: tastyStatic(base, styles)\n handleExtensionMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n mode,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else {\n throw path.buildCodeFrameError(\n 'tastyStatic() first argument must be an object (styles), ' +\n 'identifier (base StaticStyle), or string (selector)',\n );\n }\n },\n\n // Track variable declarations to register StaticStyle objects\n VariableDeclarator(\n path: NodePath<t.VariableDeclarator>,\n state: PluginState,\n ) {\n const init = path.node.init;\n const id = path.node.id;\n\n // Check if this is a StaticStyle object (has className and styles properties)\n if (\n t.isIdentifier(id) &&\n t.isObjectExpression(init) &&\n isStaticStyleObject(init)\n ) {\n const variableName = id.name;\n const styles = extractStylesFromStaticStyleObject(init, path);\n const className = extractClassNameFromStaticStyleObject(init);\n\n if (styles && className) {\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n },\n },\n\n post(this: PluginState) {\n if (mode === 'inject') {\n // In inject mode, inject token CSS as a top-level statement\n // when this file had tastyStatic calls and tokens are configured.\n if (this._fileAddedCSS && tokenCSS) {\n const program = this.file.ast.program;\n const injectCall = createInjectCallAST(':root', tokenCSS);\n\n // Find the position after the inject import to insert the token call\n let insertIndex = 0;\n for (let i = 0; i < program.body.length; i++) {\n if (t.isImportDeclaration(program.body[i])) {\n insertIndex = i + 1;\n }\n }\n\n program.body.splice(\n insertIndex,\n 0,\n t.expressionStatement(injectCall),\n );\n }\n return;\n }\n\n // Only write when this file contributed CSS (had tastyStatic calls).\n // In Turbopack, separate workers each have their own CSSWriter with\n // only token CSS. Letting those workers write would overwrite the\n // complete CSS produced by the worker that processed tastyStatic files.\n if (this._fileAddedCSS && cssWriter.size > 0) {\n cssWriter.write();\n }\n },\n };\n});\n\n/**\n * Check if an object expression looks like a StaticStyle object\n */\nfunction isStaticStyleObject(node: t.ObjectExpression): boolean {\n const hasClassName = node.properties.some(\n (p) =>\n t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'className' }),\n );\n const hasStyles = node.properties.some(\n (p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'styles' }),\n );\n return hasClassName && hasStyles;\n}\n\n/**\n * Extract styles object from a StaticStyle object expression\n */\nfunction extractStylesFromStaticStyleObject(\n node: t.ObjectExpression,\n path: NodePath,\n): Styles | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'styles' }) &&\n t.isObjectExpression(prop.value)\n ) {\n return evaluateObjectExpression(prop.value, path) as Styles;\n }\n }\n return null;\n}\n\n/**\n * Extract className from a StaticStyle object expression\n */\nfunction extractClassNameFromStaticStyleObject(\n node: t.ObjectExpression,\n): string | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'className' }) &&\n t.isStringLiteral(prop.value)\n ) {\n return prop.value.value;\n }\n }\n return null;\n}\n\n/**\n * Handle tastyStatic(styles) - returns StaticStyle object\n */\nfunction handleStylesMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n mode: 'file' | 'inject',\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n const stylesArg = args[0];\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(styles) argument must be a static object literal',\n );\n }\n\n // Evaluate styles object at build time\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Extract and add auto-inferred @property rules\n const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n styles,\n globalCounterStyle,\n );\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(styles);\n\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n const staticStyleObject = createStaticStyleAST(className, styles);\n\n if (mode === 'inject') {\n const allCSS = collectAllCSS(\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n );\n const injectCall = createInjectCallAST(className, allCSS);\n\n path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n state.sourceFile,\n );\n path.replaceWith(staticStyleObject);\n }\n\n registerIfVariableDeclaration(path, className, styles, state, globalRegistry);\n}\n\n/**\n * Handle tastyStatic(base, styles) - extends base with additional styles\n */\nfunction handleExtensionMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n mode: 'file' | 'inject',\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) requires two arguments',\n );\n }\n\n const baseArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isIdentifier(baseArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) first argument must be an identifier',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) second argument must be a static object literal',\n );\n }\n\n const baseName = baseArg.name;\n\n // Look up base styles in registry\n const baseEntry =\n state.staticStyleRegistry[baseName] || globalRegistry[baseName];\n\n if (!baseEntry) {\n throw path.buildCodeFrameError(\n `Cannot find base StaticStyle '${baseName}'. ` +\n 'Make sure it is defined before being extended.',\n );\n }\n\n // Evaluate override styles\n const overrideStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Merge styles using mergeStyles, then resolve recipes\n const mergedStyles = resolveRecipes(\n mergeStyles(baseEntry.styles, overrideStyles),\n );\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n mergedStyles,\n globalKeyframes,\n );\n\n // Extract auto-inferred @property rules\n const properties = extractPropertiesFromStyles(mergedStyles, {\n autoPropertyTypes,\n });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n mergedStyles,\n globalCounterStyle,\n );\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(mergedStyles);\n\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n const staticStyleObject = createStaticStyleAST(className, mergedStyles);\n\n if (mode === 'inject') {\n const allCSS = collectAllCSS(\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n );\n const injectCall = createInjectCallAST(className, allCSS);\n\n path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n state.sourceFile,\n );\n path.replaceWith(staticStyleObject);\n }\n\n registerIfVariableDeclaration(\n path,\n className,\n mergedStyles,\n state,\n globalRegistry,\n );\n}\n\n/**\n * Handle tastyStatic(selector, styles) - removes the call entirely\n */\nfunction handleSelectorMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n mode: 'file' | 'inject',\n sourceFile?: string,\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) requires two arguments',\n );\n }\n\n const selectorArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isStringLiteral(selectorArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) first argument must be a string literal',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) second argument must be a static object literal',\n );\n }\n\n const selector = selectorArg.value;\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Extract auto-inferred @property rules\n const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n styles,\n globalCounterStyle,\n );\n\n // Extract styles for selector\n const result = extractStylesForSelector(selector, styles);\n\n const selectorCSS =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(result.css, nameMap)\n : result.css;\n\n if (mode === 'inject') {\n const cssParts: string[] = [];\n\n for (const kf of keyframes) cssParts.push(kf.css);\n for (const prop of properties) cssParts.push(prop.css);\n for (const ff of fontFaces) cssParts.push(ff.css);\n for (const cs of counterStyles) cssParts.push(cs.css);\n cssParts.push(selectorCSS);\n\n const injectCall = createInjectCallAST(selector, cssParts.join('\\n'));\n\n const parent = path.parentPath;\n if (parent && t.isExpressionStatement(parent.node)) {\n parent.replaceWith(t.expressionStatement(injectCall));\n } else {\n path.replaceWith(injectCall);\n }\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n [],\n nameMap,\n sourceFile,\n );\n cssWriter.add(selector, selectorCSS, sourceFile);\n\n const parent = path.parentPath;\n if (parent && t.isExpressionStatement(parent.node)) {\n parent.remove();\n } else {\n path.replaceWith(t.identifier('undefined'));\n }\n }\n}\n\n/**\n * Collect all extracted CSS parts into a single string (for inject mode).\n */\nfunction collectAllCSS(\n keyframes: ExtractedKeyframes[],\n properties: ExtractedProperty[],\n fontFaces: ExtractedFontFace[],\n counterStyles: ExtractedCounterStyle[],\n chunks: ExtractedChunk[],\n nameMap: Map<string, string>,\n): string {\n const parts: string[] = [];\n\n for (const kf of keyframes) parts.push(kf.css);\n for (const prop of properties) parts.push(prop.css);\n for (const ff of fontFaces) parts.push(ff.css);\n for (const cs of counterStyles) parts.push(cs.css);\n\n for (const chunk of chunks) {\n parts.push(\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css,\n );\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Write all extracted CSS parts to a CSSWriter (for file mode).\n */\nfunction writeCSSToWriter(\n cssWriter: CSSWriter,\n keyframes: ExtractedKeyframes[],\n properties: ExtractedProperty[],\n fontFaces: ExtractedFontFace[],\n counterStyles: ExtractedCounterStyle[],\n chunks: ExtractedChunk[],\n nameMap: Map<string, string>,\n sourceFile?: string,\n): void {\n for (const kf of keyframes) {\n cssWriter.add(kf.css, kf.css, sourceFile);\n }\n for (const prop of properties) {\n cssWriter.add(prop.css, prop.css, sourceFile);\n }\n for (const ff of fontFaces) {\n cssWriter.add(ff.css, ff.css, sourceFile);\n }\n for (const cs of counterStyles) {\n cssWriter.add(cs.css, cs.css, sourceFile);\n }\n\n for (const chunk of chunks) {\n const css =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css;\n cssWriter.add(chunk.className, css, sourceFile);\n }\n}\n\n/**\n * Create an `_$i(id, css)` call expression AST node for inject mode.\n */\nfunction createInjectCallAST(id: string, css: string): t.CallExpression {\n return t.callExpression(t.identifier('_$i'), [\n t.stringLiteral(id),\n t.stringLiteral(css),\n ]);\n}\n\n/**\n * Create a StaticStyle object AST node\n */\nfunction createStaticStyleAST(\n className: string,\n styles: Styles,\n): t.ObjectExpression {\n return t.objectExpression([\n t.objectProperty(t.identifier('className'), t.stringLiteral(className)),\n t.objectProperty(t.identifier('styles'), valueToAST(styles)),\n t.objectMethod(\n 'method',\n t.identifier('toString'),\n [],\n t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.identifier('className')),\n ),\n ]),\n ),\n ]);\n}\n\n/**\n * Register a StaticStyle in the registry if it's being assigned to a variable\n */\nfunction registerIfVariableDeclaration(\n path: NodePath,\n className: string,\n styles: Styles,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n): void {\n const parent = path.parentPath;\n if (parent && t.isVariableDeclarator(parent.node)) {\n const id = parent.node.id;\n if (t.isIdentifier(id)) {\n const variableName = id.name;\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n}\n\n/**\n * Convert a JavaScript value to an AST node\n */\nfunction valueToAST(value: unknown): t.Expression {\n if (value === null) {\n return t.nullLiteral();\n }\n if (value === undefined) {\n return t.identifier('undefined');\n }\n if (typeof value === 'string') {\n return t.stringLiteral(value);\n }\n if (typeof value === 'number') {\n return t.numericLiteral(value);\n }\n if (typeof value === 'boolean') {\n return t.booleanLiteral(value);\n }\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(valueToAST));\n }\n if (typeof value === 'object') {\n const properties = Object.entries(value).map(([key, val]) =>\n t.objectProperty(\n /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? t.identifier(key)\n : t.stringLiteral(key),\n valueToAST(val),\n ),\n );\n return t.objectExpression(properties);\n }\n // Fallback for unsupported types\n return t.identifier('undefined');\n}\n\n/**\n * Evaluate an ObjectExpression to a plain JavaScript object.\n * Only supports static values that can be determined at build time.\n */\nfunction evaluateObjectExpression(\n node: t.ObjectExpression,\n path: NodePath,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const prop of node.properties) {\n if (t.isSpreadElement(prop)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic() - styles must be fully static',\n );\n }\n\n if (!t.isObjectProperty(prop)) {\n throw path.buildCodeFrameError(\n 'Only object properties are supported in tastyStatic()',\n );\n }\n\n // Get key\n let key: string;\n if (t.isIdentifier(prop.key)) {\n key = prop.key.name;\n } else if (t.isStringLiteral(prop.key)) {\n key = prop.key.value;\n } else {\n throw path.buildCodeFrameError(\n 'Dynamic property keys are not supported in tastyStatic()',\n );\n }\n\n // Get value\n const value = evaluateExpression(prop.value, path);\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Evaluate an expression to a JavaScript value.\n */\nfunction evaluateExpression(node: t.Node, path: NodePath): unknown {\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isNumericLiteral(node)) {\n return node.value;\n }\n\n if (t.isBooleanLiteral(node)) {\n return node.value;\n }\n\n if (t.isNullLiteral(node)) {\n return null;\n }\n\n if (t.isIdentifier(node, { name: 'undefined' })) {\n return undefined;\n }\n\n if (t.isArrayExpression(node)) {\n return node.elements.map((el) => {\n if (el === null) return null;\n if (t.isSpreadElement(el)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic()',\n );\n }\n return evaluateExpression(el, path);\n });\n }\n\n if (t.isObjectExpression(node)) {\n return evaluateObjectExpression(node, path);\n }\n\n if (t.isTemplateLiteral(node)) {\n // Only support template literals without expressions\n if (node.expressions.length > 0) {\n throw path.buildCodeFrameError(\n 'Template literals with expressions are not supported in tastyStatic()',\n );\n }\n return node.quasis.map((q) => q.value.cooked).join('');\n }\n\n if (t.isUnaryExpression(node, { operator: '-' })) {\n const arg = evaluateExpression(node.argument, path);\n if (typeof arg === 'number') {\n return -arg;\n }\n }\n\n throw path.buildCodeFrameError(\n `Dynamic expressions are not supported in tastyStatic() - got ${node.type}. ` +\n 'All values must be static literals.',\n );\n}\n\n/**\n * Replace animation names in CSS string.\n * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.\n */\nfunction replaceAnimationNamesInCSS(\n css: string,\n nameMap: Map<string, string>,\n): string {\n if (nameMap.size === 0) return css;\n\n // The CSS contains full rules like \".class { animation: name 1s; }\"\n // We need to replace animation names within declaration blocks\n return css.replace(\n /(animation(?:-name)?)\\s*:\\s*([^;}]+)/gi,\n (match, prop, value) => {\n let newValue = value;\n for (const [original, replacement] of nameMap) {\n // Word boundary replacement\n const pattern = new RegExp(`\\\\b${escapeRegex(original)}\\\\b`, 'g');\n newValue = newValue.replace(pattern, replacement);\n }\n return `${prop}: ${newValue}`;\n },\n );\n}\n\n/**\n * Escape special regex characters.\n */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuPA,SAAS,MAAM,UAAiC;AAC9C,KAAI;AACF,SAAO,GAAG,SAAS,SAAS,CAAC;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SAAO,KAAK,OAAO,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC,KAAK,GAAG;;AAGxD,KAAI,EAAE,kBAAkB,MAAM,EAAE,UAAU,KAAK,CAAC,EAAE;EAChD,MAAM,MAAM,mBAAmB,KAAK,UAAU,KAAK;AACnD,MAAI,OAAO,QAAQ,SACjB,QAAO,CAAC;;AAIZ,OAAM,KAAK,oBACT,gEAAgE,KAAK,KAAK,uCAE3E;;;;;;AAOH,SAAS,2BACP,KACA,SACQ;AACR,KAAI,QAAQ,SAAS,EAAG,QAAO;AAI/B,QAAO,IAAI,QACT,2CACC,OAAO,MAAM,UAAU;EACtB,IAAI,WAAW;AACf,OAAK,MAAM,CAAC,UAAU,gBAAgB,SAAS;GAE7C,MAAM,UAAU,IAAI,OAAO,MAAM,YAAY,SAAS,CAAC,MAAM,IAAI;AACjE,cAAW,SAAS,QAAQ,SAAS,YAAY;;AAEnD,SAAO,GAAG,KAAK,IAAI;GAEtB;;;;;AAMH,SAAS,YAAY,KAAqB;AACxC,QAAO,IAAI,QAAQ,uBAAuB,OAAO"}
1
+ {"version":3,"file":"babel.js","names":[],"sources":["../../src/zero/babel.ts"],"sourcesContent":["/**\n * Babel plugin for zero-runtime tasty static site generation.\n *\n * Transforms:\n * - `tastyStatic(styles)` → StaticStyle object { className, styles, toString() }\n * - `tastyStatic(base, styles)` → StaticStyle object with merged styles\n * - `tastyStatic(selector, styles)` → removed entirely\n *\n * Usage:\n * ```javascript\n * // babel.config.js\n * module.exports = {\n * plugins: [\n * ['@tenphi/tasty/babel-plugin', { output: 'public/tasty.css' }]\n * ]\n * };\n * ```\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { declare } from '@babel/helper-plugin-utils';\nimport * as t from '@babel/types';\nimport { createJiti } from 'jiti';\n\nimport {\n configure,\n getGlobalStyles,\n getGlobalConfigTokens,\n resetConfig,\n} from '../config';\nimport type { TastyConfig } from '../config';\nimport type { Styles, ConfigTokens } from '../styles/types';\nimport { mergeStyles } from '../utils/merge-styles';\nimport { resolveRecipes } from '../utils/resolve-recipes';\n\nimport { CSSWriter } from './css-writer';\nimport {\n extractCounterStyleFromStyles,\n extractFontFaceFromStyles,\n extractKeyframesFromStyles,\n extractPropertiesFromStyles,\n extractStylesForSelector,\n extractStylesWithChunks,\n} from './extractor';\nimport type {\n ExtractedChunk,\n ExtractedCounterStyle,\n ExtractedFontFace,\n ExtractedKeyframes,\n ExtractedProperty,\n} from './extractor';\n\nimport type { NodePath, PluginPass } from '@babel/core';\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n KeyframesSteps,\n} from '../injector/types';\n\n/**\n * Build-time configuration for zero-runtime mode.\n * Subset of TastyConfig excluding runtime-only DOM options\n * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)\n * and overriding `devMode` default to `false`.\n */\nexport type TastyZeroConfig = Omit<\n TastyConfig,\n 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'\n> & {\n /**\n * Enable development mode features: source comments in generated CSS.\n * @default false\n */\n devMode?: boolean;\n};\n\nexport interface TastyZeroBabelOptions {\n /** Output path for generated CSS (default: 'tasty.css') */\n output?: string;\n /**\n * Tasty configuration for build-time processing.\n * Can be a static object or a factory function that returns fresh config.\n * A factory is called on each plugin invocation, enabling hot reload\n * of config values that depend on external files (e.g. theme tokens).\n */\n config?: TastyZeroConfig | (() => TastyZeroConfig);\n /**\n * Absolute path to a TypeScript/JavaScript module that default-exports\n * a `TastyZeroConfig` object. The module is loaded via jiti on each\n * plugin invocation, enabling hot reload when the file changes.\n *\n * This option is JSON-serializable and is the primary way Turbopack\n * passes config to the Babel plugin (since Turbopack loader options\n * must be plain primitives/objects/arrays).\n *\n * When both `config` and `configFile` are set, `config` takes precedence.\n *\n * @example '/absolute/path/to/tasty-zero.config.ts'\n */\n configFile?: string;\n /**\n * Absolute file paths whose content affects the generated CSS.\n * When any of these files change, babel-loader invalidates its cache\n * and re-runs the plugin with fresh config values.\n *\n * Typically includes theme files that define Glaze palettes or token values.\n * Paths must be absolute (resolved by the Next.js wrapper).\n */\n configDeps?: string[];\n /**\n * Automatically replace `@tenphi/tasty/static` imports with an import\n * of the generated CSS file. This eliminates the need for users to\n * manually import the CSS in their app entry point.\n *\n * @default true\n */\n injectImport?: boolean;\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file and\n * the `@tenphi/tasty/static` import is rewritten to import that file.\n * - `'inject'`: CSS is embedded inline in the JS output and injected\n * at runtime via a tiny injector from `@tenphi/tasty/static/inject`.\n * No CSS file is written. Each `tastyStatic` call becomes\n * self-contained. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` and `injectImport` are ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Registry to track StaticStyle objects by their variable names.\n * Used to resolve base styles when extending.\n */\ntype StaticStyleRegistry = Record<\n string,\n {\n styles: Styles;\n className: string;\n }\n>;\n\ninterface PluginState extends PluginPass {\n staticStyleRegistry: StaticStyleRegistry;\n /** Current source file path (for devMode source comments) */\n sourceFile?: string;\n /** Whether this file added CSS blocks to the writer (via tastyStatic calls) */\n _fileAddedCSS?: boolean;\n}\n\nfunction mtime(filePath: string): number | null {\n try {\n return fs.statSync(filePath).mtimeMs;\n } catch {\n return null;\n }\n}\n\nfunction clearRequireCacheTree(filePath: string): void {\n let resolved: string;\n\n try {\n resolved = require.resolve(filePath);\n } catch {\n return;\n }\n\n const mod = require.cache[resolved];\n\n if (!mod) return;\n\n const dir = resolved.substring(0, resolved.lastIndexOf('/'));\n\n if (mod.children) {\n for (const child of mod.children) {\n if (child.id.startsWith(dir) && !child.id.includes('node_modules')) {\n clearRequireCacheTree(child.id);\n }\n }\n }\n\n delete require.cache[resolved];\n}\n\n// Shared CSSWriter cache keyed by resolved output path.\n// Persists across per-file Babel invocations (Turbopack model) so that\n// CSS from all files accumulates instead of being overwritten.\ninterface WriterCacheEntry {\n writer: CSSWriter;\n configKey: string;\n registry: StaticStyleRegistry;\n config: TastyZeroConfig;\n}\nconst writerCache = new Map<string, WriterCacheEntry>();\n\n/** Clear the shared CSSWriter cache. Exposed for testing. */\nexport function clearWriterCache(): void {\n writerCache.clear();\n}\n\n// @ts-expect-error PluginState vs PluginPass type mismatch in @babel/helper-plugin-utils\nexport default declare<TastyZeroBabelOptions>((api, options) => {\n api.assertVersion(7);\n\n const mode = options.mode ?? 'file';\n const outputPath = options.output || 'tasty.css';\n const resolvedOutputPath = path.resolve(outputPath);\n const injectImport = options.injectImport ?? true;\n\n if (mode === 'file' && injectImport) {\n const dir = path.dirname(resolvedOutputPath);\n\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n if (!fs.existsSync(resolvedOutputPath)) {\n fs.writeFileSync(\n resolvedOutputPath,\n '/* Generated by @tenphi/tasty/zero - DO NOT EDIT */\\n',\n );\n }\n }\n\n const configDeps = [\n ...(options.configFile ? [options.configFile] : []),\n ...(options.configDeps || []),\n ];\n\n // Fingerprint for config deps — used to detect config changes\n // and invalidate the shared CSSWriter cache.\n const configKey =\n configDeps.length > 0 ? configDeps.map(mtime).join(',') : '';\n\n // Register external dependencies for babel-loader cache invalidation.\n // When any configDeps file changes, babel-loader discards the cached\n // transform result and re-runs the plugin, picking up fresh config.\n if (configDeps.length > 0) {\n api.cache.using(() => configKey);\n\n for (const dep of configDeps) {\n try {\n (\n api as unknown as { addExternalDependency(path: string): void }\n ).addExternalDependency(dep);\n } catch {\n // addExternalDependency may not be available in all environments\n }\n }\n } else {\n api.cache.forever();\n }\n\n // When configDeps are set, clear the require cache so we get fresh values.\n if (configDeps.length > 0) {\n for (const dep of configDeps) {\n clearRequireCacheTree(dep);\n }\n }\n\n // Look up or create the shared CSSWriter for this output path.\n // When config deps change (different configKey), discard the old writer\n // and reset pipeline state so configure() can run again.\n const cached = writerCache.get(resolvedOutputPath);\n const configChanged = !cached || cached.configKey !== configKey;\n\n if (configChanged) {\n const configOption = options.config;\n let resolvedConfig: TastyZeroConfig;\n\n if (configOption) {\n resolvedConfig =\n typeof configOption === 'function' ? configOption() : configOption;\n } else if (options.configFile) {\n const jiti = createJiti(path.dirname(options.configFile), {\n moduleCache: false,\n });\n\n resolvedConfig = jiti(options.configFile) as TastyZeroConfig;\n } else {\n resolvedConfig = {};\n }\n\n const devMode = resolvedConfig.devMode ?? false;\n\n if (cached) {\n resetConfig();\n }\n\n configure(resolvedConfig);\n\n const newWriter = new CSSWriter(outputPath, { devMode });\n\n // Emit configured tokens and global styles (file mode only;\n // inject mode handles injection per-file in the post hook).\n if (mode !== 'inject') {\n const tokenCSS = extractCSSFromStyles(':root', getGlobalConfigTokens());\n if (tokenCSS) newWriter.add(':root:tokens', tokenCSS);\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n const css = extractCSSFromStyles(selector, styles);\n if (css) newWriter.add(`global:${selector}`, css);\n }\n }\n }\n\n writerCache.set(resolvedOutputPath, {\n writer: newWriter,\n configKey,\n registry: {},\n config: resolvedConfig,\n });\n }\n\n const entry = writerCache.get(resolvedOutputPath)!;\n const cssWriter = entry.writer;\n const globalRegistry = entry.registry;\n const config = entry.config;\n const devMode = config.devMode ?? false;\n\n // Precompute token CSS and global styles CSS for inject mode\n let tokenCSS: string | undefined;\n let globalStylesCSS: Map<string, string> | undefined;\n if (mode === 'inject') {\n tokenCSS = extractCSSFromStyles(':root', getGlobalConfigTokens());\n const gs = getGlobalStyles();\n if (gs) {\n globalStylesCSS = new Map();\n for (const [selector, styles] of Object.entries(gs)) {\n const css = extractCSSFromStyles(selector, styles);\n if (css) globalStylesCSS.set(selector, css);\n }\n if (globalStylesCSS.size === 0) globalStylesCSS = undefined;\n }\n }\n\n return {\n name: 'tasty-zero',\n\n pre(this: PluginState) {\n // Initialize per-file registry\n this.staticStyleRegistry = {};\n this._fileAddedCSS = false;\n // Extract source filename for devMode comments\n if (devMode && this.filename) {\n // Get relative path or just filename\n this.sourceFile = this.filename.split('/').pop() || this.filename;\n }\n },\n\n visitor: {\n ImportDeclaration(\n nodePath: NodePath<t.ImportDeclaration>,\n state: PluginState,\n ) {\n const source = nodePath.node.source.value;\n\n if (\n source === '@tenphi/tasty/static' ||\n source.endsWith('/tasty/static')\n ) {\n if (mode === 'inject') {\n nodePath.replaceWith(\n t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier('_$i'),\n t.identifier('injectCSS'),\n ),\n ],\n t.stringLiteral('@tenphi/tasty/static/inject'),\n ),\n );\n } else if (injectImport) {\n let importPath = resolvedOutputPath;\n\n if (state.filename) {\n const sourceDir = path.dirname(state.filename);\n importPath = path.relative(sourceDir, resolvedOutputPath);\n\n if (!importPath.startsWith('.')) {\n importPath = './' + importPath;\n }\n }\n\n nodePath.replaceWith(\n t.importDeclaration([], t.stringLiteral(importPath)),\n );\n } else {\n nodePath.remove();\n }\n }\n },\n\n // Transform tastyStatic() calls\n CallExpression(path: NodePath<t.CallExpression>, state: PluginState) {\n const callee = path.node.callee;\n\n // Match tastyStatic(...) calls\n if (!t.isIdentifier(callee, { name: 'tastyStatic' })) {\n return;\n }\n\n state._fileAddedCSS = true;\n\n const args = path.node.arguments;\n\n if (args.length === 0) {\n throw path.buildCodeFrameError(\n 'tastyStatic() requires at least one argument',\n );\n }\n\n const firstArg = args[0];\n\n if (t.isStringLiteral(firstArg)) {\n // Selector mode: tastyStatic(selector, styles)\n handleSelectorMode(\n path,\n args,\n cssWriter,\n mode,\n state.sourceFile,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else if (t.isObjectExpression(firstArg)) {\n // Styles mode: tastyStatic(styles)\n handleStylesMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n mode,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else if (t.isIdentifier(firstArg)) {\n // Extension mode: tastyStatic(base, styles)\n handleExtensionMode(\n path,\n args,\n cssWriter,\n state,\n globalRegistry,\n mode,\n config.keyframes,\n config.autoPropertyTypes,\n config.fontFace,\n config.counterStyle,\n );\n } else {\n throw path.buildCodeFrameError(\n 'tastyStatic() first argument must be an object (styles), ' +\n 'identifier (base StaticStyle), or string (selector)',\n );\n }\n },\n\n // Track variable declarations to register StaticStyle objects\n VariableDeclarator(\n path: NodePath<t.VariableDeclarator>,\n state: PluginState,\n ) {\n const init = path.node.init;\n const id = path.node.id;\n\n // Check if this is a StaticStyle object (has className and styles properties)\n if (\n t.isIdentifier(id) &&\n t.isObjectExpression(init) &&\n isStaticStyleObject(init)\n ) {\n const variableName = id.name;\n const styles = extractStylesFromStaticStyleObject(init, path);\n const className = extractClassNameFromStaticStyleObject(init);\n\n if (styles && className) {\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n },\n },\n\n post(this: PluginState) {\n if (mode === 'inject') {\n // In inject mode, inject token/global CSS as top-level statements\n // when this file had tastyStatic calls and config CSS exists.\n if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {\n const program = this.file.ast.program;\n\n // Find the position after the inject import\n let insertIndex = 0;\n for (let i = 0; i < program.body.length; i++) {\n if (t.isImportDeclaration(program.body[i])) {\n insertIndex = i + 1;\n }\n }\n\n if (tokenCSS) {\n const injectCall = createInjectCallAST(':root', tokenCSS);\n program.body.splice(\n insertIndex,\n 0,\n t.expressionStatement(injectCall),\n );\n insertIndex++;\n }\n\n if (globalStylesCSS) {\n for (const [selector, css] of globalStylesCSS) {\n const injectCall = createInjectCallAST(selector, css);\n program.body.splice(\n insertIndex,\n 0,\n t.expressionStatement(injectCall),\n );\n insertIndex++;\n }\n }\n }\n return;\n }\n\n // Only write when this file contributed CSS (had tastyStatic calls).\n // In Turbopack, separate workers each have their own CSSWriter with\n // only token CSS. Letting those workers write would overwrite the\n // complete CSS produced by the worker that processed tastyStatic files.\n if (this._fileAddedCSS && cssWriter.size > 0) {\n cssWriter.write();\n }\n },\n };\n});\n\n/**\n * Check if an object expression looks like a StaticStyle object\n */\nfunction isStaticStyleObject(node: t.ObjectExpression): boolean {\n const hasClassName = node.properties.some(\n (p) =>\n t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'className' }),\n );\n const hasStyles = node.properties.some(\n (p) => t.isObjectProperty(p) && t.isIdentifier(p.key, { name: 'styles' }),\n );\n return hasClassName && hasStyles;\n}\n\n/**\n * Extract styles object from a StaticStyle object expression\n */\nfunction extractStylesFromStaticStyleObject(\n node: t.ObjectExpression,\n path: NodePath,\n): Styles | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'styles' }) &&\n t.isObjectExpression(prop.value)\n ) {\n return evaluateObjectExpression(prop.value, path) as Styles;\n }\n }\n return null;\n}\n\n/**\n * Extract className from a StaticStyle object expression\n */\nfunction extractClassNameFromStaticStyleObject(\n node: t.ObjectExpression,\n): string | null {\n for (const prop of node.properties) {\n if (\n t.isObjectProperty(prop) &&\n t.isIdentifier(prop.key, { name: 'className' }) &&\n t.isStringLiteral(prop.value)\n ) {\n return prop.value.value;\n }\n }\n return null;\n}\n\n/**\n * Handle tastyStatic(styles) - returns StaticStyle object\n */\nfunction handleStylesMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n mode: 'file' | 'inject',\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n const stylesArg = args[0];\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(styles) argument must be a static object literal',\n );\n }\n\n // Evaluate styles object at build time\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Extract and add auto-inferred @property rules\n const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n styles,\n globalCounterStyle,\n );\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(styles);\n\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n const staticStyleObject = createStaticStyleAST(className, styles);\n\n if (mode === 'inject') {\n const allCSS = collectAllCSS(\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n );\n const injectCall = createInjectCallAST(className, allCSS);\n\n path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n state.sourceFile,\n );\n path.replaceWith(staticStyleObject);\n }\n\n registerIfVariableDeclaration(path, className, styles, state, globalRegistry);\n}\n\n/**\n * Handle tastyStatic(base, styles) - extends base with additional styles\n */\nfunction handleExtensionMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n mode: 'file' | 'inject',\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) requires two arguments',\n );\n }\n\n const baseArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isIdentifier(baseArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) first argument must be an identifier',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(base, styles) second argument must be a static object literal',\n );\n }\n\n const baseName = baseArg.name;\n\n // Look up base styles in registry\n const baseEntry =\n state.staticStyleRegistry[baseName] || globalRegistry[baseName];\n\n if (!baseEntry) {\n throw path.buildCodeFrameError(\n `Cannot find base StaticStyle '${baseName}'. ` +\n 'Make sure it is defined before being extended.',\n );\n }\n\n // Evaluate override styles\n const overrideStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Merge styles using mergeStyles, then resolve recipes\n const mergedStyles = resolveRecipes(\n mergeStyles(baseEntry.styles, overrideStyles),\n );\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n mergedStyles,\n globalKeyframes,\n );\n\n // Extract auto-inferred @property rules\n const properties = extractPropertiesFromStyles(mergedStyles, {\n autoPropertyTypes,\n });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(mergedStyles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n mergedStyles,\n globalCounterStyle,\n );\n\n // Extract styles with chunking\n const chunks = extractStylesWithChunks(mergedStyles);\n\n const className =\n chunks.length > 0 ? chunks.map((c) => c.className).join(' ') : '';\n const staticStyleObject = createStaticStyleAST(className, mergedStyles);\n\n if (mode === 'inject') {\n const allCSS = collectAllCSS(\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n );\n const injectCall = createInjectCallAST(className, allCSS);\n\n path.replaceWith(t.sequenceExpression([injectCall, staticStyleObject]));\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n chunks,\n nameMap,\n state.sourceFile,\n );\n path.replaceWith(staticStyleObject);\n }\n\n registerIfVariableDeclaration(\n path,\n className,\n mergedStyles,\n state,\n globalRegistry,\n );\n}\n\n/**\n * Handle tastyStatic(selector, styles) - removes the call entirely\n */\nfunction handleSelectorMode(\n path: NodePath<t.CallExpression>,\n args: t.CallExpression['arguments'],\n cssWriter: CSSWriter,\n mode: 'file' | 'inject',\n sourceFile?: string,\n globalKeyframes?: Record<string, KeyframesSteps>,\n autoPropertyTypes?: boolean,\n globalFontFace?: Record<string, FontFaceInput>,\n globalCounterStyle?: Record<string, CounterStyleDescriptors>,\n): void {\n if (args.length < 2) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) requires two arguments',\n );\n }\n\n const selectorArg = args[0];\n const stylesArg = args[1];\n\n if (!t.isStringLiteral(selectorArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) first argument must be a string literal',\n );\n }\n\n if (!t.isObjectExpression(stylesArg)) {\n throw path.buildCodeFrameError(\n 'tastyStatic(selector, styles) second argument must be a static object literal',\n );\n }\n\n const selector = selectorArg.value;\n const rawStyles = evaluateObjectExpression(stylesArg, path) as Styles;\n\n // Resolve recipes before extraction\n const styles = resolveRecipes(rawStyles);\n\n // Extract keyframes (deduplicated by content)\n const { keyframes, nameMap } = extractKeyframesFromStyles(\n styles,\n globalKeyframes,\n );\n\n // Extract auto-inferred @property rules\n const properties = extractPropertiesFromStyles(styles, { autoPropertyTypes });\n\n // Extract @font-face rules\n const fontFaces = extractFontFaceFromStyles(styles, globalFontFace);\n\n // Extract @counter-style rules\n const counterStyles = extractCounterStyleFromStyles(\n styles,\n globalCounterStyle,\n );\n\n // Extract styles for selector\n const result = extractStylesForSelector(selector, styles);\n\n const selectorCSS =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(result.css, nameMap)\n : result.css;\n\n if (mode === 'inject') {\n const cssParts: string[] = [];\n\n for (const kf of keyframes) cssParts.push(kf.css);\n for (const prop of properties) cssParts.push(prop.css);\n for (const ff of fontFaces) cssParts.push(ff.css);\n for (const cs of counterStyles) cssParts.push(cs.css);\n cssParts.push(selectorCSS);\n\n const injectCall = createInjectCallAST(selector, cssParts.join('\\n'));\n\n const parent = path.parentPath;\n if (parent && t.isExpressionStatement(parent.node)) {\n parent.replaceWith(t.expressionStatement(injectCall));\n } else {\n path.replaceWith(injectCall);\n }\n } else {\n writeCSSToWriter(\n cssWriter,\n keyframes,\n properties,\n fontFaces,\n counterStyles,\n [],\n nameMap,\n sourceFile,\n );\n cssWriter.add(selector, selectorCSS, sourceFile);\n\n const parent = path.parentPath;\n if (parent && t.isExpressionStatement(parent.node)) {\n parent.remove();\n } else {\n path.replaceWith(t.identifier('undefined'));\n }\n }\n}\n\n/**\n * Collect all extracted CSS parts into a single string (for inject mode).\n */\nfunction collectAllCSS(\n keyframes: ExtractedKeyframes[],\n properties: ExtractedProperty[],\n fontFaces: ExtractedFontFace[],\n counterStyles: ExtractedCounterStyle[],\n chunks: ExtractedChunk[],\n nameMap: Map<string, string>,\n): string {\n const parts: string[] = [];\n\n for (const kf of keyframes) parts.push(kf.css);\n for (const prop of properties) parts.push(prop.css);\n for (const ff of fontFaces) parts.push(ff.css);\n for (const cs of counterStyles) parts.push(cs.css);\n\n for (const chunk of chunks) {\n parts.push(\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css,\n );\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Write all extracted CSS parts to a CSSWriter (for file mode).\n */\nfunction writeCSSToWriter(\n cssWriter: CSSWriter,\n keyframes: ExtractedKeyframes[],\n properties: ExtractedProperty[],\n fontFaces: ExtractedFontFace[],\n counterStyles: ExtractedCounterStyle[],\n chunks: ExtractedChunk[],\n nameMap: Map<string, string>,\n sourceFile?: string,\n): void {\n for (const kf of keyframes) {\n cssWriter.add(kf.css, kf.css, sourceFile);\n }\n for (const prop of properties) {\n cssWriter.add(prop.css, prop.css, sourceFile);\n }\n for (const ff of fontFaces) {\n cssWriter.add(ff.css, ff.css, sourceFile);\n }\n for (const cs of counterStyles) {\n cssWriter.add(cs.css, cs.css, sourceFile);\n }\n\n for (const chunk of chunks) {\n const css =\n nameMap.size > 0\n ? replaceAnimationNamesInCSS(chunk.css, nameMap)\n : chunk.css;\n cssWriter.add(chunk.className, css, sourceFile);\n }\n}\n\n/**\n * Extract CSS for a selector from a styles/tokens object.\n * Returns undefined when there are no styles or no CSS output.\n */\nfunction extractCSSFromStyles(\n selector: string,\n styles: Styles | ConfigTokens | null,\n): string | undefined {\n if (!styles || Object.keys(styles).length === 0) return undefined;\n const result = extractStylesForSelector(selector, styles as Styles);\n return result.css || undefined;\n}\n\n/**\n * Create an `_$i(id, css)` call expression AST node for inject mode.\n */\nfunction createInjectCallAST(id: string, css: string): t.CallExpression {\n return t.callExpression(t.identifier('_$i'), [\n t.stringLiteral(id),\n t.stringLiteral(css),\n ]);\n}\n\n/**\n * Create a StaticStyle object AST node\n */\nfunction createStaticStyleAST(\n className: string,\n styles: Styles,\n): t.ObjectExpression {\n return t.objectExpression([\n t.objectProperty(t.identifier('className'), t.stringLiteral(className)),\n t.objectProperty(t.identifier('styles'), valueToAST(styles)),\n t.objectMethod(\n 'method',\n t.identifier('toString'),\n [],\n t.blockStatement([\n t.returnStatement(\n t.memberExpression(t.thisExpression(), t.identifier('className')),\n ),\n ]),\n ),\n ]);\n}\n\n/**\n * Register a StaticStyle in the registry if it's being assigned to a variable\n */\nfunction registerIfVariableDeclaration(\n path: NodePath,\n className: string,\n styles: Styles,\n state: PluginState,\n globalRegistry: StaticStyleRegistry,\n): void {\n const parent = path.parentPath;\n if (parent && t.isVariableDeclarator(parent.node)) {\n const id = parent.node.id;\n if (t.isIdentifier(id)) {\n const variableName = id.name;\n state.staticStyleRegistry[variableName] = { styles, className };\n globalRegistry[variableName] = { styles, className };\n }\n }\n}\n\n/**\n * Convert a JavaScript value to an AST node\n */\nfunction valueToAST(value: unknown): t.Expression {\n if (value === null) {\n return t.nullLiteral();\n }\n if (value === undefined) {\n return t.identifier('undefined');\n }\n if (typeof value === 'string') {\n return t.stringLiteral(value);\n }\n if (typeof value === 'number') {\n return t.numericLiteral(value);\n }\n if (typeof value === 'boolean') {\n return t.booleanLiteral(value);\n }\n if (Array.isArray(value)) {\n return t.arrayExpression(value.map(valueToAST));\n }\n if (typeof value === 'object') {\n const properties = Object.entries(value).map(([key, val]) =>\n t.objectProperty(\n /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)\n ? t.identifier(key)\n : t.stringLiteral(key),\n valueToAST(val),\n ),\n );\n return t.objectExpression(properties);\n }\n // Fallback for unsupported types\n return t.identifier('undefined');\n}\n\n/**\n * Evaluate an ObjectExpression to a plain JavaScript object.\n * Only supports static values that can be determined at build time.\n */\nfunction evaluateObjectExpression(\n node: t.ObjectExpression,\n path: NodePath,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const prop of node.properties) {\n if (t.isSpreadElement(prop)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic() - styles must be fully static',\n );\n }\n\n if (!t.isObjectProperty(prop)) {\n throw path.buildCodeFrameError(\n 'Only object properties are supported in tastyStatic()',\n );\n }\n\n // Get key\n let key: string;\n if (t.isIdentifier(prop.key)) {\n key = prop.key.name;\n } else if (t.isStringLiteral(prop.key)) {\n key = prop.key.value;\n } else {\n throw path.buildCodeFrameError(\n 'Dynamic property keys are not supported in tastyStatic()',\n );\n }\n\n // Get value\n const value = evaluateExpression(prop.value, path);\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Evaluate an expression to a JavaScript value.\n */\nfunction evaluateExpression(node: t.Node, path: NodePath): unknown {\n if (t.isStringLiteral(node)) {\n return node.value;\n }\n\n if (t.isNumericLiteral(node)) {\n return node.value;\n }\n\n if (t.isBooleanLiteral(node)) {\n return node.value;\n }\n\n if (t.isNullLiteral(node)) {\n return null;\n }\n\n if (t.isIdentifier(node, { name: 'undefined' })) {\n return undefined;\n }\n\n if (t.isArrayExpression(node)) {\n return node.elements.map((el) => {\n if (el === null) return null;\n if (t.isSpreadElement(el)) {\n throw path.buildCodeFrameError(\n 'Spread elements are not supported in tastyStatic()',\n );\n }\n return evaluateExpression(el, path);\n });\n }\n\n if (t.isObjectExpression(node)) {\n return evaluateObjectExpression(node, path);\n }\n\n if (t.isTemplateLiteral(node)) {\n // Only support template literals without expressions\n if (node.expressions.length > 0) {\n throw path.buildCodeFrameError(\n 'Template literals with expressions are not supported in tastyStatic()',\n );\n }\n return node.quasis.map((q) => q.value.cooked).join('');\n }\n\n if (t.isUnaryExpression(node, { operator: '-' })) {\n const arg = evaluateExpression(node.argument, path);\n if (typeof arg === 'number') {\n return -arg;\n }\n }\n\n throw path.buildCodeFrameError(\n `Dynamic expressions are not supported in tastyStatic() - got ${node.type}. ` +\n 'All values must be static literals.',\n );\n}\n\n/**\n * Replace animation names in CSS string.\n * Wraps the keyframes replaceAnimationNames to work on full CSS blocks.\n */\nfunction replaceAnimationNamesInCSS(\n css: string,\n nameMap: Map<string, string>,\n): string {\n if (nameMap.size === 0) return css;\n\n // The CSS contains full rules like \".class { animation: name 1s; }\"\n // We need to replace animation names within declaration blocks\n return css.replace(\n /(animation(?:-name)?)\\s*:\\s*([^;}]+)/gi,\n (match, prop, value) => {\n let newValue = value;\n for (const [original, replacement] of nameMap) {\n // Word boundary replacement\n const pattern = new RegExp(`\\\\b${escapeRegex(original)}\\\\b`, 'g');\n newValue = newValue.replace(pattern, replacement);\n }\n return `${prop}: ${newValue}`;\n },\n );\n}\n\n/**\n * Escape special regex characters.\n */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4JA,SAAS,MAAM,UAAiC;AAC9C,KAAI;AACF,SAAO,GAAG,SAAS,SAAS,CAAC;SACvB;AACN,SAAO;;;AAIX,SAAS,sBAAsB,UAAwB;CACrD,IAAI;AAEJ,KAAI;AACF,aAAA,UAAmB,QAAQ,SAAS;SAC9B;AACN;;CAGF,MAAM,MAAA,UAAc,MAAM;AAE1B,KAAI,CAAC,IAAK;CAEV,MAAM,MAAM,SAAS,UAAU,GAAG,SAAS,YAAY,IAAI,CAAC;AAE5D,KAAI,IAAI;OACD,MAAM,SAAS,IAAI,SACtB,KAAI,MA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,SAAS,KAAK,OAAO;AAC/B,MAAI,OAAO,KAAM,QAAO;AACxB,MAAI,EAAE,gBAAgB,GAAG,CACvB,OAAM,KAAK,oBACT,qDACD;AAEH,SAAO,mBAAmB,IAAI,KAAK;GACnC;AAGJ,KAAI,EAAE,mBAAmB,KAAK,CAC5B,QAAO,yBAAyB,MAAM,KAAK;AAG7C,KAAI,EAAE,kBAAkB,KAAK,EAAE;AAE7B,MAAI,KAAK,YAAY,SAAS,EAC5B,OAAM,KAAK,oBACT,wEACD;AAEH,SAAO,KAAK,OAAO,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC,KAAK,GAAG;;AAGxD,KAAI,EAAE,kBAAkB,MAAM,EAAE,UAAU,KAAK,CAAC,EAAE;EAChD,MAAM,MAAM,mBAAmB,KAAK,UAAU,KAAK;AACnD,MAAI,OAAO,QAAQ,SACjB,QAAO,CAAC;;AAIZ,OAAM,KAAK,oBACT,gEAAgE,KAAK,KAAK,uCAE3E;;;;;;AAOH,SAAS,2BACP,KACA,SACQ;AACR,KAAI,QAAQ,SAAS,EAAG,QAAO;AAI/B,QAAO,IAAI,QACT,2CACC,OAAO,MAAM,UAAU;EACtB,IAAI,WAAW;AACf,OAAK,MAAM,CAAC,UAAU,gBAAgB,SAAS;GAE7C,MAAM,UAAU,IAAI,OAAO,MAAM,YAAY,SAAS,CAAC,MAAM,IAAI;AACjE,cAAW,SAAS,QAAQ,SAAS,YAAY;;AAEnD,SAAO,GAAG,KAAK,IAAI;GAEtB;;;;;AAMH,SAAS,YAAY,KAAqB;AACxC,QAAO,IAAI,QAAQ,uBAAuB,OAAO"}
package/docs/README.md CHANGED
@@ -11,13 +11,13 @@ Tasty is a styling engine for design systems that turns component state into det
11
11
 
12
12
  ## By Role
13
13
 
14
- - **Application developer using an existing design system**: [Getting Started](getting-started.md), then [Runtime API](runtime.md).
14
+ - **Application developer using an existing design system**: [Getting Started](getting-started.md), then [React API](react-api.md).
15
15
  - **Design-system author**: [Methodology](methodology.md), [Building a Design System](design-system.md), [Configuration](configuration.md), and [Adoption Guide](adoption.md).
16
16
  - **Platform or tooling engineer**: [Configuration](configuration.md), [Zero Runtime (tastyStatic)](tasty-static.md), [Server-Side Rendering](ssr.md), and [Debug Utilities](debug.md).
17
17
 
18
18
  ## By Styling Approach
19
19
 
20
- - **Runtime React components**: [Runtime API](runtime.md)
20
+ - **React components**: [React API](react-api.md)
21
21
  - **Zero-runtime / build-time extraction**: [Zero Runtime (tastyStatic)](tasty-static.md)
22
22
  - **Runtime `tasty()` with server collection and hydration**: [Server-Side Rendering](ssr.md)
23
23
 
package/docs/adoption.md CHANGED
@@ -13,7 +13,7 @@ Tasty is not the surface your product engineers interact with directly. It sits
13
13
  ```
14
14
  Product code
15
15
  └─ DS components (Button, Card, Layout, ...)
16
- └─ Tasty engine (tasty(), configure(), hooks)
16
+ └─ Tasty engine (tasty(), configure(), style functions)
17
17
  └─ CSS (mutually exclusive selectors, tokens, custom properties)
18
18
  ```
19
19
 
@@ -64,7 +64,7 @@ Tasty provides the engine. The DS team defines the language that runs on it. Her
64
64
  | **Units** | Custom multiplier units (`x`, `r`, `bw`, or your own) | `configure({ units })` |
65
65
  | **State aliases** | Responsive breakpoints, theme modes, feature flags | `configure({ states })` |
66
66
  | **Recipes** | Reusable style bundles (card, elevated, input-reset) | `configure({ recipes })` |
67
- | **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ tokens: generateTypographyTokens(...) })` |
67
+ | **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ presets: { ... } })` |
68
68
  | **Style props** | Which CSS properties each component exposes as React props | `styleProps` in each component |
69
69
  | **Sub-elements** | Inner parts of compound components (Title, Icon, Content) | `elements` + capitalized keys in `styles` |
70
70
  | **Override rules** | How product engineers extend or constrain components | Styled wrappers via `tasty(Base, { ... })` |
@@ -270,6 +270,8 @@ const LoadingButton = tasty(Button, {
270
270
  </Space>
271
271
  ```
272
272
 
273
+ **Components are server components by default.** All `tasty()` components and style functions are hook-free, so they work as React Server Components without `'use client'`. In server-only contexts (Next.js RSC, Astro without `client:*` directives), they produce zero client JavaScript. Product engineers only add `'use client'` when their component needs actual React interactivity (state, effects, event handlers), never because of styling.
274
+
273
275
  **No cascade/specificity concerns.** Tasty's mutually exclusive selectors mean extending a component cannot accidentally break another. Import order, class name collisions, and specificity arithmetic are non-issues.
274
276
 
275
277
  ---
@@ -289,7 +291,7 @@ const LoadingButton = tasty(Button, {
289
291
  - [Methodology](methodology.md) -- the recommended patterns for structuring Tasty components
290
292
  - [Building a Design System](design-system.md) -- practical guide to building a DS layer with Tasty
291
293
  - [Style DSL](dsl.md) -- state maps, tokens, units, extending semantics, keyframes, @property
292
- - [Runtime API](runtime.md) -- `tasty()` factory, component props, variants, sub-elements, style functions
294
+ - [React API](react-api.md) -- `tasty()` factory, component props, variants, sub-elements, style functions
293
295
  - [Configuration](configuration.md) -- tokens, recipes, custom units, style handlers, and TypeScript extensions
294
296
  - [Style Properties](styles.md) -- complete reference for all enhanced style properties
295
297
  - [Comparison](comparison.md) -- positioning and trade-offs vs. other styling systems
@@ -29,14 +29,14 @@ That is why syntax-level comparisons are often shallow. The more meaningful comp
29
29
 
30
30
  ## High-level positioning
31
31
 
32
- | System | Best described as | Main authoring model | Conflict model | Best fit |
33
- |---|---|---|---|---|
34
- | **Tasty** | Design-system styling engine | Custom DSL with tokens, state maps, recipes, style props, sub-elements, custom units | **Mutually exclusive selector resolution** for stateful styles | Teams building shared component APIs or a house styling language |
35
- | **Tailwind CSS** | Utility-first styling framework | Utility classes in markup | Utility composition, variants, and framework-controlled ordering | Product teams optimizing for speed and direct authoring |
36
- | **Panda CSS** | Typed styling engine with atomic output | Typed style objects, recipes, generated primitives, style props | Atomic CSS with static analysis | Teams wanting a DS-friendly engine with typed primitives |
37
- | **vanilla-extract** | Zero-runtime TS-native stylesheet system | `.css.ts` files, theme contracts, style composition | Standard CSS semantics | Teams wanting static CSS and low-level control |
38
- | **StyleX** | Compiler-based atomic styling system | JS authoring with compiler-generated atomic CSS | Compiler-controlled atomic composition | Large app teams wanting optimized, predictable atomic styling |
39
- | **Stitches** (deprecated) **/ Emotion** | Component-first CSS-in-JS | Styled components, `css()` APIs, object/string styles | Composition within CSS-in-JS rules | Teams optimizing for component DX and flexible styling |
32
+ | System | Best described as | Main authoring model | Conflict model | RSC / zero-JS SSG | Best fit |
33
+ |---|---|---|---|---|---|
34
+ | **Tasty** | Design-system styling engine | Custom DSL with tokens, state maps, recipes, style props, sub-elements, custom units | **Mutually exclusive selector resolution** for stateful styles | Yes — hook-free, server components by default | Teams building shared component APIs or a house styling language |
35
+ | **Tailwind CSS** | Utility-first styling framework | Utility classes in markup | Utility composition, variants, and framework-controlled ordering | Yes — no JS runtime | Product teams optimizing for speed and direct authoring |
36
+ | **Panda CSS** | Typed styling engine with atomic output | Typed style objects, recipes, generated primitives, style props | Atomic CSS with static analysis | Yes — build-time extraction | Teams wanting a DS-friendly engine with typed primitives |
37
+ | **vanilla-extract** | Zero-runtime TS-native stylesheet system | `.css.ts` files, theme contracts, style composition | Standard CSS semantics | Yes — build-time extraction | Teams wanting static CSS and low-level control |
38
+ | **StyleX** | Compiler-based atomic styling system | JS authoring with compiler-generated atomic CSS | Compiler-controlled atomic composition | Yes — compiler-extracted | Large app teams wanting optimized, predictable atomic styling |
39
+ | **Stitches** (deprecated) **/ Emotion** | Component-first CSS-in-JS | Styled components, `css()` APIs, object/string styles | Composition within CSS-in-JS rules | No — requires `'use client'` | Teams optimizing for component DX and flexible styling |
40
40
 
41
41
  ---
42
42
 
@@ -92,7 +92,7 @@ That makes Tasty less of a "better way to write CSS objects" and more of a **sta
92
92
  Beyond state resolution, Tasty also provides several structural capabilities that reinforce the design-system layer:
93
93
 
94
94
  - **CSS properties as typed React props** — `styleProps` lets a component expose selected style properties as normal props (`<Button placeSelf="end">`), including state maps for responsive values. This keeps layout and composition controls inside a governed component API instead of pushing teams back to ad hoc styling escapes.
95
- - **Sub-element styling** — Compound components declare inner parts via capitalized keys in `styles` and `data-element` attributes. States, tokens, and recipes apply across the entire element tree from a single definition. See [Runtime API — Sub-element Styling](runtime.md#sub-element-styling).
95
+ - **Sub-element styling** — Compound components declare inner parts via capitalized keys in `styles` and `data-element` attributes. States, tokens, and recipes apply across the entire element tree from a single definition. See [React API — Sub-element Styling](react-api.md#sub-element-styling).
96
96
  - **Auto-inferred `@property`** — When a custom property is assigned a concrete value, Tasty infers the CSS `@property` syntax and registers it automatically, enabling smooth transitions on custom properties without manual declarations.
97
97
  - **AI-friendly style definitions** — Style definitions are declarative, self-contained, and structurally consistent. AI tools can read, refactor, and generate Tasty styles as confidently as a human — no hidden cascade logic or implicit ordering to second-guess.
98
98
  - **Companion ecosystem** — An [ESLint plugin](https://github.com/tenphi/eslint-plugin-tasty) with 27 lint rules, a [VS Code extension](https://github.com/tenphi/tasty-vscode-extension) for syntax highlighting, and [Glaze](https://github.com/tenphi/glaze) for OKHSL color theme generation with automatic WCAG contrast solving.
@@ -235,13 +235,12 @@ Tasty is more opinionated.
235
235
 
236
236
  It behaves less like "TypeScript that outputs CSS" and more like a **state-aware style compiler**. It is designed to encode higher-level styling semantics rather than only expose CSS primitives in typed form.
237
237
 
238
- This also makes Tasty's static mode notable:
238
+ This also makes Tasty's rendering model notable:
239
239
 
240
- - Runtime `tasty()` creates React components with dynamic injection
241
- - `tastyStatic()` with the Babel plugin produces static class name strings with zero runtime overhead
242
- - In static mode, the output is plain CSS + class names, so it can be used with any JavaScript framework — not only React
240
+ - `tasty()` components are hook-free and work as React Server Components. In server-only contexts (Next.js RSC, Astro without islands), they produce static HTML + CSS with zero client JavaScript — the full feature set is available without sacrificing server rendering
241
+ - `tastyStatic()` with the Babel plugin produces static class name strings via build-time extraction, with no React dependency at runtime — the output works with any JavaScript framework
243
242
 
244
- Runtime features like `styleProps`, sub-element components, and dynamic variants are React-specific. The static path is framework-agnostic.
243
+ Runtime features like `styleProps`, sub-element components, and dynamic variants are available in the `tasty()` path. The `tastyStatic()` path is framework-agnostic but limited to the DSL, tokens, and state logic.
245
244
 
246
245
  So the tradeoff is roughly:
247
246
 
@@ -303,6 +302,8 @@ So while Stitches and Emotion are strong tools for building components, Tasty is
303
302
 
304
303
  That makes it narrower in audience, but deeper in architectural ambition.
305
304
 
305
+ There is also a fundamental architectural difference: Emotion and styled-components rely on React context and hooks internally, which means they require `'use client'` in modern React and cannot run as React Server Components. Tasty's style functions and `tasty()` components are hook-free, so they work as server components by default and produce zero client JavaScript in server-only contexts. This is not a minor compatibility detail — it means Tasty-based components stay as server components until *your* code needs interactivity, while Emotion and styled-components force the client boundary at the styling layer.
306
+
306
307
  For teams evaluating runtime styling at scale, Tasty also documents its runtime benchmarks and caching model in the main [README](../README.md#performance). That matters, but it is still secondary to the core question of whether you want Tasty's deterministic selector model.
307
308
 
308
309
  ---
@@ -311,20 +312,18 @@ For teams evaluating runtime styling at scale, Tasty also documents its runtime
311
312
 
312
313
  Tasty is not limited to one execution model.
313
314
 
314
- It can be used as a styling system with runtime behavior, but it can also be used as a **fully build-time style compiler** when that is the right fit.
315
-
316
- That distinction matters.
315
+ The term "runtime" in `tasty()` refers to *when* style computation happens — during React rendering — not to where that rendering occurs. In server-only contexts (Next.js RSC without `'use client'`, Astro without `client:*` directives, SSG), `tasty()` components render on the server, produce static HTML + CSS, and ship **zero client JavaScript**. The full feature set — `styleProps`, sub-elements, variants, state maps is available. The result is the same as what `tastyStatic()` produces, but without giving up any runtime capabilities.
317
316
 
318
- In runtime mode, `tasty()` creates React components with dynamic style injection, `styleProps`, sub-element components, and variants. This path is React-specific.
317
+ Client JavaScript only enters the picture when a component needs React interactivity (state, effects, event handlers) — and that is the consuming component's decision, never Tasty's. Tasty never forces the `'use client'` boundary.
319
318
 
320
- In build-time mode, `tastyStatic()` with the Babel plugin generates plain static class names and CSS files. The output is framework-agnostic — any JavaScript framework can consume the resulting class names and CSS. This makes Tasty usable as the compiler layer underneath a design-system implementation, even outside the React ecosystem.
319
+ `tastyStatic()` with the Babel plugin is for a different scenario: when you want build-time CSS extraction **without React at runtime**. The output is framework-agnostic — any JavaScript framework can consume the resulting class names and CSS. This makes Tasty usable as the compiler layer underneath a design-system implementation, even outside the React ecosystem.
321
320
 
322
- The tradeoff is that some capabilities — `styleProps`, sub-element components (`<Card.Title>`), dynamic variants — are tied to the runtime path. The static path is best understood as extraction and compilation of the DSL, tokens, and state logic.
321
+ The tradeoff is that some capabilities — `styleProps`, sub-element components (`<Card.Title>`), dynamic variants — are tied to the `tasty()` path. The `tastyStatic()` path is best understood as extraction and compilation of the DSL, tokens, and state logic without a React dependency.
323
322
 
324
323
  This flexibility is one of Tasty's more unusual strengths:
325
324
 
326
- - it can be used as a full authoring/runtime system for React
327
- - or as a static compiler whose output works with any framework
325
+ - `tasty()` as the default for all React setups — zero client JS in server-only contexts, full feature set, SSR integration available when client hydration is needed
326
+ - `tastyStatic()` as a static compiler whose output works with any framework, including non-React ones
328
327
 
329
328
  ---
330
329
 
@@ -337,8 +336,8 @@ These are optimized for styling product code directly.
337
336
 
338
337
  Examples:
339
338
  - Tailwind CSS
340
- - Emotion
341
- - Stitches (deprecated)
339
+ - Emotion (requires `'use client'` — not RSC-compatible)
340
+ - Stitches (deprecated, requires `'use client'`)
342
341
 
343
342
  ### Typed styling engines
344
343
  These are optimized for generating CSS with stronger structure and tooling.
@@ -412,7 +411,7 @@ Tasty is most compelling when the problem is not just "how do we write styles,"
412
411
 
413
412
  - [README](../README.md) — overview, quick start, and feature highlights
414
413
  - [Style DSL](dsl.md) — state maps, tokens, units, extending semantics, keyframes, @property
415
- - [Runtime API](runtime.md) — `tasty()` factory, component props, variants, sub-elements, style functions
414
+ - [React API](react-api.md) — `tasty()` factory, component props, variants, sub-elements, style functions
416
415
  - [Style Properties](styles.md) — complete reference for all enhanced style properties
417
416
  - [Configuration](configuration.md) — tokens, recipes, custom units, style handlers, and TypeScript extensions
418
417
  - [Zero Runtime (tastyStatic)](tasty-static.md) — build-time static styling with Babel plugin
@@ -58,6 +58,8 @@ These docs use `data-schema="dark"` in examples. If your app already standardize
58
58
  | `counterStyle` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
59
59
  | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
60
60
  | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
61
+ | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
62
+ | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
61
63
  | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | `'oklch'` | Color space for decomposed color token companion variables |
62
64
 
63
65
  ---
@@ -220,6 +222,72 @@ For how to apply, compose, and override recipes in components, see [Recipes](dsl
220
222
 
221
223
  ---
222
224
 
225
+ ## Typography Presets
226
+
227
+ Typography presets are a shorthand for `generateTypographyTokens()`. Instead of calling the function manually and spreading the result into `tokens`, pass the presets directly:
228
+
229
+ ```jsx
230
+ configure({
231
+ presets: {
232
+ h1: { fontSize: '32px', lineHeight: '1.2', fontWeight: '700' },
233
+ t2: { fontSize: '16px', lineHeight: '1.5', fontWeight: '400' },
234
+ tag: {
235
+ fontSize: '10px',
236
+ lineHeight: '1.4',
237
+ letterSpacing: '0.04em',
238
+ fontWeight: '600',
239
+ },
240
+ },
241
+ });
242
+ ```
243
+
244
+ Each preset generates `$name-font-size`, `$name-line-height`, `$name-letter-spacing`, `$name-font-weight`, and optional `$name-bold-font-weight`, `$name-icon-size`, `$name-text-transform`, `$name-font-family`, `$name-font-style` tokens.
245
+
246
+ Preset values support state maps for responsive or theme-aware typography:
247
+
248
+ ```jsx
249
+ configure({
250
+ presets: {
251
+ t2: {
252
+ fontSize: '16px',
253
+ lineHeight: '1.5',
254
+ fontWeight: { '': '400', '@dark': '300' },
255
+ },
256
+ },
257
+ });
258
+ ```
259
+
260
+ The generated tokens are merged **under** explicit `tokens` — if both `presets` and `tokens` define `$t2-font-weight`, the `tokens` value wins. Plugins can also provide `presets`; plugin presets are merged first, then config presets, then explicit tokens on top.
261
+
262
+ ---
263
+
264
+ ## Global Styles
265
+
266
+ Apply Tasty styles to any selector via configuration, without needing `useGlobalStyles(selector, ...)` at runtime:
267
+
268
+ ```jsx
269
+ configure({
270
+ globalStyles: {
271
+ body: {
272
+ fill: '#surface',
273
+ color: '#text',
274
+ preset: 't2',
275
+ margin: 0,
276
+ fontFamily: 'system-ui, sans-serif',
277
+ },
278
+ html: {
279
+ overflow: 'hidden',
280
+ },
281
+ },
282
+ });
283
+ ```
284
+
285
+ Each key is a CSS selector, and each value is a Tasty `Styles` object supporting the full style syntax including style properties, tokens, state maps, and selector-based sub-styling (e.g. `$: '> .app'` for elements outside React scope). Global styles are injected alongside `:root` tokens when the first style is rendered.
286
+
287
+ Global styles are automatically emitted in all rendering modes: runtime (client), SSR, and zero-runtime (Babel plugin). Plugins can also provide `globalStyles`; they are merged per selector with config global styles (config wins on conflict).
288
+
289
+ ---
290
+
223
291
  ## Auto Property Types
224
292
 
225
293
  CSS cannot transition or animate custom properties unless their type is declared via [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property). Tasty handles this automatically — when a custom property is assigned a concrete value (e.g. `'$scale': 1`, `'$gap': '10px'`, `'#accent': 'purple'`), the type is inferred and a `@property` rule is registered.
@@ -323,4 +391,4 @@ declare module '@tenphi/tasty' {
323
391
  }
324
392
  ```
325
393
 
326
- See [Style DSL](dsl.md) for state maps, tokens, units, and extending semantics, and [Runtime API](runtime.md) for `tasty()`, style functions, and component props.
394
+ See [Style DSL](dsl.md) for state maps, tokens, units, and extending semantics, and [React API](react-api.md) for `tasty()`, style functions, and component props.