@@ -15,15 +15,16 @@ export const symbols: ControlSymbols = {
1515}
1616
1717class UnoGeneratorInternal < Theme extends object = object > {
18- public version = version
19- private _cache = new Map < string , StringifiedUtil < Theme > [ ] | null > ( )
18+ public readonly version = version
19+ public readonly events = createNanoEvents < {
20+ config : ( config : ResolvedConfig < Theme > ) => void
21+ } > ( )
22+
2023 public config : ResolvedConfig < Theme > = undefined !
24+ public cache = new Map < string , StringifiedUtil < Theme > [ ] | null > ( )
2125 public blocked = new Set < string > ( )
2226 public parentOrders = new Map < string , number > ( )
2327 public activatedRules = new Set < Rule < Theme > > ( )
24- public events = createNanoEvents < {
25- config : ( config : ResolvedConfig < Theme > ) => void
26- } > ( )
2728
2829 protected constructor (
2930 public userConfig : UserConfig < Theme > = { } ,
@@ -52,7 +53,7 @@ class UnoGeneratorInternal<Theme extends object = object> {
5253 this . blocked . clear ( )
5354 this . parentOrders . clear ( )
5455 this . activatedRules . clear ( )
55- this . _cache . clear ( )
56+ this . cache . clear ( )
5657 this . config = await resolveConfig ( userConfig , this . defaults )
5758 this . events . emit ( 'config' , this . config )
5859 }
@@ -123,24 +124,24 @@ class UnoGeneratorInternal<Theme extends object = object> {
123124 const cacheKey = `${ raw } ${ alias ? ` ${ alias } ` : '' } `
124125
125126 // use caches if possible
126- if ( this . _cache . has ( cacheKey ) )
127- return this . _cache . get ( cacheKey )
127+ if ( this . cache . has ( cacheKey ) )
128+ return this . cache . get ( cacheKey )
128129
129130 let current = raw
130131 for ( const p of this . config . preprocess )
131132 current = p ( raw ) !
132133
133134 if ( this . isBlocked ( current ) ) {
134135 this . blocked . add ( raw )
135- this . _cache . set ( cacheKey , null )
136+ this . cache . set ( cacheKey , null )
136137 return
137138 }
138139
139140 const variantResults = await this . matchVariants ( raw , current )
140141
141142 if ( variantResults . every ( i => ! i || this . isBlocked ( i [ 1 ] ) ) ) {
142143 this . blocked . add ( raw )
143- this . _cache . set ( cacheKey , null )
144+ this . cache . set ( cacheKey , null )
144145 return
145146 }
146147
@@ -162,12 +163,12 @@ class UnoGeneratorInternal<Theme extends object = object> {
162163
163164 const result = ( await Promise . all ( variantResults . map ( i => handleVariantResult ( i ) ) ) ) . flat ( ) . filter ( x => ! ! x )
164165 if ( result ?. length ) {
165- this . _cache . set ( cacheKey , result )
166+ this . cache . set ( cacheKey , result )
166167 return result
167168 }
168169
169170 // set null cache for unmatched result
170- this . _cache . set ( cacheKey , null )
171+ this . cache . set ( cacheKey , null )
171172 }
172173
173174 generate (
0 commit comments