@@ -66,7 +66,7 @@ export interface CompileClassOptions {
6666
6767export default function transformerCompileClass ( options : CompileClassOptions = { } ) : SourceCodeTransformer {
6868 const {
69- trigger = / ( [ " ' ` ] ) : u n o - ? (?< name > \S + ) ? : \s ( . * ?) \1/ g,
69+ trigger = / ( [ " ' ` ] ) \s * : u n o - ? (?< name > \S + ) ? : \s ( [ \s \S ] * ?) \1/ g,
7070 classPrefix = 'uno-' ,
7171 hashFn = hash ,
7272 keepUnknown = true ,
@@ -78,22 +78,22 @@ export default function transformerCompileClass(options: CompileClassOptions = {
7878 // Provides backwards compatibility. We either accept a trigger string which
7979 // gets turned into a regexp (like previously) or a regex literal directly.
8080 const regexp = typeof trigger === 'string'
81- ? new RegExp ( `(["'\`])${ escapeRegExp ( trigger ) } \\s([^\\1 ]*?)\\1` , 'g' )
81+ ? new RegExp ( `(["'\`])\\s* ${ escapeRegExp ( trigger ) } \\s([\\s\\S ]*?)\\1` , 'g' )
8282 : trigger
8383
8484 return {
8585 name : '@unocss/transformer-compile-class' ,
8686 enforce : 'pre' ,
8787 async transform ( s , _ , { uno, tokens, invalidate } ) {
88- const matches = [ ... s . original . matchAll ( regexp ) ]
88+ const matches = Array . from ( s . original . matchAll ( regexp ) )
8989 if ( ! matches . length )
9090 return
9191
9292 const size = compiledClass . size
9393 for ( const match of matches ) {
94- let body = ( match . length === 4 && match . groups )
94+ let body = ( ( match . length === 4 && match . groups )
9595 ? expandVariantGroup ( match [ 3 ] . trim ( ) )
96- : expandVariantGroup ( match [ 2 ] . trim ( ) )
96+ : expandVariantGroup ( match [ 2 ] . trim ( ) ) ) . replace ( / \s + / g , ' ' )
9797
9898 const start = match . index !
9999 const replacements = [ ]
0 commit comments