@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.10
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 +150 -2
- package/README.md +181 -49
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +50 -12
- package/atomic/debug/className/className.ts +24 -8
- package/atomic/element.ts +5 -2
- package/atomic/rule.ts +11 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +44 -3
- package/atomic/token.ts +7 -4
- package/atomic/utils/cssIdent.ts +54 -0
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +14 -0
- package/atomic/utils/selector.ts +31 -1
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +491 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +41 -0
- package/builder/data/const.ts +8 -1
- package/builder/data/create.ts +52 -6
- package/builder/data/data.ts +33 -8
- package/builder/data/debug.ts +1 -0
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +26 -3
- package/builder/data/merge/scope.ts +38 -38
- package/builder/data/merge/style.ts +115 -20
- package/builder/data/state.ts +17 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +30 -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 +31 -0
- package/builder/selector_override_core.ts +79 -0
- package/builder/style_builder.ts +144 -20
- package/builder/style_data.ts +25 -0
- package/builder/style_fns.ts +57 -57
- 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 +44 -16
- package/builder/types/fns.ts +24 -16
- package/builder/types/types.ts +37 -7
- 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 +4 -1
- package/compiler/cssProp.ts +21 -0
- package/compiler/extract/extract.ts +42 -14
- package/compiler/extract/types.ts +2 -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 +93 -4
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +169 -32
- package/compiler/transform/evaluator/tracer.ts +48 -11
- package/compiler/transform/extract/chain/chain.ts +1370 -162
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +3 -1
- package/compiler/transform/extract/plugin.ts +64 -6
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +72 -2
- package/compiler/transform/extract/utils/state.ts +3 -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 +12 -5
- package/compiler/utils/file_resolver.ts +2 -0
- package/compiler/utils/import_source.ts +19 -8
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +9 -2
- package/config/config/check.ts +25 -0
- package/config/config/css.ts +18 -1
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +19 -2
- package/config/types.ts +7 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +152 -0
- package/css/styleTarget.ts +251 -0
- package/dev/config.ts +2 -3
- package/dev/utils.ts +3 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +153 -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-yhJCGT0F.js +304 -0
- package/dist/className-yhJCGT0F.js.map +1 -0
- package/dist/combine-Bww7VnSr.js +1254 -0
- package/dist/combine-Bww7VnSr.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
- package/dist/compiler-C3CEGGtI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BAEzRmSJ.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
- package/dist/config-BKP5LOkt.js +35 -0
- package/dist/config-BKP5LOkt.js.map +1 -0
- package/dist/config-C5VWvTav.js +34 -0
- package/dist/config-C5VWvTav.js.map +1 -0
- package/dist/config-CB4lm2tM.js +1 -0
- package/dist/config-CDjbHwb-.js +6 -0
- package/dist/config-CDjbHwb-.js.map +1 -0
- package/dist/config-DNEnHEf3.js +36 -0
- package/dist/config-DNEnHEf3.js.map +1 -0
- package/dist/createTransformElement-D8fXZ3wA.js +34 -0
- package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
- package/dist/css-BDn0epJ8.js +1339 -0
- package/dist/css-BDn0epJ8.js.map +1 -0
- package/dist/css-CFxNrYt3.js +4040 -0
- package/dist/css-CFxNrYt3.js.map +1 -0
- package/dist/css-DEYgrj76.js +524 -0
- package/dist/css-DEYgrj76.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
- package/dist/css-DWBWsyxZ.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
- package/dist/data-CDrS1Bq4.js +785 -0
- package/dist/data-CDrS1Bq4.js.map +1 -0
- package/dist/debug-BkVbf0Cz.js +52 -0
- package/dist/debug-BkVbf0Cz.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
- package/dist/debug-YuhEIQVO.js.map +1 -0
- package/dist/dev/rsc.js +10 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
- package/dist/dev-0imWmSVb.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
- package/dist/elementMarker-kvpMjB49.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 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +13 -9
- 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 +242 -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 +84 -1201
- 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 +11 -13
- 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 +582 -664
- 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 +242 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
- package/dist/env-Cz8frh6e.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js +545 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
- package/dist/getClassName-DGm-VNDo.js.map +1 -0
- package/dist/getClassName-Dtc4yyYI.js +47 -0
- package/dist/getClassName-Dtc4yyYI.js.map +1 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
- package/dist/getClassName-DtkplEIt.js.map +1 -0
- package/dist/global-CAc9OjKx.js +14 -0
- package/dist/global-CAc9OjKx.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +10 -8
- 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-CVxpkS04.js +39 -0
- package/dist/jsx-CVxpkS04.js.map +1 -0
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
- package/dist/misc-B76PUnWe.mjs.map +1 -0
- package/dist/namedTokens-5AayGokX.js +85 -0
- package/dist/namedTokens-5AayGokX.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 +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 +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 +13 -10
- 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 +995 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
- package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
- package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
- package/dist/rules-DaMaMHgb.js.map +1 -0
- package/dist/scope-CZdGAnl_.js +601 -0
- package/dist/scope-CZdGAnl_.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
- package/dist/shared-PK52rW6T.cjs.map +1 -0
- package/dist/sheet-CxkO1Hwt.js +7 -0
- package/dist/sheet-CxkO1Hwt.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
- package/dist/style-CAhAnRni.js +1129 -0
- package/dist/style-CAhAnRni.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
- package/dist/styleStore-BzLZwpwy.js.map +1 -0
- package/dist/styleStore-DaIJ4OPV.js +58 -0
- package/dist/styleStore-DaIJ4OPV.js.map +1 -0
- package/dist/token-D33mKTka.js +138 -0
- package/dist/token-D33mKTka.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
- package/dist/transform-DSpimwwC.js +23 -0
- package/dist/transform-DSpimwwC.js.map +1 -0
- package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
- package/dist/utils-DZK0mfmY.js +42 -0
- package/dist/utils-DZK0mfmY.js.map +1 -0
- package/dist/utils-D_XgtMtn.js +72 -0
- package/dist/utils-D_XgtMtn.js.map +1 -0
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
- package/dist/utils-H1VInWpd.js.map +1 -0
- package/dist/utils-NdisireF.mjs +182 -0
- package/dist/utils-NdisireF.mjs.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CK0-Xbov.js +160 -0
- package/dist/value-CK0-Xbov.js.map +1 -0
- package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
- package/dist/webpack-D7QO0bKN.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/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -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 +4 -2
- 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_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- 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/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +14 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/jsx/types/index.ts +1 -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 +110 -8
- 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 +5 -9
- package/plugin/bundler/vite/state.ts +11 -6
- 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 +121 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +15 -2
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +239 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +436 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/adapter/utils.ts +120 -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 +16 -31
- 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 +55 -23
- package/runtime/extract/index.ts +4 -2
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/index.ts +8 -1
- package/runtime/rsc/getClassName.ts +4 -0
- package/runtime/rsc/observer.ts +4 -0
- package/runtime/rsc/styleStore.ts +18 -7
- package/runtime/sheet/rule.ts +16 -12
- package/runtime/sheet/rules.ts +8 -3
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +6 -4
- package/sheet/dev/dev_layer.ts +18 -7
- package/sheet/dev/dev_sort.ts +45 -11
- package/sheet/prod.ts +18 -7
- package/sheet/types.ts +2 -0
- package/sheet/utils/layer.ts +33 -0
- package/style/classname.ts +47 -0
- package/style/important.ts +19 -0
- package/style/index.ts +3 -0
- package/style/style.ts +47 -16
- package/style/theme.ts +4 -3
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +41 -2
- 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/hash.ts +4 -0
- package/utils/symbol.ts +3 -0
- package/atomic/layer/README.md +0 -116
- package/atomic/utils/css.ts +0 -49
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-C1Ht5Wvv.js +0 -144
- package/dist/className-C1Ht5Wvv.js.map +0 -1
- package/dist/className-DC2Cq8p3.js +0 -251
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-BryWDfQX.js +0 -25
- package/dist/config-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js +0 -243
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js +0 -805
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js +0 -235
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/css_extra-DlOnsnR1.js +0 -8
- package/dist/css_extra-oIi3UEPK.js.map +0 -1
- package/dist/data-BsqOa5br.js +0 -473
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-CcphAa3R.js.map +0 -1
- package/dist/dev-DfBbuLeE.js +0 -71
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/global-CvfmFLsK.js.map +0 -1
- package/dist/jsx-CwTeyUxr.js +0 -39
- package/dist/jsx-CwTeyUxr.js.map +0 -1
- package/dist/jsx-D2BksHSv.js +0 -38
- package/dist/jsx-D2BksHSv.js.map +0 -1
- package/dist/layer-D1SaH07m.js +0 -94
- package/dist/layer-D1SaH07m.js.map +0 -1
- package/dist/loader-B5Kw0DD-.mjs.map +0 -1
- package/dist/misc-DCdYYyhK.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CnLFt5kx.js +0 -406
- package/dist/property-CnLFt5kx.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js +0 -752
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js +0 -1269
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/styleStore-DyNXBcUK.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-u_tM-mtg.js +0 -204
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/utils-CEaq_c-A.mjs +0 -97
- package/dist/utils-CEaq_c-A.mjs.map +0 -1
- package/dist/utils-CWNHx4EC.js +0 -170
- package/dist/utils-CWNHx4EC.js.map +0 -1
- package/dist/utils-D7FAOyg6.js.map +0 -1
- package/dist/value-BR4e2MKt.js +0 -910
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
- package/dist/valueRef-lshFk1Cs.js +0 -16
- package/dist/valueRef-lshFk1Cs.js.map +0 -1
- package/dist/webpack-Dh6lox2l.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.js.map +0 -1
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ClassNameFormat,
|
|
3
|
+
ClassNameInfo,
|
|
4
|
+
TransformClassNameFormat,
|
|
5
|
+
TransformClassNameInfo,
|
|
6
|
+
} from '../../../config/types';
|
|
2
7
|
import { createNameFormatter } from '../../utils/format';
|
|
3
8
|
|
|
4
|
-
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
9
|
+
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash';
|
|
5
10
|
|
|
6
|
-
export const
|
|
11
|
+
export const SHEET_CLASS_NAME_FORMAT = 'sheet-(property)[-(value)]--$hash';
|
|
12
|
+
|
|
13
|
+
export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
|
|
7
14
|
|
|
8
15
|
export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
9
16
|
'atRule',
|
|
@@ -13,7 +20,7 @@ export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
|
13
20
|
'value',
|
|
14
21
|
]);
|
|
15
22
|
|
|
16
|
-
export const
|
|
23
|
+
export const formatTransformClassName = createNameFormatter<TransformClassNameInfo>([
|
|
17
24
|
'className',
|
|
18
25
|
]);
|
|
19
26
|
|
|
@@ -25,9 +32,18 @@ export function getDebugClassName(
|
|
|
25
32
|
return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
export function
|
|
29
|
-
format:
|
|
30
|
-
|
|
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
|
+
|
|
43
|
+
export function getDebugTransformClassName(
|
|
44
|
+
format: TransformClassNameFormat | null,
|
|
45
|
+
hash: string,
|
|
46
|
+
info: TransformClassNameInfo,
|
|
31
47
|
) {
|
|
32
|
-
return
|
|
48
|
+
return formatTransformClassName(format || TRANSFORM_CLASS_NAME_FORMAT, hash, info);
|
|
33
49
|
}
|
package/atomic/element.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
2
|
+
import { DEV_CONFIG } from '../config/config/dev';
|
|
1
3
|
import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
|
|
2
|
-
import { escapeCssIdent
|
|
4
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
3
5
|
import { sanitizeDebugName } from './utils/debug';
|
|
4
6
|
import { createNameFormatter } from './utils/format';
|
|
7
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
5
8
|
|
|
6
9
|
export const ELEMENT_CLASS_NAME_FORMAT = '@(name)';
|
|
7
10
|
|
|
@@ -15,7 +18,7 @@ export function getElementClassName(
|
|
|
15
18
|
elementClassNameFormat: ElementClassNameFormat | null,
|
|
16
19
|
) {
|
|
17
20
|
const name = sanitizeDebugName(label) || null;
|
|
18
|
-
const hash = getIdentifierSafeHash(id);
|
|
21
|
+
const hash = getIdentifierSafeHash(id, DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 5);
|
|
19
22
|
|
|
20
23
|
return formatElementClassName(
|
|
21
24
|
elementClassNameFormat || ELEMENT_CLASS_NAME_FORMAT,
|
package/atomic/rule.ts
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import type { ItemSelector } from '../builder/data/state';
|
|
2
2
|
import type { ScopeClassNameFormat } from '../config/types';
|
|
3
|
-
import { getScopeClassName } from './className';
|
|
4
3
|
import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } from './layer';
|
|
5
4
|
import { getCssPropertyName, getPropertyPriority } from './property';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { getScopeClassName } from './scope';
|
|
6
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
7
|
+
import { getSelectorPriority, getSelectorText, getSheetSelectorWeight, 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
|
|
24
|
+
const sheetWeight = getSheetSelectorWeight(selector);
|
|
25
|
+
const classSelector = sheetWeight
|
|
26
|
+
? Array(sheetWeight).fill('.' + escapedClass).join('')
|
|
27
|
+
: hasSheetSelectorAnchor(selector)
|
|
28
|
+
? `:where(.${escapedClass})`
|
|
29
|
+
: '.' + escapedClass;
|
|
24
30
|
const itemSelector = selector ? getSelectorText(selector) : '';
|
|
25
31
|
|
|
26
32
|
let selectorStr = classSelector + itemSelector;
|
package/atomic/scope.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ScopeClassNameFormat, ScopeClassNameInfo } from '../config/types';
|
|
2
|
+
|
|
3
|
+
export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
|
|
4
|
+
|
|
5
|
+
export function getScopeClassName(
|
|
6
|
+
className: string,
|
|
7
|
+
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
8
|
+
) {
|
|
9
|
+
return formatScopeClassName(scopeClassNameFormat || SCOPE_CLASS_NAME_FORMAT, { className });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function formatScopeClassName(
|
|
13
|
+
format: ScopeClassNameFormat,
|
|
14
|
+
info: ScopeClassNameInfo,
|
|
15
|
+
) {
|
|
16
|
+
if (typeof format === 'function') return format(info);
|
|
17
|
+
|
|
18
|
+
return format.replace(/\[|\]/g, '').replace(/\(className\)/g, info.className);
|
|
19
|
+
}
|
package/atomic/theme.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { ThemeNameFormat, ThemeNameInfo, TokenNameFormat } from '../config/types';
|
|
2
3
|
import type { StyleTokenOverride } from '../style/token';
|
|
3
4
|
import { getTokenOverrideValue, getTokenVarName } from './token';
|
|
4
|
-
import { escapeCssIdent
|
|
5
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
6
|
+
import { escapeCssValue } from './utils/cssVar';
|
|
5
7
|
import { createNameFormatter } from './utils/format';
|
|
8
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
6
9
|
|
|
7
10
|
export const THEME_NAME_FORMAT = 'theme[-(name)]-$hash';
|
|
8
11
|
|
|
@@ -15,8 +18,8 @@ export function createThemeClassName(
|
|
|
15
18
|
) {
|
|
16
19
|
return formatThemeName(
|
|
17
20
|
themeNameFormat || THEME_NAME_FORMAT,
|
|
18
|
-
getIdentifierSafeHash(id),
|
|
19
|
-
{ name },
|
|
21
|
+
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
22
|
+
{ name: normalizeThemeName(name) },
|
|
20
23
|
);
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -46,3 +49,41 @@ function getThemeDeclaration(
|
|
|
46
49
|
|
|
47
50
|
return name + ':' + value;
|
|
48
51
|
}
|
|
52
|
+
|
|
53
|
+
export function normalizeThemeName(value: string | null | undefined): string | null {
|
|
54
|
+
if (!value) return null;
|
|
55
|
+
|
|
56
|
+
value = value.trim();
|
|
57
|
+
if (!value) return null;
|
|
58
|
+
if (/^\d+$/.test(value)) return null;
|
|
59
|
+
if (isGeneratedNameHash(value)) return null;
|
|
60
|
+
|
|
61
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
62
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) {
|
|
63
|
+
return normalizeThemeName(stableSuffix[1]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
value = stripGenericThemePrefix(value);
|
|
67
|
+
if (!value) return null;
|
|
68
|
+
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function stripGenericThemePrefix(value: string) {
|
|
73
|
+
const parts = value.split('--');
|
|
74
|
+
|
|
75
|
+
while (parts[0] === 'theme' || parts[0] === 'themes') {
|
|
76
|
+
parts.shift();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
value = parts.join('--');
|
|
80
|
+
|
|
81
|
+
if (value.startsWith('theme-')) return value.slice('theme-'.length);
|
|
82
|
+
if (value.startsWith('themes-')) return value.slice('themes-'.length);
|
|
83
|
+
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isGeneratedNameHash(value: string) {
|
|
88
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
89
|
+
}
|
package/atomic/token.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { TokenNameFormat, TokenNameInfo } from '../config/types';
|
|
2
|
-
import { getStyleTokenId, type StyleTokenData, type StyleTokenOverride } from '../style/token';
|
|
3
|
-
import { getCssVar, getCssVarRawFallback
|
|
3
|
+
import { getStyleTokenId, getStyleTokenName, type StyleTokenData, type StyleTokenOverride } from '../style/token';
|
|
4
|
+
import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
|
|
4
5
|
import { createNameFormatter } from './utils/format';
|
|
6
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
5
7
|
|
|
6
8
|
export const TOKEN_NAME_FORMAT = 'token[-(name)]-$hash';
|
|
7
9
|
|
|
@@ -12,11 +14,12 @@ export function getTokenVarName(
|
|
|
12
14
|
format: TokenNameFormat | null,
|
|
13
15
|
) {
|
|
14
16
|
const id = getStyleTokenId(token);
|
|
17
|
+
const debugName = getStyleTokenName(token);
|
|
15
18
|
|
|
16
19
|
const name = formatTokenName(
|
|
17
20
|
format || TOKEN_NAME_FORMAT,
|
|
18
|
-
getIdentifierSafeHash(id),
|
|
19
|
-
{ name:
|
|
21
|
+
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
22
|
+
{ name: debugName },
|
|
20
23
|
);
|
|
21
24
|
|
|
22
25
|
return '--' + name;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function escapeCssIdent(ident: string): string {
|
|
2
|
+
let result = '';
|
|
3
|
+
|
|
4
|
+
for (let i = 0; i < ident.length; i++) {
|
|
5
|
+
const char = ident.charAt(i);
|
|
6
|
+
const code = ident.charCodeAt(i);
|
|
7
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
8
|
+
|
|
9
|
+
if (code === 0) {
|
|
10
|
+
result += '\uFFFD';
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (
|
|
15
|
+
(code >= 1 && code <= 31) ||
|
|
16
|
+
code === 127 ||
|
|
17
|
+
(i === 0 && code >= 48 && code <= 57) ||
|
|
18
|
+
(i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45)
|
|
19
|
+
) {
|
|
20
|
+
result += '\\' + code.toString(16) + ' ';
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
25
|
+
result += '\\-';
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (code >= 0xD800 && code <= 0xDBFF && nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
|
|
30
|
+
result += char + ident.charAt(++i);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (
|
|
35
|
+
code >= 128 ||
|
|
36
|
+
code === 45 ||
|
|
37
|
+
code === 95 ||
|
|
38
|
+
(code >= 48 && code <= 57) ||
|
|
39
|
+
(code >= 65 && code <= 90) ||
|
|
40
|
+
(code >= 97 && code <= 122)
|
|
41
|
+
) {
|
|
42
|
+
result += char;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
result += '\\' + char;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function sanitizeCssIdentName(value: string, fallback: string = '') {
|
|
53
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/^-+|-+$/g, '') || fallback;
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function getCssVar(varName: string, value: string) {
|
|
2
|
+
return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getCssVarRawFallback(varName: string, fallbackCss: string) {
|
|
6
|
+
return 'var(' + varName + ', ' + fallbackCss + ')';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function escapeCssValue(value: string): string {
|
|
10
|
+
if (!value) return '';
|
|
11
|
+
|
|
12
|
+
return value
|
|
13
|
+
.trim()
|
|
14
|
+
// Escape existing backslashes first so we don't break them.
|
|
15
|
+
.replace(/\\/g, '\\\\')
|
|
16
|
+
.replace(/"/g, '\\"')
|
|
17
|
+
.replace(/'/g, "\\'")
|
|
18
|
+
.replace(/;/g, '\\;');
|
|
19
|
+
}
|
package/atomic/utils/debug.ts
CHANGED
package/atomic/utils/format.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { hashString, normalizeHashLength } from '../../utils/hash';
|
|
2
|
+
|
|
3
|
+
export function getIdentifierSafeHash(value: string, startLength = 7) {
|
|
4
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
5
|
+
return getIdentifierSafeHashValue(hashString(value)).slice(0, normalizedStartLength);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getIdentifierSafeHashValue(hash: string) {
|
|
9
|
+
const first = hash.charCodeAt(0);
|
|
10
|
+
|
|
11
|
+
if (first < 48 || first > 57) return hash;
|
|
12
|
+
|
|
13
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
14
|
+
}
|
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,31 @@ 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
|
+
export function getSheetSelectorWeight(selector: ItemSelector | null): number | null {
|
|
24
|
+
const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
|
|
25
|
+
if (!text.startsWith(SHEET_SELECTOR_ANCHOR + ':')) return null;
|
|
26
|
+
|
|
27
|
+
const end = text.indexOf('\0', SHEET_SELECTOR_ANCHOR.length);
|
|
28
|
+
if (end < 0) return null;
|
|
29
|
+
|
|
30
|
+
const [weightValue] = text.slice(SHEET_SELECTOR_ANCHOR.length + 1, end).split(':');
|
|
31
|
+
const weight = Number(weightValue);
|
|
32
|
+
return Number.isInteger(weight) && weight > 0 ? weight : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function stripSheetSelectorAnchor(selector: string) {
|
|
36
|
+
if (!selector.startsWith(SHEET_SELECTOR_ANCHOR)) return selector;
|
|
37
|
+
|
|
38
|
+
if (selector.startsWith(SHEET_SELECTOR_ANCHOR + ':')) {
|
|
39
|
+
const end = selector.indexOf('\0', SHEET_SELECTOR_ANCHOR.length);
|
|
40
|
+
if (end >= 0) return selector.slice(end + 1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return selector.slice(SHEET_SELECTOR_ANCHOR.length);
|
|
44
|
+
}
|
package/atomic/var.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { VarNameFormat, VarNameInfo } from '../config/types';
|
|
2
|
-
import { getIdentifierSafeHash } from './utils/css';
|
|
3
3
|
import { createNameFormatter } from './utils/format';
|
|
4
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
4
5
|
|
|
5
6
|
export const VAR_NAME_FORMAT = 'var[-(name)]-$hash';
|
|
6
7
|
|
|
@@ -12,7 +13,7 @@ export function getLocalVarName(
|
|
|
12
13
|
column: number,
|
|
13
14
|
format: VarNameFormat | null | undefined,
|
|
14
15
|
) {
|
|
15
|
-
const hash = getIdentifierSafeHash(filePath + '\n' + line + ':' + column);
|
|
16
|
+
const hash = getIdentifierSafeHash(filePath + '\n' + line + ':' + column, CSS_CONFIG.hashLength);
|
|
16
17
|
const name = formatVarName(format || VAR_NAME_FORMAT, hash, { name: '' });
|
|
17
18
|
|
|
18
19
|
return '--' + name;
|