@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.4
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 +13 -0
- package/README.md +1 -1
- package/atomic/className.ts +3 -9
- package/atomic/debug/className/className.ts +0 -15
- package/atomic/element.ts +1 -1
- package/atomic/rule.ts +2 -2
- package/atomic/scope.ts +19 -0
- package/atomic/theme.ts +41 -2
- package/atomic/token.ts +4 -3
- package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
- package/atomic/utils/cssVar.ts +19 -0
- package/atomic/utils/debug.ts +1 -1
- package/builder/data/const.ts +1 -1
- package/builder/data/merge/style.ts +1 -1
- package/builder/extract/token.ts +30 -14
- package/builder/token/data.ts +30 -0
- package/builder/token/index.ts +3 -0
- package/builder/token/name.ts +54 -0
- package/builder/token/symbols.ts +6 -0
- package/compiler/transform/debug/plugin.ts +79 -1
- package/compiler/transform/evaluator/evaluator.ts +74 -26
- package/compiler/transform/extract/chain/chain.ts +1 -1
- package/compiler/transform/extract/utils/replacement.ts +6 -1
- package/compiler/transform/extract/utils/theme.ts +6 -6
- package/compiler/transform/syntax/static_ids.ts +1 -1
- package/config/build.ts +1 -8
- package/config/config/debug.ts +11 -0
- package/dialect/namedTokens.ts +22 -5
- package/dist/{className-CKo4TxuT.js → className-Do2Crx4b.js} +2 -3
- package/dist/{className-CKo4TxuT.js.map → className-Do2Crx4b.js.map} +1 -1
- package/dist/{style-91J0B5ef.js → combine-C9vjpKCs.js} +45 -304
- package/dist/combine-C9vjpKCs.js.map +1 -0
- package/dist/combineStyle-DwAhsOmS.js +26 -0
- package/dist/combineStyle-DwAhsOmS.js.map +1 -0
- package/dist/compiler/index.mjs +1 -1
- package/dist/{compiler-D5v5tJXI.mjs → compiler-CE0ZgkdH.mjs} +231 -84
- package/dist/compiler-CE0ZgkdH.mjs.map +1 -0
- package/dist/config/index.js +2 -2
- package/dist/config-BE5D5x2N.js +2 -0
- package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
- package/dist/config-BtANtGAh.js.map +1 -0
- package/dist/{config-FIfi5aJ8.js → config-CduqubI8.js} +8 -6
- package/dist/config-CduqubI8.js.map +1 -0
- package/dist/config-lJNLh7eM.js +6 -0
- package/dist/config-lJNLh7eM.js.map +1 -0
- package/dist/config-oKOjOTWi.js +7 -0
- package/dist/{config-OXHoDUIo.js.map → config-oKOjOTWi.js.map} +1 -1
- package/dist/{css-DcuJ_jSH.js → css-BewrRz3_.js} +3 -3
- package/dist/{css-DcuJ_jSH.js.map → css-BewrRz3_.js.map} +1 -1
- package/dist/{css-dPoZJDQH.js → css-CiTI58yl.js} +291 -4
- package/dist/css-CiTI58yl.js.map +1 -0
- package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
- package/dist/css-GtUPEO9U.js.map +1 -0
- package/dist/{css-oOt6ZR54.js → css-Rc7ILf-3.js} +8 -9
- package/dist/{css-oOt6ZR54.js.map → css-Rc7ILf-3.js.map} +1 -1
- package/dist/css.js +1 -1
- package/dist/{css-CELBp6Gu.js → cssIdent-BsyUXNNk.js} +3 -23
- package/dist/cssIdent-BsyUXNNk.js.map +1 -0
- package/dist/cssVar-DGgQ2GIK.js +92 -0
- package/dist/cssVar-DGgQ2GIK.js.map +1 -0
- package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
- package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
- package/dist/{css_extra-DQdCrYoC.js → css_extra-DYtS3g6Z.js} +2 -2
- package/dist/{css_extra-DeTuIlcO.js.map → css_extra-DYtS3g6Z.js.map} +1 -1
- package/dist/{data-CeYstKMP.js → data-D7NFt4JG.js} +205 -10
- package/dist/data-D7NFt4JG.js.map +1 -0
- package/dist/{debug-D96KGgpH.js → debug-Cvpo5cVu.js} +4 -3
- package/dist/{debug-D96KGgpH.js.map → debug-Cvpo5cVu.js.map} +1 -1
- package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
- package/dist/debug-DycdGrul.js.map +1 -0
- package/dist/dev/rsc.js +9 -9
- package/dist/{dev-fOtWB5K3.js → dev-DdRWa6dJ.js} +7 -6
- package/dist/{dev-fOtWB5K3.js.map → dev-DdRWa6dJ.js.map} +1 -1
- package/dist/{dev-p8tW7X-A.js → dev-px0_6TNq.js} +4 -4
- package/dist/{dev-p8tW7X-A.js.map → dev-px0_6TNq.js.map} +1 -1
- package/dist/dev.js +1 -1
- package/dist/dialect/extracted/index.js +1 -1
- package/dist/dialect/index.js +1 -1
- package/dist/{elementMarker-CvqqIb7J.js → elementMarker-ng0y3fN0.js} +8 -8
- package/dist/{elementMarker-CvqqIb7J.js.map → elementMarker-ng0y3fN0.js.map} +1 -1
- package/dist/entry/dev/css.js +2 -2
- package/dist/entry/dev/jsx-dev-runtime.js +2 -2
- package/dist/entry/dev/jsx-runtime.js +2 -2
- package/dist/entry/dev.js +11 -12
- package/dist/entry/prod/css.js +2 -2
- package/dist/entry/prod/extract.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 +5 -4
- package/dist/entry/prod.js +40 -11
- package/dist/entry/prod.js.map +1 -1
- package/dist/entry/rsc-dev/css.js +2 -2
- package/dist/entry/rsc-dev/dev.js +4 -4
- 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 +274 -68
- 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 +5 -4
- package/dist/entry/rsc-prod.js +16 -10
- package/dist/entry/rsc-prod.js.map +1 -0
- package/dist/extract-B-Vs88ME.js +3 -0
- package/dist/{extract-CzWJeQi8.js → extract-CM8Fk2eK.js} +24 -15
- package/dist/{extract-CzWJeQi8.js.map → extract-CM8Fk2eK.js.map} +1 -1
- package/dist/{getClassName-oiQ8CnkS.js → getClassName-CrNVjAoJ.js} +29 -8
- package/dist/getClassName-CrNVjAoJ.js.map +1 -0
- package/dist/{global-Cul1dX8k.js → global-CZBlA9E7.js} +3 -3
- package/dist/{global-Cul1dX8k.js.map → global-CZBlA9E7.js.map} +1 -1
- package/dist/{hash-Bycpk3MR.js → hash-BfeJDf5U.js} +13 -4
- package/dist/hash-BfeJDf5U.js.map +1 -0
- package/dist/index.js +9 -10
- 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-Ba-XV33u.js → jsx-BY1iFewe.js} +3 -3
- package/dist/{jsx-Ba-XV33u.js.map → jsx-BY1iFewe.js.map} +1 -1
- package/dist/{jsx-A4cK517J.js → jsx-DL-DEAz8.js} +8 -7
- package/dist/{jsx-A4cK517J.js.map → jsx-DL-DEAz8.js.map} +1 -1
- package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-aAhNYDeS.js} +2 -2
- package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-aAhNYDeS.js.map} +1 -1
- package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-C6i1bWlu.js} +2 -2
- package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-C6i1bWlu.js.map} +1 -1
- package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-D7Y5up6H.js} +2 -2
- package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-D7Y5up6H.js.map} +1 -1
- package/dist/{layer-CbQzwZF-.js → layer-BSxAr-hy.js} +4 -4
- package/dist/{layer-CbQzwZF-.js.map → layer-BSxAr-hy.js.map} +1 -1
- package/dist/{loader-BAth2yZ1.mjs → loader-BmYS_Rju.mjs} +3 -3
- package/dist/{loader-BAth2yZ1.mjs.map → loader-BmYS_Rju.mjs.map} +1 -1
- package/dist/{misc-DFBKJGLT.mjs → misc-BIS_c7BJ.mjs} +2 -2
- package/dist/{misc-DFBKJGLT.mjs.map → misc-BIS_c7BJ.mjs.map} +1 -1
- package/dist/{namedTokens-BUa6raTb.js → namedTokens-CN_yhhik.js} +8 -6
- package/dist/namedTokens-CN_yhhik.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 +3 -2
- package/dist/plugin/parcel/optimizer.cjs.map +1 -1
- package/dist/plugin/parcel/optimizer.mjs +3 -2
- package/dist/plugin/parcel/optimizer.mjs.map +1 -1
- 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 +3 -3
- package/dist/plugin/webpack/index.mjs +1 -1
- package/dist/plugin/webpack/loader.mjs +2 -2
- package/dist/presets/tailwind/index.js +8 -5
- package/dist/presets/tailwind/index.js.map +1 -1
- package/dist/{property-CF6JgpTq.js → property-BuLbzviK.js} +2 -2
- package/dist/{property-CF6JgpTq.js.map → property-BuLbzviK.js.map} +1 -1
- package/dist/{registry-CiwvMfx8.mjs → registry-IaXmLQzA.mjs} +2 -2
- package/dist/{registry-CiwvMfx8.mjs.map → registry-IaXmLQzA.mjs.map} +1 -1
- package/dist/{rules-DlXcch7-.js → rules-CxVzovt-.js} +60 -23
- package/dist/rules-CxVzovt-.js.map +1 -0
- package/dist/selector-A-mRmMnI.js +64 -0
- package/dist/selector-A-mRmMnI.js.map +1 -0
- package/dist/server.js +12 -13
- package/dist/server.js.map +1 -1
- package/dist/{shared-yDD0nfm1.cjs → shared-CaJuvw03.cjs} +231 -84
- package/dist/shared-CaJuvw03.cjs.map +1 -0
- package/dist/{shared-x59dI2NW.mjs → shared-DdPTZ0O3.mjs} +4 -4
- package/dist/{shared-x59dI2NW.mjs.map → shared-DdPTZ0O3.mjs.map} +1 -1
- package/dist/sheet-BWBzuy4D.js +7 -0
- package/dist/{sheet-B-uJfHRY.js.map → sheet-BWBzuy4D.js.map} +1 -1
- package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-B3oCK9vC.mjs} +3 -3
- package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-B3oCK9vC.mjs.map} +1 -1
- package/dist/{style-DFFK06Of.js → style-CGaJndOl.js} +102 -54
- package/dist/style-CGaJndOl.js.map +1 -0
- package/dist/{style-Bw5ka-Nq.js → style-DDxjKdX0.js} +356 -39
- package/dist/style-DDxjKdX0.js.map +1 -0
- package/dist/style-S7LTQbRu.js +5 -0
- package/dist/{styleStore-DJ0Msgkh.js → styleStore-0fARJlZV.js} +6 -6
- package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-0fARJlZV.js.map} +1 -1
- package/dist/{styleStore-ydQcDBD4.js → styleStore-CajcAEPO.js} +101 -223
- package/dist/styleStore-CajcAEPO.js.map +1 -0
- package/dist/symbols-Cp4ymzKF.js +14 -0
- package/dist/symbols-Cp4ymzKF.js.map +1 -0
- package/dist/token-D-S-4_mN.js +138 -0
- package/dist/token-D-S-4_mN.js.map +1 -0
- package/dist/{trace-D8j96G57.js → trace-CFnhyCVf.js} +2 -2
- package/dist/{trace-D8j96G57.js.map → trace-CFnhyCVf.js.map} +1 -1
- package/dist/{trace-CO36aenp.js → trace-ZtgeY-8s.js} +3 -3
- package/dist/{trace-CO36aenp.js.map → trace-ZtgeY-8s.js.map} +1 -1
- package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
- package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
- package/dist/{utils-D2fygyTm.mjs → utils-B5Xqf1lV.mjs} +4 -4
- package/dist/{utils-D2fygyTm.mjs.map → utils-B5Xqf1lV.mjs.map} +1 -1
- package/dist/{utils-hoYnMiA7.js → utils-B_VhPBHH.js} +4 -4
- package/dist/{utils-hoYnMiA7.js.map → utils-B_VhPBHH.js.map} +1 -1
- package/dist/{utils-Bmw655wa.js → utils-CDUaX81o.js} +3 -3
- package/dist/{utils-Bmw655wa.js.map → utils-CDUaX81o.js.map} +1 -1
- package/dist/{utils-DTXCTUlS.mjs → utils-DaAiEEIG.mjs} +3 -3
- package/dist/{utils-DTXCTUlS.mjs.map → utils-DaAiEEIG.mjs.map} +1 -1
- package/dist/{utils-DVFxZnVC.js → utils-DzydRwYo.js} +65 -49
- package/dist/utils-DzydRwYo.js.map +1 -0
- package/dist/utils.js +3 -3
- package/dist/value-C0JRsyax.js +64 -0
- package/dist/value-C0JRsyax.js.map +1 -0
- package/dist/{value-DvFkGBy2.js → value-D08AocUs.js} +96 -72
- package/dist/value-D08AocUs.js.map +1 -0
- package/dist/{valueRef-CsLVJwjA.js → valueRef-M3E1oza7.js} +2 -2
- package/dist/{valueRef-CsLVJwjA.js.map → valueRef-M3E1oza7.js.map} +1 -1
- package/dist/{webpack-BOU7_xld.mjs → webpack-CHydnRXB.mjs} +5 -5
- package/dist/{webpack-BOU7_xld.mjs.map → webpack-CHydnRXB.mjs.map} +1 -1
- package/dist/{withTokens-LRidu3Vc.js → withTokens-DAzUIPvA.js} +2 -2
- package/dist/{withTokens-LRidu3Vc.js.map → withTokens-DAzUIPvA.js.map} +1 -1
- package/entry/prod/config_debug.ts +2 -0
- package/entry/prod/index.ts +1 -1
- package/entry/prod/runtime.ts +3 -1
- package/entry/rsc_prod/config_debug.ts +6 -0
- package/entry/rsc_prod/index.ts +1 -1
- package/entry/shared/config_debug.ts +9 -0
- package/entry/shared/config_dev.ts +9 -7
- package/package.json +1 -1
- package/plugin/bundler/parcel/optimizer.ts +1 -0
- package/presets/tailwind/style/transform.ts +9 -3
- package/runtime/core/cache/combine.ts +44 -25
- package/runtime/core/cache/combineRuntime.ts +4 -0
- package/runtime/core/cache/index.ts +2 -1
- package/runtime/core/cache/item.ts +2 -2
- package/runtime/core/cache/pool.ts +15 -30
- package/runtime/core/cache/prop.ts +3 -2
- package/runtime/core/cache/token.ts +20 -0
- package/runtime/core/cache/tokenValues.ts +19 -11
- package/runtime/extract/combineStyle.ts +37 -0
- package/runtime/extract/getClassName.ts +5 -11
- package/runtime/extract/index.ts +3 -1
- package/runtime/extract/token.ts +41 -0
- package/runtime/extract/tokenResolver.ts +17 -0
- package/runtime/style/style.ts +2 -1
- package/style/style.ts +1 -1
- package/style/theme.ts +0 -1
- package/style/token.ts +26 -21
- package/style/tokens.ts +18 -12
- package/style/transform.ts +1 -1
- package/style/value.ts +26 -11
- package/style/valueRef.ts +1 -1
- package/utils/global.ts +1 -3
- package/utils/symbol.ts +3 -0
- package/dist/className-ZJ5pBA-o.js +0 -263
- package/dist/className-ZJ5pBA-o.js.map +0 -1
- package/dist/compiler-D5v5tJXI.mjs.map +0 -1
- package/dist/config-BEvP7108.js.map +0 -1
- package/dist/config-B_cbG3S6.js +0 -1
- package/dist/config-FIfi5aJ8.js.map +0 -1
- package/dist/config-OXHoDUIo.js +0 -6
- package/dist/css-CELBp6Gu.js.map +0 -1
- package/dist/css-dPoZJDQH.js.map +0 -1
- package/dist/data-CeYstKMP.js.map +0 -1
- package/dist/extract-DeOytHKW.js +0 -2
- package/dist/getClassName-oiQ8CnkS.js.map +0 -1
- package/dist/global-zaCE-g1C.js.map +0 -1
- package/dist/hash-Bycpk3MR.js.map +0 -1
- package/dist/namedTokens-BUa6raTb.js.map +0 -1
- package/dist/rules-DlXcch7-.js.map +0 -1
- package/dist/runtime-BKChZZ2-.js.map +0 -1
- package/dist/shared-yDD0nfm1.cjs.map +0 -1
- package/dist/sheet-B-uJfHRY.js +0 -7
- package/dist/style-91J0B5ef.js.map +0 -1
- package/dist/style-Bw5ka-Nq.js.map +0 -1
- package/dist/style-DFFK06Of.js.map +0 -1
- package/dist/style-pz8e5To1.js +0 -5
- package/dist/styleStore-ydQcDBD4.js.map +0 -1
- package/dist/token-CKXUECuU.js +0 -76
- package/dist/token-CKXUECuU.js.map +0 -1
- package/dist/token-DTOyFLmp.js +0 -58
- package/dist/token-DTOyFLmp.js.map +0 -1
- package/dist/token-DT_sCPtm.js +0 -298
- package/dist/token-DT_sCPtm.js.map +0 -1
- package/dist/utils-DVFxZnVC.js.map +0 -1
- package/dist/value-D-ZcRzLA.js +0 -42
- package/dist/value-D-ZcRzLA.js.map +0 -1
- package/dist/value-DvFkGBy2.js.map +0 -1
- package/dist/value-dG9LK0Gq.js +0 -85
- package/dist/value-dG9LK0Gq.js.map +0 -1
|
@@ -34,10 +34,12 @@ _babel_core = __toESM(_babel_core, 1);
|
|
|
34
34
|
let oxc_resolver = require("oxc-resolver");
|
|
35
35
|
require("@parcel/plugin");
|
|
36
36
|
let node_http = require("node:http");
|
|
37
|
-
//#region utils/
|
|
37
|
+
//#region utils/symbol.ts
|
|
38
38
|
function symbol(name) {
|
|
39
39
|
return Symbol.for(`@fluentic/style.${name}`);
|
|
40
40
|
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region utils/global.ts
|
|
41
43
|
function globalData(key, data) {
|
|
42
44
|
const id = symbol(key);
|
|
43
45
|
const root = globalThis;
|
|
@@ -61,18 +63,6 @@ const CSS_CONFIG_DEFAULT = {
|
|
|
61
63
|
};
|
|
62
64
|
const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
|
|
63
65
|
//#endregion
|
|
64
|
-
//#region config/config/debug.ts
|
|
65
|
-
const DEFAULT_DEBUG_CONFIG = {
|
|
66
|
-
isDebugClassNameEnabled: false,
|
|
67
|
-
isDebugClassNameConfigured: false,
|
|
68
|
-
maxPropertyLength: 24,
|
|
69
|
-
maxValueLength: 8,
|
|
70
|
-
maxSelectorLength: 8,
|
|
71
|
-
maxParentSelectorLength: 8,
|
|
72
|
-
maxAtRuleLength: 10
|
|
73
|
-
};
|
|
74
|
-
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
75
|
-
//#endregion
|
|
76
66
|
//#region config/utils.ts
|
|
77
67
|
function getCacheTTL(cache) {
|
|
78
68
|
return cache === true ? 3e5 : cache === false ? 0 : Math.max(cache, 0);
|
|
@@ -90,6 +80,18 @@ const RUNTIME_CONFIG_DEFAULT = {
|
|
|
90
80
|
globalData("config.runtime", () => ({ ...RUNTIME_CONFIG_DEFAULT }));
|
|
91
81
|
globalData("config.build", () => ({ current: null }));
|
|
92
82
|
//#endregion
|
|
83
|
+
//#region config/config/debug.ts
|
|
84
|
+
const DEFAULT_DEBUG_CONFIG = {
|
|
85
|
+
isDebugClassNameEnabled: false,
|
|
86
|
+
isDebugClassNameConfigured: false,
|
|
87
|
+
maxPropertyLength: 24,
|
|
88
|
+
maxValueLength: 8,
|
|
89
|
+
maxSelectorLength: 8,
|
|
90
|
+
maxParentSelectorLength: 8,
|
|
91
|
+
maxAtRuleLength: 10
|
|
92
|
+
};
|
|
93
|
+
const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
|
|
94
|
+
//#endregion
|
|
93
95
|
//#region utils/hash.ts
|
|
94
96
|
function hashString(str) {
|
|
95
97
|
let hash = 2166136261;
|
|
@@ -629,16 +631,70 @@ function normalizeSelectorArg(arg) {
|
|
|
629
631
|
return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
|
|
630
632
|
}
|
|
631
633
|
//#endregion
|
|
632
|
-
//#region
|
|
634
|
+
//#region builder/token/symbols.ts
|
|
633
635
|
const TOKEN_ID = symbol("style:token");
|
|
634
636
|
const TOKEN_OVERRIDE = symbol("style:token.override");
|
|
637
|
+
const TOKEN_NAME = symbol("style:token.name");
|
|
638
|
+
const TOKEN_VAR_NAME = symbol("style:token.varName");
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region builder/token/data.ts
|
|
641
|
+
function isStyleTokenData(value) {
|
|
642
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
643
|
+
}
|
|
644
|
+
function isStyleTokenOverrideData(value) {
|
|
645
|
+
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
646
|
+
}
|
|
647
|
+
function getStyleTokenId(token) {
|
|
648
|
+
return token[TOKEN_ID];
|
|
649
|
+
}
|
|
650
|
+
function getStyleTokenName(token) {
|
|
651
|
+
return token[TOKEN_NAME] ?? null;
|
|
652
|
+
}
|
|
653
|
+
//#endregion
|
|
654
|
+
//#region builder/token/name.ts
|
|
655
|
+
function getStyleTokenNameFromId(id) {
|
|
656
|
+
if (!id) return null;
|
|
657
|
+
const parts = id.split("--");
|
|
658
|
+
const first = normalizeStyleTokenName(parts[0]);
|
|
659
|
+
if (!first) return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join("--")) : null;
|
|
660
|
+
return normalizeStyleTokenName([first, ...parts.slice(1)].join("--"));
|
|
661
|
+
}
|
|
662
|
+
function getChildStyleTokenName(name, child) {
|
|
663
|
+
const childName = normalizeStyleTokenName(child);
|
|
664
|
+
if (!childName) return normalizeStyleTokenName(name);
|
|
665
|
+
const parentName = normalizeStyleTokenName(name);
|
|
666
|
+
return parentName ? parentName + "--" + childName : childName;
|
|
667
|
+
}
|
|
668
|
+
function normalizeStyleTokenName(value) {
|
|
669
|
+
if (!value) return null;
|
|
670
|
+
value = value.trim();
|
|
671
|
+
if (!value) return null;
|
|
672
|
+
if (/^\d+$/.test(value)) return null;
|
|
673
|
+
if (isGeneratedTokenHash(value)) return null;
|
|
674
|
+
value = stripGenericTokenPrefix(value);
|
|
675
|
+
if (!value) return null;
|
|
676
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
677
|
+
if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
|
|
678
|
+
return value;
|
|
679
|
+
}
|
|
680
|
+
function isGeneratedTokenHash(value) {
|
|
681
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
682
|
+
}
|
|
683
|
+
function stripGenericTokenPrefix(value) {
|
|
684
|
+
const parts = value.split("--");
|
|
685
|
+
while (parts[0] === "token" || parts[0] === "tokens") parts.shift();
|
|
686
|
+
return parts.join("--");
|
|
687
|
+
}
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region style/token.ts
|
|
635
690
|
const TOKEN_DEBUG = symbol("style:token.debug");
|
|
636
691
|
const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
|
|
637
|
-
function createStyleToken(value,
|
|
692
|
+
function createStyleToken(value, stableId, debugName) {
|
|
638
693
|
const token = (value, debug) => {
|
|
639
694
|
return createStyleTokenOverride(token, value, debug);
|
|
640
695
|
};
|
|
641
|
-
token[TOKEN_ID] =
|
|
696
|
+
token[TOKEN_ID] = stableId || String(idCounter$6.value++);
|
|
697
|
+
token[TOKEN_NAME] = debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
|
|
642
698
|
if (isStyleTokenData(value)) {
|
|
643
699
|
token.value = value.value;
|
|
644
700
|
token.ref = value;
|
|
@@ -652,11 +708,13 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
652
708
|
const override = isStyleTokenData(value) ? {
|
|
653
709
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
654
710
|
[TOKEN_OVERRIDE]: true,
|
|
711
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
655
712
|
value: value.value,
|
|
656
713
|
ref: value
|
|
657
714
|
} : {
|
|
658
715
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
659
716
|
[TOKEN_OVERRIDE]: true,
|
|
717
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
660
718
|
value,
|
|
661
719
|
ref: null
|
|
662
720
|
};
|
|
@@ -667,15 +725,6 @@ function createStyleTokenOverride(token, value, debug) {
|
|
|
667
725
|
});
|
|
668
726
|
return override;
|
|
669
727
|
}
|
|
670
|
-
function isStyleTokenData(value) {
|
|
671
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] !== true;
|
|
672
|
-
}
|
|
673
|
-
function isStyleTokenOverrideData(value) {
|
|
674
|
-
return !!value && typeof value[TOKEN_ID] === "string" && value[TOKEN_OVERRIDE] === true;
|
|
675
|
-
}
|
|
676
|
-
function getStyleTokenId(token) {
|
|
677
|
-
return token[TOKEN_ID];
|
|
678
|
-
}
|
|
679
728
|
//#endregion
|
|
680
729
|
//#region selector/selector.ts
|
|
681
730
|
function selector(selector, ...args) {
|
|
@@ -1082,7 +1131,6 @@ const formatClassName = createNameFormatter([
|
|
|
1082
1131
|
"selector",
|
|
1083
1132
|
"value"
|
|
1084
1133
|
]);
|
|
1085
|
-
const formatScopeClassName = createNameFormatter(["className"]);
|
|
1086
1134
|
const formatTransformClassName = createNameFormatter(["className"]);
|
|
1087
1135
|
function getDebugClassName(format, hash, info) {
|
|
1088
1136
|
return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
|
|
@@ -1090,21 +1138,8 @@ function getDebugClassName(format, hash, info) {
|
|
|
1090
1138
|
function getDebugTransformClassName(format, hash, info) {
|
|
1091
1139
|
return formatTransformClassName(format || "(className)--$hash", hash, info);
|
|
1092
1140
|
}
|
|
1093
|
-
function getDebugScopeClassName(format, info) {
|
|
1094
|
-
return formatScopeClassName(format || "-(className)", null, info);
|
|
1095
|
-
}
|
|
1096
1141
|
//#endregion
|
|
1097
|
-
//#region atomic/utils/
|
|
1098
|
-
function getCssVar(varName, value) {
|
|
1099
|
-
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1100
|
-
}
|
|
1101
|
-
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1102
|
-
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1103
|
-
}
|
|
1104
|
-
function escapeCssValue(value) {
|
|
1105
|
-
if (!value) return "";
|
|
1106
|
-
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1107
|
-
}
|
|
1142
|
+
//#region atomic/utils/cssIdent.ts
|
|
1108
1143
|
function escapeCssIdent(ident) {
|
|
1109
1144
|
let result = "";
|
|
1110
1145
|
for (let i = 0; i < ident.length; i++) {
|
|
@@ -1294,6 +1329,13 @@ function parseAtRule(rule) {
|
|
|
1294
1329
|
if (normalized.startsWith("@supports")) return compressQuery(normalized.slice(9));
|
|
1295
1330
|
return compressQuery(normalized);
|
|
1296
1331
|
}
|
|
1332
|
+
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1333
|
+
return formatScopeClassName(scopeClassNameFormat || "-(className)", { className });
|
|
1334
|
+
}
|
|
1335
|
+
function formatScopeClassName(format, info) {
|
|
1336
|
+
if (typeof format === "function") return format(info);
|
|
1337
|
+
return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
|
|
1338
|
+
}
|
|
1297
1339
|
//#endregion
|
|
1298
1340
|
//#region atomic/utils/hash.ts
|
|
1299
1341
|
const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
|
|
@@ -1380,9 +1422,6 @@ function getRuntimeClassNameHashLength(debugClassName) {
|
|
|
1380
1422
|
if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
|
|
1381
1423
|
return CSS_CONFIG.hashLength ?? 7;
|
|
1382
1424
|
}
|
|
1383
|
-
function getScopeClassName(className, scopeClassNameFormat) {
|
|
1384
|
-
return getDebugScopeClassName(scopeClassNameFormat, { className });
|
|
1385
|
-
}
|
|
1386
1425
|
function getClassNameDedupe(property, priority, selector, parentSelector, atRule) {
|
|
1387
1426
|
let hash = property;
|
|
1388
1427
|
hash += "\n" + (priority || "");
|
|
@@ -1587,10 +1626,23 @@ function getScopeLookupKey(slotId, dedupe) {
|
|
|
1587
1626
|
function getTokenLookupKey(tokenId) {
|
|
1588
1627
|
return "token\0" + tokenId;
|
|
1589
1628
|
}
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region atomic/utils/cssVar.ts
|
|
1631
|
+
function getCssVar(varName, value) {
|
|
1632
|
+
return "var(" + varName + ", " + escapeCssValue(value) + ")";
|
|
1633
|
+
}
|
|
1634
|
+
function getCssVarRawFallback(varName, fallbackCss) {
|
|
1635
|
+
return "var(" + varName + ", " + fallbackCss + ")";
|
|
1636
|
+
}
|
|
1637
|
+
function escapeCssValue(value) {
|
|
1638
|
+
if (!value) return "";
|
|
1639
|
+
return value.trim().replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/'/g, "\\'").replace(/;/g, "\\;");
|
|
1640
|
+
}
|
|
1590
1641
|
const formatTokenName = createNameFormatter(["name"]);
|
|
1591
1642
|
function getTokenVarName(token, format) {
|
|
1592
1643
|
const id = getStyleTokenId(token);
|
|
1593
|
-
|
|
1644
|
+
const debugName = getStyleTokenName(token);
|
|
1645
|
+
return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
|
|
1594
1646
|
}
|
|
1595
1647
|
function getTokenVar(token, format) {
|
|
1596
1648
|
return getTokenVarFallback(token, format);
|
|
@@ -3114,15 +3166,12 @@ function appendExtractedStyleTuples(target, source) {
|
|
|
3114
3166
|
}
|
|
3115
3167
|
}
|
|
3116
3168
|
//#endregion
|
|
3117
|
-
//#region style/value.ts
|
|
3118
|
-
function createToken(value, debugId) {
|
|
3119
|
-
return createStyleToken(value, debugId);
|
|
3120
|
-
}
|
|
3121
|
-
//#endregion
|
|
3122
3169
|
//#region dialect/namedTokens.ts
|
|
3123
3170
|
const ROOT = Symbol("fluentic.namedTokens.root");
|
|
3124
3171
|
function createNamedToken(id, value) {
|
|
3125
|
-
|
|
3172
|
+
const token = createStyleToken(value, createNamedTokenId(id));
|
|
3173
|
+
token[TOKEN_VAR_NAME] = getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null);
|
|
3174
|
+
return token;
|
|
3126
3175
|
}
|
|
3127
3176
|
function createNamedTokens(namespace, values) {
|
|
3128
3177
|
return createNamedTokenProxy({
|
|
@@ -3141,7 +3190,7 @@ function createNamedTokenProxy(root, path) {
|
|
|
3141
3190
|
if (property === ROOT) return root;
|
|
3142
3191
|
if (property === "then") return void 0;
|
|
3143
3192
|
if (property === Symbol.toStringTag) return "NamedTokens";
|
|
3144
|
-
if (property === TOKEN_ID || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3193
|
+
if (property === TOKEN_ID || property === TOKEN_NAME || property === TOKEN_VAR_NAME || property === TOKEN_OVERRIDE || property === "value" || property === "ref") {
|
|
3145
3194
|
if (!path.length) return void 0;
|
|
3146
3195
|
return getNamedTokenAtPath(root, path)[property];
|
|
3147
3196
|
}
|
|
@@ -3432,9 +3481,9 @@ function evaluateCall(node, scope) {
|
|
|
3432
3481
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createToken") {
|
|
3433
3482
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3434
3483
|
if (!value.ok) return value;
|
|
3435
|
-
const
|
|
3436
|
-
if (!
|
|
3437
|
-
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node,
|
|
3484
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
3485
|
+
if (!stableId.ok) return stableId;
|
|
3486
|
+
return evalOk(createCompiledToken(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3438
3487
|
}
|
|
3439
3488
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createKeyframes") {
|
|
3440
3489
|
const frames = evaluateNode(node.arguments[0], scope);
|
|
@@ -3501,16 +3550,16 @@ function evaluateCall(node, scope) {
|
|
|
3501
3550
|
const url = evaluateNode(node.arguments[0], scope);
|
|
3502
3551
|
if (!url.ok) return evalFail(`fontSrc url must be statically analyzable: ${url.reason}`);
|
|
3503
3552
|
if (typeof url.value !== "string") return evalFail("fontSrc url must be a static string");
|
|
3504
|
-
const format =
|
|
3553
|
+
const format = evaluateOptionalString(node.arguments[1], scope);
|
|
3505
3554
|
if (!format.ok) return evalFail(`fontSrc format must be statically analyzable: ${format.reason}`);
|
|
3506
3555
|
return evalOk(fontSrc(url.value, format.value));
|
|
3507
3556
|
}
|
|
3508
3557
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createTokens") {
|
|
3509
3558
|
const value = evaluateNode(node.arguments[0], scope);
|
|
3510
3559
|
if (!value.ok) return value;
|
|
3511
|
-
const
|
|
3512
|
-
if (!
|
|
3513
|
-
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node,
|
|
3560
|
+
const stableId = evaluateOptionalStableTokenId(node.arguments[1], scope);
|
|
3561
|
+
if (!stableId.ok) return stableId;
|
|
3562
|
+
return evalOk(createCompiledTokens(value.value, scope, node.loc?.start, node, stableId.value));
|
|
3514
3563
|
}
|
|
3515
3564
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createNamedToken") {
|
|
3516
3565
|
const id = evaluateNode(node.arguments[0], scope);
|
|
@@ -3538,13 +3587,13 @@ function evaluateCall(node, scope) {
|
|
|
3538
3587
|
if (imp && STYLE_IMPORT_PATHS.has(imp.source) && imp.name === "createValues") {
|
|
3539
3588
|
const hasNumberArg = node.arguments[0]?.type === "Identifier" && node.arguments[0].name === "Number";
|
|
3540
3589
|
const valuesNode = hasNumberArg ? node.arguments[1] : node.arguments[0];
|
|
3541
|
-
const
|
|
3590
|
+
const stableIdNode = hasNumberArg ? node.arguments[2] : node.arguments[1];
|
|
3542
3591
|
const values = evaluateNode(valuesNode, scope);
|
|
3543
3592
|
if (!values.ok) return values;
|
|
3544
|
-
const
|
|
3545
|
-
if (!
|
|
3593
|
+
const stableId = evaluateOptionalStableTokenId(stableIdNode, scope);
|
|
3594
|
+
if (!stableId.ok) return stableId;
|
|
3546
3595
|
if (!Array.isArray(values.value)) return evalFail("createValues values must be an array");
|
|
3547
|
-
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node,
|
|
3596
|
+
return evalOk(createCompiledValues(values.value, scope, node.loc?.start, node, stableId.value, hasNumberArg));
|
|
3548
3597
|
}
|
|
3549
3598
|
}
|
|
3550
3599
|
if (node.callee.type === "Identifier") {
|
|
@@ -3632,38 +3681,48 @@ function createCompiledTokenOverride(token, value, runtimeValue) {
|
|
|
3632
3681
|
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
3633
3682
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3634
3683
|
[TOKEN_OVERRIDE]: true,
|
|
3684
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3635
3685
|
value: value.value,
|
|
3636
3686
|
ref: value
|
|
3637
3687
|
});
|
|
3638
3688
|
return withRuntimeValue(runtimeValue, {
|
|
3639
3689
|
[TOKEN_ID]: getStyleTokenId(token),
|
|
3640
3690
|
[TOKEN_OVERRIDE]: true,
|
|
3691
|
+
[TOKEN_NAME]: getStyleTokenName(token),
|
|
3641
3692
|
value,
|
|
3642
3693
|
ref: null
|
|
3643
3694
|
});
|
|
3644
3695
|
}
|
|
3645
|
-
function createCompiledToken(value, scope, loc, runtimeValue,
|
|
3646
|
-
let tokenId =
|
|
3696
|
+
function createCompiledToken(value, scope, loc, runtimeValue, stableId, debugName) {
|
|
3697
|
+
let tokenId = stableId;
|
|
3647
3698
|
if (!tokenId) tokenId = hashString((scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value)));
|
|
3699
|
+
if (isStyleTokenData(value)) return withRuntimeValue(runtimeValue, {
|
|
3700
|
+
[TOKEN_ID]: tokenId,
|
|
3701
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
3702
|
+
value: value.value,
|
|
3703
|
+
ref: value
|
|
3704
|
+
});
|
|
3648
3705
|
return withRuntimeValue(runtimeValue, {
|
|
3649
3706
|
[TOKEN_ID]: tokenId,
|
|
3707
|
+
[TOKEN_NAME]: debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName),
|
|
3650
3708
|
value,
|
|
3651
3709
|
ref: null
|
|
3652
3710
|
});
|
|
3653
3711
|
}
|
|
3654
|
-
function createCompiledTokens(value, scope, loc, runtimeValue,
|
|
3655
|
-
const tokenGroupId =
|
|
3712
|
+
function createCompiledTokens(value, scope, loc, runtimeValue, stableId) {
|
|
3713
|
+
const tokenGroupId = stableId ?? createCompiledTokenGroupId(scope, loc);
|
|
3714
|
+
const tokenGroupName = getStyleTokenNameFromId(stableId);
|
|
3656
3715
|
if (Array.isArray(value)) {
|
|
3657
3716
|
const result = {};
|
|
3658
3717
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
3659
3718
|
const item = value[i];
|
|
3660
|
-
result[item] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
3719
|
+
result[item] = createCompiledToken(item, scope, loc, runtimeValue, getChildStableId(tokenGroupId, String(i)), getChildStyleTokenName(tokenGroupName, String(i)));
|
|
3661
3720
|
}
|
|
3662
3721
|
return result;
|
|
3663
3722
|
}
|
|
3664
3723
|
if (!value || typeof value !== "object") return {};
|
|
3665
3724
|
const result = {};
|
|
3666
|
-
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId);
|
|
3725
|
+
assignCompiledTokenRecord(result, value, scope, loc, runtimeValue, tokenGroupId, tokenGroupName);
|
|
3667
3726
|
return result;
|
|
3668
3727
|
}
|
|
3669
3728
|
function createCompiledTokenGroupId(scope, loc) {
|
|
@@ -3675,22 +3734,24 @@ function createCompiledAtRuleStableId(scope, loc, value) {
|
|
|
3675
3734
|
id: (scope.styleFilePath ?? scope.filePath) + "\n" + (loc ? loc.line + ":" + loc.column : String(value))
|
|
3676
3735
|
};
|
|
3677
3736
|
}
|
|
3678
|
-
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue,
|
|
3737
|
+
function assignCompiledTokenRecord(target, value, scope, loc, runtimeValue, stableId, debugName) {
|
|
3679
3738
|
for (const key of Object.keys(value)) {
|
|
3680
3739
|
const item = value[key];
|
|
3681
|
-
const
|
|
3740
|
+
const itemStableId = getChildStableId(stableId, key);
|
|
3741
|
+
const itemDebugName = getChildStyleTokenName(debugName, key);
|
|
3682
3742
|
if (item && typeof item === "object" && !Array.isArray(item) && !isStyleTokenData(item)) {
|
|
3683
3743
|
const child = {};
|
|
3684
3744
|
target[key] = child;
|
|
3685
|
-
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue,
|
|
3686
|
-
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue,
|
|
3745
|
+
assignCompiledTokenRecord(child, item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
3746
|
+
} else target[key] = createCompiledToken(item, scope, loc, runtimeValue, itemStableId, itemDebugName);
|
|
3687
3747
|
}
|
|
3688
3748
|
}
|
|
3689
|
-
function createCompiledValues(values, scope, loc, runtimeValue,
|
|
3749
|
+
function createCompiledValues(values, scope, loc, runtimeValue, stableId, isNumber) {
|
|
3690
3750
|
const tokens = /* @__PURE__ */ new Map();
|
|
3751
|
+
const groupName = getStyleTokenNameFromId(stableId);
|
|
3691
3752
|
for (let i = 0, len = values.length; i < len; i++) {
|
|
3692
3753
|
const value = values[i];
|
|
3693
|
-
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue,
|
|
3754
|
+
tokens.set(value, createCompiledToken(parseCompiledValue(value, isNumber), scope, loc, runtimeValue, getChildStableId(stableId, hashString(String(value))), getChildStyleTokenName(groupName, getValueDebugName(value))));
|
|
3694
3755
|
}
|
|
3695
3756
|
return {
|
|
3696
3757
|
[COMPILED_TOKEN_FACTORY]: true,
|
|
@@ -3708,7 +3769,10 @@ function parseCompiledValue(value, isNumber) {
|
|
|
3708
3769
|
function isCompiledTokenFactory(value) {
|
|
3709
3770
|
return !!value && typeof value === "object" && value[COMPILED_TOKEN_FACTORY] === true;
|
|
3710
3771
|
}
|
|
3711
|
-
function
|
|
3772
|
+
function evaluateOptionalStableTokenId(node, scope) {
|
|
3773
|
+
return evaluateOptionalString(node, scope);
|
|
3774
|
+
}
|
|
3775
|
+
function evaluateOptionalString(node, scope) {
|
|
3712
3776
|
if (!node) return evalOk(void 0);
|
|
3713
3777
|
const value = evaluateNode(node, scope);
|
|
3714
3778
|
if (!value.ok) return value;
|
|
@@ -3732,12 +3796,24 @@ function evaluateOptionalStableId(node, scope) {
|
|
|
3732
3796
|
id: stableId.id
|
|
3733
3797
|
});
|
|
3734
3798
|
}
|
|
3735
|
-
function
|
|
3736
|
-
return
|
|
3799
|
+
function getChildStableId(stableId, child) {
|
|
3800
|
+
return stableId ? stableId + "--" + child : void 0;
|
|
3801
|
+
}
|
|
3802
|
+
function getValueDebugName(value) {
|
|
3803
|
+
if (typeof value === "number") return String(value);
|
|
3804
|
+
if (typeof value !== "string") return null;
|
|
3805
|
+
const parts = value.split(/[;|]/);
|
|
3806
|
+
const label = parts[1]?.trim();
|
|
3807
|
+
if (label) return sanitizeTokenDebugName(label);
|
|
3808
|
+
return sanitizeTokenDebugName(parts[0]?.trim() ?? "");
|
|
3809
|
+
}
|
|
3810
|
+
function sanitizeTokenDebugName(value) {
|
|
3811
|
+
return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || null;
|
|
3737
3812
|
}
|
|
3738
3813
|
function withRuntimeValue(runtimeValue, token) {
|
|
3739
3814
|
return Object.assign({}, token, {
|
|
3740
3815
|
[TOKEN_ID]: token[TOKEN_ID],
|
|
3816
|
+
[TOKEN_NAME]: token[TOKEN_NAME] ?? null,
|
|
3741
3817
|
[COMPILED_RUNTIME_VALUE]: runtimeValue
|
|
3742
3818
|
});
|
|
3743
3819
|
}
|
|
@@ -3797,7 +3873,7 @@ function isStyleChainCall(callee, styleNames) {
|
|
|
3797
3873
|
}
|
|
3798
3874
|
const formatThemeName = createNameFormatter(["name"]);
|
|
3799
3875
|
function createThemeClassName(name, id, themeNameFormat) {
|
|
3800
|
-
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name });
|
|
3876
|
+
return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
|
|
3801
3877
|
}
|
|
3802
3878
|
function getThemeRuleCss(className, tokens, tokenNameFormat) {
|
|
3803
3879
|
const declarations = [];
|
|
@@ -3809,6 +3885,29 @@ function getThemeDeclaration(token, tokenNameFormat) {
|
|
|
3809
3885
|
const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
|
|
3810
3886
|
return name + ":" + value;
|
|
3811
3887
|
}
|
|
3888
|
+
function normalizeThemeName(value) {
|
|
3889
|
+
if (!value) return null;
|
|
3890
|
+
value = value.trim();
|
|
3891
|
+
if (!value) return null;
|
|
3892
|
+
if (/^\d+$/.test(value)) return null;
|
|
3893
|
+
if (isGeneratedNameHash(value)) return null;
|
|
3894
|
+
const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
|
|
3895
|
+
if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
|
|
3896
|
+
value = stripGenericThemePrefix(value);
|
|
3897
|
+
if (!value) return null;
|
|
3898
|
+
return value;
|
|
3899
|
+
}
|
|
3900
|
+
function stripGenericThemePrefix(value) {
|
|
3901
|
+
const parts = value.split("--");
|
|
3902
|
+
while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
|
|
3903
|
+
value = parts.join("--");
|
|
3904
|
+
if (value.startsWith("theme-")) return value.slice(6);
|
|
3905
|
+
if (value.startsWith("themes-")) return value.slice(7);
|
|
3906
|
+
return value;
|
|
3907
|
+
}
|
|
3908
|
+
function isGeneratedNameHash(value) {
|
|
3909
|
+
return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
|
|
3910
|
+
}
|
|
3812
3911
|
//#endregion
|
|
3813
3912
|
//#region compiler/transform/syntax/utils.ts
|
|
3814
3913
|
function getCallLabel(callee) {
|
|
@@ -4506,8 +4605,9 @@ function getSelectorMethodPath(path) {
|
|
|
4506
4605
|
function getDebugStyleArg(t, path, state, sourcemapTrace) {
|
|
4507
4606
|
const arg = getStyleObjectArg(path, state);
|
|
4508
4607
|
if (!arg) return arg;
|
|
4608
|
+
const meta = getStyleCallMeta(path, state);
|
|
4509
4609
|
if (arg.type !== "ObjectExpression") return resolveDebugMergeObject(t, arg, path, state, sourcemapTrace) ?? arg;
|
|
4510
|
-
return flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set());
|
|
4610
|
+
return appendTransformDebugFieldAliases(t, flattenDebugObjectExpression(t, arg, path, state, sourcemapTrace, /* @__PURE__ */ new Set()), meta, state);
|
|
4511
4611
|
}
|
|
4512
4612
|
function getDebugCallLoc(path, state) {
|
|
4513
4613
|
return isSelectorStyleCall(path, state) || isScopeItemSelectorCall(path, state) ? getMergeStyleLoc(path.node.callee) : null;
|
|
@@ -4521,6 +4621,10 @@ function getStyleObjectArg(path, state) {
|
|
|
4521
4621
|
const styleArgIndex = selectorArgIndex === null ? 0 : selectorArgIndex + 1;
|
|
4522
4622
|
return path.node.arguments[styleArgIndex];
|
|
4523
4623
|
}
|
|
4624
|
+
function getStyleCallMeta(path, state) {
|
|
4625
|
+
const rootName = getStyleChainRootName(path.node.callee, state.styleNames);
|
|
4626
|
+
return rootName ? state.styleMetas.get(rootName) ?? null : null;
|
|
4627
|
+
}
|
|
4524
4628
|
function isSelectorStyleCall(path, state) {
|
|
4525
4629
|
const methodName = getSelectorMethodName(path.node.callee);
|
|
4526
4630
|
if (!methodName) return false;
|
|
@@ -4625,6 +4729,46 @@ function flattenDebugObjectExpression(t, node, path, state, sourcemapTrace, seen
|
|
|
4625
4729
|
}
|
|
4626
4730
|
return t.objectExpression(properties);
|
|
4627
4731
|
}
|
|
4732
|
+
function appendTransformDebugFieldAliases(t, node, meta, state) {
|
|
4733
|
+
if (!meta || meta.mode !== "StyleObject" || !meta.transform) return node;
|
|
4734
|
+
const existing = /* @__PURE__ */ new Set();
|
|
4735
|
+
for (const property of node.properties) {
|
|
4736
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
4737
|
+
const key = getObjectPropertyKey$1(property);
|
|
4738
|
+
if (key) existing.add(key);
|
|
4739
|
+
}
|
|
4740
|
+
const aliases = [];
|
|
4741
|
+
for (const property of node.properties) {
|
|
4742
|
+
if (property.type !== "ObjectProperty" || property.computed) continue;
|
|
4743
|
+
const key = getObjectPropertyKey$1(property);
|
|
4744
|
+
if (!key) continue;
|
|
4745
|
+
const value = evaluateNode(property.value, getDebugEvalScope(state));
|
|
4746
|
+
if (!value.ok) continue;
|
|
4747
|
+
let transformed;
|
|
4748
|
+
try {
|
|
4749
|
+
transformed = meta.transform.transform({ [key]: value.value });
|
|
4750
|
+
} catch {
|
|
4751
|
+
continue;
|
|
4752
|
+
}
|
|
4753
|
+
for (const transformedKey of Object.keys(transformed)) {
|
|
4754
|
+
if (existing.has(transformedKey)) continue;
|
|
4755
|
+
existing.add(transformedKey);
|
|
4756
|
+
aliases.push(createDebugFieldAlias(t, transformedKey, property));
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
if (!aliases.length) return node;
|
|
4760
|
+
return t.objectExpression([...node.properties, ...aliases]);
|
|
4761
|
+
}
|
|
4762
|
+
function createDebugFieldAlias(t, key, source) {
|
|
4763
|
+
const alias = t.objectProperty(t.stringLiteral(key), t.nullLiteral());
|
|
4764
|
+
const sourceTrace = source;
|
|
4765
|
+
alias.loc = source.loc;
|
|
4766
|
+
alias.__styleSourcemapStyleLoc = sourceTrace.__styleSourcemapStyleLoc;
|
|
4767
|
+
alias.__styleSourcemapStyleSourceUrl = sourceTrace.__styleSourcemapStyleSourceUrl;
|
|
4768
|
+
alias.__styleSourcemapValueLoc = sourceTrace.__styleSourcemapValueLoc;
|
|
4769
|
+
alias.__styleSourcemapValueSourceUrl = sourceTrace.__styleSourcemapValueSourceUrl;
|
|
4770
|
+
return alias;
|
|
4771
|
+
}
|
|
4628
4772
|
function resolveDebugSpreadObject(t, spread, path, state, sourcemapTrace, seen) {
|
|
4629
4773
|
const node = spread.argument;
|
|
4630
4774
|
if (node.type !== "Identifier") return null;
|
|
@@ -6788,10 +6932,13 @@ function buildVariableValueExpression(t, value, state, item, options) {
|
|
|
6788
6932
|
}
|
|
6789
6933
|
function buildExtractedTokenExpression(t, token, state) {
|
|
6790
6934
|
state.usedHelpers.add(FN_CREATE_EXTRACTED_TOKEN);
|
|
6935
|
+
const tokenNameFormat = state.options.css?.tokenNameFormat ?? DEFAULT_CONFIG.tokenNameFormat ?? null;
|
|
6791
6936
|
return t.callExpression(t.identifier(FN_CREATE_EXTRACTED_TOKEN), [
|
|
6792
6937
|
t.stringLiteral(getStyleTokenId(token)),
|
|
6793
6938
|
literalExpression(t, token.value),
|
|
6794
|
-
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral()
|
|
6939
|
+
token.ref ? buildExtractedTokenExpression(t, token.ref, state) : t.nullLiteral(),
|
|
6940
|
+
getStyleTokenName(token) ? t.stringLiteral(getStyleTokenName(token)) : t.nullLiteral(),
|
|
6941
|
+
t.stringLiteral(getTokenVarName(token, tokenNameFormat))
|
|
6795
6942
|
]);
|
|
6796
6943
|
}
|
|
6797
6944
|
function literalExpression(t, value) {
|
|
@@ -6931,8 +7078,8 @@ function compileThemeCall(path, state, opts) {
|
|
|
6931
7078
|
const tokenArg = evaluateNode(path.node.arguments[0], scope);
|
|
6932
7079
|
if (!tokenArg.ok) throw path.buildCodeFrameError(`createTheme tokens must be statically analyzable: ${tokenArg.reason}`);
|
|
6933
7080
|
if (!Array.isArray(tokenArg.value)) throw path.buildCodeFrameError("createTheme first argument must be a static array of token overrides.");
|
|
6934
|
-
const
|
|
6935
|
-
if (path.node.arguments[1] && !
|
|
7081
|
+
const stableIdArg = evaluateNode(path.node.arguments[1], scope);
|
|
7082
|
+
if (path.node.arguments[1] && !stableIdArg.ok) throw path.buildCodeFrameError(`createTheme stableId must be statically analyzable: ${stableIdArg.reason}`);
|
|
6936
7083
|
const tokens = [];
|
|
6937
7084
|
for (let i = 0, len = tokenArg.value.length; i < len; i++) {
|
|
6938
7085
|
const token = tokenArg.value[i];
|
|
@@ -6940,7 +7087,7 @@ function compileThemeCall(path, state, opts) {
|
|
|
6940
7087
|
tokens.push(token);
|
|
6941
7088
|
}
|
|
6942
7089
|
const loc = path.node.loc?.start;
|
|
6943
|
-
const id =
|
|
7090
|
+
const id = stableIdArg.ok && stableIdArg.value !== void 0 ? String(stableIdArg.value) : getStableThemeId(state.fileId, loc ? loc.line + ":" + loc.column : "createTheme");
|
|
6944
7091
|
const themeNameFormat = opts.css?.themeNameFormat || CSS_CONFIG.themeNameFormat || null;
|
|
6945
7092
|
const className = getStableThemeClassName(id, themeNameFormat);
|
|
6946
7093
|
return {
|
|
@@ -8141,4 +8288,4 @@ Object.defineProperty(exports, "writeParcelVirtualRuntimeFile", {
|
|
|
8141
8288
|
}
|
|
8142
8289
|
});
|
|
8143
8290
|
|
|
8144
|
-
//# sourceMappingURL=shared-
|
|
8291
|
+
//# sourceMappingURL=shared-CaJuvw03.cjs.map
|