boss-css 0.0.7 → 0.0.9
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/dist/prop/bosswind/server.cjs +1 -1
- package/dist/prop/bosswind/server.mjs +1 -1
- package/dist/prop/bosswind/shared.cjs +28 -5
- package/dist/prop/bosswind/shared.mjs +28 -5
- package/dist/strategy/inline-first/browser.cjs +1 -1
- package/dist/strategy/inline-first/browser.mjs +1 -1
- package/dist/use/token/browser.cjs +10 -4
- package/dist/use/token/browser.mjs +10 -4
- package/dist/use/token/runtime-only.cjs +17 -3
- package/dist/use/token/runtime-only.mjs +17 -3
- package/dist/use/token/server.cjs +6 -2
- package/dist/use/token/server.mjs +6 -2
- package/package.json +1 -1
|
@@ -89,7 +89,7 @@ const onPropTree = async (api, { tree, parser }) => {
|
|
|
89
89
|
const { tree: next, usedBosswind, usedText } = require_shared.rewriteBosswindTree(api, tree, {
|
|
90
90
|
defaults,
|
|
91
91
|
fontSizeKeys
|
|
92
|
-
}, resolvedTokens);
|
|
92
|
+
}, resolvedTokens, parser);
|
|
93
93
|
if (usedBosswind && parser === "jsx") needsRuntime = true;
|
|
94
94
|
Object.keys(tree).forEach((key) => delete tree[key]);
|
|
95
95
|
Object.assign(tree, next);
|
|
@@ -89,7 +89,7 @@ const onPropTree = async (api, { tree, parser }) => {
|
|
|
89
89
|
const { tree: next, usedBosswind, usedText } = rewriteBosswindTree(api, tree, {
|
|
90
90
|
defaults,
|
|
91
91
|
fontSizeKeys
|
|
92
|
-
}, resolvedTokens);
|
|
92
|
+
}, resolvedTokens, parser);
|
|
93
93
|
if (usedBosswind && parser === "jsx") needsRuntime = true;
|
|
94
94
|
Object.keys(tree).forEach((key) => delete tree[key]);
|
|
95
95
|
Object.assign(tree, next);
|
|
@@ -221,6 +221,20 @@ const resolveBorderTarget = (value, config, tokens) => {
|
|
|
221
221
|
value
|
|
222
222
|
};
|
|
223
223
|
};
|
|
224
|
+
const resolveBorderToken = (value, tokens) => {
|
|
225
|
+
if (readTokenGroup(value)?.group === "color") return {
|
|
226
|
+
prop: "borderColor",
|
|
227
|
+
value
|
|
228
|
+
};
|
|
229
|
+
if (typeof value === "string" && tokens?.color) {
|
|
230
|
+
const normalized = toTokenPath(value, tokens.color);
|
|
231
|
+
if (normalized !== value) return {
|
|
232
|
+
prop: "borderColor",
|
|
233
|
+
value: normalized
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
};
|
|
224
238
|
const resolveShadowValue = (value, config) => {
|
|
225
239
|
if (value === null || value === true) return config.defaults?.boxShadow ?? value;
|
|
226
240
|
return value;
|
|
@@ -605,7 +619,7 @@ const applyAxisPairsToTree = (entries, node, output, used) => {
|
|
|
605
619
|
used.set(`__emit:${pair.emitIndex}:${pair.prop}`, true);
|
|
606
620
|
}
|
|
607
621
|
};
|
|
608
|
-
const rewriteBosswindTree = (api, tree, config, tokens) => {
|
|
622
|
+
const rewriteBosswindTree = (api, tree, config, tokens, parser) => {
|
|
609
623
|
let usedBosswind = false;
|
|
610
624
|
let usedText = false;
|
|
611
625
|
const rewriteNode = (node) => {
|
|
@@ -693,6 +707,15 @@ const rewriteBosswindTree = (api, tree, config, tokens) => {
|
|
|
693
707
|
}
|
|
694
708
|
if (name === borderAlias) {
|
|
695
709
|
usedBosswind = true;
|
|
710
|
+
if (parser === "jsx") {
|
|
711
|
+
const resolvedToken = resolveBorderToken(value, tokens);
|
|
712
|
+
if (resolvedToken) {
|
|
713
|
+
output[resolvedToken.prop] = cloneProp(prop, resolvedToken.value);
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
output[name] = prop;
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
696
719
|
const resolved = resolveBorderTarget(value, config, tokens);
|
|
697
720
|
if (!resolved) {
|
|
698
721
|
output[name] = prop;
|
|
@@ -820,12 +843,12 @@ const rewriteBosswindInput = (api, input, config) => {
|
|
|
820
843
|
return;
|
|
821
844
|
}
|
|
822
845
|
if (name === borderAlias) {
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
output[
|
|
846
|
+
const resolvedToken = resolveBorderToken(value, api.tokens);
|
|
847
|
+
if (resolvedToken) {
|
|
848
|
+
output[resolvedToken.prop] = resolvedToken.value;
|
|
826
849
|
return;
|
|
827
850
|
}
|
|
828
|
-
output[
|
|
851
|
+
output[name] = value;
|
|
829
852
|
return;
|
|
830
853
|
}
|
|
831
854
|
if (name === "shadow") {
|
|
@@ -220,6 +220,20 @@ const resolveBorderTarget = (value, config, tokens) => {
|
|
|
220
220
|
value
|
|
221
221
|
};
|
|
222
222
|
};
|
|
223
|
+
const resolveBorderToken = (value, tokens) => {
|
|
224
|
+
if (readTokenGroup(value)?.group === "color") return {
|
|
225
|
+
prop: "borderColor",
|
|
226
|
+
value
|
|
227
|
+
};
|
|
228
|
+
if (typeof value === "string" && tokens?.color) {
|
|
229
|
+
const normalized = toTokenPath(value, tokens.color);
|
|
230
|
+
if (normalized !== value) return {
|
|
231
|
+
prop: "borderColor",
|
|
232
|
+
value: normalized
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
};
|
|
223
237
|
const resolveShadowValue = (value, config) => {
|
|
224
238
|
if (value === null || value === true) return config.defaults?.boxShadow ?? value;
|
|
225
239
|
return value;
|
|
@@ -604,7 +618,7 @@ const applyAxisPairsToTree = (entries, node, output, used) => {
|
|
|
604
618
|
used.set(`__emit:${pair.emitIndex}:${pair.prop}`, true);
|
|
605
619
|
}
|
|
606
620
|
};
|
|
607
|
-
const rewriteBosswindTree = (api, tree, config, tokens) => {
|
|
621
|
+
const rewriteBosswindTree = (api, tree, config, tokens, parser) => {
|
|
608
622
|
let usedBosswind = false;
|
|
609
623
|
let usedText = false;
|
|
610
624
|
const rewriteNode = (node) => {
|
|
@@ -692,6 +706,15 @@ const rewriteBosswindTree = (api, tree, config, tokens) => {
|
|
|
692
706
|
}
|
|
693
707
|
if (name === borderAlias) {
|
|
694
708
|
usedBosswind = true;
|
|
709
|
+
if (parser === "jsx") {
|
|
710
|
+
const resolvedToken = resolveBorderToken(value, tokens);
|
|
711
|
+
if (resolvedToken) {
|
|
712
|
+
output[resolvedToken.prop] = cloneProp(prop, resolvedToken.value);
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
output[name] = prop;
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
695
718
|
const resolved = resolveBorderTarget(value, config, tokens);
|
|
696
719
|
if (!resolved) {
|
|
697
720
|
output[name] = prop;
|
|
@@ -819,12 +842,12 @@ const rewriteBosswindInput = (api, input, config) => {
|
|
|
819
842
|
return;
|
|
820
843
|
}
|
|
821
844
|
if (name === borderAlias) {
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
824
|
-
output[
|
|
845
|
+
const resolvedToken = resolveBorderToken(value, api.tokens);
|
|
846
|
+
if (resolvedToken) {
|
|
847
|
+
output[resolvedToken.prop] = resolvedToken.value;
|
|
825
848
|
return;
|
|
826
849
|
}
|
|
827
|
-
output[
|
|
850
|
+
output[name] = value;
|
|
828
851
|
return;
|
|
829
852
|
}
|
|
830
853
|
if (name === "shadow") {
|
|
@@ -45,7 +45,7 @@ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) =
|
|
|
45
45
|
output: outputRecord,
|
|
46
46
|
contexts
|
|
47
47
|
});
|
|
48
|
-
else if (!
|
|
48
|
+
else if (!contexts.length && (0, _boss_css_is_css_prop.default)(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
|
|
49
49
|
else {
|
|
50
50
|
const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
|
|
51
51
|
const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
|
|
@@ -43,7 +43,7 @@ const onBrowserObjectStart = (api, { input, output = {}, tag, contexts = [] }) =
|
|
|
43
43
|
output: outputRecord,
|
|
44
44
|
contexts
|
|
45
45
|
});
|
|
46
|
-
else if (!
|
|
46
|
+
else if (!contexts.length && isCSSProp(tag, resolvedName)) outputRecord.style[resolvedName] = api.dictionary.toValue(value, resolvedName);
|
|
47
47
|
else {
|
|
48
48
|
const className = api.contextToClassName(resolvedName, null, contexts, false, api.selectorPrefix);
|
|
49
49
|
const cssVarName = api.contextToCSSVariable(resolvedName, null, contexts, api.selectorPrefix);
|
|
@@ -61,10 +61,16 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
61
61
|
if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
|
|
62
62
|
else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
|
|
63
63
|
} else if (typeof prop === "string") {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const rawValue = mutableInput[prop];
|
|
65
|
+
if (typeof rawValue !== "string") continue;
|
|
66
|
+
const dashProp = api.camelCaseToDash?.(prop) ?? prop;
|
|
67
|
+
const groupName = [
|
|
68
|
+
require_propMap.getTokenGroupForProp(prop),
|
|
69
|
+
require_propMap.getTokenGroupForProp(dashProp),
|
|
70
|
+
prop,
|
|
71
|
+
dashProp
|
|
72
|
+
].filter(Boolean).find((group) => tokenPaths.has(`${group}.${rawValue}`));
|
|
73
|
+
if (groupName && !isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${rawValue.replace("$$.token.", "").replace(/\./g, "-")})`;
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
};
|
|
@@ -61,10 +61,16 @@ const onBrowserObjectStart = (api, { input }) => {
|
|
|
61
61
|
if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
|
|
62
62
|
else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
|
|
63
63
|
} else if (typeof prop === "string") {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const rawValue = mutableInput[prop];
|
|
65
|
+
if (typeof rawValue !== "string") continue;
|
|
66
|
+
const dashProp = api.camelCaseToDash?.(prop) ?? prop;
|
|
67
|
+
const groupName = [
|
|
68
|
+
getTokenGroupForProp(prop),
|
|
69
|
+
getTokenGroupForProp(dashProp),
|
|
70
|
+
prop,
|
|
71
|
+
dashProp
|
|
72
|
+
].filter(Boolean).find((group) => tokenPaths.has(`${group}.${rawValue}`));
|
|
73
|
+
if (groupName && !isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${rawValue.replace("$$.token.", "").replace(/\./g, "-")})`;
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
};
|
|
@@ -111,10 +111,24 @@ const getTokenPath = (api, prop, value) => {
|
|
|
111
111
|
source: "group"
|
|
112
112
|
};
|
|
113
113
|
if (typeof value !== "string") return null;
|
|
114
|
-
const { byProp } = getTokenState(api);
|
|
114
|
+
const { byProp, groups } = getTokenState(api);
|
|
115
115
|
const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const groupCandidates = [
|
|
117
|
+
require_propMap.getTokenGroupForProp(prop),
|
|
118
|
+
require_propMap.getTokenGroupForProp(dashProp),
|
|
119
|
+
prop,
|
|
120
|
+
dashProp
|
|
121
|
+
].filter(Boolean);
|
|
122
|
+
let groupName = groupCandidates[0] ?? prop;
|
|
123
|
+
let values = byProp.get(prop) ?? byProp.get(dashProp);
|
|
124
|
+
if (!values) for (const candidate of groupCandidates) {
|
|
125
|
+
const groupValues = groups?.[candidate];
|
|
126
|
+
if (groupValues) {
|
|
127
|
+
groupName = candidate;
|
|
128
|
+
values = groupValues;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
118
132
|
if (!values) return null;
|
|
119
133
|
if (typeof value === "string") {
|
|
120
134
|
const tokenAlpha = parseTokenAlphaValue(value);
|
|
@@ -111,10 +111,24 @@ const getTokenPath = (api, prop, value) => {
|
|
|
111
111
|
source: "group"
|
|
112
112
|
};
|
|
113
113
|
if (typeof value !== "string") return null;
|
|
114
|
-
const { byProp } = getTokenState(api);
|
|
114
|
+
const { byProp, groups } = getTokenState(api);
|
|
115
115
|
const dashProp = api?.camelCaseToDash ? api.camelCaseToDash(prop) : prop;
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const groupCandidates = [
|
|
117
|
+
getTokenGroupForProp(prop),
|
|
118
|
+
getTokenGroupForProp(dashProp),
|
|
119
|
+
prop,
|
|
120
|
+
dashProp
|
|
121
|
+
].filter(Boolean);
|
|
122
|
+
let groupName = groupCandidates[0] ?? prop;
|
|
123
|
+
let values = byProp.get(prop) ?? byProp.get(dashProp);
|
|
124
|
+
if (!values) for (const candidate of groupCandidates) {
|
|
125
|
+
const groupValues = groups?.[candidate];
|
|
126
|
+
if (groupValues) {
|
|
127
|
+
groupName = candidate;
|
|
128
|
+
values = groupValues;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
118
132
|
if (!values) return null;
|
|
119
133
|
if (typeof value === "string") {
|
|
120
134
|
const tokenAlpha = parseTokenAlphaValue(value);
|
|
@@ -258,9 +258,13 @@ const onPropTree = async (api, { tree, parser }) => {
|
|
|
258
258
|
const groupForProp = typeof name === "string" ? require_propMap.getTokenGroupForProp(name) : null;
|
|
259
259
|
const resolvedGroupName = isExplicitToken ? tokenGroupName : groupForProp ?? tokenGroupName;
|
|
260
260
|
const { aliases } = descriptor;
|
|
261
|
-
const valuesByGroupName = valueMap.get(tokenGroupName);
|
|
261
|
+
const valuesByGroupName = valueMap.get(resolvedGroupName) ?? valueMap.get(tokenGroupName);
|
|
262
262
|
const values = aliases.reduce((acc, alias) => {
|
|
263
|
-
|
|
263
|
+
if (acc) return acc;
|
|
264
|
+
const direct = valueMap.get(alias);
|
|
265
|
+
if (direct) return direct;
|
|
266
|
+
const dashed = api.camelCaseToDash(alias);
|
|
267
|
+
return valueMap.get(dashed) || null;
|
|
264
268
|
}, null) || valuesByGroupName;
|
|
265
269
|
if (!values) return;
|
|
266
270
|
const rawValue = prop.value;
|
|
@@ -258,9 +258,13 @@ const onPropTree = async (api, { tree, parser }) => {
|
|
|
258
258
|
const groupForProp = typeof name === "string" ? getTokenGroupForProp(name) : null;
|
|
259
259
|
const resolvedGroupName = isExplicitToken ? tokenGroupName : groupForProp ?? tokenGroupName;
|
|
260
260
|
const { aliases } = descriptor;
|
|
261
|
-
const valuesByGroupName = valueMap.get(tokenGroupName);
|
|
261
|
+
const valuesByGroupName = valueMap.get(resolvedGroupName) ?? valueMap.get(tokenGroupName);
|
|
262
262
|
const values = aliases.reduce((acc, alias) => {
|
|
263
|
-
|
|
263
|
+
if (acc) return acc;
|
|
264
|
+
const direct = valueMap.get(alias);
|
|
265
|
+
if (direct) return direct;
|
|
266
|
+
const dashed = api.camelCaseToDash(alias);
|
|
267
|
+
return valueMap.get(dashed) || null;
|
|
264
268
|
}, null) || valuesByGroupName;
|
|
265
269
|
if (!values) return;
|
|
266
270
|
const rawValue = prop.value;
|