@tenphi/tasty 0.0.0-snapshot.45da3da → 0.0.0-snapshot.46a482d

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 +39 -28
  2. package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +17 -8
  3. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  4. package/dist/{ssr/collector.js → collector-B0virMbz.js} +53 -37
  5. package/dist/collector-B0virMbz.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-DGl264AX.d.ts} +21 -15
  7. package/dist/config-B-MrRhXI.js +10952 -0
  8. package/dist/config-B-MrRhXI.js.map +1 -0
  9. package/dist/config-Bd-w2ehh.d.ts +945 -0
  10. package/dist/context-CA8YKeMn.js +24 -0
  11. package/dist/context-CA8YKeMn.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-CKwrPU-_.js +1598 -0
  15. package/dist/core-CKwrPU-_.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-C_R7DADj.js} +99 -15
  17. package/dist/css-writer-C_R7DADj.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +3 -3
  19. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  20. package/dist/format-rules-BKklQSdD.js +143 -0
  21. package/dist/format-rules-BKklQSdD.js.map +1 -0
  22. package/dist/hydrate-DSK0D4y1.js +45 -0
  23. package/dist/hydrate-DSK0D4y1.js.map +1 -0
  24. package/dist/index-079_3DLx.d.ts +1778 -0
  25. package/dist/index-BetORLZ3.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -51
  27. package/dist/index.js +731 -35
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-DzWu8tkm.js +595 -0
  30. package/dist/keyframes-DzWu8tkm.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BtXVaosu.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-DdlL9Qi1.js} +4 -6
  33. package/dist/merge-styles-DdlL9Qi1.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-DM_rDuZH.js} +5 -8
  35. package/dist/resolve-recipes-DM_rDuZH.js.map +1 -0
  36. package/dist/ssr/astro-client.d.ts +1 -0
  37. package/dist/ssr/astro-client.js +19 -0
  38. package/dist/ssr/astro-client.js.map +1 -0
  39. package/dist/ssr/astro-middleware.d.ts +15 -0
  40. package/dist/ssr/astro-middleware.js +19 -0
  41. package/dist/ssr/astro-middleware.js.map +1 -0
  42. package/dist/ssr/astro.d.ts +78 -10
  43. package/dist/ssr/astro.js +114 -32
  44. package/dist/ssr/astro.js.map +1 -1
  45. package/dist/ssr/index.d.ts +44 -5
  46. package/dist/ssr/index.js +7 -9
  47. package/dist/ssr/index.js.map +1 -1
  48. package/dist/ssr/next.d.ts +6 -6
  49. package/dist/ssr/next.js +18 -14
  50. package/dist/ssr/next.js.map +1 -1
  51. package/dist/static/index.d.ts +91 -5
  52. package/dist/static/index.js +49 -4
  53. package/dist/static/index.js.map +1 -0
  54. package/dist/static/inject.d.ts +5 -0
  55. package/dist/static/inject.js +17 -0
  56. package/dist/static/inject.js.map +1 -0
  57. package/dist/zero/babel.d.ts +23 -110
  58. package/dist/zero/babel.js +151 -51
  59. package/dist/zero/babel.js.map +1 -1
  60. package/dist/zero/index.d.ts +67 -3
  61. package/dist/zero/index.js +2 -4
  62. package/dist/zero/next.d.ts +12 -0
  63. package/dist/zero/next.js +5 -4
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +4 -4
  66. package/docs/adoption.md +5 -3
  67. package/docs/comparison.md +24 -25
  68. package/docs/configuration.md +113 -1
  69. package/docs/debug.md +11 -9
  70. package/docs/design-system.md +22 -10
  71. package/docs/dsl.md +147 -21
  72. package/docs/getting-started.md +10 -10
  73. package/docs/injector.md +43 -27
  74. package/docs/methodology.md +78 -3
  75. package/docs/pipeline.md +744 -0
  76. package/docs/{runtime.md → react-api.md} +128 -32
  77. package/docs/ssr.md +142 -82
  78. package/docs/styles.md +26 -7
  79. package/docs/tasty-static.md +116 -2
  80. package/package.json +35 -14
  81. package/tasty.config.ts +2 -0
  82. package/dist/_virtual/_rolldown/runtime.js +0 -8
  83. package/dist/chunks/cacheKey.js +0 -78
  84. package/dist/chunks/cacheKey.js.map +0 -1
  85. package/dist/chunks/definitions.d.ts +0 -37
  86. package/dist/chunks/definitions.js +0 -259
  87. package/dist/chunks/definitions.js.map +0 -1
  88. package/dist/chunks/renderChunk.js +0 -60
  89. package/dist/chunks/renderChunk.js.map +0 -1
  90. package/dist/config.d.ts +0 -366
  91. package/dist/config.js +0 -504
  92. package/dist/config.js.map +0 -1
  93. package/dist/counter-style/index.js +0 -51
  94. package/dist/counter-style/index.js.map +0 -1
  95. package/dist/debug.d.ts +0 -89
  96. package/dist/debug.js +0 -454
  97. package/dist/debug.js.map +0 -1
  98. package/dist/font-face/index.js +0 -63
  99. package/dist/font-face/index.js.map +0 -1
  100. package/dist/hooks/resolve-ssr-collector.js +0 -15
  101. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  102. package/dist/hooks/useCounterStyle.d.ts +0 -50
  103. package/dist/hooks/useCounterStyle.js +0 -47
  104. package/dist/hooks/useCounterStyle.js.map +0 -1
  105. package/dist/hooks/useFontFace.d.ts +0 -43
  106. package/dist/hooks/useFontFace.js +0 -71
  107. package/dist/hooks/useFontFace.js.map +0 -1
  108. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  109. package/dist/hooks/useGlobalStyles.js +0 -79
  110. package/dist/hooks/useGlobalStyles.js.map +0 -1
  111. package/dist/hooks/useKeyframes.d.ts +0 -56
  112. package/dist/hooks/useKeyframes.js +0 -65
  113. package/dist/hooks/useKeyframes.js.map +0 -1
  114. package/dist/hooks/useProperty.d.ts +0 -79
  115. package/dist/hooks/useProperty.js +0 -110
  116. package/dist/hooks/useProperty.js.map +0 -1
  117. package/dist/hooks/useRawCSS.d.ts +0 -53
  118. package/dist/hooks/useRawCSS.js +0 -36
  119. package/dist/hooks/useRawCSS.js.map +0 -1
  120. package/dist/hooks/useStyles.d.ts +0 -45
  121. package/dist/hooks/useStyles.js +0 -238
  122. package/dist/hooks/useStyles.js.map +0 -1
  123. package/dist/injector/index.d.ts +0 -183
  124. package/dist/injector/index.js +0 -180
  125. package/dist/injector/index.js.map +0 -1
  126. package/dist/injector/injector.d.ts +0 -166
  127. package/dist/injector/injector.js +0 -465
  128. package/dist/injector/injector.js.map +0 -1
  129. package/dist/injector/sheet-manager.d.ts +0 -136
  130. package/dist/injector/sheet-manager.js +0 -734
  131. package/dist/injector/sheet-manager.js.map +0 -1
  132. package/dist/injector/types.d.ts +0 -204
  133. package/dist/keyframes/index.js +0 -206
  134. package/dist/keyframes/index.js.map +0 -1
  135. package/dist/parser/classify.js +0 -320
  136. package/dist/parser/classify.js.map +0 -1
  137. package/dist/parser/const.js +0 -49
  138. package/dist/parser/const.js.map +0 -1
  139. package/dist/parser/lru.js +0 -109
  140. package/dist/parser/lru.js.map +0 -1
  141. package/dist/parser/parser.d.ts +0 -25
  142. package/dist/parser/parser.js +0 -116
  143. package/dist/parser/parser.js.map +0 -1
  144. package/dist/parser/tokenizer.js +0 -69
  145. package/dist/parser/tokenizer.js.map +0 -1
  146. package/dist/parser/types.d.ts +0 -51
  147. package/dist/parser/types.js +0 -46
  148. package/dist/parser/types.js.map +0 -1
  149. package/dist/pipeline/conditions.d.ts +0 -134
  150. package/dist/pipeline/conditions.js +0 -406
  151. package/dist/pipeline/conditions.js.map +0 -1
  152. package/dist/pipeline/exclusive.js +0 -231
  153. package/dist/pipeline/exclusive.js.map +0 -1
  154. package/dist/pipeline/index.d.ts +0 -55
  155. package/dist/pipeline/index.js +0 -709
  156. package/dist/pipeline/index.js.map +0 -1
  157. package/dist/pipeline/materialize.js +0 -1104
  158. package/dist/pipeline/materialize.js.map +0 -1
  159. package/dist/pipeline/parseStateKey.d.ts +0 -15
  160. package/dist/pipeline/parseStateKey.js +0 -447
  161. package/dist/pipeline/parseStateKey.js.map +0 -1
  162. package/dist/pipeline/simplify.js +0 -516
  163. package/dist/pipeline/simplify.js.map +0 -1
  164. package/dist/pipeline/warnings.js +0 -18
  165. package/dist/pipeline/warnings.js.map +0 -1
  166. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  167. package/dist/plugins/okhsl-plugin.js +0 -98
  168. package/dist/plugins/okhsl-plugin.js.map +0 -1
  169. package/dist/plugins/types.d.ts +0 -76
  170. package/dist/properties/index.js +0 -223
  171. package/dist/properties/index.js.map +0 -1
  172. package/dist/properties/property-type-resolver.d.ts +0 -24
  173. package/dist/properties/property-type-resolver.js +0 -91
  174. package/dist/properties/property-type-resolver.js.map +0 -1
  175. package/dist/ssr/async-storage.d.ts +0 -17
  176. package/dist/ssr/async-storage.js.map +0 -1
  177. package/dist/ssr/collect-auto-properties.js +0 -40
  178. package/dist/ssr/collect-auto-properties.js.map +0 -1
  179. package/dist/ssr/collector.js.map +0 -1
  180. package/dist/ssr/context.d.ts +0 -8
  181. package/dist/ssr/context.js +0 -14
  182. package/dist/ssr/context.js.map +0 -1
  183. package/dist/ssr/format-global-rules.js.map +0 -1
  184. package/dist/ssr/format-keyframes.js +0 -70
  185. package/dist/ssr/format-keyframes.js.map +0 -1
  186. package/dist/ssr/format-property.js +0 -50
  187. package/dist/ssr/format-property.js.map +0 -1
  188. package/dist/ssr/format-rules.js +0 -73
  189. package/dist/ssr/format-rules.js.map +0 -1
  190. package/dist/ssr/hydrate.d.ts +0 -22
  191. package/dist/ssr/hydrate.js +0 -50
  192. package/dist/ssr/hydrate.js.map +0 -1
  193. package/dist/ssr/ssr-collector-ref.js +0 -12
  194. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  195. package/dist/states/index.d.ts +0 -49
  196. package/dist/states/index.js +0 -171
  197. package/dist/states/index.js.map +0 -1
  198. package/dist/static/tastyStatic.d.ts +0 -46
  199. package/dist/static/tastyStatic.js +0 -31
  200. package/dist/static/tastyStatic.js.map +0 -1
  201. package/dist/static/types.d.ts +0 -49
  202. package/dist/static/types.js +0 -24
  203. package/dist/static/types.js.map +0 -1
  204. package/dist/styles/align.d.ts +0 -15
  205. package/dist/styles/align.js +0 -14
  206. package/dist/styles/align.js.map +0 -1
  207. package/dist/styles/border.d.ts +0 -25
  208. package/dist/styles/border.js +0 -114
  209. package/dist/styles/border.js.map +0 -1
  210. package/dist/styles/color.d.ts +0 -14
  211. package/dist/styles/color.js +0 -27
  212. package/dist/styles/color.js.map +0 -1
  213. package/dist/styles/createStyle.js +0 -80
  214. package/dist/styles/createStyle.js.map +0 -1
  215. package/dist/styles/dimension.js +0 -97
  216. package/dist/styles/dimension.js.map +0 -1
  217. package/dist/styles/display.d.ts +0 -37
  218. package/dist/styles/display.js +0 -67
  219. package/dist/styles/display.js.map +0 -1
  220. package/dist/styles/fade.d.ts +0 -15
  221. package/dist/styles/fade.js +0 -58
  222. package/dist/styles/fade.js.map +0 -1
  223. package/dist/styles/fill.d.ts +0 -42
  224. package/dist/styles/fill.js +0 -52
  225. package/dist/styles/fill.js.map +0 -1
  226. package/dist/styles/flow.d.ts +0 -16
  227. package/dist/styles/flow.js +0 -12
  228. package/dist/styles/flow.js.map +0 -1
  229. package/dist/styles/gap.d.ts +0 -31
  230. package/dist/styles/gap.js +0 -37
  231. package/dist/styles/gap.js.map +0 -1
  232. package/dist/styles/height.d.ts +0 -17
  233. package/dist/styles/height.js +0 -20
  234. package/dist/styles/height.js.map +0 -1
  235. package/dist/styles/index.d.ts +0 -2
  236. package/dist/styles/index.js +0 -9
  237. package/dist/styles/index.js.map +0 -1
  238. package/dist/styles/inset.d.ts +0 -52
  239. package/dist/styles/inset.js +0 -150
  240. package/dist/styles/inset.js.map +0 -1
  241. package/dist/styles/justify.d.ts +0 -15
  242. package/dist/styles/justify.js +0 -14
  243. package/dist/styles/justify.js.map +0 -1
  244. package/dist/styles/list.d.ts +0 -16
  245. package/dist/styles/list.js +0 -98
  246. package/dist/styles/list.js.map +0 -1
  247. package/dist/styles/margin.d.ts +0 -24
  248. package/dist/styles/margin.js +0 -104
  249. package/dist/styles/margin.js.map +0 -1
  250. package/dist/styles/outline.d.ts +0 -29
  251. package/dist/styles/outline.js +0 -65
  252. package/dist/styles/outline.js.map +0 -1
  253. package/dist/styles/padding.d.ts +0 -24
  254. package/dist/styles/padding.js +0 -104
  255. package/dist/styles/padding.js.map +0 -1
  256. package/dist/styles/predefined.d.ts +0 -71
  257. package/dist/styles/predefined.js +0 -238
  258. package/dist/styles/predefined.js.map +0 -1
  259. package/dist/styles/preset.d.ts +0 -52
  260. package/dist/styles/preset.js +0 -127
  261. package/dist/styles/preset.js.map +0 -1
  262. package/dist/styles/radius.d.ts +0 -14
  263. package/dist/styles/radius.js +0 -51
  264. package/dist/styles/radius.js.map +0 -1
  265. package/dist/styles/scrollbar.d.ts +0 -25
  266. package/dist/styles/scrollbar.js +0 -48
  267. package/dist/styles/scrollbar.js.map +0 -1
  268. package/dist/styles/shadow.d.ts +0 -14
  269. package/dist/styles/shadow.js +0 -24
  270. package/dist/styles/shadow.js.map +0 -1
  271. package/dist/styles/transition.d.ts +0 -14
  272. package/dist/styles/transition.js +0 -158
  273. package/dist/styles/transition.js.map +0 -1
  274. package/dist/styles/types.d.ts +0 -547
  275. package/dist/styles/width.d.ts +0 -17
  276. package/dist/styles/width.js +0 -20
  277. package/dist/styles/width.js.map +0 -1
  278. package/dist/tasty.d.ts +0 -119
  279. package/dist/tasty.js +0 -232
  280. package/dist/tasty.js.map +0 -1
  281. package/dist/types.d.ts +0 -184
  282. package/dist/utils/cache-wrapper.js +0 -22
  283. package/dist/utils/cache-wrapper.js.map +0 -1
  284. package/dist/utils/case-converter.js +0 -8
  285. package/dist/utils/case-converter.js.map +0 -1
  286. package/dist/utils/color-math.d.ts +0 -46
  287. package/dist/utils/color-math.js +0 -749
  288. package/dist/utils/color-math.js.map +0 -1
  289. package/dist/utils/color-space.d.ts +0 -5
  290. package/dist/utils/color-space.js +0 -229
  291. package/dist/utils/color-space.js.map +0 -1
  292. package/dist/utils/colors.d.ts +0 -5
  293. package/dist/utils/colors.js +0 -11
  294. package/dist/utils/colors.js.map +0 -1
  295. package/dist/utils/css-types.d.ts +0 -7
  296. package/dist/utils/dotize.d.ts +0 -26
  297. package/dist/utils/dotize.js +0 -122
  298. package/dist/utils/dotize.js.map +0 -1
  299. package/dist/utils/filter-base-props.d.ts +0 -15
  300. package/dist/utils/filter-base-props.js +0 -45
  301. package/dist/utils/filter-base-props.js.map +0 -1
  302. package/dist/utils/get-display-name.d.ts +0 -7
  303. package/dist/utils/get-display-name.js +0 -10
  304. package/dist/utils/get-display-name.js.map +0 -1
  305. package/dist/utils/has-keys.js +0 -13
  306. package/dist/utils/has-keys.js.map +0 -1
  307. package/dist/utils/is-dev-env.js +0 -19
  308. package/dist/utils/is-dev-env.js.map +0 -1
  309. package/dist/utils/is-valid-element-type.js +0 -15
  310. package/dist/utils/is-valid-element-type.js.map +0 -1
  311. package/dist/utils/merge-styles.js.map +0 -1
  312. package/dist/utils/mod-attrs.d.ts +0 -8
  313. package/dist/utils/mod-attrs.js +0 -21
  314. package/dist/utils/mod-attrs.js.map +0 -1
  315. package/dist/utils/process-tokens.d.ts +0 -21
  316. package/dist/utils/process-tokens.js +0 -91
  317. package/dist/utils/process-tokens.js.map +0 -1
  318. package/dist/utils/resolve-recipes.d.ts +0 -17
  319. package/dist/utils/resolve-recipes.js.map +0 -1
  320. package/dist/utils/selector-transform.js +0 -32
  321. package/dist/utils/selector-transform.js.map +0 -1
  322. package/dist/utils/string.js +0 -8
  323. package/dist/utils/string.js.map +0 -1
  324. package/dist/utils/styles.d.ts +0 -99
  325. package/dist/utils/styles.js +0 -221
  326. package/dist/utils/styles.js.map +0 -1
  327. package/dist/utils/typography.d.ts +0 -47
  328. package/dist/utils/typography.js +0 -51
  329. package/dist/utils/typography.js.map +0 -1
  330. package/dist/utils/warnings.d.ts +0 -16
  331. package/dist/utils/warnings.js +0 -16
  332. package/dist/utils/warnings.js.map +0 -1
  333. package/dist/zero/css-writer.d.ts +0 -45
  334. package/dist/zero/css-writer.js +0 -74
  335. package/dist/zero/css-writer.js.map +0 -1
  336. package/dist/zero/extractor.d.ts +0 -24
  337. package/dist/zero/extractor.js.map +0 -1
  338. package/docs/PIPELINE.md +0 -519
