@tenphi/tasty 0.0.0-snapshot.b3fbcbb → 0.0.0-snapshot.b478bc9

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 (319) hide show
  1. package/README.md +297 -208
  2. package/dist/_virtual/_rolldown/runtime.js +1 -2
  3. package/dist/chunks/cacheKey.d.ts +1 -0
  4. package/dist/chunks/cacheKey.js +17 -10
  5. package/dist/chunks/cacheKey.js.map +1 -1
  6. package/dist/chunks/definitions.d.ts +1 -1
  7. package/dist/chunks/definitions.js +3 -5
  8. package/dist/chunks/definitions.js.map +1 -1
  9. package/dist/chunks/index.d.ts +1 -0
  10. package/dist/chunks/renderChunk.d.ts +1 -0
  11. package/dist/chunks/renderChunk.js +32 -34
  12. package/dist/chunks/renderChunk.js.map +1 -1
  13. package/dist/compute-styles.d.ts +31 -0
  14. package/dist/compute-styles.js +322 -0
  15. package/dist/compute-styles.js.map +1 -0
  16. package/dist/config.d.ts +149 -30
  17. package/dist/config.js +233 -45
  18. package/dist/config.js.map +1 -1
  19. package/dist/core/index.d.ts +12 -11
  20. package/dist/core/index.js +12 -11
  21. package/dist/counter-style/index.js +51 -0
  22. package/dist/counter-style/index.js.map +1 -0
  23. package/dist/debug.d.ts +26 -141
  24. package/dist/debug.js +359 -639
  25. package/dist/debug.js.map +1 -1
  26. package/dist/font-face/index.js +63 -0
  27. package/dist/font-face/index.js.map +1 -0
  28. package/dist/hooks/index.d.ts +7 -0
  29. package/dist/hooks/useCounterStyle.d.ts +36 -0
  30. package/dist/hooks/useCounterStyle.js +65 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +45 -0
  33. package/dist/hooks/useFontFace.js +66 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +21 -2
  36. package/dist/hooks/useGlobalStyles.js +60 -28
  37. package/dist/hooks/useGlobalStyles.js.map +1 -1
  38. package/dist/hooks/useKeyframes.d.ts +4 -2
  39. package/dist/hooks/useKeyframes.js +44 -43
  40. package/dist/hooks/useKeyframes.js.map +1 -1
  41. package/dist/hooks/useProperty.d.ts +4 -2
  42. package/dist/hooks/useProperty.js +36 -31
  43. package/dist/hooks/useProperty.js.map +1 -1
  44. package/dist/hooks/useRawCSS.d.ts +13 -44
  45. package/dist/hooks/useRawCSS.js +91 -16
  46. package/dist/hooks/useRawCSS.js.map +1 -1
  47. package/dist/hooks/useStyles.d.ts +3 -3
  48. package/dist/hooks/useStyles.js +8 -146
  49. package/dist/hooks/useStyles.js.map +1 -1
  50. package/dist/index.d.ts +15 -12
  51. package/dist/index.js +15 -12
  52. package/dist/injector/index.d.ts +36 -11
  53. package/dist/injector/index.js +43 -12
  54. package/dist/injector/index.js.map +1 -1
  55. package/dist/injector/injector.d.ts +62 -3
  56. package/dist/injector/injector.js +256 -31
  57. package/dist/injector/injector.js.map +1 -1
  58. package/dist/injector/sheet-manager.d.ts +10 -13
  59. package/dist/injector/sheet-manager.js +42 -71
  60. package/dist/injector/sheet-manager.js.map +1 -1
  61. package/dist/injector/types.d.ts +112 -21
  62. package/dist/keyframes/index.js +1 -1
  63. package/dist/parser/classify.js +6 -6
  64. package/dist/parser/classify.js.map +1 -1
  65. package/dist/parser/const.js +30 -3
  66. package/dist/parser/const.js.map +1 -1
  67. package/dist/parser/lru.js +1 -1
  68. package/dist/parser/lru.js.map +1 -1
  69. package/dist/parser/parser.js +2 -3
  70. package/dist/parser/parser.js.map +1 -1
  71. package/dist/parser/tokenizer.js +1 -1
  72. package/dist/parser/tokenizer.js.map +1 -1
  73. package/dist/parser/types.js +1 -1
  74. package/dist/parser/types.js.map +1 -1
  75. package/dist/pipeline/conditions.js +1 -1
  76. package/dist/pipeline/conditions.js.map +1 -1
  77. package/dist/pipeline/exclusive.js +163 -5
  78. package/dist/pipeline/exclusive.js.map +1 -1
  79. package/dist/pipeline/index.d.ts +3 -1
  80. package/dist/pipeline/index.js +172 -83
  81. package/dist/pipeline/index.js.map +1 -1
  82. package/dist/pipeline/materialize-contradictions.js +125 -0
  83. package/dist/pipeline/materialize-contradictions.js.map +1 -0
  84. package/dist/pipeline/materialize.js +437 -243
  85. package/dist/pipeline/materialize.js.map +1 -1
  86. package/dist/pipeline/parseStateKey.d.ts +1 -1
  87. package/dist/pipeline/parseStateKey.js +21 -13
  88. package/dist/pipeline/parseStateKey.js.map +1 -1
  89. package/dist/pipeline/simplify.js +181 -7
  90. package/dist/pipeline/simplify.js.map +1 -1
  91. package/dist/pipeline/warnings.js +1 -1
  92. package/dist/plugins/index.d.ts +2 -0
  93. package/dist/plugins/okhsl-plugin.js +3 -277
  94. package/dist/plugins/okhsl-plugin.js.map +1 -1
  95. package/dist/plugins/types.d.ts +20 -2
  96. package/dist/properties/index.js +15 -30
  97. package/dist/properties/index.js.map +1 -1
  98. package/dist/properties/property-type-resolver.js +13 -2
  99. package/dist/properties/property-type-resolver.js.map +1 -1
  100. package/dist/rsc-cache.js +79 -0
  101. package/dist/rsc-cache.js.map +1 -0
  102. package/dist/ssr/astro-client.d.ts +1 -0
  103. package/dist/ssr/astro-client.js +19 -0
  104. package/dist/ssr/astro-client.js.map +1 -0
  105. package/dist/ssr/astro-middleware.d.ts +15 -0
  106. package/dist/ssr/astro-middleware.js +19 -0
  107. package/dist/ssr/astro-middleware.js.map +1 -0
  108. package/dist/ssr/astro.d.ts +108 -0
  109. package/dist/ssr/astro.js +149 -0
  110. package/dist/ssr/astro.js.map +1 -0
  111. package/dist/ssr/async-storage.d.ts +17 -0
  112. package/dist/ssr/async-storage.js +44 -0
  113. package/dist/ssr/async-storage.js.map +1 -0
  114. package/dist/ssr/collect-auto-properties.js +58 -0
  115. package/dist/ssr/collect-auto-properties.js.map +1 -0
  116. package/dist/ssr/collector.d.ts +98 -0
  117. package/dist/ssr/collector.js +235 -0
  118. package/dist/ssr/collector.js.map +1 -0
  119. package/dist/ssr/context.js +16 -0
  120. package/dist/ssr/context.js.map +1 -0
  121. package/dist/ssr/format-global-rules.js +22 -0
  122. package/dist/ssr/format-global-rules.js.map +1 -0
  123. package/dist/ssr/format-keyframes.js +69 -0
  124. package/dist/ssr/format-keyframes.js.map +1 -0
  125. package/dist/ssr/format-property.js +49 -0
  126. package/dist/ssr/format-property.js.map +1 -0
  127. package/dist/ssr/format-rules.js +73 -0
  128. package/dist/ssr/format-rules.js.map +1 -0
  129. package/dist/ssr/hydrate.d.ts +29 -0
  130. package/dist/ssr/hydrate.js +45 -0
  131. package/dist/ssr/hydrate.js.map +1 -0
  132. package/dist/ssr/index.d.ts +4 -0
  133. package/dist/ssr/index.js +10 -0
  134. package/dist/ssr/index.js.map +1 -0
  135. package/dist/ssr/next.d.ts +46 -0
  136. package/dist/ssr/next.js +75 -0
  137. package/dist/ssr/next.js.map +1 -0
  138. package/dist/ssr/ssr-collector-ref.js +29 -0
  139. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  140. package/dist/states/index.js +13 -259
  141. package/dist/states/index.js.map +1 -1
  142. package/dist/static/index.js +1 -2
  143. package/dist/static/inject.d.ts +5 -0
  144. package/dist/static/inject.js +17 -0
  145. package/dist/static/inject.js.map +1 -0
  146. package/dist/static/tastyStatic.js +1 -2
  147. package/dist/static/tastyStatic.js.map +1 -1
  148. package/dist/static/types.js +1 -1
  149. package/dist/styles/border.d.ts +1 -1
  150. package/dist/styles/border.js +30 -24
  151. package/dist/styles/border.js.map +1 -1
  152. package/dist/styles/color.d.ts +1 -1
  153. package/dist/styles/color.js +11 -8
  154. package/dist/styles/color.js.map +1 -1
  155. package/dist/styles/const.js +17 -0
  156. package/dist/styles/const.js.map +1 -0
  157. package/dist/styles/createStyle.js +28 -26
  158. package/dist/styles/createStyle.js.map +1 -1
  159. package/dist/styles/dimension.js +15 -3
  160. package/dist/styles/dimension.js.map +1 -1
  161. package/dist/styles/directional.js +133 -0
  162. package/dist/styles/directional.js.map +1 -0
  163. package/dist/styles/display.d.ts +3 -10
  164. package/dist/styles/display.js +45 -39
  165. package/dist/styles/display.js.map +1 -1
  166. package/dist/styles/fade.d.ts +1 -1
  167. package/dist/styles/fade.js +9 -5
  168. package/dist/styles/fade.js.map +1 -1
  169. package/dist/styles/fill.d.ts +2 -2
  170. package/dist/styles/fill.js +3 -4
  171. package/dist/styles/fill.js.map +1 -1
  172. package/dist/styles/flow.js +1 -1
  173. package/dist/styles/gap.d.ts +1 -1
  174. package/dist/styles/gap.js +4 -3
  175. package/dist/styles/gap.js.map +1 -1
  176. package/dist/styles/height.d.ts +1 -1
  177. package/dist/styles/height.js +1 -2
  178. package/dist/styles/height.js.map +1 -1
  179. package/dist/styles/index.d.ts +0 -1
  180. package/dist/styles/index.js +3 -4
  181. package/dist/styles/index.js.map +1 -1
  182. package/dist/styles/inset.d.ts +1 -29
  183. package/dist/styles/inset.js +19 -135
  184. package/dist/styles/inset.js.map +1 -1
  185. package/dist/styles/list.d.ts +5 -5
  186. package/dist/styles/list.js +4 -2
  187. package/dist/styles/list.js.map +1 -1
  188. package/dist/styles/margin.d.ts +1 -1
  189. package/dist/styles/margin.js +17 -89
  190. package/dist/styles/margin.js.map +1 -1
  191. package/dist/styles/outline.d.ts +1 -1
  192. package/dist/styles/outline.js +6 -16
  193. package/dist/styles/outline.js.map +1 -1
  194. package/dist/styles/padding.d.ts +1 -1
  195. package/dist/styles/padding.js +17 -89
  196. package/dist/styles/padding.js.map +1 -1
  197. package/dist/styles/placement.d.ts +37 -0
  198. package/dist/styles/placement.js +74 -0
  199. package/dist/styles/placement.js.map +1 -0
  200. package/dist/styles/predefined.d.ts +4 -6
  201. package/dist/styles/predefined.js +9 -13
  202. package/dist/styles/predefined.js.map +1 -1
  203. package/dist/styles/preset.d.ts +6 -1
  204. package/dist/styles/preset.js +54 -53
  205. package/dist/styles/preset.js.map +1 -1
  206. package/dist/styles/radius.d.ts +1 -3
  207. package/dist/styles/radius.js +38 -6
  208. package/dist/styles/radius.js.map +1 -1
  209. package/dist/styles/scrollMargin.d.ts +24 -0
  210. package/dist/styles/scrollMargin.js +32 -0
  211. package/dist/styles/scrollMargin.js.map +1 -0
  212. package/dist/styles/scrollbar.d.ts +9 -5
  213. package/dist/styles/scrollbar.js +31 -92
  214. package/dist/styles/scrollbar.js.map +1 -1
  215. package/dist/styles/shadow.d.ts +1 -1
  216. package/dist/styles/shadow.js +4 -3
  217. package/dist/styles/shadow.js.map +1 -1
  218. package/dist/styles/shared.js +17 -0
  219. package/dist/styles/shared.js.map +1 -0
  220. package/dist/styles/transition.d.ts +1 -1
  221. package/dist/styles/transition.js +6 -5
  222. package/dist/styles/transition.js.map +1 -1
  223. package/dist/styles/types.d.ts +94 -28
  224. package/dist/styles/width.d.ts +1 -1
  225. package/dist/styles/width.js +1 -2
  226. package/dist/styles/width.js.map +1 -1
  227. package/dist/tasty.d.ts +46 -894
  228. package/dist/tasty.js +101 -59
  229. package/dist/tasty.js.map +1 -1
  230. package/dist/types.d.ts +1 -1
  231. package/dist/utils/cache-wrapper.js +4 -9
  232. package/dist/utils/cache-wrapper.js.map +1 -1
  233. package/dist/utils/case-converter.js +1 -1
  234. package/dist/utils/color-math.d.ts +46 -0
  235. package/dist/utils/color-math.js +749 -0
  236. package/dist/utils/color-math.js.map +1 -0
  237. package/dist/utils/color-space.d.ts +5 -0
  238. package/dist/utils/color-space.js +228 -0
  239. package/dist/utils/color-space.js.map +1 -0
  240. package/dist/utils/colors.js +3 -2
  241. package/dist/utils/colors.js.map +1 -1
  242. package/dist/utils/deps-equal.js +15 -0
  243. package/dist/utils/deps-equal.js.map +1 -0
  244. package/dist/utils/dotize.js +1 -1
  245. package/dist/utils/dotize.js.map +1 -1
  246. package/dist/utils/filter-base-props.d.ts +1 -1
  247. package/dist/utils/filter-base-props.js +1 -1
  248. package/dist/utils/filter-base-props.js.map +1 -1
  249. package/dist/utils/get-display-name.js +1 -1
  250. package/dist/utils/has-keys.js +13 -0
  251. package/dist/utils/has-keys.js.map +1 -0
  252. package/dist/utils/hash.js +14 -0
  253. package/dist/utils/hash.js.map +1 -0
  254. package/dist/utils/is-dev-env.js +1 -1
  255. package/dist/utils/is-dev-env.js.map +1 -1
  256. package/dist/utils/is-valid-element-type.js +1 -1
  257. package/dist/utils/merge-styles.js +1 -2
  258. package/dist/utils/merge-styles.js.map +1 -1
  259. package/dist/utils/mod-attrs.d.ts +0 -2
  260. package/dist/utils/mod-attrs.js +3 -4
  261. package/dist/utils/mod-attrs.js.map +1 -1
  262. package/dist/utils/process-tokens.d.ts +3 -17
  263. package/dist/utils/process-tokens.js +19 -107
  264. package/dist/utils/process-tokens.js.map +1 -1
  265. package/dist/utils/resolve-recipes.js +1 -2
  266. package/dist/utils/resolve-recipes.js.map +1 -1
  267. package/dist/utils/selector-transform.js +32 -0
  268. package/dist/utils/selector-transform.js.map +1 -0
  269. package/dist/utils/string.js +1 -1
  270. package/dist/utils/styles.d.ts +3 -82
  271. package/dist/utils/styles.js +29 -560
  272. package/dist/utils/styles.js.map +1 -1
  273. package/dist/utils/typography.d.ts +35 -13
  274. package/dist/utils/typography.js +16 -18
  275. package/dist/utils/typography.js.map +1 -1
  276. package/dist/utils/warnings.js +1 -1
  277. package/dist/zero/babel.d.ts +57 -89
  278. package/dist/zero/babel.js +214 -40
  279. package/dist/zero/babel.js.map +1 -1
  280. package/dist/zero/css-writer.js +1 -2
  281. package/dist/zero/css-writer.js.map +1 -1
  282. package/dist/zero/extractor.js +54 -3
  283. package/dist/zero/extractor.js.map +1 -1
  284. package/dist/zero/index.js +1 -2
  285. package/dist/zero/next.d.ts +56 -30
  286. package/dist/zero/next.js +105 -40
  287. package/dist/zero/next.js.map +1 -1
  288. package/docs/README.md +31 -0
  289. package/docs/adoption.md +298 -0
  290. package/docs/comparison.md +419 -0
  291. package/docs/configuration.md +394 -0
  292. package/docs/debug.md +320 -0
  293. package/docs/design-system.md +436 -0
  294. package/docs/dsl.md +688 -0
  295. package/docs/getting-started.md +217 -0
  296. package/docs/injector.md +544 -0
  297. package/docs/methodology.md +616 -0
  298. package/docs/pipeline.md +673 -0
  299. package/docs/react-api.md +557 -0
  300. package/docs/ssr.md +442 -0
  301. package/docs/styles.md +596 -0
  302. package/docs/tasty-static.md +532 -0
  303. package/package.json +68 -36
  304. package/dist/styles/align.d.ts +0 -15
  305. package/dist/styles/align.js +0 -14
  306. package/dist/styles/align.js.map +0 -1
  307. package/dist/styles/justify.d.ts +0 -15
  308. package/dist/styles/justify.js +0 -14
  309. package/dist/styles/justify.js.map +0 -1
  310. package/dist/styles/styledScrollbar.d.ts +0 -47
  311. package/dist/styles/styledScrollbar.js +0 -38
  312. package/dist/styles/styledScrollbar.js.map +0 -1
  313. package/dist/tokens/typography.d.ts +0 -19
  314. package/dist/tokens/typography.js +0 -237
  315. package/dist/tokens/typography.js.map +0 -1
  316. package/dist/utils/hsl-to-rgb.js +0 -38
  317. package/dist/utils/hsl-to-rgb.js.map +0 -1
  318. package/dist/utils/okhsl-to-rgb.js +0 -296
  319. package/dist/utils/okhsl-to-rgb.js.map +0 -1
