@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.4
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 +13 -0
- package/README.md +1 -1
- package/atomic/className.ts +3 -9
- package/atomic/debug/className/className.ts +0 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +2 -2
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +41 -2
- package/atomic/token.ts +4 -3
- package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/builder/data/const.ts +1 -1
- package/builder/data/merge/style.ts +1 -1
- package/builder/extract/token.ts +30 -14
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/compiler/transform/debug/plugin.ts +79 -1
- package/compiler/transform/evaluator/evaluator.ts +74 -26
- package/compiler/transform/extract/chain/chain.ts +1 -1
- package/compiler/transform/extract/utils/replacement.ts +6 -1
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/config/build.ts +1 -8
- package/config/config/debug.ts +11 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/{className-CKo4TxuT.js → className-Do2Crx4b.js} +2 -3
- package/dist/{className-CKo4TxuT.js.map → className-Do2Crx4b.js.map} +1 -1
- package/dist/{style-91J0B5ef.js → combine-C9vjpKCs.js} +45 -304
- package/dist/combine-C9vjpKCs.js.map +1 -0
- package/dist/combineStyle-DwAhsOmS.js +26 -0
- package/dist/combineStyle-DwAhsOmS.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-D5v5tJXI.mjs → compiler-CE0ZgkdH.mjs} +231 -84
- package/dist/compiler-CE0ZgkdH.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BE5D5x2N.js +2 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/{config-FIfi5aJ8.js → config-CduqubI8.js} +8 -6
- package/dist/config-CduqubI8.js.map +1 -0
- package/dist/config-lJNLh7eM.js +6 -0
- package/dist/config-lJNLh7eM.js.map +1 -0
- package/dist/config-oKOjOTWi.js +7 -0
- package/dist/{config-OXHoDUIo.js.map → config-oKOjOTWi.js.map} +1 -1
- package/dist/{css-DcuJ_jSH.js → css-BewrRz3_.js} +3 -3
- package/dist/{css-DcuJ_jSH.js.map → css-BewrRz3_.js.map} +1 -1
- package/dist/{css-dPoZJDQH.js → css-CiTI58yl.js} +291 -4
- package/dist/css-CiTI58yl.js.map +1 -0
- package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
- package/dist/css-GtUPEO9U.js.map +1 -0
- package/dist/{css-oOt6ZR54.js → css-Rc7ILf-3.js} +8 -9
- package/dist/{css-oOt6ZR54.js.map → css-Rc7ILf-3.js.map} +1 -1
- package/dist/css.js +1 -1
- package/dist/{css-CELBp6Gu.js → cssIdent-BsyUXNNk.js} +3 -23
- package/dist/cssIdent-BsyUXNNk.js.map +1 -0
- package/dist/cssVar-DGgQ2GIK.js +92 -0
- package/dist/cssVar-DGgQ2GIK.js.map +1 -0
- package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
- package/dist/{css_extra-DQdCrYoC.js → css_extra-DYtS3g6Z.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-DYtS3g6Z.js.map} +1 -1
- package/dist/{data-CeYstKMP.js → data-D7NFt4JG.js} +205 -10
- package/dist/data-D7NFt4JG.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-Cvpo5cVu.js} +4 -3
- package/dist/{debug-D96KGgpH.js.map → debug-Cvpo5cVu.js.map} +1 -1
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-fOtWB5K3.js → dev-DdRWa6dJ.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-DdRWa6dJ.js.map} +1 -1
- package/dist/{dev-p8tW7X-A.js → dev-px0_6TNq.js} +4 -4
- package/dist/{dev-p8tW7X-A.js.map → dev-px0_6TNq.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-CvqqIb7J.js → elementMarker-ng0y3fN0.js} +8 -8
- package/dist/{elementMarker-CvqqIb7J.js.map → elementMarker-ng0y3fN0.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- 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 -12
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod/extract.js +2 -2
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +5 -4
- package/dist/entry/prod.js +40 -11
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +4 -4
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +274 -68
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +5 -4
- package/dist/entry/rsc-prod.js +16 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/extract-B-Vs88ME.js +3 -0
- package/dist/{extract-CzWJeQi8.js → extract-CM8Fk2eK.js} +24 -15
- package/dist/{extract-CzWJeQi8.js.map → extract-CM8Fk2eK.js.map} +1 -1
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-CrNVjAoJ.js} +29 -8
- package/dist/getClassName-CrNVjAoJ.js.map +1 -0
- package/dist/{global-Cul1dX8k.js → global-CZBlA9E7.js} +3 -3
- package/dist/{global-Cul1dX8k.js.map → global-CZBlA9E7.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BfeJDf5U.js} +13 -4
- package/dist/hash-BfeJDf5U.js.map +1 -0
- package/dist/index.js +9 -10
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-Ba-XV33u.js → jsx-BY1iFewe.js} +3 -3
- package/dist/{jsx-Ba-XV33u.js.map → jsx-BY1iFewe.js.map} +1 -1
- package/dist/{jsx-A4cK517J.js → jsx-DL-DEAz8.js} +8 -7
- package/dist/{jsx-A4cK517J.js.map → jsx-DL-DEAz8.js.map} +1 -1
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-aAhNYDeS.js} +2 -2
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-aAhNYDeS.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-C6i1bWlu.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-C6i1bWlu.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-D7Y5up6H.js} +2 -2
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-D7Y5up6H.js.map} +1 -1
- package/dist/{layer-CbQzwZF-.js → layer-BSxAr-hy.js} +4 -4
- package/dist/{layer-CbQzwZF-.js.map → layer-BSxAr-hy.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-BmYS_Rju.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-BmYS_Rju.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BIS_c7BJ.mjs} +2 -2
- package/dist/{misc-DFBKJGLT.mjs.map → misc-BIS_c7BJ.mjs.map} +1 -1
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-CN_yhhik.js} +8 -6
- package/dist/namedTokens-CN_yhhik.js.map +1 -0
- package/dist/plugin/farm/index.mjs +2 -2
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/optimizer.cjs +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- 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 +1 -1
- package/dist/plugin/vite/index.mjs +3 -3
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +8 -5
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{property-CF6JgpTq.js → property-BuLbzviK.js} +2 -2
- package/dist/{property-CF6JgpTq.js.map → property-BuLbzviK.js.map} +1 -1
- package/dist/{registry-CiwvMfx8.mjs → registry-IaXmLQzA.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-IaXmLQzA.mjs.map} +1 -1
- package/dist/{rules-DlXcch7-.js → rules-CxVzovt-.js} +60 -23
- package/dist/rules-CxVzovt-.js.map +1 -0
- package/dist/selector-A-mRmMnI.js +64 -0
- package/dist/selector-A-mRmMnI.js.map +1 -0
- package/dist/server.js +12 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-CaJuvw03.cjs} +231 -84
- package/dist/shared-CaJuvw03.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-DdPTZ0O3.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-DdPTZ0O3.mjs.map} +1 -1
- package/dist/sheet-BWBzuy4D.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BWBzuy4D.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-B3oCK9vC.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-B3oCK9vC.mjs.map} +1 -1
- package/dist/{style-DFFK06Of.js → style-CGaJndOl.js} +102 -54
- package/dist/style-CGaJndOl.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → style-DDxjKdX0.js} +356 -39
- package/dist/style-DDxjKdX0.js.map +1 -0
- package/dist/style-S7LTQbRu.js +5 -0
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-0fARJlZV.js} +6 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-0fARJlZV.js.map} +1 -1
- package/dist/{styleStore-ydQcDBD4.js → styleStore-CajcAEPO.js} +101 -223
- package/dist/styleStore-CajcAEPO.js.map +1 -0
- package/dist/symbols-Cp4ymzKF.js +14 -0
- package/dist/symbols-Cp4ymzKF.js.map +1 -0
- package/dist/token-D-S-4_mN.js +138 -0
- package/dist/token-D-S-4_mN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-CFnhyCVf.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-CFnhyCVf.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-ZtgeY-8s.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-ZtgeY-8s.js.map} +1 -1
- package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
- package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
- package/dist/{utils-D2fygyTm.mjs → utils-B5Xqf1lV.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-B5Xqf1lV.mjs.map} +1 -1
- package/dist/{utils-hoYnMiA7.js → utils-B_VhPBHH.js} +4 -4
- package/dist/{utils-hoYnMiA7.js.map → utils-B_VhPBHH.js.map} +1 -1
- package/dist/{utils-Bmw655wa.js → utils-CDUaX81o.js} +3 -3
- package/dist/{utils-Bmw655wa.js.map → utils-CDUaX81o.js.map} +1 -1
- package/dist/{utils-DTXCTUlS.mjs → utils-DaAiEEIG.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DaAiEEIG.mjs.map} +1 -1
- package/dist/{utils-DVFxZnVC.js → utils-DzydRwYo.js} +65 -49
- package/dist/utils-DzydRwYo.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/value-C0JRsyax.js +64 -0
- package/dist/value-C0JRsyax.js.map +1 -0
- package/dist/{value-DvFkGBy2.js → value-D08AocUs.js} +96 -72
- package/dist/value-D08AocUs.js.map +1 -0
- package/dist/{valueRef-CsLVJwjA.js → valueRef-M3E1oza7.js} +2 -2
- package/dist/{valueRef-CsLVJwjA.js.map → valueRef-M3E1oza7.js.map} +1 -1
- package/dist/{webpack-BOU7_xld.mjs → webpack-CHydnRXB.mjs} +5 -5
- package/dist/{webpack-BOU7_xld.mjs.map → webpack-CHydnRXB.mjs.map} +1 -1
- package/dist/{withTokens-LRidu3Vc.js → withTokens-DAzUIPvA.js} +2 -2
- package/dist/{withTokens-LRidu3Vc.js.map → withTokens-DAzUIPvA.js.map} +1 -1
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +3 -1
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +9 -7
- package/package.json +1 -1
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/core/cache/combine.ts +44 -25
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +2 -2
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +3 -2
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/extract/combineStyle.ts +37 -0
- package/runtime/extract/getClassName.ts +5 -11
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/style/style.ts +2 -1
- package/style/style.ts +1 -1
- package/style/theme.ts +0 -1
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +1 -1
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/className-ZJ5pBA-o.js +0 -263
- package/dist/className-ZJ5pBA-o.js.map +0 -1
- package/dist/compiler-D5v5tJXI.mjs.map +0 -1
- package/dist/config-BEvP7108.js.map +0 -1
- package/dist/config-B_cbG3S6.js +0 -1
- package/dist/config-FIfi5aJ8.js.map +0 -1
- package/dist/config-OXHoDUIo.js +0 -6
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/rules-DlXcch7-.js.map +0 -1
- package/dist/runtime-BKChZZ2-.js.map +0 -1
- package/dist/shared-yDD0nfm1.cjs.map +0 -1
- package/dist/sheet-B-uJfHRY.js +0 -7
- package/dist/style-91J0B5ef.js.map +0 -1
- package/dist/style-Bw5ka-Nq.js.map +0 -1
- package/dist/style-DFFK06Of.js.map +0 -1
- package/dist/style-pz8e5To1.js +0 -5
- package/dist/styleStore-ydQcDBD4.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-DTOyFLmp.js +0 -58
- package/dist/token-DTOyFLmp.js.map +0 -1
- package/dist/token-DT_sCPtm.js +0 -298
- package/dist/token-DT_sCPtm.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { setBuildConfig } from '../../config/build';
|
|
1
|
+
import { type BuildConfig, setBuildConfig } from '../../config/build';
|
|
2
|
+
import { setBuildDebugClassName } from '../../config/config/debug';
|
|
2
3
|
import { readEntryJsonDefine } from './utils';
|
|
3
4
|
|
|
4
5
|
declare const FLUENTIC_STYLE_BUILD_CONFIG: string;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{ hoist: true, css: {} },
|
|
11
|
-
),
|
|
7
|
+
const buildConfig = readEntryJsonDefine<BuildConfig>(
|
|
8
|
+
'FLUENTIC_STYLE_BUILD_CONFIG',
|
|
9
|
+
() => FLUENTIC_STYLE_BUILD_CONFIG,
|
|
10
|
+
{ hoist: true, css: {} } satisfies BuildConfig,
|
|
12
11
|
);
|
|
12
|
+
|
|
13
|
+
setBuildConfig(buildConfig);
|
|
14
|
+
setBuildDebugClassName(buildConfig.css?.debugClassName, false);
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
import { EXTRACTED_CSS_MARKER, transformCssOutput } from '../../utils';
|
|
2
3
|
import { replaceCssMarker } from '../../utils/cssMarker';
|
|
3
4
|
import { ensureParcelSidecarStarted, getParcelExtractedCss, getParcelState, Optimizer } from './shared';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { TOKEN_ID, TOKEN_OVERRIDE } from '../../../builder/token/symbols';
|
|
1
2
|
import { getNamedToken } from '../../../dialect';
|
|
2
|
-
import { isStyleTokenData } from '../../../style/token';
|
|
3
3
|
import { styleTransform } from '../../../style/transform';
|
|
4
4
|
import type { CSSProperties } from '../../../style/types';
|
|
5
5
|
import { defaultTailwindTheme } from '../theme';
|
|
@@ -372,7 +372,7 @@ function mapUtility(property: string, values: Record<string, unknown>): UtilityR
|
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
function resolveScale(scale: TailwindScale | undefined, value: unknown) {
|
|
375
|
-
if (!scale ||
|
|
375
|
+
if (!scale || isTailwindStyleTokenData(value)) return value;
|
|
376
376
|
if (Array.isArray(scale)) return resolveScales(scale, value);
|
|
377
377
|
|
|
378
378
|
const key = getScaleRef(value);
|
|
@@ -388,7 +388,7 @@ function resolveScale(scale: TailwindScale | undefined, value: unknown) {
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
function resolveScales(scales: (TailwindScale | undefined)[], value: unknown) {
|
|
391
|
-
if (
|
|
391
|
+
if (isTailwindStyleTokenData(value)) return value;
|
|
392
392
|
|
|
393
393
|
const key = getScaleRef(value);
|
|
394
394
|
if (key === null) return value;
|
|
@@ -407,6 +407,12 @@ function resolveScales(scales: (TailwindScale | undefined)[], value: unknown) {
|
|
|
407
407
|
return value;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
function isTailwindStyleTokenData(value: unknown) {
|
|
411
|
+
return !!value &&
|
|
412
|
+
typeof (value as { [TOKEN_ID]?: unknown; })[TOKEN_ID] === 'string' &&
|
|
413
|
+
(value as { [TOKEN_OVERRIDE]?: true; })[TOKEN_OVERRIDE] !== true;
|
|
414
|
+
}
|
|
415
|
+
|
|
410
416
|
function getScaleValue(scale: TailwindScale, key: string) {
|
|
411
417
|
if (key in scale) return { found: true, value: scale[key] };
|
|
412
418
|
|
|
@@ -4,8 +4,8 @@ import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
|
4
4
|
import type { Falsy, StyleItem } from '../../types';
|
|
5
5
|
import { type CombinedStyle, getCombinedStyleScopes, getCombinedStyleStyles, isCombinedStyle } from '../combinedStyle';
|
|
6
6
|
import { createCombinedStyleTokenWrapper, getStyleTokenValues } from './item';
|
|
7
|
-
import {
|
|
8
|
-
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
7
|
+
import { type CombinedStylePool, createCombinedStylePool, getCachedTokenWrapper } from './pool';
|
|
8
|
+
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues, type TokenValueResolver } from './tokenValues';
|
|
9
9
|
|
|
10
10
|
export type CombinedStyleArg<T extends object> =
|
|
11
11
|
| Falsy
|
|
@@ -19,30 +19,48 @@ type NormalizedStyleItems = {
|
|
|
19
19
|
tokens: StyleTokenValues | null;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
export function createCombinedStyleGetter(
|
|
23
|
+
resolver: TokenValueResolver,
|
|
24
|
+
) {
|
|
25
|
+
let configuredPool: CombinedStylePool | null = null;
|
|
26
|
+
let configuredPoolTTL = -1;
|
|
27
|
+
|
|
28
|
+
return function getConfiguredCombinedStyle<T extends object>(
|
|
29
|
+
styles: T,
|
|
30
|
+
args: readonly CombinedStyleArg<T>[],
|
|
31
|
+
): CombinedStyle<T> {
|
|
32
|
+
const ttl = RUNTIME_CONFIG.runtimeCacheTTL;
|
|
33
|
+
|
|
34
|
+
if (
|
|
35
|
+
!configuredPool ||
|
|
36
|
+
configuredPoolTTL !== ttl
|
|
37
|
+
) {
|
|
38
|
+
configuredPool = createCombinedStylePool(resolver, ttl);
|
|
39
|
+
configuredPoolTTL = ttl;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const normalized = normalizeStyleItems(styles, args, resolver);
|
|
43
|
+
const result = configuredPool.get(
|
|
44
|
+
styles,
|
|
45
|
+
normalized.inheritedScopes,
|
|
46
|
+
normalized.items,
|
|
47
|
+
normalized.tokens,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return result.tokens
|
|
51
|
+
? getCachedTokenWrapper(
|
|
52
|
+
result.tokenCache,
|
|
53
|
+
result.tokens,
|
|
54
|
+
() => createCombinedStyleTokenWrapper(result.style, result.tokens!),
|
|
55
|
+
)
|
|
56
|
+
: result.style;
|
|
57
|
+
};
|
|
41
58
|
}
|
|
42
59
|
|
|
43
60
|
function normalizeStyleItems<T extends object>(
|
|
44
61
|
styles: T,
|
|
45
62
|
args: readonly CombinedStyleArg<T>[],
|
|
63
|
+
resolver: TokenValueResolver,
|
|
46
64
|
): NormalizedStyleItems {
|
|
47
65
|
const result: NormalizedStyleItems = {
|
|
48
66
|
inheritedScopes: [],
|
|
@@ -51,7 +69,7 @@ function normalizeStyleItems<T extends object>(
|
|
|
51
69
|
};
|
|
52
70
|
|
|
53
71
|
for (let i = 0, len = args.length; i < len; i++) {
|
|
54
|
-
collectStyleArg(styles, args[i], result);
|
|
72
|
+
collectStyleArg(styles, args[i], result, resolver);
|
|
55
73
|
}
|
|
56
74
|
|
|
57
75
|
return result;
|
|
@@ -61,12 +79,13 @@ function collectStyleArg<T extends object>(
|
|
|
61
79
|
styles: T,
|
|
62
80
|
arg: CombinedStyleArg<T>,
|
|
63
81
|
result: NormalizedStyleItems,
|
|
82
|
+
resolver: TokenValueResolver,
|
|
64
83
|
) {
|
|
65
84
|
if (!arg) return;
|
|
66
85
|
|
|
67
86
|
if (Array.isArray(arg)) {
|
|
68
87
|
for (let i = 0, len = arg.length; i < len; i++) {
|
|
69
|
-
collectStyleArg(styles, arg[i], result);
|
|
88
|
+
collectStyleArg(styles, arg[i], result, resolver);
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
return;
|
|
@@ -75,9 +94,9 @@ function collectStyleArg<T extends object>(
|
|
|
75
94
|
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(arg)) {
|
|
76
95
|
const bound = getExtractedTokenBoundData(arg);
|
|
77
96
|
|
|
78
|
-
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens);
|
|
97
|
+
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
|
|
79
98
|
|
|
80
|
-
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result);
|
|
99
|
+
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result, resolver);
|
|
81
100
|
return;
|
|
82
101
|
}
|
|
83
102
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { CombinedStyleArg } from './combine';
|
|
2
|
+
export { getCombinedStyle } from './combineRuntime';
|
|
2
3
|
export type { ResolvedStyleItem } from './item';
|
|
3
4
|
export { type CombinedStylePool, createCombinedStylePool } from './pool';
|
|
4
5
|
export { type ResolvedStylePropRuntime, resolveStyleProp } from './prop';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getScopeClassName } from '../../../atomic/
|
|
1
|
+
import { getScopeClassName } from '../../../atomic/scope';
|
|
2
2
|
import { BUILDER_STATE, BUILDER_TYPE_SCOPE, BUILDER_TYPE_SLOT } from '../../../builder/data/const';
|
|
3
3
|
import type { ScopeTargetData, SlotData, StyleData } from '../../../builder/data/data';
|
|
4
4
|
import {
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
isStyleData,
|
|
10
10
|
} from '../../../builder/data/is';
|
|
11
11
|
import type { StateItem } from '../../../builder/data/state';
|
|
12
|
+
import { isStyleTokenOverrideData } from '../../../builder/token/data';
|
|
12
13
|
import { CSS_CONFIG } from '../../../config/config/css';
|
|
13
|
-
import { isStyleTokenOverrideData } from '../../../style/token';
|
|
14
14
|
import { globalData } from '../../../utils/global';
|
|
15
15
|
import {
|
|
16
16
|
type CombinedStyle,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
2
2
|
import type { ScopeData, ScopeTargetData } from '../../../builder/data/data';
|
|
3
3
|
import { getScopeTargetScope, getScopeTargetSlotId, isScopeTargetData } from '../../../builder/data/is';
|
|
4
|
-
import { CSS_CONFIG } from '../../../config/config/css';
|
|
5
|
-
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
6
4
|
import type { Falsy, StyleItem } from '../../types';
|
|
7
5
|
import type { CombinedStyle } from '../combinedStyle';
|
|
8
6
|
import { createCombinedStyleFacade } from './item';
|
|
@@ -12,6 +10,7 @@ import {
|
|
|
12
10
|
createMutableTokenValues,
|
|
13
11
|
finishTokenValues,
|
|
14
12
|
type StyleTokenValues,
|
|
13
|
+
type TokenValueResolver,
|
|
15
14
|
} from './tokenValues';
|
|
16
15
|
import { type CacheTreeNode, createCacheTreeNode, getCacheTreeChild } from './utils/tree';
|
|
17
16
|
|
|
@@ -38,7 +37,7 @@ type PoolValue = {
|
|
|
38
37
|
tokenCache: TokenWrapperCache | null;
|
|
39
38
|
h: boolean;
|
|
40
39
|
s: StyleTokenValues | null;
|
|
41
|
-
f:
|
|
40
|
+
f: unknown;
|
|
42
41
|
updatedAt: number;
|
|
43
42
|
};
|
|
44
43
|
|
|
@@ -47,31 +46,17 @@ type PoolNode = CacheTreeNode<unknown, PoolValue>;
|
|
|
47
46
|
const DEFAULT_TTL = 1000 * 60 * 5;
|
|
48
47
|
const TOKEN_WRAPPER_CACHE_LIMIT = 32;
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const ttl = RUNTIME_CONFIG.runtimeCacheTTL;
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
!configuredPool ||
|
|
58
|
-
configuredPoolTTL !== ttl
|
|
59
|
-
) {
|
|
60
|
-
configuredPool = createCombinedStylePool(ttl);
|
|
61
|
-
configuredPoolTTL = ttl;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return configuredPool;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function createCombinedStylePool(ttl = DEFAULT_TTL): CombinedStylePool {
|
|
49
|
+
export function createCombinedStylePool(
|
|
50
|
+
resolver: TokenValueResolver,
|
|
51
|
+
ttl = DEFAULT_TTL,
|
|
52
|
+
): CombinedStylePool {
|
|
68
53
|
const root = createPoolNode();
|
|
69
54
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
70
55
|
|
|
71
56
|
return {
|
|
72
57
|
get(styles, inheritedScopes, items, prevTokensData = null) {
|
|
73
58
|
if (ttl === 0) {
|
|
74
|
-
const collected = collectItems(null, items, prevTokensData);
|
|
59
|
+
const collected = collectItems(null, items, prevTokensData, resolver);
|
|
75
60
|
const allScopes = concatScopes(inheritedScopes, collected.scopes);
|
|
76
61
|
|
|
77
62
|
return {
|
|
@@ -86,7 +71,7 @@ export function createCombinedStylePool(ttl = DEFAULT_TTL): CombinedStylePool {
|
|
|
86
71
|
|
|
87
72
|
node = walkScopes(node, inheritedScopes);
|
|
88
73
|
|
|
89
|
-
const collected = collectItems(node, items, prevTokensData);
|
|
74
|
+
const collected = collectItems(node, items, prevTokensData, resolver);
|
|
90
75
|
node = collected.node ?? node;
|
|
91
76
|
node.value.updatedAt = now;
|
|
92
77
|
|
|
@@ -171,6 +156,7 @@ function collectItems(
|
|
|
171
156
|
node: PoolNode | null,
|
|
172
157
|
items: readonly (StyleItem | Falsy)[],
|
|
173
158
|
prevTokensData: StyleTokenValues | null,
|
|
159
|
+
resolver: TokenValueResolver,
|
|
174
160
|
) {
|
|
175
161
|
const scopes: ScopeTargetData[] = [];
|
|
176
162
|
const tokens = createMutableTokenValues(prevTokensData);
|
|
@@ -179,12 +165,12 @@ function collectItems(
|
|
|
179
165
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
180
166
|
const item = items[i];
|
|
181
167
|
|
|
182
|
-
if (addTokenOverride(tokens, item)) continue;
|
|
168
|
+
if (addTokenOverride(tokens, item, resolver)) continue;
|
|
183
169
|
|
|
184
170
|
if (isScopeTargetData(item)) {
|
|
185
171
|
scopes.push(item);
|
|
186
172
|
currentNode = currentNode ? walkScope(currentNode, item) : null;
|
|
187
|
-
addTokenValues(tokens, getScopeTokenValues(currentNode, getScopeTargetScope(item)));
|
|
173
|
+
addTokenValues(tokens, getScopeTokenValues(currentNode, getScopeTargetScope(item), resolver));
|
|
188
174
|
}
|
|
189
175
|
}
|
|
190
176
|
|
|
@@ -232,10 +218,9 @@ function walkScope(
|
|
|
232
218
|
function getScopeTokenValues(
|
|
233
219
|
node: PoolNode | null,
|
|
234
220
|
scope: ScopeData,
|
|
221
|
+
resolver: TokenValueResolver,
|
|
235
222
|
) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (node && node.value.h && node.value.f === tokenNameFormat) {
|
|
223
|
+
if (node && node.value.h && node.value.f === resolver.key) {
|
|
239
224
|
return node.value.s;
|
|
240
225
|
}
|
|
241
226
|
|
|
@@ -243,7 +228,7 @@ function getScopeTokenValues(
|
|
|
243
228
|
const items = scope[BUILDER_STATE].items;
|
|
244
229
|
|
|
245
230
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
246
|
-
addTokenOverride(values, items[i]);
|
|
231
|
+
addTokenOverride(values, items[i], resolver);
|
|
247
232
|
}
|
|
248
233
|
|
|
249
234
|
const tokens = finishTokenValues(null, values);
|
|
@@ -251,7 +236,7 @@ function getScopeTokenValues(
|
|
|
251
236
|
if (node) {
|
|
252
237
|
node.value.h = true;
|
|
253
238
|
node.value.s = tokens;
|
|
254
|
-
node.value.f =
|
|
239
|
+
node.value.f = resolver.key;
|
|
255
240
|
}
|
|
256
241
|
|
|
257
242
|
return tokens;
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from './item';
|
|
25
25
|
import { getStylePropCacheValue } from './propCache';
|
|
26
26
|
import { createStylePropResult, emptyStylePropResult, type ResolvedStyleProp } from './result';
|
|
27
|
+
import { runtimeTokenValueResolver } from './token';
|
|
27
28
|
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
28
29
|
import { walkRecursiveItems } from './utils/walk';
|
|
29
30
|
|
|
@@ -197,7 +198,7 @@ function normalizeStylePropItem(
|
|
|
197
198
|
const bound = getExtractedTokenBoundData(item);
|
|
198
199
|
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
199
200
|
|
|
200
|
-
const tokens = mergeTokenOverrides(null, bound.tokens);
|
|
201
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
201
202
|
|
|
202
203
|
if (isStyleData(bound.data) || isSlotData(bound.data)) {
|
|
203
204
|
return createResolvedStyleItem(bound.data, [], tokens);
|
|
@@ -224,7 +225,7 @@ function getStylePropCacheKey(
|
|
|
224
225
|
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
225
226
|
const bound = getExtractedTokenBoundData(item);
|
|
226
227
|
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
227
|
-
const tokens = mergeTokenOverrides(null, bound.tokens);
|
|
228
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
228
229
|
|
|
229
230
|
if (key && tokens) {
|
|
230
231
|
tokenBindings.push({ data: key, tokens });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getTokenOverrideValue } from '../../../atomic/token';
|
|
2
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
+
import { getStyleTokenId, isStyleTokenOverrideData } from '../../../style/token';
|
|
4
|
+
import type { TokenValueResolver } from './tokenValues';
|
|
5
|
+
|
|
6
|
+
export const runtimeTokenValueResolver: TokenValueResolver = {
|
|
7
|
+
get key() {
|
|
8
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
is: isStyleTokenOverrideData,
|
|
12
|
+
|
|
13
|
+
id(token) {
|
|
14
|
+
return getStyleTokenId(token);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
value(token) {
|
|
18
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
-
import { getStyleTokenId, isStyleTokenOverrideData, type StyleTokenOverride } from '../../../style/token';
|
|
1
|
+
import type { StyleTokenOverride } from '../../../style/token';
|
|
4
2
|
import { hasOwn } from '../../../utils/object';
|
|
5
3
|
|
|
6
4
|
export type StyleTokenValues = {
|
|
@@ -16,6 +14,13 @@ export type MutableTokenValues = {
|
|
|
16
14
|
index: Record<string, number> | null;
|
|
17
15
|
};
|
|
18
16
|
|
|
17
|
+
export type TokenValueResolver = {
|
|
18
|
+
key: unknown;
|
|
19
|
+
is(item: unknown): item is StyleTokenOverride;
|
|
20
|
+
id(token: StyleTokenOverride): string;
|
|
21
|
+
value(token: StyleTokenOverride): unknown;
|
|
22
|
+
};
|
|
23
|
+
|
|
19
24
|
export function createMutableTokenValues(base: StyleTokenValues | null): MutableTokenValues {
|
|
20
25
|
return {
|
|
21
26
|
ids: base ? base.ids.slice() : null,
|
|
@@ -25,13 +30,14 @@ export function createMutableTokenValues(base: StyleTokenValues | null): Mutable
|
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
export function addTokenOverride(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
export function addTokenOverride(
|
|
34
|
+
values: MutableTokenValues,
|
|
35
|
+
item: unknown,
|
|
36
|
+
resolver: TokenValueResolver,
|
|
37
|
+
) {
|
|
38
|
+
if (!resolver.is(item)) return false;
|
|
33
39
|
|
|
34
|
-
addTokenValue(values, id, value);
|
|
40
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
35
41
|
return true;
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -75,9 +81,10 @@ export function addTokenValues(
|
|
|
75
81
|
export function addTokenOverrides(
|
|
76
82
|
values: MutableTokenValues,
|
|
77
83
|
overrides: readonly StyleTokenOverride[],
|
|
84
|
+
resolver: TokenValueResolver,
|
|
78
85
|
) {
|
|
79
86
|
for (let i = 0, len = overrides.length; i < len; i++) {
|
|
80
|
-
addTokenOverride(values, overrides[i]);
|
|
87
|
+
addTokenOverride(values, overrides[i], resolver);
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -112,12 +119,13 @@ export function mergeTokenValues(
|
|
|
112
119
|
export function mergeTokenOverrides(
|
|
113
120
|
base: StyleTokenValues | null,
|
|
114
121
|
overrides: readonly StyleTokenOverride[],
|
|
122
|
+
resolver: TokenValueResolver,
|
|
115
123
|
): StyleTokenValues | null {
|
|
116
124
|
if (!overrides.length) return base;
|
|
117
125
|
|
|
118
126
|
const values = createMutableTokenValues(base);
|
|
119
127
|
|
|
120
|
-
addTokenOverrides(values, overrides);
|
|
128
|
+
addTokenOverrides(values, overrides, resolver);
|
|
121
129
|
|
|
122
130
|
return finishTokenValues(base, values);
|
|
123
131
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type CombinedStyleArg, createCombinedStyleGetter } from '../core/cache/combine';
|
|
2
|
+
import type { CombinedStyle } from '../core/combinedStyle';
|
|
3
|
+
import { extractedTokenValueResolver } from './tokenResolver';
|
|
4
|
+
|
|
5
|
+
export type StyleCombiner<T extends object> = (
|
|
6
|
+
...args: CombinedStyleArg<T>[]
|
|
7
|
+
) => CombinedStyle<T>;
|
|
8
|
+
|
|
9
|
+
export type CombinedStyleFor<T extends object | StyleCombiner<any>> = CombinedStyleArg<InferStyleCombinerStyles<T>>;
|
|
10
|
+
|
|
11
|
+
type InferStyleCombinerStyles<T extends object | StyleCombiner<any>> = T extends StyleCombiner<infer Styles> ? Styles
|
|
12
|
+
: T extends object ? T
|
|
13
|
+
: never;
|
|
14
|
+
|
|
15
|
+
type CombineStyleFn = <T extends object>(
|
|
16
|
+
styles: T,
|
|
17
|
+
...args: CombinedStyleArg<T>[]
|
|
18
|
+
) => CombinedStyle<T>;
|
|
19
|
+
|
|
20
|
+
type CombineStyle = CombineStyleFn & {
|
|
21
|
+
for<T extends object>(styles: T): StyleCombiner<T>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const combineStyleBase = <T extends object>(
|
|
25
|
+
styles: T,
|
|
26
|
+
...args: CombinedStyleArg<T>[]
|
|
27
|
+
): CombinedStyle<T> => getExtractedCombinedStyle(styles, args);
|
|
28
|
+
|
|
29
|
+
const combineStyleFor = <T extends object>(styles: T): StyleCombiner<T> => {
|
|
30
|
+
return (...args: CombinedStyleArg<T>[]) => combineStyleBase(styles, ...args);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const combineStyle = Object.assign(combineStyleBase, {
|
|
34
|
+
for: combineStyleFor,
|
|
35
|
+
}) as CombineStyle;
|
|
36
|
+
|
|
37
|
+
const getExtractedCombinedStyle = createCombinedStyleGetter(extractedTokenValueResolver);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getTokenVar as getAtomicTokenVar, getTokenVarName as getAtomicTokenVarName } from '../../atomic/token';
|
|
2
1
|
import {
|
|
3
2
|
BUILDER_STATE,
|
|
4
3
|
BUILDER_TYPE,
|
|
@@ -12,20 +11,15 @@ import {
|
|
|
12
11
|
} from '../../builder/data/const';
|
|
13
12
|
import type { StateItem } from '../../builder/data/state';
|
|
14
13
|
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../builder/extract/withTokens';
|
|
15
|
-
import {
|
|
14
|
+
import { getStyleTokenId, isStyleTokenData, isStyleTokenOverrideData } from '../../builder/token/data';
|
|
16
15
|
import { RUNTIME_CONFIG } from '../../config/config/runtime';
|
|
17
|
-
import {
|
|
18
|
-
getStyleTokenId,
|
|
19
|
-
isStyleTokenData,
|
|
20
|
-
isStyleTokenOverrideData,
|
|
21
|
-
type StyleTokenData,
|
|
22
|
-
type StyleTokenOverride,
|
|
23
|
-
} from '../../style/token';
|
|
16
|
+
import type { StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
24
17
|
import { getStylePropCacheValue } from '../core/cache/propCache';
|
|
25
18
|
import { getResolvedStyleItemTokenValues, isResolvedStyleItem } from '../core/cache/resolvedItem';
|
|
26
19
|
import { walkRecursiveItems } from '../core/cache/utils/walk';
|
|
27
20
|
import { type ClassNameProps, type ClassNameResult, mergeClassName, mergeStyle } from '../core/className';
|
|
28
21
|
import type { StyleProp } from '../types';
|
|
22
|
+
import { getExtractedTokenVar, getExtractedTokenVarName } from './token';
|
|
29
23
|
|
|
30
24
|
type TokenValues = Record<string, unknown> | null;
|
|
31
25
|
|
|
@@ -453,11 +447,11 @@ function mergeResolvedTokenValues(
|
|
|
453
447
|
}
|
|
454
448
|
|
|
455
449
|
function getTokenVarName(token: StyleTokenData | StyleTokenOverride) {
|
|
456
|
-
return
|
|
450
|
+
return getExtractedTokenVarName(token);
|
|
457
451
|
}
|
|
458
452
|
|
|
459
453
|
function getTokenVar(token: StyleTokenData): string {
|
|
460
|
-
return
|
|
454
|
+
return getExtractedTokenVar(token);
|
|
461
455
|
}
|
|
462
456
|
|
|
463
457
|
function setStyleValue(
|
package/runtime/extract/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { CombinedStyle } from '../core/combinedStyle';
|
|
2
|
-
export { bindScope,
|
|
2
|
+
export { bindScope, combineScope } from '../style/scope';
|
|
3
3
|
export type { StyleProp, StyleTheme, StyleTokenInput, TokenTheme } from '../types';
|
|
4
|
+
export { type CombinedStyleFor, combineStyle } from './combineStyle';
|
|
4
5
|
export { type ClassNameProps, type ClassNameResult, getClassName, mergeClassName, mergeStyle } from './getClassName';
|
|
6
|
+
export { getToken } from './token';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getCssVar, getCssVarRawFallback } from '../../atomic/utils/cssVar';
|
|
2
|
+
import { getStyleTokenId, getStyleTokenVarName, isStyleTokenData } from '../../builder/token/data';
|
|
3
|
+
import type { StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
4
|
+
|
|
5
|
+
export function getToken(value: unknown): unknown {
|
|
6
|
+
if (isStyleTokenData(value)) {
|
|
7
|
+
return getExtractedTokenVar(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getExtractedTokenVarName(
|
|
14
|
+
token: StyleTokenData | StyleTokenOverride,
|
|
15
|
+
) {
|
|
16
|
+
const varName = getStyleTokenVarName(token);
|
|
17
|
+
if (varName) return varName;
|
|
18
|
+
|
|
19
|
+
throw new Error(`Missing extracted token var name for token "${getStyleTokenId(token)}"`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getExtractedTokenVar(token: StyleTokenData): string {
|
|
23
|
+
return getExtractedTokenVarFallback(token);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getExtractedTokenOverrideValue(token: StyleTokenOverride) {
|
|
27
|
+
return token.ref ? getExtractedTokenVar(token.ref) : token.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getExtractedTokenVarFallback(token: StyleTokenData): string {
|
|
31
|
+
const varName = getExtractedTokenVarName(token);
|
|
32
|
+
|
|
33
|
+
if (token.ref) {
|
|
34
|
+
return getCssVarRawFallback(
|
|
35
|
+
varName,
|
|
36
|
+
getExtractedTokenVarFallback(token.ref),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return getCssVar(varName, String(token.value ?? ''));
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getStyleTokenId, isStyleTokenOverrideData } from '../../builder/token/data';
|
|
2
|
+
import type { TokenValueResolver } from '../core/cache/tokenValues';
|
|
3
|
+
import { getExtractedTokenOverrideValue } from './token';
|
|
4
|
+
|
|
5
|
+
export const extractedTokenValueResolver: TokenValueResolver = {
|
|
6
|
+
key: null,
|
|
7
|
+
|
|
8
|
+
is: isStyleTokenOverrideData,
|
|
9
|
+
|
|
10
|
+
id(token) {
|
|
11
|
+
return getStyleTokenId(token);
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
value(token) {
|
|
15
|
+
return getExtractedTokenOverrideValue(token);
|
|
16
|
+
},
|
|
17
|
+
};
|
package/runtime/style/style.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CombinedStyleArg } from '../core/cache/combine';
|
|
2
|
+
import { getCombinedStyle } from '../core/cache/combineRuntime';
|
|
2
3
|
import type { CombinedStyle } from '../core/combinedStyle';
|
|
3
4
|
|
|
4
5
|
export type StyleCombiner<T extends object> = (
|
package/style/style.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { createDefaultFnResult } from '../builder/style_fns';
|
|
|
6
6
|
import type { typeAliases } from '../builder/types/alias';
|
|
7
7
|
import type { StableIdInput } from '../css/utils';
|
|
8
8
|
import { PrioritySelectors } from '../selector/presets';
|
|
9
|
-
import { symbol } from '../utils/
|
|
9
|
+
import { symbol } from '../utils/symbol';
|
|
10
10
|
import { type } from '../utils/type';
|
|
11
11
|
import type { Type } from '../utils/type';
|
|
12
12
|
import { createStyleKeyframes } from './keyframes';
|
package/style/theme.ts
CHANGED