@@ -0,0 +1,143 @@
1
+ import { Ct as getComponentPropertySyntax, St as getColorSpaceSuffix, et as parseStyle, jt as getEffectiveDefinition, yt as colorInitialValueToComponents } from "./config-B-MrRhXI.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-BKklQSdD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-rules-BKklQSdD.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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"}
@@ -0,0 +1,45 @@
1
+ import { s as getGlobalInjector } from "./config-B-MrRhXI.js";
2
+ //#region src/ssr/hydrate.ts
3
+ /**
4
+ * Client-side cache hydration for SSR/RSC.
5
+ *
6
+ * Pre-populates the client injector's rules map with class names
7
+ * rendered on the server. With hash-based naming, the client derives
8
+ * the same class name from the same cache key, so only the class name
9
+ * list needs to cross the wire — no cache keys or counters.
10
+ */
11
+ /**
12
+ * Pre-populate the client-side style registry from the server's class name list.
13
+ *
14
+ * Call this before ReactDOM.hydrateRoot() or ensure it runs before
15
+ * any tasty() component renders on the client.
16
+ *
17
+ * When called without arguments, reads the class list from `window.__TASTY__`
18
+ * (populated by inline scripts emitted during SSR/RSC streaming).
19
+ */
20
+ function hydrateTastyClasses(classes) {
21
+ if (typeof document === "undefined") return;
22
+ if (!classes) classes = typeof window !== "undefined" ? window.__TASTY__ : void 0;
23
+ if (!classes?.length) return;
24
+ const registry = getGlobalInjector()._sheetManager.getRegistry(document);
25
+ for (const cls of classes) if (!registry.rules.has(cls)) {
26
+ registry.rules.set(cls, {
27
+ className: cls,
28
+ ruleIndex: -2,
29
+ sheetIndex: -2
30
+ });
31
+ registry.refCounts.set(cls, 0);
32
+ }
33
+ }
34
+ /**
35
+ * @deprecated Use `hydrateTastyClasses()` instead. This alias exists
36
+ * for backwards compatibility and will be removed in a future major version.
37
+ */
38
+ function hydrateTastyCache(state) {
39
+ if (state?.entries) hydrateTastyClasses(Object.values(state.entries));
40
+ else hydrateTastyClasses();
41
+ }
42
+ //#endregion
43
+ export { hydrateTastyClasses as n, hydrateTastyCache as t };
44
+
45
+ //# sourceMappingURL=hydrate-DSK0D4y1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate-DSK0D4y1.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,kBACO,CAAC,CAAC,cAAc,YAAY,QAAQ;CAE5D,KAAK,MAAM,OAAO,SAChB,IAAI,CAAC,SAAS,MAAM,IAAI,GAAG,GAAG;EAC5B,SAAS,MAAM,IAAI,KAAK;GACtB,WAAW;GACX,WAAA;GACA,YAAA;EACF,CAAC;EACD,SAAS,UAAU,IAAI,KAAK,CAAC;CAC/B;AAEJ;;;;;AAMA,SAAgB,kBAAkB,OAEzB;CACP,IAAI,OAAO,SACT,oBAAoB,OAAO,OAAO,MAAM,OAAO,CAAC;MAEhD,oBAAoB;AAExB"}