@@ -6,7 +6,7 @@ import type { ObjectDictionary } from "@opticss/util";
6
6
7
7
/// @ts -ignore
8
8
import { data as _data } from "./-css-blocks-data" ;
9
- import type { AggregateRewriteData , ConditionalStyle , ImpliedStyles , StyleExpression } from "./AggregateRewriteData" ;
9
+ import type { AggregateRewriteData , ConditionalStyle , ImpliedStyles , StyleExpression , StyleRequirements } from "./AggregateRewriteData" ;
10
10
11
11
const data : AggregateRewriteData = _data ;
12
12
@@ -215,6 +215,8 @@ export default class CSSBlocksService extends Service {
215
215
}
216
216
}
217
217
218
+ ensureRequirementsAreSatisfied ( stylesApplied , data . styleRequirements ) ;
219
+
218
220
let aliasClassNames = applyImpliedStyles ( stylesApplied , data . impliedStyles ) ;
219
221
220
222
let classNameIndices = new Set < number > ( ) ;
@@ -253,8 +255,22 @@ function evaluateExpression(expr: StyleExpression, stylesApplied: Set<number>, s
253
255
}
254
256
}
255
257
258
+ function ensureRequirementsAreSatisfied ( stylesApplied : Set < number > , requirements : StyleRequirements ) : void {
259
+ let checkAgain = true ;
260
+ while ( checkAgain ) {
261
+ checkAgain = false ;
262
+ for ( let s of stylesApplied ) {
263
+ let expr = requirements [ s ] ;
264
+ if ( expr && ! evaluateExpression ( expr , stylesApplied ) ) {
265
+ stylesApplied . delete ( s ) ;
266
+ checkAgain = true ;
267
+ break ;
268
+ }
269
+ }
270
+ }
271
+ }
272
+
256
273
function applyImpliedStyles ( stylesApplied : Set < number > , impliedStyles : ImpliedStyles ) : Set < string > {
257
- console . log ( { impliedStyles} ) ;
258
274
let aliases = new Set < string > ( ) ;
259
275
let newStyles = new Set ( stylesApplied ) ;
260
276
let failedConditions = new Set < ConditionalStyle > ( ) ;
0 commit comments