@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
2
|
import * as fs$1 from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
|
+
import * as BabelCore from "@babel/core";
|
|
4
5
|
import picomatch from "picomatch";
|
|
5
6
|
import { SelectorType, parse } from "css-what";
|
|
6
|
-
import * as BabelCore from "@babel/core";
|
|
7
7
|
import { ResolverFactory } from "oxc-resolver";
|
|
8
8
|
//#region compiler/compiler/cache.ts
|
|
9
9
|
function createCompilerCache(args) {
|
|
@@ -97,10 +97,12 @@ function createCssCollector() {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
|
-
//#region utils/
|
|
100
|
+
//#region utils/symbol.ts
|
|
101
101
|
function symbol(name) {
|
|
102
102
|
return Symbol.for(`@fluentic/style.${name}`);
|
|
103
103
|
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region utils/global.ts
|
|
104
106
|
function globalData(key, data) {
|
|
105
107
|
const id = symbol(key);
|
|
106
108
|
const root = globalThis;
|
|
@@ -124,18 +126,6 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
124
126
|
};
|
|
125
127
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
126
128
|
//#endregion
|
|
127
|
-
//#region config/config/debug.ts
|
|
128
|
-
const DEFAULT_DEBUG_CONFIG = {
|
|
129
|
-
isDebugClassNameEnabled: false,
|
|
130
|
-
isDebugClassNameConfigured: false,
|
|
131
|
-
maxPropertyLength: 24,
|
|
132
|
-
maxValueLength: 8,
|
|
133
|
-
maxSelectorLength: 8,
|
|
134
|
-
maxParentSelectorLength: 8,
|
|
135
|
-
maxAtRuleLength: 10
|
|
136
|
-
};
|
|
137
|
-
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
138
|
-
//#endregion
|
|
139
129
|
//#region config/utils.ts
|
|
140
130
|
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
141
131
|
function getCacheTTL(cache) {
|
|
@@ -151,9 +141,21 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
151
141
|
isRSC: false,
|
|
152
142
|
runtimeCacheTTL: getCacheTTL(true)
|
|
153
143
|
};
|
|
154
|
-
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
144
|
+
const RUNTIME_CONFIG = globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
155
145
|
globalData("config.build", () => ({ current: null }));
|
|
156
146
|
//#endregion
|
|
147
|
+
//#region config/config/debug.ts
|
|
148
|
+
const DEFAULT_DEBUG_CONFIG = {
|
|
149
|
+
isDebugClassNameEnabled: false,
|
|
150
|
+
isDebugClassNameConfigured: false,
|
|
151
|
+
maxPropertyLength: 24,
|
|
152
|
+
maxValueLength: 8,
|
|
153
|
+
maxSelectorLength: 8,
|
|
154
|
+
maxParentSelectorLength: 8,
|
|
155
|
+
maxAtRuleLength: 10
|
|
156
|
+
};
|
|
157
|
+
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
158
|
+
//#endregion
|
|
157
159
|
//#region utils/hash.ts
|
|
158
160
|
function hashString(str) {
|
|
159
161
|
let hash = 2166136261;
|
|
@@ -172,8 +174,6 @@ function flattenCssLayers(layers, layerNames) {
|
|
|
172
174
|
const names = typeof layerNames === "string" ? [layerNames] : layerNames;
|
|
173
175
|
return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
|
|
174
176
|
}
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region atomic/layer/types.ts
|
|
177
177
|
const LayerDefaultPriority = [
|
|
178
178
|
0,
|
|
179
179
|
0,
|
|
@@ -243,6 +243,7 @@ const FN_CREATE_FONT_PALETTE_VALUES = "createFontPaletteValues";
|
|
|
243
243
|
const FN_CREATE_POSITION_TRY = "createPositionTry";
|
|
244
244
|
const FN_CREATE_COUNTER_STYLE = "createCounterStyle";
|
|
245
245
|
const FN_CREATE_EXTRACTED_STYLE = "createExtractedStyle";
|
|
246
|
+
const FN_CREATE_EXTRACTED_SHEET = "createExtractedSheet";
|
|
246
247
|
const FN_CREATE_EXTRACTED_SLOT = "createExtractedSlot";
|
|
247
248
|
const FN_CREATE_EXTRACTED_SCOPE = "createExtractedScope";
|
|
248
249
|
const FN_CREATE_EXTRACTED_TOKEN = "createExtractedToken";
|
|
@@ -271,6 +272,131 @@ function getExtractedCssItems(items, args) {
|
|
|
271
272
|
return getLayerBundleCss(args.layers ?? defaults.layers ?? [], layerNamespace, css.map((item) => item.css));
|
|
272
273
|
}
|
|
273
274
|
//#endregion
|
|
275
|
+
//#region compiler/transform/utils/babel.ts
|
|
276
|
+
function babelPlugin(factory) {
|
|
277
|
+
return factory;
|
|
278
|
+
}
|
|
279
|
+
function babelTransform(args) {
|
|
280
|
+
let result = null;
|
|
281
|
+
try {
|
|
282
|
+
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
283
|
+
result = BabelCore.transformSync(args.code, {
|
|
284
|
+
...babelTransformOptions(),
|
|
285
|
+
inputSourceMap,
|
|
286
|
+
filename: args.filePath,
|
|
287
|
+
sourceFileName: args.filePath,
|
|
288
|
+
plugins: args.plugins,
|
|
289
|
+
sourceMaps: true,
|
|
290
|
+
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
291
|
+
});
|
|
292
|
+
} catch (err) {
|
|
293
|
+
if (!args.errorLabel) throw err;
|
|
294
|
+
const message = getBabelError(err, args);
|
|
295
|
+
const error = new Error(message);
|
|
296
|
+
error.stack = void 0;
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
if (!result || !result.code) return null;
|
|
300
|
+
return {
|
|
301
|
+
code: result.code,
|
|
302
|
+
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function babelTransformOptions() {
|
|
306
|
+
return {
|
|
307
|
+
configFile: false,
|
|
308
|
+
babelrc: false,
|
|
309
|
+
parserOpts: {
|
|
310
|
+
plugins: ["typescript", "jsx"],
|
|
311
|
+
strictMode: false,
|
|
312
|
+
allowImportExportEverywhere: true
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function parseInputSourceMap(sourcemap) {
|
|
317
|
+
if (!sourcemap) return void 0;
|
|
318
|
+
if (typeof sourcemap !== "string") return sourcemap;
|
|
319
|
+
return JSON.parse(sourcemap);
|
|
320
|
+
}
|
|
321
|
+
function getBabelError(err, args) {
|
|
322
|
+
const babelErr = err;
|
|
323
|
+
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
324
|
+
const codeFrame = babelErr?.codeFrame;
|
|
325
|
+
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
326
|
+
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region compiler/transform/cssProp/plugin.ts
|
|
330
|
+
function createCssPropPlugin(args) {
|
|
331
|
+
return babelPlugin((babel) => {
|
|
332
|
+
const { types: t } = babel;
|
|
333
|
+
return {
|
|
334
|
+
pre() {
|
|
335
|
+
this.options = args.options;
|
|
336
|
+
this.mergeId = null;
|
|
337
|
+
this.programPath = null;
|
|
338
|
+
this.changed = false;
|
|
339
|
+
},
|
|
340
|
+
visitor: {
|
|
341
|
+
Program: {
|
|
342
|
+
enter(path, state) {
|
|
343
|
+
state.programPath = path;
|
|
344
|
+
state.mergeId = path.scope.generateUidIdentifier("fluenticMergeJsxProps");
|
|
345
|
+
},
|
|
346
|
+
exit(path, state) {
|
|
347
|
+
const options = getCssPropOptions(state.options);
|
|
348
|
+
if (!state.changed || !options || !state.mergeId) return;
|
|
349
|
+
path.unshiftContainer("body", t.importDeclaration([t.importSpecifier(state.mergeId, t.identifier("mergeJsxProps"))], t.stringLiteral(options.adapter)));
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
JSXOpeningElement(path, state) {
|
|
353
|
+
if (!getCssPropOptions(state.options) || !state.mergeId) return;
|
|
354
|
+
if (!isIntrinsicElement(path.node.name)) return;
|
|
355
|
+
if (!hasCssAttribute(path.node.attributes)) return;
|
|
356
|
+
const parts = path.node.attributes.map((attr) => buildPart(t, attr));
|
|
357
|
+
path.node.attributes = [t.jsxSpreadAttribute(t.callExpression(state.mergeId, [t.arrayExpression(parts)]))];
|
|
358
|
+
state.changed = true;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function getCssPropOptions(options) {
|
|
365
|
+
return options.cssProp || null;
|
|
366
|
+
}
|
|
367
|
+
function isIntrinsicElement(name) {
|
|
368
|
+
return name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
369
|
+
}
|
|
370
|
+
function hasCssAttribute(attrs) {
|
|
371
|
+
return attrs.some((attr) => {
|
|
372
|
+
return attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "css";
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function buildPart(t, attr) {
|
|
376
|
+
if (attr.type === "JSXSpreadAttribute") return attr.argument;
|
|
377
|
+
return t.objectExpression([t.objectProperty(getObjectKey(t, attr.name), getAttributeValue(t, attr))]);
|
|
378
|
+
}
|
|
379
|
+
function getObjectKey(t, name) {
|
|
380
|
+
if (name.type === "JSXIdentifier" && isValidIdentifierName(name.name)) return t.identifier(name.name);
|
|
381
|
+
return t.stringLiteral(getAttributeName(name));
|
|
382
|
+
}
|
|
383
|
+
function getAttributeName(name) {
|
|
384
|
+
if (name.type === "JSXIdentifier") return name.name;
|
|
385
|
+
return `${name.namespace.name}:${name.name.name}`;
|
|
386
|
+
}
|
|
387
|
+
function getAttributeValue(t, attr) {
|
|
388
|
+
if (!attr.value) return t.booleanLiteral(true);
|
|
389
|
+
if (attr.value.type === "StringLiteral") return t.stringLiteral(attr.value.value);
|
|
390
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
391
|
+
if (attr.value.expression.type === "JSXEmptyExpression") return t.booleanLiteral(true);
|
|
392
|
+
return attr.value.expression;
|
|
393
|
+
}
|
|
394
|
+
return attr.value;
|
|
395
|
+
}
|
|
396
|
+
function isValidIdentifierName(name) {
|
|
397
|
+
return /^[$A-Z_a-z][$\w]*$/.test(name);
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
274
400
|
//#region builder/data/const.ts
|
|
275
401
|
const BUILDER_TYPE = symbol("builder.type");
|
|
276
402
|
const BUILDER_STATE = symbol("builder.state");
|
|
@@ -278,8 +404,13 @@ const BUILDER_CALLSITE = symbol("builder.callsite");
|
|
|
278
404
|
const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
279
405
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
280
406
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
407
|
+
const BUILDER_SELECTOR = symbol("builder.selector");
|
|
408
|
+
const SHEET_SELECTOR_ANCHOR = "\0sheet";
|
|
281
409
|
//#endregion
|
|
282
410
|
//#region utils/object.ts
|
|
411
|
+
function hasOwn(target, field) {
|
|
412
|
+
return Object.prototype.hasOwnProperty.call(target, field);
|
|
413
|
+
}
|
|
283
414
|
function toArray(value) {
|
|
284
415
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
285
416
|
}
|
|
@@ -459,6 +590,15 @@ function createDebugCallsite(loc, debug) {
|
|
|
459
590
|
}
|
|
460
591
|
//#endregion
|
|
461
592
|
//#region builder/data/is.ts
|
|
593
|
+
function getSlotId(data) {
|
|
594
|
+
return data[BUILDER_SLOT_ID];
|
|
595
|
+
}
|
|
596
|
+
function getScopeTargetSlotId(data) {
|
|
597
|
+
return data[BUILDER_SCOPE_ID];
|
|
598
|
+
}
|
|
599
|
+
function getScopeTargetScope(data) {
|
|
600
|
+
return data[BUILDER_SCOPE];
|
|
601
|
+
}
|
|
462
602
|
function isStyleData(value) {
|
|
463
603
|
return getBuilderType(value) === 1;
|
|
464
604
|
}
|
|
@@ -468,9 +608,18 @@ function isSlotData(value) {
|
|
|
468
608
|
function isSlotOverrideData(value) {
|
|
469
609
|
return getBuilderType(value) === 3;
|
|
470
610
|
}
|
|
611
|
+
function isSelectorData(value) {
|
|
612
|
+
return getBuilderType(value) === 7;
|
|
613
|
+
}
|
|
614
|
+
function isSheetData(value) {
|
|
615
|
+
return getBuilderType(value) === 9;
|
|
616
|
+
}
|
|
471
617
|
function isScopeData(value) {
|
|
472
618
|
return getBuilderType(value) === 4;
|
|
473
619
|
}
|
|
620
|
+
function isThemeData(value) {
|
|
621
|
+
return getBuilderType(value) === 6;
|
|
622
|
+
}
|
|
474
623
|
function getBuilderType(value) {
|
|
475
624
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
476
625
|
return value[BUILDER_TYPE];
|
|
@@ -479,16 +628,70 @@ function normalizeSelectorArg(arg) {
|
|
|
479
628
|
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
480
629
|
}
|
|
481
630
|
//#endregion
|
|
482
|
-
//#region
|
|
631
|
+
//#region builder/token/symbols.ts
|
|
483
632
|
const TOKEN_ID = symbol("style:token");
|
|
484
633
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
634
|
+
const TOKEN_NAME = symbol("style:token.name");
|
|
635
|
+
const TOKEN_VAR_NAME = symbol("style:token.varName");
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region builder/token/data.ts
|
|
638
|
+
function isStyleTokenData(value) {
|
|
639
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
640
|
+
}
|
|
641
|
+
function isStyleTokenOverrideData(value) {
|
|
642
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
643
|
+
}
|
|
644
|
+
function getStyleTokenId(token) {
|
|
645
|
+
return token[TOKEN_ID];
|
|
646
|
+
}
|
|
647
|
+
function getStyleTokenName(token) {
|
|
648
|
+
return token[TOKEN_NAME] ?? null;
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region builder/token/name.ts
|
|
652
|
+
function getStyleTokenNameFromId(id) {
|
|
653
|
+
if (!id) return null;
|
|
654
|
+
const parts = id.split("--");
|
|
655
|
+
const first = normalizeStyleTokenName(parts[0]);
|
|
656
|
+
if (!first) return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join("--")) : null;
|
|
657
|
+
return normalizeStyleTokenName([first, ...parts.slice(1)].join("--"));
|
|
658
|
+
}
|
|
659
|
+
function getChildStyleTokenName(name, child) {
|
|
660
|
+
const childName = normalizeStyleTokenName(child);
|
|
661
|
+
if (!childName) return normalizeStyleTokenName(name);
|
|
662
|
+
const parentName = normalizeStyleTokenName(name);
|
|
663
|
+
return parentName ? parentName + "--" + childName : childName;
|
|
664
|
+
}
|
|
665
|
+
function normalizeStyleTokenName(value) {
|
|
666
|
+
if (!value) return null;
|
|
667
|
+
value = value.trim();
|
|
668
|
+
if (!value) return null;
|
|
669
|
+
if (/^\d+$/.test(value)) return null;
|
|
670
|
+
if (isGeneratedTokenHash(value)) return null;
|
|
671
|
+
value = stripGenericTokenPrefix(value);
|
|
672
|
+
if (!value) return null;
|
|
673
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
674
|
+
if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
|
|
675
|
+
return value;
|
|
676
|
+
}
|
|
677
|
+
function isGeneratedTokenHash(value) {
|
|
678
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
679
|
+
}
|
|
680
|
+
function stripGenericTokenPrefix(value) {
|
|
681
|
+
const parts = value.split("--");
|
|
682
|
+
while (parts[0] === "token" || parts[0] === "tokens") parts.shift();
|
|
683
|
+
return parts.join("--");
|
|
684
|
+
}
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region style/token.ts
|
|
485
687
|
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
486
688
|
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
487
|
-
function createStyleToken(value,
|
|
689
|
+
function createStyleToken(value, stableId, debugName) {
|
|
488
690
|
const token = (value, debug) => {
|
|
489
691
|
return createStyleTokenOverride(token, value, debug);
|
|
490
692
|
};
|
|
491
|
-
token[TOKEN_ID] =
|
|
693
|
+
token[TOKEN_ID] = stableId || String(idCounter$6.value++);
|
|
694
|
+
token[TOKEN_NAME] = debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
|
|
492
695
|
if (isStyleTokenData(value)) {
|
|
493
696
|
token.value = value.value;
|
|
494
697
|
token.ref = value;
|
|
@@ -502,11 +705,13 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
502
705
|
const override = isStyleTokenData(value) ? {
|
|
503
706
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
504
707
|
[TOKEN_OVERRIDE]: true,
|
|
708
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
505
709
|
value: value.value,
|
|
506
710
|
ref: value
|
|
507
711
|
} : {
|
|
508
712
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
509
713
|
[TOKEN_OVERRIDE]: true,
|
|
714
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
510
715
|
value,
|
|
511
716
|
ref: null
|
|
512
717
|
};
|
|
@@ -517,15 +722,6 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
517
722
|
});
|
|
518
723
|
return override;
|
|
519
724
|
}
|
|
520
|
-
function isStyleTokenData(value) {
|
|
521
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
522
|
-
}
|
|
523
|
-
function isStyleTokenOverrideData(value) {
|
|
524
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
525
|
-
}
|
|
526
|
-
function getStyleTokenId(token) {
|
|
527
|
-
return token[TOKEN_ID];
|
|
528
|
-
}
|
|
529
725
|
//#endregion
|
|
530
726
|
//#region selector/selector.ts
|
|
531
727
|
function selector(selector, ...args) {
|
|
@@ -660,114 +856,6 @@ selectorPriority({
|
|
|
660
856
|
...AtRuleSelectors
|
|
661
857
|
}, PrioritySelectors);
|
|
662
858
|
//#endregion
|
|
663
|
-
//#region selector/validate.ts
|
|
664
|
-
function isLocalSelector(selector) {
|
|
665
|
-
const groups = parseSelector(selector);
|
|
666
|
-
if (!groups || groups.length !== 1) return false;
|
|
667
|
-
return isSelectorGroupsSelf(groups, false);
|
|
668
|
-
}
|
|
669
|
-
function isPseudoArgSelector(selector) {
|
|
670
|
-
const groups = parseSelector(selector);
|
|
671
|
-
if (!groups || groups.length !== 1) return false;
|
|
672
|
-
return isSelectorGroupsSelf(groups, true);
|
|
673
|
-
}
|
|
674
|
-
function isTagSelector(selector) {
|
|
675
|
-
const groups = parseSelector(selector);
|
|
676
|
-
if (!groups || groups.length !== 1) return false;
|
|
677
|
-
const group = groups[0];
|
|
678
|
-
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
679
|
-
}
|
|
680
|
-
function isAttrArg(value) {
|
|
681
|
-
if (!value) return false;
|
|
682
|
-
if (value.includes("[") || value.includes("]")) return false;
|
|
683
|
-
return true;
|
|
684
|
-
}
|
|
685
|
-
function isRawValue(value) {
|
|
686
|
-
if (!value) return false;
|
|
687
|
-
if (value.includes("{") || value.includes("}")) return false;
|
|
688
|
-
return true;
|
|
689
|
-
}
|
|
690
|
-
function parseSelector(selector) {
|
|
691
|
-
try {
|
|
692
|
-
return parse(selector);
|
|
693
|
-
} catch {
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
function isSelectorGroupsSelf(groups, allowTag) {
|
|
698
|
-
for (let i = 0; i < groups.length; i++) {
|
|
699
|
-
const group = groups[i];
|
|
700
|
-
for (let j = 0; j < group.length; j++) {
|
|
701
|
-
const token = group[j];
|
|
702
|
-
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
703
|
-
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
function isAllowedSelectorType(type, allowTag) {
|
|
709
|
-
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
710
|
-
}
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region selector/assert.ts
|
|
713
|
-
function assertSelector(type, value) {
|
|
714
|
-
assertSelectorNotEmpty(value);
|
|
715
|
-
if (!type) return;
|
|
716
|
-
if (typeof type === "function") return type(value);
|
|
717
|
-
switch (type) {
|
|
718
|
-
case "local": return assertLocalSelector(value);
|
|
719
|
-
case "arg": return assertPseudoArgSelector(value);
|
|
720
|
-
case "tag": return assertTagSelector(value);
|
|
721
|
-
case "attr": return assertAttrSelector(value);
|
|
722
|
-
case "value": return assertRawValue(value);
|
|
723
|
-
case "media": return assertMediaQuery(value);
|
|
724
|
-
case "supports": return assertSupportsQuery(value);
|
|
725
|
-
case "container": return assertContainerQuery(value);
|
|
726
|
-
default: throw new Error("unsupported selector type: " + value);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
730
|
-
if (!value) throw new Error("selector cannot be empty");
|
|
731
|
-
});
|
|
732
|
-
const assertLocalSelector = createSelectorAssert((value) => {
|
|
733
|
-
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
734
|
-
});
|
|
735
|
-
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
736
|
-
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
737
|
-
});
|
|
738
|
-
const assertTagSelector = createSelectorAssert((value) => {
|
|
739
|
-
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
740
|
-
});
|
|
741
|
-
const assertAttrSelector = createSelectorAssert((value) => {
|
|
742
|
-
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
743
|
-
});
|
|
744
|
-
const assertRawValue = createSelectorAssert((value) => {
|
|
745
|
-
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
746
|
-
});
|
|
747
|
-
const assertMediaQuery = createSelectorAssert((value) => {
|
|
748
|
-
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
749
|
-
});
|
|
750
|
-
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
751
|
-
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
752
|
-
});
|
|
753
|
-
const assertContainerQuery = createSelectorAssert((value) => {
|
|
754
|
-
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
755
|
-
});
|
|
756
|
-
//#endregion
|
|
757
|
-
//#region builder/data/check_selector.ts
|
|
758
|
-
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
759
|
-
let message = null;
|
|
760
|
-
try {
|
|
761
|
-
assertSelector(fnSelector.assert, arg);
|
|
762
|
-
} catch (error) {
|
|
763
|
-
if (typeof error === "string" && error.trim()) message = error;
|
|
764
|
-
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
765
|
-
else message = "selector is invalid: " + arg;
|
|
766
|
-
}
|
|
767
|
-
if (!message) return;
|
|
768
|
-
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
769
|
-
}
|
|
770
|
-
//#endregion
|
|
771
859
|
//#region builder/data/create.ts
|
|
772
860
|
function createStyleData(callsite) {
|
|
773
861
|
return {
|
|
@@ -801,6 +889,28 @@ function createSlotOverrideData(callsite, slotId) {
|
|
|
801
889
|
[BUILDER_SLOT_ID]: slotId
|
|
802
890
|
};
|
|
803
891
|
}
|
|
892
|
+
function createSelectorOverrideData(callsite, selectors) {
|
|
893
|
+
return {
|
|
894
|
+
[BUILDER_TYPE]: 8,
|
|
895
|
+
[BUILDER_STATE]: {
|
|
896
|
+
items: [],
|
|
897
|
+
lookup: {}
|
|
898
|
+
},
|
|
899
|
+
[BUILDER_CALLSITE]: callsite,
|
|
900
|
+
[BUILDER_SELECTOR]: selectors
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function createSelectorData(callsite, selectors) {
|
|
904
|
+
return {
|
|
905
|
+
[BUILDER_TYPE]: 7,
|
|
906
|
+
[BUILDER_STATE]: {
|
|
907
|
+
items: [],
|
|
908
|
+
lookup: {}
|
|
909
|
+
},
|
|
910
|
+
[BUILDER_CALLSITE]: callsite,
|
|
911
|
+
[BUILDER_SELECTOR]: selectors
|
|
912
|
+
};
|
|
913
|
+
}
|
|
804
914
|
function createScopeData(callsite) {
|
|
805
915
|
return {
|
|
806
916
|
[BUILDER_TYPE]: 4,
|
|
@@ -932,29 +1042,18 @@ const formatClassName = createNameFormatter([
|
|
|
932
1042
|
"selector",
|
|
933
1043
|
"value"
|
|
934
1044
|
]);
|
|
935
|
-
const formatScopeClassName = createNameFormatter(["className"]);
|
|
936
1045
|
const formatTransformClassName = createNameFormatter(["className"]);
|
|
937
1046
|
function getDebugClassName(format, hash, info) {
|
|
938
1047
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
939
1048
|
}
|
|
1049
|
+
function getDebugSheetClassName(format, hash, info) {
|
|
1050
|
+
return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
|
|
1051
|
+
}
|
|
940
1052
|
function getDebugTransformClassName(format, hash, info) {
|
|
941
1053
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
942
1054
|
}
|
|
943
|
-
function getDebugScopeClassName(format, info) {
|
|
944
|
-
return formatScopeClassName(format || "-(className)", null, info);
|
|
945
|
-
}
|
|
946
1055
|
//#endregion
|
|
947
|
-
//#region atomic/utils/
|
|
948
|
-
function getCssVar(varName, value) {
|
|
949
|
-
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
950
|
-
}
|
|
951
|
-
function getCssVarRawFallback(varName, fallbackCss) {
|
|
952
|
-
return "var(" + varName + ", " + fallbackCss + ")";
|
|
953
|
-
}
|
|
954
|
-
function escapeCssValue(value) {
|
|
955
|
-
if (!value) return "";
|
|
956
|
-
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
957
|
-
}
|
|
1056
|
+
//#region atomic/utils/cssIdent.ts
|
|
958
1057
|
function escapeCssIdent(ident) {
|
|
959
1058
|
let result = "";
|
|
960
1059
|
for (let i = 0; i < ident.length; i++) {
|
|
@@ -1144,6 +1243,13 @@ function parseAtRule(rule) {
|
|
|
1144
1243
|
if (normalized.startsWith("@supports")) return compressQuery(normalized.slice(9));
|
|
1145
1244
|
return compressQuery(normalized);
|
|
1146
1245
|
}
|
|
1246
|
+
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1247
|
+
return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
|
|
1248
|
+
}
|
|
1249
|
+
function formatScopeClassName$1(format, info) {
|
|
1250
|
+
if (typeof format === "function") return format(info);
|
|
1251
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1252
|
+
}
|
|
1147
1253
|
//#endregion
|
|
1148
1254
|
//#region atomic/utils/hash.ts
|
|
1149
1255
|
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
@@ -1194,21 +1300,28 @@ function getIdentifierSafeHashValue(hash) {
|
|
|
1194
1300
|
}
|
|
1195
1301
|
//#endregion
|
|
1196
1302
|
//#region atomic/utils/selector.ts
|
|
1197
|
-
function getSelectorText(selector) {
|
|
1198
|
-
return Array.isArray(selector) ? selector[0] : selector;
|
|
1303
|
+
function getSelectorText$1(selector) {
|
|
1304
|
+
return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
|
|
1199
1305
|
}
|
|
1200
1306
|
function getSelectorHash(selector) {
|
|
1201
1307
|
return Array.isArray(selector) ? selector.join("|") : selector;
|
|
1202
1308
|
}
|
|
1203
|
-
function getSelectorPriority(selector) {
|
|
1309
|
+
function getSelectorPriority$1(selector) {
|
|
1204
1310
|
if (!selector) return 0;
|
|
1205
1311
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
1206
1312
|
}
|
|
1313
|
+
function hasSheetSelectorAnchor(selector) {
|
|
1314
|
+
return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
|
|
1315
|
+
}
|
|
1316
|
+
function stripSheetSelectorAnchor(selector) {
|
|
1317
|
+
return selector.startsWith("\0sheet") ? selector.slice(6) : selector;
|
|
1318
|
+
}
|
|
1207
1319
|
//#endregion
|
|
1208
1320
|
//#region atomic/className.ts
|
|
1209
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1321
|
+
function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
|
|
1210
1322
|
let hash = property;
|
|
1211
1323
|
hash += "\n" + (priority || "");
|
|
1324
|
+
if (important) hash += "\nimportant";
|
|
1212
1325
|
hash += "\n" + value;
|
|
1213
1326
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1214
1327
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
@@ -1218,10 +1331,11 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1218
1331
|
if (!debugClassName) return hash;
|
|
1219
1332
|
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1220
1333
|
const propertyName = getDebugPropertyName(property, value);
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1334
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
1335
|
+
return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
|
|
1336
|
+
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
|
|
1337
|
+
scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
|
|
1338
|
+
selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
|
|
1225
1339
|
property: propertyName ? propertyName.property : property,
|
|
1226
1340
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1227
1341
|
});
|
|
@@ -1230,12 +1344,10 @@ function getRuntimeClassNameHashLength(debugClassName) {
|
|
|
1230
1344
|
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1231
1345
|
return CSS_CONFIG.hashLength ?? 7;
|
|
1232
1346
|
}
|
|
1233
|
-
function
|
|
1234
|
-
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1235
|
-
}
|
|
1236
|
-
function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
|
|
1347
|
+
function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
|
|
1237
1348
|
let hash = property;
|
|
1238
1349
|
hash += "\n" + (priority || "");
|
|
1350
|
+
if (important) hash += "\nimportant";
|
|
1239
1351
|
hash += "\n" + (selector ? getSelectorHash(selector) : "");
|
|
1240
1352
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1241
1353
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
@@ -1272,7 +1384,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1272
1384
|
let source;
|
|
1273
1385
|
let item;
|
|
1274
1386
|
let lookupIndex;
|
|
1275
|
-
let
|
|
1387
|
+
let weight;
|
|
1388
|
+
let important;
|
|
1276
1389
|
let value;
|
|
1277
1390
|
let atRule;
|
|
1278
1391
|
let dedupe;
|
|
@@ -1283,7 +1396,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1283
1396
|
source = sourceItems[i];
|
|
1284
1397
|
if (!source) continue;
|
|
1285
1398
|
if (isStyleTokenOverrideData(source)) {
|
|
1286
|
-
addTokenOverride(source, styles, lookup);
|
|
1399
|
+
addTokenOverride$1(source, styles, lookup);
|
|
1287
1400
|
continue;
|
|
1288
1401
|
}
|
|
1289
1402
|
if (isScopeData(source)) {
|
|
@@ -1291,7 +1404,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1291
1404
|
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
1292
1405
|
item = scopeItems[j];
|
|
1293
1406
|
if (isStyleTokenOverrideData(item)) {
|
|
1294
|
-
addTokenOverride(item, styles, lookup);
|
|
1407
|
+
addTokenOverride$1(item, styles, lookup);
|
|
1295
1408
|
continue;
|
|
1296
1409
|
}
|
|
1297
1410
|
if (Array.isArray(item) || item.type !== 4) {
|
|
@@ -1312,13 +1425,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1312
1425
|
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
1313
1426
|
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
|
|
1314
1427
|
value = scopeItem.value;
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1320
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1321
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1428
|
+
weight = scopeItem.weight;
|
|
1429
|
+
important = scopeItem.important;
|
|
1430
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1431
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1322
1432
|
scopeItem.dedupe = dedupe;
|
|
1323
1433
|
scopeItem.className = className;
|
|
1324
1434
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1355,6 +1465,8 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1355
1465
|
dedupe: "",
|
|
1356
1466
|
className: "",
|
|
1357
1467
|
property: overrideItem.property,
|
|
1468
|
+
weight: overrideItem.weight,
|
|
1469
|
+
important: overrideItem.important,
|
|
1358
1470
|
value: overrideItem.value,
|
|
1359
1471
|
transformClassName: overrideItem.transformClassName,
|
|
1360
1472
|
token: overrideItem.token,
|
|
@@ -1366,13 +1478,10 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1366
1478
|
parentSelector
|
|
1367
1479
|
};
|
|
1368
1480
|
value = scopeItem.value;
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}
|
|
1374
|
-
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1375
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1481
|
+
weight = scopeItem.weight;
|
|
1482
|
+
important = scopeItem.important;
|
|
1483
|
+
dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1484
|
+
className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1376
1485
|
scopeItem.dedupe = dedupe;
|
|
1377
1486
|
scopeItem.className = className;
|
|
1378
1487
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1383,7 +1492,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1383
1492
|
}
|
|
1384
1493
|
return data;
|
|
1385
1494
|
}
|
|
1386
|
-
function addTokenOverride(item, styles, lookup) {
|
|
1495
|
+
function addTokenOverride$1(item, styles, lookup) {
|
|
1387
1496
|
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
1388
1497
|
const lookupIndex = lookup[lookupKey];
|
|
1389
1498
|
if (typeof lookupIndex === "number") styles[lookupIndex] = item;
|
|
@@ -1437,10 +1546,23 @@ function getScopeLookupKey(slotId, dedupe) {
|
|
|
1437
1546
|
function getTokenLookupKey(tokenId) {
|
|
1438
1547
|
return "token\0" + tokenId;
|
|
1439
1548
|
}
|
|
1549
|
+
//#endregion
|
|
1550
|
+
//#region atomic/utils/cssVar.ts
|
|
1551
|
+
function getCssVar(varName, value) {
|
|
1552
|
+
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1553
|
+
}
|
|
1554
|
+
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1555
|
+
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1556
|
+
}
|
|
1557
|
+
function escapeCssValue(value) {
|
|
1558
|
+
if (!value) return "";
|
|
1559
|
+
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1560
|
+
}
|
|
1440
1561
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1441
1562
|
function getTokenVarName(token, format) {
|
|
1442
1563
|
const id = getStyleTokenId(token);
|
|
1443
|
-
|
|
1564
|
+
const debugName = getStyleTokenName(token);
|
|
1565
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
1444
1566
|
}
|
|
1445
1567
|
function getTokenVar(token, format) {
|
|
1446
1568
|
return getTokenVarFallback(token, format);
|
|
@@ -1515,6 +1637,18 @@ function shouldAppendCssPx(property) {
|
|
|
1515
1637
|
return !UNITLESS.has(property);
|
|
1516
1638
|
}
|
|
1517
1639
|
//#endregion
|
|
1640
|
+
//#region style/important.ts
|
|
1641
|
+
const STYLE_IMPORTANT = symbol("style.important");
|
|
1642
|
+
function importantValue(value) {
|
|
1643
|
+
return {
|
|
1644
|
+
[STYLE_IMPORTANT]: true,
|
|
1645
|
+
value
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
function isStyleImportantValue(value) {
|
|
1649
|
+
return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
|
|
1650
|
+
}
|
|
1651
|
+
//#endregion
|
|
1518
1652
|
//#region style/transform.ts
|
|
1519
1653
|
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1520
1654
|
function classNameValue(value, className) {
|
|
@@ -1540,6 +1674,19 @@ function isAtRuleRef(value) {
|
|
|
1540
1674
|
return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
|
|
1541
1675
|
}
|
|
1542
1676
|
//#endregion
|
|
1677
|
+
//#region style/weight.ts
|
|
1678
|
+
const STYLE_WEIGHT = symbol("style.weight");
|
|
1679
|
+
function weightValue(value, weight) {
|
|
1680
|
+
return {
|
|
1681
|
+
[STYLE_WEIGHT]: true,
|
|
1682
|
+
value,
|
|
1683
|
+
weight
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
function isStyleWeightValue(value) {
|
|
1687
|
+
return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
|
|
1688
|
+
}
|
|
1689
|
+
//#endregion
|
|
1543
1690
|
//#region builder/data/merge/style.ts
|
|
1544
1691
|
function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
|
|
1545
1692
|
if (!style) return source;
|
|
@@ -1550,7 +1697,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1550
1697
|
let itemData;
|
|
1551
1698
|
let valueRaw;
|
|
1552
1699
|
let value;
|
|
1553
|
-
let
|
|
1700
|
+
let weight;
|
|
1701
|
+
let important;
|
|
1554
1702
|
let itemCallsite;
|
|
1555
1703
|
let className;
|
|
1556
1704
|
let dedupe;
|
|
@@ -1571,6 +1719,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1571
1719
|
continue;
|
|
1572
1720
|
}
|
|
1573
1721
|
if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
|
|
1722
|
+
if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors$1(selector, item.selector) : selector });
|
|
1574
1723
|
if (type === 2 && slotId !== null) item = Object.assign({}, item, {
|
|
1575
1724
|
type: 2,
|
|
1576
1725
|
slotId
|
|
@@ -1579,6 +1728,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1579
1728
|
type: 3,
|
|
1580
1729
|
slotId
|
|
1581
1730
|
});
|
|
1731
|
+
else if (type === 8) item = Object.assign({}, item, { type: 1 });
|
|
1582
1732
|
const itemDebug = getMergedStyleDebug(debug, item);
|
|
1583
1733
|
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
1584
1734
|
if (debugCallsite) item = Object.assign({}, item, {
|
|
@@ -1590,11 +1740,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1590
1740
|
}
|
|
1591
1741
|
} else for (const property in style) {
|
|
1592
1742
|
valueRaw = style[property];
|
|
1593
|
-
|
|
1594
|
-
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === "number") {
|
|
1595
|
-
priority = valueRaw[0];
|
|
1596
|
-
valueRaw = valueRaw[1];
|
|
1597
|
-
}
|
|
1743
|
+
[valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
|
|
1598
1744
|
transformClassName = null;
|
|
1599
1745
|
if (isClassNameValue(valueRaw)) {
|
|
1600
1746
|
transformClassName = valueRaw.className;
|
|
@@ -1605,7 +1751,6 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1605
1751
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
1606
1752
|
variableName = getDebugFieldVarName(debug, property);
|
|
1607
1753
|
value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
|
|
1608
|
-
value = priority !== null ? [value, priority] : value;
|
|
1609
1754
|
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
1610
1755
|
itemData = {
|
|
1611
1756
|
runtime: runtimeType,
|
|
@@ -1614,6 +1759,8 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1614
1759
|
dedupe: "",
|
|
1615
1760
|
className: "",
|
|
1616
1761
|
property,
|
|
1762
|
+
weight,
|
|
1763
|
+
important,
|
|
1617
1764
|
value,
|
|
1618
1765
|
transformClassName,
|
|
1619
1766
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
@@ -1627,7 +1774,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1627
1774
|
atRule,
|
|
1628
1775
|
callsite: itemCallsite
|
|
1629
1776
|
};
|
|
1630
|
-
if (type === 1) {
|
|
1777
|
+
if (type === 1 || type === 8) {
|
|
1631
1778
|
items.push({
|
|
1632
1779
|
...itemData,
|
|
1633
1780
|
type: 1
|
|
@@ -1674,13 +1821,10 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1674
1821
|
}
|
|
1675
1822
|
const runtimeItem = item;
|
|
1676
1823
|
value = runtimeItem.value;
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
}
|
|
1682
|
-
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1683
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1824
|
+
weight = runtimeItem.weight;
|
|
1825
|
+
important = runtimeItem.important;
|
|
1826
|
+
dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1827
|
+
className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
|
|
1684
1828
|
runtimeItem.dedupe = dedupe;
|
|
1685
1829
|
runtimeItem.className = className;
|
|
1686
1830
|
lookupIndex = lookup[dedupe];
|
|
@@ -1689,6 +1833,41 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1689
1833
|
}
|
|
1690
1834
|
return data;
|
|
1691
1835
|
}
|
|
1836
|
+
function unwrapAuthoredStyleValue(value) {
|
|
1837
|
+
let weight = null;
|
|
1838
|
+
let important = false;
|
|
1839
|
+
while (true) {
|
|
1840
|
+
if (isStyleImportantValue(value)) {
|
|
1841
|
+
important = true;
|
|
1842
|
+
value = value.value;
|
|
1843
|
+
continue;
|
|
1844
|
+
}
|
|
1845
|
+
if (isStyleWeightValue(value)) {
|
|
1846
|
+
weight = value.weight;
|
|
1847
|
+
value = value.value;
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
return [
|
|
1853
|
+
value,
|
|
1854
|
+
weight,
|
|
1855
|
+
important
|
|
1856
|
+
];
|
|
1857
|
+
}
|
|
1858
|
+
function combineSelectors$1(parent, child) {
|
|
1859
|
+
const parentText = getSelectorText(parent);
|
|
1860
|
+
const childText = getSelectorText(child);
|
|
1861
|
+
const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
|
|
1862
|
+
const selector = parentText + childText;
|
|
1863
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
1864
|
+
}
|
|
1865
|
+
function getSelectorText(selector) {
|
|
1866
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
1867
|
+
}
|
|
1868
|
+
function getSelectorPriority(selector) {
|
|
1869
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
1870
|
+
}
|
|
1692
1871
|
function getMergedStyleDebug(debug, item) {
|
|
1693
1872
|
if (!debug) return null;
|
|
1694
1873
|
if (debug.fields?.[item.property]) return debug;
|
|
@@ -1732,29 +1911,183 @@ function withDebugSource$1(loc, debug) {
|
|
|
1732
1911
|
];
|
|
1733
1912
|
}
|
|
1734
1913
|
//#endregion
|
|
1735
|
-
//#region builder/
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
const
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1914
|
+
//#region builder/selector_override_core.ts
|
|
1915
|
+
function normalizeManualSelectors$1(input, assertManualSelector) {
|
|
1916
|
+
const selectors = Array.isArray(input) ? input : [input];
|
|
1917
|
+
if (!selectors.length) throw new Error("selector array cannot be empty");
|
|
1918
|
+
return selectors.flatMap((selector) => normalizeManualSelector(selector, assertManualSelector));
|
|
1919
|
+
}
|
|
1920
|
+
function assertManualSelectorSyntax(selector) {
|
|
1921
|
+
if (!selector) throw new Error("selector cannot be empty");
|
|
1922
|
+
if (selector.includes("{") || selector.includes("}")) throw new Error("selector must not contain \"{\" or \"}\"");
|
|
1923
|
+
if (selector.includes(",")) throw new Error("selector must not contain \",\"; use an array of selectors instead");
|
|
1924
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1925
|
+
if (ampersandIndex > 0) throw new Error("selector can only use \"&\" at the beginning");
|
|
1926
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1927
|
+
if (ampersandIndex === 0 && ampersandSelector && /^\s/.test(ampersandSelector)) throw new Error("selector cannot have whitespace after \"&\"; omit \"&\" for descendant selectors");
|
|
1928
|
+
}
|
|
1929
|
+
function normalizeManualSelector(selector, assertManualSelector) {
|
|
1930
|
+
const value = selector.trim();
|
|
1931
|
+
assertManualSelector(value);
|
|
1932
|
+
if (value.startsWith("&?")) {
|
|
1933
|
+
const suffix = value.slice(2);
|
|
1934
|
+
return suffix ? [SHEET_SELECTOR_ANCHOR + suffix, "\0sheet " + suffix] : [SHEET_SELECTOR_ANCHOR];
|
|
1935
|
+
}
|
|
1936
|
+
return [SHEET_SELECTOR_ANCHOR + (value.startsWith("&") ? value.slice(1) : " " + value)];
|
|
1937
|
+
}
|
|
1938
|
+
//#endregion
|
|
1939
|
+
//#region builder/selector_override.ts
|
|
1940
|
+
function normalizeManualSelectors(input) {
|
|
1941
|
+
return normalizeManualSelectors$1(input, assertManualSelector);
|
|
1942
|
+
}
|
|
1943
|
+
function assertManualSelector(selector) {
|
|
1944
|
+
assertManualSelectorSyntax(selector);
|
|
1945
|
+
const ampersandIndex = selector.indexOf("&");
|
|
1946
|
+
const ampersandSelector = selector.startsWith("&?") ? selector.slice(2) : selector.slice(1);
|
|
1947
|
+
const parsedSelector = ampersandIndex === 0 ? "*" + ampersandSelector : selector;
|
|
1948
|
+
try {
|
|
1949
|
+
parse(parsedSelector);
|
|
1950
|
+
} catch {
|
|
1951
|
+
throw new Error("selector is invalid: " + selector);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
//#endregion
|
|
1955
|
+
//#region builder/style_data.ts
|
|
1956
|
+
const mergeStyleCreate = (callsite) => {
|
|
1957
|
+
return createStyleData(callsite);
|
|
1958
|
+
};
|
|
1959
|
+
const mergeStyleData = createMerge(mergeStyleCreate, 1);
|
|
1960
|
+
const mergeSlotCreate = (callsite, data) => {
|
|
1961
|
+
return createSlotData(callsite, data[BUILDER_SLOT_ID]);
|
|
1962
|
+
};
|
|
1963
|
+
const mergeSlotData = createMerge(mergeSlotCreate, 2);
|
|
1964
|
+
const mergeSlotOverrideCreate = (callsite, data) => {
|
|
1965
|
+
return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
|
|
1966
|
+
};
|
|
1967
|
+
const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
|
|
1968
|
+
const mergeSelectorOverrideCreate = (callsite, data) => {
|
|
1969
|
+
return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
|
|
1970
|
+
};
|
|
1971
|
+
const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
|
|
1972
|
+
function createMerge(create, type) {
|
|
1973
|
+
return (data, callsite, style, debug, selector, atRule) => {
|
|
1974
|
+
return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
//#endregion
|
|
1978
|
+
//#region selector/validate.ts
|
|
1979
|
+
function isLocalSelector(selector) {
|
|
1980
|
+
const groups = parseSelector(selector);
|
|
1981
|
+
if (!groups || groups.length !== 1) return false;
|
|
1982
|
+
return isSelectorGroupsSelf(groups, false);
|
|
1983
|
+
}
|
|
1984
|
+
function isPseudoArgSelector(selector) {
|
|
1985
|
+
const groups = parseSelector(selector);
|
|
1986
|
+
if (!groups || groups.length !== 1) return false;
|
|
1987
|
+
return isSelectorGroupsSelf(groups, true);
|
|
1988
|
+
}
|
|
1989
|
+
function isTagSelector(selector) {
|
|
1990
|
+
const groups = parseSelector(selector);
|
|
1991
|
+
if (!groups || groups.length !== 1) return false;
|
|
1992
|
+
const group = groups[0];
|
|
1993
|
+
return group.length === 1 && group[0].type === SelectorType.Tag;
|
|
1994
|
+
}
|
|
1995
|
+
function isAttrArg(value) {
|
|
1996
|
+
if (!value) return false;
|
|
1997
|
+
if (value.includes("[") || value.includes("]")) return false;
|
|
1998
|
+
return true;
|
|
1999
|
+
}
|
|
2000
|
+
function isRawValue(value) {
|
|
2001
|
+
if (!value) return false;
|
|
2002
|
+
if (value.includes("{") || value.includes("}")) return false;
|
|
2003
|
+
return true;
|
|
2004
|
+
}
|
|
2005
|
+
function parseSelector(selector) {
|
|
2006
|
+
try {
|
|
2007
|
+
return parse(selector);
|
|
2008
|
+
} catch {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
function isSelectorGroupsSelf(groups, allowTag) {
|
|
2013
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2014
|
+
const group = groups[i];
|
|
2015
|
+
for (let j = 0; j < group.length; j++) {
|
|
2016
|
+
const token = group[j];
|
|
2017
|
+
if (!isAllowedSelectorType(token.type, allowTag)) return false;
|
|
2018
|
+
if (token.type === SelectorType.Pseudo && Array.isArray(token.data) && !isSelectorGroupsSelf(token.data, allowTag)) return false;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return true;
|
|
2022
|
+
}
|
|
2023
|
+
function isAllowedSelectorType(type, allowTag) {
|
|
2024
|
+
return type === SelectorType.Attribute || type === SelectorType.Pseudo || type === SelectorType.PseudoElement || allowTag && type === SelectorType.Tag;
|
|
2025
|
+
}
|
|
2026
|
+
//#endregion
|
|
2027
|
+
//#region selector/assert.ts
|
|
2028
|
+
function assertSelector(type, value) {
|
|
2029
|
+
assertSelectorNotEmpty(value);
|
|
2030
|
+
if (!type) return;
|
|
2031
|
+
if (typeof type === "function") return type(value);
|
|
2032
|
+
switch (type) {
|
|
2033
|
+
case "local": return assertLocalSelector(value);
|
|
2034
|
+
case "arg": return assertPseudoArgSelector(value);
|
|
2035
|
+
case "tag": return assertTagSelector(value);
|
|
2036
|
+
case "attr": return assertAttrSelector(value);
|
|
2037
|
+
case "value": return assertRawValue(value);
|
|
2038
|
+
case "media": return assertMediaQuery(value);
|
|
2039
|
+
case "supports": return assertSupportsQuery(value);
|
|
2040
|
+
case "container": return assertContainerQuery(value);
|
|
2041
|
+
default: throw new Error("unsupported selector type: " + value);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
2045
|
+
if (!value) throw new Error("selector cannot be empty");
|
|
2046
|
+
});
|
|
2047
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
2048
|
+
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
2049
|
+
});
|
|
2050
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
2051
|
+
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
2052
|
+
});
|
|
2053
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
2054
|
+
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
2055
|
+
});
|
|
2056
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
2057
|
+
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
2058
|
+
});
|
|
2059
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
2060
|
+
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
2061
|
+
});
|
|
2062
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
2063
|
+
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
2064
|
+
});
|
|
2065
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
2066
|
+
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
2067
|
+
});
|
|
2068
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
2069
|
+
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
2070
|
+
});
|
|
2071
|
+
//#endregion
|
|
2072
|
+
//#region builder/data/check_selector.ts
|
|
2073
|
+
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
2074
|
+
let message = null;
|
|
2075
|
+
try {
|
|
2076
|
+
assertSelector(fnSelector.assert, arg);
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
if (typeof error === "string" && error.trim()) message = error;
|
|
2079
|
+
else if (typeof error === "object" && error && error instanceof Error) message = (error.message || "").trim();
|
|
2080
|
+
else message = "selector is invalid: " + arg;
|
|
2081
|
+
}
|
|
2082
|
+
if (!message) return;
|
|
2083
|
+
throw traceError(`${fnPrefix}${fnName}(${arg || ""}): ${message}`);
|
|
1752
2084
|
}
|
|
1753
2085
|
//#endregion
|
|
1754
2086
|
//#region builder/utils.ts
|
|
1755
2087
|
const FnPrefixStyle = "style.";
|
|
1756
2088
|
const FnPrefixSlot = "slot.";
|
|
1757
2089
|
const FnPrefixScope = "scope.";
|
|
2090
|
+
const FnPrefixSelector = "selector.";
|
|
1758
2091
|
function runtimeCallsite() {
|
|
1759
2092
|
return traceCallsite();
|
|
1760
2093
|
}
|
|
@@ -1815,9 +2148,9 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1815
2148
|
let arg;
|
|
1816
2149
|
let style;
|
|
1817
2150
|
let debug;
|
|
1818
|
-
let
|
|
2151
|
+
let weight = null;
|
|
1819
2152
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1820
|
-
|
|
2153
|
+
weight = params[0];
|
|
1821
2154
|
arg = params[1];
|
|
1822
2155
|
style = params[2];
|
|
1823
2156
|
debug = params[3];
|
|
@@ -1827,7 +2160,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1827
2160
|
debug = params[2];
|
|
1828
2161
|
}
|
|
1829
2162
|
else if (isMedia && typeof params[0] === "number") {
|
|
1830
|
-
|
|
2163
|
+
weight = params[0];
|
|
1831
2164
|
arg = fnSelector.selector;
|
|
1832
2165
|
style = params[1];
|
|
1833
2166
|
debug = params[2];
|
|
@@ -1847,7 +2180,7 @@ function createAtRuleFn(mergeData, fns, createFnResult, fnPrefix, fnName, fnSele
|
|
|
1847
2180
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1848
2181
|
for (let j = 0, len = items.length; j < len; j++) {
|
|
1849
2182
|
const item = items[j];
|
|
1850
|
-
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [
|
|
2183
|
+
data = mergeData(data, callsite, isStyleData(item) ? item : transformStyle(item, transform), debug ?? null, null, [weight !== null ? [selector, weight] : selector]);
|
|
1851
2184
|
}
|
|
1852
2185
|
}
|
|
1853
2186
|
return createFnResult(data, fns);
|
|
@@ -1914,9 +2247,9 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1914
2247
|
let arg;
|
|
1915
2248
|
let data;
|
|
1916
2249
|
let debug;
|
|
1917
|
-
let
|
|
2250
|
+
let weight = null;
|
|
1918
2251
|
if (hasArg) if (isMedia && typeof params[0] === "number") {
|
|
1919
|
-
|
|
2252
|
+
weight = params[0];
|
|
1920
2253
|
arg = params[1];
|
|
1921
2254
|
data = params[2];
|
|
1922
2255
|
debug = params[3];
|
|
@@ -1926,7 +2259,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1926
2259
|
debug = params[2];
|
|
1927
2260
|
}
|
|
1928
2261
|
else if (isMedia && typeof params[0] === "number") {
|
|
1929
|
-
|
|
2262
|
+
weight = params[0];
|
|
1930
2263
|
arg = fnSelector.selector;
|
|
1931
2264
|
data = params[1];
|
|
1932
2265
|
debug = params[2];
|
|
@@ -1943,7 +2276,7 @@ function createScopeAtRuleFn(fnPrefix, fnName, fnSelector, cloneScope) {
|
|
|
1943
2276
|
selector = args[i];
|
|
1944
2277
|
if (hasArg && DEV_CONFIG.isCheckSelectorEnabled) checkSelector(fnPrefix, fnName, fnSelector, selector);
|
|
1945
2278
|
selector = hasArg ? before + normalizeSelectorArg(selector) + after : selector;
|
|
1946
|
-
result = mergeScopeItems(result, callsite, data, debug ?? null, null,
|
|
2279
|
+
result = mergeScopeItems(result, callsite, data, debug ?? null, null, weight !== null ? [selector, weight] : selector, cloneScope);
|
|
1947
2280
|
}
|
|
1948
2281
|
return result;
|
|
1949
2282
|
};
|
|
@@ -2020,6 +2353,20 @@ function createSlotBuilder(selectors, transform) {
|
|
|
2020
2353
|
traceMarker(fn, "slot");
|
|
2021
2354
|
return fn;
|
|
2022
2355
|
}
|
|
2356
|
+
function createSelectorBuilder(selectors, transform) {
|
|
2357
|
+
const fns = createStyleFns(mergeSelectorOverrideData, selectors, FnPrefixSelector, transform, null);
|
|
2358
|
+
const fn = (selector, style, debug) => {
|
|
2359
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2360
|
+
debug = style;
|
|
2361
|
+
style = void 0;
|
|
2362
|
+
}
|
|
2363
|
+
const target = createCallableSelector(createSelectorData(resolveCallsite(debug), normalizeManualSelectors(selector)), fns, transform);
|
|
2364
|
+
if (style === void 0) return target;
|
|
2365
|
+
return target(style, debug);
|
|
2366
|
+
};
|
|
2367
|
+
traceMarker(fn, "style.selector");
|
|
2368
|
+
return fn;
|
|
2369
|
+
}
|
|
2023
2370
|
function createScopeBuilder(selectors) {
|
|
2024
2371
|
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
2025
2372
|
const fn = (items, debug) => {
|
|
@@ -2035,6 +2382,34 @@ function createScopeBuilder(selectors) {
|
|
|
2035
2382
|
traceMarker(fn, "scope");
|
|
2036
2383
|
return fn;
|
|
2037
2384
|
}
|
|
2385
|
+
function createCallableSelectorOverride(data, fns, transform) {
|
|
2386
|
+
const callable = ((style, debug) => {
|
|
2387
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2388
|
+
debug = style;
|
|
2389
|
+
style = void 0;
|
|
2390
|
+
}
|
|
2391
|
+
const callsite = resolveCallsite(debug);
|
|
2392
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), fns, transform);
|
|
2393
|
+
});
|
|
2394
|
+
traceMarker(callable, "selector.override");
|
|
2395
|
+
Object.setPrototypeOf(callable, fns);
|
|
2396
|
+
Object.assign(callable, data);
|
|
2397
|
+
return callable;
|
|
2398
|
+
}
|
|
2399
|
+
function createCallableSelector(data, overrideFns, transform) {
|
|
2400
|
+
const callable = ((style, debug) => {
|
|
2401
|
+
if (isDebugData(style) && debug === void 0) {
|
|
2402
|
+
debug = style;
|
|
2403
|
+
style = void 0;
|
|
2404
|
+
}
|
|
2405
|
+
const callsite = resolveCallsite(debug);
|
|
2406
|
+
return createCallableSelectorOverride(mergeSelectorOverrideData(createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]), callsite, style ? isStyleData(style) ? style : transformStyle(style, transform) : null, debug ?? null, null, null), overrideFns, transform);
|
|
2407
|
+
});
|
|
2408
|
+
traceMarker(callable, "selector");
|
|
2409
|
+
Object.setPrototypeOf(callable, overrideFns);
|
|
2410
|
+
Object.assign(callable, data);
|
|
2411
|
+
return callable;
|
|
2412
|
+
}
|
|
2038
2413
|
function createCallableSlot(data, fns, overrideFns, transform) {
|
|
2039
2414
|
const slotId = data[BUILDER_SLOT_ID];
|
|
2040
2415
|
const callable = ((style, debug) => {
|
|
@@ -2547,101 +2922,592 @@ function createNamedAtRuleRef(config) {
|
|
|
2547
2922
|
tokens: tokens.length ? tokens : void 0
|
|
2548
2923
|
});
|
|
2549
2924
|
}
|
|
2550
|
-
createIdCounter("counterStyle");
|
|
2925
|
+
createIdCounter("counterStyle");
|
|
2926
|
+
//#endregion
|
|
2927
|
+
//#region atomic/atRule/fontFace.ts
|
|
2928
|
+
const FONT_FACE_AT_RULE = "font-face";
|
|
2929
|
+
const formatFontFaceName = createAtRuleNameFormatter("font[-(name)]-$hash");
|
|
2930
|
+
function buildFontFaceCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
2931
|
+
name = formatFontFaceName(format, id, { name });
|
|
2932
|
+
let css = buildAtRuleDeclarationCss(descriptors, tokens, tokenLookup, tokenNameFormat, true, (property) => property !== "fontFamily");
|
|
2933
|
+
css = `@${FONT_FACE_AT_RULE} { font-family: ${name}; ${css} }`;
|
|
2934
|
+
return {
|
|
2935
|
+
name,
|
|
2936
|
+
css
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
//#endregion
|
|
2940
|
+
//#region atomic/atRule/fontSrc.ts
|
|
2941
|
+
function fontSrc(url, format) {
|
|
2942
|
+
if (typeof url !== "string") throw new Error("fontSrc url must be a static string");
|
|
2943
|
+
const src = `url("${escapeFontSrcPart(url)}")`;
|
|
2944
|
+
return format ? `${src} format("${escapeFontSrcPart(format)}")` : src;
|
|
2945
|
+
}
|
|
2946
|
+
function escapeFontSrcPart(value) {
|
|
2947
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
2948
|
+
}
|
|
2949
|
+
createIdCounter("fontFace");
|
|
2950
|
+
//#endregion
|
|
2951
|
+
//#region atomic/atRule/fontPaletteValues.ts
|
|
2952
|
+
const FONT_PALETTE_VALUES_AT_RULE = "font-palette-values";
|
|
2953
|
+
const formatFontPaletteValuesName = createAtRuleNameFormatter("font-palettle[-(name)]-$hash", "--");
|
|
2954
|
+
function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
2955
|
+
name = formatFontPaletteValuesName(format, id, { name });
|
|
2956
|
+
const css = buildNamedAtRuleCss(FONT_PALETTE_VALUES_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
2957
|
+
return {
|
|
2958
|
+
name,
|
|
2959
|
+
css
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
createIdCounter("fontPaletteValues");
|
|
2963
|
+
//#endregion
|
|
2964
|
+
//#region atomic/atRule/keyframes.ts
|
|
2965
|
+
const KEYFRAMES_AT_RULE = "keyframes";
|
|
2966
|
+
const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
|
|
2967
|
+
function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
|
|
2968
|
+
name = formatKeyFramesName(format, id, { name });
|
|
2969
|
+
let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
|
|
2970
|
+
for (const selector in frames) {
|
|
2971
|
+
const frame = frames[selector];
|
|
2972
|
+
if (!frame) continue;
|
|
2973
|
+
css += selector + "{";
|
|
2974
|
+
css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
|
|
2975
|
+
css += "}";
|
|
2976
|
+
}
|
|
2977
|
+
css += "}";
|
|
2978
|
+
return {
|
|
2979
|
+
name,
|
|
2980
|
+
css
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
//#endregion
|
|
2984
|
+
//#region css/keyframes.ts
|
|
2985
|
+
const idCounter$2 = createIdCounter("keyframes");
|
|
2986
|
+
function createKeyframes(frames, stableId) {
|
|
2987
|
+
return createNamedAtRuleRef({
|
|
2988
|
+
format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
|
|
2989
|
+
buildCss: buildKeyframesCss,
|
|
2990
|
+
value: frames,
|
|
2991
|
+
idCounter: idCounter$2,
|
|
2992
|
+
stableId
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
//#endregion
|
|
2996
|
+
//#region atomic/atRule/positionTry.ts
|
|
2997
|
+
const POSITION_TRY_AT_RULE = "position-try";
|
|
2998
|
+
const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
|
|
2999
|
+
function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3000
|
+
name = formatPositionTryName(format, id, { name });
|
|
3001
|
+
const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3002
|
+
return {
|
|
3003
|
+
name,
|
|
3004
|
+
css
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
createIdCounter("positionTry");
|
|
3008
|
+
//#endregion
|
|
3009
|
+
//#region atomic/atRule/property.ts
|
|
3010
|
+
const PROPERTY_AT_RULE = "property";
|
|
3011
|
+
const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
|
|
3012
|
+
function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
3013
|
+
name = formatPropertyName(format, id, { name });
|
|
3014
|
+
return {
|
|
3015
|
+
css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
|
|
3016
|
+
name
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
createIdCounter("property");
|
|
3020
|
+
//#endregion
|
|
3021
|
+
//#region sheet/utils/sourcemap.ts
|
|
3022
|
+
const VLQ_BASE_SHIFT = 5;
|
|
3023
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
3024
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
3025
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
3026
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3027
|
+
const SOURCE_URL_PREFIX = "source://";
|
|
3028
|
+
function encodeBase64(text) {
|
|
3029
|
+
const bytes = new TextEncoder().encode(text);
|
|
3030
|
+
let binary = "";
|
|
3031
|
+
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
3032
|
+
return btoa(binary);
|
|
3033
|
+
}
|
|
3034
|
+
function getSource(sources, sourceLookup, filePath, sourceContent) {
|
|
3035
|
+
let source = sourceLookup[filePath];
|
|
3036
|
+
if (source) {
|
|
3037
|
+
if (source.sourceContent === void 0) source.sourceContent = sourceContent;
|
|
3038
|
+
return source;
|
|
3039
|
+
}
|
|
3040
|
+
source = {
|
|
3041
|
+
filePath,
|
|
3042
|
+
sourceIndex: sources.length,
|
|
3043
|
+
sourceContent
|
|
3044
|
+
};
|
|
3045
|
+
sources.push(source);
|
|
3046
|
+
sourceLookup[filePath] = source;
|
|
3047
|
+
return source;
|
|
3048
|
+
}
|
|
3049
|
+
function normalizeSourcePath(filePath) {
|
|
3050
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
3051
|
+
const atIndex = filePath.indexOf("/at ");
|
|
3052
|
+
if (atIndex !== -1) return filePath.slice(atIndex + 4);
|
|
3053
|
+
return filePath.replace(/^at\s+/, "");
|
|
3054
|
+
}
|
|
3055
|
+
function getSourceMapSourceUrl(sourceData) {
|
|
3056
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
3057
|
+
if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
|
|
3058
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
3059
|
+
}
|
|
3060
|
+
function resolveSidecarSourceUrl(sourceUrl) {
|
|
3061
|
+
const sidecarUrl = getSidecarUrl();
|
|
3062
|
+
if (!sidecarUrl) return sourceUrl;
|
|
3063
|
+
return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
|
|
3064
|
+
}
|
|
3065
|
+
function getSidecarUrl() {
|
|
3066
|
+
const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
|
|
3067
|
+
return typeof value === "string" && value ? value : null;
|
|
3068
|
+
}
|
|
3069
|
+
function getSourceUrlPath(sourceUrl) {
|
|
3070
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
|
|
3071
|
+
try {
|
|
3072
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, "");
|
|
3073
|
+
} catch {
|
|
3074
|
+
return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
function joinSourceUrl(baseUrl, sourcePath) {
|
|
3078
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
3079
|
+
const path = sourcePath.replace(/^\/+/, "");
|
|
3080
|
+
return path ? `${base}/${path}` : base;
|
|
3081
|
+
}
|
|
3082
|
+
function getLineCount(css) {
|
|
3083
|
+
let count = 1;
|
|
3084
|
+
for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
|
|
3085
|
+
return count;
|
|
3086
|
+
}
|
|
3087
|
+
function encodeVlq(value) {
|
|
3088
|
+
let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
|
|
3089
|
+
let encoded = "";
|
|
3090
|
+
do {
|
|
3091
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
3092
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
3093
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
3094
|
+
encoded += BASE64[digit];
|
|
3095
|
+
} while (vlq > 0);
|
|
3096
|
+
return encoded;
|
|
3097
|
+
}
|
|
3098
|
+
//#endregion
|
|
3099
|
+
//#region sheet/sourcemap.ts
|
|
3100
|
+
function getRuleCallsite(callsite, debug, debugField) {
|
|
3101
|
+
if (debug && debugField) {
|
|
3102
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
3103
|
+
if (loc) return normalizeRuleCallsite({
|
|
3104
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
3105
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
3106
|
+
sourceContent: loc[4] ?? debug.code,
|
|
3107
|
+
line: loc[0],
|
|
3108
|
+
column: loc[1]
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
3112
|
+
if (debug) return normalizeRuleCallsite({
|
|
3113
|
+
filePath: debug.sourceUrl,
|
|
3114
|
+
sourceUrl: debug.sourceUrl,
|
|
3115
|
+
sourceContent: debug.code,
|
|
3116
|
+
line: debug.loc[0],
|
|
3117
|
+
column: debug.loc[1]
|
|
3118
|
+
});
|
|
3119
|
+
return callsite || null;
|
|
3120
|
+
}
|
|
3121
|
+
function normalizeRuleCallsite(callsite) {
|
|
3122
|
+
return {
|
|
3123
|
+
...callsite,
|
|
3124
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
3125
|
+
sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
|
|
3126
|
+
};
|
|
3127
|
+
}
|
|
3128
|
+
globalData("sheet.dev.sourcemapTags", () => []);
|
|
3129
|
+
globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
|
|
3130
|
+
//#endregion
|
|
3131
|
+
//#region builder/extract/utils.ts
|
|
3132
|
+
function createExtractedData(type, slotId) {
|
|
3133
|
+
const data = {
|
|
3134
|
+
[BUILDER_TYPE]: type,
|
|
3135
|
+
[BUILDER_STATE]: {
|
|
3136
|
+
items: [],
|
|
3137
|
+
lookup: {}
|
|
3138
|
+
},
|
|
3139
|
+
[BUILDER_CALLSITE]: null
|
|
3140
|
+
};
|
|
3141
|
+
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
3142
|
+
return data;
|
|
3143
|
+
}
|
|
3144
|
+
function copyExtractedData(target, source) {
|
|
3145
|
+
const mutable = target;
|
|
3146
|
+
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
3147
|
+
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
3148
|
+
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
3149
|
+
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
3150
|
+
}
|
|
3151
|
+
function createExtractedScopeTarget(scope, slot) {
|
|
3152
|
+
return {
|
|
3153
|
+
[BUILDER_TYPE]: 5,
|
|
3154
|
+
[BUILDER_SCOPE]: scope,
|
|
3155
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
function normalizeExtractedItems(type, slotId, items) {
|
|
3159
|
+
const normalized = [];
|
|
3160
|
+
let i = 0;
|
|
3161
|
+
while (i < items.length) {
|
|
3162
|
+
const item = items[i];
|
|
3163
|
+
const value = item[2];
|
|
3164
|
+
normalized.push(value === void 0 ? slotId === null ? [
|
|
3165
|
+
type,
|
|
3166
|
+
item[0],
|
|
3167
|
+
item[1]
|
|
3168
|
+
] : [
|
|
3169
|
+
type,
|
|
3170
|
+
slotId,
|
|
3171
|
+
item[0],
|
|
3172
|
+
item[1]
|
|
3173
|
+
] : slotId === null ? [
|
|
3174
|
+
type,
|
|
3175
|
+
item[0],
|
|
3176
|
+
item[1],
|
|
3177
|
+
value
|
|
3178
|
+
] : [
|
|
3179
|
+
type,
|
|
3180
|
+
slotId,
|
|
3181
|
+
item[0],
|
|
3182
|
+
item[1],
|
|
3183
|
+
value
|
|
3184
|
+
]);
|
|
3185
|
+
i++;
|
|
3186
|
+
}
|
|
3187
|
+
return normalized;
|
|
3188
|
+
}
|
|
2551
3189
|
//#endregion
|
|
2552
|
-
//#region
|
|
2553
|
-
const
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
return {
|
|
2560
|
-
name,
|
|
2561
|
-
css
|
|
2562
|
-
};
|
|
3190
|
+
//#region builder/extract/withTokens.ts
|
|
3191
|
+
const tokenBoundData = /* @__PURE__ */ new WeakMap();
|
|
3192
|
+
function isExtractedTokenBoundData(value) {
|
|
3193
|
+
return !!value && (typeof value === "object" || typeof value === "function") && tokenBoundData.has(value);
|
|
3194
|
+
}
|
|
3195
|
+
function getExtractedTokenBoundData(value) {
|
|
3196
|
+
return tokenBoundData.get(value);
|
|
2563
3197
|
}
|
|
3198
|
+
function isElementDebugData(value) {
|
|
3199
|
+
if (!value || typeof value !== "object") return false;
|
|
3200
|
+
return value.$$elementDebug === true;
|
|
3201
|
+
}
|
|
3202
|
+
globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
|
|
2564
3203
|
//#endregion
|
|
2565
|
-
//#region
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
3204
|
+
//#region runtime/core/cache/resolvedItem.ts
|
|
3205
|
+
const resolvedStyleItems = globalData("runtime.resolvedStyleItems", () => /* @__PURE__ */ new WeakSet());
|
|
3206
|
+
const resolvedStyleItemTokenValues = globalData("runtime.styleItemTokenValues", () => /* @__PURE__ */ new WeakMap());
|
|
3207
|
+
function markResolvedStyleItem(item) {
|
|
3208
|
+
resolvedStyleItems.add(item);
|
|
2570
3209
|
}
|
|
2571
|
-
function
|
|
2572
|
-
return value
|
|
3210
|
+
function isResolvedStyleItem$1(value) {
|
|
3211
|
+
return !!value && typeof value === "object" && resolvedStyleItems.has(value);
|
|
3212
|
+
}
|
|
3213
|
+
function setResolvedStyleItemTokenValues(item, tokens) {
|
|
3214
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
2573
3215
|
}
|
|
2574
|
-
createIdCounter("fontFace");
|
|
2575
3216
|
//#endregion
|
|
2576
|
-
//#region
|
|
2577
|
-
|
|
2578
|
-
const formatFontPaletteValuesName = createAtRuleNameFormatter("font-palettle[-(name)]-$hash", "--");
|
|
2579
|
-
function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
|
|
2580
|
-
name = formatFontPaletteValuesName(format, id, { name });
|
|
2581
|
-
const css = buildNamedAtRuleCss(FONT_PALETTE_VALUES_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
|
|
3217
|
+
//#region runtime/core/cache/tokenValues.ts
|
|
3218
|
+
function createMutableTokenValues(base) {
|
|
2582
3219
|
return {
|
|
2583
|
-
|
|
2584
|
-
|
|
3220
|
+
ids: base ? base.ids.slice() : null,
|
|
3221
|
+
values: base ? base.values.slice() : null,
|
|
3222
|
+
lookup: base ? { ...base.lookup } : null,
|
|
3223
|
+
index: base ? createTokenIndexLookup(base.ids) : null
|
|
2585
3224
|
};
|
|
2586
3225
|
}
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
function
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
3226
|
+
function addTokenOverride(values, item, resolver) {
|
|
3227
|
+
if (!resolver.is(item)) return false;
|
|
3228
|
+
addTokenValue(values, resolver.id(item), resolver.value(item));
|
|
3229
|
+
return true;
|
|
3230
|
+
}
|
|
3231
|
+
function addTokenValue(values, id, value) {
|
|
3232
|
+
if (!values.ids) values.ids = [];
|
|
3233
|
+
if (!values.values) values.values = [];
|
|
3234
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
3235
|
+
if (!values.index) values.index = Object.create(null);
|
|
3236
|
+
const ids = values.ids;
|
|
3237
|
+
const tokenValues = values.values;
|
|
3238
|
+
const lookup = values.lookup;
|
|
3239
|
+
const indexLookup = values.index;
|
|
3240
|
+
const index = indexLookup[id];
|
|
3241
|
+
if (index === void 0) {
|
|
3242
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
3243
|
+
tokenValues.push(value);
|
|
3244
|
+
} else tokenValues[index] = value;
|
|
3245
|
+
lookup[id] = value;
|
|
3246
|
+
}
|
|
3247
|
+
function addTokenValues(values, next) {
|
|
3248
|
+
if (!next) return;
|
|
3249
|
+
for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
|
|
3250
|
+
}
|
|
3251
|
+
function addTokenOverrides(values, overrides, resolver) {
|
|
3252
|
+
for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
|
|
3253
|
+
}
|
|
3254
|
+
function finishTokenValues(base, values) {
|
|
3255
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
3256
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
2603
3257
|
return {
|
|
2604
|
-
|
|
2605
|
-
|
|
3258
|
+
ids: values.ids,
|
|
3259
|
+
values: values.values,
|
|
3260
|
+
lookup: values.lookup
|
|
2606
3261
|
};
|
|
2607
3262
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
3263
|
+
function mergeTokenValues(base, next) {
|
|
3264
|
+
if (!next) return base;
|
|
3265
|
+
if (!base) return next;
|
|
3266
|
+
const values = createMutableTokenValues(base);
|
|
3267
|
+
addTokenValues(values, next);
|
|
3268
|
+
return finishTokenValues(base, values);
|
|
3269
|
+
}
|
|
3270
|
+
function mergeTokenOverrides(base, overrides, resolver) {
|
|
3271
|
+
if (!overrides.length) return base;
|
|
3272
|
+
const values = createMutableTokenValues(base);
|
|
3273
|
+
addTokenOverrides(values, overrides, resolver);
|
|
3274
|
+
return finishTokenValues(base, values);
|
|
3275
|
+
}
|
|
3276
|
+
function createTokenIndexLookup(ids) {
|
|
3277
|
+
const lookup = Object.create(null);
|
|
3278
|
+
for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
|
|
3279
|
+
return lookup;
|
|
3280
|
+
}
|
|
3281
|
+
function isSameTokenValues(base, ids, values) {
|
|
3282
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
3283
|
+
const baseLookup = base.lookup;
|
|
3284
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
3285
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
3286
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
3287
|
+
}
|
|
3288
|
+
return true;
|
|
3289
|
+
}
|
|
3290
|
+
globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
|
|
3291
|
+
function isResolvedStyleItem(value) {
|
|
3292
|
+
return isResolvedStyleItem$1(value);
|
|
3293
|
+
}
|
|
3294
|
+
function createResolvedStyleItem(data, scopes, tokens = null) {
|
|
3295
|
+
return createStyleItem({
|
|
3296
|
+
data,
|
|
3297
|
+
items: resolveItems(data, scopes)
|
|
3298
|
+
}, tokens);
|
|
3299
|
+
}
|
|
3300
|
+
function createStyleItem(item, tokens = null) {
|
|
3301
|
+
markResolvedStyleItem(item);
|
|
3302
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
3303
|
+
return item;
|
|
3304
|
+
}
|
|
3305
|
+
function resolveItems(data, scopes) {
|
|
3306
|
+
const items = [];
|
|
3307
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3308
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
3309
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
3310
|
+
const item = stateItems[i];
|
|
3311
|
+
if (Array.isArray(item)) {
|
|
3312
|
+
items.push(item);
|
|
3313
|
+
continue;
|
|
3314
|
+
}
|
|
3315
|
+
if (isStyleTokenOverrideData(item)) {
|
|
3316
|
+
items.push(item);
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
if (slotId && item.type !== 2) continue;
|
|
3320
|
+
items.push(item);
|
|
3321
|
+
}
|
|
3322
|
+
if (!slotId || isSheetData(data)) return items;
|
|
3323
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
3324
|
+
const boundScope = scopes[i];
|
|
3325
|
+
const scope = getScopeTargetScope(boundScope);
|
|
3326
|
+
if (!scope) continue;
|
|
3327
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
3328
|
+
if (!scopeItems) continue;
|
|
3329
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
3330
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
3331
|
+
const item = scopeItems[j];
|
|
3332
|
+
if (Array.isArray(item)) {
|
|
3333
|
+
if (item[1] === slotId) items.push(item);
|
|
3334
|
+
const hasParentSelector = isExtractedScopeParentMarker$2(item[4]) || isExtractedScopeParentMarker$2(item[5]);
|
|
3335
|
+
if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
|
|
3336
|
+
continue;
|
|
3337
|
+
}
|
|
3338
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
3339
|
+
if (item.type !== 4) continue;
|
|
3340
|
+
if (item.slotId === slotId) items.push(item);
|
|
3341
|
+
if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
return items;
|
|
3345
|
+
}
|
|
3346
|
+
function getScopeParentItem(className) {
|
|
3347
|
+
const parentClassName = formatScopeClassName(className);
|
|
3348
|
+
return [parentClassName, parentClassName];
|
|
3349
|
+
}
|
|
3350
|
+
function formatScopeClassName(className) {
|
|
3351
|
+
const format = CSS_CONFIG.scopeClassNameFormat;
|
|
3352
|
+
if (!format) return "-" + className;
|
|
3353
|
+
if (typeof format === "function") return format({ className });
|
|
3354
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
|
|
3355
|
+
}
|
|
3356
|
+
function isExtractedScopeParentMarker$2(value) {
|
|
3357
|
+
return value === 1 || value === true;
|
|
2619
3358
|
}
|
|
2620
3359
|
//#endregion
|
|
2621
|
-
//#region
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
3360
|
+
//#region runtime/core/cache/itemWithResolver.ts
|
|
3361
|
+
function createResolvedStyleItemWithResolver(data, tokens, resolver) {
|
|
3362
|
+
return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
|
|
3363
|
+
}
|
|
3364
|
+
function getDirectStyleItemWithResolver(item, resolver) {
|
|
3365
|
+
return createResolvedStyleItemWithResolver(item, null, resolver);
|
|
3366
|
+
}
|
|
3367
|
+
function getDataTokenValues(data, resolver) {
|
|
3368
|
+
const stateItems = data[BUILDER_STATE]?.items ?? [];
|
|
3369
|
+
const values = createMutableTokenValues(null);
|
|
3370
|
+
for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
|
|
3371
|
+
return finishTokenValues(null, values);
|
|
3372
|
+
}
|
|
3373
|
+
createCacheValue();
|
|
3374
|
+
function createCacheValue() {
|
|
2627
3375
|
return {
|
|
2628
|
-
|
|
2629
|
-
|
|
3376
|
+
d: null,
|
|
3377
|
+
c: RUNTIME_CONFIG.changes
|
|
2630
3378
|
};
|
|
2631
3379
|
}
|
|
2632
|
-
createIdCounter("positionTry");
|
|
2633
3380
|
//#endregion
|
|
2634
|
-
//#region
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
}
|
|
3381
|
+
//#region runtime/core/cache/token.ts
|
|
3382
|
+
const runtimeTokenValueResolver = {
|
|
3383
|
+
get key() {
|
|
3384
|
+
return CSS_CONFIG.tokenNameFormat;
|
|
3385
|
+
},
|
|
3386
|
+
is: isStyleTokenOverrideData,
|
|
3387
|
+
id(token) {
|
|
3388
|
+
return getStyleTokenId(token);
|
|
3389
|
+
},
|
|
3390
|
+
value(token) {
|
|
3391
|
+
return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
function normalizeStylePropItem(item, stableTokenBound) {
|
|
3395
|
+
if (isElementDebugData(item)) return null;
|
|
3396
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3397
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3398
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
3399
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3400
|
+
if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
|
|
3401
|
+
return normalizeStylePropItem(bound.data, false);
|
|
3402
|
+
}
|
|
3403
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) return item;
|
|
3404
|
+
if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
|
|
3405
|
+
return null;
|
|
2643
3406
|
}
|
|
2644
|
-
|
|
3407
|
+
function getStylePropCacheKey(item, tokenBindings) {
|
|
3408
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
3409
|
+
const bound = getExtractedTokenBoundData(item);
|
|
3410
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
3411
|
+
const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
|
|
3412
|
+
if (key && tokens) tokenBindings.push({
|
|
3413
|
+
data: key,
|
|
3414
|
+
tokens
|
|
3415
|
+
});
|
|
3416
|
+
return key;
|
|
3417
|
+
}
|
|
3418
|
+
if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
|
|
3419
|
+
return null;
|
|
3420
|
+
}
|
|
3421
|
+
//#endregion
|
|
3422
|
+
//#region atomic/rule.ts
|
|
3423
|
+
function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
|
|
3424
|
+
const cssProp = getCssPropertyName(property);
|
|
3425
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
|
|
3426
|
+
const escapedClass = escapeCssIdent(className);
|
|
3427
|
+
const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
|
|
3428
|
+
const itemSelector = selector ? getSelectorText$1(selector) : "";
|
|
3429
|
+
let selectorStr = classSelector + itemSelector;
|
|
3430
|
+
if (parentSelector) {
|
|
3431
|
+
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
|
|
3432
|
+
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
3433
|
+
}
|
|
3434
|
+
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
3435
|
+
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
|
|
3436
|
+
return rule;
|
|
3437
|
+
}
|
|
3438
|
+
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
3439
|
+
const selectorPriority = getSelectorPriority$1(selector);
|
|
3440
|
+
const parentSelectorPriority = getSelectorPriority$1(parentSelector);
|
|
3441
|
+
const atRulePriority = getAtRulePriority$1(atRules);
|
|
3442
|
+
return [
|
|
3443
|
+
priority ?? 0,
|
|
3444
|
+
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
3445
|
+
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
3446
|
+
getMediaPriority(atRules, atRulePriority),
|
|
3447
|
+
atRules ? atRules.length : 0,
|
|
3448
|
+
isScopeRule && !parentSelector ? 1 : 0,
|
|
3449
|
+
getPropertyPriority(property)
|
|
3450
|
+
];
|
|
3451
|
+
}
|
|
3452
|
+
function getMediaPriority(atRules, priority) {
|
|
3453
|
+
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
3454
|
+
if (priority <= 0) return LayerMediaPriorities.media;
|
|
3455
|
+
return LayerMediaPriorities.priorityMedia + priority;
|
|
3456
|
+
}
|
|
3457
|
+
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
3458
|
+
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
3459
|
+
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
3460
|
+
return LayerSelectorPriorities.base;
|
|
3461
|
+
}
|
|
3462
|
+
function getParentSelectorPriority(parentSelector, priority) {
|
|
3463
|
+
if (!parentSelector) return 0;
|
|
3464
|
+
return priority > 0 ? priority + 1 : 1;
|
|
3465
|
+
}
|
|
3466
|
+
function getAtRulePriority$1(atRules) {
|
|
3467
|
+
if (!atRules?.length) return 0;
|
|
3468
|
+
let priority = 0;
|
|
3469
|
+
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
|
|
3470
|
+
return priority;
|
|
3471
|
+
}
|
|
3472
|
+
const formatThemeName = createNameFormatter(["name"]);
|
|
3473
|
+
function createThemeClassName(name, id, themeNameFormat) {
|
|
3474
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3475
|
+
}
|
|
3476
|
+
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3477
|
+
const declarations = [];
|
|
3478
|
+
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3479
|
+
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3480
|
+
}
|
|
3481
|
+
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3482
|
+
const name = getTokenVarName(token, tokenNameFormat);
|
|
3483
|
+
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3484
|
+
return name + ":" + value;
|
|
3485
|
+
}
|
|
3486
|
+
function normalizeThemeName(value) {
|
|
3487
|
+
if (!value) return null;
|
|
3488
|
+
value = value.trim();
|
|
3489
|
+
if (!value) return null;
|
|
3490
|
+
if (/^\d+$/.test(value)) return null;
|
|
3491
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3492
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3493
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3494
|
+
value = stripGenericThemePrefix(value);
|
|
3495
|
+
if (!value) return null;
|
|
3496
|
+
return value;
|
|
3497
|
+
}
|
|
3498
|
+
function stripGenericThemePrefix(value) {
|
|
3499
|
+
const parts = value.split("--");
|
|
3500
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3501
|
+
value = parts.join("--");
|
|
3502
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3503
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3504
|
+
return value;
|
|
3505
|
+
}
|
|
3506
|
+
function isGeneratedNameHash(value) {
|
|
3507
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3508
|
+
}
|
|
3509
|
+
createNameFormatter(["name"]);
|
|
3510
|
+
globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
|
|
2645
3511
|
//#endregion
|
|
2646
3512
|
//#region style/keyframes.ts
|
|
2647
3513
|
function transformKeyframes(frames, transform) {
|
|
@@ -2669,9 +3535,11 @@ function createStyleFn(args) {
|
|
|
2669
3535
|
const fnStyle = createStyleBuilder(selectors, transform);
|
|
2670
3536
|
const fnSlot = createSlotBuilder(selectors, transform);
|
|
2671
3537
|
const fnScope = createScopeBuilder(selectors);
|
|
2672
|
-
const
|
|
2673
|
-
|
|
3538
|
+
const fnSelector = createSelectorBuilder(selectors, transform);
|
|
3539
|
+
const fnWeight = (value, weight) => {
|
|
3540
|
+
return weightValue(value, weight);
|
|
2674
3541
|
};
|
|
3542
|
+
const fnImportant = (value) => importantValue(value);
|
|
2675
3543
|
const fnRaw = (style) => style;
|
|
2676
3544
|
const fnPlain = (style) => style;
|
|
2677
3545
|
const fnKeyframes = ((frames, stableId) => createStyleKeyframes(frames, transform ?? null, stableId));
|
|
@@ -2683,11 +3551,13 @@ function createStyleFn(args) {
|
|
|
2683
3551
|
const style = fnStyle;
|
|
2684
3552
|
style.slot = fnSlot;
|
|
2685
3553
|
style.scope = fnScope;
|
|
2686
|
-
style.
|
|
3554
|
+
style.weight = fnWeight;
|
|
3555
|
+
style.important = fnImportant;
|
|
2687
3556
|
style.raw = fnRaw;
|
|
2688
3557
|
style.plain = fnPlain;
|
|
2689
3558
|
style.keyframes = fnKeyframes;
|
|
2690
3559
|
style.merge = fnMerge;
|
|
3560
|
+
style.selector = fnSelector;
|
|
2691
3561
|
assignStyleFnMeta(style, {
|
|
2692
3562
|
mode: "StyleObject",
|
|
2693
3563
|
selectors,
|
|
@@ -2822,65 +3692,6 @@ function isGlobPattern(source) {
|
|
|
2822
3692
|
return /[*?[\]{}]/.test(source) || /[!+@?*]\(/.test(source);
|
|
2823
3693
|
}
|
|
2824
3694
|
//#endregion
|
|
2825
|
-
//#region builder/extract/utils.ts
|
|
2826
|
-
function createExtractedData(type, slotId) {
|
|
2827
|
-
const data = {
|
|
2828
|
-
[BUILDER_TYPE]: type,
|
|
2829
|
-
[BUILDER_STATE]: {
|
|
2830
|
-
items: [],
|
|
2831
|
-
lookup: {}
|
|
2832
|
-
},
|
|
2833
|
-
[BUILDER_CALLSITE]: null
|
|
2834
|
-
};
|
|
2835
|
-
if (slotId !== void 0) data[BUILDER_SLOT_ID] = slotId;
|
|
2836
|
-
return data;
|
|
2837
|
-
}
|
|
2838
|
-
function copyExtractedData(target, source) {
|
|
2839
|
-
const mutable = target;
|
|
2840
|
-
mutable[BUILDER_TYPE] = source[BUILDER_TYPE];
|
|
2841
|
-
mutable[BUILDER_STATE] = source[BUILDER_STATE];
|
|
2842
|
-
mutable[BUILDER_CALLSITE] = source[BUILDER_CALLSITE];
|
|
2843
|
-
if (source[BUILDER_SLOT_ID] !== void 0) mutable[BUILDER_SLOT_ID] = source[BUILDER_SLOT_ID];
|
|
2844
|
-
}
|
|
2845
|
-
function createExtractedScopeTarget(scope, slot) {
|
|
2846
|
-
return {
|
|
2847
|
-
[BUILDER_TYPE]: 5,
|
|
2848
|
-
[BUILDER_SCOPE]: scope,
|
|
2849
|
-
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
|
|
2850
|
-
};
|
|
2851
|
-
}
|
|
2852
|
-
function normalizeExtractedItems(type, slotId, items) {
|
|
2853
|
-
const normalized = [];
|
|
2854
|
-
let i = 0;
|
|
2855
|
-
while (i < items.length) {
|
|
2856
|
-
const item = items[i];
|
|
2857
|
-
const value = item[2];
|
|
2858
|
-
normalized.push(value === void 0 ? slotId === null ? [
|
|
2859
|
-
type,
|
|
2860
|
-
item[0],
|
|
2861
|
-
item[1]
|
|
2862
|
-
] : [
|
|
2863
|
-
type,
|
|
2864
|
-
slotId,
|
|
2865
|
-
item[0],
|
|
2866
|
-
item[1]
|
|
2867
|
-
] : slotId === null ? [
|
|
2868
|
-
type,
|
|
2869
|
-
item[0],
|
|
2870
|
-
item[1],
|
|
2871
|
-
value
|
|
2872
|
-
] : [
|
|
2873
|
-
type,
|
|
2874
|
-
slotId,
|
|
2875
|
-
item[0],
|
|
2876
|
-
item[1],
|
|
2877
|
-
value
|
|
2878
|
-
]);
|
|
2879
|
-
i++;
|
|
2880
|
-
}
|
|
2881
|
-
return normalized;
|
|
2882
|
-
}
|
|
2883
|
-
//#endregion
|
|
2884
3695
|
//#region builder/extract/scope.ts
|
|
2885
3696
|
function createExtractedScope(items) {
|
|
2886
3697
|
const scope = ((slot) => {
|
|
@@ -2891,6 +3702,15 @@ function createExtractedScope(items) {
|
|
|
2891
3702
|
return scope;
|
|
2892
3703
|
}
|
|
2893
3704
|
//#endregion
|
|
3705
|
+
//#region builder/extract/sheet.ts
|
|
3706
|
+
function createExtractedSheet(items) {
|
|
3707
|
+
const data = createExtractedData(9);
|
|
3708
|
+
const normalizedItems = items.filter((item) => Array.isArray(item));
|
|
3709
|
+
const tokenItems = items.filter((item) => !Array.isArray(item));
|
|
3710
|
+
data[BUILDER_STATE].items = [...tokenItems, ...normalizeExtractedItems(9, null, normalizedItems)];
|
|
3711
|
+
return data;
|
|
3712
|
+
}
|
|
3713
|
+
//#endregion
|
|
2894
3714
|
//#region builder/extract/slot.ts
|
|
2895
3715
|
function createExtractedSlot(slotId, items) {
|
|
2896
3716
|
const slot = ((items) => {
|
|
@@ -2964,15 +3784,12 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2964
3784
|
}
|
|
2965
3785
|
}
|
|
2966
3786
|
//#endregion
|
|
2967
|
-
//#region style/value.ts
|
|
2968
|
-
function createToken(value, debugId) {
|
|
2969
|
-
return createStyleToken(value, debugId);
|
|
2970
|
-
}
|
|
2971
|
-
//#endregion
|
|
2972
3787
|
//#region dialect/namedTokens.ts
|
|
2973
3788
|
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
2974
3789
|
function createNamedToken(id, value) {
|
|
2975
|
-
|
|
3790
|
+
const token = createStyleToken(value, createNamedTokenId(id));
|
|
3791
|
+
token[TOKEN_VAR_NAME] = getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3792
|
+
return token;
|
|
2976
3793
|
}
|
|
2977
3794
|
function createNamedTokens(namespace, values) {
|
|
2978
3795
|
return createNamedTokenProxy({
|
|
@@ -2991,7 +3808,7 @@ function createNamedTokenProxy(root, path) {
|
|
|
2991
3808
|
if (property === ROOT) return root;
|
|
2992
3809
|
if (property === "then") return void 0;
|
|
2993
3810
|
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
2994
|
-
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3811
|
+
if (property === TOKEN_ID || property === TOKEN_NAME || property === TOKEN_VAR_NAME || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
2995
3812
|
if (!path.length) return void 0;
|
|
2996
3813
|
return getNamedTokenAtPath(root, path)[property];
|
|
2997
3814
|
}
|
|
@@ -3037,7 +3854,7 @@ function exposeStyleObject(source) {
|
|
|
3037
3854
|
return result;
|
|
3038
3855
|
}
|
|
3039
3856
|
function exposeStyleValue(value) {
|
|
3040
|
-
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
3857
|
+
if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
|
|
3041
3858
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3042
3859
|
const exposed = exposeStyleObject(value);
|
|
3043
3860
|
return Reflect.ownKeys(exposed).length > 0 ? exposed : void 0;
|
|
@@ -3251,6 +4068,12 @@ function evaluateCall(node, scope) {
|
|
|
3251
4068
|
if (!Array.isArray(items.value)) return evalFail("createExtractedStyle items must be an array");
|
|
3252
4069
|
return evalOk(createExtractedStyle(items.value));
|
|
3253
4070
|
}
|
|
4071
|
+
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "createExtractedSheet") {
|
|
4072
|
+
const items = evaluateNode(node.arguments[0], scope);
|
|
4073
|
+
if (!items.ok) return items;
|
|
4074
|
+
if (!Array.isArray(items.value)) return evalFail("createExtractedSheet items must be an array");
|
|
4075
|
+
return evalOk(createExtractedSheet(items.value));
|
|
4076
|
+
}
|
|
3254
4077
|
if (imp && imp.source === "@fluentic/style/entry/prod/extract" && imp.name === "getExtractedStyleItems") {
|
|
3255
4078
|
const style = evaluateNode(node.arguments[0], scope);
|
|
3256
4079
|
if (!style.ok) return style;
|
|
@@ -3282,9 +4105,9 @@ function evaluateCall(node, scope) {
|
|
|
3282
4105
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createToken") {
|
|
3283
4106
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3284
4107
|
if (!value.ok) return value;
|
|
3285
|
-
const
|
|
3286
|
-
if (!
|
|
3287
|
-
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node,
|
|
4108
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
4109
|
+
if (!stableId.ok) return stableId;
|
|
4110
|
+
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3288
4111
|
}
|
|
3289
4112
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createKeyframes") {
|
|
3290
4113
|
const frames = evaluateNode(node.arguments[0], scope);
|
|
@@ -3351,16 +4174,16 @@ function evaluateCall(node, scope) {
|
|
|
3351
4174
|
const url = evaluateNode(node.arguments[0], scope);
|
|
3352
4175
|
if (!url.ok) return evalFail(`fontSrc url must be statically analyzable: ${url.reason}`);
|
|
3353
4176
|
if (typeof url.value !== "string") return evalFail("fontSrc url must be a static string");
|
|
3354
|
-
const format =
|
|
4177
|
+
const format = evaluateOptionalString(node.arguments[1], scope);
|
|
3355
4178
|
if (!format.ok) return evalFail(`fontSrc format must be statically analyzable: ${format.reason}`);
|
|
3356
4179
|
return evalOk(fontSrc(url.value, format.value));
|
|
3357
4180
|
}
|
|
3358
4181
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createTokens") {
|
|
3359
4182
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3360
4183
|
if (!value.ok) return value;
|
|
3361
|
-
const
|
|
3362
|
-
if (!
|
|
3363
|
-
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node,
|
|
4184
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
4185
|
+
if (!stableId.ok) return stableId;
|
|
4186
|
+
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3364
4187
|
}
|
|
3365
4188
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3366
4189
|
const id = evaluateNode(node.arguments[0], scope);
|
|
@@ -3388,13 +4211,13 @@ function evaluateCall(node, scope) {
|
|
|
3388
4211
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createValues") {
|
|
3389
4212
|
const hasNumberArg = node.arguments[0]?.type === "Identifier" && node.arguments[0].name === "Number";
|
|
3390
4213
|
const valuesNode = hasNumberArg ? node.arguments[1] : node.arguments[0];
|
|
3391
|
-
const
|
|
4214
|
+
const stableIdNode = hasNumberArg ? node.arguments[2] : node.arguments[1];
|
|
3392
4215
|
const values = evaluateNode(valuesNode, scope);
|
|
3393
4216
|
if (!values.ok) return values;
|
|
3394
|
-
const
|
|
3395
|
-
if (!
|
|
4217
|
+
const stableId = evaluateOptionalStableTokenId(stableIdNode, scope);
|
|
4218
|
+
if (!stableId.ok) return stableId;
|
|
3396
4219
|
if (!Array.isArray(values.value)) return evalFail("createValues values must be an array");
|
|
3397
|
-
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node,
|
|
4220
|
+
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node, stableId.value, hasNumberArg));
|
|
3398
4221
|
}
|
|
3399
4222
|
}
|
|
3400
4223
|
if (node.callee.type === "Identifier") {
|
|
@@ -3439,13 +4262,18 @@ function evaluateCall(node, scope) {
|
|
|
3439
4262
|
buildCss: (_name, tokens, tokenLookup, options) => buildKeyframesCss(format, stable.name, stable.id, transformedFrames, tokens, tokenLookup, options)
|
|
3440
4263
|
}));
|
|
3441
4264
|
}
|
|
3442
|
-
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "
|
|
4265
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "weight" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
3443
4266
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3444
4267
|
if (!value.ok) return value;
|
|
3445
4268
|
const weight = evaluateNode(node.arguments[1], scope);
|
|
3446
4269
|
if (!weight.ok) return weight;
|
|
3447
|
-
if (typeof weight.value !== "number") return evalFail(
|
|
3448
|
-
return evalOk(
|
|
4270
|
+
if (typeof weight.value !== "number") return evalFail(`${node.callee.property.name} weight must be a number`);
|
|
4271
|
+
return evalOk(weightValue(value.value, weight.value));
|
|
4272
|
+
}
|
|
4273
|
+
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && node.callee.property.name === "important" && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) {
|
|
4274
|
+
const value = evaluateNode(node.arguments[0], scope);
|
|
4275
|
+
if (!value.ok) return value;
|
|
4276
|
+
return evalOk(importantValue(value.value));
|
|
3449
4277
|
}
|
|
3450
4278
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && (node.callee.property.name === "raw" || node.callee.property.name === "plain") && node.callee.object.type === "Identifier" && scope.styleNames?.has(node.callee.object.name)) return evaluateNode(node.arguments[0], scope);
|
|
3451
4279
|
return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
@@ -3482,38 +4310,48 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
|
|
|
3482
4310
|
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
3483
4311
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3484
4312
|
[TOKEN_OVERRIDE]: true,
|
|
4313
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3485
4314
|
value: value.value,
|
|
3486
4315
|
ref: value
|
|
3487
4316
|
});
|
|
3488
4317
|
return withRuntimeValue(runtimeValue, {
|
|
3489
4318
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3490
4319
|
[TOKEN_OVERRIDE]: true,
|
|
4320
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3491
4321
|
value,
|
|
3492
4322
|
ref: null
|
|
3493
4323
|
});
|
|
3494
4324
|
}
|
|
3495
|
-
function createCompiledToken(value, scope, loc, runtimeValue,
|
|
3496
|
-
let tokenId =
|
|
4325
|
+
function createCompiledToken(value, scope, loc, runtimeValue, stableId, debugName) {
|
|
4326
|
+
let tokenId = stableId;
|
|
3497
4327
|
if (!tokenId) tokenId = hashString((scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value)));
|
|
4328
|
+
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
4329
|
+
[TOKEN_ID]: tokenId,
|
|
4330
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
4331
|
+
value: value.value,
|
|
4332
|
+
ref: value
|
|
4333
|
+
});
|
|
3498
4334
|
return withRuntimeValue(runtimeValue, {
|
|
3499
4335
|
[TOKEN_ID]: tokenId,
|
|
4336
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
3500
4337
|
value,
|
|
3501
4338
|
ref: null
|
|
3502
4339
|
});
|
|
3503
4340
|
}
|
|
3504
|
-
function createCompiledTokens(value, scope, loc, runtimeValue,
|
|
3505
|
-
const tokenGroupId =
|
|
4341
|
+
function createCompiledTokens(value, scope, loc, runtimeValue, stableId) {
|
|
4342
|
+
const tokenGroupId = stableId ?? createCompiledTokenGroupId(scope, loc);
|
|
4343
|
+
const tokenGroupName = getStyleTokenNameFromId(stableId);
|
|
3506
4344
|
if (Array.isArray(value)) {
|
|
3507
4345
|
const result = {};
|
|
3508
4346
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
3509
4347
|
const item = value[i];
|
|
3510
|
-
result[item] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
4348
|
+
result[item] = createCompiledToken(item, scope, loc, runtimeValue, getChildStableId(tokenGroupId, String(i)), getChildStyleTokenName(tokenGroupName, String(i)));
|
|
3511
4349
|
}
|
|
3512
4350
|
return result;
|
|
3513
4351
|
}
|
|
3514
4352
|
if (!value || typeof value !== "object") return {};
|
|
3515
4353
|
const result = {};
|
|
3516
|
-
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId);
|
|
4354
|
+
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId, tokenGroupName);
|
|
3517
4355
|
return result;
|
|
3518
4356
|
}
|
|
3519
4357
|
function createCompiledTokenGroupId(scope, loc) {
|
|
@@ -3525,22 +4363,24 @@ function createCompiledAtRuleStableId(scope, loc, value) {
|
|
|
3525
4363
|
id: (scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value))
|
|
3526
4364
|
};
|
|
3527
4365
|
}
|
|
3528
|
-
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue,
|
|
4366
|
+
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, stableId, debugName) {
|
|
3529
4367
|
for (const key of Object.keys(value)) {
|
|
3530
4368
|
const item = value[key];
|
|
3531
|
-
const
|
|
4369
|
+
const itemStableId = getChildStableId(stableId, key);
|
|
4370
|
+
const itemDebugName = getChildStyleTokenName(debugName, key);
|
|
3532
4371
|
if (item && typeof item === "object" && !Array.isArray(item) && !isStyleTokenData(item)) {
|
|
3533
4372
|
const child = {};
|
|
3534
4373
|
target[key] = child;
|
|
3535
|
-
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue,
|
|
3536
|
-
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
4374
|
+
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
4375
|
+
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
3537
4376
|
}
|
|
3538
4377
|
}
|
|
3539
|
-
function createCompiledValues(values, scope, loc, runtimeValue,
|
|
4378
|
+
function createCompiledValues(values, scope, loc, runtimeValue, stableId, isNumber) {
|
|
3540
4379
|
const tokens = /* @__PURE__ */ new Map();
|
|
4380
|
+
const groupName = getStyleTokenNameFromId(stableId);
|
|
3541
4381
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
3542
4382
|
const value = values[i];
|
|
3543
|
-
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue,
|
|
4383
|
+
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue, getChildStableId(stableId, hashString(String(value))), getChildStyleTokenName(groupName, getValueDebugName(value))));
|
|
3544
4384
|
}
|
|
3545
4385
|
return {
|
|
3546
4386
|
[COMPILED_TOKEN_FACTORY]: true,
|
|
@@ -3558,7 +4398,10 @@ function parseCompiledValue(value, isNumber) {
|
|
|
3558
4398
|
function isCompiledTokenFactory(value) {
|
|
3559
4399
|
return !!value && typeof value === "object" && value[COMPILED_TOKEN_FACTORY] === true;
|
|
3560
4400
|
}
|
|
3561
|
-
function
|
|
4401
|
+
function evaluateOptionalStableTokenId(node, scope) {
|
|
4402
|
+
return evaluateOptionalString(node, scope);
|
|
4403
|
+
}
|
|
4404
|
+
function evaluateOptionalString(node, scope) {
|
|
3562
4405
|
if (!node) return evalOk(void 0);
|
|
3563
4406
|
const value = evaluateNode(node, scope);
|
|
3564
4407
|
if (!value.ok) return value;
|
|
@@ -3582,12 +4425,24 @@ function evaluateOptionalStableId(node, scope) {
|
|
|
3582
4425
|
id: stableId.id
|
|
3583
4426
|
});
|
|
3584
4427
|
}
|
|
3585
|
-
function
|
|
3586
|
-
return
|
|
4428
|
+
function getChildStableId(stableId, child) {
|
|
4429
|
+
return stableId ? stableId + "--" + child : void 0;
|
|
4430
|
+
}
|
|
4431
|
+
function getValueDebugName(value) {
|
|
4432
|
+
if (typeof value === "number") return String(value);
|
|
4433
|
+
if (typeof value !== "string") return null;
|
|
4434
|
+
const parts = value.split(/[;|]/);
|
|
4435
|
+
const label = parts[1]?.trim();
|
|
4436
|
+
if (label) return sanitizeTokenDebugName(label);
|
|
4437
|
+
return sanitizeTokenDebugName(parts[0]?.trim() ?? "");
|
|
4438
|
+
}
|
|
4439
|
+
function sanitizeTokenDebugName(value) {
|
|
4440
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || null;
|
|
3587
4441
|
}
|
|
3588
4442
|
function withRuntimeValue(runtimeValue, token) {
|
|
3589
4443
|
return Object.assign({}, token, {
|
|
3590
4444
|
[TOKEN_ID]: token[TOKEN_ID],
|
|
4445
|
+
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
3591
4446
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3592
4447
|
});
|
|
3593
4448
|
}
|
|
@@ -3623,14 +4478,14 @@ function evaluateUnary(node, scope) {
|
|
|
3623
4478
|
function isStaticStyleValue(value) {
|
|
3624
4479
|
if (value.type === "StringLiteral" || value.type === "NumericLiteral" || value.type === "BooleanLiteral" || value.type === "NullLiteral") return true;
|
|
3625
4480
|
if (value.type === "TemplateLiteral") return value.expressions.length === 0;
|
|
3626
|
-
if (value.type === "
|
|
3627
|
-
const [priority, itemValue] = value.elements;
|
|
3628
|
-
return !!priority && priority.type === "NumericLiteral" && !!itemValue && isStaticStyleValue(itemValue);
|
|
3629
|
-
}
|
|
3630
|
-
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "value") {
|
|
4481
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "weight") {
|
|
3631
4482
|
const [itemValue, weight] = value.arguments;
|
|
3632
4483
|
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue) && !!weight && weight.type === "NumericLiteral";
|
|
3633
4484
|
}
|
|
4485
|
+
if (value.type === "CallExpression" && value.callee.type === "MemberExpression" && !value.callee.computed && value.callee.property.type === "Identifier" && value.callee.property.name === "important") {
|
|
4486
|
+
const [itemValue] = value.arguments;
|
|
4487
|
+
return !!itemValue && itemValue.type !== "SpreadElement" && isStaticStyleValue(itemValue);
|
|
4488
|
+
}
|
|
3634
4489
|
if (value.type === "UnaryExpression") return isStaticStyleValue(value.argument);
|
|
3635
4490
|
return false;
|
|
3636
4491
|
}
|
|
@@ -3645,20 +4500,6 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3645
4500
|
if (object.type === "MemberExpression") return isStyleChainCall(object, styleNames);
|
|
3646
4501
|
return false;
|
|
3647
4502
|
}
|
|
3648
|
-
const formatThemeName = createNameFormatter(["name"]);
|
|
3649
|
-
function createThemeClassName(name, id, themeNameFormat) {
|
|
3650
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3651
|
-
}
|
|
3652
|
-
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3653
|
-
const declarations = [];
|
|
3654
|
-
for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
|
|
3655
|
-
return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
|
|
3656
|
-
}
|
|
3657
|
-
function getThemeDeclaration(token, tokenNameFormat) {
|
|
3658
|
-
const name = getTokenVarName(token, tokenNameFormat);
|
|
3659
|
-
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3660
|
-
return name + ":" + value;
|
|
3661
|
-
}
|
|
3662
4503
|
//#endregion
|
|
3663
4504
|
//#region compiler/transform/syntax/utils.ts
|
|
3664
4505
|
function getCallLabel(callee) {
|
|
@@ -3793,60 +4634,6 @@ function sanitizeTokenId(value) {
|
|
|
3793
4634
|
return sanitizeCssIdentName(value, "token");
|
|
3794
4635
|
}
|
|
3795
4636
|
//#endregion
|
|
3796
|
-
//#region compiler/transform/utils/babel.ts
|
|
3797
|
-
function babelPlugin(factory) {
|
|
3798
|
-
return factory;
|
|
3799
|
-
}
|
|
3800
|
-
function babelTransform(args) {
|
|
3801
|
-
let result = null;
|
|
3802
|
-
try {
|
|
3803
|
-
const inputSourceMap = parseInputSourceMap(args.sourcemap);
|
|
3804
|
-
result = BabelCore.transformSync(args.code, {
|
|
3805
|
-
...babelTransformOptions(),
|
|
3806
|
-
inputSourceMap,
|
|
3807
|
-
filename: args.filePath,
|
|
3808
|
-
sourceFileName: args.filePath,
|
|
3809
|
-
plugins: args.plugins,
|
|
3810
|
-
sourceMaps: true,
|
|
3811
|
-
generatorOpts: { retainLines: args.retainLines ?? false }
|
|
3812
|
-
});
|
|
3813
|
-
} catch (err) {
|
|
3814
|
-
if (!args.errorLabel) throw err;
|
|
3815
|
-
const message = getBabelError(err, args);
|
|
3816
|
-
const error = new Error(message);
|
|
3817
|
-
error.stack = void 0;
|
|
3818
|
-
throw error;
|
|
3819
|
-
}
|
|
3820
|
-
if (!result || !result.code) return null;
|
|
3821
|
-
return {
|
|
3822
|
-
code: result.code,
|
|
3823
|
-
sourcemap: result.map ? JSON.stringify(result.map) : null
|
|
3824
|
-
};
|
|
3825
|
-
}
|
|
3826
|
-
function babelTransformOptions() {
|
|
3827
|
-
return {
|
|
3828
|
-
configFile: false,
|
|
3829
|
-
babelrc: false,
|
|
3830
|
-
parserOpts: {
|
|
3831
|
-
plugins: ["typescript", "jsx"],
|
|
3832
|
-
strictMode: false,
|
|
3833
|
-
allowImportExportEverywhere: true
|
|
3834
|
-
}
|
|
3835
|
-
};
|
|
3836
|
-
}
|
|
3837
|
-
function parseInputSourceMap(sourcemap) {
|
|
3838
|
-
if (!sourcemap) return void 0;
|
|
3839
|
-
if (typeof sourcemap !== "string") return sourcemap;
|
|
3840
|
-
return JSON.parse(sourcemap);
|
|
3841
|
-
}
|
|
3842
|
-
function getBabelError(err, args) {
|
|
3843
|
-
const babelErr = err;
|
|
3844
|
-
const msg = babelErr instanceof Error ? babelErr.message : String(err);
|
|
3845
|
-
const codeFrame = babelErr?.codeFrame;
|
|
3846
|
-
const suffix = codeFrame ? `\n\n${codeFrame}` : "";
|
|
3847
|
-
return `${args.errorLabel} in ${args.filePath}:\n${msg}${suffix}`;
|
|
3848
|
-
}
|
|
3849
|
-
//#endregion
|
|
3850
4637
|
//#region compiler/utils/path.ts
|
|
3851
4638
|
function normalizePath(value) {
|
|
3852
4639
|
return value.replace(/\\/g, "/");
|
|
@@ -4384,14 +5171,16 @@ function getSelectorMethodPath(path) {
|
|
|
4384
5171
|
function getDebugStyleArg(t, path, state, sourcemapTrace) {
|
|
4385
5172
|
const arg = getStyleObjectArg(path, state);
|
|
4386
5173
|
if (!arg) return arg;
|
|
5174
|
+
const meta = getStyleCallMeta(path, state);
|
|
4387
5175
|
if (arg.type !== "ObjectExpression") return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
4388
|
-
return flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set());
|
|
5176
|
+
return appendTransformDebugFieldAliases(t, flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set()), meta, state);
|
|
4389
5177
|
}
|
|
4390
5178
|
function getDebugCallLoc(path, state) {
|
|
4391
5179
|
return isSelectorStyleCall(path, state) || isScopeItemSelectorCall(path, state) ? getMergeStyleLoc(path.node.callee) : null;
|
|
4392
5180
|
}
|
|
4393
5181
|
function getStyleObjectArg(path, state) {
|
|
4394
5182
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
5183
|
+
if (methodName === "selector") return path.node.arguments[1];
|
|
4395
5184
|
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4396
5185
|
const selector = methodName && rootName ? state.styleMetas.get(rootName)?.selectors[methodName] : null;
|
|
4397
5186
|
if (!selector) return path.node.arguments[0];
|
|
@@ -4399,6 +5188,10 @@ function getStyleObjectArg(path, state) {
|
|
|
4399
5188
|
const styleArgIndex = selectorArgIndex === null ? 0 : selectorArgIndex + 1;
|
|
4400
5189
|
return path.node.arguments[styleArgIndex];
|
|
4401
5190
|
}
|
|
5191
|
+
function getStyleCallMeta(path, state) {
|
|
5192
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
5193
|
+
return rootName ? state.styleMetas.get(rootName) ?? null : null;
|
|
5194
|
+
}
|
|
4402
5195
|
function isSelectorStyleCall(path, state) {
|
|
4403
5196
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
4404
5197
|
if (!methodName) return false;
|
|
@@ -4503,6 +5296,46 @@ function flattenDebugObjectExpression(t, node, path, state, sourcemapTrace, seen
|
|
|
4503
5296
|
}
|
|
4504
5297
|
return t.objectExpression(properties);
|
|
4505
5298
|
}
|
|
5299
|
+
function appendTransformDebugFieldAliases(t, node, meta, state) {
|
|
5300
|
+
if (!meta || meta.mode !== "StyleObject" || !meta.transform) return node;
|
|
5301
|
+
const existing = /* @__PURE__ */ new Set();
|
|
5302
|
+
for (const property of node.properties) {
|
|
5303
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
5304
|
+
const key = getObjectPropertyKey$1(property);
|
|
5305
|
+
if (key) existing.add(key);
|
|
5306
|
+
}
|
|
5307
|
+
const aliases = [];
|
|
5308
|
+
for (const property of node.properties) {
|
|
5309
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
5310
|
+
const key = getObjectPropertyKey$1(property);
|
|
5311
|
+
if (!key) continue;
|
|
5312
|
+
const value = evaluateNode(property.value, getDebugEvalScope(state));
|
|
5313
|
+
if (!value.ok) continue;
|
|
5314
|
+
let transformed;
|
|
5315
|
+
try {
|
|
5316
|
+
transformed = meta.transform.transform({ [key]: value.value });
|
|
5317
|
+
} catch {
|
|
5318
|
+
continue;
|
|
5319
|
+
}
|
|
5320
|
+
for (const transformedKey of Object.keys(transformed)) {
|
|
5321
|
+
if (existing.has(transformedKey)) continue;
|
|
5322
|
+
existing.add(transformedKey);
|
|
5323
|
+
aliases.push(createDebugFieldAlias(t, transformedKey, property));
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5326
|
+
if (!aliases.length) return node;
|
|
5327
|
+
return t.objectExpression([...node.properties, ...aliases]);
|
|
5328
|
+
}
|
|
5329
|
+
function createDebugFieldAlias(t, key, source) {
|
|
5330
|
+
const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral());
|
|
5331
|
+
const sourceTrace = source;
|
|
5332
|
+
alias.loc = source.loc;
|
|
5333
|
+
alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
|
|
5334
|
+
alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
|
|
5335
|
+
alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
|
|
5336
|
+
alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
|
|
5337
|
+
return alias;
|
|
5338
|
+
}
|
|
4506
5339
|
function resolveDebugSpreadObject(t, spread, path, state, sourcemapTrace, seen) {
|
|
4507
5340
|
const node = spread.argument;
|
|
4508
5341
|
if (node.type !== "Identifier") return null;
|
|
@@ -4772,7 +5605,7 @@ function transformDebug(internal, args, deps) {
|
|
|
4772
5605
|
code: args.code,
|
|
4773
5606
|
filePath: args.filePath,
|
|
4774
5607
|
sourcemap: args.sourcemap,
|
|
4775
|
-
plugins: [plugin],
|
|
5608
|
+
plugins: [plugin, createCssPropPlugin({ options })],
|
|
4776
5609
|
retainLines: true
|
|
4777
5610
|
});
|
|
4778
5611
|
if (!result) return null;
|
|
@@ -4841,59 +5674,18 @@ function resolveFilePath(source, fromFile) {
|
|
|
4841
5674
|
}
|
|
4842
5675
|
}
|
|
4843
5676
|
//#endregion
|
|
4844
|
-
//#region
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText(parentSelector)})`;
|
|
4853
|
-
selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
|
|
4854
|
-
}
|
|
4855
|
-
let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
|
|
4856
|
-
if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText(atRules[i])}{${rule}}`;
|
|
4857
|
-
return rule;
|
|
4858
|
-
}
|
|
4859
|
-
function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
|
|
4860
|
-
const selectorPriority = getSelectorPriority(selector);
|
|
4861
|
-
const parentSelectorPriority = getSelectorPriority(parentSelector);
|
|
4862
|
-
const atRulePriority = getAtRulePriority$1(atRules);
|
|
4863
|
-
return [
|
|
4864
|
-
priority ?? 0,
|
|
4865
|
-
getLayerSelectorPriority(selector, parentSelector, selectorPriority),
|
|
4866
|
-
getParentSelectorPriority(parentSelector, parentSelectorPriority),
|
|
4867
|
-
getMediaPriority(atRules, atRulePriority),
|
|
4868
|
-
atRules ? atRules.length : 0,
|
|
4869
|
-
isScopeRule && !parentSelector ? 1 : 0,
|
|
4870
|
-
getPropertyPriority(property)
|
|
4871
|
-
];
|
|
4872
|
-
}
|
|
4873
|
-
function getMediaPriority(atRules, priority) {
|
|
4874
|
-
if (!atRules?.length) return LayerMediaPriorities.base;
|
|
4875
|
-
if (priority <= 0) return LayerMediaPriorities.media;
|
|
4876
|
-
return LayerMediaPriorities.priorityMedia + priority;
|
|
4877
|
-
}
|
|
4878
|
-
function getLayerSelectorPriority(selector, parentSelector, priority) {
|
|
4879
|
-
if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
|
|
4880
|
-
if (parentSelector) return LayerSelectorPriorities.parentSelector;
|
|
4881
|
-
return LayerSelectorPriorities.base;
|
|
4882
|
-
}
|
|
4883
|
-
function getParentSelectorPriority(parentSelector, priority) {
|
|
4884
|
-
if (!parentSelector) return 0;
|
|
4885
|
-
return priority > 0 ? priority + 1 : 1;
|
|
4886
|
-
}
|
|
4887
|
-
function getAtRulePriority$1(atRules) {
|
|
4888
|
-
if (!atRules?.length) return 0;
|
|
4889
|
-
let priority = 0;
|
|
4890
|
-
for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority(atRules[i]));
|
|
4891
|
-
return priority;
|
|
4892
|
-
}
|
|
5677
|
+
//#region compiler/compiler/constants.ts
|
|
5678
|
+
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
5679
|
+
CompilerRuntimeMode["Dev"] = "dev";
|
|
5680
|
+
CompilerRuntimeMode["Prod"] = "prod";
|
|
5681
|
+
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
5682
|
+
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
5683
|
+
return CompilerRuntimeMode;
|
|
5684
|
+
}({});
|
|
4893
5685
|
//#endregion
|
|
4894
5686
|
//#region compiler/transform/extract/chain/extract_chain.ts
|
|
4895
5687
|
const STATIC_MERGE_METHOD = "$$style.merge";
|
|
4896
|
-
function extractStyleChain(node, styleNames) {
|
|
5688
|
+
function extractStyleChain(node, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
4897
5689
|
if (node.type !== "CallExpression") return null;
|
|
4898
5690
|
const callee = node.callee;
|
|
4899
5691
|
if (callee.type === "Identifier" && styleNames.has(callee.name)) return {
|
|
@@ -4902,6 +5694,12 @@ function extractStyleChain(node, styleNames) {
|
|
|
4902
5694
|
baseArgs: node.arguments,
|
|
4903
5695
|
methods: []
|
|
4904
5696
|
};
|
|
5697
|
+
if (callee.type === "Identifier" && sheetNames.has(callee.name)) return {
|
|
5698
|
+
kind: "sheet",
|
|
5699
|
+
rootName: callee.name,
|
|
5700
|
+
baseArgs: node.arguments,
|
|
5701
|
+
methods: []
|
|
5702
|
+
};
|
|
4905
5703
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
4906
5704
|
const prop = callee.property.type === "Identifier" ? callee.property.name : null;
|
|
4907
5705
|
if (!prop) return null;
|
|
@@ -4919,10 +5717,16 @@ function extractStyleChain(node, styleNames) {
|
|
|
4919
5717
|
baseArgs: node.arguments,
|
|
4920
5718
|
methods: []
|
|
4921
5719
|
};
|
|
5720
|
+
if (prop === "selector") return {
|
|
5721
|
+
kind: "selector",
|
|
5722
|
+
rootName: obj.name,
|
|
5723
|
+
baseArgs: node.arguments,
|
|
5724
|
+
methods: []
|
|
5725
|
+
};
|
|
4922
5726
|
if (prop !== "merge") return null;
|
|
4923
5727
|
const target = node.arguments[0];
|
|
4924
5728
|
if (!target) return null;
|
|
4925
|
-
const targetChain = extractStyleChain(target, styleNames);
|
|
5729
|
+
const targetChain = extractStyleChain(target, styleNames, sheetNames);
|
|
4926
5730
|
if (!targetChain) return null;
|
|
4927
5731
|
return {
|
|
4928
5732
|
...targetChain,
|
|
@@ -4934,7 +5738,7 @@ function extractStyleChain(node, styleNames) {
|
|
|
4934
5738
|
};
|
|
4935
5739
|
}
|
|
4936
5740
|
if (obj.type === "CallExpression") {
|
|
4937
|
-
const inner = extractStyleChain(obj, styleNames);
|
|
5741
|
+
const inner = extractStyleChain(obj, styleNames, sheetNames);
|
|
4938
5742
|
if (!inner) return null;
|
|
4939
5743
|
return {
|
|
4940
5744
|
...inner,
|
|
@@ -4958,18 +5762,17 @@ function applyTransform(styleObj, transform, cssConfig) {
|
|
|
4958
5762
|
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
4959
5763
|
let result = null;
|
|
4960
5764
|
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
4961
|
-
const
|
|
5765
|
+
const weighted = isStyleWeightValue(rawValue) ? rawValue : null;
|
|
5766
|
+
const runtimeValue = getCompiledRuntimeValue(weighted ? weighted.value : rawValue);
|
|
4962
5767
|
if (!runtimeValue) continue;
|
|
4963
5768
|
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
4964
5769
|
if (transformedRuntimeValue === runtimeValue) continue;
|
|
4965
5770
|
result ??= cloneCompiledStyleObject(styleObj);
|
|
4966
|
-
|
|
5771
|
+
const transformed = createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5772
|
+
result[property] = weighted ? weightValue(transformed, weighted.weight) : transformed;
|
|
4967
5773
|
}
|
|
4968
5774
|
return result ?? styleObj;
|
|
4969
5775
|
}
|
|
4970
|
-
function getPriorityTupleValue(value) {
|
|
4971
|
-
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
4972
|
-
}
|
|
4973
5776
|
function cloneCompiledStyleObject(styleObj) {
|
|
4974
5777
|
const cloned = { ...styleObj };
|
|
4975
5778
|
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
@@ -5052,6 +5855,8 @@ function carryTransformedLocations(input, transformed, transform) {
|
|
|
5052
5855
|
*/
|
|
5053
5856
|
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5054
5857
|
const css = getCssConfig(opts, runtimeMode);
|
|
5858
|
+
if (chain.kind === "sheet") return compileSheetChain(chain, fileId, scope, css, opts);
|
|
5859
|
+
if (!meta) return null;
|
|
5055
5860
|
if (meta.mode === "ClassName") {
|
|
5056
5861
|
if (chain.kind !== "style") return null;
|
|
5057
5862
|
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
@@ -5063,11 +5868,91 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, st
|
|
|
5063
5868
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
5064
5869
|
return null;
|
|
5065
5870
|
}
|
|
5871
|
+
function compileSheetChain(chain, fileId, scope, cssConfig, options) {
|
|
5872
|
+
if (chain.methods.length > 0 || chain.baseArgs.length > 1) return null;
|
|
5873
|
+
const items = [];
|
|
5874
|
+
const rules = [];
|
|
5875
|
+
const sheetItems = chain.baseArgs[0];
|
|
5876
|
+
if (sheetItems && !compileSheetItemsArg(sheetItems, fileId, scope, cssConfig, options, items, rules)) return null;
|
|
5877
|
+
return {
|
|
5878
|
+
type: "sheet",
|
|
5879
|
+
items,
|
|
5880
|
+
rules
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
function compileSheetItemsArg(node, fileId, scope, cssConfig, options, items, rules) {
|
|
5884
|
+
if (node.type === "ArrayExpression") {
|
|
5885
|
+
for (const element of node.elements) {
|
|
5886
|
+
if (!element) continue;
|
|
5887
|
+
if (element.type === "SpreadElement") return false;
|
|
5888
|
+
if (!compileSheetItemsArg(element, fileId, scope, cssConfig, options, items, rules)) return false;
|
|
5889
|
+
}
|
|
5890
|
+
return true;
|
|
5891
|
+
}
|
|
5892
|
+
const tokenOverride = evaluateNode(node, scope);
|
|
5893
|
+
if (tokenOverride.ok && isStyleTokenOverrideData(tokenOverride.value)) {
|
|
5894
|
+
addCompiledTokenItem(getStyleTokenId(tokenOverride.value), tokenOverride.value, getCompiledRuntimeValue(tokenOverride.value) ?? node, items);
|
|
5895
|
+
return true;
|
|
5896
|
+
}
|
|
5897
|
+
if (tokenOverride.ok && Array.isArray(tokenOverride.value)) {
|
|
5898
|
+
for (let i = 0, len = tokenOverride.value.length; i < len; i++) {
|
|
5899
|
+
const item = tokenOverride.value[i];
|
|
5900
|
+
if (!item) continue;
|
|
5901
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
5902
|
+
addCompiledTokenItem(getStyleTokenId(item), item, getCompiledRuntimeValue(item) ?? null, items);
|
|
5903
|
+
}
|
|
5904
|
+
return true;
|
|
5905
|
+
}
|
|
5906
|
+
const styleNames = scope.styleNames ?? /* @__PURE__ */ new Set();
|
|
5907
|
+
const sheetNames = scope.sheetNames ?? /* @__PURE__ */ new Set();
|
|
5908
|
+
const selectorChain = node.type === "CallExpression" ? extractStyleChain(node, styleNames, sheetNames) ?? getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) : getLocalStyleChainArg(node, scope, styleNames, sheetNames);
|
|
5909
|
+
const selectorMeta = selectorChain ? scope.styleMetas?.get(selectorChain.rootName) : null;
|
|
5910
|
+
if (selectorChain?.kind !== "selector" || !selectorMeta || selectorMeta.mode !== "StyleObject") return false;
|
|
5911
|
+
return compileSelectorOverrideChain(selectorChain, selectorMeta.selectors, fileId, scope, cssConfig, selectorMeta.transform, scope.styleNames ?? /* @__PURE__ */ new Set(), options, items, rules);
|
|
5912
|
+
}
|
|
5913
|
+
function compileSelectorOverrideChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules) {
|
|
5914
|
+
if (chain.baseArgs.length === 0 || chain.baseArgs.length > 2) return false;
|
|
5915
|
+
const selectorArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5916
|
+
if (!selectorArg.ok) return false;
|
|
5917
|
+
const manualSelectors = normalizeManualSelectors(Array.isArray(selectorArg.value) ? selectorArg.value.map(String) : String(selectorArg.value ?? ""));
|
|
5918
|
+
for (let i = 0, len = manualSelectors.length; i < len; i++) if (!compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, manualSelectors[i])) return false;
|
|
5919
|
+
return true;
|
|
5920
|
+
}
|
|
5921
|
+
function compileSelectorOverrideInto(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options, items, rules, selectorPrefix) {
|
|
5922
|
+
if (chain.baseArgs[1]) {
|
|
5923
|
+
if (!compileSelectorStyleArg(chain.baseArgs[1], fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix)) return false;
|
|
5924
|
+
}
|
|
5925
|
+
let i = 0;
|
|
5926
|
+
while (i < chain.methods.length) {
|
|
5927
|
+
const method = chain.methods[i];
|
|
5928
|
+
if (!compileChainMethod(method, selectors, null, fileId, scope, 1, cssConfig, items, rules, transform, null, styleNames, options, null, selectorPrefix)) return false;
|
|
5929
|
+
i++;
|
|
5930
|
+
}
|
|
5931
|
+
return true;
|
|
5932
|
+
}
|
|
5933
|
+
function compileSelectorStyleArg(styleArgNode, fileId, scope, cssConfig, transform, items, rules, styleNames, options, selectorPrefix) {
|
|
5934
|
+
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5935
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5936
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5937
|
+
if (styleArgNode.type === "CallExpression") {
|
|
5938
|
+
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5939
|
+
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5940
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, 1, null, null, items, rules, styleNames, options, null, selectorPrefix);
|
|
5941
|
+
}
|
|
5942
|
+
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5943
|
+
if (!styleArg.ok) {
|
|
5944
|
+
throwIfRequiredStaticStyleValue(styleArg);
|
|
5945
|
+
return false;
|
|
5946
|
+
}
|
|
5947
|
+
if (isStyleData(styleArg.value)) return addStyleDataItems(styleArg.value, selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5948
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, null, fileId, 1, null, items, rules, cssConfig, null);
|
|
5949
|
+
}
|
|
5066
5950
|
function getCssConfig(opts, runtimeMode) {
|
|
5067
5951
|
const css = opts.css;
|
|
5068
5952
|
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
5069
5953
|
return {
|
|
5070
5954
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5955
|
+
sheetClassNameFormat: css?.sheetClassNameFormat ?? DEFAULT_CONFIG.sheetClassNameFormat ?? null,
|
|
5071
5956
|
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5072
5957
|
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
5073
5958
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
@@ -5194,15 +6079,16 @@ function decorateClassNameStyle(style, className) {
|
|
|
5194
6079
|
result[property] = value;
|
|
5195
6080
|
continue;
|
|
5196
6081
|
}
|
|
5197
|
-
|
|
5198
|
-
const rawValue = value[1];
|
|
5199
|
-
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5200
|
-
continue;
|
|
5201
|
-
}
|
|
5202
|
-
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
6082
|
+
result[property] = decorateClassNameValue(value, className);
|
|
5203
6083
|
}
|
|
5204
6084
|
return result;
|
|
5205
6085
|
}
|
|
6086
|
+
function decorateClassNameValue(value, className) {
|
|
6087
|
+
if (isClassNameValue(value)) return value;
|
|
6088
|
+
if (isStyleImportantValue(value)) return importantValue(decorateClassNameValue(value.value, className));
|
|
6089
|
+
if (isStyleWeightValue(value)) return weightValue(decorateClassNameValue(value.value, className), value.weight);
|
|
6090
|
+
return classNameValue(value, className);
|
|
6091
|
+
}
|
|
5206
6092
|
function isWeightedClassName(value) {
|
|
5207
6093
|
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5208
6094
|
}
|
|
@@ -5213,23 +6099,23 @@ function applyClassNameWeight(style, weight) {
|
|
|
5213
6099
|
weighted[property] = value;
|
|
5214
6100
|
continue;
|
|
5215
6101
|
}
|
|
5216
|
-
weighted[property] =
|
|
6102
|
+
weighted[property] = weightValue(value, weight);
|
|
5217
6103
|
}
|
|
5218
6104
|
return weighted;
|
|
5219
6105
|
}
|
|
5220
|
-
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
6106
|
+
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5221
6107
|
if (chain.baseArgs.length > 0) {
|
|
5222
6108
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
5223
6109
|
if (!styleArg.ok) {
|
|
5224
6110
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5225
6111
|
return false;
|
|
5226
6112
|
}
|
|
5227
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6113
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), selectorPrefix, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5228
6114
|
}
|
|
5229
6115
|
let i = 0;
|
|
5230
6116
|
while (i < chain.methods.length) {
|
|
5231
6117
|
const method = chain.methods[i];
|
|
5232
|
-
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride)) return false;
|
|
6118
|
+
if (!compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, rules, transform, atRules, styleNames, options, callsiteOverride, selectorPrefix)) return false;
|
|
5233
6119
|
i++;
|
|
5234
6120
|
}
|
|
5235
6121
|
return true;
|
|
@@ -5276,7 +6162,7 @@ function compileScopeChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
5276
6162
|
rules
|
|
5277
6163
|
};
|
|
5278
6164
|
}
|
|
5279
|
-
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null) {
|
|
6165
|
+
function compileScopeMethod(method, selectors, fileId, scope, cssConfig, items, cssRules, transform, options, callsiteOverride = null, _selectorPrefix = null) {
|
|
5280
6166
|
const selector = selectors[method.name];
|
|
5281
6167
|
if (!selector) return false;
|
|
5282
6168
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5549,10 +6435,10 @@ function getSlotIdFromValue(value) {
|
|
|
5549
6435
|
const slotId = value.slotId;
|
|
5550
6436
|
return typeof slotId === "string" ? slotId : null;
|
|
5551
6437
|
}
|
|
5552
|
-
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null) {
|
|
6438
|
+
function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5553
6439
|
if (method.name === "$$style.merge") {
|
|
5554
6440
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5555
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6441
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5556
6442
|
}
|
|
5557
6443
|
const selector = selectors[method.name];
|
|
5558
6444
|
if (!selector) return false;
|
|
@@ -5560,42 +6446,91 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5560
6446
|
const selectorStr = selector.selector.trim();
|
|
5561
6447
|
if (selectorStr === "...") {
|
|
5562
6448
|
const mergeCallsite = callsiteOverride ?? getMergeStyleCallsite(method.nameNode, scope, options);
|
|
5563
|
-
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite);
|
|
6449
|
+
return compileMergeArg(method.args[0], method.nameNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, mergeCallsite, selectorPrefix);
|
|
5564
6450
|
}
|
|
5565
|
-
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options);
|
|
5566
|
-
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options);
|
|
6451
|
+
if (selectorStr.startsWith("@")) return compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix);
|
|
6452
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) return compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix);
|
|
5567
6453
|
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
6454
|
+
const compiledSelector = selectorPrefix ? combineSelectors(selectorPrefix, itemSelector) : itemSelector;
|
|
5568
6455
|
const styleArg = evaluateNode(method.args[0], scope);
|
|
5569
6456
|
if (!styleArg.ok) {
|
|
5570
6457
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5571
6458
|
return false;
|
|
5572
6459
|
}
|
|
5573
|
-
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig),
|
|
6460
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5574
6461
|
}
|
|
5575
|
-
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
6462
|
+
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null, selectorPrefix = null) {
|
|
5576
6463
|
if (!styleArgNode) return false;
|
|
5577
6464
|
const styleCallsite = callsiteOverride ?? getMergeStyleCallsite(mergeNode, scope, options);
|
|
5578
6465
|
const localChain = getLocalStyleChainArg(styleArgNode, scope, styleNames);
|
|
5579
6466
|
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5580
|
-
if (
|
|
6467
|
+
if (localChain?.kind === "style" && localMeta) return compileStyleChainInto(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5581
6468
|
if (styleArgNode.type === "CallExpression") {
|
|
5582
6469
|
const nestedChain = extractStyleChain(styleArgNode, styleNames);
|
|
5583
6470
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5584
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite);
|
|
6471
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, atRules, items, cssRules, styleNames, options, styleCallsite, selectorPrefix);
|
|
5585
6472
|
}
|
|
5586
6473
|
const styleArg = evaluateNode(styleArgNode, scope);
|
|
5587
6474
|
if (!styleArg.ok) {
|
|
5588
6475
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5589
6476
|
return false;
|
|
5590
6477
|
}
|
|
5591
|
-
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode,
|
|
5592
|
-
return addStyleDataItems(styleArg.value,
|
|
6478
|
+
if (isStyleData(styleArg.value) && isStyleDataSpreadExpression(styleArgNode)) return addStyleDataSpreadItems(styleArg.value, styleArgNode, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
6479
|
+
return addStyleDataItems(styleArg.value, selectorPrefix, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, styleCallsite);
|
|
5593
6480
|
}
|
|
5594
|
-
function getLocalStyleChainArg(node, scope, styleNames) {
|
|
6481
|
+
function getLocalStyleChainArg(node, scope, styleNames, sheetNames = /* @__PURE__ */ new Set()) {
|
|
5595
6482
|
if (node.type !== "Identifier") return null;
|
|
5596
6483
|
const init = scope.bindingNodes?.get(node.name);
|
|
5597
6484
|
if (!init) return null;
|
|
5598
|
-
return extractStyleChain(init, styleNames);
|
|
6485
|
+
return extractStyleChain(init, styleNames, sheetNames);
|
|
6486
|
+
}
|
|
6487
|
+
function getLocalSelectorTargetChain(node, scope, styleNames, sheetNames) {
|
|
6488
|
+
const callee = node.callee;
|
|
6489
|
+
if (callee.type === "Identifier") {
|
|
6490
|
+
const target = getLocalStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6491
|
+
if (!isBareSelectorTargetChain(target)) return null;
|
|
6492
|
+
return {
|
|
6493
|
+
...target,
|
|
6494
|
+
baseArgs: [...target.baseArgs, ...node.arguments]
|
|
6495
|
+
};
|
|
6496
|
+
}
|
|
6497
|
+
if (callee.type !== "MemberExpression" || callee.computed) return null;
|
|
6498
|
+
const memberTarget = getLocalMemberStyleChainArg(callee, scope, styleNames, sheetNames);
|
|
6499
|
+
if (isBareSelectorTargetChain(memberTarget)) return {
|
|
6500
|
+
...memberTarget,
|
|
6501
|
+
baseArgs: [...memberTarget.baseArgs, ...node.arguments]
|
|
6502
|
+
};
|
|
6503
|
+
const methodName = callee.property.type === "Identifier" ? callee.property.name : callee.property.type === "StringLiteral" ? callee.property.value : null;
|
|
6504
|
+
if (!methodName) return null;
|
|
6505
|
+
const object = callee.object;
|
|
6506
|
+
const target = object.type === "Identifier" ? getLocalStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "MemberExpression" ? getLocalMemberStyleChainArg(object, scope, styleNames, sheetNames) : object.type === "CallExpression" ? getLocalSelectorTargetChain(object, scope, styleNames, sheetNames) : null;
|
|
6507
|
+
if (target?.kind !== "selector") return null;
|
|
6508
|
+
return {
|
|
6509
|
+
...target,
|
|
6510
|
+
methods: [...target.methods, {
|
|
6511
|
+
name: methodName,
|
|
6512
|
+
args: node.arguments,
|
|
6513
|
+
nameNode: callee.property
|
|
6514
|
+
}]
|
|
6515
|
+
};
|
|
6516
|
+
}
|
|
6517
|
+
function getLocalMemberStyleChainArg(node, scope, styleNames, sheetNames) {
|
|
6518
|
+
if (node.computed || node.object.type !== "Identifier") return null;
|
|
6519
|
+
const propertyName = node.property.type === "Identifier" ? node.property.name : node.property.type === "StringLiteral" ? node.property.value : null;
|
|
6520
|
+
if (!propertyName) return null;
|
|
6521
|
+
const objectInit = scope.bindingNodes?.get(node.object.name);
|
|
6522
|
+
if (objectInit?.type !== "ObjectExpression") return null;
|
|
6523
|
+
for (let i = 0, len = objectInit.properties.length; i < len; i++) {
|
|
6524
|
+
const property = objectInit.properties[i];
|
|
6525
|
+
if (property.type !== "ObjectProperty") continue;
|
|
6526
|
+
const key = property.key;
|
|
6527
|
+
if ((key.type === "Identifier" ? key.name : key.type === "StringLiteral" ? key.value : null) !== propertyName) continue;
|
|
6528
|
+
return extractStyleChain(property.value, styleNames, sheetNames);
|
|
6529
|
+
}
|
|
6530
|
+
return null;
|
|
6531
|
+
}
|
|
6532
|
+
function isBareSelectorTargetChain(chain) {
|
|
6533
|
+
return chain?.kind === "selector" && chain.baseArgs.length === 1 && chain.methods.length === 0;
|
|
5599
6534
|
}
|
|
5600
6535
|
function getLocalBindingNode(node, scope) {
|
|
5601
6536
|
return node?.type === "Identifier" ? scope.bindingNodes?.get(node.name) ?? null : null;
|
|
@@ -5623,7 +6558,7 @@ function isStyleDataSpreadExpression(node) {
|
|
|
5623
6558
|
default: return false;
|
|
5624
6559
|
}
|
|
5625
6560
|
}
|
|
5626
|
-
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options) {
|
|
6561
|
+
function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, selectors, styleNames, options, selectorPrefix = null) {
|
|
5627
6562
|
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5628
6563
|
const hasArg = selectorStr.includes("$$");
|
|
5629
6564
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
@@ -5645,22 +6580,22 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5645
6580
|
if (styleArg.type === "CallExpression") {
|
|
5646
6581
|
const nestedChain = extractStyleChain(styleArg, styleNames);
|
|
5647
6582
|
const nestedMeta = nestedChain ? scope.styleMetas?.get(nestedChain.rootName) : null;
|
|
5648
|
-
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options);
|
|
6583
|
+
if (nestedChain?.kind === "style" && nestedMeta) return compileStyleChainInto(nestedChain, nestedMeta.selectors, fileId, scope, cssConfig, nestedMeta.transform, type, slotId, nextAtRules, items, cssRules, styleNames, options, null, selectorPrefix);
|
|
5649
6584
|
const evaled = evaluateNode(styleArg, scope);
|
|
5650
6585
|
if (!evaled.ok) {
|
|
5651
6586
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5652
6587
|
return false;
|
|
5653
6588
|
}
|
|
5654
|
-
return addStyleItems(applyTransform(evaled.value, transform, cssConfig),
|
|
6589
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5655
6590
|
}
|
|
5656
6591
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5657
6592
|
if (!styleResult.ok) {
|
|
5658
6593
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5659
6594
|
return false;
|
|
5660
6595
|
}
|
|
5661
|
-
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig),
|
|
6596
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), selectorPrefix, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5662
6597
|
}
|
|
5663
|
-
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
6598
|
+
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options, selectorPrefix = null) {
|
|
5664
6599
|
const selectorStr = selector.selector.trim();
|
|
5665
6600
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5666
6601
|
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
@@ -5682,7 +6617,8 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5682
6617
|
while (i < selectorValues.length) {
|
|
5683
6618
|
const itemSelectorValue = selectorValues[i];
|
|
5684
6619
|
const selectorText = before + normalizeSelectorArg(String(itemSelectorValue ?? "")) + (after ?? "");
|
|
5685
|
-
|
|
6620
|
+
const compiledSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
6621
|
+
if (!addStyleItems(styleObj, selectorPrefix ? combineSelectors(selectorPrefix, compiledSelector) : compiledSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig)) return false;
|
|
5686
6622
|
i++;
|
|
5687
6623
|
}
|
|
5688
6624
|
return true;
|
|
@@ -5751,6 +6687,8 @@ function addSlotOverrideDataItems(value, parentSelector, atRules, fileId, items,
|
|
|
5751
6687
|
dedupe: overrideItem.dedupe,
|
|
5752
6688
|
className: overrideItem.className,
|
|
5753
6689
|
property: overrideItem.property,
|
|
6690
|
+
weight: overrideItem.weight,
|
|
6691
|
+
important: overrideItem.important,
|
|
5754
6692
|
value: overrideItem.value,
|
|
5755
6693
|
variable: overrideItem.variable,
|
|
5756
6694
|
token: overrideItem.token,
|
|
@@ -5794,22 +6732,20 @@ function addExtractedScopeItem(sourceItem, items) {
|
|
|
5794
6732
|
items.push(item);
|
|
5795
6733
|
}
|
|
5796
6734
|
function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5797
|
-
|
|
6735
|
+
const weight = sourceItem.weight;
|
|
6736
|
+
let important = false;
|
|
5798
6737
|
let value = sourceItem.value;
|
|
5799
|
-
|
|
5800
|
-
priority = value[1];
|
|
5801
|
-
value = value[0];
|
|
5802
|
-
}
|
|
6738
|
+
important = sourceItem.important;
|
|
5803
6739
|
const itemParentSelector = parentSelector ?? sourceItem.parentSelector;
|
|
5804
6740
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
5805
6741
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5806
6742
|
const valueStr = String(value ?? "");
|
|
5807
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
5808
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6743
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
6744
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
5809
6745
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5810
6746
|
items.push(item);
|
|
5811
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
5812
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6747
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6748
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, sourceItem.selector, itemParentSelector, itemAtRules, true);
|
|
5813
6749
|
cssRules.push({
|
|
5814
6750
|
dedupe,
|
|
5815
6751
|
className,
|
|
@@ -5872,21 +6808,18 @@ function addExtractedStyleItem(sourceItem, type, slotId, items) {
|
|
|
5872
6808
|
items.push(item);
|
|
5873
6809
|
}
|
|
5874
6810
|
function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride = null) {
|
|
5875
|
-
|
|
6811
|
+
const weight = sourceItem.weight;
|
|
6812
|
+
const important = sourceItem.important;
|
|
5876
6813
|
let value = sourceItem.value;
|
|
5877
|
-
|
|
5878
|
-
priority = value[1];
|
|
5879
|
-
value = value[0];
|
|
5880
|
-
}
|
|
5881
|
-
const itemSelector = selector ?? sourceItem.selector;
|
|
6814
|
+
const itemSelector = selector && sourceItem.selector ? combineSelectors(selector, sourceItem.selector) : selector ?? sourceItem.selector;
|
|
5882
6815
|
const itemAtRules = mergeAtRules(atRules, sourceItem.atRule);
|
|
5883
6816
|
const variable = sourceItem.variable;
|
|
5884
6817
|
const runtimeValue = variable?.[0] === 1 ? getCompiledRuntimeValue(variable[2]) : void 0;
|
|
5885
6818
|
const shouldUseVariable = !!variable && (variable[0] !== 1 || !!sourceItem.token || !!runtimeValue);
|
|
5886
6819
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5887
|
-
const dedupe = getClassNameDedupe(sourceItem.property,
|
|
6820
|
+
const dedupe = getClassNameDedupe(sourceItem.property, weight, important, itemSelector, parentSelector, itemAtRules);
|
|
5888
6821
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5889
|
-
const className = getAtomicClassName(sourceItem.property,
|
|
6822
|
+
const className = getAtomicClassName(sourceItem.property, weight, important, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
5890
6823
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5891
6824
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5892
6825
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5894,8 +6827,8 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5894
6827
|
if (runtimeValue) item.valueNode = runtimeValue;
|
|
5895
6828
|
}
|
|
5896
6829
|
items.push(item);
|
|
5897
|
-
const css = buildAtomicRule(className, sourceItem.property, valueStr, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
5898
|
-
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property,
|
|
6830
|
+
const css = buildAtomicRule(className, sourceItem.property, valueStr, important, itemSelector, parentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
6831
|
+
const layerPriority = getAtomicRuleLayerPriority(sourceItem.property, weight, itemSelector, parentSelector, itemAtRules, type === 4);
|
|
5899
6832
|
cssRules.push({
|
|
5900
6833
|
dedupe,
|
|
5901
6834
|
className,
|
|
@@ -5908,6 +6841,19 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5908
6841
|
} : void 0
|
|
5909
6842
|
});
|
|
5910
6843
|
}
|
|
6844
|
+
function combineSelectors(parent, child) {
|
|
6845
|
+
const parentText = getItemSelectorText(parent);
|
|
6846
|
+
const childText = getItemSelectorText(child);
|
|
6847
|
+
const priority = Math.max(getItemSelectorPriority(parent), getItemSelectorPriority(child));
|
|
6848
|
+
const selector = parentText + childText;
|
|
6849
|
+
return priority > 0 ? [selector, priority] : selector;
|
|
6850
|
+
}
|
|
6851
|
+
function getItemSelectorText(selector) {
|
|
6852
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
6853
|
+
}
|
|
6854
|
+
function getItemSelectorPriority(selector) {
|
|
6855
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
6856
|
+
}
|
|
5911
6857
|
function getRuntimeStyleItemSourceTrace(item, fileId) {
|
|
5912
6858
|
const trace = getRuntimeStyleItemValueTrace(item);
|
|
5913
6859
|
if (!trace) return void 0;
|
|
@@ -5952,13 +6898,11 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5952
6898
|
while (i < keys.length) {
|
|
5953
6899
|
const property = keys[i];
|
|
5954
6900
|
const rawValue = styleObj[property];
|
|
5955
|
-
let
|
|
6901
|
+
let weight = null;
|
|
6902
|
+
let important = false;
|
|
5956
6903
|
let value = rawValue;
|
|
5957
6904
|
let transformClassName = null;
|
|
5958
|
-
|
|
5959
|
-
priority = rawValue[0];
|
|
5960
|
-
value = rawValue[1];
|
|
5961
|
-
}
|
|
6905
|
+
[value, weight, important] = unwrapStaticStyleValue(value);
|
|
5962
6906
|
if (isClassNameValue(value)) {
|
|
5963
6907
|
transformClassName = value.className;
|
|
5964
6908
|
value = value.value;
|
|
@@ -5981,8 +6925,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5981
6925
|
const shouldUseVariable = !!(token || runtimeValue);
|
|
5982
6926
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5983
6927
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5984
|
-
const dedupe = getClassNameDedupe(property,
|
|
5985
|
-
const className = getAtomicClassName(property,
|
|
6928
|
+
const dedupe = getClassNameDedupe(property, weight, important, selector, parentSelector, atRules);
|
|
6929
|
+
const className = getAtomicClassName(property, weight, important, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.sheetClassNameFormat, cssConfig.hashLength);
|
|
5986
6930
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5987
6931
|
item.sourceTrace = propertyCallsite ? {
|
|
5988
6932
|
property,
|
|
@@ -6007,8 +6951,8 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6007
6951
|
item.valueNode = runtimeValue ?? token[COMPILED_RUNTIME_VALUE];
|
|
6008
6952
|
}
|
|
6009
6953
|
items.push(item);
|
|
6010
|
-
const css = buildAtomicRule(className, property, valueStr, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6011
|
-
const layerPriority = getAtomicRuleLayerPriority(property,
|
|
6954
|
+
const css = buildAtomicRule(className, property, valueStr, important, selector, parentSelector, atRules, cssConfig.scopeTargetPrefix);
|
|
6955
|
+
const layerPriority = getAtomicRuleLayerPriority(property, weight, selector, parentSelector, atRules, type === 4);
|
|
6012
6956
|
cssRules.push({
|
|
6013
6957
|
dedupe,
|
|
6014
6958
|
className,
|
|
@@ -6036,6 +6980,28 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
6036
6980
|
}
|
|
6037
6981
|
return true;
|
|
6038
6982
|
}
|
|
6983
|
+
function unwrapStaticStyleValue(value) {
|
|
6984
|
+
let weight = null;
|
|
6985
|
+
let important = false;
|
|
6986
|
+
while (true) {
|
|
6987
|
+
if (isStyleImportantValue(value)) {
|
|
6988
|
+
important = true;
|
|
6989
|
+
value = value.value;
|
|
6990
|
+
continue;
|
|
6991
|
+
}
|
|
6992
|
+
if (isStyleWeightValue(value)) {
|
|
6993
|
+
weight = value.weight;
|
|
6994
|
+
value = value.value;
|
|
6995
|
+
continue;
|
|
6996
|
+
}
|
|
6997
|
+
break;
|
|
6998
|
+
}
|
|
6999
|
+
return [
|
|
7000
|
+
value,
|
|
7001
|
+
weight,
|
|
7002
|
+
important
|
|
7003
|
+
];
|
|
7004
|
+
}
|
|
6039
7005
|
function throwIfRequiredStaticStyleValue(result) {
|
|
6040
7006
|
if (result.ok) return;
|
|
6041
7007
|
if (result.reason.includes("createCounterStyle") || result.reason.includes("createFontFace") || result.reason.includes("createFontPaletteValues") || result.reason.includes("createPositionTry") || result.reason.includes("createProperty") || result.reason.includes("fontSrc")) throw new Error(result.reason);
|
|
@@ -6171,6 +7137,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6171
7137
|
const styleMetas = /* @__PURE__ */ new Map();
|
|
6172
7138
|
const fileId = getProjectFileId$1(projectDir, filePath);
|
|
6173
7139
|
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
7140
|
+
const staticIdState = {
|
|
7141
|
+
fileId,
|
|
7142
|
+
imports,
|
|
7143
|
+
styleNames
|
|
7144
|
+
};
|
|
7145
|
+
const t = babel.types;
|
|
6174
7146
|
for (const stmt of ast.program.body) {
|
|
6175
7147
|
if (stmt.type === "ImportDeclaration") {
|
|
6176
7148
|
const source = stmt.source.value;
|
|
@@ -6195,6 +7167,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6195
7167
|
continue;
|
|
6196
7168
|
}
|
|
6197
7169
|
if (stmt.type === "VariableDeclaration") {
|
|
7170
|
+
annotateVariableDeclaration(stmt, staticIdState, t);
|
|
6198
7171
|
collectVariableBindings(rawBindings, stmt);
|
|
6199
7172
|
continue;
|
|
6200
7173
|
}
|
|
@@ -6218,6 +7191,7 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6218
7191
|
continue;
|
|
6219
7192
|
}
|
|
6220
7193
|
if (stmt.declaration?.type === "VariableDeclaration") {
|
|
7194
|
+
annotateVariableDeclaration(stmt.declaration, staticIdState, t);
|
|
6221
7195
|
collectVariableBindings(rawBindings, stmt.declaration);
|
|
6222
7196
|
continue;
|
|
6223
7197
|
}
|
|
@@ -6257,6 +7231,12 @@ function parseAndExtractModule(projectDir, filePath, content, babel, resolveImpo
|
|
|
6257
7231
|
});
|
|
6258
7232
|
return bindings;
|
|
6259
7233
|
}
|
|
7234
|
+
function annotateVariableDeclaration(declaration, state, t) {
|
|
7235
|
+
for (const decl of declaration.declarations) {
|
|
7236
|
+
annotateTokenDeclaration(decl, state, t);
|
|
7237
|
+
annotateAtRuleDeclaration(decl, state, t);
|
|
7238
|
+
}
|
|
7239
|
+
}
|
|
6260
7240
|
function collectVariableBindings(bindings, declaration) {
|
|
6261
7241
|
for (const decl of declaration.declarations) if (decl.id.type === "Identifier" && decl.init) bindings.set(decl.id.name, decl.init);
|
|
6262
7242
|
}
|
|
@@ -6336,6 +7316,11 @@ function createExtractedChainValue(result, traceResult = result) {
|
|
|
6336
7316
|
defineCompiledStyleLocations(style, traceResult);
|
|
6337
7317
|
return style;
|
|
6338
7318
|
}
|
|
7319
|
+
if (result.type === "sheet") {
|
|
7320
|
+
const sheet = createExtractedSheet(result.items.filter(Array.isArray).map((item) => toExtractedStyleTuple(item)));
|
|
7321
|
+
defineCompiledStyleLocations(sheet, traceResult);
|
|
7322
|
+
return sheet;
|
|
7323
|
+
}
|
|
6339
7324
|
if (result.type === "scope") return createExtractedScope(result.items.map(toExtractedScopeItem$1).filter((item) => item !== null));
|
|
6340
7325
|
return null;
|
|
6341
7326
|
}
|
|
@@ -6446,6 +7431,12 @@ function hashFileContent(filePath) {
|
|
|
6446
7431
|
function getStyleRuntimeImportPath(mode) {
|
|
6447
7432
|
return `${STYLE_IMPORT_PATH}/entry/${mode}`;
|
|
6448
7433
|
}
|
|
7434
|
+
function getStyleRuntimeAdapterImportPath(source, mode) {
|
|
7435
|
+
if (source === "@fluentic/style/adapter/solid") return `${getStyleRuntimeImportPath(mode)}/adapter/solid`;
|
|
7436
|
+
if (source === "@fluentic/style/adapter/preact") return `${getStyleRuntimeImportPath(mode)}/adapter/preact`;
|
|
7437
|
+
if (source === "@fluentic/style/adapter/react") return `${getStyleRuntimeImportPath(mode)}/adapter/react`;
|
|
7438
|
+
return null;
|
|
7439
|
+
}
|
|
6449
7440
|
function getStyleRuntimeCssImportPath(mode) {
|
|
6450
7441
|
return `${getStyleRuntimeImportPath(mode)}/css`;
|
|
6451
7442
|
}
|
|
@@ -6538,6 +7529,10 @@ function buildReplacement(t, chain, state, options = {}) {
|
|
|
6538
7529
|
state.usedHelpers.add(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE);
|
|
6539
7530
|
return t.callExpression(t.identifier(hasSpread ? FN_CREATE_EXTRACTED_STYLE_MERGE : FN_CREATE_EXTRACTED_STYLE), hasSpread ? buildStyleMergeArgs(t, chain, state, options) : [buildItemsArray(t, chain, 1, state, options)]);
|
|
6540
7531
|
}
|
|
7532
|
+
if (chain.type === "sheet") {
|
|
7533
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_SHEET);
|
|
7534
|
+
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SHEET), [buildItemsArray(t, chain, 9, state, options)]);
|
|
7535
|
+
}
|
|
6541
7536
|
if (chain.type === "slot") {
|
|
6542
7537
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_SLOT);
|
|
6543
7538
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_SLOT), [t.stringLiteral(chain.slotId), buildItemsArray(t, chain, 2, state, options)]);
|
|
@@ -6576,7 +7571,7 @@ function buildItemsArray(t, chain, defaultType, state, options) {
|
|
|
6576
7571
|
chain.items.forEach((item) => {
|
|
6577
7572
|
if (isCompiledTokenItem(item)) {
|
|
6578
7573
|
if (options.getTokenOverride) options.getTokenOverride(item);
|
|
6579
|
-
else itemExpressions.push(t
|
|
7574
|
+
else itemExpressions.push(buildExtractedTokenOverrideExpression(t, item.value, state));
|
|
6580
7575
|
return;
|
|
6581
7576
|
}
|
|
6582
7577
|
if (isCompiledStyleSpreadItem(item)) return;
|
|
@@ -6666,11 +7661,26 @@ function buildVariableValueExpression(t, value, state, item, options) {
|
|
|
6666
7661
|
}
|
|
6667
7662
|
function buildExtractedTokenExpression(t, token, state) {
|
|
6668
7663
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7664
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
6669
7665
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
6670
7666
|
t.stringLiteral(getStyleTokenId(token)),
|
|
6671
7667
|
literalExpression(t, token.value),
|
|
6672
|
-
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral()
|
|
7668
|
+
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral(),
|
|
7669
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7670
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
7671
|
+
]);
|
|
7672
|
+
}
|
|
7673
|
+
function buildExtractedTokenOverrideExpression(t, token, state) {
|
|
7674
|
+
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
7675
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
7676
|
+
const extractedToken = t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
7677
|
+
t.stringLiteral(getStyleTokenId(token)),
|
|
7678
|
+
t.nullLiteral(),
|
|
7679
|
+
t.nullLiteral(),
|
|
7680
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
7681
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6673
7682
|
]);
|
|
7683
|
+
return t.callExpression(extractedToken, [token.ref ? buildExtractedTokenExpression(t, token.ref, state) : literalExpression(t, token.value)]);
|
|
6674
7684
|
}
|
|
6675
7685
|
function literalExpression(t, value) {
|
|
6676
7686
|
if (typeof value === "string") return t.stringLiteral(value);
|
|
@@ -6793,6 +7803,7 @@ function getEvalScope(state) {
|
|
|
6793
7803
|
styleFilePath: state.styleFilePath,
|
|
6794
7804
|
sourcemapTrace: state.sourcemapTrace,
|
|
6795
7805
|
styleNames: state.styleNames,
|
|
7806
|
+
sheetNames: state.sheetNames,
|
|
6796
7807
|
styleMetas: state.styleMetas,
|
|
6797
7808
|
bindingNodes: state.bindingNodes,
|
|
6798
7809
|
runtimeMode: state.runtimeMode
|
|
@@ -6809,8 +7820,8 @@ function compileThemeCall(path, state, opts) {
|
|
|
6809
7820
|
const tokenArg = evaluateNode(path.node.arguments[0], scope);
|
|
6810
7821
|
if (!tokenArg.ok) throw path.buildCodeFrameError(`createTheme tokens must be statically analyzable: ${tokenArg.reason}`);
|
|
6811
7822
|
if (!Array.isArray(tokenArg.value)) throw path.buildCodeFrameError("createTheme first argument must be a static array of token overrides.");
|
|
6812
|
-
const
|
|
6813
|
-
if (path.node.arguments[1] && !
|
|
7823
|
+
const stableIdArg = evaluateNode(path.node.arguments[1], scope);
|
|
7824
|
+
if (path.node.arguments[1] && !stableIdArg.ok) throw path.buildCodeFrameError(`createTheme stableId must be statically analyzable: ${stableIdArg.reason}`);
|
|
6814
7825
|
const tokens = [];
|
|
6815
7826
|
for (let i = 0, len = tokenArg.value.length; i < len; i++) {
|
|
6816
7827
|
const token = tokenArg.value[i];
|
|
@@ -6818,7 +7829,7 @@ function compileThemeCall(path, state, opts) {
|
|
|
6818
7829
|
tokens.push(token);
|
|
6819
7830
|
}
|
|
6820
7831
|
const loc = path.node.loc?.start;
|
|
6821
|
-
const id =
|
|
7832
|
+
const id = stableIdArg.ok && stableIdArg.value !== void 0 ? String(stableIdArg.value) : getStableThemeId(state.fileId, loc ? loc.line + ":" + loc.column : "createTheme");
|
|
6822
7833
|
const themeNameFormat = opts.css?.themeNameFormat || CSS_CONFIG.themeNameFormat || null;
|
|
6823
7834
|
const className = getStableThemeClassName(id, themeNameFormat);
|
|
6824
7835
|
return {
|
|
@@ -6850,6 +7861,7 @@ function createExtractPlugin(args) {
|
|
|
6850
7861
|
return {
|
|
6851
7862
|
pre() {
|
|
6852
7863
|
this.styleNames = /* @__PURE__ */ new Set();
|
|
7864
|
+
this.sheetNames = /* @__PURE__ */ new Set();
|
|
6853
7865
|
this.styleMetas = /* @__PURE__ */ new Map();
|
|
6854
7866
|
this.bindings = /* @__PURE__ */ new Map();
|
|
6855
7867
|
this.bindingNodes = /* @__PURE__ */ new Map();
|
|
@@ -6896,6 +7908,7 @@ function createExtractPlugin(args) {
|
|
|
6896
7908
|
state.styleNames.add(spec.local.name);
|
|
6897
7909
|
state.styleMetas.set(spec.local.name, meta);
|
|
6898
7910
|
}
|
|
7911
|
+
if (sourceName === "@fluentic/style/css" && imported === "createSheet") state.sheetNames.add(spec.local.name);
|
|
6899
7912
|
});
|
|
6900
7913
|
},
|
|
6901
7914
|
VariableDeclaration(path, state) {
|
|
@@ -6942,17 +7955,17 @@ function createExtractPlugin(args) {
|
|
|
6942
7955
|
state.needsExtractImport = true;
|
|
6943
7956
|
return;
|
|
6944
7957
|
}
|
|
6945
|
-
if (!state.styleNames.size) return;
|
|
6946
|
-
const chain = extractStyleChain(path.node, state.styleNames);
|
|
7958
|
+
if (!state.styleNames.size && !state.sheetNames.size) return;
|
|
7959
|
+
const chain = extractStyleChain(path.node, state.styleNames, state.sheetNames);
|
|
6947
7960
|
if (!chain) return;
|
|
6948
7961
|
if (chain.kind === "slot" && path.parent.type === "CallExpression" && path.parent.callee === path.node) throw path.buildCodeFrameError("Direct invocation `style.slot(...)()` is not allowed. Assign the slot to a variable first, then call it through that binding.");
|
|
6949
7962
|
const scope = getEvalScope(state);
|
|
6950
7963
|
const loc = path.node.loc?.start;
|
|
6951
7964
|
const meta = state.styleMetas.get(chain.rootName);
|
|
6952
|
-
if (!meta) return;
|
|
7965
|
+
if (chain.kind !== "sheet" && !meta) return;
|
|
6953
7966
|
let result;
|
|
6954
7967
|
try {
|
|
6955
|
-
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
7968
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta ?? null, state.styleNames);
|
|
6956
7969
|
} catch (error) {
|
|
6957
7970
|
const message = error instanceof Error ? error.message : String(error);
|
|
6958
7971
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -7206,7 +8219,7 @@ function transformExtract(internal, args, deps) {
|
|
|
7206
8219
|
code: args.code,
|
|
7207
8220
|
filePath: args.filePath,
|
|
7208
8221
|
sourcemap: args.sourcemap,
|
|
7209
|
-
plugins: [plugin],
|
|
8222
|
+
plugins: [createCssPropPlugin({ options: internal.options }), plugin],
|
|
7210
8223
|
errorLabel: "[style] compiler error"
|
|
7211
8224
|
});
|
|
7212
8225
|
if (!result) return null;
|
|
@@ -7248,13 +8261,6 @@ function createPlugin(rewriteSource) {
|
|
|
7248
8261
|
}
|
|
7249
8262
|
//#endregion
|
|
7250
8263
|
//#region compiler/compiler/compiler.ts
|
|
7251
|
-
let CompilerRuntimeMode = /* @__PURE__ */ function(CompilerRuntimeMode) {
|
|
7252
|
-
CompilerRuntimeMode["Dev"] = "dev";
|
|
7253
|
-
CompilerRuntimeMode["Prod"] = "prod";
|
|
7254
|
-
CompilerRuntimeMode["RscDev"] = "rsc-dev";
|
|
7255
|
-
CompilerRuntimeMode["RscProd"] = "rsc-prod";
|
|
7256
|
-
return CompilerRuntimeMode;
|
|
7257
|
-
}({});
|
|
7258
8264
|
function createCompiler(args, options) {
|
|
7259
8265
|
const internal = createCompilerInternal(args, options);
|
|
7260
8266
|
const tracer = createTracer(internal);
|
|
@@ -7334,12 +8340,34 @@ function rewriteCompilerRuntimeImports(code, runtimeMode) {
|
|
|
7334
8340
|
}
|
|
7335
8341
|
function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
7336
8342
|
if (source === "@fluentic/style") return getStyleRuntimeImportPath(runtimeMode);
|
|
8343
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, runtimeMode);
|
|
8344
|
+
if (adapterImportPath) return adapterImportPath;
|
|
7337
8345
|
if (source === "@fluentic/style/css") return getStyleRuntimeCssImportPath(runtimeMode);
|
|
7338
8346
|
if (source === "@fluentic/style/entry/prod/runtime") return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
7339
8347
|
if (runtimeMode === "rsc-dev" && source === "@fluentic/style/dev/rsc") return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
7340
8348
|
return null;
|
|
7341
8349
|
}
|
|
8350
|
+
const CssPropPresets = {
|
|
8351
|
+
Solid: {
|
|
8352
|
+
classProp: "class",
|
|
8353
|
+
styleProp: "style",
|
|
8354
|
+
styleMode: "solid",
|
|
8355
|
+
adapter: "@fluentic/style/adapter/solid"
|
|
8356
|
+
},
|
|
8357
|
+
Preact: {
|
|
8358
|
+
classProp: "class",
|
|
8359
|
+
styleProp: "style",
|
|
8360
|
+
styleMode: "react",
|
|
8361
|
+
adapter: "@fluentic/style/adapter/preact"
|
|
8362
|
+
},
|
|
8363
|
+
React: {
|
|
8364
|
+
classProp: "className",
|
|
8365
|
+
styleProp: "style",
|
|
8366
|
+
styleMode: "react",
|
|
8367
|
+
adapter: "@fluentic/style/adapter/react"
|
|
8368
|
+
}
|
|
8369
|
+
};
|
|
7342
8370
|
//#endregion
|
|
7343
|
-
export {
|
|
8371
|
+
export { getDefaultSourcemapUrl as a, isPromiseLike as c, extractCss as d, compareLayerPriority as f, createCompilerCache as h, CompilerRuntimeMode as i, babelPlugin as l, globalData as m, createCompiler as n, normalizeSourcemapSourcePath as o, SIDECAR_URL_GLOBAL_SYMBOL as p, getStyleRuntimeImportPath as r, normalizePath as s, CssPropPresets as t, babelTransform as u };
|
|
7344
8372
|
|
|
7345
|
-
//# sourceMappingURL=compiler-
|
|
8373
|
+
//# sourceMappingURL=compiler-OgDBuqfs.mjs.map
|