@@ -7,6 +7,8 @@ import isUnicodeSupported from './external/@socketregistry/is-unicode-supported'
77import yoctocolorsCjs from './external/yoctocolors-cjs'
88import { objectAssign , objectFreeze } from './objects'
99import { applyLinePrefix , isBlankString } from './strings'
10+ import type { ColorValue } from './spinner'
11+ import { getTheme } from './themes/context'
1012
1113/**
1214 * Log symbols for terminal output with colored indicators.
@@ -115,24 +117,44 @@ function getYoctocolors() {
115117 return yoctocolorsCjs
116118}
117119
120+ /**
121+ * Apply a color to text using yoctocolors.
122+ * Handles both named colors and RGB tuples.
123+ * @private
124+ */
125+ /*@__NO_SIDE_EFFECTS__ */
126+ function applyColor (
127+ text : string ,
128+ color : ColorValue ,
129+ colors : typeof yoctocolorsCjs ,
130+ ) : string {
131+ if ( typeof color === 'string' ) {
132+ // Named color like 'green', 'red', etc.
133+ return ( colors as any ) [ color ] ( text )
134+ }
135+ // RGB tuple [r, g, b]
136+ return colors . rgb ( color [ 0 ] , color [ 1 ] , color [ 2 ] ) ( text )
137+ }
138+
118139/**
119140 * Log symbols for terminal output with colored indicators.
120141 *
121142 * Provides colored Unicode symbols (✔, ✖, ⚠, ℹ, →) with ASCII fallbacks (√, ×, ‼, i, >)
122- * for terminals that don't support Unicode. Symbols are color-coded: green for
123- * success, red for failure, yellow for warnings, blue for info, cyan for step.
143+ * for terminals that don't support Unicode. Symbols are colored according to the active
144+ * theme's color palette (success, error, warning, info, step) .
124145 *
125146 * The symbols are lazily initialized on first access and then frozen for immutability.
147+ * Colors are determined by the theme active at initialization time.
126148 *
127149 * @example
128150 * ```typescript
129151 * import { LOG_SYMBOLS } from '@socketsecurity/lib'
130152 *
131- * console.log(`${LOG_SYMBOLS.success} Build completed`) // Green ✔
132- * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Red ✖
133- * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Yellow ⚠
134- * console.log(`${LOG_SYMBOLS.info} Starting process`) // Blue ℹ
135- * console.log(`${LOG_SYMBOLS.step} Processing files`) // Cyan →
153+ * console.log(`${LOG_SYMBOLS.success} Build completed`) // Theme success color ✔
154+ * console.log(`${LOG_SYMBOLS.fail} Build failed`) // Theme error color ✖
155+ * console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Theme warning color ⚠
156+ * console.log(`${LOG_SYMBOLS.info} Starting process`) // Theme info color ℹ
157+ * console.log(`${LOG_SYMBOLS.step} Processing files`) // Theme step color →
136158 * ```
137159 */
138160export const LOG_SYMBOLS = /*@__PURE__ */ ( ( ) => {
@@ -146,12 +168,21 @@ export const LOG_SYMBOLS = /*@__PURE__*/ (() => {
146168 const init = ( ) => {
147169 const supported = isUnicodeSupported ( )
148170 const colors = getYoctocolors ( )
171+ const theme = getTheme ( )
172+
173+ // Get colors from theme
174+ const successColor = theme . colors . success
175+ const errorColor = theme . colors . error
176+ const warningColor = theme . colors . warning
177+ const infoColor = theme . colors . info
178+ const stepColor = theme . colors . step
179+
149180 objectAssign ( target , {
150- fail : colors . red ( supported ? '✖' : '×' ) ,
151- info : colors . blue ( supported ? 'ℹ' : 'i' ) ,
152- step : colors . cyan ( supported ? '→' : '>' ) ,
153- success : colors . green ( supported ? '✔' : '√' ) ,
154- warn : colors . yellow ( supported ? '⚠' : '‼' ) ,
181+ fail : applyColor ( supported ? '✖' : '×' , errorColor , colors ) ,
182+ info : applyColor ( supported ? 'ℹ' : 'i' , infoColor , colors ) ,
183+ step : applyColor ( supported ? '→' : '>' , stepColor , colors ) ,
184+ success : applyColor ( supported ? '✔' : '√' , successColor , colors ) ,
185+ warn : applyColor ( supported ? '⚠' : '‼' , warningColor , colors ) ,
155186 } )
156187 objectFreeze ( target )
157188 // The handler of a Proxy is mutable after proxy instantiation.
0 commit comments