@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
package/CHANGELOG.md CHANGED
@@ -1,30 +1,52 @@
1
1
  # @fluentic/style
2
2
 
3
- ## 0.1.0-beta.2
3
+ ## 0.1.0-beta.4
4
+
5
+ ### Patch Changes
4
6
 
5
- ### Minor Changes
7
+ - Slim the extracted production runtime token path and fix named token refs in token-bound extracted styles.
6
8
 
7
- - Add class-name style chains with `createClassNameFn`, weighted utility values,
8
- selector chaining, at-rule support, merge support, and static compiler
9
- extraction.
10
- - Split the Tailwind preset into style-object and class-name entry points so
11
- teams can choose object-first or utility-class authoring from the same preset
12
- package.
13
- - Add named token compiler support and docs for transform extraction behavior.
9
+ - Keep token symbols, guards, naming, and extracted token helpers in builder/runtime internals instead of the public style token surface.
10
+ - Split extracted combine, token resolution, CSS variable, scope, and debug config helpers so extracted builds retain less eager runtime code.
11
+ - Make named tokens carry their extracted CSS variable name so production token bindings can reference named token values without compiler metadata errors.
12
+ - Hide manual stable ids from the public token and theme factory types while preserving internal compiler-provided identities.
13
+ - Add snapshot and runtime contract coverage for createToken, createTokens, createValues, createTheme, scopes, bindScope, combineStyle, and named-token refs in extracted output.
14
+ - Keep the Parcel optimizer on Node's `Buffer` import path and declare the Parcel example polyfill dependency so workspace builds do not rely on Parcel auto-install.
15
+
16
+ ## 0.1.0-beta.3
14
17
 
15
18
  ### Patch Changes
16
19
 
17
- - Improve debug class names for transformed class utilities, including readable
18
- transform class metadata in extracted output.
19
- - Refresh docs for presets, class-name chains, numeric values, runtime/compiler
20
- tradeoffs, plugin options, and imports.
21
- - Add a Vite React Tailwind className example app.
20
+ - fd4a705: Make production class names globally dedupe extracted rules by deriving callsite-local hashing from dev mode only. Keep debug class names configurable from plugin and runtime CSS options, with dev defaulting to readable names and production defaulting to compact hashes.
21
+
22
+ ## 0.1.0-beta.2
23
+
24
+ This beta adds class-name style chains, Tailwind presets, and compiler support
25
+ for transform-driven styling.
26
+
27
+ ### Highlights
28
+
29
+ - Add `createClassNameFn` for class-name-driven style builders.
30
+ - Support nested class-name values, conditional falsey entries, weighted
31
+ class-name tokens, selector chaining, at-rules, and merges.
32
+ - Add compiler extraction for class-name style chains.
33
+ - Add Tailwind presets for both style-object and class-name authoring.
34
+ - Add `classNameTransform`, `classNameValue`, and transform metadata for
35
+ preserving source class labels in emitted rules.
36
+ - Add named token compiler support for static extraction and theme override
37
+ identity.
38
+ - Add configurable transform class-name formatting and hash length behavior for
39
+ debug output.
22
40
 
23
41
  ## 0.1.0-beta.1
24
42
 
25
- ### Patch Changes
43
+ This patch beta improves typed selector authoring and documentation.
44
+
45
+ ### Changes
26
46
 
27
- - Add `createSelectorAssert` for typed custom selector validators and improve selector preset documentation.
47
+ - Add `createSelectorAssert` for typed custom selector validators.
48
+ - Keep the public beta API moving with small usability refinements after
49
+ `0.1.0-beta.0`.
28
50
 
29
51
  ## 0.1.0-beta.0
30
52
 
package/README.md CHANGED
@@ -8,9 +8,10 @@ explores a specific question inside that space: what if styles composed around
8
8
  React components the same way props and state do?
9
9
 
10
10
  With Fluentic, you start simple with type-safe `style(...)` and the JSX `css`
11
- prop. When a component needs variants, themes, nested parts, or consumer
12
- overrides, add slots, scopes, tokens, and `combineStyle(...)` so those styles
13
- stay organized around the component.
11
+ prop. If your team prefers utility class names, you can also create class-name
12
+ style chains, including a Tailwind-like preset. When a component needs variants,
13
+ themes, nested parts, or consumer overrides, add slots, scopes, tokens, and
14
+ `combineStyle(...)` so those styles stay organized around the component.
14
15
 
