@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,40 @@
|
|
|
1
|
+
import type { KeyframeSelector, KeyframesObject } from '../atomic/atRule/keyframes';
|
|
2
|
+
import { createKeyframes } from '../css';
|
|
3
|
+
import type { StableId } from '../utils/id';
|
|
4
|
+
import type { StyleTransform } from './transform';
|
|
5
|
+
import type { CSSProperties, StyleObject } from './types';
|
|
6
|
+
|
|
7
|
+
export type StyleKeyframesObject<Style = CSSProperties> = {
|
|
8
|
+
[Selector in KeyframeSelector]?: StyleObject<Style>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function transformKeyframes<Style>(
|
|
12
|
+
frames: StyleKeyframesObject<Style>,
|
|
13
|
+
transform: StyleTransform<Style> | null,
|
|
14
|
+
): KeyframesObject {
|
|
15
|
+
if (!transform) return frames as KeyframesObject;
|
|
16
|
+
|
|
17
|
+
const result: KeyframesObject = {};
|
|
18
|
+
|
|
19
|
+
for (const selector in frames) {
|
|
20
|
+
const frame = frames[selector as KeyframeSelector];
|
|
21
|
+
if (!frame) continue;
|
|
22
|
+
|
|
23
|
+
result[selector as KeyframeSelector] = transform.transform(frame) as KeyframesObject[KeyframeSelector];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function createStyleKeyframes<Style>(
|
|
30
|
+
frames: StyleKeyframesObject<Style>,
|
|
31
|
+
transform: StyleTransform<Style> | null,
|
|
32
|
+
stableId?: StableId,
|
|
33
|
+
): ReturnType<typeof createKeyframes> {
|
|
34
|
+
const create = createKeyframes as (
|
|
35
|
+
frames: KeyframesObject,
|
|
36
|
+
stableId?: StableId,
|
|
37
|
+
) => ReturnType<typeof createKeyframes>;
|
|
38
|
+
|
|
39
|
+
return create(transformKeyframes(frames, transform), stableId);
|
|
40
|
+
}
|
package/style/style.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createScopeBuilder, createSlotBuilder, createStyleBuilder, type SelectorsRecord } from '../builder';
|
|
2
|
+
import { isStyleData } from '../builder/data';
|
|
3
|
+
import { mergeStyleData } from '../builder/style_data';
|
|
4
|
+
import { createDefaultFnResult } from '../builder/style_fns';
|
|
5
|
+
import type { typeAliases } from '../builder/types/alias';
|
|
6
|
+
import type { StableIdInput } from '../css/utils';
|
|
7
|
+
import { PrioritySelectors } from '../selector/presets';
|
|
8
|
+
import { symbol } from '../utils/global';
|
|
9
|
+
import { type } from '../utils/type';
|
|
10
|
+
import type { Type } from '../utils/type';
|
|
11
|
+
import { createStyleKeyframes } from './keyframes';
|
|
12
|
+
import type { StyleTransform } from './transform';
|
|
13
|
+
import type { CSSProperties } from './types';
|
|
14
|
+
|
|
15
|
+
const META: unique symbol = symbol('style.fn:meta');
|
|
16
|
+
|
|
17
|
+
export type StyleFnMeta = {
|
|
18
|
+
selectors: SelectorsRecord;
|
|
19
|
+
transform: StyleTransform | null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const { style } = createStyleFn({
|
|
23
|
+
style: type<CSSProperties>,
|
|
24
|
+
selectors: PrioritySelectors,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type StyleFn<Style = any, Selectors extends SelectorsRecord = any> = ReturnType<
|
|
28
|
+
typeof createStyleFn<Style, Selectors>
|
|
29
|
+
>['style'];
|
|
30
|
+
|
|
31
|
+
export function createStyleFn<
|
|
32
|
+
Style,
|
|
33
|
+
const Selectors extends SelectorsRecord,
|
|
34
|
+
>(args: {
|
|
35
|
+
style: Type<Style>;
|
|
36
|
+
selectors: Selectors;
|
|
37
|
+
transform?: StyleTransform<Style> | null;
|
|
38
|
+
}) {
|
|
39
|
+
const { selectors, transform = null } = args;
|
|
40
|
+
|
|
41
|
+
type Types = ReturnType<typeof typeAliases<Style, Selectors>>;
|
|
42
|
+
|
|
43
|
+
const fnStyle = createStyleBuilder<Style, Selectors>(selectors, transform);
|
|
44
|
+
const fnSlot = createSlotBuilder<Style, Selectors>(selectors, transform);
|
|
45
|
+
const fnScope = createScopeBuilder<Style, Selectors>(selectors);
|
|
46
|
+
|
|
47
|
+
const fnValue: Types['ValueFn'] = (value, weight) => {
|
|
48
|
+
return [weight, value];
|
|
49
|
+
};
|
|
50
|
+
const fnRaw: Types['RawFn'] = (style) => style;
|
|
51
|
+
const fnPlain: Types['PlainFn'] = (style) => style;
|
|
52
|
+
const fnKeyframes: Types['KeyframesFn'] =
|
|
53
|
+
((frames, stableId?: StableIdInput) => createStyleKeyframes(frames, transform ?? null, stableId)) as Types[
|
|
54
|
+
'KeyframesFn'
|
|
55
|
+
];
|
|
56
|
+
const fnMerge: Types['MergeFn'] = ((target: unknown, ...styles: unknown[]) => {
|
|
57
|
+
let result = target;
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < styles.length; i++) {
|
|
60
|
+
result = mergeStyleResult(result, styles[i]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return result;
|
|
64
|
+
}) as Types['MergeFn'];
|
|
65
|
+
|
|
66
|
+
const style = fnStyle as unknown as Types['StyleFn'];
|
|
67
|
+
|
|
68
|
+
style.slot = fnSlot;
|
|
69
|
+
style.scope = fnScope;
|
|
70
|
+
style.value = fnValue;
|
|
71
|
+
style.raw = fnRaw;
|
|
72
|
+
style.plain = fnPlain;
|
|
73
|
+
style.keyframes = fnKeyframes;
|
|
74
|
+
style.merge = fnMerge;
|
|
75
|
+
|
|
76
|
+
const meta: StyleFnMeta = {
|
|
77
|
+
selectors,
|
|
78
|
+
transform: transform ?? null,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
Object.assign(style, { [META]: meta });
|
|
82
|
+
|
|
83
|
+
return { style };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function mergeStyleResult(
|
|
87
|
+
target: unknown,
|
|
88
|
+
style: unknown,
|
|
89
|
+
) {
|
|
90
|
+
if (isStyleData(target)) {
|
|
91
|
+
return createDefaultFnResult(
|
|
92
|
+
mergeStyleData(
|
|
93
|
+
target,
|
|
94
|
+
null,
|
|
95
|
+
isStyleData(style) ? style : null,
|
|
96
|
+
null,
|
|
97
|
+
null,
|
|
98
|
+
null,
|
|
99
|
+
),
|
|
100
|
+
Object.getPrototypeOf(target),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const chainMerge = (target as { merge?: unknown; } | null)?.merge;
|
|
105
|
+
if (typeof chainMerge === 'function') return chainMerge.call(target, style);
|
|
106
|
+
|
|
107
|
+
return target;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function getStyleFnMeta(styleFn: StyleFn) {
|
|
111
|
+
return (styleFn as any)[META] as StyleFnMeta;
|
|
112
|
+
}
|
package/style/theme.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createThemeClassName } from '../atomic/theme';
|
|
2
|
+
import { createThemeData } from '../builder/data/create';
|
|
3
|
+
import type { BuilderCallsite } from '../builder/data/data';
|
|
4
|
+
import type { ThemeData } from '../builder/data/data';
|
|
5
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
6
|
+
import { createIdCounter, getId, type StableId } from '../utils/id';
|
|
7
|
+
import type { StyleTokenOverride } from './token';
|
|
8
|
+
|
|
9
|
+
const idCounter = createIdCounter('theme');
|
|
10
|
+
|
|
11
|
+
export function resetStyleThemeIdCounter() {
|
|
12
|
+
idCounter.value = 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createTheme(
|
|
16
|
+
tokens: readonly StyleTokenOverride[],
|
|
17
|
+
stableId?: StableId | string,
|
|
18
|
+
): ThemeData;
|
|
19
|
+
export function createTheme(
|
|
20
|
+
tokens: readonly StyleTokenOverride[],
|
|
21
|
+
stableId?: StableId | string,
|
|
22
|
+
callsite?: BuilderCallsite | null,
|
|
23
|
+
): ThemeData {
|
|
24
|
+
const normalizedStableId = typeof stableId === 'string'
|
|
25
|
+
? { name: stableId, id: stableId }
|
|
26
|
+
: stableId;
|
|
27
|
+
const { name, id } = getId(idCounter, normalizedStableId || null);
|
|
28
|
+
|
|
29
|
+
const className = createThemeClassName(
|
|
30
|
+
name,
|
|
31
|
+
id,
|
|
32
|
+
CSS_CONFIG.themeNameFormat || null,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return createThemeData(callsite ?? null, id, className, tokens);
|
|
36
|
+
}
|
package/style/token.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { DebugData } from '../builder/data/debug';
|
|
2
|
+
import { globalData, symbol } from '../utils/global';
|
|
3
|
+
|
|
4
|
+
export const TOKEN_ID: unique symbol = symbol('style:token');
|
|
5
|
+
export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
|
|
6
|
+
export const TOKEN_DEBUG: unique symbol = symbol('style:token.debug');
|
|
7
|
+
|
|
8
|
+
export type StyleTokenData<T = unknown> = {
|
|
9
|
+
[TOKEN_ID]: string;
|
|
10
|
+
[TOKEN_OVERRIDE]?: false;
|
|
11
|
+
value: T;
|
|
12
|
+
ref: StyleTokenData<T> | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type StyleTokenOverride<T = unknown> = {
|
|
16
|
+
[TOKEN_ID]: string;
|
|
17
|
+
[TOKEN_OVERRIDE]: true;
|
|
18
|
+
[TOKEN_DEBUG]?: DebugData | null;
|
|
19
|
+
value: T;
|
|
20
|
+
ref: StyleTokenData<T> | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type StyleToken<T = unknown> = StyleTokenData<T> & {
|
|
24
|
+
(value: T | StyleTokenData<T>, debug?: DebugData): StyleTokenOverride<T>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const idCounter = globalData('style.token.idCounter', () => ({ value: 0 }));
|
|
28
|
+
|
|
29
|
+
export function resetStyleTokenIdCounter() {
|
|
30
|
+
idCounter.value = 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createStyleToken<T>(value: T | StyleToken<T>, debugId?: string) {
|
|
34
|
+
const token: StyleToken<T> = (value, debug) => {
|
|
35
|
+
return createStyleTokenOverride(token, value, debug);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
token[TOKEN_ID] = debugId || String(idCounter.value++);
|
|
39
|
+
|
|
40
|
+
if (isStyleTokenData<T>(value)) {
|
|
41
|
+
token.value = value.value;
|
|
42
|
+
token.ref = value;
|
|
43
|
+
} else {
|
|
44
|
+
token.value = value;
|
|
45
|
+
token.ref = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return token;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function createStyleTokenOverride<T>(
|
|
52
|
+
token: StyleTokenData<T>,
|
|
53
|
+
value: T | StyleTokenData<T>,
|
|
54
|
+
debug?: DebugData | null,
|
|
55
|
+
): StyleTokenOverride<T> {
|
|
56
|
+
const override: StyleTokenOverride<T> = isStyleTokenData<T>(value)
|
|
57
|
+
? {
|
|
58
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
59
|
+
[TOKEN_OVERRIDE]: true,
|
|
60
|
+
value: value.value,
|
|
61
|
+
ref: value,
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
65
|
+
[TOKEN_OVERRIDE]: true,
|
|
66
|
+
value: value as T,
|
|
67
|
+
ref: null,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (debug) {
|
|
71
|
+
Object.defineProperty(override, TOKEN_DEBUG, {
|
|
72
|
+
configurable: true,
|
|
73
|
+
enumerable: false,
|
|
74
|
+
value: debug,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return override;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function getStyleTokenOverrideDebug(
|
|
82
|
+
token: StyleTokenOverride,
|
|
83
|
+
) {
|
|
84
|
+
return token[TOKEN_DEBUG] ?? null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
|
|
88
|
+
return !!value &&
|
|
89
|
+
typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
|
|
90
|
+
(value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
|
|
94
|
+
return !!value &&
|
|
95
|
+
typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
|
|
96
|
+
(value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
|
|
100
|
+
return token[TOKEN_ID];
|
|
101
|
+
}
|
package/style/tokens.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { StyleToken } from './token';
|
|
2
|
+
import { createToken, type InferValue, type ValueBase } from './value';
|
|
3
|
+
|
|
4
|
+
export type TokenTuple<T extends readonly ValueBase[]> = {
|
|
5
|
+
[P in T[number]]: StyleToken<InferValue<P>>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type TokenRecord<T extends object> = {
|
|
9
|
+
[P in keyof T]: T[P] extends readonly unknown[] ? StyleToken<T[P]>
|
|
10
|
+
: T[P] extends object ? TokenRecord<T[P]>
|
|
11
|
+
: T[P] extends ValueBase ? StyleToken<InferValue<T[P]>>
|
|
12
|
+
: StyleToken<T[P]>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function createTokens<const T extends readonly ValueBase[]>(
|
|
16
|
+
values: T,
|
|
17
|
+
debugId?: string,
|
|
18
|
+
): TokenTuple<T>;
|
|
19
|
+
export function createTokens<T extends object>(
|
|
20
|
+
values: T,
|
|
21
|
+
debugId?: string,
|
|
22
|
+
): TokenRecord<T>;
|
|
23
|
+
export function createTokens(
|
|
24
|
+
values: readonly ValueBase[] | Record<PropertyKey, unknown>,
|
|
25
|
+
debugId?: string,
|
|
26
|
+
): any {
|
|
27
|
+
const tokens: Record<PropertyKey, StyleToken> = {};
|
|
28
|
+
|
|
29
|
+
if (Array.isArray(values)) {
|
|
30
|
+
for (let i = 0, len = values.length; i < len; i++) {
|
|
31
|
+
const value = values[i];
|
|
32
|
+
tokens[value] = createToken(value, getChildDebugId(debugId, String(i)));
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, debugId);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return tokens;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function assignTokenRecord(
|
|
42
|
+
target: Record<PropertyKey, unknown>,
|
|
43
|
+
values: Record<PropertyKey, unknown>,
|
|
44
|
+
debugId: string | undefined,
|
|
45
|
+
) {
|
|
46
|
+
for (let key in values) {
|
|
47
|
+
const value = values[key];
|
|
48
|
+
|
|
49
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
50
|
+
const child: Record<PropertyKey, unknown> = {};
|
|
51
|
+
target[key] = child;
|
|
52
|
+
assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildDebugId(debugId, key));
|
|
53
|
+
} else {
|
|
54
|
+
target[key] = createToken(value, getChildDebugId(debugId, key));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getChildDebugId(
|
|
60
|
+
debugId: string | undefined,
|
|
61
|
+
child: string,
|
|
62
|
+
) {
|
|
63
|
+
return debugId ? debugId + '--' + child : undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CSSProperties, StyleObject } from './types';
|
|
2
|
+
|
|
3
|
+
export type StyleTransform<Style = unknown> = {
|
|
4
|
+
transform(style: StyleObject<Style>): StyleObject<CSSProperties>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function styleTransform<Style>(options: StyleTransform<Style>) {
|
|
8
|
+
return options;
|
|
9
|
+
}
|
package/style/types.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CSSProperties } from '../atomic/utils/types';
|
|
2
|
+
import type { StyleTokenData } from './token';
|
|
3
|
+
import type { AtRuleRef } from './valueRef';
|
|
4
|
+
|
|
5
|
+
export type { CSSProperties };
|
|
6
|
+
|
|
7
|
+
// StyleTokenize<string | number> -> StyleTokenData<string> | StyleTokenData<number>
|
|
8
|
+
type StyleTokenize<T> = Exclude<
|
|
9
|
+
T extends unknown ? StyleTokenData<T> : never,
|
|
10
|
+
StyleTokenData<undefined>
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
type Value<T> = T | StyleValueTuple<Exclude<T, null | undefined>>;
|
|
14
|
+
type PlainValue<T> = T | StyleValueTuple<Exclude<T, null | undefined>>;
|
|
15
|
+
|
|
16
|
+
export type StyleValueTuple<T = unknown> = [priority: number, value: T];
|
|
17
|
+
|
|
18
|
+
export type StyleValue<T> = Value<T | StyleTokenize<T> | AtRuleRef>;
|
|
19
|
+
|
|
20
|
+
export type AtRuleStyleValue<T> = T | StyleTokenize<T>;
|
|
21
|
+
|
|
22
|
+
export type StyleObject<T = unknown> = {
|
|
23
|
+
[P in keyof T]: StyleValue<T[P]>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type AtRuleStyleObject<T = unknown> = {
|
|
27
|
+
[P in keyof T]: AtRuleStyleValue<T[P]>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type PlainStyleObject<T = unknown> = {
|
|
31
|
+
[P in keyof T]: PlainValue<T[P]>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AnyBuilderData, SlotData } from '../../builder/data';
|
|
2
|
+
import { isSlotData } from '../../builder/data';
|
|
3
|
+
import { isStyleTokenData, type StyleTokenData } from '../token';
|
|
4
|
+
|
|
5
|
+
type ExposedStyleItem<T> = T extends StyleTokenData ? T
|
|
6
|
+
: T extends SlotData ? T
|
|
7
|
+
: T extends AnyBuilderData ? never
|
|
8
|
+
: T extends readonly unknown[] ? never
|
|
9
|
+
: T extends object ? ExposedStyle<T>
|
|
10
|
+
: never;
|
|
11
|
+
|
|
12
|
+
export type ExposedStyle<T> = {
|
|
13
|
+
[K in keyof T as ExposedStyleItem<T[K]> extends never ? never : K]: ExposedStyleItem<T[K]>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function exposeStyle<T extends object>(styles: T): ExposedStyle<T> {
|
|
17
|
+
return exposeStyleObject(styles) as ExposedStyle<T>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function exposeStyleObject(source: object) {
|
|
21
|
+
const result: Record<PropertyKey, unknown> = {};
|
|
22
|
+
|
|
23
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
24
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
25
|
+
|
|
26
|
+
const exposed = exposeStyleValue((source as Record<PropertyKey, unknown>)[key]);
|
|
27
|
+
|
|
28
|
+
if (exposed !== undefined) {
|
|
29
|
+
result[key] = exposed;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function exposeStyleValue(value: unknown): unknown {
|
|
37
|
+
if (isStyleTokenData(value) || isSlotData(value)) return value;
|
|
38
|
+
|
|
39
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
|
|
40
|
+
|
|
41
|
+
const exposed = exposeStyleObject(value);
|
|
42
|
+
return Reflect.ownKeys(exposed).length > 0 ? exposed : undefined;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './expose';
|
package/style/value.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { DebugData } from '../builder/data/debug';
|
|
2
|
+
import { hashString } from '../utils/hash';
|
|
3
|
+
import { createStyleToken, type StyleToken, type StyleTokenOverride } from './token';
|
|
4
|
+
|
|
5
|
+
export type ValueBase = string | number;
|
|
6
|
+
export type InferValue<T extends ValueBase> = T extends string ? string : T extends number ? number : ValueBase;
|
|
7
|
+
|
|
8
|
+
export type StyleValueFn<T extends ValueBase, Value extends ValueBase> = {
|
|
9
|
+
(value: T): StyleToken<Value>;
|
|
10
|
+
(value: T, provide: Value | StyleToken<Value>): StyleTokenOverride<Value>;
|
|
11
|
+
(value: T, provide: Value | StyleToken<Value>, debug: DebugData): StyleTokenOverride<Value>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function createToken<T>(value: T | StyleToken<T>, debugId?: string) {
|
|
15
|
+
return createStyleToken(value, debugId);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function createValues<const T extends ValueBase>(
|
|
19
|
+
values: readonly T[],
|
|
20
|
+
debugId?: string,
|
|
21
|
+
): StyleValueFn<T, InferValue<T>>;
|
|
22
|
+
export function createValues<const T extends ValueBase>(
|
|
23
|
+
type: NumberConstructor,
|
|
24
|
+
values: readonly T[],
|
|
25
|
+
debugId?: string,
|
|
26
|
+
): StyleValueFn<T, number>;
|
|
27
|
+
export function createValues(
|
|
28
|
+
...args: [NumberConstructor, readonly ValueBase[], string?] | [readonly ValueBase[], string?]
|
|
29
|
+
): StyleValueFn<any, any> {
|
|
30
|
+
let values: readonly ValueBase[] = args[0] as readonly ValueBase[];
|
|
31
|
+
let isNumber = false;
|
|
32
|
+
let debugId = args[1] as string | undefined;
|
|
33
|
+
|
|
34
|
+
if (args[0] === Number) {
|
|
35
|
+
values = args[1] as readonly ValueBase[];
|
|
36
|
+
debugId = args[2] as string | undefined;
|
|
37
|
+
isNumber = true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!values.length) {
|
|
41
|
+
throw new Error('[Style.values] NO_VALUES');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const tokens = new Map<ValueBase, StyleToken<ValueBase>>();
|
|
45
|
+
|
|
46
|
+
for (let value of values) {
|
|
47
|
+
tokens.set(
|
|
48
|
+
value,
|
|
49
|
+
createToken(
|
|
50
|
+
parseValue(value, isNumber),
|
|
51
|
+
getChildDebugId(debugId, hashString(String(value))),
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const fn = function ValueFn(...args: unknown[]) {
|
|
57
|
+
const [value, provide, debug] = args as [
|
|
58
|
+
ValueBase,
|
|
59
|
+
ValueBase | StyleToken<ValueBase>,
|
|
60
|
+
DebugData | undefined,
|
|
61
|
+
];
|
|
62
|
+
const token = tokens.get(value);
|
|
63
|
+
|
|
64
|
+
if (!token) {
|
|
65
|
+
throw new Error(`[Style.values] VALUE_NOT_FOUND: ${String(value)}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (args.length === 2) {
|
|
69
|
+
return token(provide);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (args.length >= 3) {
|
|
73
|
+
return token(provide, debug);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return token;
|
|
77
|
+
} as StyleValueFn<ValueBase, ValueBase>;
|
|
78
|
+
|
|
79
|
+
return fn;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getChildDebugId(
|
|
83
|
+
debugId: string | undefined,
|
|
84
|
+
child: string,
|
|
85
|
+
) {
|
|
86
|
+
return debugId ? debugId + '--' + child : undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function parseValue(value: ValueBase, isNumber: boolean) {
|
|
90
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
91
|
+
|
|
92
|
+
value = String(value).split(/[;|]/)[0].trim();
|
|
93
|
+
|
|
94
|
+
if (!isNumber) return value;
|
|
95
|
+
|
|
96
|
+
const number = Number(value);
|
|
97
|
+
|
|
98
|
+
if (!Number.isFinite(number)) {
|
|
99
|
+
throw new Error(`[Style.values] INVALID_NUMBER_VALUE: ${String(value)}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return number;
|
|
103
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { symbol } from '../utils/global';
|
|
2
|
+
import type { StyleTokenData } from './token';
|
|
3
|
+
|
|
4
|
+
export const AT_RULE_REF: unique symbol = symbol('atRule.ref');
|
|
5
|
+
|
|
6
|
+
export type AtRuleRefData = {
|
|
7
|
+
key: string;
|
|
8
|
+
value: string;
|
|
9
|
+
css: string | null;
|
|
10
|
+
tokens?: readonly StyleTokenData[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type AtRuleRef = AtRuleRefData & {
|
|
14
|
+
[AT_RULE_REF]: true;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function createAtRuleRef(data: AtRuleRefData): AtRuleRef {
|
|
18
|
+
return { [AT_RULE_REF]: true, ...data };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isAtRuleRef(value: unknown): value is AtRuleRef {
|
|
22
|
+
return !!value &&
|
|
23
|
+
typeof value === 'object' &&
|
|
24
|
+
(value as AtRuleRef)[AT_RULE_REF] === true;
|
|
25
|
+
}
|
package/utils/global.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function symbol<T extends symbol>(name: string): T {
|
|
2
|
+
return Symbol.for(`@fluentic/style.${name}`) as T;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
type Global<T> = typeof globalThis & Record<symbol, T | undefined>;
|
|
6
|
+
|
|
7
|
+
export function getGlobalData<T>(key: string) {
|
|
8
|
+
return (globalThis as Global<T>)[symbol(key)];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function globalData<T>(key: string, data: () => T) {
|
|
12
|
+
const id = symbol(key);
|
|
13
|
+
const root = globalThis as Global<T>;
|
|
14
|
+
|
|
15
|
+
if (root[id] === undefined) {
|
|
16
|
+
assign(root, id, data());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return root[id]!;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setGlobalData<T>(key: string, data: T) {
|
|
23
|
+
const id = symbol(key);
|
|
24
|
+
const root = globalThis as Global<T>;
|
|
25
|
+
|
|
26
|
+
if (root[id] === undefined) {
|
|
27
|
+
assign(root, id, data);
|
|
28
|
+
} else {
|
|
29
|
+
root[id] = data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function clearGlobalData(key: string) {
|
|
34
|
+
delete (globalThis as Global<unknown>)[symbol(key)];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assign(target: object, id: symbol, value: unknown) {
|
|
38
|
+
Object.defineProperty(target, id, {
|
|
39
|
+
value,
|
|
40
|
+
configurable: true,
|
|
41
|
+
enumerable: false,
|
|
42
|
+
writable: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
package/utils/hash.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const BASE62_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
2
|
+
|
|
3
|
+
export function toBase62(value: number) {
|
|
4
|
+
let result = '';
|
|
5
|
+
|
|
6
|
+
do {
|
|
7
|
+
result = BASE62_CHARS[value % 62] + result;
|
|
8
|
+
value = Math.floor(value / 62);
|
|
9
|
+
} while (value > 0);
|
|
10
|
+
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function hashString(str: string) {
|
|
15
|
+
let hash = 0x811c9dc5;
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < str.length; i++) {
|
|
18
|
+
hash = Math.imul(hash ^ str.charCodeAt(i), 0x01000193);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (hash >>> 0).toString(36).padEnd(7, '0');
|
|
22
|
+
}
|
package/utils/id.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { globalData } from './global';
|
|
2
|
+
|
|
3
|
+
export type StableId = {
|
|
4
|
+
name: string | null;
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type IdCounter = { value: number; };
|
|
9
|
+
|
|
10
|
+
export function createIdCounter(name: string) {
|
|
11
|
+
return globalData('idCounter.' + name, () => ({ value: 0 }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function resetIdCounter(idCounter: IdCounter) {
|
|
15
|
+
idCounter.value = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getId(idCounter: IdCounter, stableId: StableId | null): StableId {
|
|
19
|
+
return stableId || { name: null, id: String(idCounter.value++) };
|
|
20
|
+
}
|