@tenphi/tasty 0.0.0-snapshot.b3fbcbb → 0.0.0-snapshot.b3fc70b

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 (313) hide show
  1. package/README.md +372 -233
  2. package/dist/async-storage-DKK-wTD4.js +44 -0
  3. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  4. package/dist/babel-DL7Q0O2U.d.ts +83 -0
  5. package/dist/collector-DBFlaFHJ.d.ts +145 -0
  6. package/dist/collector-DOlu2dYR.js +304 -0
  7. package/dist/collector-DOlu2dYR.js.map +1 -0
  8. package/dist/config-DabydZVP.js +12380 -0
  9. package/dist/config-DabydZVP.js.map +1 -0
  10. package/dist/config-Dy7mrJRI.d.ts +1335 -0
  11. package/dist/context-CA8YKeMn.js +24 -0
  12. package/dist/context-CA8YKeMn.js.map +1 -0
  13. package/dist/core/index.d.ts +5 -33
  14. package/dist/core/index.js +6 -26
  15. package/dist/core-J67jVh8p.js +1648 -0
  16. package/dist/core-J67jVh8p.js.map +1 -0
  17. package/dist/{zero/extractor.js → css-writer-Bc_r5yM9.js} +188 -13
  18. package/dist/css-writer-Bc_r5yM9.js.map +1 -0
  19. package/dist/format-global-rules-DklyaXv-.js +22 -0
  20. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  21. package/dist/format-rules-zO4YxFIy.js +130 -0
  22. package/dist/format-rules-zO4YxFIy.js.map +1 -0
  23. package/dist/hydrate-c3-p2Ma3.js +37 -0
  24. package/dist/hydrate-c3-p2Ma3.js.map +1 -0
  25. package/dist/index-Cgk4gQ6X.d.ts +1958 -0
  26. package/dist/index-Fqlx0GUY.d.ts +1541 -0
  27. package/dist/index.d.ts +5 -48
  28. package/dist/index.js +954 -32
  29. package/dist/index.js.map +1 -0
  30. package/dist/keyframes-Dzrxy46O.js +493 -0
  31. package/dist/keyframes-Dzrxy46O.js.map +1 -0
  32. package/dist/{utils/merge-styles.js → merge-styles-DmAa79gn.js} +4 -6
  33. package/dist/merge-styles-DmAa79gn.js.map +1 -0
  34. package/dist/{utils/merge-styles.d.ts → merge-styles-kJuFR7kV.d.ts} +3 -3
  35. package/dist/{utils/resolve-recipes.js → resolve-recipes-CdFJEWNQ.js} +5 -8
  36. package/dist/resolve-recipes-CdFJEWNQ.js.map +1 -0
  37. package/dist/ssr/astro-client.d.ts +1 -0
  38. package/dist/ssr/astro-client.js +19 -0
  39. package/dist/ssr/astro-client.js.map +1 -0
  40. package/dist/ssr/astro-middleware-static.d.ts +16 -0
  41. package/dist/ssr/astro-middleware-static.js +18 -0
  42. package/dist/ssr/astro-middleware-static.js.map +1 -0
  43. package/dist/ssr/astro-middleware.d.ts +17 -0
  44. package/dist/ssr/astro-middleware.js +19 -0
  45. package/dist/ssr/astro-middleware.js.map +1 -0
  46. package/dist/ssr/astro.d.ts +93 -0
  47. package/dist/ssr/astro.js +157 -0
  48. package/dist/ssr/astro.js.map +1 -0
  49. package/dist/ssr/index.d.ts +37 -0
  50. package/dist/ssr/index.js +10 -0
  51. package/dist/ssr/index.js.map +1 -0
  52. package/dist/ssr/next.d.ts +45 -0
  53. package/dist/ssr/next.js +74 -0
  54. package/dist/ssr/next.js.map +1 -0
  55. package/dist/static/index.d.ts +91 -5
  56. package/dist/static/index.js +49 -4
  57. package/dist/static/index.js.map +1 -0
  58. package/dist/static/inject.d.ts +5 -0
  59. package/dist/static/inject.js +17 -0
  60. package/dist/static/inject.js.map +1 -0
  61. package/dist/zero/babel.d.ts +2 -113
  62. package/dist/zero/babel.js +232 -42
  63. package/dist/zero/babel.js.map +1 -1
  64. package/dist/zero/index.d.ts +81 -3
  65. package/dist/zero/index.js +2 -4
  66. package/dist/zero/next.d.ts +56 -30
  67. package/dist/zero/next.js +106 -41
  68. package/dist/zero/next.js.map +1 -1
  69. package/docs/README.md +39 -0
  70. package/docs/adoption.md +323 -0
  71. package/docs/ai-agents.md +224 -0
  72. package/docs/comparison.md +448 -0
  73. package/docs/configuration.md +823 -0
  74. package/docs/debug.md +322 -0
  75. package/docs/design-system.md +455 -0
  76. package/docs/dsl.md +1021 -0
  77. package/docs/getting-started.md +238 -0
  78. package/docs/injector.md +620 -0
  79. package/docs/methodology.md +648 -0
  80. package/docs/migration-v3.md +285 -0
  81. package/docs/pipeline.md +741 -0
  82. package/docs/plugins.md +353 -0
  83. package/docs/react-api.md +681 -0
  84. package/docs/runtime-benchmarks.md +216 -0
  85. package/docs/ssr.md +451 -0
  86. package/docs/styles.md +645 -0
  87. package/docs/tasty-static.md +582 -0
  88. package/package.json +105 -45
  89. package/tasty.config.ts +6 -0
  90. package/dist/_virtual/_rolldown/runtime.js +0 -8
  91. package/dist/chunks/cacheKey.js +0 -70
  92. package/dist/chunks/cacheKey.js.map +0 -1
  93. package/dist/chunks/definitions.d.ts +0 -37
  94. package/dist/chunks/definitions.js +0 -260
  95. package/dist/chunks/definitions.js.map +0 -1
  96. package/dist/chunks/renderChunk.js +0 -61
  97. package/dist/chunks/renderChunk.js.map +0 -1
  98. package/dist/config.d.ts +0 -288
  99. package/dist/config.js +0 -403
  100. package/dist/config.js.map +0 -1
  101. package/dist/debug.d.ts +0 -204
  102. package/dist/debug.js +0 -733
  103. package/dist/debug.js.map +0 -1
  104. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  105. package/dist/hooks/useGlobalStyles.js +0 -56
  106. package/dist/hooks/useGlobalStyles.js.map +0 -1
  107. package/dist/hooks/useKeyframes.d.ts +0 -56
  108. package/dist/hooks/useKeyframes.js +0 -54
  109. package/dist/hooks/useKeyframes.js.map +0 -1
  110. package/dist/hooks/useProperty.d.ts +0 -79
  111. package/dist/hooks/useProperty.js +0 -91
  112. package/dist/hooks/useProperty.js.map +0 -1
  113. package/dist/hooks/useRawCSS.d.ts +0 -53
  114. package/dist/hooks/useRawCSS.js +0 -28
  115. package/dist/hooks/useRawCSS.js.map +0 -1
  116. package/dist/hooks/useStyles.d.ts +0 -40
  117. package/dist/hooks/useStyles.js +0 -169
  118. package/dist/hooks/useStyles.js.map +0 -1
  119. package/dist/injector/index.d.ts +0 -157
  120. package/dist/injector/index.js +0 -154
  121. package/dist/injector/index.js.map +0 -1
  122. package/dist/injector/injector.d.ts +0 -139
  123. package/dist/injector/injector.js +0 -426
  124. package/dist/injector/injector.js.map +0 -1
  125. package/dist/injector/sheet-manager.d.ts +0 -135
  126. package/dist/injector/sheet-manager.js +0 -728
  127. package/dist/injector/sheet-manager.js.map +0 -1
  128. package/dist/injector/types.d.ts +0 -144
  129. package/dist/keyframes/index.js +0 -206
  130. package/dist/keyframes/index.js.map +0 -1
  131. package/dist/parser/classify.js +0 -319
  132. package/dist/parser/classify.js.map +0 -1
  133. package/dist/parser/const.js +0 -33
  134. package/dist/parser/const.js.map +0 -1
  135. package/dist/parser/lru.js +0 -109
  136. package/dist/parser/lru.js.map +0 -1
  137. package/dist/parser/parser.d.ts +0 -25
  138. package/dist/parser/parser.js +0 -116
  139. package/dist/parser/parser.js.map +0 -1
  140. package/dist/parser/tokenizer.js +0 -69
  141. package/dist/parser/tokenizer.js.map +0 -1
  142. package/dist/parser/types.d.ts +0 -51
  143. package/dist/parser/types.js +0 -46
  144. package/dist/parser/types.js.map +0 -1
  145. package/dist/pipeline/conditions.d.ts +0 -134
  146. package/dist/pipeline/conditions.js +0 -406
  147. package/dist/pipeline/conditions.js.map +0 -1
  148. package/dist/pipeline/exclusive.js +0 -231
  149. package/dist/pipeline/exclusive.js.map +0 -1
  150. package/dist/pipeline/index.d.ts +0 -53
  151. package/dist/pipeline/index.js +0 -660
  152. package/dist/pipeline/index.js.map +0 -1
  153. package/dist/pipeline/materialize.js +0 -844
  154. package/dist/pipeline/materialize.js.map +0 -1
  155. package/dist/pipeline/parseStateKey.d.ts +0 -15
  156. package/dist/pipeline/parseStateKey.js +0 -438
  157. package/dist/pipeline/parseStateKey.js.map +0 -1
  158. package/dist/pipeline/simplify.js +0 -516
  159. package/dist/pipeline/simplify.js.map +0 -1
  160. package/dist/pipeline/warnings.js +0 -18
  161. package/dist/pipeline/warnings.js.map +0 -1
  162. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  163. package/dist/plugins/okhsl-plugin.js +0 -371
  164. package/dist/plugins/okhsl-plugin.js.map +0 -1
  165. package/dist/plugins/types.d.ts +0 -69
  166. package/dist/properties/index.js +0 -237
  167. package/dist/properties/index.js.map +0 -1
  168. package/dist/properties/property-type-resolver.d.ts +0 -24
  169. package/dist/properties/property-type-resolver.js +0 -79
  170. package/dist/properties/property-type-resolver.js.map +0 -1
  171. package/dist/states/index.d.ts +0 -49
  172. package/dist/states/index.js +0 -416
  173. package/dist/states/index.js.map +0 -1
  174. package/dist/static/tastyStatic.d.ts +0 -46
  175. package/dist/static/tastyStatic.js +0 -31
  176. package/dist/static/tastyStatic.js.map +0 -1
  177. package/dist/static/types.d.ts +0 -49
  178. package/dist/static/types.js +0 -24
  179. package/dist/static/types.js.map +0 -1
  180. package/dist/styles/align.d.ts +0 -15
  181. package/dist/styles/align.js +0 -14
  182. package/dist/styles/align.js.map +0 -1
  183. package/dist/styles/border.d.ts +0 -25
  184. package/dist/styles/border.js +0 -114
  185. package/dist/styles/border.js.map +0 -1
  186. package/dist/styles/color.d.ts +0 -14
  187. package/dist/styles/color.js +0 -23
  188. package/dist/styles/color.js.map +0 -1
  189. package/dist/styles/createStyle.js +0 -77
  190. package/dist/styles/createStyle.js.map +0 -1
  191. package/dist/styles/dimension.js +0 -97
  192. package/dist/styles/dimension.js.map +0 -1
  193. package/dist/styles/display.d.ts +0 -37
  194. package/dist/styles/display.js +0 -67
  195. package/dist/styles/display.js.map +0 -1
  196. package/dist/styles/fade.d.ts +0 -15
  197. package/dist/styles/fade.js +0 -58
  198. package/dist/styles/fade.js.map +0 -1
  199. package/dist/styles/fill.d.ts +0 -42
  200. package/dist/styles/fill.js +0 -52
  201. package/dist/styles/fill.js.map +0 -1
  202. package/dist/styles/flow.d.ts +0 -16
  203. package/dist/styles/flow.js +0 -12
  204. package/dist/styles/flow.js.map +0 -1
  205. package/dist/styles/gap.d.ts +0 -31
  206. package/dist/styles/gap.js +0 -37
  207. package/dist/styles/gap.js.map +0 -1
  208. package/dist/styles/height.d.ts +0 -17
  209. package/dist/styles/height.js +0 -20
  210. package/dist/styles/height.js.map +0 -1
  211. package/dist/styles/index.d.ts +0 -2
  212. package/dist/styles/index.js +0 -9
  213. package/dist/styles/index.js.map +0 -1
  214. package/dist/styles/inset.d.ts +0 -52
  215. package/dist/styles/inset.js +0 -150
  216. package/dist/styles/inset.js.map +0 -1
  217. package/dist/styles/justify.d.ts +0 -15
  218. package/dist/styles/justify.js +0 -14
  219. package/dist/styles/justify.js.map +0 -1
  220. package/dist/styles/list.d.ts +0 -16
  221. package/dist/styles/list.js +0 -98
  222. package/dist/styles/list.js.map +0 -1
  223. package/dist/styles/margin.d.ts +0 -24
  224. package/dist/styles/margin.js +0 -104
  225. package/dist/styles/margin.js.map +0 -1
  226. package/dist/styles/outline.d.ts +0 -29
  227. package/dist/styles/outline.js +0 -65
  228. package/dist/styles/outline.js.map +0 -1
  229. package/dist/styles/padding.d.ts +0 -24
  230. package/dist/styles/padding.js +0 -104
  231. package/dist/styles/padding.js.map +0 -1
  232. package/dist/styles/predefined.d.ts +0 -73
  233. package/dist/styles/predefined.js +0 -241
  234. package/dist/styles/predefined.js.map +0 -1
  235. package/dist/styles/preset.d.ts +0 -47
  236. package/dist/styles/preset.js +0 -126
  237. package/dist/styles/preset.js.map +0 -1
  238. package/dist/styles/radius.d.ts +0 -14
  239. package/dist/styles/radius.js +0 -51
  240. package/dist/styles/radius.js.map +0 -1
  241. package/dist/styles/scrollbar.d.ts +0 -21
  242. package/dist/styles/scrollbar.js +0 -112
  243. package/dist/styles/scrollbar.js.map +0 -1
  244. package/dist/styles/shadow.d.ts +0 -14
  245. package/dist/styles/shadow.js +0 -24
  246. package/dist/styles/shadow.js.map +0 -1
  247. package/dist/styles/styledScrollbar.d.ts +0 -47
  248. package/dist/styles/styledScrollbar.js +0 -38
  249. package/dist/styles/styledScrollbar.js.map +0 -1
  250. package/dist/styles/transition.d.ts +0 -14
  251. package/dist/styles/transition.js +0 -158
  252. package/dist/styles/transition.js.map +0 -1
  253. package/dist/styles/types.d.ts +0 -498
  254. package/dist/styles/width.d.ts +0 -17
  255. package/dist/styles/width.js +0 -20
  256. package/dist/styles/width.js.map +0 -1
  257. package/dist/tasty.d.ts +0 -982
  258. package/dist/tasty.js +0 -206
  259. package/dist/tasty.js.map +0 -1
  260. package/dist/tokens/typography.d.ts +0 -19
  261. package/dist/tokens/typography.js +0 -237
  262. package/dist/tokens/typography.js.map +0 -1
  263. package/dist/types.d.ts +0 -184
  264. package/dist/utils/cache-wrapper.js +0 -26
  265. package/dist/utils/cache-wrapper.js.map +0 -1
  266. package/dist/utils/case-converter.js +0 -8
  267. package/dist/utils/case-converter.js.map +0 -1
  268. package/dist/utils/colors.d.ts +0 -5
  269. package/dist/utils/colors.js +0 -9
  270. package/dist/utils/colors.js.map +0 -1
  271. package/dist/utils/css-types.d.ts +0 -7
  272. package/dist/utils/dotize.d.ts +0 -26
  273. package/dist/utils/dotize.js +0 -122
  274. package/dist/utils/dotize.js.map +0 -1
  275. package/dist/utils/filter-base-props.d.ts +0 -15
  276. package/dist/utils/filter-base-props.js +0 -45
  277. package/dist/utils/filter-base-props.js.map +0 -1
  278. package/dist/utils/get-display-name.d.ts +0 -7
  279. package/dist/utils/get-display-name.js +0 -10
  280. package/dist/utils/get-display-name.js.map +0 -1
  281. package/dist/utils/hsl-to-rgb.js +0 -38
  282. package/dist/utils/hsl-to-rgb.js.map +0 -1
  283. package/dist/utils/is-dev-env.js +0 -19
  284. package/dist/utils/is-dev-env.js.map +0 -1
  285. package/dist/utils/is-valid-element-type.js +0 -15
  286. package/dist/utils/is-valid-element-type.js.map +0 -1
  287. package/dist/utils/merge-styles.js.map +0 -1
  288. package/dist/utils/mod-attrs.d.ts +0 -8
  289. package/dist/utils/mod-attrs.js +0 -21
  290. package/dist/utils/mod-attrs.js.map +0 -1
  291. package/dist/utils/okhsl-to-rgb.js +0 -296
  292. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  293. package/dist/utils/process-tokens.d.ts +0 -31
  294. package/dist/utils/process-tokens.js +0 -171
  295. package/dist/utils/process-tokens.js.map +0 -1
  296. package/dist/utils/resolve-recipes.d.ts +0 -17
  297. package/dist/utils/resolve-recipes.js.map +0 -1
  298. package/dist/utils/string.js +0 -8
  299. package/dist/utils/string.js.map +0 -1
  300. package/dist/utils/styles.d.ts +0 -178
  301. package/dist/utils/styles.js +0 -751
  302. package/dist/utils/styles.js.map +0 -1
  303. package/dist/utils/typography.d.ts +0 -36
  304. package/dist/utils/typography.js +0 -53
  305. package/dist/utils/typography.js.map +0 -1
  306. package/dist/utils/warnings.d.ts +0 -16
  307. package/dist/utils/warnings.js +0 -16
  308. package/dist/utils/warnings.js.map +0 -1
  309. package/dist/zero/css-writer.d.ts +0 -45
  310. package/dist/zero/css-writer.js +0 -74
  311. package/dist/zero/css-writer.js.map +0 -1
  312. package/dist/zero/extractor.d.ts +0 -24
  313. package/dist/zero/extractor.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,33 +1,955 @@
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 { A as DIMENSION_STYLES, At as POSITION_CHUNK_STYLES, Bt as filterMods, C as baseStylePropsRegistry, Ct as propHandlerRegistry, D as BLOCK_STYLES, Dt as DISPLAY_CHUNK_STYLES, E as BLOCK_OUTER_STYLES, Et as DIMENSION_CHUNK_STYLES, F as TEXT_STYLES, Ft as parseFunctionName, G as setGlobalPredefinedStates, Gt as parseColor, Ht as getGlobalParser, It as registerFunctionPolyfill, J as formatCounterStyleRule, Jt as okhstFunction, K as StyleInjector, Kt as parseStyle, L as isSelector, M as INNER_STYLES, N as OUTER_STYLES, Nt as formatFunctionRule, O as COLOR_STYLES, Ot as FONT_CHUNK_STYLES, P as POSITION_STYLES, Q as formatFontFaceRule, Qt as createColorFunc, R as renderStyles, Rt as CUSTOM_UNITS, S as generateTypographyTokens, T as BLOCK_INNER_STYLES, Tt as CHUNK_NAMES, Ut as getGlobalPredefinedTokens, V as createStateParserContext, W as getGlobalPredefinedStates, Wt as normalizeColorTokenValue, Xt as okhslFunction, Yt as okhstPlugin, Z as fontFaceContentHash, Zt as okhslPlugin, _ as isConfigLocked, a as getGlobalCounterStyles, an as hexToRgb, c as getGlobalInjector, ct as hasPendingStyleWrites, dt as DEFAULT_NAME_PREFIX, en as StyleParser, et as SheetManager, f as getNamePrefix, ft as DEFAULT_ZERO_NAME_PREFIX, g as hasStylesGenerated, h as hasGlobalRecipes, ht as makeKeyframeName, in as getRgbValuesFromRgbaString, j as FLOW_STYLES, jt as STYLE_TO_CHUNK, k as CONTAINER_STYLES, kt as LAYOUT_CHUNK_STYLES, l as getGlobalKeyframes, lt as openBatchWindow, m as hasGlobalKeyframes, mt as makeCounterStyleName, n as getConfig, nt as defineHandler, o as getGlobalFontFaces, on as hslToRgbValues, ot as closeBatchWindow, p as getStyleEpoch, qt as stringifyStyles, rn as getNamedColorHex, rt as styleHandlers, s as getGlobalFunctions, sn as strToRgb, st as flushStyles, t as configure, u as getGlobalRecipes, ut as resetStyleBatch, v as isFunctionsPolyfillEnabled, vt as hashString, w as BASE_STYLES, wt as APPEARANCE_CHUNK_STYLES, x as resetConfig, y as isTestEnvironment, z as parseStateKey, zt as DIRECTIONS } from "./config-DabydZVP.js";
2
+ import { A as injector, C as getCSSText, D as inject, E as hasRecipe, F as resolveChunk, I as touch, L as ChunkSheetRegistry, M as keyframes, N as property, O as injectGlobal, P as releaseStyles, R as chunkSheetRegistry, S as gc, T as getRawCSSText, _ as createInjector, a as color, b as fontFace, c as hasKeys, d as collectAutoInferredPropertiesRSC, f as getStyleTarget, g as counterStyle, h as cleanup, i as _modAttrs, j as isPropertyDefined, k as injectRawCSS, l as formatKeyframesCSS, m as acquireStyles, n as processTokens, o as filterBaseProps, p as pushRSCCSS, r as dotize, s as computeStyles, t as tastyDebug, u as collectAutoInferredProperties, v as defineRecipe, w as getCSSTextForNode, x as func, y as destroy, z as resolveFunctionColor } from "./core-J67jVh8p.js";
3
+ import { l as categorizeStyleKeys } from "./keyframes-Dzrxy46O.js";
4
+ import { n as formatPropertyCSS } from "./format-rules-zO4YxFIy.js";
5
+ import { t as mergeStyles } from "./merge-styles-DmAa79gn.js";
6
+ import { t as resolveRecipes } from "./resolve-recipes-CdFJEWNQ.js";
7
+ import { t as getTastySSRContext } from "./context-CA8YKeMn.js";
8
+ import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
9
+ import { Fragment, createElement, forwardRef, useContext, useInsertionEffect } 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-valid-element-type.ts
18
+ /**
19
+ * Lightweight replacement for `react-is`'s isValidElementType.
20
+ * Detects string tags, function/class components, and React exotic types
21
+ * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.
22
+ */
23
+ function isValidElementType(value) {
24
+ if (typeof value === "string" || typeof value === "function") return true;
25
+ if (typeof value === "object" && value !== null) return typeof value.$$typeof === "symbol";
26
+ return false;
27
+ }
28
+ //#endregion
29
+ //#region src/hooks/useStyles.ts
30
+ /**
31
+ * Hook to generate CSS classes from Tasty styles.
32
+ * Thin wrapper around `computeStyles()` that adds React context-based
33
+ * SSR collector discovery for backward compatibility with TastyRegistry.
34
+ *
35
+ * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * function MyComponent() {
40
+ * const { className } = useStyles({
41
+ * padding: '2x',
42
+ * fill: '#purple',
43
+ * radius: '1r',
44
+ * });
45
+ *
46
+ * return <div className={className}>Styled content</div>;
47
+ * }
48
+ * ```
49
+ */
50
+ function useStyles(styles, options) {
51
+ const root = options?.root;
52
+ const result = computeStyles(styles, {
53
+ ssrCollector: useContext(getTastySSRContext()),
54
+ root,
55
+ managed: true
56
+ });
57
+ useStyleCommit(result.className, root);
58
+ return result;
59
+ }
60
+ /**
61
+ * Hold the styles this render resolved for as long as the component is mounted.
62
+ *
63
+ * Rendering only names the classes and records what they stand for; this is
64
+ * where they reach the sheet. `useInsertionEffect` is React's insertion phase —
65
+ * it runs after every render in the commit and before any layout effect, so the
66
+ * rules are in place before anything can measure them.
67
+ *
68
+ * The dependency is the class-name string itself, so an unchanged rerender —
69
+ * the overwhelmingly common case — costs one string comparison and nothing
70
+ * else. Because setup re-inserts whatever is missing, a class collected while
71
+ * this render was still pending simply comes back here.
72
+ */
73
+ function useStyleCommit(className, root) {
74
+ useInsertionEffect(() => {
75
+ if (!className) return;
76
+ acquireStyles(className, { root });
77
+ return () => releaseStyles(className, { root });
78
+ }, [className, root]);
79
+ }
80
+ //#endregion
81
+ //#region src/tasty.tsx
82
+ /**
83
+ * Whether this environment ever commits. Server renders (SSR and RSC) resolve
84
+ * class names and hand them to a collector; only a browser mounts them.
85
+ */
86
+ const CAN_COMMIT = typeof document !== "undefined";
87
+ /**
88
+ * Precalculated entries for performance optimization
89
+ */
90
+ const IS_PROPERTIES_ENTRIES = Object.entries({
91
+ isDisabled: "disabled",
92
+ isHidden: "hidden",
93
+ isChecked: "checked"
94
+ });
95
+ /**
96
+ * Helper function to handle is* properties consistently
97
+ * Transforms is* props to HTML attributes and adds corresponding data-* attributes
98
+ */
99
+ function handleIsProperties(props) {
100
+ for (const [isProperty, targetAttribute] of IS_PROPERTIES_ENTRIES) {
101
+ if (isProperty in props) {
102
+ props[targetAttribute] = props[isProperty];
103
+ delete props[isProperty];
104
+ }
105
+ const dataAttribute = `data-${targetAttribute}`;
106
+ if (!(dataAttribute in props) && props[targetAttribute]) props[dataAttribute] = "";
107
+ }
108
+ }
109
+ /**
110
+ * Creates a sub-element component for compound component patterns.
111
+ * Sub-elements are lightweight components with data-element attribute for CSS targeting.
112
+ */
113
+ function createSubElement(elementName, definition) {
114
+ const config = typeof definition === "string" ? { as: definition } : definition;
115
+ const tag = config.as ?? "div";
116
+ const defaultQa = config.qa;
117
+ const defaultQaVal = config.qaVal;
118
+ const SubElement = forwardRef((props, ref) => {
119
+ const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
120
+ let modDataAttrs;
121
+ if (mods) modDataAttrs = _modAttrs(mods);
122
+ const tokenStyle = tokens ? processTokens(tokens) : void 0;
123
+ let mergedStyle;
124
+ if (tokenStyle || style) mergedStyle = tokenStyle && style ? {
125
+ ...tokenStyle,
126
+ ...style
127
+ } : tokenStyle ?? style;
128
+ const elementProps = {
129
+ "data-element": elementName,
130
+ "data-qa": qa ?? defaultQa,
131
+ "data-qaval": qaVal ?? defaultQaVal,
132
+ ...modDataAttrs || {},
133
+ ...htmlProps,
134
+ className,
135
+ style: mergedStyle,
136
+ isDisabled,
137
+ isHidden,
138
+ isChecked,
139
+ ref
140
+ };
141
+ handleIsProperties(elementProps);
142
+ if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
143
+ if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
144
+ return createElement(tag, elementProps);
145
+ });
146
+ SubElement.displayName = `SubElement(${elementName})`;
147
+ return SubElement;
148
+ }
149
+ /**
150
+ * Pre-compute the mapping from prop name to token key at component-creation time.
151
+ * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.
152
+ * Object form: entries used as-is.
153
+ */
154
+ function buildTokenPropsMapping(def) {
155
+ if (Array.isArray(def)) return def.map((propName) => {
156
+ if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
157
+ return [propName, `$${propName}`];
158
+ });
159
+ return Object.entries(def);
160
+ }
161
+ function tasty(Component, options) {
162
+ if (isValidElementType(Component)) return tastyWrap(Component, options);
163
+ return tastyElement(Component);
164
+ }
165
+ function tastyWrap(Component, options) {
166
+ const { as: extendTag, element: extendElement, styleProps: _styleProps, modProps: _modProps, tokenProps: _tokenProps, variants: _variants, elements: _elements, ...defaultProps } = options ?? {};
167
+ const propsWithStyles = ["styles"].concat(Object.keys(defaultProps).filter((prop) => prop.endsWith("Styles")));
168
+ const _WrappedComponent = forwardRef((props, ref) => {
169
+ const { as, element, ...restProps } = props;
170
+ const mergedStylesMap = propsWithStyles.reduce((map, prop) => {
171
+ const restValue = restProps[prop];
172
+ const defaultValue = defaultProps[prop];
173
+ if (restValue != null && defaultValue != null) map[prop] = mergeStyles(defaultValue, restValue);
174
+ else map[prop] = restValue ?? defaultValue;
175
+ return map;
176
+ }, {});
177
+ return createElement(Component, {
178
+ ...defaultProps,
179
+ ...restProps,
180
+ ...mergedStylesMap,
181
+ as: as ?? extendTag,
182
+ element: element || extendElement,
183
+ ref
184
+ });
185
+ });
186
+ _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
187
+ return _WrappedComponent;
188
+ }
189
+ function tastyElement(tastyOptions) {
190
+ const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
191
+ let variantStylesMap;
192
+ if (variants) {
193
+ let baseStyles = defaultStyles;
194
+ let extensionStyles;
195
+ if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
196
+ if (isSelector(key)) continue;
197
+ const value = defaultStyles[key];
198
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
199
+ if (!extensionStyles) {
200
+ baseStyles = { ...defaultStyles };
201
+ extensionStyles = {};
202
+ }
203
+ extensionStyles[key] = value;
204
+ delete baseStyles[key];
205
+ }
206
+ }
207
+ variantStylesMap = Object.entries(variants).reduce((map, [variant, variantStyles]) => {
208
+ map[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
209
+ return map;
210
+ }, {});
211
+ if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
212
+ }
213
+ const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps ?? {};
214
+ const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
215
+ let propsToCheck = ownPropsToCheck;
216
+ let propsToCheckVersion = -1;
217
+ const modPropsKeys = modPropsDef ? Array.isArray(modPropsDef) ? modPropsDef : Object.keys(modPropsDef) : void 0;
218
+ const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
219
+ const classNameCache = /* @__PURE__ */ new Map();
220
+ const STABLE_STYLES_MANAGED = {
221
+ stableStyles: true,
222
+ managed: true
223
+ };
224
+ const MANAGED = { managed: true };
225
+ const _TastyComponent = forwardRef((incomingProps, ref) => {
226
+ const applyPropHandlers = propHandlerRegistry.apply;
227
+ const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
228
+ let styles = rawStyles;
229
+ let propStyles = null;
230
+ if (propsToCheckVersion !== baseStylePropsRegistry.version) {
231
+ const promoted = baseStylePropsRegistry.list;
232
+ propsToCheck = promoted.length === 0 ? ownPropsToCheck : ownPropsToCheck.concat(promoted);
233
+ propsToCheckVersion = baseStylePropsRegistry.version;
234
+ }
235
+ for (const prop of propsToCheck) {
236
+ const key = prop;
237
+ if (key in otherProps) {
238
+ if (!propStyles) propStyles = {};
239
+ const value = otherProps[key];
240
+ propStyles[key] = value;
241
+ delete otherProps[key];
242
+ }
243
+ }
244
+ if (!styles || styles && !hasKeys(styles)) styles = void 0;
245
+ let propMods;
246
+ if (modPropsKeys) {
247
+ for (const key of modPropsKeys) if (key in otherProps) {
248
+ if (!propMods) propMods = {};
249
+ propMods[key] = otherProps[key];
250
+ delete otherProps[key];
251
+ }
252
+ }
253
+ let propTokens;
254
+ if (tokenPropsMapping) {
255
+ for (const [propName, tokenKey] of tokenPropsMapping) if (propName in otherProps) {
256
+ if (!propTokens) propTokens = {};
257
+ propTokens[tokenKey] = otherProps[propName];
258
+ delete otherProps[propName];
259
+ }
260
+ }
261
+ const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
262
+ const hasInstanceStyles = styles && hasKeys(styles);
263
+ const hasPropStyles = propStyles && hasKeys(propStyles);
264
+ const allStyles = hasInstanceStyles || hasPropStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
265
+ const useFactoryCache = typeof document !== "undefined";
266
+ const cached = useFactoryCache && allStyles === baseStyles ? classNameCache.get(allStyles) : void 0;
267
+ let stylesResult;
268
+ if (cached && cached[1] === getStyleEpoch()) stylesResult = { className: cached[0] };
269
+ else {
270
+ stylesResult = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES_MANAGED : MANAGED);
271
+ if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, [stylesResult.className, getStyleEpoch()]);
272
+ }
273
+ if (CAN_COMMIT) useStyleCommit(stylesResult.className);
274
+ let mergedTokens;
275
+ if (defaultTokens || tokens || propTokens) if (!defaultTokens && !propTokens) mergedTokens = tokens;
276
+ else if (!tokens && !propTokens) mergedTokens = defaultTokens;
277
+ else mergedTokens = {
278
+ ...defaultTokens,
279
+ ...tokens,
280
+ ...propTokens
281
+ };
282
+ const processedTokenStyle = processTokens(mergedTokens);
283
+ let mergedStyle;
284
+ if (processedTokenStyle || style) if (!processedTokenStyle) mergedStyle = style;
285
+ else if (!style) mergedStyle = processedTokenStyle;
286
+ else mergedStyle = {
287
+ ...processedTokenStyle,
288
+ ...style
289
+ };
290
+ const mergedMods = propMods ? {
291
+ ...mods,
292
+ ...propMods
293
+ } : mods;
294
+ let modDataAttrs;
295
+ if (mergedMods) modDataAttrs = _modAttrs(mergedMods);
296
+ const finalClassName = [userClassName || "", stylesResult.className].filter(Boolean).join(" ");
297
+ const elementProps = {
298
+ "data-element": element || defaultElement,
299
+ "data-qa": qa || defaultQa,
300
+ "data-qaval": qaVal || defaultQaVal,
301
+ "data-theme": theme,
302
+ ...otherDefaultProps,
303
+ ...modDataAttrs || {},
304
+ ...otherProps,
305
+ className: finalClassName,
306
+ style: mergedStyle,
307
+ ref
308
+ };
309
+ handleIsProperties(elementProps);
310
+ if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
311
+ const el = createElement(as ?? originalAs, elementProps);
312
+ if (stylesResult.css) {
313
+ const nonce = getConfig().nonce;
314
+ return createElement(Fragment, null, createElement("style", {
315
+ "data-tasty-rsc": "",
316
+ nonce,
317
+ dangerouslySetInnerHTML: { __html: stylesResult.css }
318
+ }), el);
319
+ }
320
+ return el;
321
+ });
322
+ _TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
323
+ if (elements) {
324
+ const subElements = Object.entries(elements).reduce((acc, [name, definition]) => {
325
+ acc[name] = createSubElement(name, definition);
326
+ return acc;
327
+ }, {});
328
+ return Object.assign(_TastyComponent, subElements);
329
+ }
330
+ return _TastyComponent;
331
+ }
332
+ const Element = tasty({});
333
+ //#endregion
334
+ //#region src/utils/client-state.ts
335
+ /**
336
+ * Build a per-(injector, root) client state cache for the standalone style
337
+ * functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useCounterStyle`).
338
+ *
339
+ * Two levels, both weak:
340
+ *
341
+ * - **injector** — `configure()` replaces the global injector, and every dispose
342
+ * handle and generated name we cache belongs to the one that produced it.
343
+ * Keying by injector makes stale state fall away with it, instead of letting
344
+ * change-detection keys suppress re-injection into the new sheets.
345
+ * - **root** — the same selector or slot name can be used in several shadow
346
+ * roots, and each holds its own injection.
347
+ */
348
+ function createClientState(create) {
349
+ const byInjector = /* @__PURE__ */ new WeakMap();
350
+ return (root) => {
351
+ const injector = getGlobalInjector();
352
+ let byRoot = byInjector.get(injector);
353
+ if (!byRoot) {
354
+ byRoot = /* @__PURE__ */ new WeakMap();
355
+ byInjector.set(injector, byRoot);
356
+ }
357
+ let state = byRoot.get(root);
358
+ if (!state) {
359
+ state = create();
360
+ byRoot.set(root, state);
361
+ }
362
+ return state;
363
+ };
364
+ }
365
+ //#endregion
366
+ //#region src/hooks/useGlobalStyles.ts
367
+ const getClientGlobalSlots = createClientState(() => /* @__PURE__ */ new Map());
368
+ const noop = () => {};
369
+ /**
370
+ * Inject global styles for a given selector.
371
+ * Useful for styling elements by selector without generating classNames.
372
+ *
373
+ * SSR-aware: when a ServerStyleCollector is available, CSS is collected
374
+ * during the render phase instead of being injected into the DOM.
375
+ *
376
+ * Works in all environments: client, SSR with collector, and React Server Components.
377
+ *
378
+ * Injected styles are permanent — they are not cleaned up on component unmount.
379
+ * Use the `id` option for update tracking when styles change over the
380
+ * component lifecycle.
381
+ *
382
+ * Update tracking is per-slot and per-root: a slot (`id`, or the selector when
383
+ * no `id` is given) holds exactly one injection per `root`. Changing the styles
384
+ * replaces it; rendering styles that produce no CSS clears it.
385
+ *
386
+ * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
387
+ * @param styles - Tasty styles object
388
+ * @param options - Optional settings including `id` for update tracking
389
+ *
390
+ * @example
391
+ * ```tsx
392
+ * function MyComponent() {
393
+ * useGlobalStyles('.card', {
394
+ * padding: '2x',
395
+ * radius: '1r',
396
+ * fill: '#white',
397
+ * });
398
+ *
399
+ * return <div className="card">Content</div>;
400
+ * }
401
+ * ```
402
+ */
403
+ function useGlobalStyles(selector, styles, options) {
404
+ if (!styles) return;
405
+ if (!selector) {
406
+ console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
407
+ return;
408
+ }
409
+ const target = getStyleTarget();
410
+ const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
411
+ const slotKey = options?.id ?? selector;
412
+ const stylesKey = slots ? JSON.stringify(styles) : "";
413
+ const existing = slots?.get(slotKey);
414
+ if (existing && existing.stylesKey === stylesKey) return;
415
+ const resolvedStyles = resolveRecipes(styles);
416
+ const styleResults = renderStyles(resolvedStyles, selector);
417
+ if (styleResults.length === 0) {
418
+ if (slots) {
419
+ existing?.dispose();
420
+ slots.set(slotKey, {
421
+ stylesKey,
422
+ dispose: noop
423
+ });
424
+ }
425
+ return;
426
+ }
427
+ if (target.mode === "ssr") {
428
+ target.collector.collectInternals();
429
+ const css = formatGlobalRules(styleResults);
430
+ if (css) {
431
+ const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
432
+ target.collector.collectGlobalStyles(key, css, options?.id != null);
433
+ }
434
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
435
+ return;
436
+ }
437
+ if (target.mode === "rsc") {
438
+ const css = formatGlobalRules(styleResults);
439
+ if (css) {
440
+ const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
441
+ pushRSCCSS(target.cache, key, css, options?.id != null);
442
+ }
443
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
444
+ return;
445
+ }
446
+ if (slots) {
447
+ existing?.dispose();
448
+ const { dispose } = injectGlobal(styleResults, { root: options?.root });
449
+ slots.set(slotKey, {
450
+ stylesKey,
451
+ dispose
452
+ });
453
+ }
454
+ }
455
+ //#endregion
456
+ //#region src/utils/deps-equal.ts
457
+ /**
458
+ * Shallow comparison of two dependency arrays using Object.is semantics.
459
+ * Returns true when both arrays have the same length and every element
460
+ * at the same index is identical.
461
+ */
462
+ function depsEqual(a, b) {
463
+ if (a.length !== b.length) return false;
464
+ for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false;
465
+ return true;
466
+ }
467
+ //#endregion
468
+ //#region src/hooks/useRawCSS.ts
469
+ const getClientState$1 = createClientState(() => ({
470
+ entries: /* @__PURE__ */ new Map(),
471
+ contentDedup: /* @__PURE__ */ new Set(),
472
+ factoryDeps: /* @__PURE__ */ new Map()
473
+ }));
474
+ /**
475
+ * Inject raw CSS text directly without parsing.
476
+ * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
477
+ *
478
+ * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
479
+ * with tasty's chunked style sheets.
480
+ *
481
+ * Works in all environments: client, SSR with collector, and React Server Components.
482
+ *
483
+ * Injected styles are permanent — they are not cleaned up on component unmount.
484
+ * Use the `id` option for update tracking when styles change over the
485
+ * component lifecycle.
486
+ *
487
+ * @example Static CSS string
488
+ * ```tsx
489
+ * function GlobalStyles() {
490
+ * useRawCSS(`
491
+ * body {
492
+ * margin: 0;
493
+ * padding: 0;
494
+ * font-family: sans-serif;
495
+ * }
496
+ * `);
497
+ *
498
+ * return null;
499
+ * }
500
+ * ```
501
+ *
502
+ * @example Factory function with dependencies
503
+ * ```tsx
504
+ * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
505
+ * useRawCSS(() => `
506
+ * :root {
507
+ * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
508
+ * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
509
+ * }
510
+ * `, [theme], { id: 'theme-vars' });
511
+ *
512
+ * return null;
513
+ * }
514
+ * ```
515
+ *
516
+ * @example With options
517
+ * ```tsx
518
+ * function ShadowStyles({ shadowRoot }) {
519
+ * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
520
+ * return null;
521
+ * }
522
+ * ```
523
+ */
524
+ function useRawCSS(cssOrFactory, depsOrOptions, options) {
525
+ const isFactory = typeof cssOrFactory === "function";
526
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
527
+ const opts = isFactory ? options : depsOrOptions;
528
+ const target = getStyleTarget();
529
+ const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
530
+ if (isFactory && deps && opts?.id && state) {
531
+ const cachedDeps = state.factoryDeps.get(opts.id);
532
+ if (cachedDeps && depsEqual(cachedDeps, deps)) return;
533
+ }
534
+ const css = isFactory ? cssOrFactory() : cssOrFactory;
535
+ if (!css.trim()) return;
536
+ if (target.mode === "ssr") {
537
+ const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
538
+ target.collector.collectRawCSS(key, css, opts?.id != null);
539
+ return;
540
+ }
541
+ if (target.mode === "rsc") {
542
+ const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
543
+ pushRSCCSS(target.cache, key, css, opts?.id != null);
544
+ return;
545
+ }
546
+ if (!state) return;
547
+ const id = opts?.id;
548
+ if (id) {
549
+ const existing = state.entries.get(id);
550
+ if (existing) {
551
+ if (existing.contentKey === css) return;
552
+ existing.dispose();
553
+ }
554
+ const { dispose } = injectRawCSS(css, opts);
555
+ state.entries.set(id, {
556
+ contentKey: css,
557
+ dispose
558
+ });
559
+ if (deps) state.factoryDeps.set(id, deps);
560
+ } else {
561
+ const contentKey = hashString(css);
562
+ if (state.contentDedup.has(contentKey)) return;
563
+ state.contentDedup.add(contentKey);
564
+ injectRawCSS(css, opts);
565
+ }
566
+ }
567
+ //#endregion
568
+ //#region src/hooks/useKeyframes.ts
569
+ const getClientState = createClientState(() => ({
570
+ contentToName: /* @__PURE__ */ new Map(),
571
+ namedSlots: /* @__PURE__ */ new Map(),
572
+ factoryDeps: /* @__PURE__ */ new Map()
573
+ }));
574
+ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
575
+ const isFactory = typeof stepsOrFactory === "function";
576
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
577
+ const opts = isFactory ? options : depsOrOptions;
578
+ const target = getStyleTarget();
579
+ const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
580
+ if (isFactory && deps && opts?.name && clientState) {
581
+ const cached = clientState.factoryDeps.get(opts.name);
582
+ if (cached && depsEqual(cached.deps, deps)) return cached.name;
583
+ }
584
+ const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
585
+ if (!steps || Object.keys(steps).length === 0) return "";
586
+ if (target.mode === "ssr") {
587
+ const actualName = target.collector.allocateKeyframeName(opts?.name);
588
+ const css = formatKeyframesCSS(actualName, steps);
589
+ target.collector.collectKeyframes(actualName, css);
590
+ return actualName;
591
+ }
592
+ if (target.mode === "rsc") {
593
+ const serializedContent = JSON.stringify(steps);
594
+ const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
595
+ const existingName = target.cache.generatedNames.get(key);
596
+ if (existingName) return existingName;
597
+ const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
598
+ const css = formatKeyframesCSS(actualName, steps);
599
+ pushRSCCSS(target.cache, key, css);
600
+ target.cache.generatedNames.set(key, actualName);
601
+ return actualName;
602
+ }
603
+ const state = clientState ?? getClientState(opts?.root ?? document);
604
+ const serializedContent = JSON.stringify(steps);
605
+ const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
606
+ const cachedName = state.contentToName.get(cacheKey);
607
+ if (cachedName) return cachedName;
608
+ const providedName = opts?.name;
609
+ if (providedName) {
610
+ const slot = state.namedSlots.get(providedName);
611
+ if (slot && slot.cacheKey !== cacheKey) {
612
+ slot.dispose();
613
+ state.contentToName.delete(slot.cacheKey);
614
+ state.namedSlots.delete(providedName);
615
+ }
616
+ }
617
+ const result = keyframes(steps, {
618
+ name: providedName,
619
+ root: opts?.root
620
+ });
621
+ const name = result.toString();
622
+ state.contentToName.set(cacheKey, name);
623
+ if (providedName) {
624
+ state.namedSlots.set(providedName, {
625
+ cacheKey,
626
+ dispose: result.dispose
627
+ });
628
+ if (deps) state.factoryDeps.set(providedName, {
629
+ deps,
630
+ name
631
+ });
632
+ }
633
+ return name;
634
+ }
635
+ //#endregion
636
+ //#region src/hooks/useProperty.ts
637
+ /**
638
+ * Register a CSS @property custom property.
639
+ * This enables advanced features like animating custom properties.
640
+ *
641
+ * Note: @property rules are global and persistent once defined.
642
+ * The function ensures the property is only registered once per root.
643
+ *
644
+ * Accepts tasty token syntax for the property name:
645
+ * - `$name` → defines `--name`
646
+ * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
647
+ * - `--name` → defines `--name` (legacy format)
648
+ *
649
+ * Works in all environments: client, SSR with collector, and React Server Components.
650
+ *
651
+ * @param name - The property token ($name, #name) or CSS property name (--name)
652
+ * @param options - Property configuration
653
+ *
654
+ * @example Basic property with token syntax
655
+ * ```tsx
656
+ * function Spinner() {
657
+ * useProperty('$rotation', {
658
+ * syntax: '<angle>',
659
+ * inherits: false,
660
+ * initialValue: '0deg',
661
+ * });
662
+ *
663
+ * return <div className="spinner" />;
664
+ * }
665
+ * ```
666
+ *
667
+ * @example Color property with token syntax (auto-sets syntax)
668
+ * ```tsx
669
+ * function MyComponent() {
670
+ * useProperty('#theme', {
671
+ * initialValue: 'red', // syntax: '<color>' is auto-set
672
+ * });
673
+ *
674
+ * // Now --theme-color can be animated with CSS transitions
675
+ * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
676
+ * }
677
+ * ```
678
+ *
679
+ * @example Legacy format (still supported)
680
+ * ```tsx
681
+ * function ResizableBox() {
682
+ * useProperty('--box-size', {
683
+ * syntax: '<length>',
684
+ * initialValue: '100px',
685
+ * });
686
+ *
687
+ * return <div style={{ width: 'var(--box-size)' }} />;
688
+ * }
689
+ * ```
690
+ */
691
+ function useProperty(name, options) {
692
+ if (!name) {
693
+ console.warn(`[Tasty] useProperty: property name is required`);
694
+ return;
695
+ }
696
+ const target = getStyleTarget();
697
+ if (target.mode === "ssr") {
698
+ target.collector.collectInternals();
699
+ const css = formatPropertyCSS(name, {
700
+ syntax: options?.syntax,
701
+ inherits: options?.inherits,
702
+ initialValue: options?.initialValue
703
+ });
704
+ if (css) target.collector.collectProperty(name, css);
705
+ return;
706
+ }
707
+ if (target.mode === "rsc") {
708
+ const css = formatPropertyCSS(name, {
709
+ syntax: options?.syntax,
710
+ inherits: options?.inherits,
711
+ initialValue: options?.initialValue
712
+ });
713
+ if (css) pushRSCCSS(target.cache, `__prop:${name}`, css);
714
+ return;
715
+ }
716
+ const injector = getGlobalInjector();
717
+ if (injector.isPropertyDefined(name, { root: options?.root })) return;
718
+ injector.property(name, {
719
+ syntax: options?.syntax,
720
+ inherits: options?.inherits,
721
+ initialValue: options?.initialValue,
722
+ root: options?.root
723
+ });
724
+ }
725
+ //#endregion
726
+ //#region src/hooks/useFontFace.ts
727
+ /**
728
+ * Inject CSS @font-face rules.
729
+ * Permanent — no cleanup on unmount. Deduplicates by content hash.
730
+ *
731
+ * Works in all environments: client, SSR with collector, and React Server Components.
732
+ *
733
+ * @param family - The font-family name
734
+ * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)
735
+ * @param options - Optional settings (e.g. Shadow DOM root)
736
+ *
737
+ * @example Single weight
738
+ * ```tsx
739
+ * function App() {
740
+ * useFontFace('Brand Sans', {
741
+ * src: 'url("/fonts/brand-sans.woff2") format("woff2")',
742
+ * fontWeight: '400 700',
743
+ * fontDisplay: 'swap',
744
+ * });
745
+ *
746
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
747
+ * }
748
+ * ```
749
+ *
750
+ * @example Multiple weights
751
+ * ```tsx
752
+ * function App() {
753
+ * useFontFace('Brand Sans', [
754
+ * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
755
+ * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
756
+ * ]);
757
+ *
758
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
759
+ * }
760
+ * ```
761
+ */
762
+ function useFontFace(family, input, options) {
763
+ if (!family) return;
764
+ const descriptors = Array.isArray(input) ? input : [input];
765
+ const target = getStyleTarget();
766
+ if (target.mode === "ssr") {
767
+ for (const desc of descriptors) {
768
+ const hash = fontFaceContentHash(family, desc);
769
+ const css = formatFontFaceRule(family, desc);
770
+ target.collector.collectFontFace(hash, css);
771
+ }
772
+ return;
773
+ }
774
+ if (target.mode === "rsc") {
775
+ for (const desc of descriptors) {
776
+ const hash = fontFaceContentHash(family, desc);
777
+ const css = formatFontFaceRule(family, desc);
778
+ pushRSCCSS(target.cache, `__ff:${hash}`, css);
779
+ }
780
+ return;
781
+ }
782
+ const injector = getGlobalInjector();
783
+ for (const desc of descriptors) injector.fontFace(family, desc, { root: options?.root });
784
+ }
785
+ //#endregion
786
+ //#region src/hooks/useCounterStyle.ts
787
+ let clientCounterStyleCounter = 0;
788
+ const getClientContentToName = createClientState(() => /* @__PURE__ */ new Map());
789
+ /**
790
+ * Inject a CSS @counter-style rule and return the generated name.
791
+ * Permanent — no cleanup on unmount. Deduplicates by name.
792
+ *
793
+ * Works in all environments: client, SSR with collector, and React Server Components.
794
+ *
795
+ * @example Basic usage
796
+ * ```tsx
797
+ * function EmojiList() {
798
+ * const styleName = useCounterStyle({
799
+ * system: 'cyclic',
800
+ * symbols: '"👍"',
801
+ * suffix: '" "',
802
+ * }, { name: 'thumbs' });
803
+ *
804
+ * return (
805
+ * <ol style={{ listStyleType: styleName }}>
806
+ * <li>First</li>
807
+ * <li>Second</li>
808
+ * </ol>
809
+ * );
810
+ * }
811
+ * ```
812
+ *
813
+ */
814
+ function useCounterStyle(descriptors, options) {
815
+ if (!descriptors || !descriptors.system) return "";
816
+ const target = getStyleTarget();
817
+ if (target.mode === "ssr") {
818
+ const actualName = target.collector.allocateCounterStyleName(options?.name);
819
+ const css = formatCounterStyleRule(actualName, descriptors);
820
+ target.collector.collectCounterStyle(actualName, css);
821
+ return actualName;
822
+ }
823
+ if (target.mode === "rsc") {
824
+ const serializedContent = JSON.stringify(descriptors);
825
+ const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
826
+ const existingName = target.cache.generatedNames.get(key);
827
+ if (existingName) return existingName;
828
+ const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
829
+ const css = formatCounterStyleRule(actualName, descriptors);
830
+ pushRSCCSS(target.cache, key, css);
831
+ target.cache.generatedNames.set(key, actualName);
832
+ return actualName;
833
+ }
834
+ const contentToName = getClientContentToName(options?.root ?? document);
835
+ const serializedContent = JSON.stringify(descriptors);
836
+ const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
837
+ const existingName = contentToName.get(cacheKey);
838
+ if (existingName) return existingName;
839
+ const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
840
+ contentToName.set(cacheKey, name);
841
+ getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
842
+ return name;
843
+ }
844
+ //#endregion
845
+ //#region src/hooks/useFunction.ts
846
+ /**
847
+ * Register a CSS @function (custom function).
848
+ *
849
+ * @function rules are global and persistent once defined. The hook ensures the
850
+ * function is only registered once per root (deduplicated by function name).
851
+ *
852
+ * Accepts tasty token syntax for the function name:
853
+ * - `$$name` → defines `--name` (matches the call site `$$name(...)`)
854
+ * - `$name` / `--name` → also accepted
855
+ *
856
+ * Works in all environments: client, SSR with collector, and React Server Components.
857
+ *
858
+ * @param name - The function name token (`$$name`, `$name`, or `--name`)
859
+ * @param definition - Function definition (args, returns, result, local vars)
860
+ *
861
+ * Call the function through the Tasty DSL, not a raw `style` prop: an inline
862
+ * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never
863
+ * expanded and `polyfills.functions` cannot rewrite it either.
864
+ *
865
+ * @example
866
+ * ```tsx
867
+ * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });
868
+ *
869
+ * function Layout() {
870
+ * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
871
+ * return <Box />;
872
+ * }
873
+ * ```
874
+ */
875
+ function useFunction(name, definition, options) {
876
+ if (!name) {
877
+ console.warn(`[Tasty] useFunction: function name is required`);
878
+ return;
879
+ }
880
+ if (isFunctionsPolyfillEnabled()) {
881
+ registerFunctionPolyfill(name, definition);
882
+ return;
883
+ }
884
+ const target = getStyleTarget();
885
+ if (target.mode === "ssr") {
886
+ target.collector.collectInternals();
887
+ const css = formatFunctionRule(name, definition);
888
+ if (css) target.collector.collectFunction(parseFunctionName(name), css);
889
+ return;
890
+ }
891
+ if (target.mode === "rsc") {
892
+ const css = formatFunctionRule(name, definition);
893
+ if (css) pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);
894
+ return;
895
+ }
896
+ getGlobalInjector().func(name, definition, { root: options?.root });
897
+ }
898
+ //#endregion
899
+ //#region src/batch-provider.tsx
900
+ /**
901
+ * Opens a *batch window* for the commit it renders in, so `batchInjection`
902
+ * can defer stylesheet writes without ever letting a layout effect measure an
903
+ * unstyled element.
904
+ *
905
+ * Every `insertRule()` on a live sheet invalidates style for that sheet's
906
+ * scope. When components inject during React's render phase while others read
907
+ * layout in the same pass, the two interleave and the browser recalculates
908
+ * style between every injection. Batching collapses that into one invalidation
909
+ * per flush — but only if the flush happens before anything can measure.
910
+ *
911
+ * ```
912
+ * provider renders -> window OPEN
913
+ * children render -> injections queued
914
+ * provider insertionEffect -> FLUSH, window CLOSED
915
+ * layout effects run -> rules are in the sheet
916
+ * ```
917
+ *
918
+ * `useInsertionEffect` runs in React's mutation phase, after every render in
919
+ * the commit and before any `useLayoutEffect` — which is exactly why React
920
+ * added it for CSS-in-JS libraries. Effects fire child-first, so this
921
+ * provider's runs after every descendant's and still before all layout
922
+ * effects.
923
+ *
924
+ * A commit that does not re-render this provider gets no window, and those
925
+ * injections are written synchronously instead. That is the point: turning
926
+ * `batchInjection: true` on can only ever make injection cheaper, never make a
927
+ * measurement wrong. It also means batching applies to commits this provider
928
+ * takes part in, so mount it as high in the tree as you can.
929
+ *
930
+ * Requires `configure({ batchInjection: true })`; without it this component
931
+ * only renders its children. `batchInjection: 'always'` does not need the
932
+ * provider at all — see that option's docs for the trade-off it accepts.
933
+ *
934
+ * @example
935
+ * ```tsx
936
+ * configure({ batchInjection: true });
937
+ *
938
+ * createRoot(el).render(
939
+ * <TastyBatchProvider>
940
+ * <App />
941
+ * </TastyBatchProvider>,
942
+ * );
943
+ * ```
944
+ */
945
+ function TastyBatchProvider({ children }) {
946
+ openBatchWindow();
947
+ useInsertionEffect(() => {
948
+ closeBatchWindow();
949
+ });
950
+ return children;
951
+ }
952
+ //#endregion
953
+ export { APPEARANCE_CHUNK_STYLES, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, ChunkSheetRegistry, DEFAULT_NAME_PREFIX, DEFAULT_ZERO_NAME_PREFIX, DIMENSION_CHUNK_STYLES, DIMENSION_STYLES, DIRECTIONS, DISPLAY_CHUNK_STYLES, Element, FLOW_STYLES, FONT_CHUNK_STYLES, INNER_STYLES, LAYOUT_CHUNK_STYLES, OUTER_STYLES, POSITION_CHUNK_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, TastyBatchProvider, acquireStyles, categorizeStyleKeys, chunkSheetRegistry, cleanup, color, computeStyles, configure, counterStyle, createColorFunc, createInjector, createStateParserContext, defineHandler, defineRecipe, destroy, dotize, filterBaseProps, filterMods, flushStyles, fontFace, func, gc, generateTypographyTokens, getCSSText, getCSSTextForNode, getConfig, getDisplayName, getGlobalCounterStyles, getGlobalFontFaces, getGlobalFunctions, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getNamePrefix, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasPendingStyleWrites, hasRecipe, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunction, okhslPlugin, okhstFunction, okhstPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, releaseStyles, renderStyles, resetConfig, resetStyleBatch, resolveChunk, resolveFunctionColor, resolveRecipes, setGlobalPredefinedStates, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useFunction, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles };
32
954
 
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 };
955
+ //# sourceMappingURL=index.js.map