@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -1
- package/README.md +10 -9
- package/atomic/className.ts +12 -12
- package/atomic/debug/className/className.ts +10 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +8 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +41 -2
- package/atomic/token.ts +4 -3
- package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/selector.ts +14 -1
- package/builder/classname/class_name_builder.ts +68 -24
- package/builder/classname/fns.ts +2 -2
- package/builder/classname/types.ts +7 -0
- package/builder/data/const.ts +7 -1
- package/builder/data/create.ts +42 -0
- package/builder/data/data.ts +20 -1
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +23 -0
- package/builder/data/merge/scope.ts +20 -19
- package/builder/data/merge/style.ts +71 -21
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- package/builder/extract/token.ts +30 -14
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +30 -0
- package/builder/selector_override_core.ts +66 -0
- package/builder/style_builder.ts +127 -3
- package/builder/style_data.ts +24 -0
- package/builder/style_fns.ts +24 -24
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/builder/types/alias.ts +34 -6
- package/builder/types/fns.ts +13 -5
- package/builder/types/types.ts +32 -2
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +4 -7
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +2 -0
- package/compiler/cssProp.ts +35 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +129 -0
- package/compiler/transform/debug/plugin.ts +85 -1
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +106 -30
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +541 -63
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +1 -1
- package/compiler/transform/extract/plugin.ts +20 -4
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +52 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +1 -8
- package/config/config/css.ts +1 -0
- package/config/config/debug.ts +11 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → combine-Ca6LfFxv.js} +427 -722
- package/dist/combine-Ca6LfFxv.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-D5v5tJXI.mjs → compiler-OgDBuqfs.mjs} +1635 -607
- package/dist/compiler-OgDBuqfs.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-OXHoDUIo.js.map → config-B-KbXpIh.js.map} +1 -1
- package/dist/config-Barf8f4B.js +35 -0
- package/dist/config-Barf8f4B.js.map +1 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/config-CsB4MuFI.js +6 -0
- package/dist/config-CsB4MuFI.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/{config-FIfi5aJ8.js → config-t76UljYv.js} +9 -7
- package/dist/config-t76UljYv.js.map +1 -0
- package/dist/createTransformElement-DDqld3RF.js +34 -0
- package/dist/createTransformElement-DDqld3RF.js.map +1 -0
- package/dist/css-CZwrac6F.js +3923 -0
- package/dist/css-CZwrac6F.js.map +1 -0
- package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
- package/dist/css-GtUPEO9U.js.map +1 -0
- package/dist/css-YfHN_8Nk.js +479 -0
- package/dist/css-YfHN_8Nk.js.map +1 -0
- package/dist/css-a9O5so0b.js +1246 -0
- package/dist/css-a9O5so0b.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
- package/dist/{css_extra-DQdCrYoC.js → css_extra-CXXZAylc.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-CXXZAylc.js.map} +1 -1
- package/dist/data-CzHJg147.js +763 -0
- package/dist/data-CzHJg147.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-DkrxyknP.js} +80 -4
- package/dist/debug-DkrxyknP.js.map +1 -0
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +6 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-fOtWB5K3.js → dev-z4laBwlS.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-z4laBwlS.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CvqqIb7J.js → elementMarker-CqhU_l_m.js} +95 -9
- package/dist/elementMarker-CqhU_l_m.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +13 -12
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +240 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -4
- package/dist/entry/prod.js +85 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +12 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +12 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +12 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +6 -10
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +323 -615
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -4
- package/dist/entry/rsc-prod.js +241 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-ydQcDBD4.js → env-Db2cRt-h.js} +1256 -355
- package/dist/env-Db2cRt-h.js.map +1 -0
- package/dist/{jsx-A4cK517J.js → getClassName-DKtQl5ZX.js} +5 -11
- package/dist/getClassName-DKtQl5ZX.js.map +1 -0
- package/dist/{utils-hoYnMiA7.js → getClassName-DaZF5nfJ.js} +28 -65
- package/dist/getClassName-DaZF5nfJ.js.map +1 -0
- package/dist/getClassName-a6p2uMFM.js +536 -0
- package/dist/getClassName-a6p2uMFM.js.map +1 -0
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-aD9zqg9U.js} +56 -14
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-zYTvWskP.js +10 -0
- package/dist/{global-Cul1dX8k.js.map → global-zYTvWskP.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BOlQThNz.js} +48 -4
- package/dist/hash-BOlQThNz.js.map +1 -0
- package/dist/index.js +10 -10
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-C2pnWLcb.js +39 -0
- package/dist/jsx-C2pnWLcb.js.map +1 -0
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-XJSHujgI.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-DHvgp0fK.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BuSLnvx0.mjs} +4 -4
- package/dist/misc-BuSLnvx0.mjs.map +1 -0
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-D3tt-joz.js} +8 -6
- package/dist/namedTokens-D3tt-joz.js.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +5 -5
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +9 -7
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-CiwvMfx8.mjs → registry-r3BKWqpI.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-r3BKWqpI.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-D5a37GNr.js +63 -0
- package/dist/resolveClassNameRuntime-D5a37GNr.js.map +1 -0
- package/dist/{rules-DlXcch7-.js → rules-B0_rKPfB.js} +598 -132
- package/dist/rules-B0_rKPfB.js.map +1 -0
- package/dist/scope-BSuRLice.js +601 -0
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +15 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-8_Msr7Q5.cjs} +1630 -597
- package/dist/shared-8_Msr7Q5.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-BGO_05rW.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
- package/dist/sheet-BpLZIIuO.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BpLZIIuO.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-Bu2x35JE.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-BDy5TH6N.js} +5 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-BDy5TH6N.js.map} +1 -1
- package/dist/styleStore-DX3z_UVK.js +51 -0
- package/dist/styleStore-DX3z_UVK.js.map +1 -0
- package/dist/token-BsW_S8fN.js +138 -0
- package/dist/token-BsW_S8fN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-BdKEpgME.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-BdKEpgME.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-DcuMxR45.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-DcuMxR45.js.map} +1 -1
- package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
- package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
- package/dist/{style-DFFK06Of.js → types-BEUgXuu2.js} +356 -129
- package/dist/types-BEUgXuu2.js.map +1 -0
- package/dist/{utils-D2fygyTm.mjs → utils-BPDxr-oc.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-BPDxr-oc.mjs.map} +1 -1
- package/dist/utils-CLnpwhJd.js +83 -0
- package/dist/utils-CLnpwhJd.js.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DTXCTUlS.mjs → utils-DZjLTV4D.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DZjLTV4D.mjs.map} +1 -1
- package/dist/utils-okFWrQsg.js +41 -0
- package/dist/utils-okFWrQsg.js.map +1 -0
- package/dist/{utils-DVFxZnVC.js → utils-sBVZEq4u.js} +190 -144
- package/dist/utils-sBVZEq4u.js.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CpJpQ00y.js +145 -0
- package/dist/value-CpJpQ00y.js.map +1 -0
- package/dist/{webpack-BOU7_xld.mjs → webpack-DTKgR-HY.mjs} +5 -5
- package/dist/webpack-DTKgR-HY.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +3 -1
- package/entry/rsc_dev/adapter/preact.ts +1 -0
- package/entry/rsc_dev/adapter/react.ts +1 -0
- package/entry/rsc_dev/adapter/solid.ts +1 -0
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +9 -7
- package/jsx/types/index.ts +3 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +78 -12
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +3 -8
- package/plugin/bundler/vite/state.ts +2 -2
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/nextjs/plugin.ts +3 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/adapter/utils.ts +94 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +54 -17
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +3 -3
- package/style/classname.ts +12 -6
- package/style/important.ts +19 -0
- package/style/index.ts +2 -0
- package/style/style.ts +17 -5
- package/style/theme.ts +0 -1
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +1 -1
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-CKo4TxuT.js +0 -144
- package/dist/className-CKo4TxuT.js.map +0 -1
- package/dist/className-ZJ5pBA-o.js +0 -263
- package/dist/className-ZJ5pBA-o.js.map +0 -1
- package/dist/compiler-D5v5tJXI.mjs.map +0 -1
- package/dist/config-BEvP7108.js.map +0 -1
- package/dist/config-B_cbG3S6.js +0 -1
- package/dist/config-FIfi5aJ8.js.map +0 -1
- package/dist/config-OXHoDUIo.js +0 -6
- package/dist/css-CELBp6Gu.js +0 -58
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-DcuJ_jSH.js +0 -243
- package/dist/css-DcuJ_jSH.js.map +0 -1
- package/dist/css-dPoZJDQH.js +0 -807
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/css-oOt6ZR54.js +0 -237
- package/dist/css-oOt6ZR54.js.map +0 -1
- package/dist/data-CeYstKMP.js +0 -482
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/debug-D96KGgpH.js.map +0 -1
- package/dist/dev-p8tW7X-A.js +0 -81
- package/dist/dev-p8tW7X-A.js.map +0 -1
- package/dist/elementMarker-CvqqIb7J.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-Cul1dX8k.js +0 -14
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/jsx-A4cK517J.js.map +0 -1
- package/dist/jsx-Ba-XV33u.js +0 -39
- package/dist/jsx-Ba-XV33u.js.map +0 -1
- package/dist/layer-CbQzwZF-.js +0 -94
- package/dist/layer-CbQzwZF-.js.map +0 -1
- package/dist/misc-DFBKJGLT.mjs.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CF6JgpTq.js +0 -406
- package/dist/property-CF6JgpTq.js.map +0 -1
- package/dist/rules-DlXcch7-.js.map +0 -1
- package/dist/runtime-BKChZZ2-.js.map +0 -1
- package/dist/shared-yDD0nfm1.cjs.map +0 -1
- package/dist/sheet-B-uJfHRY.js +0 -7
- package/dist/style-91J0B5ef.js +0 -771
- package/dist/style-91J0B5ef.js.map +0 -1
- package/dist/style-Bw5ka-Nq.js.map +0 -1
- package/dist/style-DFFK06Of.js.map +0 -1
- package/dist/style-pz8e5To1.js +0 -5
- package/dist/styleStore-ydQcDBD4.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-DTOyFLmp.js +0 -58
- package/dist/token-DTOyFLmp.js.map +0 -1
- package/dist/token-DT_sCPtm.js +0 -298
- package/dist/token-DT_sCPtm.js.map +0 -1
- package/dist/utils-Bmw655wa.js +0 -170
- package/dist/utils-Bmw655wa.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/utils-hoYnMiA7.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DvFkGBy2.js +0 -1029
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
- package/dist/valueRef-CsLVJwjA.js +0 -16
- package/dist/valueRef-CsLVJwjA.js.map +0 -1
- package/dist/webpack-BOU7_xld.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
package/builder/types/alias.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import type { AtRuleRef, PlainStyleObject, StyleKeyframesObject, StyleObject,
|
|
1
|
+
import type { AtRuleRef, PlainStyleObject, StyleKeyframesObject, StyleObject, StyleWeightValue } from '../../style';
|
|
2
|
+
import type { StyleImportantValue } from '../../style/important';
|
|
2
3
|
import type { Collapse } from '../../utils/type';
|
|
3
|
-
import type { BUILDER_SLOT_ID } from '../data';
|
|
4
|
+
import type { BUILDER_SELECTOR, BUILDER_SLOT_ID } from '../data';
|
|
5
|
+
import type { ManualSelectorInput } from '../selector_override';
|
|
4
6
|
import type { ScopeSelfFn, SlotSelfFn, StyleSelfFn } from './fns';
|
|
5
|
-
import type { MergeRuleStyleData } from './types';
|
|
6
|
-
import type {
|
|
7
|
+
import type { MergeRuleStyleData, SelectorOverrideStyleData } from './types';
|
|
8
|
+
import type {
|
|
9
|
+
ScopeBuilder,
|
|
10
|
+
SelectorBuilder,
|
|
11
|
+
SelectorOverrideBuilder,
|
|
12
|
+
SlotBuilder,
|
|
13
|
+
SlotOverrideBuilder,
|
|
14
|
+
StyleBuilder,
|
|
15
|
+
} from './types';
|
|
7
16
|
|
|
8
17
|
type _ = typeof BUILDER_SLOT_ID;
|
|
18
|
+
type __ = typeof BUILDER_SELECTOR;
|
|
9
19
|
|
|
10
20
|
export function styleRule<Style, Selectors>() {
|
|
11
21
|
type StyleRule<Style> = StyleBuilder<Style, Selectors> & Collapse;
|
|
@@ -22,6 +32,11 @@ export function slotOverrideRule<Style, Selectors>() {
|
|
|
22
32
|
return {} as SlotOverrideRule<Style>;
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
export function selectorOverrideRule<Style, Selectors>() {
|
|
36
|
+
type SelectorOverrideRule<Style> = SelectorOverrideBuilder<Style, Selectors> & Collapse;
|
|
37
|
+
return {} as SelectorOverrideRule<Style>;
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
export function scopeRule<Selectors>() {
|
|
26
41
|
type ScopeRule = ScopeBuilder<Selectors> & Collapse;
|
|
27
42
|
return {} as ScopeRule;
|
|
@@ -33,20 +48,25 @@ export function typeAliases<Style, Selectors>() {
|
|
|
33
48
|
type StyleRule<Style> = ReturnType<typeof styleRule<Style, Selectors>>;
|
|
34
49
|
type SlotRule<Style> = ReturnType<typeof slotRule<Style, Selectors>>;
|
|
35
50
|
type SlotOverrideRule<Style> = ReturnType<typeof slotOverrideRule<Style, Selectors>>;
|
|
51
|
+
type SelectorOverrideRule<Style> = ReturnType<typeof selectorOverrideRule<Style, Selectors>>;
|
|
36
52
|
type ScopeRule = ReturnType<typeof scopeRule<Selectors>>;
|
|
37
53
|
|
|
38
54
|
type StyleFn<Style> = StyleSelfFn<Style, Selectors> & {
|
|
39
55
|
(style?: StyleObject<Style>): ReturnType<typeof styleRule<Style, Selectors>>;
|
|
40
56
|
slot: SlotFn<Style>;
|
|
41
57
|
scope: ScopeFn;
|
|
42
|
-
|
|
58
|
+
weight: ValueFn;
|
|
59
|
+
important: ImportantFn;
|
|
43
60
|
raw: RawFn<Style>;
|
|
44
61
|
plain: PlainFn<Style>;
|
|
45
62
|
keyframes: KeyframesFn<Style>;
|
|
46
63
|
merge: MergeFn;
|
|
64
|
+
selector: SelectorFn<Style>;
|
|
47
65
|
};
|
|
48
66
|
|
|
49
|
-
type ValueFn = <const T>(value: T, weight: number) =>
|
|
67
|
+
type ValueFn = <const T>(value: T, weight: number) => StyleWeightValue<T>;
|
|
68
|
+
|
|
69
|
+
type ImportantFn = <const T>(value: T) => StyleImportantValue<T>;
|
|
50
70
|
|
|
51
71
|
type RawFn<Style> = <T extends StyleObject<Style>>(style: T) => T;
|
|
52
72
|
|
|
@@ -56,6 +76,11 @@ export function typeAliases<Style, Selectors>() {
|
|
|
56
76
|
|
|
57
77
|
type MergeFn = <Target>(target: Target, ...styles: MergeRuleStyleData[]) => Target;
|
|
58
78
|
|
|
79
|
+
type SelectorFn<Style> = {
|
|
80
|
+
(selector: ManualSelectorInput): SelectorBuilder<Style, Selectors>;
|
|
81
|
+
(selector: ManualSelectorInput, style: SelectorOverrideStyleData<Style>): SelectorOverrideBuilder<Style, Selectors>;
|
|
82
|
+
};
|
|
83
|
+
|
|
59
84
|
type SlotFn<Style> = SlotSelfFn<Style, Selectors>;
|
|
60
85
|
|
|
61
86
|
type ScopeFn =
|
|
@@ -66,6 +91,7 @@ export function typeAliases<Style, Selectors>() {
|
|
|
66
91
|
StyleRule: StyleRule<Style>;
|
|
67
92
|
SlotRule: SlotRule<Style>;
|
|
68
93
|
SlotOverrideRule: SlotOverrideRule<Style>;
|
|
94
|
+
SelectorOverrideRule: SelectorOverrideRule<Style>;
|
|
69
95
|
ScopeRule: ScopeRule;
|
|
70
96
|
//
|
|
71
97
|
StyleFn: StyleFn<Style>;
|
|
@@ -73,10 +99,12 @@ export function typeAliases<Style, Selectors>() {
|
|
|
73
99
|
ScopeFn: ScopeFn;
|
|
74
100
|
//
|
|
75
101
|
ValueFn: ValueFn;
|
|
102
|
+
ImportantFn: ImportantFn;
|
|
76
103
|
RawFn: RawFn<Style>;
|
|
77
104
|
PlainFn: PlainFn<Style>;
|
|
78
105
|
KeyframesFn: KeyframesFn<Style>;
|
|
79
106
|
MergeFn: MergeFn;
|
|
107
|
+
SelectorFn: SelectorFn<Style>;
|
|
80
108
|
};
|
|
81
109
|
|
|
82
110
|
return {} as Types<Style>;
|
package/builder/types/fns.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Selector } from '../../selector';
|
|
2
2
|
import type { StyleObject } from '../../style/types';
|
|
3
3
|
import type { ScopeItems } from '../data/merge/scope';
|
|
4
|
-
import type { scopeRule, slotOverrideRule, slotRule, styleRule } from './alias';
|
|
4
|
+
import type { scopeRule, selectorOverrideRule, slotOverrideRule, slotRule, styleRule } from './alias';
|
|
5
5
|
import type { AtRuleStyleData, MergeRuleStyleData } from './types';
|
|
6
6
|
|
|
7
7
|
/* style */
|
|
@@ -31,11 +31,11 @@ type StyleAtRuleNoArgFn<Style, Self> = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
type StyleMediaFn<Style, Self, Arg> = StyleAtRuleFn<Style, Self, Arg> & {
|
|
34
|
-
(
|
|
34
|
+
(weight: number, selector: Arg, style: AtRuleStyleData<Style>): Self;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
type StyleMediaNoArgFn<Style, Self> = StyleAtRuleNoArgFn<Style, Self> & {
|
|
38
|
-
(
|
|
38
|
+
(weight: number, style: AtRuleStyleData<Style>): Self;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
type StyleAtRuleArgFn<Style, Self, Arg extends string> = StyleAtRuleFn<Style, Self, Arg>;
|
|
@@ -113,11 +113,11 @@ type ScopeAtRuleNoArgFn<Style, Result> = {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
type ScopeMediaFn<Style, Result, Arg> = ScopeAtRuleFn<Style, Result, Arg> & {
|
|
116
|
-
(
|
|
116
|
+
(weight: number, selector: Arg, styles: Style): Result;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
type ScopeMediaNoArgFn<Style, Result> = ScopeAtRuleNoArgFn<Style, Result> & {
|
|
120
|
-
(
|
|
120
|
+
(weight: number, styles: Style): Result;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
type ScopeAtRuleArgFn<Style, Result, Arg extends string> = ScopeAtRuleFn<Style, Result, Arg>;
|
|
@@ -176,6 +176,14 @@ export type SlotOverrideSelectorFns<Style, Selectors> = {
|
|
|
176
176
|
>;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
export type SelectorOverrideSelectorFns<Style, Selectors> = {
|
|
180
|
+
[P in keyof Selectors]: GetStyleFn<
|
|
181
|
+
Selectors[P],
|
|
182
|
+
Style,
|
|
183
|
+
ReturnType<typeof selectorOverrideRule<Style, Selectors>>
|
|
184
|
+
>;
|
|
185
|
+
};
|
|
186
|
+
|
|
179
187
|
export type ScopeSelectorFns<Selectors> = {
|
|
180
188
|
[P in keyof Selectors]: GetScopeFn<
|
|
181
189
|
Selectors[P],
|
package/builder/types/types.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import type { Selector } from '../../selector';
|
|
2
2
|
import type { StyleObject } from '../../style/types';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DebugData,
|
|
5
|
+
ScopeData,
|
|
6
|
+
SelectorData,
|
|
7
|
+
SelectorOverrideData,
|
|
8
|
+
SlotData,
|
|
9
|
+
SlotOverrideData,
|
|
10
|
+
StyleData,
|
|
11
|
+
} from '../data';
|
|
12
|
+
import type {
|
|
13
|
+
ScopeSelectorFns,
|
|
14
|
+
ScopeSelfFn,
|
|
15
|
+
SelectorOverrideSelectorFns,
|
|
16
|
+
SlotOverrideSelectorFns,
|
|
17
|
+
SlotSelectorFns,
|
|
18
|
+
StyleSelectorFns,
|
|
19
|
+
} from './fns';
|
|
5
20
|
|
|
6
21
|
export type { ScopeSelfFn };
|
|
7
22
|
|
|
8
23
|
export type MergeRuleStyleData<Style = unknown> = StyleData<Style> | StyleData<Style>[];
|
|
9
24
|
|
|
10
25
|
export type AtRuleStyleData<Style = unknown> = StyleObject<Style> | StyleData<Style>;
|
|
26
|
+
export type SelectorOverrideStyleData<Style = unknown> = StyleObject<Style> | StyleData<Style>;
|
|
11
27
|
|
|
12
28
|
export type SelectorsRecord = Record<string, Selector>;
|
|
13
29
|
|
|
@@ -28,6 +44,10 @@ export type SlotOverrideBuilderFns<Style, Selectors> =
|
|
|
28
44
|
& SlotOverrideSelectorFns<Style, Selectors>
|
|
29
45
|
& {};
|
|
30
46
|
|
|
47
|
+
export type SelectorOverrideBuilderFns<Style, Selectors> =
|
|
48
|
+
& SelectorOverrideSelectorFns<Style, Selectors>
|
|
49
|
+
& {};
|
|
50
|
+
|
|
31
51
|
export type ScopeFns<Selectors> =
|
|
32
52
|
& ScopeSelectorFns<Selectors>
|
|
33
53
|
& {};
|
|
@@ -49,3 +69,13 @@ export type ScopeBuilder<Selectors> =
|
|
|
49
69
|
& ScopeData
|
|
50
70
|
& ScopeFns<Selectors>
|
|
51
71
|
& {};
|
|
72
|
+
|
|
73
|
+
export type SelectorBuilder<Style, Selectors> =
|
|
74
|
+
& SelectorData<Style>
|
|
75
|
+
& ((style?: SelectorOverrideStyleData<Style>, debug?: DebugData) => SelectorOverrideBuilder<Style, Selectors>)
|
|
76
|
+
& SelectorOverrideBuilderFns<Style, Selectors>;
|
|
77
|
+
|
|
78
|
+
export type SelectorOverrideBuilder<Style, Selectors> =
|
|
79
|
+
& SelectorOverrideData<Style>
|
|
80
|
+
& ((style?: SelectorOverrideStyleData<Style>) => SelectorOverrideBuilder<Style, Selectors>)
|
|
81
|
+
& SelectorOverrideBuilderFns<Style, Selectors>;
|
package/builder/utils.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type DebugData, getDebugCallsite } from './data/debug';
|
|
|
5
5
|
export const FnPrefixStyle = 'style.';
|
|
6
6
|
export const FnPrefixSlot = 'slot.';
|
|
7
7
|
export const FnPrefixScope = 'scope.';
|
|
8
|
+
export const FnPrefixSelector = 'selector.';
|
|
8
9
|
|
|
9
10
|
export function runtimeCallsite() {
|
|
10
11
|
return traceCallsite();
|
|
@@ -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;
|
|
@@ -163,6 +158,8 @@ function rewriteCompilerRuntimeImports(code: string, runtimeMode: CompilerRuntim
|
|
|
163
158
|
|
|
164
159
|
function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRuntimeMode) {
|
|
165
160
|
if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(runtimeMode);
|
|
161
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
|
|
162
|
+
if (adapterImportPath) return adapterImportPath;
|
|
166
163
|
if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(runtimeMode);
|
|
167
164
|
if (source === STYLE_EXTRACT_RUNTIME_IMPORT_PATH) return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
168
165
|
if (runtimeMode === CompilerRuntimeMode.RscDev && source === STYLE_DEV_RSC_IMPORT_PATH) {
|
|
@@ -2,6 +2,7 @@ import type { CssConfig } from '../../config/config/css';
|
|
|
2
2
|
import type { DevRuntimeOptions } from '../../config/config/dev';
|
|
3
3
|
import type { CheckSelectorMode } from '../../config/types';
|
|
4
4
|
import type { ReplaceProps } from '../../utils/type';
|
|
5
|
+
import type { CompilerCssPropOptions } from '../cssProp';
|
|
5
6
|
import type { CssExtractRule } from '../extract';
|
|
6
7
|
import type { BabelTransformSourceMap } from '../transform/utils/babel';
|
|
7
8
|
import type { ImportSource } from '../utils/import_source';
|
|
@@ -20,6 +21,7 @@ export type DevSourcemapMode = 'sourceUrl' | 'sourceContent' | 'sidecarServer';
|
|
|
20
21
|
export type CompilerOptions = {
|
|
21
22
|
hoist?: boolean;
|
|
22
23
|
css?: CompilerCssOptions;
|
|
24
|
+
cssProp?: false | CompilerCssPropOptions;
|
|
23
25
|
dev?: CompilerDevOptions;
|
|
24
26
|
|
|
25
27
|
importSources?: ImportSource[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type CompilerCssPropStyleMode = 'react' | 'solid';
|
|
2
|
+
|
|
3
|
+
export type CompilerCssPropOptions = {
|
|
4
|
+
classProp: 'class' | 'className';
|
|
5
|
+
styleProp: 'style';
|
|
6
|
+
styleMode: CompilerCssPropStyleMode;
|
|
7
|
+
adapter: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const CssPropSolid: CompilerCssPropOptions = {
|
|
11
|
+
classProp: 'class',
|
|
12
|
+
styleProp: 'style',
|
|
13
|
+
styleMode: 'solid',
|
|
14
|
+
adapter: '@fluentic/style/adapter/solid',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const CssPropPreact: CompilerCssPropOptions = {
|
|
18
|
+
classProp: 'class',
|
|
19
|
+
styleProp: 'style',
|
|
20
|
+
styleMode: 'react',
|
|
21
|
+
adapter: '@fluentic/style/adapter/preact',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const CssPropReact: CompilerCssPropOptions = {
|
|
25
|
+
classProp: 'className',
|
|
26
|
+
styleProp: 'style',
|
|
27
|
+
styleMode: 'react',
|
|
28
|
+
adapter: '@fluentic/style/adapter/react',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const CssPropPresets = {
|
|
32
|
+
Solid: CssPropSolid,
|
|
33
|
+
Preact: CssPropPreact,
|
|
34
|
+
React: CssPropReact,
|
|
35
|
+
};
|
package/compiler/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCssPropPlugin } from './plugin';
|
|
@@ -0,0 +1,129 @@
|
|
|
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 options = getCssPropOptions(state.options);
|
|
49
|
+
if (!options || !state.mergeId) return;
|
|
50
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
51
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
52
|
+
|
|
53
|
+
const parts = path.node.attributes.map((attr) => buildPart(t, attr));
|
|
54
|
+
|
|
55
|
+
path.node.attributes = [
|
|
56
|
+
t.jsxSpreadAttribute(t.callExpression(state.mergeId, [
|
|
57
|
+
t.arrayExpression(parts),
|
|
58
|
+
])),
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
state.changed = true;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getCssPropOptions(options: CompilerOptions): CompilerCssPropOptions | null {
|
|
69
|
+
return options.cssProp || null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isIntrinsicElement(name: BabelTypes.JSXOpeningElement['name']) {
|
|
73
|
+
return name.type === 'JSXIdentifier' && /^[a-z]/.test(name.name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function hasCssAttribute(attrs: readonly (BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute)[]) {
|
|
77
|
+
return attrs.some((attr) => {
|
|
78
|
+
return attr.type === 'JSXAttribute' &&
|
|
79
|
+
attr.name.type === 'JSXIdentifier' &&
|
|
80
|
+
attr.name.name === 'css';
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function buildPart(
|
|
85
|
+
t: typeof BabelTypes,
|
|
86
|
+
attr: BabelTypes.JSXAttribute | BabelTypes.JSXSpreadAttribute,
|
|
87
|
+
) {
|
|
88
|
+
if (attr.type === 'JSXSpreadAttribute') return attr.argument;
|
|
89
|
+
|
|
90
|
+
return t.objectExpression([
|
|
91
|
+
t.objectProperty(
|
|
92
|
+
getObjectKey(t, attr.name),
|
|
93
|
+
getAttributeValue(t, attr),
|
|
94
|
+
),
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getObjectKey(
|
|
99
|
+
t: typeof BabelTypes,
|
|
100
|
+
name: BabelTypes.JSXAttribute['name'],
|
|
101
|
+
) {
|
|
102
|
+
if (name.type === 'JSXIdentifier' && isValidIdentifierName(name.name)) {
|
|
103
|
+
return t.identifier(name.name);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return t.stringLiteral(getAttributeName(name));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getAttributeName(name: BabelTypes.JSXAttribute['name']) {
|
|
110
|
+
if (name.type === 'JSXIdentifier') return name.name;
|
|
111
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getAttributeValue(
|
|
115
|
+
t: typeof BabelTypes,
|
|
116
|
+
attr: BabelTypes.JSXAttribute,
|
|
117
|
+
) {
|
|
118
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
119
|
+
if (attr.value.type === 'StringLiteral') return t.stringLiteral(attr.value.value);
|
|
120
|
+
if (attr.value.type === 'JSXExpressionContainer') {
|
|
121
|
+
if (attr.value.expression.type === 'JSXEmptyExpression') return t.booleanLiteral(true);
|
|
122
|
+
return attr.value.expression;
|
|
123
|
+
}
|
|
124
|
+
return attr.value;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function isValidIdentifierName(name: string) {
|
|
128
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
129
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
FN_STYLE_PLAIN,
|
|
18
18
|
FN_STYLE_RAW,
|
|
19
19
|
FN_STYLE_SCOPE,
|
|
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';
|
|
@@ -552,12 +554,13 @@ function getDebugStyleArg(
|
|
|
552
554
|
) {
|
|
553
555
|
const arg = getStyleObjectArg(path, state);
|
|
554
556
|
if (!arg) return arg;
|
|
557
|
+
const meta = getStyleCallMeta(path, state);
|
|
555
558
|
|
|
556
559
|
if (arg.type !== 'ObjectExpression') {
|
|
557
560
|
return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
558
561
|
}
|
|
559
562
|
|
|
560
|
-
|
|
563
|
+
const flattened = flattenDebugObjectExpression(
|
|
561
564
|
t,
|
|
562
565
|
arg,
|
|
563
566
|
path,
|
|
@@ -565,6 +568,8 @@ function getDebugStyleArg(
|
|
|
565
568
|
sourcemapTrace,
|
|
566
569
|
new Set(),
|
|
567
570
|
);
|
|
571
|
+
|
|
572
|
+
return appendTransformDebugFieldAliases(t, flattened, meta, state);
|
|
568
573
|
}
|
|
569
574
|
|
|
570
575
|
function getDebugCallLoc(
|
|
@@ -581,6 +586,11 @@ function getStyleObjectArg(
|
|
|
581
586
|
state: PluginState,
|
|
582
587
|
) {
|
|
583
588
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
589
|
+
|
|
590
|
+
if (methodName === FN_STYLE_SELECTOR) {
|
|
591
|
+
return path.node.arguments[1];
|
|
592
|
+
}
|
|
593
|
+
|
|
584
594
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
585
595
|
const selector = methodName && rootName
|
|
586
596
|
? state.styleMetas.get(rootName)?.selectors[methodName]
|
|
@@ -594,6 +604,14 @@ function getStyleObjectArg(
|
|
|
594
604
|
return path.node.arguments[styleArgIndex];
|
|
595
605
|
}
|
|
596
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
|
+
|
|
597
615
|
function isSelectorStyleCall(
|
|
598
616
|
path: NodePath<BabelTypes.CallExpression>,
|
|
599
617
|
state: PluginState,
|
|
@@ -836,6 +854,72 @@ function flattenDebugObjectExpression(
|
|
|
836
854
|
return t.objectExpression(properties);
|
|
837
855
|
}
|
|
838
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
|
+
|
|
839
923
|
function resolveDebugSpreadObject(
|
|
840
924
|
t: typeof BabelTypes,
|
|
841
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
|
|