@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/plugin/nextjs/plugin.ts
CHANGED
|
@@ -2,13 +2,14 @@ import type { NextConfig } from 'next';
|
|
|
2
2
|
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import type { Compiler, RuleSetRule } from 'webpack';
|
|
5
|
+
import type { Compilation, Compiler, RuleSetRule } from 'webpack';
|
|
6
6
|
import type { BuildConfig, BuildDevConfig } from '../../config/build';
|
|
7
7
|
import { isPromiseLike } from '../../utils/object';
|
|
8
8
|
import {
|
|
9
9
|
BUNDLE_CSS_FILE,
|
|
10
10
|
createCompilerId,
|
|
11
11
|
createFileCssCache,
|
|
12
|
+
createFileCssContentHash,
|
|
12
13
|
createPluginCompiler,
|
|
13
14
|
DEFAULT_TRANSFORM_EXCLUDE,
|
|
14
15
|
DEFAULT_TRANSFORM_INCLUDE,
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
createNextBuildConfig,
|
|
43
44
|
createNextBuildDevConfig,
|
|
44
45
|
createNextConfigHash,
|
|
46
|
+
createSerializableImportSources,
|
|
45
47
|
getNextCacheDir,
|
|
46
48
|
getNextPrecollectCacheSubdir,
|
|
47
49
|
getTransformLoaderPath,
|
|
@@ -49,15 +51,16 @@ import {
|
|
|
49
51
|
type NextLoaderState,
|
|
50
52
|
nextRegistry,
|
|
51
53
|
removeUndefinedValues,
|
|
52
|
-
replaceCssMarkerAsset,
|
|
53
54
|
resolveNextCompilerOptions,
|
|
55
|
+
replaceCssMarkerAsset,
|
|
54
56
|
} from './utils';
|
|
55
57
|
|
|
58
|
+
export { CssPropPresets } from '../utils';
|
|
59
|
+
export type { CompilerCssPropOptions } from '../utils';
|
|
60
|
+
|
|
56
61
|
export default plugin;
|
|
57
62
|
|
|
58
63
|
const TURBOPACK_TRANSFORM_EXTENSIONS: readonly string[] = ['*.ts', '*.tsx', '*.js', '*.jsx'];
|
|
59
|
-
const clearedPrecollectCacheRoots = new Set<string>();
|
|
60
|
-
|
|
61
64
|
type NextPhaseState = {
|
|
62
65
|
buildConfig: BuildConfig;
|
|
63
66
|
buildDevConfig: BuildDevConfig | null;
|
|
@@ -107,17 +110,20 @@ function createNextConfig(
|
|
|
107
110
|
phaseState.configHash = createNextConfigHash(
|
|
108
111
|
phaseState.buildConfig,
|
|
109
112
|
phaseState.dev,
|
|
113
|
+
options.importSources,
|
|
110
114
|
);
|
|
111
115
|
|
|
112
116
|
let sidecar: SourcemapSidecar | null = null;
|
|
113
117
|
|
|
114
118
|
if (dev) {
|
|
115
|
-
const
|
|
119
|
+
const getDevCss = () => cssCache.getCss({
|
|
120
|
+
...phaseState.buildConfig.css,
|
|
121
|
+
configHash: phaseState.configHash,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const route: SidecarRouteHandler = async () => ({
|
|
116
125
|
contentType: 'text/css; charset=utf-8',
|
|
117
|
-
body:
|
|
118
|
-
...phaseState.buildConfig.css,
|
|
119
|
-
configHash: phaseState.configHash,
|
|
120
|
-
}),
|
|
126
|
+
body: await waitForDevCss(getDevCss),
|
|
121
127
|
});
|
|
122
128
|
|
|
123
129
|
sidecar = getSourcemapSidecar({
|
|
@@ -143,6 +149,22 @@ function createNextConfig(
|
|
|
143
149
|
: finish();
|
|
144
150
|
}
|
|
145
151
|
|
|
152
|
+
async function waitForDevCss(getCss: () => string) {
|
|
153
|
+
let css = getCss();
|
|
154
|
+
if (css) return css;
|
|
155
|
+
|
|
156
|
+
const deadline = Date.now() + 5000;
|
|
157
|
+
|
|
158
|
+
while (Date.now() < deadline) {
|
|
159
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
160
|
+
|
|
161
|
+
css = getCss();
|
|
162
|
+
if (css) return css;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return css;
|
|
166
|
+
}
|
|
167
|
+
|
|
146
168
|
function createFluenticNextConfigResolved(
|
|
147
169
|
nextConfig: NextConfig,
|
|
148
170
|
options: PluginOptions,
|
|
@@ -159,7 +181,7 @@ function createFluenticNextConfigResolved(
|
|
|
159
181
|
const projectDir = process.cwd();
|
|
160
182
|
|
|
161
183
|
const devCssHref = dev && sidecar
|
|
162
|
-
?
|
|
184
|
+
? DEV_CSS_ROUTE
|
|
163
185
|
: null;
|
|
164
186
|
|
|
165
187
|
const turbopackCompilerId = createCompilerId(NEXT_COMPILER_IDS.turbopack);
|
|
@@ -201,6 +223,7 @@ function createFluenticNextConfigResolved(
|
|
|
201
223
|
return {
|
|
202
224
|
...nextConfig,
|
|
203
225
|
env: nextConfig.env,
|
|
226
|
+
rewrites: createNextRewrites(nextConfig.rewrites, dev && sidecar ? sidecar : null),
|
|
204
227
|
compiler: {
|
|
205
228
|
...originalCompiler,
|
|
206
229
|
define: {
|
|
@@ -243,6 +266,7 @@ function createFluenticNextConfigResolved(
|
|
|
243
266
|
cssAliases: turbopackCssAliases,
|
|
244
267
|
dev,
|
|
245
268
|
devCssHref,
|
|
269
|
+
options,
|
|
246
270
|
projectDir,
|
|
247
271
|
}),
|
|
248
272
|
webpack(config: WebpackConfiguration, context: WebpackConfigContext) {
|
|
@@ -299,6 +323,7 @@ function createFluenticNextConfigResolved(
|
|
|
299
323
|
cssOutput: options.cssOutput,
|
|
300
324
|
cssCache,
|
|
301
325
|
dev: context.dev,
|
|
326
|
+
filter: state.filter,
|
|
302
327
|
sidecar,
|
|
303
328
|
});
|
|
304
329
|
|
|
@@ -307,6 +332,45 @@ function createFluenticNextConfigResolved(
|
|
|
307
332
|
};
|
|
308
333
|
}
|
|
309
334
|
|
|
335
|
+
function createNextRewrites(
|
|
336
|
+
originalRewrites: NextConfig['rewrites'],
|
|
337
|
+
sidecar: SourcemapSidecar | null,
|
|
338
|
+
): NextConfig['rewrites'] {
|
|
339
|
+
if (!sidecar) return originalRewrites;
|
|
340
|
+
|
|
341
|
+
return async () => {
|
|
342
|
+
await sidecar.ensureStarted();
|
|
343
|
+
|
|
344
|
+
const devCssRewrite = {
|
|
345
|
+
source: DEV_CSS_ROUTE,
|
|
346
|
+
destination: sidecar.getRouteUrl(DEV_CSS_ROUTE),
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const original = await originalRewrites?.();
|
|
350
|
+
|
|
351
|
+
if (!original) {
|
|
352
|
+
return {
|
|
353
|
+
beforeFiles: [devCssRewrite],
|
|
354
|
+
afterFiles: [],
|
|
355
|
+
fallback: [],
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (Array.isArray(original)) {
|
|
360
|
+
return {
|
|
361
|
+
beforeFiles: [devCssRewrite],
|
|
362
|
+
afterFiles: original,
|
|
363
|
+
fallback: [],
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
...original,
|
|
369
|
+
beforeFiles: [devCssRewrite, ...(original.beforeFiles ?? [])],
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
310
374
|
function getImportableCssCacheDir(projectDir: string) {
|
|
311
375
|
return path.join(projectDir, PLUGIN_CACHE_DIR);
|
|
312
376
|
}
|
|
@@ -322,6 +386,7 @@ function createTurbopackConfig(
|
|
|
322
386
|
cssAliases: Record<string, string>;
|
|
323
387
|
dev: boolean;
|
|
324
388
|
devCssHref: string | null;
|
|
389
|
+
options: PluginOptions;
|
|
325
390
|
projectDir: string;
|
|
326
391
|
},
|
|
327
392
|
): TurbopackConfig {
|
|
@@ -351,12 +416,16 @@ function mergeTurbopackRules(
|
|
|
351
416
|
cssAliases: Record<string, string>;
|
|
352
417
|
dev: boolean;
|
|
353
418
|
devCssHref: string | null;
|
|
419
|
+
options: PluginOptions;
|
|
354
420
|
projectDir: string;
|
|
355
421
|
},
|
|
356
422
|
): TurbopackRules {
|
|
423
|
+
const compilerOptions = createSerializableTurbopackCompilerOptions(args.options);
|
|
424
|
+
|
|
357
425
|
const loaderItem: TurbopackLoaderItem = {
|
|
358
426
|
loader: LOADER_IMPORT_PATH,
|
|
359
427
|
options: removeUndefinedValues({
|
|
428
|
+
...compilerOptions,
|
|
360
429
|
buildConfig: args.buildConfig,
|
|
361
430
|
buildDevConfig: args.buildDevConfig,
|
|
362
431
|
cacheDir: args.cacheDir,
|
|
@@ -379,6 +448,55 @@ function mergeTurbopackRules(
|
|
|
379
448
|
return nextRules as TurbopackRules;
|
|
380
449
|
}
|
|
381
450
|
|
|
451
|
+
function createSerializableTurbopackCompilerOptions(
|
|
452
|
+
options: PluginOptions,
|
|
453
|
+
): Partial<PluginOptions> {
|
|
454
|
+
return removeUndefinedValues({
|
|
455
|
+
css: options.css,
|
|
456
|
+
cssProp: options.cssProp,
|
|
457
|
+
dev: options.dev,
|
|
458
|
+
hoist: options.hoist,
|
|
459
|
+
importSources: createSerializableTurbopackImportSources(options.importSources),
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function createSerializableTurbopackImportSources(
|
|
464
|
+
importSources: PluginOptions['importSources'],
|
|
465
|
+
): PluginOptions['importSources'] | undefined {
|
|
466
|
+
const serialized = createSerializableImportSources(importSources);
|
|
467
|
+
if (!serialized) return undefined;
|
|
468
|
+
|
|
469
|
+
const result = serialized.filter((entry) => isSerializableLoaderValue(entry));
|
|
470
|
+
return result.length ? result : undefined;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function isSerializableLoaderValue(value: unknown): boolean {
|
|
474
|
+
if (value === null) return true;
|
|
475
|
+
|
|
476
|
+
const valueType = typeof value;
|
|
477
|
+
|
|
478
|
+
if (
|
|
479
|
+
valueType === 'string' ||
|
|
480
|
+
valueType === 'number' ||
|
|
481
|
+
valueType === 'boolean'
|
|
482
|
+
) {
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (valueType !== 'object') return false;
|
|
487
|
+
|
|
488
|
+
if (Array.isArray(value)) {
|
|
489
|
+
return value.every((item) => isSerializableLoaderValue(item));
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const prototype = Object.getPrototypeOf(value);
|
|
493
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
494
|
+
|
|
495
|
+
return Object.values(value as Record<string, unknown>).every((item) =>
|
|
496
|
+
isSerializableLoaderValue(item),
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
|
|
382
500
|
function prependTurbopackLoader(rule: unknown, loader: TurbopackLoaderItem) {
|
|
383
501
|
if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
|
|
384
502
|
return { loaders: [loader] };
|
|
@@ -475,6 +593,7 @@ function addLifecyclePlugin(
|
|
|
475
593
|
cssOutput: PluginCssOutputOptions | undefined;
|
|
476
594
|
cssCache: ReturnType<typeof createFileCssCache>;
|
|
477
595
|
dev: boolean;
|
|
596
|
+
filter: NextLoaderState['filter'];
|
|
478
597
|
sidecar: SourcemapSidecar | null;
|
|
479
598
|
},
|
|
480
599
|
) {
|
|
@@ -482,11 +601,6 @@ function addLifecyclePlugin(
|
|
|
482
601
|
apply(webpackCompiler: Compiler) {
|
|
483
602
|
webpackCompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {
|
|
484
603
|
await args.sidecar?.ensureStarted();
|
|
485
|
-
|
|
486
|
-
if (!args.dev && !clearedPrecollectCacheRoots.has(args.cssCache.rootDir)) {
|
|
487
|
-
clearedPrecollectCacheRoots.add(args.cssCache.rootDir);
|
|
488
|
-
args.cssCache.clear();
|
|
489
|
-
}
|
|
490
604
|
});
|
|
491
605
|
|
|
492
606
|
webpackCompiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (watchCompiler) => {
|
|
@@ -507,6 +621,8 @@ function addLifecyclePlugin(
|
|
|
507
621
|
stage: webpackCompiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
508
622
|
},
|
|
509
623
|
async () => {
|
|
624
|
+
precollectProductionCssFromCompilation(args, compilation, webpackCompiler);
|
|
625
|
+
|
|
510
626
|
const css = await transformCssOutput(
|
|
511
627
|
args.cssCache.getCss({
|
|
512
628
|
...args.buildConfig.css,
|
|
@@ -530,3 +646,80 @@ function addLifecyclePlugin(
|
|
|
530
646
|
},
|
|
531
647
|
});
|
|
532
648
|
}
|
|
649
|
+
|
|
650
|
+
function precollectProductionCssFromCompilation(
|
|
651
|
+
args: {
|
|
652
|
+
configHash: string;
|
|
653
|
+
compiler: NextLoaderState['compiler'];
|
|
654
|
+
cssCache: ReturnType<typeof createFileCssCache>;
|
|
655
|
+
dev: boolean;
|
|
656
|
+
filter: NextLoaderState['filter'];
|
|
657
|
+
},
|
|
658
|
+
compilation: Compilation,
|
|
659
|
+
webpackCompiler: Compiler,
|
|
660
|
+
) {
|
|
661
|
+
if (args.dev) return;
|
|
662
|
+
|
|
663
|
+
const existingCss = args.cssCache.getCss({
|
|
664
|
+
configHash: args.configHash,
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
if (existingCss) return;
|
|
668
|
+
|
|
669
|
+
const files = getCompilationSourceFiles(compilation, webpackCompiler.context, args.filter);
|
|
670
|
+
|
|
671
|
+
for (const filePath of files) {
|
|
672
|
+
let code: string;
|
|
673
|
+
|
|
674
|
+
try {
|
|
675
|
+
code = fs.readFileSync(filePath, 'utf8');
|
|
676
|
+
} catch {
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const result = args.compiler.compileExtract({
|
|
681
|
+
code,
|
|
682
|
+
filePath,
|
|
683
|
+
sourcemap: null,
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
if (!result) continue;
|
|
687
|
+
|
|
688
|
+
args.cssCache.setFileCss({
|
|
689
|
+
filePath,
|
|
690
|
+
contentHash: createFileCssContentHash(code),
|
|
691
|
+
configHash: args.configHash,
|
|
692
|
+
rules: result.rules,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function getCompilationSourceFiles(
|
|
698
|
+
compilation: Compilation,
|
|
699
|
+
projectDir: string,
|
|
700
|
+
filter: NextLoaderState['filter'],
|
|
701
|
+
) {
|
|
702
|
+
const files = new Set<string>();
|
|
703
|
+
const dependencies = compilation.fileDependencies ?? new Set<string>();
|
|
704
|
+
|
|
705
|
+
for (const filePath of dependencies) {
|
|
706
|
+
if (!isProjectSourceFile(filePath, projectDir, filter)) continue;
|
|
707
|
+
files.add(path.normalize(filePath));
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
return [...files].sort();
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function isProjectSourceFile(
|
|
714
|
+
filePath: string,
|
|
715
|
+
projectDir: string,
|
|
716
|
+
filter: NextLoaderState['filter'],
|
|
717
|
+
) {
|
|
718
|
+
if (!path.isAbsolute(filePath)) return false;
|
|
719
|
+
if (!filePath.startsWith(projectDir + path.sep)) return false;
|
|
720
|
+
if (filePath.includes(`${path.sep}.next${path.sep}`)) return false;
|
|
721
|
+
if (filePath.includes(`${path.sep}.git${path.sep}`)) return false;
|
|
722
|
+
if (!filter(filePath)) return false;
|
|
723
|
+
|
|
724
|
+
return true;
|
|
725
|
+
}
|
package/plugin/nextjs/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
-
import type { PHASE_TYPE } from 'next/constants';
|
|
3
2
|
import type { OmitProps } from '../../utils/type';
|
|
4
3
|
import type { PluginOptions as BasePluginOptions } from '../utils';
|
|
5
4
|
|
|
@@ -12,7 +11,7 @@ export type NextConfigContext = {
|
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
export type NextConfigFunction = (
|
|
15
|
-
phase:
|
|
14
|
+
phase: string,
|
|
16
15
|
context: NextConfigContext,
|
|
17
16
|
) => MaybePromise<NextConfig>;
|
|
18
17
|
|
package/plugin/nextjs/utils.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';
|
|
5
5
|
import type { Compiler as PluginCompiler } from '../../compiler';
|
|
6
|
+
import type { ImportSource } from '../../compiler/utils/import_source';
|
|
6
7
|
import { normalizePath } from '../../compiler/utils/path';
|
|
7
8
|
import type { BuildConfig, BuildDevConfig } from '../../config/build';
|
|
9
|
+
import { getStyleFnMeta } from '../../style/style';
|
|
8
10
|
import { createWebpackRegistry } from '../bundler/webpack/shared/registry';
|
|
9
11
|
import type { FileCssCache } from '../utils/cache';
|
|
10
12
|
import type { PluginOptions as BasePluginOptions } from '../utils/compiler';
|
|
@@ -69,15 +71,63 @@ export function createNextBuildDevConfig(options: PluginOptions): BuildDevConfig
|
|
|
69
71
|
export function createNextConfigHash(
|
|
70
72
|
buildConfig: BuildConfig,
|
|
71
73
|
dev: boolean,
|
|
74
|
+
importSources?: readonly ImportSource[] | null,
|
|
72
75
|
) {
|
|
73
76
|
const values = [
|
|
74
77
|
dev ? 'dev' : 'prod',
|
|
75
78
|
buildConfig.hoist ? 'hoist' : 'no-hoist',
|
|
79
|
+
JSON.stringify(createSerializableImportSources(importSources)),
|
|
76
80
|
];
|
|
77
81
|
|
|
78
82
|
return createHash('sha256').update(values.join('\0')).digest('hex');
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
export function createSerializableImportSources(
|
|
86
|
+
importSources: readonly ImportSource[] | null | undefined,
|
|
87
|
+
): ImportSource[] | undefined {
|
|
88
|
+
if (!importSources?.length) return undefined;
|
|
89
|
+
|
|
90
|
+
const result: ImportSource[] = [];
|
|
91
|
+
|
|
92
|
+
for (const entry of importSources) {
|
|
93
|
+
if (entry.check) continue;
|
|
94
|
+
|
|
95
|
+
const source = serializeImportSourcePattern(entry.source);
|
|
96
|
+
const name = entry.name;
|
|
97
|
+
const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
|
|
98
|
+
|
|
99
|
+
if (!meta) continue;
|
|
100
|
+
if (entry.source !== undefined && source === undefined) continue;
|
|
101
|
+
|
|
102
|
+
result.push(removeUndefinedValues({
|
|
103
|
+
source,
|
|
104
|
+
name,
|
|
105
|
+
meta,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return result.length ? result : undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function serializeImportSourcePattern(
|
|
113
|
+
source: ImportSource['source'],
|
|
114
|
+
): string | string[] | undefined {
|
|
115
|
+
if (source === undefined) return undefined;
|
|
116
|
+
|
|
117
|
+
if (Array.isArray(source)) {
|
|
118
|
+
const result: string[] = [];
|
|
119
|
+
|
|
120
|
+
for (const item of source) {
|
|
121
|
+
if (typeof item !== 'string') return undefined;
|
|
122
|
+
result.push(item);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return typeof source === 'string' ? source : undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
81
131
|
export function resolveNextCompilerOptions(
|
|
82
132
|
options: PluginOptions,
|
|
83
133
|
sidecar: SourcemapSidecar | null,
|
package/plugin/utils/compiler.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { createTransformFilter, normalizeModuleId, type TransformFilterOptions }
|
|
|
7
7
|
import type { BundlerSourceMap } from './sourcemap';
|
|
8
8
|
|
|
9
9
|
export type PluginCssOptions = CompilerCssOptions;
|
|
10
|
+
export { CssPropPresets } from '../../compiler';
|
|
11
|
+
export type { CompilerCssPropOptions } from '../../compiler';
|
|
10
12
|
|
|
11
13
|
export type PluginOptions = CompilerOptions & TransformFilterOptions & {
|
|
12
14
|
cacheDir?: string;
|
|
@@ -10,11 +10,11 @@ export function getStyleRuntimeMode(dev: boolean, rsc = false): CompilerRuntimeM
|
|
|
10
10
|
return dev ? CompilerRuntimeMode.Dev : CompilerRuntimeMode.Prod;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function getPluginBuildConfig(options: PluginOptions): BuildConfig {
|
|
13
|
+
export function getPluginBuildConfig(options: PluginOptions, dev = false): BuildConfig {
|
|
14
14
|
const css: CompilerCssOptions = hasBuildConfig(options.css) ? options.css! : {};
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
|
-
hoist: options.hoist !== false,
|
|
17
|
+
hoist: !dev && options.hoist !== false,
|
|
18
18
|
css,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -127,7 +127,7 @@ function classNameToStyle(className: TailwindClassName, theme: TailwindTheme): R
|
|
|
127
127
|
if (className.startsWith('w-')) return { w: ref(className, 'w-', [theme.sizes, theme.spacing]) };
|
|
128
128
|
if (className.startsWith('h-')) return { h: ref(className, 'h-', [theme.sizes, theme.spacing]) };
|
|
129
129
|
if (className.startsWith('bg-')) return { bg: ref(className, 'bg-', theme.colors) };
|
|
130
|
-
if (className.startsWith('text-')) return
|
|
130
|
+
if (className.startsWith('text-')) return textStyle(className.slice('text-'.length), theme);
|
|
131
131
|
if (className.startsWith('font-')) return { font: ref(className, 'font-', theme.fontWeights) };
|
|
132
132
|
if (className.startsWith('leading-')) return { leading: ref(className, 'leading-', theme.lineHeights) };
|
|
133
133
|
if (className.startsWith('rounded-')) return { rounded: ref(className, 'rounded-', theme.radii) };
|
|
@@ -151,6 +151,37 @@ function borderStyle(value: string, theme: TailwindTheme): Record<string, unknow
|
|
|
151
151
|
return { borderColor: scaleRef(value, theme.colors) };
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
function textStyle(value: string, theme: TailwindTheme): Record<string, unknown> {
|
|
155
|
+
if (value.startsWith('[') && value.endsWith(']')) {
|
|
156
|
+
const arbitrary = value.slice(1, -1).replace(/_/g, ' ');
|
|
157
|
+
const hinted = parseArbitraryTextHint(arbitrary);
|
|
158
|
+
|
|
159
|
+
if (hinted) return hinted;
|
|
160
|
+
if (isLikelyFontSize(arbitrary)) return { textSize: arbitrary };
|
|
161
|
+
|
|
162
|
+
return { text: arbitrary };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return { text: scaleRef(value, [theme.fontSizes, theme.colors]) };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function parseArbitraryTextHint(value: string): Record<string, unknown> | null {
|
|
169
|
+
const splitAt = value.indexOf(':');
|
|
170
|
+
if (splitAt < 1) return null;
|
|
171
|
+
|
|
172
|
+
const hint = value.slice(0, splitAt);
|
|
173
|
+
const textValue = value.slice(splitAt + 1);
|
|
174
|
+
|
|
175
|
+
if (hint === 'length' || hint === 'size') return { textSize: textValue };
|
|
176
|
+
if (hint === 'color') return { text: textValue };
|
|
177
|
+
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isLikelyFontSize(value: string) {
|
|
182
|
+
return /^(?:-?\d*\.?\d+(?:px|r?em|lh|vh|vw|vmin|vmax|%|ch|ex|cap|ic)|(?:calc|clamp|min|max)\()/.test(value);
|
|
183
|
+
}
|
|
184
|
+
|
|
154
185
|
function scaleRef(value: string, scale?: TailwindScale | (TailwindScale | undefined)[]) {
|
|
155
186
|
const scales = Array.isArray(scale) ? scale : [scale];
|
|
156
187
|
const path = value.replace(/-/g, '.');
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ClassNameProps, ClassNameResult } from '../core/className';
|
|
2
|
+
import type { StyleProp } from '../types';
|
|
3
|
+
|
|
4
|
+
export type JsxCssPropStyleMode = 'react' | 'solid';
|
|
5
|
+
|
|
6
|
+
export type JsxCssPropMergeOptions = {
|
|
7
|
+
classProp: 'class' | 'className';
|
|
8
|
+
styleProp: 'style';
|
|
9
|
+
styleMode: JsxCssPropStyleMode;
|
|
10
|
+
preserveResultProps?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type JsxCssPropInput = Record<PropertyKey, unknown>;
|
|
14
|
+
|
|
15
|
+
export type GetClassNameFn = (
|
|
16
|
+
styleProp: StyleProp,
|
|
17
|
+
props?: ClassNameProps,
|
|
18
|
+
) => ClassNameResult;
|
|
19
|
+
|
|
20
|
+
export function createMergeJsxProps(
|
|
21
|
+
getClassName: GetClassNameFn,
|
|
22
|
+
options: JsxCssPropMergeOptions,
|
|
23
|
+
) {
|
|
24
|
+
return function mergeJsxProps(parts: readonly unknown[]) {
|
|
25
|
+
let props: JsxCssPropInput | null = null;
|
|
26
|
+
let cssProps: StyleProp[] | null = null;
|
|
27
|
+
|
|
28
|
+
for (let index = 0; index < parts.length; index++) {
|
|
29
|
+
const result = mergePart(props, parts[index]);
|
|
30
|
+
props = result.props;
|
|
31
|
+
|
|
32
|
+
if (result.css) {
|
|
33
|
+
if (!cssProps) cssProps = [];
|
|
34
|
+
cssProps.push(result.css);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return mergeCssProps(props ?? {}, cssProps, getClassName, options);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function mergePart(
|
|
43
|
+
props: JsxCssPropInput | null,
|
|
44
|
+
part: unknown,
|
|
45
|
+
) {
|
|
46
|
+
if (!part) return { css: null, props };
|
|
47
|
+
|
|
48
|
+
const next = props ? { ...props } : {};
|
|
49
|
+
const attrs = part as JsxCssPropInput;
|
|
50
|
+
const css = attrs.css;
|
|
51
|
+
|
|
52
|
+
for (const key in attrs) {
|
|
53
|
+
if (key !== 'css') next[key] = attrs[key];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
css: css ? css as StyleProp : null,
|
|
58
|
+
props: next,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function mergeCssProps(
|
|
63
|
+
props: JsxCssPropInput,
|
|
64
|
+
cssProps: StyleProp[] | null,
|
|
65
|
+
getClassName: GetClassNameFn,
|
|
66
|
+
options: JsxCssPropMergeOptions,
|
|
67
|
+
) {
|
|
68
|
+
if (!cssProps?.length) return props;
|
|
69
|
+
|
|
70
|
+
const className = getClassName(cssProps.length === 1 ? cssProps[0] : cssProps, {
|
|
71
|
+
className: getClassValue(props, options.classProp),
|
|
72
|
+
style: props[options.styleProp] as ClassNameProps['style'],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
delete props.class;
|
|
76
|
+
delete props.className;
|
|
77
|
+
|
|
78
|
+
if (className.className !== undefined) {
|
|
79
|
+
props[options.classProp] = className.className;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (className.style !== undefined) {
|
|
83
|
+
props[options.styleProp] = options.styleMode === 'solid'
|
|
84
|
+
? toSolidStyle(className.style as Record<string, unknown>)
|
|
85
|
+
: className.style;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (options.preserveResultProps) {
|
|
89
|
+
for (const key in className) {
|
|
90
|
+
if (key === 'className' || key === 'style') continue;
|
|
91
|
+
|
|
92
|
+
props[key] = className[key as keyof ClassNameResult];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return props;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getClassValue(
|
|
100
|
+
props: JsxCssPropInput,
|
|
101
|
+
classProp: 'class' | 'className',
|
|
102
|
+
) {
|
|
103
|
+
return (props[classProp] ?? props[classProp === 'class' ? 'className' : 'class']) as ClassNameProps['className'];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function toSolidStyle(style: Record<string, unknown>) {
|
|
107
|
+
const next: Record<string, unknown> = {};
|
|
108
|
+
|
|
109
|
+
for (const key in style) {
|
|
110
|
+
next[toCssPropertyName(key)] = style[key];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return next;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function toCssPropertyName(key: string) {
|
|
117
|
+
if (key.startsWith('--') || key.includes('-')) return key;
|
|
118
|
+
|
|
119
|
+
return key.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
120
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
2
|
+
import type { ScopeData, ScopeTargetData, SheetData } from '../../../builder/data/data';
|
|
3
|
+
import { isScopeData, isSheetData } from '../../../builder/data/is';
|
|
2
4
|
import { getExtractedTokenBoundData, isExtractedTokenBoundData } from '../../../builder/extract/withTokens';
|
|
3
5
|
import { RUNTIME_CONFIG } from '../../../config/config/runtime';
|
|
4
6
|
import type { Falsy, StyleItem } from '../../types';
|
|
@@ -10,6 +12,8 @@ import { mergeTokenOverrides, mergeTokenValues, type StyleTokenValues, type Toke
|
|
|
10
12
|
export type CombinedStyleArg<T extends object> =
|
|
11
13
|
| Falsy
|
|
12
14
|
| StyleItem
|
|
15
|
+
| ScopeData
|
|
16
|
+
| SheetData
|
|
13
17
|
| CombinedStyle<T>
|
|
14
18
|
| readonly CombinedStyleArg<T>[];
|
|
15
19
|
|
|
@@ -94,16 +98,15 @@ function collectStyleArg<T extends object>(
|
|
|
94
98
|
if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(arg)) {
|
|
95
99
|
const bound = getExtractedTokenBoundData(arg);
|
|
96
100
|
|
|
97
|
-
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
|
|
98
|
-
|
|
99
101
|
collectStyleArg(styles, bound.data as CombinedStyleArg<T>, result, resolver);
|
|
102
|
+
result.tokens = mergeTokenOverrides(result.tokens, bound.tokens, resolver);
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
if (isCombinedStyle<T>(arg)) {
|
|
104
107
|
if (getCombinedStyleStyles(arg) !== styles) {
|
|
105
108
|
throw new TypeError(
|
|
106
|
-
'[fluentic-style] combineStyle
|
|
109
|
+
'[fluentic-style] combineStyle styles mismatch.',
|
|
107
110
|
);
|
|
108
111
|
}
|
|
109
112
|
|
|
@@ -117,5 +120,31 @@ function collectStyleArg<T extends object>(
|
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
122
|
|
|
123
|
+
if (isSheetData(arg)) {
|
|
124
|
+
collectTokenOverrides(arg, result, resolver);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (isScopeData(arg)) {
|
|
129
|
+
collectTokenOverrides(arg, result, resolver);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
120
133
|
result.items.push(arg as StyleItem);
|
|
121
134
|
}
|
|
135
|
+
|
|
136
|
+
function collectTokenOverrides(
|
|
137
|
+
data: SheetData | ScopeData,
|
|
138
|
+
result: NormalizedStyleItems,
|
|
139
|
+
resolver: TokenValueResolver,
|
|
140
|
+
) {
|
|
141
|
+
const items = data[BUILDER_STATE]?.items ?? [];
|
|
142
|
+
|
|
143
|
+
for (let i = 0, len = items.length; i < len; i++) {
|
|
144
|
+
const item = items[i];
|
|
145
|
+
|
|
146
|
+
if (resolver.is(item)) {
|
|
147
|
+
result.tokens = mergeTokenOverrides(result.tokens, [item], resolver);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|