@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.10
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 +150 -2
- package/README.md +181 -49
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +50 -12
- package/atomic/debug/className/className.ts +24 -8
- package/atomic/element.ts +5 -2
- package/atomic/rule.ts +11 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +44 -3
- package/atomic/token.ts +7 -4
- package/atomic/utils/cssIdent.ts +54 -0
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +14 -0
- package/atomic/utils/selector.ts +31 -1
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +491 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +41 -0
- package/builder/data/const.ts +8 -1
- package/builder/data/create.ts +52 -6
- package/builder/data/data.ts +33 -8
- package/builder/data/debug.ts +1 -0
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +26 -3
- package/builder/data/merge/scope.ts +38 -38
- package/builder/data/merge/style.ts +115 -20
- package/builder/data/state.ts +17 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +30 -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 +31 -0
- package/builder/selector_override_core.ts +79 -0
- package/builder/style_builder.ts +144 -20
- package/builder/style_data.ts +25 -0
- package/builder/style_fns.ts +57 -57
- 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 +44 -16
- package/builder/types/fns.ts +24 -16
- package/builder/types/types.ts +37 -7
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +88 -14
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +4 -1
- package/compiler/cssProp.ts +21 -0
- package/compiler/extract/extract.ts +42 -14
- package/compiler/extract/types.ts +2 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +93 -4
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +169 -32
- package/compiler/transform/evaluator/tracer.ts +48 -11
- package/compiler/transform/extract/chain/chain.ts +1370 -162
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +3 -1
- package/compiler/transform/extract/plugin.ts +64 -6
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +72 -2
- package/compiler/transform/extract/utils/state.ts +3 -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 +12 -5
- package/compiler/utils/file_resolver.ts +2 -0
- package/compiler/utils/import_source.ts +19 -8
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +9 -2
- package/config/config/check.ts +25 -0
- package/config/config/css.ts +18 -1
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +19 -2
- package/config/types.ts +7 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +152 -0
- package/css/styleTarget.ts +251 -0
- package/dev/config.ts +2 -3
- package/dev/utils.ts +3 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +153 -0
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-yhJCGT0F.js +304 -0
- package/dist/className-yhJCGT0F.js.map +1 -0
- package/dist/combine-Bww7VnSr.js +1254 -0
- package/dist/combine-Bww7VnSr.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
- package/dist/compiler-C3CEGGtI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BAEzRmSJ.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
- package/dist/config-BKP5LOkt.js +35 -0
- package/dist/config-BKP5LOkt.js.map +1 -0
- package/dist/config-C5VWvTav.js +34 -0
- package/dist/config-C5VWvTav.js.map +1 -0
- package/dist/config-CB4lm2tM.js +1 -0
- package/dist/config-CDjbHwb-.js +6 -0
- package/dist/config-CDjbHwb-.js.map +1 -0
- package/dist/config-DNEnHEf3.js +36 -0
- package/dist/config-DNEnHEf3.js.map +1 -0
- package/dist/createTransformElement-D8fXZ3wA.js +34 -0
- package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
- package/dist/css-BDn0epJ8.js +1339 -0
- package/dist/css-BDn0epJ8.js.map +1 -0
- package/dist/css-CFxNrYt3.js +4040 -0
- package/dist/css-CFxNrYt3.js.map +1 -0
- package/dist/css-DEYgrj76.js +524 -0
- package/dist/css-DEYgrj76.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
- package/dist/css-DWBWsyxZ.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
- package/dist/data-CDrS1Bq4.js +785 -0
- package/dist/data-CDrS1Bq4.js.map +1 -0
- package/dist/debug-BkVbf0Cz.js +52 -0
- package/dist/debug-BkVbf0Cz.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
- package/dist/debug-YuhEIQVO.js.map +1 -0
- package/dist/dev/rsc.js +10 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
- package/dist/dev-0imWmSVb.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
- package/dist/elementMarker-kvpMjB49.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 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +13 -9
- 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 +242 -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 +84 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -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 +11 -13
- 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 +582 -664
- 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 +242 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
- package/dist/env-Cz8frh6e.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js +545 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
- package/dist/getClassName-DGm-VNDo.js.map +1 -0
- package/dist/getClassName-Dtc4yyYI.js +47 -0
- package/dist/getClassName-Dtc4yyYI.js.map +1 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
- package/dist/getClassName-DtkplEIt.js.map +1 -0
- package/dist/global-CAc9OjKx.js +14 -0
- package/dist/global-CAc9OjKx.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +10 -8
- 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-CVxpkS04.js +39 -0
- package/dist/jsx-CVxpkS04.js.map +1 -0
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
- package/dist/misc-B76PUnWe.mjs.map +1 -0
- package/dist/namedTokens-5AayGokX.js +85 -0
- package/dist/namedTokens-5AayGokX.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 +121 -17
- 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 +13 -10
- 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 +995 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
- package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
- package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
- package/dist/rules-DaMaMHgb.js.map +1 -0
- package/dist/scope-CZdGAnl_.js +601 -0
- package/dist/scope-CZdGAnl_.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
- package/dist/shared-PK52rW6T.cjs.map +1 -0
- package/dist/sheet-CxkO1Hwt.js +7 -0
- package/dist/sheet-CxkO1Hwt.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
- package/dist/style-CAhAnRni.js +1129 -0
- package/dist/style-CAhAnRni.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
- package/dist/styleStore-BzLZwpwy.js.map +1 -0
- package/dist/styleStore-DaIJ4OPV.js +58 -0
- package/dist/styleStore-DaIJ4OPV.js.map +1 -0
- package/dist/token-D33mKTka.js +138 -0
- package/dist/token-D33mKTka.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
- package/dist/transform-DSpimwwC.js +23 -0
- package/dist/transform-DSpimwwC.js.map +1 -0
- package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
- package/dist/utils-DZK0mfmY.js +42 -0
- package/dist/utils-DZK0mfmY.js.map +1 -0
- package/dist/utils-D_XgtMtn.js +72 -0
- package/dist/utils-D_XgtMtn.js.map +1 -0
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
- package/dist/utils-H1VInWpd.js.map +1 -0
- package/dist/utils-NdisireF.mjs +182 -0
- package/dist/utils-NdisireF.mjs.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CK0-Xbov.js +160 -0
- package/dist/value-CK0-Xbov.js.map +1 -0
- package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
- package/dist/webpack-D7QO0bKN.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/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -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 +4 -2
- package/entry/rsc_dev/adapter/preact.ts +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -0
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- 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/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +14 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/jsx/types/index.ts +1 -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 +110 -8
- 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 +5 -9
- package/plugin/bundler/vite/state.ts +11 -6
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +208 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +121 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +15 -2
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +239 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +436 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/adapter/utils.ts +120 -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 +16 -31
- 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 +55 -23
- package/runtime/extract/index.ts +4 -2
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/index.ts +8 -1
- package/runtime/rsc/getClassName.ts +4 -0
- package/runtime/rsc/observer.ts +4 -0
- package/runtime/rsc/styleStore.ts +18 -7
- package/runtime/sheet/rule.ts +16 -12
- package/runtime/sheet/rules.ts +8 -3
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +6 -4
- package/sheet/dev/dev_layer.ts +18 -7
- package/sheet/dev/dev_sort.ts +45 -11
- package/sheet/prod.ts +18 -7
- package/sheet/types.ts +2 -0
- package/sheet/utils/layer.ts +33 -0
- package/style/classname.ts +47 -0
- package/style/important.ts +19 -0
- package/style/index.ts +3 -0
- package/style/style.ts +47 -16
- package/style/theme.ts +4 -3
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +41 -2
- 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/hash.ts +4 -0
- package/utils/symbol.ts +3 -0
- package/atomic/layer/README.md +0 -116
- package/atomic/utils/css.ts +0 -49
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-C1Ht5Wvv.js +0 -144
- package/dist/className-C1Ht5Wvv.js.map +0 -1
- package/dist/className-DC2Cq8p3.js +0 -251
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-BryWDfQX.js +0 -25
- package/dist/config-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js +0 -243
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js +0 -805
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js +0 -235
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/css_extra-DlOnsnR1.js +0 -8
- package/dist/css_extra-oIi3UEPK.js.map +0 -1
- package/dist/data-BsqOa5br.js +0 -473
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-CcphAa3R.js.map +0 -1
- package/dist/dev-DfBbuLeE.js +0 -71
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/global-CvfmFLsK.js.map +0 -1
- package/dist/jsx-CwTeyUxr.js +0 -39
- package/dist/jsx-CwTeyUxr.js.map +0 -1
- package/dist/jsx-D2BksHSv.js +0 -38
- package/dist/jsx-D2BksHSv.js.map +0 -1
- package/dist/layer-D1SaH07m.js +0 -94
- package/dist/layer-D1SaH07m.js.map +0 -1
- package/dist/loader-B5Kw0DD-.mjs.map +0 -1
- package/dist/misc-DCdYYyhK.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CnLFt5kx.js +0 -406
- package/dist/property-CnLFt5kx.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js +0 -752
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js +0 -1269
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/styleStore-DyNXBcUK.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-u_tM-mtg.js +0 -204
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/utils-CEaq_c-A.mjs +0 -97
- package/dist/utils-CEaq_c-A.mjs.map +0 -1
- package/dist/utils-CWNHx4EC.js +0 -170
- package/dist/utils-CWNHx4EC.js.map +0 -1
- package/dist/utils-D7FAOyg6.js.map +0 -1
- package/dist/value-BR4e2MKt.js +0 -910
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
- package/dist/valueRef-lshFk1Cs.js +0 -16
- package/dist/valueRef-lshFk1Cs.js.map +0 -1
- package/dist/webpack-Dh6lox2l.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
preserveResultProps?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type JsxCssPropInput = Record<PropertyKey, unknown>;
|
|
14
|
+
|
|
15
|
+
export type GetClassNameFn = (
|
|
16
|
+
styleProp: StyleProp,
|
|
17
|
+
props?: ClassNameProps,
|
|
18
|
+
) => ClassNameResult;
|
|
19
|
+
|
|
20
|
+
export function createMergeJsxProps(
|
|
21
|
+
getClassName: GetClassNameFn,
|
|
22
|
+
options: JsxCssPropMergeOptions,
|
|
23
|
+
) {
|
|
24
|
+
return function mergeJsxProps(parts: readonly unknown[]) {
|
|
25
|
+
let props: JsxCssPropInput | null = null;
|
|
26
|
+
let cssProps: StyleProp[] | null = null;
|
|
27
|
+
|
|
28
|
+
for (let index = 0; index < parts.length; index++) {
|
|
29
|
+
const result = mergePart(props, parts[index]);
|
|
30
|
+
props = result.props;
|
|
31
|
+
|
|
32
|
+
if (result.css) {
|
|
33
|
+
if (!cssProps) cssProps = [];
|
|
34
|
+
cssProps.push(result.css);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return mergeCssProps(props ?? {}, cssProps, getClassName, options);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function mergePart(
|
|
43
|
+
props: JsxCssPropInput | null,
|
|
44
|
+
part: unknown,
|
|
45
|
+
) {
|
|
46
|
+
if (!part) return { css: null, props };
|
|
47
|
+
|
|
48
|
+
const next = props ? { ...props } : {};
|
|
49
|
+
const attrs = part as JsxCssPropInput;
|
|
50
|
+
const css = attrs.css;
|
|
51
|
+
|
|
52
|
+
for (const key in attrs) {
|
|
53
|
+
if (key !== 'css') next[key] = attrs[key];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
css: css ? css as StyleProp : null,
|
|
58
|
+
props: next,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function mergeCssProps(
|
|
63
|
+
props: JsxCssPropInput,
|
|
64
|
+
cssProps: StyleProp[] | null,
|
|
65
|
+
getClassName: GetClassNameFn,
|
|
66
|
+
options: JsxCssPropMergeOptions,
|
|
67
|
+
) {
|
|
68
|
+
if (!cssProps?.length) return props;
|
|
69
|
+
|
|
70
|
+
const className = getClassName(cssProps.length === 1 ? cssProps[0] : cssProps, {
|
|
71
|
+
className: getClassValue(props, options.classProp),
|
|
72
|
+
style: props[options.styleProp] as ClassNameProps['style'],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
delete props.class;
|
|
76
|
+
delete props.className;
|
|
77
|
+
|
|
78
|
+
if (className.className !== undefined) {
|
|
79
|
+
props[options.classProp] = className.className;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (className.style !== undefined) {
|
|
83
|
+
props[options.styleProp] = options.styleMode === 'solid'
|
|
84
|
+
? toSolidStyle(className.style as Record<string, unknown>)
|
|
85
|
+
: className.style;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.preserveResultProps) {
|
|
89
|
+
for (const key in className) {
|
|
90
|
+
if (key === 'className' || key === 'style') continue;
|
|
91
|
+
|
|
92
|
+
props[key] = className[key as keyof ClassNameResult];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return props;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getClassValue(
|
|
100
|
+
props: JsxCssPropInput,
|
|
101
|
+
classProp: 'class' | 'className',
|
|
102
|
+
) {
|
|
103
|
+
return (props[classProp] ?? props[classProp === 'class' ? 'className' : 'class']) as ClassNameProps['className'];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function toSolidStyle(style: Record<string, unknown>) {
|
|
107
|
+
const next: Record<string, unknown> = {};
|
|
108
|
+
|
|
109
|
+
for (const key in style) {
|
|
110
|
+
next[toCssPropertyName(key)] = style[key];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return next;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function toCssPropertyName(key: string) {
|
|
117
|
+
if (key.startsWith('--') || key.includes('-')) return key;
|
|
118
|
+
|
|
119
|
+
return key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
120
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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,13 +10,14 @@ 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
|
|
|
18
17
|
export type CombinedStylePool = {
|
|
19
18
|
get<Styles extends object>(
|
|
20
19
|
styles: Styles,
|
|
21
|
-
inheritedScopes: readonly (ScopeTargetData
|
|
20
|
+
inheritedScopes: readonly (ScopeTargetData | Falsy)[],
|
|
22
21
|
items: readonly (StyleItem | Falsy)[],
|
|
23
22
|
prevTokensData?: StyleTokenValues | null,
|
|
24
23
|
): CombinedStylePoolResult<Styles>;
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ import type { ThemeData } from '../../../builder/data/data';
|
|
|
2
2
|
import {
|
|
3
3
|
isScopeData,
|
|
4
4
|
isScopeTargetData,
|
|
5
|
+
isSheetData,
|
|
5
6
|
isSlotData,
|
|
6
7
|
isSlotOverrideData,
|
|
7
8
|
isStyleData,
|
|
@@ -15,15 +16,15 @@ import { isStyleTokenOverrideData } from '../../../style/token';
|
|
|
15
16
|
import type { StyleProp } from '../../types';
|
|
16
17
|
import { isElementDebugData, splitElementMarkerStyleProp } from '../elementMarkerData';
|
|
17
18
|
import {
|
|
18
|
-
createResolvedStyleItem,
|
|
19
19
|
createResolvedStyleItemFromItems,
|
|
20
|
-
getDirectStyleItem,
|
|
21
20
|
getStyleTokenValues,
|
|
22
21
|
isResolvedStyleItem,
|
|
23
22
|
type ResolvedStyleItem,
|
|
24
23
|
} from './item';
|
|
24
|
+
import { createResolvedStyleItemWithResolver, getDirectStyleItemWithResolver } from './itemWithResolver';
|
|
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,10 +198,10 @@ 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
|
-
if (isStyleData(bound.data) || isSlotData(bound.data)) {
|
|
203
|
-
return
|
|
203
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) {
|
|
204
|
+
return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
return normalizeStylePropItem(bound.data, false);
|
|
@@ -210,8 +211,8 @@ function normalizeStylePropItem(
|
|
|
210
211
|
return item;
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
if (isStyleData(item) || isSlotData(item)) {
|
|
214
|
-
return
|
|
214
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) {
|
|
215
|
+
return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
return null;
|
|
@@ -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 });
|
|
@@ -237,6 +238,7 @@ function getStylePropCacheKey(
|
|
|
237
238
|
isResolvedStyleItem(item) ||
|
|
238
239
|
isThemeData(item) ||
|
|
239
240
|
isStyleData(item) ||
|
|
241
|
+
isSheetData(item) ||
|
|
240
242
|
isSlotData(item)
|
|
241
243
|
) {
|
|
242
244
|
return item;
|