@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
|
@@ -124,6 +124,18 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
124
124
|
};
|
|
125
125
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
126
126
|
//#endregion
|
|
127
|
+
//#region config/config/debug.ts
|
|
128
|
+
const DEFAULT_DEBUG_CONFIG = {
|
|
129
|
+
isDebugClassNameEnabled: false,
|
|
130
|
+
isDebugClassNameConfigured: false,
|
|
131
|
+
maxPropertyLength: 24,
|
|
132
|
+
maxValueLength: 8,
|
|
133
|
+
maxSelectorLength: 8,
|
|
134
|
+
maxParentSelectorLength: 8,
|
|
135
|
+
maxAtRuleLength: 10
|
|
136
|
+
};
|
|
137
|
+
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
138
|
+
//#endregion
|
|
127
139
|
//#region config/utils.ts
|
|
128
140
|
const SIDECAR_URL_GLOBAL_SYMBOL = "FLUENTIC_STYLE_SIDECAR_URL";
|
|
129
141
|
function getCacheTTL(cache) {
|
|
@@ -148,6 +160,9 @@ function hashString(str) {
|
|
|
148
160
|
for (let i = 0; i < str.length; i++) hash = Math.imul(hash ^ str.charCodeAt(i), 16777619);
|
|
149
161
|
return (hash >>> 0).toString(36).padEnd(7, "0");
|
|
150
162
|
}
|
|
163
|
+
function normalizeHashLength(length) {
|
|
164
|
+
return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
|
|
165
|
+
}
|
|
151
166
|
//#endregion
|
|
152
167
|
//#region atomic/layer/layer.ts
|
|
153
168
|
function compareLayerPriority(p1, p2) {
|
|
@@ -201,60 +216,18 @@ function getLayerBundleCss(layers, layerName, css) {
|
|
|
201
216
|
output.push(getLayerBlockCss(layerName, "\n" + css.join("\n") + "\n"));
|
|
202
217
|
return output.join("\n");
|
|
203
218
|
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region config/config/debug.ts
|
|
206
|
-
const DEFAULT_DEBUG_CONFIG = {
|
|
207
|
-
isDebugClassNameEnabled: true,
|
|
208
|
-
maxPropertyLength: 24,
|
|
209
|
-
maxValueLength: 8,
|
|
210
|
-
maxSelectorLength: 8,
|
|
211
|
-
maxParentSelectorLength: 8,
|
|
212
|
-
maxAtRuleLength: 10
|
|
213
|
-
};
|
|
214
|
-
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region utils/object.ts
|
|
217
|
-
function toArray(value) {
|
|
218
|
-
return Array.isArray(value) ? value : value ? [value] : [];
|
|
219
|
-
}
|
|
220
|
-
function isFunction(value) {
|
|
221
|
-
return typeof value === "function";
|
|
222
|
-
}
|
|
223
|
-
function isPromiseLike(value) {
|
|
224
|
-
return typeof value === "object" && value !== null && "then" in value;
|
|
225
|
-
}
|
|
226
|
-
//#endregion
|
|
227
|
-
//#region config/config/dev.ts
|
|
228
|
-
const DEV_CONFIG_DEFAULT = {
|
|
229
|
-
isDev: false,
|
|
230
|
-
isCheckSelectorEnabled: true,
|
|
231
|
-
isSourcemapEnabled: true,
|
|
232
|
-
isLocalClassNameEnabled: true,
|
|
233
|
-
sheetMaxRules: 1e3,
|
|
234
|
-
sheetStyleTagNonce: null,
|
|
235
|
-
stylePriorityMode: "layer",
|
|
236
|
-
sourcemapLocationMode: "style",
|
|
237
|
-
isElementClassNameEnabled: true
|
|
238
|
-
};
|
|
239
|
-
globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
240
|
-
const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
241
|
-
globalData("config.dev.plugin", () => ({ config: null }));
|
|
242
|
-
globalData("config.dev.base", () => ({ config: null }));
|
|
243
|
-
globalData("config.dev.utils", () => ({ config: null }));
|
|
244
219
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
245
220
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
221
|
+
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
246
222
|
const STYLE_DEV_RSC_IMPORT_PATH = "@fluentic/style/dev/rsc";
|
|
247
223
|
const STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH = "@fluentic/style/entry/prod/extract";
|
|
248
224
|
const STYLE_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/prod/runtime";
|
|
249
225
|
const STYLE_RSC_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/rsc-prod/runtime";
|
|
250
|
-
const DEFAULT_CONFIG = {
|
|
251
|
-
...CSS_CONFIG_DEFAULT,
|
|
252
|
-
localClassName: DEV_CONFIG_DEFAULT.isLocalClassNameEnabled,
|
|
253
|
-
debugClassName: DEFAULT_DEBUG_CONFIG.isDebugClassNameEnabled
|
|
254
|
-
};
|
|
226
|
+
const DEFAULT_CONFIG = { ...CSS_CONFIG_DEFAULT };
|
|
255
227
|
const IMPORT_PATHS = [
|
|
256
228
|
STYLE_IMPORT_PATH,
|
|
257
229
|
STYLE_CSS_IMPORT_PATH,
|
|
230
|
+
STYLE_DIALECT_IMPORT_PATH,
|
|
258
231
|
STYLE_DEV_RSC_IMPORT_PATH
|
|
259
232
|
];
|
|
260
233
|
const IMPORT_EXTRACT = STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH;
|
|
@@ -297,9 +270,6 @@ function getExtractedCssItems(items, args) {
|
|
|
297
270
|
const layerNamespace = args.layerNamespace ?? defaults.layerNamespace ?? "";
|
|
298
271
|
return getLayerBundleCss(args.layers ?? defaults.layers ?? [], layerNamespace, css.map((item) => item.css));
|
|
299
272
|
}
|
|
300
|
-
function normalizeSelectorArg(arg) {
|
|
301
|
-
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
302
|
-
}
|
|
303
273
|
//#endregion
|
|
304
274
|
//#region builder/data/const.ts
|
|
305
275
|
const BUILDER_TYPE = symbol("builder.type");
|
|
@@ -309,6 +279,36 @@ const BUILDER_SLOT_ID = symbol("builder.slotId");
|
|
|
309
279
|
const BUILDER_SCOPE_ID = symbol("builder.scopeId");
|
|
310
280
|
const BUILDER_SCOPE = symbol("builder.scope");
|
|
311
281
|
//#endregion
|
|
282
|
+
//#region utils/object.ts
|
|
283
|
+
function toArray(value) {
|
|
284
|
+
return Array.isArray(value) ? value : value ? [value] : [];
|
|
285
|
+
}
|
|
286
|
+
function isFunction(value) {
|
|
287
|
+
return typeof value === "function";
|
|
288
|
+
}
|
|
289
|
+
function isPromiseLike(value) {
|
|
290
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region config/config/dev.ts
|
|
294
|
+
const DEV_CONFIG_DEFAULT = {
|
|
295
|
+
isDev: false,
|
|
296
|
+
isCheckSelectorEnabled: true,
|
|
297
|
+
isSourcemapEnabled: true,
|
|
298
|
+
isLocalClassNameEnabled: true,
|
|
299
|
+
sheetMaxRules: 1e3,
|
|
300
|
+
sheetStyleTagNonce: null,
|
|
301
|
+
hashLength: null,
|
|
302
|
+
stylePriorityMode: "sort",
|
|
303
|
+
sourcemapLocationMode: "style",
|
|
304
|
+
isElementClassNameEnabled: true
|
|
305
|
+
};
|
|
306
|
+
globalData("config.dev.isDev", () => ({ isDev: false }));
|
|
307
|
+
const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
|
|
308
|
+
globalData("config.dev.plugin", () => ({ config: null }));
|
|
309
|
+
globalData("config.dev.base", () => ({ config: null }));
|
|
310
|
+
globalData("config.dev.utils", () => ({ config: null }));
|
|
311
|
+
//#endregion
|
|
312
312
|
//#region utils/trace.ts
|
|
313
313
|
const FN_MARKER = "$fn_";
|
|
314
314
|
function traceMarker(fn, name) {
|
|
@@ -475,12 +475,48 @@ function getBuilderType(value) {
|
|
|
475
475
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
476
476
|
return value[BUILDER_TYPE];
|
|
477
477
|
}
|
|
478
|
+
function normalizeSelectorArg(arg) {
|
|
479
|
+
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
480
|
+
}
|
|
478
481
|
//#endregion
|
|
479
482
|
//#region style/token.ts
|
|
480
483
|
const TOKEN_ID = symbol("style:token");
|
|
481
484
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
482
|
-
symbol("style:token.debug");
|
|
483
|
-
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
485
|
+
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
486
|
+
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
487
|
+
function createStyleToken(value, debugId) {
|
|
488
|
+
const token = (value, debug) => {
|
|
489
|
+
return createStyleTokenOverride(token, value, debug);
|
|
490
|
+
};
|
|
491
|
+
token[TOKEN_ID] = debugId || String(idCounter$6.value++);
|
|
492
|
+
if (isStyleTokenData(value)) {
|
|
493
|
+
token.value = value.value;
|
|
494
|
+
token.ref = value;
|
|
495
|
+
} else {
|
|
496
|
+
token.value = value;
|
|
497
|
+
token.ref = null;
|
|
498
|
+
}
|
|
499
|
+
return token;
|
|
500
|
+
}
|
|
501
|
+
function createStyleTokenOverride(token, value, debug) {
|
|
502
|
+
const override = isStyleTokenData(value) ? {
|
|
503
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
504
|
+
[TOKEN_OVERRIDE]: true,
|
|
505
|
+
value: value.value,
|
|
506
|
+
ref: value
|
|
507
|
+
} : {
|
|
508
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
509
|
+
[TOKEN_OVERRIDE]: true,
|
|
510
|
+
value,
|
|
511
|
+
ref: null
|
|
512
|
+
};
|
|
513
|
+
if (debug) Object.defineProperty(override, TOKEN_DEBUG, {
|
|
514
|
+
configurable: true,
|
|
515
|
+
enumerable: false,
|
|
516
|
+
value: debug
|
|
517
|
+
});
|
|
518
|
+
return override;
|
|
519
|
+
}
|
|
484
520
|
function isStyleTokenData(value) {
|
|
485
521
|
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
486
522
|
}
|
|
@@ -803,7 +839,7 @@ function createNameFormatter(keys) {
|
|
|
803
839
|
const name = getFormatFn(format)(info);
|
|
804
840
|
if (!hash) return name;
|
|
805
841
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
806
|
-
return name ? name + "
|
|
842
|
+
return name ? name + "--" + hash : hash;
|
|
807
843
|
};
|
|
808
844
|
}
|
|
809
845
|
function compileFormat(format, keySet) {
|
|
@@ -897,8 +933,12 @@ const formatClassName = createNameFormatter([
|
|
|
897
933
|
"value"
|
|
898
934
|
]);
|
|
899
935
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
936
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
900
937
|
function getDebugClassName(format, hash, info) {
|
|
901
|
-
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
938
|
+
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
939
|
+
}
|
|
940
|
+
function getDebugTransformClassName(format, hash, info) {
|
|
941
|
+
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
902
942
|
}
|
|
903
943
|
function getDebugScopeClassName(format, info) {
|
|
904
944
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -916,20 +956,38 @@ function escapeCssValue(value) {
|
|
|
916
956
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
917
957
|
}
|
|
918
958
|
function escapeCssIdent(ident) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
959
|
+
let result = "";
|
|
960
|
+
for (let i = 0; i < ident.length; i++) {
|
|
961
|
+
const char = ident.charAt(i);
|
|
962
|
+
const code = ident.charCodeAt(i);
|
|
963
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
964
|
+
if (code === 0) {
|
|
965
|
+
result += "�";
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
969
|
+
result += "\\" + code.toString(16) + " ";
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
973
|
+
result += "\\-";
|
|
974
|
+
continue;
|
|
975
|
+
}
|
|
976
|
+
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
977
|
+
result += char + ident.charAt(++i);
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
981
|
+
result += char;
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
result += "\\" + char;
|
|
985
|
+
}
|
|
986
|
+
return result;
|
|
923
987
|
}
|
|
924
988
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
925
989
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
926
990
|
}
|
|
927
|
-
function getIdentifierSafeHash(value) {
|
|
928
|
-
const hash = hashString(value);
|
|
929
|
-
const first = hash.charCodeAt(0);
|
|
930
|
-
if (first < 48 || first > 57) return hash;
|
|
931
|
-
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
932
|
-
}
|
|
933
991
|
//#endregion
|
|
934
992
|
//#region atomic/utils/debug.ts
|
|
935
993
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1087,6 +1145,54 @@ function parseAtRule(rule) {
|
|
|
1087
1145
|
return compressQuery(normalized);
|
|
1088
1146
|
}
|
|
1089
1147
|
//#endregion
|
|
1148
|
+
//#region atomic/utils/hash.ts
|
|
1149
|
+
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1150
|
+
byValue: /* @__PURE__ */ new Map(),
|
|
1151
|
+
byHash: /* @__PURE__ */ new Map(),
|
|
1152
|
+
usedByLength: []
|
|
1153
|
+
}));
|
|
1154
|
+
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1155
|
+
return getPooledHash(value, startLength);
|
|
1156
|
+
}
|
|
1157
|
+
function getPooledHash(value, startLength) {
|
|
1158
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1159
|
+
const valueKey = normalizedStartLength + "\0" + value;
|
|
1160
|
+
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1161
|
+
if (existing) return existing;
|
|
1162
|
+
let length = normalizedStartLength;
|
|
1163
|
+
while (true) {
|
|
1164
|
+
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1165
|
+
length++;
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1169
|
+
const hash = getPooledHashCandidate(value, length, index);
|
|
1170
|
+
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1171
|
+
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1172
|
+
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1173
|
+
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1174
|
+
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1175
|
+
return hash;
|
|
1176
|
+
}
|
|
1177
|
+
length++;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function getPooledHashCandidate(value, length, index) {
|
|
1181
|
+
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1182
|
+
}
|
|
1183
|
+
function getPooledHashUsedCount(length) {
|
|
1184
|
+
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1185
|
+
}
|
|
1186
|
+
function getIdentifierSafeHashPoolSize(length) {
|
|
1187
|
+
if (length <= 0) return 0;
|
|
1188
|
+
return 26 * 36 ** (length - 1);
|
|
1189
|
+
}
|
|
1190
|
+
function getIdentifierSafeHashValue(hash) {
|
|
1191
|
+
const first = hash.charCodeAt(0);
|
|
1192
|
+
if (first < 48 || first > 57) return hash;
|
|
1193
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1090
1196
|
//#region atomic/utils/selector.ts
|
|
1091
1197
|
function getSelectorText(selector) {
|
|
1092
1198
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1100,7 +1206,7 @@ function getSelectorPriority(selector) {
|
|
|
1100
1206
|
}
|
|
1101
1207
|
//#endregion
|
|
1102
1208
|
//#region atomic/className.ts
|
|
1103
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat) {
|
|
1209
|
+
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1104
1210
|
let hash = property;
|
|
1105
1211
|
hash += "\n" + (priority || "");
|
|
1106
1212
|
hash += "\n" + value;
|
|
@@ -1108,8 +1214,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1108
1214
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1109
1215
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1110
1216
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1111
|
-
hash = getIdentifierSafeHash(hash);
|
|
1217
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1112
1218
|
if (!debugClassName) return hash;
|
|
1219
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1113
1220
|
const propertyName = getDebugPropertyName(property, value);
|
|
1114
1221
|
return getDebugClassName(classNameFormat, hash, {
|
|
1115
1222
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1119,6 +1226,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1119
1226
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1120
1227
|
});
|
|
1121
1228
|
}
|
|
1229
|
+
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1230
|
+
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1231
|
+
return CSS_CONFIG.hashLength ?? 7;
|
|
1232
|
+
}
|
|
1122
1233
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1123
1234
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1124
1235
|
}
|
|
@@ -1207,7 +1318,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1207
1318
|
value = value[0];
|
|
1208
1319
|
}
|
|
1209
1320
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1210
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1321
|
+
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);
|
|
1211
1322
|
scopeItem.dedupe = dedupe;
|
|
1212
1323
|
scopeItem.className = className;
|
|
1213
1324
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1245,6 +1356,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1245
1356
|
className: "",
|
|
1246
1357
|
property: overrideItem.property,
|
|
1247
1358
|
value: overrideItem.value,
|
|
1359
|
+
transformClassName: overrideItem.transformClassName,
|
|
1248
1360
|
token: overrideItem.token,
|
|
1249
1361
|
selector: overrideItem.selector,
|
|
1250
1362
|
atRule,
|
|
@@ -1260,7 +1372,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1260
1372
|
value = value[0];
|
|
1261
1373
|
}
|
|
1262
1374
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1263
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1375
|
+
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);
|
|
1264
1376
|
scopeItem.dedupe = dedupe;
|
|
1265
1377
|
scopeItem.className = className;
|
|
1266
1378
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1328,7 +1440,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1328
1440
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1329
1441
|
function getTokenVarName(token, format) {
|
|
1330
1442
|
const id = getStyleTokenId(token);
|
|
1331
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1443
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1332
1444
|
}
|
|
1333
1445
|
function getTokenVar(token, format) {
|
|
1334
1446
|
return getTokenVarFallback(token, format);
|
|
@@ -1403,6 +1515,19 @@ function shouldAppendCssPx(property) {
|
|
|
1403
1515
|
return !UNITLESS.has(property);
|
|
1404
1516
|
}
|
|
1405
1517
|
//#endregion
|
|
1518
|
+
//#region style/transform.ts
|
|
1519
|
+
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1520
|
+
function classNameValue(value, className) {
|
|
1521
|
+
return {
|
|
1522
|
+
[CLASS_NAME_VALUE]: true,
|
|
1523
|
+
value,
|
|
1524
|
+
className
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
function isClassNameValue(value) {
|
|
1528
|
+
return !!value && typeof value === "object" && value[CLASS_NAME_VALUE] === true && typeof value.className === "string";
|
|
1529
|
+
}
|
|
1530
|
+
//#endregion
|
|
1406
1531
|
//#region style/valueRef.ts
|
|
1407
1532
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1408
1533
|
function createAtRuleRef(data) {
|
|
@@ -1432,6 +1557,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1432
1557
|
let token;
|
|
1433
1558
|
let ref;
|
|
1434
1559
|
let variableName;
|
|
1560
|
+
let transformClassName;
|
|
1435
1561
|
let lookupIndex;
|
|
1436
1562
|
if (isStyleData(style)) {
|
|
1437
1563
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1469,6 +1595,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1469
1595
|
priority = valueRaw[0];
|
|
1470
1596
|
valueRaw = valueRaw[1];
|
|
1471
1597
|
}
|
|
1598
|
+
transformClassName = null;
|
|
1599
|
+
if (isClassNameValue(valueRaw)) {
|
|
1600
|
+
transformClassName = valueRaw.className;
|
|
1601
|
+
valueRaw = valueRaw.value;
|
|
1602
|
+
}
|
|
1472
1603
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1473
1604
|
if (ref) valueRaw = ref.value;
|
|
1474
1605
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1484,6 +1615,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1484
1615
|
className: "",
|
|
1485
1616
|
property,
|
|
1486
1617
|
value,
|
|
1618
|
+
transformClassName,
|
|
1487
1619
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1488
1620
|
1,
|
|
1489
1621
|
variableName,
|
|
@@ -1548,7 +1680,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1548
1680
|
value = value[0];
|
|
1549
1681
|
}
|
|
1550
1682
|
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1551
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1683
|
+
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);
|
|
1552
1684
|
runtimeItem.dedupe = dedupe;
|
|
1553
1685
|
runtimeItem.className = className;
|
|
1554
1686
|
lookupIndex = lookup[dedupe];
|
|
@@ -2345,7 +2477,7 @@ function getCssPropertyName(property) {
|
|
|
2345
2477
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2346
2478
|
const formatter = createNameFormatter(["name"]);
|
|
2347
2479
|
return (format, id, info) => {
|
|
2348
|
-
const hash = getIdentifierSafeHash(id);
|
|
2480
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2349
2481
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2350
2482
|
if (!prefix) return name;
|
|
2351
2483
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2556,11 +2688,11 @@ function createStyleFn(args) {
|
|
|
2556
2688
|
style.plain = fnPlain;
|
|
2557
2689
|
style.keyframes = fnKeyframes;
|
|
2558
2690
|
style.merge = fnMerge;
|
|
2559
|
-
|
|
2691
|
+
assignStyleFnMeta(style, {
|
|
2692
|
+
mode: "StyleObject",
|
|
2560
2693
|
selectors,
|
|
2561
2694
|
transform: transform ?? null
|
|
2562
|
-
};
|
|
2563
|
-
Object.assign(style, { [META]: meta });
|
|
2695
|
+
});
|
|
2564
2696
|
return { style };
|
|
2565
2697
|
}
|
|
2566
2698
|
function mergeStyleResult(target, style) {
|
|
@@ -2569,12 +2701,17 @@ function mergeStyleResult(target, style) {
|
|
|
2569
2701
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2570
2702
|
return target;
|
|
2571
2703
|
}
|
|
2704
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2705
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2706
|
+
return styleFn;
|
|
2707
|
+
}
|
|
2572
2708
|
function getStyleFnMeta(styleFn) {
|
|
2573
2709
|
return styleFn[META];
|
|
2574
2710
|
}
|
|
2575
2711
|
//#endregion
|
|
2576
2712
|
//#region compiler/utils/import_source.ts
|
|
2577
2713
|
const DefaultStyleFnMeta = {
|
|
2714
|
+
mode: "StyleObject",
|
|
2578
2715
|
selectors: PrioritySelectors,
|
|
2579
2716
|
transform: null
|
|
2580
2717
|
};
|
|
@@ -2827,6 +2964,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2827
2964
|
}
|
|
2828
2965
|
}
|
|
2829
2966
|
//#endregion
|
|
2967
|
+
//#region style/value.ts
|
|
2968
|
+
function createToken(value, debugId) {
|
|
2969
|
+
return createStyleToken(value, debugId);
|
|
2970
|
+
}
|
|
2971
|
+
//#endregion
|
|
2972
|
+
//#region dialect/namedTokens.ts
|
|
2973
|
+
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
2974
|
+
function createNamedToken(id, value) {
|
|
2975
|
+
return createToken(value, createNamedTokenId(id));
|
|
2976
|
+
}
|
|
2977
|
+
function createNamedTokens(namespace, values) {
|
|
2978
|
+
return createNamedTokenProxy({
|
|
2979
|
+
__fluenticNamedTokens: true,
|
|
2980
|
+
namespace,
|
|
2981
|
+
values,
|
|
2982
|
+
cache: /* @__PURE__ */ new Map()
|
|
2983
|
+
}, []);
|
|
2984
|
+
}
|
|
2985
|
+
function createNamedTokenId(id) {
|
|
2986
|
+
return sanitizeCssIdentName(id.replace(/\./g, "-"), "named-token");
|
|
2987
|
+
}
|
|
2988
|
+
function createNamedTokenProxy(root, path) {
|
|
2989
|
+
return new Proxy(noop, {
|
|
2990
|
+
get(_target, property) {
|
|
2991
|
+
if (property === ROOT) return root;
|
|
2992
|
+
if (property === "then") return void 0;
|
|
2993
|
+
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
2994
|
+
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
2995
|
+
if (!path.length) return void 0;
|
|
2996
|
+
return getNamedTokenAtPath(root, path)[property];
|
|
2997
|
+
}
|
|
2998
|
+
if (typeof property === "symbol") return void 0;
|
|
2999
|
+
return createNamedTokenProxy(root, path.concat(String(property)));
|
|
3000
|
+
},
|
|
3001
|
+
apply(_target, _thisArg, args) {
|
|
3002
|
+
if (!path.length) return void 0;
|
|
3003
|
+
return getNamedTokenAtPath(root, path).apply(void 0, args);
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
function getNamedTokenAtPath(root, path) {
|
|
3008
|
+
const key = path.join(".");
|
|
3009
|
+
const cached = root.cache.get(key);
|
|
3010
|
+
if (cached) return cached;
|
|
3011
|
+
const value = getValueAtPath(root.values, path);
|
|
3012
|
+
const token = createNamedToken(root.namespace + "." + key, value);
|
|
3013
|
+
root.cache.set(key, token);
|
|
3014
|
+
return token;
|
|
3015
|
+
}
|
|
3016
|
+
function getValueAtPath(values, path) {
|
|
3017
|
+
let current = values;
|
|
3018
|
+
for (let i = 0; i < path.length; i++) {
|
|
3019
|
+
if (!current || typeof current !== "object") return void 0;
|
|
3020
|
+
current = current[path[i]];
|
|
3021
|
+
}
|
|
3022
|
+
return current;
|
|
3023
|
+
}
|
|
3024
|
+
function noop() {}
|
|
3025
|
+
//#endregion
|
|
2830
3026
|
//#region style/utils/expose.ts
|
|
2831
3027
|
function exposeStyle(styles) {
|
|
2832
3028
|
return exposeStyleObject(styles);
|
|
@@ -2882,6 +3078,7 @@ function evaluateNode(node, scope) {
|
|
|
2882
3078
|
case "ParenthesizedExpression":
|
|
2883
3079
|
case "TSAsExpression":
|
|
2884
3080
|
case "TSNonNullExpression":
|
|
3081
|
+
case "TSSatisfiesExpression":
|
|
2885
3082
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
2886
3083
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
2887
3084
|
}
|
|
@@ -2954,14 +3151,14 @@ function evaluateMember(node, scope) {
|
|
|
2954
3151
|
if (!key.ok) return key;
|
|
2955
3152
|
const obj = evaluateNode(node.object, scope);
|
|
2956
3153
|
if (!obj.ok) return obj;
|
|
2957
|
-
if (obj.value && typeof obj.value === "object") return evalOk(obj.value[key.value]);
|
|
3154
|
+
if (obj.value && (typeof obj.value === "object" || typeof obj.value === "function")) return evalOk(obj.value[key.value]);
|
|
2958
3155
|
return evalFail("Cannot index non-object");
|
|
2959
3156
|
}
|
|
2960
3157
|
const prop = node.property.name;
|
|
2961
3158
|
const obj = evaluateNode(node.object, scope);
|
|
2962
3159
|
if (!obj.ok) return obj;
|
|
2963
3160
|
if (obj.value == null) return evalFail(`Cannot access .${prop} on null/undefined`);
|
|
2964
|
-
if (typeof obj.value !== "object" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3161
|
+
if (typeof obj.value !== "object" && typeof obj.value !== "function" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
2965
3162
|
return evalOk(obj.value[prop]);
|
|
2966
3163
|
}
|
|
2967
3164
|
function evaluateObject(node, scope) {
|
|
@@ -3000,7 +3197,7 @@ function evaluateObject(node, scope) {
|
|
|
3000
3197
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
3001
3198
|
const val = evaluateNode(prop.value, scope);
|
|
3002
3199
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3003
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3200
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3004
3201
|
if (prop.loc?.start) locations[key] = {
|
|
3005
3202
|
line: prop.loc.start.line,
|
|
3006
3203
|
column: prop.loc.start.column + 1,
|
|
@@ -3165,6 +3362,23 @@ function evaluateCall(node, scope) {
|
|
|
3165
3362
|
if (!debugId.ok) return debugId;
|
|
3166
3363
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3167
3364
|
}
|
|
3365
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3366
|
+
const id = evaluateNode(node.arguments[0], scope);
|
|
3367
|
+
if (!id.ok) return id;
|
|
3368
|
+
if (typeof id.value !== "string") return evalFail("createNamedToken id must be a static string");
|
|
3369
|
+
const value = evaluateNode(node.arguments[1], scope);
|
|
3370
|
+
if (!value.ok) return value;
|
|
3371
|
+
return evalOk(createNamedToken(id.value, value.value));
|
|
3372
|
+
}
|
|
3373
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedTokens") {
|
|
3374
|
+
const namespace = evaluateNode(node.arguments[0], scope);
|
|
3375
|
+
if (!namespace.ok) return namespace;
|
|
3376
|
+
if (typeof namespace.value !== "string") return evalFail("createNamedTokens namespace must be a static string");
|
|
3377
|
+
const values = evaluateNode(node.arguments[1], scope);
|
|
3378
|
+
if (!values.ok) return values;
|
|
3379
|
+
if (!values.value || typeof values.value !== "object") return evalFail("createNamedTokens values must be a static object");
|
|
3380
|
+
return evalOk(createNamedTokens(namespace.value, values.value));
|
|
3381
|
+
}
|
|
3168
3382
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3169
3383
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3170
3384
|
if (!styles.ok) return styles;
|
|
@@ -3377,7 +3591,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3377
3591
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3378
3592
|
});
|
|
3379
3593
|
}
|
|
3380
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3594
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3381
3595
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3382
3596
|
}
|
|
3383
3597
|
function evaluateBinary(node, scope) {
|
|
@@ -3433,7 +3647,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3433
3647
|
}
|
|
3434
3648
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3435
3649
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3436
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3650
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3437
3651
|
}
|
|
3438
3652
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3439
3653
|
const declarations = [];
|
|
@@ -3758,12 +3972,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3758
3972
|
}
|
|
3759
3973
|
const formatVarName = createNameFormatter(["name"]);
|
|
3760
3974
|
function getLocalVarName(filePath, line, column, format) {
|
|
3761
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
3975
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3762
3976
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3763
3977
|
}
|
|
3764
3978
|
//#endregion
|
|
3765
3979
|
//#region compiler/transform/debug/utils/debug_data.ts
|
|
3766
|
-
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride) {
|
|
3980
|
+
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride, classNameArg = false) {
|
|
3767
3981
|
const loc = locOverride ?? node.loc?.start;
|
|
3768
3982
|
const line = loc?.line ?? 1;
|
|
3769
3983
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3780,10 +3994,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3780
3994
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3781
3995
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3782
3996
|
];
|
|
3997
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3783
3998
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3784
3999
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3785
4000
|
return t.objectExpression(properties);
|
|
3786
4001
|
}
|
|
4002
|
+
function buildClassNames(t, args) {
|
|
4003
|
+
const classNames = /* @__PURE__ */ new Map();
|
|
4004
|
+
for (const arg of args) collectClassNameLoc(arg, classNames);
|
|
4005
|
+
const fields = [];
|
|
4006
|
+
for (const [className, loc] of classNames) fields.push(t.objectProperty(t.stringLiteral(className), buildLoc(t, loc.line, loc.column + 1)));
|
|
4007
|
+
return t.objectExpression(fields);
|
|
4008
|
+
}
|
|
4009
|
+
function collectClassNameLoc(arg, classNames) {
|
|
4010
|
+
if (!arg) return;
|
|
4011
|
+
if (arg.type === "StringLiteral") {
|
|
4012
|
+
const loc = arg.loc?.start;
|
|
4013
|
+
if (loc) classNames.set(arg.value, loc);
|
|
4014
|
+
return;
|
|
4015
|
+
}
|
|
4016
|
+
if (arg.type === "TemplateLiteral" && arg.expressions.length === 0) {
|
|
4017
|
+
const loc = arg.loc?.start;
|
|
4018
|
+
if (loc) classNames.set(arg.quasis[0]?.value.cooked ?? arg.quasis[0]?.value.raw ?? "", loc);
|
|
4019
|
+
return;
|
|
4020
|
+
}
|
|
4021
|
+
if (arg.type === "ArrayExpression") {
|
|
4022
|
+
for (const item of arg.elements) collectClassNameLoc(item, classNames);
|
|
4023
|
+
return;
|
|
4024
|
+
}
|
|
4025
|
+
if (arg.type === "ConditionalExpression") {
|
|
4026
|
+
collectClassNameLoc(arg.consequent, classNames);
|
|
4027
|
+
collectClassNameLoc(arg.alternate, classNames);
|
|
4028
|
+
return;
|
|
4029
|
+
}
|
|
4030
|
+
if (arg.type === "LogicalExpression") {
|
|
4031
|
+
collectClassNameLoc(arg.left, classNames);
|
|
4032
|
+
collectClassNameLoc(arg.right, classNames);
|
|
4033
|
+
return;
|
|
4034
|
+
}
|
|
4035
|
+
if (arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && arg.callee.property.type === "Identifier" && arg.callee.property.name === "weight") collectClassNameLoc(arg.arguments[0], classNames);
|
|
4036
|
+
}
|
|
3787
4037
|
function getShortLabel(label) {
|
|
3788
4038
|
const parts = label.split(".");
|
|
3789
4039
|
return parts[parts.length - 1] || label;
|
|
@@ -3942,7 +4192,9 @@ function createDebugPlugin(args) {
|
|
|
3942
4192
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
3943
4193
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
3944
4194
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
3945
|
-
|
|
4195
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4196
|
+
const isClassNameCall = rootName ? state.styleMetas.get(rootName)?.mode === "ClassName" : false;
|
|
4197
|
+
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));
|
|
3946
4198
|
},
|
|
3947
4199
|
JSXOpeningElement(path, state) {
|
|
3948
4200
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4533,6 +4785,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4533
4785
|
//#region compiler/utils/file_resolver.ts
|
|
4534
4786
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4535
4787
|
const resolver = new ResolverFactory({
|
|
4788
|
+
conditionNames: [
|
|
4789
|
+
"import",
|
|
4790
|
+
"module",
|
|
4791
|
+
"default",
|
|
4792
|
+
"types"
|
|
4793
|
+
],
|
|
4536
4794
|
extensions: [
|
|
4537
4795
|
".ts",
|
|
4538
4796
|
".tsx",
|
|
@@ -4692,15 +4950,112 @@ function extractStyleChain(node, styleNames) {
|
|
|
4692
4950
|
}
|
|
4693
4951
|
//#endregion
|
|
4694
4952
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4695
|
-
function applyTransform(styleObj, transform) {
|
|
4696
|
-
|
|
4953
|
+
function applyTransform(styleObj, transform, cssConfig) {
|
|
4954
|
+
if (!transform) return styleObj;
|
|
4955
|
+
const input = transformRuntimeValues(styleObj, transform, cssConfig);
|
|
4956
|
+
return carryTransformedLocations(input, transform.transform(input), transform);
|
|
4957
|
+
}
|
|
4958
|
+
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
4959
|
+
let result = null;
|
|
4960
|
+
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
4961
|
+
const runtimeValue = getCompiledRuntimeValue(getPriorityTupleValue(rawValue));
|
|
4962
|
+
if (!runtimeValue) continue;
|
|
4963
|
+
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
4964
|
+
if (transformedRuntimeValue === runtimeValue) continue;
|
|
4965
|
+
result ??= cloneCompiledStyleObject(styleObj);
|
|
4966
|
+
result[property] = Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number" ? [rawValue[0], createCompiledRuntimeValue(transformedRuntimeValue)] : createCompiledRuntimeValue(transformedRuntimeValue);
|
|
4967
|
+
}
|
|
4968
|
+
return result ?? styleObj;
|
|
4969
|
+
}
|
|
4970
|
+
function getPriorityTupleValue(value) {
|
|
4971
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
4972
|
+
}
|
|
4973
|
+
function cloneCompiledStyleObject(styleObj) {
|
|
4974
|
+
const cloned = { ...styleObj };
|
|
4975
|
+
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
4976
|
+
if (locations) Object.defineProperty(cloned, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
4977
|
+
configurable: true,
|
|
4978
|
+
enumerable: false,
|
|
4979
|
+
value: locations
|
|
4980
|
+
});
|
|
4981
|
+
return cloned;
|
|
4982
|
+
}
|
|
4983
|
+
function createCompiledRuntimeValue(runtimeValue) {
|
|
4984
|
+
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
4985
|
+
}
|
|
4986
|
+
function transformRuntimeExpression(property, expression, transform, cssConfig) {
|
|
4987
|
+
if (expression.type === "StringLiteral") return createPrimitiveExpression(expression, normalizeRuntimeTransformedValue(getSingleTransformedValue(transform.transform({ [property]: expression.value })), cssConfig)) ?? expression;
|
|
4988
|
+
if (expression.type === "ConditionalExpression") {
|
|
4989
|
+
const consequent = transformRuntimeExpression(property, expression.consequent, transform, cssConfig);
|
|
4990
|
+
const alternate = transformRuntimeExpression(property, expression.alternate, transform, cssConfig);
|
|
4991
|
+
return consequent === expression.consequent && alternate === expression.alternate ? expression : {
|
|
4992
|
+
...expression,
|
|
4993
|
+
consequent,
|
|
4994
|
+
alternate
|
|
4995
|
+
};
|
|
4996
|
+
}
|
|
4997
|
+
return expression;
|
|
4998
|
+
}
|
|
4999
|
+
function getSingleTransformedValue(transformed) {
|
|
5000
|
+
const values = Object.values(transformed);
|
|
5001
|
+
if (!values.length) return void 0;
|
|
5002
|
+
return values[0];
|
|
5003
|
+
}
|
|
5004
|
+
function normalizeRuntimeTransformedValue(value, cssConfig) {
|
|
5005
|
+
if (isStyleTokenOverrideData(value)) return getTokenOverrideValue(value, cssConfig.tokenNameFormat);
|
|
5006
|
+
if (isStyleTokenData(value)) return getTokenVar(value, cssConfig.tokenNameFormat);
|
|
5007
|
+
return value;
|
|
5008
|
+
}
|
|
5009
|
+
function createPrimitiveExpression(original, value) {
|
|
5010
|
+
if (original.type === "StringLiteral" && value === original.value) return null;
|
|
5011
|
+
if (typeof value === "string") return {
|
|
5012
|
+
...original,
|
|
5013
|
+
type: "StringLiteral",
|
|
5014
|
+
value
|
|
5015
|
+
};
|
|
5016
|
+
if (typeof value === "number") return {
|
|
5017
|
+
...original,
|
|
5018
|
+
type: "NumericLiteral",
|
|
5019
|
+
value
|
|
5020
|
+
};
|
|
5021
|
+
if (typeof value === "boolean") return {
|
|
5022
|
+
...original,
|
|
5023
|
+
type: "BooleanLiteral",
|
|
5024
|
+
value
|
|
5025
|
+
};
|
|
5026
|
+
if (value === null) return {
|
|
5027
|
+
...original,
|
|
5028
|
+
type: "NullLiteral"
|
|
5029
|
+
};
|
|
5030
|
+
return null;
|
|
5031
|
+
}
|
|
5032
|
+
function carryTransformedLocations(input, transformed, transform) {
|
|
5033
|
+
const inputLocations = input[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5034
|
+
if (!inputLocations) return transformed;
|
|
5035
|
+
const locations = { ...transformed[COMPILED_STYLE_OBJECT_LOCATIONS] };
|
|
5036
|
+
for (const [property, loc] of Object.entries(inputLocations)) {
|
|
5037
|
+
if (property in transformed && !locations[property]) locations[property] = loc;
|
|
5038
|
+
const single = transform.transform({ [property]: input[property] });
|
|
5039
|
+
for (const transformedProperty of Object.keys(single)) locations[transformedProperty] ??= loc;
|
|
5040
|
+
}
|
|
5041
|
+
if (!Object.keys(locations).length) return transformed;
|
|
5042
|
+
Object.defineProperty(transformed, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5043
|
+
configurable: true,
|
|
5044
|
+
enumerable: false,
|
|
5045
|
+
value: locations
|
|
5046
|
+
});
|
|
5047
|
+
return transformed;
|
|
4697
5048
|
}
|
|
4698
5049
|
/**
|
|
4699
5050
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
4700
5051
|
* Returns null if any argument cannot be statically evaluated.
|
|
4701
5052
|
*/
|
|
4702
|
-
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4703
|
-
const css = getCssConfig(opts);
|
|
5053
|
+
function compileChain(chain, fileId, nodeLoc, scope, opts, runtimeMode, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
5054
|
+
const css = getCssConfig(opts, runtimeMode);
|
|
5055
|
+
if (meta.mode === "ClassName") {
|
|
5056
|
+
if (chain.kind !== "style") return null;
|
|
5057
|
+
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5058
|
+
}
|
|
4704
5059
|
const selectors = meta.selectors;
|
|
4705
5060
|
const transform = meta.transform;
|
|
4706
5061
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4708,13 +5063,16 @@ function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /*
|
|
|
4708
5063
|
if (chain.kind === "scope") return compileScopeChain(chain, selectors, fileId, scope, css, transform, opts);
|
|
4709
5064
|
return null;
|
|
4710
5065
|
}
|
|
4711
|
-
function getCssConfig(opts) {
|
|
5066
|
+
function getCssConfig(opts, runtimeMode) {
|
|
4712
5067
|
const css = opts.css;
|
|
5068
|
+
const isDevRuntimeMode = runtimeMode === "dev" || runtimeMode === "rsc-dev";
|
|
4713
5069
|
return {
|
|
4714
5070
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5071
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5072
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4715
5073
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4716
|
-
localClassName:
|
|
4717
|
-
debugClassName: css?.debugClassName ??
|
|
5074
|
+
localClassName: isDevRuntimeMode,
|
|
5075
|
+
debugClassName: css?.debugClassName ?? isDevRuntimeMode,
|
|
4718
5076
|
scopeTargetPrefix: css?.scopeTargetPrefix ?? ""
|
|
4719
5077
|
};
|
|
4720
5078
|
}
|
|
@@ -4732,6 +5090,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4732
5090
|
rules
|
|
4733
5091
|
};
|
|
4734
5092
|
}
|
|
5093
|
+
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
5094
|
+
const items = [];
|
|
5095
|
+
const rules = [];
|
|
5096
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
5097
|
+
let i = 0;
|
|
5098
|
+
while (i < chain.methods.length) {
|
|
5099
|
+
const method = chain.methods[i];
|
|
5100
|
+
if (!compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options)) return null;
|
|
5101
|
+
i++;
|
|
5102
|
+
}
|
|
5103
|
+
return {
|
|
5104
|
+
type: "style",
|
|
5105
|
+
items,
|
|
5106
|
+
rules
|
|
5107
|
+
};
|
|
5108
|
+
}
|
|
5109
|
+
function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options) {
|
|
5110
|
+
const selector = selectors[method.name];
|
|
5111
|
+
if (!selector) return false;
|
|
5112
|
+
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5113
|
+
const selectorStr = selector.selector.trim();
|
|
5114
|
+
if (selectorStr === "...") {
|
|
5115
|
+
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5116
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5117
|
+
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5118
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5119
|
+
if (!result) return false;
|
|
5120
|
+
items.push(...result.items);
|
|
5121
|
+
rules.push(...result.rules);
|
|
5122
|
+
return true;
|
|
5123
|
+
}
|
|
5124
|
+
return false;
|
|
5125
|
+
}
|
|
5126
|
+
if (selectorStr.startsWith("@")) {
|
|
5127
|
+
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5128
|
+
const hasArg = selectorStr.includes("$$");
|
|
5129
|
+
const priority = getAtRulePriority(selector.priority, isMedia, method.args[0]);
|
|
5130
|
+
let argOffset = 0;
|
|
5131
|
+
if (isMedia && isNumericLiteral(method.args[0])) argOffset = 1;
|
|
5132
|
+
let atRule = selectorStr;
|
|
5133
|
+
if (hasArg) {
|
|
5134
|
+
const queryArg = evaluateNode(method.args[argOffset], scope);
|
|
5135
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, queryArg, method.args[argOffset]);
|
|
5136
|
+
throwIfRequiredStaticSelectorValue(options, `style.${method.name}`, queryArg);
|
|
5137
|
+
if (!queryArg.ok) return false;
|
|
5138
|
+
const [before, after] = selectorStr.split("$$");
|
|
5139
|
+
atRule = before + String(queryArg.value) + (after ?? "");
|
|
5140
|
+
}
|
|
5141
|
+
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5142
|
+
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5143
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5144
|
+
}
|
|
5145
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5146
|
+
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
5147
|
+
const [before, after] = selectorStr.split(splitToken);
|
|
5148
|
+
const selectorArg = evaluateNode(method.args[0], scope);
|
|
5149
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, selectorArg, method.args[0]);
|
|
5150
|
+
if (!selectorArg.ok) return false;
|
|
5151
|
+
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5152
|
+
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5153
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5154
|
+
}
|
|
5155
|
+
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5156
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5157
|
+
}
|
|
5158
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
5159
|
+
if (startIndex >= args.length) return true;
|
|
5160
|
+
const styleObj = {};
|
|
5161
|
+
let i = startIndex;
|
|
5162
|
+
while (i < args.length) {
|
|
5163
|
+
const arg = evaluateNode(args[i], scope);
|
|
5164
|
+
if (!arg.ok) {
|
|
5165
|
+
throwIfRequiredStaticStyleValue(arg);
|
|
5166
|
+
return false;
|
|
5167
|
+
}
|
|
5168
|
+
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
5169
|
+
i++;
|
|
5170
|
+
}
|
|
5171
|
+
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5172
|
+
}
|
|
5173
|
+
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
5174
|
+
if (!value) return true;
|
|
5175
|
+
if (typeof value === "string") {
|
|
5176
|
+
Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
|
|
5177
|
+
return true;
|
|
5178
|
+
}
|
|
5179
|
+
if (Array.isArray(value)) {
|
|
5180
|
+
for (const item of value) if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
|
|
5181
|
+
return true;
|
|
5182
|
+
}
|
|
5183
|
+
if (isWeightedClassName(value)) {
|
|
5184
|
+
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5185
|
+
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
5186
|
+
return true;
|
|
5187
|
+
}
|
|
5188
|
+
return false;
|
|
5189
|
+
}
|
|
5190
|
+
function decorateClassNameStyle(style, className) {
|
|
5191
|
+
const result = {};
|
|
5192
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5193
|
+
if (value === null || value === void 0) {
|
|
5194
|
+
result[property] = value;
|
|
5195
|
+
continue;
|
|
5196
|
+
}
|
|
5197
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "number") {
|
|
5198
|
+
const rawValue = value[1];
|
|
5199
|
+
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5200
|
+
continue;
|
|
5201
|
+
}
|
|
5202
|
+
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
5203
|
+
}
|
|
5204
|
+
return result;
|
|
5205
|
+
}
|
|
5206
|
+
function isWeightedClassName(value) {
|
|
5207
|
+
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5208
|
+
}
|
|
5209
|
+
function applyClassNameWeight(style, weight) {
|
|
5210
|
+
const weighted = {};
|
|
5211
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5212
|
+
if (value === null || value === void 0) {
|
|
5213
|
+
weighted[property] = value;
|
|
5214
|
+
continue;
|
|
5215
|
+
}
|
|
5216
|
+
weighted[property] = [weight, Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value];
|
|
5217
|
+
}
|
|
5218
|
+
return weighted;
|
|
5219
|
+
}
|
|
4735
5220
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4736
5221
|
if (chain.baseArgs.length > 0) {
|
|
4737
5222
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4739,7 +5224,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4739
5224
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4740
5225
|
return false;
|
|
4741
5226
|
}
|
|
4742
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5227
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
4743
5228
|
}
|
|
4744
5229
|
let i = 0;
|
|
4745
5230
|
while (i < chain.methods.length) {
|
|
@@ -4758,7 +5243,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4758
5243
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4759
5244
|
return null;
|
|
4760
5245
|
}
|
|
4761
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
5246
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
4762
5247
|
}
|
|
4763
5248
|
let i = 0;
|
|
4764
5249
|
while (i < chain.methods.length) {
|
|
@@ -4876,14 +5361,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4876
5361
|
return true;
|
|
4877
5362
|
}
|
|
4878
5363
|
if (node.type !== "CallExpression") return false;
|
|
4879
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5364
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
4880
5365
|
if (!overrideChain) return false;
|
|
4881
5366
|
const { slotId, items: overrideItems } = overrideChain;
|
|
4882
5367
|
let i = 0;
|
|
4883
5368
|
while (i < overrideItems.length) {
|
|
4884
5369
|
const overrideItem = overrideItems[i];
|
|
4885
5370
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
4886
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5371
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
4887
5372
|
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;
|
|
4888
5373
|
} else if (overrideItem.styleData !== void 0) {
|
|
4889
5374
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -4892,15 +5377,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4892
5377
|
}
|
|
4893
5378
|
return true;
|
|
4894
5379
|
}
|
|
4895
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5380
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
4896
5381
|
const callee = node.callee;
|
|
4897
5382
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
4898
5383
|
const methodName = callee.property.name;
|
|
4899
5384
|
const obj = callee.object;
|
|
4900
5385
|
if (obj.type === "CallExpression") {
|
|
4901
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5386
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
4902
5387
|
if (!inner) return null;
|
|
4903
|
-
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, transform, options);
|
|
5388
|
+
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, cssConfig, transform, options);
|
|
4904
5389
|
if (!overrideItem) return null;
|
|
4905
5390
|
return {
|
|
4906
5391
|
slotId: inner.slotId,
|
|
@@ -4915,7 +5400,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4915
5400
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
4916
5401
|
if (!styleArg.ok) return null;
|
|
4917
5402
|
items.push({
|
|
4918
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5403
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4919
5404
|
selector: null,
|
|
4920
5405
|
atRules: null
|
|
4921
5406
|
});
|
|
@@ -4925,7 +5410,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4925
5410
|
items
|
|
4926
5411
|
};
|
|
4927
5412
|
}
|
|
4928
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5413
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
4929
5414
|
const sel = selectors[methodName];
|
|
4930
5415
|
if (!sel) return null;
|
|
4931
5416
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -4952,7 +5437,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4952
5437
|
callsiteOverride
|
|
4953
5438
|
};
|
|
4954
5439
|
return {
|
|
4955
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5440
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4956
5441
|
selector: null,
|
|
4957
5442
|
atRules: null,
|
|
4958
5443
|
callsiteOverride
|
|
@@ -4977,7 +5462,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4977
5462
|
if (!styleArg.ok) return null;
|
|
4978
5463
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
4979
5464
|
return {
|
|
4980
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5465
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4981
5466
|
selector: null,
|
|
4982
5467
|
atRules: [atRuleSelector]
|
|
4983
5468
|
};
|
|
@@ -4993,7 +5478,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4993
5478
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
4994
5479
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
4995
5480
|
return {
|
|
4996
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5481
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4997
5482
|
selector: itemSelector,
|
|
4998
5483
|
atRules: null
|
|
4999
5484
|
};
|
|
@@ -5001,7 +5486,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5001
5486
|
const styleArg = evaluateNode(args[0], scope);
|
|
5002
5487
|
if (!styleArg.ok) return null;
|
|
5003
5488
|
return {
|
|
5004
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5489
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5005
5490
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5006
5491
|
atRules: null
|
|
5007
5492
|
};
|
|
@@ -5085,7 +5570,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5085
5570
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5086
5571
|
return false;
|
|
5087
5572
|
}
|
|
5088
|
-
return addStyleItems(applyTransform(styleArg.value, transform), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5573
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5089
5574
|
}
|
|
5090
5575
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5091
5576
|
if (!styleArgNode) return false;
|
|
@@ -5166,14 +5651,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5166
5651
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5167
5652
|
return false;
|
|
5168
5653
|
}
|
|
5169
|
-
return addStyleItems(applyTransform(evaled.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5654
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5170
5655
|
}
|
|
5171
5656
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5172
5657
|
if (!styleResult.ok) {
|
|
5173
5658
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5174
5659
|
return false;
|
|
5175
5660
|
}
|
|
5176
|
-
return addStyleItems(applyTransform(styleResult.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5661
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5177
5662
|
}
|
|
5178
5663
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5179
5664
|
const selectorStr = selector.selector.trim();
|
|
@@ -5192,7 +5677,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5192
5677
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5193
5678
|
if (!styleResult.ok) return false;
|
|
5194
5679
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5195
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5680
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5196
5681
|
let i = 0;
|
|
5197
5682
|
while (i < selectorValues.length) {
|
|
5198
5683
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5320,7 +5805,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5320
5805
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5321
5806
|
const valueStr = String(value ?? "");
|
|
5322
5807
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
5323
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5808
|
+
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);
|
|
5324
5809
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5325
5810
|
items.push(item);
|
|
5326
5811
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5401,7 +5886,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5401
5886
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5402
5887
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5403
5888
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5404
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5889
|
+
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5405
5890
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5406
5891
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5407
5892
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5469,10 +5954,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5469
5954
|
const rawValue = styleObj[property];
|
|
5470
5955
|
let priority = null;
|
|
5471
5956
|
let value = rawValue;
|
|
5957
|
+
let transformClassName = null;
|
|
5472
5958
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5473
5959
|
priority = rawValue[0];
|
|
5474
5960
|
value = rawValue[1];
|
|
5475
5961
|
}
|
|
5962
|
+
if (isClassNameValue(value)) {
|
|
5963
|
+
transformClassName = value.className;
|
|
5964
|
+
value = value.value;
|
|
5965
|
+
}
|
|
5476
5966
|
if (value === null || value === void 0) {
|
|
5477
5967
|
i++;
|
|
5478
5968
|
continue;
|
|
@@ -5492,7 +5982,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5492
5982
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5493
5983
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5494
5984
|
const dedupe = getClassNameDedupe(property, priority, selector, parentSelector, atRules);
|
|
5495
|
-
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5985
|
+
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5496
5986
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5497
5987
|
item.sourceTrace = propertyCallsite ? {
|
|
5498
5988
|
property,
|
|
@@ -5777,7 +6267,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
|
|
|
5777
6267
|
if (chain?.kind === "style" || chain?.kind === "scope") try {
|
|
5778
6268
|
const meta = scope.styleMetas?.get(chain.rootName);
|
|
5779
6269
|
if (!meta) return evalFail("Cannot resolve imported style function");
|
|
5780
|
-
const result = compileChain(chain, fileId, node.loc?.start, scope, options, meta, styleNames);
|
|
6270
|
+
const result = compileChain(chain, fileId, node.loc?.start, scope, options, scope.runtimeMode ?? null, meta, styleNames);
|
|
5781
6271
|
if (!result) return evalFail("Cannot compile imported style chain");
|
|
5782
6272
|
const extracted = createExtractedChainValue(result, options.dev?.sourcemapMode === "value" ? result : compileChain(chain, fileId, node.loc?.start, scope, {
|
|
5783
6273
|
...options,
|
|
@@ -5785,7 +6275,7 @@ function evaluateResolvedNode(node, scope, styleNames, fileId, options) {
|
|
|
5785
6275
|
...options.dev,
|
|
5786
6276
|
sourcemapMode: "value"
|
|
5787
6277
|
}
|
|
5788
|
-
}, meta, styleNames) ?? result);
|
|
6278
|
+
}, scope.runtimeMode ?? null, meta, styleNames) ?? result);
|
|
5789
6279
|
if (!extracted) return evalFail("Cannot extract imported style chain");
|
|
5790
6280
|
return evalOk(extracted);
|
|
5791
6281
|
} catch (error) {
|
|
@@ -6304,7 +6794,8 @@ function getEvalScope(state) {
|
|
|
6304
6794
|
sourcemapTrace: state.sourcemapTrace,
|
|
6305
6795
|
styleNames: state.styleNames,
|
|
6306
6796
|
styleMetas: state.styleMetas,
|
|
6307
|
-
bindingNodes: state.bindingNodes
|
|
6797
|
+
bindingNodes: state.bindingNodes,
|
|
6798
|
+
runtimeMode: state.runtimeMode
|
|
6308
6799
|
};
|
|
6309
6800
|
}
|
|
6310
6801
|
//#endregion
|
|
@@ -6461,7 +6952,7 @@ function createExtractPlugin(args) {
|
|
|
6461
6952
|
if (!meta) return;
|
|
6462
6953
|
let result;
|
|
6463
6954
|
try {
|
|
6464
|
-
result = compileChain(chain, state.fileId, loc, scope, options, meta, state.styleNames);
|
|
6955
|
+
result = compileChain(chain, state.fileId, loc, scope, options, state.runtimeMode, meta, state.styleNames);
|
|
6465
6956
|
} catch (error) {
|
|
6466
6957
|
const message = error instanceof Error ? error.message : String(error);
|
|
6467
6958
|
throw buildCodeFrameError(path, getSelectorCompileErrorNode(error) ?? path.node, message);
|
|
@@ -6666,13 +7157,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6666
7157
|
const body = path.node.body;
|
|
6667
7158
|
let firstRuntimeIndex = 0;
|
|
6668
7159
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7160
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6669
7161
|
declarations.forEach((item) => {
|
|
6670
|
-
let insertIndex =
|
|
7162
|
+
let insertIndex = runtimeInsertIndex;
|
|
6671
7163
|
item.dependencies.forEach((name) => {
|
|
6672
7164
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6673
7165
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6674
7166
|
});
|
|
6675
7167
|
body.splice(insertIndex, 0, item.declaration);
|
|
7168
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6676
7169
|
});
|
|
6677
7170
|
}
|
|
6678
7171
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -6847,6 +7340,6 @@ function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
|
6847
7340
|
return null;
|
|
6848
7341
|
}
|
|
6849
7342
|
//#endregion
|
|
6850
|
-
export { normalizeSourcemapSourcePath as a, babelTransform as c, compareLayerPriority as d, SIDECAR_URL_GLOBAL_SYMBOL as f, getDefaultSourcemapUrl as i,
|
|
7343
|
+
export { normalizeSourcemapSourcePath as a, babelTransform as c, compareLayerPriority as d, SIDECAR_URL_GLOBAL_SYMBOL as f, getDefaultSourcemapUrl as i, isPromiseLike as l, createCompilerCache as m, createCompiler as n, normalizePath as o, globalData as p, getStyleRuntimeImportPath as r, babelPlugin as s, CompilerRuntimeMode as t, extractCss as u };
|
|
6851
7344
|
|
|
6852
|
-
//# sourceMappingURL=compiler-
|
|
7345
|
+
//# sourceMappingURL=compiler-D5v5tJXI.mjs.map
|