@tenphi/tasty 0.0.0-snapshot.db103fd → 0.0.0-snapshot.dd9840e

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 (334) hide show
  1. package/README.md +29 -23
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +16 -6
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/{ssr/collector.js → collector-DrgDE7QB.js} +36 -32
  5. package/dist/collector-DrgDE7QB.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-LuU1vZ68.d.ts} +11 -15
  7. package/dist/config-_aQ_PZ-P.js +10131 -0
  8. package/dist/config-_aQ_PZ-P.js.map +1 -0
  9. package/dist/config-vuCRkBWX.d.ts +884 -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-BqO8pplb.js +1592 -0
  15. package/dist/core-BqO8pplb.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-D--REwtp.js} +74 -11
  17. package/dist/css-writer-D--REwtp.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-xwteB7a1.js +143 -0
  21. package/dist/format-rules-xwteB7a1.js.map +1 -0
  22. package/dist/hydrate-BvPT4ndL.js +45 -0
  23. package/dist/hydrate-BvPT4ndL.js.map +1 -0
  24. package/dist/index-dUtwpOux.d.ts +1266 -0
  25. package/dist/index-h0MibUBL.d.ts +1602 -0
  26. package/dist/index.d.ts +5 -50
  27. package/dist/index.js +732 -35
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-ClPFWy33.js +587 -0
  30. package/dist/keyframes-ClPFWy33.js.map +1 -0
  31. package/dist/{utils/merge-styles.js → merge-styles-BUQsEpbv.js} +3 -4
  32. package/dist/merge-styles-BUQsEpbv.js.map +1 -0
  33. package/dist/{utils/merge-styles.d.ts → merge-styles-CtDJMhpJ.d.ts} +3 -3
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-C0-AMzCz.js} +4 -6
  35. package/dist/resolve-recipes-C0-AMzCz.js.map +1 -0
  36. package/dist/ssr/astro-client.js +19 -0
  37. package/dist/ssr/astro-client.js.map +1 -0
  38. package/dist/ssr/astro-middleware.d.ts +15 -0
  39. package/dist/ssr/astro-middleware.js +19 -0
  40. package/dist/ssr/astro-middleware.js.map +1 -0
  41. package/dist/ssr/astro.d.ts +89 -10
  42. package/dist/ssr/astro.js +115 -30
  43. package/dist/ssr/astro.js.map +1 -1
  44. package/dist/ssr/index.d.ts +44 -5
  45. package/dist/ssr/index.js +6 -7
  46. package/dist/ssr/index.js.map +1 -1
  47. package/dist/ssr/next.d.ts +5 -4
  48. package/dist/ssr/next.js +16 -10
  49. package/dist/ssr/next.js.map +1 -1
  50. package/dist/static/index.d.ts +91 -5
  51. package/dist/static/index.js +49 -3
  52. package/dist/static/index.js.map +1 -0
  53. package/dist/zero/babel.d.ts +7 -108
  54. package/dist/zero/babel.js +45 -17
  55. package/dist/zero/babel.js.map +1 -1
  56. package/dist/zero/index.d.ts +67 -3
  57. package/dist/zero/index.js +1 -2
  58. package/docs/README.md +4 -4
  59. package/docs/adoption.md +5 -3
  60. package/docs/comparison.md +24 -25
  61. package/docs/configuration.md +69 -1
  62. package/docs/debug.md +11 -9
  63. package/docs/design-system.md +22 -10
  64. package/docs/dsl.md +23 -8
  65. package/docs/getting-started.md +10 -10
  66. package/docs/injector.md +43 -27
  67. package/docs/methodology.md +52 -3
  68. package/docs/{PIPELINE.md → pipeline.md} +204 -50
  69. package/docs/{runtime.md → react-api.md} +104 -32
  70. package/docs/ssr.md +139 -81
  71. package/docs/styles.md +14 -0
  72. package/docs/tasty-static.md +14 -2
  73. package/package.json +17 -10
  74. package/dist/_virtual/_rolldown/runtime.js +0 -7
  75. package/dist/chunks/cacheKey.js +0 -77
  76. package/dist/chunks/cacheKey.js.map +0 -1
  77. package/dist/chunks/definitions.d.ts +0 -37
  78. package/dist/chunks/definitions.js +0 -258
  79. package/dist/chunks/definitions.js.map +0 -1
  80. package/dist/chunks/index.d.ts +0 -1
  81. package/dist/chunks/renderChunk.d.ts +0 -1
  82. package/dist/chunks/renderChunk.js +0 -59
  83. package/dist/chunks/renderChunk.js.map +0 -1
  84. package/dist/config.d.ts +0 -366
  85. package/dist/config.js +0 -503
  86. package/dist/config.js.map +0 -1
  87. package/dist/counter-style/index.js +0 -51
  88. package/dist/counter-style/index.js.map +0 -1
  89. package/dist/debug.d.ts +0 -89
  90. package/dist/debug.js +0 -453
  91. package/dist/debug.js.map +0 -1
  92. package/dist/font-face/index.js +0 -63
  93. package/dist/font-face/index.js.map +0 -1
  94. package/dist/hooks/index.d.ts +0 -7
  95. package/dist/hooks/resolve-ssr-collector.js +0 -14
  96. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  97. package/dist/hooks/useCounterStyle.d.ts +0 -50
  98. package/dist/hooks/useCounterStyle.js +0 -46
  99. package/dist/hooks/useCounterStyle.js.map +0 -1
  100. package/dist/hooks/useFontFace.d.ts +0 -43
  101. package/dist/hooks/useFontFace.js +0 -70
  102. package/dist/hooks/useFontFace.js.map +0 -1
  103. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  104. package/dist/hooks/useGlobalStyles.js +0 -78
  105. package/dist/hooks/useGlobalStyles.js.map +0 -1
  106. package/dist/hooks/useKeyframes.d.ts +0 -56
  107. package/dist/hooks/useKeyframes.js +0 -64
  108. package/dist/hooks/useKeyframes.js.map +0 -1
  109. package/dist/hooks/useProperty.d.ts +0 -79
  110. package/dist/hooks/useProperty.js +0 -109
  111. package/dist/hooks/useProperty.js.map +0 -1
  112. package/dist/hooks/useRawCSS.d.ts +0 -53
  113. package/dist/hooks/useRawCSS.js +0 -35
  114. package/dist/hooks/useRawCSS.js.map +0 -1
  115. package/dist/hooks/useStyles.d.ts +0 -45
  116. package/dist/hooks/useStyles.js +0 -237
  117. package/dist/hooks/useStyles.js.map +0 -1
  118. package/dist/injector/index.d.ts +0 -183
  119. package/dist/injector/index.js +0 -179
  120. package/dist/injector/index.js.map +0 -1
  121. package/dist/injector/injector.d.ts +0 -166
  122. package/dist/injector/injector.js +0 -464
  123. package/dist/injector/injector.js.map +0 -1
  124. package/dist/injector/sheet-manager.d.ts +0 -136
  125. package/dist/injector/sheet-manager.js +0 -733
  126. package/dist/injector/sheet-manager.js.map +0 -1
  127. package/dist/injector/types.d.ts +0 -204
  128. package/dist/keyframes/index.js +0 -206
  129. package/dist/keyframes/index.js.map +0 -1
  130. package/dist/parser/classify.js +0 -319
  131. package/dist/parser/classify.js.map +0 -1
  132. package/dist/parser/const.js +0 -49
  133. package/dist/parser/const.js.map +0 -1
  134. package/dist/parser/lru.js +0 -109
  135. package/dist/parser/lru.js.map +0 -1
  136. package/dist/parser/parser.d.ts +0 -25
  137. package/dist/parser/parser.js +0 -115
  138. package/dist/parser/parser.js.map +0 -1
  139. package/dist/parser/tokenizer.js +0 -69
  140. package/dist/parser/tokenizer.js.map +0 -1
  141. package/dist/parser/types.d.ts +0 -51
  142. package/dist/parser/types.js +0 -46
  143. package/dist/parser/types.js.map +0 -1
  144. package/dist/pipeline/conditions.d.ts +0 -134
  145. package/dist/pipeline/conditions.js +0 -406
  146. package/dist/pipeline/conditions.js.map +0 -1
  147. package/dist/pipeline/exclusive.js +0 -230
  148. package/dist/pipeline/exclusive.js.map +0 -1
  149. package/dist/pipeline/index.d.ts +0 -55
  150. package/dist/pipeline/index.js +0 -708
  151. package/dist/pipeline/index.js.map +0 -1
  152. package/dist/pipeline/materialize.js +0 -1103
  153. package/dist/pipeline/materialize.js.map +0 -1
  154. package/dist/pipeline/parseStateKey.d.ts +0 -15
  155. package/dist/pipeline/parseStateKey.js +0 -446
  156. package/dist/pipeline/parseStateKey.js.map +0 -1
  157. package/dist/pipeline/simplify.js +0 -515
  158. package/dist/pipeline/simplify.js.map +0 -1
  159. package/dist/pipeline/warnings.js +0 -18
  160. package/dist/pipeline/warnings.js.map +0 -1
  161. package/dist/plugins/index.d.ts +0 -2
  162. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  163. package/dist/plugins/okhsl-plugin.js +0 -97
  164. package/dist/plugins/okhsl-plugin.js.map +0 -1
  165. package/dist/plugins/types.d.ts +0 -76
  166. package/dist/properties/index.js +0 -222
  167. package/dist/properties/index.js.map +0 -1
  168. package/dist/properties/property-type-resolver.d.ts +0 -24
  169. package/dist/properties/property-type-resolver.js +0 -90
  170. package/dist/properties/property-type-resolver.js.map +0 -1
  171. package/dist/ssr/async-storage.d.ts +0 -17
  172. package/dist/ssr/async-storage.js.map +0 -1
  173. package/dist/ssr/collect-auto-properties.js +0 -39
  174. package/dist/ssr/collect-auto-properties.js.map +0 -1
  175. package/dist/ssr/collector.js.map +0 -1
  176. package/dist/ssr/context.d.ts +0 -8
  177. package/dist/ssr/context.js +0 -13
  178. package/dist/ssr/context.js.map +0 -1
  179. package/dist/ssr/format-global-rules.js.map +0 -1
  180. package/dist/ssr/format-keyframes.js +0 -69
  181. package/dist/ssr/format-keyframes.js.map +0 -1
  182. package/dist/ssr/format-property.js +0 -49
  183. package/dist/ssr/format-property.js.map +0 -1
  184. package/dist/ssr/format-rules.js +0 -73
  185. package/dist/ssr/format-rules.js.map +0 -1
  186. package/dist/ssr/hydrate.d.ts +0 -22
  187. package/dist/ssr/hydrate.js +0 -49
  188. package/dist/ssr/hydrate.js.map +0 -1
  189. package/dist/ssr/ssr-collector-ref.js +0 -12
  190. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  191. package/dist/states/index.d.ts +0 -49
  192. package/dist/states/index.js +0 -170
  193. package/dist/states/index.js.map +0 -1
  194. package/dist/static/tastyStatic.d.ts +0 -46
  195. package/dist/static/tastyStatic.js +0 -30
  196. package/dist/static/tastyStatic.js.map +0 -1
  197. package/dist/static/types.d.ts +0 -49
  198. package/dist/static/types.js +0 -24
  199. package/dist/static/types.js.map +0 -1
  200. package/dist/styles/align.d.ts +0 -15
  201. package/dist/styles/align.js +0 -14
  202. package/dist/styles/align.js.map +0 -1
  203. package/dist/styles/border.d.ts +0 -25
  204. package/dist/styles/border.js +0 -113
  205. package/dist/styles/border.js.map +0 -1
  206. package/dist/styles/color.d.ts +0 -14
  207. package/dist/styles/color.js +0 -26
  208. package/dist/styles/color.js.map +0 -1
  209. package/dist/styles/createStyle.js +0 -79
  210. package/dist/styles/createStyle.js.map +0 -1
  211. package/dist/styles/dimension.js +0 -96
  212. package/dist/styles/dimension.js.map +0 -1
  213. package/dist/styles/display.d.ts +0 -37
  214. package/dist/styles/display.js +0 -66
  215. package/dist/styles/display.js.map +0 -1
  216. package/dist/styles/fade.d.ts +0 -15
  217. package/dist/styles/fade.js +0 -57
  218. package/dist/styles/fade.js.map +0 -1
  219. package/dist/styles/fill.d.ts +0 -42
  220. package/dist/styles/fill.js +0 -51
  221. package/dist/styles/fill.js.map +0 -1
  222. package/dist/styles/flow.d.ts +0 -16
  223. package/dist/styles/flow.js +0 -12
  224. package/dist/styles/flow.js.map +0 -1
  225. package/dist/styles/gap.d.ts +0 -31
  226. package/dist/styles/gap.js +0 -36
  227. package/dist/styles/gap.js.map +0 -1
  228. package/dist/styles/height.d.ts +0 -17
  229. package/dist/styles/height.js +0 -19
  230. package/dist/styles/height.js.map +0 -1
  231. package/dist/styles/index.d.ts +0 -1
  232. package/dist/styles/index.js +0 -8
  233. package/dist/styles/index.js.map +0 -1
  234. package/dist/styles/inset.d.ts +0 -52
  235. package/dist/styles/inset.js +0 -149
  236. package/dist/styles/inset.js.map +0 -1
  237. package/dist/styles/justify.d.ts +0 -15
  238. package/dist/styles/justify.js +0 -14
  239. package/dist/styles/justify.js.map +0 -1
  240. package/dist/styles/list.d.ts +0 -16
  241. package/dist/styles/list.js +0 -98
  242. package/dist/styles/list.js.map +0 -1
  243. package/dist/styles/margin.d.ts +0 -24
  244. package/dist/styles/margin.js +0 -103
  245. package/dist/styles/margin.js.map +0 -1
  246. package/dist/styles/outline.d.ts +0 -29
  247. package/dist/styles/outline.js +0 -64
  248. package/dist/styles/outline.js.map +0 -1
  249. package/dist/styles/padding.d.ts +0 -24
  250. package/dist/styles/padding.js +0 -103
  251. package/dist/styles/padding.js.map +0 -1
  252. package/dist/styles/predefined.d.ts +0 -71
  253. package/dist/styles/predefined.js +0 -237
  254. package/dist/styles/predefined.js.map +0 -1
  255. package/dist/styles/preset.d.ts +0 -52
  256. package/dist/styles/preset.js +0 -126
  257. package/dist/styles/preset.js.map +0 -1
  258. package/dist/styles/radius.d.ts +0 -12
  259. package/dist/styles/radius.js +0 -71
  260. package/dist/styles/radius.js.map +0 -1
  261. package/dist/styles/scrollbar.d.ts +0 -25
  262. package/dist/styles/scrollbar.js +0 -46
  263. package/dist/styles/scrollbar.js.map +0 -1
  264. package/dist/styles/shadow.d.ts +0 -14
  265. package/dist/styles/shadow.js +0 -23
  266. package/dist/styles/shadow.js.map +0 -1
  267. package/dist/styles/transition.d.ts +0 -14
  268. package/dist/styles/transition.js +0 -157
  269. package/dist/styles/transition.js.map +0 -1
  270. package/dist/styles/types.d.ts +0 -549
  271. package/dist/styles/width.d.ts +0 -17
  272. package/dist/styles/width.js +0 -19
  273. package/dist/styles/width.js.map +0 -1
  274. package/dist/tasty.d.ts +0 -119
  275. package/dist/tasty.js +0 -231
  276. package/dist/tasty.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -21
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/color-math.d.ts +0 -46
  283. package/dist/utils/color-math.js +0 -749
  284. package/dist/utils/color-math.js.map +0 -1
  285. package/dist/utils/color-space.d.ts +0 -5
  286. package/dist/utils/color-space.js +0 -228
  287. package/dist/utils/color-space.js.map +0 -1
  288. package/dist/utils/colors.d.ts +0 -5
  289. package/dist/utils/colors.js +0 -10
  290. package/dist/utils/colors.js.map +0 -1
  291. package/dist/utils/css-types.d.ts +0 -7
  292. package/dist/utils/dotize.d.ts +0 -26
  293. package/dist/utils/dotize.js +0 -122
  294. package/dist/utils/dotize.js.map +0 -1
  295. package/dist/utils/filter-base-props.d.ts +0 -15
  296. package/dist/utils/filter-base-props.js +0 -45
  297. package/dist/utils/filter-base-props.js.map +0 -1
  298. package/dist/utils/get-display-name.d.ts +0 -7
  299. package/dist/utils/get-display-name.js +0 -10
  300. package/dist/utils/get-display-name.js.map +0 -1
  301. package/dist/utils/has-keys.js +0 -13
  302. package/dist/utils/has-keys.js.map +0 -1
  303. package/dist/utils/is-dev-env.js +0 -19
  304. package/dist/utils/is-dev-env.js.map +0 -1
  305. package/dist/utils/is-valid-element-type.js +0 -15
  306. package/dist/utils/is-valid-element-type.js.map +0 -1
  307. package/dist/utils/merge-styles.js.map +0 -1
  308. package/dist/utils/mod-attrs.d.ts +0 -6
  309. package/dist/utils/mod-attrs.js +0 -20
  310. package/dist/utils/mod-attrs.js.map +0 -1
  311. package/dist/utils/process-tokens.d.ts +0 -21
  312. package/dist/utils/process-tokens.js +0 -90
  313. package/dist/utils/process-tokens.js.map +0 -1
  314. package/dist/utils/resolve-recipes.d.ts +0 -17
  315. package/dist/utils/resolve-recipes.js.map +0 -1
  316. package/dist/utils/selector-transform.js +0 -32
  317. package/dist/utils/selector-transform.js.map +0 -1
  318. package/dist/utils/string.js +0 -8
  319. package/dist/utils/string.js.map +0 -1
  320. package/dist/utils/styles.d.ts +0 -99
  321. package/dist/utils/styles.js +0 -220
  322. package/dist/utils/styles.js.map +0 -1
  323. package/dist/utils/typography.d.ts +0 -47
  324. package/dist/utils/typography.js +0 -51
  325. package/dist/utils/typography.js.map +0 -1
  326. package/dist/utils/warnings.d.ts +0 -16
  327. package/dist/utils/warnings.js +0 -16
  328. package/dist/utils/warnings.js.map +0 -1
  329. package/dist/zero/css-writer.d.ts +0 -45
  330. package/dist/zero/css-writer.js +0 -73
  331. package/dist/zero/css-writer.js.map +0 -1
  332. package/dist/zero/extractor.d.ts +0 -24
  333. package/dist/zero/extractor.js.map +0 -1
  334. /package/dist/{chunks/cacheKey.d.ts → ssr/astro-client.d.ts} +0 -0
