@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.2
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 +20 -0
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +25 -4
- package/atomic/debug/className/className.ts +23 -2
- package/atomic/element.ts +5 -2
- package/atomic/theme.ts +4 -2
- package/atomic/token.ts +4 -2
- package/atomic/utils/css.ts +44 -19
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +78 -0
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +447 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +34 -0
- package/builder/data/create.ts +6 -6
- package/builder/data/data.ts +7 -7
- package/builder/data/debug.ts +1 -0
- package/builder/data/is.ts +3 -3
- package/builder/data/merge/scope.ts +18 -19
- package/builder/data/merge/style.ts +11 -0
- package/builder/data/state.ts +1 -0
- package/builder/style_builder.ts +17 -17
- package/builder/style_fns.ts +33 -33
- package/builder/types/alias.ts +10 -10
- package/builder/types/fns.ts +11 -11
- package/builder/types/types.ts +5 -5
- package/compiler/transform/debug/plugin.ts +8 -3
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +31 -2
- package/compiler/transform/evaluator/tracer.ts +2 -8
- package/compiler/transform/extract/chain/chain.ts +589 -24
- package/compiler/transform/extract/plugin.ts +4 -1
- package/compiler/utils/constants.ts +4 -0
- package/compiler/utils/file_resolver.ts +1 -0
- package/compiler/utils/import_source.ts +3 -2
- package/config/config/css.ts +3 -0
- package/config/config/dev.ts +9 -1
- package/config/types.ts +7 -0
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +136 -0
- package/dist/{className-DC2Cq8p3.js → className-Cuh2JNxO.js} +19 -7
- package/dist/className-Cuh2JNxO.js.map +1 -0
- package/dist/{className-C1Ht5Wvv.js → className-W2kDyeVl.js} +2 -2
- package/dist/{className-C1Ht5Wvv.js.map → className-W2kDyeVl.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-DENc3a2R.mjs → compiler-BXcGyZUP.mjs} +554 -60
- package/dist/compiler-BXcGyZUP.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-C1k9vUrM.js +32 -0
- package/dist/config-C1k9vUrM.js.map +1 -0
- package/dist/{config-BryWDfQX.js → config-CLYMN3_p.js} +3 -2
- package/dist/{config-BryWDfQX.js.map → config-CLYMN3_p.js.map} +1 -1
- package/dist/config-DcYrUB-M.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-DcYrUB-M.js.map} +1 -1
- package/dist/config-oI_yS50f.js +1 -0
- package/dist/css-CELBp6Gu.js +58 -0
- package/dist/css-CELBp6Gu.js.map +1 -0
- package/dist/{css-BowBszUt.js → css-CohHH2tn.js} +17 -17
- package/dist/css-CohHH2tn.js.map +1 -0
- package/dist/{css-DcazYor9.js → css-D_DL1yOz.js} +10 -8
- package/dist/css-D_DL1yOz.js.map +1 -0
- package/dist/{css-ByOrugEX.js → css-DfH4Gb1c.js} +77 -77
- package/dist/css-DfH4Gb1c.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{css_extra-oIi3UEPK.js → css_extra-9BZ_jVET.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-9BZ_jVET.js.map} +1 -1
- package/dist/{css_extra-DlOnsnR1.js → css_extra-DQdCrYoC.js} +2 -2
- package/dist/{css_extra-oIi3UEPK.js.map → css_extra-DQdCrYoC.js.map} +1 -1
- package/dist/{data-BsqOa5br.js → data-Ze8GNiJm.js} +22 -12
- package/dist/data-Ze8GNiJm.js.map +1 -0
- package/dist/{debug-BAw63qX6.js → debug-BefbXMq1.js} +2 -2
- package/dist/{debug-BAw63qX6.js.map → debug-BefbXMq1.js.map} +1 -1
- package/dist/{debug-n2aZQBSa.js → debug-DLmUG3Vh.js} +3 -3
- package/dist/debug-DLmUG3Vh.js.map +1 -0
- package/dist/{debug-DGki_v7g.js → debug-OG2wSB5R.js} +2 -2
- package/dist/{debug-DGki_v7g.js.map → debug-OG2wSB5R.js.map} +1 -1
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-DfBbuLeE.js → dev-4TqJORRn.js} +7 -3
- package/dist/dev-4TqJORRn.js.map +1 -0
- package/dist/{dev-CcphAa3R.js → dev-C2u78xuv.js} +7 -7
- package/dist/{dev-CcphAa3R.js.map → dev-C2u78xuv.js.map} +1 -1
- 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-BKzZyg5V.js} +10 -8
- package/dist/{elementMarker-Bu7gDAkE.js.map → elementMarker-BKzZyg5V.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +12 -9
- package/dist/entry/prod/css.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 +4 -4
- package/dist/entry/prod.js +8 -8
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +5 -5
- 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 +342 -105
- 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 +4 -4
- package/dist/entry/rsc-prod.js +7 -7
- package/dist/extract-B9j4TBkU.js +2 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-C6690_nr.js} +3 -3
- package/dist/getClassName-C6690_nr.js.map +1 -0
- package/dist/global-C7GsCW6Y.js +14 -0
- package/dist/{global-CvfmFLsK.js.map → global-C7GsCW6Y.js.map} +1 -1
- package/dist/global-zaCE-g1C.js +31 -0
- package/dist/global-zaCE-g1C.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Bycpk3MR.js} +53 -37
- package/dist/hash-Bycpk3MR.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-CwTeyUxr.js → jsx-Berx-L-r.js} +3 -3
- package/dist/{jsx-CwTeyUxr.js.map → jsx-Berx-L-r.js.map} +1 -1
- package/dist/{jsx-D2BksHSv.js → jsx-DsMajv_M.js} +7 -7
- package/dist/{jsx-D2BksHSv.js.map → jsx-DsMajv_M.js.map} +1 -1
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-DXlSD6kV.js} +2 -2
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-DXlSD6kV.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-CMdEXGNZ.js} +2 -2
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-CMdEXGNZ.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-DPWo5qvV.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-DPWo5qvV.js.map} +1 -1
- package/dist/{layer-D1SaH07m.js → layer-DiNeeTgG.js} +4 -4
- package/dist/{layer-D1SaH07m.js.map → layer-DiNeeTgG.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-DCT1Q9yi.mjs} +3 -3
- package/dist/{loader-B5Kw0DD-.mjs.map → loader-DCT1Q9yi.mjs.map} +1 -1
- package/dist/{misc-DCdYYyhK.mjs → misc-o8pviMUi.mjs} +7 -3
- package/dist/{misc-DCdYYyhK.mjs.map → misc-o8pviMUi.mjs.map} +1 -1
- package/dist/namedTokens-BUa6raTb.js +83 -0
- package/dist/namedTokens-BUa6raTb.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 +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +1 -1
- package/dist/plugin/vite/index.mjs +11 -8
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +971 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{property-CnLFt5kx.js → property-BzZSTVIh.js} +2 -2
- package/dist/{property-CnLFt5kx.js.map → property-BzZSTVIh.js.map} +1 -1
- package/dist/{registry-yHLRxyoo.mjs → registry-D3x1EDJm.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-D3x1EDJm.mjs.map} +1 -1
- package/dist/{rules-9HSO1pxL.js → rules-Dz7Pu2K6.js} +13 -10
- package/dist/rules-Dz7Pu2K6.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → runtime-B3jHW9B1.js} +3 -24
- package/dist/runtime-B3jHW9B1.js.map +1 -0
- package/dist/server.js +13 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-B_gJf5uj.cjs} +554 -60
- package/dist/shared-B_gJf5uj.cjs.map +1 -0
- package/dist/{shared-CxbHR89f.mjs → shared-uAzFeq0x.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-uAzFeq0x.mjs.map} +1 -1
- package/dist/sheet-DasbRnvy.js +7 -0
- package/dist/sheet-DasbRnvy.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BUO1hKXu.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BUO1hKXu.mjs.map} +1 -1
- package/dist/style-B0F1sgRZ.js +5 -0
- package/dist/{style-DgHbdbdF.js → style-BkeAZl0n.js} +258 -82
- package/dist/style-BkeAZl0n.js.map +1 -0
- package/dist/{style-B1UUqjj5.js → style-CYXTs1iu.js} +35 -7
- package/dist/style-CYXTs1iu.js.map +1 -0
- package/dist/{style-v2bf70TZ.js → style-DUztHzBz.js} +439 -123
- package/dist/style-DUztHzBz.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → styleStore-BGJ2ZYtK.js} +16 -7
- package/dist/styleStore-BGJ2ZYtK.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-DVDp-gI-.js} +6 -5
- package/dist/{styleStore-DyNXBcUK.js.map → styleStore-DVDp-gI-.js.map} +1 -1
- package/dist/{token-u_tM-mtg.js → token-CA1j7suG.js} +99 -30
- package/dist/token-CA1j7suG.js.map +1 -0
- package/dist/token-DTOyFLmp.js +58 -0
- package/dist/token-DTOyFLmp.js.map +1 -0
- package/dist/{trace-CU0rvNYr.js → trace-D0IL6JT8.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-D0IL6JT8.js.map} +1 -1
- package/dist/{trace-Bu_qOqRy.js → trace-DR7_Rpkg.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-DR7_Rpkg.js.map} +1 -1
- package/dist/transform-BTJOg8Hg.js +23 -0
- package/dist/transform-BTJOg8Hg.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-BsbfH6cd.js} +147 -76
- package/dist/utils-BsbfH6cd.js.map +1 -0
- package/dist/{utils-CEaq_c-A.mjs → utils-CpA-dSpY.mjs} +4 -4
- package/dist/{utils-CEaq_c-A.mjs.map → utils-CpA-dSpY.mjs.map} +1 -1
- package/dist/{utils-D7FAOyg6.js → utils-D4YWF2K0.js} +4 -4
- package/dist/{utils-D7FAOyg6.js.map → utils-D4YWF2K0.js.map} +1 -1
- package/dist/{utils-Bdbqn0f8.mjs → utils-DQGa0uzS.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DQGa0uzS.mjs.map} +1 -1
- package/dist/{utils-CWNHx4EC.js → utils-R6QadAsY.js} +3 -3
- package/dist/{utils-CWNHx4EC.js.map → utils-R6QadAsY.js.map} +1 -1
- package/dist/utils.js +3 -3
- package/dist/value-CJG6EWe8.js +85 -0
- package/dist/value-CJG6EWe8.js.map +1 -0
- package/dist/value-D-ZcRzLA.js +42 -0
- package/dist/value-D-ZcRzLA.js.map +1 -0
- package/dist/{value-BR4e2MKt.js → value-DBtSe-9B.js} +116 -26
- package/dist/value-DBtSe-9B.js.map +1 -0
- package/dist/{valueRef-lshFk1Cs.js → valueRef-CsLVJwjA.js} +2 -2
- package/dist/{valueRef-lshFk1Cs.js.map → valueRef-CsLVJwjA.js.map} +1 -1
- package/dist/{webpack-Dh6lox2l.mjs → webpack-Fb9xF5jS.mjs} +5 -5
- package/dist/{webpack-Dh6lox2l.mjs.map → webpack-Fb9xF5jS.mjs.map} +1 -1
- 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/runtime.ts +1 -1
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_dev.ts +12 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/package.json +26 -9
- package/plugin/bundler/vite/plugin.ts +2 -1
- package/plugin/bundler/vite/state.ts +10 -5
- package/plugin/utils/runtimeEntry.ts +12 -0
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +208 -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 +430 -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/core/cache/pool.ts +1 -1
- package/runtime/extract/getClassName.ts +1 -6
- package/runtime/extract/index.ts +1 -1
- package/runtime/index.ts +8 -1
- package/runtime/types.ts +4 -2
- package/style/classname.ts +41 -0
- package/style/index.ts +1 -0
- package/style/style.ts +30 -11
- package/style/theme.ts +4 -2
- package/style/transform.ts +41 -2
- package/utils/hash.ts +4 -0
- package/atomic/layer/README.md +0 -116
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.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.map +0 -1
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-DfBbuLeE.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/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.map +0 -1
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @fluentic/style
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add class-name style chains with `createClassNameFn`, weighted utility values,
|
|
8
|
+
selector chaining, at-rule support, merge support, and static compiler
|
|
9
|
+
extraction.
|
|
10
|
+
- Split the Tailwind preset into style-object and class-name entry points so
|
|
11
|
+
teams can choose object-first or utility-class authoring from the same preset
|
|
12
|
+
package.
|
|
13
|
+
- Add named token compiler support and docs for transform extraction behavior.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Improve debug class names for transformed class utilities, including readable
|
|
18
|
+
transform class metadata in extracted output.
|
|
19
|
+
- Refresh docs for presets, class-name chains, numeric values, runtime/compiler
|
|
20
|
+
tradeoffs, plugin options, and imports.
|
|
21
|
+
- Add a Vite React Tailwind className example app.
|
|
22
|
+
|
|
3
23
|
## 0.1.0-beta.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/atomic/atRule/utils.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../../config/config/css';
|
|
1
2
|
import { type NamedAtRuleFormat, type NamedAtRuleInfo, type TokenNameFormat } from '../../config/types';
|
|
2
3
|
import { getStyleTokenId, isStyleTokenData, type StyleTokenData } from '../../style/token';
|
|
3
4
|
import { getCssPropertyName } from '../property';
|
|
4
5
|
import { getTokenVar } from '../token';
|
|
5
|
-
import { getIdentifierSafeHash } from '../utils/css';
|
|
6
6
|
import { createNameFormatter } from '../utils/format';
|
|
7
|
+
import { getIdentifierSafeHash } from '../utils/hash';
|
|
7
8
|
import { getCssPropertyValue } from '../value';
|
|
8
9
|
|
|
9
10
|
export function createAtRuleNameFormatter(defaultFormat: NamedAtRuleFormat, prefix?: string) {
|
|
@@ -14,7 +15,7 @@ export function createAtRuleNameFormatter(defaultFormat: NamedAtRuleFormat, pref
|
|
|
14
15
|
id: string,
|
|
15
16
|
info: NamedAtRuleInfo,
|
|
16
17
|
) => {
|
|
17
|
-
const hash = getIdentifierSafeHash(id);
|
|
18
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
18
19
|
const name = formatter(format || defaultFormat, hash, info);
|
|
19
20
|
|
|
20
21
|
if (!prefix) return name;
|
package/atomic/className.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { BuilderCallsite, ItemSelector } from '../builder/data';
|
|
2
|
-
import
|
|
2
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
3
|
+
import { DEV_CONFIG } from '../config/config/dev';
|
|
4
|
+
import type { ClassNameFormat, ScopeClassNameFormat, TransformClassNameFormat } from '../config/types';
|
|
3
5
|
import { hashString } from '../utils/hash';
|
|
4
|
-
import { getDebugClassName, getDebugScopeClassName } from './debug/className';
|
|
6
|
+
import { getDebugClassName, getDebugScopeClassName, getDebugTransformClassName } from './debug/className';
|
|
5
7
|
import { getDebugPropertyName } from './debug/property';
|
|
6
8
|
import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
|
|
7
|
-
import { getIdentifierSafeHash } from './utils/
|
|
9
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
8
10
|
import { getSelectorHash, getSelectorText } from './utils/selector';
|
|
9
11
|
|
|
10
12
|
export function getAtomicClassName(
|
|
@@ -18,6 +20,9 @@ export function getAtomicClassName(
|
|
|
18
20
|
localClassName: boolean,
|
|
19
21
|
debugClassName: boolean,
|
|
20
22
|
classNameFormat: ClassNameFormat | null,
|
|
23
|
+
transformClassName: string | null,
|
|
24
|
+
transformClassNameFormat: TransformClassNameFormat | null,
|
|
25
|
+
hashLength: number | null = null,
|
|
21
26
|
) {
|
|
22
27
|
let hash = property;
|
|
23
28
|
|
|
@@ -28,10 +33,21 @@ export function getAtomicClassName(
|
|
|
28
33
|
hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
|
|
29
34
|
hash += '\n' + getCallsiteHash(callsite, localClassName);
|
|
30
35
|
|
|
31
|
-
hash = getIdentifierSafeHash(
|
|
36
|
+
hash = getIdentifierSafeHash(
|
|
37
|
+
hash,
|
|
38
|
+
hashLength ?? getRuntimeClassNameHashLength(debugClassName),
|
|
39
|
+
);
|
|
32
40
|
|
|
33
41
|
if (!debugClassName) return hash;
|
|
34
42
|
|
|
43
|
+
if (transformClassName) {
|
|
44
|
+
return getDebugTransformClassName(
|
|
45
|
+
transformClassNameFormat,
|
|
46
|
+
hash,
|
|
47
|
+
{ className: transformClassName },
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
const propertyName = getDebugPropertyName(property, value);
|
|
36
52
|
|
|
37
53
|
const className = getDebugClassName(
|
|
@@ -59,6 +75,11 @@ export function getAtomicClassName(
|
|
|
59
75
|
return className;
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
function getRuntimeClassNameHashLength(debugClassName: boolean) {
|
|
79
|
+
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
80
|
+
return CSS_CONFIG.hashLength ?? 7;
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
export function getScopeClassName(
|
|
63
84
|
className: string,
|
|
64
85
|
scopeClassNameFormat: ScopeClassNameFormat | null,
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ClassNameFormat,
|
|
3
|
+
ClassNameInfo,
|
|
4
|
+
ScopeClassNameFormat,
|
|
5
|
+
ScopeClassNameInfo,
|
|
6
|
+
TransformClassNameFormat,
|
|
7
|
+
TransformClassNameInfo,
|
|
8
|
+
} from '../../../config/types';
|
|
2
9
|
import { createNameFormatter } from '../../utils/format';
|
|
3
10
|
|
|
4
|
-
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
11
|
+
export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash';
|
|
12
|
+
|
|
13
|
+
export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
|
|
5
14
|
|
|
6
15
|
export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
|
|
7
16
|
|
|
@@ -17,6 +26,10 @@ export const formatScopeClassName = createNameFormatter<ScopeClassNameInfo>([
|
|
|
17
26
|
'className',
|
|
18
27
|
]);
|
|
19
28
|
|
|
29
|
+
export const formatTransformClassName = createNameFormatter<TransformClassNameInfo>([
|
|
30
|
+
'className',
|
|
31
|
+
]);
|
|
32
|
+
|
|
20
33
|
export function getDebugClassName(
|
|
21
34
|
format: ClassNameFormat | null,
|
|
22
35
|
hash: string,
|
|
@@ -25,6 +38,14 @@ export function getDebugClassName(
|
|
|
25
38
|
return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
|
|
26
39
|
}
|
|
27
40
|
|
|
41
|
+
export function getDebugTransformClassName(
|
|
42
|
+
format: TransformClassNameFormat | null,
|
|
43
|
+
hash: string,
|
|
44
|
+
info: TransformClassNameInfo,
|
|
45
|
+
) {
|
|
46
|
+
return formatTransformClassName(format || TRANSFORM_CLASS_NAME_FORMAT, hash, info);
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
export function getDebugScopeClassName(
|
|
29
50
|
format: ScopeClassNameFormat | null,
|
|
30
51
|
info: ScopeClassNameInfo,
|
package/atomic/element.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
2
|
+
import { DEV_CONFIG } from '../config/config/dev';
|
|
1
3
|
import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
|
|
2
|
-
import { escapeCssIdent
|
|
4
|
+
import { escapeCssIdent } from './utils/css';
|
|
3
5
|
import { sanitizeDebugName } from './utils/debug';
|
|
4
6
|
import { createNameFormatter } from './utils/format';
|
|
7
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
5
8
|
|
|
6
9
|
export const ELEMENT_CLASS_NAME_FORMAT = '@(name)';
|
|
7
10
|
|
|
@@ -15,7 +18,7 @@ export function getElementClassName(
|
|
|
15
18
|
elementClassNameFormat: ElementClassNameFormat | null,
|
|
16
19
|
) {
|
|
17
20
|
const name = sanitizeDebugName(label) || null;
|
|
18
|
-
const hash = getIdentifierSafeHash(id);
|
|
21
|
+
const hash = getIdentifierSafeHash(id, DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3);
|
|
19
22
|
|
|
20
23
|
return formatElementClassName(
|
|
21
24
|
elementClassNameFormat || ELEMENT_CLASS_NAME_FORMAT,
|
package/atomic/theme.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { ThemeNameFormat, ThemeNameInfo, TokenNameFormat } from '../config/types';
|
|
2
3
|
import type { StyleTokenOverride } from '../style/token';
|
|
3
4
|
import { getTokenOverrideValue, getTokenVarName } from './token';
|
|
4
|
-
import { escapeCssIdent, escapeCssValue
|
|
5
|
+
import { escapeCssIdent, escapeCssValue } from './utils/css';
|
|
5
6
|
import { createNameFormatter } from './utils/format';
|
|
7
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
6
8
|
|
|
7
9
|
export const THEME_NAME_FORMAT = 'theme[-(name)]-$hash';
|
|
8
10
|
|
|
@@ -15,7 +17,7 @@ export function createThemeClassName(
|
|
|
15
17
|
) {
|
|
16
18
|
return formatThemeName(
|
|
17
19
|
themeNameFormat || THEME_NAME_FORMAT,
|
|
18
|
-
getIdentifierSafeHash(id),
|
|
20
|
+
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
19
21
|
{ name },
|
|
20
22
|
);
|
|
21
23
|
}
|
package/atomic/token.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { TokenNameFormat, TokenNameInfo } from '../config/types';
|
|
2
3
|
import { getStyleTokenId, type StyleTokenData, type StyleTokenOverride } from '../style/token';
|
|
3
|
-
import { getCssVar, getCssVarRawFallback
|
|
4
|
+
import { getCssVar, getCssVarRawFallback } from './utils/css';
|
|
4
5
|
import { createNameFormatter } from './utils/format';
|
|
6
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
5
7
|
|
|
6
8
|
export const TOKEN_NAME_FORMAT = 'token[-(name)]-$hash';
|
|
7
9
|
|
|
@@ -15,7 +17,7 @@ export function getTokenVarName(
|
|
|
15
17
|
|
|
16
18
|
const name = formatTokenName(
|
|
17
19
|
format || TOKEN_NAME_FORMAT,
|
|
18
|
-
getIdentifierSafeHash(id),
|
|
20
|
+
getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
|
|
19
21
|
{ name: id },
|
|
20
22
|
);
|
|
21
23
|
|
package/atomic/utils/css.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { hashString } from '../../utils/hash';
|
|
2
|
-
|
|
3
1
|
export function getCssVar(varName: string, value: string) {
|
|
4
2
|
return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
|
|
5
3
|
}
|
|
@@ -21,29 +19,56 @@ export function escapeCssValue(value: string): string {
|
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export function escapeCssIdent(ident: string): string {
|
|
24
|
-
|
|
22
|
+
let result = '';
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
for (let i = 0; i < ident.length; i++) {
|
|
25
|
+
const char = ident.charAt(i);
|
|
26
|
+
const code = ident.charCodeAt(i);
|
|
27
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (code === 0) {
|
|
30
|
+
result += '\uFFFD';
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
if (
|
|
35
|
+
(code >= 1 && code <= 31) ||
|
|
36
|
+
code === 127 ||
|
|
37
|
+
(i === 0 && code >= 48 && code <= 57) ||
|
|
38
|
+
(i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45)
|
|
39
|
+
) {
|
|
40
|
+
result += '\\' + code.toString(16) + ' ';
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
45
|
+
result += '\\-';
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (code >= 0xD800 && code <= 0xDBFF && nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
|
|
50
|
+
result += char + ident.charAt(++i);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
if (
|
|
55
|
+
code >= 128 ||
|
|
56
|
+
code === 45 ||
|
|
57
|
+
code === 95 ||
|
|
58
|
+
(code >= 48 && code <= 57) ||
|
|
59
|
+
(code >= 65 && code <= 90) ||
|
|
60
|
+
(code >= 97 && code <= 122)
|
|
61
|
+
) {
|
|
62
|
+
result += char;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
43
65
|
|
|
44
|
-
|
|
66
|
+
result += '\\' + char;
|
|
67
|
+
}
|
|
45
68
|
|
|
46
|
-
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
47
71
|
|
|
48
|
-
|
|
72
|
+
export function sanitizeCssIdentName(value: string, fallback: string = '') {
|
|
73
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, '-').replace(/^-+|-+$/g, '') || fallback;
|
|
49
74
|
}
|
package/atomic/utils/format.ts
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { globalData } from '../../utils/global';
|
|
2
|
+
import { hashString, normalizeHashLength } from '../../utils/hash';
|
|
3
|
+
|
|
4
|
+
type PooledHashState = {
|
|
5
|
+
byValue: Map<string, string>;
|
|
6
|
+
byHash: Map<string, string>;
|
|
7
|
+
usedByLength: number[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const POOLED_HASH_STATE = globalData<PooledHashState>(
|
|
11
|
+
'atomic.hashPool',
|
|
12
|
+
() => ({
|
|
13
|
+
byValue: new Map(),
|
|
14
|
+
byHash: new Map(),
|
|
15
|
+
usedByLength: [],
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export function getIdentifierSafeHash(value: string, startLength = 7) {
|
|
20
|
+
return getPooledHash(value, startLength);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getPooledHash(value: string, startLength: number) {
|
|
24
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
25
|
+
const valueKey = normalizedStartLength + '\0' + value;
|
|
26
|
+
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
27
|
+
if (existing) return existing;
|
|
28
|
+
|
|
29
|
+
let length = normalizedStartLength;
|
|
30
|
+
|
|
31
|
+
while (true) {
|
|
32
|
+
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
33
|
+
length++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
38
|
+
const hash = getPooledHashCandidate(value, length, index);
|
|
39
|
+
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
40
|
+
|
|
41
|
+
if (owner !== undefined && owner !== valueKey) continue;
|
|
42
|
+
|
|
43
|
+
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
44
|
+
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
45
|
+
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
46
|
+
return hash;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
length++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getPooledHashCandidate(
|
|
54
|
+
value: string,
|
|
55
|
+
length: number,
|
|
56
|
+
index: number,
|
|
57
|
+
) {
|
|
58
|
+
const hashValue = index === 0 ? value : value + '::' + index;
|
|
59
|
+
return getIdentifierSafeHashValue(hashString(hashValue)).slice(0, length);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getPooledHashUsedCount(length: number) {
|
|
63
|
+
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getIdentifierSafeHashPoolSize(length: number) {
|
|
67
|
+
if (length <= 0) return 0;
|
|
68
|
+
|
|
69
|
+
return 26 * 36 ** (length - 1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getIdentifierSafeHashValue(hash: string) {
|
|
73
|
+
const first = hash.charCodeAt(0);
|
|
74
|
+
|
|
75
|
+
if (first < 48 || first > 57) return hash;
|
|
76
|
+
|
|
77
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
78
|
+
}
|
package/atomic/var.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CSS_CONFIG } from '../config/config/css';
|
|
1
2
|
import type { VarNameFormat, VarNameInfo } from '../config/types';
|
|
2
|
-
import { getIdentifierSafeHash } from './utils/css';
|
|
3
3
|
import { createNameFormatter } from './utils/format';
|
|
4
|
+
import { getIdentifierSafeHash } from './utils/hash';
|
|
4
5
|
|
|
5
6
|
export const VAR_NAME_FORMAT = 'var[-(name)]-$hash';
|
|
6
7
|
|
|
@@ -12,7 +13,7 @@ export function getLocalVarName(
|
|
|
12
13
|
column: number,
|
|
13
14
|
format: VarNameFormat | null | undefined,
|
|
14
15
|
) {
|
|
15
|
-
const hash = getIdentifierSafeHash(filePath + '\n' + line + ':' + column);
|
|
16
|
+
const hash = getIdentifierSafeHash(filePath + '\n' + line + ':' + column, CSS_CONFIG.hashLength);
|
|
16
17
|
const name = formatVarName(format || VAR_NAME_FORMAT, hash, { name: '' });
|
|
17
18
|
|
|
18
19
|
return '--' + name;
|