@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -1
- package/README.md +10 -9
- package/atomic/className.ts +12 -12
- package/atomic/debug/className/className.ts +10 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +8 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +41 -2
- package/atomic/token.ts +4 -3
- package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/selector.ts +14 -1
- package/builder/classname/class_name_builder.ts +68 -24
- package/builder/classname/fns.ts +2 -2
- package/builder/classname/types.ts +7 -0
- package/builder/data/const.ts +7 -1
- package/builder/data/create.ts +42 -0
- package/builder/data/data.ts +20 -1
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +23 -0
- package/builder/data/merge/scope.ts +20 -19
- package/builder/data/merge/style.ts +71 -21
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- package/builder/extract/token.ts +30 -14
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +30 -0
- package/builder/selector_override_core.ts +66 -0
- package/builder/style_builder.ts +127 -3
- package/builder/style_data.ts +24 -0
- package/builder/style_fns.ts +24 -24
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/builder/types/alias.ts +34 -6
- package/builder/types/fns.ts +13 -5
- package/builder/types/types.ts +32 -2
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +4 -7
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +2 -0
- package/compiler/cssProp.ts +35 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +129 -0
- package/compiler/transform/debug/plugin.ts +85 -1
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +106 -30
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +541 -63
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +1 -1
- package/compiler/transform/extract/plugin.ts +20 -4
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +52 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +1 -8
- package/config/config/css.ts +1 -0
- package/config/config/debug.ts +11 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → combine-Ca6LfFxv.js} +427 -722
- package/dist/combine-Ca6LfFxv.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-D5v5tJXI.mjs → compiler-OgDBuqfs.mjs} +1635 -607
- package/dist/compiler-OgDBuqfs.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-OXHoDUIo.js.map → config-B-KbXpIh.js.map} +1 -1
- package/dist/config-Barf8f4B.js +35 -0
- package/dist/config-Barf8f4B.js.map +1 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/config-CsB4MuFI.js +6 -0
- package/dist/config-CsB4MuFI.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/{config-FIfi5aJ8.js → config-t76UljYv.js} +9 -7
- package/dist/config-t76UljYv.js.map +1 -0
- package/dist/createTransformElement-DDqld3RF.js +34 -0
- package/dist/createTransformElement-DDqld3RF.js.map +1 -0
- package/dist/css-CZwrac6F.js +3923 -0
- package/dist/css-CZwrac6F.js.map +1 -0
- package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
- package/dist/css-GtUPEO9U.js.map +1 -0
- package/dist/css-YfHN_8Nk.js +479 -0
- package/dist/css-YfHN_8Nk.js.map +1 -0
- package/dist/css-a9O5so0b.js +1246 -0
- package/dist/css-a9O5so0b.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
- package/dist/{css_extra-DQdCrYoC.js → css_extra-CXXZAylc.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-CXXZAylc.js.map} +1 -1
- package/dist/data-CzHJg147.js +763 -0
- package/dist/data-CzHJg147.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-DkrxyknP.js} +80 -4
- package/dist/debug-DkrxyknP.js.map +1 -0
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +6 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-fOtWB5K3.js → dev-z4laBwlS.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-z4laBwlS.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CvqqIb7J.js → elementMarker-CqhU_l_m.js} +95 -9
- package/dist/elementMarker-CqhU_l_m.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +13 -12
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +240 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -4
- package/dist/entry/prod.js +85 -1201
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +12 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +12 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +12 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +6 -10
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +323 -615
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -4
- package/dist/entry/rsc-prod.js +241 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-ydQcDBD4.js → env-Db2cRt-h.js} +1256 -355
- package/dist/env-Db2cRt-h.js.map +1 -0
- package/dist/{jsx-A4cK517J.js → getClassName-DKtQl5ZX.js} +5 -11
- package/dist/getClassName-DKtQl5ZX.js.map +1 -0
- package/dist/{utils-hoYnMiA7.js → getClassName-DaZF5nfJ.js} +28 -65
- package/dist/getClassName-DaZF5nfJ.js.map +1 -0
- package/dist/getClassName-a6p2uMFM.js +536 -0
- package/dist/getClassName-a6p2uMFM.js.map +1 -0
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-aD9zqg9U.js} +56 -14
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-zYTvWskP.js +10 -0
- package/dist/{global-Cul1dX8k.js.map → global-zYTvWskP.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BOlQThNz.js} +48 -4
- package/dist/hash-BOlQThNz.js.map +1 -0
- package/dist/index.js +10 -10
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-C2pnWLcb.js +39 -0
- package/dist/jsx-C2pnWLcb.js.map +1 -0
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-XJSHujgI.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-DHvgp0fK.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BuSLnvx0.mjs} +4 -4
- package/dist/misc-BuSLnvx0.mjs.map +1 -0
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-D3tt-joz.js} +8 -6
- package/dist/namedTokens-D3tt-joz.js.map +1 -0
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +5 -5
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +9 -7
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-CiwvMfx8.mjs → registry-r3BKWqpI.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-r3BKWqpI.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-D5a37GNr.js +63 -0
- package/dist/resolveClassNameRuntime-D5a37GNr.js.map +1 -0
- package/dist/{rules-DlXcch7-.js → rules-B0_rKPfB.js} +598 -132
- package/dist/rules-B0_rKPfB.js.map +1 -0
- package/dist/scope-BSuRLice.js +601 -0
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +15 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-8_Msr7Q5.cjs} +1630 -597
- package/dist/shared-8_Msr7Q5.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-BGO_05rW.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
- package/dist/sheet-BpLZIIuO.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BpLZIIuO.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-Bu2x35JE.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-BDy5TH6N.js} +5 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-BDy5TH6N.js.map} +1 -1
- package/dist/styleStore-DX3z_UVK.js +51 -0
- package/dist/styleStore-DX3z_UVK.js.map +1 -0
- package/dist/token-BsW_S8fN.js +138 -0
- package/dist/token-BsW_S8fN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-BdKEpgME.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-BdKEpgME.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-DcuMxR45.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-DcuMxR45.js.map} +1 -1
- package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
- package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
- package/dist/{style-DFFK06Of.js → types-BEUgXuu2.js} +356 -129
- package/dist/types-BEUgXuu2.js.map +1 -0
- package/dist/{utils-D2fygyTm.mjs → utils-BPDxr-oc.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-BPDxr-oc.mjs.map} +1 -1
- package/dist/utils-CLnpwhJd.js +83 -0
- package/dist/utils-CLnpwhJd.js.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DTXCTUlS.mjs → utils-DZjLTV4D.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DZjLTV4D.mjs.map} +1 -1
- package/dist/utils-okFWrQsg.js +41 -0
- package/dist/utils-okFWrQsg.js.map +1 -0
- package/dist/{utils-DVFxZnVC.js → utils-sBVZEq4u.js} +190 -144
- package/dist/utils-sBVZEq4u.js.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CpJpQ00y.js +145 -0
- package/dist/value-CpJpQ00y.js.map +1 -0
- package/dist/{webpack-BOU7_xld.mjs → webpack-DTKgR-HY.mjs} +5 -5
- package/dist/webpack-DTKgR-HY.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +3 -1
- package/entry/rsc_dev/adapter/preact.ts +1 -0
- package/entry/rsc_dev/adapter/react.ts +1 -0
- package/entry/rsc_dev/adapter/solid.ts +1 -0
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +9 -7
- package/jsx/types/index.ts +3 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +78 -12
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +3 -8
- package/plugin/bundler/vite/state.ts +2 -2
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/nextjs/plugin.ts +3 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/adapter/utils.ts +94 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +54 -17
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +3 -3
- package/style/classname.ts +12 -6
- package/style/important.ts +19 -0
- package/style/index.ts +2 -0
- package/style/style.ts +17 -5
- package/style/theme.ts +0 -1
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +1 -1
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-CKo4TxuT.js +0 -144
- package/dist/className-CKo4TxuT.js.map +0 -1
- package/dist/className-ZJ5pBA-o.js +0 -263
- package/dist/className-ZJ5pBA-o.js.map +0 -1
- package/dist/compiler-D5v5tJXI.mjs.map +0 -1
- package/dist/config-BEvP7108.js.map +0 -1
- package/dist/config-B_cbG3S6.js +0 -1
- package/dist/config-FIfi5aJ8.js.map +0 -1
- package/dist/config-OXHoDUIo.js +0 -6
- package/dist/css-CELBp6Gu.js +0 -58
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-DcuJ_jSH.js +0 -243
- package/dist/css-DcuJ_jSH.js.map +0 -1
- package/dist/css-dPoZJDQH.js +0 -807
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/css-oOt6ZR54.js +0 -237
- package/dist/css-oOt6ZR54.js.map +0 -1
- package/dist/data-CeYstKMP.js +0 -482
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/debug-D96KGgpH.js.map +0 -1
- package/dist/dev-p8tW7X-A.js +0 -81
- package/dist/dev-p8tW7X-A.js.map +0 -1
- package/dist/elementMarker-CvqqIb7J.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-Cul1dX8k.js +0 -14
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/jsx-A4cK517J.js.map +0 -1
- package/dist/jsx-Ba-XV33u.js +0 -39
- package/dist/jsx-Ba-XV33u.js.map +0 -1
- package/dist/layer-CbQzwZF-.js +0 -94
- package/dist/layer-CbQzwZF-.js.map +0 -1
- package/dist/misc-DFBKJGLT.mjs.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CF6JgpTq.js +0 -406
- package/dist/property-CF6JgpTq.js.map +0 -1
- package/dist/rules-DlXcch7-.js.map +0 -1
- package/dist/runtime-BKChZZ2-.js.map +0 -1
- package/dist/shared-yDD0nfm1.cjs.map +0 -1
- package/dist/sheet-B-uJfHRY.js +0 -7
- package/dist/style-91J0B5ef.js +0 -771
- package/dist/style-91J0B5ef.js.map +0 -1
- package/dist/style-Bw5ka-Nq.js.map +0 -1
- package/dist/style-DFFK06Of.js.map +0 -1
- package/dist/style-pz8e5To1.js +0 -5
- package/dist/styleStore-ydQcDBD4.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-DTOyFLmp.js +0 -58
- package/dist/token-DTOyFLmp.js.map +0 -1
- package/dist/token-DT_sCPtm.js +0 -298
- package/dist/token-DT_sCPtm.js.map +0 -1
- package/dist/utils-Bmw655wa.js +0 -170
- package/dist/utils-Bmw655wa.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/utils-hoYnMiA7.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DvFkGBy2.js +0 -1029
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
- package/dist/valueRef-CsLVJwjA.js +0 -16
- package/dist/valueRef-CsLVJwjA.js.map +0 -1
- package/dist/webpack-BOU7_xld.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -26,18 +26,20 @@ let node_fs = require("node:fs");
|
|
|
26
26
|
node_fs = __toESM(node_fs, 1);
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
+
let _babel_core = require("@babel/core");
|
|
30
|
+
_babel_core = __toESM(_babel_core, 1);
|
|
29
31
|
let picomatch = require("picomatch");
|
|
30
32
|
picomatch = __toESM(picomatch, 1);
|
|
31
33
|
let css_what = require("css-what");
|
|
32
|
-
let _babel_core = require("@babel/core");
|
|
33
|
-
_babel_core = __toESM(_babel_core, 1);
|
|
34
34
|
let oxc_resolver = require("oxc-resolver");
|
|
35
35
|
require("@parcel/plugin");
|
|
36
36
|
let node_http = require("node:http");
|
|
37
|
-
//#region utils/
|
|
37
|
+
//#region utils/symbol.ts
|
|
38
38
|
function symbol(name) {
|
|
39
39
|
return Symbol.for(`@fluentic/style.${name}`);
|
|
40
40
|
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region utils/global.ts
|
|
41
43
|
function globalData(key, data) {
|
|
42
44
|
const id = symbol(key);
|
|
43
45
|
const root = globalThis;
|
|
@@ -61,19 +63,8 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
61
63
|
};
|
|
62
64
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
63
65
|
//#endregion
|
|
64
|
-
//#region config/config/debug.ts
|
|
65
|
-
const DEFAULT_DEBUG_CONFIG = {
|
|
66
|
-
isDebugClassNameEnabled: false,
|
|
67
|
-
isDebugClassNameConfigured: false,
|
|
68
|
-
maxPropertyLength: 24,
|
|
69
|
-
maxValueLength: 8,
|
|
70
|
-
maxSelectorLength: 8,
|
|
71
|
-
maxParentSelectorLength: 8,
|
|
72
|
-
maxAtRuleLength: 10
|
|
73
|
-
};
|
|
74
|
-
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
75
|
-
//#endregion
|
|
76
66
|
//#region config/utils.ts
|
|
67
|
+
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
77
68
|
function getCacheTTL(cache) {
|
|
78
69
|
return cache === true ? 3e5 : cache === false ? 0 : Math.max(cache, 0);
|
|
79
70
|
}
|
|
@@ -87,9 +78,21 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
87
78
|
isRSC: false,
|
|
88
79
|
runtimeCacheTTL: getCacheTTL(true)
|
|
89
80
|
};
|
|
90
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
81
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
91
82
|
globalData("config.build", () => ({ current: null }));
|
|
92
83
|
//#endregion
|
|
84
|
+
//#region config/config/debug.ts
|
|
85
|
+
const DEFAULT_DEBUG_CONFIG = {
|
|
86
|
+
isDebugClassNameEnabled: false,
|
|
87
|
+
isDebugClassNameConfigured: false,
|
|
88
|
+
maxPropertyLength: 24,
|
|
89
|
+
maxValueLength: 8,
|
|
90
|
+
maxSelectorLength: 8,
|
|
91
|
+
maxParentSelectorLength: 8,
|
|
92
|
+
maxAtRuleLength: 10
|
|
93
|
+
};
|
|
94
|
+
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
95
|
+
//#endregion
|
|
93
96
|
//#region utils/hash.ts
|
|
94
97
|
function hashString(str) {
|
|
95
98
|
let hash = 2166136261;
|
|
@@ -108,8 +111,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
108
111
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
109
112
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
110
113
|
}
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region atomic/layer/types.ts
|
|
113
114
|
const LayerDefaultPriority = [
|
|
114
115
|
0,
|
|
115
116
|
0,
|
|
@@ -198,6 +199,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
198
199
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
199
200
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
200
201
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
202
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
201
203
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
202
204
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
203
205
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -424,6 +426,131 @@ function getCacheKey(args) {
|
|
|
424
426
|
return node_crypto.createHash("md5").update(args.cacheType).update("\0").update(node_path.resolve(args.filePath)).digest("hex");
|
|
425
427
|
}
|
|
426
428
|
//#endregion
|
|
429
|
+
//#region compiler/transform/utils/babel.ts
|
|
430
|
+
function babelPlugin(factory) {
|
|
431
|
+
return factory;
|
|
432
|
+
}
|
|
433
|
+
function babelTransform(args) {
|
|
434
|
+
let result = null;
|
|
435
|
+
try {
|
|
436
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
437
|
+
result = _babel_core.transformSync(args.code, {
|
|
438
|
+
...babelTransformOptions(),
|
|
439
|
+
inputSourceMap,
|
|
440
|
+
filename: args.filePath,
|
|
441
|
+
sourceFileName: args.filePath,
|
|
442
|
+
plugins: args.plugins,
|
|
443
|
+
sourceMaps: true,
|
|
444
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
445
|
+
});
|
|
446
|
+
} catch (err) {
|
|
447
|
+
if (!args.errorLabel) throw err;
|
|
448
|
+
const message = getBabelError(err, args);
|
|
449
|
+
const error = new Error(message);
|
|
450
|
+
error.stack = void 0;
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
if (!result || !result.code) return null;
|
|
454
|
+
return {
|
|
455
|
+
code: result.code,
|
|
456
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function babelTransformOptions() {
|
|
460
|
+
return {
|
|
461
|
+
configFile: false,
|
|
462
|
+
babelrc: false,
|
|
463
|
+
parserOpts: {
|
|
464
|
+
plugins: ["typescript", "jsx"],
|
|
465
|
+
strictMode: false,
|
|
466
|
+
allowImportExportEverywhere: true
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function parseInputSourceMap(sourcemap) {
|
|
471
|
+
if (!sourcemap) return void 0;
|
|
472
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
473
|
+
return JSON.parse(sourcemap);
|
|
474
|
+
}
|
|
475
|
+
function getBabelError(err, args) {
|
|
476
|
+
const babelErr = err;
|
|
477
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
478
|
+
const codeFrame = babelErr?.codeFrame;
|
|
479
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
480
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
484
|
+
function createCssPropPlugin(args) {
|
|
485
|
+
return babelPlugin((babel) => {
|
|
486
|
+
const { types: t } = babel;
|
|
487
|
+
return {
|
|
488
|
+
pre() {
|
|
489
|
+
this.options = args.options;
|
|
490
|
+
this.mergeId = null;
|
|
491
|
+
this.programPath = null;
|
|
492
|
+
this.changed = false;
|
|
493
|
+
},
|
|
494
|
+
visitor: {
|
|
495
|
+
Program: {
|
|
496
|
+
enter(path, state) {
|
|
497
|
+
state.programPath = path;
|
|
498
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
499
|
+
},
|
|
500
|
+
exit(path, state) {
|
|
501
|
+
const options = getCssPropOptions(state.options);
|
|
502
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
503
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
JSXOpeningElement(path, state) {
|
|
507
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
508
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
509
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
510
|
+
const parts = path.node.attributes.map((attr) => buildPart(t, attr));
|
|
511
|
+
path.node.attributes = [t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
512
|
+
state.changed = true;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
function getCssPropOptions(options) {
|
|
519
|
+
return options.cssProp || null;
|
|
520
|
+
}
|
|
521
|
+
function isIntrinsicElement(name) {
|
|
522
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
523
|
+
}
|
|
524
|
+
function hasCssAttribute(attrs) {
|
|
525
|
+
return attrs.some((attr) => {
|
|
526
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function buildPart(t, attr) {
|
|
530
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
531
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
532
|
+
}
|
|
533
|
+
function getObjectKey(t, name) {
|
|
534
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
535
|
+
return t.stringLiteral(getAttributeName(name));
|
|
536
|
+
}
|
|
537
|
+
function getAttributeName(name) {
|
|
538
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
539
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
540
|
+
}
|
|
541
|
+
function getAttributeValue(t, attr) {
|
|
542
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
543
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
544
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
545
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
546
|
+
return attr.value.expression;
|
|
547
|
+
}
|
|
548
|
+
return attr.value;
|
|
549
|
+
}
|
|
550
|
+
function isValidIdentifierName(name) {
|
|
551
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
427
554
|
//#region builder/data/const.ts
|
|
428
555
|
const BUILDER_TYPE = symbol("builder.type");
|
|
429
556
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -431,8 +558,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
431
558
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
432
559
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
433
560
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
561
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
562
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
434
563
|
//#endregion
|
|
435
564
|
//#region utils/object.ts
|
|
565
|
+
function hasOwn(target, field) {
|
|
566
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
567
|
+
}
|
|
436
568
|
function toArray(value) {
|
|
437
569
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
438
570
|
}
|
|
@@ -609,6 +741,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
609
741
|
}
|
|
610
742
|
//#endregion
|
|
611
743
|
//#region builder/data/is.ts
|
|
744
|
+
function getSlotId(data) {
|
|
745
|
+
return data[BUILDER_SLOT_ID];
|
|
746
|
+
}
|
|
747
|
+
function getScopeTargetSlotId(data) {
|
|
748
|
+
return data[BUILDER_SCOPE_ID];
|
|
749
|
+
}
|
|
750
|
+
function getScopeTargetScope(data) {
|
|
751
|
+
return data[BUILDER_SCOPE];
|
|
752
|
+
}
|
|
612
753
|
function isStyleData(value) {
|
|
613
754
|
return getBuilderType(value) === 1;
|
|
614
755
|
}
|
|
@@ -618,9 +759,18 @@ function isSlotData(value) {
|
|
|
618
759
|
function isSlotOverrideData(value) {
|
|
619
760
|
return getBuilderType(value) === 3;
|
|
620
761
|
}
|
|
762
|
+
function isSelectorData(value) {
|
|
763
|
+
return getBuilderType(value) === 7;
|
|
764
|
+
}
|
|
765
|
+
function isSheetData(value) {
|
|
766
|
+
return getBuilderType(value) === 9;
|
|
767
|
+
}
|
|
621
768
|
function isScopeData(value) {
|
|
622
769
|
return getBuilderType(value) === 4;
|
|
623
770
|
}
|
|
771
|
+
function isThemeData(value) {
|
|
772
|
+
return getBuilderType(value) === 6;
|
|
773
|
+
}
|
|
624
774
|
function getBuilderType(value) {
|
|
625
775
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
626
776
|
return value[BUILDER_TYPE];
|
|
@@ -629,16 +779,70 @@ function normalizeSelectorArg(arg) {
|
|
|
629
779
|
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
630
780
|
}
|
|
631
781
|
//#endregion
|
|
632
|
-
//#region
|
|
782
|
+
//#region builder/token/symbols.ts
|
|
633
783
|
const TOKEN_ID = symbol("style:token");
|
|
634
784
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
785
|
+
const TOKEN_NAME = symbol("style:token.name");
|
|
786
|
+
const TOKEN_VAR_NAME = symbol("style:token.varName");
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region builder/token/data.ts
|
|
789
|
+
function isStyleTokenData(value) {
|
|
790
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
791
|
+
}
|
|
792
|
+
function isStyleTokenOverrideData(value) {
|
|
793
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
794
|
+
}
|
|
795
|
+
function getStyleTokenId(token) {
|
|
796
|
+
return token[TOKEN_ID];
|
|
797
|
+
}
|
|
798
|
+
function getStyleTokenName(token) {
|
|
799
|
+
return token[TOKEN_NAME] ?? null;
|
|
800
|
+
}
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region builder/token/name.ts
|
|
803
|
+
function getStyleTokenNameFromId(id) {
|
|
804
|
+
if (!id) return null;
|
|
805
|
+
const parts = id.split("--");
|
|
806
|
+
const first = normalizeStyleTokenName(parts[0]);
|
|
807
|
+
if (!first) return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join("--")) : null;
|
|
808
|
+
return normalizeStyleTokenName([first, ...parts.slice(1)].join("--"));
|
|
809
|
+
}
|
|
810
|
+
function getChildStyleTokenName(name, child) {
|
|
811
|
+
const childName = normalizeStyleTokenName(child);
|
|
812
|
+
if (!childName) return normalizeStyleTokenName(name);
|
|
813
|
+
const parentName = normalizeStyleTokenName(name);
|
|
814
|
+
return parentName ? parentName + "--" + childName : childName;
|
|
815
|
+
}
|
|
816
|
+
function normalizeStyleTokenName(value) {
|
|
817
|
+
if (!value) return null;
|
|
818
|
+
value = value.trim();
|
|
819
|
+
if (!value) return null;
|
|
820
|
+
if (/^\d+$/.test(value)) return null;
|
|
821
|
+
if (isGeneratedTokenHash(value)) return null;
|
|
822
|
+
value = stripGenericTokenPrefix(value);
|
|
823
|
+
if (!value) return null;
|
|
824
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
825
|
+
if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
|
|
826
|
+
return value;
|
|
827
|
+
}
|
|
828
|
+
function isGeneratedTokenHash(value) {
|
|
829
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
830
|
+
}
|
|
831
|
+
function stripGenericTokenPrefix(value) {
|
|
832
|
+
const parts = value.split("--");
|
|
833
|
+
while (parts[0] === "token" || parts[0] === "tokens") parts.shift();
|
|
834
|
+
return parts.join("--");
|
|
835
|
+
}
|
|
836
|
+
//#endregion
|
|
837
|
+
//#region style/token.ts
|
|
635
838
|
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
636
839
|
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
637
|
-
function createStyleToken(value,
|
|
840
|
+
function createStyleToken(value, stableId, debugName) {
|
|
638
841
|
const token = (value, debug) => {
|
|
639
842
|
return createStyleTokenOverride(token, value, debug);
|
|
640
843
|
};
|
|
641
|
-
token[TOKEN_ID] =
|
|
844
|
+
token[TOKEN_ID] = stableId || String(idCounter$6.value++);
|
|
845
|
+
token[TOKEN_NAME] = debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
|
|
642
846
|
if (isStyleTokenData(value)) {
|
|
643
847
|
token.value = value.value;
|
|
644
848
|
token.ref = value;
|
|
@@ -652,11 +856,13 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
652
856
|
const override = isStyleTokenData(value) ? {
|
|
653
857
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
654
858
|
[TOKEN_OVERRIDE]: true,
|
|
859
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
655
860
|
value: value.value,
|
|
656
861
|
ref: value
|
|
657
862
|
} : {
|
|
658
863
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
659
864
|
[TOKEN_OVERRIDE]: true,
|
|
865
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
660
866
|
value,
|
|
661
867
|
ref: null
|
|
662
868
|
};
|
|
@@ -667,15 +873,6 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
667
873
|
});
|
|
668
874
|
return override;
|
|
669
875
|
}
|
|
670
|
-
function isStyleTokenData(value) {
|
|
671
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
672
|
-
}
|
|
673
|
-
function isStyleTokenOverrideData(value) {
|
|
674
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
675
|
-
}
|
|
676
|
-
function getStyleTokenId(token) {
|
|
677
|
-
return token[TOKEN_ID];
|
|
678
|
-
}
|
|
679
876
|
//#endregion
|
|
680
877
|
//#region selector/selector.ts
|
|
681
878
|
function selector(selector, ...args) {
|
|
@@ -810,163 +1007,77 @@ selectorPriority({
|
|
|
810
1007
|
...AtRuleSelectors
|
|
811
1008
|
}, PrioritySelectors);
|
|
812
1009
|
//#endregion
|
|
813
|
-
//#region
|
|
814
|
-
function
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1010
|
+
//#region builder/data/create.ts
|
|
1011
|
+
function createStyleData(callsite) {
|
|
1012
|
+
return {
|
|
1013
|
+
[BUILDER_TYPE]: 1,
|
|
1014
|
+
[BUILDER_STATE]: {
|
|
1015
|
+
items: [],
|
|
1016
|
+
lookup: {}
|
|
1017
|
+
},
|
|
1018
|
+
[BUILDER_CALLSITE]: callsite
|
|
1019
|
+
};
|
|
823
1020
|
}
|
|
824
|
-
function
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1021
|
+
function createSlotData(callsite, slotId) {
|
|
1022
|
+
return {
|
|
1023
|
+
[BUILDER_TYPE]: 2,
|
|
1024
|
+
[BUILDER_STATE]: {
|
|
1025
|
+
items: [],
|
|
1026
|
+
lookup: {}
|
|
1027
|
+
},
|
|
1028
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1029
|
+
[BUILDER_SLOT_ID]: slotId
|
|
1030
|
+
};
|
|
829
1031
|
}
|
|
830
|
-
function
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1032
|
+
function createSlotOverrideData(callsite, slotId) {
|
|
1033
|
+
return {
|
|
1034
|
+
[BUILDER_TYPE]: 3,
|
|
1035
|
+
[BUILDER_STATE]: {
|
|
1036
|
+
items: [],
|
|
1037
|
+
lookup: {}
|
|
1038
|
+
},
|
|
1039
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1040
|
+
[BUILDER_SLOT_ID]: slotId
|
|
1041
|
+
};
|
|
834
1042
|
}
|
|
835
|
-
function
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
1043
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
1044
|
+
return {
|
|
1045
|
+
[BUILDER_TYPE]: 8,
|
|
1046
|
+
[BUILDER_STATE]: {
|
|
1047
|
+
items: [],
|
|
1048
|
+
lookup: {}
|
|
1049
|
+
},
|
|
1050
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1051
|
+
[BUILDER_SELECTOR]: selectors
|
|
1052
|
+
};
|
|
839
1053
|
}
|
|
840
|
-
function
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1054
|
+
function createSelectorData(callsite, selectors) {
|
|
1055
|
+
return {
|
|
1056
|
+
[BUILDER_TYPE]: 7,
|
|
1057
|
+
[BUILDER_STATE]: {
|
|
1058
|
+
items: [],
|
|
1059
|
+
lookup: {}
|
|
1060
|
+
},
|
|
1061
|
+
[BUILDER_CALLSITE]: callsite,
|
|
1062
|
+
[BUILDER_SELECTOR]: selectors
|
|
1063
|
+
};
|
|
846
1064
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
return true;
|
|
1065
|
+
function createScopeData(callsite) {
|
|
1066
|
+
return {
|
|
1067
|
+
[BUILDER_TYPE]: 4,
|
|
1068
|
+
[BUILDER_STATE]: {
|
|
1069
|
+
items: [],
|
|
1070
|
+
lookup: {}
|
|
1071
|
+
},
|
|
1072
|
+
[BUILDER_CALLSITE]: callsite
|
|
1073
|
+
};
|
|
857
1074
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
assertSelectorNotEmpty(value);
|
|
865
|
-
if (!type) return;
|
|
866
|
-
if (typeof type === "function") return type(value);
|
|
867
|
-
switch (type) {
|
|
868
|
-
case "local": return assertLocalSelector(value);
|
|
869
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
870
|
-
case "tag": return assertTagSelector(value);
|
|
871
|
-
case "attr": return assertAttrSelector(value);
|
|
872
|
-
case "value": return assertRawValue(value);
|
|
873
|
-
case "media": return assertMediaQuery(value);
|
|
874
|
-
case "supports": return assertSupportsQuery(value);
|
|
875
|
-
case "container": return assertContainerQuery(value);
|
|
876
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
880
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
881
|
-
});
|
|
882
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
883
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
884
|
-
});
|
|
885
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
886
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
887
|
-
});
|
|
888
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
889
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
890
|
-
});
|
|
891
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
892
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
893
|
-
});
|
|
894
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
895
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
896
|
-
});
|
|
897
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
898
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
899
|
-
});
|
|
900
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
901
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
902
|
-
});
|
|
903
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
904
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
905
|
-
});
|
|
906
|
-
//#endregion
|
|
907
|
-
//#region builder/data/check_selector.ts
|
|
908
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
909
|
-
let message = null;
|
|
910
|
-
try {
|
|
911
|
-
assertSelector(fnSelector.assert, arg);
|
|
912
|
-
} catch (error) {
|
|
913
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
914
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
915
|
-
else message = "selector is invalid: " + arg;
|
|
916
|
-
}
|
|
917
|
-
if (!message) return;
|
|
918
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
919
|
-
}
|
|
920
|
-
//#endregion
|
|
921
|
-
//#region builder/data/create.ts
|
|
922
|
-
function createStyleData(callsite) {
|
|
923
|
-
return {
|
|
924
|
-
[BUILDER_TYPE]: 1,
|
|
925
|
-
[BUILDER_STATE]: {
|
|
926
|
-
items: [],
|
|
927
|
-
lookup: {}
|
|
928
|
-
},
|
|
929
|
-
[BUILDER_CALLSITE]: callsite
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function createSlotData(callsite, slotId) {
|
|
933
|
-
return {
|
|
934
|
-
[BUILDER_TYPE]: 2,
|
|
935
|
-
[BUILDER_STATE]: {
|
|
936
|
-
items: [],
|
|
937
|
-
lookup: {}
|
|
938
|
-
},
|
|
939
|
-
[BUILDER_CALLSITE]: callsite,
|
|
940
|
-
[BUILDER_SLOT_ID]: slotId
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function createSlotOverrideData(callsite, slotId) {
|
|
944
|
-
return {
|
|
945
|
-
[BUILDER_TYPE]: 3,
|
|
946
|
-
[BUILDER_STATE]: {
|
|
947
|
-
items: [],
|
|
948
|
-
lookup: {}
|
|
949
|
-
},
|
|
950
|
-
[BUILDER_CALLSITE]: callsite,
|
|
951
|
-
[BUILDER_SLOT_ID]: slotId
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
function createScopeData(callsite) {
|
|
955
|
-
return {
|
|
956
|
-
[BUILDER_TYPE]: 4,
|
|
957
|
-
[BUILDER_STATE]: {
|
|
958
|
-
items: [],
|
|
959
|
-
lookup: {}
|
|
960
|
-
},
|
|
961
|
-
[BUILDER_CALLSITE]: callsite
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
function createScopeTargetData(scope, slot) {
|
|
965
|
-
return {
|
|
966
|
-
[BUILDER_TYPE]: 5,
|
|
967
|
-
[BUILDER_SCOPE]: scope,
|
|
968
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
969
|
-
};
|
|
1075
|
+
function createScopeTargetData(scope, slot) {
|
|
1076
|
+
return {
|
|
1077
|
+
[BUILDER_TYPE]: 5,
|
|
1078
|
+
[BUILDER_SCOPE]: scope,
|
|
1079
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
1080
|
+
};
|
|
970
1081
|
}
|
|
971
1082
|
//#endregion
|
|
972
1083
|
//#region atomic/utils/format.ts
|
|
@@ -1082,29 +1193,18 @@ const formatClassName = createNameFormatter([
|
|
|
1082
1193
|
"selector",
|
|
1083
1194
|
"value"
|
|
1084
1195
|
]);
|
|
1085
|
-
const formatScopeClassName = createNameFormatter(["className"]);
|
|
1086
1196
|
const formatTransformClassName = createNameFormatter(["className"]);
|
|
1087
1197
|
function getDebugClassName(format, hash, info) {
|
|
1088
1198
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
1089
1199
|
}
|
|
1200
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1201
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1202
|
+
}
|
|
1090
1203
|
function getDebugTransformClassName(format, hash, info) {
|
|
1091
1204
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1092
1205
|
}
|
|
1093
|
-
function getDebugScopeClassName(format, info) {
|
|
1094
|
-
return formatScopeClassName(format || "-(className)", null, info);
|
|
1095
|
-
}
|
|
1096
1206
|
//#endregion
|
|
1097
|
-
//#region atomic/utils/
|
|
1098
|
-
function getCssVar(varName, value) {
|
|
1099
|
-
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1100
|
-
}
|
|
1101
|
-
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1102
|
-
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1103
|
-
}
|
|
1104
|
-
function escapeCssValue(value) {
|
|
1105
|
-
if (!value) return "";
|
|
1106
|
-
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1107
|
-
}
|
|
1207
|
+
//#region atomic/utils/cssIdent.ts
|
|
1108
1208
|
function escapeCssIdent(ident) {
|
|
1109
1209
|
let result = "";
|
|
1110
1210
|
for (let i = 0; i < ident.length; i++) {
|
|
@@ -1294,6 +1394,13 @@ function parseAtRule(rule) {
|
|
|
1294
1394
|
if (normalized.startsWith("@supports")) return compressQuery(normalized.slice(9));
|
|
1295
1395
|
return compressQuery(normalized);
|
|
1296
1396
|
}
|
|
1397
|
+
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1398
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1399
|
+
}
|
|
1400
|
+
function formatScopeClassName$1(format, info) {
|
|
1401
|
+
if (typeof format === "function") return format(info);
|
|
1402
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1403
|
+
}
|
|
1297
1404
|
//#endregion
|
|
1298
1405
|
//#region atomic/utils/hash.ts
|
|
1299
1406
|
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
@@ -1344,21 +1451,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1344
1451
|
}
|
|
1345
1452
|
//#endregion
|
|
1346
1453
|
//#region atomic/utils/selector.ts
|
|
1347
|
-
function getSelectorText(selector) {
|
|
1348
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1454
|
+
function getSelectorText$1(selector) {
|
|
1455
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1349
1456
|
}
|
|
1350
1457
|
function getSelectorHash(selector) {
|
|
1351
1458
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1352
1459
|
}
|
|
1353
|
-
function getSelectorPriority(selector) {
|
|
1460
|
+
function getSelectorPriority$1(selector) {
|
|
1354
1461
|
if (!selector) return 0;
|
|
1355
1462
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1356
1463
|
}
|
|
1464
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1465
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1466
|
+
}
|
|
1467
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1468
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1469
|
+
}
|
|
1357
1470
|
//#endregion
|
|
1358
1471
|
//#region atomic/className.ts
|
|
1359
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1472
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1360
1473
|
let hash = property;
|
|
1361
1474
|
hash += "\n" + (priority || "");
|
|
1475
|
+
if (important) hash += "\nimportant";
|
|
1362
1476
|
hash += "\n" + value;
|
|
1363
1477
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1364
1478
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1368,10 +1482,11 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1368
1482
|
if (!debugClassName) return hash;
|
|
1369
1483
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1370
1484
|
const propertyName = getDebugPropertyName(property, value);
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1485
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1486
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1487
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1488
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1489
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1375
1490
|
property: propertyName ? propertyName.property : property,
|
|
1376
1491
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1377
1492
|
});
|
|
@@ -1380,12 +1495,10 @@ function getRuntimeClassNameHashLength(debugClassName) {
|
|
|
1380
1495
|
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1381
1496
|
return CSS_CONFIG.hashLength ?? 7;
|
|
1382
1497
|
}
|
|
1383
|
-
function
|
|
1384
|
-
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1385
|
-
}
|
|
1386
|
-
function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
|
|
1498
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1387
1499
|
let hash = property;
|
|
1388
1500
|
hash += "\n" + (priority || "");
|
|
1501
|
+
if (important) hash += "\nimportant";
|
|
1389
1502
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1390
1503
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1391
1504
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1422,7 +1535,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1422
1535
|
let source;
|
|
1423
1536
|
let item;
|
|
1424
1537
|
let lookupIndex;
|
|
1425
|
-
let
|
|
1538
|
+
let weight;
|
|
1539
|
+
let important;
|
|
1426
1540
|
let value;
|
|
1427
1541
|
let atRule;
|
|
1428
1542
|
let dedupe;
|
|
@@ -1433,7 +1547,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1433
1547
|
source = sourceItems[i];
|
|
1434
1548
|
if (!source) continue;
|
|
1435
1549
|
if (isStyleTokenOverrideData(source)) {
|
|
1436
|
-
addTokenOverride(source, styles, lookup);
|
|
1550
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1437
1551
|
continue;
|
|
1438
1552
|
}
|
|
1439
1553
|
if (isScopeData(source)) {
|
|
@@ -1441,7 +1555,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1441
1555
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1442
1556
|
item = scopeItems[j];
|
|
1443
1557
|
if (isStyleTokenOverrideData(item)) {
|
|
1444
|
-
addTokenOverride(item, styles, lookup);
|
|
1558
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1445
1559
|
continue;
|
|
1446
1560
|
}
|
|
1447
1561
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1462,13 +1576,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1462
1576
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1463
1577
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1464
1578
|
value = scopeItem.value;
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
}
|
|
1470
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1471
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1579
|
+
weight = scopeItem.weight;
|
|
1580
|
+
important = scopeItem.important;
|
|
1581
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1582
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1472
1583
|
scopeItem.dedupe = dedupe;
|
|
1473
1584
|
scopeItem.className = className;
|
|
1474
1585
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1505,6 +1616,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1505
1616
|
dedupe: "",
|
|
1506
1617
|
className: "",
|
|
1507
1618
|
property: overrideItem.property,
|
|
1619
|
+
weight: overrideItem.weight,
|
|
1620
|
+
important: overrideItem.important,
|
|
1508
1621
|
value: overrideItem.value,
|
|
1509
1622
|
transformClassName: overrideItem.transformClassName,
|
|
1510
1623
|
token: overrideItem.token,
|
|
@@ -1516,13 +1629,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1516
1629
|
parentSelector
|
|
1517
1630
|
};
|
|
1518
1631
|
value = scopeItem.value;
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
}
|
|
1524
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1525
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1632
|
+
weight = scopeItem.weight;
|
|
1633
|
+
important = scopeItem.important;
|
|
1634
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1635
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1526
1636
|
scopeItem.dedupe = dedupe;
|
|
1527
1637
|
scopeItem.className = className;
|
|
1528
1638
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1533,7 +1643,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1533
1643
|
}
|
|
1534
1644
|
return data;
|
|
1535
1645
|
}
|
|
1536
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1646
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1537
1647
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1538
1648
|
const lookupIndex = lookup[lookupKey];
|
|
1539
1649
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1587,10 +1697,23 @@ function getScopeLookupKey(slotId, dedupe) {
|
|
|
1587
1697
|
function getTokenLookupKey(tokenId) {
|
|
1588
1698
|
return "token\0" + tokenId;
|
|
1589
1699
|
}
|
|
1700
|
+
//#endregion
|
|
1701
|
+
//#region atomic/utils/cssVar.ts
|
|
1702
|
+
function getCssVar(varName, value) {
|
|
1703
|
+
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1704
|
+
}
|
|
1705
|
+
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1706
|
+
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1707
|
+
}
|
|
1708
|
+
function escapeCssValue(value) {
|
|
1709
|
+
if (!value) return "";
|
|
1710
|
+
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1711
|
+
}
|
|
1590
1712
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1591
1713
|
function getTokenVarName(token, format) {
|
|
1592
1714
|
const id = getStyleTokenId(token);
|
|
1593
|
-
|
|
1715
|
+
const debugName = getStyleTokenName(token);
|
|
1716
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
1594
1717
|
}
|
|
1595
1718
|
function getTokenVar(token, format) {
|
|
1596
1719
|
return getTokenVarFallback(token, format);
|
|
@@ -1665,6 +1788,18 @@ function shouldAppendCssPx(property) {
|
|
|
1665
1788
|
return !UNITLESS.has(property);
|
|
1666
1789
|
}
|
|
1667
1790
|
//#endregion
|
|
1791
|
+
//#region style/important.ts
|
|
1792
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1793
|
+
function importantValue(value) {
|
|
1794
|
+
return {
|
|
1795
|
+
[STYLE_IMPORTANT]: true,
|
|
1796
|
+
value
|
|
1797
|
+
};
|
|
1798
|
+
}
|
|
1799
|
+
function isStyleImportantValue(value) {
|
|
1800
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1801
|
+
}
|
|
1802
|
+
//#endregion
|
|
1668
1803
|
//#region style/transform.ts
|
|
1669
1804
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1670
1805
|
function classNameValue(value, className) {
|
|
@@ -1690,6 +1825,19 @@ function isAtRuleRef(value) {
|
|
|
1690
1825
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1691
1826
|
}
|
|
1692
1827
|
//#endregion
|
|
1828
|
+
//#region style/weight.ts
|
|
1829
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1830
|
+
function weightValue(value, weight) {
|
|
1831
|
+
return {
|
|
1832
|
+
[STYLE_WEIGHT]: true,
|
|
1833
|
+
value,
|
|
1834
|
+
weight
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
function isStyleWeightValue(value) {
|
|
1838
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1839
|
+
}
|
|
1840
|
+
//#endregion
|
|
1693
1841
|
//#region builder/data/merge/style.ts
|
|
1694
1842
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1695
1843
|
if (!style) return source;
|
|
@@ -1700,7 +1848,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1700
1848
|
let itemData;
|
|
1701
1849
|
let valueRaw;
|
|
1702
1850
|
let value;
|
|
1703
|
-
let
|
|
1851
|
+
let weight;
|
|
1852
|
+
let important;
|
|
1704
1853
|
let itemCallsite;
|
|
1705
1854
|
let className;
|
|
1706
1855
|
let dedupe;
|
|
@@ -1721,6 +1870,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1721
1870
|
continue;
|
|
1722
1871
|
}
|
|
1723
1872
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1873
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1724
1874
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1725
1875
|
type: 2,
|
|
1726
1876
|
slotId
|
|
@@ -1729,6 +1879,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1729
1879
|
type: 3,
|
|
1730
1880
|
slotId
|
|
1731
1881
|
});
|
|
1882
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1732
1883
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1733
1884
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1734
1885
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1740,11 +1891,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1740
1891
|
}
|
|
1741
1892
|
} else for (const property in style) {
|
|
1742
1893
|
valueRaw = style[property];
|
|
1743
|
-
|
|
1744
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1745
|
-
priority = valueRaw[0];
|
|
1746
|
-
valueRaw = valueRaw[1];
|
|
1747
|
-
}
|
|
1894
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1748
1895
|
transformClassName = null;
|
|
1749
1896
|
if (isClassNameValue(valueRaw)) {
|
|
1750
1897
|
transformClassName = valueRaw.className;
|
|
@@ -1755,7 +1902,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1755
1902
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1756
1903
|
variableName = getDebugFieldVarName(debug, property);
|
|
1757
1904
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1758
|
-
value = priority !== null ? [value, priority] : value;
|
|
1759
1905
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1760
1906
|
itemData = {
|
|
1761
1907
|
runtime: runtimeType,
|
|
@@ -1764,6 +1910,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1764
1910
|
dedupe: "",
|
|
1765
1911
|
className: "",
|
|
1766
1912
|
property,
|
|
1913
|
+
weight,
|
|
1914
|
+
important,
|
|
1767
1915
|
value,
|
|
1768
1916
|
transformClassName,
|
|
1769
1917
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1777,7 +1925,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1777
1925
|
atRule,
|
|
1778
1926
|
callsite: itemCallsite
|
|
1779
1927
|
};
|
|
1780
|
-
if (type === 1) {
|
|
1928
|
+
if (type === 1 || type === 8) {
|
|
1781
1929
|
items.push({
|
|
1782
1930
|
...itemData,
|
|
1783
1931
|
type: 1
|
|
@@ -1824,13 +1972,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1824
1972
|
}
|
|
1825
1973
|
const runtimeItem = item;
|
|
1826
1974
|
value = runtimeItem.value;
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
}
|
|
1832
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1833
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1975
|
+
weight = runtimeItem.weight;
|
|
1976
|
+
important = runtimeItem.important;
|
|
1977
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1978
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1834
1979
|
runtimeItem.dedupe = dedupe;
|
|
1835
1980
|
runtimeItem.className = className;
|
|
1836
1981
|
lookupIndex = lookup[dedupe];
|
|
@@ -1839,6 +1984,41 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1839
1984
|
}
|
|
1840
1985
|
return data;
|
|
1841
1986
|
}
|
|
1987
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1988
|
+
let weight = null;
|
|
1989
|
+
let important = false;
|
|
1990
|
+
while (true) {
|
|
1991
|
+
if (isStyleImportantValue(value)) {
|
|
1992
|
+
important = true;
|
|
1993
|
+
value = value.value;
|
|
1994
|
+
continue;
|
|
1995
|
+
}
|
|
1996
|
+
if (isStyleWeightValue(value)) {
|
|
1997
|
+
weight = value.weight;
|
|
1998
|
+
value = value.value;
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
break;
|
|
2002
|
+
}
|
|
2003
|
+
return [
|
|
2004
|
+
value,
|
|
2005
|
+
weight,
|
|
2006
|
+
important
|
|
2007
|
+
];
|
|
2008
|
+
}
|
|
2009
|
+
function combineSelectors$1(parent, child) {
|
|
2010
|
+
const parentText = getSelectorText(parent);
|
|
2011
|
+
const childText = getSelectorText(child);
|
|
2012
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
2013
|
+
const selector = parentText + childText;
|
|
2014
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
2015
|
+
}
|
|
2016
|
+
function getSelectorText(selector) {
|
|
2017
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
2018
|
+
}
|
|
2019
|
+
function getSelectorPriority(selector) {
|
|
2020
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
2021
|
+
}
|
|
1842
2022
|
function getMergedStyleDebug(debug, item) {
|
|
1843
2023
|
if (!debug) return null;
|
|
1844
2024
|
if (debug.fields?.[item.property]) return debug;
|
|
@@ -1882,6 +2062,47 @@ function withDebugSource$1(loc, debug) {
|
|
|
1882
2062
|
];
|
|
1883
2063
|
}
|
|
1884
2064
|
//#endregion
|
|
2065
|
+
//#region builder/selector_override_core.ts
|
|
2066
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
2067
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
2068
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
2069
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
2070
|
+
}
|
|
2071
|
+
function assertManualSelectorSyntax(selector) {
|
|
2072
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
2073
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
2074
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
2075
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2076
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
2077
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2078
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
2079
|
+
}
|
|
2080
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
2081
|
+
const value = selector.trim();
|
|
2082
|
+
assertManualSelector(value);
|
|
2083
|
+
if (value.startsWith("&?")) {
|
|
2084
|
+
const suffix = value.slice(2);
|
|
2085
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
2086
|
+
}
|
|
2087
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
2088
|
+
}
|
|
2089
|
+
//#endregion
|
|
2090
|
+
//#region builder/selector_override.ts
|
|
2091
|
+
function normalizeManualSelectors(input) {
|
|
2092
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
2093
|
+
}
|
|
2094
|
+
function assertManualSelector(selector) {
|
|
2095
|
+
assertManualSelectorSyntax(selector);
|
|
2096
|
+
const ampersandIndex = selector.indexOf("&");
|
|
2097
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
2098
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
2099
|
+
try {
|
|
2100
|
+
(0, css_what.parse)(parsedSelector);
|
|
2101
|
+
} catch {
|
|
2102
|
+
throw new Error("selector is invalid: " + selector);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
//#endregion
|
|
1885
2106
|
//#region builder/style_data.ts
|
|
1886
2107
|
const mergeStyleCreate = (callsite) => {
|
|
1887
2108
|
return createStyleData(callsite);
|
|
@@ -1895,61 +2116,174 @@ const mergeSlotOverrideCreate = (callsite, data) => {
|
|
|
1895
2116
|
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1896
2117
|
};
|
|
1897
2118
|
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
2119
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
2120
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
2121
|
+
};
|
|
2122
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1898
2123
|
function createMerge(create, type) {
|
|
1899
2124
|
return (data, callsite, style, debug, selector, atRule) => {
|
|
1900
2125
|
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1901
2126
|
};
|
|
1902
2127
|
}
|
|
1903
2128
|
//#endregion
|
|
1904
|
-
//#region
|
|
1905
|
-
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
return traceCallsite();
|
|
1910
|
-
}
|
|
1911
|
-
function resolveCallsite(debug) {
|
|
1912
|
-
return debug ? getDebugCallsite(debug) : runtimeCallsite();
|
|
2129
|
+
//#region selector/validate.ts
|
|
2130
|
+
function isLocalSelector(selector) {
|
|
2131
|
+
const groups = parseSelector(selector);
|
|
2132
|
+
if (!groups || groups.length !== 1) return false;
|
|
2133
|
+
return isSelectorGroupsSelf(groups, false);
|
|
1913
2134
|
}
|
|
1914
|
-
function
|
|
1915
|
-
|
|
2135
|
+
function isPseudoArgSelector(selector) {
|
|
2136
|
+
const groups = parseSelector(selector);
|
|
2137
|
+
if (!groups || groups.length !== 1) return false;
|
|
2138
|
+
return isSelectorGroupsSelf(groups, true);
|
|
1916
2139
|
}
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
function createStyleFns(mergeData, selectors, fnPrefix, transform = null, createFnResult) {
|
|
1923
|
-
createFnResult = createFnResult || createDefaultFnResult;
|
|
1924
|
-
return createFns(selectors, fnPrefix, (fns, fnName, selector) => createStyleFn$1(mergeData, fns, createFnResult, fnPrefix, fnName, selector, transform));
|
|
2140
|
+
function isTagSelector(selector) {
|
|
2141
|
+
const groups = parseSelector(selector);
|
|
2142
|
+
if (!groups || groups.length !== 1) return false;
|
|
2143
|
+
const group = groups[0];
|
|
2144
|
+
return group.length === 1 && group[0].type === css_what.SelectorType.Tag;
|
|
1925
2145
|
}
|
|
1926
|
-
function
|
|
1927
|
-
|
|
2146
|
+
function isAttrArg(value) {
|
|
2147
|
+
if (!value) return false;
|
|
2148
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
2149
|
+
return true;
|
|
1928
2150
|
}
|
|
1929
|
-
function
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
if (!fn) return;
|
|
1934
|
-
fns[fnName] = fn;
|
|
1935
|
-
traceMarker(fn, fnPrefix + fnName);
|
|
1936
|
-
});
|
|
1937
|
-
return fns;
|
|
2151
|
+
function isRawValue(value) {
|
|
2152
|
+
if (!value) return false;
|
|
2153
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
2154
|
+
return true;
|
|
1938
2155
|
}
|
|
1939
|
-
function
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
}
|
|
1945
|
-
if (selector.startsWith("@")) return createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
1946
|
-
if (selector.includes("$$")) return createArgsFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
1947
|
-
if (selector.includes("$")) return createArgFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
1948
|
-
if (selector !== "...") return createSimpleFn(mergeData, fns, createFnResult, fnSelector, transform);
|
|
1949
|
-
return createMergeFn(mergeData, fns, createFnResult);
|
|
2156
|
+
function parseSelector(selector) {
|
|
2157
|
+
try {
|
|
2158
|
+
return (0, css_what.parse)(selector);
|
|
2159
|
+
} catch {
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
1950
2162
|
}
|
|
1951
|
-
function
|
|
1952
|
-
|
|
2163
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
2164
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2165
|
+
const group = groups[i];
|
|
2166
|
+
for (let j = 0; j < group.length; j++) {
|
|
2167
|
+
const token = group[j];
|
|
2168
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2169
|
+
if (token.type === css_what.SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return true;
|
|
2173
|
+
}
|
|
2174
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2175
|
+
return type === css_what.SelectorType.Attribute || type === css_what.SelectorType.Pseudo || type === css_what.SelectorType.PseudoElement || allowTag && type === css_what.SelectorType.Tag;
|
|
2176
|
+
}
|
|
2177
|
+
//#endregion
|
|
2178
|
+
//#region selector/assert.ts
|
|
2179
|
+
function assertSelector(type, value) {
|
|
2180
|
+
assertSelectorNotEmpty(value);
|
|
2181
|
+
if (!type) return;
|
|
2182
|
+
if (typeof type === "function") return type(value);
|
|
2183
|
+
switch (type) {
|
|
2184
|
+
case "local": return assertLocalSelector(value);
|
|
2185
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2186
|
+
case "tag": return assertTagSelector(value);
|
|
2187
|
+
case "attr": return assertAttrSelector(value);
|
|
2188
|
+
case "value": return assertRawValue(value);
|
|
2189
|
+
case "media": return assertMediaQuery(value);
|
|
2190
|
+
case "supports": return assertSupportsQuery(value);
|
|
2191
|
+
case "container": return assertContainerQuery(value);
|
|
2192
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2196
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2197
|
+
});
|
|
2198
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2199
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2200
|
+
});
|
|
2201
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2202
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2203
|
+
});
|
|
2204
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2205
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2206
|
+
});
|
|
2207
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2208
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2209
|
+
});
|
|
2210
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2211
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2212
|
+
});
|
|
2213
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2214
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2215
|
+
});
|
|
2216
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2217
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2218
|
+
});
|
|
2219
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2220
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2221
|
+
});
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region builder/data/check_selector.ts
|
|
2224
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2225
|
+
let message = null;
|
|
2226
|
+
try {
|
|
2227
|
+
assertSelector(fnSelector.assert, arg);
|
|
2228
|
+
} catch (error) {
|
|
2229
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2230
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2231
|
+
else message = "selector is invalid: " + arg;
|
|
2232
|
+
}
|
|
2233
|
+
if (!message) return;
|
|
2234
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
2235
|
+
}
|
|
2236
|
+
//#endregion
|
|
2237
|
+
//#region builder/utils.ts
|
|
2238
|
+
const FnPrefixStyle = "style.";
|
|
2239
|
+
const FnPrefixSlot = "slot.";
|
|
2240
|
+
const FnPrefixScope = "scope.";
|
|
2241
|
+
const FnPrefixSelector = "selector.";
|
|
2242
|
+
function runtimeCallsite() {
|
|
2243
|
+
return traceCallsite();
|
|
2244
|
+
}
|
|
2245
|
+
function resolveCallsite(debug) {
|
|
2246
|
+
return debug ? getDebugCallsite(debug) : runtimeCallsite();
|
|
2247
|
+
}
|
|
2248
|
+
function transformStyle(style, transform) {
|
|
2249
|
+
return transform ? transform.transform(style) : style;
|
|
2250
|
+
}
|
|
2251
|
+
//#endregion
|
|
2252
|
+
//#region builder/style_fns.ts
|
|
2253
|
+
const createDefaultFnResult = (data, fns) => {
|
|
2254
|
+
return Object.assign(Object.create(fns), data);
|
|
2255
|
+
};
|
|
2256
|
+
function createStyleFns(mergeData, selectors, fnPrefix, transform = null, createFnResult) {
|
|
2257
|
+
createFnResult = createFnResult || createDefaultFnResult;
|
|
2258
|
+
return createFns(selectors, fnPrefix, (fns, fnName, selector) => createStyleFn$1(mergeData, fns, createFnResult, fnPrefix, fnName, selector, transform));
|
|
2259
|
+
}
|
|
2260
|
+
function createScopeFns(selectors, fnPrefix, cloneScope) {
|
|
2261
|
+
return createFns(selectors, fnPrefix, (_fns, fnName, selector) => createScopeFn(fnPrefix, fnName, selector, cloneScope));
|
|
2262
|
+
}
|
|
2263
|
+
function createFns(selectors, fnPrefix, createFn) {
|
|
2264
|
+
const fns = {};
|
|
2265
|
+
Object.entries(selectors).forEach(([fnName, selector]) => {
|
|
2266
|
+
const fn = createFn(fns, fnName, selector);
|
|
2267
|
+
if (!fn) return;
|
|
2268
|
+
fns[fnName] = fn;
|
|
2269
|
+
traceMarker(fn, fnPrefix + fnName);
|
|
2270
|
+
});
|
|
2271
|
+
return fns;
|
|
2272
|
+
}
|
|
2273
|
+
function createStyleFn$1(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform) {
|
|
2274
|
+
const selector = fnSelector.selector.trim();
|
|
2275
|
+
fnSelector = {
|
|
2276
|
+
...fnSelector,
|
|
2277
|
+
selector
|
|
2278
|
+
};
|
|
2279
|
+
if (selector.startsWith("@")) return createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
2280
|
+
if (selector.includes("$$")) return createArgsFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
2281
|
+
if (selector.includes("$")) return createArgFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSelector, transform);
|
|
2282
|
+
if (selector !== "...") return createSimpleFn(mergeData, fns, createFnResult, fnSelector, transform);
|
|
2283
|
+
return createMergeFn(mergeData, fns, createFnResult);
|
|
2284
|
+
}
|
|
2285
|
+
function createMergeFn(mergeData, fns, createFnResult) {
|
|
2286
|
+
return function(style, debug) {
|
|
1953
2287
|
const callsite = resolveCallsite(debug);
|
|
1954
2288
|
const items = Array.isArray(style) ? style : [style];
|
|
1955
2289
|
let data = this;
|
|
@@ -1965,9 +2299,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1965
2299
|
let arg;
|
|
1966
2300
|
let style;
|
|
1967
2301
|
let debug;
|
|
1968
|
-
let
|
|
2302
|
+
let weight = null;
|
|
1969
2303
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1970
|
-
|
|
2304
|
+
weight = params[0];
|
|
1971
2305
|
arg = params[1];
|
|
1972
2306
|
style = params[2];
|
|
1973
2307
|
debug = params[3];
|
|
@@ -1977,7 +2311,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1977
2311
|
debug = params[2];
|
|
1978
2312
|
}
|
|
1979
2313
|
else if (isMedia && typeof params[0] === "number") {
|
|
1980
|
-
|
|
2314
|
+
weight = params[0];
|
|
1981
2315
|
arg = fnSelector.selector;
|
|
1982
2316
|
style = params[1];
|
|
1983
2317
|
debug = params[2];
|
|
@@ -1997,7 +2331,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1997
2331
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1998
2332
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
1999
2333
|
const item = items[j];
|
|
2000
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2334
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
2001
2335
|
}
|
|
2002
2336
|
}
|
|
2003
2337
|
return createFnResult(data, fns);
|
|
@@ -2064,9 +2398,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2064
2398
|
let arg;
|
|
2065
2399
|
let data;
|
|
2066
2400
|
let debug;
|
|
2067
|
-
let
|
|
2401
|
+
let weight = null;
|
|
2068
2402
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
2069
|
-
|
|
2403
|
+
weight = params[0];
|
|
2070
2404
|
arg = params[1];
|
|
2071
2405
|
data = params[2];
|
|
2072
2406
|
debug = params[3];
|
|
@@ -2076,7 +2410,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2076
2410
|
debug = params[2];
|
|
2077
2411
|
}
|
|
2078
2412
|
else if (isMedia && typeof params[0] === "number") {
|
|
2079
|
-
|
|
2413
|
+
weight = params[0];
|
|
2080
2414
|
arg = fnSelector.selector;
|
|
2081
2415
|
data = params[1];
|
|
2082
2416
|
debug = params[2];
|
|
@@ -2093,7 +2427,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
2093
2427
|
selector = args[i];
|
|
2094
2428
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
2095
2429
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
2096
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2430
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
2097
2431
|
}
|
|
2098
2432
|
return result;
|
|
2099
2433
|
};
|
|
@@ -2170,6 +2504,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2170
2504
|
traceMarker(fn, "slot");
|
|
2171
2505
|
return fn;
|
|
2172
2506
|
}
|
|
2507
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2508
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2509
|
+
const fn = (selector, style, debug) => {
|
|
2510
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2511
|
+
debug = style;
|
|
2512
|
+
style = void 0;
|
|
2513
|
+
}
|
|
2514
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2515
|
+
if (style === void 0) return target;
|
|
2516
|
+
return target(style, debug);
|
|
2517
|
+
};
|
|
2518
|
+
traceMarker(fn, "style.selector");
|
|
2519
|
+
return fn;
|
|
2520
|
+
}
|
|
2173
2521
|
function createScopeBuilder(selectors) {
|
|
2174
2522
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2175
2523
|
const fn = (items, debug) => {
|
|
@@ -2185,6 +2533,34 @@ function createScopeBuilder(selectors) {
|
|
|
2185
2533
|
traceMarker(fn, "scope");
|
|
2186
2534
|
return fn;
|
|
2187
2535
|
}
|
|
2536
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2537
|
+
const callable = ((style, debug) => {
|
|
2538
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2539
|
+
debug = style;
|
|
2540
|
+
style = void 0;
|
|
2541
|
+
}
|
|
2542
|
+
const callsite = resolveCallsite(debug);
|
|
2543
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2544
|
+
});
|
|
2545
|
+
traceMarker(callable, "selector.override");
|
|
2546
|
+
Object.setPrototypeOf(callable, fns);
|
|
2547
|
+
Object.assign(callable, data);
|
|
2548
|
+
return callable;
|
|
2549
|
+
}
|
|
2550
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2551
|
+
const callable = ((style, debug) => {
|
|
2552
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2553
|
+
debug = style;
|
|
2554
|
+
style = void 0;
|
|
2555
|
+
}
|
|
2556
|
+
const callsite = resolveCallsite(debug);
|
|
2557
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2558
|
+
});
|
|
2559
|
+
traceMarker(callable, "selector");
|
|
2560
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2561
|
+
Object.assign(callable, data);
|
|
2562
|
+
return callable;
|
|
2563
|
+
}
|
|
2188
2564
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2189
2565
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2190
2566
|
const callable = ((style, debug) => {
|
|
@@ -2793,6 +3169,497 @@ function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, to
|
|
|
2793
3169
|
}
|
|
2794
3170
|
createIdCounter("property");
|
|
2795
3171
|
//#endregion
|
|
3172
|
+
//#region sheet/utils/sourcemap.ts
|
|
3173
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3174
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3175
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3176
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3177
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3178
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3179
|
+
function encodeBase64(text) {
|
|
3180
|
+
const bytes = new TextEncoder().encode(text);
|
|
3181
|
+
let binary = "";
|
|
3182
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3183
|
+
return btoa(binary);
|
|
3184
|
+
}
|
|
3185
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3186
|
+
let source = sourceLookup[filePath];
|
|
3187
|
+
if (source) {
|
|
3188
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3189
|
+
return source;
|
|
3190
|
+
}
|
|
3191
|
+
source = {
|
|
3192
|
+
filePath,
|
|
3193
|
+
sourceIndex: sources.length,
|
|
3194
|
+
sourceContent
|
|
3195
|
+
};
|
|
3196
|
+
sources.push(source);
|
|
3197
|
+
sourceLookup[filePath] = source;
|
|
3198
|
+
return source;
|
|
3199
|
+
}
|
|
3200
|
+
function normalizeSourcePath(filePath) {
|
|
3201
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3202
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3203
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3204
|
+
return filePath.replace(/^at\s+/, "");
|
|
3205
|
+
}
|
|
3206
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3207
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3208
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3209
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3210
|
+
}
|
|
3211
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3212
|
+
const sidecarUrl = getSidecarUrl();
|
|
3213
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3214
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3215
|
+
}
|
|
3216
|
+
function getSidecarUrl() {
|
|
3217
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3218
|
+
return typeof value === "string" && value ? value : null;
|
|
3219
|
+
}
|
|
3220
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3221
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3222
|
+
try {
|
|
3223
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3224
|
+
} catch {
|
|
3225
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3229
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3230
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3231
|
+
return path ? `${base}/${path}` : base;
|
|
3232
|
+
}
|
|
3233
|
+
function getLineCount(css) {
|
|
3234
|
+
let count = 1;
|
|
3235
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3236
|
+
return count;
|
|
3237
|
+
}
|
|
3238
|
+
function encodeVlq(value) {
|
|
3239
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3240
|
+
let encoded = "";
|
|
3241
|
+
do {
|
|
3242
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3243
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3244
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3245
|
+
encoded += BASE64[digit];
|
|
3246
|
+
} while (vlq > 0);
|
|
3247
|
+
return encoded;
|
|
3248
|
+
}
|
|
3249
|
+
//#endregion
|
|
3250
|
+
//#region sheet/sourcemap.ts
|
|
3251
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3252
|
+
if (debug && debugField) {
|
|
3253
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3254
|
+
if (loc) return normalizeRuleCallsite({
|
|
3255
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3256
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3257
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3258
|
+
line: loc[0],
|
|
3259
|
+
column: loc[1]
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3263
|
+
if (debug) return normalizeRuleCallsite({
|
|
3264
|
+
filePath: debug.sourceUrl,
|
|
3265
|
+
sourceUrl: debug.sourceUrl,
|
|
3266
|
+
sourceContent: debug.code,
|
|
3267
|
+
line: debug.loc[0],
|
|
3268
|
+
column: debug.loc[1]
|
|
3269
|
+
});
|
|
3270
|
+
return callsite || null;
|
|
3271
|
+
}
|
|
3272
|
+
function normalizeRuleCallsite(callsite) {
|
|
3273
|
+
return {
|
|
3274
|
+
...callsite,
|
|
3275
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3276
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3280
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3281
|
+
//#endregion
|
|
3282
|
+
//#region builder/extract/utils.ts
|
|
3283
|
+
function createExtractedData(type, slotId) {
|
|
3284
|
+
const data = {
|
|
3285
|
+
[BUILDER_TYPE]: type,
|
|
3286
|
+
[BUILDER_STATE]: {
|
|
3287
|
+
items: [],
|
|
3288
|
+
lookup: {}
|
|
3289
|
+
},
|
|
3290
|
+
[BUILDER_CALLSITE]: null
|
|
3291
|
+
};
|
|
3292
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3293
|
+
return data;
|
|
3294
|
+
}
|
|
3295
|
+
function copyExtractedData(target, source) {
|
|
3296
|
+
const mutable = target;
|
|
3297
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3298
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3299
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3300
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3301
|
+
}
|
|
3302
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3303
|
+
return {
|
|
3304
|
+
[BUILDER_TYPE]: 5,
|
|
3305
|
+
[BUILDER_SCOPE]: scope,
|
|
3306
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3310
|
+
const normalized = [];
|
|
3311
|
+
let i = 0;
|
|
3312
|
+
while (i < items.length) {
|
|
3313
|
+
const item = items[i];
|
|
3314
|
+
const value = item[2];
|
|
3315
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3316
|
+
type,
|
|
3317
|
+
item[0],
|
|
3318
|
+
item[1]
|
|
3319
|
+
] : [
|
|
3320
|
+
type,
|
|
3321
|
+
slotId,
|
|
3322
|
+
item[0],
|
|
3323
|
+
item[1]
|
|
3324
|
+
] : slotId === null ? [
|
|
3325
|
+
type,
|
|
3326
|
+
item[0],
|
|
3327
|
+
item[1],
|
|
3328
|
+
value
|
|
3329
|
+
] : [
|
|
3330
|
+
type,
|
|
3331
|
+
slotId,
|
|
3332
|
+
item[0],
|
|
3333
|
+
item[1],
|
|
3334
|
+
value
|
|
3335
|
+
]);
|
|
3336
|
+
i++;
|
|
3337
|
+
}
|
|
3338
|
+
return normalized;
|
|
3339
|
+
}
|
|
3340
|
+
//#endregion
|
|
3341
|
+
//#region builder/extract/withTokens.ts
|
|
3342
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3343
|
+
function isExtractedTokenBoundData(value) {
|
|
3344
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3345
|
+
}
|
|
3346
|
+
function getExtractedTokenBoundData(value) {
|
|
3347
|
+
return tokenBoundData.get(value);
|
|
3348
|
+
}
|
|
3349
|
+
function isElementDebugData(value) {
|
|
3350
|
+
if (!value || typeof value !== "object") return false;
|
|
3351
|
+
return value.$$elementDebug === true;
|
|
3352
|
+
}
|
|
3353
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
3354
|
+
//#endregion
|
|
3355
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3356
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3357
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3358
|
+
function markResolvedStyleItem(item) {
|
|
3359
|
+
resolvedStyleItems.add(item);
|
|
3360
|
+
}
|
|
3361
|
+
function isResolvedStyleItem$1(value) {
|
|
3362
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3363
|
+
}
|
|
3364
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3365
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
3366
|
+
}
|
|
3367
|
+
//#endregion
|
|
3368
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3369
|
+
function createMutableTokenValues(base) {
|
|
3370
|
+
return {
|
|
3371
|
+
ids: base ? base.ids.slice() : null,
|
|
3372
|
+
values: base ? base.values.slice() : null,
|
|
3373
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3374
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
function addTokenOverride(values, item, resolver) {
|
|
3378
|
+
if (!resolver.is(item)) return false;
|
|
3379
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3380
|
+
return true;
|
|
3381
|
+
}
|
|
3382
|
+
function addTokenValue(values, id, value) {
|
|
3383
|
+
if (!values.ids) values.ids = [];
|
|
3384
|
+
if (!values.values) values.values = [];
|
|
3385
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3386
|
+
if (!values.index) values.index = Object.create(null);
|
|
3387
|
+
const ids = values.ids;
|
|
3388
|
+
const tokenValues = values.values;
|
|
3389
|
+
const lookup = values.lookup;
|
|
3390
|
+
const indexLookup = values.index;
|
|
3391
|
+
const index = indexLookup[id];
|
|
3392
|
+
if (index === void 0) {
|
|
3393
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3394
|
+
tokenValues.push(value);
|
|
3395
|
+
} else tokenValues[index] = value;
|
|
3396
|
+
lookup[id] = value;
|
|
3397
|
+
}
|
|
3398
|
+
function addTokenValues(values, next) {
|
|
3399
|
+
if (!next) return;
|
|
3400
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3401
|
+
}
|
|
3402
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3403
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3404
|
+
}
|
|
3405
|
+
function finishTokenValues(base, values) {
|
|
3406
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3407
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
3408
|
+
return {
|
|
3409
|
+
ids: values.ids,
|
|
3410
|
+
values: values.values,
|
|
3411
|
+
lookup: values.lookup
|
|
3412
|
+
};
|
|
3413
|
+
}
|
|
3414
|
+
function mergeTokenValues(base, next) {
|
|
3415
|
+
if (!next) return base;
|
|
3416
|
+
if (!base) return next;
|
|
3417
|
+
const values = createMutableTokenValues(base);
|
|
3418
|
+
addTokenValues(values, next);
|
|
3419
|
+
return finishTokenValues(base, values);
|
|
3420
|
+
}
|
|
3421
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3422
|
+
if (!overrides.length) return base;
|
|
3423
|
+
const values = createMutableTokenValues(base);
|
|
3424
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3425
|
+
return finishTokenValues(base, values);
|
|
3426
|
+
}
|
|
3427
|
+
function createTokenIndexLookup(ids) {
|
|
3428
|
+
const lookup = Object.create(null);
|
|
3429
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3430
|
+
return lookup;
|
|
3431
|
+
}
|
|
3432
|
+
function isSameTokenValues(base, ids, values) {
|
|
3433
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3434
|
+
const baseLookup = base.lookup;
|
|
3435
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3436
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3437
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3438
|
+
}
|
|
3439
|
+
return true;
|
|
3440
|
+
}
|
|
3441
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3442
|
+
function isResolvedStyleItem(value) {
|
|
3443
|
+
return isResolvedStyleItem$1(value);
|
|
3444
|
+
}
|
|
3445
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3446
|
+
return createStyleItem({
|
|
3447
|
+
data,
|
|
3448
|
+
items: resolveItems(data, scopes)
|
|
3449
|
+
}, tokens);
|
|
3450
|
+
}
|
|
3451
|
+
function createStyleItem(item, tokens = null) {
|
|
3452
|
+
markResolvedStyleItem(item);
|
|
3453
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3454
|
+
return item;
|
|
3455
|
+
}
|
|
3456
|
+
function resolveItems(data, scopes) {
|
|
3457
|
+
const items = [];
|
|
3458
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3459
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3460
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3461
|
+
const item = stateItems[i];
|
|
3462
|
+
if (Array.isArray(item)) {
|
|
3463
|
+
items.push(item);
|
|
3464
|
+
continue;
|
|
3465
|
+
}
|
|
3466
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3467
|
+
items.push(item);
|
|
3468
|
+
continue;
|
|
3469
|
+
}
|
|
3470
|
+
if (slotId && item.type !== 2) continue;
|
|
3471
|
+
items.push(item);
|
|
3472
|
+
}
|
|
3473
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3474
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3475
|
+
const boundScope = scopes[i];
|
|
3476
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3477
|
+
if (!scope) continue;
|
|
3478
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3479
|
+
if (!scopeItems) continue;
|
|
3480
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3481
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3482
|
+
const item = scopeItems[j];
|
|
3483
|
+
if (Array.isArray(item)) {
|
|
3484
|
+
if (item[1] === slotId) items.push(item);
|
|
3485
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3486
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3487
|
+
continue;
|
|
3488
|
+
}
|
|
3489
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3490
|
+
if (item.type !== 4) continue;
|
|
3491
|
+
if (item.slotId === slotId) items.push(item);
|
|
3492
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
return items;
|
|
3496
|
+
}
|
|
3497
|
+
function getScopeParentItem(className) {
|
|
3498
|
+
const parentClassName = formatScopeClassName(className);
|
|
3499
|
+
return [parentClassName, parentClassName];
|
|
3500
|
+
}
|
|
3501
|
+
function formatScopeClassName(className) {
|
|
3502
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3503
|
+
if (!format) return "-" + className;
|
|
3504
|
+
if (typeof format === "function") return format({ className });
|
|
3505
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3506
|
+
}
|
|
3507
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3508
|
+
return value === 1 || value === true;
|
|
3509
|
+
}
|
|
3510
|
+
//#endregion
|
|
3511
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3512
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3513
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3514
|
+
}
|
|
3515
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3516
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3517
|
+
}
|
|
3518
|
+
function getDataTokenValues(data, resolver) {
|
|
3519
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3520
|
+
const values = createMutableTokenValues(null);
|
|
3521
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3522
|
+
return finishTokenValues(null, values);
|
|
3523
|
+
}
|
|
3524
|
+
createCacheValue();
|
|
3525
|
+
function createCacheValue() {
|
|
3526
|
+
return {
|
|
3527
|
+
d: null,
|
|
3528
|
+
c: RUNTIME_CONFIG.changes
|
|
3529
|
+
};
|
|
3530
|
+
}
|
|
3531
|
+
//#endregion
|
|
3532
|
+
//#region runtime/core/cache/token.ts
|
|
3533
|
+
const runtimeTokenValueResolver = {
|
|
3534
|
+
get key() {
|
|
3535
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3536
|
+
},
|
|
3537
|
+
is: isStyleTokenOverrideData,
|
|
3538
|
+
id(token) {
|
|
3539
|
+
return getStyleTokenId(token);
|
|
3540
|
+
},
|
|
3541
|
+
value(token) {
|
|
3542
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3546
|
+
if (isElementDebugData(item)) return null;
|
|
3547
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3548
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3549
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3550
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3551
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3552
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3553
|
+
}
|
|
3554
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3555
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3556
|
+
return null;
|
|
3557
|
+
}
|
|
3558
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3559
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3560
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3561
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3562
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3563
|
+
if (key && tokens) tokenBindings.push({
|
|
3564
|
+
data: key,
|
|
3565
|
+
tokens
|
|
3566
|
+
});
|
|
3567
|
+
return key;
|
|
3568
|
+
}
|
|
3569
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3570
|
+
return null;
|
|
3571
|
+
}
|
|
3572
|
+
//#endregion
|
|
3573
|
+
//#region atomic/rule.ts
|
|
3574
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3575
|
+
const cssProp = getCssPropertyName(property);
|
|
3576
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3577
|
+
const escapedClass = escapeCssIdent(className);
|
|
3578
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3579
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3580
|
+
let selectorStr = classSelector + itemSelector;
|
|
3581
|
+
if (parentSelector) {
|
|
3582
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3583
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3584
|
+
}
|
|
3585
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3586
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3587
|
+
return rule;
|
|
3588
|
+
}
|
|
3589
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3590
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3591
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3592
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3593
|
+
return [
|
|
3594
|
+
priority ?? 0,
|
|
3595
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3596
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3597
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3598
|
+
atRules ? atRules.length : 0,
|
|
3599
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3600
|
+
getPropertyPriority(property)
|
|
3601
|
+
];
|
|
3602
|
+
}
|
|
3603
|
+
function getMediaPriority(atRules, priority) {
|
|
3604
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3605
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3606
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3607
|
+
}
|
|
3608
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3609
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3610
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3611
|
+
return LayerSelectorPriorities.base;
|
|
3612
|
+
}
|
|
3613
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3614
|
+
if (!parentSelector) return 0;
|
|
3615
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3616
|
+
}
|
|
3617
|
+
function getAtRulePriority$1(atRules) {
|
|
3618
|
+
if (!atRules?.length) return 0;
|
|
3619
|
+
let priority = 0;
|
|
3620
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3621
|
+
return priority;
|
|
3622
|
+
}
|
|
3623
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3624
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3625
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3626
|
+
}
|
|
3627
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3628
|
+
const declarations = [];
|
|
3629
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3630
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3631
|
+
}
|
|
3632
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3633
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3634
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3635
|
+
return name + ":" + value;
|
|
3636
|
+
}
|
|
3637
|
+
function normalizeThemeName(value) {
|
|
3638
|
+
if (!value) return null;
|
|
3639
|
+
value = value.trim();
|
|
3640
|
+
if (!value) return null;
|
|
3641
|
+
if (/^\d+$/.test(value)) return null;
|
|
3642
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3643
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3644
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3645
|
+
value = stripGenericThemePrefix(value);
|
|
3646
|
+
if (!value) return null;
|
|
3647
|
+
return value;
|
|
3648
|
+
}
|
|
3649
|
+
function stripGenericThemePrefix(value) {
|
|
3650
|
+
const parts = value.split("--");
|
|
3651
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3652
|
+
value = parts.join("--");
|
|
3653
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3654
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3655
|
+
return value;
|
|
3656
|
+
}
|
|
3657
|
+
function isGeneratedNameHash(value) {
|
|
3658
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3659
|
+
}
|
|
3660
|
+
createNameFormatter(["name"]);
|
|
3661
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
3662
|
+
//#endregion
|
|
2796
3663
|
//#region style/keyframes.ts
|
|
2797
3664
|
function transformKeyframes(frames, transform) {
|
|
2798
3665
|
if (!transform) return frames;
|
|
@@ -2819,9 +3686,11 @@ function createStyleFn(args) {
|
|
|
2819
3686
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2820
3687
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2821
3688
|
const fnScope = createScopeBuilder(selectors);
|
|
2822
|
-
const
|
|
2823
|
-
|
|
3689
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3690
|
+
const fnWeight = (value, weight) => {
|
|
3691
|
+
return weightValue(value, weight);
|
|
2824
3692
|
};
|
|
3693
|
+
const fnImportant = (value) => importantValue(value);
|
|
2825
3694
|
const fnRaw = (style) => style;
|
|
2826
3695
|
const fnPlain = (style) => style;
|
|
2827
3696
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2833,11 +3702,13 @@ function createStyleFn(args) {
|
|
|
2833
3702
|
const style = fnStyle;
|
|
2834
3703
|
style.slot = fnSlot;
|
|
2835
3704
|
style.scope = fnScope;
|
|
2836
|
-
style.
|
|
3705
|
+
style.weight = fnWeight;
|
|
3706
|
+
style.important = fnImportant;
|
|
2837
3707
|
style.raw = fnRaw;
|
|
2838
3708
|
style.plain = fnPlain;
|
|
2839
3709
|
style.keyframes = fnKeyframes;
|
|
2840
3710
|
style.merge = fnMerge;
|
|
3711
|
+
style.selector = fnSelector;
|
|
2841
3712
|
assignStyleFnMeta(style, {
|
|
2842
3713
|
mode: "StyleObject",
|
|
2843
3714
|
selectors,
|
|
@@ -2972,65 +3843,6 @@ function isGlobPattern(source) {
|
|
|
2972
3843
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
2973
3844
|
}
|
|
2974
3845
|
//#endregion
|
|
2975
|
-
//#region builder/extract/utils.ts
|
|
2976
|
-
function createExtractedData(type, slotId) {
|
|
2977
|
-
const data = {
|
|
2978
|
-
[BUILDER_TYPE]: type,
|
|
2979
|
-
[BUILDER_STATE]: {
|
|
2980
|
-
items: [],
|
|
2981
|
-
lookup: {}
|
|
2982
|
-
},
|
|
2983
|
-
[BUILDER_CALLSITE]: null
|
|
2984
|
-
};
|
|
2985
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
2986
|
-
return data;
|
|
2987
|
-
}
|
|
2988
|
-
function copyExtractedData(target, source) {
|
|
2989
|
-
const mutable = target;
|
|
2990
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
2991
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
2992
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
2993
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
2994
|
-
}
|
|
2995
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
2996
|
-
return {
|
|
2997
|
-
[BUILDER_TYPE]: 5,
|
|
2998
|
-
[BUILDER_SCOPE]: scope,
|
|
2999
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3000
|
-
};
|
|
3001
|
-
}
|
|
3002
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
3003
|
-
const normalized = [];
|
|
3004
|
-
let i = 0;
|
|
3005
|
-
while (i < items.length) {
|
|
3006
|
-
const item = items[i];
|
|
3007
|
-
const value = item[2];
|
|
3008
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
3009
|
-
type,
|
|
3010
|
-
item[0],
|
|
3011
|
-
item[1]
|
|
3012
|
-
] : [
|
|
3013
|
-
type,
|
|
3014
|
-
slotId,
|
|
3015
|
-
item[0],
|
|
3016
|
-
item[1]
|
|
3017
|
-
] : slotId === null ? [
|
|
3018
|
-
type,
|
|
3019
|
-
item[0],
|
|
3020
|
-
item[1],
|
|
3021
|
-
value
|
|
3022
|
-
] : [
|
|
3023
|
-
type,
|
|
3024
|
-
slotId,
|
|
3025
|
-
item[0],
|
|
3026
|
-
item[1],
|
|
3027
|
-
value
|
|
3028
|
-
]);
|
|
3029
|
-
i++;
|
|
3030
|
-
}
|
|
3031
|
-
return normalized;
|
|
3032
|
-
}
|
|
3033
|
-
//#endregion
|
|
3034
3846
|
//#region builder/extract/scope.ts
|
|
3035
3847
|
function createExtractedScope(items) {
|
|
3036
3848
|
const scope = ((slot) => {
|
|
@@ -3041,6 +3853,15 @@ function createExtractedScope(items) {
|
|
|
3041
3853
|
return scope;
|
|
3042
3854
|
}
|
|
3043
3855
|
//#endregion
|
|
3856
|
+
//#region builder/extract/sheet.ts
|
|
3857
|
+
function createExtractedSheet(items) {
|
|
3858
|
+
const data = createExtractedData(9);
|
|
3859
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3860
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3861
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3862
|
+
return data;
|
|
3863
|
+
}
|
|
3864
|
+
//#endregion
|
|
3044
3865
|
//#region builder/extract/slot.ts
|
|
3045
3866
|
function createExtractedSlot(slotId, items) {
|
|
3046
3867
|
const slot = ((items) => {
|
|
@@ -3111,18 +3932,15 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
3111
3932
|
while (i < source.length) {
|
|
3112
3933
|
target.push(source[i]);
|
|
3113
3934
|
i++;
|
|
3114
|
-
}
|
|
3115
|
-
}
|
|
3116
|
-
//#endregion
|
|
3117
|
-
//#region style/value.ts
|
|
3118
|
-
function createToken(value, debugId) {
|
|
3119
|
-
return createStyleToken(value, debugId);
|
|
3935
|
+
}
|
|
3120
3936
|
}
|
|
3121
3937
|
//#endregion
|
|
3122
3938
|
//#region dialect/namedTokens.ts
|
|
3123
3939
|
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
3124
3940
|
function createNamedToken(id, value) {
|
|
3125
|
-
|
|
3941
|
+
const token = createStyleToken(value, createNamedTokenId(id));
|
|
3942
|
+
token[TOKEN_VAR_NAME] = getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3943
|
+
return token;
|
|
3126
3944
|
}
|
|
3127
3945
|
function createNamedTokens(namespace, values) {
|
|
3128
3946
|
return createNamedTokenProxy({
|
|
@@ -3141,7 +3959,7 @@ function createNamedTokenProxy(root, path) {
|
|
|
3141
3959
|
if (property === ROOT) return root;
|
|
3142
3960
|
if (property === "then") return void 0;
|
|
3143
3961
|
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
3144
|
-
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3962
|
+
if (property === TOKEN_ID || property === TOKEN_NAME || property === TOKEN_VAR_NAME || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3145
3963
|
if (!path.length) return void 0;
|
|
3146
3964
|
return getNamedTokenAtPath(root, path)[property];
|
|
3147
3965
|
}
|
|
@@ -3187,7 +4005,7 @@ function exposeStyleObject(source) {
|
|
|
3187
4005
|
return result;
|
|
3188
4006
|
}
|
|
3189
4007
|
function exposeStyleValue(value) {
|
|
3190
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
4008
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3191
4009
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3192
4010
|
const exposed = exposeStyleObject(value);
|
|
3193
4011
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3401,6 +4219,12 @@ function evaluateCall(node, scope) {
|
|
|
3401
4219
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3402
4220
|
return evalOk(createExtractedStyle(items.value));
|
|
3403
4221
|
}
|
|
4222
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4223
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4224
|
+
if (!items.ok) return items;
|
|
4225
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4226
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4227
|
+
}
|
|
3404
4228
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3405
4229
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3406
4230
|
if (!style.ok) return style;
|
|
@@ -3432,9 +4256,9 @@ function evaluateCall(node, scope) {
|
|
|
3432
4256
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createToken") {
|
|
3433
4257
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3434
4258
|
if (!value.ok) return value;
|
|
3435
|
-
const
|
|
3436
|
-
if (!
|
|
3437
|
-
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node,
|
|
4259
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
4260
|
+
if (!stableId.ok) return stableId;
|
|
4261
|
+
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3438
4262
|
}
|
|
3439
4263
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createKeyframes") {
|
|
3440
4264
|
const frames = evaluateNode(node.arguments[0], scope);
|
|
@@ -3501,16 +4325,16 @@ function evaluateCall(node, scope) {
|
|
|
3501
4325
|
const url = evaluateNode(node.arguments[0], scope);
|
|
3502
4326
|
if (!url.ok) return evalFail(`fontSrc url must be statically analyzable: ${url.reason}`);
|
|
3503
4327
|
if (typeof url.value !== "string") return evalFail("fontSrc url must be a static string");
|
|
3504
|
-
const format =
|
|
4328
|
+
const format = evaluateOptionalString(node.arguments[1], scope);
|
|
3505
4329
|
if (!format.ok) return evalFail(`fontSrc format must be statically analyzable: ${format.reason}`);
|
|
3506
4330
|
return evalOk(fontSrc(url.value, format.value));
|
|
3507
4331
|
}
|
|
3508
4332
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createTokens") {
|
|
3509
4333
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3510
4334
|
if (!value.ok) return value;
|
|
3511
|
-
const
|
|
3512
|
-
if (!
|
|
3513
|
-
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node,
|
|
4335
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
4336
|
+
if (!stableId.ok) return stableId;
|
|
4337
|
+
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3514
4338
|
}
|
|
3515
4339
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3516
4340
|
const id = evaluateNode(node.arguments[0], scope);
|
|
@@ -3538,13 +4362,13 @@ function evaluateCall(node, scope) {
|
|
|
3538
4362
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createValues") {
|
|
3539
4363
|
const hasNumberArg = node.arguments[0]?.type === "Identifier" && node.arguments[0].name === "Number";
|
|
3540
4364
|
const valuesNode = hasNumberArg ? node.arguments[1] : node.arguments[0];
|
|
3541
|
-
const
|
|
4365
|
+
const stableIdNode = hasNumberArg ? node.arguments[2] : node.arguments[1];
|
|
3542
4366
|
const values = evaluateNode(valuesNode, scope);
|
|
3543
4367
|
if (!values.ok) return values;
|
|
3544
|
-
const
|
|
3545
|
-
if (!
|
|
4368
|
+
const stableId = evaluateOptionalStableTokenId(stableIdNode, scope);
|
|
4369
|
+
if (!stableId.ok) return stableId;
|
|
3546
4370
|
if (!Array.isArray(values.value)) return evalFail("createValues values must be an array");
|
|
3547
|
-
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node,
|
|
4371
|
+
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node, stableId.value, hasNumberArg));
|
|
3548
4372
|
}
|
|
3549
4373
|
}
|
|
3550
4374
|
if (node.callee.type === "Identifier") {
|
|
@@ -3589,13 +4413,18 @@ function evaluateCall(node, scope) {
|
|
|
3589
4413
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3590
4414
|
}));
|
|
3591
4415
|
}
|
|
3592
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4416
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
3593
4417
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3594
4418
|
if (!value.ok) return value;
|
|
3595
4419
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3596
4420
|
if (!weight.ok) return weight;
|
|
3597
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3598
|
-
return evalOk(
|
|
4421
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4422
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4423
|
+
}
|
|
4424
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "important" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
4425
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4426
|
+
if (!value.ok) return value;
|
|
4427
|
+
return evalOk(importantValue(value.value));
|
|
3599
4428
|
}
|
|
3600
4429
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
3601
4430
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3632,38 +4461,48 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
|
|
|
3632
4461
|
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
3633
4462
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3634
4463
|
[TOKEN_OVERRIDE]: true,
|
|
4464
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3635
4465
|
value: value.value,
|
|
3636
4466
|
ref: value
|
|
3637
4467
|
});
|
|
3638
4468
|
return withRuntimeValue(runtimeValue, {
|
|
3639
4469
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3640
4470
|
[TOKEN_OVERRIDE]: true,
|
|
4471
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3641
4472
|
value,
|
|
3642
4473
|
ref: null
|
|
3643
4474
|
});
|
|
3644
4475
|
}
|
|
3645
|
-
function createCompiledToken(value, scope, loc, runtimeValue,
|
|
3646
|
-
let tokenId =
|
|
4476
|
+
function createCompiledToken(value, scope, loc, runtimeValue, stableId, debugName) {
|
|
4477
|
+
let tokenId = stableId;
|
|
3647
4478
|
if (!tokenId) tokenId = hashString((scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value)));
|
|
4479
|
+
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
4480
|
+
[TOKEN_ID]: tokenId,
|
|
4481
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
4482
|
+
value: value.value,
|
|
4483
|
+
ref: value
|
|
4484
|
+
});
|
|
3648
4485
|
return withRuntimeValue(runtimeValue, {
|
|
3649
4486
|
[TOKEN_ID]: tokenId,
|
|
4487
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
3650
4488
|
value,
|
|
3651
4489
|
ref: null
|
|
3652
4490
|
});
|
|
3653
4491
|
}
|
|
3654
|
-
function createCompiledTokens(value, scope, loc, runtimeValue,
|
|
3655
|
-
const tokenGroupId =
|
|
4492
|
+
function createCompiledTokens(value, scope, loc, runtimeValue, stableId) {
|
|
4493
|
+
const tokenGroupId = stableId ?? createCompiledTokenGroupId(scope, loc);
|
|
4494
|
+
const tokenGroupName = getStyleTokenNameFromId(stableId);
|
|
3656
4495
|
if (Array.isArray(value)) {
|
|
3657
4496
|
const result = {};
|
|
3658
4497
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
3659
4498
|
const item = value[i];
|
|
3660
|
-
result[item] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
4499
|
+
result[item] = createCompiledToken(item, scope, loc, runtimeValue, getChildStableId(tokenGroupId, String(i)), getChildStyleTokenName(tokenGroupName, String(i)));
|
|
3661
4500
|
}
|
|
3662
4501
|
return result;
|
|
3663
4502
|
}
|
|
3664
4503
|
if (!value || typeof value !== "object") return {};
|
|
3665
4504
|
const result = {};
|
|
3666
|
-
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId);
|
|
4505
|
+
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId, tokenGroupName);
|
|
3667
4506
|
return result;
|
|
3668
4507
|
}
|
|
3669
4508
|
function createCompiledTokenGroupId(scope, loc) {
|
|
@@ -3675,22 +4514,24 @@ function createCompiledAtRuleStableId(scope, loc, value) {
|
|
|
3675
4514
|
id: (scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value))
|
|
3676
4515
|
};
|
|
3677
4516
|
}
|
|
3678
|
-
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue,
|
|
4517
|
+
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, stableId, debugName) {
|
|
3679
4518
|
for (const key of Object.keys(value)) {
|
|
3680
4519
|
const item = value[key];
|
|
3681
|
-
const
|
|
4520
|
+
const itemStableId = getChildStableId(stableId, key);
|
|
4521
|
+
const itemDebugName = getChildStyleTokenName(debugName, key);
|
|
3682
4522
|
if (item && typeof item === "object" && !Array.isArray(item) && !isStyleTokenData(item)) {
|
|
3683
4523
|
const child = {};
|
|
3684
4524
|
target[key] = child;
|
|
3685
|
-
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue,
|
|
3686
|
-
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
4525
|
+
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
4526
|
+
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
3687
4527
|
}
|
|
3688
4528
|
}
|
|
3689
|
-
function createCompiledValues(values, scope, loc, runtimeValue,
|
|
4529
|
+
function createCompiledValues(values, scope, loc, runtimeValue, stableId, isNumber) {
|
|
3690
4530
|
const tokens = /* @__PURE__ */ new Map();
|
|
4531
|
+
const groupName = getStyleTokenNameFromId(stableId);
|
|
3691
4532
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
3692
4533
|
const value = values[i];
|
|
3693
|
-
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue,
|
|
4534
|
+
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue, getChildStableId(stableId, hashString(String(value))), getChildStyleTokenName(groupName, getValueDebugName(value))));
|
|
3694
4535
|
}
|
|
3695
4536
|
return {
|
|
3696
4537
|
[COMPILED_TOKEN_FACTORY]: true,
|
|
@@ -3708,7 +4549,10 @@ function parseCompiledValue(value, isNumber) {
|
|
|
3708
4549
|
function isCompiledTokenFactory(value) {
|
|
3709
4550
|
return !!value && typeof value === "object" && value[COMPILED_TOKEN_FACTORY] === true;
|
|
3710
4551
|
}
|
|
3711
|
-
function
|
|
4552
|
+
function evaluateOptionalStableTokenId(node, scope) {
|
|
4553
|
+
return evaluateOptionalString(node, scope);
|
|
4554
|
+
}
|
|
4555
|
+
function evaluateOptionalString(node, scope) {
|
|
3712
4556
|
if (!node) return evalOk(void 0);
|
|
3713
4557
|
const value = evaluateNode(node, scope);
|
|
3714
4558
|
if (!value.ok) return value;
|
|
@@ -3732,12 +4576,24 @@ function evaluateOptionalStableId(node, scope) {
|
|
|
3732
4576
|
id: stableId.id
|
|
3733
4577
|
});
|
|
3734
4578
|
}
|
|
3735
|
-
function
|
|
3736
|
-
return
|
|
4579
|
+
function getChildStableId(stableId, child) {
|
|
4580
|
+
return stableId ? stableId + "--" + child : void 0;
|
|
4581
|
+
}
|
|
4582
|
+
function getValueDebugName(value) {
|
|
4583
|
+
if (typeof value === "number") return String(value);
|
|
4584
|
+
if (typeof value !== "string") return null;
|
|
4585
|
+
const parts = value.split(/[;|]/);
|
|
4586
|
+
const label = parts[1]?.trim();
|
|
4587
|
+
if (label) return sanitizeTokenDebugName(label);
|
|
4588
|
+
return sanitizeTokenDebugName(parts[0]?.trim() ?? "");
|
|
4589
|
+
}
|
|
4590
|
+
function sanitizeTokenDebugName(value) {
|
|
4591
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || null;
|
|
3737
4592
|
}
|
|
3738
4593
|
function withRuntimeValue(runtimeValue, token) {
|
|
3739
4594
|
return Object.assign({}, token, {
|
|
3740
4595
|
[TOKEN_ID]: token[TOKEN_ID],
|
|
4596
|
+
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
3741
4597
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3742
4598
|
});
|
|
3743
4599
|
}
|
|
@@ -3773,14 +4629,14 @@ function evaluateUnary(node, scope) {
|
|
|
3773
4629
|
function isStaticStyleValue(value) {
|
|
3774
4630
|
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3775
4631
|
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3776
|
-
if (value.type === "
|
|
3777
|
-
const [priority, itemValue] = value.elements;
|
|
3778
|
-
return !!priority && priority.type === "NumericLiteral" && !!itemValue && isStaticStyleValue(itemValue);
|
|
3779
|
-
}
|
|
3780
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "value") {
|
|
4632
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
3781
4633
|
const [itemValue, weight] = value.arguments;
|
|
3782
4634
|
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
3783
4635
|
}
|
|
4636
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4637
|
+
const [itemValue] = value.arguments;
|
|
4638
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4639
|
+
}
|
|
3784
4640
|
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3785
4641
|
return false;
|
|
3786
4642
|
}
|
|
@@ -3795,20 +4651,6 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3795
4651
|
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3796
4652
|
return false;
|
|
3797
4653
|
}
|
|
3798
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3799
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3800
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3801
|
-
}
|
|
3802
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3803
|
-
const declarations = [];
|
|
3804
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3805
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3806
|
-
}
|
|
3807
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3808
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3809
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3810
|
-
return name + ":" + value;
|
|
3811
|
-
}
|
|
3812
4654
|
//#endregion
|
|
3813
4655
|
//#region compiler/transform/syntax/utils.ts
|
|
3814
4656
|
function getCallLabel(callee) {
|
|
@@ -3943,60 +4785,6 @@ function sanitizeTokenId(value) {
|
|
|
3943
4785
|
return sanitizeCssIdentName(value, "token");
|
|
3944
4786
|
}
|
|
3945
4787
|
//#endregion
|
|
3946
|
-
//#region compiler/transform/utils/babel.ts
|
|
3947
|
-
function babelPlugin(factory) {
|
|
3948
|
-
return factory;
|
|
3949
|
-
}
|
|
3950
|
-
function babelTransform(args) {
|
|
3951
|
-
let result = null;
|
|
3952
|
-
try {
|
|
3953
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
3954
|
-
result = _babel_core.transformSync(args.code, {
|
|
3955
|
-
...babelTransformOptions(),
|
|
3956
|
-
inputSourceMap,
|
|
3957
|
-
filename: args.filePath,
|
|
3958
|
-
sourceFileName: args.filePath,
|
|
3959
|
-
plugins: args.plugins,
|
|
3960
|
-
sourceMaps: true,
|
|
3961
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
3962
|
-
});
|
|
3963
|
-
} catch (err) {
|
|
3964
|
-
if (!args.errorLabel) throw err;
|
|
3965
|
-
const message = getBabelError(err, args);
|
|
3966
|
-
const error = new Error(message);
|
|
3967
|
-
error.stack = void 0;
|
|
3968
|
-
throw error;
|
|
3969
|
-
}
|
|
3970
|
-
if (!result || !result.code) return null;
|
|
3971
|
-
return {
|
|
3972
|
-
code: result.code,
|
|
3973
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
3974
|
-
};
|
|
3975
|
-
}
|
|
3976
|
-
function babelTransformOptions() {
|
|
3977
|
-
return {
|
|
3978
|
-
configFile: false,
|
|
3979
|
-
babelrc: false,
|
|
3980
|
-
parserOpts: {
|
|
3981
|
-
plugins: ["typescript", "jsx"],
|
|
3982
|
-
strictMode: false,
|
|
3983
|
-
allowImportExportEverywhere: true
|
|
3984
|
-
}
|
|
3985
|
-
};
|
|
3986
|
-
}
|
|
3987
|
-
function parseInputSourceMap(sourcemap) {
|
|
3988
|
-
if (!sourcemap) return void 0;
|
|
3989
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
3990
|
-
return JSON.parse(sourcemap);
|
|
3991
|
-
}
|
|
3992
|
-
function getBabelError(err, args) {
|
|
3993
|
-
const babelErr = err;
|
|
3994
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
3995
|
-
const codeFrame = babelErr?.codeFrame;
|
|
3996
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
3997
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
3998
|
-
}
|
|
3999
|
-
//#endregion
|
|
4000
4788
|
//#region compiler/transform/utils/path.ts
|
|
4001
4789
|
function getProjectFileId$1(projectDir, filePath) {
|
|
4002
4790
|
if (!filePath) return "unknown";
|
|
@@ -4506,14 +5294,16 @@ function getSelectorMethodPath(path) {
|
|
|
4506
5294
|
function getDebugStyleArg(t, path, state, sourcemapTrace) {
|
|
4507
5295
|
const arg = getStyleObjectArg(path, state);
|
|
4508
5296
|
if (!arg) return arg;
|
|
5297
|
+
const meta = getStyleCallMeta(path, state);
|
|
4509
5298
|
if (arg.type !== "ObjectExpression") return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
4510
|
-
return flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set());
|
|
5299
|
+
return appendTransformDebugFieldAliases(t, flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set()), meta, state);
|
|
4511
5300
|
}
|
|
4512
5301
|
function getDebugCallLoc(path, state) {
|
|
4513
5302
|
return isSelectorStyleCall(path, state) || isScopeItemSelectorCall(path, state) ? getMergeStyleLoc(path.node.callee) : null;
|
|
4514
5303
|
}
|
|
4515
5304
|
function getStyleObjectArg(path, state) {
|
|
4516
5305
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5306
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4517
5307
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4518
5308
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4519
5309
|
if (!selector) return path.node.arguments[0];
|
|
@@ -4521,6 +5311,10 @@ function getStyleObjectArg(path, state) {
|
|
|
4521
5311
|
const styleArgIndex = selectorArgIndex === null ? 0 : selectorArgIndex + 1;
|
|
4522
5312
|
return path.node.arguments[styleArgIndex];
|
|
4523
5313
|
}
|
|
5314
|
+
function getStyleCallMeta(path, state) {
|
|
5315
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
5316
|
+
return rootName ? state.styleMetas.get(rootName) ?? null : null;
|
|
5317
|
+
}
|
|
4524
5318
|
function isSelectorStyleCall(path, state) {
|
|
4525
5319
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
4526
5320
|
if (!methodName) return false;
|
|
@@ -4625,6 +5419,46 @@ function flattenDebugObjectExpression(t, node, path, state, sourcemapTrace, seen
|
|
|
4625
5419
|
}
|
|
4626
5420
|
return t.objectExpression(properties);
|
|
4627
5421
|
}
|
|
5422
|
+
function appendTransformDebugFieldAliases(t, node, meta, state) {
|
|
5423
|
+
if (!meta || meta.mode !== "StyleObject" || !meta.transform) return node;
|
|
5424
|
+
const existing = /* @__PURE__ */ new Set();
|
|
5425
|
+
for (const property of node.properties) {
|
|
5426
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
5427
|
+
const key = getObjectPropertyKey$1(property);
|
|
5428
|
+
if (key) existing.add(key);
|
|
5429
|
+
}
|
|
5430
|
+
const aliases = [];
|
|
5431
|
+
for (const property of node.properties) {
|
|
5432
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
5433
|
+
const key = getObjectPropertyKey$1(property);
|
|
5434
|
+
if (!key) continue;
|
|
5435
|
+
const value = evaluateNode(property.value, getDebugEvalScope(state));
|
|
5436
|
+
if (!value.ok) continue;
|
|
5437
|
+
let transformed;
|
|
5438
|
+
try {
|
|
5439
|
+
transformed = meta.transform.transform({ [key]: value.value });
|
|
5440
|
+
} catch {
|
|
5441
|
+
continue;
|
|
5442
|
+
}
|
|
5443
|
+
for (const transformedKey of Object.keys(transformed)) {
|
|
5444
|
+
if (existing.has(transformedKey)) continue;
|
|
5445
|
+
existing.add(transformedKey);
|
|
5446
|
+
aliases.push(createDebugFieldAlias(t, transformedKey, property));
|
|
5447
|
+
}
|
|
5448
|
+
}
|
|
5449
|
+
if (!aliases.length) return node;
|
|
5450
|
+
return t.objectExpression([...node.properties, ...aliases]);
|
|
5451
|
+
}
|
|
5452
|
+
function createDebugFieldAlias(t, key, source) {
|
|
5453
|
+
const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral());
|
|
5454
|
+
const sourceTrace = source;
|
|
5455
|
+
alias.loc = source.loc;
|
|
5456
|
+
alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
|
|
5457
|
+
alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
|
|
5458
|
+
alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
|
|
5459
|
+
alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
|
|
5460
|
+
return alias;
|
|
5461
|
+
}
|
|
4628
5462
|
function resolveDebugSpreadObject(t, spread, path, state, sourcemapTrace, seen) {
|
|
4629
5463
|
const node = spread.argument;
|
|
4630
5464
|
if (node.type !== "Identifier") return null;
|
|
@@ -4894,7 +5728,7 @@ function transformDebug(internal, args, deps) {
|
|
|
4894
5728
|
code: args.code,
|
|
4895
5729
|
filePath: args.filePath,
|
|
4896
5730
|
sourcemap: args.sourcemap,
|
|
4897
|
-
plugins: [plugin],
|
|
5731
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
4898
5732
|
retainLines: true
|
|
4899
5733
|
});
|
|
4900
5734
|
if (!result) return null;
|
|
@@ -4963,59 +5797,9 @@ function resolveFilePath(source, fromFile) {
|
|
|
4963
5797
|
}
|
|
4964
5798
|
}
|
|
4965
5799
|
//#endregion
|
|
4966
|
-
//#region atomic/rule.ts
|
|
4967
|
-
function buildAtomicRule(className, property, value, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
4968
|
-
const cssProp = getCssPropertyName(property);
|
|
4969
|
-
const cssValue = getCssPropertyValue(property, value);
|
|
4970
|
-
const classSelector = "." + escapeCssIdent(className);
|
|
4971
|
-
const itemSelector = selector ? getSelectorText(selector) : "";
|
|
4972
|
-
let selectorStr = classSelector + itemSelector;
|
|
4973
|
-
if (parentSelector) {
|
|
4974
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
4975
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
4976
|
-
}
|
|
4977
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
4978
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
4979
|
-
return rule;
|
|
4980
|
-
}
|
|
4981
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
4982
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
4983
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
4984
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
4985
|
-
return [
|
|
4986
|
-
priority ?? 0,
|
|
4987
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
4988
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
4989
|
-
getMediaPriority(atRules, atRulePriority),
|
|
4990
|
-
atRules ? atRules.length : 0,
|
|
4991
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
4992
|
-
getPropertyPriority(property)
|
|
4993
|
-
];
|
|
4994
|
-
}
|
|
4995
|
-
function getMediaPriority(atRules, priority) {
|
|
4996
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
4997
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
4998
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
4999
|
-
}
|
|
5000
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
5001
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
5002
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
5003
|
-
return LayerSelectorPriorities.base;
|
|
5004
|
-
}
|
|
5005
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
5006
|
-
if (!parentSelector) return 0;
|
|
5007
|
-
return priority > 0 ? priority + 1 : 1;
|
|
5008
|
-
}
|
|
5009
|
-
function getAtRulePriority$1(atRules) {
|
|
5010
|
-
if (!atRules?.length) return 0;
|
|
5011
|
-
let priority = 0;
|
|
5012
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
5013
|
-
return priority;
|
|
5014
|
-
}
|
|
5015
|
-
//#endregion
|
|
5016
5800
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
5017
5801
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
5018
|
-
function extractStyleChain(node, styleNames) {
|
|
5802
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5019
5803
|
if (node.type !== "CallExpression") return null;
|
|
5020
5804
|
const callee = node.callee;
|
|
5021
5805
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -5024,6 +5808,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
5024
5808
|
baseArgs: node.arguments,
|
|
5025
5809
|
methods: []
|
|
5026
5810
|
};
|
|
5811
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5812
|
+
kind: "sheet",
|
|
5813
|
+
rootName: callee.name,
|
|
5814
|
+
baseArgs: node.arguments,
|
|
5815
|
+
methods: []
|
|
5816
|
+
};
|
|
5027
5817
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5028
5818
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
5029
5819
|
if (!prop) return null;
|
|
@@ -5041,10 +5831,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
5041
5831
|
baseArgs: node.arguments,
|
|
5042
5832
|
methods: []
|
|
5043
5833
|
};
|
|
5834
|
+
if (prop === "selector") return {
|
|
5835
|
+
kind: "selector",
|
|
5836
|
+
rootName: obj.name,
|
|
5837
|
+
baseArgs: node.arguments,
|
|
5838
|
+
methods: []
|
|
5839
|
+
};
|
|
5044
5840
|
if (prop !== "merge") return null;
|
|
5045
5841
|
const target = node.arguments[0];
|
|
5046
5842
|
if (!target) return null;
|
|
5047
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5843
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
5048
5844
|
if (!targetChain) return null;
|
|
5049
5845
|
return {
|
|
5050
5846
|
...targetChain,
|
|
@@ -5056,7 +5852,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
5056
5852
|
};
|
|
5057
5853
|
}
|
|
5058
5854
|
if (obj.type === "CallExpression") {
|
|
5059
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5855
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
5060
5856
|
if (!inner) return null;
|
|
5061
5857
|
return {
|
|
5062
5858
|
...inner,
|
|
@@ -5080,18 +5876,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
5080
5876
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5081
5877
|
let result = null;
|
|
5082
5878
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5083
|
-
const
|
|
5879
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5880
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
5084
5881
|
if (!runtimeValue) continue;
|
|
5085
5882
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5086
5883
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5087
5884
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
5088
|
-
|
|
5885
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5886
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
5089
5887
|
}
|
|
5090
5888
|
return result ?? styleObj;
|
|
5091
5889
|
}
|
|
5092
|
-
function getPriorityTupleValue(value) {
|
|
5093
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5094
|
-
}
|
|
5095
5890
|
function cloneCompiledStyleObject(styleObj) {
|
|
5096
5891
|
const cloned = { ...styleObj };
|
|
5097
5892
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5174,6 +5969,8 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5174
5969
|
*/
|
|
5175
5970
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5176
5971
|
const css = getCssConfig(opts, runtimeMode);
|
|
5972
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5973
|
+
if (!meta) return null;
|
|
5177
5974
|
if (meta.mode === "ClassName") {
|
|
5178
5975
|
if (chain.kind !== "style") return null;
|
|
5179
5976
|
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
@@ -5185,11 +5982,91 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5185
5982
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5186
5983
|
return null;
|
|
5187
5984
|
}
|
|
5985
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5986
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5987
|
+
const items = [];
|
|
5988
|
+
const rules = [];
|
|
5989
|
+
const sheetItems = chain.baseArgs[0];
|
|
5990
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5991
|
+
return {
|
|
5992
|
+
type: "sheet",
|
|
5993
|
+
items,
|
|
5994
|
+
rules
|
|
5995
|
+
};
|
|
5996
|
+
}
|
|
5997
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5998
|
+
if (node.type === "ArrayExpression") {
|
|
5999
|
+
for (const element of node.elements) {
|
|
6000
|
+
if (!element) continue;
|
|
6001
|
+
if (element.type === "SpreadElement") return false;
|
|
6002
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
6003
|
+
}
|
|
6004
|
+
return true;
|
|
6005
|
+
}
|
|
6006
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
6007
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
6008
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
6009
|
+
return true;
|
|
6010
|
+
}
|
|
6011
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
6012
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
6013
|
+
const item = tokenOverride.value[i];
|
|
6014
|
+
if (!item) continue;
|
|
6015
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
6016
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
6017
|
+
}
|
|
6018
|
+
return true;
|
|
6019
|
+
}
|
|
6020
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
6021
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
6022
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
6023
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
6024
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
6025
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
6026
|
+
}
|
|
6027
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
6028
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
6029
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
6030
|
+
if (!selectorArg.ok) return false;
|
|
6031
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
6032
|
+
for (let i = 0, len = manualSelectors.length; i < len; i++) if (!compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, manualSelectors[i])) return false;
|
|
6033
|
+
return true;
|
|
6034
|
+
}
|
|
6035
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
6036
|
+
if (chain.baseArgs[1]) {
|
|
6037
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
6038
|
+
}
|
|
6039
|
+
let i = 0;
|
|
6040
|
+
while (i < chain.methods.length) {
|
|
6041
|
+
const method = chain.methods[i];
|
|
6042
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
6043
|
+
i++;
|
|
6044
|
+
}
|
|
6045
|
+
return true;
|
|
6046
|
+
}
|
|
6047
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
6048
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
6049
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
6050
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6051
|
+
if (styleArgNode.type === "CallExpression") {
|
|
6052
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
6053
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
6054
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
6055
|
+
}
|
|
6056
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
6057
|
+
if (!styleArg.ok) {
|
|
6058
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
6059
|
+
return false;
|
|
6060
|
+
}
|
|
6061
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6062
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
6063
|
+
}
|
|
5188
6064
|
function getCssConfig(opts, runtimeMode) {
|
|
5189
6065
|
const css = opts.css;
|
|
5190
6066
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
5191
6067
|
return {
|
|
5192
6068
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
6069
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5193
6070
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5194
6071
|
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
5195
6072
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
@@ -5316,15 +6193,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5316
6193
|
result[property] = value;
|
|
5317
6194
|
continue;
|
|
5318
6195
|
}
|
|
5319
|
-
|
|
5320
|
-
const rawValue = value[1];
|
|
5321
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5322
|
-
continue;
|
|
5323
|
-
}
|
|
5324
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6196
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5325
6197
|
}
|
|
5326
6198
|
return result;
|
|
5327
6199
|
}
|
|
6200
|
+
function decorateClassNameValue(value, className) {
|
|
6201
|
+
if (isClassNameValue(value)) return value;
|
|
6202
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6203
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6204
|
+
return classNameValue(value, className);
|
|
6205
|
+
}
|
|
5328
6206
|
function isWeightedClassName(value) {
|
|
5329
6207
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5330
6208
|
}
|
|
@@ -5335,23 +6213,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5335
6213
|
weighted[property] = value;
|
|
5336
6214
|
continue;
|
|
5337
6215
|
}
|
|
5338
|
-
weighted[property] =
|
|
6216
|
+
weighted[property] = weightValue(value, weight);
|
|
5339
6217
|
}
|
|
5340
6218
|
return weighted;
|
|
5341
6219
|
}
|
|
5342
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6220
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5343
6221
|
if (chain.baseArgs.length > 0) {
|
|
5344
6222
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5345
6223
|
if (!styleArg.ok) {
|
|
5346
6224
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5347
6225
|
return false;
|
|
5348
6226
|
}
|
|
5349
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6227
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5350
6228
|
}
|
|
5351
6229
|
let i = 0;
|
|
5352
6230
|
while (i < chain.methods.length) {
|
|
5353
6231
|
const method = chain.methods[i];
|
|
5354
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6232
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5355
6233
|
i++;
|
|
5356
6234
|
}
|
|
5357
6235
|
return true;
|
|
@@ -5398,7 +6276,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5398
6276
|
rules
|
|
5399
6277
|
};
|
|
5400
6278
|
}
|
|
5401
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6279
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5402
6280
|
const selector = selectors[method.name];
|
|
5403
6281
|
if (!selector) return false;
|
|
5404
6282
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5671,10 +6549,10 @@ function getSlotIdFromValue(value) {
|
|
|
5671
6549
|
const slotId = value.slotId;
|
|
5672
6550
|
return typeof slotId === "string" ? slotId : null;
|
|
5673
6551
|
}
|
|
5674
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6552
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5675
6553
|
if (method.name === "$$style.merge") {
|
|
5676
6554
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5677
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6555
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5678
6556
|
}
|
|
5679
6557
|
const selector = selectors[method.name];
|
|
5680
6558
|
if (!selector) return false;
|
|
@@ -5682,42 +6560,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5682
6560
|
const selectorStr = selector.selector.trim();
|
|
5683
6561
|
if (selectorStr === "...") {
|
|
5684
6562
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5685
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6563
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5686
6564
|
}
|
|
5687
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5688
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6565
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6566
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5689
6567
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6568
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5690
6569
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5691
6570
|
if (!styleArg.ok) {
|
|
5692
6571
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5693
6572
|
return false;
|
|
5694
6573
|
}
|
|
5695
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6574
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5696
6575
|
}
|
|
5697
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6576
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5698
6577
|
if (!styleArgNode) return false;
|
|
5699
6578
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5700
6579
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5701
6580
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5702
|
-
if (
|
|
6581
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5703
6582
|
if (styleArgNode.type === "CallExpression") {
|
|
5704
6583
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5705
6584
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5706
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6585
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5707
6586
|
}
|
|
5708
6587
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5709
6588
|
if (!styleArg.ok) {
|
|
5710
6589
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5711
6590
|
return false;
|
|
5712
6591
|
}
|
|
5713
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5714
|
-
return addStyleDataItems(styleArg.value,
|
|
6592
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6593
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5715
6594
|
}
|
|
5716
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6595
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5717
6596
|
if (node.type !== "Identifier") return null;
|
|
5718
6597
|
const init = scope.bindingNodes?.get(node.name);
|
|
5719
6598
|
if (!init) return null;
|
|
5720
|
-
return extractStyleChain(init, styleNames);
|
|
6599
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6600
|
+
}
|
|
6601
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6602
|
+
const callee = node.callee;
|
|
6603
|
+
if (callee.type === "Identifier") {
|
|
6604
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6605
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6606
|
+
return {
|
|
6607
|
+
...target,
|
|
6608
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6611
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6612
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6613
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6614
|
+
...memberTarget,
|
|
6615
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6616
|
+
};
|
|
6617
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6618
|
+
if (!methodName) return null;
|
|
6619
|
+
const object = callee.object;
|
|
6620
|
+
const target = object.type === "Identifier" ? getLocalStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "MemberExpression" ? getLocalMemberStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "CallExpression" ? getLocalSelectorTargetChain(object, scope, styleNames, sheetNames) : null;
|
|
6621
|
+
if (target?.kind !== "selector") return null;
|
|
6622
|
+
return {
|
|
6623
|
+
...target,
|
|
6624
|
+
methods: [...target.methods, {
|
|
6625
|
+
name: methodName,
|
|
6626
|
+
args: node.arguments,
|
|
6627
|
+
nameNode: callee.property
|
|
6628
|
+
}]
|
|
6629
|
+
};
|
|
6630
|
+
}
|
|
6631
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6632
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6633
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6634
|
+
if (!propertyName) return null;
|
|
6635
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6636
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6637
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6638
|
+
const property = objectInit.properties[i];
|
|
6639
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6640
|
+
const key = property.key;
|
|
6641
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6642
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6643
|
+
}
|
|
6644
|
+
return null;
|
|
6645
|
+
}
|
|
6646
|
+
function isBareSelectorTargetChain(chain) {
|
|
6647
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5721
6648
|
}
|
|
5722
6649
|
function getLocalBindingNode(node, scope) {
|
|
5723
6650
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5745,7 +6672,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5745
6672
|
default: return false;
|
|
5746
6673
|
}
|
|
5747
6674
|
}
|
|
5748
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6675
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5749
6676
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5750
6677
|
const hasArg = selectorStr.includes("$$");
|
|
5751
6678
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5767,22 +6694,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5767
6694
|
if (styleArg.type === "CallExpression") {
|
|
5768
6695
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5769
6696
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5770
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6697
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5771
6698
|
const evaled = evaluateNode(styleArg, scope);
|
|
5772
6699
|
if (!evaled.ok) {
|
|
5773
6700
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5774
6701
|
return false;
|
|
5775
6702
|
}
|
|
5776
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6703
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5777
6704
|
}
|
|
5778
6705
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5779
6706
|
if (!styleResult.ok) {
|
|
5780
6707
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5781
6708
|
return false;
|
|
5782
6709
|
}
|
|
5783
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6710
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5784
6711
|
}
|
|
5785
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6712
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5786
6713
|
const selectorStr = selector.selector.trim();
|
|
5787
6714
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5788
6715
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5804,7 +6731,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5804
6731
|
while (i < selectorValues.length) {
|
|
5805
6732
|
const itemSelectorValue = selectorValues[i];
|
|
5806
6733
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5807
|
-
|
|
6734
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6735
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5808
6736
|
i++;
|
|
5809
6737
|
}
|
|
5810
6738
|
return true;
|
|
@@ -5873,6 +6801,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
5873
6801
|
dedupe: overrideItem.dedupe,
|
|
5874
6802
|
className: overrideItem.className,
|
|
5875
6803
|
property: overrideItem.property,
|
|
6804
|
+
weight: overrideItem.weight,
|
|
6805
|
+
important: overrideItem.important,
|
|
5876
6806
|
value: overrideItem.value,
|
|
5877
6807
|
variable: overrideItem.variable,
|
|
5878
6808
|
token: overrideItem.token,
|
|
@@ -5916,22 +6846,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
5916
6846
|
items.push(item);
|
|
5917
6847
|
}
|
|
5918
6848
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5919
|
-
|
|
6849
|
+
const weight = sourceItem.weight;
|
|
6850
|
+
let important = false;
|
|
5920
6851
|
let value = sourceItem.value;
|
|
5921
|
-
|
|
5922
|
-
priority = value[1];
|
|
5923
|
-
value = value[0];
|
|
5924
|
-
}
|
|
6852
|
+
important = sourceItem.important;
|
|
5925
6853
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
5926
6854
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
5927
6855
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5928
6856
|
const valueStr = String(value ?? "");
|
|
5929
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
5930
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6857
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6858
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
5931
6859
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5932
6860
|
items.push(item);
|
|
5933
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
5934
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6861
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6862
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
5935
6863
|
cssRules.push({
|
|
5936
6864
|
dedupe,
|
|
5937
6865
|
className,
|
|
@@ -5994,21 +6922,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
5994
6922
|
items.push(item);
|
|
5995
6923
|
}
|
|
5996
6924
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5997
|
-
|
|
6925
|
+
const weight = sourceItem.weight;
|
|
6926
|
+
const important = sourceItem.important;
|
|
5998
6927
|
let value = sourceItem.value;
|
|
5999
|
-
|
|
6000
|
-
priority = value[1];
|
|
6001
|
-
value = value[0];
|
|
6002
|
-
}
|
|
6003
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6928
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
6004
6929
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
6005
6930
|
const variable = sourceItem.variable;
|
|
6006
6931
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
6007
6932
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
6008
6933
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
6009
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6934
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
6010
6935
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
6011
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6936
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6012
6937
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6013
6938
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
6014
6939
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -6016,8 +6941,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6016
6941
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
6017
6942
|
}
|
|
6018
6943
|
items.push(item);
|
|
6019
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6020
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6944
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6945
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
6021
6946
|
cssRules.push({
|
|
6022
6947
|
dedupe,
|
|
6023
6948
|
className,
|
|
@@ -6030,6 +6955,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
6030
6955
|
} : void 0
|
|
6031
6956
|
});
|
|
6032
6957
|
}
|
|
6958
|
+
function combineSelectors(parent, child) {
|
|
6959
|
+
const parentText = getItemSelectorText(parent);
|
|
6960
|
+
const childText = getItemSelectorText(child);
|
|
6961
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6962
|
+
const selector = parentText + childText;
|
|
6963
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6964
|
+
}
|
|
6965
|
+
function getItemSelectorText(selector) {
|
|
6966
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6967
|
+
}
|
|
6968
|
+
function getItemSelectorPriority(selector) {
|
|
6969
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6970
|
+
}
|
|
6033
6971
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
6034
6972
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
6035
6973
|
if (!trace) return void 0;
|
|
@@ -6074,13 +7012,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6074
7012
|
while (i < keys.length) {
|
|
6075
7013
|
const property = keys[i];
|
|
6076
7014
|
const rawValue = styleObj[property];
|
|
6077
|
-
let
|
|
7015
|
+
let weight = null;
|
|
7016
|
+
let important = false;
|
|
6078
7017
|
let value = rawValue;
|
|
6079
7018
|
let transformClassName = null;
|
|
6080
|
-
|
|
6081
|
-
priority = rawValue[0];
|
|
6082
|
-
value = rawValue[1];
|
|
6083
|
-
}
|
|
7019
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
6084
7020
|
if (isClassNameValue(value)) {
|
|
6085
7021
|
transformClassName = value.className;
|
|
6086
7022
|
value = value.value;
|
|
@@ -6103,8 +7039,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6103
7039
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
6104
7040
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
6105
7041
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
6106
|
-
const dedupe = getClassNameDedupe(property,
|
|
6107
|
-
const className = getAtomicClassName(property,
|
|
7042
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
7043
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
6108
7044
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
6109
7045
|
item.sourceTrace = propertyCallsite ? {
|
|
6110
7046
|
property,
|
|
@@ -6129,8 +7065,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6129
7065
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6130
7066
|
}
|
|
6131
7067
|
items.push(item);
|
|
6132
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6133
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
7068
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
7069
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6134
7070
|
cssRules.push({
|
|
6135
7071
|
dedupe,
|
|
6136
7072
|
className,
|
|
@@ -6158,6 +7094,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6158
7094
|
}
|
|
6159
7095
|
return true;
|
|
6160
7096
|
}
|
|
7097
|
+
function unwrapStaticStyleValue(value) {
|
|
7098
|
+
let weight = null;
|
|
7099
|
+
let important = false;
|
|
7100
|
+
while (true) {
|
|
7101
|
+
if (isStyleImportantValue(value)) {
|
|
7102
|
+
important = true;
|
|
7103
|
+
value = value.value;
|
|
7104
|
+
continue;
|
|
7105
|
+
}
|
|
7106
|
+
if (isStyleWeightValue(value)) {
|
|
7107
|
+
weight = value.weight;
|
|
7108
|
+
value = value.value;
|
|
7109
|
+
continue;
|
|
7110
|
+
}
|
|
7111
|
+
break;
|
|
7112
|
+
}
|
|
7113
|
+
return [
|
|
7114
|
+
value,
|
|
7115
|
+
weight,
|
|
7116
|
+
important
|
|
7117
|
+
];
|
|
7118
|
+
}
|
|
6161
7119
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6162
7120
|
if (result.ok) return;
|
|
6163
7121
|
if (result.reason.includes("createCounterStyle") || result.reason.includes("createFontFace") || result.reason.includes("createFontPaletteValues") || result.reason.includes("createPositionTry") || result.reason.includes("createProperty") || result.reason.includes("fontSrc")) throw new Error(result.reason);
|
|
@@ -6293,6 +7251,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6293
7251
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6294
7252
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6295
7253
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7254
|
+
const staticIdState = {
|
|
7255
|
+
fileId,
|
|
7256
|
+
imports,
|
|
7257
|
+
styleNames
|
|
7258
|
+
};
|
|
7259
|
+
const t = babel.types;
|
|
6296
7260
|
for (const stmt of ast.program.body) {
|
|
6297
7261
|
if (stmt.type === "ImportDeclaration") {
|
|
6298
7262
|
const source = stmt.source.value;
|
|
@@ -6317,6 +7281,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6317
7281
|
continue;
|
|
6318
7282
|
}
|
|
6319
7283
|
if (stmt.type === "VariableDeclaration") {
|
|
7284
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6320
7285
|
collectVariableBindings(rawBindings, stmt);
|
|
6321
7286
|
continue;
|
|
6322
7287
|
}
|
|
@@ -6340,6 +7305,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6340
7305
|
continue;
|
|
6341
7306
|
}
|
|
6342
7307
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7308
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6343
7309
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6344
7310
|
continue;
|
|
6345
7311
|
}
|
|
@@ -6379,6 +7345,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6379
7345
|
});
|
|
6380
7346
|
return bindings;
|
|
6381
7347
|
}
|
|
7348
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7349
|
+
for (const decl of declaration.declarations) {
|
|
7350
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7351
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7352
|
+
}
|
|
7353
|
+
}
|
|
6382
7354
|
function collectVariableBindings(bindings, declaration) {
|
|
6383
7355
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6384
7356
|
}
|
|
@@ -6458,6 +7430,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6458
7430
|
defineCompiledStyleLocations(style, traceResult);
|
|
6459
7431
|
return style;
|
|
6460
7432
|
}
|
|
7433
|
+
if (result.type === "sheet") {
|
|
7434
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7435
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7436
|
+
return sheet;
|
|
7437
|
+
}
|
|
6461
7438
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6462
7439
|
return null;
|
|
6463
7440
|
}
|
|
@@ -6568,6 +7545,12 @@ function hashFileContent(filePath) {
|
|
|
6568
7545
|
function getStyleRuntimeImportPath(mode) {
|
|
6569
7546
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6570
7547
|
}
|
|
7548
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7549
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7550
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7551
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7552
|
+
return null;
|
|
7553
|
+
}
|
|
6571
7554
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6572
7555
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6573
7556
|
}
|
|
@@ -6660,6 +7643,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6660
7643
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6661
7644
|
return t.callExpression(t.identifier(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE), hasSpread ? buildStyleMergeArgs(t, chain, state, options) : [buildItemsArray(t, chain, 1, state, options)]);
|
|
6662
7645
|
}
|
|
7646
|
+
if (chain.type === "sheet") {
|
|
7647
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7648
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7649
|
+
}
|
|
6663
7650
|
if (chain.type === "slot") {
|
|
6664
7651
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6665
7652
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6698,7 +7685,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6698
7685
|
chain.items.forEach((item) => {
|
|
6699
7686
|
if (isCompiledTokenItem(item)) {
|
|
6700
7687
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6701
|
-
else itemExpressions.push(t
|
|
7688
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6702
7689
|
return;
|
|
6703
7690
|
}
|
|
6704
7691
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6788,11 +7775,26 @@ function buildVariableValueExpression(t, value, state, item, options) {
|
|
|
6788
7775
|
}
|
|
6789
7776
|
function buildExtractedTokenExpression(t, token, state) {
|
|
6790
7777
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7778
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
6791
7779
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
6792
7780
|
t.stringLiteral(getStyleTokenId(token)),
|
|
6793
7781
|
literalExpression(t, token.value),
|
|
6794
|
-
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral()
|
|
7782
|
+
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral(),
|
|
7783
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7784
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7785
|
+
]);
|
|
7786
|
+
}
|
|
7787
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7788
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7789
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7790
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7791
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7792
|
+
t.nullLiteral(),
|
|
7793
|
+
t.nullLiteral(),
|
|
7794
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7795
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6795
7796
|
]);
|
|
7797
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
6796
7798
|
}
|
|
6797
7799
|
function literalExpression(t, value) {
|
|
6798
7800
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
@@ -6915,6 +7917,7 @@ function getEvalScope(state) {
|
|
|
6915
7917
|
styleFilePath: state.styleFilePath,
|
|
6916
7918
|
sourcemapTrace: state.sourcemapTrace,
|
|
6917
7919
|
styleNames: state.styleNames,
|
|
7920
|
+
sheetNames: state.sheetNames,
|
|
6918
7921
|
styleMetas: state.styleMetas,
|
|
6919
7922
|
bindingNodes: state.bindingNodes,
|
|
6920
7923
|
runtimeMode: state.runtimeMode
|
|
@@ -6931,8 +7934,8 @@ function compileThemeCall(path, state, opts) {
|
|
|
6931
7934
|
const tokenArg = evaluateNode(path.node.arguments[0], scope);
|
|
6932
7935
|
if (!tokenArg.ok) throw path.buildCodeFrameError(`createTheme tokens must be statically analyzable: ${tokenArg.reason}`);
|
|
6933
7936
|
if (!Array.isArray(tokenArg.value)) throw path.buildCodeFrameError("createTheme first argument must be a static array of token overrides.");
|
|
6934
|
-
const
|
|
6935
|
-
if (path.node.arguments[1] && !
|
|
7937
|
+
const stableIdArg = evaluateNode(path.node.arguments[1], scope);
|
|
7938
|
+
if (path.node.arguments[1] && !stableIdArg.ok) throw path.buildCodeFrameError(`createTheme stableId must be statically analyzable: ${stableIdArg.reason}`);
|
|
6936
7939
|
const tokens = [];
|
|
6937
7940
|
for (let i = 0, len = tokenArg.value.length; i < len; i++) {
|
|
6938
7941
|
const token = tokenArg.value[i];
|
|
@@ -6940,7 +7943,7 @@ function compileThemeCall(path, state, opts) {
|
|
|
6940
7943
|
tokens.push(token);
|
|
6941
7944
|
}
|
|
6942
7945
|
const loc = path.node.loc?.start;
|
|
6943
|
-
const id =
|
|
7946
|
+
const id = stableIdArg.ok && stableIdArg.value !== void 0 ? String(stableIdArg.value) : getStableThemeId(state.fileId, loc ? loc.line + ":" + loc.column : "createTheme");
|
|
6944
7947
|
const themeNameFormat = opts.css?.themeNameFormat || CSS_CONFIG.themeNameFormat || null;
|
|
6945
7948
|
const className = getStableThemeClassName(id, themeNameFormat);
|
|
6946
7949
|
return {
|
|
@@ -6972,6 +7975,7 @@ function createExtractPlugin(args) {
|
|
|
6972
7975
|
return {
|
|
6973
7976
|
pre() {
|
|
6974
7977
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
7978
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
6975
7979
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
6976
7980
|
this.bindings = /* @__PURE__ */ new Map();
|
|
6977
7981
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -7018,6 +8022,7 @@ function createExtractPlugin(args) {
|
|
|
7018
8022
|
state.styleNames.add(spec.local.name);
|
|
7019
8023
|
state.styleMetas.set(spec.local.name, meta);
|
|
7020
8024
|
}
|
|
8025
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
7021
8026
|
});
|
|
7022
8027
|
},
|
|
7023
8028
|
VariableDeclaration(path, state) {
|
|
@@ -7064,17 +8069,17 @@ function createExtractPlugin(args) {
|
|
|
7064
8069
|
state.needsExtractImport = true;
|
|
7065
8070
|
return;
|
|
7066
8071
|
}
|
|
7067
|
-
if (!state.styleNames.size) return;
|
|
7068
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
8072
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
8073
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
7069
8074
|
if (!chain) return;
|
|
7070
8075
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
7071
8076
|
const scope = getEvalScope(state);
|
|
7072
8077
|
const loc = path.node.loc?.start;
|
|
7073
8078
|
const meta = state.styleMetas.get(chain.rootName);
|
|
7074
|
-
if (!meta) return;
|
|
8079
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
7075
8080
|
let result;
|
|
7076
8081
|
try {
|
|
7077
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
8082
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
7078
8083
|
} catch (error) {
|
|
7079
8084
|
const message = error instanceof Error ? error.message : String(error);
|
|
7080
8085
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7328,7 +8333,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7328
8333
|
code: args.code,
|
|
7329
8334
|
filePath: args.filePath,
|
|
7330
8335
|
sourcemap: args.sourcemap,
|
|
7331
|
-
plugins: [plugin],
|
|
8336
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7332
8337
|
errorLabel: "[style] compiler error"
|
|
7333
8338
|
});
|
|
7334
8339
|
if (!result) return null;
|
|
@@ -7449,11 +8454,33 @@ function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
|
7449
8454
|
}
|
|
7450
8455
|
function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
7451
8456
|
if (source === "@fluentic/style") return getStyleRuntimeImportPath(runtimeMode);
|
|
8457
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
|
|
8458
|
+
if (adapterImportPath) return adapterImportPath;
|
|
7452
8459
|
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(runtimeMode);
|
|
7453
8460
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7454
8461
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7455
8462
|
return null;
|
|
7456
8463
|
}
|
|
8464
|
+
const CssPropPresets = {
|
|
8465
|
+
Solid: {
|
|
8466
|
+
classProp: "class",
|
|
8467
|
+
styleProp: "style",
|
|
8468
|
+
styleMode: "solid",
|
|
8469
|
+
adapter: "@fluentic/style/adapter/solid"
|
|
8470
|
+
},
|
|
8471
|
+
Preact: {
|
|
8472
|
+
classProp: "class",
|
|
8473
|
+
styleProp: "style",
|
|
8474
|
+
styleMode: "react",
|
|
8475
|
+
adapter: "@fluentic/style/adapter/preact"
|
|
8476
|
+
},
|
|
8477
|
+
React: {
|
|
8478
|
+
classProp: "className",
|
|
8479
|
+
styleProp: "style",
|
|
8480
|
+
styleMode: "react",
|
|
8481
|
+
adapter: "@fluentic/style/adapter/react"
|
|
8482
|
+
}
|
|
8483
|
+
};
|
|
7457
8484
|
//#endregion
|
|
7458
8485
|
//#region plugin/utils/constants.ts
|
|
7459
8486
|
const PLUGIN_NAME = "fluentic-style";
|
|
@@ -7584,10 +8611,10 @@ function getStyleRuntimeMode(dev, rsc = false) {
|
|
|
7584
8611
|
if (rsc) return dev ? "rsc-dev" : "rsc-prod";
|
|
7585
8612
|
return dev ? "dev" : "prod";
|
|
7586
8613
|
}
|
|
7587
|
-
function getPluginBuildConfig(options) {
|
|
8614
|
+
function getPluginBuildConfig(options, dev = false) {
|
|
7588
8615
|
const css = hasBuildConfig(options.css) ? options.css : {};
|
|
7589
8616
|
return {
|
|
7590
|
-
hoist: options.hoist !== false,
|
|
8617
|
+
hoist: !dev && options.hoist !== false,
|
|
7591
8618
|
css
|
|
7592
8619
|
};
|
|
7593
8620
|
}
|
|
@@ -8020,6 +9047,12 @@ Object.defineProperty(exports, "CSS_MODULE_ID", {
|
|
|
8020
9047
|
return CSS_MODULE_ID;
|
|
8021
9048
|
}
|
|
8022
9049
|
});
|
|
9050
|
+
Object.defineProperty(exports, "CssPropPresets", {
|
|
9051
|
+
enumerable: true,
|
|
9052
|
+
get: function() {
|
|
9053
|
+
return CssPropPresets;
|
|
9054
|
+
}
|
|
9055
|
+
});
|
|
8023
9056
|
Object.defineProperty(exports, "DEFAULT_TRANSFORM_INCLUDE_PATTERN", {
|
|
8024
9057
|
enumerable: true,
|
|
8025
9058
|
get: function() {
|
|
@@ -8141,4 +9174,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
8141
9174
|
}
|
|
8142
9175
|
});
|
|
8143
9176
|
|
|
8144
|
-
//# sourceMappingURL=shared-
|
|
9177
|
+
//# sourceMappingURL=shared-8_Msr7Q5.cjs.map
|