@tenphi/tasty 0.0.0-snapshot.2705ab9 → 0.0.0-snapshot.275370e

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 (296) hide show
  1. package/README.md +26 -20
  2. package/dist/_virtual/_rolldown/runtime.js +1 -2
  3. package/dist/chunks/cacheKey.d.ts +1 -0
  4. package/dist/chunks/cacheKey.js +1 -2
  5. package/dist/chunks/cacheKey.js.map +1 -1
  6. package/dist/chunks/definitions.js +1 -2
  7. package/dist/chunks/definitions.js.map +1 -1
  8. package/dist/chunks/index.d.ts +1 -0
  9. package/dist/chunks/renderChunk.d.ts +1 -0
  10. package/dist/chunks/renderChunk.js +1 -2
  11. package/dist/chunks/renderChunk.js.map +1 -1
  12. package/dist/compute-styles.d.ts +31 -0
  13. package/dist/compute-styles.js +322 -0
  14. package/dist/compute-styles.js.map +1 -0
  15. package/dist/config.d.ts +61 -20
  16. package/dist/config.js +119 -32
  17. package/dist/config.js.map +1 -1
  18. package/dist/core/index.d.ts +6 -6
  19. package/dist/core/index.js +7 -7
  20. package/dist/counter-style/index.js +1 -1
  21. package/dist/counter-style/index.js.map +1 -1
  22. package/dist/debug.js +5 -6
  23. package/dist/debug.js.map +1 -1
  24. package/dist/font-face/index.js +1 -1
  25. package/dist/font-face/index.js.map +1 -1
  26. package/dist/hooks/index.d.ts +7 -0
  27. package/dist/hooks/useCounterStyle.d.ts +3 -17
  28. package/dist/hooks/useCounterStyle.js +56 -38
  29. package/dist/hooks/useCounterStyle.js.map +1 -1
  30. package/dist/hooks/useFontFace.d.ts +3 -1
  31. package/dist/hooks/useFontFace.js +22 -27
  32. package/dist/hooks/useFontFace.js.map +1 -1
  33. package/dist/hooks/useGlobalStyles.d.ts +18 -2
  34. package/dist/hooks/useGlobalStyles.js +52 -43
  35. package/dist/hooks/useGlobalStyles.js.map +1 -1
  36. package/dist/hooks/useKeyframes.d.ts +4 -2
  37. package/dist/hooks/useKeyframes.js +43 -53
  38. package/dist/hooks/useKeyframes.js.map +1 -1
  39. package/dist/hooks/useProperty.d.ts +4 -2
  40. package/dist/hooks/useProperty.js +30 -44
  41. package/dist/hooks/useProperty.js.map +1 -1
  42. package/dist/hooks/useRawCSS.d.ts +13 -44
  43. package/dist/hooks/useRawCSS.js +91 -24
  44. package/dist/hooks/useRawCSS.js.map +1 -1
  45. package/dist/hooks/useStyles.d.ts +3 -8
  46. package/dist/hooks/useStyles.js +7 -214
  47. package/dist/hooks/useStyles.js.map +1 -1
  48. package/dist/index.d.ts +7 -7
  49. package/dist/index.js +8 -8
  50. package/dist/injector/index.d.ts +18 -19
  51. package/dist/injector/index.js +25 -20
  52. package/dist/injector/index.js.map +1 -1
  53. package/dist/injector/injector.d.ts +35 -3
  54. package/dist/injector/injector.js +200 -14
  55. package/dist/injector/injector.js.map +1 -1
  56. package/dist/injector/sheet-manager.d.ts +9 -13
  57. package/dist/injector/sheet-manager.js +34 -69
  58. package/dist/injector/sheet-manager.js.map +1 -1
  59. package/dist/injector/types.d.ts +52 -21
  60. package/dist/keyframes/index.js +1 -1
  61. package/dist/parser/classify.js +1 -2
  62. package/dist/parser/classify.js.map +1 -1
  63. package/dist/parser/const.js +14 -3
  64. package/dist/parser/const.js.map +1 -1
  65. package/dist/parser/lru.js +1 -1
  66. package/dist/parser/lru.js.map +1 -1
  67. package/dist/parser/parser.js +1 -2
  68. package/dist/parser/parser.js.map +1 -1
  69. package/dist/parser/tokenizer.js +1 -1
  70. package/dist/parser/tokenizer.js.map +1 -1
  71. package/dist/parser/types.js +1 -1
  72. package/dist/parser/types.js.map +1 -1
  73. package/dist/pipeline/conditions.js +1 -1
  74. package/dist/pipeline/conditions.js.map +1 -1
  75. package/dist/pipeline/exclusive.js +58 -4
  76. package/dist/pipeline/exclusive.js.map +1 -1
  77. package/dist/pipeline/index.js +4 -5
  78. package/dist/pipeline/index.js.map +1 -1
  79. package/dist/pipeline/materialize.js +57 -4
  80. package/dist/pipeline/materialize.js.map +1 -1
  81. package/dist/pipeline/parseStateKey.js +5 -6
  82. package/dist/pipeline/parseStateKey.js.map +1 -1
  83. package/dist/pipeline/simplify.js +181 -7
  84. package/dist/pipeline/simplify.js.map +1 -1
  85. package/dist/pipeline/warnings.js +1 -1
  86. package/dist/plugins/index.d.ts +2 -0
  87. package/dist/plugins/okhsl-plugin.js +1 -2
  88. package/dist/plugins/okhsl-plugin.js.map +1 -1
  89. package/dist/plugins/types.d.ts +12 -1
  90. package/dist/properties/index.js +2 -3
  91. package/dist/properties/index.js.map +1 -1
  92. package/dist/properties/property-type-resolver.js +1 -2
  93. package/dist/properties/property-type-resolver.js.map +1 -1
  94. package/dist/rsc-cache.js +79 -0
  95. package/dist/rsc-cache.js.map +1 -0
  96. package/dist/ssr/astro-client.d.ts +1 -0
  97. package/dist/ssr/astro-client.js +19 -0
  98. package/dist/ssr/astro-client.js.map +1 -0
  99. package/dist/ssr/astro-middleware.d.ts +15 -0
  100. package/dist/ssr/astro-middleware.js +19 -0
  101. package/dist/ssr/astro-middleware.js.map +1 -0
  102. package/dist/ssr/astro.d.ts +89 -10
  103. package/dist/ssr/astro.js +113 -29
  104. package/dist/ssr/astro.js.map +1 -1
  105. package/dist/ssr/async-storage.js +15 -6
  106. package/dist/ssr/async-storage.js.map +1 -1
  107. package/dist/ssr/collect-auto-properties.js +29 -11
  108. package/dist/ssr/collect-auto-properties.js.map +1 -1
  109. package/dist/ssr/collector.d.ts +9 -13
  110. package/dist/ssr/collector.js +35 -27
  111. package/dist/ssr/collector.js.map +1 -1
  112. package/dist/ssr/context.js +4 -2
  113. package/dist/ssr/context.js.map +1 -1
  114. package/dist/ssr/format-global-rules.js +1 -1
  115. package/dist/ssr/format-keyframes.js +1 -2
  116. package/dist/ssr/format-keyframes.js.map +1 -1
  117. package/dist/ssr/format-property.js +1 -2
  118. package/dist/ssr/format-property.js.map +1 -1
  119. package/dist/ssr/format-rules.js +1 -1
  120. package/dist/ssr/hydrate.d.ts +20 -13
  121. package/dist/ssr/hydrate.js +25 -30
  122. package/dist/ssr/hydrate.js.map +1 -1
  123. package/dist/ssr/index.d.ts +3 -4
  124. package/dist/ssr/index.js +5 -7
  125. package/dist/ssr/index.js.map +1 -1
  126. package/dist/ssr/next.d.ts +6 -5
  127. package/dist/ssr/next.js +14 -10
  128. package/dist/ssr/next.js.map +1 -1
  129. package/dist/ssr/ssr-collector-ref.js +20 -3
  130. package/dist/ssr/ssr-collector-ref.js.map +1 -1
  131. package/dist/states/index.js +1 -2
  132. package/dist/states/index.js.map +1 -1
  133. package/dist/static/index.js +1 -2
  134. package/dist/static/inject.d.ts +5 -0
  135. package/dist/static/inject.js +17 -0
  136. package/dist/static/inject.js.map +1 -0
  137. package/dist/static/tastyStatic.js +1 -2
  138. package/dist/static/tastyStatic.js.map +1 -1
  139. package/dist/static/types.js +1 -1
  140. package/dist/styles/border.d.ts +1 -1
  141. package/dist/styles/border.js +28 -22
  142. package/dist/styles/border.js.map +1 -1
  143. package/dist/styles/color.d.ts +1 -1
  144. package/dist/styles/color.js +2 -3
  145. package/dist/styles/color.js.map +1 -1
  146. package/dist/styles/const.js +17 -0
  147. package/dist/styles/const.js.map +1 -0
  148. package/dist/styles/createStyle.js +4 -5
  149. package/dist/styles/createStyle.js.map +1 -1
  150. package/dist/styles/dimension.js +15 -3
  151. package/dist/styles/dimension.js.map +1 -1
  152. package/dist/styles/directional.js +133 -0
  153. package/dist/styles/directional.js.map +1 -0
  154. package/dist/styles/display.d.ts +3 -10
  155. package/dist/styles/display.js +45 -39
  156. package/dist/styles/display.js.map +1 -1
  157. package/dist/styles/fade.d.ts +1 -1
  158. package/dist/styles/fade.js +9 -5
  159. package/dist/styles/fade.js.map +1 -1
  160. package/dist/styles/fill.d.ts +2 -2
  161. package/dist/styles/fill.js +3 -4
  162. package/dist/styles/fill.js.map +1 -1
  163. package/dist/styles/flow.js +1 -1
  164. package/dist/styles/gap.d.ts +1 -1
  165. package/dist/styles/gap.js +4 -3
  166. package/dist/styles/gap.js.map +1 -1
  167. package/dist/styles/height.d.ts +1 -1
  168. package/dist/styles/height.js +1 -2
  169. package/dist/styles/height.js.map +1 -1
  170. package/dist/styles/index.d.ts +0 -1
  171. package/dist/styles/index.js +3 -4
  172. package/dist/styles/index.js.map +1 -1
  173. package/dist/styles/inset.d.ts +1 -29
  174. package/dist/styles/inset.js +19 -135
  175. package/dist/styles/inset.js.map +1 -1
  176. package/dist/styles/list.d.ts +5 -5
  177. package/dist/styles/list.js +4 -2
  178. package/dist/styles/list.js.map +1 -1
  179. package/dist/styles/margin.d.ts +1 -1
  180. package/dist/styles/margin.js +17 -89
  181. package/dist/styles/margin.js.map +1 -1
  182. package/dist/styles/outline.d.ts +1 -1
  183. package/dist/styles/outline.js +6 -16
  184. package/dist/styles/outline.js.map +1 -1
  185. package/dist/styles/padding.d.ts +1 -1
  186. package/dist/styles/padding.js +17 -89
  187. package/dist/styles/padding.js.map +1 -1
  188. package/dist/styles/placement.d.ts +37 -0
  189. package/dist/styles/placement.js +74 -0
  190. package/dist/styles/placement.js.map +1 -0
  191. package/dist/styles/predefined.d.ts +4 -4
  192. package/dist/styles/predefined.js +8 -9
  193. package/dist/styles/predefined.js.map +1 -1
  194. package/dist/styles/preset.d.ts +1 -1
  195. package/dist/styles/preset.js +7 -7
  196. package/dist/styles/preset.js.map +1 -1
  197. package/dist/styles/radius.d.ts +1 -3
  198. package/dist/styles/radius.js +38 -6
  199. package/dist/styles/radius.js.map +1 -1
  200. package/dist/styles/scrollMargin.d.ts +24 -0
  201. package/dist/styles/scrollMargin.js +32 -0
  202. package/dist/styles/scrollMargin.js.map +1 -0
  203. package/dist/styles/scrollbar.d.ts +1 -1
  204. package/dist/styles/scrollbar.js +8 -5
  205. package/dist/styles/scrollbar.js.map +1 -1
  206. package/dist/styles/shadow.d.ts +1 -1
  207. package/dist/styles/shadow.js +4 -3
  208. package/dist/styles/shadow.js.map +1 -1
  209. package/dist/styles/shared.js +17 -0
  210. package/dist/styles/shared.js.map +1 -0
  211. package/dist/styles/transition.d.ts +1 -1
  212. package/dist/styles/transition.js +5 -4
  213. package/dist/styles/transition.js.map +1 -1
  214. package/dist/styles/types.d.ts +24 -7
  215. package/dist/styles/width.d.ts +1 -1
  216. package/dist/styles/width.js +1 -2
  217. package/dist/styles/width.js.map +1 -1
  218. package/dist/tasty.d.ts +29 -14
  219. package/dist/tasty.js +78 -62
  220. package/dist/tasty.js.map +1 -1
  221. package/dist/utils/cache-wrapper.js +1 -2
  222. package/dist/utils/cache-wrapper.js.map +1 -1
  223. package/dist/utils/case-converter.js +1 -1
  224. package/dist/utils/color-math.js +1 -1
  225. package/dist/utils/color-math.js.map +1 -1
  226. package/dist/utils/color-space.js +1 -2
  227. package/dist/utils/color-space.js.map +1 -1
  228. package/dist/utils/colors.js +1 -2
  229. package/dist/utils/colors.js.map +1 -1
  230. package/dist/utils/deps-equal.js +15 -0
  231. package/dist/utils/deps-equal.js.map +1 -0
  232. package/dist/utils/dotize.js +1 -1
  233. package/dist/utils/dotize.js.map +1 -1
  234. package/dist/utils/filter-base-props.d.ts +1 -1
  235. package/dist/utils/filter-base-props.js +1 -1
  236. package/dist/utils/filter-base-props.js.map +1 -1
  237. package/dist/utils/get-display-name.js +1 -1
  238. package/dist/utils/has-keys.js +1 -1
  239. package/dist/utils/hash.js +14 -0
  240. package/dist/utils/hash.js.map +1 -0
  241. package/dist/utils/is-dev-env.js +1 -1
  242. package/dist/utils/is-dev-env.js.map +1 -1
  243. package/dist/utils/is-valid-element-type.js +1 -1
  244. package/dist/utils/merge-styles.js +1 -2
  245. package/dist/utils/merge-styles.js.map +1 -1
  246. package/dist/utils/mod-attrs.d.ts +0 -2
  247. package/dist/utils/mod-attrs.js +1 -2
  248. package/dist/utils/mod-attrs.js.map +1 -1
  249. package/dist/utils/process-tokens.d.ts +1 -5
  250. package/dist/utils/process-tokens.js +3 -11
  251. package/dist/utils/process-tokens.js.map +1 -1
  252. package/dist/utils/resolve-recipes.js +1 -2
  253. package/dist/utils/resolve-recipes.js.map +1 -1
  254. package/dist/utils/selector-transform.js +1 -1
  255. package/dist/utils/string.js +1 -1
  256. package/dist/utils/styles.d.ts +1 -1
  257. package/dist/utils/styles.js +2 -3
  258. package/dist/utils/styles.js.map +1 -1
  259. package/dist/utils/typography.d.ts +21 -10
  260. package/dist/utils/typography.js +2 -2
  261. package/dist/utils/typography.js.map +1 -1
  262. package/dist/utils/warnings.js +1 -1
  263. package/dist/zero/babel.d.ts +24 -110
  264. package/dist/zero/babel.js +130 -42
  265. package/dist/zero/babel.js.map +1 -1
  266. package/dist/zero/css-writer.js +1 -2
  267. package/dist/zero/css-writer.js.map +1 -1
  268. package/dist/zero/extractor.js +1 -2
  269. package/dist/zero/extractor.js.map +1 -1
  270. package/dist/zero/index.js +1 -2
  271. package/dist/zero/next.d.ts +12 -0
  272. package/dist/zero/next.js +5 -4
  273. package/dist/zero/next.js.map +1 -1
  274. package/docs/README.md +2 -2
  275. package/docs/adoption.md +5 -3
  276. package/docs/comparison.md +24 -25
  277. package/docs/configuration.md +69 -1
  278. package/docs/design-system.md +22 -10
  279. package/docs/dsl.md +23 -8
  280. package/docs/getting-started.md +10 -10
  281. package/docs/injector.md +41 -25
  282. package/docs/methodology.md +52 -3
  283. package/docs/{runtime.md → react-api.md} +104 -32
  284. package/docs/ssr.md +139 -81
  285. package/docs/styles.md +17 -0
  286. package/docs/tasty-static.md +101 -2
  287. package/package.json +20 -9
  288. package/dist/hooks/resolve-ssr-collector.js +0 -15
  289. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  290. package/dist/ssr/context.d.ts +0 -8
  291. package/dist/styles/align.d.ts +0 -15
  292. package/dist/styles/align.js +0 -14
  293. package/dist/styles/align.js.map +0 -1
  294. package/dist/styles/justify.d.ts +0 -15
  295. package/dist/styles/justify.js +0 -14
  296. package/dist/styles/justify.js.map +0 -1
