import { launchManagedBrowser, resolveManagedGpuMode } from "../browser/launch.js"; // The media-metadata wait exists twice on purpose: once Node-side and once // inside a page.evaluate() body, which is serialized into the browser and // cannot import the Node helper. Line-level markers don't survive the clone // window drifting as the file is edited, hence the file-level suppression. // fallow-ignore-file code-duplication import { failCommand, setCommandExitCode } from "../utils/commandResult.js"; import { defineCommand } from "../utils/defineCommand.js"; import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; import { resolveProject, type ProjectDir } from "../utils/project.js"; import { normalizeErrorMessage } from "../utils/errorMessage.js"; import type { ProjectLintResult } from "../utils/lintProject.js"; import { resolveCompositionViewportFromHtml } from "../utils/compositionViewport.js"; import { resolveNaturalMediaTimelineDuration } from "@hyperframes/core"; import { c } from "../ui/colors.js"; import { decodeWellFormedEscapes } from "@hyperframes/studio-server"; import { printDeprecationNotice, withMeta } from "../utils/updateCheck.js"; import { pageNavigationTimeoutMs } from "../utils/renderArgs.js"; import { installPageFunctionGuard, resolveCliChromeGpuMode, seekCompositionTimeline, waitForRuntimeReady, } from "../capture/captureCompositionFrame.js"; import { failureMessage, jsonFailure } from "../utils/jsonError.js"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); interface ConsoleEntry { level: "error" | "warning"; text: string; url?: string; line?: number; } interface ContrastEntry { time: number; selector: string; text: string; ratio: number; wcagAA: boolean; large: boolean; fg: string; bg: string; } const CONTRAST_SAMPLES = 5; const SEEK_SETTLE_MS = 150; const PREFERRED_SEEK_TARGET_WAIT_MS = 500; // Media files a proxy swap can abandon mid-fetch; an aborted non-image request for one is not a load failure. const MEDIA_EXTENSIONS = /\.(3gp|aac|aif|aiff|avi|flac|flv|m2ts|m4a|m4v|mkv|mov|mp3|mp4|mpeg|mpg|mts|mxf|oga|ogg|ogv|opus|wav|weba|webm|wma|wmv)$/i; // Turn Puppeteer's opaque "Navigation timeout of Nms exceeded" into an // actionable message: the usual cause is a slow blocking CDN