@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.11
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 +156 -2
- package/README.md +181 -49
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +50 -12
- package/atomic/debug/className/className.ts +24 -8
- package/atomic/element.ts +5 -2
- package/atomic/rule.ts +11 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +44 -3
- package/atomic/token.ts +7 -4
- package/atomic/utils/cssIdent.ts +54 -0
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +14 -0
- package/atomic/utils/selector.ts +31 -1
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +491 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +41 -0
- package/builder/data/const.ts +8 -1
- package/builder/data/create.ts +52 -6
- package/builder/data/data.ts +33 -8
- package/builder/data/debug.ts +1 -0
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +26 -3
- package/builder/data/merge/scope.ts +38 -38
- package/builder/data/merge/style.ts +115 -20
- package/builder/data/state.ts +17 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +30 -0
- package/builder/extract/token.ts +30 -14
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +31 -0
- package/builder/selector_override_core.ts +79 -0
- package/builder/style_builder.ts +144 -20
- package/builder/style_data.ts +25 -0
- package/builder/style_fns.ts +57 -57
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/builder/types/alias.ts +44 -16
- package/builder/types/fns.ts +24 -16
- package/builder/types/types.ts +37 -7
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +88 -14
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +4 -1
- package/compiler/cssProp.ts +21 -0
- package/compiler/extract/extract.ts +42 -14
- package/compiler/extract/types.ts +2 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +93 -4
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +169 -32
- package/compiler/transform/evaluator/tracer.ts +48 -11
- package/compiler/transform/extract/chain/chain.ts +1370 -162
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +3 -1
- package/compiler/transform/extract/plugin.ts +64 -6
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +72 -2
- package/compiler/transform/extract/utils/state.ts +3 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +12 -5
- package/compiler/utils/file_resolver.ts +2 -0
- package/compiler/utils/import_source.ts +19 -8
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +9 -2
- package/config/config/check.ts +25 -0
- package/config/config/css.ts +18 -1
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +19 -2
- package/config/types.ts +7 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +152 -0
- package/css/styleTarget.ts +251 -0
- package/dev/config.ts +2 -3
- package/dev/utils.ts +3 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +153 -0
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-yhJCGT0F.js +304 -0
- package/dist/className-yhJCGT0F.js.map +1 -0
- package/dist/combine-Bww7VnSr.js +1254 -0
- package/dist/combine-Bww7VnSr.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
- package/dist/compiler-C3CEGGtI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BAEzRmSJ.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
- package/dist/config-BKP5LOkt.js +35 -0
- package/dist/config-BKP5LOkt.js.map +1 -0
- package/dist/config-C5VWvTav.js +34 -0
- package/dist/config-C5VWvTav.js.map +1 -0
- package/dist/config-CB4lm2tM.js +1 -0
- package/dist/config-CDjbHwb-.js +6 -0
- package/dist/config-CDjbHwb-.js.map +1 -0
- package/dist/config-DNEnHEf3.js +36 -0
- package/dist/config-DNEnHEf3.js.map +1 -0
- package/dist/createTransformElement-D8fXZ3wA.js +34 -0
- package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
- package/dist/css-BDn0epJ8.js +1339 -0
- package/dist/css-BDn0epJ8.js.map +1 -0
- package/dist/css-CFxNrYt3.js +4040 -0
- package/dist/css-CFxNrYt3.js.map +1 -0
- package/dist/css-DEYgrj76.js +524 -0
- package/dist/css-DEYgrj76.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
- package/dist/css-DWBWsyxZ.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
- package/dist/data-CDrS1Bq4.js +785 -0
- package/dist/data-CDrS1Bq4.js.map +1 -0
- package/dist/debug-BkVbf0Cz.js +52 -0
- package/dist/debug-BkVbf0Cz.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
- package/dist/debug-YuhEIQVO.js.map +1 -0
- package/dist/dev/rsc.js +10 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
- package/dist/dev-0imWmSVb.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
- package/dist/elementMarker-kvpMjB49.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +13 -9
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +242 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -4
- package/dist/entry/prod.js +84 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +11 -13
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +582 -664
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -4
- package/dist/entry/rsc-prod.js +242 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
- package/dist/env-Cz8frh6e.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js +545 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
- package/dist/getClassName-DGm-VNDo.js.map +1 -0
- package/dist/getClassName-Dtc4yyYI.js +47 -0
- package/dist/getClassName-Dtc4yyYI.js.map +1 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
- package/dist/getClassName-DtkplEIt.js.map +1 -0
- package/dist/global-CAc9OjKx.js +14 -0
- package/dist/global-CAc9OjKx.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +10 -8
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-CVxpkS04.js +39 -0
- package/dist/jsx-CVxpkS04.js.map +1 -0
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
- package/dist/misc-B76PUnWe.mjs.map +1 -0
- package/dist/namedTokens-5AayGokX.js +85 -0
- package/dist/namedTokens-5AayGokX.js.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +151 -31
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +13 -10
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +995 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
- package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
- package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
- package/dist/rules-DaMaMHgb.js.map +1 -0
- package/dist/scope-CZdGAnl_.js +601 -0
- package/dist/scope-CZdGAnl_.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
- package/dist/shared-PK52rW6T.cjs.map +1 -0
- package/dist/sheet-CxkO1Hwt.js +7 -0
- package/dist/sheet-CxkO1Hwt.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
- package/dist/style-CAhAnRni.js +1129 -0
- package/dist/style-CAhAnRni.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
- package/dist/styleStore-BzLZwpwy.js.map +1 -0
- package/dist/styleStore-DaIJ4OPV.js +58 -0
- package/dist/styleStore-DaIJ4OPV.js.map +1 -0
- package/dist/token-D33mKTka.js +138 -0
- package/dist/token-D33mKTka.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
- package/dist/transform-DSpimwwC.js +23 -0
- package/dist/transform-DSpimwwC.js.map +1 -0
- package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
- package/dist/utils-DZK0mfmY.js +42 -0
- package/dist/utils-DZK0mfmY.js.map +1 -0
- package/dist/utils-D_XgtMtn.js +72 -0
- package/dist/utils-D_XgtMtn.js.map +1 -0
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
- package/dist/utils-H1VInWpd.js.map +1 -0
- package/dist/utils-NdisireF.mjs +182 -0
- package/dist/utils-NdisireF.mjs.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CK0-Xbov.js +160 -0
- package/dist/value-CK0-Xbov.js.map +1 -0
- package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
- package/dist/webpack-D7QO0bKN.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +4 -2
- package/entry/rsc_dev/adapter/preact.ts +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -0
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +14 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/jsx/types/index.ts +1 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +110 -8
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +5 -9
- package/plugin/bundler/vite/state.ts +11 -6
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +249 -35
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +121 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +15 -2
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +239 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +436 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/adapter/utils.ts +120 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +16 -31
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +55 -23
- package/runtime/extract/index.ts +4 -2
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/index.ts +8 -1
- package/runtime/rsc/getClassName.ts +4 -0
- package/runtime/rsc/observer.ts +4 -0
- package/runtime/rsc/styleStore.ts +18 -7
- package/runtime/sheet/rule.ts +16 -12
- package/runtime/sheet/rules.ts +8 -3
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +6 -4
- package/sheet/dev/dev_layer.ts +18 -7
- package/sheet/dev/dev_sort.ts +45 -11
- package/sheet/prod.ts +18 -7
- package/sheet/types.ts +2 -0
- package/sheet/utils/layer.ts +33 -0
- package/style/classname.ts +47 -0
- package/style/important.ts +19 -0
- package/style/index.ts +3 -0
- package/style/style.ts +47 -16
- package/style/theme.ts +4 -3
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +41 -2
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/hash.ts +4 -0
- package/utils/symbol.ts +3 -0
- package/atomic/layer/README.md +0 -116
- package/atomic/utils/css.ts +0 -49
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-C1Ht5Wvv.js +0 -144
- package/dist/className-C1Ht5Wvv.js.map +0 -1
- package/dist/className-DC2Cq8p3.js +0 -251
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-BryWDfQX.js +0 -25
- package/dist/config-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js +0 -243
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js +0 -805
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js +0 -235
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/css_extra-DlOnsnR1.js +0 -8
- package/dist/css_extra-oIi3UEPK.js.map +0 -1
- package/dist/data-BsqOa5br.js +0 -473
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-CcphAa3R.js.map +0 -1
- package/dist/dev-DfBbuLeE.js +0 -71
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/global-CvfmFLsK.js.map +0 -1
- package/dist/jsx-CwTeyUxr.js +0 -39
- package/dist/jsx-CwTeyUxr.js.map +0 -1
- package/dist/jsx-D2BksHSv.js +0 -38
- package/dist/jsx-D2BksHSv.js.map +0 -1
- package/dist/layer-D1SaH07m.js +0 -94
- package/dist/layer-D1SaH07m.js.map +0 -1
- package/dist/loader-B5Kw0DD-.mjs.map +0 -1
- package/dist/misc-DCdYYyhK.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CnLFt5kx.js +0 -406
- package/dist/property-CnLFt5kx.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js +0 -752
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js +0 -1269
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/styleStore-DyNXBcUK.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-u_tM-mtg.js +0 -204
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/utils-CEaq_c-A.mjs +0 -97
- package/dist/utils-CEaq_c-A.mjs.map +0 -1
- package/dist/utils-CWNHx4EC.js +0 -170
- package/dist/utils-CWNHx4EC.js.map +0 -1
- package/dist/utils-D7FAOyg6.js.map +0 -1
- package/dist/value-BR4e2MKt.js +0 -910
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
- package/dist/valueRef-lshFk1Cs.js +0 -16
- package/dist/valueRef-lshFk1Cs.js.map +0 -1
- package/dist/webpack-Dh6lox2l.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -11,11 +11,13 @@ import {
|
|
|
11
11
|
import { clearResolverCache } from '../utils/file_resolver';
|
|
12
12
|
import {
|
|
13
13
|
getStyleExtractRuntimeImportPath,
|
|
14
|
+
getStyleRuntimeAdapterImportPath,
|
|
14
15
|
getStyleRuntimeCssImportPath,
|
|
15
16
|
getStyleRuntimeDevRscImportPath,
|
|
16
17
|
getStyleRuntimeImportPath,
|
|
17
18
|
} from '../utils/imports';
|
|
18
19
|
import { createCompilerCache } from './cache';
|
|
20
|
+
import { CompilerRuntimeMode } from './constants';
|
|
19
21
|
import type {
|
|
20
22
|
CompilerInvalidateFileInfo,
|
|
21
23
|
CompilerOptions,
|
|
@@ -26,13 +28,6 @@ import type {
|
|
|
26
28
|
TransformExtractResult,
|
|
27
29
|
} from './types';
|
|
28
30
|
|
|
29
|
-
export enum CompilerRuntimeMode {
|
|
30
|
-
Dev = 'dev',
|
|
31
|
-
Prod = 'prod',
|
|
32
|
-
RscDev = 'rsc-dev',
|
|
33
|
-
RscProd = 'rsc-prod',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
31
|
export type CompilerArgs = {
|
|
37
32
|
projectDir: string;
|
|
38
33
|
cacheDir: string;
|
|
@@ -53,6 +48,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
53
48
|
return rewriteTransformResult(
|
|
54
49
|
transformDebug(internal, args, { tracer }),
|
|
55
50
|
internal.runtimeMode,
|
|
51
|
+
args.code,
|
|
56
52
|
);
|
|
57
53
|
};
|
|
58
54
|
|
|
@@ -60,6 +56,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
60
56
|
const debugResult = rewriteTransformResult(
|
|
61
57
|
transformDebug(internal, args, { tracer }),
|
|
62
58
|
internal.runtimeMode,
|
|
59
|
+
args.code,
|
|
63
60
|
);
|
|
64
61
|
if (!debugResult) return null;
|
|
65
62
|
|
|
@@ -104,7 +101,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
104
101
|
return rewriteTransformResult({
|
|
105
102
|
...result,
|
|
106
103
|
rules: collector.getItems().slice(startIndex),
|
|
107
|
-
}, internal.runtimeMode);
|
|
104
|
+
}, internal.runtimeMode, args.code);
|
|
108
105
|
};
|
|
109
106
|
|
|
110
107
|
const getExtractedCss = () => {
|
|
@@ -145,25 +142,46 @@ function createCompilerInternal(args: CompilerArgs, options: CompilerOptions) {
|
|
|
145
142
|
function rewriteTransformResult<Result extends { code: string; }>(
|
|
146
143
|
result: Result | null,
|
|
147
144
|
runtimeMode: CompilerRuntimeMode | null,
|
|
145
|
+
sourceCode: string,
|
|
148
146
|
) {
|
|
149
147
|
if (!result || !runtimeMode) return result;
|
|
150
148
|
|
|
151
149
|
return {
|
|
152
150
|
...result,
|
|
153
|
-
code: rewriteCompilerRuntimeImports(result.code, runtimeMode),
|
|
151
|
+
code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode),
|
|
154
152
|
};
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
function rewriteCompilerRuntimeImports(
|
|
155
|
+
function rewriteCompilerRuntimeImports(
|
|
156
|
+
code: string,
|
|
157
|
+
runtimeMode: CompilerRuntimeMode,
|
|
158
|
+
sourceCode: string,
|
|
159
|
+
) {
|
|
160
|
+
const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
|
|
161
|
+
|
|
158
162
|
return rewriteImportSources(
|
|
159
163
|
code,
|
|
160
|
-
(source) => getCompilerRuntimeImportSource(source, runtimeMode),
|
|
164
|
+
(source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode),
|
|
161
165
|
);
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
function
|
|
165
|
-
if (
|
|
166
|
-
|
|
168
|
+
function getImportRuntimeMode(runtimeMode: CompilerRuntimeMode, sourceCode: string) {
|
|
169
|
+
if (runtimeMode === CompilerRuntimeMode.RscDev && hasUseClientDirective(sourceCode)) {
|
|
170
|
+
return CompilerRuntimeMode.Dev;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return runtimeMode;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getCompilerRuntimeImportSource(
|
|
177
|
+
source: string,
|
|
178
|
+
runtimeMode: CompilerRuntimeMode,
|
|
179
|
+
importRuntimeMode: CompilerRuntimeMode,
|
|
180
|
+
) {
|
|
181
|
+
if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(importRuntimeMode);
|
|
182
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
|
|
183
|
+
if (adapterImportPath) return adapterImportPath;
|
|
184
|
+
if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(importRuntimeMode);
|
|
167
185
|
if (source === STYLE_EXTRACT_RUNTIME_IMPORT_PATH) return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
168
186
|
if (runtimeMode === CompilerRuntimeMode.RscDev && source === STYLE_DEV_RSC_IMPORT_PATH) {
|
|
169
187
|
return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
@@ -171,3 +189,59 @@ function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRun
|
|
|
171
189
|
|
|
172
190
|
return null;
|
|
173
191
|
}
|
|
192
|
+
|
|
193
|
+
function hasUseClientDirective(code: string) {
|
|
194
|
+
let index = 0;
|
|
195
|
+
|
|
196
|
+
while (index < code.length) {
|
|
197
|
+
index = skipWhitespaceAndComments(code, index);
|
|
198
|
+
|
|
199
|
+
const quote = code[index];
|
|
200
|
+
if (quote !== '"' && quote !== "'") return false;
|
|
201
|
+
|
|
202
|
+
const end = code.indexOf(quote, index + 1);
|
|
203
|
+
if (end < 0) return false;
|
|
204
|
+
|
|
205
|
+
const directive = code.slice(index + 1, end);
|
|
206
|
+
index = skipWhitespaceAndComments(code, end + 1);
|
|
207
|
+
|
|
208
|
+
if (code[index] === ';') {
|
|
209
|
+
index += 1;
|
|
210
|
+
} else if (code[index] && code[index] !== '\n' && code[index] !== '\r') {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (directive === 'use client') return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function skipWhitespaceAndComments(code: string, index: number) {
|
|
221
|
+
let next = index;
|
|
222
|
+
|
|
223
|
+
while (next < code.length) {
|
|
224
|
+
const char = code[next];
|
|
225
|
+
|
|
226
|
+
if (char === ' ' || char === '\t' || char === '\n' || char === '\r') {
|
|
227
|
+
next += 1;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (char === '/' && code[next + 1] === '/') {
|
|
232
|
+
const lineEnd = code.indexOf('\n', next + 2);
|
|
233
|
+
next = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (char === '/' && code[next + 1] === '*') {
|
|
238
|
+
const commentEnd = code.indexOf('*/', next + 2);
|
|
239
|
+
next = commentEnd < 0 ? code.length : commentEnd + 2;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return next;
|
|
247
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import type { StyleCheckOptions } from '../../config/config/check';
|
|
1
2
|
import type { CssConfig } from '../../config/config/css';
|
|
2
3
|
import type { DevRuntimeOptions } from '../../config/config/dev';
|
|
3
4
|
import type { CheckSelectorMode } from '../../config/types';
|
|
4
5
|
import type { ReplaceProps } from '../../utils/type';
|
|
6
|
+
import type { CompilerCssPropOptions } from '../cssProp';
|
|
5
7
|
import type { CssExtractRule } from '../extract';
|
|
6
8
|
import type { BabelTransformSourceMap } from '../transform/utils/babel';
|
|
7
9
|
import type { ImportSource } from '../utils/import_source';
|
|
8
10
|
import type { GetSourcemapFilePathFn } from '../utils/sourcemap';
|
|
9
11
|
|
|
10
12
|
export type CompilerCssOptions = Partial<CssConfig> & {
|
|
11
|
-
localClassName?: boolean;
|
|
12
13
|
debugClassName?: boolean;
|
|
13
14
|
};
|
|
14
15
|
|
|
@@ -20,7 +21,9 @@ export type DevSourcemapMode = 'sourceUrl' | 'sourceContent' | 'sidecarServer';
|
|
|
20
21
|
|
|
21
22
|
export type CompilerOptions = {
|
|
22
23
|
hoist?: boolean;
|
|
24
|
+
check?: StyleCheckOptions;
|
|
23
25
|
css?: CompilerCssOptions;
|
|
26
|
+
cssProp?: false | CompilerCssPropOptions;
|
|
24
27
|
dev?: CompilerDevOptions;
|
|
25
28
|
|
|
26
29
|
importSources?: ImportSource[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CompilerCssPropOptions = {
|
|
2
|
+
adapter: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const CssPropSolid: CompilerCssPropOptions = {
|
|
6
|
+
adapter: '@fluentic/style/adapter/solid',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CssPropPreact: CompilerCssPropOptions = {
|
|
10
|
+
adapter: '@fluentic/style/adapter/preact',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const CssPropReact: CompilerCssPropOptions = {
|
|
14
|
+
adapter: '@fluentic/style/adapter/react',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const CssPropPresets = {
|
|
18
|
+
Solid: CssPropSolid,
|
|
19
|
+
Preact: CssPropPreact,
|
|
20
|
+
React: CssPropReact,
|
|
21
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { compareLayerPriority,
|
|
2
|
-
import type
|
|
1
|
+
import { compareLayerPriority, getLayerBlockCss, getLayerOrderCss } from '../../atomic/layer';
|
|
2
|
+
import { type CssConfig, isStyleLayerEnabled } from '../../config/config/css';
|
|
3
3
|
import { DEFAULT_CONFIG } from '../utils/constants';
|
|
4
4
|
import type { CssExtractRule } from './types';
|
|
5
5
|
|
|
6
|
-
type CssOptions = Pick<CssConfig, 'layers' | 'layerNamespace'>;
|
|
6
|
+
type CssOptions = Pick<CssConfig, 'layer' | 'layers' | 'layerNamespace'>;
|
|
7
7
|
|
|
8
|
-
export type CompilerExtractCssArgs = Partial<CssOptions
|
|
9
|
-
layer?: boolean;
|
|
10
|
-
};
|
|
8
|
+
export type CompilerExtractCssArgs = Partial<CssOptions>;
|
|
11
9
|
|
|
12
10
|
export function extractCss(
|
|
13
11
|
items: CssExtractRule[],
|
|
@@ -34,18 +32,48 @@ function getExtractedCssItems(
|
|
|
34
32
|
css.push(item);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
if (
|
|
38
|
-
return css.map((item) => item.css).join('\n');
|
|
39
|
-
}
|
|
35
|
+
if (!css.length) return '';
|
|
40
36
|
|
|
41
37
|
const defaults = DEFAULT_CONFIG;
|
|
42
38
|
|
|
43
39
|
const layerNamespace = args.layerNamespace ?? defaults.layerNamespace ?? '';
|
|
44
40
|
const layers = args.layers ?? defaults.layers ?? [];
|
|
41
|
+
const styleLayer = isStyleLayerEnabled(args.layer ?? defaults.layer);
|
|
42
|
+
const sheetLayerName = layerNamespace ? layerNamespace + '.sheet' : 'sheet';
|
|
43
|
+
const styleItems: string[] = [];
|
|
44
|
+
const sheetItems: string[] = [];
|
|
45
|
+
const unlayeredItems: string[] = [];
|
|
46
|
+
|
|
47
|
+
for (let i = 0, len = css.length; i < len; i++) {
|
|
48
|
+
const item = css[i];
|
|
49
|
+
if (item.layer === 'sheet') {
|
|
50
|
+
sheetItems.push(item.css);
|
|
51
|
+
} else if (item.layer === false || !styleLayer) {
|
|
52
|
+
unlayeredItems.push(item.css);
|
|
53
|
+
} else {
|
|
54
|
+
styleItems.push(item.css);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const styleLayerName = sheetItems.length && layerNamespace
|
|
59
|
+
? layerNamespace + '.style'
|
|
60
|
+
: layerNamespace;
|
|
61
|
+
|
|
62
|
+
const layerNames = [
|
|
63
|
+
styleItems.length ? styleLayerName : '',
|
|
64
|
+
sheetItems.length ? sheetLayerName : '',
|
|
65
|
+
].filter(Boolean);
|
|
66
|
+
const output: string[] = [];
|
|
67
|
+
const layerOrder = getLayerOrderCss(layers, layerNames);
|
|
68
|
+
|
|
69
|
+
if (layerOrder) output.push(layerOrder);
|
|
70
|
+
if (styleItems.length) {
|
|
71
|
+
output.push(getLayerBlockCss(styleLayerName, '\n' + styleItems.join('\n') + '\n'));
|
|
72
|
+
}
|
|
73
|
+
if (sheetItems.length) {
|
|
74
|
+
output.push(getLayerBlockCss(sheetLayerName, '\n' + sheetItems.join('\n') + '\n'));
|
|
75
|
+
}
|
|
76
|
+
output.push(...unlayeredItems);
|
|
45
77
|
|
|
46
|
-
return
|
|
47
|
-
layers,
|
|
48
|
-
layerNamespace,
|
|
49
|
-
css.map((item) => item.css),
|
|
50
|
-
);
|
|
78
|
+
return output.join('\n');
|
|
51
79
|
}
|
package/compiler/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCssPropPlugin } from './plugin';
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { CompilerOptions } from '../../compiler/types';
|
|
2
|
+
import type { CompilerCssPropOptions } from '../../cssProp';
|
|
3
|
+
import type { BabelCore, BabelTypes, NodePath } from '../utils/babel';
|
|
4
|
+
import { babelPlugin } from '../utils/babel';
|
|
5
|
+
|
|
6
|
+
type PluginState = BabelCore.PluginPass & {
|
|
7
|
+
options: CompilerOptions;
|
|
8
|
+
mergeId: BabelTypes.Identifier | null;
|
|
9
|
+
programPath: NodePath<BabelTypes.Program> | null;
|
|
10
|
+
changed: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type PluginArgs = {
|
|
14
|
+
options: CompilerOptions;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function createCssPropPlugin(args: PluginArgs) {
|
|
18
|
+
return babelPlugin<PluginState>((babel) => {
|
|
19
|
+
const { types: t } = babel;
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
pre(this: PluginState) {
|
|
23
|
+
this.options = args.options;
|
|
24
|
+
this.mergeId = null;
|
|
25
|
+
this.programPath = null;
|
|
26
|
+
this.changed = false;
|
|
27
|
+
},
|
|
28
|
+
visitor: {
|
|
29
|
+
Program: {
|
|
30
|
+
enter(path: NodePath<BabelTypes.Program>, state: PluginState) {
|
|
31
|
+
state.programPath = path;
|
|
32
|
+
state.mergeId = path.scope.generateUidIdentifier('fluenticMergeJsxProps');
|
|
33
|
+
},
|
|
34
|
+
exit(path: NodePath<BabelTypes.Program>, state: PluginState) {
|
|
35
|
+
const options = getCssPropOptions(state.options);
|
|
36
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
37
|
+
|
|
38
|
+
path.unshiftContainer(
|
|
39
|
+
'body',
|
|
40
|
+
t.importDeclaration([
|
|
41
|
+
t.importSpecifier(state.mergeId, t.identifier('mergeJsxProps')),
|
|
42
|
+
], t.stringLiteral(options.adapter)),
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
JSXOpeningElement(path: NodePath<BabelTypes.JSXOpeningElement>, state: PluginState) {
|
|
48
|
+
const keyHoistedAttributes = hoistKeyAttributes(path.node.attributes);
|
|
49
|
+
if (keyHoistedAttributes) path.node.attributes = keyHoistedAttributes;
|
|
50
|
+
|
|
51
|
+
const options = getCssPropOptions(state.options);
|
|
52
|
+
if (!options || !state.mergeId) return;
|
|
53
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
54
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
55
|
+
|
|
56
|
+
const keyAttributes = path.node.attributes.filter(isKeyAttribute);
|
|
57
|
+
const parts = path.node.attributes
|
|
58
|
+
.filter((attr) => !isKeyAttribute(attr))
|
|
59
|
+
.map((attr) => buildPart(t, attr));
|
|
60
|
+
|
|
61
|
+
path.node.attributes = [
|
|
62
|
+
...keyAttributes,
|
|
63
|
+
t.jsxSpreadAttribute(t.callExpression(state.mergeId, [
|
|
64
|
+
t.arrayExpression(parts),
|
|
65
|
+
])),
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
state.changed = true;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getCssPropOptions(options: CompilerOptions): CompilerCssPropOptions | null {
|
|
76
|
+
return options.cssProp || null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function isIntrinsicElement(name: BabelTypes.JSXOpeningElement['name']) {
|
|
80
|
+
return name.type === 'JSXIdentifier' && /^[a-z]/.test(name.name);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function hasCssAttribute(attrs: readonly (BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute)[]) {
|
|
84
|
+
return attrs.some((attr) => {
|
|
85
|
+
return attr.type === 'JSXAttribute' &&
|
|
86
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
87
|
+
attr.name.name === 'css';
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function hoistKeyAttributes(
|
|
92
|
+
attrs: readonly (BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute)[],
|
|
93
|
+
) {
|
|
94
|
+
const keyAttributes = attrs.filter(isKeyAttribute);
|
|
95
|
+
if (!keyAttributes.length) return null;
|
|
96
|
+
|
|
97
|
+
const firstKeyIndex = attrs.findIndex(isKeyAttribute);
|
|
98
|
+
const firstSpreadIndex = attrs.findIndex((attr) => attr.type === 'JSXSpreadAttribute');
|
|
99
|
+
|
|
100
|
+
if (firstSpreadIndex < 0 || firstKeyIndex < firstSpreadIndex) return null;
|
|
101
|
+
|
|
102
|
+
return [
|
|
103
|
+
...keyAttributes,
|
|
104
|
+
...attrs.filter((attr) => !isKeyAttribute(attr)),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isKeyAttribute(
|
|
109
|
+
attr: BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute,
|
|
110
|
+
) {
|
|
111
|
+
return attr.type === 'JSXAttribute' &&
|
|
112
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
113
|
+
attr.name.name === 'key';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function buildPart(
|
|
117
|
+
t: typeof BabelTypes,
|
|
118
|
+
attr: BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute,
|
|
119
|
+
) {
|
|
120
|
+
if (attr.type === 'JSXSpreadAttribute') return attr.argument;
|
|
121
|
+
|
|
122
|
+
return t.objectExpression([
|
|
123
|
+
t.objectProperty(
|
|
124
|
+
getObjectKey(t, attr.name),
|
|
125
|
+
getAttributeValue(t, attr),
|
|
126
|
+
),
|
|
127
|
+
]);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function getObjectKey(
|
|
131
|
+
t: typeof BabelTypes,
|
|
132
|
+
name: BabelTypes.JSXAttribute['name'],
|
|
133
|
+
) {
|
|
134
|
+
if (name.type === 'JSXIdentifier' && isValidIdentifierName(name.name)) {
|
|
135
|
+
return t.identifier(name.name);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return t.stringLiteral(getAttributeName(name));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getAttributeName(name: BabelTypes.JSXAttribute['name']) {
|
|
142
|
+
if (name.type === 'JSXIdentifier') return name.name;
|
|
143
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getAttributeValue(
|
|
147
|
+
t: typeof BabelTypes,
|
|
148
|
+
attr: BabelTypes.JSXAttribute,
|
|
149
|
+
) {
|
|
150
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
151
|
+
if (attr.value.type === 'StringLiteral') return t.stringLiteral(attr.value.value);
|
|
152
|
+
if (attr.value.type === 'JSXExpressionContainer') {
|
|
153
|
+
if (attr.value.expression.type === 'JSXEmptyExpression') return t.booleanLiteral(true);
|
|
154
|
+
return attr.value.expression;
|
|
155
|
+
}
|
|
156
|
+
return attr.value;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function isValidIdentifierName(name: string) {
|
|
160
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
161
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SELECTOR_MERGE } from '../../../builder/data/selector';
|
|
2
1
|
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
3
|
-
import { TRACE_STYLE, TRACE_VALUE
|
|
2
|
+
import { type DebugLoc, TRACE_STYLE, TRACE_VALUE } from '../../../builder/data/debug';
|
|
4
3
|
import { isScopeData, isStyleData } from '../../../builder/data/is';
|
|
4
|
+
import { SELECTOR_MERGE } from '../../../builder/data/selector';
|
|
5
5
|
import type { RuntimeItem } from '../../../builder/data/state';
|
|
6
6
|
import type { CheckSelectorMode, SourcemapLocationMode } from '../../../config/types';
|
|
7
7
|
import type { StyleFnMeta } from '../../../style/style';
|
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
DEBUG_SOURCE_CONTENT_VAR,
|
|
12
12
|
DEBUG_SOURCE_URL_VAR,
|
|
13
13
|
DEFAULT_CONFIG,
|
|
14
|
+
FN_CREATE_THEME,
|
|
14
15
|
FN_STYLE_KEYFRAMES,
|
|
15
16
|
FN_STYLE_MERGE,
|
|
16
17
|
FN_STYLE_PLAIN,
|
|
17
18
|
FN_STYLE_RAW,
|
|
18
19
|
FN_STYLE_SCOPE,
|
|
19
|
-
|
|
20
|
+
FN_STYLE_SELECTOR,
|
|
20
21
|
IMPORT_PATHS,
|
|
21
22
|
} from '../../utils/constants';
|
|
22
23
|
import { createImportSourceMatcher, type ImportSourceMatcher } from '../../utils/import_source';
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
annotateThemeCall,
|
|
35
36
|
annotateTokenDeclaration,
|
|
36
37
|
getImportedName,
|
|
38
|
+
getObjectPropertyKey,
|
|
37
39
|
isStyleChainCall,
|
|
38
40
|
} from '../syntax';
|
|
39
41
|
import type { BabelCore, BabelTypes, NodePath } from '../utils/babel';
|
|
@@ -181,6 +183,10 @@ export function createDebugPlugin(args: PluginArgs) {
|
|
|
181
183
|
const sourceContentRef = sourceContent
|
|
182
184
|
? getSourceContentId(t, state)
|
|
183
185
|
: null;
|
|
186
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
187
|
+
const isClassNameCall = rootName
|
|
188
|
+
? state.styleMetas.get(rootName)?.mode === 'ClassName'
|
|
189
|
+
: false;
|
|
184
190
|
|
|
185
191
|
path.node.arguments.push(
|
|
186
192
|
buildDebugDataObject(
|
|
@@ -192,6 +198,7 @@ export function createDebugPlugin(args: PluginArgs) {
|
|
|
192
198
|
options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat,
|
|
193
199
|
getDebugStyleArg(t, path, state, options.dev?.sourcemapMode ?? 'style'),
|
|
194
200
|
getDebugCallLoc(path, state),
|
|
201
|
+
isClassNameCall,
|
|
195
202
|
),
|
|
196
203
|
);
|
|
197
204
|
},
|
|
@@ -547,12 +554,13 @@ function getDebugStyleArg(
|
|
|
547
554
|
) {
|
|
548
555
|
const arg = getStyleObjectArg(path, state);
|
|
549
556
|
if (!arg) return arg;
|
|
557
|
+
const meta = getStyleCallMeta(path, state);
|
|
550
558
|
|
|
551
559
|
if (arg.type !== 'ObjectExpression') {
|
|
552
560
|
return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
553
561
|
}
|
|
554
562
|
|
|
555
|
-
|
|
563
|
+
const flattened = flattenDebugObjectExpression(
|
|
556
564
|
t,
|
|
557
565
|
arg,
|
|
558
566
|
path,
|
|
@@ -560,6 +568,8 @@ function getDebugStyleArg(
|
|
|
560
568
|
sourcemapTrace,
|
|
561
569
|
new Set(),
|
|
562
570
|
);
|
|
571
|
+
|
|
572
|
+
return appendTransformDebugFieldAliases(t, flattened, meta, state);
|
|
563
573
|
}
|
|
564
574
|
|
|
565
575
|
function getDebugCallLoc(
|
|
@@ -576,6 +586,11 @@ function getStyleObjectArg(
|
|
|
576
586
|
state: PluginState,
|
|
577
587
|
) {
|
|
578
588
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
589
|
+
|
|
590
|
+
if (methodName === FN_STYLE_SELECTOR) {
|
|
591
|
+
return path.node.arguments[1];
|
|
592
|
+
}
|
|
593
|
+
|
|
579
594
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
580
595
|
const selector = methodName && rootName
|
|
581
596
|
? state.styleMetas.get(rootName)?.selectors[methodName]
|
|
@@ -589,6 +604,14 @@ function getStyleObjectArg(
|
|
|
589
604
|
return path.node.arguments[styleArgIndex];
|
|
590
605
|
}
|
|
591
606
|
|
|
607
|
+
function getStyleCallMeta(
|
|
608
|
+
path: NodePath<BabelTypes.CallExpression>,
|
|
609
|
+
state: PluginState,
|
|
610
|
+
) {
|
|
611
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
612
|
+
return rootName ? state.styleMetas.get(rootName) ?? null : null;
|
|
613
|
+
}
|
|
614
|
+
|
|
592
615
|
function isSelectorStyleCall(
|
|
593
616
|
path: NodePath<BabelTypes.CallExpression>,
|
|
594
617
|
state: PluginState,
|
|
@@ -831,6 +854,72 @@ function flattenDebugObjectExpression(
|
|
|
831
854
|
return t.objectExpression(properties);
|
|
832
855
|
}
|
|
833
856
|
|
|
857
|
+
function appendTransformDebugFieldAliases(
|
|
858
|
+
t: typeof BabelTypes,
|
|
859
|
+
node: BabelTypes.ObjectExpression,
|
|
860
|
+
meta: StyleFnMeta | null,
|
|
861
|
+
state: PluginState,
|
|
862
|
+
) {
|
|
863
|
+
if (!meta || meta.mode !== 'StyleObject' || !meta.transform) return node;
|
|
864
|
+
|
|
865
|
+
const existing = new Set<string>();
|
|
866
|
+
for (const property of node.properties) {
|
|
867
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
868
|
+
const key = getObjectPropertyKey(property);
|
|
869
|
+
if (key) existing.add(key);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
const aliases: BabelTypes.ObjectProperty[] = [];
|
|
873
|
+
|
|
874
|
+
for (const property of node.properties) {
|
|
875
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
876
|
+
|
|
877
|
+
const key = getObjectPropertyKey(property);
|
|
878
|
+
if (!key) continue;
|
|
879
|
+
|
|
880
|
+
const value = evaluateNode(property.value, getDebugEvalScope(state));
|
|
881
|
+
if (!value.ok) continue;
|
|
882
|
+
|
|
883
|
+
let transformed: Record<string, unknown>;
|
|
884
|
+
try {
|
|
885
|
+
transformed = meta.transform.transform({ [key]: value.value }) as Record<string, unknown>;
|
|
886
|
+
} catch {
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
for (const transformedKey of Object.keys(transformed)) {
|
|
891
|
+
if (existing.has(transformedKey)) continue;
|
|
892
|
+
|
|
893
|
+
existing.add(transformedKey);
|
|
894
|
+
aliases.push(createDebugFieldAlias(t, transformedKey, property));
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
if (!aliases.length) return node;
|
|
899
|
+
|
|
900
|
+
return t.objectExpression([
|
|
901
|
+
...node.properties,
|
|
902
|
+
...aliases,
|
|
903
|
+
]);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function createDebugFieldAlias(
|
|
907
|
+
t: typeof BabelTypes,
|
|
908
|
+
key: string,
|
|
909
|
+
source: BabelTypes.ObjectProperty,
|
|
910
|
+
) {
|
|
911
|
+
const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral()) as DebugTraceProperty;
|
|
912
|
+
const sourceTrace = source as DebugTraceProperty;
|
|
913
|
+
|
|
914
|
+
alias.loc = source.loc;
|
|
915
|
+
alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
|
|
916
|
+
alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
|
|
917
|
+
alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
|
|
918
|
+
alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
|
|
919
|
+
|
|
920
|
+
return alias;
|
|
921
|
+
}
|
|
922
|
+
|
|
834
923
|
function resolveDebugSpreadObject(
|
|
835
924
|
t: typeof BabelTypes,
|
|
836
925
|
spread: BabelTypes.SpreadElement,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CompilerInternal, TransformDebugArgs, TransformDebugResult } from '../../compiler';
|
|
2
|
+
import { createCssPropPlugin } from '../cssProp';
|
|
2
3
|
import type { ExtractTracer } from '../extract/plugin';
|
|
3
4
|
import { babelTransform } from '../utils/babel';
|
|
4
5
|
import { createDebugPlugin } from './plugin';
|
|
@@ -34,7 +35,7 @@ export function transformDebug(
|
|
|
34
35
|
code: args.code,
|
|
35
36
|
filePath: args.filePath,
|
|
36
37
|
sourcemap: args.sourcemap,
|
|
37
|
-
plugins: [plugin],
|
|
38
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
38
39
|
retainLines: true,
|
|
39
40
|
});
|
|
40
41
|
|