@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.11

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 (491) hide show
  1. package/CHANGELOG.md +156 -2
  2. package/README.md +181 -49
  3. package/atomic/atRule/utils.ts +3 -2
  4. package/atomic/className.ts +50 -12
  5. package/atomic/debug/className/className.ts +24 -8
  6. package/atomic/element.ts +5 -2
  7. package/atomic/rule.ts +11 -5
  8. package/atomic/scope.ts +19 -0
  9. package/atomic/theme.ts +44 -3
  10. package/atomic/token.ts +7 -4
  11. package/atomic/utils/cssIdent.ts +54 -0
  12. package/atomic/utils/cssVar.ts +19 -0
  13. package/atomic/utils/debug.ts +1 -1
  14. package/atomic/utils/format.ts +1 -1
  15. package/atomic/utils/hash.ts +14 -0
  16. package/atomic/utils/selector.ts +31 -1
  17. package/atomic/var.ts +3 -2
  18. package/builder/classname/class_name_builder.ts +491 -0
  19. package/builder/classname/fns.ts +77 -0
  20. package/builder/classname/index.ts +3 -0
  21. package/builder/classname/types.ts +41 -0
  22. package/builder/data/const.ts +8 -1
  23. package/builder/data/create.ts +52 -6
  24. package/builder/data/data.ts +33 -8
  25. package/builder/data/debug.ts +1 -0
  26. package/builder/data/index.ts +0 -1
  27. package/builder/data/is.ts +26 -3
  28. package/builder/data/merge/scope.ts +38 -38
  29. package/builder/data/merge/style.ts +115 -20
  30. package/builder/data/state.ts +17 -2
  31. package/builder/extract/index.ts +1 -0
  32. package/builder/extract/sheet.ts +30 -0
  33. package/builder/extract/token.ts +30 -14
  34. package/builder/extract/utils.ts +2 -0
  35. package/builder/extract/withTokens.ts +2 -1
  36. package/builder/selector_override.noop.ts +11 -0
  37. package/builder/selector_override.ts +31 -0
  38. package/builder/selector_override_core.ts +79 -0
  39. package/builder/style_builder.ts +144 -20
  40. package/builder/style_data.ts +25 -0
  41. package/builder/style_fns.ts +57 -57
  42. package/builder/token/data.ts +30 -0
  43. package/builder/token/index.ts +3 -0
  44. package/builder/token/name.ts +54 -0
  45. package/builder/token/symbols.ts +6 -0
  46. package/builder/types/alias.ts +44 -16
  47. package/builder/types/fns.ts +24 -16
  48. package/builder/types/types.ts +37 -7
  49. package/builder/utils.ts +1 -0
  50. package/compiler/compiler/compiler.ts +88 -14
  51. package/compiler/compiler/constants.ts +6 -0
  52. package/compiler/compiler/index.ts +1 -0
  53. package/compiler/compiler/types.ts +4 -1
  54. package/compiler/cssProp.ts +21 -0
  55. package/compiler/extract/extract.ts +42 -14
  56. package/compiler/extract/types.ts +2 -0
  57. package/compiler/index.ts +1 -0
  58. package/compiler/transform/cssProp/index.ts +1 -0
  59. package/compiler/transform/cssProp/plugin.ts +161 -0
  60. package/compiler/transform/debug/plugin.ts +93 -4
  61. package/compiler/transform/debug/transform.ts +2 -1
  62. package/compiler/transform/debug/utils/debug_data.ts +73 -0
  63. package/compiler/transform/evaluator/evaluator.ts +169 -32
  64. package/compiler/transform/evaluator/tracer.ts +48 -11
  65. package/compiler/transform/extract/chain/chain.ts +1370 -162
  66. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  67. package/compiler/transform/extract/chain/types.ts +3 -1
  68. package/compiler/transform/extract/plugin.ts +64 -6
  69. package/compiler/transform/extract/transform.ts +2 -1
  70. package/compiler/transform/extract/utils/replacement.ts +72 -2
  71. package/compiler/transform/extract/utils/state.ts +3 -0
  72. package/compiler/transform/extract/utils/theme.ts +6 -6
  73. package/compiler/transform/index.ts +1 -0
  74. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  75. package/compiler/transform/syntax/static_ids.ts +1 -1
  76. package/compiler/utils/constants.ts +12 -5
  77. package/compiler/utils/file_resolver.ts +2 -0
  78. package/compiler/utils/import_source.ts +19 -8
  79. package/compiler/utils/imports.ts +11 -1
  80. package/config/build.ts +9 -2
  81. package/config/config/check.ts +25 -0
  82. package/config/config/css.ts +18 -1
  83. package/config/config/debug.ts +24 -1
  84. package/config/config/dev.ts +17 -1
  85. package/config/configure.ts +19 -2
  86. package/config/types.ts +7 -0
  87. package/css/index.ts +2 -0
  88. package/css/sheet.ts +152 -0
  89. package/css/styleTarget.ts +251 -0
  90. package/dev/config.ts +2 -3
  91. package/dev/utils.ts +3 -3
  92. package/dialect/extracted/index.ts +5 -0
  93. package/dialect/index.ts +1 -0
  94. package/dialect/namedTokens.ts +153 -0
  95. package/dist/adapter/preact.js +2 -0
  96. package/dist/adapter/react.js +2 -0
  97. package/dist/adapter/solid.js +2 -0
  98. package/dist/className-yhJCGT0F.js +304 -0
  99. package/dist/className-yhJCGT0F.js.map +1 -0
  100. package/dist/combine-Bww7VnSr.js +1254 -0
  101. package/dist/combine-Bww7VnSr.js.map +1 -0
  102. package/dist/compiler/index.mjs +2 -2
  103. package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
  104. package/dist/compiler-C3CEGGtI.mjs.map +1 -0
  105. package/dist/config/index.js +2 -2
  106. package/dist/config-BAEzRmSJ.js +6 -0
  107. package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
  108. package/dist/config-BKP5LOkt.js +35 -0
  109. package/dist/config-BKP5LOkt.js.map +1 -0
  110. package/dist/config-C5VWvTav.js +34 -0
  111. package/dist/config-C5VWvTav.js.map +1 -0
  112. package/dist/config-CB4lm2tM.js +1 -0
  113. package/dist/config-CDjbHwb-.js +6 -0
  114. package/dist/config-CDjbHwb-.js.map +1 -0
  115. package/dist/config-DNEnHEf3.js +36 -0
  116. package/dist/config-DNEnHEf3.js.map +1 -0
  117. package/dist/createTransformElement-D8fXZ3wA.js +34 -0
  118. package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
  119. package/dist/css-BDn0epJ8.js +1339 -0
  120. package/dist/css-BDn0epJ8.js.map +1 -0
  121. package/dist/css-CFxNrYt3.js +4040 -0
  122. package/dist/css-CFxNrYt3.js.map +1 -0
  123. package/dist/css-DEYgrj76.js +524 -0
  124. package/dist/css-DEYgrj76.js.map +1 -0
  125. package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
  126. package/dist/css-DWBWsyxZ.js.map +1 -0
  127. package/dist/css.js +2 -2
  128. package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
  129. package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
  130. package/dist/data-CDrS1Bq4.js +785 -0
  131. package/dist/data-CDrS1Bq4.js.map +1 -0
  132. package/dist/debug-BkVbf0Cz.js +52 -0
  133. package/dist/debug-BkVbf0Cz.js.map +1 -0
  134. package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
  135. package/dist/debug-YuhEIQVO.js.map +1 -0
  136. package/dist/dev/rsc.js +10 -9
  137. package/dist/dev/rsc.js.map +1 -1
  138. package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
  139. package/dist/dev-0imWmSVb.js.map +1 -0
  140. package/dist/dev.js +1 -1
  141. package/dist/dialect/extracted/index.js +2 -0
  142. package/dist/dialect/index.js +2 -0
  143. package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
  144. package/dist/elementMarker-kvpMjB49.js.map +1 -0
  145. package/dist/entry/dev/adapter/preact.js +12 -0
  146. package/dist/entry/dev/adapter/preact.js.map +1 -0
  147. package/dist/entry/dev/adapter/react.js +12 -0
  148. package/dist/entry/dev/adapter/react.js.map +1 -0
  149. package/dist/entry/dev/adapter/solid.js +12 -0
  150. package/dist/entry/dev/adapter/solid.js.map +1 -0
  151. package/dist/entry/dev/css.js +3 -3
  152. package/dist/entry/dev/jsx-dev-runtime.js +2 -1
  153. package/dist/entry/dev/jsx-runtime.js +2 -1
  154. package/dist/entry/dev.js +13 -9
  155. package/dist/entry/prod/adapter/preact.js +12 -0
  156. package/dist/entry/prod/adapter/preact.js.map +1 -0
  157. package/dist/entry/prod/adapter/react.js +12 -0
  158. package/dist/entry/prod/adapter/react.js.map +1 -0
  159. package/dist/entry/prod/adapter/solid.js +12 -0
  160. package/dist/entry/prod/adapter/solid.js.map +1 -0
  161. package/dist/entry/prod/css.js +3 -3
  162. package/dist/entry/prod/extract.js +242 -3
  163. package/dist/entry/prod/extract.js.map +1 -0
  164. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  165. package/dist/entry/prod/jsx-runtime.js +2 -2
  166. package/dist/entry/prod/runtime.js +3 -4
  167. package/dist/entry/prod.js +84 -1201
  168. package/dist/entry/prod.js.map +1 -1
  169. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  170. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  171. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  172. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  173. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  174. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  175. package/dist/entry/rsc-dev/css.js +3 -3
  176. package/dist/entry/rsc-dev/dev.js +11 -13
  177. package/dist/entry/rsc-dev/dev.js.map +1 -1
  178. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  179. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  180. package/dist/entry/rsc-dev.js +582 -664
  181. package/dist/entry/rsc-dev.js.map +1 -1
  182. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  183. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  184. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  185. package/dist/entry/rsc-prod/css.js +9 -3
  186. package/dist/entry/rsc-prod/css.js.map +1 -0
  187. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  188. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  189. package/dist/entry/rsc-prod/runtime.js +3 -4
  190. package/dist/entry/rsc-prod.js +242 -10
  191. package/dist/entry/rsc-prod.js.map +1 -0
  192. package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
  193. package/dist/env-Cz8frh6e.js.map +1 -0
  194. package/dist/getClassName-9CsXbNls.js +545 -0
  195. package/dist/getClassName-9CsXbNls.js.map +1 -0
  196. package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
  197. package/dist/getClassName-DGm-VNDo.js.map +1 -0
  198. package/dist/getClassName-Dtc4yyYI.js +47 -0
  199. package/dist/getClassName-Dtc4yyYI.js.map +1 -0
  200. package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
  201. package/dist/getClassName-DtkplEIt.js.map +1 -0
  202. package/dist/global-CAc9OjKx.js +14 -0
  203. package/dist/global-CAc9OjKx.js.map +1 -0
  204. package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
  205. package/dist/hash-Cr-LCWDt.js.map +1 -0
  206. package/dist/index.js +10 -8
  207. package/dist/jsx/jsx-dev-runtime.js +2 -2
  208. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  209. package/dist/jsx/jsx-runtime.js +2 -2
  210. package/dist/jsx/jsx-runtime.server.js +1 -1
  211. package/dist/jsx-CVxpkS04.js +39 -0
  212. package/dist/jsx-CVxpkS04.js.map +1 -0
  213. package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
  214. package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
  215. package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
  216. package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
  217. package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
  218. package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
  219. package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
  220. package/dist/loader-_-VjzlrX.mjs.map +1 -0
  221. package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
  222. package/dist/misc-B76PUnWe.mjs.map +1 -0
  223. package/dist/namedTokens-5AayGokX.js +85 -0
  224. package/dist/namedTokens-5AayGokX.js.map +1 -0
  225. package/dist/plugin/farm/index.mjs +4 -3
  226. package/dist/plugin/farm/index.mjs.map +1 -1
  227. package/dist/plugin/nextjs/index.mjs +151 -31
  228. package/dist/plugin/nextjs/index.mjs.map +1 -1
  229. package/dist/plugin/nextjs/loader.mjs +4 -4
  230. package/dist/plugin/parcel/index.cjs +2 -0
  231. package/dist/plugin/parcel/index.mjs +3 -1
  232. package/dist/plugin/parcel/optimizer.cjs +3 -2
  233. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  234. package/dist/plugin/parcel/optimizer.mjs +3 -2
  235. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  236. package/dist/plugin/parcel/resolver.cjs +1 -1
  237. package/dist/plugin/parcel/resolver.mjs +2 -2
  238. package/dist/plugin/parcel/runtime.cjs +1 -1
  239. package/dist/plugin/parcel/runtime.mjs +1 -1
  240. package/dist/plugin/parcel/transformer.cjs +1 -1
  241. package/dist/plugin/parcel/transformer.mjs +2 -2
  242. package/dist/plugin/rspack/index.mjs +3 -2
  243. package/dist/plugin/rspack/index.mjs.map +1 -1
  244. package/dist/plugin/vite/index.mjs +13 -10
  245. package/dist/plugin/vite/index.mjs.map +1 -1
  246. package/dist/plugin/webpack/index.mjs +3 -2
  247. package/dist/plugin/webpack/loader.mjs +2 -2
  248. package/dist/presets/tailwind/index.js +995 -0
  249. package/dist/presets/tailwind/index.js.map +1 -0
  250. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  251. package/dist/presets-DSanixJV.js.map +1 -0
  252. package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
  253. package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
  254. package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
  255. package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
  256. package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
  257. package/dist/rules-DaMaMHgb.js.map +1 -0
  258. package/dist/scope-CZdGAnl_.js +601 -0
  259. package/dist/scope-CZdGAnl_.js.map +1 -0
  260. package/dist/selector/index.js +1 -2
  261. package/dist/server.js +17 -11
  262. package/dist/server.js.map +1 -1
  263. package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
  264. package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
  265. package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
  266. package/dist/shared-PK52rW6T.cjs.map +1 -0
  267. package/dist/sheet-CxkO1Hwt.js +7 -0
  268. package/dist/sheet-CxkO1Hwt.js.map +1 -0
  269. package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
  270. package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
  271. package/dist/style-CAhAnRni.js +1129 -0
  272. package/dist/style-CAhAnRni.js.map +1 -0
  273. package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
  274. package/dist/styleStore-BzLZwpwy.js.map +1 -0
  275. package/dist/styleStore-DaIJ4OPV.js +58 -0
  276. package/dist/styleStore-DaIJ4OPV.js.map +1 -0
  277. package/dist/token-D33mKTka.js +138 -0
  278. package/dist/token-D33mKTka.js.map +1 -0
  279. package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
  280. package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
  281. package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
  282. package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
  283. package/dist/transform-DSpimwwC.js +23 -0
  284. package/dist/transform-DSpimwwC.js.map +1 -0
  285. package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
  286. package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
  287. package/dist/utils-DZK0mfmY.js +42 -0
  288. package/dist/utils-DZK0mfmY.js.map +1 -0
  289. package/dist/utils-D_XgtMtn.js +72 -0
  290. package/dist/utils-D_XgtMtn.js.map +1 -0
  291. package/dist/utils-DxCpyV2E.js +62 -0
  292. package/dist/utils-DxCpyV2E.js.map +1 -0
  293. package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
  294. package/dist/utils-H1VInWpd.js.map +1 -0
  295. package/dist/utils-NdisireF.mjs +182 -0
  296. package/dist/utils-NdisireF.mjs.map +1 -0
  297. package/dist/utils.js +4 -4
  298. package/dist/utils.js.map +1 -1
  299. package/dist/value-CK0-Xbov.js +160 -0
  300. package/dist/value-CK0-Xbov.js.map +1 -0
  301. package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
  302. package/dist/webpack-D7QO0bKN.mjs.map +1 -0
  303. package/entry/dev/adapter/preact.ts +8 -0
  304. package/entry/dev/adapter/react.ts +8 -0
  305. package/entry/dev/adapter/solid.ts +8 -0
  306. package/entry/dev/config.ts +1 -1
  307. package/entry/dev/index.ts +1 -0
  308. package/entry/dev/jsx_dev_runtime.ts +1 -0
  309. package/entry/dev/jsx_runtime.ts +1 -0
  310. package/entry/dev/sheet.ts +4 -0
  311. package/entry/prod/adapter/preact.ts +8 -0
  312. package/entry/prod/adapter/react.ts +8 -0
  313. package/entry/prod/adapter/solid.ts +8 -0
  314. package/entry/prod/config_debug.ts +2 -0
  315. package/entry/prod/index.ts +1 -1
  316. package/entry/prod/runtime.ts +4 -2
  317. package/entry/rsc_dev/adapter/preact.ts +9 -0
  318. package/entry/rsc_dev/adapter/react.ts +9 -0
  319. package/entry/rsc_dev/adapter/solid.ts +9 -0
  320. package/entry/rsc_dev/config.ts +1 -1
  321. package/entry/rsc_dev/server.ts +1 -1
  322. package/entry/rsc_prod/adapter/preact.ts +1 -0
  323. package/entry/rsc_prod/adapter/react.ts +1 -0
  324. package/entry/rsc_prod/adapter/solid.ts +1 -0
  325. package/entry/rsc_prod/config_debug.ts +6 -0
  326. package/entry/rsc_prod/index.ts +1 -1
  327. package/entry/rsc_prod/runtime.ts +1 -1
  328. package/entry/rsc_prod/server.ts +1 -1
  329. package/entry/shared/config_debug.ts +9 -0
  330. package/entry/shared/config_dev.ts +14 -0
  331. package/entry/shared/dev.ts +11 -2
  332. package/entry/shared/utils.ts +28 -0
  333. package/jsx/types/index.ts +1 -0
  334. package/jsx/types/preact.ts +14 -0
  335. package/jsx/{types.ts → types/react.ts} +2 -2
  336. package/jsx/types/solid.ts +32 -0
  337. package/package.json +110 -8
  338. package/plugin/bundler/farm/plugin.ts +2 -0
  339. package/plugin/bundler/parcel/optimizer.ts +1 -0
  340. package/plugin/bundler/parcel/plugin.ts +2 -0
  341. package/plugin/bundler/rspack/plugin.ts +1 -0
  342. package/plugin/bundler/vite/plugin.ts +5 -9
  343. package/plugin/bundler/vite/state.ts +11 -6
  344. package/plugin/bundler/webpack/plugin.ts +2 -1
  345. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  346. package/plugin/nextjs/plugin.ts +249 -35
  347. package/plugin/nextjs/types.ts +1 -2
  348. package/plugin/nextjs/utils.ts +121 -0
  349. package/plugin/utils/compiler.ts +2 -0
  350. package/plugin/utils/runtimeEntry.ts +15 -2
  351. package/presets/tailwind/classname/index.ts +2 -0
  352. package/presets/tailwind/classname/transform.ts +239 -0
  353. package/presets/tailwind/classname/types.ts +124 -0
  354. package/presets/tailwind/index.ts +5 -0
  355. package/presets/tailwind/selectors.ts +27 -0
  356. package/presets/tailwind/style/index.ts +2 -0
  357. package/presets/tailwind/style/transform.ts +436 -0
  358. package/presets/tailwind/style/types.ts +346 -0
  359. package/presets/tailwind/theme.ts +479 -0
  360. package/presets/tailwind/types.ts +147 -0
  361. package/runtime/adapter/utils.ts +120 -0
  362. package/runtime/core/cache/combine.ts +76 -28
  363. package/runtime/core/cache/combineRuntime.ts +4 -0
  364. package/runtime/core/cache/index.ts +2 -1
  365. package/runtime/core/cache/item.ts +32 -13
  366. package/runtime/core/cache/itemWithResolver.ts +44 -0
  367. package/runtime/core/cache/pool.ts +16 -31
  368. package/runtime/core/cache/prop.ts +10 -8
  369. package/runtime/core/cache/result.ts +2 -2
  370. package/runtime/core/cache/stateItem.ts +16 -1
  371. package/runtime/core/cache/token.ts +20 -0
  372. package/runtime/core/cache/tokenValues.ts +19 -11
  373. package/runtime/core/combinedStyle.ts +4 -4
  374. package/runtime/extract/combineStyle.ts +211 -0
  375. package/runtime/extract/getClassName.ts +55 -23
  376. package/runtime/extract/index.ts +4 -2
  377. package/runtime/extract/token.ts +41 -0
  378. package/runtime/extract/tokenResolver.ts +17 -0
  379. package/runtime/index.ts +8 -1
  380. package/runtime/rsc/getClassName.ts +4 -0
  381. package/runtime/rsc/observer.ts +4 -0
  382. package/runtime/rsc/styleStore.ts +18 -7
  383. package/runtime/sheet/rule.ts +16 -12
  384. package/runtime/sheet/rules.ts +8 -3
  385. package/runtime/style/scope.ts +0 -24
  386. package/runtime/style/style.ts +181 -6
  387. package/runtime/types.ts +6 -4
  388. package/sheet/dev/dev_layer.ts +18 -7
  389. package/sheet/dev/dev_sort.ts +45 -11
  390. package/sheet/prod.ts +18 -7
  391. package/sheet/types.ts +2 -0
  392. package/sheet/utils/layer.ts +33 -0
  393. package/style/classname.ts +47 -0
  394. package/style/important.ts +19 -0
  395. package/style/index.ts +3 -0
  396. package/style/style.ts +47 -16
  397. package/style/theme.ts +4 -3
  398. package/style/token.ts +26 -21
  399. package/style/tokens.ts +18 -12
  400. package/style/transform.ts +41 -2
  401. package/style/types.ts +6 -4
  402. package/style/utils/expose.ts +4 -3
  403. package/style/value.ts +26 -11
  404. package/style/valueRef.ts +1 -1
  405. package/style/weight.ts +21 -0
  406. package/utils/global.ts +1 -3
  407. package/utils/hash.ts +4 -0
  408. package/utils/symbol.ts +3 -0
  409. package/atomic/layer/README.md +0 -116
  410. package/atomic/utils/css.ts +0 -49
  411. package/dist/assert-BGdigdr5.js.map +0 -1
  412. package/dist/className-C1Ht5Wvv.js +0 -144
  413. package/dist/className-C1Ht5Wvv.js.map +0 -1
  414. package/dist/className-DC2Cq8p3.js +0 -251
  415. package/dist/className-DC2Cq8p3.js.map +0 -1
  416. package/dist/compiler-DENc3a2R.mjs.map +0 -1
  417. package/dist/config-BryWDfQX.js +0 -25
  418. package/dist/config-BryWDfQX.js.map +0 -1
  419. package/dist/config-DKHXWhe1.js +0 -1
  420. package/dist/config-Di2VYYKV.js +0 -6
  421. package/dist/config-DloHOG6I.js +0 -13
  422. package/dist/config-DloHOG6I.js.map +0 -1
  423. package/dist/css-BowBszUt.js +0 -243
  424. package/dist/css-BowBszUt.js.map +0 -1
  425. package/dist/css-ByOrugEX.js +0 -805
  426. package/dist/css-ByOrugEX.js.map +0 -1
  427. package/dist/css-DcazYor9.js +0 -235
  428. package/dist/css-DcazYor9.js.map +0 -1
  429. package/dist/css_extra-DlOnsnR1.js +0 -8
  430. package/dist/css_extra-oIi3UEPK.js.map +0 -1
  431. package/dist/data-BsqOa5br.js +0 -473
  432. package/dist/data-BsqOa5br.js.map +0 -1
  433. package/dist/debug-BAw63qX6.js +0 -15
  434. package/dist/debug-BAw63qX6.js.map +0 -1
  435. package/dist/debug-DGki_v7g.js +0 -15
  436. package/dist/debug-DGki_v7g.js.map +0 -1
  437. package/dist/debug-n2aZQBSa.js.map +0 -1
  438. package/dist/dev-CcphAa3R.js.map +0 -1
  439. package/dist/dev-DfBbuLeE.js +0 -71
  440. package/dist/dev-DfBbuLeE.js.map +0 -1
  441. package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
  442. package/dist/extract-CzWJeQi8.js +0 -121
  443. package/dist/extract-CzWJeQi8.js.map +0 -1
  444. package/dist/extract-DEwSDJ9Z.js +0 -2
  445. package/dist/format-3nKBE_5t.js.map +0 -1
  446. package/dist/getClassName-BlvXHYuf.js.map +0 -1
  447. package/dist/global-CvfmFLsK.js +0 -11
  448. package/dist/global-CvfmFLsK.js.map +0 -1
  449. package/dist/jsx-CwTeyUxr.js +0 -39
  450. package/dist/jsx-CwTeyUxr.js.map +0 -1
  451. package/dist/jsx-D2BksHSv.js +0 -38
  452. package/dist/jsx-D2BksHSv.js.map +0 -1
  453. package/dist/layer-D1SaH07m.js +0 -94
  454. package/dist/layer-D1SaH07m.js.map +0 -1
  455. package/dist/loader-B5Kw0DD-.mjs.map +0 -1
  456. package/dist/misc-DCdYYyhK.mjs.map +0 -1
  457. package/dist/presets-BhXa232U.js +0 -108
  458. package/dist/presets-BhXa232U.js.map +0 -1
  459. package/dist/property-CnLFt5kx.js +0 -406
  460. package/dist/property-CnLFt5kx.js.map +0 -1
  461. package/dist/rules-9HSO1pxL.js.map +0 -1
  462. package/dist/runtime-CYqNCiaM.js.map +0 -1
  463. package/dist/shared-CBArHB9-.cjs.map +0 -1
  464. package/dist/style-B-6jHipw.js +0 -5
  465. package/dist/style-B1UUqjj5.js +0 -743
  466. package/dist/style-B1UUqjj5.js.map +0 -1
  467. package/dist/style-DgHbdbdF.js +0 -752
  468. package/dist/style-DgHbdbdF.js.map +0 -1
  469. package/dist/style-v2bf70TZ.js +0 -1269
  470. package/dist/style-v2bf70TZ.js.map +0 -1
  471. package/dist/styleStore-Dea_WVbr.js.map +0 -1
  472. package/dist/styleStore-DyNXBcUK.js.map +0 -1
  473. package/dist/token-CKXUECuU.js +0 -76
  474. package/dist/token-CKXUECuU.js.map +0 -1
  475. package/dist/token-u_tM-mtg.js +0 -204
  476. package/dist/token-u_tM-mtg.js.map +0 -1
  477. package/dist/utils-BbehLOby.js.map +0 -1
  478. package/dist/utils-CEaq_c-A.mjs +0 -97
  479. package/dist/utils-CEaq_c-A.mjs.map +0 -1
  480. package/dist/utils-CWNHx4EC.js +0 -170
  481. package/dist/utils-CWNHx4EC.js.map +0 -1
  482. package/dist/utils-D7FAOyg6.js.map +0 -1
  483. package/dist/value-BR4e2MKt.js +0 -910
  484. package/dist/value-BR4e2MKt.js.map +0 -1
  485. package/dist/value-E8rEv2Oe.js +0 -136
  486. package/dist/value-E8rEv2Oe.js.map +0 -1
  487. package/dist/valueRef-lshFk1Cs.js +0 -16
  488. package/dist/valueRef-lshFk1Cs.js.map +0 -1
  489. package/dist/webpack-Dh6lox2l.mjs.map +0 -1
  490. package/dist/withTokens-LRidu3Vc.js +0 -95
  491. package/dist/withTokens-LRidu3Vc.js.map +0 -1
