@tenphi/tasty 0.0.0-snapshot.c8c7b2a → 0.0.0-snapshot.cae4fee

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 (338) hide show
  1. package/README.md +10 -5
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/{ssr/collector.js → collector-C-keQH9m.js} +26 -18
  5. package/dist/collector-C-keQH9m.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-osfWTeRd.d.ts} +13 -3
  7. package/dist/config-BBiyxMCe.js +10559 -0
  8. package/dist/config-BBiyxMCe.js.map +1 -0
  9. package/dist/config-BoZDUHW5.d.ts +945 -0
  10. package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -34
  13. package/dist/core/index.js +6 -27
  14. package/dist/core-BO4319td.js +1598 -0
  15. package/dist/core-BO4319td.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-BWvwQzz0.js} +98 -13
  17. package/dist/css-writer-BWvwQzz0.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-BSjeH4Z7.js +143 -0
  21. package/dist/format-rules-BSjeH4Z7.js.map +1 -0
  22. package/dist/{ssr/hydrate.js → hydrate-CcvrP4qJ.js} +3 -3
  23. package/dist/hydrate-CcvrP4qJ.js.map +1 -0
  24. package/dist/index-B_k47mc_.d.ts +1655 -0
  25. package/dist/index-tcHuMPFt.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -51
  27. package/dist/index.js +732 -36
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-BUQhdOSJ.js +588 -0
  30. package/dist/keyframes-BUQhdOSJ.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BMWcH6MF.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-Cd2vBl9b.js} +3 -4
  33. package/dist/merge-styles-Cd2vBl9b.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-C1nrvnYh.js} +4 -6
  35. package/dist/resolve-recipes-C1nrvnYh.js.map +1 -0
  36. package/dist/ssr/astro-client.js +1 -1
  37. package/dist/ssr/astro-client.js.map +1 -1
  38. package/dist/ssr/astro-middleware.js.map +1 -1
  39. package/dist/ssr/astro.d.ts +1 -12
  40. package/dist/ssr/astro.js +4 -4
  41. package/dist/ssr/astro.js.map +1 -1
  42. package/dist/ssr/index.d.ts +44 -4
  43. package/dist/ssr/index.js +4 -4
  44. package/dist/ssr/next.d.ts +1 -1
  45. package/dist/ssr/next.js +6 -6
  46. package/dist/ssr/next.js.map +1 -1
  47. package/dist/static/index.d.ts +91 -5
  48. package/dist/static/index.js +49 -3
  49. package/dist/static/index.js.map +1 -0
  50. package/dist/static/inject.js.map +1 -1
  51. package/dist/zero/babel.d.ts +1 -1
  52. package/dist/zero/babel.js +22 -10
  53. package/dist/zero/babel.js.map +1 -1
  54. package/dist/zero/index.d.ts +67 -3
  55. package/dist/zero/index.js +1 -2
  56. package/dist/zero/next.js.map +1 -1
  57. package/docs/configuration.md +44 -0
  58. package/docs/dsl.md +14 -12
  59. package/docs/injector.md +2 -2
  60. package/docs/methodology.md +26 -0
  61. package/docs/pipeline.md +230 -50
  62. package/docs/react-api.md +24 -0
  63. package/docs/ssr.md +5 -3
  64. package/docs/styles.md +9 -7
  65. package/docs/tasty-static.md +15 -0
  66. package/package.json +11 -10
  67. package/tasty.config.ts +1 -0
  68. package/dist/_virtual/_rolldown/runtime.js +0 -7
  69. package/dist/chunks/cacheKey.d.ts +0 -1
  70. package/dist/chunks/cacheKey.js +0 -77
  71. package/dist/chunks/cacheKey.js.map +0 -1
  72. package/dist/chunks/definitions.d.ts +0 -37
  73. package/dist/chunks/definitions.js +0 -258
  74. package/dist/chunks/definitions.js.map +0 -1
  75. package/dist/chunks/index.d.ts +0 -1
  76. package/dist/chunks/renderChunk.d.ts +0 -1
  77. package/dist/chunks/renderChunk.js +0 -59
  78. package/dist/chunks/renderChunk.js.map +0 -1
  79. package/dist/compute-styles.d.ts +0 -31
  80. package/dist/compute-styles.js +0 -322
  81. package/dist/compute-styles.js.map +0 -1
  82. package/dist/config.d.ts +0 -407
  83. package/dist/config.js +0 -591
  84. package/dist/config.js.map +0 -1
  85. package/dist/counter-style/index.js +0 -51
  86. package/dist/counter-style/index.js.map +0 -1
  87. package/dist/debug.d.ts +0 -89
  88. package/dist/debug.js +0 -453
  89. package/dist/debug.js.map +0 -1
  90. package/dist/font-face/index.js +0 -63
  91. package/dist/font-face/index.js.map +0 -1
  92. package/dist/hooks/index.d.ts +0 -7
  93. package/dist/hooks/useCounterStyle.d.ts +0 -36
  94. package/dist/hooks/useCounterStyle.js +0 -65
  95. package/dist/hooks/useCounterStyle.js.map +0 -1
  96. package/dist/hooks/useFontFace.d.ts +0 -45
  97. package/dist/hooks/useFontFace.js +0 -66
  98. package/dist/hooks/useFontFace.js.map +0 -1
  99. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  100. package/dist/hooks/useGlobalStyles.js +0 -88
  101. package/dist/hooks/useGlobalStyles.js.map +0 -1
  102. package/dist/hooks/useKeyframes.d.ts +0 -58
  103. package/dist/hooks/useKeyframes.js +0 -55
  104. package/dist/hooks/useKeyframes.js.map +0 -1
  105. package/dist/hooks/useProperty.d.ts +0 -81
  106. package/dist/hooks/useProperty.js +0 -96
  107. package/dist/hooks/useProperty.js.map +0 -1
  108. package/dist/hooks/useRawCSS.d.ts +0 -22
  109. package/dist/hooks/useRawCSS.js +0 -103
  110. package/dist/hooks/useRawCSS.js.map +0 -1
  111. package/dist/hooks/useStyles.d.ts +0 -40
  112. package/dist/hooks/useStyles.js +0 -31
  113. package/dist/hooks/useStyles.js.map +0 -1
  114. package/dist/injector/index.d.ts +0 -182
  115. package/dist/injector/index.js +0 -185
  116. package/dist/injector/index.js.map +0 -1
  117. package/dist/injector/injector.d.ts +0 -198
  118. package/dist/injector/injector.js +0 -651
  119. package/dist/injector/injector.js.map +0 -1
  120. package/dist/injector/sheet-manager.d.ts +0 -132
  121. package/dist/injector/sheet-manager.js +0 -699
  122. package/dist/injector/sheet-manager.js.map +0 -1
  123. package/dist/injector/types.d.ts +0 -235
  124. package/dist/keyframes/index.js +0 -206
  125. package/dist/keyframes/index.js.map +0 -1
  126. package/dist/parser/classify.js +0 -319
  127. package/dist/parser/classify.js.map +0 -1
  128. package/dist/parser/const.js +0 -60
  129. package/dist/parser/const.js.map +0 -1
  130. package/dist/parser/lru.js +0 -109
  131. package/dist/parser/lru.js.map +0 -1
  132. package/dist/parser/parser.d.ts +0 -25
  133. package/dist/parser/parser.js +0 -115
  134. package/dist/parser/parser.js.map +0 -1
  135. package/dist/parser/tokenizer.js +0 -69
  136. package/dist/parser/tokenizer.js.map +0 -1
  137. package/dist/parser/types.d.ts +0 -51
  138. package/dist/parser/types.js +0 -46
  139. package/dist/parser/types.js.map +0 -1
  140. package/dist/pipeline/conditions.d.ts +0 -134
  141. package/dist/pipeline/conditions.js +0 -406
  142. package/dist/pipeline/conditions.js.map +0 -1
  143. package/dist/pipeline/exclusive.js +0 -285
  144. package/dist/pipeline/exclusive.js.map +0 -1
  145. package/dist/pipeline/index.d.ts +0 -55
  146. package/dist/pipeline/index.js +0 -708
  147. package/dist/pipeline/index.js.map +0 -1
  148. package/dist/pipeline/materialize.js +0 -1157
  149. package/dist/pipeline/materialize.js.map +0 -1
  150. package/dist/pipeline/parseStateKey.d.ts +0 -15
  151. package/dist/pipeline/parseStateKey.js +0 -446
  152. package/dist/pipeline/parseStateKey.js.map +0 -1
  153. package/dist/pipeline/simplify.js +0 -690
  154. package/dist/pipeline/simplify.js.map +0 -1
  155. package/dist/pipeline/warnings.js +0 -18
  156. package/dist/pipeline/warnings.js.map +0 -1
  157. package/dist/plugins/index.d.ts +0 -2
  158. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  159. package/dist/plugins/okhsl-plugin.js +0 -97
  160. package/dist/plugins/okhsl-plugin.js.map +0 -1
  161. package/dist/plugins/types.d.ts +0 -87
  162. package/dist/properties/index.js +0 -222
  163. package/dist/properties/index.js.map +0 -1
  164. package/dist/properties/property-type-resolver.d.ts +0 -24
  165. package/dist/properties/property-type-resolver.js +0 -90
  166. package/dist/properties/property-type-resolver.js.map +0 -1
  167. package/dist/rsc-cache.js +0 -79
  168. package/dist/rsc-cache.js.map +0 -1
  169. package/dist/ssr/async-storage.d.ts +0 -17
  170. package/dist/ssr/async-storage.js.map +0 -1
  171. package/dist/ssr/collect-auto-properties.js +0 -58
  172. package/dist/ssr/collect-auto-properties.js.map +0 -1
  173. package/dist/ssr/collector.js.map +0 -1
  174. package/dist/ssr/context.js.map +0 -1
  175. package/dist/ssr/format-global-rules.js.map +0 -1
  176. package/dist/ssr/format-keyframes.js +0 -69
  177. package/dist/ssr/format-keyframes.js.map +0 -1
  178. package/dist/ssr/format-property.js +0 -49
  179. package/dist/ssr/format-property.js.map +0 -1
  180. package/dist/ssr/format-rules.js +0 -73
  181. package/dist/ssr/format-rules.js.map +0 -1
  182. package/dist/ssr/hydrate.d.ts +0 -29
  183. package/dist/ssr/hydrate.js.map +0 -1
  184. package/dist/ssr/ssr-collector-ref.js +0 -29
  185. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  186. package/dist/states/index.d.ts +0 -49
  187. package/dist/states/index.js +0 -170
  188. package/dist/states/index.js.map +0 -1
  189. package/dist/static/tastyStatic.d.ts +0 -46
  190. package/dist/static/tastyStatic.js +0 -30
  191. package/dist/static/tastyStatic.js.map +0 -1
  192. package/dist/static/types.d.ts +0 -49
  193. package/dist/static/types.js +0 -24
  194. package/dist/static/types.js.map +0 -1
  195. package/dist/styles/border.d.ts +0 -25
  196. package/dist/styles/border.js +0 -120
  197. package/dist/styles/border.js.map +0 -1
  198. package/dist/styles/color.d.ts +0 -14
  199. package/dist/styles/color.js +0 -26
  200. package/dist/styles/color.js.map +0 -1
  201. package/dist/styles/const.js +0 -17
  202. package/dist/styles/const.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -79
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -109
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/directional.js +0 -133
  208. package/dist/styles/directional.js.map +0 -1
  209. package/dist/styles/display.d.ts +0 -30
  210. package/dist/styles/display.js +0 -73
  211. package/dist/styles/display.js.map +0 -1
  212. package/dist/styles/fade.d.ts +0 -15
  213. package/dist/styles/fade.js +0 -62
  214. package/dist/styles/fade.js.map +0 -1
  215. package/dist/styles/fill.d.ts +0 -42
  216. package/dist/styles/fill.js +0 -51
  217. package/dist/styles/fill.js.map +0 -1
  218. package/dist/styles/flow.d.ts +0 -16
  219. package/dist/styles/flow.js +0 -12
  220. package/dist/styles/flow.js.map +0 -1
  221. package/dist/styles/gap.d.ts +0 -31
  222. package/dist/styles/gap.js +0 -38
  223. package/dist/styles/gap.js.map +0 -1
  224. package/dist/styles/height.d.ts +0 -17
  225. package/dist/styles/height.js +0 -19
  226. package/dist/styles/height.js.map +0 -1
  227. package/dist/styles/index.d.ts +0 -1
  228. package/dist/styles/index.js +0 -8
  229. package/dist/styles/index.js.map +0 -1
  230. package/dist/styles/inset.d.ts +0 -24
  231. package/dist/styles/inset.js +0 -34
  232. package/dist/styles/inset.js.map +0 -1
  233. package/dist/styles/list.d.ts +0 -16
  234. package/dist/styles/list.js +0 -100
  235. package/dist/styles/list.js.map +0 -1
  236. package/dist/styles/margin.d.ts +0 -24
  237. package/dist/styles/margin.js +0 -32
  238. package/dist/styles/margin.js.map +0 -1
  239. package/dist/styles/outline.d.ts +0 -29
  240. package/dist/styles/outline.js +0 -55
  241. package/dist/styles/outline.js.map +0 -1
  242. package/dist/styles/padding.d.ts +0 -24
  243. package/dist/styles/padding.js +0 -32
  244. package/dist/styles/padding.js.map +0 -1
  245. package/dist/styles/placement.d.ts +0 -37
  246. package/dist/styles/placement.js +0 -74
  247. package/dist/styles/placement.js.map +0 -1
  248. package/dist/styles/predefined.d.ts +0 -71
  249. package/dist/styles/predefined.js +0 -237
  250. package/dist/styles/predefined.js.map +0 -1
  251. package/dist/styles/preset.d.ts +0 -52
  252. package/dist/styles/preset.js +0 -127
  253. package/dist/styles/preset.js.map +0 -1
  254. package/dist/styles/radius.d.ts +0 -12
  255. package/dist/styles/radius.js +0 -83
  256. package/dist/styles/radius.js.map +0 -1
  257. package/dist/styles/scrollMargin.d.ts +0 -24
  258. package/dist/styles/scrollMargin.js +0 -32
  259. package/dist/styles/scrollMargin.js.map +0 -1
  260. package/dist/styles/scrollbar.d.ts +0 -25
  261. package/dist/styles/scrollbar.js +0 -51
  262. package/dist/styles/scrollbar.js.map +0 -1
  263. package/dist/styles/shadow.d.ts +0 -14
  264. package/dist/styles/shadow.js +0 -25
  265. package/dist/styles/shadow.js.map +0 -1
  266. package/dist/styles/shared.js +0 -17
  267. package/dist/styles/shared.js.map +0 -1
  268. package/dist/styles/transition.d.ts +0 -14
  269. package/dist/styles/transition.js +0 -159
  270. package/dist/styles/transition.js.map +0 -1
  271. package/dist/styles/types.d.ts +0 -564
  272. package/dist/styles/width.d.ts +0 -17
  273. package/dist/styles/width.js +0 -19
  274. package/dist/styles/width.js.map +0 -1
  275. package/dist/tasty.d.ts +0 -134
  276. package/dist/tasty.js +0 -248
  277. package/dist/tasty.js.map +0 -1
  278. package/dist/types.d.ts +0 -184
  279. package/dist/utils/cache-wrapper.js +0 -21
  280. package/dist/utils/cache-wrapper.js.map +0 -1
  281. package/dist/utils/case-converter.js +0 -8
  282. package/dist/utils/case-converter.js.map +0 -1
  283. package/dist/utils/color-math.d.ts +0 -46
  284. package/dist/utils/color-math.js +0 -749
  285. package/dist/utils/color-math.js.map +0 -1
  286. package/dist/utils/color-space.d.ts +0 -5
  287. package/dist/utils/color-space.js +0 -228
  288. package/dist/utils/color-space.js.map +0 -1
  289. package/dist/utils/colors.d.ts +0 -5
  290. package/dist/utils/colors.js +0 -10
  291. package/dist/utils/colors.js.map +0 -1
  292. package/dist/utils/css-types.d.ts +0 -7
  293. package/dist/utils/deps-equal.js +0 -15
  294. package/dist/utils/deps-equal.js.map +0 -1
  295. package/dist/utils/dotize.d.ts +0 -26
  296. package/dist/utils/dotize.js +0 -122
  297. package/dist/utils/dotize.js.map +0 -1
  298. package/dist/utils/filter-base-props.d.ts +0 -15
  299. package/dist/utils/filter-base-props.js +0 -45
  300. package/dist/utils/filter-base-props.js.map +0 -1
  301. package/dist/utils/get-display-name.d.ts +0 -7
  302. package/dist/utils/get-display-name.js +0 -10
  303. package/dist/utils/get-display-name.js.map +0 -1
  304. package/dist/utils/has-keys.js +0 -13
  305. package/dist/utils/has-keys.js.map +0 -1
  306. package/dist/utils/hash.js +0 -14
  307. package/dist/utils/hash.js.map +0 -1
  308. package/dist/utils/is-dev-env.js +0 -19
  309. package/dist/utils/is-dev-env.js.map +0 -1
  310. package/dist/utils/is-valid-element-type.js +0 -15
  311. package/dist/utils/is-valid-element-type.js.map +0 -1
  312. package/dist/utils/merge-styles.js.map +0 -1
  313. package/dist/utils/mod-attrs.d.ts +0 -6
  314. package/dist/utils/mod-attrs.js +0 -20
  315. package/dist/utils/mod-attrs.js.map +0 -1
  316. package/dist/utils/process-tokens.d.ts +0 -17
  317. package/dist/utils/process-tokens.js +0 -83
  318. package/dist/utils/process-tokens.js.map +0 -1
  319. package/dist/utils/resolve-recipes.d.ts +0 -17
  320. package/dist/utils/resolve-recipes.js.map +0 -1
  321. package/dist/utils/selector-transform.js +0 -32
  322. package/dist/utils/selector-transform.js.map +0 -1
  323. package/dist/utils/string.js +0 -8
  324. package/dist/utils/string.js.map +0 -1
  325. package/dist/utils/styles.d.ts +0 -99
  326. package/dist/utils/styles.js +0 -220
  327. package/dist/utils/styles.js.map +0 -1
  328. package/dist/utils/typography.d.ts +0 -58
  329. package/dist/utils/typography.js +0 -51
  330. package/dist/utils/typography.js.map +0 -1
  331. package/dist/utils/warnings.d.ts +0 -16
  332. package/dist/utils/warnings.js +0 -16
  333. package/dist/utils/warnings.js.map +0 -1
  334. package/dist/zero/css-writer.d.ts +0 -45
  335. package/dist/zero/css-writer.js +0 -73
  336. package/dist/zero/css-writer.js.map +0 -1
  337. package/dist/zero/extractor.d.ts +0 -24
  338. package/dist/zero/extractor.js.map +0 -1