@@ -0,0 +1,29 @@
1
+ //#region src/ssr/hydrate.d.ts
2
+ /**
3
+ * Client-side cache hydration for SSR/RSC.
4
+ *
5
+ * Pre-populates the client injector's rules map with class names
6
+ * rendered on the server. With hash-based naming, the client derives
7
+ * the same class name from the same cache key, so only the class name
8
+ * list needs to cross the wire — no cache keys or counters.
9
+ */
10
+ /**
11
+ * Pre-populate the client-side style registry from the server's class name list.
12
+ *
13
+ * Call this before ReactDOM.hydrateRoot() or ensure it runs before
14
+ * any tasty() component renders on the client.
15
+ *
16
+ * When called without arguments, reads the class list from `window.__TASTY__`
17
+ * (populated by inline scripts emitted during SSR/RSC streaming).
18
+ */
19
+ declare function hydrateTastyClasses(classes?: string[]): void;
20
+ /**
21
+ * @deprecated Use `hydrateTastyClasses()` instead. This alias exists
22
+ * for backwards compatibility and will be removed in a future major version.
23
+ */
24
+ declare function hydrateTastyCache(state?: {
25
+ entries?: Record<string, string>;
26
+ }): void;
27
+ //#endregion
28
+ export { hydrateTastyCache, hydrateTastyClasses };
29
+ //# sourceMappingURL=hydrate.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { getGlobalInjector } from "../config.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 { hydrateTastyCache, hydrateTastyClasses };
44
+
45
+ //# sourceMappingURL=hydrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate.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;AAC5D,KAAI,OAAO,aAAa,YAAa;AAErC,KAAI,CAAC,QACH,WAAU,OAAO,WAAW,cAAc,OAAO,YAAY,KAAA;AAG/D,KAAI,CAAC,SAAS,OAAQ;CAGtB,MAAM,WADW,mBAAmB,CACV,cAAc,YAAY,SAAS;AAE7D,MAAK,MAAM,OAAO,QAChB,KAAI,CAAC,SAAS,MAAM,IAAI,IAAI,EAAE;AAC5B,WAAS,MAAM,IAAI,KAAK;GACtB,WAAW;GACX,WAAA;GACA,YAAA;GACD,CAAC;AACF,WAAS,UAAU,IAAI,KAAK,EAAE;;;;;;;AASpC,SAAgB,kBAAkB,OAEzB;AACP,KAAI,OAAO,QACT,qBAAoB,OAAO,OAAO,MAAM,QAAQ,CAAC;KAEjD,sBAAqB"}
@@ -0,0 +1,4 @@
1
+ import { ServerStyleCollector } from "./collector.js";
2
+ import { getSSRCollector, runWithCollector } from "./async-storage.js";
3
+ import { hydrateTastyCache, hydrateTastyClasses } from "./hydrate.js";
4
+ export { ServerStyleCollector, getSSRCollector, hydrateTastyCache, hydrateTastyClasses, runWithCollector };
@@ -0,0 +1,10 @@
1
+ import { registerSSRCollectorGetterGlobal } from "./ssr-collector-ref.js";
2
+ import { ServerStyleCollector } from "./collector.js";
3
+ import { getSSRCollector, runWithCollector } from "./async-storage.js";
4
+ import { hydrateTastyCache, hydrateTastyClasses } from "./hydrate.js";
5
+ //#region src/ssr/index.ts
6
+ registerSSRCollectorGetterGlobal(getSSRCollector);
7
+ //#endregion
8
+ export { ServerStyleCollector, getSSRCollector, hydrateTastyCache, hydrateTastyClasses, runWithCollector };
9
+
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/ssr/index.ts"],"sourcesContent":["/**\n * SSR entry point for @tenphi/tasty.\n *\n * Provides the core SSR infrastructure: ServerStyleCollector,\n * AsyncLocalStorage integration, and cache hydration.\n *\n * Import from '@tenphi/tasty/ssr'.\n */\n\n// Core collector\nexport { ServerStyleCollector } from './collector';\n\n// AsyncLocalStorage integration for Astro / generic frameworks\nexport { runWithCollector, getSSRCollector } from './async-storage';\n\n// Client-side cache hydration\nexport { hydrateTastyClasses, hydrateTastyCache } from './hydrate';\n\n// Register the ALS getter so hooks can find the collector\n// without importing 'node:async_hooks' in the browser bundle.\n// Uses globalThis so the getter is visible across separate module graphs.\nimport { getSSRCollector } from './async-storage';\nimport { registerSSRCollectorGetterGlobal } from './ssr-collector-ref';\n\nregisterSSRCollectorGetterGlobal(getSSRCollector);\n"],"mappings":";;;;;AAwBA,iCAAiC,gBAAgB"}
@@ -0,0 +1,46 @@
1
+ import { ServerStyleCollector } from "./collector.js";
2
+ import * as _$react from "react";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region src/ssr/next.d.ts
6
+ interface TastyRegistryProps {
7
+ children: ReactNode;
8
+ /**
9
+ * Whether to embed the class-list script for client hydration.
10
+ * Set to false to skip class transfer (e.g. for CSP restrictions).
11
+ * Without it, client components may re-inject CSS that already exists
12
+ * in server-rendered `<style>` tags. Default: true.
13
+ */
14
+ transferCache?: boolean;
15
+ }
16
+ /**
17
+ * Next.js App Router registry for Tasty SSR.
18
+ *
19
+ * Wraps the component tree with a ServerStyleCollector and flushes
20
+ * collected CSS into the HTML stream via useServerInsertedHTML.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // app/tasty-registry.tsx
25
+ * 'use client';
26
+ * import { TastyRegistry } from '@tenphi/tasty/ssr/next';
27
+ * export default function TastyStyleRegistry({ children }) {
28
+ * return <TastyRegistry>{children}</TastyRegistry>;
29
+ * }
30
+ *
31
+ * // app/layout.tsx
32
+ * import TastyStyleRegistry from './tasty-registry';
33
+ * export default function RootLayout({ children }) {
34
+ * return <html><body>
35
+ * <TastyStyleRegistry>{children}</TastyStyleRegistry>
36
+ * </body></html>;
37
+ * }
38
+ * ```
39
+ */
40
+ declare function TastyRegistry({
41
+ children,
42
+ transferCache
43
+ }: TastyRegistryProps): _$react.FunctionComponentElement<_$react.ProviderProps<ServerStyleCollector | null>>;
44
+ //#endregion
45
+ export { TastyRegistry, TastyRegistryProps };
46
+ //# sourceMappingURL=next.d.ts.map
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { getConfig } from "../config.js";
3
+ import { registerSSRCollectorGetter } from "./ssr-collector-ref.js";
4
+ import { TastySSRContext } from "./context.js";
5
+ import { ServerStyleCollector } from "./collector.js";
6
+ import { hydrateTastyClasses } from "./hydrate.js";
7
+ import { Fragment, createElement, useState } from "react";
8
+ import { useServerInsertedHTML } from "next/navigation";
9
+ //#region src/ssr/next.ts
10
+ /**
11
+ * Next.js integration for Tasty SSR.
12
+ *
13
+ * Provides TastyRegistry for App Router (streaming via useServerInsertedHTML)
14
+ * and createTastySSRDocument for Pages Router (non-streaming).
15
+ *
16
+ * Import from '@tenphi/tasty/ssr/next'.
17
+ */
18
+ if (typeof window !== "undefined") hydrateTastyClasses();
19
+ /**
20
+ * Next.js App Router registry for Tasty SSR.
21
+ *
22
+ * Wraps the component tree with a ServerStyleCollector and flushes
23
+ * collected CSS into the HTML stream via useServerInsertedHTML.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * // app/tasty-registry.tsx
28
+ * 'use client';
29
+ * import { TastyRegistry } from '@tenphi/tasty/ssr/next';
30
+ * export default function TastyStyleRegistry({ children }) {
31
+ * return <TastyRegistry>{children}</TastyRegistry>;
32
+ * }
33
+ *
34
+ * // app/layout.tsx
35
+ * import TastyStyleRegistry from './tasty-registry';
36
+ * export default function RootLayout({ children }) {
37
+ * return <html><body>
38
+ * <TastyStyleRegistry>{children}</TastyStyleRegistry>
39
+ * </body></html>;
40
+ * }
41
+ * ```
42
+ */
43
+ function TastyRegistry({ children, transferCache = true }) {
44
+ const isClient = typeof window !== "undefined";
45
+ const [collector] = useState(() => {
46
+ if (isClient) return null;
47
+ const instance = new ServerStyleCollector();
48
+ registerSSRCollectorGetter(() => instance);
49
+ return instance;
50
+ });
51
+ const nonce = getConfig().nonce;
52
+ useServerInsertedHTML(() => {
53
+ if (!collector) return null;
54
+ const css = collector.flushCSS();
55
+ const classNames = collector.getRenderedClassNames();
56
+ if (!css) return null;
57
+ const styleEl = createElement("style", {
58
+ key: "tasty-ssr-styles",
59
+ "data-tasty-ssr": "",
60
+ nonce,
61
+ dangerouslySetInnerHTML: { __html: css }
62
+ });
63
+ if (!transferCache || classNames.length === 0) return styleEl;
64
+ return createElement(Fragment, null, styleEl, createElement("script", {
65
+ key: "tasty-ssr-cache",
66
+ nonce,
67
+ dangerouslySetInnerHTML: { __html: `(window.__TASTY__=window.__TASTY__||[]).push(${classNames.map((n) => `"${n}"`).join(",")})` }
68
+ }));
69
+ });
70
+ return createElement(TastySSRContext.Provider, { value: collector }, children);
71
+ }
72
+ //#endregion
73
+ export { TastyRegistry };
74
+
75
+ //# sourceMappingURL=next.js.map
@@ -0,0 +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 { 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 TastySSRContext.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,gBAAgB,UAChB,EAAE,OAAO,WAAW,EACpB,SACD"}
@@ -0,0 +1,29 @@
1
+ //#region src/ssr/ssr-collector-ref.ts
2
+ const GETTER_KEY = "__tasty_ssr_collector_getter__";
3
+ let _getSSRCollector = null;
4
+ /**
5
+ * Register the collector getter in the current module graph only.
6
+ * Used by Next.js TastyRegistry.
7
+ */
8
+ function registerSSRCollectorGetter(fn) {
9
+ _getSSRCollector = fn;
10
+ }
11
+ /**
12
+ * Register the collector getter on globalThis so it is visible across
13
+ * separate module graphs (e.g. Astro middleware ↔ page components).
14
+ */
15
+ function registerSSRCollectorGetterGlobal(fn) {
16
+ globalThis[GETTER_KEY] = fn;
17
+ }
18
+ /**
19
+ * Retrieve the SSR collector: module-level first, globalThis fallback.
20
+ */
21
+ function getRegisteredSSRCollector() {
22
+ if (_getSSRCollector) return _getSSRCollector();
23
+ const getter = globalThis[GETTER_KEY];
24
+ return getter ? getter() : null;
25
+ }
26
+ //#endregion
27
+ export { getRegisteredSSRCollector, registerSSRCollectorGetter, registerSSRCollectorGetterGlobal };
28
+
29
+ //# sourceMappingURL=ssr-collector-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr-collector-ref.js","names":[],"sources":["../../src/ssr/ssr-collector-ref.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"],"mappings":";AAsBA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;;;;;AAMlD,SAAgB,2BAA2B,IAA8B;AACvE,oBAAmB;;;;;;AAOrB,SAAgB,iCAAiC,IAA8B;AAC5E,YAAuC,cAAc;;;;;AAMxD,SAAgB,4BAAyD;AACvE,KAAI,iBAAkB,QAAO,kBAAkB;CAC/C,MAAM,SAAU,WAAuC;AAGvD,QAAO,SAAS,QAAQ,GAAG"}
@@ -1,6 +1,5 @@
1
1
  import { isDevEnv } from "../utils/is-dev-env.js";
2
2
  import { hasStylesGenerated } from "../config.js";
3
-
4
3
  //#region src/states/index.ts
5
4
  /**
6
5
  * Advanced State Mapping - Predefined States Management
@@ -12,21 +11,11 @@ const BUILTIN_STATES = new Set([
12
11
  "@starting",
13
12
  "@keyframes",
14
13
  "@properties",
14
+ "@fontFace",
15
+ "@counterStyle",
15
16
  "@supports",
16
17
  "@inherit"
17
18
  ]);
18
- const RESERVED_PREFIXES = [
19
- "@media",
20
- "@root",
21
- "@parent",
22
- "@own",
23
- "@(",
24
- "@starting",
25
- "@keyframes",
26
- "@properties",
27
- "@supports",
28
- "@inherit"
29
- ];
30
19
  let globalPredefinedStates = {};
31
20
  const emittedWarnings = /* @__PURE__ */ new Set();
32
21
  const devMode = isDevEnv();
@@ -94,29 +83,21 @@ function extractPredefinedStateRefs(value) {
94
83
  }
95
84
  return refs;
96
85
  }