@@ -11,11 +11,13 @@ import {
11
11
  import { clearResolverCache } from '../utils/file_resolver';
12
12
  import {
13
13
  getStyleExtractRuntimeImportPath,
14
+ getStyleRuntimeAdapterImportPath,
14
15
  getStyleRuntimeCssImportPath,
15
16
  getStyleRuntimeDevRscImportPath,
16
17
  getStyleRuntimeImportPath,
17
18
  } from '../utils/imports';
18
19
  import { createCompilerCache } from './cache';
20
+ import { CompilerRuntimeMode } from './constants';
19
21
  import type {
20
22
  CompilerInvalidateFileInfo,
21
23
  CompilerOptions,
@@ -26,13 +28,6 @@ import type {
26
28
  TransformExtractResult,
27
29
  } from './types';
28
30
 
29
- export enum CompilerRuntimeMode {
30
- Dev = 'dev',
31
- Prod = 'prod',
32
- RscDev = 'rsc-dev',
33
- RscProd = 'rsc-prod',
34
- }
35
-
36
31
  export type CompilerArgs = {
37
32
  projectDir: string;
38
33
  cacheDir: string;
@@ -53,6 +48,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
53
48
  return rewriteTransformResult(
54
49
  transformDebug(internal, args, { tracer }),
55
50
  internal.runtimeMode,
51
+ args.code,
56
52
  );
57
53
  };
58
54
 
@@ -60,6 +56,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
60
56
  const debugResult = rewriteTransformResult(
61
57
  transformDebug(internal, args, { tracer }),
62
58
  internal.runtimeMode,
59
+ args.code,
63
60
  );
64
61
  if (!debugResult) return null;
65
62
 
@@ -104,7 +101,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
104
101
  return rewriteTransformResult({
105
102
  ...result,
106
103
  rules: collector.getItems().slice(startIndex),
107
- }, internal.runtimeMode);
104
+ }, internal.runtimeMode, args.code);
108
105
  };
