fix(cli): align snapshot's local InjectFn return type with engine

`injectVideoFramesBatch` now returns `Promise<string[]>` so the caller can
filter cache entries to videos the page actually painted. The cli-side
snapshot command does not use the return value, but its local `InjectFn`
declared `Promise<void>` which made the `as { injectVideoFramesBatch:
InjectFn }` cast on the dynamic engine import fail typecheck under TS's
"sufficiently overlapping types" rule. Match the engine's actual export
shape.
This commit is contained in:
Lirian Su
2026-05-26 00:37:13 -04:00
committed by Miguel Ángel
parent f89c17fd81
commit 9a7b3efa94
+7 -1
View File
@@ -232,10 +232,16 @@ async function captureSnapshots(
// Chrome-headless ignores programmatic <video>.currentTime writes, so
// we extract frames via FFmpeg and overlay them as <img> elements.
//
// The engine's injectVideoFramesBatch returns the subset of videoIds it
// actually painted (skipped ancestor-hidden videos are excluded).
// Snapshot doesn't use the return value, but the local type must match
// the real export — a `Promise<void>` shape rejects the `as` cast on
// the dynamic import.
type InjectFn = (
page: unknown,
updates: Array<{ videoId: string; dataUri: string }>,
) => Promise<void>;
) => Promise<string[]>;
type SyncVisibilityFn = (page: unknown, activeVideoIds: string[]) => Promise<void>;
type ExtractMediaMetadataFn = (
filePath: string,