@fluentic/style 0.1.0-beta.4 → 0.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -1
- package/README.md +106 -31
- package/atomic/className.ts +29 -6
- package/atomic/debug/className/className.ts +10 -0
- package/atomic/rule.ts +6 -3
- package/atomic/utils/hash.ts +1 -65
- package/atomic/utils/selector.ts +14 -1
- package/builder/classname/class_name_builder.ts +68 -24
- package/builder/classname/fns.ts +2 -2
- package/builder/classname/types.ts +7 -0
- package/builder/data/const.ts +6 -0
- package/builder/data/create.ts +42 -0
- package/builder/data/data.ts +20 -1
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +23 -0
- package/builder/data/merge/scope.ts +20 -19
- package/builder/data/merge/style.ts +70 -20
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +30 -0
- package/builder/selector_override_core.ts +66 -0
- package/builder/style_builder.ts +127 -3
- package/builder/style_data.ts +24 -0
- package/builder/style_fns.ts +24 -24
- package/builder/types/alias.ts +34 -6
- package/builder/types/fns.ts +13 -5
- package/builder/types/types.ts +32 -2
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +88 -14
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +2 -0
- package/compiler/cssProp.ts +21 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +6 -0
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +33 -4
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +660 -73
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +1 -1
- package/compiler/transform/extract/plugin.ts +20 -4
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +47 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/import_source.ts +17 -7
- package/compiler/utils/imports.ts +11 -1
- package/config/config/css.ts +1 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -0
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/combine-D0AXSTn-.js +1279 -0
- package/dist/combine-D0AXSTn-.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-CE0ZgkdH.mjs → compiler-CCvRlaq0.mjs} +1467 -534
- package/dist/compiler-CCvRlaq0.mjs.map +1 -0
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-oKOjOTWi.js.map → config-B-KbXpIh.js.map} +1 -1
- package/dist/config-B-w6rOe0.js +35 -0
- package/dist/config-B-w6rOe0.js.map +1 -0
- package/dist/{config-lJNLh7eM.js → config-B1WtpYar.js} +2 -2
- package/dist/{config-lJNLh7eM.js.map → config-B1WtpYar.js.map} +1 -1
- package/dist/{config-CduqubI8.js → config-CCMwA9Gm.js} +3 -3
- package/dist/config-CCMwA9Gm.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/createTransformElement-PCilcudP.js +34 -0
- package/dist/createTransformElement-PCilcudP.js.map +1 -0
- package/dist/css-DirG7Jwu.js +1280 -0
- package/dist/css-DirG7Jwu.js.map +1 -0
- package/dist/css-GtUPEO9U.js.map +1 -1
- package/dist/css-nmclCl2P.js +479 -0
- package/dist/css-nmclCl2P.js.map +1 -0
- package/dist/css-shX7_73D.js +3894 -0
- package/dist/css-shX7_73D.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{data-D7NFt4JG.js → data-DUvixly5.js} +155 -61
- package/dist/data-DUvixly5.js.map +1 -0
- package/dist/{debug-Cvpo5cVu.js → debug-DJRCBKhM.js} +80 -5
- package/dist/debug-DJRCBKhM.js.map +1 -0
- package/dist/dev/rsc.js +5 -8
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-DdRWa6dJ.js → dev-Cwha8aAp.js} +4 -4
- package/dist/{dev-DdRWa6dJ.js.map → dev-Cwha8aAp.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-ng0y3fN0.js → elementMarker-Cb46vtLU.js} +94 -8
- package/dist/elementMarker-Cb46vtLU.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +10 -8
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +240 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -5
- package/dist/entry/prod.js +84 -1229
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +5 -10
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +252 -750
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -5
- package/dist/entry/rsc-prod.js +236 -11
- package/dist/entry/rsc-prod.js.map +1 -1
- package/dist/{styleStore-CajcAEPO.js → env-0Gu2Jh47.js} +1148 -162
- package/dist/env-0Gu2Jh47.js.map +1 -0
- package/dist/getClassName-CHZKhmde.js +45 -0
- package/dist/getClassName-CHZKhmde.js.map +1 -0
- package/dist/{utils-B_VhPBHH.js → getClassName-CHd0iCXp.js} +28 -65
- package/dist/getClassName-CHd0iCXp.js.map +1 -0
- package/dist/getClassName-a6p2uMFM.js +536 -0
- package/dist/getClassName-a6p2uMFM.js.map +1 -0
- package/dist/{getClassName-CrNVjAoJ.js → getClassName-aD9zqg9U.js} +31 -10
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-Dg37z0lV.js +14 -0
- package/dist/global-Dg37z0lV.js.map +1 -0
- package/dist/{hash-BfeJDf5U.js → hash-Cr-LCWDt.js} +35 -38
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +7 -6
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-BMFC8_tA.js +39 -0
- package/dist/jsx-BMFC8_tA.js.map +1 -0
- package/dist/{jsx_dev_runtime-aAhNYDeS.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-aAhNYDeS.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-D7Y5up6H.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-D7Y5up6H.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-C6i1bWlu.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
- package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
- package/dist/{loader-BmYS_Rju.mjs → loader-hNaefW-U.mjs} +13 -14
- package/dist/loader-hNaefW-U.mjs.map +1 -0
- package/dist/{misc-BIS_c7BJ.mjs → misc-1OS0aeY1.mjs} +4 -4
- package/dist/misc-1OS0aeY1.mjs.map +1 -0
- package/dist/{namedTokens-CN_yhhik.js → namedTokens-mgRfd9hs.js} +3 -3
- package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +121 -17
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +26 -5
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-IaXmLQzA.mjs → registry-OA0niXJL.mjs} +2 -2
- package/dist/{registry-IaXmLQzA.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-BKXT1bmR.js +63 -0
- package/dist/resolveClassNameRuntime-BKXT1bmR.js.map +1 -0
- package/dist/{rules-CxVzovt-.js → rules-DgcCENkw.js} +583 -154
- package/dist/rules-DgcCENkw.js.map +1 -0
- package/dist/{combine-C9vjpKCs.js → scope-BSuRLice.js} +239 -150
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +12 -9
- package/dist/server.js.map +1 -1
- package/dist/{shared-CaJuvw03.cjs → shared-Bc9RwNNj.cjs} +1473 -535
- package/dist/shared-Bc9RwNNj.cjs.map +1 -0
- package/dist/{shared-DdPTZ0O3.mjs → shared-COiLPdZ1.mjs} +4 -4
- package/dist/{shared-DdPTZ0O3.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
- package/dist/sheet-B87QCFWF.js +7 -0
- package/dist/{sheet-BWBzuy4D.js.map → sheet-B87QCFWF.js.map} +1 -1
- package/dist/{sidecar-B3oCK9vC.mjs → sidecar-ViZUL9B8.mjs} +3 -3
- package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
- package/dist/{styleStore-0fARJlZV.js → styleStore-BlC8Ax9f.js} +3 -4
- package/dist/{styleStore-0fARJlZV.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
- package/dist/styleStore-DHzH25A7.js +51 -0
- package/dist/styleStore-DHzH25A7.js.map +1 -0
- package/dist/{token-D-S-4_mN.js → token-CAQWMtan.js} +2 -2
- package/dist/{token-D-S-4_mN.js.map → token-CAQWMtan.js.map} +1 -1
- package/dist/{trace-CFnhyCVf.js → trace-D3yBmJad.js} +2 -2
- package/dist/{trace-CFnhyCVf.js.map → trace-D3yBmJad.js.map} +1 -1
- package/dist/{trace-ZtgeY-8s.js → trace-DdXWjgAD.js} +3 -3
- package/dist/{trace-ZtgeY-8s.js.map → trace-DdXWjgAD.js.map} +1 -1
- package/dist/{style-CGaJndOl.js → types-BhdAXX7z.js} +268 -89
- package/dist/types-BhdAXX7z.js.map +1 -0
- package/dist/utils-B6HVRX10.js +42 -0
- package/dist/utils-B6HVRX10.js.map +1 -0
- package/dist/{utils-B5Xqf1lV.mjs → utils-C7UalRKf.mjs} +41 -7
- package/dist/utils-C7UalRKf.mjs.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DzydRwYo.js → utils-Cd4wqN56.js} +142 -149
- package/dist/utils-Cd4wqN56.js.map +1 -0
- package/dist/{utils-DaAiEEIG.mjs → utils-DjxH0zc7.mjs} +3 -3
- package/dist/{utils-DaAiEEIG.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CpJpQ00y.js +145 -0
- package/dist/value-CpJpQ00y.js.map +1 -0
- package/dist/{webpack-CHydnRXB.mjs → webpack-6et2ZVI6.mjs} +5 -5
- package/dist/webpack-6et2ZVI6.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/rsc_dev/adapter/preact.ts +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -0
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/shared/config_dev.ts +1 -1
- package/jsx/types/index.ts +3 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +98 -22
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +3 -8
- package/plugin/bundler/vite/state.ts +2 -2
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +208 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +50 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/classname/transform.ts +32 -1
- package/runtime/adapter/utils.ts +120 -0
- package/runtime/core/cache/combine.ts +33 -4
- package/runtime/core/cache/item.ts +31 -12
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/prop.ts +7 -6
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +179 -5
- package/runtime/extract/getClassName.ts +49 -6
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +179 -5
- package/runtime/types.ts +3 -3
- package/style/classname.ts +12 -6
- package/style/important.ts +19 -0
- package/style/index.ts +2 -0
- package/style/style.ts +16 -4
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/weight.ts +21 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-Do2Crx4b.js +0 -143
- package/dist/className-Do2Crx4b.js.map +0 -1
- package/dist/combine-C9vjpKCs.js.map +0 -1
- package/dist/combineStyle-DwAhsOmS.js +0 -26
- package/dist/combineStyle-DwAhsOmS.js.map +0 -1
- package/dist/compiler-CE0ZgkdH.mjs.map +0 -1
- package/dist/config-BE5D5x2N.js +0 -2
- package/dist/config-CduqubI8.js.map +0 -1
- package/dist/config-oKOjOTWi.js +0 -7
- package/dist/css-BewrRz3_.js +0 -243
- package/dist/css-BewrRz3_.js.map +0 -1
- package/dist/css-CiTI58yl.js +0 -1094
- package/dist/css-CiTI58yl.js.map +0 -1
- package/dist/css-Rc7ILf-3.js +0 -236
- package/dist/css-Rc7ILf-3.js.map +0 -1
- package/dist/cssIdent-BsyUXNNk.js +0 -38
- package/dist/cssIdent-BsyUXNNk.js.map +0 -1
- package/dist/cssVar-DGgQ2GIK.js +0 -92
- package/dist/cssVar-DGgQ2GIK.js.map +0 -1
- package/dist/css_extra-DYtS3g6Z.js +0 -8
- package/dist/css_extra-DYtS3g6Z.js.map +0 -1
- package/dist/data-D7NFt4JG.js.map +0 -1
- package/dist/debug-Cvpo5cVu.js.map +0 -1
- package/dist/dev-px0_6TNq.js +0 -81
- package/dist/dev-px0_6TNq.js.map +0 -1
- package/dist/elementMarker-ng0y3fN0.js.map +0 -1
- package/dist/extract-B-Vs88ME.js +0 -3
- package/dist/extract-CM8Fk2eK.js +0 -130
- package/dist/extract-CM8Fk2eK.js.map +0 -1
- package/dist/getClassName-CrNVjAoJ.js.map +0 -1
- package/dist/global-CZBlA9E7.js +0 -14
- package/dist/global-CZBlA9E7.js.map +0 -1
- package/dist/hash-BfeJDf5U.js.map +0 -1
- package/dist/jsx-BY1iFewe.js +0 -39
- package/dist/jsx-BY1iFewe.js.map +0 -1
- package/dist/jsx-DL-DEAz8.js +0 -39
- package/dist/jsx-DL-DEAz8.js.map +0 -1
- package/dist/layer-BSxAr-hy.js +0 -94
- package/dist/layer-BSxAr-hy.js.map +0 -1
- package/dist/loader-BmYS_Rju.mjs.map +0 -1
- package/dist/misc-BIS_c7BJ.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-BuLbzviK.js +0 -406
- package/dist/property-BuLbzviK.js.map +0 -1
- package/dist/rules-CxVzovt-.js.map +0 -1
- package/dist/selector-A-mRmMnI.js +0 -64
- package/dist/selector-A-mRmMnI.js.map +0 -1
- package/dist/shared-CaJuvw03.cjs.map +0 -1
- package/dist/sheet-BWBzuy4D.js +0 -7
- package/dist/style-CGaJndOl.js.map +0 -1
- package/dist/style-DDxjKdX0.js +0 -1891
- package/dist/style-DDxjKdX0.js.map +0 -1
- package/dist/style-S7LTQbRu.js +0 -5
- package/dist/styleStore-CajcAEPO.js.map +0 -1
- package/dist/symbols-Cp4ymzKF.js +0 -14
- package/dist/symbols-Cp4ymzKF.js.map +0 -1
- package/dist/utils-B5Xqf1lV.mjs.map +0 -1
- package/dist/utils-B_VhPBHH.js.map +0 -1
- package/dist/utils-CDUaX81o.js +0 -170
- package/dist/utils-CDUaX81o.js.map +0 -1
- package/dist/utils-DzydRwYo.js.map +0 -1
- package/dist/value-C0JRsyax.js +0 -64
- package/dist/value-C0JRsyax.js.map +0 -1
- package/dist/value-D08AocUs.js +0 -1053
- package/dist/value-D08AocUs.js.map +0 -1
- package/dist/valueRef-M3E1oza7.js +0 -16
- package/dist/valueRef-M3E1oza7.js.map +0 -1
- package/dist/webpack-CHydnRXB.mjs.map +0 -1
- package/dist/withTokens-DAzUIPvA.js +0 -95
- package/dist/withTokens-DAzUIPvA.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @fluentic/style
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2bff82f: Improve css-prop adapters, class-name extraction, and Next.js build stability.
|
|
8
|
+
|
|
9
|
+
- Preserve normal JSX prop precedence when compiling intrinsic `css` props through React, Preact, and Solid adapters.
|
|
10
|
+
- Keep React `key` props outside generated css-prop spreads so list identity is preserved.
|
|
11
|
+
- Improve React Server Component development handling for css-prop adapter imports, including client components.
|
|
12
|
+
- Make class-name extraction produce stable debug hashes and better source locations for class-name utilities.
|
|
13
|
+
- Add Tailwind class-name support for arbitrary text values such as `text-[13px]`, `text-[length:13px]`, and `text-[color:purple]`.
|
|
14
|
+
- Improve Next.js integration for dev CSS delivery, Turbopack loader options, and production CSS precollection.
|
|
15
|
+
- Add default export conditions for common package entry points.
|
|
16
|
+
|
|
17
|
+
## 0.1.0-beta.5
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Add attachable selector sheets for styling fixed third-party class names
|
|
22
|
+
without emitting global CSS.
|
|
23
|
+
|
|
24
|
+
- Add `style.selector(...)` selector targets and `createSheet(...)` from
|
|
25
|
+
`@fluentic/style/css` for manual selector rules that still attach through
|
|
26
|
+
generated Fluentic classes.
|
|
27
|
+
- Support selector overrides and token overrides inside sheets so component
|
|
28
|
+
wrappers can expose local third-party themes with the same shape as
|
|
29
|
+
scoped style composition.
|
|
30
|
+
- Add `&` and `&?` selector handling for attached-element and portal-friendly
|
|
31
|
+
selector rules. Comma-separated selector strings are rejected; pass an
|
|
32
|
+
array when a rule should target multiple selectors.
|
|
33
|
+
- Add `createStyleTarget(...)` for applying style props to explicit DOM
|
|
34
|
+
targets such as `document.body`, with shared-target reference counting for
|
|
35
|
+
overlapping portal users.
|
|
36
|
+
- Make `combineStyle(...)` compose sheets directly, and add
|
|
37
|
+
`combineStyle.with(...)` plus array-only `combineStyle.multi(...)` for
|
|
38
|
+
cache-friendly style and sheet composition.
|
|
39
|
+
- Support selector sheet extraction, local token overrides, debug class
|
|
40
|
+
names, source tracing, and sourcemap data across runtime and extracted
|
|
41
|
+
builds.
|
|
42
|
+
- Add Preact css-prop support with a `CssPropPresets.Preact` compiler
|
|
43
|
+
preset, runtime adapters, JSX types, and a Vite example.
|
|
44
|
+
- Keep plugin css-prop configuration focused on `CssPropPresets` instead of
|
|
45
|
+
exporting each framework preset as a separate top-level plugin API.
|
|
46
|
+
- Add `style.important(...)` and `className.important(...)` for interop cases
|
|
47
|
+
that need emitted `!important` declarations, especially selector sheets
|
|
48
|
+
wrapping third-party CSS.
|
|
49
|
+
- Add `style.weight(...)` as the style-object counterpart to
|
|
50
|
+
`className.weight(...)`.
|
|
51
|
+
- Keep the extracted production runtime below 5 KB minified and gzipped with
|
|
52
|
+
`combineStyle` included, and keep selector parsing helpers out of the
|
|
53
|
+
extracted production entry.
|
|
54
|
+
- Add a React Select third-party selectors example, Preact integration docs,
|
|
55
|
+
and a clearer third-party styling guide for selector sheets, style targets,
|
|
56
|
+
portal menus, and the new `combineStyle` helpers.
|
|
57
|
+
|
|
3
58
|
## 0.1.0-beta.4
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
|
@@ -27,7 +82,7 @@ for transform-driven styling.
|
|
|
27
82
|
### Highlights
|
|
28
83
|
|
|
29
84
|
- Add `createClassNameFn` for class-name-driven style builders.
|
|
30
|
-
- Support nested class-name values, conditional
|
|
85
|
+
- Support nested class-name values, conditional falsy entries, weighted
|
|
31
86
|
class-name tokens, selector chaining, at-rules, and merges.
|
|
32
87
|
- Add compiler extraction for class-name style chains.
|
|
33
88
|
- Add Tailwind presets for both style-object and class-name authoring.
|
package/README.md
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
# Fluentic Style
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build your own styling language on top of a stable component styling model.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Styling UI apps has a lot of good answers already: CSS files, utility classes,
|
|
6
6
|
CSS-in-JS, compiled CSS, design tokens, and component libraries. Fluentic
|
|
7
7
|
explores a specific question inside that space: what if styles composed around
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
With Fluentic, you start simple with type-safe `style(...)` and
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
components the same way props, state, and themes do?
|
|
9
|
+
|
|
10
|
+
With Fluentic, you start simple with type-safe `style(...)` values and attach
|
|
11
|
+
them through a JSX `css` prop or a framework adapter. React, Preact, and SolidJS
|
|
12
|
+
are supported today, with the core style data model designed to keep expanding
|
|
13
|
+
across JSX runtimes, compiler-backed frameworks, and server-rendered UI stacks.
|
|
14
|
+
If your team prefers utility class names, you can also create class-name style
|
|
15
|
+
chains, including a Tailwind-like preset.
|
|
16
|
+
|
|
17
|
+
When a component needs variants, themes, nested parts, or consumer overrides,
|
|
18
|
+
add slots, scopes, tokens, values, and `combineStyle(...)` so those styles stay
|
|
19
|
+
organized around the component instead of leaking through class names or private
|
|
20
|
+
DOM structure. For production builds, Fluentic extracts static styles into
|
|
21
|
+
atomic CSS output while dynamic values from props, state, signals, or request
|
|
22
|
+
data still work at runtime.
|
|
18
23
|
|
|
19
24
|
[Docs](https://fluenticstack.com/style) |
|
|
20
|
-
[
|
|
25
|
+
[Start here](https://fluenticstack.com/style/docs/learn/start-here/) |
|
|
21
26
|
[Playground](https://fluenticstack.com/style/playground/) |
|
|
22
27
|
[npm](https://www.npmjs.com/package/@fluentic/style)
|
|
23
28
|
|
|
@@ -35,13 +40,35 @@ Or with pnpm:
|
|
|
35
40
|
pnpm add @fluentic/style@beta
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
Use Fluentic in a
|
|
39
|
-
extraction.
|
|
43
|
+
Use Fluentic in a JSX app. Add a bundler or framework plugin when you want
|
|
44
|
+
production extraction.
|
|
45
|
+
|
|
46
|
+
## What Fluentic Supports
|
|
47
|
+
|
|
48
|
+
Fluentic is not tied to one styling vocabulary or one framework runtime. The
|
|
49
|
+
same style model powers CSS-like objects, custom design-system fields,
|
|
50
|
+
Tailwind-like object fields, class-name chains, slots, scopes, themes, tokens,
|
|
51
|
+
runtime values, static extraction, and development traces.
|
|
52
|
+
|
|
53
|
+
| Area | Support |
|
|
54
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| Core styling model | [`style(...)`](https://fluenticstack.com/style/docs/reference/style/), [`style.slot(...)`](https://fluenticstack.com/style/docs/reference/style-slot/), [`style.scope(...)`](https://fluenticstack.com/style/docs/reference/style-scope/), [`combineStyle(...)`](https://fluenticstack.com/style/docs/reference/combine-style/), themes, tokens, values, selectors, at-rules, keyframes, and font faces. |
|
|
56
|
+
| Authoring vocabularies | CSS-like object styles, custom style functions, custom selectors, custom properties, Tailwind-like object fields, and Tailwind-like class-name chains. |
|
|
57
|
+
| Runtime paths | Runtime-only JSX setup for quick adoption, compiler-backed extracted runtime for production, and framework css-prop adapters that keep the framework's normal JSX transform. |
|
|
58
|
+
| Frameworks today | React, Next.js App Router, Preact, and SolidJS. |
|
|
59
|
+
| Bundlers today | Vite, Webpack, Rspack, Farm, Parcel 2, Babel/custom compiler use, and the Next.js integration for App Router projects. |
|
|
60
|
+
| Development tools | Readable debug class names, source traces, JSX element markers, sourcemaps, priority inspection, and React Server Component development support for Next.js. |
|
|
61
|
+
|
|
62
|
+
See the [integration overview](https://fluenticstack.com/style/docs/integrations/overview/)
|
|
63
|
+
for setup guides and the
|
|
64
|
+
[reference overview](https://fluenticstack.com/style/docs/reference/overview/)
|
|
65
|
+
for the API surface.
|
|
40
66
|
|
|
41
67
|
## Configure Runtime JSX
|
|
42
68
|
|
|
43
69
|
Enable the runtime JSX import source so DOM and SVG elements accept the `css`
|
|
44
|
-
prop. This path works without a Fluentic bundler plugin
|
|
70
|
+
prop. This path works without a Fluentic bundler plugin and is the quickest
|
|
71
|
+
React setup path.
|
|
45
72
|
|
|
46
73
|
```jsonc
|
|
47
74
|
/* tsconfig.json */
|
|
@@ -53,10 +80,14 @@ prop. This path works without a Fluentic bundler plugin.
|
|
|
53
80
|
}
|
|
54
81
|
```
|
|
55
82
|
|
|
83
|
+
For SolidJS and Preact, keep the framework's normal JSX configuration and use
|
|
84
|
+
the Vite css-prop adapter instead:
|
|
85
|
+
[SolidJS](https://fluenticstack.com/style/docs/integrations/solidjs/) and
|
|
86
|
+
[PreactJS](https://fluenticstack.com/style/docs/integrations/preact/).
|
|
87
|
+
|
|
56
88
|
## Why Another Style Library?
|
|
57
89
|
|
|
58
|
-
Component
|
|
59
|
-
need:
|
|
90
|
+
Component systems need more than a way to attach styles to elements. They need:
|
|
60
91
|
|
|
61
92
|
- base styles owned by the component;
|
|
62
93
|
- state styles for hover, focus, active, disabled, media, and container queries;
|
|
@@ -98,8 +129,9 @@ export function Card() {
|
|
|
98
129
|
}
|
|
99
130
|
```
|
|
100
131
|
|
|
101
|
-
That is the smallest version of Fluentic Style: type-safe styles, selectors,
|
|
102
|
-
a
|
|
132
|
+
That is the smallest version of Fluentic Style: type-safe styles, selectors,
|
|
133
|
+
and a component-owned style value attached to JSX. The example uses React-style
|
|
134
|
+
syntax, but the same style data can be lowered through framework adapters.
|
|
103
135
|
|
|
104
136
|
## Class Name Chains
|
|
105
137
|
|
|
@@ -146,7 +178,11 @@ for the built-in Tailwind-like class-name vocabulary.
|
|
|
146
178
|
|
|
147
179
|
## Scale Into Components
|
|
148
180
|
|
|
149
|
-
When a component becomes reusable, give its styles component structure.
|
|
181
|
+
When a component becomes reusable, give its styles component structure. This
|
|
182
|
+
section uses React component types for the example, but the important part is
|
|
183
|
+
the framework-independent style model: slots name public styling targets, scopes
|
|
184
|
+
describe changes to those targets, and the component decides where resolved
|
|
185
|
+
styles attach.
|
|
150
186
|
|
|
151
187
|
```tsx
|
|
152
188
|
/* tokens.ts */
|
|
@@ -329,15 +365,24 @@ priority with layers or sorted output.
|
|
|
329
365
|
|
|
330
366
|
## Add Production Extraction
|
|
331
367
|
|
|
332
|
-
Fluentic Style works without a compiler. In runtime mode, the JSX `css`
|
|
333
|
-
resolves class names and inserts atomic CSS rules as needed.
|
|
368
|
+
Fluentic Style works without a compiler. In runtime-only mode, the JSX `css`
|
|
369
|
+
prop resolves class names and inserts atomic CSS rules as needed. That is useful
|
|
370
|
+
for trying the API, custom environments, and incremental adoption.
|
|
371
|
+
|
|
372
|
+
For production builds, add a bundler or framework plugin. Static styles are
|
|
373
|
+
extracted into ordered atomic CSS output. Runtime composition stays available
|
|
374
|
+
for values that still depend on props, state, signals, request data, user input,
|
|
375
|
+
or incoming themes.
|
|
376
|
+
|
|
377
|
+
There are two integration shapes:
|
|
334
378
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
379
|
+
- React apps can use Fluentic's JSX runtime import source, switching from
|
|
380
|
+
`@fluentic/style/jsx` to `@fluentic/style/plugin/jsx` after adding a plugin.
|
|
381
|
+
- React, Preact, and SolidJS can also use a compiler css-prop adapter, letting
|
|
382
|
+
the framework keep its normal JSX runtime while Fluentic compiles
|
|
383
|
+
`css={...}` before the framework JSX transform runs.
|
|
338
384
|
|
|
339
|
-
|
|
340
|
-
`@fluentic/style/jsx` to `@fluentic/style/plugin/jsx`.
|
|
385
|
+
The React JSX-runtime setup looks like this:
|
|
341
386
|
|
|
342
387
|
```jsonc
|
|
343
388
|
/* tsconfig.json */
|
|
@@ -369,8 +414,38 @@ export default defineConfig({
|
|
|
369
414
|
development sourcemaps, and extracted CSS output. See
|
|
370
415
|
[Plugin Options](https://fluenticstack.com/style/docs/reference/plugin-options/).
|
|
371
416
|
|
|
372
|
-
|
|
373
|
-
|
|
417
|
+
The framework-adapter setup passes a css-prop preset to the plugin. This is the
|
|
418
|
+
normal path for SolidJS and Preact, and an optional path for React:
|
|
419
|
+
|
|
420
|
+
```ts
|
|
421
|
+
/* vite.config.ts */
|
|
422
|
+
import { CssPropPresets, plugin as stylePlugin } from '@fluentic/style/plugin/vite';
|
|
423
|
+
import { defineConfig } from 'vite';
|
|
424
|
+
|
|
425
|
+
export default defineConfig({
|
|
426
|
+
plugins: [
|
|
427
|
+
stylePlugin({
|
|
428
|
+
cssProp: CssPropPresets.Solid,
|
|
429
|
+
}),
|
|
430
|
+
// then the framework JSX plugin, such as vite-plugin-solid
|
|
431
|
+
],
|
|
432
|
+
});
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
For framework and bundler-specific setup, see:
|
|
436
|
+
|
|
437
|
+
| Environment | Guide |
|
|
438
|
+
| -------------------------- | ----------------------------------------------------------------------------------------- |
|
|
439
|
+
| Next.js App Router | [Next.js](https://fluenticstack.com/style/docs/integrations/nextjs/) |
|
|
440
|
+
| Vite + React | [Vite](https://fluenticstack.com/style/docs/integrations/vite/) |
|
|
441
|
+
| Vite + SolidJS | [SolidJS](https://fluenticstack.com/style/docs/integrations/solidjs/) |
|
|
442
|
+
| Vite + Preact | [PreactJS](https://fluenticstack.com/style/docs/integrations/preact/) |
|
|
443
|
+
| Webpack | [Webpack](https://fluenticstack.com/style/docs/integrations/webpack/) |
|
|
444
|
+
| Rspack | [Rspack](https://fluenticstack.com/style/docs/integrations/rspack/) |
|
|
445
|
+
| Farm | [Farm](https://fluenticstack.com/style/docs/integrations/farm/) |
|
|
446
|
+
| Parcel 2 | [Parcel](https://fluenticstack.com/style/docs/integrations/parcel/) |
|
|
447
|
+
| Runtime-only | [Runtime-Only Mode](https://fluenticstack.com/style/docs/integrations/runtime-only-mode/) |
|
|
448
|
+
| Custom compiler or bundler | [Custom Compiler](https://fluenticstack.com/style/docs/integrations/custom-compiler/) |
|
|
374
449
|
|
|
375
450
|
## Benchmarks
|
|
376
451
|
|
|
@@ -380,7 +455,7 @@ production builds. Current benchmark snapshots:
|
|
|
380
455
|
The main production checks are runtime cost and bundle size. In the production
|
|
381
456
|
path most apps use, Fluentic extracts CSS at build time and ships the extracted
|
|
382
457
|
production runtime for `css` prop composition, dynamic values, class-name
|
|
383
|
-
merging, and token resolution. That runtime entry currently reports `4.
|
|
458
|
+
merging, and token resolution. That runtime entry currently reports `4.92 KB`
|
|
384
459
|
min+gzip.
|
|
385
460
|
Browser and SSR benchmarks track whether style resolution stays fast in
|
|
386
461
|
app-shaped renders. See the
|
package/atomic/className.ts
CHANGED
|
@@ -3,16 +3,17 @@ import { CSS_CONFIG } from '../config/config/css';
|
|
|
3
3
|
import { DEV_CONFIG } from '../config/config/dev';
|
|
4
4
|
import type { ClassNameFormat, TransformClassNameFormat } from '../config/types';
|
|
5
5
|
import { hashString } from '../utils/hash';
|
|
6
|
-
import { getDebugClassName, getDebugTransformClassName } from './debug/className';
|
|
6
|
+
import { getDebugClassName, getDebugSheetClassName, getDebugTransformClassName } from './debug/className';
|
|
7
7
|
import { getDebugPropertyName } from './debug/property';
|
|
8
8
|
import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
|
|
9
9
|
export { getScopeClassName } from './scope';
|
|
10
10
|
import { getIdentifierSafeHash } from './utils/hash';
|
|
11
|
-
import { getSelectorHash, getSelectorText } from './utils/selector';
|
|
11
|
+
import { getSelectorHash, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
|
|
12
12
|
|
|
13
13
|
export function getAtomicClassName(
|
|
14
14
|
property: string,
|
|
15
15
|
priority: number | null,
|
|
16
|
+
important: boolean,
|
|
16
17
|
value: string,
|
|
17
18
|
selector: ItemSelector | null,
|
|
18
19
|
parentSelector: ItemSelector | null,
|
|
@@ -23,11 +24,13 @@ export function getAtomicClassName(
|
|
|
23
24
|
classNameFormat: ClassNameFormat | null,
|
|
24
25
|
transformClassName: string | null,
|
|
25
26
|
transformClassNameFormat: TransformClassNameFormat | null,
|
|
27
|
+
sheetClassNameFormat: ClassNameFormat | null = null,
|
|
26
28
|
hashLength: number | null = null,
|
|
27
29
|
) {
|
|
28
30
|
let hash = property;
|
|
29
31
|
|
|
30
32
|
hash += '\n' + (priority || '');
|
|
33
|
+
if (important) hash += '\nimportant';
|
|
31
34
|
hash += '\n' + value;
|
|
32
35
|
hash += '\n' + (selector ? getSelectorHash(selector) : '');
|
|
33
36
|
hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
|
|
@@ -51,8 +54,9 @@ export function getAtomicClassName(
|
|
|
51
54
|
|
|
52
55
|
const propertyName = getDebugPropertyName(property, value);
|
|
53
56
|
|
|
54
|
-
const
|
|
55
|
-
|
|
57
|
+
const isSheetClassName = hasSheetSelectorAnchor(selector);
|
|
58
|
+
const className = (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(
|
|
59
|
+
isSheetClassName ? sheetClassNameFormat : classNameFormat,
|
|
56
60
|
hash,
|
|
57
61
|
{
|
|
58
62
|
atRule: atRule
|
|
@@ -77,13 +81,31 @@ export function getAtomicClassName(
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
function getRuntimeClassNameHashLength(debugClassName: boolean) {
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
return getClassNameHashLength({
|
|
85
|
+
debugClassName,
|
|
86
|
+
isDev: DEV_CONFIG.isDev,
|
|
87
|
+
devHashLength: DEV_CONFIG.hashLength,
|
|
88
|
+
cssHashLength: CSS_CONFIG.hashLength,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getClassNameHashLength(options: {
|
|
93
|
+
debugClassName: boolean;
|
|
94
|
+
isDev: boolean;
|
|
95
|
+
devHashLength?: number | null;
|
|
96
|
+
cssHashLength?: number | null;
|
|
97
|
+
}) {
|
|
98
|
+
if (options.debugClassName && options.isDev) {
|
|
99
|
+
return options.devHashLength ?? options.cssHashLength ?? 3;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return options.cssHashLength ?? 7;
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
export function getClassNameDedupe(
|
|
85
106
|
property: string,
|
|
86
107
|
priority: number | null,
|
|
108
|
+
important: boolean,
|
|
87
109
|
selector: ItemSelector | null,
|
|
88
110
|
parentSelector: ItemSelector | null,
|
|
89
111
|
atRule: ItemSelector[] | null,
|
|
@@ -91,6 +113,7 @@ export function getClassNameDedupe(
|
|
|
91
113
|
let hash = property;
|
|
92
114
|
|
|
93
115
|
hash += '\n' + (priority || '');
|
|
116
|
+
if (important) hash += '\nimportant';
|
|
94
117
|
hash += '\n' + (selector ? getSelectorHash(selector) : '');
|
|
95
118
|
hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
|
|
96
119
|
hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
|
|
@@ -8,6 +8,8 @@ import { createNameFormatter } from '../../utils/format';
|
|
|
8
8
|
|
|
9
9
|
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash';
|
|
10
10
|
|
|
11
|
+
export const SHEET_CLASS_NAME_FORMAT = 'sheet-(property)[-(value)]--$hash';
|
|
12
|
+
|
|
11
13
|
export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
|
|
12
14
|
|
|
13
15
|
export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
@@ -30,6 +32,14 @@ export function getDebugClassName(
|
|
|
30
32
|
return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
export function getDebugSheetClassName(
|
|
36
|
+
format: ClassNameFormat | null,
|
|
37
|
+
hash: string,
|
|
38
|
+
info: ClassNameInfo,
|
|
39
|
+
) {
|
|
40
|
+
return formatClassName(format || SHEET_CLASS_NAME_FORMAT, hash, info);
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
export function getDebugTransformClassName(
|
|
34
44
|
format: TransformClassNameFormat | null,
|
|
35
45
|
hash: string,
|
package/atomic/rule.ts
CHANGED
|
@@ -4,23 +4,26 @@ import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } fro
|
|
|
4
4
|
import { getCssPropertyName, getPropertyPriority } from './property';
|
|
5
5
|
import { getScopeClassName } from './scope';
|
|
6
6
|
import { escapeCssIdent } from './utils/cssIdent';
|
|
7
|
-
import { getSelectorPriority, getSelectorText } from './utils/selector';
|
|
7
|
+
import { getSelectorPriority, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
|
|
8
8
|
import { getCssPropertyValue } from './value';
|
|
9
9
|
|
|
10
10
|
export function buildAtomicRule(
|
|
11
11
|
className: string,
|
|
12
12
|
property: string,
|
|
13
13
|
value: string,
|
|
14
|
+
important: boolean,
|
|
14
15
|
selector: ItemSelector | null,
|
|
15
16
|
parentSelector: ItemSelector | null,
|
|
16
17
|
atRules: ItemSelector[] | null,
|
|
17
18
|
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
18
19
|
): string {
|
|
19
20
|
const cssProp = getCssPropertyName(property);
|
|
20
|
-
const cssValue = getCssPropertyValue(property, value);
|
|
21
|
+
const cssValue = getCssPropertyValue(property, value) + (important ? ' !important' : '');
|
|
21
22
|
const escapedClass = escapeCssIdent(className);
|
|
22
23
|
|
|
23
|
-
const classSelector =
|
|
24
|
+
const classSelector = hasSheetSelectorAnchor(selector)
|
|
25
|
+
? `:where(.${escapedClass})`
|
|
26
|
+
: '.' + escapedClass;
|
|
24
27
|
const itemSelector = selector ? getSelectorText(selector) : '';
|
|
25
28
|
|
|
26
29
|
let selectorStr = classSelector + itemSelector;
|
package/atomic/utils/hash.ts
CHANGED
|
@@ -1,72 +1,8 @@
|
|
|
1
|
-
import { globalData } from '../../utils/global';
|
|
2
1
|
import { hashString, normalizeHashLength } from '../../utils/hash';
|
|
3
2
|
|
|
4
|
-
type PooledHashState = {
|
|
5
|
-
byValue: Map<string, string>;
|
|
6
|
-
byHash: Map<string, string>;
|
|
7
|
-
usedByLength: number[];
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const POOLED_HASH_STATE = globalData<PooledHashState>(
|
|
11
|
-
'atomic.hashPool',
|
|
12
|
-
() => ({
|
|
13
|
-
byValue: new Map(),
|
|
14
|
-
byHash: new Map(),
|
|
15
|
-
usedByLength: [],
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
3
|
export function getIdentifierSafeHash(value: string, startLength = 7) {
|
|
20
|
-
return getPooledHash(value, startLength);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getPooledHash(value: string, startLength: number) {
|
|
24
4
|
const normalizedStartLength = normalizeHashLength(startLength);
|
|
25
|
-
|
|
26
|
-
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
27
|
-
if (existing) return existing;
|
|
28
|
-
|
|
29
|
-
let length = normalizedStartLength;
|
|
30
|
-
|
|
31
|
-
while (true) {
|
|
32
|
-
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
33
|
-
length++;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
38
|
-
const hash = getPooledHashCandidate(value, length, index);
|
|
39
|
-
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
40
|
-
|
|
41
|
-
if (owner !== undefined && owner !== valueKey) continue;
|
|
42
|
-
|
|
43
|
-
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
44
|
-
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
45
|
-
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
46
|
-
return hash;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
length++;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getPooledHashCandidate(
|
|
54
|
-
value: string,
|
|
55
|
-
length: number,
|
|
56
|
-
index: number,
|
|
57
|
-
) {
|
|
58
|
-
const hashValue = index === 0 ? value : value + '::' + index;
|
|
59
|
-
return getIdentifierSafeHashValue(hashString(hashValue)).slice(0, length);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getPooledHashUsedCount(length: number) {
|
|
63
|
-
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function getIdentifierSafeHashPoolSize(length: number) {
|
|
67
|
-
if (length <= 0) return 0;
|
|
68
|
-
|
|
69
|
-
return 26 * 36 ** (length - 1);
|
|
5
|
+
return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
|
|
70
6
|
}
|
|
71
7
|
|
|
72
8
|
function getIdentifierSafeHashValue(hash: string) {
|
package/atomic/utils/selector.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { SHEET_SELECTOR_ANCHOR } from '../../builder/data/const';
|
|
1
2
|
import type { ItemSelector } from '../../builder/data/state';
|
|
2
3
|
|
|
3
4
|
export function getSelectorText(selector: ItemSelector): string {
|
|
4
|
-
|
|
5
|
+
const text = Array.isArray(selector) ? selector[0] : selector;
|
|
6
|
+
return stripSheetSelectorAnchor(text);
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export function getSelectorHash(selector: ItemSelector): string {
|
|
@@ -12,3 +14,14 @@ export function getSelectorPriority(selector: ItemSelector | null): number {
|
|
|
12
14
|
if (!selector) return 0;
|
|
13
15
|
return Array.isArray(selector) ? selector[1] : 0;
|
|
14
16
|
}
|
|
17
|
+
|
|
18
|
+
export function hasSheetSelectorAnchor(selector: ItemSelector | null): boolean {
|
|
19
|
+
const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
|
|
20
|
+
return text.startsWith(SHEET_SELECTOR_ANCHOR);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function stripSheetSelectorAnchor(selector: string) {
|
|
24
|
+
return selector.startsWith(SHEET_SELECTOR_ANCHOR)
|
|
25
|
+
? selector.slice(SHEET_SELECTOR_ANCHOR.length)
|
|
26
|
+
: selector;
|
|
27
|
+
}
|