Skip to content

Commit 5e7ce96

Browse files
fix: restore buildVscodeRules export to avoid breaking external consumers
1 parent c39fa7e commit 5e7ce96

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

packages/monaco/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
darkThemeColors,
3131
lightThemeColors,
3232
buildMonacoRules,
33+
buildVscodeRules,
3334
} from './theme';
3435
export type { ThemeColors, TokenStyle } from './theme';
3536

packages/monaco/src/theme.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,38 @@ export function buildMonacoRules(
9999
return rules;
100100
}
101101

102+
/**
103+
* Build VS Code semanticTokenColorCustomizations rules from color definitions.
104+
* Returns an object suitable for package.json configurationDefaults.
105+
*/
106+
type VscodeRule =
107+
| string
108+
| { foreground?: string; bold?: boolean; italic?: boolean };
109+
110+
export function buildVscodeRules(
111+
colors: ThemeColors
112+
): Record<string, VscodeRule> {
113+
const rules: Record<string, VscodeRule> = {};
114+
115+
for (const [token, style] of Object.entries(colors)) {
116+
if (token === 'default') continue;
117+
118+
const key = `${token}:agentscript`;
119+
const hasExplicitFontStyle =
120+
style.bold !== undefined || style.italic !== undefined;
121+
122+
if (hasExplicitFontStyle) {
123+
rules[key] = {
124+
...(style.foreground
125+
? { foreground: `#${style.foreground.toUpperCase()}` }
126+
: {}),
127+
...(style.bold !== undefined ? { bold: style.bold } : {}),
128+
...(style.italic !== undefined ? { italic: style.italic } : {}),
129+
};
130+
} else if (style.foreground) {
131+
rules[key] = `#${style.foreground.toUpperCase()}`;
132+
}
133+
}
134+
135+
return rules;
136+
}

0 commit comments

Comments
 (0)