package/dist/ssr/next.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use client";
2
- import { getConfig } from "../config.js";
3
- import { TastySSRContext } from "./context.js";
4
- import { ServerStyleCollector } from "./collector.js";
5
- import { hydrateTastyCache } from "./hydrate.js";
2
+ import { n as getConfig } from "../config-_aQ_PZ-P.js";
3
+ import { i as registerSSRCollectorGetter } from "../format-rules-xwteB7a1.js";
4
+ import { t as getTastySSRContext } from "../context-CkSg-kDT.js";
5
+ import { t as ServerStyleCollector } from "../collector-DrgDE7QB.js";
6
+ import { n as hydrateTastyClasses } from "../hydrate-BvPT4ndL.js";
6
7
  import { Fragment, createElement, useState } from "react";
7
8
  import { useServerInsertedHTML } from "next/navigation";
8
9
  //#region src/ssr/next.ts
@@ -14,7 +15,7 @@ import { useServerInsertedHTML } from "next/navigation";
14
15
  *
15
16
  * Import from '@tenphi/tasty/ssr/next'.
16
17
  */
17
- if (typeof window !== "undefined" && window.__TASTY_SSR_CACHE__) hydrateTastyCache(window.__TASTY_SSR_CACHE__);
18
+ if (typeof window !== "undefined") hydrateTastyClasses();
18
19
  /**
19
20
  * Next.js App Router registry for Tasty SSR.
20
21
  *
@@ -41,12 +42,17 @@ if (typeof window !== "undefined" && window.__TASTY_SSR_CACHE__) hydrateTastyCac
41
42
  */