15
16
  For production builds, styles are extracted into static atomic CSS output.
16
17
  Dynamic values from props and state still work as usual.
@@ -100,6 +101,49 @@ export function Card() {
100
101
  That is the smallest version of Fluentic Style: type-safe styles, selectors, and
101
102
  a `css` prop.
102
103
 
104
+ ## Class Name Chains
105
+
106
+ Fluentic's default authoring path is object style chains, but class-name chains
107
+ are supported too. A class-name chain still produces Fluentic style data, so it
108
+ can use the same `css` prop, selector methods, slots, scopes, debugging, runtime
109
+ resolution, and production extraction path.
110
+
111
+ ```tsx
112
+ import { createClassNameFn } from '@fluentic/style';
113
+ import {
114
+ createTailwindClassNamePreset,
115
+ defaultTailwindTheme,
116
+ } from '@fluentic/style/presets/tailwind';
117
+
118
+ const tailwind = createTailwindClassNamePreset({
119
+ theme: defaultTailwindTheme,
120
+ });
121
+
122
+ export const { className: cx } = createClassNameFn({
123
+ selectors: tailwind.selectors,
124
+ transform: tailwind.transform,
125
+ });
126
+
127
+ const button = cx(
128
+ 'inline-flex',
129
+ 'items-center',
130
+ 'gap-2',
131
+ 'rounded-md',
132
+ 'bg-blue-600',
133
+ 'px-4',
134
+ 'py-2',
135
+ 'text-white',
136
+ )
137
+ .hover('bg-blue-700')
138
+ .md('px-6');
139
+ ```
140
+
141
+ Class names get their meaning from a user-land transform or a preset. See
142
+ [Class Name Style Chains](https://fluenticstack.com/style/docs/beyond-the-basics/class-name-style-chains/)
143
+ for the generic API, or
144
+ [Tailwind Class Name Preset](https://fluenticstack.com/style/docs/presets/tailwind/class-name/)
145
+ for the built-in Tailwind-like class-name vocabulary.
146
+
103
147
  ## Scale Into Components
104
148
 
105
149
  When a component becomes reusable, give its styles component structure.
@@ -333,7 +377,19 @@ For Next.js and other bundlers, see the
333
377
  Benchmarks live in the repository's `benchmark/` folder and run against
334
378
  production builds. Current benchmark snapshots:
335
379
 
336
- React app, 1500-row dashboard:
380
+ The main production checks are runtime cost and bundle size. In the production
381
+ path most apps use, Fluentic extracts CSS at build time and ships the extracted
382
+ production runtime for `css` prop composition, dynamic values, class-name
383
+ merging, and token resolution. That runtime entry currently reports `4.45 KB`
384
+ min+gzip.
385
+ Browser and SSR benchmarks track whether style resolution stays fast in
386
+ app-shaped renders. See the
387
+ [Bundle Size](https://fluenticstack.com/style/docs/benchmark/bundle-size/),
388
+ [React App](https://fluenticstack.com/style/docs/benchmark/react-app/), and
389
+ [SSR Style](https://fluenticstack.com/style/docs/benchmark/ssr-style/) reports
390
+ for what each number measures and how to rerun it.
391
+
392
+ [React app](https://fluenticstack.com/style/docs/benchmark/react-app/), 1500-row dashboard:
337
393
 
338
394
  | Case | Mount | Style Update |
339
395
  | -------------------------- | ---------- | ------------ |
@@ -347,7 +403,7 @@ React app, 1500-row dashboard:
347
403
  | vanilla-extract DOM | `39.85 ms` | `17.65 ms` |
348
404
  | CSS Modules DOM | `40.35 ms` | `17.75 ms` |
349
405
 
350
- SSR render-only, 500 rows:
406
+ [SSR render-only](https://fluenticstack.com/style/docs/benchmark/ssr-style/), 500 rows:
351
407
 
352
408
  | Case | Dashboard Mean | Composition Mean |
353
409
  | --------------- | -------------- | ---------------- |
@@ -357,7 +413,7 @@ SSR render-only, 500 rows:
357
413
  | Fluentic token | `7.667 ms` | `8.253 ms` |
358
414
  | StyleX | `6.826 ms` | `8.059 ms` |
359
415
 
360
- Compiler transform, 100 files per corpus:
416
+ [Compiler transform](https://fluenticstack.com/style/docs/benchmark/compiler/), 100 files per corpus:
361
417
 
362
418
  | Corpus | Fluentic Warm | StyleX Babel |
363
419
  | ------------- | ------------- | ------------ |
@@ -371,23 +427,24 @@ and the public suite list.
371
427
 
372
428
  ## Package Exports
373
429
 
374
- | Import | Purpose |
375
- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
376
- | `@fluentic/style` | Runtime API, style builders, hooks, tokens, themes, and types. |
377
- | `@fluentic/style/css` | CSS helper APIs for keyframes, font faces, and at-rules. |
378
- | `@fluentic/style/selector` | Selector constructors, validators, presets, and priority helpers. |
379
- | `@fluentic/style/config` | Runtime configuration helpers. |
380
- | `@fluentic/style/compiler` | Node-only compiler entry used by build integrations and compiler benchmarks. |
381
- | `@fluentic/style/dev` | Development utilities. |
382
- | `@fluentic/style/dev/rsc` | React Server Component dev client boundary. |
383
- | `@fluentic/style/jsx` | [JSX import source without a bundler plugin](https://fluenticstack.com/style/docs/integrations/runtime-only-mode/). |
384
- | `@fluentic/style/plugin/jsx` | [JSX import source after adding a bundler plugin](https://fluenticstack.com/style/docs/integrations/jsx-runtime-setup/). |
385
- | `@fluentic/style/plugin/nextjs` | [Next.js App Router integration](https://fluenticstack.com/style/docs/integrations/nextjs/). |
386
- | `@fluentic/style/plugin/vite` | [Vite plugin](https://fluenticstack.com/style/docs/integrations/vite/). |
387
- | `@fluentic/style/plugin/webpack` | [Webpack plugin](https://fluenticstack.com/style/docs/integrations/webpack/). |
388
- | `@fluentic/style/plugin/rspack` | [Rspack plugin](https://fluenticstack.com/style/docs/integrations/rspack/). |
389
- | `@fluentic/style/plugin/farm` | [Farm plugin](https://fluenticstack.com/style/docs/integrations/farm/). |
390
- | `@fluentic/style/plugin/parcel` | [Parcel plugin](https://fluenticstack.com/style/docs/integrations/parcel/). |
430
+ | Import | Purpose |
431
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
432
+ | `@fluentic/style` | Runtime API, style builders, hooks, tokens, themes, and types. |
433
+ | `@fluentic/style/css` | CSS helper APIs for keyframes, font faces, and at-rules. |
434
+ | `@fluentic/style/selector` | Selector constructors, validators, presets, and priority helpers. |
435
+ | `@fluentic/style/config` | Runtime configuration helpers. |
436
+ | `@fluentic/style/compiler` | Node-only compiler entry used by build integrations and compiler benchmarks. |
437
+ | `@fluentic/style/presets/tailwind` | [Tailwind-like object fields and class-name chains](https://fluenticstack.com/style/docs/presets/tailwind/). |
438
+ | `@fluentic/style/dev` | Development utilities. |
439
+ | `@fluentic/style/dev/rsc` | React Server Component dev client boundary. |
440
+ | `@fluentic/style/jsx` | [JSX import source without a bundler plugin](https://fluenticstack.com/style/docs/integrations/runtime-only-mode/). |
441
+ | `@fluentic/style/plugin/jsx` | [JSX import source after adding a bundler plugin](https://fluenticstack.com/style/docs/integrations/jsx-runtime-setup/). |
442
+ | `@fluentic/style/plugin/nextjs` | [Next.js App Router integration](https://fluenticstack.com/style/docs/integrations/nextjs/). |
443
+ | `@fluentic/style/plugin/vite` | [Vite plugin](https://fluenticstack.com/style/docs/integrations/vite/). |
444
+ | `@fluentic/style/plugin/webpack` | [Webpack plugin](https://fluenticstack.com/style/docs/integrations/webpack/). |
445
+ | `@fluentic/style/plugin/rspack` | [Rspack plugin](https://fluenticstack.com/style/docs/integrations/rspack/). |
446
+ | `@fluentic/style/plugin/farm` | [Farm plugin](https://fluenticstack.com/style/docs/integrations/farm/). |
447
+ | `@fluentic/style/plugin/parcel` | [Parcel plugin](https://fluenticstack.com/style/docs/integrations/parcel/). |
391
448
 
392
449
  ## Repository Guide
393
450
 
@@ -1,11 +1,12 @@
1
1
  import type { BuilderCallsite, ItemSelector } from '../builder/data';
2
2
  import { CSS_CONFIG } from '../config/config/css';
3
3
  import { DEV_CONFIG } from '../config/config/dev';
4
- import type { ClassNameFormat, ScopeClassNameFormat, TransformClassNameFormat } from '../config/types';
4
+ import type { ClassNameFormat, TransformClassNameFormat } from '../config/types';
5
5
  import { hashString } from '../utils/hash';
6
- import { getDebugClassName, getDebugScopeClassName, getDebugTransformClassName } from './debug/className';
6
+ import { getDebugClassName, getDebugTransformClassName } from './debug/className';
7
7
  import { getDebugPropertyName } from './debug/property';
8
8
  import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
9
+ export { getScopeClassName } from './scope';
9
10
  import { getIdentifierSafeHash } from './utils/hash';
10
11
  import { getSelectorHash, getSelectorText } from './utils/selector';
11
12
 
@@ -80,13 +81,6 @@ function getRuntimeClassNameHashLength(debugClassName: boolean) {
80
81
  return CSS_CONFIG.hashLength ?? 7;
81
82
  }
82
83
 
83
- export function getScopeClassName(
84
- className: string,
85
- scopeClassNameFormat: ScopeClassNameFormat | null,
86
- ) {
87
- return getDebugScopeClassName(scopeClassNameFormat, { className });
88
- }
89
-
90
84
  export function getClassNameDedupe(
91
85
  property: string,
92
86
  priority: number | null,
@@ -1,8 +1,6 @@
1
1
  import type {
2
2
  ClassNameFormat,
3
3
  ClassNameInfo,
4
- ScopeClassNameFormat,
5
- ScopeClassNameInfo,
6
4
  TransformClassNameFormat,
7
5
  TransformClassNameInfo,
8
6
  } from '../../../config/types';
@@ -12,8 +10,6 @@ export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(sele
12
10
 
13
11
  export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
14
12
 
15
- export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
16
-
17
13
  export const formatClassName = createNameFormatter<ClassNameInfo>([
18
14
  'atRule',
19
15
  'scopeSelector',
@@ -22,10 +18,6 @@ export const formatClassName = createNameFormatter<ClassNameInfo>([
22
18
  'value',
23
19
  ]);
24
20
 
25
- export const formatScopeClassName = createNameFormatter<ScopeClassNameInfo>([
26
- 'className',
27
- ]);
28
-
29
21
  export const formatTransformClassName = createNameFormatter<TransformClassNameInfo>([
30
22
  'className',
31
23
  ]);
@@ -45,10 +37,3 @@ export function getDebugTransformClassName(
45
37
  ) {
46
38
  return formatTransformClassName(format || TRANSFORM_CLASS_NAME_FORMAT, hash, info);
47
39
  }
48
-
49
- export function getDebugScopeClassName(
50
- format: ScopeClassNameFormat | null,
51
- info: ScopeClassNameInfo,
52
- ) {
53
- return formatScopeClassName(format || SCOPE_CLASS_NAME_FORMAT, null, info);
54
- }
package/atomic/element.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CSS_CONFIG } from '../config/config/css';
2
2
  import { DEV_CONFIG } from '../config/config/dev';
3
3
  import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
4
- import { escapeCssIdent } from './utils/css';
4
+ import { escapeCssIdent } from './utils/cssIdent';
5
5
  import { sanitizeDebugName } from './utils/debug';
6
6
  import { createNameFormatter } from './utils/format';
7
7
  import { getIdentifierSafeHash } from './utils/hash';
package/atomic/rule.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { ItemSelector } from '../builder/data/state';
2
2
  import type { ScopeClassNameFormat } from '../config/types';
3
- import { getScopeClassName } from './className';
4
3
  import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } from './layer';
5
4
  import { getCssPropertyName, getPropertyPriority } from './property';
6
- import { escapeCssIdent } from './utils/css';
5
+ import { getScopeClassName } from './scope';
6
+ import { escapeCssIdent } from './utils/cssIdent';
7
7
  import { getSelectorPriority, getSelectorText } from './utils/selector';
8
8
  import { getCssPropertyValue } from './value';
9
9
 
@@ -0,0 +1,19 @@
1
+ import type { ScopeClassNameFormat, ScopeClassNameInfo } from '../config/types';
2
+
3
+ export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
4
+
5
+ export function getScopeClassName(
6
+ className: string,
7
+ scopeClassNameFormat: ScopeClassNameFormat | null,
8
+ ) {
9
+ return formatScopeClassName(scopeClassNameFormat || SCOPE_CLASS_NAME_FORMAT, { className });
10
+ }
11
+
12
+ function formatScopeClassName(
13
+ format: ScopeClassNameFormat,
14
+ info: ScopeClassNameInfo,
15
+ ) {
16
+ if (typeof format === 'function') return format(info);
17
+
18
+ return format.replace(/\[|\]/g, '').replace(/\(className\)/g, info.className);
19
+ }
package/atomic/theme.ts CHANGED
@@ -2,7 +2,8 @@ import { CSS_CONFIG } from '../config/config/css';
2
2
  import type { ThemeNameFormat, ThemeNameInfo, TokenNameFormat } from '../config/types';
3
3
  import type { StyleTokenOverride } from '../style/token';
4
4
  import { getTokenOverrideValue, getTokenVarName } from './token';
5
- import { escapeCssIdent, escapeCssValue } from './utils/css';
5
+ import { escapeCssIdent } from './utils/cssIdent';
6
+ import { escapeCssValue } from './utils/cssVar';
6
7
  import { createNameFormatter } from './utils/format';
7
8
  import { getIdentifierSafeHash } from './utils/hash';
8
9
 
@@ -18,7 +19,7 @@ export function createThemeClassName(
18
19
  return formatThemeName(
19
20
  themeNameFormat || THEME_NAME_FORMAT,
20
21
  getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
21
- { name },
22
+ { name: normalizeThemeName(name) },
22
23
  );
23
24
  }
24
25
 
@@ -48,3 +49,41 @@ function getThemeDeclaration(
48
49
 
49
50
  return name + ':' + value;
50
51
  }
52
+
53
+ export function normalizeThemeName(value: string | null | undefined): string | null {
54
+ if (!value) return null;
55
+
56
+ value = value.trim();
57
+ if (!value) return null;
58
+ if (/^\d+$/.test(value)) return null;
59
+ if (isGeneratedNameHash(value)) return null;
60
+
61
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
62
+ if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) {
63
+ return normalizeThemeName(stableSuffix[1]);
64
+ }
65
+
66
+ value = stripGenericThemePrefix(value);
67
+ if (!value) return null;
68
+
69
+ return value;
70
+ }
71
+
72
+ function stripGenericThemePrefix(value: string) {
73
+ const parts = value.split('--');
74
+
75
+ while (parts[0] === 'theme' || parts[0] === 'themes') {
76
+ parts.shift();
77
+ }
78
+
79
+ value = parts.join('--');
80
+
81
+ if (value.startsWith('theme-')) return value.slice('theme-'.length);
82
+ if (value.startsWith('themes-')) return value.slice('themes-'.length);
83
+
84
+ return value;
85
+ }
86
+
87
+ function isGeneratedNameHash(value: string) {
88
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
89
+ }
package/atomic/token.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CSS_CONFIG } from '../config/config/css';
2
2
  import type { TokenNameFormat, TokenNameInfo } from '../config/types';
3
- import { getStyleTokenId, type StyleTokenData, type StyleTokenOverride } from '../style/token';
4
- import { getCssVar, getCssVarRawFallback } from './utils/css';
3
+ import { getStyleTokenId, getStyleTokenName, type StyleTokenData, type StyleTokenOverride } from '../style/token';
4
+ import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
5
5
  import { createNameFormatter } from './utils/format';
6
6
  import { getIdentifierSafeHash } from './utils/hash';
7
7
 
@@ -14,11 +14,12 @@ export function getTokenVarName(
14
14
  format: TokenNameFormat | null,
15
15
  ) {
16
16
  const id = getStyleTokenId(token);
17
+ const debugName = getStyleTokenName(token);
17
18
 
18
19
  const name = formatTokenName(
19
20
  format || TOKEN_NAME_FORMAT,
20
21
  getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
21
- { name: id },
22
+ { name: debugName },
22
23
  );
23
24
 
24
25
  return '--' + name;
@@ -1,23 +1,3 @@
1
- export function getCssVar(varName: string, value: string) {
2
- return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
3
- }
4
-
5
- export function getCssVarRawFallback(varName: string, fallbackCss: string) {
6
- return 'var(' + varName + ', ' + fallbackCss + ')';
7
- }
8
-
9
- export function escapeCssValue(value: string): string {
10
- if (!value) return '';
11
-
12
- return value
13
- .trim()
14
- // Escape existing backslashes first so we don't break them.
15
- .replace(/\\/g, '\\\\')
16
- .replace(/"/g, '\\"')
17
- .replace(/'/g, "\\'")
18
- .replace(/;/g, '\\;');
19
- }
20
-
21
1
  export function escapeCssIdent(ident: string): string {
22
2
  let result = '';
23
3
 
@@ -0,0 +1,19 @@
1
+ export function getCssVar(varName: string, value: string) {
2
+ return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
3
+ }
4
+
5
+ export function getCssVarRawFallback(varName: string, fallbackCss: string) {
6
+ return 'var(' + varName + ', ' + fallbackCss + ')';
7
+ }
8
+
9
+ export function escapeCssValue(value: string): string {
10
+ if (!value) return '';
11
+
12
+ return value
13
+ .trim()
14
+ // Escape existing backslashes first so we don't break them.
15
+ .replace(/\\/g, '\\\\')
16
+ .replace(/"/g, '\\"')
17
+ .replace(/'/g, "\\'")
18
+ .replace(/;/g, '\\;');
19
+ }
@@ -1,4 +1,4 @@
1
- import { sanitizeCssIdentName } from './css';
1
+ import { sanitizeCssIdentName } from './cssIdent';
2
2
 
3
3
  export function normalizeDebugKeywordValue(value: string) {
4
4
  const normalized = value.trim().toLowerCase();
@@ -1,4 +1,4 @@
1
- import { symbol } from '../../utils/global';
1
+ import { symbol } from '../../utils/symbol';
2
2
 
3
3
  export const BUILDER_TYPE: unique symbol = symbol('builder.type');
4
4
  export const BUILDER_STATE: unique symbol = symbol('builder.state');
@@ -1,6 +1,6 @@
1
1
  import { getAtomicClassName, getClassNameDedupe } from '../../../atomic/className';
2
2
  import { getTokenVar } from '../../../atomic/token';
3
- import { getCssVarRawFallback } from '../../../atomic/utils/css';
3
+ import { getCssVarRawFallback } from '../../../atomic/utils/cssVar';
4
4
  import { shouldAppendCssPx } from '../../../atomic/value';
5
5
  import { CSS_CONFIG } from '../../../config/config/css';
6
6
  import { DEBUG_CONFIG } from '../../../config/config/debug';
@@ -1,4 +1,5 @@
1
- import { type StyleToken, type StyleTokenData, TOKEN_ID, TOKEN_OVERRIDE } from '../../style/token';
1
+ import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../../builder/token/symbols';
2
+ import type { StyleToken, StyleTokenData, StyleTokenOverride } from '../../style/token';
2
3
 
3
4
  export type ExtractedTokenInput = {
4
5
  id: string;
@@ -10,30 +11,45 @@ export function createExtractedToken(
10
11
  id: string,
11
12
  value: unknown,
12
13
  ref: StyleTokenData | null = null,
14
+ name: string | null = null,
15
+ varName: string | null = null,
13
16
  ): StyleToken<unknown> {
14
17
  const token = ((value: unknown | StyleTokenData) => {
15
- return isExtractedTokenRef(value)
16
- ? {
17
- [TOKEN_ID]: token[TOKEN_ID],
18
- [TOKEN_OVERRIDE]: true,
19
- value: value.value,
20
- ref: value,
21
- }
22
- : {
23
- [TOKEN_ID]: token[TOKEN_ID],
24
- [TOKEN_OVERRIDE]: true,
25
- value,
26
- ref: null,
27
- };
18
+ return createExtractedTokenOverride(token, value);
28
19
  }) as StyleToken<unknown>;
29
20
 
30
21
  token[TOKEN_ID] = id;
22
+ token[TOKEN_NAME] = name;
23
+ token[TOKEN_VAR_NAME] = varName;
31
24
  token.value = ref ? ref.value : value;
32
25
  token.ref = ref;
33
26
 
34
27
  return token;
35
28
  }
36
29
 
30
+ function createExtractedTokenOverride(
31
+ token: StyleToken,
32
+ value: unknown | StyleTokenData,
33
+ ): StyleTokenOverride {
34
+ return isExtractedTokenRef(value)
35
+ ? {
36
+ [TOKEN_ID]: token[TOKEN_ID],
37
+ [TOKEN_OVERRIDE]: true,
38
+ [TOKEN_NAME]: token[TOKEN_NAME] ?? null,
39
+ [TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
40
+ value: value.value,
41
+ ref: value,
42
+ }
43
+ : {
44
+ [TOKEN_ID]: token[TOKEN_ID],
45
+ [TOKEN_OVERRIDE]: true,
46
+ [TOKEN_NAME]: token[TOKEN_NAME] ?? null,
47
+ [TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
48
+ value,
49
+ ref: null,
50
+ };
51
+ }
52
+
37
53
  function isExtractedTokenRef(value: unknown): value is StyleTokenData {
38
54
  return !!value &&
39
55
  typeof (value as StyleTokenData)[TOKEN_ID] === 'string' &&
@@ -0,0 +1,30 @@
1
+ import type { StyleToken, StyleTokenData, StyleTokenOverride } from '../../style/token';
2
+ import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from './symbols';
3
+
4
+ export type ExtractedStyleTokenVarName = {
5
+ [TOKEN_VAR_NAME]?: string | null;
6
+ };
7
+
8
+ export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
9
+ return !!value &&
10
+ typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
11
+ (value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
12
+ }
13
+
14
+ export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
15
+ return !!value &&
16
+ typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
17
+ (value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
18
+ }
19
+
20
+ export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
21
+ return token[TOKEN_ID];
22
+ }
23
+
24
+ export function getStyleTokenName<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string | null {
25
+ return token[TOKEN_NAME] ?? null;
26
+ }
27
+
28
+ export function getStyleTokenVarName<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string | null {
29
+ return (token as ExtractedStyleTokenVarName)[TOKEN_VAR_NAME] ?? null;
30
+ }
@@ -0,0 +1,3 @@
1
+ export * from './data';
2
+ export * from './name';
3
+ export * from './symbols';
@@ -0,0 +1,54 @@
1
+ export function getStyleTokenNameFromId(id: string | undefined): string | null {
2
+ if (!id) return null;
3
+
4
+ const parts = id.split('--');
5
+ const first = normalizeStyleTokenName(parts[0]);
6
+
7
+ if (!first) {
8
+ return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join('--')) : null;
9
+ }
10
+
11
+ return normalizeStyleTokenName([first, ...parts.slice(1)].join('--'));
12
+ }
13
+
14
+ export function getChildStyleTokenName(
15
+ name: string | null | undefined,
16
+ child: string | null | undefined,
17
+ ) {
18
+ const childName = normalizeStyleTokenName(child);
19
+ if (!childName) return normalizeStyleTokenName(name);
20
+
21
+ const parentName = normalizeStyleTokenName(name);
22
+ return parentName ? parentName + '--' + childName : childName;
23
+ }
24
+
25
+ export function normalizeStyleTokenName(value: string | null | undefined): string | null {
26
+ if (!value) return null;
27
+
28
+ value = value.trim();
29
+ if (!value) return null;
30
+ if (/^\d+$/.test(value)) return null;
31
+ if (isGeneratedTokenHash(value)) return null;
32
+
33
+ value = stripGenericTokenPrefix(value);
34
+ if (!value) return null;
35
+
36
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
37
+ if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
38
+
39
+ return value;
40
+ }
41
+
42
+ function isGeneratedTokenHash(value: string) {
43
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
44
+ }
45
+
46
+ function stripGenericTokenPrefix(value: string) {
47
+ const parts = value.split('--');
48
+
49
+ while (parts[0] === 'token' || parts[0] === 'tokens') {
50
+ parts.shift();
51
+ }
52
+
53
+ return parts.join('--');
54
+ }
@@ -0,0 +1,6 @@
1
+ import { symbol } from '../../utils/symbol';
2
+
3
+ export const TOKEN_ID: unique symbol = symbol('style:token');
4
+ export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
5
+ export const TOKEN_NAME: unique symbol = symbol('style:token.name');
6
+ export const TOKEN_VAR_NAME: unique symbol = symbol('style:token.varName');