@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fde7ec8

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 (325) hide show
  1. package/README.md +322 -160
  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 +157 -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 +23 -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 +293 -46
  57. package/dist/injector/injector.js.map +1 -1
  58. package/dist/injector/sheet-manager.d.ts +22 -17
  59. package/dist/injector/sheet-manager.js +64 -79
  60. package/dist/injector/sheet-manager.js.map +1 -1
  61. package/dist/injector/types.d.ts +121 -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 +15 -9
  76. package/dist/pipeline/conditions.js.map +1 -1
  77. package/dist/pipeline/exclusive.js +58 -4
  78. package/dist/pipeline/exclusive.js.map +1 -1
  79. package/dist/pipeline/index.d.ts +3 -1
  80. package/dist/pipeline/index.js +141 -74
  81. package/dist/pipeline/index.js.map +1 -1
  82. package/dist/pipeline/materialize.js +460 -211
  83. package/dist/pipeline/materialize.js.map +1 -1
  84. package/dist/pipeline/parseStateKey.d.ts +1 -1
  85. package/dist/pipeline/parseStateKey.js +38 -22
  86. package/dist/pipeline/parseStateKey.js.map +1 -1
  87. package/dist/pipeline/simplify.js +289 -156
  88. package/dist/pipeline/simplify.js.map +1 -1
  89. package/dist/pipeline/warnings.js +18 -0
  90. package/dist/pipeline/warnings.js.map +1 -0
  91. package/dist/plugins/index.d.ts +2 -0
  92. package/dist/plugins/okhsl-plugin.js +3 -277
  93. package/dist/plugins/okhsl-plugin.js.map +1 -1
  94. package/dist/plugins/types.d.ts +20 -2
  95. package/dist/properties/index.js +83 -19
  96. package/dist/properties/index.js.map +1 -1
  97. package/dist/properties/property-type-resolver.d.ts +24 -0
  98. package/dist/properties/property-type-resolver.js +90 -0
  99. package/dist/properties/property-type-resolver.js.map +1 -0
  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 +2 -2
  150. package/dist/styles/border.js +30 -24
  151. package/dist/styles/border.js.map +1 -1
  152. package/dist/styles/color.d.ts +3 -3
  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 +29 -27
  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 +2 -2
  167. package/dist/styles/fade.js +9 -5
  168. package/dist/styles/fade.js.map +1 -1
  169. package/dist/styles/fill.d.ts +15 -17
  170. package/dist/styles/fill.js +9 -9
  171. package/dist/styles/fill.js.map +1 -1
  172. package/dist/styles/flow.d.ts +3 -3
  173. package/dist/styles/flow.js +1 -1
  174. package/dist/styles/flow.js.map +1 -1
  175. package/dist/styles/gap.d.ts +1 -1
  176. package/dist/styles/gap.js +4 -3
  177. package/dist/styles/gap.js.map +1 -1
  178. package/dist/styles/height.d.ts +1 -1
  179. package/dist/styles/height.js +1 -2
  180. package/dist/styles/height.js.map +1 -1
  181. package/dist/styles/index.d.ts +0 -1
  182. package/dist/styles/index.js +3 -4
  183. package/dist/styles/index.js.map +1 -1
  184. package/dist/styles/inset.d.ts +1 -29
  185. package/dist/styles/inset.js +19 -135
  186. package/dist/styles/inset.js.map +1 -1
  187. package/dist/styles/list.d.ts +5 -5
  188. package/dist/styles/list.js +4 -2
  189. package/dist/styles/list.js.map +1 -1
  190. package/dist/styles/margin.d.ts +1 -1
  191. package/dist/styles/margin.js +17 -89
  192. package/dist/styles/margin.js.map +1 -1
  193. package/dist/styles/outline.d.ts +1 -1
  194. package/dist/styles/outline.js +6 -16
  195. package/dist/styles/outline.js.map +1 -1
  196. package/dist/styles/padding.d.ts +1 -1
  197. package/dist/styles/padding.js +17 -89
  198. package/dist/styles/padding.js.map +1 -1
  199. package/dist/styles/placement.d.ts +37 -0
  200. package/dist/styles/placement.js +74 -0
  201. package/dist/styles/placement.js.map +1 -0
  202. package/dist/styles/predefined.d.ts +4 -6
  203. package/dist/styles/predefined.js +9 -13
  204. package/dist/styles/predefined.js.map +1 -1
  205. package/dist/styles/preset.d.ts +6 -1
  206. package/dist/styles/preset.js +54 -53
  207. package/dist/styles/preset.js.map +1 -1
  208. package/dist/styles/radius.d.ts +2 -4
  209. package/dist/styles/radius.js +38 -6
  210. package/dist/styles/radius.js.map +1 -1
  211. package/dist/styles/scrollMargin.d.ts +24 -0
  212. package/dist/styles/scrollMargin.js +32 -0
  213. package/dist/styles/scrollMargin.js.map +1 -0
  214. package/dist/styles/scrollbar.d.ts +9 -5
  215. package/dist/styles/scrollbar.js +31 -85
  216. package/dist/styles/scrollbar.js.map +1 -1
  217. package/dist/styles/shadow.d.ts +3 -3
  218. package/dist/styles/shadow.js +4 -3
  219. package/dist/styles/shadow.js.map +1 -1
  220. package/dist/styles/shared.js +17 -0
  221. package/dist/styles/shared.js.map +1 -0
  222. package/dist/styles/transition.d.ts +2 -2
  223. package/dist/styles/transition.js +6 -5
  224. package/dist/styles/transition.js.map +1 -1
  225. package/dist/styles/types.d.ts +94 -28
  226. package/dist/styles/width.d.ts +1 -1
  227. package/dist/styles/width.js +1 -2
  228. package/dist/styles/width.js.map +1 -1
  229. package/dist/tasty.d.ts +46 -894
  230. package/dist/tasty.js +117 -60
  231. package/dist/tasty.js.map +1 -1
  232. package/dist/types.d.ts +3 -3
  233. package/dist/utils/cache-wrapper.js +4 -9
  234. package/dist/utils/cache-wrapper.js.map +1 -1
  235. package/dist/utils/case-converter.js +1 -1
  236. package/dist/utils/color-math.d.ts +46 -0
  237. package/dist/utils/color-math.js +749 -0
  238. package/dist/utils/color-math.js.map +1 -0
  239. package/dist/utils/color-space.d.ts +5 -0
  240. package/dist/utils/color-space.js +228 -0
  241. package/dist/utils/color-space.js.map +1 -0
  242. package/dist/utils/colors.d.ts +1 -1
  243. package/dist/utils/colors.js +3 -2
  244. package/dist/utils/colors.js.map +1 -1
  245. package/dist/utils/css-types.d.ts +1 -1
  246. package/dist/utils/deps-equal.js +15 -0
  247. package/dist/utils/deps-equal.js.map +1 -0
  248. package/dist/utils/dotize.d.ts +1 -1
  249. package/dist/utils/dotize.js +1 -1
  250. package/dist/utils/dotize.js.map +1 -1
  251. package/dist/utils/filter-base-props.d.ts +1 -1
  252. package/dist/utils/filter-base-props.js +1 -1
  253. package/dist/utils/filter-base-props.js.map +1 -1
  254. package/dist/utils/get-display-name.js +1 -1
  255. package/dist/utils/has-keys.js +13 -0
  256. package/dist/utils/has-keys.js.map +1 -0
  257. package/dist/utils/hash.js +14 -0
  258. package/dist/utils/hash.js.map +1 -0
  259. package/dist/utils/is-dev-env.js +1 -1
  260. package/dist/utils/is-dev-env.js.map +1 -1
  261. package/dist/utils/is-valid-element-type.js +1 -1
  262. package/dist/utils/merge-styles.js +1 -2
  263. package/dist/utils/merge-styles.js.map +1 -1
  264. package/dist/utils/mod-attrs.d.ts +0 -2
  265. package/dist/utils/mod-attrs.js +3 -4
  266. package/dist/utils/mod-attrs.js.map +1 -1
  267. package/dist/utils/process-tokens.d.ts +3 -17
  268. package/dist/utils/process-tokens.js +19 -107
  269. package/dist/utils/process-tokens.js.map +1 -1
  270. package/dist/utils/resolve-recipes.js +1 -2
  271. package/dist/utils/resolve-recipes.js.map +1 -1
  272. package/dist/utils/selector-transform.js +32 -0
  273. package/dist/utils/selector-transform.js.map +1 -0
  274. package/dist/utils/string.js +1 -1
  275. package/dist/utils/string.js.map +1 -1
  276. package/dist/utils/styles.d.ts +5 -89
  277. package/dist/utils/styles.js +35 -400
  278. package/dist/utils/styles.js.map +1 -1
  279. package/dist/utils/typography.d.ts +35 -13
  280. package/dist/utils/typography.js +16 -18
  281. package/dist/utils/typography.js.map +1 -1
  282. package/dist/utils/warnings.js +1 -1
  283. package/dist/zero/babel.d.ts +57 -84
  284. package/dist/zero/babel.js +217 -37
  285. package/dist/zero/babel.js.map +1 -1
  286. package/dist/zero/css-writer.js +1 -2
  287. package/dist/zero/css-writer.js.map +1 -1
  288. package/dist/zero/extractor.js +119 -3
  289. package/dist/zero/extractor.js.map +1 -1
  290. package/dist/zero/index.js +1 -2
  291. package/dist/zero/next.d.ts +56 -30
  292. package/dist/zero/next.js +105 -40
  293. package/dist/zero/next.js.map +1 -1
  294. package/docs/PIPELINE.md +519 -0
  295. package/docs/README.md +31 -0
  296. package/docs/adoption.md +298 -0
  297. package/docs/comparison.md +419 -0
  298. package/docs/configuration.md +394 -0
  299. package/docs/debug.md +318 -0
  300. package/docs/design-system.md +436 -0
  301. package/docs/dsl.md +688 -0
  302. package/docs/getting-started.md +217 -0
  303. package/docs/injector.md +544 -0
  304. package/docs/methodology.md +616 -0
  305. package/docs/react-api.md +557 -0
  306. package/docs/ssr.md +442 -0
  307. package/docs/styles.md +596 -0
  308. package/docs/tasty-static.md +532 -0
  309. package/package.json +112 -31
  310. package/dist/styles/align.d.ts +0 -15
  311. package/dist/styles/align.js +0 -14
  312. package/dist/styles/align.js.map +0 -1
  313. package/dist/styles/justify.d.ts +0 -15
  314. package/dist/styles/justify.js +0 -14
  315. package/dist/styles/justify.js.map +0 -1
  316. package/dist/styles/styledScrollbar.d.ts +0 -47
  317. package/dist/styles/styledScrollbar.js +0 -38
  318. package/dist/styles/styledScrollbar.js.map +0 -1
  319. package/dist/tokens/typography.d.ts +0 -19
  320. package/dist/tokens/typography.js +0 -237
  321. package/dist/tokens/typography.js.map +0 -1
  322. package/dist/utils/hsl-to-rgb.js +0 -38
  323. package/dist/utils/hsl-to-rgb.js.map +0 -1
  324. package/dist/utils/okhsl-to-rgb.js +0 -296
  325. package/dist/utils/okhsl-to-rgb.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  import { ProcessedStyle, StyleDetails } from "../parser/types.js";
