@fluentic/style 0.1.0-beta.4 → 0.1.0-beta.6
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 +56 -1
- package/README.md +106 -31
- package/atomic/className.ts +29 -6
- package/atomic/debug/className/className.ts +10 -0
- package/atomic/rule.ts +6 -3
- package/atomic/utils/hash.ts +1 -65
- 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 +88 -14
- 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 +21 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +6 -0
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +33 -4
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +660 -73
- 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/import_source.ts +17 -7
- 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-D0AXSTn-.js +1279 -0
- package/dist/combine-D0AXSTn-.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-CE0ZgkdH.mjs → compiler-CCvRlaq0.mjs} +1467 -534
- package/dist/compiler-CCvRlaq0.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-B-w6rOe0.js +35 -0
- package/dist/config-B-w6rOe0.js.map +1 -0
- package/dist/{config-lJNLh7eM.js → config-B1WtpYar.js} +2 -2
- package/dist/{config-lJNLh7eM.js.map → config-B1WtpYar.js.map} +1 -1
- package/dist/{config-CduqubI8.js → config-CCMwA9Gm.js} +3 -3
- package/dist/config-CCMwA9Gm.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/createTransformElement-PCilcudP.js +34 -0
- package/dist/createTransformElement-PCilcudP.js.map +1 -0
- package/dist/css-DirG7Jwu.js +1280 -0
- package/dist/css-DirG7Jwu.js.map +1 -0
- package/dist/css-GtUPEO9U.js.map +1 -1
- package/dist/css-nmclCl2P.js +479 -0
- package/dist/css-nmclCl2P.js.map +1 -0
- package/dist/css-shX7_73D.js +3894 -0
- package/dist/css-shX7_73D.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{data-D7NFt4JG.js → data-DUvixly5.js} +155 -61
- package/dist/data-DUvixly5.js.map +1 -0
- package/dist/{debug-Cvpo5cVu.js → debug-DJRCBKhM.js} +80 -5
- package/dist/debug-DJRCBKhM.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-Cwha8aAp.js} +4 -4
- package/dist/{dev-DdRWa6dJ.js.map → dev-Cwha8aAp.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-Cb46vtLU.js} +94 -8
- package/dist/elementMarker-Cb46vtLU.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 +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +5 -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-0Gu2Jh47.js} +1148 -162
- package/dist/env-0Gu2Jh47.js.map +1 -0
- package/dist/getClassName-CHZKhmde.js +45 -0
- package/dist/getClassName-CHZKhmde.js.map +1 -0
- package/dist/{utils-B_VhPBHH.js → getClassName-CHd0iCXp.js} +28 -65
- package/dist/getClassName-CHd0iCXp.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-Dg37z0lV.js +14 -0
- package/dist/global-Dg37z0lV.js.map +1 -0
- package/dist/{hash-BfeJDf5U.js → hash-Cr-LCWDt.js} +35 -38
- package/dist/hash-Cr-LCWDt.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-BMFC8_tA.js +39 -0
- package/dist/jsx-BMFC8_tA.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-Ch1pZ6-n.js} +2 -2
- package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
- package/dist/{loader-BmYS_Rju.mjs → loader-hNaefW-U.mjs} +13 -14
- package/dist/loader-hNaefW-U.mjs.map +1 -0
- package/dist/{misc-BIS_c7BJ.mjs → misc-1OS0aeY1.mjs} +4 -4
- package/dist/misc-1OS0aeY1.mjs.map +1 -0
- package/dist/{namedTokens-CN_yhhik.js → namedTokens-mgRfd9hs.js} +3 -3
- package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-mgRfd9hs.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 +121 -17
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +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 +26 -5
- 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-OA0niXJL.mjs} +2 -2
- package/dist/{registry-IaXmLQzA.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-BKXT1bmR.js +63 -0
- package/dist/resolveClassNameRuntime-BKXT1bmR.js.map +1 -0
- package/dist/{rules-CxVzovt-.js → rules-DgcCENkw.js} +583 -154
- package/dist/rules-DgcCENkw.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-Bc9RwNNj.cjs} +1473 -535
- package/dist/shared-Bc9RwNNj.cjs.map +1 -0
- package/dist/{shared-DdPTZ0O3.mjs → shared-COiLPdZ1.mjs} +4 -4
- package/dist/{shared-DdPTZ0O3.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
- package/dist/sheet-B87QCFWF.js +7 -0
- package/dist/{sheet-BWBzuy4D.js.map → sheet-B87QCFWF.js.map} +1 -1
- package/dist/{sidecar-B3oCK9vC.mjs → sidecar-ViZUL9B8.mjs} +3 -3
- package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
- package/dist/{styleStore-0fARJlZV.js → styleStore-BlC8Ax9f.js} +3 -4
- package/dist/{styleStore-0fARJlZV.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
- package/dist/styleStore-DHzH25A7.js +51 -0
- package/dist/styleStore-DHzH25A7.js.map +1 -0
- package/dist/{token-D-S-4_mN.js → token-CAQWMtan.js} +2 -2
- package/dist/{token-D-S-4_mN.js.map → token-CAQWMtan.js.map} +1 -1
- package/dist/{trace-CFnhyCVf.js → trace-D3yBmJad.js} +2 -2
- package/dist/{trace-CFnhyCVf.js.map → trace-D3yBmJad.js.map} +1 -1
- package/dist/{trace-ZtgeY-8s.js → trace-DdXWjgAD.js} +3 -3
- package/dist/{trace-ZtgeY-8s.js.map → trace-DdXWjgAD.js.map} +1 -1
- package/dist/{style-CGaJndOl.js → types-BhdAXX7z.js} +268 -89
- package/dist/types-BhdAXX7z.js.map +1 -0
- package/dist/utils-B6HVRX10.js +42 -0
- package/dist/utils-B6HVRX10.js.map +1 -0
- package/dist/{utils-B5Xqf1lV.mjs → utils-C7UalRKf.mjs} +41 -7
- package/dist/utils-C7UalRKf.mjs.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DzydRwYo.js → utils-Cd4wqN56.js} +142 -149
- package/dist/utils-Cd4wqN56.js.map +1 -0
- package/dist/{utils-DaAiEEIG.mjs → utils-DjxH0zc7.mjs} +3 -3
- package/dist/{utils-DaAiEEIG.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.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-6et2ZVI6.mjs} +5 -5
- package/dist/webpack-6et2ZVI6.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 +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -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 +98 -22
- 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/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +208 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +50 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/classname/transform.ts +32 -1
- package/runtime/adapter/utils.ts +120 -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/css_extra-DYtS3g6Z.js +0 -8
- package/dist/css_extra-DYtS3g6Z.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/global-CZBlA9E7.js.map +0 -1
- 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 +0 -39
- 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/loader-BmYS_Rju.mjs.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-B5Xqf1lV.mjs.map +0 -1
- package/dist/utils-B_VhPBHH.js.map +0 -1
- package/dist/utils-CDUaX81o.js +0 -170
- package/dist/utils-CDUaX81o.js.map +0 -1
- package/dist/utils-DzydRwYo.js.map +0 -1
- package/dist/value-C0JRsyax.js +0 -64
- package/dist/value-C0JRsyax.js.map +0 -1
- package/dist/value-D08AocUs.js +0 -1053
- package/dist/value-D08AocUs.js.map +0 -1
- package/dist/valueRef-M3E1oza7.js +0 -16
- package/dist/valueRef-M3E1oza7.js.map +0 -1
- package/dist/webpack-CHydnRXB.mjs.map +0 -1
- package/dist/withTokens-DAzUIPvA.js +0 -95
- package/dist/withTokens-DAzUIPvA.js.map +0 -1
|
@@ -26,11 +26,11 @@ let node_fs = require("node:fs");
|
|
|
26
26
|
node_fs = __toESM(node_fs, 1);
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
+
let _babel_core = require("@babel/core");
|
|
30
|
+
_babel_core = __toESM(_babel_core, 1);
|
|
29
31
|
let picomatch = require("picomatch");
|
|
30
32
|
picomatch = __toESM(picomatch, 1);
|
|
31
33
|
let css_what = require("css-what");
|
|
32
|
-
let _babel_core = require("@babel/core");
|
|
33
|
-
_babel_core = __toESM(_babel_core, 1);
|
|
34
34
|
let oxc_resolver = require("oxc-resolver");
|
|
35
35
|
require("@parcel/plugin");
|
|
36
36
|
let node_http = require("node:http");
|
|
@@ -64,6 +64,7 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
64
64
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region config/utils.ts
|
|
67
|
+
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
67
68
|
function getCacheTTL(cache) {
|
|
68
69
|
return cache === true ? 3e5 : cache === false ? 0 : Math.max(cache, 0);
|
|
69
70
|
}
|
|
@@ -77,7 +78,7 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
77
78
|
isRSC: false,
|
|
78
79
|
runtimeCacheTTL: getCacheTTL(true)
|
|
79
80
|
};
|
|
80
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
81
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
81
82
|
globalData("config.build", () => ({ current: null }));
|
|
82
83
|
//#endregion
|
|
83
84
|
//#region config/config/debug.ts
|
|
@@ -110,8 +111,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
110
111
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
111
112
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
112
113
|
}
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region atomic/layer/types.ts
|
|
115
114
|
const LayerDefaultPriority = [
|
|
116
115
|
0,
|
|
117
116
|
0,
|
|
@@ -200,6 +199,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
200
199
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
201
200
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
202
201
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
202
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
203
203
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
204
204
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
205
205
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -426,6 +426,145 @@ function getCacheKey(args) {
|
|
|
426
426
|
return node_crypto.createHash("md5").update(args.cacheType).update("\0").update(node_path.resolve(args.filePath)).digest("hex");
|
|
427
427
|
}
|
|
428
428
|
//#endregion
|
|
429
|
+
//#region compiler/transform/utils/babel.ts
|
|
430
|
+
function babelPlugin(factory) {
|
|
431
|
+
return factory;
|
|
432
|
+
}
|
|
433
|
+
function babelTransform(args) {
|
|
434
|
+
let result = null;
|
|
435
|
+
try {
|
|
436
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
437
|
+
result = _babel_core.transformSync(args.code, {
|
|
438
|
+
...babelTransformOptions(),
|
|
439
|
+
inputSourceMap,
|
|
440
|
+
filename: args.filePath,
|
|
441
|
+
sourceFileName: args.filePath,
|
|
442
|
+
plugins: args.plugins,
|
|
443
|
+
sourceMaps: true,
|
|
444
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
445
|
+
});
|
|
446
|
+
} catch (err) {
|
|
447
|
+
if (!args.errorLabel) throw err;
|
|
448
|
+
const message = getBabelError(err, args);
|
|
449
|
+
const error = new Error(message);
|
|
450
|
+
error.stack = void 0;
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
if (!result || !result.code) return null;
|
|
454
|
+
return {
|
|
455
|
+
code: result.code,
|
|
456
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function babelTransformOptions() {
|
|
460
|
+
return {
|
|
461
|
+
configFile: false,
|
|
462
|
+
babelrc: false,
|
|
463
|
+
parserOpts: {
|
|
464
|
+
plugins: ["typescript", "jsx"],
|
|
465
|
+
strictMode: false,
|
|
466
|
+
allowImportExportEverywhere: true
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function parseInputSourceMap(sourcemap) {
|
|
471
|
+
if (!sourcemap) return void 0;
|
|
472
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
473
|
+
return JSON.parse(sourcemap);
|
|
474
|
+
}
|
|
475
|
+
function getBabelError(err, args) {
|
|
476
|
+
const babelErr = err;
|
|
477
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
478
|
+
const codeFrame = babelErr?.codeFrame;
|
|
479
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
480
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
484
|
+
function createCssPropPlugin(args) {
|
|
485
|
+
return babelPlugin((babel) => {
|
|
486
|
+
const { types: t } = babel;
|
|
487
|
+
return {
|
|
488
|
+
pre() {
|
|
489
|
+
this.options = args.options;
|
|
490
|
+
this.mergeId = null;
|
|
491
|
+
this.programPath = null;
|
|
492
|
+
this.changed = false;
|
|
493
|
+
},
|
|
494
|
+
visitor: {
|
|
495
|
+
Program: {
|
|
496
|
+
enter(path, state) {
|
|
497
|
+
state.programPath = path;
|
|
498
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
499
|
+
},
|
|
500
|
+
exit(path, state) {
|
|
501
|
+
const options = getCssPropOptions(state.options);
|
|
502
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
503
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
JSXOpeningElement(path, state) {
|
|
507
|
+
const keyHoistedAttributes = hoistKeyAttributes(path.node.attributes);
|
|
508
|
+
if (keyHoistedAttributes) path.node.attributes = keyHoistedAttributes;
|
|
509
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
510
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
511
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
512
|
+
const keyAttributes = path.node.attributes.filter(isKeyAttribute);
|
|
513
|
+
const parts = path.node.attributes.filter((attr) => !isKeyAttribute(attr)).map((attr) => buildPart(t, attr));
|
|
514
|
+
path.node.attributes = [...keyAttributes, t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
515
|
+
state.changed = true;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function getCssPropOptions(options) {
|
|
522
|
+
return options.cssProp || null;
|
|
523
|
+
}
|
|
524
|
+
function isIntrinsicElement(name) {
|
|
525
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
526
|
+
}
|
|
527
|
+
function hasCssAttribute(attrs) {
|
|
528
|
+
return attrs.some((attr) => {
|
|
529
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
function hoistKeyAttributes(attrs) {
|
|
533
|
+
const keyAttributes = attrs.filter(isKeyAttribute);
|
|
534
|
+
if (!keyAttributes.length) return null;
|
|
535
|
+
const firstKeyIndex = attrs.findIndex(isKeyAttribute);
|
|
536
|
+
const firstSpreadIndex = attrs.findIndex((attr) => attr.type === "JSXSpreadAttribute");
|
|
537
|
+
if (firstSpreadIndex < 0 || firstKeyIndex < firstSpreadIndex) return null;
|
|
538
|
+
return [...keyAttributes, ...attrs.filter((attr) => !isKeyAttribute(attr))];
|
|
539
|
+
}
|
|
540
|
+
function isKeyAttribute(attr) {
|
|
541
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "key";
|
|
542
|
+
}
|
|
543
|
+
function buildPart(t, attr) {
|
|
544
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
545
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
546
|
+
}
|
|
547
|
+
function getObjectKey(t, name) {
|
|
548
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
549
|
+
return t.stringLiteral(getAttributeName(name));
|
|
550
|
+
}
|
|
551
|
+
function getAttributeName(name) {
|
|
552
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
553
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
554
|
+
}
|
|
555
|
+
function getAttributeValue(t, attr) {
|
|
556
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
557
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
558
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
559
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
560
|
+
return attr.value.expression;
|
|
561
|
+
}
|
|
562
|
+
return attr.value;
|
|
563
|
+
}
|
|
564
|
+
function isValidIdentifierName(name) {
|
|
565
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
566
|
+
}
|
|
567
|
+
//#endregion
|
|
429
568
|
//#region builder/data/const.ts
|
|
430
569
|
const BUILDER_TYPE = symbol("builder.type");
|
|
431
570
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -433,8 +572,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
433
572
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
434
573
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
435
574
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
575
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
576
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
436
577
|
//#endregion
|
|
437
578
|
//#region utils/object.ts
|
|
579
|
+
function hasOwn(target, field) {
|
|
580
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
581
|
+
}
|
|
438
582
|
function toArray(value) {
|
|
439
583
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
440
584
|
}
|
|
@@ -611,6 +755,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
611
755
|
}
|
|
612
756
|
//#endregion
|
|
613
757
|
//#region builder/data/is.ts
|
|
758
|
+
function getSlotId(data) {
|
|
759
|
+
return data[BUILDER_SLOT_ID];
|
|
760
|
+
}
|
|
761
|
+
function getScopeTargetSlotId(data) {
|
|
762
|
+
return data[BUILDER_SCOPE_ID];
|
|
763
|
+
}
|
|
764
|
+
function getScopeTargetScope(data) {
|
|
765
|
+
return data[BUILDER_SCOPE];
|
|
766
|
+
}
|
|
614
767
|
function isStyleData(value) {
|
|
615
768
|
return getBuilderType(value) === 1;
|
|
616
769
|
}
|
|
@@ -620,9 +773,18 @@ function isSlotData(value) {
|
|
|
620
773
|
function isSlotOverrideData(value) {
|
|
621
774
|
return getBuilderType(value) === 3;
|
|
622
775
|
}
|
|
776
|
+
function isSelectorData(value) {
|
|
777
|
+
return getBuilderType(value) === 7;
|
|
778
|
+
}
|
|
779
|
+
function isSheetData(value) {
|
|
780
|
+
return getBuilderType(value) === 9;
|
|
781
|
+
}
|
|
623
782
|
function isScopeData(value) {
|
|
624
783
|
return getBuilderType(value) === 4;
|
|
625
784
|
}
|
|
785
|
+
function isThemeData(value) {
|
|
786
|
+
return getBuilderType(value) === 6;
|
|
787
|
+
}
|
|
626
788
|
function getBuilderType(value) {
|
|
627
789
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
628
790
|
return value[BUILDER_TYPE];
|
|
@@ -859,114 +1021,6 @@ selectorPriority({
|
|
|
859
1021
|
...AtRuleSelectors
|
|
860
1022
|
}, PrioritySelectors);
|
|
861
1023
|
//#endregion
|
|
862
|
-
//#region selector/validate.ts
|
|
863
|
-
function isLocalSelector(selector) {
|
|
864
|
-
const groups = parseSelector(selector);
|
|
865
|
-
if (!groups || groups.length !== 1) return false;
|
|
866
|
-
return isSelectorGroupsSelf(groups, false);
|
|
867
|
-
}
|
|
868
|
-
function isPseudoArgSelector(selector) {
|
|
869
|
-
const groups = parseSelector(selector);
|
|
870
|
-
if (!groups || groups.length !== 1) return false;
|
|
871
|
-
return isSelectorGroupsSelf(groups, true);
|
|
872
|
-
}
|
|
873
|
-
function isTagSelector(selector) {
|
|
874
|
-
const groups = parseSelector(selector);
|
|
875
|
-
if (!groups || groups.length !== 1) return false;
|
|
876
|
-
const group = groups[0];
|
|
877
|
-
return group.length === 1 && group[0].type === css_what.SelectorType.Tag;
|
|
878
|
-
}
|
|
879
|
-
function isAttrArg(value) {
|
|
880
|
-
if (!value) return false;
|
|
881
|
-
if (value.includes("[") || value.includes("]")) return false;
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
function isRawValue(value) {
|
|
885
|
-
if (!value) return false;
|
|
886
|
-
if (value.includes("{") || value.includes("}")) return false;
|
|
887
|
-
return true;
|
|
888
|
-
}
|
|
889
|
-
function parseSelector(selector) {
|
|
890
|
-
try {
|
|
891
|
-
return (0, css_what.parse)(selector);
|
|
892
|
-
} catch {
|
|
893
|
-
return;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
function isSelectorGroupsSelf(groups, allowTag) {
|
|
897
|
-
for (let i = 0; i < groups.length; i++) {
|
|
898
|
-
const group = groups[i];
|
|
899
|
-
for (let j = 0; j < group.length; j++) {
|
|
900
|
-
const token = group[j];
|
|
901
|
-
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
902
|
-
if (token.type === css_what.SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
return true;
|
|
906
|
-
}
|
|
907
|
-
function isAllowedSelectorType(type, allowTag) {
|
|
908
|
-
return type === css_what.SelectorType.Attribute || type === css_what.SelectorType.Pseudo || type === css_what.SelectorType.PseudoElement || allowTag && type === css_what.SelectorType.Tag;
|
|
909
|
-
}
|
|
910
|
-
//#endregion
|
|
911
|
-
//#region selector/assert.ts
|
|
912
|
-
function assertSelector(type, value) {
|
|
913
|
-
assertSelectorNotEmpty(value);
|
|
914
|
-
if (!type) return;
|
|
915
|
-
if (typeof type === "function") return type(value);
|
|
916
|
-
switch (type) {
|
|
917
|
-
case "local": return assertLocalSelector(value);
|
|
918
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
919
|
-
case "tag": return assertTagSelector(value);
|
|
920
|
-
case "attr": return assertAttrSelector(value);
|
|
921
|
-
case "value": return assertRawValue(value);
|
|
922
|
-
case "media": return assertMediaQuery(value);
|
|
923
|
-
case "supports": return assertSupportsQuery(value);
|
|
924
|
-
case "container": return assertContainerQuery(value);
|
|
925
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
929
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
930
|
-
});
|
|
931
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
932
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
933
|
-
});
|
|
934
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
935
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
936
|
-
});
|
|
937
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
938
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
939
|
-
});
|
|
940
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
941
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
942
|
-
});
|
|
943
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
944
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
945
|
-
});
|
|
946
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
947
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
948
|
-
});
|
|
949
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
950
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
951
|
-
});
|
|
952
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
953
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
954
|
-
});
|
|
955
|
-
//#endregion
|
|
956
|
-
//#region builder/data/check_selector.ts
|
|
957
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
958
|
-
let message = null;
|
|
959
|
-
try {
|
|
960
|
-
assertSelector(fnSelector.assert, arg);
|
|
961
|
-
} catch (error) {
|
|
962
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
963
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
964
|
-
else message = "selector is invalid: " + arg;
|
|
965
|
-
}
|
|
966
|
-
if (!message) return;
|
|
967
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
968
|
-
}
|
|
969
|
-
//#endregion
|
|
970
1024
|
//#region builder/data/create.ts
|
|
971
1025
|
function createStyleData(callsite) {
|
|
972
1026
|
return {
|
|
@@ -1000,6 +1054,28 @@ function createSlotOverrideData(callsite, slotId) {
|
|
|
1000
1054
|
[BUILDER_SLOT_ID]: slotId
|
|
1001
1055
|
};
|
|
1002
1056
|
}
|
|
1057
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
1058
|
+
return {
|
|
1059
|
+
[BUILDER_TYPE]: 8,
|
|
1060
|
+
[BUILDER_STATE]: {
|
|
1061
|
+
items: [],
|
|
1062
|
+
lookup: {}
|
|
1063
|
+
},
|
|
1064
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1065
|
+
[BUILDER_SELECTOR]: selectors
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
function createSelectorData(callsite, selectors) {
|
|
1069
|
+
return {
|
|
1070
|
+
[BUILDER_TYPE]: 7,
|
|
1071
|
+
[BUILDER_STATE]: {
|
|
1072
|
+
items: [],
|
|
1073
|
+
lookup: {}
|
|
1074
|
+
},
|
|
1075
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1076
|
+
[BUILDER_SELECTOR]: selectors
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1003
1079
|
function createScopeData(callsite) {
|
|
1004
1080
|
return {
|
|
1005
1081
|
[BUILDER_TYPE]: 4,
|
|
@@ -1135,6 +1211,9 @@ const formatTransformClassName = createNameFormatter(["className"]);
|
|
|
1135
1211
|
function getDebugClassName(format, hash, info) {
|
|
1136
1212
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
1137
1213
|
}
|
|
1214
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1215
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1216
|
+
}
|
|
1138
1217
|
function getDebugTransformClassName(format, hash, info) {
|
|
1139
1218
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1140
1219
|
}
|
|
@@ -1330,54 +1409,17 @@ function parseAtRule(rule) {
|
|
|
1330
1409
|
return compressQuery(normalized);
|
|
1331
1410
|
}
|
|
1332
1411
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1333
|
-
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
1412
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1334
1413
|
}
|
|
1335
|
-
function formatScopeClassName(format, info) {
|
|
1414
|
+
function formatScopeClassName$1(format, info) {
|
|
1336
1415
|
if (typeof format === "function") return format(info);
|
|
1337
1416
|
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1338
1417
|
}
|
|
1339
1418
|
//#endregion
|
|
1340
1419
|
//#region atomic/utils/hash.ts
|
|
1341
|
-
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1342
|
-
byValue: /* @__PURE__ */ new Map(),
|
|
1343
|
-
byHash: /* @__PURE__ */ new Map(),
|
|
1344
|
-
usedByLength: []
|
|
1345
|
-
}));
|
|
1346
1420
|
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1347
|
-
return getPooledHash(value, startLength);
|
|
1348
|
-
}
|
|
1349
|
-
function getPooledHash(value, startLength) {
|
|
1350
1421
|
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1351
|
-
|
|
1352
|
-
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1353
|
-
if (existing) return existing;
|
|
1354
|
-
let length = normalizedStartLength;
|
|
1355
|
-
while (true) {
|
|
1356
|
-
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1357
|
-
length++;
|
|
1358
|
-
continue;
|
|
1359
|
-
}
|
|
1360
|
-
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1361
|
-
const hash = getPooledHashCandidate(value, length, index);
|
|
1362
|
-
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1363
|
-
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1364
|
-
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1365
|
-
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1366
|
-
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1367
|
-
return hash;
|
|
1368
|
-
}
|
|
1369
|
-
length++;
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
function getPooledHashCandidate(value, length, index) {
|
|
1373
|
-
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1374
|
-
}
|
|
1375
|
-
function getPooledHashUsedCount(length) {
|
|
1376
|
-
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1377
|
-
}
|
|
1378
|
-
function getIdentifierSafeHashPoolSize(length) {
|
|
1379
|
-
if (length <= 0) return 0;
|
|
1380
|
-
return 26 * 36 ** (length - 1);
|
|
1422
|
+
return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
|
|
1381
1423
|
}
|
|
1382
1424
|
function getIdentifierSafeHashValue(hash) {
|
|
1383
1425
|
const first = hash.charCodeAt(0);
|
|
@@ -1386,21 +1428,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1386
1428
|
}
|
|
1387
1429
|
//#endregion
|
|
1388
1430
|
//#region atomic/utils/selector.ts
|
|
1389
|
-
function getSelectorText(selector) {
|
|
1390
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1431
|
+
function getSelectorText$1(selector) {
|
|
1432
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1391
1433
|
}
|
|
1392
1434
|
function getSelectorHash(selector) {
|
|
1393
1435
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1394
1436
|
}
|
|
1395
|
-
function getSelectorPriority(selector) {
|
|
1437
|
+
function getSelectorPriority$1(selector) {
|
|
1396
1438
|
if (!selector) return 0;
|
|
1397
1439
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1398
1440
|
}
|
|
1441
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1442
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1443
|
+
}
|
|
1444
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1445
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1446
|
+
}
|
|
1399
1447
|
//#endregion
|
|
1400
1448
|
//#region atomic/className.ts
|
|
1401
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1449
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1402
1450
|
let hash = property;
|
|
1403
1451
|
hash += "\n" + (priority || "");
|
|
1452
|
+
if (important) hash += "\nimportant";
|
|
1404
1453
|
hash += "\n" + value;
|
|
1405
1454
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1406
1455
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1410,21 +1459,31 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1410
1459
|
if (!debugClassName) return hash;
|
|
1411
1460
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1412
1461
|
const propertyName = getDebugPropertyName(property, value);
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1462
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1463
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1464
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1465
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1466
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1417
1467
|
property: propertyName ? propertyName.property : property,
|
|
1418
1468
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1419
1469
|
});
|
|
1420
1470
|
}
|
|
1421
1471
|
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1422
|
-
|
|
1423
|
-
|
|
1472
|
+
return getClassNameHashLength({
|
|
1473
|
+
debugClassName,
|
|
1474
|
+
isDev: DEV_CONFIG.isDev,
|
|
1475
|
+
devHashLength: DEV_CONFIG.hashLength,
|
|
1476
|
+
cssHashLength: CSS_CONFIG.hashLength
|
|
1477
|
+
});
|
|
1424
1478
|
}
|
|
1425
|
-
function
|
|
1479
|
+
function getClassNameHashLength(options) {
|
|
1480
|
+
if (options.debugClassName && options.isDev) return options.devHashLength ?? options.cssHashLength ?? 3;
|
|
1481
|
+
return options.cssHashLength ?? 7;
|
|
1482
|
+
}
|
|
1483
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1426
1484
|
let hash = property;
|
|
1427
1485
|
hash += "\n" + (priority || "");
|
|
1486
|
+
if (important) hash += "\nimportant";
|
|
1428
1487
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1429
1488
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1430
1489
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1461,7 +1520,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1461
1520
|
let source;
|
|
1462
1521
|
let item;
|
|
1463
1522
|
let lookupIndex;
|
|
1464
|
-
let
|
|
1523
|
+
let weight;
|
|
1524
|
+
let important;
|
|
1465
1525
|
let value;
|
|
1466
1526
|
let atRule;
|
|
1467
1527
|
let dedupe;
|
|
@@ -1472,7 +1532,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1472
1532
|
source = sourceItems[i];
|
|
1473
1533
|
if (!source) continue;
|
|
1474
1534
|
if (isStyleTokenOverrideData(source)) {
|
|
1475
|
-
addTokenOverride(source, styles, lookup);
|
|
1535
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1476
1536
|
continue;
|
|
1477
1537
|
}
|
|
1478
1538
|
if (isScopeData(source)) {
|
|
@@ -1480,7 +1540,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1480
1540
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1481
1541
|
item = scopeItems[j];
|
|
1482
1542
|
if (isStyleTokenOverrideData(item)) {
|
|
1483
|
-
addTokenOverride(item, styles, lookup);
|
|
1543
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1484
1544
|
continue;
|
|
1485
1545
|
}
|
|
1486
1546
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1501,13 +1561,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1501
1561
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1502
1562
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1503
1563
|
value = scopeItem.value;
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
}
|
|
1509
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1510
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1564
|
+
weight = scopeItem.weight;
|
|
1565
|
+
important = scopeItem.important;
|
|
1566
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1567
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1511
1568
|
scopeItem.dedupe = dedupe;
|
|
1512
1569
|
scopeItem.className = className;
|
|
1513
1570
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1544,6 +1601,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1544
1601
|
dedupe: "",
|
|
1545
1602
|
className: "",
|
|
1546
1603
|
property: overrideItem.property,
|
|
1604
|
+
weight: overrideItem.weight,
|
|
1605
|
+
important: overrideItem.important,
|
|
1547
1606
|
value: overrideItem.value,
|
|
1548
1607
|
transformClassName: overrideItem.transformClassName,
|
|
1549
1608
|
token: overrideItem.token,
|
|
@@ -1555,13 +1614,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1555
1614
|
parentSelector
|
|
1556
1615
|
};
|
|
1557
1616
|
value = scopeItem.value;
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
}
|
|
1563
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1564
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1617
|
+
weight = scopeItem.weight;
|
|
1618
|
+
important = scopeItem.important;
|
|
1619
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1620
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1565
1621
|
scopeItem.dedupe = dedupe;
|
|
1566
1622
|
scopeItem.className = className;
|
|
1567
1623
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1572,7 +1628,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1572
1628
|
}
|
|
1573
1629
|
return data;
|
|
1574
1630
|
}
|
|
1575
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1631
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1576
1632
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1577
1633
|
const lookupIndex = lookup[lookupKey];
|
|
1578
1634
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1717,6 +1773,18 @@ function shouldAppendCssPx(property) {
|
|
|
1717
1773
|
return !UNITLESS.has(property);
|
|
1718
1774
|
}
|
|
1719
1775
|
//#endregion
|
|
1776
|
+
//#region style/important.ts
|
|
1777
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1778
|
+
function importantValue(value) {
|
|
1779
|
+
return {
|
|
1780
|
+
[STYLE_IMPORTANT]: true,
|
|
1781
|
+
value
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function isStyleImportantValue(value) {
|
|
1785
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1786
|
+
}
|
|
1787
|
+
//#endregion
|
|
1720
1788
|
//#region style/transform.ts
|
|
1721
1789
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1722
1790
|
function classNameValue(value, className) {
|
|
@@ -1742,6 +1810,19 @@ function isAtRuleRef(value) {
|
|
|
1742
1810
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1743
1811
|
}
|
|
1744
1812
|
//#endregion
|
|
1813
|
+
//#region style/weight.ts
|
|
1814
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1815
|
+
function weightValue(value, weight) {
|
|
1816
|
+
return {
|
|
1817
|
+
[STYLE_WEIGHT]: true,
|
|
1818
|
+
value,
|
|
1819
|
+
weight
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
function isStyleWeightValue(value) {
|
|
1823
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1824
|
+
}
|
|
1825
|
+
//#endregion
|
|
1745
1826
|
//#region builder/data/merge/style.ts
|
|
1746
1827
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1747
1828
|
if (!style) return source;
|
|
@@ -1752,7 +1833,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1752
1833
|
let itemData;
|
|
1753
1834
|
let valueRaw;
|
|
1754
1835
|
let value;
|
|
1755
|
-
let
|
|
1836
|
+
let weight;
|
|
1837
|
+
let important;
|
|
1756
1838
|
let itemCallsite;
|
|
1757
1839
|
let className;
|
|
1758
1840
|
let dedupe;
|
|
@@ -1773,6 +1855,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1773
1855
|
continue;
|
|
1774
1856
|
}
|
|
1775
1857
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1858
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1776
1859
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1777
1860
|
type: 2,
|
|
1778
1861
|
slotId
|
|
@@ -1781,6 +1864,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1781
1864
|
type: 3,
|
|
1782
1865
|
slotId
|
|
1783
1866
|
});
|
|
1867
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1784
1868
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1785
1869
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1786
1870
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1792,11 +1876,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1792
1876
|
}
|
|
1793
1877
|
} else for (const property in style) {
|
|
1794
1878
|
valueRaw = style[property];
|
|
1795
|
-
|
|
1796
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1797
|
-
priority = valueRaw[0];
|
|
1798
|
-
valueRaw = valueRaw[1];
|
|
1799
|
-
}
|
|
1879
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1800
1880
|
transformClassName = null;
|
|
1801
1881
|
if (isClassNameValue(valueRaw)) {
|
|
1802
1882
|
transformClassName = valueRaw.className;
|
|
@@ -1807,7 +1887,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1807
1887
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1808
1888
|
variableName = getDebugFieldVarName(debug, property);
|
|
1809
1889
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1810
|
-
value = priority !== null ? [value, priority] : value;
|
|
1811
1890
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1812
1891
|
itemData = {
|
|
1813
1892
|
runtime: runtimeType,
|
|
@@ -1816,6 +1895,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1816
1895
|
dedupe: "",
|
|
1817
1896
|
className: "",
|
|
1818
1897
|
property,
|
|
1898
|
+
weight,
|
|
1899
|
+
important,
|
|
1819
1900
|
value,
|
|
1820
1901
|
transformClassName,
|
|
1821
1902
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1829,7 +1910,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1829
1910
|
atRule,
|
|
1830
1911
|
callsite: itemCallsite
|
|
1831
1912
|
};
|
|
1832
|
-
if (type === 1) {
|
|
1913
|
+
if (type === 1 || type === 8) {
|
|
1833
1914
|
items.push({
|
|
1834
1915
|
...itemData,
|
|
1835
1916
|
type: 1
|
|
@@ -1876,13 +1957,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1876
1957
|
}
|
|
1877
1958
|
const runtimeItem = item;
|
|
1878
1959
|
value = runtimeItem.value;
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
}
|
|
1884
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1885
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1960
|
+
weight = runtimeItem.weight;
|
|
1961
|
+
important = runtimeItem.important;
|
|
1962
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1963
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1886
1964
|
runtimeItem.dedupe = dedupe;
|
|
1887
1965
|
runtimeItem.className = className;
|
|
1888
1966
|
lookupIndex = lookup[dedupe];
|
|
@@ -1891,6 +1969,41 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1891
1969
|
}
|
|
1892
1970
|
return data;
|
|
1893
1971
|
}
|
|
1972
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1973
|
+
let weight = null;
|
|
1974
|
+
let important = false;
|
|
1975
|
+
while (true) {
|
|
1976
|
+
if (isStyleImportantValue(value)) {
|
|
1977
|
+
important = true;
|
|
1978
|
+
value = value.value;
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
if (isStyleWeightValue(value)) {
|
|
1982
|
+
weight = value.weight;
|
|
1983
|
+
value = value.value;
|
|
1984
|
+
continue;
|
|
1985
|
+
}
|
|
1986
|
+
break;
|
|
1987
|
+
}
|
|
1988
|
+
return [
|
|
1989
|
+
value,
|
|
1990
|
+
weight,
|
|
1991
|
+
important
|
|
1992
|
+
];
|
|
1993
|
+
}
|
|
1994
|
+
function combineSelectors$1(parent, child) {
|
|
1995
|
+
const parentText = getSelectorText(parent);
|
|
1996
|
+
const childText = getSelectorText(child);
|
|
1997
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
1998
|
+
const selector = parentText + childText;
|
|
1999
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
2000
|
+
}
|
|
2001
|
+
function getSelectorText(selector) {
|
|
2002
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
2003
|
+
}
|
|
2004
|
+
function getSelectorPriority(selector) {
|
|
2005
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
2006
|
+
}
|
|
1894
2007
|
function getMergedStyleDebug(debug, item) {
|
|
1895
2008
|
if (!debug) return null;
|
|
1896
2009
|
if (debug.fields?.[item.property]) return debug;
|
|
@@ -1934,6 +2047,47 @@ function withDebugSource$1(loc, debug) {
|
|
|
1934
2047
|
];
|
|
1935
2048
|
}
|
|
1936
2049
|
//#endregion
|
|
2050
|
+
//#region builder/selector_override_core.ts
|
|
2051
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
2052
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
2053
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
2054
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
2055
|
+
}
|
|
2056
|
+
function assertManualSelectorSyntax(selector) {
|
|
2057
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
2058
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
2059
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
2060
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2061
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
2062
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2063
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
2064
|
+
}
|
|
2065
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
2066
|
+
const value = selector.trim();
|
|
2067
|
+
assertManualSelector(value);
|
|
2068
|
+
if (value.startsWith("&?")) {
|
|
2069
|
+
const suffix = value.slice(2);
|
|
2070
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
2071
|
+
}
|
|
2072
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
2073
|
+
}
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region builder/selector_override.ts
|
|
2076
|
+
function normalizeManualSelectors(input) {
|
|
2077
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
2078
|
+
}
|
|
2079
|
+
function assertManualSelector(selector) {
|
|
2080
|
+
assertManualSelectorSyntax(selector);
|
|
2081
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2082
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2083
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
2084
|
+
try {
|
|
2085
|
+
(0, css_what.parse)(parsedSelector);
|
|
2086
|
+
} catch {
|
|
2087
|
+
throw new Error("selector is invalid: " + selector);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
//#endregion
|
|
1937
2091
|
//#region builder/style_data.ts
|
|
1938
2092
|
const mergeStyleCreate = (callsite) => {
|
|
1939
2093
|
return createStyleData(callsite);
|
|
@@ -1947,16 +2101,129 @@ const mergeSlotOverrideCreate = (callsite, data) => {
|
|
|
1947
2101
|
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1948
2102
|
};
|
|
1949
2103
|
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
2104
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
2105
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
2106
|
+
};
|
|
2107
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1950
2108
|
function createMerge(create, type) {
|
|
1951
2109
|
return (data, callsite, style, debug, selector, atRule) => {
|
|
1952
2110
|
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1953
2111
|
};
|
|
1954
2112
|
}
|
|
1955
2113
|
//#endregion
|
|
2114
|
+
//#region selector/validate.ts
|
|
2115
|
+
function isLocalSelector(selector) {
|
|
2116
|
+
const groups = parseSelector(selector);
|
|
2117
|
+
if (!groups || groups.length !== 1) return false;
|
|
2118
|
+
return isSelectorGroupsSelf(groups, false);
|
|
2119
|
+
}
|
|
2120
|
+
function isPseudoArgSelector(selector) {
|
|
2121
|
+
const groups = parseSelector(selector);
|
|
2122
|
+
if (!groups || groups.length !== 1) return false;
|
|
2123
|
+
return isSelectorGroupsSelf(groups, true);
|
|
2124
|
+
}
|
|
2125
|
+
function isTagSelector(selector) {
|
|
2126
|
+
const groups = parseSelector(selector);
|
|
2127
|
+
if (!groups || groups.length !== 1) return false;
|
|
2128
|
+
const group = groups[0];
|
|
2129
|
+
return group.length === 1 && group[0].type === css_what.SelectorType.Tag;
|
|
2130
|
+
}
|
|
2131
|
+
function isAttrArg(value) {
|
|
2132
|
+
if (!value) return false;
|
|
2133
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
2134
|
+
return true;
|
|
2135
|
+
}
|
|
2136
|
+
function isRawValue(value) {
|
|
2137
|
+
if (!value) return false;
|
|
2138
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
2139
|
+
return true;
|
|
2140
|
+
}
|
|
2141
|
+
function parseSelector(selector) {
|
|
2142
|
+
try {
|
|
2143
|
+
return (0, css_what.parse)(selector);
|
|
2144
|
+
} catch {
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
2149
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2150
|
+
const group = groups[i];
|
|
2151
|
+
for (let j = 0; j < group.length; j++) {
|
|
2152
|
+
const token = group[j];
|
|
2153
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2154
|
+
if (token.type === css_what.SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
return true;
|
|
2158
|
+
}
|
|
2159
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2160
|
+
return type === css_what.SelectorType.Attribute || type === css_what.SelectorType.Pseudo || type === css_what.SelectorType.PseudoElement || allowTag && type === css_what.SelectorType.Tag;
|
|
2161
|
+
}
|
|
2162
|
+
//#endregion
|
|
2163
|
+
//#region selector/assert.ts
|
|
2164
|
+
function assertSelector(type, value) {
|
|
2165
|
+
assertSelectorNotEmpty(value);
|
|
2166
|
+
if (!type) return;
|
|
2167
|
+
if (typeof type === "function") return type(value);
|
|
2168
|
+
switch (type) {
|
|
2169
|
+
case "local": return assertLocalSelector(value);
|
|
2170
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2171
|
+
case "tag": return assertTagSelector(value);
|
|
2172
|
+
case "attr": return assertAttrSelector(value);
|
|
2173
|
+
case "value": return assertRawValue(value);
|
|
2174
|
+
case "media": return assertMediaQuery(value);
|
|
2175
|
+
case "supports": return assertSupportsQuery(value);
|
|
2176
|
+
case "container": return assertContainerQuery(value);
|
|
2177
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2181
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2182
|
+
});
|
|
2183
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2184
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2185
|
+
});
|
|
2186
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2187
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2188
|
+
});
|
|
2189
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2190
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2191
|
+
});
|
|
2192
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2193
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2194
|
+
});
|
|
2195
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2196
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2197
|
+
});
|
|
2198
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2199
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2200
|
+
});
|
|
2201
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2202
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2203
|
+
});
|
|
2204
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2205
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2206
|
+
});
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region builder/data/check_selector.ts
|
|
2209
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2210
|
+
let message = null;
|
|
2211
|
+
try {
|
|
2212
|
+
assertSelector(fnSelector.assert, arg);
|
|
2213
|
+
} catch (error) {
|
|
2214
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2215
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2216
|
+
else message = "selector is invalid: " + arg;
|
|
2217
|
+
}
|
|
2218
|
+
if (!message) return;
|
|
2219
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
2220
|
+
}
|
|
2221
|
+
//#endregion
|
|
1956
2222
|
//#region builder/utils.ts
|
|
1957
2223
|
const FnPrefixStyle = "style.";
|
|
1958
2224
|
const FnPrefixSlot = "slot.";
|
|
1959
2225
|
const FnPrefixScope = "scope.";
|
|
2226
|
+
const FnPrefixSelector = "selector.";
|
|
1960
2227
|
function runtimeCallsite() {
|
|
1961
2228
|
return traceCallsite();
|
|
1962
2229
|
}
|
|
@@ -2017,9 +2284,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2017
2284
|
let arg;
|
|
2018
2285
|
let style;
|
|
2019
2286
|
let debug;
|
|
2020
|
-
let
|
|
2287
|
+
let weight = null;
|
|
2021
2288
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
2022
|
-
|
|
2289
|
+
weight = params[0];
|
|
2023
2290
|
arg = params[1];
|
|
2024
2291
|
style = params[2];
|
|
2025
2292
|
debug = params[3];
|
|
@@ -2029,7 +2296,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2029
2296
|
debug = params[2];
|
|
2030
2297
|
}
|
|
2031
2298
|
else if (isMedia && typeof params[0] === "number") {
|
|
2032
|
-
|
|
2299
|
+
weight = params[0];
|
|
2033
2300
|
arg = fnSelector.selector;
|
|
2034
2301
|
style = params[1];
|
|
2035
2302
|
debug = params[2];
|
|
@@ -2049,7 +2316,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
2049
2316
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
2050
2317
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
2051
2318
|
const item = items[j];
|
|
2052
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2319
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
2053
2320
|
}
|
|
2054
2321
|
}
|
|
2055
2322
|
return createFnResult(data, fns);
|
|
@@ -2116,9 +2383,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2116
2383
|
let arg;
|
|
2117
2384
|
let data;
|
|
2118
2385
|
let debug;
|
|
2119
|
-
let
|
|
2386
|
+
let weight = null;
|
|
2120
2387
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
2121
|
-
|
|
2388
|
+
weight = params[0];
|
|
2122
2389
|
arg = params[1];
|
|
2123
2390
|
data = params[2];
|
|
2124
2391
|
debug = params[3];
|
|
@@ -2128,7 +2395,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2128
2395
|
debug = params[2];
|
|
2129
2396
|
}
|
|
2130
2397
|
else if (isMedia && typeof params[0] === "number") {
|
|
2131
|
-
|
|
2398
|
+
weight = params[0];
|
|
2132
2399
|
arg = fnSelector.selector;
|
|
2133
2400
|
data = params[1];
|
|
2134
2401
|
debug = params[2];
|
|
@@ -2145,7 +2412,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2145
2412
|
selector = args[i];
|
|
2146
2413
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
2147
2414
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
2148
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2415
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
2149
2416
|
}
|
|
2150
2417
|
return result;
|
|
2151
2418
|
};
|
|
@@ -2222,6 +2489,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2222
2489
|
traceMarker(fn, "slot");
|
|
2223
2490
|
return fn;
|
|
2224
2491
|
}
|
|
2492
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2493
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2494
|
+
const fn = (selector, style, debug) => {
|
|
2495
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2496
|
+
debug = style;
|
|
2497
|
+
style = void 0;
|
|
2498
|
+
}
|
|
2499
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2500
|
+
if (style === void 0) return target;
|
|
2501
|
+
return target(style, debug);
|
|
2502
|
+
};
|
|
2503
|
+
traceMarker(fn, "style.selector");
|
|
2504
|
+
return fn;
|
|
2505
|
+
}
|
|
2225
2506
|
function createScopeBuilder(selectors) {
|
|
2226
2507
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2227
2508
|
const fn = (items, debug) => {
|
|
@@ -2237,6 +2518,34 @@ function createScopeBuilder(selectors) {
|
|
|
2237
2518
|
traceMarker(fn, "scope");
|
|
2238
2519
|
return fn;
|
|
2239
2520
|
}
|
|
2521
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2522
|
+
const callable = ((style, debug) => {
|
|
2523
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2524
|
+
debug = style;
|
|
2525
|
+
style = void 0;
|
|
2526
|
+
}
|
|
2527
|
+
const callsite = resolveCallsite(debug);
|
|
2528
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2529
|
+
});
|
|
2530
|
+
traceMarker(callable, "selector.override");
|
|
2531
|
+
Object.setPrototypeOf(callable, fns);
|
|
2532
|
+
Object.assign(callable, data);
|
|
2533
|
+
return callable;
|
|
2534
|
+
}
|
|
2535
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2536
|
+
const callable = ((style, debug) => {
|
|
2537
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2538
|
+
debug = style;
|
|
2539
|
+
style = void 0;
|
|
2540
|
+
}
|
|
2541
|
+
const callsite = resolveCallsite(debug);
|
|
2542
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2543
|
+
});
|
|
2544
|
+
traceMarker(callable, "selector");
|
|
2545
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2546
|
+
Object.assign(callable, data);
|
|
2547
|
+
return callable;
|
|
2548
|
+
}
|
|
2240
2549
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2241
2550
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2242
2551
|
const callable = ((style, debug) => {
|
|
@@ -2845,6 +3154,497 @@ function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, to
|
|
|
2845
3154
|
}
|
|
2846
3155
|
createIdCounter("property");
|
|
2847
3156
|
//#endregion
|
|
3157
|
+
//#region sheet/utils/sourcemap.ts
|
|
3158
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3159
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3160
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3161
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3162
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3163
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3164
|
+
function encodeBase64(text) {
|
|
3165
|
+
const bytes = new TextEncoder().encode(text);
|
|
3166
|
+
let binary = "";
|
|
3167
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3168
|
+
return btoa(binary);
|
|
3169
|
+
}
|
|
3170
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3171
|
+
let source = sourceLookup[filePath];
|
|
3172
|
+
if (source) {
|
|
3173
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3174
|
+
return source;
|
|
3175
|
+
}
|
|
3176
|
+
source = {
|
|
3177
|
+
filePath,
|
|
3178
|
+
sourceIndex: sources.length,
|
|
3179
|
+
sourceContent
|
|
3180
|
+
};
|
|
3181
|
+
sources.push(source);
|
|
3182
|
+
sourceLookup[filePath] = source;
|
|
3183
|
+
return source;
|
|
3184
|
+
}
|
|
3185
|
+
function normalizeSourcePath(filePath) {
|
|
3186
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3187
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3188
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3189
|
+
return filePath.replace(/^at\s+/, "");
|
|
3190
|
+
}
|
|
3191
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3192
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3193
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3194
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3195
|
+
}
|
|
3196
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3197
|
+
const sidecarUrl = getSidecarUrl();
|
|
3198
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3199
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3200
|
+
}
|
|
3201
|
+
function getSidecarUrl() {
|
|
3202
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3203
|
+
return typeof value === "string" && value ? value : null;
|
|
3204
|
+
}
|
|
3205
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3206
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3207
|
+
try {
|
|
3208
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3209
|
+
} catch {
|
|
3210
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3214
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3215
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3216
|
+
return path ? `${base}/${path}` : base;
|
|
3217
|
+
}
|
|
3218
|
+
function getLineCount(css) {
|
|
3219
|
+
let count = 1;
|
|
3220
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3221
|
+
return count;
|
|
3222
|
+
}
|
|
3223
|
+
function encodeVlq(value) {
|
|
3224
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3225
|
+
let encoded = "";
|
|
3226
|
+
do {
|
|
3227
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3228
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3229
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3230
|
+
encoded += BASE64[digit];
|
|
3231
|
+
} while (vlq > 0);
|
|
3232
|
+
return encoded;
|
|
3233
|
+
}
|
|
3234
|
+
//#endregion
|
|
3235
|
+
//#region sheet/sourcemap.ts
|
|
3236
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3237
|
+
if (debug && debugField) {
|
|
3238
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3239
|
+
if (loc) return normalizeRuleCallsite({
|
|
3240
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3241
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3242
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3243
|
+
line: loc[0],
|
|
3244
|
+
column: loc[1]
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3248
|
+
if (debug) return normalizeRuleCallsite({
|
|
3249
|
+
filePath: debug.sourceUrl,
|
|
3250
|
+
sourceUrl: debug.sourceUrl,
|
|
3251
|
+
sourceContent: debug.code,
|
|
3252
|
+
line: debug.loc[0],
|
|
3253
|
+
column: debug.loc[1]
|
|
3254
|
+
});
|
|
3255
|
+
return callsite || null;
|
|
3256
|
+
}
|
|
3257
|
+
function normalizeRuleCallsite(callsite) {
|
|
3258
|
+
return {
|
|
3259
|
+
...callsite,
|
|
3260
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3261
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3262
|
+
};
|
|
3263
|
+
}
|
|
3264
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3265
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3266
|
+
//#endregion
|
|
3267
|
+
//#region builder/extract/utils.ts
|
|
3268
|
+
function createExtractedData(type, slotId) {
|
|
3269
|
+
const data = {
|
|
3270
|
+
[BUILDER_TYPE]: type,
|
|
3271
|
+
[BUILDER_STATE]: {
|
|
3272
|
+
items: [],
|
|
3273
|
+
lookup: {}
|
|
3274
|
+
},
|
|
3275
|
+
[BUILDER_CALLSITE]: null
|
|
3276
|
+
};
|
|
3277
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3278
|
+
return data;
|
|
3279
|
+
}
|
|
3280
|
+
function copyExtractedData(target, source) {
|
|
3281
|
+
const mutable = target;
|
|
3282
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3283
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3284
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3285
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3286
|
+
}
|
|
3287
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3288
|
+
return {
|
|
3289
|
+
[BUILDER_TYPE]: 5,
|
|
3290
|
+
[BUILDER_SCOPE]: scope,
|
|
3291
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3295
|
+
const normalized = [];
|
|
3296
|
+
let i = 0;
|
|
3297
|
+
while (i < items.length) {
|
|
3298
|
+
const item = items[i];
|
|
3299
|
+
const value = item[2];
|
|
3300
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3301
|
+
type,
|
|
3302
|
+
item[0],
|
|
3303
|
+
item[1]
|
|
3304
|
+
] : [
|
|
3305
|
+
type,
|
|
3306
|
+
slotId,
|
|
3307
|
+
item[0],
|
|
3308
|
+
item[1]
|
|
3309
|
+
] : slotId === null ? [
|
|
3310
|
+
type,
|
|
3311
|
+
item[0],
|
|
3312
|
+
item[1],
|
|
3313
|
+
value
|
|
3314
|
+
] : [
|
|
3315
|
+
type,
|
|
3316
|
+
slotId,
|
|
3317
|
+
item[0],
|
|
3318
|
+
item[1],
|
|
3319
|
+
value
|
|
3320
|
+
]);
|
|
3321
|
+
i++;
|
|
3322
|
+
}
|
|
3323
|
+
return normalized;
|
|
3324
|
+
}
|
|
3325
|
+
//#endregion
|
|
3326
|
+
//#region builder/extract/withTokens.ts
|
|
3327
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3328
|
+
function isExtractedTokenBoundData(value) {
|
|
3329
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3330
|
+
}
|
|
3331
|
+
function getExtractedTokenBoundData(value) {
|
|
3332
|
+
return tokenBoundData.get(value);
|
|
3333
|
+
}
|
|
3334
|
+
function isElementDebugData(value) {
|
|
3335
|
+
if (!value || typeof value !== "object") return false;
|
|
3336
|
+
return value.$$elementDebug === true;
|
|
3337
|
+
}
|
|
3338
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3339
|
+
//#endregion
|
|
3340
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3341
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3342
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3343
|
+
function markResolvedStyleItem(item) {
|
|
3344
|
+
resolvedStyleItems.add(item);
|
|
3345
|
+
}
|
|
3346
|
+
function isResolvedStyleItem$1(value) {
|
|
3347
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3348
|
+
}
|
|
3349
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3350
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
3351
|
+
}
|
|
3352
|
+
//#endregion
|
|
3353
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3354
|
+
function createMutableTokenValues(base) {
|
|
3355
|
+
return {
|
|
3356
|
+
ids: base ? base.ids.slice() : null,
|
|
3357
|
+
values: base ? base.values.slice() : null,
|
|
3358
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3359
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
function addTokenOverride(values, item, resolver) {
|
|
3363
|
+
if (!resolver.is(item)) return false;
|
|
3364
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3365
|
+
return true;
|
|
3366
|
+
}
|
|
3367
|
+
function addTokenValue(values, id, value) {
|
|
3368
|
+
if (!values.ids) values.ids = [];
|
|
3369
|
+
if (!values.values) values.values = [];
|
|
3370
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3371
|
+
if (!values.index) values.index = Object.create(null);
|
|
3372
|
+
const ids = values.ids;
|
|
3373
|
+
const tokenValues = values.values;
|
|
3374
|
+
const lookup = values.lookup;
|
|
3375
|
+
const indexLookup = values.index;
|
|
3376
|
+
const index = indexLookup[id];
|
|
3377
|
+
if (index === void 0) {
|
|
3378
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3379
|
+
tokenValues.push(value);
|
|
3380
|
+
} else tokenValues[index] = value;
|
|
3381
|
+
lookup[id] = value;
|
|
3382
|
+
}
|
|
3383
|
+
function addTokenValues(values, next) {
|
|
3384
|
+
if (!next) return;
|
|
3385
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3386
|
+
}
|
|
3387
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3388
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3389
|
+
}
|
|
3390
|
+
function finishTokenValues(base, values) {
|
|
3391
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3392
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
3393
|
+
return {
|
|
3394
|
+
ids: values.ids,
|
|
3395
|
+
values: values.values,
|
|
3396
|
+
lookup: values.lookup
|
|
3397
|
+
};
|
|
3398
|
+
}
|
|
3399
|
+
function mergeTokenValues(base, next) {
|
|
3400
|
+
if (!next) return base;
|
|
3401
|
+
if (!base) return next;
|
|
3402
|
+
const values = createMutableTokenValues(base);
|
|
3403
|
+
addTokenValues(values, next);
|
|
3404
|
+
return finishTokenValues(base, values);
|
|
3405
|
+
}
|
|
3406
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3407
|
+
if (!overrides.length) return base;
|
|
3408
|
+
const values = createMutableTokenValues(base);
|
|
3409
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3410
|
+
return finishTokenValues(base, values);
|
|
3411
|
+
}
|
|
3412
|
+
function createTokenIndexLookup(ids) {
|
|
3413
|
+
const lookup = Object.create(null);
|
|
3414
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3415
|
+
return lookup;
|
|
3416
|
+
}
|
|
3417
|
+
function isSameTokenValues(base, ids, values) {
|
|
3418
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3419
|
+
const baseLookup = base.lookup;
|
|
3420
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3421
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3422
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3423
|
+
}
|
|
3424
|
+
return true;
|
|
3425
|
+
}
|
|
3426
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3427
|
+
function isResolvedStyleItem(value) {
|
|
3428
|
+
return isResolvedStyleItem$1(value);
|
|
3429
|
+
}
|
|
3430
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3431
|
+
return createStyleItem({
|
|
3432
|
+
data,
|
|
3433
|
+
items: resolveItems(data, scopes)
|
|
3434
|
+
}, tokens);
|
|
3435
|
+
}
|
|
3436
|
+
function createStyleItem(item, tokens = null) {
|
|
3437
|
+
markResolvedStyleItem(item);
|
|
3438
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3439
|
+
return item;
|
|
3440
|
+
}
|
|
3441
|
+
function resolveItems(data, scopes) {
|
|
3442
|
+
const items = [];
|
|
3443
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3444
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3445
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3446
|
+
const item = stateItems[i];
|
|
3447
|
+
if (Array.isArray(item)) {
|
|
3448
|
+
items.push(item);
|
|
3449
|
+
continue;
|
|
3450
|
+
}
|
|
3451
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3452
|
+
items.push(item);
|
|
3453
|
+
continue;
|
|
3454
|
+
}
|
|
3455
|
+
if (slotId && item.type !== 2) continue;
|
|
3456
|
+
items.push(item);
|
|
3457
|
+
}
|
|
3458
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3459
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3460
|
+
const boundScope = scopes[i];
|
|
3461
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3462
|
+
if (!scope) continue;
|
|
3463
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3464
|
+
if (!scopeItems) continue;
|
|
3465
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3466
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3467
|
+
const item = scopeItems[j];
|
|
3468
|
+
if (Array.isArray(item)) {
|
|
3469
|
+
if (item[1] === slotId) items.push(item);
|
|
3470
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3471
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3472
|
+
continue;
|
|
3473
|
+
}
|
|
3474
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3475
|
+
if (item.type !== 4) continue;
|
|
3476
|
+
if (item.slotId === slotId) items.push(item);
|
|
3477
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
return items;
|
|
3481
|
+
}
|
|
3482
|
+
function getScopeParentItem(className) {
|
|
3483
|
+
const parentClassName = formatScopeClassName(className);
|
|
3484
|
+
return [parentClassName, parentClassName];
|
|
3485
|
+
}
|
|
3486
|
+
function formatScopeClassName(className) {
|
|
3487
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3488
|
+
if (!format) return "-" + className;
|
|
3489
|
+
if (typeof format === "function") return format({ className });
|
|
3490
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3491
|
+
}
|
|
3492
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3493
|
+
return value === 1 || value === true;
|
|
3494
|
+
}
|
|
3495
|
+
//#endregion
|
|
3496
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3497
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3498
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3499
|
+
}
|
|
3500
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3501
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3502
|
+
}
|
|
3503
|
+
function getDataTokenValues(data, resolver) {
|
|
3504
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3505
|
+
const values = createMutableTokenValues(null);
|
|
3506
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3507
|
+
return finishTokenValues(null, values);
|
|
3508
|
+
}
|
|
3509
|
+
createCacheValue();
|
|
3510
|
+
function createCacheValue() {
|
|
3511
|
+
return {
|
|
3512
|
+
d: null,
|
|
3513
|
+
c: RUNTIME_CONFIG.changes
|
|
3514
|
+
};
|
|
3515
|
+
}
|
|
3516
|
+
//#endregion
|
|
3517
|
+
//#region runtime/core/cache/token.ts
|
|
3518
|
+
const runtimeTokenValueResolver = {
|
|
3519
|
+
get key() {
|
|
3520
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3521
|
+
},
|
|
3522
|
+
is: isStyleTokenOverrideData,
|
|
3523
|
+
id(token) {
|
|
3524
|
+
return getStyleTokenId(token);
|
|
3525
|
+
},
|
|
3526
|
+
value(token) {
|
|
3527
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3531
|
+
if (isElementDebugData(item)) return null;
|
|
3532
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3533
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3534
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3535
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3536
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3537
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3538
|
+
}
|
|
3539
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3540
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3541
|
+
return null;
|
|
3542
|
+
}
|
|
3543
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3544
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3545
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3546
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3547
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3548
|
+
if (key && tokens) tokenBindings.push({
|
|
3549
|
+
data: key,
|
|
3550
|
+
tokens
|
|
3551
|
+
});
|
|
3552
|
+
return key;
|
|
3553
|
+
}
|
|
3554
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3555
|
+
return null;
|
|
3556
|
+
}
|
|
3557
|
+
//#endregion
|
|
3558
|
+
//#region atomic/rule.ts
|
|
3559
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3560
|
+
const cssProp = getCssPropertyName(property);
|
|
3561
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3562
|
+
const escapedClass = escapeCssIdent(className);
|
|
3563
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3564
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3565
|
+
let selectorStr = classSelector + itemSelector;
|
|
3566
|
+
if (parentSelector) {
|
|
3567
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3568
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3569
|
+
}
|
|
3570
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3571
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3572
|
+
return rule;
|
|
3573
|
+
}
|
|
3574
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3575
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3576
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3577
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3578
|
+
return [
|
|
3579
|
+
priority ?? 0,
|
|
3580
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3581
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3582
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3583
|
+
atRules ? atRules.length : 0,
|
|
3584
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3585
|
+
getPropertyPriority(property)
|
|
3586
|
+
];
|
|
3587
|
+
}
|
|
3588
|
+
function getMediaPriority(atRules, priority) {
|
|
3589
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3590
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3591
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3592
|
+
}
|
|
3593
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3594
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3595
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3596
|
+
return LayerSelectorPriorities.base;
|
|
3597
|
+
}
|
|
3598
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3599
|
+
if (!parentSelector) return 0;
|
|
3600
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3601
|
+
}
|
|
3602
|
+
function getAtRulePriority$1(atRules) {
|
|
3603
|
+
if (!atRules?.length) return 0;
|
|
3604
|
+
let priority = 0;
|
|
3605
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3606
|
+
return priority;
|
|
3607
|
+
}
|
|
3608
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3609
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3610
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3611
|
+
}
|
|
3612
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3613
|
+
const declarations = [];
|
|
3614
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3615
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3616
|
+
}
|
|
3617
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3618
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3619
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3620
|
+
return name + ":" + value;
|
|
3621
|
+
}
|
|
3622
|
+
function normalizeThemeName(value) {
|
|
3623
|
+
if (!value) return null;
|
|
3624
|
+
value = value.trim();
|
|
3625
|
+
if (!value) return null;
|
|
3626
|
+
if (/^\d+$/.test(value)) return null;
|
|
3627
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3628
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3629
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3630
|
+
value = stripGenericThemePrefix(value);
|
|
3631
|
+
if (!value) return null;
|
|
3632
|
+
return value;
|
|
3633
|
+
}
|
|
3634
|
+
function stripGenericThemePrefix(value) {
|
|
3635
|
+
const parts = value.split("--");
|
|
3636
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3637
|
+
value = parts.join("--");
|
|
3638
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3639
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3640
|
+
return value;
|
|
3641
|
+
}
|
|
3642
|
+
function isGeneratedNameHash(value) {
|
|
3643
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3644
|
+
}
|
|
3645
|
+
createNameFormatter(["name"]);
|
|
3646
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3647
|
+
//#endregion
|
|
2848
3648
|
//#region style/keyframes.ts
|
|
2849
3649
|
function transformKeyframes(frames, transform) {
|
|
2850
3650
|
if (!transform) return frames;
|
|
@@ -2871,9 +3671,11 @@ function createStyleFn(args) {
|
|
|
2871
3671
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2872
3672
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2873
3673
|
const fnScope = createScopeBuilder(selectors);
|
|
2874
|
-
const
|
|
2875
|
-
|
|
3674
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3675
|
+
const fnWeight = (value, weight) => {
|
|
3676
|
+
return weightValue(value, weight);
|
|
2876
3677
|
};
|
|
3678
|
+
const fnImportant = (value) => importantValue(value);
|
|
2877
3679
|
const fnRaw = (style) => style;
|
|
2878
3680
|
const fnPlain = (style) => style;
|
|
2879
3681
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2885,11 +3687,13 @@ function createStyleFn(args) {
|
|
|
2885
3687
|
const style = fnStyle;
|
|
2886
3688
|
style.slot = fnSlot;
|
|
2887
3689
|
style.scope = fnScope;
|
|
2888
|
-
style.
|
|
3690
|
+
style.weight = fnWeight;
|
|
3691
|
+
style.important = fnImportant;
|
|
2889
3692
|
style.raw = fnRaw;
|
|
2890
3693
|
style.plain = fnPlain;
|
|
2891
3694
|
style.keyframes = fnKeyframes;
|
|
2892
3695
|
style.merge = fnMerge;
|
|
3696
|
+
style.selector = fnSelector;
|
|
2893
3697
|
assignStyleFnMeta(style, {
|
|
2894
3698
|
mode: "StyleObject",
|
|
2895
3699
|
selectors,
|
|
@@ -2930,9 +3734,11 @@ function createImportSourceMatcher(importSources) {
|
|
|
2930
3734
|
meta: DefaultStyleFnMeta
|
|
2931
3735
|
});
|
|
2932
3736
|
importSources?.forEach((entry) => {
|
|
3737
|
+
const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
|
|
3738
|
+
if (!meta) return;
|
|
2933
3739
|
addImportSourceEntry(state, {
|
|
2934
3740
|
...entry,
|
|
2935
|
-
meta
|
|
3741
|
+
meta
|
|
2936
3742
|
});
|
|
2937
3743
|
});
|
|
2938
3744
|
return (source) => {
|
|
@@ -3024,65 +3830,6 @@ function isGlobPattern(source) {
|
|
|
3024
3830
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
3025
3831
|
}
|
|
3026
3832
|
//#endregion
|
|
3027
|
-
//#region builder/extract/utils.ts
|
|
3028
|
-
function createExtractedData(type, slotId) {
|
|
3029
|
-
const data = {
|
|
3030
|
-
[BUILDER_TYPE]: type,
|
|
3031
|
-
[BUILDER_STATE]: {
|
|
3032
|
-
items: [],
|
|
3033
|
-
lookup: {}
|
|
3034
|
-
},
|
|
3035
|
-
[BUILDER_CALLSITE]: null
|
|
3036
|
-
};
|
|
3037
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3038
|
-
return data;
|
|
3039
|
-
}
|
|
3040
|
-
function copyExtractedData(target, source) {
|
|
3041
|
-
const mutable = target;
|
|
3042
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3043
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3044
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3045
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3046
|
-
}
|
|
3047
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
3048
|
-
return {
|
|
3049
|
-
[BUILDER_TYPE]: 5,
|
|
3050
|
-
[BUILDER_SCOPE]: scope,
|
|
3051
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3052
|
-
};
|
|
3053
|
-
}
|
|
3054
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
3055
|
-
const normalized = [];
|
|
3056
|
-
let i = 0;
|
|
3057
|
-
while (i < items.length) {
|
|
3058
|
-
const item = items[i];
|
|
3059
|
-
const value = item[2];
|
|
3060
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
3061
|
-
type,
|
|
3062
|
-
item[0],
|
|
3063
|
-
item[1]
|
|
3064
|
-
] : [
|
|
3065
|
-
type,
|
|
3066
|
-
slotId,
|
|
3067
|
-
item[0],
|
|
3068
|
-
item[1]
|
|
3069
|
-
] : slotId === null ? [
|
|
3070
|
-
type,
|
|
3071
|
-
item[0],
|
|
3072
|
-
item[1],
|
|
3073
|
-
value
|
|
3074
|
-
] : [
|
|
3075
|
-
type,
|
|
3076
|
-
slotId,
|
|
3077
|
-
item[0],
|
|
3078
|
-
item[1],
|
|
3079
|
-
value
|
|
3080
|
-
]);
|
|
3081
|
-
i++;
|
|
3082
|
-
}
|
|
3083
|
-
return normalized;
|
|
3084
|
-
}
|
|
3085
|
-
//#endregion
|
|
3086
3833
|
//#region builder/extract/scope.ts
|
|
3087
3834
|
function createExtractedScope(items) {
|
|
3088
3835
|
const scope = ((slot) => {
|
|
@@ -3093,6 +3840,15 @@ function createExtractedScope(items) {
|
|
|
3093
3840
|
return scope;
|
|
3094
3841
|
}
|
|
3095
3842
|
//#endregion
|
|
3843
|
+
//#region builder/extract/sheet.ts
|
|
3844
|
+
function createExtractedSheet(items) {
|
|
3845
|
+
const data = createExtractedData(9);
|
|
3846
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3847
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3848
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3849
|
+
return data;
|
|
3850
|
+
}
|
|
3851
|
+
//#endregion
|
|
3096
3852
|
//#region builder/extract/slot.ts
|
|
3097
3853
|
function createExtractedSlot(slotId, items) {
|
|
3098
3854
|
const slot = ((items) => {
|
|
@@ -3236,7 +3992,7 @@ function exposeStyleObject(source) {
|
|
|
3236
3992
|
return result;
|
|
3237
3993
|
}
|
|
3238
3994
|
function exposeStyleValue(value) {
|
|
3239
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
3995
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3240
3996
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3241
3997
|
const exposed = exposeStyleObject(value);
|
|
3242
3998
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3450,6 +4206,12 @@ function evaluateCall(node, scope) {
|
|
|
3450
4206
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3451
4207
|
return evalOk(createExtractedStyle(items.value));
|
|
3452
4208
|
}
|
|
4209
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4210
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4211
|
+
if (!items.ok) return items;
|
|
4212
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4213
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4214
|
+
}
|
|
3453
4215
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3454
4216
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3455
4217
|
if (!style.ok) return style;
|
|
@@ -3638,13 +4400,18 @@ function evaluateCall(node, scope) {
|
|
|
3638
4400
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3639
4401
|
}));
|
|
3640
4402
|
}
|
|
3641
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4403
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
3642
4404
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3643
4405
|
if (!value.ok) return value;
|
|
3644
4406
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3645
4407
|
if (!weight.ok) return weight;
|
|
3646
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3647
|
-
return evalOk(
|
|
4408
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4409
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4410
|
+
}
|
|
4411
|
+
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)) {
|
|
4412
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4413
|
+
if (!value.ok) return value;
|
|
4414
|
+
return evalOk(importantValue(value.value));
|
|
3648
4415
|
}
|
|
3649
4416
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
3650
4417
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3848,65 +4615,28 @@ function evaluateUnary(node, scope) {
|
|
|
3848
4615
|
//#region compiler/transform/syntax/isStaticStyleValue.ts
|
|
3849
4616
|
function isStaticStyleValue(value) {
|
|
3850
4617
|
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3851
|
-
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3852
|
-
if (value.type === "
|
|
3853
|
-
const [
|
|
3854
|
-
return !!
|
|
3855
|
-
}
|
|
3856
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "
|
|
3857
|
-
const [itemValue
|
|
3858
|
-
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue)
|
|
3859
|
-
}
|
|
3860
|
-
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3861
|
-
return false;
|
|
3862
|
-
}
|
|
3863
|
-
//#endregion
|
|
3864
|
-
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
3865
|
-
function isStyleChainCall(callee, styleNames) {
|
|
3866
|
-
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
3867
|
-
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
3868
|
-
const object = callee.object;
|
|
3869
|
-
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
3870
|
-
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
3871
|
-
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3872
|
-
return false;
|
|
3873
|
-
}
|
|
3874
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3875
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3876
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3877
|
-
}
|
|
3878
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3879
|
-
const declarations = [];
|
|
3880
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3881
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3882
|
-
}
|
|
3883
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3884
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3885
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3886
|
-
return name + ":" + value;
|
|
3887
|
-
}
|
|
3888
|
-
function normalizeThemeName(value) {
|
|
3889
|
-
if (!value) return null;
|
|
3890
|
-
value = value.trim();
|
|
3891
|
-
if (!value) return null;
|
|
3892
|
-
if (/^\d+$/.test(value)) return null;
|
|
3893
|
-
if (isGeneratedNameHash(value)) return null;
|
|
3894
|
-
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3895
|
-
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3896
|
-
value = stripGenericThemePrefix(value);
|
|
3897
|
-
if (!value) return null;
|
|
3898
|
-
return value;
|
|
3899
|
-
}
|
|
3900
|
-
function stripGenericThemePrefix(value) {
|
|
3901
|
-
const parts = value.split("--");
|
|
3902
|
-
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3903
|
-
value = parts.join("--");
|
|
3904
|
-
if (value.startsWith("theme-")) return value.slice(6);
|
|
3905
|
-
if (value.startsWith("themes-")) return value.slice(7);
|
|
3906
|
-
return value;
|
|
4618
|
+
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
4619
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
4620
|
+
const [itemValue, weight] = value.arguments;
|
|
4621
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
4622
|
+
}
|
|
4623
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4624
|
+
const [itemValue] = value.arguments;
|
|
4625
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4626
|
+
}
|
|
4627
|
+
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
4628
|
+
return false;
|
|
3907
4629
|
}
|
|
3908
|
-
|
|
3909
|
-
|
|
4630
|
+
//#endregion
|
|
4631
|
+
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
4632
|
+
function isStyleChainCall(callee, styleNames) {
|
|
4633
|
+
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
4634
|
+
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
4635
|
+
const object = callee.object;
|
|
4636
|
+
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
4637
|
+
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
4638
|
+
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
4639
|
+
return false;
|
|
3910
4640
|
}
|
|
3911
4641
|
//#endregion
|
|
3912
4642
|
//#region compiler/transform/syntax/utils.ts
|
|
@@ -4042,60 +4772,6 @@ function sanitizeTokenId(value) {
|
|
|
4042
4772
|
return sanitizeCssIdentName(value, "token");
|
|
4043
4773
|
}
|
|
4044
4774
|
//#endregion
|
|
4045
|
-
//#region compiler/transform/utils/babel.ts
|
|
4046
|
-
function babelPlugin(factory) {
|
|
4047
|
-
return factory;
|
|
4048
|
-
}
|
|
4049
|
-
function babelTransform(args) {
|
|
4050
|
-
let result = null;
|
|
4051
|
-
try {
|
|
4052
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
4053
|
-
result = _babel_core.transformSync(args.code, {
|
|
4054
|
-
...babelTransformOptions(),
|
|
4055
|
-
inputSourceMap,
|
|
4056
|
-
filename: args.filePath,
|
|
4057
|
-
sourceFileName: args.filePath,
|
|
4058
|
-
plugins: args.plugins,
|
|
4059
|
-
sourceMaps: true,
|
|
4060
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
4061
|
-
});
|
|
4062
|
-
} catch (err) {
|
|
4063
|
-
if (!args.errorLabel) throw err;
|
|
4064
|
-
const message = getBabelError(err, args);
|
|
4065
|
-
const error = new Error(message);
|
|
4066
|
-
error.stack = void 0;
|
|
4067
|
-
throw error;
|
|
4068
|
-
}
|
|
4069
|
-
if (!result || !result.code) return null;
|
|
4070
|
-
return {
|
|
4071
|
-
code: result.code,
|
|
4072
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
4073
|
-
};
|
|
4074
|
-
}
|
|
4075
|
-
function babelTransformOptions() {
|
|
4076
|
-
return {
|
|
4077
|
-
configFile: false,
|
|
4078
|
-
babelrc: false,
|
|
4079
|
-
parserOpts: {
|
|
4080
|
-
plugins: ["typescript", "jsx"],
|
|
4081
|
-
strictMode: false,
|
|
4082
|
-
allowImportExportEverywhere: true
|
|
4083
|
-
}
|
|
4084
|
-
};
|
|
4085
|
-
}
|
|
4086
|
-
function parseInputSourceMap(sourcemap) {
|
|
4087
|
-
if (!sourcemap) return void 0;
|
|
4088
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
4089
|
-
return JSON.parse(sourcemap);
|
|
4090
|
-
}
|
|
4091
|
-
function getBabelError(err, args) {
|
|
4092
|
-
const babelErr = err;
|
|
4093
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
4094
|
-
const codeFrame = babelErr?.codeFrame;
|
|
4095
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
4096
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
4097
|
-
}
|
|
4098
|
-
//#endregion
|
|
4099
4775
|
//#region compiler/transform/utils/path.ts
|
|
4100
4776
|
function getProjectFileId$1(projectDir, filePath) {
|
|
4101
4777
|
if (!filePath) return "unknown";
|
|
@@ -4614,6 +5290,7 @@ function getDebugCallLoc(path, state) {
|
|
|
4614
5290
|
}
|
|
4615
5291
|
function getStyleObjectArg(path, state) {
|
|
4616
5292
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5293
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4617
5294
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4618
5295
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4619
5296
|
if (!selector) return path.node.arguments[0];
|
|
@@ -5038,7 +5715,7 @@ function transformDebug(internal, args, deps) {
|
|
|
5038
5715
|
code: args.code,
|
|
5039
5716
|
filePath: args.filePath,
|
|
5040
5717
|
sourcemap: args.sourcemap,
|
|
5041
|
-
plugins: [plugin],
|
|
5718
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
5042
5719
|
retainLines: true
|
|
5043
5720
|
});
|
|
5044
5721
|
if (!result) return null;
|
|
@@ -5107,59 +5784,9 @@ function resolveFilePath(source, fromFile) {
|
|
|
5107
5784
|
}
|
|
5108
5785
|
}
|
|
5109
5786
|
//#endregion
|
|
5110
|
-
//#region atomic/rule.ts
|
|
5111
|
-
function buildAtomicRule(className, property, value, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
5112
|
-
const cssProp = getCssPropertyName(property);
|
|
5113
|
-
const cssValue = getCssPropertyValue(property, value);
|
|
5114
|
-
const classSelector = "." + escapeCssIdent(className);
|
|
5115
|
-
const itemSelector = selector ? getSelectorText(selector) : "";
|
|
5116
|
-
let selectorStr = classSelector + itemSelector;
|
|
5117
|
-
if (parentSelector) {
|
|
5118
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
5119
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
5120
|
-
}
|
|
5121
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
5122
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
5123
|
-
return rule;
|
|
5124
|
-
}
|
|
5125
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
5126
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
5127
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
5128
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
5129
|
-
return [
|
|
5130
|
-
priority ?? 0,
|
|
5131
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
5132
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
5133
|
-
getMediaPriority(atRules, atRulePriority),
|
|
5134
|
-
atRules ? atRules.length : 0,
|
|
5135
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
5136
|
-
getPropertyPriority(property)
|
|
5137
|
-
];
|
|
5138
|
-
}
|
|
5139
|
-
function getMediaPriority(atRules, priority) {
|
|
5140
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
5141
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
5142
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
5143
|
-
}
|
|
5144
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
5145
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
5146
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
5147
|
-
return LayerSelectorPriorities.base;
|
|
5148
|
-
}
|
|
5149
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
5150
|
-
if (!parentSelector) return 0;
|
|
5151
|
-
return priority > 0 ? priority + 1 : 1;
|
|
5152
|
-
}
|
|
5153
|
-
function getAtRulePriority$1(atRules) {
|
|
5154
|
-
if (!atRules?.length) return 0;
|
|
5155
|
-
let priority = 0;
|
|
5156
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
5157
|
-
return priority;
|
|
5158
|
-
}
|
|
5159
|
-
//#endregion
|
|
5160
5787
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
5161
5788
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
5162
|
-
function extractStyleChain(node, styleNames) {
|
|
5789
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5163
5790
|
if (node.type !== "CallExpression") return null;
|
|
5164
5791
|
const callee = node.callee;
|
|
5165
5792
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -5168,6 +5795,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
5168
5795
|
baseArgs: node.arguments,
|
|
5169
5796
|
methods: []
|
|
5170
5797
|
};
|
|
5798
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5799
|
+
kind: "sheet",
|
|
5800
|
+
rootName: callee.name,
|
|
5801
|
+
baseArgs: node.arguments,
|
|
5802
|
+
methods: []
|
|
5803
|
+
};
|
|
5171
5804
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5172
5805
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
5173
5806
|
if (!prop) return null;
|
|
@@ -5185,10 +5818,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
5185
5818
|
baseArgs: node.arguments,
|
|
5186
5819
|
methods: []
|
|
5187
5820
|
};
|
|
5821
|
+
if (prop === "selector") return {
|
|
5822
|
+
kind: "selector",
|
|
5823
|
+
rootName: obj.name,
|
|
5824
|
+
baseArgs: node.arguments,
|
|
5825
|
+
methods: []
|
|
5826
|
+
};
|
|
5188
5827
|
if (prop !== "merge") return null;
|
|
5189
5828
|
const target = node.arguments[0];
|
|
5190
5829
|
if (!target) return null;
|
|
5191
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5830
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
5192
5831
|
if (!targetChain) return null;
|
|
5193
5832
|
return {
|
|
5194
5833
|
...targetChain,
|
|
@@ -5200,7 +5839,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
5200
5839
|
};
|
|
5201
5840
|
}
|
|
5202
5841
|
if (obj.type === "CallExpression") {
|
|
5203
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5842
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
5204
5843
|
if (!inner) return null;
|
|
5205
5844
|
return {
|
|
5206
5845
|
...inner,
|
|
@@ -5224,18 +5863,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
5224
5863
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5225
5864
|
let result = null;
|
|
5226
5865
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5227
|
-
const
|
|
5866
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5867
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
5228
5868
|
if (!runtimeValue) continue;
|
|
5229
5869
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5230
5870
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5231
5871
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
5232
|
-
|
|
5872
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5873
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
5233
5874
|
}
|
|
5234
5875
|
return result ?? styleObj;
|
|
5235
5876
|
}
|
|
5236
|
-
function getPriorityTupleValue(value) {
|
|
5237
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5238
|
-
}
|
|
5239
5877
|
function cloneCompiledStyleObject(styleObj) {
|
|
5240
5878
|
const cloned = { ...styleObj };
|
|
5241
5879
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5318,9 +5956,11 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5318
5956
|
*/
|
|
5319
5957
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5320
5958
|
const css = getCssConfig(opts, runtimeMode);
|
|
5959
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5960
|
+
if (!meta) return null;
|
|
5321
5961
|
if (meta.mode === "ClassName") {
|
|
5322
5962
|
if (chain.kind !== "style") return null;
|
|
5323
|
-
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5963
|
+
return compileClassNameChain(chain, meta.selectors, fileId, nodeLoc, scope, css, meta.transform, styleNames, opts);
|
|
5324
5964
|
}
|
|
5325
5965
|
const selectors = meta.selectors;
|
|
5326
5966
|
const transform = meta.transform;
|
|
@@ -5329,16 +5969,101 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5329
5969
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5330
5970
|
return null;
|
|
5331
5971
|
}
|
|
5972
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5973
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5974
|
+
const items = [];
|
|
5975
|
+
const rules = [];
|
|
5976
|
+
const sheetItems = chain.baseArgs[0];
|
|
5977
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5978
|
+
return {
|
|
5979
|
+
type: "sheet",
|
|
5980
|
+
items,
|
|
5981
|
+
rules
|
|
5982
|
+
};
|
|
5983
|
+
}
|
|
5984
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5985
|
+
if (node.type === "ArrayExpression") {
|
|
5986
|
+
for (const element of node.elements) {
|
|
5987
|
+
if (!element) continue;
|
|
5988
|
+
if (element.type === "SpreadElement") return false;
|
|
5989
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
5990
|
+
}
|
|
5991
|
+
return true;
|
|
5992
|
+
}
|
|
5993
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
5994
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
5995
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
5996
|
+
return true;
|
|
5997
|
+
}
|
|
5998
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
5999
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
6000
|
+
const item = tokenOverride.value[i];
|
|
6001
|
+
if (!item) continue;
|
|
6002
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
6003
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
6004
|
+
}
|
|
6005
|
+
return true;
|
|
6006
|
+
}
|
|
6007
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
6008
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
6009
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
6010
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
6011
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
6012
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
6013
|
+
}
|
|
6014
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
6015
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
6016
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
6017
|
+
if (!selectorArg.ok) return false;
|
|
6018
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
6019
|
+
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;
|
|
6020
|
+
return true;
|
|
6021
|
+
}
|
|
6022
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
6023
|
+
if (chain.baseArgs[1]) {
|
|
6024
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
6025
|
+
}
|
|
6026
|
+
let i = 0;
|
|
6027
|
+
while (i < chain.methods.length) {
|
|
6028
|
+
const method = chain.methods[i];
|
|
6029
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
6030
|
+
i++;
|
|
6031
|
+
}
|
|
6032
|
+
return true;
|
|
6033
|
+
}
|
|
6034
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
6035
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
6036
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
6037
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6038
|
+
if (styleArgNode.type === "CallExpression") {
|
|
6039
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
6040
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
6041
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6042
|
+
}
|
|
6043
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
6044
|
+
if (!styleArg.ok) {
|
|
6045
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
6046
|
+
return false;
|
|
6047
|
+
}
|
|
6048
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6049
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6050
|
+
}
|
|
5332
6051
|
function getCssConfig(opts, runtimeMode) {
|
|
5333
6052
|
const css = opts.css;
|
|
5334
6053
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
6054
|
+
const debugClassName = css?.debugClassName ?? isDevRuntimeMode;
|
|
5335
6055
|
return {
|
|
5336
6056
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
6057
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5337
6058
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5338
|
-
hashLength:
|
|
6059
|
+
hashLength: getClassNameHashLength({
|
|
6060
|
+
debugClassName,
|
|
6061
|
+
isDev: isDevRuntimeMode,
|
|
6062
|
+
cssHashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength
|
|
6063
|
+
}),
|
|
5339
6064
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
5340
6065
|
localClassName: isDevRuntimeMode,
|
|
5341
|
-
debugClassName
|
|
6066
|
+
debugClassName,
|
|
5342
6067
|
scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
|
|
5343
6068
|
};
|
|
5344
6069
|
}
|
|
@@ -5356,10 +6081,10 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5356
6081
|
rules
|
|
5357
6082
|
};
|
|
5358
6083
|
}
|
|
5359
|
-
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
6084
|
+
function compileClassNameChain(chain, selectors, fileId, nodeLoc, scope, cssConfig, transform, styleNames, options) {
|
|
5360
6085
|
const items = [];
|
|
5361
6086
|
const rules = [];
|
|
5362
|
-
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
6087
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, createClassNameFallbackLocation(nodeLoc, scope, fileId), cssConfig, transform, 1, null, items, rules)) return null;
|
|
5363
6088
|
let i = 0;
|
|
5364
6089
|
while (i < chain.methods.length) {
|
|
5365
6090
|
const method = chain.methods[i];
|
|
@@ -5381,7 +6106,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5381
6106
|
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5382
6107
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5383
6108
|
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5384
|
-
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
6109
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, method.nameNode.loc?.start, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5385
6110
|
if (!result) return false;
|
|
5386
6111
|
items.push(...result.items);
|
|
5387
6112
|
rules.push(...result.rules);
|
|
@@ -5406,7 +6131,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5406
6131
|
}
|
|
5407
6132
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5408
6133
|
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5409
|
-
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6134
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5410
6135
|
}
|
|
5411
6136
|
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5412
6137
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5416,14 +6141,15 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5416
6141
|
if (!selectorArg.ok) return false;
|
|
5417
6142
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5418
6143
|
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5419
|
-
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6144
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5420
6145
|
}
|
|
5421
6146
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5422
|
-
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6147
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5423
6148
|
}
|
|
5424
|
-
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
6149
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, fallbackLocation, cssConfig, transform, type, slotId, items, rules) {
|
|
5425
6150
|
if (startIndex >= args.length) return true;
|
|
5426
6151
|
const styleObj = {};
|
|
6152
|
+
const locations = {};
|
|
5427
6153
|
let i = startIndex;
|
|
5428
6154
|
while (i < args.length) {
|
|
5429
6155
|
const arg = evaluateNode(args[i], scope);
|
|
@@ -5431,28 +6157,59 @@ function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, s
|
|
|
5431
6157
|
throwIfRequiredStaticStyleValue(arg);
|
|
5432
6158
|
return false;
|
|
5433
6159
|
}
|
|
5434
|
-
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
6160
|
+
if (!appendClassNameArgStyle(args[i], arg.value, transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
|
|
5435
6161
|
i++;
|
|
5436
6162
|
}
|
|
6163
|
+
if (Object.keys(locations).length) Object.defineProperty(styleObj, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
6164
|
+
configurable: true,
|
|
6165
|
+
enumerable: false,
|
|
6166
|
+
value: locations
|
|
6167
|
+
});
|
|
5437
6168
|
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5438
6169
|
}
|
|
5439
|
-
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
6170
|
+
function appendClassNameArgStyle(node, value, transform, styleObj, locations, fallbackLocation, scope, fileId) {
|
|
5440
6171
|
if (!value) return true;
|
|
5441
6172
|
if (typeof value === "string") {
|
|
5442
|
-
|
|
6173
|
+
const transformed = decorateClassNameStyle(transform.transform(value), value);
|
|
6174
|
+
Object.assign(styleObj, transformed);
|
|
6175
|
+
assignClassNameStyleLocations(transformed, locations, getClassNameArgLocation(node, fallbackLocation, scope, fileId));
|
|
5443
6176
|
return true;
|
|
5444
6177
|
}
|
|
5445
6178
|
if (Array.isArray(value)) {
|
|
5446
|
-
|
|
6179
|
+
const nodes = node.type === "ArrayExpression" ? node.elements : [];
|
|
6180
|
+
for (let i = 0; i < value.length; i++) if (!appendClassNameArgStyle(nodes[i] ?? node, value[i], transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
|
|
5447
6181
|
return true;
|
|
5448
6182
|
}
|
|
5449
6183
|
if (isWeightedClassName(value)) {
|
|
5450
6184
|
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5451
6185
|
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
6186
|
+
assignClassNameStyleLocations(transformed, locations, getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId));
|
|
5452
6187
|
return true;
|
|
5453
6188
|
}
|
|
5454
6189
|
return false;
|
|
5455
6190
|
}
|
|
6191
|
+
function assignClassNameStyleLocations(styleObj, locations, location) {
|
|
6192
|
+
if (!location) return;
|
|
6193
|
+
for (const property of Object.keys(styleObj)) locations[property] = location;
|
|
6194
|
+
}
|
|
6195
|
+
function getClassNameArgLocation(node, fallbackLocation, scope, fileId) {
|
|
6196
|
+
if (node.type === "StringLiteral") return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
|
|
6197
|
+
if (node.type === "TemplateLiteral" && node.expressions.length === 0) return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
|
|
6198
|
+
return fallbackLocation;
|
|
6199
|
+
}
|
|
6200
|
+
function getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId) {
|
|
6201
|
+
if (node.type === "CallExpression" && node.arguments[0] && node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight") return getClassNameArgLocation(node.arguments[0], fallbackLocation, scope, fileId);
|
|
6202
|
+
return fallbackLocation;
|
|
6203
|
+
}
|
|
6204
|
+
function createClassNameFallbackLocation(loc, scope, fileId) {
|
|
6205
|
+
if (!loc) return null;
|
|
6206
|
+
return {
|
|
6207
|
+
filePath: scope.styleFilePath ?? fileId,
|
|
6208
|
+
line: loc.line,
|
|
6209
|
+
column: loc.column + 1,
|
|
6210
|
+
variable: false
|
|
6211
|
+
};
|
|
6212
|
+
}
|
|
5456
6213
|
function decorateClassNameStyle(style, className) {
|
|
5457
6214
|
const result = {};
|
|
5458
6215
|
for (const [property, value] of Object.entries(style)) {
|
|
@@ -5460,15 +6217,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5460
6217
|
result[property] = value;
|
|
5461
6218
|
continue;
|
|
5462
6219
|
}
|
|
5463
|
-
|
|
5464
|
-
const rawValue = value[1];
|
|
5465
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5466
|
-
continue;
|
|
5467
|
-
}
|
|
5468
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6220
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5469
6221
|
}
|
|
5470
6222
|
return result;
|
|
5471
6223
|
}
|
|
6224
|
+
function decorateClassNameValue(value, className) {
|
|
6225
|
+
if (isClassNameValue(value)) return value;
|
|
6226
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6227
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6228
|
+
return classNameValue(value, className);
|
|
6229
|
+
}
|
|
5472
6230
|
function isWeightedClassName(value) {
|
|
5473
6231
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5474
6232
|
}
|
|
@@ -5479,23 +6237,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5479
6237
|
weighted[property] = value;
|
|
5480
6238
|
continue;
|
|
5481
6239
|
}
|
|
5482
|
-
weighted[property] =
|
|
6240
|
+
weighted[property] = weightValue(value, weight);
|
|
5483
6241
|
}
|
|
5484
6242
|
return weighted;
|
|
5485
6243
|
}
|
|
5486
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6244
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5487
6245
|
if (chain.baseArgs.length > 0) {
|
|
5488
6246
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5489
6247
|
if (!styleArg.ok) {
|
|
5490
6248
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5491
6249
|
return false;
|
|
5492
6250
|
}
|
|
5493
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6251
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5494
6252
|
}
|
|
5495
6253
|
let i = 0;
|
|
5496
6254
|
while (i < chain.methods.length) {
|
|
5497
6255
|
const method = chain.methods[i];
|
|
5498
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6256
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5499
6257
|
i++;
|
|
5500
6258
|
}
|
|
5501
6259
|
return true;
|
|
@@ -5542,7 +6300,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5542
6300
|
rules
|
|
5543
6301
|
};
|
|
5544
6302
|
}
|
|
5545
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6303
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5546
6304
|
const selector = selectors[method.name];
|
|
5547
6305
|
if (!selector) return false;
|
|
5548
6306
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5815,10 +6573,10 @@ function getSlotIdFromValue(value) {
|
|
|
5815
6573
|
const slotId = value.slotId;
|
|
5816
6574
|
return typeof slotId === "string" ? slotId : null;
|
|
5817
6575
|
}
|
|
5818
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6576
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5819
6577
|
if (method.name === "$$style.merge") {
|
|
5820
6578
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5821
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6579
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5822
6580
|
}
|
|
5823
6581
|
const selector = selectors[method.name];
|
|
5824
6582
|
if (!selector) return false;
|
|
@@ -5826,42 +6584,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5826
6584
|
const selectorStr = selector.selector.trim();
|
|
5827
6585
|
if (selectorStr === "...") {
|
|
5828
6586
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5829
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6587
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5830
6588
|
}
|
|
5831
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5832
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6589
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6590
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5833
6591
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6592
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5834
6593
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5835
6594
|
if (!styleArg.ok) {
|
|
5836
6595
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5837
6596
|
return false;
|
|
5838
6597
|
}
|
|
5839
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6598
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5840
6599
|
}
|
|
5841
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6600
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5842
6601
|
if (!styleArgNode) return false;
|
|
5843
6602
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5844
6603
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5845
6604
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5846
|
-
if (
|
|
6605
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5847
6606
|
if (styleArgNode.type === "CallExpression") {
|
|
5848
6607
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5849
6608
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5850
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6609
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5851
6610
|
}
|
|
5852
6611
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5853
6612
|
if (!styleArg.ok) {
|
|
5854
6613
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5855
6614
|
return false;
|
|
5856
6615
|
}
|
|
5857
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5858
|
-
return addStyleDataItems(styleArg.value,
|
|
6616
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6617
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5859
6618
|
}
|
|
5860
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6619
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5861
6620
|
if (node.type !== "Identifier") return null;
|
|
5862
6621
|
const init = scope.bindingNodes?.get(node.name);
|
|
5863
6622
|
if (!init) return null;
|
|
5864
|
-
return extractStyleChain(init, styleNames);
|
|
6623
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6624
|
+
}
|
|
6625
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6626
|
+
const callee = node.callee;
|
|
6627
|
+
if (callee.type === "Identifier") {
|
|
6628
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6629
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6630
|
+
return {
|
|
6631
|
+
...target,
|
|
6632
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6633
|
+
};
|
|
6634
|
+
}
|
|
6635
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6636
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6637
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6638
|
+
...memberTarget,
|
|
6639
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6640
|
+
};
|
|
6641
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6642
|
+
if (!methodName) return null;
|
|
6643
|
+
const object = callee.object;
|
|
6644
|
+
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;
|
|
6645
|
+
if (target?.kind !== "selector") return null;
|
|
6646
|
+
return {
|
|
6647
|
+
...target,
|
|
6648
|
+
methods: [...target.methods, {
|
|
6649
|
+
name: methodName,
|
|
6650
|
+
args: node.arguments,
|
|
6651
|
+
nameNode: callee.property
|
|
6652
|
+
}]
|
|
6653
|
+
};
|
|
6654
|
+
}
|
|
6655
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6656
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6657
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6658
|
+
if (!propertyName) return null;
|
|
6659
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6660
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6661
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6662
|
+
const property = objectInit.properties[i];
|
|
6663
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6664
|
+
const key = property.key;
|
|
6665
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6666
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6667
|
+
}
|
|
6668
|
+
return null;
|
|
6669
|
+
}
|
|
6670
|
+
function isBareSelectorTargetChain(chain) {
|
|
6671
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5865
6672
|
}
|
|
5866
6673
|
function getLocalBindingNode(node, scope) {
|
|
5867
6674
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5889,7 +6696,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5889
6696
|
default: return false;
|
|
5890
6697
|
}
|
|
5891
6698
|
}
|
|
5892
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6699
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5893
6700
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5894
6701
|
const hasArg = selectorStr.includes("$$");
|
|
5895
6702
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5911,22 +6718,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5911
6718
|
if (styleArg.type === "CallExpression") {
|
|
5912
6719
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5913
6720
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5914
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6721
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5915
6722
|
const evaled = evaluateNode(styleArg, scope);
|
|
5916
6723
|
if (!evaled.ok) {
|
|
5917
6724
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5918
6725
|
return false;
|
|
5919
6726
|
}
|
|
5920
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6727
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5921
6728
|
}
|
|
5922
6729
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5923
6730
|
if (!styleResult.ok) {
|
|
5924
6731
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5925
6732
|
return false;
|
|
5926
6733
|
}
|
|
5927
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6734
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5928
6735
|
}
|
|
5929
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6736
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5930
6737
|
const selectorStr = selector.selector.trim();
|
|
5931
6738
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5932
6739
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5948,7 +6755,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5948
6755
|
while (i < selectorValues.length) {
|
|
5949
6756
|
const itemSelectorValue = selectorValues[i];
|
|
5950
6757
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5951
|
-
|
|
6758
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6759
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5952
6760
|
i++;
|
|
5953
6761
|
}
|
|
5954
6762
|
return true;
|
|
@@ -6017,6 +6825,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
6017
6825
|
dedupe: overrideItem.dedupe,
|
|
6018
6826
|
className: overrideItem.className,
|
|
6019
6827
|
property: overrideItem.property,
|
|
6828
|
+
weight: overrideItem.weight,
|
|
6829
|
+
important: overrideItem.important,
|
|
6020
6830
|
value: overrideItem.value,
|
|
6021
6831
|
variable: overrideItem.variable,
|
|
6022
6832
|
token: overrideItem.token,
|
|
@@ -6060,22 +6870,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
6060
6870
|
items.push(item);
|
|
6061
6871
|
}
|
|
6062
6872
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6063
|
-
|
|
6873
|
+
const weight = sourceItem.weight;
|
|
6874
|
+
let important = false;
|
|
6064
6875
|
let value = sourceItem.value;
|
|
6065
|
-
|
|
6066
|
-
priority = value[1];
|
|
6067
|
-
value = value[0];
|
|
6068
|
-
}
|
|
6876
|
+
important = sourceItem.important;
|
|
6069
6877
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
6070
6878
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6071
6879
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6072
6880
|
const valueStr = String(value ?? "");
|
|
6073
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6074
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6881
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6882
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6075
6883
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
6076
6884
|
items.push(item);
|
|
6077
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6078
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6885
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6886
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
6079
6887
|
cssRules.push({
|
|
6080
6888
|
dedupe,
|
|
6081
6889
|
className,
|
|
@@ -6138,21 +6946,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
6138
6946
|
items.push(item);
|
|
6139
6947
|
}
|
|
6140
6948
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6141
|
-
|
|
6949
|
+
const weight = sourceItem.weight;
|
|
6950
|
+
const important = sourceItem.important;
|
|
6142
6951
|
let value = sourceItem.value;
|
|
6143
|
-
|
|
6144
|
-
priority = value[1];
|
|
6145
|
-
value = value[0];
|
|
6146
|
-
}
|
|
6147
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6952
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
6148
6953
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6149
6954
|
const variable = sourceItem.variable;
|
|
6150
6955
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
6151
6956
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
6152
6957
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
6153
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6958
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
6154
6959
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6155
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6960
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6156
6961
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6157
6962
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
6158
6963
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -6160,8 +6965,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6160
6965
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
6161
6966
|
}
|
|
6162
6967
|
items.push(item);
|
|
6163
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6164
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6968
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6969
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
6165
6970
|
cssRules.push({
|
|
6166
6971
|
dedupe,
|
|
6167
6972
|
className,
|
|
@@ -6174,6 +6979,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6174
6979
|
} : void 0
|
|
6175
6980
|
});
|
|
6176
6981
|
}
|
|
6982
|
+
function combineSelectors(parent, child) {
|
|
6983
|
+
const parentText = getItemSelectorText(parent);
|
|
6984
|
+
const childText = getItemSelectorText(child);
|
|
6985
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6986
|
+
const selector = parentText + childText;
|
|
6987
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6988
|
+
}
|
|
6989
|
+
function getItemSelectorText(selector) {
|
|
6990
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6991
|
+
}
|
|
6992
|
+
function getItemSelectorPriority(selector) {
|
|
6993
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6994
|
+
}
|
|
6177
6995
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
6178
6996
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
6179
6997
|
if (!trace) return void 0;
|
|
@@ -6218,13 +7036,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6218
7036
|
while (i < keys.length) {
|
|
6219
7037
|
const property = keys[i];
|
|
6220
7038
|
const rawValue = styleObj[property];
|
|
6221
|
-
let
|
|
7039
|
+
let weight = null;
|
|
7040
|
+
let important = false;
|
|
6222
7041
|
let value = rawValue;
|
|
6223
7042
|
let transformClassName = null;
|
|
6224
|
-
|
|
6225
|
-
priority = rawValue[0];
|
|
6226
|
-
value = rawValue[1];
|
|
6227
|
-
}
|
|
7043
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
6228
7044
|
if (isClassNameValue(value)) {
|
|
6229
7045
|
transformClassName = value.className;
|
|
6230
7046
|
value = value.value;
|
|
@@ -6245,10 +7061,10 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6245
7061
|
column: propertyLoc.column
|
|
6246
7062
|
} : null);
|
|
6247
7063
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
6248
|
-
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
7064
|
+
const variableName = shouldUseVariable && propertyLoc && propertyLoc.variable !== false ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6249
7065
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
6250
|
-
const dedupe = getClassNameDedupe(property,
|
|
6251
|
-
const className = getAtomicClassName(property,
|
|
7066
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
7067
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6252
7068
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6253
7069
|
item.sourceTrace = propertyCallsite ? {
|
|
6254
7070
|
property,
|
|
@@ -6273,8 +7089,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6273
7089
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6274
7090
|
}
|
|
6275
7091
|
items.push(item);
|
|
6276
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6277
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
7092
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
7093
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6278
7094
|
cssRules.push({
|
|
6279
7095
|
dedupe,
|
|
6280
7096
|
className,
|
|
@@ -6302,6 +7118,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6302
7118
|
}
|
|
6303
7119
|
return true;
|
|
6304
7120
|
}
|
|
7121
|
+
function unwrapStaticStyleValue(value) {
|
|
7122
|
+
let weight = null;
|
|
7123
|
+
let important = false;
|
|
7124
|
+
while (true) {
|
|
7125
|
+
if (isStyleImportantValue(value)) {
|
|
7126
|
+
important = true;
|
|
7127
|
+
value = value.value;
|
|
7128
|
+
continue;
|
|
7129
|
+
}
|
|
7130
|
+
if (isStyleWeightValue(value)) {
|
|
7131
|
+
weight = value.weight;
|
|
7132
|
+
value = value.value;
|
|
7133
|
+
continue;
|
|
7134
|
+
}
|
|
7135
|
+
break;
|
|
7136
|
+
}
|
|
7137
|
+
return [
|
|
7138
|
+
value,
|
|
7139
|
+
weight,
|
|
7140
|
+
important
|
|
7141
|
+
];
|
|
7142
|
+
}
|
|
6305
7143
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6306
7144
|
if (result.ok) return;
|
|
6307
7145
|
if (result.reason.includes("createCounterStyle") || result.reason.includes("createFontFace") || result.reason.includes("createFontPaletteValues") || result.reason.includes("createPositionTry") || result.reason.includes("createProperty") || result.reason.includes("fontSrc")) throw new Error(result.reason);
|
|
@@ -6437,6 +7275,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6437
7275
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6438
7276
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6439
7277
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7278
|
+
const staticIdState = {
|
|
7279
|
+
fileId,
|
|
7280
|
+
imports,
|
|
7281
|
+
styleNames
|
|
7282
|
+
};
|
|
7283
|
+
const t = babel.types;
|
|
6440
7284
|
for (const stmt of ast.program.body) {
|
|
6441
7285
|
if (stmt.type === "ImportDeclaration") {
|
|
6442
7286
|
const source = stmt.source.value;
|
|
@@ -6461,6 +7305,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6461
7305
|
continue;
|
|
6462
7306
|
}
|
|
6463
7307
|
if (stmt.type === "VariableDeclaration") {
|
|
7308
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6464
7309
|
collectVariableBindings(rawBindings, stmt);
|
|
6465
7310
|
continue;
|
|
6466
7311
|
}
|
|
@@ -6484,6 +7329,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6484
7329
|
continue;
|
|
6485
7330
|
}
|
|
6486
7331
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7332
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6487
7333
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6488
7334
|
continue;
|
|
6489
7335
|
}
|
|
@@ -6523,6 +7369,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6523
7369
|
});
|
|
6524
7370
|
return bindings;
|
|
6525
7371
|
}
|
|
7372
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7373
|
+
for (const decl of declaration.declarations) {
|
|
7374
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7375
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7376
|
+
}
|
|
7377
|
+
}
|
|
6526
7378
|
function collectVariableBindings(bindings, declaration) {
|
|
6527
7379
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6528
7380
|
}
|
|
@@ -6602,6 +7454,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6602
7454
|
defineCompiledStyleLocations(style, traceResult);
|
|
6603
7455
|
return style;
|
|
6604
7456
|
}
|
|
7457
|
+
if (result.type === "sheet") {
|
|
7458
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7459
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7460
|
+
return sheet;
|
|
7461
|
+
}
|
|
6605
7462
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6606
7463
|
return null;
|
|
6607
7464
|
}
|
|
@@ -6712,6 +7569,12 @@ function hashFileContent(filePath) {
|
|
|
6712
7569
|
function getStyleRuntimeImportPath(mode) {
|
|
6713
7570
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6714
7571
|
}
|
|
7572
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7573
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7574
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7575
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7576
|
+
return null;
|
|
7577
|
+
}
|
|
6715
7578
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6716
7579
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6717
7580
|
}
|
|
@@ -6804,6 +7667,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6804
7667
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6805
7668
|
return t.callExpression(t.identifier(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE), hasSpread ? buildStyleMergeArgs(t, chain, state, options) : [buildItemsArray(t, chain, 1, state, options)]);
|
|
6806
7669
|
}
|
|
7670
|
+
if (chain.type === "sheet") {
|
|
7671
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7672
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7673
|
+
}
|
|
6807
7674
|
if (chain.type === "slot") {
|
|
6808
7675
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6809
7676
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6842,7 +7709,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6842
7709
|
chain.items.forEach((item) => {
|
|
6843
7710
|
if (isCompiledTokenItem(item)) {
|
|
6844
7711
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6845
|
-
else itemExpressions.push(t
|
|
7712
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6846
7713
|
return;
|
|
6847
7714
|
}
|
|
6848
7715
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6941,6 +7808,18 @@ function buildExtractedTokenExpression(t, token, state) {
|
|
|
6941
7808
|
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6942
7809
|
]);
|
|
6943
7810
|
}
|
|
7811
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7812
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7813
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7814
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7815
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7816
|
+
t.nullLiteral(),
|
|
7817
|
+
t.nullLiteral(),
|
|
7818
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7819
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7820
|
+
]);
|
|
7821
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
7822
|
+
}
|
|
6944
7823
|
function literalExpression(t, value) {
|
|
6945
7824
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
6946
7825
|
if (typeof value === "number") return t.numericLiteral(value);
|
|
@@ -7062,6 +7941,7 @@ function getEvalScope(state) {
|
|
|
7062
7941
|
styleFilePath: state.styleFilePath,
|
|
7063
7942
|
sourcemapTrace: state.sourcemapTrace,
|
|
7064
7943
|
styleNames: state.styleNames,
|
|
7944
|
+
sheetNames: state.sheetNames,
|
|
7065
7945
|
styleMetas: state.styleMetas,
|
|
7066
7946
|
bindingNodes: state.bindingNodes,
|
|
7067
7947
|
runtimeMode: state.runtimeMode
|
|
@@ -7119,6 +7999,7 @@ function createExtractPlugin(args) {
|
|
|
7119
7999
|
return {
|
|
7120
8000
|
pre() {
|
|
7121
8001
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
8002
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
7122
8003
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
7123
8004
|
this.bindings = /* @__PURE__ */ new Map();
|
|
7124
8005
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -7165,6 +8046,7 @@ function createExtractPlugin(args) {
|
|
|
7165
8046
|
state.styleNames.add(spec.local.name);
|
|
7166
8047
|
state.styleMetas.set(spec.local.name, meta);
|
|
7167
8048
|
}
|
|
8049
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
7168
8050
|
});
|
|
7169
8051
|
},
|
|
7170
8052
|
VariableDeclaration(path, state) {
|
|
@@ -7211,17 +8093,17 @@ function createExtractPlugin(args) {
|
|
|
7211
8093
|
state.needsExtractImport = true;
|
|
7212
8094
|
return;
|
|
7213
8095
|
}
|
|
7214
|
-
if (!state.styleNames.size) return;
|
|
7215
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
8096
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
8097
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
7216
8098
|
if (!chain) return;
|
|
7217
8099
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
7218
8100
|
const scope = getEvalScope(state);
|
|
7219
8101
|
const loc = path.node.loc?.start;
|
|
7220
8102
|
const meta = state.styleMetas.get(chain.rootName);
|
|
7221
|
-
if (!meta) return;
|
|
8103
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
7222
8104
|
let result;
|
|
7223
8105
|
try {
|
|
7224
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
8106
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
7225
8107
|
} catch (error) {
|
|
7226
8108
|
const message = error instanceof Error ? error.message : String(error);
|
|
7227
8109
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7475,7 +8357,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7475
8357
|
code: args.code,
|
|
7476
8358
|
filePath: args.filePath,
|
|
7477
8359
|
sourcemap: args.sourcemap,
|
|
7478
|
-
plugins: [plugin],
|
|
8360
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7479
8361
|
errorLabel: "[style] compiler error"
|
|
7480
8362
|
});
|
|
7481
8363
|
if (!result) return null;
|
|
@@ -7522,10 +8404,10 @@ function createCompiler(args, options) {
|
|
|
7522
8404
|
const tracer = createTracer(internal);
|
|
7523
8405
|
const collector = createCssCollector();
|
|
7524
8406
|
const compileDebug = (args) => {
|
|
7525
|
-
return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
|
|
8407
|
+
return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
|
|
7526
8408
|
};
|
|
7527
8409
|
const compileDebugRSC = (args) => {
|
|
7528
|
-
const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
|
|
8410
|
+
const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
|
|
7529
8411
|
if (!debugResult) return null;
|
|
7530
8412
|
const rscCollector = createCssCollector();
|
|
7531
8413
|
transformExtract(internal, args, {
|
|
@@ -7554,7 +8436,7 @@ function createCompiler(args, options) {
|
|
|
7554
8436
|
return rewriteTransformResult({
|
|
7555
8437
|
...result,
|
|
7556
8438
|
rules: collector.getItems().slice(startIndex)
|
|
7557
|
-
}, internal.runtimeMode);
|
|
8439
|
+
}, internal.runtimeMode, args.code);
|
|
7558
8440
|
};
|
|
7559
8441
|
const getExtractedCss = () => {
|
|
7560
8442
|
return extractCss(collector.getItems(), {
|
|
@@ -7584,23 +8466,73 @@ function createCompilerInternal(args, options) {
|
|
|
7584
8466
|
options
|
|
7585
8467
|
};
|
|
7586
8468
|
}
|
|
7587
|
-
function rewriteTransformResult(result, runtimeMode) {
|
|
8469
|
+
function rewriteTransformResult(result, runtimeMode, sourceCode) {
|
|
7588
8470
|
if (!result || !runtimeMode) return result;
|
|
7589
8471
|
return {
|
|
7590
8472
|
...result,
|
|
7591
|
-
code: rewriteCompilerRuntimeImports(result.code, runtimeMode)
|
|
8473
|
+
code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode)
|
|
7592
8474
|
};
|
|
7593
8475
|
}
|
|
7594
|
-
function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
7595
|
-
|
|
8476
|
+
function rewriteCompilerRuntimeImports(code, runtimeMode, sourceCode) {
|
|
8477
|
+
const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
|
|
8478
|
+
return rewriteImportSources(code, (source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode));
|
|
8479
|
+
}
|
|
8480
|
+
function getImportRuntimeMode(runtimeMode, sourceCode) {
|
|
8481
|
+
if (runtimeMode === "rsc-dev" && hasUseClientDirective(sourceCode)) return "dev";
|
|
8482
|
+
return runtimeMode;
|
|
7596
8483
|
}
|
|
7597
|
-
function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
7598
|
-
if (source === "@fluentic/style") return getStyleRuntimeImportPath(
|
|
7599
|
-
|
|
8484
|
+
function getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode) {
|
|
8485
|
+
if (source === "@fluentic/style") return getStyleRuntimeImportPath(importRuntimeMode);
|
|
8486
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
|
|
8487
|
+
if (adapterImportPath) return adapterImportPath;
|
|
8488
|
+
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(importRuntimeMode);
|
|
7600
8489
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7601
8490
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7602
8491
|
return null;
|
|
7603
8492
|
}
|
|
8493
|
+
function hasUseClientDirective(code) {
|
|
8494
|
+
let index = 0;
|
|
8495
|
+
while (index < code.length) {
|
|
8496
|
+
index = skipWhitespaceAndComments(code, index);
|
|
8497
|
+
const quote = code[index];
|
|
8498
|
+
if (quote !== "\"" && quote !== "'") return false;
|
|
8499
|
+
const end = code.indexOf(quote, index + 1);
|
|
8500
|
+
if (end < 0) return false;
|
|
8501
|
+
const directive = code.slice(index + 1, end);
|
|
8502
|
+
index = skipWhitespaceAndComments(code, end + 1);
|
|
8503
|
+
if (code[index] === ";") index += 1;
|
|
8504
|
+
else if (code[index] && code[index] !== "\n" && code[index] !== "\r") return false;
|
|
8505
|
+
if (directive === "use client") return true;
|
|
8506
|
+
}
|
|
8507
|
+
return false;
|
|
8508
|
+
}
|
|
8509
|
+
function skipWhitespaceAndComments(code, index) {
|
|
8510
|
+
let next = index;
|
|
8511
|
+
while (next < code.length) {
|
|
8512
|
+
const char = code[next];
|
|
8513
|
+
if (char === " " || char === " " || char === "\n" || char === "\r") {
|
|
8514
|
+
next += 1;
|
|
8515
|
+
continue;
|
|
8516
|
+
}
|
|
8517
|
+
if (char === "/" && code[next + 1] === "/") {
|
|
8518
|
+
const lineEnd = code.indexOf("\n", next + 2);
|
|
8519
|
+
next = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
8520
|
+
continue;
|
|
8521
|
+
}
|
|
8522
|
+
if (char === "/" && code[next + 1] === "*") {
|
|
8523
|
+
const commentEnd = code.indexOf("*/", next + 2);
|
|
8524
|
+
next = commentEnd < 0 ? code.length : commentEnd + 2;
|
|
8525
|
+
continue;
|
|
8526
|
+
}
|
|
8527
|
+
break;
|
|
8528
|
+
}
|
|
8529
|
+
return next;
|
|
8530
|
+
}
|
|
8531
|
+
const CssPropPresets = {
|
|
8532
|
+
Solid: { adapter: "@fluentic/style/adapter/solid" },
|
|
8533
|
+
Preact: { adapter: "@fluentic/style/adapter/preact" },
|
|
8534
|
+
React: { adapter: "@fluentic/style/adapter/react" }
|
|
8535
|
+
};
|
|
7604
8536
|
//#endregion
|
|
7605
8537
|
//#region plugin/utils/constants.ts
|
|
7606
8538
|
const PLUGIN_NAME = "fluentic-style";
|
|
@@ -7731,10 +8663,10 @@ function getStyleRuntimeMode(dev, rsc = false) {
|
|
|
7731
8663
|
if (rsc) return dev ? "rsc-dev" : "rsc-prod";
|
|
7732
8664
|
return dev ? "dev" : "prod";
|
|
7733
8665
|
}
|
|
7734
|
-
function getPluginBuildConfig(options) {
|
|
8666
|
+
function getPluginBuildConfig(options, dev = false) {
|
|
7735
8667
|
const css = hasBuildConfig(options.css) ? options.css : {};
|
|
7736
8668
|
return {
|
|
7737
|
-
hoist: options.hoist !== false,
|
|
8669
|
+
hoist: !dev && options.hoist !== false,
|
|
7738
8670
|
css
|
|
7739
8671
|
};
|
|
7740
8672
|
}
|
|
@@ -8167,6 +9099,12 @@ Object.defineProperty(exports, "CSS_MODULE_ID", {
|
|
|
8167
9099
|
return CSS_MODULE_ID;
|
|
8168
9100
|
}
|
|
8169
9101
|
});
|
|
9102
|
+
Object.defineProperty(exports, "CssPropPresets", {
|
|
9103
|
+
enumerable: true,
|
|
9104
|
+
get: function() {
|
|
9105
|
+
return CssPropPresets;
|
|
9106
|
+
}
|
|
9107
|
+
});
|
|
8170
9108
|
Object.defineProperty(exports, "DEFAULT_TRANSFORM_INCLUDE_PATTERN", {
|
|
8171
9109
|
enumerable: true,
|
|
8172
9110
|
get: function() {
|
|
@@ -8288,4 +9226,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
8288
9226
|
}
|
|
8289
9227
|
});
|
|
8290
9228
|
|
|
8291
|
-
//# sourceMappingURL=shared-
|
|
9229
|
+
//# sourceMappingURL=shared-Bc9RwNNj.cjs.map
|