@@ -1,36 +1,103 @@
1
+ import { hashString } from "../utils/hash.js";
1
2
  import { injectRawCSS } from "../injector/index.js";
2
- import { resolveSSRCollector } from "./resolve-ssr-collector.js";
3
- import { TastySSRContext } from "../ssr/context.js";
4
- import { useContext, useInsertionEffect, useMemo, useRef } from "react";
5
-
3
+ import { getStyleTarget, pushRSCCSS } from "../rsc-cache.js";
4
+ import { depsEqual } from "../utils/deps-equal.js";
6
5
  //#region src/hooks/useRawCSS.ts
6
+ const clientEntries = /* @__PURE__ */ new Map();
7
+ const clientContentDedup = /* @__PURE__ */ new Set();
8
+ const factoryDepsCache = /* @__PURE__ */ new Map();
9
+ /**
10
+ * Inject raw CSS text directly without parsing.
11
+ * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
12
+ *
13
+ * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
14
+ * with tasty's chunked style sheets.
15
+ *
16
+ * Works in all environments: client, SSR with collector, and React Server Components.
17
+ *
18
+ * Injected styles are permanent — they are not cleaned up on component unmount.
19
+ * Use the `id` option for update tracking when styles change over the
20
+ * component lifecycle.
21
+ *
22
+ * @example Static CSS string
23
+ * ```tsx
24
+ * function GlobalStyles() {
25
+ * useRawCSS(`
26
+ * body {
27
+ * margin: 0;
28
+ * padding: 0;
29
+ * font-family: sans-serif;
30
+ * }
31
+ * `);
32
+ *
33
+ * return null;
34
+ * }
35
+ * ```
36
+ *
37
+ * @example Factory function with dependencies
38
+ * ```tsx
39
+ * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
40
+ * useRawCSS(() => `
41
+ * :root {
42
+ * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
43
+ * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
44
+ * }
45
+ * `, [theme], { id: 'theme-vars' });
46
+ *
47
+ * return null;
48
+ * }
49
+ * ```
50
+ *
51
+ * @example With options
52
+ * ```tsx
53
+ * function ShadowStyles({ shadowRoot }) {
54
+ * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
55
+ * return null;
56
+ * }
57
+ * ```
58
+ */
7
59
  function useRawCSS(cssOrFactory, depsOrOptions, options) {
8
- const ssrCollector = resolveSSRCollector(useContext(TastySSRContext));
9
60
  const isFactory = typeof cssOrFactory === "function";
10
61
  const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
11
62
  const opts = isFactory ? options : depsOrOptions;
12
- const css = useMemo(() => isFactory ? cssOrFactory() : cssOrFactory, isFactory ? deps ?? [] : [cssOrFactory]);
13
- useMemo(() => {
14
- if (!ssrCollector || !css.trim()) return;
15
- const key = `raw:${css.length}:${css.slice(0, 64)}`;
16
- ssrCollector.collectRawCSS(key, css);
17
- }, [ssrCollector, css]);
18
- const disposeRef = useRef(null);
19
- useInsertionEffect(() => {
20
- disposeRef.current?.();
21
- if (!css.trim()) {
22
- disposeRef.current = null;
23
- return;
63
+ const target = getStyleTarget();
64
+ if (isFactory && deps && opts?.id && target.mode === "client") {
65
+ const cachedDeps = factoryDepsCache.get(opts.id);
66
+ if (cachedDeps && depsEqual(cachedDeps, deps)) return;
67
+ }
68
+ const css = isFactory ? cssOrFactory() : cssOrFactory;
69
+ if (!css.trim()) return;
70
+ if (target.mode === "ssr") {
71
+ const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;
72
+ target.collector.collectRawCSS(key, css);
73
+ return;
74
+ }
75
+ if (target.mode === "rsc") {
76
+ const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;
77
+ pushRSCCSS(target.cache, key, css);
78
+ return;
79
+ }
80
+ const id = opts?.id;
81
+ if (id) {
82
+ const existing = clientEntries.get(id);
83
+ if (existing) {
84
+ if (existing.contentKey === css) return;
85
+ existing.dispose();
24
86
  }
25
87
  const { dispose } = injectRawCSS(css, opts);
26
- disposeRef.current = dispose;
27
- return () => {
28
- disposeRef.current?.();
29
- disposeRef.current = null;
30
- };
31
- }, [css, opts?.root]);
88
+ clientEntries.set(id, {
89
+ contentKey: css,
90
+ dispose
91
+ });
92
+ if (deps) factoryDepsCache.set(id, deps);
93
+ } else {
94
+ const contentKey = hashString(css);
95
+ if (clientContentDedup.has(contentKey)) return;
96
+ clientContentDedup.add(contentKey);
97
+ injectRawCSS(css, opts);
98
+ }
32
99
  }
33
-
34
100
  //#endregion
35
101
  export { useRawCSS };
102
+
36
103
  //# sourceMappingURL=useRawCSS.js.map
@@ -1 +1 @@
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;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
+ {"version":3,"file":"useRawCSS.js","names":[],"sources":["../../src/hooks/useRawCSS.ts"],"sourcesContent":["import { injectRawCSS } from '../injector';\nimport { getStyleTarget, pushRSCCSS } from '../rsc-cache';\nimport { depsEqual } from '../utils/deps-equal';\nimport { hashString } from '../utils/hash';\n\ninterface UseRawCSSOptions {\n /**\n * Shadow root or document to inject into.\n * Note: `root` is not part of the update-tracking comparison — changing\n * only the root for the same id/content will not re-inject.\n */\n root?: Document | ShadowRoot;\n /**\n * Stable identifier for update tracking (client-only). When provided,\n * changing the CSS content will dispose the previous injection and inject\n * the new one. Without an id, deduplication is purely content-based (same\n * CSS is injected only once). In RSC mode, renders are single-pass so\n * update tracking does not apply.\n */\n id?: string;\n}\n\ninterface ClientEntry {\n contentKey: string;\n dispose: () => void;\n}\n\nconst clientEntries = new Map<string, ClientEntry>();\nconst clientContentDedup = new Set<string>();\nconst factoryDepsCache = new Map<string, readonly unknown[]>();\n\n/* @internal — used only for tests */\nexport function _resetRawCSSCache(): void {\n clientEntries.clear();\n clientContentDedup.clear();\n factoryDepsCache.clear();\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/**\n * 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 * Works in all environments: client, SSR with collector, and React Server Components.\n *\n * Injected styles are permanent — they are not cleaned up on component unmount.\n * Use the `id` option for update tracking when styles change over the\n * component lifecycle.\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\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], { id: 'theme-vars' });\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 */\nexport function useRawCSS(\n cssOrFactory: string | (() => string),\n depsOrOptions?: readonly unknown[] | UseRawCSSOptions,\n options?: UseRawCSSOptions,\n): void {\n const isFactory = typeof cssOrFactory === 'function';\n\n const deps =\n isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : undefined;\n const opts = isFactory\n ? options\n : (depsOrOptions as UseRawCSSOptions | undefined);\n\n const target = getStyleTarget();\n\n // Client deps cache: skip factory re-evaluation when deps haven't changed\n if (isFactory && deps && opts?.id && target.mode === 'client') {\n const cachedDeps = factoryDepsCache.get(opts.id);\n if (cachedDeps && depsEqual(cachedDeps, deps)) {\n return;\n }\n }\n\n const css = isFactory\n ? (cssOrFactory as () => string)()\n : (cssOrFactory as string);\n\n if (!css.trim()) return;\n\n if (target.mode === 'ssr') {\n const key = opts?.id ? `raw:${opts.id}` : `raw:${hashString(css)}`;\n target.collector.collectRawCSS(key, css);\n return;\n }\n\n if (target.mode === 'rsc') {\n const key = opts?.id ? `__raw:${opts.id}` : `__raw:${hashString(css)}`;\n pushRSCCSS(target.cache, key, css);\n return;\n }\n\n // Client path\n const id = opts?.id;\n\n if (id) {\n const existing = clientEntries.get(id);\n if (existing) {\n if (existing.contentKey === css) return;\n existing.dispose();\n }\n\n const { dispose } = injectRawCSS(css, opts);\n clientEntries.set(id, { contentKey: css, dispose });\n if (deps) factoryDepsCache.set(id, deps);\n } else {\n const contentKey = hashString(css);\n if (clientContentDedup.has(contentKey)) return;\n clientContentDedup.add(contentKey);\n injectRawCSS(css, opts);\n }\n}\n"],"mappings":";;;;;AA2BA,MAAM,gCAAgB,IAAI,KAA0B;AACpD,MAAM,qCAAqB,IAAI,KAAa;AAC5C,MAAM,mCAAmB,IAAI,KAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqE9D,SAAgB,UACd,cACA,eACA,SACM;CACN,MAAM,YAAY,OAAO,iBAAiB;CAE1C,MAAM,OACJ,aAAa,MAAM,QAAQ,cAAc,GAAG,gBAAgB,KAAA;CAC9D,MAAM,OAAO,YACT,UACC;CAEL,MAAM,SAAS,gBAAgB;AAG/B,KAAI,aAAa,QAAQ,MAAM,MAAM,OAAO,SAAS,UAAU;EAC7D,MAAM,aAAa,iBAAiB,IAAI,KAAK,GAAG;AAChD,MAAI,cAAc,UAAU,YAAY,KAAK,CAC3C;;CAIJ,MAAM,MAAM,YACP,cAA+B,GAC/B;AAEL,KAAI,CAAC,IAAI,MAAM,CAAE;AAEjB,KAAI,OAAO,SAAS,OAAO;EACzB,MAAM,MAAM,MAAM,KAAK,OAAO,KAAK,OAAO,OAAO,WAAW,IAAI;AAChE,SAAO,UAAU,cAAc,KAAK,IAAI;AACxC;;AAGF,KAAI,OAAO,SAAS,OAAO;EACzB,MAAM,MAAM,MAAM,KAAK,SAAS,KAAK,OAAO,SAAS,WAAW,IAAI;AACpE,aAAW,OAAO,OAAO,KAAK,IAAI;AAClC;;CAIF,MAAM,KAAK,MAAM;AAEjB,KAAI,IAAI;EACN,MAAM,WAAW,cAAc,IAAI,GAAG;AACtC,MAAI,UAAU;AACZ,OAAI,SAAS,eAAe,IAAK;AACjC,YAAS,SAAS;;EAGpB,MAAM,EAAE,YAAY,aAAa,KAAK,KAAK;AAC3C,gBAAc,IAAI,IAAI;GAAE,YAAY;GAAK;GAAS,CAAC;AACnD,MAAI,KAAM,kBAAiB,IAAI,IAAI,KAAK;QACnC;EACL,MAAM,aAAa,WAAW,IAAI;AAClC,MAAI,mBAAmB,IAAI,WAAW,CAAE;AACxC,qBAAmB,IAAI,WAAW;AAClC,eAAa,KAAK,KAAK"}
@@ -16,15 +16,10 @@ interface UseStylesResult {
16
16
  }
17
17
  /**
18
18
  * Hook to generate CSS classes from Tasty styles.
19
- * Handles style rendering, className allocation, and CSS injection.
19
+ * Thin wrapper around `computeStyles()` that adds React context-based
20
+ * SSR collector discovery for backward compatibility with TastyRegistry.
20
21
  *
21
- * SSR-aware: when a ServerStyleCollector is available (via React context
22
- * or AsyncLocalStorage), CSS is collected during the render phase instead
23
- * of being injected into the DOM. useInsertionEffect does not run on the
24
- * server, so the collector path is the only active path during SSR.
25
- *
26
- * Uses chunking to split styles into logical groups for better caching
27
- * and CSS reuse across components.
22
+ * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
28
23
  *
29
24
  * @example
30
25
  * ```tsx
@@ -1,105 +1,13 @@
1
- import { extractLocalProperties, hasLocalProperties } from "../properties/index.js";
2
- import { stringifyStyles } from "../utils/styles.js";
3
- import { extractLocalFontFace, fontFaceContentHash, formatFontFaceRule, hasLocalFontFace } from "../font-face/index.js";
4
- import { extractLocalCounterStyle, formatCounterStyleRule, hasLocalCounterStyle } from "../counter-style/index.js";
5
- import { getConfig, getGlobalKeyframes, hasGlobalKeyframes } from "../config.js";
6
- import { categorizeStyleKeys } from "../chunks/definitions.js";
7
- import { generateChunkCacheKey } from "../chunks/cacheKey.js";
8
- import { renderStylesForChunk } from "../chunks/renderChunk.js";
9
- import { allocateClassName, counterStyle, fontFace, inject, keyframes, property } from "../injector/index.js";
10
- import { resolveRecipes } from "../utils/resolve-recipes.js";
11
- import { extractAnimationNamesFromStyles, extractLocalKeyframes, filterUsedKeyframes, hasLocalKeyframes, mergeKeyframes, replaceAnimationNames } from "../keyframes/index.js";
12
- import { formatPropertyCSS } from "../ssr/format-property.js";
13
- import { collectAutoInferredProperties } from "../ssr/collect-auto-properties.js";
14
- import { resolveSSRCollector } from "./resolve-ssr-collector.js";
1
+ import { computeStyles } from "../compute-styles.js";
15
2
  import { TastySSRContext } from "../ssr/context.js";
16
- import { formatKeyframesCSS } from "../ssr/format-keyframes.js";
17
- import { hasKeys } from "../utils/has-keys.js";
18
- import { useContext, useInsertionEffect, useMemo, useRef } from "react";
19
-
3
+ import { useContext } from "react";
20
4
  //#region src/hooks/useStyles.ts
21
5
  /**
22
- * Render, cache-key, and allocate a className for a single chunk.
23
- * Returns a ProcessedChunk, or null if the chunk produces no CSS rules.
24
- *
25
- * Always runs the pipeline and calls allocateClassName. The inject()
26
- * call in useInsertionEffect handles all edge cases: placeholders from
27
- * abandoned concurrent renders, hydration hits (ruleIndex -2), and
28
- * runtime cache hits (already injected). The pipeline's own LRU cache
29
- * makes repeated calls for identical styles cheap.
30
- */
31
- function processChunk(styles, chunkName, styleKeys) {
32
- if (styleKeys.length === 0) return null;
33
- const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
34
- const renderResult = renderStylesForChunk(styles, chunkName, styleKeys, cacheKey);
35
- if (renderResult.rules.length === 0) return null;
36
- const { className } = allocateClassName(cacheKey);
37
- return {
38
- name: chunkName,
39
- styleKeys,
40
- cacheKey,
41
- renderResult,
42
- className
43
- };
44
- }
45
- /**
46
- * Get keyframes that are actually used in styles.
47
- * Returns null if no keyframes are used (fast path for zero overhead).
48
- *
49
- * Optimization order:
50
- * 1. Check if any keyframes are defined (local or global) - if not, return null
51
- * 2. Extract animation names from styles - if none, return null
52
- * 3. Merge and filter keyframes to only used ones
53
- */
54
- function getUsedKeyframes(styles) {
55
- const hasLocal = hasLocalKeyframes(styles);
56
- const hasGlobal = hasGlobalKeyframes();
57
- if (!hasLocal && !hasGlobal) return null;
58
- const usedNames = extractAnimationNamesFromStyles(styles);
59
- if (usedNames.size === 0) return null;
60
- return filterUsedKeyframes(mergeKeyframes(hasLocal ? extractLocalKeyframes(styles) : null, hasGlobal ? getGlobalKeyframes() : null), usedNames);
61
- }
62
- /**
63
- * Process a chunk on the SSR path: allocate via collector, render, collect CSS.
64
- * Returns null if the chunk produces no CSS rules.
65
- */
66
- function processChunkSSR(collector, styles, chunkName, styleKeys) {
67
- if (styleKeys.length === 0) return null;
68
- const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);
69
- const { className, isNewAllocation } = collector.allocateClassName(cacheKey);
70
- if (isNewAllocation) {
71
- const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);
72
- if (renderResult.rules.length > 0) {
73
- collector.collectChunk(cacheKey, className, renderResult.rules);
74
- return {
75
- name: chunkName,
76
- styleKeys,
77
- cacheKey,
78
- renderResult,
79
- className
80
- };
81
- }
82
- return null;
83
- }
84
- return {
85
- name: chunkName,
86
- styleKeys,
87
- cacheKey,
88
- renderResult: { rules: [] },
89
- className
90
- };
91
- }
92
- /**
93
6
  * Hook to generate CSS classes from Tasty styles.
94
- * Handles style rendering, className allocation, and CSS injection.
7
+ * Thin wrapper around `computeStyles()` that adds React context-based
8
+ * SSR collector discovery for backward compatibility with TastyRegistry.
95
9
  *
96
- * SSR-aware: when a ServerStyleCollector is available (via React context
97
- * or AsyncLocalStorage), CSS is collected during the render phase instead
98
- * of being injected into the DOM. useInsertionEffect does not run on the
99
- * server, so the collector path is the only active path during SSR.
100
- *
101
- * Uses chunking to split styles into logical groups for better caching
102
- * and CSS reuse across components.
10
+ * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
103
11
  *
104
12
  * @example
105
13
  * ```tsx
@@ -115,124 +23,9 @@ function processChunkSSR(collector, styles, chunkName, styleKeys) {
115
23
  * ```
116
24
  */