42
43
  function TastyRegistry({ children, transferCache = true }) {
43
44
  const isClient = typeof window !== "undefined";
44
- const [collector] = useState(() => isClient ? null : new ServerStyleCollector());
45
+ const [collector] = useState(() => {
46
+ if (isClient) return null;
47
+ const instance = new ServerStyleCollector();
48
+ registerSSRCollectorGetter(() => instance);
49
+ return instance;
50
+ });
45
51
  const nonce = getConfig().nonce;
46
52
  useServerInsertedHTML(() => {
47
53
  if (!collector) return null;
48
54
  const css = collector.flushCSS();
49
- const cacheState = collector.getCacheState();
55
+ const classNames = collector.getRenderedClassNames();
50
56
  if (!css) return null;
51
57
  const styleEl = createElement("style", {
52
58
  key: "tasty-ssr-styles",
@@ -54,14 +60,14 @@ function TastyRegistry({ children, transferCache = true }) {
54
60
  nonce,
55
61
  dangerouslySetInnerHTML: { __html: css }
56
62
  });
57
- if (!transferCache) return styleEl;
63
+ if (!transferCache || classNames.length === 0) return styleEl;
58
64
  return createElement(Fragment, null, styleEl, createElement("script", {
59
65
  key: "tasty-ssr-cache",
60
66
  nonce,
61
- dangerouslySetInnerHTML: { __html: `(window.__TASTY_SSR_CACHE__=window.__TASTY_SSR_CACHE__||{entries:{},classCounter:0});Object.assign(window.__TASTY_SSR_CACHE__.entries,${JSON.stringify(cacheState.entries)});window.__TASTY_SSR_CACHE__.classCounter=${cacheState.classCounter};` }
67
+ dangerouslySetInnerHTML: { __html: `(window.__TASTY__=window.__TASTY__||[]).push(${classNames.map((n) => `"${n}"`).join(",")})` }
62
68
  }));
63
69
  });
64
- return createElement(TastySSRContext.Provider, { value: collector }, children);
70
+ return createElement(getTastySSRContext().Provider, { value: collector }, children);
65
71
  }
66
72
  //#endregion
67
73
  export { TastyRegistry };
@@ -1 +1 @@
1
- {"version":3,"file":"next.js","names":[],"sources":["../../src/ssr/next.ts"],"sourcesContent":["/**\n * Next.js integration for Tasty SSR.\n *\n * Provides TastyRegistry for App Router (streaming via useServerInsertedHTML)\n * and createTastySSRDocument for Pages Router (non-streaming).\n *\n * Import from '@tenphi/tasty/ssr/next'.\n */\n\n'use client';\n\n/// <reference path=\"./next-navigation.d.ts\" />\n\nimport { createElement, Fragment, useState, type ReactNode } from 'react';\nimport { useServerInsertedHTML } from 'next/navigation';\n\nimport { getConfig } from '../config';\nimport { ServerStyleCollector } from './collector';\nimport { TastySSRContext } from './context';\nimport { hydrateTastyCache } from './hydrate';\n\n// Auto-hydrate on module load (client only).\n// When this module is imported by the TastyRegistry client component,\n// the streaming cache scripts have already populated __TASTY_SSR_CACHE__.\nif (typeof window !== 'undefined' && window.__TASTY_SSR_CACHE__) {\n hydrateTastyCache(window.__TASTY_SSR_CACHE__);\n}\n\nexport interface TastyRegistryProps {\n children: ReactNode;\n /**\n * Whether to embed the cache state script for client hydration.\n * Set to false to skip cache transfer (useful when cache size\n * exceeds the hydration benefit). Default: true.\n */\n transferCache?: boolean;\n}\n\n/**\n * Next.js App Router registry for Tasty SSR.\n *\n * Wraps the component tree with a ServerStyleCollector and flushes\n * collected CSS into the HTML stream via useServerInsertedHTML.\n *\n * @example\n * ```tsx\n * // app/tasty-registry.tsx\n * 'use client';\n * import { TastyRegistry } from '@tenphi/tasty/ssr/next';\n * export default function TastyStyleRegistry({ children }) {\n * return <TastyRegistry>{children}</TastyRegistry>;\n * }\n *\n * // app/layout.tsx\n * import TastyStyleRegistry from './tasty-registry';\n * export default function RootLayout({ children }) {\n * return <html><body>\n * <TastyStyleRegistry>{children}</TastyStyleRegistry>\n * </body></html>;\n * }\n * ```\n */\nexport function TastyRegistry({\n children,\n transferCache = true,\n}: TastyRegistryProps) {\n const isClient = typeof window !== 'undefined';\n\n const [collector] = useState(() =>\n isClient ? null : new ServerStyleCollector(),\n );\n const nonce = getConfig().nonce;\n\n useServerInsertedHTML(() => {\n if (!collector) return null;\n\n const css = collector.flushCSS();\n const cacheState = collector.getCacheState();\n\n if (!css) return null;\n\n const styleEl = createElement('style', {\n key: 'tasty-ssr-styles',\n 'data-tasty-ssr': '',\n nonce,\n dangerouslySetInnerHTML: { __html: css },\n });\n\n if (!transferCache) return styleEl;\n\n const scriptEl = createElement('script', {\n key: 'tasty-ssr-cache',\n nonce,\n dangerouslySetInnerHTML: {\n __html:\n `(window.__TASTY_SSR_CACHE__=window.__TASTY_SSR_CACHE__||{entries:{},classCounter:0});` +\n `Object.assign(window.__TASTY_SSR_CACHE__.entries,${JSON.stringify(cacheState.entries)});` +\n `window.__TASTY_SSR_CACHE__.classCounter=${cacheState.classCounter};`,\n },\n });\n\n return createElement(Fragment, null, styleEl, scriptEl);\n });\n\n return createElement(\n TastySSRContext.Provider,\n { value: collector },\n children,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAI,OAAO,WAAW,eAAe,OAAO,oBAC1C,mBAAkB,OAAO,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;AAqC/C,SAAgB,cAAc,EAC5B,UACA,gBAAgB,QACK;CACrB,MAAM,WAAW,OAAO,WAAW;CAEnC,MAAM,CAAC,aAAa,eAClB,WAAW,OAAO,IAAI,sBAAsB,CAC7C;CACD,MAAM,QAAQ,WAAW,CAAC;AAE1B,6BAA4B;AAC1B,MAAI,CAAC,UAAW,QAAO;EAEvB,MAAM,MAAM,UAAU,UAAU;EAChC,MAAM,aAAa,UAAU,eAAe;AAE5C,MAAI,CAAC,IAAK,QAAO;EAEjB,MAAM,UAAU,cAAc,SAAS;GACrC,KAAK;GACL,kBAAkB;GAClB;GACA,yBAAyB,EAAE,QAAQ,KAAK;GACzC,CAAC;AAEF,MAAI,CAAC,cAAe,QAAO;AAa3B,SAAO,cAAc,UAAU,MAAM,SAXpB,cAAc,UAAU;GACvC,KAAK;GACL;GACA,yBAAyB,EACvB,QACE,yIACoD,KAAK,UAAU,WAAW,QAAQ,CAAC,4CAC5C,WAAW,aAAa,IACtE;GACF,CAAC,CAEqD;GACvD;AAEF,QAAO,cACL,gBAAgB,UAChB,EAAE,OAAO,WAAW,EACpB,SACD"}
1
+ {"version":3,"file":"next.js","names":[],"sources":["../../src/ssr/next.ts"],"sourcesContent":["/**\n * Next.js integration for Tasty SSR.\n *\n * Provides TastyRegistry for App Router (streaming via useServerInsertedHTML)\n * and createTastySSRDocument for Pages Router (non-streaming).\n *\n * Import from '@tenphi/tasty/ssr/next'.\n */\n\n'use client';\n\n/// <reference path=\"./next-navigation.d.ts\" />\n\nimport { createElement, Fragment, useState, type ReactNode } from 'react';\nimport { useServerInsertedHTML } from 'next/navigation';\n\nimport { getConfig } from '../config';\nimport { ServerStyleCollector } from './collector';\nimport { getTastySSRContext } from './context';\nimport { hydrateTastyClasses } from './hydrate';\nimport { registerSSRCollectorGetter } from './ssr-collector-ref';\n\n// Auto-hydrate on module load (client only).\n// Reads the class name list from `window.__TASTY__` populated by streaming scripts.\nif (typeof window !== 'undefined') {\n hydrateTastyClasses();\n}\n\nexport interface TastyRegistryProps {\n children: ReactNode;\n /**\n * Whether to embed the class-list script for client hydration.\n * Set to false to skip class transfer (e.g. for CSP restrictions).\n * Without it, client components may re-inject CSS that already exists\n * in server-rendered `<style>` tags. Default: true.\n */\n transferCache?: boolean;\n}\n\n/**\n * Next.js App Router registry for Tasty SSR.\n *\n * Wraps the component tree with a ServerStyleCollector and flushes\n * collected CSS into the HTML stream via useServerInsertedHTML.\n *\n * @example\n * ```tsx\n * // app/tasty-registry.tsx\n * 'use client';\n * import { TastyRegistry } from '@tenphi/tasty/ssr/next';\n * export default function TastyStyleRegistry({ children }) {\n * return <TastyRegistry>{children}</TastyRegistry>;\n * }\n *\n * // app/layout.tsx\n * import TastyStyleRegistry from './tasty-registry';\n * export default function RootLayout({ children }) {\n * return <html><body>\n * <TastyStyleRegistry>{children}</TastyStyleRegistry>\n * </body></html>;\n * }\n * ```\n */\nexport function TastyRegistry({\n children,\n transferCache = true,\n}: TastyRegistryProps) {\n const isClient = typeof window !== 'undefined';\n\n const [collector] = useState(() => {\n if (isClient) return null;\n\n const instance = new ServerStyleCollector();\n\n registerSSRCollectorGetter(() => instance);\n\n return instance;\n });\n const nonce = getConfig().nonce;\n\n useServerInsertedHTML(() => {\n if (!collector) return null;\n\n const css = collector.flushCSS();\n const classNames = collector.getRenderedClassNames();\n\n if (!css) return null;\n\n const styleEl = createElement('style', {\n key: 'tasty-ssr-styles',\n 'data-tasty-ssr': '',\n nonce,\n dangerouslySetInnerHTML: { __html: css },\n });\n\n if (!transferCache || classNames.length === 0) return styleEl;\n\n const classListJSON = classNames.map((n) => `\"${n}\"`).join(',');\n\n const scriptEl = createElement('script', {\n key: 'tasty-ssr-cache',\n nonce,\n dangerouslySetInnerHTML: {\n __html: `(window.__TASTY__=window.__TASTY__||[]).push(${classListJSON})`,\n },\n });\n\n return createElement(Fragment, null, styleEl, scriptEl);\n });\n\n return createElement(\n getTastySSRContext().Provider,\n { value: collector },\n children,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,IAAI,OAAO,WAAW,YACpB,sBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;AAsCvB,SAAgB,cAAc,EAC5B,UACA,gBAAgB,QACK;CACrB,MAAM,WAAW,OAAO,WAAW;CAEnC,MAAM,CAAC,aAAa,eAAe;AACjC,MAAI,SAAU,QAAO;EAErB,MAAM,WAAW,IAAI,sBAAsB;AAE3C,mCAAiC,SAAS;AAE1C,SAAO;GACP;CACF,MAAM,QAAQ,WAAW,CAAC;AAE1B,6BAA4B;AAC1B,MAAI,CAAC,UAAW,QAAO;EAEvB,MAAM,MAAM,UAAU,UAAU;EAChC,MAAM,aAAa,UAAU,uBAAuB;AAEpD,MAAI,CAAC,IAAK,QAAO;EAEjB,MAAM,UAAU,cAAc,SAAS;GACrC,KAAK;GACL,kBAAkB;GAClB;GACA,yBAAyB,EAAE,QAAQ,KAAK;GACzC,CAAC;AAEF,MAAI,CAAC,iBAAiB,WAAW,WAAW,EAAG,QAAO;AAYtD,SAAO,cAAc,UAAU,MAAM,SARpB,cAAc,UAAU;GACvC,KAAK;GACL;GACA,yBAAyB,EACvB,QAAQ,gDANU,WAAW,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,IAAI,CAMW,IACvE;GACF,CAAC,CAEqD;GACvD;AAEF,QAAO,cACL,oBAAoB,CAAC,UACrB,EAAE,OAAO,WAAW,EACpB,SACD"}
@@ -1,5 +1,91 @@
1
- import { Styles } from "../styles/types.js";
2
- import { mergeStyles } from "../utils/merge-styles.js";
3
- import { StaticStyle, createStaticStyle, isStaticStyle } from "./types.js";
4
- import { tastyStatic } from "./tastyStatic.js";
5
- export { type StaticStyle, type Styles, createStaticStyle, isStaticStyle, mergeStyles, tastyStatic };
1
+ import { b as Styles } from "../index-dUtwpOux.js";
2
+ import { t as mergeStyles } from "../merge-styles-CtDJMhpJ.js";
3
+
4
+ //#region src/static/types.d.ts
5
+ /**
6
+ * Static style definition returned by tastyStatic().
7
+ *
8
+ * Supports both explicit className access and implicit string coercion via toString().
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const button = tastyStatic({ fill: '#blue' });
13
+ *
14
+ * // Both work in JSX:
15
+ * <div className={button} /> // Uses toString()
16
+ * <div className={button.className} /> // Explicit
17
+ *
18
+ * // Extension:
19
+ * const primary = tastyStatic(button, { fill: '#purple' });
20
+ * ```
21
+ */
22
+ interface StaticStyle {
23
+ /**
24
+ * Generated className(s) for use in JSX.
25
+ * May contain multiple space-separated class names due to chunking.
26
+ */
27
+ className: string;
28
+ /**
29
+ * The original (or merged) styles object.
30
+ * Available for extension via tastyStatic(base, overrides).
31
+ */
32
+ styles: Styles;
33
+ /**
34
+ * Returns className for implicit string coercion.
35
+ * Enables `<div className={button} />` syntax.
36
+ */
37
+ toString(): string;
38
+ }
39
+ /**
40
+ * Create a StaticStyle object.
41
+ * Used internally by the Babel plugin to generate output.
42
+ */
43
+ declare function createStaticStyle(className: string, styles: Styles): StaticStyle;
44
+ /**
45
+ * Type guard to check if a value is a StaticStyle object.
46
+ */
47
+ declare function isStaticStyle(value: unknown): value is StaticStyle;
48
+ //#endregion
49
+ //#region src/static/tastyStatic.d.ts
50
+ /**
51
+ * Generate styles and return a StaticStyle object.
52
+ * The object has `className`, `styles`, and `toString()`.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const button = tastyStatic({
57
+ * fill: '#blue',
58
+ * padding: '2x',
59
+ * });
60
+ * // After build: { className: 'ts3f2a1b', styles: {...}, toString() }
61
+ *
62
+ * <div className={button} /> // Works via toString()
63
+ * ```
64
+ */
65
+ declare function tastyStatic(styles: Styles): StaticStyle;
66
+ /**
67
+ * Extend an existing StaticStyle with additional styles.
68
+ * Uses mergeStyles() internally for proper nested selector handling.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const button = tastyStatic({ fill: '#blue' });
73
+ * const primary = tastyStatic(button, { fill: '#purple' });
74
+ * // After build: { className: 'ts8c4d2e', styles: {...merged...}, toString() }
75
+ * ```
76
+ */
77
+ declare function tastyStatic(base: StaticStyle, styles: Styles): StaticStyle;
78
+ /**
79
+ * Generate styles for a specific CSS selector.
80
+ * The call is completely removed after build transformation.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * tastyStatic('.heading', { preset: 'h1', color: '#primary' });
85
+ * // After build: (removed)
86
+ * ```
87
+ */
88
+ declare function tastyStatic(selector: string, styles: Styles): void;
89
+ //#endregion
90
+ export { type StaticStyle, type Styles, createStaticStyle, isStaticStyle, mergeStyles, tastyStatic };
91
+ //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,50 @@
1
- import { mergeStyles } from "../utils/merge-styles.js";
2
- import { createStaticStyle, isStaticStyle } from "./types.js";
3
- import { tastyStatic } from "./tastyStatic.js";
1
+ import { t as mergeStyles } from "../merge-styles-BUQsEpbv.js";
2
+ //#region src/static/types.ts
3
+ /**
4
+ * Create a StaticStyle object.
5
+ * Used internally by the Babel plugin to generate output.
6
+ */
7
+ function createStaticStyle(className, styles) {
8
+ return {
9
+ className,
10
+ styles,
11
+ toString() {
12
+ return this.className;
13
+ }
14
+ };
15
+ }
16
+ /**
17
+ * Type guard to check if a value is a StaticStyle object.
18
+ */
19
+ function isStaticStyle(value) {
20
+ return typeof value === "object" && value !== null && "className" in value && "styles" in value && "toString" in value && typeof value.className === "string" && typeof value.styles === "object";
21
+ }
22
+ //#endregion
23
+ //#region src/static/tastyStatic.ts
24
+ /**
25
+ * Build-time only function for zero-runtime static site generation.
26
+ *
27
+ * This function is transformed by the Babel plugin:
28
+ * - `tastyStatic(styles)` → StaticStyle object with className
29
+ * - `tastyStatic(base, styles)` → StaticStyle object with merged styles
30
+ * - `tastyStatic(selector, styles)` → removed entirely
31
+ *
32
+ * At runtime (during development/build), this function returns a placeholder.
33
+ * In production, all calls are replaced/removed by the build plugin.
34
+ */
35
+ function tastyStatic(stylesOrBaseOrSelector, styles) {
36
+ if (typeof stylesOrBaseOrSelector === "string") {
37
+ console.warn(`[tasty] tastyStatic('${stylesOrBaseOrSelector}', styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.`);
38
+ return;
39
+ }
40
+ if (isStaticStyle(stylesOrBaseOrSelector)) {
41
+ console.warn("[tasty] tastyStatic(base, styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.");
42
+ return createStaticStyle("__TASTY_STATIC_NOT_TRANSFORMED__", mergeStyles(stylesOrBaseOrSelector.styles, styles || {}));
43
+ }
44
+ console.warn("[tasty] tastyStatic(styles) was called at runtime. This indicates the Babel plugin is not configured. Add @tenphi/tasty/babel-plugin to your Babel config.");
45
+ return createStaticStyle("__TASTY_STATIC_NOT_TRANSFORMED__", stylesOrBaseOrSelector);
46
+ }
47
+ //#endregion
4
48
  export { createStaticStyle, isStaticStyle, mergeStyles, tastyStatic };
49
+
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/static/types.ts","../../src/static/tastyStatic.ts"],"sourcesContent":["import type { Styles } from '../styles/types';\n\n/**\n * Static style definition returned by tastyStatic().\n *\n * Supports both explicit className access and implicit string coercion via toString().\n *\n * @example\n * ```typescript\n * const button = tastyStatic({ fill: '#blue' });\n *\n * // Both work in JSX:\n * <div className={button} /> // Uses toString()\n * <div className={button.className} /> // Explicit\n *\n * // Extension:\n * const primary = tastyStatic(button, { fill: '#purple' });\n * ```\n */\nexport interface StaticStyle {\n /**\n * Generated className(s) for use in JSX.\n * May contain multiple space-separated class names due to chunking.\n */\n className: string;\n\n /**\n * The original (or merged) styles object.\n * Available for extension via tastyStatic(base, overrides).\n */\n styles: Styles;\n\n /**\n * Returns className for implicit string coercion.\n * Enables `<div className={button} />` syntax.\n */\n toString(): string;\n}\n\n/**\n * Create a StaticStyle object.\n * Used internally by the Babel plugin to generate output.\n */\nexport function createStaticStyle(\n className: string,\n styles: Styles,\n): StaticStyle {\n return {\n className,\n styles,\n toString() {\n return this.className;\n },\n };\n}\n\n/**\n * Type guard to check if a value is a StaticStyle object.\n */\nexport function isStaticStyle(value: unknown): value is StaticStyle {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'className' in value &&\n 'styles' in value &&\n 'toString' in value &&\n typeof (value as StaticStyle).className === 'string' &&\n typeof (value as StaticStyle).styles === 'object'\n );\n}\n","import type { Styles } from '../styles/types';\nimport { mergeStyles } from '../utils/merge-styles';\n\nimport type { StaticStyle } from './types';\nimport { createStaticStyle, isStaticStyle } from './types';\n\n/**\n * Generate styles and return a StaticStyle object.\n * The object has `className`, `styles`, and `toString()`.\n *\n * @example\n * ```typescript\n * const button = tastyStatic({\n * fill: '#blue',\n * padding: '2x',\n * });\n * // After build: { className: 'ts3f2a1b', styles: {...}, toString() }\n *\n * <div className={button} /> // Works via toString()\n * ```\n */\nexport function tastyStatic(styles: Styles): StaticStyle;\n\n/**\n * Extend an existing StaticStyle with additional styles.\n * Uses mergeStyles() internally for proper nested selector handling.\n *\n * @example\n * ```typescript\n * const button = tastyStatic({ fill: '#blue' });\n * const primary = tastyStatic(button, { fill: '#purple' });\n * // After build: { className: 'ts8c4d2e', styles: {...merged...}, toString() }\n * ```\n */\nexport function tastyStatic(base: StaticStyle, styles: Styles): StaticStyle;\n\n/**\n * Generate styles for a specific CSS selector.\n * The call is completely removed after build transformation.\n *\n * @example\n * ```typescript\n * tastyStatic('.heading', { preset: 'h1', color: '#primary' });\n * // After build: (removed)\n * ```\n */\nexport function tastyStatic(selector: string, styles: Styles): void;\n\n/**\n * Build-time only function for zero-runtime static site generation.\n *\n * This function is transformed by the Babel plugin:\n * - `tastyStatic(styles)` → StaticStyle object with className\n * - `tastyStatic(base, styles)` → StaticStyle object with merged styles\n * - `tastyStatic(selector, styles)` → removed entirely\n *\n * At runtime (during development/build), this function returns a placeholder.\n * In production, all calls are replaced/removed by the build plugin.\n */\nexport function tastyStatic(\n stylesOrBaseOrSelector: Styles | StaticStyle | string,\n styles?: Styles,\n): StaticStyle | void {\n // This code only executes if the Babel plugin hasn't processed the file yet.\n // In a properly configured build, this function is never called at runtime.\n\n if (typeof stylesOrBaseOrSelector === 'string') {\n // Selector mode: tastyStatic(selector, styles)\n // The plugin will remove this call entirely\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[tasty] tastyStatic('${stylesOrBaseOrSelector}', styles) was called at runtime. ` +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n return; // void\n }\n\n if (isStaticStyle(stylesOrBaseOrSelector)) {\n // Extension mode: tastyStatic(base, styles)\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[tasty] tastyStatic(base, styles) was called at runtime. ' +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n // Merge styles for dev mode preview (won't have real classNames)\n const mergedStyles = mergeStyles(\n stylesOrBaseOrSelector.styles,\n styles || {},\n );\n return createStaticStyle('__TASTY_STATIC_NOT_TRANSFORMED__', mergedStyles);\n }\n\n // Styles mode: tastyStatic(styles)\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n '[tasty] tastyStatic(styles) was called at runtime. ' +\n 'This indicates the Babel plugin is not configured. ' +\n 'Add @tenphi/tasty/babel-plugin to your Babel config.',\n );\n }\n\n // Return placeholder - styles won't be applied without the plugin\n return createStaticStyle(\n '__TASTY_STATIC_NOT_TRANSFORMED__',\n stylesOrBaseOrSelector,\n );\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,kBACd,WACA,QACa;AACb,QAAO;EACL;EACA;EACA,WAAW;AACT,UAAO,KAAK;;EAEf;;;;;AAMH,SAAgB,cAAc,OAAsC;AAClE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,YAAY,SACZ,cAAc,SACd,OAAQ,MAAsB,cAAc,YAC5C,OAAQ,MAAsB,WAAW;;;;;;;;;;;;;;;ACR7C,SAAgB,YACd,wBACA,QACoB;AAIpB,KAAI,OAAO,2BAA2B,UAAU;AAI5C,UAAQ,KACN,wBAAwB,uBAAuB,2IAGhD;AAEH;;AAGF,KAAI,cAAc,uBAAuB,EAAE;AAGvC,UAAQ,KACN,mKAGD;AAOH,SAAO,kBAAkB,oCAJJ,YACnB,uBAAuB,QACvB,UAAU,EAAE,CACb,CACyE;;AAK1E,SAAQ,KACN,6JAGD;AAIH,QAAO,kBACL,oCACA,uBACD"}
@@ -1,122 +1,21 @@
1
- import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps } from "../injector/types.js";
2
- import { StyleDetails, UnitHandler } from "../parser/types.js";
3
- import { StyleHandlerDefinition } from "../utils/styles.js";
4
- import { ConfigTokens, RecipeStyles } from "../styles/types.js";
5
- import { TastyPlugin } from "../plugins/types.js";
1
+ import { t as TastyConfig } from "../config-vuCRkBWX.js";
6
2
  import * as _$_babel_core0 from "@babel/core";
7
3
  import { PluginPass } from "@babel/core";
8
4
 
9
5
  //#region src/zero/babel.d.ts
10
6
  /**
11
7
  * Build-time configuration for zero-runtime mode.
12
- * Subset of TastyConfig that applies at build time.
8
+ * Subset of TastyConfig excluding runtime-only DOM options
9
+ * (`nonce`, `maxRulesPerSheet`, `forceTextInjection`, `gc`)
10
+ * and overriding `devMode` default to `false`.
13
11
  */
14
- interface TastyZeroConfig {
15
- /**
16
- * Global predefined states for advanced state mapping.
17
- * Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }
18
- */
19
- states?: Record<string, string>;
12
+ type TastyZeroConfig = Omit<TastyConfig, 'nonce' | 'maxRulesPerSheet' | 'forceTextInjection' | 'gc' | 'devMode'> & {
20
13
  /**
21
14
  * Enable development mode features: source comments in generated CSS.
22
- * Default: false
15
+ * @default false
23
16
  */
24
17
  devMode?: boolean;
25
- /**
26
- * Parser LRU cache size (default: 1000).
27
- * Larger values improve performance for builds with many unique style values.
28
- */
29
- parserCacheSize?: number;
30
- /**
31
- * Custom units for the style parser (merged with built-in units).
32
- * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
33
- * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
34
- */
35
- units?: Record<string, string | UnitHandler>;
36
- /**
37
- * Custom functions for the style parser (merged with existing).
38
- * Functions process parsed style groups and return CSS values.
39
- * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
40
- */
41
- funcs?: Record<string, (groups: StyleDetails[]) => string>;
42
- /**
43
- * Plugins that extend tasty with custom functions, units, states, and handlers.
44
- * Plugins are processed in order, with later plugins overriding earlier ones.
45
- * @example
46
- * ```ts
47
- * import { okhslPlugin } from '@tenphi/tasty';
48
- *
49
- * // babel.config.js
50
- * module.exports = {
51
- * plugins: [
52
- * ['@tenphi/tasty/babel-plugin', {
53
- * config: { plugins: [okhslPlugin()] }
54
- * }]
55
- * ]
56
- * };
57
- * ```
58
- */
59
- plugins?: TastyPlugin[];
60
- /**
61
- * Global keyframes definitions for static extraction.
62
- * Keys are animation names, values are keyframes step definitions.
63
- * @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }
64
- */
65
- keyframes?: Record<string, KeyframesSteps>;
66
- /**
67
- * Global @font-face definitions for static extraction.
68
- * Keys are font-family names, values are descriptors or arrays of descriptors.
69
- */
70
- fontFace?: Record<string, FontFaceInput>;
71
- /**
72
- * Global @counter-style definitions for static extraction.
73
- * Keys are counter-style names, values are descriptor objects.
74
- */
75
- counterStyle?: Record<string, CounterStyleDescriptors>;
76
- /**
77
- * Custom style handlers that transform style properties into CSS declarations.
78
- * Handlers replace built-in handlers for the same style name.
79
- * @example
80
- * ```ts
81
- * handlers: {
82
- * fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
83
- * elevation: ({ elevation }) => ({
84
- * 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,
85
- * }),
86
- * }
87
- * ```
88
- */
89
- handlers?: Record<string, StyleHandlerDefinition>;
90
- /**
91
- * Design tokens injected as CSS custom properties on `:root`.
92
- * Values are parsed through the Tasty DSL. Supports state maps.
93
- * @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
94
- */
95
- tokens?: ConfigTokens;
96
- /**
97
- * Predefined tokens replaced during style parsing (parse-time substitution).
98
- * Use `$name` for custom properties and `#name` for color tokens.
99
- * @example { $spacing: '2x', '#accent': '#purple' }
100
- */
101
- replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
102
- /**
103
- * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
104
- * Recipe values are flat tasty styles (no sub-element keys).
105
- * @example
106
- * ```ts
107
- * recipes: {
108
- * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
109
- * elevated: { shadow: '2x 2x 4x #shadow' },
110
- * }
111
- * ```
112
- */
113
- recipes?: Record<string, RecipeStyles>;
114
- /**
115
- * Automatically infer and register CSS @property declarations from values.
116
- * @default true
117
- */
118
- autoPropertyTypes?: boolean;
119
- }
18
+ };
120
19
  interface TastyZeroBabelOptions {
121
20
  /** Output path for generated CSS (default: 'tasty.css') */
122
21
  output?: string;
@@ -1,14 +1,18 @@
1
- import { __require } from "../_virtual/_rolldown/runtime.js";
2
- import { configure, getGlobalConfigTokens, resetConfig } from "../config.js";
3
- import { mergeStyles } from "../utils/merge-styles.js";
4
- import { resolveRecipes } from "../utils/resolve-recipes.js";
5
- import { extractCounterStyleFromStyles, extractFontFaceFromStyles, extractKeyframesFromStyles, extractPropertiesFromStyles, extractStylesForSelector, extractStylesWithChunks } from "./extractor.js";
6
- import { CSSWriter } from "./css-writer.js";
1
+ import { _ as resetConfig, i as getGlobalConfigTokens, t as configure, u as getGlobalStyles } from "../config-_aQ_PZ-P.js";
2
+ import { t as mergeStyles } from "../merge-styles-BUQsEpbv.js";
3
+ import { t as resolveRecipes } from "../resolve-recipes-C0-AMzCz.js";
4
+ import { a as extractPropertiesFromStyles, i as extractKeyframesFromStyles, n as extractCounterStyleFromStyles, o as extractStylesForSelector, r as extractFontFaceFromStyles, s as extractStylesWithChunks, t as CSSWriter } from "../css-writer-D--REwtp.js";
7
5
  import * as fs from "fs";
8
6
  import * as path from "path";
9
7
  import { declare } from "@babel/helper-plugin-utils";
10
8
  import * as t from "@babel/types";
11
9
  import { createJiti } from "jiti";
10
+ //#region \0rolldown/runtime.js
11
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
14
+ });
15
+ //#endregion
12
16
  //#region src/zero/babel.ts
13
17
  /**
14
18
  * Babel plugin for zero-runtime tasty static site generation.
@@ -87,10 +91,12 @@ var babel_default = declare((api, options) => {
87
91
  configure(resolvedConfig);
88
92
  const newWriter = new CSSWriter(outputPath, { devMode });
89
93
  if (mode !== "inject") {
90
- const tokenStyles = getGlobalConfigTokens();
91
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
92
- const result = extractStylesForSelector(":root", tokenStyles);
93
- if (result.css) newWriter.add(":root:tokens", result.css);
94
+ const tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
95
+ if (tokenCSS) newWriter.add(":root:tokens", tokenCSS);
96
+ const globalStyles = getGlobalStyles();
97
+ if (globalStyles) for (const [selector, styles] of Object.entries(globalStyles)) {
98
+ const css = extractCSSFromStyles(selector, styles);
99
+ if (css) newWriter.add(`global:${selector}`, css);
94
100
  }
95
101
  }
96
102
  writerCache.set(resolvedOutputPath, {
@@ -106,11 +112,17 @@ var babel_default = declare((api, options) => {
106
112
  const config = entry.config;
107
113
  const devMode = config.devMode ?? false;
108
114
  let tokenCSS;
115
+ let globalStylesCSS;
109
116
  if (mode === "inject") {
110
- const tokenStyles = getGlobalConfigTokens();
111
- if (tokenStyles && Object.keys(tokenStyles).length > 0) {
112
- const result = extractStylesForSelector(":root", tokenStyles);
113
- if (result.css) tokenCSS = result.css;
117
+ tokenCSS = extractCSSFromStyles(":root", getGlobalConfigTokens());
118
+ const gs = getGlobalStyles();
119
+ if (gs) {
120
+ globalStylesCSS = /* @__PURE__ */ new Map();
121
+ for (const [selector, styles] of Object.entries(gs)) {
122
+ const css = extractCSSFromStyles(selector, styles);
123
+ if (css) globalStylesCSS.set(selector, css);
124
+ }
125
+ if (globalStylesCSS.size === 0) globalStylesCSS = void 0;
114
126
  }