2
2
  import { StyleParser } from "../parser/parser.js";
3
- import { AtRuleContext, ParsedAdvancedState, StateParserContext } from "../states/index.js";
4
- import { Styles } from "../styles/types.js";
3
+ import { getNamedColorHex, getRgbValuesFromRgbaString, hexToRgb, strToRgb } from "./color-math.js";
5
4
 
6
5
  //#region src/utils/styles.d.ts
7
6
  type StyleValue<T = string> = T | boolean | number | null | undefined;
@@ -21,11 +20,10 @@ type StyleValueStateMap<T = string> = Record<string, StyleValue<T> | '@inherit'>
21
20
  * Use this for component props that accept style values.
22
21
  */
23
22
  type StylePropValue<T = string> = StyleValue<T> | StyleValueStateMap<T>;
24
- type ComputeModel = string | number;
25
23
  type CSSMap = {
26
24
  $?: string | string[];
27
25
  } & Record<string, string | string[]>;
28
- type StyleHandlerResult = CSSMap | CSSMap[] | void;
26
+ type StyleHandlerResult = CSSMap | CSSMap[] | null | void;
29
27
  type RawStyleHandler = (value: StyleValueStateMap) => StyleHandlerResult;
30
28
  type StyleHandler = RawStyleHandler & {
31
29
  __lookupStyles: string[];
@@ -37,44 +35,21 @@ type StyleHandler = RawStyleHandler & {
37
35
  * - Multi-property tuple: [['style1', 'style2'], handler]
38
36
  */
39
37
  type StyleHandlerDefinition = RawStyleHandler | [string, RawStyleHandler] | [string[], RawStyleHandler];
40
- interface StyleStateData {
41
- model?: ComputeModel;
42
- tokens?: string[];
43
- value: StyleValue | StyleValueStateMap | StyleStateData;
44
- /** The list of mods to apply */
45
- mods: string[];
46
- /** The list of **not** mods to apply (e.g. `:not(:hover)`) */
47
- notMods: string[];
48
- /** Advanced states (media queries, container queries, etc.) */
49
- advancedStates?: ParsedAdvancedState[];
50
- /** At-rule context for CSS generation */
51
- atRuleContext?: AtRuleContext;
52
- /** Own mods for sub-element states (from @own()) - applied to sub-element selector */
53
- ownMods?: string[];
54
- /** Negated own mods for sub-element states */
55
- negatedOwnMods?: string[];
56
- }
57
38
  interface ParsedColor {
58
39
  color?: string;
59
40
  name?: string;
60
41
  opacity?: number;
61
42
  }
62
- type StyleStateDataList = StyleStateData[];
63
- type StyleStateDataListMap = Record<string, StyleStateDataList>;
64
43
  type StyleMap = Record<string, StyleValue | StyleValueStateMap>;
65
- type StyleStateMap = Record<string, StyleStateData>;
66
44
  declare const CUSTOM_UNITS: {
67
45
  r: string;
68
46
  cr: string;
69
47
  bw: string;
70
48
  ow: string;
71
49
  x: string;
72
- fs: string;
73
- lh: string;
74
- sf: (num: any) => string;
50
+ sf: (num: number) => string;
75
51
  };
76
52
  declare const DIRECTIONS: string[];
77
- declare function getModSelector(modName: string): string;
78
53
  declare function customFunc(name: string, fn: (groups: StyleDetails[]) => string): void;
79
54
  /**
80
55
  * Get the global StyleParser instance.
@@ -117,67 +92,8 @@ declare function parseStyle(value: StyleValue): ProcessedStyle;
117
92
  * Optimized to avoid heavy parseStyle calls for simple color patterns.
118
93
  */
119
94
  declare function parseColor(val: string, ignoreError?: boolean): ParsedColor;
120
- declare function strToRgb(color: any, _ignoreAlpha?: boolean): any;
121
- /**
122
- * Extract RGB values from an rgb()/rgba() string.
123
- * Supports all modern CSS syntax variations:
124
- * - Comma-separated: rgb(255, 128, 0)
125
- * - Space-separated: rgb(255 128 0)
126
- * - Fractional: rgb(128.5, 64.3, 32.1)
127
- * - Percentages: rgb(50%, 25%, 75%)
128
- * - Slash alpha notation: rgb(255 128 0 / 0.5)
129
- *
130
- * Returns array of RGB values (0-255 range), converting percentages as needed.
131
- */
132
- declare function getRgbValuesFromRgbaString(str: string): number[];
133
- declare function hexToRgb(hex: any): string | null;
134
- declare function filterMods(mods: any, allowedMods: any): any;
135
- declare function extendStyles(defaultStyles: any, newStyles: any): {};
136
- /**
137
- * Split properties into style and non-style properties.
138
- * @param props - Component prop map.
139
- * @param [styleList] - List of all style properties.
140
- * @param [defaultStyles] - Default style map of the component.
141
- * @param [propMap] - Props to style alias map.
142
- * @param [ignoreList] - A list of properties to ignore.
143
- */
144
- declare function extractStyles(props: Record<string, unknown>, styleList?: readonly string[], defaultStyles?: Styles, propMap?: Record<string, string>, ignoreList?: readonly string[]): Styles;
145
- /**
146
- * Check if a token is an advanced state (starts with @)
147
- */
148
- declare function isAdvancedStateToken(token: string): boolean;
149
- declare const STATE_OPERATORS: {
150
- NOT: string;
151
- AND: string;
152
- OR: string;
153
- XOR: string;
154
- };
155
- declare const STATE_OPERATOR_LIST: string[];
156
- declare const parseStateNotation: (firstArg: string, secondArg?: string | number | boolean | StyleValueStateMap<string> | StyleStateData | null | undefined) => StyleStateData;
157
- /**
158
- * Build an AtRuleContext from parsed advanced states
159
- */
160
- declare function buildAtRuleContext(advancedStates: ParsedAdvancedState[], negatedStates: Set<string>): AtRuleContext | undefined;
161
- /**
162
- * Parse state notation and return tokens, modifiers and compute model.
163
- * Enhanced to detect and extract advanced states.
164
- */
165
- declare function styleStateMapToStyleStateDataList(styleStateMap: StyleStateMap | StyleValue | StyleValueStateMap, parserContext?: StateParserContext): {
166
- states: StyleStateDataList;
167
- mods: string[];
168
- hasAdvancedStates: boolean;
169
- };
170
- declare const COMPUTE_FUNC_MAP: {
171
- '!': (a: any) => boolean;
172
- '^': (a: any, b: any) => any;
173
- '|': (a: any, b: any) => any;
174
- '&': (a: any, b: any) => any;
175
- };
176
- /**
177
- * Compute a result based on a model and incoming map.
178
- */
179
- declare function computeState(computeModel: ComputeModel, valueMap: (number | boolean)[] | Record<string, boolean> | ((...args: unknown[]) => unknown)): any;
95
+ declare function filterMods(mods: string[], allowedMods: string[]): string[];
180
96
  declare function stringifyStyles(styles: unknown): string;
181
97
  //#endregion
182
- export { COMPUTE_FUNC_MAP, CSSMap, CUSTOM_UNITS, ComputeModel, DIRECTIONS, ParsedColor, RawStyleHandler, STATE_OPERATORS, STATE_OPERATOR_LIST, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleMap, StylePropValue, StyleStateData, StyleStateDataList, StyleStateDataListMap, StyleStateMap, StyleValue, StyleValueStateMap, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getModSelector, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList };
98
+ export { CSSMap, CUSTOM_UNITS, DIRECTIONS, ParsedColor, RawStyleHandler, StyleHandler, StyleHandlerDefinition, StyleHandlerResult, StyleMap, StylePropValue, StyleValue, StyleValueStateMap, customFunc, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, normalizeColorTokenValue, parseColor, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, stringifyStyles };
183
99
  //# sourceMappingURL=styles.d.ts.map
@@ -1,11 +1,6 @@
1
+ import { getNamedColorHex } from "./color-math.js";
1
2
  import { StyleParser } from "../parser/parser.js";
2
3
  import { okhslFunc } from "../plugins/okhsl-plugin.js";
3
- import { createStateParserContext, parseAdvancedState } from "../states/index.js";
4
- import { cacheWrapper } from "./cache-wrapper.js";
5
- import { camelToKebab } from "./case-converter.js";
6
- import { okhslToRgb } from "./okhsl-to-rgb.js";
7
- import { hslToRgb } from "./hsl-to-rgb.js";
8
-
9
4
  //#region src/utils/styles.ts
10
5
  /**
11
6
  * Normalize a color token value.
@@ -22,19 +17,23 @@ function normalizeColorTokenValue(value) {
22
17
  return value;
23
18
  }
24
19
  const COLOR_VAR_PATTERN = /var\(--([a-z0-9-]+)-color/;
25
- const COLOR_VAR_RGB_PATTERN = /var\(--([a-z0-9-]+)-color-rgb/;
20
+ const COLOR_VAR_COMPONENTS_PATTERN = /var\(--([a-z0-9-]+)-color-(?:rgb|hsl|oklch)/;
26
21
  const RGB_ALPHA_PATTERN = /\/\s*([0-9.]+)\)/;
27
- const SIMPLE_COLOR_PATTERNS = [
28
- /^#[0-9a-fA-F]{3,8}$/,
29
- /^rgb\(/,
30
- /^hsl\(/,
31
- /^lch\(/,
32
- /^oklch\(/,
33
- /^okhsl\(/,
34
- /^var\(--[a-z0-9-]+-color/,
35
- /^currentColor$/,
36
- /^transparent$/
37
- ];
22
+ const RE_HEX_COLOR = /^#[0-9a-fA-F]{3,8}$/;
23
+ const RE_VAR_COLOR = /^var\(--[a-z0-9-]+-color/;
24
+ function isSimpleColorFast(val) {
25
+ switch (val.charCodeAt(0)) {
26
+ case 35: return RE_HEX_COLOR.test(val);
27
+ case 114: return val.charCodeAt(1) === 103 && val.charCodeAt(2) === 98;
28
+ case 104: return val.charCodeAt(1) === 115 && val.charCodeAt(2) === 108;
29
+ case 108: return val.charCodeAt(1) === 99 && val.charCodeAt(2) === 104;
30
+ case 111: return val.startsWith("oklch(") || val.startsWith("okhsl(");
31
+ case 118: return RE_VAR_COLOR.test(val);
32
+ case 99: return val === "currentColor" || val === "currentcolor";
33
+ case 116: return val === "transparent";
34
+ default: return getNamedColorHex().has(val.toLowerCase());
35
+ }
36
+ }
38
37
  let colorWarningCount = 0;
39
38
  const MAX_COLOR_WARNINGS = 10;
40
39
  const CUSTOM_UNITS = {
@@ -43,8 +42,6 @@ const CUSTOM_UNITS = {
43
42
  bw: "1px",
44
43
  ow: "3px",
45
44
  x: "8px",
46
- fs: "var(--font-size)",
47
- lh: "var(--line-height)",
48
45
  sf: function sf(num) {
49
46
  return `minmax(0, ${num}fr)`;
50
47
  }
@@ -55,27 +52,6 @@ const DIRECTIONS = [
55
52
  "bottom",
56
53
  "left"
57
54
  ];
58
- const MOD_NAME_CACHE = /* @__PURE__ */ new Map();
59
- function getModSelector(modName) {
60
- if (!MOD_NAME_CACHE.has(modName)) {
61
- let selector;
62
- const valueModMatch = modName.match(/^([a-z][a-z0-9-]*)(\^=|\$=|\*=|=)(.+)$/i);
63
- if (valueModMatch) {
64
- const key = valueModMatch[1];
65
- const operator = valueModMatch[2];
66
- let value = valueModMatch[3];
67
- if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
68
- selector = `[data-${camelToKebab(key)}${operator}"${value}"]`;
69
- } else if (modName.match(/^[a-z]/)) selector = `[data-${camelToKebab(modName)}]`;
70
- else if (modName.includes(":has(")) selector = modName.replace(/:has\(([^)]+)\)/g, (match, content) => {
71
- if (/[A-Z][a-z]*[>+~]|[>+~][A-Z][a-z]*/.test(content)) console.error(`[Tasty] Invalid :has() selector syntax: "${modName}"\nCombinators (>, +, ~) must have spaces around them when used with element names.\nExample: Use ":has(Body > Row)" instead of ":has(Body>Row)"\nThis is a design choice: the parser uses simple whitespace splitting for performance.`);
72
- return `:has(${content.split(/\s+/).map((token) => /^[A-Z]/.test(token) ? `[data-element="${token}"]` : token).join(" ")})`;
73
- });
74
- else selector = modName;
75
- MOD_NAME_CACHE.set(modName, selector);
76
- }
77
- return MOD_NAME_CACHE.get(modName);
78
- }
79
55
  let __tastyParser = null;
80
56
  function getOrCreateParser() {
81
57
  if (!__tastyParser) {
@@ -169,23 +145,23 @@ function parseColor(val, ignoreError = false) {
169
145
  if (typeof val !== "string") val = String(val ?? "");
170
146
  val = val.trim();
171
147
  if (!val) return {};
172
- const isSimpleColor = SIMPLE_COLOR_PATTERNS.some((pattern) => pattern.test(val));
148
+ const isSimpleColor = isSimpleColorFast(val);
173
149
  let firstColor;
174
150
  if (isSimpleColor) firstColor = val;
175
151
  else {
176
152
  const extractedColor = parseStyle(val).groups.find((g) => g.colors.length)?.colors[0];
177
153
  if (!extractedColor) {
178
154
  if (!ignoreError && colorWarningCount < MAX_COLOR_WARNINGS) {
179
- console.warn("CubeUIKit: unable to parse color:", val);
155
+ console.warn("Tasty: unable to parse color:", val);
180
156
  colorWarningCount++;
181
- if (colorWarningCount === MAX_COLOR_WARNINGS) console.warn("CubeUIKit: color parsing warnings will be suppressed from now on");
157
+ if (colorWarningCount === MAX_COLOR_WARNINGS) console.warn("Tasty: color parsing warnings will be suppressed from now on");
182
158
  }
183
159
  return {};
184
160
  }
185
161
  firstColor = extractedColor;
186
162
  }
187
163
  let nameMatch = firstColor.match(COLOR_VAR_PATTERN);
188
- if (!nameMatch) nameMatch = firstColor.match(COLOR_VAR_RGB_PATTERN);
164
+ if (!nameMatch) nameMatch = firstColor.match(COLOR_VAR_COMPONENTS_PATTERN);
189
165
  let opacity;
190
166
  if (firstColor.startsWith("rgb") || firstColor.startsWith("hsl") || firstColor.startsWith("lch") || firstColor.startsWith("oklch") || firstColor.startsWith("okhsl")) {
191
167
  const alphaMatch = firstColor.match(RGB_ALPHA_PATTERN);
@@ -200,364 +176,20 @@ function parseColor(val, ignoreError = false) {
200
176
  opacity
201
177
  };
202
178
  }
203
- function strToRgb(color, _ignoreAlpha = false) {
204
- if (!color) return void 0;
205
- if (color.startsWith("rgb")) return color;
206
- if (color.startsWith("#")) return hexToRgb(color);
207
- if (color.startsWith("okhsl(")) return okhslToRgb(color);
208
- if (color.startsWith("hsl")) return hslToRgb(color);
209
- return null;
210
- }
211
- /**
212
- * Extract RGB values from an rgb()/rgba() string.
213
- * Supports all modern CSS syntax variations:
214
- * - Comma-separated: rgb(255, 128, 0)
215
- * - Space-separated: rgb(255 128 0)
216
- * - Fractional: rgb(128.5, 64.3, 32.1)
217
- * - Percentages: rgb(50%, 25%, 75%)
218
- * - Slash alpha notation: rgb(255 128 0 / 0.5)
219
- *
220
- * Returns array of RGB values (0-255 range), converting percentages as needed.
221
- */
222
- function getRgbValuesFromRgbaString(str) {
223
- const match = str.match(/rgba?\(([^)]+)\)/i);
224
- if (!match) return [];
225
- const [colorPart] = match[1].trim().split("/");
226
- return colorPart.trim().split(/[,\s]+/).filter(Boolean).slice(0, 3).map((part) => {
227
- part = part.trim();
228
- if (part.endsWith("%")) return parseFloat(part) / 100 * 255;
229
- return parseFloat(part);
230
- });
231
- }
232
- function hexToRgb(hex) {
233
- const rgba = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => "#" + r + r + g + g + b + b).substring(1).match(/.{2}/g).map((x, i) => parseInt(x, 16) * (i === 3 ? 1 / 255 : 1));
234
- if (rgba.some((v) => Number.isNaN(v))) return null;
235
- if (rgba.length >= 3) return `rgb(${rgba.slice(0, 3).join(" ")}${rgba.length > 3 ? ` / ${rgba[3]}` : ""})`;
236
- return null;
237
- }
238
179
  function filterMods(mods, allowedMods) {
239
180
  return mods.filter((mod) => allowedMods.includes(mod));
240
181
  }
241
- function extendStyles(defaultStyles, newStyles) {
242
- let styles = {};
243
- if (!defaultStyles) {
244
- if (!newStyles) return styles;
245
- } else styles = Object.assign({}, defaultStyles);
246
- if (newStyles) Object.keys(newStyles).forEach((key) => {
247
- if (newStyles[key] != null) styles[key] = newStyles[key];
248
- });
249
- return styles;
250
- }
251
- /**
252
- * Split properties into style and non-style properties.
253
- * @param props - Component prop map.
254
- * @param [styleList] - List of all style properties.
255
- * @param [defaultStyles] - Default style map of the component.
256
- * @param [propMap] - Props to style alias map.
257
- * @param [ignoreList] - A list of properties to ignore.
258
- */
259
- function extractStyles(props, styleList = [], defaultStyles, propMap, ignoreList = []) {
260
- const styles = {
261
- ...defaultStyles,
262
- ...ignoreList.includes("styles") ? void 0 : props.styles && typeof props.styles === "object" ? props.styles : void 0
263
- };
264
- Object.keys(props).forEach((prop) => {
265
- const propName = propMap ? propMap[prop] || prop : prop;
266
- const value = props[prop];
267
- if (ignoreList && ignoreList.includes(prop)) {} else if (styleList.includes(propName)) styles[propName] = value;
268
- }, {});
269
- return styles;
270
- }
271
- const STATES_REGEXP = /([&|!^])|([()])|(@media:[a-z]+)|(@media\([^)]+\))|(@root\([^)]+\))|(@own\([^)]+\))|(@\([^)]+\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]+=(?:"[^"]*"|'[^']*'|[^\s&|!^()]+))|([a-z][a-z0-9-]+)|(:[a-z][a-z0-9-]+\([^)]+\)|:[a-z][a-z0-9-]+)|(\.[a-z][a-z0-9-]+)|(\[[^\]]+])/gi;
272
- /**
273
- * Check if a token is an advanced state (starts with @)
274
- */
275
- function isAdvancedStateToken(token) {
276
- return token.startsWith("@") || token.startsWith("!@");
277
- }
278
- const STATE_OPERATORS = {
279
- NOT: "!",
280
- AND: "&",
281
- OR: "|",
282
- XOR: "^"
283
- };
284
- const STATE_OPERATOR_LIST = [
285
- "!",
286
- "&",
287
- "|",
288
- "^"
289
- ];
290
- /**
291
- * Convert state notation tokens to a compute model (string, or nested [op, lhs, rhs]).
292
- */
293
- function convertTokensToComputeUnits(tokens) {
294
- if (tokens.length === 1) return tokens[0];
295
- const hasLength = (x) => typeof x === "string" || Array.isArray(x);
296
- STATE_OPERATOR_LIST.forEach((operator) => {
297
- let i;
298
- while ((i = tokens.indexOf(operator)) !== -1) {
299
- const token = tokens[i];
300
- if (token === "!") {
301
- const next = tokens[i + 1];
302
- if (next !== void 0 && hasLength(next) && next.length !== 1) tokens.splice(i, 2, ["!", next]);
303
- else tokens.splice(i, 1);
304
- } else {
305
- const prev = tokens[i - 1];
306
- const next = tokens[i + 1];
307
- if (prev !== void 0 && next !== void 0 && hasLength(prev) && hasLength(next) && prev.length !== 1 && next.length !== 1) tokens.splice(i - 1, 3, [
308
- token,
309
- prev,
310
- next
311
- ]);
312
- else tokens.splice(i, 1);
313
- }
314
- }
315
- });
316
- return tokens.length === 1 ? tokens[0] : tokens;
317
- }
318
- /**
319
- * Replace commas with | only outside of parentheses.
320
- * This preserves commas in advanced states like @(card, w < 600px)
321
- */
322
- function replaceCommasOutsideParens(str) {
323
- let result = "";
324
- let depth = 0;
325
- for (const char of str) if (char === "(") {
326
- depth++;
327
- result += char;
328
- } else if (char === ")") {
329
- depth--;
330
- result += char;
331
- } else if (char === "," && depth === 0) result += "|";
332
- else result += char;
333
- return result;
334
- }
335
- /**
336
- * Parse state notation and return tokens, modifiers and compute model.
337
- */
338
- function parseStateNotationInner(notation, value) {
339
- const tokens = replaceCommasOutsideParens(notation).match(STATES_REGEXP);
340
- if (!tokens || !tokens.length) return {
341
- model: void 0,
342
- mods: [],
343
- notMods: [],
344
- tokens: [],
345
- value
346
- };
347
- else if (tokens.length === 1) return {
348
- model: tokens[0],
349
- mods: tokens.slice(0),
350
- notMods: [],
351
- tokens,
352
- value
353
- };
354
- const mods = [];
355
- const operations = [[]];
356
- let list = operations[0];
357
- let position = 0;
358
- let operation;
359
- tokens.forEach((token) => {
360
- switch (token) {
361
- case "(":
362
- operation = [];
363
- position++;
364
- list = operations[position] = operation;
365
- break;
366
- case ")":
367
- position--;
368
- operations[position].push(convertTokensToComputeUnits(list));
369
- list = operations[position];
370
- break;
371
- default:
372
- if (token.length > 1) {
373
- if (!mods.includes(token)) mods.push(token);
374
- }
375
- list.push(token);
376
- }
377
- });
378
- while (position) {
379
- position--;
380
- operations[position].push(convertTokensToComputeUnits(list));
381
- list = operations[position];
382
- }
383
- return {
384
- tokens,
385
- mods,
386
- notMods: [],
387
- model: convertTokensToComputeUnits(operations[0]),
388
- value
389
- };
390
- }
391
- const parseStateNotation = cacheWrapper(parseStateNotationInner);
392
- /**
393
- * Build an AtRuleContext from parsed advanced states
394
- */
395
- function buildAtRuleContext(advancedStates, negatedStates) {
396
- if (advancedStates.length === 0) return void 0;
397
- const ctx = {};
398
- for (const state of advancedStates) {
399
- const isNegated = negatedStates.has(state.raw);
400
- switch (state.type) {
401
- case "media": {
402
- if (!ctx.media) ctx.media = [];
403
- let mediaCondition = "";
404
- if (state.mediaType) mediaCondition = state.mediaType;
405
- else if (state.condition) mediaCondition = `(${state.condition})`;
406
- if (mediaCondition) if (isNegated) ctx.media.push(`not ${mediaCondition}`);
407
- else ctx.media.push(mediaCondition);
408
- break;
409
- }
410
- case "container": {
411
- if (!ctx.container) ctx.container = [];
412
- let condition = state.condition;
413
- if (isNegated) condition = `not (${condition})`;
414
- ctx.container.push({
415
- name: state.containerName,
416
- condition
417
- });
418
- break;
419
- }
420
- case "root": {
421
- if (!ctx.rootStates) ctx.rootStates = [];
422
- const rootSelector = buildRootSelector(state.condition, isNegated);
423
- ctx.rootStates.push(rootSelector);
424
- break;
425
- }
426
- case "starting":
427
- if (!isNegated) ctx.startingStyle = true;
428
- break;
429
- }
430
- }
431
- if (!ctx.media?.length && !ctx.container?.length && !ctx.rootStates?.length && !ctx.startingStyle) return;
432
- return ctx;
433
- }
434
- /**
435
- * Build a root state selector from a condition
436
- */
437
- function buildRootSelector(condition, isNegated) {
438
- let selector;
439
- if (condition.startsWith(".")) selector = condition;
440
- else if (condition.startsWith("[")) selector = condition;
441
- else if (condition.includes("=")) {
442
- const [key, value] = condition.split("=");
443
- selector = `[data-${camelToKebab(key.trim())}="${value.trim()}"]`;
444
- } else selector = `[data-${camelToKebab(condition)}]`;
445
- if (isNegated) return `:not(${selector})`;
446
- return selector;
447
- }
448
- /**
449
- * Parse state notation and return tokens, modifiers and compute model.
450
- * Enhanced to detect and extract advanced states.
451
- */
452
- function styleStateMapToStyleStateDataList(styleStateMap, parserContext) {
453
- if (typeof styleStateMap !== "object" || !styleStateMap) return {
454
- states: [{
455
- model: void 0,
456
- mods: [],
457
- notMods: [],
458
- value: styleStateMap
459
- }],
460
- mods: [],
461
- hasAdvancedStates: false
462
- };
463
- const stateDataList = [];
464
- let hasAdvancedStates = false;
465
- Object.keys(styleStateMap).forEach((stateNotation) => {
466
- const state = parseStateNotation(stateNotation, styleStateMap[stateNotation]);
467
- const advancedStates = [];
468
- const negatedAdvancedStates = /* @__PURE__ */ new Set();
469
- const regularMods = [];
470
- const ownMods = [];
471
- const negatedOwnMods = [];
472
- if (state.tokens) {
473
- let isNegated = false;
474
- for (const token of state.tokens) {
475
- if (token === "!") {
476
- isNegated = true;
477
- continue;
478
- }
479
- if (isAdvancedStateToken(token)) {
480
- hasAdvancedStates = true;
481
- const parsed = parseAdvancedState(token, parserContext || createStateParserContext(void 0));
482
- advancedStates.push(parsed);
483
- if (parsed.type === "own" && parsed.condition) if (isNegated) negatedOwnMods.push(parsed.condition);
484
- else ownMods.push(parsed.condition);
485
- else if (isNegated) negatedAdvancedStates.add(token);
486
- isNegated = false;
487
- } else if (token.length > 1 && ![
488
- "&",
489
- "|",
490
- "^",
491
- "(",
492
- ")"
493
- ].includes(token)) {
494
- regularMods.push(token);
495
- isNegated = false;
496
- } else isNegated = false;
497
- }
498
- }
499
- if (advancedStates.length > 0) {
500
- state.advancedStates = advancedStates;
501
- state.atRuleContext = buildAtRuleContext(advancedStates, negatedAdvancedStates);
502
- state.mods = regularMods;
503
- }
504
- if (ownMods.length > 0) state.ownMods = ownMods;
505
- if (negatedOwnMods.length > 0) state.negatedOwnMods = negatedOwnMods;
506
- stateDataList.push(state);
507
- });
508
- stateDataList.reverse();
509
- let initialState;
510
- const allMods = stateDataList.reduce((all, state) => {
511
- if (!state.mods.length && !state.advancedStates?.length) initialState = state;
512
- else state.mods.forEach((mod) => {
513
- if (!all.includes(mod)) all.push(mod);
514
- });
515
- return all;
516
- }, []);
517
- if (!initialState) stateDataList.push({
518
- mods: [],
519
- notMods: allMods,
520
- value: true
521
- });
522
- return {
523
- states: stateDataList,
524
- mods: allMods,
525
- hasAdvancedStates
526
- };
527
- }
528
- const COMPUTE_FUNC_MAP = {
529
- "!": (a) => !a,
530
- "^": (a, b) => a && !b || !a && b,
531
- "|": (a, b) => a || b,
532
- "&": (a, b) => a && b
533
- };
534
- /**
535
- * Compute a result based on a model and incoming map.
536
- */
537
- function computeState(computeModel, valueMap) {
538
- if (!computeModel) return true;
539
- if (!Array.isArray(computeModel)) if (typeof valueMap === "function") return !!valueMap(computeModel);
540
- else return !!valueMap[computeModel];
541
- const func = COMPUTE_FUNC_MAP[computeModel[0]];
542
- if (!func) console.warn("CubeUIKit: unexpected compute method in the model", computeModel);
543
- let a = computeModel[1];
544
- if (typeof a === "object") a = !!computeState(a, valueMap);
545
- else if (typeof valueMap === "function") a = !!valueMap(a);
546
- else a = !!valueMap[a];
547
- if (computeModel.length === 2) return func(a);
548
- let b = computeModel[2];
549
- if (typeof b === "object") b = !!computeState(b, valueMap);
550
- else if (typeof valueMap === "function") b = !!valueMap(b);
551
- else b = !!valueMap[b];
552
- return !!func(a, b);
553
- }
554
182
  const _innerCache = /* @__PURE__ */ new WeakMap();
