@tenphi/tasty 0.0.0-snapshot.2dc73be → 0.0.0-snapshot.2f41cf6

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 (326) hide show
  1. package/README.md +298 -250
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +17 -8
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/collector-BMEQCkCn.js +243 -0
  5. package/dist/collector-BMEQCkCn.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-osfWTeRd.d.ts} +38 -15
  7. package/dist/config-BoZDUHW5.d.ts +945 -0
  8. package/dist/config-eiremPHv.js +10559 -0
  9. package/dist/config-eiremPHv.js.map +1 -0
  10. package/dist/context-CkSg-kDT.js +24 -0
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -33
  13. package/dist/core/index.js +6 -26
  14. package/dist/core-Dm9EkOA_.js +1598 -0
  15. package/dist/core-Dm9EkOA_.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-BSv8PrEX.js} +149 -13
  17. package/dist/css-writer-BSv8PrEX.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +3 -3
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-DcFFQceU.js +143 -0
  21. package/dist/format-rules-DcFFQceU.js.map +1 -0
  22. package/dist/hydrate-B6SjFHhj.js +45 -0
  23. package/dist/hydrate-B6SjFHhj.js.map +1 -0
  24. package/dist/index-D-OA_O6i.d.ts +1748 -0
  25. package/dist/index-tcHuMPFt.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -48
  27. package/dist/index.js +731 -32
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-DJ8Geo4L.js +595 -0
  30. package/dist/keyframes-DJ8Geo4L.js.map +1 -0
  31. package/dist/{utils/merge-styles.js → merge-styles-3il_ClCF.js} +4 -6
  32. package/dist/merge-styles-3il_ClCF.js.map +1 -0
  33. package/dist/{utils/merge-styles.d.ts → merge-styles-BMWcH6MF.d.ts} +3 -3
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-B3MSkfFQ.js} +5 -8
  35. package/dist/resolve-recipes-B3MSkfFQ.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 +116 -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 +7 -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 +49 -95
  58. package/dist/zero/babel.js +203 -48
  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 +28 -1
  63. package/dist/zero/next.js +70 -15
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +31 -0
  66. package/docs/adoption.md +298 -0
  67. package/docs/comparison.md +419 -0
  68. package/docs/configuration.md +239 -12
  69. package/docs/debug.md +155 -340
  70. package/docs/design-system.md +436 -0
  71. package/docs/dsl.md +690 -0
  72. package/docs/getting-started.md +217 -0
  73. package/docs/injector.md +45 -29
  74. package/docs/methodology.md +642 -0
  75. package/docs/pipeline.md +699 -0
  76. package/docs/react-api.md +581 -0
  77. package/docs/ssr.md +156 -84
  78. package/docs/styles.md +50 -26
  79. package/docs/tasty-static.md +194 -23
  80. package/package.json +40 -15
  81. package/tasty.config.ts +1 -0
  82. package/dist/_virtual/_rolldown/runtime.js +0 -8
  83. package/dist/chunks/cacheKey.js +0 -70
  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 -61
  89. package/dist/chunks/renderChunk.js.map +0 -1
  90. package/dist/config.d.ts +0 -288
  91. package/dist/config.js +0 -417
  92. package/dist/config.js.map +0 -1
  93. package/dist/debug.d.ts +0 -204
  94. package/dist/debug.js +0 -733
  95. package/dist/debug.js.map +0 -1
  96. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  97. package/dist/hooks/useGlobalStyles.js +0 -83
  98. package/dist/hooks/useGlobalStyles.js.map +0 -1
  99. package/dist/hooks/useKeyframes.d.ts +0 -56
  100. package/dist/hooks/useKeyframes.js +0 -69
  101. package/dist/hooks/useKeyframes.js.map +0 -1
  102. package/dist/hooks/useProperty.d.ts +0 -79
  103. package/dist/hooks/useProperty.js +0 -114
  104. package/dist/hooks/useProperty.js.map +0 -1
  105. package/dist/hooks/useRawCSS.d.ts +0 -53
  106. package/dist/hooks/useRawCSS.js +0 -40
  107. package/dist/hooks/useRawCSS.js.map +0 -1
  108. package/dist/hooks/useStyles.d.ts +0 -45
  109. package/dist/hooks/useStyles.js +0 -248
  110. package/dist/hooks/useStyles.js.map +0 -1
  111. package/dist/injector/index.d.ts +0 -165
  112. package/dist/injector/index.js +0 -162
  113. package/dist/injector/index.js.map +0 -1
  114. package/dist/injector/injector.d.ts +0 -148
  115. package/dist/injector/injector.js +0 -436
  116. package/dist/injector/injector.js.map +0 -1
  117. package/dist/injector/sheet-manager.d.ts +0 -136
  118. package/dist/injector/sheet-manager.js +0 -729
  119. package/dist/injector/sheet-manager.js.map +0 -1
  120. package/dist/injector/types.d.ts +0 -144
  121. package/dist/keyframes/index.js +0 -206
  122. package/dist/keyframes/index.js.map +0 -1
  123. package/dist/parser/classify.js +0 -319
  124. package/dist/parser/classify.js.map +0 -1
  125. package/dist/parser/const.js +0 -33
  126. package/dist/parser/const.js.map +0 -1
  127. package/dist/parser/lru.js +0 -109
  128. package/dist/parser/lru.js.map +0 -1
  129. package/dist/parser/parser.d.ts +0 -25
  130. package/dist/parser/parser.js +0 -116
  131. package/dist/parser/parser.js.map +0 -1
  132. package/dist/parser/tokenizer.js +0 -69
  133. package/dist/parser/tokenizer.js.map +0 -1
  134. package/dist/parser/types.d.ts +0 -51
  135. package/dist/parser/types.js +0 -46
  136. package/dist/parser/types.js.map +0 -1
  137. package/dist/pipeline/conditions.d.ts +0 -134
  138. package/dist/pipeline/conditions.js +0 -406
  139. package/dist/pipeline/conditions.js.map +0 -1
  140. package/dist/pipeline/exclusive.js +0 -231
  141. package/dist/pipeline/exclusive.js.map +0 -1
  142. package/dist/pipeline/index.d.ts +0 -53
  143. package/dist/pipeline/index.js +0 -660
  144. package/dist/pipeline/index.js.map +0 -1
  145. package/dist/pipeline/materialize.js +0 -856
  146. package/dist/pipeline/materialize.js.map +0 -1
  147. package/dist/pipeline/parseStateKey.d.ts +0 -15
  148. package/dist/pipeline/parseStateKey.js +0 -451
  149. package/dist/pipeline/parseStateKey.js.map +0 -1
  150. package/dist/pipeline/simplify.js +0 -516
  151. package/dist/pipeline/simplify.js.map +0 -1
  152. package/dist/pipeline/warnings.js +0 -18
  153. package/dist/pipeline/warnings.js.map +0 -1
  154. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  155. package/dist/plugins/okhsl-plugin.js +0 -371
  156. package/dist/plugins/okhsl-plugin.js.map +0 -1
  157. package/dist/plugins/types.d.ts +0 -69
  158. package/dist/properties/index.js +0 -236
  159. package/dist/properties/index.js.map +0 -1
  160. package/dist/properties/property-type-resolver.d.ts +0 -24
  161. package/dist/properties/property-type-resolver.js +0 -87
  162. package/dist/properties/property-type-resolver.js.map +0 -1
  163. package/dist/ssr/async-storage.d.ts +0 -17
  164. package/dist/ssr/async-storage.js.map +0 -1
  165. package/dist/ssr/collect-auto-properties.js +0 -40
  166. package/dist/ssr/collect-auto-properties.js.map +0 -1
  167. package/dist/ssr/collector.js +0 -173
  168. package/dist/ssr/collector.js.map +0 -1
  169. package/dist/ssr/context.d.ts +0 -8
  170. package/dist/ssr/context.js +0 -14
  171. package/dist/ssr/context.js.map +0 -1
  172. package/dist/ssr/format-global-rules.js.map +0 -1
  173. package/dist/ssr/format-keyframes.js +0 -70
  174. package/dist/ssr/format-keyframes.js.map +0 -1
  175. package/dist/ssr/format-property.js +0 -48
  176. package/dist/ssr/format-property.js.map +0 -1
  177. package/dist/ssr/format-rules.js +0 -70
  178. package/dist/ssr/format-rules.js.map +0 -1
  179. package/dist/ssr/hydrate.d.ts +0 -22
  180. package/dist/ssr/hydrate.js +0 -50
  181. package/dist/ssr/hydrate.js.map +0 -1
  182. package/dist/ssr/ssr-collector-ref.js +0 -12
  183. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  184. package/dist/states/index.d.ts +0 -49
  185. package/dist/states/index.js +0 -416
  186. package/dist/states/index.js.map +0 -1
  187. package/dist/static/tastyStatic.d.ts +0 -46
  188. package/dist/static/tastyStatic.js +0 -31
  189. package/dist/static/tastyStatic.js.map +0 -1
  190. package/dist/static/types.d.ts +0 -49
  191. package/dist/static/types.js +0 -24
  192. package/dist/static/types.js.map +0 -1
  193. package/dist/styles/align.d.ts +0 -15
  194. package/dist/styles/align.js +0 -14
  195. package/dist/styles/align.js.map +0 -1
  196. package/dist/styles/border.d.ts +0 -25
  197. package/dist/styles/border.js +0 -114
  198. package/dist/styles/border.js.map +0 -1
  199. package/dist/styles/color.d.ts +0 -14
  200. package/dist/styles/color.js +0 -23
  201. package/dist/styles/color.js.map +0 -1
  202. package/dist/styles/createStyle.js +0 -77
  203. package/dist/styles/createStyle.js.map +0 -1
  204. package/dist/styles/dimension.js +0 -97
  205. package/dist/styles/dimension.js.map +0 -1
  206. package/dist/styles/display.d.ts +0 -37
  207. package/dist/styles/display.js +0 -67
  208. package/dist/styles/display.js.map +0 -1
  209. package/dist/styles/fade.d.ts +0 -15
  210. package/dist/styles/fade.js +0 -58
  211. package/dist/styles/fade.js.map +0 -1
  212. package/dist/styles/fill.d.ts +0 -42
  213. package/dist/styles/fill.js +0 -52
  214. package/dist/styles/fill.js.map +0 -1
  215. package/dist/styles/flow.d.ts +0 -16
  216. package/dist/styles/flow.js +0 -12
  217. package/dist/styles/flow.js.map +0 -1
  218. package/dist/styles/gap.d.ts +0 -31
  219. package/dist/styles/gap.js +0 -37
  220. package/dist/styles/gap.js.map +0 -1
  221. package/dist/styles/height.d.ts +0 -17
  222. package/dist/styles/height.js +0 -20
  223. package/dist/styles/height.js.map +0 -1
  224. package/dist/styles/index.d.ts +0 -2
  225. package/dist/styles/index.js +0 -9
  226. package/dist/styles/index.js.map +0 -1
  227. package/dist/styles/inset.d.ts +0 -52
  228. package/dist/styles/inset.js +0 -150
  229. package/dist/styles/inset.js.map +0 -1
  230. package/dist/styles/justify.d.ts +0 -15
  231. package/dist/styles/justify.js +0 -14
  232. package/dist/styles/justify.js.map +0 -1
  233. package/dist/styles/list.d.ts +0 -16
  234. package/dist/styles/list.js +0 -98
  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 -104
  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 -65
  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 -104
  244. package/dist/styles/padding.js.map +0 -1
  245. package/dist/styles/predefined.d.ts +0 -71
  246. package/dist/styles/predefined.js +0 -238
  247. package/dist/styles/predefined.js.map +0 -1
  248. package/dist/styles/preset.d.ts +0 -47
  249. package/dist/styles/preset.js +0 -126
  250. package/dist/styles/preset.js.map +0 -1
  251. package/dist/styles/radius.d.ts +0 -14
  252. package/dist/styles/radius.js +0 -51
  253. package/dist/styles/radius.js.map +0 -1
  254. package/dist/styles/scrollbar.d.ts +0 -25
  255. package/dist/styles/scrollbar.js +0 -48
  256. package/dist/styles/scrollbar.js.map +0 -1
  257. package/dist/styles/shadow.d.ts +0 -14
  258. package/dist/styles/shadow.js +0 -24
  259. package/dist/styles/shadow.js.map +0 -1
  260. package/dist/styles/transition.d.ts +0 -14
  261. package/dist/styles/transition.js +0 -158
  262. package/dist/styles/transition.js.map +0 -1
  263. package/dist/styles/types.d.ts +0 -495
  264. package/dist/styles/width.d.ts +0 -17
  265. package/dist/styles/width.js +0 -20
  266. package/dist/styles/width.js.map +0 -1
  267. package/dist/tasty.d.ts +0 -981
  268. package/dist/tasty.js +0 -206
  269. package/dist/tasty.js.map +0 -1
  270. package/dist/tokens/typography.d.ts +0 -19
  271. package/dist/tokens/typography.js +0 -237
  272. package/dist/tokens/typography.js.map +0 -1
  273. package/dist/types.d.ts +0 -184
  274. package/dist/utils/cache-wrapper.js +0 -26
  275. package/dist/utils/cache-wrapper.js.map +0 -1
  276. package/dist/utils/case-converter.js +0 -8
  277. package/dist/utils/case-converter.js.map +0 -1
  278. package/dist/utils/colors.d.ts +0 -5
  279. package/dist/utils/colors.js +0 -9
  280. package/dist/utils/colors.js.map +0 -1
  281. package/dist/utils/css-types.d.ts +0 -7
  282. package/dist/utils/dotize.d.ts +0 -26
  283. package/dist/utils/dotize.js +0 -122
  284. package/dist/utils/dotize.js.map +0 -1
  285. package/dist/utils/filter-base-props.d.ts +0 -15
  286. package/dist/utils/filter-base-props.js +0 -45
  287. package/dist/utils/filter-base-props.js.map +0 -1
  288. package/dist/utils/get-display-name.d.ts +0 -7
  289. package/dist/utils/get-display-name.js +0 -10
  290. package/dist/utils/get-display-name.js.map +0 -1
  291. package/dist/utils/hsl-to-rgb.js +0 -38
  292. package/dist/utils/hsl-to-rgb.js.map +0 -1
  293. package/dist/utils/is-dev-env.js +0 -19
  294. package/dist/utils/is-dev-env.js.map +0 -1
  295. package/dist/utils/is-valid-element-type.js +0 -15
  296. package/dist/utils/is-valid-element-type.js.map +0 -1
  297. package/dist/utils/merge-styles.js.map +0 -1
  298. package/dist/utils/mod-attrs.d.ts +0 -8
  299. package/dist/utils/mod-attrs.js +0 -21
  300. package/dist/utils/mod-attrs.js.map +0 -1
  301. package/dist/utils/okhsl-to-rgb.js +0 -296
  302. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  303. package/dist/utils/process-tokens.d.ts +0 -31
  304. package/dist/utils/process-tokens.js +0 -171
  305. package/dist/utils/process-tokens.js.map +0 -1
  306. package/dist/utils/resolve-recipes.d.ts +0 -17
  307. package/dist/utils/resolve-recipes.js.map +0 -1
  308. package/dist/utils/selector-transform.js +0 -32
  309. package/dist/utils/selector-transform.js.map +0 -1
  310. package/dist/utils/string.js +0 -8
  311. package/dist/utils/string.js.map +0 -1
  312. package/dist/utils/styles.d.ts +0 -177
  313. package/dist/utils/styles.js +0 -730
  314. package/dist/utils/styles.js.map +0 -1
  315. package/dist/utils/typography.d.ts +0 -36
  316. package/dist/utils/typography.js +0 -53
  317. package/dist/utils/typography.js.map +0 -1
  318. package/dist/utils/warnings.d.ts +0 -16
  319. package/dist/utils/warnings.js +0 -16
  320. package/dist/utils/warnings.js.map +0 -1
  321. package/dist/zero/css-writer.d.ts +0 -45
  322. package/dist/zero/css-writer.js +0 -74
  323. package/dist/zero/css-writer.js.map +0 -1
  324. package/dist/zero/extractor.d.ts +0 -24
  325. package/dist/zero/extractor.js.map +0 -1
  326. package/docs/usage.md +0 -695
