@fluentic/style 0.1.0-beta.4 → 0.1.0-beta.6

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 (380) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +106 -31
  3. package/atomic/className.ts +29 -6
  4. package/atomic/debug/className/className.ts +10 -0
  5. package/atomic/rule.ts +6 -3
  6. package/atomic/utils/hash.ts +1 -65
  7. package/atomic/utils/selector.ts +14 -1
  8. package/builder/classname/class_name_builder.ts +68 -24
  9. package/builder/classname/fns.ts +2 -2
  10. package/builder/classname/types.ts +7 -0
  11. package/builder/data/const.ts +6 -0
  12. package/builder/data/create.ts +42 -0
  13. package/builder/data/data.ts +20 -1
  14. package/builder/data/index.ts +0 -1
  15. package/builder/data/is.ts +23 -0
  16. package/builder/data/merge/scope.ts +20 -19
  17. package/builder/data/merge/style.ts +70 -20
  18. package/builder/data/state.ts +16 -2
  19. package/builder/extract/index.ts +1 -0
  20. package/builder/extract/sheet.ts +26 -0
  21. package/builder/extract/utils.ts +2 -0
  22. package/builder/extract/withTokens.ts +2 -1
  23. package/builder/selector_override.noop.ts +11 -0
  24. package/builder/selector_override.ts +30 -0
  25. package/builder/selector_override_core.ts +66 -0
  26. package/builder/style_builder.ts +127 -3
  27. package/builder/style_data.ts +24 -0
  28. package/builder/style_fns.ts +24 -24
  29. package/builder/types/alias.ts +34 -6
  30. package/builder/types/fns.ts +13 -5
  31. package/builder/types/types.ts +32 -2
  32. package/builder/utils.ts +1 -0
  33. package/compiler/compiler/compiler.ts +88 -14
  34. package/compiler/compiler/constants.ts +6 -0
  35. package/compiler/compiler/index.ts +1 -0
  36. package/compiler/compiler/types.ts +2 -0
  37. package/compiler/cssProp.ts +21 -0
  38. package/compiler/index.ts +1 -0
  39. package/compiler/transform/cssProp/index.ts +1 -0
  40. package/compiler/transform/cssProp/plugin.ts +161 -0
  41. package/compiler/transform/debug/plugin.ts +6 -0
  42. package/compiler/transform/debug/transform.ts +2 -1
  43. package/compiler/transform/evaluator/evaluator.ts +33 -4
  44. package/compiler/transform/evaluator/tracer.ts +30 -2
  45. package/compiler/transform/extract/chain/chain.ts +660 -73
  46. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  47. package/compiler/transform/extract/chain/types.ts +1 -1
  48. package/compiler/transform/extract/plugin.ts +20 -4
  49. package/compiler/transform/extract/transform.ts +2 -1
  50. package/compiler/transform/extract/utils/replacement.ts +47 -2
  51. package/compiler/transform/extract/utils/state.ts +2 -0
  52. package/compiler/transform/index.ts +1 -0
  53. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  54. package/compiler/utils/constants.ts +8 -1
  55. package/compiler/utils/import_source.ts +17 -7
  56. package/compiler/utils/imports.ts +11 -1
  57. package/config/config/css.ts +1 -0
  58. package/css/index.ts +2 -0
  59. package/css/sheet.ts +119 -0
  60. package/css/styleTarget.ts +251 -0
  61. package/dist/adapter/preact.js +2 -0
  62. package/dist/adapter/react.js +2 -0
  63. package/dist/adapter/solid.js +2 -0
  64. package/dist/className-hiAsQ9V6.js +303 -0
  65. package/dist/className-hiAsQ9V6.js.map +1 -0
  66. package/dist/combine-D0AXSTn-.js +1279 -0
  67. package/dist/combine-D0AXSTn-.js.map +1 -0
  68. package/dist/compiler/index.mjs +2 -2
  69. package/dist/{compiler-CE0ZgkdH.mjs → compiler-CCvRlaq0.mjs} +1467 -534
  70. package/dist/compiler-CCvRlaq0.mjs.map +1 -0
  71. package/dist/config-B-KbXpIh.js +6 -0
  72. package/dist/{config-oKOjOTWi.js.map → config-B-KbXpIh.js.map} +1 -1
  73. package/dist/config-B-w6rOe0.js +35 -0
  74. package/dist/config-B-w6rOe0.js.map +1 -0
  75. package/dist/{config-lJNLh7eM.js → config-B1WtpYar.js} +2 -2
  76. package/dist/{config-lJNLh7eM.js.map → config-B1WtpYar.js.map} +1 -1
  77. package/dist/{config-CduqubI8.js → config-CCMwA9Gm.js} +3 -3
  78. package/dist/config-CCMwA9Gm.js.map +1 -0
  79. package/dist/config-DOWSNV8w.js +1 -0
  80. package/dist/createTransformElement-PCilcudP.js +34 -0
  81. package/dist/createTransformElement-PCilcudP.js.map +1 -0
  82. package/dist/css-DirG7Jwu.js +1280 -0
  83. package/dist/css-DirG7Jwu.js.map +1 -0
  84. package/dist/css-GtUPEO9U.js.map +1 -1
  85. package/dist/css-nmclCl2P.js +479 -0
  86. package/dist/css-nmclCl2P.js.map +1 -0
  87. package/dist/css-shX7_73D.js +3894 -0
  88. package/dist/css-shX7_73D.js.map +1 -0
  89. package/dist/css.js +2 -2
  90. package/dist/{data-D7NFt4JG.js → data-DUvixly5.js} +155 -61
  91. package/dist/data-DUvixly5.js.map +1 -0
  92. package/dist/{debug-Cvpo5cVu.js → debug-DJRCBKhM.js} +80 -5
  93. package/dist/debug-DJRCBKhM.js.map +1 -0
  94. package/dist/dev/rsc.js +5 -8
  95. package/dist/dev/rsc.js.map +1 -1
  96. package/dist/{dev-DdRWa6dJ.js → dev-Cwha8aAp.js} +4 -4
  97. package/dist/{dev-DdRWa6dJ.js.map → dev-Cwha8aAp.js.map} +1 -1
  98. package/dist/dev.js +1 -1
  99. package/dist/dialect/extracted/index.js +1 -1
  100. package/dist/dialect/index.js +1 -1
  101. package/dist/{elementMarker-ng0y3fN0.js → elementMarker-Cb46vtLU.js} +94 -8
  102. package/dist/elementMarker-Cb46vtLU.js.map +1 -0
  103. package/dist/entry/dev/adapter/preact.js +12 -0
  104. package/dist/entry/dev/adapter/preact.js.map +1 -0
  105. package/dist/entry/dev/adapter/react.js +12 -0
  106. package/dist/entry/dev/adapter/react.js.map +1 -0
  107. package/dist/entry/dev/adapter/solid.js +12 -0
  108. package/dist/entry/dev/adapter/solid.js.map +1 -0
  109. package/dist/entry/dev/css.js +3 -3
  110. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  111. package/dist/entry/dev/jsx-runtime.js +2 -2
  112. package/dist/entry/dev.js +10 -8
  113. package/dist/entry/prod/adapter/preact.js +12 -0
  114. package/dist/entry/prod/adapter/preact.js.map +1 -0
  115. package/dist/entry/prod/adapter/react.js +12 -0
  116. package/dist/entry/prod/adapter/react.js.map +1 -0
  117. package/dist/entry/prod/adapter/solid.js +12 -0
  118. package/dist/entry/prod/adapter/solid.js.map +1 -0
  119. package/dist/entry/prod/css.js +3 -3
  120. package/dist/entry/prod/extract.js +240 -3
  121. package/dist/entry/prod/extract.js.map +1 -0
  122. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  123. package/dist/entry/prod/jsx-runtime.js +2 -2
  124. package/dist/entry/prod/runtime.js +3 -5
  125. package/dist/entry/prod.js +84 -1229
  126. package/dist/entry/prod.js.map +1 -1
  127. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  128. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  129. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  130. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  131. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  132. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  133. package/dist/entry/rsc-dev/css.js +3 -3
  134. package/dist/entry/rsc-dev/dev.js +5 -10
  135. package/dist/entry/rsc-dev/dev.js.map +1 -1
  136. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  137. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  138. package/dist/entry/rsc-dev.js +252 -750
  139. package/dist/entry/rsc-dev.js.map +1 -1
  140. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  141. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  142. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  143. package/dist/entry/rsc-prod/css.js +9 -3
  144. package/dist/entry/rsc-prod/css.js.map +1 -0
  145. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  146. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  147. package/dist/entry/rsc-prod/runtime.js +3 -5
  148. package/dist/entry/rsc-prod.js +236 -11
  149. package/dist/entry/rsc-prod.js.map +1 -1
  150. package/dist/{styleStore-CajcAEPO.js → env-0Gu2Jh47.js} +1148 -162
  151. package/dist/env-0Gu2Jh47.js.map +1 -0
  152. package/dist/getClassName-CHZKhmde.js +45 -0
  153. package/dist/getClassName-CHZKhmde.js.map +1 -0
  154. package/dist/{utils-B_VhPBHH.js → getClassName-CHd0iCXp.js} +28 -65
  155. package/dist/getClassName-CHd0iCXp.js.map +1 -0
  156. package/dist/getClassName-a6p2uMFM.js +536 -0
  157. package/dist/getClassName-a6p2uMFM.js.map +1 -0
  158. package/dist/{getClassName-CrNVjAoJ.js → getClassName-aD9zqg9U.js} +31 -10
  159. package/dist/getClassName-aD9zqg9U.js.map +1 -0
  160. package/dist/global-Dg37z0lV.js +14 -0
  161. package/dist/global-Dg37z0lV.js.map +1 -0
  162. package/dist/{hash-BfeJDf5U.js → hash-Cr-LCWDt.js} +35 -38
  163. package/dist/hash-Cr-LCWDt.js.map +1 -0
  164. package/dist/index.js +7 -6
  165. package/dist/jsx/jsx-dev-runtime.js +2 -2
  166. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  167. package/dist/jsx/jsx-runtime.js +2 -2
  168. package/dist/jsx/jsx-runtime.server.js +1 -1
  169. package/dist/jsx-BMFC8_tA.js +39 -0
  170. package/dist/jsx-BMFC8_tA.js.map +1 -0
  171. package/dist/{jsx_dev_runtime-aAhNYDeS.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
  172. package/dist/{jsx_dev_runtime-aAhNYDeS.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
  173. package/dist/{jsx_runtime-D7Y5up6H.js → jsx_runtime-BgK90E2O.js} +2 -3
  174. package/dist/{jsx_runtime-D7Y5up6H.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
  175. package/dist/{jsx_runtime-C6i1bWlu.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
  176. package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
  177. package/dist/{loader-BmYS_Rju.mjs → loader-hNaefW-U.mjs} +13 -14
  178. package/dist/loader-hNaefW-U.mjs.map +1 -0
  179. package/dist/{misc-BIS_c7BJ.mjs → misc-1OS0aeY1.mjs} +4 -4
  180. package/dist/misc-1OS0aeY1.mjs.map +1 -0
  181. package/dist/{namedTokens-CN_yhhik.js → namedTokens-mgRfd9hs.js} +3 -3
  182. package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
  183. package/dist/plugin/farm/index.mjs +4 -3
  184. package/dist/plugin/farm/index.mjs.map +1 -1
  185. package/dist/plugin/nextjs/index.mjs +121 -17
  186. package/dist/plugin/nextjs/index.mjs.map +1 -1
  187. package/dist/plugin/nextjs/loader.mjs +4 -4
  188. package/dist/plugin/parcel/index.cjs +2 -0
  189. package/dist/plugin/parcel/index.mjs +3 -1
  190. package/dist/plugin/parcel/optimizer.cjs +1 -1
  191. package/dist/plugin/parcel/optimizer.mjs +2 -2
  192. package/dist/plugin/parcel/resolver.cjs +1 -1
  193. package/dist/plugin/parcel/resolver.mjs +2 -2
  194. package/dist/plugin/parcel/runtime.cjs +1 -1
  195. package/dist/plugin/parcel/runtime.mjs +1 -1
  196. package/dist/plugin/parcel/transformer.cjs +1 -1
  197. package/dist/plugin/parcel/transformer.mjs +2 -2
  198. package/dist/plugin/rspack/index.mjs +3 -2
  199. package/dist/plugin/rspack/index.mjs.map +1 -1
  200. package/dist/plugin/vite/index.mjs +6 -6
  201. package/dist/plugin/vite/index.mjs.map +1 -1
  202. package/dist/plugin/webpack/index.mjs +3 -2
  203. package/dist/plugin/webpack/loader.mjs +2 -2
  204. package/dist/presets/tailwind/index.js +26 -5
  205. package/dist/presets/tailwind/index.js.map +1 -1
  206. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  207. package/dist/presets-DSanixJV.js.map +1 -0
  208. package/dist/{registry-IaXmLQzA.mjs → registry-OA0niXJL.mjs} +2 -2
  209. package/dist/{registry-IaXmLQzA.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
  210. package/dist/resolveClassNameRuntime-BKXT1bmR.js +63 -0
  211. package/dist/resolveClassNameRuntime-BKXT1bmR.js.map +1 -0
  212. package/dist/{rules-CxVzovt-.js → rules-DgcCENkw.js} +583 -154
  213. package/dist/rules-DgcCENkw.js.map +1 -0
  214. package/dist/{combine-C9vjpKCs.js → scope-BSuRLice.js} +239 -150
  215. package/dist/scope-BSuRLice.js.map +1 -0
  216. package/dist/selector/index.js +1 -2
  217. package/dist/server.js +12 -9
  218. package/dist/server.js.map +1 -1
  219. package/dist/{shared-CaJuvw03.cjs → shared-Bc9RwNNj.cjs} +1473 -535
  220. package/dist/shared-Bc9RwNNj.cjs.map +1 -0
  221. package/dist/{shared-DdPTZ0O3.mjs → shared-COiLPdZ1.mjs} +4 -4
  222. package/dist/{shared-DdPTZ0O3.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
  223. package/dist/sheet-B87QCFWF.js +7 -0
  224. package/dist/{sheet-BWBzuy4D.js.map → sheet-B87QCFWF.js.map} +1 -1
  225. package/dist/{sidecar-B3oCK9vC.mjs → sidecar-ViZUL9B8.mjs} +3 -3
  226. package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
  227. package/dist/{styleStore-0fARJlZV.js → styleStore-BlC8Ax9f.js} +3 -4
  228. package/dist/{styleStore-0fARJlZV.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
  229. package/dist/styleStore-DHzH25A7.js +51 -0
  230. package/dist/styleStore-DHzH25A7.js.map +1 -0
  231. package/dist/{token-D-S-4_mN.js → token-CAQWMtan.js} +2 -2
  232. package/dist/{token-D-S-4_mN.js.map → token-CAQWMtan.js.map} +1 -1
  233. package/dist/{trace-CFnhyCVf.js → trace-D3yBmJad.js} +2 -2
  234. package/dist/{trace-CFnhyCVf.js.map → trace-D3yBmJad.js.map} +1 -1
  235. package/dist/{trace-ZtgeY-8s.js → trace-DdXWjgAD.js} +3 -3
  236. package/dist/{trace-ZtgeY-8s.js.map → trace-DdXWjgAD.js.map} +1 -1
  237. package/dist/{style-CGaJndOl.js → types-BhdAXX7z.js} +268 -89
  238. package/dist/types-BhdAXX7z.js.map +1 -0
  239. package/dist/utils-B6HVRX10.js +42 -0
  240. package/dist/utils-B6HVRX10.js.map +1 -0
  241. package/dist/{utils-B5Xqf1lV.mjs → utils-C7UalRKf.mjs} +41 -7
  242. package/dist/utils-C7UalRKf.mjs.map +1 -0
  243. package/dist/utils-CUl1BU40.js +72 -0
  244. package/dist/utils-CUl1BU40.js.map +1 -0
  245. package/dist/{utils-DzydRwYo.js → utils-Cd4wqN56.js} +142 -149
  246. package/dist/utils-Cd4wqN56.js.map +1 -0
  247. package/dist/{utils-DaAiEEIG.mjs → utils-DjxH0zc7.mjs} +3 -3
  248. package/dist/{utils-DaAiEEIG.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
  249. package/dist/utils-DxCpyV2E.js +62 -0
  250. package/dist/utils-DxCpyV2E.js.map +1 -0
  251. package/dist/utils.js +4 -4
  252. package/dist/utils.js.map +1 -1
  253. package/dist/value-CpJpQ00y.js +145 -0
  254. package/dist/value-CpJpQ00y.js.map +1 -0
  255. package/dist/{webpack-CHydnRXB.mjs → webpack-6et2ZVI6.mjs} +5 -5
  256. package/dist/webpack-6et2ZVI6.mjs.map +1 -0
  257. package/entry/dev/adapter/preact.ts +8 -0
  258. package/entry/dev/adapter/react.ts +8 -0
  259. package/entry/dev/adapter/solid.ts +8 -0
  260. package/entry/prod/adapter/preact.ts +8 -0
  261. package/entry/prod/adapter/react.ts +8 -0
  262. package/entry/prod/adapter/solid.ts +8 -0
  263. package/entry/rsc_dev/adapter/preact.ts +9 -0
  264. package/entry/rsc_dev/adapter/react.ts +9 -0
  265. package/entry/rsc_dev/adapter/solid.ts +9 -0
  266. package/entry/rsc_prod/adapter/preact.ts +1 -0
  267. package/entry/rsc_prod/adapter/react.ts +1 -0
  268. package/entry/rsc_prod/adapter/solid.ts +1 -0
  269. package/entry/shared/config_dev.ts +1 -1
  270. package/jsx/types/index.ts +3 -0
  271. package/jsx/types/preact.ts +14 -0
  272. package/jsx/{types.ts → types/react.ts} +2 -2
  273. package/jsx/types/solid.ts +32 -0
  274. package/package.json +98 -22
  275. package/plugin/bundler/farm/plugin.ts +2 -0
  276. package/plugin/bundler/parcel/plugin.ts +2 -0
  277. package/plugin/bundler/rspack/plugin.ts +1 -0
  278. package/plugin/bundler/vite/plugin.ts +3 -8
  279. package/plugin/bundler/vite/state.ts +2 -2
  280. package/plugin/bundler/webpack/plugin.ts +2 -1
  281. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  282. package/plugin/nextjs/plugin.ts +208 -15
  283. package/plugin/nextjs/types.ts +1 -2
  284. package/plugin/nextjs/utils.ts +50 -0
  285. package/plugin/utils/compiler.ts +2 -0
  286. package/plugin/utils/runtimeEntry.ts +2 -2
  287. package/presets/tailwind/classname/transform.ts +32 -1
  288. package/runtime/adapter/utils.ts +120 -0
  289. package/runtime/core/cache/combine.ts +33 -4
  290. package/runtime/core/cache/item.ts +31 -12
  291. package/runtime/core/cache/itemWithResolver.ts +44 -0
  292. package/runtime/core/cache/prop.ts +7 -6
  293. package/runtime/core/cache/result.ts +2 -2
  294. package/runtime/core/cache/stateItem.ts +16 -1
  295. package/runtime/core/combinedStyle.ts +4 -4
  296. package/runtime/extract/combineStyle.ts +179 -5
  297. package/runtime/extract/getClassName.ts +49 -6
  298. package/runtime/sheet/rule.ts +3 -10
  299. package/runtime/style/scope.ts +0 -24
  300. package/runtime/style/style.ts +179 -5
  301. package/runtime/types.ts +3 -3
  302. package/style/classname.ts +12 -6
  303. package/style/important.ts +19 -0
  304. package/style/index.ts +2 -0
  305. package/style/style.ts +16 -4
  306. package/style/types.ts +6 -4
  307. package/style/utils/expose.ts +4 -3
  308. package/style/weight.ts +21 -0
  309. package/dist/assert-BGdigdr5.js.map +0 -1
  310. package/dist/className-Do2Crx4b.js +0 -143
  311. package/dist/className-Do2Crx4b.js.map +0 -1
  312. package/dist/combine-C9vjpKCs.js.map +0 -1
  313. package/dist/combineStyle-DwAhsOmS.js +0 -26
  314. package/dist/combineStyle-DwAhsOmS.js.map +0 -1
  315. package/dist/compiler-CE0ZgkdH.mjs.map +0 -1
  316. package/dist/config-BE5D5x2N.js +0 -2
  317. package/dist/config-CduqubI8.js.map +0 -1
  318. package/dist/config-oKOjOTWi.js +0 -7
  319. package/dist/css-BewrRz3_.js +0 -243
  320. package/dist/css-BewrRz3_.js.map +0 -1
  321. package/dist/css-CiTI58yl.js +0 -1094
  322. package/dist/css-CiTI58yl.js.map +0 -1
  323. package/dist/css-Rc7ILf-3.js +0 -236
  324. package/dist/css-Rc7ILf-3.js.map +0 -1
  325. package/dist/cssIdent-BsyUXNNk.js +0 -38
  326. package/dist/cssIdent-BsyUXNNk.js.map +0 -1
  327. package/dist/cssVar-DGgQ2GIK.js +0 -92
  328. package/dist/cssVar-DGgQ2GIK.js.map +0 -1
  329. package/dist/css_extra-DYtS3g6Z.js +0 -8
  330. package/dist/css_extra-DYtS3g6Z.js.map +0 -1
  331. package/dist/data-D7NFt4JG.js.map +0 -1
  332. package/dist/debug-Cvpo5cVu.js.map +0 -1
  333. package/dist/dev-px0_6TNq.js +0 -81
  334. package/dist/dev-px0_6TNq.js.map +0 -1
  335. package/dist/elementMarker-ng0y3fN0.js.map +0 -1
  336. package/dist/extract-B-Vs88ME.js +0 -3
  337. package/dist/extract-CM8Fk2eK.js +0 -130
  338. package/dist/extract-CM8Fk2eK.js.map +0 -1
  339. package/dist/getClassName-CrNVjAoJ.js.map +0 -1
  340. package/dist/global-CZBlA9E7.js +0 -14
  341. package/dist/global-CZBlA9E7.js.map +0 -1
  342. package/dist/hash-BfeJDf5U.js.map +0 -1
  343. package/dist/jsx-BY1iFewe.js +0 -39
  344. package/dist/jsx-BY1iFewe.js.map +0 -1
  345. package/dist/jsx-DL-DEAz8.js +0 -39
  346. package/dist/jsx-DL-DEAz8.js.map +0 -1
  347. package/dist/layer-BSxAr-hy.js +0 -94
  348. package/dist/layer-BSxAr-hy.js.map +0 -1
  349. package/dist/loader-BmYS_Rju.mjs.map +0 -1
  350. package/dist/misc-BIS_c7BJ.mjs.map +0 -1
  351. package/dist/presets-BhXa232U.js +0 -108
  352. package/dist/presets-BhXa232U.js.map +0 -1
  353. package/dist/property-BuLbzviK.js +0 -406
  354. package/dist/property-BuLbzviK.js.map +0 -1
  355. package/dist/rules-CxVzovt-.js.map +0 -1
  356. package/dist/selector-A-mRmMnI.js +0 -64
  357. package/dist/selector-A-mRmMnI.js.map +0 -1
  358. package/dist/shared-CaJuvw03.cjs.map +0 -1
  359. package/dist/sheet-BWBzuy4D.js +0 -7
  360. package/dist/style-CGaJndOl.js.map +0 -1
  361. package/dist/style-DDxjKdX0.js +0 -1891
  362. package/dist/style-DDxjKdX0.js.map +0 -1
  363. package/dist/style-S7LTQbRu.js +0 -5
  364. package/dist/styleStore-CajcAEPO.js.map +0 -1
  365. package/dist/symbols-Cp4ymzKF.js +0 -14
  366. package/dist/symbols-Cp4ymzKF.js.map +0 -1
  367. package/dist/utils-B5Xqf1lV.mjs.map +0 -1
  368. package/dist/utils-B_VhPBHH.js.map +0 -1
  369. package/dist/utils-CDUaX81o.js +0 -170
  370. package/dist/utils-CDUaX81o.js.map +0 -1
  371. package/dist/utils-DzydRwYo.js.map +0 -1
  372. package/dist/value-C0JRsyax.js +0 -64
  373. package/dist/value-C0JRsyax.js.map +0 -1
  374. package/dist/value-D08AocUs.js +0 -1053
  375. package/dist/value-D08AocUs.js.map +0 -1
  376. package/dist/valueRef-M3E1oza7.js +0 -16
  377. package/dist/valueRef-M3E1oza7.js.map +0 -1
  378. package/dist/webpack-CHydnRXB.mjs.map +0 -1
  379. package/dist/withTokens-DAzUIPvA.js +0 -95
  380. package/dist/withTokens-DAzUIPvA.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { getAtomicClassName, getClassNameDedupe } from '../../../../atomic/className';
1
+ import { getAtomicClassName, getClassNameDedupe, getClassNameHashLength } from '../../../../atomic/className';
2
2
  import { LayerDefaultPriority } from '../../../../atomic/layer';
3
3
  import { buildAtomicRule, getAtomicRuleLayerPriority } from '../../../../atomic/rule';
4
4
  import { getTokenOverrideValue, getTokenVar, getTokenVarName } from '../../../../atomic/token';
@@ -34,8 +34,10 @@ import type {
34
34
  RuntimeSlotOverrideItem,
35
35
  RuntimeStyleItem,
36
36
  } from '../../../../builder/data/state';
37
+ import { normalizeManualSelectors } from '../../../../builder/selector_override';
37
38
  import type { ClassNameFormat, TokenNameFormat, TransformClassNameFormat } from '../../../../config/types';
38
39
  import type { Selector } from '../../../../selector/types';
40
+ import { importantValue, isStyleImportantValue } from '../../../../style/important';
39
41
  import type { StyleFnMeta } from '../../../../style/style';
40
42
  import {
41
43
  getStyleTokenId,
@@ -50,8 +52,9 @@ import {
50
52
  type StyleTransform,
51
53
  } from '../../../../style/transform';
52
54
  import { isAtRuleRef } from '../../../../style/valueRef';
55
+ import { isStyleWeightValue, weightValue } from '../../../../style/weight';
53
56
  import { hashString } from '../../../../utils/hash';
54
- import { CompilerRuntimeMode } from '../../../compiler';
57
+ import { CompilerRuntimeMode } from '../../../compiler/constants';
55
58
  import type { CompilerOptions } from '../../../compiler/types';
56
59
  import { DEFAULT_CONFIG } from '../../../utils/constants';
57
60
  import {
@@ -59,6 +62,7 @@ import {
59
62
  COMPILED_STYLE_OBJECT_LOCATIONS,
60
63
  type CompiledRuntimeValue,
61
64
  type CompiledStyleObject,
65
+ type CompiledStyleObjectLocations,
62
66
  type EvalScope,
63
67
  evaluateNode,
64
68
  } from '../../evaluator/evaluator';
@@ -83,6 +87,7 @@ type SelectorsMap = Record<string, Selector>;
83
87
 
84
88
  type CssConfig = {
85
89
  classNameFormat: ClassNameFormat | null;
90
+ sheetClassNameFormat: ClassNameFormat | null;
86
91
  transformClassNameFormat: TransformClassNameFormat | null;
87
92
  hashLength: number;
88
93
  tokenNameFormat: TokenNameFormat | null;
@@ -128,7 +133,8 @@ function transformRuntimeValues(
128
133
  let result: Record<string, unknown> | null = null;
129
134
 
130
135
  for (const [property, rawValue] of Object.entries(styleObj)) {
131
- const value = getPriorityTupleValue(rawValue);
136
+ const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
137
+ const value = weighted ? weighted.value : rawValue;
132
138
  const runtimeValue = getCompiledRuntimeValue(value);
133
139
  if (!runtimeValue) continue;
134
140
 
@@ -136,20 +142,13 @@ function transformRuntimeValues(
136
142
  if (transformedRuntimeValue === runtimeValue) continue;
137
143
 
138
144
  result ??= cloneCompiledStyleObject(styleObj);
139
- result[property] = Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === 'number'
140
- ? [rawValue[0], createCompiledRuntimeValue(transformedRuntimeValue)]
141
- : createCompiledRuntimeValue(transformedRuntimeValue);
145
+ const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
146
+ result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
142
147
  }
143
148
 
144
149
  return result ?? styleObj;
145
150
  }
146
151
 
147
- function getPriorityTupleValue(value: unknown) {
148
- return Array.isArray(value) && value.length === 2 && typeof value[0] === 'number'
149
- ? value[1]
150
- : value;
151
- }
152
-
153
152
  function cloneCompiledStyleObject(
154
153
  styleObj: Record<string, unknown>,
155
154
  ): Record<string, unknown> {
@@ -327,14 +326,20 @@ export function compileChain(
327
326
  scope: EvalScope,
328
327
  opts: CompilerOptions,
329
328
  runtimeMode: CompilerRuntimeMode | null,
330
- meta: StyleFnMeta,
329
+ meta: StyleFnMeta | null,
331
330
  styleNames: Set<string> = new Set(),
332
331
  ): CompiledChainData | null {
333
332
  const css = getCssConfig(opts, runtimeMode);
334
333
 
334
+ if (chain.kind === 'sheet') {
335
+ return compileSheetChain(chain, fileId, scope, css, opts);
336
+ }
337
+
338
+ if (!meta) return null;
339
+
335
340
  if (meta.mode === 'ClassName') {
336
341
  if (chain.kind !== 'style') return null;
337
- return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
342
+ return compileClassNameChain(chain, meta.selectors, fileId, nodeLoc, scope, css, meta.transform, styleNames, opts);
338
343
  }
339
344
 
340
345
  const selectors = meta.selectors;
@@ -356,20 +361,326 @@ export function compileChain(
356
361
  return null;
357
362
  }
358
363
 
364
+ function compileSheetChain(
365
+ chain: NonNullable<StyleChainParseResult>,
366
+ fileId: string,
367
+ scope: EvalScope,
368
+ cssConfig: CssConfig,
369
+ options: CompilerOptions,
370
+ ): CompiledChainData | null {
371
+ if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
372
+
373
+ const items: CompiledItem[] = [];
374
+ const rules: CssExtractRule[] = [];
375
+ const sheetItems = chain.baseArgs[0];
376
+
377
+ if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) {
378
+ return null;
379
+ }
380
+
381
+ return { type: 'sheet', items, rules };
382
+ }
383
+
384
+ function compileSheetItemsArg(
385
+ node: BabelTypes.Node,
386
+ fileId: string,
387
+ scope: EvalScope,
388
+ cssConfig: CssConfig,
389
+ options: CompilerOptions,
390
+ items: CompiledItem[],
391
+ rules: CssExtractRule[],
392
+ ): boolean {
393
+ if (node.type === 'ArrayExpression') {
394
+ for (const element of node.elements) {
395
+ if (!element) continue;
396
+ if (element.type === 'SpreadElement') return false;
397
+ if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
398
+ }
399
+
400
+ return true;
401
+ }
402
+
403
+ const tokenOverride = evaluateNode(node, scope);
404
+ if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
405
+ addCompiledTokenItem(
406
+ getStyleTokenId(tokenOverride.value),
407
+ tokenOverride.value,
408
+ getCompiledRuntimeValue(tokenOverride.value) ?? node as BabelTypes.Expression,
409
+ items,
410
+ );
411
+ return true;
412
+ }
413
+
414
+ if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
415
+ for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
416
+ const item = tokenOverride.value[i];
417
+ if (!item) continue;
418
+ if (!isStyleTokenOverrideData(item)) return false;
419
+
420
+ addCompiledTokenItem(
421
+ getStyleTokenId(item),
422
+ item,
423
+ getCompiledRuntimeValue(item) ?? null,
424
+ items,
425
+ );
426
+ }
427
+
428
+ return true;
429
+ }
430
+
431
+ const styleNames = scope.styleNames ?? new Set();
432
+ const sheetNames = scope.sheetNames ?? new Set();
433
+ const selectorChain = node.type === 'CallExpression'
434
+ ? extractStyleChain(node, styleNames, sheetNames) ??
435
+ getLocalSelectorTargetChain(node, scope, styleNames, sheetNames)
436
+ : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
437
+ const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
438
+
439
+ if (selectorChain?.kind !== 'selector' || !selectorMeta || selectorMeta.mode !== 'StyleObject') {
440
+ return false;
441
+ }
442
+
443
+ return compileSelectorOverrideChain(
444
+ selectorChain,
445
+ selectorMeta.selectors,
446
+ fileId,
447
+ scope,
448
+ cssConfig,
449
+ selectorMeta.transform,
450
+ scope.styleNames ?? new Set(),
451
+ options,
452
+ items,
453
+ rules,
454
+ );
455
+ }
456
+
457
+ function compileSelectorOverrideChain(
458
+ chain: NonNullable<StyleChainParseResult>,
459
+ selectors: SelectorsMap,
460
+ fileId: string,
461
+ scope: EvalScope,
462
+ cssConfig: CssConfig,
463
+ transform: StyleTransform | null,
464
+ styleNames: Set<string>,
465
+ options: CompilerOptions,
466
+ items: CompiledItem[],
467
+ rules: CssExtractRule[],
468
+ ): boolean {
469
+ if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
470
+
471
+ const selectorArg = evaluateNode(chain.baseArgs[0], scope);
472
+ if (!selectorArg.ok) return false;
473
+
474
+ const manualSelectors = normalizeManualSelectors(
475
+ Array.isArray(selectorArg.value)
476
+ ? selectorArg.value.map(String)
477
+ : String(selectorArg.value ?? ''),
478
+ );
479
+
480
+ for (let i = 0, len = manualSelectors.length; i < len; i++) {
481
+ if (
482
+ !compileSelectorOverrideInto(
483
+ chain,
484
+ selectors,
485
+ fileId,
486
+ scope,
487
+ cssConfig,
488
+ transform,
489
+ styleNames,
490
+ options,
491
+ items,
492
+ rules,
493
+ manualSelectors[i],
494
+ )
495
+ ) {
496
+ return false;
497
+ }
498
+ }
499
+
500
+ return true;
501
+ }
502
+
503
+ function compileSelectorOverrideInto(
504
+ chain: NonNullable<StyleChainParseResult>,
505
+ selectors: SelectorsMap,
506
+ fileId: string,
507
+ scope: EvalScope,
508
+ cssConfig: CssConfig,
509
+ transform: StyleTransform | null,
510
+ styleNames: Set<string>,
511
+ options: CompilerOptions,
512
+ items: CompiledItem[],
513
+ rules: CssExtractRule[],
514
+ selectorPrefix: ItemSelector,
515
+ ): boolean {
516
+ if (chain.baseArgs[1]) {
517
+ if (
518
+ !compileSelectorStyleArg(
519
+ chain.baseArgs[1],
520
+ fileId,
521
+ scope,
522
+ cssConfig,
523
+ transform,
524
+ items,
525
+ rules,
526
+ styleNames,
527
+ options,
528
+ selectorPrefix,
529
+ )
530
+ ) {
531
+ return false;
532
+ }
533
+ }
534
+
535
+ let i = 0;
536
+ while (i < chain.methods.length) {
537
+ const method = chain.methods[i];
538
+ if (
539
+ !compileChainMethod(
540
+ method,
541
+ selectors,
542
+ null,
543
+ fileId,
544
+ scope,
545
+ BUILDER_TYPE_STYLE,
546
+ cssConfig,
547
+ items,
548
+ rules,
549
+ transform,
550
+ null,
551
+ styleNames,
552
+ options,
553
+ null,
554
+ selectorPrefix,
555
+ )
556
+ ) {
557
+ return false;
558
+ }
559
+ i++;
560
+ }
561
+
562
+ return true;
563
+ }
564
+
565
+ function compileSelectorStyleArg(
566
+ styleArgNode: BabelTypes.Node,
567
+ fileId: string,
568
+ scope: EvalScope,
569
+ cssConfig: CssConfig,
570
+ transform: StyleTransform | null,
571
+ items: CompiledItem[],
572
+ rules: CssExtractRule[],
573
+ styleNames: Set<string>,
574
+ options: CompilerOptions,
575
+ selectorPrefix: ItemSelector,
576
+ ): boolean {
577
+ const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
578
+ const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
579
+
580
+ if (localChain?.kind === 'style' && localMeta) {
581
+ return compileStyleChainInto(
582
+ localChain,
583
+ localMeta.selectors,
584
+ fileId,
585
+ scope,
586
+ cssConfig,
587
+ localMeta.transform,
588
+ BUILDER_TYPE_STYLE,
589
+ null,
590
+ null,
591
+ items,
592
+ rules,
593
+ styleNames,
594
+ options,
595
+ null,
596
+ selectorPrefix,
597
+ );
598
+ }
599
+
600
+ if (styleArgNode.type === 'CallExpression') {
601
+ const nestedChain = extractStyleChain(styleArgNode, styleNames);
602
+ const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
603
+
604
+ if (nestedChain?.kind === 'style' && nestedMeta) {
605
+ return compileStyleChainInto(
606
+ nestedChain,
607
+ nestedMeta.selectors,
608
+ fileId,
609
+ scope,
610
+ cssConfig,
611
+ nestedMeta.transform,
612
+ BUILDER_TYPE_STYLE,
613
+ null,
614
+ null,
615
+ items,
616
+ rules,
617
+ styleNames,
618
+ options,
619
+ null,
620
+ selectorPrefix,
621
+ );
622
+ }
623
+ }
624
+
625
+ const styleArg = evaluateNode(styleArgNode, scope);
626
+ if (!styleArg.ok) {
627
+ throwIfRequiredStaticStyleValue(styleArg);
628
+ return false;
629
+ }
630
+
631
+ if (isStyleData(styleArg.value)) {
632
+ return addStyleDataItems(
633
+ styleArg.value,
634
+ selectorPrefix,
635
+ null,
636
+ null,
637
+ fileId,
638
+ BUILDER_TYPE_STYLE,
639
+ null,
640
+ items,
641
+ rules,
642
+ cssConfig,
643
+ null,
644
+ );
645
+ }
646
+
647
+ const styleObj = applyTransform(styleArg.value as Record<string, unknown>, transform, cssConfig);
648
+
649
+ return addStyleItems(
650
+ styleObj,
651
+ selectorPrefix,
652
+ null,
653
+ null,
654
+ fileId,
655
+ BUILDER_TYPE_STYLE,
656
+ null,
657
+ items,
658
+ rules,
659
+ cssConfig,
660
+ null,
661
+ );
662
+ }
663
+
359
664
  function getCssConfig(
360
665
  opts: CompilerOptions,
361
666
  runtimeMode: CompilerRuntimeMode | null,
362
667
  ): CssConfig {
363
668
  const css = opts.css as ExtractCssOptions | undefined;
364
669
  const isDevRuntimeMode = runtimeMode === CompilerRuntimeMode.Dev || runtimeMode === CompilerRuntimeMode.RscDev;
670
+ const debugClassName = css?.debugClassName ?? isDevRuntimeMode;
365
671
 
366
672
  return {
367
673
  classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
674
+ sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
368
675
  transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
369
- hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
676
+ hashLength: getClassNameHashLength({
677
+ debugClassName,
678
+ isDev: isDevRuntimeMode,
679
+ cssHashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength,
680
+ }),
370
681
  tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
371
682
  localClassName: isDevRuntimeMode,
372
- debugClassName: css?.debugClassName ?? isDevRuntimeMode,
683
+ debugClassName,
373
684
  scopeTargetPrefix: css?.scopeTargetPrefix ?? '',
374
685
  };
375
686
  }
@@ -426,6 +737,7 @@ function compileClassNameChain(
426
737
  chain: NonNullable<StyleChainParseResult>,
427
738
  selectors: SelectorsMap,
428
739
  fileId: string,
740
+ nodeLoc: { line: number; column: number; } | null | undefined,
429
741
  scope: EvalScope,
430
742
  cssConfig: CssConfig,
431
743
  transform: ClassNameTransform,
@@ -443,6 +755,7 @@ function compileClassNameChain(
443
755
  null,
444
756
  fileId,
445
757
  scope,
758
+ createClassNameFallbackLocation(nodeLoc, scope, fileId),
446
759
  cssConfig,
447
760
  transform,
448
761
  BUILDER_TYPE_STYLE,
@@ -503,6 +816,7 @@ function compileClassNameChainMethod(
503
816
  localChain,
504
817
  localMeta.selectors,
505
818
  fileId,
819
+ method.nameNode.loc?.start,
506
820
  scope,
507
821
  cssConfig,
508
822
  localMeta.transform,
@@ -555,6 +869,7 @@ function compileClassNameChainMethod(
555
869
  [atRuleSelector],
556
870
  fileId,
557
871
  scope,
872
+ createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId),
558
873
  cssConfig,
559
874
  transform,
560
875
  BUILDER_TYPE_STYLE,
@@ -589,6 +904,7 @@ function compileClassNameChainMethod(
589
904
  null,
590
905
  fileId,
591
906
  scope,
907
+ createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId),
592
908
  cssConfig,
593
909
  transform,
594
910
  BUILDER_TYPE_STYLE,
@@ -609,6 +925,7 @@ function compileClassNameChainMethod(
609
925
  null,
610
926
  fileId,
611
927
  scope,
928
+ createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId),
612
929
  cssConfig,
613
930
  transform,
614
931
  BUILDER_TYPE_STYLE,
@@ -625,6 +942,7 @@ function compileClassNameArgsInto(
625
942
  atRules: ItemSelector[] | null,
626
943
  fileId: string,
627
944
  scope: EvalScope,
945
+ fallbackLocation: CompiledStyleObjectLocations[string] | null,
628
946
  cssConfig: CssConfig,
629
947
  transform: ClassNameTransform,
630
948
  type: ExtractedCssBuilderType,
@@ -634,7 +952,8 @@ function compileClassNameArgsInto(
634
952
  ): boolean {
635
953
  if (startIndex >= args.length) return true;
636
954
 
637
- const styleObj: Record<string, unknown> = {};
955
+ const styleObj: CompiledStyleObject = {};
956
+ const locations: CompiledStyleObjectLocations = {};
638
957
 
639
958
  let i = startIndex;
640
959
  while (i < args.length) {
@@ -644,10 +963,20 @@ function compileClassNameArgsInto(
644
963
  return false;
645
964
  }
646
965
 
647
- if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
966
+ if (!appendClassNameArgStyle(args[i], arg.value, transform, styleObj, locations, fallbackLocation, scope, fileId)) {
967
+ return false;
968
+ }
648
969
  i++;
649
970
  }
650
971
 
972
+ if (Object.keys(locations).length) {
973
+ Object.defineProperty(styleObj, COMPILED_STYLE_OBJECT_LOCATIONS, {
974
+ configurable: true,
975
+ enumerable: false,
976
+ value: locations,
977
+ });
978
+ }
979
+
651
980
  return addStyleItems(
652
981
  styleObj,
653
982
  selector,
@@ -663,20 +992,36 @@ function compileClassNameArgsInto(
663
992
  }
664
993
 
665
994
  function appendClassNameArgStyle(
995
+ node: BabelTypes.Node,
666
996
  value: unknown,
667
997
  transform: ClassNameTransform,
668
- styleObj: Record<string, unknown>,
998
+ styleObj: CompiledStyleObject,
999
+ locations: CompiledStyleObjectLocations,
1000
+ fallbackLocation: CompiledStyleObjectLocations[string] | null,
1001
+ scope: EvalScope,
1002
+ fileId: string,
669
1003
  ): boolean {
670
1004
  if (!value) return true;
671
1005
 
672
1006
  if (typeof value === 'string') {
673
- Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
1007
+ const transformed = decorateClassNameStyle(transform.transform(value), value);
1008
+ Object.assign(styleObj, transformed);
1009
+ assignClassNameStyleLocations(
1010
+ transformed,
1011
+ locations,
1012
+ getClassNameArgLocation(node, fallbackLocation, scope, fileId),
1013
+ );
674
1014
  return true;
675
1015
  }
676
1016
 
677
1017
  if (Array.isArray(value)) {
678
- for (const item of value) {
679
- if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
1018
+ const nodes = node.type === 'ArrayExpression' ? node.elements : [];
1019
+
1020
+ for (let i = 0; i < value.length; i++) {
1021
+ const itemNode = nodes[i] ?? node;
1022
+ if (!appendClassNameArgStyle(itemNode, value[i], transform, styleObj, locations, fallbackLocation, scope, fileId)) {
1023
+ return false;
1024
+ }
680
1025
  }
681
1026
  return true;
682
1027
  }
@@ -684,12 +1029,81 @@ function appendClassNameArgStyle(
684
1029
  if (isWeightedClassName(value)) {
685
1030
  const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
686
1031
  Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
1032
+ assignClassNameStyleLocations(
1033
+ transformed,
1034
+ locations,
1035
+ getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId),
1036
+ );
687
1037
  return true;
688
1038
  }
689
1039
 
690
1040
  return false;
691
1041
  }
692
1042
 
1043
+ function assignClassNameStyleLocations(
1044
+ styleObj: Record<string, unknown>,
1045
+ locations: CompiledStyleObjectLocations,
1046
+ location: CompiledStyleObjectLocations[string] | null,
1047
+ ) {
1048
+ if (!location) return;
1049
+
1050
+ for (const property of Object.keys(styleObj)) {
1051
+ locations[property] = location;
1052
+ }
1053
+ }
1054
+
1055
+ function getClassNameArgLocation(
1056
+ node: BabelTypes.Node,
1057
+ fallbackLocation: CompiledStyleObjectLocations[string] | null,
1058
+ scope: EvalScope,
1059
+ fileId: string,
1060
+ ): CompiledStyleObjectLocations[string] | null {
1061
+ if (node.type === 'StringLiteral') {
1062
+ return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
1063
+ }
1064
+
1065
+ if (node.type === 'TemplateLiteral' && node.expressions.length === 0) {
1066
+ return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
1067
+ }
1068
+
1069
+ return fallbackLocation;
1070
+ }
1071
+
1072
+ function getWeightedClassNameArgLocation(
1073
+ node: BabelTypes.Node,
1074
+ fallbackLocation: CompiledStyleObjectLocations[string] | null,
1075
+ scope: EvalScope,
1076
+ fileId: string,
1077
+ ): CompiledStyleObjectLocations[string] | null {
1078
+ if (
1079
+ node.type === 'CallExpression' &&
1080
+ node.arguments[0] &&
1081
+ node.callee.type === 'MemberExpression' &&
1082
+ !node.callee.computed &&
1083
+ node.callee.property.type === 'Identifier' &&
1084
+ node.callee.property.name === 'weight'
1085
+ ) {
1086
+ return getClassNameArgLocation(node.arguments[0] as BabelTypes.Node, fallbackLocation, scope, fileId);
1087
+ }
1088
+
1089
+ return fallbackLocation;
1090
+ }
1091
+
1092
+ function createClassNameFallbackLocation(
1093
+ loc: { line: number; column: number; } | null | undefined,
1094
+ scope: EvalScope,
1095
+ fileId: string,
1096
+ ): CompiledStyleObjectLocations[string] | null {
1097
+ if (!loc) return null;
1098
+
1099
+ return {
1100
+ filePath: scope.styleFilePath ?? fileId,
1101
+ line: loc.line,
1102
+ column: loc.column + 1,
1103
+ variable: false,
1104
+ };
1105
+ }
1106
+
693
1107
  function decorateClassNameStyle(
694
1108
  style: Record<string, unknown>,
695
1109
  className: string,
@@ -702,20 +1116,29 @@ function decorateClassNameStyle(
702
1116
  continue;
703
1117
  }
704
1118
 
705
- if (Array.isArray(value) && value.length === 2 && typeof value[0] === 'number') {
706
- const rawValue = value[1];
707
- result[property] = isClassNameValue(rawValue)
708
- ? value
709
- : [value[0], classNameValue(rawValue, className)];
710
- continue;
711
- }
712
-
713
- result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
1119
+ result[property] = decorateClassNameValue(value, className);
714
1120
  }
715
1121
 
716
1122
  return result;
717
1123
  }
718
1124
 
1125
+ function decorateClassNameValue(
1126
+ value: unknown,
1127
+ className: string,
1128
+ ): unknown {
1129
+ if (isClassNameValue(value)) return value;
1130
+
1131
+ if (isStyleImportantValue(value)) {
1132
+ return importantValue(decorateClassNameValue(value.value, className));
1133
+ }
1134
+
1135
+ if (isStyleWeightValue(value)) {
1136
+ return weightValue(decorateClassNameValue(value.value, className), value.weight);
1137
+ }
1138
+
1139
+ return classNameValue(value, className);
1140
+ }
1141
+
719
1142
  function isWeightedClassName(
720
1143
  value: unknown,
721
1144
  ): value is { className: string; weight: number; } {
@@ -737,11 +1160,7 @@ function applyClassNameWeight(
737
1160
  continue;
738
1161
  }
739
1162
 
740
- const rawValue = Array.isArray(value) && value.length === 2 && typeof value[0] === 'number'
741
- ? value[1]
742
- : value;
743
-
744
- weighted[property] = [weight, rawValue];
1163
+ weighted[property] = weightValue(value, weight);
745
1164
  }
746
1165
 
747
1166
  return weighted;
@@ -762,6 +1181,7 @@ function compileStyleChainInto(
762
1181
  styleNames: Set<string>,
763
1182
  options: CompilerOptions,
764
1183
  callsiteOverride: TraceCallsiteOverride = null,
1184
+ selectorPrefix: ItemSelector | null = null,
765
1185
  ): boolean {
766
1186
  if (chain.baseArgs.length > 0) {
767
1187
  const styleArg = evaluateNode(chain.baseArgs[0], scope);
@@ -773,7 +1193,7 @@ function compileStyleChainInto(
773
1193
  if (
774
1194
  !addStyleItems(
775
1195
  styleObj,
776
- null,
1196
+ selectorPrefix,
777
1197
  null,
778
1198
  atRules,
779
1199
  fileId,
@@ -808,6 +1228,7 @@ function compileStyleChainInto(
808
1228
  styleNames,
809
1229
  options,
810
1230
  callsiteOverride,
1231
+ selectorPrefix,
811
1232
  );
812
1233
  if (!result) return false;
813
1234
  i++;
@@ -941,6 +1362,7 @@ function compileScopeMethod(
941
1362
  transform: StyleTransform | null,
942
1363
  options: CompilerOptions,
943
1364
  callsiteOverride: TraceCallsiteOverride = null,
1365
+ _selectorPrefix: ItemSelector | null = null,
944
1366
  ): boolean {
945
1367
  const selector = selectors[method.name];
946
1368
  if (!selector) return false;
@@ -1595,6 +2017,7 @@ function compileChainMethod(
1595
2017
  styleNames: Set<string>,
1596
2018
  options: CompilerOptions,
1597
2019
  callsiteOverride: TraceCallsiteOverride = null,
2020
+ selectorPrefix: ItemSelector | null = null,
1598
2021
  ): boolean {
1599
2022
  if (method.name === STATIC_MERGE_METHOD) {
1600
2023
  const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
@@ -1612,6 +2035,7 @@ function compileChainMethod(
1612
2035
  styleNames,
1613
2036
  options,
1614
2037
  mergeCallsite,
2038
+ selectorPrefix,
1615
2039
  );
1616
2040
  }
1617
2041
 
@@ -1637,6 +2061,7 @@ function compileChainMethod(
1637
2061
  styleNames,
1638
2062
  options,
1639
2063
  mergeCallsite,
2064
+ selectorPrefix,
1640
2065
  );
1641
2066
  }
1642
2067
 
@@ -1657,6 +2082,7 @@ function compileChainMethod(
1657
2082
  selectors,
1658
2083
  styleNames,
1659
2084
  options,
2085
+ selectorPrefix,
1660
2086
  );
1661
2087
  }
1662
2088
 
@@ -1675,12 +2101,14 @@ function compileChainMethod(
1675
2101
  transform,
1676
2102
  atRules,
1677
2103
  options,
2104
+ selectorPrefix,
1678
2105
  );
1679
2106
  }
1680
2107
 
1681
2108
  const itemSelector: ItemSelector = selector.priority !== null
1682
2109
  ? [selectorStr, selector.priority]
1683
2110
  : selectorStr;
2111
+ const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
1684
2112
 
1685
2113
  const styleArg = evaluateNode(method.args[0], scope);
1686
2114
  if (!styleArg.ok) {
@@ -1691,7 +2119,7 @@ function compileChainMethod(
1691
2119
 
1692
2120
  return addStyleItems(
1693
2121
  styleObj,
1694
- itemSelector,
2122
+ compiledSelector,
1695
2123
  null,
1696
2124
  atRules,
1697
2125
  fileId,
@@ -1718,13 +2146,14 @@ function compileMergeArg(
1718
2146
  styleNames: Set<string>,
1719
2147
  options: CompilerOptions,
1720
2148
  callsiteOverride: TraceCallsiteOverride = null,
2149
+ selectorPrefix: ItemSelector | null = null,
1721
2150
  ): boolean {
1722
2151
  if (!styleArgNode) return false;
1723
2152
  const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
1724
2153
  const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
1725
2154
  const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
1726
2155
 
1727
- if ((styleCallsite || options.dev?.sourcemapMode === 'value') && localChain?.kind === 'style' && localMeta) {
2156
+ if (localChain?.kind === 'style' && localMeta) {
1728
2157
  return compileStyleChainInto(
1729
2158
  localChain,
1730
2159
  localMeta.selectors,
@@ -1740,6 +2169,7 @@ function compileMergeArg(
1740
2169
  styleNames,
1741
2170
  options,
1742
2171
  styleCallsite,
2172
+ selectorPrefix,
1743
2173
  );
1744
2174
  }
1745
2175
 
@@ -1763,6 +2193,7 @@ function compileMergeArg(
1763
2193
  styleNames,
1764
2194
  options,
1765
2195
  styleCallsite,
2196
+ selectorPrefix,
1766
2197
  );
1767
2198
  }
1768
2199
  }
@@ -1777,7 +2208,7 @@ function compileMergeArg(
1777
2208
  return addStyleDataSpreadItems(
1778
2209
  styleArg.value,
1779
2210
  styleArgNode,
1780
- null,
2211
+ selectorPrefix,
1781
2212
  null,
1782
2213
  atRules,
1783
2214
  fileId,
@@ -1792,7 +2223,7 @@ function compileMergeArg(
1792
2223
 
1793
2224
  return addStyleDataItems(
1794
2225
  styleArg.value,
1795
- null,
2226
+ selectorPrefix,
1796
2227
  null,
1797
2228
  atRules,
1798
2229
  fileId,
@@ -1809,13 +2240,114 @@ function getLocalStyleChainArg(
1809
2240
  node: BabelTypes.Node,
1810
2241
  scope: EvalScope,
1811
2242
  styleNames: Set<string>,
2243
+ sheetNames: Set<string> = new Set(),
1812
2244
  ) {
1813
2245
  if (node.type !== 'Identifier') return null;
1814
2246
 
1815
2247
  const init = scope.bindingNodes?.get(node.name);
1816
2248
  if (!init) return null;
1817
2249
 
1818
- return extractStyleChain(init, styleNames);
2250
+ return extractStyleChain(init, styleNames, sheetNames);
2251
+ }
2252
+
2253
+ function getLocalSelectorTargetChain(
2254
+ node: BabelTypes.CallExpression,
2255
+ scope: EvalScope,
2256
+ styleNames: Set<string>,
2257
+ sheetNames: Set<string>,
2258
+ ): StyleChainParseResult {
2259
+ const callee = node.callee;
2260
+
2261
+ if (callee.type === 'Identifier') {
2262
+ const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
2263
+ if (!isBareSelectorTargetChain(target)) return null;
2264
+
2265
+ return {
2266
+ ...target,
2267
+ baseArgs: [...target.baseArgs, ...(node.arguments as BabelTypes.Node[])],
2268
+ };
2269
+ }
2270
+
2271
+ if (callee.type !== 'MemberExpression' || callee.computed) return null;
2272
+
2273
+ const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
2274
+ if (isBareSelectorTargetChain(memberTarget)) {
2275
+ return {
2276
+ ...memberTarget,
2277
+ baseArgs: [...memberTarget.baseArgs, ...(node.arguments as BabelTypes.Node[])],
2278
+ };
2279
+ }
2280
+
2281
+ const methodName = callee.property.type === 'Identifier'
2282
+ ? callee.property.name
2283
+ : callee.property.type === 'StringLiteral'
2284
+ ? callee.property.value
2285
+ : null;
2286
+
2287
+ if (!methodName) return null;
2288
+
2289
+ const object = callee.object;
2290
+ const target = object.type === 'Identifier'
2291
+ ? getLocalStyleChainArg(object, scope, styleNames, sheetNames)
2292
+ : object.type === 'MemberExpression'
2293
+ ? getLocalMemberStyleChainArg(object, scope, styleNames, sheetNames)
2294
+ : object.type === 'CallExpression'
2295
+ ? getLocalSelectorTargetChain(object, scope, styleNames, sheetNames)
2296
+ : null;
2297
+
2298
+ if (target?.kind !== 'selector') return null;
2299
+
2300
+ return {
2301
+ ...target,
2302
+ methods: [
2303
+ ...target.methods,
2304
+ { name: methodName, args: node.arguments as BabelTypes.Node[], nameNode: callee.property },
2305
+ ],
2306
+ };
2307
+ }
2308
+
2309
+ function getLocalMemberStyleChainArg(
2310
+ node: BabelTypes.MemberExpression,
2311
+ scope: EvalScope,
2312
+ styleNames: Set<string>,
2313
+ sheetNames: Set<string>,
2314
+ ) {
2315
+ if (node.computed || node.object.type !== 'Identifier') return null;
2316
+
2317
+ const propertyName = node.property.type === 'Identifier'
2318
+ ? node.property.name
2319
+ : node.property.type === 'StringLiteral'
2320
+ ? node.property.value
2321
+ : null;
2322
+
2323
+ if (!propertyName) return null;
2324
+
2325
+ const objectInit = scope.bindingNodes?.get(node.object.name);
2326
+ if (objectInit?.type !== 'ObjectExpression') return null;
2327
+
2328
+ for (let i = 0, len = objectInit.properties.length; i < len; i++) {
2329
+ const property = objectInit.properties[i];
2330
+ if (property.type !== 'ObjectProperty') continue;
2331
+
2332
+ const key = property.key;
2333
+ const keyName = key.type === 'Identifier'
2334
+ ? key.name
2335
+ : key.type === 'StringLiteral'
2336
+ ? key.value
2337
+ : null;
2338
+
2339
+ if (keyName !== propertyName) continue;
2340
+
2341
+ return extractStyleChain(property.value as BabelTypes.Node, styleNames, sheetNames);
2342
+ }
2343
+
2344
+ return null;
2345
+ }
2346
+
2347
+ function isBareSelectorTargetChain(
2348
+ chain: StyleChainParseResult,
2349
+ ): chain is NonNullable<StyleChainParseResult> {
2350
+ return chain?.kind === 'selector' && chain.baseArgs.length === 1 && chain.methods.length === 0;
1819
2351
  }
1820
2352
 
1821
2353
  function getLocalBindingNode(
@@ -1878,6 +2410,7 @@ function compileAtRuleMethod(
1878
2410
  selectors: SelectorsMap,
1879
2411
  styleNames: Set<string>,
1880
2412
  options: CompilerOptions,
2413
+ selectorPrefix: ItemSelector | null = null,
1881
2414
  ): boolean {
1882
2415
  const isMedia = selectorStr.startsWith(SELECTOR_MEDIA) || selectorStr.startsWith(SELECTOR_CONTAINER);
1883
2416
  const hasArg = selectorStr.includes(SELECTOR_ARGS);
@@ -1932,6 +2465,8 @@ function compileAtRuleMethod(
1932
2465
  cssRules,
1933
2466
  styleNames,
1934
2467
  options,
2468
+ null,
2469
+ selectorPrefix,
1935
2470
  );
1936
2471
  }
1937
2472
  // Could not parse as chain — try to evaluate as static object
@@ -1942,7 +2477,7 @@ function compileAtRuleMethod(
1942
2477
  }
1943
2478
  return addStyleItems(
1944
2479
  applyTransform(evaled.value as Record<string, unknown>, transform, cssConfig),
1945
- null,
2480
+ selectorPrefix,
1946
2481
  null,
1947
2482
  nextAtRules,
1948
2483
  fileId,
@@ -1962,7 +2497,7 @@ function compileAtRuleMethod(
1962
2497
 
1963
2498
  return addStyleItems(
1964
2499
  applyTransform(styleResult.value as Record<string, unknown>, transform, cssConfig),
1965
- null,
2500
+ selectorPrefix,
1966
2501
  null,
1967
2502
  nextAtRules,
1968
2503
  fileId,
@@ -1987,6 +2522,7 @@ function compileArgMethod(
1987
2522
  transform: StyleTransform | null,
1988
2523
  atRules: ItemSelector[] | null,
1989
2524
  options: CompilerOptions,
2525
+ selectorPrefix: ItemSelector | null = null,
1990
2526
  ): boolean {
1991
2527
  const selectorStr = selector.selector.trim();
1992
2528
  validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
@@ -2021,8 +2557,9 @@ function compileArgMethod(
2021
2557
  const compiledSelector: ItemSelector = selector.priority !== null
2022
2558
  ? [selectorText, selector.priority]
2023
2559
  : selectorText;
2560
+ const itemSelector = selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector;
2024
2561
 
2025
- if (!addStyleItems(styleObj, compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) {
2562
+ if (!addStyleItems(styleObj, itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) {
2026
2563
  return false;
2027
2564
  }
2028
2565
 
@@ -2165,6 +2702,8 @@ function addSlotOverrideDataItems(
2165
2702
  dedupe: overrideItem.dedupe,
2166
2703
  className: overrideItem.className,
2167
2704
  property: overrideItem.property,
2705
+ weight: overrideItem.weight,
2706
+ important: overrideItem.important,
2168
2707
  value: overrideItem.value,
2169
2708
  variable: overrideItem.variable,
2170
2709
  token: overrideItem.token,
@@ -2251,13 +2790,10 @@ function addRuntimeScopeItem(
2251
2790
  cssConfig: CssConfig,
2252
2791
  callsiteOverride: TraceCallsiteOverride = null,
2253
2792
  ) {
2254
- let priority: number | null = null;
2793
+ const weight = sourceItem.weight;
2794
+ let important = false;
2255
2795
  let value = sourceItem.value;
2256
-
2257
- if (Array.isArray(value)) {
2258
- priority = value[1];
2259
- value = value[0];
2260
- }
2796
+ important = sourceItem.important;
2261
2797
 
2262
2798
  const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
2263
2799
  const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
@@ -2266,7 +2802,8 @@ function addRuntimeScopeItem(
2266
2802
 
2267
2803
  const dedupe = getClassNameDedupe(
2268
2804
  sourceItem.property,
2269
- priority,
2805
+ weight,
2806
+ important,
2270
2807
  sourceItem.selector,
2271
2808
  itemParentSelector,
2272
2809
  itemAtRules,
@@ -2274,7 +2811,8 @@ function addRuntimeScopeItem(
2274
2811
 
2275
2812
  const className = getAtomicClassName(
2276
2813
  sourceItem.property,
2277
- priority,
2814
+ weight,
2815
+ important,
2278
2816
  valueStr,
2279
2817
  sourceItem.selector,
2280
2818
  itemParentSelector,
@@ -2285,6 +2823,7 @@ function addRuntimeScopeItem(
2285
2823
  cssConfig.classNameFormat,
2286
2824
  sourceItem.transformClassName ?? null,
2287
2825
  cssConfig.transformClassNameFormat,
2826
+ cssConfig.sheetClassNameFormat,
2288
2827
  cssConfig.hashLength,
2289
2828
  );
2290
2829
 
@@ -2302,6 +2841,7 @@ function addRuntimeScopeItem(
2302
2841
  className,
2303
2842
  sourceItem.property,
2304
2843
  valueStr,
2844
+ important,
2305
2845
  sourceItem.selector,
2306
2846
  itemParentSelector,
2307
2847
  itemAtRules,
@@ -2310,7 +2850,7 @@ function addRuntimeScopeItem(
2310
2850
 
2311
2851
  const layerPriority = getAtomicRuleLayerPriority(
2312
2852
  sourceItem.property,
2313
- priority,
2853
+ weight,
2314
2854
  sourceItem.selector,
2315
2855
  itemParentSelector,
2316
2856
  itemAtRules,
@@ -2477,15 +3017,13 @@ function addRuntimeStyleItem(
2477
3017
  cssConfig: CssConfig,
2478
3018
  callsiteOverride: TraceCallsiteOverride = null,
2479
3019
  ) {
2480
- let priority: number | null = null;
3020
+ const weight = sourceItem.weight;
3021
+ const important = sourceItem.important;
2481
3022
  let value = sourceItem.value;
2482
3023
 
2483
- if (Array.isArray(value)) {
2484
- priority = value[1];
2485
- value = value[0];
2486
- }
2487
-
2488
- const itemSelector = selector ?? sourceItem.selector;
3024
+ const itemSelector = selector && sourceItem.selector
3025
+ ? combineSelectors(selector, sourceItem.selector)
3026
+ : selector ?? sourceItem.selector;
2489
3027
  const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
2490
3028
  const variable = sourceItem.variable;
2491
3029
  const runtimeValue = variable?.[0] === ITEM_VALUE_TYPE_VARIABLE
@@ -2503,7 +3041,8 @@ function addRuntimeStyleItem(
2503
3041
 
2504
3042
  const dedupe = getClassNameDedupe(
2505
3043
  sourceItem.property,
2506
- priority,
3044
+ weight,
3045
+ important,
2507
3046
  itemSelector,
2508
3047
  parentSelector,
2509
3048
  itemAtRules,
@@ -2513,7 +3052,8 @@ function addRuntimeStyleItem(
2513
3052
 
2514
3053
  const className = getAtomicClassName(
2515
3054
  sourceItem.property,
2516
- priority,
3055
+ weight,
3056
+ important,
2517
3057
  valueStr,
2518
3058
  itemSelector,
2519
3059
  parentSelector,
@@ -2524,6 +3064,7 @@ function addRuntimeStyleItem(
2524
3064
  cssConfig.classNameFormat,
2525
3065
  sourceItem.transformClassName ?? null,
2526
3066
  cssConfig.transformClassNameFormat,
3067
+ cssConfig.sheetClassNameFormat,
2527
3068
  cssConfig.hashLength,
2528
3069
  );
2529
3070
 
@@ -2547,6 +3088,7 @@ function addRuntimeStyleItem(
2547
3088
  className,
2548
3089
  sourceItem.property,
2549
3090
  valueStr,
3091
+ important,
2550
3092
  itemSelector,
2551
3093
  parentSelector,
2552
3094
  itemAtRules,
@@ -2555,7 +3097,7 @@ function addRuntimeStyleItem(
2555
3097
 
2556
3098
  const layerPriority = getAtomicRuleLayerPriority(
2557
3099
  sourceItem.property,
2558
- priority,
3100
+ weight,
2559
3101
  itemSelector,
2560
3102
  parentSelector,
2561
3103
  itemAtRules,
@@ -2577,6 +3119,26 @@ function addRuntimeStyleItem(
2577
3119
  });
2578
3120
  }
2579
3121
 
3122
+ function combineSelectors(
3123
+ parent: ItemSelector,
3124
+ child: ItemSelector,
3125
+ ): ItemSelector {
3126
+ const parentText = getItemSelectorText(parent);
3127
+ const childText = getItemSelectorText(child);
3128
+ const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
3129
+ const selector = parentText + childText;
3130
+
3131
+ return priority > 0 ? [selector, priority] : selector;
3132
+ }
3133
+
3134
+ function getItemSelectorText(selector: ItemSelector) {
3135
+ return Array.isArray(selector) ? selector[0] : selector;
3136
+ }
3137
+
3138
+ function getItemSelectorPriority(selector: ItemSelector) {
3139
+ return Array.isArray(selector) ? selector[1] : 0;
3140
+ }
3141
+
2580
3142
  function getRuntimeStyleItemSourceTrace(
2581
3143
  item: RuntimeStyleItem,
2582
3144
  fileId: string,
@@ -2658,14 +3220,12 @@ function addStyleItems(
2658
3220
  const property = keys[i];
2659
3221
  const rawValue = styleObj[property];
2660
3222
 
2661
- let priority: number | null = null;
3223
+ let weight: number | null = null;
3224
+ let important = false;
2662
3225
  let value: unknown = rawValue;
2663
3226
  let transformClassName: string | null = null;
2664
3227
 
2665
- if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === 'number') {
2666
- priority = rawValue[0];
2667
- value = rawValue[1];
2668
- }
3228
+ [value, weight, important] = unwrapStaticStyleValue(value);
2669
3229
 
2670
3230
  if (isClassNameValue(value)) {
2671
3231
  transformClassName = value.className;
@@ -2697,7 +3257,7 @@ function addStyleItems(
2697
3257
 
2698
3258
  const shouldUseVariable = !!(token || runtimeValue);
2699
3259
 
2700
- const variableName = shouldUseVariable && propertyLoc
3260
+ const variableName = shouldUseVariable && propertyLoc && propertyLoc.variable !== false
2701
3261
  ? getLocalVarName(
2702
3262
  propertyLoc.filePath ?? fileId,
2703
3263
  propertyLoc.line,
@@ -2716,7 +3276,8 @@ function addStyleItems(
2716
3276
 
2717
3277
  const dedupe = getClassNameDedupe(
2718
3278
  property,
2719
- priority,
3279
+ weight,
3280
+ important,
2720
3281
  selector,
2721
3282
  parentSelector,
2722
3283
  atRules,
@@ -2724,7 +3285,8 @@ function addStyleItems(
2724
3285
 
2725
3286
  const className = getAtomicClassName(
2726
3287
  property,
2727
- priority,
3288
+ weight,
3289
+ important,
2728
3290
  valueStr,
2729
3291
  selector,
2730
3292
  parentSelector,
@@ -2735,6 +3297,7 @@ function addStyleItems(
2735
3297
  cssConfig.classNameFormat,
2736
3298
  transformClassName,
2737
3299
  cssConfig.transformClassNameFormat,
3300
+ cssConfig.sheetClassNameFormat,
2738
3301
  cssConfig.hashLength,
2739
3302
  );
2740
3303
 
@@ -2782,6 +3345,7 @@ function addStyleItems(
2782
3345
  className,
2783
3346
  property,
2784
3347
  valueStr,
3348
+ important,
2785
3349
  selector,
2786
3350
  parentSelector,
2787
3351
  atRules,
@@ -2790,7 +3354,7 @@ function addStyleItems(
2790
3354
 
2791
3355
  const layerPriority = getAtomicRuleLayerPriority(
2792
3356
  property,
2793
- priority,
3357
+ weight,
2794
3358
  selector,
2795
3359
  parentSelector,
2796
3360
  atRules,
@@ -2834,6 +3398,29 @@ function addStyleItems(
2834
3398
  return true;
2835
3399
  }
2836
3400
 
3401
+ function unwrapStaticStyleValue(value: unknown): [value: unknown, weight: number | null, important: boolean] {
3402
+ let weight: number | null = null;
3403
+ let important = false;
3404
+
3405
+ while (true) {
3406
+ if (isStyleImportantValue(value)) {
3407
+ important = true;
3408
+ value = value.value;
3409
+ continue;
3410
+ }
3411
+
3412
+ if (isStyleWeightValue(value)) {
3413
+ weight = value.weight;
3414
+ value = value.value;
3415
+ continue;
3416
+ }
3417
+
3418
+ break;
3419
+ }
3420
+
3421
+ return [value, weight, important];
3422
+ }
3423
+
2837
3424
  function throwIfRequiredStaticStyleValue(result: EvalResult) {
2838
3425
  if (result.ok) return;
2839
3426
  if (