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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/CHANGELOG.md +38 -16
  2. package/README.md +80 -23
  3. package/atomic/className.ts +3 -9
  4. package/atomic/debug/className/className.ts +0 -15
  5. package/atomic/element.ts +1 -1
  6. package/atomic/rule.ts +2 -2
  7. package/atomic/scope.ts +19 -0
  8. package/atomic/theme.ts +41 -2
  9. package/atomic/token.ts +4 -3
  10. package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
  11. package/atomic/utils/cssVar.ts +19 -0
  12. package/atomic/utils/debug.ts +1 -1
  13. package/builder/data/const.ts +1 -1
  14. package/builder/data/merge/style.ts +1 -1
  15. package/builder/extract/token.ts +30 -14
  16. package/builder/token/data.ts +30 -0
  17. package/builder/token/index.ts +3 -0
  18. package/builder/token/name.ts +54 -0
  19. package/builder/token/symbols.ts +6 -0
  20. package/compiler/compiler/types.ts +0 -1
  21. package/compiler/transform/debug/plugin.ts +79 -1
  22. package/compiler/transform/evaluator/evaluator.ts +76 -26
  23. package/compiler/transform/evaluator/tracer.ts +11 -1
  24. package/compiler/transform/extract/chain/chain.ts +8 -5
  25. package/compiler/transform/extract/plugin.ts +1 -1
  26. package/compiler/transform/extract/utils/replacement.ts +6 -1
  27. package/compiler/transform/extract/utils/state.ts +1 -0
  28. package/compiler/transform/extract/utils/theme.ts +6 -6
  29. package/compiler/transform/syntax/static_ids.ts +1 -1
  30. package/compiler/utils/constants.ts +0 -4
  31. package/config/build.ts +5 -2
  32. package/config/config/debug.ts +24 -1
  33. package/config/config/dev.ts +8 -0
  34. package/config/configure.ts +10 -2
  35. package/dev/config.ts +2 -3
  36. package/dialect/namedTokens.ts +22 -5
  37. package/dist/{className-W2kDyeVl.js → className-Do2Crx4b.js} +2 -3
  38. package/dist/{className-W2kDyeVl.js.map → className-Do2Crx4b.js.map} +1 -1
  39. package/dist/{style-CYXTs1iu.js → combine-C9vjpKCs.js} +45 -304
  40. package/dist/combine-C9vjpKCs.js.map +1 -0
  41. package/dist/combineStyle-DwAhsOmS.js +26 -0
  42. package/dist/combineStyle-DwAhsOmS.js.map +1 -0
  43. package/dist/compiler/index.mjs +1 -1
  44. package/dist/{compiler-BXcGyZUP.mjs → compiler-CE0ZgkdH.mjs} +274 -128
  45. package/dist/compiler-CE0ZgkdH.mjs.map +1 -0
  46. package/dist/config/index.js +2 -2
  47. package/dist/config-BE5D5x2N.js +2 -0
  48. package/dist/{config-CLYMN3_p.js → config-BtANtGAh.js} +10 -5
  49. package/dist/config-BtANtGAh.js.map +1 -0
  50. package/dist/{config-C1k9vUrM.js → config-CduqubI8.js} +8 -6
  51. package/dist/config-CduqubI8.js.map +1 -0
  52. package/dist/config-lJNLh7eM.js +6 -0
  53. package/dist/config-lJNLh7eM.js.map +1 -0
  54. package/dist/config-oKOjOTWi.js +7 -0
  55. package/dist/{config-DcYrUB-M.js.map → config-oKOjOTWi.js.map} +1 -1
  56. package/dist/{css-CohHH2tn.js → css-BewrRz3_.js} +3 -3
  57. package/dist/{css-CohHH2tn.js.map → css-BewrRz3_.js.map} +1 -1
  58. package/dist/{css-DfH4Gb1c.js → css-CiTI58yl.js} +294 -5
  59. package/dist/css-CiTI58yl.js.map +1 -0
  60. package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
  61. package/dist/css-GtUPEO9U.js.map +1 -0
  62. package/dist/{css-D_DL1yOz.js → css-Rc7ILf-3.js} +8 -9
  63. package/dist/{css-D_DL1yOz.js.map → css-Rc7ILf-3.js.map} +1 -1
  64. package/dist/css.js +1 -1
  65. package/dist/{css-CELBp6Gu.js → cssIdent-BsyUXNNk.js} +3 -23
  66. package/dist/cssIdent-BsyUXNNk.js.map +1 -0
  67. package/dist/cssVar-DGgQ2GIK.js +92 -0
  68. package/dist/cssVar-DGgQ2GIK.js.map +1 -0
  69. package/dist/{css_extra-9BZ_jVET.js → css_extra-BiG57TKN.js} +2 -2
  70. package/dist/{css_extra-9BZ_jVET.js.map → css_extra-BiG57TKN.js.map} +1 -1
  71. package/dist/{css_extra-DQdCrYoC.js → css_extra-DYtS3g6Z.js} +2 -2
  72. package/dist/{css_extra-DQdCrYoC.js.map → css_extra-DYtS3g6Z.js.map} +1 -1
  73. package/dist/{data-Ze8GNiJm.js → data-D7NFt4JG.js} +205 -11
  74. package/dist/data-D7NFt4JG.js.map +1 -0
  75. package/dist/{debug-DLmUG3Vh.js → debug-Cvpo5cVu.js} +4 -3
  76. package/dist/{debug-DLmUG3Vh.js.map → debug-Cvpo5cVu.js.map} +1 -1
  77. package/dist/debug-DycdGrul.js +45 -0
  78. package/dist/debug-DycdGrul.js.map +1 -0
  79. package/dist/dev/rsc.js +9 -9
  80. package/dist/{dev-C2u78xuv.js → dev-DdRWa6dJ.js} +8 -8
  81. package/dist/{dev-C2u78xuv.js.map → dev-DdRWa6dJ.js.map} +1 -1
  82. package/dist/{dev-4TqJORRn.js → dev-px0_6TNq.js} +11 -5
  83. package/dist/dev-px0_6TNq.js.map +1 -0
  84. package/dist/dev.js +1 -1
  85. package/dist/dialect/extracted/index.js +1 -1
  86. package/dist/dialect/index.js +1 -1
  87. package/dist/{elementMarker-BKzZyg5V.js → elementMarker-ng0y3fN0.js} +8 -8
  88. package/dist/{elementMarker-BKzZyg5V.js.map → elementMarker-ng0y3fN0.js.map} +1 -1
  89. package/dist/entry/dev/css.js +2 -2
  90. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  91. package/dist/entry/dev/jsx-runtime.js +2 -2
  92. package/dist/entry/dev.js +11 -12
  93. package/dist/entry/prod/css.js +2 -2
  94. package/dist/entry/prod/extract.js +2 -2
  95. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  96. package/dist/entry/prod/jsx-runtime.js +2 -2
  97. package/dist/entry/prod/runtime.js +5 -4
  98. package/dist/entry/prod.js +40 -11
  99. package/dist/entry/prod.js.map +1 -1
  100. package/dist/entry/rsc-dev/css.js +2 -2
  101. package/dist/entry/rsc-dev/dev.js +4 -5
  102. package/dist/entry/rsc-dev/dev.js.map +1 -1
  103. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  104. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  105. package/dist/entry/rsc-dev.js +274 -69
  106. package/dist/entry/rsc-dev.js.map +1 -1
  107. package/dist/entry/rsc-prod/css.js +2 -2
  108. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  109. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  110. package/dist/entry/rsc-prod/runtime.js +5 -4
  111. package/dist/entry/rsc-prod.js +16 -10
  112. package/dist/entry/rsc-prod.js.map +1 -0
  113. package/dist/extract-B-Vs88ME.js +3 -0
  114. package/dist/{extract-CzWJeQi8.js → extract-CM8Fk2eK.js} +24 -15
  115. package/dist/{extract-CzWJeQi8.js.map → extract-CM8Fk2eK.js.map} +1 -1
  116. package/dist/{getClassName-C6690_nr.js → getClassName-CrNVjAoJ.js} +29 -8
  117. package/dist/getClassName-CrNVjAoJ.js.map +1 -0
  118. package/dist/{global-C7GsCW6Y.js → global-CZBlA9E7.js} +3 -3
  119. package/dist/{global-C7GsCW6Y.js.map → global-CZBlA9E7.js.map} +1 -1
  120. package/dist/{hash-Bycpk3MR.js → hash-BfeJDf5U.js} +13 -4
  121. package/dist/hash-BfeJDf5U.js.map +1 -0
  122. package/dist/index.js +9 -10
  123. package/dist/jsx/jsx-dev-runtime.js +2 -2
  124. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  125. package/dist/jsx/jsx-runtime.js +2 -2
  126. package/dist/jsx/jsx-runtime.server.js +1 -1
  127. package/dist/{jsx-Berx-L-r.js → jsx-BY1iFewe.js} +3 -3
  128. package/dist/{jsx-Berx-L-r.js.map → jsx-BY1iFewe.js.map} +1 -1
  129. package/dist/{jsx-DsMajv_M.js → jsx-DL-DEAz8.js} +8 -7
  130. package/dist/{jsx-DsMajv_M.js.map → jsx-DL-DEAz8.js.map} +1 -1
  131. package/dist/{jsx_dev_runtime-DXlSD6kV.js → jsx_dev_runtime-aAhNYDeS.js} +2 -2
  132. package/dist/{jsx_dev_runtime-DXlSD6kV.js.map → jsx_dev_runtime-aAhNYDeS.js.map} +1 -1
  133. package/dist/{jsx_runtime-DPWo5qvV.js → jsx_runtime-C6i1bWlu.js} +2 -2
  134. package/dist/{jsx_runtime-DPWo5qvV.js.map → jsx_runtime-C6i1bWlu.js.map} +1 -1
  135. package/dist/{jsx_runtime-CMdEXGNZ.js → jsx_runtime-D7Y5up6H.js} +2 -2
  136. package/dist/{jsx_runtime-CMdEXGNZ.js.map → jsx_runtime-D7Y5up6H.js.map} +1 -1
  137. package/dist/{layer-DiNeeTgG.js → layer-BSxAr-hy.js} +4 -4
  138. package/dist/{layer-DiNeeTgG.js.map → layer-BSxAr-hy.js.map} +1 -1
  139. package/dist/{loader-DCT1Q9yi.mjs → loader-BmYS_Rju.mjs} +3 -3
  140. package/dist/{loader-DCT1Q9yi.mjs.map → loader-BmYS_Rju.mjs.map} +1 -1
  141. package/dist/{misc-o8pviMUi.mjs → misc-BIS_c7BJ.mjs} +2 -2
  142. package/dist/{misc-o8pviMUi.mjs.map → misc-BIS_c7BJ.mjs.map} +1 -1
  143. package/dist/{namedTokens-BUa6raTb.js → namedTokens-CN_yhhik.js} +8 -6
  144. package/dist/namedTokens-CN_yhhik.js.map +1 -0
  145. package/dist/plugin/farm/index.mjs +2 -2
  146. package/dist/plugin/nextjs/index.mjs +4 -4
  147. package/dist/plugin/nextjs/loader.mjs +4 -4
  148. package/dist/plugin/parcel/optimizer.cjs +3 -2
  149. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  150. package/dist/plugin/parcel/optimizer.mjs +3 -2
  151. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  152. package/dist/plugin/parcel/resolver.cjs +1 -1
  153. package/dist/plugin/parcel/resolver.mjs +2 -2
  154. package/dist/plugin/parcel/runtime.cjs +1 -1
  155. package/dist/plugin/parcel/runtime.mjs +1 -1
  156. package/dist/plugin/parcel/transformer.cjs +1 -1
  157. package/dist/plugin/parcel/transformer.mjs +2 -2
  158. package/dist/plugin/rspack/index.mjs +1 -1
  159. package/dist/plugin/vite/index.mjs +3 -3
  160. package/dist/plugin/webpack/index.mjs +1 -1
  161. package/dist/plugin/webpack/loader.mjs +2 -2
  162. package/dist/presets/tailwind/index.js +8 -5
  163. package/dist/presets/tailwind/index.js.map +1 -1
  164. package/dist/{property-BzZSTVIh.js → property-BuLbzviK.js} +2 -2
  165. package/dist/{property-BzZSTVIh.js.map → property-BuLbzviK.js.map} +1 -1
  166. package/dist/{registry-D3x1EDJm.mjs → registry-IaXmLQzA.mjs} +2 -2
  167. package/dist/{registry-D3x1EDJm.mjs.map → registry-IaXmLQzA.mjs.map} +1 -1
  168. package/dist/{rules-Dz7Pu2K6.js → rules-CxVzovt-.js} +60 -23
  169. package/dist/rules-CxVzovt-.js.map +1 -0
  170. package/dist/selector-A-mRmMnI.js +64 -0
  171. package/dist/selector-A-mRmMnI.js.map +1 -0
  172. package/dist/server.js +12 -13
  173. package/dist/server.js.map +1 -1
  174. package/dist/{shared-B_gJf5uj.cjs → shared-CaJuvw03.cjs} +270 -124
  175. package/dist/shared-CaJuvw03.cjs.map +1 -0
  176. package/dist/{shared-uAzFeq0x.mjs → shared-DdPTZ0O3.mjs} +4 -4
  177. package/dist/{shared-uAzFeq0x.mjs.map → shared-DdPTZ0O3.mjs.map} +1 -1
  178. package/dist/sheet-BWBzuy4D.js +7 -0
  179. package/dist/{sheet-DasbRnvy.js.map → sheet-BWBzuy4D.js.map} +1 -1
  180. package/dist/{sidecar-BUO1hKXu.mjs → sidecar-B3oCK9vC.mjs} +3 -3
  181. package/dist/{sidecar-BUO1hKXu.mjs.map → sidecar-B3oCK9vC.mjs.map} +1 -1
  182. package/dist/{style-BkeAZl0n.js → style-CGaJndOl.js} +102 -54
  183. package/dist/style-CGaJndOl.js.map +1 -0
  184. package/dist/{style-DUztHzBz.js → style-DDxjKdX0.js} +354 -48
  185. package/dist/style-DDxjKdX0.js.map +1 -0
  186. package/dist/style-S7LTQbRu.js +5 -0
  187. package/dist/{styleStore-DVDp-gI-.js → styleStore-0fARJlZV.js} +6 -6
  188. package/dist/{styleStore-DVDp-gI-.js.map → styleStore-0fARJlZV.js.map} +1 -1
  189. package/dist/{styleStore-BGJ2ZYtK.js → styleStore-CajcAEPO.js} +101 -223
  190. package/dist/styleStore-CajcAEPO.js.map +1 -0
  191. package/dist/symbols-Cp4ymzKF.js +14 -0
  192. package/dist/symbols-Cp4ymzKF.js.map +1 -0
  193. package/dist/token-D-S-4_mN.js +138 -0
  194. package/dist/token-D-S-4_mN.js.map +1 -0
  195. package/dist/{trace-D0IL6JT8.js → trace-CFnhyCVf.js} +2 -2
  196. package/dist/{trace-D0IL6JT8.js.map → trace-CFnhyCVf.js.map} +1 -1
  197. package/dist/{trace-DR7_Rpkg.js → trace-ZtgeY-8s.js} +3 -3
  198. package/dist/{trace-DR7_Rpkg.js.map → trace-ZtgeY-8s.js.map} +1 -1
  199. package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
  200. package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
  201. package/dist/{utils-CpA-dSpY.mjs → utils-B5Xqf1lV.mjs} +4 -4
  202. package/dist/{utils-CpA-dSpY.mjs.map → utils-B5Xqf1lV.mjs.map} +1 -1
  203. package/dist/{utils-D4YWF2K0.js → utils-B_VhPBHH.js} +4 -4
  204. package/dist/{utils-D4YWF2K0.js.map → utils-B_VhPBHH.js.map} +1 -1
  205. package/dist/{utils-R6QadAsY.js → utils-CDUaX81o.js} +3 -3
  206. package/dist/{utils-R6QadAsY.js.map → utils-CDUaX81o.js.map} +1 -1
  207. package/dist/{utils-DQGa0uzS.mjs → utils-DaAiEEIG.mjs} +3 -3
  208. package/dist/{utils-DQGa0uzS.mjs.map → utils-DaAiEEIG.mjs.map} +1 -1
  209. package/dist/{utils-BsbfH6cd.js → utils-DzydRwYo.js} +77 -49
  210. package/dist/utils-DzydRwYo.js.map +1 -0
  211. package/dist/utils.js +3 -3
  212. package/dist/value-C0JRsyax.js +64 -0
  213. package/dist/value-C0JRsyax.js.map +1 -0
  214. package/dist/{value-DBtSe-9B.js → value-D08AocUs.js} +115 -62
  215. package/dist/value-D08AocUs.js.map +1 -0
  216. package/dist/{valueRef-CsLVJwjA.js → valueRef-M3E1oza7.js} +2 -2
  217. package/dist/{valueRef-CsLVJwjA.js.map → valueRef-M3E1oza7.js.map} +1 -1
  218. package/dist/{webpack-Fb9xF5jS.mjs → webpack-CHydnRXB.mjs} +5 -5
  219. package/dist/{webpack-Fb9xF5jS.mjs.map → webpack-CHydnRXB.mjs.map} +1 -1
  220. package/dist/{withTokens-LRidu3Vc.js → withTokens-DAzUIPvA.js} +2 -2
  221. package/dist/{withTokens-LRidu3Vc.js.map → withTokens-DAzUIPvA.js.map} +1 -1
  222. package/entry/prod/config_debug.ts +2 -0
  223. package/entry/prod/index.ts +1 -1
  224. package/entry/prod/runtime.ts +3 -1
  225. package/entry/rsc_prod/config_debug.ts +6 -0
  226. package/entry/rsc_prod/index.ts +1 -1
  227. package/entry/shared/config_debug.ts +9 -0
  228. package/entry/shared/config_dev.ts +9 -7
  229. package/package.json +1 -1
  230. package/plugin/bundler/parcel/optimizer.ts +1 -0
  231. package/presets/tailwind/style/transform.ts +9 -3
  232. package/runtime/core/cache/combine.ts +44 -25
  233. package/runtime/core/cache/combineRuntime.ts +4 -0
  234. package/runtime/core/cache/index.ts +2 -1
  235. package/runtime/core/cache/item.ts +2 -2
  236. package/runtime/core/cache/pool.ts +15 -30
  237. package/runtime/core/cache/prop.ts +3 -2
  238. package/runtime/core/cache/token.ts +20 -0
  239. package/runtime/core/cache/tokenValues.ts +19 -11
  240. package/runtime/extract/combineStyle.ts +37 -0
  241. package/runtime/extract/getClassName.ts +5 -11
  242. package/runtime/extract/index.ts +3 -1
  243. package/runtime/extract/token.ts +41 -0
  244. package/runtime/extract/tokenResolver.ts +17 -0
  245. package/runtime/style/style.ts +2 -1
  246. package/style/style.ts +1 -1
  247. package/style/theme.ts +0 -1
  248. package/style/token.ts +26 -21
  249. package/style/tokens.ts +18 -12
  250. package/style/transform.ts +1 -1
  251. package/style/value.ts +26 -11
  252. package/style/valueRef.ts +1 -1
  253. package/utils/global.ts +1 -3
  254. package/utils/symbol.ts +3 -0
  255. package/dist/className-Cuh2JNxO.js +0 -263
  256. package/dist/className-Cuh2JNxO.js.map +0 -1
  257. package/dist/compiler-BXcGyZUP.mjs.map +0 -1
  258. package/dist/config-C1k9vUrM.js.map +0 -1
  259. package/dist/config-CLYMN3_p.js.map +0 -1
  260. package/dist/config-DcYrUB-M.js +0 -6
  261. package/dist/config-oI_yS50f.js +0 -1
  262. package/dist/css-CELBp6Gu.js.map +0 -1
  263. package/dist/css-DfH4Gb1c.js.map +0 -1
  264. package/dist/data-Ze8GNiJm.js.map +0 -1
  265. package/dist/debug-BefbXMq1.js +0 -15
  266. package/dist/debug-BefbXMq1.js.map +0 -1
  267. package/dist/debug-OG2wSB5R.js +0 -15
  268. package/dist/debug-OG2wSB5R.js.map +0 -1
  269. package/dist/dev-4TqJORRn.js.map +0 -1
  270. package/dist/extract-B9j4TBkU.js +0 -2
  271. package/dist/getClassName-C6690_nr.js.map +0 -1
  272. package/dist/global-zaCE-g1C.js.map +0 -1
  273. package/dist/hash-Bycpk3MR.js.map +0 -1
  274. package/dist/namedTokens-BUa6raTb.js.map +0 -1
  275. package/dist/rules-Dz7Pu2K6.js.map +0 -1
  276. package/dist/runtime-B3jHW9B1.js +0 -32
  277. package/dist/runtime-B3jHW9B1.js.map +0 -1
  278. package/dist/shared-B_gJf5uj.cjs.map +0 -1
  279. package/dist/sheet-DasbRnvy.js +0 -7
  280. package/dist/style-B0F1sgRZ.js +0 -5
  281. package/dist/style-BkeAZl0n.js.map +0 -1
  282. package/dist/style-CYXTs1iu.js.map +0 -1
  283. package/dist/style-DUztHzBz.js.map +0 -1
  284. package/dist/styleStore-BGJ2ZYtK.js.map +0 -1
  285. package/dist/token-CA1j7suG.js +0 -273
  286. package/dist/token-CA1j7suG.js.map +0 -1
  287. package/dist/token-CKXUECuU.js +0 -76
  288. package/dist/token-CKXUECuU.js.map +0 -1
  289. package/dist/token-DTOyFLmp.js +0 -58
  290. package/dist/token-DTOyFLmp.js.map +0 -1
  291. package/dist/utils-BsbfH6cd.js.map +0 -1
  292. package/dist/value-CJG6EWe8.js +0 -85
  293. package/dist/value-CJG6EWe8.js.map +0 -1
  294. package/dist/value-D-ZcRzLA.js +0 -42
  295. package/dist/value-D-ZcRzLA.js.map +0 -1
  296. package/dist/value-DBtSe-9B.js.map +0 -1
