@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
|
@@ -27,11 +27,13 @@ import {
|
|
|
27
27
|
getStyleTokenId,
|
|
28
28
|
getStyleTokenName,
|
|
29
29
|
isStyleTokenData,
|
|
30
|
+
isStyleTokenOverrideData,
|
|
30
31
|
type StyleTokenData,
|
|
31
32
|
type StyleTokenOverride,
|
|
32
33
|
TOKEN_ID,
|
|
33
34
|
TOKEN_NAME,
|
|
34
35
|
TOKEN_OVERRIDE,
|
|
36
|
+
TOKEN_VAR_NAME,
|
|
35
37
|
} from '../../../style/token';
|
|
36
38
|
import type { StyleTransform } from '../../../style/transform';
|
|
37
39
|
import { exposeStyle } from '../../../style/utils';
|
|
@@ -70,12 +72,16 @@ import {
|
|
|
70
72
|
IMPORT_PATHS,
|
|
71
73
|
STYLE_UTILS_IMPORT_PATH,
|
|
72
74
|
} from '../../utils/constants';
|
|
73
|
-
import type
|
|
75
|
+
import { BabelCore, type BabelTypes } from '../utils/babel';
|
|
74
76
|
import type { EvalFail, EvalModuleBindings, EvalOk, EvalResult, ImportMap, ResolveImportFn } from './types';
|
|
75
77
|
|
|
76
78
|
const STYLE_IMPORT_PATHS = new Set(IMPORT_PATHS);
|
|
77
79
|
|
|
78
80
|
export const COMPILED_RUNTIME_VALUE = Symbol();
|
|
81
|
+
export const COMPILED_TOKEN_REFERENCE = Symbol();
|
|
82
|
+
export type CompiledTokenReference = {
|
|
83
|
+
[COMPILED_TOKEN_REFERENCE]?: { expression: BabelTypes.Expression; filePath: string; };
|
|
84
|
+
};
|
|
79
85
|
export const COMPILED_STYLE_OBJECT_LOCATIONS = Symbol();
|
|
80
86
|
const COMPILED_TOKEN_FACTORY = Symbol();
|
|
81
87
|
|
|
@@ -123,6 +129,7 @@ export type EvalScope = {
|
|
|
123
129
|
styleTransform?: StyleTransform | null;
|
|
124
130
|
sourcemapTrace?: 'style' | 'value';
|
|
125
131
|
runtimeMode?: CompilerRuntimeMode | null;
|
|
132
|
+
tokenNameFormat?: TokenNameFormat | null;
|
|
126
133
|
};
|
|
127
134
|
|
|
128
135
|
export function evaluateNode(
|
|
@@ -148,10 +155,10 @@ export function evaluateNode(
|
|
|
148
155
|
return evaluateTemplate(node, scope);
|
|
149
156
|
|
|
150
157
|
case 'Identifier':
|
|
151
|
-
return evaluateIdentifier(node, scope);
|
|
158
|
+
return referenceResult(evaluateIdentifier(node, scope), node, scope);
|
|
152
159
|
|
|
153
160
|
case 'MemberExpression':
|
|
154
|
-
return evaluateMember(node as BabelTypes.MemberExpression, scope);
|
|
161
|
+
return referenceResult(evaluateMember(node as BabelTypes.MemberExpression, scope), node, scope);
|
|
155
162
|
|
|
156
163
|
case 'ObjectExpression':
|
|
157
164
|
return evaluateObject(node as BabelTypes.ObjectExpression, scope);
|
|
@@ -160,7 +167,7 @@ export function evaluateNode(
|
|
|
160
167
|
return evaluateArray(node as BabelTypes.ArrayExpression, scope);
|
|
161
168
|
|
|
162
169
|
case 'CallExpression':
|
|
163
|
-
return evaluateCall(node as BabelTypes.CallExpression, scope);
|
|
170
|
+
return referenceCallResult(evaluateCall(node as BabelTypes.CallExpression, scope), node, scope);
|
|
164
171
|
|
|
165
172
|
case 'BinaryExpression':
|
|
166
173
|
return evaluateBinary(node as BabelTypes.BinaryExpression, scope);
|
|
@@ -679,7 +686,12 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
|
|
|
679
686
|
if (!value.ok) return value;
|
|
680
687
|
|
|
681
688
|
if (isStyleTokenData(value.value)) {
|
|
682
|
-
return evalOk(
|
|
689
|
+
return evalOk(
|
|
690
|
+
getTokenVar(
|
|
691
|
+
value.value,
|
|
692
|
+
scope.tokenNameFormat === undefined ? CSS_CONFIG.tokenNameFormat || null : scope.tokenNameFormat,
|
|
693
|
+
),
|
|
694
|
+
);
|
|
683
695
|
}
|
|
684
696
|
|
|
685
697
|
return evalOk(value.value);
|
|
@@ -740,7 +752,7 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
|
|
|
740
752
|
return evalOk(createCompiledTokenOverride(target, provide.value, node));
|
|
741
753
|
}
|
|
742
754
|
|
|
743
|
-
return evalOk(withRuntimeValue(node, target));
|
|
755
|
+
return referenceResult(evalOk(withRuntimeValue(node, target)), node, scope);
|
|
744
756
|
}
|
|
745
757
|
}
|
|
746
758
|
|
|
@@ -773,7 +785,7 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
|
|
|
773
785
|
const meta = scope.styleMetas?.get(node.callee.object.name);
|
|
774
786
|
const transformedFrames = transformKeyframes(
|
|
775
787
|
frames.value as KeyframesObject,
|
|
776
|
-
meta?.transform ?? scope.styleTransform ?? null,
|
|
788
|
+
(meta?.mode === 'StyleObject' ? meta.transform : null) ?? scope.styleTransform ?? null,
|
|
777
789
|
);
|
|
778
790
|
const format = CSS_EXTRA_CONFIG.namedRuleFormat.keyframes ?? null;
|
|
779
791
|
|
|
@@ -816,7 +828,10 @@ function evaluateCall(node: BabelTypes.CallExpression, scope: EvalScope): EvalRe
|
|
|
816
828
|
const value = evaluateNode(node.arguments[0] as BabelTypes.Node, scope);
|
|
817
829
|
if (!value.ok) return value;
|
|
818
830
|
|
|
819
|
-
|
|
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));
|
|
820
835
|
}
|
|
821
836
|
|
|
822
837
|
if (
|
|
@@ -941,6 +956,7 @@ function createCompiledTokenOverride(
|
|
|
941
956
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
942
957
|
[TOKEN_OVERRIDE]: true,
|
|
943
958
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
959
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
944
960
|
value: value.value,
|
|
945
961
|
ref: value,
|
|
946
962
|
});
|
|
@@ -950,6 +966,7 @@ function createCompiledTokenOverride(
|
|
|
950
966
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
951
967
|
[TOKEN_OVERRIDE]: true,
|
|
952
968
|
[TOKEN_NAME]: getStyleTokenName(token),
|
|
969
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
953
970
|
value,
|
|
954
971
|
ref: null,
|
|
955
972
|
});
|
|
@@ -1108,6 +1125,7 @@ function createCompiledValues(
|
|
|
1108
1125
|
stableId: string | undefined,
|
|
1109
1126
|
isNumber: boolean,
|
|
1110
1127
|
): CompiledTokenFactory {
|
|
1128
|
+
if (!values.length) throw new Error('[Style.values] NO_VALUES');
|
|
1111
1129
|
const tokens = new Map<unknown, StyleTokenData>();
|
|
1112
1130
|
const groupName = getStyleTokenNameFromId(stableId);
|
|
1113
1131
|
|
|
@@ -1138,12 +1156,12 @@ function parseCompiledValue(value: unknown, isNumber: boolean) {
|
|
|
1138
1156
|
if (!isNumber) return value;
|
|
1139
1157
|
|
|
1140
1158
|
const number = Number(value);
|
|
1141
|
-
if (!Number.isFinite(number))
|
|
1159
|
+
if (!Number.isFinite(number)) throw new Error(`[Style.values] INVALID_NUMBER_VALUE: ${String(value)}`);
|
|
1142
1160
|
|
|
1143
1161
|
return number;
|
|
1144
1162
|
}
|
|
1145
1163
|
|
|
1146
|
-
function isCompiledTokenFactory(value: unknown): value is CompiledTokenFactory {
|
|
1164
|
+
export function isCompiledTokenFactory(value: unknown): value is CompiledTokenFactory {
|
|
1147
1165
|
return !!value && typeof value === 'object' && (value as CompiledTokenFactory)[COMPILED_TOKEN_FACTORY] === true;
|
|
1148
1166
|
}
|
|
1149
1167
|
|
|
@@ -1224,9 +1242,18 @@ function withRuntimeValue<T extends StyleTokenData | StyleTokenOverride>(
|
|
|
1224
1242
|
runtimeValue: BabelTypes.Expression,
|
|
1225
1243
|
token: T,
|
|
1226
1244
|
): T {
|
|
1245
|
+
if (typeof token === 'function') {
|
|
1246
|
+
return new Proxy(token, {
|
|
1247
|
+
get(target, key) {
|
|
1248
|
+
if (key === COMPILED_RUNTIME_VALUE) return runtimeValue;
|
|
1249
|
+
return Reflect.get(target, key);
|
|
1250
|
+
},
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1227
1253
|
return Object.assign({}, token, {
|
|
1228
1254
|
[TOKEN_ID]: token[TOKEN_ID],
|
|
1229
1255
|
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
1256
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
1230
1257
|
[COMPILED_RUNTIME_VALUE]: runtimeValue,
|
|
1231
1258
|
});
|
|
1232
1259
|
}
|
|
@@ -1277,3 +1304,53 @@ function evaluateUnary(node: BabelTypes.UnaryExpression, scope: EvalScope): Eval
|
|
|
1277
1304
|
return evalFail(`Unsupported unary operator: ${node.operator}`);
|
|
1278
1305
|
}
|
|
1279
1306
|
}
|
|
1307
|
+
|
|
1308
|
+
function referenceResult(result: EvalResult, expression: BabelTypes.Expression, scope: EvalScope): EvalResult {
|
|
1309
|
+
if (!result.ok) return result;
|
|
1310
|
+
return evalOk(referenceValue(result.value, expression, scope));
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function referenceValue(value: unknown, expression: BabelTypes.Expression, scope: EvalScope, nested = false): unknown {
|
|
1314
|
+
if (isStyleTokenData(value) || isStyleTokenOverrideData(value)) {
|
|
1315
|
+
if (nested && (value as CompiledTokenReference)[COMPILED_TOKEN_REFERENCE]?.filePath === scope.filePath) {
|
|
1316
|
+
return value;
|
|
1317
|
+
}
|
|
1318
|
+
const reference = { expression, filePath: scope.filePath };
|
|
1319
|
+
if (typeof value === 'function') {
|
|
1320
|
+
return new Proxy(value, {
|
|
1321
|
+
get(target, key) {
|
|
1322
|
+
if (key === COMPILED_TOKEN_REFERENCE) return reference;
|
|
1323
|
+
return Reflect.get(target, key);
|
|
1324
|
+
},
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
return Object.assign(
|
|
1328
|
+
withRuntimeValue((value as CompiledRuntimeValue)[COMPILED_RUNTIME_VALUE] ?? expression, value),
|
|
1329
|
+
{
|
|
1330
|
+
[COMPILED_TOKEN_REFERENCE]: reference,
|
|
1331
|
+
},
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
if (!value || typeof value !== 'object' || isCompiledTokenFactory(value)) return value;
|
|
1335
|
+
// Only recurse through ordinary data records; compiled styles and other tagged data stay intact.
|
|
1336
|
+
if (Object.getOwnPropertySymbols(value).some((key) => key !== COMPILED_STYLE_OBJECT_LOCATIONS)) return value;
|
|
1337
|
+
const result = Object.defineProperties(Array.isArray(value) ? [] : {}, Object.getOwnPropertyDescriptors(value));
|
|
1338
|
+
for (const key of Object.keys(value)) {
|
|
1339
|
+
(result as Record<string, unknown>)[key] = referenceValue(
|
|
1340
|
+
(value as Record<string, unknown>)[key],
|
|
1341
|
+
BabelCore.types.memberExpression(expression, BabelCore.types.stringLiteral(key), true),
|
|
1342
|
+
scope,
|
|
1343
|
+
true,
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
return result;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
function referenceCallResult(result: EvalResult, node: BabelTypes.CallExpression, scope: EvalScope): EvalResult {
|
|
1350
|
+
// Factory calls are rewritten separately. Ordinary token/value calls retain their expression.
|
|
1351
|
+
const imp = node.callee.type === 'Identifier' ? scope.imports.get(node.callee.name) : undefined;
|
|
1352
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source)) return result;
|
|
1353
|
+
return result.ok && (isStyleTokenData(result.value) || isStyleTokenOverrideData(result.value))
|
|
1354
|
+
? referenceResult(result, node, scope)
|
|
1355
|
+
: result;
|
|
1356
|
+
}
|
|
@@ -245,10 +245,13 @@ function parseAndExtractModule(
|
|
|
245
245
|
|
|
246
246
|
if (stmt.source) {
|
|
247
247
|
imports.set(exported, { source: stmt.source.value, name: local });
|
|
248
|
+
rawBindings.set(exported, t.identifier(exported));
|
|
248
249
|
} else if (rawBindings.has(local)) {
|
|
249
250
|
rawBindings.set(exported, rawBindings.get(local)!);
|
|
250
251
|
} else if (bindings.has(local)) {
|
|
251
252
|
bindings.set(exported, bindings.get(local)!);
|
|
253
|
+
} else if (imports.has(local)) {
|
|
254
|
+
rawBindings.set(exported, t.identifier(local));
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
257
|
|
|
@@ -270,6 +273,7 @@ function parseAndExtractModule(
|
|
|
270
273
|
}
|
|
271
274
|
|
|
272
275
|
const scope: EvalScope = {
|
|
276
|
+
tokenNameFormat: options.css?.tokenNameFormat ?? null,
|
|
273
277
|
bindings,
|
|
274
278
|
imports,
|
|
275
279
|
styleNames,
|
|
@@ -35,8 +35,12 @@ import type {
|
|
|
35
35
|
RuntimeSlotOverrideItem,
|
|
36
36
|
RuntimeStyleItem,
|
|
37
37
|
} from '../../../../builder/data/state';
|
|
38
|
-
import {
|
|
39
|
-
|
|
38
|
+
import {
|
|
39
|
+
normalizeManualSelectors,
|
|
40
|
+
setGlobalSheetSelectorOptions,
|
|
41
|
+
setSheetSelectorOptions,
|
|
42
|
+
} from '../../../../builder/selector_override';
|
|
43
|
+
import { isSheetLayerOption, isStyleLayerEnabled, resolveSheetLayerOption } from '../../../../config/config/css';
|
|
40
44
|
import type { ClassNameFormat, TokenNameFormat, TransformClassNameFormat } from '../../../../config/types';
|
|
41
45
|
import type { Selector } from '../../../../selector/types';
|
|
42
46
|
import { importantValue, isStyleImportantValue } from '../../../../style/important';
|
|
@@ -376,10 +380,14 @@ function compileSheetChain(
|
|
|
376
380
|
const items: CompiledItem[] = [];
|
|
377
381
|
const rules: CssExtractRule[] = [];
|
|
378
382
|
const hasOptions = chain.baseArgs.length === 2;
|
|
379
|
-
const sheetOptions = hasOptions
|
|
380
|
-
? evaluateCreateSheetOptions(chain.baseArgs[0], scope)
|
|
383
|
+
const sheetOptions: (CreateSheetOptions & { global?: boolean; order?: number; }) | null = hasOptions
|
|
384
|
+
? evaluateCreateSheetOptions(chain.baseArgs[0], scope, chain.global)
|
|
381
385
|
: {};
|
|
382
386
|
if (!sheetOptions) return null;
|
|
387
|
+
if (chain.global) {
|
|
388
|
+
if (sheetOptions.specificity !== undefined) throw new Error('createGlobalSheet does not support specificity');
|
|
389
|
+
sheetOptions.global = true;
|
|
390
|
+
}
|
|
383
391
|
|
|
384
392
|
const sheetItems = chain.baseArgs[hasOptions ? 1 : 0];
|
|
385
393
|
|
|
@@ -390,12 +398,15 @@ function compileSheetChain(
|
|
|
390
398
|
return null;
|
|
391
399
|
}
|
|
392
400
|
|
|
393
|
-
const sheetLayer = sheetOptions.layer ??
|
|
401
|
+
const sheetLayer = sheetOptions.layer ?? false;
|
|
394
402
|
for (let i = 0, len = rules.length; i < len; i++) {
|
|
395
403
|
rules[i].layer = resolveSheetLayerOption(
|
|
396
404
|
sheetLayer,
|
|
397
405
|
options.css?.layerNamespace ?? DEFAULT_CONFIG.layerNamespace ?? '',
|
|
406
|
+
isStyleLayerEnabled(options.css?.layer ?? DEFAULT_CONFIG.layer),
|
|
398
407
|
);
|
|
408
|
+
rules[i].sheet = true;
|
|
409
|
+
if (chain.global) rules[i].globalSheet = { id: chain.sheetId ?? fileId, order: sheetOptions.order ?? 0 };
|
|
399
410
|
}
|
|
400
411
|
|
|
401
412
|
return { type: 'sheet', items, rules, sheetOptions };
|
|
@@ -404,19 +415,26 @@ function compileSheetChain(
|
|
|
404
415
|
function evaluateCreateSheetOptions(
|
|
405
416
|
node: BabelTypes.Node,
|
|
406
417
|
scope: EvalScope,
|
|
407
|
-
|
|
418
|
+
global = false,
|
|
419
|
+
): (CreateSheetOptions & { order?: number; }) | null {
|
|
408
420
|
const result = evaluateNode(node, scope);
|
|
409
421
|
if (!result.ok || !result.value || typeof result.value !== 'object' || Array.isArray(result.value)) return null;
|
|
410
|
-
|
|
411
422
|
const value = result.value as Record<string, unknown>;
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
423
|
+
if (hasGlobalRuntimeValue(value)) return null;
|
|
424
|
+
const allowed = global ? ['layer', 'order'] : ['layer', 'specificity'];
|
|
425
|
+
if (Object.keys(value).some((key) => !allowed.includes(key))) {
|
|
426
|
+
throw new Error(
|
|
427
|
+
global ? 'createGlobalSheet only supports layer and order' : 'createSheet only supports layer and specificity',
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
if (!isSheetLayerOption(value.layer)) throw new Error('invalid sheet layer');
|
|
431
|
+
if (value.specificity !== undefined && (!Number.isInteger(value.specificity) || (value.specificity as number) < 0)) {
|
|
432
|
+
throw new Error('specificity must be a non-negative integer');
|
|
433
|
+
}
|
|
434
|
+
if (value.order !== undefined && (typeof value.order !== 'number' || !Number.isFinite(value.order))) {
|
|
435
|
+
throw new Error('order must be a finite number');
|
|
436
|
+
}
|
|
437
|
+
return value as CreateSheetOptions & { order?: number; };
|
|
420
438
|
}
|
|
421
439
|
|
|
422
440
|
function compileSheetItemsArg(
|
|
@@ -427,7 +445,7 @@ function compileSheetItemsArg(
|
|
|
427
445
|
options: CompilerOptions,
|
|
428
446
|
items: CompiledItem[],
|
|
429
447
|
rules: CssExtractRule[],
|
|
430
|
-
sheetOptions: CreateSheetOptions,
|
|
448
|
+
sheetOptions: CreateSheetOptions & { global?: boolean; order?: number; },
|
|
431
449
|
): boolean {
|
|
432
450
|
if (node.type === 'ArrayExpression') {
|
|
433
451
|
for (const element of node.elements) {
|
|
@@ -440,7 +458,9 @@ function compileSheetItemsArg(
|
|
|
440
458
|
}
|
|
441
459
|
|
|
442
460
|
const tokenOverride = evaluateNode(node, scope);
|
|
461
|
+
if (tokenOverride.ok && !tokenOverride.value) return true;
|
|
443
462
|
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
463
|
+
if (sheetOptions.global) throw new Error('createGlobalSheet requires token overrides inside an explicit selector');
|
|
444
464
|
addCompiledTokenItem(
|
|
445
465
|
getStyleTokenId(tokenOverride.value),
|
|
446
466
|
tokenOverride.value,
|
|
@@ -455,6 +475,9 @@ function compileSheetItemsArg(
|
|
|
455
475
|
const item = tokenOverride.value[i];
|
|
456
476
|
if (!item) continue;
|
|
457
477
|
if (!isStyleTokenOverrideData(item)) return false;
|
|
478
|
+
if (sheetOptions.global) {
|
|
479
|
+
throw new Error('createGlobalSheet requires token overrides inside an explicit selector');
|
|
480
|
+
}
|
|
458
481
|
|
|
459
482
|
addCompiledTokenItem(
|
|
460
483
|
getStyleTokenId(item),
|
|
@@ -505,10 +528,22 @@ function compileSelectorOverrideChain(
|
|
|
505
528
|
options: CompilerOptions,
|
|
506
529
|
items: CompiledItem[],
|
|
507
530
|
rules: CssExtractRule[],
|
|
508
|
-
sheetOptions: CreateSheetOptions,
|
|
531
|
+
sheetOptions: CreateSheetOptions & { global?: boolean; order?: number; },
|
|
509
532
|
): boolean {
|
|
510
533
|
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
511
534
|
|
|
535
|
+
// Unlike attached sheets, globals have no runtime replacement to supply dynamic values.
|
|
536
|
+
// Only erase the call when every selector/style argument is statically evaluable.
|
|
537
|
+
if (sheetOptions.global) {
|
|
538
|
+
const args = [...chain.baseArgs, ...chain.methods.flatMap((method) => method.args)];
|
|
539
|
+
if (
|
|
540
|
+
args.some((arg) => {
|
|
541
|
+
const result = evaluateNode(arg, scope);
|
|
542
|
+
return !result.ok || hasGlobalRuntimeValue(result.value);
|
|
543
|
+
})
|
|
544
|
+
) return false;
|
|
545
|
+
}
|
|
546
|
+
|
|
512
547
|
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
513
548
|
if (!selectorArg.ok) return false;
|
|
514
549
|
|
|
@@ -531,7 +566,9 @@ function compileSelectorOverrideChain(
|
|
|
531
566
|
options,
|
|
532
567
|
items,
|
|
533
568
|
rules,
|
|
534
|
-
|
|
569
|
+
sheetOptions.global
|
|
570
|
+
? setGlobalSheetSelectorOptions(manualSelectors[i], sheetOptions)
|
|
571
|
+
: setSheetSelectorOptions(manualSelectors[i], sheetOptions),
|
|
535
572
|
)
|
|
536
573
|
) {
|
|
537
574
|
return false;
|
|
@@ -1173,7 +1210,7 @@ function decorateClassNameValue(
|
|
|
1173
1210
|
if (isClassNameValue(value)) return value;
|
|
1174
1211
|
|
|
1175
1212
|
if (isStyleImportantValue(value)) {
|
|
1176
|
-
return importantValue(decorateClassNameValue(value.value, className));
|
|
1213
|
+
return importantValue(decorateClassNameValue(value.value, className), value.native);
|
|
1177
1214
|
}
|
|
1178
1215
|
|
|
1179
1216
|
if (isStyleWeightValue(value)) {
|
|
@@ -2751,6 +2788,7 @@ function addSlotOverrideDataItems(
|
|
|
2751
2788
|
property: overrideItem.property,
|
|
2752
2789
|
weight: overrideItem.weight,
|
|
2753
2790
|
important: overrideItem.important,
|
|
2791
|
+
importantNative: overrideItem.importantNative,
|
|
2754
2792
|
value: overrideItem.value,
|
|
2755
2793
|
variable: overrideItem.variable,
|
|
2756
2794
|
token: overrideItem.token,
|
|
@@ -2854,6 +2892,7 @@ function addRuntimeScopeItem(
|
|
|
2854
2892
|
sourceItem.selector,
|
|
2855
2893
|
itemParentSelector,
|
|
2856
2894
|
itemAtRules,
|
|
2895
|
+
sourceItem.importantNative,
|
|
2857
2896
|
);
|
|
2858
2897
|
|
|
2859
2898
|
const className = getAtomicClassName(
|
|
@@ -2872,6 +2911,7 @@ function addRuntimeScopeItem(
|
|
|
2872
2911
|
cssConfig.transformClassNameFormat,
|
|
2873
2912
|
cssConfig.sheetClassNameFormat,
|
|
2874
2913
|
cssConfig.hashLength,
|
|
2914
|
+
sourceItem.importantNative,
|
|
2875
2915
|
);
|
|
2876
2916
|
|
|
2877
2917
|
const item: CompiledItem = createCompiledItem(
|
|
@@ -2910,6 +2950,7 @@ function addRuntimeScopeItem(
|
|
|
2910
2950
|
css,
|
|
2911
2951
|
priority: layerPriority,
|
|
2912
2952
|
important,
|
|
2953
|
+
importantNative: sourceItem.importantNative,
|
|
2913
2954
|
trace: traceCallsite
|
|
2914
2955
|
? {
|
|
2915
2956
|
filePath: traceCallsite.filePath ?? fileId,
|
|
@@ -3094,6 +3135,7 @@ function addRuntimeStyleItem(
|
|
|
3094
3135
|
itemSelector,
|
|
3095
3136
|
parentSelector,
|
|
3096
3137
|
itemAtRules,
|
|
3138
|
+
sourceItem.importantNative,
|
|
3097
3139
|
);
|
|
3098
3140
|
|
|
3099
3141
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
@@ -3114,6 +3156,7 @@ function addRuntimeStyleItem(
|
|
|
3114
3156
|
cssConfig.transformClassNameFormat,
|
|
3115
3157
|
cssConfig.sheetClassNameFormat,
|
|
3116
3158
|
cssConfig.hashLength,
|
|
3159
|
+
sourceItem.importantNative,
|
|
3117
3160
|
);
|
|
3118
3161
|
|
|
3119
3162
|
const item: CompiledItem = createCompiledItem(
|
|
@@ -3158,6 +3201,7 @@ function addRuntimeStyleItem(
|
|
|
3158
3201
|
css,
|
|
3159
3202
|
priority: layerPriority,
|
|
3160
3203
|
important,
|
|
3204
|
+
importantNative: sourceItem.importantNative,
|
|
3161
3205
|
trace: traceCallsite
|
|
3162
3206
|
? {
|
|
3163
3207
|
filePath: traceCallsite.filePath ?? fileId,
|
|
@@ -3271,10 +3315,11 @@ function addStyleItems(
|
|
|
3271
3315
|
|
|
3272
3316
|
let weight: number | null = null;
|
|
3273
3317
|
let important = false;
|
|
3318
|
+
let importantNative = false;
|
|
3274
3319
|
let value: unknown = rawValue;
|
|
3275
3320
|
let transformClassName: string | null = null;
|
|
3276
3321
|
|
|
3277
|
-
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
3322
|
+
[value, weight, important, importantNative] = unwrapStaticStyleValue(value);
|
|
3278
3323
|
|
|
3279
3324
|
if (isClassNameValue(value)) {
|
|
3280
3325
|
transformClassName = value.className;
|
|
@@ -3336,6 +3381,7 @@ function addStyleItems(
|
|
|
3336
3381
|
selector,
|
|
3337
3382
|
parentSelector,
|
|
3338
3383
|
atRules,
|
|
3384
|
+
importantNative,
|
|
3339
3385
|
);
|
|
3340
3386
|
|
|
3341
3387
|
const className = getAtomicClassName(
|
|
@@ -3354,6 +3400,7 @@ function addStyleItems(
|
|
|
3354
3400
|
cssConfig.transformClassNameFormat,
|
|
3355
3401
|
cssConfig.sheetClassNameFormat,
|
|
3356
3402
|
cssConfig.hashLength,
|
|
3403
|
+
importantNative,
|
|
3357
3404
|
);
|
|
3358
3405
|
|
|
3359
3406
|
const item: CompiledItem = createCompiledItem(
|
|
@@ -3422,6 +3469,7 @@ function addStyleItems(
|
|
|
3422
3469
|
css,
|
|
3423
3470
|
priority: layerPriority,
|
|
3424
3471
|
important,
|
|
3472
|
+
importantNative,
|
|
3425
3473
|
trace: propertyCallsite
|
|
3426
3474
|
? {
|
|
3427
3475
|
filePath: propertyCallsite.filePath ?? fileId,
|
|
@@ -3454,13 +3502,17 @@ function addStyleItems(
|
|
|
3454
3502
|
return true;
|
|
3455
3503
|
}
|
|
3456
3504
|
|
|
3457
|
-
function unwrapStaticStyleValue(
|
|
3505
|
+
function unwrapStaticStyleValue(
|
|
3506
|
+
value: unknown,
|
|
3507
|
+
): [value: unknown, weight: number | null, important: boolean, native: boolean] {
|
|
3458
3508
|
let weight: number | null = null;
|
|
3459
3509
|
let important = false;
|
|
3510
|
+
let native = false;
|
|
3460
3511
|
|
|
3461
3512
|
while (true) {
|
|
3462
3513
|
if (isStyleImportantValue(value)) {
|
|
3463
3514
|
important = true;
|
|
3515
|
+
native ||= value.native === true;
|
|
3464
3516
|
value = value.value;
|
|
3465
3517
|
continue;
|
|
3466
3518
|
}
|
|
@@ -3474,7 +3526,7 @@ function unwrapStaticStyleValue(value: unknown): [value: unknown, weight: number
|
|
|
3474
3526
|
break;
|
|
3475
3527
|
}
|
|
3476
3528
|
|
|
3477
|
-
return [value, weight, important];
|
|
3529
|
+
return [value, weight, important, native];
|
|
3478
3530
|
}
|
|
3479
3531
|
|
|
3480
3532
|
function throwIfRequiredStaticStyleValue(result: EvalResult) {
|
|
@@ -3552,3 +3604,11 @@ function getCompiledRuntimeValue(value: unknown): BabelTypes.Expression | undefi
|
|
|
3552
3604
|
if (!value || typeof value !== 'object') return undefined;
|
|
3553
3605
|
return (value as CompiledRuntimeValue)[COMPILED_RUNTIME_VALUE];
|
|
3554
3606
|
}
|
|
3607
|
+
|
|
3608
|
+
function hasGlobalRuntimeValue(value: unknown, seen = new Set<object>()): boolean {
|
|
3609
|
+
if (!value || typeof value !== 'object' || isStyleTokenData(value) || isAtRuleRef(value)) return false;
|
|
3610
|
+
if (getCompiledRuntimeValue(value)) return true;
|
|
3611
|
+
if (seen.has(value)) return false;
|
|
3612
|
+
seen.add(value);
|
|
3613
|
+
return Object.values(value).some((item) => hasGlobalRuntimeValue(item, seen));
|
|
3614
|
+
}
|