@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.3
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 +31 -2
- package/README.md +80 -23
- 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/compiler/types.ts +0 -1
- package/compiler/transform/debug/plugin.ts +8 -3
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +33 -2
- package/compiler/transform/evaluator/tracer.ts +13 -9
- package/compiler/transform/extract/chain/chain.ts +596 -28
- package/compiler/transform/extract/plugin.ts +5 -2
- package/compiler/transform/extract/utils/state.ts +1 -0
- package/compiler/utils/constants.ts +4 -4
- package/compiler/utils/file_resolver.ts +1 -0
- package/compiler/utils/import_source.ts +3 -2
- package/config/build.ts +12 -2
- package/config/config/css.ts +3 -0
- package/config/config/debug.ts +13 -1
- package/config/config/dev.ts +17 -1
- package/config/configure.ts +10 -2
- package/config/types.ts +7 -0
- package/dev/config.ts +2 -3
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +136 -0
- package/dist/{className-C1Ht5Wvv.js → className-CKo4TxuT.js} +2 -2
- package/dist/{className-C1Ht5Wvv.js.map → className-CKo4TxuT.js.map} +1 -1
- package/dist/{className-DC2Cq8p3.js → className-ZJ5pBA-o.js} +19 -7
- package/dist/className-ZJ5pBA-o.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-DENc3a2R.mjs → compiler-D5v5tJXI.mjs} +607 -114
- package/dist/compiler-D5v5tJXI.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/{config-BryWDfQX.js → config-BEvP7108.js} +12 -4
- package/dist/config-BEvP7108.js.map +1 -0
- package/dist/config-B_cbG3S6.js +1 -0
- package/dist/config-FIfi5aJ8.js +32 -0
- package/dist/config-FIfi5aJ8.js.map +1 -0
- package/dist/config-OXHoDUIo.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-OXHoDUIo.js.map} +1 -1
- package/dist/css-CELBp6Gu.js +58 -0
- package/dist/css-CELBp6Gu.js.map +1 -0
- package/dist/{css-BowBszUt.js → css-DcuJ_jSH.js} +17 -17
- package/dist/css-DcuJ_jSH.js.map +1 -0
- package/dist/{css-ByOrugEX.js → css-dPoZJDQH.js} +80 -78
- package/dist/css-dPoZJDQH.js.map +1 -0
- package/dist/{css-DcazYor9.js → css-oOt6ZR54.js} +10 -8
- package/dist/css-oOt6ZR54.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{css_extra-DlOnsnR1.js → css_extra-DQdCrYoC.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-DQdCrYoC.js.map} +1 -1
- package/dist/{css_extra-oIi3UEPK.js → css_extra-DeTuIlcO.js} +2 -2
- package/dist/{css_extra-oIi3UEPK.js.map → css_extra-DeTuIlcO.js.map} +1 -1
- package/dist/{data-BsqOa5br.js → data-CeYstKMP.js} +21 -12
- package/dist/data-CeYstKMP.js.map +1 -0
- package/dist/{debug-n2aZQBSa.js → debug-D96KGgpH.js} +3 -3
- package/dist/debug-D96KGgpH.js.map +1 -0
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-CcphAa3R.js → dev-fOtWB5K3.js} +7 -8
- package/dist/{dev-CcphAa3R.js.map → dev-fOtWB5K3.js.map} +1 -1
- package/dist/{dev-DfBbuLeE.js → dev-p8tW7X-A.js} +14 -4
- package/dist/dev-p8tW7X-A.js.map +1 -0
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-CvqqIb7J.js} +10 -8
- package/dist/{elementMarker-Bu7gDAkE.js.map → elementMarker-CvqqIb7J.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 +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 +341 -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-DeOytHKW.js +2 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-oiQ8CnkS.js} +3 -3
- package/dist/getClassName-oiQ8CnkS.js.map +1 -0
- package/dist/global-Cul1dX8k.js +14 -0
- package/dist/{global-CvfmFLsK.js.map → global-Cul1dX8k.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-D2BksHSv.js → jsx-A4cK517J.js} +7 -7
- package/dist/{jsx-D2BksHSv.js.map → jsx-A4cK517J.js.map} +1 -1
- package/dist/{jsx-CwTeyUxr.js → jsx-Ba-XV33u.js} +3 -3
- package/dist/{jsx-CwTeyUxr.js.map → jsx-Ba-XV33u.js.map} +1 -1
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-BQcRzl5D.js} +2 -2
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-BQcRzl5D.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-B9KEoAQN.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-B9KEoAQN.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-BXcbW8Yp.js} +2 -2
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-BXcbW8Yp.js.map} +1 -1
- package/dist/{layer-D1SaH07m.js → layer-CbQzwZF-.js} +4 -4
- package/dist/{layer-D1SaH07m.js.map → layer-CbQzwZF-.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-BAth2yZ1.mjs} +3 -3
- package/dist/{loader-B5Kw0DD-.mjs.map → loader-BAth2yZ1.mjs.map} +1 -1
- package/dist/{misc-DCdYYyhK.mjs → misc-DFBKJGLT.mjs} +7 -3
- package/dist/{misc-DCdYYyhK.mjs.map → misc-DFBKJGLT.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-CF6JgpTq.js} +2 -2
- package/dist/{property-CnLFt5kx.js.map → property-CF6JgpTq.js.map} +1 -1
- package/dist/{registry-yHLRxyoo.mjs → registry-CiwvMfx8.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-CiwvMfx8.mjs.map} +1 -1
- package/dist/{rules-9HSO1pxL.js → rules-DlXcch7-.js} +13 -10
- package/dist/rules-DlXcch7-.js.map +1 -0
- package/dist/runtime-BKChZZ2-.js +52 -0
- package/dist/runtime-BKChZZ2-.js.map +1 -0
- package/dist/server.js +13 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CxbHR89f.mjs → shared-x59dI2NW.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-x59dI2NW.mjs.map} +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-yDD0nfm1.cjs} +603 -110
- package/dist/shared-yDD0nfm1.cjs.map +1 -0
- package/dist/sheet-B-uJfHRY.js +7 -0
- package/dist/sheet-B-uJfHRY.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-CJ6i4wmn.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-CJ6i4wmn.mjs.map} +1 -1
- package/dist/{style-B1UUqjj5.js → style-91J0B5ef.js} +35 -7
- package/dist/style-91J0B5ef.js.map +1 -0
- package/dist/{style-v2bf70TZ.js → style-Bw5ka-Nq.js} +440 -135
- package/dist/style-Bw5ka-Nq.js.map +1 -0
- package/dist/{style-DgHbdbdF.js → style-DFFK06Of.js} +258 -82
- package/dist/style-DFFK06Of.js.map +1 -0
- package/dist/style-pz8e5To1.js +5 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-DJ0Msgkh.js} +6 -5
- package/dist/{styleStore-DyNXBcUK.js.map → styleStore-DJ0Msgkh.js.map} +1 -1
- package/dist/{styleStore-Dea_WVbr.js → styleStore-ydQcDBD4.js} +16 -7
- package/dist/styleStore-ydQcDBD4.js.map +1 -0
- package/dist/token-DTOyFLmp.js +58 -0
- package/dist/token-DTOyFLmp.js.map +1 -0
- package/dist/{token-u_tM-mtg.js → token-DT_sCPtm.js} +125 -31
- package/dist/token-DT_sCPtm.js.map +1 -0
- package/dist/{trace-Bu_qOqRy.js → trace-CO36aenp.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-CO36aenp.js.map} +1 -1
- package/dist/{trace-CU0rvNYr.js → trace-D8j96G57.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-D8j96G57.js.map} +1 -1
- package/dist/transform-BTJOg8Hg.js +23 -0
- package/dist/transform-BTJOg8Hg.js.map +1 -0
- package/dist/{utils-CWNHx4EC.js → utils-Bmw655wa.js} +3 -3
- package/dist/{utils-CWNHx4EC.js.map → utils-Bmw655wa.js.map} +1 -1
- package/dist/{utils-CEaq_c-A.mjs → utils-D2fygyTm.mjs} +4 -4
- package/dist/{utils-CEaq_c-A.mjs.map → utils-D2fygyTm.mjs.map} +1 -1
- package/dist/{utils-Bdbqn0f8.mjs → utils-DTXCTUlS.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DTXCTUlS.mjs.map} +1 -1
- package/dist/{utils-BbehLOby.js → utils-DVFxZnVC.js} +159 -76
- package/dist/utils-DVFxZnVC.js.map +1 -0
- package/dist/{utils-D7FAOyg6.js → utils-hoYnMiA7.js} +4 -4
- package/dist/{utils-D7FAOyg6.js.map → utils-hoYnMiA7.js.map} +1 -1
- package/dist/utils.js +3 -3
- package/dist/value-D-ZcRzLA.js +42 -0
- package/dist/value-D-ZcRzLA.js.map +1 -0
- package/dist/{value-BR4e2MKt.js → value-DvFkGBy2.js} +147 -28
- package/dist/value-DvFkGBy2.js.map +1 -0
- package/dist/value-dG9LK0Gq.js +85 -0
- package/dist/value-dG9LK0Gq.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-BOU7_xld.mjs} +5 -5
- package/dist/{webpack-Dh6lox2l.mjs.map → webpack-BOU7_xld.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-BryWDfQX.js.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js.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-BAw63qX6.js +0 -15
- package/dist/debug-BAw63qX6.js.map +0 -1
- package/dist/debug-DGki_v7g.js +0 -15
- package/dist/debug-DGki_v7g.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-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 +0 -53
- 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
|
@@ -61,6 +61,18 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
61
61
|
};
|
|
62
62
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
63
63
|
//#endregion
|
|
64
|
+
//#region config/config/debug.ts
|
|
65
|
+
const DEFAULT_DEBUG_CONFIG = {
|
|
66
|
+
isDebugClassNameEnabled: false,
|
|
67
|
+
isDebugClassNameConfigured: false,
|
|
68
|
+
maxPropertyLength: 24,
|
|
69
|
+
maxValueLength: 8,
|
|
70
|
+
maxSelectorLength: 8,
|
|
71
|
+
maxParentSelectorLength: 8,
|
|
72
|
+
maxAtRuleLength: 10
|
|
73
|
+
};
|
|
74
|
+
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
75
|
+
//#endregion
|
|
64
76
|
//#region config/utils.ts
|
|
65
77
|
function getCacheTTL(cache) {
|
|
66
78
|
return cache === true ? 3e5 : cache === false ? 0 : Math.max(cache, 0);
|
|
@@ -84,6 +96,9 @@ function hashString(str) {
|
|
|
84
96
|
for (let i = 0; i < str.length; i++) hash = Math.imul(hash ^ str.charCodeAt(i), 16777619);
|
|
85
97
|
return (hash >>> 0).toString(36).padEnd(7, "0");
|
|
86
98
|
}
|
|
99
|
+
function normalizeHashLength(length) {
|
|
100
|
+
return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
|
|
101
|
+
}
|
|
87
102
|
//#endregion
|
|
88
103
|
//#region atomic/layer/layer.ts
|
|
89
104
|
function compareLayerPriority(p1, p2) {
|
|
@@ -156,57 +171,18 @@ function createCssCollector() {
|
|
|
156
171
|
}
|
|
157
172
|
};
|
|
158
173
|
}
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region config/config/debug.ts
|
|
161
|
-
const DEFAULT_DEBUG_CONFIG = {
|
|
162
|
-
isDebugClassNameEnabled: true,
|
|
163
|
-
maxPropertyLength: 24,
|
|
164
|
-
maxValueLength: 8,
|
|
165
|
-
maxSelectorLength: 8,
|
|
166
|
-
maxParentSelectorLength: 8,
|
|
167
|
-
maxAtRuleLength: 10
|
|
168
|
-
};
|
|
169
|
-
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region utils/object.ts
|
|
172
|
-
function toArray(value) {
|
|
173
|
-
return Array.isArray(value) ? value : value ? [value] : [];
|
|
174
|
-
}
|
|
175
|
-
function isFunction(value) {
|
|
176
|
-
return typeof value === "function";
|
|
177
|
-
}
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region config/config/dev.ts
|
|
180
|
-
const DEV_CONFIG_DEFAULT = {
|
|
181
|
-
isDev: false,
|
|
182
|
-
isCheckSelectorEnabled: true,
|
|
183
|
-
isSourcemapEnabled: true,
|
|
184
|
-
isLocalClassNameEnabled: true,
|
|
185
|
-
sheetMaxRules: 1e3,
|
|
186
|
-
sheetStyleTagNonce: null,
|
|
187
|
-
stylePriorityMode: "layer",
|
|
188
|
-
sourcemapLocationMode: "style",
|
|
189
|
-
isElementClassNameEnabled: true
|
|
190
|
-
};
|
|
191
|
-
globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
192
|
-
const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
193
|
-
globalData("config.dev.plugin", () => ({ config: null }));
|
|
194
|
-
globalData("config.dev.base", () => ({ config: null }));
|
|
195
|
-
globalData("config.dev.utils", () => ({ config: null }));
|
|
196
174
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
197
175
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
176
|
+
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
198
177
|
const STYLE_DEV_RSC_IMPORT_PATH = "@fluentic/style/dev/rsc";
|
|
199
178
|
const STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH = "@fluentic/style/entry/prod/extract";
|
|
200
179
|
const STYLE_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/prod/runtime";
|
|
201
180
|
const STYLE_RSC_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/rsc-prod/runtime";
|
|
202
|
-
const DEFAULT_CONFIG = {
|
|
203
|
-
...CSS_CONFIG_DEFAULT,
|
|
204
|
-
localClassName: DEV_CONFIG_DEFAULT.isLocalClassNameEnabled,
|
|
205
|
-
debugClassName: DEFAULT_DEBUG_CONFIG.isDebugClassNameEnabled
|
|
206
|
-
};
|
|
181
|
+
const DEFAULT_CONFIG = { ...CSS_CONFIG_DEFAULT };
|
|
207
182
|
const IMPORT_PATHS = [
|
|
208
183
|
STYLE_IMPORT_PATH,
|
|
209
184
|
STYLE_CSS_IMPORT_PATH,
|
|
185
|
+
STYLE_DIALECT_IMPORT_PATH,
|
|
210
186
|
STYLE_DEV_RSC_IMPORT_PATH
|
|
211
187
|
];
|
|
212
188
|
const IMPORT_EXTRACT = STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH;
|
|
@@ -447,9 +423,6 @@ function getCacheFilePath(cacheDir, args) {
|
|
|
447
423
|
function getCacheKey(args) {
|
|
448
424
|
return node_crypto.createHash("md5").update(args.cacheType).update("\0").update(node_path.resolve(args.filePath)).digest("hex");
|
|
449
425
|
}
|
|
450
|
-
function normalizeSelectorArg(arg) {
|
|
451
|
-
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
452
|
-
}
|
|
453
426
|
//#endregion
|
|
454
427
|
//#region builder/data/const.ts
|
|
455
428
|
const BUILDER_TYPE = symbol("builder.type");
|
|
@@ -459,6 +432,33 @@ const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
|
459
432
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
460
433
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
461
434
|
//#endregion
|
|
435
|
+
//#region utils/object.ts
|
|
436
|
+
function toArray(value) {
|
|
437
|
+
return Array.isArray(value) ? value : value ? [value] : [];
|
|
438
|
+
}
|
|
439
|
+
function isFunction(value) {
|
|
440
|
+
return typeof value === "function";
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region config/config/dev.ts
|
|
444
|
+
const DEV_CONFIG_DEFAULT = {
|
|
445
|
+
isDev: false,
|
|
446
|
+
isCheckSelectorEnabled: true,
|
|
447
|
+
isSourcemapEnabled: true,
|
|
448
|
+
isLocalClassNameEnabled: true,
|
|
449
|
+
sheetMaxRules: 1e3,
|
|
450
|
+
sheetStyleTagNonce: null,
|
|
451
|
+
hashLength: null,
|
|
452
|
+
stylePriorityMode: "sort",
|
|
453
|
+
sourcemapLocationMode: "style",
|
|
454
|
+
isElementClassNameEnabled: true
|
|
455
|
+
};
|
|
456
|
+
globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
457
|
+
const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
458
|
+
globalData("config.dev.plugin", () => ({ config: null }));
|
|
459
|
+
globalData("config.dev.base", () => ({ config: null }));
|
|
460
|
+
globalData("config.dev.utils", () => ({ config: null }));
|
|
461
|
+
//#endregion
|
|
462
462
|
//#region utils/trace.ts
|
|
463
463
|
const FN_MARKER = "$fn_";
|
|
464
464
|
function traceMarker(fn, name) {
|
|
@@ -625,12 +625,48 @@ function getBuilderType(value) {
|
|
|
625
625
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
626
626
|
return value[BUILDER_TYPE];
|
|
627
627
|
}
|
|
628
|
+
function normalizeSelectorArg(arg) {
|
|
629
|
+
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
630
|
+
}
|
|
628
631
|
//#endregion
|
|
629
632
|
//#region style/token.ts
|
|
630
633
|
const TOKEN_ID = symbol("style:token");
|
|
631
634
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
632
|
-
symbol("style:token.debug");
|
|
633
|
-
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
635
|
+
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
636
|
+
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
637
|
+
function createStyleToken(value, debugId) {
|
|
638
|
+
const token = (value, debug) => {
|
|
639
|
+
return createStyleTokenOverride(token, value, debug);
|
|
640
|
+
};
|
|
641
|
+
token[TOKEN_ID] = debugId || String(idCounter$6.value++);
|
|
642
|
+
if (isStyleTokenData(value)) {
|
|
643
|
+
token.value = value.value;
|
|
644
|
+
token.ref = value;
|
|
645
|
+
} else {
|
|
646
|
+
token.value = value;
|
|
647
|
+
token.ref = null;
|
|
648
|
+
}
|
|
649
|
+
return token;
|
|
650
|
+
}
|
|
651
|
+
function createStyleTokenOverride(token, value, debug) {
|
|
652
|
+
const override = isStyleTokenData(value) ? {
|
|
653
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
654
|
+
[TOKEN_OVERRIDE]: true,
|
|
655
|
+
value: value.value,
|
|
656
|
+
ref: value
|
|
657
|
+
} : {
|
|
658
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
659
|
+
[TOKEN_OVERRIDE]: true,
|
|
660
|
+
value,
|
|
661
|
+
ref: null
|
|
662
|
+
};
|
|
663
|
+
if (debug) Object.defineProperty(override, TOKEN_DEBUG, {
|
|
664
|
+
configurable: true,
|
|
665
|
+
enumerable: false,
|
|
666
|
+
value: debug
|
|
667
|
+
});
|
|
668
|
+
return override;
|
|
669
|
+
}
|
|
634
670
|
function isStyleTokenData(value) {
|
|
635
671
|
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
636
672
|
}
|
|
@@ -953,7 +989,7 @@ function createNameFormatter(keys) {
|
|
|
953
989
|
const name = getFormatFn(format)(info);
|
|
954
990
|
if (!hash) return name;
|
|
955
991
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
956
|
-
return name ? name + "
|
|
992
|
+
return name ? name + "--" + hash : hash;
|
|
957
993
|
};
|
|
958
994
|
}
|
|
959
995
|
function compileFormat(format, keySet) {
|
|
@@ -1047,8 +1083,12 @@ const formatClassName = createNameFormatter([
|
|
|
1047
1083
|
"value"
|
|
1048
1084
|
]);
|
|
1049
1085
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
1086
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
1050
1087
|
function getDebugClassName(format, hash, info) {
|
|
1051
|
-
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
1088
|
+
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
1089
|
+
}
|
|
1090
|
+
function getDebugTransformClassName(format, hash, info) {
|
|
1091
|
+
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1052
1092
|
}
|
|
1053
1093
|
function getDebugScopeClassName(format, info) {
|
|
1054
1094
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -1066,20 +1106,38 @@ function escapeCssValue(value) {
|
|
|
1066
1106
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1067
1107
|
}
|
|
1068
1108
|
function escapeCssIdent(ident) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1109
|
+
let result = "";
|
|
1110
|
+
for (let i = 0; i < ident.length; i++) {
|
|
1111
|
+
const char = ident.charAt(i);
|
|
1112
|
+
const code = ident.charCodeAt(i);
|
|
1113
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
1114
|
+
if (code === 0) {
|
|
1115
|
+
result += "�";
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
1119
|
+
result += "\\" + code.toString(16) + " ";
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
1123
|
+
result += "\\-";
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
1127
|
+
result += char + ident.charAt(++i);
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
1131
|
+
result += char;
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
result += "\\" + char;
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1073
1137
|
}
|
|
1074
1138
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
1075
1139
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
1076
1140
|
}
|
|
1077
|
-
function getIdentifierSafeHash(value) {
|
|
1078
|
-
const hash = hashString(value);
|
|
1079
|
-
const first = hash.charCodeAt(0);
|
|
1080
|
-
if (first < 48 || first > 57) return hash;
|
|
1081
|
-
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1082
|
-
}
|
|
1083
1141
|
//#endregion
|
|
1084
1142
|
//#region atomic/utils/debug.ts
|
|
1085
1143
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1237,6 +1295,54 @@ function parseAtRule(rule) {
|
|
|
1237
1295
|
return compressQuery(normalized);
|
|
1238
1296
|
}
|
|
1239
1297
|
//#endregion
|
|
1298
|
+
//#region atomic/utils/hash.ts
|
|
1299
|
+
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1300
|
+
byValue: /* @__PURE__ */ new Map(),
|
|
1301
|
+
byHash: /* @__PURE__ */ new Map(),
|
|
1302
|
+
usedByLength: []
|
|
1303
|
+
}));
|
|
1304
|
+
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1305
|
+
return getPooledHash(value, startLength);
|
|
1306
|
+
}
|
|
1307
|
+
function getPooledHash(value, startLength) {
|
|
1308
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1309
|
+
const valueKey = normalizedStartLength + "\0" + value;
|
|
1310
|
+
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1311
|
+
if (existing) return existing;
|
|
1312
|
+
let length = normalizedStartLength;
|
|
1313
|
+
while (true) {
|
|
1314
|
+
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1315
|
+
length++;
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1319
|
+
const hash = getPooledHashCandidate(value, length, index);
|
|
1320
|
+
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1321
|
+
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1322
|
+
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1323
|
+
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1324
|
+
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1325
|
+
return hash;
|
|
1326
|
+
}
|
|
1327
|
+
length++;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function getPooledHashCandidate(value, length, index) {
|
|
1331
|
+
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1332
|
+
}
|
|
1333
|
+
function getPooledHashUsedCount(length) {
|
|
1334
|
+
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1335
|
+
}
|
|
1336
|
+
function getIdentifierSafeHashPoolSize(length) {
|
|
1337
|
+
if (length <= 0) return 0;
|
|
1338
|
+
return 26 * 36 ** (length - 1);
|
|
1339
|
+
}
|
|
1340
|
+
function getIdentifierSafeHashValue(hash) {
|
|
1341
|
+
const first = hash.charCodeAt(0);
|
|
1342
|
+
if (first < 48 || first > 57) return hash;
|
|
1343
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1344
|
+
}
|
|
1345
|
+
//#endregion
|
|
1240
1346
|
//#region atomic/utils/selector.ts
|
|
1241
1347
|
function getSelectorText(selector) {
|
|
1242
1348
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1250,7 +1356,7 @@ function getSelectorPriority(selector) {
|
|
|
1250
1356
|
}
|
|
1251
1357
|
//#endregion
|
|
1252
1358
|
//#region atomic/className.ts
|
|
1253
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat) {
|
|
1359
|
+
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1254
1360
|
let hash = property;
|
|
1255
1361
|
hash += "\n" + (priority || "");
|
|
1256
1362
|
hash += "\n" + value;
|
|
@@ -1258,8 +1364,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1258
1364
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1259
1365
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1260
1366
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1261
|
-
hash = getIdentifierSafeHash(hash);
|
|
1367
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1262
1368
|
if (!debugClassName) return hash;
|
|
1369
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1263
1370
|
const propertyName = getDebugPropertyName(property, value);
|
|
1264
1371
|
return getDebugClassName(classNameFormat, hash, {
|
|
1265
1372
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1269,6 +1376,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1269
1376
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1270
1377
|
});
|
|
1271
1378
|
}
|
|
1379
|
+
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1380
|
+
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1381
|
+
return CSS_CONFIG.hashLength ?? 7;
|
|
1382
|
+
}
|
|
1272
1383
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1273
1384
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1274
1385
|
}
|
|
@@ -1357,7 +1468,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1357
1468
|
value = value[0];
|
|
1358
1469
|
}
|
|
1359
1470
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1360
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1471
|
+
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1361
1472
|
scopeItem.dedupe = dedupe;
|
|
1362
1473
|
scopeItem.className = className;
|
|
1363
1474
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1395,6 +1506,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1395
1506
|
className: "",
|
|
1396
1507
|
property: overrideItem.property,
|
|
1397
1508
|
value: overrideItem.value,
|
|
1509
|
+
transformClassName: overrideItem.transformClassName,
|
|
1398
1510
|
token: overrideItem.token,
|
|
1399
1511
|
selector: overrideItem.selector,
|
|
1400
1512
|
atRule,
|
|
@@ -1410,7 +1522,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1410
1522
|
value = value[0];
|
|
1411
1523
|
}
|
|
1412
1524
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1413
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1525
|
+
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1414
1526
|
scopeItem.dedupe = dedupe;
|
|
1415
1527
|
scopeItem.className = className;
|
|
1416
1528
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1478,7 +1590,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1478
1590
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1479
1591
|
function getTokenVarName(token, format) {
|
|
1480
1592
|
const id = getStyleTokenId(token);
|
|
1481
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1593
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1482
1594
|
}
|
|
1483
1595
|
function getTokenVar(token, format) {
|
|
1484
1596
|
return getTokenVarFallback(token, format);
|
|
@@ -1553,6 +1665,19 @@ function shouldAppendCssPx(property) {
|
|
|
1553
1665
|
return !UNITLESS.has(property);
|
|
1554
1666
|
}
|
|
1555
1667
|
//#endregion
|
|
1668
|
+
//#region style/transform.ts
|
|
1669
|
+
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1670
|
+
function classNameValue(value, className) {
|
|
1671
|
+
return {
|
|
1672
|
+
[CLASS_NAME_VALUE]: true,
|
|
1673
|
+
value,
|
|
1674
|
+
className
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
function isClassNameValue(value) {
|
|
1678
|
+
return !!value && typeof value === "object" && value[CLASS_NAME_VALUE] === true && typeof value.className === "string";
|
|
1679
|
+
}
|
|
1680
|
+
//#endregion
|
|
1556
1681
|
//#region style/valueRef.ts
|
|
1557
1682
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1558
1683
|
function createAtRuleRef(data) {
|
|
@@ -1582,6 +1707,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1582
1707
|
let token;
|
|
1583
1708
|
let ref;
|
|
1584
1709
|
let variableName;
|
|
1710
|
+
let transformClassName;
|
|
1585
1711
|
let lookupIndex;
|
|
1586
1712
|
if (isStyleData(style)) {
|
|
1587
1713
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1619,6 +1745,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1619
1745
|
priority = valueRaw[0];
|
|
1620
1746
|
valueRaw = valueRaw[1];
|
|
1621
1747
|
}
|
|
1748
|
+
transformClassName = null;
|
|
1749
|
+
if (isClassNameValue(valueRaw)) {
|
|
1750
|
+
transformClassName = valueRaw.className;
|
|
1751
|
+
valueRaw = valueRaw.value;
|
|
1752
|
+
}
|
|
1622
1753
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1623
1754
|
if (ref) valueRaw = ref.value;
|
|
1624
1755
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1634,6 +1765,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1634
1765
|
className: "",
|
|
1635
1766
|
property,
|
|
1636
1767
|
value,
|
|
1768
|
+
transformClassName,
|
|
1637
1769
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1638
1770
|
1,
|
|
1639
1771
|
variableName,
|
|
@@ -1698,7 +1830,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1698
1830
|
value = value[0];
|
|
1699
1831
|
}
|
|
1700
1832
|
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1701
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1833
|
+
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null);
|
|
1702
1834
|
runtimeItem.dedupe = dedupe;
|
|
1703
1835
|
runtimeItem.className = className;
|
|
1704
1836
|
lookupIndex = lookup[dedupe];
|
|
@@ -2495,7 +2627,7 @@ function getCssPropertyName(property) {
|
|
|
2495
2627
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2496
2628
|
const formatter = createNameFormatter(["name"]);
|
|
2497
2629
|
return (format, id, info) => {
|
|
2498
|
-
const hash = getIdentifierSafeHash(id);
|
|
2630
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2499
2631
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2500
2632
|
if (!prefix) return name;
|
|
2501
2633
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2706,11 +2838,11 @@ function createStyleFn(args) {
|
|
|
2706
2838
|
style.plain = fnPlain;
|
|
2707
2839
|
style.keyframes = fnKeyframes;
|
|
2708
2840
|
style.merge = fnMerge;
|
|
2709
|
-
|
|
2841
|
+
assignStyleFnMeta(style, {
|
|
2842
|
+
mode: "StyleObject",
|
|
2710
2843
|
selectors,
|
|
2711
2844
|
transform: transform ?? null
|
|
2712
|
-
};
|
|
2713
|
-
Object.assign(style, { [META]: meta });
|
|
2845
|
+
});
|
|
2714
2846
|
return { style };
|
|
2715
2847
|
}
|
|
2716
2848
|
function mergeStyleResult(target, style) {
|
|
@@ -2719,12 +2851,17 @@ function mergeStyleResult(target, style) {
|
|
|
2719
2851
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2720
2852
|
return target;
|
|
2721
2853
|
}
|
|
2854
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2855
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2856
|
+
return styleFn;
|
|
2857
|
+
}
|
|
2722
2858
|
function getStyleFnMeta(styleFn) {
|
|
2723
2859
|
return styleFn[META];
|
|
2724
2860
|
}
|
|
2725
2861
|
//#endregion
|
|
2726
2862
|
//#region compiler/utils/import_source.ts
|
|
2727
2863
|
const DefaultStyleFnMeta = {
|
|
2864
|
+
mode: "StyleObject",
|
|
2728
2865
|
selectors: PrioritySelectors,
|
|
2729
2866
|
transform: null
|
|
2730
2867
|
};
|
|
@@ -2977,6 +3114,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2977
3114
|
}
|
|
2978
3115
|
}
|
|
2979
3116
|
//#endregion
|
|
3117
|
+
//#region style/value.ts
|
|
3118
|
+
function createToken(value, debugId) {
|
|
3119
|
+
return createStyleToken(value, debugId);
|
|
3120
|
+
}
|
|
3121
|
+
//#endregion
|
|
3122
|
+
//#region dialect/namedTokens.ts
|
|
3123
|
+
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
3124
|
+
function createNamedToken(id, value) {
|
|
3125
|
+
return createToken(value, createNamedTokenId(id));
|
|
3126
|
+
}
|
|
3127
|
+
function createNamedTokens(namespace, values) {
|
|
3128
|
+
return createNamedTokenProxy({
|
|
3129
|
+
__fluenticNamedTokens: true,
|
|
3130
|
+
namespace,
|
|
3131
|
+
values,
|
|
3132
|
+
cache: /* @__PURE__ */ new Map()
|
|
3133
|
+
}, []);
|
|
3134
|
+
}
|
|
3135
|
+
function createNamedTokenId(id) {
|
|
3136
|
+
return sanitizeCssIdentName(id.replace(/\./g, "-"), "named-token");
|
|
3137
|
+
}
|
|
3138
|
+
function createNamedTokenProxy(root, path) {
|
|
3139
|
+
return new Proxy(noop, {
|
|
3140
|
+
get(_target, property) {
|
|
3141
|
+
if (property === ROOT) return root;
|
|
3142
|
+
if (property === "then") return void 0;
|
|
3143
|
+
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
3144
|
+
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3145
|
+
if (!path.length) return void 0;
|
|
3146
|
+
return getNamedTokenAtPath(root, path)[property];
|
|
3147
|
+
}
|
|
3148
|
+
if (typeof property === "symbol") return void 0;
|
|
3149
|
+
return createNamedTokenProxy(root, path.concat(String(property)));
|
|
3150
|
+
},
|
|
3151
|
+
apply(_target, _thisArg, args) {
|
|
3152
|
+
if (!path.length) return void 0;
|
|
3153
|
+
return getNamedTokenAtPath(root, path).apply(void 0, args);
|
|
3154
|
+
}
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
function getNamedTokenAtPath(root, path) {
|
|
3158
|
+
const key = path.join(".");
|
|
3159
|
+
const cached = root.cache.get(key);
|
|
3160
|
+
if (cached) return cached;
|
|
3161
|
+
const value = getValueAtPath(root.values, path);
|
|
3162
|
+
const token = createNamedToken(root.namespace + "." + key, value);
|
|
3163
|
+
root.cache.set(key, token);
|
|
3164
|
+
return token;
|
|
3165
|
+
}
|
|
3166
|
+
function getValueAtPath(values, path) {
|
|
3167
|
+
let current = values;
|
|
3168
|
+
for (let i = 0; i < path.length; i++) {
|
|
3169
|
+
if (!current || typeof current !== "object") return void 0;
|
|
3170
|
+
current = current[path[i]];
|
|
3171
|
+
}
|
|
3172
|
+
return current;
|
|
3173
|
+
}
|
|
3174
|
+
function noop() {}
|
|
3175
|
+
//#endregion
|
|
2980
3176
|
//#region style/utils/expose.ts
|
|
2981
3177
|
function exposeStyle(styles) {
|
|
2982
3178
|
return exposeStyleObject(styles);
|
|
@@ -3032,6 +3228,7 @@ function evaluateNode(node, scope) {
|
|
|
3032
3228
|
case "ParenthesizedExpression":
|
|
3033
3229
|
case "TSAsExpression":
|
|
3034
3230
|
case "TSNonNullExpression":
|
|
3231
|
+
case "TSSatisfiesExpression":
|
|
3035
3232
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
3036
3233
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
3037
3234
|
}
|
|
@@ -3104,14 +3301,14 @@ function evaluateMember(node, scope) {
|
|
|
3104
3301
|
if (!key.ok) return key;
|
|
3105
3302
|
const obj = evaluateNode(node.object, scope);
|
|
3106
3303
|
if (!obj.ok) return obj;
|
|
3107
|
-
if (obj.value && typeof obj.value === "object") return evalOk(obj.value[key.value]);
|
|
3304
|
+
if (obj.value && (typeof obj.value === "object" || typeof obj.value === "function")) return evalOk(obj.value[key.value]);
|
|
3108
3305
|
return evalFail("Cannot index non-object");
|
|
3109
3306
|
}
|
|
3110
3307
|
const prop = node.property.name;
|
|
3111
3308
|
const obj = evaluateNode(node.object, scope);
|
|
3112
3309
|
if (!obj.ok) return obj;
|
|
3113
3310
|
if (obj.value == null) return evalFail(`Cannot access .${prop} on null/undefined`);
|
|
3114
|
-
if (typeof obj.value !== "object" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3311
|
+
if (typeof obj.value !== "object" && typeof obj.value !== "function" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3115
3312
|
return evalOk(obj.value[prop]);
|
|
3116
3313
|
}
|
|
3117
3314
|
function evaluateObject(node, scope) {
|
|
@@ -3150,7 +3347,7 @@ function evaluateObject(node, scope) {
|
|
|
3150
3347
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
3151
3348
|
const val = evaluateNode(prop.value, scope);
|
|
3152
3349
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3153
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3350
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3154
3351
|
if (prop.loc?.start) locations[key] = {
|
|
3155
3352
|
line: prop.loc.start.line,
|
|
3156
3353
|
column: prop.loc.start.column + 1,
|
|
@@ -3315,6 +3512,23 @@ function evaluateCall(node, scope) {
|
|
|
3315
3512
|
if (!debugId.ok) return debugId;
|
|
3316
3513
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3317
3514
|
}
|
|
3515
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3516
|
+
const id = evaluateNode(node.arguments[0], scope);
|
|
3517
|
+
if (!id.ok) return id;
|
|
3518
|
+
if (typeof id.value !== "string") return evalFail("createNamedToken id must be a static string");
|
|
3519
|
+
const value = evaluateNode(node.arguments[1], scope);
|
|
3520
|
+
if (!value.ok) return value;
|
|
3521
|
+
return evalOk(createNamedToken(id.value, value.value));
|
|
3522
|
+
}
|
|
3523
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedTokens") {
|
|
3524
|
+
const namespace = evaluateNode(node.arguments[0], scope);
|
|
3525
|
+
if (!namespace.ok) return namespace;
|
|
3526
|
+
if (typeof namespace.value !== "string") return evalFail("createNamedTokens namespace must be a static string");
|
|
3527
|
+
const values = evaluateNode(node.arguments[1], scope);
|
|
3528
|
+
if (!values.ok) return values;
|
|
3529
|
+
if (!values.value || typeof values.value !== "object") return evalFail("createNamedTokens values must be a static object");
|
|
3530
|
+
return evalOk(createNamedTokens(namespace.value, values.value));
|
|
3531
|
+
}
|
|
3318
3532
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3319
3533
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3320
3534
|
if (!styles.ok) return styles;
|
|
@@ -3527,7 +3741,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3527
3741
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3528
3742
|
});
|
|
3529
3743
|
}
|
|
3530
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3744
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3531
3745
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3532
3746
|
}
|
|
3533
3747
|
function evaluateBinary(node, scope) {
|
|
@@ -3583,7 +3797,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3583
3797
|
}
|
|
3584
3798
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3585
3799
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3586
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3800
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3587
3801
|
}
|
|
3588
3802
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3589
3803
|
const declarations = [];
|
|
@@ -3880,12 +4094,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3880
4094
|
}
|
|
3881
4095
|
const formatVarName = createNameFormatter(["name"]);
|
|
3882
4096
|
function getLocalVarName(filePath, line, column, format) {
|
|
3883
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
4097
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3884
4098
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3885
4099
|
}
|
|
3886
4100
|
//#endregion
|
|
3887
4101
|
//#region compiler/transform/debug/utils/debug_data.ts
|
|
3888
|
-
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride) {
|
|
4102
|
+
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride, classNameArg = false) {
|
|
3889
4103
|
const loc = locOverride ?? node.loc?.start;
|
|
3890
4104
|
const line = loc?.line ?? 1;
|
|
3891
4105
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3902,10 +4116,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3902
4116
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3903
4117
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3904
4118
|
];
|
|
4119
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3905
4120
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3906
4121
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3907
4122
|
return t.objectExpression(properties);
|
|
3908
4123
|
}
|
|
4124
|
+
function buildClassNames(t, args) {
|
|
4125
|
+
const classNames = /* @__PURE__ */ new Map();
|
|
4126
|
+
for (const arg of args) collectClassNameLoc(arg, classNames);
|
|
4127
|
+
const fields = [];
|
|
4128
|
+
for (const [className, loc] of classNames) fields.push(t.objectProperty(t.stringLiteral(className), buildLoc(t, loc.line, loc.column + 1)));
|
|
4129
|
+
return t.objectExpression(fields);
|
|
4130
|
+
}
|
|
4131
|
+
function collectClassNameLoc(arg, classNames) {
|
|
4132
|
+
if (!arg) return;
|
|
4133
|
+
if (arg.type === "StringLiteral") {
|
|
4134
|
+
const loc = arg.loc?.start;
|
|
4135
|
+
if (loc) classNames.set(arg.value, loc);
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
if (arg.type === "TemplateLiteral" && arg.expressions.length === 0) {
|
|
4139
|
+
const loc = arg.loc?.start;
|
|
4140
|
+
if (loc) classNames.set(arg.quasis[0]?.value.cooked ?? arg.quasis[0]?.value.raw ?? "", loc);
|
|
4141
|
+
return;
|
|
4142
|
+
}
|
|
4143
|
+
if (arg.type === "ArrayExpression") {
|
|
4144
|
+
for (const item of arg.elements) collectClassNameLoc(item, classNames);
|
|
4145
|
+
return;
|
|
4146
|
+
}
|
|
4147
|
+
if (arg.type === "ConditionalExpression") {
|
|
4148
|
+
collectClassNameLoc(arg.consequent, classNames);
|
|
4149
|
+
collectClassNameLoc(arg.alternate, classNames);
|
|
4150
|
+
return;
|
|
4151
|
+
}
|
|
4152
|
+
if (arg.type === "LogicalExpression") {
|
|
4153
|
+
collectClassNameLoc(arg.left, classNames);
|
|
4154
|
+
collectClassNameLoc(arg.right, classNames);
|
|
4155
|
+
return;
|
|
4156
|
+
}
|
|
4157
|
+
if (arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && arg.callee.property.type === "Identifier" && arg.callee.property.name === "weight") collectClassNameLoc(arg.arguments[0], classNames);
|
|
4158
|
+
}
|
|
3909
4159
|
function getShortLabel(label) {
|
|
3910
4160
|
const parts = label.split(".");
|
|
3911
4161
|
return parts[parts.length - 1] || label;
|
|
@@ -4064,7 +4314,9 @@ function createDebugPlugin(args) {
|
|
|
4064
4314
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
4065
4315
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
4066
4316
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
4067
|
-
|
|
4317
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4318
|
+
const isClassNameCall = rootName ? state.styleMetas.get(rootName)?.mode === "ClassName" : false;
|
|
4319
|
+
path.node.arguments.push(buildDebugDataObject(t, path.node, state.fileId, sourceUrlRef, sourceContentRef, options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat, getDebugStyleArg(t, path, state, options.dev?.sourcemapMode ?? "style"), getDebugCallLoc(path, state), isClassNameCall));
|
|
4068
4320
|
},
|
|
4069
4321
|
JSXOpeningElement(path, state) {
|
|
4070
4322
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4655,6 +4907,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4655
4907
|
//#region compiler/utils/file_resolver.ts
|
|
4656
4908
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4657
4909
|
const resolver = new oxc_resolver.ResolverFactory({
|
|
4910
|
+
conditionNames: [
|
|
4911
|
+
"import",
|
|
4912
|
+
"module",
|
|
4913
|
+
"default",
|
|
4914
|
+
"types"
|
|
4915
|
+
],
|
|
4658
4916
|
extensions: [
|
|
4659
4917
|
".ts",
|
|
4660
4918
|
".tsx",
|
|
@@ -4814,15 +5072,112 @@ function extractStyleChain(node, styleNames) {
|
|
|
4814
5072
|
}
|
|
4815
5073
|
//#endregion
|
|
4816
5074
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4817
|
-
function applyTransform(styleObj, transform) {
|
|
4818
|
-
|
|
5075
|
+
function applyTransform(styleObj, transform, cssConfig) {
|
|
5076
|
+
if (!transform) return styleObj;
|
|
5077
|
+
const input = transformRuntimeValues(styleObj, transform, cssConfig);
|
|
5078
|
+
return carryTransformedLocations(input, transform.transform(input), transform);
|
|
5079
|
+
}
|
|
5080
|
+
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5081
|
+
let result = null;
|
|
5082
|
+
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5083
|
+
const runtimeValue = getCompiledRuntimeValue(getPriorityTupleValue(rawValue));
|
|
5084
|
+
if (!runtimeValue) continue;
|
|
5085
|
+
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5086
|
+
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5087
|
+
result ??= cloneCompiledStyleObject(styleObj);
|
|
5088
|
+
result[property] = Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number" ? [rawValue[0], createCompiledRuntimeValue(transformedRuntimeValue)] : createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5089
|
+
}
|
|
5090
|
+
return result ?? styleObj;
|
|
5091
|
+
}
|
|
5092
|
+
function getPriorityTupleValue(value) {
|
|
5093
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5094
|
+
}
|
|
5095
|
+
function cloneCompiledStyleObject(styleObj) {
|
|
5096
|
+
const cloned = { ...styleObj };
|
|
5097
|
+
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5098
|
+
if (locations) Object.defineProperty(cloned, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5099
|
+
configurable: true,
|
|
5100
|
+
enumerable: false,
|
|
5101
|
+
value: locations
|
|
5102
|
+
});
|
|
5103
|
+
return cloned;
|
|
5104
|
+
}
|
|
5105
|
+
function createCompiledRuntimeValue(runtimeValue) {
|
|
5106
|
+
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
5107
|
+
}
|
|
5108
|
+
function transformRuntimeExpression(property, expression, transform, cssConfig) {
|
|
5109
|
+
if (expression.type === "StringLiteral") return createPrimitiveExpression(expression, normalizeRuntimeTransformedValue(getSingleTransformedValue(transform.transform({ [property]: expression.value })), cssConfig)) ?? expression;
|
|
5110
|
+
if (expression.type === "ConditionalExpression") {
|
|
5111
|
+
const consequent = transformRuntimeExpression(property, expression.consequent, transform, cssConfig);
|
|
5112
|
+
const alternate = transformRuntimeExpression(property, expression.alternate, transform, cssConfig);
|
|
5113
|
+
return consequent === expression.consequent && alternate === expression.alternate ? expression : {
|
|
5114
|
+
...expression,
|
|
5115
|
+
consequent,
|
|
5116
|
+
alternate
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
5119
|
+
return expression;
|
|
5120
|
+
}
|
|
5121
|
+
function getSingleTransformedValue(transformed) {
|
|
5122
|
+
const values = Object.values(transformed);
|
|
5123
|
+
if (!values.length) return void 0;
|
|
5124
|
+
return values[0];
|
|
5125
|
+
}
|
|
5126
|
+
function normalizeRuntimeTransformedValue(value, cssConfig) {
|
|
5127
|
+
if (isStyleTokenOverrideData(value)) return getTokenOverrideValue(value, cssConfig.tokenNameFormat);
|
|
5128
|
+
if (isStyleTokenData(value)) return getTokenVar(value, cssConfig.tokenNameFormat);
|
|
5129
|
+
return value;
|
|
5130
|
+
}
|
|
5131
|
+
function createPrimitiveExpression(original, value) {
|
|
5132
|
+
if (original.type === "StringLiteral" && value === original.value) return null;
|
|
5133
|
+
if (typeof value === "string") return {
|
|
5134
|
+
...original,
|
|
5135
|
+
type: "StringLiteral",
|
|
5136
|
+
value
|
|
5137
|
+
};
|
|
5138
|
+
if (typeof value === "number") return {
|
|
5139
|
+
...original,
|
|
5140
|
+
type: "NumericLiteral",
|
|
5141
|
+
value
|
|
5142
|
+
};
|
|
5143
|
+
if (typeof value === "boolean") return {
|
|
5144
|
+
...original,
|
|
5145
|
+
type: "BooleanLiteral",
|
|
5146
|
+
value
|
|
5147
|
+
};
|
|
5148
|
+
if (value === null) return {
|
|
5149
|
+
...original,
|
|
5150
|
+
type: "NullLiteral"
|
|
5151
|
+
};
|
|
5152
|
+
return null;
|
|
5153
|
+
}
|
|
5154
|
+
function carryTransformedLocations(input, transformed, transform) {
|
|
5155
|
+
const inputLocations = input[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5156
|
+
if (!inputLocations) return transformed;
|
|
5157
|
+
const locations = { ...transformed[COMPILED_STYLE_OBJECT_LOCATIONS] };
|
|
5158
|
+
for (const [property, loc] of Object.entries(inputLocations)) {
|
|
5159
|
+
if (property in transformed && !locations[property]) locations[property] = loc;
|
|
5160
|
+
const single = transform.transform({ [property]: input[property] });
|
|
5161
|
+
for (const transformedProperty of Object.keys(single)) locations[transformedProperty] ??= loc;
|
|
5162
|
+
}
|
|
5163
|
+
if (!Object.keys(locations).length) return transformed;
|
|
5164
|
+
Object.defineProperty(transformed, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5165
|
+
configurable: true,
|
|
5166
|
+
enumerable: false,
|
|
5167
|
+
value: locations
|
|
5168
|
+
});
|
|
5169
|
+
return transformed;
|
|
4819
5170
|
}
|
|
4820
5171
|
/**
|
|
4821
5172
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
4822
5173
|
* Returns null if any argument cannot be statically evaluated.
|
|
4823
5174
|
*/
|
|
4824
|
-
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4825
|
-
const css = getCssConfig(opts);
|
|
5175
|
+
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5176
|
+
const css = getCssConfig(opts, runtimeMode);
|
|
5177
|
+
if (meta.mode === "ClassName") {
|
|
5178
|
+
if (chain.kind !== "style") return null;
|
|
5179
|
+
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5180
|
+
}
|
|
4826
5181
|
const selectors = meta.selectors;
|
|
4827
5182
|
const transform = meta.transform;
|
|
4828
5183
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4830,13 +5185,16 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /*
|
|
|
4830
5185
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
4831
5186
|
return null;
|
|
4832
5187
|
}
|
|
4833
|
-
function getCssConfig(opts) {
|
|
5188
|
+
function getCssConfig(opts, runtimeMode) {
|
|
4834
5189
|
const css = opts.css;
|
|
5190
|
+
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
4835
5191
|
return {
|
|
4836
5192
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5193
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5194
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4837
5195
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4838
|
-
localClassName:
|
|
4839
|
-
debugClassName: css?.debugClassName ??
|
|
5196
|
+
localClassName: isDevRuntimeMode,
|
|
5197
|
+
debugClassName: css?.debugClassName ?? isDevRuntimeMode,
|
|
4840
5198
|
scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
|
|
4841
5199
|
};
|
|
4842
5200
|
}
|
|
@@ -4854,6 +5212,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4854
5212
|
rules
|
|
4855
5213
|
};
|
|
4856
5214
|
}
|
|
5215
|
+
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
5216
|
+
const items = [];
|
|
5217
|
+
const rules = [];
|
|
5218
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
5219
|
+
let i = 0;
|
|
5220
|
+
while (i < chain.methods.length) {
|
|
5221
|
+
const method = chain.methods[i];
|
|
5222
|
+
if (!compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options)) return null;
|
|
5223
|
+
i++;
|
|
5224
|
+
}
|
|
5225
|
+
return {
|
|
5226
|
+
type: "style",
|
|
5227
|
+
items,
|
|
5228
|
+
rules
|
|
5229
|
+
};
|
|
5230
|
+
}
|
|
5231
|
+
function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options) {
|
|
5232
|
+
const selector = selectors[method.name];
|
|
5233
|
+
if (!selector) return false;
|
|
5234
|
+
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5235
|
+
const selectorStr = selector.selector.trim();
|
|
5236
|
+
if (selectorStr === "...") {
|
|
5237
|
+
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5238
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5239
|
+
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5240
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5241
|
+
if (!result) return false;
|
|
5242
|
+
items.push(...result.items);
|
|
5243
|
+
rules.push(...result.rules);
|
|
5244
|
+
return true;
|
|
5245
|
+
}
|
|
5246
|
+
return false;
|
|
5247
|
+
}
|
|
5248
|
+
if (selectorStr.startsWith("@")) {
|
|
5249
|
+
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5250
|
+
const hasArg = selectorStr.includes("$$");
|
|
5251
|
+
const priority = getAtRulePriority(selector.priority, isMedia, method.args[0]);
|
|
5252
|
+
let argOffset = 0;
|
|
5253
|
+
if (isMedia && isNumericLiteral(method.args[0])) argOffset = 1;
|
|
5254
|
+
let atRule = selectorStr;
|
|
5255
|
+
if (hasArg) {
|
|
5256
|
+
const queryArg = evaluateNode(method.args[argOffset], scope);
|
|
5257
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, queryArg, method.args[argOffset]);
|
|
5258
|
+
throwIfRequiredStaticSelectorValue(options, `style.${method.name}`, queryArg);
|
|
5259
|
+
if (!queryArg.ok) return false;
|
|
5260
|
+
const [before, after] = selectorStr.split("$$");
|
|
5261
|
+
atRule = before + String(queryArg.value) + (after ?? "");
|
|
5262
|
+
}
|
|
5263
|
+
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5264
|
+
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5265
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5266
|
+
}
|
|
5267
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5268
|
+
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
5269
|
+
const [before, after] = selectorStr.split(splitToken);
|
|
5270
|
+
const selectorArg = evaluateNode(method.args[0], scope);
|
|
5271
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, selectorArg, method.args[0]);
|
|
5272
|
+
if (!selectorArg.ok) return false;
|
|
5273
|
+
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5274
|
+
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5275
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5276
|
+
}
|
|
5277
|
+
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5278
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5279
|
+
}
|
|
5280
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
5281
|
+
if (startIndex >= args.length) return true;
|
|
5282
|
+
const styleObj = {};
|
|
5283
|
+
let i = startIndex;
|
|
5284
|
+
while (i < args.length) {
|
|
5285
|
+
const arg = evaluateNode(args[i], scope);
|
|
5286
|
+
if (!arg.ok) {
|
|
5287
|
+
throwIfRequiredStaticStyleValue(arg);
|
|
5288
|
+
return false;
|
|
5289
|
+
}
|
|
5290
|
+
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
5291
|
+
i++;
|
|
5292
|
+
}
|
|
5293
|
+
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5294
|
+
}
|
|
5295
|
+
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
5296
|
+
if (!value) return true;
|
|
5297
|
+
if (typeof value === "string") {
|
|
5298
|
+
Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
|
|
5299
|
+
return true;
|
|
5300
|
+
}
|
|
5301
|
+
if (Array.isArray(value)) {
|
|
5302
|
+
for (const item of value) if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
|
|
5303
|
+
return true;
|
|
5304
|
+
}
|
|
5305
|
+
if (isWeightedClassName(value)) {
|
|
5306
|
+
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5307
|
+
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
5308
|
+
return true;
|
|
5309
|
+
}
|
|
5310
|
+
return false;
|
|
5311
|
+
}
|
|
5312
|
+
function decorateClassNameStyle(style, className) {
|
|
5313
|
+
const result = {};
|
|
5314
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5315
|
+
if (value === null || value === void 0) {
|
|
5316
|
+
result[property] = value;
|
|
5317
|
+
continue;
|
|
5318
|
+
}
|
|
5319
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "number") {
|
|
5320
|
+
const rawValue = value[1];
|
|
5321
|
+
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5322
|
+
continue;
|
|
5323
|
+
}
|
|
5324
|
+
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
5325
|
+
}
|
|
5326
|
+
return result;
|
|
5327
|
+
}
|
|
5328
|
+
function isWeightedClassName(value) {
|
|
5329
|
+
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5330
|
+
}
|
|
5331
|
+
function applyClassNameWeight(style, weight) {
|
|
5332
|
+
const weighted = {};
|
|
5333
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5334
|
+
if (value === null || value === void 0) {
|
|
5335
|
+
weighted[property] = value;
|
|
5336
|
+
continue;
|
|
5337
|
+
}
|
|
5338
|
+
weighted[property] = [weight, Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value];
|
|
5339
|
+
}
|
|
5340
|
+
return weighted;
|
|
5341
|
+
}
|
|
4857
5342
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4858
5343
|
if (chain.baseArgs.length > 0) {
|
|
4859
5344
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4861,7 +5346,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4861
5346
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4862
5347
|
return false;
|
|
4863
5348
|
}
|
|
4864
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5349
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
4865
5350
|
}
|
|
4866
5351
|
let i = 0;
|
|
4867
5352
|
while (i < chain.methods.length) {
|
|
@@ -4880,7 +5365,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4880
5365
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4881
5366
|
return null;
|
|
4882
5367
|
}
|
|
4883
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
5368
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
4884
5369
|
}
|
|
4885
5370
|
let i = 0;
|
|
4886
5371
|
while (i < chain.methods.length) {
|
|
@@ -4998,14 +5483,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4998
5483
|
return true;
|
|
4999
5484
|
}
|
|
5000
5485
|
if (node.type !== "CallExpression") return false;
|
|
5001
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5486
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
5002
5487
|
if (!overrideChain) return false;
|
|
5003
5488
|
const { slotId, items: overrideItems } = overrideChain;
|
|
5004
5489
|
let i = 0;
|
|
5005
5490
|
while (i < overrideItems.length) {
|
|
5006
5491
|
const overrideItem = overrideItems[i];
|
|
5007
5492
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
5008
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5493
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
5009
5494
|
if (!compileStyleChainInto(overrideItem.chain, overrideItem.meta.selectors, fileId, scope, cssConfig, overrideItem.meta.transform, 4, slotId, mergedAtRules, items, cssRules, scope.styleNames ?? /* @__PURE__ */ new Set(), options, overrideItem.callsiteOverride)) return false;
|
|
5010
5495
|
} else if (overrideItem.styleData !== void 0) {
|
|
5011
5496
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -5014,15 +5499,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
5014
5499
|
}
|
|
5015
5500
|
return true;
|
|
5016
5501
|
}
|
|
5017
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5502
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
5018
5503
|
const callee = node.callee;
|
|
5019
5504
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5020
5505
|
const methodName = callee.property.name;
|
|
5021
5506
|
const obj = callee.object;
|
|
5022
5507
|
if (obj.type === "CallExpression") {
|
|
5023
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5508
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
5024
5509
|
if (!inner) return null;
|
|
5025
|
-
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, transform, options);
|
|
5510
|
+
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, cssConfig, transform, options);
|
|
5026
5511
|
if (!overrideItem) return null;
|
|
5027
5512
|
return {
|
|
5028
5513
|
slotId: inner.slotId,
|
|
@@ -5037,7 +5522,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5037
5522
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
5038
5523
|
if (!styleArg.ok) return null;
|
|
5039
5524
|
items.push({
|
|
5040
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5525
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5041
5526
|
selector: null,
|
|
5042
5527
|
atRules: null
|
|
5043
5528
|
});
|
|
@@ -5047,7 +5532,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5047
5532
|
items
|
|
5048
5533
|
};
|
|
5049
5534
|
}
|
|
5050
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5535
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
5051
5536
|
const sel = selectors[methodName];
|
|
5052
5537
|
if (!sel) return null;
|
|
5053
5538
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -5074,7 +5559,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5074
5559
|
callsiteOverride
|
|
5075
5560
|
};
|
|
5076
5561
|
return {
|
|
5077
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5562
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5078
5563
|
selector: null,
|
|
5079
5564
|
atRules: null,
|
|
5080
5565
|
callsiteOverride
|
|
@@ -5099,7 +5584,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5099
5584
|
if (!styleArg.ok) return null;
|
|
5100
5585
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5101
5586
|
return {
|
|
5102
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5587
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5103
5588
|
selector: null,
|
|
5104
5589
|
atRules: [atRuleSelector]
|
|
5105
5590
|
};
|
|
@@ -5115,7 +5600,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5115
5600
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5116
5601
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
5117
5602
|
return {
|
|
5118
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5603
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5119
5604
|
selector: itemSelector,
|
|
5120
5605
|
atRules: null
|
|
5121
5606
|
};
|
|
@@ -5123,7 +5608,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5123
5608
|
const styleArg = evaluateNode(args[0], scope);
|
|
5124
5609
|
if (!styleArg.ok) return null;
|
|
5125
5610
|
return {
|
|
5126
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5611
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5127
5612
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5128
5613
|
atRules: null
|
|
5129
5614
|
};
|
|
@@ -5207,7 +5692,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5207
5692
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5208
5693
|
return false;
|
|
5209
5694
|
}
|
|
5210
|
-
return addStyleItems(applyTransform(styleArg.value, transform), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5695
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5211
5696
|
}
|
|
5212
5697
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5213
5698
|
if (!styleArgNode) return false;
|
|
@@ -5288,14 +5773,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5288
5773
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5289
5774
|
return false;
|
|
5290
5775
|
}
|
|
5291
|
-
return addStyleItems(applyTransform(evaled.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5776
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5292
5777
|
}
|
|
5293
5778
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5294
5779
|
if (!styleResult.ok) {
|
|
5295
5780
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5296
5781
|
return false;
|
|
5297
5782
|
}
|
|
5298
|
-
return addStyleItems(applyTransform(styleResult.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5783
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5299
5784
|
}
|
|
5300
5785
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5301
5786
|
const selectorStr = selector.selector.trim();
|
|
@@ -5314,7 +5799,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5314
5799
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5315
5800
|
if (!styleResult.ok) return false;
|
|
5316
5801
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5317
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5802
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5318
5803
|
let i = 0;
|
|
5319
5804
|
while (i < selectorValues.length) {
|
|
5320
5805
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5442,7 +5927,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5442
5927
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5443
5928
|
const valueStr = String(value ?? "");
|
|
5444
5929
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
5445
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5930
|
+
const className = getAtomicClassName(sourceItem.property, priority, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5446
5931
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5447
5932
|
items.push(item);
|
|
5448
5933
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5523,7 +6008,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5523
6008
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5524
6009
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5525
6010
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5526
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
6011
|
+
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5527
6012
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5528
6013
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5529
6014
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5591,10 +6076,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5591
6076
|
const rawValue = styleObj[property];
|
|
5592
6077
|
let priority = null;
|
|
5593
6078
|
let value = rawValue;
|
|
6079
|
+
let transformClassName = null;
|
|
5594
6080
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5595
6081
|
priority = rawValue[0];
|
|
5596
6082
|
value = rawValue[1];
|
|
5597
6083
|
}
|
|
6084
|
+
if (isClassNameValue(value)) {
|
|
6085
|
+
transformClassName = value.className;
|
|
6086
|
+
value = value.value;
|
|
6087
|
+
}
|
|
5598
6088
|
if (value === null || value === void 0) {
|
|
5599
6089
|
i++;
|
|
5600
6090
|
continue;
|
|
@@ -5614,7 +6104,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5614
6104
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5615
6105
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5616
6106
|
const dedupe = getClassNameDedupe(property, priority, selector, parentSelector, atRules);
|
|
5617
|
-
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
6107
|
+
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5618
6108
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5619
6109
|
item.sourceTrace = propertyCallsite ? {
|
|
5620
6110
|
property,
|
|
@@ -5899,7 +6389,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
|
|
|
5899
6389
|
if (chain?.kind === "style" || chain?.kind === "scope") try {
|
|
5900
6390
|
const meta = scope.styleMetas?.get(chain.rootName);
|
|
5901
6391
|
if (!meta) return evalFail("Cannot resolve imported style function");
|
|
5902
|
-
const result = compileChain(chain, fileId, node.loc?.start, scope, options, meta, styleNames);
|
|
6392
|
+
const result = compileChain(chain, fileId, node.loc?.start, scope, options, scope.runtimeMode ?? null, meta, styleNames);
|
|
5903
6393
|
if (!result) return evalFail("Cannot compile imported style chain");
|
|
5904
6394
|
const extracted = createExtractedChainValue(result, options.dev?.sourcemapMode === "value" ? result : compileChain(chain, fileId, node.loc?.start, scope, {
|
|
5905
6395
|
...options,
|
|
@@ -5907,7 +6397,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
|
|
|
5907
6397
|
...options.dev,
|
|
5908
6398
|
sourcemapMode: "value"
|
|
5909
6399
|
}
|
|
5910
|
-
}, meta, styleNames) ?? result);
|
|
6400
|
+
}, scope.runtimeMode ?? null, meta, styleNames) ?? result);
|
|
5911
6401
|
if (!extracted) return evalFail("Cannot extract imported style chain");
|
|
5912
6402
|
return evalOk(extracted);
|
|
5913
6403
|
} catch (error) {
|
|
@@ -6426,7 +6916,8 @@ function getEvalScope(state) {
|
|
|
6426
6916
|
sourcemapTrace: state.sourcemapTrace,
|
|
6427
6917
|
styleNames: state.styleNames,
|
|
6428
6918
|
styleMetas: state.styleMetas,
|
|
6429
|
-
bindingNodes: state.bindingNodes
|
|
6919
|
+
bindingNodes: state.bindingNodes,
|
|
6920
|
+
runtimeMode: state.runtimeMode
|
|
6430
6921
|
};
|
|
6431
6922
|
}
|
|
6432
6923
|
//#endregion
|
|
@@ -6583,7 +7074,7 @@ function createExtractPlugin(args) {
|
|
|
6583
7074
|
if (!meta) return;
|
|
6584
7075
|
let result;
|
|
6585
7076
|
try {
|
|
6586
|
-
result = compileChain(chain, state.fileId, loc, scope, options, meta, state.styleNames);
|
|
7077
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
6587
7078
|
} catch (error) {
|
|
6588
7079
|
const message = error instanceof Error ? error.message : String(error);
|
|
6589
7080
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -6788,13 +7279,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6788
7279
|
const body = path.node.body;
|
|
6789
7280
|
let firstRuntimeIndex = 0;
|
|
6790
7281
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7282
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6791
7283
|
declarations.forEach((item) => {
|
|
6792
|
-
let insertIndex =
|
|
7284
|
+
let insertIndex = runtimeInsertIndex;
|
|
6793
7285
|
item.dependencies.forEach((name) => {
|
|
6794
7286
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6795
7287
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6796
7288
|
});
|
|
6797
7289
|
body.splice(insertIndex, 0, item.declaration);
|
|
7290
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6798
7291
|
});
|
|
6799
7292
|
}
|
|
6800
7293
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -7648,4 +8141,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
7648
8141
|
}
|
|
7649
8142
|
});
|
|
7650
8143
|
|
|
7651
|
-
//# sourceMappingURL=shared-
|
|
8144
|
+
//# sourceMappingURL=shared-yDD0nfm1.cjs.map
|