@@ -0,0 +1,143 @@
1
+ import { _t as colorInitialValueToComponents, bt as getColorSpaceSuffix, et as parseStyle, kt as getEffectiveDefinition, xt as getComponentPropertySyntax } from "./config-eiremPHv.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-DcFFQceU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-rules-DcFFQceU.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":";;AAsBA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;;;;;AAMlD,SAAgB,2BAA2B,IAA8B;CACvE,mBAAmB;;;;;;AAOrB,SAAgB,iCAAiC,IAA8B;CAC7E,WAAwC,cAAc;;;;;AAMxD,SAAgB,4BAAyD;CACvE,IAAI,k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KAAK;EACT,MAAM,WAAW,GAAG,KAAK,SAAS,KAAK,aAAa;EAEpD,IAAI,WAAW;EACf,IAAI,KAAK,WAAW,KAAK,QAAQ,SAAS,GACxC,WAAW,KAAK,QAAQ,QACrB,KAAK,WAAW,GAAG,OAAO,KAAK,IAAI,KACpC,SACD;EAGH,SAAS,KAAK,SAAS;;CAGzB,OAAO,SAAS,KAAK,KAAK"}
@@ -0,0 +1,45 @@
1
+ import { s as getGlobalInjector } from "./config-eiremPHv.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-B6SjFHhj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate-B6SjFHhj.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"}