117
25
  function useStyles(styles) {
118
- const ssrCollector = resolveSSRCollector(useContext(TastySSRContext));
119
- const disposeRef = useRef([]);
120
- const stylesRef = useRef({
121
- key: "",
122
- styles: void 0
123
- });
124
- const resolvedStyles = useMemo(() => {
125
- if (!styles) return styles;
126
- return resolveRecipes(styles);
127
- }, [styles]);
128
- const styleKey = useMemo(() => {
129
- if (!resolvedStyles || !hasKeys(resolvedStyles)) return "";
130
- return stringifyStyles(resolvedStyles);
131
- }, [resolvedStyles]);
132
- if (stylesRef.current.key !== styleKey) stylesRef.current = {
133
- key: styleKey,
134
- styles: resolvedStyles
135
- };
136
- const processedChunks = useMemo(() => {
137
- const currentStyles = stylesRef.current.styles;
138
- if (!styleKey || !currentStyles) return [];
139
- const chunkMap = categorizeStyleKeys(currentStyles);
140
- const chunks = [];
141
- if (ssrCollector) {
142
- ssrCollector.collectInternals();
143
- for (const [chunkName, chunkStyleKeys] of chunkMap) {
144
- const chunk = processChunkSSR(ssrCollector, currentStyles, chunkName, chunkStyleKeys);
145
- if (chunk) chunks.push(chunk);
146
- }
147
- const usedKeyframes = getUsedKeyframes(currentStyles);
148
- if (usedKeyframes) for (const [name, steps] of Object.entries(usedKeyframes)) {
149
- const css = formatKeyframesCSS(name, steps);
150
- ssrCollector.collectKeyframes(name, css);
151
- }
152
- if (hasLocalProperties(currentStyles)) {
153
- const localProperties = extractLocalProperties(currentStyles);
154
- if (localProperties) for (const [token, definition] of Object.entries(localProperties)) {
155
- const css = formatPropertyCSS(token, definition);
156
- if (css) ssrCollector.collectProperty(token, css);
157
- }
158
- }
159
- if (hasLocalFontFace(currentStyles)) {
160
- const localFontFace = extractLocalFontFace(currentStyles);
161
- if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
162
- const descriptors = Array.isArray(input) ? input : [input];
163
- for (const desc of descriptors) {
164
- const hash = fontFaceContentHash(family, desc);
165
- const css = formatFontFaceRule(family, desc);
166
- ssrCollector.collectFontFace(hash, css);
167
- }
168
- }
169
- }
170
- if (hasLocalCounterStyle(currentStyles)) {
171
- const localCounterStyle = extractLocalCounterStyle(currentStyles);
172
- if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) {
173
- const css = formatCounterStyleRule(name, descriptors);
174
- ssrCollector.collectCounterStyle(name, css);
175
- }
176
- }
177
- if (getConfig().autoPropertyTypes !== false) {
178
- const allRules = chunks.flatMap((c) => c.renderResult.rules);
179
- if (allRules.length > 0) collectAutoInferredProperties(allRules, ssrCollector, currentStyles);
180
- }
181
- } else for (const [chunkName, chunkStyleKeys] of chunkMap) {
182
- const chunk = processChunk(currentStyles, chunkName, chunkStyleKeys);
183
- if (chunk) chunks.push(chunk);
184
- }
185
- return chunks;
186
- }, [styleKey]);
187
- useInsertionEffect(() => {
188
- disposeRef.current.forEach((dispose) => dispose?.());
189
- disposeRef.current = [];
190
- if (processedChunks.length === 0) return;
191
- const currentStyles = stylesRef.current.styles;
192
- if (currentStyles && hasLocalProperties(currentStyles)) {
193
- const localProperties = extractLocalProperties(currentStyles);
194
- if (localProperties) for (const [token, definition] of Object.entries(localProperties)) property(token, definition);
195
- }
196
- if (currentStyles && hasLocalFontFace(currentStyles)) {
197
- const localFontFace = extractLocalFontFace(currentStyles);
198
- if (localFontFace) for (const [family, input] of Object.entries(localFontFace)) {
199
- const descriptors = Array.isArray(input) ? input : [input];
200
- for (const desc of descriptors) fontFace(family, desc);
201
- }
202
- }
203
- if (currentStyles && hasLocalCounterStyle(currentStyles)) {
204
- const localCounterStyle = extractLocalCounterStyle(currentStyles);
205
- if (localCounterStyle) for (const [name, descriptors] of Object.entries(localCounterStyle)) counterStyle(name, descriptors);
206
- }
207
- const usedKeyframes = currentStyles ? getUsedKeyframes(currentStyles) : null;
208
- let nameMap = null;
209
- if (usedKeyframes) {
210
- nameMap = /* @__PURE__ */ new Map();
211
- for (const [name, steps] of Object.entries(usedKeyframes)) {
212
- const result = keyframes(steps, { name });
213
- const injectedName = result.toString();
214
- if (injectedName !== name) nameMap.set(name, injectedName);
215
- disposeRef.current.push(result.dispose);
216
- }
217
- if (nameMap.size === 0) nameMap = null;
218
- }
219
- for (const chunk of processedChunks) if (chunk.renderResult.rules.length > 0) {
220
- const { dispose } = inject(nameMap ? chunk.renderResult.rules.map((rule) => ({
221
- ...rule,
222
- declarations: replaceAnimationNames(rule.declarations, nameMap)
223
- })) : chunk.renderResult.rules, { cacheKey: chunk.cacheKey });
224
- disposeRef.current.push(dispose);
225
- }
226
- return () => {
227
- disposeRef.current.forEach((dispose) => dispose?.());
228
- disposeRef.current = [];
229
- };
230
- }, [processedChunks]);
231
- return { className: useMemo(() => {
232
- return processedChunks.map((chunk) => chunk.className).join(" ");
233
- }, [processedChunks]) };
26
+ return computeStyles(styles, { ssrCollector: useContext(TastySSRContext) });
234
27
  }
