@tenphi/tasty 0.0.0-snapshot.ef967bb → 0.0.0-snapshot.effc80a

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 (385) hide show
  1. package/README.md +441 -362
  2. package/dist/babel-types-BKDTT4--.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-DHL8W6vf.js +60 -0
  6. package/dist/chunks/build-config-DHL8W6vf.js.map +1 -0
  7. package/dist/chunks/collector-P1lIDioe.js +210 -0
  8. package/dist/chunks/collector-P1lIDioe.js.map +1 -0
  9. package/dist/chunks/config-engine-HlsfjR7T.js +272 -0
  10. package/dist/chunks/config-engine-HlsfjR7T.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BE12wEJB.js +910 -0
  14. package/dist/chunks/css-definitions-BE12wEJB.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/{debug.js → chunks/debug-CWZkJJ7A.js} +196 -147
  18. package/dist/chunks/debug-CWZkJJ7A.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-BwKuG_3d.js +689 -0
  24. package/dist/chunks/react-runtime-BwKuG_3d.js.map +1 -0
  25. package/dist/chunks/runtime-engine-D2N-eiPD.js +2432 -0
  26. package/dist/chunks/runtime-engine-D2N-eiPD.js.map +1 -0
  27. package/dist/chunks/runtime-state-BJoTY_DP.js +152 -0
  28. package/dist/chunks/runtime-state-BJoTY_DP.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +60 -56
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-CJoK33le.js +5521 -0
  32. package/dist/chunks/style-engine-CJoK33le.js.map +1 -0
  33. package/dist/chunks/zero-engine-BCqhSuwo.js +310 -0
  34. package/dist/chunks/zero-engine-BCqhSuwo.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-CcxqSZI2.d.ts +1368 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index--GdqCPlp.d.ts +1962 -0
  41. package/dist/index.d.ts +5 -51
  42. package/dist/index.js +11 -36
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +110 -12
  60. package/dist/ssr/astro.js +205 -48
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -5
  65. package/dist/ssr/index.js +6 -7
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -12
  71. package/dist/ssr/next.js +32 -47
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -3
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/static/inject.js.map +1 -1
  78. package/dist/types-DJEM_BOJ.d.ts +1567 -0
  79. package/dist/zero/babel.d.ts +5 -120
  80. package/dist/zero/babel.js +123 -146
  81. package/dist/zero/babel.js.map +1 -1
  82. package/dist/zero/index.d.ts +135 -3
  83. package/dist/zero/index.js +24 -3
  84. package/dist/zero/index.js.map +1 -0
  85. package/dist/zero/next.d.ts +4 -5
  86. package/dist/zero/next.js +3 -38
  87. package/dist/zero/next.js.map +1 -1
  88. package/docs/README.md +23 -12
  89. package/docs/adoption.md +72 -37
  90. package/docs/ai-agents.md +257 -0
  91. package/docs/comparison.md +83 -54
  92. package/docs/configuration.md +710 -81
  93. package/docs/debug.md +39 -24
  94. package/docs/design-system.md +174 -41
  95. package/docs/dsl.md +667 -195
  96. package/docs/getting-started.md +132 -52
  97. package/docs/injector.md +197 -90
  98. package/docs/methodology.md +107 -50
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +768 -0
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +744 -0
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +402 -150
  105. package/docs/styles.md +182 -47
  106. package/docs/tasty-static.md +284 -118
  107. package/package.json +148 -35
  108. package/tasty.config.ts +6 -0
  109. package/dist/_virtual/_rolldown/runtime.js +0 -7
  110. package/dist/chunks/cacheKey.d.ts +0 -1
  111. package/dist/chunks/cacheKey.js +0 -77
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -258
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/index.d.ts +0 -1
  117. package/dist/chunks/renderChunk.d.ts +0 -1
  118. package/dist/chunks/renderChunk.js +0 -59
  119. package/dist/chunks/renderChunk.js.map +0 -1
  120. package/dist/compute-styles.d.ts +0 -31
  121. package/dist/compute-styles.js +0 -356
  122. package/dist/compute-styles.js.map +0 -1
  123. package/dist/config.d.ts +0 -372
  124. package/dist/config.js +0 -507
  125. package/dist/config.js.map +0 -1
  126. package/dist/counter-style/index.js +0 -51
  127. package/dist/counter-style/index.js.map +0 -1
  128. package/dist/debug.d.ts +0 -89
  129. package/dist/debug.js.map +0 -1
  130. package/dist/font-face/index.js +0 -63
  131. package/dist/font-face/index.js.map +0 -1
  132. package/dist/hooks/index.d.ts +0 -7
  133. package/dist/hooks/resolve-ssr-collector.js +0 -14
  134. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  135. package/dist/hooks/useCounterStyle.d.ts +0 -50
  136. package/dist/hooks/useCounterStyle.js +0 -46
  137. package/dist/hooks/useCounterStyle.js.map +0 -1
  138. package/dist/hooks/useFontFace.d.ts +0 -43
  139. package/dist/hooks/useFontFace.js +0 -70
  140. package/dist/hooks/useFontFace.js.map +0 -1
  141. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  142. package/dist/hooks/useGlobalStyles.js +0 -78
  143. package/dist/hooks/useGlobalStyles.js.map +0 -1
  144. package/dist/hooks/useKeyframes.d.ts +0 -56
  145. package/dist/hooks/useKeyframes.js +0 -64
  146. package/dist/hooks/useKeyframes.js.map +0 -1
  147. package/dist/hooks/useProperty.d.ts +0 -79
  148. package/dist/hooks/useProperty.js +0 -109
  149. package/dist/hooks/useProperty.js.map +0 -1
  150. package/dist/hooks/useRawCSS.d.ts +0 -53
  151. package/dist/hooks/useRawCSS.js +0 -35
  152. package/dist/hooks/useRawCSS.js.map +0 -1
  153. package/dist/hooks/useStyles.d.ts +0 -40
  154. package/dist/hooks/useStyles.js +0 -31
  155. package/dist/hooks/useStyles.js.map +0 -1
  156. package/dist/injector/index.d.ts +0 -166
  157. package/dist/injector/index.js +0 -166
  158. package/dist/injector/index.js.map +0 -1
  159. package/dist/injector/injector.d.ts +0 -166
  160. package/dist/injector/injector.js +0 -464
  161. package/dist/injector/injector.js.map +0 -1
  162. package/dist/injector/sheet-manager.d.ts +0 -136
  163. package/dist/injector/sheet-manager.js +0 -733
  164. package/dist/injector/sheet-manager.js.map +0 -1
  165. package/dist/injector/types.d.ts +0 -204
  166. package/dist/keyframes/index.js +0 -206
  167. package/dist/keyframes/index.js.map +0 -1
  168. package/dist/parser/classify.js +0 -319
  169. package/dist/parser/classify.js.map +0 -1
  170. package/dist/parser/const.js +0 -60
  171. package/dist/parser/const.js.map +0 -1
  172. package/dist/parser/lru.js +0 -109
  173. package/dist/parser/lru.js.map +0 -1
  174. package/dist/parser/parser.d.ts +0 -25
  175. package/dist/parser/parser.js +0 -115
  176. package/dist/parser/parser.js.map +0 -1
  177. package/dist/parser/tokenizer.js +0 -69
  178. package/dist/parser/tokenizer.js.map +0 -1
  179. package/dist/parser/types.d.ts +0 -51
  180. package/dist/parser/types.js +0 -46
  181. package/dist/parser/types.js.map +0 -1
  182. package/dist/pipeline/conditions.d.ts +0 -134
  183. package/dist/pipeline/conditions.js +0 -406
  184. package/dist/pipeline/conditions.js.map +0 -1
  185. package/dist/pipeline/exclusive.js +0 -230
  186. package/dist/pipeline/exclusive.js.map +0 -1
  187. package/dist/pipeline/index.d.ts +0 -55
  188. package/dist/pipeline/index.js +0 -708
  189. package/dist/pipeline/index.js.map +0 -1
  190. package/dist/pipeline/materialize.js +0 -1103
  191. package/dist/pipeline/materialize.js.map +0 -1
  192. package/dist/pipeline/parseStateKey.d.ts +0 -15
  193. package/dist/pipeline/parseStateKey.js +0 -446
  194. package/dist/pipeline/parseStateKey.js.map +0 -1
  195. package/dist/pipeline/simplify.js +0 -515
  196. package/dist/pipeline/simplify.js.map +0 -1
  197. package/dist/pipeline/warnings.js +0 -18
  198. package/dist/pipeline/warnings.js.map +0 -1
  199. package/dist/plugins/index.d.ts +0 -2
  200. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  201. package/dist/plugins/okhsl-plugin.js +0 -97
  202. package/dist/plugins/okhsl-plugin.js.map +0 -1
  203. package/dist/plugins/types.d.ts +0 -76
  204. package/dist/properties/index.js +0 -222
  205. package/dist/properties/index.js.map +0 -1
  206. package/dist/properties/property-type-resolver.d.ts +0 -24
  207. package/dist/properties/property-type-resolver.js +0 -90
  208. package/dist/properties/property-type-resolver.js.map +0 -1
  209. package/dist/ssr/async-storage.d.ts +0 -17
  210. package/dist/ssr/async-storage.js +0 -34
  211. package/dist/ssr/async-storage.js.map +0 -1
  212. package/dist/ssr/collect-auto-properties.js +0 -39
  213. package/dist/ssr/collect-auto-properties.js.map +0 -1
  214. package/dist/ssr/collector.d.ts +0 -102
  215. package/dist/ssr/collector.js +0 -219
  216. package/dist/ssr/collector.js.map +0 -1
  217. package/dist/ssr/context.d.ts +0 -8
  218. package/dist/ssr/context.js +0 -13
  219. package/dist/ssr/context.js.map +0 -1
  220. package/dist/ssr/format-global-rules.js +0 -22
  221. package/dist/ssr/format-global-rules.js.map +0 -1
  222. package/dist/ssr/format-keyframes.js +0 -69
  223. package/dist/ssr/format-keyframes.js.map +0 -1
  224. package/dist/ssr/format-property.js +0 -49
  225. package/dist/ssr/format-property.js.map +0 -1
  226. package/dist/ssr/format-rules.js +0 -73
  227. package/dist/ssr/format-rules.js.map +0 -1
  228. package/dist/ssr/hydrate.d.ts +0 -22
  229. package/dist/ssr/hydrate.js +0 -49
  230. package/dist/ssr/hydrate.js.map +0 -1
  231. package/dist/ssr/ssr-collector-ref.js +0 -12
  232. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  233. package/dist/states/index.d.ts +0 -49
  234. package/dist/states/index.js +0 -170
  235. package/dist/states/index.js.map +0 -1
  236. package/dist/static/tastyStatic.d.ts +0 -46
  237. package/dist/static/tastyStatic.js +0 -30
  238. package/dist/static/tastyStatic.js.map +0 -1
  239. package/dist/static/types.d.ts +0 -49
  240. package/dist/static/types.js +0 -24
  241. package/dist/static/types.js.map +0 -1
  242. package/dist/styles/border.d.ts +0 -25
  243. package/dist/styles/border.js +0 -120
  244. package/dist/styles/border.js.map +0 -1
  245. package/dist/styles/color.d.ts +0 -14
  246. package/dist/styles/color.js +0 -26
  247. package/dist/styles/color.js.map +0 -1
  248. package/dist/styles/const.js +0 -17
  249. package/dist/styles/const.js.map +0 -1
  250. package/dist/styles/createStyle.js +0 -79
  251. package/dist/styles/createStyle.js.map +0 -1
  252. package/dist/styles/dimension.js +0 -109
  253. package/dist/styles/dimension.js.map +0 -1
  254. package/dist/styles/directional.js +0 -133
  255. package/dist/styles/directional.js.map +0 -1
  256. package/dist/styles/display.d.ts +0 -30
  257. package/dist/styles/display.js +0 -73
  258. package/dist/styles/display.js.map +0 -1
  259. package/dist/styles/fade.d.ts +0 -15
  260. package/dist/styles/fade.js +0 -62
  261. package/dist/styles/fade.js.map +0 -1
  262. package/dist/styles/fill.d.ts +0 -42
  263. package/dist/styles/fill.js +0 -51
  264. package/dist/styles/fill.js.map +0 -1
  265. package/dist/styles/flow.d.ts +0 -16
  266. package/dist/styles/flow.js +0 -12
  267. package/dist/styles/flow.js.map +0 -1
  268. package/dist/styles/gap.d.ts +0 -31
  269. package/dist/styles/gap.js +0 -38
  270. package/dist/styles/gap.js.map +0 -1
  271. package/dist/styles/height.d.ts +0 -17
  272. package/dist/styles/height.js +0 -19
  273. package/dist/styles/height.js.map +0 -1
  274. package/dist/styles/index.d.ts +0 -1
  275. package/dist/styles/index.js +0 -8
  276. package/dist/styles/index.js.map +0 -1
  277. package/dist/styles/inset.d.ts +0 -24
  278. package/dist/styles/inset.js +0 -34
  279. package/dist/styles/inset.js.map +0 -1
  280. package/dist/styles/list.d.ts +0 -16
  281. package/dist/styles/list.js +0 -100
  282. package/dist/styles/list.js.map +0 -1
  283. package/dist/styles/margin.d.ts +0 -24
  284. package/dist/styles/margin.js +0 -32
  285. package/dist/styles/margin.js.map +0 -1
  286. package/dist/styles/outline.d.ts +0 -29
  287. package/dist/styles/outline.js +0 -55
  288. package/dist/styles/outline.js.map +0 -1
  289. package/dist/styles/padding.d.ts +0 -24
  290. package/dist/styles/padding.js +0 -32
  291. package/dist/styles/padding.js.map +0 -1
  292. package/dist/styles/placement.d.ts +0 -37
  293. package/dist/styles/placement.js +0 -74
  294. package/dist/styles/placement.js.map +0 -1
  295. package/dist/styles/predefined.d.ts +0 -71
  296. package/dist/styles/predefined.js +0 -237
  297. package/dist/styles/predefined.js.map +0 -1
  298. package/dist/styles/preset.d.ts +0 -52
  299. package/dist/styles/preset.js +0 -127
  300. package/dist/styles/preset.js.map +0 -1
  301. package/dist/styles/radius.d.ts +0 -12
  302. package/dist/styles/radius.js +0 -83
  303. package/dist/styles/radius.js.map +0 -1
  304. package/dist/styles/scrollMargin.d.ts +0 -24
  305. package/dist/styles/scrollMargin.js +0 -32
  306. package/dist/styles/scrollMargin.js.map +0 -1
  307. package/dist/styles/scrollbar.d.ts +0 -25
  308. package/dist/styles/scrollbar.js +0 -51
  309. package/dist/styles/scrollbar.js.map +0 -1
  310. package/dist/styles/shadow.d.ts +0 -14
  311. package/dist/styles/shadow.js +0 -25
  312. package/dist/styles/shadow.js.map +0 -1
  313. package/dist/styles/shared.js +0 -17
  314. package/dist/styles/shared.js.map +0 -1
  315. package/dist/styles/transition.d.ts +0 -14
  316. package/dist/styles/transition.js +0 -159
  317. package/dist/styles/transition.js.map +0 -1
  318. package/dist/styles/types.d.ts +0 -564
  319. package/dist/styles/width.d.ts +0 -17
  320. package/dist/styles/width.js +0 -19
  321. package/dist/styles/width.js.map +0 -1
  322. package/dist/tasty.d.ts +0 -134
  323. package/dist/tasty.js +0 -240
  324. package/dist/tasty.js.map +0 -1
  325. package/dist/types.d.ts +0 -184
  326. package/dist/utils/cache-wrapper.js +0 -21
  327. package/dist/utils/cache-wrapper.js.map +0 -1
  328. package/dist/utils/case-converter.js +0 -8
  329. package/dist/utils/case-converter.js.map +0 -1
  330. package/dist/utils/color-math.d.ts +0 -46
  331. package/dist/utils/color-math.js +0 -749
  332. package/dist/utils/color-math.js.map +0 -1
  333. package/dist/utils/color-space.d.ts +0 -5
  334. package/dist/utils/color-space.js +0 -228
  335. package/dist/utils/color-space.js.map +0 -1
  336. package/dist/utils/colors.d.ts +0 -5
  337. package/dist/utils/colors.js +0 -10
  338. package/dist/utils/colors.js.map +0 -1
  339. package/dist/utils/css-types.d.ts +0 -7
  340. package/dist/utils/dotize.d.ts +0 -26
  341. package/dist/utils/dotize.js +0 -122
  342. package/dist/utils/dotize.js.map +0 -1
  343. package/dist/utils/filter-base-props.d.ts +0 -15
  344. package/dist/utils/filter-base-props.js +0 -45
  345. package/dist/utils/filter-base-props.js.map +0 -1
  346. package/dist/utils/get-display-name.d.ts +0 -7
  347. package/dist/utils/get-display-name.js +0 -10
  348. package/dist/utils/get-display-name.js.map +0 -1
  349. package/dist/utils/has-keys.js +0 -13
  350. package/dist/utils/has-keys.js.map +0 -1
  351. package/dist/utils/is-dev-env.js +0 -19
  352. package/dist/utils/is-dev-env.js.map +0 -1
  353. package/dist/utils/is-valid-element-type.js +0 -15
  354. package/dist/utils/is-valid-element-type.js.map +0 -1
  355. package/dist/utils/merge-styles.js.map +0 -1
  356. package/dist/utils/mod-attrs.d.ts +0 -6
  357. package/dist/utils/mod-attrs.js +0 -20
  358. package/dist/utils/mod-attrs.js.map +0 -1
  359. package/dist/utils/process-tokens.d.ts +0 -17
  360. package/dist/utils/process-tokens.js +0 -83
  361. package/dist/utils/process-tokens.js.map +0 -1
  362. package/dist/utils/resolve-recipes.d.ts +0 -17
  363. package/dist/utils/resolve-recipes.js +0 -146
  364. package/dist/utils/resolve-recipes.js.map +0 -1
  365. package/dist/utils/selector-transform.js +0 -32
  366. package/dist/utils/selector-transform.js.map +0 -1
  367. package/dist/utils/string.js +0 -8
  368. package/dist/utils/string.js.map +0 -1
  369. package/dist/utils/styles.d.ts +0 -99
  370. package/dist/utils/styles.js +0 -220
  371. package/dist/utils/styles.js.map +0 -1
  372. package/dist/utils/typography.d.ts +0 -47
  373. package/dist/utils/typography.js +0 -51
  374. package/dist/utils/typography.js.map +0 -1
  375. package/dist/utils/warnings.d.ts +0 -16
  376. package/dist/utils/warnings.js +0 -16
  377. package/dist/utils/warnings.js.map +0 -1
  378. package/dist/zero/css-writer.d.ts +0 -45
  379. package/dist/zero/css-writer.js +0 -73
  380. package/dist/zero/css-writer.js.map +0 -1
  381. package/dist/zero/extractor.d.ts +0 -24
  382. package/dist/zero/extractor.js +0 -266
  383. package/dist/zero/extractor.js.map +0 -1
  384. package/docs/PIPELINE.md +0 -519
  385. package/docs/runtime.md +0 -572