97
- /**
98
- * Check if a state key is a predefined state reference
99
- */
100
- function isPredefinedStateRef(stateKey) {
101
- if (!stateKey.startsWith("@")) return false;
102
- if (BUILTIN_STATES.has(stateKey)) return false;
103
- for (const prefix of RESERVED_PREFIXES) if (stateKey === prefix || stateKey.startsWith(prefix)) {
104
- if (stateKey === "@media" || stateKey.startsWith("@media(") || stateKey.startsWith("@media:")) return false;
105
- if (stateKey === "@root" || stateKey.startsWith("@root(")) return false;
106
- if (stateKey === "@parent" || stateKey.startsWith("@parent(")) return false;
107
- if (stateKey === "@own" || stateKey.startsWith("@own(")) return false;
108
- if (stateKey.startsWith("@(")) return false;
109
- }
110
- return /^@[A-Za-z][A-Za-z0-9-]*$/.test(stateKey);
111
- }
86
+ const _localStatesCache = /* @__PURE__ */ new WeakMap();
112
87
  /**
113
88
  * Extract local predefined states from a styles object
114
89
  * Local predefined states are top-level keys starting with @ that have string values
115
90
  * and are valid predefined state names (not built-in like @media, @root, etc.)
91
+ *
92
+ * Results are cached by object identity via WeakMap since the same styles object
93
+ * is passed to this function multiple times per pipeline run (once per chunk
94
+ * in renderStylesForChunk and generateChunkCacheKey).
116
95
  */