235
-
236
28
  //#endregion
237
29
  export { useStyles };
30
+
238
31
  //# sourceMappingURL=useStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStyles.js","names":[],"sources":["../../src/hooks/useStyles.ts"],"sourcesContent":["import { useContext, useInsertionEffect, useMemo, useRef } from 'react';\n\nimport {\n categorizeStyleKeys,\n generateChunkCacheKey,\n renderStylesForChunk,\n} from '../chunks';\nimport { getConfig, getGlobalKeyframes, hasGlobalKeyframes } from '../config';\nimport {\n allocateClassName,\n counterStyle,\n fontFace,\n inject,\n keyframes,\n property,\n} from '../injector';\nimport type { FontFaceDescriptors, KeyframesSteps } from '../injector/types';\nimport {\n extractLocalCounterStyle,\n formatCounterStyleRule,\n hasLocalCounterStyle,\n} from '../counter-style';\nimport {\n extractLocalFontFace,\n fontFaceContentHash,\n formatFontFaceRule,\n hasLocalFontFace,\n} from '../font-face';\nimport {\n extractAnimationNamesFromStyles,\n extractLocalKeyframes,\n filterUsedKeyframes,\n hasLocalKeyframes,\n mergeKeyframes,\n replaceAnimationNames,\n} from '../keyframes';\nimport type { RenderResult } from '../pipeline';\nimport { extractLocalProperties, hasLocalProperties } from '../properties';\nimport { collectAutoInferredProperties } from '../ssr/collect-auto-properties';\nimport type { ServerStyleCollector } from '../ssr/collector';\nimport { resolveSSRCollector } from './resolve-ssr-collector';\nimport { TastySSRContext } from '../ssr/context';\nimport { formatKeyframesCSS } from '../ssr/format-keyframes';\nimport { formatPropertyCSS } from '../ssr/format-property';\nimport type { Styles } from '../styles/types';\nimport { hasKeys } from '../utils/has-keys';\nimport { resolveRecipes } from '../utils/resolve-recipes';\nimport { stringifyStyles } from '../utils/styles';\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 * Information about a processed chunk\n */\ninterface ProcessedChunk {\n name: string;\n styleKeys: string[];\n cacheKey: string;\n renderResult: RenderResult;\n className: string;\n}\n\n/**\n * Render, cache-key, and allocate a className for a single chunk.\n * Returns a ProcessedChunk, or null if the chunk produces no CSS rules.\n *\n * Always runs the pipeline and calls allocateClassName. The inject()\n * call in useInsertionEffect handles all edge cases: placeholders from\n * abandoned concurrent renders, hydration hits (ruleIndex -2), and\n * runtime cache hits (already injected). The pipeline's own LRU cache\n * makes repeated calls for identical styles cheap.\n */\nfunction processChunk(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);\n const renderResult = renderStylesForChunk(\n styles,\n chunkName,\n styleKeys,\n cacheKey,\n );\n if (renderResult.rules.length === 0) return null;\n\n const { className } = allocateClassName(cacheKey);\n\n return { name: chunkName, styleKeys, cacheKey, renderResult, className };\n}\n\n/**\n * Get keyframes that are actually used in styles.\n * Returns null if no keyframes are used (fast path for zero overhead).\n *\n * Optimization order:\n * 1. Check if any keyframes are defined (local or global) - if not, return null\n * 2. Extract animation names from styles - if none, return null\n * 3. Merge and filter keyframes to only used ones\n */\nfunction getUsedKeyframes(\n styles: Styles,\n): Record<string, KeyframesSteps> | null {\n // Fast path: no keyframes defined anywhere\n const hasLocal = hasLocalKeyframes(styles);\n const hasGlobal = hasGlobalKeyframes();\n if (!hasLocal && !hasGlobal) return null;\n\n // Extract animation names from styles (not from rendered CSS - faster)\n const usedNames = extractAnimationNamesFromStyles(styles);\n if (usedNames.size === 0) return null;\n\n // Merge local and global keyframes\n const local = hasLocal ? extractLocalKeyframes(styles) : null;\n const global = hasGlobal ? getGlobalKeyframes() : null;\n const allKeyframes = mergeKeyframes(local, global);\n\n // Filter to only used keyframes\n return filterUsedKeyframes(allKeyframes, usedNames);\n}\n\n/**\n * Process a chunk on the SSR path: allocate via collector, render, collect CSS.\n * Returns null if the chunk produces no CSS rules.\n */\nfunction processChunkSSR(\n collector: ServerStyleCollector,\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): ProcessedChunk | null {\n if (styleKeys.length === 0) return null;\n\n const cacheKey = generateChunkCacheKey(styles, chunkName, styleKeys);\n const { className, isNewAllocation } = collector.allocateClassName(cacheKey);\n\n if (isNewAllocation) {\n const renderResult = renderStylesForChunk(styles, chunkName, styleKeys);\n if (renderResult.rules.length > 0) {\n collector.collectChunk(cacheKey, className, renderResult.rules);\n return {\n name: chunkName,\n styleKeys,\n cacheKey,\n renderResult,\n className,\n };\n }\n return null;\n }\n\n return {\n name: chunkName,\n styleKeys,\n cacheKey,\n renderResult: { rules: [] },\n className,\n };\n}\n\n/**\n * Hook to generate CSS classes from Tasty styles.\n * Handles style rendering, className allocation, and CSS injection.\n *\n * SSR-aware: when a ServerStyleCollector is available (via React context\n * or AsyncLocalStorage), CSS is collected during the render phase instead\n * of being injected into the DOM. useInsertionEffect does not run on the\n * server, so the collector path is the only active path during SSR.\n *\n * Uses chunking to split styles into logical groups for better caching\n * and CSS reuse across components.\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 = useContext(TastySSRContext);\n const ssrCollector = resolveSSRCollector(ssrContextValue);\n\n // Array of dispose functions for each chunk\n const disposeRef = useRef<(() => void)[]>([]);\n\n // Store styles by their stringified key to avoid recomputing when only reference changes\n const stylesRef = useRef<{ key: string; styles: Styles | undefined }>({\n key: '',\n styles: undefined,\n });\n\n // Resolve recipes before any processing (zero overhead if no recipes configured)\n const resolvedStyles = useMemo(() => {\n if (!styles) return styles;\n return resolveRecipes(styles);\n }, [styles]);\n\n // Compute style key - this is a primitive string that captures style content\n const styleKey = useMemo(() => {\n if (!resolvedStyles || !hasKeys(resolvedStyles)) {\n return '';\n }\n return stringifyStyles(resolvedStyles);\n }, [resolvedStyles]);\n\n // Update ref when styleKey changes (content actually changed)\n if (stylesRef.current.key !== styleKey) {\n stylesRef.current = { key: styleKey, styles: resolvedStyles };\n }\n\n // Process chunks: categorize, generate cache keys, render, and allocate classNames\n // Only depends on styleKey (primitive), not styles object reference\n const processedChunks: ProcessedChunk[] = useMemo(() => {\n const currentStyles = stylesRef.current.styles;\n if (!styleKey || !currentStyles) {\n return [];\n }\n\n // Categorize style keys into chunks\n const chunkMap = categorizeStyleKeys(\n currentStyles as Record<string, unknown>,\n );\n\n const chunks: ProcessedChunk[] = [];\n\n if (ssrCollector) {\n // Ensure internal @property and :root token CSS is included\n ssrCollector.collectInternals();\n\n // SERVER PATH: allocate via collector, collect CSS\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunkSSR(\n ssrCollector,\n currentStyles,\n chunkName,\n chunkStyleKeys,\n );\n if (chunk) chunks.push(chunk);\n }\n\n // Collect keyframes on the server\n const usedKeyframes = getUsedKeyframes(currentStyles);\n if (usedKeyframes) {\n for (const [name, steps] of Object.entries(usedKeyframes)) {\n const css = formatKeyframesCSS(name, steps);\n ssrCollector.collectKeyframes(name, css);\n }\n }\n\n // Collect explicit @property rules on the server\n if (hasLocalProperties(currentStyles)) {\n const localProperties = extractLocalProperties(currentStyles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n ssrCollector.collectProperty(token, css);\n }\n }\n }\n }\n\n // Collect @font-face rules on the server\n if (hasLocalFontFace(currentStyles)) {\n const localFontFace = extractLocalFontFace(currentStyles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n ssrCollector.collectFontFace(hash, css);\n }\n }\n }\n }\n\n // Collect @counter-style rules on the server\n if (hasLocalCounterStyle(currentStyles)) {\n const localCounterStyle = extractLocalCounterStyle(currentStyles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n const css = formatCounterStyleRule(name, descriptors);\n ssrCollector.collectCounterStyle(name, css);\n }\n }\n }\n\n // Auto-infer @property types from rendered declarations (SSR).\n // On the client this happens inside StyleInjector.inject(), which\n // runs in useInsertionEffect and therefore never executes on the server.\n if (getConfig().autoPropertyTypes !== false) {\n const allRules = chunks.flatMap((c) => c.renderResult.rules);\n if (allRules.length > 0) {\n collectAutoInferredProperties(allRules, ssrCollector, currentStyles);\n }\n }\n } else {\n // CLIENT PATH: unchanged behavior\n for (const [chunkName, chunkStyleKeys] of chunkMap) {\n const chunk = processChunk(currentStyles, chunkName, chunkStyleKeys);\n if (chunk) chunks.push(chunk);\n }\n }\n\n return chunks;\n }, [styleKey]);\n\n // Inject styles in insertion effect (avoids render phase side effects).\n // Does NOT run on the server — the SSR path above handles collection.\n useInsertionEffect(() => {\n // Cleanup all previous disposals\n disposeRef.current.forEach((dispose) => dispose?.());\n disposeRef.current = [];\n\n // Fast path: no chunks to inject\n if (processedChunks.length === 0) {\n return;\n }\n\n const currentStyles = stylesRef.current.styles;\n\n // Register explicit @properties first so they take precedence over auto-inference\n // that happens during keyframe and style chunk injection.\n // Token formats: $name → --name, #name → --name-color (with auto syntax: '<color>')\n // Note: Global properties are injected once when styles are first generated (see markStylesGenerated)\n if (currentStyles && hasLocalProperties(currentStyles)) {\n const localProperties = extractLocalProperties(currentStyles);\n if (localProperties) {\n for (const [token, definition] of Object.entries(localProperties)) {\n property(token, definition);\n }\n }\n }\n\n // Inject @font-face rules (permanent, no cleanup needed)\n if (currentStyles && hasLocalFontFace(currentStyles)) {\n const localFontFace = extractLocalFontFace(currentStyles);\n if (localFontFace) {\n for (const [family, input] of Object.entries(localFontFace)) {\n const descriptors: FontFaceDescriptors[] = Array.isArray(input)\n ? input\n : [input];\n for (const desc of descriptors) {\n fontFace(family, desc);\n }\n }\n }\n }\n\n // Inject @counter-style rules (permanent, no cleanup needed)\n if (currentStyles && hasLocalCounterStyle(currentStyles)) {\n const localCounterStyle = extractLocalCounterStyle(currentStyles);\n if (localCounterStyle) {\n for (const [name, descriptors] of Object.entries(localCounterStyle)) {\n counterStyle(name, descriptors);\n }\n }\n }\n\n // Get keyframes that are actually used (returns null if none - zero overhead)\n const usedKeyframes = currentStyles\n ? getUsedKeyframes(currentStyles)\n : null;\n\n // Inject keyframes and build name map (only if we have keyframes)\n let nameMap: Map<string, string> | null = null;\n\n if (usedKeyframes) {\n nameMap = new Map();\n for (const [name, steps] of Object.entries(usedKeyframes)) {\n const result = keyframes(steps, { name });\n const injectedName = result.toString();\n // Only add to map if name differs (optimization for replacement check)\n if (injectedName !== name) {\n nameMap.set(name, injectedName);\n }\n disposeRef.current.push(result.dispose);\n }\n // Clear map if no replacements needed\n if (nameMap.size === 0) {\n nameMap = null;\n }\n }\n\n // Inject each chunk\n for (const chunk of processedChunks) {\n if (chunk.renderResult.rules.length > 0) {\n // Replace animation names only if needed\n const rulesToInject = nameMap\n ? chunk.renderResult.rules.map((rule) => ({\n ...rule,\n declarations: replaceAnimationNames(rule.declarations, nameMap!),\n }))\n : chunk.renderResult.rules;\n\n const { dispose } = inject(rulesToInject, {\n cacheKey: chunk.cacheKey,\n });\n disposeRef.current.push(dispose);\n }\n }\n\n return () => {\n disposeRef.current.forEach((dispose) => dispose?.());\n disposeRef.current = [];\n };\n }, [processedChunks]);\n\n // Combine all chunk classNames\n const className = useMemo(() => {\n return processedChunks.map((chunk) => chunk.className).join(' ');\n }, [processedChunks]);\n\n return {\n className,\n };\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"useStyles.js","names":[],"sources":["../../src/hooks/useStyles.ts"],"sourcesContent":["import { useContext } from 'react';\n\nimport { computeStyles } from '../compute-styles';\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 return computeStyles(styles, { ssrCollector: useContext(TastySSRContext) });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,UAAU,QAA2C;AACnE,QAAO,cAAc,QAAQ,EAAE,cAAc,WAAW,gBAAgB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./injector/types.js";
