@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.
- package/CHANGELOG.md +12 -0
- package/atomic/className.ts +4 -0
- package/atomic/rule.ts +15 -7
- package/atomic/utils/selector.ts +12 -3
- package/builder/classname/class_name_builder.ts +1 -1
- package/builder/data/const.ts +2 -0
- package/builder/data/data.ts +1 -1
- package/builder/data/merge/scope.ts +7 -0
- package/builder/data/merge/style.ts +12 -3
- package/builder/data/state.ts +1 -0
- package/builder/selector_override.ts +1 -1
- package/builder/selector_override_core.ts +17 -3
- package/builder/types/alias.ts +1 -1
- package/compiler/extract/extract.ts +21 -75
- package/compiler/extract/types.ts +4 -1
- package/compiler/transform/debug/plugin.ts +22 -0
- package/compiler/transform/evaluator/evaluator.ts +4 -1
- package/compiler/transform/extract/chain/chain.ts +82 -22
- package/compiler/transform/extract/chain/extract_chain.ts +2 -0
- package/compiler/transform/extract/plugin.ts +51 -25
- package/compiler/transform/extract/utils/imports.ts +4 -1
- package/compiler/transform/extract/utils/replacement.ts +2 -2
- package/compiler/transform/utils/babel.ts +1 -1
- package/compiler/utils/constants.ts +1 -0
- package/config/config/css.ts +5 -3
- package/config/configure.ts +4 -0
- package/config/document.ts +23 -0
- package/css/globalSheet.ts +66 -0
- package/css/index.ts +4 -1
- package/css/sheet.ts +34 -14
- package/dist/{className-yhJCGT0F.js → className-CC5PHcXI.js} +9 -2
- package/dist/className-CC5PHcXI.js.map +1 -0
- package/dist/{combine-CC9bY-hu.js → combine-BpOQWCtM.js} +5 -5
- package/dist/combine-BpOQWCtM.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-Ct5xGIeu.mjs → compiler-AOb_VaKQ.mjs} +464 -166
- package/dist/compiler-AOb_VaKQ.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/{config-CCgsVvyR.js → config-B70LIQhi.js} +2 -2
- package/dist/{config-CCgsVvyR.js.map → config-B70LIQhi.js.map} +1 -1
- package/dist/{config-DZKR6gH1.js → config-BF-mxuPk.js} +4 -4
- package/dist/{config-DZKR6gH1.js.map → config-BF-mxuPk.js.map} +1 -1
- package/dist/{config-BiiMS4rU.js → config-B_OQYZSm.js} +25 -4
- package/dist/config-B_OQYZSm.js.map +1 -0
- package/dist/{css-WaHZ6gxv.js → css-C7tcD3IO.js} +611 -213
- package/dist/css-C7tcD3IO.js.map +1 -0
- package/dist/css-Cdxkur4h.js +414 -0
- package/dist/css-Cdxkur4h.js.map +1 -0
- package/dist/{css-IecKRNxs.js → css-RohOR3Vq.js} +112 -73
- package/dist/css-RohOR3Vq.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/css_extra-BC1Z_hDy.js +8 -0
- package/dist/{css_extra-DDeJc2Cu.js.map → css_extra-BC1Z_hDy.js.map} +1 -1
- package/dist/{css_extra-DDeJc2Cu.js → css_extra-CuzJtAR_.js} +2 -2
- package/dist/css_extra-CuzJtAR_.js.map +1 -0
- package/dist/{data-BgZmL55Y.js → data-Bw3Xod5J.js} +28 -19
- package/dist/data-Bw3Xod5J.js.map +1 -0
- package/dist/{debug-D-1hhd0G.js → debug-CVO3xx4C.js} +6 -9
- package/dist/debug-CVO3xx4C.js.map +1 -0
- package/dist/dev/rsc.js +134 -25
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CBRbVaeq.js → dev-BnQXPLQB.js} +6 -6
- package/dist/{dev-CBRbVaeq.js.map → dev-BnQXPLQB.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CJcfpKL1.js → elementMarker-BrHXg161.js} +334 -53
- package/dist/elementMarker-BrHXg161.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +1 -1
- package/dist/entry/dev/adapter/react.js +1 -1
- package/dist/entry/dev/adapter/solid.js +1 -1
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +11 -11
- package/dist/entry/prod/adapter/preact.js +1 -1
- package/dist/entry/prod/adapter/react.js +1 -1
- package/dist/entry/prod/adapter/solid.js +1 -1
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js.map +1 -1
- package/dist/entry/prod.js +3 -3
- package/dist/entry/rsc-dev/adapter/preact.js +1 -1
- package/dist/entry/rsc-dev/adapter/react.js +1 -1
- package/dist/entry/rsc-dev/adapter/solid.js +1 -1
- package/dist/entry/rsc-dev/css.js +4 -3
- package/dist/entry/rsc-dev/dev.js +129 -24
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +5 -4
- package/dist/entry/rsc-dev/jsx-dev-runtime.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +8 -7
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +4 -4
- package/dist/entry/rsc-prod.js +4 -4
- package/dist/{rules-Dz-szpPu.js → env-D6daex-9.js} +64 -19
- package/dist/env-D6daex-9.js.map +1 -0
- package/dist/{getClassName-DtkplEIt.js → getClassName-5yYUibKw.js} +2 -2
- package/dist/{getClassName-DtkplEIt.js.map → getClassName-5yYUibKw.js.map} +1 -1
- package/dist/getClassName-9CsXbNls.js.map +1 -1
- package/dist/{getClassName-CeoxISNW.js → getClassName-B3azD1TO.js} +6 -4
- package/dist/getClassName-B3azD1TO.js.map +1 -0
- package/dist/{getClassName-BNe3Ycyy.js → getClassName-m5DOkMFQ.js} +4 -4
- package/dist/{getClassName-BNe3Ycyy.js.map → getClassName-m5DOkMFQ.js.map} +1 -1
- package/dist/{global-UOHFwqHN.js → global-DeIYtcdl.js} +5 -2
- package/dist/{global-UOHFwqHN.js.map → global-DeIYtcdl.js.map} +1 -1
- package/dist/{css-BhoclXaw.js → globalSheet-CdgVpvCb.js} +185 -426
- package/dist/globalSheet-CdgVpvCb.js.map +1 -0
- package/dist/{hash-DlXmmPPm.js → hash-DCJkLls_.js} +4 -4
- package/dist/hash-DCJkLls_.js.map +1 -0
- package/dist/index.js +9 -9
- package/dist/jsx/jsx-dev-runtime.js +1 -1
- package/dist/jsx/jsx-dev-runtime.server.js +3 -3
- package/dist/jsx/jsx-dev-runtime.server.js.map +1 -1
- package/dist/jsx/jsx-runtime.js +1 -1
- package/dist/jsx/jsx-runtime.server.js +4 -4
- package/dist/jsx/jsx-runtime.server.js.map +1 -1
- package/dist/{jsx-8TwYuvgM.js → jsx-CvloSSpb.js} +4 -4
- package/dist/{jsx-8TwYuvgM.js.map → jsx-CvloSSpb.js.map} +1 -1
- package/dist/jsx_runtime-pt7DOZOE.js +13 -0
- package/dist/jsx_runtime-pt7DOZOE.js.map +1 -0
- package/dist/{loader-BVebGteg.mjs → loader-fAuIjIik.mjs} +3 -3
- package/dist/{loader-BVebGteg.mjs.map → loader-fAuIjIik.mjs.map} +1 -1
- package/dist/{misc-Bs2DgdG7.mjs → misc-CyZgGtc9.mjs} +3 -3
- package/dist/{misc-Bs2DgdG7.mjs.map → misc-CyZgGtc9.mjs.map} +1 -1
- package/dist/{namedTokens-CwniouKk.js → namedTokens-DwgmUMBM.js} +2 -2
- package/dist/{namedTokens-CwniouKk.js.map → namedTokens-DwgmUMBM.js.map} +1 -1
- package/dist/plugin/farm/index.mjs +3 -3
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +7 -5
- package/dist/plugin/nextjs/loader.mjs.map +1 -1
- package/dist/plugin/parcel/index.cjs +1 -1
- package/dist/plugin/parcel/index.mjs +2 -2
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +2 -2
- package/dist/plugin/vite/index.mjs +3 -3
- package/dist/plugin/webpack/index.mjs +2 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +3 -3
- package/dist/{registry-D1n78rd7.mjs → registry-BMijh1CM.mjs} +2 -2
- package/dist/{registry-D1n78rd7.mjs.map → registry-BMijh1CM.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-BJcykzdl.js → resolveClassNameRuntime-B6vKNL5y.js} +2 -2
- package/dist/{resolveClassNameRuntime-BJcykzdl.js.map → resolveClassNameRuntime-B6vKNL5y.js.map} +1 -1
- package/dist/server.js +87 -17
- package/dist/server.js.map +1 -1
- package/dist/{shared-D4-AKGn6.mjs → shared-BfASWZo1.mjs} +4 -4
- package/dist/{shared-D4-AKGn6.mjs.map → shared-BfASWZo1.mjs.map} +1 -1
- package/dist/{shared-C9XQd8p_.cjs → shared-DY0kuBcN.cjs} +460 -162
- package/dist/shared-DY0kuBcN.cjs.map +1 -0
- package/dist/sheet-B-5idGtZ.js +9 -0
- package/dist/sheet-B-5idGtZ.js.map +1 -0
- package/dist/{config-TyjNpRrV.js → sheet-C6ymGhKV.js} +23 -2
- package/dist/sheet-C6ymGhKV.js.map +1 -0
- package/dist/sheet-D4f9KYPf.js +1 -0
- package/dist/{sidecar-CZTYX2vA.mjs → sidecar-cCzTDkzg.mjs} +3 -3
- package/dist/{sidecar-CZTYX2vA.mjs.map → sidecar-cCzTDkzg.mjs.map} +1 -1
- package/dist/{style-CmXHCPF4.js → style-a6ccye6R.js} +12 -12
- package/dist/style-a6ccye6R.js.map +1 -0
- package/dist/styleStore-Ceoaqa5U.js +45 -0
- package/dist/styleStore-Ceoaqa5U.js.map +1 -0
- package/dist/{env-C8TRVSyb.js → styleStore-D1IEmq1v.js} +435 -63
- package/dist/styleStore-D1IEmq1v.js.map +1 -0
- package/dist/{token-DMrBbat8.js → token-Ci73NE6h.js} +2 -2
- package/dist/{token-DMrBbat8.js.map → token-Ci73NE6h.js.map} +1 -1
- package/dist/{trace-C7EzEj2Q.js → trace-DDsvwdF0.js} +3 -3
- package/dist/{trace-C7EzEj2Q.js.map → trace-DDsvwdF0.js.map} +1 -1
- package/dist/{trace-DzCntvK4.js → trace-uHVvnYiw.js} +2 -2
- package/dist/{trace-DzCntvK4.js.map → trace-uHVvnYiw.js.map} +1 -1
- package/dist/{transform-CSZMklMb.js → transform-BkxIouPX.js} +2 -2
- package/dist/{transform-CSZMklMb.js.map → transform-BkxIouPX.js.map} +1 -1
- package/dist/types/atomic/className.d.ts +2 -2
- package/dist/types/atomic/utils/selector.d.ts +2 -1
- package/dist/types/builder/data/const.d.ts +1 -0
- package/dist/types/builder/data/data.d.ts +1 -1
- package/dist/types/builder/data/state.d.ts +1 -0
- package/dist/types/builder/selector_override.d.ts +1 -1
- package/dist/types/builder/selector_override_core.d.ts +2 -0
- package/dist/types/builder/types/alias.d.ts +2 -2
- package/dist/types/compiler/extract/types.d.ts +7 -1
- package/dist/types/compiler/transform/extract/chain/extract_chain.d.ts +2 -0
- package/dist/types/compiler/utils/constants.d.ts +1 -0
- package/dist/types/config/config/css.d.ts +2 -1
- package/dist/types/config/configure.d.ts +2 -0
- package/dist/types/config/document.d.ts +3 -0
- package/dist/types/css/globalSheet.d.ts +24 -0
- package/dist/types/css/index.d.ts +4 -1
- package/dist/types/css/sheet.d.ts +3 -2
- package/dist/types/entry/rsc_dev/css.d.ts +1 -0
- package/dist/types/runtime/rsc/constants.d.ts +2 -0
- package/dist/types/runtime/rsc/dev.d.ts +5 -0
- package/dist/types/runtime/rsc/getClassName.d.ts +3 -0
- package/dist/types/runtime/rsc/globalSheet.d.ts +22 -0
- package/dist/types/runtime/rsc/observer.d.ts +5 -0
- package/dist/types/runtime/rsc/styleStore.d.ts +2 -0
- package/dist/types/runtime/sheet/document.d.ts +3 -0
- package/dist/types/sheet/ordered.d.ts +4 -0
- package/dist/types/sheet/ordering.d.ts +15 -0
- package/dist/types/sheet/types.d.ts +7 -0
- package/dist/types/style/important.d.ts +2 -1
- package/dist/types/style/style.d.ts +2 -2
- package/dist/{utils-CoMwEfhG.mjs → utils-BO6Ix8t5.mjs} +4 -4
- package/dist/{utils-CoMwEfhG.mjs.map → utils-BO6Ix8t5.mjs.map} +1 -1
- package/dist/{utils-B7QcJ-Yw.js → utils-CB70kIh6.js} +3 -3
- package/dist/{utils-B7QcJ-Yw.js.map → utils-CB70kIh6.js.map} +1 -1
- package/dist/{utils-BYpkJ-uE.mjs → utils-EG9gh2g3.mjs} +3 -3
- package/dist/{utils-BYpkJ-uE.mjs.map → utils-EG9gh2g3.mjs.map} +1 -1
- package/dist/{utils-D4KMqCu2.js → utils-sG7IWYP6.js} +1089 -646
- package/dist/utils-sG7IWYP6.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/{value-yd2SZ1XQ.js → value-B-ThmbY-.js} +16 -9
- package/dist/value-B-ThmbY-.js.map +1 -0
- package/dist/{webpack-B6z1UHh9.mjs → webpack-WXAJ3IYn.mjs} +5 -5
- package/dist/{webpack-B6z1UHh9.mjs.map → webpack-WXAJ3IYn.mjs.map} +1 -1
- package/entry/dev/sheet.ts +4 -1
- package/entry/rsc_dev/css.ts +2 -0
- package/jsx/rsc/jsx_dev_runtime.ts +11 -2
- package/jsx/rsc/jsx_runtime.ts +14 -3
- package/package.json +1 -1
- package/plugin/nextjs/loader.ts +18 -2
- package/runtime/core/elementMarker.ts +9 -3
- package/runtime/rsc/constants.ts +3 -0
- package/runtime/rsc/dev.ts +31 -15
- package/runtime/rsc/getClassName.ts +6 -0
- package/runtime/rsc/globalSheet.ts +130 -0
- package/runtime/rsc/observer.ts +118 -15
- package/runtime/rsc/styleStore.ts +12 -36
- package/runtime/sheet/document.ts +28 -0
- package/runtime/sheet/global-prod.ts +3 -5
- package/runtime/sheet/global.ts +3 -5
- package/runtime/sheet/rule.ts +4 -2
- package/runtime/sheet/rules.ts +3 -0
- package/sheet/dev/dev_sort.ts +5 -1
- package/sheet/dev/index.ts +23 -3
- package/sheet/ordered.ts +188 -0
- package/sheet/ordering.ts +138 -0
- package/sheet/prod.ts +17 -5
- package/sheet/types.ts +4 -0
- package/style/important.ts +3 -1
- package/style/style.ts +1 -1
- package/utils/trace.ts +1 -0
- package/dist/className-yhJCGT0F.js.map +0 -1
- package/dist/combine-CC9bY-hu.js.map +0 -1
- package/dist/compiler-Ct5xGIeu.mjs.map +0 -1
- package/dist/config-BiiMS4rU.js.map +0 -1
- package/dist/config-TyjNpRrV.js.map +0 -1
- package/dist/createTransformElement-BGznW-Mu.js +0 -34
- package/dist/createTransformElement-BGznW-Mu.js.map +0 -1
- package/dist/css-BhoclXaw.js.map +0 -1
- package/dist/css-IecKRNxs.js.map +0 -1
- package/dist/css-WaHZ6gxv.js.map +0 -1
- package/dist/data-BgZmL55Y.js.map +0 -1
- package/dist/debug-D-1hhd0G.js.map +0 -1
- package/dist/elementMarker-CJcfpKL1.js.map +0 -1
- package/dist/env-C8TRVSyb.js.map +0 -1
- package/dist/getClassName-CeoxISNW.js.map +0 -1
- package/dist/global-CWYOol4o.js +0 -14
- package/dist/global-CWYOol4o.js.map +0 -1
- package/dist/hash-DlXmmPPm.js.map +0 -1
- package/dist/jsx_runtime-CPojW0KD.js +0 -12
- package/dist/jsx_runtime-CPojW0KD.js.map +0 -1
- package/dist/rules-Dz-szpPu.js.map +0 -1
- package/dist/shared-C9XQd8p_.cjs.map +0 -1
- package/dist/sheet-LU89fcH_.js +0 -7
- package/dist/sheet-LU89fcH_.js.map +0 -1
- package/dist/style-CmXHCPF4.js.map +0 -1
- package/dist/styleStore-B0x4Ahpx.js +0 -60
- package/dist/styleStore-B0x4Ahpx.js.map +0 -1
- package/dist/styleStore-BrpgLNgc.js +0 -57
- package/dist/styleStore-BrpgLNgc.js.map +0 -1
- package/dist/utils-D4KMqCu2.js.map +0 -1
- 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
|
package/atomic/className.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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 =
|
|
38
|
+
let selectorStr = hasGlobalSheetSelectorAnchor(selector)
|
|
39
|
+
? itemSelector
|
|
40
|
+
: classSelector + itemSelector;
|
|
33
41
|
|
|
34
42
|
if (parentSelector) {
|
|
35
43
|
const parentClass = '.' + escapeCssIdent(
|
package/atomic/utils/selector.ts
CHANGED
|
@@ -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
|
|
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
|
|
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)) {
|
package/builder/data/const.ts
CHANGED
package/builder/data/data.ts
CHANGED
|
@@ -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(
|
|
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) {
|
package/builder/data/state.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
+
}
|
package/builder/types/alias.ts
CHANGED
|
@@ -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 {
|
|
2
|
-
import {
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|