@fluentic/style 0.1.0-beta.4 → 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 +42 -1
- package/README.md +10 -9
- package/atomic/className.ts +10 -4
- package/atomic/debug/className/className.ts +10 -0
- package/atomic/rule.ts +6 -3
- 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 +6 -0
- 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 +70 -20
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- 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/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 +6 -0
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +32 -4
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +540 -62
- 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 +47 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/imports.ts +11 -1
- package/config/config/css.ts +1 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -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-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/combine-Ca6LfFxv.js +1279 -0
- package/dist/combine-Ca6LfFxv.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-CE0ZgkdH.mjs → compiler-OgDBuqfs.mjs} +1427 -546
- package/dist/compiler-OgDBuqfs.mjs.map +1 -0
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-oKOjOTWi.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-lJNLh7eM.js → config-CsB4MuFI.js} +2 -2
- package/dist/{config-lJNLh7eM.js.map → config-CsB4MuFI.js.map} +1 -1
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/{config-CduqubI8.js → config-t76UljYv.js} +3 -3
- 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/css-GtUPEO9U.js.map +1 -1
- 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-DYtS3g6Z.js → css_extra-CXXZAylc.js} +2 -2
- package/dist/{css_extra-DYtS3g6Z.js.map → css_extra-CXXZAylc.js.map} +1 -1
- package/dist/{data-D7NFt4JG.js → data-CzHJg147.js} +145 -59
- package/dist/data-CzHJg147.js.map +1 -0
- package/dist/{debug-Cvpo5cVu.js → debug-DkrxyknP.js} +80 -5
- package/dist/debug-DkrxyknP.js.map +1 -0
- package/dist/dev/rsc.js +5 -8
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-DdRWa6dJ.js → dev-z4laBwlS.js} +4 -4
- package/dist/{dev-DdRWa6dJ.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-ng0y3fN0.js → elementMarker-CqhU_l_m.js} +94 -8
- 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 +10 -8
- 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 -5
- package/dist/entry/prod.js +84 -1229
- 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 +252 -750
- 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 -5
- package/dist/entry/rsc-prod.js +236 -11
- package/dist/entry/rsc-prod.js.map +1 -1
- package/dist/{styleStore-CajcAEPO.js → env-Db2cRt-h.js} +1185 -162
- package/dist/env-Db2cRt-h.js.map +1 -0
- package/dist/{jsx-DL-DEAz8.js → getClassName-DKtQl5ZX.js} +5 -12
- package/dist/getClassName-DKtQl5ZX.js.map +1 -0
- package/dist/{utils-B_VhPBHH.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-CrNVjAoJ.js → getClassName-aD9zqg9U.js} +31 -10
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-zYTvWskP.js +10 -0
- package/dist/{global-CZBlA9E7.js.map → global-zYTvWskP.js.map} +1 -1
- package/dist/{hash-BfeJDf5U.js → hash-BOlQThNz.js} +37 -2
- package/dist/hash-BOlQThNz.js.map +1 -0
- package/dist/index.js +7 -6
- 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-aAhNYDeS.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-aAhNYDeS.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-D7Y5up6H.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-D7Y5up6H.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-C6i1bWlu.js → jsx_runtime-XJSHujgI.js} +2 -2
- package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
- package/dist/{loader-BmYS_Rju.mjs → loader-DHvgp0fK.mjs} +3 -3
- package/dist/{loader-BmYS_Rju.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
- package/dist/{misc-BIS_c7BJ.mjs → misc-BuSLnvx0.mjs} +4 -4
- package/dist/misc-BuSLnvx0.mjs.map +1 -0
- package/dist/{namedTokens-CN_yhhik.js → namedTokens-D3tt-joz.js} +3 -3
- package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-D3tt-joz.js.map} +1 -1
- 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 +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- 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 +3 -4
- 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-IaXmLQzA.mjs → registry-r3BKWqpI.mjs} +2 -2
- package/dist/{registry-IaXmLQzA.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-CxVzovt-.js → rules-B0_rKPfB.js} +583 -154
- package/dist/rules-B0_rKPfB.js.map +1 -0
- package/dist/{combine-C9vjpKCs.js → scope-BSuRLice.js} +239 -150
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +12 -9
- package/dist/server.js.map +1 -1
- package/dist/{shared-CaJuvw03.cjs → shared-8_Msr7Q5.cjs} +1352 -466
- package/dist/shared-8_Msr7Q5.cjs.map +1 -0
- package/dist/{shared-DdPTZ0O3.mjs → shared-BGO_05rW.mjs} +4 -4
- package/dist/{shared-DdPTZ0O3.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
- package/dist/sheet-BpLZIIuO.js +7 -0
- package/dist/{sheet-BWBzuy4D.js.map → sheet-BpLZIIuO.js.map} +1 -1
- package/dist/{sidecar-B3oCK9vC.mjs → sidecar-Bu2x35JE.mjs} +3 -3
- package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
- package/dist/{styleStore-0fARJlZV.js → styleStore-BDy5TH6N.js} +3 -4
- package/dist/{styleStore-0fARJlZV.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-D-S-4_mN.js → token-BsW_S8fN.js} +2 -2
- package/dist/{token-D-S-4_mN.js.map → token-BsW_S8fN.js.map} +1 -1
- package/dist/{trace-CFnhyCVf.js → trace-BdKEpgME.js} +2 -2
- package/dist/{trace-CFnhyCVf.js.map → trace-BdKEpgME.js.map} +1 -1
- package/dist/{trace-ZtgeY-8s.js → trace-DcuMxR45.js} +3 -3
- package/dist/{trace-ZtgeY-8s.js.map → trace-DcuMxR45.js.map} +1 -1
- package/dist/{style-CGaJndOl.js → types-BEUgXuu2.js} +268 -89
- package/dist/types-BEUgXuu2.js.map +1 -0
- package/dist/{utils-B5Xqf1lV.mjs → utils-BPDxr-oc.mjs} +4 -4
- package/dist/{utils-B5Xqf1lV.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-DaAiEEIG.mjs → utils-DZjLTV4D.mjs} +3 -3
- package/dist/{utils-DaAiEEIG.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-DzydRwYo.js → utils-sBVZEq4u.js} +141 -111
- 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-CHydnRXB.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/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/shared/config_dev.ts +1 -1
- 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/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/runtime/adapter/utils.ts +94 -0
- package/runtime/core/cache/combine.ts +33 -4
- package/runtime/core/cache/item.ts +31 -12
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/prop.ts +7 -6
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +179 -5
- package/runtime/extract/getClassName.ts +49 -6
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +179 -5
- 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 +16 -4
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/weight.ts +21 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-Do2Crx4b.js +0 -143
- package/dist/className-Do2Crx4b.js.map +0 -1
- package/dist/combine-C9vjpKCs.js.map +0 -1
- package/dist/combineStyle-DwAhsOmS.js +0 -26
- package/dist/combineStyle-DwAhsOmS.js.map +0 -1
- package/dist/compiler-CE0ZgkdH.mjs.map +0 -1
- package/dist/config-BE5D5x2N.js +0 -2
- package/dist/config-CduqubI8.js.map +0 -1
- package/dist/config-oKOjOTWi.js +0 -7
- package/dist/css-BewrRz3_.js +0 -243
- package/dist/css-BewrRz3_.js.map +0 -1
- package/dist/css-CiTI58yl.js +0 -1094
- package/dist/css-CiTI58yl.js.map +0 -1
- package/dist/css-Rc7ILf-3.js +0 -236
- package/dist/css-Rc7ILf-3.js.map +0 -1
- package/dist/cssIdent-BsyUXNNk.js +0 -38
- package/dist/cssIdent-BsyUXNNk.js.map +0 -1
- package/dist/cssVar-DGgQ2GIK.js +0 -92
- package/dist/cssVar-DGgQ2GIK.js.map +0 -1
- package/dist/data-D7NFt4JG.js.map +0 -1
- package/dist/debug-Cvpo5cVu.js.map +0 -1
- package/dist/dev-px0_6TNq.js +0 -81
- package/dist/dev-px0_6TNq.js.map +0 -1
- package/dist/elementMarker-ng0y3fN0.js.map +0 -1
- package/dist/extract-B-Vs88ME.js +0 -3
- package/dist/extract-CM8Fk2eK.js +0 -130
- package/dist/extract-CM8Fk2eK.js.map +0 -1
- package/dist/getClassName-CrNVjAoJ.js.map +0 -1
- package/dist/global-CZBlA9E7.js +0 -14
- package/dist/hash-BfeJDf5U.js.map +0 -1
- package/dist/jsx-BY1iFewe.js +0 -39
- package/dist/jsx-BY1iFewe.js.map +0 -1
- package/dist/jsx-DL-DEAz8.js.map +0 -1
- package/dist/layer-BSxAr-hy.js +0 -94
- package/dist/layer-BSxAr-hy.js.map +0 -1
- package/dist/misc-BIS_c7BJ.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-BuLbzviK.js +0 -406
- package/dist/property-BuLbzviK.js.map +0 -1
- package/dist/rules-CxVzovt-.js.map +0 -1
- package/dist/selector-A-mRmMnI.js +0 -64
- package/dist/selector-A-mRmMnI.js.map +0 -1
- package/dist/shared-CaJuvw03.cjs.map +0 -1
- package/dist/sheet-BWBzuy4D.js +0 -7
- package/dist/style-CGaJndOl.js.map +0 -1
- package/dist/style-DDxjKdX0.js +0 -1891
- package/dist/style-DDxjKdX0.js.map +0 -1
- package/dist/style-S7LTQbRu.js +0 -5
- package/dist/styleStore-CajcAEPO.js.map +0 -1
- package/dist/symbols-Cp4ymzKF.js +0 -14
- package/dist/symbols-Cp4ymzKF.js.map +0 -1
- package/dist/utils-B_VhPBHH.js.map +0 -1
- package/dist/utils-CDUaX81o.js +0 -170
- package/dist/utils-CDUaX81o.js.map +0 -1
- package/dist/utils-DzydRwYo.js.map +0 -1
- package/dist/value-C0JRsyax.js +0 -64
- package/dist/value-C0JRsyax.js.map +0 -1
- package/dist/value-D08AocUs.js +0 -1053
- package/dist/value-D08AocUs.js.map +0 -1
- package/dist/valueRef-M3E1oza7.js +0 -16
- package/dist/valueRef-M3E1oza7.js.map +0 -1
- package/dist/webpack-CHydnRXB.mjs.map +0 -1
- package/dist/withTokens-DAzUIPvA.js +0 -95
- package/dist/withTokens-DAzUIPvA.js.map +0 -1
|
@@ -26,11 +26,11 @@ let node_fs = require("node:fs");
|
|
|
26
26
|
node_fs = __toESM(node_fs, 1);
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
+
let _babel_core = require("@babel/core");
|
|
30
|
+
_babel_core = __toESM(_babel_core, 1);
|
|
29
31
|
let picomatch = require("picomatch");
|
|
30
32
|
picomatch = __toESM(picomatch, 1);
|
|
31
33
|
let css_what = require("css-what");
|
|
32
|
-
let _babel_core = require("@babel/core");
|
|
33
|
-
_babel_core = __toESM(_babel_core, 1);
|
|
34
34
|
let oxc_resolver = require("oxc-resolver");
|
|
35
35
|
require("@parcel/plugin");
|
|
36
36
|
let node_http = require("node:http");
|
|
@@ -64,6 +64,7 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
64
64
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region config/utils.ts
|
|
67
|
+
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
67
68
|
function getCacheTTL(cache) {
|
|
68
69
|
return cache === true ? 3e5 : cache === false ? 0 : Math.max(cache, 0);
|
|
69
70
|
}
|
|
@@ -77,7 +78,7 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
77
78
|
isRSC: false,
|
|
78
79
|
runtimeCacheTTL: getCacheTTL(true)
|
|
79
80
|
};
|
|
80
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
81
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
81
82
|
globalData("config.build", () => ({ current: null }));
|
|
82
83
|
//#endregion
|
|
83
84
|
//#region config/config/debug.ts
|
|
@@ -110,8 +111,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
110
111
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
111
112
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
112
113
|
}
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region atomic/layer/types.ts
|
|
115
114
|
const LayerDefaultPriority = [
|
|
116
115
|
0,
|
|
117
116
|
0,
|
|
@@ -200,6 +199,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
200
199
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
201
200
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
202
201
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
202
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
203
203
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
204
204
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
205
205
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -426,6 +426,131 @@ function getCacheKey(args) {
|
|
|
426
426
|
return node_crypto.createHash("md5").update(args.cacheType).update("\0").update(node_path.resolve(args.filePath)).digest("hex");
|
|
427
427
|
}
|
|
428
428
|
//#endregion
|
|
429
|
+
//#region compiler/transform/utils/babel.ts
|
|
430
|
+
function babelPlugin(factory) {
|
|
431
|
+
return factory;
|
|
432
|
+
}
|
|
433
|
+
function babelTransform(args) {
|
|
434
|
+
let result = null;
|
|
435
|
+
try {
|
|
436
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
437
|
+
result = _babel_core.transformSync(args.code, {
|
|
438
|
+
...babelTransformOptions(),
|
|
439
|
+
inputSourceMap,
|
|
440
|
+
filename: args.filePath,
|
|
441
|
+
sourceFileName: args.filePath,
|
|
442
|
+
plugins: args.plugins,
|
|
443
|
+
sourceMaps: true,
|
|
444
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
445
|
+
});
|
|
446
|
+
} catch (err) {
|
|
447
|
+
if (!args.errorLabel) throw err;
|
|
448
|
+
const message = getBabelError(err, args);
|
|
449
|
+
const error = new Error(message);
|
|
450
|
+
error.stack = void 0;
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
if (!result || !result.code) return null;
|
|
454
|
+
return {
|
|
455
|
+
code: result.code,
|
|
456
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function babelTransformOptions() {
|
|
460
|
+
return {
|
|
461
|
+
configFile: false,
|
|
462
|
+
babelrc: false,
|
|
463
|
+
parserOpts: {
|
|
464
|
+
plugins: ["typescript", "jsx"],
|
|
465
|
+
strictMode: false,
|
|
466
|
+
allowImportExportEverywhere: true
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function parseInputSourceMap(sourcemap) {
|
|
471
|
+
if (!sourcemap) return void 0;
|
|
472
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
473
|
+
return JSON.parse(sourcemap);
|
|
474
|
+
}
|
|
475
|
+
function getBabelError(err, args) {
|
|
476
|
+
const babelErr = err;
|
|
477
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
478
|
+
const codeFrame = babelErr?.codeFrame;
|
|
479
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
480
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
484
|
+
function createCssPropPlugin(args) {
|
|
485
|
+
return babelPlugin((babel) => {
|
|
486
|
+
const { types: t } = babel;
|
|
487
|
+
return {
|
|
488
|
+
pre() {
|
|
489
|
+
this.options = args.options;
|
|
490
|
+
this.mergeId = null;
|
|
491
|
+
this.programPath = null;
|
|
492
|
+
this.changed = false;
|
|
493
|
+
},
|
|
494
|
+
visitor: {
|
|
495
|
+
Program: {
|
|
496
|
+
enter(path, state) {
|
|
497
|
+
state.programPath = path;
|
|
498
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
499
|
+
},
|
|
500
|
+
exit(path, state) {
|
|
501
|
+
const options = getCssPropOptions(state.options);
|
|
502
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
503
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
JSXOpeningElement(path, state) {
|
|
507
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
508
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
509
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
510
|
+
const parts = path.node.attributes.map((attr) => buildPart(t, attr));
|
|
511
|
+
path.node.attributes = [t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
512
|
+
state.changed = true;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function getCssPropOptions(options) {
|
|
519
|
+
return options.cssProp || null;
|
|
520
|
+
}
|
|
521
|
+
function isIntrinsicElement(name) {
|
|
522
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
523
|
+
}
|
|
524
|
+
function hasCssAttribute(attrs) {
|
|
525
|
+
return attrs.some((attr) => {
|
|
526
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function buildPart(t, attr) {
|
|
530
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
531
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
532
|
+
}
|
|
533
|
+
function getObjectKey(t, name) {
|
|
534
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
535
|
+
return t.stringLiteral(getAttributeName(name));
|
|
536
|
+
}
|
|
537
|
+
function getAttributeName(name) {
|
|
538
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
539
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
540
|
+
}
|
|
541
|
+
function getAttributeValue(t, attr) {
|
|
542
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
543
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
544
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
545
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
546
|
+
return attr.value.expression;
|
|
547
|
+
}
|
|
548
|
+
return attr.value;
|
|
549
|
+
}
|
|
550
|
+
function isValidIdentifierName(name) {
|
|
551
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
429
554
|
//#region builder/data/const.ts
|
|
430
555
|
const BUILDER_TYPE = symbol("builder.type");
|
|
431
556
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -433,8 +558,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
433
558
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
434
559
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
435
560
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
561
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
562
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
436
563
|
//#endregion
|
|
437
564
|
//#region utils/object.ts
|
|
565
|
+
function hasOwn(target, field) {
|
|
566
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
567
|
+
}
|
|
438
568
|
function toArray(value) {
|
|
439
569
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
440
570
|
}
|
|
@@ -611,6 +741,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
611
741
|
}
|
|
612
742
|
//#endregion
|
|
613
743
|
//#region builder/data/is.ts
|
|
744
|
+
function getSlotId(data) {
|
|
745
|
+
return data[BUILDER_SLOT_ID];
|
|
746
|
+
}
|
|
747
|
+
function getScopeTargetSlotId(data) {
|
|
748
|
+
return data[BUILDER_SCOPE_ID];
|
|
749
|
+
}
|
|
750
|
+
function getScopeTargetScope(data) {
|
|
751
|
+
return data[BUILDER_SCOPE];
|
|
752
|
+
}
|
|
614
753
|
function isStyleData(value) {
|
|
615
754
|
return getBuilderType(value) === 1;
|
|
616
755
|
}
|
|
@@ -620,9 +759,18 @@ function isSlotData(value) {
|
|
|
620
759
|
function isSlotOverrideData(value) {
|
|
621
760
|
return getBuilderType(value) === 3;
|
|
622
761
|
}
|
|
762
|
+
function isSelectorData(value) {
|
|
763
|
+
return getBuilderType(value) === 7;
|
|
764
|
+
}
|
|
765
|
+
function isSheetData(value) {
|
|
766
|
+
return getBuilderType(value) === 9;
|
|
767
|
+
}
|
|
623
768
|
function isScopeData(value) {
|
|
624
769
|
return getBuilderType(value) === 4;
|
|
625
770
|
}
|
|
771
|
+
function isThemeData(value) {
|
|
772
|
+
return getBuilderType(value) === 6;
|
|
773
|
+
}
|
|
626
774
|
function getBuilderType(value) {
|
|
627
775
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
628
776
|
return value[BUILDER_TYPE];
|
|
@@ -859,114 +1007,6 @@ selectorPriority({
|
|
|
859
1007
|
...AtRuleSelectors
|
|
860
1008
|
}, PrioritySelectors);
|
|
861
1009
|
//#endregion
|
|
862
|
-
//#region selector/validate.ts
|
|
863
|
-
function isLocalSelector(selector) {
|
|
864
|
-
const groups = parseSelector(selector);
|
|
865
|
-
if (!groups || groups.length !== 1) return false;
|
|
866
|
-
return isSelectorGroupsSelf(groups, false);
|
|
867
|
-
}
|
|
868
|
-
function isPseudoArgSelector(selector) {
|
|
869
|
-
const groups = parseSelector(selector);
|
|
870
|
-
if (!groups || groups.length !== 1) return false;
|
|
871
|
-
return isSelectorGroupsSelf(groups, true);
|
|
872
|
-
}
|
|
873
|
-
function isTagSelector(selector) {
|
|
874
|
-
const groups = parseSelector(selector);
|
|
875
|
-
if (!groups || groups.length !== 1) return false;
|
|
876
|
-
const group = groups[0];
|
|
877
|
-
return group.length === 1 && group[0].type === css_what.SelectorType.Tag;
|
|
878
|
-
}
|
|
879
|
-
function isAttrArg(value) {
|
|
880
|
-
if (!value) return false;
|
|
881
|
-
if (value.includes("[") || value.includes("]")) return false;
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
function isRawValue(value) {
|
|
885
|
-
if (!value) return false;
|
|
886
|
-
if (value.includes("{") || value.includes("}")) return false;
|
|
887
|
-
return true;
|
|
888
|
-
}
|
|
889
|
-
function parseSelector(selector) {
|
|
890
|
-
try {
|
|
891
|
-
return (0, css_what.parse)(selector);
|
|
892
|
-
} catch {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
function isSelectorGroupsSelf(groups, allowTag) {
|
|
897
|
-
for (let i = 0; i < groups.length; i++) {
|
|
898
|
-
const group = groups[i];
|
|
899
|
-
for (let j = 0; j < group.length; j++) {
|
|
900
|
-
const token = group[j];
|
|
901
|
-
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
902
|
-
if (token.type === css_what.SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return true;
|
|
906
|
-
}
|
|
907
|
-
function isAllowedSelectorType(type, allowTag) {
|
|
908
|
-
return type === css_what.SelectorType.Attribute || type === css_what.SelectorType.Pseudo || type === css_what.SelectorType.PseudoElement || allowTag && type === css_what.SelectorType.Tag;
|
|
909
|
-
}
|
|
910
|
-
//#endregion
|
|
911
|
-
//#region selector/assert.ts
|
|
912
|
-
function assertSelector(type, value) {
|
|
913
|
-
assertSelectorNotEmpty(value);
|
|
914
|
-
if (!type) return;
|
|
915
|
-
if (typeof type === "function") return type(value);
|
|
916
|
-
switch (type) {
|
|
917
|
-
case "local": return assertLocalSelector(value);
|
|
918
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
919
|
-
case "tag": return assertTagSelector(value);
|
|
920
|
-
case "attr": return assertAttrSelector(value);
|
|
921
|
-
case "value": return assertRawValue(value);
|
|
922
|
-
case "media": return assertMediaQuery(value);
|
|
923
|
-
case "supports": return assertSupportsQuery(value);
|
|
924
|
-
case "container": return assertContainerQuery(value);
|
|
925
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
929
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
930
|
-
});
|
|
931
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
932
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
933
|
-
});
|
|
934
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
935
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
936
|
-
});
|
|
937
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
938
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
939
|
-
});
|
|
940
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
941
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
942
|
-
});
|
|
943
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
944
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
945
|
-
});
|
|
946
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
947
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
948
|
-
});
|
|
949
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
950
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
951
|
-
});
|
|
952
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
953
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
954
|
-
});
|
|
955
|
-
//#endregion
|
|
956
|
-
//#region builder/data/check_selector.ts
|
|
957
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
958
|
-
let message = null;
|
|
959
|
-
try {
|
|
960
|
-
assertSelector(fnSelector.assert, arg);
|
|
961
|
-
} catch (error) {
|
|
962
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
963
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
964
|
-
else message = "selector is invalid: " + arg;
|
|
965
|
-
}
|
|
966
|
-
if (!message) return;
|
|
967
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
968
|
-
}
|
|
969
|
-
//#endregion
|
|
970
1010
|
//#region builder/data/create.ts
|
|
971
1011
|
function createStyleData(callsite) {
|
|
972
1012
|
return {
|
|
@@ -1000,6 +1040,28 @@ function createSlotOverrideData(callsite, slotId) {
|
|
|
1000
1040
|
[BUILDER_SLOT_ID]: slotId
|
|
1001
1041
|
};
|
|
1002
1042
|
}
|
|
1043
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
1044
|
+
return {
|
|
1045
|
+
[BUILDER_TYPE]: 8,
|
|
1046
|
+
[BUILDER_STATE]: {
|
|
1047
|
+
items: [],
|
|
1048
|
+
lookup: {}
|
|
1049
|
+
},
|
|
1050
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1051
|
+
[BUILDER_SELECTOR]: selectors
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
function createSelectorData(callsite, selectors) {
|
|
1055
|
+
return {
|
|
1056
|
+
[BUILDER_TYPE]: 7,
|
|
1057
|
+
[BUILDER_STATE]: {
|
|
1058
|
+
items: [],
|
|
1059
|
+
lookup: {}
|
|
1060
|
+
},
|
|
1061
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1062
|
+
[BUILDER_SELECTOR]: selectors
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1003
1065
|
function createScopeData(callsite) {
|
|
1004
1066
|
return {
|
|
1005
1067
|
[BUILDER_TYPE]: 4,
|
|
@@ -1135,6 +1197,9 @@ const formatTransformClassName = createNameFormatter(["className"]);
|
|
|
1135
1197
|
function getDebugClassName(format, hash, info) {
|
|
1136
1198
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
1137
1199
|
}
|
|
1200
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1201
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1202
|
+
}
|
|
1138
1203
|
function getDebugTransformClassName(format, hash, info) {
|
|
1139
1204
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1140
1205
|
}
|
|
@@ -1330,9 +1395,9 @@ function parseAtRule(rule) {
|
|
|
1330
1395
|
return compressQuery(normalized);
|
|
1331
1396
|
}
|
|
1332
1397
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1333
|
-
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
1398
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1334
1399
|
}
|
|
1335
|
-
function formatScopeClassName(format, info) {
|
|
1400
|
+
function formatScopeClassName$1(format, info) {
|
|
1336
1401
|
if (typeof format === "function") return format(info);
|
|
1337
1402
|
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1338
1403
|
}
|
|
@@ -1386,21 +1451,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1386
1451
|
}
|
|
1387
1452
|
//#endregion
|
|
1388
1453
|
//#region atomic/utils/selector.ts
|
|
1389
|
-
function getSelectorText(selector) {
|
|
1390
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1454
|
+
function getSelectorText$1(selector) {
|
|
1455
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1391
1456
|
}
|
|
1392
1457
|
function getSelectorHash(selector) {
|
|
1393
1458
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1394
1459
|
}
|
|
1395
|
-
function getSelectorPriority(selector) {
|
|
1460
|
+
function getSelectorPriority$1(selector) {
|
|
1396
1461
|
if (!selector) return 0;
|
|
1397
1462
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1398
1463
|
}
|
|
1464
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1465
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1466
|
+
}
|
|
1467
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1468
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1469
|
+
}
|
|
1399
1470
|
//#endregion
|
|
1400
1471
|
//#region atomic/className.ts
|
|
1401
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1472
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1402
1473
|
let hash = property;
|
|
1403
1474
|
hash += "\n" + (priority || "");
|
|
1475
|
+
if (important) hash += "\nimportant";
|
|
1404
1476
|
hash += "\n" + value;
|
|
1405
1477
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1406
1478
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1410,10 +1482,11 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1410
1482
|
if (!debugClassName) return hash;
|
|
1411
1483
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1412
1484
|
const propertyName = getDebugPropertyName(property, value);
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1485
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1486
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1487
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1488
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1489
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1417
1490
|
property: propertyName ? propertyName.property : property,
|
|
1418
1491
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1419
1492
|
});
|
|
@@ -1422,9 +1495,10 @@ function getRuntimeClassNameHashLength(debugClassName) {
|
|
|
1422
1495
|
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1423
1496
|
return CSS_CONFIG.hashLength ?? 7;
|
|
1424
1497
|
}
|
|
1425
|
-
function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
|
|
1498
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1426
1499
|
let hash = property;
|
|
1427
1500
|
hash += "\n" + (priority || "");
|
|
1501
|
+
if (important) hash += "\nimportant";
|
|
1428
1502
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1429
1503
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1430
1504
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1461,7 +1535,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1461
1535
|
let source;
|
|
1462
1536
|
let item;
|
|
1463
1537
|
let lookupIndex;
|
|
1464
|
-
let
|
|
1538
|
+
let weight;
|
|
1539
|
+
let important;
|
|
1465
1540
|
let value;
|
|
1466
1541
|
let atRule;
|
|
1467
1542
|
let dedupe;
|
|
@@ -1472,7 +1547,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1472
1547
|
source = sourceItems[i];
|
|
1473
1548
|
if (!source) continue;
|
|
1474
1549
|
if (isStyleTokenOverrideData(source)) {
|
|
1475
|
-
addTokenOverride(source, styles, lookup);
|
|
1550
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1476
1551
|
continue;
|
|
1477
1552
|
}
|
|
1478
1553
|
if (isScopeData(source)) {
|
|
@@ -1480,7 +1555,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1480
1555
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1481
1556
|
item = scopeItems[j];
|
|
1482
1557
|
if (isStyleTokenOverrideData(item)) {
|
|
1483
|
-
addTokenOverride(item, styles, lookup);
|
|
1558
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1484
1559
|
continue;
|
|
1485
1560
|
}
|
|
1486
1561
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1501,13 +1576,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1501
1576
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1502
1577
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1503
1578
|
value = scopeItem.value;
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
}
|
|
1509
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1510
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1579
|
+
weight = scopeItem.weight;
|
|
1580
|
+
important = scopeItem.important;
|
|
1581
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1582
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1511
1583
|
scopeItem.dedupe = dedupe;
|
|
1512
1584
|
scopeItem.className = className;
|
|
1513
1585
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1544,6 +1616,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1544
1616
|
dedupe: "",
|
|
1545
1617
|
className: "",
|
|
1546
1618
|
property: overrideItem.property,
|
|
1619
|
+
weight: overrideItem.weight,
|
|
1620
|
+
important: overrideItem.important,
|
|
1547
1621
|
value: overrideItem.value,
|
|
1548
1622
|
transformClassName: overrideItem.transformClassName,
|
|
1549
1623
|
token: overrideItem.token,
|
|
@@ -1555,13 +1629,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1555
1629
|
parentSelector
|
|
1556
1630
|
};
|
|
1557
1631
|
value = scopeItem.value;
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1563
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1564
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1632
|
+
weight = scopeItem.weight;
|
|
1633
|
+
important = scopeItem.important;
|
|
1634
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1635
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1565
1636
|
scopeItem.dedupe = dedupe;
|
|
1566
1637
|
scopeItem.className = className;
|
|
1567
1638
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1572,7 +1643,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1572
1643
|
}
|
|
1573
1644
|
return data;
|
|
1574
1645
|
}
|
|
1575
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1646
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1576
1647
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1577
1648
|
const lookupIndex = lookup[lookupKey];
|
|
1578
1649
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1717,6 +1788,18 @@ function shouldAppendCssPx(property) {
|
|
|
1717
1788
|
return !UNITLESS.has(property);
|
|
1718
1789
|
}
|
|
1719
1790
|
//#endregion
|
|
1791
|
+
//#region style/important.ts
|
|
1792
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1793
|
+
function importantValue(value) {
|
|
1794
|
+
return {
|
|
1795
|
+
[STYLE_IMPORTANT]: true,
|
|
1796
|
+
value
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
function isStyleImportantValue(value) {
|
|
1800
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1801
|
+
}
|
|
1802
|
+
//#endregion
|
|
1720
1803
|
//#region style/transform.ts
|
|
1721
1804
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1722
1805
|
function classNameValue(value, className) {
|
|
@@ -1742,6 +1825,19 @@ function isAtRuleRef(value) {
|
|
|
1742
1825
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1743
1826
|
}
|
|
1744
1827
|
//#endregion
|
|
1828
|
+
//#region style/weight.ts
|
|
1829
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1830
|
+
function weightValue(value, weight) {
|
|
1831
|
+
return {
|
|
1832
|
+
[STYLE_WEIGHT]: true,
|
|
1833
|
+
value,
|
|
1834
|
+
weight
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
function isStyleWeightValue(value) {
|
|
1838
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1839
|
+
}
|
|
1840
|
+
//#endregion
|
|
1745
1841
|
//#region builder/data/merge/style.ts
|
|
1746
1842
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1747
1843
|
if (!style) return source;
|
|
@@ -1752,7 +1848,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1752
1848
|
let itemData;
|
|
1753
1849
|
let valueRaw;
|
|
1754
1850
|
let value;
|
|
1755
|
-
let
|
|
1851
|
+
let weight;
|
|
1852
|
+
let important;
|
|
1756
1853
|
let itemCallsite;
|
|
1757
1854
|
let className;
|
|
1758
1855
|
let dedupe;
|
|
@@ -1773,6 +1870,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1773
1870
|
continue;
|
|
1774
1871
|
}
|
|
1775
1872
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1873
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1776
1874
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1777
1875
|
type: 2,
|
|
1778
1876
|
slotId
|
|
@@ -1781,6 +1879,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1781
1879
|
type: 3,
|
|
1782
1880
|
slotId
|
|
1783
1881
|
});
|
|
1882
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1784
1883
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1785
1884
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1786
1885
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1792,11 +1891,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1792
1891
|
}
|
|
1793
1892
|
} else for (const property in style) {
|
|
1794
1893
|
valueRaw = style[property];
|
|
1795
|
-
|
|
1796
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1797
|
-
priority = valueRaw[0];
|
|
1798
|
-
valueRaw = valueRaw[1];
|
|
1799
|
-
}
|
|
1894
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1800
1895
|
transformClassName = null;
|
|
1801
1896
|
if (isClassNameValue(valueRaw)) {
|
|
1802
1897
|
transformClassName = valueRaw.className;
|
|
@@ -1807,7 +1902,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1807
1902
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1808
1903
|
variableName = getDebugFieldVarName(debug, property);
|
|
1809
1904
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1810
|
-
value = priority !== null ? [value, priority] : value;
|
|
1811
1905
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1812
1906
|
itemData = {
|
|
1813
1907
|
runtime: runtimeType,
|
|
@@ -1816,6 +1910,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1816
1910
|
dedupe: "",
|
|
1817
1911
|
className: "",
|
|
1818
1912
|
property,
|
|
1913
|
+
weight,
|
|
1914
|
+
important,
|
|
1819
1915
|
value,
|
|
1820
1916
|
transformClassName,
|
|
1821
1917
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1829,7 +1925,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1829
1925
|
atRule,
|
|
1830
1926
|
callsite: itemCallsite
|
|
1831
1927
|
};
|
|
1832
|
-
if (type === 1) {
|
|
1928
|
+
if (type === 1 || type === 8) {
|
|
1833
1929
|
items.push({
|
|
1834
1930
|
...itemData,
|
|
1835
1931
|
type: 1
|
|
@@ -1876,13 +1972,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1876
1972
|
}
|
|
1877
1973
|
const runtimeItem = item;
|
|
1878
1974
|
value = runtimeItem.value;
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
}
|
|
1884
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1885
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1975
|
+
weight = runtimeItem.weight;
|
|
1976
|
+
important = runtimeItem.important;
|
|
1977
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1978
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1886
1979
|
runtimeItem.dedupe = dedupe;
|
|
1887
1980
|
runtimeItem.className = className;
|
|
1888
1981
|
lookupIndex = lookup[dedupe];
|
|
@@ -1891,19 +1984,54 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1891
1984
|
}
|
|
1892
1985
|
return data;
|
|
1893
1986
|
}
|
|
1894
|
-
function
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1987
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1988
|
+
let weight = null;
|
|
1989
|
+
let important = false;
|
|
1990
|
+
while (true) {
|
|
1991
|
+
if (isStyleImportantValue(value)) {
|
|
1992
|
+
important = true;
|
|
1993
|
+
value = value.value;
|
|
1994
|
+
continue;
|
|
1995
|
+
}
|
|
1996
|
+
if (isStyleWeightValue(value)) {
|
|
1997
|
+
weight = value.weight;
|
|
1998
|
+
value = value.value;
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
break;
|
|
2002
|
+
}
|
|
2003
|
+
return [
|
|
2004
|
+
value,
|
|
2005
|
+
weight,
|
|
2006
|
+
important
|
|
2007
|
+
];
|
|
2008
|
+
}
|
|
2009
|
+
function combineSelectors$1(parent, child) {
|
|
2010
|
+
const parentText = getSelectorText(parent);
|
|
2011
|
+
const childText = getSelectorText(child);
|
|
2012
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
2013
|
+
const selector = parentText + childText;
|
|
2014
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
2015
|
+
}
|
|
2016
|
+
function getSelectorText(selector) {
|
|
2017
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
2018
|
+
}
|
|
2019
|
+
function getSelectorPriority(selector) {
|
|
2020
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
2021
|
+
}
|
|
2022
|
+
function getMergedStyleDebug(debug, item) {
|
|
2023
|
+
if (!debug) return null;
|
|
2024
|
+
if (debug.fields?.[item.property]) return debug;
|
|
2025
|
+
const valueLoc = getMergedItemValueLoc(item);
|
|
2026
|
+
if (!valueLoc) return debug;
|
|
2027
|
+
return {
|
|
2028
|
+
...debug,
|
|
2029
|
+
fields: {
|
|
2030
|
+
...debug.fields,
|
|
2031
|
+
[item.property]: {
|
|
2032
|
+
[0]: withDebugSource$1(debug.loc, debug),
|
|
2033
|
+
[1]: valueLoc
|
|
2034
|
+
}
|
|
1907
2035
|
}
|
|
1908
2036
|
};
|
|
1909
2037
|
}
|
|
@@ -1934,6 +2062,47 @@ function withDebugSource$1(loc, debug) {
|
|
|
1934
2062
|
];
|
|
1935
2063
|
}
|
|
1936
2064
|
//#endregion
|
|
2065
|
+
//#region builder/selector_override_core.ts
|
|
2066
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
2067
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
2068
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
2069
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
2070
|
+
}
|
|
2071
|
+
function assertManualSelectorSyntax(selector) {
|
|
2072
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
2073
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
2074
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
2075
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2076
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
2077
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2078
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
2079
|
+
}
|
|
2080
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
2081
|
+
const value = selector.trim();
|
|
2082
|
+
assertManualSelector(value);
|
|
2083
|
+
if (value.startsWith("&?")) {
|
|
2084
|
+
const suffix = value.slice(2);
|
|
2085
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
2086
|
+
}
|
|
2087
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
2088
|
+
}
|
|
2089
|
+
//#endregion
|
|
2090
|
+
//#region builder/selector_override.ts
|
|
2091
|
+
function normalizeManualSelectors(input) {
|
|
2092
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
2093
|
+
}
|
|
2094
|
+
function assertManualSelector(selector) {
|
|
2095
|
+
assertManualSelectorSyntax(selector);
|
|
2096
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2097
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2098
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
2099
|
+
try {
|
|
2100
|
+
(0, css_what.parse)(parsedSelector);
|
|
2101
|
+
} catch {
|
|
2102
|
+
throw new Error("selector is invalid: " + selector);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
//#endregion
|
|
1937
2106
|
//#region builder/style_data.ts
|
|
1938
2107
|
const mergeStyleCreate = (callsite) => {
|
|
1939
2108
|
return createStyleData(callsite);
|
|
@@ -1947,16 +2116,129 @@ const mergeSlotOverrideCreate = (callsite, data) => {
|
|
|
1947
2116
|
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1948
2117
|
};
|
|
1949
2118
|
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
2119
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
2120
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
2121
|
+
};
|
|
2122
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1950
2123
|
function createMerge(create, type) {
|
|
1951
2124
|
return (data, callsite, style, debug, selector, atRule) => {
|
|
1952
2125
|
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1953
2126
|
};
|
|
1954
2127
|
}
|
|
1955
2128
|
//#endregion
|
|
2129
|
+
//#region selector/validate.ts
|
|
2130
|
+
function isLocalSelector(selector) {
|
|
2131
|
+
const groups = parseSelector(selector);
|
|
2132
|
+
if (!groups || groups.length !== 1) return false;
|
|
2133
|
+
return isSelectorGroupsSelf(groups, false);
|
|
2134
|
+
}
|
|
2135
|
+
function isPseudoArgSelector(selector) {
|
|
2136
|
+
const groups = parseSelector(selector);
|
|
2137
|
+
if (!groups || groups.length !== 1) return false;
|
|
2138
|
+
return isSelectorGroupsSelf(groups, true);
|
|
2139
|
+
}
|
|
2140
|
+
function isTagSelector(selector) {
|
|
2141
|
+
const groups = parseSelector(selector);
|
|
2142
|
+
if (!groups || groups.length !== 1) return false;
|
|
2143
|
+
const group = groups[0];
|
|
2144
|
+
return group.length === 1 && group[0].type === css_what.SelectorType.Tag;
|
|
2145
|
+
}
|
|
2146
|
+
function isAttrArg(value) {
|
|
2147
|
+
if (!value) return false;
|
|
2148
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
2149
|
+
return true;
|
|
2150
|
+
}
|
|
2151
|
+
function isRawValue(value) {
|
|
2152
|
+
if (!value) return false;
|
|
2153
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
2154
|
+
return true;
|
|
2155
|
+
}
|
|
2156
|
+
function parseSelector(selector) {
|
|
2157
|
+
try {
|
|
2158
|
+
return (0, css_what.parse)(selector);
|
|
2159
|
+
} catch {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
2164
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2165
|
+
const group = groups[i];
|
|
2166
|
+
for (let j = 0; j < group.length; j++) {
|
|
2167
|
+
const token = group[j];
|
|
2168
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2169
|
+
if (token.type === css_what.SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return true;
|
|
2173
|
+
}
|
|
2174
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2175
|
+
return type === css_what.SelectorType.Attribute || type === css_what.SelectorType.Pseudo || type === css_what.SelectorType.PseudoElement || allowTag && type === css_what.SelectorType.Tag;
|
|
2176
|
+
}
|
|
2177
|
+
//#endregion
|
|
2178
|
+
//#region selector/assert.ts
|
|
2179
|
+
function assertSelector(type, value) {
|
|
2180
|
+
assertSelectorNotEmpty(value);
|
|
2181
|
+
if (!type) return;
|
|
2182
|
+
if (typeof type === "function") return type(value);
|
|
2183
|
+
switch (type) {
|
|
2184
|
+
case "local": return assertLocalSelector(value);
|
|
2185
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2186
|
+
case "tag": return assertTagSelector(value);
|
|
2187
|
+
case "attr": return assertAttrSelector(value);
|
|
2188
|
+
case "value": return assertRawValue(value);
|
|
2189
|
+
case "media": return assertMediaQuery(value);
|
|
2190
|
+
case "supports": return assertSupportsQuery(value);
|
|
2191
|
+
case "container": return assertContainerQuery(value);
|
|
2192
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2196
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2197
|
+
});
|
|
2198
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2199
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2200
|
+
});
|
|
2201
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2202
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2203
|
+
});
|
|
2204
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2205
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2206
|
+
});
|
|
2207
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2208
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2209
|
+
});
|
|
2210
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2211
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2212
|
+
});
|
|
2213
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2214
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2215
|
+
});
|
|
2216
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2217
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2218
|
+
});
|
|
2219
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2220
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2221
|
+
});
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region builder/data/check_selector.ts
|
|
2224
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2225
|
+
let message = null;
|
|
2226
|
+
try {
|
|
2227
|
+
assertSelector(fnSelector.assert, arg);
|
|
2228
|
+
} catch (error) {
|
|
2229
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2230
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2231
|
+
else message = "selector is invalid: " + arg;
|
|
2232
|
+
}
|
|
2233
|
+
if (!message) return;
|
|
2234
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
2235
|
+
}
|
|
2236
|
+
//#endregion
|
|
1956
2237
|
//#region builder/utils.ts
|
|
1957
2238
|
const FnPrefixStyle = "style.";
|
|
1958
2239
|
const FnPrefixSlot = "slot.";
|
|
1959
2240
|
const FnPrefixScope = "scope.";
|
|
2241
|
+
const FnPrefixSelector = "selector.";
|
|
1960
2242
|
function runtimeCallsite() {
|
|
1961
2243
|
return traceCallsite();
|
|
1962
2244
|
}
|
|
@@ -2017,9 +2299,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2017
2299
|
let arg;
|
|
2018
2300
|
let style;
|
|
2019
2301
|
let debug;
|
|
2020
|
-
let
|
|
2302
|
+
let weight = null;
|
|
2021
2303
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
2022
|
-
|
|
2304
|
+
weight = params[0];
|
|
2023
2305
|
arg = params[1];
|
|
2024
2306
|
style = params[2];
|
|
2025
2307
|
debug = params[3];
|
|
@@ -2029,7 +2311,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2029
2311
|
debug = params[2];
|
|
2030
2312
|
}
|
|
2031
2313
|
else if (isMedia && typeof params[0] === "number") {
|
|
2032
|
-
|
|
2314
|
+
weight = params[0];
|
|
2033
2315
|
arg = fnSelector.selector;
|
|
2034
2316
|
style = params[1];
|
|
2035
2317
|
debug = params[2];
|
|
@@ -2049,7 +2331,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2049
2331
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
2050
2332
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
2051
2333
|
const item = items[j];
|
|
2052
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2334
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
2053
2335
|
}
|
|
2054
2336
|
}
|
|
2055
2337
|
return createFnResult(data, fns);
|
|
@@ -2116,9 +2398,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2116
2398
|
let arg;
|
|
2117
2399
|
let data;
|
|
2118
2400
|
let debug;
|
|
2119
|
-
let
|
|
2401
|
+
let weight = null;
|
|
2120
2402
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
2121
|
-
|
|
2403
|
+
weight = params[0];
|
|
2122
2404
|
arg = params[1];
|
|
2123
2405
|
data = params[2];
|
|
2124
2406
|
debug = params[3];
|
|
@@ -2128,7 +2410,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2128
2410
|
debug = params[2];
|
|
2129
2411
|
}
|
|
2130
2412
|
else if (isMedia && typeof params[0] === "number") {
|
|
2131
|
-
|
|
2413
|
+
weight = params[0];
|
|
2132
2414
|
arg = fnSelector.selector;
|
|
2133
2415
|
data = params[1];
|
|
2134
2416
|
debug = params[2];
|
|
@@ -2145,7 +2427,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2145
2427
|
selector = args[i];
|
|
2146
2428
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
2147
2429
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
2148
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2430
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
2149
2431
|
}
|
|
2150
2432
|
return result;
|
|
2151
2433
|
};
|
|
@@ -2222,6 +2504,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2222
2504
|
traceMarker(fn, "slot");
|
|
2223
2505
|
return fn;
|
|
2224
2506
|
}
|
|
2507
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2508
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2509
|
+
const fn = (selector, style, debug) => {
|
|
2510
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2511
|
+
debug = style;
|
|
2512
|
+
style = void 0;
|
|
2513
|
+
}
|
|
2514
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2515
|
+
if (style === void 0) return target;
|
|
2516
|
+
return target(style, debug);
|
|
2517
|
+
};
|
|
2518
|
+
traceMarker(fn, "style.selector");
|
|
2519
|
+
return fn;
|
|
2520
|
+
}
|
|
2225
2521
|
function createScopeBuilder(selectors) {
|
|
2226
2522
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2227
2523
|
const fn = (items, debug) => {
|
|
@@ -2237,6 +2533,34 @@ function createScopeBuilder(selectors) {
|
|
|
2237
2533
|
traceMarker(fn, "scope");
|
|
2238
2534
|
return fn;
|
|
2239
2535
|
}
|
|
2536
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2537
|
+
const callable = ((style, debug) => {
|
|
2538
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2539
|
+
debug = style;
|
|
2540
|
+
style = void 0;
|
|
2541
|
+
}
|
|
2542
|
+
const callsite = resolveCallsite(debug);
|
|
2543
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2544
|
+
});
|
|
2545
|
+
traceMarker(callable, "selector.override");
|
|
2546
|
+
Object.setPrototypeOf(callable, fns);
|
|
2547
|
+
Object.assign(callable, data);
|
|
2548
|
+
return callable;
|
|
2549
|
+
}
|
|
2550
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2551
|
+
const callable = ((style, debug) => {
|
|
2552
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2553
|
+
debug = style;
|
|
2554
|
+
style = void 0;
|
|
2555
|
+
}
|
|
2556
|
+
const callsite = resolveCallsite(debug);
|
|
2557
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2558
|
+
});
|
|
2559
|
+
traceMarker(callable, "selector");
|
|
2560
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2561
|
+
Object.assign(callable, data);
|
|
2562
|
+
return callable;
|
|
2563
|
+
}
|
|
2240
2564
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2241
2565
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2242
2566
|
const callable = ((style, debug) => {
|
|
@@ -2845,6 +3169,497 @@ function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, to
|
|
|
2845
3169
|
}
|
|
2846
3170
|
createIdCounter("property");
|
|
2847
3171
|
//#endregion
|
|
3172
|
+
//#region sheet/utils/sourcemap.ts
|
|
3173
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3174
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3175
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3176
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3177
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3178
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3179
|
+
function encodeBase64(text) {
|
|
3180
|
+
const bytes = new TextEncoder().encode(text);
|
|
3181
|
+
let binary = "";
|
|
3182
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3183
|
+
return btoa(binary);
|
|
3184
|
+
}
|
|
3185
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3186
|
+
let source = sourceLookup[filePath];
|
|
3187
|
+
if (source) {
|
|
3188
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3189
|
+
return source;
|
|
3190
|
+
}
|
|
3191
|
+
source = {
|
|
3192
|
+
filePath,
|
|
3193
|
+
sourceIndex: sources.length,
|
|
3194
|
+
sourceContent
|
|
3195
|
+
};
|
|
3196
|
+
sources.push(source);
|
|
3197
|
+
sourceLookup[filePath] = source;
|
|
3198
|
+
return source;
|
|
3199
|
+
}
|
|
3200
|
+
function normalizeSourcePath(filePath) {
|
|
3201
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3202
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3203
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3204
|
+
return filePath.replace(/^at\s+/, "");
|
|
3205
|
+
}
|
|
3206
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3207
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3208
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3209
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3210
|
+
}
|
|
3211
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3212
|
+
const sidecarUrl = getSidecarUrl();
|
|
3213
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3214
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3215
|
+
}
|
|
3216
|
+
function getSidecarUrl() {
|
|
3217
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3218
|
+
return typeof value === "string" && value ? value : null;
|
|
3219
|
+
}
|
|
3220
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3221
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3222
|
+
try {
|
|
3223
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3224
|
+
} catch {
|
|
3225
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3229
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3230
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3231
|
+
return path ? `${base}/${path}` : base;
|
|
3232
|
+
}
|
|
3233
|
+
function getLineCount(css) {
|
|
3234
|
+
let count = 1;
|
|
3235
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3236
|
+
return count;
|
|
3237
|
+
}
|
|
3238
|
+
function encodeVlq(value) {
|
|
3239
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3240
|
+
let encoded = "";
|
|
3241
|
+
do {
|
|
3242
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3243
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3244
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3245
|
+
encoded += BASE64[digit];
|
|
3246
|
+
} while (vlq > 0);
|
|
3247
|
+
return encoded;
|
|
3248
|
+
}
|
|
3249
|
+
//#endregion
|
|
3250
|
+
//#region sheet/sourcemap.ts
|
|
3251
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3252
|
+
if (debug && debugField) {
|
|
3253
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3254
|
+
if (loc) return normalizeRuleCallsite({
|
|
3255
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3256
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3257
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3258
|
+
line: loc[0],
|
|
3259
|
+
column: loc[1]
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3263
|
+
if (debug) return normalizeRuleCallsite({
|
|
3264
|
+
filePath: debug.sourceUrl,
|
|
3265
|
+
sourceUrl: debug.sourceUrl,
|
|
3266
|
+
sourceContent: debug.code,
|
|
3267
|
+
line: debug.loc[0],
|
|
3268
|
+
column: debug.loc[1]
|
|
3269
|
+
});
|
|
3270
|
+
return callsite || null;
|
|
3271
|
+
}
|
|
3272
|
+
function normalizeRuleCallsite(callsite) {
|
|
3273
|
+
return {
|
|
3274
|
+
...callsite,
|
|
3275
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3276
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3280
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3281
|
+
//#endregion
|
|
3282
|
+
//#region builder/extract/utils.ts
|
|
3283
|
+
function createExtractedData(type, slotId) {
|
|
3284
|
+
const data = {
|
|
3285
|
+
[BUILDER_TYPE]: type,
|
|
3286
|
+
[BUILDER_STATE]: {
|
|
3287
|
+
items: [],
|
|
3288
|
+
lookup: {}
|
|
3289
|
+
},
|
|
3290
|
+
[BUILDER_CALLSITE]: null
|
|
3291
|
+
};
|
|
3292
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3293
|
+
return data;
|
|
3294
|
+
}
|
|
3295
|
+
function copyExtractedData(target, source) {
|
|
3296
|
+
const mutable = target;
|
|
3297
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3298
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3299
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3300
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3301
|
+
}
|
|
3302
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3303
|
+
return {
|
|
3304
|
+
[BUILDER_TYPE]: 5,
|
|
3305
|
+
[BUILDER_SCOPE]: scope,
|
|
3306
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3310
|
+
const normalized = [];
|
|
3311
|
+
let i = 0;
|
|
3312
|
+
while (i < items.length) {
|
|
3313
|
+
const item = items[i];
|
|
3314
|
+
const value = item[2];
|
|
3315
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3316
|
+
type,
|
|
3317
|
+
item[0],
|
|
3318
|
+
item[1]
|
|
3319
|
+
] : [
|
|
3320
|
+
type,
|
|
3321
|
+
slotId,
|
|
3322
|
+
item[0],
|
|
3323
|
+
item[1]
|
|
3324
|
+
] : slotId === null ? [
|
|
3325
|
+
type,
|
|
3326
|
+
item[0],
|
|
3327
|
+
item[1],
|
|
3328
|
+
value
|
|
3329
|
+
] : [
|
|
3330
|
+
type,
|
|
3331
|
+
slotId,
|
|
3332
|
+
item[0],
|
|
3333
|
+
item[1],
|
|
3334
|
+
value
|
|
3335
|
+
]);
|
|
3336
|
+
i++;
|
|
3337
|
+
}
|
|
3338
|
+
return normalized;
|
|
3339
|
+
}
|
|
3340
|
+
//#endregion
|
|
3341
|
+
//#region builder/extract/withTokens.ts
|
|
3342
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3343
|
+
function isExtractedTokenBoundData(value) {
|
|
3344
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3345
|
+
}
|
|
3346
|
+
function getExtractedTokenBoundData(value) {
|
|
3347
|
+
return tokenBoundData.get(value);
|
|
3348
|
+
}
|
|
3349
|
+
function isElementDebugData(value) {
|
|
3350
|
+
if (!value || typeof value !== "object") return false;
|
|
3351
|
+
return value.$$elementDebug === true;
|
|
3352
|
+
}
|
|
3353
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3354
|
+
//#endregion
|
|
3355
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3356
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3357
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3358
|
+
function markResolvedStyleItem(item) {
|
|
3359
|
+
resolvedStyleItems.add(item);
|
|
3360
|
+
}
|
|
3361
|
+
function isResolvedStyleItem$1(value) {
|
|
3362
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3363
|
+
}
|
|
3364
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3365
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
3366
|
+
}
|
|
3367
|
+
//#endregion
|
|
3368
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3369
|
+
function createMutableTokenValues(base) {
|
|
3370
|
+
return {
|
|
3371
|
+
ids: base ? base.ids.slice() : null,
|
|
3372
|
+
values: base ? base.values.slice() : null,
|
|
3373
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3374
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
function addTokenOverride(values, item, resolver) {
|
|
3378
|
+
if (!resolver.is(item)) return false;
|
|
3379
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3380
|
+
return true;
|
|
3381
|
+
}
|
|
3382
|
+
function addTokenValue(values, id, value) {
|
|
3383
|
+
if (!values.ids) values.ids = [];
|
|
3384
|
+
if (!values.values) values.values = [];
|
|
3385
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3386
|
+
if (!values.index) values.index = Object.create(null);
|
|
3387
|
+
const ids = values.ids;
|
|
3388
|
+
const tokenValues = values.values;
|
|
3389
|
+
const lookup = values.lookup;
|
|
3390
|
+
const indexLookup = values.index;
|
|
3391
|
+
const index = indexLookup[id];
|
|
3392
|
+
if (index === void 0) {
|
|
3393
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3394
|
+
tokenValues.push(value);
|
|
3395
|
+
} else tokenValues[index] = value;
|
|
3396
|
+
lookup[id] = value;
|
|
3397
|
+
}
|
|
3398
|
+
function addTokenValues(values, next) {
|
|
3399
|
+
if (!next) return;
|
|
3400
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3401
|
+
}
|
|
3402
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3403
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3404
|
+
}
|
|
3405
|
+
function finishTokenValues(base, values) {
|
|
3406
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3407
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
3408
|
+
return {
|
|
3409
|
+
ids: values.ids,
|
|
3410
|
+
values: values.values,
|
|
3411
|
+
lookup: values.lookup
|
|
3412
|
+
};
|
|
3413
|
+
}
|
|
3414
|
+
function mergeTokenValues(base, next) {
|
|
3415
|
+
if (!next) return base;
|
|
3416
|
+
if (!base) return next;
|
|
3417
|
+
const values = createMutableTokenValues(base);
|
|
3418
|
+
addTokenValues(values, next);
|
|
3419
|
+
return finishTokenValues(base, values);
|
|
3420
|
+
}
|
|
3421
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3422
|
+
if (!overrides.length) return base;
|
|
3423
|
+
const values = createMutableTokenValues(base);
|
|
3424
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3425
|
+
return finishTokenValues(base, values);
|
|
3426
|
+
}
|
|
3427
|
+
function createTokenIndexLookup(ids) {
|
|
3428
|
+
const lookup = Object.create(null);
|
|
3429
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3430
|
+
return lookup;
|
|
3431
|
+
}
|
|
3432
|
+
function isSameTokenValues(base, ids, values) {
|
|
3433
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3434
|
+
const baseLookup = base.lookup;
|
|
3435
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3436
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3437
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3438
|
+
}
|
|
3439
|
+
return true;
|
|
3440
|
+
}
|
|
3441
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3442
|
+
function isResolvedStyleItem(value) {
|
|
3443
|
+
return isResolvedStyleItem$1(value);
|
|
3444
|
+
}
|
|
3445
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3446
|
+
return createStyleItem({
|
|
3447
|
+
data,
|
|
3448
|
+
items: resolveItems(data, scopes)
|
|
3449
|
+
}, tokens);
|
|
3450
|
+
}
|
|
3451
|
+
function createStyleItem(item, tokens = null) {
|
|
3452
|
+
markResolvedStyleItem(item);
|
|
3453
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3454
|
+
return item;
|
|
3455
|
+
}
|
|
3456
|
+
function resolveItems(data, scopes) {
|
|
3457
|
+
const items = [];
|
|
3458
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3459
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3460
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3461
|
+
const item = stateItems[i];
|
|
3462
|
+
if (Array.isArray(item)) {
|
|
3463
|
+
items.push(item);
|
|
3464
|
+
continue;
|
|
3465
|
+
}
|
|
3466
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3467
|
+
items.push(item);
|
|
3468
|
+
continue;
|
|
3469
|
+
}
|
|
3470
|
+
if (slotId && item.type !== 2) continue;
|
|
3471
|
+
items.push(item);
|
|
3472
|
+
}
|
|
3473
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3474
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3475
|
+
const boundScope = scopes[i];
|
|
3476
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3477
|
+
if (!scope) continue;
|
|
3478
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3479
|
+
if (!scopeItems) continue;
|
|
3480
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3481
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3482
|
+
const item = scopeItems[j];
|
|
3483
|
+
if (Array.isArray(item)) {
|
|
3484
|
+
if (item[1] === slotId) items.push(item);
|
|
3485
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3486
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3487
|
+
continue;
|
|
3488
|
+
}
|
|
3489
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3490
|
+
if (item.type !== 4) continue;
|
|
3491
|
+
if (item.slotId === slotId) items.push(item);
|
|
3492
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
return items;
|
|
3496
|
+
}
|
|
3497
|
+
function getScopeParentItem(className) {
|
|
3498
|
+
const parentClassName = formatScopeClassName(className);
|
|
3499
|
+
return [parentClassName, parentClassName];
|
|
3500
|
+
}
|
|
3501
|
+
function formatScopeClassName(className) {
|
|
3502
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3503
|
+
if (!format) return "-" + className;
|
|
3504
|
+
if (typeof format === "function") return format({ className });
|
|
3505
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3506
|
+
}
|
|
3507
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3508
|
+
return value === 1 || value === true;
|
|
3509
|
+
}
|
|
3510
|
+
//#endregion
|
|
3511
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3512
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3513
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3514
|
+
}
|
|
3515
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3516
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3517
|
+
}
|
|
3518
|
+
function getDataTokenValues(data, resolver) {
|
|
3519
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3520
|
+
const values = createMutableTokenValues(null);
|
|
3521
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3522
|
+
return finishTokenValues(null, values);
|
|
3523
|
+
}
|
|
3524
|
+
createCacheValue();
|
|
3525
|
+
function createCacheValue() {
|
|
3526
|
+
return {
|
|
3527
|
+
d: null,
|
|
3528
|
+
c: RUNTIME_CONFIG.changes
|
|
3529
|
+
};
|
|
3530
|
+
}
|
|
3531
|
+
//#endregion
|
|
3532
|
+
//#region runtime/core/cache/token.ts
|
|
3533
|
+
const runtimeTokenValueResolver = {
|
|
3534
|
+
get key() {
|
|
3535
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3536
|
+
},
|
|
3537
|
+
is: isStyleTokenOverrideData,
|
|
3538
|
+
id(token) {
|
|
3539
|
+
return getStyleTokenId(token);
|
|
3540
|
+
},
|
|
3541
|
+
value(token) {
|
|
3542
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3546
|
+
if (isElementDebugData(item)) return null;
|
|
3547
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3548
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3549
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3550
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3551
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3552
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3553
|
+
}
|
|
3554
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3555
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3556
|
+
return null;
|
|
3557
|
+
}
|
|
3558
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3559
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3560
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3561
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3562
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3563
|
+
if (key && tokens) tokenBindings.push({
|
|
3564
|
+
data: key,
|
|
3565
|
+
tokens
|
|
3566
|
+
});
|
|
3567
|
+
return key;
|
|
3568
|
+
}
|
|
3569
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3570
|
+
return null;
|
|
3571
|
+
}
|
|
3572
|
+
//#endregion
|
|
3573
|
+
//#region atomic/rule.ts
|
|
3574
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3575
|
+
const cssProp = getCssPropertyName(property);
|
|
3576
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3577
|
+
const escapedClass = escapeCssIdent(className);
|
|
3578
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3579
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3580
|
+
let selectorStr = classSelector + itemSelector;
|
|
3581
|
+
if (parentSelector) {
|
|
3582
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3583
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3584
|
+
}
|
|
3585
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3586
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3587
|
+
return rule;
|
|
3588
|
+
}
|
|
3589
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3590
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3591
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3592
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3593
|
+
return [
|
|
3594
|
+
priority ?? 0,
|
|
3595
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3596
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3597
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3598
|
+
atRules ? atRules.length : 0,
|
|
3599
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3600
|
+
getPropertyPriority(property)
|
|
3601
|
+
];
|
|
3602
|
+
}
|
|
3603
|
+
function getMediaPriority(atRules, priority) {
|
|
3604
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3605
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3606
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3607
|
+
}
|
|
3608
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3609
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3610
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3611
|
+
return LayerSelectorPriorities.base;
|
|
3612
|
+
}
|
|
3613
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3614
|
+
if (!parentSelector) return 0;
|
|
3615
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3616
|
+
}
|
|
3617
|
+
function getAtRulePriority$1(atRules) {
|
|
3618
|
+
if (!atRules?.length) return 0;
|
|
3619
|
+
let priority = 0;
|
|
3620
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3621
|
+
return priority;
|
|
3622
|
+
}
|
|
3623
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3624
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3625
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3626
|
+
}
|
|
3627
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3628
|
+
const declarations = [];
|
|
3629
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3630
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3631
|
+
}
|
|
3632
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3633
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3634
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3635
|
+
return name + ":" + value;
|
|
3636
|
+
}
|
|
3637
|
+
function normalizeThemeName(value) {
|
|
3638
|
+
if (!value) return null;
|
|
3639
|
+
value = value.trim();
|
|
3640
|
+
if (!value) return null;
|
|
3641
|
+
if (/^\d+$/.test(value)) return null;
|
|
3642
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3643
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3644
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3645
|
+
value = stripGenericThemePrefix(value);
|
|
3646
|
+
if (!value) return null;
|
|
3647
|
+
return value;
|
|
3648
|
+
}
|
|
3649
|
+
function stripGenericThemePrefix(value) {
|
|
3650
|
+
const parts = value.split("--");
|
|
3651
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3652
|
+
value = parts.join("--");
|
|
3653
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3654
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3655
|
+
return value;
|
|
3656
|
+
}
|
|
3657
|
+
function isGeneratedNameHash(value) {
|
|
3658
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3659
|
+
}
|
|
3660
|
+
createNameFormatter(["name"]);
|
|
3661
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3662
|
+
//#endregion
|
|
2848
3663
|
//#region style/keyframes.ts
|
|
2849
3664
|
function transformKeyframes(frames, transform) {
|
|
2850
3665
|
if (!transform) return frames;
|
|
@@ -2871,9 +3686,11 @@ function createStyleFn(args) {
|
|
|
2871
3686
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2872
3687
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2873
3688
|
const fnScope = createScopeBuilder(selectors);
|
|
2874
|
-
const
|
|
2875
|
-
|
|
3689
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3690
|
+
const fnWeight = (value, weight) => {
|
|
3691
|
+
return weightValue(value, weight);
|
|
2876
3692
|
};
|
|
3693
|
+
const fnImportant = (value) => importantValue(value);
|
|
2877
3694
|
const fnRaw = (style) => style;
|
|
2878
3695
|
const fnPlain = (style) => style;
|
|
2879
3696
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2885,11 +3702,13 @@ function createStyleFn(args) {
|
|
|
2885
3702
|
const style = fnStyle;
|
|
2886
3703
|
style.slot = fnSlot;
|
|
2887
3704
|
style.scope = fnScope;
|
|
2888
|
-
style.
|
|
3705
|
+
style.weight = fnWeight;
|
|
3706
|
+
style.important = fnImportant;
|
|
2889
3707
|
style.raw = fnRaw;
|
|
2890
3708
|
style.plain = fnPlain;
|
|
2891
3709
|
style.keyframes = fnKeyframes;
|
|
2892
3710
|
style.merge = fnMerge;
|
|
3711
|
+
style.selector = fnSelector;
|
|
2893
3712
|
assignStyleFnMeta(style, {
|
|
2894
3713
|
mode: "StyleObject",
|
|
2895
3714
|
selectors,
|
|
@@ -3024,65 +3843,6 @@ function isGlobPattern(source) {
|
|
|
3024
3843
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
3025
3844
|
}
|
|
3026
3845
|
//#endregion
|
|
3027
|
-
//#region builder/extract/utils.ts
|
|
3028
|
-
function createExtractedData(type, slotId) {
|
|
3029
|
-
const data = {
|
|
3030
|
-
[BUILDER_TYPE]: type,
|
|
3031
|
-
[BUILDER_STATE]: {
|
|
3032
|
-
items: [],
|
|
3033
|
-
lookup: {}
|
|
3034
|
-
},
|
|
3035
|
-
[BUILDER_CALLSITE]: null
|
|
3036
|
-
};
|
|
3037
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3038
|
-
return data;
|
|
3039
|
-
}
|
|
3040
|
-
function copyExtractedData(target, source) {
|
|
3041
|
-
const mutable = target;
|
|
3042
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3043
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3044
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3045
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3046
|
-
}
|
|
3047
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
3048
|
-
return {
|
|
3049
|
-
[BUILDER_TYPE]: 5,
|
|
3050
|
-
[BUILDER_SCOPE]: scope,
|
|
3051
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3052
|
-
};
|
|
3053
|
-
}
|
|
3054
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
3055
|
-
const normalized = [];
|
|
3056
|
-
let i = 0;
|
|
3057
|
-
while (i < items.length) {
|
|
3058
|
-
const item = items[i];
|
|
3059
|
-
const value = item[2];
|
|
3060
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
3061
|
-
type,
|
|
3062
|
-
item[0],
|
|
3063
|
-
item[1]
|
|
3064
|
-
] : [
|
|
3065
|
-
type,
|
|
3066
|
-
slotId,
|
|
3067
|
-
item[0],
|
|
3068
|
-
item[1]
|
|
3069
|
-
] : slotId === null ? [
|
|
3070
|
-
type,
|
|
3071
|
-
item[0],
|
|
3072
|
-
item[1],
|
|
3073
|
-
value
|
|
3074
|
-
] : [
|
|
3075
|
-
type,
|
|
3076
|
-
slotId,
|
|
3077
|
-
item[0],
|
|
3078
|
-
item[1],
|
|
3079
|
-
value
|
|
3080
|
-
]);
|
|
3081
|
-
i++;
|
|
3082
|
-
}
|
|
3083
|
-
return normalized;
|
|
3084
|
-
}
|
|
3085
|
-
//#endregion
|
|
3086
3846
|
//#region builder/extract/scope.ts
|
|
3087
3847
|
function createExtractedScope(items) {
|
|
3088
3848
|
const scope = ((slot) => {
|
|
@@ -3093,6 +3853,15 @@ function createExtractedScope(items) {
|
|
|
3093
3853
|
return scope;
|
|
3094
3854
|
}
|
|
3095
3855
|
//#endregion
|
|
3856
|
+
//#region builder/extract/sheet.ts
|
|
3857
|
+
function createExtractedSheet(items) {
|
|
3858
|
+
const data = createExtractedData(9);
|
|
3859
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3860
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3861
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3862
|
+
return data;
|
|
3863
|
+
}
|
|
3864
|
+
//#endregion
|
|
3096
3865
|
//#region builder/extract/slot.ts
|
|
3097
3866
|
function createExtractedSlot(slotId, items) {
|
|
3098
3867
|
const slot = ((items) => {
|
|
@@ -3236,7 +4005,7 @@ function exposeStyleObject(source) {
|
|
|
3236
4005
|
return result;
|
|
3237
4006
|
}
|
|
3238
4007
|
function exposeStyleValue(value) {
|
|
3239
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
4008
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3240
4009
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3241
4010
|
const exposed = exposeStyleObject(value);
|
|
3242
4011
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3450,6 +4219,12 @@ function evaluateCall(node, scope) {
|
|
|
3450
4219
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3451
4220
|
return evalOk(createExtractedStyle(items.value));
|
|
3452
4221
|
}
|
|
4222
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4223
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4224
|
+
if (!items.ok) return items;
|
|
4225
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4226
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4227
|
+
}
|
|
3453
4228
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3454
4229
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3455
4230
|
if (!style.ok) return style;
|
|
@@ -3638,13 +4413,18 @@ function evaluateCall(node, scope) {
|
|
|
3638
4413
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3639
4414
|
}));
|
|
3640
4415
|
}
|
|
3641
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4416
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
3642
4417
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3643
4418
|
if (!value.ok) return value;
|
|
3644
4419
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3645
4420
|
if (!weight.ok) return weight;
|
|
3646
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3647
|
-
return evalOk(
|
|
4421
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4422
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4423
|
+
}
|
|
4424
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "important" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
4425
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4426
|
+
if (!value.ok) return value;
|
|
4427
|
+
return evalOk(importantValue(value.value));
|
|
3648
4428
|
}
|
|
3649
4429
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
3650
4430
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3849,14 +4629,14 @@ function evaluateUnary(node, scope) {
|
|
|
3849
4629
|
function isStaticStyleValue(value) {
|
|
3850
4630
|
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3851
4631
|
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3852
|
-
if (value.type === "
|
|
3853
|
-
const [priority, itemValue] = value.elements;
|
|
3854
|
-
return !!priority && priority.type === "NumericLiteral" && !!itemValue && isStaticStyleValue(itemValue);
|
|
3855
|
-
}
|
|
3856
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "value") {
|
|
4632
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
3857
4633
|
const [itemValue, weight] = value.arguments;
|
|
3858
4634
|
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
3859
4635
|
}
|
|
4636
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4637
|
+
const [itemValue] = value.arguments;
|
|
4638
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4639
|
+
}
|
|
3860
4640
|
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3861
4641
|
return false;
|
|
3862
4642
|
}
|
|
@@ -3871,43 +4651,6 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3871
4651
|
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3872
4652
|
return false;
|
|
3873
4653
|
}
|
|
3874
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3875
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3876
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3877
|
-
}
|
|
3878
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3879
|
-
const declarations = [];
|
|
3880
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3881
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3882
|
-
}
|
|
3883
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3884
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3885
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3886
|
-
return name + ":" + value;
|
|
3887
|
-
}
|
|
3888
|
-
function normalizeThemeName(value) {
|
|
3889
|
-
if (!value) return null;
|
|
3890
|
-
value = value.trim();
|
|
3891
|
-
if (!value) return null;
|
|
3892
|
-
if (/^\d+$/.test(value)) return null;
|
|
3893
|
-
if (isGeneratedNameHash(value)) return null;
|
|
3894
|
-
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3895
|
-
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3896
|
-
value = stripGenericThemePrefix(value);
|
|
3897
|
-
if (!value) return null;
|
|
3898
|
-
return value;
|
|
3899
|
-
}
|
|
3900
|
-
function stripGenericThemePrefix(value) {
|
|
3901
|
-
const parts = value.split("--");
|
|
3902
|
-
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3903
|
-
value = parts.join("--");
|
|
3904
|
-
if (value.startsWith("theme-")) return value.slice(6);
|
|
3905
|
-
if (value.startsWith("themes-")) return value.slice(7);
|
|
3906
|
-
return value;
|
|
3907
|
-
}
|
|
3908
|
-
function isGeneratedNameHash(value) {
|
|
3909
|
-
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3910
|
-
}
|
|
3911
4654
|
//#endregion
|
|
3912
4655
|
//#region compiler/transform/syntax/utils.ts
|
|
3913
4656
|
function getCallLabel(callee) {
|
|
@@ -4042,60 +4785,6 @@ function sanitizeTokenId(value) {
|
|
|
4042
4785
|
return sanitizeCssIdentName(value, "token");
|
|
4043
4786
|
}
|
|
4044
4787
|
//#endregion
|
|
4045
|
-
//#region compiler/transform/utils/babel.ts
|
|
4046
|
-
function babelPlugin(factory) {
|
|
4047
|
-
return factory;
|
|
4048
|
-
}
|
|
4049
|
-
function babelTransform(args) {
|
|
4050
|
-
let result = null;
|
|
4051
|
-
try {
|
|
4052
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
4053
|
-
result = _babel_core.transformSync(args.code, {
|
|
4054
|
-
...babelTransformOptions(),
|
|
4055
|
-
inputSourceMap,
|
|
4056
|
-
filename: args.filePath,
|
|
4057
|
-
sourceFileName: args.filePath,
|
|
4058
|
-
plugins: args.plugins,
|
|
4059
|
-
sourceMaps: true,
|
|
4060
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
4061
|
-
});
|
|
4062
|
-
} catch (err) {
|
|
4063
|
-
if (!args.errorLabel) throw err;
|
|
4064
|
-
const message = getBabelError(err, args);
|
|
4065
|
-
const error = new Error(message);
|
|
4066
|
-
error.stack = void 0;
|
|
4067
|
-
throw error;
|
|
4068
|
-
}
|
|
4069
|
-
if (!result || !result.code) return null;
|
|
4070
|
-
return {
|
|
4071
|
-
code: result.code,
|
|
4072
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
4073
|
-
};
|
|
4074
|
-
}
|
|
4075
|
-
function babelTransformOptions() {
|
|
4076
|
-
return {
|
|
4077
|
-
configFile: false,
|
|
4078
|
-
babelrc: false,
|
|
4079
|
-
parserOpts: {
|
|
4080
|
-
plugins: ["typescript", "jsx"],
|
|
4081
|
-
strictMode: false,
|
|
4082
|
-
allowImportExportEverywhere: true
|
|
4083
|
-
}
|
|
4084
|
-
};
|
|
4085
|
-
}
|
|
4086
|
-
function parseInputSourceMap(sourcemap) {
|
|
4087
|
-
if (!sourcemap) return void 0;
|
|
4088
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
4089
|
-
return JSON.parse(sourcemap);
|
|
4090
|
-
}
|
|
4091
|
-
function getBabelError(err, args) {
|
|
4092
|
-
const babelErr = err;
|
|
4093
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
4094
|
-
const codeFrame = babelErr?.codeFrame;
|
|
4095
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
4096
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
4097
|
-
}
|
|
4098
|
-
//#endregion
|
|
4099
4788
|
//#region compiler/transform/utils/path.ts
|
|
4100
4789
|
function getProjectFileId$1(projectDir, filePath) {
|
|
4101
4790
|
if (!filePath) return "unknown";
|
|
@@ -4614,6 +5303,7 @@ function getDebugCallLoc(path, state) {
|
|
|
4614
5303
|
}
|
|
4615
5304
|
function getStyleObjectArg(path, state) {
|
|
4616
5305
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5306
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4617
5307
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4618
5308
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4619
5309
|
if (!selector) return path.node.arguments[0];
|
|
@@ -5038,7 +5728,7 @@ function transformDebug(internal, args, deps) {
|
|
|
5038
5728
|
code: args.code,
|
|
5039
5729
|
filePath: args.filePath,
|
|
5040
5730
|
sourcemap: args.sourcemap,
|
|
5041
|
-
plugins: [plugin],
|
|
5731
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
5042
5732
|
retainLines: true
|
|
5043
5733
|
});
|
|
5044
5734
|
if (!result) return null;
|
|
@@ -5107,59 +5797,9 @@ function resolveFilePath(source, fromFile) {
|
|
|
5107
5797
|
}
|
|
5108
5798
|
}
|
|
5109
5799
|
//#endregion
|
|
5110
|
-
//#region atomic/rule.ts
|
|
5111
|
-
function buildAtomicRule(className, property, value, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
5112
|
-
const cssProp = getCssPropertyName(property);
|
|
5113
|
-
const cssValue = getCssPropertyValue(property, value);
|
|
5114
|
-
const classSelector = "." + escapeCssIdent(className);
|
|
5115
|
-
const itemSelector = selector ? getSelectorText(selector) : "";
|
|
5116
|
-
let selectorStr = classSelector + itemSelector;
|
|
5117
|
-
if (parentSelector) {
|
|
5118
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
5119
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
5120
|
-
}
|
|
5121
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
5122
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
5123
|
-
return rule;
|
|
5124
|
-
}
|
|
5125
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
5126
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
5127
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
5128
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
5129
|
-
return [
|
|
5130
|
-
priority ?? 0,
|
|
5131
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
5132
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
5133
|
-
getMediaPriority(atRules, atRulePriority),
|
|
5134
|
-
atRules ? atRules.length : 0,
|
|
5135
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
5136
|
-
getPropertyPriority(property)
|
|
5137
|
-
];
|
|
5138
|
-
}
|
|
5139
|
-
function getMediaPriority(atRules, priority) {
|
|
5140
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
5141
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
5142
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
5143
|
-
}
|
|
5144
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
5145
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
5146
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
5147
|
-
return LayerSelectorPriorities.base;
|
|
5148
|
-
}
|
|
5149
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
5150
|
-
if (!parentSelector) return 0;
|
|
5151
|
-
return priority > 0 ? priority + 1 : 1;
|
|
5152
|
-
}
|
|
5153
|
-
function getAtRulePriority$1(atRules) {
|
|
5154
|
-
if (!atRules?.length) return 0;
|
|
5155
|
-
let priority = 0;
|
|
5156
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
5157
|
-
return priority;
|
|
5158
|
-
}
|
|
5159
|
-
//#endregion
|
|
5160
5800
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
5161
5801
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
5162
|
-
function extractStyleChain(node, styleNames) {
|
|
5802
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5163
5803
|
if (node.type !== "CallExpression") return null;
|
|
5164
5804
|
const callee = node.callee;
|
|
5165
5805
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -5168,6 +5808,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
5168
5808
|
baseArgs: node.arguments,
|
|
5169
5809
|
methods: []
|
|
5170
5810
|
};
|
|
5811
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5812
|
+
kind: "sheet",
|
|
5813
|
+
rootName: callee.name,
|
|
5814
|
+
baseArgs: node.arguments,
|
|
5815
|
+
methods: []
|
|
5816
|
+
};
|
|
5171
5817
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5172
5818
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
5173
5819
|
if (!prop) return null;
|
|
@@ -5185,10 +5831,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
5185
5831
|
baseArgs: node.arguments,
|
|
5186
5832
|
methods: []
|
|
5187
5833
|
};
|
|
5834
|
+
if (prop === "selector") return {
|
|
5835
|
+
kind: "selector",
|
|
5836
|
+
rootName: obj.name,
|
|
5837
|
+
baseArgs: node.arguments,
|
|
5838
|
+
methods: []
|
|
5839
|
+
};
|
|
5188
5840
|
if (prop !== "merge") return null;
|
|
5189
5841
|
const target = node.arguments[0];
|
|
5190
5842
|
if (!target) return null;
|
|
5191
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5843
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
5192
5844
|
if (!targetChain) return null;
|
|
5193
5845
|
return {
|
|
5194
5846
|
...targetChain,
|
|
@@ -5200,7 +5852,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
5200
5852
|
};
|
|
5201
5853
|
}
|
|
5202
5854
|
if (obj.type === "CallExpression") {
|
|
5203
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5855
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
5204
5856
|
if (!inner) return null;
|
|
5205
5857
|
return {
|
|
5206
5858
|
...inner,
|
|
@@ -5224,18 +5876,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
5224
5876
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5225
5877
|
let result = null;
|
|
5226
5878
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5227
|
-
const
|
|
5879
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5880
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
5228
5881
|
if (!runtimeValue) continue;
|
|
5229
5882
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5230
5883
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5231
5884
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
5232
|
-
|
|
5885
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5886
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
5233
5887
|
}
|
|
5234
5888
|
return result ?? styleObj;
|
|
5235
5889
|
}
|
|
5236
|
-
function getPriorityTupleValue(value) {
|
|
5237
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5238
|
-
}
|
|
5239
5890
|
function cloneCompiledStyleObject(styleObj) {
|
|
5240
5891
|
const cloned = { ...styleObj };
|
|
5241
5892
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5318,6 +5969,8 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5318
5969
|
*/
|
|
5319
5970
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5320
5971
|
const css = getCssConfig(opts, runtimeMode);
|
|
5972
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5973
|
+
if (!meta) return null;
|
|
5321
5974
|
if (meta.mode === "ClassName") {
|
|
5322
5975
|
if (chain.kind !== "style") return null;
|
|
5323
5976
|
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
@@ -5329,11 +5982,91 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5329
5982
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5330
5983
|
return null;
|
|
5331
5984
|
}
|
|
5985
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5986
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5987
|
+
const items = [];
|
|
5988
|
+
const rules = [];
|
|
5989
|
+
const sheetItems = chain.baseArgs[0];
|
|
5990
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5991
|
+
return {
|
|
5992
|
+
type: "sheet",
|
|
5993
|
+
items,
|
|
5994
|
+
rules
|
|
5995
|
+
};
|
|
5996
|
+
}
|
|
5997
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5998
|
+
if (node.type === "ArrayExpression") {
|
|
5999
|
+
for (const element of node.elements) {
|
|
6000
|
+
if (!element) continue;
|
|
6001
|
+
if (element.type === "SpreadElement") return false;
|
|
6002
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
6003
|
+
}
|
|
6004
|
+
return true;
|
|
6005
|
+
}
|
|
6006
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
6007
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
6008
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
6009
|
+
return true;
|
|
6010
|
+
}
|
|
6011
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
6012
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
6013
|
+
const item = tokenOverride.value[i];
|
|
6014
|
+
if (!item) continue;
|
|
6015
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
6016
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
6017
|
+
}
|
|
6018
|
+
return true;
|
|
6019
|
+
}
|
|
6020
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
6021
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
6022
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
6023
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
6024
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
6025
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
6026
|
+
}
|
|
6027
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
6028
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
6029
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
6030
|
+
if (!selectorArg.ok) return false;
|
|
6031
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
6032
|
+
for (let i = 0, len = manualSelectors.length; i < len; i++) if (!compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, manualSelectors[i])) return false;
|
|
6033
|
+
return true;
|
|
6034
|
+
}
|
|
6035
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
6036
|
+
if (chain.baseArgs[1]) {
|
|
6037
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
6038
|
+
}
|
|
6039
|
+
let i = 0;
|
|
6040
|
+
while (i < chain.methods.length) {
|
|
6041
|
+
const method = chain.methods[i];
|
|
6042
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
6043
|
+
i++;
|
|
6044
|
+
}
|
|
6045
|
+
return true;
|
|
6046
|
+
}
|
|
6047
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
6048
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
6049
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
6050
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6051
|
+
if (styleArgNode.type === "CallExpression") {
|
|
6052
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
6053
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
6054
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6055
|
+
}
|
|
6056
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
6057
|
+
if (!styleArg.ok) {
|
|
6058
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
6059
|
+
return false;
|
|
6060
|
+
}
|
|
6061
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6062
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6063
|
+
}
|
|
5332
6064
|
function getCssConfig(opts, runtimeMode) {
|
|
5333
6065
|
const css = opts.css;
|
|
5334
6066
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
5335
6067
|
return {
|
|
5336
6068
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
6069
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5337
6070
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5338
6071
|
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
5339
6072
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
@@ -5460,15 +6193,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5460
6193
|
result[property] = value;
|
|
5461
6194
|
continue;
|
|
5462
6195
|
}
|
|
5463
|
-
|
|
5464
|
-
const rawValue = value[1];
|
|
5465
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5466
|
-
continue;
|
|
5467
|
-
}
|
|
5468
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6196
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5469
6197
|
}
|
|
5470
6198
|
return result;
|
|
5471
6199
|
}
|
|
6200
|
+
function decorateClassNameValue(value, className) {
|
|
6201
|
+
if (isClassNameValue(value)) return value;
|
|
6202
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6203
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6204
|
+
return classNameValue(value, className);
|
|
6205
|
+
}
|
|
5472
6206
|
function isWeightedClassName(value) {
|
|
5473
6207
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5474
6208
|
}
|
|
@@ -5479,23 +6213,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5479
6213
|
weighted[property] = value;
|
|
5480
6214
|
continue;
|
|
5481
6215
|
}
|
|
5482
|
-
weighted[property] =
|
|
6216
|
+
weighted[property] = weightValue(value, weight);
|
|
5483
6217
|
}
|
|
5484
6218
|
return weighted;
|
|
5485
6219
|
}
|
|
5486
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6220
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5487
6221
|
if (chain.baseArgs.length > 0) {
|
|
5488
6222
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5489
6223
|
if (!styleArg.ok) {
|
|
5490
6224
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5491
6225
|
return false;
|
|
5492
6226
|
}
|
|
5493
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6227
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5494
6228
|
}
|
|
5495
6229
|
let i = 0;
|
|
5496
6230
|
while (i < chain.methods.length) {
|
|
5497
6231
|
const method = chain.methods[i];
|
|
5498
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6232
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5499
6233
|
i++;
|
|
5500
6234
|
}
|
|
5501
6235
|
return true;
|
|
@@ -5542,7 +6276,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5542
6276
|
rules
|
|
5543
6277
|
};
|
|
5544
6278
|
}
|
|
5545
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6279
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5546
6280
|
const selector = selectors[method.name];
|
|
5547
6281
|
if (!selector) return false;
|
|
5548
6282
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5815,10 +6549,10 @@ function getSlotIdFromValue(value) {
|
|
|
5815
6549
|
const slotId = value.slotId;
|
|
5816
6550
|
return typeof slotId === "string" ? slotId : null;
|
|
5817
6551
|
}
|
|
5818
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6552
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5819
6553
|
if (method.name === "$$style.merge") {
|
|
5820
6554
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5821
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6555
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5822
6556
|
}
|
|
5823
6557
|
const selector = selectors[method.name];
|
|
5824
6558
|
if (!selector) return false;
|
|
@@ -5826,42 +6560,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5826
6560
|
const selectorStr = selector.selector.trim();
|
|
5827
6561
|
if (selectorStr === "...") {
|
|
5828
6562
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5829
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6563
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5830
6564
|
}
|
|
5831
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5832
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6565
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6566
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5833
6567
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6568
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5834
6569
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5835
6570
|
if (!styleArg.ok) {
|
|
5836
6571
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5837
6572
|
return false;
|
|
5838
6573
|
}
|
|
5839
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6574
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5840
6575
|
}
|
|
5841
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6576
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5842
6577
|
if (!styleArgNode) return false;
|
|
5843
6578
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5844
6579
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5845
6580
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5846
|
-
if (
|
|
6581
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5847
6582
|
if (styleArgNode.type === "CallExpression") {
|
|
5848
6583
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5849
6584
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5850
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6585
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5851
6586
|
}
|
|
5852
6587
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5853
6588
|
if (!styleArg.ok) {
|
|
5854
6589
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5855
6590
|
return false;
|
|
5856
6591
|
}
|
|
5857
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5858
|
-
return addStyleDataItems(styleArg.value,
|
|
6592
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6593
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5859
6594
|
}
|
|
5860
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6595
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5861
6596
|
if (node.type !== "Identifier") return null;
|
|
5862
6597
|
const init = scope.bindingNodes?.get(node.name);
|
|
5863
6598
|
if (!init) return null;
|
|
5864
|
-
return extractStyleChain(init, styleNames);
|
|
6599
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6600
|
+
}
|
|
6601
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6602
|
+
const callee = node.callee;
|
|
6603
|
+
if (callee.type === "Identifier") {
|
|
6604
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6605
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6606
|
+
return {
|
|
6607
|
+
...target,
|
|
6608
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6611
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6612
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6613
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6614
|
+
...memberTarget,
|
|
6615
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6616
|
+
};
|
|
6617
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6618
|
+
if (!methodName) return null;
|
|
6619
|
+
const object = callee.object;
|
|
6620
|
+
const target = object.type === "Identifier" ? getLocalStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "MemberExpression" ? getLocalMemberStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "CallExpression" ? getLocalSelectorTargetChain(object, scope, styleNames, sheetNames) : null;
|
|
6621
|
+
if (target?.kind !== "selector") return null;
|
|
6622
|
+
return {
|
|
6623
|
+
...target,
|
|
6624
|
+
methods: [...target.methods, {
|
|
6625
|
+
name: methodName,
|
|
6626
|
+
args: node.arguments,
|
|
6627
|
+
nameNode: callee.property
|
|
6628
|
+
}]
|
|
6629
|
+
};
|
|
6630
|
+
}
|
|
6631
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6632
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6633
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6634
|
+
if (!propertyName) return null;
|
|
6635
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6636
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6637
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6638
|
+
const property = objectInit.properties[i];
|
|
6639
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6640
|
+
const key = property.key;
|
|
6641
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6642
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6643
|
+
}
|
|
6644
|
+
return null;
|
|
6645
|
+
}
|
|
6646
|
+
function isBareSelectorTargetChain(chain) {
|
|
6647
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5865
6648
|
}
|
|
5866
6649
|
function getLocalBindingNode(node, scope) {
|
|
5867
6650
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5889,7 +6672,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5889
6672
|
default: return false;
|
|
5890
6673
|
}
|
|
5891
6674
|
}
|
|
5892
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6675
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5893
6676
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5894
6677
|
const hasArg = selectorStr.includes("$$");
|
|
5895
6678
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5911,22 +6694,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5911
6694
|
if (styleArg.type === "CallExpression") {
|
|
5912
6695
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5913
6696
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5914
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6697
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5915
6698
|
const evaled = evaluateNode(styleArg, scope);
|
|
5916
6699
|
if (!evaled.ok) {
|
|
5917
6700
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5918
6701
|
return false;
|
|
5919
6702
|
}
|
|
5920
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6703
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5921
6704
|
}
|
|
5922
6705
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5923
6706
|
if (!styleResult.ok) {
|
|
5924
6707
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5925
6708
|
return false;
|
|
5926
6709
|
}
|
|
5927
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6710
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5928
6711
|
}
|
|
5929
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6712
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5930
6713
|
const selectorStr = selector.selector.trim();
|
|
5931
6714
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5932
6715
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5948,7 +6731,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5948
6731
|
while (i < selectorValues.length) {
|
|
5949
6732
|
const itemSelectorValue = selectorValues[i];
|
|
5950
6733
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5951
|
-
|
|
6734
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6735
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5952
6736
|
i++;
|
|
5953
6737
|
}
|
|
5954
6738
|
return true;
|
|
@@ -6017,6 +6801,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
6017
6801
|
dedupe: overrideItem.dedupe,
|
|
6018
6802
|
className: overrideItem.className,
|
|
6019
6803
|
property: overrideItem.property,
|
|
6804
|
+
weight: overrideItem.weight,
|
|
6805
|
+
important: overrideItem.important,
|
|
6020
6806
|
value: overrideItem.value,
|
|
6021
6807
|
variable: overrideItem.variable,
|
|
6022
6808
|
token: overrideItem.token,
|
|
@@ -6060,22 +6846,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
6060
6846
|
items.push(item);
|
|
6061
6847
|
}
|
|
6062
6848
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6063
|
-
|
|
6849
|
+
const weight = sourceItem.weight;
|
|
6850
|
+
let important = false;
|
|
6064
6851
|
let value = sourceItem.value;
|
|
6065
|
-
|
|
6066
|
-
priority = value[1];
|
|
6067
|
-
value = value[0];
|
|
6068
|
-
}
|
|
6852
|
+
important = sourceItem.important;
|
|
6069
6853
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
6070
6854
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6071
6855
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6072
6856
|
const valueStr = String(value ?? "");
|
|
6073
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6074
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6857
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6858
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6075
6859
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
6076
6860
|
items.push(item);
|
|
6077
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6078
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6861
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6862
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
6079
6863
|
cssRules.push({
|
|
6080
6864
|
dedupe,
|
|
6081
6865
|
className,
|
|
@@ -6138,21 +6922,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
6138
6922
|
items.push(item);
|
|
6139
6923
|
}
|
|
6140
6924
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6141
|
-
|
|
6925
|
+
const weight = sourceItem.weight;
|
|
6926
|
+
const important = sourceItem.important;
|
|
6142
6927
|
let value = sourceItem.value;
|
|
6143
|
-
|
|
6144
|
-
priority = value[1];
|
|
6145
|
-
value = value[0];
|
|
6146
|
-
}
|
|
6147
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6928
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
6148
6929
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6149
6930
|
const variable = sourceItem.variable;
|
|
6150
6931
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
6151
6932
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
6152
6933
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
6153
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6934
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
6154
6935
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6155
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6936
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6156
6937
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6157
6938
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
6158
6939
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -6160,8 +6941,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6160
6941
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
6161
6942
|
}
|
|
6162
6943
|
items.push(item);
|
|
6163
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6164
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6944
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6945
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
6165
6946
|
cssRules.push({
|
|
6166
6947
|
dedupe,
|
|
6167
6948
|
className,
|
|
@@ -6174,6 +6955,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6174
6955
|
} : void 0
|
|
6175
6956
|
});
|
|
6176
6957
|
}
|
|
6958
|
+
function combineSelectors(parent, child) {
|
|
6959
|
+
const parentText = getItemSelectorText(parent);
|
|
6960
|
+
const childText = getItemSelectorText(child);
|
|
6961
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6962
|
+
const selector = parentText + childText;
|
|
6963
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6964
|
+
}
|
|
6965
|
+
function getItemSelectorText(selector) {
|
|
6966
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6967
|
+
}
|
|
6968
|
+
function getItemSelectorPriority(selector) {
|
|
6969
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6970
|
+
}
|
|
6177
6971
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
6178
6972
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
6179
6973
|
if (!trace) return void 0;
|
|
@@ -6218,13 +7012,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6218
7012
|
while (i < keys.length) {
|
|
6219
7013
|
const property = keys[i];
|
|
6220
7014
|
const rawValue = styleObj[property];
|
|
6221
|
-
let
|
|
7015
|
+
let weight = null;
|
|
7016
|
+
let important = false;
|
|
6222
7017
|
let value = rawValue;
|
|
6223
7018
|
let transformClassName = null;
|
|
6224
|
-
|
|
6225
|
-
priority = rawValue[0];
|
|
6226
|
-
value = rawValue[1];
|
|
6227
|
-
}
|
|
7019
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
6228
7020
|
if (isClassNameValue(value)) {
|
|
6229
7021
|
transformClassName = value.className;
|
|
6230
7022
|
value = value.value;
|
|
@@ -6247,8 +7039,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6247
7039
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
6248
7040
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6249
7041
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
6250
|
-
const dedupe = getClassNameDedupe(property,
|
|
6251
|
-
const className = getAtomicClassName(property,
|
|
7042
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
7043
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6252
7044
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6253
7045
|
item.sourceTrace = propertyCallsite ? {
|
|
6254
7046
|
property,
|
|
@@ -6273,8 +7065,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6273
7065
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6274
7066
|
}
|
|
6275
7067
|
items.push(item);
|
|
6276
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6277
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
7068
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
7069
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6278
7070
|
cssRules.push({
|
|
6279
7071
|
dedupe,
|
|
6280
7072
|
className,
|
|
@@ -6302,6 +7094,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6302
7094
|
}
|
|
6303
7095
|
return true;
|
|
6304
7096
|
}
|
|
7097
|
+
function unwrapStaticStyleValue(value) {
|
|
7098
|
+
let weight = null;
|
|
7099
|
+
let important = false;
|
|
7100
|
+
while (true) {
|
|
7101
|
+
if (isStyleImportantValue(value)) {
|
|
7102
|
+
important = true;
|
|
7103
|
+
value = value.value;
|
|
7104
|
+
continue;
|
|
7105
|
+
}
|
|
7106
|
+
if (isStyleWeightValue(value)) {
|
|
7107
|
+
weight = value.weight;
|
|
7108
|
+
value = value.value;
|
|
7109
|
+
continue;
|
|
7110
|
+
}
|
|
7111
|
+
break;
|
|
7112
|
+
}
|
|
7113
|
+
return [
|
|
7114
|
+
value,
|
|
7115
|
+
weight,
|
|
7116
|
+
important
|
|
7117
|
+
];
|
|
7118
|
+
}
|
|
6305
7119
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6306
7120
|
if (result.ok) return;
|
|
6307
7121
|
if (result.reason.includes("createCounterStyle") || result.reason.includes("createFontFace") || result.reason.includes("createFontPaletteValues") || result.reason.includes("createPositionTry") || result.reason.includes("createProperty") || result.reason.includes("fontSrc")) throw new Error(result.reason);
|
|
@@ -6437,6 +7251,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6437
7251
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6438
7252
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6439
7253
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7254
|
+
const staticIdState = {
|
|
7255
|
+
fileId,
|
|
7256
|
+
imports,
|
|
7257
|
+
styleNames
|
|
7258
|
+
};
|
|
7259
|
+
const t = babel.types;
|
|
6440
7260
|
for (const stmt of ast.program.body) {
|
|
6441
7261
|
if (stmt.type === "ImportDeclaration") {
|
|
6442
7262
|
const source = stmt.source.value;
|
|
@@ -6461,6 +7281,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6461
7281
|
continue;
|
|
6462
7282
|
}
|
|
6463
7283
|
if (stmt.type === "VariableDeclaration") {
|
|
7284
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6464
7285
|
collectVariableBindings(rawBindings, stmt);
|
|
6465
7286
|
continue;
|
|
6466
7287
|
}
|
|
@@ -6484,6 +7305,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6484
7305
|
continue;
|
|
6485
7306
|
}
|
|
6486
7307
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7308
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6487
7309
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6488
7310
|
continue;
|
|
6489
7311
|
}
|
|
@@ -6523,6 +7345,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6523
7345
|
});
|
|
6524
7346
|
return bindings;
|
|
6525
7347
|
}
|
|
7348
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7349
|
+
for (const decl of declaration.declarations) {
|
|
7350
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7351
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
6526
7354
|
function collectVariableBindings(bindings, declaration) {
|
|
6527
7355
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6528
7356
|
}
|
|
@@ -6602,6 +7430,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6602
7430
|
defineCompiledStyleLocations(style, traceResult);
|
|
6603
7431
|
return style;
|
|
6604
7432
|
}
|
|
7433
|
+
if (result.type === "sheet") {
|
|
7434
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7435
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7436
|
+
return sheet;
|
|
7437
|
+
}
|
|
6605
7438
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6606
7439
|
return null;
|
|
6607
7440
|
}
|
|
@@ -6712,6 +7545,12 @@ function hashFileContent(filePath) {
|
|
|
6712
7545
|
function getStyleRuntimeImportPath(mode) {
|
|
6713
7546
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6714
7547
|
}
|
|
7548
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7549
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7550
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7551
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7552
|
+
return null;
|
|
7553
|
+
}
|
|
6715
7554
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6716
7555
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6717
7556
|
}
|
|
@@ -6804,6 +7643,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6804
7643
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6805
7644
|
return t.callExpression(t.identifier(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE), hasSpread ? buildStyleMergeArgs(t, chain, state, options) : [buildItemsArray(t, chain, 1, state, options)]);
|
|
6806
7645
|
}
|
|
7646
|
+
if (chain.type === "sheet") {
|
|
7647
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7648
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7649
|
+
}
|
|
6807
7650
|
if (chain.type === "slot") {
|
|
6808
7651
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6809
7652
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6842,7 +7685,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6842
7685
|
chain.items.forEach((item) => {
|
|
6843
7686
|
if (isCompiledTokenItem(item)) {
|
|
6844
7687
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6845
|
-
else itemExpressions.push(t
|
|
7688
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6846
7689
|
return;
|
|
6847
7690
|
}
|
|
6848
7691
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6941,6 +7784,18 @@ function buildExtractedTokenExpression(t, token, state) {
|
|
|
6941
7784
|
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6942
7785
|
]);
|
|
6943
7786
|
}
|
|
7787
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7788
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7789
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7790
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7791
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7792
|
+
t.nullLiteral(),
|
|
7793
|
+
t.nullLiteral(),
|
|
7794
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7795
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7796
|
+
]);
|
|
7797
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
7798
|
+
}
|
|
6944
7799
|
function literalExpression(t, value) {
|
|
6945
7800
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
6946
7801
|
if (typeof value === "number") return t.numericLiteral(value);
|
|
@@ -7062,6 +7917,7 @@ function getEvalScope(state) {
|
|
|
7062
7917
|
styleFilePath: state.styleFilePath,
|
|
7063
7918
|
sourcemapTrace: state.sourcemapTrace,
|
|
7064
7919
|
styleNames: state.styleNames,
|
|
7920
|
+
sheetNames: state.sheetNames,
|
|
7065
7921
|
styleMetas: state.styleMetas,
|
|
7066
7922
|
bindingNodes: state.bindingNodes,
|
|
7067
7923
|
runtimeMode: state.runtimeMode
|
|
@@ -7119,6 +7975,7 @@ function createExtractPlugin(args) {
|
|
|
7119
7975
|
return {
|
|
7120
7976
|
pre() {
|
|
7121
7977
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
7978
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
7122
7979
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
7123
7980
|
this.bindings = /* @__PURE__ */ new Map();
|
|
7124
7981
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -7165,6 +8022,7 @@ function createExtractPlugin(args) {
|
|
|
7165
8022
|
state.styleNames.add(spec.local.name);
|
|
7166
8023
|
state.styleMetas.set(spec.local.name, meta);
|
|
7167
8024
|
}
|
|
8025
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
7168
8026
|
});
|
|
7169
8027
|
},
|
|
7170
8028
|
VariableDeclaration(path, state) {
|
|
@@ -7211,17 +8069,17 @@ function createExtractPlugin(args) {
|
|
|
7211
8069
|
state.needsExtractImport = true;
|
|
7212
8070
|
return;
|
|
7213
8071
|
}
|
|
7214
|
-
if (!state.styleNames.size) return;
|
|
7215
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
8072
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
8073
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
7216
8074
|
if (!chain) return;
|
|
7217
8075
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
7218
8076
|
const scope = getEvalScope(state);
|
|
7219
8077
|
const loc = path.node.loc?.start;
|
|
7220
8078
|
const meta = state.styleMetas.get(chain.rootName);
|
|
7221
|
-
if (!meta) return;
|
|
8079
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
7222
8080
|
let result;
|
|
7223
8081
|
try {
|
|
7224
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
8082
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
7225
8083
|
} catch (error) {
|
|
7226
8084
|
const message = error instanceof Error ? error.message : String(error);
|
|
7227
8085
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7475,7 +8333,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7475
8333
|
code: args.code,
|
|
7476
8334
|
filePath: args.filePath,
|
|
7477
8335
|
sourcemap: args.sourcemap,
|
|
7478
|
-
plugins: [plugin],
|
|
8336
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7479
8337
|
errorLabel: "[style] compiler error"
|
|
7480
8338
|
});
|
|
7481
8339
|
if (!result) return null;
|
|
@@ -7596,11 +8454,33 @@ function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
|
7596
8454
|
}
|
|
7597
8455
|
function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
7598
8456
|
if (source === "@fluentic/style") return getStyleRuntimeImportPath(runtimeMode);
|
|
8457
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
|
|
8458
|
+
if (adapterImportPath) return adapterImportPath;
|
|
7599
8459
|
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(runtimeMode);
|
|
7600
8460
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7601
8461
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7602
8462
|
return null;
|
|
7603
8463
|
}
|
|
8464
|
+
const CssPropPresets = {
|
|
8465
|
+
Solid: {
|
|
8466
|
+
classProp: "class",
|
|
8467
|
+
styleProp: "style",
|
|
8468
|
+
styleMode: "solid",
|
|
8469
|
+
adapter: "@fluentic/style/adapter/solid"
|
|
8470
|
+
},
|
|
8471
|
+
Preact: {
|
|
8472
|
+
classProp: "class",
|
|
8473
|
+
styleProp: "style",
|
|
8474
|
+
styleMode: "react",
|
|
8475
|
+
adapter: "@fluentic/style/adapter/preact"
|
|
8476
|
+
},
|
|
8477
|
+
React: {
|
|
8478
|
+
classProp: "className",
|
|
8479
|
+
styleProp: "style",
|
|
8480
|
+
styleMode: "react",
|
|
8481
|
+
adapter: "@fluentic/style/adapter/react"
|
|
8482
|
+
}
|
|
8483
|
+
};
|
|
7604
8484
|
//#endregion
|
|
7605
8485
|
//#region plugin/utils/constants.ts
|
|
7606
8486
|
const PLUGIN_NAME = "fluentic-style";
|
|
@@ -7731,10 +8611,10 @@ function getStyleRuntimeMode(dev, rsc = false) {
|
|
|
7731
8611
|
if (rsc) return dev ? "rsc-dev" : "rsc-prod";
|
|
7732
8612
|
return dev ? "dev" : "prod";
|
|
7733
8613
|
}
|
|
7734
|
-
function getPluginBuildConfig(options) {
|
|
8614
|
+
function getPluginBuildConfig(options, dev = false) {
|
|
7735
8615
|
const css = hasBuildConfig(options.css) ? options.css : {};
|
|
7736
8616
|
return {
|
|
7737
|
-
hoist: options.hoist !== false,
|
|
8617
|
+
hoist: !dev && options.hoist !== false,
|
|
7738
8618
|
css
|
|
7739
8619
|
};
|
|
7740
8620
|
}
|
|
@@ -8167,6 +9047,12 @@ Object.defineProperty(exports, "CSS_MODULE_ID", {
|
|
|
8167
9047
|
return CSS_MODULE_ID;
|
|
8168
9048
|
}
|
|
8169
9049
|
});
|
|
9050
|
+
Object.defineProperty(exports, "CssPropPresets", {
|
|
9051
|
+
enumerable: true,
|
|
9052
|
+
get: function() {
|
|
9053
|
+
return CssPropPresets;
|
|
9054
|
+
}
|
|
9055
|
+
});
|
|
8170
9056
|
Object.defineProperty(exports, "DEFAULT_TRANSFORM_INCLUDE_PATTERN", {
|
|
8171
9057
|
enumerable: true,
|
|
8172
9058
|
get: function() {
|
|
@@ -8288,4 +9174,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
8288
9174
|
}
|
|
8289
9175
|
});
|
|
8290
9176
|
|
|
8291
|
-
//# sourceMappingURL=shared-
|
|
9177
|
+
//# sourceMappingURL=shared-8_Msr7Q5.cjs.map
|