@tenphi/tasty 2.0.3 → 2.0.4

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 (322) hide show
  1. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
  2. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  3. package/dist/{ssr/collector.d.ts → collector-CkZ517g4.d.ts} +3 -3
  4. package/dist/{ssr/collector.js → collector-DXqvGOb1.js} +5 -10
  5. package/dist/collector-DXqvGOb1.js.map +1 -0
  6. package/dist/config-5jzS6k6B.js +10005 -0
  7. package/dist/config-5jzS6k6B.js.map +1 -0
  8. package/dist/config-DknGsfMo.d.ts +857 -0
  9. package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
  10. package/dist/context-CkSg-kDT.js.map +1 -0
  11. package/dist/core/index.d.ts +5 -34
  12. package/dist/core/index.js +5 -26
  13. package/dist/core-CtU6-9OC.js +1507 -0
  14. package/dist/core-CtU6-9OC.js.map +1 -0
  15. package/dist/{zero/extractor.js → css-writer-DHkX0JuE.js} +74 -11
  16. package/dist/css-writer-DHkX0JuE.js.map +1 -0
  17. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  18. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  19. package/dist/format-rules-DH13ewDu.js +143 -0
  20. package/dist/format-rules-DH13ewDu.js.map +1 -0
  21. package/dist/{ssr/hydrate.js → hydrate-C1Gv-DoS.js} +3 -3
  22. package/dist/hydrate-C1Gv-DoS.js.map +1 -0
  23. package/dist/{styles/types.d.ts → index-PzENbpAq.d.ts} +701 -5
  24. package/dist/index-o7zV2yCr.d.ts +1561 -0
  25. package/dist/index.d.ts +5 -51
  26. package/dist/index.js +728 -35
  27. package/dist/index.js.map +1 -0
  28. package/dist/keyframes-b7X3UxDV.js +587 -0
  29. package/dist/keyframes-b7X3UxDV.js.map +1 -0
  30. package/dist/{utils/merge-styles.d.ts → merge-styles-C7KTy7MY.d.ts} +3 -3
  31. package/dist/{utils/merge-styles.js → merge-styles-Tgo3BbL2.js} +3 -4
  32. package/dist/merge-styles-Tgo3BbL2.js.map +1 -0
  33. package/dist/{utils/resolve-recipes.js → resolve-recipes-Ca2-5CxM.js} +4 -6
  34. package/dist/resolve-recipes-Ca2-5CxM.js.map +1 -0
  35. package/dist/ssr/astro-client.js +1 -1
  36. package/dist/ssr/astro.js +4 -4
  37. package/dist/ssr/index.d.ts +44 -4
  38. package/dist/ssr/index.js +4 -4
  39. package/dist/ssr/next.d.ts +1 -1
  40. package/dist/ssr/next.js +6 -6
  41. package/dist/ssr/next.js.map +1 -1
  42. package/dist/static/index.d.ts +91 -5
  43. package/dist/static/index.js +49 -3
  44. package/dist/static/index.js.map +1 -0
  45. package/dist/zero/babel.d.ts +1 -1
  46. package/dist/zero/babel.js +10 -6
  47. package/dist/zero/babel.js.map +1 -1
  48. package/dist/zero/index.d.ts +67 -3
  49. package/dist/zero/index.js +1 -2
  50. package/package.json +3 -3
  51. package/dist/_virtual/_rolldown/runtime.js +0 -7
  52. package/dist/chunks/cacheKey.d.ts +0 -1
  53. package/dist/chunks/cacheKey.js +0 -77
  54. package/dist/chunks/cacheKey.js.map +0 -1
  55. package/dist/chunks/definitions.d.ts +0 -37
  56. package/dist/chunks/definitions.js +0 -258
  57. package/dist/chunks/definitions.js.map +0 -1
  58. package/dist/chunks/index.d.ts +0 -1
  59. package/dist/chunks/renderChunk.d.ts +0 -1
  60. package/dist/chunks/renderChunk.js +0 -59
  61. package/dist/chunks/renderChunk.js.map +0 -1
  62. package/dist/compute-styles.d.ts +0 -31
  63. package/dist/compute-styles.js +0 -322
  64. package/dist/compute-styles.js.map +0 -1
  65. package/dist/config.d.ts +0 -407
  66. package/dist/config.js +0 -591
  67. package/dist/config.js.map +0 -1
  68. package/dist/counter-style/index.js +0 -51
  69. package/dist/counter-style/index.js.map +0 -1
  70. package/dist/debug.d.ts +0 -89
  71. package/dist/debug.js +0 -453
  72. package/dist/debug.js.map +0 -1
  73. package/dist/font-face/index.js +0 -63
  74. package/dist/font-face/index.js.map +0 -1
  75. package/dist/hooks/index.d.ts +0 -7
  76. package/dist/hooks/useCounterStyle.d.ts +0 -36
  77. package/dist/hooks/useCounterStyle.js +0 -65
  78. package/dist/hooks/useCounterStyle.js.map +0 -1
  79. package/dist/hooks/useFontFace.d.ts +0 -45
  80. package/dist/hooks/useFontFace.js +0 -66
  81. package/dist/hooks/useFontFace.js.map +0 -1
  82. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  83. package/dist/hooks/useGlobalStyles.js +0 -88
  84. package/dist/hooks/useGlobalStyles.js.map +0 -1
  85. package/dist/hooks/useKeyframes.d.ts +0 -58
  86. package/dist/hooks/useKeyframes.js +0 -55
  87. package/dist/hooks/useKeyframes.js.map +0 -1
  88. package/dist/hooks/useProperty.d.ts +0 -81
  89. package/dist/hooks/useProperty.js +0 -96
  90. package/dist/hooks/useProperty.js.map +0 -1
  91. package/dist/hooks/useRawCSS.d.ts +0 -22
  92. package/dist/hooks/useRawCSS.js +0 -103
  93. package/dist/hooks/useRawCSS.js.map +0 -1
  94. package/dist/hooks/useStyles.d.ts +0 -40
  95. package/dist/hooks/useStyles.js +0 -31
  96. package/dist/hooks/useStyles.js.map +0 -1
  97. package/dist/injector/index.d.ts +0 -182
  98. package/dist/injector/index.js +0 -185
  99. package/dist/injector/index.js.map +0 -1
  100. package/dist/injector/injector.d.ts +0 -198
  101. package/dist/injector/injector.js +0 -651
  102. package/dist/injector/injector.js.map +0 -1
  103. package/dist/injector/sheet-manager.d.ts +0 -132
  104. package/dist/injector/sheet-manager.js +0 -699
  105. package/dist/injector/sheet-manager.js.map +0 -1
  106. package/dist/injector/types.d.ts +0 -235
  107. package/dist/keyframes/index.js +0 -206
  108. package/dist/keyframes/index.js.map +0 -1
  109. package/dist/parser/classify.js +0 -319
  110. package/dist/parser/classify.js.map +0 -1
  111. package/dist/parser/const.js +0 -60
  112. package/dist/parser/const.js.map +0 -1
  113. package/dist/parser/lru.js +0 -109
  114. package/dist/parser/lru.js.map +0 -1
  115. package/dist/parser/parser.d.ts +0 -25
  116. package/dist/parser/parser.js +0 -115
  117. package/dist/parser/parser.js.map +0 -1
  118. package/dist/parser/tokenizer.js +0 -69
  119. package/dist/parser/tokenizer.js.map +0 -1
  120. package/dist/parser/types.d.ts +0 -51
  121. package/dist/parser/types.js +0 -46
  122. package/dist/parser/types.js.map +0 -1
  123. package/dist/pipeline/conditions.d.ts +0 -134
  124. package/dist/pipeline/conditions.js +0 -406
  125. package/dist/pipeline/conditions.js.map +0 -1
  126. package/dist/pipeline/exclusive.js +0 -389
  127. package/dist/pipeline/exclusive.js.map +0 -1
  128. package/dist/pipeline/index.d.ts +0 -55
  129. package/dist/pipeline/index.js +0 -749
  130. package/dist/pipeline/index.js.map +0 -1
  131. package/dist/pipeline/materialize-contradictions.js +0 -125
  132. package/dist/pipeline/materialize-contradictions.js.map +0 -1
  133. package/dist/pipeline/materialize.js +0 -1038
  134. package/dist/pipeline/materialize.js.map +0 -1
  135. package/dist/pipeline/parseStateKey.d.ts +0 -15
  136. package/dist/pipeline/parseStateKey.js +0 -446
  137. package/dist/pipeline/parseStateKey.js.map +0 -1
  138. package/dist/pipeline/simplify.js +0 -725
  139. package/dist/pipeline/simplify.js.map +0 -1
  140. package/dist/pipeline/warnings.js +0 -18
  141. package/dist/pipeline/warnings.js.map +0 -1
  142. package/dist/plugins/index.d.ts +0 -2
  143. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  144. package/dist/plugins/okhsl-plugin.js +0 -97
  145. package/dist/plugins/okhsl-plugin.js.map +0 -1
  146. package/dist/plugins/types.d.ts +0 -87
  147. package/dist/properties/index.js +0 -222
  148. package/dist/properties/index.js.map +0 -1
  149. package/dist/properties/property-type-resolver.d.ts +0 -24
  150. package/dist/properties/property-type-resolver.js +0 -90
  151. package/dist/properties/property-type-resolver.js.map +0 -1
  152. package/dist/rsc-cache.js +0 -79
  153. package/dist/rsc-cache.js.map +0 -1
  154. package/dist/ssr/async-storage.d.ts +0 -17
  155. package/dist/ssr/async-storage.js.map +0 -1
  156. package/dist/ssr/collect-auto-properties.js +0 -58
  157. package/dist/ssr/collect-auto-properties.js.map +0 -1
  158. package/dist/ssr/collector.js.map +0 -1
  159. package/dist/ssr/context.js.map +0 -1
  160. package/dist/ssr/format-global-rules.js.map +0 -1
  161. package/dist/ssr/format-keyframes.js +0 -69
  162. package/dist/ssr/format-keyframes.js.map +0 -1
  163. package/dist/ssr/format-property.js +0 -49
  164. package/dist/ssr/format-property.js.map +0 -1
  165. package/dist/ssr/format-rules.js +0 -73
  166. package/dist/ssr/format-rules.js.map +0 -1
  167. package/dist/ssr/hydrate.d.ts +0 -29
  168. package/dist/ssr/hydrate.js.map +0 -1
  169. package/dist/ssr/ssr-collector-ref.js +0 -29
  170. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  171. package/dist/states/index.d.ts +0 -49
  172. package/dist/states/index.js +0 -170
  173. package/dist/states/index.js.map +0 -1
  174. package/dist/static/tastyStatic.d.ts +0 -46
  175. package/dist/static/tastyStatic.js +0 -30
  176. package/dist/static/tastyStatic.js.map +0 -1
  177. package/dist/static/types.d.ts +0 -49
  178. package/dist/static/types.js +0 -24
  179. package/dist/static/types.js.map +0 -1
  180. package/dist/styles/border.d.ts +0 -25
  181. package/dist/styles/border.js +0 -120
  182. package/dist/styles/border.js.map +0 -1
  183. package/dist/styles/color.d.ts +0 -14
  184. package/dist/styles/color.js +0 -26
  185. package/dist/styles/color.js.map +0 -1
  186. package/dist/styles/const.js +0 -17
  187. package/dist/styles/const.js.map +0 -1
  188. package/dist/styles/createStyle.js +0 -79
  189. package/dist/styles/createStyle.js.map +0 -1
  190. package/dist/styles/dimension.js +0 -109
  191. package/dist/styles/dimension.js.map +0 -1
  192. package/dist/styles/directional.js +0 -133
  193. package/dist/styles/directional.js.map +0 -1
  194. package/dist/styles/display.d.ts +0 -30
  195. package/dist/styles/display.js +0 -73
  196. package/dist/styles/display.js.map +0 -1
  197. package/dist/styles/fade.d.ts +0 -15
  198. package/dist/styles/fade.js +0 -62
  199. package/dist/styles/fade.js.map +0 -1
  200. package/dist/styles/fill.d.ts +0 -42
  201. package/dist/styles/fill.js +0 -51
  202. package/dist/styles/fill.js.map +0 -1
  203. package/dist/styles/flow.d.ts +0 -16
  204. package/dist/styles/flow.js +0 -12
  205. package/dist/styles/flow.js.map +0 -1
  206. package/dist/styles/gap.d.ts +0 -31
  207. package/dist/styles/gap.js +0 -38
  208. package/dist/styles/gap.js.map +0 -1
  209. package/dist/styles/height.d.ts +0 -17
  210. package/dist/styles/height.js +0 -19
  211. package/dist/styles/height.js.map +0 -1
  212. package/dist/styles/index.d.ts +0 -1
  213. package/dist/styles/index.js +0 -8
  214. package/dist/styles/index.js.map +0 -1
  215. package/dist/styles/inset.d.ts +0 -24
  216. package/dist/styles/inset.js +0 -34
  217. package/dist/styles/inset.js.map +0 -1
  218. package/dist/styles/list.d.ts +0 -16
  219. package/dist/styles/list.js +0 -100
  220. package/dist/styles/list.js.map +0 -1
  221. package/dist/styles/margin.d.ts +0 -24
  222. package/dist/styles/margin.js +0 -32
  223. package/dist/styles/margin.js.map +0 -1
  224. package/dist/styles/outline.d.ts +0 -29
  225. package/dist/styles/outline.js +0 -55
  226. package/dist/styles/outline.js.map +0 -1
  227. package/dist/styles/padding.d.ts +0 -24
  228. package/dist/styles/padding.js +0 -32
  229. package/dist/styles/padding.js.map +0 -1
  230. package/dist/styles/placement.d.ts +0 -37
  231. package/dist/styles/placement.js +0 -74
  232. package/dist/styles/placement.js.map +0 -1
  233. package/dist/styles/predefined.d.ts +0 -71
  234. package/dist/styles/predefined.js +0 -237
  235. package/dist/styles/predefined.js.map +0 -1
  236. package/dist/styles/preset.d.ts +0 -52
  237. package/dist/styles/preset.js +0 -127
  238. package/dist/styles/preset.js.map +0 -1
  239. package/dist/styles/radius.d.ts +0 -12
  240. package/dist/styles/radius.js +0 -83
  241. package/dist/styles/radius.js.map +0 -1
  242. package/dist/styles/scrollMargin.d.ts +0 -24
  243. package/dist/styles/scrollMargin.js +0 -32
  244. package/dist/styles/scrollMargin.js.map +0 -1
  245. package/dist/styles/scrollbar.d.ts +0 -25
  246. package/dist/styles/scrollbar.js +0 -51
  247. package/dist/styles/scrollbar.js.map +0 -1
  248. package/dist/styles/shadow.d.ts +0 -14
  249. package/dist/styles/shadow.js +0 -25
  250. package/dist/styles/shadow.js.map +0 -1
  251. package/dist/styles/shared.js +0 -17
  252. package/dist/styles/shared.js.map +0 -1
  253. package/dist/styles/transition.d.ts +0 -14
  254. package/dist/styles/transition.js +0 -159
  255. package/dist/styles/transition.js.map +0 -1
  256. package/dist/styles/width.d.ts +0 -17
  257. package/dist/styles/width.js +0 -19
  258. package/dist/styles/width.js.map +0 -1
  259. package/dist/tasty.d.ts +0 -134
  260. package/dist/tasty.js +0 -248
  261. package/dist/tasty.js.map +0 -1
  262. package/dist/types.d.ts +0 -184
  263. package/dist/utils/cache-wrapper.js +0 -21
  264. package/dist/utils/cache-wrapper.js.map +0 -1
  265. package/dist/utils/case-converter.js +0 -8
  266. package/dist/utils/case-converter.js.map +0 -1
  267. package/dist/utils/color-math.d.ts +0 -46
  268. package/dist/utils/color-math.js +0 -749
  269. package/dist/utils/color-math.js.map +0 -1
  270. package/dist/utils/color-space.d.ts +0 -5
  271. package/dist/utils/color-space.js +0 -228
  272. package/dist/utils/color-space.js.map +0 -1
  273. package/dist/utils/colors.d.ts +0 -5
  274. package/dist/utils/colors.js +0 -10
  275. package/dist/utils/colors.js.map +0 -1
  276. package/dist/utils/css-types.d.ts +0 -7
  277. package/dist/utils/deps-equal.js +0 -15
  278. package/dist/utils/deps-equal.js.map +0 -1
  279. package/dist/utils/dotize.d.ts +0 -26
  280. package/dist/utils/dotize.js +0 -122
  281. package/dist/utils/dotize.js.map +0 -1
  282. package/dist/utils/filter-base-props.d.ts +0 -15
  283. package/dist/utils/filter-base-props.js +0 -45
  284. package/dist/utils/filter-base-props.js.map +0 -1
  285. package/dist/utils/get-display-name.d.ts +0 -7
  286. package/dist/utils/get-display-name.js +0 -10
  287. package/dist/utils/get-display-name.js.map +0 -1
  288. package/dist/utils/has-keys.js +0 -13
  289. package/dist/utils/has-keys.js.map +0 -1
  290. package/dist/utils/hash.js +0 -14
  291. package/dist/utils/hash.js.map +0 -1
  292. package/dist/utils/is-dev-env.js +0 -19
  293. package/dist/utils/is-dev-env.js.map +0 -1
  294. package/dist/utils/is-valid-element-type.js +0 -15
  295. package/dist/utils/is-valid-element-type.js.map +0 -1
  296. package/dist/utils/merge-styles.js.map +0 -1
  297. package/dist/utils/mod-attrs.d.ts +0 -6
  298. package/dist/utils/mod-attrs.js +0 -20
  299. package/dist/utils/mod-attrs.js.map +0 -1
  300. package/dist/utils/process-tokens.d.ts +0 -17
  301. package/dist/utils/process-tokens.js +0 -83
  302. package/dist/utils/process-tokens.js.map +0 -1
  303. package/dist/utils/resolve-recipes.d.ts +0 -17
  304. package/dist/utils/resolve-recipes.js.map +0 -1
  305. package/dist/utils/selector-transform.js +0 -32
  306. package/dist/utils/selector-transform.js.map +0 -1
  307. package/dist/utils/string.js +0 -8
  308. package/dist/utils/string.js.map +0 -1
  309. package/dist/utils/styles.d.ts +0 -99
  310. package/dist/utils/styles.js +0 -220
  311. package/dist/utils/styles.js.map +0 -1
  312. package/dist/utils/typography.d.ts +0 -58
  313. package/dist/utils/typography.js +0 -51
  314. package/dist/utils/typography.js.map +0 -1
  315. package/dist/utils/warnings.d.ts +0 -16
  316. package/dist/utils/warnings.js +0 -16
  317. package/dist/utils/warnings.js.map +0 -1
  318. package/dist/zero/css-writer.d.ts +0 -45
  319. package/dist/zero/css-writer.js +0 -73
  320. package/dist/zero/css-writer.js.map +0 -1
  321. package/dist/zero/extractor.d.ts +0 -24
  322. package/dist/zero/extractor.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/properties/index.ts"],"sourcesContent":["/**\n * Properties Utilities\n *\n * Utilities for extracting and processing CSS @property definitions in styles.\n * Unlike keyframes, properties are permanent once registered and don't need cleanup.\n *\n * Property names use tasty token syntax:\n * - `$name` for regular properties → `--name`\n * - `#name` for color properties → `--name-color` (auto-sets syntax: '<color>')\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { RE_NUMBER, RE_RAW_UNIT } from '../parser/const';\nimport type { Styles } from '../styles/types';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst PROPERTIES_KEY = '@properties';\n\n/**\n * Valid CSS custom property name pattern (after the -- prefix).\n * Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.\n */\nconst VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;\n\n// ============================================================================\n// Validation Functions\n// ============================================================================\n\n/**\n * Validate a CSS custom property name (the part after --).\n * Returns true if the name is valid for use as a CSS custom property.\n */\nexport function isValidPropertyName(name: string): boolean {\n return VALID_PROPERTY_NAME_PATTERN.test(name);\n}\n\n/**\n * Result of parsing a property token.\n */\nexport interface ParsedPropertyToken {\n /** The CSS custom property name (e.g., '--my-prop') */\n cssName: string;\n /** Whether this is a color property */\n isColor: boolean;\n /** Whether the token was valid */\n isValid: boolean;\n /** Error message if invalid */\n error?: string;\n}\n\n// ============================================================================\n// Extraction Functions\n// ============================================================================\n\n/**\n * Check if styles object has local @properties definition.\n * Fast path: single property lookup.\n */\nexport function hasLocalProperties(styles: Styles): boolean {\n return PROPERTIES_KEY in styles;\n}\n\n/**\n * Extract local @properties from styles object.\n * Returns null if no local properties (fast path).\n */\nexport function extractLocalProperties(\n styles: Styles,\n): Record<string, PropertyDefinition> | null {\n const properties = styles[PROPERTIES_KEY];\n if (!properties || typeof properties !== 'object') {\n return null;\n }\n return properties as Record<string, PropertyDefinition>;\n}\n\n// ============================================================================\n// Token Parsing Functions\n// ============================================================================\n\n/**\n * Parse a property token name and return the CSS property name and whether it's a color.\n * Supports tasty token syntax and validates the property name.\n *\n * Token formats:\n * - `$name` → { cssName: '--name', isColor: false }\n * - `#name` → { cssName: '--name-color', isColor: true }\n * - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)\n * - `name` → { cssName: '--name', isColor: false } (legacy)\n *\n * @param token - The property token to parse\n * @returns Parsed result with cssName, isColor, isValid, and optional error\n */\nexport function parsePropertyToken(token: string): ParsedPropertyToken {\n if (!token || typeof token !== 'string') {\n return {\n cssName: '',\n isColor: false,\n isValid: false,\n error: 'Property token must be a non-empty string',\n };\n }\n\n let name: string;\n let isColor: boolean;\n\n if (token.startsWith('$')) {\n // Regular property token: $name → --name\n name = token.slice(1);\n isColor = false;\n } else if (token.startsWith('#')) {\n // Color property token: #name → --name-color\n name = token.slice(1);\n isColor = true;\n } else if (token.startsWith('--')) {\n // Legacy format with -- prefix\n name = token.slice(2);\n isColor = token.endsWith('-color');\n } else {\n // Legacy format without prefix\n name = token;\n isColor = token.endsWith('-color');\n }\n\n // Validate the name\n if (!name) {\n return {\n cssName: '',\n isColor,\n isValid: false,\n error: 'Property name cannot be empty',\n };\n }\n\n if (!isValidPropertyName(name)) {\n return {\n cssName: '',\n isColor,\n isValid: false,\n error: `Invalid property name \"${name}\". Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.`,\n };\n }\n\n // Build the CSS custom property name\n // For #name tokens, we add -color suffix\n // For legacy formats (--name-color or name-color), the name already includes -color\n let cssName: string;\n if (token.startsWith('#')) {\n // Color token: #name → --name-color\n cssName = `--${name}-color`;\n } else {\n // All other formats: just add -- prefix\n cssName = `--${name}`;\n }\n\n return {\n cssName,\n isColor,\n isValid: true,\n };\n}\n\n// ============================================================================\n// Normalization Functions\n// ============================================================================\n\n/**\n * Normalize a property name to the CSS custom property format.\n *\n * @deprecated Use parsePropertyToken instead for proper token handling\n */\nexport function normalizePropertyName(name: string): string {\n const result = parsePropertyToken(name);\n return result.isValid ? result.cssName : `--${name}`;\n}\n\n/**\n * Normalize a property definition to a consistent string representation.\n * Used for comparing definitions to detect type conflicts.\n *\n * Only `syntax` and `inherits` are compared — `initialValue` is intentionally\n * excluded because different components may set different defaults for the\n * same typed property (e.g. auto-inferred `0px` vs explicit `6px`).\n *\n * Keys are sorted alphabetically to ensure consistent comparison:\n * { inherits: true, syntax: '<color>' } === { syntax: '<color>', inherits: true }\n */\nexport function normalizePropertyDefinition(def: PropertyDefinition): string {\n const normalized: Record<string, unknown> = {};\n\n if (def.inherits !== undefined) {\n normalized.inherits = def.inherits;\n }\n if (def.syntax !== undefined) {\n normalized.syntax = def.syntax;\n }\n\n return JSON.stringify(normalized);\n}\n\n/**\n * Result of getEffectiveDefinition.\n */\nexport interface EffectiveDefinitionResult {\n /** The CSS custom property name */\n cssName: string;\n /** The effective property definition */\n definition: PropertyDefinition;\n /** Whether this is a color property */\n isColor: boolean;\n /** Whether the token was valid */\n isValid: boolean;\n /** Error message if invalid */\n error?: string;\n}\n\n/**\n * Get the effective property definition for a token.\n * For color tokens (#name), auto-sets syntax to '<color>' and defaults initialValue to 'transparent'.\n *\n * @param token - Property token ($name, #name, --name, or plain name)\n * @param userDefinition - User-provided definition options\n * @returns Effective definition with cssName, definition, isValid, and optional error\n */\nexport function getEffectiveDefinition(\n token: string,\n userDefinition: PropertyDefinition,\n): EffectiveDefinitionResult {\n const parsed = parsePropertyToken(token);\n\n if (!parsed.isValid) {\n return {\n cssName: '',\n definition: userDefinition,\n isColor: false,\n isValid: false,\n error: parsed.error,\n };\n }\n\n if (parsed.isColor) {\n // Color properties have fixed syntax and default initialValue\n return {\n cssName: parsed.cssName,\n definition: {\n syntax: '<color>', // Always '<color>' for color tokens, cannot be overridden\n inherits: userDefinition.inherits, // Allow inherits to be customized\n initialValue: userDefinition.initialValue ?? 'transparent', // Default to transparent\n },\n isColor: true,\n isValid: true,\n };\n }\n\n // Regular properties use the definition as-is\n return {\n cssName: parsed.cssName,\n definition: userDefinition,\n isColor: false,\n isValid: true,\n };\n}\n\n// ============================================================================\n// Color Utilities\n// ============================================================================\n\nexport { colorInitialValueToComponents } from '../utils/color-space';\n\n// ============================================================================\n// Value Type Inference\n// ============================================================================\n\n/**\n * Result of inferring a CSS @property syntax from a value.\n */\nexport interface InferredSyntax {\n syntax: string;\n initialValue: string;\n}\n\nconst UNIT_TO_SYNTAX: Record<string, InferredSyntax> = {};\n\nconst LENGTH_UNITS = [\n 'px',\n 'em',\n 'rem',\n 'vw',\n 'vh',\n 'vmin',\n 'vmax',\n 'ch',\n 'ex',\n 'cap',\n 'ic',\n 'lh',\n 'rlh',\n 'svw',\n 'svh',\n 'lvw',\n 'lvh',\n 'dvw',\n 'dvh',\n 'cqw',\n 'cqh',\n 'cqi',\n 'cqb',\n 'cqmin',\n 'cqmax',\n];\n\nconst ANGLE_UNITS = ['deg', 'rad', 'grad', 'turn'];\nconst TIME_UNITS = ['ms', 's'];\n\nfor (const u of LENGTH_UNITS) {\n UNIT_TO_SYNTAX[u] = { syntax: '<length-percentage>', initialValue: '0px' };\n}\nUNIT_TO_SYNTAX['%'] = { syntax: '<length-percentage>', initialValue: '0px' };\nfor (const u of ANGLE_UNITS) {\n UNIT_TO_SYNTAX[u] = { syntax: '<angle>', initialValue: '0deg' };\n}\nfor (const u of TIME_UNITS) {\n UNIT_TO_SYNTAX[u] = { syntax: '<time>', initialValue: '0s' };\n}\n\n/**\n * Infer CSS @property syntax from a concrete value.\n * Detects numeric types: \\<number\\>, \\<length-percentage\\>, \\<angle\\>, \\<time\\>.\n * Length and percentage values both map to \\<length-percentage\\> for maximum flexibility.\n * Color properties are handled separately via the #name token convention\n * (--name-color gets \\<color\\> syntax automatically in getEffectiveDefinition).\n *\n * @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')\n * @returns Inferred syntax and initial value, or null if not inferable\n */\nexport function inferSyntaxFromValue(value: string): InferredSyntax | null {\n if (!value || typeof value !== 'string') return null;\n\n const trimmed = value.trim();\n if (!trimmed) return null;\n\n if (RE_NUMBER.test(trimmed)) {\n // Bare zero is ambiguous (could be <length>, <angle>, <percentage>, etc.)\n if (parseFloat(trimmed) === 0) return null;\n return { syntax: '<number>', initialValue: '0' };\n }\n\n const unitMatch = trimmed.match(RE_RAW_UNIT);\n if (unitMatch) {\n const unit = unitMatch[2];\n const mapping = UNIT_TO_SYNTAX[unit];\n if (mapping) return mapping;\n }\n\n return null;\n}\n"],"mappings":";;;AAmBA,MAAM,iBAAiB;;;;;AAMvB,MAAM,8BAA8B;;;;;AAUpC,SAAgB,oBAAoB,MAAuB;AACzD,QAAO,4BAA4B,KAAK,KAAK;;;;;;AAyB/C,SAAgB,mBAAmB,QAAyB;AAC1D,QAAO,kBAAkB;;;;;;AAO3B,SAAgB,uBACd,QAC2C;CAC3C,MAAM,aAAa,OAAO;AAC1B,KAAI,CAAC,cAAc,OAAO,eAAe,SACvC,QAAO;AAET,QAAO;;;;;;;;;;;;;;;AAoBT,SAAgB,mBAAmB,OAAoC;AACrE,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO;EACL,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;EACR;CAGH,IAAI;CACJ,IAAI;AAEJ,KAAI,MAAM,WAAW,IAAI,EAAE;AAEzB,SAAO,MAAM,MAAM,EAAE;AACrB,YAAU;YACD,MAAM,WAAW,IAAI,EAAE;AAEhC,SAAO,MAAM,MAAM,EAAE;AACrB,YAAU;YACD,MAAM,WAAW,KAAK,EAAE;AAEjC,SAAO,MAAM,MAAM,EAAE;AACrB,YAAU,MAAM,SAAS,SAAS;QAC7B;AAEL,SAAO;AACP,YAAU,MAAM,SAAS,SAAS;;AAIpC,KAAI,CAAC,KACH,QAAO;EACL,SAAS;EACT;EACA,SAAS;EACT,OAAO;EACR;AAGH,KAAI,CAAC,oBAAoB,KAAK,CAC5B,QAAO;EACL,SAAS;EACT;EACA,SAAS;EACT,OAAO,0BAA0B,KAAK;EACvC;CAMH,IAAI;AACJ,KAAI,MAAM,WAAW,IAAI,CAEvB,WAAU,KAAK,KAAK;KAGpB,WAAU,KAAK;AAGjB,QAAO;EACL;EACA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O,UAAU,SAAU,QAAO;CAEhD,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,CAAC,QAAS,QAAO;AAErB,KAAI,UAAU,KAAK,QAAQ,EAAE;AAE3B,MAAI,WAAW,QAAQ,KAAK,EAAG,QAAO;AACtC,SAAO;GAAE,QAAQ;GAAY,cAAc;GAAK;;CAGlD,MAAM,YAAY,QAAQ,MAAM,YAAY;AAC5C,KAAI,WAAW;EAEb,MAAM,UAAU,eADH,UAAU;AAEvB,MAAI,QAAS,QAAO;;AAGtB,QAAO"}
