@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,185 @@
|
|
|
1
|
+
import type { Selector } from '../../selector';
|
|
2
|
+
import type { StyleObject } from '../../style/types';
|
|
3
|
+
import type { ScopeItems } from '../data/merge/scope';
|
|
4
|
+
import type { scopeRule, slotOverrideRule, slotRule, styleRule } from './alias';
|
|
5
|
+
import type { AtRuleStyleData, MergeRuleStyleData } from './types';
|
|
6
|
+
|
|
7
|
+
/* style */
|
|
8
|
+
|
|
9
|
+
type StyleFn<Style, Self> = {
|
|
10
|
+
(style: StyleObject<Style>): Self;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type StyleArgFn<Style, Self, Arg extends string> = {
|
|
14
|
+
(selector: Arg, style: StyleObject<Style>): Self;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type StyleArgsFn<Style, Self, Arg extends string> = {
|
|
18
|
+
(selector: Arg | Arg[], style: StyleObject<Style>): Self;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type StyleMergeFn<Style, Self> = {
|
|
22
|
+
(style: MergeRuleStyleData<Style>): Self;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type StyleAtRuleFn<Style, Self, Arg> = {
|
|
26
|
+
(selector: Arg, style: AtRuleStyleData<Style>): Self;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type StyleAtRuleNoArgFn<Style, Self> = {
|
|
30
|
+
(style: AtRuleStyleData<Style>): Self;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type StyleMediaFn<Style, Self, Arg> = StyleAtRuleFn<Style, Self, Arg> & {
|
|
34
|
+
(priority: number, selector: Arg, style: AtRuleStyleData<Style>): Self;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type StyleMediaNoArgFn<Style, Self> = StyleAtRuleNoArgFn<Style, Self> & {
|
|
38
|
+
(priority: number, style: AtRuleStyleData<Style>): Self;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type StyleAtRuleArgFn<Style, Self, Arg extends string> = StyleAtRuleFn<Style, Self, Arg>;
|
|
42
|
+
type StyleAtRuleArgsFn<Style, Self, Arg extends string> = StyleAtRuleFn<Style, Self, Arg | Arg[]>;
|
|
43
|
+
|
|
44
|
+
type StyleMediaArgFn<Style, Self, Arg extends string> = StyleMediaFn<Style, Self, Arg>;
|
|
45
|
+
type StyleMediaArgsFn<Style, Self, Arg extends string> = StyleMediaFn<Style, Self, Arg | Arg[]>;
|
|
46
|
+
|
|
47
|
+
type SelectorString<S> = S extends Selector<infer T, any> ? T : S;
|
|
48
|
+
type SelectorArg<S> = S extends Selector<any, infer Arg> ? Arg : string;
|
|
49
|
+
|
|
50
|
+
type GetArgFn<
|
|
51
|
+
Selector,
|
|
52
|
+
Fns extends Record<'Args' | 'Arg' | 'Default', unknown>,
|
|
53
|
+
> = Selector extends `${string}$$${string}` ? Fns['Args']
|
|
54
|
+
: Selector extends `${string}$${string}` ? Fns['Arg']
|
|
55
|
+
: Fns['Default'];
|
|
56
|
+
|
|
57
|
+
type GetFn<
|
|
58
|
+
Selector,
|
|
59
|
+
Fns extends Record<
|
|
60
|
+
'MediaNoArg' | 'MediaArg' | 'MediaArgs' | 'AtRuleNoArg' | 'AtRuleArg' | 'AtRuleArgs' | 'Args' | 'Arg' | 'Default',
|
|
61
|
+
unknown
|
|
62
|
+
>,
|
|
63
|
+
> = Selector extends `@media${string}` | `@container${string}` ? GetArgFn<Selector, {
|
|
64
|
+
Args: Fns['MediaArgs'];
|
|
65
|
+
Arg: Fns['MediaArg'];
|
|
66
|
+
Default: Fns['MediaNoArg'];
|
|
67
|
+
}>
|
|
68
|
+
: Selector extends `@${string}` //
|
|
69
|
+
? GetArgFn<Selector, {
|
|
70
|
+
Args: Fns['AtRuleArgs'];
|
|
71
|
+
Arg: Fns['AtRuleArg'];
|
|
72
|
+
Default: Fns['AtRuleNoArg'];
|
|
73
|
+
}>
|
|
74
|
+
: GetArgFn<Selector, {
|
|
75
|
+
Args: Fns['Args'];
|
|
76
|
+
Arg: Fns['Arg'];
|
|
77
|
+
Default: Fns['Default'];
|
|
78
|
+
}>;
|
|
79
|
+
|
|
80
|
+
type GetStyleFn<Selector, Style, Self> = SelectorString<Selector> extends '...' ? StyleMergeFn<Style, Self>
|
|
81
|
+
: GetFn<SelectorString<Selector>, {
|
|
82
|
+
MediaNoArg: StyleMediaNoArgFn<Style, Self>;
|
|
83
|
+
MediaArgs: StyleMediaArgsFn<Style, Self, SelectorArg<Selector>>;
|
|
84
|
+
MediaArg: StyleMediaArgFn<Style, Self, SelectorArg<Selector>>;
|
|
85
|
+
AtRuleNoArg: StyleAtRuleNoArgFn<Style, Self>;
|
|
86
|
+
AtRuleArgs: StyleAtRuleArgsFn<Style, Self, SelectorArg<Selector>>;
|
|
87
|
+
AtRuleArg: StyleAtRuleArgFn<Style, Self, SelectorArg<Selector>>;
|
|
88
|
+
Args: StyleArgsFn<Style, Self, SelectorArg<Selector>>;
|
|
89
|
+
Arg: StyleArgFn<Style, Self, SelectorArg<Selector>>;
|
|
90
|
+
Default: StyleFn<Style, Self>;
|
|
91
|
+
}>;
|
|
92
|
+
|
|
93
|
+
/* scope */
|
|
94
|
+
|
|
95
|
+
type ScopeFn<Style, Result> = {
|
|
96
|
+
(styles: Style): Result;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type ScopeArgFn<Style, Result, Arg extends string> = {
|
|
100
|
+
(selector: Arg, styles: Style): Result;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
type ScopeArgsFn<Style, Result, Arg extends string> = {
|
|
104
|
+
(selector: Arg | Arg[], styles: Style): Result;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type ScopeAtRuleFn<Style, Result, Arg> = {
|
|
108
|
+
(selector: Arg, styles: Style): Result;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type ScopeAtRuleNoArgFn<Style, Result> = {
|
|
112
|
+
(styles: Style): Result;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
type ScopeMediaFn<Style, Result, Arg> = ScopeAtRuleFn<Style, Result, Arg> & {
|
|
116
|
+
(priority: number, selector: Arg, styles: Style): Result;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type ScopeMediaNoArgFn<Style, Result> = ScopeAtRuleNoArgFn<Style, Result> & {
|
|
120
|
+
(priority: number, styles: Style): Result;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
type ScopeAtRuleArgFn<Style, Result, Arg extends string> = ScopeAtRuleFn<Style, Result, Arg>;
|
|
124
|
+
type ScopeAtRuleArgsFn<Style, Result, Arg extends string> = ScopeAtRuleFn<Style, Result, Arg | Arg[]>;
|
|
125
|
+
|
|
126
|
+
type ScopeMediaArgFn<Style, Result, Arg extends string> = ScopeMediaFn<Style, Result, Arg>;
|
|
127
|
+
type ScopeMediaArgsFn<Style, Result, Arg extends string> = ScopeMediaFn<Style, Result, Arg | Arg[]>;
|
|
128
|
+
|
|
129
|
+
type GetScopeFn<Selector, Style, Result> = GetFn<SelectorString<Selector>, {
|
|
130
|
+
MediaNoArg: ScopeMediaNoArgFn<Style, Result>;
|
|
131
|
+
MediaArgs: ScopeMediaArgsFn<Style, Result, SelectorArg<Selector>>;
|
|
132
|
+
MediaArg: ScopeMediaArgFn<Style, Result, SelectorArg<Selector>>;
|
|
133
|
+
AtRuleNoArg: ScopeAtRuleNoArgFn<Style, Result>;
|
|
134
|
+
AtRuleArgs: ScopeAtRuleArgsFn<Style, Result, SelectorArg<Selector>>;
|
|
135
|
+
AtRuleArg: ScopeAtRuleArgFn<Style, Result, SelectorArg<Selector>>;
|
|
136
|
+
Args: ScopeArgsFn<Style, Result, SelectorArg<Selector>>;
|
|
137
|
+
Arg: ScopeArgFn<Style, Result, SelectorArg<Selector>>;
|
|
138
|
+
Default: ScopeFn<Style, Result>;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
/* selector fns */
|
|
142
|
+
|
|
143
|
+
export type StyleSelfFn<Style, Selectors> = (
|
|
144
|
+
style?: StyleObject<Style>,
|
|
145
|
+
) => ReturnType<typeof styleRule<Style, Selectors>>;
|
|
146
|
+
|
|
147
|
+
export type SlotSelfFn<Style, Selectors> = (
|
|
148
|
+
style?: StyleObject<Style>,
|
|
149
|
+
) => ReturnType<typeof slotRule<Style, Selectors>>;
|
|
150
|
+
|
|
151
|
+
export type ScopeSelfFn<Style, Selectors> = (
|
|
152
|
+
styles?: ScopeItems<Style>,
|
|
153
|
+
) => ReturnType<typeof scopeRule<Style, Selectors>>;
|
|
154
|
+
|
|
155
|
+
export type StyleSelectorFns<Style, Selectors> = {
|
|
156
|
+
[P in keyof Selectors]: GetStyleFn<
|
|
157
|
+
Selectors[P],
|
|
158
|
+
Style,
|
|
159
|
+
ReturnType<typeof styleRule<Style, Selectors>>
|
|
160
|
+
>;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type SlotSelectorFns<Style, Selectors> = {
|
|
164
|
+
[P in keyof Selectors]: GetStyleFn<
|
|
165
|
+
Selectors[P],
|
|
166
|
+
Style,
|
|
167
|
+
ReturnType<typeof slotRule<Style, Selectors>>
|
|
168
|
+
>;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export type SlotOverrideSelectorFns<Style, Selectors> = {
|
|
172
|
+
[P in keyof Selectors]: GetStyleFn<
|
|
173
|
+
Selectors[P],
|
|
174
|
+
Style,
|
|
175
|
+
ReturnType<typeof slotOverrideRule<Style, Selectors>>
|
|
176
|
+
>;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type ScopeSelectorFns<Style, Selectors> = {
|
|
180
|
+
[P in keyof Selectors]: GetScopeFn<
|
|
181
|
+
Selectors[P],
|
|
182
|
+
ScopeItems<Style>,
|
|
183
|
+
ReturnType<typeof scopeRule<Style, Selectors>>
|
|
184
|
+
>;
|
|
185
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Selector } from '../../selector';
|
|
2
|
+
import type { StyleObject } from '../../style/types';
|
|
3
|
+
import type { ScopeData, SlotData, SlotOverrideData, StyleData } from '../data';
|
|
4
|
+
import type { ScopeSelectorFns, ScopeSelfFn, SlotOverrideSelectorFns, SlotSelectorFns, StyleSelectorFns } from './fns';
|
|
5
|
+
|
|
6
|
+
export type { ScopeSelfFn };
|
|
7
|
+
|
|
8
|
+
export type MergeRuleStyleData<Style = unknown> = StyleData<Style> | StyleData<Style>[];
|
|
9
|
+
|
|
10
|
+
export type AtRuleStyleData<Style = unknown> = StyleObject<Style> | StyleData<Style>;
|
|
11
|
+
|
|
12
|
+
export type SelectorsRecord = Record<string, Selector>;
|
|
13
|
+
|
|
14
|
+
export type SelectItemFalsy = false | null | undefined;
|
|
15
|
+
export type SelectItems<Item> =
|
|
16
|
+
| Item
|
|
17
|
+
| (Item | SelectItemFalsy)[];
|
|
18
|
+
|
|
19
|
+
export type StyleBuilderFns<Style, Selectors> =
|
|
20
|
+
& StyleSelectorFns<Style, Selectors>
|
|
21
|
+
& {};
|
|
22
|
+
|
|
23
|
+
export type SlotBuilderFns<Style, Selectors> =
|
|
24
|
+
& SlotSelectorFns<Style, Selectors>
|
|
25
|
+
& {};
|
|
26
|
+
|
|
27
|
+
export type SlotOverrideBuilderFns<Style, Selectors> =
|
|
28
|
+
& SlotOverrideSelectorFns<Style, Selectors>
|
|
29
|
+
& {};
|
|
30
|
+
|
|
31
|
+
export type ScopeFns<Style, Selectors> =
|
|
32
|
+
& ScopeSelectorFns<Style, Selectors>
|
|
33
|
+
& {};
|
|
34
|
+
|
|
35
|
+
export type StyleBuilder<Style, Selectors> =
|
|
36
|
+
& StyleData<Style>
|
|
37
|
+
& StyleBuilderFns<Style, Selectors>;
|
|
38
|
+
|
|
39
|
+
export type SlotBuilder<Style, Selectors> =
|
|
40
|
+
& SlotData<Style>
|
|
41
|
+
& ((style?: StyleObject<Style>) => SlotOverrideBuilder<Style, Selectors>)
|
|
42
|
+
& SlotBuilderFns<Style, Selectors>;
|
|
43
|
+
|
|
44
|
+
export type SlotOverrideBuilder<Style, Selectors> =
|
|
45
|
+
& SlotOverrideData<Style>
|
|
46
|
+
& SlotOverrideBuilderFns<Style, Selectors>;
|
|
47
|
+
|
|
48
|
+
export type ScopeBuilder<Style, Selectors> =
|
|
49
|
+
& ScopeData<Style>
|
|
50
|
+
& ScopeFns<Style, Selectors>
|
|
51
|
+
& {};
|
package/builder/utils.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StyleObject, StyleTransform } from '../style';
|
|
2
|
+
import { traceCallsite } from '../utils/trace';
|
|
3
|
+
import { type DebugData, getDebugCallsite } from './data/debug';
|
|
4
|
+
|
|
5
|
+
export const FnPrefixStyle = 'style.';
|
|
6
|
+
export const FnPrefixSlot = 'slot.';
|
|
7
|
+
export const FnPrefixScope = 'scope.';
|
|
8
|
+
|
|
9
|
+
export function runtimeCallsite() {
|
|
10
|
+
return traceCallsite();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function resolveCallsite(debug: DebugData | null | undefined) {
|
|
14
|
+
return debug ? getDebugCallsite(debug) : runtimeCallsite();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function transformStyle<Style>(style: StyleObject<Style>, transform: StyleTransform<Style> | null) {
|
|
18
|
+
return transform ? transform.transform(style) : style;
|
|
19
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as crypto from 'node:crypto';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
|
|
5
|
+
export type CompilerCacheArgs = {
|
|
6
|
+
cacheDir: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type CompilerCacheFile<T = unknown> = {
|
|
10
|
+
filePath: string;
|
|
11
|
+
contentHash: string;
|
|
12
|
+
cacheContent: T;
|
|
13
|
+
cacheType: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type CompilerCacheGetItemArgs = {
|
|
17
|
+
filePath: string;
|
|
18
|
+
contentHash: string;
|
|
19
|
+
cacheType: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type CompilerCacheSetItemArgs<T = unknown> = CompilerCacheGetItemArgs & {
|
|
23
|
+
cacheContent: T;
|
|
24
|
+
persistent?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type CacheItem<T = unknown> = {
|
|
28
|
+
contentHash: string;
|
|
29
|
+
cacheContent: T;
|
|
30
|
+
cacheType: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type CompilerCache = ReturnType<typeof createCompilerCache>;
|
|
34
|
+
|
|
35
|
+
export function createCompilerCache(args: CompilerCacheArgs) {
|
|
36
|
+
const { cacheDir } = args;
|
|
37
|
+
|
|
38
|
+
const cache = new Map<string, CacheItem>();
|
|
39
|
+
|
|
40
|
+
const getItem = <T>(args: CompilerCacheGetItemArgs): T | null => {
|
|
41
|
+
const key = getCacheKey(args);
|
|
42
|
+
|
|
43
|
+
const cached = cache.get(key);
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
cached &&
|
|
47
|
+
cached.contentHash === args.contentHash &&
|
|
48
|
+
cached.cacheType === args.cacheType
|
|
49
|
+
) {
|
|
50
|
+
return cached.cacheContent as T;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const file = getCacheFile<T>(cacheDir, args);
|
|
54
|
+
if (!file) return null;
|
|
55
|
+
|
|
56
|
+
cache.set(key, {
|
|
57
|
+
contentHash: file.contentHash,
|
|
58
|
+
cacheContent: file.cacheContent,
|
|
59
|
+
cacheType: file.cacheType,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return file.cacheContent as T;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const setItem = <T>(args: CompilerCacheSetItemArgs<T>) => {
|
|
66
|
+
const key = getCacheKey(args);
|
|
67
|
+
|
|
68
|
+
cache.set(key, {
|
|
69
|
+
contentHash: args.contentHash,
|
|
70
|
+
cacheContent: args.cacheContent,
|
|
71
|
+
cacheType: args.cacheType,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
saveCacheFile(cacheDir, args);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const clear = () => {
|
|
78
|
+
cache.clear();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
getItem,
|
|
83
|
+
setItem,
|
|
84
|
+
clear,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getCacheFile<TCacheContent>(
|
|
89
|
+
cacheDir: string,
|
|
90
|
+
args: CompilerCacheGetItemArgs,
|
|
91
|
+
): CompilerCacheFile<TCacheContent> | null {
|
|
92
|
+
const filePath = getCacheFilePath(cacheDir, args);
|
|
93
|
+
|
|
94
|
+
let raw: string;
|
|
95
|
+
let file: CompilerCacheFile<TCacheContent>;
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
file = JSON.parse(raw) as CompilerCacheFile<TCacheContent>;
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
file.filePath !== args.filePath ||
|
|
111
|
+
file.contentHash !== args.contentHash ||
|
|
112
|
+
file.cacheType !== args.cacheType
|
|
113
|
+
) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return file;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function saveCacheFile<TCacheContent>(
|
|
121
|
+
cacheDir: string,
|
|
122
|
+
args: CompilerCacheSetItemArgs<TCacheContent>,
|
|
123
|
+
): void {
|
|
124
|
+
if (args.persistent === false) return;
|
|
125
|
+
|
|
126
|
+
const filePath = getCacheFilePath(cacheDir, args);
|
|
127
|
+
|
|
128
|
+
const cacheFile: CompilerCacheFile<TCacheContent> = {
|
|
129
|
+
filePath: args.filePath,
|
|
130
|
+
contentHash: args.contentHash,
|
|
131
|
+
cacheContent: args.cacheContent,
|
|
132
|
+
cacheType: args.cacheType,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
137
|
+
fs.writeFileSync(filePath, JSON.stringify(cacheFile), 'utf8');
|
|
138
|
+
} catch {
|
|
139
|
+
// cache writes are best-effort
|
|
140
|
+
// a failed cache should not fail compilation.
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function getCacheFilePath(cacheDir: string, args: CompilerCacheGetItemArgs): string {
|
|
145
|
+
return path.join(cacheDir, args.cacheType, getCacheKey(args) + '.json');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getCacheKey(args: CompilerCacheGetItemArgs): string {
|
|
149
|
+
return crypto
|
|
150
|
+
.createHash('md5')
|
|
151
|
+
.update(args.cacheType)
|
|
152
|
+
.update('\0')
|
|
153
|
+
.update(path.resolve(args.filePath))
|
|
154
|
+
.digest('hex');
|
|
155
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createCssCollector, extractCss } from '../extract';
|
|
2
|
+
import { createTracer, transformDebug, transformExtract } from '../transform';
|
|
3
|
+
import { getDebugSourceUrl } from '../transform/debug/utils/source_url';
|
|
4
|
+
import { rewriteImportSources } from '../transform/utils/import';
|
|
5
|
+
import {
|
|
6
|
+
STYLE_CSS_IMPORT_PATH,
|
|
7
|
+
STYLE_DEV_RSC_IMPORT_PATH,
|
|
8
|
+
STYLE_EXTRACT_RUNTIME_IMPORT_PATH,
|
|
9
|
+
STYLE_IMPORT_PATH,
|
|
10
|
+
} from '../utils/constants';
|
|
11
|
+
import { clearResolverCache } from '../utils/file_resolver';
|
|
12
|
+
import {
|
|
13
|
+
getStyleExtractRuntimeImportPath,
|
|
14
|
+
getStyleRuntimeCssImportPath,
|
|
15
|
+
getStyleRuntimeDevRscImportPath,
|
|
16
|
+
getStyleRuntimeImportPath,
|
|
17
|
+
} from '../utils/imports';
|
|
18
|
+
import { createCompilerCache } from './cache';
|
|
19
|
+
import type {
|
|
20
|
+
CompilerInvalidateFileInfo,
|
|
21
|
+
CompilerOptions,
|
|
22
|
+
TransformDebugArgs,
|
|
23
|
+
TransformDebugResult,
|
|
24
|
+
TransformDebugRscResult,
|
|
25
|
+
TransformExtractArgs,
|
|
26
|
+
TransformExtractResult,
|
|
27
|
+
} from './types';
|
|
28
|
+
|
|
29
|
+
export enum CompilerRuntimeMode {
|
|
30
|
+
Dev = 'dev',
|
|
31
|
+
Prod = 'prod',
|
|
32
|
+
RscDev = 'rsc-dev',
|
|
33
|
+
RscProd = 'rsc-prod',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type CompilerArgs = {
|
|
37
|
+
projectDir: string;
|
|
38
|
+
cacheDir: string;
|
|
39
|
+
runtimeMode: CompilerRuntimeMode | null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type Compiler = ReturnType<typeof createCompiler>;
|
|
43
|
+
|
|
44
|
+
export type CompilerInternal = ReturnType<typeof createCompilerInternal>;
|
|
45
|
+
|
|
46
|
+
export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
47
|
+
const internal = createCompilerInternal(args, options);
|
|
48
|
+
|
|
49
|
+
const tracer = createTracer(internal);
|
|
50
|
+
const collector = createCssCollector();
|
|
51
|
+
|
|
52
|
+
const compileDebug = (args: TransformDebugArgs): TransformDebugResult | null => {
|
|
53
|
+
return rewriteTransformResult(
|
|
54
|
+
transformDebug(internal, args, { tracer }),
|
|
55
|
+
internal.runtimeMode,
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const compileDebugRSC = (args: TransformDebugArgs): TransformDebugRscResult | null => {
|
|
60
|
+
const debugResult = rewriteTransformResult(
|
|
61
|
+
transformDebug(internal, args, { tracer }),
|
|
62
|
+
internal.runtimeMode,
|
|
63
|
+
);
|
|
64
|
+
if (!debugResult) return null;
|
|
65
|
+
|
|
66
|
+
const rscCollector = createCssCollector();
|
|
67
|
+
|
|
68
|
+
const styleFilePath = getDebugSourceUrl(
|
|
69
|
+
args.filePath,
|
|
70
|
+
args.filePath,
|
|
71
|
+
internal.projectDir,
|
|
72
|
+
options,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
transformExtract(internal, args, {
|
|
76
|
+
collector: rscCollector,
|
|
77
|
+
mode: 'collect',
|
|
78
|
+
styleFilePath,
|
|
79
|
+
tracer,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const rules = rscCollector.getItems();
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
...debugResult,
|
|
86
|
+
css: extractCss(rules, {
|
|
87
|
+
...options.css,
|
|
88
|
+
layer: options.css?.layer,
|
|
89
|
+
}),
|
|
90
|
+
rules,
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const compileExtract = (args: TransformExtractArgs): TransformExtractResult | null => {
|
|
95
|
+
const startIndex = collector.getItems().length;
|
|
96
|
+
|
|
97
|
+
const result = transformExtract(internal, args, {
|
|
98
|
+
collector,
|
|
99
|
+
tracer,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (!result) return null;
|
|
103
|
+
|
|
104
|
+
return rewriteTransformResult({
|
|
105
|
+
...result,
|
|
106
|
+
rules: collector.getItems().slice(startIndex),
|
|
107
|
+
}, internal.runtimeMode);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const getExtractedCss = () => {
|
|
111
|
+
return extractCss(collector.getItems(), {
|
|
112
|
+
...options.css,
|
|
113
|
+
layer: options.css?.layer,
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const invalidateFile = (_info: CompilerInvalidateFileInfo) => {
|
|
118
|
+
internal.cache.clear();
|
|
119
|
+
clearResolverCache();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
compileDebug,
|
|
124
|
+
compileDebugRSC,
|
|
125
|
+
compileExtract,
|
|
126
|
+
getExtractedCss,
|
|
127
|
+
invalidateFile,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function createCompilerInternal(args: CompilerArgs, options: CompilerOptions) {
|
|
132
|
+
const { projectDir, cacheDir, runtimeMode } = args;
|
|
133
|
+
|
|
134
|
+
const cache = createCompilerCache({ cacheDir });
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
projectDir,
|
|
138
|
+
cacheDir,
|
|
139
|
+
runtimeMode,
|
|
140
|
+
cache,
|
|
141
|
+
options,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function rewriteTransformResult<Result extends { code: string; }>(
|
|
146
|
+
result: Result | null,
|
|
147
|
+
runtimeMode: CompilerRuntimeMode | null,
|
|
148
|
+
) {
|
|
149
|
+
if (!result || !runtimeMode) return result;
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
...result,
|
|
153
|
+
code: rewriteCompilerRuntimeImports(result.code, runtimeMode),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function rewriteCompilerRuntimeImports(code: string, runtimeMode: CompilerRuntimeMode) {
|
|
158
|
+
return rewriteImportSources(
|
|
159
|
+
code,
|
|
160
|
+
(source) => getCompilerRuntimeImportSource(source, runtimeMode),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRuntimeMode) {
|
|
165
|
+
if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(runtimeMode);
|
|
166
|
+
if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(runtimeMode);
|
|
167
|
+
if (source === STYLE_EXTRACT_RUNTIME_IMPORT_PATH) return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
168
|
+
if (runtimeMode === CompilerRuntimeMode.RscDev && source === STYLE_DEV_RSC_IMPORT_PATH) {
|
|
169
|
+
return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { CssConfig } from '../../config/config/css';
|
|
2
|
+
import type { DevRuntimeOptions } from '../../config/config/dev';
|
|
3
|
+
import type { CheckSelectorMode } from '../../config/types';
|
|
4
|
+
import type { ReplaceProps } from '../../utils/type';
|
|
5
|
+
import type { CssExtractRule } from '../extract';
|
|
6
|
+
import type { BabelTransformSourceMap } from '../transform/utils/babel';
|
|
7
|
+
import type { ImportSource } from '../utils/import_source';
|
|
8
|
+
import type { GetSourcemapFilePathFn } from '../utils/sourcemap';
|
|
9
|
+
|
|
10
|
+
export type CompilerCssOptions = Partial<CssConfig> & {
|
|
11
|
+
localClassName?: boolean;
|
|
12
|
+
debugClassName?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type CompilerDevOptions = ReplaceProps<DevRuntimeOptions, {
|
|
16
|
+
checkSelector?: CheckSelectorMode;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type DevSourcemapMode = 'sourceUrl' | 'sourceContent' | 'sidecarServer';
|
|
20
|
+
|
|
21
|
+
export type CompilerOptions = {
|
|
22
|
+
hoist?: boolean;
|
|
23
|
+
css?: CompilerCssOptions;
|
|
24
|
+
dev?: CompilerDevOptions;
|
|
25
|
+
|
|
26
|
+
importSources?: ImportSource[];
|
|
27
|
+
|
|
28
|
+
getSourcemapFilePath?: GetSourcemapFilePathFn;
|
|
29
|
+
devSourcemap?: DevSourcemapMode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type TransformDebugArgs = {
|
|
33
|
+
code: string;
|
|
34
|
+
sourcemap: BabelTransformSourceMap;
|
|
35
|
+
filePath: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type TransformDebugResult = {
|
|
39
|
+
code: string;
|
|
40
|
+
sourcemap: string | null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type TransformDebugRscResult = TransformDebugResult & {
|
|
44
|
+
css: string;
|
|
45
|
+
rules: CssExtractRule[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type TransformExtractArgs = {
|
|
49
|
+
code: string;
|
|
50
|
+
sourcemap: BabelTransformSourceMap;
|
|
51
|
+
filePath: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type TransformExtractResult = {
|
|
55
|
+
code: string;
|
|
56
|
+
rules: CssExtractRule[];
|
|
57
|
+
sourcemap: string | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type CompilerInvalidateFileInfo = {
|
|
61
|
+
filePath: string;
|
|
62
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CssExtractRule } from './types';
|
|
2
|
+
|
|
3
|
+
export type CompilerCssCollector = ReturnType<typeof createCssCollector>;
|
|
4
|
+
|
|
5
|
+
export function createCssCollector() {
|
|
6
|
+
let items: CssExtractRule[] = [];
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
add(item: CssExtractRule) {
|
|
10
|
+
items.push(item);
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
addMany(items: CssExtractRule[]) {
|
|
14
|
+
items.push(...items);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
getItems() {
|
|
18
|
+
return items;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
clear() {
|
|
22
|
+
items = [];
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|