const PREFERS_COLOR_SCHEME_REG = /prefers-color-scheme:\s?([light|dark]+[^\s)])/i ; export function isPrefersColorScheme ( mediaKey ) { return PREFERS_COLOR_SCHEME_REG . test ( mediaKey || '' ) ; } export function processPrefersColorScheme ( mediaRules , styles = { } , taskName = 'web' ) { mediaRules . forEach ( ( rule ) => { if ( taskName === 'weex' && isPrefersColorScheme ( rule . key ) ) { for ( const className in rule . data ) { for ( const key in rule . data [ className ] ) { if ( /^[a-zA-Z].*$/ . test ( key ) ) { if ( ! styles [ className ] ) { styles [ className ] = { } ; } styles [ className ] [ `-weex-${ rule . key . match ( PREFERS_COLOR_SCHEME_REG ) [ 1 ] }-scheme-${ key }` ] = rule . data [ className ] [ key ] ; } } } } } ) ; return styles ; }