@@ -97,10 +97,12 @@ function createCssCollector() {
97
97
  };
98
98
  }
99
99
  //#endregion
100
- //#region utils/global.ts
100
+ //#region utils/symbol.ts
101
101
  function symbol(name) {
102
102
  return Symbol.for(`@fluentic/style.${name}`);
103
103
  }
104
+ //#endregion
105
+ //#region utils/global.ts
104
106
  function globalData(key, data) {
105
107
  const id = symbol(key);
106
108
  const root = globalThis;
@@ -142,6 +144,18 @@ const RUNTIME_CONFIG_DEFAULT = {
142
144
  globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
143
145
  globalData("config.build", () => ({ current: null }));
144
146
  //#endregion
147
+ //#region config/config/debug.ts
148
+ const DEFAULT_DEBUG_CONFIG = {
149
+ isDebugClassNameEnabled: false,
150
+ isDebugClassNameConfigured: false,
151
+ maxPropertyLength: 24,
152
+ maxValueLength: 8,
153
+ maxSelectorLength: 8,
154
+ maxParentSelectorLength: 8,
155
+ maxAtRuleLength: 10
156
+ };
157
+ const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
158
+ //#endregion
145
159
  //#region utils/hash.ts
146
160
  function hashString(str) {
147
161
  let hash = 2166136261;
@@ -204,47 +218,6 @@ function getLayerBundleCss(layers, layerName, css) {
204
218
  output.push(getLayerBlockCss(layerName, "\n" + css.join("\n") + "\n"));
205
219
  return output.join("\n");
206
220
  }
207
- //#endregion
208
- //#region config/config/debug.ts
209
- const DEFAULT_DEBUG_CONFIG = {
210
- isDebugClassNameEnabled: true,
211
- maxPropertyLength: 24,
212
- maxValueLength: 8,
213
- maxSelectorLength: 8,
214
- maxParentSelectorLength: 8,
215
- maxAtRuleLength: 10
216
- };
217
- const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
218
- //#endregion
219
- //#region utils/object.ts
220
- function toArray(value) {
221
- return Array.isArray(value) ? value : value ? [value] : [];
222
- }
223
- function isFunction(value) {
224
- return typeof value === "function";
225
- }
226
- function isPromiseLike(value) {
227
- return typeof value === "object" && value !== null && "then" in value;
228
- }
229
- //#endregion
230
- //#region config/config/dev.ts
231
- const DEV_CONFIG_DEFAULT = {
232
- isDev: false,
233
- isCheckSelectorEnabled: true,
234
- isSourcemapEnabled: true,
235
- isLocalClassNameEnabled: true,
236
- sheetMaxRules: 1e3,
237
- sheetStyleTagNonce: null,
238
- hashLength: null,
239
- stylePriorityMode: "sort",
240
- sourcemapLocationMode: "style",
241
- isElementClassNameEnabled: true
242
- };
243
- globalData("config.dev.isDev", () => ({ isDev: false }));
244
- const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
245
- globalData("config.dev.plugin", () => ({ config: null }));
246
- globalData("config.dev.base", () => ({ config: null }));
247
- globalData("config.dev.utils", () => ({ config: null }));
248
221
  const STYLE_IMPORT_PATH = "@fluentic/style";
249
222
  const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
250
223
  const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
@@ -252,11 +225,7 @@ const STYLE_DEV_RSC_IMPORT_PATH = "@fluentic/style/dev/rsc";
252
225
  const STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH = "@fluentic/style/entry/prod/extract";
253
226
  const STYLE_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/prod/runtime";
254
227
  const STYLE_RSC_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/rsc-prod/runtime";
255
- const DEFAULT_CONFIG = {
256
- ...CSS_CONFIG_DEFAULT,
257
- localClassName: DEV_CONFIG_DEFAULT.isLocalClassNameEnabled,
258
- debugClassName: DEFAULT_DEBUG_CONFIG.isDebugClassNameEnabled
259
- };
228
+ const DEFAULT_CONFIG = { ...CSS_CONFIG_DEFAULT };
260
229
  const IMPORT_PATHS = [
261
230
  STYLE_IMPORT_PATH,
262
231
  STYLE_CSS_IMPORT_PATH,
@@ -312,6 +281,36 @@ const BUILDER_SLOT_ID = symbol("builder.slotId");
312
281
  const BUILDER_SCOPE_ID = symbol("builder.scopeId");
313
282
  const BUILDER_SCOPE = symbol("builder.scope");
314
283
  //#endregion
284
+ //#region utils/object.ts
285
+ function toArray(value) {
286
+ return Array.isArray(value) ? value : value ? [value] : [];
287
+ }
288
+ function isFunction(value) {
289
+ return typeof value === "function";
290
+ }
291
+ function isPromiseLike(value) {
292
+ return typeof value === "object" && value !== null && "then" in value;
293
+ }
294
+ //#endregion
295
+ //#region config/config/dev.ts
296
+ const DEV_CONFIG_DEFAULT = {
297
+ isDev: false,
298
+ isCheckSelectorEnabled: true,
299
+ isSourcemapEnabled: true,
300
+ isLocalClassNameEnabled: true,
301
+ sheetMaxRules: 1e3,
302
+ sheetStyleTagNonce: null,
303
+ hashLength: null,
304
+ stylePriorityMode: "sort",
305
+ sourcemapLocationMode: "style",
306
+ isElementClassNameEnabled: true
307
+ };
308
+ globalData("config.dev.isDev", () => ({ isDev: false }));
309
+ const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
310
+ globalData("config.dev.plugin", () => ({ config: null }));
311
+ globalData("config.dev.base", () => ({ config: null }));
312
+ globalData("config.dev.utils", () => ({ config: null }));
313
+ //#endregion
315
314
  //#region utils/trace.ts
316
315
  const FN_MARKER = "$fn_";
317
316
  function traceMarker(fn, name) {
@@ -482,16 +481,70 @@ function normalizeSelectorArg(arg) {
482
481
  return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
483
482
  }
484
483
  //#endregion
485
- //#region style/token.ts
484
+ //#region builder/token/symbols.ts
486
485
  const TOKEN_ID = symbol("style:token");
487
486
  const TOKEN_OVERRIDE = symbol("style:token.override");
487
+ const TOKEN_NAME = symbol("style:token.name");
488
+ const TOKEN_VAR_NAME = symbol("style:token.varName");
489
+ //#endregion
490
+ //#region builder/token/data.ts
491
+ function isStyleTokenData(value) {
492
+ return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
493
+ }
494
+ function isStyleTokenOverrideData(value) {
495
+ return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
496
+ }
497
+ function getStyleTokenId(token) {
498
+ return token[TOKEN_ID];
499
+ }
500
+ function getStyleTokenName(token) {
501
+ return token[TOKEN_NAME] ?? null;
502
+ }
503
+ //#endregion
504
+ //#region builder/token/name.ts
505
+ function getStyleTokenNameFromId(id) {
506
+ if (!id) return null;
507
+ const parts = id.split("--");
508
+ const first = normalizeStyleTokenName(parts[0]);
509
+ if (!first) return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join("--")) : null;
510
+ return normalizeStyleTokenName([first, ...parts.slice(1)].join("--"));
511
+ }
512
+ function getChildStyleTokenName(name, child) {
513
+ const childName = normalizeStyleTokenName(child);
514
+ if (!childName) return normalizeStyleTokenName(name);
515
+ const parentName = normalizeStyleTokenName(name);
516
+ return parentName ? parentName + "--" + childName : childName;
517
+ }
518
+ function normalizeStyleTokenName(value) {
519
+ if (!value) return null;
520
+ value = value.trim();
521
+ if (!value) return null;
522
+ if (/^\d+$/.test(value)) return null;
523
+ if (isGeneratedTokenHash(value)) return null;
524
+ value = stripGenericTokenPrefix(value);
525
+ if (!value) return null;
526
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
527
+ if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
528
+ return value;
529
+ }
530
+ function isGeneratedTokenHash(value) {
531
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
532
+ }
533
+ function stripGenericTokenPrefix(value) {
534
+ const parts = value.split("--");
535
+ while (parts[0] === "token" || parts[0] === "tokens") parts.shift();
536
+ return parts.join("--");
537
+ }
538
+ //#endregion
539
+ //#region style/token.ts
488
540
  const TOKEN_DEBUG = symbol("style:token.debug");
489
541
  const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
490
- function createStyleToken(value, debugId) {
542
+ function createStyleToken(value, stableId, debugName) {
491
543
  const token = (value, debug) => {
492
544
  return createStyleTokenOverride(token, value, debug);
493
545
  };
494
- token[TOKEN_ID] = debugId || String(idCounter$6.value++);
546
+ token[TOKEN_ID] = stableId || String(idCounter$6.value++);
547
+ token[TOKEN_NAME] = debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
495
548
  if (isStyleTokenData(value)) {
496
549
  token.value = value.value;
497
550
  token.ref = value;
@@ -505,11 +558,13 @@ function createStyleTokenOverride(token, value, debug) {
505
558
  const override = isStyleTokenData(value) ? {
506
559
  [TOKEN_ID]: getStyleTokenId(token),
507
560
  [TOKEN_OVERRIDE]: true,
561
+ [TOKEN_NAME]: getStyleTokenName(token),
508
562
  value: value.value,
509
563
  ref: value
510
564
  } : {
511
565
  [TOKEN_ID]: getStyleTokenId(token),
512
566
  [TOKEN_OVERRIDE]: true,
567
+ [TOKEN_NAME]: getStyleTokenName(token),
513
568
  value,
514
569
  ref: null
515
570
  };
@@ -520,15 +575,6 @@ function createStyleTokenOverride(token, value, debug) {
520
575
  });
521
576
  return override;
522
577
  }
523
- function isStyleTokenData(value) {
524
- return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
525
- }
526
- function isStyleTokenOverrideData(value) {
527
- return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
528
- }
529
- function getStyleTokenId(token) {
530
- return token[TOKEN_ID];
531
- }
532
578
  //#endregion
533
579
  //#region selector/selector.ts
534
580
  function selector(selector, ...args) {
@@ -935,7 +981,6 @@ const formatClassName = createNameFormatter([
935
981
  "selector",
936
982
  "value"
937
983
  ]);
938
- const formatScopeClassName = createNameFormatter(["className"]);
939
984
  const formatTransformClassName = createNameFormatter(["className"]);
940
985
  function getDebugClassName(format, hash, info) {
941
986
  return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
@@ -943,21 +988,8 @@ function getDebugClassName(format, hash, info) {
943
988
  function getDebugTransformClassName(format, hash, info) {
944
989
  return formatTransformClassName(format || "(className)--$hash", hash, info);
945
990
  }
946
- function getDebugScopeClassName(format, info) {
947
- return formatScopeClassName(format || "-(className)", null, info);
948
- }
949
991
  //#endregion
950
- //#region atomic/utils/css.ts
951
- function getCssVar(varName, value) {
952
- return "var(" + varName + ", " + escapeCssValue(value) + ")";
953
- }
954
- function getCssVarRawFallback(varName, fallbackCss) {
955
- return "var(" + varName + ", " + fallbackCss + ")";
956
- }
957
- function escapeCssValue(value) {
958
- if (!value) return "";
959
- return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
960
- }
992
+ //#region atomic/utils/cssIdent.ts
961
993
  function escapeCssIdent(ident) {
962
994
  let result = "";
963
995
  for (let i = 0; i < ident.length; i++) {
@@ -1147,6 +1179,13 @@ function parseAtRule(rule) {
1147
1179
  if (normalized.startsWith("@supports")) return compressQuery(normalized.slice(9));
1148
1180
  return compressQuery(normalized);
1149
1181
  }
1182
+ function getScopeClassName(className, scopeClassNameFormat) {
1183
+ return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
1184
+ }
1185
+ function formatScopeClassName(format, info) {
1186
+ if (typeof format === "function") return format(info);
1187
+ return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
1188
+ }
1150
1189
  //#endregion
1151
1190
  //#region atomic/utils/hash.ts
1152
1191
  const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
@@ -1233,9 +1272,6 @@ function getRuntimeClassNameHashLength(debugClassName) {
1233
1272
  if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
1234
1273
  return CSS_CONFIG.hashLength ?? 7;
1235
1274
  }
1236
- function getScopeClassName(className, scopeClassNameFormat) {
1237
- return getDebugScopeClassName(scopeClassNameFormat, { className });
1238
- }
1239
1275
  function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
1240
1276
  let hash = property;
1241
1277
  hash += "\n" + (priority || "");
@@ -1440,10 +1476,23 @@ function getScopeLookupKey(slotId, dedupe) {
1440
1476
  function getTokenLookupKey(tokenId) {
1441
1477
  return "token\0" + tokenId;
1442
1478
  }
1479
+ //#endregion
1480
+ //#region atomic/utils/cssVar.ts
1481
+ function getCssVar(varName, value) {
1482
+ return "var(" + varName + ", " + escapeCssValue(value) + ")";
1483
+ }
1484
+ function getCssVarRawFallback(varName, fallbackCss) {
1485
+ return "var(" + varName + ", " + fallbackCss + ")";
1486
+ }
1487
+ function escapeCssValue(value) {
1488
+ if (!value) return "";
1489
+ return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
1490
+ }
1443
1491
  const formatTokenName = createNameFormatter(["name"]);
1444
1492
  function getTokenVarName(token, format) {
1445
1493
  const id = getStyleTokenId(token);
1446
- return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
1494
+ const debugName = getStyleTokenName(token);
1495
+ return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
1447
1496
  }
1448
1497
  function getTokenVar(token, format) {
1449
1498
  return getTokenVarFallback(token, format);
@@ -2967,15 +3016,12 @@ function appendExtractedStyleTuples(target, source) {
2967
3016
  }
2968
3017
  }
2969
3018
  //#endregion
2970
- //#region style/value.ts
2971
- function createToken(value, debugId) {
2972
- return createStyleToken(value, debugId);
2973
- }
2974
- //#endregion
2975
3019
  //#region dialect/namedTokens.ts
2976
3020
  const ROOT = Symbol("fluentic.namedTokens.root");
2977
3021
  function createNamedToken(id, value) {
2978
- return createToken(value, createNamedTokenId(id));
3022
+ const token = createStyleToken(value, createNamedTokenId(id));
3023
+ token[TOKEN_VAR_NAME] = getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null);
3024
+ return token;
2979
3025
  }
2980
3026
  function createNamedTokens(namespace, values) {
2981
3027
  return createNamedTokenProxy({
@@ -2994,7 +3040,7 @@ function createNamedTokenProxy(root, path) {
2994
3040
  if (property === ROOT) return root;
2995
3041
  if (property === "then") return void 0;
2996
3042
  if (property === Symbol.toStringTag) return "NamedTokens";
2997
- if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
3043
+ if (property === TOKEN_ID || property === TOKEN_NAME || property === TOKEN_VAR_NAME || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
2998
3044
  if (!path.length) return void 0;
2999
3045
  return getNamedTokenAtPath(root, path)[property];
3000
3046
  }
@@ -3285,9 +3331,9 @@ function evaluateCall(node, scope) {
3285
3331
  if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createToken") {
3286
3332
  const value = evaluateNode(node.arguments[0], scope);
3287
3333
  if (!value.ok) return value;
3288
- const debugId = evaluateOptionalDebugId(node.arguments[1], scope);
3289
- if (!debugId.ok) return debugId;
3290
- return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node, debugId.value));
3334
+ const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
3335
+ if (!stableId.ok) return stableId;
3336
+ return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node, stableId.value));
3291
3337
  }
3292
3338
  if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createKeyframes") {
3293
3339
  const frames = evaluateNode(node.arguments[0], scope);
@@ -3354,16 +3400,16 @@ function evaluateCall(node, scope) {
3354
3400
  const url = evaluateNode(node.arguments[0], scope);
3355
3401
  if (!url.ok) return evalFail(`fontSrc url must be statically analyzable: ${url.reason}`);
3356
3402
  if (typeof url.value !== "string") return evalFail("fontSrc url must be a static string");
3357
- const format = evaluateOptionalDebugId(node.arguments[1], scope);
3403
+ const format = evaluateOptionalString(node.arguments[1], scope);
3358
3404
  if (!format.ok) return evalFail(`fontSrc format must be statically analyzable: ${format.reason}`);
3359
3405
  return evalOk(fontSrc(url.value, format.value));
3360
3406
  }
3361
3407
  if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createTokens") {
3362
3408
  const value = evaluateNode(node.arguments[0], scope);
3363
3409
  if (!value.ok) return value;
3364
- const debugId = evaluateOptionalDebugId(node.arguments[1], scope);
3365
- if (!debugId.ok) return debugId;
3366
- return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
3410
+ const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
3411
+ if (!stableId.ok) return stableId;
3412
+ return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, stableId.value));
3367
3413
  }
3368
3414
  if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
3369
3415
  const id = evaluateNode(node.arguments[0], scope);
@@ -3391,13 +3437,13 @@ function evaluateCall(node, scope) {
3391
3437
  if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createValues") {
3392
3438
  const hasNumberArg = node.arguments[0]?.type === "Identifier" && node.arguments[0].name === "Number";
3393
3439
  const valuesNode = hasNumberArg ? node.arguments[1] : node.arguments[0];
3394
- const debugNode = hasNumberArg ? node.arguments[2] : node.arguments[1];
3440
+ const stableIdNode = hasNumberArg ? node.arguments[2] : node.arguments[1];
3395
3441
  const values = evaluateNode(valuesNode, scope);
3396
3442
  if (!values.ok) return values;
3397
- const debugId = evaluateOptionalDebugId(debugNode, scope);
3398
- if (!debugId.ok) return debugId;
3443
+ const stableId = evaluateOptionalStableTokenId(stableIdNode, scope);
3444
+ if (!stableId.ok) return stableId;
3399
3445
  if (!Array.isArray(values.value)) return evalFail("createValues values must be an array");
3400
- return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node, debugId.value, hasNumberArg));
3446
+ return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node, stableId.value, hasNumberArg));
3401
3447
  }
3402
3448
  }
3403
3449
  if (node.callee.type === "Identifier") {
@@ -3485,38 +3531,48 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
3485
3531
  if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
3486
3532
  [TOKEN_ID]: getStyleTokenId(token),
3487
3533
  [TOKEN_OVERRIDE]: true,
3534
+ [TOKEN_NAME]: getStyleTokenName(token),
3488
3535
  value: value.value,
3489
3536
  ref: value
3490
3537
  });
3491
3538
  return withRuntimeValue(runtimeValue, {
3492
3539
  [TOKEN_ID]: getStyleTokenId(token),
3493
3540
  [TOKEN_OVERRIDE]: true,
3541
+ [TOKEN_NAME]: getStyleTokenName(token),
3494
3542
  value,
3495
3543
  ref: null
3496
3544
  });
3497
3545
  }
3498
- function createCompiledToken(value, scope, loc, runtimeValue, debugId) {
3499
- let tokenId = debugId;
3546
+ function createCompiledToken(value, scope, loc, runtimeValue, stableId, debugName) {
3547
+ let tokenId = stableId;
3500
3548
  if (!tokenId) tokenId = hashString((scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value)));
3549
+ if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
3550
+ [TOKEN_ID]: tokenId,
3551
+ [TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
3552
+ value: value.value,
3553
+ ref: value
3554
+ });
3501
3555
  return withRuntimeValue(runtimeValue, {
3502
3556
  [TOKEN_ID]: tokenId,
3557
+ [TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
3503
3558
  value,
3504
3559
  ref: null
3505
3560
  });
3506
3561
  }
3507
- function createCompiledTokens(value, scope, loc, runtimeValue, debugId) {
3508
- const tokenGroupId = debugId ?? createCompiledTokenGroupId(scope, loc);
3562
+ function createCompiledTokens(value, scope, loc, runtimeValue, stableId) {
3563
+ const tokenGroupId = stableId ?? createCompiledTokenGroupId(scope, loc);
3564
+ const tokenGroupName = getStyleTokenNameFromId(stableId);
3509
3565
  if (Array.isArray(value)) {
3510
3566
  const result = {};
3511
3567
  for (let i = 0, len = value.length; i < len; i++) {
3512
3568
  const item = value[i];
3513
- result[item] = createCompiledToken(item, scope, loc, runtimeValue, getChildDebugId(tokenGroupId, String(i)));
3569
+ result[item] = createCompiledToken(item, scope, loc, runtimeValue, getChildStableId(tokenGroupId, String(i)), getChildStyleTokenName(tokenGroupName, String(i)));
3514
3570
  }
3515
3571
  return result;
3516
3572
  }
3517
3573
  if (!value || typeof value !== "object") return {};
3518
3574
  const result = {};
3519
- assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId);
3575
+ assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId, tokenGroupName);
3520
3576
  return result;
3521
3577
  }
