@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/atomic/atRule/utils.ts +3 -2
- package/atomic/className.ts +25 -4
- package/atomic/debug/className/className.ts +23 -2
- package/atomic/element.ts +5 -2
- package/atomic/theme.ts +4 -2
- package/atomic/token.ts +4 -2
- package/atomic/utils/css.ts +44 -19
- package/atomic/utils/format.ts +1 -1
- package/atomic/utils/hash.ts +78 -0
- package/atomic/var.ts +3 -2
- package/builder/classname/class_name_builder.ts +447 -0
- package/builder/classname/fns.ts +77 -0
- package/builder/classname/index.ts +3 -0
- package/builder/classname/types.ts +34 -0
- package/builder/data/create.ts +6 -6
- package/builder/data/data.ts +7 -7
- package/builder/data/debug.ts +1 -0
- package/builder/data/is.ts +3 -3
- package/builder/data/merge/scope.ts +18 -19
- package/builder/data/merge/style.ts +11 -0
- package/builder/data/state.ts +1 -0
- package/builder/style_builder.ts +17 -17
- package/builder/style_fns.ts +33 -33
- package/builder/types/alias.ts +10 -10
- package/builder/types/fns.ts +11 -11
- package/builder/types/types.ts +5 -5
- package/compiler/transform/debug/plugin.ts +8 -3
- package/compiler/transform/debug/utils/debug_data.ts +73 -0
- package/compiler/transform/evaluator/evaluator.ts +31 -2
- package/compiler/transform/evaluator/tracer.ts +2 -8
- package/compiler/transform/extract/chain/chain.ts +589 -24
- package/compiler/transform/extract/plugin.ts +4 -1
- package/compiler/utils/constants.ts +4 -0
- package/compiler/utils/file_resolver.ts +1 -0
- package/compiler/utils/import_source.ts +3 -2
- package/config/config/css.ts +3 -0
- package/config/config/dev.ts +9 -1
- package/config/types.ts +7 -0
- package/dialect/extracted/index.ts +5 -0
- package/dialect/index.ts +1 -0
- package/dialect/namedTokens.ts +136 -0
- package/dist/{className-DC2Cq8p3.js → className-Cuh2JNxO.js} +19 -7
- package/dist/className-Cuh2JNxO.js.map +1 -0
- package/dist/{className-C1Ht5Wvv.js → className-W2kDyeVl.js} +2 -2
- package/dist/{className-C1Ht5Wvv.js.map → className-W2kDyeVl.js.map} +1 -1
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-DENc3a2R.mjs → compiler-BXcGyZUP.mjs} +554 -60
- package/dist/compiler-BXcGyZUP.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-C1k9vUrM.js +32 -0
- package/dist/config-C1k9vUrM.js.map +1 -0
- package/dist/{config-BryWDfQX.js → config-CLYMN3_p.js} +3 -2
- package/dist/{config-BryWDfQX.js.map → config-CLYMN3_p.js.map} +1 -1
- package/dist/config-DcYrUB-M.js +6 -0
- package/dist/{config-Di2VYYKV.js.map → config-DcYrUB-M.js.map} +1 -1
- package/dist/config-oI_yS50f.js +1 -0
- package/dist/css-CELBp6Gu.js +58 -0
- package/dist/css-CELBp6Gu.js.map +1 -0
- package/dist/{css-BowBszUt.js → css-CohHH2tn.js} +17 -17
- package/dist/css-CohHH2tn.js.map +1 -0
- package/dist/{css-DcazYor9.js → css-D_DL1yOz.js} +10 -8
- package/dist/css-D_DL1yOz.js.map +1 -0
- package/dist/{css-ByOrugEX.js → css-DfH4Gb1c.js} +77 -77
- package/dist/css-DfH4Gb1c.js.map +1 -0
- package/dist/css.js +1 -1
- package/dist/{css_extra-oIi3UEPK.js → css_extra-9BZ_jVET.js} +2 -2
- package/dist/{css_extra-DlOnsnR1.js.map → css_extra-9BZ_jVET.js.map} +1 -1
- package/dist/{css_extra-DlOnsnR1.js → css_extra-DQdCrYoC.js} +2 -2
- package/dist/{css_extra-oIi3UEPK.js.map → css_extra-DQdCrYoC.js.map} +1 -1
- package/dist/{data-BsqOa5br.js → data-Ze8GNiJm.js} +22 -12
- package/dist/data-Ze8GNiJm.js.map +1 -0
- package/dist/{debug-BAw63qX6.js → debug-BefbXMq1.js} +2 -2
- package/dist/{debug-BAw63qX6.js.map → debug-BefbXMq1.js.map} +1 -1
- package/dist/{debug-n2aZQBSa.js → debug-DLmUG3Vh.js} +3 -3
- package/dist/debug-DLmUG3Vh.js.map +1 -0
- package/dist/{debug-DGki_v7g.js → debug-OG2wSB5R.js} +2 -2
- package/dist/{debug-DGki_v7g.js.map → debug-OG2wSB5R.js.map} +1 -1
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-DfBbuLeE.js → dev-4TqJORRn.js} +7 -3
- package/dist/dev-4TqJORRn.js.map +1 -0
- package/dist/{dev-CcphAa3R.js → dev-C2u78xuv.js} +7 -7
- package/dist/{dev-CcphAa3R.js.map → dev-C2u78xuv.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +2 -0
- package/dist/dialect/index.js +2 -0
- package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-BKzZyg5V.js} +10 -8
- package/dist/{elementMarker-Bu7gDAkE.js.map → elementMarker-BKzZyg5V.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -1
- package/dist/entry/dev/jsx-runtime.js +2 -1
- package/dist/entry/dev.js +12 -9
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/prod/jsx-runtime.js +2 -2
- package/dist/entry/prod/runtime.js +4 -4
- package/dist/entry/prod.js +8 -8
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +5 -5
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
- package/dist/entry/rsc-dev.js +342 -105
- package/dist/entry/rsc-dev.js.map +1 -1
- package/dist/entry/rsc-prod/css.js +2 -2
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
- package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
- package/dist/entry/rsc-prod/runtime.js +4 -4
- package/dist/entry/rsc-prod.js +7 -7
- package/dist/extract-B9j4TBkU.js +2 -0
- package/dist/{getClassName-BlvXHYuf.js → getClassName-C6690_nr.js} +3 -3
- package/dist/getClassName-C6690_nr.js.map +1 -0
- package/dist/global-C7GsCW6Y.js +14 -0
- package/dist/{global-CvfmFLsK.js.map → global-C7GsCW6Y.js.map} +1 -1
- package/dist/global-zaCE-g1C.js +31 -0
- package/dist/global-zaCE-g1C.js.map +1 -0
- package/dist/{format-3nKBE_5t.js → hash-Bycpk3MR.js} +53 -37
- package/dist/hash-Bycpk3MR.js.map +1 -0
- package/dist/index.js +10 -8
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.server.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.server.js +1 -1
- package/dist/{jsx-CwTeyUxr.js → jsx-Berx-L-r.js} +3 -3
- package/dist/{jsx-CwTeyUxr.js.map → jsx-Berx-L-r.js.map} +1 -1
- package/dist/{jsx-D2BksHSv.js → jsx-DsMajv_M.js} +7 -7
- package/dist/{jsx-D2BksHSv.js.map → jsx-DsMajv_M.js.map} +1 -1
- package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-DXlSD6kV.js} +2 -2
- package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-DXlSD6kV.js.map} +1 -1
- package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-CMdEXGNZ.js} +2 -2
- package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-CMdEXGNZ.js.map} +1 -1
- package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-DPWo5qvV.js} +2 -2
- package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-DPWo5qvV.js.map} +1 -1
- package/dist/{layer-D1SaH07m.js → layer-DiNeeTgG.js} +4 -4
- package/dist/{layer-D1SaH07m.js.map → layer-DiNeeTgG.js.map} +1 -1
- package/dist/{loader-B5Kw0DD-.mjs → loader-DCT1Q9yi.mjs} +3 -3
- package/dist/{loader-B5Kw0DD-.mjs.map → loader-DCT1Q9yi.mjs.map} +1 -1
- package/dist/{misc-DCdYYyhK.mjs → misc-o8pviMUi.mjs} +7 -3
- package/dist/{misc-DCdYYyhK.mjs.map → misc-o8pviMUi.mjs.map} +1 -1
- package/dist/namedTokens-BUa6raTb.js +83 -0
- package/dist/namedTokens-BUa6raTb.js.map +1 -0
- package/dist/plugin/farm/index.mjs +2 -2
- package/dist/plugin/nextjs/index.mjs +4 -4
- package/dist/plugin/nextjs/loader.mjs +4 -4
- package/dist/plugin/parcel/optimizer.cjs +1 -1
- package/dist/plugin/parcel/optimizer.mjs +2 -2
- package/dist/plugin/parcel/resolver.cjs +1 -1
- package/dist/plugin/parcel/resolver.mjs +2 -2
- package/dist/plugin/parcel/runtime.cjs +1 -1
- package/dist/plugin/parcel/runtime.mjs +1 -1
- package/dist/plugin/parcel/transformer.cjs +1 -1
- package/dist/plugin/parcel/transformer.mjs +2 -2
- package/dist/plugin/rspack/index.mjs +1 -1
- package/dist/plugin/vite/index.mjs +11 -8
- package/dist/plugin/vite/index.mjs.map +1 -1
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +971 -0
- package/dist/presets/tailwind/index.js.map +1 -0
- package/dist/{property-CnLFt5kx.js → property-BzZSTVIh.js} +2 -2
- package/dist/{property-CnLFt5kx.js.map → property-BzZSTVIh.js.map} +1 -1
- package/dist/{registry-yHLRxyoo.mjs → registry-D3x1EDJm.mjs} +2 -2
- package/dist/{registry-yHLRxyoo.mjs.map → registry-D3x1EDJm.mjs.map} +1 -1
- package/dist/{rules-9HSO1pxL.js → rules-Dz7Pu2K6.js} +13 -10
- package/dist/rules-Dz7Pu2K6.js.map +1 -0
- package/dist/{runtime-CYqNCiaM.js → runtime-B3jHW9B1.js} +3 -24
- package/dist/runtime-B3jHW9B1.js.map +1 -0
- package/dist/server.js +13 -11
- package/dist/server.js.map +1 -1
- package/dist/{shared-CBArHB9-.cjs → shared-B_gJf5uj.cjs} +554 -60
- package/dist/shared-B_gJf5uj.cjs.map +1 -0
- package/dist/{shared-CxbHR89f.mjs → shared-uAzFeq0x.mjs} +4 -4
- package/dist/{shared-CxbHR89f.mjs.map → shared-uAzFeq0x.mjs.map} +1 -1
- package/dist/sheet-DasbRnvy.js +7 -0
- package/dist/sheet-DasbRnvy.js.map +1 -0
- package/dist/{sidecar-BFakLl0X.mjs → sidecar-BUO1hKXu.mjs} +3 -3
- package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BUO1hKXu.mjs.map} +1 -1
- package/dist/style-B0F1sgRZ.js +5 -0
- package/dist/{style-DgHbdbdF.js → style-BkeAZl0n.js} +258 -82
- package/dist/style-BkeAZl0n.js.map +1 -0
- package/dist/{style-B1UUqjj5.js → style-CYXTs1iu.js} +35 -7
- package/dist/style-CYXTs1iu.js.map +1 -0
- package/dist/{style-v2bf70TZ.js → style-DUztHzBz.js} +439 -123
- package/dist/style-DUztHzBz.js.map +1 -0
- package/dist/{styleStore-Dea_WVbr.js → styleStore-BGJ2ZYtK.js} +16 -7
- package/dist/styleStore-BGJ2ZYtK.js.map +1 -0
- package/dist/{styleStore-DyNXBcUK.js → styleStore-DVDp-gI-.js} +6 -5
- package/dist/{styleStore-DyNXBcUK.js.map → styleStore-DVDp-gI-.js.map} +1 -1
- package/dist/{token-u_tM-mtg.js → token-CA1j7suG.js} +99 -30
- package/dist/token-CA1j7suG.js.map +1 -0
- package/dist/token-DTOyFLmp.js +58 -0
- package/dist/token-DTOyFLmp.js.map +1 -0
- package/dist/{trace-CU0rvNYr.js → trace-D0IL6JT8.js} +2 -2
- package/dist/{trace-CU0rvNYr.js.map → trace-D0IL6JT8.js.map} +1 -1
- package/dist/{trace-Bu_qOqRy.js → trace-DR7_Rpkg.js} +3 -3
- package/dist/{trace-Bu_qOqRy.js.map → trace-DR7_Rpkg.js.map} +1 -1
- package/dist/transform-BTJOg8Hg.js +23 -0
- package/dist/transform-BTJOg8Hg.js.map +1 -0
- package/dist/{utils-BbehLOby.js → utils-BsbfH6cd.js} +147 -76
- package/dist/utils-BsbfH6cd.js.map +1 -0
- package/dist/{utils-CEaq_c-A.mjs → utils-CpA-dSpY.mjs} +4 -4
- package/dist/{utils-CEaq_c-A.mjs.map → utils-CpA-dSpY.mjs.map} +1 -1
- package/dist/{utils-D7FAOyg6.js → utils-D4YWF2K0.js} +4 -4
- package/dist/{utils-D7FAOyg6.js.map → utils-D4YWF2K0.js.map} +1 -1
- package/dist/{utils-Bdbqn0f8.mjs → utils-DQGa0uzS.mjs} +3 -3
- package/dist/{utils-Bdbqn0f8.mjs.map → utils-DQGa0uzS.mjs.map} +1 -1
- package/dist/{utils-CWNHx4EC.js → utils-R6QadAsY.js} +3 -3
- package/dist/{utils-CWNHx4EC.js.map → utils-R6QadAsY.js.map} +1 -1
- package/dist/utils.js +3 -3
- package/dist/value-CJG6EWe8.js +85 -0
- package/dist/value-CJG6EWe8.js.map +1 -0
- package/dist/value-D-ZcRzLA.js +42 -0
- package/dist/value-D-ZcRzLA.js.map +1 -0
- package/dist/{value-BR4e2MKt.js → value-DBtSe-9B.js} +116 -26
- package/dist/value-DBtSe-9B.js.map +1 -0
- package/dist/{valueRef-lshFk1Cs.js → valueRef-CsLVJwjA.js} +2 -2
- package/dist/{valueRef-lshFk1Cs.js.map → valueRef-CsLVJwjA.js.map} +1 -1
- package/dist/{webpack-Dh6lox2l.mjs → webpack-Fb9xF5jS.mjs} +5 -5
- package/dist/{webpack-Dh6lox2l.mjs.map → webpack-Fb9xF5jS.mjs.map} +1 -1
- package/entry/dev/config.ts +1 -1
- package/entry/dev/index.ts +1 -0
- package/entry/dev/jsx_dev_runtime.ts +1 -0
- package/entry/dev/jsx_runtime.ts +1 -0
- package/entry/dev/sheet.ts +4 -0
- package/entry/prod/runtime.ts +1 -1
- package/entry/rsc_dev/config.ts +1 -1
- package/entry/rsc_dev/server.ts +1 -1
- package/entry/rsc_prod/runtime.ts +1 -1
- package/entry/rsc_prod/server.ts +1 -1
- package/entry/shared/config_dev.ts +12 -0
- package/entry/shared/dev.ts +11 -2
- package/entry/shared/utils.ts +28 -0
- package/package.json +26 -9
- package/plugin/bundler/vite/plugin.ts +2 -1
- package/plugin/bundler/vite/state.ts +10 -5
- package/plugin/utils/runtimeEntry.ts +12 -0
- package/presets/tailwind/classname/index.ts +2 -0
- package/presets/tailwind/classname/transform.ts +208 -0
- package/presets/tailwind/classname/types.ts +124 -0
- package/presets/tailwind/index.ts +5 -0
- package/presets/tailwind/selectors.ts +27 -0
- package/presets/tailwind/style/index.ts +2 -0
- package/presets/tailwind/style/transform.ts +430 -0
- package/presets/tailwind/style/types.ts +346 -0
- package/presets/tailwind/theme.ts +479 -0
- package/presets/tailwind/types.ts +147 -0
- package/runtime/core/cache/pool.ts +1 -1
- package/runtime/extract/getClassName.ts +1 -6
- package/runtime/extract/index.ts +1 -1
- package/runtime/index.ts +8 -1
- package/runtime/types.ts +4 -2
- package/style/classname.ts +41 -0
- package/style/index.ts +1 -0
- package/style/style.ts +30 -11
- package/style/theme.ts +4 -2
- package/style/transform.ts +41 -2
- package/utils/hash.ts +4 -0
- package/atomic/layer/README.md +0 -116
- package/dist/className-DC2Cq8p3.js.map +0 -1
- package/dist/compiler-DENc3a2R.mjs.map +0 -1
- package/dist/config-DKHXWhe1.js +0 -1
- package/dist/config-Di2VYYKV.js +0 -6
- package/dist/config-DloHOG6I.js +0 -13
- package/dist/config-DloHOG6I.js.map +0 -1
- package/dist/css-BowBszUt.js.map +0 -1
- package/dist/css-ByOrugEX.js.map +0 -1
- package/dist/css-DcazYor9.js.map +0 -1
- package/dist/data-BsqOa5br.js.map +0 -1
- package/dist/debug-n2aZQBSa.js.map +0 -1
- package/dist/dev-DfBbuLeE.js.map +0 -1
- package/dist/extract-DEwSDJ9Z.js +0 -2
- package/dist/format-3nKBE_5t.js.map +0 -1
- package/dist/getClassName-BlvXHYuf.js.map +0 -1
- package/dist/global-CvfmFLsK.js +0 -11
- package/dist/rules-9HSO1pxL.js.map +0 -1
- package/dist/runtime-CYqNCiaM.js.map +0 -1
- package/dist/shared-CBArHB9-.cjs.map +0 -1
- package/dist/style-B-6jHipw.js +0 -5
- package/dist/style-B1UUqjj5.js.map +0 -1
- package/dist/style-DgHbdbdF.js.map +0 -1
- package/dist/style-v2bf70TZ.js.map +0 -1
- package/dist/styleStore-Dea_WVbr.js.map +0 -1
- package/dist/token-u_tM-mtg.js.map +0 -1
- package/dist/utils-BbehLOby.js.map +0 -1
- package/dist/value-BR4e2MKt.js.map +0 -1
- package/dist/value-E8rEv2Oe.js +0 -136
- package/dist/value-E8rEv2Oe.js.map +0 -1
|
@@ -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
|
}
|
|
@@ -803,7 +842,7 @@ function createNameFormatter(keys) {
|
|
|
803
842
|
const name = getFormatFn(format)(info);
|
|
804
843
|
if (!hash) return name;
|
|
805
844
|
if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
|
|
806
|
-
return name ? name + "
|
|
845
|
+
return name ? name + "--" + hash : hash;
|
|
807
846
|
};
|
|
808
847
|
}
|
|
809
848
|
function compileFormat(format, keySet) {
|
|
@@ -897,8 +936,12 @@ const formatClassName = createNameFormatter([
|
|
|
897
936
|
"value"
|
|
898
937
|
]);
|
|
899
938
|
const formatScopeClassName = createNameFormatter(["className"]);
|
|
939
|
+
const formatTransformClassName = createNameFormatter(["className"]);
|
|
900
940
|
function getDebugClassName(format, hash, info) {
|
|
901
|
-
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);
|
|
902
945
|
}
|
|
903
946
|
function getDebugScopeClassName(format, info) {
|
|
904
947
|
return formatScopeClassName(format || "-(className)", null, info);
|
|
@@ -916,20 +959,38 @@ function escapeCssValue(value) {
|
|
|
916
959
|
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
917
960
|
}
|
|
918
961
|
function escapeCssIdent(ident) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
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;
|
|
923
990
|
}
|
|
924
991
|
function sanitizeCssIdentName(value, fallback = "") {
|
|
925
992
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
|
|
926
993
|
}
|
|
927
|
-
function getIdentifierSafeHash(value) {
|
|
928
|
-
const hash = hashString(value);
|
|
929
|
-
const first = hash.charCodeAt(0);
|
|
930
|
-
if (first < 48 || first > 57) return hash;
|
|
931
|
-
return String.fromCharCode(97 + first - 48) + hash.slice(1);
|
|
932
|
-
}
|
|
933
994
|
//#endregion
|
|
934
995
|
//#region atomic/utils/debug.ts
|
|
935
996
|
function normalizeDebugKeywordValue(value) {
|
|
@@ -1087,6 +1148,54 @@ function parseAtRule(rule) {
|
|
|
1087
1148
|
return compressQuery(normalized);
|
|
1088
1149
|
}
|
|
1089
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
|
|
1090
1199
|
//#region atomic/utils/selector.ts
|
|
1091
1200
|
function getSelectorText(selector) {
|
|
1092
1201
|
return Array.isArray(selector) ? selector[0] : selector;
|
|
@@ -1100,7 +1209,7 @@ function getSelectorPriority(selector) {
|
|
|
1100
1209
|
}
|
|
1101
1210
|
//#endregion
|
|
1102
1211
|
//#region atomic/className.ts
|
|
1103
|
-
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) {
|
|
1104
1213
|
let hash = property;
|
|
1105
1214
|
hash += "\n" + (priority || "");
|
|
1106
1215
|
hash += "\n" + value;
|
|
@@ -1108,8 +1217,9 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1108
1217
|
hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
|
|
1109
1218
|
hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
|
|
1110
1219
|
hash += "\n" + getCallsiteHash(callsite, localClassName);
|
|
1111
|
-
hash = getIdentifierSafeHash(hash);
|
|
1220
|
+
hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
|
|
1112
1221
|
if (!debugClassName) return hash;
|
|
1222
|
+
if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
|
|
1113
1223
|
const propertyName = getDebugPropertyName(property, value);
|
|
1114
1224
|
return getDebugClassName(classNameFormat, hash, {
|
|
1115
1225
|
atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText)) : null,
|
|
@@ -1119,6 +1229,10 @@ function getAtomicClassName(property, priority, value, selector, parentSelector,
|
|
|
1119
1229
|
value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
|
|
1120
1230
|
});
|
|
1121
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
|
+
}
|
|
1122
1236
|
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1123
1237
|
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1124
1238
|
}
|
|
@@ -1207,7 +1321,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1207
1321
|
value = value[0];
|
|
1208
1322
|
}
|
|
1209
1323
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
|
|
1210
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
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);
|
|
1211
1325
|
scopeItem.dedupe = dedupe;
|
|
1212
1326
|
scopeItem.className = className;
|
|
1213
1327
|
scopeItem.callsite = itemCallsite;
|
|
@@ -1245,6 +1359,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1245
1359
|
className: "",
|
|
1246
1360
|
property: overrideItem.property,
|
|
1247
1361
|
value: overrideItem.value,
|
|
1362
|
+
transformClassName: overrideItem.transformClassName,
|
|
1248
1363
|
token: overrideItem.token,
|
|
1249
1364
|
selector: overrideItem.selector,
|
|
1250
1365
|
atRule,
|
|
@@ -1260,7 +1375,7 @@ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRu
|
|
|
1260
1375
|
value = value[0];
|
|
1261
1376
|
}
|
|
1262
1377
|
dedupe = getClassNameDedupe(scopeItem.property, priority, scopeItem.selector, parentSelector, scopeItem.atRule);
|
|
1263
|
-
className = getAtomicClassName(scopeItem.property, priority, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
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);
|
|
1264
1379
|
scopeItem.dedupe = dedupe;
|
|
1265
1380
|
scopeItem.className = className;
|
|
1266
1381
|
const lookupKey = getScopeLookupKey(slotId, dedupe);
|
|
@@ -1328,7 +1443,7 @@ function getTokenLookupKey(tokenId) {
|
|
|
1328
1443
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1329
1444
|
function getTokenVarName(token, format) {
|
|
1330
1445
|
const id = getStyleTokenId(token);
|
|
1331
|
-
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id), { name: id });
|
|
1446
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: id });
|
|
1332
1447
|
}
|
|
1333
1448
|
function getTokenVar(token, format) {
|
|
1334
1449
|
return getTokenVarFallback(token, format);
|
|
@@ -1403,6 +1518,19 @@ function shouldAppendCssPx(property) {
|
|
|
1403
1518
|
return !UNITLESS.has(property);
|
|
1404
1519
|
}
|
|
1405
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
|
|
1406
1534
|
//#region style/valueRef.ts
|
|
1407
1535
|
const AT_RULE_REF = symbol("atRule.ref");
|
|
1408
1536
|
function createAtRuleRef(data) {
|
|
@@ -1432,6 +1560,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1432
1560
|
let token;
|
|
1433
1561
|
let ref;
|
|
1434
1562
|
let variableName;
|
|
1563
|
+
let transformClassName;
|
|
1435
1564
|
let lookupIndex;
|
|
1436
1565
|
if (isStyleData(style)) {
|
|
1437
1566
|
const stylesItems = style[BUILDER_STATE].items;
|
|
@@ -1469,6 +1598,11 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1469
1598
|
priority = valueRaw[0];
|
|
1470
1599
|
valueRaw = valueRaw[1];
|
|
1471
1600
|
}
|
|
1601
|
+
transformClassName = null;
|
|
1602
|
+
if (isClassNameValue(valueRaw)) {
|
|
1603
|
+
transformClassName = valueRaw.className;
|
|
1604
|
+
valueRaw = valueRaw.value;
|
|
1605
|
+
}
|
|
1472
1606
|
ref = isAtRuleRef(valueRaw) ? valueRaw : null;
|
|
1473
1607
|
if (ref) valueRaw = ref.value;
|
|
1474
1608
|
token = isStyleTokenData(valueRaw) ? valueRaw : null;
|
|
@@ -1484,6 +1618,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1484
1618
|
className: "",
|
|
1485
1619
|
property,
|
|
1486
1620
|
value,
|
|
1621
|
+
transformClassName,
|
|
1487
1622
|
variable: ref ? [3, ref] : variableName && token ? [
|
|
1488
1623
|
1,
|
|
1489
1624
|
variableName,
|
|
@@ -1548,7 +1683,7 @@ function mergeBuilderData(create, callsite, source, style, debug, selector, atRu
|
|
|
1548
1683
|
value = value[0];
|
|
1549
1684
|
}
|
|
1550
1685
|
dedupe = getClassNameDedupe(runtimeItem.property, priority, runtimeItem.selector, null, runtimeItem.atRule);
|
|
1551
|
-
className = getAtomicClassName(runtimeItem.property, priority, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null);
|
|
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);
|
|
1552
1687
|
runtimeItem.dedupe = dedupe;
|
|
1553
1688
|
runtimeItem.className = className;
|
|
1554
1689
|
lookupIndex = lookup[dedupe];
|
|
@@ -2345,7 +2480,7 @@ function getCssPropertyName(property) {
|
|
|
2345
2480
|
function createAtRuleNameFormatter(defaultFormat, prefix) {
|
|
2346
2481
|
const formatter = createNameFormatter(["name"]);
|
|
2347
2482
|
return (format, id, info) => {
|
|
2348
|
-
const hash = getIdentifierSafeHash(id);
|
|
2483
|
+
const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
|
|
2349
2484
|
const name = formatter(format || defaultFormat, hash, info);
|
|
2350
2485
|
if (!prefix) return name;
|
|
2351
2486
|
return name.startsWith(prefix) ? name : prefix + name;
|
|
@@ -2556,11 +2691,11 @@ function createStyleFn(args) {
|
|
|
2556
2691
|
style.plain = fnPlain;
|
|
2557
2692
|
style.keyframes = fnKeyframes;
|
|
2558
2693
|
style.merge = fnMerge;
|
|
2559
|
-
|
|
2694
|
+
assignStyleFnMeta(style, {
|
|
2695
|
+
mode: "StyleObject",
|
|
2560
2696
|
selectors,
|
|
2561
2697
|
transform: transform ?? null
|
|
2562
|
-
};
|
|
2563
|
-
Object.assign(style, { [META]: meta });
|
|
2698
|
+
});
|
|
2564
2699
|
return { style };
|
|
2565
2700
|
}
|
|
2566
2701
|
function mergeStyleResult(target, style) {
|
|
@@ -2569,12 +2704,17 @@ function mergeStyleResult(target, style) {
|
|
|
2569
2704
|
if (typeof chainMerge === "function") return chainMerge.call(target, style);
|
|
2570
2705
|
return target;
|
|
2571
2706
|
}
|
|
2707
|
+
function assignStyleFnMeta(styleFn, meta) {
|
|
2708
|
+
Object.assign(styleFn, { [META]: meta });
|
|
2709
|
+
return styleFn;
|
|
2710
|
+
}
|
|
2572
2711
|
function getStyleFnMeta(styleFn) {
|
|
2573
2712
|
return styleFn[META];
|
|
2574
2713
|
}
|
|
2575
2714
|
//#endregion
|
|
2576
2715
|
//#region compiler/utils/import_source.ts
|
|
2577
2716
|
const DefaultStyleFnMeta = {
|
|
2717
|
+
mode: "StyleObject",
|
|
2578
2718
|
selectors: PrioritySelectors,
|
|
2579
2719
|
transform: null
|
|
2580
2720
|
};
|
|
@@ -2827,6 +2967,65 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
2827
2967
|
}
|
|
2828
2968
|
}
|
|
2829
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
|
|
2830
3029
|
//#region style/utils/expose.ts
|
|
2831
3030
|
function exposeStyle(styles) {
|
|
2832
3031
|
return exposeStyleObject(styles);
|
|
@@ -2882,6 +3081,7 @@ function evaluateNode(node, scope) {
|
|
|
2882
3081
|
case "ParenthesizedExpression":
|
|
2883
3082
|
case "TSAsExpression":
|
|
2884
3083
|
case "TSNonNullExpression":
|
|
3084
|
+
case "TSSatisfiesExpression":
|
|
2885
3085
|
case "TSTypeAssertion": return evaluateNode(node.expression, scope);
|
|
2886
3086
|
default: return evalFail(`Cannot statically evaluate: ${node.type}`);
|
|
2887
3087
|
}
|
|
@@ -2954,14 +3154,14 @@ function evaluateMember(node, scope) {
|
|
|
2954
3154
|
if (!key.ok) return key;
|
|
2955
3155
|
const obj = evaluateNode(node.object, scope);
|
|
2956
3156
|
if (!obj.ok) return obj;
|
|
2957
|
-
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]);
|
|
2958
3158
|
return evalFail("Cannot index non-object");
|
|
2959
3159
|
}
|
|
2960
3160
|
const prop = node.property.name;
|
|
2961
3161
|
const obj = evaluateNode(node.object, scope);
|
|
2962
3162
|
if (!obj.ok) return obj;
|
|
2963
3163
|
if (obj.value == null) return evalFail(`Cannot access .${prop} on null/undefined`);
|
|
2964
|
-
if (typeof obj.value !== "object" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
3164
|
+
if (typeof obj.value !== "object" && typeof obj.value !== "function" && typeof obj.value !== "string") return evalFail(`Cannot access .${prop} on ${typeof obj.value}`);
|
|
2965
3165
|
return evalOk(obj.value[prop]);
|
|
2966
3166
|
}
|
|
2967
3167
|
function evaluateObject(node, scope) {
|
|
@@ -3000,7 +3200,7 @@ function evaluateObject(node, scope) {
|
|
|
3000
3200
|
} else key = prop.key.type === "Identifier" ? prop.key.name : prop.key.value;
|
|
3001
3201
|
const val = evaluateNode(prop.value, scope);
|
|
3002
3202
|
if (!val.ok && isRequiredStaticStyleValueFail(val.reason)) return val;
|
|
3003
|
-
result[key] = val.ok ? val.value : createCompiledRuntimeValue(prop.value);
|
|
3203
|
+
result[key] = val.ok ? val.value : createCompiledRuntimeValue$1(prop.value);
|
|
3004
3204
|
if (prop.loc?.start) locations[key] = {
|
|
3005
3205
|
line: prop.loc.start.line,
|
|
3006
3206
|
column: prop.loc.start.column + 1,
|
|
@@ -3165,6 +3365,23 @@ function evaluateCall(node, scope) {
|
|
|
3165
3365
|
if (!debugId.ok) return debugId;
|
|
3166
3366
|
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, debugId.value));
|
|
3167
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
|
+
}
|
|
3168
3385
|
if (imp && imp.source === "@fluentic/style/utils" && imp.name === "exposeStyle") {
|
|
3169
3386
|
const styles = evaluateNode(node.arguments[0], scope);
|
|
3170
3387
|
if (!styles.ok) return styles;
|
|
@@ -3377,7 +3594,7 @@ function withRuntimeValue(runtimeValue, token) {
|
|
|
3377
3594
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3378
3595
|
});
|
|
3379
3596
|
}
|
|
3380
|
-
function createCompiledRuntimeValue(runtimeValue) {
|
|
3597
|
+
function createCompiledRuntimeValue$1(runtimeValue) {
|
|
3381
3598
|
return { [COMPILED_RUNTIME_VALUE]: runtimeValue };
|
|
3382
3599
|
}
|
|
3383
3600
|
function evaluateBinary(node, scope) {
|
|
@@ -3433,7 +3650,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3433
3650
|
}
|
|
3434
3651
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3435
3652
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3436
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id), { name });
|
|
3653
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3437
3654
|
}
|
|
3438
3655
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3439
3656
|
const declarations = [];
|
|
@@ -3758,12 +3975,12 @@ function normalizeSelectorMessage(message) {
|
|
|
3758
3975
|
}
|
|
3759
3976
|
const formatVarName = createNameFormatter(["name"]);
|
|
3760
3977
|
function getLocalVarName(filePath, line, column, format) {
|
|
3761
|
-
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column);
|
|
3978
|
+
const hash = getIdentifierSafeHash(filePath + "\n" + line + ":" + column, CSS_CONFIG.hashLength);
|
|
3762
3979
|
return "--" + formatVarName(format || "var[-(name)]-$hash", hash, { name: "" });
|
|
3763
3980
|
}
|
|
3764
3981
|
//#endregion
|
|
3765
3982
|
//#region compiler/transform/debug/utils/debug_data.ts
|
|
3766
|
-
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride) {
|
|
3983
|
+
function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, tokenNameFormat = DEFAULT_CONFIG.tokenNameFormat, styleArg = node.arguments[0], locOverride, classNameArg = false) {
|
|
3767
3984
|
const loc = locOverride ?? node.loc?.start;
|
|
3768
3985
|
const line = loc?.line ?? 1;
|
|
3769
3986
|
const column = (loc?.column ?? 0) + 1;
|
|
@@ -3780,10 +3997,46 @@ function buildDebugDataObject(t, node, fileId, sourceUrlRef, sourceContentRef, t
|
|
|
3780
3997
|
t.objectProperty(t.identifier("fields"), buildFields(t, styleArg)),
|
|
3781
3998
|
t.objectProperty(t.identifier("vars"), buildVars(t, styleArg, fileId, tokenNameFormat))
|
|
3782
3999
|
];
|
|
4000
|
+
if (classNameArg) properties.push(t.objectProperty(t.identifier("classNames"), buildClassNames(t, node.arguments)));
|
|
3783
4001
|
properties.push(t.objectProperty(t.identifier("sourceUrl"), sourceUrlRef));
|
|
3784
4002
|
if (sourceContentRef) properties.push(t.objectProperty(t.identifier("code"), sourceContentRef));
|
|
3785
4003
|
return t.objectExpression(properties);
|
|
3786
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
|
+
}
|
|
3787
4040
|
function getShortLabel(label) {
|
|
3788
4041
|
const parts = label.split(".");
|
|
3789
4042
|
return parts[parts.length - 1] || label;
|
|
@@ -3942,7 +4195,9 @@ function createDebugPlugin(args) {
|
|
|
3942
4195
|
if (hasDebugArgument(path.node.arguments)) return;
|
|
3943
4196
|
const sourceUrlRef = getSourceUrlId(t, state);
|
|
3944
4197
|
const sourceContentRef = sourceContent ? getSourceContentId(t, state) : null;
|
|
3945
|
-
|
|
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));
|
|
3946
4201
|
},
|
|
3947
4202
|
JSXOpeningElement(path, state) {
|
|
3948
4203
|
if (options.dev?.elementClassName === false) return;
|
|
@@ -4533,6 +4788,12 @@ function transformDebug(internal, args, deps) {
|
|
|
4533
4788
|
//#region compiler/utils/file_resolver.ts
|
|
4534
4789
|
const contentCache = /* @__PURE__ */ new Map();
|
|
4535
4790
|
const resolver = new ResolverFactory({
|
|
4791
|
+
conditionNames: [
|
|
4792
|
+
"import",
|
|
4793
|
+
"module",
|
|
4794
|
+
"default",
|
|
4795
|
+
"types"
|
|
4796
|
+
],
|
|
4536
4797
|
extensions: [
|
|
4537
4798
|
".ts",
|
|
4538
4799
|
".tsx",
|
|
@@ -4692,8 +4953,101 @@ function extractStyleChain(node, styleNames) {
|
|
|
4692
4953
|
}
|
|
4693
4954
|
//#endregion
|
|
4694
4955
|
//#region compiler/transform/extract/chain/chain.ts
|
|
4695
|
-
function applyTransform(styleObj, transform) {
|
|
4696
|
-
|
|
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;
|
|
4697
5051
|
}
|
|
4698
5052
|
/**
|
|
4699
5053
|
* Compile a parsed chain into extracted items and CSS rules.
|
|
@@ -4701,6 +5055,10 @@ function applyTransform(styleObj, transform) {
|
|
|
4701
5055
|
*/
|
|
4702
5056
|
function compileChain(chain, fileId, nodeLoc, scope, opts, meta, styleNames = /* @__PURE__ */ new Set()) {
|
|
4703
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
|
+
}
|
|
4704
5062
|
const selectors = meta.selectors;
|
|
4705
5063
|
const transform = meta.transform;
|
|
4706
5064
|
if (chain.kind === "style") return compileStyleChain(chain, selectors, fileId, scope, css, transform, styleNames, opts);
|
|
@@ -4712,6 +5070,8 @@ function getCssConfig(opts) {
|
|
|
4712
5070
|
const css = opts.css;
|
|
4713
5071
|
return {
|
|
4714
5072
|
classNameFormat: css?.classNameFormat ?? DEFAULT_CONFIG.classNameFormat ?? null,
|
|
5073
|
+
transformClassNameFormat: css?.transformClassNameFormat ?? DEFAULT_CONFIG.transformClassNameFormat ?? null,
|
|
5074
|
+
hashLength: css?.hashLength ?? DEFAULT_CONFIG.hashLength ?? 7,
|
|
4715
5075
|
tokenNameFormat: css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null,
|
|
4716
5076
|
localClassName: css?.localClassName ?? DEFAULT_CONFIG.localClassName,
|
|
4717
5077
|
debugClassName: css?.debugClassName ?? DEFAULT_CONFIG.debugClassName,
|
|
@@ -4732,6 +5092,133 @@ function compileStyleChain(chain, selectors, fileId, scope, cssConfig, transform
|
|
|
4732
5092
|
rules
|
|
4733
5093
|
};
|
|
4734
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
|
+
}
|
|
4735
5222
|
function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, transform, type, slotId, atRules, items, rules, styleNames, options, callsiteOverride = null) {
|
|
4736
5223
|
if (chain.baseArgs.length > 0) {
|
|
4737
5224
|
const styleArg = evaluateNode(chain.baseArgs[0], scope);
|
|
@@ -4739,7 +5226,7 @@ function compileStyleChainInto(chain, selectors, fileId, scope, cssConfig, trans
|
|
|
4739
5226
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4740
5227
|
return false;
|
|
4741
5228
|
}
|
|
4742
|
-
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;
|
|
4743
5230
|
}
|
|
4744
5231
|
let i = 0;
|
|
4745
5232
|
while (i < chain.methods.length) {
|
|
@@ -4758,7 +5245,7 @@ function compileSlotChain(chain, slotId, selectors, fileId, scope, cssConfig, tr
|
|
|
4758
5245
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
4759
5246
|
return null;
|
|
4760
5247
|
}
|
|
4761
|
-
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;
|
|
4762
5249
|
}
|
|
4763
5250
|
let i = 0;
|
|
4764
5251
|
while (i < chain.methods.length) {
|
|
@@ -4876,14 +5363,14 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4876
5363
|
return true;
|
|
4877
5364
|
}
|
|
4878
5365
|
if (node.type !== "CallExpression") return false;
|
|
4879
|
-
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, transform, options);
|
|
5366
|
+
const overrideChain = extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options);
|
|
4880
5367
|
if (!overrideChain) return false;
|
|
4881
5368
|
const { slotId, items: overrideItems } = overrideChain;
|
|
4882
5369
|
let i = 0;
|
|
4883
5370
|
while (i < overrideItems.length) {
|
|
4884
5371
|
const overrideItem = overrideItems[i];
|
|
4885
5372
|
const mergedAtRules = mergeAtRules(atRules, overrideItem.atRules);
|
|
4886
|
-
if (overrideItem.chain && overrideItem.meta) {
|
|
5373
|
+
if (overrideItem.chain && overrideItem.meta?.mode === "StyleObject") {
|
|
4887
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;
|
|
4888
5375
|
} else if (overrideItem.styleData !== void 0) {
|
|
4889
5376
|
if (!addStyleDataItems(overrideItem.styleData, overrideItem.selector, parentSelector, mergedAtRules, fileId, 4, slotId, items, cssRules, cssConfig, overrideItem.callsiteOverride)) return false;
|
|
@@ -4892,15 +5379,15 @@ function resolveSlotOverrideNode(node, parentSelector, atRules, selectors, fileI
|
|
|
4892
5379
|
}
|
|
4893
5380
|
return true;
|
|
4894
5381
|
}
|
|
4895
|
-
function extractOverrideChain(node, selectors, scope, fileId, transform, options) {
|
|
5382
|
+
function extractOverrideChain(node, selectors, scope, fileId, cssConfig, transform, options) {
|
|
4896
5383
|
const callee = node.callee;
|
|
4897
5384
|
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
4898
5385
|
const methodName = callee.property.name;
|
|
4899
5386
|
const obj = callee.object;
|
|
4900
5387
|
if (obj.type === "CallExpression") {
|
|
4901
|
-
const inner = extractOverrideChain(obj, selectors, scope, fileId, transform, options);
|
|
5388
|
+
const inner = extractOverrideChain(obj, selectors, scope, fileId, cssConfig, transform, options);
|
|
4902
5389
|
if (!inner) return null;
|
|
4903
|
-
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);
|
|
4904
5391
|
if (!overrideItem) return null;
|
|
4905
5392
|
return {
|
|
4906
5393
|
slotId: inner.slotId,
|
|
@@ -4915,7 +5402,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4915
5402
|
const styleArg = evaluateNode(node.arguments[0], scope);
|
|
4916
5403
|
if (!styleArg.ok) return null;
|
|
4917
5404
|
items.push({
|
|
4918
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5405
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4919
5406
|
selector: null,
|
|
4920
5407
|
atRules: null
|
|
4921
5408
|
});
|
|
@@ -4925,7 +5412,7 @@ function extractOverrideChain(node, selectors, scope, fileId, transform, options
|
|
|
4925
5412
|
items
|
|
4926
5413
|
};
|
|
4927
5414
|
}
|
|
4928
|
-
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, transform, options) {
|
|
5415
|
+
function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, cssConfig, transform, options) {
|
|
4929
5416
|
const sel = selectors[methodName];
|
|
4930
5417
|
if (!sel) return null;
|
|
4931
5418
|
validateSelectorDefinition(options.dev?.checkSelector, `style.${methodName}`, sel);
|
|
@@ -4952,7 +5439,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4952
5439
|
callsiteOverride
|
|
4953
5440
|
};
|
|
4954
5441
|
return {
|
|
4955
|
-
styleObj: applyTransform(styleArg.value ?? {}, transform),
|
|
5442
|
+
styleObj: applyTransform(styleArg.value ?? {}, transform, cssConfig),
|
|
4956
5443
|
selector: null,
|
|
4957
5444
|
atRules: null,
|
|
4958
5445
|
callsiteOverride
|
|
@@ -4977,7 +5464,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4977
5464
|
if (!styleArg.ok) return null;
|
|
4978
5465
|
const atRuleSelector = priority !== null ? [atRule, priority] : atRule;
|
|
4979
5466
|
return {
|
|
4980
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5467
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4981
5468
|
selector: null,
|
|
4982
5469
|
atRules: [atRuleSelector]
|
|
4983
5470
|
};
|
|
@@ -4993,7 +5480,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
4993
5480
|
const selectorText = before + normalizeSelectorArg(String(selectorArg.value ?? "")) + (after ?? "");
|
|
4994
5481
|
const itemSelector = sel.priority !== null ? [selectorText, sel.priority] : selectorText;
|
|
4995
5482
|
return {
|
|
4996
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5483
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
4997
5484
|
selector: itemSelector,
|
|
4998
5485
|
atRules: null
|
|
4999
5486
|
};
|
|
@@ -5001,7 +5488,7 @@ function resolveOverrideMethod(methodName, args, nameNode, selectors, scope, tra
|
|
|
5001
5488
|
const styleArg = evaluateNode(args[0], scope);
|
|
5002
5489
|
if (!styleArg.ok) return null;
|
|
5003
5490
|
return {
|
|
5004
|
-
styleObj: applyTransform(styleArg.value, transform),
|
|
5491
|
+
styleObj: applyTransform(styleArg.value, transform, cssConfig),
|
|
5005
5492
|
selector: sel.priority !== null ? [selectorStr, sel.priority] : selectorStr,
|
|
5006
5493
|
atRules: null
|
|
5007
5494
|
};
|
|
@@ -5085,7 +5572,7 @@ function compileChainMethod(method, selectors, slotId, fileId, scope, type, cssC
|
|
|
5085
5572
|
throwIfRequiredStaticStyleValue(styleArg);
|
|
5086
5573
|
return false;
|
|
5087
5574
|
}
|
|
5088
|
-
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);
|
|
5089
5576
|
}
|
|
5090
5577
|
function compileMergeArg(styleArgNode, mergeNode, fileId, scope, type, slotId, atRules, cssConfig, items, cssRules, styleNames, options, callsiteOverride = null) {
|
|
5091
5578
|
if (!styleArgNode) return false;
|
|
@@ -5166,14 +5653,14 @@ function compileAtRuleMethod(method, slotId, selector, selectorStr, fileId, scop
|
|
|
5166
5653
|
throwIfRequiredStaticStyleValue(evaled);
|
|
5167
5654
|
return false;
|
|
5168
5655
|
}
|
|
5169
|
-
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);
|
|
5170
5657
|
}
|
|
5171
5658
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5172
5659
|
if (!styleResult.ok) {
|
|
5173
5660
|
throwIfRequiredStaticStyleValue(styleResult);
|
|
5174
5661
|
return false;
|
|
5175
5662
|
}
|
|
5176
|
-
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);
|
|
5177
5664
|
}
|
|
5178
5665
|
function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConfig, items, cssRules, transform, atRules, options) {
|
|
5179
5666
|
const selectorStr = selector.selector.trim();
|
|
@@ -5192,7 +5679,7 @@ function compileArgMethod(method, selector, slotId, fileId, scope, type, cssConf
|
|
|
5192
5679
|
const styleResult = evaluateNode(styleArg, scope);
|
|
5193
5680
|
if (!styleResult.ok) return false;
|
|
5194
5681
|
const selectorValues = Array.isArray(selectorArg.value) ? selectorArg.value : [selectorArg.value];
|
|
5195
|
-
const styleObj = applyTransform(styleResult.value, transform);
|
|
5682
|
+
const styleObj = applyTransform(styleResult.value, transform, cssConfig);
|
|
5196
5683
|
let i = 0;
|
|
5197
5684
|
while (i < selectorValues.length) {
|
|
5198
5685
|
const itemSelectorValue = selectorValues[i];
|
|
@@ -5320,7 +5807,7 @@ function addRuntimeScopeItem(sourceItem, parentSelector, atRules, fileId, items,
|
|
|
5320
5807
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5321
5808
|
const valueStr = String(value ?? "");
|
|
5322
5809
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, sourceItem.selector, itemParentSelector, itemAtRules);
|
|
5323
|
-
const className = getAtomicClassName(sourceItem.property, priority, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, traceCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
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);
|
|
5324
5811
|
const item = createCompiledItem(4, sourceItem.slotId, dedupe, className, !!itemParentSelector);
|
|
5325
5812
|
items.push(item);
|
|
5326
5813
|
const css = buildAtomicRule(className, sourceItem.property, valueStr, sourceItem.selector, itemParentSelector, itemAtRules, cssConfig.scopeTargetPrefix);
|
|
@@ -5401,7 +5888,7 @@ function addRuntimeStyleItem(sourceItem, selector, parentSelector, atRules, file
|
|
|
5401
5888
|
const valueStr = variable?.[0] === 1 && !shouldUseVariable ? String(variable[2] ?? "") : String(value ?? "");
|
|
5402
5889
|
const dedupe = getClassNameDedupe(sourceItem.property, priority, itemSelector, parentSelector, itemAtRules);
|
|
5403
5890
|
const traceCallsite = callsiteOverride ?? sourceItem.callsite;
|
|
5404
|
-
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);
|
|
5405
5892
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5406
5893
|
item.sourceTrace = getRuntimeStyleItemSourceTrace(sourceItem, fileId);
|
|
5407
5894
|
if (type !== 4 && variable && shouldUseVariable) {
|
|
@@ -5469,10 +5956,15 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5469
5956
|
const rawValue = styleObj[property];
|
|
5470
5957
|
let priority = null;
|
|
5471
5958
|
let value = rawValue;
|
|
5959
|
+
let transformClassName = null;
|
|
5472
5960
|
if (Array.isArray(rawValue) && rawValue.length === 2 && typeof rawValue[0] === "number") {
|
|
5473
5961
|
priority = rawValue[0];
|
|
5474
5962
|
value = rawValue[1];
|
|
5475
5963
|
}
|
|
5964
|
+
if (isClassNameValue(value)) {
|
|
5965
|
+
transformClassName = value.className;
|
|
5966
|
+
value = value.value;
|
|
5967
|
+
}
|
|
5476
5968
|
if (value === null || value === void 0) {
|
|
5477
5969
|
i++;
|
|
5478
5970
|
continue;
|
|
@@ -5492,7 +5984,7 @@ function addStyleItems(styleObj, selector, parentSelector, atRules, fileId, type
|
|
|
5492
5984
|
const variableName = shouldUseVariable && propertyLoc ? getLocalVarName(propertyLoc.filePath ?? fileId, propertyLoc.line, propertyLoc.column, cssConfig.tokenNameFormat) : null;
|
|
5493
5985
|
const valueStr = variableName ? token ? getCssVarRawFallback(variableName, getTokenVar(token, cssConfig.tokenNameFormat)) : `var(${variableName})` : token ? getTokenVar(token, cssConfig.tokenNameFormat) : String(value);
|
|
5494
5986
|
const dedupe = getClassNameDedupe(property, priority, selector, parentSelector, atRules);
|
|
5495
|
-
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat);
|
|
5987
|
+
const className = getAtomicClassName(property, priority, valueStr, selector, parentSelector, atRules, propertyCallsite, cssConfig.localClassName, cssConfig.debugClassName, cssConfig.classNameFormat, transformClassName, cssConfig.transformClassNameFormat, cssConfig.hashLength);
|
|
5496
5988
|
const item = createCompiledItem(type, slotId, dedupe, className, !!parentSelector);
|
|
5497
5989
|
item.sourceTrace = propertyCallsite ? {
|
|
5498
5990
|
property,
|
|
@@ -6666,13 +7158,15 @@ function insertHoistedDeclarations(path, declarations) {
|
|
|
6666
7158
|
const body = path.node.body;
|
|
6667
7159
|
let firstRuntimeIndex = 0;
|
|
6668
7160
|
while (firstRuntimeIndex < body.length && body[firstRuntimeIndex].type === "ImportDeclaration") firstRuntimeIndex++;
|
|
7161
|
+
let runtimeInsertIndex = firstRuntimeIndex;
|
|
6669
7162
|
declarations.forEach((item) => {
|
|
6670
|
-
let insertIndex =
|
|
7163
|
+
let insertIndex = runtimeInsertIndex;
|
|
6671
7164
|
item.dependencies.forEach((name) => {
|
|
6672
7165
|
const dependencyIndex = findTopLevelDeclarationIndex(body, name);
|
|
6673
7166
|
if (dependencyIndex >= insertIndex) insertIndex = dependencyIndex + 1;
|
|
6674
7167
|
});
|
|
6675
7168
|
body.splice(insertIndex, 0, item.declaration);
|
|
7169
|
+
runtimeInsertIndex = insertIndex + 1;
|
|
6676
7170
|
});
|
|
6677
7171
|
}
|
|
6678
7172
|
function findTopLevelDeclarationIndex(body, name) {
|
|
@@ -6849,4 +7343,4 @@ function getCompilerRuntimeImportSource(source, runtimeMode) {
|
|
|
6849
7343
|
//#endregion
|
|
6850
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 };
|
|
6851
7345
|
|
|
6852
|
-
//# sourceMappingURL=compiler-
|
|
7346
|
+
//# sourceMappingURL=compiler-BXcGyZUP.mjs.map
|