Skip to content

Commit 27285ca

Browse files
committed
refactor(default-policy): improve code readability with consistent formatting
1 parent 7f39264 commit 27285ca

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

plugins/profile/default-policy.js

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,23 @@ export const defaultProfilePlugin = {
8484
const win = typeof window !== "undefined" ? window : {};
8585
const scr = typeof screen !== "undefined" ? screen : {};
8686

87-
const userAgentHint = typeof nav.userAgent === "string" ? nav.userAgent : "";
87+
const userAgentHint =
88+
typeof nav.userAgent === "string" ? nav.userAgent : "";
8889
const cores = Math.max(1, Number(nav.hardwareConcurrency || 2));
8990
const memoryGB = Math.max(0.5, Number(nav.deviceMemory || 2));
9091
const webgl2 = !!win.WebGL2RenderingContext;
91-
const wasmSIMD = typeof WebAssembly === "object" && typeof WebAssembly.validate === "function";
92-
const screenLongSide = Math.max(Number(scr.width || 0), Number(scr.height || 0)) || 0;
92+
const wasmSIMD =
93+
typeof WebAssembly === "object" &&
94+
typeof WebAssembly.validate === "function";
95+
const screenLongSide =
96+
Math.max(Number(scr.width || 0), Number(scr.height || 0)) || 0;
9397

9498
let torch = false;
9599
let focusMode = "unknown";
96100
try {
97-
const getSC = nav.mediaDevices?.getSupportedConstraints?.bind(nav.mediaDevices);
101+
const getSC = nav.mediaDevices?.getSupportedConstraints?.bind(
102+
nav.mediaDevices,
103+
);
98104
const sc = getSC ? getSC() : {};
99105
torch = !!sc?.torch;
100106
focusMode = sc?.focusMode ? "supported" : "unknown";
@@ -117,7 +123,10 @@ export const defaultProfilePlugin = {
117123
* Very small CPU probe to approximate budget
118124
*/
119125
async _microBenchmark(msTarget = 8) {
120-
if (typeof performance === "undefined" || typeof performance.now !== "function") {
126+
if (
127+
typeof performance === "undefined" ||
128+
typeof performance.now !== "function"
129+
) {
121130
return 0;
122131
}
123132
const start = performance.now();
@@ -162,15 +171,35 @@ export const defaultProfilePlugin = {
162171
*/
163172
_pickTier(score) {
164173
if (score >= 85) {
165-
return { tier: QUALITY_TIERS.ULTRA, capture: [1280, 720], budget: 12, complexity: "high" };
174+
return {
175+
tier: QUALITY_TIERS.ULTRA,
176+
capture: [1280, 720],
177+
budget: 12,
178+
complexity: "high",
179+
};
166180
}
167181
if (score >= 65) {
168-
return { tier: QUALITY_TIERS.HIGH, capture: [960, 540], budget: 10, complexity: "high" };
182+
return {
183+
tier: QUALITY_TIERS.HIGH,
184+
capture: [960, 540],
185+
budget: 10,
186+
complexity: "high",
187+
};
169188
}
170189
if (score >= 45) {
171-
return { tier: QUALITY_TIERS.MEDIUM, capture: [800, 450], budget: 8, complexity: "medium" };
190+
return {
191+
tier: QUALITY_TIERS.MEDIUM,
192+
capture: [800, 450],
193+
budget: 8,
194+
complexity: "medium",
195+
};
172196
}
173-
return { tier: QUALITY_TIERS.LOW, capture: [640, 360], budget: 6, complexity: "low" };
197+
return {
198+
tier: QUALITY_TIERS.LOW,
199+
capture: [640, 360],
200+
budget: 6,
201+
complexity: "low",
202+
};
174203
},
175204

176205
/**
@@ -262,4 +291,4 @@ export const defaultProfilePlugin = {
262291
async dispose() {
263292
// Nothing to clean up
264293
},
265-
};
294+
};

0 commit comments

Comments
 (0)