109
106
 
110
107
  const getExtractedCss = () => {
@@ -145,25 +142,46 @@ function createCompilerInternal(args: CompilerArgs, options: CompilerOptions) {
145
142
  function rewriteTransformResult<Result extends { code: string; }>(
146
143
  result: Result | null,
147
144
  runtimeMode: CompilerRuntimeMode | null,
145
+ sourceCode: string,
148
146
  ) {
149
147
  if (!result || !runtimeMode) return result;
150
148
 
151
149
  return {
152
150
  ...result,
153
- code: rewriteCompilerRuntimeImports(result.code, runtimeMode),
151
+ code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode),
154
152
  };
155
153
  }
156
154
 
157
- function rewriteCompilerRuntimeImports(code: string, runtimeMode: CompilerRuntimeMode) {
155
+ function rewriteCompilerRuntimeImports(
156
+ code: string,
157
+ runtimeMode: CompilerRuntimeMode,
158
+ sourceCode: string,
159
+ ) {
160
+ const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
161
+
158
162
  return rewriteImportSources(
159
163
  code,
160
- (source) => getCompilerRuntimeImportSource(source, runtimeMode),
164
+ (source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode),
161
165
  );
162
166
  }
163
167
 
164
- function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRuntimeMode) {
165
- if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(runtimeMode);
166
- if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(runtimeMode);
168
+ function getImportRuntimeMode(runtimeMode: CompilerRuntimeMode, sourceCode: string) {
169
+ if (runtimeMode === CompilerRuntimeMode.RscDev && hasUseClientDirective(sourceCode)) {
170
+ return CompilerRuntimeMode.Dev;
171
+ }
172
+
173
+ return runtimeMode;
174
+ }
175
+
176
+ function getCompilerRuntimeImportSource(
177
+ source: string,
178
+ runtimeMode: CompilerRuntimeMode,
179
+ importRuntimeMode: CompilerRuntimeMode,
180
+ ) {
181
+ if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(importRuntimeMode);
182
+ const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
183
+ if (adapterImportPath) return adapterImportPath;
184
+ if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(importRuntimeMode);
167
185
  if (source === STYLE_EXTRACT_RUNTIME_IMPORT_PATH) return getStyleExtractRuntimeImportPath(runtimeMode);
168
186
  if (runtimeMode === CompilerRuntimeMode.RscDev && source === STYLE_DEV_RSC_IMPORT_PATH) {
169
187
  return getStyleRuntimeDevRscImportPath(runtimeMode);
@@ -171,3 +189,59 @@ function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRun
171
189
 
172
190
  return null;
173
191
  }
192
+
193
+ function hasUseClientDirective(code: string) {
194
+ let index = 0;
195
+
196
+ while (index < code.length) {
197
+ index = skipWhitespaceAndComments(code, index);
198
+
199
+ const quote = code[index];
200
+ if (quote !== '"' && quote !== "'") return false;
201
+
202
+ const end = code.indexOf(quote, index + 1);
203
+ if (end < 0) return false;
204
+
205
+ const directive = code.slice(index + 1, end);
206
+ index = skipWhitespaceAndComments(code, end + 1);
207
+
208
+ if (code[index] === ';') {
209
+ index += 1;
210
+ } else if (code[index] && code[index] !== '\n' && code[index] !== '\r') {
211
+ return false;
212
+ }
213
+
214
+ if (directive === 'use client') return true;
215
+ }
216
+
217
+ return false;
218
+ }
219
+
220
+ function skipWhitespaceAndComments(code: string, index: number) {
221
+ let next = index;
222
+
223
+ while (next < code.length) {
224
+ const char = code[next];
225
+
226
+ if (char === ' ' || char === '\t' || char === '\n' || char === '\r') {
227
+ next += 1;
228
+ continue;
229
+ }
230
+
231
+ if (char === '/' && code[next + 1] === '/') {
232
+ const lineEnd = code.indexOf('\n', next + 2);
233
+ next = lineEnd < 0 ? code.length : lineEnd + 1;
234
+ continue;
235
+ }
236
+
237
+ if (char === '/' && code[next + 1] === '*') {
238
+ const commentEnd = code.indexOf('*/', next + 2);
239
+ next = commentEnd < 0 ? code.length : commentEnd + 2;
240
+ continue;
241
+ }
242
+
243
+ break;
244
+ }
245
+
246
+ return next;
247
+ }
@@ -0,0 +1,6 @@
1
+ export enum CompilerRuntimeMode {
2
+ Dev = 'dev',
3
+ Prod = 'prod',
4
+ RscDev = 'rsc-dev',
5
+ RscProd = 'rsc-prod',
6
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './cache';
2
2
  export * from './compiler';
3
+ export * from './constants';
3
4
  export * from './types';
@@ -1,14 +1,15 @@
1
+ import type { StyleCheckOptions } from '../../config/config/check';
1
2
  import type { CssConfig } from '../../config/config/css';
2
3
  import type { DevRuntimeOptions } from '../../config/config/dev';
3
4
  import type { CheckSelectorMode } from '../../config/types';
4
5
  import type { ReplaceProps } from '../../utils/type';
6
+ import type { CompilerCssPropOptions } from '../cssProp';
5
7
  import type { CssExtractRule } from '../extract';
6
8
  import type { BabelTransformSourceMap } from '../transform/utils/babel';
7
9
  import type { ImportSource } from '../utils/import_source';
8
10
  import type { GetSourcemapFilePathFn } from '../utils/sourcemap';
9
11
 
10
12
  export type CompilerCssOptions = Partial<CssConfig> & {
11
- localClassName?: boolean;
12
13
  debugClassName?: boolean;
13
14
  };
14
15
 
@@ -20,7 +21,9 @@ export type DevSourcemapMode = 'sourceUrl' | 'sourceContent' | 'sidecarServer';
20
21
 
21
22
  export type CompilerOptions = {
22
23
  hoist?: boolean;
24
+ check?: StyleCheckOptions;
23
25
  css?: CompilerCssOptions;
26
+ cssProp?: false | CompilerCssPropOptions;
24
27
  dev?: CompilerDevOptions;
25
28
 
26
29
  importSources?: ImportSource[];
@@ -0,0 +1,21 @@
1
+ export type CompilerCssPropOptions = {
2
+ adapter: string;
3
+ };
4
+
5
+ const CssPropSolid: CompilerCssPropOptions = {
6
+ adapter: '@fluentic/style/adapter/solid',
7
+ };
8
+
9
+ const CssPropPreact: CompilerCssPropOptions = {
10
+ adapter: '@fluentic/style/adapter/preact',
11
+ };
12
+
13
+ const CssPropReact: CompilerCssPropOptions = {
14
+ adapter: '@fluentic/style/adapter/react',
15
+ };
16
+
17
+ export const CssPropPresets = {
18
+ Solid: CssPropSolid,
19
+ Preact: CssPropPreact,
20
+ React: CssPropReact,
21
+ };
@@ -1,13 +1,11 @@
1
- import { compareLayerPriority, getLayerBundleCss } from '../../atomic/layer';
2
- import type { CssConfig } from '../../config/config/css';
1
+ import { compareLayerPriority, getLayerBlockCss, getLayerOrderCss } from '../../atomic/layer';
2
+ import { type CssConfig, isStyleLayerEnabled } from '../../config/config/css';
3
3
  import { DEFAULT_CONFIG } from '../utils/constants';
4
4
  import type { CssExtractRule } from './types';
5
5
 
6
- type CssOptions = Pick<CssConfig, 'layers' | 'layerNamespace'>;
6
+ type CssOptions = Pick<CssConfig, 'layer' | 'layers' | 'layerNamespace'>;
7
7
 
8
- export type CompilerExtractCssArgs = Partial<CssOptions> & {
9
- layer?: boolean;
10
- };
8
+ export type CompilerExtractCssArgs = Partial<CssOptions>;
11
9
 
12
10
  export function extractCss(
13
11
  items: CssExtractRule[],
@@ -34,18 +32,48 @@ function getExtractedCssItems(
34
32
  css.push(item);
35
33
  }
36
34
 
37
- if (args.layer === false || !css.length) {
38
- return css.map((item) => item.css).join('\n');
39
- }
35
+ if (!css.length) return '';
40
36
 
41
37
  const defaults = DEFAULT_CONFIG;
42
38
 
43
39
  const layerNamespace = args.layerNamespace ?? defaults.layerNamespace ?? '';
44
40
  const layers = args.layers ?? defaults.layers ?? [];
41
+ const styleLayer = isStyleLayerEnabled(args.layer ?? defaults.layer);
42
+ const sheetLayerName = layerNamespace ? layerNamespace + '.sheet' : 'sheet';
43
+ const styleItems: string[] = [];
44
+ const sheetItems: string[] = [];
45
+ const unlayeredItems: string[] = [];
46
+
47
+ for (let i = 0, len = css.length; i < len; i++) {
48
+ const item = css[i];
49
+ if (item.layer === 'sheet') {
50
+ sheetItems.push(item.css);
51
+ } else if (item.layer === false || !styleLayer) {
52
+ unlayeredItems.push(item.css);
53
+ } else {
54
+ styleItems.push(item.css);
55
+ }
56
+ }
57
+
58
+ const styleLayerName = sheetItems.length && layerNamespace
59
+ ? layerNamespace + '.style'
60
+ : layerNamespace;
61
+
62
+ const layerNames = [
63
+ styleItems.length ? styleLayerName : '',
64
+ sheetItems.length ? sheetLayerName : '',
65
+ ].filter(Boolean);
66
+ const output: string[] = [];
67
+ const layerOrder = getLayerOrderCss(layers, layerNames);
68
+
69
+ if (layerOrder) output.push(layerOrder);
70
+ if (styleItems.length) {
71
+ output.push(getLayerBlockCss(styleLayerName, '\n' + styleItems.join('\n') + '\n'));
72
+ }
73
+ if (sheetItems.length) {
74
+ output.push(getLayerBlockCss(sheetLayerName, '\n' + sheetItems.join('\n') + '\n'));
75
+ }
76
+ output.push(...unlayeredItems);
45
77
 
46
- return getLayerBundleCss(
47
- layers,
48
- layerNamespace,
49
- css.map((item) => item.css),
50
- );
78
+ return output.join('\n');
51
79
  }
@@ -26,6 +26,8 @@ export type CssExtractRule = {
26
26
  className: string;
27
27
  css: string;
28
28
  priority: LayerPriority;
29
+ important?: boolean;
30
+ layer?: 'sheet' | false;
29
31
  trace?: {
30
32
  filePath: string;
31
33
  line: number;
package/compiler/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './compiler';
2
+ export * from './cssProp';
2
3
  export * from './utils/sourcemap';
@@ -0,0 +1 @@
1
+ export { createCssPropPlugin } from './plugin';
@@ -0,0 +1,161 @@
1
+ import type { CompilerOptions } from '../../compiler/types';
2
+ import type { CompilerCssPropOptions } from '../../cssProp';
3
+ import type { BabelCore, BabelTypes, NodePath } from '../utils/babel';
4
+ import { babelPlugin } from '../utils/babel';
5
+
6
+ type PluginState = BabelCore.PluginPass & {
7
+ options: CompilerOptions;
8
+ mergeId: BabelTypes.Identifier | null;
9
+ programPath: NodePath<BabelTypes.Program> | null;
10
+ changed: boolean;
11
+ };
12
+
13
+ type PluginArgs = {
14
+ options: CompilerOptions;
15
+ };
16
+
17
+ export function createCssPropPlugin(args: PluginArgs) {
18
+ return babelPlugin<PluginState>((babel) => {
19
+ const { types: t } = babel;
20
+
21
+ return {
22
+ pre(this: PluginState) {
23
+ this.options = args.options;
24
+ this.mergeId = null;
25
+ this.programPath = null;
26
+ this.changed = false;
27
+ },
28
+ visitor: {
29
+ Program: {
30
+ enter(path: NodePath<BabelTypes.Program>, state: PluginState) {
31
+ state.programPath = path;
32
+ state.mergeId = path.scope.generateUidIdentifier('fluenticMergeJsxProps');
33
+ },
34
+ exit(path: NodePath<BabelTypes.Program>, state: PluginState) {
35
+ const options = getCssPropOptions(state.options);
36
+ if (!state.changed || !options || !state.mergeId) return;
37
+
38
+ path.unshiftContainer(
39
+ 'body',
40
+ t.importDeclaration([
41
+ t.importSpecifier(state.mergeId, t.identifier('mergeJsxProps')),
42
+ ], t.stringLiteral(options.adapter)),
43
+ );
44
+ },
45
+ },
46
+
47
+ JSXOpeningElement(path: NodePath<BabelTypes.JSXOpeningElement>, state: PluginState) {
48
+ const keyHoistedAttributes = hoistKeyAttributes(path.node.attributes);
49
+ if (keyHoistedAttributes) path.node.attributes = keyHoistedAttributes;
50
+
51
+ const options = getCssPropOptions(state.options);
52
+ if (!options || !state.mergeId) return;
53
+ if (!isIntrinsicElement(path.node.name)) return;
54
+ if (!hasCssAttribute(path.node.attributes)) return;
55
+
56
+ const keyAttributes = path.node.attributes.filter(isKeyAttribute);
57
+ const parts = path.node.attributes
58
+ .filter((attr) => !isKeyAttribute(attr))
59
+ .map((attr) => buildPart(t, attr));
60
+
61
+ path.node.attributes = [
62
+ ...keyAttributes,
63
+ t.jsxSpreadAttribute(t.callExpression(state.mergeId, [
64
+ t.arrayExpression(parts),
65
+ ])),
66
+ ];
67
+
68
+ state.changed = true;
69
+ },
70
+ },
71
+ };
72
+ });
73
+ }
74
+
75
+ function getCssPropOptions(options: CompilerOptions): CompilerCssPropOptions | null {
76
+ return options.cssProp || null;
77
+ }
78
+
79
+ function isIntrinsicElement(name: BabelTypes.JSXOpeningElement['name']) {
80
+ return name.type === 'JSXIdentifier' && /^[a-z]/.test(name.name);
81
+ }
82
+
83
+ function hasCssAttribute(attrs: readonly (BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute)[]) {
84
+ return attrs.some((attr) => {
85
+ return attr.type === 'JSXAttribute' &&
86
+ attr.name.type === 'JSXIdentifier' &&
87
+ attr.name.name === 'css';
88
+ });
89
+ }
90
+
91
+ function hoistKeyAttributes(
92
+ attrs: readonly (BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute)[],
93
+ ) {
94
+ const keyAttributes = attrs.filter(isKeyAttribute);
95
+ if (!keyAttributes.length) return null;
96
+
97
+ const firstKeyIndex = attrs.findIndex(isKeyAttribute);
98
+ const firstSpreadIndex = attrs.findIndex((attr) => attr.type === 'JSXSpreadAttribute');
99
+
100
+ if (firstSpreadIndex < 0 || firstKeyIndex < firstSpreadIndex) return null;
101
+
102
+ return [
103
+ ...keyAttributes,
104
+ ...attrs.filter((attr) => !isKeyAttribute(attr)),
105
+ ];
106
+ }
107
+
108
+ function isKeyAttribute(
109
+ attr: BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute,
110
+ ) {
111
+ return attr.type === 'JSXAttribute' &&
112
+ attr.name.type === 'JSXIdentifier' &&
113
+ attr.name.name === 'key';
114
+ }
115
+
116
+ function buildPart(
117
+ t: typeof BabelTypes,
118
+ attr: BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute,
119
+ ) {
120
+ if (attr.type === 'JSXSpreadAttribute') return attr.argument;
121
+
122
+ return t.objectExpression([
123
+ t.objectProperty(
124
+ getObjectKey(t, attr.name),
125
+ getAttributeValue(t, attr),
126
+ ),
127
+ ]);
128
+ }
129
+
130
+ function getObjectKey(
131
+ t: typeof BabelTypes,
132
+ name: BabelTypes.JSXAttribute['name'],
133
+ ) {
134
+ if (name.type === 'JSXIdentifier' && isValidIdentifierName(name.name)) {
135
+ return t.identifier(name.name);
136
+ }
137
+
138
+ return t.stringLiteral(getAttributeName(name));
139
+ }
140
+
141
+ function getAttributeName(name: BabelTypes.JSXAttribute['name']) {
142
+ if (name.type === 'JSXIdentifier') return name.name;
143
+ return `${name.namespace.name}:${name.name.name}`;
144
+ }
145
+
146
+ function getAttributeValue(
147
+ t: typeof BabelTypes,
148
+ attr: BabelTypes.JSXAttribute,
149
+ ) {
150
+ if (!attr.value) return t.booleanLiteral(true);
151
+ if (attr.value.type === 'StringLiteral') return t.stringLiteral(attr.value.value);
152
+ if (attr.value.type === 'JSXExpressionContainer') {
153
+ if (attr.value.expression.type === 'JSXEmptyExpression') return t.booleanLiteral(true);
154
+ return attr.value.expression;
155
+ }
156
+ return attr.value;
157
+ }
158
+
159
+ function isValidIdentifierName(name: string) {
160
+ return /^[$A-Z_a-z][$\w]*$/.test(name);
161
+ }
@@ -1,7 +1,7 @@
1
- import { SELECTOR_MERGE } from '../../../builder/data/selector';
2
1
  import { BUILDER_STATE } from '../../../builder/data/const';
3
- import { TRACE_STYLE, TRACE_VALUE, type DebugLoc } from '../../../builder/data/debug';
2
+ import { type DebugLoc, TRACE_STYLE, TRACE_VALUE } from '../../../builder/data/debug';
4
3
  import { isScopeData, isStyleData } from '../../../builder/data/is';
4
+ import { SELECTOR_MERGE } from '../../../builder/data/selector';
5
5
  import type { RuntimeItem } from '../../../builder/data/state';
6
6
  import type { CheckSelectorMode, SourcemapLocationMode } from '../../../config/types';
7
7
  import type { StyleFnMeta } from '../../../style/style';
@@ -11,12 +11,13 @@ import {
11
11
  DEBUG_SOURCE_CONTENT_VAR,
12
12
  DEBUG_SOURCE_URL_VAR,
13
13
  DEFAULT_CONFIG,
14
+ FN_CREATE_THEME,
14
15
  FN_STYLE_KEYFRAMES,
15
16
  FN_STYLE_MERGE,
16
17
  FN_STYLE_PLAIN,
17
18
  FN_STYLE_RAW,
18
19
  FN_STYLE_SCOPE,
19
- FN_CREATE_THEME,
20
+ FN_STYLE_SELECTOR,
20
21
  IMPORT_PATHS,
21
22
  } from '../../utils/constants';
22
23
  import { createImportSourceMatcher, type ImportSourceMatcher } from '../../utils/import_source';
@@ -34,6 +35,7 @@ import {
34
35
  annotateThemeCall,
35
36
  annotateTokenDeclaration,
36
37
  getImportedName,
38
+ getObjectPropertyKey,
37
39
  isStyleChainCall,
38
40
  } from '../syntax';
39
41
  import type { BabelCore, BabelTypes, NodePath } from '../utils/babel';
@@ -181,6 +183,10 @@ export function createDebugPlugin(args: PluginArgs) {
181
183
  const sourceContentRef = sourceContent
182
184
  ? getSourceContentId(t, state)
183
185
  : null;
186
+ const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
187
+ const isClassNameCall = rootName
188
+ ? state.styleMetas.get(rootName)?.mode === 'ClassName'
189
+ : false;
184
190
 
185
191
  path.node.arguments.push(
186
192
  buildDebugDataObject(
@@ -192,6 +198,7 @@ export function createDebugPlugin(args: PluginArgs) {
192
198
  options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat,
193
199
  getDebugStyleArg(t, path, state, options.dev?.sourcemapMode ?? 'style'),
194
200
  getDebugCallLoc(path, state),
201
+ isClassNameCall,
195
202
  ),
196
203
  );
197
204
  },
@@ -547,12 +554,13 @@ function getDebugStyleArg(
547
554
  ) {
548
555
  const arg = getStyleObjectArg(path, state);
549
556
  if (!arg) return arg;
557
+ const meta = getStyleCallMeta(path, state);
550
558
 
551
559
  if (arg.type !== 'ObjectExpression') {
552
560
  return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
553
561
  }
554
562
 
555
- return flattenDebugObjectExpression(
563
+ const flattened = flattenDebugObjectExpression(
556
564
  t,
557
565
  arg,
558
566
  path,
@@ -560,6 +568,8 @@ function getDebugStyleArg(
560
568
  sourcemapTrace,
561
569
  new Set(),
562
570
  );
571
+
572
+ return appendTransformDebugFieldAliases(t, flattened, meta, state);
563
573
  }
564
574
 
565
575
  function getDebugCallLoc(
@@ -576,6 +586,11 @@ function getStyleObjectArg(
576
586
  state: PluginState,
577
587
  ) {
578
588
  const methodName = getSelectorMethodName(path.node.callee);
589
+
590
+ if (methodName === FN_STYLE_SELECTOR) {
591
+ return path.node.arguments[1];
592
+ }
593
+
579
594
  const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
580
595
  const selector = methodName && rootName
581
596
  ? state.styleMetas.get(rootName)?.selectors[methodName]
@@ -589,6 +604,14 @@ function getStyleObjectArg(
589
604
  return path.node.arguments[styleArgIndex];
590
605
  }
591
606
 
607
+ function getStyleCallMeta(
608
+ path: NodePath<BabelTypes.CallExpression>,
609
+ state: PluginState,
610
+ ) {
611
+ const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
612
+ return rootName ? state.styleMetas.get(rootName) ?? null : null;
613
+ }
614
+
592
615
  function isSelectorStyleCall(
593
616
  path: NodePath<BabelTypes.CallExpression>,
594
617
  state: PluginState,
@@ -831,6 +854,72 @@ function flattenDebugObjectExpression(
831
854
  return t.objectExpression(properties);
832
855
  }
833
856
 
857
+ function appendTransformDebugFieldAliases(
858
+ t: typeof BabelTypes,
859
+ node: BabelTypes.ObjectExpression,
860
+ meta: StyleFnMeta | null,
861
+ state: PluginState,
862
+ ) {
863
+ if (!meta || meta.mode !== 'StyleObject' || !meta.transform) return node;
864
+
865
+ const existing = new Set<string>();
866
+ for (const property of node.properties) {
867
+ if (property.type !== 'ObjectProperty' || property.computed) continue;
868
+ const key = getObjectPropertyKey(property);
869
+ if (key) existing.add(key);
870
+ }
871
+
872
+ const aliases: BabelTypes.ObjectProperty[] = [];
873
+
874
+ for (const property of node.properties) {
875
+ if (property.type !== 'ObjectProperty' || property.computed) continue;
876
+
877
+ const key = getObjectPropertyKey(property);
878
+ if (!key) continue;
879
+
880
+ const value = evaluateNode(property.value, getDebugEvalScope(state));
881
+ if (!value.ok) continue;
882
+
883
+ let transformed: Record<string, unknown>;
884
+ try {
885
+ transformed = meta.transform.transform({ [key]: value.value }) as Record<string, unknown>;
886
+ } catch {
887
+ continue;
888
+ }
889
+
890
+ for (const transformedKey of Object.keys(transformed)) {
891
+ if (existing.has(transformedKey)) continue;
892
+
893
+ existing.add(transformedKey);
894
+ aliases.push(createDebugFieldAlias(t, transformedKey, property));
895
+ }
896
+ }
897
+
898
+ if (!aliases.length) return node;
899
+
900
+ return t.objectExpression([
901
+ ...node.properties,
902
+ ...aliases,
903
+ ]);
904
+ }
905
+
906
+ function createDebugFieldAlias(
907
+ t: typeof BabelTypes,
908
+ key: string,
909
+ source: BabelTypes.ObjectProperty,
910
+ ) {
911
+ const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral()) as DebugTraceProperty;
912
+ const sourceTrace = source as DebugTraceProperty;
913
+
914
+ alias.loc = source.loc;
915
+ alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
916
+ alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
917
+ alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
918
+ alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
919
+
920
+ return alias;
921
+ }
922
+
834
923
  function resolveDebugSpreadObject(
835
924
  t: typeof BabelTypes,
836
925
  spread: BabelTypes.SpreadElement,
@@ -1,4 +1,5 @@
1
1
  import type { CompilerInternal, TransformDebugArgs, TransformDebugResult } from '../../compiler';
2
+ import { createCssPropPlugin } from '../cssProp';
2
3
  import type { ExtractTracer } from '../extract/plugin';
3
4
  import { babelTransform } from '../utils/babel';
4
5
  import { createDebugPlugin } from './plugin';
@@ -34,7 +35,7 @@ export function transformDebug(
34
35
  code: args.code,
35
36
  filePath: args.filePath,
36
37
  sourcemap: args.sourcemap,
37
- plugins: [plugin],
38
+ plugins: [plugin, createCssPropPlugin({ options })],
38
39
  retainLines: true,
39
40
  });
40
41