@fluentic/style 0.1.0-beta.0 → 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 +154 -0
- 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 +173 -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-DweanHoB.mjs → compiler-C3CEGGtI.mjs} +2349 -647
- 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 +634 -713
- 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-DS61nRqr.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-B9kqEb2N.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/presets-DSanixJV.js +243 -0
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-CyIj8LYK.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-CyIj8LYK.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 +2 -3
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CCpq1zqA.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CCpq1zqA.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-BAL9peIw.cjs → shared-PK52rW6T.cjs} +2352 -644
- 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-4u6GnlQG.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-4u6GnlQG.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-DMFgOOtA.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-DMFgOOtA.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-CxS2FDYU.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 +118 -18
- 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 +12 -7
- 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/selector/assert.ts +24 -25
- package/selector/selector.ts +6 -0
- 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-h_Zkqc4E.js +0 -105
- package/dist/assert-h_Zkqc4E.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-DweanHoB.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-_te7t0M4.js +0 -473
- package/dist/data-_te7t0M4.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-DS61nRqr.mjs.map +0 -1
- package/dist/misc-B9kqEb2N.mjs.map +0 -1
- package/dist/presets-Bye3ea2x.js +0 -139
- package/dist/presets-Bye3ea2x.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-BAL9peIw.cjs.map +0 -1
- package/dist/style-4rFUy-zW.js +0 -752
- package/dist/style-4rFUy-zW.js.map +0 -1
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-Cw3NtvR0.js +0 -5
- package/dist/style-DNqQ6H-7.js +0 -1255
- package/dist/style-DNqQ6H-7.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-C7xfDxtM.mjs +0 -97
- package/dist/utils-C7xfDxtM.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-CxS2FDYU.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -53,7 +53,7 @@ export function createStylePropResult(
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (!classNames.length) return emptyStylePropResult;
|
|
56
|
+
if (!classNames.length && !style) return emptyStylePropResult;
|
|
57
57
|
|
|
58
58
|
return {
|
|
59
59
|
className: classNames.join(' '),
|
|
@@ -70,7 +70,7 @@ function addItem(
|
|
|
70
70
|
const dedupe = getStateItemDedupe(item);
|
|
71
71
|
const className = getStateItemClassName(item);
|
|
72
72
|
|
|
73
|
-
if (!dedupe || !className) return style;
|
|
73
|
+
if (!dedupe || !className) return addItemStyle(style, item, tokens);
|
|
74
74
|
|
|
75
75
|
if (dedupeRun[dedupe] === runId) {
|
|
76
76
|
classNames[dedupeIndex[dedupe]] = className;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getTokenVar, getTokenVarName } from '../../../atomic/token';
|
|
1
|
+
import { getTokenOverrideValue, getTokenVar, getTokenVarName } from '../../../atomic/token';
|
|
2
2
|
import {
|
|
3
3
|
BUILDER_TYPE_SCOPE,
|
|
4
|
+
BUILDER_TYPE_SHEET,
|
|
4
5
|
BUILDER_TYPE_SLOT,
|
|
5
6
|
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
6
7
|
BUILDER_TYPE_STYLE,
|
|
@@ -20,6 +21,7 @@ export function getStateItemDedupe(item: StateItem) {
|
|
|
20
21
|
if (typeof item[0] === 'number') {
|
|
21
22
|
switch (item[0]) {
|
|
22
23
|
case BUILDER_TYPE_STYLE:
|
|
24
|
+
case BUILDER_TYPE_SHEET:
|
|
23
25
|
return item[1];
|
|
24
26
|
case BUILDER_TYPE_SLOT:
|
|
25
27
|
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
@@ -43,6 +45,7 @@ export function getStateItemClassName(item: StateItem) {
|
|
|
43
45
|
if (typeof item[0] === 'number') {
|
|
44
46
|
switch (item[0]) {
|
|
45
47
|
case BUILDER_TYPE_STYLE:
|
|
48
|
+
case BUILDER_TYPE_SHEET:
|
|
46
49
|
return item[2];
|
|
47
50
|
case BUILDER_TYPE_SLOT:
|
|
48
51
|
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
@@ -65,6 +68,17 @@ export function getStateItemVariableValue(
|
|
|
65
68
|
item: StateItem,
|
|
66
69
|
tokens: StyleTokenValues | null,
|
|
67
70
|
): [string, unknown] | null {
|
|
71
|
+
if (isStyleTokenOverrideData(item)) {
|
|
72
|
+
const id = getStyleTokenId(item);
|
|
73
|
+
|
|
74
|
+
return [
|
|
75
|
+
getTokenVarName(item, CSS_CONFIG.tokenNameFormat ?? null),
|
|
76
|
+
tokens && hasOwn(tokens.lookup, id)
|
|
77
|
+
? tokens.lookup[id]
|
|
78
|
+
: getTokenOverrideValue(item, CSS_CONFIG.tokenNameFormat ?? null),
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
const value = getStateItemValue(item);
|
|
69
83
|
|
|
70
84
|
if (Array.isArray(value) && value[0] === ITEM_VALUE_TYPE_VARIABLE) {
|
|
@@ -163,6 +177,7 @@ function getStateItemValue(item: StateItem) {
|
|
|
163
177
|
if (typeof item[0] === 'number') {
|
|
164
178
|
switch (item[0]) {
|
|
165
179
|
case BUILDER_TYPE_STYLE:
|
|
180
|
+
case BUILDER_TYPE_SHEET:
|
|
166
181
|
return item[3];
|
|
167
182
|
case BUILDER_TYPE_SLOT:
|
|
168
183
|
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getTokenOverrideValue } from '../../../atomic/token';
|
|
2
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
+
import { getStyleTokenId, isStyleTokenOverrideData } from '../../../style/token';
|
|
4
|
+
import type { TokenValueResolver } from './tokenValues';
|
|
5
|
+
|
|
6
|
+
export const runtimeTokenValueResolver: TokenValueResolver = {
|
|
7
|
+
get key() {
|
|
8
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
is: isStyleTokenOverrideData,
|
|
12
|
+
|
|
13
|
+
id(token) {
|
|
14
|
+
return getStyleTokenId(token);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
value(token) {
|
|
18
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
-
import { getStyleTokenId, isStyleTokenOverrideData, type StyleTokenOverride } from '../../../style/token';
|
|
1
|
+
import type { StyleTokenOverride } from '../../../style/token';
|
|
4
2
|
import { hasOwn } from '../../../utils/object';
|
|
5
3
|
|
|
6
4
|
export type StyleTokenValues = {
|
|
@@ -16,6 +14,13 @@ export type MutableTokenValues = {
|
|
|
16
14
|
index: Record<string, number> | null;
|
|
17
15
|
};
|
|
18
16
|
|
|
17
|
+
export type TokenValueResolver = {
|
|
18
|
+
key: unknown;
|
|
19
|
+
is(item: unknown): item is StyleTokenOverride;
|
|
20
|
+
id(token: StyleTokenOverride): string;
|
|
21
|
+
value(token: StyleTokenOverride): unknown;
|
|
22
|
+
};
|
|
23
|
+
|
|
19
24
|
export function createMutableTokenValues(base: StyleTokenValues | null): MutableTokenValues {
|
|
20
25
|
return {
|
|
21
26
|
ids: base ? base.ids.slice() : null,
|
|
@@ -25,13 +30,14 @@ export function createMutableTokenValues(base: StyleTokenValues | null): Mutable
|
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
export function addTokenOverride(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
export function addTokenOverride(
|
|
34
|
+
values: MutableTokenValues,
|
|
35
|
+
item: unknown,
|
|
36
|
+
resolver: TokenValueResolver,
|
|
37
|
+
) {
|
|
38
|
+
if (!resolver.is(item)) return false;
|
|
33
39
|
|
|
34
|
-
addTokenValue(values, id, value);
|
|
40
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
35
41
|
return true;
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -75,9 +81,10 @@ export function addTokenValues(
|
|
|
75
81
|
export function addTokenOverrides(
|
|
76
82
|
values: MutableTokenValues,
|
|
77
83
|
overrides: readonly StyleTokenOverride[],
|
|
84
|
+
resolver: TokenValueResolver,
|
|
78
85
|
) {
|
|
79
86
|
for (let i = 0, len = overrides.length; i < len; i++) {
|
|
80
|
-
addTokenOverride(values, overrides[i]);
|
|
87
|
+
addTokenOverride(values, overrides[i], resolver);
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -112,12 +119,13 @@ export function mergeTokenValues(
|
|
|
112
119
|
export function mergeTokenOverrides(
|
|
113
120
|
base: StyleTokenValues | null,
|
|
114
121
|
overrides: readonly StyleTokenOverride[],
|
|
122
|
+
resolver: TokenValueResolver,
|
|
115
123
|
): StyleTokenValues | null {
|
|
116
124
|
if (!overrides.length) return base;
|
|
117
125
|
|
|
118
126
|
const values = createMutableTokenValues(base);
|
|
119
127
|
|
|
120
|
-
addTokenOverrides(values, overrides);
|
|
128
|
+
addTokenOverrides(values, overrides, resolver);
|
|
121
129
|
|
|
122
130
|
return finishTokenValues(base, values);
|
|
123
131
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ScopeTargetData } from '../../builder/data';
|
|
2
|
-
import type { SlotData, StyleData } from '../../builder/data';
|
|
1
|
+
import type { ScopeTargetData, SelectorData, SheetData, SlotData, StyleData } from '../../builder/data';
|
|
3
2
|
import { globalData } from '../../utils/global';
|
|
4
3
|
import { hasOwn } from '../../utils/object';
|
|
5
4
|
import type { ResolvedStyleItem } from './cache/item';
|
|
@@ -92,8 +91,9 @@ function getTarget(value: object): CombinedStyleTarget {
|
|
|
92
91
|
return target;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
type InferValue<Value> = Value extends StyleData | SlotData ? ResolvedStyleItem<Value>
|
|
96
|
-
: Value extends
|
|
94
|
+
type InferValue<Value> = Value extends StyleData | SheetData | SlotData ? ResolvedStyleItem<Value>
|
|
95
|
+
: Value extends SelectorData ? Value
|
|
96
|
+
: Value extends object ? CombinedStyle<Value>
|
|
97
97
|
: Value;
|
|
98
98
|
|
|
99
99
|
type InferData<Styles> = unknown extends Styles ? {}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { SheetData, SlotData, StyleData } from '../../builder/data/data';
|
|
2
|
+
import { isSheetData, isSlotData, isStyleData } from '../../builder/data/is';
|
|
3
|
+
import { type CombinedStyleArg, createCombinedStyleGetter } from '../core/cache/combine';
|
|
4
|
+
import type { CombinedStyle } from '../core/combinedStyle';
|
|
5
|
+
import type { StyleProp } from '../types';
|
|
6
|
+
import { extractedTokenValueResolver } from './tokenResolver';
|
|
7
|
+
|
|
8
|
+
export type StyleCombiner<T extends object> = (
|
|
9
|
+
...args: CombinedStyleArg<T>[]
|
|
10
|
+
) => CombinedStyle<T>;
|
|
11
|
+
|
|
12
|
+
export type CombinedStyleFor<T extends object | StyleCombiner<any>> = CombinedStyleArg<InferStyleCombinerStyles<T>>;
|
|
13
|
+
|
|
14
|
+
type InferStyleCombinerStyles<T extends object | StyleCombiner<any>> = T extends StyleCombiner<infer Styles> ? Styles
|
|
15
|
+
: T extends object ? T
|
|
16
|
+
: never;
|
|
17
|
+
|
|
18
|
+
type SingleStyleItem = StyleData | SheetData | SlotData;
|
|
19
|
+
type DirectStyleItem =
|
|
20
|
+
| SingleStyleItem
|
|
21
|
+
| false
|
|
22
|
+
| null
|
|
23
|
+
| undefined
|
|
24
|
+
| readonly DirectStyleItem[];
|
|
25
|
+
|
|
26
|
+
type CombineStyleFn = {
|
|
27
|
+
(style: SingleStyleItem, ...args: CombinedStyleArg<any>[]): StyleProp;
|
|
28
|
+
(styles: readonly DirectStyleItem[], ...args: CombinedStyleArg<any>[]): StyleProp;
|
|
29
|
+
<T extends object>(styles: T, ...args: CombinedStyleArg<T>[]): CombinedStyle<T>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type StyleWithCombiner = {
|
|
33
|
+
(style: SingleStyleItem): StyleProp;
|
|
34
|
+
<T extends object>(styles: T): CombinedStyle<T>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type CombineStyle = CombineStyleFn & {
|
|
38
|
+
for<T extends object>(styles: T): StyleCombiner<T>;
|
|
39
|
+
with(...args: CombinedStyleArg<any>[]): StyleWithCombiner;
|
|
40
|
+
multi<T extends readonly SingleStyleItem[]>(
|
|
41
|
+
styles: T,
|
|
42
|
+
...args: CombinedStyleArg<any>[]
|
|
43
|
+
): { [P in keyof T]: StyleProp; };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type StyleWithArgs = {
|
|
47
|
+
combineArgs: CombinedStyleArg<any>[];
|
|
48
|
+
styles: SingleStyleItem[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const singleStyleWrappers = new WeakMap<SingleStyleItem, { value: SingleStyleItem; }>();
|
|
52
|
+
|
|
53
|
+
const combineStyleBase = <T extends object>(
|
|
54
|
+
styles: T,
|
|
55
|
+
...args: CombinedStyleArg<T>[]
|
|
56
|
+
): CombinedStyle<T> => getExtractedCombinedStyle(styles, args);
|
|
57
|
+
|
|
58
|
+
const combineStyleResolve = ((
|
|
59
|
+
styles: object,
|
|
60
|
+
...args: CombinedStyleArg<any>[]
|
|
61
|
+
) => {
|
|
62
|
+
if (Array.isArray(styles)) return combineStyleArray(styles, collectStyleWithArgs(args));
|
|
63
|
+
|
|
64
|
+
return isSingleStyleItem(styles)
|
|
65
|
+
? combineStyleSingle(styles, collectStyleWithArgs(args))
|
|
66
|
+
: combineStyleBase(styles, ...args);
|
|
67
|
+
}) as CombineStyleFn;
|
|
68
|
+
|
|
69
|
+
const combineStyleFor = <T extends object>(styles: T): StyleCombiner<T> => {
|
|
70
|
+
return (...args: CombinedStyleArg<T>[]) => combineStyleBase(styles, ...args);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const combineStyleWith = (...args: CombinedStyleArg<any>[]): StyleWithCombiner => {
|
|
74
|
+
const withArgs = collectStyleWithArgs(args);
|
|
75
|
+
|
|
76
|
+
return ((styles: object) => {
|
|
77
|
+
return isSingleStyleItem(styles)
|
|
78
|
+
? combineStyleSingle(styles, withArgs)
|
|
79
|
+
: combineStyleBase(styles, ...withArgs.combineArgs);
|
|
80
|
+
}) as StyleWithCombiner;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const combineStyleMulti = <T extends readonly SingleStyleItem[]>(
|
|
84
|
+
styles: T,
|
|
85
|
+
...args: CombinedStyleArg<any>[]
|
|
86
|
+
): { [P in keyof T]: StyleProp; } => {
|
|
87
|
+
const withArgs = collectStyleWithArgs(args);
|
|
88
|
+
|
|
89
|
+
return styles.map((style) => combineStyleSingle(style, withArgs)) as { [P in keyof T]: StyleProp; };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function combineStyleSingle(
|
|
93
|
+
style: SingleStyleItem,
|
|
94
|
+
args: StyleWithArgs,
|
|
95
|
+
): StyleProp {
|
|
96
|
+
const result = combineStyleSingleItem(style, args.combineArgs);
|
|
97
|
+
|
|
98
|
+
if (!args.styles.length) return result;
|
|
99
|
+
|
|
100
|
+
const styles: StyleProp[] = [result];
|
|
101
|
+
|
|
102
|
+
for (let i = 0, len = args.styles.length; i < len; i++) {
|
|
103
|
+
styles.push(combineStyleSingleItem(args.styles[i], args.combineArgs));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return styles;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function combineStyleArray(
|
|
110
|
+
styles: readonly DirectStyleItem[],
|
|
111
|
+
args: StyleWithArgs,
|
|
112
|
+
): StyleProp {
|
|
113
|
+
const result: StyleProp[] = [];
|
|
114
|
+
|
|
115
|
+
collectDirectStyles(styles, result, args);
|
|
116
|
+
|
|
117
|
+
for (let i = 0, len = args.styles.length; i < len; i++) {
|
|
118
|
+
result.push(combineStyleSingleItem(args.styles[i], args.combineArgs));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function collectDirectStyles(
|
|
125
|
+
styles: readonly DirectStyleItem[],
|
|
126
|
+
result: StyleProp[],
|
|
127
|
+
args: StyleWithArgs,
|
|
128
|
+
) {
|
|
129
|
+
for (let i = 0, len = styles.length; i < len; i++) {
|
|
130
|
+
const style = styles[i];
|
|
131
|
+
|
|
132
|
+
if (!style) continue;
|
|
133
|
+
|
|
134
|
+
if (Array.isArray(style)) {
|
|
135
|
+
collectDirectStyles(style, result, args);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (isSingleStyleItem(style)) {
|
|
140
|
+
result.push(combineStyleSingleItem(style, args.combineArgs));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function combineStyleSingleItem(
|
|
146
|
+
style: SingleStyleItem,
|
|
147
|
+
args: readonly CombinedStyleArg<any>[],
|
|
148
|
+
): StyleProp {
|
|
149
|
+
const wrapper = getSingleStyleWrapper(style);
|
|
150
|
+
|
|
151
|
+
return combineStyleBase<{ value: SingleStyleItem; }>(
|
|
152
|
+
wrapper,
|
|
153
|
+
...(args as CombinedStyleArg<{ value: SingleStyleItem; }>[]),
|
|
154
|
+
).value as StyleProp;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getSingleStyleWrapper(style: SingleStyleItem) {
|
|
158
|
+
let wrapper = singleStyleWrappers.get(style);
|
|
159
|
+
|
|
160
|
+
if (!wrapper) {
|
|
161
|
+
wrapper = { value: style };
|
|
162
|
+
singleStyleWrappers.set(style, wrapper);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return wrapper;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function isSingleStyleItem(value: object): value is SingleStyleItem {
|
|
169
|
+
return isStyleData(value) || isSheetData(value) || isSlotData(value);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function collectStyleWithArgs(args: readonly CombinedStyleArg<any>[]) {
|
|
173
|
+
const result: StyleWithArgs = {
|
|
174
|
+
combineArgs: [],
|
|
175
|
+
styles: [],
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
collectArgs(args, result);
|
|
179
|
+
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function collectArgs(
|
|
184
|
+
args: readonly CombinedStyleArg<any>[],
|
|
185
|
+
result: StyleWithArgs,
|
|
186
|
+
) {
|
|
187
|
+
for (let i = 0, len = args.length; i < len; i++) {
|
|
188
|
+
const arg = args[i];
|
|
189
|
+
|
|
190
|
+
if (!arg) continue;
|
|
191
|
+
|
|
192
|
+
if (Array.isArray(arg)) {
|
|
193
|
+
collectArgs(arg, result);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
result.combineArgs.push(arg);
|
|
198
|
+
|
|
199
|
+
if (isSingleStyleItem(arg)) {
|
|
200
|
+
result.styles.push(arg);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export const combineStyle = Object.assign(combineStyleResolve, {
|
|
206
|
+
for: combineStyleFor,
|
|
207
|
+
with: combineStyleWith,
|
|
208
|
+
multi: combineStyleMulti,
|
|
209
|
+
}) as CombineStyle;
|
|
210
|
+
|
|
211
|
+
const getExtractedCombinedStyle = createCombinedStyleGetter(extractedTokenValueResolver);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getTokenVar as getAtomicTokenVar, getTokenVarName as getAtomicTokenVarName } from '../../atomic/token';
|
|
2
1
|
import {
|
|
3
2
|
BUILDER_STATE,
|
|
4
3
|
BUILDER_TYPE,
|
|
4
|
+
BUILDER_TYPE_SHEET,
|
|
5
5
|
BUILDER_TYPE_SLOT,
|
|
6
6
|
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
7
7
|
BUILDER_TYPE_STYLE,
|
|
@@ -12,25 +12,15 @@ import {
|
|
|
12
12
|
} from '../../builder/data/const';
|
|
13
13
|
import type { StateItem } from '../../builder/data/state';
|
|
14
14
|
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../builder/extract/withTokens';
|
|
15
|
-
import {
|
|
15
|
+
import { getStyleTokenId, isStyleTokenData, isStyleTokenOverrideData } from '../../builder/token/data';
|
|
16
16
|
import { RUNTIME_CONFIG } from '../../config/config/runtime';
|
|
17
|
-
import {
|
|
18
|
-
getStyleTokenId,
|
|
19
|
-
isStyleTokenData,
|
|
20
|
-
isStyleTokenOverrideData,
|
|
21
|
-
type StyleTokenData,
|
|
22
|
-
type StyleTokenOverride,
|
|
23
|
-
} from '../../style/token';
|
|
17
|
+
import type { StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
24
18
|
import { getStylePropCacheValue } from '../core/cache/propCache';
|
|
25
19
|
import { getResolvedStyleItemTokenValues, isResolvedStyleItem } from '../core/cache/resolvedItem';
|
|
26
20
|
import { walkRecursiveItems } from '../core/cache/utils/walk';
|
|
27
|
-
import {
|
|
28
|
-
type ClassNameProps,
|
|
29
|
-
type ClassNameResult,
|
|
30
|
-
mergeClassName,
|
|
31
|
-
mergeStyle,
|
|
32
|
-
} from '../core/className';
|
|
21
|
+
import { type ClassNameProps, type ClassNameResult, mergeClassName, mergeStyle } from '../core/className';
|
|
33
22
|
import type { StyleProp } from '../types';
|
|
23
|
+
import { getExtractedTokenVar, getExtractedTokenVarName } from './token';
|
|
34
24
|
|
|
35
25
|
type TokenValues = Record<string, unknown> | null;
|
|
36
26
|
|
|
@@ -240,7 +230,7 @@ function resolveExtractedStylePropUncached(
|
|
|
240
230
|
style = appendExtractedData(classNames, style, item, null, collectedItems, ignoreTokenStyle);
|
|
241
231
|
}
|
|
242
232
|
|
|
243
|
-
if (!classNames.length) return null;
|
|
233
|
+
if (!classNames.length && !style) return null;
|
|
244
234
|
|
|
245
235
|
return {
|
|
246
236
|
className: classNames.join(' '),
|
|
@@ -281,11 +271,13 @@ function appendExtractedData(
|
|
|
281
271
|
return style;
|
|
282
272
|
}
|
|
283
273
|
|
|
284
|
-
if (type !== BUILDER_TYPE_STYLE && type !== BUILDER_TYPE_SLOT) return style;
|
|
274
|
+
if (type !== BUILDER_TYPE_STYLE && type !== BUILDER_TYPE_SHEET && type !== BUILDER_TYPE_SLOT) return style;
|
|
285
275
|
|
|
286
276
|
const items = (data as { [BUILDER_STATE]?: { items?: StateItem[]; }; })[BUILDER_STATE]?.items;
|
|
287
277
|
if (!items) return style;
|
|
288
278
|
|
|
279
|
+
tokens = mergeTokenValuesFromItems(tokens, items);
|
|
280
|
+
|
|
289
281
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
290
282
|
collectedItems?.push(items[i]);
|
|
291
283
|
style = addStateItem(classNames, style, items[i], tokens);
|
|
@@ -294,6 +286,35 @@ function appendExtractedData(
|
|
|
294
286
|
return style;
|
|
295
287
|
}
|
|
296
288
|
|
|
289
|
+
function mergeTokenValuesFromItems(
|
|
290
|
+
tokens: TokenValues,
|
|
291
|
+
items: readonly StateItem[],
|
|
292
|
+
): TokenValues {
|
|
293
|
+
let next = tokens;
|
|
294
|
+
|
|
295
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
296
|
+
const item = items[i];
|
|
297
|
+
if (!isStyleTokenOverrideData(item)) continue;
|
|
298
|
+
|
|
299
|
+
next = mergeTokenValues(next, createTokenValues([item]));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return next;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function mergeTokenValues(
|
|
306
|
+
base: TokenValues,
|
|
307
|
+
next: TokenValues,
|
|
308
|
+
): TokenValues {
|
|
309
|
+
if (!next) return base;
|
|
310
|
+
if (!base) return next;
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
...base,
|
|
314
|
+
...next,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
297
318
|
function resolveExtractedStateItemTokens(
|
|
298
319
|
data: ExtractedStylePropCacheData,
|
|
299
320
|
tokens: TokenValues,
|
|
@@ -335,7 +356,7 @@ function addStateItem(
|
|
|
335
356
|
const dedupe = getStateItemDedupe(item);
|
|
336
357
|
const className = getStateItemClassName(item);
|
|
337
358
|
|
|
338
|
-
if (!dedupe || !className) return style;
|
|
359
|
+
if (!dedupe || !className) return addStateItemStyle(style, item, tokens);
|
|
339
360
|
|
|
340
361
|
if (dedupeRun[dedupe] === runId) {
|
|
341
362
|
classNames[dedupeIndex[dedupe]] = className;
|
|
@@ -352,6 +373,17 @@ function addStateItemStyle(
|
|
|
352
373
|
item: StateItem,
|
|
353
374
|
tokens: TokenValues,
|
|
354
375
|
) {
|
|
376
|
+
if (isStyleTokenOverrideData(item)) {
|
|
377
|
+
const id = getStyleTokenId(item);
|
|
378
|
+
const value = tokens && tokens[id] !== undefined
|
|
379
|
+
? tokens[id]
|
|
380
|
+
: item.ref
|
|
381
|
+
? getTokenVar(item.ref)
|
|
382
|
+
: item.value;
|
|
383
|
+
|
|
384
|
+
return setStyleValue(style, getTokenVarName(item), value);
|
|
385
|
+
}
|
|
386
|
+
|
|
355
387
|
const value = getStateItemValue(item);
|
|
356
388
|
|
|
357
389
|
if (Array.isArray(value)) {
|
|
@@ -383,7 +415,7 @@ function addStateItemStyle(
|
|
|
383
415
|
function getStateItemDedupe(item: StateItem) {
|
|
384
416
|
if (Array.isArray(item)) {
|
|
385
417
|
return typeof item[0] === 'number'
|
|
386
|
-
? item[0] === BUILDER_TYPE_STYLE ? item[1] : item[2]
|
|
418
|
+
? item[0] === BUILDER_TYPE_STYLE || item[0] === BUILDER_TYPE_SHEET ? item[1] : item[2]
|
|
387
419
|
: item[0];
|
|
388
420
|
}
|
|
389
421
|
|
|
@@ -393,7 +425,7 @@ function getStateItemDedupe(item: StateItem) {
|
|
|
393
425
|
function getStateItemClassName(item: StateItem) {
|
|
394
426
|
if (Array.isArray(item)) {
|
|
395
427
|
return typeof item[0] === 'number'
|
|
396
|
-
? item[0] === BUILDER_TYPE_STYLE ? item[2] : item[3]
|
|
428
|
+
? item[0] === BUILDER_TYPE_STYLE || item[0] === BUILDER_TYPE_SHEET ? item[2] : item[3]
|
|
397
429
|
: item[1];
|
|
398
430
|
}
|
|
399
431
|
|
|
@@ -404,7 +436,7 @@ function getStateItemValue(item: StateItem) {
|
|
|
404
436
|
if (!Array.isArray(item)) return undefined;
|
|
405
437
|
|
|
406
438
|
if (typeof item[0] !== 'number') return item[2];
|
|
407
|
-
if (item[0] === BUILDER_TYPE_STYLE) return item[3];
|
|
439
|
+
if (item[0] === BUILDER_TYPE_STYLE || item[0] === BUILDER_TYPE_SHEET) return item[3];
|
|
408
440
|
if (item[0] === BUILDER_TYPE_SLOT || item[0] === BUILDER_TYPE_SLOT_OVERRIDE) return item[4];
|
|
409
441
|
|
|
410
442
|
return undefined;
|
|
@@ -458,11 +490,11 @@ function mergeResolvedTokenValues(
|
|
|
458
490
|
}
|
|
459
491
|
|
|
460
492
|
function getTokenVarName(token: StyleTokenData | StyleTokenOverride) {
|
|
461
|
-
return
|
|
493
|
+
return getExtractedTokenVarName(token);
|
|
462
494
|
}
|
|
463
495
|
|
|
464
496
|
function getTokenVar(token: StyleTokenData): string {
|
|
465
|
-
return
|
|
497
|
+
return getExtractedTokenVar(token);
|
|
466
498
|
}
|
|
467
499
|
|
|
468
500
|
function setStyleValue(
|
package/runtime/extract/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { CombinedStyle } from '../core/combinedStyle';
|
|
2
|
-
export { bindScope,
|
|
3
|
-
export type { StyleProp, StyleTheme, StyleTokenInput } from '../types';
|
|
2
|
+
export { bindScope, combineScope } from '../style/scope';
|
|
3
|
+
export type { StyleProp, StyleTheme, StyleTokenInput, TokenTheme } from '../types';
|
|
4
|
+
export { type CombinedStyleFor, combineStyle } from './combineStyle';
|
|
4
5
|
export { type ClassNameProps, type ClassNameResult, getClassName, mergeClassName, mergeStyle } from './getClassName';
|
|
6
|
+
export { getToken } from './token';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getCssVar, getCssVarRawFallback } from '../../atomic/utils/cssVar';
|
|
2
|
+
import { getStyleTokenId, getStyleTokenVarName, isStyleTokenData } from '../../builder/token/data';
|
|
3
|
+
import type { StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
4
|
+
|
|
5
|
+
export function getToken(value: unknown): unknown {
|
|
6
|
+
if (isStyleTokenData(value)) {
|
|
7
|
+
return getExtractedTokenVar(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getExtractedTokenVarName(
|
|
14
|
+
token: StyleTokenData | StyleTokenOverride,
|
|
15
|
+
) {
|
|
16
|
+
const varName = getStyleTokenVarName(token);
|
|
17
|
+
if (varName) return varName;
|
|
18
|
+
|
|
19
|
+
throw new Error(`Missing extracted token var name for token "${getStyleTokenId(token)}"`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getExtractedTokenVar(token: StyleTokenData): string {
|
|
23
|
+
return getExtractedTokenVarFallback(token);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getExtractedTokenOverrideValue(token: StyleTokenOverride) {
|
|
27
|
+
return token.ref ? getExtractedTokenVar(token.ref) : token.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getExtractedTokenVarFallback(token: StyleTokenData): string {
|
|
31
|
+
const varName = getExtractedTokenVarName(token);
|
|
32
|
+
|
|
33
|
+
if (token.ref) {
|
|
34
|
+
return getCssVarRawFallback(
|
|
35
|
+
varName,
|
|
36
|
+
getExtractedTokenVarFallback(token.ref),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return getCssVar(varName, String(token.value ?? ''));
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getStyleTokenId, isStyleTokenOverrideData } from '../../builder/token/data';
|
|
2
|
+
import type { TokenValueResolver } from '../core/cache/tokenValues';
|
|
3
|
+
import { getExtractedTokenOverrideValue } from './token';
|
|
4
|
+
|
|
5
|
+
export const extractedTokenValueResolver: TokenValueResolver = {
|
|
6
|
+
key: null,
|
|
7
|
+
|
|
8
|
+
is: isStyleTokenOverrideData,
|
|
9
|
+
|
|
10
|
+
id(token) {
|
|
11
|
+
return getStyleTokenId(token);
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
value(token) {
|
|
15
|
+
return getExtractedTokenOverrideValue(token);
|
|
16
|
+
},
|
|
17
|
+
};
|
package/runtime/index.ts
CHANGED
|
@@ -9,4 +9,11 @@ export {
|
|
|
9
9
|
mergeStyle,
|
|
10
10
|
} from './core';
|
|
11
11
|
export { bindScope, type CombinedStyleFor, combineScope, combineStyle } from './style';
|
|
12
|
-
export type {
|
|
12
|
+
export type {
|
|
13
|
+
DomElementProps,
|
|
14
|
+
RuntimeStyleAttributes,
|
|
15
|
+
StyleProp,
|
|
16
|
+
StyleTheme,
|
|
17
|
+
StyleTokenInput,
|
|
18
|
+
TokenTheme,
|
|
19
|
+
} from './types';
|
|
@@ -19,6 +19,8 @@ export type RscStylePayloadRule = {
|
|
|
19
19
|
key?: string | null;
|
|
20
20
|
css: string;
|
|
21
21
|
priority?: LayerPriority | null;
|
|
22
|
+
important?: boolean;
|
|
23
|
+
layer?: SheetRule['layer'];
|
|
22
24
|
callsite?: SheetRule['callsite'];
|
|
23
25
|
debug?: DebugData | null;
|
|
24
26
|
debugField?: string | null;
|
|
@@ -73,6 +75,8 @@ function createRscStylePayloadRule(rule: SheetRule): RscStylePayloadRule {
|
|
|
73
75
|
key: rule.key,
|
|
74
76
|
css: rule.css,
|
|
75
77
|
priority: rule.priority,
|
|
78
|
+
important: rule.important,
|
|
79
|
+
layer: rule.layer,
|
|
76
80
|
callsite: isElementMarkerRule(rule) ? rule.callsite : undefined,
|
|
77
81
|
debug: rule.debug ? createRscDebugPayload(rule.debug, rule.debugField) : undefined,
|
|
78
82
|
debugField: rule.debugField,
|
package/runtime/rsc/observer.ts
CHANGED
|
@@ -184,6 +184,8 @@ function normalizePayloadItem(value: unknown): SheetRule | null {
|
|
|
184
184
|
const rule = value as RscStylePayloadRule;
|
|
185
185
|
|
|
186
186
|
if (typeof rule.key !== 'string' || typeof rule.css !== 'string') return null;
|
|
187
|
+
if (rule.important !== undefined && typeof rule.important !== 'boolean') return null;
|
|
188
|
+
if (rule.layer !== undefined && rule.layer !== false && rule.layer !== 'style' && rule.layer !== 'sheet') return null;
|
|
187
189
|
if (rule.debug !== undefined && rule.debug !== null && !isDebugData(rule.debug)) return null;
|
|
188
190
|
if (rule.debugField !== undefined && rule.debugField !== null && typeof rule.debugField !== 'string') return null;
|
|
189
191
|
|
|
@@ -191,6 +193,8 @@ function normalizePayloadItem(value: unknown): SheetRule | null {
|
|
|
191
193
|
key: rule.key,
|
|
192
194
|
css: rule.css,
|
|
193
195
|
priority: rule.priority,
|
|
196
|
+
important: rule.important,
|
|
197
|
+
layer: rule.layer,
|
|
194
198
|
callsite: normalizePayloadCallsite(rule.callsite),
|
|
195
199
|
debug: rule.debug,
|
|
196
200
|
debugField: rule.debugField,
|