File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export {
3030 darkThemeColors ,
3131 lightThemeColors ,
3232 buildMonacoRules ,
33+ buildVscodeRules ,
3334} from './theme' ;
3435export type { ThemeColors , TokenStyle } from './theme' ;
3536
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments