@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,283 @@
|
|
|
1
|
+
import type { ThemeData } from '../../../builder/data/data';
|
|
2
|
+
import {
|
|
3
|
+
isScopeData,
|
|
4
|
+
isScopeTargetData,
|
|
5
|
+
isSlotData,
|
|
6
|
+
isSlotOverrideData,
|
|
7
|
+
isStyleData,
|
|
8
|
+
isThemeData,
|
|
9
|
+
} from '../../../builder/data/is';
|
|
10
|
+
import type { StateItem } from '../../../builder/data/state';
|
|
11
|
+
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../../builder/extract/withTokens';
|
|
12
|
+
import { DEV_CONFIG } from '../../../config/config/dev';
|
|
13
|
+
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
14
|
+
import { isStyleTokenOverrideData } from '../../../style/token';
|
|
15
|
+
import type { StyleProp } from '../../types';
|
|
16
|
+
import { isElementDebugData, splitElementMarkerStyleProp } from '../elementMarkerData';
|
|
17
|
+
import {
|
|
18
|
+
createResolvedStyleItem,
|
|
19
|
+
createResolvedStyleItemFromItems,
|
|
20
|
+
getDirectStyleItem,
|
|
21
|
+
getStyleTokenValues,
|
|
22
|
+
isResolvedStyleItem,
|
|
23
|
+
type ResolvedStyleItem,
|
|
24
|
+
} from './item';
|
|
25
|
+
import { getStylePropCacheValue } from './propCache';
|
|
26
|
+
import { createStylePropResult, emptyStylePropResult, type ResolvedStyleProp } from './result';
|
|
27
|
+
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
28
|
+
import { walkRecursiveItems } from './utils/walk';
|
|
29
|
+
|
|
30
|
+
export type StylePropItem = ResolvedStyleItem | ThemeData;
|
|
31
|
+
|
|
32
|
+
type StylePropWalkOptions = {
|
|
33
|
+
onUnsupported?: (item: unknown) => void;
|
|
34
|
+
stableTokenBound?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type ResolvedStylePropRuntime = {
|
|
38
|
+
items: StylePropItem[];
|
|
39
|
+
result: ResolvedStyleProp;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type StylePropTokenBinding = {
|
|
43
|
+
data: object;
|
|
44
|
+
tokens: StyleTokenValues;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function resolveStyleProp(styleProp: StyleProp | undefined): ResolvedStyleProp {
|
|
48
|
+
return resolveStylePropRuntime(styleProp)?.result ?? emptyStylePropResult;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function resolveStylePropRuntime(styleProp: StyleProp | undefined): ResolvedStylePropRuntime | null {
|
|
52
|
+
if (!styleProp) return null;
|
|
53
|
+
|
|
54
|
+
styleProp = splitElementMarkerStyleProp(styleProp).styleProp;
|
|
55
|
+
if (!styleProp) return null;
|
|
56
|
+
|
|
57
|
+
if (RUNTIME_CONFIG.runtimeCacheTTL === 0) {
|
|
58
|
+
const items = collectStylePropItems(styleProp);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
items,
|
|
62
|
+
result: createStylePropResult(items, getThemeClassName),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let unsupportedItem: unknown;
|
|
67
|
+
const tokenBindings: StylePropTokenBinding[] = [];
|
|
68
|
+
const cache = getStylePropCacheValue<StylePropItem>(
|
|
69
|
+
styleProp,
|
|
70
|
+
walkStylePropCachePath,
|
|
71
|
+
() => warnUnsupportedStylePropItem(unsupportedItem),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (cache?.d) {
|
|
75
|
+
if (!tokenBindings.length) {
|
|
76
|
+
return {
|
|
77
|
+
items: cache.d.i,
|
|
78
|
+
result: cache.d.r,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
items: cache.d.i,
|
|
84
|
+
result: createStylePropResult(
|
|
85
|
+
applyTokenBindings(cache.d.i, tokenBindings),
|
|
86
|
+
getThemeClassName,
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const items = collectStylePropItems(styleProp, tokenBindings.length > 0);
|
|
92
|
+
const result = createStylePropResult(items, getThemeClassName);
|
|
93
|
+
const data = { i: items, r: result };
|
|
94
|
+
|
|
95
|
+
if (cache) cache.d = data;
|
|
96
|
+
|
|
97
|
+
if (!tokenBindings.length) return { items: data.i, result: data.r };
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
items,
|
|
101
|
+
result: createStylePropResult(
|
|
102
|
+
applyTokenBindings(items, tokenBindings),
|
|
103
|
+
getThemeClassName,
|
|
104
|
+
),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function walkStylePropCachePath(
|
|
108
|
+
styleProp: StyleProp,
|
|
109
|
+
fn: (item: object) => void,
|
|
110
|
+
onUnsupported: () => void,
|
|
111
|
+
) {
|
|
112
|
+
walkRecursiveItems(styleProp, (item) => {
|
|
113
|
+
if (isElementDebugData(item)) return;
|
|
114
|
+
|
|
115
|
+
const key = getStylePropCacheKey(item, tokenBindings);
|
|
116
|
+
|
|
117
|
+
if (key) {
|
|
118
|
+
fn(key);
|
|
119
|
+
} else {
|
|
120
|
+
unsupportedItem = item;
|
|
121
|
+
onUnsupported();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function walkStyleProp(
|
|
128
|
+
styleProp: StyleProp,
|
|
129
|
+
fn: (item: StylePropItem) => void,
|
|
130
|
+
options?: StylePropWalkOptions,
|
|
131
|
+
) {
|
|
132
|
+
walkRecursiveItems(styleProp, (item) => {
|
|
133
|
+
if (isElementDebugData(item)) return;
|
|
134
|
+
|
|
135
|
+
const styleItem = normalizeStylePropItem(item, options?.stableTokenBound ?? false);
|
|
136
|
+
|
|
137
|
+
if (styleItem) {
|
|
138
|
+
fn(styleItem);
|
|
139
|
+
} else {
|
|
140
|
+
options?.onUnsupported?.(item);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function getStylePropItems(
|
|
146
|
+
item: StylePropItem,
|
|
147
|
+
): StateItem[] {
|
|
148
|
+
if (isResolvedStyleItem(item)) return item.items;
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function collectStylePropItems(
|
|
153
|
+
styleProp: StyleProp,
|
|
154
|
+
stableTokenBound = false,
|
|
155
|
+
) {
|
|
156
|
+
const items: StylePropItem[] = [];
|
|
157
|
+
|
|
158
|
+
walkStyleProp(styleProp, (item) => {
|
|
159
|
+
items.push(item);
|
|
160
|
+
}, { stableTokenBound });
|
|
161
|
+
|
|
162
|
+
return items;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function warnUnsupportedStylePropItem(item: unknown) {
|
|
166
|
+
if (!DEV_CONFIG.isDev) return;
|
|
167
|
+
if (isElementDebugData(item)) return;
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
isSlotOverrideData(item) ||
|
|
171
|
+
isScopeData(item) ||
|
|
172
|
+
isScopeTargetData(item) ||
|
|
173
|
+
isStyleTokenOverrideData(item)
|
|
174
|
+
) {
|
|
175
|
+
console.warn(
|
|
176
|
+
'[fluentic-style] Unsupported style prop value. Pass themes, scopes, slot overrides, and token overrides to combineStyle before using style prop.',
|
|
177
|
+
item,
|
|
178
|
+
);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (item) {
|
|
183
|
+
console.warn(
|
|
184
|
+
'[fluentic-style] Unsupported style prop value.',
|
|
185
|
+
item,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function normalizeStylePropItem(
|
|
191
|
+
item: unknown,
|
|
192
|
+
stableTokenBound: boolean,
|
|
193
|
+
): StylePropItem | null {
|
|
194
|
+
if (isElementDebugData(item)) return null;
|
|
195
|
+
|
|
196
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
197
|
+
const bound = getExtractedTokenBoundData(item);
|
|
198
|
+
if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
|
|
199
|
+
|
|
200
|
+
const tokens = mergeTokenOverrides(null, bound.tokens);
|
|
201
|
+
|
|
202
|
+
if (isStyleData(bound.data) || isSlotData(bound.data)) {
|
|
203
|
+
return createResolvedStyleItem(bound.data, [], tokens);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return normalizeStylePropItem(bound.data, false);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (isResolvedStyleItem(item) || isThemeData(item)) {
|
|
210
|
+
return item;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (isStyleData(item) || isSlotData(item)) {
|
|
214
|
+
return getDirectStyleItem(item);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function getStylePropCacheKey(
|
|
221
|
+
item: unknown,
|
|
222
|
+
tokenBindings: StylePropTokenBinding[],
|
|
223
|
+
): object | null {
|
|
224
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
|
|
225
|
+
const bound = getExtractedTokenBoundData(item);
|
|
226
|
+
const key = getStylePropCacheKey(bound.data, tokenBindings);
|
|
227
|
+
const tokens = mergeTokenOverrides(null, bound.tokens);
|
|
228
|
+
|
|
229
|
+
if (key && tokens) {
|
|
230
|
+
tokenBindings.push({ data: key, tokens });
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return key;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (
|
|
237
|
+
isResolvedStyleItem(item) ||
|
|
238
|
+
isThemeData(item) ||
|
|
239
|
+
isStyleData(item) ||
|
|
240
|
+
isSlotData(item)
|
|
241
|
+
) {
|
|
242
|
+
return item;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function getThemeClassName(item: object) {
|
|
249
|
+
return isThemeData(item) ? item.className : null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function applyTokenBindings(
|
|
253
|
+
items: readonly StylePropItem[],
|
|
254
|
+
bindings: readonly StylePropTokenBinding[],
|
|
255
|
+
): StylePropItem[] {
|
|
256
|
+
if (!bindings.length) return items.slice();
|
|
257
|
+
|
|
258
|
+
return items.map((item) => {
|
|
259
|
+
if (!isResolvedStyleItem(item)) return item;
|
|
260
|
+
|
|
261
|
+
const tokens = getBoundTokens(item, bindings);
|
|
262
|
+
if (!tokens) return item;
|
|
263
|
+
|
|
264
|
+
return createResolvedStyleItemFromItems(item, tokens);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function getBoundTokens(
|
|
269
|
+
item: ResolvedStyleItem,
|
|
270
|
+
bindings: readonly StylePropTokenBinding[],
|
|
271
|
+
) {
|
|
272
|
+
let tokens = getStyleTokenValues(item);
|
|
273
|
+
|
|
274
|
+
for (let i = 0, len = bindings.length; i < len; i++) {
|
|
275
|
+
const binding = bindings[i];
|
|
276
|
+
|
|
277
|
+
if (binding.data !== item.data && binding.data !== item) continue;
|
|
278
|
+
|
|
279
|
+
tokens = mergeTokenValues(tokens, binding.tokens);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return tokens;
|
|
283
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
2
|
+
import type { StyleProp } from '../../types';
|
|
3
|
+
import type { ResolvedStyleProp } from './result';
|
|
4
|
+
import { createWeakCacheTreeNode, getWeakCacheTreeChild, type WeakCacheTreeNode } from './utils/tree';
|
|
5
|
+
|
|
6
|
+
type CacheValue<Data = StylePropCacheData<object>> = {
|
|
7
|
+
d: Data | null;
|
|
8
|
+
c: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type CacheNode<Item extends object> = WeakCacheTreeNode<Item, CacheValue>;
|
|
12
|
+
|
|
13
|
+
export type StylePropCacheData<Item extends object> = {
|
|
14
|
+
i: Item[];
|
|
15
|
+
r: ResolvedStyleProp;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const root = createWeakCacheTreeNode<object, CacheValue>(createCacheValue());
|
|
19
|
+
|
|
20
|
+
export function getStylePropCacheValue<Item extends object, Data = StylePropCacheData<Item>>(
|
|
21
|
+
styleProp: StyleProp,
|
|
22
|
+
walk: (
|
|
23
|
+
styleProp: StyleProp,
|
|
24
|
+
fn: (item: object) => void,
|
|
25
|
+
onUnsupported: () => void,
|
|
26
|
+
) => void,
|
|
27
|
+
onUnsupported?: () => void,
|
|
28
|
+
) {
|
|
29
|
+
let node = root as CacheNode<object>;
|
|
30
|
+
let hasItem = false;
|
|
31
|
+
let canCache = true;
|
|
32
|
+
|
|
33
|
+
walk(
|
|
34
|
+
styleProp,
|
|
35
|
+
(item) => {
|
|
36
|
+
hasItem = true;
|
|
37
|
+
node = getWeakCacheTreeChild(node, item, createCacheValue);
|
|
38
|
+
},
|
|
39
|
+
() => {
|
|
40
|
+
canCache = false;
|
|
41
|
+
onUnsupported?.();
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (!hasItem || !canCache) return null;
|
|
46
|
+
|
|
47
|
+
const value = node.value as CacheValue<Data>;
|
|
48
|
+
|
|
49
|
+
if (value.c !== RUNTIME_CONFIG.changes) {
|
|
50
|
+
value.d = null;
|
|
51
|
+
value.c = RUNTIME_CONFIG.changes;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function createCacheValue(): CacheValue {
|
|
58
|
+
return {
|
|
59
|
+
d: null,
|
|
60
|
+
c: RUNTIME_CONFIG.changes,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { globalData } from '../../../utils/global';
|
|
2
|
+
import type { StyleTokenValues } from './tokenValues';
|
|
3
|
+
|
|
4
|
+
const resolvedStyleItems = globalData(
|
|
5
|
+
'runtime.resolvedStyleItems',
|
|
6
|
+
() => new WeakSet<object>(),
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const resolvedStyleItemTokenValues = globalData(
|
|
10
|
+
'runtime.styleItemTokenValues',
|
|
11
|
+
() => new WeakMap<object, StyleTokenValues | null>(),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export function markResolvedStyleItem(item: object) {
|
|
15
|
+
resolvedStyleItems.add(item);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isResolvedStyleItem(value: unknown): value is object {
|
|
19
|
+
return !!value && typeof value === 'object' && resolvedStyleItems.has(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setResolvedStyleItemTokenValues(
|
|
23
|
+
item: object,
|
|
24
|
+
tokens: StyleTokenValues,
|
|
25
|
+
) {
|
|
26
|
+
resolvedStyleItemTokenValues.set(item, tokens);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getResolvedStyleItemTokenValues(item: object) {
|
|
30
|
+
return resolvedStyleItemTokenValues.get(item) ?? null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { StateItem } from '../../../builder/data/state';
|
|
3
|
+
import type { ResolvedStyleItem } from './item';
|
|
4
|
+
import { getStyleTokenValues, isResolvedStyleItem } from './item';
|
|
5
|
+
import {
|
|
6
|
+
getStateItemAtRuleRefVariables,
|
|
7
|
+
getStateItemClassName,
|
|
8
|
+
getStateItemDedupe,
|
|
9
|
+
getStateItemVariableValue,
|
|
10
|
+
} from './stateItem';
|
|
11
|
+
import type { StyleTokenValues } from './tokenValues';
|
|
12
|
+
|
|
13
|
+
export type ResolvedStyleProp = {
|
|
14
|
+
className: string;
|
|
15
|
+
style: CSSProperties | undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type StylePropResolveItem = ResolvedStyleItem | object;
|
|
19
|
+
|
|
20
|
+
export const emptyStylePropResult: ResolvedStyleProp = {
|
|
21
|
+
className: '',
|
|
22
|
+
style: undefined,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
let runId = 0;
|
|
26
|
+
|
|
27
|
+
const dedupeRun: Record<string, number> = Object.create(null);
|
|
28
|
+
const dedupeIndex: Record<string, number> = Object.create(null);
|
|
29
|
+
|
|
30
|
+
export function createStylePropResult(
|
|
31
|
+
items: readonly StylePropResolveItem[],
|
|
32
|
+
getThemeClassName: (item: object) => string | null,
|
|
33
|
+
): ResolvedStyleProp {
|
|
34
|
+
runId++;
|
|
35
|
+
|
|
36
|
+
const classNames: string[] = [];
|
|
37
|
+
let style: CSSProperties | undefined;
|
|
38
|
+
|
|
39
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
40
|
+
const item = items[i];
|
|
41
|
+
|
|
42
|
+
if (!isResolvedStyleItem(item)) {
|
|
43
|
+
const themeClassName = getThemeClassName(item);
|
|
44
|
+
if (themeClassName) classNames.push(themeClassName);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const tokens = getStyleTokenValues(item);
|
|
49
|
+
const stateItems = item.items;
|
|
50
|
+
|
|
51
|
+
for (let j = 0, itemLen = stateItems.length; j < itemLen; j++) {
|
|
52
|
+
style = addItem(classNames, style, stateItems[j], tokens);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!classNames.length) return emptyStylePropResult;
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
className: classNames.join(' '),
|
|
60
|
+
style,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function addItem(
|
|
65
|
+
classNames: string[],
|
|
66
|
+
style: CSSProperties | undefined,
|
|
67
|
+
item: StateItem,
|
|
68
|
+
tokens: StyleTokenValues | null,
|
|
69
|
+
) {
|
|
70
|
+
const dedupe = getStateItemDedupe(item);
|
|
71
|
+
const className = getStateItemClassName(item);
|
|
72
|
+
|
|
73
|
+
if (!dedupe || !className) return style;
|
|
74
|
+
|
|
75
|
+
if (dedupeRun[dedupe] === runId) {
|
|
76
|
+
classNames[dedupeIndex[dedupe]] = className;
|
|
77
|
+
return addItemStyle(style, item, tokens);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
dedupeRun[dedupe] = runId;
|
|
81
|
+
dedupeIndex[dedupe] = classNames.push(className) - 1;
|
|
82
|
+
return addItemStyle(style, item, tokens);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function addItemStyle(
|
|
86
|
+
style: CSSProperties | undefined,
|
|
87
|
+
item: StateItem,
|
|
88
|
+
tokens: StyleTokenValues | null,
|
|
89
|
+
) {
|
|
90
|
+
const variableValue = getStateItemVariableValue(item, tokens);
|
|
91
|
+
if (variableValue) {
|
|
92
|
+
style = setStyleValue(style, variableValue[0], variableValue[1]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const refValues = getStateItemAtRuleRefVariables(item, tokens);
|
|
96
|
+
if (!refValues) return style;
|
|
97
|
+
|
|
98
|
+
for (let i = 0, len = refValues.length; i < len; i++) {
|
|
99
|
+
style = setStyleValue(style, refValues[i][0], refValues[i][1]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return style;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function setStyleValue(
|
|
106
|
+
style: CSSProperties | undefined,
|
|
107
|
+
name: string,
|
|
108
|
+
value: unknown,
|
|
109
|
+
) {
|
|
110
|
+
const next = style ?? {};
|
|
111
|
+
|
|
112
|
+
(next as Record<string, unknown>)[name] = value;
|
|
113
|
+
|
|
114
|
+
return next;
|
|
115
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { getTokenVar, getTokenVarName } from '../../../atomic/token';
|
|
2
|
+
import {
|
|
3
|
+
BUILDER_TYPE_SCOPE,
|
|
4
|
+
BUILDER_TYPE_SLOT,
|
|
5
|
+
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
6
|
+
BUILDER_TYPE_STYLE,
|
|
7
|
+
ITEM_VALUE_NUMBER_PX,
|
|
8
|
+
ITEM_VALUE_TYPE_AT_RULE_REF,
|
|
9
|
+
ITEM_VALUE_TYPE_VARIABLE,
|
|
10
|
+
} from '../../../builder/data/const';
|
|
11
|
+
import type { StateItem } from '../../../builder/data/state';
|
|
12
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
13
|
+
import { getStyleTokenId, isStyleTokenData, isStyleTokenOverrideData, type StyleTokenData } from '../../../style/token';
|
|
14
|
+
import type { AtRuleRefData } from '../../../style/valueRef';
|
|
15
|
+
import { hasOwn } from '../../../utils/object';
|
|
16
|
+
import type { StyleTokenValues } from './tokenValues';
|
|
17
|
+
|
|
18
|
+
export function getStateItemDedupe(item: StateItem) {
|
|
19
|
+
if (Array.isArray(item)) {
|
|
20
|
+
if (typeof item[0] === 'number') {
|
|
21
|
+
switch (item[0]) {
|
|
22
|
+
case BUILDER_TYPE_STYLE:
|
|
23
|
+
return item[1];
|
|
24
|
+
case BUILDER_TYPE_SLOT:
|
|
25
|
+
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
26
|
+
case BUILDER_TYPE_SCOPE:
|
|
27
|
+
return item[2];
|
|
28
|
+
}
|
|
29
|
+
} else if (typeof item[1] === 'string') {
|
|
30
|
+
return item[1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (isStyleTokenOverrideData(item)) return '';
|
|
37
|
+
|
|
38
|
+
return item.dedupe;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getStateItemClassName(item: StateItem) {
|
|
42
|
+
if (Array.isArray(item)) {
|
|
43
|
+
if (typeof item[0] === 'number') {
|
|
44
|
+
switch (item[0]) {
|
|
45
|
+
case BUILDER_TYPE_STYLE:
|
|
46
|
+
return item[2];
|
|
47
|
+
case BUILDER_TYPE_SLOT:
|
|
48
|
+
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
49
|
+
case BUILDER_TYPE_SCOPE:
|
|
50
|
+
return item[3];
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
return item[1];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isStyleTokenOverrideData(item)) return '';
|
|
60
|
+
|
|
61
|
+
return item.className;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function getStateItemVariableValue(
|
|
65
|
+
item: StateItem,
|
|
66
|
+
tokens: StyleTokenValues | null,
|
|
67
|
+
): [string, unknown] | null {
|
|
68
|
+
const value = getStateItemValue(item);
|
|
69
|
+
|
|
70
|
+
if (Array.isArray(value) && value[0] === ITEM_VALUE_TYPE_VARIABLE) {
|
|
71
|
+
return [
|
|
72
|
+
value[1],
|
|
73
|
+
resolveMarkedVariableValue(value[2], value[3], tokens),
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!Array.isArray(item) && !isStyleTokenOverrideData(item) && item.variable?.[0] === ITEM_VALUE_TYPE_VARIABLE) {
|
|
78
|
+
return [
|
|
79
|
+
item.variable[1],
|
|
80
|
+
resolveMarkedVariableValue(item.variable[2], item.variable[3], tokens),
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!Array.isArray(item) && !isStyleTokenOverrideData(item) && item.token) {
|
|
85
|
+
if (!tokens) return null;
|
|
86
|
+
|
|
87
|
+
const id = getStyleTokenId(item.token);
|
|
88
|
+
if (!hasOwn(tokens.lookup, id)) return null;
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
getTokenVarName(item.token, CSS_CONFIG.tokenNameFormat ?? null),
|
|
92
|
+
tokens.lookup[id],
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function resolveMarkedVariableValue(
|
|
100
|
+
value: unknown,
|
|
101
|
+
valueMode: unknown,
|
|
102
|
+
tokens: StyleTokenValues | null,
|
|
103
|
+
) {
|
|
104
|
+
return normalizeVariableValue(resolveVariableValue(value, tokens), valueMode);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function normalizeVariableValue(
|
|
108
|
+
value: unknown,
|
|
109
|
+
valueMode: unknown,
|
|
110
|
+
) {
|
|
111
|
+
if (typeof value !== 'number') return value;
|
|
112
|
+
|
|
113
|
+
return valueMode === ITEM_VALUE_NUMBER_PX ? value + 'px' : String(value);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function getStateItemAtRuleRef(item: StateItem): AtRuleRefData | null {
|
|
117
|
+
const value = getStateItemValue(item);
|
|
118
|
+
|
|
119
|
+
if (Array.isArray(value) && value[0] === ITEM_VALUE_TYPE_AT_RULE_REF) {
|
|
120
|
+
return value[1];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
!Array.isArray(item) && !isStyleTokenOverrideData(item) &&
|
|
125
|
+
item.variable?.[0] === ITEM_VALUE_TYPE_AT_RULE_REF
|
|
126
|
+
) {
|
|
127
|
+
return item.variable[1];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function getStateItemAtRuleRefVariables(
|
|
134
|
+
item: StateItem,
|
|
135
|
+
tokens: StyleTokenValues | null,
|
|
136
|
+
): [string, unknown][] | null {
|
|
137
|
+
if (!tokens) return null;
|
|
138
|
+
|
|
139
|
+
const ref = getStateItemAtRuleRef(item);
|
|
140
|
+
const refTokens = ref?.tokens;
|
|
141
|
+
|
|
142
|
+
if (!refTokens?.length) return null;
|
|
143
|
+
|
|
144
|
+
const values: [string, unknown][] = [];
|
|
145
|
+
|
|
146
|
+
for (let i = 0, len = refTokens.length; i < len; i++) {
|
|
147
|
+
const token = refTokens[i];
|
|
148
|
+
const id = getStyleTokenId(token);
|
|
149
|
+
|
|
150
|
+
if (!hasOwn(tokens.lookup, id)) continue;
|
|
151
|
+
|
|
152
|
+
values.push([
|
|
153
|
+
getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null),
|
|
154
|
+
tokens.lookup[id],
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return values.length ? values : null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getStateItemValue(item: StateItem) {
|
|
162
|
+
if (Array.isArray(item)) {
|
|
163
|
+
if (typeof item[0] === 'number') {
|
|
164
|
+
switch (item[0]) {
|
|
165
|
+
case BUILDER_TYPE_STYLE:
|
|
166
|
+
return item[3];
|
|
167
|
+
case BUILDER_TYPE_SLOT:
|
|
168
|
+
case BUILDER_TYPE_SLOT_OVERRIDE:
|
|
169
|
+
return item[4];
|
|
170
|
+
case BUILDER_TYPE_SCOPE:
|
|
171
|
+
return isExtractedScopeParentMarker(item[4]) ? undefined : item[4];
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
return item[2];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isExtractedScopeParentMarker(value: unknown) {
|
|
182
|
+
return value === 1 || value === true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function resolveVariableValue(
|
|
186
|
+
value: unknown,
|
|
187
|
+
tokens: StyleTokenValues | null,
|
|
188
|
+
) {
|
|
189
|
+
if (isStyleTokenData(value)) {
|
|
190
|
+
return resolveTokenValue(value, tokens);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function resolveTokenValue<T>(
|
|
197
|
+
token: StyleTokenData<T>,
|
|
198
|
+
tokens: StyleTokenValues | null,
|
|
199
|
+
): T {
|
|
200
|
+
if (tokens) {
|
|
201
|
+
const id = getStyleTokenId(token);
|
|
202
|
+
if (hasOwn(tokens.lookup, id)) {
|
|
203
|
+
return tokens.lookup[id] as T;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) as T;
|
|
208
|
+
}
|