@tenphi/tasty 0.0.0-snapshot.f656100 → 0.0.0-snapshot.f6c0abf

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 (180) hide show
  1. package/README.md +8 -7
  2. package/dist/chunks/definitions.js.map +1 -1
  3. package/dist/compute-styles.d.ts +31 -0
  4. package/dist/compute-styles.js +335 -0
  5. package/dist/compute-styles.js.map +1 -0
  6. package/dist/config.d.ts +20 -19
  7. package/dist/config.js +25 -26
  8. package/dist/config.js.map +1 -1
  9. package/dist/core/index.d.ts +5 -4
  10. package/dist/core/index.js +6 -5
  11. package/dist/hooks/useCounterStyle.d.ts +3 -17
  12. package/dist/hooks/useCounterStyle.js +54 -36
  13. package/dist/hooks/useCounterStyle.js.map +1 -1
  14. package/dist/hooks/useFontFace.d.ts +3 -1
  15. package/dist/hooks/useFontFace.js +21 -25
  16. package/dist/hooks/useFontFace.js.map +1 -1
  17. package/dist/hooks/useGlobalStyles.d.ts +18 -2
  18. package/dist/hooks/useGlobalStyles.js +52 -42
  19. package/dist/hooks/useGlobalStyles.js.map +1 -1
  20. package/dist/hooks/useKeyframes.d.ts +4 -2
  21. package/dist/hooks/useKeyframes.js +41 -51
  22. package/dist/hooks/useKeyframes.js.map +1 -1
  23. package/dist/hooks/useProperty.d.ts +4 -2
  24. package/dist/hooks/useProperty.js +29 -42
  25. package/dist/hooks/useProperty.js.map +1 -1
  26. package/dist/hooks/useRawCSS.d.ts +13 -44
  27. package/dist/hooks/useRawCSS.js +90 -22
  28. package/dist/hooks/useRawCSS.js.map +1 -1
  29. package/dist/hooks/useStyles.d.ts +4 -9
  30. package/dist/hooks/useStyles.js +6 -214
  31. package/dist/hooks/useStyles.js.map +1 -1
  32. package/dist/index.d.ts +6 -5
  33. package/dist/index.js +7 -6
  34. package/dist/injector/index.d.ts +18 -19
  35. package/dist/injector/index.js +22 -16
  36. package/dist/injector/index.js.map +1 -1
  37. package/dist/injector/injector.d.ts +30 -3
  38. package/dist/injector/injector.js +107 -7
  39. package/dist/injector/injector.js.map +1 -1
  40. package/dist/injector/sheet-manager.d.ts +9 -13
  41. package/dist/injector/sheet-manager.js +31 -66
  42. package/dist/injector/sheet-manager.js.map +1 -1
  43. package/dist/injector/types.d.ts +43 -19
  44. package/dist/parser/const.js +13 -2
  45. package/dist/parser/const.js.map +1 -1
  46. package/dist/pipeline/parseStateKey.js +4 -4
  47. package/dist/pipeline/parseStateKey.js.map +1 -1
  48. package/dist/rsc-cache.js +81 -0
  49. package/dist/rsc-cache.js.map +1 -0
  50. package/dist/ssr/astro-client.d.ts +1 -0
  51. package/dist/ssr/astro-client.js +24 -0
  52. package/dist/ssr/astro-client.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +15 -0
  54. package/dist/ssr/astro-middleware.js +19 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +85 -8
  57. package/dist/ssr/astro.js +91 -21
  58. package/dist/ssr/astro.js.map +1 -1
  59. package/dist/ssr/async-storage.js +14 -4
  60. package/dist/ssr/async-storage.js.map +1 -1
  61. package/dist/ssr/collect-auto-properties.js +28 -9
  62. package/dist/ssr/collect-auto-properties.js.map +1 -1
  63. package/dist/ssr/collector.js +3 -10
  64. package/dist/ssr/collector.js.map +1 -1
  65. package/dist/ssr/index.d.ts +2 -3
  66. package/dist/ssr/index.js +1 -2
  67. package/dist/ssr/index.js.map +1 -1
  68. package/dist/ssr/next.d.ts +1 -3
  69. package/dist/ssr/next.js +8 -3
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/ssr/ssr-collector-ref.js +4 -3
  72. package/dist/ssr/ssr-collector-ref.js.map +1 -1
  73. package/dist/styles/border.d.ts +1 -1
  74. package/dist/styles/border.js +27 -20
  75. package/dist/styles/border.js.map +1 -1
  76. package/dist/styles/color.d.ts +1 -1
  77. package/dist/styles/color.js +1 -1
  78. package/dist/styles/color.js.map +1 -1
  79. package/dist/styles/const.js +17 -0
  80. package/dist/styles/const.js.map +1 -0
  81. package/dist/styles/createStyle.js +3 -3
  82. package/dist/styles/createStyle.js.map +1 -1
  83. package/dist/styles/dimension.js +14 -1
  84. package/dist/styles/dimension.js.map +1 -1
  85. package/dist/styles/directional.js +133 -0
  86. package/dist/styles/directional.js.map +1 -0
  87. package/dist/styles/display.d.ts +3 -10
  88. package/dist/styles/display.js +44 -37
  89. package/dist/styles/display.js.map +1 -1
  90. package/dist/styles/fade.d.ts +1 -1
  91. package/dist/styles/fade.js +8 -3
  92. package/dist/styles/fade.js.map +1 -1
  93. package/dist/styles/fill.d.ts +2 -2
  94. package/dist/styles/fill.js +2 -2
  95. package/dist/styles/fill.js.map +1 -1
  96. package/dist/styles/gap.d.ts +1 -1
  97. package/dist/styles/gap.js +3 -1
  98. package/dist/styles/gap.js.map +1 -1
  99. package/dist/styles/height.d.ts +1 -1
  100. package/dist/styles/inset.d.ts +1 -29
  101. package/dist/styles/inset.js +18 -133
  102. package/dist/styles/inset.js.map +1 -1
  103. package/dist/styles/list.d.ts +5 -5
  104. package/dist/styles/list.js +3 -1
  105. package/dist/styles/list.js.map +1 -1
  106. package/dist/styles/margin.d.ts +1 -1
  107. package/dist/styles/margin.js +16 -87
  108. package/dist/styles/margin.js.map +1 -1
  109. package/dist/styles/outline.d.ts +1 -1
  110. package/dist/styles/outline.js +5 -14
  111. package/dist/styles/outline.js.map +1 -1
  112. package/dist/styles/padding.d.ts +1 -1
  113. package/dist/styles/padding.js +16 -87
  114. package/dist/styles/padding.js.map +1 -1
  115. package/dist/styles/placement.d.ts +37 -0
  116. package/dist/styles/placement.js +74 -0
  117. package/dist/styles/placement.js.map +1 -0
  118. package/dist/styles/predefined.d.ts +4 -4
  119. package/dist/styles/predefined.js +7 -7
  120. package/dist/styles/predefined.js.map +1 -1
  121. package/dist/styles/preset.d.ts +1 -1
  122. package/dist/styles/preset.js +6 -5
  123. package/dist/styles/preset.js.map +1 -1
  124. package/dist/styles/radius.d.ts +1 -1
  125. package/dist/styles/radius.js +19 -7
  126. package/dist/styles/radius.js.map +1 -1
  127. package/dist/styles/scrollMargin.d.ts +24 -0
  128. package/dist/styles/scrollMargin.js +32 -0
  129. package/dist/styles/scrollMargin.js.map +1 -0
  130. package/dist/styles/scrollbar.d.ts +1 -1
  131. package/dist/styles/scrollbar.js +6 -1
  132. package/dist/styles/scrollbar.js.map +1 -1
  133. package/dist/styles/shadow.d.ts +1 -1
  134. package/dist/styles/shadow.js +3 -1
  135. package/dist/styles/shadow.js.map +1 -1
  136. package/dist/styles/shared.js +17 -0
  137. package/dist/styles/shared.js.map +1 -0
  138. package/dist/styles/transition.d.ts +1 -1
  139. package/dist/styles/transition.js +4 -2
  140. package/dist/styles/transition.js.map +1 -1
  141. package/dist/styles/types.d.ts +20 -5
  142. package/dist/styles/width.d.ts +1 -1
  143. package/dist/tasty.d.ts +28 -13
  144. package/dist/tasty.js +72 -60
  145. package/dist/tasty.js.map +1 -1
  146. package/dist/utils/deps-equal.js +15 -0
  147. package/dist/utils/deps-equal.js.map +1 -0
  148. package/dist/utils/filter-base-props.d.ts +1 -1
  149. package/dist/utils/filter-base-props.js.map +1 -1
  150. package/dist/utils/hash.js +14 -0
  151. package/dist/utils/hash.js.map +1 -0
  152. package/dist/utils/process-tokens.d.ts +1 -5
  153. package/dist/utils/process-tokens.js +1 -8
  154. package/dist/utils/process-tokens.js.map +1 -1
  155. package/dist/utils/styles.d.ts +1 -1
  156. package/dist/utils/styles.js.map +1 -1
  157. package/docs/adoption.md +1 -1
  158. package/docs/comparison.md +1 -1
  159. package/docs/configuration.md +1 -1
  160. package/docs/design-system.md +1 -1
  161. package/docs/dsl.md +21 -6
  162. package/docs/getting-started.md +1 -1
  163. package/docs/injector.md +39 -23
  164. package/docs/methodology.md +51 -2
  165. package/docs/runtime.md +99 -31
  166. package/docs/ssr.md +130 -79
  167. package/docs/styles.md +14 -0
  168. package/docs/tasty-static.md +1 -1
  169. package/package.json +12 -6
  170. package/dist/hooks/resolve-ssr-collector.js +0 -14
  171. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  172. package/dist/ssr/context.d.ts +0 -8
  173. package/dist/ssr/context.js +0 -13
  174. package/dist/ssr/context.js.map +0 -1
  175. package/dist/styles/align.d.ts +0 -15
  176. package/dist/styles/align.js +0 -14
  177. package/dist/styles/align.js.map +0 -1
  178. package/dist/styles/justify.d.ts +0 -15
  179. package/dist/styles/justify.js +0 -14
  180. package/dist/styles/justify.js.map +0 -1
