@fluentic/style 0.1.0-beta.2 → 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 +38 -16
- package/README.md +80 -23
- 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/compiler/types.ts +0 -1
- package/compiler/transform/debug/plugin.ts +79 -1
- package/compiler/transform/evaluator/evaluator.ts +76 -26
- package/compiler/transform/evaluator/tracer.ts +11 -1
- package/compiler/transform/extract/chain/chain.ts +8 -5
- package/compiler/transform/extract/plugin.ts +1 -1
- package/compiler/transform/extract/utils/replacement.ts +6 -1
- package/compiler/transform/extract/utils/state.ts +1 -0
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/compiler/utils/constants.ts +0 -4
- package/config/build.ts +5 -2
- package/config/config/debug.ts +24 -1
- package/config/config/dev.ts +8 -0
- package/config/configure.ts +10 -2
- package/dev/config.ts +2 -3
- package/dialect/namedTokens.ts +22 -5
- package/dist/{className-W2kDyeVl.js → className-Do2Crx4b.js} +2 -3
- package/dist/{className-W2kDyeVl.js.map → className-Do2Crx4b.js.map} +1 -1
- package/dist/{style-CYXTs1iu.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-BXcGyZUP.mjs → compiler-CE0ZgkdH.mjs} +274 -128
- 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-CLYMN3_p.js → config-BtANtGAh.js} +10 -5
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/{config-C1k9vUrM.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-DcYrUB-M.js.map → config-oKOjOTWi.js.map} +1 -1
- package/dist/{css-CohHH2tn.js → css-BewrRz3_.js} +3 -3
- package/dist/{css-CohHH2tn.js.map → css-BewrRz3_.js.map} +1 -1
- package/dist/{css-DfH4Gb1c.js → css-CiTI58yl.js} +294 -5
- 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-D_DL1yOz.js → css-Rc7ILf-3.js} +8 -9
- package/dist/{css-D_DL1yOz.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-9BZ_jVET.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-9BZ_jVET.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-DQdCrYoC.js.map → css_extra-DYtS3g6Z.js.map} +1 -1
- package/dist/{data-Ze8GNiJm.js → data-D7NFt4JG.js} +205 -11
- package/dist/data-D7NFt4JG.js.map +1 -0
- package/dist/{debug-DLmUG3Vh.js → debug-Cvpo5cVu.js} +4 -3
- package/dist/{debug-DLmUG3Vh.js.map → debug-Cvpo5cVu.js.map} +1 -1
- package/dist/debug-DycdGrul.js +45 -0
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-C2u78xuv.js → dev-DdRWa6dJ.js} +8 -8
- package/dist/{dev-C2u78xuv.js.map → dev-DdRWa6dJ.js.map} +1 -1
- package/dist/{dev-4TqJORRn.js → dev-px0_6TNq.js} +11 -5
- package/dist/dev-px0_6TNq.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-BKzZyg5V.js → elementMarker-ng0y3fN0.js} +8 -8
- package/dist/{elementMarker-BKzZyg5V.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 -5
- 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 +274 -69
- 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-C6690_nr.js → getClassName-CrNVjAoJ.js} +29 -8
- package/dist/getClassName-CrNVjAoJ.js.map +1 -0
- package/dist/{global-C7GsCW6Y.js → global-CZBlA9E7.js} +3 -3
- package/dist/{global-C7GsCW6Y.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-Berx-L-r.js → jsx-BY1iFewe.js} +3 -3
- package/dist/{jsx-Berx-L-r.js.map → jsx-BY1iFewe.js.map} +1 -1
- package/dist/{jsx-DsMajv_M.js → jsx-DL-DEAz8.js} +8 -7
- package/dist/{jsx-DsMajv_M.js.map → jsx-DL-DEAz8.js.map} +1 -1
- package/dist/{jsx_dev_runtime-DXlSD6kV.js → jsx_dev_runtime-aAhNYDeS.js} +2 -2
- package/dist/{jsx_dev_runtime-DXlSD6kV.js.map → jsx_dev_runtime-aAhNYDeS.js.map} +1 -1
- package/dist/{jsx_runtime-DPWo5qvV.js → jsx_runtime-C6i1bWlu.js} +2 -2
- package/dist/{jsx_runtime-DPWo5qvV.js.map → jsx_runtime-C6i1bWlu.js.map} +1 -1
- package/dist/{jsx_runtime-CMdEXGNZ.js → jsx_runtime-D7Y5up6H.js} +2 -2
- package/dist/{jsx_runtime-CMdEXGNZ.js.map → jsx_runtime-D7Y5up6H.js.map} +1 -1
- package/dist/{layer-DiNeeTgG.js → layer-BSxAr-hy.js} +4 -4
- package/dist/{layer-DiNeeTgG.js.map → layer-BSxAr-hy.js.map} +1 -1
- package/dist/{loader-DCT1Q9yi.mjs → loader-BmYS_Rju.mjs} +3 -3
- package/dist/{loader-DCT1Q9yi.mjs.map → loader-BmYS_Rju.mjs.map} +1 -1
- package/dist/{misc-o8pviMUi.mjs → misc-BIS_c7BJ.mjs} +2 -2
- package/dist/{misc-o8pviMUi.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-BzZSTVIh.js → property-BuLbzviK.js} +2 -2
- package/dist/{property-BzZSTVIh.js.map → property-BuLbzviK.js.map} +1 -1
- package/dist/{registry-D3x1EDJm.mjs → registry-IaXmLQzA.mjs} +2 -2
- package/dist/{registry-D3x1EDJm.mjs.map → registry-IaXmLQzA.mjs.map} +1 -1
- package/dist/{rules-Dz7Pu2K6.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-B_gJf5uj.cjs → shared-CaJuvw03.cjs} +270 -124
- package/dist/shared-CaJuvw03.cjs.map +1 -0
- package/dist/{shared-uAzFeq0x.mjs → shared-DdPTZ0O3.mjs} +4 -4
- package/dist/{shared-uAzFeq0x.mjs.map → shared-DdPTZ0O3.mjs.map} +1 -1
- package/dist/sheet-BWBzuy4D.js +7 -0
- package/dist/{sheet-DasbRnvy.js.map → sheet-BWBzuy4D.js.map} +1 -1
- package/dist/{sidecar-BUO1hKXu.mjs → sidecar-B3oCK9vC.mjs} +3 -3
- package/dist/{sidecar-BUO1hKXu.mjs.map → sidecar-B3oCK9vC.mjs.map} +1 -1
- package/dist/{style-BkeAZl0n.js → style-CGaJndOl.js} +102 -54
- package/dist/style-CGaJndOl.js.map +1 -0
- package/dist/{style-DUztHzBz.js → style-DDxjKdX0.js} +354 -48
- package/dist/style-DDxjKdX0.js.map +1 -0
- package/dist/style-S7LTQbRu.js +5 -0
- package/dist/{styleStore-DVDp-gI-.js → styleStore-0fARJlZV.js} +6 -6
- package/dist/{styleStore-DVDp-gI-.js.map → styleStore-0fARJlZV.js.map} +1 -1
- package/dist/{styleStore-BGJ2ZYtK.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-D0IL6JT8.js → trace-CFnhyCVf.js} +2 -2
- package/dist/{trace-D0IL6JT8.js.map → trace-CFnhyCVf.js.map} +1 -1
- package/dist/{trace-DR7_Rpkg.js → trace-ZtgeY-8s.js} +3 -3
- package/dist/{trace-DR7_Rpkg.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-CpA-dSpY.mjs → utils-B5Xqf1lV.mjs} +4 -4
- package/dist/{utils-CpA-dSpY.mjs.map → utils-B5Xqf1lV.mjs.map} +1 -1
- package/dist/{utils-D4YWF2K0.js → utils-B_VhPBHH.js} +4 -4
- package/dist/{utils-D4YWF2K0.js.map → utils-B_VhPBHH.js.map} +1 -1
- package/dist/{utils-R6QadAsY.js → utils-CDUaX81o.js} +3 -3
- package/dist/{utils-R6QadAsY.js.map → utils-CDUaX81o.js.map} +1 -1
- package/dist/{utils-DQGa0uzS.mjs → utils-DaAiEEIG.mjs} +3 -3
- package/dist/{utils-DQGa0uzS.mjs.map → utils-DaAiEEIG.mjs.map} +1 -1
- package/dist/{utils-BsbfH6cd.js → utils-DzydRwYo.js} +77 -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-DBtSe-9B.js → value-D08AocUs.js} +115 -62
- 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-Fb9xF5jS.mjs → webpack-CHydnRXB.mjs} +5 -5
- package/dist/{webpack-Fb9xF5jS.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-Cuh2JNxO.js +0 -263
- package/dist/className-Cuh2JNxO.js.map +0 -1
- package/dist/compiler-BXcGyZUP.mjs.map +0 -1
- package/dist/config-C1k9vUrM.js.map +0 -1
- package/dist/config-CLYMN3_p.js.map +0 -1
- package/dist/config-DcYrUB-M.js +0 -6
- package/dist/config-oI_yS50f.js +0 -1
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-DfH4Gb1c.js.map +0 -1
- package/dist/data-Ze8GNiJm.js.map +0 -1
- package/dist/debug-BefbXMq1.js +0 -15
- package/dist/debug-BefbXMq1.js.map +0 -1
- package/dist/debug-OG2wSB5R.js +0 -15
- package/dist/debug-OG2wSB5R.js.map +0 -1
- package/dist/dev-4TqJORRn.js.map +0 -1
- package/dist/extract-B9j4TBkU.js +0 -2
- package/dist/getClassName-C6690_nr.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-Dz7Pu2K6.js.map +0 -1
- package/dist/runtime-B3jHW9B1.js +0 -32
- package/dist/runtime-B3jHW9B1.js.map +0 -1
- package/dist/shared-B_gJf5uj.cjs.map +0 -1
- package/dist/sheet-DasbRnvy.js +0 -7
- package/dist/style-B0F1sgRZ.js +0 -5
- package/dist/style-BkeAZl0n.js.map +0 -1
- package/dist/style-CYXTs1iu.js.map +0 -1
- package/dist/style-DUztHzBz.js.map +0 -1
- package/dist/styleStore-BGJ2ZYtK.js.map +0 -1
- package/dist/token-CA1j7suG.js +0 -273
- package/dist/token-CA1j7suG.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/utils-BsbfH6cd.js.map +0 -1
- package/dist/value-CJG6EWe8.js +0 -85
- package/dist/value-CJG6EWe8.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DBtSe-9B.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,52 @@
|
|
|
1
1
|
# @fluentic/style
|
|
2
2
|
|
|
3
|
-
## 0.1.0-beta.
|
|
3
|
+
## 0.1.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
- Slim the extracted production runtime token path and fix named token refs in token-bound extracted styles.
|
|
6
8
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
|
|
16
|
+
## 0.1.0-beta.3
|
|
14
17
|
|
|
15
18
|
### Patch Changes
|
|
16
19
|
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
- fd4a705: Make production class names globally dedupe extracted rules by deriving callsite-local hashing from dev mode only. Keep debug class names configurable from plugin and runtime CSS options, with dev defaulting to readable names and production defaulting to compact hashes.
|
|
21
|
+
|
|
22
|
+
## 0.1.0-beta.2
|
|
23
|
+
|
|
24
|
+
This beta adds class-name style chains, Tailwind presets, and compiler support
|
|
25
|
+
for transform-driven styling.
|
|
26
|
+
|
|
27
|
+
### Highlights
|
|
28
|
+
|
|
29
|
+
- Add `createClassNameFn` for class-name-driven style builders.
|
|
30
|
+
- Support nested class-name values, conditional falsey entries, weighted
|
|
31
|
+
class-name tokens, selector chaining, at-rules, and merges.
|
|
32
|
+
- Add compiler extraction for class-name style chains.
|
|
33
|
+
- Add Tailwind presets for both style-object and class-name authoring.
|
|
34
|
+
- Add `classNameTransform`, `classNameValue`, and transform metadata for
|
|
35
|
+
preserving source class labels in emitted rules.
|
|
36
|
+
- Add named token compiler support for static extraction and theme override
|
|
37
|
+
identity.
|
|
38
|
+
- Add configurable transform class-name formatting and hash length behavior for
|
|
39
|
+
debug output.
|
|
22
40
|
|
|
23
41
|
## 0.1.0-beta.1
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
This patch beta improves typed selector authoring and documentation.
|
|
44
|
+
|
|
45
|
+
### Changes
|
|
26
46
|
|
|
27
|
-
- Add `createSelectorAssert` for typed custom selector validators
|
|
47
|
+
- Add `createSelectorAssert` for typed custom selector validators.
|
|
48
|
+
- Keep the public beta API moving with small usability refinements after
|
|
49
|
+
`0.1.0-beta.0`.
|
|
28
50
|
|
|
29
51
|
## 0.1.0-beta.0
|
|
30
52
|
|
package/README.md
CHANGED
|
@@ -8,9 +8,10 @@ explores a specific question inside that space: what if styles composed around
|
|
|
8
8
|
React components the same way props and state do?
|
|
9
9
|
|
|
10
10
|
With Fluentic, you start simple with type-safe `style(...)` and the JSX `css`
|
|
11
|
-
prop.
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
prop. If your team prefers utility class names, you can also create class-name
|
|
12
|
+
style chains, including a Tailwind-like preset. When a component needs variants,
|
|
13
|
+
themes, nested parts, or consumer overrides, add slots, scopes, tokens, and
|
|
14
|
+
`combineStyle(...)` so those styles stay organized around the component.
|
|
14
15
|
|
|
15
16
|
For production builds, styles are extracted into static atomic CSS output.
|
|
16
17
|
Dynamic values from props and state still work as usual.
|
|
@@ -100,6 +101,49 @@ export function Card() {
|
|
|
100
101
|
That is the smallest version of Fluentic Style: type-safe styles, selectors, and
|
|
101
102
|
a `css` prop.
|
|
102
103
|
|
|
104
|
+
## Class Name Chains
|
|
105
|
+
|
|
106
|
+
Fluentic's default authoring path is object style chains, but class-name chains
|
|
107
|
+
are supported too. A class-name chain still produces Fluentic style data, so it
|
|
108
|
+
can use the same `css` prop, selector methods, slots, scopes, debugging, runtime
|
|
109
|
+
resolution, and production extraction path.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { createClassNameFn } from '@fluentic/style';
|
|
113
|
+
import {
|
|
114
|
+
createTailwindClassNamePreset,
|
|
115
|
+
defaultTailwindTheme,
|
|
116
|
+
} from '@fluentic/style/presets/tailwind';
|
|
117
|
+
|
|
118
|
+
const tailwind = createTailwindClassNamePreset({
|
|
119
|
+
theme: defaultTailwindTheme,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export const { className: cx } = createClassNameFn({
|
|
123
|
+
selectors: tailwind.selectors,
|
|
124
|
+
transform: tailwind.transform,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const button = cx(
|
|
128
|
+
'inline-flex',
|
|
129
|
+
'items-center',
|
|
130
|
+
'gap-2',
|
|
131
|
+
'rounded-md',
|
|
132
|
+
'bg-blue-600',
|
|
133
|
+
'px-4',
|
|
134
|
+
'py-2',
|
|
135
|
+
'text-white',
|
|
136
|
+
)
|
|
137
|
+
.hover('bg-blue-700')
|
|
138
|
+
.md('px-6');
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Class names get their meaning from a user-land transform or a preset. See
|
|
142
|
+
[Class Name Style Chains](https://fluenticstack.com/style/docs/beyond-the-basics/class-name-style-chains/)
|
|
143
|
+
for the generic API, or
|
|
144
|
+
[Tailwind Class Name Preset](https://fluenticstack.com/style/docs/presets/tailwind/class-name/)
|
|
145
|
+
for the built-in Tailwind-like class-name vocabulary.
|
|
146
|
+
|
|
103
147
|
## Scale Into Components
|
|
104
148
|
|
|
105
149
|
When a component becomes reusable, give its styles component structure.
|
|
@@ -333,7 +377,19 @@ For Next.js and other bundlers, see the
|
|
|
333
377
|
Benchmarks live in the repository's `benchmark/` folder and run against
|
|
334
378
|
production builds. Current benchmark snapshots:
|
|
335
379
|
|
|
336
|
-
|
|
380
|
+
The main production checks are runtime cost and bundle size. In the production
|
|
381
|
+
path most apps use, Fluentic extracts CSS at build time and ships the extracted
|
|
382
|
+
production runtime for `css` prop composition, dynamic values, class-name
|
|
383
|
+
merging, and token resolution. That runtime entry currently reports `4.45 KB`
|
|
384
|
+
min+gzip.
|
|
385
|
+
Browser and SSR benchmarks track whether style resolution stays fast in
|
|
386
|
+
app-shaped renders. See the
|
|
387
|
+
[Bundle Size](https://fluenticstack.com/style/docs/benchmark/bundle-size/),
|
|
388
|
+
[React App](https://fluenticstack.com/style/docs/benchmark/react-app/), and
|
|
389
|
+
[SSR Style](https://fluenticstack.com/style/docs/benchmark/ssr-style/) reports
|
|
390
|
+
for what each number measures and how to rerun it.
|
|
391
|
+
|
|
392
|
+
[React app](https://fluenticstack.com/style/docs/benchmark/react-app/), 1500-row dashboard:
|
|
337
393
|
|
|
338
394
|
| Case | Mount | Style Update |
|
|
339
395
|
| -------------------------- | ---------- | ------------ |
|
|
@@ -347,7 +403,7 @@ React app, 1500-row dashboard:
|
|
|
347
403
|
| vanilla-extract DOM | `39.85 ms` | `17.65 ms` |
|
|
348
404
|
| CSS Modules DOM | `40.35 ms` | `17.75 ms` |
|
|
349
405
|
|
|
350
|
-
SSR render-only, 500 rows:
|
|
406
|
+
[SSR render-only](https://fluenticstack.com/style/docs/benchmark/ssr-style/), 500 rows:
|
|
351
407
|
|
|
352
408
|
| Case | Dashboard Mean | Composition Mean |
|
|
353
409
|
| --------------- | -------------- | ---------------- |
|
|
@@ -357,7 +413,7 @@ SSR render-only, 500 rows:
|
|
|
357
413
|
| Fluentic token | `7.667 ms` | `8.253 ms` |
|
|
358
414
|
| StyleX | `6.826 ms` | `8.059 ms` |
|
|
359
415
|
|
|
360
|
-
Compiler transform, 100 files per corpus:
|
|
416
|
+
[Compiler transform](https://fluenticstack.com/style/docs/benchmark/compiler/), 100 files per corpus:
|
|
361
417
|
|
|
362
418
|
| Corpus | Fluentic Warm | StyleX Babel |
|
|
363
419
|
| ------------- | ------------- | ------------ |
|
|
@@ -371,23 +427,24 @@ and the public suite list.
|
|
|
371
427
|
|
|
372
428
|
## Package Exports
|
|
373
429
|
|
|
374
|
-
| Import
|
|
375
|
-
|
|
|
376
|
-
| `@fluentic/style`
|
|
377
|
-
| `@fluentic/style/css`
|
|
378
|
-
| `@fluentic/style/selector`
|
|
379
|
-
| `@fluentic/style/config`
|
|
380
|
-
| `@fluentic/style/compiler`
|
|
381
|
-
| `@fluentic/style/
|
|
382
|
-
| `@fluentic/style/dev
|
|
383
|
-
| `@fluentic/style/
|
|
384
|
-
| `@fluentic/style/
|
|
385
|
-
| `@fluentic/style/plugin/
|
|
386
|
-
| `@fluentic/style/plugin/
|
|
387
|
-
| `@fluentic/style/plugin/
|
|
388
|
-
| `@fluentic/style/plugin/
|
|
389
|
-
| `@fluentic/style/plugin/
|
|
390
|
-
| `@fluentic/style/plugin/
|
|
430
|
+
| Import | Purpose |
|
|
431
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
432
|
+
| `@fluentic/style` | Runtime API, style builders, hooks, tokens, themes, and types. |
|
|
433
|
+
| `@fluentic/style/css` | CSS helper APIs for keyframes, font faces, and at-rules. |
|
|
434
|
+
| `@fluentic/style/selector` | Selector constructors, validators, presets, and priority helpers. |
|
|
435
|
+
| `@fluentic/style/config` | Runtime configuration helpers. |
|
|
436
|
+
| `@fluentic/style/compiler` | Node-only compiler entry used by build integrations and compiler benchmarks. |
|
|
437
|
+
| `@fluentic/style/presets/tailwind` | [Tailwind-like object fields and class-name chains](https://fluenticstack.com/style/docs/presets/tailwind/). |
|
|
438
|
+
| `@fluentic/style/dev` | Development utilities. |
|
|
439
|
+
| `@fluentic/style/dev/rsc` | React Server Component dev client boundary. |
|
|
440
|
+
| `@fluentic/style/jsx` | [JSX import source without a bundler plugin](https://fluenticstack.com/style/docs/integrations/runtime-only-mode/). |
|
|
441
|
+
| `@fluentic/style/plugin/jsx` | [JSX import source after adding a bundler plugin](https://fluenticstack.com/style/docs/integrations/jsx-runtime-setup/). |
|
|
442
|
+
| `@fluentic/style/plugin/nextjs` | [Next.js App Router integration](https://fluenticstack.com/style/docs/integrations/nextjs/). |
|
|
443
|
+
| `@fluentic/style/plugin/vite` | [Vite plugin](https://fluenticstack.com/style/docs/integrations/vite/). |
|
|
444
|
+
| `@fluentic/style/plugin/webpack` | [Webpack plugin](https://fluenticstack.com/style/docs/integrations/webpack/). |
|
|
445
|
+
| `@fluentic/style/plugin/rspack` | [Rspack plugin](https://fluenticstack.com/style/docs/integrations/rspack/). |
|
|
446
|
+
| `@fluentic/style/plugin/farm` | [Farm plugin](https://fluenticstack.com/style/docs/integrations/farm/). |
|
|
447
|
+
| `@fluentic/style/plugin/parcel` | [Parcel plugin](https://fluenticstack.com/style/docs/integrations/parcel/). |
|
|
391
448
|
|
|
392
449
|
## Repository Guide
|
|
393
450
|
|
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');
|