115
127
  }
116
128
  return {
@@ -168,12 +180,20 @@ var babel_default = declare((api, options) => {
168
180
  },
169
181
  post() {
170
182
  if (mode === "inject") {
171
- if (this._fileAddedCSS && tokenCSS) {
183
+ if (this._fileAddedCSS && (tokenCSS || globalStylesCSS)) {
172
184
  const program = this.file.ast.program;
173
- const injectCall = createInjectCallAST(":root", tokenCSS);
174
185
  let insertIndex = 0;
175
186
  for (let i = 0; i < program.body.length; i++) if (t.isImportDeclaration(program.body[i])) insertIndex = i + 1;
176
- program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
187
+ if (tokenCSS) {
188
+ const injectCall = createInjectCallAST(":root", tokenCSS);
189
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
190
+ insertIndex++;
191
+ }
192
+ if (globalStylesCSS) for (const [selector, css] of globalStylesCSS) {
193
+ const injectCall = createInjectCallAST(selector, css);
194
+ program.body.splice(insertIndex, 0, t.expressionStatement(injectCall));
195
+ insertIndex++;
196
+ }
177
197
  }
178
198
  return;
179
199
  }
@@ -318,6 +338,14 @@ function writeCSSToWriter(cssWriter, keyframes, properties, fontFaces, counterSt
318
338
  }
319
339
  }
320
340
  /**
341
+ * Extract CSS for a selector from a styles/tokens object.
342
+ * Returns undefined when there are no styles or no CSS output.
343
+ */
344
+ function extractCSSFromStyles(selector, styles) {
345
+ if (!styles || Object.keys(styles).length === 0) return void 0;
346
+ return extractStylesForSelector(selector, styles).css || void 0;
347
+ }
348
+ /**
321
349
  * Create an `_$i(id, css)` call expression AST node for inject mode.
322
350
  */
323
351
  function createInjectCallAST(id, css) {