package/README.md CHANGED
@@ -347,7 +347,7 @@ Every style property accepts a state mapping object. Keys can be combined with b
347
347
  | Feature query | `@supports(display: grid)` | `@supports (display: grid)` |
348
348
  | Entry animation | `@starting` | `@starting-style` |
349
349
 
350
- Combine with `&` (AND), `|` (OR), `!` (NOT):
350
+ Combine with `&` (AND), `|` (OR), `!` (NOT), `^` (XOR):
351
351
 
352
352
  ```tsx
353
353
  fill: {
@@ -427,11 +427,11 @@ Use explicit `@properties` only when you need to override defaults such as `inhe
427
427
 
428
428
  See [Style DSL - Properties (`@property`)](docs/dsl.md#properties-property).
429
429
 
430
- ### React Hooks
430
+ ### Style Functions
431
431
 
432
- When you do not need a full component wrapper, use the hooks directly: `useStyles` for local class names, `useGlobalStyles` for selector-scoped global CSS, `useRawCSS` for raw rules, plus `useKeyframes` and `useProperty` for animation and custom-property primitives.
432
+ When you do not need a full component wrapper, use the style functions directly: `useStyles` for local class names, `useGlobalStyles` for selector-scoped global CSS, `useRawCSS` for raw rules, plus `useKeyframes`, `useProperty`, `useFontFace`, and `useCounterStyle` for animation, custom-property, font, and counter-style primitives. All style functions are hook-free and work in React Server Components.
433
433
 
434
- See [Runtime API - Hooks](docs/runtime.md#hooks).
434
+ See [Runtime API - Style Functions](docs/runtime.md#style-functions).
435
435
 
436
436
  ### Zero-Runtime Mode
437
437
 
@@ -457,7 +457,7 @@ See the [full SSR guide](docs/ssr.md).
457
457
 
458
458
  | Import | Description | Platform |
459
459
  |--------|-------------|----------|
460
- | `@tenphi/tasty` | Runtime style engine (`tasty`, hooks, `configure`) | Browser |
460
+ | `@tenphi/tasty` | Runtime style engine (`tasty`, style functions, `configure`) | Browser |
461
461
  | `@tenphi/tasty/static` | Zero-runtime static styles (`tastyStatic`) | Browser |
462
462
  | `@tenphi/tasty/core` | Lower-level internals (config, parser, pipeline, injector, style handlers) for tooling and advanced use | Browser / Node |
463
463
  | `@tenphi/tasty/babel-plugin` | Babel plugin for zero-runtime CSS extraction | Node |
@@ -465,7 +465,8 @@ See the [full SSR guide](docs/ssr.md).
465
465
  | `@tenphi/tasty/next` | Next.js integration wrapper | Node |
466
466
  | `@tenphi/tasty/ssr` | Core SSR API (collector, context, hydration) | Node |
467
467
  | `@tenphi/tasty/ssr/next` | Next.js App Router SSR integration | Node |
468
- | `@tenphi/tasty/ssr/astro` | Astro middleware + auto-hydration | Node / Browser |
468
+ | `@tenphi/tasty/ssr/astro` | Astro integration + middleware | Node |
469
+ | `@tenphi/tasty/ssr/astro-client` | Astro client-side cache hydration | Browser |
469
470
 
470
471
  ## Browser Requirements
471
472
 
@@ -605,7 +606,7 @@ Start from the docs hub if you want the shortest path to the right guide for you
605
606
  ### Reference
606
607
 
607
608
  - **[Style DSL](docs/dsl.md)** — The Tasty style language: state maps, tokens, units, color syntax, extending semantics, recipes, keyframes, and @property
608
- - **[Runtime API](docs/runtime.md)** — React-specific API: `tasty()` factory, component props, variants, sub-elements, and hooks
609
+ - **[Runtime API](docs/runtime.md)** — React-specific API: `tasty()` factory, component props, variants, sub-elements, and style functions
609
610
  - **[Configuration](docs/configuration.md)** — Global configuration: tokens, recipes, custom units, style handlers, and TypeScript extensions
610
611
  - **[Style Properties](docs/styles.md)** — Complete reference for all enhanced style properties: syntax, values, modifiers, and recommendations
611
612
 
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","names":[],"sources":["../../src/chunks/definitions.ts"],"sourcesContent":["/**\n * Style chunk definitions for CSS chunking optimization.\n *\n * Styles are grouped into chunks based on:\n * 1. Handler dependencies - styles that share a handler MUST be in the same chunk\n * 2. Logical grouping - related styles grouped for better cache reuse\n *\n * See STYLE_CHUNKING_SPEC.md for detailed rationale.\n *\n * ============================================================================\n * ⚠️ CRITICAL ARCHITECTURAL CONSTRAINT: NO CROSS-CHUNK HANDLER DEPENDENCIES\n * ============================================================================\n *\n * Style handlers declare their dependencies via `__lookupStyles` array.\n * This creates a dependency graph where handlers read multiple style props.\n *\n * **ALL styles in a handler's `__lookupStyles` MUST be in the SAME chunk.**\n *\n * Why this matters:\n * 1. Each chunk computes a cache key from ONLY its own style values\n * 2. If a handler reads a style from another chunk, that value isn't in the cache key\n * 3. Changing the cross-chunk style won't invalidate this chunk's cache\n * 4. Result: stale CSS output or incorrect cache hits\n *\n * Example of a violation:\n * ```\n * // flowStyle.__lookupStyles = ['display', 'flow']\n * // If 'display' is in DISPLAY chunk and 'flow' is in LAYOUT chunk:\n * // - User sets { display: 'grid', flow: 'column' }\n * // - LAYOUT chunk caches CSS with flow=column, display=grid\n * // - User changes to { display: 'flex', flow: 'column' }\n * // - LAYOUT chunk cache key unchanged (only has 'flow')\n * // - Returns stale CSS computed with display=grid!\n * ```\n *\n * Before adding/moving styles, verify:\n * 1. Find all handlers that use this style (grep for the style name in __lookupStyles)\n * 2. Ensure ALL styles from each handler's __lookupStyles are in the same chunk\n * ============================================================================\n */\n\nimport { isSelector } from '../pipeline';\n\n// ============================================================================\n// Chunk Style Lists\n// ============================================================================\n\n/**\n * Appearance chunk - visual styling with independent handlers\n */\nexport const APPEARANCE_CHUNK_STYLES = [\n 'fill', // fillStyle (independent)\n 'color', // colorStyle (independent)\n 'opacity', // independent\n 'border', // borderStyle (independent)\n 'radius', // radiusStyle (independent)\n 'outline', // outlineStyle: outline ↔ outlineOffset\n 'outlineOffset', // outlineStyle: outline ↔ outlineOffset\n 'shadow', // shadowStyle (independent)\n 'fade', // fadeStyle (independent)\n] as const;\n\n/**\n * Font chunk - typography styles\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ presetStyle: preset, fontSize, lineHeight, letterSpacing, textTransform,\n * fontWeight, fontStyle, font\n */\nexport const FONT_CHUNK_STYLES = [\n // All from presetStyle handler - MUST stay together\n 'preset',\n 'font',\n 'fontWeight',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textTransform',\n // Independent text styles grouped for cohesion\n 'fontFamily', // independent alias (logical grouping with font styles)\n 'textAlign',\n 'textDecoration',\n 'wordBreak',\n 'wordWrap',\n 'boldFontWeight',\n] as const;\n\n/**\n * Dimension chunk - sizing and spacing\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ paddingStyle: padding, paddingTop/Right/Bottom/Left, paddingBlock/Inline\n * ⚠️ marginStyle: margin, marginTop/Right/Bottom/Left, marginBlock/Inline\n * ⚠️ widthStyle: width, minWidth, maxWidth\n * ⚠️ heightStyle: height, minHeight, maxHeight\n */\nexport const DIMENSION_CHUNK_STYLES = [\n // All from paddingStyle handler - MUST stay together\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n // All from marginStyle handler - MUST stay together\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n // widthStyle handler - MUST stay together\n 'width',\n 'minWidth',\n 'maxWidth',\n // heightStyle handler - MUST stay together\n 'height',\n 'minHeight',\n 'maxHeight',\n 'flexBasis',\n 'flexGrow',\n 'flexShrink',\n 'flex',\n] as const;\n\n/**\n * Display chunk - display mode, layout flow, text overflow, and scrollbar\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ displayStyle: display, hide, textOverflow, overflow, whiteSpace\n * ⚠️ flowStyle: display, flow\n * ⚠️ gapStyle: display, flow, gap\n * ⚠️ scrollbarStyle: scrollbar, overflow\n */\nexport const DISPLAY_CHUNK_STYLES = [\n // displayStyle handler\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow', // also used by scrollbarStyle\n 'whiteSpace',\n // flowStyle handler (requires display)\n 'flow',\n // gapStyle handler (requires display, flow)\n 'gap',\n // scrollbarStyle handler (requires overflow)\n 'scrollbar',\n] as const;\n\n/**\n * Layout chunk - flex/grid alignment and grid templates\n *\n * Note: flow and gap are in DISPLAY chunk due to handler dependencies\n * (flowStyle and gapStyle both require 'display' prop).\n */\nexport const LAYOUT_CHUNK_STYLES = [\n // Alignment styles (all independent handlers)\n 'placeItems',\n 'placeContent',\n 'alignItems',\n 'alignContent',\n 'justifyItems',\n 'justifyContent',\n 'align', // alignStyle (independent)\n 'justify', // justifyStyle (independent)\n 'place', // placeStyle (independent)\n 'columnGap',\n 'rowGap',\n // Grid template styles\n 'gridColumns',\n 'gridRows',\n 'gridTemplate',\n 'gridAreas',\n 'gridAutoFlow',\n 'gridAutoColumns',\n 'gridAutoRows',\n] as const;\n\n/**\n * Position chunk - element positioning\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ insetStyle: inset, insetBlock, insetInline, top, right, bottom, left\n */\nexport const POSITION_CHUNK_STYLES = [\n 'position',\n // All from insetStyle handler - MUST stay together\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'zIndex',\n 'gridArea',\n 'gridColumn',\n 'gridRow',\n 'order',\n 'placeSelf',\n 'alignSelf',\n 'justifySelf',\n 'transform',\n 'transition',\n 'animation',\n] as const;\n\n// ============================================================================\n// Chunk Names\n// ============================================================================\n\nexport const CHUNK_NAMES = {\n /** Special chunk for styles that cannot be split */\n COMBINED: 'combined',\n SUBCOMPONENTS: 'subcomponents',\n APPEARANCE: 'appearance',\n FONT: 'font',\n DIMENSION: 'dimension',\n DISPLAY: 'display',\n LAYOUT: 'layout',\n POSITION: 'position',\n MISC: 'misc',\n} as const;\n\nexport type ChunkName = (typeof CHUNK_NAMES)[keyof typeof CHUNK_NAMES];\n\n// ============================================================================\n// Style-to-Chunk Lookup Map (O(1) categorization)\n// ============================================================================\n\n/**\n * Pre-computed map for O(1) style-to-chunk lookup.\n * Built once at module load time.\n */\nexport const STYLE_TO_CHUNK = new Map<string, ChunkName>();\n\n// Populate the lookup map\nfunction populateStyleToChunkMap() {\n for (const style of APPEARANCE_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.APPEARANCE);\n }\n for (const style of FONT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.FONT);\n }\n for (const style of DIMENSION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DIMENSION);\n }\n for (const style of DISPLAY_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DISPLAY);\n }\n for (const style of LAYOUT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.LAYOUT);\n }\n for (const style of POSITION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.POSITION);\n }\n}\n\n// Initialize at module load\npopulateStyleToChunkMap();\n\n// ============================================================================\n// Chunk Priority Order\n// ============================================================================\n\n/**\n * Chunk processing order. This ensures deterministic className allocation\n * regardless of style key order in the input.\n */\nconst CHUNK_ORDER: readonly string[] = [\n CHUNK_NAMES.APPEARANCE,\n CHUNK_NAMES.FONT,\n CHUNK_NAMES.DIMENSION,\n CHUNK_NAMES.DISPLAY,\n CHUNK_NAMES.LAYOUT,\n CHUNK_NAMES.POSITION,\n CHUNK_NAMES.MISC,\n CHUNK_NAMES.SUBCOMPONENTS,\n] as const;\n\n/**\n * Map from chunk name to its priority index for sorting.\n */\nconst _CHUNK_PRIORITY = new Map<string, number>(\n CHUNK_ORDER.map((name, index) => [name, index]),\n);\n\n// ============================================================================\n// Chunk Info Interface\n// ============================================================================\n\nexport interface ChunkInfo {\n /** Name of the chunk */\n name: ChunkName | string;\n /** Style keys belonging to this chunk */\n styleKeys: string[];\n}\n\n// ============================================================================\n// Style Categorization\n// ============================================================================\n\n/**\n * Categorize style keys into chunks.\n *\n * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless\n * of the order of keys in the input styles object.\n *\n * @param styles - The styles object to categorize\n * @returns Map of chunk name to array of style keys in that chunk (in priority order)\n */\nexport function categorizeStyleKeys(\n styles: Record<string, unknown>,\n): Map<string, string[]> {\n // First pass: collect keys into chunks (unordered)\n const chunkData: Record<string, string[]> = {};\n const keys = Object.keys(styles);\n\n for (const key of keys) {\n // Skip the $ helper key (used for selector combinators)\n // Skip @keyframes and @properties (processed separately in useStyles)\n // Skip recipe (resolved before pipeline by resolveRecipes)\n if (\n key === '$' ||\n key === '@keyframes' ||\n key === '@properties' ||\n key === '@fontFace' ||\n key === '@counterStyle' ||\n key === 'recipe'\n ) {\n continue;\n }\n\n if (isSelector(key)) {\n // All selectors go into the subcomponents chunk\n if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) {\n chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];\n }\n chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);\n } else {\n // Look up the chunk for this style, default to misc\n const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;\n if (!chunkData[chunkName]) {\n chunkData[chunkName] = [];\n }\n chunkData[chunkName].push(key);\n }\n }\n\n // Second pass: build ordered Map based on CHUNK_ORDER\n const orderedChunks = new Map<string, string[]>();\n\n // Add chunks in priority order\n for (const chunkName of CHUNK_ORDER) {\n if (chunkData[chunkName] && chunkData[chunkName].length > 0) {\n // Sort keys within chunk for consistent cache key generation\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n // Handle any unknown chunks (shouldn't happen, but be defensive)\n for (const chunkName of Object.keys(chunkData)) {\n if (!orderedChunks.has(chunkName)) {\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n return orderedChunks;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,M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yB;;;;;AAUzB,MAAM,cAAiC;CACrC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAKuB,IAAI,IAC1B,YAAY,KAAK,MAAM,UAAU,CAAC,MAAM,MAAM,CAAC,CAChD;;;;;;;;;;AA0BD,SAAgB,oBACd,QACuB;CAEvB,MAAM,YAAsC,EAAE;CAC9C,MAAM,OAAO,OAAO,KAAK,OAAO;AAEhC,MAAK,MAAM,OAAO,MAAM;AAItB,MACE,QAAQ,OACR,QAAQ,gBACR,QAAQ,iBACR,QAAQ,eACR,QAAQ,mBACR,QAAQ,SAER;AAGF,MAAI,WAAW,IAAI,EAAE;AAEnB,OAAI,CAAC,UAAU,YAAY,eACzB,WAAU,YAAY,iBAAiB,EAAE;AAE3C,aAAU,YAAY,eAAe,KAAK,IAAI;SACzC;GAEL,MAAM,YAAY,eAAe,IAAI,IAAI,IAAI,YAAY;AACzD,OAAI,CAAC,UAAU,WACb,WAAU,aAAa,EAAE;AAE3B,aAAU,WAAW,KAAK,IAAI;;;CAKlC,MAAM,gCAAgB,IAAI,KAAuB;AAGjD,MAAK,MAAM,aAAa,YACtB,KAAI,UAAU,cAAc,UAAU,WAAW,SAAS,EAExD,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAK7D,MAAK,MAAM,aAAa,OAAO,KAAK,UAAU,CAC5C,KAAI,CAAC,cAAc,IAAI,UAAU,CAC/B,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAI7D,QAAO"}
1
+ {"version":3,"file":"definitions.js","names":[],"sources":["../../src/chunks/definitions.ts"],"sourcesContent":["/**\n * Style chunk definitions for CSS chunking optimization.\n *\n * Styles are grouped into chunks based on:\n * 1. Handler dependencies - styles that share a handler MUST be in the same chunk\n * 2. Logical grouping - related styles grouped for better cache reuse\n *\n * See STYLE_CHUNKING_SPEC.md for detailed rationale.\n *\n * ============================================================================\n * ⚠️ CRITICAL ARCHITECTURAL CONSTRAINT: NO CROSS-CHUNK HANDLER DEPENDENCIES\n * ============================================================================\n *\n * Style handlers declare their dependencies via `__lookupStyles` array.\n * This creates a dependency graph where handlers read multiple style props.\n *\n * **ALL styles in a handler's `__lookupStyles` MUST be in the SAME chunk.**\n *\n * Why this matters:\n * 1. Each chunk computes a cache key from ONLY its own style values\n * 2. If a handler reads a style from another chunk, that value isn't in the cache key\n * 3. Changing the cross-chunk style won't invalidate this chunk's cache\n * 4. Result: stale CSS output or incorrect cache hits\n *\n * Example of a violation:\n * ```\n * // flowStyle.__lookupStyles = ['display', 'flow']\n * // If 'display' is in DISPLAY chunk and 'flow' is in LAYOUT chunk:\n * // - User sets { display: 'grid', flow: 'column' }\n * // - LAYOUT chunk caches CSS with flow=column, display=grid\n * // - User changes to { display: 'flex', flow: 'column' }\n * // - LAYOUT chunk cache key unchanged (only has 'flow')\n * // - Returns stale CSS computed with display=grid!\n * ```\n *\n * Before adding/moving styles, verify:\n * 1. Find all handlers that use this style (grep for the style name in __lookupStyles)\n * 2. Ensure ALL styles from each handler's __lookupStyles are in the same chunk\n * ============================================================================\n */\n\nimport { isSelector } from '../pipeline';\n\n// ============================================================================\n// Chunk Style Lists\n// ============================================================================\n\n/**\n * Appearance chunk - visual styling with independent handlers\n */\nexport const APPEARANCE_CHUNK_STYLES = [\n 'fill', // fillStyle (independent)\n 'color', // colorStyle (independent)\n 'opacity', // independent\n 'border', // borderStyle (independent)\n 'radius', // radiusStyle (independent)\n 'outline', // outlineStyle: outline ↔ outlineOffset\n 'outlineOffset', // outlineStyle: outline ↔ outlineOffset\n 'shadow', // shadowStyle (independent)\n 'fade', // fadeStyle (independent)\n] as const;\n\n/**\n * Font chunk - typography styles\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ presetStyle: preset, fontSize, lineHeight, letterSpacing, textTransform,\n * fontWeight, fontStyle, font\n */\nexport const FONT_CHUNK_STYLES = [\n // All from presetStyle handler - MUST stay together\n 'preset',\n 'font',\n 'fontWeight',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textTransform',\n // Independent text styles grouped for cohesion\n 'fontFamily', // independent alias (logical grouping with font styles)\n 'textAlign',\n 'textDecoration',\n 'wordBreak',\n 'wordWrap',\n 'boldFontWeight',\n] as const;\n\n/**\n * Dimension chunk - sizing and spacing\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ paddingStyle: padding, paddingTop/Right/Bottom/Left, paddingBlock/Inline\n * ⚠️ marginStyle: margin, marginTop/Right/Bottom/Left, marginBlock/Inline\n * ⚠️ widthStyle: width, minWidth, maxWidth\n * ⚠️ heightStyle: height, minHeight, maxHeight\n */\nexport const DIMENSION_CHUNK_STYLES = [\n // All from paddingStyle handler - MUST stay together\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n // All from marginStyle handler - MUST stay together\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n // widthStyle handler - MUST stay together\n 'width',\n 'minWidth',\n 'maxWidth',\n // heightStyle handler - MUST stay together\n 'height',\n 'minHeight',\n 'maxHeight',\n 'flexBasis',\n 'flexGrow',\n 'flexShrink',\n 'flex',\n] as const;\n\n/**\n * Display chunk - display mode, layout flow, text overflow, and scrollbar\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ displayStyle: display, hide, textOverflow, overflow, whiteSpace\n * ⚠️ flowStyle: display, flow\n * ⚠️ gapStyle: display, flow, gap\n * ⚠️ scrollbarStyle: scrollbar, overflow\n */\nexport const DISPLAY_CHUNK_STYLES = [\n // displayStyle handler\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow', // also used by scrollbarStyle\n 'whiteSpace',\n // flowStyle handler (requires display)\n 'flow',\n // gapStyle handler (requires display, flow)\n 'gap',\n // scrollbarStyle handler (requires overflow)\n 'scrollbar',\n] as const;\n\n/**\n * Layout chunk - flex/grid alignment and grid templates\n *\n * Note: flow and gap are in DISPLAY chunk due to handler dependencies\n * (flowStyle and gapStyle both require 'display' prop).\n */\nexport const LAYOUT_CHUNK_STYLES = [\n // Alignment styles (all independent handlers)\n 'placeItems',\n 'placeContent',\n 'alignItems',\n 'alignContent',\n 'justifyItems',\n 'justifyContent',\n 'align', // placementStyle\n 'justify', // placementStyle\n 'place', // placementStyle\n 'columnGap',\n 'rowGap',\n // Grid template styles\n 'gridColumns',\n 'gridRows',\n 'gridTemplate',\n 'gridAreas',\n 'gridAutoFlow',\n 'gridAutoColumns',\n 'gridAutoRows',\n] as const;\n\n/**\n * Position chunk - element positioning\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ insetStyle: inset, insetBlock, insetInline, top, right, bottom, left\n */\nexport const POSITION_CHUNK_STYLES = [\n 'position',\n // All from insetStyle handler - MUST stay together\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'zIndex',\n 'gridArea',\n 'gridColumn',\n 'gridRow',\n 'order',\n 'placeSelf',\n 'alignSelf',\n 'justifySelf',\n 'transform',\n 'transition',\n 'animation',\n] as const;\n\n// ============================================================================\n// Chunk Names\n// ============================================================================\n\nexport const CHUNK_NAMES = {\n /** Special chunk for styles that cannot be split */\n COMBINED: 'combined',\n SUBCOMPONENTS: 'subcomponents',\n APPEARANCE: 'appearance',\n FONT: 'font',\n DIMENSION: 'dimension',\n DISPLAY: 'display',\n LAYOUT: 'layout',\n POSITION: 'position',\n MISC: 'misc',\n} as const;\n\nexport type ChunkName = (typeof CHUNK_NAMES)[keyof typeof CHUNK_NAMES];\n\n// ============================================================================\n// Style-to-Chunk Lookup Map (O(1) categorization)\n// ============================================================================\n\n/**\n * Pre-computed map for O(1) style-to-chunk lookup.\n * Built once at module load time.\n */\nexport const STYLE_TO_CHUNK = new Map<string, ChunkName>();\n\n// Populate the lookup map\nfunction populateStyleToChunkMap() {\n for (const style of APPEARANCE_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.APPEARANCE);\n }\n for (const style of FONT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.FONT);\n }\n for (const style of DIMENSION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DIMENSION);\n }\n for (const style of DISPLAY_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DISPLAY);\n }\n for (const style of LAYOUT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.LAYOUT);\n }\n for (const style of POSITION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.POSITION);\n }\n}\n\n// Initialize at module load\npopulateStyleToChunkMap();\n\n// ============================================================================\n// Chunk Priority Order\n// ============================================================================\n\n/**\n * Chunk processing order. This ensures deterministic className allocation\n * regardless of style key order in the input.\n */\nconst CHUNK_ORDER: readonly string[] = [\n CHUNK_NAMES.APPEARANCE,\n CHUNK_NAMES.FONT,\n CHUNK_NAMES.DIMENSION,\n CHUNK_NAMES.DISPLAY,\n CHUNK_NAMES.LAYOUT,\n CHUNK_NAMES.POSITION,\n CHUNK_NAMES.MISC,\n CHUNK_NAMES.SUBCOMPONENTS,\n] as const;\n\n/**\n * Map from chunk name to its priority index for sorting.\n */\nconst _CHUNK_PRIORITY = new Map<string, number>(\n CHUNK_ORDER.map((name, index) => [name, index]),\n);\n\n// ============================================================================\n// Chunk Info Interface\n// ============================================================================\n\nexport interface ChunkInfo {\n /** Name of the chunk */\n name: ChunkName | string;\n /** Style keys belonging to this chunk */\n styleKeys: string[];\n}\n\n// ============================================================================\n// Style Categorization\n// ============================================================================\n\n/**\n * Categorize style keys into chunks.\n *\n * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless\n * of the order of keys in the input styles object.\n *\n * @param styles - The styles object to categorize\n * @returns Map of chunk name to array of style keys in that chunk (in priority order)\n */\nexport function categorizeStyleKeys(\n styles: Record<string, unknown>,\n): Map<string, string[]> {\n // First pass: collect keys into chunks (unordered)\n const chunkData: Record<string, string[]> = {};\n const keys = Object.keys(styles);\n\n for (const key of keys) {\n // Skip the $ helper key (used for selector combinators)\n // Skip @keyframes and @properties (processed separately in useStyles)\n // Skip recipe (resolved before pipeline by resolveRecipes)\n if (\n key === '$' ||\n key === '@keyframes' ||\n key === '@properties' ||\n key === '@fontFace' ||\n key === '@counterStyle' ||\n key === 'recipe'\n ) {\n continue;\n }\n\n if (isSelector(key)) {\n // All selectors go into the subcomponents chunk\n if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) {\n chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];\n }\n chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);\n } else {\n // Look up the chunk for this style, default to misc\n const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;\n if (!chunkData[chunkName]) {\n chunkData[chunkName] = [];\n }\n chunkData[chunkName].push(key);\n }\n }\n\n // Second pass: build ordered Map based on CHUNK_ORDER\n const orderedChunks = new Map<string, string[]>();\n\n // Add chunks in priority order\n for (const chunkName of CHUNK_ORDER) {\n if (chunkData[chunkName] && chunkData[chunkName].length > 0) {\n // Sort keys within chunk for consistent cache key generation\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n // Handle any unknown chunks (shouldn't happen, but be defensive)\n for (const chunkName of Object.keys(chunkData)) {\n if (!orderedChunks.has(chunkName)) {\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n return orderedChunks;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,oBAAoB;CAE/B;CACA;CACA;CACA;CACA;CACA;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AY;CACb;AAKuB,IAAI,IAC1B,YAAY,KAAK,MAAM,UAAU,CAAC,MAAM,MAAM,CAAC,CAChD;;;;;;;;;;AA0BD,SAAgB,oBACd,QACuB;CAEvB,MAAM,YAAsC,EAAE;CAC9C,MAAM,OAAO,OAAO,KAAK,OAAO;AAEhC,MAAK,MAAM,OAAO,MAAM;AAItB,MACE,QAAQ,OACR,QAAQ,gBACR,QAAQ,iBACR,QAAQ,eACR,QAAQ,mBACR,QAAQ,SAER;AAGF,MAAI,WAAW,IAAI,EAAE;AAEnB,OAAI,CAAC,UAAU,YAAY,eACzB,WAAU,YAAY,iBAAiB,EAAE;AAE3C,aAAU,YAAY,eAAe,KAAK,IAAI;SACzC;GAEL,MAAM,YAAY,eAAe,IAAI,IAAI,IAAI,YAAY;AACzD,OAAI,CAAC,UAAU,WACb,WAAU,aAAa,EAAE;AAE3B,aAAU,WAAW,KAAK,IAAI;;;CAKlC,MAAM,gCAAgB,IAAI,KAAuB;AAGjD,MAAK,MAAM,aAAa,YACtB,KAAI,UAAU,cAAc,UAAU,WAAW,SAAS,EAExD,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAK7D,MAAK,MAAM,aAAa,OAAO,KAAK,UAAU,CAC5C,KAAI,CAAC,cAAc,IAAI,UAAU,CAC/B,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAI7D,QAAO"}
@@ -0,0 +1,31 @@
1
+ import { Styles } from "./styles/types.js";
2
+ import { ServerStyleCollector } from "./ssr/collector.js";
3
+
4
+ //#region src/compute-styles.d.ts
5
+ interface ComputeStylesResult {
6
+ className: string;
7
+ /** CSS text to emit as an inline <style> tag (RSC mode only). */
8
+ css?: string;
9
+ }
10
+ interface ComputeStylesOptions {
11
+ ssrCollector?: ServerStyleCollector | null;
12
+ }
13
+ /**
14
+ * Synchronous, hook-free style computation.
15
+ *
16
+ * Resolves recipes, categorizes style keys into chunks, renders CSS rules,
17
+ * allocates class names, and injects / collects / returns the CSS.
18
+ *
19
+ * Three code paths:
20
+ * 1. SSR collector — discovered via ALS or passed explicitly; CSS collected
21
+ * 2. RSC inline — no collector and no `document`; CSS returned as `result.css`
22
+ * for the caller to emit as an inline `<style>` tag
23
+ * 3. Client inject — CSS injected synchronously into the DOM (idempotent)
24
+ *
25
+ * @param styles - Tasty styles object (or undefined for no styles)
26
+ * @param options - Optional SSR collector override
27
+ */
28
+ declare function computeStyles(styles: Styles | undefined, options?: ComputeStylesOptions): ComputeStylesResult;
29
+ //#endregion
30
+ export { ComputeStylesOptions, ComputeStylesResult, computeStyles };
31
+ //# sourceMappingURL=compute-styles.d.ts.map
@@ -0,0 +1,335 @@
1
+ import { extractLocalProperties, hasLocalProperties } from "./properties/index.js";
2
+ import { extractLocalFontFace, fontFaceContentHash, formatFontFaceRule, hasLocalFontFace } from "./font-face/index.js";
3
+ import { extractLocalCounterStyle, formatCounterStyleRule, hasLocalCounterStyle } from "./counter-style/index.js";
4
+ import { renderStyles } from "./pipeline/index.js";
5
+ import { getConfig, getEffectiveProperties, getGlobalConfigTokens, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, hasGlobalKeyframes } from "./config.js";
6
+ import { categorizeStyleKeys } from "./chunks/definitions.js";
7
+ import { generateChunkCacheKey } from "./chunks/cacheKey.js";
8
+ import { renderStylesForChunk } from "./chunks/renderChunk.js";
9
+ import { counterStyle, fontFace, inject, keyframes, property, touch } from "./injector/index.js";
10
+ import { extractAnimationNamesFromStyles, extractLocalKeyframes, filterUsedKeyframes, hasLocalKeyframes, mergeKeyframes, replaceAnimationNames } from "./keyframes/index.js";
11
+ import { getRegisteredSSRCollector } from "./ssr/ssr-collector-ref.js";
12
+ import { flushPendingCSS, getRSCCache, rscAllocateClassName } from "./rsc-cache.js";
13
+ import { formatPropertyCSS } from "./ssr/format-property.js";
14
+ import { collectAutoInferredProperties } from "./ssr/collect-auto-properties.js";
15
+ import { formatGlobalRules } from "./ssr/format-global-rules.js";
16
+ import { formatKeyframesCSS } from "./ssr/format-keyframes.js";
17
+ import { formatRules } from "./ssr/format-rules.js";
18
+ import { hasKeys } from "./utils/has-keys.js";
19
+ import { resolveRecipes } from "./utils/resolve-recipes.js";
20
+ //#region src/compute-styles.ts
21
+ /**
22
+ * Hook-free, synchronous style computation.
23
+ *
24
+ * Extracts the core logic from useStyles() into a plain function that can
25
+ * be called during React render without any hooks. Three code paths:
26
+ *
27
+ * 1. SSR collector — styles collected via ServerStyleCollector
28
+ * 2. Client inject — styles injected synchronously into the DOM
29
+ * 3. RSC inline — styles returned as CSS strings for inline <style> emission
30
+ *
31
+ * This enables tasty() components to work as React Server Components.
32
+ */
33
+ const EMPTY_RESULT = { className: "" };
34
+ /**
35
+ * Collect internals CSS for RSC — mirrors ServerStyleCollector.collectInternals().
36
+ * Emitted once per request (tracked via rscCache.internalsEmitted).
37
+ */
38
+ function collectInternalsRSC(rscCache) {
39
+ if (rscCache.internalsEmitted) return "";
40
+ rscCache.internalsEmitted = true;
41
+ const parts = [];
42
+ for (const [token, definition] of Object.entries(getEffectiveProperties())) {
43
+ const css = formatPropertyCSS(token, definition);
44
+ if (css) parts.push(css);
45
+ }
46
+ const tokenStyles = getGlobalConfigTokens();
47
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
48
+ const tokenRules = renderStyles(tokenStyles, ":root");
49
+ if (tokenRules.length > 0) {
50
+ const css = formatGlobalRules(tokenRules);
51
+ if (css) parts.push(css);
52
+ }
53
+ }
54
+ const globalFF = getGlobalFontFace();
55
+ if (globalFF) for (const [family, input] of Object.entries(globalFF)) {
56
+ const descriptors = Array.isArray(input) ? input : [input];
57
+ for (const desc of descriptors) parts.push(formatFontFaceRule(family, desc));
58
+ }
59
+ const globalCS = getGlobalCounterStyle();
60
+ if (globalCS) for (const [name, descriptors] of Object.entries(globalCS)) parts.push(formatCounterStyleRule(name, descriptors));
61
+ return parts.join("\n");
62
+ }
63
+ /**
64
+ * Collect per-component ancillary CSS (keyframes, @property, font-face,
65
+ * counter-style) for RSC mode.
66
+ */
67
+ function collectAncillaryRSC(rscCache, styles) {
68
+ const parts = [];
69
+ const usedKf = getUsedKeyframes(styles);
70
+ if (usedKf) for (const [name, steps] of Object.entries(usedKf)) {
71
+ const key = `__kf:${name}:${JSON.stringify(steps)}`;
72
+ if (!rscCache.emittedKeys.has(key)) {
73
+ rscCache.emittedKeys.add(key);
74
+ parts.push(formatKeyframesCSS(name, steps));
75
+ }
76
+ }
77
+ if (hasLocalProperties(styles)) {
78
+ const localProperties = extractLocalProperties(styles);
79
+ if (localProperties) for (const [token, definition] of Object.entries(localProperties)) {
80
+ const key = `__prop:${token}`;
81
+ if (!rscCache.emittedKeys.has(key)) {
82
+ rscCache.emittedKeys.add(key);
83
+ const css = formatPropertyCSS(token, definition);
84
+ if (css) parts.push(css);
85
+ }
86
+ }
87
+ }
88
+ if (hasLocalFontFace(styles)) {
89
+ const localFontFace = extractLocalFontFace(styles);
90
+ if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
91
+ const descriptors = Array.isArray(input) ? input : [input];
92
+ for (const desc of descriptors) {
93
+ const key = `__ff:${fontFaceContentHash(family, desc)}`;
94
+ if (!rscCache.emittedKeys.has(key)) {
95
+ rscCache.emittedKeys.add(key);
96
+ parts.push(formatFontFaceRule(family, desc));
97
+ }
98
+ }
99
+ }
100
+ }
101
+ if (hasLocalCounterStyle(styles)) {
102
+ const localCounterStyle = extractLocalCounterStyle(styles);
103
+ if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) {
104
+ const key = `__cs:${name}:${JSON.stringify(descriptors)}`;
105
+ if (!rscCache.emittedKeys.has(key)) {
106
+ rscCache.emittedKeys.add(key);
107
+ parts.push(formatCounterStyleRule(name, descriptors));
108
+ }
109
+ }
110
+ }
111
+ return parts.join("\n");
112
+ }
113
+ /**
114
+ * Process all chunks in RSC mode: render CSS to strings, allocate classNames,
115
+ * and return combined { className, css }.
116
+ */
117
+ function computeStylesRSC(styles, chunkMap) {
118
+ const rscCache = getRSCCache();
119
+ const cssParts = [];
120
+ const classNames = [];
121
+ const pendingCSS = flushPendingCSS(rscCache);
122
+ if (pendingCSS) cssParts.push(pendingCSS);
123
+ const internalsCSS = collectInternalsRSC(rscCache);
124
+ if (internalsCSS) cssParts.push(internalsCSS);
125
+ for (const [chunkName, chunkStyleKeys] of chunkMap) {
126
+ if (chunkStyleKeys.length === 0) continue;
127
+ const { className, isNew } = rscAllocateClassName(rscCache, generateChunkCacheKey(styles, chunkName, chunkStyleKeys));
128
+ classNames.push(className);
129
+ if (isNew) {
130
+ const renderResult = renderStylesForChunk(styles, chunkName, chunkStyleKeys);
131
+ if (renderResult.rules.length > 0) {
132
+ const css = formatRules(renderResult.rules, className);
133
+ if (css) cssParts.push(css);
134
+ }
135
+ }
136
+ }
137
+ const ancillaryCSS = collectAncillaryRSC(rscCache, styles);
138
+ if (ancillaryCSS) cssParts.push(ancillaryCSS);
139
+ if (classNames.length === 0) return EMPTY_RESULT;
140
+ const css = cssParts.join("\n");
141
+ return {
142
+ className: classNames.join(" "),
143
+ css: css || void 0
144
+ };
145
+ }
146
+ /**
147
+ * Get keyframes that are actually used in styles.
148
+ * Returns null if no keyframes are used (fast path for zero overhead).
149
+ */
150
+ function getUsedKeyframes(styles) {
151
+ const hasLocal = hasLocalKeyframes(styles);
152
+ const hasGlobal = hasGlobalKeyframes();
153
+ if (!hasLocal && !hasGlobal) return null;
154
+ const usedNames = extractAnimationNamesFromStyles(styles);
155
+ if (usedNames.size === 0) return null;
156
+ return filterUsedKeyframes(mergeKeyframes(hasLocal ? extractLocalKeyframes(styles) : null, hasGlobal ? getGlobalKeyframes() : null), usedNames);
157
+ }
158
+ /**
159
+ * Process a chunk on the SSR path: allocate via collector, render, collect CSS.
160
+ */
161
+ function processChunkSSR(collector, styles, chunkName, styleKeys) {
162
+ if (styleKeys.length === 0) return null;
163
+ const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
164
+ const { className, isNewAllocation } = collector.allocateClassName(cacheKey);
165
+ if (isNewAllocation) {
166
+ const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);
167
+ if (renderResult.rules.length > 0) {
168
+ collector.collectChunk(cacheKey, className, renderResult.rules);
169
+ return {
170
+ name: chunkName,
171
+ styleKeys,
172
+ cacheKey,
173
+ renderResult,
174
+ className
175
+ };
176
+ }
177
+ return null;
178
+ }
179
+ return {
180
+ name: chunkName,
181
+ styleKeys,
182
+ cacheKey,
183
+ renderResult: { rules: [] },
184
+ className
185
+ };
186
+ }
187
+ /**
188
+ * Process a chunk on the client: render, allocate className, and inject
189
+ * CSS synchronously. The injector's cache makes this idempotent.
190
+ */
191
+ function processChunkSync(styles, chunkName, styleKeys) {
192
+ if (styleKeys.length === 0) return null;
193
+ const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
194
+ const renderResult = renderStylesForChunk(styles, chunkName, styleKeys, cacheKey);
195
+ if (renderResult.rules.length === 0) return null;
196
+ const { className } = inject(renderResult.rules, { cacheKey });
197
+ return {
198
+ name: chunkName,
199
+ styleKeys,
200
+ cacheKey,
201
+ renderResult,
202
+ className
203
+ };
204
+ }
205
+ /**
206
+ * Inject keyframes synchronously and return a name replacement map.
207
+ * On the client, keyframes are injected into the DOM.
208
+ */
209
+ function injectKeyframesSync(usedKeyframes) {
210
+ let nameMap = null;
211
+ for (const [name, steps] of Object.entries(usedKeyframes)) {
212
+ const injectedName = keyframes(steps, { name }).toString();
213
+ if (injectedName !== name) {
214
+ if (!nameMap) nameMap = /* @__PURE__ */ new Map();
215
+ nameMap.set(name, injectedName);
216
+ }
217
+ }
218
+ return nameMap;
219
+ }
220
+ /**
221
+ * Inject chunk rules synchronously, replacing animation names if needed.
222
+ */
223
+ function injectChunkRulesSync(chunks, nameMap) {
224
+ for (const chunk of chunks) if (chunk.renderResult.rules.length > 0) inject(nameMap ? chunk.renderResult.rules.map((rule) => ({
225
+ ...rule,
226
+ declarations: replaceAnimationNames(rule.declarations, nameMap)
227
+ })) : chunk.renderResult.rules, { cacheKey: chunk.cacheKey });
228
+ }
229
+ /**
230
+ * Inject all ancillary rules (properties, font-faces, counter-styles) synchronously.
231
+ */
232
+ function injectAncillarySync(styles) {
233
+ if (hasLocalProperties(styles)) {
234
+ const localProperties = extractLocalProperties(styles);
235
+ if (localProperties) for (const [token, definition] of Object.entries(localProperties)) property(token, definition);
236
+ }
237
+ if (hasLocalFontFace(styles)) {
238
+ const localFontFace = extractLocalFontFace(styles);
239
+ if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
240
+ const descriptors = Array.isArray(input) ? input : [input];
241
+ for (const desc of descriptors) fontFace(family, desc);
242
+ }
243
+ }
244
+ if (hasLocalCounterStyle(styles)) {
245
+ const localCounterStyle = extractLocalCounterStyle(styles);
246
+ if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) counterStyle(name, descriptors);
247
+ }
248
+ }
249
+ /**
250
+ * Collect all ancillary rules into the SSR collector.
251
+ */
252
+ function collectAncillarySSR(collector, styles, chunks) {
253
+ const usedKf = getUsedKeyframes(styles);
254
+ if (usedKf) for (const [name, steps] of Object.entries(usedKf)) {
255
+ const css = formatKeyframesCSS(name, steps);
256
+ collector.collectKeyframes(name, css);
257
+ }
258
+ if (hasLocalProperties(styles)) {
259
+ const localProperties = extractLocalProperties(styles);
260
+ if (localProperties) for (const [token, definition] of Object.entries(localProperties)) {
261
+ const css = formatPropertyCSS(token, definition);
262
+ if (css) collector.collectProperty(token, css);
263
+ }
264
+ }
265
+ if (hasLocalFontFace(styles)) {
266
+ const localFontFace = extractLocalFontFace(styles);
267
+ if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
268
+ const descriptors = Array.isArray(input) ? input : [input];
269
+ for (const desc of descriptors) {
270
+ const hash = fontFaceContentHash(family, desc);
271
+ const css = formatFontFaceRule(family, desc);
272
+ collector.collectFontFace(hash, css);
273
+ }
274
+ }
275
+ }
276
+ if (hasLocalCounterStyle(styles)) {
277
+ const localCounterStyle = extractLocalCounterStyle(styles);
278
+ if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) {
279
+ const css = formatCounterStyleRule(name, descriptors);
280
+ collector.collectCounterStyle(name, css);
281
+ }
282
+ }
283
+ if (getConfig().autoPropertyTypes !== false) {
284
+ const allRules = chunks.flatMap((c) => c.renderResult.rules);
285
+ if (allRules.length > 0) collectAutoInferredProperties(allRules, collector, styles);
286
+ }
287
+ }
288
+ /**
289
+ * Synchronous, hook-free style computation.
290
+ *
291
+ * Resolves recipes, categorizes style keys into chunks, renders CSS rules,
292
+ * allocates class names, and injects / collects / returns the CSS.
293
+ *
294
+ * Three code paths:
295
+ * 1. SSR collector — discovered via ALS or passed explicitly; CSS collected
296
+ * 2. RSC inline — no collector and no `document`; CSS returned as `result.css`
297
+ * for the caller to emit as an inline `<style>` tag
298
+ * 3. Client inject — CSS injected synchronously into the DOM (idempotent)
299
+ *
300
+ * @param styles - Tasty styles object (or undefined for no styles)
301
+ * @param options - Optional SSR collector override
302
+ */
303
+ function computeStyles(styles, options) {
304
+ if (!styles || !hasKeys(styles)) return EMPTY_RESULT;
305
+ const resolved = resolveRecipes(styles);
306
+ const chunkMap = categorizeStyleKeys(resolved);
307
+ const collector = options?.ssrCollector !== void 0 ? options.ssrCollector : getRegisteredSSRCollector();
308
+ const chunks = [];
309
+ if (collector) {
310
+ collector.collectInternals();
311
+ for (const [chunkName, chunkStyleKeys] of chunkMap) {
312
+ const chunk = processChunkSSR(collector, resolved, chunkName, chunkStyleKeys);
313
+ if (chunk) chunks.push(chunk);
314
+ }
315
+ collectAncillarySSR(collector, resolved, chunks);
316
+ } else if (typeof document === "undefined") return computeStylesRSC(resolved, chunkMap);
317
+ else {
318
+ injectAncillarySync(resolved);
319
+ const usedKf = getUsedKeyframes(resolved);
320
+ const nameMap = usedKf ? injectKeyframesSync(usedKf) : null;
321
+ for (const [chunkName, chunkStyleKeys] of chunkMap) {
322
+ const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys);
323
+ if (chunk) chunks.push(chunk);
324
+ }
325
+ if (nameMap) injectChunkRulesSync(chunks, nameMap);
326
+ for (const chunk of chunks) touch(chunk.className);
327
+ }
328
+ if (chunks.length === 0) return EMPTY_RESULT;
329
+ if (chunks.length === 1) return { className: chunks[0].className };
330
+ return { className: chunks.map((c) => c.className).join(" ") };
331
+ }
332
+ //#endregion
333
+ export { computeStyles };
334
+
335
+ //# sourceMappingURL=compute-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-styles.js","names":[],"sources":["../src/compute-styles.ts"],"sourcesContent":["/**\n * Hook-free, synchronous style computation.\n *\n * Extracts the core logic from useStyles() into a plain function that can\n * be called during React render without any hooks. Three code paths:\n *\n * 1. SSR collector — styles collected via ServerStyleCollector\n * 2. Client inject — styles injected synchronously into the DOM\n * 3. RSC inline — styles returned as CSS strings for inline <style> emission\n *\n * This enables tasty() components to work as React Server Components.\n */\n\nimport {\n categorizeStyleKeys,\n generateChunkCacheKey,\n renderStylesForChunk,\n} from './chunks';\nimport {\n getConfig,\n getGlobalConfigTokens,\n getGlobalCounterStyle,\n getEffectiveProperties,\n getGlobalFontFace,\n getGlobalKeyframes,\n hasGlobalKeyframes,\n} from './config';\nimport {\n counterStyle,\n fontFace,\n inject,\n keyframes,\n property,\n touch,\n} from './injector';\nimport type { FontFaceDescriptors, KeyframesSteps } from './injector/types';\nimport {\n extractLocalCounterStyle,\n formatCounterStyleRule,\n hasLocalCounterStyle,\n} from './counter-style';\nimport {\n extractLocalFontFace,\n fontFaceContentHash,\n formatFontFaceRule,\n hasLocalFontFace,\n} from './font-face';\nimport {\n extractAnimationNamesFromStyles,\n extractLocalKeyframes,\n filterUsedKeyframes,\n hasLocalKeyframes,\n mergeKeyframes,\n replaceAnimationNames,\n} from './keyframes';\nimport type { RenderResult, StyleResult } from './pipeline';\nimport { renderStyles } from './pipeline';\nimport {\n flushPendingCSS,\n getRSCCache,\n rscAllocateClassName,\n} from './rsc-cache';\nimport type { RSCStyleCache } from './rsc-cache';\nimport { extractLocalProperties, hasLocalProperties } from './properties';\nimport { collectAutoInferredProperties } from './ssr/collect-auto-properties';\nimport type { ServerStyleCollector } from './ssr/collector';\nimport { formatGlobalRules } from './ssr/format-global-rules';\nimport { formatKeyframesCSS } from './ssr/format-keyframes';\nimport { formatPropertyCSS } from './ssr/format-property';\nimport { formatRules } from './ssr/format-rules';\nimport { getRegisteredSSRCollector } from './ssr/ssr-collector-ref';\nimport type { Styles } from './styles/types';\nimport { hasKeys } from './utils/has-keys';\nimport { resolveRecipes } from './utils/resolve-recipes';\n\nexport interface ComputeStylesResult {\n className: string;\n /** CSS text to emit as an inline <style> tag (RSC mode only). */\n css?: string;\n}\n\nexport interface ComputeStylesOptions {\n ssrCollector?: ServerStyleCollector | null;\n}\n\ninterface ProcessedChunk {\n name: string;\n styleKeys: string[];\n cacheKey: string;\n renderResult: RenderResult;\n className: string;\n}\n\nconst EMPTY_RESULT: ComputeStylesResult = { className: '' };\n\n// ---------------------------------------------------------------------------\n// RSC (React Server Components) inline style support\n// ---------------------------------------------------------------------------\n\n/**\n * Collect internals CSS for RSC — mirrors ServerStyleCollector.collectInternals().\n * Emitted once per request (tracked via rscCache.internalsEmitted).\n */\nfunction collectInternalsRSC(rscCache: RSCStyleCache): string {\n if (rscCache.internalsEmitted) return '';\n rscCache.internalsEmitted = true;\n\n const parts: string[] = [];\n\n for (const [token, definition] of Object.entries(getEffectiveProperties())) {\n const css = formatPropertyCSS(token, definition);\n if (css) parts.push(css);\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) parts.push(css);\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n parts.push(formatFontFaceRule(family, desc));\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n parts.push(formatCounterStyleRule(name, descriptors));\n }\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Collect per-component ancillary CSS (keyframes, @property, font-face,\n * counter-style) for RSC mode.\n */\nfunction collectAncillaryRSC(rscCache: RSCStyleCache, styles: Styles): string {\n const parts: string[] = [];\n\n const usedKf = getUsedKeyframes(styles);\n if (usedKf) {\n for (const [name, steps] of Object.entries(usedKf)) {\n const key = `__kf:${name}:${JSON.stringify(steps)}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatKeyframesCSS(name, steps));\n }\n }\n }\n\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n const key = `__prop:${token}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n const css = formatPropertyCSS(token, definition);\n if (css) parts.push(css);\n }\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const key = `__ff:${hash}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatFontFaceRule(family, desc));\n }\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n const key = `__cs:${name}:${JSON.stringify(descriptors)}`;\n if (!rscCache.emittedKeys.has(key)) {\n rscCache.emittedKeys.add(key);\n parts.push(formatCounterStyleRule(name, descriptors));\n }\n }\n }\n }\n\n return parts.join('\\n');\n}\n\n/**\n * Process all chunks in RSC mode: render CSS to strings, allocate classNames,\n * and return combined { className, css }.\n */\nfunction computeStylesRSC(\n styles: Styles,\n chunkMap: Map<string, string[]>,\n): ComputeStylesResult {\n const rscCache = getRSCCache();\n const cssParts: string[] = [];\n const classNames: string[] = [];\n\n // Flush CSS accumulated by standalone style functions\n const pendingCSS = flushPendingCSS(rscCache);\n if (pendingCSS) cssParts.push(pendingCSS);\n\n const internalsCSS = collectInternalsRSC(rscCache);\n if (internalsCSS) cssParts.push(internalsCSS);\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n if (chunkStyleKeys.length === 0) continue;\n\n const cacheKey = generateChunkCacheKey(styles, chunkName, chunkStyleKeys);\n const { className, isNew } = rscAllocateClassName(rscCache, cacheKey);\n classNames.push(className);\n\n if (isNew) {\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n chunkStyleKeys,\n );\n if (renderResult.rules.length > 0) {\n const css = formatRules(renderResult.rules, className);\n if (css) cssParts.push(css);\n }\n }\n }\n\n const ancillaryCSS = collectAncillaryRSC(rscCache, styles);\n if (ancillaryCSS) cssParts.push(ancillaryCSS);\n\n if (classNames.length === 0) return EMPTY_RESULT;\n\n const css = cssParts.join('\\n');\n\n return {\n className: classNames.join(' '),\n css: css || undefined,\n };\n}\n\n/**\n * Get keyframes that are actually used in styles.\n * Returns null if no keyframes are used (fast path for zero overhead).\n */\nfunction getUsedKeyframes(\n styles: Styles,\n): Record<string, KeyframesSteps> | null {\n const hasLocal = hasLocalKeyframes(styles);\n const hasGlobal = hasGlobalKeyframes();\n if (!hasLocal && !hasGlobal) return null;\n\n const usedNames = extractAnimationNamesFromStyles(styles);\n if (usedNames.size === 0) return null;\n\n const local = hasLocal ? extractLocalKeyframes(styles) : null;\n const global = hasGlobal ? getGlobalKeyframes() : null;\n const allKeyframes = mergeKeyframes(local, global);\n\n return filterUsedKeyframes(allKeyframes, usedNames);\n}\n\n/**\n * Process a chunk on the SSR path: allocate via collector, render, collect CSS.\n */\nfunction processChunkSSR(\n collector: ServerStyleCollector,\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);\n const { className, isNewAllocation } = collector.allocateClassName(cacheKey);\n\n if (isNewAllocation) {\n const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);\n if (renderResult.rules.length > 0) {\n collector.collectChunk(cacheKey, className, renderResult.rules);\n return { name: chunkName, styleKeys, cacheKey, renderResult, className };\n }\n return null;\n }\n\n return {\n name: chunkName,\n styleKeys,\n cacheKey,\n renderResult: { rules: [] },\n className,\n };\n}\n\n/**\n * Process a chunk on the client: render, allocate className, and inject\n * CSS synchronously. The injector's cache makes this idempotent.\n */\nfunction processChunkSync(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n styleKeys,\n cacheKey,\n );\n if (renderResult.rules.length === 0) return null;\n\n const { className } = inject(renderResult.rules, { cacheKey });\n\n return { name: chunkName, styleKeys, cacheKey, renderResult, className };\n}\n\n/**\n * Inject keyframes synchronously and return a name replacement map.\n * On the client, keyframes are injected into the DOM.\n */\nfunction injectKeyframesSync(\n usedKeyframes: Record<string, KeyframesSteps>,\n): Map<string, string> | null {\n let nameMap: Map<string, string> | null = null;\n\n for (const [name, steps] of Object.entries(usedKeyframes)) {\n const result = keyframes(steps, { name });\n const injectedName = result.toString();\n if (injectedName !== name) {\n if (!nameMap) nameMap = new Map();\n nameMap.set(name, injectedName);\n }\n }\n\n return nameMap;\n}\n\n/**\n * Inject chunk rules synchronously, replacing animation names if needed.\n */\nfunction injectChunkRulesSync(\n chunks: ProcessedChunk[],\n nameMap: Map<string, string> | null,\n): void {\n for (const chunk of chunks) {\n if (chunk.renderResult.rules.length > 0) {\n const rulesToInject: StyleResult[] = nameMap\n ? chunk.renderResult.rules.map((rule) => ({\n ...rule,\n declarations: replaceAnimationNames(rule.declarations, nameMap!),\n }))\n : chunk.renderResult.rules;\n\n inject(rulesToInject, { cacheKey: chunk.cacheKey });\n }\n }\n}\n\n/**\n * Inject all ancillary rules (properties, font-faces, counter-styles) synchronously.\n */\nfunction injectAncillarySync(styles: Styles): void {\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n property(token, definition);\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n fontFace(family, desc);\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n counterStyle(name, descriptors);\n }\n }\n }\n}\n\n/**\n * Collect all ancillary rules into the SSR collector.\n */\nfunction collectAncillarySSR(\n collector: ServerStyleCollector,\n styles: Styles,\n chunks: ProcessedChunk[],\n): void {\n const usedKf = getUsedKeyframes(styles);\n if (usedKf) {\n for (const [name, steps] of Object.entries(usedKf)) {\n const css = formatKeyframesCSS(name, steps);\n collector.collectKeyframes(name, css);\n }\n }\n\n if (hasLocalProperties(styles)) {\n const localProperties = extractLocalProperties(styles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n collector.collectProperty(token, css);\n }\n }\n }\n }\n\n if (hasLocalFontFace(styles)) {\n const localFontFace = extractLocalFontFace(styles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n collector.collectFontFace(hash, css);\n }\n }\n }\n }\n\n if (hasLocalCounterStyle(styles)) {\n const localCounterStyle = extractLocalCounterStyle(styles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n const css = formatCounterStyleRule(name, descriptors);\n collector.collectCounterStyle(name, css);\n }\n }\n }\n\n if (getConfig().autoPropertyTypes !== false) {\n const allRules = chunks.flatMap((c) => c.renderResult.rules);\n if (allRules.length > 0) {\n collectAutoInferredProperties(allRules, collector, styles);\n }\n }\n}\n\n/**\n * Synchronous, hook-free style computation.\n *\n * Resolves recipes, categorizes style keys into chunks, renders CSS rules,\n * allocates class names, and injects / collects / returns the CSS.\n *\n * Three code paths:\n * 1. SSR collector — discovered via ALS or passed explicitly; CSS collected\n * 2. RSC inline — no collector and no `document`; CSS returned as `result.css`\n * for the caller to emit as an inline `<style>` tag\n * 3. Client inject — CSS injected synchronously into the DOM (idempotent)\n *\n * @param styles - Tasty styles object (or undefined for no styles)\n * @param options - Optional SSR collector override\n */\nexport function computeStyles(\n styles: Styles | undefined,\n options?: ComputeStylesOptions,\n): ComputeStylesResult {\n if (!styles || !hasKeys(styles as Record<string, unknown>)) {\n return EMPTY_RESULT;\n }\n\n const resolved = resolveRecipes(styles);\n const chunkMap = categorizeStyleKeys(resolved as Record<string, unknown>);\n\n const collector =\n options?.ssrCollector !== undefined\n ? options.ssrCollector\n : getRegisteredSSRCollector();\n\n const chunks: ProcessedChunk[] = [];\n\n if (collector) {\n collector.collectInternals();\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunkSSR(\n collector,\n resolved,\n chunkName,\n chunkStyleKeys,\n );\n if (chunk) chunks.push(chunk);\n }\n\n collectAncillarySSR(collector, resolved, chunks);\n } else if (typeof document === 'undefined') {\n // RSC path: render CSS to strings for inline <style> emission\n return computeStylesRSC(resolved, chunkMap);\n } else {\n injectAncillarySync(resolved);\n\n const usedKf = getUsedKeyframes(resolved);\n const nameMap = usedKf ? injectKeyframesSync(usedKf) : null;\n\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunkSync(resolved, chunkName, chunkStyleKeys);\n if (chunk) chunks.push(chunk);\n }\n\n if (nameMap) {\n injectChunkRulesSync(chunks, nameMap);\n }\n\n for (const chunk of chunks) {\n touch(chunk.className);\n }\n }\n\n if (chunks.length === 0) return EMPTY_RESULT;\n if (chunks.length === 1) return { className: chunks[0].className };\n\n return { className: chunks.map((c) => c.className).join(' ') };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,MAAM,eAAoC,EAAE,WAAW,IAAI;;;;;AAU3D,SAAS,oBAAoB,UAAiC;AAC5D,KAAI,SAAS,iBAAkB,QAAO;AACtC,UAAS,mBAAmB;CAE5B,MAAM,QAAkB,EAAE;AAE1B,MAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QAAQ,wBAAwB,CAAC,EAAE;EAC1E,MAAM,MAAM,kBAAkB,OAAO,WAAW;AAChD,MAAI,IAAK,OAAM,KAAK,IAAI;;CAG1B,MAAM,cAAc,uBAAuB;AAC3C,KAAI,eAAe,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;EACtD,MAAM,aAAa,aAAa,aAAa,QAAQ;AACrD,MAAI,WAAW,SAAS,GAAG;GACzB,MAAM,MAAM,kBAAkB,WAAW;AACzC,OAAI,IAAK,OAAM,KAAK,IAAI;;;CAI5B,MAAM,WAAW,mBAAmB;AACpC,KAAI,SACF,MAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,SAAS,EAAE;EACtD,MAAM,cAAqC,MAAM,QAAQ,MAAM,GAC3D,QACA,CAAC,MAAM;AACX,OAAK,MAAM,QAAQ,YACjB,OAAM,KAAK,mBAAmB,QAAQ,KAAK,CAAC;;CAKlD,MAAM,WAAW,uBAAuB;AACxC,KAAI,SACF,MAAK,MAAM,CAA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K,MAAM,CAAC,WAAW,mBAAmB,UAAU;GAClD,MAAM,QAAQ,gBACZ,WACA,UACA,WACA,eACD;AACD,OAAI,MAAO,QAAO,KAAK,MAAM;;AAG/B,sBAAoB,WAAW,UAAU,OAAO;YACvC,OAAO,aAAa,YAE7B,QAAO,iBAAiB,UAAU,SAAS;MACtC;AACL,sBAAoB,SAAS;EAE7B,MAAM,SAAS,iBAAiB,SAAS;EACzC,MAAM,UAAU,SAAS,oBAAoB,OAAO,GAAG;AAEvD,OAAK,MAAM,CAAC,WAAW,mBAAmB,UAAU;GAClD,MAAM,QAAQ,iBAAiB,UAAU,WAAW,eAAe;AACnE,OAAI,MAAO,QAAO,KAAK,MAAM;;AAG/B,MAAI,QACF,sBAAqB,QAAQ,QAAQ;AAGvC,OAAK,MAAM,SAAS,OAClB,OAAM,MAAM,UAAU;;AAI1B,KAAI,OAAO,WAAW,EAAG,QAAO;AAChC,KAAI,OAAO,WAAW,EAAG,QAAO,EAAE,WAAW,OAAO,GAAG,WAAW;AAElE,QAAO,EAAE,WAAW,OAAO,KAAK,MAAM,EAAE,UAAU,CAAC,KAAK,IAAI,EAAE"}
package/dist/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps, PropertyDefinition } from "./injector/types.js";
1
+ import { CounterStyleDescriptors, FontFaceInput, GCConfig, KeyframesSteps, PropertyDefinition } from "./injector/types.js";
2
2
  import { StyleDetails, UnitHandler } from "./parser/types.js";
