@tenphi/tasty 0.0.0-snapshot.05c1c22

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 (314) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +629 -0
  3. package/dist/_virtual/_rolldown/runtime.js +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +77 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +258 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +1 -0
  11. package/dist/chunks/renderChunk.d.ts +1 -0
  12. package/dist/chunks/renderChunk.js +59 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +366 -0
  15. package/dist/config.js +503 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/core/index.d.ts +33 -0
  18. package/dist/core/index.js +26 -0
  19. package/dist/counter-style/index.js +51 -0
  20. package/dist/counter-style/index.js.map +1 -0
  21. package/dist/debug.d.ts +89 -0
  22. package/dist/debug.js +453 -0
  23. package/dist/debug.js.map +1 -0
  24. package/dist/font-face/index.js +63 -0
  25. package/dist/font-face/index.js.map +1 -0
  26. package/dist/hooks/index.d.ts +7 -0
  27. package/dist/hooks/resolve-ssr-collector.js +14 -0
  28. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  29. package/dist/hooks/useCounterStyle.d.ts +50 -0
  30. package/dist/hooks/useCounterStyle.js +46 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +43 -0
  33. package/dist/hooks/useFontFace.js +70 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +30 -0
  36. package/dist/hooks/useGlobalStyles.js +78 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +64 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +109 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +35 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +45 -0
  48. package/dist/hooks/useStyles.js +237 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +50 -0
  51. package/dist/index.js +35 -0
  52. package/dist/injector/index.d.ts +183 -0
  53. package/dist/injector/index.js +179 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +166 -0
  56. package/dist/injector/injector.js +464 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/sheet-manager.d.ts +136 -0
  59. package/dist/injector/sheet-manager.js +733 -0
  60. package/dist/injector/sheet-manager.js.map +1 -0
  61. package/dist/injector/types.d.ts +204 -0
  62. package/dist/keyframes/index.js +206 -0
  63. package/dist/keyframes/index.js.map +1 -0
  64. package/dist/parser/classify.js +319 -0
  65. package/dist/parser/classify.js.map +1 -0
  66. package/dist/parser/const.js +49 -0
  67. package/dist/parser/const.js.map +1 -0
  68. package/dist/parser/lru.js +109 -0
  69. package/dist/parser/lru.js.map +1 -0
  70. package/dist/parser/parser.d.ts +25 -0
  71. package/dist/parser/parser.js +115 -0
  72. package/dist/parser/parser.js.map +1 -0
  73. package/dist/parser/tokenizer.js +69 -0
  74. package/dist/parser/tokenizer.js.map +1 -0
  75. package/dist/parser/types.d.ts +51 -0
  76. package/dist/parser/types.js +46 -0
  77. package/dist/parser/types.js.map +1 -0
  78. package/dist/pipeline/conditions.d.ts +134 -0
  79. package/dist/pipeline/conditions.js +406 -0
  80. package/dist/pipeline/conditions.js.map +1 -0
  81. package/dist/pipeline/exclusive.js +230 -0
  82. package/dist/pipeline/exclusive.js.map +1 -0
  83. package/dist/pipeline/index.d.ts +55 -0
  84. package/dist/pipeline/index.js +708 -0
  85. package/dist/pipeline/index.js.map +1 -0
  86. package/dist/pipeline/materialize.js +1103 -0
  87. package/dist/pipeline/materialize.js.map +1 -0
  88. package/dist/pipeline/parseStateKey.d.ts +15 -0
  89. package/dist/pipeline/parseStateKey.js +446 -0
  90. package/dist/pipeline/parseStateKey.js.map +1 -0
  91. package/dist/pipeline/simplify.js +515 -0
  92. package/dist/pipeline/simplify.js.map +1 -0
  93. package/dist/pipeline/warnings.js +18 -0
  94. package/dist/pipeline/warnings.js.map +1 -0
  95. package/dist/plugins/index.d.ts +2 -0
  96. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  97. package/dist/plugins/okhsl-plugin.js +97 -0
  98. package/dist/plugins/okhsl-plugin.js.map +1 -0
  99. package/dist/plugins/types.d.ts +76 -0
  100. package/dist/properties/index.js +222 -0
  101. package/dist/properties/index.js.map +1 -0
  102. package/dist/properties/property-type-resolver.d.ts +24 -0
  103. package/dist/properties/property-type-resolver.js +90 -0
  104. package/dist/properties/property-type-resolver.js.map +1 -0
  105. package/dist/ssr/astro.d.ts +29 -0
  106. package/dist/ssr/astro.js +64 -0
  107. package/dist/ssr/astro.js.map +1 -0
  108. package/dist/ssr/async-storage.d.ts +17 -0
  109. package/dist/ssr/async-storage.js +34 -0
  110. package/dist/ssr/async-storage.js.map +1 -0
  111. package/dist/ssr/collect-auto-properties.js +39 -0
  112. package/dist/ssr/collect-auto-properties.js.map +1 -0
  113. package/dist/ssr/collector.d.ts +102 -0
  114. package/dist/ssr/collector.js +226 -0
  115. package/dist/ssr/collector.js.map +1 -0
  116. package/dist/ssr/context.d.ts +8 -0
  117. package/dist/ssr/context.js +13 -0
  118. package/dist/ssr/context.js.map +1 -0
  119. package/dist/ssr/format-global-rules.js +22 -0
  120. package/dist/ssr/format-global-rules.js.map +1 -0
  121. package/dist/ssr/format-keyframes.js +69 -0
  122. package/dist/ssr/format-keyframes.js.map +1 -0
  123. package/dist/ssr/format-property.js +49 -0
  124. package/dist/ssr/format-property.js.map +1 -0
  125. package/dist/ssr/format-rules.js +73 -0
  126. package/dist/ssr/format-rules.js.map +1 -0
  127. package/dist/ssr/hydrate.d.ts +22 -0
  128. package/dist/ssr/hydrate.js +49 -0
  129. package/dist/ssr/hydrate.js.map +1 -0
  130. package/dist/ssr/index.d.ts +5 -0
  131. package/dist/ssr/index.js +11 -0
  132. package/dist/ssr/index.js.map +1 -0
  133. package/dist/ssr/next.d.ts +45 -0
  134. package/dist/ssr/next.js +69 -0
  135. package/dist/ssr/next.js.map +1 -0
  136. package/dist/ssr/ssr-collector-ref.js +12 -0
  137. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  138. package/dist/states/index.d.ts +49 -0
  139. package/dist/states/index.js +170 -0
  140. package/dist/states/index.js.map +1 -0
  141. package/dist/static/index.d.ts +5 -0
  142. package/dist/static/index.js +4 -0
  143. package/dist/static/inject.d.ts +5 -0
  144. package/dist/static/inject.js +17 -0
  145. package/dist/static/inject.js.map +1 -0
  146. package/dist/static/tastyStatic.d.ts +46 -0
  147. package/dist/static/tastyStatic.js +30 -0
  148. package/dist/static/tastyStatic.js.map +1 -0
  149. package/dist/static/types.d.ts +49 -0
  150. package/dist/static/types.js +24 -0
  151. package/dist/static/types.js.map +1 -0
  152. package/dist/styles/align.d.ts +15 -0
  153. package/dist/styles/align.js +14 -0
  154. package/dist/styles/align.js.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +113 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/color.d.ts +14 -0
  159. package/dist/styles/color.js +26 -0
  160. package/dist/styles/color.js.map +1 -0
  161. package/dist/styles/createStyle.js +79 -0
  162. package/dist/styles/createStyle.js.map +1 -0
  163. package/dist/styles/dimension.js +96 -0
  164. package/dist/styles/dimension.js.map +1 -0
  165. package/dist/styles/display.d.ts +37 -0
  166. package/dist/styles/display.js +66 -0
  167. package/dist/styles/display.js.map +1 -0
  168. package/dist/styles/fade.d.ts +15 -0
  169. package/dist/styles/fade.js +57 -0
  170. package/dist/styles/fade.js.map +1 -0
  171. package/dist/styles/fill.d.ts +42 -0
  172. package/dist/styles/fill.js +51 -0
  173. package/dist/styles/fill.js.map +1 -0
  174. package/dist/styles/flow.d.ts +16 -0
  175. package/dist/styles/flow.js +12 -0
  176. package/dist/styles/flow.js.map +1 -0
  177. package/dist/styles/gap.d.ts +31 -0
  178. package/dist/styles/gap.js +36 -0
  179. package/dist/styles/gap.js.map +1 -0
  180. package/dist/styles/height.d.ts +17 -0
  181. package/dist/styles/height.js +19 -0
  182. package/dist/styles/height.js.map +1 -0
  183. package/dist/styles/index.d.ts +1 -0
  184. package/dist/styles/index.js +8 -0
  185. package/dist/styles/index.js.map +1 -0
  186. package/dist/styles/inset.d.ts +52 -0
  187. package/dist/styles/inset.js +149 -0
  188. package/dist/styles/inset.js.map +1 -0
  189. package/dist/styles/justify.d.ts +15 -0
  190. package/dist/styles/justify.js +14 -0
  191. package/dist/styles/justify.js.map +1 -0
  192. package/dist/styles/list.d.ts +16 -0
  193. package/dist/styles/list.js +98 -0
  194. package/dist/styles/list.js.map +1 -0
  195. package/dist/styles/margin.d.ts +24 -0
  196. package/dist/styles/margin.js +103 -0
  197. package/dist/styles/margin.js.map +1 -0
  198. package/dist/styles/outline.d.ts +29 -0
  199. package/dist/styles/outline.js +64 -0
  200. package/dist/styles/outline.js.map +1 -0
  201. package/dist/styles/padding.d.ts +24 -0
  202. package/dist/styles/padding.js +103 -0
  203. package/dist/styles/padding.js.map +1 -0
  204. package/dist/styles/predefined.d.ts +71 -0
  205. package/dist/styles/predefined.js +237 -0
  206. package/dist/styles/predefined.js.map +1 -0
  207. package/dist/styles/preset.d.ts +52 -0
  208. package/dist/styles/preset.js +126 -0
  209. package/dist/styles/preset.js.map +1 -0
  210. package/dist/styles/radius.d.ts +12 -0
  211. package/dist/styles/radius.js +71 -0
  212. package/dist/styles/radius.js.map +1 -0
  213. package/dist/styles/scrollbar.d.ts +25 -0
  214. package/dist/styles/scrollbar.js +46 -0
  215. package/dist/styles/scrollbar.js.map +1 -0
  216. package/dist/styles/shadow.d.ts +14 -0
  217. package/dist/styles/shadow.js +23 -0
  218. package/dist/styles/shadow.js.map +1 -0
  219. package/dist/styles/transition.d.ts +14 -0
  220. package/dist/styles/transition.js +157 -0
  221. package/dist/styles/transition.js.map +1 -0
  222. package/dist/styles/types.d.ts +549 -0
  223. package/dist/styles/width.d.ts +17 -0
  224. package/dist/styles/width.js +19 -0
  225. package/dist/styles/width.js.map +1 -0
  226. package/dist/tasty.d.ts +119 -0
  227. package/dist/tasty.js +231 -0
  228. package/dist/tasty.js.map +1 -0
  229. package/dist/types.d.ts +184 -0
  230. package/dist/utils/cache-wrapper.js +21 -0
  231. package/dist/utils/cache-wrapper.js.map +1 -0
  232. package/dist/utils/case-converter.js +8 -0
  233. package/dist/utils/case-converter.js.map +1 -0
  234. package/dist/utils/color-math.d.ts +46 -0
  235. package/dist/utils/color-math.js +749 -0
  236. package/dist/utils/color-math.js.map +1 -0
  237. package/dist/utils/color-space.d.ts +5 -0
  238. package/dist/utils/color-space.js +228 -0
  239. package/dist/utils/color-space.js.map +1 -0
  240. package/dist/utils/colors.d.ts +5 -0
  241. package/dist/utils/colors.js +10 -0
  242. package/dist/utils/colors.js.map +1 -0
  243. package/dist/utils/css-types.d.ts +7 -0
  244. package/dist/utils/dotize.d.ts +26 -0
  245. package/dist/utils/dotize.js +122 -0
  246. package/dist/utils/dotize.js.map +1 -0
  247. package/dist/utils/filter-base-props.d.ts +15 -0
  248. package/dist/utils/filter-base-props.js +45 -0
  249. package/dist/utils/filter-base-props.js.map +1 -0
  250. package/dist/utils/get-display-name.d.ts +7 -0
  251. package/dist/utils/get-display-name.js +10 -0
  252. package/dist/utils/get-display-name.js.map +1 -0
  253. package/dist/utils/has-keys.js +13 -0
  254. package/dist/utils/has-keys.js.map +1 -0
  255. package/dist/utils/is-dev-env.js +19 -0
  256. package/dist/utils/is-dev-env.js.map +1 -0
  257. package/dist/utils/is-valid-element-type.js +15 -0
  258. package/dist/utils/is-valid-element-type.js.map +1 -0
  259. package/dist/utils/merge-styles.d.ts +7 -0
  260. package/dist/utils/merge-styles.js +145 -0
  261. package/dist/utils/merge-styles.js.map +1 -0
  262. package/dist/utils/mod-attrs.d.ts +6 -0
  263. package/dist/utils/mod-attrs.js +20 -0
  264. package/dist/utils/mod-attrs.js.map +1 -0
  265. package/dist/utils/process-tokens.d.ts +21 -0
  266. package/dist/utils/process-tokens.js +90 -0
  267. package/dist/utils/process-tokens.js.map +1 -0
  268. package/dist/utils/resolve-recipes.d.ts +17 -0
  269. package/dist/utils/resolve-recipes.js +146 -0
  270. package/dist/utils/resolve-recipes.js.map +1 -0
  271. package/dist/utils/selector-transform.js +32 -0
  272. package/dist/utils/selector-transform.js.map +1 -0
  273. package/dist/utils/string.js +8 -0
  274. package/dist/utils/string.js.map +1 -0
  275. package/dist/utils/styles.d.ts +99 -0
  276. package/dist/utils/styles.js +220 -0
  277. package/dist/utils/styles.js.map +1 -0
  278. package/dist/utils/typography.d.ts +47 -0
  279. package/dist/utils/typography.js +51 -0
  280. package/dist/utils/typography.js.map +1 -0
  281. package/dist/utils/warnings.d.ts +16 -0
  282. package/dist/utils/warnings.js +16 -0
  283. package/dist/utils/warnings.js.map +1 -0
  284. package/dist/zero/babel.d.ts +182 -0
  285. package/dist/zero/babel.js +438 -0
  286. package/dist/zero/babel.js.map +1 -0
  287. package/dist/zero/css-writer.d.ts +45 -0
  288. package/dist/zero/css-writer.js +73 -0
  289. package/dist/zero/css-writer.js.map +1 -0
  290. package/dist/zero/extractor.d.ts +24 -0
  291. package/dist/zero/extractor.js +266 -0
  292. package/dist/zero/extractor.js.map +1 -0
  293. package/dist/zero/index.d.ts +3 -0
  294. package/dist/zero/index.js +3 -0
  295. package/dist/zero/next.d.ts +86 -0
  296. package/dist/zero/next.js +143 -0
  297. package/dist/zero/next.js.map +1 -0
  298. package/docs/PIPELINE.md +519 -0
  299. package/docs/README.md +31 -0
  300. package/docs/adoption.md +296 -0
  301. package/docs/comparison.md +420 -0
  302. package/docs/configuration.md +326 -0
  303. package/docs/debug.md +318 -0
  304. package/docs/design-system.md +424 -0
  305. package/docs/dsl.md +673 -0
  306. package/docs/getting-started.md +217 -0
  307. package/docs/injector.md +528 -0
  308. package/docs/methodology.md +567 -0
  309. package/docs/runtime.md +485 -0
  310. package/docs/ssr.md +384 -0
  311. package/docs/styles.md +582 -0
  312. package/docs/tasty-static.md +520 -0
  313. package/package.json +215 -0
  314. package/tasty.config.ts +14 -0
