@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
|
@@ -5,37 +5,31 @@ import { DEV_CONFIG } from '../../../config/config/dev';
|
|
|
5
5
|
import { getStyleTokenId, isStyleTokenOverrideData, type StyleTokenOverride } from '../../../style/token';
|
|
6
6
|
import { BUILDER_SLOT_ID, BUILDER_STATE, BUILDER_TYPE_SCOPE, BUILDER_TYPE_SLOT_OVERRIDE } from '../const';
|
|
7
7
|
import type { BuilderCallsite, ScopeData, SlotOverrideData } from '../data';
|
|
8
|
-
import {
|
|
9
|
-
getDebugFieldCallsite,
|
|
10
|
-
TRACE_STYLE,
|
|
11
|
-
TRACE_VALUE,
|
|
12
|
-
type DebugData,
|
|
13
|
-
type DebugLoc,
|
|
14
|
-
} from '../debug';
|
|
8
|
+
import { type DebugData, type DebugLoc, getDebugFieldCallsite, TRACE_STYLE, TRACE_VALUE } from '../debug';
|
|
15
9
|
import { isScopeData, isSlotOverrideData } from '../is';
|
|
16
10
|
import type { ItemSelector, ItemValue, RuntimeScopeItem, RuntimeSlotOverrideItem, StateItem } from '../state';
|
|
17
11
|
import { cloneData, logInvalidData } from './utils';
|
|
18
12
|
|
|
19
|
-
export type ScopeItem
|
|
20
|
-
| SlotOverrideData<
|
|
21
|
-
| ScopeData
|
|
13
|
+
export type ScopeItem =
|
|
14
|
+
| SlotOverrideData<any>
|
|
15
|
+
| ScopeData
|
|
22
16
|
| StyleTokenOverride
|
|
23
17
|
| false
|
|
24
18
|
| null
|
|
25
19
|
| undefined;
|
|
26
20
|
|
|
27
|
-
export type ScopeItems
|
|
28
|
-
| ScopeItem
|
|
29
|
-
| ScopeItem
|
|
21
|
+
export type ScopeItems =
|
|
22
|
+
| ScopeItem
|
|
23
|
+
| ScopeItem[];
|
|
30
24
|
|
|
31
|
-
export function mergeScopeData
|
|
32
|
-
scope: ScopeData
|
|
25
|
+
export function mergeScopeData(
|
|
26
|
+
scope: ScopeData,
|
|
33
27
|
callsite: BuilderCallsite | null,
|
|
34
|
-
items: ScopeItems
|
|
28
|
+
items: ScopeItems | null,
|
|
35
29
|
debug: DebugData | null,
|
|
36
30
|
parentSelector: ItemSelector | null,
|
|
37
31
|
scopeAtRule: ItemSelector | null,
|
|
38
|
-
): ScopeData
|
|
32
|
+
): ScopeData {
|
|
39
33
|
if (!items) return scope;
|
|
40
34
|
|
|
41
35
|
const sourceItems = Array.isArray(items) ? items : [items];
|
|
@@ -45,7 +39,7 @@ export function mergeScopeData<Style>(
|
|
|
45
39
|
debug,
|
|
46
40
|
);
|
|
47
41
|
|
|
48
|
-
let source: ScopeItem
|
|
42
|
+
let source: ScopeItem;
|
|
49
43
|
let item: StateItem;
|
|
50
44
|
let lookupIndex: number;
|
|
51
45
|
let priority: number | null;
|
|
@@ -125,6 +119,8 @@ export function mergeScopeData<Style>(
|
|
|
125
119
|
DEV_CONFIG.isLocalClassNameEnabled,
|
|
126
120
|
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
127
121
|
CSS_CONFIG.classNameFormat ?? null,
|
|
122
|
+
scopeItem.transformClassName ?? null,
|
|
123
|
+
CSS_CONFIG.transformClassNameFormat ?? null,
|
|
128
124
|
);
|
|
129
125
|
|
|
130
126
|
scopeItem.dedupe = dedupe;
|
|
@@ -176,6 +172,7 @@ export function mergeScopeData<Style>(
|
|
|
176
172
|
className: '',
|
|
177
173
|
property: overrideItem.property,
|
|
178
174
|
value: overrideItem.value,
|
|
175
|
+
transformClassName: overrideItem.transformClassName,
|
|
179
176
|
token: overrideItem.token,
|
|
180
177
|
selector: overrideItem.selector,
|
|
181
178
|
atRule,
|
|
@@ -212,6 +209,8 @@ export function mergeScopeData<Style>(
|
|
|
212
209
|
DEV_CONFIG.isLocalClassNameEnabled,
|
|
213
210
|
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
214
211
|
CSS_CONFIG.classNameFormat ?? null,
|
|
212
|
+
scopeItem.transformClassName ?? null,
|
|
213
|
+
CSS_CONFIG.transformClassNameFormat ?? null,
|
|
215
214
|
);
|
|
216
215
|
|
|
217
216
|
scopeItem.dedupe = dedupe;
|
|
@@ -228,7 +227,7 @@ export function mergeScopeData<Style>(
|
|
|
228
227
|
}
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
return data as ScopeData
|
|
230
|
+
return data as ScopeData;
|
|
232
231
|
}
|
|
233
232
|
|
|
234
233
|
function addTokenOverride(
|
|
@@ -6,6 +6,7 @@ import { CSS_CONFIG } from '../../../config/config/css';
|
|
|
6
6
|
import { DEBUG_CONFIG } from '../../../config/config/debug';
|
|
7
7
|
import { DEV_CONFIG } from '../../../config/config/dev';
|
|
8
8
|
import { isStyleTokenData, isStyleTokenOverrideData, type StyleTokenData } from '../../../style/token';
|
|
9
|
+
import { isClassNameValue } from '../../../style/transform';
|
|
9
10
|
import type { StyleObject, StyleValueTuple } from '../../../style/types';
|
|
10
11
|
import { type AtRuleRef, isAtRuleRef } from '../../../style/valueRef';
|
|
11
12
|
import {
|
|
@@ -72,6 +73,7 @@ export function mergeBuilderData<Data extends BuilderData>(
|
|
|
72
73
|
let token: StyleTokenData | null;
|
|
73
74
|
let ref: AtRuleRef | null;
|
|
74
75
|
let variableName: string | null;
|
|
76
|
+
let transformClassName: string | null;
|
|
75
77
|
let lookupIndex: number;
|
|
76
78
|
|
|
77
79
|
if (isStyleData(style)) {
|
|
@@ -122,6 +124,12 @@ export function mergeBuilderData<Data extends BuilderData>(
|
|
|
122
124
|
valueRaw = (valueRaw as StyleValueTuple)[1];
|
|
123
125
|
}
|
|
124
126
|
|
|
127
|
+
transformClassName = null;
|
|
128
|
+
if (isClassNameValue(valueRaw)) {
|
|
129
|
+
transformClassName = valueRaw.className;
|
|
130
|
+
valueRaw = valueRaw.value;
|
|
131
|
+
}
|
|
132
|
+
|
|
125
133
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
126
134
|
if (ref) valueRaw = ref.value;
|
|
127
135
|
|
|
@@ -145,6 +153,7 @@ export function mergeBuilderData<Data extends BuilderData>(
|
|
|
145
153
|
className: '',
|
|
146
154
|
property,
|
|
147
155
|
value,
|
|
156
|
+
transformClassName,
|
|
148
157
|
variable: ref
|
|
149
158
|
? [ITEM_VALUE_TYPE_AT_RULE_REF, ref]
|
|
150
159
|
: variableName && token
|
|
@@ -225,6 +234,8 @@ export function mergeBuilderData<Data extends BuilderData>(
|
|
|
225
234
|
DEV_CONFIG.isLocalClassNameEnabled,
|
|
226
235
|
DEBUG_CONFIG.isDebugClassNameEnabled,
|
|
227
236
|
CSS_CONFIG.classNameFormat ?? null,
|
|
237
|
+
runtimeItem.transformClassName ?? null,
|
|
238
|
+
CSS_CONFIG.transformClassNameFormat ?? null,
|
|
228
239
|
);
|
|
229
240
|
|
|
230
241
|
runtimeItem.dedupe = dedupe;
|
package/builder/data/state.ts
CHANGED
package/builder/style_builder.ts
CHANGED
|
@@ -131,16 +131,16 @@ export function createSlotBuilder<Style, Selectors extends SelectorsRecord>(
|
|
|
131
131
|
return fn as unknown as SlotFn<Style>;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
export function createScopeBuilder<
|
|
134
|
+
export function createScopeBuilder<Selectors extends SelectorsRecord>(
|
|
135
135
|
selectors: Selectors,
|
|
136
136
|
) {
|
|
137
|
-
type ScopeFn
|
|
138
|
-
& ScopeSelfFn<
|
|
139
|
-
& ScopeBuilder<
|
|
137
|
+
type ScopeFn =
|
|
138
|
+
& ScopeSelfFn<Selectors>
|
|
139
|
+
& ScopeBuilder<Selectors>;
|
|
140
140
|
|
|
141
|
-
const fns = createScopeFns
|
|
141
|
+
const fns = createScopeFns(selectors, FnPrefixScope, cloneScope);
|
|
142
142
|
|
|
143
|
-
const fn = (items?: ScopeItems
|
|
143
|
+
const fn = (items?: ScopeItems, debug?: DebugData) => {
|
|
144
144
|
if (isDebugData(items) && debug === undefined) {
|
|
145
145
|
debug = items;
|
|
146
146
|
items = undefined;
|
|
@@ -148,7 +148,7 @@ export function createScopeBuilder<Style, Selectors extends SelectorsRecord>(
|
|
|
148
148
|
|
|
149
149
|
const callsite = resolveCallsite(debug);
|
|
150
150
|
|
|
151
|
-
const scope = createCallableScope(createScopeData
|
|
151
|
+
const scope = createCallableScope(createScopeData(callsite), fns);
|
|
152
152
|
|
|
153
153
|
if (!items) return scope;
|
|
154
154
|
|
|
@@ -166,7 +166,7 @@ export function createScopeBuilder<Style, Selectors extends SelectorsRecord>(
|
|
|
166
166
|
|
|
167
167
|
traceMarker(fn, 'scope');
|
|
168
168
|
|
|
169
|
-
return fn as unknown as ScopeFn
|
|
169
|
+
return fn as unknown as ScopeFn;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
function createCallableSlot<Style>(
|
|
@@ -203,13 +203,13 @@ function createCallableSlot<Style>(
|
|
|
203
203
|
return callable;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
function createCallableScope
|
|
207
|
-
data: ReturnType<typeof createScopeData
|
|
206
|
+
function createCallableScope(
|
|
207
|
+
data: ReturnType<typeof createScopeData>,
|
|
208
208
|
fns: Record<string, Function>,
|
|
209
|
-
): ScopeData
|
|
210
|
-
const scope = ((slot: SlotData<
|
|
211
|
-
return createScopeTargetData(scope as ScopeData
|
|
212
|
-
}) as ScopeData
|
|
209
|
+
): ScopeData {
|
|
210
|
+
const scope = ((slot: SlotData<any>) => {
|
|
211
|
+
return createScopeTargetData(scope as ScopeData, slot);
|
|
212
|
+
}) as ScopeData;
|
|
213
213
|
|
|
214
214
|
traceMarker(scope, 'scope.target');
|
|
215
215
|
Object.setPrototypeOf(scope, fns);
|
|
@@ -218,12 +218,12 @@ function createCallableScope<Style>(
|
|
|
218
218
|
return scope;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function cloneScope
|
|
222
|
-
source: ScopeData
|
|
221
|
+
function cloneScope(
|
|
222
|
+
source: ScopeData,
|
|
223
223
|
callsite: BuilderCallsite | null,
|
|
224
224
|
) {
|
|
225
225
|
const scope = createCallableScope(
|
|
226
|
-
createScopeData
|
|
226
|
+
createScopeData(callsite ?? source[BUILDER_CALLSITE]),
|
|
227
227
|
Object.getPrototypeOf(source),
|
|
228
228
|
);
|
|
229
229
|
|
package/builder/style_fns.ts
CHANGED
|
@@ -27,10 +27,10 @@ import { resolveCallsite, transformStyle } from './utils';
|
|
|
27
27
|
|
|
28
28
|
type Fns = Record<string, Function>;
|
|
29
29
|
type CreateFnResult<Data extends BuilderData> = (data: Data, fns: Fns) => Data;
|
|
30
|
-
type CloneScope
|
|
31
|
-
source: ScopeData
|
|
30
|
+
type CloneScope = (
|
|
31
|
+
source: ScopeData,
|
|
32
32
|
callsite: BuilderCallsite | null,
|
|
33
|
-
) => ScopeData
|
|
33
|
+
) => ScopeData;
|
|
34
34
|
type CreateFn = (fns: Fns, fnName: string, selector: Selector) => Function | undefined;
|
|
35
35
|
|
|
36
36
|
export const createDefaultFnResult = <Data extends BuilderData>(data: Data, fns: Fns) => {
|
|
@@ -53,10 +53,10 @@ export function createStyleFns<Data extends BuilderData>(
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function createScopeFns
|
|
56
|
+
export function createScopeFns(
|
|
57
57
|
selectors: SelectorsRecord,
|
|
58
58
|
fnPrefix: string,
|
|
59
|
-
cloneScope: CloneScope
|
|
59
|
+
cloneScope: CloneScope,
|
|
60
60
|
) {
|
|
61
61
|
return createFns(
|
|
62
62
|
selectors,
|
|
@@ -65,7 +65,7 @@ export function createScopeFns<Style>(
|
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function createFns(
|
|
68
|
+
export function createFns(
|
|
69
69
|
selectors: SelectorsRecord,
|
|
70
70
|
fnPrefix: string,
|
|
71
71
|
createFn: CreateFn,
|
|
@@ -356,11 +356,11 @@ function createSimpleFn<Data extends BuilderData>(
|
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
function createScopeFn
|
|
359
|
+
function createScopeFn(
|
|
360
360
|
fnPrefix: string,
|
|
361
361
|
fnName: string,
|
|
362
362
|
fnSelector: Selector,
|
|
363
|
-
cloneScope: CloneScope
|
|
363
|
+
cloneScope: CloneScope,
|
|
364
364
|
) {
|
|
365
365
|
const selector = fnSelector.selector.trim();
|
|
366
366
|
|
|
@@ -385,12 +385,12 @@ function createScopeFn<Style>(
|
|
|
385
385
|
return createScopeSimpleFn(fnSelector, cloneScope);
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
function createScopeMergeFn
|
|
389
|
-
cloneScope: CloneScope
|
|
388
|
+
function createScopeMergeFn(
|
|
389
|
+
cloneScope: CloneScope,
|
|
390
390
|
) {
|
|
391
391
|
return function(
|
|
392
|
-
this: ScopeData
|
|
393
|
-
data: ScopeItems
|
|
392
|
+
this: ScopeData,
|
|
393
|
+
data: ScopeItems,
|
|
394
394
|
debug?: DebugData,
|
|
395
395
|
) {
|
|
396
396
|
const callsite = resolveCallsite(debug);
|
|
@@ -407,11 +407,11 @@ function createScopeMergeFn<Style>(
|
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
function createScopeAtRuleFn
|
|
410
|
+
function createScopeAtRuleFn(
|
|
411
411
|
fnPrefix: string,
|
|
412
412
|
fnName: string,
|
|
413
413
|
fnSelector: Selector,
|
|
414
|
-
cloneScope: CloneScope
|
|
414
|
+
cloneScope: CloneScope,
|
|
415
415
|
) {
|
|
416
416
|
const isMedia = fnSelector.selector.startsWith(SELECTOR_MEDIA) ||
|
|
417
417
|
fnSelector.selector.startsWith(SELECTOR_CONTAINER);
|
|
@@ -421,16 +421,16 @@ function createScopeAtRuleFn<Style>(
|
|
|
421
421
|
|
|
422
422
|
type Params = [
|
|
423
423
|
arg: string | string[],
|
|
424
|
-
data: ScopeItems
|
|
424
|
+
data: ScopeItems,
|
|
425
425
|
debug?: DebugData,
|
|
426
426
|
];
|
|
427
427
|
|
|
428
428
|
type PriorityParams = [priority: number, ...Params];
|
|
429
|
-
type SelfParams = [data: ScopeItems
|
|
429
|
+
type SelfParams = [data: ScopeItems, debug?: DebugData];
|
|
430
430
|
type PrioritySelfParams = [priority: number, ...SelfParams];
|
|
431
431
|
|
|
432
432
|
return function(
|
|
433
|
-
this: ScopeData
|
|
433
|
+
this: ScopeData,
|
|
434
434
|
...params: Params | PriorityParams | SelfParams | PrioritySelfParams
|
|
435
435
|
) {
|
|
436
436
|
let arg: Params[0];
|
|
@@ -492,19 +492,19 @@ function createScopeAtRuleFn<Style>(
|
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
function createScopeArgsFn
|
|
495
|
+
function createScopeArgsFn(
|
|
496
496
|
fnPrefix: string,
|
|
497
497
|
fnName: string,
|
|
498
498
|
fnSelector: Selector,
|
|
499
|
-
cloneScope: CloneScope
|
|
499
|
+
cloneScope: CloneScope,
|
|
500
500
|
) {
|
|
501
501
|
const [before, after] = fnSelector.selector.split(SELECTOR_ARGS);
|
|
502
502
|
const priority = fnSelector.priority;
|
|
503
503
|
|
|
504
504
|
return function(
|
|
505
|
-
this: ScopeData
|
|
505
|
+
this: ScopeData,
|
|
506
506
|
arg: string | string[],
|
|
507
|
-
data: ScopeItems
|
|
507
|
+
data: ScopeItems,
|
|
508
508
|
debug?: DebugData,
|
|
509
509
|
) {
|
|
510
510
|
const args = Array.isArray(arg) ? arg : [arg];
|
|
@@ -537,19 +537,19 @@ function createScopeArgsFn<Style>(
|
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
-
function createScopeArgFn
|
|
540
|
+
function createScopeArgFn(
|
|
541
541
|
fnPrefix: string,
|
|
542
542
|
fnName: string,
|
|
543
543
|
fnSelector: Selector,
|
|
544
|
-
cloneScope: CloneScope
|
|
544
|
+
cloneScope: CloneScope,
|
|
545
545
|
) {
|
|
546
546
|
const [before, after] = fnSelector.selector.split(SELECTOR_ARG);
|
|
547
547
|
const priority = fnSelector.priority;
|
|
548
548
|
|
|
549
549
|
return function(
|
|
550
|
-
this: ScopeData
|
|
550
|
+
this: ScopeData,
|
|
551
551
|
arg: string,
|
|
552
|
-
data: ScopeItems
|
|
552
|
+
data: ScopeItems,
|
|
553
553
|
debug?: DebugData,
|
|
554
554
|
) {
|
|
555
555
|
const callsite = resolveCallsite(debug);
|
|
@@ -572,16 +572,16 @@ function createScopeArgFn<Style>(
|
|
|
572
572
|
};
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
function createScopeSimpleFn
|
|
575
|
+
function createScopeSimpleFn(
|
|
576
576
|
fnSelector: Selector,
|
|
577
|
-
cloneScope: CloneScope
|
|
577
|
+
cloneScope: CloneScope,
|
|
578
578
|
) {
|
|
579
579
|
const selector = fnSelector.selector;
|
|
580
580
|
const priority = fnSelector.priority;
|
|
581
581
|
|
|
582
582
|
return function(
|
|
583
|
-
this: ScopeData
|
|
584
|
-
data: ScopeItems
|
|
583
|
+
this: ScopeData,
|
|
584
|
+
data: ScopeItems,
|
|
585
585
|
debug?: DebugData,
|
|
586
586
|
) {
|
|
587
587
|
const callsite = resolveCallsite(debug);
|
|
@@ -598,14 +598,14 @@ function createScopeSimpleFn<Style>(
|
|
|
598
598
|
};
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
-
function mergeScopeItems
|
|
602
|
-
scope: ScopeData
|
|
601
|
+
function mergeScopeItems(
|
|
602
|
+
scope: ScopeData,
|
|
603
603
|
callsite: BuilderCallsite | null,
|
|
604
|
-
data: ScopeItems
|
|
604
|
+
data: ScopeItems,
|
|
605
605
|
debug: DebugData | null,
|
|
606
606
|
selector: ItemSelector | null,
|
|
607
607
|
atRule: ItemSelector | null,
|
|
608
|
-
cloneScope: CloneScope
|
|
608
|
+
cloneScope: CloneScope,
|
|
609
609
|
) {
|
|
610
610
|
return mergeScopeData(cloneScope(scope, callsite), callsite, data, debug, selector, atRule);
|
|
611
611
|
}
|
package/builder/types/alias.ts
CHANGED
|
@@ -22,9 +22,9 @@ export function slotOverrideRule<Style, Selectors>() {
|
|
|
22
22
|
return {} as SlotOverrideRule<Style>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function scopeRule<
|
|
26
|
-
type ScopeRule
|
|
27
|
-
return {} as ScopeRule
|
|
25
|
+
export function scopeRule<Selectors>() {
|
|
26
|
+
type ScopeRule = ScopeBuilder<Selectors> & Collapse;
|
|
27
|
+
return {} as ScopeRule;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export function typeAliases<Style, Selectors>() {
|
|
@@ -33,12 +33,12 @@ export function typeAliases<Style, Selectors>() {
|
|
|
33
33
|
type StyleRule<Style> = ReturnType<typeof styleRule<Style, Selectors>>;
|
|
34
34
|
type SlotRule<Style> = ReturnType<typeof slotRule<Style, Selectors>>;
|
|
35
35
|
type SlotOverrideRule<Style> = ReturnType<typeof slotOverrideRule<Style, Selectors>>;
|
|
36
|
-
type ScopeRule
|
|
36
|
+
type ScopeRule = ReturnType<typeof scopeRule<Selectors>>;
|
|
37
37
|
|
|
38
38
|
type StyleFn<Style> = StyleSelfFn<Style, Selectors> & {
|
|
39
39
|
(style?: StyleObject<Style>): ReturnType<typeof styleRule<Style, Selectors>>;
|
|
40
40
|
slot: SlotFn<Style>;
|
|
41
|
-
scope: ScopeFn
|
|
41
|
+
scope: ScopeFn;
|
|
42
42
|
value: ValueFn;
|
|
43
43
|
raw: RawFn<Style>;
|
|
44
44
|
plain: PlainFn<Style>;
|
|
@@ -58,19 +58,19 @@ export function typeAliases<Style, Selectors>() {
|
|
|
58
58
|
|
|
59
59
|
type SlotFn<Style> = SlotSelfFn<Style, Selectors>;
|
|
60
60
|
|
|
61
|
-
type ScopeFn
|
|
62
|
-
& ScopeSelfFn<
|
|
63
|
-
& ScopeBuilder<
|
|
61
|
+
type ScopeFn =
|
|
62
|
+
& ScopeSelfFn<Selectors>
|
|
63
|
+
& ScopeBuilder<Selector>;
|
|
64
64
|
|
|
65
65
|
type Types<Style> = {
|
|
66
66
|
StyleRule: StyleRule<Style>;
|
|
67
67
|
SlotRule: SlotRule<Style>;
|
|
68
68
|
SlotOverrideRule: SlotOverrideRule<Style>;
|
|
69
|
-
ScopeRule: ScopeRule
|
|
69
|
+
ScopeRule: ScopeRule;
|
|
70
70
|
//
|
|
71
71
|
StyleFn: StyleFn<Style>;
|
|
72
72
|
SlotFn: SlotFn<Style>;
|
|
73
|
-
ScopeFn: ScopeFn
|
|
73
|
+
ScopeFn: ScopeFn;
|
|
74
74
|
//
|
|
75
75
|
ValueFn: ValueFn;
|
|
76
76
|
RawFn: RawFn<Style>;
|
package/builder/types/fns.ts
CHANGED
|
@@ -44,8 +44,8 @@ type StyleAtRuleArgsFn<Style, Self, Arg extends string> = StyleAtRuleFn<Style, S
|
|
|
44
44
|
type StyleMediaArgFn<Style, Self, Arg extends string> = StyleMediaFn<Style, Self, Arg>;
|
|
45
45
|
type StyleMediaArgsFn<Style, Self, Arg extends string> = StyleMediaFn<Style, Self, Arg | Arg[]>;
|
|
46
46
|
|
|
47
|
-
type SelectorString<S> = S extends Selector<infer T, any> ? T : S;
|
|
48
|
-
type SelectorArg<S> = S extends Selector<any, infer Arg> ? Arg : string;
|
|
47
|
+
export type SelectorString<S> = S extends Selector<infer T, any> ? T : S;
|
|
48
|
+
export type SelectorArg<S> = S extends Selector<any, infer Arg> ? Arg : string;
|
|
49
49
|
|
|
50
50
|
type GetArgFn<
|
|
51
51
|
Selector,
|
|
@@ -54,7 +54,7 @@ type GetArgFn<
|
|
|
54
54
|
: Selector extends `${string}$${string}` ? Fns['Arg']
|
|
55
55
|
: Fns['Default'];
|
|
56
56
|
|
|
57
|
-
type
|
|
57
|
+
export type GetSelectorFn<
|
|
58
58
|
Selector,
|
|
59
59
|
Fns extends Record<
|
|
60
60
|
'MediaNoArg' | 'MediaArg' | 'MediaArgs' | 'AtRuleNoArg' | 'AtRuleArg' | 'AtRuleArgs' | 'Args' | 'Arg' | 'Default',
|
|
@@ -78,7 +78,7 @@ type GetFn<
|
|
|
78
78
|
}>;
|
|
79
79
|
|
|
80
80
|
type GetStyleFn<Selector, Style, Self> = SelectorString<Selector> extends '...' ? StyleMergeFn<Style, Self>
|
|
81
|
-
:
|
|
81
|
+
: GetSelectorFn<SelectorString<Selector>, {
|
|
82
82
|
MediaNoArg: StyleMediaNoArgFn<Style, Self>;
|
|
83
83
|
MediaArgs: StyleMediaArgsFn<Style, Self, SelectorArg<Selector>>;
|
|
84
84
|
MediaArg: StyleMediaArgFn<Style, Self, SelectorArg<Selector>>;
|
|
@@ -126,7 +126,7 @@ type ScopeAtRuleArgsFn<Style, Result, Arg extends string> = ScopeAtRuleFn<Style,
|
|
|
126
126
|
type ScopeMediaArgFn<Style, Result, Arg extends string> = ScopeMediaFn<Style, Result, Arg>;
|
|
127
127
|
type ScopeMediaArgsFn<Style, Result, Arg extends string> = ScopeMediaFn<Style, Result, Arg | Arg[]>;
|
|
128
128
|
|
|
129
|
-
type GetScopeFn<Selector, Style, Result> =
|
|
129
|
+
type GetScopeFn<Selector, Style, Result> = GetSelectorFn<SelectorString<Selector>, {
|
|
130
130
|
MediaNoArg: ScopeMediaNoArgFn<Style, Result>;
|
|
131
131
|
MediaArgs: ScopeMediaArgsFn<Style, Result, SelectorArg<Selector>>;
|
|
132
132
|
MediaArg: ScopeMediaArgFn<Style, Result, SelectorArg<Selector>>;
|
|
@@ -148,9 +148,9 @@ export type SlotSelfFn<Style, Selectors> = (
|
|
|
148
148
|
style?: StyleObject<Style>,
|
|
149
149
|
) => ReturnType<typeof slotRule<Style, Selectors>>;
|
|
150
150
|
|
|
151
|
-
export type ScopeSelfFn<
|
|
152
|
-
styles?: ScopeItems
|
|
153
|
-
) => ReturnType<typeof scopeRule<
|
|
151
|
+
export type ScopeSelfFn<Selectors> = (
|
|
152
|
+
styles?: ScopeItems,
|
|
153
|
+
) => ReturnType<typeof scopeRule<Selectors>>;
|
|
154
154
|
|
|
155
155
|
export type StyleSelectorFns<Style, Selectors> = {
|
|
156
156
|
[P in keyof Selectors]: GetStyleFn<
|
|
@@ -176,10 +176,10 @@ export type SlotOverrideSelectorFns<Style, Selectors> = {
|
|
|
176
176
|
>;
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
-
export type ScopeSelectorFns<
|
|
179
|
+
export type ScopeSelectorFns<Selectors> = {
|
|
180
180
|
[P in keyof Selectors]: GetScopeFn<
|
|
181
181
|
Selectors[P],
|
|
182
|
-
ScopeItems
|
|
183
|
-
ReturnType<typeof scopeRule<
|
|
182
|
+
ScopeItems,
|
|
183
|
+
ReturnType<typeof scopeRule<Selectors>>
|
|
184
184
|
>;
|
|
185
185
|
};
|
package/builder/types/types.ts
CHANGED
|
@@ -28,8 +28,8 @@ export type SlotOverrideBuilderFns<Style, Selectors> =
|
|
|
28
28
|
& SlotOverrideSelectorFns<Style, Selectors>
|
|
29
29
|
& {};
|
|
30
30
|
|
|
31
|
-
export type ScopeFns<
|
|
32
|
-
& ScopeSelectorFns<
|
|
31
|
+
export type ScopeFns<Selectors> =
|
|
32
|
+
& ScopeSelectorFns<Selectors>
|
|
33
33
|
& {};
|
|
34
34
|
|
|
35
35
|
export type StyleBuilder<Style, Selectors> =
|
|
@@ -45,7 +45,7 @@ export type SlotOverrideBuilder<Style, Selectors> =
|
|
|
45
45
|
& SlotOverrideData<Style>
|
|
46
46
|
& SlotOverrideBuilderFns<Style, Selectors>;
|
|
47
47
|
|
|
48
|
-
export type ScopeBuilder<
|
|
49
|
-
& ScopeData
|
|
50
|
-
& ScopeFns<
|
|
48
|
+
export type ScopeBuilder<Selectors> =
|
|
49
|
+
& ScopeData
|
|
50
|
+
& ScopeFns<Selectors>
|
|
51
51
|
& {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SELECTOR_MERGE } from '../../../builder/data/selector';
|
|
2
1
|
import { BUILDER_STATE } from '../../../builder/data/const';
|
|
3
|
-
import { TRACE_STYLE, TRACE_VALUE
|
|
2
|
+
import { type DebugLoc, TRACE_STYLE, TRACE_VALUE } from '../../../builder/data/debug';
|
|
4
3
|
import { isScopeData, isStyleData } from '../../../builder/data/is';
|
|
4
|
+
import { SELECTOR_MERGE } from '../../../builder/data/selector';
|
|
5
5
|
import type { RuntimeItem } from '../../../builder/data/state';
|
|
6
6
|
import type { CheckSelectorMode, SourcemapLocationMode } from '../../../config/types';
|
|
7
7
|
import type { StyleFnMeta } from '../../../style/style';
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
DEBUG_SOURCE_CONTENT_VAR,
|
|
12
12
|
DEBUG_SOURCE_URL_VAR,
|
|
13
13
|
DEFAULT_CONFIG,
|
|
14
|
+
FN_CREATE_THEME,
|
|
14
15
|
FN_STYLE_KEYFRAMES,
|
|
15
16
|
FN_STYLE_MERGE,
|
|
16
17
|
FN_STYLE_PLAIN,
|
|
17
18
|
FN_STYLE_RAW,
|
|
18
19
|
FN_STYLE_SCOPE,
|
|
19
|
-
FN_CREATE_THEME,
|
|
20
20
|
IMPORT_PATHS,
|
|
21
21
|
} from '../../utils/constants';
|
|
22
22
|
import { createImportSourceMatcher, type ImportSourceMatcher } from '../../utils/import_source';
|
|
@@ -181,6 +181,10 @@ export function createDebugPlugin(args: PluginArgs) {
|
|
|
181
181
|
const sourceContentRef = sourceContent
|
|
182
182
|
? getSourceContentId(t, state)
|
|
183
183
|
: null;
|
|
184
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
185
|
+
const isClassNameCall = rootName
|
|
186
|
+
? state.styleMetas.get(rootName)?.mode === 'ClassName'
|
|
187
|
+
: false;
|
|
184
188
|
|
|
185
189
|
path.node.arguments.push(
|
|
186
190
|
buildDebugDataObject(
|
|
@@ -192,6 +196,7 @@ export function createDebugPlugin(args: PluginArgs) {
|
|
|
192
196
|
options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat,
|
|
193
197
|
getDebugStyleArg(t, path, state, options.dev?.sourcemapMode ?? 'style'),
|
|
194
198
|
getDebugCallLoc(path, state),
|
|
199
|
+
isClassNameCall,
|
|
195
200
|
),
|
|
196
201
|
);
|
|
197
202
|
},
|
|
@@ -23,6 +23,7 @@ export function buildDebugDataObject(
|
|
|
23
23
|
tokenNameFormat: TokenNameFormat = DEFAULT_CONFIG.tokenNameFormat!,
|
|
24
24
|
styleArg: CallArg = node.arguments[0],
|
|
25
25
|
locOverride?: BabelTypes.SourceLocation['start'] | null,
|
|
26
|
+
classNameArg: boolean = false,
|
|
26
27
|
) {
|
|
27
28
|
const loc = locOverride ?? node.loc?.start;
|
|
28
29
|
const line = loc?.line ?? 1;
|
|
@@ -57,6 +58,13 @@ export function buildDebugDataObject(
|
|
|
57
58
|
),
|
|
58
59
|
];
|
|
59
60
|
|
|
61
|
+
if (classNameArg) {
|
|
62
|
+
properties.push(t.objectProperty(
|
|
63
|
+
t.identifier('classNames'),
|
|
64
|
+
buildClassNames(t, node.arguments),
|
|
65
|
+
));
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
properties.push(t.objectProperty(
|
|
61
69
|
t.identifier('sourceUrl'),
|
|
62
70
|
sourceUrlRef,
|
|
@@ -72,6 +80,71 @@ export function buildDebugDataObject(
|
|
|
72
80
|
return t.objectExpression(properties);
|
|
73
81
|
}
|
|
74
82
|
|
|
83
|
+
function buildClassNames(
|
|
84
|
+
t: typeof BabelTypes,
|
|
85
|
+
args: CallArgs,
|
|
86
|
+
) {
|
|
87
|
+
const classNames = new Map<string, BabelTypes.SourceLocation['start']>();
|
|
88
|
+
|
|
89
|
+
for (const arg of args) collectClassNameLoc(arg, classNames);
|
|
90
|
+
|
|
91
|
+
const fields: BabelTypes.ObjectProperty[] = [];
|
|
92
|
+
|
|
93
|
+
for (const [className, loc] of classNames) {
|
|
94
|
+
fields.push(t.objectProperty(
|
|
95
|
+
t.stringLiteral(className),
|
|
96
|
+
buildLoc(t, loc.line, loc.column + 1),
|
|
97
|
+
));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return t.objectExpression(fields);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function collectClassNameLoc(
|
|
104
|
+
arg: BabelTypes.Node | null | undefined,
|
|
105
|
+
classNames: Map<string, BabelTypes.SourceLocation['start']>,
|
|
106
|
+
) {
|
|
107
|
+
if (!arg) return;
|
|
108
|
+
|
|
109
|
+
if (arg.type === 'StringLiteral') {
|
|
110
|
+
const loc = arg.loc?.start;
|
|
111
|
+
if (loc) classNames.set(arg.value, loc);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (arg.type === 'TemplateLiteral' && arg.expressions.length === 0) {
|
|
116
|
+
const loc = arg.loc?.start;
|
|
117
|
+
if (loc) classNames.set(arg.quasis[0]?.value.cooked ?? arg.quasis[0]?.value.raw ?? '', loc);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (arg.type === 'ArrayExpression') {
|
|
122
|
+
for (const item of arg.elements) collectClassNameLoc(item, classNames);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (arg.type === 'ConditionalExpression') {
|
|
127
|
+
collectClassNameLoc(arg.consequent, classNames);
|
|
128
|
+
collectClassNameLoc(arg.alternate, classNames);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (arg.type === 'LogicalExpression') {
|
|
133
|
+
collectClassNameLoc(arg.left, classNames);
|
|
134
|
+
collectClassNameLoc(arg.right, classNames);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (
|
|
139
|
+
arg.type === 'CallExpression' &&
|
|
140
|
+
arg.callee.type === 'MemberExpression' &&
|
|
141
|
+
arg.callee.property.type === 'Identifier' &&
|
|
142
|
+
arg.callee.property.name === 'weight'
|
|
143
|
+
) {
|
|
144
|
+
collectClassNameLoc(arg.arguments[0], classNames);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
75
148
|
function getShortLabel(label: string) {
|
|
76
149
|
const parts = label.split('.');
|
|
77
150
|
return parts[parts.length - 1] || label;
|