@fluentic/style 0.1.0-beta.0 → 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 +26 -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 +35 -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/{assert-h_Zkqc4E.js → assert-BGdigdr5.js} +57 -23
- package/dist/assert-BGdigdr5.js.map +1 -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-DweanHoB.mjs → compiler-BXcGyZUP.mjs} +577 -78
- 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-_te7t0M4.js → data-Ze8GNiJm.js} +23 -13
- 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 +389 -149
- 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-DS61nRqr.mjs → loader-DCT1Q9yi.mjs} +3 -3
- package/dist/{loader-DS61nRqr.mjs.map → loader-DCT1Q9yi.mjs.map} +1 -1
- package/dist/{misc-B9kqEb2N.mjs → misc-o8pviMUi.mjs} +7 -3
- package/dist/{misc-B9kqEb2N.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/{presets-Bye3ea2x.js → presets-BhXa232U.js} +3 -34
- package/dist/presets-BhXa232U.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-CyIj8LYK.mjs → registry-D3x1EDJm.mjs} +2 -2
- package/dist/{registry-CyIj8LYK.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/selector/index.js +3 -3
- package/dist/server.js +13 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-BAL9peIw.cjs → shared-B_gJf5uj.cjs} +577 -78
- package/dist/shared-B_gJf5uj.cjs.map +1 -0
- package/dist/{shared-CCpq1zqA.mjs → shared-uAzFeq0x.mjs} +4 -4
- package/dist/{shared-CCpq1zqA.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-4u6GnlQG.mjs → sidecar-BUO1hKXu.mjs} +3 -3
- package/dist/{sidecar-4u6GnlQG.mjs.map → sidecar-BUO1hKXu.mjs.map} +1 -1
- package/dist/style-B0F1sgRZ.js +5 -0
- package/dist/{style-4rFUy-zW.js → style-BkeAZl0n.js} +259 -83
- 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-DNqQ6H-7.js → style-DUztHzBz.js} +482 -152
- 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-C7xfDxtM.mjs → utils-CpA-dSpY.mjs} +4 -4
- package/dist/{utils-C7xfDxtM.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-DMFgOOtA.mjs → utils-DQGa0uzS.mjs} +3 -3
- package/dist/{utils-DMFgOOtA.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-CxS2FDYU.mjs → webpack-Fb9xF5jS.mjs} +5 -5
- package/dist/{webpack-CxS2FDYU.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 +16 -1
- package/plugin/bundler/vite/plugin.ts +2 -1
- package/plugin/bundler/vite/state.ts +11 -6
- 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/selector/assert.ts +24 -25
- package/selector/selector.ts +6 -0
- 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/assert-h_Zkqc4E.js.map +0 -1
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DweanHoB.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-_te7t0M4.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/presets-Bye3ea2x.js.map +0 -1
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-BAL9peIw.cjs.map +0 -1
- package/dist/style-4rFUy-zW.js.map +0 -1
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-Cw3NtvR0.js +0 -5
- package/dist/style-DNqQ6H-7.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
|
}
|
|
@@ -672,6 +711,9 @@ function selectorPriority(selectors, values) {
|
|
|
672
711
|
});
|
|
673
712
|
return selectors;
|
|
674
713
|
}
|
|
714
|
+
function createSelectorAssert(fn) {
|
|
715
|
+
return fn;
|
|
716
|
+
}
|
|
675
717
|
//#endregion
|
|
676
718
|
//#region selector/presets/selectors.ts
|
|
677
719
|
const PseudoSelectors = {
|
|
@@ -837,33 +879,33 @@ function assertSelector(type, value) {
|
|
|
837
879
|
default: throw new Error("unsupported selector type: " + value);
|
|
838
880
|
}
|
|
839
881
|
}
|
|
840
|
-
|
|
882
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
841
883
|
if (!value) throw new Error("selector cannot be empty");
|
|
842
|
-
}
|
|
843
|
-
|
|
884
|
+
});
|
|
885
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
844
886
|
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
845
|
-
}
|
|
846
|
-
|
|
887
|
+
});
|
|
888
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
847
889
|
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
848
|
-
}
|
|
849
|
-
|
|
890
|
+
});
|
|
891
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
850
892
|
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
851
|
-
}
|
|
852
|
-
|
|
893
|
+
});
|
|
894
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
853
895
|
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
854
|
-
}
|
|
855
|
-
|
|
896
|
+
});
|
|
897
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
856
898
|
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
857
|
-
}
|
|
858
|
-
|
|
899
|
+
});
|
|
900
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
859
901
|
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
860
|
-
}
|
|
861
|
-
|
|
902
|
+
});
|
|
903
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
862
904
|
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
863
|
-
}
|
|
864
|
-
|
|
905
|
+
});
|
|
906
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
865
907
|
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
866
|
-
}
|
|
908
|
+
});
|
|
867
909
|
//#endregion
|
|
868
910
|
//#region builder/data/check_selector.ts
|
|
869
911
|
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
@@ -950,7 +992,7 @@ function createNameFormatter(keys) {
|
|
|
950
992
|
const name = getFormatFn(format)(info);
|
|
951
993
|
if (!hash) return name;
|
|
952
994
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
953
|
-
return name ? name + "
|
|
995
|
+
return name ? name + "--" + hash : hash;
|
|
954
996
|
};
|
|
955
997
|
}
|
|
956
998
|
function compileFormat(format, keySet) {
|
|
@@ -1044,8 +1086,12 @@ const formatClassName = createNameFormatter([
|
|
|
1044
1086
|
"value"
|
|
1045
1087
|
]);
|
|
1046
1088
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
1089
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
1047
1090
|
function getDebugClassName(format, hash, info) {
|
|
1048
|
-
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);
|
|
1049
1095
|
}
|
|
1050
1096
|
function getDebugScopeClassName(format, info) {
|
|
1051
1097
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -1063,20 +1109,38 @@ function escapeCssValue(value) {
|
|
|
1063
1109
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1064
1110
|
}
|
|
1065
1111
|
function escapeCssIdent(ident) {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
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;
|
|
1070
1140
|
}
|
|
1071
1141
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
1072
1142
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
1073
1143
|
}
|
|
1074
|
-
function getIdentifierSafeHash(value) {
|
|
1075
|
-
const hash = hashString(value);
|
|
1076
|
-
const first = hash.charCodeAt(0);
|
|
1077
|
-
if (first < 48 || first > 57) return hash;
|
|
1078
|
-
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1079
|
-
}
|
|
1080
1144
|
//#endregion
|
|
1081
1145
|
//#region atomic/utils/debug.ts
|
|
1082
1146
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1234,6 +1298,54 @@ function parseAtRule(rule) {
|
|
|
1234
1298
|
return compressQuery(normalized);
|
|
1235
1299
|
}
|
|
1236
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
|
|
1237
1349
|
//#region atomic/utils/selector.ts
|
|
1238
1350
|
function getSelectorText(selector) {
|
|
1239
1351
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1247,7 +1359,7 @@ function getSelectorPriority(selector) {
|
|
|
1247
1359
|
}
|
|
1248
1360
|
//#endregion
|
|
1249
1361
|
//#region atomic/className.ts
|
|
1250
|
-
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) {
|
|
1251
1363
|
let hash = property;
|
|
1252
1364
|
hash += "\n" + (priority || "");
|
|
1253
1365
|
hash += "\n" + value;
|
|
@@ -1255,8 +1367,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1255
1367
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1256
1368
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1257
1369
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1258
|
-
hash = getIdentifierSafeHash(hash);
|
|
1370
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1259
1371
|
if (!debugClassName) return hash;
|
|
1372
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1260
1373
|
const propertyName = getDebugPropertyName(property, value);
|
|
1261
1374
|
return getDebugClassName(classNameFormat, hash, {
|
|
1262
1375
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1266,6 +1379,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1266
1379
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1267
1380
|
});
|
|
1268
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
|
+
}
|
|
1269
1386
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1270
1387
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1271
1388
|
}
|
|
@@ -1354,7 +1471,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1354
1471
|
value = value[0];
|
|
1355
1472
|
}
|
|
1356
1473
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1357
|
-
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);
|
|
1358
1475
|
scopeItem.dedupe = dedupe;
|
|
1359
1476
|
scopeItem.className = className;
|
|
1360
1477
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1392,6 +1509,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1392
1509
|
className: "",
|
|
1393
1510
|
property: overrideItem.property,
|
|
1394
1511
|
value: overrideItem.value,
|
|
1512
|
+
transformClassName: overrideItem.transformClassName,
|
|
1395
1513
|
token: overrideItem.token,
|
|
1396
1514
|
selector: overrideItem.selector,
|
|
1397
1515
|
atRule,
|
|
@@ -1407,7 +1525,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1407
1525
|
value = value[0];
|
|
1408
1526
|
}
|
|
1409
1527
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1410
|
-
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);
|
|
1411
1529
|
scopeItem.dedupe = dedupe;
|
|
1412
1530
|
scopeItem.className = className;
|
|
1413
1531
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1475,7 +1593,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1475
1593
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1476
1594
|
function getTokenVarName(token, format) {
|
|
1477
1595
|
const id = getStyleTokenId(token);
|
|
1478
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1596
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1479
1597
|
}
|
|
1480
1598
|
function getTokenVar(token, format) {
|
|
1481
1599
|
return getTokenVarFallback(token, format);
|
|
@@ -1550,6 +1668,19 @@ function shouldAppendCssPx(property) {
|
|
|
1550
1668
|
return !UNITLESS.has(property);
|
|
1551
1669
|
}
|
|
1552
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
|
|
1553
1684
|
//#region style/valueRef.ts
|
|
1554
1685
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1555
1686
|
function createAtRuleRef(data) {
|
|
@@ -1579,6 +1710,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1579
1710
|
let token;
|
|
1580
1711
|
let ref;
|
|
1581
1712
|
let variableName;
|
|
1713
|
+
let transformClassName;
|
|
1582
1714
|
let lookupIndex;
|
|
1583
1715
|
if (isStyleData(style)) {
|
|
1584
1716
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1616,6 +1748,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1616
1748
|
priority = valueRaw[0];
|
|
1617
1749
|
valueRaw = valueRaw[1];
|
|
1618
1750
|
}
|
|
1751
|
+
transformClassName = null;
|
|
1752
|
+
if (isClassNameValue(valueRaw)) {
|
|
1753
|
+
transformClassName = valueRaw.className;
|
|
1754
|
+
valueRaw = valueRaw.value;
|
|
1755
|
+
}
|
|
1619
1756
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1620
1757
|
if (ref) valueRaw = ref.value;
|
|
1621
1758
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1631,6 +1768,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1631
1768
|
className: "",
|
|
1632
1769
|
property,
|
|
1633
1770
|
value,
|
|
1771
|
+
transformClassName,
|
|
1634
1772
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1635
1773
|
1,
|
|
1636
1774
|
variableName,
|
|
@@ -1695,7 +1833,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1695
1833
|
value = value[0];
|
|
1696
1834
|
}
|
|
1697
1835
|
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1698
|
-
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);
|
|
1699
1837
|
runtimeItem.dedupe = dedupe;
|
|
1700
1838
|
runtimeItem.className = className;
|
|
1701
1839
|
lookupIndex = lookup[dedupe];
|
|
@@ -2492,7 +2630,7 @@ function getCssPropertyName(property) {
|
|
|
2492
2630
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2493
2631
|
const formatter = createNameFormatter(["name"]);
|
|
2494
2632
|
return (format, id, info) => {
|
|
2495
|
-
const hash = getIdentifierSafeHash(id);
|
|
2633
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2496
2634
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2497
2635
|
if (!prefix) return name;
|
|
2498
2636
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2703,11 +2841,11 @@ function createStyleFn(args) {
|
|
|
2703
2841
|
style.plain = fnPlain;
|
|
2704
2842
|
style.keyframes = fnKeyframes;
|
|
2705
2843
|
style.merge = fnMerge;
|
|
2706
|
-
|
|
2844
|
+
assignStyleFnMeta(style, {
|
|
2845
|
+
mode: "StyleObject",
|
|
2707
2846
|
selectors,
|
|
2708
2847
|
transform: transform ?? null
|
|
2709
|
-
};
|
|
2710
|
-
Object.assign(style, { [META]: meta });
|
|
2848
|
+
});
|
|
2711
2849
|
return { style };
|
|
2712
2850
|
}
|
|
2713
2851
|
function mergeStyleResult(target, style) {
|
|
@@ -2716,12 +2854,17 @@ function mergeStyleResult(target, style) {
|
|
|
2716
2854
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2717
2855
|
return target;
|
|
2718
2856
|
}
|
|
2857
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2858
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2859
|
+
return styleFn;
|
|
2860
|
+
}
|
|
2719
2861
|
function getStyleFnMeta(styleFn) {
|
|
2720
2862
|
return styleFn[META];
|
|
2721
2863
|
}
|
|
2722
2864
|
//#endregion
|
|
2723
2865
|
//#region compiler/utils/import_source.ts
|
|
2724
2866
|
const DefaultStyleFnMeta = {
|
|
2867
|
+
mode: "StyleObject",
|
|
2725
2868
|
selectors: PrioritySelectors,
|
|
2726
2869
|
transform: null
|
|
2727
2870
|
};
|
|
@@ -2974,6 +3117,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2974
3117
|
}
|
|
2975
3118
|
}
|
|
2976
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
|
|
2977
3179
|
//#region style/utils/expose.ts
|
|
2978
3180
|
function exposeStyle(styles) {
|
|
2979
3181
|
return exposeStyleObject(styles);
|
|
@@ -3029,6 +3231,7 @@ function evaluateNode(node, scope) {
|
|
|
3029
3231
|
case "ParenthesizedExpression":
|
|
3030
3232
|
case "TSAsExpression":
|
|
3031
3233
|
case "TSNonNullExpression":
|
|
3234
|
+
case "TSSatisfiesExpression":
|
|
3032
3235
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
3033
3236
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
3034
3237
|
}
|
|
@@ -3101,14 +3304,14 @@ function evaluateMember(node, scope) {
|
|
|
3101
3304
|
if (!key.ok) return key;
|
|
3102
3305
|
const obj = evaluateNode(node.object, scope);
|
|
3103
3306
|
if (!obj.ok) return obj;
|
|
3104
|
-
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]);
|
|
3105
3308
|
return evalFail("Cannot index non-object");
|
|
3106
3309
|
}
|
|
3107
3310
|
const prop = node.property.name;
|
|
3108
3311
|
const obj = evaluateNode(node.object, scope);
|
|
3109
3312
|
if (!obj.ok) return obj;
|
|
3110
3313
|
if (obj.value == null) return evalFail(`Cannot access .${prop} on null/undefined`);
|
|
3111
|
-
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}`);
|
|
3112
3315
|
return evalOk(obj.value[prop]);
|
|
3113
3316
|
}
|
|
3114
3317
|
function evaluateObject(node, scope) {
|
|
@@ -3147,7 +3350,7 @@ function evaluateObject(node, scope) {
|
|
|
3147
3350
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
3148
3351
|
const val = evaluateNode(prop.value, scope);
|
|
3149
3352
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3150
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3353
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3151
3354
|
if (prop.loc?.start) locations[key] = {
|
|
3152
3355
|
line: prop.loc.start.line,
|
|
3153
3356
|
column: prop.loc.start.column + 1,
|
|
@@ -3312,6 +3515,23 @@ function evaluateCall(node, scope) {
|
|
|
3312
3515
|
if (!debugId.ok) return debugId;
|
|
3313
3516
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3314
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
|
+
}
|
|
3315
3535
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3316
3536
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3317
3537
|
if (!styles.ok) return styles;
|
|
@@ -3481,6 +3701,8 @@ function createCompiledValues(values, scope, loc, runtimeValue, debugId, isNumbe
|
|
|
3481
3701
|
};
|
|
3482
3702
|
}
|
|
3483
3703
|
function parseCompiledValue(value, isNumber) {
|
|
3704
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
3705
|
+
value = String(value).split(/[;|]/)[0].trim();
|
|
3484
3706
|
if (!isNumber) return value;
|
|
3485
3707
|
const number = Number(value);
|
|
3486
3708
|
if (!Number.isFinite(number)) return value;
|
|
@@ -3522,7 +3744,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3522
3744
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3523
3745
|
});
|
|
3524
3746
|
}
|
|
3525
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3747
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3526
3748
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3527
3749
|
}
|
|
3528
3750
|
function evaluateBinary(node, scope) {
|
|
@@ -3578,7 +3800,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3578
3800
|
}
|
|
3579
3801
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3580
3802
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3581
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3803
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3582
3804
|
}
|
|
3583
3805
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3584
3806
|
const declarations = [];
|
|
@@ -3875,12 +4097,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3875
4097
|
}
|
|
3876
4098
|
const formatVarName = createNameFormatter(["name"]);
|
|
3877
4099
|
function getLocalVarName(filePath, line, column, format) {
|
|
3878
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
4100
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3879
4101
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3880
4102
|
}
|
|
3881
4103
|
//#endregion
|
|
3882
4104
|
//#region compiler/transform/debug/utils/debug_data.ts
|
|
3883
|
-
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) {
|
|
3884
4106
|
const loc = locOverride ?? node.loc?.start;
|
|
3885
4107
|
const line = loc?.line ?? 1;
|
|
3886
4108
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3897,10 +4119,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3897
4119
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3898
4120
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3899
4121
|
];
|
|
4122
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3900
4123
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3901
4124
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3902
4125
|
return t.objectExpression(properties);
|
|
3903
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
|
+
}
|
|
3904
4162
|
function getShortLabel(label) {
|
|
3905
4163
|
const parts = label.split(".");
|
|
3906
4164
|
return parts[parts.length - 1] || label;
|
|
@@ -4059,7 +4317,9 @@ function createDebugPlugin(args) {
|
|
|
4059
4317
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
4060
4318
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
4061
4319
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
4062
|
-
|
|
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));
|
|
4063
4323
|
},
|
|
4064
4324
|
JSXOpeningElement(path, state) {
|
|
4065
4325
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4650,6 +4910,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4650
4910
|
//#region compiler/utils/file_resolver.ts
|
|
4651
4911
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4652
4912
|
const resolver = new oxc_resolver.ResolverFactory({
|
|
4913
|
+
conditionNames: [
|
|
4914
|
+
"import",
|
|
4915
|
+
"module",
|
|
4916
|
+
"default",
|
|
4917
|
+
"types"
|
|
4918
|
+
],
|
|
4653
4919
|
extensions: [
|
|
4654
4920
|
".ts",
|
|
4655
4921
|
".tsx",
|
|
@@ -4809,8 +5075,101 @@ function extractStyleChain(node, styleNames) {
|
|
|
4809
5075
|
}
|
|
4810
5076
|
//#endregion
|
|
4811
5077
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4812
|
-
function applyTransform(styleObj, transform) {
|
|
4813
|
-
|
|
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;
|
|
4814
5173
|
}
|
|
4815
5174
|
/**
|
|
4816
5175
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
@@ -4818,6 +5177,10 @@ function applyTransform(styleObj, transform) {
|
|
|
4818
5177
|
*/
|
|
4819
5178
|
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4820
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
|
+
}
|
|
4821
5184
|
const selectors = meta.selectors;
|
|
4822
5185
|
const transform = meta.transform;
|
|
4823
5186
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4829,6 +5192,8 @@ function getCssConfig(opts) {
|
|
|
4829
5192
|
const css = opts.css;
|
|
4830
5193
|
return {
|
|
4831
5194
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5195
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5196
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4832
5197
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4833
5198
|
localClassName: css?.localClassName ?? DEFAULT_CONFIG.localClassName,
|
|
4834
5199
|
debugClassName: css?.debugClassName ?? DEFAULT_CONFIG.debugClassName,
|
|
@@ -4849,6 +5214,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4849
5214
|
rules
|
|
4850
5215
|
};
|
|
4851
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
|
+
}
|
|
4852
5344
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4853
5345
|
if (chain.baseArgs.length > 0) {
|
|
4854
5346
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4856,7 +5348,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4856
5348
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4857
5349
|
return false;
|
|
4858
5350
|
}
|
|
4859
|
-
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;
|
|
4860
5352
|
}
|
|
4861
5353
|
let i = 0;
|
|
4862
5354
|
while (i < chain.methods.length) {
|
|
@@ -4875,7 +5367,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4875
5367
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4876
5368
|
return null;
|
|
4877
5369
|
}
|
|
4878
|
-
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;
|
|
4879
5371
|
}
|
|
4880
5372
|
let i = 0;
|
|
4881
5373
|
while (i < chain.methods.length) {
|
|
@@ -4993,14 +5485,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4993
5485
|
return true;
|
|
4994
5486
|
}
|
|
4995
5487
|
if (node.type !== "CallExpression") return false;
|
|
4996
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5488
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
4997
5489
|
if (!overrideChain) return false;
|
|
4998
5490
|
const { slotId, items: overrideItems } = overrideChain;
|
|
4999
5491
|
let i = 0;
|
|
5000
5492
|
while (i < overrideItems.length) {
|
|
5001
5493
|
const overrideItem = overrideItems[i];
|
|
5002
5494
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
5003
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5495
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
5004
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;
|
|
5005
5497
|
} else if (overrideItem.styleData !== void 0) {
|
|
5006
5498
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -5009,15 +5501,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
5009
5501
|
}
|
|
5010
5502
|
return true;
|
|
5011
5503
|
}
|
|
5012
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5504
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
5013
5505
|
const callee = node.callee;
|
|
5014
5506
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
5015
5507
|
const methodName = callee.property.name;
|
|
5016
5508
|
const obj = callee.object;
|
|
5017
5509
|
if (obj.type === "CallExpression") {
|
|
5018
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5510
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
5019
5511
|
if (!inner) return null;
|
|
5020
|
-
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);
|
|
5021
5513
|
if (!overrideItem) return null;
|
|
5022
5514
|
return {
|
|
5023
5515
|
slotId: inner.slotId,
|
|
@@ -5032,7 +5524,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5032
5524
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
5033
5525
|
if (!styleArg.ok) return null;
|
|
5034
5526
|
items.push({
|
|
5035
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5527
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5036
5528
|
selector: null,
|
|
5037
5529
|
atRules: null
|
|
5038
5530
|
});
|
|
@@ -5042,7 +5534,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
5042
5534
|
items
|
|
5043
5535
|
};
|
|
5044
5536
|
}
|
|
5045
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5537
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
5046
5538
|
const sel = selectors[methodName];
|
|
5047
5539
|
if (!sel) return null;
|
|
5048
5540
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -5069,7 +5561,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5069
5561
|
callsiteOverride
|
|
5070
5562
|
};
|
|
5071
5563
|
return {
|
|
5072
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5564
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
5073
5565
|
selector: null,
|
|
5074
5566
|
atRules: null,
|
|
5075
5567
|
callsiteOverride
|
|
@@ -5094,7 +5586,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5094
5586
|
if (!styleArg.ok) return null;
|
|
5095
5587
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5096
5588
|
return {
|
|
5097
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5589
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5098
5590
|
selector: null,
|
|
5099
5591
|
atRules: [atRuleSelector]
|
|
5100
5592
|
};
|
|
@@ -5110,7 +5602,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5110
5602
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5111
5603
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
5112
5604
|
return {
|
|
5113
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5605
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5114
5606
|
selector: itemSelector,
|
|
5115
5607
|
atRules: null
|
|
5116
5608
|
};
|
|
@@ -5118,7 +5610,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5118
5610
|
const styleArg = evaluateNode(args[0], scope);
|
|
5119
5611
|
if (!styleArg.ok) return null;
|
|
5120
5612
|
return {
|
|
5121
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5613
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5122
5614
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5123
5615
|
atRules: null
|
|
5124
5616
|
};
|
|
@@ -5202,7 +5694,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5202
5694
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5203
5695
|
return false;
|
|
5204
5696
|
}
|
|
5205
|
-
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);
|
|
5206
5698
|
}
|
|
5207
5699
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5208
5700
|
if (!styleArgNode) return false;
|
|
@@ -5283,14 +5775,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5283
5775
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5284
5776
|
return false;
|
|
5285
5777
|
}
|
|
5286
|
-
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);
|
|
5287
5779
|
}
|
|
5288
5780
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5289
5781
|
if (!styleResult.ok) {
|
|
5290
5782
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5291
5783
|
return false;
|
|
5292
5784
|
}
|
|
5293
|
-
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);
|
|
5294
5786
|
}
|
|
5295
5787
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5296
5788
|
const selectorStr = selector.selector.trim();
|
|
@@ -5309,7 +5801,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5309
5801
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5310
5802
|
if (!styleResult.ok) return false;
|
|
5311
5803
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5312
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5804
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5313
5805
|
let i = 0;
|
|
5314
5806
|
while (i < selectorValues.length) {
|
|
5315
5807
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5437,7 +5929,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5437
5929
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5438
5930
|
const valueStr = String(value ?? "");
|
|
5439
5931
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
5440
|
-
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);
|
|
5441
5933
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5442
5934
|
items.push(item);
|
|
5443
5935
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5518,7 +6010,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5518
6010
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5519
6011
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5520
6012
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5521
|
-
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);
|
|
5522
6014
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5523
6015
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5524
6016
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5586,10 +6078,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5586
6078
|
const rawValue = styleObj[property];
|
|
5587
6079
|
let priority = null;
|
|
5588
6080
|
let value = rawValue;
|
|
6081
|
+
let transformClassName = null;
|
|
5589
6082
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5590
6083
|
priority = rawValue[0];
|
|
5591
6084
|
value = rawValue[1];
|
|
5592
6085
|
}
|
|
6086
|
+
if (isClassNameValue(value)) {
|
|
6087
|
+
transformClassName = value.className;
|
|
6088
|
+
value = value.value;
|
|
6089
|
+
}
|
|
5593
6090
|
if (value === null || value === void 0) {
|
|
5594
6091
|
i++;
|
|
5595
6092
|
continue;
|
|
@@ -5609,7 +6106,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5609
6106
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5610
6107
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5611
6108
|
const dedupe = getClassNameDedupe(property, priority, selector, parentSelector, atRules);
|
|
5612
|
-
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);
|
|
5613
6110
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5614
6111
|
item.sourceTrace = propertyCallsite ? {
|
|
5615
6112
|
property,
|
|
@@ -6783,13 +7280,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6783
7280
|
const body = path.node.body;
|
|
6784
7281
|
let firstRuntimeIndex = 0;
|
|
6785
7282
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7283
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6786
7284
|
declarations.forEach((item) => {
|
|
6787
|
-
let insertIndex =
|
|
7285
|
+
let insertIndex = runtimeInsertIndex;
|
|
6788
7286
|
item.dependencies.forEach((name) => {
|
|
6789
7287
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6790
7288
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6791
7289
|
});
|
|
6792
7290
|
body.splice(insertIndex, 0, item.declaration);
|
|
7291
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6793
7292
|
});
|
|
6794
7293
|
}
|
|
6795
7294
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -7643,4 +8142,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
7643
8142
|
}
|
|
7644
8143
|
});
|
|
7645
8144
|
|
|
7646
|
-
//# sourceMappingURL=shared-
|
|
8145
|
+
//# sourceMappingURL=shared-B_gJf5uj.cjs.map
|