@@ -0,0 +1,366 @@
1
+ import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps, PropertyDefinition } from "./injector/types.js";
2
+ import { StyleDetails, UnitHandler } from "./parser/types.js";
3
+ import { StyleHandlerDefinition } from "./utils/styles.js";
4
+ import { ConfigTokens, RecipeStyles } from "./styles/types.js";
5
+ import { StyleInjector } from "./injector/injector.js";
6
+ import { ColorSpace } from "./utils/color-space.js";
7
+ import { TastyPlugin } from "./plugins/types.js";
8
+
9
+ //#region src/config.d.ts
10
+ /**
11
+ * Configuration options for the Tasty style system
12
+ */
13
+ interface TastyConfig {
14
+ /** CSP nonce for style elements */
15
+ nonce?: string;
16
+ /** Maximum rules per stylesheet (default: 8192) */
17
+ maxRulesPerSheet?: number;
18
+ /** Threshold for bulk cleanup of unused styles (default: 500) */
19
+ unusedStylesThreshold?: number;
20
+ /** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
21
+ bulkCleanupDelay?: number;
22
+ /** Use requestIdleCallback for cleanup when available (default: true) */
23
+ idleCleanup?: boolean;
24
+ /** Force text injection mode, auto-detected in test environments (default: auto) */
25
+ forceTextInjection?: boolean;
26
+ /** Enable development mode features: performance metrics and debug info (default: auto) */
27
+ devMode?: boolean;
28
+ /**
29
+ * Ratio of unused styles to delete per bulk cleanup run (0..1).
30
+ * Defaults to 0.5 (oldest half) to reduce risk of removing styles
31
+ * that may be restored shortly after being marked unused.
32
+ */
33
+ bulkCleanupBatchRatio?: number;
34
+ /**
35
+ * Minimum age (in ms) a style must remain unused before eligible for deletion.
36
+ * Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
37
+ */
38
+ unusedStylesMinAgeMs?: number;
39
+ /**
40
+ * Global predefined states for advanced state mapping.
41
+ * These are state aliases that can be used in any component.
42
+ * Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
43
+ */
44
+ states?: Record<string, string>;
45
+ /**
46
+ * Parser LRU cache size (default: 1000).
47
+ * Larger values improve performance for apps with many unique style values.
48
+ */
49
+ parserCacheSize?: number;
50
+ /**
51
+ * Custom units for the style parser (merged with built-in units).
52
+ * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
53
+ * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
54
+ */
55
+ units?: Record<string, string | UnitHandler>;
56
+ /**
57
+ * Custom functions for the style parser (merged with existing).
58
+ * Functions process parsed style groups and return CSS values.
59
+ * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
60
+ */
61
+ funcs?: Record<string, (groups: StyleDetails[]) => string>;
62
+ /**
63
+ * Color space used for decomposed color token companion variables.
64
+ * Controls the CSS function and suffix for alpha composition.
65
+ *
66
+ * - `'rgb'` — suffix `-rgb`, e.g. `rgb(var(--name-color-rgb) / .5)`
67
+ * - `'hsl'` — suffix `-hsl`, e.g. `hsl(var(--name-color-hsl) / .5)`
68
+ * - `'oklch'` — suffix `-oklch`, e.g. `oklch(var(--name-color-oklch) / .5)`
69
+ *
70
+ * @default 'oklch'
71
+ */
72
+ colorSpace?: ColorSpace;
73
+ /**
74
+ * Automatically infer and register CSS @property declarations
75
+ * from custom property values found in styles, keyframes, and global config.
76
+ * Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
77
+ * When false, only explicitly declared @properties are registered.
78
+ * @default true
79
+ */
80
+ autoPropertyTypes?: boolean;
81
+ /**
82
+ * Plugins that extend tasty with custom functions, units, or states.
83
+ * Plugins are processed in order, with later plugins overriding earlier ones.
84
+ * @example
85
+ * ```ts
86
+ * import { okhslPlugin } from '@tenphi/tasty';
87
+ *
88
+ * configure({
89
+ * plugins: [okhslPlugin()],
90
+ * });
91
+ * ```
92
+ */
93
+ plugins?: TastyPlugin[];
94
+ /**
95
+ * Global keyframes definitions that can be referenced by animation names in styles.
96
+ * Keys are animation names, values are keyframes step definitions.
97
+ * Keyframes are only injected when actually used in styles.
98
+ * @example
99
+ * ```ts
100
+ * configure({
101
+ * keyframes: {
102
+ * fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
103
+ * pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
104
+ * },
105
+ * });
106
+ * ```
107
+ */
108
+ keyframes?: Record<string, KeyframesSteps>;
109
+ /**
110
+ * Global CSS @property definitions for custom properties.
111
+ * Keys use tasty token syntax ($name for properties, #name for colors).
112
+ * Properties are only injected when the component using them is rendered.
113
+ *
114
+ * For color tokens (#name), `syntax: '<color>'` is auto-set and
115
+ * `initialValue` defaults to `'transparent'` if not specified.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * configure({
120
+ * properties: {
121
+ * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
122
+ * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
123
+ * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
124
+ * },
125
+ * });
126
+ *
127
+ * // Now use in styles - properties are registered when component renders:
128
+ * const Spinner = tasty({
129
+ * styles: {
130
+ * transform: 'rotate($rotation)',
131
+ * transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
132
+ * },
133
+ * });
134
+ * ```
135
+ */
136
+ properties?: Record<string, PropertyDefinition>;
137
+ /**
138
+ * Global @font-face definitions.
139
+ * Keys are font-family names, values are descriptors or arrays of descriptors
140
+ * (for multiple weights/styles of the same family).
141
+ * Injected eagerly when styles are first generated.
142
+ * @example
143
+ * ```ts
144
+ * configure({
145
+ * fontFace: {
146
+ * 'Brand Sans': [
147
+ * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
148
+ * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
149
+ * ],
150
+ * Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' },
151
+ * },
152
+ * });
153
+ * ```
154
+ */
155
+ fontFace?: Record<string, FontFaceInput>;
156
+ /**
157
+ * Global @counter-style definitions.
158
+ * Keys are counter-style names, values are descriptor objects.
159
+ * Injected eagerly when styles are first generated.
160
+ * @example
161
+ * ```ts
162
+ * configure({
163
+ * counterStyle: {
164
+ * thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' },
165
+ * },
166
+ * });
167
+ * ```
168
+ */
169
+ counterStyle?: Record<string, CounterStyleDescriptors>;
170
+ /**
171
+ * Custom style handlers that transform style properties into CSS declarations.
172
+ * Handlers replace built-in handlers for the same style name.
173
+ * @example
174
+ * ```ts
175
+ * import { styleHandlers } from '@tenphi/tasty';
176
+ *
177
+ * configure({
178
+ * handlers: {
179
+ * // Override fill with custom behavior
180
+ * fill: ({ fill }) => {
181
+ * if (fill?.startsWith('gradient:')) {
182
+ * return { background: fill.slice(9) };
183
+ * }
184
+ * return styleHandlers.fill({ fill });
185
+ * },
186
+ * // Add new custom style
187
+ * elevation: ({ elevation }) => {
188
+ * const level = parseInt(elevation) || 1;
189
+ * return {
190
+ * 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
191
+ * 'z-index': String(level * 100),
192
+ * };
193
+ * },
194
+ * },
195
+ * });
196
+ * ```
197
+ */
198
+ handlers?: Record<string, StyleHandlerDefinition>;
199
+ /**
200
+ * Design tokens injected as CSS custom properties on `:root`.
201
+ * Values are parsed through the Tasty DSL. Supports state maps
202
+ * for responsive/theme-aware tokens.
203
+ *
204
+ * - `$name` keys become `--name` CSS custom properties
205
+ * - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties
206
+ *
207
+ * Tokens are injected once when the first style is rendered.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * configure({
212
+ * tokens: {
213
+ * '$gap': '4px',
214
+ * '#primary': {
215
+ * '': '#purple',
216
+ * '@dark': '#light-purple',
217
+ * },
218
+ * },
219
+ * });
220
+ * ```
221
+ */
222
+ tokens?: ConfigTokens;
223
+ /**
224
+ * Predefined tokens that are replaced during style parsing (parse-time substitution).
225
+ * Use `$name` for custom properties and `#name` for color tokens.
226
+ * Values are substituted inline before CSS generation, unlike `tokens` which
227
+ * inject CSS custom properties on `:root`.
228
+ *
229
+ * For color tokens (#name), boolean `true` is converted to `transparent`.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * configure({
234
+ * replaceTokens: {
235
+ * $spacing: '2x',
236
+ * '#accent': '#purple',
237
+ * '#overlay': true, // → transparent
238
+ * },
239
+ * });
240
+ *
241
+ * // Now use in styles - tokens are replaced at parse time:
242
+ * const Card = tasty({
243
+ * styles: {
244
+ * padding: '$spacing', // → calc(2 * var(--gap))
245
+ * fill: '#accent', // → var(--purple-color)
246
+ * },
247
+ * });
248
+ * ```
249
+ */
250
+ replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
251
+ /**
252
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
253
+ * Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
254
+ * tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
255
+ *
256
+ * Components reference recipes via: `recipe: 'name1 name2'` in their styles.
257
+ * Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
258
+ * Use `none` to skip base recipes: `recipe: 'none / post1'`.
259
+ * Resolution order: `base_recipes → component styles → post_recipes`.
260
+ *
261
+ * Recipes cannot reference other recipes.
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * configure({
266
+ * recipes: {
267
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
268
+ * elevated: { shadow: '2x 2x 4x #shadow' },
269
+ * },
270
+ * });
271
+ *
272
+ * // Usage in styles:
273
+ * const Card = tasty({
274
+ * styles: {
275
+ * recipe: 'card elevated',
276
+ * color: '#text', // Overrides recipe values
277
+ * },
278
+ * });
279
+ * ```
280
+ */
281
+ recipes?: Record<string, RecipeStyles>;
282
+ }
283
+ declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
284
+ declare global {
285
+ interface Window {
286
+ [GLOBAL_INJECTOR_KEY]?: StyleInjector;
287
+ }
288
+ var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
289
+ }
290
+ /**
291
+ * Detect if we're running in a test environment
292
+ */
293
+ declare function isTestEnvironment(): boolean;
294
+ /**
295
+ * Check if styles have been generated (configuration is locked)
296
+ */
297
+ declare function hasStylesGenerated(): boolean;
298
+ /**
299
+ * Check if any global keyframes are configured.
300
+ * Uses a pre-computed flag to avoid Object.keys() allocation on every call.
301
+ */
302
+ declare function hasGlobalKeyframes(): boolean;
303
+ /**
304
+ * Get global keyframes configuration.
305
+ * Returns null if no keyframes configured (fast path for zero-overhead).
306
+ */
307
+ declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
308
+ /**
309
+ * Get global font-face configuration.
310
+ * Returns null if no font faces configured.
311
+ */
312
+ declare function getGlobalFontFace(): Record<string, FontFaceInput> | null;
313
+ /**
314
+ * Get global counter-style configuration.
315
+ * Returns null if no counter styles configured.
316
+ */
317
+ declare function getGlobalCounterStyle(): Record<string, CounterStyleDescriptors> | null;
318
+ /**
319
+ * Check if any global recipes are configured.
320
+ * Fast path: returns false if no recipes were ever set.
321
+ */
322
+ declare function hasGlobalRecipes(): boolean;
323
+ /**
324
+ * Get global recipes configuration.
325
+ * Returns null if no recipes configured (fast path for zero-overhead).
326
+ */
327
+ declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
328
+ /**
329
+ * Check if configuration is locked (styles have been generated)
330
+ */
331
+ declare function isConfigLocked(): boolean;
332
+ /**
333
+ * Configure the Tasty style system.
334
+ *
335
+ * Must be called BEFORE any styles are generated (before first render that uses tasty).
336
+ * After styles are generated, configuration is locked and calls to configure() will
337
+ * emit a warning and be ignored.
338
+ *
339
+ * @example
340
+ * ```ts
341
+ * import { configure } from '@tenphi/tasty';
342
+ *
343
+ * // Configure before app renders
344
+ * configure({
345
+ * nonce: 'abc123',
346
+ * states: {
347
+ * '@mobile': '@media(w < 768px)',
348
+ * '@dark': '@root(theme=dark)',
349
+ * },
350
+ * });
351
+ * ```
352
+ */
353
+ declare function configure(config?: Partial<TastyConfig>): void;
354
+ /**
355
+ * Get the current configuration.
356
+ * If not configured, returns default configuration.
357
+ */
358
+ declare function getConfig(): TastyConfig;
359
+ /**
360
+ * Reset configuration (for testing only).
361
+ * Clears the global injector and allows reconfiguration.
362
+ */
363
+ declare function resetConfig(): void;
364
+ //#endregion
365
+ export { TastyConfig, configure, getConfig, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig };
366
+ //# sourceMappingURL=config.d.ts.map