@tenphi/tasty 0.0.0-snapshot.c8bdaeb → 0.0.0-snapshot.cb232f9

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 (303) hide show
  1. package/README.md +314 -159
  2. package/dist/async-storage-B7_o6FKt.js +44 -0
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/collector-BQHl-atL.d.ts +108 -0
  5. package/dist/collector-DROCOiaT.js +243 -0
  6. package/dist/collector-DROCOiaT.js.map +1 -0
  7. package/dist/config-CzzTHmtS.d.ts +928 -0
  8. package/dist/config-JokB1Lc8.js +10351 -0
  9. package/dist/config-JokB1Lc8.js.map +1 -0
  10. package/dist/context-CkSg-kDT.js +24 -0
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -33
  13. package/dist/core/index.js +6 -26
  14. package/dist/core-CW4XEUFk.js +1598 -0
  15. package/dist/core-CW4XEUFk.js.map +1 -0
  16. package/dist/css-writer-Jv468wSl.js +351 -0
  17. package/dist/css-writer-Jv468wSl.js.map +1 -0
  18. package/dist/format-global-rules-Dbc_1tc3.js +22 -0
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-B0vbh8Qz.js +143 -0
  21. package/dist/format-rules-B0vbh8Qz.js.map +1 -0
  22. package/dist/hydrate-BO6nlAeD.js +45 -0
  23. package/dist/hydrate-BO6nlAeD.js.map +1 -0
  24. package/dist/index-CgD29XlB.d.ts +1628 -0
  25. package/dist/index-Dy74C11K.d.ts +1273 -0
  26. package/dist/index.d.ts +5 -48
  27. package/dist/index.js +777 -32
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-J_JNrpdh.js +588 -0
  30. package/dist/keyframes-J_JNrpdh.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BS-mpcci.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-Du-eC7zp.js} +4 -6
  33. package/dist/merge-styles-Du-eC7zp.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-DPRT3FMM.js} +5 -8
  35. package/dist/resolve-recipes-DPRT3FMM.js.map +1 -0
  36. package/dist/ssr/astro-client.d.ts +1 -0
  37. package/dist/ssr/astro-client.js +19 -0
  38. package/dist/ssr/astro-client.js.map +1 -0
  39. package/dist/ssr/astro-middleware.d.ts +15 -0
  40. package/dist/ssr/astro-middleware.js +19 -0
  41. package/dist/ssr/astro-middleware.js.map +1 -0
  42. package/dist/ssr/astro.d.ts +97 -0
  43. package/dist/ssr/astro.js +149 -0
  44. package/dist/ssr/astro.js.map +1 -0
  45. package/dist/ssr/index.d.ts +44 -0
  46. package/dist/ssr/index.js +10 -0
  47. package/dist/ssr/index.js.map +1 -0
  48. package/dist/ssr/next.d.ts +46 -0
  49. package/dist/ssr/next.js +75 -0
  50. package/dist/ssr/next.js.map +1 -0
  51. package/dist/static/index.d.ts +91 -5
  52. package/dist/static/index.js +49 -4
  53. package/dist/static/index.js.map +1 -0
  54. package/dist/static/inject.d.ts +5 -0
  55. package/dist/static/inject.js +17 -0
  56. package/dist/static/inject.js.map +1 -0
  57. package/dist/zero/babel.d.ts +57 -84
  58. package/dist/zero/babel.js +232 -40
  59. package/dist/zero/babel.js.map +1 -1
  60. package/dist/zero/index.d.ts +67 -3
  61. package/dist/zero/index.js +2 -4
  62. package/dist/zero/next.d.ts +56 -30
  63. package/dist/zero/next.js +105 -40
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +31 -0
  66. package/docs/adoption.md +298 -0
  67. package/docs/comparison.md +419 -0
  68. package/docs/configuration.md +438 -0
  69. package/docs/debug.md +320 -0
  70. package/docs/design-system.md +436 -0
  71. package/docs/dsl.md +690 -0
  72. package/docs/getting-started.md +217 -0
  73. package/docs/injector.md +544 -0
  74. package/docs/methodology.md +638 -0
  75. package/docs/pipeline.md +673 -0
  76. package/docs/react-api.md +575 -0
  77. package/docs/ssr.md +444 -0
  78. package/docs/styles.md +596 -0
  79. package/docs/tasty-static.md +547 -0
  80. package/package.json +70 -37
  81. package/tasty.config.ts +1 -0
  82. package/dist/_virtual/_rolldown/runtime.js +0 -8
  83. package/dist/chunks/cacheKey.js +0 -70
  84. package/dist/chunks/cacheKey.js.map +0 -1
  85. package/dist/chunks/definitions.d.ts +0 -37
  86. package/dist/chunks/definitions.js +0 -260
  87. package/dist/chunks/definitions.js.map +0 -1
  88. package/dist/chunks/renderChunk.js +0 -61
  89. package/dist/chunks/renderChunk.js.map +0 -1
  90. package/dist/config.d.ts +0 -280
  91. package/dist/config.js +0 -403
  92. package/dist/config.js.map +0 -1
  93. package/dist/debug.d.ts +0 -204
  94. package/dist/debug.js +0 -733
  95. package/dist/debug.js.map +0 -1
  96. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  97. package/dist/hooks/useGlobalStyles.js +0 -56
  98. package/dist/hooks/useGlobalStyles.js.map +0 -1
  99. package/dist/hooks/useKeyframes.d.ts +0 -56
  100. package/dist/hooks/useKeyframes.js +0 -54
  101. package/dist/hooks/useKeyframes.js.map +0 -1
  102. package/dist/hooks/useProperty.d.ts +0 -79
  103. package/dist/hooks/useProperty.js +0 -91
  104. package/dist/hooks/useProperty.js.map +0 -1
  105. package/dist/hooks/useRawCSS.d.ts +0 -53
  106. package/dist/hooks/useRawCSS.js +0 -28
  107. package/dist/hooks/useRawCSS.js.map +0 -1
  108. package/dist/hooks/useStyles.d.ts +0 -40
  109. package/dist/hooks/useStyles.js +0 -169
  110. package/dist/hooks/useStyles.js.map +0 -1
  111. package/dist/injector/index.d.ts +0 -157
  112. package/dist/injector/index.js +0 -154
  113. package/dist/injector/index.js.map +0 -1
  114. package/dist/injector/injector.d.ts +0 -139
  115. package/dist/injector/injector.js +0 -404
  116. package/dist/injector/injector.js.map +0 -1
  117. package/dist/injector/sheet-manager.d.ts +0 -127
  118. package/dist/injector/sheet-manager.js +0 -714
  119. package/dist/injector/sheet-manager.js.map +0 -1
  120. package/dist/injector/types.d.ts +0 -135
  121. package/dist/keyframes/index.js +0 -206
  122. package/dist/keyframes/index.js.map +0 -1
  123. package/dist/parser/classify.js +0 -319
  124. package/dist/parser/classify.js.map +0 -1
  125. package/dist/parser/const.js +0 -33
  126. package/dist/parser/const.js.map +0 -1
  127. package/dist/parser/lru.js +0 -109
  128. package/dist/parser/lru.js.map +0 -1
  129. package/dist/parser/parser.d.ts +0 -25
  130. package/dist/parser/parser.js +0 -116
  131. package/dist/parser/parser.js.map +0 -1
  132. package/dist/parser/tokenizer.js +0 -69
  133. package/dist/parser/tokenizer.js.map +0 -1
  134. package/dist/parser/types.d.ts +0 -51
  135. package/dist/parser/types.js +0 -46
  136. package/dist/parser/types.js.map +0 -1
  137. package/dist/pipeline/conditions.d.ts +0 -134
  138. package/dist/pipeline/conditions.js +0 -406
  139. package/dist/pipeline/conditions.js.map +0 -1
  140. package/dist/pipeline/exclusive.js +0 -231
  141. package/dist/pipeline/exclusive.js.map +0 -1
  142. package/dist/pipeline/index.d.ts +0 -53
  143. package/dist/pipeline/index.js +0 -660
  144. package/dist/pipeline/index.js.map +0 -1
  145. package/dist/pipeline/materialize.js +0 -844
  146. package/dist/pipeline/materialize.js.map +0 -1
  147. package/dist/pipeline/parseStateKey.d.ts +0 -15
  148. package/dist/pipeline/parseStateKey.js +0 -438
  149. package/dist/pipeline/parseStateKey.js.map +0 -1
  150. package/dist/pipeline/simplify.js +0 -516
  151. package/dist/pipeline/simplify.js.map +0 -1
  152. package/dist/pipeline/warnings.js +0 -18
  153. package/dist/pipeline/warnings.js.map +0 -1
  154. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  155. package/dist/plugins/okhsl-plugin.js +0 -371
  156. package/dist/plugins/okhsl-plugin.js.map +0 -1
  157. package/dist/plugins/types.d.ts +0 -69
  158. package/dist/properties/index.js +0 -158
  159. package/dist/properties/index.js.map +0 -1
  160. package/dist/states/index.d.ts +0 -49
  161. package/dist/states/index.js +0 -416
  162. package/dist/states/index.js.map +0 -1
  163. package/dist/static/tastyStatic.d.ts +0 -46
  164. package/dist/static/tastyStatic.js +0 -31
  165. package/dist/static/tastyStatic.js.map +0 -1
  166. package/dist/static/types.d.ts +0 -49
  167. package/dist/static/types.js +0 -24
  168. package/dist/static/types.js.map +0 -1
  169. package/dist/styles/align.d.ts +0 -15
  170. package/dist/styles/align.js +0 -14
  171. package/dist/styles/align.js.map +0 -1
  172. package/dist/styles/border.d.ts +0 -25
  173. package/dist/styles/border.js +0 -114
  174. package/dist/styles/border.js.map +0 -1
  175. package/dist/styles/color.d.ts +0 -14
  176. package/dist/styles/color.js +0 -23
  177. package/dist/styles/color.js.map +0 -1
  178. package/dist/styles/createStyle.js +0 -77
  179. package/dist/styles/createStyle.js.map +0 -1
  180. package/dist/styles/dimension.js +0 -97
  181. package/dist/styles/dimension.js.map +0 -1
  182. package/dist/styles/display.d.ts +0 -37
  183. package/dist/styles/display.js +0 -67
  184. package/dist/styles/display.js.map +0 -1
  185. package/dist/styles/fade.d.ts +0 -15
  186. package/dist/styles/fade.js +0 -58
  187. package/dist/styles/fade.js.map +0 -1
  188. package/dist/styles/fill.d.ts +0 -42
  189. package/dist/styles/fill.js +0 -51
  190. package/dist/styles/fill.js.map +0 -1
  191. package/dist/styles/flow.d.ts +0 -16
  192. package/dist/styles/flow.js +0 -12
  193. package/dist/styles/flow.js.map +0 -1
  194. package/dist/styles/gap.d.ts +0 -31
  195. package/dist/styles/gap.js +0 -37
  196. package/dist/styles/gap.js.map +0 -1
  197. package/dist/styles/height.d.ts +0 -17
  198. package/dist/styles/height.js +0 -20
  199. package/dist/styles/height.js.map +0 -1
  200. package/dist/styles/index.d.ts +0 -2
  201. package/dist/styles/index.js +0 -9
  202. package/dist/styles/index.js.map +0 -1
  203. package/dist/styles/inset.d.ts +0 -52
  204. package/dist/styles/inset.js +0 -150
  205. package/dist/styles/inset.js.map +0 -1
  206. package/dist/styles/justify.d.ts +0 -15
  207. package/dist/styles/justify.js +0 -14
  208. package/dist/styles/justify.js.map +0 -1
  209. package/dist/styles/list.d.ts +0 -16
  210. package/dist/styles/list.js +0 -98
  211. package/dist/styles/list.js.map +0 -1
  212. package/dist/styles/margin.d.ts +0 -24
  213. package/dist/styles/margin.js +0 -104
  214. package/dist/styles/margin.js.map +0 -1
  215. package/dist/styles/outline.d.ts +0 -29
  216. package/dist/styles/outline.js +0 -65
  217. package/dist/styles/outline.js.map +0 -1
  218. package/dist/styles/padding.d.ts +0 -24
  219. package/dist/styles/padding.js +0 -104
  220. package/dist/styles/padding.js.map +0 -1
  221. package/dist/styles/predefined.d.ts +0 -73
  222. package/dist/styles/predefined.js +0 -241
  223. package/dist/styles/predefined.js.map +0 -1
  224. package/dist/styles/preset.d.ts +0 -47
  225. package/dist/styles/preset.js +0 -126
  226. package/dist/styles/preset.js.map +0 -1
  227. package/dist/styles/radius.d.ts +0 -14
  228. package/dist/styles/radius.js +0 -51
  229. package/dist/styles/radius.js.map +0 -1
  230. package/dist/styles/scrollbar.d.ts +0 -21
  231. package/dist/styles/scrollbar.js +0 -112
  232. package/dist/styles/scrollbar.js.map +0 -1
  233. package/dist/styles/shadow.d.ts +0 -14
  234. package/dist/styles/shadow.js +0 -24
  235. package/dist/styles/shadow.js.map +0 -1
  236. package/dist/styles/styledScrollbar.d.ts +0 -47
  237. package/dist/styles/styledScrollbar.js +0 -38
  238. package/dist/styles/styledScrollbar.js.map +0 -1
  239. package/dist/styles/transition.d.ts +0 -14
  240. package/dist/styles/transition.js +0 -158
  241. package/dist/styles/transition.js.map +0 -1
  242. package/dist/styles/types.d.ts +0 -498
  243. package/dist/styles/width.d.ts +0 -17
  244. package/dist/styles/width.js +0 -20
  245. package/dist/styles/width.js.map +0 -1
  246. package/dist/tasty.d.ts +0 -982
  247. package/dist/tasty.js +0 -206
  248. package/dist/tasty.js.map +0 -1
  249. package/dist/tokens/typography.d.ts +0 -19
  250. package/dist/tokens/typography.js +0 -237
  251. package/dist/tokens/typography.js.map +0 -1
  252. package/dist/types.d.ts +0 -184
  253. package/dist/utils/cache-wrapper.js +0 -26
  254. package/dist/utils/cache-wrapper.js.map +0 -1
  255. package/dist/utils/case-converter.js +0 -8
  256. package/dist/utils/case-converter.js.map +0 -1
  257. package/dist/utils/colors.d.ts +0 -5
  258. package/dist/utils/colors.js +0 -9
  259. package/dist/utils/colors.js.map +0 -1
  260. package/dist/utils/css-types.d.ts +0 -7
  261. package/dist/utils/dotize.d.ts +0 -26
  262. package/dist/utils/dotize.js +0 -122
  263. package/dist/utils/dotize.js.map +0 -1
  264. package/dist/utils/filter-base-props.d.ts +0 -15
  265. package/dist/utils/filter-base-props.js +0 -45
  266. package/dist/utils/filter-base-props.js.map +0 -1
  267. package/dist/utils/get-display-name.d.ts +0 -7
  268. package/dist/utils/get-display-name.js +0 -10
  269. package/dist/utils/get-display-name.js.map +0 -1
  270. package/dist/utils/hsl-to-rgb.js +0 -38
  271. package/dist/utils/hsl-to-rgb.js.map +0 -1
  272. package/dist/utils/is-dev-env.js +0 -19
  273. package/dist/utils/is-dev-env.js.map +0 -1
  274. package/dist/utils/is-valid-element-type.js +0 -15
  275. package/dist/utils/is-valid-element-type.js.map +0 -1
  276. package/dist/utils/merge-styles.js.map +0 -1
  277. package/dist/utils/mod-attrs.d.ts +0 -8
  278. package/dist/utils/mod-attrs.js +0 -21
  279. package/dist/utils/mod-attrs.js.map +0 -1
  280. package/dist/utils/okhsl-to-rgb.js +0 -296
  281. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  282. package/dist/utils/process-tokens.d.ts +0 -31
  283. package/dist/utils/process-tokens.js +0 -171
  284. package/dist/utils/process-tokens.js.map +0 -1
  285. package/dist/utils/resolve-recipes.d.ts +0 -17
  286. package/dist/utils/resolve-recipes.js.map +0 -1
  287. package/dist/utils/string.js +0 -8
  288. package/dist/utils/string.js.map +0 -1
  289. package/dist/utils/styles.d.ts +0 -178
  290. package/dist/utils/styles.js +0 -590
  291. package/dist/utils/styles.js.map +0 -1
  292. package/dist/utils/typography.d.ts +0 -36
  293. package/dist/utils/typography.js +0 -53
  294. package/dist/utils/typography.js.map +0 -1
  295. package/dist/utils/warnings.d.ts +0 -16
  296. package/dist/utils/warnings.js +0 -16
  297. package/dist/utils/warnings.js.map +0 -1
  298. package/dist/zero/css-writer.d.ts +0 -45
  299. package/dist/zero/css-writer.js +0 -74
  300. package/dist/zero/css-writer.js.map +0 -1
  301. package/dist/zero/extractor.d.ts +0 -24
  302. package/dist/zero/extractor.js +0 -150
  303. package/dist/zero/extractor.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,33 +1,778 @@
