@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
2
|
import * as fs$1 from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
|
+
import * as BabelCore from "@babel/core";
|
|
4
5
|
import picomatch from "picomatch";
|
|
5
6
|
import { SelectorType, parse } from "css-what";
|
|
6
|
-
import * as BabelCore from "@babel/core";
|
|
7
7
|
import { ResolverFactory } from "oxc-resolver";
|
|
8
8
|
//#region compiler/compiler/cache.ts
|
|
9
9
|
function createCompilerCache(args) {
|
|
@@ -141,7 +141,7 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
141
141
|
isRSC: false,
|
|
142
142
|
runtimeCacheTTL: getCacheTTL(true)
|
|
143
143
|
};
|
|
144
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
144
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
145
145
|
globalData("config.build", () => ({ current: null }));
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region config/config/debug.ts
|
|
@@ -174,8 +174,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
174
174
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
175
175
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
176
176
|
}
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region atomic/layer/types.ts
|
|
179
177
|
const LayerDefaultPriority = [
|
|
180
178
|
0,
|
|
181
179
|
0,
|
|
@@ -245,6 +243,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
245
243
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
246
244
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
247
245
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
246
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
248
247
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
249
248
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
250
249
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -273,6 +272,131 @@ function getExtractedCssItems(items, args) {
|
|
|
273
272
|
return getLayerBundleCss(args.layers ?? defaults.layers ?? [], layerNamespace, css.map((item) => item.css));
|
|
274
273
|
}
|
|
275
274
|
//#endregion
|
|
275
|
+
//#region compiler/transform/utils/babel.ts
|
|
276
|
+
function babelPlugin(factory) {
|
|
277
|
+
return factory;
|
|
278
|
+
}
|
|
279
|
+
function babelTransform(args) {
|
|
280
|
+
let result = null;
|
|
281
|
+
try {
|
|
282
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
283
|
+
result = BabelCore.transformSync(args.code, {
|
|
284
|
+
...babelTransformOptions(),
|
|
285
|
+
inputSourceMap,
|
|
286
|
+
filename: args.filePath,
|
|
287
|
+
sourceFileName: args.filePath,
|
|
288
|
+
plugins: args.plugins,
|
|
289
|
+
sourceMaps: true,
|
|
290
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
291
|
+
});
|
|
292
|
+
} catch (err) {
|
|
293
|
+
if (!args.errorLabel) throw err;
|
|
294
|
+
const message = getBabelError(err, args);
|
|
295
|
+
const error = new Error(message);
|
|
296
|
+
error.stack = void 0;
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
if (!result || !result.code) return null;
|
|
300
|
+
return {
|
|
301
|
+
code: result.code,
|
|
302
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function babelTransformOptions() {
|
|
306
|
+
return {
|
|
307
|
+
configFile: false,
|
|
308
|
+
babelrc: false,
|
|
309
|
+
parserOpts: {
|
|
310
|
+
plugins: ["typescript", "jsx"],
|
|
311
|
+
strictMode: false,
|
|
312
|
+
allowImportExportEverywhere: true
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function parseInputSourceMap(sourcemap) {
|
|
317
|
+
if (!sourcemap) return void 0;
|
|
318
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
319
|
+
return JSON.parse(sourcemap);
|
|
320
|
+
}
|
|
321
|
+
function getBabelError(err, args) {
|
|
322
|
+
const babelErr = err;
|
|
323
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
324
|
+
const codeFrame = babelErr?.codeFrame;
|
|
325
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
326
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
330
|
+
function createCssPropPlugin(args) {
|
|
331
|
+
return babelPlugin((babel) => {
|
|
332
|
+
const { types: t } = babel;
|
|
333
|
+
return {
|
|
334
|
+
pre() {
|
|
335
|
+
this.options = args.options;
|
|
336
|
+
this.mergeId = null;
|
|
337
|
+
this.programPath = null;
|
|
338
|
+
this.changed = false;
|
|
339
|
+
},
|
|
340
|
+
visitor: {
|
|
341
|
+
Program: {
|
|
342
|
+
enter(path, state) {
|
|
343
|
+
state.programPath = path;
|
|
344
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
345
|
+
},
|
|
346
|
+
exit(path, state) {
|
|
347
|
+
const options = getCssPropOptions(state.options);
|
|
348
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
349
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
JSXOpeningElement(path, state) {
|
|
353
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
354
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
355
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
356
|
+
const parts = path.node.attributes.map((attr) => buildPart(t, attr));
|
|
357
|
+
path.node.attributes = [t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
358
|
+
state.changed = true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function getCssPropOptions(options) {
|
|
365
|
+
return options.cssProp || null;
|
|
366
|
+
}
|
|
367
|
+
function isIntrinsicElement(name) {
|
|
368
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
369
|
+
}
|
|
370
|
+
function hasCssAttribute(attrs) {
|
|
371
|
+
return attrs.some((attr) => {
|
|
372
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function buildPart(t, attr) {
|
|
376
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
377
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
378
|
+
}
|
|
379
|
+
function getObjectKey(t, name) {
|
|
380
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
381
|
+
return t.stringLiteral(getAttributeName(name));
|
|
382
|
+
}
|
|
383
|
+
function getAttributeName(name) {
|
|
384
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
385
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
386
|
+
}
|
|
387
|
+
function getAttributeValue(t, attr) {
|
|
388
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
389
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
390
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
391
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
392
|
+
return attr.value.expression;
|
|
393
|
+
}
|
|
394
|
+
return attr.value;
|
|
395
|
+
}
|
|
396
|
+
function isValidIdentifierName(name) {
|
|
397
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
276
400
|
//#region builder/data/const.ts
|
|
277
401
|
const BUILDER_TYPE = symbol("builder.type");
|
|
278
402
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -280,8 +404,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
280
404
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
281
405
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
282
406
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
407
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
408
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
283
409
|
//#endregion
|
|
284
410
|
//#region utils/object.ts
|
|
411
|
+
function hasOwn(target, field) {
|
|
412
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
413
|
+
}
|
|
285
414
|
function toArray(value) {
|
|
286
415
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
287
416
|
}
|
|
@@ -461,6 +590,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
461
590
|
}
|
|
462
591
|
//#endregion
|
|
463
592
|
//#region builder/data/is.ts
|
|
593
|
+
function getSlotId(data) {
|
|
594
|
+
return data[BUILDER_SLOT_ID];
|
|
595
|
+
}
|
|
596
|
+
function getScopeTargetSlotId(data) {
|
|
597
|
+
return data[BUILDER_SCOPE_ID];
|
|
598
|
+
}
|
|
599
|
+
function getScopeTargetScope(data) {
|
|
600
|
+
return data[BUILDER_SCOPE];
|
|
601
|
+
}
|
|
464
602
|
function isStyleData(value) {
|
|
465
603
|
return getBuilderType(value) === 1;
|
|
466
604
|
}
|
|
@@ -470,9 +608,18 @@ function isSlotData(value) {
|
|
|
470
608
|
function isSlotOverrideData(value) {
|
|
471
609
|
return getBuilderType(value) === 3;
|
|
472
610
|
}
|
|
611
|
+
function isSelectorData(value) {
|
|
612
|
+
return getBuilderType(value) === 7;
|
|
613
|
+
}
|
|
614
|
+
function isSheetData(value) {
|
|
615
|
+
return getBuilderType(value) === 9;
|
|
616
|
+
}
|
|
473
617
|
function isScopeData(value) {
|
|
474
618
|
return getBuilderType(value) === 4;
|
|
475
619
|
}
|
|
620
|
+
function isThemeData(value) {
|
|
621
|
+
return getBuilderType(value) === 6;
|
|
622
|
+
}
|
|
476
623
|
function getBuilderType(value) {
|
|
477
624
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
478
625
|
return value[BUILDER_TYPE];
|
|
@@ -709,114 +856,6 @@ selectorPriority({
|
|
|
709
856
|
...AtRuleSelectors
|
|
710
857
|
}, PrioritySelectors);
|
|
711
858
|
//#endregion
|
|
712
|
-
//#region selector/validate.ts
|
|
713
|
-
function isLocalSelector(selector) {
|
|
714
|
-
const groups = parseSelector(selector);
|
|
715
|
-
if (!groups || groups.length !== 1) return false;
|
|
716
|
-
return isSelectorGroupsSelf(groups, false);
|
|
717
|
-
}
|
|
718
|
-
function isPseudoArgSelector(selector) {
|
|
719
|
-
const groups = parseSelector(selector);
|
|
720
|
-
if (!groups || groups.length !== 1) return false;
|
|
721
|
-
return isSelectorGroupsSelf(groups, true);
|
|
722
|
-
}
|
|
723
|
-
function isTagSelector(selector) {
|
|
724
|
-
const groups = parseSelector(selector);
|
|
725
|
-
if (!groups || groups.length !== 1) return false;
|
|
726
|
-
const group = groups[0];
|
|
727
|
-
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
728
|
-
}
|
|
729
|
-
function isAttrArg(value) {
|
|
730
|
-
if (!value) return false;
|
|
731
|
-
if (value.includes("[") || value.includes("]")) return false;
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
function isRawValue(value) {
|
|
735
|
-
if (!value) return false;
|
|
736
|
-
if (value.includes("{") || value.includes("}")) return false;
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
function parseSelector(selector) {
|
|
740
|
-
try {
|
|
741
|
-
return parse(selector);
|
|
742
|
-
} catch {
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
function isSelectorGroupsSelf(groups, allowTag) {
|
|
747
|
-
for (let i = 0; i < groups.length; i++) {
|
|
748
|
-
const group = groups[i];
|
|
749
|
-
for (let j = 0; j < group.length; j++) {
|
|
750
|
-
const token = group[j];
|
|
751
|
-
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
752
|
-
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
return true;
|
|
756
|
-
}
|
|
757
|
-
function isAllowedSelectorType(type, allowTag) {
|
|
758
|
-
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
759
|
-
}
|
|
760
|
-
//#endregion
|
|
761
|
-
//#region selector/assert.ts
|
|
762
|
-
function assertSelector(type, value) {
|
|
763
|
-
assertSelectorNotEmpty(value);
|
|
764
|
-
if (!type) return;
|
|
765
|
-
if (typeof type === "function") return type(value);
|
|
766
|
-
switch (type) {
|
|
767
|
-
case "local": return assertLocalSelector(value);
|
|
768
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
769
|
-
case "tag": return assertTagSelector(value);
|
|
770
|
-
case "attr": return assertAttrSelector(value);
|
|
771
|
-
case "value": return assertRawValue(value);
|
|
772
|
-
case "media": return assertMediaQuery(value);
|
|
773
|
-
case "supports": return assertSupportsQuery(value);
|
|
774
|
-
case "container": return assertContainerQuery(value);
|
|
775
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
779
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
780
|
-
});
|
|
781
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
782
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
783
|
-
});
|
|
784
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
785
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
786
|
-
});
|
|
787
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
788
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
789
|
-
});
|
|
790
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
791
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
792
|
-
});
|
|
793
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
794
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
795
|
-
});
|
|
796
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
797
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
798
|
-
});
|
|
799
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
800
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
801
|
-
});
|
|
802
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
803
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
804
|
-
});
|
|
805
|
-
//#endregion
|
|
806
|
-
//#region builder/data/check_selector.ts
|
|
807
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
808
|
-
let message = null;
|
|
809
|
-
try {
|
|
810
|
-
assertSelector(fnSelector.assert, arg);
|
|
811
|
-
} catch (error) {
|
|
812
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
813
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
814
|
-
else message = "selector is invalid: " + arg;
|
|
815
|
-
}
|
|
816
|
-
if (!message) return;
|
|
817
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
818
|
-
}
|
|
819
|
-
//#endregion
|
|
820
859
|
//#region builder/data/create.ts
|
|
821
860
|
function createStyleData(callsite) {
|
|
822
861
|
return {
|
|
@@ -850,6 +889,28 @@ function createSlotOverrideData(callsite, slotId) {
|
|
|
850
889
|
[BUILDER_SLOT_ID]: slotId
|
|
851
890
|
};
|
|
852
891
|
}
|
|
892
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
893
|
+
return {
|
|
894
|
+
[BUILDER_TYPE]: 8,
|
|
895
|
+
[BUILDER_STATE]: {
|
|
896
|
+
items: [],
|
|
897
|
+
lookup: {}
|
|
898
|
+
},
|
|
899
|
+
[BUILDER_CALLSITE]: callsite,
|
|
900
|
+
[BUILDER_SELECTOR]: selectors
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function createSelectorData(callsite, selectors) {
|
|
904
|
+
return {
|
|
905
|
+
[BUILDER_TYPE]: 7,
|
|
906
|
+
[BUILDER_STATE]: {
|
|
907
|
+
items: [],
|
|
908
|
+
lookup: {}
|
|
909
|
+
},
|
|
910
|
+
[BUILDER_CALLSITE]: callsite,
|
|
911
|
+
[BUILDER_SELECTOR]: selectors
|
|
912
|
+
};
|
|
913
|
+
}
|
|
853
914
|
function createScopeData(callsite) {
|
|
854
915
|
return {
|
|
855
916
|
[BUILDER_TYPE]: 4,
|
|
@@ -985,6 +1046,9 @@ const formatTransformClassName = createNameFormatter(["className"]);
|
|
|
985
1046
|
function getDebugClassName(format, hash, info) {
|
|
986
1047
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
987
1048
|
}
|
|
1049
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1050
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1051
|
+
}
|
|
988
1052
|
function getDebugTransformClassName(format, hash, info) {
|
|
989
1053
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
990
1054
|
}
|
|
@@ -1180,9 +1244,9 @@ function parseAtRule(rule) {
|
|
|
1180
1244
|
return compressQuery(normalized);
|
|
1181
1245
|
}
|
|
1182
1246
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1183
|
-
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
1247
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1184
1248
|
}
|
|
1185
|
-
function formatScopeClassName(format, info) {
|
|
1249
|
+
function formatScopeClassName$1(format, info) {
|
|
1186
1250
|
if (typeof format === "function") return format(info);
|
|
1187
1251
|
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1188
1252
|
}
|
|
@@ -1236,21 +1300,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1236
1300
|
}
|
|
1237
1301
|
//#endregion
|
|
1238
1302
|
//#region atomic/utils/selector.ts
|
|
1239
|
-
function getSelectorText(selector) {
|
|
1240
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1303
|
+
function getSelectorText$1(selector) {
|
|
1304
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1241
1305
|
}
|
|
1242
1306
|
function getSelectorHash(selector) {
|
|
1243
1307
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1244
1308
|
}
|
|
1245
|
-
function getSelectorPriority(selector) {
|
|
1309
|
+
function getSelectorPriority$1(selector) {
|
|
1246
1310
|
if (!selector) return 0;
|
|
1247
1311
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1248
1312
|
}
|
|
1313
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1314
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1315
|
+
}
|
|
1316
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1317
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1318
|
+
}
|
|
1249
1319
|
//#endregion
|
|
1250
1320
|
//#region atomic/className.ts
|
|
1251
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1321
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1252
1322
|
let hash = property;
|
|
1253
1323
|
hash += "\n" + (priority || "");
|
|
1324
|
+
if (important) hash += "\nimportant";
|
|
1254
1325
|
hash += "\n" + value;
|
|
1255
1326
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1256
1327
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1260,10 +1331,11 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1260
1331
|
if (!debugClassName) return hash;
|
|
1261
1332
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1262
1333
|
const propertyName = getDebugPropertyName(property, value);
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1334
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1335
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1336
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1337
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1338
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1267
1339
|
property: propertyName ? propertyName.property : property,
|
|
1268
1340
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1269
1341
|
});
|
|
@@ -1272,9 +1344,10 @@ function getRuntimeClassNameHashLength(debugClassName) {
|
|
|
1272
1344
|
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1273
1345
|
return CSS_CONFIG.hashLength ?? 7;
|
|
1274
1346
|
}
|
|
1275
|
-
function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
|
|
1347
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1276
1348
|
let hash = property;
|
|
1277
1349
|
hash += "\n" + (priority || "");
|
|
1350
|
+
if (important) hash += "\nimportant";
|
|
1278
1351
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1279
1352
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1280
1353
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1311,7 +1384,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1311
1384
|
let source;
|
|
1312
1385
|
let item;
|
|
1313
1386
|
let lookupIndex;
|
|
1314
|
-
let
|
|
1387
|
+
let weight;
|
|
1388
|
+
let important;
|
|
1315
1389
|
let value;
|
|
1316
1390
|
let atRule;
|
|
1317
1391
|
let dedupe;
|
|
@@ -1322,7 +1396,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1322
1396
|
source = sourceItems[i];
|
|
1323
1397
|
if (!source) continue;
|
|
1324
1398
|
if (isStyleTokenOverrideData(source)) {
|
|
1325
|
-
addTokenOverride(source, styles, lookup);
|
|
1399
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1326
1400
|
continue;
|
|
1327
1401
|
}
|
|
1328
1402
|
if (isScopeData(source)) {
|
|
@@ -1330,7 +1404,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1330
1404
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1331
1405
|
item = scopeItems[j];
|
|
1332
1406
|
if (isStyleTokenOverrideData(item)) {
|
|
1333
|
-
addTokenOverride(item, styles, lookup);
|
|
1407
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1334
1408
|
continue;
|
|
1335
1409
|
}
|
|
1336
1410
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1351,13 +1425,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1351
1425
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1352
1426
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1353
1427
|
value = scopeItem.value;
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1360
|
-
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);
|
|
1428
|
+
weight = scopeItem.weight;
|
|
1429
|
+
important = scopeItem.important;
|
|
1430
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1431
|
+
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);
|
|
1361
1432
|
scopeItem.dedupe = dedupe;
|
|
1362
1433
|
scopeItem.className = className;
|
|
1363
1434
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1394,6 +1465,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1394
1465
|
dedupe: "",
|
|
1395
1466
|
className: "",
|
|
1396
1467
|
property: overrideItem.property,
|
|
1468
|
+
weight: overrideItem.weight,
|
|
1469
|
+
important: overrideItem.important,
|
|
1397
1470
|
value: overrideItem.value,
|
|
1398
1471
|
transformClassName: overrideItem.transformClassName,
|
|
1399
1472
|
token: overrideItem.token,
|
|
@@ -1405,13 +1478,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1405
1478
|
parentSelector
|
|
1406
1479
|
};
|
|
1407
1480
|
value = scopeItem.value;
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1414
|
-
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);
|
|
1481
|
+
weight = scopeItem.weight;
|
|
1482
|
+
important = scopeItem.important;
|
|
1483
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1484
|
+
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);
|
|
1415
1485
|
scopeItem.dedupe = dedupe;
|
|
1416
1486
|
scopeItem.className = className;
|
|
1417
1487
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1422,7 +1492,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1422
1492
|
}
|
|
1423
1493
|
return data;
|
|
1424
1494
|
}
|
|
1425
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1495
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1426
1496
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1427
1497
|
const lookupIndex = lookup[lookupKey];
|
|
1428
1498
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1567,6 +1637,18 @@ function shouldAppendCssPx(property) {
|
|
|
1567
1637
|
return !UNITLESS.has(property);
|
|
1568
1638
|
}
|
|
1569
1639
|
//#endregion
|
|
1640
|
+
//#region style/important.ts
|
|
1641
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1642
|
+
function importantValue(value) {
|
|
1643
|
+
return {
|
|
1644
|
+
[STYLE_IMPORTANT]: true,
|
|
1645
|
+
value
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
function isStyleImportantValue(value) {
|
|
1649
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1650
|
+
}
|
|
1651
|
+
//#endregion
|
|
1570
1652
|
//#region style/transform.ts
|
|
1571
1653
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1572
1654
|
function classNameValue(value, className) {
|
|
@@ -1592,6 +1674,19 @@ function isAtRuleRef(value) {
|
|
|
1592
1674
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1593
1675
|
}
|
|
1594
1676
|
//#endregion
|
|
1677
|
+
//#region style/weight.ts
|
|
1678
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1679
|
+
function weightValue(value, weight) {
|
|
1680
|
+
return {
|
|
1681
|
+
[STYLE_WEIGHT]: true,
|
|
1682
|
+
value,
|
|
1683
|
+
weight
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function isStyleWeightValue(value) {
|
|
1687
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1688
|
+
}
|
|
1689
|
+
//#endregion
|
|
1595
1690
|
//#region builder/data/merge/style.ts
|
|
1596
1691
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1597
1692
|
if (!style) return source;
|
|
@@ -1602,7 +1697,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1602
1697
|
let itemData;
|
|
1603
1698
|
let valueRaw;
|
|
1604
1699
|
let value;
|
|
1605
|
-
let
|
|
1700
|
+
let weight;
|
|
1701
|
+
let important;
|
|
1606
1702
|
let itemCallsite;
|
|
1607
1703
|
let className;
|
|
1608
1704
|
let dedupe;
|
|
@@ -1623,6 +1719,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1623
1719
|
continue;
|
|
1624
1720
|
}
|
|
1625
1721
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1722
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1626
1723
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1627
1724
|
type: 2,
|
|
1628
1725
|
slotId
|
|
@@ -1631,6 +1728,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1631
1728
|
type: 3,
|
|
1632
1729
|
slotId
|
|
1633
1730
|
});
|
|
1731
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1634
1732
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1635
1733
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1636
1734
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1642,11 +1740,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1642
1740
|
}
|
|
1643
1741
|
} else for (const property in style) {
|
|
1644
1742
|
valueRaw = style[property];
|
|
1645
|
-
|
|
1646
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1647
|
-
priority = valueRaw[0];
|
|
1648
|
-
valueRaw = valueRaw[1];
|
|
1649
|
-
}
|
|
1743
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1650
1744
|
transformClassName = null;
|
|
1651
1745
|
if (isClassNameValue(valueRaw)) {
|
|
1652
1746
|
transformClassName = valueRaw.className;
|
|
@@ -1657,7 +1751,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1657
1751
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1658
1752
|
variableName = getDebugFieldVarName(debug, property);
|
|
1659
1753
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1660
|
-
value = priority !== null ? [value, priority] : value;
|
|
1661
1754
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1662
1755
|
itemData = {
|
|
1663
1756
|
runtime: runtimeType,
|
|
@@ -1666,6 +1759,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1666
1759
|
dedupe: "",
|
|
1667
1760
|
className: "",
|
|
1668
1761
|
property,
|
|
1762
|
+
weight,
|
|
1763
|
+
important,
|
|
1669
1764
|
value,
|
|
1670
1765
|
transformClassName,
|
|
1671
1766
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1679,7 +1774,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1679
1774
|
atRule,
|
|
1680
1775
|
callsite: itemCallsite
|
|
1681
1776
|
};
|
|
1682
|
-
if (type === 1) {
|
|
1777
|
+
if (type === 1 || type === 8) {
|
|
1683
1778
|
items.push({
|
|
1684
1779
|
...itemData,
|
|
1685
1780
|
type: 1
|
|
@@ -1726,13 +1821,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1726
1821
|
}
|
|
1727
1822
|
const runtimeItem = item;
|
|
1728
1823
|
value = runtimeItem.value;
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}
|
|
1734
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1735
|
-
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);
|
|
1824
|
+
weight = runtimeItem.weight;
|
|
1825
|
+
important = runtimeItem.important;
|
|
1826
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1827
|
+
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);
|
|
1736
1828
|
runtimeItem.dedupe = dedupe;
|
|
1737
1829
|
runtimeItem.className = className;
|
|
1738
1830
|
lookupIndex = lookup[dedupe];
|
|
@@ -1741,21 +1833,56 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1741
1833
|
}
|
|
1742
1834
|
return data;
|
|
1743
1835
|
}
|
|
1744
|
-
function
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1836
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1837
|
+
let weight = null;
|
|
1838
|
+
let important = false;
|
|
1839
|
+
while (true) {
|
|
1840
|
+
if (isStyleImportantValue(value)) {
|
|
1841
|
+
important = true;
|
|
1842
|
+
value = value.value;
|
|
1843
|
+
continue;
|
|
1844
|
+
}
|
|
1845
|
+
if (isStyleWeightValue(value)) {
|
|
1846
|
+
weight = value.weight;
|
|
1847
|
+
value = value.value;
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
return [
|
|
1853
|
+
value,
|
|
1854
|
+
weight,
|
|
1855
|
+
important
|
|
1856
|
+
];
|
|
1857
|
+
}
|
|
1858
|
+
function combineSelectors$1(parent, child) {
|
|
1859
|
+
const parentText = getSelectorText(parent);
|
|
1860
|
+
const childText = getSelectorText(child);
|
|
1861
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
1862
|
+
const selector = parentText + childText;
|
|
1863
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
1864
|
+
}
|
|
1865
|
+
function getSelectorText(selector) {
|
|
1866
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
1867
|
+
}
|
|
1868
|
+
function getSelectorPriority(selector) {
|
|
1869
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
1870
|
+
}
|
|
1871
|
+
function getMergedStyleDebug(debug, item) {
|
|
1872
|
+
if (!debug) return null;
|
|
1873
|
+
if (debug.fields?.[item.property]) return debug;
|
|
1874
|
+
const valueLoc = getMergedItemValueLoc(item);
|
|
1875
|
+
if (!valueLoc) return debug;
|
|
1876
|
+
return {
|
|
1877
|
+
...debug,
|
|
1878
|
+
fields: {
|
|
1879
|
+
...debug.fields,
|
|
1880
|
+
[item.property]: {
|
|
1881
|
+
[0]: withDebugSource$1(debug.loc, debug),
|
|
1882
|
+
[1]: valueLoc
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1759
1886
|
}
|
|
1760
1887
|
function getMergedItemValueLoc(item) {
|
|
1761
1888
|
if (item.debug && item.debugField) {
|
|
@@ -1784,6 +1911,47 @@ function withDebugSource$1(loc, debug) {
|
|
|
1784
1911
|
];
|
|
1785
1912
|
}
|
|
1786
1913
|
//#endregion
|
|
1914
|
+
//#region builder/selector_override_core.ts
|
|
1915
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
1916
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
1917
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
1918
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
1919
|
+
}
|
|
1920
|
+
function assertManualSelectorSyntax(selector) {
|
|
1921
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
1922
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
1923
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
1924
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1925
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
1926
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1927
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
1928
|
+
}
|
|
1929
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
1930
|
+
const value = selector.trim();
|
|
1931
|
+
assertManualSelector(value);
|
|
1932
|
+
if (value.startsWith("&?")) {
|
|
1933
|
+
const suffix = value.slice(2);
|
|
1934
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
1935
|
+
}
|
|
1936
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
1937
|
+
}
|
|
1938
|
+
//#endregion
|
|
1939
|
+
//#region builder/selector_override.ts
|
|
1940
|
+
function normalizeManualSelectors(input) {
|
|
1941
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
1942
|
+
}
|
|
1943
|
+
function assertManualSelector(selector) {
|
|
1944
|
+
assertManualSelectorSyntax(selector);
|
|
1945
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1946
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1947
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
1948
|
+
try {
|
|
1949
|
+
parse(parsedSelector);
|
|
1950
|
+
} catch {
|
|
1951
|
+
throw new Error("selector is invalid: " + selector);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
//#endregion
|
|
1787
1955
|
//#region builder/style_data.ts
|
|
1788
1956
|
const mergeStyleCreate = (callsite) => {
|
|
1789
1957
|
return createStyleData(callsite);
|
|
@@ -1797,16 +1965,129 @@ const mergeSlotOverrideCreate = (callsite, data) => {
|
|
|
1797
1965
|
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1798
1966
|
};
|
|
1799
1967
|
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
1968
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
1969
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
1970
|
+
};
|
|
1971
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1800
1972
|
function createMerge(create, type) {
|
|
1801
1973
|
return (data, callsite, style, debug, selector, atRule) => {
|
|
1802
1974
|
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1803
1975
|
};
|
|
1804
1976
|
}
|
|
1805
1977
|
//#endregion
|
|
1978
|
+
//#region selector/validate.ts
|
|
1979
|
+
function isLocalSelector(selector) {
|
|
1980
|
+
const groups = parseSelector(selector);
|
|
1981
|
+
if (!groups || groups.length !== 1) return false;
|
|
1982
|
+
return isSelectorGroupsSelf(groups, false);
|
|
1983
|
+
}
|
|
1984
|
+
function isPseudoArgSelector(selector) {
|
|
1985
|
+
const groups = parseSelector(selector);
|
|
1986
|
+
if (!groups || groups.length !== 1) return false;
|
|
1987
|
+
return isSelectorGroupsSelf(groups, true);
|
|
1988
|
+
}
|
|
1989
|
+
function isTagSelector(selector) {
|
|
1990
|
+
const groups = parseSelector(selector);
|
|
1991
|
+
if (!groups || groups.length !== 1) return false;
|
|
1992
|
+
const group = groups[0];
|
|
1993
|
+
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
1994
|
+
}
|
|
1995
|
+
function isAttrArg(value) {
|
|
1996
|
+
if (!value) return false;
|
|
1997
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
1998
|
+
return true;
|
|
1999
|
+
}
|
|
2000
|
+
function isRawValue(value) {
|
|
2001
|
+
if (!value) return false;
|
|
2002
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
2003
|
+
return true;
|
|
2004
|
+
}
|
|
2005
|
+
function parseSelector(selector) {
|
|
2006
|
+
try {
|
|
2007
|
+
return parse(selector);
|
|
2008
|
+
} catch {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
2013
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2014
|
+
const group = groups[i];
|
|
2015
|
+
for (let j = 0; j < group.length; j++) {
|
|
2016
|
+
const token = group[j];
|
|
2017
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2018
|
+
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return true;
|
|
2022
|
+
}
|
|
2023
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2024
|
+
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
2025
|
+
}
|
|
2026
|
+
//#endregion
|
|
2027
|
+
//#region selector/assert.ts
|
|
2028
|
+
function assertSelector(type, value) {
|
|
2029
|
+
assertSelectorNotEmpty(value);
|
|
2030
|
+
if (!type) return;
|
|
2031
|
+
if (typeof type === "function") return type(value);
|
|
2032
|
+
switch (type) {
|
|
2033
|
+
case "local": return assertLocalSelector(value);
|
|
2034
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2035
|
+
case "tag": return assertTagSelector(value);
|
|
2036
|
+
case "attr": return assertAttrSelector(value);
|
|
2037
|
+
case "value": return assertRawValue(value);
|
|
2038
|
+
case "media": return assertMediaQuery(value);
|
|
2039
|
+
case "supports": return assertSupportsQuery(value);
|
|
2040
|
+
case "container": return assertContainerQuery(value);
|
|
2041
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2045
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2046
|
+
});
|
|
2047
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2048
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2049
|
+
});
|
|
2050
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2051
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2052
|
+
});
|
|
2053
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2054
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2055
|
+
});
|
|
2056
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2057
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2058
|
+
});
|
|
2059
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2060
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2061
|
+
});
|
|
2062
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2063
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2064
|
+
});
|
|
2065
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2066
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2067
|
+
});
|
|
2068
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2069
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2070
|
+
});
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region builder/data/check_selector.ts
|
|
2073
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2074
|
+
let message = null;
|
|
2075
|
+
try {
|
|
2076
|
+
assertSelector(fnSelector.assert, arg);
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2079
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2080
|
+
else message = "selector is invalid: " + arg;
|
|
2081
|
+
}
|
|
2082
|
+
if (!message) return;
|
|
2083
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
2084
|
+
}
|
|
2085
|
+
//#endregion
|
|
1806
2086
|
//#region builder/utils.ts
|
|
1807
2087
|
const FnPrefixStyle = "style.";
|
|
1808
2088
|
const FnPrefixSlot = "slot.";
|
|
1809
2089
|
const FnPrefixScope = "scope.";
|
|
2090
|
+
const FnPrefixSelector = "selector.";
|
|
1810
2091
|
function runtimeCallsite() {
|
|
1811
2092
|
return traceCallsite();
|
|
1812
2093
|
}
|
|
@@ -1867,9 +2148,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1867
2148
|
let arg;
|
|
1868
2149
|
let style;
|
|
1869
2150
|
let debug;
|
|
1870
|
-
let
|
|
2151
|
+
let weight = null;
|
|
1871
2152
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1872
|
-
|
|
2153
|
+
weight = params[0];
|
|
1873
2154
|
arg = params[1];
|
|
1874
2155
|
style = params[2];
|
|
1875
2156
|
debug = params[3];
|
|
@@ -1879,7 +2160,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1879
2160
|
debug = params[2];
|
|
1880
2161
|
}
|
|
1881
2162
|
else if (isMedia && typeof params[0] === "number") {
|
|
1882
|
-
|
|
2163
|
+
weight = params[0];
|
|
1883
2164
|
arg = fnSelector.selector;
|
|
1884
2165
|
style = params[1];
|
|
1885
2166
|
debug = params[2];
|
|
@@ -1899,7 +2180,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1899
2180
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1900
2181
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
1901
2182
|
const item = items[j];
|
|
1902
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2183
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
1903
2184
|
}
|
|
1904
2185
|
}
|
|
1905
2186
|
return createFnResult(data, fns);
|
|
@@ -1966,9 +2247,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1966
2247
|
let arg;
|
|
1967
2248
|
let data;
|
|
1968
2249
|
let debug;
|
|
1969
|
-
let
|
|
2250
|
+
let weight = null;
|
|
1970
2251
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1971
|
-
|
|
2252
|
+
weight = params[0];
|
|
1972
2253
|
arg = params[1];
|
|
1973
2254
|
data = params[2];
|
|
1974
2255
|
debug = params[3];
|
|
@@ -1978,7 +2259,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1978
2259
|
debug = params[2];
|
|
1979
2260
|
}
|
|
1980
2261
|
else if (isMedia && typeof params[0] === "number") {
|
|
1981
|
-
|
|
2262
|
+
weight = params[0];
|
|
1982
2263
|
arg = fnSelector.selector;
|
|
1983
2264
|
data = params[1];
|
|
1984
2265
|
debug = params[2];
|
|
@@ -1995,7 +2276,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1995
2276
|
selector = args[i];
|
|
1996
2277
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
1997
2278
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1998
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2279
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
1999
2280
|
}
|
|
2000
2281
|
return result;
|
|
2001
2282
|
};
|
|
@@ -2072,6 +2353,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2072
2353
|
traceMarker(fn, "slot");
|
|
2073
2354
|
return fn;
|
|
2074
2355
|
}
|
|
2356
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2357
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2358
|
+
const fn = (selector, style, debug) => {
|
|
2359
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2360
|
+
debug = style;
|
|
2361
|
+
style = void 0;
|
|
2362
|
+
}
|
|
2363
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2364
|
+
if (style === void 0) return target;
|
|
2365
|
+
return target(style, debug);
|
|
2366
|
+
};
|
|
2367
|
+
traceMarker(fn, "style.selector");
|
|
2368
|
+
return fn;
|
|
2369
|
+
}
|
|
2075
2370
|
function createScopeBuilder(selectors) {
|
|
2076
2371
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2077
2372
|
const fn = (items, debug) => {
|
|
@@ -2087,6 +2382,34 @@ function createScopeBuilder(selectors) {
|
|
|
2087
2382
|
traceMarker(fn, "scope");
|
|
2088
2383
|
return fn;
|
|
2089
2384
|
}
|
|
2385
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2386
|
+
const callable = ((style, debug) => {
|
|
2387
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2388
|
+
debug = style;
|
|
2389
|
+
style = void 0;
|
|
2390
|
+
}
|
|
2391
|
+
const callsite = resolveCallsite(debug);
|
|
2392
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2393
|
+
});
|
|
2394
|
+
traceMarker(callable, "selector.override");
|
|
2395
|
+
Object.setPrototypeOf(callable, fns);
|
|
2396
|
+
Object.assign(callable, data);
|
|
2397
|
+
return callable;
|
|
2398
|
+
}
|
|
2399
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2400
|
+
const callable = ((style, debug) => {
|
|
2401
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2402
|
+
debug = style;
|
|
2403
|
+
style = void 0;
|
|
2404
|
+
}
|
|
2405
|
+
const callsite = resolveCallsite(debug);
|
|
2406
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2407
|
+
});
|
|
2408
|
+
traceMarker(callable, "selector");
|
|
2409
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2410
|
+
Object.assign(callable, data);
|
|
2411
|
+
return callable;
|
|
2412
|
+
}
|
|
2090
2413
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2091
2414
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2092
2415
|
const callable = ((style, debug) => {
|
|
@@ -2636,64 +2959,555 @@ function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenL
|
|
|
2636
2959
|
css
|
|
2637
2960
|
};
|
|
2638
2961
|
}
|
|
2639
|
-
createIdCounter("fontPaletteValues");
|
|
2962
|
+
createIdCounter("fontPaletteValues");
|
|
2963
|
+
//#endregion
|
|
2964
|
+
//#region atomic/atRule/keyframes.ts
|
|
2965
|
+
const KEYFRAMES_AT_RULE = "keyframes";
|
|
2966
|
+
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
2967
|
+
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
2968
|
+
name = formatKeyFramesName(format, id, { name });
|
|
2969
|
+
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
2970
|
+
for (const selector in frames) {
|
|
2971
|
+
const frame = frames[selector];
|
|
2972
|
+
if (!frame) continue;
|
|
2973
|
+
css += selector + "{";
|
|
2974
|
+
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
2975
|
+
css += "}";
|
|
2976
|
+
}
|
|
2977
|
+
css += "}";
|
|
2978
|
+
return {
|
|
2979
|
+
name,
|
|
2980
|
+
css
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
//#endregion
|
|
2984
|
+
//#region css/keyframes.ts
|
|
2985
|
+
const idCounter$2 = createIdCounter("keyframes");
|
|
2986
|
+
function createKeyframes(frames, stableId) {
|
|
2987
|
+
return createNamedAtRuleRef({
|
|
2988
|
+
format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
|
|
2989
|
+
buildCss: buildKeyframesCss,
|
|
2990
|
+
value: frames,
|
|
2991
|
+
idCounter: idCounter$2,
|
|
2992
|
+
stableId
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
//#endregion
|
|
2996
|
+
//#region atomic/atRule/positionTry.ts
|
|
2997
|
+
const POSITION_TRY_AT_RULE = "position-try";
|
|
2998
|
+
const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
|
|
2999
|
+
function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3000
|
+
name = formatPositionTryName(format, id, { name });
|
|
3001
|
+
const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3002
|
+
return {
|
|
3003
|
+
name,
|
|
3004
|
+
css
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
createIdCounter("positionTry");
|
|
3008
|
+
//#endregion
|
|
3009
|
+
//#region atomic/atRule/property.ts
|
|
3010
|
+
const PROPERTY_AT_RULE = "property";
|
|
3011
|
+
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3012
|
+
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3013
|
+
name = formatPropertyName(format, id, { name });
|
|
3014
|
+
return {
|
|
3015
|
+
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3016
|
+
name
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
createIdCounter("property");
|
|
3020
|
+
//#endregion
|
|
3021
|
+
//#region sheet/utils/sourcemap.ts
|
|
3022
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3023
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3024
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3025
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3026
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3027
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3028
|
+
function encodeBase64(text) {
|
|
3029
|
+
const bytes = new TextEncoder().encode(text);
|
|
3030
|
+
let binary = "";
|
|
3031
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3032
|
+
return btoa(binary);
|
|
3033
|
+
}
|
|
3034
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3035
|
+
let source = sourceLookup[filePath];
|
|
3036
|
+
if (source) {
|
|
3037
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3038
|
+
return source;
|
|
3039
|
+
}
|
|
3040
|
+
source = {
|
|
3041
|
+
filePath,
|
|
3042
|
+
sourceIndex: sources.length,
|
|
3043
|
+
sourceContent
|
|
3044
|
+
};
|
|
3045
|
+
sources.push(source);
|
|
3046
|
+
sourceLookup[filePath] = source;
|
|
3047
|
+
return source;
|
|
3048
|
+
}
|
|
3049
|
+
function normalizeSourcePath(filePath) {
|
|
3050
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3051
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3052
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3053
|
+
return filePath.replace(/^at\s+/, "");
|
|
3054
|
+
}
|
|
3055
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3056
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3057
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3058
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3059
|
+
}
|
|
3060
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3061
|
+
const sidecarUrl = getSidecarUrl();
|
|
3062
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3063
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3064
|
+
}
|
|
3065
|
+
function getSidecarUrl() {
|
|
3066
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3067
|
+
return typeof value === "string" && value ? value : null;
|
|
3068
|
+
}
|
|
3069
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3070
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3071
|
+
try {
|
|
3072
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3073
|
+
} catch {
|
|
3074
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3078
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3079
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3080
|
+
return path ? `${base}/${path}` : base;
|
|
3081
|
+
}
|
|
3082
|
+
function getLineCount(css) {
|
|
3083
|
+
let count = 1;
|
|
3084
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3085
|
+
return count;
|
|
3086
|
+
}
|
|
3087
|
+
function encodeVlq(value) {
|
|
3088
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3089
|
+
let encoded = "";
|
|
3090
|
+
do {
|
|
3091
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3092
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3093
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3094
|
+
encoded += BASE64[digit];
|
|
3095
|
+
} while (vlq > 0);
|
|
3096
|
+
return encoded;
|
|
3097
|
+
}
|
|
3098
|
+
//#endregion
|
|
3099
|
+
//#region sheet/sourcemap.ts
|
|
3100
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3101
|
+
if (debug && debugField) {
|
|
3102
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3103
|
+
if (loc) return normalizeRuleCallsite({
|
|
3104
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3105
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3106
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3107
|
+
line: loc[0],
|
|
3108
|
+
column: loc[1]
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3112
|
+
if (debug) return normalizeRuleCallsite({
|
|
3113
|
+
filePath: debug.sourceUrl,
|
|
3114
|
+
sourceUrl: debug.sourceUrl,
|
|
3115
|
+
sourceContent: debug.code,
|
|
3116
|
+
line: debug.loc[0],
|
|
3117
|
+
column: debug.loc[1]
|
|
3118
|
+
});
|
|
3119
|
+
return callsite || null;
|
|
3120
|
+
}
|
|
3121
|
+
function normalizeRuleCallsite(callsite) {
|
|
3122
|
+
return {
|
|
3123
|
+
...callsite,
|
|
3124
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3125
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3126
|
+
};
|
|
3127
|
+
}
|
|
3128
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3129
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3130
|
+
//#endregion
|
|
3131
|
+
//#region builder/extract/utils.ts
|
|
3132
|
+
function createExtractedData(type, slotId) {
|
|
3133
|
+
const data = {
|
|
3134
|
+
[BUILDER_TYPE]: type,
|
|
3135
|
+
[BUILDER_STATE]: {
|
|
3136
|
+
items: [],
|
|
3137
|
+
lookup: {}
|
|
3138
|
+
},
|
|
3139
|
+
[BUILDER_CALLSITE]: null
|
|
3140
|
+
};
|
|
3141
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3142
|
+
return data;
|
|
3143
|
+
}
|
|
3144
|
+
function copyExtractedData(target, source) {
|
|
3145
|
+
const mutable = target;
|
|
3146
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3147
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3148
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3149
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3150
|
+
}
|
|
3151
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3152
|
+
return {
|
|
3153
|
+
[BUILDER_TYPE]: 5,
|
|
3154
|
+
[BUILDER_SCOPE]: scope,
|
|
3155
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3159
|
+
const normalized = [];
|
|
3160
|
+
let i = 0;
|
|
3161
|
+
while (i < items.length) {
|
|
3162
|
+
const item = items[i];
|
|
3163
|
+
const value = item[2];
|
|
3164
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3165
|
+
type,
|
|
3166
|
+
item[0],
|
|
3167
|
+
item[1]
|
|
3168
|
+
] : [
|
|
3169
|
+
type,
|
|
3170
|
+
slotId,
|
|
3171
|
+
item[0],
|
|
3172
|
+
item[1]
|
|
3173
|
+
] : slotId === null ? [
|
|
3174
|
+
type,
|
|
3175
|
+
item[0],
|
|
3176
|
+
item[1],
|
|
3177
|
+
value
|
|
3178
|
+
] : [
|
|
3179
|
+
type,
|
|
3180
|
+
slotId,
|
|
3181
|
+
item[0],
|
|
3182
|
+
item[1],
|
|
3183
|
+
value
|
|
3184
|
+
]);
|
|
3185
|
+
i++;
|
|
3186
|
+
}
|
|
3187
|
+
return normalized;
|
|
3188
|
+
}
|
|
3189
|
+
//#endregion
|
|
3190
|
+
//#region builder/extract/withTokens.ts
|
|
3191
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3192
|
+
function isExtractedTokenBoundData(value) {
|
|
3193
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3194
|
+
}
|
|
3195
|
+
function getExtractedTokenBoundData(value) {
|
|
3196
|
+
return tokenBoundData.get(value);
|
|
3197
|
+
}
|
|
3198
|
+
function isElementDebugData(value) {
|
|
3199
|
+
if (!value || typeof value !== "object") return false;
|
|
3200
|
+
return value.$$elementDebug === true;
|
|
3201
|
+
}
|
|
3202
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3203
|
+
//#endregion
|
|
3204
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3205
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3206
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3207
|
+
function markResolvedStyleItem(item) {
|
|
3208
|
+
resolvedStyleItems.add(item);
|
|
3209
|
+
}
|
|
3210
|
+
function isResolvedStyleItem$1(value) {
|
|
3211
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3212
|
+
}
|
|
3213
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3214
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
3215
|
+
}
|
|
3216
|
+
//#endregion
|
|
3217
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3218
|
+
function createMutableTokenValues(base) {
|
|
3219
|
+
return {
|
|
3220
|
+
ids: base ? base.ids.slice() : null,
|
|
3221
|
+
values: base ? base.values.slice() : null,
|
|
3222
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3223
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
function addTokenOverride(values, item, resolver) {
|
|
3227
|
+
if (!resolver.is(item)) return false;
|
|
3228
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3229
|
+
return true;
|
|
3230
|
+
}
|
|
3231
|
+
function addTokenValue(values, id, value) {
|
|
3232
|
+
if (!values.ids) values.ids = [];
|
|
3233
|
+
if (!values.values) values.values = [];
|
|
3234
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3235
|
+
if (!values.index) values.index = Object.create(null);
|
|
3236
|
+
const ids = values.ids;
|
|
3237
|
+
const tokenValues = values.values;
|
|
3238
|
+
const lookup = values.lookup;
|
|
3239
|
+
const indexLookup = values.index;
|
|
3240
|
+
const index = indexLookup[id];
|
|
3241
|
+
if (index === void 0) {
|
|
3242
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3243
|
+
tokenValues.push(value);
|
|
3244
|
+
} else tokenValues[index] = value;
|
|
3245
|
+
lookup[id] = value;
|
|
3246
|
+
}
|
|
3247
|
+
function addTokenValues(values, next) {
|
|
3248
|
+
if (!next) return;
|
|
3249
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3250
|
+
}
|
|
3251
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3252
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3253
|
+
}
|
|
3254
|
+
function finishTokenValues(base, values) {
|
|
3255
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3256
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
3257
|
+
return {
|
|
3258
|
+
ids: values.ids,
|
|
3259
|
+
values: values.values,
|
|
3260
|
+
lookup: values.lookup
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3263
|
+
function mergeTokenValues(base, next) {
|
|
3264
|
+
if (!next) return base;
|
|
3265
|
+
if (!base) return next;
|
|
3266
|
+
const values = createMutableTokenValues(base);
|
|
3267
|
+
addTokenValues(values, next);
|
|
3268
|
+
return finishTokenValues(base, values);
|
|
3269
|
+
}
|
|
3270
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3271
|
+
if (!overrides.length) return base;
|
|
3272
|
+
const values = createMutableTokenValues(base);
|
|
3273
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3274
|
+
return finishTokenValues(base, values);
|
|
3275
|
+
}
|
|
3276
|
+
function createTokenIndexLookup(ids) {
|
|
3277
|
+
const lookup = Object.create(null);
|
|
3278
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3279
|
+
return lookup;
|
|
3280
|
+
}
|
|
3281
|
+
function isSameTokenValues(base, ids, values) {
|
|
3282
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3283
|
+
const baseLookup = base.lookup;
|
|
3284
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3285
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3286
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3287
|
+
}
|
|
3288
|
+
return true;
|
|
3289
|
+
}
|
|
3290
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3291
|
+
function isResolvedStyleItem(value) {
|
|
3292
|
+
return isResolvedStyleItem$1(value);
|
|
3293
|
+
}
|
|
3294
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3295
|
+
return createStyleItem({
|
|
3296
|
+
data,
|
|
3297
|
+
items: resolveItems(data, scopes)
|
|
3298
|
+
}, tokens);
|
|
3299
|
+
}
|
|
3300
|
+
function createStyleItem(item, tokens = null) {
|
|
3301
|
+
markResolvedStyleItem(item);
|
|
3302
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3303
|
+
return item;
|
|
3304
|
+
}
|
|
3305
|
+
function resolveItems(data, scopes) {
|
|
3306
|
+
const items = [];
|
|
3307
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3308
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3309
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3310
|
+
const item = stateItems[i];
|
|
3311
|
+
if (Array.isArray(item)) {
|
|
3312
|
+
items.push(item);
|
|
3313
|
+
continue;
|
|
3314
|
+
}
|
|
3315
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3316
|
+
items.push(item);
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
if (slotId && item.type !== 2) continue;
|
|
3320
|
+
items.push(item);
|
|
3321
|
+
}
|
|
3322
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3323
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3324
|
+
const boundScope = scopes[i];
|
|
3325
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3326
|
+
if (!scope) continue;
|
|
3327
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3328
|
+
if (!scopeItems) continue;
|
|
3329
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3330
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3331
|
+
const item = scopeItems[j];
|
|
3332
|
+
if (Array.isArray(item)) {
|
|
3333
|
+
if (item[1] === slotId) items.push(item);
|
|
3334
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3335
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3336
|
+
continue;
|
|
3337
|
+
}
|
|
3338
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3339
|
+
if (item.type !== 4) continue;
|
|
3340
|
+
if (item.slotId === slotId) items.push(item);
|
|
3341
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
return items;
|
|
3345
|
+
}
|
|
3346
|
+
function getScopeParentItem(className) {
|
|
3347
|
+
const parentClassName = formatScopeClassName(className);
|
|
3348
|
+
return [parentClassName, parentClassName];
|
|
3349
|
+
}
|
|
3350
|
+
function formatScopeClassName(className) {
|
|
3351
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3352
|
+
if (!format) return "-" + className;
|
|
3353
|
+
if (typeof format === "function") return format({ className });
|
|
3354
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3355
|
+
}
|
|
3356
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3357
|
+
return value === 1 || value === true;
|
|
3358
|
+
}
|
|
2640
3359
|
//#endregion
|
|
2641
|
-
//#region
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
3360
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3361
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3362
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3363
|
+
}
|
|
3364
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3365
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3366
|
+
}
|
|
3367
|
+
function getDataTokenValues(data, resolver) {
|
|
3368
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3369
|
+
const values = createMutableTokenValues(null);
|
|
3370
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3371
|
+
return finishTokenValues(null, values);
|
|
3372
|
+
}
|
|
3373
|
+
createCacheValue();
|
|
3374
|
+
function createCacheValue() {
|
|
2655
3375
|
return {
|
|
2656
|
-
|
|
2657
|
-
|
|
3376
|
+
d: null,
|
|
3377
|
+
c: RUNTIME_CONFIG.changes
|
|
2658
3378
|
};
|
|
2659
3379
|
}
|
|
2660
3380
|
//#endregion
|
|
2661
|
-
//#region
|
|
2662
|
-
const
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
3381
|
+
//#region runtime/core/cache/token.ts
|
|
3382
|
+
const runtimeTokenValueResolver = {
|
|
3383
|
+
get key() {
|
|
3384
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3385
|
+
},
|
|
3386
|
+
is: isStyleTokenOverrideData,
|
|
3387
|
+
id(token) {
|
|
3388
|
+
return getStyleTokenId(token);
|
|
3389
|
+
},
|
|
3390
|
+
value(token) {
|
|
3391
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3395
|
+
if (isElementDebugData(item)) return null;
|
|
3396
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3397
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3398
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3399
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3400
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3401
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3402
|
+
}
|
|
3403
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3404
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3405
|
+
return null;
|
|
2671
3406
|
}
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
const
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
}
|
|
3407
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3408
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3409
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3410
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3411
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3412
|
+
if (key && tokens) tokenBindings.push({
|
|
3413
|
+
data: key,
|
|
3414
|
+
tokens
|
|
3415
|
+
});
|
|
3416
|
+
return key;
|
|
3417
|
+
}
|
|
3418
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3419
|
+
return null;
|
|
2683
3420
|
}
|
|
2684
|
-
createIdCounter("positionTry");
|
|
2685
3421
|
//#endregion
|
|
2686
|
-
//#region atomic/
|
|
2687
|
-
|
|
2688
|
-
const
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
3422
|
+
//#region atomic/rule.ts
|
|
3423
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3424
|
+
const cssProp = getCssPropertyName(property);
|
|
3425
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3426
|
+
const escapedClass = escapeCssIdent(className);
|
|
3427
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3428
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3429
|
+
let selectorStr = classSelector + itemSelector;
|
|
3430
|
+
if (parentSelector) {
|
|
3431
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3432
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3433
|
+
}
|
|
3434
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3435
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3436
|
+
return rule;
|
|
2695
3437
|
}
|
|
2696
|
-
|
|
3438
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3439
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3440
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3441
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3442
|
+
return [
|
|
3443
|
+
priority ?? 0,
|
|
3444
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3445
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3446
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3447
|
+
atRules ? atRules.length : 0,
|
|
3448
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3449
|
+
getPropertyPriority(property)
|
|
3450
|
+
];
|
|
3451
|
+
}
|
|
3452
|
+
function getMediaPriority(atRules, priority) {
|
|
3453
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3454
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3455
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3456
|
+
}
|
|
3457
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3458
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3459
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3460
|
+
return LayerSelectorPriorities.base;
|
|
3461
|
+
}
|
|
3462
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3463
|
+
if (!parentSelector) return 0;
|
|
3464
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3465
|
+
}
|
|
3466
|
+
function getAtRulePriority$1(atRules) {
|
|
3467
|
+
if (!atRules?.length) return 0;
|
|
3468
|
+
let priority = 0;
|
|
3469
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3470
|
+
return priority;
|
|
3471
|
+
}
|
|
3472
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3473
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3474
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3475
|
+
}
|
|
3476
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3477
|
+
const declarations = [];
|
|
3478
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3479
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3480
|
+
}
|
|
3481
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3482
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3483
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3484
|
+
return name + ":" + value;
|
|
3485
|
+
}
|
|
3486
|
+
function normalizeThemeName(value) {
|
|
3487
|
+
if (!value) return null;
|
|
3488
|
+
value = value.trim();
|
|
3489
|
+
if (!value) return null;
|
|
3490
|
+
if (/^\d+$/.test(value)) return null;
|
|
3491
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3492
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3493
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3494
|
+
value = stripGenericThemePrefix(value);
|
|
3495
|
+
if (!value) return null;
|
|
3496
|
+
return value;
|
|
3497
|
+
}
|
|
3498
|
+
function stripGenericThemePrefix(value) {
|
|
3499
|
+
const parts = value.split("--");
|
|
3500
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3501
|
+
value = parts.join("--");
|
|
3502
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3503
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3504
|
+
return value;
|
|
3505
|
+
}
|
|
3506
|
+
function isGeneratedNameHash(value) {
|
|
3507
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3508
|
+
}
|
|
3509
|
+
createNameFormatter(["name"]);
|
|
3510
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
2697
3511
|
//#endregion
|
|
2698
3512
|
//#region style/keyframes.ts
|
|
2699
3513
|
function transformKeyframes(frames, transform) {
|
|
@@ -2721,9 +3535,11 @@ function createStyleFn(args) {
|
|
|
2721
3535
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2722
3536
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2723
3537
|
const fnScope = createScopeBuilder(selectors);
|
|
2724
|
-
const
|
|
2725
|
-
|
|
3538
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3539
|
+
const fnWeight = (value, weight) => {
|
|
3540
|
+
return weightValue(value, weight);
|
|
2726
3541
|
};
|
|
3542
|
+
const fnImportant = (value) => importantValue(value);
|
|
2727
3543
|
const fnRaw = (style) => style;
|
|
2728
3544
|
const fnPlain = (style) => style;
|
|
2729
3545
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2735,11 +3551,13 @@ function createStyleFn(args) {
|
|
|
2735
3551
|
const style = fnStyle;
|
|
2736
3552
|
style.slot = fnSlot;
|
|
2737
3553
|
style.scope = fnScope;
|
|
2738
|
-
style.
|
|
3554
|
+
style.weight = fnWeight;
|
|
3555
|
+
style.important = fnImportant;
|
|
2739
3556
|
style.raw = fnRaw;
|
|
2740
3557
|
style.plain = fnPlain;
|
|
2741
3558
|
style.keyframes = fnKeyframes;
|
|
2742
3559
|
style.merge = fnMerge;
|
|
3560
|
+
style.selector = fnSelector;
|
|
2743
3561
|
assignStyleFnMeta(style, {
|
|
2744
3562
|
mode: "StyleObject",
|
|
2745
3563
|
selectors,
|
|
@@ -2874,65 +3692,6 @@ function isGlobPattern(source) {
|
|
|
2874
3692
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
2875
3693
|
}
|
|
2876
3694
|
//#endregion
|
|
2877
|
-
//#region builder/extract/utils.ts
|
|
2878
|
-
function createExtractedData(type, slotId) {
|
|
2879
|
-
const data = {
|
|
2880
|
-
[BUILDER_TYPE]: type,
|
|
2881
|
-
[BUILDER_STATE]: {
|
|
2882
|
-
items: [],
|
|
2883
|
-
lookup: {}
|
|
2884
|
-
},
|
|
2885
|
-
[BUILDER_CALLSITE]: null
|
|
2886
|
-
};
|
|
2887
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
2888
|
-
return data;
|
|
2889
|
-
}
|
|
2890
|
-
function copyExtractedData(target, source) {
|
|
2891
|
-
const mutable = target;
|
|
2892
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
2893
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
2894
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
2895
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
2896
|
-
}
|
|
2897
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
2898
|
-
return {
|
|
2899
|
-
[BUILDER_TYPE]: 5,
|
|
2900
|
-
[BUILDER_SCOPE]: scope,
|
|
2901
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
2902
|
-
};
|
|
2903
|
-
}
|
|
2904
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
2905
|
-
const normalized = [];
|
|
2906
|
-
let i = 0;
|
|
2907
|
-
while (i < items.length) {
|
|
2908
|
-
const item = items[i];
|
|
2909
|
-
const value = item[2];
|
|
2910
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
2911
|
-
type,
|
|
2912
|
-
item[0],
|
|
2913
|
-
item[1]
|
|
2914
|
-
] : [
|
|
2915
|
-
type,
|
|
2916
|
-
slotId,
|
|
2917
|
-
item[0],
|
|
2918
|
-
item[1]
|
|
2919
|
-
] : slotId === null ? [
|
|
2920
|
-
type,
|
|
2921
|
-
item[0],
|
|
2922
|
-
item[1],
|
|
2923
|
-
value
|
|
2924
|
-
] : [
|
|
2925
|
-
type,
|
|
2926
|
-
slotId,
|
|
2927
|
-
item[0],
|
|
2928
|
-
item[1],
|
|
2929
|
-
value
|
|
2930
|
-
]);
|
|
2931
|
-
i++;
|
|
2932
|
-
}
|
|
2933
|
-
return normalized;
|
|
2934
|
-
}
|
|
2935
|
-
//#endregion
|
|
2936
3695
|
//#region builder/extract/scope.ts
|
|
2937
3696
|
function createExtractedScope(items) {
|
|
2938
3697
|
const scope = ((slot) => {
|
|
@@ -2943,6 +3702,15 @@ function createExtractedScope(items) {
|
|
|
2943
3702
|
return scope;
|
|
2944
3703
|
}
|
|
2945
3704
|
//#endregion
|
|
3705
|
+
//#region builder/extract/sheet.ts
|
|
3706
|
+
function createExtractedSheet(items) {
|
|
3707
|
+
const data = createExtractedData(9);
|
|
3708
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3709
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3710
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3711
|
+
return data;
|
|
3712
|
+
}
|
|
3713
|
+
//#endregion
|
|
2946
3714
|
//#region builder/extract/slot.ts
|
|
2947
3715
|
function createExtractedSlot(slotId, items) {
|
|
2948
3716
|
const slot = ((items) => {
|
|
@@ -3086,7 +3854,7 @@ function exposeStyleObject(source) {
|
|
|
3086
3854
|
return result;
|
|
3087
3855
|
}
|
|
3088
3856
|
function exposeStyleValue(value) {
|
|
3089
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
3857
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3090
3858
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3091
3859
|
const exposed = exposeStyleObject(value);
|
|
3092
3860
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3300,6 +4068,12 @@ function evaluateCall(node, scope) {
|
|
|
3300
4068
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3301
4069
|
return evalOk(createExtractedStyle(items.value));
|
|
3302
4070
|
}
|
|
4071
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4072
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4073
|
+
if (!items.ok) return items;
|
|
4074
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4075
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4076
|
+
}
|
|
3303
4077
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3304
4078
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3305
4079
|
if (!style.ok) return style;
|
|
@@ -3488,13 +4262,18 @@ function evaluateCall(node, scope) {
|
|
|
3488
4262
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3489
4263
|
}));
|
|
3490
4264
|
}
|
|
3491
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4265
|
+
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)) {
|
|
3492
4266
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3493
4267
|
if (!value.ok) return value;
|
|
3494
4268
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3495
4269
|
if (!weight.ok) return weight;
|
|
3496
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3497
|
-
return evalOk(
|
|
4270
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4271
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4272
|
+
}
|
|
4273
|
+
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)) {
|
|
4274
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4275
|
+
if (!value.ok) return value;
|
|
4276
|
+
return evalOk(importantValue(value.value));
|
|
3498
4277
|
}
|
|
3499
4278
|
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);
|
|
3500
4279
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3688,75 +4467,38 @@ function evaluateUnary(node, scope) {
|
|
|
3688
4467
|
const arg = evaluateNode(node.argument, scope);
|
|
3689
4468
|
if (!arg.ok) return arg;
|
|
3690
4469
|
switch (node.operator) {
|
|
3691
|
-
case "-": return evalOk(-arg.value);
|
|
3692
|
-
case "+": return evalOk(+arg.value);
|
|
3693
|
-
case "!": return evalOk(!arg.value);
|
|
3694
|
-
default: return evalFail(`Unsupported unary operator: ${node.operator}`);
|
|
3695
|
-
}
|
|
3696
|
-
}
|
|
3697
|
-
//#endregion
|
|
3698
|
-
//#region compiler/transform/syntax/isStaticStyleValue.ts
|
|
3699
|
-
function isStaticStyleValue(value) {
|
|
3700
|
-
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3701
|
-
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3702
|
-
if (value.type === "ArrayExpression") {
|
|
3703
|
-
const [priority, itemValue] = value.elements;
|
|
3704
|
-
return !!priority && priority.type === "NumericLiteral" && !!itemValue && isStaticStyleValue(itemValue);
|
|
3705
|
-
}
|
|
3706
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "value") {
|
|
3707
|
-
const [itemValue, weight] = value.arguments;
|
|
3708
|
-
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
3709
|
-
}
|
|
3710
|
-
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3711
|
-
return false;
|
|
3712
|
-
}
|
|
3713
|
-
//#endregion
|
|
3714
|
-
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
3715
|
-
function isStyleChainCall(callee, styleNames) {
|
|
3716
|
-
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
3717
|
-
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
3718
|
-
const object = callee.object;
|
|
3719
|
-
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
3720
|
-
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
3721
|
-
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3722
|
-
return false;
|
|
3723
|
-
}
|
|
3724
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3725
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3726
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3727
|
-
}
|
|
3728
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3729
|
-
const declarations = [];
|
|
3730
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3731
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3732
|
-
}
|
|
3733
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3734
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3735
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3736
|
-
return name + ":" + value;
|
|
3737
|
-
}
|
|
3738
|
-
function normalizeThemeName(value) {
|
|
3739
|
-
if (!value) return null;
|
|
3740
|
-
value = value.trim();
|
|
3741
|
-
if (!value) return null;
|
|
3742
|
-
if (/^\d+$/.test(value)) return null;
|
|
3743
|
-
if (isGeneratedNameHash(value)) return null;
|
|
3744
|
-
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3745
|
-
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3746
|
-
value = stripGenericThemePrefix(value);
|
|
3747
|
-
if (!value) return null;
|
|
3748
|
-
return value;
|
|
4470
|
+
case "-": return evalOk(-arg.value);
|
|
4471
|
+
case "+": return evalOk(+arg.value);
|
|
4472
|
+
case "!": return evalOk(!arg.value);
|
|
4473
|
+
default: return evalFail(`Unsupported unary operator: ${node.operator}`);
|
|
4474
|
+
}
|
|
3749
4475
|
}
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
value
|
|
3754
|
-
if (value.
|
|
3755
|
-
if (value.
|
|
3756
|
-
|
|
4476
|
+
//#endregion
|
|
4477
|
+
//#region compiler/transform/syntax/isStaticStyleValue.ts
|
|
4478
|
+
function isStaticStyleValue(value) {
|
|
4479
|
+
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
4480
|
+
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
4481
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
4482
|
+
const [itemValue, weight] = value.arguments;
|
|
4483
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
4484
|
+
}
|
|
4485
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4486
|
+
const [itemValue] = value.arguments;
|
|
4487
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4488
|
+
}
|
|
4489
|
+
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
4490
|
+
return false;
|
|
3757
4491
|
}
|
|
3758
|
-
|
|
3759
|
-
|
|
4492
|
+
//#endregion
|
|
4493
|
+
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
4494
|
+
function isStyleChainCall(callee, styleNames) {
|
|
4495
|
+
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
4496
|
+
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
4497
|
+
const object = callee.object;
|
|
4498
|
+
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
4499
|
+
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
4500
|
+
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
4501
|
+
return false;
|
|
3760
4502
|
}
|
|
3761
4503
|
//#endregion
|
|
3762
4504
|
//#region compiler/transform/syntax/utils.ts
|
|
@@ -3892,60 +4634,6 @@ function sanitizeTokenId(value) {
|
|
|
3892
4634
|
return sanitizeCssIdentName(value, "token");
|
|
3893
4635
|
}
|
|
3894
4636
|
//#endregion
|
|
3895
|
-
//#region compiler/transform/utils/babel.ts
|
|
3896
|
-
function babelPlugin(factory) {
|
|
3897
|
-
return factory;
|
|
3898
|
-
}
|
|
3899
|
-
function babelTransform(args) {
|
|
3900
|
-
let result = null;
|
|
3901
|
-
try {
|
|
3902
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
3903
|
-
result = BabelCore.transformSync(args.code, {
|
|
3904
|
-
...babelTransformOptions(),
|
|
3905
|
-
inputSourceMap,
|
|
3906
|
-
filename: args.filePath,
|
|
3907
|
-
sourceFileName: args.filePath,
|
|
3908
|
-
plugins: args.plugins,
|
|
3909
|
-
sourceMaps: true,
|
|
3910
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
3911
|
-
});
|
|
3912
|
-
} catch (err) {
|
|
3913
|
-
if (!args.errorLabel) throw err;
|
|
3914
|
-
const message = getBabelError(err, args);
|
|
3915
|
-
const error = new Error(message);
|
|
3916
|
-
error.stack = void 0;
|
|
3917
|
-
throw error;
|
|
3918
|
-
}
|
|
3919
|
-
if (!result || !result.code) return null;
|
|
3920
|
-
return {
|
|
3921
|
-
code: result.code,
|
|
3922
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
3923
|
-
};
|
|
3924
|
-
}
|
|
3925
|
-
function babelTransformOptions() {
|
|
3926
|
-
return {
|
|
3927
|
-
configFile: false,
|
|
3928
|
-
babelrc: false,
|
|
3929
|
-
parserOpts: {
|
|
3930
|
-
plugins: ["typescript", "jsx"],
|
|
3931
|
-
strictMode: false,
|
|
3932
|
-
allowImportExportEverywhere: true
|
|
3933
|
-
}
|
|
3934
|
-
};
|
|
3935
|
-
}
|
|
3936
|
-
function parseInputSourceMap(sourcemap) {
|
|
3937
|
-
if (!sourcemap) return void 0;
|
|
3938
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
3939
|
-
return JSON.parse(sourcemap);
|
|
3940
|
-
}
|
|
3941
|
-
function getBabelError(err, args) {
|
|
3942
|
-
const babelErr = err;
|
|
3943
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
3944
|
-
const codeFrame = babelErr?.codeFrame;
|
|
3945
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
3946
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
3947
|
-
}
|
|
3948
|
-
//#endregion
|
|
3949
4637
|
//#region compiler/utils/path.ts
|
|
3950
4638
|
function normalizePath(value) {
|
|
3951
4639
|
return value.replace(/\\/g, "/");
|
|
@@ -4492,6 +5180,7 @@ function getDebugCallLoc(path, state) {
|
|
|
4492
5180
|
}
|
|
4493
5181
|
function getStyleObjectArg(path, state) {
|
|
4494
5182
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5183
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4495
5184
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4496
5185
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4497
5186
|
if (!selector) return path.node.arguments[0];
|
|
@@ -4916,7 +5605,7 @@ function transformDebug(internal, args, deps) {
|
|
|
4916
5605
|
code: args.code,
|
|
4917
5606
|
filePath: args.filePath,
|
|
4918
5607
|
sourcemap: args.sourcemap,
|
|
4919
|
-
plugins: [plugin],
|
|
5608
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
4920
5609
|
retainLines: true
|
|
4921
5610
|
});
|
|
4922
5611
|
if (!result) return null;
|
|
@@ -4985,59 +5674,18 @@ function resolveFilePath(source, fromFile) {
|
|
|
4985
5674
|
}
|
|
4986
5675
|
}
|
|
4987
5676
|
//#endregion
|
|
4988
|
-
//#region
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
4997
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
4998
|
-
}
|
|
4999
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
5000
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
5001
|
-
return rule;
|
|
5002
|
-
}
|
|
5003
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
5004
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
5005
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
5006
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
5007
|
-
return [
|
|
5008
|
-
priority ?? 0,
|
|
5009
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
5010
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
5011
|
-
getMediaPriority(atRules, atRulePriority),
|
|
5012
|
-
atRules ? atRules.length : 0,
|
|
5013
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
5014
|
-
getPropertyPriority(property)
|
|
5015
|
-
];
|
|
5016
|
-
}
|
|
5017
|
-
function getMediaPriority(atRules, priority) {
|
|
5018
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
5019
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
5020
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
5021
|
-
}
|
|
5022
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
5023
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
5024
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
5025
|
-
return LayerSelectorPriorities.base;
|
|
5026
|
-
}
|
|
5027
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
5028
|
-
if (!parentSelector) return 0;
|
|
5029
|
-
return priority > 0 ? priority + 1 : 1;
|
|
5030
|
-
}
|
|
5031
|
-
function getAtRulePriority$1(atRules) {
|
|
5032
|
-
if (!atRules?.length) return 0;
|
|
5033
|
-
let priority = 0;
|
|
5034
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
5035
|
-
return priority;
|
|
5036
|
-
}
|
|
5677
|
+
//#region compiler/compiler/constants.ts
|
|
5678
|
+
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
5679
|
+
CompilerRuntimeMode["Dev"] = "dev";
|
|
5680
|
+
CompilerRuntimeMode["Prod"] = "prod";
|
|
5681
|
+
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
5682
|
+
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
5683
|
+
return CompilerRuntimeMode;
|
|
5684
|
+
}({});
|
|
5037
5685
|
//#endregion
|
|
5038
5686
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
5039
5687
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
5040
|
-
function extractStyleChain(node, styleNames) {
|
|
5688
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5041
5689
|
if (node.type !== "CallExpression") return null;
|
|
5042
5690
|
const callee = node.callee;
|
|
5043
5691
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -5046,6 +5694,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
5046
5694
|
baseArgs: node.arguments,
|
|
5047
5695
|
methods: []
|
|
5048
5696
|
};
|
|
5697
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5698
|
+
kind: "sheet",
|
|
5699
|
+
rootName: callee.name,
|
|
5700
|
+
baseArgs: node.arguments,
|
|
5701
|
+
methods: []
|
|
5702
|
+
};
|
|
5049
5703
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5050
5704
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
5051
5705
|
if (!prop) return null;
|
|
@@ -5063,10 +5717,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
5063
5717
|
baseArgs: node.arguments,
|
|
5064
5718
|
methods: []
|
|
5065
5719
|
};
|
|
5720
|
+
if (prop === "selector") return {
|
|
5721
|
+
kind: "selector",
|
|
5722
|
+
rootName: obj.name,
|
|
5723
|
+
baseArgs: node.arguments,
|
|
5724
|
+
methods: []
|
|
5725
|
+
};
|
|
5066
5726
|
if (prop !== "merge") return null;
|
|
5067
5727
|
const target = node.arguments[0];
|
|
5068
5728
|
if (!target) return null;
|
|
5069
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5729
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
5070
5730
|
if (!targetChain) return null;
|
|
5071
5731
|
return {
|
|
5072
5732
|
...targetChain,
|
|
@@ -5078,7 +5738,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
5078
5738
|
};
|
|
5079
5739
|
}
|
|
5080
5740
|
if (obj.type === "CallExpression") {
|
|
5081
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5741
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
5082
5742
|
if (!inner) return null;
|
|
5083
5743
|
return {
|
|
5084
5744
|
...inner,
|
|
@@ -5102,18 +5762,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
5102
5762
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5103
5763
|
let result = null;
|
|
5104
5764
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5105
|
-
const
|
|
5765
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5766
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
5106
5767
|
if (!runtimeValue) continue;
|
|
5107
5768
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5108
5769
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5109
5770
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
5110
|
-
|
|
5771
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5772
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
5111
5773
|
}
|
|
5112
5774
|
return result ?? styleObj;
|
|
5113
5775
|
}
|
|
5114
|
-
function getPriorityTupleValue(value) {
|
|
5115
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5116
|
-
}
|
|
5117
5776
|
function cloneCompiledStyleObject(styleObj) {
|
|
5118
5777
|
const cloned = { ...styleObj };
|
|
5119
5778
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5196,6 +5855,8 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5196
5855
|
*/
|
|
5197
5856
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5198
5857
|
const css = getCssConfig(opts, runtimeMode);
|
|
5858
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5859
|
+
if (!meta) return null;
|
|
5199
5860
|
if (meta.mode === "ClassName") {
|
|
5200
5861
|
if (chain.kind !== "style") return null;
|
|
5201
5862
|
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
@@ -5207,11 +5868,91 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5207
5868
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5208
5869
|
return null;
|
|
5209
5870
|
}
|
|
5871
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5872
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5873
|
+
const items = [];
|
|
5874
|
+
const rules = [];
|
|
5875
|
+
const sheetItems = chain.baseArgs[0];
|
|
5876
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5877
|
+
return {
|
|
5878
|
+
type: "sheet",
|
|
5879
|
+
items,
|
|
5880
|
+
rules
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5884
|
+
if (node.type === "ArrayExpression") {
|
|
5885
|
+
for (const element of node.elements) {
|
|
5886
|
+
if (!element) continue;
|
|
5887
|
+
if (element.type === "SpreadElement") return false;
|
|
5888
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
5889
|
+
}
|
|
5890
|
+
return true;
|
|
5891
|
+
}
|
|
5892
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
5893
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
5894
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
5895
|
+
return true;
|
|
5896
|
+
}
|
|
5897
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
5898
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
5899
|
+
const item = tokenOverride.value[i];
|
|
5900
|
+
if (!item) continue;
|
|
5901
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
5902
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
5903
|
+
}
|
|
5904
|
+
return true;
|
|
5905
|
+
}
|
|
5906
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
5907
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
5908
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
5909
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
5910
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
5911
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
5912
|
+
}
|
|
5913
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
5914
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
5915
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5916
|
+
if (!selectorArg.ok) return false;
|
|
5917
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
5918
|
+
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;
|
|
5919
|
+
return true;
|
|
5920
|
+
}
|
|
5921
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
5922
|
+
if (chain.baseArgs[1]) {
|
|
5923
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
5924
|
+
}
|
|
5925
|
+
let i = 0;
|
|
5926
|
+
while (i < chain.methods.length) {
|
|
5927
|
+
const method = chain.methods[i];
|
|
5928
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
5929
|
+
i++;
|
|
5930
|
+
}
|
|
5931
|
+
return true;
|
|
5932
|
+
}
|
|
5933
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
5934
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5935
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5936
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5937
|
+
if (styleArgNode.type === "CallExpression") {
|
|
5938
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5939
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5940
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5941
|
+
}
|
|
5942
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5943
|
+
if (!styleArg.ok) {
|
|
5944
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
5945
|
+
return false;
|
|
5946
|
+
}
|
|
5947
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5948
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5949
|
+
}
|
|
5210
5950
|
function getCssConfig(opts, runtimeMode) {
|
|
5211
5951
|
const css = opts.css;
|
|
5212
5952
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
5213
5953
|
return {
|
|
5214
5954
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5955
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5215
5956
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5216
5957
|
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
5217
5958
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
@@ -5338,15 +6079,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5338
6079
|
result[property] = value;
|
|
5339
6080
|
continue;
|
|
5340
6081
|
}
|
|
5341
|
-
|
|
5342
|
-
const rawValue = value[1];
|
|
5343
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5344
|
-
continue;
|
|
5345
|
-
}
|
|
5346
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6082
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5347
6083
|
}
|
|
5348
6084
|
return result;
|
|
5349
6085
|
}
|
|
6086
|
+
function decorateClassNameValue(value, className) {
|
|
6087
|
+
if (isClassNameValue(value)) return value;
|
|
6088
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6089
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6090
|
+
return classNameValue(value, className);
|
|
6091
|
+
}
|
|
5350
6092
|
function isWeightedClassName(value) {
|
|
5351
6093
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5352
6094
|
}
|
|
@@ -5357,23 +6099,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5357
6099
|
weighted[property] = value;
|
|
5358
6100
|
continue;
|
|
5359
6101
|
}
|
|
5360
|
-
weighted[property] =
|
|
6102
|
+
weighted[property] = weightValue(value, weight);
|
|
5361
6103
|
}
|
|
5362
6104
|
return weighted;
|
|
5363
6105
|
}
|
|
5364
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6106
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5365
6107
|
if (chain.baseArgs.length > 0) {
|
|
5366
6108
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5367
6109
|
if (!styleArg.ok) {
|
|
5368
6110
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5369
6111
|
return false;
|
|
5370
6112
|
}
|
|
5371
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6113
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5372
6114
|
}
|
|
5373
6115
|
let i = 0;
|
|
5374
6116
|
while (i < chain.methods.length) {
|
|
5375
6117
|
const method = chain.methods[i];
|
|
5376
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6118
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5377
6119
|
i++;
|
|
5378
6120
|
}
|
|
5379
6121
|
return true;
|
|
@@ -5420,7 +6162,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5420
6162
|
rules
|
|
5421
6163
|
};
|
|
5422
6164
|
}
|
|
5423
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6165
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5424
6166
|
const selector = selectors[method.name];
|
|
5425
6167
|
if (!selector) return false;
|
|
5426
6168
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5693,10 +6435,10 @@ function getSlotIdFromValue(value) {
|
|
|
5693
6435
|
const slotId = value.slotId;
|
|
5694
6436
|
return typeof slotId === "string" ? slotId : null;
|
|
5695
6437
|
}
|
|
5696
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6438
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5697
6439
|
if (method.name === "$$style.merge") {
|
|
5698
6440
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5699
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6441
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5700
6442
|
}
|
|
5701
6443
|
const selector = selectors[method.name];
|
|
5702
6444
|
if (!selector) return false;
|
|
@@ -5704,42 +6446,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5704
6446
|
const selectorStr = selector.selector.trim();
|
|
5705
6447
|
if (selectorStr === "...") {
|
|
5706
6448
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5707
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6449
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5708
6450
|
}
|
|
5709
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5710
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6451
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6452
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5711
6453
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6454
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5712
6455
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5713
6456
|
if (!styleArg.ok) {
|
|
5714
6457
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5715
6458
|
return false;
|
|
5716
6459
|
}
|
|
5717
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6460
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5718
6461
|
}
|
|
5719
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6462
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5720
6463
|
if (!styleArgNode) return false;
|
|
5721
6464
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5722
6465
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5723
6466
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5724
|
-
if (
|
|
6467
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5725
6468
|
if (styleArgNode.type === "CallExpression") {
|
|
5726
6469
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5727
6470
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5728
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6471
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5729
6472
|
}
|
|
5730
6473
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5731
6474
|
if (!styleArg.ok) {
|
|
5732
6475
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5733
6476
|
return false;
|
|
5734
6477
|
}
|
|
5735
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5736
|
-
return addStyleDataItems(styleArg.value,
|
|
6478
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6479
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5737
6480
|
}
|
|
5738
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6481
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5739
6482
|
if (node.type !== "Identifier") return null;
|
|
5740
6483
|
const init = scope.bindingNodes?.get(node.name);
|
|
5741
6484
|
if (!init) return null;
|
|
5742
|
-
return extractStyleChain(init, styleNames);
|
|
6485
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6486
|
+
}
|
|
6487
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6488
|
+
const callee = node.callee;
|
|
6489
|
+
if (callee.type === "Identifier") {
|
|
6490
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6491
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6492
|
+
return {
|
|
6493
|
+
...target,
|
|
6494
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6495
|
+
};
|
|
6496
|
+
}
|
|
6497
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6498
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6499
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6500
|
+
...memberTarget,
|
|
6501
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6502
|
+
};
|
|
6503
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6504
|
+
if (!methodName) return null;
|
|
6505
|
+
const object = callee.object;
|
|
6506
|
+
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;
|
|
6507
|
+
if (target?.kind !== "selector") return null;
|
|
6508
|
+
return {
|
|
6509
|
+
...target,
|
|
6510
|
+
methods: [...target.methods, {
|
|
6511
|
+
name: methodName,
|
|
6512
|
+
args: node.arguments,
|
|
6513
|
+
nameNode: callee.property
|
|
6514
|
+
}]
|
|
6515
|
+
};
|
|
6516
|
+
}
|
|
6517
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6518
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6519
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6520
|
+
if (!propertyName) return null;
|
|
6521
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6522
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6523
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6524
|
+
const property = objectInit.properties[i];
|
|
6525
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6526
|
+
const key = property.key;
|
|
6527
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6528
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6529
|
+
}
|
|
6530
|
+
return null;
|
|
6531
|
+
}
|
|
6532
|
+
function isBareSelectorTargetChain(chain) {
|
|
6533
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5743
6534
|
}
|
|
5744
6535
|
function getLocalBindingNode(node, scope) {
|
|
5745
6536
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5767,7 +6558,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5767
6558
|
default: return false;
|
|
5768
6559
|
}
|
|
5769
6560
|
}
|
|
5770
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6561
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5771
6562
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5772
6563
|
const hasArg = selectorStr.includes("$$");
|
|
5773
6564
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5789,22 +6580,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5789
6580
|
if (styleArg.type === "CallExpression") {
|
|
5790
6581
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5791
6582
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5792
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6583
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5793
6584
|
const evaled = evaluateNode(styleArg, scope);
|
|
5794
6585
|
if (!evaled.ok) {
|
|
5795
6586
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5796
6587
|
return false;
|
|
5797
6588
|
}
|
|
5798
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6589
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5799
6590
|
}
|
|
5800
6591
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5801
6592
|
if (!styleResult.ok) {
|
|
5802
6593
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5803
6594
|
return false;
|
|
5804
6595
|
}
|
|
5805
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6596
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5806
6597
|
}
|
|
5807
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6598
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5808
6599
|
const selectorStr = selector.selector.trim();
|
|
5809
6600
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5810
6601
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5826,7 +6617,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5826
6617
|
while (i < selectorValues.length) {
|
|
5827
6618
|
const itemSelectorValue = selectorValues[i];
|
|
5828
6619
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5829
|
-
|
|
6620
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6621
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5830
6622
|
i++;
|
|
5831
6623
|
}
|
|
5832
6624
|
return true;
|
|
@@ -5895,6 +6687,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
5895
6687
|
dedupe: overrideItem.dedupe,
|
|
5896
6688
|
className: overrideItem.className,
|
|
5897
6689
|
property: overrideItem.property,
|
|
6690
|
+
weight: overrideItem.weight,
|
|
6691
|
+
important: overrideItem.important,
|
|
5898
6692
|
value: overrideItem.value,
|
|
5899
6693
|
variable: overrideItem.variable,
|
|
5900
6694
|
token: overrideItem.token,
|
|
@@ -5938,22 +6732,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
5938
6732
|
items.push(item);
|
|
5939
6733
|
}
|
|
5940
6734
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5941
|
-
|
|
6735
|
+
const weight = sourceItem.weight;
|
|
6736
|
+
let important = false;
|
|
5942
6737
|
let value = sourceItem.value;
|
|
5943
|
-
|
|
5944
|
-
priority = value[1];
|
|
5945
|
-
value = value[0];
|
|
5946
|
-
}
|
|
6738
|
+
important = sourceItem.important;
|
|
5947
6739
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
5948
6740
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
5949
6741
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5950
6742
|
const valueStr = String(value ?? "");
|
|
5951
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
5952
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6743
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6744
|
+
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);
|
|
5953
6745
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5954
6746
|
items.push(item);
|
|
5955
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
5956
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6747
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6748
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
5957
6749
|
cssRules.push({
|
|
5958
6750
|
dedupe,
|
|
5959
6751
|
className,
|
|
@@ -6016,21 +6808,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
6016
6808
|
items.push(item);
|
|
6017
6809
|
}
|
|
6018
6810
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6019
|
-
|
|
6811
|
+
const weight = sourceItem.weight;
|
|
6812
|
+
const important = sourceItem.important;
|
|
6020
6813
|
let value = sourceItem.value;
|
|
6021
|
-
|
|
6022
|
-
priority = value[1];
|
|
6023
|
-
value = value[0];
|
|
6024
|
-
}
|
|
6025
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6814
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
6026
6815
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6027
6816
|
const variable = sourceItem.variable;
|
|
6028
6817
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
6029
6818
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
6030
6819
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
6031
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6820
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
6032
6821
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6033
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6822
|
+
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);
|
|
6034
6823
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6035
6824
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
6036
6825
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -6038,8 +6827,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6038
6827
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
6039
6828
|
}
|
|
6040
6829
|
items.push(item);
|
|
6041
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6042
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6830
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6831
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
6043
6832
|
cssRules.push({
|
|
6044
6833
|
dedupe,
|
|
6045
6834
|
className,
|
|
@@ -6052,6 +6841,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6052
6841
|
} : void 0
|
|
6053
6842
|
});
|
|
6054
6843
|
}
|
|
6844
|
+
function combineSelectors(parent, child) {
|
|
6845
|
+
const parentText = getItemSelectorText(parent);
|
|
6846
|
+
const childText = getItemSelectorText(child);
|
|
6847
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6848
|
+
const selector = parentText + childText;
|
|
6849
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6850
|
+
}
|
|
6851
|
+
function getItemSelectorText(selector) {
|
|
6852
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6853
|
+
}
|
|
6854
|
+
function getItemSelectorPriority(selector) {
|
|
6855
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6856
|
+
}
|
|
6055
6857
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
6056
6858
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
6057
6859
|
if (!trace) return void 0;
|
|
@@ -6096,13 +6898,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6096
6898
|
while (i < keys.length) {
|
|
6097
6899
|
const property = keys[i];
|
|
6098
6900
|
const rawValue = styleObj[property];
|
|
6099
|
-
let
|
|
6901
|
+
let weight = null;
|
|
6902
|
+
let important = false;
|
|
6100
6903
|
let value = rawValue;
|
|
6101
6904
|
let transformClassName = null;
|
|
6102
|
-
|
|
6103
|
-
priority = rawValue[0];
|
|
6104
|
-
value = rawValue[1];
|
|
6105
|
-
}
|
|
6905
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
6106
6906
|
if (isClassNameValue(value)) {
|
|
6107
6907
|
transformClassName = value.className;
|
|
6108
6908
|
value = value.value;
|
|
@@ -6125,8 +6925,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6125
6925
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
6126
6926
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6127
6927
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
6128
|
-
const dedupe = getClassNameDedupe(property,
|
|
6129
|
-
const className = getAtomicClassName(property,
|
|
6928
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
6929
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6130
6930
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6131
6931
|
item.sourceTrace = propertyCallsite ? {
|
|
6132
6932
|
property,
|
|
@@ -6151,8 +6951,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6151
6951
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6152
6952
|
}
|
|
6153
6953
|
items.push(item);
|
|
6154
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6155
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
6954
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6955
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6156
6956
|
cssRules.push({
|
|
6157
6957
|
dedupe,
|
|
6158
6958
|
className,
|
|
@@ -6180,6 +6980,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6180
6980
|
}
|
|
6181
6981
|
return true;
|
|
6182
6982
|
}
|
|
6983
|
+
function unwrapStaticStyleValue(value) {
|
|
6984
|
+
let weight = null;
|
|
6985
|
+
let important = false;
|
|
6986
|
+
while (true) {
|
|
6987
|
+
if (isStyleImportantValue(value)) {
|
|
6988
|
+
important = true;
|
|
6989
|
+
value = value.value;
|
|
6990
|
+
continue;
|
|
6991
|
+
}
|
|
6992
|
+
if (isStyleWeightValue(value)) {
|
|
6993
|
+
weight = value.weight;
|
|
6994
|
+
value = value.value;
|
|
6995
|
+
continue;
|
|
6996
|
+
}
|
|
6997
|
+
break;
|
|
6998
|
+
}
|
|
6999
|
+
return [
|
|
7000
|
+
value,
|
|
7001
|
+
weight,
|
|
7002
|
+
important
|
|
7003
|
+
];
|
|
7004
|
+
}
|
|
6183
7005
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6184
7006
|
if (result.ok) return;
|
|
6185
7007
|
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);
|
|
@@ -6315,6 +7137,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6315
7137
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6316
7138
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6317
7139
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7140
|
+
const staticIdState = {
|
|
7141
|
+
fileId,
|
|
7142
|
+
imports,
|
|
7143
|
+
styleNames
|
|
7144
|
+
};
|
|
7145
|
+
const t = babel.types;
|
|
6318
7146
|
for (const stmt of ast.program.body) {
|
|
6319
7147
|
if (stmt.type === "ImportDeclaration") {
|
|
6320
7148
|
const source = stmt.source.value;
|
|
@@ -6339,6 +7167,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6339
7167
|
continue;
|
|
6340
7168
|
}
|
|
6341
7169
|
if (stmt.type === "VariableDeclaration") {
|
|
7170
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6342
7171
|
collectVariableBindings(rawBindings, stmt);
|
|
6343
7172
|
continue;
|
|
6344
7173
|
}
|
|
@@ -6362,6 +7191,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6362
7191
|
continue;
|
|
6363
7192
|
}
|
|
6364
7193
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7194
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6365
7195
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6366
7196
|
continue;
|
|
6367
7197
|
}
|
|
@@ -6401,6 +7231,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6401
7231
|
});
|
|
6402
7232
|
return bindings;
|
|
6403
7233
|
}
|
|
7234
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7235
|
+
for (const decl of declaration.declarations) {
|
|
7236
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7237
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7238
|
+
}
|
|
7239
|
+
}
|
|
6404
7240
|
function collectVariableBindings(bindings, declaration) {
|
|
6405
7241
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6406
7242
|
}
|
|
@@ -6480,6 +7316,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6480
7316
|
defineCompiledStyleLocations(style, traceResult);
|
|
6481
7317
|
return style;
|
|
6482
7318
|
}
|
|
7319
|
+
if (result.type === "sheet") {
|
|
7320
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7321
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7322
|
+
return sheet;
|
|
7323
|
+
}
|
|
6483
7324
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6484
7325
|
return null;
|
|
6485
7326
|
}
|
|
@@ -6590,6 +7431,12 @@ function hashFileContent(filePath) {
|
|
|
6590
7431
|
function getStyleRuntimeImportPath(mode) {
|
|
6591
7432
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6592
7433
|
}
|
|
7434
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7435
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7436
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7437
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7438
|
+
return null;
|
|
7439
|
+
}
|
|
6593
7440
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6594
7441
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6595
7442
|
}
|
|
@@ -6682,6 +7529,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6682
7529
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6683
7530
|
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)]);
|
|
6684
7531
|
}
|
|
7532
|
+
if (chain.type === "sheet") {
|
|
7533
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7534
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7535
|
+
}
|
|
6685
7536
|
if (chain.type === "slot") {
|
|
6686
7537
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6687
7538
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6720,7 +7571,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6720
7571
|
chain.items.forEach((item) => {
|
|
6721
7572
|
if (isCompiledTokenItem(item)) {
|
|
6722
7573
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6723
|
-
else itemExpressions.push(t
|
|
7574
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6724
7575
|
return;
|
|
6725
7576
|
}
|
|
6726
7577
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6819,6 +7670,18 @@ function buildExtractedTokenExpression(t, token, state) {
|
|
|
6819
7670
|
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6820
7671
|
]);
|
|
6821
7672
|
}
|
|
7673
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7674
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7675
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7676
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7677
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7678
|
+
t.nullLiteral(),
|
|
7679
|
+
t.nullLiteral(),
|
|
7680
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7681
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7682
|
+
]);
|
|
7683
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
7684
|
+
}
|
|
6822
7685
|
function literalExpression(t, value) {
|
|
6823
7686
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
6824
7687
|
if (typeof value === "number") return t.numericLiteral(value);
|
|
@@ -6940,6 +7803,7 @@ function getEvalScope(state) {
|
|
|
6940
7803
|
styleFilePath: state.styleFilePath,
|
|
6941
7804
|
sourcemapTrace: state.sourcemapTrace,
|
|
6942
7805
|
styleNames: state.styleNames,
|
|
7806
|
+
sheetNames: state.sheetNames,
|
|
6943
7807
|
styleMetas: state.styleMetas,
|
|
6944
7808
|
bindingNodes: state.bindingNodes,
|
|
6945
7809
|
runtimeMode: state.runtimeMode
|
|
@@ -6997,6 +7861,7 @@ function createExtractPlugin(args) {
|
|
|
6997
7861
|
return {
|
|
6998
7862
|
pre() {
|
|
6999
7863
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
7864
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
7000
7865
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
7001
7866
|
this.bindings = /* @__PURE__ */ new Map();
|
|
7002
7867
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -7043,6 +7908,7 @@ function createExtractPlugin(args) {
|
|
|
7043
7908
|
state.styleNames.add(spec.local.name);
|
|
7044
7909
|
state.styleMetas.set(spec.local.name, meta);
|
|
7045
7910
|
}
|
|
7911
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
7046
7912
|
});
|
|
7047
7913
|
},
|
|
7048
7914
|
VariableDeclaration(path, state) {
|
|
@@ -7089,17 +7955,17 @@ function createExtractPlugin(args) {
|
|
|
7089
7955
|
state.needsExtractImport = true;
|
|
7090
7956
|
return;
|
|
7091
7957
|
}
|
|
7092
|
-
if (!state.styleNames.size) return;
|
|
7093
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
7958
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
7959
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
7094
7960
|
if (!chain) return;
|
|
7095
7961
|
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.");
|
|
7096
7962
|
const scope = getEvalScope(state);
|
|
7097
7963
|
const loc = path.node.loc?.start;
|
|
7098
7964
|
const meta = state.styleMetas.get(chain.rootName);
|
|
7099
|
-
if (!meta) return;
|
|
7965
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
7100
7966
|
let result;
|
|
7101
7967
|
try {
|
|
7102
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
7968
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
7103
7969
|
} catch (error) {
|
|
7104
7970
|
const message = error instanceof Error ? error.message : String(error);
|
|
7105
7971
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7353,7 +8219,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7353
8219
|
code: args.code,
|
|
7354
8220
|
filePath: args.filePath,
|
|
7355
8221
|
sourcemap: args.sourcemap,
|
|
7356
|
-
plugins: [plugin],
|
|
8222
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7357
8223
|
errorLabel: "[style] compiler error"
|
|
7358
8224
|
});
|
|
7359
8225
|
if (!result) return null;
|
|
@@ -7395,13 +8261,6 @@ function createPlugin(rewriteSource) {
|
|
|
7395
8261
|
}
|
|
7396
8262
|
//#endregion
|
|
7397
8263
|
//#region compiler/compiler/compiler.ts
|
|
7398
|
-
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
7399
|
-
CompilerRuntimeMode["Dev"] = "dev";
|
|
7400
|
-
CompilerRuntimeMode["Prod"] = "prod";
|
|
7401
|
-
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
7402
|
-
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
7403
|
-
return CompilerRuntimeMode;
|
|
7404
|
-
}({});
|
|
7405
8264
|
function createCompiler(args, options) {
|
|
7406
8265
|
const internal = createCompilerInternal(args, options);
|
|
7407
8266
|
const tracer = createTracer(internal);
|
|
@@ -7481,12 +8340,34 @@ function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
|
7481
8340
|
}
|
|
7482
8341
|
function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
7483
8342
|
if (source === "@fluentic/style") return getStyleRuntimeImportPath(runtimeMode);
|
|
8343
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
|
|
8344
|
+
if (adapterImportPath) return adapterImportPath;
|
|
7484
8345
|
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(runtimeMode);
|
|
7485
8346
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7486
8347
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7487
8348
|
return null;
|
|
7488
8349
|
}
|
|
8350
|
+
const CssPropPresets = {
|
|
8351
|
+
Solid: {
|
|
8352
|
+
classProp: "class",
|
|
8353
|
+
styleProp: "style",
|
|
8354
|
+
styleMode: "solid",
|
|
8355
|
+
adapter: "@fluentic/style/adapter/solid"
|
|
8356
|
+
},
|
|
8357
|
+
Preact: {
|
|
8358
|
+
classProp: "class",
|
|
8359
|
+
styleProp: "style",
|
|
8360
|
+
styleMode: "react",
|
|
8361
|
+
adapter: "@fluentic/style/adapter/preact"
|
|
8362
|
+
},
|
|
8363
|
+
React: {
|
|
8364
|
+
classProp: "className",
|
|
8365
|
+
styleProp: "style",
|
|
8366
|
+
styleMode: "react",
|
|
8367
|
+
adapter: "@fluentic/style/adapter/react"
|
|
8368
|
+
}
|
|
8369
|
+
};
|
|
7489
8370
|
//#endregion
|
|
7490
|
-
export {
|
|
8371
|
+
export { getDefaultSourcemapUrl as a, isPromiseLike as c, extractCss as d, compareLayerPriority as f, createCompilerCache as h, CompilerRuntimeMode as i, babelPlugin as l, globalData as m, createCompiler as n, normalizeSourcemapSourcePath as o, SIDECAR_URL_GLOBAL_SYMBOL as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelTransform as u };
|
|
7491
8372
|
|
|
7492
|
-
//# sourceMappingURL=compiler-
|
|
8373
|
+
//# sourceMappingURL=compiler-OgDBuqfs.mjs.map
|