3522
3578
  function createCompiledTokenGroupId(scope, loc) {
@@ -3528,22 +3584,24 @@ function createCompiledAtRuleStableId(scope, loc, value) {
3528
3584
  id: (scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value))
3529
3585
  };
3530
3586
  }
3531
- function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, debugId) {
3587
+ function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, stableId, debugName) {
3532
3588
  for (const key of Object.keys(value)) {
3533
3589
  const item = value[key];
3534
- const itemDebugId = getChildDebugId(debugId, key);
3590
+ const itemStableId = getChildStableId(stableId, key);
3591
+ const itemDebugName = getChildStyleTokenName(debugName, key);
3535
3592
  if (item && typeof item === "object" && !Array.isArray(item) && !isStyleTokenData(item)) {
3536
3593
  const child = {};
3537
3594
  target[key] = child;
3538
- assignCompiledTokenRecord(child, item, scope, loc, runtimeValue, itemDebugId);
3539
- } else target[key] = createCompiledToken(item, scope, loc, runtimeValue, itemDebugId);
3595
+ assignCompiledTokenRecord(child, item, scope, loc, runtimeValue, itemStableId, itemDebugName);
3596
+ } else target[key] = createCompiledToken(item, scope, loc, runtimeValue, itemStableId, itemDebugName);
3540
3597
  }