3
3
  import { StyleHandlerDefinition } from "./utils/styles.js";
4
4
  import { ConfigTokens, RecipeStyles } from "./styles/types.js";
@@ -15,27 +15,10 @@ interface TastyConfig {
15
15
  nonce?: string;
16
16
  /** Maximum rules per stylesheet (default: 8192) */
17
17
  maxRulesPerSheet?: number;
18
- /** Threshold for bulk cleanup of unused styles (default: 500) */
19
- unusedStylesThreshold?: number;
20
- /** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
21
- bulkCleanupDelay?: number;
22
- /** Use requestIdleCallback for cleanup when available (default: true) */
23
- idleCleanup?: boolean;
24
18
  /** Force text injection mode, auto-detected in test environments (default: auto) */
25
19
  forceTextInjection?: boolean;
26
20
  /** Enable development mode features: performance metrics and debug info (default: auto) */
27
21
  devMode?: boolean;
28
- /**
29
- * Ratio of unused styles to delete per bulk cleanup run (0..1).
30
- * Defaults to 0.5 (oldest half) to reduce risk of removing styles
31
- * that may be restored shortly after being marked unused.
32
- */
33
- bulkCleanupBatchRatio?: number;
34
- /**
35
- * Minimum age (in ms) a style must remain unused before eligible for deletion.
36
- * Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
37
- */
38
- unusedStylesMinAgeMs?: number;
39
22
  /**
40
23
  * Global predefined states for advanced state mapping.
41
24
  * These are state aliases that can be used in any component.
@@ -78,6 +61,18 @@ interface TastyConfig {
78
61
  * @default true
79
62
  */
80
63
  autoPropertyTypes?: boolean;
64
+ /**
65
+ * Garbage collection configuration for unused styles.
66
+ * GC is triggered by touch count: every `touchInterval` touches, the
67
+ * oldest unused styles are evicted when their count exceeds `capacity`.
68
+ * @example
69
+ * ```ts
70
+ * configure({
71
+ * gc: { touchInterval: 1000, capacity: 1000 },
72
+ * });
73
+ * ```
74
+ */
75
+ gc?: GCConfig;
81
76
  /**
82
77
  * Plugins that extend tasty with custom functions, units, or states.
83
78
  * Plugins are processed in order, with later plugins overriding earlier ones.
@@ -109,7 +104,11 @@ interface TastyConfig {
109
104
  /**
110
105
  * Global CSS @property definitions for custom properties.
111
106
  * Keys use tasty token syntax ($name for properties, #name for colors).
112
- * Properties are only injected when the component using them is rendered.
107
+ *
108
+ * Tasty ships with `DEFAULT_PROPERTIES` (e.g. `$gap`, `$radius`, `#white`,
109
+ * `#black`, `#clear`, `#border`, etc.) that are always included.
110
+ * Properties you specify here are merged on top, so you can override any
111
+ * default by using the same key.
113
112
  *
114
113
  * For color tokens (#name), `syntax: '<color>'` is auto-set and
115
114
  * `initialValue` defaults to `'transparent'` if not specified.
@@ -121,6 +120,8 @@ interface TastyConfig {
121
120
  * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
122
121
  * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
123
122
  * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
123
+ * // Override a default property:
124
+ * '$gap': { syntax: '<length>', inherits: true, initialValue: '8px' },
124
125
  * },
125
126
  * });
126
127
  *