@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,607 @@
|
|
|
1
|
+
import * as crypto from 'node:crypto';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { TRACE_STYLE, TRACE_VALUE } from '../../../builder/data/debug';
|
|
4
|
+
import { BUILDER_TYPE_SCOPE } from '../../../builder/data';
|
|
5
|
+
import { createExtractedScope, createExtractedStyle } from '../../../builder/extract';
|
|
6
|
+
import type { ExtractedStyleTuple } from '../../../builder/extract';
|
|
7
|
+
import type { CompilerInternal } from '../../compiler';
|
|
8
|
+
import type { CompilerOptions } from '../../compiler/types';
|
|
9
|
+
import { resolveFile } from '../../utils/file_resolver';
|
|
10
|
+
import { createImportSourceMatcher } from '../../utils/import_source';
|
|
11
|
+
import {
|
|
12
|
+
compileChain,
|
|
13
|
+
type CompiledChainData,
|
|
14
|
+
type CompiledCssItem,
|
|
15
|
+
type CompiledItem,
|
|
16
|
+
computeSlotId,
|
|
17
|
+
extractStyleChain,
|
|
18
|
+
} from '../extract/chain';
|
|
19
|
+
import type { BabelCore, BabelTypes } from '../utils/babel';
|
|
20
|
+
import { babelTransformOptions } from '../utils/babel';
|
|
21
|
+
import { getProjectFileId } from '../utils/path';
|
|
22
|
+
import type { CompiledStyleObject, CompiledStyleObjectLocations, EvalScope } from './evaluator';
|
|
23
|
+
import {
|
|
24
|
+
COMPILED_STYLE_OBJECT_LOCATIONS,
|
|
25
|
+
evalFail,
|
|
26
|
+
evalOk,
|
|
27
|
+
evaluateEnumDeclaration,
|
|
28
|
+
evaluateNode,
|
|
29
|
+
} from './evaluator';
|
|
30
|
+
import type { EvalModuleBindings, EvalResult, EvalSlotRef, ImportMap, ResolveImportFn } from './types';
|
|
31
|
+
|
|
32
|
+
export type Tracer = ReturnType<typeof createTracer>;
|
|
33
|
+
|
|
34
|
+
type TraceCacheContent = {
|
|
35
|
+
bindings: Array<[string, EvalResult]>;
|
|
36
|
+
dependencies?: TraceDependency[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const CACHE_TYPE = 'transform-trace';
|
|
40
|
+
|
|
41
|
+
type TraceDependency = {
|
|
42
|
+
filePath: string;
|
|
43
|
+
contentHash: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type TraceResult = TraceDependency & {
|
|
47
|
+
bindings: EvalModuleBindings;
|
|
48
|
+
dependencies: TraceDependency[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function createTracer(internal: CompilerInternal) {
|
|
52
|
+
const active = new Set<string>();
|
|
53
|
+
|
|
54
|
+
const resolveImport = (
|
|
55
|
+
babel: typeof BabelCore,
|
|
56
|
+
source: string,
|
|
57
|
+
fromFile: string,
|
|
58
|
+
): EvalModuleBindings | null => {
|
|
59
|
+
return traceModuleResult(babel, source, fromFile)?.bindings ?? null;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const traceModuleResult = (
|
|
63
|
+
babel: typeof BabelCore,
|
|
64
|
+
source: string,
|
|
65
|
+
fromFile: string,
|
|
66
|
+
): TraceResult | null => {
|
|
67
|
+
const resolved = resolveFile(source, fromFile);
|
|
68
|
+
if (!resolved) return null;
|
|
69
|
+
|
|
70
|
+
const contentHash = hashContent(resolved.content);
|
|
71
|
+
|
|
72
|
+
const cached = internal.cache.getItem<TraceCacheContent>({
|
|
73
|
+
filePath: resolved.filePath,
|
|
74
|
+
contentHash,
|
|
75
|
+
cacheType: CACHE_TYPE,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (cached && areDependenciesFresh(cached.dependencies ?? [])) {
|
|
79
|
+
return {
|
|
80
|
+
filePath: resolved.filePath,
|
|
81
|
+
contentHash,
|
|
82
|
+
bindings: new Map(cached.bindings),
|
|
83
|
+
dependencies: cached.dependencies ?? [],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (active.has(resolved.filePath)) return null;
|
|
88
|
+
active.add(resolved.filePath);
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const dependencies = new Map<string, TraceDependency>();
|
|
92
|
+
const resolveDependency: ResolveImportFn = (source, fromFile) => {
|
|
93
|
+
const traced = traceModuleResult(babel, source, fromFile);
|
|
94
|
+
if (!traced) return null;
|
|
95
|
+
|
|
96
|
+
return createTrackedBindings(traced, dependencies);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const bindings = parseAndExtractModule(
|
|
100
|
+
internal.projectDir,
|
|
101
|
+
resolved.filePath,
|
|
102
|
+
resolved.content,
|
|
103
|
+
babel,
|
|
104
|
+
resolveDependency,
|
|
105
|
+
internal.options,
|
|
106
|
+
);
|
|
107
|
+
if (!bindings) return null;
|
|
108
|
+
|
|
109
|
+
const dependencyList = [...dependencies.values()];
|
|
110
|
+
|
|
111
|
+
internal.cache.setItem<TraceCacheContent>({
|
|
112
|
+
filePath: resolved.filePath,
|
|
113
|
+
contentHash,
|
|
114
|
+
cacheType: CACHE_TYPE,
|
|
115
|
+
persistent: false,
|
|
116
|
+
cacheContent: {
|
|
117
|
+
bindings: [...bindings.entries()],
|
|
118
|
+
dependencies: dependencyList,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
filePath: resolved.filePath,
|
|
124
|
+
contentHash,
|
|
125
|
+
bindings,
|
|
126
|
+
dependencies: dependencyList,
|
|
127
|
+
};
|
|
128
|
+
} finally {
|
|
129
|
+
active.delete(resolved.filePath);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const traceModule = (
|
|
134
|
+
babel: typeof BabelCore,
|
|
135
|
+
source: string,
|
|
136
|
+
fromFile: string,
|
|
137
|
+
): EvalModuleBindings | null => {
|
|
138
|
+
return traceModuleResult(babel, source, fromFile)?.bindings ?? null;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
resolveImport,
|
|
143
|
+
traceModule,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function parseAndExtractModule(
|
|
148
|
+
projectDir: string,
|
|
149
|
+
filePath: string,
|
|
150
|
+
content: string,
|
|
151
|
+
babel: typeof BabelCore,
|
|
152
|
+
resolveImport: ResolveImportFn,
|
|
153
|
+
options: CompilerOptions,
|
|
154
|
+
): EvalModuleBindings | null {
|
|
155
|
+
let ast: BabelTypes.File | null = null;
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
const parsed = babel.parseSync(content, {
|
|
159
|
+
...babelTransformOptions(),
|
|
160
|
+
filename: filePath,
|
|
161
|
+
});
|
|
162
|
+
ast = parsed as BabelTypes.File;
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!ast) return null;
|
|
168
|
+
|
|
169
|
+
const imports: ImportMap = new Map();
|
|
170
|
+
const rawBindings: Map<string, BabelTypes.Node> = new Map();
|
|
171
|
+
const bindings: EvalModuleBindings = new Map();
|
|
172
|
+
const styleNames = new Set<string>();
|
|
173
|
+
const styleMetas = new Map();
|
|
174
|
+
const fileId = getProjectFileId(projectDir, filePath);
|
|
175
|
+
const importSourceMatcher = createImportSourceMatcher(options.importSources ?? null);
|
|
176
|
+
|
|
177
|
+
for (const stmt of ast.program.body) {
|
|
178
|
+
if (stmt.type === 'ImportDeclaration') {
|
|
179
|
+
const source = stmt.source.value;
|
|
180
|
+
|
|
181
|
+
for (const spec of stmt.specifiers) {
|
|
182
|
+
if (spec.type === 'ImportSpecifier') {
|
|
183
|
+
const imported = spec.imported.type === 'Identifier'
|
|
184
|
+
? spec.imported.name
|
|
185
|
+
: spec.imported.value;
|
|
186
|
+
|
|
187
|
+
imports.set(spec.local.name, { source, name: imported });
|
|
188
|
+
|
|
189
|
+
const meta = importSourceMatcher({ source, name: imported });
|
|
190
|
+
if (meta) {
|
|
191
|
+
styleNames.add(spec.local.name);
|
|
192
|
+
styleMetas.set(spec.local.name, meta);
|
|
193
|
+
}
|
|
194
|
+
} else if (spec.type === 'ImportDefaultSpecifier') {
|
|
195
|
+
imports.set(spec.local.name, { source, name: 'default' });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (stmt.type === 'VariableDeclaration') {
|
|
203
|
+
collectVariableBindings(rawBindings, stmt);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (stmt.type === 'TSEnumDeclaration') {
|
|
208
|
+
bindings.set(
|
|
209
|
+
stmt.id.name,
|
|
210
|
+
evaluateEnumDeclaration(stmt, {
|
|
211
|
+
bindings,
|
|
212
|
+
imports,
|
|
213
|
+
filePath,
|
|
214
|
+
resolveImport,
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (stmt.type === 'ExportNamedDeclaration') {
|
|
221
|
+
if (stmt.declaration?.type === 'TSEnumDeclaration') {
|
|
222
|
+
bindings.set(
|
|
223
|
+
stmt.declaration.id.name,
|
|
224
|
+
evaluateEnumDeclaration(stmt.declaration, {
|
|
225
|
+
bindings,
|
|
226
|
+
imports,
|
|
227
|
+
filePath,
|
|
228
|
+
resolveImport,
|
|
229
|
+
}),
|
|
230
|
+
);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (stmt.declaration?.type === 'VariableDeclaration') {
|
|
235
|
+
collectVariableBindings(rawBindings, stmt.declaration);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const spec of stmt.specifiers) {
|
|
240
|
+
if (spec.type !== 'ExportSpecifier') continue;
|
|
241
|
+
|
|
242
|
+
const local = spec.local.name;
|
|
243
|
+
const exported = spec.exported.type === 'Identifier'
|
|
244
|
+
? spec.exported.name
|
|
245
|
+
: spec.exported.value;
|
|
246
|
+
|
|
247
|
+
if (stmt.source) {
|
|
248
|
+
imports.set(exported, { source: stmt.source.value, name: local });
|
|
249
|
+
} else if (rawBindings.has(local)) {
|
|
250
|
+
rawBindings.set(exported, rawBindings.get(local)!);
|
|
251
|
+
} else if (bindings.has(local)) {
|
|
252
|
+
bindings.set(exported, bindings.get(local)!);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (stmt.type === 'ExportAllDeclaration') {
|
|
260
|
+
const exported = resolveImport(stmt.source.value, filePath);
|
|
261
|
+
if (exported) {
|
|
262
|
+
exported.forEach((value, key) => {
|
|
263
|
+
if (key !== 'default') bindings.set(key, value);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (stmt.type === 'ExportDefaultDeclaration') {
|
|
269
|
+
rawBindings.set('default', stmt.declaration);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const scope: EvalScope = {
|
|
274
|
+
bindings,
|
|
275
|
+
imports,
|
|
276
|
+
styleNames,
|
|
277
|
+
styleMetas,
|
|
278
|
+
filePath,
|
|
279
|
+
sourcemapTrace: options.dev?.sourcemapMode ?? 'style',
|
|
280
|
+
resolveImport,
|
|
281
|
+
bindingNodes: rawBindings,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
rawBindings.forEach((node, name) => {
|
|
285
|
+
bindings.set(name, evaluateResolvedNode(node, scope, styleNames, fileId, options));
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
return bindings;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function collectVariableBindings(
|
|
292
|
+
bindings: Map<string, BabelTypes.Node>,
|
|
293
|
+
declaration: BabelTypes.VariableDeclaration,
|
|
294
|
+
) {
|
|
295
|
+
for (const decl of declaration.declarations) {
|
|
296
|
+
if (decl.id.type === 'Identifier' && decl.init) {
|
|
297
|
+
bindings.set(decl.id.name, decl.init);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function evaluateResolvedNode(
|
|
303
|
+
node: BabelTypes.Node,
|
|
304
|
+
scope: EvalScope,
|
|
305
|
+
styleNames: Set<string>,
|
|
306
|
+
fileId: string,
|
|
307
|
+
options: CompilerOptions,
|
|
308
|
+
): EvalResult {
|
|
309
|
+
if (node.type === 'CallExpression') {
|
|
310
|
+
const chain = extractStyleChain(node, styleNames);
|
|
311
|
+
|
|
312
|
+
if (chain?.kind === 'slot') {
|
|
313
|
+
return createSlotRef(fileId, node.loc?.start);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (chain?.kind === 'style' || chain?.kind === 'scope') {
|
|
317
|
+
try {
|
|
318
|
+
const meta = scope.styleMetas?.get(chain.rootName);
|
|
319
|
+
if (!meta) return evalFail('Cannot resolve imported style function');
|
|
320
|
+
|
|
321
|
+
const result = compileChain(chain, fileId, node.loc?.start, scope, options, meta, styleNames);
|
|
322
|
+
if (!result) return evalFail('Cannot compile imported style chain');
|
|
323
|
+
|
|
324
|
+
const traceResult = options.dev?.sourcemapMode === 'value'
|
|
325
|
+
? result
|
|
326
|
+
: compileChain(
|
|
327
|
+
chain,
|
|
328
|
+
fileId,
|
|
329
|
+
node.loc?.start,
|
|
330
|
+
scope,
|
|
331
|
+
{
|
|
332
|
+
...options,
|
|
333
|
+
dev: {
|
|
334
|
+
...options.dev,
|
|
335
|
+
sourcemapMode: 'value',
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
meta,
|
|
339
|
+
styleNames,
|
|
340
|
+
) ?? result;
|
|
341
|
+
|
|
342
|
+
const extracted = createExtractedChainValue(result, traceResult);
|
|
343
|
+
if (!extracted) return evalFail('Cannot extract imported style chain');
|
|
344
|
+
|
|
345
|
+
return evalOk(extracted);
|
|
346
|
+
} catch (error) {
|
|
347
|
+
return evalFail(error instanceof Error ? error.message : String(error));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (node.type === 'ObjectExpression') {
|
|
353
|
+
return evaluateResolvedObject(node, scope, styleNames, fileId, options);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return evaluateNode(node, scope);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function evaluateResolvedObject(
|
|
360
|
+
node: BabelTypes.ObjectExpression,
|
|
361
|
+
scope: EvalScope,
|
|
362
|
+
styleNames: Set<string>,
|
|
363
|
+
fileId: string,
|
|
364
|
+
options: CompilerOptions,
|
|
365
|
+
): EvalResult {
|
|
366
|
+
const result: CompiledStyleObject = {};
|
|
367
|
+
const locations: CompiledStyleObjectLocations = {};
|
|
368
|
+
|
|
369
|
+
for (const prop of node.properties) {
|
|
370
|
+
if (prop.type === 'SpreadElement') {
|
|
371
|
+
const value = evaluateResolvedNode(prop.argument, scope, styleNames, fileId, options);
|
|
372
|
+
if (!value.ok) return value;
|
|
373
|
+
if (value.value && typeof value.value === 'object') {
|
|
374
|
+
Object.assign(result, value.value);
|
|
375
|
+
|
|
376
|
+
const sourceLocations = (value.value as CompiledStyleObject)[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
377
|
+
if (sourceLocations) {
|
|
378
|
+
const trace = scope.sourcemapTrace === 'value'
|
|
379
|
+
? TRACE_VALUE
|
|
380
|
+
: TRACE_STYLE;
|
|
381
|
+
const spreadLoc = prop.loc?.start;
|
|
382
|
+
|
|
383
|
+
for (const [key, loc] of Object.entries(sourceLocations)) {
|
|
384
|
+
locations[key] = trace === TRACE_STYLE && spreadLoc
|
|
385
|
+
? {
|
|
386
|
+
line: spreadLoc.line,
|
|
387
|
+
column: spreadLoc.column + 1,
|
|
388
|
+
filePath: scope.styleFilePath ?? scope.filePath,
|
|
389
|
+
trace,
|
|
390
|
+
}
|
|
391
|
+
: {
|
|
392
|
+
...loc,
|
|
393
|
+
trace,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (prop.type !== 'ObjectProperty') {
|
|
402
|
+
return evalFail('Cannot evaluate ObjectMethod in style object');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const key = getObjectPropertyKey(prop, scope);
|
|
406
|
+
if (!key.ok) return key;
|
|
407
|
+
|
|
408
|
+
const value = evaluateResolvedNode(prop.value as BabelTypes.Node, scope, styleNames, fileId, options);
|
|
409
|
+
if (!value.ok && value.reason !== 'slot-ref') return value;
|
|
410
|
+
|
|
411
|
+
result[String(key.value)] = value.ok ? value.value : value;
|
|
412
|
+
|
|
413
|
+
if (prop.loc?.start) {
|
|
414
|
+
locations[String(key.value)] = {
|
|
415
|
+
line: prop.loc.start.line,
|
|
416
|
+
column: prop.loc.start.column + 1,
|
|
417
|
+
filePath: scope.styleFilePath ?? scope.filePath,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (Object.keys(locations).length) {
|
|
423
|
+
Object.defineProperty(result, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
424
|
+
configurable: true,
|
|
425
|
+
enumerable: false,
|
|
426
|
+
value: locations,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return evalOk(result);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function createExtractedChainValue(
|
|
434
|
+
result: CompiledChainData,
|
|
435
|
+
traceResult: CompiledChainData = result,
|
|
436
|
+
): unknown {
|
|
437
|
+
if (result.type === 'style') {
|
|
438
|
+
const style = createExtractedStyle(
|
|
439
|
+
result.items
|
|
440
|
+
.filter(Array.isArray)
|
|
441
|
+
.map((item) => toExtractedStyleTuple(item as CompiledCssItem)),
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
defineCompiledStyleLocations(style, traceResult);
|
|
445
|
+
|
|
446
|
+
return style;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (result.type === 'scope') {
|
|
450
|
+
return createExtractedScope(
|
|
451
|
+
result.items
|
|
452
|
+
.map(toExtractedScopeItem)
|
|
453
|
+
.filter((item) => item !== null),
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function defineCompiledStyleLocations(
|
|
461
|
+
value: CompiledStyleObject,
|
|
462
|
+
result: CompiledChainData,
|
|
463
|
+
) {
|
|
464
|
+
const locations: CompiledStyleObjectLocations = {};
|
|
465
|
+
|
|
466
|
+
for (const item of result.items) {
|
|
467
|
+
if (!Array.isArray(item) || !item.sourceTrace) continue;
|
|
468
|
+
|
|
469
|
+
locations[item.sourceTrace.property] = {
|
|
470
|
+
filePath: item.sourceTrace.filePath,
|
|
471
|
+
line: item.sourceTrace.line,
|
|
472
|
+
column: item.sourceTrace.column,
|
|
473
|
+
trace: TRACE_VALUE,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (!Object.keys(locations).length) return;
|
|
478
|
+
|
|
479
|
+
Object.defineProperty(value, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
480
|
+
configurable: true,
|
|
481
|
+
enumerable: false,
|
|
482
|
+
value: locations,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function toExtractedStyleTuple(item: CompiledCssItem): ExtractedStyleTuple {
|
|
487
|
+
const startsWithType = typeof item[0] === 'number';
|
|
488
|
+
const dedupe = String(startsWithType ? item[1] : item[0]);
|
|
489
|
+
const className = String(startsWithType ? item[2] : item[1]);
|
|
490
|
+
const value = startsWithType ? item[3] : item[2];
|
|
491
|
+
|
|
492
|
+
return value === undefined
|
|
493
|
+
? [dedupe, className]
|
|
494
|
+
: [dedupe, className, value as ExtractedStyleTuple[2]];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function toExtractedScopeItem(item: CompiledItem): Parameters<typeof createExtractedScope>[0][number] | null {
|
|
498
|
+
if (!Array.isArray(item)) {
|
|
499
|
+
return item.kind === 'token' ? item.value : null;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return toExtractedScopeTuple(item);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function toExtractedScopeTuple(item: CompiledCssItem) {
|
|
506
|
+
const value = item[4];
|
|
507
|
+
const tuple: unknown[] = [
|
|
508
|
+
BUILDER_TYPE_SCOPE,
|
|
509
|
+
String(item[1]),
|
|
510
|
+
String(item[2]),
|
|
511
|
+
String(item[3]),
|
|
512
|
+
];
|
|
513
|
+
|
|
514
|
+
if (value !== undefined) tuple.push(value);
|
|
515
|
+
if (item.hasParentSelector) tuple.push(1);
|
|
516
|
+
|
|
517
|
+
return tuple as Parameters<typeof createExtractedScope>[0][number];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function getObjectPropertyKey(
|
|
521
|
+
prop: BabelTypes.ObjectProperty,
|
|
522
|
+
scope: EvalScope,
|
|
523
|
+
): EvalResult {
|
|
524
|
+
if (prop.computed) return evaluateNode(prop.key as BabelTypes.Node, scope);
|
|
525
|
+
if (prop.key.type === 'Identifier') return evalOk(prop.key.name);
|
|
526
|
+
if (prop.key.type === 'StringLiteral') return evalOk(prop.key.value);
|
|
527
|
+
if (prop.key.type === 'NumericLiteral') return evalOk(prop.key.value);
|
|
528
|
+
return evalFail('Unsupported object property key');
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function createSlotRef(
|
|
532
|
+
fileId: string,
|
|
533
|
+
loc: { line: number; column: number; } | null | undefined,
|
|
534
|
+
): EvalSlotRef {
|
|
535
|
+
return {
|
|
536
|
+
ok: false,
|
|
537
|
+
reason: 'slot-ref',
|
|
538
|
+
filePath: fileId,
|
|
539
|
+
slotId: computeSlotId(fileId, loc),
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function hashContent(content: string): string {
|
|
544
|
+
return crypto.createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function addTraceDependency(
|
|
548
|
+
dependencies: Map<string, TraceDependency>,
|
|
549
|
+
dependency: TraceDependency,
|
|
550
|
+
) {
|
|
551
|
+
dependencies.set(dependency.filePath, dependency);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function createTrackedBindings(
|
|
555
|
+
traced: TraceResult,
|
|
556
|
+
dependencies: Map<string, TraceDependency>,
|
|
557
|
+
): EvalModuleBindings {
|
|
558
|
+
const track = () => {
|
|
559
|
+
addTraceDependency(dependencies, traced);
|
|
560
|
+
traced.dependencies.forEach((dependency) => addTraceDependency(dependencies, dependency));
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
return new class extends Map<string, EvalResult> {
|
|
564
|
+
constructor() {
|
|
565
|
+
super(traced.bindings);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
override get(key: string): EvalResult | undefined {
|
|
569
|
+
const value = super.get(key);
|
|
570
|
+
if (value !== undefined || super.has(key)) track();
|
|
571
|
+
return value;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
override has(key: string): boolean {
|
|
575
|
+
const result = super.has(key);
|
|
576
|
+
if (result) track();
|
|
577
|
+
return result;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
override forEach(
|
|
581
|
+
callbackfn: (value: EvalResult, key: string, map: Map<string, EvalResult>) => void,
|
|
582
|
+
thisArg?: unknown,
|
|
583
|
+
): void {
|
|
584
|
+
track();
|
|
585
|
+
super.forEach(callbackfn, thisArg);
|
|
586
|
+
}
|
|
587
|
+
}();
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function areDependenciesFresh(
|
|
591
|
+
dependencies: TraceDependency[],
|
|
592
|
+
): boolean {
|
|
593
|
+
for (const dependency of dependencies) {
|
|
594
|
+
const currentHash = hashFileContent(dependency.filePath);
|
|
595
|
+
if (currentHash !== dependency.contentHash) return false;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return true;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function hashFileContent(filePath: string): string | null {
|
|
602
|
+
try {
|
|
603
|
+
return hashContent(fs.readFileSync(filePath, 'utf8'));
|
|
604
|
+
} catch {
|
|
605
|
+
return null;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ResolveImportFn = (
|
|
2
|
+
source: string,
|
|
3
|
+
from: string,
|
|
4
|
+
) => EvalModuleBindings | null;
|
|
5
|
+
|
|
6
|
+
export type ImportMap = Map<string, {
|
|
7
|
+
source: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
export type EvalModuleBindings = Map<string, EvalResult>;
|
|
12
|
+
|
|
13
|
+
export type EvalSlotRef = {
|
|
14
|
+
ok: false;
|
|
15
|
+
reason: 'slot-ref';
|
|
16
|
+
filePath: string;
|
|
17
|
+
slotId: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type EvalOk = { ok: true; value: unknown; };
|
|
21
|
+
export type EvalFail = { ok: false; reason: string; };
|
|
22
|
+
export type EvalResult = EvalOk | EvalFail | EvalSlotRef;
|