@fluentic/style 0.1.0-beta.13 → 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 +22 -0
- package/README.md +3 -2
- package/atomic/className.ts +4 -0
- package/atomic/rule.ts +15 -7
- package/atomic/token.ts +10 -1
- 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/extract/token.ts +10 -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 +87 -10
- package/compiler/transform/evaluator/tracer.ts +4 -0
- 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 +81 -29
- package/compiler/transform/extract/utils/imports.ts +8 -1
- package/compiler/transform/extract/utils/replacement.ts +17 -5
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/extract/utils/token.ts +107 -0
- package/compiler/transform/utils/babel.ts +1 -1
- package/compiler/utils/constants.ts +2 -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/dialect/namedTokens.ts +13 -8
- package/dist/{className-yhJCGT0F.js → className-CC5PHcXI.js} +9 -2
- package/dist/className-CC5PHcXI.js.map +1 -0
- package/dist/{combine-yuoQ_qpx.js → combine-BpOQWCtM.js} +5 -5
- package/dist/combine-BpOQWCtM.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-BEHxZYjz.mjs → compiler-AOb_VaKQ.mjs} +626 -188
- package/dist/compiler-AOb_VaKQ.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/{config-B5nEd-TV.js → config-B70LIQhi.js} +2 -2
- package/dist/{config-B5nEd-TV.js.map → config-B70LIQhi.js.map} +1 -1
- package/dist/{config-BWGBkVrM.js → config-BF-mxuPk.js} +4 -4
- package/dist/{config-BWGBkVrM.js.map → config-BF-mxuPk.js.map} +1 -1
- package/dist/config-B_OQYZSm.js +57 -0
- package/dist/config-B_OQYZSm.js.map +1 -0
- package/dist/{css-BQRIvzwZ.js → css-C7tcD3IO.js} +615 -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-p_5ZNny_.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-DuVzUIYx.js.map → css_extra-BC1Z_hDy.js.map} +1 -1
- package/dist/{css_extra-DuVzUIYx.js → css_extra-CuzJtAR_.js} +2 -2
- package/dist/css_extra-CuzJtAR_.js.map +1 -0
- package/dist/{data-QXDBLlWs.js → data-Bw3Xod5J.js} +28 -20
- package/dist/data-Bw3Xod5J.js.map +1 -0
- package/dist/{debug-CkgcZDaX.js → debug-CVO3xx4C.js} +24 -3
- 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-DocaGP3_.js → dev-BnQXPLQB.js} +6 -7
- package/dist/{dev-DocaGP3_.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-DZjd1NuA.js → elementMarker-BrHXg161.js} +334 -54
- 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 +10 -1
- 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 +14 -5
- package/dist/entry/rsc-prod.js.map +1 -1
- package/dist/{rules-znG9bsKI.js → env-D6daex-9.js} +64 -20
- 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-BIqt1S41.js → getClassName-B3azD1TO.js} +6 -4
- package/dist/getClassName-B3azD1TO.js.map +1 -0
- package/dist/{getClassName-BB_L7U_v.js → getClassName-m5DOkMFQ.js} +4 -5
- package/dist/{getClassName-BB_L7U_v.js.map → getClassName-m5DOkMFQ.js.map} +1 -1
- package/dist/global-DeIYtcdl.js +36 -0
- package/dist/global-DeIYtcdl.js.map +1 -0
- package/dist/{css-CGMAis1n.js → globalSheet-CdgVpvCb.js} +185 -426
- package/dist/globalSheet-CdgVpvCb.js.map +1 -0
- package/dist/{debug-0iaVEC7z.js → hash-DCJkLls_.js} +168 -6
- 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-BCufpzdb.js → jsx-CvloSSpb.js} +4 -4
- package/dist/{jsx-BCufpzdb.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-vMHuD1zT.mjs → loader-fAuIjIik.mjs} +3 -3
- package/dist/{loader-vMHuD1zT.mjs.map → loader-fAuIjIik.mjs.map} +1 -1
- package/dist/{misc-9EGKYkZo.mjs → misc-CyZgGtc9.mjs} +3 -3
- package/dist/{misc-9EGKYkZo.mjs.map → misc-CyZgGtc9.mjs.map} +1 -1
- package/dist/{namedTokens-DnpyC5XT.js → namedTokens-DwgmUMBM.js} +13 -9
- package/dist/namedTokens-DwgmUMBM.js.map +1 -0
- 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-DVB7n6V-.mjs → registry-BMijh1CM.mjs} +2 -2
- package/dist/{registry-DVB7n6V-.mjs.map → registry-BMijh1CM.mjs.map} +1 -1
- package/dist/{resolveClassNameRuntime-DvH6j_4N.js → resolveClassNameRuntime-B6vKNL5y.js} +2 -2
- package/dist/{resolveClassNameRuntime-DvH6j_4N.js.map → resolveClassNameRuntime-B6vKNL5y.js.map} +1 -1
- package/dist/server.js +87 -17
- package/dist/server.js.map +1 -1
- package/dist/{shared-O-5Fcsxa.mjs → shared-BfASWZo1.mjs} +4 -4
- package/dist/{shared-O-5Fcsxa.mjs.map → shared-BfASWZo1.mjs.map} +1 -1
- package/dist/{shared-DaEDCb8I.cjs → shared-DY0kuBcN.cjs} +622 -184
- 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-Bqe8Y-4_.js → sheet-C6ymGhKV.js} +23 -2
- package/dist/sheet-C6ymGhKV.js.map +1 -0
- package/dist/sheet-D4f9KYPf.js +1 -0
- package/dist/{sidecar-DiYLwXbk.mjs → sidecar-cCzTDkzg.mjs} +3 -3
- package/dist/{sidecar-DiYLwXbk.mjs.map → sidecar-cCzTDkzg.mjs.map} +1 -1
- package/dist/{style-CtXEZqgx.js → style-a6ccye6R.js} +12 -13
- 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-DJyXPJ9q.js → styleStore-D1IEmq1v.js} +439 -63
- package/dist/styleStore-D1IEmq1v.js.map +1 -0
- package/dist/{token-DyLO6Hnf.js → token-Ci73NE6h.js} +5 -33
- package/dist/token-Ci73NE6h.js.map +1 -0
- package/dist/{trace-C1_6fM21.js → trace-DDsvwdF0.js} +3 -3
- package/dist/{trace-C1_6fM21.js.map → trace-DDsvwdF0.js.map} +1 -1
- package/dist/{trace-Bsh-Kkg_.js → trace-uHVvnYiw.js} +2 -2
- package/dist/{trace-Bsh-Kkg_.js.map → trace-uHVvnYiw.js.map} +1 -1
- package/dist/{transform-8TIMiF5A.js → transform-BkxIouPX.js} +2 -2
- package/dist/{transform-8TIMiF5A.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/merge/utils.d.ts +6 -1
- package/dist/types/builder/data/state.d.ts +17 -2
- package/dist/types/builder/extract/token.d.ts +6 -1
- 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/style_fns.d.ts +1 -1
- package/dist/types/builder/types/alias.d.ts +2 -2
- package/dist/types/builder/utils.d.ts +1 -1
- package/dist/types/compiler/extract/types.d.ts +7 -1
- package/dist/types/compiler/transform/evaluator/evaluator.d.ts +18 -1
- package/dist/types/compiler/transform/extract/chain/extract_chain.d.ts +2 -0
- package/dist/types/compiler/transform/extract/utils/replacement.d.ts +2 -0
- package/dist/types/compiler/transform/extract/utils/state.d.ts +1 -0
- package/dist/types/compiler/transform/extract/utils/token.d.ts +3 -0
- package/dist/types/compiler/transform/utils/selector.d.ts +1 -1
- package/dist/types/compiler/utils/constants.d.ts +2 -0
- package/dist/types/compiler/utils/import_source.d.ts +8 -2
- 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/plugin/bundler/farm/plugin.d.ts +8 -2
- package/dist/types/presets/tailwind/selectors.d.ts +24 -24
- package/dist/types/presets/tailwind/theme.d.ts +361 -361
- package/dist/types/runtime/core/cache/itemWithResolver.d.ts +1 -1
- package/dist/types/runtime/core/cache/stateItem.d.ts +8 -2
- 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/runtime/types.d.ts +4 -1
- package/dist/types/selector/presets/default.d.ts +28 -28
- package/dist/types/selector/presets/minimal.d.ts +10 -10
- package/dist/types/selector/selector.d.ts +15 -2
- 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 +95 -95
- package/dist/{utils-BBN9msTv.mjs → utils-BO6Ix8t5.mjs} +4 -4
- package/dist/{utils-BBN9msTv.mjs.map → utils-BO6Ix8t5.mjs.map} +1 -1
- package/dist/{utils-DoKJnvxk.js → utils-CB70kIh6.js} +3 -3
- package/dist/{utils-DoKJnvxk.js.map → utils-CB70kIh6.js.map} +1 -1
- package/dist/{utils-Bjh9pO87.mjs → utils-EG9gh2g3.mjs} +3 -3
- package/dist/{utils-Bjh9pO87.mjs.map → utils-EG9gh2g3.mjs.map} +1 -1
- package/dist/{utils-10MTZOuB.js → utils-sG7IWYP6.js} +1091 -643
- package/dist/utils-sG7IWYP6.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/{value-Dg6ALjjj.js → value-B-ThmbY-.js} +47 -6
- package/dist/value-B-ThmbY-.js.map +1 -0
- package/dist/{webpack-C1j49Psk.mjs → webpack-WXAJ3IYn.mjs} +5 -5
- package/dist/{webpack-C1j49Psk.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 +5 -4
- package/plugin/nextjs/loader.ts +18 -2
- package/runtime/core/elementMarker.ts +9 -3
- package/runtime/extract/getClassName.ts +1 -1
- 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/style/token.ts +2 -0
- package/utils/trace.ts +1 -0
- package/dist/className-yhJCGT0F.js.map +0 -1
- package/dist/combine-yuoQ_qpx.js.map +0 -1
- package/dist/compiler-BEHxZYjz.mjs.map +0 -1
- package/dist/config-Bqe8Y-4_.js.map +0 -1
- package/dist/config-DggQEE-4.js +0 -36
- package/dist/config-DggQEE-4.js.map +0 -1
- package/dist/createTransformElement-B2jSnugo.js +0 -34
- package/dist/createTransformElement-B2jSnugo.js.map +0 -1
- package/dist/css-BQRIvzwZ.js.map +0 -1
- package/dist/css-CGMAis1n.js.map +0 -1
- package/dist/css-D7eTqvMH.js +0 -57
- package/dist/css-D7eTqvMH.js.map +0 -1
- package/dist/css-p_5ZNny_.js.map +0 -1
- package/dist/data-QXDBLlWs.js.map +0 -1
- package/dist/debug-0iaVEC7z.js.map +0 -1
- package/dist/debug-CkgcZDaX.js.map +0 -1
- package/dist/elementMarker-DZjd1NuA.js.map +0 -1
- package/dist/env-DJyXPJ9q.js.map +0 -1
- package/dist/getClassName-BIqt1S41.js.map +0 -1
- package/dist/global-CBQGormL.js +0 -14
- package/dist/global-CBQGormL.js.map +0 -1
- package/dist/hash-Cr-LCWDt.js +0 -166
- package/dist/hash-Cr-LCWDt.js.map +0 -1
- package/dist/jsx_runtime-Bu_A8mr4.js +0 -12
- package/dist/jsx_runtime-Bu_A8mr4.js.map +0 -1
- package/dist/namedTokens-DnpyC5XT.js.map +0 -1
- package/dist/rules-znG9bsKI.js.map +0 -1
- package/dist/shared-DaEDCb8I.cjs.map +0 -1
- package/dist/sheet-SlZRjOmw.js +0 -7
- package/dist/sheet-SlZRjOmw.js.map +0 -1
- package/dist/style-CtXEZqgx.js.map +0 -1
- package/dist/styleStore-BImBZdt6.js +0 -57
- package/dist/styleStore-BImBZdt6.js.map +0 -1
- package/dist/styleStore-CBan0gHQ.js +0 -60
- package/dist/styleStore-CBan0gHQ.js.map +0 -1
- package/dist/token-DyLO6Hnf.js.map +0 -1
- package/dist/utils-10MTZOuB.js.map +0 -1
- package/dist/value-Dg6ALjjj.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
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
|
+
|
|
15
|
+
## 0.1.0-beta.14
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Compile token factories at their definitions and preserve token references in extracted styles. Token groups become nested objects of extracted token leaves; value scales use a small precompiled lookup helper. Standalone getToken calls now receive CSS-variable metadata, including values imported through re-exports.
|
|
20
|
+
|
|
21
|
+
Named tokens now use global, hash-free CSS variable names derived from their explicit namespace and property path, independent of tokenNameFormat and hashLength. Rebuild all consumers together and update external CSS references to the new names. Path segments escape punctuation to avoid collisions.
|
|
22
|
+
|
|
23
|
+
- Use native TypeScript 7.0.2 for workspace checks and declaration emission, with TypeScript 6.0.2 API compatibility for tooling. Validate packed declarations with both TypeScript 5.9 and 7.
|
|
24
|
+
|
|
3
25
|
## 0.1.0-beta.13
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -455,8 +455,9 @@ production builds. Current benchmark snapshots:
|
|
|
455
455
|
The main production checks are runtime cost and bundle size. In the production
|
|
456
456
|
path most apps use, Fluentic extracts CSS at build time and ships the extracted
|
|
457
457
|
production runtime for `css` prop composition, dynamic values, class-name
|
|
458
|
-
merging, and token resolution.
|
|
459
|
-
min+gzip.
|
|
458
|
+
merging, and token resolution. The measured runtime surface reports `4.98 KiB`
|
|
459
|
+
(5,097 bytes) min+gzip in the refreshed beta.14 report; generated helpers and the optional JSX/dialect surfaces are
|
|
460
|
+
reported separately.
|
|
460
461
|
Browser and SSR benchmarks track whether style resolution stays fast in
|
|
461
462
|
app-shaped renders. See the
|
|
462
463
|
[Bundle Size](https://fluenticstack.com/style/docs/benchmark/bundle-size/),
|
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/token.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { CSS_CONFIG } from '../config/config/css';
|
|
2
2
|
import type { TokenNameFormat, TokenNameInfo } from '../config/types';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getStyleTokenId,
|
|
5
|
+
getStyleTokenName,
|
|
6
|
+
getStyleTokenVarName,
|
|
7
|
+
type StyleTokenData,
|
|
8
|
+
type StyleTokenOverride,
|
|
9
|
+
} from '../style/token';
|
|
4
10
|
import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
|
|
5
11
|
import { createNameFormatter } from './utils/format';
|
|
6
12
|
import { getIdentifierSafeHash } from './utils/hash';
|
|
@@ -13,6 +19,9 @@ export function getTokenVarName(
|
|
|
13
19
|
token: StyleTokenData | StyleTokenOverride,
|
|
14
20
|
format: TokenNameFormat | null,
|
|
15
21
|
) {
|
|
22
|
+
const explicitName = getStyleTokenVarName(token);
|
|
23
|
+
if (explicitName) return explicitName;
|
|
24
|
+
|
|
16
25
|
const id = getStyleTokenId(token);
|
|
17
26
|
const debugName = getStyleTokenName(token);
|
|
18
27
|
|
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
package/builder/extract/token.ts
CHANGED
|
@@ -55,3 +55,13 @@ function isExtractedTokenRef(value: unknown): value is StyleTokenData {
|
|
|
55
55
|
typeof (value as StyleTokenData)[TOKEN_ID] === 'string' &&
|
|
56
56
|
(value as { [TOKEN_OVERRIDE]?: true; })[TOKEN_OVERRIDE] !== true;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
/** A compiled value scale: parsing and CSS variable naming happen in the compiler. */
|
|
60
|
+
export function createExtractedValues(entries: readonly (readonly [string | number, StyleToken<unknown>])[]) {
|
|
61
|
+
const tokens = new Map(entries);
|
|
62
|
+
return function(key: string | number, value?: unknown) {
|
|
63
|
+
const token = tokens.get(key);
|
|
64
|
+
if (!token) throw new Error(`[Style.values] VALUE_NOT_FOUND: ${String(key)}`);
|
|
65
|
+
return arguments.length >= 2 ? token(value) : token;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -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
|
|