@tenphi/tasty 0.0.0-snapshot.db103fd → 0.0.0-snapshot.dc62ea3

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 (365) hide show
  1. package/README.md +196 -140
  2. package/dist/astro-CeYENy2x.js +301 -0
  3. package/dist/astro-CeYENy2x.js.map +1 -0
  4. package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +16 -6
  5. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  6. package/dist/babel-DWCsafYw.d.ts +83 -0
  7. package/dist/collector-B3OsM252.js +327 -0
  8. package/dist/collector-B3OsM252.js.map +1 -0
  9. package/dist/collector-BTVXj2hS.d.ts +163 -0
  10. package/dist/config-B3gPdCqd.js +12421 -0
  11. package/dist/config-B3gPdCqd.js.map +1 -0
  12. package/dist/config-LfIDmVHx.d.ts +1363 -0
  13. package/dist/context-CA8YKeMn.js +24 -0
  14. package/dist/context-CA8YKeMn.js.map +1 -0
  15. package/dist/core/index.d.ts +5 -33
  16. package/dist/core/index.js +6 -26
  17. package/dist/core-DGm0CFHP.js +1732 -0
  18. package/dist/core-DGm0CFHP.js.map +1 -0
  19. package/dist/css-resources-Cyl_axbI.js +149 -0
  20. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  21. package/dist/{zero/extractor.js → css-writer-Bgowobbx.js} +148 -24
  22. package/dist/css-writer-Bgowobbx.js.map +1 -0
  23. package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +2 -2
  24. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  25. package/dist/{ssr/format-rules.js → format-rules-XRw9u7d4.js} +33 -2
  26. package/dist/format-rules-XRw9u7d4.js.map +1 -0
  27. package/dist/hydrate-CNOmZprz.js +37 -0
  28. package/dist/hydrate-CNOmZprz.js.map +1 -0
  29. package/dist/index-Bm9ltvdH.d.ts +1933 -0
  30. package/dist/index-BmogEzTo.d.ts +1575 -0
  31. package/dist/index.d.ts +5 -50
  32. package/dist/index.js +922 -35
  33. package/dist/index.js.map +1 -0
  34. package/dist/keyframes-DE-OE76F.js +535 -0
  35. package/dist/keyframes-DE-OE76F.js.map +1 -0
  36. package/dist/{utils/merge-styles.d.ts → merge-styles-BcLl1u_d.d.ts} +3 -3
  37. package/dist/{utils/merge-styles.js → merge-styles-DuoZEsm9.js} +3 -4
  38. package/dist/merge-styles-DuoZEsm9.js.map +1 -0
  39. package/dist/{utils/resolve-recipes.js → resolve-recipes-H9NqOQuP.js} +4 -6
  40. package/dist/resolve-recipes-H9NqOQuP.js.map +1 -0
  41. package/dist/ssr/astro-client.js +19 -0
  42. package/dist/ssr/astro-client.js.map +1 -0
  43. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  44. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  45. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  46. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  47. package/dist/ssr/astro-middleware-extract.js +9 -0
  48. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  49. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  50. package/dist/ssr/astro-middleware-static.js +18 -0
  51. package/dist/ssr/astro-middleware-static.js.map +1 -0
  52. package/dist/ssr/astro-middleware.d.ts +19 -0
  53. package/dist/ssr/astro-middleware.js +19 -0
  54. package/dist/ssr/astro-middleware.js.map +1 -0
  55. package/dist/ssr/astro.d.ts +117 -11
  56. package/dist/ssr/astro.js +2 -64
  57. package/dist/ssr/index.d.ts +37 -5
  58. package/dist/ssr/index.js +6 -7
  59. package/dist/ssr/index.js.map +1 -1
  60. package/dist/ssr/next-config.d.ts +66 -0
  61. package/dist/ssr/next-config.js +115 -0
  62. package/dist/ssr/next-config.js.map +1 -0
  63. package/dist/ssr/next.d.ts +14 -7
  64. package/dist/ssr/next.js +38 -16
  65. package/dist/ssr/next.js.map +1 -1
  66. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  67. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  68. package/dist/static/index.d.ts +91 -5
  69. package/dist/static/index.js +49 -3
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.js.map +1 -1
  72. package/dist/zero/babel.d.ts +2 -182
  73. package/dist/zero/babel.js +80 -40
  74. package/dist/zero/babel.js.map +1 -1
  75. package/dist/zero/index.d.ts +81 -3
  76. package/dist/zero/index.js +2 -3
  77. package/dist/zero/next.d.ts +1 -1
  78. package/dist/zero/next.js +1 -1
  79. package/dist/zero/next.js.map +1 -1
  80. package/docs/README.md +20 -12
  81. package/docs/adoption.md +59 -32
  82. package/docs/ai-agents.md +224 -0
  83. package/docs/comparison.md +76 -48
  84. package/docs/configuration.md +566 -69
  85. package/docs/debug.md +35 -18
  86. package/docs/design-system.md +63 -32
  87. package/docs/dsl.md +527 -179
  88. package/docs/getting-started.md +62 -41
  89. package/docs/injector.md +157 -51
  90. package/docs/methodology.md +116 -35
  91. package/docs/migration-v3.md +285 -0
  92. package/docs/pipeline.md +741 -0
  93. package/docs/plugins.md +353 -0
  94. package/docs/react-api.md +681 -0
  95. package/docs/runtime-benchmarks.md +351 -0
  96. package/docs/ssr.md +356 -130
  97. package/docs/styles.md +79 -16
  98. package/docs/tasty-static.md +149 -87
  99. package/package.json +78 -23
  100. package/tasty.config.ts +6 -0
  101. package/dist/_virtual/_rolldown/runtime.js +0 -7
  102. package/dist/chunks/cacheKey.js +0 -77
  103. package/dist/chunks/cacheKey.js.map +0 -1
  104. package/dist/chunks/definitions.d.ts +0 -37
  105. package/dist/chunks/definitions.js +0 -258
  106. package/dist/chunks/definitions.js.map +0 -1
  107. package/dist/chunks/index.d.ts +0 -1
  108. package/dist/chunks/renderChunk.d.ts +0 -1
  109. package/dist/chunks/renderChunk.js +0 -59
  110. package/dist/chunks/renderChunk.js.map +0 -1
  111. package/dist/config.d.ts +0 -366
  112. package/dist/config.js +0 -503
  113. package/dist/config.js.map +0 -1
  114. package/dist/counter-style/index.js +0 -51
  115. package/dist/counter-style/index.js.map +0 -1
  116. package/dist/debug.d.ts +0 -89
  117. package/dist/debug.js +0 -453
  118. package/dist/debug.js.map +0 -1
  119. package/dist/font-face/index.js +0 -63
  120. package/dist/font-face/index.js.map +0 -1
  121. package/dist/hooks/index.d.ts +0 -7
  122. package/dist/hooks/resolve-ssr-collector.js +0 -14
  123. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  124. package/dist/hooks/useCounterStyle.d.ts +0 -50
  125. package/dist/hooks/useCounterStyle.js +0 -46
  126. package/dist/hooks/useCounterStyle.js.map +0 -1
  127. package/dist/hooks/useFontFace.d.ts +0 -43
  128. package/dist/hooks/useFontFace.js +0 -70
  129. package/dist/hooks/useFontFace.js.map +0 -1
  130. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  131. package/dist/hooks/useGlobalStyles.js +0 -78
  132. package/dist/hooks/useGlobalStyles.js.map +0 -1
  133. package/dist/hooks/useKeyframes.d.ts +0 -56
  134. package/dist/hooks/useKeyframes.js +0 -64
  135. package/dist/hooks/useKeyframes.js.map +0 -1
  136. package/dist/hooks/useProperty.d.ts +0 -79
  137. package/dist/hooks/useProperty.js +0 -109
  138. package/dist/hooks/useProperty.js.map +0 -1
  139. package/dist/hooks/useRawCSS.d.ts +0 -53
  140. package/dist/hooks/useRawCSS.js +0 -35
  141. package/dist/hooks/useRawCSS.js.map +0 -1
  142. package/dist/hooks/useStyles.d.ts +0 -45
  143. package/dist/hooks/useStyles.js +0 -237
  144. package/dist/hooks/useStyles.js.map +0 -1
  145. package/dist/injector/index.d.ts +0 -183
  146. package/dist/injector/index.js +0 -179
  147. package/dist/injector/index.js.map +0 -1
  148. package/dist/injector/injector.d.ts +0 -166
  149. package/dist/injector/injector.js +0 -464
  150. package/dist/injector/injector.js.map +0 -1
  151. package/dist/injector/sheet-manager.d.ts +0 -136
  152. package/dist/injector/sheet-manager.js +0 -733
  153. package/dist/injector/sheet-manager.js.map +0 -1
  154. package/dist/injector/types.d.ts +0 -204
  155. package/dist/keyframes/index.js +0 -206
  156. package/dist/keyframes/index.js.map +0 -1
  157. package/dist/parser/classify.js +0 -319
  158. package/dist/parser/classify.js.map +0 -1
  159. package/dist/parser/const.js +0 -49
  160. package/dist/parser/const.js.map +0 -1
  161. package/dist/parser/lru.js +0 -109
  162. package/dist/parser/lru.js.map +0 -1
  163. package/dist/parser/parser.d.ts +0 -25
  164. package/dist/parser/parser.js +0 -115
  165. package/dist/parser/parser.js.map +0 -1
  166. package/dist/parser/tokenizer.js +0 -69
  167. package/dist/parser/tokenizer.js.map +0 -1
  168. package/dist/parser/types.d.ts +0 -51
  169. package/dist/parser/types.js +0 -46
  170. package/dist/parser/types.js.map +0 -1
  171. package/dist/pipeline/conditions.d.ts +0 -134
  172. package/dist/pipeline/conditions.js +0 -406
  173. package/dist/pipeline/conditions.js.map +0 -1
  174. package/dist/pipeline/exclusive.js +0 -230
  175. package/dist/pipeline/exclusive.js.map +0 -1
  176. package/dist/pipeline/index.d.ts +0 -55
  177. package/dist/pipeline/index.js +0 -708
  178. package/dist/pipeline/index.js.map +0 -1
  179. package/dist/pipeline/materialize.js +0 -1103
  180. package/dist/pipeline/materialize.js.map +0 -1
  181. package/dist/pipeline/parseStateKey.d.ts +0 -15
  182. package/dist/pipeline/parseStateKey.js +0 -446
  183. package/dist/pipeline/parseStateKey.js.map +0 -1
  184. package/dist/pipeline/simplify.js +0 -515
  185. package/dist/pipeline/simplify.js.map +0 -1
  186. package/dist/pipeline/warnings.js +0 -18
  187. package/dist/pipeline/warnings.js.map +0 -1
  188. package/dist/plugins/index.d.ts +0 -2
  189. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  190. package/dist/plugins/okhsl-plugin.js +0 -97
  191. package/dist/plugins/okhsl-plugin.js.map +0 -1
  192. package/dist/plugins/types.d.ts +0 -76
  193. package/dist/properties/index.js +0 -222
  194. package/dist/properties/index.js.map +0 -1
  195. package/dist/properties/property-type-resolver.d.ts +0 -24
  196. package/dist/properties/property-type-resolver.js +0 -90
  197. package/dist/properties/property-type-resolver.js.map +0 -1
  198. package/dist/ssr/astro.js.map +0 -1
  199. package/dist/ssr/async-storage.d.ts +0 -17
  200. package/dist/ssr/async-storage.js.map +0 -1
  201. package/dist/ssr/collect-auto-properties.js +0 -39
  202. package/dist/ssr/collect-auto-properties.js.map +0 -1
  203. package/dist/ssr/collector.d.ts +0 -102
  204. package/dist/ssr/collector.js +0 -226
  205. package/dist/ssr/collector.js.map +0 -1
  206. package/dist/ssr/context.d.ts +0 -8
  207. package/dist/ssr/context.js +0 -13
  208. package/dist/ssr/context.js.map +0 -1
  209. package/dist/ssr/format-global-rules.js.map +0 -1
  210. package/dist/ssr/format-keyframes.js +0 -69
  211. package/dist/ssr/format-keyframes.js.map +0 -1
  212. package/dist/ssr/format-property.js +0 -49
  213. package/dist/ssr/format-property.js.map +0 -1
  214. package/dist/ssr/format-rules.js.map +0 -1
  215. package/dist/ssr/hydrate.d.ts +0 -22
  216. package/dist/ssr/hydrate.js +0 -49
  217. package/dist/ssr/hydrate.js.map +0 -1
  218. package/dist/ssr/ssr-collector-ref.js +0 -12
  219. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  220. package/dist/states/index.d.ts +0 -49
  221. package/dist/states/index.js +0 -170
  222. package/dist/states/index.js.map +0 -1
  223. package/dist/static/tastyStatic.d.ts +0 -46
  224. package/dist/static/tastyStatic.js +0 -30
  225. package/dist/static/tastyStatic.js.map +0 -1
  226. package/dist/static/types.d.ts +0 -49
  227. package/dist/static/types.js +0 -24
  228. package/dist/static/types.js.map +0 -1
  229. package/dist/styles/align.d.ts +0 -15
  230. package/dist/styles/align.js +0 -14
  231. package/dist/styles/align.js.map +0 -1
  232. package/dist/styles/border.d.ts +0 -25
  233. package/dist/styles/border.js +0 -113
  234. package/dist/styles/border.js.map +0 -1
  235. package/dist/styles/color.d.ts +0 -14
  236. package/dist/styles/color.js +0 -26
  237. package/dist/styles/color.js.map +0 -1
  238. package/dist/styles/createStyle.js +0 -79
  239. package/dist/styles/createStyle.js.map +0 -1
  240. package/dist/styles/dimension.js +0 -96
  241. package/dist/styles/dimension.js.map +0 -1
  242. package/dist/styles/display.d.ts +0 -37
  243. package/dist/styles/display.js +0 -66
  244. package/dist/styles/display.js.map +0 -1
  245. package/dist/styles/fade.d.ts +0 -15
  246. package/dist/styles/fade.js +0 -57
  247. package/dist/styles/fade.js.map +0 -1
  248. package/dist/styles/fill.d.ts +0 -42
  249. package/dist/styles/fill.js +0 -51
  250. package/dist/styles/fill.js.map +0 -1
  251. package/dist/styles/flow.d.ts +0 -16
  252. package/dist/styles/flow.js +0 -12
  253. package/dist/styles/flow.js.map +0 -1
  254. package/dist/styles/gap.d.ts +0 -31
  255. package/dist/styles/gap.js +0 -36
  256. package/dist/styles/gap.js.map +0 -1
  257. package/dist/styles/height.d.ts +0 -17
  258. package/dist/styles/height.js +0 -19
  259. package/dist/styles/height.js.map +0 -1
  260. package/dist/styles/index.d.ts +0 -1
  261. package/dist/styles/index.js +0 -8
  262. package/dist/styles/index.js.map +0 -1
  263. package/dist/styles/inset.d.ts +0 -52
  264. package/dist/styles/inset.js +0 -149
  265. package/dist/styles/inset.js.map +0 -1
  266. package/dist/styles/justify.d.ts +0 -15
  267. package/dist/styles/justify.js +0 -14
  268. package/dist/styles/justify.js.map +0 -1
  269. package/dist/styles/list.d.ts +0 -16
  270. package/dist/styles/list.js +0 -98
  271. package/dist/styles/list.js.map +0 -1
  272. package/dist/styles/margin.d.ts +0 -24
  273. package/dist/styles/margin.js +0 -103
  274. package/dist/styles/margin.js.map +0 -1
  275. package/dist/styles/outline.d.ts +0 -29
  276. package/dist/styles/outline.js +0 -64
  277. package/dist/styles/outline.js.map +0 -1
  278. package/dist/styles/padding.d.ts +0 -24
  279. package/dist/styles/padding.js +0 -103
  280. package/dist/styles/padding.js.map +0 -1
  281. package/dist/styles/predefined.d.ts +0 -71
  282. package/dist/styles/predefined.js +0 -237
  283. package/dist/styles/predefined.js.map +0 -1
  284. package/dist/styles/preset.d.ts +0 -52
  285. package/dist/styles/preset.js +0 -126
  286. package/dist/styles/preset.js.map +0 -1
  287. package/dist/styles/radius.d.ts +0 -12
  288. package/dist/styles/radius.js +0 -71
  289. package/dist/styles/radius.js.map +0 -1
  290. package/dist/styles/scrollbar.d.ts +0 -25
  291. package/dist/styles/scrollbar.js +0 -46
  292. package/dist/styles/scrollbar.js.map +0 -1
  293. package/dist/styles/shadow.d.ts +0 -14
  294. package/dist/styles/shadow.js +0 -23
  295. package/dist/styles/shadow.js.map +0 -1
  296. package/dist/styles/transition.d.ts +0 -14
  297. package/dist/styles/transition.js +0 -157
  298. package/dist/styles/transition.js.map +0 -1
  299. package/dist/styles/types.d.ts +0 -549
  300. package/dist/styles/width.d.ts +0 -17
  301. package/dist/styles/width.js +0 -19
  302. package/dist/styles/width.js.map +0 -1
  303. package/dist/tasty.d.ts +0 -119
  304. package/dist/tasty.js +0 -231
  305. package/dist/tasty.js.map +0 -1
  306. package/dist/types.d.ts +0 -184
  307. package/dist/utils/cache-wrapper.js +0 -21
  308. package/dist/utils/cache-wrapper.js.map +0 -1
  309. package/dist/utils/case-converter.js +0 -8
  310. package/dist/utils/case-converter.js.map +0 -1
  311. package/dist/utils/color-math.d.ts +0 -46
  312. package/dist/utils/color-math.js +0 -749
  313. package/dist/utils/color-math.js.map +0 -1
  314. package/dist/utils/color-space.d.ts +0 -5
  315. package/dist/utils/color-space.js +0 -228
  316. package/dist/utils/color-space.js.map +0 -1
  317. package/dist/utils/colors.d.ts +0 -5
  318. package/dist/utils/colors.js +0 -10
  319. package/dist/utils/colors.js.map +0 -1
  320. package/dist/utils/css-types.d.ts +0 -7
  321. package/dist/utils/dotize.d.ts +0 -26
  322. package/dist/utils/dotize.js +0 -122
  323. package/dist/utils/dotize.js.map +0 -1
  324. package/dist/utils/filter-base-props.d.ts +0 -15
  325. package/dist/utils/filter-base-props.js +0 -45
  326. package/dist/utils/filter-base-props.js.map +0 -1
  327. package/dist/utils/get-display-name.d.ts +0 -7
  328. package/dist/utils/get-display-name.js +0 -10
  329. package/dist/utils/get-display-name.js.map +0 -1
  330. package/dist/utils/has-keys.js +0 -13
  331. package/dist/utils/has-keys.js.map +0 -1
  332. package/dist/utils/is-dev-env.js +0 -19
  333. package/dist/utils/is-dev-env.js.map +0 -1
  334. package/dist/utils/is-valid-element-type.js +0 -15
  335. package/dist/utils/is-valid-element-type.js.map +0 -1
  336. package/dist/utils/merge-styles.js.map +0 -1
  337. package/dist/utils/mod-attrs.d.ts +0 -6
  338. package/dist/utils/mod-attrs.js +0 -20
  339. package/dist/utils/mod-attrs.js.map +0 -1
  340. package/dist/utils/process-tokens.d.ts +0 -21
  341. package/dist/utils/process-tokens.js +0 -90
  342. package/dist/utils/process-tokens.js.map +0 -1
  343. package/dist/utils/resolve-recipes.d.ts +0 -17
  344. package/dist/utils/resolve-recipes.js.map +0 -1
  345. package/dist/utils/selector-transform.js +0 -32
  346. package/dist/utils/selector-transform.js.map +0 -1
  347. package/dist/utils/string.js +0 -8
  348. package/dist/utils/string.js.map +0 -1
  349. package/dist/utils/styles.d.ts +0 -99
  350. package/dist/utils/styles.js +0 -220
  351. package/dist/utils/styles.js.map +0 -1
  352. package/dist/utils/typography.d.ts +0 -47
  353. package/dist/utils/typography.js +0 -51
  354. package/dist/utils/typography.js.map +0 -1
  355. package/dist/utils/warnings.d.ts +0 -16
  356. package/dist/utils/warnings.js +0 -16
  357. package/dist/utils/warnings.js.map +0 -1
  358. package/dist/zero/css-writer.d.ts +0 -45
  359. package/dist/zero/css-writer.js +0 -73
  360. package/dist/zero/css-writer.js.map +0 -1
  361. package/dist/zero/extractor.d.ts +0 -24
  362. package/dist/zero/extractor.js.map +0 -1
  363. package/docs/PIPELINE.md +0 -519
  364. package/docs/runtime.md +0 -485
  365. /package/dist/{chunks/cacheKey.d.ts → ssr/astro-client.d.ts} +0 -0
