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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +106 -31
  3. package/atomic/className.ts +29 -6
  4. package/atomic/debug/className/className.ts +10 -0
  5. package/atomic/rule.ts +6 -3
  6. package/atomic/utils/hash.ts +1 -65
  7. package/atomic/utils/selector.ts +14 -1
  8. package/builder/classname/class_name_builder.ts +68 -24
  9. package/builder/classname/fns.ts +2 -2
  10. package/builder/classname/types.ts +7 -0
  11. package/builder/data/const.ts +6 -0
  12. package/builder/data/create.ts +42 -0
  13. package/builder/data/data.ts +20 -1
  14. package/builder/data/index.ts +0 -1
  15. package/builder/data/is.ts +23 -0
  16. package/builder/data/merge/scope.ts +20 -19
  17. package/builder/data/merge/style.ts +70 -20
  18. package/builder/data/state.ts +16 -2
  19. package/builder/extract/index.ts +1 -0
  20. package/builder/extract/sheet.ts +26 -0
  21. package/builder/extract/utils.ts +2 -0
  22. package/builder/extract/withTokens.ts +2 -1
  23. package/builder/selector_override.noop.ts +11 -0
  24. package/builder/selector_override.ts +30 -0
  25. package/builder/selector_override_core.ts +66 -0
  26. package/builder/style_builder.ts +127 -3
  27. package/builder/style_data.ts +24 -0
  28. package/builder/style_fns.ts +24 -24
  29. package/builder/types/alias.ts +34 -6
  30. package/builder/types/fns.ts +13 -5
  31. package/builder/types/types.ts +32 -2
  32. package/builder/utils.ts +1 -0
  33. package/compiler/compiler/compiler.ts +88 -14
  34. package/compiler/compiler/constants.ts +6 -0
  35. package/compiler/compiler/index.ts +1 -0
  36. package/compiler/compiler/types.ts +2 -0
  37. package/compiler/cssProp.ts +21 -0
  38. package/compiler/index.ts +1 -0
  39. package/compiler/transform/cssProp/index.ts +1 -0
  40. package/compiler/transform/cssProp/plugin.ts +161 -0
  41. package/compiler/transform/debug/plugin.ts +6 -0
  42. package/compiler/transform/debug/transform.ts +2 -1
  43. package/compiler/transform/evaluator/evaluator.ts +33 -4
  44. package/compiler/transform/evaluator/tracer.ts +30 -2
  45. package/compiler/transform/extract/chain/chain.ts +660 -73
  46. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  47. package/compiler/transform/extract/chain/types.ts +1 -1
  48. package/compiler/transform/extract/plugin.ts +20 -4
  49. package/compiler/transform/extract/transform.ts +2 -1
  50. package/compiler/transform/extract/utils/replacement.ts +47 -2
  51. package/compiler/transform/extract/utils/state.ts +2 -0
  52. package/compiler/transform/index.ts +1 -0
  53. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  54. package/compiler/utils/constants.ts +8 -1
  55. package/compiler/utils/import_source.ts +17 -7
  56. package/compiler/utils/imports.ts +11 -1
  57. package/config/config/css.ts +1 -0
  58. package/css/index.ts +2 -0
  59. package/css/sheet.ts +119 -0
  60. package/css/styleTarget.ts +251 -0
  61. package/dist/adapter/preact.js +2 -0
  62. package/dist/adapter/react.js +2 -0
  63. package/dist/adapter/solid.js +2 -0
  64. package/dist/className-hiAsQ9V6.js +303 -0
  65. package/dist/className-hiAsQ9V6.js.map +1 -0
  66. package/dist/combine-D0AXSTn-.js +1279 -0
  67. package/dist/combine-D0AXSTn-.js.map +1 -0
  68. package/dist/compiler/index.mjs +2 -2
  69. package/dist/{compiler-CE0ZgkdH.mjs → compiler-CCvRlaq0.mjs} +1467 -534
  70. package/dist/compiler-CCvRlaq0.mjs.map +1 -0
  71. package/dist/config-B-KbXpIh.js +6 -0
  72. package/dist/{config-oKOjOTWi.js.map → config-B-KbXpIh.js.map} +1 -1
  73. package/dist/config-B-w6rOe0.js +35 -0
  74. package/dist/config-B-w6rOe0.js.map +1 -0
  75. package/dist/{config-lJNLh7eM.js → config-B1WtpYar.js} +2 -2
  76. package/dist/{config-lJNLh7eM.js.map → config-B1WtpYar.js.map} +1 -1
  77. package/dist/{config-CduqubI8.js → config-CCMwA9Gm.js} +3 -3
  78. package/dist/config-CCMwA9Gm.js.map +1 -0
  79. package/dist/config-DOWSNV8w.js +1 -0
  80. package/dist/createTransformElement-PCilcudP.js +34 -0
  81. package/dist/createTransformElement-PCilcudP.js.map +1 -0
  82. package/dist/css-DirG7Jwu.js +1280 -0
  83. package/dist/css-DirG7Jwu.js.map +1 -0
  84. package/dist/css-GtUPEO9U.js.map +1 -1
  85. package/dist/css-nmclCl2P.js +479 -0
  86. package/dist/css-nmclCl2P.js.map +1 -0
  87. package/dist/css-shX7_73D.js +3894 -0
  88. package/dist/css-shX7_73D.js.map +1 -0
  89. package/dist/css.js +2 -2
  90. package/dist/{data-D7NFt4JG.js → data-DUvixly5.js} +155 -61
  91. package/dist/data-DUvixly5.js.map +1 -0
  92. package/dist/{debug-Cvpo5cVu.js → debug-DJRCBKhM.js} +80 -5
  93. package/dist/debug-DJRCBKhM.js.map +1 -0
  94. package/dist/dev/rsc.js +5 -8
  95. package/dist/dev/rsc.js.map +1 -1
  96. package/dist/{dev-DdRWa6dJ.js → dev-Cwha8aAp.js} +4 -4
  97. package/dist/{dev-DdRWa6dJ.js.map → dev-Cwha8aAp.js.map} +1 -1
  98. package/dist/dev.js +1 -1
  99. package/dist/dialect/extracted/index.js +1 -1
  100. package/dist/dialect/index.js +1 -1
  101. package/dist/{elementMarker-ng0y3fN0.js → elementMarker-Cb46vtLU.js} +94 -8
  102. package/dist/elementMarker-Cb46vtLU.js.map +1 -0
  103. package/dist/entry/dev/adapter/preact.js +12 -0
  104. package/dist/entry/dev/adapter/preact.js.map +1 -0
  105. package/dist/entry/dev/adapter/react.js +12 -0
  106. package/dist/entry/dev/adapter/react.js.map +1 -0
  107. package/dist/entry/dev/adapter/solid.js +12 -0
  108. package/dist/entry/dev/adapter/solid.js.map +1 -0
  109. package/dist/entry/dev/css.js +3 -3
  110. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  111. package/dist/entry/dev/jsx-runtime.js +2 -2
  112. package/dist/entry/dev.js +10 -8
  113. package/dist/entry/prod/adapter/preact.js +12 -0
  114. package/dist/entry/prod/adapter/preact.js.map +1 -0
  115. package/dist/entry/prod/adapter/react.js +12 -0
  116. package/dist/entry/prod/adapter/react.js.map +1 -0
  117. package/dist/entry/prod/adapter/solid.js +12 -0
  118. package/dist/entry/prod/adapter/solid.js.map +1 -0
  119. package/dist/entry/prod/css.js +3 -3
  120. package/dist/entry/prod/extract.js +240 -3
  121. package/dist/entry/prod/extract.js.map +1 -0
  122. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  123. package/dist/entry/prod/jsx-runtime.js +2 -2
  124. package/dist/entry/prod/runtime.js +3 -5
  125. package/dist/entry/prod.js +84 -1229
  126. package/dist/entry/prod.js.map +1 -1
  127. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  128. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  129. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  130. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  131. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  132. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  133. package/dist/entry/rsc-dev/css.js +3 -3
  134. package/dist/entry/rsc-dev/dev.js +5 -10
  135. package/dist/entry/rsc-dev/dev.js.map +1 -1
  136. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  137. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  138. package/dist/entry/rsc-dev.js +252 -750
  139. package/dist/entry/rsc-dev.js.map +1 -1
  140. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  141. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  142. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  143. package/dist/entry/rsc-prod/css.js +9 -3
  144. package/dist/entry/rsc-prod/css.js.map +1 -0
  145. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  146. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  147. package/dist/entry/rsc-prod/runtime.js +3 -5
  148. package/dist/entry/rsc-prod.js +236 -11
  149. package/dist/entry/rsc-prod.js.map +1 -1
  150. package/dist/{styleStore-CajcAEPO.js → env-0Gu2Jh47.js} +1148 -162
  151. package/dist/env-0Gu2Jh47.js.map +1 -0
  152. package/dist/getClassName-CHZKhmde.js +45 -0
  153. package/dist/getClassName-CHZKhmde.js.map +1 -0
  154. package/dist/{utils-B_VhPBHH.js → getClassName-CHd0iCXp.js} +28 -65
  155. package/dist/getClassName-CHd0iCXp.js.map +1 -0
  156. package/dist/getClassName-a6p2uMFM.js +536 -0
  157. package/dist/getClassName-a6p2uMFM.js.map +1 -0
  158. package/dist/{getClassName-CrNVjAoJ.js → getClassName-aD9zqg9U.js} +31 -10
  159. package/dist/getClassName-aD9zqg9U.js.map +1 -0
  160. package/dist/global-Dg37z0lV.js +14 -0
  161. package/dist/global-Dg37z0lV.js.map +1 -0
  162. package/dist/{hash-BfeJDf5U.js → hash-Cr-LCWDt.js} +35 -38
  163. package/dist/hash-Cr-LCWDt.js.map +1 -0
  164. package/dist/index.js +7 -6
  165. package/dist/jsx/jsx-dev-runtime.js +2 -2
  166. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  167. package/dist/jsx/jsx-runtime.js +2 -2
  168. package/dist/jsx/jsx-runtime.server.js +1 -1
  169. package/dist/jsx-BMFC8_tA.js +39 -0
  170. package/dist/jsx-BMFC8_tA.js.map +1 -0
  171. package/dist/{jsx_dev_runtime-aAhNYDeS.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
  172. package/dist/{jsx_dev_runtime-aAhNYDeS.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
  173. package/dist/{jsx_runtime-D7Y5up6H.js → jsx_runtime-BgK90E2O.js} +2 -3
  174. package/dist/{jsx_runtime-D7Y5up6H.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
  175. package/dist/{jsx_runtime-C6i1bWlu.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
  176. package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
  177. package/dist/{loader-BmYS_Rju.mjs → loader-hNaefW-U.mjs} +13 -14
  178. package/dist/loader-hNaefW-U.mjs.map +1 -0
  179. package/dist/{misc-BIS_c7BJ.mjs → misc-1OS0aeY1.mjs} +4 -4
  180. package/dist/misc-1OS0aeY1.mjs.map +1 -0
  181. package/dist/{namedTokens-CN_yhhik.js → namedTokens-mgRfd9hs.js} +3 -3
  182. package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
  183. package/dist/plugin/farm/index.mjs +4 -3
  184. package/dist/plugin/farm/index.mjs.map +1 -1
  185. package/dist/plugin/nextjs/index.mjs +121 -17
  186. package/dist/plugin/nextjs/index.mjs.map +1 -1
  187. package/dist/plugin/nextjs/loader.mjs +4 -4
  188. package/dist/plugin/parcel/index.cjs +2 -0
  189. package/dist/plugin/parcel/index.mjs +3 -1
  190. package/dist/plugin/parcel/optimizer.cjs +1 -1
  191. package/dist/plugin/parcel/optimizer.mjs +2 -2
  192. package/dist/plugin/parcel/resolver.cjs +1 -1
  193. package/dist/plugin/parcel/resolver.mjs +2 -2
  194. package/dist/plugin/parcel/runtime.cjs +1 -1
  195. package/dist/plugin/parcel/runtime.mjs +1 -1
  196. package/dist/plugin/parcel/transformer.cjs +1 -1
  197. package/dist/plugin/parcel/transformer.mjs +2 -2
  198. package/dist/plugin/rspack/index.mjs +3 -2
  199. package/dist/plugin/rspack/index.mjs.map +1 -1
  200. package/dist/plugin/vite/index.mjs +6 -6
  201. package/dist/plugin/vite/index.mjs.map +1 -1
  202. package/dist/plugin/webpack/index.mjs +3 -2
  203. package/dist/plugin/webpack/loader.mjs +2 -2
  204. package/dist/presets/tailwind/index.js +26 -5
  205. package/dist/presets/tailwind/index.js.map +1 -1
  206. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  207. package/dist/presets-DSanixJV.js.map +1 -0
  208. package/dist/{registry-IaXmLQzA.mjs → registry-OA0niXJL.mjs} +2 -2
  209. package/dist/{registry-IaXmLQzA.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
  210. package/dist/resolveClassNameRuntime-BKXT1bmR.js +63 -0
  211. package/dist/resolveClassNameRuntime-BKXT1bmR.js.map +1 -0
  212. package/dist/{rules-CxVzovt-.js → rules-DgcCENkw.js} +583 -154
  213. package/dist/rules-DgcCENkw.js.map +1 -0
  214. package/dist/{combine-C9vjpKCs.js → scope-BSuRLice.js} +239 -150
  215. package/dist/scope-BSuRLice.js.map +1 -0
  216. package/dist/selector/index.js +1 -2
  217. package/dist/server.js +12 -9
  218. package/dist/server.js.map +1 -1
  219. package/dist/{shared-CaJuvw03.cjs → shared-Bc9RwNNj.cjs} +1473 -535
  220. package/dist/shared-Bc9RwNNj.cjs.map +1 -0
  221. package/dist/{shared-DdPTZ0O3.mjs → shared-COiLPdZ1.mjs} +4 -4
  222. package/dist/{shared-DdPTZ0O3.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
  223. package/dist/sheet-B87QCFWF.js +7 -0
  224. package/dist/{sheet-BWBzuy4D.js.map → sheet-B87QCFWF.js.map} +1 -1
  225. package/dist/{sidecar-B3oCK9vC.mjs → sidecar-ViZUL9B8.mjs} +3 -3
  226. package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
  227. package/dist/{styleStore-0fARJlZV.js → styleStore-BlC8Ax9f.js} +3 -4
  228. package/dist/{styleStore-0fARJlZV.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
  229. package/dist/styleStore-DHzH25A7.js +51 -0
  230. package/dist/styleStore-DHzH25A7.js.map +1 -0
  231. package/dist/{token-D-S-4_mN.js → token-CAQWMtan.js} +2 -2
  232. package/dist/{token-D-S-4_mN.js.map → token-CAQWMtan.js.map} +1 -1
  233. package/dist/{trace-CFnhyCVf.js → trace-D3yBmJad.js} +2 -2
  234. package/dist/{trace-CFnhyCVf.js.map → trace-D3yBmJad.js.map} +1 -1
  235. package/dist/{trace-ZtgeY-8s.js → trace-DdXWjgAD.js} +3 -3
  236. package/dist/{trace-ZtgeY-8s.js.map → trace-DdXWjgAD.js.map} +1 -1
  237. package/dist/{style-CGaJndOl.js → types-BhdAXX7z.js} +268 -89
  238. package/dist/types-BhdAXX7z.js.map +1 -0
  239. package/dist/utils-B6HVRX10.js +42 -0
  240. package/dist/utils-B6HVRX10.js.map +1 -0
  241. package/dist/{utils-B5Xqf1lV.mjs → utils-C7UalRKf.mjs} +41 -7
  242. package/dist/utils-C7UalRKf.mjs.map +1 -0
  243. package/dist/utils-CUl1BU40.js +72 -0
  244. package/dist/utils-CUl1BU40.js.map +1 -0
  245. package/dist/{utils-DzydRwYo.js → utils-Cd4wqN56.js} +142 -149
  246. package/dist/utils-Cd4wqN56.js.map +1 -0
  247. package/dist/{utils-DaAiEEIG.mjs → utils-DjxH0zc7.mjs} +3 -3
  248. package/dist/{utils-DaAiEEIG.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
  249. package/dist/utils-DxCpyV2E.js +62 -0
  250. package/dist/utils-DxCpyV2E.js.map +1 -0
  251. package/dist/utils.js +4 -4
  252. package/dist/utils.js.map +1 -1
  253. package/dist/value-CpJpQ00y.js +145 -0
  254. package/dist/value-CpJpQ00y.js.map +1 -0
  255. package/dist/{webpack-CHydnRXB.mjs → webpack-6et2ZVI6.mjs} +5 -5
  256. package/dist/webpack-6et2ZVI6.mjs.map +1 -0
  257. package/entry/dev/adapter/preact.ts +8 -0
  258. package/entry/dev/adapter/react.ts +8 -0
  259. package/entry/dev/adapter/solid.ts +8 -0
  260. package/entry/prod/adapter/preact.ts +8 -0
  261. package/entry/prod/adapter/react.ts +8 -0
  262. package/entry/prod/adapter/solid.ts +8 -0
  263. package/entry/rsc_dev/adapter/preact.ts +9 -0
  264. package/entry/rsc_dev/adapter/react.ts +9 -0
  265. package/entry/rsc_dev/adapter/solid.ts +9 -0
  266. package/entry/rsc_prod/adapter/preact.ts +1 -0
  267. package/entry/rsc_prod/adapter/react.ts +1 -0
  268. package/entry/rsc_prod/adapter/solid.ts +1 -0
  269. package/entry/shared/config_dev.ts +1 -1
  270. package/jsx/types/index.ts +3 -0
  271. package/jsx/types/preact.ts +14 -0
  272. package/jsx/{types.ts → types/react.ts} +2 -2
  273. package/jsx/types/solid.ts +32 -0
  274. package/package.json +98 -22
  275. package/plugin/bundler/farm/plugin.ts +2 -0
  276. package/plugin/bundler/parcel/plugin.ts +2 -0
  277. package/plugin/bundler/rspack/plugin.ts +1 -0
  278. package/plugin/bundler/vite/plugin.ts +3 -8
  279. package/plugin/bundler/vite/state.ts +2 -2
  280. package/plugin/bundler/webpack/plugin.ts +2 -1
  281. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  282. package/plugin/nextjs/plugin.ts +208 -15
  283. package/plugin/nextjs/types.ts +1 -2
  284. package/plugin/nextjs/utils.ts +50 -0
  285. package/plugin/utils/compiler.ts +2 -0
  286. package/plugin/utils/runtimeEntry.ts +2 -2
  287. package/presets/tailwind/classname/transform.ts +32 -1
  288. package/runtime/adapter/utils.ts +120 -0
  289. package/runtime/core/cache/combine.ts +33 -4
  290. package/runtime/core/cache/item.ts +31 -12
  291. package/runtime/core/cache/itemWithResolver.ts +44 -0
  292. package/runtime/core/cache/prop.ts +7 -6
  293. package/runtime/core/cache/result.ts +2 -2
  294. package/runtime/core/cache/stateItem.ts +16 -1
  295. package/runtime/core/combinedStyle.ts +4 -4
  296. package/runtime/extract/combineStyle.ts +179 -5
  297. package/runtime/extract/getClassName.ts +49 -6
  298. package/runtime/sheet/rule.ts +3 -10
  299. package/runtime/style/scope.ts +0 -24
  300. package/runtime/style/style.ts +179 -5
  301. package/runtime/types.ts +3 -3
  302. package/style/classname.ts +12 -6
  303. package/style/important.ts +19 -0
  304. package/style/index.ts +2 -0
  305. package/style/style.ts +16 -4
  306. package/style/types.ts +6 -4
  307. package/style/utils/expose.ts +4 -3
  308. package/style/weight.ts +21 -0
  309. package/dist/assert-BGdigdr5.js.map +0 -1
  310. package/dist/className-Do2Crx4b.js +0 -143
  311. package/dist/className-Do2Crx4b.js.map +0 -1
  312. package/dist/combine-C9vjpKCs.js.map +0 -1
  313. package/dist/combineStyle-DwAhsOmS.js +0 -26
  314. package/dist/combineStyle-DwAhsOmS.js.map +0 -1
  315. package/dist/compiler-CE0ZgkdH.mjs.map +0 -1
  316. package/dist/config-BE5D5x2N.js +0 -2
  317. package/dist/config-CduqubI8.js.map +0 -1
  318. package/dist/config-oKOjOTWi.js +0 -7
  319. package/dist/css-BewrRz3_.js +0 -243
  320. package/dist/css-BewrRz3_.js.map +0 -1
  321. package/dist/css-CiTI58yl.js +0 -1094
  322. package/dist/css-CiTI58yl.js.map +0 -1
  323. package/dist/css-Rc7ILf-3.js +0 -236
  324. package/dist/css-Rc7ILf-3.js.map +0 -1
  325. package/dist/cssIdent-BsyUXNNk.js +0 -38
  326. package/dist/cssIdent-BsyUXNNk.js.map +0 -1
  327. package/dist/cssVar-DGgQ2GIK.js +0 -92
  328. package/dist/cssVar-DGgQ2GIK.js.map +0 -1
  329. package/dist/css_extra-DYtS3g6Z.js +0 -8
  330. package/dist/css_extra-DYtS3g6Z.js.map +0 -1
  331. package/dist/data-D7NFt4JG.js.map +0 -1
  332. package/dist/debug-Cvpo5cVu.js.map +0 -1
  333. package/dist/dev-px0_6TNq.js +0 -81
  334. package/dist/dev-px0_6TNq.js.map +0 -1
  335. package/dist/elementMarker-ng0y3fN0.js.map +0 -1
  336. package/dist/extract-B-Vs88ME.js +0 -3
  337. package/dist/extract-CM8Fk2eK.js +0 -130
  338. package/dist/extract-CM8Fk2eK.js.map +0 -1
  339. package/dist/getClassName-CrNVjAoJ.js.map +0 -1
  340. package/dist/global-CZBlA9E7.js +0 -14
  341. package/dist/global-CZBlA9E7.js.map +0 -1
  342. package/dist/hash-BfeJDf5U.js.map +0 -1
  343. package/dist/jsx-BY1iFewe.js +0 -39
  344. package/dist/jsx-BY1iFewe.js.map +0 -1
  345. package/dist/jsx-DL-DEAz8.js +0 -39
  346. package/dist/jsx-DL-DEAz8.js.map +0 -1
  347. package/dist/layer-BSxAr-hy.js +0 -94
  348. package/dist/layer-BSxAr-hy.js.map +0 -1
  349. package/dist/loader-BmYS_Rju.mjs.map +0 -1
  350. package/dist/misc-BIS_c7BJ.mjs.map +0 -1
  351. package/dist/presets-BhXa232U.js +0 -108
  352. package/dist/presets-BhXa232U.js.map +0 -1
  353. package/dist/property-BuLbzviK.js +0 -406
  354. package/dist/property-BuLbzviK.js.map +0 -1
  355. package/dist/rules-CxVzovt-.js.map +0 -1
  356. package/dist/selector-A-mRmMnI.js +0 -64
  357. package/dist/selector-A-mRmMnI.js.map +0 -1
  358. package/dist/shared-CaJuvw03.cjs.map +0 -1
  359. package/dist/sheet-BWBzuy4D.js +0 -7
  360. package/dist/style-CGaJndOl.js.map +0 -1
  361. package/dist/style-DDxjKdX0.js +0 -1891
  362. package/dist/style-DDxjKdX0.js.map +0 -1
  363. package/dist/style-S7LTQbRu.js +0 -5
  364. package/dist/styleStore-CajcAEPO.js.map +0 -1
  365. package/dist/symbols-Cp4ymzKF.js +0 -14
  366. package/dist/symbols-Cp4ymzKF.js.map +0 -1
  367. package/dist/utils-B5Xqf1lV.mjs.map +0 -1
  368. package/dist/utils-B_VhPBHH.js.map +0 -1
  369. package/dist/utils-CDUaX81o.js +0 -170
  370. package/dist/utils-CDUaX81o.js.map +0 -1
  371. package/dist/utils-DzydRwYo.js.map +0 -1
  372. package/dist/value-C0JRsyax.js +0 -64
  373. package/dist/value-C0JRsyax.js.map +0 -1
  374. package/dist/value-D08AocUs.js +0 -1053
  375. package/dist/value-D08AocUs.js.map +0 -1
  376. package/dist/valueRef-M3E1oza7.js +0 -16
  377. package/dist/valueRef-M3E1oza7.js.map +0 -1
  378. package/dist/webpack-CHydnRXB.mjs.map +0 -1
  379. package/dist/withTokens-DAzUIPvA.js +0 -95
  380. package/dist/withTokens-DAzUIPvA.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @fluentic/style
2
2
 
3
+ ## 0.1.0-beta.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 2bff82f: Improve css-prop adapters, class-name extraction, and Next.js build stability.
8
+
9
+ - Preserve normal JSX prop precedence when compiling intrinsic `css` props through React, Preact, and Solid adapters.
10
+ - Keep React `key` props outside generated css-prop spreads so list identity is preserved.
11
+ - Improve React Server Component development handling for css-prop adapter imports, including client components.
12
+ - Make class-name extraction produce stable debug hashes and better source locations for class-name utilities.
13
+ - Add Tailwind class-name support for arbitrary text values such as `text-[13px]`, `text-[length:13px]`, and `text-[color:purple]`.
14
+ - Improve Next.js integration for dev CSS delivery, Turbopack loader options, and production CSS precollection.
15
+ - Add default export conditions for common package entry points.
16
+
17
+ ## 0.1.0-beta.5
18
+
19
+ ### Patch Changes
20
+
21
+ - Add attachable selector sheets for styling fixed third-party class names
22
+ without emitting global CSS.
23
+
24
+ - Add `style.selector(...)` selector targets and `createSheet(...)` from
25
+ `@fluentic/style/css` for manual selector rules that still attach through
26
+ generated Fluentic classes.
27
+ - Support selector overrides and token overrides inside sheets so component
28
+ wrappers can expose local third-party themes with the same shape as
29
+ scoped style composition.
30
+ - Add `&` and `&?` selector handling for attached-element and portal-friendly
31
+ selector rules. Comma-separated selector strings are rejected; pass an
32
+ array when a rule should target multiple selectors.
33
+ - Add `createStyleTarget(...)` for applying style props to explicit DOM
34
+ targets such as `document.body`, with shared-target reference counting for
35
+ overlapping portal users.
36
+ - Make `combineStyle(...)` compose sheets directly, and add
37
+ `combineStyle.with(...)` plus array-only `combineStyle.multi(...)` for
38
+ cache-friendly style and sheet composition.
39
+ - Support selector sheet extraction, local token overrides, debug class
40
+ names, source tracing, and sourcemap data across runtime and extracted
41
+ builds.
42
+ - Add Preact css-prop support with a `CssPropPresets.Preact` compiler
43
+ preset, runtime adapters, JSX types, and a Vite example.
44
+ - Keep plugin css-prop configuration focused on `CssPropPresets` instead of
45
+ exporting each framework preset as a separate top-level plugin API.
46
+ - Add `style.important(...)` and `className.important(...)` for interop cases
47
+ that need emitted `!important` declarations, especially selector sheets
48
+ wrapping third-party CSS.
49
+ - Add `style.weight(...)` as the style-object counterpart to
50
+ `className.weight(...)`.
51
+ - Keep the extracted production runtime below 5 KB minified and gzipped with
52
+ `combineStyle` included, and keep selector parsing helpers out of the
53
+ extracted production entry.
54
+ - Add a React Select third-party selectors example, Preact integration docs,
55
+ and a clearer third-party styling guide for selector sheets, style targets,
56
+ portal menus, and the new `combineStyle` helpers.
57
+
3
58
  ## 0.1.0-beta.4
4
59
 
5
60
  ### Patch Changes
@@ -27,7 +82,7 @@ for transform-driven styling.
27
82
  ### Highlights
28
83
 
29
84
  - Add `createClassNameFn` for class-name-driven style builders.
30
- - Support nested class-name values, conditional falsey entries, weighted
85
+ - Support nested class-name values, conditional falsy entries, weighted
31
86
  class-name tokens, selector chaining, at-rules, and merges.
32
87
  - Add compiler extraction for class-name style chains.
33
88
  - Add Tailwind presets for both style-object and class-name authoring.
package/README.md CHANGED
@@ -1,23 +1,28 @@
1
1
  # Fluentic Style
2
2
 
3
- Component style composition for React.
3
+ Build your own styling language on top of a stable component styling model.
4
4
 
5
- React styling has a lot of good answers already: CSS files, utility classes,
5
+ Styling UI apps has a lot of good answers already: CSS files, utility classes,
6
6
  CSS-in-JS, compiled CSS, design tokens, and component libraries. Fluentic
7
7
  explores a specific question inside that space: what if styles composed around
8
- React components the same way props and state do?
9
-
10
- With Fluentic, you start simple with type-safe `style(...)` and the JSX `css`
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.
15
-
16
- For production builds, styles are extracted into static atomic CSS output.
17
- Dynamic values from props and state still work as usual.
8
+ components the same way props, state, and themes do?
9
+
10
+ With Fluentic, you start simple with type-safe `style(...)` values and attach
11
+ them through a JSX `css` prop or a framework adapter. React, Preact, and SolidJS
12
+ are supported today, with the core style data model designed to keep expanding
13
+ across JSX runtimes, compiler-backed frameworks, and server-rendered UI stacks.
14
+ If your team prefers utility class names, you can also create class-name style
15
+ chains, including a Tailwind-like preset.
16
+
17
+ When a component needs variants, themes, nested parts, or consumer overrides,
18
+ add slots, scopes, tokens, values, and `combineStyle(...)` so those styles stay
19
+ organized around the component instead of leaking through class names or private
20
+ DOM structure. For production builds, Fluentic extracts static styles into
21
+ atomic CSS output while dynamic values from props, state, signals, or request
22
+ data still work at runtime.
18
23
 
19
24
  [Docs](https://fluenticstack.com/style) |
20
- [Quick start](https://fluenticstack.com/style/docs/getting-started/quick-start/) |
25
+ [Start here](https://fluenticstack.com/style/docs/learn/start-here/) |
21
26
  [Playground](https://fluenticstack.com/style/playground/) |
22
27
  [npm](https://www.npmjs.com/package/@fluentic/style)
23
28
 
@@ -35,13 +40,35 @@ Or with pnpm:
35
40
  pnpm add @fluentic/style@beta
36
41
  ```
37
42
 
38
- Use Fluentic in a React app. Add a bundler plugin later when you want production
39
- extraction.
43
+ Use Fluentic in a JSX app. Add a bundler or framework plugin when you want
44
+ production extraction.
45
+
46
+ ## What Fluentic Supports
47
+
48
+ Fluentic is not tied to one styling vocabulary or one framework runtime. The
49
+ same style model powers CSS-like objects, custom design-system fields,
50
+ Tailwind-like object fields, class-name chains, slots, scopes, themes, tokens,
51
+ runtime values, static extraction, and development traces.
52
+
53
+ | Area | Support |
54
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
+ | Core styling model | [`style(...)`](https://fluenticstack.com/style/docs/reference/style/), [`style.slot(...)`](https://fluenticstack.com/style/docs/reference/style-slot/), [`style.scope(...)`](https://fluenticstack.com/style/docs/reference/style-scope/), [`combineStyle(...)`](https://fluenticstack.com/style/docs/reference/combine-style/), themes, tokens, values, selectors, at-rules, keyframes, and font faces. |
56
+ | Authoring vocabularies | CSS-like object styles, custom style functions, custom selectors, custom properties, Tailwind-like object fields, and Tailwind-like class-name chains. |
57
+ | Runtime paths | Runtime-only JSX setup for quick adoption, compiler-backed extracted runtime for production, and framework css-prop adapters that keep the framework's normal JSX transform. |
58
+ | Frameworks today | React, Next.js App Router, Preact, and SolidJS. |
59
+ | Bundlers today | Vite, Webpack, Rspack, Farm, Parcel 2, Babel/custom compiler use, and the Next.js integration for App Router projects. |
60
+ | Development tools | Readable debug class names, source traces, JSX element markers, sourcemaps, priority inspection, and React Server Component development support for Next.js. |
61
+
62
+ See the [integration overview](https://fluenticstack.com/style/docs/integrations/overview/)
63
+ for setup guides and the
64
+ [reference overview](https://fluenticstack.com/style/docs/reference/overview/)
65
+ for the API surface.
40
66
 
41
67
  ## Configure Runtime JSX
42
68
 
43
69
  Enable the runtime JSX import source so DOM and SVG elements accept the `css`
44
- prop. This path works without a Fluentic bundler plugin.
70
+ prop. This path works without a Fluentic bundler plugin and is the quickest
71
+ React setup path.
45
72
 
46
73
  ```jsonc
47
74
  /* tsconfig.json */
@@ -53,10 +80,14 @@ prop. This path works without a Fluentic bundler plugin.
53
80
  }
54
81
  ```
55
82
 
83
+ For SolidJS and Preact, keep the framework's normal JSX configuration and use
84
+ the Vite css-prop adapter instead:
85
+ [SolidJS](https://fluenticstack.com/style/docs/integrations/solidjs/) and
86
+ [PreactJS](https://fluenticstack.com/style/docs/integrations/preact/).
87
+
56
88
  ## Why Another Style Library?
57
89
 
58
- Component libraries need more than a way to attach styles to elements. They
59
- need:
90
+ Component systems need more than a way to attach styles to elements. They need:
60
91
 
61
92
  - base styles owned by the component;
62
93
  - state styles for hover, focus, active, disabled, media, and container queries;
@@ -98,8 +129,9 @@ export function Card() {
98
129
  }
99
130
  ```
100
131
 
101
- That is the smallest version of Fluentic Style: type-safe styles, selectors, and
102
- a `css` prop.
132
+ That is the smallest version of Fluentic Style: type-safe styles, selectors,
133
+ and a component-owned style value attached to JSX. The example uses React-style
134
+ syntax, but the same style data can be lowered through framework adapters.
103
135
 
104
136
  ## Class Name Chains
105
137
 
@@ -146,7 +178,11 @@ for the built-in Tailwind-like class-name vocabulary.
146
178
 
147
179
  ## Scale Into Components
148
180
 
149
- When a component becomes reusable, give its styles component structure.
181
+ When a component becomes reusable, give its styles component structure. This
182
+ section uses React component types for the example, but the important part is
183
+ the framework-independent style model: slots name public styling targets, scopes
184
+ describe changes to those targets, and the component decides where resolved
185
+ styles attach.
150
186
 
151
187
  ```tsx
152
188
  /* tokens.ts */
@@ -329,15 +365,24 @@ priority with layers or sorted output.
329
365
 
330
366
  ## Add Production Extraction
331
367
 
332
- Fluentic Style works without a compiler. In runtime mode, the JSX `css` prop
333
- resolves class names and inserts atomic CSS rules as needed.
368
+ Fluentic Style works without a compiler. In runtime-only mode, the JSX `css`
369
+ prop resolves class names and inserts atomic CSS rules as needed. That is useful
370
+ for trying the API, custom environments, and incremental adoption.
371
+
372
+ For production builds, add a bundler or framework plugin. Static styles are
373
+ extracted into ordered atomic CSS output. Runtime composition stays available
374
+ for values that still depend on props, state, signals, request data, user input,
375
+ or incoming themes.
376
+
377
+ There are two integration shapes:
334
378
 
335
- For production builds, add a bundler plugin. Styles are extracted into static
336
- atomic CSS output. Dynamic values from props, state, or user input still work as
337
- usual.
379
+ - React apps can use Fluentic's JSX runtime import source, switching from
380
+ `@fluentic/style/jsx` to `@fluentic/style/plugin/jsx` after adding a plugin.
381
+ - React, Preact, and SolidJS can also use a compiler css-prop adapter, letting
382
+ the framework keep its normal JSX runtime while Fluentic compiles
383
+ `css={...}` before the framework JSX transform runs.
338
384
 
339
- After adding a Fluentic bundler plugin, change the JSX import source from
340
- `@fluentic/style/jsx` to `@fluentic/style/plugin/jsx`.
385
+ The React JSX-runtime setup looks like this:
341
386
 
342
387
  ```jsonc
343
388
  /* tsconfig.json */
@@ -369,8 +414,38 @@ export default defineConfig({
369
414
  development sourcemaps, and extracted CSS output. See
370
415
  [Plugin Options](https://fluenticstack.com/style/docs/reference/plugin-options/).
371
416
 
372
- For Next.js and other bundlers, see the
373
- [integration docs](https://fluenticstack.com/style/docs/integrations/overview/).
417
+ The framework-adapter setup passes a css-prop preset to the plugin. This is the
418
+ normal path for SolidJS and Preact, and an optional path for React:
419
+
420
+ ```ts
421
+ /* vite.config.ts */
422
+ import { CssPropPresets, plugin as stylePlugin } from '@fluentic/style/plugin/vite';
423
+ import { defineConfig } from 'vite';
424
+
425
+ export default defineConfig({
426
+ plugins: [
427
+ stylePlugin({
428
+ cssProp: CssPropPresets.Solid,
429
+ }),
430
+ // then the framework JSX plugin, such as vite-plugin-solid
431
+ ],
432
+ });
433
+ ```
434
+
435
+ For framework and bundler-specific setup, see:
436
+
437
+ | Environment | Guide |
438
+ | -------------------------- | ----------------------------------------------------------------------------------------- |
439
+ | Next.js App Router | [Next.js](https://fluenticstack.com/style/docs/integrations/nextjs/) |
440
+ | Vite + React | [Vite](https://fluenticstack.com/style/docs/integrations/vite/) |
441
+ | Vite + SolidJS | [SolidJS](https://fluenticstack.com/style/docs/integrations/solidjs/) |
442
+ | Vite + Preact | [PreactJS](https://fluenticstack.com/style/docs/integrations/preact/) |
443
+ | Webpack | [Webpack](https://fluenticstack.com/style/docs/integrations/webpack/) |
444
+ | Rspack | [Rspack](https://fluenticstack.com/style/docs/integrations/rspack/) |
445
+ | Farm | [Farm](https://fluenticstack.com/style/docs/integrations/farm/) |
446
+ | Parcel 2 | [Parcel](https://fluenticstack.com/style/docs/integrations/parcel/) |
447
+ | Runtime-only | [Runtime-Only Mode](https://fluenticstack.com/style/docs/integrations/runtime-only-mode/) |
448
+ | Custom compiler or bundler | [Custom Compiler](https://fluenticstack.com/style/docs/integrations/custom-compiler/) |
374
449
 
375
450
  ## Benchmarks
376
451
 
@@ -380,7 +455,7 @@ production builds. Current benchmark snapshots:
380
455
  The main production checks are runtime cost and bundle size. In the production
381
456
  path most apps use, Fluentic extracts CSS at build time and ships the extracted
382
457
  production runtime for `css` prop composition, dynamic values, class-name
383
- merging, and token resolution. That runtime entry currently reports `4.45 KB`
458
+ merging, and token resolution. That runtime entry currently reports `4.92 KB`
384
459
  min+gzip.
385
460
  Browser and SSR benchmarks track whether style resolution stays fast in
386
461
  app-shaped renders. See the
@@ -3,16 +3,17 @@ import { CSS_CONFIG } from '../config/config/css';
3
3
  import { DEV_CONFIG } from '../config/config/dev';
4
4
  import type { ClassNameFormat, TransformClassNameFormat } from '../config/types';
5
5
  import { hashString } from '../utils/hash';
6
- import { getDebugClassName, getDebugTransformClassName } from './debug/className';
6
+ import { getDebugClassName, getDebugSheetClassName, getDebugTransformClassName } from './debug/className';
7
7
  import { getDebugPropertyName } from './debug/property';
8
8
  import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
9
9
  export { getScopeClassName } from './scope';
10
10
  import { getIdentifierSafeHash } from './utils/hash';
11
- import { getSelectorHash, getSelectorText } from './utils/selector';
11
+ import { getSelectorHash, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
12
12
 
13
13
  export function getAtomicClassName(
14
14
  property: string,
15
15
  priority: number | null,
16
+ important: boolean,
16
17
  value: string,
17
18
  selector: ItemSelector | null,
18
19
  parentSelector: ItemSelector | null,
@@ -23,11 +24,13 @@ export function getAtomicClassName(
23
24
  classNameFormat: ClassNameFormat | null,
24
25
  transformClassName: string | null,
25
26
  transformClassNameFormat: TransformClassNameFormat | null,
27
+ sheetClassNameFormat: ClassNameFormat | null = null,
26
28
  hashLength: number | null = null,
27
29
  ) {
28
30
  let hash = property;
29
31
 
30
32
  hash += '\n' + (priority || '');
33
+ if (important) hash += '\nimportant';
31
34
  hash += '\n' + value;
32
35
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
33
36
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
@@ -51,8 +54,9 @@ export function getAtomicClassName(
51
54
 
52
55
  const propertyName = getDebugPropertyName(property, value);
53
56
 
54
- const className = getDebugClassName(
55
- classNameFormat,
57
+ const isSheetClassName = hasSheetSelectorAnchor(selector);
58
+ const className = (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(
59
+ isSheetClassName ? sheetClassNameFormat : classNameFormat,
56
60
  hash,
57
61
  {
58
62
  atRule: atRule
@@ -77,13 +81,31 @@ export function getAtomicClassName(
77
81
  }
78
82
 
79
83
  function getRuntimeClassNameHashLength(debugClassName: boolean) {
80
- if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
81
- return CSS_CONFIG.hashLength ?? 7;
84
+ return getClassNameHashLength({
85
+ debugClassName,
86
+ isDev: DEV_CONFIG.isDev,
87
+ devHashLength: DEV_CONFIG.hashLength,
88
+ cssHashLength: CSS_CONFIG.hashLength,
89
+ });
90
+ }
91
+
92
+ export function getClassNameHashLength(options: {
93
+ debugClassName: boolean;
94
+ isDev: boolean;
95
+ devHashLength?: number | null;
96
+ cssHashLength?: number | null;
97
+ }) {
98
+ if (options.debugClassName && options.isDev) {
99
+ return options.devHashLength ?? options.cssHashLength ?? 3;
100
+ }
101
+
102
+ return options.cssHashLength ?? 7;
82
103
  }
83
104
 
84
105
  export function getClassNameDedupe(
85
106
  property: string,
86
107
  priority: number | null,
108
+ important: boolean,
87
109
  selector: ItemSelector | null,
88
110
  parentSelector: ItemSelector | null,
89
111
  atRule: ItemSelector[] | null,
@@ -91,6 +113,7 @@ export function getClassNameDedupe(
91
113
  let hash = property;
92
114
 
93
115
  hash += '\n' + (priority || '');
116
+ if (important) hash += '\nimportant';
94
117
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
95
118
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
96
119
  hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
@@ -8,6 +8,8 @@ import { createNameFormatter } from '../../utils/format';
8
8
 
9
9
  export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash';
10
10
 
11
+ export const SHEET_CLASS_NAME_FORMAT = 'sheet-(property)[-(value)]--$hash';
12
+
11
13
  export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
12
14
 
13
15
  export const formatClassName = createNameFormatter<ClassNameInfo>([
@@ -30,6 +32,14 @@ export function getDebugClassName(
30
32
  return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
31
33
  }
32
34
 
35
+ export function getDebugSheetClassName(
36
+ format: ClassNameFormat | null,
37
+ hash: string,
38
+ info: ClassNameInfo,
39
+ ) {
40
+ return formatClassName(format || SHEET_CLASS_NAME_FORMAT, hash, info);
41
+ }
42
+
33
43
  export function getDebugTransformClassName(
34
44
  format: TransformClassNameFormat | null,
35
45
  hash: string,
package/atomic/rule.ts CHANGED
@@ -4,23 +4,26 @@ import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } fro
4
4
  import { getCssPropertyName, getPropertyPriority } from './property';
5
5
  import { getScopeClassName } from './scope';
6
6
  import { escapeCssIdent } from './utils/cssIdent';
7
- import { getSelectorPriority, getSelectorText } from './utils/selector';
7
+ import { getSelectorPriority, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
8
8
  import { getCssPropertyValue } from './value';
9
9
 
10
10
  export function buildAtomicRule(
11
11
  className: string,
12
12
  property: string,
13
13
  value: string,
14
+ important: boolean,
14
15
  selector: ItemSelector | null,
15
16
  parentSelector: ItemSelector | null,
16
17
  atRules: ItemSelector[] | null,
17
18
  scopeClassNameFormat: ScopeClassNameFormat | null,
18
19
  ): string {
19
20
  const cssProp = getCssPropertyName(property);
20
- const cssValue = getCssPropertyValue(property, value);
21
+ const cssValue = getCssPropertyValue(property, value) + (important ? ' !important' : '');
21
22
  const escapedClass = escapeCssIdent(className);
22
23
 
23
- const classSelector = '.' + escapedClass;
24
+ const classSelector = hasSheetSelectorAnchor(selector)
25
+ ? `:where(.${escapedClass})`
26
+ : '.' + escapedClass;
24
27
  const itemSelector = selector ? getSelectorText(selector) : '';
25
28
 
26
29
  let selectorStr = classSelector + itemSelector;
@@ -1,72 +1,8 @@
1
- import { globalData } from '../../utils/global';
2
1
  import { hashString, normalizeHashLength } from '../../utils/hash';
3
2
 
4
- type PooledHashState = {
5
- byValue: Map<string, string>;
6
- byHash: Map<string, string>;
7
- usedByLength: number[];
8
- };
9
-
10
- const POOLED_HASH_STATE = globalData<PooledHashState>(
11
- 'atomic.hashPool',
12
- () => ({
13
- byValue: new Map(),
14
- byHash: new Map(),
15
- usedByLength: [],
16
- }),
17
- );
18
-
19
3
  export function getIdentifierSafeHash(value: string, startLength = 7) {
20
- return getPooledHash(value, startLength);
21
- }
22
-
23
- function getPooledHash(value: string, startLength: number) {
24
4
  const normalizedStartLength = normalizeHashLength(startLength);
25
- const valueKey = normalizedStartLength + '\0' + value;
26
- const existing = POOLED_HASH_STATE.byValue.get(valueKey);
27
- if (existing) return existing;
28
-
29
- let length = normalizedStartLength;
30
-
31
- while (true) {
32
- if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
33
- length++;
34
- continue;
35
- }
36
-
37
- for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
38
- const hash = getPooledHashCandidate(value, length, index);
39
- const owner = POOLED_HASH_STATE.byHash.get(hash);
40
-
41
- if (owner !== undefined && owner !== valueKey) continue;
42
-
43
- POOLED_HASH_STATE.byValue.set(valueKey, hash);
44
- POOLED_HASH_STATE.byHash.set(hash, valueKey);
45
- POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
46
- return hash;
47
- }
48
-
49
- length++;
50
- }
51
- }
52
-
53
- function getPooledHashCandidate(
54
- value: string,
55
- length: number,
56
- index: number,
57
- ) {
58
- const hashValue = index === 0 ? value : value + '::' + index;
59
- return getIdentifierSafeHashValue(hashString(hashValue)).slice(0, length);
60
- }
61
-
62
- function getPooledHashUsedCount(length: number) {
63
- return POOLED_HASH_STATE.usedByLength[length] ?? 0;
64
- }
65
-
66
- function getIdentifierSafeHashPoolSize(length: number) {
67
- if (length <= 0) return 0;
68
-
69
- return 26 * 36 ** (length - 1);
5
+ return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
70
6
  }
71
7
 
72
8
  function getIdentifierSafeHashValue(hash: string) {
@@ -1,7 +1,9 @@
1
+ import { SHEET_SELECTOR_ANCHOR } from '../../builder/data/const';
1
2
  import type { ItemSelector } from '../../builder/data/state';
2
3
 
3
4
  export function getSelectorText(selector: ItemSelector): string {
4
- return Array.isArray(selector) ? selector[0] : selector;
5
+ const text = Array.isArray(selector) ? selector[0] : selector;
6
+ return stripSheetSelectorAnchor(text);
5
7
  }
6
8
 
7
9
  export function getSelectorHash(selector: ItemSelector): string {
@@ -12,3 +14,14 @@ export function getSelectorPriority(selector: ItemSelector | null): number {
12
14
  if (!selector) return 0;
13
15
  return Array.isArray(selector) ? selector[1] : 0;
14
16
  }
17
+
18
+ export function hasSheetSelectorAnchor(selector: ItemSelector | null): boolean {
19
+ const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
20
+ return text.startsWith(SHEET_SELECTOR_ANCHOR);
21
+ }
22
+
23
+ function stripSheetSelectorAnchor(selector: string) {
24
+ return selector.startsWith(SHEET_SELECTOR_ANCHOR)
25
+ ? selector.slice(SHEET_SELECTOR_ANCHOR.length)
26
+ : selector;
27
+ }