@@ -5,7 +5,7 @@ import Service from "@ember/service";
5
5
6
6
/// @ts -ignore
7
7
import { data as _data } from "./-css-blocks-data" ;
8
- import type { AggregateRewriteData , ConditionalStyle , GlobalBlockIndex , ImpliedStyles , OptimizationEntry , StyleExpression , StyleRequirements } from "./AggregateRewriteData" ;
8
+ import type { AggregateRewriteData , GlobalBlockIndex , OptimizationEntry , StyleExpression } from "./AggregateRewriteData" ;
9
9
import { StyleEvaluator } from "./StyleEvaluator" ;
10
10
import { StyleResolver } from "./StyleResolver" ;
11
11
@@ -85,6 +85,9 @@ export default class CSSBlocksService extends Service {
85
85
return [ ...new Set ( optimizations ) ] . map ( i => data . optimizations [ i ] ) ;
86
86
}
87
87
88
+ /**
89
+ * Reverse maps style ids to their style names for debugging.
90
+ */
88
91
debugStyles ( msg : string , stylesApplied : Set < number > ) : void {
89
92
if ( ! DEBUGGING ) return ;
90
93
let appliedStyleNames = new Array < string > ( ) ;
@@ -110,24 +113,6 @@ export default class CSSBlocksService extends Service {
110
113
return debugExpr ;
111
114
}
112
115
113
- ensureRequirementsAreSatisfied ( stylesApplied : Set < number > , requirements : StyleRequirements ) : void {
114
- let checkAgain = true ;
115
- while ( checkAgain ) {
116
- checkAgain = false ;
117
- for ( let s of stylesApplied ) {
118
- let expr = requirements [ s ] ;
119
- if ( expr && ! this . evaluateExpression ( expr , stylesApplied ) ) {
120
- if ( DEBUGGING ) {
121
- console . log ( `Removing ${ this . styleNames [ s ] } because` , this . debugExpression ( expr ) ) ;
122
- }
123
- stylesApplied . delete ( s ) ;
124
- checkAgain = true ;
125
- break ;
126
- }
127
- }
128
- }
129
- }
130
-
131
116
evaluateExpression ( expr : StyleExpression , stylesApplied : Set < number > , stylesApplied2 ?: Set < number > ) : boolean {
132
117
if ( typeof expr === "number" ) return ( stylesApplied . has ( expr ) || ( ! ! stylesApplied2 && stylesApplied2 . has ( expr ) ) ) ;
133
118
if ( expr [ 0 ] === Operator . AND ) {
@@ -146,52 +131,6 @@ export default class CSSBlocksService extends Service {
146
131
return false ;
147
132
}
148
133
}
149
-
150
- applyImpliedStyles ( stylesApplied : Set < number > , impliedStyles : ImpliedStyles ) : Set < string > {
151
- let aliases = new Set < string > ( ) ;
152
- let newStyles = new Set ( stylesApplied ) ;
153
- let failedConditions = new Set < ConditionalStyle > ( ) ;
154
- // for each new style we get the directly implied styles by each of them and
155
- // add them to the next iteration of new styles. if a conditionally applied
156
- // style doesn't match, it might be due to an implied style that isn't applied
157
- // yet, so we keep the failures around and try adding them during each
158
- // iteration once new styles are taken into account.
159
- while ( newStyles . size > 0 ) {
160
- let nextStyles = new Set < number > ( ) ;
161
- let newFailedConditions = new Set < ConditionalStyle > ( ) ;
162
- for ( let style of newStyles ) {
163
- let implied = impliedStyles [ style ] ;
164
- if ( ! implied ) continue ;
165
- for ( let i of implied ) {
166
- if ( typeof i === "number" ) {
167
- nextStyles . add ( i ) ;
168
- } else if ( typeof i === "string" ) {
169
- aliases . add ( i ) ;
170
- } else {
171
- if ( this . evaluateExpression ( i . conditions , stylesApplied , newStyles ) ) {
172
- for ( let s of i . styles ) nextStyles . add ( s ) ;
173
- } else {
174
- newFailedConditions . add ( i ) ;
175
- }
176
- }
177
- }
178
- }
179
- for ( let s of newStyles ) {
180
- stylesApplied . add ( s ) ;
181
- }
182
- newStyles = nextStyles ;
183
- for ( let c of failedConditions ) {
184
- if ( this . evaluateExpression ( c . conditions , stylesApplied , newStyles ) ) {
185
- for ( let s of c . styles ) newStyles . add ( s ) ;
186
- failedConditions . delete ( c ) ;
187
- }
188
- }
189
- for ( let c of newFailedConditions ) {
190
- failedConditions . add ( c ) ;
191
- }
192
- }
193
- return aliases ;
194
- }
195
134
}
196
135
197
136
function getOptimizationInverseMap ( optimizations : Array < OptimizationEntry > ) : StyleIdToOptimizationsMap {
0 commit comments