Skip to content

Commit a492f4f

Browse files
committed
chore: Remove dead code left over from old style resolution algorithm.
1 parent fc7a346 commit a492f4f

File tree

1 file changed

+4
-65
lines changed

1 file changed

+4
-65
lines changed

packages/@css-blocks/ember-app/runtime/app/services/css-blocks.ts

+4-65
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Service from "@ember/service";
55

66
/// @ts-ignore
77
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";
99
import { StyleEvaluator } from "./StyleEvaluator";
1010
import { StyleResolver } from "./StyleResolver";
1111

@@ -85,6 +85,9 @@ export default class CSSBlocksService extends Service {
8585
return [...new Set(optimizations)].map(i => data.optimizations[i]);
8686
}
8787

88+
/**
89+
* Reverse maps style ids to their style names for debugging.
90+
*/
8891
debugStyles(msg: string, stylesApplied: Set<number>): void {
8992
if (!DEBUGGING) return;
9093
let appliedStyleNames = new Array<string>();
@@ -110,24 +113,6 @@ export default class CSSBlocksService extends Service {
110113
return debugExpr;
111114
}
112115

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-
131116
evaluateExpression(expr: StyleExpression, stylesApplied: Set<number>, stylesApplied2?: Set<number>): boolean {
132117
if (typeof expr === "number") return (stylesApplied.has(expr) || (!!stylesApplied2 && stylesApplied2.has(expr)));
133118
if (expr[0] === Operator.AND) {
@@ -146,52 +131,6 @@ export default class CSSBlocksService extends Service {
146131
return false;
147132
}
148133
}
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-
}
195134
}
196135

197136
function getOptimizationInverseMap(optimizations: Array<OptimizationEntry>): StyleIdToOptimizationsMap {

0 commit comments

Comments
 (0)