@fluentic/style 0.1.0-beta.14 → 0.1.0-beta.15

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 (277) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/atomic/className.ts +4 -0
  3. package/atomic/rule.ts +15 -7
  4. package/atomic/utils/selector.ts +12 -3
  5. package/builder/classname/class_name_builder.ts +1 -1
  6. package/builder/data/const.ts +2 -0
  7. package/builder/data/data.ts +1 -1
  8. package/builder/data/merge/scope.ts +7 -0
  9. package/builder/data/merge/style.ts +12 -3
  10. package/builder/data/state.ts +1 -0
  11. package/builder/selector_override.ts +1 -1
  12. package/builder/selector_override_core.ts +17 -3
  13. package/builder/types/alias.ts +1 -1
  14. package/compiler/extract/extract.ts +21 -75
  15. package/compiler/extract/types.ts +4 -1
  16. package/compiler/transform/debug/plugin.ts +22 -0
  17. package/compiler/transform/evaluator/evaluator.ts +4 -1
  18. package/compiler/transform/extract/chain/chain.ts +82 -22
  19. package/compiler/transform/extract/chain/extract_chain.ts +2 -0
  20. package/compiler/transform/extract/plugin.ts +51 -25
  21. package/compiler/transform/extract/utils/imports.ts +4 -1
  22. package/compiler/transform/extract/utils/replacement.ts +2 -2
  23. package/compiler/transform/utils/babel.ts +1 -1
  24. package/compiler/utils/constants.ts +1 -0
  25. package/config/config/css.ts +5 -3
  26. package/config/configure.ts +4 -0
  27. package/config/document.ts +23 -0
  28. package/css/globalSheet.ts +66 -0
  29. package/css/index.ts +4 -1
  30. package/css/sheet.ts +34 -14
  31. package/dist/{className-yhJCGT0F.js → className-CC5PHcXI.js} +9 -2
  32. package/dist/className-CC5PHcXI.js.map +1 -0
  33. package/dist/{combine-CC9bY-hu.js → combine-BpOQWCtM.js} +5 -5
  34. package/dist/combine-BpOQWCtM.js.map +1 -0
  35. package/dist/compiler/index.mjs +1 -1
  36. package/dist/{compiler-Ct5xGIeu.mjs → compiler-AOb_VaKQ.mjs} +464 -166
  37. package/dist/compiler-AOb_VaKQ.mjs.map +1 -0
  38. package/dist/config/index.js +2 -2
  39. package/dist/{config-CCgsVvyR.js → config-B70LIQhi.js} +2 -2
  40. package/dist/{config-CCgsVvyR.js.map → config-B70LIQhi.js.map} +1 -1
  41. package/dist/{config-DZKR6gH1.js → config-BF-mxuPk.js} +4 -4
  42. package/dist/{config-DZKR6gH1.js.map → config-BF-mxuPk.js.map} +1 -1
  43. package/dist/{config-BiiMS4rU.js → config-B_OQYZSm.js} +25 -4
  44. package/dist/config-B_OQYZSm.js.map +1 -0
  45. package/dist/{css-WaHZ6gxv.js → css-C7tcD3IO.js} +611 -213
  46. package/dist/css-C7tcD3IO.js.map +1 -0
  47. package/dist/css-Cdxkur4h.js +414 -0
  48. package/dist/css-Cdxkur4h.js.map +1 -0
  49. package/dist/{css-IecKRNxs.js → css-RohOR3Vq.js} +112 -73
  50. package/dist/css-RohOR3Vq.js.map +1 -0
  51. package/dist/css.js +2 -2
  52. package/dist/css_extra-BC1Z_hDy.js +8 -0
  53. package/dist/{css_extra-DDeJc2Cu.js.map → css_extra-BC1Z_hDy.js.map} +1 -1
  54. package/dist/{css_extra-DDeJc2Cu.js → css_extra-CuzJtAR_.js} +2 -2
  55. package/dist/css_extra-CuzJtAR_.js.map +1 -0
  56. package/dist/{data-BgZmL55Y.js → data-Bw3Xod5J.js} +28 -19
  57. package/dist/data-Bw3Xod5J.js.map +1 -0
  58. package/dist/{debug-D-1hhd0G.js → debug-CVO3xx4C.js} +6 -9
  59. package/dist/debug-CVO3xx4C.js.map +1 -0
  60. package/dist/dev/rsc.js +134 -25
  61. package/dist/dev/rsc.js.map +1 -1
  62. package/dist/{dev-CBRbVaeq.js → dev-BnQXPLQB.js} +6 -6
  63. package/dist/{dev-CBRbVaeq.js.map → dev-BnQXPLQB.js.map} +1 -1
  64. package/dist/dev.js +1 -1
  65. package/dist/dialect/extracted/index.js +1 -1
  66. package/dist/dialect/index.js +1 -1
  67. package/dist/{elementMarker-CJcfpKL1.js → elementMarker-BrHXg161.js} +334 -53
  68. package/dist/elementMarker-BrHXg161.js.map +1 -0
  69. package/dist/entry/dev/adapter/preact.js +1 -1
  70. package/dist/entry/dev/adapter/react.js +1 -1
  71. package/dist/entry/dev/adapter/solid.js +1 -1
  72. package/dist/entry/dev/css.js +3 -3
  73. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  74. package/dist/entry/dev/jsx-runtime.js +2 -2
  75. package/dist/entry/dev.js +11 -11
  76. package/dist/entry/prod/adapter/preact.js +1 -1
  77. package/dist/entry/prod/adapter/react.js +1 -1
  78. package/dist/entry/prod/adapter/solid.js +1 -1
  79. package/dist/entry/prod/css.js +3 -3
  80. package/dist/entry/prod/extract.js.map +1 -1
  81. package/dist/entry/prod.js +3 -3
  82. package/dist/entry/rsc-dev/adapter/preact.js +1 -1
  83. package/dist/entry/rsc-dev/adapter/react.js +1 -1
  84. package/dist/entry/rsc-dev/adapter/solid.js +1 -1
  85. package/dist/entry/rsc-dev/css.js +4 -3
  86. package/dist/entry/rsc-dev/dev.js +129 -24
  87. package/dist/entry/rsc-dev/dev.js.map +1 -1
  88. package/dist/entry/rsc-dev/jsx-dev-runtime.js +5 -4
  89. package/dist/entry/rsc-dev/jsx-dev-runtime.js.map +1 -1
  90. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  91. package/dist/entry/rsc-dev.js +8 -7
  92. package/dist/entry/rsc-dev.js.map +1 -1
  93. package/dist/entry/rsc-prod/css.js +4 -4
  94. package/dist/entry/rsc-prod.js +4 -4
  95. package/dist/{rules-Dz-szpPu.js → env-D6daex-9.js} +64 -19
  96. package/dist/env-D6daex-9.js.map +1 -0
  97. package/dist/{getClassName-DtkplEIt.js → getClassName-5yYUibKw.js} +2 -2
  98. package/dist/{getClassName-DtkplEIt.js.map → getClassName-5yYUibKw.js.map} +1 -1
  99. package/dist/getClassName-9CsXbNls.js.map +1 -1
  100. package/dist/{getClassName-CeoxISNW.js → getClassName-B3azD1TO.js} +6 -4
  101. package/dist/getClassName-B3azD1TO.js.map +1 -0
  102. package/dist/{getClassName-BNe3Ycyy.js → getClassName-m5DOkMFQ.js} +4 -4
  103. package/dist/{getClassName-BNe3Ycyy.js.map → getClassName-m5DOkMFQ.js.map} +1 -1
  104. package/dist/{global-UOHFwqHN.js → global-DeIYtcdl.js} +5 -2
  105. package/dist/{global-UOHFwqHN.js.map → global-DeIYtcdl.js.map} +1 -1
  106. package/dist/{css-BhoclXaw.js → globalSheet-CdgVpvCb.js} +185 -426
  107. package/dist/globalSheet-CdgVpvCb.js.map +1 -0
  108. package/dist/{hash-DlXmmPPm.js → hash-DCJkLls_.js} +4 -4
  109. package/dist/hash-DCJkLls_.js.map +1 -0
  110. package/dist/index.js +9 -9
  111. package/dist/jsx/jsx-dev-runtime.js +1 -1
  112. package/dist/jsx/jsx-dev-runtime.server.js +3 -3
  113. package/dist/jsx/jsx-dev-runtime.server.js.map +1 -1
  114. package/dist/jsx/jsx-runtime.js +1 -1
  115. package/dist/jsx/jsx-runtime.server.js +4 -4
  116. package/dist/jsx/jsx-runtime.server.js.map +1 -1
  117. package/dist/{jsx-8TwYuvgM.js → jsx-CvloSSpb.js} +4 -4
  118. package/dist/{jsx-8TwYuvgM.js.map → jsx-CvloSSpb.js.map} +1 -1
  119. package/dist/jsx_runtime-pt7DOZOE.js +13 -0
  120. package/dist/jsx_runtime-pt7DOZOE.js.map +1 -0
  121. package/dist/{loader-BVebGteg.mjs → loader-fAuIjIik.mjs} +3 -3
  122. package/dist/{loader-BVebGteg.mjs.map → loader-fAuIjIik.mjs.map} +1 -1
  123. package/dist/{misc-Bs2DgdG7.mjs → misc-CyZgGtc9.mjs} +3 -3
  124. package/dist/{misc-Bs2DgdG7.mjs.map → misc-CyZgGtc9.mjs.map} +1 -1
  125. package/dist/{namedTokens-CwniouKk.js → namedTokens-DwgmUMBM.js} +2 -2
  126. package/dist/{namedTokens-CwniouKk.js.map → namedTokens-DwgmUMBM.js.map} +1 -1
  127. package/dist/plugin/farm/index.mjs +3 -3
  128. package/dist/plugin/nextjs/index.mjs +4 -4
  129. package/dist/plugin/nextjs/loader.mjs +7 -5
  130. package/dist/plugin/nextjs/loader.mjs.map +1 -1
  131. package/dist/plugin/parcel/index.cjs +1 -1
  132. package/dist/plugin/parcel/index.mjs +2 -2
  133. package/dist/plugin/parcel/optimizer.cjs +1 -1
  134. package/dist/plugin/parcel/optimizer.mjs +2 -2
  135. package/dist/plugin/parcel/resolver.cjs +1 -1
  136. package/dist/plugin/parcel/resolver.mjs +2 -2
  137. package/dist/plugin/parcel/runtime.cjs +1 -1
  138. package/dist/plugin/parcel/runtime.mjs +1 -1
  139. package/dist/plugin/parcel/transformer.cjs +1 -1
  140. package/dist/plugin/parcel/transformer.mjs +2 -2
  141. package/dist/plugin/rspack/index.mjs +2 -2
  142. package/dist/plugin/vite/index.mjs +3 -3
  143. package/dist/plugin/webpack/index.mjs +2 -2
  144. package/dist/plugin/webpack/loader.mjs +2 -2
  145. package/dist/presets/tailwind/index.js +3 -3
  146. package/dist/{registry-D1n78rd7.mjs → registry-BMijh1CM.mjs} +2 -2
  147. package/dist/{registry-D1n78rd7.mjs.map → registry-BMijh1CM.mjs.map} +1 -1
  148. package/dist/{resolveClassNameRuntime-BJcykzdl.js → resolveClassNameRuntime-B6vKNL5y.js} +2 -2
  149. package/dist/{resolveClassNameRuntime-BJcykzdl.js.map → resolveClassNameRuntime-B6vKNL5y.js.map} +1 -1
  150. package/dist/server.js +87 -17
  151. package/dist/server.js.map +1 -1
  152. package/dist/{shared-D4-AKGn6.mjs → shared-BfASWZo1.mjs} +4 -4
  153. package/dist/{shared-D4-AKGn6.mjs.map → shared-BfASWZo1.mjs.map} +1 -1
  154. package/dist/{shared-C9XQd8p_.cjs → shared-DY0kuBcN.cjs} +460 -162
  155. package/dist/shared-DY0kuBcN.cjs.map +1 -0
  156. package/dist/sheet-B-5idGtZ.js +9 -0
  157. package/dist/sheet-B-5idGtZ.js.map +1 -0
  158. package/dist/{config-TyjNpRrV.js → sheet-C6ymGhKV.js} +23 -2
  159. package/dist/sheet-C6ymGhKV.js.map +1 -0
  160. package/dist/sheet-D4f9KYPf.js +1 -0
  161. package/dist/{sidecar-CZTYX2vA.mjs → sidecar-cCzTDkzg.mjs} +3 -3
  162. package/dist/{sidecar-CZTYX2vA.mjs.map → sidecar-cCzTDkzg.mjs.map} +1 -1
  163. package/dist/{style-CmXHCPF4.js → style-a6ccye6R.js} +12 -12
  164. package/dist/style-a6ccye6R.js.map +1 -0
  165. package/dist/styleStore-Ceoaqa5U.js +45 -0
  166. package/dist/styleStore-Ceoaqa5U.js.map +1 -0
  167. package/dist/{env-C8TRVSyb.js → styleStore-D1IEmq1v.js} +435 -63
  168. package/dist/styleStore-D1IEmq1v.js.map +1 -0
  169. package/dist/{token-DMrBbat8.js → token-Ci73NE6h.js} +2 -2
  170. package/dist/{token-DMrBbat8.js.map → token-Ci73NE6h.js.map} +1 -1
  171. package/dist/{trace-C7EzEj2Q.js → trace-DDsvwdF0.js} +3 -3
  172. package/dist/{trace-C7EzEj2Q.js.map → trace-DDsvwdF0.js.map} +1 -1
  173. package/dist/{trace-DzCntvK4.js → trace-uHVvnYiw.js} +2 -2
  174. package/dist/{trace-DzCntvK4.js.map → trace-uHVvnYiw.js.map} +1 -1
  175. package/dist/{transform-CSZMklMb.js → transform-BkxIouPX.js} +2 -2
  176. package/dist/{transform-CSZMklMb.js.map → transform-BkxIouPX.js.map} +1 -1
  177. package/dist/types/atomic/className.d.ts +2 -2
  178. package/dist/types/atomic/utils/selector.d.ts +2 -1
  179. package/dist/types/builder/data/const.d.ts +1 -0
  180. package/dist/types/builder/data/data.d.ts +1 -1
  181. package/dist/types/builder/data/state.d.ts +1 -0
  182. package/dist/types/builder/selector_override.d.ts +1 -1
  183. package/dist/types/builder/selector_override_core.d.ts +2 -0
  184. package/dist/types/builder/types/alias.d.ts +2 -2
  185. package/dist/types/compiler/extract/types.d.ts +7 -1
  186. package/dist/types/compiler/transform/extract/chain/extract_chain.d.ts +2 -0
  187. package/dist/types/compiler/utils/constants.d.ts +1 -0
  188. package/dist/types/config/config/css.d.ts +2 -1
  189. package/dist/types/config/configure.d.ts +2 -0
  190. package/dist/types/config/document.d.ts +3 -0
  191. package/dist/types/css/globalSheet.d.ts +24 -0
  192. package/dist/types/css/index.d.ts +4 -1
  193. package/dist/types/css/sheet.d.ts +3 -2
  194. package/dist/types/entry/rsc_dev/css.d.ts +1 -0
  195. package/dist/types/runtime/rsc/constants.d.ts +2 -0
  196. package/dist/types/runtime/rsc/dev.d.ts +5 -0
  197. package/dist/types/runtime/rsc/getClassName.d.ts +3 -0
  198. package/dist/types/runtime/rsc/globalSheet.d.ts +22 -0
  199. package/dist/types/runtime/rsc/observer.d.ts +5 -0
  200. package/dist/types/runtime/rsc/styleStore.d.ts +2 -0
  201. package/dist/types/runtime/sheet/document.d.ts +3 -0
  202. package/dist/types/sheet/ordered.d.ts +4 -0
  203. package/dist/types/sheet/ordering.d.ts +15 -0
  204. package/dist/types/sheet/types.d.ts +7 -0
  205. package/dist/types/style/important.d.ts +2 -1
  206. package/dist/types/style/style.d.ts +2 -2
  207. package/dist/{utils-CoMwEfhG.mjs → utils-BO6Ix8t5.mjs} +4 -4
  208. package/dist/{utils-CoMwEfhG.mjs.map → utils-BO6Ix8t5.mjs.map} +1 -1
  209. package/dist/{utils-B7QcJ-Yw.js → utils-CB70kIh6.js} +3 -3
  210. package/dist/{utils-B7QcJ-Yw.js.map → utils-CB70kIh6.js.map} +1 -1
  211. package/dist/{utils-BYpkJ-uE.mjs → utils-EG9gh2g3.mjs} +3 -3
  212. package/dist/{utils-BYpkJ-uE.mjs.map → utils-EG9gh2g3.mjs.map} +1 -1
  213. package/dist/{utils-D4KMqCu2.js → utils-sG7IWYP6.js} +1089 -646
  214. package/dist/utils-sG7IWYP6.js.map +1 -0
  215. package/dist/utils.js +3 -3
  216. package/dist/{value-yd2SZ1XQ.js → value-B-ThmbY-.js} +16 -9
  217. package/dist/value-B-ThmbY-.js.map +1 -0
  218. package/dist/{webpack-B6z1UHh9.mjs → webpack-WXAJ3IYn.mjs} +5 -5
  219. package/dist/{webpack-B6z1UHh9.mjs.map → webpack-WXAJ3IYn.mjs.map} +1 -1
  220. package/entry/dev/sheet.ts +4 -1
  221. package/entry/rsc_dev/css.ts +2 -0
  222. package/jsx/rsc/jsx_dev_runtime.ts +11 -2
  223. package/jsx/rsc/jsx_runtime.ts +14 -3
  224. package/package.json +1 -1
  225. package/plugin/nextjs/loader.ts +18 -2
  226. package/runtime/core/elementMarker.ts +9 -3
  227. package/runtime/rsc/constants.ts +3 -0
  228. package/runtime/rsc/dev.ts +31 -15
  229. package/runtime/rsc/getClassName.ts +6 -0
  230. package/runtime/rsc/globalSheet.ts +130 -0
  231. package/runtime/rsc/observer.ts +118 -15
  232. package/runtime/rsc/styleStore.ts +12 -36
  233. package/runtime/sheet/document.ts +28 -0
  234. package/runtime/sheet/global-prod.ts +3 -5
  235. package/runtime/sheet/global.ts +3 -5
  236. package/runtime/sheet/rule.ts +4 -2
  237. package/runtime/sheet/rules.ts +3 -0
  238. package/sheet/dev/dev_sort.ts +5 -1
  239. package/sheet/dev/index.ts +23 -3
  240. package/sheet/ordered.ts +188 -0
  241. package/sheet/ordering.ts +138 -0
  242. package/sheet/prod.ts +17 -5
  243. package/sheet/types.ts +4 -0
  244. package/style/important.ts +3 -1
  245. package/style/style.ts +1 -1
  246. package/utils/trace.ts +1 -0
  247. package/dist/className-yhJCGT0F.js.map +0 -1
  248. package/dist/combine-CC9bY-hu.js.map +0 -1
  249. package/dist/compiler-Ct5xGIeu.mjs.map +0 -1
  250. package/dist/config-BiiMS4rU.js.map +0 -1
  251. package/dist/config-TyjNpRrV.js.map +0 -1
  252. package/dist/createTransformElement-BGznW-Mu.js +0 -34
  253. package/dist/createTransformElement-BGznW-Mu.js.map +0 -1
  254. package/dist/css-BhoclXaw.js.map +0 -1
  255. package/dist/css-IecKRNxs.js.map +0 -1
  256. package/dist/css-WaHZ6gxv.js.map +0 -1
  257. package/dist/data-BgZmL55Y.js.map +0 -1
  258. package/dist/debug-D-1hhd0G.js.map +0 -1
  259. package/dist/elementMarker-CJcfpKL1.js.map +0 -1
  260. package/dist/env-C8TRVSyb.js.map +0 -1
  261. package/dist/getClassName-CeoxISNW.js.map +0 -1
  262. package/dist/global-CWYOol4o.js +0 -14
  263. package/dist/global-CWYOol4o.js.map +0 -1
  264. package/dist/hash-DlXmmPPm.js.map +0 -1
  265. package/dist/jsx_runtime-CPojW0KD.js +0 -12
  266. package/dist/jsx_runtime-CPojW0KD.js.map +0 -1
  267. package/dist/rules-Dz-szpPu.js.map +0 -1
  268. package/dist/shared-C9XQd8p_.cjs.map +0 -1
  269. package/dist/sheet-LU89fcH_.js +0 -7
  270. package/dist/sheet-LU89fcH_.js.map +0 -1
  271. package/dist/style-CmXHCPF4.js.map +0 -1
  272. package/dist/styleStore-B0x4Ahpx.js +0 -60
  273. package/dist/styleStore-B0x4Ahpx.js.map +0 -1
  274. package/dist/styleStore-BrpgLNgc.js +0 -57
  275. package/dist/styleStore-BrpgLNgc.js.map +0 -1
  276. package/dist/utils-D4KMqCu2.js.map +0 -1
  277. package/dist/value-yd2SZ1XQ.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @fluentic/style