183
+ const _topLevelCache = /* @__PURE__ */ new WeakMap();
555
184
  function stringifyStyles(styles) {
556
185
  if (styles == null || typeof styles !== "object") return "";
557
- const keys = Object.keys(styles).sort();
186
+ const cached = _topLevelCache.get(styles);
187
+ if (cached !== void 0) return cached;
188
+ const obj = styles;
189
+ const keys = Object.keys(obj).sort();
558
190
  const parts = [];
559
191
  for (const k of keys) {
560
- const v = styles[k];
192
+ const v = obj[k];
561
193
  if (v === void 0 || typeof v === "function" || typeof v === "symbol") continue;
562
194
  const c0 = k.charCodeAt(0);
563
195
  const needsInnerSort = (c0 >= 65 && c0 <= 90 || c0 === 38) && v && typeof v === "object" && !Array.isArray(v);
@@ -565,10 +197,11 @@ function stringifyStyles(styles) {
565
197
  if (needsInnerSort) {
566
198
  sv = _innerCache.get(v);
567
199
  if (sv === void 0) {
568
- const innerKeys = Object.keys(v).sort();
200
+ const innerObj = v;
201
+ const innerKeys = Object.keys(innerObj).sort();
569
202
  const innerParts = [];
570
203
  for (const ik of innerKeys) {
571
- const ivs = JSON.stringify(v[ik]);
204
+ const ivs = JSON.stringify(innerObj[ik]);
572
205
  if (ivs !== void 0) innerParts.push(JSON.stringify(ik) + ":" + ivs);
573
206
  }
574
207
  sv = "{" + innerParts.join(",") + "}";
@@ -577,9 +210,11 @@ function stringifyStyles(styles) {
577
210
  } else sv = JSON.stringify(v);
578
211
  parts.push(JSON.stringify(k) + ":" + sv);
579
212
  }
580
- return "{" + parts.join(",") + "}";
213
+ const result = "{" + parts.join(",") + "}";
214
+ _topLevelCache.set(styles, result);
215
+ return result;
581
216
  }
582
-
583
217
  //#endregion
584
- export { COMPUTE_FUNC_MAP, CUSTOM_UNITS, DIRECTIONS, STATE_OPERATORS, STATE_OPERATOR_LIST, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getModSelector, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList };
218
+ export { CUSTOM_UNITS, DIRECTIONS, customFunc, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, normalizeColorTokenValue, parseColor, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, stringifyStyles };
219
+
585
220
  //# sourceMappingURL=styles.js.map