@@ -36,6 +36,7 @@ const COLOR_PROPS = [
3636]
3737
3838export type KeywordColor = 'transparent' | 'currentColor'
39+ export type ParsedColor = KeywordColor | culori . Color
3940
4041function getKeywordColor ( value : unknown ) : KeywordColor | null {
4142 if ( typeof value !== 'string' ) return null
@@ -56,7 +57,7 @@ const colorRegex = new RegExp(
5657 'gi' ,
5758)
5859
59- function getColorsInString ( state : State , str : string ) : ( culori . Color | KeywordColor ) [ ] {
60+ function getColorsInString ( state : State , str : string ) : ParsedColor [ ] {
6061 if ( / (?: b o x | d r o p ) - s h a d o w / . test ( str ) && ! / - - t w - d r o p - s h a d o w / . test ( str ) ) return [ ]
6162
6263 function toColor ( match : RegExpMatchArray ) {
@@ -76,7 +77,7 @@ function getColorsInString(state: State, str: string): (culori.Color | KeywordCo
7677function getColorFromDecls (
7778 state : State ,
7879 decls : Record < string , string | string [ ] > ,
79- ) : culori . Color | KeywordColor | null {
80+ ) : ParsedColor | null {
8081 let props = Object . keys ( decls ) . filter ( ( prop ) => {
8182 // ignore content: "";
8283 if ( prop === 'content' ) {
@@ -151,7 +152,7 @@ function getColorFromDecls(
151152 return null
152153}
153154
154- function getColorFromRoot ( state : State , css : AstNode [ ] ) : culori . Color | KeywordColor | null {
155+ function getColorFromRoot ( state : State , css : AstNode [ ] ) : ParsedColor | null {
155156 let decls : Record < string , string [ ] > = { }
156157
157158 walk ( css , ( node ) => {
@@ -202,7 +203,7 @@ function isLikelyColorless(className: string) {
202203 return false
203204}
204205
205- export function getColor ( state : State , className : string ) : culori . Color | KeywordColor | null {
206+ export function getColor ( state : State , className : string ) : ParsedColor | null {
206207 if ( state . v4 ) {
207208 // FIXME: This is a performance optimization and not strictly correct
208209 if ( isLikelyColorless ( className ) ) return null
@@ -268,7 +269,7 @@ export function getColor(state: State, className: string): culori.Color | Keywor
268269 return getColorFromDecls ( state , removeMeta ( item ) )
269270}
270271
271- export function getColorFromValue ( value : unknown ) : culori . Color | KeywordColor | null {
272+ export function getColorFromValue ( value : unknown ) : ParsedColor | null {
272273 if ( typeof value !== 'string' ) return null
273274
274275 let trimmedValue = value . trim ( )
0 commit comments