@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.10
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 +150 -2
- package/README.md +181 -49
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +50 -12
- package/atomic/debug/className/className.ts +24 -8
- package/atomic/element.ts +5 -2
- package/atomic/rule.ts +11 -5
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +44 -3
- package/atomic/token.ts +7 -4
- package/atomic/utils/cssIdent.ts +54 -0
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +14 -0
- package/atomic/utils/selector.ts +31 -1
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +491 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +41 -0
- package/builder/data/const.ts +8 -1
- package/builder/data/create.ts +52 -6
- package/builder/data/data.ts +33 -8
- package/builder/data/debug.ts +1 -0
- package/builder/data/index.ts +0 -1
- package/builder/data/is.ts +26 -3
- package/builder/data/merge/scope.ts +38 -38
- package/builder/data/merge/style.ts +115 -20
- package/builder/data/state.ts +17 -2
- package/builder/extract/index.ts +1 -0
- package/builder/extract/sheet.ts +30 -0
- package/builder/extract/token.ts +30 -14
- 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 +31 -0
- package/builder/selector_override_core.ts +79 -0
- package/builder/style_builder.ts +144 -20
- package/builder/style_data.ts +25 -0
- package/builder/style_fns.ts +57 -57
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/builder/types/alias.ts +44 -16
- package/builder/types/fns.ts +24 -16
- package/builder/types/types.ts +37 -7
- 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 +4 -1
- package/compiler/cssProp.ts +21 -0
- package/compiler/extract/extract.ts +42 -14
- package/compiler/extract/types.ts +2 -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 +93 -4
- package/compiler/transform/debug/transform.ts +2 -1
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +169 -32
- package/compiler/transform/evaluator/tracer.ts +48 -11
- package/compiler/transform/extract/chain/chain.ts +1370 -162
- package/compiler/transform/extract/chain/extract_chain.ts +12 -4
- package/compiler/transform/extract/chain/types.ts +3 -1
- package/compiler/transform/extract/plugin.ts +64 -6
- package/compiler/transform/extract/transform.ts +2 -1
- package/compiler/transform/extract/utils/replacement.ts +72 -2
- package/compiler/transform/extract/utils/state.ts +3 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/index.ts +1 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +12 -5
- package/compiler/utils/file_resolver.ts +2 -0
- package/compiler/utils/import_source.ts +19 -8
- package/compiler/utils/imports.ts +11 -1
- package/config/build.ts +9 -2
- package/config/config/check.ts +25 -0
- package/config/config/css.ts +18 -1
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +19 -2
- package/config/types.ts +7 -0
- package/css/index.ts +2 -0
- package/css/sheet.ts +152 -0
- package/css/styleTarget.ts +251 -0
- package/dev/config.ts +2 -3
- package/dev/utils.ts +3 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +153 -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-yhJCGT0F.js +304 -0
- package/dist/className-yhJCGT0F.js.map +1 -0
- package/dist/combine-Bww7VnSr.js +1254 -0
- package/dist/combine-Bww7VnSr.js.map +1 -0
- package/dist/compiler/index.mjs +2 -2
- package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
- package/dist/compiler-C3CEGGtI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BAEzRmSJ.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
- package/dist/config-BKP5LOkt.js +35 -0
- package/dist/config-BKP5LOkt.js.map +1 -0
- package/dist/config-C5VWvTav.js +34 -0
- package/dist/config-C5VWvTav.js.map +1 -0
- package/dist/config-CB4lm2tM.js +1 -0
- package/dist/config-CDjbHwb-.js +6 -0
- package/dist/config-CDjbHwb-.js.map +1 -0
- package/dist/config-DNEnHEf3.js +36 -0
- package/dist/config-DNEnHEf3.js.map +1 -0
- package/dist/createTransformElement-D8fXZ3wA.js +34 -0
- package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
- package/dist/css-BDn0epJ8.js +1339 -0
- package/dist/css-BDn0epJ8.js.map +1 -0
- package/dist/css-CFxNrYt3.js +4040 -0
- package/dist/css-CFxNrYt3.js.map +1 -0
- package/dist/css-DEYgrj76.js +524 -0
- package/dist/css-DEYgrj76.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
- package/dist/css-DWBWsyxZ.js.map +1 -0
- package/dist/css.js +2 -2
- package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
- package/dist/data-CDrS1Bq4.js +785 -0
- package/dist/data-CDrS1Bq4.js.map +1 -0
- package/dist/debug-BkVbf0Cz.js +52 -0
- package/dist/debug-BkVbf0Cz.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
- package/dist/debug-YuhEIQVO.js.map +1 -0
- package/dist/dev/rsc.js +10 -9
- package/dist/dev/rsc.js.map +1 -1
- package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
- package/dist/dev-0imWmSVb.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
- package/dist/elementMarker-kvpMjB49.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 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +13 -9
- 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 +242 -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 -4
- package/dist/entry/prod.js +84 -1201
- 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 +11 -13
- 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 +582 -664
- 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 -4
- package/dist/entry/rsc-prod.js +242 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
- package/dist/env-Cz8frh6e.js.map +1 -0
- package/dist/getClassName-9CsXbNls.js +545 -0
- package/dist/getClassName-9CsXbNls.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
- package/dist/getClassName-DGm-VNDo.js.map +1 -0
- package/dist/getClassName-Dtc4yyYI.js +47 -0
- package/dist/getClassName-Dtc4yyYI.js.map +1 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
- package/dist/getClassName-DtkplEIt.js.map +1 -0
- package/dist/global-CAc9OjKx.js +14 -0
- package/dist/global-CAc9OjKx.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
- package/dist/hash-Cr-LCWDt.js.map +1 -0
- package/dist/index.js +10 -8
- 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-CVxpkS04.js +39 -0
- package/dist/jsx-CVxpkS04.js.map +1 -0
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
- package/dist/loader-_-VjzlrX.mjs.map +1 -0
- package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
- package/dist/misc-B76PUnWe.mjs.map +1 -0
- package/dist/namedTokens-5AayGokX.js +85 -0
- package/dist/namedTokens-5AayGokX.js.map +1 -0
- 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 +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- 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 +13 -10
- 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 +995 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
- package/dist/presets-DSanixJV.js.map +1 -0
- package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
- package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
- package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
- package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
- package/dist/rules-DaMaMHgb.js.map +1 -0
- package/dist/scope-CZdGAnl_.js +601 -0
- package/dist/scope-CZdGAnl_.js.map +1 -0
- package/dist/selector/index.js +1 -2
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
- package/dist/shared-PK52rW6T.cjs.map +1 -0
- package/dist/sheet-CxkO1Hwt.js +7 -0
- package/dist/sheet-CxkO1Hwt.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
- package/dist/style-CAhAnRni.js +1129 -0
- package/dist/style-CAhAnRni.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
- package/dist/styleStore-BzLZwpwy.js.map +1 -0
- package/dist/styleStore-DaIJ4OPV.js +58 -0
- package/dist/styleStore-DaIJ4OPV.js.map +1 -0
- package/dist/token-D33mKTka.js +138 -0
- package/dist/token-D33mKTka.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
- package/dist/transform-DSpimwwC.js +23 -0
- package/dist/transform-DSpimwwC.js.map +1 -0
- package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
- package/dist/utils-DZK0mfmY.js +42 -0
- package/dist/utils-DZK0mfmY.js.map +1 -0
- package/dist/utils-D_XgtMtn.js +72 -0
- package/dist/utils-D_XgtMtn.js.map +1 -0
- package/dist/utils-DxCpyV2E.js +62 -0
- package/dist/utils-DxCpyV2E.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
- package/dist/utils-H1VInWpd.js.map +1 -0
- package/dist/utils-NdisireF.mjs +182 -0
- package/dist/utils-NdisireF.mjs.map +1 -0
- package/dist/utils.js +4 -4
- package/dist/utils.js.map +1 -1
- package/dist/value-CK0-Xbov.js +160 -0
- package/dist/value-CK0-Xbov.js.map +1 -0
- package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
- package/dist/webpack-D7QO0bKN.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/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -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/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +4 -2
- 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_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- 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/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +14 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/jsx/types/index.ts +1 -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 +110 -8
- package/plugin/bundler/farm/plugin.ts +2 -0
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/plugin/bundler/parcel/plugin.ts +2 -0
- package/plugin/bundler/rspack/plugin.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +5 -9
- package/plugin/bundler/vite/state.ts +11 -6
- 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 +121 -0
- package/plugin/utils/compiler.ts +2 -0
- package/plugin/utils/runtimeEntry.ts +15 -2
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +239 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +436 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/adapter/utils.ts +120 -0
- package/runtime/core/cache/combine.ts +76 -28
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +32 -13
- package/runtime/core/cache/itemWithResolver.ts +44 -0
- package/runtime/core/cache/pool.ts +16 -31
- package/runtime/core/cache/prop.ts +10 -8
- package/runtime/core/cache/result.ts +2 -2
- package/runtime/core/cache/stateItem.ts +16 -1
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/core/combinedStyle.ts +4 -4
- package/runtime/extract/combineStyle.ts +211 -0
- package/runtime/extract/getClassName.ts +55 -23
- package/runtime/extract/index.ts +4 -2
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/index.ts +8 -1
- package/runtime/rsc/getClassName.ts +4 -0
- package/runtime/rsc/observer.ts +4 -0
- package/runtime/rsc/styleStore.ts +18 -7
- package/runtime/sheet/rule.ts +16 -12
- package/runtime/sheet/rules.ts +8 -3
- package/runtime/style/scope.ts +0 -24
- package/runtime/style/style.ts +181 -6
- package/runtime/types.ts +6 -4
- package/sheet/dev/dev_layer.ts +18 -7
- package/sheet/dev/dev_sort.ts +45 -11
- package/sheet/prod.ts +18 -7
- package/sheet/types.ts +2 -0
- package/sheet/utils/layer.ts +33 -0
- package/style/classname.ts +47 -0
- package/style/important.ts +19 -0
- package/style/index.ts +3 -0
- package/style/style.ts +47 -16
- package/style/theme.ts +4 -3
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +41 -2
- package/style/types.ts +6 -4
- package/style/utils/expose.ts +4 -3
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/style/weight.ts +21 -0
- package/utils/global.ts +1 -3
- package/utils/hash.ts +4 -0
- package/utils/symbol.ts +3 -0
- package/atomic/layer/README.md +0 -116
- package/atomic/utils/css.ts +0 -49
- package/dist/assert-BGdigdr5.js.map +0 -1
- package/dist/className-C1Ht5Wvv.js +0 -144
- package/dist/className-C1Ht5Wvv.js.map +0 -1
- package/dist/className-DC2Cq8p3.js +0 -251
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-BryWDfQX.js +0 -25
- package/dist/config-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js +0 -243
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js +0 -805
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js +0 -235
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/css_extra-DlOnsnR1.js +0 -8
- package/dist/css_extra-oIi3UEPK.js.map +0 -1
- package/dist/data-BsqOa5br.js +0 -473
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-CcphAa3R.js.map +0 -1
- package/dist/dev-DfBbuLeE.js +0 -71
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
- package/dist/extract-CzWJeQi8.js +0 -121
- package/dist/extract-CzWJeQi8.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/global-CvfmFLsK.js.map +0 -1
- package/dist/jsx-CwTeyUxr.js +0 -39
- package/dist/jsx-CwTeyUxr.js.map +0 -1
- package/dist/jsx-D2BksHSv.js +0 -38
- package/dist/jsx-D2BksHSv.js.map +0 -1
- package/dist/layer-D1SaH07m.js +0 -94
- package/dist/layer-D1SaH07m.js.map +0 -1
- package/dist/loader-B5Kw0DD-.mjs.map +0 -1
- package/dist/misc-DCdYYyhK.mjs.map +0 -1
- package/dist/presets-BhXa232U.js +0 -108
- package/dist/presets-BhXa232U.js.map +0 -1
- package/dist/property-CnLFt5kx.js +0 -406
- package/dist/property-CnLFt5kx.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js +0 -743
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js +0 -752
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js +0 -1269
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/styleStore-DyNXBcUK.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-u_tM-mtg.js +0 -204
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/utils-CEaq_c-A.mjs +0 -97
- package/dist/utils-CEaq_c-A.mjs.map +0 -1
- package/dist/utils-CWNHx4EC.js +0 -170
- package/dist/utils-CWNHx4EC.js.map +0 -1
- package/dist/utils-D7FAOyg6.js.map +0 -1
- package/dist/value-BR4e2MKt.js +0 -910
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
- package/dist/valueRef-lshFk1Cs.js +0 -16
- package/dist/valueRef-lshFk1Cs.js.map +0 -1
- package/dist/webpack-Dh6lox2l.mjs.map +0 -1
- package/dist/withTokens-LRidu3Vc.js +0 -95
- package/dist/withTokens-LRidu3Vc.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
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
4
6
|
import type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';
|
|
5
7
|
import type { Compiler as PluginCompiler } from '../../compiler';
|
|
8
|
+
import type { ImportSource } from '../../compiler/utils/import_source';
|
|
6
9
|
import { normalizePath } from '../../compiler/utils/path';
|
|
7
10
|
import type { BuildConfig, BuildDevConfig } from '../../config/build';
|
|
11
|
+
import { getStyleFnMeta } from '../../style/style';
|
|
8
12
|
import { createWebpackRegistry } from '../bundler/webpack/shared/registry';
|
|
9
13
|
import type { FileCssCache } from '../utils/cache';
|
|
10
14
|
import type { PluginOptions as BasePluginOptions } from '../utils/compiler';
|
|
@@ -69,15 +73,132 @@ export function createNextBuildDevConfig(options: PluginOptions): BuildDevConfig
|
|
|
69
73
|
export function createNextConfigHash(
|
|
70
74
|
buildConfig: BuildConfig,
|
|
71
75
|
dev: boolean,
|
|
76
|
+
importSources?: readonly ImportSource[] | null,
|
|
72
77
|
) {
|
|
73
78
|
const values = [
|
|
79
|
+
createPackageCacheIdentity(),
|
|
74
80
|
dev ? 'dev' : 'prod',
|
|
75
81
|
buildConfig.hoist ? 'hoist' : 'no-hoist',
|
|
82
|
+
JSON.stringify(createSerializableImportSources(importSources)),
|
|
76
83
|
];
|
|
77
84
|
|
|
78
85
|
return createHash('sha256').update(values.join('\0')).digest('hex');
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
function createPackageCacheIdentity() {
|
|
89
|
+
const require = createRequire(import.meta.url);
|
|
90
|
+
let entryPath = '';
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
entryPath = require.resolve('@fluentic/style/plugin/nextjs');
|
|
94
|
+
} catch {
|
|
95
|
+
entryPath = fileURLToPath(import.meta.url);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const packageInfo = findPackageInfo(entryPath);
|
|
99
|
+
const parts = [
|
|
100
|
+
packageInfo.version,
|
|
101
|
+
normalizePath(packageInfo.packageRoot),
|
|
102
|
+
normalizePath(entryPath),
|
|
103
|
+
getStatIdentity(packageInfo.packageJsonPath),
|
|
104
|
+
getStatIdentity(entryPath),
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
return parts.join('\0');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function findPackageInfo(entryPath: string) {
|
|
111
|
+
let current = path.dirname(entryPath);
|
|
112
|
+
|
|
113
|
+
while (true) {
|
|
114
|
+
const packageJsonPath = path.join(current, 'package.json');
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as {
|
|
118
|
+
name?: string;
|
|
119
|
+
version?: string;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (pkg.name === '@fluentic/style') {
|
|
123
|
+
return {
|
|
124
|
+
packageRoot: current,
|
|
125
|
+
packageJsonPath,
|
|
126
|
+
version: pkg.version ?? '',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
} catch {
|
|
130
|
+
// Keep walking toward the filesystem root.
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const parent = path.dirname(current);
|
|
134
|
+
if (parent === current) break;
|
|
135
|
+
current = parent;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
packageRoot: path.dirname(entryPath),
|
|
140
|
+
packageJsonPath: '',
|
|
141
|
+
version: '',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function getStatIdentity(filePath: string) {
|
|
146
|
+
if (!filePath) return '';
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
const stat = fs.statSync(filePath);
|
|
150
|
+
return `${stat.size}:${stat.mtimeMs}`;
|
|
151
|
+
} catch {
|
|
152
|
+
return '';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function createSerializableImportSources(
|
|
157
|
+
importSources: readonly ImportSource[] | null | undefined,
|
|
158
|
+
): ImportSource[] | undefined {
|
|
159
|
+
if (!importSources?.length) return undefined;
|
|
160
|
+
|
|
161
|
+
const result: ImportSource[] = [];
|
|
162
|
+
|
|
163
|
+
for (const entry of importSources) {
|
|
164
|
+
if (entry.check) continue;
|
|
165
|
+
|
|
166
|
+
const source = serializeImportSourcePattern(entry.source);
|
|
167
|
+
const name = entry.name;
|
|
168
|
+
const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
|
|
169
|
+
|
|
170
|
+
if (!meta) continue;
|
|
171
|
+
if (entry.source !== undefined && source === undefined) continue;
|
|
172
|
+
|
|
173
|
+
result.push(removeUndefinedValues({
|
|
174
|
+
source,
|
|
175
|
+
name,
|
|
176
|
+
meta,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return result.length ? result : undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function serializeImportSourcePattern(
|
|
184
|
+
source: ImportSource['source'],
|
|
185
|
+
): string | string[] | undefined {
|
|
186
|
+
if (source === undefined) return undefined;
|
|
187
|
+
|
|
188
|
+
if (Array.isArray(source)) {
|
|
189
|
+
const result: string[] = [];
|
|
190
|
+
|
|
191
|
+
for (const item of source) {
|
|
192
|
+
if (typeof item !== 'string') return undefined;
|
|
193
|
+
result.push(item);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return typeof source === 'string' ? source : undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
81
202
|
export function resolveNextCompilerOptions(
|
|
82
203
|
options: PluginOptions,
|
|
83
204
|
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,12 +10,13 @@ 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
|
+
check: options.check,
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -55,3 +56,15 @@ export function getStyleEntryDefines(
|
|
|
55
56
|
|
|
56
57
|
return defines;
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
export function createStyleEntryGlobalSource(
|
|
61
|
+
buildConfig: BuildConfig,
|
|
62
|
+
buildDevConfig: BuildDevConfig | null,
|
|
63
|
+
sidecarUrl: string | null,
|
|
64
|
+
) {
|
|
65
|
+
const defines = getStyleEntryDefines(buildConfig, buildDevConfig, sidecarUrl, false);
|
|
66
|
+
|
|
67
|
+
return Object.entries(defines)
|
|
68
|
+
.map(([key, value]) => `globalThis[${JSON.stringify(key)}] = ${JSON.stringify(value)};`)
|
|
69
|
+
.join('\n');
|
|
70
|
+
}
|