@@ -0,0 +1,1363 @@
1
+ import { At as StyleRule, Ct as PropertyDefinition, Dt as RuleInfo, Et as RootRegistry, Ot as SheetInfo, P as StyleHandlerDefinition, St as KeyframesSteps, Tt as RawCSSResult, _t as InjectResult, b as Styles, bt as KeyframesInfo, dt as FunctionDefinition, gt as InjectOptions, h as ConfigTokens, ht as GlobalInjectResult, it as UnitHandler, kt as StyleInjectorConfig, lt as FontFaceDescriptors, mt as GCOptions, n as StyleResult, nt as StyleDetails, ot as CacheMetrics, pt as GCConfig, st as CounterStyleDescriptors, ut as FontFaceInput, v as RecipeStyles, xt as KeyframesResult } from "./index-BmogEzTo.js";
2
+
3
+ //#region src/prop-handlers.d.ts
4
+ /**
5
+ * Props middleware for tasty components.
6
+ *
7
+ * A prop handler receives a component's props and returns them, changed or not.
8
+ * That makes it the extension point for props that are *not* style properties:
9
+ * it can read a custom prop, strip it so it never reaches the DOM, and fold its
10
+ * meaning into `styles`, `mods`, `tokens`, `variant`, or `as`.
11
+ *
12
+ * ```ts
13
+ * configure({
14
+ * propHandlers: {
15
+ * glaze: (props) => {
16
+ * const { glaze, ...rest } = props;
17
+ * if (!glaze) return rest;
18
+ * return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
19
+ * },
20
+ * },
21
+ * });
22
+ * ```
23
+ *
24
+ * Handlers run on every render of every tasty component, so the registry is a
25
+ * pre-composed chain that is `null` while nothing is registered — the cost when
26
+ * unused is one property load and one branch.
27
+ */
28
+ /** Props object handed to a prop handler. Deliberately untyped: handlers see everything. */
29
+ type PropHandlerProps = Record<string, unknown>;
30
+ /**
31
+ * Props middleware: props in, props out. Returning nothing means "unchanged".
32
+ *
33
+ * Must be a **pure function** and must not mutate its input. Style values are
34
+ * cached by object identity, so mutating a value object in place produces a stale
35
+ * class name and stale CSS. Return fresh (ideally frozen, ideally memoized)
36
+ * objects instead.
37
+ */
38
+ type PropHandler = (props: PropHandlerProps) => PropHandlerProps | void | null;
39
+ /**
40
+ * How a prop handler is declared. The map key is both its name and, by default,
41
+ * the prop that triggers it.
42
+ *
43
+ * - `fn` — triggered when a prop matching the key is present
44
+ * - `['glaze', fn]` — triggered by the named prop
45
+ * - `[['glaze', 'tone'], fn]` — triggered by any of them
46
+ * - `['*', fn]` — unconditional; runs on every render of every component
47
+ */
48
+ type PropHandlerDefinition = PropHandler | [string, PropHandler] | [string[], PropHandler];
49
+ //#endregion
50
+ //#region src/injector/sheet-manager.d.ts
51
+ declare class SheetManager {
52
+ private rootRegistries;
53
+ /** Strong set of active roots so background GC can iterate them all */
54
+ private activeRoots;
55
+ private config;
56
+ /** Dedicated style elements for raw CSS per root */
57
+ private rawStyleElements;
58
+ /** Constructable sheets for raw CSS in adopted mode */
59
+ private rawConstructableSheets;
60
+ /** Tracking for raw CSS blocks per root */
61
+ private rawCSSBlocks;
62
+ /** Counter for generating unique raw CSS IDs */
63
+ private rawCSSCounter;
64
+ constructor(config: StyleInjectorConfig);
65
+ /**
66
+ * Resolve the underlying CSSStyleSheet from a SheetInfo,
67
+ * abstracting away adopted vs style-element modes.
68
+ */
69
+ getCSSSheet(sheetInfo: SheetInfo): CSSStyleSheet | null;
70
+ /**
71
+ * Record an inserted rule text at its rule index (text mode only).
72
+ *
73
+ * `textRules` mirrors the sheet's rule order. `textContent` cannot be edited
74
+ * rule-by-rule the way CSSOM can, so keeping the texts is what makes
75
+ * deletion possible at all in this mode.
76
+ */
77
+ private trackTextRule;
78
+ /**
79
+ * Remove rule indices from a text-mode sheet and rewrite the element's text.
80
+ * Returns the indices that were actually removed.
81
+ */
82
+ private deleteTextRules;
83
+ /**
84
+ * Determine the injection mode for a root.
85
+ * ShadowRoot uses adopted stylesheets when supported; Document uses <style> elements.
86
+ */
87
+ private detectInjectionMode;
88
+ /**
89
+ * Get or create registry for a root (Document or ShadowRoot)
90
+ */
91
+ getRegistry(root: Document | ShadowRoot): RootRegistry;
92
+ /** Return all roots with active registries (for background GC sweep). */
93
+ getActiveRoots(): Iterable<Document | ShadowRoot>;
94
+ /** Check whether any roots have active registries. */
95
+ hasActiveRoots(): boolean;
96
+ /** Remove registries for ShadowRoots whose host has been detached from the DOM. */
97
+ pruneDisconnectedRoots(): void;
98
+ /**
99
+ * Create a new stylesheet for the registry.
100
+ * In adopted mode (ShadowRoot), creates a constructable CSSStyleSheet and
101
+ * pushes it to adoptedStyleSheets. Otherwise creates a <style> element.
102
+ */
103
+ createSheet(registry: RootRegistry, root: Document | ShadowRoot): SheetInfo;
104
+ /**
105
+ * Create a style element and append to document
106
+ */
107
+ private createStyleElement;
108
+ /**
109
+ * Insert CSS rules as a single block
110
+ */
111
+ insertRule(registry: RootRegistry, flattenedRules: StyleRule[], className: string, root: Document | ShadowRoot): RuleInfo | null;
112
+ /**
113
+ * Insert global CSS rules
114
+ */
115
+ insertGlobalRule(registry: RootRegistry, flattenedRules: StyleRule[], globalKey: string, root: Document | ShadowRoot): RuleInfo | null;
116
+ /**
117
+ * Delete a global CSS rule by key
118
+ */
119
+ deleteGlobalRule(registry: RootRegistry, globalKey: string): void;
120
+ /**
121
+ * Adjust rule indices after deletion to account for shifting
122
+ */
123
+ private adjustIndicesAfterDeletion;
124
+ /**
125
+ * Delete a CSS rule from the sheet
126
+ */
127
+ deleteRule(registry: RootRegistry, ruleInfo: RuleInfo): void;
128
+ /**
129
+ * Find a sheet with available space or return null
130
+ */
131
+ private findAvailableSheet;
132
+ /**
133
+ * Find an available rule index in the sheet
134
+ */
135
+ findAvailableRuleIndex(sheet: SheetInfo): number;
136
+ /**
137
+ * Probe whether the underlying CSS engine supports `@property` at-rules.
138
+ * Result is cached per registry on `registry.atPropertySupported`.
139
+ *
140
+ * The probe inserts and immediately deletes a minimal known-valid rule
141
+ * (`@property --__tasty_probe__ { syntax: "*"; inherits: true; }`).
142
+ * Engines that lack `@property` support (jsdom, happy-dom) reject any
143
+ * `@property` rule including this one, so a probe failure is a reliable
144
+ * signal that further `@property` rejections are environmental noise and
145
+ * not user-authored bugs.
146
+ *
147
+ * The probe is intentionally a separate operation from the user's failing
148
+ * insertion: we don't want to leak `--__tasty_probe__` into the sheet, so
149
+ * on success we delete the probe rule immediately, leaving `ruleCount`
150
+ * and `cssRules.length` unchanged.
151
+ */
152
+ private engineSupportsAtProperty;
153
+ /**
154
+ * Delete the given classes: their rules leave the sheets and every registry
155
+ * entry pointing at them is dropped.
156
+ *
157
+ * Deciding *what* is unused belongs to `StyleInjector.gc()`, which owns the
158
+ * DOM scan and the capacity policy. This only re-checks that each class is
159
+ * still safe to delete, and reports how many were.
160
+ *
161
+ * @returns Number of classes actually deleted.
162
+ */
163
+ deleteClasses(registry: RootRegistry, classNames: Iterable<string>): number;
164
+ /**
165
+ * Get total number of rules across all sheets
166
+ */
167
+ getTotalRuleCount(registry: RootRegistry): number;
168
+ /**
169
+ * The CSS of one managed sheet, or `null` when it holds none this can read —
170
+ * an empty style element, or a sheet the engine refuses to hand over.
171
+ */
172
+ private readSheetCSS;
173
+ /**
174
+ * Get CSS text from all sheets (for SSR)
175
+ */
176
+ getCSSText(registry: RootRegistry): string;
177
+ /**
178
+ * Get cache performance metrics
179
+ */
180
+ getMetrics(registry: RootRegistry): CacheMetrics | null;
181
+ /**
182
+ * Reset cache performance metrics
183
+ */
184
+ resetMetrics(registry: RootRegistry): void;
185
+ /**
186
+ * Convert keyframes steps to CSS string.
187
+ * Public so the SSR collector can format keyframes without DOM access.
188
+ * Returns both the CSS text and a combined declarations string for property type scanning.
189
+ */
190
+ stepsToCSS(steps: KeyframesSteps): {
191
+ css: string;
192
+ declarations: string;
193
+ };
194
+ /**
195
+ * Insert keyframes rule.
196
+ * Returns the KeyframesInfo and the raw declarations string for property type scanning.
197
+ */
198
+ insertKeyframes(registry: RootRegistry, steps: KeyframesSteps, name: string, root: Document | ShadowRoot): {
199
+ info: KeyframesInfo;
200
+ declarations: string;
201
+ } | null;
202
+ /**
203
+ * Delete keyframes rule
204
+ */
205
+ deleteKeyframes(registry: RootRegistry, info: KeyframesInfo): void;
206
+ /**
207
+ * Clean up resources for a root
208
+ */
209
+ cleanup(root: Document | ShadowRoot): void;
210
+ /**
211
+ * Check if a root uses adopted injection mode.
212
+ */
213
+ private isAdoptedMode;
214
+ /**
215
+ * Get or create a constructable CSSStyleSheet for raw CSS in adopted mode.
216
+ * The raw sheet is prepended to adoptedStyleSheets so it precedes tasty rules.
217
+ */
218
+ private getOrCreateRawAdoptedSheet;
219
+ /**
220
+ * Get or create a dedicated style element for raw CSS
221
+ * Raw CSS is kept separate from tasty-managed sheets to avoid index conflicts
222
+ */
223
+ private getOrCreateRawStyleElement;
224
+ /**
225
+ * Inject raw CSS text directly without parsing
226
+ * Returns a dispose function to remove the injected CSS
227
+ */
228
+ injectRawCSS(css: string, root: Document | ShadowRoot): RawCSSResult;
229
+ /**
230
+ * Rebuild the raw CSS constructable sheet from all tracked blocks.
231
+ */
232
+ private rebuildRawAdoptedSheet;
233
+ /**
234
+ * Remove a raw CSS block by ID
235
+ */
236
+ private disposeRawCSS;
237
+ /**
238
+ * Get the raw CSS content
239
+ */
240
+ /**
241
+ * The CSS this injector owns in `root`, one entry per sheet, in the order the
242
+ * engine applies them.
243
+ *
244
+ * `getCSSText()` walks the managed sheets only, and raw CSS has its own —
245
+ * which sits before, after, or *between* them depending on how it got there:
246
+ * prepended to `adoptedStyleSheets`, or wherever in `<head>` the first raw
247
+ * injection happened to land, with every managed sheet opened afterwards
248
+ * following it. Reporting a fixed order would describe the opposite winner
249
+ * from the live page whenever two rules of equal specificity meet, so the raw
250
+ * sheet is spliced in at the position the DOM actually gives it.
251
+ */
252
+ getOwnedCSSInOrder(registry: RootRegistry, root: Document | ShadowRoot): string[];
253
+ /**
254
+ * Top-level rules in the raw sheet.
255
+ *
256
+ * Read from the sheet the engine parsed, not from the text: a raw block is
257
+ * one string but any number of rules, and one rule — `@keyframes`, `@media` —
258
+ * can contain any number of blocks, so counting braces answers neither
259
+ * question.
260
+ */
261
+ getRawRuleCount(root: Document | ShadowRoot): number;
262
+ getRawCSSText(root: Document | ShadowRoot): string;
263
+ }
264
+ //#endregion
265
+ //#region src/injector/injector.d.ts
266
+ declare class StyleInjector {
267
+ private sheetManager;
268
+ private config;
269
+ private globalRuleCounter;
270
+ /** Cancels the scheduled sweep, whichever timer scheduled it. */
271
+ private cancelPendingGC;
272
+ private namePrefix;
273
+ private classRegex;
274
+ private rscClassRegex;
275
+ /** @internal — exposed for debug utilities only */
276
+ get _sheetManager(): SheetManager;
277
+ /**
278
+ * Whether sheet writes should be queued instead of applied immediately.
279
+ *
280
+ * Only ever true on the client: SSR collects CSS as text and the RSC path
281
+ * returns it as strings, so neither has a live sheet to batch writes against.
282
+ *
283
+ * In the default `true` mode a write is only queued inside an open batch
284
+ * window — a commit in which `<TastyBatchProvider>` rendered and will
285
+ * therefore flush in its insertion effect, before any layout effect can
286
+ * measure. Everything else falls through to a synchronous write, so enabling
287
+ * the flag cannot make a `useLayoutEffect` read an unstyled element.
288
+ * `'always'` drops the gate and accepts that trade for wider coverage.
289
+ */
290
+ private get batching();
291
+ /**
292
+ * Apply a sheet write now, or queue it when batching is on.
293
+ * Returns the queue handle when deferred, so the caller can cancel it if it
294
+ * disposes before the flush.
295
+ */
296
+ private writeSheet;
297
+ /**
298
+ * Insert a global (non-class) rule, honouring batching.
299
+ *
300
+ * `onApplied` records the caller's dedupe bookkeeping. When the write is
301
+ * queued it runs eagerly, so a repeat call before the flush bails out instead
302
+ * of queueing the same rule twice — the same reasoning as
303
+ * `insertPropertyRule`'s eager marking. When written synchronously it runs
304
+ * only on success, preserving the existing retry-on-failure behaviour.
305
+ */
306
+ private writeGlobalRule;
307
+ constructor(config?: StyleInjectorConfig);
308
+ /**
309
+ * Generate a deterministic class name from a cache key using content hash.
310
+ * The same cache key always produces the same class name across environments
311
+ * with the same `namePrefix`.
312
+ */
313
+ private generateClassName;
314
+ /**
315
+ * Check if `className` was hydrated from server-rendered styles and,
316
+ * if so, wire the cacheKey mapping. Returns true on hit.
317
+ */
318
+ private tryHydratedHit;
319
+ /**
320
+ * Allocate a className for a cacheKey without injecting styles yet.
321
+ * This allows separating className allocation (render phase) from style injection (insertion phase).
322
+ */
323
+ allocateClassName(cacheKey: string, options?: {
324
+ root?: Document | ShadowRoot;
325
+ }): {
326
+ className: string;
327
+ isNewAllocation: boolean;
328
+ };
329
+ /**
330
+ * Inject styles from StyleResult objects
331
+ */
332
+ inject(rules: StyleResult[], options?: InjectOptions): InjectResult;
333
+ /**
334
+ * Inject global styles (rules without a generated tasty class selector)
335
+ * This ensures we don't reserve a tasty class name (t{number}) for global rules,
336
+ * which could otherwise collide with element-level styles and break lookups.
337
+ */
338
+ injectGlobal(rules: StyleResult[], options?: {
339
+ root?: Document | ShadowRoot;
340
+ }): GlobalInjectResult;
341
+ /**
342
+ * Inject raw CSS text directly without parsing
343
+ * This is a low-overhead alternative to createGlobalStyle for raw CSS
344
+ * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking
345
+ */
346
+ injectRawCSS(css: string, options?: {
347
+ root?: Document | ShadowRoot;
348
+ }): RawCSSResult;
349
+ /**
350
+ * Get raw CSS text for SSR
351
+ */
352
+ getRawCSSText(options?: {
353
+ root?: Document | ShadowRoot;
354
+ }): string;
355
+ /**
356
+ * Take a reference on local `@keyframes`, under the deterministic names the
357
+ * caller resolved.
358
+ *
359
+ * One reference per distinct set of steps, shared by every class that ends up
360
+ * animating it, so a repeat render takes nothing further. Ownership is
361
+ * assigned by `ownKeyframes()` once the rules exist to be inspected.
362
+ */
363
+ holdKeyframes(steps: Record<string, KeyframesSteps>, names: Map<string, string>, options?: {
364
+ root?: Document | ShadowRoot;
365
+ }): Map<string, string>;
366
+ /**
367
+ * Record that `className` animates these keyframes, so the reference is
368
+ * released when the last such class is collected.
369
+ *
370
+ * Only classes whose rules actually reference the animation should be here:
371
+ * a class that merely rendered alongside one would otherwise keep the
372
+ * keyframes alive for as long as it lives.
373
+ */
374
+ ownKeyframes(key: string, className: string, options?: {
375
+ root?: Document | ShadowRoot;
376
+ }): void;
377
+ /**
378
+ * Pin an already-injected cacheKey and return the handle that releases it.
379
+ * For callers that skipped the pipeline on a cache hit but still need the
380
+ * class held. Returns null if the cacheKey is not found.
381
+ */
382
+ trackRef(cacheKey: string, options?: {
383
+ root?: Document | ShadowRoot;
384
+ }): InjectResult | null;
385
+ /**
386
+ * Release one pin on a className. At zero pins the class is not deleted — it
387
+ * stays cached and collectible, and `gc()` decides when it actually goes.
388
+ */
389
+ private unpin;
390
+ /**
391
+ * Remove every style that is neither in the DOM nor referenced by an
392
+ * outstanding `inject()` handle, ignoring the GC capacity threshold.
393
+ */
394
+ cleanup(root?: Document | ShadowRoot): void;
395
+ /**
396
+ * Get CSS text from all sheets (for SSR)
397
+ */
398
+ getCSSText(options?: {
399
+ root?: Document | ShadowRoot;
400
+ }): string;
401
+ /**
402
+ * Get CSS only for the provided tasty classNames (e.g., ["t0","t3"])
403
+ */
404
+ getCSSTextForClasses(classNames: Iterable<string>, options?: {
405
+ root?: Document | ShadowRoot;
406
+ }): string;
407
+ /**
408
+ * Get cache performance metrics
409
+ */
410
+ getMetrics(options?: {
411
+ root?: Document | ShadowRoot;
412
+ }): CacheMetrics | null;
413
+ /**
414
+ * Reset cache performance metrics
415
+ */
416
+ resetMetrics(options?: {
417
+ root?: Document | ShadowRoot;
418
+ }): void;
419
+ /**
420
+ * Define a CSS @property custom property.
421
+ *
422
+ * Accepts tasty token syntax for the property name:
423
+ * - `$name` → defines `--name`
424
+ * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
425
+ * - `--name` → defines `--name` (legacy format)
426
+ *
427
+ * Example:
428
+ * @property --rotation { syntax: "<angle>"; inherits: false; initial-value: 45deg; }
429
+ *
430
+ * Note: No caching or dispose — this defines a global property.
431
+ *
432
+ * If the same property is registered with different options, a warning is emitted
433
+ * but the original definition is preserved (CSS @property cannot be redefined).
434
+ */
435
+ property(name: string, options?: PropertyDefinition & {
436
+ root?: Document | ShadowRoot;
437
+ }): void;
438
+ /**
439
+ * Build and insert a single `@property` rule into the given registry.
440
+ * No-op if the property was already injected.
441
+ */
442
+ private insertPropertyRule;
443
+ /**
444
+ * Check whether a given @property name was already injected by this injector.
445
+ *
446
+ * Accepts tasty token syntax:
447
+ * - `$name` → checks `--name`
448
+ * - `#name` → checks `--name-color`
449
+ * - `--name` → checks `--name` (legacy format)
450
+ */
451
+ isPropertyDefined(name: string, options?: {
452
+ root?: Document | ShadowRoot;
453
+ }): boolean;
454
+ /**
455
+ * Inject a CSS @font-face rule.
456
+ *
457
+ * Permanent and global — no dispose or ref-counting.
458
+ * Deduplicates by content hash (family + descriptors).
459
+ */
460
+ fontFace(family: string, descriptors: FontFaceDescriptors, options?: {
461
+ root?: Document | ShadowRoot;
462
+ }): void;
463
+ /**
464
+ * Inject a CSS @counter-style rule.
465
+ *
466
+ * Permanent and global — no dispose or ref-counting. Deduplicates by name.
467
+ * By default a definition overrides a previously injected one of the same
468
+ * name. Pass `weak: true` for global `configure()` definitions, which must
469
+ * never clobber an existing rule (so component-local definitions win
470
+ * regardless of injection order).
471
+ */
472
+ counterStyle(name: string, descriptors: CounterStyleDescriptors, options?: {
473
+ root?: Document | ShadowRoot;
474
+ weak?: boolean;
475
+ }): void;
476
+ /**
477
+ * Inject a CSS @function rule (custom function).
478
+ *
479
+ * Permanent and global — no dispose or ref-counting. Deduplicates by function
480
+ * name. By default a definition overrides a previously injected one of the
481
+ * same name. Pass `weak: true` for global `configure()` definitions, which
482
+ * must never clobber an existing rule (so component-local definitions win
483
+ * regardless of injection order).
484
+ */
485
+ func(name: string, definition: FunctionDefinition, options?: {
486
+ root?: Document | ShadowRoot;
487
+ weak?: boolean;
488
+ }): void;
489
+ /**
490
+ * Inject keyframes and return object with toString() and dispose()
491
+ *
492
+ * Keyframes are cached by content (steps). If the same content is injected
493
+ * multiple times with different provided names, the first injected name is reused.
494
+ *
495
+ * If the same name is provided with different content (collision), a unique
496
+ * name is generated to avoid overwriting the existing keyframes.
497
+ */
498
+ keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
499
+ root?: Document | ShadowRoot;
500
+ name?: string;
501
+ /**
502
+ * Give this name its own rule even if another name already carries
503
+ * the same steps. Without it two names with identical steps share
504
+ * one rule under whichever name arrived first — fine when the caller
505
+ * only wants the animation, wrong when the name has to be the one it
506
+ * asked for.
507
+ */
508
+ distinctByName?: boolean;
509
+ }): KeyframesResult;
510
+ /**
511
+ * Dispose keyframes
512
+ */
513
+ private disposeKeyframes;
514
+ /**
515
+ * Count a render, and schedule a collection pass every `touchInterval` of
516
+ * them. Nothing else: what a class is worth keeping is decided by the sweep's
517
+ * own DOM scan, so rendering does not track usage at all.
518
+ *
519
+ * @deprecated The class name is ignored — pass anything, or stop calling it.
520
+ * Collection no longer records per-class usage, and scheduling does not need
521
+ * to know which class was rendered. A class handed back by `inject()` is
522
+ * marked wanted there, which is what reuse actually goes through.
523
+ */
524
+ touch(_className: string, options?: {
525
+ root?: Document | ShadowRoot;
526
+ }): void;
527
+ /**
528
+ * Schedule a GC in idle time. Runs GC on all active roots, and avoids
529
+ * double-scheduling.
530
+ *
531
+ * Idle only. Without `requestIdleCallback` nothing is collected
532
+ * automatically: running the sweep inline here would put it inside the render
533
+ * that touched the class, and collection is never urgent enough for that.
534
+ */
535
+ private scheduleGC;
536
+ /**
537
+ * The one definition of "unused": this injector owns the class's rules, no
538
+ * element in `root` carries it, and nobody pinned it.
539
+ *
540
+ * `gc()` evicts from this set, `getMetrics()` counts it, and `tastyDebug`
541
+ * reports it — all through here, so the three can never disagree about what
542
+ * "unused" means. Entries carry their last `touch()` so callers can drop the
543
+ * oldest first; a class that was never touched sorts as oldest.
544
+ */
545
+ /**
546
+ * Everything the injector holds falls into one of five bands, and only the
547
+ * last of them is ever deleted:
548
+ *
549
+ * 1. rendered — some element carries the class right now
550
+ * 2. not ours — queued for a batched write, pre-allocated, or server-rendered
551
+ * 3. hot — nothing carries it, but that was noticed less than `grace` ago
552
+ * 4. cached — cold, but within `capacity` when ordered by when it went cold
553
+ * 5. the rest
554
+ *
555
+ * This returns bands 4 and 5 together, most recently cold first; `gc()` draws
556
+ * the capacity line through them. Band 3 is what makes collection safe
557
+ * without a commit signal: a render can resolve a class and commit it a
558
+ * little later, and during that gap nothing on the page carries it.
559
+ */
560
+ private collectUnused;
561
+ /**
562
+ * Class names this injector holds CSS for that nothing renders and nobody
563
+ * pinned — exactly what `gc({ force: true })` would delete. Unordered.
564
+ */
565
+ getUnusedClasses(options?: {
566
+ root?: Document | ShadowRoot;
567
+ }): string[];
568
+ /**
569
+ * Synchronous garbage collection.
570
+ *
571
+ * 1. Quick upper-bound check: skip if the registry is smaller than capacity.
572
+ * 2. Scans the DOM for live tasty classNames — the DOM, not a ref count, is
573
+ * what says a class rendered by a component is still in use.
574
+ * 3. With `force: true`: deletes every unused class.
575
+ * Without `force`: keeps the `capacity` most recently touched and deletes
576
+ * the rest, oldest first.
577
+ *
578
+ * @returns Number of styles evicted.
579
+ */
580
+ gc(options?: GCOptions): number;
581
+ /**
582
+ * Destroy all resources for a root
583
+ */
584
+ destroy(root?: Document | ShadowRoot): void;
585
+ }
586
+ //#endregion
587
+ //#region src/functions/index.d.ts
588
+ /**
589
+ * A parse-time function: receives the parsed (comma-separated) argument groups
590
+ * and returns a CSS value string. This is the JS flavor of the unified
591
+ * `functions` config (bare-name keys), distinct from declarative `@function`
592
+ * definitions (`$$`-prefixed keys).
593
+ */
594
+ type ParseFunction = (groups: StyleDetails[]) => string;
595
+ /**
596
+ * The unified `functions` map: keys are either bare names (parse functions,
597
+ * value is a function) or `$$name`/`$name`/`--name` (declarative CSS functions,
598
+ * value is a {@link FunctionDefinition} object).
599
+ */
600
+ type FunctionsConfig = Record<string, FunctionDefinition | ParseFunction>;
601
+ //#endregion
602
+ //#region src/utils/color-space.d.ts
603
+ /**
604
+ * Color handling that survives into the emitted CSS.
605
+ *
606
+ * Tasty does not rewrite a color into a particular color space: opacity is
607
+ * applied with CSS relative color syntax, which reads the channels off whatever
608
+ * the browser resolves a value to, so a color is emitted exactly as authored.
609
+ * What is left here is how an alpha gets applied, and the one distinction that
610
+ * matters — replacing a token's alpha versus composing onto an inherited one.
611
+ */
612
+ /**
613
+ * The color space a `#name` token's value used to be rewritten into.
614
+ *
615
+ * @deprecated Kept for the `colorSpace` config option, which no longer has any
616
+ * effect. Colors are emitted as authored and opacity is always applied in
617
+ * `oklch` through relative color syntax.
618
+ */
619
+ type ColorSpace = 'rgb' | 'hsl' | 'oklch';
620
+ //#endregion
621
+ //#region src/utils/typography.d.ts
622
+ /**
623
+ * A typography token value: plain value or a state map for responsive/theme-aware presets.
624
+ *
625
+ * @example
626
+ * // Plain value
627
+ * fontWeight: '400'
628
+ * // State map
629
+ * fontWeight: { '': '400', '@dark': '300' }
630
+ */
631
+ type TypographyTokenValue = string | number | Record<string, string | number | undefined | null | '@inherit'>;
632
+ /**
633
+ * Typography preset configuration.
634
+ * Each preset defines font properties that get expanded into CSS custom properties.
635
+ * All fields accept plain values or state maps for responsive/theme-aware tokens.
636
+ *
637
+ * Use with `generateTypographyTokens()` to create typography tokens for your design system.
638
+ */
639
+ interface TypographyPreset {
640
+ fontSize: TypographyTokenValue;
641
+ lineHeight: TypographyTokenValue;
642
+ letterSpacing?: TypographyTokenValue;
643
+ fontWeight: TypographyTokenValue;
644
+ boldFontWeight?: TypographyTokenValue;
645
+ iconSize?: TypographyTokenValue;
646
+ textTransform?: TypographyTokenValue;
647
+ fontFamily?: TypographyTokenValue;
648
+ fontStyle?: TypographyTokenValue;
649
+ }
650
+ /**
651
+ * Generate typography tokens with $ prefix for CSS custom properties.
652
+ *
653
+ * Each preset generates the following CSS custom properties:
654
+ * - `${name}-font-size`
655
+ * - `${name}-line-height`
656
+ * - `${name}-letter-spacing`
657
+ * - `${name}-font-weight`
658
+ * - `${name}-bold-font-weight` (if defined)
659
+ * - `${name}-icon-size` (if defined)
660
+ * - `${name}-text-transform` (if defined)
661
+ * - `${name}-font-family` (if defined)
662
+ * - `${name}-font-style` (if defined)
663
+ *
664
+ * @param presets - Typography presets object
665
+ * @returns ConfigTokens object with $ prefixed keys
666
+ *
667
+ * @example
668
+ * const customTokens = generateTypographyTokens({
669
+ * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
670
+ * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
671
+ * });
672
+ */
673
+ declare function generateTypographyTokens(presets: Record<string, TypographyPreset>): ConfigTokens;
674
+ //#endregion
675
+ //#region src/plugins/types.d.ts
676
+ /**
677
+ * A tasty plugin that extends the style system with custom functions, units, states, or handlers.
678
+ */
679
+ interface TastyPlugin {
680
+ /** Unique name for the plugin (used for debugging and conflict detection) */
681
+ name: string;
682
+ /**
683
+ * Custom functions (unified map). Bare keys map to parse functions
684
+ * `(groups) => string`; `$$name` keys map to declarative CSS `@function`
685
+ * definitions. See {@link FunctionsConfig}.
686
+ */
687
+ functions?: FunctionsConfig;
688
+ /** Custom units that transform numeric values (e.g., `2x` → `calc(2 * var(--gap))`) */
689
+ units?: Record<string, string | UnitHandler>;
690
+ /** Custom state aliases (e.g., `'@mobile': '@media(w < 768px)'`) */
691
+ states?: Record<string, string>;
692
+ /**
693
+ * Custom style handlers that transform style properties into CSS declarations.
694
+ * Handlers replace built-in handlers for the same style name.
695
+ * @example
696
+ * ```ts
697
+ * handlers: {
698
+ * // Simple handler - lookup style inferred from key
699
+ * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
700
+ * // Multi-property handler
701
+ * spacing: [['gap', 'padding'], ({ gap, padding }) => ({ ... })],
702
+ * }
703
+ * ```
704
+ */
705
+ handlers?: Record<string, StyleHandlerDefinition>;
706
+ /**
707
+ * Props middleware for every tasty component — props in, props out. The
708
+ * extension point for props that are not style properties: read a custom prop,
709
+ * strip it so it never reaches the DOM, and fold its meaning into `styles`,
710
+ * `mods`, `tokens`, `variant`, or `as`.
711
+ *
712
+ * Must be pure and must not mutate its input.
713
+ * See {@link TastyConfig.propHandlers}.
714
+ * @example
715
+ * ```ts
716
+ * propHandlers: {
717
+ * glaze: (props) => {
718
+ * const { glaze, ...rest } = props;
719
+ * if (!glaze) return rest;
720
+ * return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
721
+ * },
722
+ * }
723
+ * ```
724
+ */
725
+ propHandlers?: Record<string, PropHandlerDefinition>;
726
+ /**
727
+ * Style properties exposed as top-level props on every tasty component, in
728
+ * addition to the built-in base styles.
729
+ * See {@link TastyConfig.baseStyleProps}.
730
+ */
731
+ baseStyleProps?: readonly string[];
732
+ /**
733
+ * Design tokens injected as CSS custom properties on `:root`.
734
+ * Values are parsed through the Tasty DSL. Supports state maps.
735
+ * - `$name` → `--name` CSS custom property
736
+ * - `#name` → `--name-color`
737
+ */
738
+ tokens?: ConfigTokens;
739
+ /** Predefined tokens replaced during style parsing (`$name` or `#name`) */
740
+ replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
741
+ /**
742
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
743
+ * Recipe values are flat tasty styles (no sub-element keys).
744
+ * @example
745
+ * ```ts
746
+ * recipes: {
747
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
748
+ * elevated: { shadow: '2x 2x 4x #shadow' },
749
+ * }
750
+ * ```
751
+ */
752
+ recipes?: Record<string, RecipeStyles>;
753
+ /**
754
+ * Typography presets — shorthand for `generateTypographyTokens()`.
755
+ * Generated tokens are merged under explicit `tokens` (tokens win on conflict).
756
+ */
757
+ presets?: Record<string, TypographyPreset>;
758
+ /**
759
+ * Global Tasty styles keyed by CSS selector.
760
+ * Supports the full Tasty style syntax.
761
+ */
762
+ globalStyles?: Record<string, Styles>;
763
+ /**
764
+ * Global CSS `@property` definitions. A plugin whose handler or prop handler
765
+ * emits a custom property usually wants one, so the property animates and
766
+ * inherits correctly instead of being treated as an untyped string.
767
+ * See {@link TastyConfig.properties}.
768
+ */
769
+ properties?: Record<string, PropertyDefinition>;
770
+ /** Global keyframes, injected only when referenced. See {@link TastyConfig.keyframes}. */
771
+ keyframes?: Record<string, KeyframesSteps>;
772
+ /** Global `@font-face` definitions. See {@link TastyConfig.fontFaces}. */
773
+ fontFaces?: Record<string, FontFaceInput>;
774
+ /** Global `@counter-style` definitions. See {@link TastyConfig.counterStyles}. */
775
+ counterStyles?: Record<string, CounterStyleDescriptors>;
776
+ }
777
+ /**
778
+ * A factory function that creates a TastyPlugin.
779
+ * Can optionally accept configuration options.
780
+ *
781
+ * @example
782
+ * ```ts
783
+ * // Plugin without options
784
+ * const okhslPlugin: TastyPluginFactory = () => ({
785
+ * name: 'okhsl',
786
+ * functions: { okhsl: okhslFunction },
787
+ * });
788
+ *
789
+ * // Plugin with options
790
+ * const debugPlugin: TastyPluginFactory<{ verbose: boolean }> = (options) => ({
791
+ * name: 'debug',
792
+ * functions: { debug: createDebugFunc(options.verbose) },
793
+ * });
794
+ * ```
795
+ */
796
+ type TastyPluginFactory<TOptions = void> = TOptions extends void ? () => TastyPlugin : (options: TOptions) => TastyPlugin;
797
+ //#endregion
798
+ //#region src/config.d.ts
799
+ /**
800
+ * Configuration options for the Tasty style system
801
+ */
802
+ interface TastyConfig {
803
+ /** CSP nonce for style elements */
804
+ nonce?: string;
805
+ /** Maximum rules per stylesheet (default: 8192) */
806
+ maxRulesPerSheet?: number;
807
+ /** Force text injection mode, auto-detected in test environments (default: auto) */
808
+ forceTextInjection?: boolean;
809
+ /** Enable development mode features: performance metrics and debug info (default: auto) */
810
+ devMode?: boolean;
811
+ /**
812
+ * Global predefined states for advanced state mapping.
813
+ * These are state aliases that can be used in any component.
814
+ * Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
815
+ */
816
+ states?: Record<string, string>;
817
+ /**
818
+ * Parser LRU cache size (default: 1000).
819
+ * Larger values improve performance for apps with many unique style values.
820
+ */
821
+ parserCacheSize?: number;
822
+ /**
823
+ * Custom units for the style parser (merged with built-in units).
824
+ * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
825
+ * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
826
+ */
827
+ units?: Record<string, string | UnitHandler>;
828
+ /**
829
+ * Custom functions (merged with existing). A single map holds both flavors,
830
+ * discriminated by value type:
831
+ *
832
+ * - **Bare key + function value** — a parse-time function that processes the
833
+ * parsed argument groups and returns a CSS value. Called as `name(...)`.
834
+ * - **`$$name` key + object value** — a declarative CSS `@function`
835
+ * definition. Called as `$$name(...)` (→ native `--name(...)`).
836
+ *
837
+ * A key whose prefix does not match its value type (object under a bare key,
838
+ * or function under a `$$` key) is ignored with a dev warning.
839
+ *
840
+ * @example
841
+ * ```ts
842
+ * configure({
843
+ * functions: {
844
+ * double: (groups) => `calc(2 * ${groups[0].output})`, // parse function
845
+ * $$negative: { args: ['$value'], result: '(-1 * $value)' }, // CSS function
846
+ * },
847
+ * });
848
+ * ```
849
+ */
850
+ functions?: FunctionsConfig;
851
+ /**
852
+ * @deprecated No longer has any effect; will be removed in the next major.
853
+ * Setting it warns in development.
854
+ *
855
+ * A `#name` token's value used to be rewritten into this color space so an
856
+ * opacity suffix had numeric channels to write an alpha into. Opacity now uses
857
+ * relative color syntax — `oklch(from var(--name-color) l c h / .5)` — which
858
+ * has the browser read the channels, so a color is emitted exactly as
859
+ * authored and there is nothing left for the setting to decide.
860
+ *
861
+ * To address a token's channels yourself, write relative color syntax against
862
+ * the token: `oklch(from var(--brand-color) calc(l * 1.2) c h)`. It works on
863
+ * every `<color>`, including the ones no conversion could evaluate.
864
+ */
865
+ colorSpace?: ColorSpace;
866
+ /**
867
+ * Automatically infer and register CSS @property declarations
868
+ * from custom property values found in styles, keyframes, and global config.
869
+ * Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
870
+ * When false, only explicitly declared @property are registered.
871
+ * @default true
872
+ */
873
+ autoPropertyTypes?: boolean;
874
+ /**
875
+ * Defer stylesheet writes and apply them in one batch instead of performing
876
+ * one `insertRule()` per component during render.
877
+ *
878
+ * Each `insertRule()` on a live sheet invalidates style for that sheet's
879
+ * scope. When components inject during React's render phase while other
880
+ * components read layout in the same pass, the two interleave and the browser
881
+ * is forced to recalculate style between every injection. Batching collapses
882
+ * that into one invalidation per flush.
883
+ *
884
+ * - `false` (default) — inject synchronously, one write per component.
885
+ * - `true` — batch, but only inside a *batch window*: a commit in which
886
+ * `<TastyBatchProvider>` rendered and will therefore flush in its
887
+ * `useInsertionEffect`, before any `useLayoutEffect` runs. Any injection
888
+ * outside a window — a deep update the provider did not re-render for, an
889
+ * injection from a layout effect, an event handler, an async callback — is
890
+ * written straight through. Enabling this can never make a layout effect
891
+ * measure an unstyled element. Requires `<TastyBatchProvider>`; without it
892
+ * nothing is batched (and dev mode says so once).
893
+ * - `'always'` — batch every injection, flushing on a microtask when no
894
+ * window is open. Wins on more commits, but a `useLayoutEffect` that
895
+ * measures a freshly mounted element can read its unstyled box, because
896
+ * microtasks run after the layout phase. Paint is unaffected: microtasks
897
+ * always drain before the browser paints.
898
+ *
899
+ * No effect during SSR or RSC: styles are collected as text there, the
900
+ * runtime injector never runs, and the provider is inert without a
901
+ * `document`. No effect on zero-runtime `tastyStatic` styles either — those
902
+ * are extracted at build time and never reach the injector.
903
+ *
904
+ * @default false
905
+ * @example
906
+ * ```tsx
907
+ * configure({ batchInjection: true });
908
+ *
909
+ * <TastyBatchProvider>
910
+ * <App />
911
+ * </TastyBatchProvider>
912
+ * ```
913
+ */
914
+ batchInjection?: boolean | 'always';
915
+ /**
916
+ * Garbage collection configuration for unused styles.
917
+ * GC is triggered by touch count: every `touchInterval` touches, the
918
+ * oldest unused styles are evicted when their count exceeds `capacity`.
919
+ * @example
920
+ * ```ts
921
+ * configure({
922
+ * gc: { touchInterval: 1000, capacity: 1000 },
923
+ * });
924
+ * ```
925
+ */
926
+ gc?: GCConfig;
927
+ /**
928
+ * Prefix prepended to every generated identifier (class names,
929
+ * keyframe names, counter-style names). The hash is appended verbatim,
930
+ * so include any separator inside the prefix itself (e.g. `'myapp-'`).
931
+ *
932
+ * Discriminator letters are inserted between the prefix and the hash
933
+ * for non-class names so the three kinds stay visually distinct:
934
+ * - class: `${namePrefix}${hash}` — e.g. `t1a2b3`
935
+ * - keyframe: `${namePrefix}k${hash}` — e.g. `tk1a2b3`
936
+ * - counter-style: `${namePrefix}c${hash}` — e.g. `tc1a2b3`
937
+ *
938
+ * The runtime, SSR, and RSC paths must agree on this value or
939
+ * hydration will mismatch. The zero-runtime build path defaults to
940
+ * `'ts'` (overridable via the same option) so its classes can't
941
+ * collide with runtime classes when both are loaded on the same page.
942
+ *
943
+ * Must match `^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$`. Locked once styles
944
+ * have been generated.
945
+ *
946
+ * @default 't'
947
+ */
948
+ namePrefix?: string;
949
+ /**
950
+ * Plugins that extend tasty with custom functions, units, or states.
951
+ * Plugins are processed in order, with later plugins overriding earlier ones.
952
+ * @example
953
+ * ```ts
954
+ * import { okhslPlugin } from '@tenphi/tasty';
955
+ *
956
+ * configure({
957
+ * plugins: [okhslPlugin()],
958
+ * });
959
+ * ```
960
+ */
961
+ plugins?: TastyPlugin[];
962
+ /**
963
+ * Global keyframes definitions that can be referenced by animation names in styles.
964
+ * Keys are animation names, values are keyframes step definitions.
965
+ * Keyframes are only injected when actually used in styles.
966
+ * @example
967
+ * ```ts
968
+ * configure({
969
+ * keyframes: {
970
+ * fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
971
+ * pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
972
+ * },
973
+ * });
974
+ * ```
975
+ */
976
+ keyframes?: Record<string, KeyframesSteps>;
977
+ /**
978
+ * Global CSS @property definitions for custom properties.
979
+ * Keys use tasty token syntax ($name for properties, #name for colors).
980
+ *
981
+ * Tasty ships with `DEFAULT_PROPERTIES` (e.g. `$gap`, `$radius`, `#white`,
982
+ * `#black`, `#clear`, `#border`, etc.) that are always included.
983
+ * Properties you specify here are merged on top, so you can override any
984
+ * default by using the same key.
985
+ *
986
+ * For color tokens (#name), `syntax: '<color>'` is auto-set and
987
+ * `initialValue` defaults to `'transparent'` if not specified.
988
+ *
989
+ * @example
990
+ * ```ts
991
+ * configure({
992
+ * properties: {
993
+ * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
994
+ * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
995
+ * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
996
+ * // Override a default property:
997
+ * '$gap': { syntax: '<length>', inherits: true, initialValue: '8px' },
998
+ * },
999
+ * });
1000
+ *
1001
+ * // Now use in styles - properties are registered when component renders:
1002
+ * const Spinner = tasty({
1003
+ * styles: {
1004
+ * transform: 'rotate($rotation)',
1005
+ * transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
1006
+ * },
1007
+ * });
1008
+ * ```
1009
+ */
1010
+ properties?: Record<string, PropertyDefinition>;
1011
+ /**
1012
+ * Global @font-face definitions.
1013
+ * Keys are font-family names, values are descriptors or arrays of descriptors
1014
+ * (for multiple weights/styles of the same family).
1015
+ * Injected eagerly when styles are first generated.
1016
+ * @example
1017
+ * ```ts
1018
+ * configure({
1019
+ * fontFaces: {
1020
+ * 'Brand Sans': [
1021
+ * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
1022
+ * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
1023
+ * ],
1024
+ * Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' },
1025
+ * },
1026
+ * });
1027
+ * ```
1028
+ */
1029
+ fontFaces?: Record<string, FontFaceInput>;
1030
+ /**
1031
+ * Global @counter-style definitions.
1032
+ * Keys are counter-style names, values are descriptor objects.
1033
+ * Injected eagerly when styles are first generated.
1034
+ * @example
1035
+ * ```ts
1036
+ * configure({
1037
+ * counterStyles: {
1038
+ * thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' },
1039
+ * },
1040
+ * });
1041
+ * ```
1042
+ */
1043
+ counterStyles?: Record<string, CounterStyleDescriptors>;
1044
+ /**
1045
+ * Opt-in polyfills for not-yet-baseline CSS features. Each key toggles a
1046
+ * feature polyfill; all default to `false`.
1047
+ *
1048
+ * - `functions` — polyfill CSS `@function` by inlining every `$$name(...)`
1049
+ * call into plain CSS (calc/var/color-mix) at parse time instead of
1050
+ * emitting the native `@function` at-rule. Enables `@function` usage in
1051
+ * browsers that don't support it yet (Firefox/Safari). Note this is the
1052
+ * `functions` *feature toggle*, distinct from the top-level `functions`
1053
+ * definitions map.
1054
+ *
1055
+ * @example
1056
+ * ```ts
1057
+ * configure({ polyfills: { functions: true } });
1058
+ * ```
1059
+ */
1060
+ polyfills?: {
1061
+ functions?: boolean;
1062
+ };
1063
+ /**
1064
+ * Custom style handlers that transform style properties into CSS declarations.
1065
+ * Handlers replace built-in handlers for the same style name.
1066
+ * @example
1067
+ * ```ts
1068
+ * import { styleHandlers } from '@tenphi/tasty';
1069
+ *
1070
+ * configure({
1071
+ * handlers: {
1072
+ * // Override fill with custom behavior
1073
+ * fill: ({ fill }) => {
1074
+ * if (fill?.startsWith('gradient:')) {
1075
+ * return { background: fill.slice(9) };
1076
+ * }
1077
+ * return styleHandlers.fill({ fill });
1078
+ * },
1079
+ * // Add new custom style
1080
+ * elevation: ({ elevation }) => {
1081
+ * const level = parseInt(elevation) || 1;
1082
+ * return {
1083
+ * 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
1084
+ * 'z-index': String(level * 100),
1085
+ * };
1086
+ * },
1087
+ * },
1088
+ * });
1089
+ * ```
1090
+ */
1091
+ handlers?: Record<string, StyleHandlerDefinition>;
1092
+ /**
1093
+ * Props middleware for every tasty component. A prop handler receives the
1094
+ * component's props and returns them, changed or not — the extension point for
1095
+ * props that are not style properties.
1096
+ *
1097
+ * The map key is the handler's name and, by default, the prop that triggers it.
1098
+ * Use `['*', fn]` for an unconditional handler, or `[['a', 'b'], fn]` to trigger
1099
+ * on any of several props.
1100
+ *
1101
+ * Handlers must be pure and must not mutate their input: style values are cached
1102
+ * by object identity, so mutating one in place yields stale CSS. Memoize the
1103
+ * styles you build per input value.
1104
+ *
1105
+ * Not applicable to zero-runtime mode — `tastyStatic()` takes styles objects, not
1106
+ * props, so there is nothing for middleware to run on. Components rendered
1107
+ * through `tasty()` are unaffected and keep the runtime injector.
1108
+ *
1109
+ * @example
1110
+ * ```ts
1111
+ * configure({
1112
+ * propHandlers: {
1113
+ * glaze: (props) => {
1114
+ * const { glaze, ...rest } = props;
1115
+ * if (!glaze) return rest;
1116
+ * return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
1117
+ * },
1118
+ * },
1119
+ * });
1120
+ *
1121
+ * <Element glaze="purple" />
1122
+ * ```
1123
+ */
1124
+ propHandlers?: Record<string, PropHandlerDefinition>;
1125
+ /**
1126
+ * Style properties exposed as top-level props on **every** tasty component, in
1127
+ * addition to the built-in base styles, without each component listing them in
1128
+ * `styleProps`.
1129
+ *
1130
+ * Augment `TastyBaseStylePropNames` to type them. Each name costs one property
1131
+ * check per render of every component, so keep the list short; the effect is
1132
+ * app-global and cannot be scoped to a subtree.
1133
+ *
1134
+ * @example
1135
+ * ```ts
1136
+ * configure({ baseStyleProps: ['radius', 'shadow'] });
1137
+ *
1138
+ * <Card radius="1r" shadow />
1139
+ * ```
1140
+ */
1141
+ baseStyleProps?: readonly string[];
1142
+ /**
1143
+ * Design tokens injected as CSS custom properties on `:root`.
1144
+ * Values are parsed through the Tasty DSL. Supports state maps
1145
+ * for responsive/theme-aware tokens.
1146
+ *
1147
+ * - `$name` keys become `--name` CSS custom properties
1148
+ * - `#name` keys become `--name-color` properties
1149
+ *
1150
+ * Tokens are injected once when the first style is rendered.
1151
+ *
1152
+ * @example
1153
+ * ```ts
1154
+ * configure({
1155
+ * tokens: {
1156
+ * '$gap': '4px',
1157
+ * '#primary': {
1158
+ * '': '#purple',
1159
+ * '@dark': '#light-purple',
1160
+ * },
1161
+ * },
1162
+ * });
1163
+ * ```
1164
+ */
1165
+ tokens?: ConfigTokens;
1166
+ /**
1167
+ * Predefined tokens that are replaced during style parsing (parse-time substitution).
1168
+ * Use `$name` for custom properties and `#name` for color tokens.
1169
+ * Values are substituted inline before CSS generation, unlike `tokens` which
1170
+ * inject CSS custom properties on `:root`.
1171
+ *
1172
+ * For color tokens (#name), boolean `true` is converted to `transparent`.
1173
+ *
1174
+ * @example
1175
+ * ```ts
1176
+ * configure({
1177
+ * replaceTokens: {
1178
+ * $spacing: '2x',
1179
+ * '#accent': '#purple',
1180
+ * '#overlay': true, // → transparent
1181
+ * },
1182
+ * });
1183
+ *
1184
+ * // Now use in styles - tokens are replaced at parse time:
1185
+ * const Card = tasty({
1186
+ * styles: {
1187
+ * padding: '$spacing', // → calc(2 * var(--gap))
1188
+ * fill: '#accent', // → var(--purple-color)
1189
+ * },
1190
+ * });
1191
+ * ```
1192
+ */
1193
+ replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
1194
+ /**
1195
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
1196
+ * Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
1197
+ * tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@property`.
1198
+ *
1199
+ * Components reference recipes via: `recipe: 'name1 name2'` in their styles.
1200
+ * Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
1201
+ * Use `none` to skip base recipes: `recipe: 'none / post1'`.
1202
+ * Resolution order: `base_recipes → component styles → post_recipes`.
1203
+ *
1204
+ * Recipes cannot reference other recipes.
1205
+ *
1206
+ * @example
1207
+ * ```ts
1208
+ * configure({
1209
+ * recipes: {
1210
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
1211
+ * elevated: { shadow: '2x 2x 4x #shadow' },
1212
+ * },
1213
+ * });
1214
+ *
1215
+ * // Usage in styles:
1216
+ * const Card = tasty({
1217
+ * styles: {
1218
+ * recipe: 'card elevated',
1219
+ * color: '#text', // Overrides recipe values
1220
+ * },
1221
+ * });
1222
+ * ```
1223
+ */
1224
+ recipes?: Record<string, RecipeStyles>;
1225
+ /**
1226
+ * Typography presets — shorthand for `generateTypographyTokens()`.
1227
+ * Accepts the same input and internally generates typography tokens
1228
+ * that are merged into `tokens`. Explicit `tokens` override preset-generated ones.
1229
+ *
1230
+ * @example
1231
+ * ```ts
1232
+ * configure({
1233
+ * presets: {
1234
+ * h1: { fontSize: '32px', lineHeight: '1.2', fontWeight: '700' },
1235
+ * t2: { fontSize: '16px', lineHeight: '1.5', fontWeight: '400' },
1236
+ * },
1237
+ * tokens: {
1238
+ * // Overrides the preset-generated $t2-font-weight
1239
+ * '$t2-font-weight': { '': '400', '@dark': '300' },
1240
+ * },
1241
+ * });
1242
+ * ```
1243
+ */
1244
+ presets?: Record<string, TypographyPreset>;
1245
+ /**
1246
+ * Global Tasty styles keyed by CSS selector.
1247
+ * Each entry applies the full Tasty style syntax (style properties,
1248
+ * tokens, state maps, selector-based sub-styling) to the given selector.
1249
+ * Injected alongside `:root` tokens when the first style is rendered.
1250
+ *
1251
+ * @example
1252
+ * ```ts
1253
+ * configure({
1254
+ * globalStyles: {
1255
+ * body: { fill: '#surface', color: '#text', preset: 't2', margin: 0 },
1256
+ * html: { overflow: 'hidden' },
1257
+ * },
1258
+ * });
1259
+ * ```
1260
+ */
1261
+ globalStyles?: Record<string, Styles>;
1262
+ }
1263
+ declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
1264
+ declare global {
1265
+ interface Window {
1266
+ [GLOBAL_INJECTOR_KEY]?: StyleInjector;
1267
+ }
1268
+ var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
1269
+ }
1270
+ /**
1271
+ * Detect if we're running in a test environment
1272
+ */
1273
+ declare function isTestEnvironment(): boolean;
1274
+ /**
1275
+ * Check if styles have been generated (configuration is locked)
1276
+ */
1277
+ declare function hasStylesGenerated(): boolean;
1278
+ /**
1279
+ * Check if any global keyframes are configured.
1280
+ * Uses a pre-computed flag to avoid Object.keys() allocation on every call.
1281
+ */
1282
+ declare function hasGlobalKeyframes(): boolean;
1283
+ /**
1284
+ * Get global keyframes configuration.
1285
+ * Returns null if no keyframes configured (fast path for zero-overhead).
1286
+ */
1287
+ declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
1288
+ /**
1289
+ * Get global font-face configuration.
1290
+ * Returns null if no font faces configured.
1291
+ * Reads from globalThis first for cross-module SSR support.
1292
+ */
1293
+ declare function getGlobalFontFaces(): Record<string, FontFaceInput> | null;
1294
+ /**
1295
+ * Get global counter-style configuration.
1296
+ * Returns null if no counter styles configured.
1297
+ * Reads from globalThis first for cross-module SSR support.
1298
+ */
1299
+ declare function getGlobalCounterStyles(): Record<string, CounterStyleDescriptors> | null;
1300
+ /**
1301
+ * Get global @function configuration.
1302
+ * Returns null if no functions configured.
1303
+ * Reads from globalThis first for cross-module SSR support.
1304
+ */
1305
+ declare function getGlobalFunctions(): Record<string, FunctionDefinition> | null;
1306
+ /**
1307
+ * Check if any global recipes are configured.
1308
+ * Fast path: returns false if no recipes were ever set.
1309
+ */
1310
+ declare function hasGlobalRecipes(): boolean;
1311
+ /**
1312
+ * Get global recipes configuration.
1313
+ * Returns null if no recipes configured (fast path for zero-overhead).
1314
+ */
1315
+ declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
1316
+ /**
1317
+ * Check if configuration is locked (styles have been generated)
1318
+ */
1319
+ declare function isConfigLocked(): boolean;
1320
+ /**
1321
+ * Configure the Tasty style system.
1322
+ *
1323
+ * Must be called BEFORE any styles are generated (before first render that uses tasty).
1324
+ * After styles are generated, configuration is locked and calls to configure() will
1325
+ * emit a warning and be ignored.
1326
+ *
1327
+ * @example
1328
+ * ```ts
1329
+ * import { configure } from '@tenphi/tasty';
1330
+ *
1331
+ * // Configure before app renders
1332
+ * configure({
1333
+ * nonce: 'abc123',
1334
+ * states: {
1335
+ * '@mobile': '@media(w < 768px)',
1336
+ * '@dark': '@root(theme=dark)',
1337
+ * },
1338
+ * });
1339
+ * ```
1340
+ */
1341
+ declare function configure(config?: Partial<TastyConfig>): void;
1342
+ /**
1343
+ * Get the current configuration.
1344
+ * If not configured, returns default configuration.
1345
+ */
1346
+ declare function getConfig(): TastyConfig;
1347
+ /**
1348
+ * Get the configured prefix used for every generated identifier
1349
+ * (class names, keyframe names, counter-style names).
1350
+ *
1351
+ * Falls back to the default prefix (`'t'`) when `configure()` has not
1352
+ * been called yet — this matches the auto-configuration behavior used
1353
+ * by the rest of the system.
1354
+ */
1355
+ declare function getNamePrefix(): string;
1356
+ /**
1357
+ * Reset configuration (for testing only).
1358
+ * Clears the global injector and allows reconfiguration.
1359
+ */
1360
+ declare function resetConfig(): void;
1361
+ //#endregion
1362
+ export { ParseFunction as C, PropHandlerDefinition as D, PropHandler as E, PropHandlerProps as O, FunctionsConfig as S, SheetManager as T, TastyPluginFactory as _, getGlobalFontFaces as a, generateTypographyTokens as b, getGlobalRecipes as c, hasGlobalRecipes as d, hasStylesGenerated as f, TastyPlugin as g, resetConfig as h, getGlobalCounterStyles as i, getNamePrefix as l, isTestEnvironment as m, configure as n, getGlobalFunctions as o, isConfigLocked as p, getConfig as r, getGlobalKeyframes as s, TastyConfig as t, hasGlobalKeyframes as u, TypographyPreset as v, StyleInjector as w, ColorSpace as x, TypographyTokenValue as y };
1363
+ //# sourceMappingURL=config-LfIDmVHx.d.ts.map