@@ -0,0 +1,143 @@
1
+ import { Tt as getComponentPropertySyntax, et as parseStyle, vt as getEffectiveDefinition, wt as getColorSpaceSuffix, xt as colorInitialValueToComponents } from "./config-BBiyxMCe.js";
2
+ //#region src/ssr/ssr-collector-ref.ts
3
+ const GETTER_KEY = "__tasty_ssr_collector_getter__";
4
+ let _getSSRCollector = null;
5
+ /**
6
+ * Register the collector getter in the current module graph only.
7
+ * Used by Next.js TastyRegistry.
8
+ */
9
+ function registerSSRCollectorGetter(fn) {
10
+ _getSSRCollector = fn;
11
+ }
12
+ /**
13
+ * Register the collector getter on globalThis so it is visible across
14
+ * separate module graphs (e.g. Astro middleware ↔ page components).
15
+ */
16
+ function registerSSRCollectorGetterGlobal(fn) {
17
+ globalThis[GETTER_KEY] = fn;
18
+ }
19
+ /**
20
+ * Retrieve the SSR collector: module-level first, globalThis fallback.
21
+ */
22
+ function getRegisteredSSRCollector() {
23
+ if (_getSSRCollector) return _getSSRCollector();
24
+ const getter = globalThis[GETTER_KEY];
25
+ return getter ? getter() : null;
26
+ }
27
+ //#endregion
28
+ //#region src/ssr/format-property.ts
29
+ /**
30
+ * Format a single @property rule as a CSS string.
31
+ *
32
+ * Returns the full `@property --name { ... }` text, or empty string
33
+ * if the token is invalid. For color properties, also returns
34
+ * the companion component property.
35
+ */
36
+ function formatPropertyCSS(token, definition) {
37
+ const result = getEffectiveDefinition(token, definition);
38
+ if (!result.isValid) return "";
39
+ const rules = [];
40
+ rules.push(buildPropertyRule(result.cssName, result.definition));
41
+ if (result.isColor) {
42
+ const suffix = getColorSpaceSuffix();
43
+ const componentCssName = `${result.cssName}-${suffix}`;
44
+ const componentInitial = colorInitialValueToComponents(result.definition.initialValue);
45
+ rules.push(buildPropertyRule(componentCssName, {
46
+ syntax: getComponentPropertySyntax(),
47
+ inherits: result.definition.inherits,
48
+ initialValue: componentInitial
49
+ }));
50
+ }
51
+ return rules.join("\n");
52
+ }
53
+ function buildPropertyRule(cssName, definition) {
54
+ const parts = [];
55
+ if (definition.syntax != null) {
56
+ let syntax = String(definition.syntax).trim();
57
+ if (!/^['"]/u.test(syntax)) syntax = `"${syntax}"`;
58
+ parts.push(`syntax: ${syntax};`);
59
+ }
60
+ const inherits = definition.inherits ?? true;
61
+ parts.push(`inherits: ${inherits ? "true" : "false"};`);
62
+ if (definition.initialValue != null) {
63
+ let initialValueStr;
64
+ if (typeof definition.initialValue === "number") initialValueStr = String(definition.initialValue);
65
+ else initialValueStr = parseStyle(definition.initialValue).output;
66
+ parts.push(`initial-value: ${initialValueStr};`);
67
+ }
68
+ return `@property ${cssName} { ${parts.join(" ").trim()} }`;
69
+ }
70
+ //#endregion
71
+ //#region src/ssr/format-rules.ts
72
+ /**
73
+ * Resolve selectors for a rule, applying className-based specificity doubling
74
+ * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().
75
+ */
76
+ function resolveSelector(rule, className) {
77
+ let selector = rule.selector;
78
+ if (rule.needsClassName) {
79
+ const selectorParts = selector ? selector.split("|||") : [""];
80
+ const classPrefix = `.${className}.${className}`;
81
+ selector = selectorParts.map((part) => {
82
+ const classSelector = part ? `${classPrefix}${part}` : classPrefix;
83
+ if (rule.rootPrefix) return `${rule.rootPrefix} ${classSelector}`;
84
+ return classSelector;
85
+ }).join(", ");
86
+ }
87
+ return selector;
88
+ }
89
+ /**
90
+ * Group rules by selector + at-rules + startingStyle and merge their declarations.
91
+ * Mirrors the grouping logic in SheetManager.insertRule().
92
+ */
93
+ function groupRules(rules) {
94
+ const groupMap = /* @__PURE__ */ new Map();
95
+ const order = [];
96
+ const atKey = (at) => at && at.length ? at.join("|") : "";
97
+ for (const r of rules) {
98
+ const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? "1" : "0"}`;
99
+ const existing = groupMap.get(key);
100
+ if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${r.declarations}` : r.declarations;
101
+ else {
102
+ groupMap.set(key, {
103
+ selector: r.selector,
104
+ atRules: r.atRules,
105
+ startingStyle: r.startingStyle,
106
+ declarations: r.declarations
107
+ });
108
+ order.push(key);
109
+ }
110
+ }
111
+ return order.map((key) => groupMap.get(key));
112
+ }
113
+ /**
114
+ * Format an array of StyleResult rules into a CSS text string.
115
+ *
116
+ * Applies className-based specificity doubling (.cls.cls),
117
+ * groups rules by selector + at-rules, and wraps with at-rule blocks.
118
+ *
119
+ * Produces the same CSS text as SheetManager.insertRule() would insert
120
+ * into the DOM, but as a plain string suitable for SSR output.
121
+ */
122
+ function formatRules(rules, className) {
123
+ if (rules.length === 0) return "";
124
+ const grouped = groupRules(rules.map((rule) => ({
125
+ selector: resolveSelector(rule, className),
126
+ declarations: rule.declarations,
127
+ atRules: rule.atRules,
128
+ startingStyle: rule.startingStyle
129
+ })));
130
+ const cssRules = [];
131
+ for (const rule of grouped) {
132
+ const innerContent = rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations;
133
+ const baseRule = `${rule.selector} { ${innerContent} }`;
134
+ let fullRule = baseRule;
135
+ if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
136
+ cssRules.push(fullRule);
137
+ }
138
+ return cssRules.join("\n");
139
+ }
140
+ //#endregion
141
+ export { registerSSRCollectorGetterGlobal as a, registerSSRCollectorGetter as i, formatPropertyCSS as n, getRegisteredSSRCollector as r, formatRules as t };
142
+
143
+ //# sourceMappingURL=format-rules-BSjeH4Z7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-rules-BSjeH4Z7.js","names":[],"sources":["../src/ssr/ssr-collector-ref.ts","../src/ssr/format-property.ts","../src/ssr/format-rules.ts"],"sourcesContent":["/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n | SSRCollectorGetter\n | undefined;\n return getter ? getter() : null;\n}\n","/**\n * Format @property CSS rules for SSR output.\n *\n * Replicates the CSS construction from StyleInjector.property()\n * but returns a CSS string instead of inserting into the DOM.\n */\n\nimport type { PropertyDefinition } from '../injector/types';\nimport { getEffectiveDefinition } from '../properties';\nimport {\n colorInitialValueToComponents,\n getColorSpaceSuffix,\n getComponentPropertySyntax,\n} from '../utils/color-space';\nimport type { StyleValue } from '../utils/styles';\nimport { parseStyle } from '../utils/styles';\n\n/**\n * Format a single @property rule as a CSS string.\n *\n * Returns the full `@property --name { ... }` text, or empty string\n * if the token is invalid. For color properties, also returns\n * the companion component property.\n */\nexport function formatPropertyCSS(\n token: string,\n definition: PropertyDefinition,\n): string {\n const result = getEffectiveDefinition(token, definition);\n if (!result.isValid) return '';\n\n const rules: string[] = [];\n\n rules.push(buildPropertyRule(result.cssName, result.definition));\n\n if (result.isColor) {\n const suffix = getColorSpaceSuffix();\n const componentCssName = `${result.cssName}-${suffix}`;\n const componentInitial = colorInitialValueToComponents(\n result.definition.initialValue,\n );\n rules.push(\n buildPropertyRule(componentCssName, {\n syntax: getComponentPropertySyntax(),\n inherits: result.definition.inherits,\n initialValue: componentInitial,\n }),\n );\n }\n\n return rules.join('\\n');\n}\n\nfunction buildPropertyRule(\n cssName: string,\n definition: PropertyDefinition,\n): string {\n const parts: string[] = [];\n\n if (definition.syntax != null) {\n let syntax = String(definition.syntax).trim();\n if (!/^['\"]/u.test(syntax)) syntax = `\"${syntax}\"`;\n parts.push(`syntax: ${syntax};`);\n }\n\n const inherits = definition.inherits ?? true;\n parts.push(`inherits: ${inherits ? 'true' : 'false'};`);\n\n if (definition.initialValue != null) {\n let initialValueStr: string;\n if (typeof definition.initialValue === 'number') {\n initialValueStr = String(definition.initialValue);\n } else {\n initialValueStr = parseStyle(\n definition.initialValue as StyleValue,\n ).output;\n }\n parts.push(`initial-value: ${initialValueStr};`);\n }\n\n const declarations = parts.join(' ').trim();\n return `@property ${cssName} { ${declarations} }`;\n}\n","/**\n * Shared CSS rule formatting utility.\n *\n * Extracted from SheetManager to allow both the DOM-based injector (client)\n * and the ServerStyleCollector (server) to produce identical CSS text\n * from StyleResult arrays.\n */\n\nimport type { StyleResult } from '../pipeline';\n\n/**\n * Resolve selectors for a rule, applying className-based specificity doubling\n * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().\n */\nfunction resolveSelector(rule: StyleResult, className: string): string {\n let selector = rule.selector;\n\n if (rule.needsClassName) {\n const selectorParts = selector ? selector.split('|||') : [''];\n const classPrefix = `.${className}.${className}`;\n\n selector = selectorParts\n .map((part) => {\n const classSelector = part ? `${classPrefix}${part}` : classPrefix;\n\n if (rule.rootPrefix) {\n return `${rule.rootPrefix} ${classSelector}`;\n }\n return classSelector;\n })\n .join(', ');\n }\n\n return selector;\n}\n\ninterface GroupedRule {\n selector: string;\n declarations: string;\n atRules?: string[];\n startingStyle?: boolean;\n}\n\n/**\n * Group rules by selector + at-rules + startingStyle and merge their declarations.\n * Mirrors the grouping logic in SheetManager.insertRule().\n */\nfunction groupRules(rules: GroupedRule[]): GroupedRule[] {\n const groupMap = new Map<string, GroupedRule>();\n const order: string[] = [];\n\n const atKey = (at?: string[]) => (at && at.length ? at.join('|') : '');\n\n for (const r of rules) {\n const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? '1' : '0'}`;\n const existing = groupMap.get(key);\n if (existing) {\n existing.declarations = existing.declarations\n ? `${existing.declarations} ${r.declarations}`\n : r.declarations;\n } else {\n groupMap.set(key, {\n selector: r.selector,\n atRules: r.atRules,\n startingStyle: r.startingStyle,\n declarations: r.declarations,\n });\n order.push(key);\n }\n }\n\n return order.map((key) => groupMap.get(key)!);\n}\n\n/**\n * Format an array of StyleResult rules into a CSS text string.\n *\n * Applies className-based specificity doubling (.cls.cls),\n * groups rules by selector + at-rules, and wraps with at-rule blocks.\n *\n * Produces the same CSS text as SheetManager.insertRule() would insert\n * into the DOM, but as a plain string suitable for SSR output.\n */\nexport function formatRules(rules: StyleResult[], className: string): string {\n if (rules.length === 0) return '';\n\n const resolvedRules = rules.map((rule) => ({\n selector: resolveSelector(rule, className),\n declarations: rule.declarations,\n atRules: rule.atRules,\n startingStyle: rule.startingStyle,\n }));\n\n const grouped = groupRules(resolvedRules);\n const cssRules: string[] = [];\n\n for (const rule of grouped) {\n const innerContent = rule.startingStyle\n ? `@starting-style { ${rule.declarations} }`\n : rule.declarations;\n const baseRule = `${rule.selector} { ${innerContent} }`;\n\n let fullRule = baseRule;\n if (rule.atRules && rule.atRules.length > 0) {\n fullRule = rule.atRules.reduce(\n (css, atRule) => `${atRule} { ${css} }`,\n baseRule,\n );\n }\n\n cssRules.push(fullRule);\n }\n\n return cssRules.join('\\n');\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { getGlobalInjector } from "../config.js";
1
+ import { s as getGlobalInjector } from "./config-BBiyxMCe.js";
2
2
  //#region src/ssr/hydrate.ts
3
3
  /**
4
4
  * Client-side cache hydration for SSR/RSC.
@@ -40,6 +40,6 @@ function hydrateTastyCache(state) {
40
40
  else hydrateTastyClasses();
41
41
  }
42
42
  //#endregion
43
- export { hydrateTastyCache, hydrateTastyClasses };
43
+ export { hydrateTastyClasses as n, hydrateTastyCache as t };
44
44
 
45
- //# sourceMappingURL=hydrate.js.map
45
+ //# sourceMappingURL=hydrate-CcvrP4qJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate-CcvrP4qJ.js","names":[],"sources":["../src/ssr/hydrate.ts"],"sourcesContent":["/**\n * Client-side cache hydration for SSR/RSC.\n *\n * Pre-populates the client injector's rules map with class names\n * rendered on the server. With hash-based naming, the client derives\n * the same class name from the same cache key, so only the class name\n * list needs to cross the wire — no cache keys or counters.\n */\n\nimport { getGlobalInjector } from '../config';\nimport { HYDRATED_RULE_INDEX } from '../injector/types';\n\n/**\n * Pre-populate the client-side style registry from the server's class name list.\n *\n * Call this before ReactDOM.hydrateRoot() or ensure it runs before\n * any tasty() component renders on the client.\n *\n * When called without arguments, reads the class list from `window.__TASTY__`\n * (populated by inline scripts emitted during SSR/RSC streaming).\n */\nexport function hydrateTastyClasses(classes?: string[]): void {\n if (typeof document === 'undefined') return;\n\n if (!classes) {\n classes = typeof window !== 'undefined' ? window.__TASTY__ : undefined;\n }\n\n if (!classes?.length) return;\n\n const injector = getGlobalInjector();\n const registry = injector._sheetManager.getRegistry(document);\n\n for (const cls of classes) {\n if (!registry.rules.has(cls)) {\n registry.rules.set(cls, {\n className: cls,\n ruleIndex: HYDRATED_RULE_INDEX,\n sheetIndex: HYDRATED_RULE_INDEX,\n });\n registry.refCounts.set(cls, 0);\n }\n }\n}\n\n/**\n * @deprecated Use `hydrateTastyClasses()` instead. This alias exists\n * for backwards compatibility and will be removed in a future major version.\n */\nexport function hydrateTastyCache(state?: {\n entries?: Record<string, string>;\n}): void {\n if (state?.entries) {\n hydrateTastyClasses(Object.values(state.entries));\n } else {\n hydrateTastyClasses();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,SAA0B;CAC5D,IAAI,OAAO,aAAa,aAAa;CAErC,IAAI,CAAC,SACH,UAAU,OAAO,WAAW,cAAc,OAAO,YAAY,KAAA;CAG/D,IAAI,CAAC,SAAS,QAAQ;CAGtB,MAAM,WADW,mBACQ,CAAC,cAAc,YAAY,SAAS;CAE7D,KAAK,MAAM,OAAO,SAChB,IAAI,CAAC,SAAS,MAAM,IAAI,IAAI,EAAE;EAC5B,SAAS,MAAM,IAAI,KAAK;GACtB,WAAW;GACX,WAAA;GACA,YAAA;GACD,CAAC;EACF,SAAS,UAAU,IAAI,KAAK,EAAE;;;;;;;AASpC,SAAgB,kBAAkB,OAEzB;CACP,IAAI,OAAO,SACT,oBAAoB,OAAO,OAAO,MAAM,QAAQ,CAAC;MAEjD,qBAAqB"}