@tenphi/tasty 2.0.2 → 2.0.4

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 (321) hide show
  1. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
  2. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  3. package/dist/{ssr/collector.d.ts → collector-CkZ517g4.d.ts} +3 -3
  4. package/dist/{ssr/collector.js → collector-DXqvGOb1.js} +5 -10
  5. package/dist/collector-DXqvGOb1.js.map +1 -0
  6. package/dist/config-5jzS6k6B.js +10005 -0
  7. package/dist/config-5jzS6k6B.js.map +1 -0
  8. package/dist/config-DknGsfMo.d.ts +857 -0
  9. package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
  10. package/dist/context-CkSg-kDT.js.map +1 -0
  11. package/dist/core/index.d.ts +5 -34
  12. package/dist/core/index.js +5 -26
  13. package/dist/core-CtU6-9OC.js +1507 -0
  14. package/dist/core-CtU6-9OC.js.map +1 -0
  15. package/dist/{zero/extractor.js → css-writer-DHkX0JuE.js} +74 -11
  16. package/dist/css-writer-DHkX0JuE.js.map +1 -0
  17. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  18. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  19. package/dist/format-rules-DH13ewDu.js +143 -0
  20. package/dist/format-rules-DH13ewDu.js.map +1 -0
  21. package/dist/{ssr/hydrate.js → hydrate-C1Gv-DoS.js} +3 -3
  22. package/dist/hydrate-C1Gv-DoS.js.map +1 -0
  23. package/dist/{styles/types.d.ts → index-PzENbpAq.d.ts} +701 -5
  24. package/dist/index-o7zV2yCr.d.ts +1561 -0
  25. package/dist/index.d.ts +5 -51
  26. package/dist/index.js +728 -35
  27. package/dist/index.js.map +1 -0
  28. package/dist/keyframes-b7X3UxDV.js +587 -0
  29. package/dist/keyframes-b7X3UxDV.js.map +1 -0
  30. package/dist/{utils/merge-styles.d.ts → merge-styles-C7KTy7MY.d.ts} +3 -3
  31. package/dist/{utils/merge-styles.js → merge-styles-Tgo3BbL2.js} +3 -4
  32. package/dist/merge-styles-Tgo3BbL2.js.map +1 -0
  33. package/dist/{utils/resolve-recipes.js → resolve-recipes-Ca2-5CxM.js} +4 -6
  34. package/dist/resolve-recipes-Ca2-5CxM.js.map +1 -0
  35. package/dist/ssr/astro-client.js +1 -1
  36. package/dist/ssr/astro.js +4 -4
  37. package/dist/ssr/index.d.ts +44 -4
  38. package/dist/ssr/index.js +4 -4
  39. package/dist/ssr/next.d.ts +1 -1
  40. package/dist/ssr/next.js +6 -6
  41. package/dist/ssr/next.js.map +1 -1
  42. package/dist/static/index.d.ts +91 -5
  43. package/dist/static/index.js +49 -3
  44. package/dist/static/index.js.map +1 -0
  45. package/dist/zero/babel.d.ts +1 -1
  46. package/dist/zero/babel.js +10 -6
  47. package/dist/zero/babel.js.map +1 -1
  48. package/dist/zero/index.d.ts +67 -3
  49. package/dist/zero/index.js +1 -2
  50. package/docs/pipeline.md +204 -50
  51. package/package.json +3 -3
  52. package/dist/_virtual/_rolldown/runtime.js +0 -7
  53. package/dist/chunks/cacheKey.d.ts +0 -1
  54. package/dist/chunks/cacheKey.js +0 -77
  55. package/dist/chunks/cacheKey.js.map +0 -1
  56. package/dist/chunks/definitions.d.ts +0 -37
  57. package/dist/chunks/definitions.js +0 -258
  58. package/dist/chunks/definitions.js.map +0 -1
  59. package/dist/chunks/index.d.ts +0 -1
  60. package/dist/chunks/renderChunk.d.ts +0 -1
  61. package/dist/chunks/renderChunk.js +0 -59
  62. package/dist/chunks/renderChunk.js.map +0 -1
  63. package/dist/compute-styles.d.ts +0 -31
  64. package/dist/compute-styles.js +0 -322
  65. package/dist/compute-styles.js.map +0 -1
  66. package/dist/config.d.ts +0 -407
  67. package/dist/config.js +0 -591
  68. package/dist/config.js.map +0 -1
  69. package/dist/counter-style/index.js +0 -51
  70. package/dist/counter-style/index.js.map +0 -1
  71. package/dist/debug.d.ts +0 -89
  72. package/dist/debug.js +0 -453
  73. package/dist/debug.js.map +0 -1
  74. package/dist/font-face/index.js +0 -63
  75. package/dist/font-face/index.js.map +0 -1
  76. package/dist/hooks/index.d.ts +0 -7
  77. package/dist/hooks/useCounterStyle.d.ts +0 -36
  78. package/dist/hooks/useCounterStyle.js +0 -65
  79. package/dist/hooks/useCounterStyle.js.map +0 -1
  80. package/dist/hooks/useFontFace.d.ts +0 -45
  81. package/dist/hooks/useFontFace.js +0 -66
  82. package/dist/hooks/useFontFace.js.map +0 -1
  83. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  84. package/dist/hooks/useGlobalStyles.js +0 -88
  85. package/dist/hooks/useGlobalStyles.js.map +0 -1
  86. package/dist/hooks/useKeyframes.d.ts +0 -58
  87. package/dist/hooks/useKeyframes.js +0 -55
  88. package/dist/hooks/useKeyframes.js.map +0 -1
  89. package/dist/hooks/useProperty.d.ts +0 -81
  90. package/dist/hooks/useProperty.js +0 -96
  91. package/dist/hooks/useProperty.js.map +0 -1
  92. package/dist/hooks/useRawCSS.d.ts +0 -22
  93. package/dist/hooks/useRawCSS.js +0 -103
  94. package/dist/hooks/useRawCSS.js.map +0 -1
  95. package/dist/hooks/useStyles.d.ts +0 -40
  96. package/dist/hooks/useStyles.js +0 -31
  97. package/dist/hooks/useStyles.js.map +0 -1
  98. package/dist/injector/index.d.ts +0 -182
  99. package/dist/injector/index.js +0 -185
  100. package/dist/injector/index.js.map +0 -1
  101. package/dist/injector/injector.d.ts +0 -198
  102. package/dist/injector/injector.js +0 -651
  103. package/dist/injector/injector.js.map +0 -1
  104. package/dist/injector/sheet-manager.d.ts +0 -132
  105. package/dist/injector/sheet-manager.js +0 -699
  106. package/dist/injector/sheet-manager.js.map +0 -1
  107. package/dist/injector/types.d.ts +0 -235
  108. package/dist/keyframes/index.js +0 -206
  109. package/dist/keyframes/index.js.map +0 -1
  110. package/dist/parser/classify.js +0 -319
  111. package/dist/parser/classify.js.map +0 -1
  112. package/dist/parser/const.js +0 -60
  113. package/dist/parser/const.js.map +0 -1
  114. package/dist/parser/lru.js +0 -109
  115. package/dist/parser/lru.js.map +0 -1
  116. package/dist/parser/parser.d.ts +0 -25
  117. package/dist/parser/parser.js +0 -115
  118. package/dist/parser/parser.js.map +0 -1
  119. package/dist/parser/tokenizer.js +0 -69
  120. package/dist/parser/tokenizer.js.map +0 -1
  121. package/dist/parser/types.d.ts +0 -51
  122. package/dist/parser/types.js +0 -46
  123. package/dist/parser/types.js.map +0 -1
  124. package/dist/pipeline/conditions.d.ts +0 -134
  125. package/dist/pipeline/conditions.js +0 -406
  126. package/dist/pipeline/conditions.js.map +0 -1
  127. package/dist/pipeline/exclusive.js +0 -382
  128. package/dist/pipeline/exclusive.js.map +0 -1
  129. package/dist/pipeline/index.d.ts +0 -55
  130. package/dist/pipeline/index.js +0 -708
  131. package/dist/pipeline/index.js.map +0 -1
  132. package/dist/pipeline/materialize.js +0 -1157
  133. package/dist/pipeline/materialize.js.map +0 -1
  134. package/dist/pipeline/parseStateKey.d.ts +0 -15
  135. package/dist/pipeline/parseStateKey.js +0 -446
  136. package/dist/pipeline/parseStateKey.js.map +0 -1
  137. package/dist/pipeline/simplify.js +0 -690
  138. package/dist/pipeline/simplify.js.map +0 -1
  139. package/dist/pipeline/warnings.js +0 -18
  140. package/dist/pipeline/warnings.js.map +0 -1
  141. package/dist/plugins/index.d.ts +0 -2
  142. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  143. package/dist/plugins/okhsl-plugin.js +0 -97
  144. package/dist/plugins/okhsl-plugin.js.map +0 -1
  145. package/dist/plugins/types.d.ts +0 -87
  146. package/dist/properties/index.js +0 -222
  147. package/dist/properties/index.js.map +0 -1
  148. package/dist/properties/property-type-resolver.d.ts +0 -24
  149. package/dist/properties/property-type-resolver.js +0 -90
  150. package/dist/properties/property-type-resolver.js.map +0 -1
  151. package/dist/rsc-cache.js +0 -79
  152. package/dist/rsc-cache.js.map +0 -1
  153. package/dist/ssr/async-storage.d.ts +0 -17
  154. package/dist/ssr/async-storage.js.map +0 -1
  155. package/dist/ssr/collect-auto-properties.js +0 -58
  156. package/dist/ssr/collect-auto-properties.js.map +0 -1
  157. package/dist/ssr/collector.js.map +0 -1
  158. package/dist/ssr/context.js.map +0 -1
  159. package/dist/ssr/format-global-rules.js.map +0 -1
  160. package/dist/ssr/format-keyframes.js +0 -69
  161. package/dist/ssr/format-keyframes.js.map +0 -1
  162. package/dist/ssr/format-property.js +0 -49
  163. package/dist/ssr/format-property.js.map +0 -1
  164. package/dist/ssr/format-rules.js +0 -73
  165. package/dist/ssr/format-rules.js.map +0 -1
  166. package/dist/ssr/hydrate.d.ts +0 -29
  167. package/dist/ssr/hydrate.js.map +0 -1
  168. package/dist/ssr/ssr-collector-ref.js +0 -29
  169. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  170. package/dist/states/index.d.ts +0 -49
  171. package/dist/states/index.js +0 -170
  172. package/dist/states/index.js.map +0 -1
  173. package/dist/static/tastyStatic.d.ts +0 -46
  174. package/dist/static/tastyStatic.js +0 -30
  175. package/dist/static/tastyStatic.js.map +0 -1
  176. package/dist/static/types.d.ts +0 -49
  177. package/dist/static/types.js +0 -24
  178. package/dist/static/types.js.map +0 -1
  179. package/dist/styles/border.d.ts +0 -25
  180. package/dist/styles/border.js +0 -120
  181. package/dist/styles/border.js.map +0 -1
  182. package/dist/styles/color.d.ts +0 -14
  183. package/dist/styles/color.js +0 -26
  184. package/dist/styles/color.js.map +0 -1
  185. package/dist/styles/const.js +0 -17
  186. package/dist/styles/const.js.map +0 -1
  187. package/dist/styles/createStyle.js +0 -79
  188. package/dist/styles/createStyle.js.map +0 -1
  189. package/dist/styles/dimension.js +0 -109
  190. package/dist/styles/dimension.js.map +0 -1
  191. package/dist/styles/directional.js +0 -133
  192. package/dist/styles/directional.js.map +0 -1
  193. package/dist/styles/display.d.ts +0 -30
  194. package/dist/styles/display.js +0 -73
  195. package/dist/styles/display.js.map +0 -1
  196. package/dist/styles/fade.d.ts +0 -15
  197. package/dist/styles/fade.js +0 -62
  198. package/dist/styles/fade.js.map +0 -1
  199. package/dist/styles/fill.d.ts +0 -42
  200. package/dist/styles/fill.js +0 -51
  201. package/dist/styles/fill.js.map +0 -1
  202. package/dist/styles/flow.d.ts +0 -16
  203. package/dist/styles/flow.js +0 -12
  204. package/dist/styles/flow.js.map +0 -1
  205. package/dist/styles/gap.d.ts +0 -31
  206. package/dist/styles/gap.js +0 -38
  207. package/dist/styles/gap.js.map +0 -1
  208. package/dist/styles/height.d.ts +0 -17
  209. package/dist/styles/height.js +0 -19
  210. package/dist/styles/height.js.map +0 -1
  211. package/dist/styles/index.d.ts +0 -1
  212. package/dist/styles/index.js +0 -8
  213. package/dist/styles/index.js.map +0 -1
  214. package/dist/styles/inset.d.ts +0 -24
  215. package/dist/styles/inset.js +0 -34
  216. package/dist/styles/inset.js.map +0 -1
  217. package/dist/styles/list.d.ts +0 -16
  218. package/dist/styles/list.js +0 -100
  219. package/dist/styles/list.js.map +0 -1
  220. package/dist/styles/margin.d.ts +0 -24
  221. package/dist/styles/margin.js +0 -32
  222. package/dist/styles/margin.js.map +0 -1
  223. package/dist/styles/outline.d.ts +0 -29
  224. package/dist/styles/outline.js +0 -55
  225. package/dist/styles/outline.js.map +0 -1
  226. package/dist/styles/padding.d.ts +0 -24
  227. package/dist/styles/padding.js +0 -32
  228. package/dist/styles/padding.js.map +0 -1
  229. package/dist/styles/placement.d.ts +0 -37
  230. package/dist/styles/placement.js +0 -74
  231. package/dist/styles/placement.js.map +0 -1
  232. package/dist/styles/predefined.d.ts +0 -71
  233. package/dist/styles/predefined.js +0 -237
  234. package/dist/styles/predefined.js.map +0 -1
  235. package/dist/styles/preset.d.ts +0 -52
  236. package/dist/styles/preset.js +0 -127
  237. package/dist/styles/preset.js.map +0 -1
  238. package/dist/styles/radius.d.ts +0 -12
  239. package/dist/styles/radius.js +0 -83
  240. package/dist/styles/radius.js.map +0 -1
  241. package/dist/styles/scrollMargin.d.ts +0 -24
  242. package/dist/styles/scrollMargin.js +0 -32
  243. package/dist/styles/scrollMargin.js.map +0 -1
  244. package/dist/styles/scrollbar.d.ts +0 -25
  245. package/dist/styles/scrollbar.js +0 -51
  246. package/dist/styles/scrollbar.js.map +0 -1
  247. package/dist/styles/shadow.d.ts +0 -14
  248. package/dist/styles/shadow.js +0 -25
  249. package/dist/styles/shadow.js.map +0 -1
  250. package/dist/styles/shared.js +0 -17
  251. package/dist/styles/shared.js.map +0 -1
  252. package/dist/styles/transition.d.ts +0 -14
  253. package/dist/styles/transition.js +0 -159
  254. package/dist/styles/transition.js.map +0 -1
  255. package/dist/styles/width.d.ts +0 -17
  256. package/dist/styles/width.js +0 -19
  257. package/dist/styles/width.js.map +0 -1
  258. package/dist/tasty.d.ts +0 -134
  259. package/dist/tasty.js +0 -248
  260. package/dist/tasty.js.map +0 -1
  261. package/dist/types.d.ts +0 -184
  262. package/dist/utils/cache-wrapper.js +0 -21
  263. package/dist/utils/cache-wrapper.js.map +0 -1
  264. package/dist/utils/case-converter.js +0 -8
  265. package/dist/utils/case-converter.js.map +0 -1
  266. package/dist/utils/color-math.d.ts +0 -46
  267. package/dist/utils/color-math.js +0 -749
  268. package/dist/utils/color-math.js.map +0 -1
  269. package/dist/utils/color-space.d.ts +0 -5
  270. package/dist/utils/color-space.js +0 -228
  271. package/dist/utils/color-space.js.map +0 -1
  272. package/dist/utils/colors.d.ts +0 -5
  273. package/dist/utils/colors.js +0 -10
  274. package/dist/utils/colors.js.map +0 -1
  275. package/dist/utils/css-types.d.ts +0 -7
  276. package/dist/utils/deps-equal.js +0 -15
  277. package/dist/utils/deps-equal.js.map +0 -1
  278. package/dist/utils/dotize.d.ts +0 -26
  279. package/dist/utils/dotize.js +0 -122
  280. package/dist/utils/dotize.js.map +0 -1
  281. package/dist/utils/filter-base-props.d.ts +0 -15
  282. package/dist/utils/filter-base-props.js +0 -45
  283. package/dist/utils/filter-base-props.js.map +0 -1
  284. package/dist/utils/get-display-name.d.ts +0 -7
  285. package/dist/utils/get-display-name.js +0 -10
  286. package/dist/utils/get-display-name.js.map +0 -1
  287. package/dist/utils/has-keys.js +0 -13
  288. package/dist/utils/has-keys.js.map +0 -1
  289. package/dist/utils/hash.js +0 -14
  290. package/dist/utils/hash.js.map +0 -1
  291. package/dist/utils/is-dev-env.js +0 -19
  292. package/dist/utils/is-dev-env.js.map +0 -1
  293. package/dist/utils/is-valid-element-type.js +0 -15
  294. package/dist/utils/is-valid-element-type.js.map +0 -1
  295. package/dist/utils/merge-styles.js.map +0 -1
  296. package/dist/utils/mod-attrs.d.ts +0 -6
  297. package/dist/utils/mod-attrs.js +0 -20
  298. package/dist/utils/mod-attrs.js.map +0 -1
  299. package/dist/utils/process-tokens.d.ts +0 -17
  300. package/dist/utils/process-tokens.js +0 -83
  301. package/dist/utils/process-tokens.js.map +0 -1
  302. package/dist/utils/resolve-recipes.d.ts +0 -17
  303. package/dist/utils/resolve-recipes.js.map +0 -1
  304. package/dist/utils/selector-transform.js +0 -32
  305. package/dist/utils/selector-transform.js.map +0 -1
  306. package/dist/utils/string.js +0 -8
  307. package/dist/utils/string.js.map +0 -1
  308. package/dist/utils/styles.d.ts +0 -99
  309. package/dist/utils/styles.js +0 -220
  310. package/dist/utils/styles.js.map +0 -1
  311. package/dist/utils/typography.d.ts +0 -58
  312. package/dist/utils/typography.js +0 -51
  313. package/dist/utils/typography.js.map +0 -1
  314. package/dist/utils/warnings.d.ts +0 -16
  315. package/dist/utils/warnings.js +0 -16
  316. package/dist/utils/warnings.js.map +0 -1
  317. package/dist/zero/css-writer.d.ts +0 -45
  318. package/dist/zero/css-writer.js +0 -73
  319. package/dist/zero/css-writer.js.map +0 -1
  320. package/dist/zero/extractor.d.ts +0 -24
  321. package/dist/zero/extractor.js.map +0 -1