@@ -1,56 +0,0 @@
1
- import { KeyframesSteps } from "../injector/types.js";
2
-
3
- //#region src/hooks/useKeyframes.d.ts
4
- interface UseKeyframesOptions {
5
- name?: string;
6
- root?: Document | ShadowRoot;
7
- }
8
- /**
9
- * Hook to inject CSS @keyframes and return the generated animation name.
10
- * Handles keyframes injection with proper cleanup on unmount or dependency changes.
11
- *
12
- * @example Basic usage - steps object is the dependency
13
- * ```tsx
14
- * function MyComponent() {
15
- * const bounce = useKeyframes({
16
- * '0%': { transform: 'scale(1)' },
17
- * '50%': { transform: 'scale(1.1)' },
18
- * '100%': { transform: 'scale(1)' },
19
- * });
20
- *
21
- * return <div style={{ animation: `${bounce} 1s infinite` }}>Bouncing</div>;
22
- * }
23
- * ```
24
- *
25
- * @example With custom name
26
- * ```tsx
27
- * function MyComponent() {
28
- * const fadeIn = useKeyframes(
29
- * { from: { opacity: 0 }, to: { opacity: 1 } },
30
- * { name: 'fadeIn' }
31
- * );
32
- *
33
- * return <div style={{ animation: `${fadeIn} 0.3s ease-out` }}>Fading in</div>;
34
- * }
35
- * ```
36
- *
37
- * @example Factory function with dependencies
38
- * ```tsx
39
- * function MyComponent({ scale }: { scale: number }) {
40
- * const pulse = useKeyframes(
41
- * () => ({
42
- * '0%': { transform: 'scale(1)' },
43
- * '100%': { transform: `scale(${scale})` },
44
- * }),
45
- * [scale]
46
- * );
47
- *
48
- * return <div style={{ animation: `${pulse} 1s infinite` }}>Pulsing</div>;
49
- * }
50
- * ```
51
- */
52
- declare function useKeyframes(steps: KeyframesSteps, options?: UseKeyframesOptions): string;
53
- declare function useKeyframes(factory: () => KeyframesSteps, deps: readonly unknown[], options?: UseKeyframesOptions): string;
54
- //#endregion
55
- export { useKeyframes };
56
- //# sourceMappingURL=useKeyframes.d.ts.map
@@ -1,64 +0,0 @@
1
- import { keyframes } from "../injector/index.js";
2
- import { formatKeyframesCSS } from "../ssr/format-keyframes.js";
3
- import { TastySSRContext } from "../ssr/context.js";
4
- import { resolveSSRCollector } from "./resolve-ssr-collector.js";
5
- import { useContext, useInsertionEffect, useMemo, useRef } from "react";
6
- //#region src/hooks/useKeyframes.ts
7
- function useKeyframes(stepsOrFactory, depsOrOptions, options) {
8
- const ssrCollector = resolveSSRCollector(useContext(TastySSRContext));
9
- const isFactory = typeof stepsOrFactory === "function";
10
- const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
11
- const opts = isFactory ? options : depsOrOptions;
12
- const stepsData = useMemo(() => {
13
- const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
14
- if (!steps || Object.keys(steps).length === 0) return null;
15
- return steps;
16
- }, isFactory ? deps ?? [] : [stepsOrFactory]);
17
- const renderResultRef = useRef(null);
18
- const effectResultRef = useRef(null);
19
- const name = useMemo(() => {
20
- if (!stepsData) return "";
21
- if (ssrCollector) {
22
- const actualName = ssrCollector.allocateKeyframeName(opts?.name);
23
- const css = formatKeyframesCSS(actualName, stepsData);
24
- ssrCollector.collectKeyframes(actualName, css);
25
- return actualName;
26
- }
27
- renderResultRef.current?.dispose();
28
- renderResultRef.current = null;
29
- const result = keyframes(stepsData, {
30
- name: opts?.name,
31
- root: opts?.root
32
- });
33
- renderResultRef.current = result;
34
- return result.toString();
35
- }, [
36
- stepsData,
37
- opts?.name,
38
- opts?.root,
39
- ssrCollector
40
- ]);
41
- useInsertionEffect(() => {
42
- effectResultRef.current?.dispose();
43
- effectResultRef.current = null;
44
- if (stepsData) effectResultRef.current = keyframes(stepsData, {
45
- name: opts?.name,
46
- root: opts?.root
47
- });
48
- return () => {
49
- effectResultRef.current?.dispose();
50
- effectResultRef.current = null;
51
- renderResultRef.current?.dispose();
52
- renderResultRef.current = null;
53
- };
54
- }, [
55
- stepsData,
56
- opts?.name,
57
- opts?.root
58
- ]);
59
- return name;
60
- }
61
- //#endregion
62
- export { useKeyframes };
63
-
64
- //# sourceMappingURL=useKeyframes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useKeyframes.js","names":[],"sources":["../../src/hooks/useKeyframes.ts"],"sourcesContent":["import { useContext, useInsertionEffect, useMemo, useRef } from 'react';\n\nimport { keyframes } from '../injector';\nimport type { KeyframesResult, KeyframesSteps } from '../injector/types';\nimport { resolveSSRCollector } from './resolve-ssr-collector';\nimport { TastySSRContext } from '../ssr/context';\nimport { formatKeyframesCSS } from '../ssr/format-keyframes';\n\ninterface UseKeyframesOptions {\n name?: string;\n root?: Document | ShadowRoot;\n}\n\n/**\n * Hook to inject CSS @keyframes and return the generated animation name.\n * Handles keyframes injection with proper cleanup on unmount or dependency changes.\n *\n * @example Basic usage - steps object is the dependency\n * ```tsx\n * function MyComponent() {\n * const bounce = useKeyframes({\n * '0%': { transform: 'scale(1)' },\n * '50%': { transform: 'scale(1.1)' },\n * '100%': { transform: 'scale(1)' },\n * });\n *\n * return <div style={{ animation: `${bounce} 1s infinite` }}>Bouncing</div>;\n * }\n * ```\n *\n * @example With custom name\n * ```tsx\n * function MyComponent() {\n * const fadeIn = useKeyframes(\n * { from: { opacity: 0 }, to: { opacity: 1 } },\n * { name: 'fadeIn' }\n * );\n *\n * return <div style={{ animation: `${fadeIn} 0.3s ease-out` }}>Fading in</div>;\n * }\n * ```\n *\n * @example Factory function with dependencies\n * ```tsx\n * function MyComponent({ scale }: { scale: number }) {\n * const pulse = useKeyframes(\n * () => ({\n * '0%': { transform: 'scale(1)' },\n * '100%': { transform: `scale(${scale})` },\n * }),\n * [scale]\n * );\n *\n * return <div style={{ animation: `${pulse} 1s infinite` }}>Pulsing</div>;\n * }\n * ```\n */\n\n// Overload 1: Static steps object\nexport function useKeyframes(\n steps: KeyframesSteps,\n options?: UseKeyframesOptions,\n): string;\n\n// Overload 2: Factory function with dependencies\nexport function useKeyframes(\n factory: () => KeyframesSteps,\n deps: readonly unknown[],\n options?: UseKeyframesOptions,\n): string;\n\n// Implementation\nexport function useKeyframes(\n stepsOrFactory: KeyframesSteps | (() => KeyframesSteps),\n depsOrOptions?: readonly unknown[] | UseKeyframesOptions,\n options?: UseKeyframesOptions,\n): string {\n const ssrContextValue = useContext(TastySSRContext);\n const ssrCollector = resolveSSRCollector(ssrContextValue);\n\n // Detect which overload is being used\n const isFactory = typeof stepsOrFactory === 'function';\n\n // Parse arguments based on overload\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseKeyframesOptions | undefined);\n\n // Memoize the keyframes steps to get a stable reference\n const stepsData = useMemo(\n () => {\n const steps = isFactory\n ? (stepsOrFactory as () => KeyframesSteps)()\n : (stepsOrFactory as KeyframesSteps);\n\n if (!steps || Object.keys(steps).length === 0) {\n return null;\n }\n\n return steps;\n },\n\n isFactory ? (deps ?? []) : [stepsOrFactory],\n );\n\n // Store keyframes results for cleanup (client only)\n const renderResultRef = useRef<KeyframesResult | null>(null);\n const effectResultRef = useRef<KeyframesResult | null>(null);\n\n const name = useMemo(() => {\n if (!stepsData) {\n return '';\n }\n\n // SSR path: format and collect, return name without DOM injection\n if (ssrCollector) {\n const actualName = ssrCollector.allocateKeyframeName(opts?.name);\n const css = formatKeyframesCSS(actualName, stepsData);\n ssrCollector.collectKeyframes(actualName, css);\n return actualName;\n }\n\n // Client path: inject keyframes synchronously for immediate name availability\n renderResultRef.current?.dispose();\n renderResultRef.current = null;\n\n const result = keyframes(stepsData, {\n name: opts?.name,\n root: opts?.root,\n });\n\n renderResultRef.current = result;\n\n return result.toString();\n }, [stepsData, opts?.name, opts?.root, ssrCollector]);\n\n // Client path: handle Strict Mode double-invocation and cleanup\n useInsertionEffect(() => {\n effectResultRef.current?.dispose();\n effectResultRef.current = null;\n\n if (stepsData) {\n const result = keyframes(stepsData, {\n name: opts?.name,\n root: opts?.root,\n });\n effectResultRef.current = result;\n }\n\n return () => {\n effectResultRef.current?.dispose();\n effectResultRef.current = null;\n renderResultRef.current?.dispose();\n renderResultRef.current = null;\n };\n }, [stepsData, opts?.name, opts?.root]);\n\n return name;\n}\n"],"mappings":";;;;;;AAwEA,SAAgB,aACd,gBACA,eACA,SACQ;CAER,MAAM,eAAe,oBADG,WAAW,gBAAgB,CACM;CAGzD,MAAM,YAAY,OAAO,mBAAmB;CAG5C,MAAM,OACJ,aAAa,MAAM,QAAQ,cAAc,GAAG,gBAAgB,KAAA;CAC9D,MAAM,OAAO,YACT,UACC;CAGL,MAAM,YAAY,cACV;EACJ,MAAM,QAAQ,YACT,gBAAyC,GACzC;AAEL,MAAI,CAAC,SAAS,OAAO,KAAK,MAAM,CAAC,WAAW,EAC1C,QAAO;AAGT,SAAO;IAGT,YAAa,QAAQ,EAAE,GAAI,CAAC,eAAe,CAC5C;CAGD,MAAM,kBAAkB,OAA+B,KAAK;CAC5D,MAAM,kBAAkB,OAA+B,KAAK;CAE5D,MAAM,OAAO,cAAc;AACzB,MAAI,CAAC,UACH,QAAO;AAIT,MAAI,cAAc;GAChB,MAAM,aAAa,aAAa,qBAAqB,MAAM,KAAK;GAChE,MAAM,MAAM,mBAAmB,YAAY,UAAU;AACrD,gBAAa,iBAAiB,YAAY,IAAI;AAC9C,UAAO;;AAIT,kBAAgB,SAAS,SAAS;AAClC,kBAAgB,UAAU;EAE1B,MAAM,SAAS,UAAU,WAAW;GAClC,MAAM,MAAM;GACZ,MAAM,MAAM;GACb,CAAC;AAEF,kBAAgB,UAAU;AAE1B,SAAO,OAAO,UAAU;IACvB;EAAC;EAAW,MAAM;EAAM,MAAM;EAAM;EAAa,CAAC;AAGrD,0BAAyB;AACvB,kBAAgB,SAAS,SAAS;AAClC,kBAAgB,UAAU;AAE1B,MAAI,UAKF,iBAAgB,UAJD,UAAU,WAAW;GAClC,MAAM,MAAM;GACZ,MAAM,MAAM;GACb,CAAC;AAIJ,eAAa;AACX,mBAAgB,SAAS,SAAS;AAClC,mBAAgB,UAAU;AAC1B,mBAAgB,SAAS,SAAS;AAClC,mBAAgB,UAAU;;IAE3B;EAAC;EAAW,MAAM;EAAM,MAAM;EAAK,CAAC;AAEvC,QAAO"}
@@ -1,79 +0,0 @@
1
- //#region src/hooks/useProperty.d.ts
2
- interface UsePropertyOptions {
3
- /**
4
- * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>').
5
- * For color tokens (#name), this is auto-set to '<color>' and cannot be overridden.
6
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax
7
- */
8
- syntax?: string;
9
- /**
10
- * Whether the property inherits from parent elements
11
- * @default true
12
- */
13
- inherits?: boolean;
14
- /**
15
- * Initial value for the property.
16
- * For color tokens (#name), this defaults to 'transparent' if not specified.
17
- */
18
- initialValue?: string | number;
19
- /**
20
- * Shadow root or document to inject into
21
- */
22
- root?: Document | ShadowRoot;
23
- }
24
- /**
25
- * Hook to register a CSS @property custom property.
26
- * This enables advanced features like animating custom properties.
27
- *
28
- * Note: @property rules are global and persistent once defined.
29
- * The hook ensures the property is only registered once per root.
30
- *
31
- * Accepts tasty token syntax for the property name:
32
- * - `$name` → defines `--name`
33
- * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
34
- * - `--name` → defines `--name` (legacy format)
35
- *
36
- * @param name - The property token ($name, #name) or CSS property name (--name)
37
- * @param options - Property configuration
38
- *
39
- * @example Basic property with token syntax
40
- * ```tsx
41
- * function Spinner() {
42
- * useProperty('$rotation', {
43
- * syntax: '<angle>',
44
- * inherits: false,
45
- * initialValue: '0deg',
46
- * });
47
- *
48
- * return <div className="spinner" />;
49
- * }
50
- * ```
51
- *
52
- * @example Color property with token syntax (auto-sets syntax)
53
- * ```tsx
54
- * function MyComponent() {
55
- * useProperty('#theme', {
56
- * initialValue: 'red', // syntax: '<color>' is auto-set
57
- * });
58
- *
59
- * // Now --theme-color can be animated with CSS transitions
60
- * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
61
- * }
62
- * ```
63
- *
64
- * @example Legacy format (still supported)
65
- * ```tsx
66
- * function ResizableBox() {
67
- * useProperty('--box-size', {
68
- * syntax: '<length>',
69
- * initialValue: '100px',
70
- * });
71
- *
72
- * return <div style={{ width: 'var(--box-size)' }} />;
73
- * }
74
- * ```
75
- */
76
- declare function useProperty(name: string, options?: UsePropertyOptions): void;
77
- //#endregion
78
- export { UsePropertyOptions, useProperty };
79
- //# sourceMappingURL=useProperty.d.ts.map
@@ -1,109 +0,0 @@
1
- import { getGlobalInjector } from "../config.js";
2
- import { formatPropertyCSS } from "../ssr/format-property.js";
3
- import { TastySSRContext } from "../ssr/context.js";
4
- import { resolveSSRCollector } from "./resolve-ssr-collector.js";
5
- import { useContext, useInsertionEffect, useMemo } from "react";
6
- //#region src/hooks/useProperty.ts
7
- /**
8
- * Hook to register a CSS @property custom property.
9
- * This enables advanced features like animating custom properties.
10
- *
11
- * Note: @property rules are global and persistent once defined.
12
- * The hook ensures the property is only registered once per root.
13
- *
14
- * Accepts tasty token syntax for the property name:
15
- * - `$name` → defines `--name`
16
- * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
17
- * - `--name` → defines `--name` (legacy format)
18
- *
19
- * @param name - The property token ($name, #name) or CSS property name (--name)
20
- * @param options - Property configuration
21
- *
22
- * @example Basic property with token syntax
23
- * ```tsx
24
- * function Spinner() {
25
- * useProperty('$rotation', {
26
- * syntax: '<angle>',
27
- * inherits: false,
28
- * initialValue: '0deg',
29
- * });
30
- *
31
- * return <div className="spinner" />;
32
- * }
33
- * ```
34
- *
35
- * @example Color property with token syntax (auto-sets syntax)
36
- * ```tsx
37
- * function MyComponent() {
38
- * useProperty('#theme', {
39
- * initialValue: 'red', // syntax: '<color>' is auto-set
40
- * });
41
- *
42
- * // Now --theme-color can be animated with CSS transitions
43
- * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
44
- * }
45
- * ```
46
- *
47
- * @example Legacy format (still supported)
48
- * ```tsx
49
- * function ResizableBox() {
50
- * useProperty('--box-size', {
51
- * syntax: '<length>',
52
- * initialValue: '100px',
53
- * });
54
- *
55
- * return <div style={{ width: 'var(--box-size)' }} />;
56
- * }
57
- * ```
58
- */
59
- function useProperty(name, options) {
60
- const ssrCollector = resolveSSRCollector(useContext(TastySSRContext));
61
- const optionsKey = useMemo(() => {
62
- if (!options) return "";
63
- return JSON.stringify({
64
- syntax: options.syntax,
65
- inherits: options.inherits,
66
- initialValue: options.initialValue
67
- });
68
- }, [
69
- options?.syntax,
70
- options?.inherits,
71
- options?.initialValue
72
- ]);
73
- useMemo(() => {
74
- if (!ssrCollector || !name) return;
75
- ssrCollector.collectInternals();
76
- const css = formatPropertyCSS(name, {
77
- syntax: options?.syntax,
78
- inherits: options?.inherits,
79
- initialValue: options?.initialValue
80
- });
81
- if (css) ssrCollector.collectProperty(name, css);
82
- }, [
83
- ssrCollector,
84
- name,
85
- optionsKey
86
- ]);
87
- useInsertionEffect(() => {
88
- if (!name) {
89
- console.warn(`[Tasty] useProperty: property name is required`);
90
- return;
91
- }
92
- const injector = getGlobalInjector();
93
- if (injector.isPropertyDefined(name, { root: options?.root })) return;
94
- injector.property(name, {
95
- syntax: options?.syntax,
96
- inherits: options?.inherits,
97
- initialValue: options?.initialValue,
98
- root: options?.root
99
- });
100
- }, [
101
- name,
102
- optionsKey,
103
- options?.root
104
- ]);
105
- }
106
- //#endregion
107
- export { useProperty };
108
-
109
- //# sourceMappingURL=useProperty.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useProperty.js","names":[],"sources":["../../src/hooks/useProperty.ts"],"sourcesContent":["import { useContext, useInsertionEffect, useMemo } from 'react';\n\nimport { getGlobalInjector } from '../config';\nimport { resolveSSRCollector } from './resolve-ssr-collector';\nimport { TastySSRContext } from '../ssr/context';\nimport { formatPropertyCSS } from '../ssr/format-property';\n\nexport interface UsePropertyOptions {\n /**\n * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>').\n * For color tokens (#name), this is auto-set to '<color>' and cannot be overridden.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax\n */\n syntax?: string;\n /**\n * Whether the property inherits from parent elements\n * @default true\n */\n inherits?: boolean;\n /**\n * Initial value for the property.\n * For color tokens (#name), this defaults to 'transparent' if not specified.\n */\n initialValue?: string | number;\n /**\n * Shadow root or document to inject into\n */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Hook to register a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * The hook ensures the property is only registered once per root.\n *\n * Accepts tasty token syntax for the property name:\n * - `$name` → defines `--name`\n * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')\n * - `--name` → defines `--name` (legacy format)\n *\n * @param name - The property token ($name, #name) or CSS property name (--name)\n * @param options - Property configuration\n *\n * @example Basic property with token syntax\n * ```tsx\n * function Spinner() {\n * useProperty('$rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n *\n * return <div className=\"spinner\" />;\n * }\n * ```\n *\n * @example Color property with token syntax (auto-sets syntax)\n * ```tsx\n * function MyComponent() {\n * useProperty('#theme', {\n * initialValue: 'red', // syntax: '<color>' is auto-set\n * });\n *\n * // Now --theme-color can be animated with CSS transitions\n * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;\n * }\n * ```\n *\n * @example Legacy format (still supported)\n * ```tsx\n * function ResizableBox() {\n * useProperty('--box-size', {\n * syntax: '<length>',\n * initialValue: '100px',\n * });\n *\n * return <div style={{ width: 'var(--box-size)' }} />;\n * }\n * ```\n */\nexport function useProperty(name: string, options?: UsePropertyOptions): void {\n const ssrContextValue = useContext(TastySSRContext);\n const ssrCollector = resolveSSRCollector(ssrContextValue);\n\n // Memoize the options to create a stable dependency\n const optionsKey = useMemo(() => {\n if (!options) return '';\n return JSON.stringify({\n syntax: options.syntax,\n inherits: options.inherits,\n initialValue: options.initialValue,\n });\n }, [options?.syntax, options?.inherits, options?.initialValue]);\n\n // SSR path: collect @property CSS during render\n useMemo(() => {\n if (!ssrCollector || !name) return;\n\n ssrCollector.collectInternals();\n\n const css = formatPropertyCSS(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n });\n if (css) {\n ssrCollector.collectProperty(name, css);\n }\n }, [ssrCollector, name, optionsKey]);\n\n // Client path: inject via DOM\n useInsertionEffect(() => {\n if (!name) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Tasty] useProperty: property name is required`);\n }\n return;\n }\n\n const injector = getGlobalInjector();\n\n if (injector.isPropertyDefined(name, { root: options?.root })) {\n return;\n }\n\n injector.property(name, {\n syntax: options?.syntax,\n inherits: options?.inherits,\n initialValue: options?.initialValue,\n root: options?.root,\n });\n }, [name, optionsKey, options?.root]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAgB,YAAY,MAAc,SAAoC;CAE5E,MAAM,eAAe,oBADG,WAAW,gBAAgB,CACM;CAGzD,MAAM,aAAa,cAAc;AAC/B,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,KAAK,UAAU;GACpB,QAAQ,QAAQ;GAChB,UAAU,QAAQ;GAClB,cAAc,QAAQ;GACvB,CAAC;IACD;EAAC,SAAS;EAAQ,SAAS;EAAU,SAAS;EAAa,CAAC;AAG/D,eAAc;AACZ,MAAI,CAAC,gBAAgB,CAAC,KAAM;AAE5B,eAAa,kBAAkB;EAE/B,MAAM,MAAM,kBAAkB,MAAM;GAClC,QAAQ,SAAS;GACjB,UAAU,SAAS;GACnB,cAAc,SAAS;GACxB,CAAC;AACF,MAAI,IACF,cAAa,gBAAgB,MAAM,IAAI;IAExC;EAAC;EAAc;EAAM;EAAW,CAAC;AAGpC,0BAAyB;AACvB,MAAI,CAAC,MAAM;AAEP,WAAQ,KAAK,iDAAiD;AAEhE;;EAGF,MAAM,WAAW,mBAAmB;AAEpC,MAAI,SAAS,kBAAkB,MAAM,EAAE,MAAM,SAAS,MAAM,CAAC,CAC3D;AAGF,WAAS,SAAS,MAAM;GACtB,QAAQ,SAAS;GACjB,UAAU,SAAS;GACnB,cAAc,SAAS;GACvB,MAAM,SAAS;GAChB,CAAC;IACD;EAAC;EAAM;EAAY,SAAS;EAAK,CAAC"}
@@ -1,53 +0,0 @@
1
- //#region src/hooks/useRawCSS.d.ts
2
- interface UseRawCSSOptions {
3
- root?: Document | ShadowRoot;
4
- }
5
- /**
6
- * Hook to inject raw CSS text directly without parsing.
7
- * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
8
- *
9
- * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
10
- * with tasty's chunked style sheets.
11
- *
12
- * @example Static CSS string
13
- * ```tsx
14
- * function GlobalStyles() {
15
- * useRawCSS(`
16
- * body {
17
- * margin: 0;
18
- * padding: 0;
19
- * font-family: sans-serif;
20
- * }
21
- * `);
22
- *
23
- * return null;
24
- * }
25
- * ```
26
- *
27
- * @example Factory function with dependencies (like useMemo)
28
- * ```tsx
29
- * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
30
- * useRawCSS(() => `
31
- * :root {
32
- * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
33
- * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
34
- * }
35
- * `, [theme]);
36
- *
37
- * return null;
38
- * }
39
- * ```
40
- *
41
- * @example With options
42
- * ```tsx
43
- * function ShadowStyles({ shadowRoot }) {
44
- * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
45
- * return null;
46
- * }
47
- * ```
48
- */
49
- declare function useRawCSS(css: string, options?: UseRawCSSOptions): void;
50
- declare function useRawCSS(factory: () => string, deps: readonly unknown[], options?: UseRawCSSOptions): void;
51
- //#endregion
52
- export { useRawCSS };
53
- //# sourceMappingURL=useRawCSS.d.ts.map
@@ -1,35 +0,0 @@
1
- import { injectRawCSS } from "../injector/index.js";
2
- import { TastySSRContext } from "../ssr/context.js";
3
- import { resolveSSRCollector } from "./resolve-ssr-collector.js";
4
- import { useContext, useInsertionEffect, useMemo, useRef } from "react";
5
- //#region src/hooks/useRawCSS.ts
6
- function useRawCSS(cssOrFactory, depsOrOptions, options) {
7
- const ssrCollector = resolveSSRCollector(useContext(TastySSRContext));
8
- const isFactory = typeof cssOrFactory === "function";
9
- const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
10
- const opts = isFactory ? options : depsOrOptions;
11
- const css = useMemo(() => isFactory ? cssOrFactory() : cssOrFactory, isFactory ? deps ?? [] : [cssOrFactory]);
12
- useMemo(() => {
13
- if (!ssrCollector || !css.trim()) return;
14
- const key = `raw:${css.length}:${css.slice(0, 64)}`;
15
- ssrCollector.collectRawCSS(key, css);
16
- }, [ssrCollector, css]);
17
- const disposeRef = useRef(null);
18
- useInsertionEffect(() => {
19
- disposeRef.current?.();
20
- if (!css.trim()) {
21
- disposeRef.current = null;
22
- return;
23
- }
24
- const { dispose } = injectRawCSS(css, opts);
25
- disposeRef.current = dispose;
26
- return () => {
27
- disposeRef.current?.();
28
- disposeRef.current = null;
29
- };
30
- }, [css, opts?.root]);
31
- }
32
- //#endregion
33
- export { useRawCSS };
34
-
35
- //# sourceMappingURL=useRawCSS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRawCSS.js","names":[],"sources":["../../src/hooks/useRawCSS.ts"],"sourcesContent":["import { useContext, useInsertionEffect, useMemo, useRef } from 'react';\n\nimport { injectRawCSS } from '../injector';\nimport { resolveSSRCollector } from './resolve-ssr-collector';\nimport { TastySSRContext } from '../ssr/context';\n\ninterface UseRawCSSOptions {\n root?: Document | ShadowRoot;\n}\n\n/**\n * Hook to inject raw CSS text directly without parsing.\n * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.\n *\n * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts\n * with tasty's chunked style sheets.\n *\n * @example Static CSS string\n * ```tsx\n * function GlobalStyles() {\n * useRawCSS(`\n * body {\n * margin: 0;\n * padding: 0;\n * font-family: sans-serif;\n * }\n * `);\n *\n * return null;\n * }\n * ```\n *\n * @example Factory function with dependencies (like useMemo)\n * ```tsx\n * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {\n * useRawCSS(() => `\n * :root {\n * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};\n * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};\n * }\n * `, [theme]);\n *\n * return null;\n * }\n * ```\n *\n * @example With options\n * ```tsx\n * function ShadowStyles({ shadowRoot }) {\n * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });\n * return null;\n * }\n * ```\n */\n\n// Overload 1: Static CSS string\nexport function useRawCSS(css: string, options?: UseRawCSSOptions): void;\n\n// Overload 2: Factory function with dependencies\nexport function useRawCSS(\n factory: () => string,\n deps: readonly unknown[],\n options?: UseRawCSSOptions,\n): void;\n\n// Implementation\nexport function useRawCSS(\n cssOrFactory: string | (() => string),\n depsOrOptions?: readonly unknown[] | UseRawCSSOptions,\n options?: UseRawCSSOptions,\n): void {\n const ssrContextValue = useContext(TastySSRContext);\n const ssrCollector = resolveSSRCollector(ssrContextValue);\n\n // Detect which overload is being used\n const isFactory = typeof cssOrFactory === 'function';\n\n // Parse arguments based on overload\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseRawCSSOptions | undefined);\n\n // Memoize CSS - for factory functions, use provided deps; for strings, use the string itself\n const css = useMemo(\n () =>\n isFactory ? (cssOrFactory as () => string)() : (cssOrFactory as string),\n\n isFactory ? (deps ?? []) : [cssOrFactory],\n );\n\n // SSR path: collect raw CSS during render\n useMemo(() => {\n if (!ssrCollector || !css.trim()) return;\n\n const key = `raw:${css.length}:${css.slice(0, 64)}`;\n ssrCollector.collectRawCSS(key, css);\n }, [ssrCollector, css]);\n\n const disposeRef = useRef<(() => void) | null>(null);\n\n // Client path: inject via DOM\n useInsertionEffect(() => {\n disposeRef.current?.();\n\n if (!css.trim()) {\n disposeRef.current = null;\n return;\n }\n\n const { dispose } = injectRawCSS(css, opts);\n disposeRef.current = dispose;\n\n return () => {\n disposeRef.current?.();\n disposeRef.current = null;\n };\n }, [css, opts?.root]);\n}\n"],"mappings":";;;;;AAkEA,SAAgB,UACd,cACA,eACA,SACM;CAEN,MAAM,eAAe,oBADG,WAAW,gBAAgB,CACM;CAGzD,MAAM,YAAY,OAAO,iBAAiB;CAG1C,MAAM,OACJ,aAAa,MAAM,QAAQ,cAAc,GAAG,gBAAgB,KAAA;CAC9D,MAAM,OAAO,YACT,UACC;CAGL,MAAM,MAAM,cAER,YAAa,cAA+B,GAAI,cAElD,YAAa,QAAQ,EAAE,GAAI,CAAC,aAAa,CAC1C;AAGD,eAAc;AACZ,MAAI,CAAC,gBAAgB,CAAC,IAAI,MAAM,CAAE;EAElC,MAAM,MAAM,OAAO,IAAI,OAAO,GAAG,IAAI,MAAM,GAAG,GAAG;AACjD,eAAa,cAAc,KAAK,IAAI;IACnC,CAAC,cAAc,IAAI,CAAC;CAEvB,MAAM,aAAa,OAA4B,KAAK;AAGpD,0BAAyB;AACvB,aAAW,WAAW;AAEtB,MAAI,CAAC,IAAI,MAAM,EAAE;AACf,cAAW,UAAU;AACrB;;EAGF,MAAM,EAAE,YAAY,aAAa,KAAK,KAAK;AAC3C,aAAW,UAAU;AAErB,eAAa;AACX,cAAW,WAAW;AACtB,cAAW,UAAU;;IAEtB,CAAC,KAAK,MAAM,KAAK,CAAC"}
@@ -1,40 +0,0 @@
1
- import { Styles } from "../styles/types.js";
2
-
3
- //#region src/hooks/useStyles.d.ts
4
- /**
5
- * Tasty styles object to generate CSS classes for.
6
- * Can be undefined or empty object for no styles.
7
- */
8
- type UseStylesOptions = Styles | undefined;
9
- interface UseStylesResult {
10
- /**
11
- * Generated className(s) to apply to the element.
12
- * Can be empty string if no styles are provided.
13
- * With chunking enabled, may contain multiple space-separated class names.
14
- */
15
- className: string;
16
- }
17
- /**
18
- * Hook to generate CSS classes from Tasty styles.
19
- * Thin wrapper around `computeStyles()` that adds React context-based
20
- * SSR collector discovery for backward compatibility with TastyRegistry.
21
- *
22
- * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
23
- *
24
- * @example
25
- * ```tsx
26
- * function MyComponent() {
27
- * const { className } = useStyles({
28
- * padding: '2x',
29
- * fill: '#purple',
30
- * radius: '1r',
31
- * });
32
- *
33
- * return <div className={className}>Styled content</div>;
34
- * }
35
- * ```
36
- */
37
- declare function useStyles(styles: UseStylesOptions): UseStylesResult;
38
- //#endregion
39
- export { UseStylesOptions, UseStylesResult, useStyles };
40
- //# sourceMappingURL=useStyles.d.ts.map
@@ -1,31 +0,0 @@
1
- import { computeStyles } from "../compute-styles.js";
2
- import { TastySSRContext } from "../ssr/context.js";
3
- import { useContext } from "react";
4
- //#region src/hooks/useStyles.ts
5
- /**
6
- * Hook to generate CSS classes from Tasty styles.
7
- * Thin wrapper around `computeStyles()` that adds React context-based
8
- * SSR collector discovery for backward compatibility with TastyRegistry.
9
- *
10
- * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
11
- *
12
- * @example
13
- * ```tsx
14
- * function MyComponent() {
15
- * const { className } = useStyles({
16
- * padding: '2x',
17
- * fill: '#purple',
18
- * radius: '1r',
19
- * });
20
- *
21
- * return <div className={className}>Styled content</div>;
22
- * }
23
- * ```
24
- */
25
- function useStyles(styles) {
26
- return computeStyles(styles, { ssrCollector: useContext(TastySSRContext) });
27
- }
28
- //#endregion
29
- export { useStyles };
30
-
31
- //# sourceMappingURL=useStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useStyles.js","names":[],"sources":["../../src/hooks/useStyles.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { computeStyles } from '../compute-styles';\nimport type { ServerStyleCollector } from '../ssr/collector';\nimport { TastySSRContext } from '../ssr/context';\nimport type { Styles } from '../styles/types';\n\n/**\n * Tasty styles object to generate CSS classes for.\n * Can be undefined or empty object for no styles.\n */\nexport type UseStylesOptions = Styles | undefined;\n\nexport interface UseStylesResult {\n /**\n * Generated className(s) to apply to the element.\n * Can be empty string if no styles are provided.\n * With chunking enabled, may contain multiple space-separated class names.\n */\n className: string;\n}\n\n/**\n * Hook to generate CSS classes from Tasty styles.\n * Thin wrapper around `computeStyles()` that adds React context-based\n * SSR collector discovery for backward compatibility with TastyRegistry.\n *\n * For hook-free usage (e.g. in server components), use `computeStyles()` directly.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { className } = useStyles({\n * padding: '2x',\n * fill: '#purple',\n * radius: '1r',\n * });\n *\n * return <div className={className}>Styled content</div>;\n * }\n * ```\n */\nexport function useStyles(styles: UseStylesOptions): UseStylesResult {\n const ssrContextValue: ServerStyleCollector | null =\n useContext(TastySSRContext);\n\n return computeStyles(styles, {\n ssrCollector: ssrContextValue,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,UAAU,QAA2C;AAInE,QAAO,cAAc,QAAQ,EAC3B,cAHA,WAAW,gBAAgB,EAI5B,CAAC"}