@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,102 @@
|
|
|
1
|
+
import type { ScopeTargetData } from '../../../builder/data/data';
|
|
2
|
+
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../../builder/extract/withTokens';
|
|
3
|
+
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
4
|
+
import type { Falsy, StyleItem } from '../../types';
|
|
5
|
+
import { type CombinedStyle, getCombinedStyleScopes, getCombinedStyleStyles, isCombinedStyle } from '../combinedStyle';
|
|
6
|
+
import { createCombinedStyleTokenWrapper, getStyleTokenValues } from './item';
|
|
7
|
+
import { getCachedTokenWrapper, getCombinedStylePool } from './pool';
|
|
8
|
+
import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues } from './tokenValues';
|
|
9
|
+
|
|
10
|
+
export type CombinedStyleArg<T extends object> =
|
|
11
|
+
| Falsy
|
|
12
|
+
| StyleItem
|
|
13
|
+
| CombinedStyle<T>
|
|
14
|
+
| readonly CombinedStyleArg<T>[];
|
|
15
|
+
|
|
16
|
+
type NormalizedStyleItems = {
|
|
17
|
+
inheritedScopes: ScopeTargetData[];
|
|
18
|
+
items: StyleItem[];
|
|
19
|
+
tokens: StyleTokenValues | null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function getCombinedStyle<T extends object>(
|
|
23
|
+
styles: T,
|
|
24
|
+
args: readonly CombinedStyleArg<T>[],
|
|
25
|
+
): CombinedStyle<T> {
|
|
26
|
+
const normalized = normalizeStyleItems(styles, args);
|
|
27
|
+
const result = getCombinedStylePool().get(
|
|
28
|
+
styles,
|
|
29
|
+
normalized.inheritedScopes,
|
|
30
|
+
normalized.items,
|
|
31
|
+
normalized.tokens,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return result.tokens
|
|
35
|
+
? getCachedTokenWrapper(
|
|
36
|
+
result.tokenCache,
|
|
37
|
+
result.tokens,
|
|
38
|
+
() => createCombinedStyleTokenWrapper(result.style, result.tokens!),
|
|
39
|
+
)
|
|
40
|
+
: result.style;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function normalizeStyleItems<T extends object>(
|
|
44
|
+
styles: T,
|
|
45
|
+
args: readonly CombinedStyleArg<T>[],
|
|
46
|
+
): NormalizedStyleItems {
|
|
47
|
+
const result: NormalizedStyleItems = {
|
|
48
|
+
inheritedScopes: [],
|
|
49
|
+
items: [],
|
|
50
|
+
tokens: null,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
for (let i = 0, len = args.length; i < len; i++) {
|
|
54
|
+
collectStyleArg(styles, args[i], result);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function collectStyleArg<T extends object>(
|
|
61
|
+
styles: T,
|
|
62
|
+
arg: CombinedStyleArg<T>,
|
|
63
|
+
result: NormalizedStyleItems,
|
|
64
|
+
) {
|
|
65
|
+
if (!arg) return;
|
|
66
|
+
|
|
67
|
+
if (Array.isArray(arg)) {
|
|
68
|
+
for (let i = 0, len = arg.length; i < len; i++) {
|
|
69
|
+
collectStyleArg(styles, arg[i], result);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(arg)) {
|
|
76
|
+
const bound = getExtractedTokenBoundData(arg);
|
|
77
|
+
|
|
78
|
+
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens);
|
|
79
|
+
|
|
80
|
+
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isCombinedStyle<T>(arg)) {
|
|
85
|
+
if (getCombinedStyleStyles(arg) !== styles) {
|
|
86
|
+
throw new TypeError(
|
|
87
|
+
'[fluentic-style] combineStyle can only carry a combined style created from the same styles object.',
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const scopes = getCombinedStyleScopes(arg);
|
|
92
|
+
|
|
93
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
94
|
+
result.inheritedScopes.push(scopes[i]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
result.tokens = mergeTokenValues(result.tokens, getStyleTokenValues(arg));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
result.items.push(arg as StyleItem);
|
|
102
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type CombinedStyleArg, getCombinedStyle } from './combine';
|
|
2
|
+
export type { ResolvedStyleItem } from './item';
|
|
3
|
+
export { type CombinedStylePool, createCombinedStylePool } from './pool';
|
|
4
|
+
export { type ResolvedStylePropRuntime, resolveStyleProp } from './prop';
|
|
5
|
+
export type { StyleTokenValues } from './tokenValues';
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { getScopeClassName } from '../../../atomic/className';
|
|
2
|
+
import { BUILDER_STATE, BUILDER_TYPE_SCOPE, BUILDER_TYPE_SLOT } from '../../../builder/data/const';
|
|
3
|
+
import type { ScopeTargetData, SlotData, StyleData } from '../../../builder/data/data';
|
|
4
|
+
import {
|
|
5
|
+
getScopeTargetScope,
|
|
6
|
+
getScopeTargetSlotId,
|
|
7
|
+
getSlotId,
|
|
8
|
+
isSlotData,
|
|
9
|
+
isStyleData,
|
|
10
|
+
} from '../../../builder/data/is';
|
|
11
|
+
import type { StateItem } from '../../../builder/data/state';
|
|
12
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
13
|
+
import { isStyleTokenOverrideData } from '../../../style/token';
|
|
14
|
+
import { globalData } from '../../../utils/global';
|
|
15
|
+
import {
|
|
16
|
+
type CombinedStyle,
|
|
17
|
+
type CombinedStyleFieldGetter,
|
|
18
|
+
createCombinedStyle,
|
|
19
|
+
getCombinedStyleScopes,
|
|
20
|
+
getCombinedStyleStyles,
|
|
21
|
+
getCombinedStyleTokens,
|
|
22
|
+
isCombinedStyle,
|
|
23
|
+
} from '../combinedStyle';
|
|
24
|
+
import {
|
|
25
|
+
getResolvedStyleItemTokenValues,
|
|
26
|
+
isResolvedStyleItem as isResolvedStyleItemMarked,
|
|
27
|
+
markResolvedStyleItem,
|
|
28
|
+
setResolvedStyleItemTokenValues,
|
|
29
|
+
} from './resolvedItem';
|
|
30
|
+
import type { StyleTokenValues } from './tokenValues';
|
|
31
|
+
|
|
32
|
+
export type ResolvedStyleItem<Data = unknown> = {
|
|
33
|
+
data: Data;
|
|
34
|
+
items: StateItem[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const directStyleItemCache = globalData(
|
|
38
|
+
'runtime.directStyleItemCache',
|
|
39
|
+
() => new WeakMap<StyleData | SlotData, ResolvedStyleItem>(),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export function isResolvedStyleItem<T>(value: unknown): value is ResolvedStyleItem<T> {
|
|
43
|
+
return isResolvedStyleItemMarked(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function createResolvedStyleItem<Data extends StyleData | SlotData>(
|
|
47
|
+
data: Data,
|
|
48
|
+
scopes: readonly ScopeTargetData[],
|
|
49
|
+
tokens: StyleTokenValues | null = null,
|
|
50
|
+
): ResolvedStyleItem<Data> {
|
|
51
|
+
return createStyleItem({
|
|
52
|
+
data,
|
|
53
|
+
items: resolveItems(data, scopes),
|
|
54
|
+
}, tokens);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createResolvedStyleItemFromItems<Data>(
|
|
58
|
+
item: ResolvedStyleItem<Data>,
|
|
59
|
+
tokens: StyleTokenValues | null,
|
|
60
|
+
): ResolvedStyleItem<Data> {
|
|
61
|
+
return createStyleItem({
|
|
62
|
+
data: item.data,
|
|
63
|
+
items: item.items,
|
|
64
|
+
}, tokens);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getDirectStyleItem(item: StyleData | SlotData) {
|
|
68
|
+
let cached = directStyleItemCache.get(item);
|
|
69
|
+
|
|
70
|
+
if (!cached) {
|
|
71
|
+
cached = createResolvedStyleItem(item, []);
|
|
72
|
+
directStyleItemCache.set(item, cached);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return cached;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function getStyleTokenValues(value: CombinedStyle | ResolvedStyleItem) {
|
|
79
|
+
if (isCombinedStyle(value)) return getCombinedStyleTokens(value);
|
|
80
|
+
|
|
81
|
+
return getResolvedStyleItemTokenValues(value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function createCombinedStyleFacade<T extends object>(
|
|
85
|
+
styles: T,
|
|
86
|
+
scopes: readonly ScopeTargetData[],
|
|
87
|
+
): CombinedStyle<T> {
|
|
88
|
+
return createCombinedStyle(
|
|
89
|
+
{
|
|
90
|
+
styles,
|
|
91
|
+
scopes,
|
|
92
|
+
tokens: null,
|
|
93
|
+
},
|
|
94
|
+
getStyleField,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function createCombinedStyleTokenWrapper<T extends object>(
|
|
99
|
+
style: CombinedStyle<T>,
|
|
100
|
+
tokens: StyleTokenValues,
|
|
101
|
+
): CombinedStyle<T> {
|
|
102
|
+
return createCombinedStyle(
|
|
103
|
+
{
|
|
104
|
+
styles: getCombinedStyleStyles(style),
|
|
105
|
+
scopes: getCombinedStyleScopes(style),
|
|
106
|
+
tokens,
|
|
107
|
+
},
|
|
108
|
+
getTokenField(style),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const getStyleField: CombinedStyleFieldGetter = (meta, prop) => {
|
|
113
|
+
const value = (meta.styles as any)?.[prop] ?? null;
|
|
114
|
+
|
|
115
|
+
if (isStyleData(value) || isSlotData(value)) {
|
|
116
|
+
return createResolvedStyleItem(value, meta.scopes);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (value && typeof value === 'object') {
|
|
120
|
+
return createCombinedStyleFacade(value, meta.scopes);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return value;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function getTokenField(base: CombinedStyle): CombinedStyleFieldGetter {
|
|
127
|
+
return (meta, prop) => {
|
|
128
|
+
const value = (base as any)?.[prop] ?? null;
|
|
129
|
+
|
|
130
|
+
if (isResolvedStyleItem(value)) {
|
|
131
|
+
return createStyleItem({
|
|
132
|
+
data: value.data,
|
|
133
|
+
items: value.items,
|
|
134
|
+
}, meta.tokens);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isCombinedStyle(value)) {
|
|
138
|
+
return createCombinedStyleTokenWrapper(value as CombinedStyle<object>, meta.tokens!);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return value;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function createStyleItem<Data>(
|
|
146
|
+
item: ResolvedStyleItem<Data>,
|
|
147
|
+
tokens: StyleTokenValues | null = null,
|
|
148
|
+
): ResolvedStyleItem<Data> {
|
|
149
|
+
markResolvedStyleItem(item);
|
|
150
|
+
if (tokens) setResolvedStyleItemTokenValues(item, tokens);
|
|
151
|
+
return item;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function resolveItems(
|
|
155
|
+
data: StyleData | SlotData,
|
|
156
|
+
scopes: readonly ScopeTargetData[],
|
|
157
|
+
) {
|
|
158
|
+
const items: StateItem[] = [];
|
|
159
|
+
|
|
160
|
+
const state = data[BUILDER_STATE];
|
|
161
|
+
const stateItems = state?.items ?? [];
|
|
162
|
+
const slotId = isSlotData(data) ? getSlotId(data) : null;
|
|
163
|
+
|
|
164
|
+
for (let i = 0, len = stateItems.length; i < len; i++) {
|
|
165
|
+
const item = stateItems[i];
|
|
166
|
+
|
|
167
|
+
if (Array.isArray(item)) {
|
|
168
|
+
items.push(item);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
173
|
+
|
|
174
|
+
if (slotId && item.type !== BUILDER_TYPE_SLOT) continue;
|
|
175
|
+
|
|
176
|
+
items.push(item);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!slotId) return items;
|
|
180
|
+
|
|
181
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
182
|
+
const boundScope = scopes[i];
|
|
183
|
+
|
|
184
|
+
const scope = getScopeTargetScope(boundScope);
|
|
185
|
+
if (!scope) continue;
|
|
186
|
+
|
|
187
|
+
const scopeItems = scope[BUILDER_STATE]?.items;
|
|
188
|
+
if (!scopeItems) continue;
|
|
189
|
+
|
|
190
|
+
const targetSlotId = getScopeTargetSlotId(boundScope);
|
|
191
|
+
|
|
192
|
+
for (let j = 0, len = scopeItems.length; j < len; j++) {
|
|
193
|
+
const item = scopeItems[j];
|
|
194
|
+
|
|
195
|
+
if (Array.isArray(item)) {
|
|
196
|
+
if (item[1] === slotId) {
|
|
197
|
+
items.push(item);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const hasParentSelector = isExtractedScopeParentMarker(item[4]) || isExtractedScopeParentMarker(item[5]);
|
|
201
|
+
if (targetSlotId === slotId && hasParentSelector) {
|
|
202
|
+
items.push(getScopeParentItem(String(item[3])));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (isStyleTokenOverrideData(item)) continue;
|
|
209
|
+
|
|
210
|
+
if (item.type !== BUILDER_TYPE_SCOPE) continue;
|
|
211
|
+
|
|
212
|
+
if (item.slotId === slotId) items.push(item);
|
|
213
|
+
|
|
214
|
+
if (item.parentSelector && targetSlotId === slotId) {
|
|
215
|
+
items.push(getScopeParentItem(item.className));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return items;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function getScopeParentItem(className: string): StateItem {
|
|
224
|
+
const parentClassName = getScopeClassName(className, CSS_CONFIG.scopeClassNameFormat || null);
|
|
225
|
+
|
|
226
|
+
return [parentClassName, parentClassName];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function isExtractedScopeParentMarker(value: unknown) {
|
|
230
|
+
return value === 1 || value === true;
|
|
231
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
2
|
+
import type { ScopeData, ScopeTargetData } from '../../../builder/data/data';
|
|
3
|
+
import { getScopeTargetScope, getScopeTargetSlotId, isScopeTargetData } from '../../../builder/data/is';
|
|
4
|
+
import { CSS_CONFIG } from '../../../config/config/css';
|
|
5
|
+
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
6
|
+
import type { Falsy, StyleItem } from '../../types';
|
|
7
|
+
import type { CombinedStyle } from '../combinedStyle';
|
|
8
|
+
import { createCombinedStyleFacade } from './item';
|
|
9
|
+
import {
|
|
10
|
+
addTokenOverride,
|
|
11
|
+
addTokenValues,
|
|
12
|
+
createMutableTokenValues,
|
|
13
|
+
finishTokenValues,
|
|
14
|
+
type StyleTokenValues,
|
|
15
|
+
} from './tokenValues';
|
|
16
|
+
import { type CacheTreeNode, createCacheTreeNode, getCacheTreeChild } from './utils/tree';
|
|
17
|
+
|
|
18
|
+
export type CombinedStylePool = {
|
|
19
|
+
get<Styles extends object>(
|
|
20
|
+
styles: Styles,
|
|
21
|
+
inheritedScopes: readonly (ScopeTargetData<any> | Falsy)[],
|
|
22
|
+
items: readonly (StyleItem | Falsy)[],
|
|
23
|
+
prevTokensData?: StyleTokenValues | null,
|
|
24
|
+
): CombinedStylePoolResult<Styles>;
|
|
25
|
+
cleanup(now?: number): void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type CombinedStylePoolResult<Styles = unknown> = {
|
|
29
|
+
style: CombinedStyle<Styles>;
|
|
30
|
+
tokenCache: TokenWrapperCache | null;
|
|
31
|
+
tokens: StyleTokenValues | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type TokenWrapperCache = Map<string, CombinedStyle>;
|
|
35
|
+
|
|
36
|
+
type PoolValue = {
|
|
37
|
+
style: CombinedStyle | null;
|
|
38
|
+
tokenCache: TokenWrapperCache | null;
|
|
39
|
+
h: boolean;
|
|
40
|
+
s: StyleTokenValues | null;
|
|
41
|
+
f: typeof CSS_CONFIG.tokenNameFormat;
|
|
42
|
+
updatedAt: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type PoolNode = CacheTreeNode<unknown, PoolValue>;
|
|
46
|
+
|
|
47
|
+
const DEFAULT_TTL = 1000 * 60 * 5;
|
|
48
|
+
const TOKEN_WRAPPER_CACHE_LIMIT = 32;
|
|
49
|
+
|
|
50
|
+
let configuredPool: CombinedStylePool | null = null;
|
|
51
|
+
let configuredPoolTTL = -1;
|
|
52
|
+
|
|
53
|
+
export function getCombinedStylePool() {
|
|
54
|
+
const ttl = RUNTIME_CONFIG.runtimeCacheTTL;
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
!configuredPool ||
|
|
58
|
+
configuredPoolTTL !== ttl
|
|
59
|
+
) {
|
|
60
|
+
configuredPool = createCombinedStylePool(ttl);
|
|
61
|
+
configuredPoolTTL = ttl;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return configuredPool;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createCombinedStylePool(ttl = DEFAULT_TTL): CombinedStylePool {
|
|
68
|
+
const root = createPoolNode();
|
|
69
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
get(styles, inheritedScopes, items, prevTokensData = null) {
|
|
73
|
+
if (ttl === 0) {
|
|
74
|
+
const collected = collectItems(null, items, prevTokensData);
|
|
75
|
+
const allScopes = concatScopes(inheritedScopes, collected.scopes);
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
style: createCombinedStyleFacade(styles, allScopes) as CombinedStyle<typeof styles>,
|
|
79
|
+
tokenCache: null,
|
|
80
|
+
tokens: collected.tokens,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
let node = getPoolChild(root, styles);
|
|
86
|
+
|
|
87
|
+
node = walkScopes(node, inheritedScopes);
|
|
88
|
+
|
|
89
|
+
const collected = collectItems(node, items, prevTokensData);
|
|
90
|
+
node = collected.node ?? node;
|
|
91
|
+
node.value.updatedAt = now;
|
|
92
|
+
|
|
93
|
+
if (node.value.style) {
|
|
94
|
+
scheduleCleanup();
|
|
95
|
+
return {
|
|
96
|
+
style: node.value.style as CombinedStyle<typeof styles>,
|
|
97
|
+
tokenCache: collected.tokens ? getTokenWrapperCache(node.value) : null,
|
|
98
|
+
tokens: collected.tokens,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const allScopes = concatScopes(inheritedScopes, collected.scopes);
|
|
103
|
+
|
|
104
|
+
node.value.style = createCombinedStyleFacade(styles, allScopes);
|
|
105
|
+
|
|
106
|
+
scheduleCleanup();
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
style: node.value.style as CombinedStyle<typeof styles>,
|
|
110
|
+
tokenCache: collected.tokens ? getTokenWrapperCache(node.value) : null,
|
|
111
|
+
tokens: collected.tokens,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
cleanup(now = Date.now()) {
|
|
116
|
+
cleanupNode(root, now, ttl);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function scheduleCleanup() {
|
|
121
|
+
if (timer) return;
|
|
122
|
+
|
|
123
|
+
timer = setTimeout(() => {
|
|
124
|
+
timer = null;
|
|
125
|
+
cleanupNode(root, Date.now(), ttl);
|
|
126
|
+
}, Math.max(ttl, 0));
|
|
127
|
+
|
|
128
|
+
(timer as { unref?: () => void; }).unref?.();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function getCachedTokenWrapper<T extends CombinedStyle>(
|
|
133
|
+
cache: TokenWrapperCache | null,
|
|
134
|
+
tokens: StyleTokenValues,
|
|
135
|
+
create: () => T,
|
|
136
|
+
): T {
|
|
137
|
+
if (!cache) {
|
|
138
|
+
return create();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const key = getTokenWrapperCacheKey(tokens);
|
|
142
|
+
const cached = cache.get(key) as T | undefined;
|
|
143
|
+
|
|
144
|
+
if (cached) {
|
|
145
|
+
cache.delete(key);
|
|
146
|
+
cache.set(key, cached);
|
|
147
|
+
return cached;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const value = create();
|
|
151
|
+
cache.set(key, value);
|
|
152
|
+
|
|
153
|
+
if (cache.size > TOKEN_WRAPPER_CACHE_LIMIT) {
|
|
154
|
+
const oldest = cache.keys().next().value;
|
|
155
|
+
if (oldest !== undefined) cache.delete(oldest);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getTokenWrapperCache(node: PoolValue) {
|
|
162
|
+
if (!node.tokenCache) node.tokenCache = new Map();
|
|
163
|
+
return node.tokenCache;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function getTokenWrapperCacheKey(tokens: StyleTokenValues) {
|
|
167
|
+
return tokens.ids.join('\x1f') + '\x1e' + tokens.values.join('\x1f');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function collectItems(
|
|
171
|
+
node: PoolNode | null,
|
|
172
|
+
items: readonly (StyleItem | Falsy)[],
|
|
173
|
+
prevTokensData: StyleTokenValues | null,
|
|
174
|
+
) {
|
|
175
|
+
const scopes: ScopeTargetData[] = [];
|
|
176
|
+
const tokens = createMutableTokenValues(prevTokensData);
|
|
177
|
+
let currentNode = node;
|
|
178
|
+
|
|
179
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
180
|
+
const item = items[i];
|
|
181
|
+
|
|
182
|
+
if (addTokenOverride(tokens, item)) continue;
|
|
183
|
+
|
|
184
|
+
if (isScopeTargetData(item)) {
|
|
185
|
+
scopes.push(item);
|
|
186
|
+
currentNode = currentNode ? walkScope(currentNode, item) : null;
|
|
187
|
+
addTokenValues(tokens, getScopeTokenValues(currentNode, getScopeTargetScope(item)));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const tokensData = finishTokenValues(prevTokensData, tokens);
|
|
192
|
+
|
|
193
|
+
if (!tokensData) {
|
|
194
|
+
return {
|
|
195
|
+
node: currentNode,
|
|
196
|
+
scopes,
|
|
197
|
+
tokens: null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
node: currentNode,
|
|
203
|
+
scopes,
|
|
204
|
+
tokens: tokensData,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function walkScopes(
|
|
209
|
+
node: PoolNode,
|
|
210
|
+
scopes: readonly (ScopeTargetData | Falsy)[],
|
|
211
|
+
) {
|
|
212
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
213
|
+
const scope = scopes[i];
|
|
214
|
+
if (!scope) continue;
|
|
215
|
+
|
|
216
|
+
node = walkScope(node, scope);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return node;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function walkScope(
|
|
223
|
+
node: PoolNode,
|
|
224
|
+
scope: ScopeTargetData,
|
|
225
|
+
) {
|
|
226
|
+
node = getPoolChild(node, getScopeTargetScope(scope));
|
|
227
|
+
node = getPoolChild(node, getScopeTargetSlotId(scope));
|
|
228
|
+
|
|
229
|
+
return node;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function getScopeTokenValues(
|
|
233
|
+
node: PoolNode | null,
|
|
234
|
+
scope: ScopeData,
|
|
235
|
+
) {
|
|
236
|
+
const tokenNameFormat = CSS_CONFIG.tokenNameFormat;
|
|
237
|
+
|
|
238
|
+
if (node && node.value.h && node.value.f === tokenNameFormat) {
|
|
239
|
+
return node.value.s;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const values = createMutableTokenValues(null);
|
|
243
|
+
const items = scope[BUILDER_STATE].items;
|
|
244
|
+
|
|
245
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
246
|
+
addTokenOverride(values, items[i]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const tokens = finishTokenValues(null, values);
|
|
250
|
+
|
|
251
|
+
if (node) {
|
|
252
|
+
node.value.h = true;
|
|
253
|
+
node.value.s = tokens;
|
|
254
|
+
node.value.f = tokenNameFormat;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return tokens;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function concatScopes(
|
|
261
|
+
inheritedScopes: readonly (ScopeTargetData | Falsy)[],
|
|
262
|
+
scopes: readonly (ScopeTargetData | Falsy)[],
|
|
263
|
+
) {
|
|
264
|
+
const items: ScopeTargetData[] = [];
|
|
265
|
+
|
|
266
|
+
for (let i = 0, len = inheritedScopes.length; i < len; i++) {
|
|
267
|
+
const item = inheritedScopes[i];
|
|
268
|
+
if (item) items.push(item);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
272
|
+
const item = scopes[i];
|
|
273
|
+
if (item) items.push(item);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return items;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function getPoolChild(node: PoolNode, key: unknown) {
|
|
280
|
+
return getCacheTreeChild(node, key, createPoolValue);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function createPoolNode(): PoolNode {
|
|
284
|
+
return createCacheTreeNode<unknown, PoolValue>(createPoolValue());
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function createPoolValue(): PoolValue {
|
|
288
|
+
return {
|
|
289
|
+
style: null,
|
|
290
|
+
tokenCache: null,
|
|
291
|
+
h: false,
|
|
292
|
+
s: null,
|
|
293
|
+
f: undefined,
|
|
294
|
+
updatedAt: Date.now(),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function cleanupNode(node: PoolNode, now: number, ttl: number) {
|
|
299
|
+
for (const [key, child] of node.children) {
|
|
300
|
+
cleanupNode(child, now, ttl);
|
|
301
|
+
|
|
302
|
+
if (child.value.style && now - child.value.updatedAt >= ttl) {
|
|
303
|
+
child.value.style = null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (!child.value.style && !child.children.size) {
|
|
307
|
+
node.children.delete(key);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|