@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
@@ -2,13 +2,14 @@ import type { NextConfig } from 'next';
2
2
  import { PHASE_DEVELOPMENT_SERVER } from 'next/constants';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import type { Compiler, RuleSetRule } from 'webpack';
5
+ import type { Compilation, Compiler, RuleSetRule } from 'webpack';
6
6
  import type { BuildConfig, BuildDevConfig } from '../../config/build';
7
7
  import { isPromiseLike } from '../../utils/object';
8
8
  import {
9
9
  BUNDLE_CSS_FILE,
10
10
  createCompilerId,
11
11
  createFileCssCache,
12
+ createFileCssContentHash,
12
13
  createPluginCompiler,
13
14
  DEFAULT_TRANSFORM_EXCLUDE,
14
15
  DEFAULT_TRANSFORM_INCLUDE,
@@ -42,6 +43,7 @@ import {
42
43
  createNextBuildConfig,
43
44
  createNextBuildDevConfig,
44
45
  createNextConfigHash,
46
+ createSerializableImportSources,
45
47
  getNextCacheDir,
46
48
  getNextPrecollectCacheSubdir,
47
49
  getTransformLoaderPath,
@@ -49,15 +51,16 @@ import {
49
51
  type NextLoaderState,
50
52
  nextRegistry,
51
53
  removeUndefinedValues,
52
- replaceCssMarkerAsset,
53
54
  resolveNextCompilerOptions,
55
+ replaceCssMarkerAsset,
54
56
  } from './utils';
55
57
 
58
+ export { CssPropPresets } from '../utils';
59
+ export type { CompilerCssPropOptions } from '../utils';
60
+
56
61
  export default plugin;
57
62
 
58
63
  const TURBOPACK_TRANSFORM_EXTENSIONS: readonly string[] = ['*.ts', '*.tsx', '*.js', '*.jsx'];
59
- const clearedPrecollectCacheRoots = new Set<string>();
60
-
61
64
  type NextPhaseState = {
62
65
  buildConfig: BuildConfig;
63
66
  buildDevConfig: BuildDevConfig | null;
@@ -107,17 +110,20 @@ function createNextConfig(
107
110
  phaseState.configHash = createNextConfigHash(
108
111
  phaseState.buildConfig,
109
112
  phaseState.dev,
113
+ options.importSources,
110
114
  );
111
115
 
112
116
  let sidecar: SourcemapSidecar | null = null;
113
117
 
114
118
  if (dev) {
115
- const route: SidecarRouteHandler = () => ({
119
+ const getDevCss = () => cssCache.getCss({
120
+ ...phaseState.buildConfig.css,
121
+ configHash: phaseState.configHash,
122
+ });
123
+
124
+ const route: SidecarRouteHandler = async () => ({
116
125
  contentType: 'text/css; charset=utf-8',
117
- body: cssCache.getCss({
118
- ...phaseState.buildConfig.css,
119
- configHash: phaseState.configHash,
120
- }),
126
+ body: await waitForDevCss(getDevCss),
121
127
  });
122
128
 
123
129
  sidecar = getSourcemapSidecar({
@@ -143,6 +149,22 @@ function createNextConfig(
143
149
  : finish();
144
150
  }
145
151
 
152
+ async function waitForDevCss(getCss: () => string) {
153
+ let css = getCss();
154
+ if (css) return css;
155
+
156
+ const deadline = Date.now() + 5000;
157
+
158
+ while (Date.now() < deadline) {
159
+ await new Promise((resolve) => setTimeout(resolve, 25));
160
+
161
+ css = getCss();
162
+ if (css) return css;
163
+ }
164
+
165
+ return css;
166
+ }
167
+
146
168
  function createFluenticNextConfigResolved(
147
169
  nextConfig: NextConfig,
148
170
  options: PluginOptions,
@@ -159,7 +181,7 @@ function createFluenticNextConfigResolved(
159
181
  const projectDir = process.cwd();
160
182
 
161
183
  const devCssHref = dev && sidecar
162
- ? sidecar.getRouteUrl(DEV_CSS_ROUTE)
184
+ ? DEV_CSS_ROUTE
163
185
  : null;
164
186
 
165
187
  const turbopackCompilerId = createCompilerId(NEXT_COMPILER_IDS.turbopack);
@@ -201,6 +223,7 @@ function createFluenticNextConfigResolved(
201
223
  return {
202
224
  ...nextConfig,
203
225
  env: nextConfig.env,
226
+ rewrites: createNextRewrites(nextConfig.rewrites, dev && sidecar ? sidecar : null),
204
227
  compiler: {
205
228
  ...originalCompiler,
206
229
  define: {
@@ -243,6 +266,7 @@ function createFluenticNextConfigResolved(
243
266
  cssAliases: turbopackCssAliases,
244
267
  dev,
245
268
  devCssHref,
269
+ options,
246
270
  projectDir,
247
271
  }),
248
272
  webpack(config: WebpackConfiguration, context: WebpackConfigContext) {
@@ -299,6 +323,7 @@ function createFluenticNextConfigResolved(
299
323
  cssOutput: options.cssOutput,
300
324
  cssCache,
301
325
  dev: context.dev,
326
+ filter: state.filter,
302
327
  sidecar,
303
328
  });
304
329
 
@@ -307,6 +332,45 @@ function createFluenticNextConfigResolved(
307
332
  };
308
333
  }
309
334
 
335
+ function createNextRewrites(
336
+ originalRewrites: NextConfig['rewrites'],
337
+ sidecar: SourcemapSidecar | null,
338
+ ): NextConfig['rewrites'] {
339
+ if (!sidecar) return originalRewrites;
340
+
341
+ return async () => {
342
+ await sidecar.ensureStarted();
343
+
344
+ const devCssRewrite = {
345
+ source: DEV_CSS_ROUTE,
346
+ destination: sidecar.getRouteUrl(DEV_CSS_ROUTE),
347
+ };
348
+
349
+ const original = await originalRewrites?.();
350
+
351
+ if (!original) {
352
+ return {
353
+ beforeFiles: [devCssRewrite],
354
+ afterFiles: [],
355
+ fallback: [],
356
+ };
357
+ }
358
+
359
+ if (Array.isArray(original)) {
360
+ return {
361
+ beforeFiles: [devCssRewrite],
362
+ afterFiles: original,
363
+ fallback: [],
364
+ };
365
+ }
366
+
367
+ return {
368
+ ...original,
369
+ beforeFiles: [devCssRewrite, ...(original.beforeFiles ?? [])],
370
+ };
371
+ };
372
+ }
373
+
310
374
  function getImportableCssCacheDir(projectDir: string) {
311
375
  return path.join(projectDir, PLUGIN_CACHE_DIR);
312
376
  }
@@ -322,6 +386,7 @@ function createTurbopackConfig(
322
386
  cssAliases: Record<string, string>;
323
387
  dev: boolean;
324
388
  devCssHref: string | null;
389
+ options: PluginOptions;
325
390
  projectDir: string;
326
391
  },
327
392
  ): TurbopackConfig {
@@ -351,12 +416,16 @@ function mergeTurbopackRules(
351
416
  cssAliases: Record<string, string>;
352
417
  dev: boolean;
353
418
  devCssHref: string | null;
419
+ options: PluginOptions;
354
420
  projectDir: string;
355
421
  },
356
422
  ): TurbopackRules {
423
+ const compilerOptions = createSerializableTurbopackCompilerOptions(args.options);
424
+
357
425
  const loaderItem: TurbopackLoaderItem = {
358
426
  loader: LOADER_IMPORT_PATH,
359
427
  options: removeUndefinedValues({
428
+ ...compilerOptions,
360
429
  buildConfig: args.buildConfig,
361
430
  buildDevConfig: args.buildDevConfig,
362
431
  cacheDir: args.cacheDir,
@@ -379,6 +448,55 @@ function mergeTurbopackRules(
379
448
  return nextRules as TurbopackRules;
380
449
  }
381
450
 
451
+ function createSerializableTurbopackCompilerOptions(
452
+ options: PluginOptions,
453
+ ): Partial<PluginOptions> {
454
+ return removeUndefinedValues({
455
+ css: options.css,
456
+ cssProp: options.cssProp,
457
+ dev: options.dev,
458
+ hoist: options.hoist,
459
+ importSources: createSerializableTurbopackImportSources(options.importSources),
460
+ });
461
+ }
462
+
463
+ function createSerializableTurbopackImportSources(
464
+ importSources: PluginOptions['importSources'],
465
+ ): PluginOptions['importSources'] | undefined {
466
+ const serialized = createSerializableImportSources(importSources);
467
+ if (!serialized) return undefined;
468
+
469
+ const result = serialized.filter((entry) => isSerializableLoaderValue(entry));
470
+ return result.length ? result : undefined;
471
+ }
472
+
473
+ function isSerializableLoaderValue(value: unknown): boolean {
474
+ if (value === null) return true;
475
+
476
+ const valueType = typeof value;
477
+
478
+ if (
479
+ valueType === 'string' ||
480
+ valueType === 'number' ||
481
+ valueType === 'boolean'
482
+ ) {
483
+ return true;
484
+ }
485
+
486
+ if (valueType !== 'object') return false;
487
+
488
+ if (Array.isArray(value)) {
489
+ return value.every((item) => isSerializableLoaderValue(item));
490
+ }
491
+
492
+ const prototype = Object.getPrototypeOf(value);
493
+ if (prototype !== Object.prototype && prototype !== null) return false;
494
+
495
+ return Object.values(value as Record<string, unknown>).every((item) =>
496
+ isSerializableLoaderValue(item),
497
+ );
498
+ }
499
+
382
500
  function prependTurbopackLoader(rule: unknown, loader: TurbopackLoaderItem) {
383
501
  if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
384
502
  return { loaders: [loader] };
@@ -475,6 +593,7 @@ function addLifecyclePlugin(
475
593
  cssOutput: PluginCssOutputOptions | undefined;
476
594
  cssCache: ReturnType<typeof createFileCssCache>;
477
595
  dev: boolean;
596
+ filter: NextLoaderState['filter'];
478
597
  sidecar: SourcemapSidecar | null;
479
598
  },
480
599
  ) {
@@ -482,11 +601,6 @@ function addLifecyclePlugin(
482
601
  apply(webpackCompiler: Compiler) {
483
602
  webpackCompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {
484
603
  await args.sidecar?.ensureStarted();
485
-
486
- if (!args.dev && !clearedPrecollectCacheRoots.has(args.cssCache.rootDir)) {
487
- clearedPrecollectCacheRoots.add(args.cssCache.rootDir);
488
- args.cssCache.clear();
489
- }
490
604
  });
491
605
 
492
606
  webpackCompiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (watchCompiler) => {
@@ -507,6 +621,8 @@ function addLifecyclePlugin(
507
621
  stage: webpackCompiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
508
622
  },
509
623
  async () => {
624
+ precollectProductionCssFromCompilation(args, compilation, webpackCompiler);
625
+
510
626
  const css = await transformCssOutput(
511
627
  args.cssCache.getCss({
512
628
  ...args.buildConfig.css,
@@ -530,3 +646,80 @@ function addLifecyclePlugin(
530
646
  },
531
647
  });
532
648
  }
649
+
650
+ function precollectProductionCssFromCompilation(
651
+ args: {
652
+ configHash: string;
653
+ compiler: NextLoaderState['compiler'];
654
+ cssCache: ReturnType<typeof createFileCssCache>;
655
+ dev: boolean;
656
+ filter: NextLoaderState['filter'];
657
+ },
658
+ compilation: Compilation,
659
+ webpackCompiler: Compiler,
660
+ ) {
661
+ if (args.dev) return;
662
+
663
+ const existingCss = args.cssCache.getCss({
664
+ configHash: args.configHash,
665
+ });
666
+
667
+ if (existingCss) return;
668
+
669
+ const files = getCompilationSourceFiles(compilation, webpackCompiler.context, args.filter);
670
+
671
+ for (const filePath of files) {
672
+ let code: string;
673
+
674
+ try {
675
+ code = fs.readFileSync(filePath, 'utf8');
676
+ } catch {
677
+ continue;
678
+ }
679
+
680
+ const result = args.compiler.compileExtract({
681
+ code,
682
+ filePath,
683
+ sourcemap: null,
684
+ });
685
+
686
+ if (!result) continue;
687
+
688
+ args.cssCache.setFileCss({
689
+ filePath,
690
+ contentHash: createFileCssContentHash(code),
691
+ configHash: args.configHash,
692
+ rules: result.rules,
693
+ });
694
+ }
695
+ }
696
+
697
+ function getCompilationSourceFiles(
698
+ compilation: Compilation,
699
+ projectDir: string,
700
+ filter: NextLoaderState['filter'],
701
+ ) {
702
+ const files = new Set<string>();
703
+ const dependencies = compilation.fileDependencies ?? new Set<string>();
704
+
705
+ for (const filePath of dependencies) {
706
+ if (!isProjectSourceFile(filePath, projectDir, filter)) continue;
707
+ files.add(path.normalize(filePath));
708
+ }
709
+
710
+ return [...files].sort();
711
+ }
712
+
713
+ function isProjectSourceFile(
714
+ filePath: string,
715
+ projectDir: string,
716
+ filter: NextLoaderState['filter'],
717
+ ) {
718
+ if (!path.isAbsolute(filePath)) return false;
719
+ if (!filePath.startsWith(projectDir + path.sep)) return false;
720
+ if (filePath.includes(`${path.sep}.next${path.sep}`)) return false;
721
+ if (filePath.includes(`${path.sep}.git${path.sep}`)) return false;
722
+ if (!filter(filePath)) return false;
723
+
724
+ return true;
725
+ }
@@ -1,5 +1,4 @@
1
1
  import type { NextConfig } from 'next';
2
- import type { PHASE_TYPE } from 'next/constants';
3
2
  import type { OmitProps } from '../../utils/type';
4
3
  import type { PluginOptions as BasePluginOptions } from '../utils';
5
4
 
@@ -12,7 +11,7 @@ export type NextConfigContext = {
12
11
  };
13
12
 
14
13
  export type NextConfigFunction = (
15
- phase: PHASE_TYPE,
14
+ phase: string,
16
15
  context: NextConfigContext,
17
16
  ) => MaybePromise<NextConfig>;
18
17
 
@@ -3,8 +3,10 @@ import { createRequire } from 'node:module';
3
3
  import path from 'node:path';
4
4
  import type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';
5
5
  import type { Compiler as PluginCompiler } from '../../compiler';
6
+ import type { ImportSource } from '../../compiler/utils/import_source';
6
7
  import { normalizePath } from '../../compiler/utils/path';
7
8
  import type { BuildConfig, BuildDevConfig } from '../../config/build';
9
+ import { getStyleFnMeta } from '../../style/style';
8
10
  import { createWebpackRegistry } from '../bundler/webpack/shared/registry';
9
11
  import type { FileCssCache } from '../utils/cache';
10
12
  import type { PluginOptions as BasePluginOptions } from '../utils/compiler';
@@ -69,15 +71,63 @@ export function createNextBuildDevConfig(options: PluginOptions): BuildDevConfig
69
71
  export function createNextConfigHash(
70
72
  buildConfig: BuildConfig,
71
73
  dev: boolean,
74
+ importSources?: readonly ImportSource[] | null,
72
75
  ) {
73
76
  const values = [
74
77
  dev ? 'dev' : 'prod',
75
78
  buildConfig.hoist ? 'hoist' : 'no-hoist',
79
+ JSON.stringify(createSerializableImportSources(importSources)),
76
80
  ];
77
81
 
78
82
  return createHash('sha256').update(values.join('\0')).digest('hex');
79
83
  }
80
84
 
85
+ export function createSerializableImportSources(
86
+ importSources: readonly ImportSource[] | null | undefined,
87
+ ): ImportSource[] | undefined {
88
+ if (!importSources?.length) return undefined;
89
+
90
+ const result: ImportSource[] = [];
91
+
92
+ for (const entry of importSources) {
93
+ if (entry.check) continue;
94
+
95
+ const source = serializeImportSourcePattern(entry.source);
96
+ const name = entry.name;
97
+ const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
98
+
99
+ if (!meta) continue;
100
+ if (entry.source !== undefined && source === undefined) continue;
101
+
102
+ result.push(removeUndefinedValues({
103
+ source,
104
+ name,
105
+ meta,
106
+ }));
107
+ }
108
+
109
+ return result.length ? result : undefined;
110
+ }
111
+
112
+ function serializeImportSourcePattern(
113
+ source: ImportSource['source'],
114
+ ): string | string[] | undefined {
115
+ if (source === undefined) return undefined;
116
+
117
+ if (Array.isArray(source)) {
118
+ const result: string[] = [];
119
+
120
+ for (const item of source) {
121
+ if (typeof item !== 'string') return undefined;
122
+ result.push(item);
123
+ }
124
+
125
+ return result;
126
+ }
127
+
128
+ return typeof source === 'string' ? source : undefined;
129
+ }
130
+
81
131
  export function resolveNextCompilerOptions(
82
132
  options: PluginOptions,
83
133
  sidecar: SourcemapSidecar | null,
@@ -7,6 +7,8 @@ import { createTransformFilter, normalizeModuleId, type TransformFilterOptions }
7
7
  import type { BundlerSourceMap } from './sourcemap';
8
8
 
9
9
  export type PluginCssOptions = CompilerCssOptions;
10
+ export { CssPropPresets } from '../../compiler';
11
+ export type { CompilerCssPropOptions } from '../../compiler';
10
12
 
11
13
  export type PluginOptions = CompilerOptions & TransformFilterOptions & {
12
14
  cacheDir?: string;
@@ -10,11 +10,11 @@ export function getStyleRuntimeMode(dev: boolean, rsc = false): CompilerRuntimeM
10
10
  return dev ? CompilerRuntimeMode.Dev : CompilerRuntimeMode.Prod;
11
11
  }
12
12
 
13
- export function getPluginBuildConfig(options: PluginOptions): BuildConfig {
13
+ export function getPluginBuildConfig(options: PluginOptions, dev = false): BuildConfig {
14
14
  const css: CompilerCssOptions = hasBuildConfig(options.css) ? options.css! : {};
15
15
 
16
16
  return {
17
- hoist: options.hoist !== false,
17
+ hoist: !dev && options.hoist !== false,
18
18
  css,
19
19
  };
20
20
  }
@@ -127,7 +127,7 @@ function classNameToStyle(className: TailwindClassName, theme: TailwindTheme): R
127
127
  if (className.startsWith('w-')) return { w: ref(className, 'w-', [theme.sizes, theme.spacing]) };
128
128
  if (className.startsWith('h-')) return { h: ref(className, 'h-', [theme.sizes, theme.spacing]) };
129
129
  if (className.startsWith('bg-')) return { bg: ref(className, 'bg-', theme.colors) };
130
- if (className.startsWith('text-')) return { text: ref(className, 'text-', [theme.fontSizes, theme.colors]) };
130
+ if (className.startsWith('text-')) return textStyle(className.slice('text-'.length), theme);
131
131
  if (className.startsWith('font-')) return { font: ref(className, 'font-', theme.fontWeights) };
132
132
  if (className.startsWith('leading-')) return { leading: ref(className, 'leading-', theme.lineHeights) };
133
133
  if (className.startsWith('rounded-')) return { rounded: ref(className, 'rounded-', theme.radii) };
@@ -151,6 +151,37 @@ function borderStyle(value: string, theme: TailwindTheme): Record<string, unknow
151
151
  return { borderColor: scaleRef(value, theme.colors) };
152
152
  }
153
153
 
154
+ function textStyle(value: string, theme: TailwindTheme): Record<string, unknown> {
155
+ if (value.startsWith('[') && value.endsWith(']')) {
156
+ const arbitrary = value.slice(1, -1).replace(/_/g, ' ');
157
+ const hinted = parseArbitraryTextHint(arbitrary);
158
+
159
+ if (hinted) return hinted;
160
+ if (isLikelyFontSize(arbitrary)) return { textSize: arbitrary };
161
+
162
+ return { text: arbitrary };
163
+ }
164
+
165
+ return { text: scaleRef(value, [theme.fontSizes, theme.colors]) };
166
+ }
167
+
168
+ function parseArbitraryTextHint(value: string): Record<string, unknown> | null {
169
+ const splitAt = value.indexOf(':');
170
+ if (splitAt < 1) return null;
171
+
172
+ const hint = value.slice(0, splitAt);
173
+ const textValue = value.slice(splitAt + 1);
174
+
175
+ if (hint === 'length' || hint === 'size') return { textSize: textValue };
176
+ if (hint === 'color') return { text: textValue };
177
+
178
+ return null;
179
+ }
180
+
181
+ function isLikelyFontSize(value: string) {
182
+ return /^(?:-?\d*\.?\d+(?:px|r?em|lh|vh|vw|vmin|vmax|%|ch|ex|cap|ic)|(?:calc|clamp|min|max)\()/.test(value);
183
+ }
184
+
154
185
  function scaleRef(value: string, scale?: TailwindScale | (TailwindScale | undefined)[]) {
155
186
  const scales = Array.isArray(scale) ? scale : [scale];
156
187
  const path = value.replace(/-/g, '.');
@@ -0,0 +1,120 @@
1
+ import type { ClassNameProps, ClassNameResult } from '../core/className';
2
+ import type { StyleProp } from '../types';
3
+
4
+ export type JsxCssPropStyleMode = 'react' | 'solid';
5
+
6
+ export type JsxCssPropMergeOptions = {
7
+ classProp: 'class' | 'className';
8
+ styleProp: 'style';
9
+ styleMode: JsxCssPropStyleMode;
10
+ preserveResultProps?: boolean;
11
+ };
12
+
13
+ export type JsxCssPropInput = Record<PropertyKey, unknown>;
14
+
15
+ export type GetClassNameFn = (
16
+ styleProp: StyleProp,
17
+ props?: ClassNameProps,
18
+ ) => ClassNameResult;
19
+
20
+ export function createMergeJsxProps(
21
+ getClassName: GetClassNameFn,
22
+ options: JsxCssPropMergeOptions,
23
+ ) {
24
+ return function mergeJsxProps(parts: readonly unknown[]) {
25
+ let props: JsxCssPropInput | null = null;
26
+ let cssProps: StyleProp[] | null = null;
27
+
28
+ for (let index = 0; index < parts.length; index++) {
29
+ const result = mergePart(props, parts[index]);
30
+ props = result.props;
31
+
32
+ if (result.css) {
33
+ if (!cssProps) cssProps = [];
34
+ cssProps.push(result.css);
35
+ }
36
+ }
37
+
38
+ return mergeCssProps(props ?? {}, cssProps, getClassName, options);
39
+ };
40
+ }
41
+
42
+ function mergePart(
43
+ props: JsxCssPropInput | null,
44
+ part: unknown,
45
+ ) {
46
+ if (!part) return { css: null, props };
47
+
48
+ const next = props ? { ...props } : {};
49
+ const attrs = part as JsxCssPropInput;
50
+ const css = attrs.css;
51
+
52
+ for (const key in attrs) {
53
+ if (key !== 'css') next[key] = attrs[key];
54
+ }
55
+
56
+ return {
57
+ css: css ? css as StyleProp : null,
58
+ props: next,
59
+ };
60
+ }
61
+
62
+ function mergeCssProps(
63
+ props: JsxCssPropInput,
64
+ cssProps: StyleProp[] | null,
65
+ getClassName: GetClassNameFn,
66
+ options: JsxCssPropMergeOptions,
67
+ ) {
68
+ if (!cssProps?.length) return props;
69
+
70
+ const className = getClassName(cssProps.length === 1 ? cssProps[0] : cssProps, {
71
+ className: getClassValue(props, options.classProp),
72
+ style: props[options.styleProp] as ClassNameProps['style'],
73
+ });
74
+
75
+ delete props.class;
76
+ delete props.className;
77
+
78
+ if (className.className !== undefined) {
79
+ props[options.classProp] = className.className;
80
+ }
81
+
82
+ if (className.style !== undefined) {
83
+ props[options.styleProp] = options.styleMode === 'solid'
84
+ ? toSolidStyle(className.style as Record<string, unknown>)
85
+ : className.style;
86
+ }
87
+
88
+ if (options.preserveResultProps) {
89
+ for (const key in className) {
90
+ if (key === 'className' || key === 'style') continue;
91
+
92
+ props[key] = className[key as keyof ClassNameResult];
93
+ }
94
+ }
95
+
96
+ return props;
97
+ }
98
+
99
+ function getClassValue(
100
+ props: JsxCssPropInput,
101
+ classProp: 'class' | 'className',
102
+ ) {
103
+ return (props[classProp] ?? props[classProp === 'class' ? 'className' : 'class']) as ClassNameProps['className'];
104
+ }
105
+
106
+ function toSolidStyle(style: Record<string, unknown>) {
107
+ const next: Record<string, unknown> = {};
108
+
109
+ for (const key in style) {
110
+ next[toCssPropertyName(key)] = style[key];
111
+ }
112
+
113
+ return next;
114
+ }
115
+
116
+ function toCssPropertyName(key: string) {
117
+ if (key.startsWith('--') || key.includes('-')) return key;
118
+
119
+ return key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
120
+ }
@@ -1,4 +1,6 @@
1
- import type { ScopeTargetData } from '../../../builder/data/data';
1
+ import { BUILDER_STATE } from '../../../builder/data/const';
2
+ import type { ScopeData, ScopeTargetData, SheetData } from '../../../builder/data/data';
3
+ import { isScopeData, isSheetData } from '../../../builder/data/is';
2
4
  import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../../builder/extract/withTokens';
3
5
  import { RUNTIME_CONFIG } from '../../../config/config/runtime';
4
6
  import type { Falsy, StyleItem } from '../../types';
@@ -10,6 +12,8 @@ import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues, type Toke
10
12
  export type CombinedStyleArg<T extends object> =
11
13
  | Falsy
12
14
  | StyleItem
15
+ | ScopeData
16
+ | SheetData
13
17
  | CombinedStyle<T>
14
18
  | readonly CombinedStyleArg<T>[];
15
19
 
@@ -94,16 +98,15 @@ function collectStyleArg<T extends object>(
94
98
  if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(arg)) {
95
99
  const bound = getExtractedTokenBoundData(arg);
96
100
 
97
- result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
98
-
99
101
  collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result, resolver);
102
+ result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
100
103
  return;
101
104
  }
102
105
 
103
106
  if (isCombinedStyle<T>(arg)) {
104
107
  if (getCombinedStyleStyles(arg) !== styles) {
105
108
  throw new TypeError(
106
- '[fluentic-style] combineStyle can only carry a combined style created from the same styles object.',
109
+ '[fluentic-style] combineStyle styles mismatch.',
107
110
  );
108
111
  }
109
112
 
@@ -117,5 +120,31 @@ function collectStyleArg<T extends object>(
117
120
  return;
118
121
  }
119
122
 
123
+ if (isSheetData(arg)) {
124
+ collectTokenOverrides(arg, result, resolver);
125
+ return;
126
+ }
127
+
128
+ if (isScopeData(arg)) {
129
+ collectTokenOverrides(arg, result, resolver);
130
+ return;
131
+ }
132
+
120
133
  result.items.push(arg as StyleItem);
121
134
  }
135
+
136
+ function collectTokenOverrides(
137
+ data: SheetData | ScopeData,
138
+ result: NormalizedStyleItems,
139
+ resolver: TokenValueResolver,
140
+ ) {
141
+ const items = data[BUILDER_STATE]?.items ?? [];
142
+
143
+ for (let i = 0, len = items.length; i < len; i++) {
144
+ const item = items[i];
145
+
146
+ if (resolver.is(item)) {
147
+ result.tokens = mergeTokenOverrides(result.tokens, [item], resolver);
148
+ }
149
+ }
150
+ }