@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,68 @@
|
|
|
1
|
+
import type { StyleValue } from '../../style/types';
|
|
2
|
+
import {
|
|
3
|
+
BUILDER_SCOPE,
|
|
4
|
+
BUILDER_SCOPE_ID,
|
|
5
|
+
BUILDER_SLOT_ID,
|
|
6
|
+
BUILDER_TYPE,
|
|
7
|
+
BUILDER_TYPE_SCOPE,
|
|
8
|
+
BUILDER_TYPE_SCOPE_TARGET,
|
|
9
|
+
BUILDER_TYPE_SLOT,
|
|
10
|
+
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
11
|
+
BUILDER_TYPE_STYLE,
|
|
12
|
+
BUILDER_TYPE_THEME,
|
|
13
|
+
} from './const';
|
|
14
|
+
import {
|
|
15
|
+
type BuilderData,
|
|
16
|
+
type ScopeData,
|
|
17
|
+
type ScopeTargetData,
|
|
18
|
+
type SlotData,
|
|
19
|
+
type SlotOverrideData,
|
|
20
|
+
type StyleData,
|
|
21
|
+
type ThemeData,
|
|
22
|
+
} from './data';
|
|
23
|
+
|
|
24
|
+
export function getSlotId(data: SlotData | SlotOverrideData) {
|
|
25
|
+
return data[BUILDER_SLOT_ID];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getScopeTargetSlotId(data: ScopeTargetData) {
|
|
29
|
+
return data[BUILDER_SCOPE_ID];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getScopeTargetScope<Style>(data: ScopeTargetData<Style>) {
|
|
33
|
+
return data[BUILDER_SCOPE];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isStyleValue<T>(value: unknown): value is StyleValue<T> {
|
|
37
|
+
return Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function isStyleData<Style>(value: unknown): value is StyleData<Style> {
|
|
41
|
+
return getBuilderType(value) === BUILDER_TYPE_STYLE;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function isSlotData<Style>(value: unknown): value is SlotData<Style> {
|
|
45
|
+
return getBuilderType(value) === BUILDER_TYPE_SLOT;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function isSlotOverrideData<Style>(value: unknown): value is SlotOverrideData<Style> {
|
|
49
|
+
return getBuilderType(value) === BUILDER_TYPE_SLOT_OVERRIDE;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function isScopeData<Style>(value: unknown): value is ScopeData<Style> {
|
|
53
|
+
return getBuilderType(value) === BUILDER_TYPE_SCOPE;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function isScopeTargetData<Style>(value: unknown): value is ScopeTargetData<Style> {
|
|
57
|
+
return getBuilderType(value) === BUILDER_TYPE_SCOPE_TARGET;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isThemeData(value: unknown): value is ThemeData {
|
|
61
|
+
return getBuilderType(value) === BUILDER_TYPE_THEME;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getBuilderType(value: unknown) {
|
|
65
|
+
if (!value || (typeof value !== 'object' && typeof value !== 'function')) return null;
|
|
66
|
+
|
|
67
|
+
return (value as BuilderData)[BUILDER_TYPE];
|
|
68
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { getAtomicClassName, getClassNameDedupe } from '../../../atomic/className';
|
|
2
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
+
import { DEBUG_CONFIG } from '../../../config/config/debug';
|
|
4
|
+
import { DEV_CONFIG } from '../../../config/config/dev';
|
|
5
|
+
import { getStyleTokenId, isStyleTokenOverrideData, type StyleTokenOverride } from '../../../style/token';
|
|
6
|
+
import { BUILDER_SLOT_ID, BUILDER_STATE, BUILDER_TYPE_SCOPE, BUILDER_TYPE_SLOT_OVERRIDE } from '../const';
|
|
7
|
+
import type { BuilderCallsite, ScopeData, SlotOverrideData } from '../data';
|
|
8
|
+
import {
|
|
9
|
+
getDebugFieldCallsite,
|
|
10
|
+
TRACE_STYLE,
|
|
11
|
+
TRACE_VALUE,
|
|
12
|
+
type DebugData,
|
|
13
|
+
type DebugLoc,
|
|
14
|
+
} from '../debug';
|
|
15
|
+
import { isScopeData, isSlotOverrideData } from '../is';
|
|
16
|
+
import type { ItemSelector, ItemValue, RuntimeScopeItem, RuntimeSlotOverrideItem, StateItem } from '../state';
|
|
17
|
+
import { cloneData, logInvalidData } from './utils';
|
|
18
|
+
|
|
19
|
+
export type ScopeItem<Style = unknown> =
|
|
20
|
+
| SlotOverrideData<Style>
|
|
21
|
+
| ScopeData<Style>
|
|
22
|
+
| StyleTokenOverride
|
|
23
|
+
| false
|
|
24
|
+
| null
|
|
25
|
+
| undefined;
|
|
26
|
+
|
|
27
|
+
export type ScopeItems<Style = unknown> =
|
|
28
|
+
| ScopeItem<Style>
|
|
29
|
+
| ScopeItem<Style>[];
|
|
30
|
+
|
|
31
|
+
export function mergeScopeData<Style>(
|
|
32
|
+
scope: ScopeData<Style>,
|
|
33
|
+
callsite: BuilderCallsite | null,
|
|
34
|
+
items: ScopeItems<Style> | null,
|
|
35
|
+
debug: DebugData | null,
|
|
36
|
+
parentSelector: ItemSelector | null,
|
|
37
|
+
scopeAtRule: ItemSelector | null,
|
|
38
|
+
): ScopeData<Style> {
|
|
39
|
+
if (!items) return scope;
|
|
40
|
+
|
|
41
|
+
const sourceItems = Array.isArray(items) ? items : [items];
|
|
42
|
+
const [runtimeType, data, styles, lookup] = cloneData(
|
|
43
|
+
scope,
|
|
44
|
+
scope,
|
|
45
|
+
debug,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let source: ScopeItem<Style>;
|
|
49
|
+
let item: StateItem;
|
|
50
|
+
let lookupIndex: number;
|
|
51
|
+
let priority: number | null;
|
|
52
|
+
let value: ItemValue;
|
|
53
|
+
let atRule: ItemSelector[] | null;
|
|
54
|
+
let dedupe: string;
|
|
55
|
+
let className: string;
|
|
56
|
+
let itemDebug: DebugData | null | undefined;
|
|
57
|
+
let itemCallsite: BuilderCallsite | null;
|
|
58
|
+
|
|
59
|
+
for (let i = 0, len = sourceItems.length; i < len; i++) {
|
|
60
|
+
source = sourceItems[i];
|
|
61
|
+
if (!source) continue;
|
|
62
|
+
|
|
63
|
+
if (isStyleTokenOverrideData(source)) {
|
|
64
|
+
addTokenOverride(source, styles, lookup);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isScopeData(source)) {
|
|
69
|
+
const scopeItems = source[BUILDER_STATE].items;
|
|
70
|
+
|
|
71
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
72
|
+
item = scopeItems[j];
|
|
73
|
+
|
|
74
|
+
if (isStyleTokenOverrideData(item)) {
|
|
75
|
+
addTokenOverride(item, styles, lookup);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (Array.isArray(item) || item.type !== BUILDER_TYPE_SCOPE) {
|
|
80
|
+
logInvalidData('invalid scope data', { source, item });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const sourceScopeItem = item as RuntimeScopeItem;
|
|
85
|
+
|
|
86
|
+
atRule = scopeAtRule
|
|
87
|
+
? (sourceScopeItem.atRule ? [scopeAtRule].concat(sourceScopeItem.atRule) : [scopeAtRule])
|
|
88
|
+
: sourceScopeItem.atRule;
|
|
89
|
+
|
|
90
|
+
const scopeItem: RuntimeScopeItem = {
|
|
91
|
+
...sourceScopeItem,
|
|
92
|
+
runtime: runtimeType,
|
|
93
|
+
atRule,
|
|
94
|
+
parentSelector: parentSelector ?? sourceScopeItem.parentSelector,
|
|
95
|
+
};
|
|
96
|
+
itemDebug = getMergedScopeDebug(debug, scopeItem);
|
|
97
|
+
itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ??
|
|
98
|
+
callsite ??
|
|
99
|
+
scopeItem.callsite;
|
|
100
|
+
|
|
101
|
+
value = scopeItem.value;
|
|
102
|
+
priority = null;
|
|
103
|
+
|
|
104
|
+
if (Array.isArray(value)) {
|
|
105
|
+
priority = value[1];
|
|
106
|
+
value = value[0];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
dedupe = getClassNameDedupe(
|
|
110
|
+
scopeItem.property,
|
|
111
|
+
priority,
|
|
112
|
+
scopeItem.selector,
|
|
113
|
+
scopeItem.parentSelector,
|
|
114
|
+
scopeItem.atRule,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
className = getAtomicClassName(
|
|
118
|
+
scopeItem.property,
|
|
119
|
+
priority,
|
|
120
|
+
value,
|
|
121
|
+
scopeItem.selector,
|
|
122
|
+
scopeItem.parentSelector,
|
|
123
|
+
scopeItem.atRule,
|
|
124
|
+
itemCallsite,
|
|
125
|
+
DEV_CONFIG.isLocalClassNameEnabled,
|
|
126
|
+
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
127
|
+
CSS_CONFIG.classNameFormat ?? null,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
scopeItem.dedupe = dedupe;
|
|
131
|
+
scopeItem.className = className;
|
|
132
|
+
scopeItem.callsite = itemCallsite;
|
|
133
|
+
scopeItem.debug = itemDebug ?? null;
|
|
134
|
+
scopeItem.debugField = itemDebug ? scopeItem.property : null;
|
|
135
|
+
|
|
136
|
+
const lookupKey = getScopeLookupKey(scopeItem.slotId, dedupe);
|
|
137
|
+
lookupIndex = lookup[lookupKey];
|
|
138
|
+
|
|
139
|
+
if (typeof lookupIndex === 'number') {
|
|
140
|
+
styles[lookupIndex] = scopeItem;
|
|
141
|
+
} else {
|
|
142
|
+
lookup[lookupKey] = styles.push(scopeItem) - 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!isSlotOverrideData(source)) {
|
|
150
|
+
logInvalidData('invalid scope data', { source });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const slotId = source[BUILDER_SLOT_ID];
|
|
155
|
+
const overrideItems = source[BUILDER_STATE].items;
|
|
156
|
+
|
|
157
|
+
for (let j = 0, len = overrideItems.length; j < len; j++) {
|
|
158
|
+
item = overrideItems[j];
|
|
159
|
+
|
|
160
|
+
if (Array.isArray(item) || isStyleTokenOverrideData(item) || item.type !== BUILDER_TYPE_SLOT_OVERRIDE) {
|
|
161
|
+
logInvalidData('invalid scope data', { source, item });
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const overrideItem = item as RuntimeSlotOverrideItem;
|
|
166
|
+
|
|
167
|
+
atRule = scopeAtRule
|
|
168
|
+
? (overrideItem.atRule ? [scopeAtRule].concat(overrideItem.atRule) : [scopeAtRule])
|
|
169
|
+
: overrideItem.atRule;
|
|
170
|
+
|
|
171
|
+
const scopeItem: RuntimeScopeItem = {
|
|
172
|
+
type: BUILDER_TYPE_SCOPE,
|
|
173
|
+
slotId,
|
|
174
|
+
runtime: runtimeType,
|
|
175
|
+
dedupe: '',
|
|
176
|
+
className: '',
|
|
177
|
+
property: overrideItem.property,
|
|
178
|
+
value: overrideItem.value,
|
|
179
|
+
token: overrideItem.token,
|
|
180
|
+
selector: overrideItem.selector,
|
|
181
|
+
atRule,
|
|
182
|
+
callsite: overrideItem.callsite ?? callsite,
|
|
183
|
+
debug: overrideItem.debug,
|
|
184
|
+
debugField: overrideItem.debugField,
|
|
185
|
+
parentSelector,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
value = scopeItem.value;
|
|
189
|
+
priority = null;
|
|
190
|
+
|
|
191
|
+
if (Array.isArray(value)) {
|
|
192
|
+
priority = value[1];
|
|
193
|
+
value = value[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
dedupe = getClassNameDedupe(
|
|
197
|
+
scopeItem.property,
|
|
198
|
+
priority,
|
|
199
|
+
scopeItem.selector,
|
|
200
|
+
parentSelector,
|
|
201
|
+
scopeItem.atRule,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
className = getAtomicClassName(
|
|
205
|
+
scopeItem.property,
|
|
206
|
+
priority,
|
|
207
|
+
value,
|
|
208
|
+
scopeItem.selector,
|
|
209
|
+
parentSelector,
|
|
210
|
+
scopeItem.atRule,
|
|
211
|
+
scopeItem.callsite,
|
|
212
|
+
DEV_CONFIG.isLocalClassNameEnabled,
|
|
213
|
+
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
214
|
+
CSS_CONFIG.classNameFormat ?? null,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
scopeItem.dedupe = dedupe;
|
|
218
|
+
scopeItem.className = className;
|
|
219
|
+
|
|
220
|
+
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
221
|
+
lookupIndex = lookup[lookupKey];
|
|
222
|
+
|
|
223
|
+
if (typeof lookupIndex === 'number') {
|
|
224
|
+
styles[lookupIndex] = scopeItem;
|
|
225
|
+
} else {
|
|
226
|
+
lookup[lookupKey] = styles.push(scopeItem) - 1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return data as ScopeData<Style>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function addTokenOverride(
|
|
235
|
+
item: StyleTokenOverride,
|
|
236
|
+
styles: StateItem[],
|
|
237
|
+
lookup: Record<string, number>,
|
|
238
|
+
) {
|
|
239
|
+
const lookupKey = getTokenLookupKey(getStyleTokenId(item));
|
|
240
|
+
const lookupIndex = lookup[lookupKey];
|
|
241
|
+
|
|
242
|
+
if (typeof lookupIndex === 'number') {
|
|
243
|
+
styles[lookupIndex] = item;
|
|
244
|
+
} else {
|
|
245
|
+
lookup[lookupKey] = styles.push(item) - 1;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function getMergedScopeDebug(
|
|
250
|
+
debug: DebugData | null,
|
|
251
|
+
item: RuntimeScopeItem,
|
|
252
|
+
): DebugData | null | undefined {
|
|
253
|
+
if (!debug) return item.debug;
|
|
254
|
+
if (debug.fields?.[item.property]) return debug;
|
|
255
|
+
|
|
256
|
+
const valueLoc = getRuntimeScopeItemValueLoc(item);
|
|
257
|
+
if (!valueLoc) return debug;
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
...debug,
|
|
261
|
+
fields: {
|
|
262
|
+
...debug.fields,
|
|
263
|
+
[item.property]: {
|
|
264
|
+
[TRACE_STYLE]: debug.loc,
|
|
265
|
+
[TRACE_VALUE]: valueLoc,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function getRuntimeScopeItemValueLoc(item: RuntimeScopeItem): DebugLoc | null {
|
|
272
|
+
if (item.debug && item.debugField) {
|
|
273
|
+
const loc = item.debug.fields?.[item.debugField];
|
|
274
|
+
if (Array.isArray(loc)) return withDebugSource(loc, item.debug.sourceUrl, item.debug.code);
|
|
275
|
+
if (loc) {
|
|
276
|
+
const valueLoc = loc[TRACE_VALUE] ?? loc[TRACE_STYLE] ?? null;
|
|
277
|
+
return valueLoc ? withDebugSource(valueLoc, item.debug.sourceUrl, item.debug.code) : null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return item.callsite
|
|
282
|
+
? [item.callsite.line, item.callsite.column, undefined, item.callsite.sourceUrl, item.callsite.sourceContent]
|
|
283
|
+
: null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function withDebugSource(
|
|
287
|
+
loc: DebugLoc,
|
|
288
|
+
sourceUrl: string,
|
|
289
|
+
sourceContent: string | undefined,
|
|
290
|
+
): DebugLoc {
|
|
291
|
+
return loc[3] ? loc : [loc[0], loc[1], loc[2], sourceUrl, sourceContent];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function getScopeLookupKey(slotId: string, dedupe: string) {
|
|
295
|
+
return slotId + '\0' + dedupe;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function getTokenLookupKey(tokenId: string) {
|
|
299
|
+
return 'token\0' + tokenId;
|
|
300
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { getAtomicClassName, getClassNameDedupe } from '../../../atomic/className';
|
|
2
|
+
import { getTokenVar } from '../../../atomic/token';
|
|
3
|
+
import { getCssVarRawFallback } from '../../../atomic/utils/css';
|
|
4
|
+
import { shouldAppendCssPx } from '../../../atomic/value';
|
|
5
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
6
|
+
import { DEBUG_CONFIG } from '../../../config/config/debug';
|
|
7
|
+
import { DEV_CONFIG } from '../../../config/config/dev';
|
|
8
|
+
import { isStyleTokenData, isStyleTokenOverrideData, type StyleTokenData } from '../../../style/token';
|
|
9
|
+
import type { StyleObject, StyleValueTuple } from '../../../style/types';
|
|
10
|
+
import { type AtRuleRef, isAtRuleRef } from '../../../style/valueRef';
|
|
11
|
+
import {
|
|
12
|
+
BUILDER_SLOT_ID,
|
|
13
|
+
BUILDER_STATE,
|
|
14
|
+
BUILDER_TYPE_SLOT,
|
|
15
|
+
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
16
|
+
BUILDER_TYPE_STYLE,
|
|
17
|
+
ITEM_VALUE_NUMBER_PX,
|
|
18
|
+
ITEM_VALUE_TYPE_AT_RULE_REF,
|
|
19
|
+
ITEM_VALUE_TYPE_VARIABLE,
|
|
20
|
+
} from '../const';
|
|
21
|
+
import type { BuilderCallsite, BuilderData, StyleData } from '../data';
|
|
22
|
+
import {
|
|
23
|
+
type DebugData,
|
|
24
|
+
type DebugLoc,
|
|
25
|
+
getDebugFieldCallsite,
|
|
26
|
+
getDebugFieldVarName,
|
|
27
|
+
TRACE_STYLE,
|
|
28
|
+
TRACE_VALUE,
|
|
29
|
+
} from '../debug';
|
|
30
|
+
import { isSlotData, isSlotOverrideData, isStyleData } from '../is';
|
|
31
|
+
import type { BuilderType, ItemSelector, ItemValue, RuntimeItem, RuntimeItemData, StateItem } from '../state';
|
|
32
|
+
import { cloneData, logInvalidData } from './utils';
|
|
33
|
+
|
|
34
|
+
export type CreateData<Data extends BuilderData> = (
|
|
35
|
+
callsite: BuilderCallsite | null,
|
|
36
|
+
data: Data,
|
|
37
|
+
) => Data;
|
|
38
|
+
|
|
39
|
+
export function mergeBuilderData<Data extends BuilderData>(
|
|
40
|
+
create: CreateData<Data>,
|
|
41
|
+
callsite: BuilderCallsite | null,
|
|
42
|
+
source: Data,
|
|
43
|
+
style: StyleObject | StyleData | null,
|
|
44
|
+
debug: DebugData | null,
|
|
45
|
+
selector: ItemSelector | null,
|
|
46
|
+
atRule: ItemSelector[] | null,
|
|
47
|
+
type: BuilderType,
|
|
48
|
+
): Data {
|
|
49
|
+
if (!style) return source;
|
|
50
|
+
|
|
51
|
+
const [runtimeType, data, styles, lookup] = cloneData(
|
|
52
|
+
create(callsite, source),
|
|
53
|
+
source,
|
|
54
|
+
debug,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const slotId = isSlotData(source) || isSlotOverrideData(source)
|
|
58
|
+
? source[BUILDER_SLOT_ID]
|
|
59
|
+
: null;
|
|
60
|
+
|
|
61
|
+
const items: RuntimeItem[] = [];
|
|
62
|
+
|
|
63
|
+
let item: StateItem;
|
|
64
|
+
let itemData: RuntimeItemData;
|
|
65
|
+
|
|
66
|
+
let valueRaw: unknown;
|
|
67
|
+
let value: ItemValue;
|
|
68
|
+
let priority: number | null;
|
|
69
|
+
let itemCallsite: BuilderCallsite | null;
|
|
70
|
+
let className: string;
|
|
71
|
+
let dedupe: string;
|
|
72
|
+
let token: StyleTokenData | null;
|
|
73
|
+
let ref: AtRuleRef | null;
|
|
74
|
+
let variableName: string | null;
|
|
75
|
+
let lookupIndex: number;
|
|
76
|
+
|
|
77
|
+
if (isStyleData(style)) {
|
|
78
|
+
const stylesItems = style[BUILDER_STATE].items;
|
|
79
|
+
|
|
80
|
+
for (let i = 0, len = stylesItems.length; i < len; i++) {
|
|
81
|
+
item = stylesItems[i];
|
|
82
|
+
|
|
83
|
+
if (Array.isArray(item) || isStyleTokenOverrideData(item) || item.type !== BUILDER_TYPE_STYLE) {
|
|
84
|
+
logInvalidData('invalid style data', { item, style });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (atRule) {
|
|
89
|
+
item = Object.assign({}, item, {
|
|
90
|
+
atRule: item.atRule ? atRule.concat(item.atRule) : atRule,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Re-type to SLOT/SLOT_OVERRIDE when this StyleData is used inside a slot context.
|
|
95
|
+
// Without this, style.slot(...).media('...', style({...})) would keep the inner
|
|
96
|
+
// items as BUILDER_TYPE_STYLE and they would not be resolved when the slot is used.
|
|
97
|
+
if (type === BUILDER_TYPE_SLOT && slotId !== null) {
|
|
98
|
+
item = Object.assign({}, item, { type: BUILDER_TYPE_SLOT, slotId });
|
|
99
|
+
} else if (type === BUILDER_TYPE_SLOT_OVERRIDE && slotId !== null) {
|
|
100
|
+
item = Object.assign({}, item, { type: BUILDER_TYPE_SLOT_OVERRIDE, slotId });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const itemDebug = getMergedStyleDebug(debug, item);
|
|
104
|
+
const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
|
|
105
|
+
if (debugCallsite) {
|
|
106
|
+
item = Object.assign({}, item, {
|
|
107
|
+
callsite: debugCallsite,
|
|
108
|
+
debug: itemDebug,
|
|
109
|
+
debugField: item.property,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
items.push(item);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
for (const property in style) {
|
|
117
|
+
valueRaw = style[property as keyof typeof style];
|
|
118
|
+
priority = null;
|
|
119
|
+
|
|
120
|
+
if (Array.isArray(valueRaw) && valueRaw.length === 2 && typeof valueRaw[0] === 'number') {
|
|
121
|
+
priority = (valueRaw as StyleValueTuple)[0];
|
|
122
|
+
valueRaw = (valueRaw as StyleValueTuple)[1];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
126
|
+
if (ref) valueRaw = ref.value;
|
|
127
|
+
|
|
128
|
+
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
129
|
+
variableName = getDebugFieldVarName(debug, property);
|
|
130
|
+
|
|
131
|
+
value = variableName && token
|
|
132
|
+
? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null))
|
|
133
|
+
: token
|
|
134
|
+
? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)
|
|
135
|
+
: String(valueRaw ?? '');
|
|
136
|
+
|
|
137
|
+
value = priority !== null ? [value, priority] : value;
|
|
138
|
+
itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
|
|
139
|
+
|
|
140
|
+
itemData = {
|
|
141
|
+
runtime: runtimeType,
|
|
142
|
+
debug,
|
|
143
|
+
debugField: property,
|
|
144
|
+
dedupe: '',
|
|
145
|
+
className: '',
|
|
146
|
+
property,
|
|
147
|
+
value,
|
|
148
|
+
variable: ref
|
|
149
|
+
? [ITEM_VALUE_TYPE_AT_RULE_REF, ref]
|
|
150
|
+
: variableName && token
|
|
151
|
+
? [
|
|
152
|
+
ITEM_VALUE_TYPE_VARIABLE,
|
|
153
|
+
variableName,
|
|
154
|
+
valueRaw,
|
|
155
|
+
shouldAppendCssPx(property) ? ITEM_VALUE_NUMBER_PX : undefined,
|
|
156
|
+
]
|
|
157
|
+
: ref
|
|
158
|
+
? [ITEM_VALUE_TYPE_AT_RULE_REF, ref]
|
|
159
|
+
: undefined,
|
|
160
|
+
token,
|
|
161
|
+
selector,
|
|
162
|
+
atRule,
|
|
163
|
+
callsite: itemCallsite,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (type === BUILDER_TYPE_STYLE) {
|
|
167
|
+
items.push({ ...itemData, type: BUILDER_TYPE_STYLE });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (slotId === null) {
|
|
172
|
+
logInvalidData('invalid style data', { property, style });
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (type === BUILDER_TYPE_SLOT) {
|
|
177
|
+
items.push({ ...itemData, type: BUILDER_TYPE_SLOT, slotId });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (type === BUILDER_TYPE_SLOT_OVERRIDE) {
|
|
182
|
+
items.push({ ...itemData, type: BUILDER_TYPE_SLOT_OVERRIDE, slotId });
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
logInvalidData('invalid style data', { property, style });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!items.length) return data;
|
|
191
|
+
|
|
192
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
193
|
+
item = items[i];
|
|
194
|
+
|
|
195
|
+
if (Array.isArray(item) || isStyleTokenOverrideData(item)) {
|
|
196
|
+
logInvalidData('invalid style data', { item, style });
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const runtimeItem = item as RuntimeItem;
|
|
201
|
+
value = runtimeItem.value;
|
|
202
|
+
priority = null;
|
|
203
|
+
|
|
204
|
+
if (Array.isArray(value)) {
|
|
205
|
+
priority = value[1];
|
|
206
|
+
value = value[0];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
dedupe = getClassNameDedupe(
|
|
210
|
+
runtimeItem.property,
|
|
211
|
+
priority,
|
|
212
|
+
runtimeItem.selector,
|
|
213
|
+
null,
|
|
214
|
+
runtimeItem.atRule,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
className = getAtomicClassName(
|
|
218
|
+
runtimeItem.property,
|
|
219
|
+
priority,
|
|
220
|
+
value,
|
|
221
|
+
runtimeItem.selector,
|
|
222
|
+
null,
|
|
223
|
+
runtimeItem.atRule,
|
|
224
|
+
runtimeItem.callsite,
|
|
225
|
+
DEV_CONFIG.isLocalClassNameEnabled,
|
|
226
|
+
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
227
|
+
CSS_CONFIG.classNameFormat ?? null,
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
runtimeItem.dedupe = dedupe;
|
|
231
|
+
runtimeItem.className = className;
|
|
232
|
+
|
|
233
|
+
lookupIndex = lookup[dedupe];
|
|
234
|
+
|
|
235
|
+
if (typeof lookupIndex === 'number') {
|
|
236
|
+
styles[lookupIndex] = runtimeItem;
|
|
237
|
+
} else {
|
|
238
|
+
lookup[dedupe] = styles.push(runtimeItem) - 1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return data;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function getMergedStyleDebug(
|
|
246
|
+
debug: DebugData | null,
|
|
247
|
+
item: RuntimeItem,
|
|
248
|
+
) {
|
|
249
|
+
if (!debug) return null;
|
|
250
|
+
if (debug.fields?.[item.property]) return debug;
|
|
251
|
+
|
|
252
|
+
const valueLoc = getMergedItemValueLoc(item);
|
|
253
|
+
if (!valueLoc) return debug;
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
...debug,
|
|
257
|
+
fields: {
|
|
258
|
+
...debug.fields,
|
|
259
|
+
[item.property]: {
|
|
260
|
+
[TRACE_STYLE]: withDebugSource(debug.loc, debug),
|
|
261
|
+
[TRACE_VALUE]: valueLoc,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function getMergedItemValueLoc(item: RuntimeItem): DebugLoc | null {
|
|
268
|
+
if (item.debug && item.debugField) {
|
|
269
|
+
const loc = item.debug.fields?.[item.debugField];
|
|
270
|
+
if (Array.isArray(loc)) return withDebugSource(loc, item.debug);
|
|
271
|
+
if (loc) {
|
|
272
|
+
const traceLoc = loc[TRACE_VALUE] ?? loc[TRACE_STYLE] ?? null;
|
|
273
|
+
return traceLoc ? withDebugSource(traceLoc, item.debug) : null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return item.callsite
|
|
278
|
+
? [item.callsite.line, item.callsite.column, undefined, item.callsite.sourceUrl, item.callsite.sourceContent]
|
|
279
|
+
: null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function withDebugSource(loc: DebugLoc, debug: DebugData): DebugLoc {
|
|
283
|
+
return loc[3] ? loc : [loc[0], loc[1], loc[2], debug.sourceUrl, debug.code];
|
|
284
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DEV_CONFIG } from '../../../config/config/dev';
|
|
2
|
+
import { traceError } from '../../../utils/trace';
|
|
3
|
+
import { BUILDER_STATE, ITEM_RUNTIME_DEV, ITEM_RUNTIME_DEV_PLUGIN, ITEM_RUNTIME_PROD } from '../const';
|
|
4
|
+
import type { BuilderData } from '../data';
|
|
5
|
+
import type { DebugData } from '../debug';
|
|
6
|
+
import type { ItemRuntimeType, StateItem, StateLookup } from '../state';
|
|
7
|
+
|
|
8
|
+
export function cloneData<Data extends BuilderData, Source extends BuilderData>(
|
|
9
|
+
data: Data,
|
|
10
|
+
source: Source,
|
|
11
|
+
debug: DebugData | null,
|
|
12
|
+
merge = true,
|
|
13
|
+
): [runtimeType: ItemRuntimeType, data: Data, items: StateItem[], lookup: StateLookup] {
|
|
14
|
+
const runtimeType = DEV_CONFIG.isDev
|
|
15
|
+
? (debug ? ITEM_RUNTIME_DEV_PLUGIN : ITEM_RUNTIME_DEV)
|
|
16
|
+
: ITEM_RUNTIME_PROD;
|
|
17
|
+
|
|
18
|
+
const state = data[BUILDER_STATE];
|
|
19
|
+
|
|
20
|
+
state.items = merge ? source[BUILDER_STATE].items.slice() : [];
|
|
21
|
+
|
|
22
|
+
state.lookup = Object.assign(
|
|
23
|
+
Object.create(null),
|
|
24
|
+
merge ? source[BUILDER_STATE].lookup : null,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const lookup = state.lookup!;
|
|
28
|
+
const items = state.items;
|
|
29
|
+
|
|
30
|
+
return [runtimeType, data, items, lookup];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function logInvalidData(message: string, data: object) {
|
|
34
|
+
console.log(traceError(message), 'data:', data);
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const SELECTOR_BASE = '';
|
|
2
|
+
export const SELECTOR_ARG = '$';
|
|
3
|
+
export const SELECTOR_ARGS = '$$';
|
|
4
|
+
export const SELECTOR_MERGE = '...';
|
|
5
|
+
export const SELECTOR_AT_RULE = '@';
|
|
6
|
+
export const SELECTOR_MEDIA = '@media';
|
|
7
|
+
export const SELECTOR_CONTAINER = '@container';
|
|
8
|
+
|
|
9
|
+
export function normalizeSelectorArg(arg: string) {
|
|
10
|
+
return arg.includes('\n') ? arg.replace(/\n/g, '') : arg;
|
|
11
|
+
}
|