@fluentic/style 0.1.0-beta.4 → 0.1.0-beta.6
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 +56 -1
- package/README.md +106 -31
- package/atomic/className.ts +29 -6
- package/atomic/debug/className/className.ts +10 -0
- package/atomic/rule.ts +6 -3
- package/atomic/utils/hash.ts +1 -65
- package/atomic/utils/selector.ts +14 -1
- package/builder/classname/class_name_builder.ts +68 -24
- package/builder/classname/fns.ts +2 -2
- package/builder/classname/types.ts +7 -0
- package/builder/data/const.ts +6 -0
- package/builder/data/create.ts +42 -0
- package/builder/data/data.ts +20 -1
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +23 -0
- package/builder/data/merge/scope.ts +20 -19
- package/builder/data/merge/style.ts +70 -20
- package/builder/data/state.ts +16 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +26 -0
- package/builder/extract/utils.ts +2 -0
- package/builder/extract/withTokens.ts +2 -1
- package/builder/selector_override.noop.ts +11 -0
- package/builder/selector_override.ts +30 -0
- package/builder/selector_override_core.ts +66 -0
- package/builder/style_builder.ts +127 -3
- package/builder/style_data.ts +24 -0
- package/builder/style_fns.ts +24 -24
- package/builder/types/alias.ts +34 -6
- package/builder/types/fns.ts +13 -5
- package/builder/types/types.ts +32 -2
- package/builder/utils.ts +1 -0
- package/compiler/compiler/compiler.ts +88 -14
- package/compiler/compiler/constants.ts +6 -0
- package/compiler/compiler/index.ts +1 -0
- package/compiler/compiler/types.ts +2 -0
- package/compiler/cssProp.ts +21 -0
- package/compiler/index.ts +1 -0
- package/compiler/transform/cssProp/index.ts +1 -0
- package/compiler/transform/cssProp/plugin.ts +161 -0
- package/compiler/transform/debug/plugin.ts +6 -0
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/evaluator/evaluator.ts +33 -4
- package/compiler/transform/evaluator/tracer.ts +30 -2
- package/compiler/transform/extract/chain/chain.ts +660 -73
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +1 -1
- package/compiler/transform/extract/plugin.ts +20 -4
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +47 -2
- package/compiler/transform/extract/utils/state.ts +2 -0
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/utils/constants.ts +8 -1
- package/compiler/utils/import_source.ts +17 -7
- package/compiler/utils/imports.ts +11 -1
- package/config/config/css.ts +1 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +119 -0
- package/css/styleTarget.ts +251 -0
- package/dist/adapter/preact.js +2 -0
- package/dist/adapter/react.js +2 -0
- package/dist/adapter/solid.js +2 -0
- package/dist/className-hiAsQ9V6.js +303 -0
- package/dist/className-hiAsQ9V6.js.map +1 -0
- package/dist/combine-D0AXSTn-.js +1279 -0
- package/dist/combine-D0AXSTn-.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-CE0ZgkdH.mjs → compiler-CCvRlaq0.mjs} +1467 -534
- package/dist/compiler-CCvRlaq0.mjs.map +1 -0
- package/dist/config-B-KbXpIh.js +6 -0
- package/dist/{config-oKOjOTWi.js.map → config-B-KbXpIh.js.map} +1 -1
- package/dist/config-B-w6rOe0.js +35 -0
- package/dist/config-B-w6rOe0.js.map +1 -0
- package/dist/{config-lJNLh7eM.js → config-B1WtpYar.js} +2 -2
- package/dist/{config-lJNLh7eM.js.map → config-B1WtpYar.js.map} +1 -1
- package/dist/{config-CduqubI8.js → config-CCMwA9Gm.js} +3 -3
- package/dist/config-CCMwA9Gm.js.map +1 -0
- package/dist/config-DOWSNV8w.js +1 -0
- package/dist/createTransformElement-PCilcudP.js +34 -0
- package/dist/createTransformElement-PCilcudP.js.map +1 -0
- package/dist/css-DirG7Jwu.js +1280 -0
- package/dist/css-DirG7Jwu.js.map +1 -0
- package/dist/css-GtUPEO9U.js.map +1 -1
- package/dist/css-nmclCl2P.js +479 -0
- package/dist/css-nmclCl2P.js.map +1 -0
- package/dist/css-shX7_73D.js +3894 -0
- package/dist/css-shX7_73D.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{data-D7NFt4JG.js → data-DUvixly5.js} +155 -61
- package/dist/data-DUvixly5.js.map +1 -0
- package/dist/{debug-Cvpo5cVu.js → debug-DJRCBKhM.js} +80 -5
- package/dist/debug-DJRCBKhM.js.map +1 -0
- package/dist/dev/rsc.js +5 -8
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-DdRWa6dJ.js → dev-Cwha8aAp.js} +4 -4
- package/dist/{dev-DdRWa6dJ.js.map → dev-Cwha8aAp.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-ng0y3fN0.js → elementMarker-Cb46vtLU.js} +94 -8
- package/dist/elementMarker-Cb46vtLU.js.map +1 -0
- package/dist/entry/dev/adapter/preact.js +12 -0
- package/dist/entry/dev/adapter/preact.js.map +1 -0
- package/dist/entry/dev/adapter/react.js +12 -0
- package/dist/entry/dev/adapter/react.js.map +1 -0
- package/dist/entry/dev/adapter/solid.js +12 -0
- package/dist/entry/dev/adapter/solid.js.map +1 -0
- package/dist/entry/dev/css.js +3 -3
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +10 -8
- package/dist/entry/prod/adapter/preact.js +12 -0
- package/dist/entry/prod/adapter/preact.js.map +1 -0
- package/dist/entry/prod/adapter/react.js +12 -0
- package/dist/entry/prod/adapter/react.js.map +1 -0
- package/dist/entry/prod/adapter/solid.js +12 -0
- package/dist/entry/prod/adapter/solid.js.map +1 -0
- package/dist/entry/prod/css.js +3 -3
- package/dist/entry/prod/extract.js +240 -3
- package/dist/entry/prod/extract.js.map +1 -0
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +3 -5
- package/dist/entry/prod.js +84 -1229
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/adapter/preact.js +13 -0
- package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/react.js +13 -0
- package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
- package/dist/entry/rsc-dev/adapter/solid.js +13 -0
- package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -3
- package/dist/entry/rsc-dev/dev.js +5 -10
- package/dist/entry/rsc-dev/dev.js.map +1 -1
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +252 -750
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/adapter/preact.js +2 -0
- package/dist/entry/rsc-prod/adapter/react.js +2 -0
- package/dist/entry/rsc-prod/adapter/solid.js +2 -0
- package/dist/entry/rsc-prod/css.js +9 -3
- package/dist/entry/rsc-prod/css.js.map +1 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +3 -5
- package/dist/entry/rsc-prod.js +236 -11
- package/dist/entry/rsc-prod.js.map +1 -1
- package/dist/{styleStore-CajcAEPO.js → env-0Gu2Jh47.js} +1148 -162
- package/dist/env-0Gu2Jh47.js.map +1 -0
- package/dist/getClassName-CHZKhmde.js +45 -0
- package/dist/getClassName-CHZKhmde.js.map +1 -0
- package/dist/{utils-B_VhPBHH.js → getClassName-CHd0iCXp.js} +28 -65
- package/dist/getClassName-CHd0iCXp.js.map +1 -0
- package/dist/getClassName-a6p2uMFM.js +536 -0
- package/dist/getClassName-a6p2uMFM.js.map +1 -0
- package/dist/{getClassName-CrNVjAoJ.js → getClassName-aD9zqg9U.js} +31 -10
- package/dist/getClassName-aD9zqg9U.js.map +1 -0
- package/dist/global-Dg37z0lV.js +14 -0
- package/dist/global-Dg37z0lV.js.map +1 -0
- package/dist/{hash-BfeJDf5U.js → hash-Cr-LCWDt.js} +35 -38
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +7 -6
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/jsx-BMFC8_tA.js +39 -0
- package/dist/jsx-BMFC8_tA.js.map +1 -0
- package/dist/{jsx_dev_runtime-aAhNYDeS.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
- package/dist/{jsx_dev_runtime-aAhNYDeS.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
- package/dist/{jsx_runtime-D7Y5up6H.js → jsx_runtime-BgK90E2O.js} +2 -3
- package/dist/{jsx_runtime-D7Y5up6H.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
- package/dist/{jsx_runtime-C6i1bWlu.js → jsx_runtime-Ch1pZ6-n.js} +2 -2
- package/dist/{jsx_runtime-C6i1bWlu.js.map → jsx_runtime-Ch1pZ6-n.js.map} +1 -1
- package/dist/{loader-BmYS_Rju.mjs → loader-hNaefW-U.mjs} +13 -14
- package/dist/loader-hNaefW-U.mjs.map +1 -0
- package/dist/{misc-BIS_c7BJ.mjs → misc-1OS0aeY1.mjs} +4 -4
- package/dist/misc-1OS0aeY1.mjs.map +1 -0
- package/dist/{namedTokens-CN_yhhik.js → namedTokens-mgRfd9hs.js} +3 -3
- package/dist/{namedTokens-CN_yhhik.js.map → namedTokens-mgRfd9hs.js.map} +1 -1
- package/dist/plugin/farm/index.mjs +4 -3
- package/dist/plugin/farm/index.mjs.map +1 -1
- package/dist/plugin/nextjs/index.mjs +121 -17
- package/dist/plugin/nextjs/index.mjs.map +1 -1
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/index.cjs +2 -0
- package/dist/plugin/parcel/index.mjs +3 -1
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +3 -2
- package/dist/plugin/rspack/index.mjs.map +1 -1
- package/dist/plugin/vite/index.mjs +6 -6
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +3 -2
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +26 -5
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-IaXmLQzA.mjs → registry-OA0niXJL.mjs} +2 -2
- package/dist/{registry-IaXmLQzA.mjs.map → registry-OA0niXJL.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-BKXT1bmR.js +63 -0
- package/dist/resolveClassNameRuntime-BKXT1bmR.js.map +1 -0
- package/dist/{rules-CxVzovt-.js → rules-DgcCENkw.js} +583 -154
- package/dist/rules-DgcCENkw.js.map +1 -0
- package/dist/{combine-C9vjpKCs.js → scope-BSuRLice.js} +239 -150
- package/dist/scope-BSuRLice.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +12 -9
- package/dist/server.js.map +1 -1
- package/dist/{shared-CaJuvw03.cjs → shared-Bc9RwNNj.cjs} +1473 -535
- package/dist/shared-Bc9RwNNj.cjs.map +1 -0
- package/dist/{shared-DdPTZ0O3.mjs → shared-COiLPdZ1.mjs} +4 -4
- package/dist/{shared-DdPTZ0O3.mjs.map → shared-COiLPdZ1.mjs.map} +1 -1
- package/dist/sheet-B87QCFWF.js +7 -0
- package/dist/{sheet-BWBzuy4D.js.map → sheet-B87QCFWF.js.map} +1 -1
- package/dist/{sidecar-B3oCK9vC.mjs → sidecar-ViZUL9B8.mjs} +3 -3
- package/dist/{sidecar-B3oCK9vC.mjs.map → sidecar-ViZUL9B8.mjs.map} +1 -1
- package/dist/{styleStore-0fARJlZV.js → styleStore-BlC8Ax9f.js} +3 -4
- package/dist/{styleStore-0fARJlZV.js.map → styleStore-BlC8Ax9f.js.map} +1 -1
- package/dist/styleStore-DHzH25A7.js +51 -0
- package/dist/styleStore-DHzH25A7.js.map +1 -0
- package/dist/{token-D-S-4_mN.js → token-CAQWMtan.js} +2 -2
- package/dist/{token-D-S-4_mN.js.map → token-CAQWMtan.js.map} +1 -1
- package/dist/{trace-CFnhyCVf.js → trace-D3yBmJad.js} +2 -2
- package/dist/{trace-CFnhyCVf.js.map → trace-D3yBmJad.js.map} +1 -1
- package/dist/{trace-ZtgeY-8s.js → trace-DdXWjgAD.js} +3 -3
- package/dist/{trace-ZtgeY-8s.js.map → trace-DdXWjgAD.js.map} +1 -1
- package/dist/{style-CGaJndOl.js → types-BhdAXX7z.js} +268 -89
- package/dist/types-BhdAXX7z.js.map +1 -0
- package/dist/utils-B6HVRX10.js +42 -0
- package/dist/utils-B6HVRX10.js.map +1 -0
- package/dist/{utils-B5Xqf1lV.mjs → utils-C7UalRKf.mjs} +41 -7
- package/dist/utils-C7UalRKf.mjs.map +1 -0
- package/dist/utils-CUl1BU40.js +72 -0
- package/dist/utils-CUl1BU40.js.map +1 -0
- package/dist/{utils-DzydRwYo.js → utils-Cd4wqN56.js} +142 -149
- package/dist/utils-Cd4wqN56.js.map +1 -0
- package/dist/{utils-DaAiEEIG.mjs → utils-DjxH0zc7.mjs} +3 -3
- package/dist/{utils-DaAiEEIG.mjs.map → utils-DjxH0zc7.mjs.map} +1 -1
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CpJpQ00y.js +145 -0
- package/dist/value-CpJpQ00y.js.map +1 -0
- package/dist/{webpack-CHydnRXB.mjs → webpack-6et2ZVI6.mjs} +5 -5
- package/dist/webpack-6et2ZVI6.mjs.map +1 -0
- package/entry/dev/adapter/preact.ts +8 -0
- package/entry/dev/adapter/react.ts +8 -0
- package/entry/dev/adapter/solid.ts +8 -0
- package/entry/prod/adapter/preact.ts +8 -0
- package/entry/prod/adapter/react.ts +8 -0
- package/entry/prod/adapter/solid.ts +8 -0
- package/entry/rsc_dev/adapter/preact.ts +9 -0
- package/entry/rsc_dev/adapter/react.ts +9 -0
- package/entry/rsc_dev/adapter/solid.ts +9 -0
- package/entry/rsc_prod/adapter/preact.ts +1 -0
- package/entry/rsc_prod/adapter/react.ts +1 -0
- package/entry/rsc_prod/adapter/solid.ts +1 -0
- package/entry/shared/config_dev.ts +1 -1
- package/jsx/types/index.ts +3 -0
- package/jsx/types/preact.ts +14 -0
- package/jsx/{types.ts → types/react.ts} +2 -2
- package/jsx/types/solid.ts +32 -0
- package/package.json +98 -22
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +3 -8
- package/plugin/bundler/vite/state.ts +2 -2
- package/plugin/bundler/webpack/plugin.ts +2 -1
- package/plugin/bundler/webpack/shared/loader.ts +9 -7
- package/plugin/nextjs/plugin.ts +208 -15
- package/plugin/nextjs/types.ts +1 -2
- package/plugin/nextjs/utils.ts +50 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +2 -2
- package/presets/tailwind/classname/transform.ts +32 -1
- package/runtime/adapter/utils.ts +120 -0
- package/runtime/core/cache/combine.ts +33 -4
- package/runtime/core/cache/item.ts +31 -12
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/prop.ts +7 -6
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +179 -5
- package/runtime/extract/getClassName.ts +49 -6
- package/runtime/sheet/rule.ts +3 -10
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +179 -5
- package/runtime/types.ts +3 -3
- package/style/classname.ts +12 -6
- package/style/important.ts +19 -0
- package/style/index.ts +2 -0
- package/style/style.ts +16 -4
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/weight.ts +21 -0
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-Do2Crx4b.js +0 -143
- package/dist/className-Do2Crx4b.js.map +0 -1
- package/dist/combine-C9vjpKCs.js.map +0 -1
- package/dist/combineStyle-DwAhsOmS.js +0 -26
- package/dist/combineStyle-DwAhsOmS.js.map +0 -1
- package/dist/compiler-CE0ZgkdH.mjs.map +0 -1
- package/dist/config-BE5D5x2N.js +0 -2
- package/dist/config-CduqubI8.js.map +0 -1
- package/dist/config-oKOjOTWi.js +0 -7
- package/dist/css-BewrRz3_.js +0 -243
- package/dist/css-BewrRz3_.js.map +0 -1
- package/dist/css-CiTI58yl.js +0 -1094
- package/dist/css-CiTI58yl.js.map +0 -1
- package/dist/css-Rc7ILf-3.js +0 -236
- package/dist/css-Rc7ILf-3.js.map +0 -1
- package/dist/cssIdent-BsyUXNNk.js +0 -38
- package/dist/cssIdent-BsyUXNNk.js.map +0 -1
- package/dist/cssVar-DGgQ2GIK.js +0 -92
- package/dist/cssVar-DGgQ2GIK.js.map +0 -1
- package/dist/css_extra-DYtS3g6Z.js +0 -8
- package/dist/css_extra-DYtS3g6Z.js.map +0 -1
- package/dist/data-D7NFt4JG.js.map +0 -1
- package/dist/debug-Cvpo5cVu.js.map +0 -1
- package/dist/dev-px0_6TNq.js +0 -81
- package/dist/dev-px0_6TNq.js.map +0 -1
- package/dist/elementMarker-ng0y3fN0.js.map +0 -1
- package/dist/extract-B-Vs88ME.js +0 -3
- package/dist/extract-CM8Fk2eK.js +0 -130
- package/dist/extract-CM8Fk2eK.js.map +0 -1
- package/dist/getClassName-CrNVjAoJ.js.map +0 -1
- package/dist/global-CZBlA9E7.js +0 -14
- package/dist/global-CZBlA9E7.js.map +0 -1
- package/dist/hash-BfeJDf5U.js.map +0 -1
- package/dist/jsx-BY1iFewe.js +0 -39
- package/dist/jsx-BY1iFewe.js.map +0 -1
- package/dist/jsx-DL-DEAz8.js +0 -39
- package/dist/jsx-DL-DEAz8.js.map +0 -1
- package/dist/layer-BSxAr-hy.js +0 -94
- package/dist/layer-BSxAr-hy.js.map +0 -1
- package/dist/loader-BmYS_Rju.mjs.map +0 -1
- package/dist/misc-BIS_c7BJ.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-BuLbzviK.js +0 -406
- package/dist/property-BuLbzviK.js.map +0 -1
- package/dist/rules-CxVzovt-.js.map +0 -1
- package/dist/selector-A-mRmMnI.js +0 -64
- package/dist/selector-A-mRmMnI.js.map +0 -1
- package/dist/shared-CaJuvw03.cjs.map +0 -1
- package/dist/sheet-BWBzuy4D.js +0 -7
- package/dist/style-CGaJndOl.js.map +0 -1
- package/dist/style-DDxjKdX0.js +0 -1891
- package/dist/style-DDxjKdX0.js.map +0 -1
- package/dist/style-S7LTQbRu.js +0 -5
- package/dist/styleStore-CajcAEPO.js.map +0 -1
- package/dist/symbols-Cp4ymzKF.js +0 -14
- package/dist/symbols-Cp4ymzKF.js.map +0 -1
- package/dist/utils-B5Xqf1lV.mjs.map +0 -1
- package/dist/utils-B_VhPBHH.js.map +0 -1
- package/dist/utils-CDUaX81o.js +0 -170
- package/dist/utils-CDUaX81o.js.map +0 -1
- package/dist/utils-DzydRwYo.js.map +0 -1
- package/dist/value-C0JRsyax.js +0 -64
- package/dist/value-C0JRsyax.js.map +0 -1
- package/dist/value-D08AocUs.js +0 -1053
- package/dist/value-D08AocUs.js.map +0 -1
- package/dist/valueRef-M3E1oza7.js +0 -16
- package/dist/valueRef-M3E1oza7.js.map +0 -1
- package/dist/webpack-CHydnRXB.mjs.map +0 -1
- package/dist/withTokens-DAzUIPvA.js +0 -95
- package/dist/withTokens-DAzUIPvA.js.map +0 -1
package/builder/style_fns.ts
CHANGED
|
@@ -168,35 +168,35 @@ function createAtRuleFn<Data extends BuilderData>(
|
|
|
168
168
|
debug?: DebugData,
|
|
169
169
|
];
|
|
170
170
|
|
|
171
|
-
type
|
|
171
|
+
type WeightParams = [weight: number, ...Params];
|
|
172
172
|
type SelfParams = [style: AtRuleStyleData, debug?: DebugData];
|
|
173
|
-
type
|
|
173
|
+
type WeightSelfParams = [weight: number, ...SelfParams];
|
|
174
174
|
|
|
175
175
|
return function(
|
|
176
176
|
this: Data,
|
|
177
|
-
...params: Params |
|
|
177
|
+
...params: Params | WeightParams | SelfParams | WeightSelfParams
|
|
178
178
|
) {
|
|
179
179
|
let arg: Params[0];
|
|
180
180
|
let style: Params[1];
|
|
181
181
|
let debug: Params[2];
|
|
182
|
-
let
|
|
182
|
+
let weight: number | null = null;
|
|
183
183
|
|
|
184
184
|
if (hasArg) {
|
|
185
185
|
if (isMedia && typeof params[0] === 'number') {
|
|
186
|
-
|
|
187
|
-
arg = (params as
|
|
188
|
-
style = (params as
|
|
189
|
-
debug = (params as
|
|
186
|
+
weight = (params as WeightParams)[0];
|
|
187
|
+
arg = (params as WeightParams)[1];
|
|
188
|
+
style = (params as WeightParams)[2];
|
|
189
|
+
debug = (params as WeightParams)[3];
|
|
190
190
|
} else {
|
|
191
191
|
arg = (params as Params)[0];
|
|
192
192
|
style = (params as Params)[1];
|
|
193
193
|
debug = (params as Params)[2];
|
|
194
194
|
}
|
|
195
195
|
} else if (isMedia && typeof params[0] === 'number') {
|
|
196
|
-
|
|
196
|
+
weight = (params as WeightSelfParams)[0];
|
|
197
197
|
arg = fnSelector.selector;
|
|
198
|
-
style = (params as
|
|
199
|
-
debug = (params as
|
|
198
|
+
style = (params as WeightSelfParams)[1];
|
|
199
|
+
debug = (params as WeightSelfParams)[2];
|
|
200
200
|
} else {
|
|
201
201
|
arg = fnSelector.selector;
|
|
202
202
|
style = (params as SelfParams)[0];
|
|
@@ -230,7 +230,7 @@ function createAtRuleFn<Data extends BuilderData>(
|
|
|
230
230
|
isStyleData(item) ? item : transformStyle(item as StyleObject, transform),
|
|
231
231
|
debug ?? null,
|
|
232
232
|
null,
|
|
233
|
-
[
|
|
233
|
+
[weight !== null ? [selector, weight] : selector],
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -425,35 +425,35 @@ function createScopeAtRuleFn(
|
|
|
425
425
|
debug?: DebugData,
|
|
426
426
|
];
|
|
427
427
|
|
|
428
|
-
type
|
|
428
|
+
type WeightParams = [weight: number, ...Params];
|
|
429
429
|
type SelfParams = [data: ScopeItems, debug?: DebugData];
|
|
430
|
-
type
|
|
430
|
+
type WeightSelfParams = [weight: number, ...SelfParams];
|
|
431
431
|
|
|
432
432
|
return function(
|
|
433
433
|
this: ScopeData,
|
|
434
|
-
...params: Params |
|
|
434
|
+
...params: Params | WeightParams | SelfParams | WeightSelfParams
|
|
435
435
|
) {
|
|
436
436
|
let arg: Params[0];
|
|
437
437
|
let data: Params[1];
|
|
438
438
|
let debug: Params[2];
|
|
439
|
-
let
|
|
439
|
+
let weight: number | null = null;
|
|
440
440
|
|
|
441
441
|
if (hasArg) {
|
|
442
442
|
if (isMedia && typeof params[0] === 'number') {
|
|
443
|
-
|
|
444
|
-
arg = (params as
|
|
445
|
-
data = (params as
|
|
446
|
-
debug = (params as
|
|
443
|
+
weight = (params as WeightParams)[0];
|
|
444
|
+
arg = (params as WeightParams)[1];
|
|
445
|
+
data = (params as WeightParams)[2];
|
|
446
|
+
debug = (params as WeightParams)[3];
|
|
447
447
|
} else {
|
|
448
448
|
arg = (params as Params)[0];
|
|
449
449
|
data = (params as Params)[1];
|
|
450
450
|
debug = (params as Params)[2];
|
|
451
451
|
}
|
|
452
452
|
} else if (isMedia && typeof params[0] === 'number') {
|
|
453
|
-
|
|
453
|
+
weight = (params as WeightSelfParams)[0];
|
|
454
454
|
arg = fnSelector.selector;
|
|
455
|
-
data = (params as
|
|
456
|
-
debug = (params as
|
|
455
|
+
data = (params as WeightSelfParams)[1];
|
|
456
|
+
debug = (params as WeightSelfParams)[2];
|
|
457
457
|
} else {
|
|
458
458
|
arg = fnSelector.selector;
|
|
459
459
|
data = (params as SelfParams)[0];
|
|
@@ -483,7 +483,7 @@ function createScopeAtRuleFn(
|
|
|
483
483
|
data,
|
|
484
484
|
debug ?? null,
|
|
485
485
|
null,
|
|
486
|
-
|
|
486
|
+
weight !== null ? [selector, weight] : selector,
|
|
487
487
|
cloneScope,
|
|
488
488
|
);
|
|
489
489
|
}
|
package/builder/types/alias.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import type { AtRuleRef, PlainStyleObject, StyleKeyframesObject, StyleObject,
|
|
1
|
+
import type { AtRuleRef, PlainStyleObject, StyleKeyframesObject, StyleObject, StyleWeightValue } from '../../style';
|
|
2
|
+
import type { StyleImportantValue } from '../../style/important';
|
|
2
3
|
import type { Collapse } from '../../utils/type';
|
|
3
|
-
import type { BUILDER_SLOT_ID } from '../data';
|
|
4
|
+
import type { BUILDER_SELECTOR, BUILDER_SLOT_ID } from '../data';
|
|
5
|
+
import type { ManualSelectorInput } from '../selector_override';
|
|
4
6
|
import type { ScopeSelfFn, SlotSelfFn, StyleSelfFn } from './fns';
|
|
5
|
-
import type { MergeRuleStyleData } from './types';
|
|
6
|
-
import type {
|
|
7
|
+
import type { MergeRuleStyleData, SelectorOverrideStyleData } from './types';
|
|
8
|
+
import type {
|
|
9
|
+
ScopeBuilder,
|
|
10
|
+
SelectorBuilder,
|
|
11
|
+
SelectorOverrideBuilder,
|
|
12
|
+
SlotBuilder,
|
|
13
|
+
SlotOverrideBuilder,
|
|
14
|
+
StyleBuilder,
|
|
15
|
+
} from './types';
|
|
7
16
|
|
|
8
17
|
type _ = typeof BUILDER_SLOT_ID;
|
|
18
|
+
type __ = typeof BUILDER_SELECTOR;
|
|
9
19
|
|
|
10
20
|
export function styleRule<Style, Selectors>() {
|
|
11
21
|
type StyleRule<Style> = StyleBuilder<Style, Selectors> & Collapse;
|
|
@@ -22,6 +32,11 @@ export function slotOverrideRule<Style, Selectors>() {
|
|
|
22
32
|
return {} as SlotOverrideRule<Style>;
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
export function selectorOverrideRule<Style, Selectors>() {
|
|
36
|
+
type SelectorOverrideRule<Style> = SelectorOverrideBuilder<Style, Selectors> & Collapse;
|
|
37
|
+
return {} as SelectorOverrideRule<Style>;
|
|
38
|
+
}
|
|
39
|
+
|
|
25
40
|
export function scopeRule<Selectors>() {
|
|
26
41
|
type ScopeRule = ScopeBuilder<Selectors> & Collapse;
|
|
27
42
|
return {} as ScopeRule;
|
|
@@ -33,20 +48,25 @@ export function typeAliases<Style, Selectors>() {
|
|
|
33
48
|
type StyleRule<Style> = ReturnType<typeof styleRule<Style, Selectors>>;
|
|
34
49
|
type SlotRule<Style> = ReturnType<typeof slotRule<Style, Selectors>>;
|
|
35
50
|
type SlotOverrideRule<Style> = ReturnType<typeof slotOverrideRule<Style, Selectors>>;
|
|
51
|
+
type SelectorOverrideRule<Style> = ReturnType<typeof selectorOverrideRule<Style, Selectors>>;
|
|
36
52
|
type ScopeRule = ReturnType<typeof scopeRule<Selectors>>;
|
|
37
53
|
|
|
38
54
|
type StyleFn<Style> = StyleSelfFn<Style, Selectors> & {
|
|
39
55
|
(style?: StyleObject<Style>): ReturnType<typeof styleRule<Style, Selectors>>;
|
|
40
56
|
slot: SlotFn<Style>;
|
|
41
57
|
scope: ScopeFn;
|
|
42
|
-
|
|
58
|
+
weight: ValueFn;
|
|
59
|
+
important: ImportantFn;
|
|
43
60
|
raw: RawFn<Style>;
|
|
44
61
|
plain: PlainFn<Style>;
|
|
45
62
|
keyframes: KeyframesFn<Style>;
|
|
46
63
|
merge: MergeFn;
|
|
64
|
+
selector: SelectorFn<Style>;
|
|
47
65
|
};
|
|
48
66
|
|
|
49
|
-
type ValueFn = <const T>(value: T, weight: number) =>
|
|
67
|
+
type ValueFn = <const T>(value: T, weight: number) => StyleWeightValue<T>;
|
|
68
|
+
|
|
69
|
+
type ImportantFn = <const T>(value: T) => StyleImportantValue<T>;
|
|
50
70
|
|
|
51
71
|
type RawFn<Style> = <T extends StyleObject<Style>>(style: T) => T;
|
|
52
72
|
|
|
@@ -56,6 +76,11 @@ export function typeAliases<Style, Selectors>() {
|
|
|
56
76
|
|
|
57
77
|
type MergeFn = <Target>(target: Target, ...styles: MergeRuleStyleData[]) => Target;
|
|
58
78
|
|
|
79
|
+
type SelectorFn<Style> = {
|
|
80
|
+
(selector: ManualSelectorInput): SelectorBuilder<Style, Selectors>;
|
|
81
|
+
(selector: ManualSelectorInput, style: SelectorOverrideStyleData<Style>): SelectorOverrideBuilder<Style, Selectors>;
|
|
82
|
+
};
|
|
83
|
+
|
|
59
84
|
type SlotFn<Style> = SlotSelfFn<Style, Selectors>;
|
|
60
85
|
|
|
61
86
|
type ScopeFn =
|
|
@@ -66,6 +91,7 @@ export function typeAliases<Style, Selectors>() {
|
|
|
66
91
|
StyleRule: StyleRule<Style>;
|
|
67
92
|
SlotRule: SlotRule<Style>;
|
|
68
93
|
SlotOverrideRule: SlotOverrideRule<Style>;
|
|
94
|
+
SelectorOverrideRule: SelectorOverrideRule<Style>;
|
|
69
95
|
ScopeRule: ScopeRule;
|
|
70
96
|
//
|
|
71
97
|
StyleFn: StyleFn<Style>;
|
|
@@ -73,10 +99,12 @@ export function typeAliases<Style, Selectors>() {
|
|
|
73
99
|
ScopeFn: ScopeFn;
|
|
74
100
|
//
|
|
75
101
|
ValueFn: ValueFn;
|
|
102
|
+
ImportantFn: ImportantFn;
|
|
76
103
|
RawFn: RawFn<Style>;
|
|
77
104
|
PlainFn: PlainFn<Style>;
|
|
78
105
|
KeyframesFn: KeyframesFn<Style>;
|
|
79
106
|
MergeFn: MergeFn;
|
|
107
|
+
SelectorFn: SelectorFn<Style>;
|
|
80
108
|
};
|
|
81
109
|
|
|
82
110
|
return {} as Types<Style>;
|
package/builder/types/fns.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Selector } from '../../selector';
|
|
2
2
|
import type { StyleObject } from '../../style/types';
|
|
3
3
|
import type { ScopeItems } from '../data/merge/scope';
|
|
4
|
-
import type { scopeRule, slotOverrideRule, slotRule, styleRule } from './alias';
|
|
4
|
+
import type { scopeRule, selectorOverrideRule, slotOverrideRule, slotRule, styleRule } from './alias';
|
|
5
5
|
import type { AtRuleStyleData, MergeRuleStyleData } from './types';
|
|
6
6
|
|
|
7
7
|
/* style */
|
|
@@ -31,11 +31,11 @@ type StyleAtRuleNoArgFn<Style, Self> = {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
type StyleMediaFn<Style, Self, Arg> = StyleAtRuleFn<Style, Self, Arg> & {
|
|
34
|
-
(
|
|
34
|
+
(weight: number, selector: Arg, style: AtRuleStyleData<Style>): Self;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
type StyleMediaNoArgFn<Style, Self> = StyleAtRuleNoArgFn<Style, Self> & {
|
|
38
|
-
(
|
|
38
|
+
(weight: number, style: AtRuleStyleData<Style>): Self;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
type StyleAtRuleArgFn<Style, Self, Arg extends string> = StyleAtRuleFn<Style, Self, Arg>;
|
|
@@ -113,11 +113,11 @@ type ScopeAtRuleNoArgFn<Style, Result> = {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
type ScopeMediaFn<Style, Result, Arg> = ScopeAtRuleFn<Style, Result, Arg> & {
|
|
116
|
-
(
|
|
116
|
+
(weight: number, selector: Arg, styles: Style): Result;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
type ScopeMediaNoArgFn<Style, Result> = ScopeAtRuleNoArgFn<Style, Result> & {
|
|
120
|
-
(
|
|
120
|
+
(weight: number, styles: Style): Result;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
type ScopeAtRuleArgFn<Style, Result, Arg extends string> = ScopeAtRuleFn<Style, Result, Arg>;
|
|
@@ -176,6 +176,14 @@ export type SlotOverrideSelectorFns<Style, Selectors> = {
|
|
|
176
176
|
>;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
export type SelectorOverrideSelectorFns<Style, Selectors> = {
|
|
180
|
+
[P in keyof Selectors]: GetStyleFn<
|
|
181
|
+
Selectors[P],
|
|
182
|
+
Style,
|
|
183
|
+
ReturnType<typeof selectorOverrideRule<Style, Selectors>>
|
|
184
|
+
>;
|
|
185
|
+
};
|
|
186
|
+
|
|
179
187
|
export type ScopeSelectorFns<Selectors> = {
|
|
180
188
|
[P in keyof Selectors]: GetScopeFn<
|
|
181
189
|
Selectors[P],
|
package/builder/types/types.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import type { Selector } from '../../selector';
|
|
2
2
|
import type { StyleObject } from '../../style/types';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DebugData,
|
|
5
|
+
ScopeData,
|
|
6
|
+
SelectorData,
|
|
7
|
+
SelectorOverrideData,
|
|
8
|
+
SlotData,
|
|
9
|
+
SlotOverrideData,
|
|
10
|
+
StyleData,
|
|
11
|
+
} from '../data';
|
|
12
|
+
import type {
|
|
13
|
+
ScopeSelectorFns,
|
|
14
|
+
ScopeSelfFn,
|
|
15
|
+
SelectorOverrideSelectorFns,
|
|
16
|
+
SlotOverrideSelectorFns,
|
|
17
|
+
SlotSelectorFns,
|
|
18
|
+
StyleSelectorFns,
|
|
19
|
+
} from './fns';
|
|
5
20
|
|
|
6
21
|
export type { ScopeSelfFn };
|
|
7
22
|
|
|
8
23
|
export type MergeRuleStyleData<Style = unknown> = StyleData<Style> | StyleData<Style>[];
|
|
9
24
|
|
|
10
25
|
export type AtRuleStyleData<Style = unknown> = StyleObject<Style> | StyleData<Style>;
|
|
26
|
+
export type SelectorOverrideStyleData<Style = unknown> = StyleObject<Style> | StyleData<Style>;
|
|
11
27
|
|
|
12
28
|
export type SelectorsRecord = Record<string, Selector>;
|
|
13
29
|
|
|
@@ -28,6 +44,10 @@ export type SlotOverrideBuilderFns<Style, Selectors> =
|
|
|
28
44
|
& SlotOverrideSelectorFns<Style, Selectors>
|
|
29
45
|
& {};
|
|
30
46
|
|
|
47
|
+
export type SelectorOverrideBuilderFns<Style, Selectors> =
|
|
48
|
+
& SelectorOverrideSelectorFns<Style, Selectors>
|
|
49
|
+
& {};
|
|
50
|
+
|
|
31
51
|
export type ScopeFns<Selectors> =
|
|
32
52
|
& ScopeSelectorFns<Selectors>
|
|
33
53
|
& {};
|
|
@@ -49,3 +69,13 @@ export type ScopeBuilder<Selectors> =
|
|
|
49
69
|
& ScopeData
|
|
50
70
|
& ScopeFns<Selectors>
|
|
51
71
|
& {};
|
|
72
|
+
|
|
73
|
+
export type SelectorBuilder<Style, Selectors> =
|
|
74
|
+
& SelectorData<Style>
|
|
75
|
+
& ((style?: SelectorOverrideStyleData<Style>, debug?: DebugData) => SelectorOverrideBuilder<Style, Selectors>)
|
|
76
|
+
& SelectorOverrideBuilderFns<Style, Selectors>;
|
|
77
|
+
|
|
78
|
+
export type SelectorOverrideBuilder<Style, Selectors> =
|
|
79
|
+
& SelectorOverrideData<Style>
|
|
80
|
+
& ((style?: SelectorOverrideStyleData<Style>) => SelectorOverrideBuilder<Style, Selectors>)
|
|
81
|
+
& SelectorOverrideBuilderFns<Style, Selectors>;
|
package/builder/utils.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type DebugData, getDebugCallsite } from './data/debug';
|
|
|
5
5
|
export const FnPrefixStyle = 'style.';
|
|
6
6
|
export const FnPrefixSlot = 'slot.';
|
|
7
7
|
export const FnPrefixScope = 'scope.';
|
|
8
|
+
export const FnPrefixSelector = 'selector.';
|
|
8
9
|
|
|
9
10
|
export function runtimeCallsite() {
|
|
10
11
|
return traceCallsite();
|
|
@@ -11,11 +11,13 @@ import {
|
|
|
11
11
|
import { clearResolverCache } from '../utils/file_resolver';
|
|
12
12
|
import {
|
|
13
13
|
getStyleExtractRuntimeImportPath,
|
|
14
|
+
getStyleRuntimeAdapterImportPath,
|
|
14
15
|
getStyleRuntimeCssImportPath,
|
|
15
16
|
getStyleRuntimeDevRscImportPath,
|
|
16
17
|
getStyleRuntimeImportPath,
|
|
17
18
|
} from '../utils/imports';
|
|
18
19
|
import { createCompilerCache } from './cache';
|
|
20
|
+
import { CompilerRuntimeMode } from './constants';
|
|
19
21
|
import type {
|
|
20
22
|
CompilerInvalidateFileInfo,
|
|
21
23
|
CompilerOptions,
|
|
@@ -26,13 +28,6 @@ import type {
|
|
|
26
28
|
TransformExtractResult,
|
|
27
29
|
} from './types';
|
|
28
30
|
|
|
29
|
-
export enum CompilerRuntimeMode {
|
|
30
|
-
Dev = 'dev',
|
|
31
|
-
Prod = 'prod',
|
|
32
|
-
RscDev = 'rsc-dev',
|
|
33
|
-
RscProd = 'rsc-prod',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
31
|
export type CompilerArgs = {
|
|
37
32
|
projectDir: string;
|
|
38
33
|
cacheDir: string;
|
|
@@ -53,6 +48,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
53
48
|
return rewriteTransformResult(
|
|
54
49
|
transformDebug(internal, args, { tracer }),
|
|
55
50
|
internal.runtimeMode,
|
|
51
|
+
args.code,
|
|
56
52
|
);
|
|
57
53
|
};
|
|
58
54
|
|
|
@@ -60,6 +56,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
60
56
|
const debugResult = rewriteTransformResult(
|
|
61
57
|
transformDebug(internal, args, { tracer }),
|
|
62
58
|
internal.runtimeMode,
|
|
59
|
+
args.code,
|
|
63
60
|
);
|
|
64
61
|
if (!debugResult) return null;
|
|
65
62
|
|
|
@@ -104,7 +101,7 @@ export function createCompiler(args: CompilerArgs, options: CompilerOptions) {
|
|
|
104
101
|
return rewriteTransformResult({
|
|
105
102
|
...result,
|
|
106
103
|
rules: collector.getItems().slice(startIndex),
|
|
107
|
-
}, internal.runtimeMode);
|
|
104
|
+
}, internal.runtimeMode, args.code);
|
|
108
105
|
};
|
|
109
106
|
|
|
110
107
|
const getExtractedCss = () => {
|
|
@@ -145,25 +142,46 @@ function createCompilerInternal(args: CompilerArgs, options: CompilerOptions) {
|
|
|
145
142
|
function rewriteTransformResult<Result extends { code: string; }>(
|
|
146
143
|
result: Result | null,
|
|
147
144
|
runtimeMode: CompilerRuntimeMode | null,
|
|
145
|
+
sourceCode: string,
|
|
148
146
|
) {
|
|
149
147
|
if (!result || !runtimeMode) return result;
|
|
150
148
|
|
|
151
149
|
return {
|
|
152
150
|
...result,
|
|
153
|
-
code: rewriteCompilerRuntimeImports(result.code, runtimeMode),
|
|
151
|
+
code: rewriteCompilerRuntimeImports(result.code, runtimeMode, sourceCode),
|
|
154
152
|
};
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
function rewriteCompilerRuntimeImports(
|
|
155
|
+
function rewriteCompilerRuntimeImports(
|
|
156
|
+
code: string,
|
|
157
|
+
runtimeMode: CompilerRuntimeMode,
|
|
158
|
+
sourceCode: string,
|
|
159
|
+
) {
|
|
160
|
+
const importRuntimeMode = getImportRuntimeMode(runtimeMode, sourceCode);
|
|
161
|
+
|
|
158
162
|
return rewriteImportSources(
|
|
159
163
|
code,
|
|
160
|
-
(source) => getCompilerRuntimeImportSource(source, runtimeMode),
|
|
164
|
+
(source) => getCompilerRuntimeImportSource(source, runtimeMode, importRuntimeMode),
|
|
161
165
|
);
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
function
|
|
165
|
-
if (
|
|
166
|
-
|
|
168
|
+
function getImportRuntimeMode(runtimeMode: CompilerRuntimeMode, sourceCode: string) {
|
|
169
|
+
if (runtimeMode === CompilerRuntimeMode.RscDev && hasUseClientDirective(sourceCode)) {
|
|
170
|
+
return CompilerRuntimeMode.Dev;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return runtimeMode;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getCompilerRuntimeImportSource(
|
|
177
|
+
source: string,
|
|
178
|
+
runtimeMode: CompilerRuntimeMode,
|
|
179
|
+
importRuntimeMode: CompilerRuntimeMode,
|
|
180
|
+
) {
|
|
181
|
+
if (source === STYLE_IMPORT_PATH) return getStyleRuntimeImportPath(importRuntimeMode);
|
|
182
|
+
const adapterImportPath = getStyleRuntimeAdapterImportPath(source, importRuntimeMode);
|
|
183
|
+
if (adapterImportPath) return adapterImportPath;
|
|
184
|
+
if (source === STYLE_CSS_IMPORT_PATH) return getStyleRuntimeCssImportPath(importRuntimeMode);
|
|
167
185
|
if (source === STYLE_EXTRACT_RUNTIME_IMPORT_PATH) return getStyleExtractRuntimeImportPath(runtimeMode);
|
|
168
186
|
if (runtimeMode === CompilerRuntimeMode.RscDev && source === STYLE_DEV_RSC_IMPORT_PATH) {
|
|
169
187
|
return getStyleRuntimeDevRscImportPath(runtimeMode);
|
|
@@ -171,3 +189,59 @@ function getCompilerRuntimeImportSource(source: string, runtimeMode: CompilerRun
|
|
|
171
189
|
|
|
172
190
|
return null;
|
|
173
191
|
}
|
|
192
|
+
|
|
193
|
+
function hasUseClientDirective(code: string) {
|
|
194
|
+
let index = 0;
|
|
195
|
+
|
|
196
|
+
while (index < code.length) {
|
|
197
|
+
index = skipWhitespaceAndComments(code, index);
|
|
198
|
+
|
|
199
|
+
const quote = code[index];
|
|
200
|
+
if (quote !== '"' && quote !== "'") return false;
|
|
201
|
+
|
|
202
|
+
const end = code.indexOf(quote, index + 1);
|
|
203
|
+
if (end < 0) return false;
|
|
204
|
+
|
|
205
|
+
const directive = code.slice(index + 1, end);
|
|
206
|
+
index = skipWhitespaceAndComments(code, end + 1);
|
|
207
|
+
|
|
208
|
+
if (code[index] === ';') {
|
|
209
|
+
index += 1;
|
|
210
|
+
} else if (code[index] && code[index] !== '\n' && code[index] !== '\r') {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (directive === 'use client') return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function skipWhitespaceAndComments(code: string, index: number) {
|
|
221
|
+
let next = index;
|
|
222
|
+
|
|
223
|
+
while (next < code.length) {
|
|
224
|
+
const char = code[next];
|
|
225
|
+
|
|
226
|
+
if (char === ' ' || char === '\t' || char === '\n' || char === '\r') {
|
|
227
|
+
next += 1;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (char === '/' && code[next + 1] === '/') {
|
|
232
|
+
const lineEnd = code.indexOf('\n', next + 2);
|
|
233
|
+
next = lineEnd < 0 ? code.length : lineEnd + 1;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (char === '/' && code[next + 1] === '*') {
|
|
238
|
+
const commentEnd = code.indexOf('*/', next + 2);
|
|
239
|
+
next = commentEnd < 0 ? code.length : commentEnd + 2;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return next;
|
|
247
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { CssConfig } from '../../config/config/css';
|
|
|
2
2
|
import type { DevRuntimeOptions } from '../../config/config/dev';
|
|
3
3
|
import type { CheckSelectorMode } from '../../config/types';
|
|
4
4
|
import type { ReplaceProps } from '../../utils/type';
|
|
5
|
+
import type { CompilerCssPropOptions } from '../cssProp';
|
|
5
6
|
import type { CssExtractRule } from '../extract';
|
|
6
7
|
import type { BabelTransformSourceMap } from '../transform/utils/babel';
|
|
7
8
|
import type { ImportSource } from '../utils/import_source';
|
|
@@ -20,6 +21,7 @@ export type DevSourcemapMode = 'sourceUrl' | 'sourceContent' | 'sidecarServer';
|
|
|
20
21
|
export type CompilerOptions = {
|
|
21
22
|
hoist?: boolean;
|
|
22
23
|
css?: CompilerCssOptions;
|
|
24
|
+
cssProp?: false | CompilerCssPropOptions;
|
|
23
25
|
dev?: CompilerDevOptions;
|
|
24
26
|
|
|
25
27
|
importSources?: ImportSource[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type CompilerCssPropOptions = {
|
|
2
|
+
adapter: string;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const CssPropSolid: CompilerCssPropOptions = {
|
|
6
|
+
adapter: '@fluentic/style/adapter/solid',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CssPropPreact: CompilerCssPropOptions = {
|
|
10
|
+
adapter: '@fluentic/style/adapter/preact',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const CssPropReact: CompilerCssPropOptions = {
|
|
14
|
+
adapter: '@fluentic/style/adapter/react',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const CssPropPresets = {
|
|
18
|
+
Solid: CssPropSolid,
|
|
19
|
+
Preact: CssPropPreact,
|
|
20
|
+
React: CssPropReact,
|
|
21
|
+
};
|
package/compiler/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCssPropPlugin } from './plugin';
|