@@ -1,708 +0,0 @@
1
- import { Lru } from "../parser/lru.js";
2
- import { stringifyStyles } from "../utils/styles.js";
3
- import { createStyle } from "../styles/createStyle.js";
4
- import { STYLE_HANDLER_MAP } from "../styles/index.js";
5
- import { createStateParserContext, extractLocalPredefinedStates } from "../states/index.js";
6
- import { and, or, trueCondition } from "./conditions.js";
7
- import { simplifyCondition } from "./simplify.js";
8
- import { buildExclusiveConditions, expandExclusiveOrs, expandOrConditions, extractCompoundStates, isValueMapping, mergeEntriesByValue, parseStyleEntries } from "./exclusive.js";
9
- import { branchToCSS, buildAtRulesFromVariant, conditionToCSS, mergeVariantsIntoSelectorGroups, optimizeGroups, parentGroupsToCSS, rootGroupsToCSS, selectorGroupToCSS } from "./materialize.js";
10
- import { emitWarning } from "./warnings.js";
11
- import { parseStateKey } from "./parseStateKey.js";
12
- //#region src/pipeline/index.ts
13
- /**
14
- * Tasty Style Rendering Pipeline
15
- *
16
- * This is the main entrypoint for the new pipeline implementation.
17
- * It implements the complete flow from style objects to CSS rules.
18
- *
19
- * Pipeline stages:
20
- * 1. PARSE CONDITIONS - Parse state keys into ConditionNode trees
21
- * 2. BUILD EXCLUSIVE CONDITIONS - AND with negation of higher-priority conditions
22
- * 3. SIMPLIFY CONDITIONS - Apply boolean algebra, detect contradictions
23
- * 4. GROUP BY HANDLER - Collect styles per handler, compute combinations
24
- * 5. COMPUTE CSS VALUES - Call handlers to get CSS declarations
25
- * 6. MERGE BY VALUE - Merge rules with identical CSS output
26
- * 7. MATERIALIZE CSS - Convert conditions to CSS selectors + at-rules
27
- */
28
- const pipelineCache = new Lru(5e3);
29
- /**
30
- * Check if a cache key exists in the pipeline cache.
31
- * Used by renderStylesForChunk to avoid building filtered styles on cache hit.
32
- */
33
- function hasPipelineCacheEntry(cacheKey) {
34
- return pipelineCache.get(cacheKey) !== void 0;
35
- }
36
- /**
37
- * Clear the pipeline cache (for testing)
38
- */
39
- function clearPipelineCache() {
40
- pipelineCache.clear();
41
- }
42
- function runPipeline(styles, parserContext) {
43
- const allRules = [];
44
- processStyles(styles, "", parserContext, allRules);
45
- const seen = /* @__PURE__ */ new Set();
46
- const dedupedRules = allRules.filter((rule) => {
47
- const key = `${rule.selector}|${rule.declarations}|${rule.atRules?.join("|") ?? ""}|${rule.rootPrefix || ""}|${rule.startingStyle ? "1" : "0"}`;
48
- if (seen.has(key)) return false;
49
- seen.add(key);
50
- return true;
51
- });
52
- const normal = [];
53
- const starting = [];
54
- for (const rule of dedupedRules) if (rule.startingStyle) starting.push(rule);
55
- else normal.push(rule);
56
- return normal.concat(starting);
57
- }
58
- /**
59
- * Process styles at a given nesting level
60
- */
61
- function processStyles(styles, selectorSuffix, parserContext, allRules) {
62
- const keys = Object.keys(styles);
63
- const selectorKeys = keys.filter((key) => isSelector(key));
64
- const styleKeys = keys.filter((key) => !isSelector(key) && !key.startsWith("@"));
65
- for (const key of selectorKeys) {
66
- const nestedStyles = styles[key];
67
- if (!nestedStyles || typeof nestedStyles !== "object") continue;
68
- const suffixes = getAllSelectors(key, nestedStyles);
69
- if (!suffixes) continue;
70
- const { $: _$, ...cleanedStyles } = nestedStyles;
71
- const subLocalStates = extractLocalPredefinedStates(cleanedStyles);
72
- const hasSubStates = Object.keys(subLocalStates).length > 0;
73
- const subContext = {
74
- ...parserContext,
75
- isSubElement: true,
76
- localPredefinedStates: hasSubStates ? {
77
- ...parserContext.localPredefinedStates,
78
- ...subLocalStates
79
- } : parserContext.localPredefinedStates
80
- };
81
- for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
82
- }
83
- const handlerQueue = buildHandlerQueue(styleKeys, styles);
84
- for (const { handler, styleMap } of handlerQueue) {
85
- const lookupStyles = handler.__lookupStyles;
86
- const exclusiveByStyle = /* @__PURE__ */ new Map();
87
- for (const styleName of lookupStyles) {
88
- const value = styleMap[styleName];
89
- if (value === void 0) continue;
90
- if (isValueMapping(value)) {
91
- const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
92
- exclusiveByStyle.set(styleName, fullyExpanded);
93
- } else exclusiveByStyle.set(styleName, [{
94
- styleKey: styleName,
95
- stateKey: "",
96
- value,
97
- condition: trueCondition(),
98
- priority: 0,
99
- exclusiveCondition: trueCondition()
100
- }]);
101
- }
102
- const stateSnapshots = computeStateCombinations(exclusiveByStyle, lookupStyles);
103
- const computedRules = [];
104
- for (const snapshot of stateSnapshots) {
105
- const result = handler(snapshot.values);
106
- if (!result) continue;
107
- const results = Array.isArray(result) ? result : [result];
108
- for (const r of results) {
109
- if (!r || typeof r !== "object") continue;
110
- const { $, ...styleProps } = r;
111
- const declarations = {};
112
- for (const [prop, val] of Object.entries(styleProps)) if (val != null && val !== "") declarations[prop] = String(val);
113
- if (Object.keys(declarations).length === 0) continue;
114
- const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
115
- for (const suffix of suffixes) computedRules.push({
116
- condition: snapshot.condition,
117
- declarations,
118
- selectorSuffix: suffix
119
- });
120
- }
121
- }
122
- const mergedRules = mergeByValue(computedRules);
123
- for (const rule of mergedRules) {
124
- const cssRules = materializeComputedRule(rule);
125
- allRules.push(...cssRules);
126
- }
127
- }
128
- }
129
- /**
130
- * Check if a key is a CSS selector
131
- */
132
- function isSelector(key) {
133
- return key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key);
134
- }
135
- /**
136
- * Get all selector suffixes for a sub-element key.
137
- *
138
- * Handles three types of selector keys:
139
- * - `&` prefix: Raw selector suffix (e.g., `&:hover` → `:hover`)
140
- * - `.` prefix: Class selector (e.g., `.active` → ` .active`)
141
- * - Uppercase: Sub-element with optional `$` affix pattern
142
- *
143
- * @param key - The sub-element key (e.g., 'Label', '&:hover', '.active')
144
- * @param styles - The styles object, may contain `$` property for selector affix
145
- * @returns Array of selector suffixes, or null if invalid (with console warning)
146
- *
147
- * @example
148
- * getAllSelectors('Label', {})
149
- * // → [' [data-element="Label"]']
150
- *
151
- * getAllSelectors('Cell', { $: '>, >Body>' })
152
- * // → ['> [data-element="Cell"]', ' [data-element="Body"] > [data-element="Cell"]']
153
- */
154
- function getAllSelectors(key, styles) {
155
- if (key.startsWith("&")) return [key.slice(1)];
156
- if (key.startsWith(".")) return [` ${key}`];
157
- if (/^[A-Z]/.test(key)) {
158
- const affix = styles?.$;
159
- if (affix !== void 0) {
160
- const result = processAffix(String(affix), key);
161
- if (!result.valid) {
162
- emitWarning("INVALID_SELECTOR_AFFIX", result.reason);
163
- return null;
164
- }
165
- return result.selectors;
166
- }
167
- return [` [data-element="${key}"]`];
168
- }
169
- return null;
170
- }
171
- /**
172
- * Process selector affix pattern and return selector(s)
173
- *
174
- * Supports:
175
- * - Direct child: '>'
176
- * - Chained elements: '>Body>Row>'
177
- * - HTML tags (no key injection): 'h1', '>ul>li', 'button:hover'
178
- * - Universal selector: '*', 'h1 *'
179
- * - Pseudo-elements on root: '::before'
180
- * - Pseudo on sub-element: '@::before', '>@:hover'
181
- * - Classes: '.active', '>@.active'
182
- * - Multiple selectors: '>, >Body>'
183
- * - Sibling combinators (after element): '>Item+', '>Item~'
184
- */
185
- function processAffix(affix, key) {
186
- const trimmed = affix.trim();
187
- if (!trimmed) return {
188
- valid: true,
189
- selectors: [` [data-element="${key}"]`]
190
- };
191
- const patterns = trimmed.split(",").map((p) => p.trim());
192
- const selectors = [];
193
- for (const pattern of patterns) {
194
- const validation = validatePattern(pattern);
195
- if (!validation.valid) return validation;
196
- const selector = processSinglePattern(pattern, key);
197
- selectors.push(selector);
198
- }
199
- return {
200
- valid: true,
201
- selectors
202
- };
203
- }
204
- /**
205
- * Recognized token patterns for selector affix validation.
206
- *
207
- * These patterns are used to tokenize and validate `$` affix strings.
208
- * Order matters: more specific patterns must come first to avoid
209
- * partial matches (e.g., `::before` must match before `:` alone).
210
- *
211
- * Unrecognized tokens (like `#id`, `*`, or numbers) will cause validation to fail.
212
- */
213
- const VALID_TOKEN_PATTERNS = [
214
- /^[>+~]/,
215
- /^\*/,
216
- /^[A-Z][a-zA-Z0-9]*/,
217
- /^@/,
218
- /^::?[a-z][a-z0-9-]*(?:\([^)]*\))?/,
219
- /^\.[a-zA-Z_-][a-zA-Z0-9_-]*/,
220
- /^\[[^\]]+\]/,
221
- /^[a-z][a-z0-9-]*/,
222
- /^\s+/,
223
- /^&/
224
- ];
225
- /**
226
- * Scan a pattern for unrecognized tokens.
227
- *
228
- * Iterates through the pattern, consuming recognized tokens until
229
- * either the pattern is fully consumed (valid) or an unrecognized
230
- * character sequence is found (invalid).
231
- *
232
- * @param pattern - The selector pattern to validate
233
- * @returns The first unrecognized token found, or null if all tokens are valid
234
- *
235
- * @example
236
- * findUnrecognizedTokens('>Body>Row>') // → null (valid)
237
- * findUnrecognizedTokens('123') // → '123' (invalid)
238
- * findUnrecognizedTokens('#myId') // → '#' (invalid)
239
- */
240
- function findUnrecognizedTokens(pattern) {
241
- let remaining = pattern;
242
- while (remaining.length > 0) {
243
- let matched = false;
244
- for (const regex of VALID_TOKEN_PATTERNS) {
245
- const match = remaining.match(regex);
246
- if (match) {
247
- remaining = remaining.slice(match[0].length);
248
- matched = true;
249
- break;
250
- }
251
- }
252
- if (!matched) {
253
- const unrecognized = remaining.match(/^[^\s>+~@.:[\]A-Z]+/);
254
- return unrecognized ? unrecognized[0] : remaining[0];
255
- }
256
- }
257
- return null;
258
- }
259
- /**
260
- * Validate a selector pattern for structural correctness.
261
- *
262
- * Checks for:
263
- * 1. Out-of-scope selectors: Patterns starting with `+` or `~` target siblings
264
- * of the root element, which is outside the component's DOM scope.
265
- * 2. Consecutive combinators: Patterns like `>>` or `>+` are malformed CSS.
266
- * 3. Unrecognized tokens: Characters/sequences not matching valid CSS selectors.
267
- *
268
- * @param pattern - A single selector pattern (already split by comma)
269
- * @returns AffixResult indicating validity and error reason if invalid
270
- *
271
- * @example
272
- * validatePattern('>Body>Row>') // → { valid: true, selectors: [] }
273
- * validatePattern('+') // → { valid: false, reason: '...outside root scope...' }
274
- * validatePattern('>>') // → { valid: false, reason: '...consecutive combinators...' }
275
- */
276
- function validatePattern(pattern) {
277
- const trimmed = pattern.trim();
278
- if (/^[+~]/.test(trimmed)) return {
279
- valid: false,
280
- reason: `Selector affix "${pattern}" targets elements outside the root scope. Sibling selectors (+, ~) must be preceded by an element inside the root. Use ">Element+" or ">Element~" instead.`
281
- };
282
- if (/[>+~]{2,}/.test(trimmed.replace(/\s+/g, ""))) return {
283
- valid: false,
284
- reason: `Selector affix "${pattern}" contains consecutive combinators.`
285
- };
286
- const unrecognized = findUnrecognizedTokens(trimmed);
287
- if (unrecognized) return {
288
- valid: false,
289
- reason: `Selector affix "${pattern}" contains unrecognized token "${unrecognized}". Valid tokens: combinators (>, +, ~), element names (Uppercase), @ placeholder, pseudo (:hover, ::before), class (.name), attribute ([attr]).`
290
- };
291
- return {
292
- valid: true,
293
- selectors: []
294
- };
295
- }
296
- /**
297
- * Process a single selector pattern into a CSS selector suffix.
298
- *
299
- * This is the main transformation function that converts a `$` affix pattern
300
- * into a valid CSS selector suffix. It handles:
301
- *
302
- * 1. `@` placeholder replacement with `[data-element="key"]`
303
- * 2. Key injection based on pattern ending (see `shouldInjectKey`)
304
- * 3. Proper spacing for descendant vs direct child selectors
305
- *
306
- * @param pattern - A single validated selector pattern
307
- * @param key - The sub-element key to inject (e.g., 'Label', 'Cell')
308
- * @returns CSS selector suffix ready to append to the root selector
309
- *
310
- * @example
311
- * processSinglePattern('>', 'Row')
312
- * // → '> [data-element="Row"]'
313
- *
314
- * processSinglePattern('>Body>Row>', 'Cell')
315
- * // → '> [data-element="Body"] > [data-element="Row"] > [data-element="Cell"]'
316
- *
317
- * processSinglePattern('::before', 'Before')
318
- * // → '::before' (no key injection for pseudo on root)
319
- *
320
- * processSinglePattern('>@:hover', 'Item')
321
- * // → '> [data-element="Item"]:hover'
322
- */
323
- function processSinglePattern(pattern, key) {
324
- const normalized = pattern.replace(/^&/, "").trim();
325
- if (!normalized) return ` [data-element="${key}"]`;
326
- const startsWithPseudo = /^::?[a-z]/.test(normalized);
327
- let result = transformPattern(normalized);
328
- if (result.includes("@")) {
329
- result = result.replace(/@ (?=[.:])/g, "@");
330
- result = result.replace(/@/g, `[data-element="${key}"]`);
331
- if (!startsWithPseudo && !result.startsWith(" ")) result = " " + result;
332
- return result;
333
- }
334
- if (shouldInjectKey(normalized)) result = result + ` [data-element="${key}"]`;
335
- if (!startsWithPseudo && !result.startsWith(" ")) result = " " + result;
336
- return result;
337
- }
338
- /**
339
- * Transform a selector pattern by converting element names and normalizing spacing.
340
- *
341
- * This is a character-by-character tokenizer that:
342
- * - Converts uppercase names to `[data-element="Name"]` selectors
343
- * - Adds proper spacing around combinators (>, +, ~)
344
- * - Preserves lowercase tags, classes, pseudos, and attributes as-is
345
- * - Keeps @ placeholder for later replacement
346
- *
347
- * The tokenizer handles these token types in order:
348
- * 1. Whitespace (skipped)
349
- * 2. Combinators: >, +, ~ (add surrounding spaces)
350
- * 3. Universal selector: * (keep as-is with spacing)
351
- * 4. Uppercase names: Body, Row (convert to [data-element="..."])
352
- * 5. @ placeholder (keep for later replacement)
353
- * 6. Pseudo: :hover, ::before (attach to previous token)
354
- * 7. Tags: a, div, button (keep as-is with spacing)
355
- * 8. Classes: .active (attach to previous element/tag/placeholder)
356
- * 9. Attributes: [type="text"] (keep as-is)
357
- *
358
- * @param pattern - The raw selector pattern to transform
359
- * @returns Transformed pattern with proper CSS selector syntax
360
- *
361
- * @example
362
- * transformPattern('>Body>Row>')
363
- * // → '> [data-element="Body"] > [data-element="Row"] >'
364
- *
365
- * transformPattern('button.primary:hover')
366
- * // → 'button.primary:hover'
367
- */
368
- function transformPattern(pattern) {
369
- let result = "";
370
- let lastCh = "";
371
- let i = 0;
372
- while (i < pattern.length) {
373
- const char = pattern[i];
374
- if (/\s/.test(char)) {
375
- i++;
376
- continue;
377
- }
378
- if (/[>+~]/.test(char)) {
379
- if (result && lastCh !== " ") result += " ";
380
- result += char;
381
- lastCh = char;
382
- i++;
383
- continue;
384
- }
385
- if (char === "*") {
386
- if (result && lastCh !== " ") result += " ";
387
- result += "*";
388
- lastCh = "*";
389
- i++;
390
- continue;
391
- }
392
- if (/[A-Z]/.test(char)) {
393
- const nameStart = i;
394
- while (i < pattern.length && /[a-zA-Z0-9]/.test(pattern[i])) i++;
395
- if (result && lastCh !== " ") result += " ";
396
- const segment = `[data-element="${pattern.slice(nameStart, i)}"]`;
397
- result += segment;
398
- lastCh = "]";
399
- continue;
400
- }
401
- if (char === "@") {
402
- if (result && lastCh !== " ") result += " ";
403
- result += "@";
404
- lastCh = "@";
405
- i++;
406
- continue;
407
- }
408
- if (char === ":") {
409
- const pseudoStart = i;
410
- while (i < pattern.length && !/[\s>+~,@]/.test(pattern[i]) && !/[A-Z]/.test(pattern[i])) i++;
411
- const segment = pattern.slice(pseudoStart, i);
412
- result += segment;
413
- lastCh = segment[segment.length - 1] || lastCh;
414
- continue;
415
- }
416
- if (/[a-z]/.test(char)) {
417
- const tagStart = i;
418
- while (i < pattern.length && /[a-z0-9-]/.test(pattern[i])) i++;
419
- if (result && lastCh !== " ") result += " ";
420
- const segment = pattern.slice(tagStart, i);
421
- result += segment;
422
- lastCh = segment[segment.length - 1] || lastCh;
423
- continue;
424
- }
425
- if (char === ".") {
426
- const attachToLast = lastCh === "]" || lastCh === "@" || /[a-zA-Z0-9-]/.test(lastCh);
427
- if (result && !attachToLast && lastCh !== " ") result += " ";
428
- const clsStart = i;
429
- i++;
430
- while (i < pattern.length && /[a-zA-Z0-9_-]/.test(pattern[i])) i++;
431
- const segment = pattern.slice(clsStart, i);
432
- result += segment;
433
- lastCh = segment[segment.length - 1] || lastCh;
434
- continue;
435
- }
436
- if (char === "[") {
437
- const attachToLast = lastCh === "]" || lastCh === "@" || /[a-zA-Z0-9-]/.test(lastCh);
438
- if (result && !attachToLast && lastCh !== " ") result += " ";
439
- const attrStart = i;
440
- let depth = 0;
441
- while (i < pattern.length) {
442
- if (pattern[i] === "[") depth++;
443
- if (pattern[i] === "]") depth--;
444
- i++;
445
- if (depth === 0) break;
446
- }
447
- result += pattern.slice(attrStart, i);
448
- lastCh = "]";
449
- continue;
450
- }
451
- result += char;
452
- lastCh = char;
453
- i++;
454
- }
455
- return result;
456
- }
457
- /**
458
- * Determine if the sub-element key should be auto-injected based on pattern ending.
459
- *
460
- * Key injection rules (when no @ placeholder is present):
461
- *
462
- * | Pattern Ending | Inject Key? | Example | Result |
463
- * |----------------|-------------|---------|--------|
464
- * | Combinator (>, +, ~) | Yes | `'>Body>'` | `> [data-element="Body"] > [el]` |
465
- * | Uppercase element | Yes | `'>Body>Row'` | `> [el1] > [el2] [key]` |
466
- * | Lowercase tag | No | `'h1'` | ` h1` |
467
- * | Universal (*) | No | `'h1 *'` | ` h1 *` |
468
- * | Pseudo (:hover, ::before) | No | `'::before'` | `::before` |
469
- * | Class (.active) | No | `'.active'` | `.active` |
470
- * | Attribute ([type]) | No | `'[type="text"]'` | `[type="text"]` |
471
- *
472
- * @param pattern - The normalized pattern (after stripping &)
473
- * @returns true if key should be injected, false otherwise
474
- *
475
- * @example
476
- * shouldInjectKey('>') // → true (trailing combinator)
477
- * shouldInjectKey('>Body>Row') // → true (ends with element)
478
- * shouldInjectKey('h1') // → false (ends with tag)
479
- * shouldInjectKey('*') // → false (universal selector)
480
- * shouldInjectKey('::before') // → false (ends with pseudo)
481
- * shouldInjectKey('.active') // → false (ends with class)
482
- * shouldInjectKey('a:hover') // → false (ends with pseudo)
483
- * shouldInjectKey('button.primary') // → false (ends with class)
484
- */
485
- function shouldInjectKey(pattern) {
486
- const trimmed = pattern.trim();
487
- if (/[>+~]$/.test(trimmed)) return true;
488
- if (/(?:^|[\s>+~\]:])[A-Z][a-zA-Z0-9]*$/.test(trimmed)) return true;
489
- return false;
490
- }
491
- /**
492
- * Normalize selector suffix from $ property
493
- */
494
- function normalizeSelectorSuffix(suffix) {
495
- if (!suffix) return "";
496
- return suffix.startsWith("&") ? suffix.slice(1) : suffix;
497
- }
498
- /**
499
- * Build handler queue from style keys
500
- */
501
- function buildHandlerQueue(styleKeys, styles) {
502
- const queue = [];
503
- const seenHandlers = /* @__PURE__ */ new Set();
504
- for (const styleName of styleKeys) {
505
- let handlers = STYLE_HANDLER_MAP[styleName];
506
- if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
507
- for (const handler of handlers) {
508
- if (seenHandlers.has(handler)) continue;
509
- seenHandlers.add(handler);
510
- const lookupStyles = handler.__lookupStyles;
511
- const styleMap = {};
512
- for (const name of lookupStyles) {
513
- const val = styles[name];
514
- if (val !== void 0) styleMap[name] = val;
515
- }
516
- queue.push({
517
- handler,
518
- styleMap
519
- });
520
- }
521
- }
522
- return queue;
523
- }
524
- /**
525
- * Compute all valid state combinations for a handler's lookup styles
526
- */
527
- function computeStateCombinations(exclusiveByStyle, lookupStyles) {
528
- const combinations = cartesianProduct(lookupStyles.map((style) => exclusiveByStyle.get(style) || []));
529
- const snapshots = [];
530
- for (const combo of combinations) {
531
- const simplified = simplifyCondition(and(...combo.map((e) => e.exclusiveCondition)));
532
- if (simplified.kind === "false") continue;
533
- const values = {};
534
- for (const entry of combo) values[entry.styleKey] = entry.value;
535
- snapshots.push({
536
- condition: simplified,
537
- values
538
- });
539
- }
540
- return snapshots;
541
- }
542
- /**
543
- * Cartesian product of arrays
544
- */
545
- function cartesianProduct(arrays) {
546
- if (arrays.length === 0) return [[]];
547
- const nonEmpty = arrays.filter((a) => a.length > 0);
548
- if (nonEmpty.length === 0) return [[]];
549
- let result = [[]];
550
- for (const arr of nonEmpty) {
551
- const next = [];
552
- for (const combo of result) for (const item of arr) {
553
- const newCombo = new Array(combo.length + 1);
554
- for (let i = 0; i < combo.length; i++) newCombo[i] = combo[i];
555
- newCombo[combo.length] = item;
556
- next.push(newCombo);
557
- }
558
- result = next;
559
- }
560
- return result;
561
- }
562
- const declStringCache = /* @__PURE__ */ new WeakMap();
563
- function stringifyDeclarations(decl) {
564
- let cached = declStringCache.get(decl);
565
- if (cached === void 0) {
566
- cached = JSON.stringify(decl);
567
- declStringCache.set(decl, cached);
568
- }
569
- return cached;
570
- }
571
- /**
572
- * Merge rules with identical CSS output
573
- */
574
- function mergeByValue(rules) {
575
- const groups = /* @__PURE__ */ new Map();
576
- for (const rule of rules) {
577
- const key = `${rule.selectorSuffix}|${stringifyDeclarations(rule.declarations)}`;
578
- if (!groups.has(key)) groups.set(key, []);
579
- groups.get(key).push(rule);
580
- }
581
- const merged = [];
582
- for (const [, groupRules] of groups) if (groupRules.length === 1) merged.push(groupRules[0]);
583
- else {
584
- const mergedCondition = simplifyCondition(or(...groupRules.map((r) => r.condition)));
585
- merged.push({
586
- condition: mergedCondition,
587
- declarations: groupRules[0].declarations,
588
- selectorSuffix: groupRules[0].selectorSuffix
589
- });
590
- }
591
- return merged;
592
- }
593
- /**
594
- * Build selector fragment from a variant (without className prefix)
595
- */
596
- function buildSelectorFromVariant(variant, selectorSuffix) {
597
- let selector = "";
598
- selector += branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
599
- for (const group of variant.selectorGroups) selector += selectorGroupToCSS(group);
600
- if (variant.parentGroups.length > 0) selector += parentGroupsToCSS(variant.parentGroups);
601
- selector += selectorSuffix;
602
- const ownOptimized = optimizeGroups(variant.ownGroups);
603
- for (const group of ownOptimized) selector += selectorGroupToCSS(group);
604
- return selector;
605
- }
606
- /**
607
- * Materialize a computed rule to final CSS format
608
- *
609
- * Returns an array because OR conditions may generate multiple CSS rules
610
- * (when different branches have different at-rules)
611
- */
612
- function materializeComputedRule(rule) {
613
- const components = conditionToCSS(rule.condition);
614
- if (components.isImpossible || components.variants.length === 0) return [];
615
- const declarations = Object.entries(rule.declarations).map(([prop, value]) => `${prop}: ${value};`).join(" ");
616
- const getRootPrefixKey = (variant) => {
617
- return rootGroupsToCSS(variant.rootGroups) || "";
618
- };
619
- const byAtRules = /* @__PURE__ */ new Map();
620
- for (const variant of components.variants) {
621
- const atRules = buildAtRulesFromVariant(variant);
622
- const startingStyle = variant.startingStyle;
623
- const key = atRules.sort().join("|||") + "###" + getRootPrefixKey(variant) + "###" + (startingStyle ? "1" : "0");
624
- const group = byAtRules.get(key);
625
- if (group) group.variants.push(variant);
626
- else byAtRules.set(key, {
627
- variants: [variant],
628
- atRules,
629
- rootPrefix: rootGroupsToCSS(variant.rootGroups),
630
- startingStyle: startingStyle || void 0
631
- });
632
- }
633
- const rules = [];
634
- for (const [, group] of byAtRules) {
635
- const selectorFragments = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
636
- const cssRule = {
637
- selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
638
- declarations
639
- };
640
- if (group.atRules.length > 0) cssRule.atRules = group.atRules;
641
- if (group.rootPrefix) cssRule.rootPrefix = group.rootPrefix;
642
- if (group.startingStyle) cssRule.startingStyle = true;
643
- rules.push(cssRule);
644
- }
645
- return rules;
646
- }
647
- /**
648
- * Merge StyleResult entries that share the same selector and at-rules,
649
- * concatenating their declarations into a single rule.
650
- *
651
- * This reduces CSS output size when many style keys (e.g. design tokens)
652
- * resolve to the same selector/state combination.
653
- */
654
- function mergeStyleResults(results) {
655
- if (results.length <= 1) return results;
656
- const groups = /* @__PURE__ */ new Map();
657
- for (const result of results) {
658
- const key = `${result.atRules?.join("|") ?? ""}||${result.selector}||${result.startingStyle ? "1" : "0"}`;
659
- const existing = groups.get(key);
660
- if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${result.declarations}` : result.declarations;
661
- else groups.set(key, { ...result });
662
- }
663
- return Array.from(groups.values());
664
- }
665
- function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
666
- const directSelector = !!classNameOrSelector;
667
- let rules;
668
- if (pipelineCacheKey) rules = pipelineCache.get(pipelineCacheKey);
669
- if (!rules && !styles) return directSelector ? [] : { rules: [] };
670
- const cacheKey = pipelineCacheKey || stringifyStyles(styles);
671
- if (!rules) rules = pipelineCache.get(cacheKey);
672
- if (!rules) {
673
- rules = runPipeline(styles, createStateParserContext(styles));
674
- pipelineCache.set(cacheKey, rules);
675
- }
676
- if (directSelector) {
677
- const shouldDouble = options?.doubleSelector ?? false;
678
- return mergeStyleResults(rules.map((rule) => {
679
- const result = {
680
- selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).map((part) => {
681
- let sel = part ? `${classNameOrSelector}${part}` : classNameOrSelector;
682
- if (shouldDouble && sel.startsWith(".")) {
683
- const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
684
- if (classMatch) sel = classMatch[0] + sel;
685
- }
686
- if (rule.rootPrefix) sel = `${rule.rootPrefix} ${sel}`;
687
- return sel;
688
- }).join(", "),
689
- declarations: rule.declarations
690
- };
691
- if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
692
- if (rule.startingStyle) result.startingStyle = true;
693
- return result;
694
- }));
695
- }
696
- return { rules: rules.map((r) => ({
697
- selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
698
- declarations: r.declarations,
699
- atRules: r.atRules,
700
- needsClassName: true,
701
- rootPrefix: r.rootPrefix,
702
- startingStyle: r.startingStyle
703
- })) };
704
- }
705
- //#endregion
706
- export { clearPipelineCache, hasPipelineCacheEntry, isSelector, renderStyles };
707
-
708
- //# sourceMappingURL=index.js.map