1
+ import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, GCConfig, GCOptions, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule, StyleUsage } from "./injector/types.js";
2
2
  import { CSSProperties } from "./utils/css-types.js";
3
3
  import { Bucket, ParserOptions, ProcessedStyle, StyleDetails, StyleDetailsPart, UnitHandler } from "./parser/types.js";
4
4
  import { StyleParser } from "./parser/parser.js";
@@ -12,13 +12,14 @@ import { RenderResult, StyleResult, isSelector, renderStyles } from "./pipeline/
12
12
  import { SheetManager } from "./injector/sheet-manager.js";
13
13
  import { StyleInjector } from "./injector/injector.js";
14
14
  import { ColorSpace } from "./utils/color-space.js";
15
+ import { TypographyPreset, TypographyTokenValue, generateTypographyTokens } from "./utils/typography.js";
15
16
  import { TastyPlugin, TastyPluginFactory } from "./plugins/types.js";
16
17
  import { TastyConfig, configure, getConfig, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
17
18
  import { okhslFunc, okhslPlugin } from "./plugins/okhsl-plugin.js";
18
19
  import { CHUNK_NAMES, ChunkInfo, ChunkName, STYLE_TO_CHUNK, categorizeStyleKeys } from "./chunks/definitions.js";
19
20
  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";
20
21
  import { AllBaseProps, BaseProps, BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, ColorStyleProps, ContainerStyleProps, DimensionStyleProps, FlowStyleProps, GlobalStyledProps, InnerStyleProps, ModValue, Mods, OuterStyleProps, PositionStyleProps, Props, ShortGridStyles, TagName, TastyExtensionConfig, TastyThemeNames, TextStyleProps, TokenValue, Tokens } from "./types.js";
21
- import { AllBasePropsWithMods, Element, ElementsDefinition, ModPropDef, ModPropsInput, ResolveModPropDef, ResolveModProps, SubElementDefinition, SubElementProps, TastyElementOptions, TastyElementProps, TastyProps, VariantMap, WithVariant, tasty } from "./tasty.js";
22
+ import { AllBasePropsWithMods, Element, ElementsDefinition, ModPropDef, ModPropsInput, ResolveModPropDef, ResolveModProps, ResolveTokenProps, SubElementDefinition, SubElementProps, TastyElementOptions, TastyElementProps, TastyProps, TokenPropsInput, VariantMap, WithVariant, tasty } from "./tasty.js";
22
23
  import { UseStylesOptions, UseStylesResult, useStyles } from "./hooks/useStyles.js";
23
24
  import { useGlobalStyles } from "./hooks/useGlobalStyles.js";
24
25
  import { useRawCSS } from "./hooks/useRawCSS.js";
@@ -28,7 +29,8 @@ import { useFontFace } from "./hooks/useFontFace.js";
28
29
  import { useCounterStyle } from "./hooks/useCounterStyle.js";
29
30
  import { getDisplayName } from "./utils/get-display-name.js";
30
31
  import { styleHandlers } from "./styles/predefined.js";
31
- import { PropertyOptions, allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef } from "./injector/index.js";
32
+ import { ComputeStylesOptions, ComputeStylesResult, computeStyles } from "./compute-styles.js";
33
+ import { PropertyOptions, cleanup, counterStyle, createInjector, destroy, fontFace, gc, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, touch } from "./injector/index.js";
32
34
  import { filterBaseProps } from "./utils/filter-base-props.js";
33
35
  import { color } from "./utils/colors.js";
34
36
  import { _modAttrs } from "./utils/mod-attrs.js";
@@ -36,10 +38,8 @@ import { dotize } from "./utils/dotize.js";
36
38
  import { mergeStyles } from "./utils/merge-styles.js";
37
39
  import { resolveRecipes } from "./utils/resolve-recipes.js";
38
40
  import { deprecationWarning, warn } from "./utils/warnings.js";
39
- import { processTokens, stringifyTokens } from "./utils/process-tokens.js";
40
- import { TypographyPreset, generateTypographyTokens } from "./utils/typography.js";
41
+ import { processTokens } from "./utils/process-tokens.js";
41
42
  import { tastyDebug } from "./debug.js";
42
- import "./core/index.js";
43
43
  import { CSSProperties as CSSProperties$1 } from "react";
44
44
 
45
45
  //#region src/index.d.ts
@@ -47,5 +47,5 @@ declare module './utils/css-types' {
47
47
  interface CSSProperties extends CSSProperties$1 {}
48
48
  }
49
49
  //#endregion
50
- export { type AllBaseProps, type AllBasePropsWithMods, AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CSSMap, CSSProperties, CUSTOM_UNITS, CacheMetrics, ChunkInfo, ChunkName, ColorSpace, ColorStyleProps, ConditionNode, ConfigTokenValue, ConfigTokens, ContainerStyleProps, CounterStyleDescriptors, DIMENSION_STYLES, DIRECTIONS, DimensionStyleProps, DisposeFunction, Element, type ElementsDefinition, FLOW_STYLES, FlowStyleProps, FontFaceDescriptors, FontFaceInput, GlobalStyledProps, INNER_STYLES, InjectResult, InnerStyleProps, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, type ModPropDef, type ModPropsInput, ModValue, Mods, NoType, NotSelector, OUTER_STYLES, OuterStyleProps, POSITION_STYLES, ParseStateKeyOptions, ParsedAdvancedState, ParsedColor, ParserOptions, PositionStyleProps, ProcessedStyle, PropertyDefinition, PropertyOptions, Props, RawCSSResult, RawStyleHandler, RecipeStyles, RenderResult, type ResolveModPropDef, type ResolveModProps, RootRegistry, RuleInfo, STYLE_TO_CHUNK, Selector, SheetInfo, SheetManager, ShortGridStyles, StateParserContext, StyleDetails, StyleDetailsPart, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleInjector, StyleInjectorConfig, StyleMap, StyleParser, StylePropValue, StyleResult, StyleRule, StyleValue, StyleValueStateMap, Styles, StylesInterface, StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, SuffixForSelector, TEXT_STYLES, TagName, TastyConfig, type TastyElementOptions, type TastyElementProps, TastyExtensionConfig, TastyNamedColors, TastyPlugin, TastyPluginFactory, TastyPresetNames, type TastyProps, TastyThemeNames, TextStyleProps, TokenValue, Tokens, TypographyPreset, UnitHandler, type UsePropertyOptions, type UseStylesOptions, type UseStylesResult, type VariantMap, type WithVariant, allocateClassName, categorizeStyleKeys, cleanup, color, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, tasty, tastyDebug, trackRef, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
50
+ export { type AllBaseProps, type AllBasePropsWithMods, AtRuleContext, BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, type BaseProps, type BasePropsWithoutChildren, BaseStyleProps, BlockInnerStyleProps, BlockOuterStyleProps, BlockStyleProps, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CSSMap, CSSProperties, CUSTOM_UNITS, CacheMetrics, ChunkInfo, ChunkName, ColorSpace, ColorStyleProps, ComputeStylesOptions, ComputeStylesResult, ConditionNode, ConfigTokenValue, ConfigTokens, ContainerStyleProps, CounterStyleDescriptors, DIMENSION_STYLES, DIRECTIONS, DimensionStyleProps, DisposeFunction, Element, type ElementsDefinition, FLOW_STYLES, FlowStyleProps, FontFaceDescriptors, FontFaceInput, GCConfig, GCOptions, GlobalStyledProps, INNER_STYLES, InjectResult, InnerStyleProps, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, type ModPropDef, type ModPropsInput, ModValue, Mods, NoType, NotSelector, OUTER_STYLES, OuterStyleProps, POSITION_STYLES, ParseStateKeyOptions, ParsedAdvancedState, ParsedColor, ParserOptions, PositionStyleProps, ProcessedStyle, PropertyDefinition, PropertyOptions, Props, RawCSSResult, RawStyleHandler, RecipeStyles, RenderResult, type ResolveModPropDef, type ResolveModProps, type ResolveTokenProps, RootRegistry, RuleInfo, STYLE_TO_CHUNK, Selector, SheetInfo, SheetManager, ShortGridStyles, StateParserContext, StyleDetails, StyleDetailsPart, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleInjector, StyleInjectorConfig, StyleMap, StyleParser, StylePropValue, StyleResult, StyleRule, StyleUsage, StyleValue, StyleValueStateMap, Styles, StylesInterface, StylesWithoutSelectors, type SubElementDefinition, type SubElementProps, SuffixForSelector, TEXT_STYLES, TagName, TastyConfig, type TastyElementOptions, type TastyElementProps, TastyExtensionConfig, TastyNamedColors, TastyPlugin, TastyPluginFactory, TastyPresetNames, type TastyProps, TastyThemeNames, TextStyleProps, type TokenPropsInput, TokenValue, Tokens, TypographyPreset, TypographyTokenValue, UnitHandler, type UsePropertyOptions, type UseStylesOptions, type UseStylesResult, type VariantMap, type WithVariant, categorizeStyleKeys, cleanup, color, computeStyles, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, gc, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
51
51
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -10,27 +10,27 @@ import { StyleInjector } from "./injector/injector.js";
10
10
  import { createStateParserContext, getGlobalPredefinedStates, setGlobalPredefinedStates } from "./states/index.js";
11
11
  import { parseStateKey } from "./pipeline/parseStateKey.js";
12
12
  import { isSelector, renderStyles } from "./pipeline/index.js";
13
+ import { generateTypographyTokens } from "./utils/typography.js";
13
14
  import { configure, getConfig, getGlobalCounterStyle, getGlobalFontFace, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig } from "./config.js";
14
15
  import { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys } from "./chunks/definitions.js";
15
16
  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";
16
- import { allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef } from "./injector/index.js";
17
+ import { cleanup, counterStyle, createInjector, destroy, fontFace, gc, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, touch } from "./injector/index.js";
18
+ import { mergeStyles } from "./utils/merge-styles.js";
19
+ import { resolveRecipes } from "./utils/resolve-recipes.js";
20
+ import { computeStyles } from "./compute-styles.js";
17
21
  import { filterBaseProps } from "./utils/filter-base-props.js";
18
22
  import { color } from "./utils/colors.js";
19
23
  import { _modAttrs } from "./utils/mod-attrs.js";
20
24
  import { dotize } from "./utils/dotize.js";
21
- import { mergeStyles } from "./utils/merge-styles.js";
22
- import { resolveRecipes } from "./utils/resolve-recipes.js";
23
- import { processTokens, stringifyTokens } from "./utils/process-tokens.js";
24
- import { generateTypographyTokens } from "./utils/typography.js";
25
+ import { processTokens } from "./utils/process-tokens.js";
25
26
  import { tastyDebug } from "./debug.js";
26
- import { useStyles } from "./hooks/useStyles.js";
27
27
  import { getDisplayName } from "./utils/get-display-name.js";
28
28
  import { Element, tasty } from "./tasty.js";
29
+ import { useStyles } from "./hooks/useStyles.js";
29
30
  import { useGlobalStyles } from "./hooks/useGlobalStyles.js";
30
31
  import { useRawCSS } from "./hooks/useRawCSS.js";
31
32
  import { useKeyframes } from "./hooks/useKeyframes.js";
32
33
  import { useProperty } from "./hooks/useProperty.js";
33
34
  import { useFontFace } from "./hooks/useFontFace.js";
34
35
  import { useCounterStyle } from "./hooks/useCounterStyle.js";
35
-
36
- export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, allocateClassName, categorizeStyleKeys, cleanup, color, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, stringifyTokens, styleHandlers, tasty, tastyDebug, trackRef, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
36
+ export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, Bucket, CHUNK_NAMES, COLOR_STYLES, CONTAINER_STYLES, CUSTOM_UNITS, DIMENSION_STYLES, DIRECTIONS, Element, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, STYLE_TO_CHUNK, SheetManager, StyleInjector, StyleParser, TEXT_STYLES, categorizeStyleKeys, cleanup, color, computeStyles, configure, counterStyle, createInjector, createStateParserContext, customFunc, deprecationWarning, destroy, dotize, filterBaseProps, filterMods, fontFace, gc, generateTypographyTokens, getConfig, getCssText, getCssTextForNode, getDisplayName, getGlobalCounterStyle, getGlobalFontFace, getGlobalFuncs, getGlobalKeyframes, getGlobalParser, getGlobalPredefinedStates, getGlobalPredefinedTokens, getGlobalRecipes, getIsTestEnvironment, getNamedColorHex, getRawCSSText, getRgbValuesFromRgbaString, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, hexToRgb, hslToRgbValues, inject, injectGlobal, injectRawCSS, injector, isConfigLocked, isPropertyDefined, isSelector, isTestEnvironment, keyframes, mergeStyles, _modAttrs as modAttrs, normalizeColorTokenValue, okhslFunc, okhslPlugin, parseColor, parseStateKey, parseStyle, processTokens, property, renderStyles, resetConfig, resetGlobalPredefinedTokens, resolveRecipes, setGlobalPredefinedStates, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleHandlers, tasty, tastyDebug, touch, useCounterStyle, useFontFace, useGlobalStyles, useKeyframes, useProperty, useRawCSS, useStyles, warn };
@@ -1,26 +1,9 @@
1
- import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./types.js";
1
+ import { CacheMetrics, CounterStyleDescriptors, DisposeFunction, FontFaceDescriptors, FontFaceInput, GCConfig, GCOptions, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule, StyleUsage } from "./types.js";
2
2
  import { StyleResult } from "../pipeline/index.js";
3
3
  import { SheetManager } from "./sheet-manager.js";
4
4
  import { StyleInjector } from "./injector.js";
5
5
 
6
6
  //#region src/injector/index.d.ts
7
- /**
8
- * Allocate a className for a cacheKey without injecting styles yet
9
- */
10
- declare function allocateClassName(cacheKey: string, options?: {
11
- root?: Document | ShadowRoot;
12
- }): {
13
- className: string;
14
- isNewAllocation: boolean;
15
- };
16
- /**
17
- * Track a reference to an already-injected cacheKey (refCount + dispose).
18
- * Used on cache hits (SSR hydration or runtime reuse) where the pipeline
19
- * was skipped. Returns null if the cacheKey is not in the cache.
20
- */
21
- declare function trackRef(cacheKey: string, options?: {
22
- root?: Document | ShadowRoot;
23
- }): InjectResult | null;
24
7
  /**
25
8
  * Inject styles and return className with dispose function
26
9
  */
@@ -160,6 +143,22 @@ declare function getCssTextForNode(node: ParentNode | Element | DocumentFragment
160
143
  * Force cleanup of unused rules
161
144
  */
162
145
  declare function cleanup(root?: Document | ShadowRoot): void;
146
+ /**
147
+ * Record a render-time usage hit for one or more classNames.
148
+ * Used internally by computeStyles and tasty() to track usage for GC.
149
+ * When the global touch counter reaches `touchInterval`, schedules GC.
150
+ */
151
+ declare function touch(className: string, options?: {
152
+ root?: Document | ShadowRoot;
153
+ }): void;
154
+ /**
155
+ * Synchronous garbage collection of unused styles.
156
+ * Evicts the oldest unused styles when usageMap exceeds capacity.
157
+ * With `{ force: true }`, removes ALL unused styles regardless of capacity.
158
+ *
159
+ * @returns Number of styles evicted.
160
+ */
161
+ declare function gc(options?: GCOptions): number;
163
162
  /**
164
163
  * Check if we're currently running in a test environment
165
164
  */
@@ -179,5 +178,5 @@ declare function destroy(root?: Document | ShadowRoot): void;
179
178
  */
180
179
  declare function createInjector(config?: Partial<StyleInjectorConfig>): StyleInjector;
181
180
  //#endregion
182
- export { PropertyOptions, allocateClassName, cleanup, counterStyle, createInjector, destroy, fontFace, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, trackRef };
181
+ export { PropertyOptions, cleanup, counterStyle, createInjector, destroy, fontFace, gc, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property, touch };
183
182
  //# sourceMappingURL=index.d.ts.map