@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.5
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 +55 -1
- package/README.md +10 -9
- package/atomic/className.ts +12 -12
- package/atomic/debug/className/className.ts +10 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +8 -5
- 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/atomic/utils/selector.ts +14 -1
- package/builder/classname/class_name_builder.ts +68 -24
- package/builder/classname/fns.ts +2 -2
- package/builder/classname/types.ts +7 -0
- package/builder/data/const.ts +7 -1
- package/builder/data/create.ts +42 -0
- package/builder/data/data.ts +20 -1
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +23 -0
- package/builder/data/merge/scope.ts +20 -19
- package/builder/data/merge/style.ts +71 -21
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- package/builder/extract/token.ts +30 -14
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +30 -0
- package/builder/selector_override_core.ts +66 -0
- package/builder/style_builder.ts +127 -3
- package/builder/style_data.ts +24 -0
- package/builder/style_fns.ts +24 -24
- 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/builder/types/alias.ts +34 -6
- package/builder/types/fns.ts +13 -5
- package/builder/types/types.ts +32 -2
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +4 -7
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +2 -0
- package/compiler/cssProp.ts +35 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +129 -0
- package/compiler/transform/debug/plugin.ts +85 -1
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +106 -30
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +541 -63
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +1 -1
- package/compiler/transform/extract/plugin.ts +20 -4
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +52 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +1 -8
- package/config/config/css.ts +1 -0
- package/config/config/debug.ts +11 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → combine-Ca6LfFxv.js} +427 -722
- package/dist/combine-Ca6LfFxv.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-D5v5tJXI.mjs → compiler-OgDBuqfs.mjs} +1635 -607
- package/dist/compiler-OgDBuqfs.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-OXHoDUIo.js.map → config-B-KbXpIh.js.map} +1 -1
- package/dist/config-Barf8f4B.js +35 -0
- package/dist/config-Barf8f4B.js.map +1 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/config-CsB4MuFI.js +6 -0
- package/dist/config-CsB4MuFI.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/{config-FIfi5aJ8.js → config-t76UljYv.js} +9 -7
- package/dist/config-t76UljYv.js.map +1 -0
- package/dist/createTransformElement-DDqld3RF.js +34 -0
- package/dist/createTransformElement-DDqld3RF.js.map +1 -0
- package/dist/css-CZwrac6F.js +3923 -0
- package/dist/css-CZwrac6F.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-YfHN_8Nk.js +479 -0
- package/dist/css-YfHN_8Nk.js.map +1 -0
- package/dist/css-a9O5so0b.js +1246 -0
- package/dist/css-a9O5so0b.js.map +1 -0
- package/dist/css.js +2 -2
- 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-CXXZAylc.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-CXXZAylc.js.map} +1 -1
- package/dist/data-CzHJg147.js +763 -0
- package/dist/data-CzHJg147.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-DkrxyknP.js} +80 -4
- package/dist/debug-DkrxyknP.js.map +1 -0
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +6 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-fOtWB5K3.js → dev-z4laBwlS.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-z4laBwlS.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-CqhU_l_m.js} +95 -9
- package/dist/elementMarker-CqhU_l_m.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- 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 +13 -12
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +240 -3
- package/dist/entry/prod/extract.js.map +1 -0
- 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 +3 -4
- package/dist/entry/prod.js +85 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +12 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +12 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +12 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +6 -10
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- 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 +323 -615
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- 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 +3 -4
- package/dist/entry/rsc-prod.js +241 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-ydQcDBD4.js → env-Db2cRt-h.js} +1256 -355
- package/dist/env-Db2cRt-h.js.map +1 -0
- package/dist/{jsx-A4cK517J.js → getClassName-DKtQl5ZX.js} +5 -11
- package/dist/getClassName-DKtQl5ZX.js.map +1 -0
- package/dist/{utils-hoYnMiA7.js → getClassName-DaZF5nfJ.js} +28 -65
- package/dist/getClassName-DaZF5nfJ.js.map +1 -0
- package/dist/getClassName-a6p2uMFM.js +536 -0
- package/dist/getClassName-a6p2uMFM.js.map +1 -0
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-aD9zqg9U.js} +56 -14
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-zYTvWskP.js +10 -0
- package/dist/{global-Cul1dX8k.js.map → global-zYTvWskP.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BOlQThNz.js} +48 -4
- package/dist/hash-BOlQThNz.js.map +1 -0
- package/dist/index.js +10 -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-C2pnWLcb.js +39 -0
- package/dist/jsx-C2pnWLcb.js.map +1 -0
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-XJSHujgI.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-DHvgp0fK.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BuSLnvx0.mjs} +4 -4
- package/dist/misc-BuSLnvx0.mjs.map +1 -0
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-D3tt-joz.js} +8 -6
- package/dist/namedTokens-D3tt-joz.js.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +5 -5
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- 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 +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +9 -7
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-CiwvMfx8.mjs → registry-r3BKWqpI.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-r3BKWqpI.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-D5a37GNr.js +63 -0
- package/dist/resolveClassNameRuntime-D5a37GNr.js.map +1 -0
- package/dist/{rules-DlXcch7-.js → rules-B0_rKPfB.js} +598 -132
- package/dist/rules-B0_rKPfB.js.map +1 -0
- package/dist/scope-BSuRLice.js +601 -0
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +15 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-8_Msr7Q5.cjs} +1630 -597
- package/dist/shared-8_Msr7Q5.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-BGO_05rW.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
- package/dist/sheet-BpLZIIuO.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BpLZIIuO.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-Bu2x35JE.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-BDy5TH6N.js} +5 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-BDy5TH6N.js.map} +1 -1
- package/dist/styleStore-DX3z_UVK.js +51 -0
- package/dist/styleStore-DX3z_UVK.js.map +1 -0
- package/dist/token-BsW_S8fN.js +138 -0
- package/dist/token-BsW_S8fN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-BdKEpgME.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-BdKEpgME.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-DcuMxR45.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-DcuMxR45.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/{style-DFFK06Of.js → types-BEUgXuu2.js} +356 -129
- package/dist/types-BEUgXuu2.js.map +1 -0
- package/dist/{utils-D2fygyTm.mjs → utils-BPDxr-oc.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-BPDxr-oc.mjs.map} +1 -1
- package/dist/utils-CLnpwhJd.js +83 -0
- package/dist/utils-CLnpwhJd.js.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DTXCTUlS.mjs → utils-DZjLTV4D.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DZjLTV4D.mjs.map} +1 -1
- package/dist/utils-okFWrQsg.js +41 -0
- package/dist/utils-okFWrQsg.js.map +1 -0
- package/dist/{utils-DVFxZnVC.js → utils-sBVZEq4u.js} +190 -144
- package/dist/utils-sBVZEq4u.js.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CpJpQ00y.js +145 -0
- package/dist/value-CpJpQ00y.js.map +1 -0
- package/dist/{webpack-BOU7_xld.mjs → webpack-DTKgR-HY.mjs} +5 -5
- package/dist/webpack-DTKgR-HY.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- 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_dev/adapter/preact.ts +1 -0
- package/entry/rsc_dev/adapter/react.ts +1 -0
- package/entry/rsc_dev/adapter/solid.ts +1 -0
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- 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/jsx/types/index.ts +3 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +78 -12
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +3 -8
- package/plugin/bundler/vite/state.ts +2 -2
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/nextjs/plugin.ts +3 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/adapter/utils.ts +94 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +54 -17
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +3 -3
- package/style/classname.ts +12 -6
- package/style/important.ts +19 -0
- package/style/index.ts +2 -0
- package/style/style.ts +17 -5
- 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/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-CKo4TxuT.js +0 -144
- package/dist/className-CKo4TxuT.js.map +0 -1
- 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 +0 -58
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-DcuJ_jSH.js +0 -243
- package/dist/css-DcuJ_jSH.js.map +0 -1
- package/dist/css-dPoZJDQH.js +0 -807
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/css-oOt6ZR54.js +0 -237
- package/dist/css-oOt6ZR54.js.map +0 -1
- package/dist/data-CeYstKMP.js +0 -482
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/debug-D96KGgpH.js.map +0 -1
- package/dist/dev-p8tW7X-A.js +0 -81
- package/dist/dev-p8tW7X-A.js.map +0 -1
- package/dist/elementMarker-CvqqIb7J.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-Cul1dX8k.js +0 -14
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/jsx-A4cK517J.js.map +0 -1
- package/dist/jsx-Ba-XV33u.js +0 -39
- package/dist/jsx-Ba-XV33u.js.map +0 -1
- package/dist/layer-CbQzwZF-.js +0 -94
- package/dist/layer-CbQzwZF-.js.map +0 -1
- package/dist/misc-DFBKJGLT.mjs.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CF6JgpTq.js +0 -406
- package/dist/property-CF6JgpTq.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 +0 -771
- 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-Bmw655wa.js +0 -170
- package/dist/utils-Bmw655wa.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/utils-hoYnMiA7.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 +0 -1029
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
- package/dist/valueRef-CsLVJwjA.js +0 -16
- package/dist/valueRef-CsLVJwjA.js.map +0 -1
- package/dist/webpack-BOU7_xld.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
import {
|
|
3
|
-
invalidateFiles,
|
|
4
|
-
PLUGIN_NAME,
|
|
5
|
-
type PluginCssOptions,
|
|
6
|
-
type PluginOptions,
|
|
7
|
-
transformCssOutput,
|
|
8
|
-
} from '../../utils';
|
|
2
|
+
import { invalidateFiles, PLUGIN_NAME, type PluginOptions, transformCssOutput } from '../../utils';
|
|
9
3
|
import { hasCssMarker, replaceCssMarker } from '../../utils/cssMarker';
|
|
10
4
|
import { formatError } from '../../utils/misc';
|
|
11
5
|
import { getVirtualModuleId, RESOLVED_RUNTIME_MODULE_ID } from '../../utils/virtual';
|
|
12
6
|
import { createVitePluginState } from './state';
|
|
13
7
|
|
|
14
|
-
export
|
|
8
|
+
export { CssPropPresets } from '../../utils';
|
|
9
|
+
export type { CompilerCssPropOptions, PluginCssOptions, PluginOptions } from '../../utils';
|
|
15
10
|
|
|
16
11
|
type CssAsset = {
|
|
17
12
|
source: string;
|
|
@@ -42,7 +42,7 @@ export function createVitePluginState(options: PluginOptions) {
|
|
|
42
42
|
|
|
43
43
|
async getConfig(config: UserConfig, env: ConfigEnv) {
|
|
44
44
|
const dev = env.command === 'serve';
|
|
45
|
-
const buildConfig = getPluginBuildConfig(options);
|
|
45
|
+
const buildConfig = getPluginBuildConfig(options, dev);
|
|
46
46
|
const buildDevConfig = getPluginBuildDevConfig(options);
|
|
47
47
|
const sidecarUrl = await getSidecarUrl(dev, getViteRoot(config));
|
|
48
48
|
|
|
@@ -62,7 +62,7 @@ export function createVitePluginState(options: PluginOptions) {
|
|
|
62
62
|
|
|
63
63
|
loadRuntimeModule() {
|
|
64
64
|
const current = this.getState();
|
|
65
|
-
const buildConfig = getPluginBuildConfig(options);
|
|
65
|
+
const buildConfig = getPluginBuildConfig(options, current.dev);
|
|
66
66
|
const buildDevConfig = getPluginBuildDevConfig(options);
|
|
67
67
|
const configSource = createStyleEntryGlobalSource(
|
|
68
68
|
buildConfig,
|
|
@@ -35,7 +35,8 @@ import {
|
|
|
35
35
|
webpackRegistry,
|
|
36
36
|
} from './utils';
|
|
37
37
|
|
|
38
|
-
export
|
|
38
|
+
export { CssPropPresets } from '../../utils';
|
|
39
|
+
export type { CompilerCssPropOptions, PluginOptions } from '../../utils';
|
|
39
40
|
|
|
40
41
|
const WEBPACK_RUNTIME_FILE = 'webpack-runtime.js';
|
|
41
42
|
|
package/plugin/nextjs/plugin.ts
CHANGED
|
@@ -53,6 +53,9 @@ import {
|
|
|
53
53
|
resolveNextCompilerOptions,
|
|
54
54
|
} from './utils';
|
|
55
55
|
|
|
56
|
+
export { CssPropPresets } from '../utils';
|
|
57
|
+
export type { CompilerCssPropOptions } from '../utils';
|
|
58
|
+
|
|
56
59
|
export default plugin;
|
|
57
60
|
|
|
58
61
|
const TURBOPACK_TRANSFORM_EXTENSIONS: readonly string[] = ['*.ts', '*.tsx', '*.js', '*.jsx'];
|
package/plugin/utils/compiler.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { createTransformFilter, normalizeModuleId, type TransformFilterOptions }
|
|
|
7
7
|
import type { BundlerSourceMap } from './sourcemap';
|
|
8
8
|
|
|
9
9
|
export type PluginCssOptions = CompilerCssOptions;
|
|
10
|
+
export { CssPropPresets } from '../../compiler';
|
|
11
|
+
export type { CompilerCssPropOptions } from '../../compiler';
|
|
10
12
|
|
|
11
13
|
export type PluginOptions = CompilerOptions & TransformFilterOptions & {
|
|
12
14
|
cacheDir?: string;
|
|
@@ -10,11 +10,11 @@ export function getStyleRuntimeMode(dev: boolean, rsc = false): CompilerRuntimeM
|
|
|
10
10
|
return dev ? CompilerRuntimeMode.Dev : CompilerRuntimeMode.Prod;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function getPluginBuildConfig(options: PluginOptions): BuildConfig {
|
|
13
|
+
export function getPluginBuildConfig(options: PluginOptions, dev = false): BuildConfig {
|
|
14
14
|
const css: CompilerCssOptions = hasBuildConfig(options.css) ? options.css! : {};
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
|
-
hoist: options.hoist !== false,
|
|
17
|
+
hoist: !dev && options.hoist !== false,
|
|
18
18
|
css,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -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
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ClassNameProps, ClassNameResult } from '../core/className';
|
|
2
|
+
import type { StyleProp } from '../types';
|
|
3
|
+
|
|
4
|
+
export type JsxCssPropStyleMode = 'react' | 'solid';
|
|
5
|
+
|
|
6
|
+
export type JsxCssPropMergeOptions = {
|
|
7
|
+
classProp: 'class' | 'className';
|
|
8
|
+
styleProp: 'style';
|
|
9
|
+
styleMode: JsxCssPropStyleMode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type JsxCssPropInput = Record<PropertyKey, unknown>;
|
|
13
|
+
|
|
14
|
+
export type GetClassNameFn = (
|
|
15
|
+
styleProp: StyleProp,
|
|
16
|
+
props?: ClassNameProps,
|
|
17
|
+
) => ClassNameResult;
|
|
18
|
+
|
|
19
|
+
export function createMergeJsxProps(
|
|
20
|
+
getClassName: GetClassNameFn,
|
|
21
|
+
options: JsxCssPropMergeOptions,
|
|
22
|
+
) {
|
|
23
|
+
return function mergeJsxProps(parts: readonly unknown[]) {
|
|
24
|
+
let props: JsxCssPropInput | null = null;
|
|
25
|
+
|
|
26
|
+
for (let index = 0; index < parts.length; index++) {
|
|
27
|
+
props = mergePart(props, parts[index], getClassName, options);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return props ?? {};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function mergePart(
|
|
35
|
+
props: JsxCssPropInput | null,
|
|
36
|
+
part: unknown,
|
|
37
|
+
getClassName: GetClassNameFn,
|
|
38
|
+
options: JsxCssPropMergeOptions,
|
|
39
|
+
) {
|
|
40
|
+
if (!part) return props;
|
|
41
|
+
|
|
42
|
+
const next = props ? { ...props } : {};
|
|
43
|
+
const attrs = part as JsxCssPropInput;
|
|
44
|
+
const css = attrs.css;
|
|
45
|
+
|
|
46
|
+
for (const key in attrs) {
|
|
47
|
+
if (key !== 'css') next[key] = attrs[key];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!css) return next;
|
|
51
|
+
|
|
52
|
+
const className = getClassName(css as StyleProp, {
|
|
53
|
+
className: getClassValue(next, options.classProp),
|
|
54
|
+
style: next[options.styleProp] as ClassNameProps['style'],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
delete next.class;
|
|
58
|
+
delete next.className;
|
|
59
|
+
|
|
60
|
+
if (className.className !== undefined) {
|
|
61
|
+
next[options.classProp] = className.className;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (className.style !== undefined) {
|
|
65
|
+
next[options.styleProp] = options.styleMode === 'solid'
|
|
66
|
+
? toSolidStyle(className.style as Record<string, unknown>)
|
|
67
|
+
: className.style;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return next;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getClassValue(
|
|
74
|
+
props: JsxCssPropInput,
|
|
75
|
+
classProp: 'class' | 'className',
|
|
76
|
+
) {
|
|
77
|
+
return (props[classProp] ?? props[classProp === 'class' ? 'className' : 'class']) as ClassNameProps['className'];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function toSolidStyle(style: Record<string, unknown>) {
|
|
81
|
+
const next: Record<string, unknown> = {};
|
|
82
|
+
|
|
83
|
+
for (const key in style) {
|
|
84
|
+
next[toCssPropertyName(key)] = style[key];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return next;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function toCssPropertyName(key: string) {
|
|
91
|
+
if (key.startsWith('--') || key.includes('-')) return key;
|
|
92
|
+
|
|
93
|
+
return key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
94
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
2
|
+
import type { ScopeData, ScopeTargetData, SheetData } from '../../../builder/data/data';
|
|
3
|
+
import { isScopeData, isSheetData } from '../../../builder/data/is';
|
|
2
4
|
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../../builder/extract/withTokens';
|
|
3
5
|
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
4
6
|
import type { Falsy, StyleItem } from '../../types';
|
|
5
7
|
import { type CombinedStyle, getCombinedStyleScopes, getCombinedStyleStyles, isCombinedStyle } from '../combinedStyle';
|
|
6
8
|
import { createCombinedStyleTokenWrapper, getStyleTokenValues } from './item';
|
|
7
|
-
import {
|
|
8
|
-
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
9
|
+
import { type CombinedStylePool, createCombinedStylePool, getCachedTokenWrapper } from './pool';
|
|
10
|
+
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues, type TokenValueResolver } from './tokenValues';
|
|
9
11
|
|
|
10
12
|
export type CombinedStyleArg<T extends object> =
|
|
11
13
|
| Falsy
|
|
12
14
|
| StyleItem
|
|
15
|
+
| ScopeData
|
|
16
|
+
| SheetData
|
|
13
17
|
| CombinedStyle<T>
|
|
14
18
|
| readonly CombinedStyleArg<T>[];
|
|
15
19
|
|
|
@@ -19,30 +23,48 @@ type NormalizedStyleItems = {
|
|
|
19
23
|
tokens: StyleTokenValues | null;
|
|
20
24
|
};
|
|
21
25
|
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
export function createCombinedStyleGetter(
|
|
27
|
+
resolver: TokenValueResolver,
|
|
28
|
+
) {
|
|
29
|
+
let configuredPool: CombinedStylePool | null = null;
|
|
30
|
+
let configuredPoolTTL = -1;
|
|
31
|
+
|
|
32
|
+
return function getConfiguredCombinedStyle<T extends object>(
|
|
33
|
+
styles: T,
|
|
34
|
+
args: readonly CombinedStyleArg<T>[],
|
|
35
|
+
): CombinedStyle<T> {
|
|
36
|
+
const ttl = RUNTIME_CONFIG.runtimeCacheTTL;
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
!configuredPool ||
|
|
40
|
+
configuredPoolTTL !== ttl
|
|
41
|
+
) {
|
|
42
|
+
configuredPool = createCombinedStylePool(resolver, ttl);
|
|
43
|
+
configuredPoolTTL = ttl;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const normalized = normalizeStyleItems(styles, args, resolver);
|
|
47
|
+
const result = configuredPool.get(
|
|
48
|
+
styles,
|
|
49
|
+
normalized.inheritedScopes,
|
|
50
|
+
normalized.items,
|
|
51
|
+
normalized.tokens,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return result.tokens
|
|
55
|
+
? getCachedTokenWrapper(
|
|
56
|
+
result.tokenCache,
|
|
57
|
+
result.tokens,
|
|
58
|
+
() => createCombinedStyleTokenWrapper(result.style, result.tokens!),
|
|
59
|
+
)
|
|
60
|
+
: result.style;
|
|
61
|
+
};
|
|
41
62
|
}
|
|
42
63
|
|
|
43
64
|
function normalizeStyleItems<T extends object>(
|
|
44
65
|
styles: T,
|
|
45
66
|
args: readonly CombinedStyleArg<T>[],
|
|
67
|
+
resolver: TokenValueResolver,
|
|
46
68
|
): NormalizedStyleItems {
|
|
47
69
|
const result: NormalizedStyleItems = {
|
|
48
70
|
inheritedScopes: [],
|
|
@@ -51,7 +73,7 @@ function normalizeStyleItems<T extends object>(
|
|
|
51
73
|
};
|
|
52
74
|
|
|
53
75
|
for (let i = 0, len = args.length; i < len; i++) {
|
|
54
|
-
collectStyleArg(styles, args[i], result);
|
|
76
|
+
collectStyleArg(styles, args[i], result, resolver);
|
|
55
77
|
}
|
|
56
78
|
|
|
57
79
|
return result;
|
|
@@ -61,12 +83,13 @@ function collectStyleArg<T extends object>(
|
|
|
61
83
|
styles: T,
|
|
62
84
|
arg: CombinedStyleArg<T>,
|
|
63
85
|
result: NormalizedStyleItems,
|
|
86
|
+
resolver: TokenValueResolver,
|
|
64
87
|
) {
|
|
65
88
|
if (!arg) return;
|
|
66
89
|
|
|
67
90
|
if (Array.isArray(arg)) {
|
|
68
91
|
for (let i = 0, len = arg.length; i < len; i++) {
|
|
69
|
-
collectStyleArg(styles, arg[i], result);
|
|
92
|
+
collectStyleArg(styles, arg[i], result, resolver);
|
|
70
93
|
}
|
|
71
94
|
|
|
72
95
|
return;
|
|
@@ -75,16 +98,15 @@ function collectStyleArg<T extends object>(
|
|
|
75
98
|
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(arg)) {
|
|
76
99
|
const bound = getExtractedTokenBoundData(arg);
|
|
77
100
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result);
|
|
101
|
+
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result, resolver);
|
|
102
|
+
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
|
|
81
103
|
return;
|
|
82
104
|
}
|
|
83
105
|
|
|
84
106
|
if (isCombinedStyle<T>(arg)) {
|
|
85
107
|
if (getCombinedStyleStyles(arg) !== styles) {
|
|
86
108
|
throw new TypeError(
|
|
87
|
-
'[fluentic-style] combineStyle
|
|
109
|
+
'[fluentic-style] combineStyle styles mismatch.',
|
|
88
110
|
);
|
|
89
111
|
}
|
|
90
112
|
|
|
@@ -98,5 +120,31 @@ function collectStyleArg<T extends object>(
|
|
|
98
120
|
return;
|
|
99
121
|
}
|
|
100
122
|
|
|
123
|
+
if (isSheetData(arg)) {
|
|
124
|
+
collectTokenOverrides(arg, result, resolver);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (isScopeData(arg)) {
|
|
129
|
+
collectTokenOverrides(arg, result, resolver);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
101
133
|
result.items.push(arg as StyleItem);
|
|
102
134
|
}
|
|
135
|
+
|
|
136
|
+
function collectTokenOverrides(
|
|
137
|
+
data: SheetData | ScopeData,
|
|
138
|
+
result: NormalizedStyleItems,
|
|
139
|
+
resolver: TokenValueResolver,
|
|
140
|
+
) {
|
|
141
|
+
const items = data[BUILDER_STATE]?.items ?? [];
|
|
142
|
+
|
|
143
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
144
|
+
const item = items[i];
|
|
145
|
+
|
|
146
|
+
if (resolver.is(item)) {
|
|
147
|
+
result.tokens = mergeTokenOverrides(result.tokens, [item], resolver);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -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,16 +1,17 @@
|
|
|
1
|
-
import { getScopeClassName } from '../../../atomic/className';
|
|
2
1
|
import { BUILDER_STATE, BUILDER_TYPE_SCOPE, BUILDER_TYPE_SLOT } from '../../../builder/data/const';
|
|
3
|
-
import type { ScopeTargetData, SlotData, StyleData } from '../../../builder/data/data';
|
|
2
|
+
import type { ScopeTargetData, SheetData, SlotData, StyleData } from '../../../builder/data/data';
|
|
4
3
|
import {
|
|
5
4
|
getScopeTargetScope,
|
|
6
5
|
getScopeTargetSlotId,
|
|
7
6
|
getSlotId,
|
|
7
|
+
isSelectorData,
|
|
8
|
+
isSheetData,
|
|
8
9
|
isSlotData,
|
|
9
10
|
isStyleData,
|
|
10
11
|
} from '../../../builder/data/is';
|
|
11
12
|
import type { StateItem } from '../../../builder/data/state';
|
|
13
|
+
import { isStyleTokenOverrideData } from '../../../builder/token/data';
|
|
12
14
|
import { CSS_CONFIG } from '../../../config/config/css';
|
|
13
|
-
import { isStyleTokenOverrideData } from '../../../style/token';
|
|
14
15
|
import { globalData } from '../../../utils/global';
|
|
15
16
|
import {
|
|
16
17
|
type CombinedStyle,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
markResolvedStyleItem,
|
|
28
29
|
setResolvedStyleItemTokenValues,
|
|
29
30
|
} from './resolvedItem';
|
|
30
|
-
import type
|
|
31
|
+
import { mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
31
32
|
|
|
32
33
|
export type ResolvedStyleItem<Data = unknown> = {
|
|
33
34
|
data: Data;
|
|
@@ -36,14 +37,14 @@ export type ResolvedStyleItem<Data = unknown> = {
|
|
|
36
37
|
|
|
37
38
|
const directStyleItemCache = globalData(
|
|
38
39
|
'runtime.directStyleItemCache',
|
|
39
|
-
() => new WeakMap<StyleData | SlotData, ResolvedStyleItem>(),
|
|
40
|
+
() => new WeakMap<StyleData | SheetData | SlotData, ResolvedStyleItem>(),
|
|
40
41
|
);
|
|
41
42
|
|
|
42
43
|
export function isResolvedStyleItem<T>(value: unknown): value is ResolvedStyleItem<T> {
|
|
43
44
|
return isResolvedStyleItemMarked(value);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function createResolvedStyleItem<Data extends StyleData | SlotData>(
|
|
47
|
+
export function createResolvedStyleItem<Data extends StyleData | SheetData | SlotData>(
|
|
47
48
|
data: Data,
|
|
48
49
|
scopes: readonly ScopeTargetData[],
|
|
49
50
|
tokens: StyleTokenValues | null = null,
|
|
@@ -64,7 +65,7 @@ export function createResolvedStyleItemFromItems<Data>(
|
|
|
64
65
|
}, tokens);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
export function getDirectStyleItem(item: StyleData | SlotData) {
|
|
68
|
+
export function getDirectStyleItem(item: StyleData | SheetData | SlotData) {
|
|
68
69
|
let cached = directStyleItemCache.get(item);
|
|
69
70
|
|
|
70
71
|
if (!cached) {
|
|
@@ -112,10 +113,14 @@ export function createCombinedStyleTokenWrapper<T extends object>(
|
|
|
112
113
|
const getStyleField: CombinedStyleFieldGetter = (meta, prop) => {
|
|
113
114
|
const value = (meta.styles as any)?.[prop] ?? null;
|
|
114
115
|
|
|
115
|
-
if (isStyleData(value) || isSlotData(value)) {
|
|
116
|
+
if (isStyleData(value) || isSheetData(value) || isSlotData(value)) {
|
|
116
117
|
return createResolvedStyleItem(value, meta.scopes);
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
if (isSelectorData(value)) {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
|
|
119
124
|
if (value && typeof value === 'object') {
|
|
120
125
|
return createCombinedStyleFacade(value, meta.scopes);
|
|
121
126
|
}
|
|
@@ -128,10 +133,12 @@ function getTokenField(base: CombinedStyle): CombinedStyleFieldGetter {
|
|
|
128
133
|
const value = (base as any)?.[prop] ?? null;
|
|
129
134
|
|
|
130
135
|
if (isResolvedStyleItem(value)) {
|
|
136
|
+
const tokens = mergeTokenValues(getStyleTokenValues(value), meta.tokens);
|
|
137
|
+
|
|
131
138
|
return createStyleItem({
|
|
132
139
|
data: value.data,
|
|
133
140
|
items: value.items,
|
|
134
|
-
},
|
|
141
|
+
}, tokens);
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
if (isCombinedStyle(value)) {
|
|
@@ -152,7 +159,7 @@ function createStyleItem<Data>(
|
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
function resolveItems(
|
|
155
|
-
data: StyleData | SlotData,
|
|
162
|
+
data: StyleData | SheetData | SlotData,
|
|
156
163
|
scopes: readonly ScopeTargetData[],
|
|
157
164
|
) {
|
|
158
165
|
const items: StateItem[] = [];
|
|
@@ -169,14 +176,17 @@ function resolveItems(
|
|
|
169
176
|
continue;
|
|
170
177
|
}
|
|
171
178
|
|
|
172
|
-
if (isStyleTokenOverrideData(item))
|
|
179
|
+
if (isStyleTokenOverrideData(item)) {
|
|
180
|
+
items.push(item);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
173
183
|
|
|
174
184
|
if (slotId && item.type !== BUILDER_TYPE_SLOT) continue;
|
|
175
185
|
|
|
176
186
|
items.push(item);
|
|
177
187
|
}
|
|
178
188
|
|
|
179
|
-
if (!slotId) return items;
|
|
189
|
+
if (!slotId || isSheetData(data)) return items;
|
|
180
190
|
|
|
181
191
|
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
182
192
|
const boundScope = scopes[i];
|
|
@@ -221,11 +231,20 @@ function resolveItems(
|
|
|
221
231
|
}
|
|
222
232
|
|
|
223
233
|
function getScopeParentItem(className: string): StateItem {
|
|
224
|
-
const parentClassName =
|
|
234
|
+
const parentClassName = formatScopeClassName(className);
|
|
225
235
|
|
|
226
236
|
return [parentClassName, parentClassName];
|
|
227
237
|
}
|
|
228
238
|
|
|
239
|
+
function formatScopeClassName(className: string) {
|
|
240
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
241
|
+
|
|
242
|
+
if (!format) return '-' + className;
|
|
243
|
+
if (typeof format === 'function') return format({ className });
|
|
244
|
+
|
|
245
|
+
return format.replace(/\[|\]/g, '').replace(/\(className\)/g, className);
|
|
246
|
+
}
|
|
247
|
+
|
|
229
248
|
function isExtractedScopeParentMarker(value: unknown) {
|
|
230
249
|
return value === 1 || value === true;
|
|
231
250
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
2
|
+
import type { SheetData, SlotData, StyleData } from '../../../builder/data/data';
|
|
3
|
+
import { createResolvedStyleItem } from './item';
|
|
4
|
+
import {
|
|
5
|
+
addTokenOverride,
|
|
6
|
+
createMutableTokenValues,
|
|
7
|
+
finishTokenValues,
|
|
8
|
+
mergeTokenValues,
|
|
9
|
+
type StyleTokenValues,
|
|
10
|
+
type TokenValueResolver,
|
|
11
|
+
} from './tokenValues';
|
|
12
|
+
|
|
13
|
+
export function createResolvedStyleItemWithResolver<Data extends StyleData | SheetData | SlotData>(
|
|
14
|
+
data: Data,
|
|
15
|
+
tokens: StyleTokenValues | null,
|
|
16
|
+
resolver: TokenValueResolver,
|
|
17
|
+
) {
|
|
18
|
+
return createResolvedStyleItem(
|
|
19
|
+
data,
|
|
20
|
+
[],
|
|
21
|
+
mergeTokenValues(getDataTokenValues(data, resolver), tokens),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getDirectStyleItemWithResolver(
|
|
26
|
+
item: StyleData | SheetData | SlotData,
|
|
27
|
+
resolver: TokenValueResolver,
|
|
28
|
+
) {
|
|
29
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getDataTokenValues(
|
|
33
|
+
data: StyleData | SheetData | SlotData,
|
|
34
|
+
resolver: TokenValueResolver,
|
|
35
|
+
) {
|
|
36
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
37
|
+
const values = createMutableTokenValues(null);
|
|
38
|
+
|
|
39
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
40
|
+
addTokenOverride(values, stateItems[i], resolver);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return finishTokenValues(null, values);
|
|
44
|
+
}
|