#!/usr/bin/env node // Generic browser capture kit for the Flutter app. See README.md beside this file. // // node tool/capture/capture.mjs --build build/probe-app --out /tmp/shots \ // open=/runs/7 shot=summary click=Artifacts shot=artifacts // // Serves a build (or takes --url), launches private headless Chrome (or // attaches with --cdp), runs the steps, writes NN-.png files plus // report.json into --out, and always removes Chrome, its profile and the server. import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { join, resolve } from 'node:path'; import { setTimeout as delay } from 'node:timers/promises'; import { openBrowser } from './browser.mjs'; import { serveBuild } from './serve.mjs'; import { contactSheet, pickFrames } from './sheet.mjs'; import { describe, flutterPage, parseTarget } from './page.mjs'; const USAGE = `usage: capture.mjs (--build | --url ) --out [options] [steps...] options: --script --size WxH (880x1000) --platform material|cupertino --theme light|dark --q --wait --film-ms --cdp http://127.0.0.1: --probe true|false --params --touch true (emulate a touch screen: mobile metrics, touch input) steps: open=[@WxH] wait= shot= click= waitfor= type= press= scroll= size=WxH files=[,] (answers the next file chooser) film= labels= tabs= eval= expect= hover= drag=>, (JSON: drag, dx, dy, steps, gap, hold) swipe=>, pinch=> (with --touch true) target: