@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
|
@@ -148,6 +148,9 @@ function hashString(str) {
|
|
|
148
148
|
for (let i = 0; i < str.length; i++) hash = Math.imul(hash ^ str.charCodeAt(i), 16777619);
|
|
149
149
|
return (hash >>> 0).toString(36).padEnd(7, "0");
|
|
150
150
|
}
|
|
151
|
+
function normalizeHashLength(length) {
|
|
152
|
+
return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
|
|
153
|
+
}
|
|
151
154
|
//#endregion
|
|
152
155
|
//#region atomic/layer/layer.ts
|
|
153
156
|
function compareLayerPriority(p1, p2) {
|
|
@@ -232,7 +235,8 @@ const DEV_CONFIG_DEFAULT = {
|
|
|
232
235
|
isLocalClassNameEnabled: true,
|
|
233
236
|
sheetMaxRules: 1e3,
|
|
234
237
|
sheetStyleTagNonce: null,
|
|
235
|
-
|
|
238
|
+
hashLength: null,
|
|
239
|
+
stylePriorityMode: "sort",
|
|
236
240
|
sourcemapLocationMode: "style",
|
|
237
241
|
isElementClassNameEnabled: true
|
|
238
242
|
};
|
|
@@ -243,6 +247,7 @@ globalData("config.dev.base", () => ({ config: null }));
|
|
|
243
247
|
globalData("config.dev.utils", () => ({ config: null }));
|
|
244
248
|
const STYLE_IMPORT_PATH = "@fluentic/style";
|
|
245
249
|
const STYLE_CSS_IMPORT_PATH = "@fluentic/style/css";
|
|
250
|
+
const STYLE_DIALECT_IMPORT_PATH = "@fluentic/style/dialect";
|
|
246
251
|
const STYLE_DEV_RSC_IMPORT_PATH = "@fluentic/style/dev/rsc";
|
|
247
252
|
const STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH = "@fluentic/style/entry/prod/extract";
|
|
248
253
|
const STYLE_EXTRACT_RUNTIME_IMPORT_PATH = "@fluentic/style/entry/prod/runtime";
|
|
@@ -255,6 +260,7 @@ const DEFAULT_CONFIG = {
|
|
|
255
260
|
const IMPORT_PATHS = [
|
|
256
261
|
STYLE_IMPORT_PATH,
|
|
257
262
|
STYLE_CSS_IMPORT_PATH,
|
|
263
|
+
STYLE_DIALECT_IMPORT_PATH,
|
|
258
264
|
STYLE_DEV_RSC_IMPORT_PATH
|
|
259
265
|
];
|
|
260
266
|
const IMPORT_EXTRACT = STYLE_ENTRY_PROD_EXTRACT_IMPORT_PATH;
|
|
@@ -297,9 +303,6 @@ function getExtractedCssItems(items, args) {
|
|
|
297
303
|
const layerNamespace = args.layerNamespace ?? defaults.layerNamespace ?? "";
|
|
298
304
|
return getLayerBundleCss(args.layers ?? defaults.layers ?? [], layerNamespace, css.map((item) => item.css));
|
|
299
305
|
}
|
|
300
|
-
function normalizeSelectorArg(arg) {
|
|
301
|
-
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
302
|
-
}
|
|
303
306
|
//#endregion
|
|
304
307
|
//#region builder/data/const.ts
|
|
305
308
|
const BUILDER_TYPE = symbol("builder.type");
|
|
@@ -475,12 +478,48 @@ function getBuilderType(value) {
|
|
|
475
478
|
if (!value || typeof value !== "object" && typeof value !== "function") return null;
|
|
476
479
|
return value[BUILDER_TYPE];
|
|
477
480
|
}
|
|
481
|
+
function normalizeSelectorArg(arg) {
|
|
482
|
+
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
483
|
+
}
|
|
478
484
|
//#endregion
|
|
479
485
|
//#region style/token.ts
|
|
480
486
|
const TOKEN_ID = symbol("style:token");
|
|
481
487
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
482
|
-
symbol("style:token.debug");
|
|
483
|
-
globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
488
|
+
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
489
|
+
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
490
|
+
function createStyleToken(value, debugId) {
|
|
491
|
+
const token = (value, debug) => {
|
|
492
|
+
return createStyleTokenOverride(token, value, debug);
|
|
493
|
+
};
|
|
494
|
+
token[TOKEN_ID] = debugId || String(idCounter$6.value++);
|
|
495
|
+
if (isStyleTokenData(value)) {
|
|
496
|
+
token.value = value.value;
|
|
497
|
+
token.ref = value;
|
|
498
|
+
} else {
|
|
499
|
+
token.value = value;
|
|
500
|
+
token.ref = null;
|
|
501
|
+
}
|
|
502
|
+
return token;
|
|
503
|
+
}
|
|
504
|
+
function createStyleTokenOverride(token, value, debug) {
|
|
505
|
+
const override = isStyleTokenData(value) ? {
|
|
506
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
507
|
+
[TOKEN_OVERRIDE]: true,
|
|
508
|
+
value: value.value,
|
|
509
|
+
ref: value
|
|
510
|
+
} : {
|
|
511
|
+
[TOKEN_ID]: getStyleTokenId(token),
|
|
512
|
+
[TOKEN_OVERRIDE]: true,
|
|
513
|
+
value,
|
|
514
|
+
ref: null
|
|
515
|
+
};
|
|
516
|
+
if (debug) Object.defineProperty(override, TOKEN_DEBUG, {
|
|
517
|
+
configurable: true,
|
|
518
|
+
enumerable: false,
|
|
519
|
+
value: debug
|
|
520
|
+
});
|
|
521
|
+
return override;
|
|
522
|
+
}
|
|
484
523
|
function isStyleTokenData(value) {
|
|
485
524
|
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
486
525
|
}
|
|
@@ -522,6 +561,9 @@ function selectorPriority(selectors, values) {
|
|
|
522
561
|
});
|
|
523
562
|
return selectors;
|
|
524
563
|
}
|
|
564
|
+
function createSelectorAssert(fn) {
|
|
565
|
+
return fn;
|
|
566
|
+
}
|
|
525
567
|
//#endregion
|
|
526
568
|
//#region selector/presets/selectors.ts
|
|
527
569
|
const PseudoSelectors = {
|
|
@@ -687,33 +729,33 @@ function assertSelector(type, value) {
|
|
|
687
729
|
default: throw new Error("unsupported selector type: " + value);
|
|
688
730
|
}
|
|
689
731
|
}
|
|
690
|
-
|
|
732
|
+
const assertSelectorNotEmpty = createSelectorAssert((value) => {
|
|
691
733
|
if (!value) throw new Error("selector cannot be empty");
|
|
692
|
-
}
|
|
693
|
-
|
|
734
|
+
});
|
|
735
|
+
const assertLocalSelector = createSelectorAssert((value) => {
|
|
694
736
|
if (!isLocalSelector(value)) throw new Error("selector must target the current element only and cannot contain tags, combinators, or multiple selectors");
|
|
695
|
-
}
|
|
696
|
-
|
|
737
|
+
});
|
|
738
|
+
const assertPseudoArgSelector = createSelectorAssert((value) => {
|
|
697
739
|
if (!isPseudoArgSelector(value)) throw new Error("pseudo selector argument must contain only tags or selectors targeting the current element");
|
|
698
|
-
}
|
|
699
|
-
|
|
740
|
+
});
|
|
741
|
+
const assertTagSelector = createSelectorAssert((value) => {
|
|
700
742
|
if (!isTagSelector(value)) throw new Error("selector must be a single tag selector");
|
|
701
|
-
}
|
|
702
|
-
|
|
743
|
+
});
|
|
744
|
+
const assertAttrSelector = createSelectorAssert((value) => {
|
|
703
745
|
if (!isAttrArg(value)) throw new Error("attribute selector value must not include \"[\" or \"]\"");
|
|
704
|
-
}
|
|
705
|
-
|
|
746
|
+
});
|
|
747
|
+
const assertRawValue = createSelectorAssert((value) => {
|
|
706
748
|
if (!isRawValue(value)) throw new Error("value must not contain \"{\" or \"}\"");
|
|
707
|
-
}
|
|
708
|
-
|
|
749
|
+
});
|
|
750
|
+
const assertMediaQuery = createSelectorAssert((value) => {
|
|
709
751
|
if (!isRawValue(value)) throw new Error("media query must not contain \"{\" or \"}\"");
|
|
710
|
-
}
|
|
711
|
-
|
|
752
|
+
});
|
|
753
|
+
const assertSupportsQuery = createSelectorAssert((value) => {
|
|
712
754
|
if (!isRawValue(value)) throw new Error("supports query must not contain \"{\" or \"}\"");
|
|
713
|
-
}
|
|
714
|
-
|
|
755
|
+
});
|
|
756
|
+
const assertContainerQuery = createSelectorAssert((value) => {
|
|
715
757
|
if (!isRawValue(value)) throw new Error("container query must not contain \"{\" or \"}\"");
|
|
716
|
-
}
|
|
758
|
+
});
|
|
717
759
|
//#endregion
|
|
718
760
|
//#region builder/data/check_selector.ts
|
|
719
761
|
function checkSelector(fnPrefix, fnName, fnSelector, arg) {
|
|
@@ -800,7 +842,7 @@ function createNameFormatter(keys) {
|
|
|
800
842
|
const name = getFormatFn(format)(info);
|
|
801
843
|
if (!hash) return name;
|
|
802
844
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
803
|
-
return name ? name + "
|
|
845
|
+
return name ? name + "--" + hash : hash;
|
|
804
846
|
};
|
|
805
847
|
}
|
|
806
848
|
function compileFormat(format, keySet) {
|
|
@@ -894,8 +936,12 @@ const formatClassName = createNameFormatter([
|
|
|
894
936
|
"value"
|
|
895
937
|
]);
|
|
896
938
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
939
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
897
940
|
function getDebugClassName(format, hash, info) {
|
|
898
|
-
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]
|
|
941
|
+
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
942
|
+
}
|
|
943
|
+
function getDebugTransformClassName(format, hash, info) {
|
|
944
|
+
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
899
945
|
}
|
|
900
946
|
function getDebugScopeClassName(format, info) {
|
|
901
947
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -913,20 +959,38 @@ function escapeCssValue(value) {
|
|
|
913
959
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
914
960
|
}
|
|
915
961
|
function escapeCssIdent(ident) {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
962
|
+
let result = "";
|
|
963
|
+
for (let i = 0; i < ident.length; i++) {
|
|
964
|
+
const char = ident.charAt(i);
|
|
965
|
+
const code = ident.charCodeAt(i);
|
|
966
|
+
const nextCode = ident.charCodeAt(i + 1);
|
|
967
|
+
if (code === 0) {
|
|
968
|
+
result += "�";
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
|
|
972
|
+
result += "\\" + code.toString(16) + " ";
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
if (i === 0 && code === 45 && ident.length === 1) {
|
|
976
|
+
result += "\\-";
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
|
|
980
|
+
result += char + ident.charAt(++i);
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
|
|
984
|
+
result += char;
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
result += "\\" + char;
|
|
988
|
+
}
|
|
989
|
+
return result;
|
|
920
990
|
}
|
|
921
991
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
922
992
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
923
993
|
}
|
|
924
|
-
function getIdentifierSafeHash(value) {
|
|
925
|
-
const hash = hashString(value);
|
|
926
|
-
const first = hash.charCodeAt(0);
|
|
927
|
-
if (first < 48 || first > 57) return hash;
|
|
928
|
-
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
929
|
-
}
|
|
930
994
|
//#endregion
|
|
931
995
|
//#region atomic/utils/debug.ts
|
|
932
996
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1084,6 +1148,54 @@ function parseAtRule(rule) {
|
|
|
1084
1148
|
return compressQuery(normalized);
|
|
1085
1149
|
}
|
|
1086
1150
|
//#endregion
|
|
1151
|
+
//#region atomic/utils/hash.ts
|
|
1152
|
+
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
1153
|
+
byValue: /* @__PURE__ */ new Map(),
|
|
1154
|
+
byHash: /* @__PURE__ */ new Map(),
|
|
1155
|
+
usedByLength: []
|
|
1156
|
+
}));
|
|
1157
|
+
function getIdentifierSafeHash(value, startLength = 7) {
|
|
1158
|
+
return getPooledHash(value, startLength);
|
|
1159
|
+
}
|
|
1160
|
+
function getPooledHash(value, startLength) {
|
|
1161
|
+
const normalizedStartLength = normalizeHashLength(startLength);
|
|
1162
|
+
const valueKey = normalizedStartLength + "\0" + value;
|
|
1163
|
+
const existing = POOLED_HASH_STATE.byValue.get(valueKey);
|
|
1164
|
+
if (existing) return existing;
|
|
1165
|
+
let length = normalizedStartLength;
|
|
1166
|
+
while (true) {
|
|
1167
|
+
if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
|
|
1168
|
+
length++;
|
|
1169
|
+
continue;
|
|
1170
|
+
}
|
|
1171
|
+
for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
|
|
1172
|
+
const hash = getPooledHashCandidate(value, length, index);
|
|
1173
|
+
const owner = POOLED_HASH_STATE.byHash.get(hash);
|
|
1174
|
+
if (owner !== void 0 && owner !== valueKey) continue;
|
|
1175
|
+
POOLED_HASH_STATE.byValue.set(valueKey, hash);
|
|
1176
|
+
POOLED_HASH_STATE.byHash.set(hash, valueKey);
|
|
1177
|
+
POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
|
|
1178
|
+
return hash;
|
|
1179
|
+
}
|
|
1180
|
+
length++;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
function getPooledHashCandidate(value, length, index) {
|
|
1184
|
+
return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
|
|
1185
|
+
}
|
|
1186
|
+
function getPooledHashUsedCount(length) {
|
|
1187
|
+
return POOLED_HASH_STATE.usedByLength[length] ?? 0;
|
|
1188
|
+
}
|
|
1189
|
+
function getIdentifierSafeHashPoolSize(length) {
|
|
1190
|
+
if (length <= 0) return 0;
|
|
1191
|
+
return 26 * 36 ** (length - 1);
|
|
1192
|
+
}
|
|
1193
|
+
function getIdentifierSafeHashValue(hash) {
|
|
1194
|
+
const first = hash.charCodeAt(0);
|
|
1195
|
+
if (first < 48 || first > 57) return hash;
|
|
1196
|
+
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
1197
|
+
}
|
|
1198
|
+
//#endregion
|
|
1087
1199
|
//#region atomic/utils/selector.ts
|
|
1088
1200
|
function getSelectorText(selector) {
|
|
1089
1201
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1097,7 +1209,7 @@ function getSelectorPriority(selector) {
|
|
|
1097
1209
|
}
|
|
1098
1210
|
//#endregion
|
|
1099
1211
|
//#region atomic/className.ts
|
|
1100
|
-
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat) {
|
|
1212
|
+
function getAtomicClassName(property, priority, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, hashLength = null) {
|
|
1101
1213
|
let hash = property;
|
|
1102
1214
|
hash += "\n" + (priority || "");
|
|
1103
1215
|
hash += "\n" + value;
|
|
@@ -1105,8 +1217,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1105
1217
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1106
1218
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1107
1219
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1108
|
-
hash = getIdentifierSafeHash(hash);
|
|
1220
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1109
1221
|
if (!debugClassName) return hash;
|
|
1222
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1110
1223
|
const propertyName = getDebugPropertyName(property, value);
|
|
1111
1224
|
return getDebugClassName(classNameFormat, hash, {
|
|
1112
1225
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1116,6 +1229,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1116
1229
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1117
1230
|
});
|
|
1118
1231
|
}
|
|
1232
|
+
function getRuntimeClassNameHashLength(debugClassName) {
|
|
1233
|
+
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1234
|
+
return CSS_CONFIG.hashLength ?? 7;
|
|
1235
|
+
}
|
|
1119
1236
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1120
1237
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1121
1238
|
}
|
|
@@ -1204,7 +1321,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1204
1321
|
value = value[0];
|
|
1205
1322
|
}
|
|
1206
1323
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1207
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1324
|
+
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);
|
|
1208
1325
|
scopeItem.dedupe = dedupe;
|
|
1209
1326
|
scopeItem.className = className;
|
|
1210
1327
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1242,6 +1359,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1242
1359
|
className: "",
|
|
1243
1360
|
property: overrideItem.property,
|
|
1244
1361
|
value: overrideItem.value,
|
|
1362
|
+
transformClassName: overrideItem.transformClassName,
|
|
1245
1363
|
token: overrideItem.token,
|
|
1246
1364
|
selector: overrideItem.selector,
|
|
1247
1365
|
atRule,
|
|
@@ -1257,7 +1375,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1257
1375
|
value = value[0];
|
|
1258
1376
|
}
|
|
1259
1377
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1260
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1378
|
+
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);
|
|
1261
1379
|
scopeItem.dedupe = dedupe;
|
|
1262
1380
|
scopeItem.className = className;
|
|
1263
1381
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1325,7 +1443,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1325
1443
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1326
1444
|
function getTokenVarName(token, format) {
|
|
1327
1445
|
const id = getStyleTokenId(token);
|
|
1328
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1446
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1329
1447
|
}
|
|
1330
1448
|
function getTokenVar(token, format) {
|
|
1331
1449
|
return getTokenVarFallback(token, format);
|
|
@@ -1400,6 +1518,19 @@ function shouldAppendCssPx(property) {
|
|
|
1400
1518
|
return !UNITLESS.has(property);
|
|
1401
1519
|
}
|
|
1402
1520
|
//#endregion
|
|
1521
|
+
//#region style/transform.ts
|
|
1522
|
+
const CLASS_NAME_VALUE = symbol("transform.classNameValue");
|
|
1523
|
+
function classNameValue(value, className) {
|
|
1524
|
+
return {
|
|
1525
|
+
[CLASS_NAME_VALUE]: true,
|
|
1526
|
+
value,
|
|
1527
|
+
className
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function isClassNameValue(value) {
|
|
1531
|
+
return !!value && typeof value === "object" && value[CLASS_NAME_VALUE] === true && typeof value.className === "string";
|
|
1532
|
+
}
|
|
1533
|
+
//#endregion
|
|
1403
1534
|
//#region style/valueRef.ts
|
|
1404
1535
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1405
1536
|
function createAtRuleRef(data) {
|
|
@@ -1429,6 +1560,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1429
1560
|
let token;
|
|
1430
1561
|
let ref;
|
|
1431
1562
|
let variableName;
|
|
1563
|
+
let transformClassName;
|
|
1432
1564
|
let lookupIndex;
|
|
1433
1565
|
if (isStyleData(style)) {
|
|
1434
1566
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1466,6 +1598,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1466
1598
|
priority = valueRaw[0];
|
|
1467
1599
|
valueRaw = valueRaw[1];
|
|
1468
1600
|
}
|
|
1601
|
+
transformClassName = null;
|
|
1602
|
+
if (isClassNameValue(valueRaw)) {
|
|
1603
|
+
transformClassName = valueRaw.className;
|
|
1604
|
+
valueRaw = valueRaw.value;
|
|
1605
|
+
}
|
|
1469
1606
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1470
1607
|
if (ref) valueRaw = ref.value;
|
|
1471
1608
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1481,6 +1618,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1481
1618
|
className: "",
|
|
1482
1619
|
property,
|
|
1483
1620
|
value,
|
|
1621
|
+
transformClassName,
|
|
1484
1622
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1485
1623
|
1,
|
|
1486
1624
|
variableName,
|
|
@@ -1545,7 +1683,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1545
1683
|
value = value[0];
|
|
1546
1684
|
}
|
|
1547
1685
|
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1548
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
1686
|
+
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);
|
|
1549
1687
|
runtimeItem.dedupe = dedupe;
|
|
1550
1688
|
runtimeItem.className = className;
|
|
1551
1689
|
lookupIndex = lookup[dedupe];
|
|
@@ -2342,7 +2480,7 @@ function getCssPropertyName(property) {
|
|
|
2342
2480
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2343
2481
|
const formatter = createNameFormatter(["name"]);
|
|
2344
2482
|
return (format, id, info) => {
|
|
2345
|
-
const hash = getIdentifierSafeHash(id);
|
|
2483
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2346
2484
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2347
2485
|
if (!prefix) return name;
|
|
2348
2486
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2553,11 +2691,11 @@ function createStyleFn(args) {
|
|
|
2553
2691
|
style.plain = fnPlain;
|
|
2554
2692
|
style.keyframes = fnKeyframes;
|
|
2555
2693
|
style.merge = fnMerge;
|
|
2556
|
-
|
|
2694
|
+
assignStyleFnMeta(style, {
|
|
2695
|
+
mode: "StyleObject",
|
|
2557
2696
|
selectors,
|
|
2558
2697
|
transform: transform ?? null
|
|
2559
|
-
};
|
|
2560
|
-
Object.assign(style, { [META]: meta });
|
|
2698
|
+
});
|
|
2561
2699
|
return { style };
|
|
2562
2700
|
}
|
|
2563
2701
|
function mergeStyleResult(target, style) {
|
|
@@ -2566,12 +2704,17 @@ function mergeStyleResult(target, style) {
|
|
|
2566
2704
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2567
2705
|
return target;
|
|
2568
2706
|
}
|
|
2707
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2708
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2709
|
+
return styleFn;
|
|
2710
|
+
}
|
|
2569
2711
|
function getStyleFnMeta(styleFn) {
|
|
2570
2712
|
return styleFn[META];
|
|
2571
2713
|
}
|
|
2572
2714
|
//#endregion
|
|
2573
2715
|
//#region compiler/utils/import_source.ts
|
|
2574
2716
|
const DefaultStyleFnMeta = {
|
|
2717
|
+
mode: "StyleObject",
|
|
2575
2718
|
selectors: PrioritySelectors,
|
|
2576
2719
|
transform: null
|
|
2577
2720
|
};
|
|
@@ -2824,6 +2967,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2824
2967
|
}
|
|
2825
2968
|
}
|
|
2826
2969
|
//#endregion
|
|
2970
|
+
//#region style/value.ts
|
|
2971
|
+
function createToken(value, debugId) {
|
|
2972
|
+
return createStyleToken(value, debugId);
|
|
2973
|
+
}
|
|
2974
|
+
//#endregion
|
|
2975
|
+
//#region dialect/namedTokens.ts
|
|
2976
|
+
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
2977
|
+
function createNamedToken(id, value) {
|
|
2978
|
+
return createToken(value, createNamedTokenId(id));
|
|
2979
|
+
}
|
|
2980
|
+
function createNamedTokens(namespace, values) {
|
|
2981
|
+
return createNamedTokenProxy({
|
|
2982
|
+
__fluenticNamedTokens: true,
|
|
2983
|
+
namespace,
|
|
2984
|
+
values,
|
|
2985
|
+
cache: /* @__PURE__ */ new Map()
|
|
2986
|
+
}, []);
|
|
2987
|
+
}
|
|
2988
|
+
function createNamedTokenId(id) {
|
|
2989
|
+
return sanitizeCssIdentName(id.replace(/\./g, "-"), "named-token");
|
|
2990
|
+
}
|
|
2991
|
+
function createNamedTokenProxy(root, path) {
|
|
2992
|
+
return new Proxy(noop, {
|
|
2993
|
+
get(_target, property) {
|
|
2994
|
+
if (property === ROOT) return root;
|
|
2995
|
+
if (property === "then") return void 0;
|
|
2996
|
+
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
2997
|
+
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
2998
|
+
if (!path.length) return void 0;
|
|
2999
|
+
return getNamedTokenAtPath(root, path)[property];
|
|
3000
|
+
}
|
|
3001
|
+
if (typeof property === "symbol") return void 0;
|
|
3002
|
+
return createNamedTokenProxy(root, path.concat(String(property)));
|
|
3003
|
+
},
|
|
3004
|
+
apply(_target, _thisArg, args) {
|
|
3005
|
+
if (!path.length) return void 0;
|
|
3006
|
+
return getNamedTokenAtPath(root, path).apply(void 0, args);
|
|
3007
|
+
}
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
function getNamedTokenAtPath(root, path) {
|
|
3011
|
+
const key = path.join(".");
|
|
3012
|
+
const cached = root.cache.get(key);
|
|
3013
|
+
if (cached) return cached;
|
|
3014
|
+
const value = getValueAtPath(root.values, path);
|
|
3015
|
+
const token = createNamedToken(root.namespace + "." + key, value);
|
|
3016
|
+
root.cache.set(key, token);
|
|
3017
|
+
return token;
|
|
3018
|
+
}
|
|
3019
|
+
function getValueAtPath(values, path) {
|
|
3020
|
+
let current = values;
|
|
3021
|
+
for (let i = 0; i < path.length; i++) {
|
|
3022
|
+
if (!current || typeof current !== "object") return void 0;
|
|
3023
|
+
current = current[path[i]];
|
|
3024
|
+
}
|
|
3025
|
+
return current;
|
|
3026
|
+
}
|
|
3027
|
+
function noop() {}
|
|
3028
|
+
//#endregion
|
|
2827
3029
|
//#region style/utils/expose.ts
|
|
2828
3030
|
function exposeStyle(styles) {
|
|
2829
3031
|
return exposeStyleObject(styles);
|
|
@@ -2879,6 +3081,7 @@ function evaluateNode(node, scope) {
|
|
|
2879
3081
|
case "ParenthesizedExpression":
|
|
2880
3082
|
case "TSAsExpression":
|
|
2881
3083
|
case "TSNonNullExpression":
|
|
3084
|
+
case "TSSatisfiesExpression":
|
|
2882
3085
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
2883
3086
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
2884
3087
|
}
|
|
@@ -2951,14 +3154,14 @@ function evaluateMember(node, scope) {
|
|
|
2951
3154
|
if (!key.ok) return key;
|
|
2952
3155
|
const obj = evaluateNode(node.object, scope);
|
|
2953
3156
|
if (!obj.ok) return obj;
|
|
2954
|
-
if (obj.value && typeof obj.value === "object") return evalOk(obj.value[key.value]);
|
|
3157
|
+
if (obj.value && (typeof obj.value === "object" || typeof obj.value === "function")) return evalOk(obj.value[key.value]);
|
|
2955
3158
|
return evalFail("Cannot index non-object");
|
|
2956
3159
|
}
|
|
2957
3160
|
const prop = node.property.name;
|
|
2958
3161
|
const obj = evaluateNode(node.object, scope);
|
|
2959
3162
|
if (!obj.ok) return obj;
|
|
2960
3163
|
if (obj.value == null) return evalFail(`Cannot access .${prop} on null/undefined`);
|
|
2961
|
-
if (typeof obj.value !== "object" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3164
|
+
if (typeof obj.value !== "object" && typeof obj.value !== "function" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
2962
3165
|
return evalOk(obj.value[prop]);
|
|
2963
3166
|
}
|
|
2964
3167
|
function evaluateObject(node, scope) {
|
|
@@ -2997,7 +3200,7 @@ function evaluateObject(node, scope) {
|
|
|
2997
3200
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
2998
3201
|
const val = evaluateNode(prop.value, scope);
|
|
2999
3202
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3000
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3203
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3001
3204
|
if (prop.loc?.start) locations[key] = {
|
|
3002
3205
|
line: prop.loc.start.line,
|
|
3003
3206
|
column: prop.loc.start.column + 1,
|
|
@@ -3162,6 +3365,23 @@ function evaluateCall(node, scope) {
|
|
|
3162
3365
|
if (!debugId.ok) return debugId;
|
|
3163
3366
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3164
3367
|
}
|
|
3368
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3369
|
+
const id = evaluateNode(node.arguments[0], scope);
|
|
3370
|
+
if (!id.ok) return id;
|
|
3371
|
+
if (typeof id.value !== "string") return evalFail("createNamedToken id must be a static string");
|
|
3372
|
+
const value = evaluateNode(node.arguments[1], scope);
|
|
3373
|
+
if (!value.ok) return value;
|
|
3374
|
+
return evalOk(createNamedToken(id.value, value.value));
|
|
3375
|
+
}
|
|
3376
|
+
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedTokens") {
|
|
3377
|
+
const namespace = evaluateNode(node.arguments[0], scope);
|
|
3378
|
+
if (!namespace.ok) return namespace;
|
|
3379
|
+
if (typeof namespace.value !== "string") return evalFail("createNamedTokens namespace must be a static string");
|
|
3380
|
+
const values = evaluateNode(node.arguments[1], scope);
|
|
3381
|
+
if (!values.ok) return values;
|
|
3382
|
+
if (!values.value || typeof values.value !== "object") return evalFail("createNamedTokens values must be a static object");
|
|
3383
|
+
return evalOk(createNamedTokens(namespace.value, values.value));
|
|
3384
|
+
}
|
|
3165
3385
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3166
3386
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3167
3387
|
if (!styles.ok) return styles;
|
|
@@ -3331,6 +3551,8 @@ function createCompiledValues(values, scope, loc, runtimeValue, debugId, isNumbe
|
|
|
3331
3551
|
};
|
|
3332
3552
|
}
|
|
3333
3553
|
function parseCompiledValue(value, isNumber) {
|
|
3554
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
3555
|
+
value = String(value).split(/[;|]/)[0].trim();
|
|
3334
3556
|
if (!isNumber) return value;
|
|
3335
3557
|
const number = Number(value);
|
|
3336
3558
|
if (!Number.isFinite(number)) return value;
|
|
@@ -3372,7 +3594,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3372
3594
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3373
3595
|
});
|
|
3374
3596
|
}
|
|
3375
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3597
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3376
3598
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3377
3599
|
}
|
|
3378
3600
|
function evaluateBinary(node, scope) {
|
|
@@ -3428,7 +3650,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3428
3650
|
}
|
|
3429
3651
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3430
3652
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3431
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3653
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3432
3654
|
}
|
|
3433
3655
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3434
3656
|
const declarations = [];
|
|
@@ -3753,12 +3975,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3753
3975
|
}
|
|
3754
3976
|
const formatVarName = createNameFormatter(["name"]);
|
|
3755
3977
|
function getLocalVarName(filePath, line, column, format) {
|
|
3756
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
3978
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3757
3979
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3758
3980
|
}
|
|
3759
3981
|
//#endregion
|
|
3760
3982
|
//#region compiler/transform/debug/utils/debug_data.ts
|
|
3761
|
-
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride) {
|
|
3983
|
+
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride, classNameArg = false) {
|
|
3762
3984
|
const loc = locOverride ?? node.loc?.start;
|
|
3763
3985
|
const line = loc?.line ?? 1;
|
|
3764
3986
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3775,10 +3997,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3775
3997
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3776
3998
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3777
3999
|
];
|
|
4000
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3778
4001
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3779
4002
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3780
4003
|
return t.objectExpression(properties);
|
|
3781
4004
|
}
|
|
4005
|
+
function buildClassNames(t, args) {
|
|
4006
|
+
const classNames = /* @__PURE__ */ new Map();
|
|
4007
|
+
for (const arg of args) collectClassNameLoc(arg, classNames);
|
|
4008
|
+
const fields = [];
|
|
4009
|
+
for (const [className, loc] of classNames) fields.push(t.objectProperty(t.stringLiteral(className), buildLoc(t, loc.line, loc.column + 1)));
|
|
4010
|
+
return t.objectExpression(fields);
|
|
4011
|
+
}
|
|
4012
|
+
function collectClassNameLoc(arg, classNames) {
|
|
4013
|
+
if (!arg) return;
|
|
4014
|
+
if (arg.type === "StringLiteral") {
|
|
4015
|
+
const loc = arg.loc?.start;
|
|
4016
|
+
if (loc) classNames.set(arg.value, loc);
|
|
4017
|
+
return;
|
|
4018
|
+
}
|
|
4019
|
+
if (arg.type === "TemplateLiteral" && arg.expressions.length === 0) {
|
|
4020
|
+
const loc = arg.loc?.start;
|
|
4021
|
+
if (loc) classNames.set(arg.quasis[0]?.value.cooked ?? arg.quasis[0]?.value.raw ?? "", loc);
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
if (arg.type === "ArrayExpression") {
|
|
4025
|
+
for (const item of arg.elements) collectClassNameLoc(item, classNames);
|
|
4026
|
+
return;
|
|
4027
|
+
}
|
|
4028
|
+
if (arg.type === "ConditionalExpression") {
|
|
4029
|
+
collectClassNameLoc(arg.consequent, classNames);
|
|
4030
|
+
collectClassNameLoc(arg.alternate, classNames);
|
|
4031
|
+
return;
|
|
4032
|
+
}
|
|
4033
|
+
if (arg.type === "LogicalExpression") {
|
|
4034
|
+
collectClassNameLoc(arg.left, classNames);
|
|
4035
|
+
collectClassNameLoc(arg.right, classNames);
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
if (arg.type === "CallExpression" && arg.callee.type === "MemberExpression" && arg.callee.property.type === "Identifier" && arg.callee.property.name === "weight") collectClassNameLoc(arg.arguments[0], classNames);
|
|
4039
|
+
}
|
|
3782
4040
|
function getShortLabel(label) {
|
|
3783
4041
|
const parts = label.split(".");
|
|
3784
4042
|
return parts[parts.length - 1] || label;
|
|
@@ -3937,7 +4195,9 @@ function createDebugPlugin(args) {
|
|
|
3937
4195
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
3938
4196
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
3939
4197
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
3940
|
-
|
|
4198
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4199
|
+
const isClassNameCall = rootName ? state.styleMetas.get(rootName)?.mode === "ClassName" : false;
|
|
4200
|
+
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));
|
|
3941
4201
|
},
|
|
3942
4202
|
JSXOpeningElement(path, state) {
|
|
3943
4203
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4528,6 +4788,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4528
4788
|
//#region compiler/utils/file_resolver.ts
|
|
4529
4789
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4530
4790
|
const resolver = new ResolverFactory({
|
|
4791
|
+
conditionNames: [
|
|
4792
|
+
"import",
|
|
4793
|
+
"module",
|
|
4794
|
+
"default",
|
|
4795
|
+
"types"
|
|
4796
|
+
],
|
|
4531
4797
|
extensions: [
|
|
4532
4798
|
".ts",
|
|
4533
4799
|
".tsx",
|
|
@@ -4687,8 +4953,101 @@ function extractStyleChain(node, styleNames) {
|
|
|
4687
4953
|
}
|
|
4688
4954
|
//#endregion
|
|
4689
4955
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4690
|
-
function applyTransform(styleObj, transform) {
|
|
4691
|
-
|
|
4956
|
+
function applyTransform(styleObj, transform, cssConfig) {
|
|
4957
|
+
if (!transform) return styleObj;
|
|
4958
|
+
const input = transformRuntimeValues(styleObj, transform, cssConfig);
|
|
4959
|
+
return carryTransformedLocations(input, transform.transform(input), transform);
|
|
4960
|
+
}
|
|
4961
|
+
function transformRuntimeValues(styleObj, transform, cssConfig) {
|
|
4962
|
+
let result = null;
|
|
4963
|
+
for (const [property, rawValue] of Object.entries(styleObj)) {
|
|
4964
|
+
const runtimeValue = getCompiledRuntimeValue(getPriorityTupleValue(rawValue));
|
|
4965
|
+
if (!runtimeValue) continue;
|
|
4966
|
+
const transformedRuntimeValue = transformRuntimeExpression(property, runtimeValue, transform, cssConfig);
|
|
4967
|
+
if (transformedRuntimeValue === runtimeValue) continue;
|
|
4968
|
+
result ??= cloneCompiledStyleObject(styleObj);
|
|
4969
|
+
result[property] = Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number" ? [rawValue[0], createCompiledRuntimeValue(transformedRuntimeValue)] : createCompiledRuntimeValue(transformedRuntimeValue);
|
|
4970
|
+
}
|
|
4971
|
+
return result ?? styleObj;
|
|
4972
|
+
}
|
|
4973
|
+
function getPriorityTupleValue(value) {
|
|
4974
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value;
|
|
4975
|
+
}
|
|
4976
|
+
function cloneCompiledStyleObject(styleObj) {
|
|
4977
|
+
const cloned = { ...styleObj };
|
|
4978
|
+
const locations = styleObj[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
4979
|
+
if (locations) Object.defineProperty(cloned, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
4980
|
+
configurable: true,
|
|
4981
|
+
enumerable: false,
|
|
4982
|
+
value: locations
|
|
4983
|
+
});
|
|
4984
|
+
return cloned;
|
|
4985
|
+
}
|
|
4986
|
+
function createCompiledRuntimeValue(runtimeValue) {
|
|
4987
|
+
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
4988
|
+
}
|
|
4989
|
+
function transformRuntimeExpression(property, expression, transform, cssConfig) {
|
|
4990
|
+
if (expression.type === "StringLiteral") return createPrimitiveExpression(expression, normalizeRuntimeTransformedValue(getSingleTransformedValue(transform.transform({ [property]: expression.value })), cssConfig)) ?? expression;
|
|
4991
|
+
if (expression.type === "ConditionalExpression") {
|
|
4992
|
+
const consequent = transformRuntimeExpression(property, expression.consequent, transform, cssConfig);
|
|
4993
|
+
const alternate = transformRuntimeExpression(property, expression.alternate, transform, cssConfig);
|
|
4994
|
+
return consequent === expression.consequent && alternate === expression.alternate ? expression : {
|
|
4995
|
+
...expression,
|
|
4996
|
+
consequent,
|
|
4997
|
+
alternate
|
|
4998
|
+
};
|
|
4999
|
+
}
|
|
5000
|
+
return expression;
|
|
5001
|
+
}
|
|
5002
|
+
function getSingleTransformedValue(transformed) {
|
|
5003
|
+
const values = Object.values(transformed);
|
|
5004
|
+
if (!values.length) return void 0;
|
|
5005
|
+
return values[0];
|
|
5006
|
+
}
|
|
5007
|
+
function normalizeRuntimeTransformedValue(value, cssConfig) {
|
|
5008
|
+
if (isStyleTokenOverrideData(value)) return getTokenOverrideValue(value, cssConfig.tokenNameFormat);
|
|
5009
|
+
if (isStyleTokenData(value)) return getTokenVar(value, cssConfig.tokenNameFormat);
|
|
5010
|
+
return value;
|
|
5011
|
+
}
|
|
5012
|
+
function createPrimitiveExpression(original, value) {
|
|
5013
|
+
if (original.type === "StringLiteral" && value === original.value) return null;
|
|
5014
|
+
if (typeof value === "string") return {
|
|
5015
|
+
...original,
|
|
5016
|
+
type: "StringLiteral",
|
|
5017
|
+
value
|
|
5018
|
+
};
|
|
5019
|
+
if (typeof value === "number") return {
|
|
5020
|
+
...original,
|
|
5021
|
+
type: "NumericLiteral",
|
|
5022
|
+
value
|
|
5023
|
+
};
|
|
5024
|
+
if (typeof value === "boolean") return {
|
|
5025
|
+
...original,
|
|
5026
|
+
type: "BooleanLiteral",
|
|
5027
|
+
value
|
|
5028
|
+
};
|
|
5029
|
+
if (value === null) return {
|
|
5030
|
+
...original,
|
|
5031
|
+
type: "NullLiteral"
|
|
5032
|
+
};
|
|
5033
|
+
return null;
|
|
5034
|
+
}
|
|
5035
|
+
function carryTransformedLocations(input, transformed, transform) {
|
|
5036
|
+
const inputLocations = input[COMPILED_STYLE_OBJECT_LOCATIONS];
|
|
5037
|
+
if (!inputLocations) return transformed;
|
|
5038
|
+
const locations = { ...transformed[COMPILED_STYLE_OBJECT_LOCATIONS] };
|
|
5039
|
+
for (const [property, loc] of Object.entries(inputLocations)) {
|
|
5040
|
+
if (property in transformed && !locations[property]) locations[property] = loc;
|
|
5041
|
+
const single = transform.transform({ [property]: input[property] });
|
|
5042
|
+
for (const transformedProperty of Object.keys(single)) locations[transformedProperty] ??= loc;
|
|
5043
|
+
}
|
|
5044
|
+
if (!Object.keys(locations).length) return transformed;
|
|
5045
|
+
Object.defineProperty(transformed, COMPILED_STYLE_OBJECT_LOCATIONS, {
|
|
5046
|
+
configurable: true,
|
|
5047
|
+
enumerable: false,
|
|
5048
|
+
value: locations
|
|
5049
|
+
});
|
|
5050
|
+
return transformed;
|
|
4692
5051
|
}
|
|
4693
5052
|
/**
|
|
4694
5053
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
@@ -4696,6 +5055,10 @@ function applyTransform(styleObj, transform) {
|
|
|
4696
5055
|
*/
|
|
4697
5056
|
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4698
5057
|
const css = getCssConfig(opts);
|
|
5058
|
+
if (meta.mode === "ClassName") {
|
|
5059
|
+
if (chain.kind !== "style") return null;
|
|
5060
|
+
return compileClassNameChain(chain, meta.selectors, fileId, scope, css, meta.transform, styleNames, opts);
|
|
5061
|
+
}
|
|
4699
5062
|
const selectors = meta.selectors;
|
|
4700
5063
|
const transform = meta.transform;
|
|
4701
5064
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4707,6 +5070,8 @@ function getCssConfig(opts) {
|
|
|
4707
5070
|
const css = opts.css;
|
|
4708
5071
|
return {
|
|
4709
5072
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5073
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5074
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4710
5075
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4711
5076
|
localClassName: css?.localClassName ?? DEFAULT_CONFIG.localClassName,
|
|
4712
5077
|
debugClassName: css?.debugClassName ?? DEFAULT_CONFIG.debugClassName,
|
|
@@ -4727,6 +5092,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4727
5092
|
rules
|
|
4728
5093
|
};
|
|
4729
5094
|
}
|
|
5095
|
+
function compileClassNameChain(chain, selectors, fileId, scope, cssConfig, transform, styleNames, options) {
|
|
5096
|
+
const items = [];
|
|
5097
|
+
const rules = [];
|
|
5098
|
+
if (!compileClassNameArgsInto(chain.baseArgs, 0, null, null, fileId, scope, cssConfig, transform, 1, null, items, rules)) return null;
|
|
5099
|
+
let i = 0;
|
|
5100
|
+
while (i < chain.methods.length) {
|
|
5101
|
+
const method = chain.methods[i];
|
|
5102
|
+
if (!compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options)) return null;
|
|
5103
|
+
i++;
|
|
5104
|
+
}
|
|
5105
|
+
return {
|
|
5106
|
+
type: "style",
|
|
5107
|
+
items,
|
|
5108
|
+
rules
|
|
5109
|
+
};
|
|
5110
|
+
}
|
|
5111
|
+
function compileClassNameChainMethod(method, selectors, fileId, scope, cssConfig, transform, items, rules, styleNames, options) {
|
|
5112
|
+
const selector = selectors[method.name];
|
|
5113
|
+
if (!selector) return false;
|
|
5114
|
+
validateSelectorDefinition(options.dev?.checkSelector, `style.${method.name}`, selector, method.nameNode);
|
|
5115
|
+
const selectorStr = selector.selector.trim();
|
|
5116
|
+
if (selectorStr === "...") {
|
|
5117
|
+
const localChain = getLocalStyleChainArg(method.args[0], scope, styleNames);
|
|
5118
|
+
const localMeta = localChain ? scope.styleMetas?.get(localChain.rootName) : null;
|
|
5119
|
+
if (localChain?.kind === "style" && localMeta?.mode === "ClassName") {
|
|
5120
|
+
const result = compileClassNameChain(localChain, localMeta.selectors, fileId, scope, cssConfig, localMeta.transform, styleNames, options);
|
|
5121
|
+
if (!result) return false;
|
|
5122
|
+
items.push(...result.items);
|
|
5123
|
+
rules.push(...result.rules);
|
|
5124
|
+
return true;
|
|
5125
|
+
}
|
|
5126
|
+
return false;
|
|
5127
|
+
}
|
|
5128
|
+
if (selectorStr.startsWith("@")) {
|
|
5129
|
+
const isMedia = selectorStr.startsWith("@media") || selectorStr.startsWith("@container");
|
|
5130
|
+
const hasArg = selectorStr.includes("$$");
|
|
5131
|
+
const priority = getAtRulePriority(selector.priority, isMedia, method.args[0]);
|
|
5132
|
+
let argOffset = 0;
|
|
5133
|
+
if (isMedia && isNumericLiteral(method.args[0])) argOffset = 1;
|
|
5134
|
+
let atRule = selectorStr;
|
|
5135
|
+
if (hasArg) {
|
|
5136
|
+
const queryArg = evaluateNode(method.args[argOffset], scope);
|
|
5137
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, queryArg, method.args[argOffset]);
|
|
5138
|
+
throwIfRequiredStaticSelectorValue(options, `style.${method.name}`, queryArg);
|
|
5139
|
+
if (!queryArg.ok) return false;
|
|
5140
|
+
const [before, after] = selectorStr.split("$$");
|
|
5141
|
+
atRule = before + String(queryArg.value) + (after ?? "");
|
|
5142
|
+
}
|
|
5143
|
+
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
5144
|
+
const classNameOffset = hasArg ? argOffset + 1 : argOffset;
|
|
5145
|
+
return compileClassNameArgsInto(method.args, classNameOffset, null, [atRuleSelector], fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5146
|
+
}
|
|
5147
|
+
if (selectorStr.includes("$$") || selectorStr.includes("$")) {
|
|
5148
|
+
const splitToken = selectorStr.includes("$$") ? "$$" : "$";
|
|
5149
|
+
const [before, after] = selectorStr.split(splitToken);
|
|
5150
|
+
const selectorArg = evaluateNode(method.args[0], scope);
|
|
5151
|
+
validateResolvedSelectorValue(options.dev?.checkSelector, `style.${method.name}`, selector, selectorArg, method.args[0]);
|
|
5152
|
+
if (!selectorArg.ok) return false;
|
|
5153
|
+
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
5154
|
+
const itemSelector = selector.priority !== null ? [selectorText, selector.priority] : selectorText;
|
|
5155
|
+
return compileClassNameArgsInto(method.args, 1, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5156
|
+
}
|
|
5157
|
+
const itemSelector = selector.priority !== null ? [selectorStr, selector.priority] : selectorStr;
|
|
5158
|
+
return compileClassNameArgsInto(method.args, 0, itemSelector, null, fileId, scope, cssConfig, transform, 1, null, items, rules);
|
|
5159
|
+
}
|
|
5160
|
+
function compileClassNameArgsInto(args, startIndex, selector, atRules, fileId, scope, cssConfig, transform, type, slotId, items, rules) {
|
|
5161
|
+
if (startIndex >= args.length) return true;
|
|
5162
|
+
const styleObj = {};
|
|
5163
|
+
let i = startIndex;
|
|
5164
|
+
while (i < args.length) {
|
|
5165
|
+
const arg = evaluateNode(args[i], scope);
|
|
5166
|
+
if (!arg.ok) {
|
|
5167
|
+
throwIfRequiredStaticStyleValue(arg);
|
|
5168
|
+
return false;
|
|
5169
|
+
}
|
|
5170
|
+
if (!appendClassNameArgStyle(arg.value, transform, styleObj)) return false;
|
|
5171
|
+
i++;
|
|
5172
|
+
}
|
|
5173
|
+
return addStyleItems(styleObj, selector, null, atRules, fileId, type, slotId, items, rules, cssConfig);
|
|
5174
|
+
}
|
|
5175
|
+
function appendClassNameArgStyle(value, transform, styleObj) {
|
|
5176
|
+
if (!value) return true;
|
|
5177
|
+
if (typeof value === "string") {
|
|
5178
|
+
Object.assign(styleObj, decorateClassNameStyle(transform.transform(value), value));
|
|
5179
|
+
return true;
|
|
5180
|
+
}
|
|
5181
|
+
if (Array.isArray(value)) {
|
|
5182
|
+
for (const item of value) if (!appendClassNameArgStyle(item, transform, styleObj)) return false;
|
|
5183
|
+
return true;
|
|
5184
|
+
}
|
|
5185
|
+
if (isWeightedClassName(value)) {
|
|
5186
|
+
const transformed = decorateClassNameStyle(transform.transform(value.className), value.className);
|
|
5187
|
+
Object.assign(styleObj, applyClassNameWeight(transformed, value.weight));
|
|
5188
|
+
return true;
|
|
5189
|
+
}
|
|
5190
|
+
return false;
|
|
5191
|
+
}
|
|
5192
|
+
function decorateClassNameStyle(style, className) {
|
|
5193
|
+
const result = {};
|
|
5194
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5195
|
+
if (value === null || value === void 0) {
|
|
5196
|
+
result[property] = value;
|
|
5197
|
+
continue;
|
|
5198
|
+
}
|
|
5199
|
+
if (Array.isArray(value) && value.length === 2 && typeof value[0] === "number") {
|
|
5200
|
+
const rawValue = value[1];
|
|
5201
|
+
result[property] = isClassNameValue(rawValue) ? value : [value[0], classNameValue(rawValue, className)];
|
|
5202
|
+
continue;
|
|
5203
|
+
}
|
|
5204
|
+
result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
|
|
5205
|
+
}
|
|
5206
|
+
return result;
|
|
5207
|
+
}
|
|
5208
|
+
function isWeightedClassName(value) {
|
|
5209
|
+
return !!value && typeof value === "object" && typeof value.className === "string" && typeof value.weight === "number";
|
|
5210
|
+
}
|
|
5211
|
+
function applyClassNameWeight(style, weight) {
|
|
5212
|
+
const weighted = {};
|
|
5213
|
+
for (const [property, value] of Object.entries(style)) {
|
|
5214
|
+
if (value === null || value === void 0) {
|
|
5215
|
+
weighted[property] = value;
|
|
5216
|
+
continue;
|
|
5217
|
+
}
|
|
5218
|
+
weighted[property] = [weight, Array.isArray(value) && value.length === 2 && typeof value[0] === "number" ? value[1] : value];
|
|
5219
|
+
}
|
|
5220
|
+
return weighted;
|
|
5221
|
+
}
|
|
4730
5222
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4731
5223
|
if (chain.baseArgs.length > 0) {
|
|
4732
5224
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4734,7 +5226,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4734
5226
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4735
5227
|
return false;
|
|
4736
5228
|
}
|
|
4737
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
5229
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, atRules, fileId, type, slotId, items, rules, cssConfig, callsiteOverride)) return false;
|
|
4738
5230
|
}
|
|
4739
5231
|
let i = 0;
|
|
4740
5232
|
while (i < chain.methods.length) {
|
|
@@ -4753,7 +5245,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4753
5245
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4754
5246
|
return null;
|
|
4755
5247
|
}
|
|
4756
|
-
if (!addStyleItems(applyTransform(styleArg.value, transform), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
5248
|
+
if (!addStyleItems(applyTransform(styleArg.value, transform, cssConfig), null, null, null, fileId, 2, slotId, items, rules, cssConfig)) return null;
|
|
4757
5249
|
}
|
|
4758
5250
|
let i = 0;
|
|
4759
5251
|
while (i < chain.methods.length) {
|
|
@@ -4871,14 +5363,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4871
5363
|
return true;
|
|
4872
5364
|
}
|
|
4873
5365
|
if (node.type !== "CallExpression") return false;
|
|
4874
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5366
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
4875
5367
|
if (!overrideChain) return false;
|
|
4876
5368
|
const { slotId, items: overrideItems } = overrideChain;
|
|
4877
5369
|
let i = 0;
|
|
4878
5370
|
while (i < overrideItems.length) {
|
|
4879
5371
|
const overrideItem = overrideItems[i];
|
|
4880
5372
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
4881
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5373
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
4882
5374
|
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;
|
|
4883
5375
|
} else if (overrideItem.styleData !== void 0) {
|
|
4884
5376
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -4887,15 +5379,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4887
5379
|
}
|
|
4888
5380
|
return true;
|
|
4889
5381
|
}
|
|
4890
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5382
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
4891
5383
|
const callee = node.callee;
|
|
4892
5384
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
4893
5385
|
const methodName = callee.property.name;
|
|
4894
5386
|
const obj = callee.object;
|
|
4895
5387
|
if (obj.type === "CallExpression") {
|
|
4896
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5388
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
4897
5389
|
if (!inner) return null;
|
|
4898
|
-
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, transform, options);
|
|
5390
|
+
const overrideItem = resolveOverrideMethod(methodName, node.arguments, callee.property, selectors, scope, cssConfig, transform, options);
|
|
4899
5391
|
if (!overrideItem) return null;
|
|
4900
5392
|
return {
|
|
4901
5393
|
slotId: inner.slotId,
|
|
@@ -4910,7 +5402,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4910
5402
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
4911
5403
|
if (!styleArg.ok) return null;
|
|
4912
5404
|
items.push({
|
|
4913
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5405
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4914
5406
|
selector: null,
|
|
4915
5407
|
atRules: null
|
|
4916
5408
|
});
|
|
@@ -4920,7 +5412,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4920
5412
|
items
|
|
4921
5413
|
};
|
|
4922
5414
|
}
|
|
4923
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5415
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
4924
5416
|
const sel = selectors[methodName];
|
|
4925
5417
|
if (!sel) return null;
|
|
4926
5418
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -4947,7 +5439,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4947
5439
|
callsiteOverride
|
|
4948
5440
|
};
|
|
4949
5441
|
return {
|
|
4950
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5442
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4951
5443
|
selector: null,
|
|
4952
5444
|
atRules: null,
|
|
4953
5445
|
callsiteOverride
|
|
@@ -4972,7 +5464,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4972
5464
|
if (!styleArg.ok) return null;
|
|
4973
5465
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
4974
5466
|
return {
|
|
4975
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5467
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4976
5468
|
selector: null,
|
|
4977
5469
|
atRules: [atRuleSelector]
|
|
4978
5470
|
};
|
|
@@ -4988,7 +5480,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4988
5480
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
4989
5481
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
4990
5482
|
return {
|
|
4991
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5483
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4992
5484
|
selector: itemSelector,
|
|
4993
5485
|
atRules: null
|
|
4994
5486
|
};
|
|
@@ -4996,7 +5488,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4996
5488
|
const styleArg = evaluateNode(args[0], scope);
|
|
4997
5489
|
if (!styleArg.ok) return null;
|
|
4998
5490
|
return {
|
|
4999
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5491
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5000
5492
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5001
5493
|
atRules: null
|
|
5002
5494
|
};
|
|
@@ -5080,7 +5572,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5080
5572
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5081
5573
|
return false;
|
|
5082
5574
|
}
|
|
5083
|
-
return addStyleItems(applyTransform(styleArg.value, transform), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5575
|
+
return addStyleItems(applyTransform(styleArg.value, transform, cssConfig), itemSelector, null, atRules, fileId, type, slotId, items, cssRules, cssConfig, callsiteOverride);
|
|
5084
5576
|
}
|
|
5085
5577
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5086
5578
|
if (!styleArgNode) return false;
|
|
@@ -5161,14 +5653,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5161
5653
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5162
5654
|
return false;
|
|
5163
5655
|
}
|
|
5164
|
-
return addStyleItems(applyTransform(evaled.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5656
|
+
return addStyleItems(applyTransform(evaled.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5165
5657
|
}
|
|
5166
5658
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5167
5659
|
if (!styleResult.ok) {
|
|
5168
5660
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5169
5661
|
return false;
|
|
5170
5662
|
}
|
|
5171
|
-
return addStyleItems(applyTransform(styleResult.value, transform), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5663
|
+
return addStyleItems(applyTransform(styleResult.value, transform, cssConfig), null, null, nextAtRules, fileId, type, slotId, items, cssRules, cssConfig);
|
|
5172
5664
|
}
|
|
5173
5665
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5174
5666
|
const selectorStr = selector.selector.trim();
|
|
@@ -5187,7 +5679,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5187
5679
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5188
5680
|
if (!styleResult.ok) return false;
|
|
5189
5681
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5190
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5682
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5191
5683
|
let i = 0;
|
|
5192
5684
|
while (i < selectorValues.length) {
|
|
5193
5685
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5315,7 +5807,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5315
5807
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5316
5808
|
const valueStr = String(value ?? "");
|
|
5317
5809
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
5318
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5810
|
+
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);
|
|
5319
5811
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5320
5812
|
items.push(item);
|
|
5321
5813
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5396,7 +5888,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5396
5888
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5397
5889
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5398
5890
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5399
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5891
|
+
const className = getAtomicClassName(sourceItem.property, priority, valueStr, itemSelector, parentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, sourceItem.transformClassName ?? null, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5400
5892
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5401
5893
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5402
5894
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5464,10 +5956,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5464
5956
|
const rawValue = styleObj[property];
|
|
5465
5957
|
let priority = null;
|
|
5466
5958
|
let value = rawValue;
|
|
5959
|
+
let transformClassName = null;
|
|
5467
5960
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5468
5961
|
priority = rawValue[0];
|
|
5469
5962
|
value = rawValue[1];
|
|
5470
5963
|
}
|
|
5964
|
+
if (isClassNameValue(value)) {
|
|
5965
|
+
transformClassName = value.className;
|
|
5966
|
+
value = value.value;
|
|
5967
|
+
}
|
|
5471
5968
|
if (value === null || value === void 0) {
|
|
5472
5969
|
i++;
|
|
5473
5970
|
continue;
|
|
@@ -5487,7 +5984,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5487
5984
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5488
5985
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5489
5986
|
const dedupe = getClassNameDedupe(property, priority, selector, parentSelector, atRules);
|
|
5490
|
-
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5987
|
+
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5491
5988
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5492
5989
|
item.sourceTrace = propertyCallsite ? {
|
|
5493
5990
|
property,
|
|
@@ -6661,13 +7158,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6661
7158
|
const body = path.node.body;
|
|
6662
7159
|
let firstRuntimeIndex = 0;
|
|
6663
7160
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7161
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6664
7162
|
declarations.forEach((item) => {
|
|
6665
|
-
let insertIndex =
|
|
7163
|
+
let insertIndex = runtimeInsertIndex;
|
|
6666
7164
|
item.dependencies.forEach((name) => {
|
|
6667
7165
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6668
7166
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6669
7167
|
});
|
|
6670
7168
|
body.splice(insertIndex, 0, item.declaration);
|
|
7169
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6671
7170
|
});
|
|
6672
7171
|
}
|
|
6673
7172
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -6844,4 +7343,4 @@ function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
|
6844
7343
|
//#endregion
|
|
6845
7344
|
export { normalizeSourcemapSourcePath as a, babelTransform as c, compareLayerPriority as d, SIDECAR_URL_GLOBAL_SYMBOL as f, getDefaultSourcemapUrl as i, extractCss as l, createCompilerCache as m, createCompiler as n, normalizePath as o, globalData as p, getStyleRuntimeImportPath as r, babelPlugin as s, CompilerRuntimeMode as t, isPromiseLike as u };
|
|
6846
7345
|
|
|
6847
|
-
//# sourceMappingURL=compiler-
|
|
7346
|
+
//# sourceMappingURL=compiler-BXcGyZUP.mjs.map
|