@fluentic/style 0.1.0-beta.0 → 0.1.0-beta.10

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 (494) hide show
  1. package/CHANGELOG.md +154 -0
  2. package/README.md +181 -49
  3. package/atomic/atRule/utils.ts +3 -2
  4. package/atomic/className.ts +50 -12
  5. package/atomic/debug/className/className.ts +24 -8
  6. package/atomic/element.ts +5 -2
  7. package/atomic/rule.ts +11 -5
  8. package/atomic/scope.ts +19 -0
  9. package/atomic/theme.ts +44 -3
  10. package/atomic/token.ts +7 -4
  11. package/atomic/utils/cssIdent.ts +54 -0
  12. package/atomic/utils/cssVar.ts +19 -0
  13. package/atomic/utils/debug.ts +1 -1
  14. package/atomic/utils/format.ts +1 -1
  15. package/atomic/utils/hash.ts +14 -0
  16. package/atomic/utils/selector.ts +31 -1
  17. package/atomic/var.ts +3 -2
  18. package/builder/classname/class_name_builder.ts +491 -0
  19. package/builder/classname/fns.ts +77 -0
  20. package/builder/classname/index.ts +3 -0
  21. package/builder/classname/types.ts +41 -0
  22. package/builder/data/const.ts +8 -1
  23. package/builder/data/create.ts +52 -6
  24. package/builder/data/data.ts +33 -8
  25. package/builder/data/debug.ts +1 -0
  26. package/builder/data/index.ts +0 -1
  27. package/builder/data/is.ts +26 -3
  28. package/builder/data/merge/scope.ts +38 -38
  29. package/builder/data/merge/style.ts +115 -20
  30. package/builder/data/state.ts +17 -2
  31. package/builder/extract/index.ts +1 -0
  32. package/builder/extract/sheet.ts +30 -0
  33. package/builder/extract/token.ts +30 -14
  34. package/builder/extract/utils.ts +2 -0
  35. package/builder/extract/withTokens.ts +2 -1
  36. package/builder/selector_override.noop.ts +11 -0
  37. package/builder/selector_override.ts +31 -0
  38. package/builder/selector_override_core.ts +79 -0
  39. package/builder/style_builder.ts +144 -20
  40. package/builder/style_data.ts +25 -0
  41. package/builder/style_fns.ts +57 -57
  42. package/builder/token/data.ts +30 -0
  43. package/builder/token/index.ts +3 -0
  44. package/builder/token/name.ts +54 -0
  45. package/builder/token/symbols.ts +6 -0
  46. package/builder/types/alias.ts +44 -16
  47. package/builder/types/fns.ts +24 -16
  48. package/builder/types/types.ts +37 -7
  49. package/builder/utils.ts +1 -0
  50. package/compiler/compiler/compiler.ts +88 -14
  51. package/compiler/compiler/constants.ts +6 -0
  52. package/compiler/compiler/index.ts +1 -0
  53. package/compiler/compiler/types.ts +4 -1
  54. package/compiler/cssProp.ts +21 -0
  55. package/compiler/extract/extract.ts +42 -14
  56. package/compiler/extract/types.ts +2 -0
  57. package/compiler/index.ts +1 -0
  58. package/compiler/transform/cssProp/index.ts +1 -0
  59. package/compiler/transform/cssProp/plugin.ts +161 -0
  60. package/compiler/transform/debug/plugin.ts +93 -4
  61. package/compiler/transform/debug/transform.ts +2 -1
  62. package/compiler/transform/debug/utils/debug_data.ts +73 -0
  63. package/compiler/transform/evaluator/evaluator.ts +173 -32
  64. package/compiler/transform/evaluator/tracer.ts +48 -11
  65. package/compiler/transform/extract/chain/chain.ts +1370 -162
  66. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  67. package/compiler/transform/extract/chain/types.ts +3 -1
  68. package/compiler/transform/extract/plugin.ts +64 -6
  69. package/compiler/transform/extract/transform.ts +2 -1
  70. package/compiler/transform/extract/utils/replacement.ts +72 -2
  71. package/compiler/transform/extract/utils/state.ts +3 -0
  72. package/compiler/transform/extract/utils/theme.ts +6 -6
  73. package/compiler/transform/index.ts +1 -0
  74. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  75. package/compiler/transform/syntax/static_ids.ts +1 -1
  76. package/compiler/utils/constants.ts +12 -5
  77. package/compiler/utils/file_resolver.ts +2 -0
  78. package/compiler/utils/import_source.ts +19 -8
  79. package/compiler/utils/imports.ts +11 -1
  80. package/config/build.ts +9 -2
  81. package/config/config/check.ts +25 -0
  82. package/config/config/css.ts +18 -1
  83. package/config/config/debug.ts +24 -1
  84. package/config/config/dev.ts +17 -1
  85. package/config/configure.ts +19 -2
  86. package/config/types.ts +7 -0
  87. package/css/index.ts +2 -0
  88. package/css/sheet.ts +152 -0
  89. package/css/styleTarget.ts +251 -0
  90. package/dev/config.ts +2 -3
  91. package/dev/utils.ts +3 -3
  92. package/dialect/extracted/index.ts +5 -0
  93. package/dialect/index.ts +1 -0
  94. package/dialect/namedTokens.ts +153 -0
  95. package/dist/adapter/preact.js +2 -0
  96. package/dist/adapter/react.js +2 -0
  97. package/dist/adapter/solid.js +2 -0
  98. package/dist/className-yhJCGT0F.js +304 -0
  99. package/dist/className-yhJCGT0F.js.map +1 -0
  100. package/dist/combine-Bww7VnSr.js +1254 -0
  101. package/dist/combine-Bww7VnSr.js.map +1 -0
  102. package/dist/compiler/index.mjs +2 -2
  103. package/dist/{compiler-DweanHoB.mjs → compiler-C3CEGGtI.mjs} +2349 -647
  104. package/dist/compiler-C3CEGGtI.mjs.map +1 -0
  105. package/dist/config/index.js +2 -2
  106. package/dist/config-BAEzRmSJ.js +6 -0
  107. package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
  108. package/dist/config-BKP5LOkt.js +35 -0
  109. package/dist/config-BKP5LOkt.js.map +1 -0
  110. package/dist/config-C5VWvTav.js +34 -0
  111. package/dist/config-C5VWvTav.js.map +1 -0
  112. package/dist/config-CB4lm2tM.js +1 -0
  113. package/dist/config-CDjbHwb-.js +6 -0
  114. package/dist/config-CDjbHwb-.js.map +1 -0
  115. package/dist/config-DNEnHEf3.js +36 -0
  116. package/dist/config-DNEnHEf3.js.map +1 -0
  117. package/dist/createTransformElement-D8fXZ3wA.js +34 -0
  118. package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
  119. package/dist/css-BDn0epJ8.js +1339 -0
  120. package/dist/css-BDn0epJ8.js.map +1 -0
  121. package/dist/css-CFxNrYt3.js +4040 -0
  122. package/dist/css-CFxNrYt3.js.map +1 -0
  123. package/dist/css-DEYgrj76.js +524 -0
  124. package/dist/css-DEYgrj76.js.map +1 -0
  125. package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
  126. package/dist/css-DWBWsyxZ.js.map +1 -0
  127. package/dist/css.js +2 -2
  128. package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
  129. package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
  130. package/dist/data-CDrS1Bq4.js +785 -0
  131. package/dist/data-CDrS1Bq4.js.map +1 -0
  132. package/dist/debug-BkVbf0Cz.js +52 -0
  133. package/dist/debug-BkVbf0Cz.js.map +1 -0
  134. package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
  135. package/dist/debug-YuhEIQVO.js.map +1 -0
  136. package/dist/dev/rsc.js +10 -9
  137. package/dist/dev/rsc.js.map +1 -1
  138. package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
  139. package/dist/dev-0imWmSVb.js.map +1 -0
  140. package/dist/dev.js +1 -1
  141. package/dist/dialect/extracted/index.js +2 -0
  142. package/dist/dialect/index.js +2 -0
  143. package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
  144. package/dist/elementMarker-kvpMjB49.js.map +1 -0
  145. package/dist/entry/dev/adapter/preact.js +12 -0
  146. package/dist/entry/dev/adapter/preact.js.map +1 -0
  147. package/dist/entry/dev/adapter/react.js +12 -0
  148. package/dist/entry/dev/adapter/react.js.map +1 -0
  149. package/dist/entry/dev/adapter/solid.js +12 -0
  150. package/dist/entry/dev/adapter/solid.js.map +1 -0
  151. package/dist/entry/dev/css.js +3 -3
  152. package/dist/entry/dev/jsx-dev-runtime.js +2 -1
  153. package/dist/entry/dev/jsx-runtime.js +2 -1
  154. package/dist/entry/dev.js +13 -9
  155. package/dist/entry/prod/adapter/preact.js +12 -0
  156. package/dist/entry/prod/adapter/preact.js.map +1 -0
  157. package/dist/entry/prod/adapter/react.js +12 -0
  158. package/dist/entry/prod/adapter/react.js.map +1 -0
  159. package/dist/entry/prod/adapter/solid.js +12 -0
  160. package/dist/entry/prod/adapter/solid.js.map +1 -0
  161. package/dist/entry/prod/css.js +3 -3
  162. package/dist/entry/prod/extract.js +242 -3
  163. package/dist/entry/prod/extract.js.map +1 -0
  164. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  165. package/dist/entry/prod/jsx-runtime.js +2 -2
  166. package/dist/entry/prod/runtime.js +3 -4
  167. package/dist/entry/prod.js +84 -1201
  168. package/dist/entry/prod.js.map +1 -1
  169. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  170. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  171. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  172. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  173. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  174. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  175. package/dist/entry/rsc-dev/css.js +3 -3
  176. package/dist/entry/rsc-dev/dev.js +11 -13
  177. package/dist/entry/rsc-dev/dev.js.map +1 -1
  178. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  179. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  180. package/dist/entry/rsc-dev.js +634 -713
  181. package/dist/entry/rsc-dev.js.map +1 -1
  182. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  183. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  184. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  185. package/dist/entry/rsc-prod/css.js +9 -3
  186. package/dist/entry/rsc-prod/css.js.map +1 -0
  187. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  188. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  189. package/dist/entry/rsc-prod/runtime.js +3 -4
  190. package/dist/entry/rsc-prod.js +242 -10
  191. package/dist/entry/rsc-prod.js.map +1 -0
  192. package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
  193. package/dist/env-Cz8frh6e.js.map +1 -0
  194. package/dist/getClassName-9CsXbNls.js +545 -0
  195. package/dist/getClassName-9CsXbNls.js.map +1 -0
  196. package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
  197. package/dist/getClassName-DGm-VNDo.js.map +1 -0
  198. package/dist/getClassName-Dtc4yyYI.js +47 -0
  199. package/dist/getClassName-Dtc4yyYI.js.map +1 -0
  200. package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
  201. package/dist/getClassName-DtkplEIt.js.map +1 -0
  202. package/dist/global-CAc9OjKx.js +14 -0
  203. package/dist/global-CAc9OjKx.js.map +1 -0
  204. package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
  205. package/dist/hash-Cr-LCWDt.js.map +1 -0
  206. package/dist/index.js +10 -8
  207. package/dist/jsx/jsx-dev-runtime.js +2 -2
  208. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  209. package/dist/jsx/jsx-runtime.js +2 -2
  210. package/dist/jsx/jsx-runtime.server.js +1 -1
  211. package/dist/jsx-CVxpkS04.js +39 -0
  212. package/dist/jsx-CVxpkS04.js.map +1 -0
  213. package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
  214. package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
  215. package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
  216. package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
  217. package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
  218. package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
  219. package/dist/{loader-DS61nRqr.mjs → loader-_-VjzlrX.mjs} +13 -14
  220. package/dist/loader-_-VjzlrX.mjs.map +1 -0
  221. package/dist/{misc-B9kqEb2N.mjs → misc-B76PUnWe.mjs} +11 -6
  222. package/dist/misc-B76PUnWe.mjs.map +1 -0
  223. package/dist/namedTokens-5AayGokX.js +85 -0
  224. package/dist/namedTokens-5AayGokX.js.map +1 -0
  225. package/dist/plugin/farm/index.mjs +4 -3
  226. package/dist/plugin/farm/index.mjs.map +1 -1
  227. package/dist/plugin/nextjs/index.mjs +121 -17
  228. package/dist/plugin/nextjs/index.mjs.map +1 -1
  229. package/dist/plugin/nextjs/loader.mjs +4 -4
  230. package/dist/plugin/parcel/index.cjs +2 -0
  231. package/dist/plugin/parcel/index.mjs +3 -1
  232. package/dist/plugin/parcel/optimizer.cjs +3 -2
  233. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  234. package/dist/plugin/parcel/optimizer.mjs +3 -2
  235. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  236. package/dist/plugin/parcel/resolver.cjs +1 -1
  237. package/dist/plugin/parcel/resolver.mjs +2 -2
  238. package/dist/plugin/parcel/runtime.cjs +1 -1
  239. package/dist/plugin/parcel/runtime.mjs +1 -1
  240. package/dist/plugin/parcel/transformer.cjs +1 -1
  241. package/dist/plugin/parcel/transformer.mjs +2 -2
  242. package/dist/plugin/rspack/index.mjs +3 -2
  243. package/dist/plugin/rspack/index.mjs.map +1 -1
  244. package/dist/plugin/vite/index.mjs +13 -10
  245. package/dist/plugin/vite/index.mjs.map +1 -1
  246. package/dist/plugin/webpack/index.mjs +3 -2
  247. package/dist/plugin/webpack/loader.mjs +2 -2
  248. package/dist/presets/tailwind/index.js +995 -0
  249. package/dist/presets/tailwind/index.js.map +1 -0
  250. package/dist/presets-DSanixJV.js +243 -0
  251. package/dist/presets-DSanixJV.js.map +1 -0
  252. package/dist/{registry-CyIj8LYK.mjs → registry-w8ET5R7v.mjs} +2 -2
  253. package/dist/{registry-CyIj8LYK.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
  254. package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
  255. package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
  256. package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
  257. package/dist/rules-DaMaMHgb.js.map +1 -0
  258. package/dist/scope-CZdGAnl_.js +601 -0
  259. package/dist/scope-CZdGAnl_.js.map +1 -0
  260. package/dist/selector/index.js +2 -3
  261. package/dist/server.js +17 -11
  262. package/dist/server.js.map +1 -1
  263. package/dist/{shared-CCpq1zqA.mjs → shared-C_cYxNzz.mjs} +4 -4
  264. package/dist/{shared-CCpq1zqA.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
  265. package/dist/{shared-BAL9peIw.cjs → shared-PK52rW6T.cjs} +2352 -644
  266. package/dist/shared-PK52rW6T.cjs.map +1 -0
  267. package/dist/sheet-CxkO1Hwt.js +7 -0
  268. package/dist/sheet-CxkO1Hwt.js.map +1 -0
  269. package/dist/{sidecar-4u6GnlQG.mjs → sidecar-BhvmXYsD.mjs} +3 -3
  270. package/dist/{sidecar-4u6GnlQG.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
  271. package/dist/style-CAhAnRni.js +1129 -0
  272. package/dist/style-CAhAnRni.js.map +1 -0
  273. package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
  274. package/dist/styleStore-BzLZwpwy.js.map +1 -0
  275. package/dist/styleStore-DaIJ4OPV.js +58 -0
  276. package/dist/styleStore-DaIJ4OPV.js.map +1 -0
  277. package/dist/token-D33mKTka.js +138 -0
  278. package/dist/token-D33mKTka.js.map +1 -0
  279. package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
  280. package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
  281. package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
  282. package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
  283. package/dist/transform-DSpimwwC.js +23 -0
  284. package/dist/transform-DSpimwwC.js.map +1 -0
  285. package/dist/{utils-DMFgOOtA.mjs → utils-DND33M6y.mjs} +3 -3
  286. package/dist/{utils-DMFgOOtA.mjs.map → utils-DND33M6y.mjs.map} +1 -1
  287. package/dist/utils-DZK0mfmY.js +42 -0
  288. package/dist/utils-DZK0mfmY.js.map +1 -0
  289. package/dist/utils-D_XgtMtn.js +72 -0
  290. package/dist/utils-D_XgtMtn.js.map +1 -0
  291. package/dist/utils-DxCpyV2E.js +62 -0
  292. package/dist/utils-DxCpyV2E.js.map +1 -0
  293. package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
  294. package/dist/utils-H1VInWpd.js.map +1 -0
  295. package/dist/utils-NdisireF.mjs +182 -0
  296. package/dist/utils-NdisireF.mjs.map +1 -0
  297. package/dist/utils.js +4 -4
  298. package/dist/utils.js.map +1 -1
  299. package/dist/value-CK0-Xbov.js +160 -0
  300. package/dist/value-CK0-Xbov.js.map +1 -0
  301. package/dist/{webpack-CxS2FDYU.mjs → webpack-D7QO0bKN.mjs} +5 -5
  302. package/dist/webpack-D7QO0bKN.mjs.map +1 -0
  303. package/entry/dev/adapter/preact.ts +8 -0
  304. package/entry/dev/adapter/react.ts +8 -0
  305. package/entry/dev/adapter/solid.ts +8 -0
  306. package/entry/dev/config.ts +1 -1
  307. package/entry/dev/index.ts +1 -0
  308. package/entry/dev/jsx_dev_runtime.ts +1 -0
  309. package/entry/dev/jsx_runtime.ts +1 -0
  310. package/entry/dev/sheet.ts +4 -0
  311. package/entry/prod/adapter/preact.ts +8 -0
  312. package/entry/prod/adapter/react.ts +8 -0
  313. package/entry/prod/adapter/solid.ts +8 -0
  314. package/entry/prod/config_debug.ts +2 -0
  315. package/entry/prod/index.ts +1 -1
  316. package/entry/prod/runtime.ts +4 -2
  317. package/entry/rsc_dev/adapter/preact.ts +9 -0
  318. package/entry/rsc_dev/adapter/react.ts +9 -0
  319. package/entry/rsc_dev/adapter/solid.ts +9 -0
  320. package/entry/rsc_dev/config.ts +1 -1
  321. package/entry/rsc_dev/server.ts +1 -1
  322. package/entry/rsc_prod/adapter/preact.ts +1 -0
  323. package/entry/rsc_prod/adapter/react.ts +1 -0
  324. package/entry/rsc_prod/adapter/solid.ts +1 -0
  325. package/entry/rsc_prod/config_debug.ts +6 -0
  326. package/entry/rsc_prod/index.ts +1 -1
  327. package/entry/rsc_prod/runtime.ts +1 -1
  328. package/entry/rsc_prod/server.ts +1 -1
  329. package/entry/shared/config_debug.ts +9 -0
  330. package/entry/shared/config_dev.ts +14 -0
  331. package/entry/shared/dev.ts +11 -2
  332. package/entry/shared/utils.ts +28 -0
  333. package/jsx/types/index.ts +1 -0
  334. package/jsx/types/preact.ts +14 -0
  335. package/jsx/{types.ts → types/react.ts} +2 -2
  336. package/jsx/types/solid.ts +32 -0
  337. package/package.json +118 -18
  338. package/plugin/bundler/farm/plugin.ts +2 -0
  339. package/plugin/bundler/parcel/optimizer.ts +1 -0
  340. package/plugin/bundler/parcel/plugin.ts +2 -0
  341. package/plugin/bundler/rspack/plugin.ts +1 -0
  342. package/plugin/bundler/vite/plugin.ts +5 -9
  343. package/plugin/bundler/vite/state.ts +12 -7
  344. package/plugin/bundler/webpack/plugin.ts +2 -1
  345. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  346. package/plugin/nextjs/plugin.ts +208 -15
  347. package/plugin/nextjs/types.ts +1 -2
  348. package/plugin/nextjs/utils.ts +121 -0
  349. package/plugin/utils/compiler.ts +2 -0
  350. package/plugin/utils/runtimeEntry.ts +15 -2
  351. package/presets/tailwind/classname/index.ts +2 -0
  352. package/presets/tailwind/classname/transform.ts +239 -0
  353. package/presets/tailwind/classname/types.ts +124 -0
  354. package/presets/tailwind/index.ts +5 -0
  355. package/presets/tailwind/selectors.ts +27 -0
  356. package/presets/tailwind/style/index.ts +2 -0
  357. package/presets/tailwind/style/transform.ts +436 -0
  358. package/presets/tailwind/style/types.ts +346 -0
  359. package/presets/tailwind/theme.ts +479 -0
  360. package/presets/tailwind/types.ts +147 -0
  361. package/runtime/adapter/utils.ts +120 -0
  362. package/runtime/core/cache/combine.ts +76 -28
  363. package/runtime/core/cache/combineRuntime.ts +4 -0
  364. package/runtime/core/cache/index.ts +2 -1
  365. package/runtime/core/cache/item.ts +32 -13
  366. package/runtime/core/cache/itemWithResolver.ts +44 -0
  367. package/runtime/core/cache/pool.ts +16 -31
  368. package/runtime/core/cache/prop.ts +10 -8
  369. package/runtime/core/cache/result.ts +2 -2
  370. package/runtime/core/cache/stateItem.ts +16 -1
  371. package/runtime/core/cache/token.ts +20 -0
  372. package/runtime/core/cache/tokenValues.ts +19 -11
  373. package/runtime/core/combinedStyle.ts +4 -4
  374. package/runtime/extract/combineStyle.ts +211 -0
  375. package/runtime/extract/getClassName.ts +55 -23
  376. package/runtime/extract/index.ts +4 -2
  377. package/runtime/extract/token.ts +41 -0
  378. package/runtime/extract/tokenResolver.ts +17 -0
  379. package/runtime/index.ts +8 -1
  380. package/runtime/rsc/getClassName.ts +4 -0
  381. package/runtime/rsc/observer.ts +4 -0
  382. package/runtime/rsc/styleStore.ts +18 -7
  383. package/runtime/sheet/rule.ts +16 -12
  384. package/runtime/sheet/rules.ts +8 -3
  385. package/runtime/style/scope.ts +0 -24
  386. package/runtime/style/style.ts +181 -6
  387. package/runtime/types.ts +6 -4
  388. package/selector/assert.ts +24 -25
  389. package/selector/selector.ts +6 -0
  390. package/sheet/dev/dev_layer.ts +18 -7
  391. package/sheet/dev/dev_sort.ts +45 -11
  392. package/sheet/prod.ts +18 -7
  393. package/sheet/types.ts +2 -0
  394. package/sheet/utils/layer.ts +33 -0
  395. package/style/classname.ts +47 -0
  396. package/style/important.ts +19 -0
  397. package/style/index.ts +3 -0
  398. package/style/style.ts +47 -16
  399. package/style/theme.ts +4 -3
  400. package/style/token.ts +26 -21
  401. package/style/tokens.ts +18 -12
  402. package/style/transform.ts +41 -2
  403. package/style/types.ts +6 -4
  404. package/style/utils/expose.ts +4 -3
  405. package/style/value.ts +26 -11
  406. package/style/valueRef.ts +1 -1
  407. package/style/weight.ts +21 -0
  408. package/utils/global.ts +1 -3
  409. package/utils/hash.ts +4 -0
  410. package/utils/symbol.ts +3 -0
  411. package/atomic/layer/README.md +0 -116
  412. package/atomic/utils/css.ts +0 -49
  413. package/dist/assert-h_Zkqc4E.js +0 -105
  414. package/dist/assert-h_Zkqc4E.js.map +0 -1
  415. package/dist/className-C1Ht5Wvv.js +0 -144
  416. package/dist/className-C1Ht5Wvv.js.map +0 -1
  417. package/dist/className-DC2Cq8p3.js +0 -251
  418. package/dist/className-DC2Cq8p3.js.map +0 -1
  419. package/dist/compiler-DweanHoB.mjs.map +0 -1
  420. package/dist/config-BryWDfQX.js +0 -25
  421. package/dist/config-BryWDfQX.js.map +0 -1
  422. package/dist/config-DKHXWhe1.js +0 -1
  423. package/dist/config-Di2VYYKV.js +0 -6
  424. package/dist/config-DloHOG6I.js +0 -13
  425. package/dist/config-DloHOG6I.js.map +0 -1
  426. package/dist/css-BowBszUt.js +0 -243
  427. package/dist/css-BowBszUt.js.map +0 -1
  428. package/dist/css-ByOrugEX.js +0 -805
  429. package/dist/css-ByOrugEX.js.map +0 -1
  430. package/dist/css-DcazYor9.js +0 -235
  431. package/dist/css-DcazYor9.js.map +0 -1
  432. package/dist/css_extra-DlOnsnR1.js +0 -8
  433. package/dist/css_extra-oIi3UEPK.js.map +0 -1
  434. package/dist/data-_te7t0M4.js +0 -473
  435. package/dist/data-_te7t0M4.js.map +0 -1
  436. package/dist/debug-BAw63qX6.js +0 -15
  437. package/dist/debug-BAw63qX6.js.map +0 -1
  438. package/dist/debug-DGki_v7g.js +0 -15
  439. package/dist/debug-DGki_v7g.js.map +0 -1
  440. package/dist/debug-n2aZQBSa.js.map +0 -1
  441. package/dist/dev-CcphAa3R.js.map +0 -1
  442. package/dist/dev-DfBbuLeE.js +0 -71
  443. package/dist/dev-DfBbuLeE.js.map +0 -1
  444. package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
  445. package/dist/extract-CzWJeQi8.js +0 -121
  446. package/dist/extract-CzWJeQi8.js.map +0 -1
  447. package/dist/extract-DEwSDJ9Z.js +0 -2
  448. package/dist/format-3nKBE_5t.js.map +0 -1
  449. package/dist/getClassName-BlvXHYuf.js.map +0 -1
  450. package/dist/global-CvfmFLsK.js +0 -11
  451. package/dist/global-CvfmFLsK.js.map +0 -1
  452. package/dist/jsx-CwTeyUxr.js +0 -39
  453. package/dist/jsx-CwTeyUxr.js.map +0 -1
  454. package/dist/jsx-D2BksHSv.js +0 -38
  455. package/dist/jsx-D2BksHSv.js.map +0 -1
  456. package/dist/layer-D1SaH07m.js +0 -94
  457. package/dist/layer-D1SaH07m.js.map +0 -1
  458. package/dist/loader-DS61nRqr.mjs.map +0 -1
  459. package/dist/misc-B9kqEb2N.mjs.map +0 -1
  460. package/dist/presets-Bye3ea2x.js +0 -139
  461. package/dist/presets-Bye3ea2x.js.map +0 -1
  462. package/dist/property-CnLFt5kx.js +0 -406
  463. package/dist/property-CnLFt5kx.js.map +0 -1
  464. package/dist/rules-9HSO1pxL.js.map +0 -1
  465. package/dist/runtime-CYqNCiaM.js.map +0 -1
  466. package/dist/shared-BAL9peIw.cjs.map +0 -1
  467. package/dist/style-4rFUy-zW.js +0 -752
  468. package/dist/style-4rFUy-zW.js.map +0 -1
  469. package/dist/style-B1UUqjj5.js +0 -743
  470. package/dist/style-B1UUqjj5.js.map +0 -1
  471. package/dist/style-Cw3NtvR0.js +0 -5
  472. package/dist/style-DNqQ6H-7.js +0 -1255
  473. package/dist/style-DNqQ6H-7.js.map +0 -1
  474. package/dist/styleStore-Dea_WVbr.js.map +0 -1
  475. package/dist/styleStore-DyNXBcUK.js.map +0 -1
  476. package/dist/token-CKXUECuU.js +0 -76
  477. package/dist/token-CKXUECuU.js.map +0 -1
  478. package/dist/token-u_tM-mtg.js +0 -204
  479. package/dist/token-u_tM-mtg.js.map +0 -1
  480. package/dist/utils-BbehLOby.js.map +0 -1
  481. package/dist/utils-C7xfDxtM.mjs +0 -97
  482. package/dist/utils-C7xfDxtM.mjs.map +0 -1
  483. package/dist/utils-CWNHx4EC.js +0 -170
  484. package/dist/utils-CWNHx4EC.js.map +0 -1
  485. package/dist/utils-D7FAOyg6.js.map +0 -1
  486. package/dist/value-BR4e2MKt.js +0 -910
  487. package/dist/value-BR4e2MKt.js.map +0 -1
  488. package/dist/value-E8rEv2Oe.js +0 -136
  489. package/dist/value-E8rEv2Oe.js.map +0 -1
  490. package/dist/valueRef-lshFk1Cs.js +0 -16
  491. package/dist/valueRef-lshFk1Cs.js.map +0 -1
  492. package/dist/webpack-CxS2FDYU.mjs.map +0 -1
  493. package/dist/withTokens-LRidu3Vc.js +0 -95
  494. package/dist/withTokens-LRidu3Vc.js.map +0 -1
@@ -1,10 +1,11 @@
1
1
  import { compareLayerPriority, getLayerOrderCss, type LayerPriority } from '../../atomic/layer';
2
- import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../../config/config/css';
2
+ import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../../config/config/css';
3
3
  import { DEV_CONFIG } from '../../config/config/dev';
4
4
  import type { SheetOptions, SheetRule, StyleSheet } from '../types';
5
5
  import {
6
6
  createNoopSheet,
7
7
  createStyleTag,
8
+ getSheetLayerName,
8
9
  getSheetRulePriority,
9
10
  getStyleLayerName,
10
11
  insertStyleTagAfter,
@@ -18,12 +19,14 @@ type QueuedRule = {
18
19
  css: string;
19
20
  rule: SheetRule | null;
20
21
  priority: LayerPriority;
22
+ layer: 'style' | 'sheet' | false;
21
23
  };
22
24
 
23
25
  type SortGroup = {
24
26
  key: string;
25
27
  priority: LayerPriority;
26
28
  tags: DevRuleTag[];
29
+ layer: 'style' | 'sheet' | false;
27
30
  };
28
31
 
29
32
  export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
@@ -36,12 +39,13 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
36
39
  const inserted = new Set<string>();
37
40
  const queued: QueuedRule[] = [];
38
41
  const groups: SortGroup[] = [];
39
- const shouldLayer = CSS_CONFIG.layer !== false;
42
+ const shouldLayer = isStyleLayerEnabled();
40
43
  const layerName = getStyleLayerName();
41
44
  const tagPrefix = options.tagName ? options.tagName + ' ' : '';
42
- const layerTag = shouldLayer ? createStyleTag(document, tagPrefix + 'layers', options.nonce) : null;
45
+ let layerTag = shouldLayer ? createStyleTag(document, tagPrefix + 'layers', options.nonce) : null;
43
46
  let activeLayers: readonly string[] = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
44
47
  let layerText = '';
48
+ let hasSheetLayer = false;
45
49
 
46
50
  if (layerTag) {
47
51
  if (options.top) {
@@ -68,12 +72,21 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
68
72
  if (key && inserted.has(key)) return;
69
73
  if (key) inserted.add(key);
70
74
 
75
+ const requestedLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
76
+ const layer = requestedLayer === 'style' && !shouldLayer ? false : requestedLayer;
77
+ if (layer === 'sheet') {
78
+ hasSheetLayer = true;
79
+ ensureLayerTag();
80
+ updateLayerText();
81
+ }
82
+
71
83
  queued.push({
72
84
  css,
73
85
  rule: typeof rule === 'string' ? null : rule,
74
86
  priority: getSheetRulePriority(
75
87
  typeof rule === 'string' ? null : rule.priority,
76
88
  ),
89
+ layer,
77
90
  });
78
91
  },
79
92
 
@@ -104,7 +117,7 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
104
117
 
105
118
  for (let i = 0, len = queued.length; i < len; i++) {
106
119
  const item = queued[i];
107
- const group = ensureGroup(groups, item.priority);
120
+ const group = ensureGroup(groups, item.priority, item.layer);
108
121
  let active = group.tags[group.tags.length - 1] ?? null;
109
122
 
110
123
  if (!active || active.count >= maxRules) {
@@ -113,7 +126,11 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
113
126
  previous: layerTag,
114
127
  className: tagPrefix + 'rules ' + group.key,
115
128
  top: options.top,
116
- layerName: shouldLayer ? layerName : null,
129
+ layerName: group.layer === 'style'
130
+ ? layerName
131
+ : group.layer === 'sheet'
132
+ ? getSheetLayerName()
133
+ : null,
117
134
  sourcemap,
118
135
  nonce: options.nonce,
119
136
  });
@@ -146,41 +163,58 @@ export function createDevSortSheet(options: SheetOptions = {}): StyleSheet {
146
163
  function updateLayerText() {
147
164
  if (!layerTag) return;
148
165
 
149
- const next = getLayerOrderCss(activeLayers, layerName);
166
+ const names = [shouldLayer ? layerName : '', hasSheetLayer ? getSheetLayerName() : ''].filter(Boolean);
167
+ const next = getLayerOrderCss(activeLayers, names);
150
168
 
151
169
  if (next === layerText) return;
152
170
 
153
171
  layerText = next;
154
172
  layerTag.textContent = next;
155
173
  }
174
+
175
+ function ensureLayerTag() {
176
+ if (layerTag) return;
177
+
178
+ layerTag = createStyleTag(document!, tagPrefix + 'layers', options.nonce);
179
+ if (options.top) {
180
+ insertStyleTagAtTop(document!, layerTag);
181
+ } else {
182
+ insertStyleTagAfter(document!, layerTag, null);
183
+ }
184
+ }
156
185
  }
157
186
 
158
187
  function ensureGroup(
159
188
  groups: SortGroup[],
160
189
  priority: LayerPriority,
190
+ layer: 'style' | 'sheet' | false,
161
191
  ) {
162
- const key = getPriorityKey(priority);
192
+ const key = (layer === 'sheet' ? 'sheet-' : '') + getPriorityKey(priority);
163
193
 
164
194
  for (let i = 0, len = groups.length; i < len; i++) {
165
195
  const group = groups[i];
166
- const order = compareLayerPriority(priority, group.priority);
196
+ const order = getLayerRank(layer) - getLayerRank(group.layer) || compareLayerPriority(priority, group.priority);
167
197
 
168
- if (order === 0) return group;
198
+ if (order === 0 && layer === group.layer) return group;
169
199
 
170
200
  if (order < 0) {
171
- const next = { key, priority, tags: [] };
201
+ const next = { key, priority, tags: [], layer };
172
202
  groups.splice(i, 0, next);
173
203
  return next;
174
204
  }
175
205
  }
176
206
 
177
- const group = { key, priority, tags: [] };
207
+ const group = { key, priority, tags: [], layer };
178
208
 
179
209
  groups.push(group);
180
210
 
181
211
  return group;
182
212
  }
183
213
 
214
+ function getLayerRank(layer: 'style' | 'sheet' | false) {
215
+ return layer === 'style' ? 0 : layer === 'sheet' ? 1 : 2;
216
+ }
217
+
184
218
  function createGroupTag(
185
219
  document: Document,
186
220
  groups: SortGroup[],
package/sheet/prod.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { getLayerBlockCss, getLayerOrderCss } from '../atomic/layer';
2
- import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../config/config/css';
2
+ import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../config/config/css';
3
3
  import type { SheetOptions, StyleSheet } from './types';
4
4
  import {
5
5
  createNoopSheet,
6
6
  createSheetLayerState,
7
7
  createStyleTag,
8
- getSheetRulePriority,
8
+ getSheetLayerName,
9
+ getSheetLayerNames,
10
+ getSheetRuleLayerPriority,
9
11
  insertStyleTagAfter,
10
12
  normalizeRule,
11
13
  resolveDocument,
@@ -24,12 +26,13 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
24
26
  let layerText = '';
25
27
  let layerTag: HTMLStyleElement | null = null;
26
28
  let ruleTag: HTMLStyleElement | null = null;
29
+ let hasSheetLayer = false;
27
30
 
28
31
  return {
29
32
  updateLayers(layers) {
30
33
  activeLayers = layers;
31
34
 
32
- const next = getLayerOrderCss(layers, layerState.getNames());
35
+ const next = getLayerOrderCss(layers, getSheetLayerNames(layerState, hasSheetLayer));
33
36
  if (next === layerText) return;
34
37
 
35
38
  layerText = next;
@@ -43,12 +46,20 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
43
46
 
44
47
  if (ruleKey && inserted.has(ruleKey)) return;
45
48
 
46
- const priority = typeof rule === 'string' ? null : rule.priority;
47
- const layerName = layerState.getName(getSheetRulePriority(priority));
49
+ const priority = typeof rule === 'string'
50
+ ? getSheetRuleLayerPriority(null, false)
51
+ : getSheetRuleLayerPriority(rule.priority, rule.important);
52
+ const ruleLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
53
+ if (ruleLayer === 'sheet') hasSheetLayer = true;
54
+ const layerName = ruleLayer === 'sheet'
55
+ ? getSheetLayerName()
56
+ : ruleLayer === false || !isStyleLayerEnabled()
57
+ ? null
58
+ : layerState.getName(priority);
48
59
 
49
60
  const nextLayerText = getLayerOrderCss(
50
61
  activeLayers,
51
- layerState.getNames(),
62
+ getSheetLayerNames(layerState, hasSheetLayer),
52
63
  );
53
64
 
54
65
  if (nextLayerText !== layerText) {
@@ -57,7 +68,7 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
57
68
  layerTag.textContent = nextLayerText;
58
69
  }
59
70
 
60
- const css = getLayerBlockCss(layerName, rawCss);
71
+ const css = layerName ? getLayerBlockCss(layerName, rawCss) : rawCss;
61
72
  const key = typeof rule === 'string' ? css : ruleKey;
62
73
 
63
74
  if (key && inserted.has(key)) return;
package/sheet/types.ts CHANGED
@@ -8,6 +8,8 @@ export type SheetRule = {
8
8
  css: string;
9
9
  key?: string | null;
10
10
  priority?: LayerPriority | null;
11
+ important?: boolean;
12
+ layer?: 'style' | 'sheet' | false;
11
13
  callsite?: SheetCallsite | null;
12
14
  debug?: DebugData | null;
13
15
  debugField?: string | null;
@@ -9,6 +9,39 @@ export function getSheetRulePriority(priority: LayerPriority | null | undefined)
9
9
  return priority ?? LayerDefaultPriority;
10
10
  }
11
11
 
12
+ export function getSheetRuleLayerPriority(
13
+ priority: LayerPriority | null | undefined,
14
+ important: boolean | null | undefined,
15
+ ): LayerPriority {
16
+ const resolved = getSheetRulePriority(priority);
17
+
18
+ // Cascade layer order is reversed for important declarations. Mirror the
19
+ // atomic priority so a higher Fluentic priority still wins in that cascade.
20
+ return important
21
+ ? [
22
+ -resolved[0],
23
+ -resolved[1],
24
+ -resolved[2],
25
+ -resolved[3],
26
+ -resolved[4],
27
+ -resolved[5],
28
+ -resolved[6],
29
+ ]
30
+ : resolved;
31
+ }
32
+
12
33
  export function getStyleLayerName() {
13
34
  return CSS_CONFIG.layerNamespace || LayerDefaultNamespace;
14
35
  }
36
+
37
+ export function getSheetLayerName() {
38
+ return getStyleLayerName() + '.sheet';
39
+ }
40
+
41
+ export function getSheetLayerNames(
42
+ layerState: ReturnType<typeof createSheetLayerState>,
43
+ hasSheetLayer: boolean,
44
+ ) {
45
+ const names = layerState.getNames();
46
+ return hasSheetLayer ? names.concat(getSheetLayerName()) : names;
47
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ type ClassNameFn,
3
+ createClassNameBuilder,
4
+ type ImportantClassName,
5
+ type WeightedClassName,
6
+ } from '../builder/classname';
7
+ import type { SelectorsRecord } from '../builder/types';
8
+ import { PrioritySelectors } from '../selector/presets';
9
+ import type { Type } from '../utils/type';
10
+ import { assignStyleFnMeta } from './style';
11
+ import type { ClassNameTransform } from './transform';
12
+
13
+ export type { ClassNameBuilder, ClassNameFn, ClassNameItem, WeightedClassName } from '../builder/classname';
14
+ export type { ClassNameTransform } from './transform';
15
+
16
+ type InferClassName<Transform> = Transform extends ClassNameTransform<infer ClassName> ? ClassName : never;
17
+
18
+ export function createClassNameFn<
19
+ const Selectors extends SelectorsRecord = typeof PrioritySelectors,
20
+ const Transform extends ClassNameTransform<any> = ClassNameTransform<string>,
21
+ ClassName extends string = InferClassName<Transform>,
22
+ >(args: {
23
+ className?: Type<ClassName>;
24
+ selectors: Selectors;
25
+ transform: Transform;
26
+ }) {
27
+ const { selectors, transform } = args;
28
+
29
+ const fnClassName = createClassNameBuilder<ClassName, Selectors>(selectors, transform);
30
+ const className = fnClassName as ClassNameFn<ClassName, Selectors>;
31
+
32
+ className.weight = (className, weight): WeightedClassName<ClassName> => {
33
+ return { className, weight };
34
+ };
35
+
36
+ className.important = (className): ImportantClassName<ClassName> => {
37
+ return { className, important: true };
38
+ };
39
+
40
+ assignStyleFnMeta(className, {
41
+ mode: 'ClassName',
42
+ selectors,
43
+ transform,
44
+ });
45
+
46
+ return { className };
47
+ }
@@ -0,0 +1,19 @@
1
+ import { symbol } from '../utils/symbol';
2
+
3
+ const STYLE_IMPORTANT: unique symbol = symbol('style.important');
4
+
5
+ export type StyleImportantValue<T = unknown> = {
6
+ readonly [STYLE_IMPORTANT]: true;
7
+ readonly value: T;
8
+ };
9
+
10
+ export function importantValue<T>(value: T): StyleImportantValue<T> {
11
+ return {
12
+ [STYLE_IMPORTANT]: true,
13
+ value,
14
+ };
15
+ }
16
+
17
+ export function isStyleImportantValue(value: unknown): value is StyleImportantValue {
18
+ return !!value && typeof value === 'object' && (value as StyleImportantValue)[STYLE_IMPORTANT] === true;
19
+ }
package/style/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './classname';
2
+ export * from './important';
1
3
  export * from './keyframes';
2
4
  export * from './style';
3
5
  export * from './theme';
@@ -7,3 +9,4 @@ export * from './transform';
7
9
  export * from './types';
8
10
  export * from './value';
9
11
  export * from './valueRef';
12
+ export * from './weight';
package/style/style.ts CHANGED
@@ -1,23 +1,39 @@
1
- import { createScopeBuilder, createSlotBuilder, createStyleBuilder, type SelectorsRecord } from '../builder';
1
+ import {
2
+ createScopeBuilder,
3
+ createSelectorBuilder,
4
+ createSlotBuilder,
5
+ createStyleBuilder,
6
+ type SelectorsRecord,
7
+ } from '../builder';
8
+ import type { ClassNameFn } from '../builder/classname';
2
9
  import { isStyleData } from '../builder/data';
3
10
  import { mergeStyleData } from '../builder/style_data';
4
11
  import { createDefaultFnResult } from '../builder/style_fns';
5
12
  import type { typeAliases } from '../builder/types/alias';
6
13
  import type { StableIdInput } from '../css/utils';
7
14
  import { PrioritySelectors } from '../selector/presets';
8
- import { symbol } from '../utils/global';
15
+ import { symbol } from '../utils/symbol';
9
16
  import { type } from '../utils/type';
10
17
  import type { Type } from '../utils/type';
18
+ import { importantValue } from './important';
11
19
  import { createStyleKeyframes } from './keyframes';
12
- import type { StyleTransform } from './transform';
20
+ import type { ClassNameTransform, StyleTransform } from './transform';
13
21
  import type { CSSProperties } from './types';
22
+ import { weightValue } from './weight';
14
23
 
15
24
  const META: unique symbol = symbol('style.fn:meta');
16
25
 
17
- export type StyleFnMeta = {
18
- selectors: SelectorsRecord;
19
- transform: StyleTransform | null;
20
- };
26
+ export type StyleFnMeta =
27
+ | {
28
+ mode: 'StyleObject';
29
+ selectors: SelectorsRecord;
30
+ transform: StyleTransform | null;
31
+ }
32
+ | {
33
+ mode: 'ClassName';
34
+ selectors: SelectorsRecord;
35
+ transform: ClassNameTransform;
36
+ };
21
37
 
22
38
  export const { style } = createStyleFn({
23
39
  style: type<CSSProperties>,
@@ -29,10 +45,10 @@ export type StyleFn<Style = any, Selectors extends SelectorsRecord = any> = Retu
29
45
  >['style'];
30
46
 
31
47
  export function createStyleFn<
32
- Style,
33
- const Selectors extends SelectorsRecord,
48
+ Style = CSSProperties,
49
+ const Selectors extends SelectorsRecord = typeof PrioritySelectors,
34
50
  >(args: {
35
- style: Type<Style>;
51
+ style?: Type<Style>;
36
52
  selectors: Selectors;
37
53
  transform?: StyleTransform<Style> | null;
38
54
  }) {
@@ -42,11 +58,13 @@ export function createStyleFn<
42
58
 
43
59
  const fnStyle = createStyleBuilder<Style, Selectors>(selectors, transform);
44
60
  const fnSlot = createSlotBuilder<Style, Selectors>(selectors, transform);
45
- const fnScope = createScopeBuilder<Style, Selectors>(selectors);
61
+ const fnScope = createScopeBuilder<Selectors>(selectors);
62
+ const fnSelector = createSelectorBuilder<Style, Selectors>(selectors, transform);
46
63
 
47
- const fnValue: Types['ValueFn'] = (value, weight) => {
48
- return [weight, value];
64
+ const fnWeight: Types['ValueFn'] = (value, weight) => {
65
+ return weightValue(value, weight);
49
66
  };
67
+ const fnImportant: Types['ImportantFn'] = (value) => importantValue(value);
50
68
  const fnRaw: Types['RawFn'] = (style) => style;
51
69
  const fnPlain: Types['PlainFn'] = (style) => style;
52
70
  const fnKeyframes: Types['KeyframesFn'] =
@@ -67,18 +85,21 @@ export function createStyleFn<
67
85
 
68
86
  style.slot = fnSlot;
69
87
  style.scope = fnScope;
70
- style.value = fnValue;
88
+ style.weight = fnWeight;
89
+ style.important = fnImportant;
71
90
  style.raw = fnRaw;
72
91
  style.plain = fnPlain;
73
92
  style.keyframes = fnKeyframes;
74
93
  style.merge = fnMerge;
94
+ style.selector = fnSelector as Types['SelectorFn'];
75
95
 
76
96
  const meta: StyleFnMeta = {
97
+ mode: 'StyleObject',
77
98
  selectors,
78
99
  transform: transform ?? null,
79
100
  };
80
101
 
81
- Object.assign(style, { [META]: meta });
102
+ assignStyleFnMeta(style, meta);
82
103
 
83
104
  return { style };
84
105
  }
@@ -107,6 +128,16 @@ function mergeStyleResult(
107
128
  return target;
108
129
  }
109
130
 
110
- export function getStyleFnMeta(styleFn: StyleFn) {
131
+ export type StyleFnWithMeta = StyleFn | ClassNameFn<any, any>;
132
+
133
+ export function assignStyleFnMeta<T extends object>(
134
+ styleFn: T,
135
+ meta: StyleFnMeta,
136
+ ) {
137
+ Object.assign(styleFn, { [META]: meta });
138
+ return styleFn;
139
+ }
140
+
141
+ export function getStyleFnMeta(styleFn: StyleFnWithMeta) {
111
142
  return (styleFn as any)[META] as StyleFnMeta;
112
143
  }
package/style/theme.ts CHANGED
@@ -8,19 +8,20 @@ import type { StyleTokenOverride } from './token';
8
8
 
9
9
  const idCounter = createIdCounter('theme');
10
10
 
11
+ export type TokenTheme = ThemeData;
12
+
11
13
  export function resetStyleThemeIdCounter() {
12
14
  idCounter.value = 0;
13
15
  }
14
16
 
15
17
  export function createTheme(
16
18
  tokens: readonly StyleTokenOverride[],
17
- stableId?: StableId | string,
18
- ): ThemeData;
19
+ ): TokenTheme;
19
20
  export function createTheme(
20
21
  tokens: readonly StyleTokenOverride[],
21
22
  stableId?: StableId | string,
22
23
  callsite?: BuilderCallsite | null,
23
- ): ThemeData {
24
+ ): TokenTheme {
24
25
  const normalizedStableId = typeof stableId === 'string'
25
26
  ? { name: stableId, id: stableId }
26
27
  : stableId;
package/style/token.ts CHANGED
@@ -1,12 +1,24 @@
1
1
  import type { DebugData } from '../builder/data/debug';
2
- import { globalData, symbol } from '../utils/global';
2
+ import { getStyleTokenId, getStyleTokenName, isStyleTokenData } from '../builder/token/data';
3
+ import { getStyleTokenNameFromId, normalizeStyleTokenName } from '../builder/token/name';
4
+ import { globalData } from '../utils/global';
5
+ import { symbol } from '../utils/symbol';
6
+ export {
7
+ getStyleTokenId,
8
+ getStyleTokenName,
9
+ getStyleTokenVarName,
10
+ isStyleTokenData,
11
+ isStyleTokenOverrideData,
12
+ } from '../builder/token/data';
13
+ export { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
14
+ import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
3
15
 
4
- export const TOKEN_ID: unique symbol = symbol('style:token');
5
- export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
6
16
  export const TOKEN_DEBUG: unique symbol = symbol('style:token.debug');
7
17
 
8
18
  export type StyleTokenData<T = unknown> = {
9
19
  [TOKEN_ID]: string;
20
+ [TOKEN_NAME]?: string | null;
21
+ [TOKEN_VAR_NAME]?: string | null;
10
22
  [TOKEN_OVERRIDE]?: false;
11
23
  value: T;
12
24
  ref: StyleTokenData<T> | null;
@@ -16,6 +28,8 @@ export type StyleTokenOverride<T = unknown> = {
16
28
  [TOKEN_ID]: string;
17
29
  [TOKEN_OVERRIDE]: true;
18
30
  [TOKEN_DEBUG]?: DebugData | null;
31
+ [TOKEN_NAME]?: string | null;
32
+ [TOKEN_VAR_NAME]?: string | null;
19
33
  value: T;
20
34
  ref: StyleTokenData<T> | null;
21
35
  };
@@ -30,12 +44,17 @@ export function resetStyleTokenIdCounter() {
30
44
  idCounter.value = 0;
31
45
  }
32
46
 
33
- export function createStyleToken<T>(value: T | StyleToken<T>, debugId?: string) {
47
+ export function createStyleToken<T>(
48
+ value: T | StyleToken<T>,
49
+ stableId?: string,
50
+ debugName?: string | null,
51
+ ) {
34
52
  const token: StyleToken<T> = (value, debug) => {
35
53
  return createStyleTokenOverride(token, value, debug);
36
54
  };
37
55
 
38
- token[TOKEN_ID] = debugId || String(idCounter.value++);
56
+ token[TOKEN_ID] = stableId || String(idCounter.value++);
57
+ token[TOKEN_NAME] = debugName === undefined ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
39
58
 
40
59
  if (isStyleTokenData<T>(value)) {
41
60
  token.value = value.value;
@@ -57,12 +76,14 @@ export function createStyleTokenOverride<T>(
57
76
  ? {
58
77
  [TOKEN_ID]: getStyleTokenId(token),
59
78
  [TOKEN_OVERRIDE]: true,
79
+ [TOKEN_NAME]: getStyleTokenName(token),
60
80
  value: value.value,
61
81
  ref: value,
62
82
  }
63
83
  : {
64
84
  [TOKEN_ID]: getStyleTokenId(token),
65
85
  [TOKEN_OVERRIDE]: true,
86
+ [TOKEN_NAME]: getStyleTokenName(token),
66
87
  value: value as T,
67
88
  ref: null,
68
89
  };
@@ -83,19 +104,3 @@ export function getStyleTokenOverrideDebug(
83
104
  ) {
84
105
  return token[TOKEN_DEBUG] ?? null;
85
106
  }
86
-
87
- export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
88
- return !!value &&
89
- typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
90
- (value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
91
- }
92
-
93
- export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
94
- return !!value &&
95
- typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
96
- (value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
97
- }
98
-
99
- export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
100
- return token[TOKEN_ID];
101
- }
package/style/tokens.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { getChildStyleTokenName } from '../builder/token/name';
1
2
  import type { StyleToken } from './token';
2
- import { createToken, type InferValue, type ValueBase } from './value';
3
+ import { createStyleToken } from './token';
4
+ import type { InferValue, ValueBase } from './value';
3
5
 
4
6
  export type TokenTuple<T extends readonly ValueBase[]> = {
5
7
  [P in T[number]]: StyleToken<InferValue<P>>;
@@ -14,25 +16,27 @@ export type TokenRecord<T extends object> = {
14
16
 
15
17
  export function createTokens<const T extends readonly ValueBase[]>(
16
18
  values: T,
17
- debugId?: string,
18
19
  ): TokenTuple<T>;
19
20
  export function createTokens<T extends object>(
20
21
  values: T,
21
- debugId?: string,
22
22
  ): TokenRecord<T>;
23
23
  export function createTokens(
24
24
  values: readonly ValueBase[] | Record<PropertyKey, unknown>,
25
- debugId?: string,
25
+ stableId?: string,
26
26
  ): any {
27
27
  const tokens: Record<PropertyKey, StyleToken> = {};
28
28
 
29
29
  if (Array.isArray(values)) {
30
30
  for (let i = 0, len = values.length; i < len; i++) {
31
31
  const value = values[i];
32
- tokens[value] = createToken(value, getChildDebugId(debugId, String(i)));
32
+ tokens[value] = createStyleToken(
33
+ value,
34
+ getChildStableId(stableId, String(i)),
35
+ getChildStyleTokenName(stableId, String(i)),
36
+ );
33
37
  }
34
38
  } else {
35
- assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, debugId);
39
+ assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, stableId, stableId ?? null);
36
40
  }
37
41
 
38
42
  return tokens;
@@ -41,24 +45,26 @@ export function createTokens(
41
45
  function assignTokenRecord(
42
46
  target: Record<PropertyKey, unknown>,
43
47
  values: Record<PropertyKey, unknown>,
44
- debugId: string | undefined,
48
+ stableId: string | undefined,
49
+ debugName: string | null,
45
50
  ) {
46
51
  for (let key in values) {
47
52
  const value = values[key];
53
+ const childName = getChildStyleTokenName(debugName, key);
48
54
 
49
55
  if (value && typeof value === 'object' && !Array.isArray(value)) {
50
56
  const child: Record<PropertyKey, unknown> = {};
51
57
  target[key] = child;
52
- assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildDebugId(debugId, key));
58
+ assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildStableId(stableId, key), childName);
53
59
  } else {
54
- target[key] = createToken(value, getChildDebugId(debugId, key));
60
+ target[key] = createStyleToken(value, getChildStableId(stableId, key), childName);
55
61
  }
56
62
  }
57
63
  }
58
64
 
59
- function getChildDebugId(
60
- debugId: string | undefined,
65
+ function getChildStableId(
66
+ stableId: string | undefined,
61
67
  child: string,
62
68
  ) {
63
- return debugId ? debugId + '--' + child : undefined;
69
+ return stableId ? stableId + '--' + child : undefined;
64
70
  }