1
- import { Bucket } from "./parser/types.js";
2
- import { StyleParser } from "./parser/parser.js";
3
- import { okhslFunc, okhslPlugin } from "./plugins/okhsl-plugin.js";
4
- import { createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
5
- import { hslToRgbValues, processTokens, stringifyTokens } from "./utils/process-tokens.js";
6
- import { COMPUTE_FUNC_MAP, CUSTOM_UNITS, DIRECTIONS, STATE_OPERATORS, STATE_OPERATOR_LIST, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getModSelector, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList } from "./utils/styles.js";
7
- import { styleHandlers } from "./styles/predefined.js";
8
- import { SheetManager } from "./injector/sheet-manager.js";
9
- import { StyleInjector } from "./injector/injector.js";
10
- import { parseStateKey } from "./pipeline/parseStateKey.js";
11
- import { isSelector, renderStyles } from "./pipeline/index.js";
12
- import { configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
13
- import { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys } from "./chunks/definitions.js";
14
- import { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES } from "./styles/list.js";
15
- import { allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property } from "./injector/index.js";
16
- import { filterBaseProps } from "./utils/filter-base-props.js";
17
- import { color } from "./utils/colors.js";
18
- import { _modAttrs } from "./utils/mod-attrs.js";
19
- import { dotize } from "./utils/dotize.js";
20
- import { mergeStyles } from "./utils/merge-styles.js";
21
- import { resolveRecipes } from "./utils/resolve-recipes.js";
22
- import { deprecationWarning, warn } from "./utils/warnings.js";
23
- import { generateTypographyTokens } from "./utils/typography.js";
24
- import { tastyDebug } from "./debug.js";
25
- import { useStyles } from "./hooks/useStyles.js";
26
- import { getDisplayName } from "./utils/get-display-name.js";
27
- import { Element, tasty } from "./tasty.js";
28
- import { useGlobalStyles } from "./hooks/useGlobalStyles.js";
29
- import { useRawCSS } from "./hooks/useRawCSS.js";
30
- import { useKeyframes } from "./hooks/useKeyframes.js";
31
- import { useProperty } from "./hooks/useProperty.js";
1
+ import { $ as parseColor, A as StyleInjector, At as strToRgb, B as styleHandlers, C as parseStateKey, Dt as getRgbValuesFromRgbaString, Et as getNamedColorHex, F as fontFaceContentHash, G as CUSTOM_UNITS, H as warn, I as formatFontFaceRule, J as filterMods, K as DIRECTIONS, M as formatCounterStyleRule, O as getGlobalPredefinedStates, Ot as hexToRgb, Q as normalizeColorTokenValue, R as SheetManager, S as renderStyles, T as createStateParserContext, V as deprecationWarning, X as getGlobalParser, Y as getGlobalFuncs, Z as getGlobalPredefinedTokens, a as getGlobalCounterStyle, at as okhslPlugin, c as getGlobalKeyframes, ct as DEFAULT_NAME_PREFIX, d as getNamePrefix, dt as makeCounterStyleName, et as parseStyle, f as hasGlobalKeyframes, ft as makeKeyframeName, g as isTestEnvironment, gt as hashString, h as isConfigLocked, it as okhslFunc, k as setGlobalPredefinedStates, kt as hslToRgbValues, l as getGlobalRecipes, lt as DEFAULT_ZERO_NAME_PREFIX, m as hasStylesGenerated, n as getConfig, nt as setGlobalPredefinedTokens, o as getGlobalFontFace, ot as StyleParser, p as hasGlobalRecipes, q as customFunc, rt as stringifyStyles, s as getGlobalInjector, st as Bucket, t as configure, tt as resetGlobalPredefinedTokens, v as resetConfig, x as isSelector, y as generateTypographyTokens } from "./config-JokB1Lc8.js";
2
+ import { d as categorizeStyleKeys, l as CHUNK_NAMES, u as STYLE_TO_CHUNK } from "./keyframes-J_JNrpdh.js";
3
+ import { A as property, B as DIMENSION_STYLES, C as getRawCSSText, D as injector, E as injectRawCSS, F as BLOCK_INNER_STYLES, G as TEXT_STYLES, H as INNER_STYLES, I as BLOCK_OUTER_STYLES, L as BLOCK_STYLES, M as ChunkSheetRegistry, N as chunkSheetRegistry, O as isPropertyDefined, P as BASE_STYLES, R as COLOR_STYLES, S as getIsTestEnvironment, T as injectGlobal, U as OUTER_STYLES, V as FLOW_STYLES, W as POSITION_STYLES, _ as destroy, a as color, b as getCssText, c as hasKeys, d as collectAutoInferredPropertiesRSC, f as getStyleTarget, g as createInjector, h as counterStyle, i as _modAttrs, j as touch, k as keyframes, l as formatKeyframesCSS, m as cleanup, n as processTokens, o as filterBaseProps, p as pushRSCCSS, r as dotize, s as computeStyles, t as tastyDebug, u as collectAutoInferredProperties, v as fontFace, w as inject, x as getCssTextForNode, y as gc, z as CONTAINER_STYLES } from "./core-CW4XEUFk.js";
4
+ import { n as formatPropertyCSS } from "./format-rules-B0vbh8Qz.js";
5
+ import { t as mergeStyles } from "./merge-styles-Du-eC7zp.js";
6
+ import { t as resolveRecipes } from "./resolve-recipes-DPRT3FMM.js";
7
+ import { t as getTastySSRContext } from "./context-CkSg-kDT.js";
8
+ import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
9
+ import { Fragment, createElement, forwardRef, useContext } from "react";
10
+ //#region src/utils/get-display-name.ts
11
+ const DEFAULT_NAME = "Anonymous";
12
+ function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
13
+ if (typeof Component === "function") return Component.displayName ?? Component.name ?? fallbackName;
14
+ return fallbackName;
15
+ }
16
+ //#endregion
17
+ //#region src/utils/is-tasty-component.ts
18
+ /**
19
+ * Brand applied to every component returned by `tasty()` so the dispatcher
20
+ * can distinguish Tasty-produced components from arbitrary React components
21
+ * (third-party libraries, plain `forwardRef`/`memo` wrappers, string tags).
22
+ *
23
+ * Uses `Symbol.for(...)` so that multiple bundled copies of `@tenphi/tasty`
24
+ * still recognise each other's components — important for monorepos and
25
+ * peer-dep nesting.
26
+ */
27
+ const TASTY_COMPONENT_BRAND = Symbol.for("@tenphi/tasty.component");
28
+ /**
29
+ * Returns `true` when `value` is a component produced by `tasty()`.
30
+ *
31
+ * Sub-elements created via `createSubElement` are intentionally not branded:
32
+ * they forward `className`/`style` to their underlying tag but do not consume
33
+ * `styles`, so wrapping them must go through the non-Tasty path.
34
+ */
35
+ function isTastyComponent(value) {
36
+ if (value == null) return false;
37
+ const type = typeof value;
38
+ if (type !== "function" && type !== "object") return false;
39
+ return value[TASTY_COMPONENT_BRAND] === true;
40
+ }
41
+ /**
42
+ * Marks `value` as a Tasty-produced component. No-op if `value` is not a
43
+ * brandable target (string tags, primitives, etc.).
44
+ */
45
+ function brandTastyComponent(value) {
46
+ if (value == null) return value;
47
+ const type = typeof value;
48
+ if (type !== "function" && type !== "object") return value;
49
+ try {
50
+ value[TASTY_COMPONENT_BRAND] = true;
51
+ } catch {}
52
+ return value;
53
+ }
54
+ //#endregion
55
+ //#region src/utils/is-valid-element-type.ts
56
+ /**
57
+ * Lightweight replacement for `react-is`'s isValidElementType.
58
+ * Detects string tags, function/class components, and React exotic types
59
+ * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.
60
+ */
61
+ function isValidElementType(value) {
62
+ if (typeof value === "string" || typeof value === "function") return true;
63
+ if (typeof value === "object" && value !== null) return typeof value.$$typeof === "symbol";
64
+ return false;
65
+ }
66
+ //#endregion
67
+ //#region src/tasty.tsx
68
+ /**
69
+ * Precalculated entries for performance optimization
70
+ */
71
+ const IS_PROPERTIES_ENTRIES = Object.entries({
72
+ isDisabled: "disabled",
73
+ isHidden: "hidden",
74
+ isChecked: "checked"
75
+ });
76
+ /**
77
+ * Helper function to handle is* properties consistently
78
+ * Transforms is* props to HTML attributes and adds corresponding data-* attributes
79
+ */
80
+ function handleIsProperties(props) {
81
+ for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {
82
+ if (isProperty in props) {
83
+ props[targetAttribute] = props[isProperty];
84
+ delete props[isProperty];
85
+ }
86
+ const dataAttribute = `data-${targetAttribute}`;
87
+ if (!(dataAttribute in props) && props[targetAttribute]) props[dataAttribute] = "";
88
+ }
89
+ }
90
+ /**
91
+ * Creates a sub-element component for compound component patterns.
92
+ * Sub-elements are lightweight components with data-element attribute for CSS targeting.
93
+ */
94
+ function createSubElement(elementName, definition) {
95
+ const config = typeof definition === "string" ? { as: definition } : definition;
96
+ const tag = config.as ?? "div";
97
+ const defaultQa = config.qa;
98
+ const defaultQaVal = config.qaVal;
99
+ const SubElement = forwardRef((props, ref) => {
100
+ const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
101
+ let modDataAttrs;
102
+ if (mods) modDataAttrs = _modAttrs(mods);
103
+ const tokenStyle = tokens ? processTokens(tokens) : void 0;
104
+ let mergedStyle;
105
+ if (tokenStyle || style) mergedStyle = tokenStyle && style ? {
106
+ ...tokenStyle,
107
+ ...style
108
+ } : tokenStyle ?? style;
109
+ const elementProps = {
110
+ "data-element": elementName,
111
+ "data-qa": qa ?? defaultQa,
112
+ "data-qaval": qaVal ?? defaultQaVal,
113
+ ...modDataAttrs || {},
114
+ ...htmlProps,
115
+ className,
116
+ style: mergedStyle,
117
+ isDisabled,
118
+ isHidden,
119
+ isChecked,
120
+ ref
121
+ };
122
+ handleIsProperties(elementProps);
123
+ if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
124
+ if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
125
+ return createElement(tag, elementProps);
126
+ });
127
+ SubElement.displayName = `SubElement(${elementName})`;
128
+ return SubElement;
129
+ }
130
+ /**
131
+ * Pre-compute the mapping from prop name to token key at component-creation time.
132
+ * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.
133
+ * Object form: entries used as-is.
134
+ */
135
+ function buildTokenPropsMapping(def) {
136
+ if (Array.isArray(def)) return def.map((propName) => {
137
+ if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
138
+ return [propName, `$${propName}`];
139
+ });
140
+ return Object.entries(def);
141
+ }
142
+ function tasty(Component, options) {
143
+ if (isValidElementType(Component)) {
144
+ if (isTastyComponent(Component)) return tastyWrap(Component, options);
145
+ return tastyElement({
146
+ ...options ?? {},
147
+ as: Component
148
+ });
149
+ }
150
+ return tastyElement(Component);
151
+ }
152
+ function tastyWrap(Component, options) {
153
+ const { as: extendTag, element: extendElement, ...defaultProps } = options ?? {};
154
+ const propsWithStyles = ["styles"].concat(Object.keys(defaultProps).filter((prop) => prop.endsWith("Styles")));
155
+ const _WrappedComponent = forwardRef((props, ref) => {
156
+ const { as, element, ...restProps } = props;
157
+ const mergedStylesMap = propsWithStyles.reduce((map, prop) => {
158
+ const restValue = restProps[prop];
159
+ const defaultValue = defaultProps[prop];
160
+ if (restValue != null && defaultValue != null) map[prop] = mergeStyles(defaultValue, restValue);
161
+ else map[prop] = restValue ?? defaultValue;
162
+ return map;
163
+ }, {});
164
+ return createElement(Component, {
165
+ ...defaultProps,
166
+ ...restProps,
167
+ ...mergedStylesMap,
168
+ as: as ?? extendTag,
169
+ element: element || extendElement,
170
+ ref
171
+ });
172
+ });
173
+ _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
174
+ brandTastyComponent(_WrappedComponent);
175
+ return _WrappedComponent;
176
+ }
177
+ function tastyElement(tastyOptions) {
178
+ const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
179
+ let variantStylesMap;
180
+ if (variants) {
181
+ let baseStyles = defaultStyles;
182
+ let extensionStyles;
183
+ if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
184
+ if (isSelector(key)) continue;
185
+ const value = defaultStyles[key];
186
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
187
+ if (!extensionStyles) {
188
+ baseStyles = { ...defaultStyles };
189
+ extensionStyles = {};
190
+ }
191
+ extensionStyles[key] = value;
192
+ delete baseStyles[key];
193
+ }
194
+ }
195
+ variantStylesMap = Object.entries(variants).reduce((map, [variant, variantStyles]) => {
196
+ map[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
197
+ return map;
198
+ }, {});
199
+ if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
200
+ }
201
+ const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps ?? {};
202
+ const propsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
203
+ const modPropsKeys = modPropsDef ? Array.isArray(modPropsDef) ? modPropsDef : Object.keys(modPropsDef) : void 0;
204
+ const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
205
+ const classNameCache = /* @__PURE__ */ new Map();
206
+ const _TastyComponent = forwardRef((allProps, ref) => {
207
+ const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, ...otherProps } = allProps;
208
+ let styles = rawStyles;
209
+ let propStyles = null;
210
+ for (const prop of propsToCheck) {
211
+ const key = prop;
212
+ if (key in otherProps) {
213
+ if (!propStyles) propStyles = {};
214
+ const value = otherProps[key];
215
+ propStyles[key] = value;
216
+ delete otherProps[key];
217
+ }
218
+ }
219
+ if (!styles || styles && !hasKeys(styles)) styles = void 0;
220
+ let propMods;
221
+ if (modPropsKeys) {
222
+ for (const key of modPropsKeys) if (key in otherProps) {
223
+ if (!propMods) propMods = {};
224
+ propMods[key] = otherProps[key];
225
+ delete otherProps[key];
226
+ }
227
+ }
228
+ let propTokens;
229
+ if (tokenPropsMapping) {
230
+ for (const [propName, tokenKey] of tokenPropsMapping) if (propName in otherProps) {
231
+ if (!propTokens) propTokens = {};
232
+ propTokens[tokenKey] = otherProps[propName];
233
+ delete otherProps[propName];
234
+ }
235
+ }
236
+ const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
237
+ const hasInstanceStyles = styles && hasKeys(styles);
238
+ const hasPropStyles = propStyles && hasKeys(propStyles);
239
+ const allStyles = hasInstanceStyles || hasPropStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
240
+ const useFactoryCache = typeof document !== "undefined";
241
+ let stylesResult;
242
+ if (useFactoryCache && allStyles === baseStyles && classNameCache.has(allStyles)) {
243
+ stylesResult = { className: classNameCache.get(allStyles) };
244
+ touch(stylesResult.className);
245
+ } else {
246
+ stylesResult = computeStyles(allStyles);
247
+ if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, stylesResult.className);
248
+ }
249
+ let mergedTokens;
250
+ if (defaultTokens || tokens || propTokens) if (!defaultTokens && !propTokens) mergedTokens = tokens;
251
+ else if (!tokens && !propTokens) mergedTokens = defaultTokens;
252
+ else mergedTokens = {
253
+ ...defaultTokens,
254
+ ...tokens,
255
+ ...propTokens
256
+ };
257
+ const processedTokenStyle = processTokens(mergedTokens);
258
+ let mergedStyle;
259
+ if (processedTokenStyle || style) if (!processedTokenStyle) mergedStyle = style;
260
+ else if (!style) mergedStyle = processedTokenStyle;
261
+ else mergedStyle = {
262
+ ...processedTokenStyle,
263
+ ...style
264
+ };
265
+ const mergedMods = propMods ? {
266
+ ...mods,
267
+ ...propMods
268
+ } : mods;
269
+ let modDataAttrs;
270
+ if (mergedMods) modDataAttrs = _modAttrs(mergedMods);
271
+ const finalClassName = [userClassName || "", stylesResult.className].filter(Boolean).join(" ");
272
+ const elementProps = {
273
+ "data-element": element || defaultElement,
274
+ "data-qa": qa || defaultQa,
275
+ "data-qaval": qaVal || defaultQaVal,
276
+ ...otherDefaultProps,
277
+ ...modDataAttrs || {},
278
+ ...otherProps,
279
+ className: finalClassName,
280
+ style: mergedStyle,
281
+ ref
282
+ };
283
+ handleIsProperties(elementProps);
284
+ const el = createElement(as ?? originalAs, elementProps);
285
+ if (stylesResult.css) {
286
+ const nonce = getConfig().nonce;
287
+ return createElement(Fragment, null, createElement("style", {
288
+ "data-tasty-rsc": "",
289
+ nonce,
290
+ dangerouslySetInnerHTML: { __html: stylesResult.css }
291
+ }), el);
292
+ }
293
+ return el;
294
+ });
295
+ _TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
296
+ brandTastyComponent(_TastyComponent);
297
+ if (elements) {
298
+ const subElements = Object.entries(elements).reduce((acc, [name, definition]) => {
299
+ acc[name] = createSubElement(name, definition);
300
+ return acc;
301
+ }, {});
302
+ return Object.assign(_TastyComponent, subElements);
303
+ }
304
+ return _TastyComponent;
305
+ }
306
+ const Element = tasty({});
307
+ //#endregion
308
+ //#region src/hooks/useStyles.ts
309
+ /**
310
+ * Hook to generate CSS classes from Tasty styles.
311
+ * Thin wrapper around `computeStyles()` that adds React context-based
312
+ * SSR collector discovery for backward compatibility with TastyRegistry.
313
+ *
314
+ * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
315
+ *
316
+ * @example
317
+ * ```tsx
318
+ * function MyComponent() {
319
+ * const { className } = useStyles({
320
+ * padding: '2x',
321
+ * fill: '#purple',
322
+ * radius: '1r',
323
+ * });
324
+ *
325
+ * return <div className={className}>Styled content</div>;
326
+ * }
327
+ * ```
328
+ */
329
+ function useStyles(styles, options) {
330
+ return computeStyles(styles, {
331
+ ssrCollector: useContext(getTastySSRContext()),
332
+ root: options?.root
333
+ });
334
+ }
335
+ //#endregion
336
+ //#region src/hooks/useGlobalStyles.ts
337
+ const clientGlobalEntries = /* @__PURE__ */ new Map();
338
+ /**
339
+ * Inject global styles for a given selector.
340
+ * Useful for styling elements by selector without generating classNames.
341
+ *
342
+ * SSR-aware: when a ServerStyleCollector is available, CSS is collected
343
+ * during the render phase instead of being injected into the DOM.
344
+ *
345
+ * Works in all environments: client, SSR with collector, and React Server Components.
346
+ *
347
+ * Injected styles are permanent — they are not cleaned up on component unmount.
348
+ * Use the `id` option for update tracking when styles change over the
349
+ * component lifecycle.
350
+ *
351
+ * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
352
+ * @param styles - Tasty styles object
353
+ * @param options - Optional settings including `id` for update tracking
354
+ *
355
+ * @example
356
+ * ```tsx
357
+ * function MyComponent() {
358
+ * useGlobalStyles('.card', {
359
+ * padding: '2x',
360
+ * radius: '1r',
361
+ * fill: '#white',
362
+ * });
363
+ *
364
+ * return <div className="card">Content</div>;
365
+ * }
366
+ * ```
367
+ */
368
+ function useGlobalStyles(selector, styles, options) {
369
+ if (!styles) return;
370
+ if (!selector) {
371
+ console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
372
+ return;
373
+ }
374
+ const target = getStyleTarget();
375
+ if (target.mode === "client") {
376
+ const slotKey = options?.id ?? selector;
377
+ const stylesKey = JSON.stringify(styles);
378
+ const existing = clientGlobalEntries.get(slotKey);
379
+ if (existing && existing.stylesKey === stylesKey) return;
380
+ }
381
+ const resolvedStyles = resolveRecipes(styles);
382
+ const styleResults = renderStyles(resolvedStyles, selector);
383
+ if (styleResults.length === 0) return;
384
+ if (target.mode === "ssr") {
385
+ target.collector.collectInternals();
386
+ const css = formatGlobalRules(styleResults);
387
+ if (css) {
388
+ const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
389
+ target.collector.collectGlobalStyles(key, css);
390
+ }
391
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
392
+ return;
393
+ }
394
+ if (target.mode === "rsc") {
395
+ const css = formatGlobalRules(styleResults);
396
+ if (css) {
397
+ const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
398
+ pushRSCCSS(target.cache, key, css);
399
+ }
400
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
401
+ return;
402
+ }
403
+ const slotKey = options?.id ?? selector;
404
+ const existing = clientGlobalEntries.get(slotKey);
405
+ if (existing) existing.dispose();
406
+ const { dispose } = injectGlobal(styleResults, { root: options?.root });
407
+ clientGlobalEntries.set(slotKey, {
408
+ stylesKey: JSON.stringify(styles),
409
+ dispose
410
+ });
411
+ }
412
+ //#endregion
413
+ //#region src/utils/deps-equal.ts
414
+ /**
415
+ * Shallow comparison of two dependency arrays using Object.is semantics.
416
+ * Returns true when both arrays have the same length and every element
417
+ * at the same index is identical.
418
+ */
419
+ function depsEqual(a, b) {
420
+ if (a.length !== b.length) return false;
421
+ for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false;
422
+ return true;
423
+ }
424
+ //#endregion
425
+ //#region src/hooks/useRawCSS.ts
426
+ const clientEntries = /* @__PURE__ */ new Map();
427
+ const clientContentDedup = /* @__PURE__ */ new Set();
428
+ const factoryDepsCache$1 = /* @__PURE__ */ new Map();
429
+ /**
430
+ * Inject raw CSS text directly without parsing.
431
+ * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
432
+ *
433
+ * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
434
+ * with tasty's chunked style sheets.
435
+ *
436
+ * Works in all environments: client, SSR with collector, and React Server Components.
437
+ *
438
+ * Injected styles are permanent — they are not cleaned up on component unmount.
439
+ * Use the `id` option for update tracking when styles change over the
440
+ * component lifecycle.
441
+ *
442
+ * @example Static CSS string
443
+ * ```tsx
444
+ * function GlobalStyles() {
445
+ * useRawCSS(`
446
+ * body {
447
+ * margin: 0;
448
+ * padding: 0;
449
+ * font-family: sans-serif;
450
+ * }
451
+ * `);
452
+ *
453
+ * return null;
454
+ * }
455
+ * ```
456
+ *
457
+ * @example Factory function with dependencies
458
+ * ```tsx
459
+ * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
460
+ * useRawCSS(() => `
461
+ * :root {
462
+ * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
463
+ * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
464
+ * }
465
+ * `, [theme], { id: 'theme-vars' });
466
+ *
467
+ * return null;
468
+ * }
469
+ * ```
470
+ *
471
+ * @example With options
472
+ * ```tsx
473
+ * function ShadowStyles({ shadowRoot }) {
474
+ * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
475
+ * return null;
476
+ * }
477
+ * ```
478
+ */
479
+ function useRawCSS(cssOrFactory, depsOrOptions, options) {
480
+ const isFactory = typeof cssOrFactory === "function";
481
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
482
+ const opts = isFactory ? options : depsOrOptions;
483
+ const target = getStyleTarget();
484
+ if (isFactory && deps && opts?.id && target.mode === "client") {
485
+ const cachedDeps = factoryDepsCache$1.get(opts.id);
486
+ if (cachedDeps && depsEqual(cachedDeps, deps)) return;
487
+ }
488
+ const css = isFactory ? cssOrFactory() : cssOrFactory;
489
+ if (!css.trim()) return;
490
+ if (target.mode === "ssr") {
491
+ const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
492
+ target.collector.collectRawCSS(key, css);
493
+ return;
494
+ }
495
+ if (target.mode === "rsc") {
496
+ const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
497
+ pushRSCCSS(target.cache, key, css);
498
+ return;
499
+ }
500
+ const id = opts?.id;
501
+ if (id) {
502
+ const existing = clientEntries.get(id);
503
+ if (existing) {
504
+ if (existing.contentKey === css) return;
505
+ existing.dispose();
506
+ }
507
+ const { dispose } = injectRawCSS(css, opts);
508
+ clientEntries.set(id, {
509
+ contentKey: css,
510
+ dispose
511
+ });
512
+ if (deps) factoryDepsCache$1.set(id, deps);
513
+ } else {
514
+ const contentKey = hashString(css);
515
+ if (clientContentDedup.has(contentKey)) return;
516
+ clientContentDedup.add(contentKey);
517
+ injectRawCSS(css, opts);
518
+ }
519
+ }
520
+ //#endregion
521
+ //#region src/hooks/useKeyframes.ts
522
+ const clientContentToName$1 = /* @__PURE__ */ new Map();
523
+ const factoryDepsCache = /* @__PURE__ */ new Map();
524
+ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
525
+ const isFactory = typeof stepsOrFactory === "function";
526
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
527
+ const opts = isFactory ? options : depsOrOptions;
528
+ const target = getStyleTarget();
529
+ if (isFactory && deps && opts?.name && target.mode === "client") {
530
+ const cached = factoryDepsCache.get(opts.name);
531
+ if (cached && depsEqual(cached.deps, deps)) return cached.name;
532
+ }
533
+ const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
534
+ if (!steps || Object.keys(steps).length === 0) return "";
535
+ if (target.mode === "ssr") {
536
+ const actualName = target.collector.allocateKeyframeName(opts?.name);
537
+ const css = formatKeyframesCSS(actualName, steps);
538
+ target.collector.collectKeyframes(actualName, css);
539
+ return actualName;
540
+ }
541
+ if (target.mode === "rsc") {
542
+ const serializedContent = JSON.stringify(steps);
543
+ const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
544
+ const existingName = target.cache.generatedNames.get(key);
545
+ if (existingName) return existingName;
546
+ const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
547
+ const css = formatKeyframesCSS(actualName, steps);
548
+ pushRSCCSS(target.cache, key, css);
549
+ target.cache.generatedNames.set(key, actualName);
550
+ return actualName;
551
+ }
552
+ const serializedContent = JSON.stringify(steps);
553
+ const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
554
+ const cachedName = clientContentToName$1.get(cacheKey);
555
+ if (cachedName) return cachedName;
556
+ const name = keyframes(steps, {
557
+ name: opts?.name,
558
+ root: opts?.root
559
+ }).toString();
560
+ clientContentToName$1.set(cacheKey, name);
561
+ if (deps && opts?.name) factoryDepsCache.set(opts.name, {
562
+ deps,
563
+ name
564
+ });
565
+ return name;
566
+ }
567
+ //#endregion
568
+ //#region src/hooks/useProperty.ts
569
+ /**
570
+ * Register a CSS @property custom property.
571
+ * This enables advanced features like animating custom properties.
572
+ *
573
+ * Note: @property rules are global and persistent once defined.
574
+ * The function ensures the property is only registered once per root.
575
+ *
576
+ * Accepts tasty token syntax for the property name:
577
+ * - `$name` → defines `--name`
578
+ * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
579
+ * - `--name` → defines `--name` (legacy format)
580
+ *
581
+ * Works in all environments: client, SSR with collector, and React Server Components.
582
+ *
583
+ * @param name - The property token ($name, #name) or CSS property name (--name)
584
+ * @param options - Property configuration
585
+ *
586
+ * @example Basic property with token syntax
587
+ * ```tsx
588
+ * function Spinner() {
589
+ * useProperty('$rotation', {
590
+ * syntax: '<angle>',
591
+ * inherits: false,
592
+ * initialValue: '0deg',
593
+ * });
594
+ *
595
+ * return <div className="spinner" />;
596
+ * }
597
+ * ```
598
+ *
599
+ * @example Color property with token syntax (auto-sets syntax)
600
+ * ```tsx
601
+ * function MyComponent() {
602
+ * useProperty('#theme', {
603
+ * initialValue: 'red', // syntax: '<color>' is auto-set
604
+ * });
605
+ *
606
+ * // Now --theme-color can be animated with CSS transitions
607
+ * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
608
+ * }
609
+ * ```
610
+ *
611
+ * @example Legacy format (still supported)
612
+ * ```tsx
613
+ * function ResizableBox() {
614
+ * useProperty('--box-size', {
615
+ * syntax: '<length>',
616
+ * initialValue: '100px',
617
+ * });
618
+ *
619
+ * return <div style={{ width: 'var(--box-size)' }} />;
620
+ * }
621
+ * ```
622
+ */
623
+ function useProperty(name, options) {
624
+ if (!name) {
625
+ console.warn(`[Tasty] useProperty: property name is required`);
626
+ return;
627
+ }
628
+ const target = getStyleTarget();
629
+ if (target.mode === "ssr") {
630
+ target.collector.collectInternals();
631
+ const css = formatPropertyCSS(name, {
632
+ syntax: options?.syntax,
633
+ inherits: options?.inherits,
634
+ initialValue: options?.initialValue
635
+ });
636
+ if (css) target.collector.collectProperty(name, css);
637
+ return;
638
+ }
639
+ if (target.mode === "rsc") {
640
+ const css = formatPropertyCSS(name, {
641
+ syntax: options?.syntax,
642
+ inherits: options?.inherits,
643
+ initialValue: options?.initialValue
644
+ });
645
+ if (css) pushRSCCSS(target.cache, `__prop:${name}`, css);
646
+ return;
647
+ }
648
+ const injector = getGlobalInjector();
649
+ if (injector.isPropertyDefined(name, { root: options?.root })) return;
650
+ injector.property(name, {
651
+ syntax: options?.syntax,
652
+ inherits: options?.inherits,
653
+ initialValue: options?.initialValue,
654
+ root: options?.root
655
+ });
656
+ }
657
+ //#endregion
658
+ //#region src/hooks/useFontFace.ts
659
+ /**
660
+ * Inject CSS @font-face rules.
661
+ * Permanent — no cleanup on unmount. Deduplicates by content hash.
662
+ *
663
+ * Works in all environments: client, SSR with collector, and React Server Components.
664
+ *
665
+ * @param family - The font-family name
666
+ * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)
667
+ * @param options - Optional settings (e.g. Shadow DOM root)
668
+ *
669
+ * @example Single weight
670
+ * ```tsx
671
+ * function App() {
672
+ * useFontFace('Brand Sans', {
673
+ * src: 'url("/fonts/brand-sans.woff2") format("woff2")',
674
+ * fontWeight: '400 700',
675
+ * fontDisplay: 'swap',
676
+ * });
677
+ *
678
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
679
+ * }
680
+ * ```
681
+ *
682
+ * @example Multiple weights
683
+ * ```tsx
684
+ * function App() {
685
+ * useFontFace('Brand Sans', [
686
+ * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
687
+ * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
688
+ * ]);
689
+ *
690
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
691
+ * }
692
+ * ```
693
+ */
694
+ function useFontFace(family, input, options) {
695
+ if (!family) return;
696
+ const descriptors = Array.isArray(input) ? input : [input];
697
+ const target = getStyleTarget();
698
+ if (target.mode === "ssr") {
699
+ for (const desc of descriptors) {
700
+ const hash = fontFaceContentHash(family, desc);
701
+ const css = formatFontFaceRule(family, desc);
702
+ target.collector.collectFontFace(hash, css);
703
+ }
704
+ return;
705
+ }
706
+ if (target.mode === "rsc") {
707
+ for (const desc of descriptors) {
708
+ const hash = fontFaceContentHash(family, desc);
709
+ const css = formatFontFaceRule(family, desc);
710
+ pushRSCCSS(target.cache, `__ff:${hash}`, css);
711
+ }
712
+ return;
713
+ }
714
+ const injector = getGlobalInjector();
715
+ for (const desc of descriptors) injector.fontFace(family, desc, { root: options?.root });
716
+ }
717
+ //#endregion
718
+ //#region src/hooks/useCounterStyle.ts
719
+ let clientCounterStyleCounter = 0;
720
+ const clientContentToName = /* @__PURE__ */ new Map();
721
+ /**
722
+ * Inject a CSS @counter-style rule and return the generated name.
723
+ * Permanent — no cleanup on unmount. Deduplicates by name.
724
+ *
725
+ * Works in all environments: client, SSR with collector, and React Server Components.
726
+ *
727
+ * @example Basic usage
728
+ * ```tsx
729
+ * function EmojiList() {
730
+ * const styleName = useCounterStyle({
731
+ * system: 'cyclic',
732
+ * symbols: '"👍"',
733
+ * suffix: '" "',
734
+ * }, { name: 'thumbs' });
735
+ *
736
+ * return (
737
+ * <ol style={{ listStyleType: styleName }}>
738
+ * <li>First</li>
739
+ * <li>Second</li>
740
+ * </ol>
741
+ * );
742
+ * }
743
+ * ```
744
+ *
745
+ */
746
+ function useCounterStyle(descriptors, options) {
747
+ if (!descriptors || !descriptors.system) return "";
748
+ const target = getStyleTarget();
749
+ if (target.mode === "ssr") {
750
+ const actualName = target.collector.allocateCounterStyleName(options?.name);
751
+ const css = formatCounterStyleRule(actualName, descriptors);
752
+ target.collector.collectCounterStyle(actualName, css);
753
+ return actualName;
754
+ }
755
+ if (target.mode === "rsc") {
756
+ const serializedContent = JSON.stringify(descriptors);
757
+ const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
758
+ const existingName = target.cache.generatedNames.get(key);
759
+ if (existingName) return existingName;
760
+ const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
761
+ const css = formatCounterStyleRule(actualName, descriptors);
762
+ pushRSCCSS(target.cache, key, css);
763
+ target.cache.generatedNames.set(key, actualName);
764
+ return actualName;
765
+ }
766
+ const serializedContent = JSON.stringify(descriptors);
767
+ const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
768
+ const existingName = clientContentToName.get(cacheKey);
769
+ if (existingName) return existingName;
770
+ const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
771
+ clientContentToName.set(cacheKey, name);
772
+ getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
773
+ return name;
774
+ }
775
+ //#endregion
776
+ export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, ChunkSheetRegistry, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, categorizeStyleKeys, chunkSheetRegistry, cleanup, color, computeStyles, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, gc, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamePrefix, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
32
777
 
33
- export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, COMPUTE_FUNC_MAP, CONTAINER_STYLES, CUSTOM_UNITS, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STATE_OPERATORS, STATE_OPERATOR_LIST, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, allocateClassName, buildAtRuleContext, categorizeStyleKeys, cleanup, color, computeState, configure, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, extendStyles, extractStyles, filterBaseProps, filterMods, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getModSelector, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isAdvancedStateToken, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStateNotation, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, styleStateMapToStyleStateDataList, tasty, tastyDebug, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
778
+ //# sourceMappingURL=index.js.map