@@ -1,24 +0,0 @@
1
- //#region src/properties/property-type-resolver.d.ts
2
- /**
3
- * PropertyTypeResolver
4
- *
5
- * Automatically infers CSS @property types from custom property values.
6
- * Supports deferred resolution for var() reference chains of arbitrary depth.
7
- */
8
- declare class PropertyTypeResolver {
9
- /** propName → the prop it depends on */
10
- private pendingDeps;
11
- /** propName → list of props waiting on it */
12
- private reverseDeps;
13
- /**
14
- * Scan CSS declarations and auto-register @property for custom properties
15
- * whose types can be inferred from their values.
16
- */
17
- scanDeclarations(declarations: string, isPropertyDefined: (name: string) => boolean, registerProperty: (name: string, syntax: string, initialValue: string) => void): void;
18
- private addDependency;
19
- private resolve;
20
- private isComplexValue;
21
- }
22
- //#endregion
23
- export { PropertyTypeResolver };
24
- //# sourceMappingURL=property-type-resolver.d.ts.map
@@ -1,90 +0,0 @@
1
- import { inferSyntaxFromValue } from "./index.js";
2
- //#region src/properties/property-type-resolver.ts
3
- /**
4
- * PropertyTypeResolver
5
- *
6
- * Automatically infers CSS @property types from custom property values.
7
- * Supports deferred resolution for var() reference chains of arbitrary depth.
8
- */
9
- const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(.+?)\s*$/i;
10
- const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
11
- var PropertyTypeResolver = class {
12
- /** propName → the prop it depends on */
13
- pendingDeps = /* @__PURE__ */ new Map();
14
- /** propName → list of props waiting on it */
15
- reverseDeps = /* @__PURE__ */ new Map();
16
- /**
17
- * Scan CSS declarations and auto-register @property for custom properties
18
- * whose types can be inferred from their values.
19
- */
20
- scanDeclarations(declarations, isPropertyDefined, registerProperty) {
21
- if (!declarations.includes("--")) return;
22
- const parts = declarations.split(/;+/);
23
- for (const part of parts) {
24
- if (!part.trim()) continue;
25
- const match = CUSTOM_PROP_DECL.exec(part);
26
- if (!match) continue;
27
- const propName = match[1];
28
- const value = match[2].trim();
29
- if (isPropertyDefined(propName)) continue;
30
- if (propName.endsWith("-color")) {
31
- registerProperty(propName, "<color>", "transparent");
32
- continue;
33
- }
34
- if (propName.endsWith("-line-height")) {
35
- registerProperty(propName, "<number> | <length-percentage>", "0");
36
- continue;
37
- }
38
- if (propName.endsWith("-opacity")) {
39
- registerProperty(propName, "<number> | <percentage>", "0");
40
- continue;
41
- }
42
- const varMatch = SINGLE_VAR_REF.exec(value);
43
- if (varMatch) {
44
- const depName = varMatch[1];
45
- this.addDependency(propName, depName);
46
- continue;
47
- }
48
- if (this.isComplexValue(value)) continue;
49
- const inferred = inferSyntaxFromValue(value);
50
- if (!inferred) continue;
51
- this.resolve(propName, inferred.syntax, inferred.initialValue, isPropertyDefined, registerProperty);
52
- }
53
- }
54
- addDependency(propName, depName) {
55
- if (propName === depName) return;
56
- this.pendingDeps.set(propName, depName);
57
- let dependents = this.reverseDeps.get(depName);
58
- if (!dependents) {
59
- dependents = [];
60
- this.reverseDeps.set(depName, dependents);
61
- }
62
- if (!dependents.includes(propName)) dependents.push(propName);
63
- }
64
- resolve(propName, syntax, initialValue, isPropertyDefined, registerProperty, resolving) {
65
- if (!resolving) resolving = /* @__PURE__ */ new Set();
66
- if (resolving.has(propName)) return;
67
- resolving.add(propName);
68
- if (!isPropertyDefined(propName)) registerProperty(propName, syntax, initialValue);
69
- const dependents = this.reverseDeps.get(propName);
70
- if (dependents) {
71
- this.reverseDeps.delete(propName);
72
- for (const dependent of dependents) {
73
- this.pendingDeps.delete(dependent);
74
- if (isPropertyDefined(dependent)) continue;
75
- this.resolve(dependent, syntax, initialValue, isPropertyDefined, registerProperty, resolving);
76
- }
77
- }
78
- }
79
- isComplexValue(value) {
80
- if (value.includes("calc(")) return true;
81
- const firstVar = value.indexOf("var(");
82
- if (firstVar === -1) return false;
83
- if (value.indexOf("var(", firstVar + 4) !== -1) return true;
84
- return !SINGLE_VAR_REF.test(value);
85
- }
86
- };
87
- //#endregion
88
- export { PropertyTypeResolver };
89
-
90
- //# sourceMappingURL=property-type-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"property-type-resolver.js","names":[],"sources":["../../src/properties/property-type-resolver.ts"],"sourcesContent":["/**\n * PropertyTypeResolver\n *\n * Automatically infers CSS @property types from custom property values.\n * Supports deferred resolution for var() reference chains of arbitrary depth.\n */\n\nimport { inferSyntaxFromValue } from './index';\n\nconst CUSTOM_PROP_DECL = /^\\s*(--[a-z0-9_-]+)\\s*:\\s*(.+?)\\s*$/i;\nconst SINGLE_VAR_REF = /^var\\((--[a-z0-9_-]+)\\)$/i;\n\nexport class PropertyTypeResolver {\n /** propName → the prop it depends on */\n private pendingDeps = new Map<string, string>();\n /** propName → list of props waiting on it */\n private reverseDeps = new Map<string, string[]>();\n\n /**\n * Scan CSS declarations and auto-register @property for custom properties\n * whose types can be inferred from their values.\n */\n scanDeclarations(\n declarations: string,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n ): void {\n if (!declarations.includes('--')) return;\n\n const parts = declarations.split(/;+/);\n\n for (const part of parts) {\n if (!part.trim()) continue;\n\n const match = CUSTOM_PROP_DECL.exec(part);\n if (!match) continue;\n\n const propName = match[1];\n const value = match[2].trim();\n\n if (isPropertyDefined(propName)) continue;\n\n // Name-based: --*-color properties are always <color> (from #name tokens)\n if (propName.endsWith('-color')) {\n registerProperty(propName, '<color>', 'transparent');\n continue;\n }\n\n // Name-based: --*-line-height accepts numbers, lengths, and percentages\n if (propName.endsWith('-line-height')) {\n registerProperty(propName, '<number> | <length-percentage>', '0');\n continue;\n }\n\n // Name-based: --*-opacity accepts numbers and percentages\n if (propName.endsWith('-opacity')) {\n registerProperty(propName, '<number> | <percentage>', '0');\n continue;\n }\n\n // Single var() reference → record dependency for deferred resolution\n const varMatch = SINGLE_VAR_REF.exec(value);\n if (varMatch) {\n const depName = varMatch[1];\n this.addDependency(propName, depName);\n continue;\n }\n\n // Skip complex expressions (calc, multiple var, etc.)\n if (this.isComplexValue(value)) continue;\n\n const inferred = inferSyntaxFromValue(value);\n if (!inferred) continue;\n\n this.resolve(\n propName,\n inferred.syntax,\n inferred.initialValue,\n isPropertyDefined,\n registerProperty,\n );\n }\n }\n\n private addDependency(propName: string, depName: string): void {\n if (propName === depName) return;\n\n this.pendingDeps.set(propName, depName);\n\n let dependents = this.reverseDeps.get(depName);\n if (!dependents) {\n dependents = [];\n this.reverseDeps.set(depName, dependents);\n }\n if (!dependents.includes(propName)) {\n dependents.push(propName);\n }\n }\n\n private resolve(\n propName: string,\n syntax: string,\n initialValue: string,\n isPropertyDefined: (name: string) => boolean,\n registerProperty: (\n name: string,\n syntax: string,\n initialValue: string,\n ) => void,\n resolving?: Set<string>,\n ): void {\n if (!resolving) resolving = new Set();\n if (resolving.has(propName)) return;\n resolving.add(propName);\n\n if (!isPropertyDefined(propName)) {\n registerProperty(propName, syntax, initialValue);\n }\n\n const dependents = this.reverseDeps.get(propName);\n if (dependents) {\n this.reverseDeps.delete(propName);\n\n for (const dependent of dependents) {\n this.pendingDeps.delete(dependent);\n\n if (isPropertyDefined(dependent)) continue;\n\n this.resolve(\n dependent,\n syntax,\n initialValue,\n isPropertyDefined,\n registerProperty,\n resolving,\n );\n }\n }\n }\n\n private isComplexValue(value: string): boolean {\n if (value.includes('calc(')) return true;\n const firstVar = value.indexOf('var(');\n if (firstVar === -1) return false;\n if (value.indexOf('var(', firstVar + 4) !== -1) return true;\n return !SINGLE_VAR_REF.test(value);\n }\n}\n"],"mappings":";;;;;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,CAChC,YAAW,KAAK,SAAS;;CAI7B,QACE,UACA,QACA,cACA,mBACA,kBAKA,WACM;AACN,MAAI,CAAC,UAAW,6BAAY,IAAI,KAAK;AACrC,MAAI,UAAU,IAAI,SAAS,CAAE;AAC7B,YAAU,IAAI,SAAS;AAEvB,MAAI,CAAC,kBAAkB,SAAS,CAC9B,kBAAiB,UAAU,QAAQ,aAAa;EAGlD,MAAM,aAAa,KAAK,YAAY,IAAI,SAAS;AACjD,MAAI,YAAY;AACd,QAAK,YAAY,OAAO,SAAS;AAEjC,QAAK,MAAM,aAAa,YAAY;AAClC,SAAK,YAAY,OAAO,UAAU;AAElC,QAAI,kBAAkB,UAAU,CAAE;AAElC,SAAK,QACH,WACA,QACA,cACA,mBACA,kBACA,UACD;;;;CAKP,eAAuB,OAAwB;AAC7C,MAAI,MAAM,SAAS,QAAQ,CAAE,QAAO;EACpC,MAAM,WAAW,MAAM,QAAQ,OAAO;AACtC,MAAI,aAAa,GAAI,QAAO;AAC5B,MAAI,MAAM,QAAQ,QAAQ,WAAW,EAAE,KAAK,GAAI,QAAO;AACvD,SAAO,CAAC,eAAe,KAAK,MAAM"}
package/dist/rsc-cache.js DELETED
@@ -1,79 +0,0 @@
1
- import { hashString } from "./utils/hash.js";
2
- import { getRegisteredSSRCollector } from "./ssr/ssr-collector-ref.js";
3
- import { cache } from "react";
4
- //#region src/rsc-cache.ts
5
- /**
6
- * Shared RSC (React Server Components) inline style cache.
7
- *
8
- * Uses React.cache for per-request memoization in Server Components.
9
- * Both computeStyles() and standalone style functions (useGlobalStyles,
10
- * useRawCSS, useKeyframes, useProperty, useFontFace, useCounterStyle)
11
- * share this cache so that CSS accumulated by standalone functions is
12
- * flushed into inline <style> tags by the next tasty() component.
13
- */
14
- /**
15
- * Per-request RSC style cache using React.cache.
16
- * React.cache provides per-request memoization in Server Components,
17
- * so each request gets its own isolated cache.
18
- */
19
- const getRSCCache = cache(() => ({
20
- cacheKeyToClassName: /* @__PURE__ */ new Map(),
21
- emittedKeys: /* @__PURE__ */ new Set(),
22
- internalsEmitted: false,
23
- pendingCSS: [],
24
- generatedNames: /* @__PURE__ */ new Map()
25
- }));
26
- function rscAllocateClassName(rscCache, cacheKey) {
27
- const existing = rscCache.cacheKeyToClassName.get(cacheKey);
28
- if (existing) return {
29
- className: existing,
30
- isNew: false
31
- };
32
- const className = `t${hashString(cacheKey)}`;
33
- rscCache.cacheKeyToClassName.set(cacheKey, className);
34
- return {
35
- className,
36
- isNew: true
37
- };
38
- }
39
- /**
40
- * Flush any pending CSS accumulated by standalone functions.
41
- * Returns the CSS string and clears the buffer.
42
- */
43
- function flushPendingCSS(rscCache) {
44
- if (rscCache.pendingCSS.length === 0) return "";
45
- const css = rscCache.pendingCSS.join("\n");
46
- rscCache.pendingCSS.length = 0;
47
- return css;
48
- }
49
- /**
50
- * Push CSS into the RSC pending buffer with dedup via emittedKeys.
51
- * Returns true if the CSS was added, false if it was already emitted.
52
- */
53
- function pushRSCCSS(rscCache, key, css) {
54
- if (rscCache.emittedKeys.has(key)) return false;
55
- rscCache.emittedKeys.add(key);
56
- rscCache.pendingCSS.push(css);
57
- return true;
58
- }
59
- /**
60
- * Determine the current style injection target.
61
- * Centralizes the three-way detection (SSR collector / RSC cache / client DOM)
62
- * used by all style functions.
63
- */
64
- function getStyleTarget() {
65
- const collector = getRegisteredSSRCollector();
66
- if (collector) return {
67
- mode: "ssr",
68
- collector
69
- };
70
- if (typeof document === "undefined") return {
71
- mode: "rsc",
72
- cache: getRSCCache()
73
- };
74
- return { mode: "client" };
75
- }
76
- //#endregion
77
- export { flushPendingCSS, getRSCCache, getStyleTarget, pushRSCCSS, rscAllocateClassName };
78
-
79
- //# sourceMappingURL=rsc-cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rsc-cache.js","names":[],"sources":["../src/rsc-cache.ts"],"sourcesContent":["/**\n * Shared RSC (React Server Components) inline style cache.\n *\n * Uses React.cache for per-request memoization in Server Components.\n * Both computeStyles() and standalone style functions (useGlobalStyles,\n * useRawCSS, useKeyframes, useProperty, useFontFace, useCounterStyle)\n * share this cache so that CSS accumulated by standalone functions is\n * flushed into inline <style> tags by the next tasty() component.\n */\n\nimport { cache } from 'react';\n\nimport type { ServerStyleCollector } from './ssr/collector';\nimport { getRegisteredSSRCollector } from './ssr/ssr-collector-ref';\nimport { hashString } from './utils/hash';\n\nexport interface RSCStyleCache {\n cacheKeyToClassName: Map<string, string>;\n emittedKeys: Set<string>;\n internalsEmitted: boolean;\n pendingCSS: string[];\n /** Maps dedup key -> generated name for keyframes and counter-styles in RSC mode. */\n generatedNames: Map<string, string>;\n}\n\n/**\n * Per-request RSC style cache using React.cache.\n * React.cache provides per-request memoization in Server Components,\n * so each request gets its own isolated cache.\n */\nexport const getRSCCache = cache(\n (): RSCStyleCache => ({\n cacheKeyToClassName: new Map(),\n emittedKeys: new Set(),\n internalsEmitted: false,\n pendingCSS: [],\n generatedNames: new Map(),\n }),\n);\n\nexport function rscAllocateClassName(\n rscCache: RSCStyleCache,\n cacheKey: string,\n): { className: string; isNew: boolean } {\n const existing = rscCache.cacheKeyToClassName.get(cacheKey);\n if (existing) return { className: existing, isNew: false };\n\n // Content-hash ensures stable names across all environments (RSC, SSR, client),\n // enabling cross-environment dedup and preventing class collisions.\n const className = `t${hashString(cacheKey)}`;\n rscCache.cacheKeyToClassName.set(cacheKey, className);\n return { className, isNew: true };\n}\n\n/**\n * Flush any pending CSS accumulated by standalone functions.\n * Returns the CSS string and clears the buffer.\n */\nexport function flushPendingCSS(rscCache: RSCStyleCache): string {\n if (rscCache.pendingCSS.length === 0) return '';\n const css = rscCache.pendingCSS.join('\\n');\n rscCache.pendingCSS.length = 0;\n return css;\n}\n\n/**\n * Push CSS into the RSC pending buffer with dedup via emittedKeys.\n * Returns true if the CSS was added, false if it was already emitted.\n */\nexport function pushRSCCSS(\n rscCache: RSCStyleCache,\n key: string,\n css: string,\n): boolean {\n if (rscCache.emittedKeys.has(key)) return false;\n rscCache.emittedKeys.add(key);\n rscCache.pendingCSS.push(css);\n return true;\n}\n\nexport type StyleTarget =\n | { mode: 'ssr'; collector: ServerStyleCollector }\n | { mode: 'rsc'; cache: RSCStyleCache }\n | { mode: 'client' };\n\n/**\n * Determine the current style injection target.\n * Centralizes the three-way detection (SSR collector / RSC cache / client DOM)\n * used by all style functions.\n */\nexport function getStyleTarget(): StyleTarget {\n const collector = getRegisteredSSRCollector();\n if (collector) return { mode: 'ssr', collector };\n if (typeof document === 'undefined')\n return { mode: 'rsc', cache: getRSCCache() };\n return { mode: 'client' };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BA,MAAa,cAAc,aACH;CACpB,qCAAqB,IAAI,KAAK;CAC9B,6BAAa,IAAI,KAAK;CACtB,kBAAkB;CAClB,YAAY,EAAE;CACd,gCAAgB,IAAI,KAAK;CAC1B,EACF;AAED,SAAgB,qBACd,UACA,UACuC;CACvC,MAAM,WAAW,SAAS,oBAAoB,IAAI,SAAS;AAC3D,KAAI,SAAU,QAAO;EAAE,WAAW;EAAU,OAAO;EAAO;CAI1D,MAAM,YAAY,IAAI,WAAW,SAAS;AAC1C,UAAS,oBAAoB,IAAI,UAAU,UAAU;AACrD,QAAO;EAAE;EAAW,OAAO;EAAM;;;;;;AAOnC,SAAgB,gBAAgB,UAAiC;AAC/D,KAAI,SAAS,WAAW,WAAW,EAAG,QAAO;CAC7C,MAAM,MAAM,SAAS,WAAW,KAAK,KAAK;AAC1C,UAAS,WAAW,SAAS;AAC7B,QAAO;;;;;;AAOT,SAAgB,WACd,UACA,KACA,KACS;AACT,KAAI,SAAS,YAAY,IAAI,IAAI,CAAE,QAAO;AAC1C,UAAS,YAAY,IAAI,IAAI;AAC7B,UAAS,WAAW,KAAK,IAAI;AAC7B,QAAO;;;;;;;AAaT,SAAgB,iBAA8B;CAC5C,MAAM,YAAY,2BAA2B;AAC7C,KAAI,UAAW,QAAO;EAAE,MAAM;EAAO;EAAW;AAChD,KAAI,OAAO,aAAa,YACtB,QAAO;EAAE,MAAM;EAAO,OAAO,aAAa;EAAE;AAC9C,QAAO,EAAE,MAAM,UAAU"}
@@ -1,17 +0,0 @@
1
- import { ServerStyleCollector } from "./collector.js";
2
-
3
- //#region src/ssr/async-storage.d.ts
4
- /**
5
- * Run a function with a ServerStyleCollector bound to the current
6
- * async context. All useStyles() calls within `fn` (and any async
7
- * continuations) will find this collector via getSSRCollector().
8
- */
9
- declare function runWithCollector<T>(collector: ServerStyleCollector, fn: () => T): T;
10
- /**
11
- * Retrieve the ServerStyleCollector bound to the current async context.
12
- * Returns null when called outside of runWithCollector() or on the client.
13
- */
14
- declare function getSSRCollector(): ServerStyleCollector | null;
15
- //#endregion
16
- export { getSSRCollector, runWithCollector };
17
- //# sourceMappingURL=async-storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-storage.js","names":[],"sources":["../../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,SACL,GAAE,WAAW,IAAI,mBAAyC;AAE5D,QAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;AACH,QAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;AAClC,KAAI,OAAO,SAAS,aAAa,WAAY,QAAO;AACpD,QAAO,QAAQ,UAAU,IAAI"}
@@ -1,58 +0,0 @@
1
- import { parsePropertyToken } from "../properties/index.js";
2
- import { PropertyTypeResolver } from "../properties/property-type-resolver.js";
3
- import { pushRSCCSS } from "../rsc-cache.js";
4
- import { formatPropertyCSS } from "./format-property.js";
5
- //#region src/ssr/collect-auto-properties.ts
6
- /**
7
- * Scan rendered rules for auto-inferable custom properties and emit
8
- * @property CSS via the provided callback.
9
- */
10
- function scanAndEmitAutoProperties(rules, styles, emit) {
11
- const registered = /* @__PURE__ */ new Set();
12
- if (styles) {
13
- const localProps = styles["@properties"];
14
- if (localProps && typeof localProps === "object") for (const token of Object.keys(localProps)) {
15
- const parsed = parsePropertyToken(token);
16
- if (parsed.isValid) registered.add(parsed.cssName);
17
- }
18
- }
19
- const resolver = new PropertyTypeResolver();
20
- for (const rule of rules) {
21
- if (!rule.declarations) continue;
22
- resolver.scanDeclarations(rule.declarations, (name) => registered.has(name), (name, syntax, initialValue) => {
23
- registered.add(name);
24
- const css = formatPropertyCSS(name, {
25
- syntax,
26
- inherits: true,
27
- initialValue
28
- });
29
- if (css) emit(name, css);
30
- });
31
- }
32
- }
33
- /**
34
- * Scan rendered rules for custom property declarations and collect
35
- * auto-inferred @property rules via the SSR collector.
36
- *
37
- * @param rules - Rendered style rules containing CSS declarations
38
- * @param collector - SSR collector to emit @property CSS into
39
- * @param styles - Original styles object (used to skip explicit @properties)
40
- */
41
- function collectAutoInferredProperties(rules, collector, styles) {
42
- scanAndEmitAutoProperties(rules, styles, (name, css) => {
43
- collector.collectProperty(`__auto:${name}`, css);
44
- });
45
- }
46
- /**
47
- * RSC variant: scan rendered rules and push auto-inferred @property CSS
48
- * into the RSC pending buffer.
49
- */
50
- function collectAutoInferredPropertiesRSC(rules, rscCache, styles) {
51
- scanAndEmitAutoProperties(rules, styles, (name, css) => {
52
- pushRSCCSS(rscCache, `__auto:${name}`, css);
53
- });
54
- }
55
- //#endregion
56
- export { collectAutoInferredProperties, collectAutoInferredPropertiesRSC };
57
-
58
- //# sourceMappingURL=collect-auto-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collect-auto-properties.js","names":[],"sources":["../../src/ssr/collect-auto-properties.ts"],"sourcesContent":["/**\n * SSR / RSC auto-property inference.\n *\n * Scans rendered CSS declarations for custom properties whose types\n * can be inferred from their values (e.g. `--angle: 30deg` → `<angle>`).\n * Mirrors the client-side auto-inference in StyleInjector.inject().\n */\n\nimport type { StyleResult } from '../pipeline';\nimport { parsePropertyToken } from '../properties';\nimport { PropertyTypeResolver } from '../properties/property-type-resolver';\nimport type { RSCStyleCache } from '../rsc-cache';\nimport { pushRSCCSS } from '../rsc-cache';\nimport type { Styles } from '../styles/types';\n\nimport type { ServerStyleCollector } from './collector';\nimport { formatPropertyCSS } from './format-property';\n\n/**\n * Scan rendered rules for auto-inferable custom properties and emit\n * @property CSS via the provided callback.\n */\nfunction scanAndEmitAutoProperties(\n rules: StyleResult[],\n styles: Styles | undefined,\n emit: (name: string, css: string) => void,\n): void {\n const registered = new Set<string>();\n\n if (styles) {\n const localProps = styles['@properties'];\n if (localProps && typeof localProps === 'object') {\n for (const token of Object.keys(localProps as Record<string, unknown>)) {\n const parsed = parsePropertyToken(token);\n if (parsed.isValid) {\n registered.add(parsed.cssName);\n }\n }\n }\n }\n\n const resolver = new PropertyTypeResolver();\n\n for (const rule of rules) {\n if (!rule.declarations) continue;\n resolver.scanDeclarations(\n rule.declarations,\n (name) => registered.has(name),\n (name, syntax, initialValue) => {\n registered.add(name);\n const css = formatPropertyCSS(name, {\n syntax,\n inherits: true,\n initialValue,\n });\n if (css) {\n emit(name, css);\n }\n },\n );\n }\n}\n\n/**\n * Scan rendered rules for custom property declarations and collect\n * auto-inferred @property rules via the SSR collector.\n *\n * @param rules - Rendered style rules containing CSS declarations\n * @param collector - SSR collector to emit @property CSS into\n * @param styles - Original styles object (used to skip explicit @properties)\n */\nexport function collectAutoInferredProperties(\n rules: StyleResult[],\n collector: ServerStyleCollector,\n styles?: Styles,\n): void {\n scanAndEmitAutoProperties(rules, styles, (name, css) => {\n collector.collectProperty(`__auto:${name}`, css);\n });\n}\n\n/**\n * RSC variant: scan rendered rules and push auto-inferred @property CSS\n * into the RSC pending buffer.\n */\nexport function collectAutoInferredPropertiesRSC(\n rules: StyleResult[],\n rscCache: RSCStyleCache,\n styles?: Styles,\n): void {\n scanAndEmitAutoProperties(rules, styles, (name, css) => {\n pushRSCCSS(rscCache, `__auto:${name}`, css);\n });\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAS,0BACP,OACA,QACA,MACM;CACN,MAAM,6BAAa,IAAI,KAAa;AAEpC,KAAI,QAAQ;EACV,MAAM,aAAa,OAAO;AAC1B,MAAI,cAAc,OAAO,eAAe,SACtC,MAAK,MAAM,SAAS,OAAO,KAAK,WAAsC,EAAE;GACtE,MAAM,SAAS,mBAAmB,MAAM;AACxC,OAAI,OAAO,QACT,YAAW,IAAI,OAAO,QAAQ;;;CAMtC,MAAM,WAAW,IAAI,sBAAsB;AAE3C,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,KAAK,aAAc;AACxB,WAAS,iBACP,KAAK,eACJ,SAAS,WAAW,IAAI,KAAK,GAC7B,MAAM,QAAQ,iBAAiB;AAC9B,cAAW,IAAI,KAAK;GACpB,MAAM,MAAM,kBAAkB,MAAM;IAClC;IACA,UAAU;IACV;IACD,CAAC;AACF,OAAI,IACF,MAAK,MAAM,IAAI;IAGpB;;;;;;;;;;;AAYL,SAAgB,8BACd,OACA,WACA,QACM;AACN,2BAA0B,OAAO,SAAS,MAAM,QAAQ;AACtD,YAAU,gBAAgB,UAAU,QAAQ,IAAI;GAChD;;;;;;AAOJ,SAAgB,iCACd,OACA,UACA,QACM;AACN,2BAA0B,OAAO,SAAS,MAAM,QAAQ;AACtD,aAAW,UAAU,UAAU,QAAQ,IAAI;GAC3C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector.js","names":[],"sources":["../../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names (`t${hash}`), formats CSS rules into text,\n * and tracks rendered class names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nfunction generateClassName(cacheKey: string): string {\n return `t${hashString(cacheKey)}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\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) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return providedName ?? `k${this.keyframesCounter++}`;\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return providedName ?? `cs${this.counterStyleCounter++}`;\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,SAAS,kBAAkB,UAA0B;AACnD,QAAO,IAAI,WAAW,SAAS;;AAGjC,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACnD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;;;;;;;;;;CAW7B,mBAAyB;AACvB,MAAI,KAAK,mBAAoB;AAC7B,OAAK,qBAAqB;AAE1B,OAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QACvC,wBAAwB,CACzB,E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M,CAAC,KAAK,QAAQ,KAAK,OAC5B,KAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;AAC9B,SAAM,KAAK,IAAI;AACf,QAAK,YAAY,IAAI,IAAI;;AAI7B,OAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,cAC7B,KAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;AACvC,SAAM,KAAK,IAAI;AACf,QAAK,oBAAoB,IAAI,KAAK;;AAItC,SAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,CACvD,KAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;AAC1C,QAAK,kBAAkB,IAAI,UAAU;AACrC,SAAM,KAAK,UAAU;;AAGzB,SAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../src/ssr/context.ts"],"sourcesContent":["/**\n * React context for SSR collector discovery.\n *\n * Used by Next.js TastyRegistry to provide the ServerStyleCollector\n * to useStyles() via React context (the streaming-compatible path).\n *\n * This avoids relying on globalThis for cross-layer communication,\n * which leaks between RSC and SSR module graphs in Next.js App Router.\n */\n\nimport { createContext } from 'react';\n\nimport type { ServerStyleCollector } from './collector';\n\nexport const TastySSRContext = createContext<ServerStyleCollector | null>(null);\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,kBAAkB,cAA2C,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-global-rules.js","names":[],"sources":["../../src/ssr/format-global-rules.ts"],"sourcesContent":["/**\n * Format global CSS rules for SSR output.\n *\n * Unlike formatRules() which applies className-based specificity doubling,\n * this function formats rules that already have their full selectors\n * (from renderStyles called with a selector string).\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Format an array of global StyleResult rules into a CSS text string.\n *\n * Rules already have their full selectors applied by renderStyles().\n * Handles rootPrefix prepending and at-rule wrapping.\n */\nexport function formatGlobalRules(rules: StyleResult[]): string {\n if (rules.length === 0) return '';\n\n const cssRules: string[] = [];\n\n for (const rule of rules) {\n const selector = rule.rootPrefix\n ? `${rule.rootPrefix} ${rule.selector}`\n : rule.selector;\n\n const baseRule = `${selector} { ${rule.declarations} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,kBAAkB,OAA8B;AAC9D,KAAI,MAAM,WAAW,EAAG,QAAO;CAE/B,MAAM,WAAqB,EAAE;AAE7B,MAAK,MAAM,QAAQ,OAAO;EAKxB,MAAM,WAAW,GAJA,KAAK,aAClB,GAAG,KAAK,WAAW,GAAG,KAAK,aAC3B,KAAK,SAEoB,KAAK,KAAK,aAAa;EAEpD,IAAI,WAAW;AACf,MAAI,KAAK,WAAW,KAAK,QAAQ,SAAS,EACxC,YAAW,KAAK,QAAQ,QACrB,KAAK,WAAW,GAAG,OAAO,KAAK,IAAI,KACpC,SACD;AAGH,WAAS,KAAK,SAAS;;AAGzB,QAAO,SAAS,KAAK,KAAK"}
@@ -1,69 +0,0 @@
1
- import { createStyle } from "../styles/createStyle.js";
2
- import { STYLE_HANDLER_MAP } from "../styles/index.js";
3
- //#region src/ssr/format-keyframes.ts
4
- /**
5
- * Convert keyframes steps to a CSS string.
6
- * Replicates SheetManager.stepsToCSS() without the class instance.
7
- */
8
- function stepsToCSS(steps) {
9
- const rules = [];
10
- for (const [key, value] of Object.entries(steps)) {
11
- if (typeof value === "string") {
12
- rules.push(`${key} { ${value.trim()} }`);
13
- continue;
14
- }
15
- const styleMap = value || {};
16
- const styleNames = Object.keys(styleMap).sort();
17
- const handlerQueue = [];
18
- const seenHandlers = /* @__PURE__ */ new Set();
19
- styleNames.forEach((styleName) => {
20
- let handlers = STYLE_HANDLER_MAP[styleName];
21
- if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
22
- handlers.forEach((handler) => {
23
- if (!seenHandlers.has(handler)) {
24
- seenHandlers.add(handler);
25
- handlerQueue.push(handler);
26
- }
27
- });
28
- });
29
- const declarationPairs = [];
30
- handlerQueue.forEach((handler) => {
31
- const result = handler(handler.__lookupStyles.reduce((acc, name) => {
32
- const v = styleMap[name];
33
- if (v !== void 0) acc[name] = v;
34
- return acc;
35
- }, {}));
36
- if (!result) return;
37
- (Array.isArray(result) ? result : [result]).forEach((cssMap) => {
38
- if (!cssMap || typeof cssMap !== "object") return;
39
- const { $: _$, ...props } = cssMap;
40
- Object.entries(props).forEach(([prop, val]) => {
41
- if (val == null || val === "") return;
42
- if (Array.isArray(val)) val.forEach((v) => {
43
- if (v != null && v !== "") declarationPairs.push({
44
- prop,
45
- value: String(v)
46
- });
47
- });
48
- else declarationPairs.push({
49
- prop,
50
- value: String(val)
51
- });
52
- });
53
- });
54
- });
55
- const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
56
- rules.push(`${key} { ${declarations.trim()} }`);
57
- }
58
- return rules.join(" ");
59
- }
60
- /**
61
- * Format a @keyframes rule as a CSS string.
62
- */
63
- function formatKeyframesCSS(name, steps) {
64
- return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
65
- }
66
- //#endregion
67
- export { formatKeyframesCSS };
68
-
69
- //# sourceMappingURL=format-keyframes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-keyframes.js","names":[],"sources":["../../src/ssr/format-keyframes.ts"],"sourcesContent":["/**\n * Format @keyframes CSS rules for SSR output.\n *\n * Replicates the stepsToCSS logic from SheetManager but as a\n * standalone function that doesn't need DOM access.\n */\n\nimport type { KeyframesSteps } from '../injector/types';\nimport { createStyle, STYLE_HANDLER_MAP } from '../styles';\nimport type { CSSMap, StyleHandler, StyleValueStateMap } from '../utils/styles';\n\n/**\n * Convert keyframes steps to a CSS string.\n * Replicates SheetManager.stepsToCSS() without the class instance.\n */\nfunction stepsToCSS(steps: KeyframesSteps): string {\n const rules: string[] = [];\n\n for (const [key, value] of Object.entries(steps)) {\n if (typeof value === 'string') {\n rules.push(`${key} { ${value.trim()} }`);\n continue;\n }\n\n const styleMap = (value || {}) as StyleValueStateMap;\n const styleNames = Object.keys(styleMap).sort();\n const handlerQueue: StyleHandler[] = [];\n const seenHandlers = new Set<StyleHandler>();\n\n styleNames.forEach((styleName) => {\n let handlers = STYLE_HANDLER_MAP[styleName];\n if (!handlers) {\n handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];\n }\n\n handlers.forEach((handler) => {\n if (!seenHandlers.has(handler)) {\n seenHandlers.add(handler);\n handlerQueue.push(handler);\n }\n });\n });\n\n const declarationPairs: { prop: string; value: string }[] = [];\n\n handlerQueue.forEach((handler) => {\n const lookup = handler.__lookupStyles;\n const filteredMap = lookup.reduce<StyleValueStateMap>((acc, name) => {\n const v = styleMap[name];\n if (v !== undefined) acc[name] = v;\n return acc;\n }, {});\n\n const result = handler(filteredMap);\n if (!result) return;\n\n const results = Array.isArray(result) ? result : [result];\n results.forEach((cssMap) => {\n if (!cssMap || typeof cssMap !== 'object') return;\n const { $: _$, ...props } = cssMap as CSSMap;\n\n Object.entries(props).forEach(([prop, val]) => {\n if (val == null || val === '') return;\n\n if (Array.isArray(val)) {\n val.forEach((v) => {\n if (v != null && v !== '') {\n declarationPairs.push({ prop, value: String(v) });\n }\n });\n } else {\n declarationPairs.push({ prop, value: String(val) });\n }\n });\n });\n });\n\n const declarations = declarationPairs\n .map((d) => `${d.prop}: ${d.value}`)\n .join('; ');\n\n rules.push(`${key} { ${declarations.trim()} }`);\n }\n\n return rules.join(' ');\n}\n\n/**\n * Format a @keyframes rule as a CSS string.\n */\nexport function formatKeyframesCSS(\n name: string,\n steps: KeyframesSteps,\n): string {\n const cssSteps = stepsToCSS(steps);\n return `@keyframes ${name}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BAAiB,KAAK;OAAE;OAAM,OAAO,OAAO,EAAE;OAAE,CAAC;OAEnD;SAEF,kBAAiB,KAAK;MAAE;MAAM,OAAO,OAAO,IAAI;MAAE,CAAC;MAErD;KACF;IACF;EAEF,MAAM,eAAe,iBAClB,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,QAAQ,CACnC,KAAK,KAAK;AAEb,QAAM,KAAK,GAAG,IAAI,KAAK,aAAa,MAAM,CAAC,IAAI;;AAGjD,QAAO,MAAM,KAAK,IAAI;;;;;AAMxB,SAAgB,mBACd,MACA,OACQ;AAER,QAAO,cAAc,KAAK,KADT,WAAW,MAAM,CACM"}
@@ -1,49 +0,0 @@
1
- import { colorInitialValueToComponents, getColorSpaceSuffix, getComponentPropertySyntax } from "../utils/color-space.js";
2
- import { getEffectiveDefinition } from "../properties/index.js";
3
- import { parseStyle } from "../utils/styles.js";
4
- //#region src/ssr/format-property.ts
5
- /**
6
- * Format a single @property rule as a CSS string.
7
- *
8
- * Returns the full `@property --name { ... }` text, or empty string
9
- * if the token is invalid. For color properties, also returns
10
- * the companion component property.
11
- */
12
- function formatPropertyCSS(token, definition) {
13
- const result = getEffectiveDefinition(token, definition);
14
- if (!result.isValid) return "";
15
- const rules = [];
16
- rules.push(buildPropertyRule(result.cssName, result.definition));
17
- if (result.isColor) {
18
- const suffix = getColorSpaceSuffix();
19
- const componentCssName = `${result.cssName}-${suffix}`;
20
- const componentInitial = colorInitialValueToComponents(result.definition.initialValue);
21
- rules.push(buildPropertyRule(componentCssName, {
22
- syntax: getComponentPropertySyntax(),
23
- inherits: result.definition.inherits,
24
- initialValue: componentInitial
25
- }));
26
- }
27
- return rules.join("\n");
28
- }
29
- function buildPropertyRule(cssName, definition) {
30
- const parts = [];
31
- if (definition.syntax != null) {
32
- let syntax = String(definition.syntax).trim();
33
- if (!/^['"]/u.test(syntax)) syntax = `"${syntax}"`;
34
- parts.push(`syntax: ${syntax};`);
35
- }
36
- const inherits = definition.inherits ?? true;
37
- parts.push(`inherits: ${inherits ? "true" : "false"};`);
38
- if (definition.initialValue != null) {
39
- let initialValueStr;
40
- if (typeof definition.initialValue === "number") initialValueStr = String(definition.initialValue);
41
- else initialValueStr = parseStyle(definition.initialValue).output;
42
- parts.push(`initial-value: ${initialValueStr};`);
43
- }
44
- return `@property ${cssName} { ${parts.join(" ").trim()} }`;
45
- }
46
- //#endregion
47
- export { formatPropertyCSS };
48
-
49
- //# sourceMappingURL=format-property.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-property.js","names":[],"sources":["../../src/ssr/format-property.ts"],"sourcesContent":["/**\n * Format @property CSS rules for SSR output.\n *\n * Replicates the CSS construction from StyleInjector.property()\n * but returns a CSS string instead of inserting into the DOM.\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { getEffectiveDefinition } from '../properties';\nimport {\n colorInitialValueToComponents,\n getColorSpaceSuffix,\n getComponentPropertySyntax,\n} from '../utils/color-space';\nimport type { StyleValue } from '../utils/styles';\nimport { parseStyle } from '../utils/styles';\n\n/**\n * Format a single @property rule as a CSS string.\n *\n * Returns the full `@property --name { ... }` text, or empty string\n * if the token is invalid. For color properties, also returns\n * the companion component property.\n */\nexport function formatPropertyCSS(\n token: string,\n definition: PropertyDefinition,\n): string {\n const result = getEffectiveDefinition(token, definition);\n if (!result.isValid) return '';\n\n const rules: string[] = [];\n\n rules.push(buildPropertyRule(result.cssName, result.definition));\n\n if (result.isColor) {\n const suffix = getColorSpaceSuffix();\n const componentCssName = `${result.cssName}-${suffix}`;\n const componentInitial = colorInitialValueToComponents(\n result.definition.initialValue,\n );\n rules.push(\n buildPropertyRule(componentCssName, {\n syntax: getComponentPropertySyntax(),\n inherits: result.definition.inherits,\n initialValue: componentInitial,\n }),\n );\n }\n\n return rules.join('\\n');\n}\n\nfunction buildPropertyRule(\n cssName: string,\n definition: PropertyDefinition,\n): string {\n const parts: string[] = [];\n\n if (definition.syntax != null) {\n let syntax = String(definition.syntax).trim();\n if (!/^['\"]/u.test(syntax)) syntax = `\"${syntax}\"`;\n parts.push(`syntax: ${syntax};`);\n }\n\n const inherits = definition.inherits ?? true;\n parts.push(`inherits: ${inherits ? 'true' : 'false'};`);\n\n if (definition.initialValue != null) {\n let initialValueStr: string;\n if (typeof definition.initialValue === 'number') {\n initialValueStr = String(definition.initialValue);\n } else {\n initialValueStr = parseStyle(\n definition.initialValue as StyleValue,\n ).output;\n }\n parts.push(`initial-value: ${initialValueStr};`);\n }\n\n const declarations = parts.join(' ').trim();\n return `@property ${cssName} { ${declarations} }`;\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAgB,kBACd,OACA,YACQ;CACR,MAAM,SAAS,uBAAuB,OAAO,WAAW;AACxD,KAAI,CAAC,OAAO,QAAS,QAAO;CAE5B,MAAM,QAAkB,EAAE;AAE1B,OAAM,KAAK,kBAAkB,OAAO,SAAS,OAAO,WAAW,CAAC;AAEhE,KAAI,OAAO,SAAS;EAClB,MAAM,SAAS,qBAAqB;EACpC,MAAM,mBAAmB,GAAG,OAAO,QAAQ,GAAG;EAC9C,MAAM,mBAAmB,8BACvB,OAAO,WAAW,aACnB;AACD,QAAM,KACJ,kBAAkB,kBAAkB;GAClC,QAAQ,4BAA4B;GACpC,UAAU,OAAO,WAAW;GAC5B,cAAc;GACf,CAAC,CACH;;AAGH,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,kBACP,SACA,YACQ;CACR,MAAM,QAAkB,EAAE;AAE1B,KAAI,WAAW,UAAU,MAAM;EAC7B,IAAI,SAAS,OAAO,WAAW,OAAO,CAAC,MAAM;AAC7C,MAAI,CAAC,SAAS,KAAK,OAAO,CAAE,UAAS,IAAI,OAAO;AAChD,QAAM,KAAK,WAAW,OAAO,GAAG;;CAGlC,MAAM,WAAW,WAAW,YAAY;AACxC,OAAM,KAAK,aAAa,WAAW,SAAS,QAAQ,GAAG;AAEvD,KAAI,WAAW,gBAAgB,MAAM;EACnC,IAAI;AACJ,MAAI,OAAO,WAAW,iBAAiB,SACrC,mBAAkB,OAAO,WAAW,aAAa;MAEjD,mBAAkB,WAChB,WAAW,aACZ,CAAC;AAEJ,QAAM,KAAK,kBAAkB,gBAAgB,GAAG;;AAIlD,QAAO,aAAa,QAAQ,KADP,MAAM,KAAK,IAAI,CAAC,MAAM,CACG"}
@@ -1,73 +0,0 @@
1
- //#region src/ssr/format-rules.ts
2
- /**
3
- * Resolve selectors for a rule, applying className-based specificity doubling
4
- * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().
5
- */
6
- function resolveSelector(rule, className) {
7
- let selector = rule.selector;
8
- if (rule.needsClassName) {
9
- const selectorParts = selector ? selector.split("|||") : [""];
10
- const classPrefix = `.${className}.${className}`;
11
- selector = selectorParts.map((part) => {
12
- const classSelector = part ? `${classPrefix}${part}` : classPrefix;
13
- if (rule.rootPrefix) return `${rule.rootPrefix} ${classSelector}`;
14
- return classSelector;
15
- }).join(", ");
16
- }
17
- return selector;
18
- }
19
- /**
20
- * Group rules by selector + at-rules + startingStyle and merge their declarations.
21
- * Mirrors the grouping logic in SheetManager.insertRule().
22
- */
23
- function groupRules(rules) {
24
- const groupMap = /* @__PURE__ */ new Map();
25
- const order = [];
26
- const atKey = (at) => at && at.length ? at.join("|") : "";
27
- for (const r of rules) {
28
- const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? "1" : "0"}`;
29
- const existing = groupMap.get(key);
30
- if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${r.declarations}` : r.declarations;
31
- else {
32
- groupMap.set(key, {
33
- selector: r.selector,
34
- atRules: r.atRules,
35
- startingStyle: r.startingStyle,
36
- declarations: r.declarations
37
- });
38
- order.push(key);
39
- }
40
- }
41
- return order.map((key) => groupMap.get(key));
42
- }
43
- /**
44
- * Format an array of StyleResult rules into a CSS text string.
45
- *
46
- * Applies className-based specificity doubling (.cls.cls),
47
- * groups rules by selector + at-rules, and wraps with at-rule blocks.
48
- *
49
- * Produces the same CSS text as SheetManager.insertRule() would insert
50
- * into the DOM, but as a plain string suitable for SSR output.
51
- */
52
- function formatRules(rules, className) {
53
- if (rules.length === 0) return "";
54
- const grouped = groupRules(rules.map((rule) => ({
55
- selector: resolveSelector(rule, className),
56
- declarations: rule.declarations,
57
- atRules: rule.atRules,
58
- startingStyle: rule.startingStyle
59
- })));
60
- const cssRules = [];
61
- for (const rule of grouped) {
62
- const innerContent = rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations;
63
- const baseRule = `${rule.selector} { ${innerContent} }`;
64
- let fullRule = baseRule;
65
- if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
66
- cssRules.push(fullRule);
67
- }
68
- return cssRules.join("\n");
69
- }
70
- //#endregion
71
- export { formatRules };
72
-
73
- //# sourceMappingURL=format-rules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-rules.js","names":[],"sources":["../../src/ssr/format-rules.ts"],"sourcesContent":["/**\n * Shared CSS rule formatting utility.\n *\n * Extracted from SheetManager to allow both the DOM-based injector (client)\n * and the ServerStyleCollector (server) to produce identical CSS text\n * from StyleResult arrays.\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Resolve selectors for a rule, applying className-based specificity doubling\n * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().\n */\nfunction resolveSelector(rule: StyleResult, className: string): string {\n let selector = rule.selector;\n\n if (rule.needsClassName) {\n const selectorParts = selector ? selector.split('|||') : [''];\n const classPrefix = `.${className}.${className}`;\n\n selector = selectorParts\n .map((part) => {\n const classSelector = part ? `${classPrefix}${part}` : classPrefix;\n\n if (rule.rootPrefix) {\n return `${rule.rootPrefix} ${classSelector}`;\n }\n return classSelector;\n })\n .join(', ');\n }\n\n return selector;\n}\n\ninterface GroupedRule {\n selector: string;\n declarations: string;\n atRules?: string[];\n startingStyle?: boolean;\n}\n\n/**\n * Group rules by selector + at-rules + startingStyle and merge their declarations.\n * Mirrors the grouping logic in SheetManager.insertRule().\n */\nfunction groupRules(rules: GroupedRule[]): GroupedRule[] {\n const groupMap = new Map<string, GroupedRule>();\n const order: string[] = [];\n\n const atKey = (at?: string[]) => (at && at.length ? at.join('|') : '');\n\n for (const r of rules) {\n const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? '1' : '0'}`;\n const existing = groupMap.get(key);\n if (existing) {\n existing.declarations = existing.declarations\n ? `${existing.declarations} ${r.declarations}`\n : r.declarations;\n } else {\n groupMap.set(key, {\n selector: r.selector,\n atRules: r.atRules,\n startingStyle: r.startingStyle,\n declarations: r.declarations,\n });\n order.push(key);\n }\n }\n\n return order.map((key) => groupMap.get(key)!);\n}\n\n/**\n * Format an array of StyleResult rules into a CSS text string.\n *\n * Applies className-based specificity doubling (.cls.cls),\n * groups rules by selector + at-rules, and wraps with at-rule blocks.\n *\n * Produces the same CSS text as SheetManager.insertRule() would insert\n * into the DOM, but as a plain string suitable for SSR output.\n */\nexport function formatRules(rules: StyleResult[], className: string): string {\n if (rules.length === 0) return '';\n\n const resolvedRules = rules.map((rule) => ({\n selector: resolveSelector(rule, className),\n declarations: rule.declarations,\n atRules: rule.atRules,\n startingStyle: rule.startingStyle,\n }));\n\n const grouped = groupRules(resolvedRules);\n const cssRules: string[] = [];\n\n for (const rule of grouped) {\n const innerContent = rule.startingStyle\n ? `@starting-style { ${rule.declarations} }`\n : rule.declarations;\n const baseRule = `${rule.selector} { ${innerContent} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":";;;;;AAcA,SAAS,gBAAgB,MAAmB,WAA2B;CACrE,IAAI,WAAW,KAAK;AAEpB,KAAI,KAAK,gBAAgB;EACvB,MAAM,gBAAgB,WAAW,SAAS,MAAM,MAAM,GAAG,CAAC,GAAG;EAC7D,MAAM,cAAc,IAAI,UAA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