@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.4
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 +13 -0
- package/README.md +1 -1
- package/atomic/className.ts +3 -9
- package/atomic/debug/className/className.ts +0 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +2 -2
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +41 -2
- package/atomic/token.ts +4 -3
- package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/builder/data/const.ts +1 -1
- package/builder/data/merge/style.ts +1 -1
- package/builder/extract/token.ts +30 -14
- 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/compiler/transform/debug/plugin.ts +79 -1
- package/compiler/transform/evaluator/evaluator.ts +74 -26
- package/compiler/transform/extract/chain/chain.ts +1 -1
- package/compiler/transform/extract/utils/replacement.ts +6 -1
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/config/build.ts +1 -8
- package/config/config/debug.ts +11 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/{className-CKo4TxuT.js → className-Do2Crx4b.js} +2 -3
- package/dist/{className-CKo4TxuT.js.map → className-Do2Crx4b.js.map} +1 -1
- package/dist/{style-91J0B5ef.js → combine-C9vjpKCs.js} +45 -304
- package/dist/combine-C9vjpKCs.js.map +1 -0
- package/dist/combineStyle-DwAhsOmS.js +26 -0
- package/dist/combineStyle-DwAhsOmS.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-D5v5tJXI.mjs → compiler-CE0ZgkdH.mjs} +231 -84
- package/dist/compiler-CE0ZgkdH.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BE5D5x2N.js +2 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/{config-FIfi5aJ8.js → config-CduqubI8.js} +8 -6
- package/dist/config-CduqubI8.js.map +1 -0
- package/dist/config-lJNLh7eM.js +6 -0
- package/dist/config-lJNLh7eM.js.map +1 -0
- package/dist/config-oKOjOTWi.js +7 -0
- package/dist/{config-OXHoDUIo.js.map → config-oKOjOTWi.js.map} +1 -1
- package/dist/{css-DcuJ_jSH.js → css-BewrRz3_.js} +3 -3
- package/dist/{css-DcuJ_jSH.js.map → css-BewrRz3_.js.map} +1 -1
- package/dist/{css-dPoZJDQH.js → css-CiTI58yl.js} +291 -4
- package/dist/css-CiTI58yl.js.map +1 -0
- package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
- package/dist/css-GtUPEO9U.js.map +1 -0
- package/dist/{css-oOt6ZR54.js → css-Rc7ILf-3.js} +8 -9
- package/dist/{css-oOt6ZR54.js.map → css-Rc7ILf-3.js.map} +1 -1
- package/dist/css.js +1 -1
- package/dist/{css-CELBp6Gu.js → cssIdent-BsyUXNNk.js} +3 -23
- package/dist/cssIdent-BsyUXNNk.js.map +1 -0
- package/dist/cssVar-DGgQ2GIK.js +92 -0
- package/dist/cssVar-DGgQ2GIK.js.map +1 -0
- package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
- package/dist/{css_extra-DQdCrYoC.js → css_extra-DYtS3g6Z.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-DYtS3g6Z.js.map} +1 -1
- package/dist/{data-CeYstKMP.js → data-D7NFt4JG.js} +205 -10
- package/dist/data-D7NFt4JG.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-Cvpo5cVu.js} +4 -3
- package/dist/{debug-D96KGgpH.js.map → debug-Cvpo5cVu.js.map} +1 -1
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-fOtWB5K3.js → dev-DdRWa6dJ.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-DdRWa6dJ.js.map} +1 -1
- package/dist/{dev-p8tW7X-A.js → dev-px0_6TNq.js} +4 -4
- package/dist/{dev-p8tW7X-A.js.map → dev-px0_6TNq.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-CvqqIb7J.js → elementMarker-ng0y3fN0.js} +8 -8
- package/dist/{elementMarker-CvqqIb7J.js.map → elementMarker-ng0y3fN0.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +11 -12
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod/extract.js +2 -2
- 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 +5 -4
- package/dist/entry/prod.js +40 -11
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +4 -4
- 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 +274 -68
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- 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 +5 -4
- package/dist/entry/rsc-prod.js +16 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/extract-B-Vs88ME.js +3 -0
- package/dist/{extract-CzWJeQi8.js → extract-CM8Fk2eK.js} +24 -15
- package/dist/{extract-CzWJeQi8.js.map → extract-CM8Fk2eK.js.map} +1 -1
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-CrNVjAoJ.js} +29 -8
- package/dist/getClassName-CrNVjAoJ.js.map +1 -0
- package/dist/{global-Cul1dX8k.js → global-CZBlA9E7.js} +3 -3
- package/dist/{global-Cul1dX8k.js.map → global-CZBlA9E7.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BfeJDf5U.js} +13 -4
- package/dist/hash-BfeJDf5U.js.map +1 -0
- package/dist/index.js +9 -10
- 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-Ba-XV33u.js → jsx-BY1iFewe.js} +3 -3
- package/dist/{jsx-Ba-XV33u.js.map → jsx-BY1iFewe.js.map} +1 -1
- package/dist/{jsx-A4cK517J.js → jsx-DL-DEAz8.js} +8 -7
- package/dist/{jsx-A4cK517J.js.map → jsx-DL-DEAz8.js.map} +1 -1
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-aAhNYDeS.js} +2 -2
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-aAhNYDeS.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-C6i1bWlu.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-C6i1bWlu.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-D7Y5up6H.js} +2 -2
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-D7Y5up6H.js.map} +1 -1
- package/dist/{layer-CbQzwZF-.js → layer-BSxAr-hy.js} +4 -4
- package/dist/{layer-CbQzwZF-.js.map → layer-BSxAr-hy.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-BmYS_Rju.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-BmYS_Rju.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BIS_c7BJ.mjs} +2 -2
- package/dist/{misc-DFBKJGLT.mjs.map → misc-BIS_c7BJ.mjs.map} +1 -1
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-CN_yhhik.js} +8 -6
- package/dist/namedTokens-CN_yhhik.js.map +1 -0
- package/dist/plugin/farm/index.mjs +2 -2
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +4 -4
- 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 +1 -1
- package/dist/plugin/vite/index.mjs +3 -3
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +8 -5
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{property-CF6JgpTq.js → property-BuLbzviK.js} +2 -2
- package/dist/{property-CF6JgpTq.js.map → property-BuLbzviK.js.map} +1 -1
- package/dist/{registry-CiwvMfx8.mjs → registry-IaXmLQzA.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-IaXmLQzA.mjs.map} +1 -1
- package/dist/{rules-DlXcch7-.js → rules-CxVzovt-.js} +60 -23
- package/dist/rules-CxVzovt-.js.map +1 -0
- package/dist/selector-A-mRmMnI.js +64 -0
- package/dist/selector-A-mRmMnI.js.map +1 -0
- package/dist/server.js +12 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-CaJuvw03.cjs} +231 -84
- package/dist/shared-CaJuvw03.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-DdPTZ0O3.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-DdPTZ0O3.mjs.map} +1 -1
- package/dist/sheet-BWBzuy4D.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BWBzuy4D.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-B3oCK9vC.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-B3oCK9vC.mjs.map} +1 -1
- package/dist/{style-DFFK06Of.js → style-CGaJndOl.js} +102 -54
- package/dist/style-CGaJndOl.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → style-DDxjKdX0.js} +356 -39
- package/dist/style-DDxjKdX0.js.map +1 -0
- package/dist/style-S7LTQbRu.js +5 -0
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-0fARJlZV.js} +6 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-0fARJlZV.js.map} +1 -1
- package/dist/{styleStore-ydQcDBD4.js → styleStore-CajcAEPO.js} +101 -223
- package/dist/styleStore-CajcAEPO.js.map +1 -0
- package/dist/symbols-Cp4ymzKF.js +14 -0
- package/dist/symbols-Cp4ymzKF.js.map +1 -0
- package/dist/token-D-S-4_mN.js +138 -0
- package/dist/token-D-S-4_mN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-CFnhyCVf.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-CFnhyCVf.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-ZtgeY-8s.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-ZtgeY-8s.js.map} +1 -1
- package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
- package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
- package/dist/{utils-D2fygyTm.mjs → utils-B5Xqf1lV.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-B5Xqf1lV.mjs.map} +1 -1
- package/dist/{utils-hoYnMiA7.js → utils-B_VhPBHH.js} +4 -4
- package/dist/{utils-hoYnMiA7.js.map → utils-B_VhPBHH.js.map} +1 -1
- package/dist/{utils-Bmw655wa.js → utils-CDUaX81o.js} +3 -3
- package/dist/{utils-Bmw655wa.js.map → utils-CDUaX81o.js.map} +1 -1
- package/dist/{utils-DTXCTUlS.mjs → utils-DaAiEEIG.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DaAiEEIG.mjs.map} +1 -1
- package/dist/{utils-DVFxZnVC.js → utils-DzydRwYo.js} +65 -49
- package/dist/utils-DzydRwYo.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/value-C0JRsyax.js +64 -0
- package/dist/value-C0JRsyax.js.map +1 -0
- package/dist/{value-DvFkGBy2.js → value-D08AocUs.js} +96 -72
- package/dist/value-D08AocUs.js.map +1 -0
- package/dist/{valueRef-CsLVJwjA.js → valueRef-M3E1oza7.js} +2 -2
- package/dist/{valueRef-CsLVJwjA.js.map → valueRef-M3E1oza7.js.map} +1 -1
- package/dist/{webpack-BOU7_xld.mjs → webpack-CHydnRXB.mjs} +5 -5
- package/dist/{webpack-BOU7_xld.mjs.map → webpack-CHydnRXB.mjs.map} +1 -1
- package/dist/{withTokens-LRidu3Vc.js → withTokens-DAzUIPvA.js} +2 -2
- package/dist/{withTokens-LRidu3Vc.js.map → withTokens-DAzUIPvA.js.map} +1 -1
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +3 -1
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +9 -7
- package/package.json +1 -1
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/core/cache/combine.ts +44 -25
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +2 -2
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +3 -2
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/extract/combineStyle.ts +37 -0
- package/runtime/extract/getClassName.ts +5 -11
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/style/style.ts +2 -1
- package/style/style.ts +1 -1
- package/style/theme.ts +0 -1
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +1 -1
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/className-ZJ5pBA-o.js +0 -263
- package/dist/className-ZJ5pBA-o.js.map +0 -1
- package/dist/compiler-D5v5tJXI.mjs.map +0 -1
- package/dist/config-BEvP7108.js.map +0 -1
- package/dist/config-B_cbG3S6.js +0 -1
- package/dist/config-FIfi5aJ8.js.map +0 -1
- package/dist/config-OXHoDUIo.js +0 -6
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/rules-DlXcch7-.js.map +0 -1
- package/dist/runtime-BKChZZ2-.js.map +0 -1
- package/dist/shared-yDD0nfm1.cjs.map +0 -1
- package/dist/sheet-B-uJfHRY.js +0 -7
- package/dist/style-91J0B5ef.js.map +0 -1
- package/dist/style-Bw5ka-Nq.js.map +0 -1
- package/dist/style-DFFK06Of.js.map +0 -1
- package/dist/style-pz8e5To1.js +0 -5
- package/dist/styleStore-ydQcDBD4.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-DTOyFLmp.js +0 -58
- package/dist/token-DTOyFLmp.js.map +0 -1
- package/dist/token-DT_sCPtm.js +0 -298
- package/dist/token-DT_sCPtm.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @fluentic/style
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Slim the extracted production runtime token path and fix named token refs in token-bound extracted styles.
|
|
8
|
+
|
|
9
|
+
- Keep token symbols, guards, naming, and extracted token helpers in builder/runtime internals instead of the public style token surface.
|
|
10
|
+
- Split extracted combine, token resolution, CSS variable, scope, and debug config helpers so extracted builds retain less eager runtime code.
|
|
11
|
+
- Make named tokens carry their extracted CSS variable name so production token bindings can reference named token values without compiler metadata errors.
|
|
12
|
+
- Hide manual stable ids from the public token and theme factory types while preserving internal compiler-provided identities.
|
|
13
|
+
- Add snapshot and runtime contract coverage for createToken, createTokens, createValues, createTheme, scopes, bindScope, combineStyle, and named-token refs in extracted output.
|
|
14
|
+
- Keep the Parcel optimizer on Node's `Buffer` import path and declare the Parcel example polyfill dependency so workspace builds do not rely on Parcel auto-install.
|
|
15
|
+
|
|
3
16
|
## 0.1.0-beta.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -380,7 +380,7 @@ production builds. Current benchmark snapshots:
|
|
|
380
380
|
The main production checks are runtime cost and bundle size. In the production
|
|
381
381
|
path most apps use, Fluentic extracts CSS at build time and ships the extracted
|
|
382
382
|
production runtime for `css` prop composition, dynamic values, class-name
|
|
383
|
-
merging, and token resolution. That runtime entry currently reports `
|
|
383
|
+
merging, and token resolution. That runtime entry currently reports `4.45 KB`
|
|
384
384
|
min+gzip.
|
|
385
385
|
Browser and SSR benchmarks track whether style resolution stays fast in
|
|
386
386
|
app-shaped renders. See the
|
package/atomic/className.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BuilderCallsite, ItemSelector } from '../builder/data';
|
|
2
2
|
import { CSS_CONFIG } from '../config/config/css';
|
|
3
3
|
import { DEV_CONFIG } from '../config/config/dev';
|
|
4
|
-
import type { ClassNameFormat,
|
|
4
|
+
import type { ClassNameFormat, TransformClassNameFormat } from '../config/types';
|
|
5
5
|
import { hashString } from '../utils/hash';
|
|
6
|
-
import { getDebugClassName,
|
|
6
|
+
import { getDebugClassName, getDebugTransformClassName } from './debug/className';
|
|
7
7
|
import { getDebugPropertyName } from './debug/property';
|
|
8
8
|
import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
|
|
9
|
+
export { getScopeClassName } from './scope';
|
|
9
10
|
import { getIdentifierSafeHash } from './utils/hash';
|
|
10
11
|
import { getSelectorHash, getSelectorText } from './utils/selector';
|
|
11
12
|
|
|
@@ -80,13 +81,6 @@ function getRuntimeClassNameHashLength(debugClassName: boolean) {
|
|
|
80
81
|
return CSS_CONFIG.hashLength ?? 7;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
export function getScopeClassName(
|
|
84
|
-
className: string,
|
|
85
|
-
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
86
|
-
) {
|
|
87
|
-
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
84
|
export function getClassNameDedupe(
|
|
91
85
|
property: string,
|
|
92
86
|
priority: number | null,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ClassNameFormat,
|
|
3
3
|
ClassNameInfo,
|
|
4
|
-
ScopeClassNameFormat,
|
|
5
|
-
ScopeClassNameInfo,
|
|
6
4
|
TransformClassNameFormat,
|
|
7
5
|
TransformClassNameInfo,
|
|
8
6
|
} from '../../../config/types';
|
|
@@ -12,8 +10,6 @@ export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(sele
|
|
|
12
10
|
|
|
13
11
|
export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
|
|
14
12
|
|
|
15
|
-
export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
|
|
16
|
-
|
|
17
13
|
export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
18
14
|
'atRule',
|
|
19
15
|
'scopeSelector',
|
|
@@ -22,10 +18,6 @@ export const formatClassName = createNameFormatter<ClassNameInfo>([
|
|
|
22
18
|
'value',
|
|
23
19
|
]);
|
|
24
20
|
|
|
25
|
-
export const formatScopeClassName = createNameFormatter<ScopeClassNameInfo>([
|
|
26
|
-
'className',
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
21
|
export const formatTransformClassName = createNameFormatter<TransformClassNameInfo>([
|
|
30
22
|
'className',
|
|
31
23
|
]);
|
|
@@ -45,10 +37,3 @@ export function getDebugTransformClassName(
|
|
|
45
37
|
) {
|
|
46
38
|
return formatTransformClassName(format || TRANSFORM_CLASS_NAME_FORMAT, hash, info);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
export function getDebugScopeClassName(
|
|
50
|
-
format: ScopeClassNameFormat | null,
|
|
51
|
-
info: ScopeClassNameInfo,
|
|
52
|
-
) {
|
|
53
|
-
return formatScopeClassName(format || SCOPE_CLASS_NAME_FORMAT, null, info);
|
|
54
|
-
}
|
package/atomic/element.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSS_CONFIG } from '../config/config/css';
|
|
2
2
|
import { DEV_CONFIG } from '../config/config/dev';
|
|
3
3
|
import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
|
|
4
|
-
import { escapeCssIdent } from './utils/
|
|
4
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
5
5
|
import { sanitizeDebugName } from './utils/debug';
|
|
6
6
|
import { createNameFormatter } from './utils/format';
|
|
7
7
|
import { getIdentifierSafeHash } from './utils/hash';
|
package/atomic/rule.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ItemSelector } from '../builder/data/state';
|
|
2
2
|
import type { ScopeClassNameFormat } from '../config/types';
|
|
3
|
-
import { getScopeClassName } from './className';
|
|
4
3
|
import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } from './layer';
|
|
5
4
|
import { getCssPropertyName, getPropertyPriority } from './property';
|
|
6
|
-
import {
|
|
5
|
+
import { getScopeClassName } from './scope';
|
|
6
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
7
7
|
import { getSelectorPriority, getSelectorText } from './utils/selector';
|
|
8
8
|
import { getCssPropertyValue } from './value';
|
|
9
9
|
|
package/atomic/scope.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ScopeClassNameFormat, ScopeClassNameInfo } from '../config/types';
|
|
2
|
+
|
|
3
|
+
export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
|
|
4
|
+
|
|
5
|
+
export function getScopeClassName(
|
|
6
|
+
className: string,
|
|
7
|
+
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
8
|
+
) {
|
|
9
|
+
return formatScopeClassName(scopeClassNameFormat || SCOPE_CLASS_NAME_FORMAT, { className });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function formatScopeClassName(
|
|
13
|
+
format: ScopeClassNameFormat,
|
|
14
|
+
info: ScopeClassNameInfo,
|
|
15
|
+
) {
|
|
16
|
+
if (typeof format === 'function') return format(info);
|
|
17
|
+
|
|
18
|
+
return format.replace(/\[|\]/g, '').replace(/\(className\)/g, info.className);
|
|
19
|
+
}
|
package/atomic/theme.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { CSS_CONFIG } from '../config/config/css';
|
|
|
2
2
|
import type { ThemeNameFormat, ThemeNameInfo, TokenNameFormat } from '../config/types';
|
|
3
3
|
import type { StyleTokenOverride } from '../style/token';
|
|
4
4
|
import { getTokenOverrideValue, getTokenVarName } from './token';
|
|
5
|
-
import { escapeCssIdent
|
|
5
|
+
import { escapeCssIdent } from './utils/cssIdent';
|
|
6
|
+
import { escapeCssValue } from './utils/cssVar';
|
|
6
7
|
import { createNameFormatter } from './utils/format';
|
|
7
8
|
import { getIdentifierSafeHash } from './utils/hash';
|
|
8
9
|
|
|
@@ -18,7 +19,7 @@ export function createThemeClassName(
|
|
|
18
19
|
return formatThemeName(
|
|
19
20
|
themeNameFormat || THEME_NAME_FORMAT,
|
|
20
21
|
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
21
|
-
{ name },
|
|
22
|
+
{ name: normalizeThemeName(name) },
|
|
22
23
|
);
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -48,3 +49,41 @@ function getThemeDeclaration(
|
|
|
48
49
|
|
|
49
50
|
return name + ':' + value;
|
|
50
51
|
}
|
|
52
|
+
|
|
53
|
+
export function normalizeThemeName(value: string | null | undefined): string | null {
|
|
54
|
+
if (!value) return null;
|
|
55
|
+
|
|
56
|
+
value = value.trim();
|
|
57
|
+
if (!value) return null;
|
|
58
|
+
if (/^\d+$/.test(value)) return null;
|
|
59
|
+
if (isGeneratedNameHash(value)) return null;
|
|
60
|
+
|
|
61
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
62
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) {
|
|
63
|
+
return normalizeThemeName(stableSuffix[1]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
value = stripGenericThemePrefix(value);
|
|
67
|
+
if (!value) return null;
|
|
68
|
+
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function stripGenericThemePrefix(value: string) {
|
|
73
|
+
const parts = value.split('--');
|
|
74
|
+
|
|
75
|
+
while (parts[0] === 'theme' || parts[0] === 'themes') {
|
|
76
|
+
parts.shift();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
value = parts.join('--');
|
|
80
|
+
|
|
81
|
+
if (value.startsWith('theme-')) return value.slice('theme-'.length);
|
|
82
|
+
if (value.startsWith('themes-')) return value.slice('themes-'.length);
|
|
83
|
+
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isGeneratedNameHash(value: string) {
|
|
88
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
89
|
+
}
|
package/atomic/token.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSS_CONFIG } from '../config/config/css';
|
|
2
2
|
import type { TokenNameFormat, TokenNameInfo } from '../config/types';
|
|
3
|
-
import { getStyleTokenId, type StyleTokenData, type StyleTokenOverride } from '../style/token';
|
|
4
|
-
import { getCssVar, getCssVarRawFallback } from './utils/
|
|
3
|
+
import { getStyleTokenId, getStyleTokenName, type StyleTokenData, type StyleTokenOverride } from '../style/token';
|
|
4
|
+
import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
|
|
5
5
|
import { createNameFormatter } from './utils/format';
|
|
6
6
|
import { getIdentifierSafeHash } from './utils/hash';
|
|
7
7
|
|
|
@@ -14,11 +14,12 @@ export function getTokenVarName(
|
|
|
14
14
|
format: TokenNameFormat | null,
|
|
15
15
|
) {
|
|
16
16
|
const id = getStyleTokenId(token);
|
|
17
|
+
const debugName = getStyleTokenName(token);
|
|
17
18
|
|
|
18
19
|
const name = formatTokenName(
|
|
19
20
|
format || TOKEN_NAME_FORMAT,
|
|
20
21
|
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
21
|
-
{ name:
|
|
22
|
+
{ name: debugName },
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
return '--' + name;
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
export function getCssVar(varName: string, value: string) {
|
|
2
|
-
return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function getCssVarRawFallback(varName: string, fallbackCss: string) {
|
|
6
|
-
return 'var(' + varName + ', ' + fallbackCss + ')';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function escapeCssValue(value: string): string {
|
|
10
|
-
if (!value) return '';
|
|
11
|
-
|
|
12
|
-
return value
|
|
13
|
-
.trim()
|
|
14
|
-
// Escape existing backslashes first so we don't break them.
|
|
15
|
-
.replace(/\\/g, '\\\\')
|
|
16
|
-
.replace(/"/g, '\\"')
|
|
17
|
-
.replace(/'/g, "\\'")
|
|
18
|
-
.replace(/;/g, '\\;');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
1
|
export function escapeCssIdent(ident: string): string {
|
|
22
2
|
let result = '';
|
|
23
3
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function getCssVar(varName: string, value: string) {
|
|
2
|
+
return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function getCssVarRawFallback(varName: string, fallbackCss: string) {
|
|
6
|
+
return 'var(' + varName + ', ' + fallbackCss + ')';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function escapeCssValue(value: string): string {
|
|
10
|
+
if (!value) return '';
|
|
11
|
+
|
|
12
|
+
return value
|
|
13
|
+
.trim()
|
|
14
|
+
// Escape existing backslashes first so we don't break them.
|
|
15
|
+
.replace(/\\/g, '\\\\')
|
|
16
|
+
.replace(/"/g, '\\"')
|
|
17
|
+
.replace(/'/g, "\\'")
|
|
18
|
+
.replace(/;/g, '\\;');
|
|
19
|
+
}
|
package/atomic/utils/debug.ts
CHANGED
package/builder/data/const.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAtomicClassName, getClassNameDedupe } from '../../../atomic/className';
|
|
2
2
|
import { getTokenVar } from '../../../atomic/token';
|
|
3
|
-
import { getCssVarRawFallback } from '../../../atomic/utils/
|
|
3
|
+
import { getCssVarRawFallback } from '../../../atomic/utils/cssVar';
|
|
4
4
|
import { shouldAppendCssPx } from '../../../atomic/value';
|
|
5
5
|
import { CSS_CONFIG } from '../../../config/config/css';
|
|
6
6
|
import { DEBUG_CONFIG } from '../../../config/config/debug';
|
package/builder/extract/token.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../../builder/token/symbols';
|
|
2
|
+
import type { StyleToken, StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
2
3
|
|
|
3
4
|
export type ExtractedTokenInput = {
|
|
4
5
|
id: string;
|
|
@@ -10,30 +11,45 @@ export function createExtractedToken(
|
|
|
10
11
|
id: string,
|
|
11
12
|
value: unknown,
|
|
12
13
|
ref: StyleTokenData | null = null,
|
|
14
|
+
name: string | null = null,
|
|
15
|
+
varName: string | null = null,
|
|
13
16
|
): StyleToken<unknown> {
|
|
14
17
|
const token = ((value: unknown | StyleTokenData) => {
|
|
15
|
-
return
|
|
16
|
-
? {
|
|
17
|
-
[TOKEN_ID]: token[TOKEN_ID],
|
|
18
|
-
[TOKEN_OVERRIDE]: true,
|
|
19
|
-
value: value.value,
|
|
20
|
-
ref: value,
|
|
21
|
-
}
|
|
22
|
-
: {
|
|
23
|
-
[TOKEN_ID]: token[TOKEN_ID],
|
|
24
|
-
[TOKEN_OVERRIDE]: true,
|
|
25
|
-
value,
|
|
26
|
-
ref: null,
|
|
27
|
-
};
|
|
18
|
+
return createExtractedTokenOverride(token, value);
|
|
28
19
|
}) as StyleToken<unknown>;
|
|
29
20
|
|
|
30
21
|
token[TOKEN_ID] = id;
|
|
22
|
+
token[TOKEN_NAME] = name;
|
|
23
|
+
token[TOKEN_VAR_NAME] = varName;
|
|
31
24
|
token.value = ref ? ref.value : value;
|
|
32
25
|
token.ref = ref;
|
|
33
26
|
|
|
34
27
|
return token;
|
|
35
28
|
}
|
|
36
29
|
|
|
30
|
+
function createExtractedTokenOverride(
|
|
31
|
+
token: StyleToken,
|
|
32
|
+
value: unknown | StyleTokenData,
|
|
33
|
+
): StyleTokenOverride {
|
|
34
|
+
return isExtractedTokenRef(value)
|
|
35
|
+
? {
|
|
36
|
+
[TOKEN_ID]: token[TOKEN_ID],
|
|
37
|
+
[TOKEN_OVERRIDE]: true,
|
|
38
|
+
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
39
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
40
|
+
value: value.value,
|
|
41
|
+
ref: value,
|
|
42
|
+
}
|
|
43
|
+
: {
|
|
44
|
+
[TOKEN_ID]: token[TOKEN_ID],
|
|
45
|
+
[TOKEN_OVERRIDE]: true,
|
|
46
|
+
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
47
|
+
[TOKEN_VAR_NAME]: token[TOKEN_VAR_NAME] ?? null,
|
|
48
|
+
value,
|
|
49
|
+
ref: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
37
53
|
function isExtractedTokenRef(value: unknown): value is StyleTokenData {
|
|
38
54
|
return !!value &&
|
|
39
55
|
typeof (value as StyleTokenData)[TOKEN_ID] === 'string' &&
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StyleToken, StyleTokenData, StyleTokenOverride } from '../../style/token';
|
|
2
|
+
import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from './symbols';
|
|
3
|
+
|
|
4
|
+
export type ExtractedStyleTokenVarName = {
|
|
5
|
+
[TOKEN_VAR_NAME]?: string | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
|
|
9
|
+
return !!value &&
|
|
10
|
+
typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
|
|
11
|
+
(value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
|
|
15
|
+
return !!value &&
|
|
16
|
+
typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
|
|
17
|
+
(value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
|
|
21
|
+
return token[TOKEN_ID];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getStyleTokenName<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string | null {
|
|
25
|
+
return token[TOKEN_NAME] ?? null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getStyleTokenVarName<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string | null {
|
|
29
|
+
return (token as ExtractedStyleTokenVarName)[TOKEN_VAR_NAME] ?? null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function getStyleTokenNameFromId(id: string | undefined): string | null {
|
|
2
|
+
if (!id) return null;
|
|
3
|
+
|
|
4
|
+
const parts = id.split('--');
|
|
5
|
+
const first = normalizeStyleTokenName(parts[0]);
|
|
6
|
+
|
|
7
|
+
if (!first) {
|
|
8
|
+
return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join('--')) : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return normalizeStyleTokenName([first, ...parts.slice(1)].join('--'));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getChildStyleTokenName(
|
|
15
|
+
name: string | null | undefined,
|
|
16
|
+
child: string | null | undefined,
|
|
17
|
+
) {
|
|
18
|
+
const childName = normalizeStyleTokenName(child);
|
|
19
|
+
if (!childName) return normalizeStyleTokenName(name);
|
|
20
|
+
|
|
21
|
+
const parentName = normalizeStyleTokenName(name);
|
|
22
|
+
return parentName ? parentName + '--' + childName : childName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function normalizeStyleTokenName(value: string | null | undefined): string | null {
|
|
26
|
+
if (!value) return null;
|
|
27
|
+
|
|
28
|
+
value = value.trim();
|
|
29
|
+
if (!value) return null;
|
|
30
|
+
if (/^\d+$/.test(value)) return null;
|
|
31
|
+
if (isGeneratedTokenHash(value)) return null;
|
|
32
|
+
|
|
33
|
+
value = stripGenericTokenPrefix(value);
|
|
34
|
+
if (!value) return null;
|
|
35
|
+
|
|
36
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
37
|
+
if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
|
|
38
|
+
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isGeneratedTokenHash(value: string) {
|
|
43
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function stripGenericTokenPrefix(value: string) {
|
|
47
|
+
const parts = value.split('--');
|
|
48
|
+
|
|
49
|
+
while (parts[0] === 'token' || parts[0] === 'tokens') {
|
|
50
|
+
parts.shift();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return parts.join('--');
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { symbol } from '../../utils/symbol';
|
|
2
|
+
|
|
3
|
+
export const TOKEN_ID: unique symbol = symbol('style:token');
|
|
4
|
+
export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
|
|
5
|
+
export const TOKEN_NAME: unique symbol = symbol('style:token.name');
|
|
6
|
+
export const TOKEN_VAR_NAME: unique symbol = symbol('style:token.varName');
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
annotateThemeCall,
|
|
35
35
|
annotateTokenDeclaration,
|
|
36
36
|
getImportedName,
|
|
37
|
+
getObjectPropertyKey,
|
|
37
38
|
isStyleChainCall,
|
|
38
39
|
} from '../syntax';
|
|
39
40
|
import type { BabelCore, BabelTypes, NodePath } from '../utils/babel';
|
|
@@ -552,12 +553,13 @@ function getDebugStyleArg(
|
|
|
552
553
|
) {
|
|
553
554
|
const arg = getStyleObjectArg(path, state);
|
|
554
555
|
if (!arg) return arg;
|
|
556
|
+
const meta = getStyleCallMeta(path, state);
|
|
555
557
|
|
|
556
558
|
if (arg.type !== 'ObjectExpression') {
|
|
557
559
|
return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
558
560
|
}
|
|
559
561
|
|
|
560
|
-
|
|
562
|
+
const flattened = flattenDebugObjectExpression(
|
|
561
563
|
t,
|
|
562
564
|
arg,
|
|
563
565
|
path,
|
|
@@ -565,6 +567,8 @@ function getDebugStyleArg(
|
|
|
565
567
|
sourcemapTrace,
|
|
566
568
|
new Set(),
|
|
567
569
|
);
|
|
570
|
+
|
|
571
|
+
return appendTransformDebugFieldAliases(t, flattened, meta, state);
|
|
568
572
|
}
|
|
569
573
|
|
|
570
574
|
function getDebugCallLoc(
|
|
@@ -594,6 +598,14 @@ function getStyleObjectArg(
|
|
|
594
598
|
return path.node.arguments[styleArgIndex];
|
|
595
599
|
}
|
|
596
600
|
|
|
601
|
+
function getStyleCallMeta(
|
|
602
|
+
path: NodePath<BabelTypes.CallExpression>,
|
|
603
|
+
state: PluginState,
|
|
604
|
+
) {
|
|
605
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
606
|
+
return rootName ? state.styleMetas.get(rootName) ?? null : null;
|
|
607
|
+
}
|
|
608
|
+
|
|
597
609
|
function isSelectorStyleCall(
|
|
598
610
|
path: NodePath<BabelTypes.CallExpression>,
|
|
599
611
|
state: PluginState,
|
|
@@ -836,6 +848,72 @@ function flattenDebugObjectExpression(
|
|
|
836
848
|
return t.objectExpression(properties);
|
|
837
849
|
}
|
|
838
850
|
|
|
851
|
+
function appendTransformDebugFieldAliases(
|
|
852
|
+
t: typeof BabelTypes,
|
|
853
|
+
node: BabelTypes.ObjectExpression,
|
|
854
|
+
meta: StyleFnMeta | null,
|
|
855
|
+
state: PluginState,
|
|
856
|
+
) {
|
|
857
|
+
if (!meta || meta.mode !== 'StyleObject' || !meta.transform) return node;
|
|
858
|
+
|
|
859
|
+
const existing = new Set<string>();
|
|
860
|
+
for (const property of node.properties) {
|
|
861
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
862
|
+
const key = getObjectPropertyKey(property);
|
|
863
|
+
if (key) existing.add(key);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
const aliases: BabelTypes.ObjectProperty[] = [];
|
|
867
|
+
|
|
868
|
+
for (const property of node.properties) {
|
|
869
|
+
if (property.type !== 'ObjectProperty' || property.computed) continue;
|
|
870
|
+
|
|
871
|
+
const key = getObjectPropertyKey(property);
|
|
872
|
+
if (!key) continue;
|
|
873
|
+
|
|
874
|
+
const value = evaluateNode(property.value, getDebugEvalScope(state));
|
|
875
|
+
if (!value.ok) continue;
|
|
876
|
+
|
|
877
|
+
let transformed: Record<string, unknown>;
|
|
878
|
+
try {
|
|
879
|
+
transformed = meta.transform.transform({ [key]: value.value }) as Record<string, unknown>;
|
|
880
|
+
} catch {
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
for (const transformedKey of Object.keys(transformed)) {
|
|
885
|
+
if (existing.has(transformedKey)) continue;
|
|
886
|
+
|
|
887
|
+
existing.add(transformedKey);
|
|
888
|
+
aliases.push(createDebugFieldAlias(t, transformedKey, property));
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
if (!aliases.length) return node;
|
|
893
|
+
|
|
894
|
+
return t.objectExpression([
|
|
895
|
+
...node.properties,
|
|
896
|
+
...aliases,
|
|
897
|
+
]);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
function createDebugFieldAlias(
|
|
901
|
+
t: typeof BabelTypes,
|
|
902
|
+
key: string,
|
|
903
|
+
source: BabelTypes.ObjectProperty,
|
|
904
|
+
) {
|
|
905
|
+
const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral()) as DebugTraceProperty;
|
|
906
|
+
const sourceTrace = source as DebugTraceProperty;
|
|
907
|
+
|
|
908
|
+
alias.loc = source.loc;
|
|
909
|
+
alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
|
|
910
|
+
alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
|
|
911
|
+
alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
|
|
912
|
+
alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
|
|
913
|
+
|
|
914
|
+
return alias;
|
|
915
|
+
}
|
|
916
|
+
|
|
839
917
|
function resolveDebugSpreadObject(
|
|
840
918
|
t: typeof BabelTypes,
|
|
841
919
|
spread: BabelTypes.SpreadElement,
|