@fluentic/style 0.1.0-beta.0
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 +32 -0
- package/LICENSE +21 -0
- package/README.md +409 -0
- package/atomic/atRule/counterStyle.ts +35 -0
- package/atomic/atRule/fontFace.ts +37 -0
- package/atomic/atRule/fontPaletteValues.ts +36 -0
- package/atomic/atRule/fontSrc.ts +13 -0
- package/atomic/atRule/keyframes.ts +43 -0
- package/atomic/atRule/positionTry.ts +73 -0
- package/atomic/atRule/property.ts +39 -0
- package/atomic/atRule/utils.ts +81 -0
- package/atomic/className.ts +93 -0
- package/atomic/debug/className/className.ts +33 -0
- package/atomic/debug/className/index.ts +1 -0
- package/atomic/debug/property/data.ts +59 -0
- package/atomic/debug/property/index.ts +1 -0
- package/atomic/debug/property/property.ts +59 -0
- package/atomic/debug/selector.ts +88 -0
- package/atomic/debug/value.ts +53 -0
- package/atomic/element.ts +29 -0
- package/atomic/layer/README.md +116 -0
- package/atomic/layer/index.ts +3 -0
- package/atomic/layer/layer.ts +95 -0
- package/atomic/layer/types.ts +37 -0
- package/atomic/layer/utils.ts +51 -0
- package/atomic/property/index.ts +2 -0
- package/atomic/property/presets.ts +34 -0
- package/atomic/property/property.ts +13 -0
- package/atomic/property/type_maps.ts +389 -0
- package/atomic/property/types.ts +7 -0
- package/atomic/rule.ts +116 -0
- package/atomic/theme.ts +48 -0
- package/atomic/token.ts +53 -0
- package/atomic/utils/css.ts +49 -0
- package/atomic/utils/debug.ts +37 -0
- package/atomic/utils/format.ts +192 -0
- package/atomic/utils/selector.ts +14 -0
- package/atomic/utils/types.ts +11 -0
- package/atomic/value/index.ts +2 -0
- package/atomic/value/unitless.ts +47 -0
- package/atomic/value/value.ts +17 -0
- package/atomic/var.ts +19 -0
- package/builder/data/check_selector.noop.ts +8 -0
- package/builder/data/check_selector.ts +30 -0
- package/builder/data/const.ts +25 -0
- package/builder/data/create.ts +96 -0
- package/builder/data/data.ts +63 -0
- package/builder/data/debug.ts +113 -0
- package/builder/data/index.ts +9 -0
- package/builder/data/is.ts +68 -0
- package/builder/data/merge/index.ts +2 -0
- package/builder/data/merge/scope.ts +300 -0
- package/builder/data/merge/style.ts +284 -0
- package/builder/data/merge/utils.ts +35 -0
- package/builder/data/selector.ts +11 -0
- package/builder/data/state.ts +134 -0
- package/builder/extract/index.ts +6 -0
- package/builder/extract/scope.ts +30 -0
- package/builder/extract/slot.ts +36 -0
- package/builder/extract/style.ts +89 -0
- package/builder/extract/theme.ts +16 -0
- package/builder/extract/token.ts +41 -0
- package/builder/extract/utils.ts +95 -0
- package/builder/extract/withTokens.ts +64 -0
- package/builder/index.ts +2 -0
- package/builder/style_builder.ts +234 -0
- package/builder/style_data.ts +81 -0
- package/builder/style_fns.ts +611 -0
- package/builder/types/alias.ts +83 -0
- package/builder/types/fns.ts +185 -0
- package/builder/types/index.ts +1 -0
- package/builder/types/types.ts +51 -0
- package/builder/utils.ts +19 -0
- package/compiler/compiler/cache.ts +155 -0
- package/compiler/compiler/compiler.ts +173 -0
- package/compiler/compiler/index.ts +3 -0
- package/compiler/compiler/types.ts +62 -0
- package/compiler/extract/collector.ts +25 -0
- package/compiler/extract/extract.ts +51 -0
- package/compiler/extract/index.ts +3 -0
- package/compiler/extract/types.ts +35 -0
- package/compiler/index.ts +2 -0
- package/compiler/transform/debug/index.ts +2 -0
- package/compiler/transform/debug/plugin.ts +1347 -0
- package/compiler/transform/debug/transform.ts +47 -0
- package/compiler/transform/debug/utils/debug_data.ts +187 -0
- package/compiler/transform/debug/utils/source_url.ts +29 -0
- package/compiler/transform/evaluator/evaluator.ts +1138 -0
- package/compiler/transform/evaluator/index.ts +3 -0
- package/compiler/transform/evaluator/tracer.ts +607 -0
- package/compiler/transform/evaluator/types.ts +22 -0
- package/compiler/transform/extract/chain/chain.ts +2343 -0
- package/compiler/transform/extract/chain/extract_chain.ts +89 -0
- package/compiler/transform/extract/chain/index.ts +3 -0
- package/compiler/transform/extract/chain/types.ts +37 -0
- package/compiler/transform/extract/index.ts +2 -0
- package/compiler/transform/extract/plugin.ts +665 -0
- package/compiler/transform/extract/transform.ts +45 -0
- package/compiler/transform/extract/utils/imports.ts +132 -0
- package/compiler/transform/extract/utils/replacement.ts +349 -0
- package/compiler/transform/extract/utils/slot.ts +186 -0
- package/compiler/transform/extract/utils/state.ts +48 -0
- package/compiler/transform/extract/utils/theme.ts +86 -0
- package/compiler/transform/extract/utils/token.ts +1 -0
- package/compiler/transform/index.ts +5 -0
- package/compiler/transform/syntax/index.ts +5 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +44 -0
- package/compiler/transform/syntax/isStyleChainCall.ts +16 -0
- package/compiler/transform/syntax/static_ids.ts +282 -0
- package/compiler/transform/syntax/types.ts +7 -0
- package/compiler/transform/syntax/utils.ts +31 -0
- package/compiler/transform/utils/babel.ts +100 -0
- package/compiler/transform/utils/import.ts +47 -0
- package/compiler/transform/utils/path.ts +13 -0
- package/compiler/transform/utils/selector.ts +252 -0
- package/compiler/utils/constants.ts +69 -0
- package/compiler/utils/file_resolver.ts +72 -0
- package/compiler/utils/import_source.ts +200 -0
- package/compiler/utils/imports.ts +24 -0
- package/compiler/utils/path.ts +40 -0
- package/compiler/utils/sourcemap.ts +61 -0
- package/config/build.ts +32 -0
- package/config/config/css.ts +32 -0
- package/config/config/css_extra.ts +22 -0
- package/config/config/debug.ts +26 -0
- package/config/config/dev.ts +145 -0
- package/config/config/runtime.ts +29 -0
- package/config/configure.ts +28 -0
- package/config/constants.ts +1 -0
- package/config/index.ts +2 -0
- package/config/types.ts +56 -0
- package/config/utils.ts +5 -0
- package/css/counterStyle.ts +20 -0
- package/css/fontFace.ts +25 -0
- package/css/fontPaletteValues.ts +20 -0
- package/css/index.ts +8 -0
- package/css/keyframes.ts +20 -0
- package/css/positionTry.ts +20 -0
- package/css/property.ts +32 -0
- package/css/utils.ts +56 -0
- package/dev/config.ts +16 -0
- package/dev/fns.ts +48 -0
- package/dev/index.ts +2 -0
- package/dev/trace.ts +413 -0
- package/dev/utils.ts +528 -0
- package/dist/assert-h_Zkqc4E.js +105 -0
- package/dist/assert-h_Zkqc4E.js.map +1 -0
- package/dist/className-C1Ht5Wvv.js +144 -0
- package/dist/className-C1Ht5Wvv.js.map +1 -0
- package/dist/className-DC2Cq8p3.js +251 -0
- package/dist/className-DC2Cq8p3.js.map +1 -0
- package/dist/compiler/index.mjs +2 -0
- package/dist/compiler-DweanHoB.mjs +6847 -0
- package/dist/compiler-DweanHoB.mjs.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config-BryWDfQX.js +25 -0
- package/dist/config-BryWDfQX.js.map +1 -0
- package/dist/config-DKHXWhe1.js +1 -0
- package/dist/config-Di2VYYKV.js +6 -0
- package/dist/config-Di2VYYKV.js.map +1 -0
- package/dist/config-DloHOG6I.js +13 -0
- package/dist/config-DloHOG6I.js.map +1 -0
- package/dist/css-BowBszUt.js +243 -0
- package/dist/css-BowBszUt.js.map +1 -0
- package/dist/css-ByOrugEX.js +805 -0
- package/dist/css-ByOrugEX.js.map +1 -0
- package/dist/css-DcazYor9.js +235 -0
- package/dist/css-DcazYor9.js.map +1 -0
- package/dist/css.js +2 -0
- package/dist/css_extra-DlOnsnR1.js +8 -0
- package/dist/css_extra-DlOnsnR1.js.map +1 -0
- package/dist/css_extra-oIi3UEPK.js +8 -0
- package/dist/css_extra-oIi3UEPK.js.map +1 -0
- package/dist/data-_te7t0M4.js +473 -0
- package/dist/data-_te7t0M4.js.map +1 -0
- package/dist/debug-BAw63qX6.js +15 -0
- package/dist/debug-BAw63qX6.js.map +1 -0
- package/dist/debug-DGki_v7g.js +15 -0
- package/dist/debug-DGki_v7g.js.map +1 -0
- package/dist/debug-n2aZQBSa.js +172 -0
- package/dist/debug-n2aZQBSa.js.map +1 -0
- package/dist/dev/rsc.js +183 -0
- package/dist/dev/rsc.js.map +1 -0
- package/dist/dev-CcphAa3R.js +376 -0
- package/dist/dev-CcphAa3R.js.map +1 -0
- package/dist/dev-DfBbuLeE.js +71 -0
- package/dist/dev-DfBbuLeE.js.map +1 -0
- package/dist/dev.js +2 -0
- package/dist/elementMarker-Bu7gDAkE.js +800 -0
- package/dist/elementMarker-Bu7gDAkE.js.map +1 -0
- package/dist/entry/dev/css.js +3 -0
- package/dist/entry/dev/jsx-dev-runtime.js +3 -0
- package/dist/entry/dev/jsx-runtime.js +3 -0
- package/dist/entry/dev.js +10 -0
- package/dist/entry/prod/css.js +3 -0
- package/dist/entry/prod/extract.js +3 -0
- package/dist/entry/prod/jsx-dev-runtime.js +3 -0
- package/dist/entry/prod/jsx-runtime.js +3 -0
- package/dist/entry/prod/runtime.js +5 -0
- package/dist/entry/prod.js +1230 -0
- package/dist/entry/prod.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -0
- package/dist/entry/rsc-dev/dev.js +544 -0
- package/dist/entry/rsc-dev/dev.js.map +1 -0
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +12 -0
- package/dist/entry/rsc-dev/jsx-dev-runtime.js.map +1 -0
- package/dist/entry/rsc-dev/jsx-runtime.js +3 -0
- package/dist/entry/rsc-dev.js +1429 -0
- package/dist/entry/rsc-dev.js.map +1 -0
- package/dist/entry/rsc-prod/css.js +3 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +3 -0
- package/dist/entry/rsc-prod/jsx-runtime.js +3 -0
- package/dist/entry/rsc-prod/runtime.js +5 -0
- package/dist/entry/rsc-prod.js +10 -0
- package/dist/extract-CzWJeQi8.js +121 -0
- package/dist/extract-CzWJeQi8.js.map +1 -0
- package/dist/extract-DEwSDJ9Z.js +2 -0
- package/dist/format-3nKBE_5t.js +144 -0
- package/dist/format-3nKBE_5t.js.map +1 -0
- package/dist/getClassName-BlvXHYuf.js +260 -0
- package/dist/getClassName-BlvXHYuf.js.map +1 -0
- package/dist/global-CvfmFLsK.js +11 -0
- package/dist/global-CvfmFLsK.js.map +1 -0
- package/dist/index.js +9 -0
- package/dist/jsx/jsx-dev-runtime.js +12 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.server.js +11 -0
- package/dist/jsx/jsx-dev-runtime.server.js.map +1 -0
- package/dist/jsx/jsx-runtime.js +13 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.server.js +12 -0
- package/dist/jsx/jsx-runtime.server.js.map +1 -0
- package/dist/jsx-CwTeyUxr.js +39 -0
- package/dist/jsx-CwTeyUxr.js.map +1 -0
- package/dist/jsx-D2BksHSv.js +38 -0
- package/dist/jsx-D2BksHSv.js.map +1 -0
- package/dist/jsx_dev_runtime-B6xs4by8.js +12 -0
- package/dist/jsx_dev_runtime-B6xs4by8.js.map +1 -0
- package/dist/jsx_runtime-04xfnsi7.js +13 -0
- package/dist/jsx_runtime-04xfnsi7.js.map +1 -0
- package/dist/jsx_runtime-iHLDwpcW.js +12 -0
- package/dist/jsx_runtime-iHLDwpcW.js.map +1 -0
- package/dist/layer-D1SaH07m.js +94 -0
- package/dist/layer-D1SaH07m.js.map +1 -0
- package/dist/loader-DS61nRqr.mjs +81 -0
- package/dist/loader-DS61nRqr.mjs.map +1 -0
- package/dist/misc-B9kqEb2N.mjs +360 -0
- package/dist/misc-B9kqEb2N.mjs.map +1 -0
- package/dist/plugin/farm/index.mjs +176 -0
- package/dist/plugin/farm/index.mjs.map +1 -0
- package/dist/plugin/nextjs/index.mjs +282 -0
- package/dist/plugin/nextjs/index.mjs.map +1 -0
- package/dist/plugin/nextjs/loader.mjs +162 -0
- package/dist/plugin/nextjs/loader.mjs.map +1 -0
- package/dist/plugin/parcel/index.cjs +9 -0
- package/dist/plugin/parcel/index.mjs +5 -0
- package/dist/plugin/parcel/optimizer.cjs +28 -0
- package/dist/plugin/parcel/optimizer.cjs.map +1 -0
- package/dist/plugin/parcel/optimizer.mjs +29 -0
- package/dist/plugin/parcel/optimizer.mjs.map +1 -0
- package/dist/plugin/parcel/resolver.cjs +17 -0
- package/dist/plugin/parcel/resolver.cjs.map +1 -0
- package/dist/plugin/parcel/resolver.mjs +18 -0
- package/dist/plugin/parcel/resolver.mjs.map +1 -0
- package/dist/plugin/parcel/runtime.cjs +17 -0
- package/dist/plugin/parcel/runtime.cjs.map +1 -0
- package/dist/plugin/parcel/runtime.mjs +17 -0
- package/dist/plugin/parcel/runtime.mjs.map +1 -0
- package/dist/plugin/parcel/transformer.cjs +41 -0
- package/dist/plugin/parcel/transformer.cjs.map +1 -0
- package/dist/plugin/parcel/transformer.mjs +41 -0
- package/dist/plugin/parcel/transformer.mjs.map +1 -0
- package/dist/plugin/rspack/index.mjs +11 -0
- package/dist/plugin/rspack/index.mjs.map +1 -0
- package/dist/plugin/vite/index.mjs +176 -0
- package/dist/plugin/vite/index.mjs.map +1 -0
- package/dist/plugin/webpack/index.mjs +2 -0
- package/dist/plugin/webpack/loader.mjs +19 -0
- package/dist/plugin/webpack/loader.mjs.map +1 -0
- package/dist/presets-Bye3ea2x.js +139 -0
- package/dist/presets-Bye3ea2x.js.map +1 -0
- package/dist/property-CnLFt5kx.js +406 -0
- package/dist/property-CnLFt5kx.js.map +1 -0
- package/dist/registry-CyIj8LYK.mjs +22 -0
- package/dist/registry-CyIj8LYK.mjs.map +1 -0
- package/dist/rules-9HSO1pxL.js +767 -0
- package/dist/rules-9HSO1pxL.js.map +1 -0
- package/dist/runtime-CYqNCiaM.js +53 -0
- package/dist/runtime-CYqNCiaM.js.map +1 -0
- package/dist/selector/index.js +3 -0
- package/dist/server.js +63 -0
- package/dist/server.js.map +1 -0
- package/dist/shared-BAL9peIw.cjs +7646 -0
- package/dist/shared-BAL9peIw.cjs.map +1 -0
- package/dist/shared-CCpq1zqA.mjs +132 -0
- package/dist/shared-CCpq1zqA.mjs.map +1 -0
- package/dist/sidecar-4u6GnlQG.mjs +236 -0
- package/dist/sidecar-4u6GnlQG.mjs.map +1 -0
- package/dist/style-4rFUy-zW.js +752 -0
- package/dist/style-4rFUy-zW.js.map +1 -0
- package/dist/style-B1UUqjj5.js +743 -0
- package/dist/style-B1UUqjj5.js.map +1 -0
- package/dist/style-Cw3NtvR0.js +5 -0
- package/dist/style-DNqQ6H-7.js +1255 -0
- package/dist/style-DNqQ6H-7.js.map +1 -0
- package/dist/styleStore-Dea_WVbr.js +2000 -0
- package/dist/styleStore-Dea_WVbr.js.map +1 -0
- package/dist/styleStore-DyNXBcUK.js +54 -0
- package/dist/styleStore-DyNXBcUK.js.map +1 -0
- package/dist/token-CKXUECuU.js +76 -0
- package/dist/token-CKXUECuU.js.map +1 -0
- package/dist/token-u_tM-mtg.js +204 -0
- package/dist/token-u_tM-mtg.js.map +1 -0
- package/dist/trace-Bu_qOqRy.js +245 -0
- package/dist/trace-Bu_qOqRy.js.map +1 -0
- package/dist/trace-CU0rvNYr.js +244 -0
- package/dist/trace-CU0rvNYr.js.map +1 -0
- package/dist/utils-BbehLOby.js +2415 -0
- package/dist/utils-BbehLOby.js.map +1 -0
- package/dist/utils-C7xfDxtM.mjs +97 -0
- package/dist/utils-C7xfDxtM.mjs.map +1 -0
- package/dist/utils-CWNHx4EC.js +170 -0
- package/dist/utils-CWNHx4EC.js.map +1 -0
- package/dist/utils-CdI6vZsP.js +37 -0
- package/dist/utils-CdI6vZsP.js.map +1 -0
- package/dist/utils-D7FAOyg6.js +129 -0
- package/dist/utils-D7FAOyg6.js.map +1 -0
- package/dist/utils-DMFgOOtA.mjs +49 -0
- package/dist/utils-DMFgOOtA.mjs.map +1 -0
- package/dist/utils.js +26 -0
- package/dist/utils.js.map +1 -0
- package/dist/value-BR4e2MKt.js +910 -0
- package/dist/value-BR4e2MKt.js.map +1 -0
- package/dist/value-E8rEv2Oe.js +136 -0
- package/dist/value-E8rEv2Oe.js.map +1 -0
- package/dist/valueRef-lshFk1Cs.js +16 -0
- package/dist/valueRef-lshFk1Cs.js.map +1 -0
- package/dist/webpack-CxS2FDYU.mjs +107 -0
- package/dist/webpack-CxS2FDYU.mjs.map +1 -0
- package/dist/withTokens-LRidu3Vc.js +95 -0
- package/dist/withTokens-LRidu3Vc.js.map +1 -0
- package/entry/dev/config.ts +2 -0
- package/entry/dev/css.ts +3 -0
- package/entry/dev/index.ts +3 -0
- package/entry/dev/jsx_dev_runtime.ts +3 -0
- package/entry/dev/jsx_runtime.ts +3 -0
- package/entry/prod/config.ts +2 -0
- package/entry/prod/css.ts +3 -0
- package/entry/prod/extract.ts +1 -0
- package/entry/prod/index.ts +3 -0
- package/entry/prod/jsx_dev_runtime.ts +3 -0
- package/entry/prod/jsx_runtime.ts +3 -0
- package/entry/prod/runtime.ts +14 -0
- package/entry/rsc_dev/config.ts +6 -0
- package/entry/rsc_dev/css.ts +3 -0
- package/entry/rsc_dev/dev.ts +5 -0
- package/entry/rsc_dev/index.ts +3 -0
- package/entry/rsc_dev/jsx_dev_runtime.ts +3 -0
- package/entry/rsc_dev/jsx_runtime.ts +3 -0
- package/entry/rsc_dev/server.ts +11 -0
- package/entry/rsc_prod/config.ts +6 -0
- package/entry/rsc_prod/css.ts +3 -0
- package/entry/rsc_prod/index.ts +3 -0
- package/entry/rsc_prod/jsx_dev_runtime.ts +3 -0
- package/entry/rsc_prod/jsx_runtime.ts +3 -0
- package/entry/rsc_prod/runtime.ts +12 -0
- package/entry/rsc_prod/server.ts +13 -0
- package/entry/shared/config.ts +5 -0
- package/entry/shared/dev.ts +19 -0
- package/entry/shared/prod.ts +4 -0
- package/index.ts +36 -0
- package/jsx/extracted/jsx_dev_runtime.ts +11 -0
- package/jsx/extracted/jsx_runtime.ts +12 -0
- package/jsx/rsc/jsx_dev_runtime.ts +11 -0
- package/jsx/rsc/jsx_runtime.ts +12 -0
- package/jsx/rsc_extracted/jsx_dev_runtime.ts +2 -0
- package/jsx/rsc_extracted/jsx_runtime.ts +2 -0
- package/jsx/runtime/jsx_dev_runtime.ts +11 -0
- package/jsx/runtime/jsx_runtime.ts +12 -0
- package/jsx/types.ts +8 -0
- package/jsx/utils.ts +59 -0
- package/package.json +298 -0
- package/plugin/bundler/farm/index.ts +1 -0
- package/plugin/bundler/farm/plugin.ts +320 -0
- package/plugin/bundler/parcel/config.json +19 -0
- package/plugin/bundler/parcel/index.ts +1 -0
- package/plugin/bundler/parcel/optimizer.ts +36 -0
- package/plugin/bundler/parcel/plugin.ts +4 -0
- package/plugin/bundler/parcel/resolver.ts +36 -0
- package/plugin/bundler/parcel/runtime.ts +23 -0
- package/plugin/bundler/parcel/shared.ts +234 -0
- package/plugin/bundler/parcel/transformer.ts +67 -0
- package/plugin/bundler/rspack/index.ts +1 -0
- package/plugin/bundler/rspack/plugin.ts +14 -0
- package/plugin/bundler/vite/index.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +133 -0
- package/plugin/bundler/vite/state.ts +153 -0
- package/plugin/bundler/webpack/index.ts +1 -0
- package/plugin/bundler/webpack/loader.ts +19 -0
- package/plugin/bundler/webpack/plugin.ts +240 -0
- package/plugin/bundler/webpack/shared/index.ts +2 -0
- package/plugin/bundler/webpack/shared/loader.ts +155 -0
- package/plugin/bundler/webpack/shared/registry.ts +16 -0
- package/plugin/bundler/webpack/utils.ts +96 -0
- package/plugin/nextjs/constants.ts +7 -0
- package/plugin/nextjs/html.ts +62 -0
- package/plugin/nextjs/index.ts +2 -0
- package/plugin/nextjs/loader.ts +222 -0
- package/plugin/nextjs/plugin.ts +532 -0
- package/plugin/nextjs/types.ts +33 -0
- package/plugin/nextjs/utils.ts +210 -0
- package/plugin/utils/cache/css_cache.ts +146 -0
- package/plugin/utils/cache/file.ts +40 -0
- package/plugin/utils/cache/index.ts +2 -0
- package/plugin/utils/compiler.ts +94 -0
- package/plugin/utils/constants.ts +7 -0
- package/plugin/utils/cssMarker.ts +14 -0
- package/plugin/utils/cssOutput.ts +65 -0
- package/plugin/utils/filter.ts +98 -0
- package/plugin/utils/imports.ts +5 -0
- package/plugin/utils/index.ts +10 -0
- package/plugin/utils/injection.ts +28 -0
- package/plugin/utils/misc.ts +5 -0
- package/plugin/utils/runtimeEntry.ts +57 -0
- package/plugin/utils/sidecar/index.ts +1 -0
- package/plugin/utils/sidecar/server.ts +143 -0
- package/plugin/utils/sidecar/sidecar.ts +167 -0
- package/plugin/utils/sidecar/utils.ts +109 -0
- package/plugin/utils/sourcemap.ts +52 -0
- package/plugin/utils/virtual.ts +81 -0
- package/runtime/core/cache/combine.ts +102 -0
- package/runtime/core/cache/index.ts +5 -0
- package/runtime/core/cache/item.ts +231 -0
- package/runtime/core/cache/pool.ts +310 -0
- package/runtime/core/cache/prop.ts +283 -0
- package/runtime/core/cache/propCache.ts +62 -0
- package/runtime/core/cache/resolvedItem.ts +31 -0
- package/runtime/core/cache/result.ts +115 -0
- package/runtime/core/cache/stateItem.ts +208 -0
- package/runtime/core/cache/tokenValues.ts +150 -0
- package/runtime/core/cache/utils/tree.ts +57 -0
- package/runtime/core/cache/utils/walk.ts +24 -0
- package/runtime/core/className.ts +101 -0
- package/runtime/core/combinedStyle.ts +101 -0
- package/runtime/core/createTransformElement.ts +39 -0
- package/runtime/core/elementMarker.ts +189 -0
- package/runtime/core/elementMarkerData.ts +27 -0
- package/runtime/core/getClassName.ts +47 -0
- package/runtime/core/getSheetRules.ts +7 -0
- package/runtime/core/getToken.ts +14 -0
- package/runtime/core/index.ts +5 -0
- package/runtime/core/jsx.ts +4 -0
- package/runtime/core/resolveClassNameRuntime.ts +33 -0
- package/runtime/env.ts +7 -0
- package/runtime/extract/getClassName.ts +476 -0
- package/runtime/extract/index.ts +4 -0
- package/runtime/extract/jsx.ts +55 -0
- package/runtime/index.ts +12 -0
- package/runtime/rsc/constants.ts +6 -0
- package/runtime/rsc/dev.ts +38 -0
- package/runtime/rsc/getClassName.ts +98 -0
- package/runtime/rsc/index.ts +3 -0
- package/runtime/rsc/jsx.ts +4 -0
- package/runtime/rsc/observer.ts +238 -0
- package/runtime/rsc/styleStore.ts +82 -0
- package/runtime/sheet/element.ts +13 -0
- package/runtime/sheet/global-noop.ts +13 -0
- package/runtime/sheet/global-prod.ts +13 -0
- package/runtime/sheet/global.ts +13 -0
- package/runtime/sheet/index.ts +3 -0
- package/runtime/sheet/insert.ts +37 -0
- package/runtime/sheet/rule.ts +77 -0
- package/runtime/sheet/rules.ts +131 -0
- package/runtime/sheet/theme.ts +34 -0
- package/runtime/style/index.ts +3 -0
- package/runtime/style/scope.ts +65 -0
- package/runtime/style/style.ts +34 -0
- package/runtime/style/token.ts +1 -0
- package/runtime/types.ts +42 -0
- package/selector/assert.ts +131 -0
- package/selector/index.ts +5 -0
- package/selector/presets/default.ts +27 -0
- package/selector/presets/index.ts +3 -0
- package/selector/presets/minimal.ts +37 -0
- package/selector/presets/selectors.ts +85 -0
- package/selector/selector.ts +68 -0
- package/selector/types.ts +24 -0
- package/selector/validate.ts +91 -0
- package/sheet/dev/dev_layer.ts +151 -0
- package/sheet/dev/dev_sort.ts +249 -0
- package/sheet/dev/index.ts +129 -0
- package/sheet/dev/utils.ts +130 -0
- package/sheet/index.ts +4 -0
- package/sheet/prod.ts +109 -0
- package/sheet/sheet.ts +10 -0
- package/sheet/sourcemap.ts +70 -0
- package/sheet/types.ts +31 -0
- package/sheet/utils/dom.ts +71 -0
- package/sheet/utils/index.ts +4 -0
- package/sheet/utils/layer.ts +14 -0
- package/sheet/utils/noop.ts +11 -0
- package/sheet/utils/rule.ts +3 -0
- package/sheet/utils/sourcemap.ts +221 -0
- package/style/index.ts +9 -0
- package/style/keyframes.ts +40 -0
- package/style/style.ts +112 -0
- package/style/theme.ts +36 -0
- package/style/token.ts +101 -0
- package/style/tokens.ts +64 -0
- package/style/transform.ts +9 -0
- package/style/types.ts +32 -0
- package/style/utils/expose.ts +43 -0
- package/style/utils/index.ts +1 -0
- package/style/value.ts +103 -0
- package/style/valueRef.ts +25 -0
- package/utils/global.ts +44 -0
- package/utils/hash.ts +22 -0
- package/utils/id.ts +20 -0
- package/utils/object.ts +87 -0
- package/utils/trace.ts +211 -0
- package/utils/type.ts +22 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { NamedAtRuleFormat, TokenNameFormat } from '../../config/types';
|
|
2
|
+
import type { AtRuleStyleObject } from '../../style';
|
|
3
|
+
import type { StyleTokenData } from '../../style/token';
|
|
4
|
+
import type { CSSProperties } from '../utils/types';
|
|
5
|
+
import { buildNamedAtRuleCss, createAtRuleNameFormatter } from './utils';
|
|
6
|
+
|
|
7
|
+
type Properties = Pick<
|
|
8
|
+
CSSProperties,
|
|
9
|
+
| 'positionArea'
|
|
10
|
+
| 'insetArea'
|
|
11
|
+
| 'top'
|
|
12
|
+
| 'right'
|
|
13
|
+
| 'bottom'
|
|
14
|
+
| 'left'
|
|
15
|
+
| 'inset'
|
|
16
|
+
| 'insetBlock'
|
|
17
|
+
| 'insetBlockStart'
|
|
18
|
+
| 'insetBlockEnd'
|
|
19
|
+
| 'insetInline'
|
|
20
|
+
| 'insetInlineStart'
|
|
21
|
+
| 'insetInlineEnd'
|
|
22
|
+
| 'width'
|
|
23
|
+
| 'minWidth'
|
|
24
|
+
| 'maxWidth'
|
|
25
|
+
| 'height'
|
|
26
|
+
| 'minHeight'
|
|
27
|
+
| 'maxHeight'
|
|
28
|
+
| 'blockSize'
|
|
29
|
+
| 'minBlockSize'
|
|
30
|
+
| 'maxBlockSize'
|
|
31
|
+
| 'inlineSize'
|
|
32
|
+
| 'minInlineSize'
|
|
33
|
+
| 'maxInlineSize'
|
|
34
|
+
| 'margin'
|
|
35
|
+
| 'marginBlock'
|
|
36
|
+
| 'marginBlockStart'
|
|
37
|
+
| 'marginBlockEnd'
|
|
38
|
+
| 'marginInline'
|
|
39
|
+
| 'marginInlineStart'
|
|
40
|
+
| 'marginInlineEnd'
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
export type PositionTryObject = AtRuleStyleObject<Properties>;
|
|
44
|
+
|
|
45
|
+
export const POSITION_TRY_AT_RULE = 'position-try';
|
|
46
|
+
|
|
47
|
+
export const formatPositionTryName = createAtRuleNameFormatter(
|
|
48
|
+
'position-try[-(name)]-$hash',
|
|
49
|
+
'--',
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export function buildPositionTryCss(
|
|
53
|
+
format: NamedAtRuleFormat | null,
|
|
54
|
+
name: string | null,
|
|
55
|
+
id: string,
|
|
56
|
+
descriptors: PositionTryObject,
|
|
57
|
+
tokens: StyleTokenData[],
|
|
58
|
+
tokenLookup: Set<string>,
|
|
59
|
+
tokenNameFormat: TokenNameFormat | null,
|
|
60
|
+
) {
|
|
61
|
+
name = formatPositionTryName(format, id, { name });
|
|
62
|
+
|
|
63
|
+
const css = buildNamedAtRuleCss(
|
|
64
|
+
POSITION_TRY_AT_RULE,
|
|
65
|
+
name,
|
|
66
|
+
descriptors,
|
|
67
|
+
tokens,
|
|
68
|
+
tokenLookup,
|
|
69
|
+
tokenNameFormat,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return { name, css };
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NamedAtRuleFormat, TokenNameFormat } from '../../config/types';
|
|
2
|
+
import type { StyleTokenData } from '../../style/token';
|
|
3
|
+
import { buildNamedAtRuleCss, createAtRuleNameFormatter } from './utils';
|
|
4
|
+
|
|
5
|
+
export type PropertyObject = {
|
|
6
|
+
syntax: string;
|
|
7
|
+
inherits: boolean;
|
|
8
|
+
initialValue: string | number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const PROPERTY_AT_RULE = 'property';
|
|
12
|
+
|
|
13
|
+
export const formatPropertyName = createAtRuleNameFormatter(
|
|
14
|
+
'[-(name)]-$hash',
|
|
15
|
+
'--',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export function buildPropertyCss(
|
|
19
|
+
format: NamedAtRuleFormat | null,
|
|
20
|
+
name: string | null,
|
|
21
|
+
id: string,
|
|
22
|
+
descriptors: PropertyObject,
|
|
23
|
+
tokens: StyleTokenData[],
|
|
24
|
+
tokenLookup: Set<string>,
|
|
25
|
+
tokenNameFormat: TokenNameFormat | null,
|
|
26
|
+
) {
|
|
27
|
+
name = formatPropertyName(format, id, { name });
|
|
28
|
+
|
|
29
|
+
const css = buildNamedAtRuleCss(
|
|
30
|
+
PROPERTY_AT_RULE,
|
|
31
|
+
name,
|
|
32
|
+
descriptors,
|
|
33
|
+
tokens,
|
|
34
|
+
tokenLookup,
|
|
35
|
+
tokenNameFormat,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return { css, name };
|
|
39
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type NamedAtRuleFormat, type NamedAtRuleInfo, type TokenNameFormat } from '../../config/types';
|
|
2
|
+
import { getStyleTokenId, isStyleTokenData, type StyleTokenData } from '../../style/token';
|
|
3
|
+
import { getCssPropertyName } from '../property';
|
|
4
|
+
import { getTokenVar } from '../token';
|
|
5
|
+
import { getIdentifierSafeHash } from '../utils/css';
|
|
6
|
+
import { createNameFormatter } from '../utils/format';
|
|
7
|
+
import { getCssPropertyValue } from '../value';
|
|
8
|
+
|
|
9
|
+
export function createAtRuleNameFormatter(defaultFormat: NamedAtRuleFormat, prefix?: string) {
|
|
10
|
+
const formatter = createNameFormatter<NamedAtRuleInfo>(['name']);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
format: NamedAtRuleFormat | null,
|
|
14
|
+
id: string,
|
|
15
|
+
info: NamedAtRuleInfo,
|
|
16
|
+
) => {
|
|
17
|
+
const hash = getIdentifierSafeHash(id);
|
|
18
|
+
const name = formatter(format || defaultFormat, hash, info);
|
|
19
|
+
|
|
20
|
+
if (!prefix) return name;
|
|
21
|
+
|
|
22
|
+
return name.startsWith(prefix) ? name : prefix + name;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function buildNamedAtRuleCss(
|
|
27
|
+
atRule: string,
|
|
28
|
+
name: string,
|
|
29
|
+
descriptors: object,
|
|
30
|
+
tokens: StyleTokenData[],
|
|
31
|
+
tokenLookup: Set<string>,
|
|
32
|
+
tokenNameFormat: TokenNameFormat | null,
|
|
33
|
+
) {
|
|
34
|
+
return `@${atRule} ${name} {${
|
|
35
|
+
buildAtRuleDeclarationCss(
|
|
36
|
+
descriptors,
|
|
37
|
+
tokens,
|
|
38
|
+
tokenLookup,
|
|
39
|
+
tokenNameFormat,
|
|
40
|
+
true,
|
|
41
|
+
)
|
|
42
|
+
}}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function buildAtRuleDeclarationCss(
|
|
46
|
+
style: Record<string, any>,
|
|
47
|
+
tokens: StyleTokenData[],
|
|
48
|
+
tokenLookup: Set<string>,
|
|
49
|
+
tokenNameFormat: TokenNameFormat | null,
|
|
50
|
+
rawValue: boolean,
|
|
51
|
+
shouldInclude?: (property: string) => boolean,
|
|
52
|
+
) {
|
|
53
|
+
let css = '';
|
|
54
|
+
|
|
55
|
+
for (const property in style) {
|
|
56
|
+
if (shouldInclude && !shouldInclude(property)) continue;
|
|
57
|
+
|
|
58
|
+
let value = style[property];
|
|
59
|
+
|
|
60
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === 'number') {
|
|
61
|
+
value = value[1];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isStyleTokenData(value)) {
|
|
65
|
+
const tokenId = getStyleTokenId(value);
|
|
66
|
+
if (!tokenLookup.has(tokenId)) {
|
|
67
|
+
tokenLookup.add(tokenId);
|
|
68
|
+
tokens.push(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
css += `${getCssPropertyName(property)}: ${getTokenVar(value, tokenNameFormat)};`;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const valueString = String(value ?? '');
|
|
76
|
+
|
|
77
|
+
css += `${getCssPropertyName(property)}: ${rawValue ? valueString : getCssPropertyValue(property, valueString)};`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return css;
|
|
81
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { BuilderCallsite, ItemSelector } from '../builder/data';
|
|
2
|
+
import type { ClassNameFormat, ScopeClassNameFormat } from '../config/types';
|
|
3
|
+
import { hashString } from '../utils/hash';
|
|
4
|
+
import { getDebugClassName, getDebugScopeClassName } from './debug/className';
|
|
5
|
+
import { getDebugPropertyName } from './debug/property';
|
|
6
|
+
import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
|
|
7
|
+
import { getIdentifierSafeHash } from './utils/css';
|
|
8
|
+
import { getSelectorHash, getSelectorText } from './utils/selector';
|
|
9
|
+
|
|
10
|
+
export function getAtomicClassName(
|
|
11
|
+
property: string,
|
|
12
|
+
priority: number | null,
|
|
13
|
+
value: string,
|
|
14
|
+
selector: ItemSelector | null,
|
|
15
|
+
parentSelector: ItemSelector | null,
|
|
16
|
+
atRule: ItemSelector[] | null,
|
|
17
|
+
callsite: BuilderCallsite | null,
|
|
18
|
+
localClassName: boolean,
|
|
19
|
+
debugClassName: boolean,
|
|
20
|
+
classNameFormat: ClassNameFormat | null,
|
|
21
|
+
) {
|
|
22
|
+
let hash = property;
|
|
23
|
+
|
|
24
|
+
hash += '\n' + (priority || '');
|
|
25
|
+
hash += '\n' + value;
|
|
26
|
+
hash += '\n' + (selector ? getSelectorHash(selector) : '');
|
|
27
|
+
hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
|
|
28
|
+
hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
|
|
29
|
+
hash += '\n' + getCallsiteHash(callsite, localClassName);
|
|
30
|
+
|
|
31
|
+
hash = getIdentifierSafeHash(hash);
|
|
32
|
+
|
|
33
|
+
if (!debugClassName) return hash;
|
|
34
|
+
|
|
35
|
+
const propertyName = getDebugPropertyName(property, value);
|
|
36
|
+
|
|
37
|
+
const className = getDebugClassName(
|
|
38
|
+
classNameFormat,
|
|
39
|
+
hash,
|
|
40
|
+
{
|
|
41
|
+
atRule: atRule
|
|
42
|
+
? getDebugAtRuleName(atRule.map(getSelectorText))
|
|
43
|
+
: null,
|
|
44
|
+
scopeSelector: parentSelector
|
|
45
|
+
? getDebugSelectorName(getSelectorText(parentSelector))
|
|
46
|
+
: null,
|
|
47
|
+
selector: selector
|
|
48
|
+
? getDebugSelectorName(getSelectorText(selector))
|
|
49
|
+
: null,
|
|
50
|
+
property: propertyName
|
|
51
|
+
? propertyName.property
|
|
52
|
+
: property,
|
|
53
|
+
value: propertyName
|
|
54
|
+
? propertyName.value ?? propertyName.arbitraryValue
|
|
55
|
+
: null,
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return className;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getScopeClassName(
|
|
63
|
+
className: string,
|
|
64
|
+
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
65
|
+
) {
|
|
66
|
+
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getClassNameDedupe(
|
|
70
|
+
property: string,
|
|
71
|
+
priority: number | null,
|
|
72
|
+
selector: ItemSelector | null,
|
|
73
|
+
parentSelector: ItemSelector | null,
|
|
74
|
+
atRule: ItemSelector[] | null,
|
|
75
|
+
) {
|
|
76
|
+
let hash = property;
|
|
77
|
+
|
|
78
|
+
hash += '\n' + (priority || '');
|
|
79
|
+
hash += '\n' + (selector ? getSelectorHash(selector) : '');
|
|
80
|
+
hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
|
|
81
|
+
hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
|
|
82
|
+
|
|
83
|
+
return hashString(hash);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getCallsiteHash(
|
|
87
|
+
callsite: BuilderCallsite | null,
|
|
88
|
+
localClassName: boolean,
|
|
89
|
+
) {
|
|
90
|
+
if (!localClassName || !callsite) return '';
|
|
91
|
+
|
|
92
|
+
return callsite.filePath + '\n' + callsite.line + ':' + callsite.column;
|
|
93
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ClassNameFormat, ClassNameInfo, ScopeClassNameFormat, ScopeClassNameInfo } from '../../../config/types';
|
|
2
|
+
import { createNameFormatter } from '../../utils/format';
|
|
3
|
+
|
|
4
|
+
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]-$hash';
|
|
5
|
+
|
|
6
|
+
export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
|
|
7
|
+
|
|
8
|
+
export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
9
|
+
'atRule',
|
|
10
|
+
'scopeSelector',
|
|
11
|
+
'property',
|
|
12
|
+
'selector',
|
|
13
|
+
'value',
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
export const formatScopeClassName = createNameFormatter<ScopeClassNameInfo>([
|
|
17
|
+
'className',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export function getDebugClassName(
|
|
21
|
+
format: ClassNameFormat | null,
|
|
22
|
+
hash: string,
|
|
23
|
+
info: ClassNameInfo,
|
|
24
|
+
) {
|
|
25
|
+
return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getDebugScopeClassName(
|
|
29
|
+
format: ScopeClassNameFormat | null,
|
|
30
|
+
info: ScopeClassNameInfo,
|
|
31
|
+
) {
|
|
32
|
+
return formatScopeClassName(format || SCOPE_CLASS_NAME_FORMAT, null, info);
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './className';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const PROPERTY_ALIASES: Record<string, string> = {
|
|
2
|
+
'border-radius': 'radius',
|
|
3
|
+
'flex-direction': 'flex',
|
|
4
|
+
'font-style': 'font',
|
|
5
|
+
'font-weight': 'font',
|
|
6
|
+
'grid-template-columns': 'grid-cols',
|
|
7
|
+
'grid-template-rows': 'grid-rows',
|
|
8
|
+
'align-items': 'items',
|
|
9
|
+
'justify-content': 'justify',
|
|
10
|
+
'z-index': 'zindex',
|
|
11
|
+
'pointer-events': 'pointer',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const KEYWORD_VALUE_PROPERTIES = new Set([
|
|
15
|
+
'align-content',
|
|
16
|
+
'align-items',
|
|
17
|
+
'align-self',
|
|
18
|
+
'background-repeat',
|
|
19
|
+
'background-size',
|
|
20
|
+
'border-collapse',
|
|
21
|
+
'border-style',
|
|
22
|
+
'box-sizing',
|
|
23
|
+
'clear',
|
|
24
|
+
'cursor',
|
|
25
|
+
'display',
|
|
26
|
+
'flex-direction',
|
|
27
|
+
'flex-wrap',
|
|
28
|
+
'float',
|
|
29
|
+
'font-weight',
|
|
30
|
+
'font-style',
|
|
31
|
+
'justify-content',
|
|
32
|
+
'justify-items',
|
|
33
|
+
'justify-self',
|
|
34
|
+
'list-style-position',
|
|
35
|
+
'list-style-type',
|
|
36
|
+
'object-fit',
|
|
37
|
+
'object-position',
|
|
38
|
+
'overflow',
|
|
39
|
+
'overflow-x',
|
|
40
|
+
'overflow-y',
|
|
41
|
+
'pointer-events',
|
|
42
|
+
'place-content',
|
|
43
|
+
'place-items',
|
|
44
|
+
'place-self',
|
|
45
|
+
'position',
|
|
46
|
+
'resize',
|
|
47
|
+
'table-layout',
|
|
48
|
+
'text-align',
|
|
49
|
+
'text-decoration-line',
|
|
50
|
+
'text-transform',
|
|
51
|
+
'user-select',
|
|
52
|
+
'vertical-align',
|
|
53
|
+
'visibility',
|
|
54
|
+
'white-space',
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export const ARBITRARY_VALUE_PROPERTIES = new Set([
|
|
58
|
+
'font-weight',
|
|
59
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './property';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { normalizeDebugKeywordValue, normalizePropertyName, sanitizeDebugPropertyName } from '../../utils/debug';
|
|
2
|
+
import { type DebugValueName, getDebugValueName } from '../value';
|
|
3
|
+
import { ARBITRARY_VALUE_PROPERTIES, KEYWORD_VALUE_PROPERTIES, PROPERTY_ALIASES } from './data';
|
|
4
|
+
|
|
5
|
+
export type DebugPropertyName = DebugValueName & {
|
|
6
|
+
property: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function getDebugPropertyName(
|
|
10
|
+
property: string,
|
|
11
|
+
value: string,
|
|
12
|
+
): DebugPropertyName | null {
|
|
13
|
+
if (!property) return null;
|
|
14
|
+
|
|
15
|
+
const normalized = normalizePropertyName(property);
|
|
16
|
+
const name = PROPERTY_ALIASES[normalized] || sanitizeDebugPropertyName(normalized);
|
|
17
|
+
|
|
18
|
+
if (!name) return null;
|
|
19
|
+
|
|
20
|
+
const valueName = getDebugValueName(value);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
property: name,
|
|
24
|
+
...withKeywordValueFallback(
|
|
25
|
+
normalized,
|
|
26
|
+
value,
|
|
27
|
+
withArbitraryValueFallback(normalized, valueName),
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function withArbitraryValueFallback(
|
|
33
|
+
property: string,
|
|
34
|
+
valueName: DebugValueName,
|
|
35
|
+
): DebugValueName {
|
|
36
|
+
if (!valueName.arbitraryValue || ARBITRARY_VALUE_PROPERTIES.has(property)) return valueName;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
value: valueName.value,
|
|
40
|
+
arbitraryValue: null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function withKeywordValueFallback(
|
|
45
|
+
property: string,
|
|
46
|
+
value: string,
|
|
47
|
+
valueName: DebugValueName,
|
|
48
|
+
): DebugValueName {
|
|
49
|
+
if (valueName.value || valueName.arbitraryValue) return valueName;
|
|
50
|
+
if (!KEYWORD_VALUE_PROPERTIES.has(property)) return valueName;
|
|
51
|
+
|
|
52
|
+
const normalized = normalizeDebugKeywordValue(value);
|
|
53
|
+
if (!normalized) return valueName;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
value: normalized,
|
|
57
|
+
arbitraryValue: null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export function getDebugSelectorName(
|
|
2
|
+
selector: string,
|
|
3
|
+
): string | null {
|
|
4
|
+
if (!selector) return null;
|
|
5
|
+
|
|
6
|
+
const normalized = selector.trim().toLowerCase();
|
|
7
|
+
|
|
8
|
+
// Return null early *only* for completely plain element tags (e.g., "div", "main")
|
|
9
|
+
if (/^[a-z0-9]+$/.test(normalized)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const name = normalized
|
|
14
|
+
// Safe placeholder substitutions before blowing away special characters
|
|
15
|
+
.replace(/\$\$/g, 'args')
|
|
16
|
+
.replace(/\$/g, 'arg')
|
|
17
|
+
.replace(/\.\.\./g, 'merge')
|
|
18
|
+
// Compress common pseudo-arguments before classNameFormat applies any length policy.
|
|
19
|
+
.replace(/:not\(/g, 'not-')
|
|
20
|
+
.replace(/:(is|where|has)\(/g, '$1-')
|
|
21
|
+
.replace(/:nth-(child|of-type)\(/g, 'nth-')
|
|
22
|
+
// Standardize structural symbols and colons (handles :hover:active and ::before)
|
|
23
|
+
.replace(/[.#]/g, '-')
|
|
24
|
+
.replace(/[[\]()]/g, '-')
|
|
25
|
+
.replace(/:+/g, '-')
|
|
26
|
+
.replace(/\s+/g, '-')
|
|
27
|
+
// Strip any remaining illegal characters, clean up dashes
|
|
28
|
+
.replace(/[^a-z0-9_-]+/g, '-')
|
|
29
|
+
.replace(/[-_]+/g, '-')
|
|
30
|
+
.replace(/^-+|-+$/g, '');
|
|
31
|
+
|
|
32
|
+
return validateName(name);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getDebugAtRuleName(
|
|
36
|
+
selector: string | string[],
|
|
37
|
+
): string | null {
|
|
38
|
+
if (!selector || (Array.isArray(selector) && selector.length === 0)) return null;
|
|
39
|
+
|
|
40
|
+
// Link stacked/nested array features together cleanly using a single dash
|
|
41
|
+
const name = Array.isArray(selector)
|
|
42
|
+
? selector.map(parseAtRule).filter(Boolean).join('-')
|
|
43
|
+
: parseAtRule(selector);
|
|
44
|
+
|
|
45
|
+
const cleanName = name.replace(/[-_]+/g, '-').replace(/^-+|-+$/g, '');
|
|
46
|
+
return validateName(cleanName);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function compressQuery(query: string): string {
|
|
50
|
+
return query
|
|
51
|
+
.trim()
|
|
52
|
+
.toLowerCase()
|
|
53
|
+
// 1. Convert feature names directly to clean, recognizable short tokens
|
|
54
|
+
.replace(/prefers-color-scheme\s*:\s*dark/g, 'dark')
|
|
55
|
+
.replace(/prefers-color-scheme\s*:\s*light/g, 'light')
|
|
56
|
+
.replace(/min-width\s*:\s*/g, 'min-')
|
|
57
|
+
.replace(/max-width\s*:\s*/g, 'max-')
|
|
58
|
+
.replace(/min-height\s*:\s*/g, 'minh-')
|
|
59
|
+
.replace(/max-height\s*:\s*/g, 'maxh-')
|
|
60
|
+
.replace(/inline-size/g, 'inline')
|
|
61
|
+
// 2. Clear out noise words
|
|
62
|
+
.replace(/\b(and|or|only|not)\b/g, '')
|
|
63
|
+
// 3. Handle mathematical range syntax cleanly (e.g., width >= 400px -> width-gte-400px)
|
|
64
|
+
.replace(/>=/g, '-gte-')
|
|
65
|
+
.replace(/<=/g, '-lte-')
|
|
66
|
+
.replace(/>/g, '-gt-')
|
|
67
|
+
.replace(/</g, '-lt-')
|
|
68
|
+
// 4. Flatten layout syntax and clean dashes
|
|
69
|
+
.replace(/[():=\s]+/g, '-')
|
|
70
|
+
.replace(/[-_]+/g, '-')
|
|
71
|
+
.replace(/^-+|-+$/g, '');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function validateName(name: string): string | null {
|
|
75
|
+
if (!name || name === 'selector' || name.length < 2) return null;
|
|
76
|
+
return name;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function parseAtRule(rule: string): string {
|
|
80
|
+
const normalized = rule.trim().toLowerCase();
|
|
81
|
+
|
|
82
|
+
// Strip away structural keywords completely for a clean variant prefix
|
|
83
|
+
if (normalized.startsWith('@media')) return compressQuery(normalized.slice(6));
|
|
84
|
+
if (normalized.startsWith('@container')) return compressQuery(normalized.slice(10));
|
|
85
|
+
if (normalized.startsWith('@supports')) return compressQuery(normalized.slice(9));
|
|
86
|
+
|
|
87
|
+
return compressQuery(normalized);
|
|
88
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type DebugValueName = {
|
|
2
|
+
value: string | null;
|
|
3
|
+
arbitraryValue: string | null;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export function getDebugValueName(
|
|
7
|
+
value: string,
|
|
8
|
+
): DebugValueName {
|
|
9
|
+
if (!value) {
|
|
10
|
+
return { value: null, arbitraryValue: null };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const normalized = value.trim().toLowerCase();
|
|
14
|
+
|
|
15
|
+
if (!normalized) {
|
|
16
|
+
return { value: null, arbitraryValue: null };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (
|
|
20
|
+
normalized.startsWith('url') ||
|
|
21
|
+
normalized.includes('gradient') ||
|
|
22
|
+
normalized.startsWith('image') ||
|
|
23
|
+
normalized.startsWith('calc(') ||
|
|
24
|
+
normalized.startsWith('var(') ||
|
|
25
|
+
normalized.startsWith('env(') ||
|
|
26
|
+
normalized.startsWith('rgb') ||
|
|
27
|
+
normalized.startsWith('hsl')
|
|
28
|
+
) {
|
|
29
|
+
return { value: null, arbitraryValue: null };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (/^[a-z][a-z0-9-]*$/.test(normalized)) {
|
|
33
|
+
return { value: normalized, arbitraryValue: null };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const name = normalized
|
|
37
|
+
.replace(/px/g, '')
|
|
38
|
+
.replace(/rem/g, 'rem')
|
|
39
|
+
.replace(/em/g, 'em')
|
|
40
|
+
.replace(/%/g, 'pct')
|
|
41
|
+
.replace(/fr/g, 'fr')
|
|
42
|
+
.replace(/[,()"'#]/g, '-')
|
|
43
|
+
.replace(/\s+/g, '-')
|
|
44
|
+
.replace(/[^a-z0-9._%-]+/g, '-')
|
|
45
|
+
.replace(/[-_]+/g, '-')
|
|
46
|
+
.replace(/^-+|-+$/g, '');
|
|
47
|
+
|
|
48
|
+
if (!name) {
|
|
49
|
+
return { value: null, arbitraryValue: null };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return { value: null, arbitraryValue: name };
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
|
|
2
|
+
import { escapeCssIdent, getIdentifierSafeHash } from './utils/css';
|
|
3
|
+
import { sanitizeDebugName } from './utils/debug';
|
|
4
|
+
import { createNameFormatter } from './utils/format';
|
|
5
|
+
|
|
6
|
+
export const ELEMENT_CLASS_NAME_FORMAT = '@(name)';
|
|
7
|
+
|
|
8
|
+
export const formatElementClassName = createNameFormatter<ElementClassNameInfo>([
|
|
9
|
+
'name',
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
export function getElementClassName(
|
|
13
|
+
label: string | undefined,
|
|
14
|
+
id: string,
|
|
15
|
+
elementClassNameFormat: ElementClassNameFormat | null,
|
|
16
|
+
) {
|
|
17
|
+
const name = sanitizeDebugName(label) || null;
|
|
18
|
+
const hash = getIdentifierSafeHash(id);
|
|
19
|
+
|
|
20
|
+
return formatElementClassName(
|
|
21
|
+
elementClassNameFormat || ELEMENT_CLASS_NAME_FORMAT,
|
|
22
|
+
hash,
|
|
23
|
+
{ name },
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getElementMarkerRuleCss(className: string) {
|
|
28
|
+
return `.${escapeCssIdent(className)}{--fluentic-element-marker:0}`;
|
|
29
|
+
}
|