@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
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { getLayerBlockCss, getLayerOrderCss, joinLayerCss } from '../../atomic/layer';
|
|
2
|
-
import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../../config/config/css';
|
|
2
|
+
import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../../config/config/css';
|
|
3
3
|
import { RUNTIME_CONFIG } from '../../config/config/runtime';
|
|
4
4
|
import type { SheetRule } from '../../sheet';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createSheetLayerState,
|
|
7
|
+
getSheetLayerName,
|
|
8
|
+
getSheetLayerNames,
|
|
9
|
+
getSheetRuleLayerPriority,
|
|
10
|
+
} from '../../sheet/utils';
|
|
6
11
|
import { clearGlobalData, getGlobalData, globalData } from '../../utils/global';
|
|
7
12
|
import { IS_SERVER_RUNTIME } from '../env';
|
|
8
13
|
|
|
@@ -53,16 +58,22 @@ export function getRscStyleCss(): string {
|
|
|
53
58
|
|
|
54
59
|
const layerState = createSheetLayerState();
|
|
55
60
|
|
|
61
|
+
let hasSheetLayer = false;
|
|
56
62
|
const cssItems = store.rules.map((rule) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
const ruleLayer = rule.layer ?? 'style';
|
|
64
|
+
if (ruleLayer === 'sheet') hasSheetLayer = true;
|
|
65
|
+
const layerName = ruleLayer === 'sheet'
|
|
66
|
+
? getSheetLayerName()
|
|
67
|
+
: ruleLayer === false || !isStyleLayerEnabled()
|
|
68
|
+
? null
|
|
69
|
+
: layerState.getName(getSheetRuleLayerPriority(rule.priority, rule.important));
|
|
70
|
+
|
|
71
|
+
return layerName ? getLayerBlockCss(layerName, rule.css) : rule.css;
|
|
61
72
|
});
|
|
62
73
|
|
|
63
74
|
const layerOrderCss = getLayerOrderCss(
|
|
64
75
|
CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [],
|
|
65
|
-
layerState
|
|
76
|
+
getSheetLayerNames(layerState, hasSheetLayer),
|
|
66
77
|
);
|
|
67
78
|
|
|
68
79
|
return joinLayerCss(layerOrderCss, cssItems);
|
package/runtime/sheet/rule.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { buildAtomicRule, getAtomicRuleLayerPriority } from '../../atomic/rule';
|
|
2
|
+
import type { CreateSheetOptions } from '../../builder/data';
|
|
2
3
|
import { BUILDER_TYPE_SCOPE } from '../../builder/data/const';
|
|
3
4
|
import type { RuntimeItem, StateItem } from '../../builder/data/state';
|
|
4
|
-
import { CSS_CONFIG } from '../../config/config/css';
|
|
5
|
+
import { CSS_CONFIG, isSheetLayerEnabled } from '../../config/config/css';
|
|
5
6
|
import type { SheetRule } from '../../sheet';
|
|
6
7
|
import { isStyleTokenOverrideData } from '../../style/token';
|
|
7
8
|
import { getStateItemAtRuleRef } from '../core/cache/stateItem';
|
|
@@ -10,27 +11,22 @@ export type RuntimeSheetRule = SheetRule & {
|
|
|
10
11
|
dedupe: string;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
export function createRuntimeSheetRules(
|
|
14
|
+
export function createRuntimeSheetRules(
|
|
15
|
+
item: StateItem,
|
|
16
|
+
sheetOptions: CreateSheetOptions | null = null,
|
|
17
|
+
): RuntimeSheetRule[] | null {
|
|
14
18
|
if (Array.isArray(item)) return null;
|
|
15
19
|
if (isStyleTokenOverrideData(item)) return null;
|
|
16
20
|
|
|
17
21
|
const runtimeItem = item as RuntimeItem;
|
|
18
22
|
|
|
19
|
-
const value = Array.isArray(runtimeItem.value)
|
|
20
|
-
? runtimeItem.value[0]
|
|
21
|
-
: runtimeItem.value;
|
|
22
|
-
|
|
23
|
-
const priority = Array.isArray(runtimeItem.value)
|
|
24
|
-
? runtimeItem.value[1]
|
|
25
|
-
: null;
|
|
26
|
-
|
|
27
23
|
const parentSelector = runtimeItem.type === BUILDER_TYPE_SCOPE
|
|
28
24
|
? runtimeItem.parentSelector
|
|
29
25
|
: null;
|
|
30
26
|
|
|
31
27
|
const layerPriority = getAtomicRuleLayerPriority(
|
|
32
28
|
runtimeItem.property,
|
|
33
|
-
|
|
29
|
+
runtimeItem.weight,
|
|
34
30
|
runtimeItem.selector,
|
|
35
31
|
parentSelector,
|
|
36
32
|
runtimeItem.atRule,
|
|
@@ -40,7 +36,8 @@ export function createRuntimeSheetRules(item: StateItem): RuntimeSheetRule[] | n
|
|
|
40
36
|
const ruleCss = buildAtomicRule(
|
|
41
37
|
runtimeItem.className,
|
|
42
38
|
runtimeItem.property,
|
|
43
|
-
value,
|
|
39
|
+
runtimeItem.value,
|
|
40
|
+
runtimeItem.important,
|
|
44
41
|
runtimeItem.selector,
|
|
45
42
|
parentSelector,
|
|
46
43
|
runtimeItem.atRule,
|
|
@@ -51,6 +48,8 @@ export function createRuntimeSheetRules(item: StateItem): RuntimeSheetRule[] | n
|
|
|
51
48
|
key: runtimeItem.className,
|
|
52
49
|
dedupe: runtimeItem.dedupe,
|
|
53
50
|
priority: layerPriority,
|
|
51
|
+
important: runtimeItem.important,
|
|
52
|
+
layer: getRuntimeRuleLayer(sheetOptions),
|
|
54
53
|
css: ruleCss,
|
|
55
54
|
callsite: runtimeItem.callsite,
|
|
56
55
|
debug: runtimeItem.debug,
|
|
@@ -75,3 +74,8 @@ export function createRuntimeSheetRules(item: StateItem): RuntimeSheetRule[] | n
|
|
|
75
74
|
export function createRuntimeSheetRule(item: StateItem): RuntimeSheetRule | null {
|
|
76
75
|
return createRuntimeSheetRules(item)?.[0] ?? null;
|
|
77
76
|
}
|
|
77
|
+
|
|
78
|
+
function getRuntimeRuleLayer(sheetOptions: CreateSheetOptions | null): SheetRule['layer'] {
|
|
79
|
+
if (!sheetOptions) return 'style';
|
|
80
|
+
return (sheetOptions.layer ?? isSheetLayerEnabled()) ? 'sheet' : false;
|
|
81
|
+
}
|
package/runtime/sheet/rules.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BUILDER_CALLSITE } from '../../builder/data/const';
|
|
1
|
+
import { BUILDER_CALLSITE, BUILDER_SHEET_OPTIONS } from '../../builder/data/const';
|
|
2
2
|
import type { ThemeData } from '../../builder/data/data';
|
|
3
|
-
import { isThemeData } from '../../builder/data/is';
|
|
3
|
+
import { isSheetData, isThemeData } from '../../builder/data/is';
|
|
4
4
|
import type { SheetRule } from '../../sheet';
|
|
5
|
+
import { isResolvedStyleItem } from '../core/cache/item';
|
|
5
6
|
import { getStylePropItems, type StylePropItem, walkStyleProp } from '../core/cache/prop';
|
|
6
7
|
import type { StyleProp } from '../types';
|
|
7
8
|
import { createRuntimeSheetRules, type RuntimeSheetRule } from './rule';
|
|
@@ -38,9 +39,11 @@ function walkStylePropItemSheetRules(
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const items = getStylePropItems(item);
|
|
42
|
+
const sheetData = isResolvedStyleItem(item) && isSheetData(item.data) ? item.data : null;
|
|
43
|
+
const sheetOptions = sheetData ? sheetData[BUILDER_SHEET_OPTIONS] : null;
|
|
41
44
|
|
|
42
45
|
for (let i = 0, len = items.length; i < len; i++) {
|
|
43
|
-
const rules = createRuntimeSheetRules(items[i]);
|
|
46
|
+
const rules = createRuntimeSheetRules(items[i], sheetOptions);
|
|
44
47
|
if (!rules) continue;
|
|
45
48
|
|
|
46
49
|
for (let j = 0, len = rules.length; j < len; j++) {
|
|
@@ -127,5 +130,7 @@ function createSheetRulePayload(rule: RuntimeSheetRule): SheetRule {
|
|
|
127
130
|
debug: rule.debug || null,
|
|
128
131
|
debugField: rule.debugField || null,
|
|
129
132
|
priority: rule.priority,
|
|
133
|
+
important: rule.important,
|
|
134
|
+
layer: rule.layer,
|
|
130
135
|
};
|
|
131
136
|
}
|
package/runtime/style/scope.ts
CHANGED
|
@@ -3,12 +3,6 @@ import { isScopeData } from '../../builder/data/is';
|
|
|
3
3
|
import type { StyleTheme } from '../types';
|
|
4
4
|
|
|
5
5
|
export function combineScope(...scopes: (StyleTheme | undefined)[]) {
|
|
6
|
-
const shortcut = resolveSingleScopeTarget(scopes);
|
|
7
|
-
|
|
8
|
-
if (shortcut !== null) {
|
|
9
|
-
return (target: SlotData) => shortcut(target);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
6
|
return (target: SlotData) => resolveScopeTargets(target, scopes);
|
|
13
7
|
}
|
|
14
8
|
|
|
@@ -16,27 +10,9 @@ export function bindScope(
|
|
|
16
10
|
target: SlotData,
|
|
17
11
|
...scopes: (StyleTheme | undefined)[]
|
|
18
12
|
) {
|
|
19
|
-
const shortcut = resolveSingleScopeTarget(scopes);
|
|
20
|
-
|
|
21
|
-
if (shortcut !== null) {
|
|
22
|
-
return shortcut(target);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
13
|
return resolveScopeTargets(target, scopes);
|
|
26
14
|
}
|
|
27
15
|
|
|
28
|
-
function resolveSingleScopeTarget(
|
|
29
|
-
scopes: (StyleTheme | undefined)[],
|
|
30
|
-
): ((target: SlotData) => ScopeTargetData[]) | null {
|
|
31
|
-
if (scopes.length !== 1) return null;
|
|
32
|
-
|
|
33
|
-
const scope = scopes[0];
|
|
34
|
-
if (!scope) return () => [];
|
|
35
|
-
if (Array.isArray(scope) || !isScopeData(scope)) return null;
|
|
36
|
-
|
|
37
|
-
return (target: SlotData) => [scope(target)];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
16
|
function resolveScopeTargets(
|
|
41
17
|
target: SlotData,
|
|
42
18
|
scopes: (StyleTheme | undefined)[],
|
package/runtime/style/style.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SheetData, SlotData, StyleData } from '../../builder/data';
|
|
2
|
+
import { isSheetData, isSlotData, isStyleData } from '../../builder/data';
|
|
3
|
+
import type { CombinedStyleArg } from '../core/cache/combine';
|
|
4
|
+
import { getCombinedStyle } from '../core/cache/combineRuntime';
|
|
2
5
|
import type { CombinedStyle } from '../core/combinedStyle';
|
|
6
|
+
import type { StyleProp } from '../types';
|
|
3
7
|
|
|
4
8
|
export type StyleCombiner<T extends object> = (
|
|
5
9
|
...args: CombinedStyleArg<T>[]
|
|
@@ -11,24 +15,195 @@ type InferStyleCombinerStyles<T extends object | StyleCombiner<any>> = T extends
|
|
|
11
15
|
: T extends object ? T
|
|
12
16
|
: never;
|
|
13
17
|
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
};
|
|
18
36
|
|
|
19
37
|
type CombineStyle = CombineStyleFn & {
|
|
20
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[];
|
|
21
49
|
};
|
|
22
50
|
|
|
51
|
+
const singleStyleWrappers = new WeakMap<SingleStyleItem, { value: SingleStyleItem; }>();
|
|
52
|
+
|
|
23
53
|
const combineStyleBase = <T extends object>(
|
|
24
54
|
styles: T,
|
|
25
55
|
...args: CombinedStyleArg<T>[]
|
|
26
56
|
): CombinedStyle<T> => getCombinedStyle(styles, args);
|
|
27
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
|
+
|
|
28
69
|
const combineStyleFor = <T extends object>(styles: T): StyleCombiner<T> => {
|
|
29
70
|
return (...args: CombinedStyleArg<T>[]) => combineStyleBase(styles, ...args);
|
|
30
71
|
};
|
|
31
72
|
|
|
32
|
-
|
|
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, {
|
|
33
206
|
for: combineStyleFor,
|
|
207
|
+
with: combineStyleWith,
|
|
208
|
+
multi: combineStyleMulti,
|
|
34
209
|
}) as CombineStyle;
|
package/runtime/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import type { ScopeData, ScopeTargetData, SlotData, StyleData, ThemeData } from '../builder/data';
|
|
2
|
+
import type { ScopeData, ScopeTargetData, SheetData, SlotData, StyleData, ThemeData } from '../builder/data';
|
|
3
3
|
import type { StyleTokenData, StyleTokenOverride } from '../style';
|
|
4
4
|
import type { ResolvedStyleItem } from './core/cache/item';
|
|
5
5
|
|
|
@@ -10,19 +10,21 @@ export type RecursiveProp<Item> =
|
|
|
10
10
|
| Falsy
|
|
11
11
|
| readonly RecursiveProp<Item>[];
|
|
12
12
|
|
|
13
|
-
export type StyleItem = ScopeTargetData
|
|
13
|
+
export type StyleItem = ScopeTargetData | StyleTokenOverride<any>;
|
|
14
14
|
|
|
15
15
|
export type StyleItems = (StyleItem | Falsy)[];
|
|
16
16
|
|
|
17
17
|
export type RuntimeStyleItem = ResolvedStyleItem | ThemeData;
|
|
18
18
|
|
|
19
|
-
export type RuntimeStylePropItem = RuntimeStyleItem | StyleData | SlotData;
|
|
19
|
+
export type RuntimeStylePropItem = RuntimeStyleItem | StyleData | SheetData | SlotData;
|
|
20
20
|
|
|
21
21
|
export type StyleProp = RecursiveProp<RuntimeStylePropItem>;
|
|
22
22
|
|
|
23
23
|
export type StyleTokenInput<T> = T | StyleTokenData<T>;
|
|
24
24
|
|
|
25
|
-
export type StyleTheme = RecursiveProp<ScopeData
|
|
25
|
+
export type StyleTheme = RecursiveProp<ScopeData | SheetData>;
|
|
26
|
+
|
|
27
|
+
export type TokenTheme = ThemeData;
|
|
26
28
|
|
|
27
29
|
export type RuntimeStyleAttributes = {
|
|
28
30
|
css?: StyleProp;
|
package/selector/assert.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSelectorAssert } from './selector';
|
|
1
2
|
import type { SelectorAssert, SelectorAssertFn } from './types';
|
|
2
3
|
import { isAttrArg, isLocalSelector, isPseudoArgSelector, isRawValue, isTagSelector } from './validate';
|
|
3
4
|
|
|
@@ -46,86 +47,84 @@ export function assertEnumSelector<const Values extends readonly string[]>(
|
|
|
46
47
|
export function assertEnumSelector<const Values extends readonly string[]>(
|
|
47
48
|
...values: Values
|
|
48
49
|
): SelectorAssertFn<Values[number]>;
|
|
49
|
-
export function assertEnumSelector(
|
|
50
|
-
...input: [
|
|
51
|
-
) {
|
|
50
|
+
export function assertEnumSelector<const Values extends readonly string[]>(
|
|
51
|
+
...input: [Values] | Values
|
|
52
|
+
): SelectorAssertFn<Values[number]> {
|
|
52
53
|
const values = Array.isArray(input[0]) ? input[0] : input;
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
return createSelectorAssert<Values[number]>((arg) => {
|
|
55
56
|
if (!values.includes(arg)) {
|
|
56
57
|
throw new Error(`value must be one of: ${values.join(', ')}`);
|
|
57
58
|
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return fn as SelectorAssertFn<string>;
|
|
59
|
+
});
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
export
|
|
62
|
+
export const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
64
63
|
if (!value) {
|
|
65
64
|
throw new Error('selector cannot be empty');
|
|
66
65
|
}
|
|
67
|
-
}
|
|
66
|
+
});
|
|
68
67
|
|
|
69
|
-
export
|
|
68
|
+
export const assertLocalSelector = createSelectorAssert((value) => {
|
|
70
69
|
if (!isLocalSelector(value)) {
|
|
71
70
|
throw new Error(
|
|
72
71
|
'selector must target the current element only and cannot contain tags, combinators, or multiple selectors',
|
|
73
72
|
);
|
|
74
73
|
}
|
|
75
|
-
}
|
|
74
|
+
});
|
|
76
75
|
|
|
77
|
-
export
|
|
76
|
+
export const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
78
77
|
if (!isPseudoArgSelector(value)) {
|
|
79
78
|
throw new Error(
|
|
80
79
|
'pseudo selector argument must contain only tags or selectors targeting the current element',
|
|
81
80
|
);
|
|
82
81
|
}
|
|
83
|
-
}
|
|
82
|
+
});
|
|
84
83
|
|
|
85
|
-
export
|
|
84
|
+
export const assertTagSelector = createSelectorAssert((value) => {
|
|
86
85
|
if (!isTagSelector(value)) {
|
|
87
86
|
throw new Error(
|
|
88
87
|
'selector must be a single tag selector',
|
|
89
88
|
);
|
|
90
89
|
}
|
|
91
|
-
}
|
|
90
|
+
});
|
|
92
91
|
|
|
93
|
-
export
|
|
92
|
+
export const assertAttrSelector = createSelectorAssert((value) => {
|
|
94
93
|
if (!isAttrArg(value)) {
|
|
95
94
|
throw new Error(
|
|
96
95
|
'attribute selector value must not include "[" or "]"',
|
|
97
96
|
);
|
|
98
97
|
}
|
|
99
|
-
}
|
|
98
|
+
});
|
|
100
99
|
|
|
101
|
-
export
|
|
100
|
+
export const assertRawValue = createSelectorAssert((value) => {
|
|
102
101
|
if (!isRawValue(value)) {
|
|
103
102
|
throw new Error(
|
|
104
103
|
'value must not contain "{" or "}"',
|
|
105
104
|
);
|
|
106
105
|
}
|
|
107
|
-
}
|
|
106
|
+
});
|
|
108
107
|
|
|
109
|
-
export
|
|
108
|
+
export const assertMediaQuery = createSelectorAssert((value) => {
|
|
110
109
|
if (!isRawValue(value)) {
|
|
111
110
|
throw new Error(
|
|
112
111
|
'media query must not contain "{" or "}"',
|
|
113
112
|
);
|
|
114
113
|
}
|
|
115
|
-
}
|
|
114
|
+
});
|
|
116
115
|
|
|
117
|
-
export
|
|
116
|
+
export const assertSupportsQuery = createSelectorAssert((value) => {
|
|
118
117
|
if (!isRawValue(value)) {
|
|
119
118
|
throw new Error(
|
|
120
119
|
'supports query must not contain "{" or "}"',
|
|
121
120
|
);
|
|
122
121
|
}
|
|
123
|
-
}
|
|
122
|
+
});
|
|
124
123
|
|
|
125
|
-
export
|
|
124
|
+
export const assertContainerQuery = createSelectorAssert((value) => {
|
|
126
125
|
if (!isRawValue(value)) {
|
|
127
126
|
throw new Error(
|
|
128
127
|
'container query must not contain "{" or "}"',
|
|
129
128
|
);
|
|
130
129
|
}
|
|
131
|
-
}
|
|
130
|
+
});
|
package/selector/selector.ts
CHANGED
|
@@ -66,3 +66,9 @@ export function selectorPriority<Selectors extends Record<string, Selector>>(
|
|
|
66
66
|
|
|
67
67
|
return selectors;
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
export function createSelectorAssert<const Arg extends string = string>(
|
|
71
|
+
fn: (arg: Arg) => void,
|
|
72
|
+
) {
|
|
73
|
+
return fn as SelectorAssertFn<Arg>;
|
|
74
|
+
}
|
package/sheet/dev/dev_layer.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { getLayerBlockCss, getLayerOrderCss } from '../../atomic/layer';
|
|
2
|
-
import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../../config/config/css';
|
|
2
|
+
import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../../config/config/css';
|
|
3
3
|
import { DEV_CONFIG } from '../../config/config/dev';
|
|
4
4
|
import type { SheetOptions, SheetRule, StyleSheet } from '../types';
|
|
5
5
|
import {
|
|
6
6
|
createNoopSheet,
|
|
7
7
|
createSheetLayerState,
|
|
8
8
|
createStyleTag,
|
|
9
|
-
|
|
9
|
+
getSheetLayerName,
|
|
10
|
+
getSheetLayerNames,
|
|
11
|
+
getSheetRuleLayerPriority,
|
|
10
12
|
getStyleLayerName,
|
|
11
13
|
insertStyleTagAfter,
|
|
12
14
|
insertStyleTagAtTop,
|
|
@@ -40,6 +42,7 @@ export function createDevLayerSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
40
42
|
let activeLayers: readonly string[] = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
|
|
41
43
|
let active: DevRuleTag | null = null;
|
|
42
44
|
let lastTag: HTMLStyleElement = layerTag;
|
|
45
|
+
let hasSheetLayer = false;
|
|
43
46
|
|
|
44
47
|
if (options.top) {
|
|
45
48
|
insertStyleTagAtTop(document, layerTag);
|
|
@@ -50,7 +53,7 @@ export function createDevLayerSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
50
53
|
return {
|
|
51
54
|
updateLayers(layers) {
|
|
52
55
|
activeLayers = layers;
|
|
53
|
-
const next = getLayerOrderCss(layers, rootLayer ?? layerState
|
|
56
|
+
const next = getLayerOrderCss(layers, rootLayer ?? getSheetLayerNames(layerState, hasSheetLayer));
|
|
54
57
|
|
|
55
58
|
if (next === layerText) return;
|
|
56
59
|
|
|
@@ -64,11 +67,19 @@ export function createDevLayerSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
64
67
|
|
|
65
68
|
if (ruleKey && inserted.has(ruleKey)) return;
|
|
66
69
|
|
|
67
|
-
const priority = typeof rule === 'string'
|
|
68
|
-
|
|
70
|
+
const priority = typeof rule === 'string'
|
|
71
|
+
? getSheetRuleLayerPriority(null, false)
|
|
72
|
+
: getSheetRuleLayerPriority(rule.priority, rule.important);
|
|
73
|
+
const ruleLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
|
|
74
|
+
if (ruleLayer === 'sheet') hasSheetLayer = true;
|
|
75
|
+
const layerName = rootLayer ?? (ruleLayer === 'sheet'
|
|
76
|
+
? getSheetLayerName()
|
|
77
|
+
: ruleLayer === false || !isStyleLayerEnabled()
|
|
78
|
+
? null
|
|
79
|
+
: layerState.getName(priority));
|
|
69
80
|
const nextLayerText = getLayerOrderCss(
|
|
70
81
|
activeLayers,
|
|
71
|
-
rootLayer ?? layerState
|
|
82
|
+
rootLayer ?? getSheetLayerNames(layerState, hasSheetLayer),
|
|
72
83
|
);
|
|
73
84
|
|
|
74
85
|
if (nextLayerText !== layerText) {
|
|
@@ -76,7 +87,7 @@ export function createDevLayerSheet(options: SheetOptions = {}): StyleSheet {
|
|
|
76
87
|
layerTag.textContent = nextLayerText;
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
const css = getLayerBlockCss(layerName, rawCss);
|
|
90
|
+
const css = layerName ? getLayerBlockCss(layerName, rawCss) : rawCss;
|
|
80
91
|
const key = typeof rule === 'string' ? css : ruleKey;
|
|
81
92
|
|
|
82
93
|
if (key && inserted.has(key)) return;
|