@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
2
|
import * as fs$1 from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
|
+
import * as BabelCore from "@babel/core";
|
|
4
5
|
import picomatch from "picomatch";
|
|
5
6
|
import { SelectorType, parse } from "css-what";
|
|
6
|
-
import * as BabelCore from "@babel/core";
|
|
7
7
|
import { ResolverFactory } from "oxc-resolver";
|
|
8
8
|
//#region compiler/compiler/cache.ts
|
|
9
9
|
function createCompilerCache(args) {
|
|
@@ -141,7 +141,7 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
141
141
|
isRSC: false,
|
|
142
142
|
runtimeCacheTTL: getCacheTTL(true)
|
|
143
143
|
};
|
|
144
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
144
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
145
145
|
globalData("config.build", () => ({ current: null }));
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region config/config/debug.ts
|
|
@@ -174,8 +174,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
174
174
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
175
175
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
176
176
|
}
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region atomic/layer/types.ts
|
|
179
177
|
const LayerDefaultPriority = [
|
|
180
178
|
0,
|
|
181
179
|
0,
|
|
@@ -245,6 +243,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
245
243
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
246
244
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
247
245
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
246
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
248
247
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
249
248
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
250
249
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -273,6 +272,145 @@ function getExtractedCssItems(items, args) {
|
|
|
273
272
|
return getLayerBundleCss(args.layers ?? defaults.layers ?? [], layerNamespace, css.map((item) => item.css));
|
|
274
273
|
}
|
|
275
274
|
//#endregion
|
|
275
|
+
//#region compiler/transform/utils/babel.ts
|
|
276
|
+
function babelPlugin(factory) {
|
|
277
|
+
return factory;
|
|
278
|
+
}
|
|
279
|
+
function babelTransform(args) {
|
|
280
|
+
let result = null;
|
|
281
|
+
try {
|
|
282
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
283
|
+
result = BabelCore.transformSync(args.code, {
|
|
284
|
+
...babelTransformOptions(),
|
|
285
|
+
inputSourceMap,
|
|
286
|
+
filename: args.filePath,
|
|
287
|
+
sourceFileName: args.filePath,
|
|
288
|
+
plugins: args.plugins,
|
|
289
|
+
sourceMaps: true,
|
|
290
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
291
|
+
});
|
|
292
|
+
} catch (err) {
|
|
293
|
+
if (!args.errorLabel) throw err;
|
|
294
|
+
const message = getBabelError(err, args);
|
|
295
|
+
const error = new Error(message);
|
|
296
|
+
error.stack = void 0;
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
if (!result || !result.code) return null;
|
|
300
|
+
return {
|
|
301
|
+
code: result.code,
|
|
302
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function babelTransformOptions() {
|
|
306
|
+
return {
|
|
307
|
+
configFile: false,
|
|
308
|
+
babelrc: false,
|
|
309
|
+
parserOpts: {
|
|
310
|
+
plugins: ["typescript", "jsx"],
|
|
311
|
+
strictMode: false,
|
|
312
|
+
allowImportExportEverywhere: true
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function parseInputSourceMap(sourcemap) {
|
|
317
|
+
if (!sourcemap) return void 0;
|
|
318
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
319
|
+
return JSON.parse(sourcemap);
|
|
320
|
+
}
|
|
321
|
+
function getBabelError(err, args) {
|
|
322
|
+
const babelErr = err;
|
|
323
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
324
|
+
const codeFrame = babelErr?.codeFrame;
|
|
325
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
326
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
330
|
+
function createCssPropPlugin(args) {
|
|
331
|
+
return babelPlugin((babel) => {
|
|
332
|
+
const { types: t } = babel;
|
|
333
|
+
return {
|
|
334
|
+
pre() {
|
|
335
|
+
this.options = args.options;
|
|
336
|
+
this.mergeId = null;
|
|
337
|
+
this.programPath = null;
|
|
338
|
+
this.changed = false;
|
|
339
|
+
},
|
|
340
|
+
visitor: {
|
|
341
|
+
Program: {
|
|
342
|
+
enter(path, state) {
|
|
343
|
+
state.programPath = path;
|
|
344
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
345
|
+
},
|
|
346
|
+
exit(path, state) {
|
|
347
|
+
const options = getCssPropOptions(state.options);
|
|
348
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
349
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
JSXOpeningElement(path, state) {
|
|
353
|
+
const keyHoistedAttributes = hoistKeyAttributes(path.node.attributes);
|
|
354
|
+
if (keyHoistedAttributes) path.node.attributes = keyHoistedAttributes;
|
|
355
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
356
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
357
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
358
|
+
const keyAttributes = path.node.attributes.filter(isKeyAttribute);
|
|
359
|
+
const parts = path.node.attributes.filter((attr) => !isKeyAttribute(attr)).map((attr) => buildPart(t, attr));
|
|
360
|
+
path.node.attributes = [...keyAttributes, t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
361
|
+
state.changed = true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function getCssPropOptions(options) {
|
|
368
|
+
return options.cssProp || null;
|
|
369
|
+
}
|
|
370
|
+
function isIntrinsicElement(name) {
|
|
371
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
372
|
+
}
|
|
373
|
+
function hasCssAttribute(attrs) {
|
|
374
|
+
return attrs.some((attr) => {
|
|
375
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function hoistKeyAttributes(attrs) {
|
|
379
|
+
const keyAttributes = attrs.filter(isKeyAttribute);
|
|
380
|
+
if (!keyAttributes.length) return null;
|
|
381
|
+
const firstKeyIndex = attrs.findIndex(isKeyAttribute);
|
|
382
|
+
const firstSpreadIndex = attrs.findIndex((attr) => attr.type === "JSXSpreadAttribute");
|
|
383
|
+
if (firstSpreadIndex < 0 || firstKeyIndex < firstSpreadIndex) return null;
|
|
384
|
+
return [...keyAttributes, ...attrs.filter((attr) => !isKeyAttribute(attr))];
|
|
385
|
+
}
|
|
386
|
+
function isKeyAttribute(attr) {
|
|
387
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "key";
|
|
388
|
+
}
|
|
389
|
+
function buildPart(t, attr) {
|
|
390
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
391
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
392
|
+
}
|
|
393
|
+
function getObjectKey(t, name) {
|
|
394
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
395
|
+
return t.stringLiteral(getAttributeName(name));
|
|
396
|
+
}
|
|
397
|
+
function getAttributeName(name) {
|
|
398
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
399
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
400
|
+
}
|
|
401
|
+
function getAttributeValue(t, attr) {
|
|
402
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
403
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
404
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
405
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
406
|
+
return attr.value.expression;
|
|
407
|
+
}
|
|
408
|
+
return attr.value;
|
|
409
|
+
}
|
|
410
|
+
function isValidIdentifierName(name) {
|
|
411
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
276
414
|
//#region builder/data/const.ts
|
|
277
415
|
const BUILDER_TYPE = symbol("builder.type");
|
|
278
416
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -280,8 +418,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
280
418
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
281
419
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
282
420
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
421
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
422
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
283
423
|
//#endregion
|
|
284
424
|
//#region utils/object.ts
|
|
425
|
+
function hasOwn(target, field) {
|
|
426
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
427
|
+
}
|
|
285
428
|
function toArray(value) {
|
|
286
429
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
287
430
|
}
|
|
@@ -461,6 +604,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
461
604
|
}
|
|
462
605
|
//#endregion
|
|
463
606
|
//#region builder/data/is.ts
|
|
607
|
+
function getSlotId(data) {
|
|
608
|
+
return data[BUILDER_SLOT_ID];
|
|
609
|
+
}
|
|
610
|
+
function getScopeTargetSlotId(data) {
|
|
611
|
+
return data[BUILDER_SCOPE_ID];
|
|
612
|
+
}
|
|
613
|
+
function getScopeTargetScope(data) {
|
|
614
|
+
return data[BUILDER_SCOPE];
|
|
615
|
+
}
|
|
464
616
|
function isStyleData(value) {
|
|
465
617
|
return getBuilderType(value) === 1;
|
|
466
618
|
}
|
|
@@ -470,9 +622,18 @@ function isSlotData(value) {
|
|
|
470
622
|
function isSlotOverrideData(value) {
|
|
471
623
|
return getBuilderType(value) === 3;
|
|
472
624
|
}
|
|
625
|
+
function isSelectorData(value) {
|
|
626
|
+
return getBuilderType(value) === 7;
|
|
627
|
+
}
|
|
628
|
+
function isSheetData(value) {
|
|
629
|
+
return getBuilderType(value) === 9;
|
|
630
|
+
}
|
|
473
631
|
function isScopeData(value) {
|
|
474
632
|
return getBuilderType(value) === 4;
|
|
475
633
|
}
|
|
634
|
+
function isThemeData(value) {
|
|
635
|
+
return getBuilderType(value) === 6;
|
|
636
|
+
}
|
|
476
637
|
function getBuilderType(value) {
|
|
477
638
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
478
639
|
return value[BUILDER_TYPE];
|
|
@@ -709,114 +870,6 @@ selectorPriority({
|
|
|
709
870
|
...AtRuleSelectors
|
|
710
871
|
}, PrioritySelectors);
|
|
711
872
|
//#endregion
|
|
712
|
-
//#region selector/validate.ts
|
|
713
|
-
function isLocalSelector(selector) {
|
|
714
|
-
const groups = parseSelector(selector);
|
|
715
|
-
if (!groups || groups.length !== 1) return false;
|
|
716
|
-
return isSelectorGroupsSelf(groups, false);
|
|
717
|
-
}
|
|
718
|
-
function isPseudoArgSelector(selector) {
|
|
719
|
-
const groups = parseSelector(selector);
|
|
720
|
-
if (!groups || groups.length !== 1) return false;
|
|
721
|
-
return isSelectorGroupsSelf(groups, true);
|
|
722
|
-
}
|
|
723
|
-
function isTagSelector(selector) {
|
|
724
|
-
const groups = parseSelector(selector);
|
|
725
|
-
if (!groups || groups.length !== 1) return false;
|
|
726
|
-
const group = groups[0];
|
|
727
|
-
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
728
|
-
}
|
|
729
|
-
function isAttrArg(value) {
|
|
730
|
-
if (!value) return false;
|
|
731
|
-
if (value.includes("[") || value.includes("]")) return false;
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
function isRawValue(value) {
|
|
735
|
-
if (!value) return false;
|
|
736
|
-
if (value.includes("{") || value.includes("}")) return false;
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
function parseSelector(selector) {
|
|
740
|
-
try {
|
|
741
|
-
return parse(selector);
|
|
742
|
-
} catch {
|
|
743
|
-
return;
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
function isSelectorGroupsSelf(groups, allowTag) {
|
|
747
|
-
for (let i = 0; i < groups.length; i++) {
|
|
748
|
-
const group = groups[i];
|
|
749
|
-
for (let j = 0; j < group.length; j++) {
|
|
750
|
-
const token = group[j];
|
|
751
|
-
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
752
|
-
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
return true;
|
|
756
|
-
}
|
|
757
|
-
function isAllowedSelectorType(type, allowTag) {
|
|
758
|
-
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
759
|
-
}
|
|
760
|
-
//#endregion
|
|
761
|
-
//#region selector/assert.ts
|
|
762
|
-
function assertSelector(type, value) {
|
|
763
|
-
assertSelectorNotEmpty(value);
|
|
764
|
-
if (!type) return;
|
|
765
|
-
if (typeof type === "function") return type(value);
|
|
766
|
-
switch (type) {
|
|
767
|
-
case "local": return assertLocalSelector(value);
|
|
768
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
769
|
-
case "tag": return assertTagSelector(value);
|
|
770
|
-
case "attr": return assertAttrSelector(value);
|
|
771
|
-
case "value": return assertRawValue(value);
|
|
772
|
-
case "media": return assertMediaQuery(value);
|
|
773
|
-
case "supports": return assertSupportsQuery(value);
|
|
774
|
-
case "container": return assertContainerQuery(value);
|
|
775
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
779
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
780
|
-
});
|
|
781
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
782
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
783
|
-
});
|
|
784
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
785
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
786
|
-
});
|
|
787
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
788
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
789
|
-
});
|
|
790
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
791
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
792
|
-
});
|
|
793
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
794
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
795
|
-
});
|
|
796
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
797
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
798
|
-
});
|
|
799
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
800
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
801
|
-
});
|
|
802
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
803
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
804
|
-
});
|
|
805
|
-
//#endregion
|
|
806
|
-
//#region builder/data/check_selector.ts
|
|
807
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
808
|
-
let message = null;
|
|
809
|
-
try {
|
|
810
|
-
assertSelector(fnSelector.assert, arg);
|
|
811
|
-
} catch (error) {
|
|
812
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
813
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
814
|
-
else message = "selector is invalid: " + arg;
|
|
815
|
-
}
|
|
816
|
-
if (!message) return;
|
|
817
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
818
|
-
}
|
|
819
|
-
//#endregion
|
|
820
873
|
//#region builder/data/create.ts
|
|
821
874
|
function createStyleData(callsite) {
|
|
822
875
|
return {
|
|
@@ -850,6 +903,28 @@ function createSlotOverrideData(callsite, slotId) {
|
|
|
850
903
|
[BUILDER_SLOT_ID]: slotId
|
|
851
904
|
};
|
|
852
905
|
}
|
|
906
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
907
|
+
return {
|
|
908
|
+
[BUILDER_TYPE]: 8,
|
|
909
|
+
[BUILDER_STATE]: {
|
|
910
|
+
items: [],
|
|
911
|
+
lookup: {}
|
|
912
|
+
},
|
|
913
|
+
[BUILDER_CALLSITE]: callsite,
|
|
914
|
+
[BUILDER_SELECTOR]: selectors
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function createSelectorData(callsite, selectors) {
|
|
918
|
+
return {
|
|
919
|
+
[BUILDER_TYPE]: 7,
|
|
920
|
+
[BUILDER_STATE]: {
|
|
921
|
+
items: [],
|
|
922
|
+
lookup: {}
|
|
923
|
+
},
|
|
924
|
+
[BUILDER_CALLSITE]: callsite,
|
|
925
|
+
[BUILDER_SELECTOR]: selectors
|
|
926
|
+
};
|
|
927
|
+
}
|
|
853
928
|
function createScopeData(callsite) {
|
|
854
929
|
return {
|
|
855
930
|
[BUILDER_TYPE]: 4,
|
|
@@ -985,6 +1060,9 @@ const formatTransformClassName = createNameFormatter(["className"]);
|
|
|
985
1060
|
function getDebugClassName(format, hash, info) {
|
|
986
1061
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
987
1062
|
}
|
|
1063
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1064
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1065
|
+
}
|
|
988
1066
|
function getDebugTransformClassName(format, hash, info) {
|
|
989
1067
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
990
1068
|
}
|
|
@@ -1180,54 +1258,17 @@ function parseAtRule(rule) {
|
|
|
1180
1258
|
return compressQuery(normalized);
|
|
1181
1259
|
}
|
|
1182
1260
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1183
|
-
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
1261
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1184
1262
|
}
|
|
1185
|
-
function formatScopeClassName(format, info) {
|
|
1263
|
+
function formatScopeClassName$1(format, info) {
|
|
1186
1264
|
if (typeof format === "function") return format(info);
|
|
1187
1265
|
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1188
1266
|
}
|
|
1189
1267
|
//#endregion
|
|
1190
1268
|
//#region atomic/utils/hash.ts
|
|
1191
|
-
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1192
|
-
byValue: /* @__PURE__ */ new Map(),
|
|
1193
|
-
byHash: /* @__PURE__ */ new Map(),
|
|
1194
|
-
usedByLength: []
|
|
1195
|
-
}));
|
|
1196
1269
|
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1197
|
-
return getPooledHash(value, startLength);
|
|
1198
|
-
}
|
|
1199
|
-
function getPooledHash(value, startLength) {
|
|
1200
1270
|
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1201
|
-
|
|
1202
|
-
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1203
|
-
if (existing) return existing;
|
|
1204
|
-
let length = normalizedStartLength;
|
|
1205
|
-
while (true) {
|
|
1206
|
-
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1207
|
-
length++;
|
|
1208
|
-
continue;
|
|
1209
|
-
}
|
|
1210
|
-
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1211
|
-
const hash = getPooledHashCandidate(value, length, index);
|
|
1212
|
-
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1213
|
-
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1214
|
-
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1215
|
-
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1216
|
-
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1217
|
-
return hash;
|
|
1218
|
-
}
|
|
1219
|
-
length++;
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
function getPooledHashCandidate(value, length, index) {
|
|
1223
|
-
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1224
|
-
}
|
|
1225
|
-
function getPooledHashUsedCount(length) {
|
|
1226
|
-
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1227
|
-
}
|
|
1228
|
-
function getIdentifierSafeHashPoolSize(length) {
|
|
1229
|
-
if (length <= 0) return 0;
|
|
1230
|
-
return 26 * 36 ** (length - 1);
|
|
1271
|
+
return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
|
|
1231
1272
|
}
|
|
1232
1273
|
function getIdentifierSafeHashValue(hash) {
|
|
1233
1274
|
const first = hash.charCodeAt(0);
|
|
@@ -1236,21 +1277,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1236
1277
|
}
|
|
1237
1278
|
//#endregion
|
|
1238
1279
|
//#region atomic/utils/selector.ts
|
|
1239
|
-
function getSelectorText(selector) {
|
|
1240
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1280
|
+
function getSelectorText$1(selector) {
|
|
1281
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1241
1282
|
}
|
|
1242
1283
|
function getSelectorHash(selector) {
|
|
1243
1284
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1244
1285
|
}
|
|
1245
|
-
function getSelectorPriority(selector) {
|
|
1286
|
+
function getSelectorPriority$1(selector) {
|
|
1246
1287
|
if (!selector) return 0;
|
|
1247
1288
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1248
1289
|
}
|
|
1290
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1291
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1292
|
+
}
|
|
1293
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1294
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1295
|
+
}
|
|
1249
1296
|
//#endregion
|
|
1250
1297
|
//#region atomic/className.ts
|
|
1251
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1298
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1252
1299
|
let hash = property;
|
|
1253
1300
|
hash += "\n" + (priority || "");
|
|
1301
|
+
if (important) hash += "\nimportant";
|
|
1254
1302
|
hash += "\n" + value;
|
|
1255
1303
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1256
1304
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1260,21 +1308,31 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1260
1308
|
if (!debugClassName) return hash;
|
|
1261
1309
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1262
1310
|
const propertyName = getDebugPropertyName(property, value);
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1311
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1312
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1313
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1314
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1315
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1267
1316
|
property: propertyName ? propertyName.property : property,
|
|
1268
1317
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1269
1318
|
});
|
|
1270
1319
|
}
|
|
1271
1320
|
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1272
|
-
|
|
1273
|
-
|
|
1321
|
+
return getClassNameHashLength({
|
|
1322
|
+
debugClassName,
|
|
1323
|
+
isDev: DEV_CONFIG.isDev,
|
|
1324
|
+
devHashLength: DEV_CONFIG.hashLength,
|
|
1325
|
+
cssHashLength: CSS_CONFIG.hashLength
|
|
1326
|
+
});
|
|
1274
1327
|
}
|
|
1275
|
-
function
|
|
1328
|
+
function getClassNameHashLength(options) {
|
|
1329
|
+
if (options.debugClassName && options.isDev) return options.devHashLength ?? options.cssHashLength ?? 3;
|
|
1330
|
+
return options.cssHashLength ?? 7;
|
|
1331
|
+
}
|
|
1332
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1276
1333
|
let hash = property;
|
|
1277
1334
|
hash += "\n" + (priority || "");
|
|
1335
|
+
if (important) hash += "\nimportant";
|
|
1278
1336
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1279
1337
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1280
1338
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1311,7 +1369,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1311
1369
|
let source;
|
|
1312
1370
|
let item;
|
|
1313
1371
|
let lookupIndex;
|
|
1314
|
-
let
|
|
1372
|
+
let weight;
|
|
1373
|
+
let important;
|
|
1315
1374
|
let value;
|
|
1316
1375
|
let atRule;
|
|
1317
1376
|
let dedupe;
|
|
@@ -1322,7 +1381,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1322
1381
|
source = sourceItems[i];
|
|
1323
1382
|
if (!source) continue;
|
|
1324
1383
|
if (isStyleTokenOverrideData(source)) {
|
|
1325
|
-
addTokenOverride(source, styles, lookup);
|
|
1384
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1326
1385
|
continue;
|
|
1327
1386
|
}
|
|
1328
1387
|
if (isScopeData(source)) {
|
|
@@ -1330,7 +1389,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1330
1389
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1331
1390
|
item = scopeItems[j];
|
|
1332
1391
|
if (isStyleTokenOverrideData(item)) {
|
|
1333
|
-
addTokenOverride(item, styles, lookup);
|
|
1392
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1334
1393
|
continue;
|
|
1335
1394
|
}
|
|
1336
1395
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1351,13 +1410,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1351
1410
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1352
1411
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1353
1412
|
value = scopeItem.value;
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1359
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1360
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1413
|
+
weight = scopeItem.weight;
|
|
1414
|
+
important = scopeItem.important;
|
|
1415
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1416
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1361
1417
|
scopeItem.dedupe = dedupe;
|
|
1362
1418
|
scopeItem.className = className;
|
|
1363
1419
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1394,6 +1450,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1394
1450
|
dedupe: "",
|
|
1395
1451
|
className: "",
|
|
1396
1452
|
property: overrideItem.property,
|
|
1453
|
+
weight: overrideItem.weight,
|
|
1454
|
+
important: overrideItem.important,
|
|
1397
1455
|
value: overrideItem.value,
|
|
1398
1456
|
transformClassName: overrideItem.transformClassName,
|
|
1399
1457
|
token: overrideItem.token,
|
|
@@ -1405,13 +1463,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1405
1463
|
parentSelector
|
|
1406
1464
|
};
|
|
1407
1465
|
value = scopeItem.value;
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1414
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1466
|
+
weight = scopeItem.weight;
|
|
1467
|
+
important = scopeItem.important;
|
|
1468
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1469
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1415
1470
|
scopeItem.dedupe = dedupe;
|
|
1416
1471
|
scopeItem.className = className;
|
|
1417
1472
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1422,7 +1477,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1422
1477
|
}
|
|
1423
1478
|
return data;
|
|
1424
1479
|
}
|
|
1425
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1480
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1426
1481
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1427
1482
|
const lookupIndex = lookup[lookupKey];
|
|
1428
1483
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1567,6 +1622,18 @@ function shouldAppendCssPx(property) {
|
|
|
1567
1622
|
return !UNITLESS.has(property);
|
|
1568
1623
|
}
|
|
1569
1624
|
//#endregion
|
|
1625
|
+
//#region style/important.ts
|
|
1626
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1627
|
+
function importantValue(value) {
|
|
1628
|
+
return {
|
|
1629
|
+
[STYLE_IMPORTANT]: true,
|
|
1630
|
+
value
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1633
|
+
function isStyleImportantValue(value) {
|
|
1634
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1635
|
+
}
|
|
1636
|
+
//#endregion
|
|
1570
1637
|
//#region style/transform.ts
|
|
1571
1638
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1572
1639
|
function classNameValue(value, className) {
|
|
@@ -1592,6 +1659,19 @@ function isAtRuleRef(value) {
|
|
|
1592
1659
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1593
1660
|
}
|
|
1594
1661
|
//#endregion
|
|
1662
|
+
//#region style/weight.ts
|
|
1663
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1664
|
+
function weightValue(value, weight) {
|
|
1665
|
+
return {
|
|
1666
|
+
[STYLE_WEIGHT]: true,
|
|
1667
|
+
value,
|
|
1668
|
+
weight
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
function isStyleWeightValue(value) {
|
|
1672
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1673
|
+
}
|
|
1674
|
+
//#endregion
|
|
1595
1675
|
//#region builder/data/merge/style.ts
|
|
1596
1676
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1597
1677
|
if (!style) return source;
|
|
@@ -1602,7 +1682,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1602
1682
|
let itemData;
|
|
1603
1683
|
let valueRaw;
|
|
1604
1684
|
let value;
|
|
1605
|
-
let
|
|
1685
|
+
let weight;
|
|
1686
|
+
let important;
|
|
1606
1687
|
let itemCallsite;
|
|
1607
1688
|
let className;
|
|
1608
1689
|
let dedupe;
|
|
@@ -1623,6 +1704,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1623
1704
|
continue;
|
|
1624
1705
|
}
|
|
1625
1706
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1707
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1626
1708
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1627
1709
|
type: 2,
|
|
1628
1710
|
slotId
|
|
@@ -1631,6 +1713,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1631
1713
|
type: 3,
|
|
1632
1714
|
slotId
|
|
1633
1715
|
});
|
|
1716
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1634
1717
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1635
1718
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1636
1719
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1642,11 +1725,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1642
1725
|
}
|
|
1643
1726
|
} else for (const property in style) {
|
|
1644
1727
|
valueRaw = style[property];
|
|
1645
|
-
|
|
1646
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1647
|
-
priority = valueRaw[0];
|
|
1648
|
-
valueRaw = valueRaw[1];
|
|
1649
|
-
}
|
|
1728
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1650
1729
|
transformClassName = null;
|
|
1651
1730
|
if (isClassNameValue(valueRaw)) {
|
|
1652
1731
|
transformClassName = valueRaw.className;
|
|
@@ -1657,7 +1736,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1657
1736
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1658
1737
|
variableName = getDebugFieldVarName(debug, property);
|
|
1659
1738
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1660
|
-
value = priority !== null ? [value, priority] : value;
|
|
1661
1739
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1662
1740
|
itemData = {
|
|
1663
1741
|
runtime: runtimeType,
|
|
@@ -1666,6 +1744,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1666
1744
|
dedupe: "",
|
|
1667
1745
|
className: "",
|
|
1668
1746
|
property,
|
|
1747
|
+
weight,
|
|
1748
|
+
important,
|
|
1669
1749
|
value,
|
|
1670
1750
|
transformClassName,
|
|
1671
1751
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1679,7 +1759,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1679
1759
|
atRule,
|
|
1680
1760
|
callsite: itemCallsite
|
|
1681
1761
|
};
|
|
1682
|
-
if (type === 1) {
|
|
1762
|
+
if (type === 1 || type === 8) {
|
|
1683
1763
|
items.push({
|
|
1684
1764
|
...itemData,
|
|
1685
1765
|
type: 1
|
|
@@ -1726,13 +1806,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1726
1806
|
}
|
|
1727
1807
|
const runtimeItem = item;
|
|
1728
1808
|
value = runtimeItem.value;
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}
|
|
1734
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1735
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1809
|
+
weight = runtimeItem.weight;
|
|
1810
|
+
important = runtimeItem.important;
|
|
1811
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1812
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1736
1813
|
runtimeItem.dedupe = dedupe;
|
|
1737
1814
|
runtimeItem.className = className;
|
|
1738
1815
|
lookupIndex = lookup[dedupe];
|
|
@@ -1741,7 +1818,42 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1741
1818
|
}
|
|
1742
1819
|
return data;
|
|
1743
1820
|
}
|
|
1744
|
-
function
|
|
1821
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1822
|
+
let weight = null;
|
|
1823
|
+
let important = false;
|
|
1824
|
+
while (true) {
|
|
1825
|
+
if (isStyleImportantValue(value)) {
|
|
1826
|
+
important = true;
|
|
1827
|
+
value = value.value;
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
if (isStyleWeightValue(value)) {
|
|
1831
|
+
weight = value.weight;
|
|
1832
|
+
value = value.value;
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
return [
|
|
1838
|
+
value,
|
|
1839
|
+
weight,
|
|
1840
|
+
important
|
|
1841
|
+
];
|
|
1842
|
+
}
|
|
1843
|
+
function combineSelectors$1(parent, child) {
|
|
1844
|
+
const parentText = getSelectorText(parent);
|
|
1845
|
+
const childText = getSelectorText(child);
|
|
1846
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
1847
|
+
const selector = parentText + childText;
|
|
1848
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
1849
|
+
}
|
|
1850
|
+
function getSelectorText(selector) {
|
|
1851
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
1852
|
+
}
|
|
1853
|
+
function getSelectorPriority(selector) {
|
|
1854
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
1855
|
+
}
|
|
1856
|
+
function getMergedStyleDebug(debug, item) {
|
|
1745
1857
|
if (!debug) return null;
|
|
1746
1858
|
if (debug.fields?.[item.property]) return debug;
|
|
1747
1859
|
const valueLoc = getMergedItemValueLoc(item);
|
|
@@ -1784,6 +1896,47 @@ function withDebugSource$1(loc, debug) {
|
|
|
1784
1896
|
];
|
|
1785
1897
|
}
|
|
1786
1898
|
//#endregion
|
|
1899
|
+
//#region builder/selector_override_core.ts
|
|
1900
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
1901
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
1902
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
1903
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
1904
|
+
}
|
|
1905
|
+
function assertManualSelectorSyntax(selector) {
|
|
1906
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
1907
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
1908
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
1909
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1910
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
1911
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1912
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
1913
|
+
}
|
|
1914
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
1915
|
+
const value = selector.trim();
|
|
1916
|
+
assertManualSelector(value);
|
|
1917
|
+
if (value.startsWith("&?")) {
|
|
1918
|
+
const suffix = value.slice(2);
|
|
1919
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
1920
|
+
}
|
|
1921
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
1922
|
+
}
|
|
1923
|
+
//#endregion
|
|
1924
|
+
//#region builder/selector_override.ts
|
|
1925
|
+
function normalizeManualSelectors(input) {
|
|
1926
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
1927
|
+
}
|
|
1928
|
+
function assertManualSelector(selector) {
|
|
1929
|
+
assertManualSelectorSyntax(selector);
|
|
1930
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1931
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1932
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
1933
|
+
try {
|
|
1934
|
+
parse(parsedSelector);
|
|
1935
|
+
} catch {
|
|
1936
|
+
throw new Error("selector is invalid: " + selector);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
//#endregion
|
|
1787
1940
|
//#region builder/style_data.ts
|
|
1788
1941
|
const mergeStyleCreate = (callsite) => {
|
|
1789
1942
|
return createStyleData(callsite);
|
|
@@ -1797,16 +1950,129 @@ const mergeSlotOverrideCreate = (callsite, data) => {
|
|
|
1797
1950
|
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1798
1951
|
};
|
|
1799
1952
|
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
1953
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
1954
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
1955
|
+
};
|
|
1956
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1800
1957
|
function createMerge(create, type) {
|
|
1801
1958
|
return (data, callsite, style, debug, selector, atRule) => {
|
|
1802
1959
|
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1803
1960
|
};
|
|
1804
1961
|
}
|
|
1805
1962
|
//#endregion
|
|
1963
|
+
//#region selector/validate.ts
|
|
1964
|
+
function isLocalSelector(selector) {
|
|
1965
|
+
const groups = parseSelector(selector);
|
|
1966
|
+
if (!groups || groups.length !== 1) return false;
|
|
1967
|
+
return isSelectorGroupsSelf(groups, false);
|
|
1968
|
+
}
|
|
1969
|
+
function isPseudoArgSelector(selector) {
|
|
1970
|
+
const groups = parseSelector(selector);
|
|
1971
|
+
if (!groups || groups.length !== 1) return false;
|
|
1972
|
+
return isSelectorGroupsSelf(groups, true);
|
|
1973
|
+
}
|
|
1974
|
+
function isTagSelector(selector) {
|
|
1975
|
+
const groups = parseSelector(selector);
|
|
1976
|
+
if (!groups || groups.length !== 1) return false;
|
|
1977
|
+
const group = groups[0];
|
|
1978
|
+
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
1979
|
+
}
|
|
1980
|
+
function isAttrArg(value) {
|
|
1981
|
+
if (!value) return false;
|
|
1982
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
1983
|
+
return true;
|
|
1984
|
+
}
|
|
1985
|
+
function isRawValue(value) {
|
|
1986
|
+
if (!value) return false;
|
|
1987
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
1988
|
+
return true;
|
|
1989
|
+
}
|
|
1990
|
+
function parseSelector(selector) {
|
|
1991
|
+
try {
|
|
1992
|
+
return parse(selector);
|
|
1993
|
+
} catch {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
1998
|
+
for (let i = 0; i < groups.length; i++) {
|
|
1999
|
+
const group = groups[i];
|
|
2000
|
+
for (let j = 0; j < group.length; j++) {
|
|
2001
|
+
const token = group[j];
|
|
2002
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2003
|
+
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
return true;
|
|
2007
|
+
}
|
|
2008
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2009
|
+
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
2010
|
+
}
|
|
2011
|
+
//#endregion
|
|
2012
|
+
//#region selector/assert.ts
|
|
2013
|
+
function assertSelector(type, value) {
|
|
2014
|
+
assertSelectorNotEmpty(value);
|
|
2015
|
+
if (!type) return;
|
|
2016
|
+
if (typeof type === "function") return type(value);
|
|
2017
|
+
switch (type) {
|
|
2018
|
+
case "local": return assertLocalSelector(value);
|
|
2019
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2020
|
+
case "tag": return assertTagSelector(value);
|
|
2021
|
+
case "attr": return assertAttrSelector(value);
|
|
2022
|
+
case "value": return assertRawValue(value);
|
|
2023
|
+
case "media": return assertMediaQuery(value);
|
|
2024
|
+
case "supports": return assertSupportsQuery(value);
|
|
2025
|
+
case "container": return assertContainerQuery(value);
|
|
2026
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2030
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2031
|
+
});
|
|
2032
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2033
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2034
|
+
});
|
|
2035
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2036
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2037
|
+
});
|
|
2038
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2039
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2040
|
+
});
|
|
2041
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2042
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2043
|
+
});
|
|
2044
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2045
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2046
|
+
});
|
|
2047
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2048
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2049
|
+
});
|
|
2050
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2051
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2052
|
+
});
|
|
2053
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2054
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2055
|
+
});
|
|
2056
|
+
//#endregion
|
|
2057
|
+
//#region builder/data/check_selector.ts
|
|
2058
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2059
|
+
let message = null;
|
|
2060
|
+
try {
|
|
2061
|
+
assertSelector(fnSelector.assert, arg);
|
|
2062
|
+
} catch (error) {
|
|
2063
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2064
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2065
|
+
else message = "selector is invalid: " + arg;
|
|
2066
|
+
}
|
|
2067
|
+
if (!message) return;
|
|
2068
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
2069
|
+
}
|
|
2070
|
+
//#endregion
|
|
1806
2071
|
//#region builder/utils.ts
|
|
1807
2072
|
const FnPrefixStyle = "style.";
|
|
1808
2073
|
const FnPrefixSlot = "slot.";
|
|
1809
2074
|
const FnPrefixScope = "scope.";
|
|
2075
|
+
const FnPrefixSelector = "selector.";
|
|
1810
2076
|
function runtimeCallsite() {
|
|
1811
2077
|
return traceCallsite();
|
|
1812
2078
|
}
|
|
@@ -1867,9 +2133,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1867
2133
|
let arg;
|
|
1868
2134
|
let style;
|
|
1869
2135
|
let debug;
|
|
1870
|
-
let
|
|
2136
|
+
let weight = null;
|
|
1871
2137
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1872
|
-
|
|
2138
|
+
weight = params[0];
|
|
1873
2139
|
arg = params[1];
|
|
1874
2140
|
style = params[2];
|
|
1875
2141
|
debug = params[3];
|
|
@@ -1879,7 +2145,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1879
2145
|
debug = params[2];
|
|
1880
2146
|
}
|
|
1881
2147
|
else if (isMedia && typeof params[0] === "number") {
|
|
1882
|
-
|
|
2148
|
+
weight = params[0];
|
|
1883
2149
|
arg = fnSelector.selector;
|
|
1884
2150
|
style = params[1];
|
|
1885
2151
|
debug = params[2];
|
|
@@ -1899,7 +2165,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1899
2165
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1900
2166
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
1901
2167
|
const item = items[j];
|
|
1902
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2168
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
1903
2169
|
}
|
|
1904
2170
|
}
|
|
1905
2171
|
return createFnResult(data, fns);
|
|
@@ -1966,9 +2232,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1966
2232
|
let arg;
|
|
1967
2233
|
let data;
|
|
1968
2234
|
let debug;
|
|
1969
|
-
let
|
|
2235
|
+
let weight = null;
|
|
1970
2236
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1971
|
-
|
|
2237
|
+
weight = params[0];
|
|
1972
2238
|
arg = params[1];
|
|
1973
2239
|
data = params[2];
|
|
1974
2240
|
debug = params[3];
|
|
@@ -1978,7 +2244,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1978
2244
|
debug = params[2];
|
|
1979
2245
|
}
|
|
1980
2246
|
else if (isMedia && typeof params[0] === "number") {
|
|
1981
|
-
|
|
2247
|
+
weight = params[0];
|
|
1982
2248
|
arg = fnSelector.selector;
|
|
1983
2249
|
data = params[1];
|
|
1984
2250
|
debug = params[2];
|
|
@@ -1995,7 +2261,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1995
2261
|
selector = args[i];
|
|
1996
2262
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
1997
2263
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1998
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2264
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
1999
2265
|
}
|
|
2000
2266
|
return result;
|
|
2001
2267
|
};
|
|
@@ -2072,6 +2338,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2072
2338
|
traceMarker(fn, "slot");
|
|
2073
2339
|
return fn;
|
|
2074
2340
|
}
|
|
2341
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2342
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2343
|
+
const fn = (selector, style, debug) => {
|
|
2344
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2345
|
+
debug = style;
|
|
2346
|
+
style = void 0;
|
|
2347
|
+
}
|
|
2348
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2349
|
+
if (style === void 0) return target;
|
|
2350
|
+
return target(style, debug);
|
|
2351
|
+
};
|
|
2352
|
+
traceMarker(fn, "style.selector");
|
|
2353
|
+
return fn;
|
|
2354
|
+
}
|
|
2075
2355
|
function createScopeBuilder(selectors) {
|
|
2076
2356
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2077
2357
|
const fn = (items, debug) => {
|
|
@@ -2087,6 +2367,34 @@ function createScopeBuilder(selectors) {
|
|
|
2087
2367
|
traceMarker(fn, "scope");
|
|
2088
2368
|
return fn;
|
|
2089
2369
|
}
|
|
2370
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2371
|
+
const callable = ((style, debug) => {
|
|
2372
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2373
|
+
debug = style;
|
|
2374
|
+
style = void 0;
|
|
2375
|
+
}
|
|
2376
|
+
const callsite = resolveCallsite(debug);
|
|
2377
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2378
|
+
});
|
|
2379
|
+
traceMarker(callable, "selector.override");
|
|
2380
|
+
Object.setPrototypeOf(callable, fns);
|
|
2381
|
+
Object.assign(callable, data);
|
|
2382
|
+
return callable;
|
|
2383
|
+
}
|
|
2384
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2385
|
+
const callable = ((style, debug) => {
|
|
2386
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2387
|
+
debug = style;
|
|
2388
|
+
style = void 0;
|
|
2389
|
+
}
|
|
2390
|
+
const callsite = resolveCallsite(debug);
|
|
2391
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2392
|
+
});
|
|
2393
|
+
traceMarker(callable, "selector");
|
|
2394
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2395
|
+
Object.assign(callable, data);
|
|
2396
|
+
return callable;
|
|
2397
|
+
}
|
|
2090
2398
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2091
2399
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2092
2400
|
const callable = ((style, debug) => {
|
|
@@ -2695,6 +3003,497 @@ function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, to
|
|
|
2695
3003
|
}
|
|
2696
3004
|
createIdCounter("property");
|
|
2697
3005
|
//#endregion
|
|
3006
|
+
//#region sheet/utils/sourcemap.ts
|
|
3007
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3008
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3009
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3010
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3011
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3012
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3013
|
+
function encodeBase64(text) {
|
|
3014
|
+
const bytes = new TextEncoder().encode(text);
|
|
3015
|
+
let binary = "";
|
|
3016
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3017
|
+
return btoa(binary);
|
|
3018
|
+
}
|
|
3019
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3020
|
+
let source = sourceLookup[filePath];
|
|
3021
|
+
if (source) {
|
|
3022
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3023
|
+
return source;
|
|
3024
|
+
}
|
|
3025
|
+
source = {
|
|
3026
|
+
filePath,
|
|
3027
|
+
sourceIndex: sources.length,
|
|
3028
|
+
sourceContent
|
|
3029
|
+
};
|
|
3030
|
+
sources.push(source);
|
|
3031
|
+
sourceLookup[filePath] = source;
|
|
3032
|
+
return source;
|
|
3033
|
+
}
|
|
3034
|
+
function normalizeSourcePath(filePath) {
|
|
3035
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3036
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3037
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3038
|
+
return filePath.replace(/^at\s+/, "");
|
|
3039
|
+
}
|
|
3040
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3041
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3042
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3043
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3044
|
+
}
|
|
3045
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3046
|
+
const sidecarUrl = getSidecarUrl();
|
|
3047
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3048
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3049
|
+
}
|
|
3050
|
+
function getSidecarUrl() {
|
|
3051
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3052
|
+
return typeof value === "string" && value ? value : null;
|
|
3053
|
+
}
|
|
3054
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3055
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3056
|
+
try {
|
|
3057
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3058
|
+
} catch {
|
|
3059
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3063
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3064
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3065
|
+
return path ? `${base}/${path}` : base;
|
|
3066
|
+
}
|
|
3067
|
+
function getLineCount(css) {
|
|
3068
|
+
let count = 1;
|
|
3069
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3070
|
+
return count;
|
|
3071
|
+
}
|
|
3072
|
+
function encodeVlq(value) {
|
|
3073
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3074
|
+
let encoded = "";
|
|
3075
|
+
do {
|
|
3076
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3077
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3078
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3079
|
+
encoded += BASE64[digit];
|
|
3080
|
+
} while (vlq > 0);
|
|
3081
|
+
return encoded;
|
|
3082
|
+
}
|
|
3083
|
+
//#endregion
|
|
3084
|
+
//#region sheet/sourcemap.ts
|
|
3085
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3086
|
+
if (debug && debugField) {
|
|
3087
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3088
|
+
if (loc) return normalizeRuleCallsite({
|
|
3089
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3090
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3091
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3092
|
+
line: loc[0],
|
|
3093
|
+
column: loc[1]
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3097
|
+
if (debug) return normalizeRuleCallsite({
|
|
3098
|
+
filePath: debug.sourceUrl,
|
|
3099
|
+
sourceUrl: debug.sourceUrl,
|
|
3100
|
+
sourceContent: debug.code,
|
|
3101
|
+
line: debug.loc[0],
|
|
3102
|
+
column: debug.loc[1]
|
|
3103
|
+
});
|
|
3104
|
+
return callsite || null;
|
|
3105
|
+
}
|
|
3106
|
+
function normalizeRuleCallsite(callsite) {
|
|
3107
|
+
return {
|
|
3108
|
+
...callsite,
|
|
3109
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3110
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3114
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3115
|
+
//#endregion
|
|
3116
|
+
//#region builder/extract/utils.ts
|
|
3117
|
+
function createExtractedData(type, slotId) {
|
|
3118
|
+
const data = {
|
|
3119
|
+
[BUILDER_TYPE]: type,
|
|
3120
|
+
[BUILDER_STATE]: {
|
|
3121
|
+
items: [],
|
|
3122
|
+
lookup: {}
|
|
3123
|
+
},
|
|
3124
|
+
[BUILDER_CALLSITE]: null
|
|
3125
|
+
};
|
|
3126
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3127
|
+
return data;
|
|
3128
|
+
}
|
|
3129
|
+
function copyExtractedData(target, source) {
|
|
3130
|
+
const mutable = target;
|
|
3131
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3132
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3133
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3134
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3135
|
+
}
|
|
3136
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3137
|
+
return {
|
|
3138
|
+
[BUILDER_TYPE]: 5,
|
|
3139
|
+
[BUILDER_SCOPE]: scope,
|
|
3140
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3144
|
+
const normalized = [];
|
|
3145
|
+
let i = 0;
|
|
3146
|
+
while (i < items.length) {
|
|
3147
|
+
const item = items[i];
|
|
3148
|
+
const value = item[2];
|
|
3149
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3150
|
+
type,
|
|
3151
|
+
item[0],
|
|
3152
|
+
item[1]
|
|
3153
|
+
] : [
|
|
3154
|
+
type,
|
|
3155
|
+
slotId,
|
|
3156
|
+
item[0],
|
|
3157
|
+
item[1]
|
|
3158
|
+
] : slotId === null ? [
|
|
3159
|
+
type,
|
|
3160
|
+
item[0],
|
|
3161
|
+
item[1],
|
|
3162
|
+
value
|
|
3163
|
+
] : [
|
|
3164
|
+
type,
|
|
3165
|
+
slotId,
|
|
3166
|
+
item[0],
|
|
3167
|
+
item[1],
|
|
3168
|
+
value
|
|
3169
|
+
]);
|
|
3170
|
+
i++;
|
|
3171
|
+
}
|
|
3172
|
+
return normalized;
|
|
3173
|
+
}
|
|
3174
|
+
//#endregion
|
|
3175
|
+
//#region builder/extract/withTokens.ts
|
|
3176
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3177
|
+
function isExtractedTokenBoundData(value) {
|
|
3178
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3179
|
+
}
|
|
3180
|
+
function getExtractedTokenBoundData(value) {
|
|
3181
|
+
return tokenBoundData.get(value);
|
|
3182
|
+
}
|
|
3183
|
+
function isElementDebugData(value) {
|
|
3184
|
+
if (!value || typeof value !== "object") return false;
|
|
3185
|
+
return value.$$elementDebug === true;
|
|
3186
|
+
}
|
|
3187
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3188
|
+
//#endregion
|
|
3189
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3190
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3191
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3192
|
+
function markResolvedStyleItem(item) {
|
|
3193
|
+
resolvedStyleItems.add(item);
|
|
3194
|
+
}
|
|
3195
|
+
function isResolvedStyleItem$1(value) {
|
|
3196
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3197
|
+
}
|
|
3198
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3199
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
3200
|
+
}
|
|
3201
|
+
//#endregion
|
|
3202
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3203
|
+
function createMutableTokenValues(base) {
|
|
3204
|
+
return {
|
|
3205
|
+
ids: base ? base.ids.slice() : null,
|
|
3206
|
+
values: base ? base.values.slice() : null,
|
|
3207
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3208
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
function addTokenOverride(values, item, resolver) {
|
|
3212
|
+
if (!resolver.is(item)) return false;
|
|
3213
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3214
|
+
return true;
|
|
3215
|
+
}
|
|
3216
|
+
function addTokenValue(values, id, value) {
|
|
3217
|
+
if (!values.ids) values.ids = [];
|
|
3218
|
+
if (!values.values) values.values = [];
|
|
3219
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3220
|
+
if (!values.index) values.index = Object.create(null);
|
|
3221
|
+
const ids = values.ids;
|
|
3222
|
+
const tokenValues = values.values;
|
|
3223
|
+
const lookup = values.lookup;
|
|
3224
|
+
const indexLookup = values.index;
|
|
3225
|
+
const index = indexLookup[id];
|
|
3226
|
+
if (index === void 0) {
|
|
3227
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3228
|
+
tokenValues.push(value);
|
|
3229
|
+
} else tokenValues[index] = value;
|
|
3230
|
+
lookup[id] = value;
|
|
3231
|
+
}
|
|
3232
|
+
function addTokenValues(values, next) {
|
|
3233
|
+
if (!next) return;
|
|
3234
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3235
|
+
}
|
|
3236
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3237
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3238
|
+
}
|
|
3239
|
+
function finishTokenValues(base, values) {
|
|
3240
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3241
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
3242
|
+
return {
|
|
3243
|
+
ids: values.ids,
|
|
3244
|
+
values: values.values,
|
|
3245
|
+
lookup: values.lookup
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
function mergeTokenValues(base, next) {
|
|
3249
|
+
if (!next) return base;
|
|
3250
|
+
if (!base) return next;
|
|
3251
|
+
const values = createMutableTokenValues(base);
|
|
3252
|
+
addTokenValues(values, next);
|
|
3253
|
+
return finishTokenValues(base, values);
|
|
3254
|
+
}
|
|
3255
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3256
|
+
if (!overrides.length) return base;
|
|
3257
|
+
const values = createMutableTokenValues(base);
|
|
3258
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3259
|
+
return finishTokenValues(base, values);
|
|
3260
|
+
}
|
|
3261
|
+
function createTokenIndexLookup(ids) {
|
|
3262
|
+
const lookup = Object.create(null);
|
|
3263
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3264
|
+
return lookup;
|
|
3265
|
+
}
|
|
3266
|
+
function isSameTokenValues(base, ids, values) {
|
|
3267
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3268
|
+
const baseLookup = base.lookup;
|
|
3269
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3270
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3271
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3272
|
+
}
|
|
3273
|
+
return true;
|
|
3274
|
+
}
|
|
3275
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3276
|
+
function isResolvedStyleItem(value) {
|
|
3277
|
+
return isResolvedStyleItem$1(value);
|
|
3278
|
+
}
|
|
3279
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3280
|
+
return createStyleItem({
|
|
3281
|
+
data,
|
|
3282
|
+
items: resolveItems(data, scopes)
|
|
3283
|
+
}, tokens);
|
|
3284
|
+
}
|
|
3285
|
+
function createStyleItem(item, tokens = null) {
|
|
3286
|
+
markResolvedStyleItem(item);
|
|
3287
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3288
|
+
return item;
|
|
3289
|
+
}
|
|
3290
|
+
function resolveItems(data, scopes) {
|
|
3291
|
+
const items = [];
|
|
3292
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3293
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3294
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3295
|
+
const item = stateItems[i];
|
|
3296
|
+
if (Array.isArray(item)) {
|
|
3297
|
+
items.push(item);
|
|
3298
|
+
continue;
|
|
3299
|
+
}
|
|
3300
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3301
|
+
items.push(item);
|
|
3302
|
+
continue;
|
|
3303
|
+
}
|
|
3304
|
+
if (slotId && item.type !== 2) continue;
|
|
3305
|
+
items.push(item);
|
|
3306
|
+
}
|
|
3307
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3308
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3309
|
+
const boundScope = scopes[i];
|
|
3310
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3311
|
+
if (!scope) continue;
|
|
3312
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3313
|
+
if (!scopeItems) continue;
|
|
3314
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3315
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3316
|
+
const item = scopeItems[j];
|
|
3317
|
+
if (Array.isArray(item)) {
|
|
3318
|
+
if (item[1] === slotId) items.push(item);
|
|
3319
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3320
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3321
|
+
continue;
|
|
3322
|
+
}
|
|
3323
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3324
|
+
if (item.type !== 4) continue;
|
|
3325
|
+
if (item.slotId === slotId) items.push(item);
|
|
3326
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
return items;
|
|
3330
|
+
}
|
|
3331
|
+
function getScopeParentItem(className) {
|
|
3332
|
+
const parentClassName = formatScopeClassName(className);
|
|
3333
|
+
return [parentClassName, parentClassName];
|
|
3334
|
+
}
|
|
3335
|
+
function formatScopeClassName(className) {
|
|
3336
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3337
|
+
if (!format) return "-" + className;
|
|
3338
|
+
if (typeof format === "function") return format({ className });
|
|
3339
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3340
|
+
}
|
|
3341
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3342
|
+
return value === 1 || value === true;
|
|
3343
|
+
}
|
|
3344
|
+
//#endregion
|
|
3345
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3346
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3347
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3348
|
+
}
|
|
3349
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3350
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3351
|
+
}
|
|
3352
|
+
function getDataTokenValues(data, resolver) {
|
|
3353
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3354
|
+
const values = createMutableTokenValues(null);
|
|
3355
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3356
|
+
return finishTokenValues(null, values);
|
|
3357
|
+
}
|
|
3358
|
+
createCacheValue();
|
|
3359
|
+
function createCacheValue() {
|
|
3360
|
+
return {
|
|
3361
|
+
d: null,
|
|
3362
|
+
c: RUNTIME_CONFIG.changes
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
//#endregion
|
|
3366
|
+
//#region runtime/core/cache/token.ts
|
|
3367
|
+
const runtimeTokenValueResolver = {
|
|
3368
|
+
get key() {
|
|
3369
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3370
|
+
},
|
|
3371
|
+
is: isStyleTokenOverrideData,
|
|
3372
|
+
id(token) {
|
|
3373
|
+
return getStyleTokenId(token);
|
|
3374
|
+
},
|
|
3375
|
+
value(token) {
|
|
3376
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3377
|
+
}
|
|
3378
|
+
};
|
|
3379
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3380
|
+
if (isElementDebugData(item)) return null;
|
|
3381
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3382
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3383
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3384
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3385
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3386
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3387
|
+
}
|
|
3388
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3389
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3390
|
+
return null;
|
|
3391
|
+
}
|
|
3392
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3393
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3394
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3395
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3396
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3397
|
+
if (key && tokens) tokenBindings.push({
|
|
3398
|
+
data: key,
|
|
3399
|
+
tokens
|
|
3400
|
+
});
|
|
3401
|
+
return key;
|
|
3402
|
+
}
|
|
3403
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3404
|
+
return null;
|
|
3405
|
+
}
|
|
3406
|
+
//#endregion
|
|
3407
|
+
//#region atomic/rule.ts
|
|
3408
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3409
|
+
const cssProp = getCssPropertyName(property);
|
|
3410
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3411
|
+
const escapedClass = escapeCssIdent(className);
|
|
3412
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3413
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3414
|
+
let selectorStr = classSelector + itemSelector;
|
|
3415
|
+
if (parentSelector) {
|
|
3416
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3417
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3418
|
+
}
|
|
3419
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3420
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3421
|
+
return rule;
|
|
3422
|
+
}
|
|
3423
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3424
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3425
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3426
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3427
|
+
return [
|
|
3428
|
+
priority ?? 0,
|
|
3429
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3430
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3431
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3432
|
+
atRules ? atRules.length : 0,
|
|
3433
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3434
|
+
getPropertyPriority(property)
|
|
3435
|
+
];
|
|
3436
|
+
}
|
|
3437
|
+
function getMediaPriority(atRules, priority) {
|
|
3438
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3439
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3440
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3441
|
+
}
|
|
3442
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3443
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3444
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3445
|
+
return LayerSelectorPriorities.base;
|
|
3446
|
+
}
|
|
3447
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3448
|
+
if (!parentSelector) return 0;
|
|
3449
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3450
|
+
}
|
|
3451
|
+
function getAtRulePriority$1(atRules) {
|
|
3452
|
+
if (!atRules?.length) return 0;
|
|
3453
|
+
let priority = 0;
|
|
3454
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3455
|
+
return priority;
|
|
3456
|
+
}
|
|
3457
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3458
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3459
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3460
|
+
}
|
|
3461
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3462
|
+
const declarations = [];
|
|
3463
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3464
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3465
|
+
}
|
|
3466
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3467
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3468
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3469
|
+
return name + ":" + value;
|
|
3470
|
+
}
|
|
3471
|
+
function normalizeThemeName(value) {
|
|
3472
|
+
if (!value) return null;
|
|
3473
|
+
value = value.trim();
|
|
3474
|
+
if (!value) return null;
|
|
3475
|
+
if (/^\d+$/.test(value)) return null;
|
|
3476
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3477
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3478
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3479
|
+
value = stripGenericThemePrefix(value);
|
|
3480
|
+
if (!value) return null;
|
|
3481
|
+
return value;
|
|
3482
|
+
}
|
|
3483
|
+
function stripGenericThemePrefix(value) {
|
|
3484
|
+
const parts = value.split("--");
|
|
3485
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3486
|
+
value = parts.join("--");
|
|
3487
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3488
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3489
|
+
return value;
|
|
3490
|
+
}
|
|
3491
|
+
function isGeneratedNameHash(value) {
|
|
3492
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3493
|
+
}
|
|
3494
|
+
createNameFormatter(["name"]);
|
|
3495
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3496
|
+
//#endregion
|
|
2698
3497
|
//#region style/keyframes.ts
|
|
2699
3498
|
function transformKeyframes(frames, transform) {
|
|
2700
3499
|
if (!transform) return frames;
|
|
@@ -2721,9 +3520,11 @@ function createStyleFn(args) {
|
|
|
2721
3520
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2722
3521
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2723
3522
|
const fnScope = createScopeBuilder(selectors);
|
|
2724
|
-
const
|
|
2725
|
-
|
|
3523
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3524
|
+
const fnWeight = (value, weight) => {
|
|
3525
|
+
return weightValue(value, weight);
|
|
2726
3526
|
};
|
|
3527
|
+
const fnImportant = (value) => importantValue(value);
|
|
2727
3528
|
const fnRaw = (style) => style;
|
|
2728
3529
|
const fnPlain = (style) => style;
|
|
2729
3530
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2735,11 +3536,13 @@ function createStyleFn(args) {
|
|
|
2735
3536
|
const style = fnStyle;
|
|
2736
3537
|
style.slot = fnSlot;
|
|
2737
3538
|
style.scope = fnScope;
|
|
2738
|
-
style.
|
|
3539
|
+
style.weight = fnWeight;
|
|
3540
|
+
style.important = fnImportant;
|
|
2739
3541
|
style.raw = fnRaw;
|
|
2740
3542
|
style.plain = fnPlain;
|
|
2741
3543
|
style.keyframes = fnKeyframes;
|
|
2742
3544
|
style.merge = fnMerge;
|
|
3545
|
+
style.selector = fnSelector;
|
|
2743
3546
|
assignStyleFnMeta(style, {
|
|
2744
3547
|
mode: "StyleObject",
|
|
2745
3548
|
selectors,
|
|
@@ -2780,9 +3583,11 @@ function createImportSourceMatcher(importSources) {
|
|
|
2780
3583
|
meta: DefaultStyleFnMeta
|
|
2781
3584
|
});
|
|
2782
3585
|
importSources?.forEach((entry) => {
|
|
3586
|
+
const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
|
|
3587
|
+
if (!meta) return;
|
|
2783
3588
|
addImportSourceEntry(state, {
|
|
2784
3589
|
...entry,
|
|
2785
|
-
meta
|
|
3590
|
+
meta
|
|
2786
3591
|
});
|
|
2787
3592
|
});
|
|
2788
3593
|
return (source) => {
|
|
@@ -2874,65 +3679,6 @@ function isGlobPattern(source) {
|
|
|
2874
3679
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
2875
3680
|
}
|
|
2876
3681
|
//#endregion
|
|
2877
|
-
//#region builder/extract/utils.ts
|
|
2878
|
-
function createExtractedData(type, slotId) {
|
|
2879
|
-
const data = {
|
|
2880
|
-
[BUILDER_TYPE]: type,
|
|
2881
|
-
[BUILDER_STATE]: {
|
|
2882
|
-
items: [],
|
|
2883
|
-
lookup: {}
|
|
2884
|
-
},
|
|
2885
|
-
[BUILDER_CALLSITE]: null
|
|
2886
|
-
};
|
|
2887
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
2888
|
-
return data;
|
|
2889
|
-
}
|
|
2890
|
-
function copyExtractedData(target, source) {
|
|
2891
|
-
const mutable = target;
|
|
2892
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
2893
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
2894
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
2895
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
2896
|
-
}
|
|
2897
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
2898
|
-
return {
|
|
2899
|
-
[BUILDER_TYPE]: 5,
|
|
2900
|
-
[BUILDER_SCOPE]: scope,
|
|
2901
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
2902
|
-
};
|
|
2903
|
-
}
|
|
2904
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
2905
|
-
const normalized = [];
|
|
2906
|
-
let i = 0;
|
|
2907
|
-
while (i < items.length) {
|
|
2908
|
-
const item = items[i];
|
|
2909
|
-
const value = item[2];
|
|
2910
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
2911
|
-
type,
|
|
2912
|
-
item[0],
|
|
2913
|
-
item[1]
|
|
2914
|
-
] : [
|
|
2915
|
-
type,
|
|
2916
|
-
slotId,
|
|
2917
|
-
item[0],
|
|
2918
|
-
item[1]
|
|
2919
|
-
] : slotId === null ? [
|
|
2920
|
-
type,
|
|
2921
|
-
item[0],
|
|
2922
|
-
item[1],
|
|
2923
|
-
value
|
|
2924
|
-
] : [
|
|
2925
|
-
type,
|
|
2926
|
-
slotId,
|
|
2927
|
-
item[0],
|
|
2928
|
-
item[1],
|
|
2929
|
-
value
|
|
2930
|
-
]);
|
|
2931
|
-
i++;
|
|
2932
|
-
}
|
|
2933
|
-
return normalized;
|
|
2934
|
-
}
|
|
2935
|
-
//#endregion
|
|
2936
3682
|
//#region builder/extract/scope.ts
|
|
2937
3683
|
function createExtractedScope(items) {
|
|
2938
3684
|
const scope = ((slot) => {
|
|
@@ -2943,6 +3689,15 @@ function createExtractedScope(items) {
|
|
|
2943
3689
|
return scope;
|
|
2944
3690
|
}
|
|
2945
3691
|
//#endregion
|
|
3692
|
+
//#region builder/extract/sheet.ts
|
|
3693
|
+
function createExtractedSheet(items) {
|
|
3694
|
+
const data = createExtractedData(9);
|
|
3695
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3696
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3697
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3698
|
+
return data;
|
|
3699
|
+
}
|
|
3700
|
+
//#endregion
|
|
2946
3701
|
//#region builder/extract/slot.ts
|
|
2947
3702
|
function createExtractedSlot(slotId, items) {
|
|
2948
3703
|
const slot = ((items) => {
|
|
@@ -3086,7 +3841,7 @@ function exposeStyleObject(source) {
|
|
|
3086
3841
|
return result;
|
|
3087
3842
|
}
|
|
3088
3843
|
function exposeStyleValue(value) {
|
|
3089
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
3844
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3090
3845
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3091
3846
|
const exposed = exposeStyleObject(value);
|
|
3092
3847
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3300,6 +4055,12 @@ function evaluateCall(node, scope) {
|
|
|
3300
4055
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3301
4056
|
return evalOk(createExtractedStyle(items.value));
|
|
3302
4057
|
}
|
|
4058
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4059
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4060
|
+
if (!items.ok) return items;
|
|
4061
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4062
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4063
|
+
}
|
|
3303
4064
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3304
4065
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3305
4066
|
if (!style.ok) return style;
|
|
@@ -3488,13 +4249,18 @@ function evaluateCall(node, scope) {
|
|
|
3488
4249
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3489
4250
|
}));
|
|
3490
4251
|
}
|
|
3491
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4252
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
3492
4253
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3493
4254
|
if (!value.ok) return value;
|
|
3494
4255
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3495
4256
|
if (!weight.ok) return weight;
|
|
3496
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3497
|
-
return evalOk(
|
|
4257
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4258
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4259
|
+
}
|
|
4260
|
+
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)) {
|
|
4261
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4262
|
+
if (!value.ok) return value;
|
|
4263
|
+
return evalOk(importantValue(value.value));
|
|
3498
4264
|
}
|
|
3499
4265
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
3500
4266
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3699,64 +4465,27 @@ function evaluateUnary(node, scope) {
|
|
|
3699
4465
|
function isStaticStyleValue(value) {
|
|
3700
4466
|
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3701
4467
|
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3702
|
-
if (value.type === "
|
|
3703
|
-
const [priority, itemValue] = value.elements;
|
|
3704
|
-
return !!priority && priority.type === "NumericLiteral" && !!itemValue && isStaticStyleValue(itemValue);
|
|
3705
|
-
}
|
|
3706
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "value") {
|
|
4468
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
3707
4469
|
const [itemValue, weight] = value.arguments;
|
|
3708
4470
|
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
3709
4471
|
}
|
|
4472
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4473
|
+
const [itemValue] = value.arguments;
|
|
4474
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4475
|
+
}
|
|
3710
4476
|
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3711
4477
|
return false;
|
|
3712
4478
|
}
|
|
3713
|
-
//#endregion
|
|
3714
|
-
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
3715
|
-
function isStyleChainCall(callee, styleNames) {
|
|
3716
|
-
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
3717
|
-
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
3718
|
-
const object = callee.object;
|
|
3719
|
-
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
3720
|
-
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
3721
|
-
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3722
|
-
return false;
|
|
3723
|
-
}
|
|
3724
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3725
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3726
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3727
|
-
}
|
|
3728
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3729
|
-
const declarations = [];
|
|
3730
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3731
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3732
|
-
}
|
|
3733
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3734
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3735
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3736
|
-
return name + ":" + value;
|
|
3737
|
-
}
|
|
3738
|
-
function normalizeThemeName(value) {
|
|
3739
|
-
if (!value) return null;
|
|
3740
|
-
value = value.trim();
|
|
3741
|
-
if (!value) return null;
|
|
3742
|
-
if (/^\d+$/.test(value)) return null;
|
|
3743
|
-
if (isGeneratedNameHash(value)) return null;
|
|
3744
|
-
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3745
|
-
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3746
|
-
value = stripGenericThemePrefix(value);
|
|
3747
|
-
if (!value) return null;
|
|
3748
|
-
return value;
|
|
3749
|
-
}
|
|
3750
|
-
function stripGenericThemePrefix(value) {
|
|
3751
|
-
const parts = value.split("--");
|
|
3752
|
-
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3753
|
-
value = parts.join("--");
|
|
3754
|
-
if (value.startsWith("theme-")) return value.slice(6);
|
|
3755
|
-
if (value.startsWith("themes-")) return value.slice(7);
|
|
3756
|
-
return value;
|
|
3757
|
-
}
|
|
3758
|
-
function isGeneratedNameHash(value) {
|
|
3759
|
-
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
4479
|
+
//#endregion
|
|
4480
|
+
//#region compiler/transform/syntax/isStyleChainCall.ts
|
|
4481
|
+
function isStyleChainCall(callee, styleNames) {
|
|
4482
|
+
if (callee.type === "Identifier") return styleNames.has(callee.name);
|
|
4483
|
+
if (callee.type !== "MemberExpression" || callee.computed) return false;
|
|
4484
|
+
const object = callee.object;
|
|
4485
|
+
if (object.type === "Identifier") return styleNames.has(object.name);
|
|
4486
|
+
if (object.type === "CallExpression") return isStyleChainCall(object.callee, styleNames);
|
|
4487
|
+
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
4488
|
+
return false;
|
|
3760
4489
|
}
|
|
3761
4490
|
//#endregion
|
|
3762
4491
|
//#region compiler/transform/syntax/utils.ts
|
|
@@ -3892,60 +4621,6 @@ function sanitizeTokenId(value) {
|
|
|
3892
4621
|
return sanitizeCssIdentName(value, "token");
|
|
3893
4622
|
}
|
|
3894
4623
|
//#endregion
|
|
3895
|
-
//#region compiler/transform/utils/babel.ts
|
|
3896
|
-
function babelPlugin(factory) {
|
|
3897
|
-
return factory;
|
|
3898
|
-
}
|
|
3899
|
-
function babelTransform(args) {
|
|
3900
|
-
let result = null;
|
|
3901
|
-
try {
|
|
3902
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
3903
|
-
result = BabelCore.transformSync(args.code, {
|
|
3904
|
-
...babelTransformOptions(),
|
|
3905
|
-
inputSourceMap,
|
|
3906
|
-
filename: args.filePath,
|
|
3907
|
-
sourceFileName: args.filePath,
|
|
3908
|
-
plugins: args.plugins,
|
|
3909
|
-
sourceMaps: true,
|
|
3910
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
3911
|
-
});
|
|
3912
|
-
} catch (err) {
|
|
3913
|
-
if (!args.errorLabel) throw err;
|
|
3914
|
-
const message = getBabelError(err, args);
|
|
3915
|
-
const error = new Error(message);
|
|
3916
|
-
error.stack = void 0;
|
|
3917
|
-
throw error;
|
|
3918
|
-
}
|
|
3919
|
-
if (!result || !result.code) return null;
|
|
3920
|
-
return {
|
|
3921
|
-
code: result.code,
|
|
3922
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
3923
|
-
};
|
|
3924
|
-
}
|
|
3925
|
-
function babelTransformOptions() {
|
|
3926
|
-
return {
|
|
3927
|
-
configFile: false,
|
|
3928
|
-
babelrc: false,
|
|
3929
|
-
parserOpts: {
|
|
3930
|
-
plugins: ["typescript", "jsx"],
|
|
3931
|
-
strictMode: false,
|
|
3932
|
-
allowImportExportEverywhere: true
|
|
3933
|
-
}
|
|
3934
|
-
};
|
|
3935
|
-
}
|
|
3936
|
-
function parseInputSourceMap(sourcemap) {
|
|
3937
|
-
if (!sourcemap) return void 0;
|
|
3938
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
3939
|
-
return JSON.parse(sourcemap);
|
|
3940
|
-
}
|
|
3941
|
-
function getBabelError(err, args) {
|
|
3942
|
-
const babelErr = err;
|
|
3943
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
3944
|
-
const codeFrame = babelErr?.codeFrame;
|
|
3945
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
3946
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
3947
|
-
}
|
|
3948
|
-
//#endregion
|
|
3949
4624
|
//#region compiler/utils/path.ts
|
|
3950
4625
|
function normalizePath(value) {
|
|
3951
4626
|
return value.replace(/\\/g, "/");
|
|
@@ -4492,6 +5167,7 @@ function getDebugCallLoc(path, state) {
|
|
|
4492
5167
|
}
|
|
4493
5168
|
function getStyleObjectArg(path, state) {
|
|
4494
5169
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5170
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4495
5171
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4496
5172
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4497
5173
|
if (!selector) return path.node.arguments[0];
|
|
@@ -4916,7 +5592,7 @@ function transformDebug(internal, args, deps) {
|
|
|
4916
5592
|
code: args.code,
|
|
4917
5593
|
filePath: args.filePath,
|
|
4918
5594
|
sourcemap: args.sourcemap,
|
|
4919
|
-
plugins: [plugin],
|
|
5595
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
4920
5596
|
retainLines: true
|
|
4921
5597
|
});
|
|
4922
5598
|
if (!result) return null;
|
|
@@ -4985,59 +5661,18 @@ function resolveFilePath(source, fromFile) {
|
|
|
4985
5661
|
}
|
|
4986
5662
|
}
|
|
4987
5663
|
//#endregion
|
|
4988
|
-
//#region
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
4997
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
4998
|
-
}
|
|
4999
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
5000
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
5001
|
-
return rule;
|
|
5002
|
-
}
|
|
5003
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
5004
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
5005
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
5006
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
5007
|
-
return [
|
|
5008
|
-
priority ?? 0,
|
|
5009
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
5010
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
5011
|
-
getMediaPriority(atRules, atRulePriority),
|
|
5012
|
-
atRules ? atRules.length : 0,
|
|
5013
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
5014
|
-
getPropertyPriority(property)
|
|
5015
|
-
];
|
|
5016
|
-
}
|
|
5017
|
-
function getMediaPriority(atRules, priority) {
|
|
5018
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
5019
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
5020
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
5021
|
-
}
|
|
5022
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
5023
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
5024
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
5025
|
-
return LayerSelectorPriorities.base;
|
|
5026
|
-
}
|
|
5027
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
5028
|
-
if (!parentSelector) return 0;
|
|
5029
|
-
return priority > 0 ? priority + 1 : 1;
|
|
5030
|
-
}
|
|
5031
|
-
function getAtRulePriority$1(atRules) {
|
|
5032
|
-
if (!atRules?.length) return 0;
|
|
5033
|
-
let priority = 0;
|
|
5034
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
5035
|
-
return priority;
|
|
5036
|
-
}
|
|
5664
|
+
//#region compiler/compiler/constants.ts
|
|
5665
|
+
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
5666
|
+
CompilerRuntimeMode["Dev"] = "dev";
|
|
5667
|
+
CompilerRuntimeMode["Prod"] = "prod";
|
|
5668
|
+
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
5669
|
+
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
5670
|
+
return CompilerRuntimeMode;
|
|
5671
|
+
}({});
|
|
5037
5672
|
//#endregion
|
|
5038
5673
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
5039
5674
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
5040
|
-
function extractStyleChain(node, styleNames) {
|
|
5675
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5041
5676
|
if (node.type !== "CallExpression") return null;
|
|
5042
5677
|
const callee = node.callee;
|
|
5043
5678
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -5046,6 +5681,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
5046
5681
|
baseArgs: node.arguments,
|
|
5047
5682
|
methods: []
|
|
5048
5683
|
};
|
|
5684
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5685
|
+
kind: "sheet",
|
|
5686
|
+
rootName: callee.name,
|
|
5687
|
+
baseArgs: node.arguments,
|
|
5688
|
+
methods: []
|
|
5689
|
+
};
|
|
5049
5690
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5050
5691
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
5051
5692
|
if (!prop) return null;
|
|
@@ -5063,10 +5704,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
5063
5704
|
baseArgs: node.arguments,
|
|
5064
5705
|
methods: []
|
|
5065
5706
|
};
|
|
5707
|
+
if (prop === "selector") return {
|
|
5708
|
+
kind: "selector",
|
|
5709
|
+
rootName: obj.name,
|
|
5710
|
+
baseArgs: node.arguments,
|
|
5711
|
+
methods: []
|
|
5712
|
+
};
|
|
5066
5713
|
if (prop !== "merge") return null;
|
|
5067
5714
|
const target = node.arguments[0];
|
|
5068
5715
|
if (!target) return null;
|
|
5069
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5716
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
5070
5717
|
if (!targetChain) return null;
|
|
5071
5718
|
return {
|
|
5072
5719
|
...targetChain,
|
|
@@ -5078,7 +5725,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
5078
5725
|
};
|
|
5079
5726
|
}
|
|
5080
5727
|
if (obj.type === "CallExpression") {
|
|
5081
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5728
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
5082
5729
|
if (!inner) return null;
|
|
5083
5730
|
return {
|
|
5084
5731
|
...inner,
|
|
@@ -5102,18 +5749,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
5102
5749
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5103
5750
|
let result = null;
|
|
5104
5751
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5105
|
-
const
|
|
5752
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5753
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
5106
5754
|
if (!runtimeValue) continue;
|
|
5107
5755
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5108
5756
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5109
5757
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
5110
|
-
|
|
5758
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5759
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
5111
5760
|
}
|
|
5112
5761
|
return result ?? styleObj;
|
|
5113
5762
|
}
|
|
5114
|
-
function getPriorityTupleValue(value) {
|
|
5115
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5116
|
-
}
|
|
5117
5763
|
function cloneCompiledStyleObject(styleObj) {
|
|
5118
5764
|
const cloned = { ...styleObj };
|
|
5119
5765
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5196,9 +5842,11 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5196
5842
|
*/
|
|
5197
5843
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5198
5844
|
const css = getCssConfig(opts, runtimeMode);
|
|
5845
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5846
|
+
if (!meta) return null;
|
|
5199
5847
|
if (meta.mode === "ClassName") {
|
|
5200
5848
|
if (chain.kind !== "style") return null;
|
|
5201
|
-
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5849
|
+
return compileClassNameChain(chain, meta.selectors, fileId, nodeLoc, scope, css, meta.transform, styleNames, opts);
|
|
5202
5850
|
}
|
|
5203
5851
|
const selectors = meta.selectors;
|
|
5204
5852
|
const transform = meta.transform;
|
|
@@ -5207,16 +5855,101 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5207
5855
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5208
5856
|
return null;
|
|
5209
5857
|
}
|
|
5858
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5859
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5860
|
+
const items = [];
|
|
5861
|
+
const rules = [];
|
|
5862
|
+
const sheetItems = chain.baseArgs[0];
|
|
5863
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5864
|
+
return {
|
|
5865
|
+
type: "sheet",
|
|
5866
|
+
items,
|
|
5867
|
+
rules
|
|
5868
|
+
};
|
|
5869
|
+
}
|
|
5870
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5871
|
+
if (node.type === "ArrayExpression") {
|
|
5872
|
+
for (const element of node.elements) {
|
|
5873
|
+
if (!element) continue;
|
|
5874
|
+
if (element.type === "SpreadElement") return false;
|
|
5875
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
5876
|
+
}
|
|
5877
|
+
return true;
|
|
5878
|
+
}
|
|
5879
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
5880
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
5881
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
5882
|
+
return true;
|
|
5883
|
+
}
|
|
5884
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
5885
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
5886
|
+
const item = tokenOverride.value[i];
|
|
5887
|
+
if (!item) continue;
|
|
5888
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
5889
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
5890
|
+
}
|
|
5891
|
+
return true;
|
|
5892
|
+
}
|
|
5893
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
5894
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
5895
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
5896
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
5897
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
5898
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
5899
|
+
}
|
|
5900
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
5901
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
5902
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5903
|
+
if (!selectorArg.ok) return false;
|
|
5904
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
5905
|
+
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;
|
|
5906
|
+
return true;
|
|
5907
|
+
}
|
|
5908
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
5909
|
+
if (chain.baseArgs[1]) {
|
|
5910
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
5911
|
+
}
|
|
5912
|
+
let i = 0;
|
|
5913
|
+
while (i < chain.methods.length) {
|
|
5914
|
+
const method = chain.methods[i];
|
|
5915
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
5916
|
+
i++;
|
|
5917
|
+
}
|
|
5918
|
+
return true;
|
|
5919
|
+
}
|
|
5920
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
5921
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5922
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5923
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5924
|
+
if (styleArgNode.type === "CallExpression") {
|
|
5925
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5926
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5927
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5928
|
+
}
|
|
5929
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5930
|
+
if (!styleArg.ok) {
|
|
5931
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
5932
|
+
return false;
|
|
5933
|
+
}
|
|
5934
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5935
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5936
|
+
}
|
|
5210
5937
|
function getCssConfig(opts, runtimeMode) {
|
|
5211
5938
|
const css = opts.css;
|
|
5212
5939
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
5940
|
+
const debugClassName = css?.debugClassName ?? isDevRuntimeMode;
|
|
5213
5941
|
return {
|
|
5214
5942
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5943
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5215
5944
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5216
|
-
hashLength:
|
|
5945
|
+
hashLength: getClassNameHashLength({
|
|
5946
|
+
debugClassName,
|
|
5947
|
+
isDev: isDevRuntimeMode,
|
|
5948
|
+
cssHashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength
|
|
5949
|
+
}),
|
|
5217
5950
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
5218
5951
|
localClassName: isDevRuntimeMode,
|
|
5219
|
-
debugClassName
|
|
5952
|
+
debugClassName,
|
|
5220
5953
|
scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
|
|
5221
5954
|
};
|
|
5222
5955
|
}
|
|
@@ -5234,10 +5967,10 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5234
5967
|
rules
|
|
5235
5968
|
};
|
|
5236
5969
|
}
|
|
5237
|
-
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
5970
|
+
function compileClassNameChain(chain, selectors, fileId, nodeLoc, scope, cssConfig, transform, styleNames, options) {
|
|
5238
5971
|
const items = [];
|
|
5239
5972
|
const rules = [];
|
|
5240
|
-
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
5973
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, createClassNameFallbackLocation(nodeLoc, scope, fileId), cssConfig, transform, 1, null, items, rules)) return null;
|
|
5241
5974
|
let i = 0;
|
|
5242
5975
|
while (i < chain.methods.length) {
|
|
5243
5976
|
const method = chain.methods[i];
|
|
@@ -5259,7 +5992,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5259
5992
|
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5260
5993
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5261
5994
|
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5262
|
-
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5995
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, method.nameNode.loc?.start, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5263
5996
|
if (!result) return false;
|
|
5264
5997
|
items.push(...result.items);
|
|
5265
5998
|
rules.push(...result.rules);
|
|
@@ -5284,7 +6017,7 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5284
6017
|
}
|
|
5285
6018
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5286
6019
|
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5287
|
-
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6020
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5288
6021
|
}
|
|
5289
6022
|
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5290
6023
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5294,14 +6027,15 @@ function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig
|
|
|
5294
6027
|
if (!selectorArg.ok) return false;
|
|
5295
6028
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5296
6029
|
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5297
|
-
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6030
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5298
6031
|
}
|
|
5299
6032
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5300
|
-
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
6033
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, createClassNameFallbackLocation(method.nameNode.loc?.start, scope, fileId), cssConfig, transform, 1, null, items, rules);
|
|
5301
6034
|
}
|
|
5302
|
-
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
6035
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, fallbackLocation, cssConfig, transform, type, slotId, items, rules) {
|
|
5303
6036
|
if (startIndex >= args.length) return true;
|
|
5304
6037
|
const styleObj = {};
|
|
6038
|
+
const locations = {};
|
|
5305
6039
|
let i = startIndex;
|
|
5306
6040
|
while (i < args.length) {
|
|
5307
6041
|
const arg = evaluateNode(args[i], scope);
|
|
@@ -5309,28 +6043,59 @@ function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, s
|
|
|
5309
6043
|
throwIfRequiredStaticStyleValue(arg);
|
|
5310
6044
|
return false;
|
|
5311
6045
|
}
|
|
5312
|
-
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
6046
|
+
if (!appendClassNameArgStyle(args[i], arg.value, transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
|
|
5313
6047
|
i++;
|
|
5314
6048
|
}
|
|
6049
|
+
if (Object.keys(locations).length) Object.defineProperty(styleObj, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
6050
|
+
configurable: true,
|
|
6051
|
+
enumerable: false,
|
|
6052
|
+
value: locations
|
|
6053
|
+
});
|
|
5315
6054
|
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5316
6055
|
}
|
|
5317
|
-
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
6056
|
+
function appendClassNameArgStyle(node, value, transform, styleObj, locations, fallbackLocation, scope, fileId) {
|
|
5318
6057
|
if (!value) return true;
|
|
5319
6058
|
if (typeof value === "string") {
|
|
5320
|
-
|
|
6059
|
+
const transformed = decorateClassNameStyle(transform.transform(value), value);
|
|
6060
|
+
Object.assign(styleObj, transformed);
|
|
6061
|
+
assignClassNameStyleLocations(transformed, locations, getClassNameArgLocation(node, fallbackLocation, scope, fileId));
|
|
5321
6062
|
return true;
|
|
5322
6063
|
}
|
|
5323
6064
|
if (Array.isArray(value)) {
|
|
5324
|
-
|
|
6065
|
+
const nodes = node.type === "ArrayExpression" ? node.elements : [];
|
|
6066
|
+
for (let i = 0; i < value.length; i++) if (!appendClassNameArgStyle(nodes[i] ?? node, value[i], transform, styleObj, locations, fallbackLocation, scope, fileId)) return false;
|
|
5325
6067
|
return true;
|
|
5326
6068
|
}
|
|
5327
6069
|
if (isWeightedClassName(value)) {
|
|
5328
6070
|
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5329
6071
|
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
6072
|
+
assignClassNameStyleLocations(transformed, locations, getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId));
|
|
5330
6073
|
return true;
|
|
5331
6074
|
}
|
|
5332
6075
|
return false;
|
|
5333
6076
|
}
|
|
6077
|
+
function assignClassNameStyleLocations(styleObj, locations, location) {
|
|
6078
|
+
if (!location) return;
|
|
6079
|
+
for (const property of Object.keys(styleObj)) locations[property] = location;
|
|
6080
|
+
}
|
|
6081
|
+
function getClassNameArgLocation(node, fallbackLocation, scope, fileId) {
|
|
6082
|
+
if (node.type === "StringLiteral") return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
|
|
6083
|
+
if (node.type === "TemplateLiteral" && node.expressions.length === 0) return createClassNameFallbackLocation(node.loc?.start, scope, fileId);
|
|
6084
|
+
return fallbackLocation;
|
|
6085
|
+
}
|
|
6086
|
+
function getWeightedClassNameArgLocation(node, fallbackLocation, scope, fileId) {
|
|
6087
|
+
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);
|
|
6088
|
+
return fallbackLocation;
|
|
6089
|
+
}
|
|
6090
|
+
function createClassNameFallbackLocation(loc, scope, fileId) {
|
|
6091
|
+
if (!loc) return null;
|
|
6092
|
+
return {
|
|
6093
|
+
filePath: scope.styleFilePath ?? fileId,
|
|
6094
|
+
line: loc.line,
|
|
6095
|
+
column: loc.column + 1,
|
|
6096
|
+
variable: false
|
|
6097
|
+
};
|
|
6098
|
+
}
|
|
5334
6099
|
function decorateClassNameStyle(style, className) {
|
|
5335
6100
|
const result = {};
|
|
5336
6101
|
for (const [property, value] of Object.entries(style)) {
|
|
@@ -5338,15 +6103,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5338
6103
|
result[property] = value;
|
|
5339
6104
|
continue;
|
|
5340
6105
|
}
|
|
5341
|
-
|
|
5342
|
-
const rawValue = value[1];
|
|
5343
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5344
|
-
continue;
|
|
5345
|
-
}
|
|
5346
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6106
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5347
6107
|
}
|
|
5348
6108
|
return result;
|
|
5349
6109
|
}
|
|
6110
|
+
function decorateClassNameValue(value, className) {
|
|
6111
|
+
if (isClassNameValue(value)) return value;
|
|
6112
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6113
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6114
|
+
return classNameValue(value, className);
|
|
6115
|
+
}
|
|
5350
6116
|
function isWeightedClassName(value) {
|
|
5351
6117
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5352
6118
|
}
|
|
@@ -5357,23 +6123,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5357
6123
|
weighted[property] = value;
|
|
5358
6124
|
continue;
|
|
5359
6125
|
}
|
|
5360
|
-
weighted[property] =
|
|
6126
|
+
weighted[property] = weightValue(value, weight);
|
|
5361
6127
|
}
|
|
5362
6128
|
return weighted;
|
|
5363
6129
|
}
|
|
5364
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6130
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5365
6131
|
if (chain.baseArgs.length > 0) {
|
|
5366
6132
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5367
6133
|
if (!styleArg.ok) {
|
|
5368
6134
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5369
6135
|
return false;
|
|
5370
6136
|
}
|
|
5371
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6137
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5372
6138
|
}
|
|
5373
6139
|
let i = 0;
|
|
5374
6140
|
while (i < chain.methods.length) {
|
|
5375
6141
|
const method = chain.methods[i];
|
|
5376
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6142
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5377
6143
|
i++;
|
|
5378
6144
|
}
|
|
5379
6145
|
return true;
|
|
@@ -5420,7 +6186,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5420
6186
|
rules
|
|
5421
6187
|
};
|
|
5422
6188
|
}
|
|
5423
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6189
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5424
6190
|
const selector = selectors[method.name];
|
|
5425
6191
|
if (!selector) return false;
|
|
5426
6192
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5693,10 +6459,10 @@ function getSlotIdFromValue(value) {
|
|
|
5693
6459
|
const slotId = value.slotId;
|
|
5694
6460
|
return typeof slotId === "string" ? slotId : null;
|
|
5695
6461
|
}
|
|
5696
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6462
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5697
6463
|
if (method.name === "$$style.merge") {
|
|
5698
6464
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5699
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6465
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5700
6466
|
}
|
|
5701
6467
|
const selector = selectors[method.name];
|
|
5702
6468
|
if (!selector) return false;
|
|
@@ -5704,42 +6470,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5704
6470
|
const selectorStr = selector.selector.trim();
|
|
5705
6471
|
if (selectorStr === "...") {
|
|
5706
6472
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5707
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6473
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5708
6474
|
}
|
|
5709
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5710
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6475
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6476
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5711
6477
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6478
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5712
6479
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5713
6480
|
if (!styleArg.ok) {
|
|
5714
6481
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5715
6482
|
return false;
|
|
5716
6483
|
}
|
|
5717
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6484
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5718
6485
|
}
|
|
5719
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6486
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5720
6487
|
if (!styleArgNode) return false;
|
|
5721
6488
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5722
6489
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5723
6490
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5724
|
-
if (
|
|
6491
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5725
6492
|
if (styleArgNode.type === "CallExpression") {
|
|
5726
6493
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5727
6494
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5728
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6495
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5729
6496
|
}
|
|
5730
6497
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5731
6498
|
if (!styleArg.ok) {
|
|
5732
6499
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5733
6500
|
return false;
|
|
5734
6501
|
}
|
|
5735
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5736
|
-
return addStyleDataItems(styleArg.value,
|
|
6502
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6503
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5737
6504
|
}
|
|
5738
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6505
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5739
6506
|
if (node.type !== "Identifier") return null;
|
|
5740
6507
|
const init = scope.bindingNodes?.get(node.name);
|
|
5741
6508
|
if (!init) return null;
|
|
5742
|
-
return extractStyleChain(init, styleNames);
|
|
6509
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6510
|
+
}
|
|
6511
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6512
|
+
const callee = node.callee;
|
|
6513
|
+
if (callee.type === "Identifier") {
|
|
6514
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6515
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6516
|
+
return {
|
|
6517
|
+
...target,
|
|
6518
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6519
|
+
};
|
|
6520
|
+
}
|
|
6521
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6522
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6523
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6524
|
+
...memberTarget,
|
|
6525
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6526
|
+
};
|
|
6527
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6528
|
+
if (!methodName) return null;
|
|
6529
|
+
const object = callee.object;
|
|
6530
|
+
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;
|
|
6531
|
+
if (target?.kind !== "selector") return null;
|
|
6532
|
+
return {
|
|
6533
|
+
...target,
|
|
6534
|
+
methods: [...target.methods, {
|
|
6535
|
+
name: methodName,
|
|
6536
|
+
args: node.arguments,
|
|
6537
|
+
nameNode: callee.property
|
|
6538
|
+
}]
|
|
6539
|
+
};
|
|
6540
|
+
}
|
|
6541
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6542
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6543
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6544
|
+
if (!propertyName) return null;
|
|
6545
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6546
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6547
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6548
|
+
const property = objectInit.properties[i];
|
|
6549
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6550
|
+
const key = property.key;
|
|
6551
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6552
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6553
|
+
}
|
|
6554
|
+
return null;
|
|
6555
|
+
}
|
|
6556
|
+
function isBareSelectorTargetChain(chain) {
|
|
6557
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5743
6558
|
}
|
|
5744
6559
|
function getLocalBindingNode(node, scope) {
|
|
5745
6560
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5767,7 +6582,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5767
6582
|
default: return false;
|
|
5768
6583
|
}
|
|
5769
6584
|
}
|
|
5770
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6585
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5771
6586
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5772
6587
|
const hasArg = selectorStr.includes("$$");
|
|
5773
6588
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5789,22 +6604,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5789
6604
|
if (styleArg.type === "CallExpression") {
|
|
5790
6605
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5791
6606
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5792
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6607
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5793
6608
|
const evaled = evaluateNode(styleArg, scope);
|
|
5794
6609
|
if (!evaled.ok) {
|
|
5795
6610
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5796
6611
|
return false;
|
|
5797
6612
|
}
|
|
5798
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6613
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5799
6614
|
}
|
|
5800
6615
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5801
6616
|
if (!styleResult.ok) {
|
|
5802
6617
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5803
6618
|
return false;
|
|
5804
6619
|
}
|
|
5805
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6620
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5806
6621
|
}
|
|
5807
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6622
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5808
6623
|
const selectorStr = selector.selector.trim();
|
|
5809
6624
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5810
6625
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5826,7 +6641,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5826
6641
|
while (i < selectorValues.length) {
|
|
5827
6642
|
const itemSelectorValue = selectorValues[i];
|
|
5828
6643
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5829
|
-
|
|
6644
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6645
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5830
6646
|
i++;
|
|
5831
6647
|
}
|
|
5832
6648
|
return true;
|
|
@@ -5895,6 +6711,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
5895
6711
|
dedupe: overrideItem.dedupe,
|
|
5896
6712
|
className: overrideItem.className,
|
|
5897
6713
|
property: overrideItem.property,
|
|
6714
|
+
weight: overrideItem.weight,
|
|
6715
|
+
important: overrideItem.important,
|
|
5898
6716
|
value: overrideItem.value,
|
|
5899
6717
|
variable: overrideItem.variable,
|
|
5900
6718
|
token: overrideItem.token,
|
|
@@ -5938,22 +6756,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
5938
6756
|
items.push(item);
|
|
5939
6757
|
}
|
|
5940
6758
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5941
|
-
|
|
6759
|
+
const weight = sourceItem.weight;
|
|
6760
|
+
let important = false;
|
|
5942
6761
|
let value = sourceItem.value;
|
|
5943
|
-
|
|
5944
|
-
priority = value[1];
|
|
5945
|
-
value = value[0];
|
|
5946
|
-
}
|
|
6762
|
+
important = sourceItem.important;
|
|
5947
6763
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
5948
6764
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
5949
6765
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5950
6766
|
const valueStr = String(value ?? "");
|
|
5951
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
5952
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6767
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6768
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
5953
6769
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5954
6770
|
items.push(item);
|
|
5955
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
5956
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6771
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6772
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
5957
6773
|
cssRules.push({
|
|
5958
6774
|
dedupe,
|
|
5959
6775
|
className,
|
|
@@ -6016,21 +6832,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
6016
6832
|
items.push(item);
|
|
6017
6833
|
}
|
|
6018
6834
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
6019
|
-
|
|
6835
|
+
const weight = sourceItem.weight;
|
|
6836
|
+
const important = sourceItem.important;
|
|
6020
6837
|
let value = sourceItem.value;
|
|
6021
|
-
|
|
6022
|
-
priority = value[1];
|
|
6023
|
-
value = value[0];
|
|
6024
|
-
}
|
|
6025
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6838
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
6026
6839
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6027
6840
|
const variable = sourceItem.variable;
|
|
6028
6841
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
6029
6842
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
6030
6843
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
6031
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6844
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
6032
6845
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6033
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6846
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6034
6847
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6035
6848
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
6036
6849
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -6038,8 +6851,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6038
6851
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
6039
6852
|
}
|
|
6040
6853
|
items.push(item);
|
|
6041
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6042
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6854
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6855
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
6043
6856
|
cssRules.push({
|
|
6044
6857
|
dedupe,
|
|
6045
6858
|
className,
|
|
@@ -6052,6 +6865,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6052
6865
|
} : void 0
|
|
6053
6866
|
});
|
|
6054
6867
|
}
|
|
6868
|
+
function combineSelectors(parent, child) {
|
|
6869
|
+
const parentText = getItemSelectorText(parent);
|
|
6870
|
+
const childText = getItemSelectorText(child);
|
|
6871
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6872
|
+
const selector = parentText + childText;
|
|
6873
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6874
|
+
}
|
|
6875
|
+
function getItemSelectorText(selector) {
|
|
6876
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6877
|
+
}
|
|
6878
|
+
function getItemSelectorPriority(selector) {
|
|
6879
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6880
|
+
}
|
|
6055
6881
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
6056
6882
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
6057
6883
|
if (!trace) return void 0;
|
|
@@ -6096,13 +6922,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6096
6922
|
while (i < keys.length) {
|
|
6097
6923
|
const property = keys[i];
|
|
6098
6924
|
const rawValue = styleObj[property];
|
|
6099
|
-
let
|
|
6925
|
+
let weight = null;
|
|
6926
|
+
let important = false;
|
|
6100
6927
|
let value = rawValue;
|
|
6101
6928
|
let transformClassName = null;
|
|
6102
|
-
|
|
6103
|
-
priority = rawValue[0];
|
|
6104
|
-
value = rawValue[1];
|
|
6105
|
-
}
|
|
6929
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
6106
6930
|
if (isClassNameValue(value)) {
|
|
6107
6931
|
transformClassName = value.className;
|
|
6108
6932
|
value = value.value;
|
|
@@ -6123,10 +6947,10 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6123
6947
|
column: propertyLoc.column
|
|
6124
6948
|
} : null);
|
|
6125
6949
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
6126
|
-
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6950
|
+
const variableName = shouldUseVariable && propertyLoc && propertyLoc.variable !== false ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6127
6951
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
6128
|
-
const dedupe = getClassNameDedupe(property,
|
|
6129
|
-
const className = getAtomicClassName(property,
|
|
6952
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
6953
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6130
6954
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6131
6955
|
item.sourceTrace = propertyCallsite ? {
|
|
6132
6956
|
property,
|
|
@@ -6151,8 +6975,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6151
6975
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6152
6976
|
}
|
|
6153
6977
|
items.push(item);
|
|
6154
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6155
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
6978
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6979
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6156
6980
|
cssRules.push({
|
|
6157
6981
|
dedupe,
|
|
6158
6982
|
className,
|
|
@@ -6180,6 +7004,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6180
7004
|
}
|
|
6181
7005
|
return true;
|
|
6182
7006
|
}
|
|
7007
|
+
function unwrapStaticStyleValue(value) {
|
|
7008
|
+
let weight = null;
|
|
7009
|
+
let important = false;
|
|
7010
|
+
while (true) {
|
|
7011
|
+
if (isStyleImportantValue(value)) {
|
|
7012
|
+
important = true;
|
|
7013
|
+
value = value.value;
|
|
7014
|
+
continue;
|
|
7015
|
+
}
|
|
7016
|
+
if (isStyleWeightValue(value)) {
|
|
7017
|
+
weight = value.weight;
|
|
7018
|
+
value = value.value;
|
|
7019
|
+
continue;
|
|
7020
|
+
}
|
|
7021
|
+
break;
|
|
7022
|
+
}
|
|
7023
|
+
return [
|
|
7024
|
+
value,
|
|
7025
|
+
weight,
|
|
7026
|
+
important
|
|
7027
|
+
];
|
|
7028
|
+
}
|
|
6183
7029
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6184
7030
|
if (result.ok) return;
|
|
6185
7031
|
if (result.reason.includes("createCounterStyle") || result.reason.includes("createFontFace") || result.reason.includes("createFontPaletteValues") || result.reason.includes("createPositionTry") || result.reason.includes("createProperty") || result.reason.includes("fontSrc")) throw new Error(result.reason);
|
|
@@ -6315,6 +7161,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6315
7161
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6316
7162
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6317
7163
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7164
|
+
const staticIdState = {
|
|
7165
|
+
fileId,
|
|
7166
|
+
imports,
|
|
7167
|
+
styleNames
|
|
7168
|
+
};
|
|
7169
|
+
const t = babel.types;
|
|
6318
7170
|
for (const stmt of ast.program.body) {
|
|
6319
7171
|
if (stmt.type === "ImportDeclaration") {
|
|
6320
7172
|
const source = stmt.source.value;
|
|
@@ -6339,6 +7191,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6339
7191
|
continue;
|
|
6340
7192
|
}
|
|
6341
7193
|
if (stmt.type === "VariableDeclaration") {
|
|
7194
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6342
7195
|
collectVariableBindings(rawBindings, stmt);
|
|
6343
7196
|
continue;
|
|
6344
7197
|
}
|
|
@@ -6362,6 +7215,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6362
7215
|
continue;
|
|
6363
7216
|
}
|
|
6364
7217
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7218
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6365
7219
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6366
7220
|
continue;
|
|
6367
7221
|
}
|
|
@@ -6401,6 +7255,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6401
7255
|
});
|
|
6402
7256
|
return bindings;
|
|
6403
7257
|
}
|
|
7258
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7259
|
+
for (const decl of declaration.declarations) {
|
|
7260
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7261
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7262
|
+
}
|
|
7263
|
+
}
|
|
6404
7264
|
function collectVariableBindings(bindings, declaration) {
|
|
6405
7265
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6406
7266
|
}
|
|
@@ -6480,6 +7340,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6480
7340
|
defineCompiledStyleLocations(style, traceResult);
|
|
6481
7341
|
return style;
|
|
6482
7342
|
}
|
|
7343
|
+
if (result.type === "sheet") {
|
|
7344
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7345
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7346
|
+
return sheet;
|
|
7347
|
+
}
|
|
6483
7348
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6484
7349
|
return null;
|
|
6485
7350
|
}
|
|
@@ -6590,6 +7455,12 @@ function hashFileContent(filePath) {
|
|
|
6590
7455
|
function getStyleRuntimeImportPath(mode) {
|
|
6591
7456
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6592
7457
|
}
|
|
7458
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7459
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7460
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7461
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7462
|
+
return null;
|
|
7463
|
+
}
|
|
6593
7464
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6594
7465
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6595
7466
|
}
|
|
@@ -6682,6 +7553,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6682
7553
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6683
7554
|
return t.callExpression(t.identifier(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE), hasSpread ? buildStyleMergeArgs(t, chain, state, options) : [buildItemsArray(t, chain, 1, state, options)]);
|
|
6684
7555
|
}
|
|
7556
|
+
if (chain.type === "sheet") {
|
|
7557
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7558
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7559
|
+
}
|
|
6685
7560
|
if (chain.type === "slot") {
|
|
6686
7561
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6687
7562
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6720,7 +7595,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6720
7595
|
chain.items.forEach((item) => {
|
|
6721
7596
|
if (isCompiledTokenItem(item)) {
|
|
6722
7597
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6723
|
-
else itemExpressions.push(t
|
|
7598
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6724
7599
|
return;
|
|
6725
7600
|
}
|
|
6726
7601
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6819,6 +7694,18 @@ function buildExtractedTokenExpression(t, token, state) {
|
|
|
6819
7694
|
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6820
7695
|
]);
|
|
6821
7696
|
}
|
|
7697
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7698
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7699
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7700
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7701
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7702
|
+
t.nullLiteral(),
|
|
7703
|
+
t.nullLiteral(),
|
|
7704
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7705
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7706
|
+
]);
|
|
7707
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
7708
|
+
}
|
|
6822
7709
|
function literalExpression(t, value) {
|
|
6823
7710
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
6824
7711
|
if (typeof value === "number") return t.numericLiteral(value);
|
|
@@ -6940,6 +7827,7 @@ function getEvalScope(state) {
|
|
|
6940
7827
|
styleFilePath: state.styleFilePath,
|
|
6941
7828
|
sourcemapTrace: state.sourcemapTrace,
|
|
6942
7829
|
styleNames: state.styleNames,
|
|
7830
|
+
sheetNames: state.sheetNames,
|
|
6943
7831
|
styleMetas: state.styleMetas,
|
|
6944
7832
|
bindingNodes: state.bindingNodes,
|
|
6945
7833
|
runtimeMode: state.runtimeMode
|
|
@@ -6997,6 +7885,7 @@ function createExtractPlugin(args) {
|
|
|
6997
7885
|
return {
|
|
6998
7886
|
pre() {
|
|
6999
7887
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
7888
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
7000
7889
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
7001
7890
|
this.bindings = /* @__PURE__ */ new Map();
|
|
7002
7891
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -7043,6 +7932,7 @@ function createExtractPlugin(args) {
|
|
|
7043
7932
|
state.styleNames.add(spec.local.name);
|
|
7044
7933
|
state.styleMetas.set(spec.local.name, meta);
|
|
7045
7934
|
}
|
|
7935
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
7046
7936
|
});
|
|
7047
7937
|
},
|
|
7048
7938
|
VariableDeclaration(path, state) {
|
|
@@ -7089,17 +7979,17 @@ function createExtractPlugin(args) {
|
|
|
7089
7979
|
state.needsExtractImport = true;
|
|
7090
7980
|
return;
|
|
7091
7981
|
}
|
|
7092
|
-
if (!state.styleNames.size) return;
|
|
7093
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
7982
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
7983
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
7094
7984
|
if (!chain) return;
|
|
7095
7985
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
7096
7986
|
const scope = getEvalScope(state);
|
|
7097
7987
|
const loc = path.node.loc?.start;
|
|
7098
7988
|
const meta = state.styleMetas.get(chain.rootName);
|
|
7099
|
-
if (!meta) return;
|
|
7989
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
7100
7990
|
let result;
|
|
7101
7991
|
try {
|
|
7102
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
7992
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
7103
7993
|
} catch (error) {
|
|
7104
7994
|
const message = error instanceof Error ? error.message : String(error);
|
|
7105
7995
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7353,7 +8243,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7353
8243
|
code: args.code,
|
|
7354
8244
|
filePath: args.filePath,
|
|
7355
8245
|
sourcemap: args.sourcemap,
|
|
7356
|
-
plugins: [plugin],
|
|
8246
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7357
8247
|
errorLabel: "[style] compiler error"
|
|
7358
8248
|
});
|
|
7359
8249
|
if (!result) return null;
|
|
@@ -7395,22 +8285,15 @@ function createPlugin(rewriteSource) {
|
|
|
7395
8285
|
}
|
|
7396
8286
|
//#endregion
|
|
7397
8287
|
//#region compiler/compiler/compiler.ts
|
|
7398
|
-
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
7399
|
-
CompilerRuntimeMode["Dev"] = "dev";
|
|
7400
|
-
CompilerRuntimeMode["Prod"] = "prod";
|
|
7401
|
-
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
7402
|
-
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
7403
|
-
return CompilerRuntimeMode;
|
|
7404
|
-
}({});
|
|
7405
8288
|
function createCompiler(args, options) {
|
|
7406
8289
|
const internal = createCompilerInternal(args, options);
|
|
7407
8290
|
const tracer = createTracer(internal);
|
|
7408
8291
|
const collector = createCssCollector();
|
|
7409
8292
|
const compileDebug = (args) => {
|
|
7410
|
-
return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
|
|
8293
|
+
return rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
|
|
7411
8294
|
};
|
|
7412
8295
|
const compileDebugRSC = (args) => {
|
|
7413
|
-
const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode);
|
|
8296
|
+
const debugResult = rewriteTransformResult(transformDebug(internal, args, { tracer }), internal.runtimeMode, args.code);
|
|
7414
8297
|
if (!debugResult) return null;
|
|
7415
8298
|
const rscCollector = createCssCollector();
|
|
7416
8299
|
transformExtract(internal, args, {
|
|
@@ -7439,7 +8322,7 @@ function createCompiler(args, options) {
|
|
|
7439
8322
|
return rewriteTransformResult({
|
|
7440
8323
|
...result,
|
|
7441
8324
|
rules: collector.getItems().slice(startIndex)
|
|
7442
|
-
}, internal.runtimeMode);
|
|
8325
|
+
}, internal.runtimeMode, args.code);
|
|
7443
8326
|
};
|
|
7444
8327
|
const getExtractedCss = () => {
|
|
7445
8328
|
return extractCss(collector.getItems(), {
|
|
@@ -7469,24 +8352,74 @@ function createCompilerInternal(args, options) {
|
|
|
7469
8352
|
options
|
|
7470
8353
|
};
|
|
7471
8354
|
}
|
|
7472
|
-
function rewriteTransformResult(result, runtimeMode) {
|
|
8355
|
+
function rewriteTransformResult(result, runtimeMode, sourceCode) {
|
|
7473
8356
|
if (!result || !runtimeMode) return result;
|
|
7474
8357
|
return {
|
|
7475
8358
|
...result,
|
|
7476
|
-
code: rewriteCompilerRuntimeImports(result.code, runtimeMode)
|
|
8359
|
+
code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode)
|
|
7477
8360
|
};
|
|
7478
8361
|
}
|
|
7479
|
-
function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
7480
|
-
|
|
8362
|
+
function rewriteCompilerRuntimeImports(code, runtimeMode, sourceCode) {
|
|
8363
|
+
const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
|
|
8364
|
+
return rewriteImportSources(code, (source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode));
|
|
7481
8365
|
}
|
|
7482
|
-
function
|
|
7483
|
-
if (
|
|
7484
|
-
|
|
8366
|
+
function getImportRuntimeMode(runtimeMode, sourceCode) {
|
|
8367
|
+
if (runtimeMode === "rsc-dev" && hasUseClientDirective(sourceCode)) return "dev";
|
|
8368
|
+
return runtimeMode;
|
|
8369
|
+
}
|
|
8370
|
+
function getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode) {
|
|
8371
|
+
if (source === "@fluentic/style") return getStyleRuntimeImportPath(importRuntimeMode);
|
|
8372
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
|
|
8373
|
+
if (adapterImportPath) return adapterImportPath;
|
|
8374
|
+
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(importRuntimeMode);
|
|
7485
8375
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7486
8376
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7487
8377
|
return null;
|
|
7488
8378
|
}
|
|
8379
|
+
function hasUseClientDirective(code) {
|
|
8380
|
+
let index = 0;
|
|
8381
|
+
while (index < code.length) {
|
|
8382
|
+
index = skipWhitespaceAndComments(code, index);
|
|
8383
|
+
const quote = code[index];
|
|
8384
|
+
if (quote !== "\"" && quote !== "'") return false;
|
|
8385
|
+
const end = code.indexOf(quote, index + 1);
|
|
8386
|
+
if (end < 0) return false;
|
|
8387
|
+
const directive = code.slice(index + 1, end);
|
|
8388
|
+
index = skipWhitespaceAndComments(code, end + 1);
|
|
8389
|
+
if (code[index] === ";") index += 1;
|
|
8390
|
+
else if (code[index] && code[index] !== "\n" && code[index] !== "\r") return false;
|
|
8391
|
+
if (directive === "use client") return true;
|
|
8392
|
+
}
|
|
8393
|
+
return false;
|
|
8394
|
+
}
|
|
8395
|
+
function skipWhitespaceAndComments(code, index) {
|
|
8396
|
+
let next = index;
|
|
8397
|
+
while (next < code.length) {
|
|
8398
|
+
const char = code[next];
|
|
8399
|
+
if (char === " " || char === " " || char === "\n" || char === "\r") {
|
|
8400
|
+
next += 1;
|
|
8401
|
+
continue;
|
|
8402
|
+
}
|
|
8403
|
+
if (char === "/" && code[next + 1] === "/") {
|
|
8404
|
+
const lineEnd = code.indexOf("\n", next + 2);
|
|
8405
|
+
next = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
8406
|
+
continue;
|
|
8407
|
+
}
|
|
8408
|
+
if (char === "/" && code[next + 1] === "*") {
|
|
8409
|
+
const commentEnd = code.indexOf("*/", next + 2);
|
|
8410
|
+
next = commentEnd < 0 ? code.length : commentEnd + 2;
|
|
8411
|
+
continue;
|
|
8412
|
+
}
|
|
8413
|
+
break;
|
|
8414
|
+
}
|
|
8415
|
+
return next;
|
|
8416
|
+
}
|
|
8417
|
+
const CssPropPresets = {
|
|
8418
|
+
Solid: { adapter: "@fluentic/style/adapter/solid" },
|
|
8419
|
+
Preact: { adapter: "@fluentic/style/adapter/preact" },
|
|
8420
|
+
React: { adapter: "@fluentic/style/adapter/react" }
|
|
8421
|
+
};
|
|
7489
8422
|
//#endregion
|
|
7490
|
-
export {
|
|
8423
|
+
export { getDefaultSourcemapUrl as a, getStyleFnMeta as c, babelTransform as d, extractCss as f, createCompilerCache as g, globalData as h, CompilerRuntimeMode as i, isPromiseLike as l, SIDECAR_URL_GLOBAL_SYMBOL as m, createCompiler as n, normalizeSourcemapSourcePath as o, compareLayerPriority as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelPlugin as u };
|
|
7491
8424
|
|
|
7492
|
-
//# sourceMappingURL=compiler-
|
|
8425
|
+
//# sourceMappingURL=compiler-CCvRlaq0.mjs.map
|