117
96
  function extractLocalPredefinedStates(styles) {
97
+ if (!styles || typeof styles !== "object") return {};
98
+ const cached = _localStatesCache.get(styles);
99
+ if (cached !== void 0) return cached;
118
100
  const localStates = {};
119
- if (!styles || typeof styles !== "object") return localStates;
120
101
  for (const [key, value] of Object.entries(styles)) if (key.startsWith("@") && typeof value === "string") {
121
102
  if (!/^@[A-Za-z][A-Za-z0-9-]*$/.test(key)) continue;
122
103
  if (BUILTIN_STATES.has(key)) continue;
@@ -128,6 +109,7 @@ function extractLocalPredefinedStates(styles) {
128
109
  }
129
110
  localStates[key] = value;
130
111
  }
112
+ _localStatesCache.set(styles, localStates);
131
113
  return localStates;
132
114
  }
133
115
  /**
@@ -171,224 +153,6 @@ function expandTastyUnits(value) {
171
153
  });
172
154
  }
173
155
  /**
174
- * Parse an advanced state key and return its type and components
175
- */
176
- function parseAdvancedState(stateKey, ctx) {
177
- const raw = stateKey;
178
- if (stateKey === "@starting") return {
179
- type: "starting",
180
- condition: "",
181
- raw
182
- };
183
- if (stateKey.startsWith("@media:")) {
184
- const mediaType = stateKey.slice(7);
185
- if (![
186
- "all",
187
- "screen",
188
- "print",
189
- "speech"
190
- ].includes(mediaType)) warnOnce(`unknown-media-type:${mediaType}`, `[Tasty] Unknown media type '${mediaType}'. Valid types: all, screen, print, speech.`);
191
- return {
192
- type: "media",
193
- condition: "",
194
- mediaType,
195
- raw
196
- };
197
- }
198
- if (stateKey.startsWith("@media(")) {
199
- const endParen = findMatchingParen(stateKey, 6);
200
- if (endParen === -1) {
201
- warnOnce(`unclosed-media:${stateKey}`, `[Tasty] Unclosed media query '${stateKey}'. Missing closing parenthesis.`);
202
- return {
203
- type: "modifier",
204
- condition: stateKey,
205
- raw
206
- };
207
- }
208
- let condition = stateKey.slice(7, endParen);
209
- if (!condition.trim()) {
210
- warnOnce(`empty-media:${stateKey}`, `[Tasty] Empty media query condition '${stateKey}'.`);
211
- return {
212
- type: "modifier",
213
- condition: stateKey,
214
- raw
215
- };
216
- }
217
- condition = expandDimensionShorthands(condition);
218
- condition = expandTastyUnits(condition);
219
- return {
220
- type: "media",
221
- condition,
222
- raw
223
- };
224
- }
225
- if (stateKey.startsWith("@root(")) {
226
- const endParen = findMatchingParen(stateKey, 5);
227
- if (endParen === -1) {
228
- warnOnce(`unclosed-root:${stateKey}`, `[Tasty] Unclosed root state '${stateKey}'. Missing closing parenthesis.`);
229
- return {
230
- type: "modifier",
231
- condition: stateKey,
232
- raw
233
- };
234
- }
235
- const condition = stateKey.slice(6, endParen);
236
- if (!condition.trim()) {
237
- warnOnce(`empty-root:${stateKey}`, `[Tasty] Empty root state condition '${stateKey}'.`);
238
- return {
239
- type: "modifier",
240
- condition: stateKey,
241
- raw
242
- };
243
- }
244
- return {
245
- type: "root",
246
- condition,
247
- raw
248
- };
249
- }
250
- if (stateKey.startsWith("@parent(")) {
251
- const endParen = findMatchingParen(stateKey, 7);
252
- if (endParen === -1) {
253
- warnOnce(`unclosed-parent:${stateKey}`, `[Tasty] Unclosed parent state '${stateKey}'. Missing closing parenthesis.`);
254
- return {
255
- type: "modifier",
256
- condition: stateKey,
257
- raw
258
- };
259
- }
260
- const condition = stateKey.slice(8, endParen);
261
- if (!condition.trim()) {
262
- warnOnce(`empty-parent:${stateKey}`, `[Tasty] Empty parent state condition '${stateKey}'.`);
263
- return {
264
- type: "modifier",
265
- condition: stateKey,
266
- raw
267
- };
268
- }
269
- return {
270
- type: "parent",
271
- condition,
272
- raw
273
- };
274
- }
275
- if (stateKey.startsWith("@own(")) {
276
- const endParen = findMatchingParen(stateKey, 4);
277
- if (endParen === -1) {
278
- warnOnce(`unclosed-own:${stateKey}`, `[Tasty] Unclosed own state '${stateKey}'. Missing closing parenthesis.`);
279
- return {
280
- type: "modifier",
281
- condition: stateKey,
282
- raw
283
- };
284
- }
285
- const condition = stateKey.slice(5, endParen);
286
- if (!condition.trim()) {
287
- warnOnce(`empty-own:${stateKey}`, `[Tasty] Empty own state condition '${stateKey}'.`);
288
- return {
289
- type: "modifier",
290
- condition: stateKey,
291
- raw
292
- };
293
- }
294
- if (!ctx.isSubElement) {
295
- warnOnce(`own-outside-subelement:${stateKey}`, `[Tasty] @own(${condition}) used outside sub-element context.\n@own() is equivalent to '${condition}' at the root level. Did you mean to use it inside a sub-element?`);
296
- return {
297
- type: "modifier",
298
- condition,
299
- raw
300
- };
301
- }
302
- return {
303
- type: "own",
304
- condition,
305
- raw
306
- };
307
- }
308
- if (stateKey.startsWith("@(")) {
309
- const endParen = findMatchingParen(stateKey, 1);
310
- if (endParen === -1) {
311
- warnOnce(`unclosed-container:${stateKey}`, `[Tasty] Unclosed container query '${stateKey}'. Missing closing parenthesis.`);
312
- return {
313
- type: "modifier",
314
- condition: stateKey,
315
- raw
316
- };
317
- }
318
- const content = stateKey.slice(2, endParen);
319
- if (!content.trim()) {
320
- warnOnce(`empty-container:${stateKey}`, `[Tasty] Empty container query '${stateKey}'.`);
321
- return {
322
- type: "modifier",
323
- condition: stateKey,
324
- raw
325
- };
326
- }
327
- const commaIndex = findTopLevelComma(content);
328
- let containerName;
329
- let condition;
330
- if (commaIndex !== -1) {
331
- containerName = content.slice(0, commaIndex).trim();
332
- condition = content.slice(commaIndex + 1).trim();
333
- } else condition = content.trim();
334
- if (condition.startsWith("$")) {
335
- const styleCondition = parseStyleQuery(condition);
336
- if (!styleCondition) {
337
- warnOnce(`invalid-style-query:${stateKey}`, `[Tasty] Invalid style query '${condition}' in container query.`);
338
- return {
339
- type: "modifier",
340
- condition: stateKey,
341
- raw
342
- };
343
- }
344
- condition = styleCondition;
345
- } else if (/^[a-zA-Z][\w-]*\s*\(/.test(condition)) {} else {
346
- condition = expandDimensionShorthands(condition);
347
- condition = expandTastyUnits(condition);
348
- }
349
- return {
350
- type: "container",
351
- condition,
352
- containerName,
353
- raw
354
- };
355
- }
356
- if (isPredefinedStateRef(stateKey)) {
357
- const resolved = resolvePredefinedState(stateKey, ctx);
358
- if (resolved) return {
359
- ...parseAdvancedState(resolved, ctx),
360
- raw
361
- };
362
- return {
363
- type: "modifier",
364
- condition: stateKey,
365
- raw
366
- };
367
- }
368
- return {
369
- type: "modifier",
370
- condition: stateKey,
371
- raw
372
- };
373
- }
374
- /**
375
- * Parse a style query condition (e.g., $compact, $variant=compact, $variant="very compact")
376
- */
377
- function parseStyleQuery(condition) {
378
- const query = condition.slice(1);
379
- if (/[<>]/.test(query)) {
380
- warnOnce(`style-query-comparison:${condition}`, `[Tasty] Style queries only support equality. '${condition}' is invalid. Use '${condition.split(/[<>]/)[0]}=...' instead.`);
381
- return null;
382
- }
383
- const eqIndex = query.indexOf("=");
384
- if (eqIndex === -1) return `style(--${query})`;
385
- const propName = query.slice(0, eqIndex).trim();
386
- let value = query.slice(eqIndex + 1).trim();
387
- if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) {} else value = `"${value}"`;
388
- value = expandTastyUnits(value);
389
- return `style(--${propName}: ${value})`;
390
- }
391
- /**
392
156
  * Find the index of the first comma at parentheses depth 0.
393
157
  * Returns -1 if no top-level comma is found.
394
158
  * This prevents splitting on commas inside function calls like scroll-state(a, b).
@@ -400,17 +164,7 @@ function findTopLevelComma(s) {
400
164
  else if (s[i] === "," && depth === 0) return i;
401
165
  return -1;
402
166
  }
403
- function findMatchingParen(str, startIndex) {
404
- let depth = 1;
405
- let i = startIndex + 1;
406
- while (i < str.length && depth > 0) {
407
- if (str[i] === "(") depth++;
408
- else if (str[i] === ")") depth--;
409
- i++;
410
- }
411
- return depth === 0 ? i - 1 : -1;
412
- }
413
-
414
167
  //#endregion
415
- export { createStateParserContext, expandDimensionShorthands, expandTastyUnits, extractLocalPredefinedStates, extractPredefinedStateRefs, findTopLevelComma, getGlobalPredefinedStates, parseAdvancedState, resolvePredefinedState, setGlobalPredefinedStates };
168
+ export { createStateParserContext, expandDimensionShorthands, expandTastyUnits, extractLocalPredefinedStates, extractPredefinedStateRefs, findTopLevelComma, getGlobalPredefinedStates, resolvePredefinedState, setGlobalPredefinedStates };
169
+
416
170
  //# sourceMappingURL=index.js.map