@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fc19da9

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