2
2
 
3
+ ## 0.1.0-beta.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Add global selector sheets with immediate client injection, static extraction, and Next.js RSC development transport. Sort whole global sheets by `order` (default `0`), retaining discovery order for ties, across runtime, extracted CSS, server seeds, and client adoption.
8
+
9
+ Rename the local sheet `weight` option to `specificity`, defaulting to `1`; use `0` for a zero-specificity `:where(...)` anchor. Local sheets remain unlayered by default. `layer: true` shares ordinary style layers, absolute names stay literal, and relative names only receive an enabled main-layer prefix. The legacy `css.layer.sheet` setting no longer enables sheet layers.
10
+
11
+ Place managed important sheet declarations in a first `<resolved-layer>.important` child; `style.important(value, true)` retains native layer placement. Preserve rule ordering and debug metadata through streaming, hydration, navigation, and HMR. Update client and Next.js examples and add a dedicated ordering guide.
12
+
13
+ Support configurable runtime stylesheet documents, including disabling injection and reinserting cached styles when changing documents. Add generated bundle reports and a release gate that rejects stale measurements and documentation.
14
+
3
15
  ## 0.1.0-beta.14
4
16
 
5
17
  ### Patch Changes
@@ -26,11 +26,13 @@ export function getAtomicClassName(
26
26
  transformClassNameFormat: TransformClassNameFormat | null,
27
27
  sheetClassNameFormat: ClassNameFormat | null = null,
28
28
  hashLength: number | null = null,
29
+ importantNative = false,
29
30
  ) {
30
31
  let hash = property;
31
32
 
32
33
  hash += '\n' + (priority || '');
33
34
  if (important) hash += '\nimportant';
35
+ if (importantNative) hash += '\nnative-important';
34
36
  hash += '\n' + value;
35
37
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
36
38
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
@@ -109,11 +111,13 @@ export function getClassNameDedupe(
109
111
  selector: ItemSelector | null,
110
112
  parentSelector: ItemSelector | null,
111
113
  atRule: ItemSelector[] | null,
114
+ importantNative = false,
112
115
  ) {
113
116
  let hash = property;
114
117
 
115
118
  hash += '\n' + (priority || '');
116
119
  if (important) hash += '\nimportant';
120
+ if (importantNative) hash += '\nnative-important';
117
121
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
118
122
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
119
123
  hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
package/atomic/rule.ts CHANGED
@@ -4,7 +4,13 @@ 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, getSheetSelectorWeight, hasSheetSelectorAnchor } from './utils/selector';
7
+ import {
8
+ getSelectorPriority,
9
+ getSelectorText,
10
+ getSheetSelectorSpecificity,
11
+ hasGlobalSheetSelectorAnchor,
12
+ hasSheetSelectorAnchor,
13
+ } from './utils/selector';
8
14
  import { getCssPropertyValue } from './value';
9
15
 
10
16
  export function buildAtomicRule(
@@ -21,15 +27,17 @@ export function buildAtomicRule(
21
27
  const cssValue = getCssPropertyValue(property, value) + (important ? ' !important' : '');
22
28
  const escapedClass = escapeCssIdent(className);
23
29
 
24
- const sheetWeight = getSheetSelectorWeight(selector);
25
- const classSelector = sheetWeight
26
- ? Array(sheetWeight).fill('.' + escapedClass).join('')
27
- : hasSheetSelectorAnchor(selector)
30
+ const specificity = hasSheetSelectorAnchor(selector) ? getSheetSelectorSpecificity(selector) ?? 1 : 1;
31
+
32
+ const classSelector = specificity === 0
28
33
  ? `:where(.${escapedClass})`
29
- : '.' + escapedClass;
34
+ : Array(specificity).fill('.' + escapedClass).join('');
35
+
30
36
  const itemSelector = selector ? getSelectorText(selector) : '';
31
37
 
32
- let selectorStr = classSelector + itemSelector;
38
+ let selectorStr = hasGlobalSheetSelectorAnchor(selector)
39
+ ? itemSelector
40
+ : classSelector + itemSelector;
33
41
 
34
42
  if (parentSelector) {
35
43
  const parentClass = '.' + escapeCssIdent(
@@ -1,8 +1,11 @@
1
- import { SHEET_SELECTOR_ANCHOR } from '../../builder/data/const';
1
+ import { GLOBAL_SHEET_SELECTOR_ANCHOR, SHEET_SELECTOR_ANCHOR } from '../../builder/data/const';
2
2
  import type { ItemSelector } from '../../builder/data/state';
3
3
 
4
4
  export function getSelectorText(selector: ItemSelector): string {
5
5
  const text = Array.isArray(selector) ? selector[0] : selector;
6
+ if (text.startsWith(GLOBAL_SHEET_SELECTOR_ANCHOR)) {
7
+ return text.slice(text.indexOf('\0', GLOBAL_SHEET_SELECTOR_ANCHOR.length) + 1);
8
+ }
6
9
  return stripSheetSelectorAnchor(text);
7
10
  }
8
11
 
@@ -20,7 +23,7 @@ export function hasSheetSelectorAnchor(selector: ItemSelector | null): boolean {
20
23
  return text.startsWith(SHEET_SELECTOR_ANCHOR);
21
24
  }
22
25
 
23
- export function getSheetSelectorWeight(selector: ItemSelector | null): number | null {
26
+ export function getSheetSelectorSpecificity(selector: ItemSelector | null): number | null {
24
27
  const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
25
28
  if (!text.startsWith(SHEET_SELECTOR_ANCHOR + ':')) return null;
26
29
 
@@ -28,8 +31,9 @@ export function getSheetSelectorWeight(selector: ItemSelector | null): number |
28
31
  if (end < 0) return null;
29
32
 
30
33
  const [weightValue] = text.slice(SHEET_SELECTOR_ANCHOR.length + 1, end).split(':');
34
+ if (!weightValue) return null;
31
35
  const weight = Number(weightValue);
32
- return Number.isInteger(weight) && weight > 0 ? weight : null;
36
+ return Number.isInteger(weight) && weight >= 0 ? weight : null;
33
37
  }
34
38
 
35
39
  function stripSheetSelectorAnchor(selector: string) {
@@ -42,3 +46,8 @@ function stripSheetSelectorAnchor(selector: string) {
42
46
 
43
47
  return selector.slice(SHEET_SELECTOR_ANCHOR.length);
44
48
  }
49
+
50
+ export function hasGlobalSheetSelectorAnchor(selector: ItemSelector | null): boolean {
51
+ const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
52
+ return text.startsWith(GLOBAL_SHEET_SELECTOR_ANCHOR);
53
+ }
@@ -382,7 +382,7 @@ function decorateClassNameValue<ClassName extends string>(
382
382
  if (isClassNameValue(value)) return value;
383
383
 
384
384
  if (isStyleImportantValue(value)) {
385
- return importantValue(decorateClassNameValue(value.value, className));
385
+ return importantValue(decorateClassNameValue(value.value, className), value.native);
386
386
  }
387
387
 
388
388
  if (isStyleWeightValue(value)) {
@@ -29,4 +29,6 @@ export const ITEM_VALUE_TYPE_STYLE_DATA = 2;
29
29
  export const ITEM_VALUE_NUMBER_PX = 1;
30
30
  export const ITEM_VALUE_TYPE_AT_RULE_REF = 3;
31
31
 
32
+ export const GLOBAL_SHEET_SELECTOR_ANCHOR = '\0global';
33
+
32
34
  export const SHEET_SELECTOR_ANCHOR = '\0sheet';
@@ -66,7 +66,7 @@ export type SheetData<Style = unknown> =
66
66
 
67
67
  export type CreateSheetOptions = {
68
68
  layer?: boolean | string;
69
- weight?: number;
69
+ specificity?: number;
70
70
  };
71
71
 
72
72
  export type ScopeData =
@@ -104,6 +104,7 @@ export function mergeScopeData(
104
104
  scopeItem.selector,
105
105
  scopeItem.parentSelector,
106
106
  scopeItem.atRule,
107
+ scopeItem.importantNative,
107
108
  );
108
109
 
109
110
  className = getAtomicClassName(
@@ -121,6 +122,8 @@ export function mergeScopeData(
121
122
  scopeItem.transformClassName ?? null,
122
123
  CSS_CONFIG.transformClassNameFormat ?? null,
123
124
  CSS_CONFIG.sheetClassNameFormat ?? null,
125
+ null,
126
+ scopeItem.importantNative,
124
127
  );
125
128
 
126
129
  scopeItem.dedupe = dedupe;
@@ -173,6 +176,7 @@ export function mergeScopeData(
173
176
  property: overrideItem.property,
174
177
  weight: overrideItem.weight,
175
178
  important: overrideItem.important,
179
+ importantNative: overrideItem.importantNative,
176
180
  value: overrideItem.value,
177
181
  transformClassName: overrideItem.transformClassName,
178
182
  token: overrideItem.token,
@@ -195,6 +199,7 @@ export function mergeScopeData(
195
199
  scopeItem.selector,
196
200
  parentSelector,
197
201
  scopeItem.atRule,
202
+ scopeItem.importantNative,
198
203
  );
199
204
 
200
205
  className = getAtomicClassName(
@@ -212,6 +217,8 @@ export function mergeScopeData(
212
217
  scopeItem.transformClassName ?? null,
213
218
  CSS_CONFIG.transformClassNameFormat ?? null,
214
219
  CSS_CONFIG.sheetClassNameFormat ?? null,
220
+ null,
221
+ scopeItem.importantNative,
215
222
  );
216
223
 
217
224
  scopeItem.dedupe = dedupe;
@@ -74,6 +74,7 @@ export function mergeBuilderData<Data extends BuilderData>(
74
74
  let value: string;
75
75
  let weight: number | null;
76
76
  let important: boolean;
77
+ let importantNative: boolean;
77
78
  let itemCallsite: BuilderCallsite | null;
78
79
  let className: string;
79
80
  let dedupe: string;
@@ -132,7 +133,7 @@ export function mergeBuilderData<Data extends BuilderData>(
132
133
  } else {
133
134
  for (const property in style) {
134
135
  valueRaw = style[property as keyof typeof style];
135
- [valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
136
+ [valueRaw, weight, important, importantNative] = unwrapAuthoredStyleValue(valueRaw);
136
137
  const sourceType = source[BUILDER_TYPE];
137
138
  checkImportantUsage(
138
139
  valueRaw,
@@ -169,6 +170,7 @@ export function mergeBuilderData<Data extends BuilderData>(
169
170
  property,
170
171
  weight,
171
172
  important,
173
+ importantNative,
172
174
  value,
173
175
  transformClassName,
174
176
  variable: ref
@@ -235,6 +237,7 @@ export function mergeBuilderData<Data extends BuilderData>(
235
237
  runtimeItem.selector,
236
238
  null,
237
239
  runtimeItem.atRule,
240
+ runtimeItem.importantNative,
238
241
  );
239
242
 
240
243
  className = getAtomicClassName(
@@ -252,6 +255,8 @@ export function mergeBuilderData<Data extends BuilderData>(
252
255
  runtimeItem.transformClassName ?? null,
253
256
  CSS_CONFIG.transformClassNameFormat ?? null,
254
257
  CSS_CONFIG.sheetClassNameFormat ?? null,
258
+ null,
259
+ runtimeItem.importantNative,
255
260
  );
256
261
 
257
262
  runtimeItem.dedupe = dedupe;
@@ -269,13 +274,17 @@ export function mergeBuilderData<Data extends BuilderData>(
269
274
  return data;
270
275
  }
271
276
 
272
- function unwrapAuthoredStyleValue(value: unknown): [value: unknown, weight: number | null, important: boolean] {
277
+ function unwrapAuthoredStyleValue(
278
+ value: unknown,
279
+ ): [value: unknown, weight: number | null, important: boolean, native: boolean] {
273
280
  let weight: number | null = null;
274
281
  let important = false;
282
+ let native = false;
275
283
 
276
284
  while (true) {
277
285
  if (isStyleImportantValue(value)) {
278
286
  important = true;
287
+ native ||= value.native === true;
279
288
  value = value.value;
280
289
  continue;
281
290
  }
@@ -289,7 +298,7 @@ function unwrapAuthoredStyleValue(value: unknown): [value: unknown, weight: numb
289
298
  break;
290
299
  }
291
300
 
292
- return [value, weight, important];
301
+ return [value, weight, important, native];
293
302
  }
294
303
 
295
304
  function checkImportantUsage(value: unknown, important: boolean, isSheet: boolean) {
@@ -92,6 +92,7 @@ export type RuntimeItemData = {
92
92
  property: string;
93
93
  weight: number | null;
94
94
  important: boolean;
95
+ importantNative?: boolean;
95
96
  value: ItemValue;
96
97
  transformClassName?: string | null;
97
98
  variable?: ExtractedItemValue;
@@ -7,7 +7,7 @@ import {
7
7
  } from './selector_override_core';
8
8
 
9
9
  export type { ManualSelectorInput } from './selector_override_core';
10
- export { setSheetSelectorOptions } from './selector_override_core';
10
+ export { setGlobalSheetSelectorOptions, setSheetSelectorOptions } from './selector_override_core';
11
11
 
12
12
  export function normalizeManualSelectors(input: ManualSelectorInput): ItemSelector[] {
13
13
  return normalizeManualSelectorsCore(input, assertManualSelector);
@@ -1,6 +1,6 @@
1
1
  import type { ItemSelector } from './data';
2
2
  import type { CreateSheetOptions } from './data';
3
- import { SHEET_SELECTOR_ANCHOR } from './data';
3
+ import { GLOBAL_SHEET_SELECTOR_ANCHOR, SHEET_SELECTOR_ANCHOR } from './data';
4
4
 
5
5
  export type ManualSelectorInput = string | readonly string[];
6
6
 
@@ -45,10 +45,10 @@ export function assertManualSelectorSyntax(selector: string) {
45
45
  }
46
46
 
47
47
  export function setSheetSelectorOptions(selector: ItemSelector, options: CreateSheetOptions): ItemSelector {
48
- if (options.weight === undefined && options.layer === undefined) return selector;
48
+ if (options.specificity === undefined && options.layer === undefined) return selector;
49
49
 
50
50
  const text = Array.isArray(selector) ? selector[0] : selector;
51
- const optionMarker = ':' + (options.weight ?? '') + ':' + (
51
+ const optionMarker = ':' + (options.specificity ?? '') + ':' + (
52
52
  typeof options.layer === 'string'
53
53
  ? JSON.stringify(options.layer)
54
54
  : options.layer === undefined
@@ -83,3 +83,17 @@ function normalizeManualSelector(
83
83
  SHEET_SELECTOR_ANCHOR + (value.startsWith('&') ? value.slice(1) : ' ' + value),
84
84
  ];
85
85
  }
86
+
87
+ /** Convert a normalized explicit selector into an unscoped sheet selector. */
88
+ export function setGlobalSheetSelectorOptions(
89
+ selector: ItemSelector,
90
+ options: Pick<CreateSheetOptions, 'layer'>,
91
+ ): ItemSelector {
92
+ const text = Array.isArray(selector) ? selector[0] : selector;
93
+ const suffix = text.slice(SHEET_SELECTOR_ANCHOR.length);
94
+ if (!suffix.startsWith(' ') || !suffix.trim()) {
95
+ throw new Error('createGlobalSheet requires explicit selectors without an ampersand anchor');
96
+ }
97
+ const global = GLOBAL_SHEET_SELECTOR_ANCHOR + JSON.stringify(options.layer ?? null) + '\0' + suffix.trimStart();
98
+ return Array.isArray(selector) ? [global, selector[1]] : global;
99
+ }
@@ -66,7 +66,7 @@ export function typeAliases<Style, Selectors>() {
66
66
 
67
67
  type ValueFn = <const T>(value: T, weight: number) => StyleWeightValue<T>;
68
68
 
69
- type ImportantFn = <const T>(value: T) => StyleImportantValue<T>;
69
+ type ImportantFn = <const T>(value: T, native?: boolean) => StyleImportantValue<T>;
70
70
 
71
71
  type RawFn<Style> = <T extends StyleObject<Style>>(style: T) => T;
72
72
 
@@ -1,84 +1,30 @@
1
- import { compareLayerPriority, getLayerBlockCss, getLayerOrderCss } from '../../atomic/layer';
2
- import { type CssConfig, isStyleLayerEnabled } from '../../config/config/css';
1
+ import { type CssConfig } from '../../config/config/css';
2
+ import { serializeOrderedRules } from '../../sheet/ordering';
3
3
  import { DEFAULT_CONFIG } from '../utils/constants';
4
4
  import type { CssExtractRule } from './types';
5
5
 
6
6
  type CssOptions = Pick<CssConfig, 'layer' | 'layers' | 'layerNamespace'>;
7
-
8
7
  export type CompilerExtractCssArgs = Partial<CssOptions>;
9
8
 
10
- export function extractCss(
11
- items: CssExtractRule[],
12
- args: CompilerExtractCssArgs,
13
- ) {
14
- return getExtractedCssItems(items, args);
15
- }
16
-
17
- function getExtractedCssItems(
18
- items: CssExtractRule[],
19
- args: CompilerExtractCssArgs,
20
- ): string {
21
- const sortedItems = items
22
- .slice()
23
- .sort((a, b) => compareLayerPriority(a.priority, b.priority));
24
-
9
+ export function extractCss(items: CssExtractRule[], args: CompilerExtractCssArgs) {
25
10
  const seen = new Set<string>();
26
- const css: CssExtractRule[] = [];
27
-
28
- for (const item of sortedItems) {
29
- const key = JSON.stringify([item.layer, item.css]);
30
- if (seen.has(key)) continue;
31
-
11
+ const unique = items.filter((item) => {
12
+ const key = JSON.stringify([
13
+ item.globalSheet?.id,
14
+ item.globalSheet?.order,
15
+ item.sheet,
16
+ item.layer,
17
+ item.importantNative,
18
+ item.css,
19
+ ]);
20
+ if (seen.has(key)) return false;
32
21
  seen.add(key);
33
- css.push(item);
34
- }
35
-
36
- if (!css.length) return '';
37
-
38
- const defaults = DEFAULT_CONFIG;
39
-
40
- const layerNamespace = args.layerNamespace ?? defaults.layerNamespace ?? '';
41
- const layers = args.layers ?? defaults.layers ?? [];
42
- const styleLayer = isStyleLayerEnabled(args.layer ?? defaults.layer);
43
- const sheetLayerName = layerNamespace ? layerNamespace + '.sheet' : 'sheet';
44
- const styleItems: string[] = [];
45
- const sheetItems = new Map<string, string[]>();
46
- const unlayeredItems: string[] = [];
47
-
48
- for (let i = 0, len = css.length; i < len; i++) {
49
- const item = css[i];
50
- if (item.layer === 'sheet' || typeof item.layer === 'object') {
51
- const name = typeof item.layer === 'object' ? item.layer.name : sheetLayerName;
52
- const rules = sheetItems.get(name) ?? [];
53
- rules.push(item.css);
54
- sheetItems.set(name, rules);
55
- } else if (item.layer === false || !styleLayer) {
56
- unlayeredItems.push(item.css);
57
- } else {
58
- styleItems.push(item.css);
59
- }
60
- }
61
-
62
- const hasNestedSheetLayer = [...sheetItems.keys()].some((name) => name.startsWith(layerNamespace + '.'));
63
- const styleLayerName = hasNestedSheetLayer && layerNamespace
64
- ? layerNamespace + '.style'
65
- : layerNamespace;
66
-
67
- const layerNames = [
68
- styleItems.length ? styleLayerName : '',
69
- ...sheetItems.keys(),
70
- ].filter(Boolean);
71
- const output: string[] = [];
72
- const layerOrder = getLayerOrderCss(layers, layerNames);
73
-
74
- if (layerOrder) output.push(layerOrder);
75
- if (styleItems.length) {
76
- output.push(getLayerBlockCss(styleLayerName, '\n' + styleItems.join('\n') + '\n'));
77
- }
78
- for (const [name, rules] of sheetItems) {
79
- output.push(getLayerBlockCss(name, '\n' + rules.join('\n') + '\n'));
80
- }
81
- output.push(...unlayeredItems);
82
-
83
- return output.join('\n');
22
+ return true;
23
+ });
24
+ if (!unique.length) return '';
25
+ return serializeOrderedRules(unique, {
26
+ layer: args.layer ?? DEFAULT_CONFIG.layer ?? true,
27
+ layers: args.layers ?? DEFAULT_CONFIG.layers,
28
+ layerNamespace: args.layerNamespace ?? DEFAULT_CONFIG.layerNamespace,
29
+ });
84
30
  }
@@ -28,7 +28,10 @@ export type CssExtractRule = {
28
28
  css: string;
29
29
  priority: LayerPriority;
30
30
  important?: boolean;
31
- layer?: 'sheet' | false | NamedSheetLayer;
31
+ importantNative?: boolean;
32
+ sheet?: boolean;
33
+ globalSheet?: { id: string; order: number; };
34
+ layer?: 'style' | 'sheet' | false | NamedSheetLayer;
32
35
  trace?: {
33
36
  filePath: string;
34
37
  line: number;
@@ -11,6 +11,7 @@ import {
11
11
  DEBUG_SOURCE_CONTENT_VAR,
12
12
  DEBUG_SOURCE_URL_VAR,
13
13
  DEFAULT_CONFIG,
14
+ FN_CREATE_GLOBAL_SHEET,
14
15
  FN_CREATE_THEME,
15
16
  FN_STYLE_KEYFRAMES,
16
17
  FN_STYLE_MERGE,
@@ -19,6 +20,7 @@ import {
19
20
  FN_STYLE_SCOPE,
20
21
  FN_STYLE_SELECTOR,
21
22
  IMPORT_PATHS,
23
+ STYLE_CSS_IMPORT_PATH,
22
24
  } from '../../utils/constants';
23
25
  import { createImportSourceMatcher, type ImportSourceMatcher } from '../../utils/import_source';
24
26
  import {
@@ -160,6 +162,26 @@ export function createDebugPlugin(args: PluginArgs) {
160
162
  path: NodePath<BabelTypes.CallExpression>,
161
163
  state: PluginState,
162
164
  ) {
165
+ if (path.node.callee.type === 'Identifier') {
166
+ const imported = state.imports.get(path.node.callee.name);
167
+ if (
168
+ imported?.source === STYLE_CSS_IMPORT_PATH && imported.name === FN_CREATE_GLOBAL_SHEET &&
169
+ !hasDebugArgument(path.node.arguments)
170
+ ) {
171
+ const debug = buildDebugDataObject(
172
+ t,
173
+ path.node,
174
+ state.fileId,
175
+ getSourceUrlId(t, state),
176
+ sourceContent ? getSourceContentId(t, state) : null,
177
+ );
178
+ if (!path.getFunctionParent()) {
179
+ debug.properties.push(t.objectProperty(t.identifier('globalModule'), t.stringLiteral(state.filePath)));
180
+ }
181
+ if (!path.node.arguments.length) path.node.arguments.push(t.arrayExpression([]));
182
+ path.node.arguments.push(debug);
183
+ }
184
+ }
163
185
  annotateThemeCall(path.node, state, t);
164
186
  annotateThemeCallsite(t, path, state, sourceContent);
165
187
 
@@ -828,7 +828,10 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
828
828
  const value = evaluateNode(node.arguments[0] as BabelTypes.Node, scope);
829
829
  if (!value.ok) return value;
830
830
 
831
- return evalOk(importantValue(value.value));
831
+ const native = node.arguments[1] ? evaluateNode(node.arguments[1] as BabelTypes.Node, scope) : evalOk(false);
832
+ if (!native.ok) return native;
833
+ if (typeof native.value !== 'boolean') return evalFail('style.important second argument must be a boolean');
834
+ return evalOk(importantValue(value.value, native.value));
832
835
  }
833
836
 
834
837
  if (