@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,150 @@
|
|
|
1
|
+
import { getTokenOverrideValue } from '../../../atomic/token';
|
|
2
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
3
|
+
import { getStyleTokenId, isStyleTokenOverrideData, type StyleTokenOverride } from '../../../style/token';
|
|
4
|
+
import { hasOwn } from '../../../utils/object';
|
|
5
|
+
|
|
6
|
+
export type StyleTokenValues = {
|
|
7
|
+
ids: readonly string[];
|
|
8
|
+
values: readonly unknown[];
|
|
9
|
+
lookup: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type MutableTokenValues = {
|
|
13
|
+
ids: string[] | null;
|
|
14
|
+
values: unknown[] | null;
|
|
15
|
+
lookup: Record<string, unknown> | null;
|
|
16
|
+
index: Record<string, number> | null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function createMutableTokenValues(base: StyleTokenValues | null): MutableTokenValues {
|
|
20
|
+
return {
|
|
21
|
+
ids: base ? base.ids.slice() : null,
|
|
22
|
+
values: base ? base.values.slice() : null,
|
|
23
|
+
lookup: base ? { ...base.lookup } : null,
|
|
24
|
+
index: base ? createTokenIndexLookup(base.ids) : null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function addTokenOverride(values: MutableTokenValues, item: unknown) {
|
|
29
|
+
if (!isStyleTokenOverrideData(item)) return false;
|
|
30
|
+
|
|
31
|
+
const id = getStyleTokenId(item);
|
|
32
|
+
const value = getTokenOverrideValue(item, CSS_CONFIG.tokenNameFormat ?? null);
|
|
33
|
+
|
|
34
|
+
addTokenValue(values, id, value);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function addTokenValue(
|
|
39
|
+
values: MutableTokenValues,
|
|
40
|
+
id: string,
|
|
41
|
+
value: unknown,
|
|
42
|
+
) {
|
|
43
|
+
if (!values.ids) values.ids = [];
|
|
44
|
+
if (!values.values) values.values = [];
|
|
45
|
+
if (!values.lookup) values.lookup = Object.create(null);
|
|
46
|
+
if (!values.index) values.index = Object.create(null);
|
|
47
|
+
|
|
48
|
+
const ids = values.ids!;
|
|
49
|
+
const tokenValues = values.values!;
|
|
50
|
+
const lookup = values.lookup!;
|
|
51
|
+
const indexLookup = values.index!;
|
|
52
|
+
const index = indexLookup[id];
|
|
53
|
+
|
|
54
|
+
if (index === undefined) {
|
|
55
|
+
indexLookup[id] = ids.push(id) - 1;
|
|
56
|
+
tokenValues.push(value);
|
|
57
|
+
} else {
|
|
58
|
+
tokenValues[index] = value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
lookup[id] = value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function addTokenValues(
|
|
65
|
+
values: MutableTokenValues,
|
|
66
|
+
next: StyleTokenValues | null,
|
|
67
|
+
) {
|
|
68
|
+
if (!next) return;
|
|
69
|
+
|
|
70
|
+
for (let i = 0, len = next.ids.length; i < len; i++) {
|
|
71
|
+
addTokenValue(values, next.ids[i], next.values[i]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function addTokenOverrides(
|
|
76
|
+
values: MutableTokenValues,
|
|
77
|
+
overrides: readonly StyleTokenOverride[],
|
|
78
|
+
) {
|
|
79
|
+
for (let i = 0, len = overrides.length; i < len; i++) {
|
|
80
|
+
addTokenOverride(values, overrides[i]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function finishTokenValues(
|
|
85
|
+
base: StyleTokenValues | null,
|
|
86
|
+
values: MutableTokenValues,
|
|
87
|
+
) {
|
|
88
|
+
if (!values.ids || !values.values || !values.lookup) return null;
|
|
89
|
+
if (isSameTokenValues(base, values.ids, values.values)) return base;
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
ids: values.ids,
|
|
93
|
+
values: values.values,
|
|
94
|
+
lookup: values.lookup,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function mergeTokenValues(
|
|
99
|
+
base: StyleTokenValues | null,
|
|
100
|
+
next: StyleTokenValues | null,
|
|
101
|
+
): StyleTokenValues | null {
|
|
102
|
+
if (!next) return base;
|
|
103
|
+
if (!base) return next;
|
|
104
|
+
|
|
105
|
+
const values = createMutableTokenValues(base);
|
|
106
|
+
|
|
107
|
+
addTokenValues(values, next);
|
|
108
|
+
|
|
109
|
+
return finishTokenValues(base, values);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function mergeTokenOverrides(
|
|
113
|
+
base: StyleTokenValues | null,
|
|
114
|
+
overrides: readonly StyleTokenOverride[],
|
|
115
|
+
): StyleTokenValues | null {
|
|
116
|
+
if (!overrides.length) return base;
|
|
117
|
+
|
|
118
|
+
const values = createMutableTokenValues(base);
|
|
119
|
+
|
|
120
|
+
addTokenOverrides(values, overrides);
|
|
121
|
+
|
|
122
|
+
return finishTokenValues(base, values);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function createTokenIndexLookup(ids: readonly string[]) {
|
|
126
|
+
const lookup: Record<string, number> = Object.create(null);
|
|
127
|
+
|
|
128
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
129
|
+
lookup[ids[i]] = i;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return lookup;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function isSameTokenValues(
|
|
136
|
+
base: StyleTokenValues | null,
|
|
137
|
+
ids: readonly string[],
|
|
138
|
+
values: readonly unknown[],
|
|
139
|
+
) {
|
|
140
|
+
if (!base || base.ids.length !== ids.length) return false;
|
|
141
|
+
|
|
142
|
+
const baseLookup = base.lookup;
|
|
143
|
+
|
|
144
|
+
for (let i = 0, len = ids.length; i < len; i++) {
|
|
145
|
+
if (!hasOwn(baseLookup, ids[i])) return false;
|
|
146
|
+
if (baseLookup[ids[i]] !== values[i]) return false;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type CacheTreeNode<Key, Value> = {
|
|
2
|
+
children: Map<Key, CacheTreeNode<Key, Value>>;
|
|
3
|
+
value: Value;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type WeakCacheTreeNode<Key extends object, Value> = {
|
|
7
|
+
children: WeakMap<Key, WeakCacheTreeNode<Key, Value>>;
|
|
8
|
+
value: Value;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function createCacheTreeNode<Key, Value>(
|
|
12
|
+
value: Value,
|
|
13
|
+
): CacheTreeNode<Key, Value> {
|
|
14
|
+
return {
|
|
15
|
+
children: new Map(),
|
|
16
|
+
value,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getCacheTreeChild<Key, Value>(
|
|
21
|
+
node: CacheTreeNode<Key, Value>,
|
|
22
|
+
key: Key,
|
|
23
|
+
createValue: () => Value,
|
|
24
|
+
) {
|
|
25
|
+
let child = node.children.get(key);
|
|
26
|
+
|
|
27
|
+
if (!child) {
|
|
28
|
+
child = createCacheTreeNode<Key, Value>(createValue());
|
|
29
|
+
node.children.set(key, child);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return child;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createWeakCacheTreeNode<Key extends object, Value>(
|
|
36
|
+
value: Value,
|
|
37
|
+
): WeakCacheTreeNode<Key, Value> {
|
|
38
|
+
return {
|
|
39
|
+
children: new WeakMap(),
|
|
40
|
+
value,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getWeakCacheTreeChild<Key extends object, Value>(
|
|
45
|
+
node: WeakCacheTreeNode<Key, Value>,
|
|
46
|
+
key: Key,
|
|
47
|
+
createValue: () => Value,
|
|
48
|
+
) {
|
|
49
|
+
let child = node.children.get(key);
|
|
50
|
+
|
|
51
|
+
if (!child) {
|
|
52
|
+
child = createWeakCacheTreeNode<Key, Value>(createValue());
|
|
53
|
+
node.children.set(key, child);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return child;
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function walkRecursiveItems(
|
|
2
|
+
root: unknown,
|
|
3
|
+
fn: (item: unknown) => void,
|
|
4
|
+
) {
|
|
5
|
+
if (!root) return;
|
|
6
|
+
|
|
7
|
+
const stack: unknown[] = [root];
|
|
8
|
+
|
|
9
|
+
while (stack.length > 0) {
|
|
10
|
+
const item = stack.pop();
|
|
11
|
+
|
|
12
|
+
if (!item) continue;
|
|
13
|
+
|
|
14
|
+
if (Array.isArray(item)) {
|
|
15
|
+
for (let i = item.length - 1; i >= 0; i--) {
|
|
16
|
+
stack.push(item[i]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fn(item);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { RecursiveArray } from '../../utils/type';
|
|
3
|
+
|
|
4
|
+
type Items<T = string> = T | false | null | undefined | RecursiveArray<T | false | null | undefined>;
|
|
5
|
+
|
|
6
|
+
export type ClassNameProps = {
|
|
7
|
+
className?: Items<string>;
|
|
8
|
+
style?: Items<CSSProperties>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ClassNameResult = {
|
|
12
|
+
className?: string | undefined;
|
|
13
|
+
style?: CSSProperties | undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function mergeClassName(className: Items<string>) {
|
|
17
|
+
if (!className) return undefined;
|
|
18
|
+
if (!Array.isArray(className)) return className as string;
|
|
19
|
+
|
|
20
|
+
let nextClassName = '';
|
|
21
|
+
|
|
22
|
+
const stack: unknown[] = [className];
|
|
23
|
+
|
|
24
|
+
while (stack.length) {
|
|
25
|
+
const item = stack.pop();
|
|
26
|
+
|
|
27
|
+
if (!item) continue;
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(item)) {
|
|
30
|
+
for (let index = item.length - 1; index >= 0; index--) {
|
|
31
|
+
stack.push(item[index]);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
nextClassName = nextClassName
|
|
35
|
+
? `${nextClassName} ${item}`
|
|
36
|
+
: item as string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return nextClassName || undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function mergeStyle(style: Items<CSSProperties>) {
|
|
44
|
+
if (!style) return undefined;
|
|
45
|
+
if (!Array.isArray(style)) return style as CSSProperties;
|
|
46
|
+
|
|
47
|
+
const nextStyle = {};
|
|
48
|
+
|
|
49
|
+
const stack: unknown[] = [style];
|
|
50
|
+
|
|
51
|
+
while (stack.length) {
|
|
52
|
+
const item = stack.pop();
|
|
53
|
+
|
|
54
|
+
if (!item) continue;
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(item)) {
|
|
57
|
+
for (let index = item.length - 1; index >= 0; index--) {
|
|
58
|
+
stack.push(item[index]);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
Object.assign(nextStyle, item);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return nextStyle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function mergeResolvedClassName(
|
|
69
|
+
result: ClassNameResult,
|
|
70
|
+
resolvedClassName: string,
|
|
71
|
+
) {
|
|
72
|
+
if (!resolvedClassName) return;
|
|
73
|
+
|
|
74
|
+
result.className = result.className
|
|
75
|
+
? result.className + ' ' + resolvedClassName
|
|
76
|
+
: resolvedClassName;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function mergeResolvedStyle(
|
|
80
|
+
result: ClassNameResult,
|
|
81
|
+
resolvedStyle: CSSProperties | undefined,
|
|
82
|
+
) {
|
|
83
|
+
if (!resolvedStyle) return;
|
|
84
|
+
|
|
85
|
+
result.style = result.style
|
|
86
|
+
? Object.assign({}, resolvedStyle, result.style)
|
|
87
|
+
: resolvedStyle;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createClassNameResult(
|
|
91
|
+
props: ClassNameProps = {},
|
|
92
|
+
): ClassNameResult {
|
|
93
|
+
return {
|
|
94
|
+
className: props.className ? mergeClassName(props.className) : undefined,
|
|
95
|
+
style: props.style ? mergeStyle(props.style) : undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function finishClassNameResult(result: ClassNameResult): ClassNameResult {
|
|
100
|
+
return result.className || result.style ? result : {};
|
|
101
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ScopeTargetData } from '../../builder/data';
|
|
2
|
+
import type { SlotData, StyleData } from '../../builder/data';
|
|
3
|
+
import { globalData } from '../../utils/global';
|
|
4
|
+
import { hasOwn } from '../../utils/object';
|
|
5
|
+
import type { ResolvedStyleItem } from './cache/item';
|
|
6
|
+
import type { StyleTokenValues } from './cache/tokenValues';
|
|
7
|
+
|
|
8
|
+
export type CombinedStyleMeta<Styles = unknown> = {
|
|
9
|
+
styles: Styles;
|
|
10
|
+
scopes: readonly ScopeTargetData[];
|
|
11
|
+
tokens: StyleTokenValues | null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type CombinedStyle<Styles = unknown> = InferData<Styles>;
|
|
15
|
+
|
|
16
|
+
export type CombinedStyleFieldGetter = (
|
|
17
|
+
meta: CombinedStyleMeta,
|
|
18
|
+
prop: string | symbol,
|
|
19
|
+
) => unknown;
|
|
20
|
+
|
|
21
|
+
type CombinedStyleTarget = CombinedStyleMeta & {
|
|
22
|
+
cache: Record<PropertyKey, unknown>;
|
|
23
|
+
getField: CombinedStyleFieldGetter;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const targets = globalData(
|
|
27
|
+
'runtime.combinedStyle.targets',
|
|
28
|
+
() => new WeakMap<object, CombinedStyleTarget>(),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export function createCombinedStyle<Styles extends object>(
|
|
32
|
+
meta: CombinedStyleMeta<Styles>,
|
|
33
|
+
getField: CombinedStyleFieldGetter,
|
|
34
|
+
): CombinedStyle<Styles> {
|
|
35
|
+
const target: CombinedStyleTarget = {
|
|
36
|
+
...meta,
|
|
37
|
+
cache: Object.create(null),
|
|
38
|
+
getField,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const proxyTarget = {};
|
|
42
|
+
|
|
43
|
+
const proxy = new Proxy(proxyTarget, handlers) as CombinedStyle<Styles>;
|
|
44
|
+
|
|
45
|
+
targets.set(proxyTarget, target);
|
|
46
|
+
targets.set(proxy, target);
|
|
47
|
+
|
|
48
|
+
return proxy;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isCombinedStyle<Styles = unknown>(value: unknown): value is CombinedStyle<Styles> {
|
|
52
|
+
return !!value && typeof value === 'object' && targets.has(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getCombinedStyleStyles<Styles>(style: CombinedStyle<Styles>) {
|
|
56
|
+
return getTarget(style).styles as Styles;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getCombinedStyleScopes(style: CombinedStyle) {
|
|
60
|
+
return getTarget(style).scopes;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getCombinedStyleTokens(style: CombinedStyle) {
|
|
64
|
+
return getTarget(style).tokens;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handlers: ProxyHandler<object> = {
|
|
68
|
+
get(proxy, prop) {
|
|
69
|
+
const target = getTarget(proxy);
|
|
70
|
+
|
|
71
|
+
if (hasOwn(target.cache, prop)) {
|
|
72
|
+
return target.cache[prop];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const value = target.getField(target, prop);
|
|
76
|
+
|
|
77
|
+
if (value && typeof value === 'object') {
|
|
78
|
+
target.cache[prop] = value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return value;
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function getTarget(value: object): CombinedStyleTarget {
|
|
86
|
+
const target = targets.get(value);
|
|
87
|
+
|
|
88
|
+
if (!target) {
|
|
89
|
+
throw new Error('[fluentic-style] Expected combined style.');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return target;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type InferValue<Value> = Value extends StyleData | SlotData ? ResolvedStyleItem<Value>
|
|
96
|
+
: Value extends object ? CombinedStyle<any>
|
|
97
|
+
: Value;
|
|
98
|
+
|
|
99
|
+
type InferData<Styles> = unknown extends Styles ? {}
|
|
100
|
+
: Styles extends object ? { [P in keyof Styles]: InferValue<Styles[P]>; }
|
|
101
|
+
: {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TransformElement } from '../../jsx/utils';
|
|
2
|
+
import { hasOwn } from '../../utils/object';
|
|
3
|
+
import type { RuntimeStyleAttributes, StyleProp } from '../types';
|
|
4
|
+
import type { ClassNameProps, ClassNameResult } from './className';
|
|
5
|
+
import { createElementMarkerClassName, splitElementMarkerStyleProp } from './elementMarker';
|
|
6
|
+
|
|
7
|
+
export function createTransformElement(
|
|
8
|
+
getClassName: (styleProp: StyleProp, props?: ClassNameProps) => ClassNameResult,
|
|
9
|
+
): TransformElement {
|
|
10
|
+
return ({ type, props }) => {
|
|
11
|
+
if (!props || typeof type !== 'string') return { type, props };
|
|
12
|
+
if (!hasOwn(props as object, 'css')) return { type, props };
|
|
13
|
+
|
|
14
|
+
const { css, ...rest } = props as RuntimeStyleAttributes & ClassNameProps;
|
|
15
|
+
|
|
16
|
+
if (!css) return { type, props: rest };
|
|
17
|
+
|
|
18
|
+
const marker = splitElementMarkerStyleProp(css);
|
|
19
|
+
|
|
20
|
+
if (marker.styleProp) {
|
|
21
|
+
Object.assign(rest, getClassName(marker.styleProp, rest));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
prependClassName(rest, createElementMarkerClassName(marker.debug));
|
|
25
|
+
|
|
26
|
+
return { type, props: rest };
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function prependClassName(
|
|
31
|
+
props: ClassNameProps,
|
|
32
|
+
className: string | null,
|
|
33
|
+
) {
|
|
34
|
+
if (!className) return;
|
|
35
|
+
|
|
36
|
+
props.className = props.className
|
|
37
|
+
? `${className} ${props.className}`
|
|
38
|
+
: className;
|
|
39
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { getElementClassName } from '../../atomic/element';
|
|
2
|
+
import { CSS_CONFIG } from '../../config/config/css';
|
|
3
|
+
import { DEV_CONFIG } from '../../config/config/dev';
|
|
4
|
+
import type { ElementClassNameFormat } from '../../config/types';
|
|
5
|
+
import type { SheetCallsite, SheetRule } from '../../sheet';
|
|
6
|
+
import { createDevSheet } from '../../sheet';
|
|
7
|
+
import { globalData } from '../../utils/global';
|
|
8
|
+
import { createElementMarkerRule } from '../sheet/element';
|
|
9
|
+
import type { ElementDebugData } from '../types';
|
|
10
|
+
export { type ElementMarkerStyleProp, isElementDebugData, splitElementMarkerStyleProp } from './elementMarkerData';
|
|
11
|
+
|
|
12
|
+
type ElementMarkerSheet = {
|
|
13
|
+
document: Document;
|
|
14
|
+
sheet: ReturnType<typeof createDevSheet>;
|
|
15
|
+
classNames: Set<string>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ELEMENT_MARKER_SHEET = globalData<{ sheet: ElementMarkerSheet | null; }>(
|
|
19
|
+
'runtime.elementMarkerSheet',
|
|
20
|
+
() => ({ sheet: null }),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export function createElementMarkerClassName(
|
|
24
|
+
debug: ElementDebugData | undefined,
|
|
25
|
+
) {
|
|
26
|
+
if (!DEV_CONFIG.isDev || !DEV_CONFIG.isElementClassNameEnabled) return null;
|
|
27
|
+
|
|
28
|
+
const marker = createElementMarkerRuleFromDebug(debug);
|
|
29
|
+
if (!marker) return null;
|
|
30
|
+
|
|
31
|
+
insertElementMarkerSheetRule(marker.rule);
|
|
32
|
+
|
|
33
|
+
return marker.className;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function insertElementMarkerSheetRule(
|
|
37
|
+
rule: SheetRule,
|
|
38
|
+
documentOverride?: Document,
|
|
39
|
+
) {
|
|
40
|
+
const document = documentOverride ?? (
|
|
41
|
+
typeof globalThis.document === 'undefined' ? null : globalThis.document
|
|
42
|
+
);
|
|
43
|
+
if (!document) return;
|
|
44
|
+
|
|
45
|
+
const className = getElementMarkerClassNameFromRule(rule);
|
|
46
|
+
if (!className) return;
|
|
47
|
+
|
|
48
|
+
const sheet = getElementMarkerSheet(document);
|
|
49
|
+
|
|
50
|
+
sheet.classNames.add(className);
|
|
51
|
+
sheet.sheet.insert(rule);
|
|
52
|
+
sheet.sheet.flush();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createElementMarkerRuleFromDebug(
|
|
56
|
+
debug: ElementDebugData | undefined,
|
|
57
|
+
) {
|
|
58
|
+
const callsite = getElementCallsite(debug);
|
|
59
|
+
if (!callsite) return null;
|
|
60
|
+
|
|
61
|
+
const className = getElementClassName(
|
|
62
|
+
debug?.label,
|
|
63
|
+
getElementCallsiteId(callsite),
|
|
64
|
+
CSS_CONFIG.elementClassNameFormat as ElementClassNameFormat | undefined || null,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
className,
|
|
69
|
+
rule: createElementMarkerRule(className, callsite),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isElementMarkerRule(rule: SheetRule) {
|
|
74
|
+
return typeof rule.key === 'string' && rule.key.startsWith('element-marker:');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function getElementMarkerClassNameFromRule(rule: SheetRule) {
|
|
78
|
+
if (!isElementMarkerRule(rule)) return null;
|
|
79
|
+
|
|
80
|
+
return rule.key!.slice('element-marker:'.length) || null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getElementMarkerSheet(document: Document) {
|
|
84
|
+
const current = ELEMENT_MARKER_SHEET.sheet;
|
|
85
|
+
if (current?.document === document) return current;
|
|
86
|
+
|
|
87
|
+
const sheet: ElementMarkerSheet = {
|
|
88
|
+
document,
|
|
89
|
+
sheet: createDevSheet({
|
|
90
|
+
document,
|
|
91
|
+
tagName: 'element-marker',
|
|
92
|
+
top: true,
|
|
93
|
+
}),
|
|
94
|
+
classNames: new Set(),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
ELEMENT_MARKER_SHEET.sheet = sheet;
|
|
98
|
+
|
|
99
|
+
return sheet;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function clearElementMarkers(documentOverride?: Document | null) {
|
|
103
|
+
const sheet = ELEMENT_MARKER_SHEET.sheet;
|
|
104
|
+
const document = documentOverride ?? sheet?.document ?? (
|
|
105
|
+
typeof globalThis.document === 'undefined' ? null : globalThis.document
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if (!sheet) {
|
|
109
|
+
removeElementMarkerTags(document);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
stripElementMarkerClasses(document, sheet.classNames);
|
|
114
|
+
sheet.sheet.destroy?.();
|
|
115
|
+
sheet.classNames.clear();
|
|
116
|
+
ELEMENT_MARKER_SHEET.sheet = null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function removeElementMarkerTags(document: Document | null | undefined) {
|
|
120
|
+
if (!document) return;
|
|
121
|
+
|
|
122
|
+
const head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
|
|
123
|
+
const nodes = Array.from(head.childNodes);
|
|
124
|
+
|
|
125
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
126
|
+
const node = nodes[i] as HTMLElement;
|
|
127
|
+
|
|
128
|
+
if (typeof node.getAttribute !== 'function') continue;
|
|
129
|
+
const sheetName = node.getAttribute('data-css-sheet');
|
|
130
|
+
if (sheetName !== 'element-marker' && !sheetName?.startsWith('element-marker ')) continue;
|
|
131
|
+
|
|
132
|
+
node.parentNode?.removeChild(node);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function stripElementMarkerClasses(
|
|
137
|
+
document: Document | null | undefined,
|
|
138
|
+
classNames: ReadonlySet<string>,
|
|
139
|
+
) {
|
|
140
|
+
if (!document || !classNames.size) return;
|
|
141
|
+
if (typeof document.querySelectorAll !== 'function') return;
|
|
142
|
+
|
|
143
|
+
const nodes = document.querySelectorAll('[class]');
|
|
144
|
+
|
|
145
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
146
|
+
stripElementClassNames(nodes[i] as HTMLElement, classNames);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function stripElementClassNames(
|
|
151
|
+
element: HTMLElement,
|
|
152
|
+
classNames: ReadonlySet<string>,
|
|
153
|
+
) {
|
|
154
|
+
if (element.classList) {
|
|
155
|
+
classNames.forEach((className) => element.classList.remove(className));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const value = element.getAttribute('class');
|
|
160
|
+
if (!value) return;
|
|
161
|
+
|
|
162
|
+
const next = value.split(/\s+/).filter((className) => !classNames.has(className)).join(' ');
|
|
163
|
+
|
|
164
|
+
if (next) {
|
|
165
|
+
element.setAttribute('class', next);
|
|
166
|
+
} else {
|
|
167
|
+
element.removeAttribute('class');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function getElementCallsite(
|
|
172
|
+
debug: ElementDebugData | undefined,
|
|
173
|
+
): SheetCallsite | null {
|
|
174
|
+
if (debug) {
|
|
175
|
+
return {
|
|
176
|
+
filePath: debug.sourceUrl,
|
|
177
|
+
sourceUrl: debug.sourceUrl,
|
|
178
|
+
sourceContent: debug.code,
|
|
179
|
+
line: debug.loc[0],
|
|
180
|
+
column: debug.loc[1],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getElementCallsiteId(callsite: SheetCallsite) {
|
|
188
|
+
return `${callsite.filePath}\n${callsite.line}:${callsite.column}`;
|
|
189
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ElementDebugData, StyleProp } from '../types';
|
|
2
|
+
|
|
3
|
+
export type ElementMarkerStyleProp = {
|
|
4
|
+
debug: ElementDebugData | undefined;
|
|
5
|
+
styleProp: StyleProp | undefined;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function splitElementMarkerStyleProp(styleProp: StyleProp): ElementMarkerStyleProp {
|
|
9
|
+
if (isElementDebugData(styleProp)) {
|
|
10
|
+
return { debug: styleProp, styleProp: undefined };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!Array.isArray(styleProp) || !isElementDebugData(styleProp[0])) {
|
|
14
|
+
return { debug: undefined, styleProp };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
debug: styleProp[0],
|
|
19
|
+
styleProp: styleProp.length > 2 ? styleProp.slice(1) : styleProp[1] as StyleProp | undefined,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isElementDebugData(value: unknown): value is ElementDebugData {
|
|
24
|
+
if (!value || typeof value !== 'object') return false;
|
|
25
|
+
|
|
26
|
+
return (value as Partial<ElementDebugData>).$$elementDebug === true;
|
|
27
|
+
}
|