From 6614587661ae1a37887814901b7d7f6bdb0e8e0d Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Fri, 6 Nov 2026 15:26:36 -0500 Subject: [PATCH] refactor(engine): the effect scan resolves its options before scanning --- packages/engine/src/services/riskFrames.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/engine/src/services/riskFrames.ts b/packages/engine/src/services/riskFrames.ts index 6815a09d3d7..8387c39e580 100644 --- a/packages/engine/src/services/riskFrames.ts +++ b/packages/engine/src/services/riskFrames.ts @@ -94,12 +94,17 @@ export async function scanCssEffectLiveFrames( fps: number, totalFrames: number, maxFrames: number, - options: ScanOptions = {}, + { + budgetMs = SCAN_BUDGET_MS, + now = () => performance.now(), + onProgress = () => {}, + onEnd, + }: ScanOptions = {}, ): Promise | null> { try { - return await scanLiveFrames(page, fps, totalFrames, maxFrames, options); + return await scanLiveFrames(page, fps, totalFrames, maxFrames, budgetMs, now, onProgress); } finally { - options.onEnd?.(); + onEnd?.(); } } @@ -108,7 +113,9 @@ async function scanLiveFrames( fps: number, totalFrames: number, maxFrames: number, - { budgetMs = SCAN_BUDGET_MS, now = () => performance.now(), onProgress }: ScanOptions, + budgetMs: number, + now: () => number, + onProgress: NonNullable, ): Promise | null> { const live = new Set(); const started = now(); @@ -125,7 +132,7 @@ async function scanLiveFrames( return null; } for (const i of shown) live.add(from + i); - onProgress?.(to, totalFrames); + onProgress(to, totalFrames); const projectedMs = ((now() - started) / to) * totalFrames; if (to < totalFrames && projectedMs > budgetMs) { console.error(