@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +25 -4
- package/atomic/debug/className/className.ts +23 -2
- package/atomic/element.ts +5 -2
- package/atomic/theme.ts +4 -2
- package/atomic/token.ts +4 -2
- package/atomic/utils/css.ts +44 -19
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +78 -0
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +447 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +34 -0
- package/builder/data/create.ts +6 -6
- package/builder/data/data.ts +7 -7
- package/builder/data/debug.ts +1 -0
- package/builder/data/is.ts +3 -3
- package/builder/data/merge/scope.ts +18 -19
- package/builder/data/merge/style.ts +11 -0
- package/builder/data/state.ts +1 -0
- package/builder/style_builder.ts +17 -17
- package/builder/style_fns.ts +33 -33
- package/builder/types/alias.ts +10 -10
- package/builder/types/fns.ts +11 -11
- package/builder/types/types.ts +5 -5
- package/compiler/transform/debug/plugin.ts +8 -3
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +31 -2
- package/compiler/transform/evaluator/tracer.ts +2 -8
- package/compiler/transform/extract/chain/chain.ts +589 -24
- package/compiler/transform/extract/plugin.ts +4 -1
- package/compiler/utils/constants.ts +4 -0
- package/compiler/utils/file_resolver.ts +1 -0
- package/compiler/utils/import_source.ts +3 -2
- package/config/config/css.ts +3 -0
- package/config/config/dev.ts +9 -1
- package/config/types.ts +7 -0
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +136 -0
- package/dist/{className-DC2Cq8p3.js → className-Cuh2JNxO.js} +19 -7
- package/dist/className-Cuh2JNxO.js.map +1 -0
- package/dist/{className-C1Ht5Wvv.js → className-W2kDyeVl.js} +2 -2
- package/dist/{className-C1Ht5Wvv.js.map → className-W2kDyeVl.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-DENc3a2R.mjs → compiler-BXcGyZUP.mjs} +554 -60
- package/dist/compiler-BXcGyZUP.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-C1k9vUrM.js +32 -0
- package/dist/config-C1k9vUrM.js.map +1 -0
- package/dist/{config-BryWDfQX.js → config-CLYMN3_p.js} +3 -2
- package/dist/{config-BryWDfQX.js.map → config-CLYMN3_p.js.map} +1 -1
- package/dist/config-DcYrUB-M.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-DcYrUB-M.js.map} +1 -1
- package/dist/config-oI_yS50f.js +1 -0
- package/dist/css-CELBp6Gu.js +58 -0
- package/dist/css-CELBp6Gu.js.map +1 -0
- package/dist/{css-BowBszUt.js → css-CohHH2tn.js} +17 -17
- package/dist/css-CohHH2tn.js.map +1 -0
- package/dist/{css-DcazYor9.js → css-D_DL1yOz.js} +10 -8
- package/dist/css-D_DL1yOz.js.map +1 -0
- package/dist/{css-ByOrugEX.js → css-DfH4Gb1c.js} +77 -77
- package/dist/css-DfH4Gb1c.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{css_extra-oIi3UEPK.js → css_extra-9BZ_jVET.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-9BZ_jVET.js.map} +1 -1
- package/dist/{css_extra-DlOnsnR1.js → css_extra-DQdCrYoC.js} +2 -2
- package/dist/{css_extra-oIi3UEPK.js.map → css_extra-DQdCrYoC.js.map} +1 -1
- package/dist/{data-BsqOa5br.js → data-Ze8GNiJm.js} +22 -12
- package/dist/data-Ze8GNiJm.js.map +1 -0
- package/dist/{debug-BAw63qX6.js → debug-BefbXMq1.js} +2 -2
- package/dist/{debug-BAw63qX6.js.map → debug-BefbXMq1.js.map} +1 -1
- package/dist/{debug-n2aZQBSa.js → debug-DLmUG3Vh.js} +3 -3
- package/dist/debug-DLmUG3Vh.js.map +1 -0
- package/dist/{debug-DGki_v7g.js → debug-OG2wSB5R.js} +2 -2
- package/dist/{debug-DGki_v7g.js.map → debug-OG2wSB5R.js.map} +1 -1
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-DfBbuLeE.js → dev-4TqJORRn.js} +7 -3
- package/dist/dev-4TqJORRn.js.map +1 -0
- package/dist/{dev-CcphAa3R.js → dev-C2u78xuv.js} +7 -7
- package/dist/{dev-CcphAa3R.js.map → dev-C2u78xuv.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-BKzZyg5V.js} +10 -8
- package/dist/{elementMarker-Bu7gDAkE.js.map → elementMarker-BKzZyg5V.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +12 -9
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +4 -4
- package/dist/entry/prod.js +8 -8
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +5 -5
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +342 -105
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +4 -4
- package/dist/entry/rsc-prod.js +7 -7
- package/dist/extract-B9j4TBkU.js +2 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-C6690_nr.js} +3 -3
- package/dist/getClassName-C6690_nr.js.map +1 -0
- package/dist/global-C7GsCW6Y.js +14 -0
- package/dist/{global-CvfmFLsK.js.map → global-C7GsCW6Y.js.map} +1 -1
- package/dist/global-zaCE-g1C.js +31 -0
- package/dist/global-zaCE-g1C.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Bycpk3MR.js} +53 -37
- package/dist/hash-Bycpk3MR.js.map +1 -0
- package/dist/index.js +10 -8
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-CwTeyUxr.js → jsx-Berx-L-r.js} +3 -3
- package/dist/{jsx-CwTeyUxr.js.map → jsx-Berx-L-r.js.map} +1 -1
- package/dist/{jsx-D2BksHSv.js → jsx-DsMajv_M.js} +7 -7
- package/dist/{jsx-D2BksHSv.js.map → jsx-DsMajv_M.js.map} +1 -1
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-DXlSD6kV.js} +2 -2
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-DXlSD6kV.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-CMdEXGNZ.js} +2 -2
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-CMdEXGNZ.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-DPWo5qvV.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-DPWo5qvV.js.map} +1 -1
- package/dist/{layer-D1SaH07m.js → layer-DiNeeTgG.js} +4 -4
- package/dist/{layer-D1SaH07m.js.map → layer-DiNeeTgG.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-DCT1Q9yi.mjs} +3 -3
- package/dist/{loader-B5Kw0DD-.mjs.map → loader-DCT1Q9yi.mjs.map} +1 -1
- package/dist/{misc-DCdYYyhK.mjs → misc-o8pviMUi.mjs} +7 -3
- package/dist/{misc-DCdYYyhK.mjs.map → misc-o8pviMUi.mjs.map} +1 -1
- package/dist/namedTokens-BUa6raTb.js +83 -0
- package/dist/namedTokens-BUa6raTb.js.map +1 -0
- package/dist/plugin/farm/index.mjs +2 -2
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +1 -1
- package/dist/plugin/vite/index.mjs +11 -8
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +971 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{property-CnLFt5kx.js → property-BzZSTVIh.js} +2 -2
- package/dist/{property-CnLFt5kx.js.map → property-BzZSTVIh.js.map} +1 -1
- package/dist/{registry-yHLRxyoo.mjs → registry-D3x1EDJm.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-D3x1EDJm.mjs.map} +1 -1
- package/dist/{rules-9HSO1pxL.js → rules-Dz7Pu2K6.js} +13 -10
- package/dist/rules-Dz7Pu2K6.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → runtime-B3jHW9B1.js} +3 -24
- package/dist/runtime-B3jHW9B1.js.map +1 -0
- package/dist/server.js +13 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-B_gJf5uj.cjs} +554 -60
- package/dist/shared-B_gJf5uj.cjs.map +1 -0
- package/dist/{shared-CxbHR89f.mjs → shared-uAzFeq0x.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-uAzFeq0x.mjs.map} +1 -1
- package/dist/sheet-DasbRnvy.js +7 -0
- package/dist/sheet-DasbRnvy.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BUO1hKXu.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BUO1hKXu.mjs.map} +1 -1
- package/dist/style-B0F1sgRZ.js +5 -0
- package/dist/{style-DgHbdbdF.js → style-BkeAZl0n.js} +258 -82
- package/dist/style-BkeAZl0n.js.map +1 -0
- package/dist/{style-B1UUqjj5.js → style-CYXTs1iu.js} +35 -7
- package/dist/style-CYXTs1iu.js.map +1 -0
- package/dist/{style-v2bf70TZ.js → style-DUztHzBz.js} +439 -123
- package/dist/style-DUztHzBz.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → styleStore-BGJ2ZYtK.js} +16 -7
- package/dist/styleStore-BGJ2ZYtK.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-DVDp-gI-.js} +6 -5
- package/dist/{styleStore-DyNXBcUK.js.map → styleStore-DVDp-gI-.js.map} +1 -1
- package/dist/{token-u_tM-mtg.js → token-CA1j7suG.js} +99 -30
- package/dist/token-CA1j7suG.js.map +1 -0
- package/dist/token-DTOyFLmp.js +58 -0
- package/dist/token-DTOyFLmp.js.map +1 -0
- package/dist/{trace-CU0rvNYr.js → trace-D0IL6JT8.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-D0IL6JT8.js.map} +1 -1
- package/dist/{trace-Bu_qOqRy.js → trace-DR7_Rpkg.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-DR7_Rpkg.js.map} +1 -1
- package/dist/transform-BTJOg8Hg.js +23 -0
- package/dist/transform-BTJOg8Hg.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-BsbfH6cd.js} +147 -76
- package/dist/utils-BsbfH6cd.js.map +1 -0
- package/dist/{utils-CEaq_c-A.mjs → utils-CpA-dSpY.mjs} +4 -4
- package/dist/{utils-CEaq_c-A.mjs.map → utils-CpA-dSpY.mjs.map} +1 -1
- package/dist/{utils-D7FAOyg6.js → utils-D4YWF2K0.js} +4 -4
- package/dist/{utils-D7FAOyg6.js.map → utils-D4YWF2K0.js.map} +1 -1
- package/dist/{utils-Bdbqn0f8.mjs → utils-DQGa0uzS.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DQGa0uzS.mjs.map} +1 -1
- package/dist/{utils-CWNHx4EC.js → utils-R6QadAsY.js} +3 -3
- package/dist/{utils-CWNHx4EC.js.map → utils-R6QadAsY.js.map} +1 -1
- package/dist/utils.js +3 -3
- package/dist/value-CJG6EWe8.js +85 -0
- package/dist/value-CJG6EWe8.js.map +1 -0
- package/dist/value-D-ZcRzLA.js +42 -0
- package/dist/value-D-ZcRzLA.js.map +1 -0
- package/dist/{value-BR4e2MKt.js → value-DBtSe-9B.js} +116 -26
- package/dist/value-DBtSe-9B.js.map +1 -0
- package/dist/{valueRef-lshFk1Cs.js → valueRef-CsLVJwjA.js} +2 -2
- package/dist/{valueRef-lshFk1Cs.js.map → valueRef-CsLVJwjA.js.map} +1 -1
- package/dist/{webpack-Dh6lox2l.mjs → webpack-Fb9xF5jS.mjs} +5 -5
- package/dist/{webpack-Dh6lox2l.mjs.map → webpack-Fb9xF5jS.mjs.map} +1 -1
- package/entry/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -0
- package/entry/prod/runtime.ts +1 -1
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_dev.ts +12 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/package.json +26 -9
- package/plugin/bundler/vite/plugin.ts +2 -1
- package/plugin/bundler/vite/state.ts +10 -5
- package/plugin/utils/runtimeEntry.ts +12 -0
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +208 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +430 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/core/cache/pool.ts +1 -1
- package/runtime/extract/getClassName.ts +1 -6
- package/runtime/extract/index.ts +1 -1
- package/runtime/index.ts +8 -1
- package/runtime/types.ts +4 -2
- package/style/classname.ts +41 -0
- package/style/index.ts +1 -0
- package/style/style.ts +30 -11
- package/style/theme.ts +4 -2
- package/style/transform.ts +41 -2
- package/utils/hash.ts +4 -0
- package/atomic/layer/README.md +0 -116
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
|
@@ -84,6 +84,9 @@ function hashString(str) {
|
|
|
84
84
|
for (let i = 0; i < str.length; i++) hash = Math.imul(hash ^ str.charCodeAt(i), 16777619);
|
|
85
85
|
return (hash >>> 0).toString(36).padEnd(7, "0");
|
|
86
86
|
}
|
|
87
|
+
function normalizeHashLength(length) {
|
|
88
|
+
return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
|
|
89
|
+
}
|
|
87
90
|
//#endregion
|
|
88
91
|
//#region atomic/layer/layer.ts
|
|
89
92
|
function compareLayerPriority(p1, p2) {
|
|
@@ -184,7 +187,8 @@ const DEV_CONFIG_DEFAULT = {
|
|
|
184
187
|
isLocalClassNameEnabled: true,
|
|
185
188
|
sheetMaxRules: 1e3,
|
|
186
189
|
sheetStyleTagNonce: null,
|
|
187
|
-
|
|
190
|
+
hashLength: null,
|
|
191
|
+
stylePriorityMode: "sort",
|
|
188
192
|
sourcemapLocationMode: "style",
|
|
189
193
|
isElementClassNameEnabled: true
|
|
190
194
|
};
|
|
@@ -195,6 +199,7 @@ globalData("config.dev.base", () => ({ config: null }));
|
|
|
195
199
|
globalData("config.dev.utils", () => ({ config: null }));
|
|
196
200
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
197
201
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
202
|
+
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
198
203
|
const STYLE_DEV_RSC_IMPORT_PATH = "@fluentic/style/dev/rsc";
|
|
199
204
|
const STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH = "@fluentic/style/entry/prod/extract";
|
|
200
205
|
const STYLE_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/prod/runtime";
|
|
@@ -207,6 +212,7 @@ const DEFAULT_CONFIG = {
|
|
|
207
212
|
const IMPORT_PATHS = [
|
|
208
213
|
STYLE_IMPORT_PATH,
|
|
209
214
|
STYLE_CSS_IMPORT_PATH,
|
|
215
|
+
STYLE_DIALECT_IMPORT_PATH,
|
|
210
216
|
STYLE_DEV_RSC_IMPORT_PATH
|
|
211
217
|
];
|
|
212
218
|
const IMPORT_EXTRACT = STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH;
|
|
@@ -447,9 +453,6 @@ function getCacheFilePath(cacheDir, args) {
|
|
|
447
453
|
function getCacheKey(args) {
|
|
448
454
|
return node_crypto.createHash("md5").update(args.cacheType).update("\0").update(node_path.resolve(args.filePath)).digest("hex");
|
|
449
455
|
}
|
|
450
|
-
function normalizeSelectorArg(arg) {
|
|
451
|
-
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
452
|
-
}
|
|
453
456
|
//#endregion
|
|
454
457
|
//#region builder/data/const.ts
|
|
455
458
|
const BUILDER_TYPE = symbol("builder.type");
|
|
@@ -625,12 +628,48 @@ function getBuilderType(value) {
|
|
|
625
628
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
626
629
|
return value[BUILDER_TYPE];
|
|
627
630
|
}
|
|
631
|
+
function normalizeSelectorArg(arg) {
|
|
632
|
+
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
633
|
+
}
|
|
628
634
|
//#endregion
|
|
629
635
|
//#region style/token.ts
|
|
630
636
|
const TOKEN_ID = symbol("style:token");
|
|
631
637
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
632
|
-
symbol("style:token.debug");
|
|
633
|
-
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
638
|
+
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
639
|
+
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
640
|
+
function createStyleToken(value, debugId) {
|
|
641
|
+
const token = (value, debug) => {
|
|
642
|
+
return createStyleTokenOverride(token, value, debug);
|
|
643
|
+
};
|
|
644
|
+
token[TOKEN_ID] = debugId || String(idCounter$6.value++);
|
|
645
|
+
if (isStyleTokenData(value)) {
|
|
646
|
+
token.value = value.value;
|
|
647
|
+
token.ref = value;
|
|
648
|
+
} else {
|
|
649
|
+
token.value = value;
|
|
650
|
+
token.ref = null;
|
|
651
|
+
}
|
|
652
|
+
return token;
|
|
653
|
+
}
|
|
654
|
+
function createStyleTokenOverride(token, value, debug) {
|
|
655
|
+
const override = isStyleTokenData(value) ? {
|
|
656
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
657
|
+
[TOKEN_OVERRIDE]: true,
|
|
658
|
+
value: value.value,
|
|
659
|
+
ref: value
|
|
660
|
+
} : {
|
|
661
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
662
|
+
[TOKEN_OVERRIDE]: true,
|
|
663
|
+
value,
|
|
664
|
+
ref: null
|
|
665
|
+
};
|
|
666
|
+
if (debug) Object.defineProperty(override, TOKEN_DEBUG, {
|
|
667
|
+
configurable: true,
|
|
668
|
+
enumerable: false,
|
|
669
|
+
value: debug
|
|
670
|
+
});
|
|
671
|
+
return override;
|
|
672
|
+
}
|
|
634
673
|
function isStyleTokenData(value) {
|
|
635
674
|
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
636
675
|
}
|
|
@@ -953,7 +992,7 @@ function createNameFormatter(keys) {
|
|
|
953
992
|
const name = getFormatFn(format)(info);
|
|
954
993
|
if (!hash) return name;
|
|
955
994
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
956
|
-
return name ? name + "
|
|
995
|
+
return name ? name + "--" + hash : hash;
|
|
957
996
|
};
|
|
958
997
|
}
|
|
959
998
|
function compileFormat(format, keySet) {
|
|
@@ -1047,8 +1086,12 @@ const formatClassName = createNameFormatter([
|
|
|
1047
1086
|
"value"
|
|
1048
1087
|
]);
|
|
1049
1088
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
1089
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
1050
1090
|
function getDebugClassName(format, hash, info) {
|
|
1051
|
-
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
1091
|
+
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
1092
|
+
}
|
|
1093
|
+
function getDebugTransformClassName(format, hash, info) {
|
|
1094
|
+
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1052
1095
|
}
|
|
1053
1096
|
function getDebugScopeClassName(format, info) {
|
|
1054
1097
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -1066,20 +1109,38 @@ function escapeCssValue(value) {
|
|
|
1066
1109
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1067
1110
|
}
|
|
1068
1111
|
function escapeCssIdent(ident) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1112
|
+
let result = "";
|
|
1113
|
+
for (let i = 0; i < ident.length; i++) {
|
|
1114
|
+
const char = ident.charAt(i);
|
|
1115
|
+
const code = ident.charCodeAt(i);
|
|
1116
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
1117
|
+
if (code === 0) {
|
|
1118
|
+
result += "�";
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
1122
|
+
result += "\\" + code.toString(16) + " ";
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
1126
|
+
result += "\\-";
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
1130
|
+
result += char + ident.charAt(++i);
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
1134
|
+
result += char;
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1137
|
+
result += "\\" + char;
|
|
1138
|
+
}
|
|
1139
|
+
return result;
|
|
1073
1140
|
}
|
|
1074
1141
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
1075
1142
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
1076
1143
|
}
|
|
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
1144
|
//#endregion
|
|
1084
1145
|
//#region atomic/utils/debug.ts
|
|
1085
1146
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1237,6 +1298,54 @@ function parseAtRule(rule) {
|
|
|
1237
1298
|
return compressQuery(normalized);
|
|
1238
1299
|
}
|
|
1239
1300
|
//#endregion
|
|
1301
|
+
//#region atomic/utils/hash.ts
|
|
1302
|
+
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1303
|
+
byValue: /* @__PURE__ */ new Map(),
|
|
1304
|
+
byHash: /* @__PURE__ */ new Map(),
|
|
1305
|
+
usedByLength: []
|
|
1306
|
+
}));
|
|
1307
|
+
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1308
|
+
return getPooledHash(value, startLength);
|
|
1309
|
+
}
|
|
1310
|
+
function getPooledHash(value, startLength) {
|
|
1311
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1312
|
+
const valueKey = normalizedStartLength + "\0" + value;
|
|
1313
|
+
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1314
|
+
if (existing) return existing;
|
|
1315
|
+
let length = normalizedStartLength;
|
|
1316
|
+
while (true) {
|
|
1317
|
+
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1318
|
+
length++;
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1322
|
+
const hash = getPooledHashCandidate(value, length, index);
|
|
1323
|
+
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1324
|
+
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1325
|
+
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1326
|
+
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1327
|
+
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1328
|
+
return hash;
|
|
1329
|
+
}
|
|
1330
|
+
length++;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
function getPooledHashCandidate(value, length, index) {
|
|
1334
|
+
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1335
|
+
}
|
|
1336
|
+
function getPooledHashUsedCount(length) {
|
|
1337
|
+
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1338
|
+
}
|
|
1339
|
+
function getIdentifierSafeHashPoolSize(length) {
|
|
1340
|
+
if (length <= 0) return 0;
|
|
1341
|
+
return 26 * 36 ** (length - 1);
|
|
1342
|
+
}
|
|
1343
|
+
function getIdentifierSafeHashValue(hash) {
|
|
1344
|
+
const first = hash.charCodeAt(0);
|
|
1345
|
+
if (first < 48 || first > 57) return hash;
|
|
1346
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1347
|
+
}
|
|
1348
|
+
//#endregion
|
|
1240
1349
|
//#region atomic/utils/selector.ts
|
|
1241
1350
|
function getSelectorText(selector) {
|
|
1242
1351
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1250,7 +1359,7 @@ function getSelectorPriority(selector) {
|
|
|
1250
1359
|
}
|
|
1251
1360
|
//#endregion
|
|
1252
1361
|
//#region atomic/className.ts
|
|
1253
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat) {
|
|
1362
|
+
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1254
1363
|
let hash = property;
|
|
1255
1364
|
hash += "\n" + (priority || "");
|
|
1256
1365
|
hash += "\n" + value;
|
|
@@ -1258,8 +1367,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1258
1367
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1259
1368
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1260
1369
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1261
|
-
hash = getIdentifierSafeHash(hash);
|
|
1370
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1262
1371
|
if (!debugClassName) return hash;
|
|
1372
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1263
1373
|
const propertyName = getDebugPropertyName(property, value);
|
|
1264
1374
|
return getDebugClassName(classNameFormat, hash, {
|
|
1265
1375
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1269,6 +1379,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1269
1379
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1270
1380
|
});
|
|
1271
1381
|
}
|
|
1382
|
+
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1383
|
+
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1384
|
+
return CSS_CONFIG.hashLength ?? 7;
|
|
1385
|
+
}
|
|
1272
1386
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1273
1387
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1274
1388
|
}
|
|
@@ -1357,7 +1471,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1357
1471
|
value = value[0];
|
|
1358
1472
|
}
|
|
1359
1473
|
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);
|
|
1474
|
+
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
1475
|
scopeItem.dedupe = dedupe;
|
|
1362
1476
|
scopeItem.className = className;
|
|
1363
1477
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1395,6 +1509,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1395
1509
|
className: "",
|
|
1396
1510
|
property: overrideItem.property,
|
|
1397
1511
|
value: overrideItem.value,
|
|
1512
|
+
transformClassName: overrideItem.transformClassName,
|
|
1398
1513
|
token: overrideItem.token,
|
|
1399
1514
|
selector: overrideItem.selector,
|
|
1400
1515
|
atRule,
|
|
@@ -1410,7 +1525,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1410
1525
|
value = value[0];
|
|
1411
1526
|
}
|
|
1412
1527
|
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);
|
|
1528
|
+
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
1529
|
scopeItem.dedupe = dedupe;
|
|
1415
1530
|
scopeItem.className = className;
|
|
1416
1531
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1478,7 +1593,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1478
1593
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1479
1594
|
function getTokenVarName(token, format) {
|
|
1480
1595
|
const id = getStyleTokenId(token);
|
|
1481
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1596
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1482
1597
|
}
|
|
1483
1598
|
function getTokenVar(token, format) {
|
|
1484
1599
|
return getTokenVarFallback(token, format);
|
|
@@ -1553,6 +1668,19 @@ function shouldAppendCssPx(property) {
|
|
|
1553
1668
|
return !UNITLESS.has(property);
|
|
1554
1669
|
}
|
|
1555
1670
|
//#endregion
|
|
1671
|
+
//#region style/transform.ts
|
|
1672
|
+
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1673
|
+
function classNameValue(value, className) {
|
|
1674
|
+
return {
|
|
1675
|
+
[CLASS_NAME_VALUE]: true,
|
|
1676
|
+
value,
|
|
1677
|
+
className
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function isClassNameValue(value) {
|
|
1681
|
+
return !!value && typeof value === "object" && value[CLASS_NAME_VALUE] === true && typeof value.className === "string";
|
|
1682
|
+
}
|
|
1683
|
+
//#endregion
|
|
1556
1684
|
//#region style/valueRef.ts
|
|
1557
1685
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1558
1686
|
function createAtRuleRef(data) {
|
|
@@ -1582,6 +1710,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1582
1710
|
let token;
|
|
1583
1711
|
let ref;
|
|
1584
1712
|
let variableName;
|
|
1713
|
+
let transformClassName;
|
|
1585
1714
|
let lookupIndex;
|
|
1586
1715
|
if (isStyleData(style)) {
|
|
1587
1716
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1619,6 +1748,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1619
1748
|
priority = valueRaw[0];
|
|
1620
1749
|
valueRaw = valueRaw[1];
|
|
1621
1750
|
}
|
|
1751
|
+
transformClassName = null;
|
|
1752
|
+
if (isClassNameValue(valueRaw)) {
|
|
1753
|
+
transformClassName = valueRaw.className;
|
|
1754
|
+
valueRaw = valueRaw.value;
|
|
1755
|
+
}
|
|
1622
1756
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1623
1757
|
if (ref) valueRaw = ref.value;
|
|
1624
1758
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1634,6 +1768,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1634
1768
|
className: "",
|
|
1635
1769
|
property,
|
|
1636
1770
|
value,
|
|
1771
|
+
transformClassName,
|
|
1637
1772
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1638
1773
|
1,
|
|
1639
1774
|
variableName,
|
|
@@ -1698,7 +1833,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1698
1833
|
value = value[0];
|
|
1699
1834
|
}
|
|
1700
1835
|
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);
|
|
1836
|
+
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
1837
|
runtimeItem.dedupe = dedupe;
|
|
1703
1838
|
runtimeItem.className = className;
|
|
1704
1839
|
lookupIndex = lookup[dedupe];
|
|
@@ -2495,7 +2630,7 @@ function getCssPropertyName(property) {
|
|
|
2495
2630
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2496
2631
|
const formatter = createNameFormatter(["name"]);
|
|
2497
2632
|
return (format, id, info) => {
|
|
2498
|
-
const hash = getIdentifierSafeHash(id);
|
|
2633
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2499
2634
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2500
2635
|
if (!prefix) return name;
|
|
2501
2636
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2706,11 +2841,11 @@ function createStyleFn(args) {
|
|
|
2706
2841
|
style.plain = fnPlain;
|
|
2707
2842
|
style.keyframes = fnKeyframes;
|
|
2708
2843
|
style.merge = fnMerge;
|
|
2709
|
-
|
|
2844
|
+
assignStyleFnMeta(style, {
|
|
2845
|
+
mode: "StyleObject",
|
|
2710
2846
|
selectors,
|
|
2711
2847
|
transform: transform ?? null
|
|
2712
|
-
};
|
|
2713
|
-
Object.assign(style, { [META]: meta });
|
|
2848
|
+
});
|
|
2714
2849
|
return { style };
|
|
2715
2850
|
}
|
|
2716
2851
|
function mergeStyleResult(target, style) {
|
|
@@ -2719,12 +2854,17 @@ function mergeStyleResult(target, style) {
|
|
|
2719
2854
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2720
2855
|
return target;
|
|
2721
2856
|
}
|
|
2857
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2858
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2859
|
+
return styleFn;
|
|
2860
|
+
}
|
|
2722
2861
|
function getStyleFnMeta(styleFn) {
|
|
2723
2862
|
return styleFn[META];
|
|
2724
2863
|
}
|
|
2725
2864
|
//#endregion
|
|
2726
2865
|
//#region compiler/utils/import_source.ts
|
|
2727
2866
|
const DefaultStyleFnMeta = {
|
|
2867
|
+
mode: "StyleObject",
|
|
2728
2868
|
selectors: PrioritySelectors,
|
|
2729
2869
|
transform: null
|
|
2730
2870
|
};
|
|
@@ -2977,6 +3117,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2977
3117
|
}
|
|
2978
3118
|
}
|
|
2979
3119
|
//#endregion
|
|
3120
|
+
//#region style/value.ts
|
|
3121
|
+
function createToken(value, debugId) {
|
|
3122
|
+
return createStyleToken(value, debugId);
|
|
3123
|
+
}
|
|
3124
|
+
//#endregion
|
|
3125
|
+
//#region dialect/namedTokens.ts
|
|
3126
|
+
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
3127
|
+
function createNamedToken(id, value) {
|
|
3128
|
+
return createToken(value, createNamedTokenId(id));
|
|
3129
|
+
}
|
|
3130
|
+
function createNamedTokens(namespace, values) {
|
|
3131
|
+
return createNamedTokenProxy({
|
|
3132
|
+
__fluenticNamedTokens: true,
|
|
3133
|
+
namespace,
|
|
3134
|
+
values,
|
|
3135
|
+
cache: /* @__PURE__ */ new Map()
|
|
3136
|
+
}, []);
|
|
3137
|
+
}
|
|
3138
|
+
function createNamedTokenId(id) {
|
|
3139
|
+
return sanitizeCssIdentName(id.replace(/\./g, "-"), "named-token");
|
|
3140
|
+
}
|
|
3141
|
+
function createNamedTokenProxy(root, path) {
|
|
3142
|
+
return new Proxy(noop, {
|
|
3143
|
+
get(_target, property) {
|
|
3144
|
+
if (property === ROOT) return root;
|
|
3145
|
+
if (property === "then") return void 0;
|
|
3146
|
+
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
3147
|
+
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3148
|
+
if (!path.length) return void 0;
|
|
3149
|
+
return getNamedTokenAtPath(root, path)[property];
|
|
3150
|
+
}
|
|
3151
|
+
if (typeof property === "symbol") return void 0;
|
|
3152
|
+
return createNamedTokenProxy(root, path.concat(String(property)));
|
|
3153
|
+
},
|
|
3154
|
+
apply(_target, _thisArg, args) {
|
|
3155
|
+
if (!path.length) return void 0;
|
|
3156
|
+
return getNamedTokenAtPath(root, path).apply(void 0, args);
|
|
3157
|
+
}
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
function getNamedTokenAtPath(root, path) {
|
|
3161
|
+
const key = path.join(".");
|
|
3162
|
+
const cached = root.cache.get(key);
|
|
3163
|
+
if (cached) return cached;
|
|
3164
|
+
const value = getValueAtPath(root.values, path);
|
|
3165
|
+
const token = createNamedToken(root.namespace + "." + key, value);
|
|
3166
|
+
root.cache.set(key, token);
|
|
3167
|
+
return token;
|
|
3168
|
+
}
|
|
3169
|
+
function getValueAtPath(values, path) {
|
|
3170
|
+
let current = values;
|
|
3171
|
+
for (let i = 0; i < path.length; i++) {
|
|
3172
|
+
if (!current || typeof current !== "object") return void 0;
|
|
3173
|
+
current = current[path[i]];
|
|
3174
|
+
}
|
|
3175
|
+
return current;
|
|
3176
|
+
}
|
|
3177
|
+
function noop() {}
|
|
3178
|
+
//#endregion
|
|
2980
3179
|
//#region style/utils/expose.ts
|
|
2981
3180
|
function exposeStyle(styles) {
|
|
2982
3181
|
return exposeStyleObject(styles);
|
|
@@ -3032,6 +3231,7 @@ function evaluateNode(node, scope) {
|
|
|
3032
3231
|
case "ParenthesizedExpression":
|
|
3033
3232
|
case "TSAsExpression":
|
|
3034
3233
|
case "TSNonNullExpression":
|
|
3234
|
+
case "TSSatisfiesExpression":
|
|
3035
3235
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
3036
3236
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
3037
3237
|
}
|
|
@@ -3104,14 +3304,14 @@ function evaluateMember(node, scope) {
|
|
|
3104
3304
|
if (!key.ok) return key;
|
|
3105
3305
|
const obj = evaluateNode(node.object, scope);
|
|
3106
3306
|
if (!obj.ok) return obj;
|
|
3107
|
-
if (obj.value && typeof obj.value === "object") return evalOk(obj.value[key.value]);
|
|
3307
|
+
if (obj.value && (typeof obj.value === "object" || typeof obj.value === "function")) return evalOk(obj.value[key.value]);
|
|
3108
3308
|
return evalFail("Cannot index non-object");
|
|
3109
3309
|
}
|
|
3110
3310
|
const prop = node.property.name;
|
|
3111
3311
|
const obj = evaluateNode(node.object, scope);
|
|
3112
3312
|
if (!obj.ok) return obj;
|
|
3113
3313
|
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}`);
|
|
3314
|
+
if (typeof obj.value !== "object" && typeof obj.value !== "function" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3115
3315
|
return evalOk(obj.value[prop]);
|
|
3116
3316
|
}
|
|
3117
3317
|
function evaluateObject(node, scope) {
|
|
@@ -3150,7 +3350,7 @@ function evaluateObject(node, scope) {
|
|
|
3150
3350
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
3151
3351
|
const val = evaluateNode(prop.value, scope);
|
|
3152
3352
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3153
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3353
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3154
3354
|
if (prop.loc?.start) locations[key] = {
|
|
3155
3355
|
line: prop.loc.start.line,
|
|
3156
3356
|
column: prop.loc.start.column + 1,
|
|
@@ -3315,6 +3515,23 @@ function evaluateCall(node, scope) {
|
|
|
3315
3515
|
if (!debugId.ok) return debugId;
|
|
3316
3516
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3317
3517
|
}
|
|
3518
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3519
|
+
const id = evaluateNode(node.arguments[0], scope);
|
|
3520
|
+
if (!id.ok) return id;
|
|
3521
|
+
if (typeof id.value !== "string") return evalFail("createNamedToken id must be a static string");
|
|
3522
|
+
const value = evaluateNode(node.arguments[1], scope);
|
|
3523
|
+
if (!value.ok) return value;
|
|
3524
|
+
return evalOk(createNamedToken(id.value, value.value));
|
|
3525
|
+
}
|
|
3526
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedTokens") {
|
|
3527
|
+
const namespace = evaluateNode(node.arguments[0], scope);
|
|
3528
|
+
if (!namespace.ok) return namespace;
|
|
3529
|
+
if (typeof namespace.value !== "string") return evalFail("createNamedTokens namespace must be a static string");
|
|
3530
|
+
const values = evaluateNode(node.arguments[1], scope);
|
|
3531
|
+
if (!values.ok) return values;
|
|
3532
|
+
if (!values.value || typeof values.value !== "object") return evalFail("createNamedTokens values must be a static object");
|
|
3533
|
+
return evalOk(createNamedTokens(namespace.value, values.value));
|
|
3534
|
+
}
|
|
3318
3535
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3319
3536
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3320
3537
|
if (!styles.ok) return styles;
|
|
@@ -3527,7 +3744,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3527
3744
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3528
3745
|
});
|
|
3529
3746
|
}
|
|
3530
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3747
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3531
3748
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3532
3749
|
}
|
|
3533
3750
|
function evaluateBinary(node, scope) {
|
|
@@ -3583,7 +3800,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3583
3800
|
}
|
|
3584
3801
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3585
3802
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3586
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3803
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3587
3804
|
}
|
|
3588
3805
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3589
3806
|
const declarations = [];
|
|
@@ -3880,12 +4097,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3880
4097
|
}
|
|
3881
4098
|
const formatVarName = createNameFormatter(["name"]);
|
|
3882
4099
|
function getLocalVarName(filePath, line, column, format) {
|
|
3883
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
4100
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3884
4101
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3885
4102
|
}
|
|
3886
4103
|
//#endregion
|
|
3887
4104
|
//#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) {
|
|
4105
|
+
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride, classNameArg = false) {
|
|
3889
4106
|
const loc = locOverride ?? node.loc?.start;
|
|
3890
4107
|
const line = loc?.line ?? 1;
|
|
3891
4108
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3902,10 +4119,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3902
4119
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3903
4120
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3904
4121
|
];
|
|
4122
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3905
4123
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3906
4124
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3907
4125
|
return t.objectExpression(properties);
|
|
3908
4126
|
}
|
|
4127
|
+
function buildClassNames(t, args) {
|
|
4128
|
+
const classNames = /* @__PURE__ */ new Map();
|
|
4129
|
+
for (const arg of args) collectClassNameLoc(arg, classNames);
|
|
4130
|
+
const fields = [];
|
|
4131
|
+
for (const [className, loc] of classNames) fields.push(t.objectProperty(t.stringLiteral(className), buildLoc(t, loc.line, loc.column + 1)));
|
|
4132
|
+
return t.objectExpression(fields);
|
|
4133
|
+
}
|
|
4134
|
+
function collectClassNameLoc(arg, classNames) {
|
|
4135
|
+
if (!arg) return;
|
|
4136
|
+
if (arg.type === "StringLiteral") {
|
|
4137
|
+
const loc = arg.loc?.start;
|
|
4138
|
+
if (loc) classNames.set(arg.value, loc);
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
if (arg.type === "TemplateLiteral" && arg.expressions.length === 0) {
|
|
4142
|
+
const loc = arg.loc?.start;
|
|
4143
|
+
if (loc) classNames.set(arg.quasis[0]?.value.cooked ?? arg.quasis[0]?.value.raw ?? "", loc);
|
|
4144
|
+
return;
|
|
4145
|
+
}
|
|
4146
|
+
if (arg.type === "ArrayExpression") {
|
|
4147
|
+
for (const item of arg.elements) collectClassNameLoc(item, classNames);
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4150
|
+
if (arg.type === "ConditionalExpression") {
|
|
4151
|
+
collectClassNameLoc(arg.consequent, classNames);
|
|
4152
|
+
collectClassNameLoc(arg.alternate, classNames);
|
|
4153
|
+
return;
|
|
4154
|
+
}
|
|
4155
|
+
if (arg.type === "LogicalExpression") {
|
|
4156
|
+
collectClassNameLoc(arg.left, classNames);
|
|
4157
|
+
collectClassNameLoc(arg.right, classNames);
|
|
4158
|
+
return;
|
|
4159
|
+
}
|
|
4160
|
+
if (arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && arg.callee.property.type === "Identifier" && arg.callee.property.name === "weight") collectClassNameLoc(arg.arguments[0], classNames);
|
|
4161
|
+
}
|
|
3909
4162
|
function getShortLabel(label) {
|
|
3910
4163
|
const parts = label.split(".");
|
|
3911
4164
|
return parts[parts.length - 1] || label;
|
|
@@ -4064,7 +4317,9 @@ function createDebugPlugin(args) {
|
|
|
4064
4317
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
4065
4318
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
4066
4319
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
4067
|
-
|
|
4320
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4321
|
+
const isClassNameCall = rootName ? state.styleMetas.get(rootName)?.mode === "ClassName" : false;
|
|
4322
|
+
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
4323
|
},
|
|
4069
4324
|
JSXOpeningElement(path, state) {
|
|
4070
4325
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4655,6 +4910,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4655
4910
|
//#region compiler/utils/file_resolver.ts
|
|
4656
4911
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4657
4912
|
const resolver = new oxc_resolver.ResolverFactory({
|
|
4913
|
+
conditionNames: [
|
|
4914
|
+
"import",
|
|
4915
|
+
"module",
|
|
4916
|
+
"default",
|
|
4917
|
+
"types"
|
|
4918
|
+
],
|
|
4658
4919
|
extensions: [
|
|
4659
4920
|
".ts",
|
|
4660
4921
|
".tsx",
|
|
@@ -4814,8 +5075,101 @@ function extractStyleChain(node, styleNames) {
|
|
|
4814
5075
|
}
|
|
4815
5076
|
//#endregion
|
|
4816
5077
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4817
|
-
function applyTransform(styleObj, transform) {
|
|
4818
|
-
|
|
5078
|
+
function applyTransform(styleObj, transform, cssConfig) {
|
|
5079
|
+
if (!transform) return styleObj;
|
|
5080
|
+
const input = transformRuntimeValues(styleObj, transform, cssConfig);
|
|
5081
|
+
return carryTransformedLocations(input, transform.transform(input), transform);
|
|
5082
|
+
}
|
|
5083
|
+
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
5084
|
+
let result = null;
|
|
5085
|
+
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
5086
|
+
const runtimeValue = getCompiledRuntimeValue(getPriorityTupleValue(rawValue));
|
|
5087
|
+
if (!runtimeValue) continue;
|
|
5088
|
+
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
5089
|
+
if (transformedRuntimeValue === runtimeValue) continue;
|
|
5090
|
+
result ??= cloneCompiledStyleObject(styleObj);
|
|
5091
|
+
result[property] = Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number" ? [rawValue[0], createCompiledRuntimeValue(transformedRuntimeValue)] : createCompiledRuntimeValue(transformedRuntimeValue);
|
|
5092
|
+
}
|
|
5093
|
+
return result ?? styleObj;
|
|
5094
|
+
}
|
|
5095
|
+
function getPriorityTupleValue(value) {
|
|
5096
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
5097
|
+
}
|
|
5098
|
+
function cloneCompiledStyleObject(styleObj) {
|
|
5099
|
+
const cloned = { ...styleObj };
|
|
5100
|
+
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5101
|
+
if (locations) Object.defineProperty(cloned, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5102
|
+
configurable: true,
|
|
5103
|
+
enumerable: false,
|
|
5104
|
+
value: locations
|
|
5105
|
+
});
|
|
5106
|
+
return cloned;
|
|
5107
|
+
}
|
|
5108
|
+
function createCompiledRuntimeValue(runtimeValue) {
|
|
5109
|
+
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
5110
|
+
}
|
|
5111
|
+
function transformRuntimeExpression(property, expression, transform, cssConfig) {
|
|
5112
|
+
if (expression.type === "StringLiteral") return createPrimitiveExpression(expression, normalizeRuntimeTransformedValue(getSingleTransformedValue(transform.transform({ [property]: expression.value })), cssConfig)) ?? expression;
|
|
5113
|
+
if (expression.type === "ConditionalExpression") {
|
|
5114
|
+
const consequent = transformRuntimeExpression(property, expression.consequent, transform, cssConfig);
|
|
5115
|
+
const alternate = transformRuntimeExpression(property, expression.alternate, transform, cssConfig);
|
|
5116
|
+
return consequent === expression.consequent && alternate === expression.alternate ? expression : {
|
|
5117
|
+
...expression,
|
|
5118
|
+
consequent,
|
|
5119
|
+
alternate
|
|
5120
|
+
};
|
|
5121
|
+
}
|
|
5122
|
+
return expression;
|
|
5123
|
+
}
|
|
5124
|
+
function getSingleTransformedValue(transformed) {
|
|
5125
|
+
const values = Object.values(transformed);
|
|
5126
|
+
if (!values.length) return void 0;
|
|
5127
|
+
return values[0];
|
|
5128
|
+
}
|
|
5129
|
+
function normalizeRuntimeTransformedValue(value, cssConfig) {
|
|
5130
|
+
if (isStyleTokenOverrideData(value)) return getTokenOverrideValue(value, cssConfig.tokenNameFormat);
|
|
5131
|
+
if (isStyleTokenData(value)) return getTokenVar(value, cssConfig.tokenNameFormat);
|
|
5132
|
+
return value;
|
|
5133
|
+
}
|
|
5134
|
+
function createPrimitiveExpression(original, value) {
|
|
5135
|
+
if (original.type === "StringLiteral" && value === original.value) return null;
|
|
5136
|
+
if (typeof value === "string") return {
|
|
5137
|
+
...original,
|
|
5138
|
+
type: "StringLiteral",
|
|
5139
|
+
value
|
|
5140
|
+
};
|
|
5141
|
+
if (typeof value === "number") return {
|
|
5142
|
+
...original,
|
|
5143
|
+
type: "NumericLiteral",
|
|
5144
|
+
value
|
|
5145
|
+
};
|
|
5146
|
+
if (typeof value === "boolean") return {
|
|
5147
|
+
...original,
|
|
5148
|
+
type: "BooleanLiteral",
|
|
5149
|
+
value
|
|
5150
|
+
};
|
|
5151
|
+
if (value === null) return {
|
|
5152
|
+
...original,
|
|
5153
|
+
type: "NullLiteral"
|
|
5154
|
+
};
|
|
5155
|
+
return null;
|
|
5156
|
+
}
|
|
5157
|
+
function carryTransformedLocations(input, transformed, transform) {
|
|
5158
|
+
const inputLocations = input[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5159
|
+
if (!inputLocations) return transformed;
|
|
5160
|
+
const locations = { ...transformed[COMPILED_STYLE_OBJECT_LOCATIONS] };
|
|
5161
|
+
for (const [property, loc] of Object.entries(inputLocations)) {
|
|
5162
|
+
if (property in transformed && !locations[property]) locations[property] = loc;
|
|
5163
|
+
const single = transform.transform({ [property]: input[property] });
|
|
5164
|
+
for (const transformedProperty of Object.keys(single)) locations[transformedProperty] ??= loc;
|
|
5165
|
+
}
|
|
5166
|
+
if (!Object.keys(locations).length) return transformed;
|
|
5167
|
+
Object.defineProperty(transformed, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5168
|
+
configurable: true,
|
|
5169
|
+
enumerable: false,
|
|
5170
|
+
value: locations
|
|
5171
|
+
});
|
|
5172
|
+
return transformed;
|
|
4819
5173
|
}
|
|
4820
5174
|
/**
|
|
4821
5175
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
@@ -4823,6 +5177,10 @@ function applyTransform(styleObj, transform) {
|
|
|
4823
5177
|
*/
|
|
4824
5178
|
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4825
5179
|
const css = getCssConfig(opts);
|
|
5180
|
+
if (meta.mode === "ClassName") {
|
|
5181
|
+
if (chain.kind !== "style") return null;
|
|
5182
|
+
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5183
|
+
}
|
|
4826
5184
|
const selectors = meta.selectors;
|
|
4827
5185
|
const transform = meta.transform;
|
|
4828
5186
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4834,6 +5192,8 @@ function getCssConfig(opts) {
|
|
|
4834
5192
|
const css = opts.css;
|
|
4835
5193
|
return {
|
|
4836
5194
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5195
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5196
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4837
5197
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4838
5198
|
localClassName: css?.localClassName ?? DEFAULT_CONFIG.localClassName,
|
|
4839
5199
|
debugClassName: css?.debugClassName ?? DEFAULT_CONFIG.debugClassName,
|
|
@@ -4854,6 +5214,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4854
5214
|
rules
|
|
4855
5215
|
};
|
|
4856
5216
|
}
|
|
5217
|
+
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
5218
|
+
const items = [];
|
|
5219
|
+
const rules = [];
|
|
5220
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
5221
|
+
let i = 0;
|
|
5222
|
+
while (i < chain.methods.length) {
|
|
5223
|
+
const method = chain.methods[i];
|
|
5224
|
+
if (!compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options)) return null;
|
|
5225
|
+
i++;
|
|
5226
|
+
}
|
|
5227
|
+
return {
|
|
5228
|
+
type: "style",
|
|
5229
|
+
items,
|
|
5230
|
+
rules
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options) {
|
|
5234
|
+
const selector = selectors[method.name];
|
|
5235
|
+
if (!selector) return false;
|
|
5236
|
+
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5237
|
+
const selectorStr = selector.selector.trim();
|
|
5238
|
+
if (selectorStr === "...") {
|
|
5239
|
+
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5240
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5241
|
+
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5242
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5243
|
+
if (!result) return false;
|
|
5244
|
+
items.push(...result.items);
|
|
5245
|
+
rules.push(...result.rules);
|
|
5246
|
+
return true;
|
|
5247
|
+
}
|
|
5248
|
+
return false;
|
|
5249
|
+
}
|
|
5250
|
+
if (selectorStr.startsWith("@")) {
|
|
5251
|
+
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5252
|
+
const hasArg = selectorStr.includes("$$");
|
|
5253
|
+
const priority = getAtRulePriority(selector.priority, isMedia, method.args[0]);
|
|
5254
|
+
let argOffset = 0;
|
|
5255
|
+
if (isMedia && isNumericLiteral(method.args[0])) argOffset = 1;
|
|
5256
|
+
let atRule = selectorStr;
|
|
5257
|
+
if (hasArg) {
|
|
5258
|
+
const queryArg = evaluateNode(method.args[argOffset], scope);
|
|
5259
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, queryArg, method.args[argOffset]);
|
|
5260
|
+
throwIfRequiredStaticSelectorValue(options, `style.${method.name}`, queryArg);
|
|
5261
|
+
if (!queryArg.ok) return false;
|
|
5262
|
+
const [before, after] = selectorStr.split("$$");
|
|
5263
|
+
atRule = before + String(queryArg.value) + (after ?? "");
|
|
5264
|
+
}
|
|
5265
|
+
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5266
|
+
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5267
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5268
|
+
}
|
|
5269
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5270
|
+
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
5271
|
+
const [before, after] = selectorStr.split(splitToken);
|
|
5272
|
+
const selectorArg = evaluateNode(method.args[0], scope);
|
|
5273
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, selectorArg, method.args[0]);
|
|
5274
|
+
if (!selectorArg.ok) return false;
|
|
5275
|
+
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5276
|
+
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5277
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5278
|
+
}
|
|
5279
|
+
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5280
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5281
|
+
}
|
|
5282
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
5283
|
+
if (startIndex >= args.length) return true;
|
|
5284
|
+
const styleObj = {};
|
|
5285
|
+
let i = startIndex;
|
|
5286
|
+
while (i < args.length) {
|
|
5287
|
+
const arg = evaluateNode(args[i], scope);
|
|
5288
|
+
if (!arg.ok) {
|
|
5289
|
+
throwIfRequiredStaticStyleValue(arg);
|
|
5290
|
+
return false;
|
|
5291
|
+
}
|
|
5292
|
+
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
5293
|
+
i++;
|
|
5294
|
+
}
|
|
5295
|
+
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5296
|
+
}
|
|
5297
|
+
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
5298
|
+
if (!value) return true;
|
|
5299
|
+
if (typeof value === "string") {
|
|
5300
|
+
Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
|
|
5301
|
+
return true;
|
|
5302
|
+
}
|
|
5303
|
+
if (Array.isArray(value)) {
|
|
5304
|
+
for (const item of value) if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
|
|
5305
|
+
return true;
|
|
5306
|
+
}
|
|
5307
|
+
if (isWeightedClassName(value)) {
|
|
5308
|
+
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5309
|
+
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
5310
|
+
return true;
|
|
5311
|
+
}
|
|
5312
|
+
return false;
|
|
5313
|
+
}
|
|
5314
|
+
function decorateClassNameStyle(style, className) {
|
|
5315
|
+
const result = {};
|
|
5316
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5317
|
+
if (value === null || value === void 0) {
|
|
5318
|
+
result[property] = value;
|
|
5319
|
+
continue;
|
|
5320
|
+
}
|
|
5321
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "number") {
|
|
5322
|
+
const rawValue = value[1];
|
|
5323
|
+
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5324
|
+
continue;
|
|
5325
|
+
}
|
|
5326
|
+
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
5327
|
+
}
|
|
5328
|
+
return result;
|
|
5329
|
+
}
|
|
5330
|
+
function isWeightedClassName(value) {
|
|
5331
|
+
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5332
|
+
}
|
|
5333
|
+
function applyClassNameWeight(style, weight) {
|
|
5334
|
+
const weighted = {};
|
|
5335
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5336
|
+
if (value === null || value === void 0) {
|
|
5337
|
+
weighted[property] = value;
|
|
5338
|
+
continue;
|
|
5339
|
+
}
|
|
5340
|
+
weighted[property] = [weight, Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value];
|
|
5341
|
+
}
|
|
5342
|
+
return weighted;
|
|
5343
|
+
}
|
|
4857
5344
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4858
5345
|
if (chain.baseArgs.length > 0) {
|
|
4859
5346
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4861,7 +5348,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4861
5348
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4862
5349
|
return false;
|
|
4863
5350
|
}
|
|
4864
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5351
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
4865
5352
|
}
|
|
4866
5353
|
let i = 0;
|
|
4867
5354
|
while (i < chain.methods.length) {
|
|
@@ -4880,7 +5367,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4880
5367
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4881
5368
|
return null;
|
|
4882
5369
|
}
|
|
4883
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
5370
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
4884
5371
|
}
|
|
4885
5372
|
let i = 0;
|
|
4886
5373
|
while (i < chain.methods.length) {
|
|
@@ -4998,14 +5485,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4998
5485
|
return true;
|
|
4999
5486
|
}
|
|
5000
5487
|
if (node.type !== "CallExpression") return false;
|
|
5001
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5488
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
5002
5489
|
if (!overrideChain) return false;
|
|
5003
5490
|
const { slotId, items: overrideItems } = overrideChain;
|
|
5004
5491
|
let i = 0;
|
|
5005
5492
|
while (i < overrideItems.length) {
|
|
5006
5493
|
const overrideItem = overrideItems[i];
|
|
5007
5494
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
5008
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5495
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
5009
5496
|
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
5497
|
} else if (overrideItem.styleData !== void 0) {
|
|
5011
5498
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -5014,15 +5501,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
5014
5501
|
}
|
|
5015
5502
|
return true;
|
|
5016
5503
|
}
|
|
5017
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5504
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
5018
5505
|
const callee = node.callee;
|
|
5019
5506
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5020
5507
|
const methodName = callee.property.name;
|
|
5021
5508
|
const obj = callee.object;
|
|
5022
5509
|
if (obj.type === "CallExpression") {
|
|
5023
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5510
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
5024
5511
|
if (!inner) return null;
|
|
5025
|
-
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, transform, options);
|
|
5512
|
+
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, cssConfig, transform, options);
|
|
5026
5513
|
if (!overrideItem) return null;
|
|
5027
5514
|
return {
|
|
5028
5515
|
slotId: inner.slotId,
|
|
@@ -5037,7 +5524,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5037
5524
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
5038
5525
|
if (!styleArg.ok) return null;
|
|
5039
5526
|
items.push({
|
|
5040
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5527
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5041
5528
|
selector: null,
|
|
5042
5529
|
atRules: null
|
|
5043
5530
|
});
|
|
@@ -5047,7 +5534,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5047
5534
|
items
|
|
5048
5535
|
};
|
|
5049
5536
|
}
|
|
5050
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5537
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
5051
5538
|
const sel = selectors[methodName];
|
|
5052
5539
|
if (!sel) return null;
|
|
5053
5540
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -5074,7 +5561,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5074
5561
|
callsiteOverride
|
|
5075
5562
|
};
|
|
5076
5563
|
return {
|
|
5077
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5564
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5078
5565
|
selector: null,
|
|
5079
5566
|
atRules: null,
|
|
5080
5567
|
callsiteOverride
|
|
@@ -5099,7 +5586,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5099
5586
|
if (!styleArg.ok) return null;
|
|
5100
5587
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5101
5588
|
return {
|
|
5102
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5589
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5103
5590
|
selector: null,
|
|
5104
5591
|
atRules: [atRuleSelector]
|
|
5105
5592
|
};
|
|
@@ -5115,7 +5602,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5115
5602
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5116
5603
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
5117
5604
|
return {
|
|
5118
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5605
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5119
5606
|
selector: itemSelector,
|
|
5120
5607
|
atRules: null
|
|
5121
5608
|
};
|
|
@@ -5123,7 +5610,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5123
5610
|
const styleArg = evaluateNode(args[0], scope);
|
|
5124
5611
|
if (!styleArg.ok) return null;
|
|
5125
5612
|
return {
|
|
5126
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5613
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5127
5614
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5128
5615
|
atRules: null
|
|
5129
5616
|
};
|
|
@@ -5207,7 +5694,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5207
5694
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5208
5695
|
return false;
|
|
5209
5696
|
}
|
|
5210
|
-
return addStyleItems(applyTransform(styleArg.value, transform), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5697
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5211
5698
|
}
|
|
5212
5699
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5213
5700
|
if (!styleArgNode) return false;
|
|
@@ -5288,14 +5775,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5288
5775
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5289
5776
|
return false;
|
|
5290
5777
|
}
|
|
5291
|
-
return addStyleItems(applyTransform(evaled.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5778
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5292
5779
|
}
|
|
5293
5780
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5294
5781
|
if (!styleResult.ok) {
|
|
5295
5782
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5296
5783
|
return false;
|
|
5297
5784
|
}
|
|
5298
|
-
return addStyleItems(applyTransform(styleResult.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5785
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5299
5786
|
}
|
|
5300
5787
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5301
5788
|
const selectorStr = selector.selector.trim();
|
|
@@ -5314,7 +5801,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5314
5801
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5315
5802
|
if (!styleResult.ok) return false;
|
|
5316
5803
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5317
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5804
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5318
5805
|
let i = 0;
|
|
5319
5806
|
while (i < selectorValues.length) {
|
|
5320
5807
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5442,7 +5929,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5442
5929
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5443
5930
|
const valueStr = String(value ?? "");
|
|
5444
5931
|
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);
|
|
5932
|
+
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
5933
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5447
5934
|
items.push(item);
|
|
5448
5935
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5523,7 +6010,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5523
6010
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5524
6011
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5525
6012
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5526
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
6013
|
+
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
6014
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5528
6015
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5529
6016
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5591,10 +6078,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5591
6078
|
const rawValue = styleObj[property];
|
|
5592
6079
|
let priority = null;
|
|
5593
6080
|
let value = rawValue;
|
|
6081
|
+
let transformClassName = null;
|
|
5594
6082
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5595
6083
|
priority = rawValue[0];
|
|
5596
6084
|
value = rawValue[1];
|
|
5597
6085
|
}
|
|
6086
|
+
if (isClassNameValue(value)) {
|
|
6087
|
+
transformClassName = value.className;
|
|
6088
|
+
value = value.value;
|
|
6089
|
+
}
|
|
5598
6090
|
if (value === null || value === void 0) {
|
|
5599
6091
|
i++;
|
|
5600
6092
|
continue;
|
|
@@ -5614,7 +6106,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5614
6106
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5615
6107
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5616
6108
|
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);
|
|
6109
|
+
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5618
6110
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5619
6111
|
item.sourceTrace = propertyCallsite ? {
|
|
5620
6112
|
property,
|
|
@@ -6788,13 +7280,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6788
7280
|
const body = path.node.body;
|
|
6789
7281
|
let firstRuntimeIndex = 0;
|
|
6790
7282
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7283
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6791
7284
|
declarations.forEach((item) => {
|
|
6792
|
-
let insertIndex =
|
|
7285
|
+
let insertIndex = runtimeInsertIndex;
|
|
6793
7286
|
item.dependencies.forEach((name) => {
|
|
6794
7287
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6795
7288
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6796
7289
|
});
|
|
6797
7290
|
body.splice(insertIndex, 0, item.declaration);
|
|
7291
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6798
7292
|
});
|
|
6799
7293
|
}
|
|
6800
7294
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -7648,4 +8142,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
7648
8142
|
}
|
|
7649
8143
|
});
|
|
7650
8144
|
|
|
7651
|
-
//# sourceMappingURL=shared-
|
|
8145
|
+
//# sourceMappingURL=shared-B_gJf5uj.cjs.map
|