3541
3598
  }
3542
- function createCompiledValues(values, scope, loc, runtimeValue, debugId, isNumber) {
3599
+ function createCompiledValues(values, scope, loc, runtimeValue, stableId, isNumber) {
3543
3600
  const tokens = /* @__PURE__ */ new Map();
3601
+ const groupName = getStyleTokenNameFromId(stableId);
3544
3602
  for (let i = 0, len = values.length; i < len; i++) {
3545
3603
  const value = values[i];
3546
- tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue, getChildDebugId(debugId, hashString(String(value)))));
3604
+ tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue, getChildStableId(stableId, hashString(String(value))), getChildStyleTokenName(groupName, getValueDebugName(value))));
3547
3605
  }
3548
3606
  return {
3549
3607
  [COMPILED_TOKEN_FACTORY]: true,
@@ -3561,7 +3619,10 @@ function parseCompiledValue(value, isNumber) {
3561
3619
  function isCompiledTokenFactory(value) {
3562
3620
  return !!value && typeof value === "object" && value[COMPILED_TOKEN_FACTORY] === true;
3563
3621
  }
3564
- function evaluateOptionalDebugId(node, scope) {
3622
+ function evaluateOptionalStableTokenId(node, scope) {
3623
+ return evaluateOptionalString(node, scope);
3624
+ }
3625
+ function evaluateOptionalString(node, scope) {
3565
3626
  if (!node) return evalOk(void 0);
3566
3627
  const value = evaluateNode(node, scope);
3567
3628
  if (!value.ok) return value;
@@ -3585,12 +3646,24 @@ function evaluateOptionalStableId(node, scope) {
3585
3646
  id: stableId.id
3586
3647
  });
3587
3648
  }
3588
- function getChildDebugId(debugId, child) {
3589
- return debugId ? debugId + "--" + child : void 0;
3649
+ function getChildStableId(stableId, child) {
3650
+ return stableId ? stableId + "--" + child : void 0;
3651
+ }
3652
+ function getValueDebugName(value) {
3653
+ if (typeof value === "number") return String(value);
3654
+ if (typeof value !== "string") return null;
3655
+ const parts = value.split(/[;|]/);
3656
+ const label = parts[1]?.trim();
3657
+ if (label) return sanitizeTokenDebugName(label);
3658
+ return sanitizeTokenDebugName(parts[0]?.trim() ?? "");
3659
+ }
3660
+ function sanitizeTokenDebugName(value) {
3661
+ return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || null;
3590
3662
  }
3591
3663
  function withRuntimeValue(runtimeValue, token) {
3592
3664
  return Object.assign({}, token, {
3593
3665
  [TOKEN_ID]: token[TOKEN_ID],
3666
+ [TOKEN_NAME]: token[TOKEN_NAME] ?? null,
3594
3667
  [COMPILED_RUNTIME_VALUE]: runtimeValue
3595
3668
  });
3596
3669
  }
@@ -3650,7 +3723,7 @@ function isStyleChainCall(callee, styleNames) {
3650
3723
  }
3651
3724
  const formatThemeName = createNameFormatter(["name"]);
3652
3725
  function createThemeClassName(name, id, themeNameFormat) {
3653
- return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
3726
+ return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
3654
3727
  }
3655
3728
  function getThemeRuleCss(className, tokens, tokenNameFormat) {
3656
3729
  const declarations = [];
@@ -3662,6 +3735,29 @@ function getThemeDeclaration(token, tokenNameFormat) {
3662
3735
  const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
3663
3736
  return name + ":" + value;
3664
3737
  }
3738
+ function normalizeThemeName(value) {
3739
+ if (!value) return null;
3740
+ value = value.trim();
3741
+ if (!value) return null;
3742
+ if (/^\d+$/.test(value)) return null;
3743
+ if (isGeneratedNameHash(value)) return null;
3744
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
3745
+ if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
3746
+ value = stripGenericThemePrefix(value);
3747
+ if (!value) return null;
3748
+ return value;
3749
+ }
3750
+ function stripGenericThemePrefix(value) {
3751
+ const parts = value.split("--");
3752
+ while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
3753
+ value = parts.join("--");
3754
+ if (value.startsWith("theme-")) return value.slice(6);
3755
+ if (value.startsWith("themes-")) return value.slice(7);
3756
+ return value;
3757
+ }
3758
+ function isGeneratedNameHash(value) {
3759
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
3760
+ }
3665
3761
  //#endregion
3666
3762
  //#region compiler/transform/syntax/utils.ts
3667
3763
  function getCallLabel(callee) {
@@ -4387,8 +4483,9 @@ function getSelectorMethodPath(path) {
4387
4483
  function getDebugStyleArg(t, path, state, sourcemapTrace) {
4388
4484
  const arg = getStyleObjectArg(path, state);
4389
4485
  if (!arg) return arg;
4486
+ const meta = getStyleCallMeta(path, state);
4390
4487
  if (arg.type !== "ObjectExpression") return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
4391
- return flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set());
4488
+ return appendTransformDebugFieldAliases(t, flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set()), meta, state);
4392
4489
  }
4393
4490
  function getDebugCallLoc(path, state) {
4394
4491
  return isSelectorStyleCall(path, state) || isScopeItemSelectorCall(path, state) ? getMergeStyleLoc(path.node.callee) : null;
@@ -4402,6 +4499,10 @@ function getStyleObjectArg(path, state) {
4402
4499
  const styleArgIndex = selectorArgIndex === null ? 0 : selectorArgIndex + 1;
4403
4500
  return path.node.arguments[styleArgIndex];
4404
4501
  }
4502
+ function getStyleCallMeta(path, state) {
4503
+ const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
4504
+ return rootName ? state.styleMetas.get(rootName) ?? null : null;
4505
+ }
4405
4506
  function isSelectorStyleCall(path, state) {
4406
4507
  const methodName = getSelectorMethodName(path.node.callee);
4407
4508
  if (!methodName) return false;
@@ -4506,6 +4607,46 @@ function flattenDebugObjectExpression(t, node, path, state, sourcemapTrace, seen
4506
4607
  }
4507
4608
  return t.objectExpression(properties);
4508
4609
  }
4610
+ function appendTransformDebugFieldAliases(t, node, meta, state) {
4611
+ if (!meta || meta.mode !== "StyleObject" || !meta.transform) return node;
4612
+ const existing = /* @__PURE__ */ new Set();
4613
+ for (const property of node.properties) {
4614
+ if (property.type !== "ObjectProperty" || property.computed) continue;
4615
+ const key = getObjectPropertyKey$1(property);
4616
+ if (key) existing.add(key);
4617
+ }
4618
+ const aliases = [];
4619
+ for (const property of node.properties) {
4620
+ if (property.type !== "ObjectProperty" || property.computed) continue;
4621
+ const key = getObjectPropertyKey$1(property);
4622
+ if (!key) continue;
4623
+ const value = evaluateNode(property.value, getDebugEvalScope(state));
4624
+ if (!value.ok) continue;
4625
+ let transformed;
4626
+ try {
4627
+ transformed = meta.transform.transform({ [key]: value.value });
4628
+ } catch {
4629
+ continue;
4630
+ }
4631
+ for (const transformedKey of Object.keys(transformed)) {
4632
+ if (existing.has(transformedKey)) continue;
4633
+ existing.add(transformedKey);
4634
+ aliases.push(createDebugFieldAlias(t, transformedKey, property));
4635
+ }
4636
+ }
4637
+ if (!aliases.length) return node;
4638
+ return t.objectExpression([...node.properties, ...aliases]);
4639
+ }
4640
+ function createDebugFieldAlias(t, key, source) {
4641
+ const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral());
4642
+ const sourceTrace = source;
4643
+ alias.loc = source.loc;
4644
+ alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
4645
+ alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
4646
+ alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
4647
+ alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
4648
+ return alias;
4649
+ }
4509
4650
  function resolveDebugSpreadObject(t, spread, path, state, sourcemapTrace, seen) {
4510
4651
  const node = spread.argument;
4511
4652
  if (node.type !== "Identifier") return null;
@@ -5053,8 +5194,8 @@ function carryTransformedLocations(input, transformed, transform) {
5053
5194
  * Compile a parsed chain into extracted items and CSS rules.
5054
5195
  * Returns null if any argument cannot be statically evaluated.
5055
5196
  */
5056
- function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
5057
- const css = getCssConfig(opts);
5197
+ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
5198
+ const css = getCssConfig(opts, runtimeMode);
5058
5199
  if (meta.mode === "ClassName") {
5059
5200
  if (chain.kind !== "style") return null;
5060
5201
  return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
@@ -5066,15 +5207,16 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /*
5066
5207
  if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
5067
5208
  return null;
5068
5209
  }
5069
- function getCssConfig(opts) {
5210
+ function getCssConfig(opts, runtimeMode) {
5070
5211
  const css = opts.css;
5212
+ const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
5071
5213
  return {
5072
5214
  classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
5073
5215
  transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
5074
5216
  hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
5075
5217
  tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
5076
- localClassName: css?.localClassName ?? DEFAULT_CONFIG.localClassName,
5077
- debugClassName: css?.debugClassName ?? DEFAULT_CONFIG.debugClassName,
5218
+ localClassName: isDevRuntimeMode,
5219
+ debugClassName: css?.debugClassName ?? isDevRuntimeMode,
5078
5220
  scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
5079
5221
  };
5080
5222
  }
@@ -6269,7 +6411,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
6269
6411
  if (chain?.kind === "style" || chain?.kind === "scope") try {
6270
6412
  const meta = scope.styleMetas?.get(chain.rootName);
6271
6413
  if (!meta) return evalFail("Cannot resolve imported style function");
6272
- const result = compileChain(chain, fileId, node.loc?.start, scope, options, meta, styleNames);
6414
+ const result = compileChain(chain, fileId, node.loc?.start, scope, options, scope.runtimeMode ?? null, meta, styleNames);
6273
6415
  if (!result) return evalFail("Cannot compile imported style chain");
6274
6416
  const extracted = createExtractedChainValue(result, options.dev?.sourcemapMode === "value" ? result : compileChain(chain, fileId, node.loc?.start, scope, {
6275
6417
  ...options,
@@ -6277,7 +6419,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
6277
6419
  ...options.dev,
6278
6420
  sourcemapMode: "value"
6279
6421
  }
6280
- }, meta, styleNames) ?? result);
6422
+ }, scope.runtimeMode ?? null, meta, styleNames) ?? result);
6281
6423
  if (!extracted) return evalFail("Cannot extract imported style chain");
6282
6424
  return evalOk(extracted);
6283
6425
  } catch (error) {
@@ -6668,10 +6810,13 @@ function buildVariableValueExpression(t, value, state, item, options) {
6668
6810
  }
6669
6811
  function buildExtractedTokenExpression(t, token, state) {
6670
6812
  state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
6813
+ const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
6671
6814
  return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
6672
6815
  t.stringLiteral(getStyleTokenId(token)),
6673
6816
  literalExpression(t, token.value),
6674
- token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral()
6817
+ token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral(),
6818
+ getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
6819
+ t.stringLiteral(getTokenVarName(token, tokenNameFormat))
6675
6820
  ]);
6676
6821
  }
6677
6822
  function literalExpression(t, value) {
@@ -6796,7 +6941,8 @@ function getEvalScope(state) {
6796
6941
  sourcemapTrace: state.sourcemapTrace,
6797
6942
  styleNames: state.styleNames,
6798
6943
  styleMetas: state.styleMetas,
6799
- bindingNodes: state.bindingNodes
6944
+ bindingNodes: state.bindingNodes,
6945
+ runtimeMode: state.runtimeMode
6800
6946
  };
6801
6947
  }
6802
6948
  //#endregion
@@ -6810,8 +6956,8 @@ function compileThemeCall(path, state, opts) {
6810
6956
  const tokenArg = evaluateNode(path.node.arguments[0], scope);
6811
6957
  if (!tokenArg.ok) throw path.buildCodeFrameError(`createTheme tokens must be statically analyzable: ${tokenArg.reason}`);
6812
6958
  if (!Array.isArray(tokenArg.value)) throw path.buildCodeFrameError("createTheme first argument must be a static array of token overrides.");
6813
- const debugIdArg = evaluateNode(path.node.arguments[1], scope);
6814
- if (path.node.arguments[1] && !debugIdArg.ok) throw path.buildCodeFrameError(`createTheme debugId must be statically analyzable: ${debugIdArg.reason}`);
6959
+ const stableIdArg = evaluateNode(path.node.arguments[1], scope);
6960
+ if (path.node.arguments[1] && !stableIdArg.ok) throw path.buildCodeFrameError(`createTheme stableId must be statically analyzable: ${stableIdArg.reason}`);
6815
6961
  const tokens = [];
6816
6962
  for (let i = 0, len = tokenArg.value.length; i < len; i++) {
6817
6963
  const token = tokenArg.value[i];
@@ -6819,7 +6965,7 @@ function compileThemeCall(path, state, opts) {
6819
6965
  tokens.push(token);
6820
6966
  }
6821
6967
  const loc = path.node.loc?.start;
6822
- const id = debugIdArg.ok && debugIdArg.value !== void 0 ? String(debugIdArg.value) : getStableThemeId(state.fileId, loc ? loc.line + ":" + loc.column : "createTheme");
6968
+ const id = stableIdArg.ok && stableIdArg.value !== void 0 ? String(stableIdArg.value) : getStableThemeId(state.fileId, loc ? loc.line + ":" + loc.column : "createTheme");
6823
6969
  const themeNameFormat = opts.css?.themeNameFormat || CSS_CONFIG.themeNameFormat || null;
6824
6970
  const className = getStableThemeClassName(id, themeNameFormat);
6825
6971
  return {
@@ -6953,7 +7099,7 @@ function createExtractPlugin(args) {
6953
7099
  if (!meta) return;
6954
7100
  let result;
6955
7101
  try {
6956
- result = compileChain(chain, state.fileId, loc, scope, options, meta, state.styleNames);
7102
+ result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
6957
7103
  } catch (error) {
6958
7104
  const message = error instanceof Error ? error.message : String(error);
6959
7105
  throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
@@ -7341,6 +7487,6 @@ function getCompilerRuntimeImportSource(source, runtimeMode) {
7341
7487
  return null;
7342
7488
  }
7343
7489
  //#endregion
7344
- export { normalizeSourcemapSourcePath as a, babelTransform as c, compareLayerPriority as d, SIDECAR_URL_GLOBAL_SYMBOL as f, getDefaultSourcemapUrl as i, extractCss as l, createCompilerCache as m, createCompiler as n, normalizePath as o, globalData as p, getStyleRuntimeImportPath as r, babelPlugin as s, CompilerRuntimeMode as t, isPromiseLike as u };
7490
+ export { normalizeSourcemapSourcePath as a, babelTransform as c, compareLayerPriority as d, SIDECAR_URL_GLOBAL_SYMBOL as f, getDefaultSourcemapUrl as i, isPromiseLike as l, createCompilerCache as m, createCompiler as n, normalizePath as o, globalData as p, getStyleRuntimeImportPath as r, babelPlugin as s, CompilerRuntimeMode as t, extractCss as u };
7345
7491
 
7346
- //# sourceMappingURL=compiler-BXcGyZUP.mjs.map
7492
+ //# sourceMappingURL=compiler-CE0ZgkdH.mjs.map