MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runMotionPass

Function runMotionPass

packages/cli/src/commands/layout.ts:400–419  ·  view source on GitHub ↗

* Motion verification (#1437): sample the asserted selectors on a dense grid * against the same seeked timeline the renderer uses, then evaluate the spec's * assertions in Node. Reuses the live page from the layout audit — no extra * Chrome launch. Findings reuse the LayoutIssue shape.

(
  page: import("puppeteer-core").Page,
  spec: MotionSpec,
  duration: number,
)

Source from the content-addressed store, hash-verified

398 * Chrome launch. Findings reuse the LayoutIssue shape.
399 */
400async function runMotionPass(
401 page: import("puppeteer-core").Page,
402 spec: MotionSpec,
403 duration: number,
404): Promise<{ issues: LayoutIssue[]; sampleCount: number }> {
405 const times = buildMotionSampleTimes(spec.duration ?? duration);
406 if (times.length === 0) return { issues: [], sampleCount: 0 };
407
408 const { selectors, livenessScopes } = collectSamplingTargets(spec.assertions);
409 const ambiguous = await findAmbiguousSelectors(page, selectors);
410 if (ambiguous.length > 0) return { issues: ambiguous, sampleCount: 0 };
411
412 const canvas = await page.evaluate(() => ({
413 width: window.innerWidth,
414 height: window.innerHeight,
415 }));
416 await page.addScriptTag({ content: loadBrowserScript("motion-sample.browser.js") });
417 const frames = await collectMotionFrames(page, times, selectors, livenessScopes);
418 return { issues: evaluateMotion(frames, spec.assertions, canvas), sampleCount: frames.length };
419}
420
421/** Read + validate the motion sidecar; print the error and exit on a bad spec. */
422function resolveMotionSpec(specPath: string, json: boolean): MotionSpec {

Callers 1

runLayoutAuditFunction · 0.85

Calls 7

buildMotionSampleTimesFunction · 0.85
collectSamplingTargetsFunction · 0.85
findAmbiguousSelectorsFunction · 0.85
loadBrowserScriptFunction · 0.85
collectMotionFramesFunction · 0.85
evaluateMotionFunction · 0.85
evaluateMethod · 0.80

Tested by

no test coverage detected