import { RecordingMeta, PeerStepSpan, CursorEvent, RecordingSkip, RecordingOutput, Backdrop, RecordingArtifact, ProjectDoc, RecordingPageMedia, Rect, StepSpan } from '@vosjs/studio-core'; export { PeerStepSpan } from '@vosjs/studio-core'; /** * The recorder's driver: what it needs from a browser, as a STRUCTURAL * contract. Playwright's own `Browser`/`BrowserContext`/`Page` satisfy it * unchanged, and so does `@cloudflare/playwright`'s (the same client * surface over Browser Rendering), so the CLI hands in a launched Node * browser and the fleet hands in a connected one, and the recorder never * imports either package. Only the members the recorder calls are named * here; a driver that offers more is fine, one that offers less fails to * type. * * Frames leave through a `FrameSink`, never through a filesystem: the CLI's * sink writes a take directory, the fleet's puts each JPEG to R2. */ interface RecorderRect { x: number; y: number; width: number; height: number; } interface RecorderLocator { waitFor(opts: { state: 'visible' | 'attached'; timeout: number; }): Promise; scrollIntoViewIfNeeded(): Promise; boundingBox(): Promise; click(): Promise; fill(value: string): Promise; /** what an `expect` and an `await` read, and the disabled-click report */ isVisible(): Promise; isEnabled(opts?: { timeout?: number; }): Promise; /** a `download` src reads the media element's source through the locator engine */ evaluate(fn: (el: RecorderMediaElement) => R): Promise; } /** What a `download` src reads off the element its selector matched. */ interface RecorderMediaElement { currentSrc?: string; src?: string; getAttribute(name: string): string | null; } /** A browser download, as Playwright's `Download` answers it. */ interface RecorderDownload { suggestedFilename(): string; createReadStream(): Promise | null>; } /** The page's own request context (its cookies), as Playwright's `APIResponse` answers. */ interface RecorderApiResponse { ok(): boolean; status(): number; headers(): Record; body(): Promise; } /** Which button a press is, and which press of a multi-click. */ interface RecorderButtonOpts { button?: 'left' | 'right' | 'middle'; clickCount?: number; } interface RecorderLocatorRoot { first(): RecorderLocator; } interface RecorderResponse { status(): number; } interface RecorderConsoleMessage { type(): string; text(): string; } interface RecorderPage { goto(url: string, opts: { waitUntil: 'networkidle' | 'load'; timeout: number; }): Promise; url(): string; title(): Promise; /** An `await` with `reload: true`; absent, the recorder opens the page's URL again. */ reload?(opts: { waitUntil: 'networkidle' | 'load'; timeout: number; }): Promise; /** A `download` step's click; absent, the recorder says the browser reports none. */ waitForEvent?(event: 'download', opts: { timeout: number; }): Promise; /** A `download` step's `src` fetch, with the page's cookies; absent, it fetches in the page. */ request?: { get(url: string, opts?: { timeout?: number; }): Promise; }; evaluate(pageFunction: string | (() => T)): Promise; on(event: 'console', cb: (m: RecorderConsoleMessage) => void): unknown; locator(selector: string): RecorderLocatorRoot; mouse: { move(x: number, y: number): Promise; down(opts?: RecorderButtonOpts): Promise; up(opts?: RecorderButtonOpts): Promise; wheel(dx: number, dy: number): Promise; }; keyboard: { type(text: string): Promise; press(key: string): Promise; /** A drag's modifiers, held from the press to the release. */ down(key: string): Promise; up(key: string): Promise; }; } interface RecorderCdp { on(event: 'Page.screencastFrame', cb: (ev: { data: string; sessionId: number; metadata: { timestamp?: number; }; }) => void): unknown; send(method: string, params?: Record): Promise; } /** One intercepted request, as Playwright's `Route` answers it. */ interface RecorderRoute { request(): { url(): string; headers(): Record; }; continue(opts?: { headers?: Record; }): Promise; } interface RecorderContext { newPage(): Promise; addInitScript(script: string): Promise; setExtraHTTPHeaders(headers: Record): Promise; /** * Request interception, when the driver has it: how a job's headers are * sent to the recorded origin alone. A driver without it gets them on * every request through `setExtraHTTPHeaders`, and the recorder says so. */ route?(pattern: string, handler: (route: RecorderRoute) => Promise | unknown): Promise; newCDPSession(page: unknown): Promise; /** * A `paste` step's clipboard access, when the driver grants it; absent, * the paste is dispatched in the page and the recorder says so. */ grantPermissions?(permissions: string[], opts?: { origin?: string; }): Promise; close(): Promise; } interface RecorderBrowser { newContext(opts: { viewport: { width: number; height: number; }; deviceScaleFactor: number; storageState?: string; extraHTTPHeaders?: Record; }): Promise; } /** * Where the screencast's frames go. `frame` is called in order with the * JPEG bytes; the recorder keeps the index (`file`, `tMs`) itself. The CLI * writes `frames/`; the fleet puts to R2. A sink may be async and * slow: the recorder never awaits it on the screencast's own thread, so a * slow store costs no frames, only memory until it catches up. */ interface FrameSink { frame(file: string, bytes: Uint8Array): Promise | void; } /** * Where a `download` step's file goes: the CLI writes `outputs/` in * the take directory. A host that hands in none cannot keep a download, * and the recorder refuses such a script before capturing anything. */ interface OutputSink { save(name: string, bytes: Uint8Array, contentType?: string): Promise | void; } /** * Where the sound a page played during the take is kept: the CLI writes * `page-sound/` in the take directory and answers that take-relative * key, which the plan's audio clips name. A host that hands in none (the * fleet) still records `meta.media`; the plan then places nothing. */ interface SoundSink { save(name: string, bytes: Uint8Array, contentType?: string): Promise | string; } /** * Where the files a script names beside itself come from: a drag's path * file, a paste's file, by a plain name. The CLI reads the actions file's * directory. A host that hands in none (a hosted recorder carries the * script alone) cannot run such a step, and the recorder refuses it before * capturing anything. */ interface ScriptFiles { read(name: string): Promise; } /** The clock and the pauses, injectable so a rehearsal runs fast. */ interface RecorderClock { now(): number; sleep(ms: number): Promise; } declare const realSleep: (ms: number) => Promise; /** * The recorder's pace — the pure parts. * * A take of a scripted flow should run as long as the script asks, plus the * gestures a person makes between the asks (the pointer's travel, the press, * the settle after it) and no more. Measured before this module (§4.5 of * the utility-clip retrospective), hovers ran 2× their ask, drags 4.8× and * a 25 s script recorded 42 s, for two reasons the numbers here answer: * * - The motion loops counted STEPS (one per 16 ms of the asked duration) * and awaited a `mouse.move` round trip per step, so a page that * re-renders per move (a slider) stretched every gesture by the round * trip. A gesture is now driven by the CLOCK: its position is a function * of the elapsed time, and it ends when the asked duration has elapsed, * however many samples the page allowed. * - The settles after a gesture were fixed sleeps (500 ms after a click, * 250 after every selector lookup). A settle is DATA: `ms` on the step * overrides a small default, and the script's own `wait` steps carry * the intended pauses. */ /** Pointer travel: ms per CSS px, floor and ceiling — a person's hand. */ declare const POINTER_MS_PER_PX = 0.7; declare const POINTER_MIN_MS = 250; declare const POINTER_MAX_MS = 800; /** The sample cadence a motion loop aims for. */ declare const MOTION_TICK_MS = 16; /** The settle after a gesture when the step names none, by verb. */ declare const SETTLE_MS: { readonly click: 150; readonly type: 150; readonly press: 150; readonly paste: 150; readonly scroll: 200; readonly drag: 80; }; /** The press: the pause before the button goes down, and the hold. */ declare const PRESS_LEAD_MS = 80; declare const PRESS_HOLD_MS = 70; /** The pause between a selector lookup that scrolled the page and the move. */ declare const SCROLL_SETTLE_MS = 120; /** * A scroll travels by the clock too, at a wheel's pace: 0.9 ms per px, * floored so a short flick still reads as motion and capped so a long page * does not crawl. Each tick moves the page's scroll container in the page * itself (recorder.ts says why not a wheel event, an animation frame or a * page timer). */ declare const SCROLL_MS_PER_PX = 0.9; declare const SCROLL_MIN_MS = 240; declare const SCROLL_MAX_MS = 1000; /** The hold after the last step, so the take does not cut on a press. */ declare const TRAILING_HOLD_MS = 400; /** How long the pointer takes to travel `dist` CSS px. */ declare function scrollTravelMs(px: number): number; declare function pointerTravelMs(dist: number): number; /** * A click's `ms` is READING time, held from the page's last visual change, * and the recorder pays the settle itself: the same `ms` was read on one * run and dead on the next because the hold started at the press and the * page's settle varied run to run (0.3 s to 0.7 s on the same step). * * The settle is watched on the screencast, which emits only on change: * after the press, a change that arrives within RESPONSE_MS says the page * is answering, and it has settled once QUIET_MS pass with no new frame. * No change within RESPONSE_MS means the page did not change (a click that * only moves state) and the settle is over. SETTLE_CAP_MS bounds a page * that never stops changing (a playing preview), which is a page nothing * is dead on, so the hold simply starts. */ declare const RESPONSE_MS = 400; declare const QUIET_MS = 250; declare const SETTLE_CAP_MS = 1200; /** * Is the page settled? Pure: the recorder feeds it what it knows at each * tick since the press. */ declare function settleVerdict(t: { /** ms since the press. */ sincePress: number; /** ms since the last screencast frame, or null when none arrived since the press. */ sinceChange: number | null; }, c?: { response: number; quiet: number; cap: number; }): 'wait' | 'settled'; /** * What is left of a hold once the settle is detected: the hold is measured * from the last change, so the quiet already spent counts toward it. */ declare function holdLeftMs(holdMs: number, sinceChange: number | null): number; /** The settle after a step: its own `ms` when it names one, else the verb's. */ declare function settleMs(step: { do: string; ms?: number; }): number; declare const easeInOutCubic: (u: number) => number; /** * Drive a motion by the clock: `at(u)` is called with the eased progress * for each sample, and the loop ends when `dur` ms have elapsed, with the * last call at u = 1 exactly. Between samples it sleeps to the next tick * only when the sample came back early; a slow sample (a page busy * re-rendering) is followed at once, so the gesture keeps its length and * loses samples, never the other way round. */ declare function clockMotion(dur: number, at: (u: number) => Promise, clock: { now: () => number; sleep: (ms: number) => Promise; }): Promise; /** * Typing paced by the clock: the i-th character is due at `start + i·delay`; * after each keystroke the loop sleeps to the next due time only if the * keystroke came back early. A slow field (an editor re-rendering per key) * types as fast as it can and says so in the pace report. */ declare function clockTyping(chars: readonly string[], delay: number, type: (ch: string, index: number) => Promise, clock: { now: () => number; sleep: (ms: number) => Promise; }): Promise; /** One step's pace: what the script asked for it and what it took. */ interface StepPace { step: number; do: string; /** The script's own ask: a wait's ms, a hover's dwell, a drag's ms, typing's chars × delay, a click's read after the settle; 0 for a scroll. */ askedMs: number; /** The gesture the recorder adds by design: pointer travel, the press, the settle. */ gestureMs: number; wallMs: number; } interface PaceReport { askedMs: number; gestureMs: number; wallMs: number; /** Wall time neither asked nor a gesture: what the page and the round trips cost. */ overheadMs: number; overheadPct: number; /** The steps whose wall ran past their ask plus gesture by more than a third. */ slow: { step: number; do: string; askedMs: number; wallMs: number; }[]; } /** What a script asks of a step, in ms: the part of its wall time that is the author's. */ declare function askedMs(step: { do: string; ms?: number; text?: string; delayMs?: number; }): number; declare function paceReport(steps: readonly StepPace[]): PaceReport; /** The pace in one line for the log. */ declare function paceLine(r: PaceReport): string; /** * DEAD TIME, the smoothness fact that replaces the freeze share as the * warning. A still frame is not a defect: a page the viewer is reading is * content, and a workspace tour is mostly still. What is dead is a still * frame under a PARKED cursor past the beat it takes to read what changed: * after that the picture, the pointer and the camera all hold and nothing * is being said. So the derivation reads, per step, when the page settled * after the step's act, how long the settled frame was held, and whether * the cursor moved in that hold; a hold past the reading beat is dead. * * The beat is longer after a page changed (a navigation shows a whole new * page to take in) than after a control changed (one thing to see). */ declare const READ_BEAT_MS: { readonly page: 1000; readonly control: 600; }; /** A dead stretch this long is a warning on its own, whatever the share. */ declare const DEAD_STRETCH_WARN_MS = 1500; /** The share of the take past which dead time is a warning. */ declare const DEAD_SHARE_WARN_PCT = 20; interface DeadStep { step: number; id?: string; do: string; /** ms from the step's act (its press, else its start) to the last frame change in the step. */ settledMs: number; /** ms the settled frame was held before the step ended. */ heldMs: number; /** the hold past the reading beat, while the cursor was parked; 0 when the hold was read or the pointer moved. */ deadMs: number; } interface DeadReport { ms: number; pct: number; /** the steps that carried any dead time, in order. */ steps: DeadStep[]; /** the longest single dead hold. */ longestMs: number; } declare function deadTime(steps: readonly { step: number; id?: string; do: string; tStart: number; tEnd: number; navigated?: boolean; }[], frames: readonly { tMs: number; }[], events: readonly { t: number; type: string; }[], durationMs: number): DeadReport; /** Whether a dead report earns a warning: the share, or one long hold. */ declare function deadWarns(r: DeadReport): boolean; /** The dead time in words, naming the steps and what to cut. */ declare function deadLine(r: DeadReport): string; /** * `setup`: the steps that run BEFORE the camera rolls. A sign-in form, a * cookie banner, the "choose your editor" modal, an onboarding tour: things * a take must get past and must not show. They run after the first * navigation and before `Page.startScreencast`, with no cursor synthesis, * no pace accounting and nothing written to `meta.steps`. Then the recorder * navigates to `url` again and the take begins where the setup left it. * * A `type` step's `text` may be `{ "env": "DEMO_PASSWORD" }`: resolved at run * time from the `env` the caller hands in (the shell's for the CLI, the * job's own map for a hosted take), never logged, never stored. The * guarantee is narrow and real: the secret is never in a file that travels * (`actions.json` is committed and pushed with the take; `meta.json` is read * by the digest) and never in the footage. * * `teardown`: the same steps, run AFTER the take, off camera too: what the * take created in the product (an API key, a project, an invite) removed * again, so a rehearsal or a re-record leaves the account as it found it. * They run once the screencast has stopped, on the take's own page and * context (a session's cookies apply), and also when the take stops early * or throws once its first step has run. A teardown that fails never fails * the take: the footage is fine, and what is left behind is reported. * * `if`: a guard, `{ "do": "if", "selector": "…" }`. When its selector is on * the page the steps after it run as usual; when it is not, they are skipped * and the list ends there, which is not a failure. A teardown that undoes * what the take may already have removed on camera starts its undoing with * one (`if` the new key's row is still listed), so a good take reports * nothing to undo instead of a failure; a setup that signs in guards its * sign-in the same way (`if` the email field shows), so a session that is * already signed in passes. A failure AFTER a guard is still a failure. */ type SetupText = string | { env: string; }; type SetupStep = ({ do: 'wait'; ms: number; } | { do: 'click'; selector: string; ms?: number; } | { do: 'type'; selector: string; text: SetupText; ms?: number; } | { do: 'press'; key: string; ms?: number; } | { do: 'goto'; url: string; } | { do: 'if'; selector: string; ms?: number; }) & { id?: string; }; /** How long an `if` looks for its selector, when it names no `ms`. */ declare const IF_LOOK_MS = 3000; /** Which list a step belongs to, as its messages and log lines name it. */ type StepPhase = 'setup' | 'teardown'; /** * Why a page address is not one the recorder opens, or null. A script's * `url` and a setup's `goto` open a browser, so only http and https are * taken: a `file:` address would read this machine's disk into a take * and a `javascript:` one would run in the page. */ declare function urlSchemeProblem(url: string): string | null; /** * Structural validation, mirrored on `validateActions` for `steps`. The * same verbs and rules hold for `teardown`; `phase` names the list. */ declare function validateSetup(value: unknown, phase?: StepPhase): string[]; /** The names a setup reads from its env, so a host can say what it must supply. */ declare function setupEnvNames(steps: SetupStep[] | undefined): string[]; /** * Every name a script reads from its env, its setup's and its teardown's, * each once: what a host must supply before the take begins. */ declare function scriptEnvNames(script: { setup?: SetupStep[]; teardown?: SetupStep[]; }): string[]; /** A `{ env }` text resolved, or thrown in words. The value is never returned to a log. */ declare function resolveSetupText(t: SetupText, env: Record, phase?: StepPhase): { value: string; secret: boolean; }; /** * The first `{ env }` a teardown reads that `env` does not hold, in words, * or null. Asked BEFORE the take: a take that creates something its * teardown cannot then remove is the one case teardown exists for. */ declare function teardownEnvProblem(steps: SetupStep[] | undefined, env: Record): string | null; interface SetupResult { ran: number; /** what the log may say about each step: the verb and the selector, never a typed value */ lines: string[]; /** * The step that failed: for a setup, a selector that never appeared (the * take does not start); for a teardown, the step it stopped at. `error` * is the driver's reason, one line, never a typed value. */ failed?: { step: number; do: string; selector?: string; error?: string; }; /** * An `if` whose selector was not on the page: the list ended there, and * `rest` steps after it were skipped. Not a failure. */ skipped?: { step: number; selector: string; rest: number; }; } /** How long a whole teardown may take before it is stopped and reported. */ declare const TEARDOWN_BOUND_MS = 60000; /** * What a teardown did, on the take's result: how many of its steps ran, * and where it stopped. Never a typed value. */ interface TeardownReport { ran: number; of: number; failed?: { step: number; do: string; selector?: string; error: string; }; /** An `if` whose selector was gone: nothing left to undo, never a failure. */ skipped?: { step: number; selector: string; rest: number; }; } /** The teardown in one line, for the end of a take or a rehearsal. */ declare function teardownLine(report: TeardownReport): string; /** * Run the setup (or the teardown) on a page, with plain Playwright actions: * no humanized pointer, no cursor events, no frames. A selector that never * appears fails the steps there, because a take that begins at a * half-finished sign-in is the wall by another name. With `boundMs`, the * steps together run no longer than that: the step running when it passes * fails, and the call it left pending is abandoned. */ declare function runSetup(page: RecorderPage, steps: SetupStep[], opts: { sleep: (ms: number) => Promise; /** Absent means no env at all: a `{ env }` text then fails in words. */ env?: Record; /** How a `goto` opens its page and waits for it (the take's ready mode); absent, network idle. */ goto?: (url: string) => Promise; /** Which list these are, for the log and the messages (default `setup`). */ phase?: StepPhase; /** The longest the steps may take together, in ms. */ boundMs?: number; now?: () => number; }): Promise; /** A `{ env }` the shell did not provide: a usage error, not a page's. */ declare class SetupEnvError extends Error { constructor(message: string); } /** A setup step whose selector never appeared: the take does not start. */ declare class SetupError extends Error { failed: NonNullable; constructor(failed: NonNullable); } /** `--header name=value`, repeatable: extra request headers on every request. */ declare function parseHeaders(given: string[] | undefined): Record; /** * The page's own console errors, as the recorder reports them. A page * under recording is someone else's, and its errors are context, never the * story: a third party's Content-Security-Policy violation runs to a few * kilobytes and repeats on every load, which buried the step lines. So the * log gets one line per distinct error, cut short, and a repeat is counted * instead of printed; the full text stays in the result (and a verbose * host prints every one whole). */ /** How much of an error a log line keeps. */ declare const PAGE_ERROR_LINE_CHARS = 160; interface PageError { /** the full text, whitespace as the page wrote it */ text: string; count: number; } /** One line of an error: whitespace collapsed, cut to the line's length. */ declare function pageErrorLine(text: string): string; declare class PageErrorLog { private readonly verbose; private readonly seen; constructor(verbose?: boolean); /** The line to log for this error now, or null when it repeats one already said. */ add(text: string): string | null; /** Every distinct error with how often it came, in the order first seen. */ entries(): PageError[]; /** The closing lines: each error that repeated, with its count. */ repeats(): string[]; } /** * What a signed-in take SHOWS. Getting past the login is half the problem; * the other half is that the account's own data is now in the frame: an * email address in the header, a key on a settings page, a card number. * Asking nicely does not hold this line (a person asked to sign in with a * demo account signs in as themselves, because it is the account they have), * so the recorder looks. * * Two pieces, both run IN the page: * * - the EXPOSURE scan reads the text that is visible in the viewport after * each step and reports the KIND of thing it saw and where. Never the * string itself: a report that quotes the secret is a second leak. * - a MASK hides a selector before the first frame is captured and keeps it * hidden across navigations and re-renders, so the real value is never in * a frame, never in the recording, never pushed. `as: 'text'` swaps the * words (a product reads better than a redaction); `as: 'blur'` blurs. * * The matchers are ONE plain-JavaScript source string, evaluated in the page * and, by the tests, in Node: a function serialized out of a bundle picks up * the bundler's `__name` helper and dies in the page, and two copies of a * regex drift. */ type ExposureKind = 'email' | 'key' | 'card' | 'card-tail'; type Exposure = NonNullable[number]; type MaskReport = NonNullable[number]; type Notice = NonNullable[number]; /** A notice as one scan reports it. */ type ScannedNotice = Omit; interface MaskRule { selector: string; /** `blur` (default) blurs the element; `text` swaps its words for `text`. */ as?: 'blur' | 'text'; text?: string; } /** * `kindsIn(text)` → the kinds of sensitive-looking strings in `text`. * * - email: any address, EXCEPT one on a domain that can reach no one * (example.com/.org/.net, and the reserved .test/.example/.invalid/ * .localhost TLDs), which is what demo data should use. * - key: the prefixes of keys people actually paste into dashboards, and a * JWT's three base64url parts. * - card: 13 to 19 digits that pass the Luhn check, so an order number or a * phone number is not a card. * - card-tail: a masked number's visible tail (•••• 4242). */ declare const EXPOSURE_MATCHERS_SRC = "(() => {\n const EMAIL = /[A-Za-z0-9._%+-]+@((?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,})/g\n const SAFE_HOST = /(^|\\.)example\\.(com|org|net)$|\\.(test|example|invalid|localhost)$/i\n const KEY = new RegExp([\n '\\\\b[srp]k_(?:live|test)_[A-Za-z0-9]{8,}',\n '\\\\bgh[pousr]_[A-Za-z0-9]{20,}',\n '\\\\bgithub_pat_[A-Za-z0-9_]{20,}',\n '\\\\bxox[abprs]-[A-Za-z0-9-]{10,}',\n '\\\\bAKIA[0-9A-Z]{16}\\\\b',\n '\\\\bAIza[0-9A-Za-z_-]{30,}',\n '\\\\bvos_(?:sk|rg|ho)_[A-Za-z0-9]{8,}',\n '\\\\beyJ[A-Za-z0-9_-]{8,}\\\\.eyJ[A-Za-z0-9_-]{8,}\\\\.[A-Za-z0-9_-]{8,}',\n ].join('|'))\n const CARD = /(?:^|[^0-9])((?:[0-9][ -]?){12,18}[0-9])(?![0-9])/g\n const TAIL = /[\\u2022\\u00b7*xX]{2,}[ -]?[0-9]{4}(?![0-9])/\n const luhn = (digits) => {\n let sum = 0, alt = false\n for (let i = digits.length - 1; i >= 0; i--) {\n let d = digits.charCodeAt(i) - 48\n if (alt) { d *= 2; if (d > 9) d -= 9 }\n sum += d; alt = !alt\n }\n return sum % 10 === 0\n }\n const kindsIn = (text) => {\n const kinds = []\n if (!text || text.length < 6) return kinds\n EMAIL.lastIndex = 0\n for (let m; (m = EMAIL.exec(text)); ) {\n if (!SAFE_HOST.test(m[1])) { kinds.push('email'); break }\n }\n if (KEY.test(text)) kinds.push('key')\n CARD.lastIndex = 0\n for (let m; (m = CARD.exec(text)); ) {\n const digits = m[1].replace(/[ -]/g, '')\n if (digits.length >= 13 && digits.length <= 19 && !/^0+$/.test(digits) && luhn(digits)) { kinds.push('card'); break }\n }\n if (TAIL.test(text)) kinds.push('card-tail')\n return kinds\n }\n return { kindsIn }\n})()"; /** * The INFORMATION the scan reports beside the exposures (never a failure): * the signed-in account's own display name, wherever the frame shows it, * and a list of the account's recent items. Runs inside EXPOSURE_PROBE, * after `seen` and before any selector is made: it sets `acct`, which * `quiet` then keeps out of every selector. Never `$` + `{` in here: it is * spliced into a template. * * The name is read conservatively, from where apps say whose account it * is: a line that greets or names the account ("Signed in as …", * "Welcome back, …"), the label of an account menu ("Account menu for …"), * or the words on the account menu's own trigger (the button that opens * a menu and holds the avatar), which are SURE; or a name-like label on an avatar (an image's alt, a * button holding the picture), which MAY be the name. */ declare const NOTICE_SRC: string; /** * The scan: visible text in the viewport, plus the values of text inputs. * Skips anything inside a masked element, password fields, and text the eye * cannot see. Reports kind + a selector-ish name for the element + its rect. */ declare const EXPOSURE_PROBE: string; /** * The mask, as an init script: it runs at document start on EVERY navigation, * so a masked value is hidden before the page's first paint, and a * MutationObserver re-applies it after a client-side re-render. A form * control is blurred even when `as: 'text'` was asked for: writing into an * input would change what the app submits. */ declare function maskInitScript(masks: MaskRule[]): string; /** * Accumulates scans across a take: an exposure is reported ONCE, at the * first step it was seen, with how many scans saw it. */ declare class ExposureLog { private byKey; private maskHits; constructor(masks?: MaskRule[]); add(step: number, scan: { exposures?: Omit[]; maskHits?: Record; } | null): void; exposures(): Exposure[]; masks(rules: MaskRule[]): MaskReport[]; } /** One exposure, in words. `step` -1 is the page as it opened. */ declare function exposureLine(e: Exposure): string; declare const EXPOSURE_ADVICE = "The recording shows these. Record from a demo account, or hide them before the camera rolls with \"mask\" in actions.json: { \"selector\": \"\u2026\", \"as\": \"text\", \"text\": \"demo@acme.test\" } swaps the words, \"as\": \"blur\" blurs. Then re-record."; /** * Accumulates the notices across a take: the account's name is ONE notice, * its places gathered from every scan; a recent-items list is one notice * per list. Each keeps the first step it was seen at. */ declare class NoticeLog { private byKey; add(step: number, notices: ScannedNotice[] | undefined | null): void; notices(): Notice[]; } /** * One notice, in words. The account's name is never printed: the line says * where it showed, so each place can be masked. */ declare function noticeLine(n: Notice): string; /** * What to do about the notices, in one line: the swap hint is about the * account's name, so it is said only when the name was noticed. */ declare function noticeAdvice(notices: readonly Pick[]): string; /** * When a page counts as ready for the take to begin. The default is the * DOM: after `load`, the page must make no DOM change for a beat (counted * from outside, the way an `await` reload's settle is), at most a few * seconds. Network idle is the opt-in: plenty of real apps hold a socket * open or keep an analytics beacon going and never go network-idle, so a * take that waited for it started after its whole timeout, every time. */ /** How a page counts as ready: its DOM settled (default), or its network went idle. */ type ReadyMode = 'networkidle' | 'dom'; declare const READY_MODES: readonly ReadyMode[]; declare const DEFAULT_READY: ReadyMode; /** The longest a navigation waits for `load` or network idle. */ declare const NAV_TIMEOUT_MS = 45000; /** The longest the settle waits on a page that never stops changing. */ declare const READY_SETTLE_CAP_MS = 8000; /** After network idle, the beat a hydration takes (what the recorder always gave it). */ declare const NETWORKIDLE_HYDRATION_MS = 800; /** How the first load settled: the done event's `ready`. */ interface ReadyReport { mode: ReadyMode; /** ms from the navigation's start until the page counted as ready */ ms: number; /** * The wait gave up instead of the page settling: the DOM never stopped * changing within the cap (dom), or network idle never came within * the navigation timeout (networkidle). Recorded anyway either way. */ capped: boolean; } /** Why a ready mode is not one, or null. */ declare function readyProblem(v: unknown): string | null; interface ReadyOpts { sleep: (ms: number) => Promise; now?: () => number; /** the settle's cap (default `READY_SETTLE_CAP_MS`) */ capMs?: number; /** the navigation's own timeout (default `NAV_TIMEOUT_MS`) */ timeoutMs?: number; } /** * Wait for a page that is navigating (or has just navigated) to be ready: * `navigate` starts the navigation with the `waitUntil` the mode asks for; * in `dom` mode the DOM settle follows `load`. A navigation that times * out is not fatal: the take goes on from whatever the page shows, and the * report says it was capped. */ declare function untilReady(page: RecorderPage, mode: ReadyMode, navigate: (opts: { waitUntil: 'networkidle' | 'load'; timeout: number; }) => Promise, opts: ReadyOpts): Promise<{ response: RecorderResponse | null; ready: ReadyReport; }>; /** * An `await`'s reload between polls, under the take's ready mode: the * reload waits for `load` (dom) or network idle (networkidle), at most * the await's own timeout, and then the DOM settles either way, because * network quiet is not a drawn page (a list rendered from its data lands * after it). A page that never goes network-idle no longer costs a whole * navigation timeout per poll. */ declare function reloadUntilReady(page: RecorderPage, mode: ReadyMode, timeoutMs: number, opts?: { sleep?: (ms: number) => Promise; }): Promise; /** The ready report in words, for the take's log. */ declare function readyLine(r: ReadyReport): string; /** * The canvas gestures, the pure parts: key chords and sequences, the * modifiers a drag holds, a drawn path and its timing, a click's count and * button, and the overrun report. What a whiteboard, a design tool or a * timeline is recorded with, said as data so a script can carry it and * both hosts validate it in the same words. * * None of it reaches the cursor track as key identity: a key is a typing * ping (when and where), a modifier is nothing at all, and a path is its * points. */ /** The modifiers a chord or a drag may hold. `Mod` is Meta on macOS, Control elsewhere. */ declare const MODIFIERS: readonly ["Shift", "Control", "Alt", "Meta", "Mod", "ControlOrMeta"]; type Modifier = (typeof MODIFIERS)[number]; /** The modifiers a drag names (the platform-neutral one is `Mod`). */ declare const DRAG_MODIFIERS: readonly ["Alt", "Shift", "Meta", "Control", "Mod"]; type DragModifier = (typeof DRAG_MODIFIERS)[number]; /** A key name the browser's keyboard answers: a character, a code, a named key. */ declare function isKeyName(k: string): boolean; /** * A chord split into its modifiers and its key: `Shift+D` is * `{ mods: ['Shift'], key: 'D' }`, a bare `r` has no modifiers, and `+` * names the plus key when it ends the chord (`Shift++`). */ declare function splitChord(chord: string): { mods: string[]; key: string; }; /** Why a chord is not one the recorder can press, or null. */ declare function chordProblem(chord: unknown): string | null; /** * A chord as the browser's keyboard takes it: `Mod` becomes * `ControlOrMeta`, which the browser resolves to Meta on macOS and to * Control elsewhere, where the browser runs. */ declare function resolveChord(chord: string): string; /** A `press` step's keys as a list: one chord or a sequence. */ declare function pressSequence(step: { key?: string; keys?: string | string[]; }): string[]; /** The pause between two keys of a sequence, a person's hand: ms. */ declare const KEY_SEQUENCE_GAP_MS = 150; /** * What one key costs beyond the script's gaps: the browser's round trip for * the press (a keydown and a keyup the page answers). Part of the plan, so a * sequence on an idle page is never "slower than scripted". */ declare const KEY_ROUNDTRIP_MS = 50; /** A key sequence's plan, ms: its gaps, and each key's round trip. */ declare const keySequencePlanMs: (keys: number) => number; /** The hold after a drag's release, ms: the recorder's, part of the gesture. */ declare const DRAG_HOLD_MS = 400; /** The most keys one press step may name. */ declare const MAX_KEYS = 50; /** A drag modifier as the keyboard holds it. */ declare function resolveModifier(m: DragModifier): string; /** * The modifier bits of a raw pointer event (the pen path): Alt 1, Control * 2, Meta 4, Shift 8, with `Mod` read for the platform the browser runs on. */ declare function modifierBits(mods: readonly DragModifier[], platform: 'mac' | 'linux' | 'windows' | undefined): number; /** A click's button, and the pointer button number the cursor track records. */ declare const CLICK_BUTTONS: readonly ["left", "right", "middle"]; type ClickButton = (typeof CLICK_BUTTONS)[number]; declare const buttonNumber: (b: ClickButton | undefined) => 0 | 1 | 2; /** * The pause between the presses of a double or triple click, well inside * every platform's double-click interval (500 ms on macOS and Windows by * default), so the page reads one gesture. */ declare const MULTI_CLICK_GAP_MS = 90; /** * One point of a drawn path: viewport CSS px, with an optional time in ms * (from the path's start) and an optional pressure in [0, 1]. Written as a * tuple `[x, y]`, `[x, y, t]`, `[x, y, t, pressure]`, or an object. */ type PathPoint = [number, number] | [number, number, number] | [number, number, number, number] | { x: number; y: number; t?: number; pressure?: number; }; /** A path point as the recorder replays it. */ interface PathSample { x: number; y: number; /** ms from the path's first point */ at: number; pressure?: number; } /** The most points one path may hold. */ declare const MAX_PATH_POINTS = 20000; /** An untimed path's travel when the step names no ms. */ declare const PATH_DEFAULT_MS = 700; /** * A path's points read and checked, or the problems in words. The same * reader takes an inline `path` and the contents of a path file (an array * of points, or `{ "points": [...] }`). */ declare function readPath(raw: unknown): { points: PathSample[]; timed: boolean; } | { problems: string[]; }; /** * The path's schedule: a timed path keeps its own times (from its first * point), an untimed one spreads its points evenly over `ms` (default * 700). The last point is at the path's whole duration. */ declare function schedulePath(path: { points: PathSample[]; timed: boolean; }, ms: number | undefined): PathSample[]; /** How long a scheduled path takes, ms. */ declare const pathDurationMs: (s: readonly PathSample[]) => number; /** * A paced gesture that ran past its script: the wall time it took against * the time the script planned for it (a drag's travel, a path's timing, * typing's characters × delay, a key sequence's gaps). Reported when the * gesture took more than a fifth longer, the sign of a page that could not * keep up with what it was sent. */ interface StepOverrun { step: number; id?: string; do: string; plannedMs: number; tookMs: number; overrunMs: number; } /** The share past the plan that counts as an overrun. */ declare const OVERRUN_SHARE = 0.2; /** A plan shorter than this is not measured: its noise is the round trip. */ declare const OVERRUN_MIN_PLANNED_MS = 100; /** * The least a gesture must run over to count, ms: below it the difference * is one slow sample or round trip on a busy machine, never a page that * fell behind, however short the gesture. */ declare const OVERRUN_MIN_MS = 100; /** The overrun, ms, or null when the gesture kept to its plan. */ declare function overrunOf(plannedMs: number, tookMs: number): number | null; /** The overruns in one line for the log and the done event, or null when none. */ declare function overrunLine(overruns: readonly StepOverrun[]): string | null; /** * What an `expect` and an `await` wait for: a condition on the page, read * without touching it (no cursor, no input), polled until it holds or the * time runs out. `expect` polls on camera for a few seconds; `await` polls * off camera for as long as a slow result takes. One reader for both, so * "appeared" means the same thing in either. */ interface WaitCondition { /** an element matching this selector is visible */ selector?: string; /** some visible text on the page contains this */ text?: string; /** no element matching this selector is visible */ gone?: string; /** with `selector`: the element is enabled (true) or disabled (false) */ enabled?: boolean; /** * A JavaScript expression evaluated in the page (awaited when it answers * a promise): the condition holds when its value is truthy, or, with * `equals`, when its value equals that one. For an app that keeps its * state in script rather than in the DOM (a canvas, a document model). */ js?: string; /** with `js`: the value the expression must equal (compared as JSON) */ equals?: unknown; } /** What the condition found the last time it looked: what a miss is said from. */ interface ConditionState { holds: boolean; /** with `selector`: whether a match was visible */ visible?: boolean; /** * with `js`: what the expression answered the last time it was read, as * JSON when it has a JSON form (absent for `undefined`), and in words * either way (`said`), or the error it threw (`threw`). */ value?: unknown; said?: string; threw?: string; } /** * The visible text of the page contains `text`: `innerText` is what the * page renders, so a hidden element's words never count. */ declare function visibleTextScript(text: string): string; /** The longest a js value is said in a line, in characters. */ declare const JS_SAID_MAX = 120; /** The most a js value kept on the step holds, in characters of JSON. */ declare const JS_VALUE_MAX = 2048; /** * The page script that evaluates a step's expression and answers what it * found, as a string (the one evaluate shape every driver shares). The * expression is the script author's own, run on their own page: it is * wrapped, never parsed, and a newline closes it before the paren so a * trailing line comment cannot swallow the wrapper. */ declare function jsConditionScript(expr: string): string; /** Two JSON values alike: the same keys and values whatever the key order. */ declare function sameJson(a: unknown, b: unknown): boolean; /** * A js value as a step keeps it (`meta.steps[].value`): the value itself * while its JSON fits, else its JSON cut short as a string. */ declare function keptValue(value: unknown): unknown; /** Read the condition once. A page mid-navigation reads as "not yet". */ declare function readCondition(page: RecorderPage, c: WaitCondition): Promise; /** What a poll found: whether the condition held, after how long, and the last read. */ interface PollResult { ok: boolean; ms: number; last: ConditionState; } /** * Poll the condition every `everyMs` until it holds or `timeoutMs` pass. * `between` runs before each look but the first (an `await`'s reload). * With `confirm`, a hold counts only once it has held on that many reads * in a row, `confirm.gapMs` apart: a page that renders after network quiet * reads half-built for a moment, and a `gone` condition holds on a list * that has not been drawn yet. The clock is the wall's: a rehearsal waits * as long as a take would, because how long a result takes is what a * rehearsal is for. */ declare function pollCondition(page: RecorderPage, c: WaitCondition, opts: { timeoutMs: number; everyMs: number; sleep: (ms: number) => Promise; now?: () => number; between?: () => Promise; confirm?: { reads: number; gapMs: number; }; }): Promise; /** The DOM counts as settled after this long with no change. */ declare const DOM_QUIET_MS = 800; /** The longest a settle waits on a page that never stops changing. */ declare const DOM_SETTLE_CAP_MS = 5000; /** * The page's own count of DOM changes: an observer installed once per * document, read back as a number. A string, the one evaluate shape every * driver shares. */ declare const DOM_CHANGE_PROBE = "(() => {\n if (!window.__vosDomChanges) {\n window.__vosDomChanges = { n: 0 };\n new MutationObserver((list) => { window.__vosDomChanges.n += list.length })\n .observe(document, { subtree: true, childList: true, attributes: true, characterData: true });\n }\n return window.__vosDomChanges.n;\n})()"; /** * Wait until the DOM has not changed for `quietMs`, at most `capMs`: what * a page does after its network went quiet (a list rendered from data, a * hydration). The count is polled from here rather than timed in the * page, because a background tab throttles its own timers. */ declare function domSettled(page: RecorderPage, opts: { sleep: (ms: number) => Promise; now?: () => number; quietMs?: number; capMs?: number; tickMs?: number; }): Promise<{ settled: boolean; ms: number; }>; /** Seconds as the recorder says them: `5 s`, `2.5 s`, `3 min 20 s`. */ declare function sayDuration(ms: number): string; /** What the condition waits for, in words: `'#result' to appear`. */ declare function sayCondition(c: WaitCondition): string; /** Why the condition did not hold, in words: `'Generate' stayed disabled for 5 s`. */ declare function conditionMiss(c: WaitCondition, last: ConditionState, ms: number): string; /** An expression as a line names it: in backticks, cut short. */ declare function sayJs(expr: string): string; /** A kept value as a line says it: its JSON, cut short. */ declare function sayValue(value: unknown): string; /** * `peers`: other people on the same page, off camera. A collaboration * product shows best with a second person on the canvas: their cursor, the * shape they drew, the comment they left, arriving in the filmed page the * way the app syncs them. A peer is a second browser context (its own * cookies, so its own user, from its own storage state or none) on the * same URL, driven by its own step list, interleaved with the take's. * * What a peer is, and is not: * * - NOT FILMED. Only the take's own page is captured. A peer's page is * never screencast, scanned, masked or listened to; what it does reaches * the footage only through the app (its sync, its presence, its remote * cursors), which is what a viewer would see. * - NOT ON THE CURSOR TRACK. A peer's pointer moves its own page; the take's * CursorTrack is synthesized from the take's own steps alone, so a zoom, * a click ring or a dwell is never planned on a peer's gesture. * - ORDERED BY THE TAKE'S STEPS. A peer step may name a take step by id: * `with` starts it as that step starts (the two run together), `after` as * that step ends. A step naming neither follows the peer's previous step * at once; a peer's first step with neither starts as the camera rolls. * The take never waits on a peer: it waits on what the peer's work * SHOWS, with an `expect` or an `await` on its own page, so the footage * holds exactly the moment the sync landed. When the take's steps end, * a peer step still waiting on a trigger never runs (said), and one * already running finishes, bounded, before the trailing hold. * - PACED, NOT INSTANT. A peer's pointer glides on the same clock as the * take's (an app that draws remote cursors shows it travelling) and its * typing is paced per key, so what it does reads as a person. * - BOUNDED. Every peer step runs inside its own bound, as a take step * does; a selector that never appears or a check that never holds is a * skip with its reason, listed with the take's (`--strict` fails on it). * * A peer takes the take's gestures and checks (`wait`, `move`, `hover`, * `click`, `type`, `press`, `scroll`, `drag` with an inline `path`, and * `expect`), never a `paste`, a `download`, an `await` (a peer that must * wait for a result is the take's `await`), a guard, a `read`, a `caption` * or `settle`, which all belong to the filmed page. */ /** One other person on the page: their own context, their own steps. */ interface Peer { /** How the peer is named in lines and in `meta.peers`: a short word. */ id: string; /** The page the peer opens; absent, the take's own `url`. */ url?: string; /** The peer's viewport in CSS px; absent, the take's. */ viewport?: { width: number; height: number; }; /** * A Playwright storage state the peer's context is made from: the second * person's own sign-in. The host resolves the name (the CLI: a path from * the actions file's directory) and never sends the file anywhere. * Absent, the peer is signed out. */ storageState?: string; steps: PeerStep[]; } /** A peer's step: one of the take's gestures or checks, and when it starts. */ type PeerStep = ActionStep & { /** * Start as the take's step with this id starts: the two run together. * (`with`, never `at`: a `type` step's `at` is where its caret goes.) */ with?: string; /** Start as the take's step with this id ends. */ after?: string; }; /** The verbs a peer takes: the gestures and the on-page check. */ declare const PEER_VERBS: readonly ["wait", "move", "hover", "click", "type", "press", "scroll", "drag", "expect"]; /** The most peers a take may have: each is a whole browser context. */ declare const MAX_PEERS = 4; /** The most steps one peer may take. */ declare const MAX_PEER_STEPS = 200; /** * Structural validation of `peers`, given the take's own steps (a trigger * names one of their ids). `validate` is the take's step validator, run on * each peer's list so a peer step is checked in exactly the take's words. */ declare function validatePeers(value: unknown, takeSteps: unknown, validate: (steps: unknown[]) => string[]): string[]; /** What a hosted recorder says of a script with peers, or null. */ declare function peersHostedRefusal(peers: unknown): string | null; /** * The take's step boundaries, as promises a peer step waits on. The take * calls `begin` as the camera rolls, `start`/`end` around each step and * `close` once its steps are over; a trigger still pending then resolves * false and its step never runs. */ declare class StepSignals { private readonly started; private readonly ended; private readonly began; private closed; constructor(ids: Iterable); begin(): void; start(id: string | undefined): void; end(id: string | undefined): void; close(): void; get isClosed(): boolean; /** When a step with this trigger may start: true, or false for never. */ when(trigger: { with?: string; after?: string; }): { ready: Promise; already: boolean; }; } /** The most a peer step's kept value holds, in characters of JSON (as a take step's). */ declare const PEER_VALUE_MAX = 2048; /** * What a peer's check last answered, kept on its step the way the take's * own steps keep theirs (`meta.steps[].value`): the value itself while its * JSON fits, else that JSON cut short as a string; absent when the read * answered nothing JSON can hold, or no value at all (a check that only * holds or not). */ declare function peerValue(last: ConditionState): unknown; /** What a peer did: its steps as they ran, and the ones that never did. */ interface PeerRun { id: string; steps: PeerStepSpan[]; /** Steps whose trigger never fired before the take's steps were over. */ notRun: number[]; } /** * Drive one peer's steps on its page, each when its trigger fires. Never * throws for a page's reasons: a miss is a skip on the run. */ declare function runPeer(peer: Peer, rawPage: RecorderPage, signals: StepSignals, opts: { clock: RecorderClock; /** The take's footage clock, ms: what a span is placed by. */ footageMs: () => number; log: (msg: string) => void; /** A rehearsal: no travel, every pause cut short. */ dry?: boolean; }): Promise; /** * The action script — the declarative recipe an agent (or human) writes to * drive a take. Small on purpose: selectors + a handful of verbs. The recorder * executes it with humanized cursor motion and synthesizes the CursorTrack * from its own dispatches. */ interface ActionsFile { /** Page to record. `--url` overrides. */ url?: string; /** * A DESKTOP app to record in place of a page: its name or bundle id. * `--app` overrides. The script's selectors are then in the desktop * dialect (`button[name='Save']`, `textfield[id='title']`) and the page's * fields have no meaning (`desktopProblems`). */ app?: string; /** * Recording viewport in CSS px (default 1280x720). For a desktop app, the * size its window is given before the take, in points; absent, the window * is recorded at the size it has. */ viewport?: { width: number; height: number; }; /** * A DESKTOP script's answer to a step that missed (an element that never * appeared, an expect that never held, a control that was disabled): * `stop` ends the take there, `continue` goes on to the next step. * Default `stop`: the keys of the steps after a miss would land wherever * focus happens to be, and an app is not a page that can be thrown away. */ onSkip?: 'stop' | 'continue'; /** * Hidden BEFORE the first frame is captured and kept hidden across * navigations: what a signed-in account shows that must not ship. `blur` * (default) blurs the element; `text` swaps its words for `text`, which is * for IDENTIFIERS (an email, a name, an account id), never for product * copy or numbers: the video must stay true to the product. */ mask?: MaskRule[]; /** * Run BEFORE the camera rolls, after the first navigation: a sign-in form, * a cookie banner, an onboarding tour. Plain actions with no cursor, no * frames, no pace and nothing in `meta.steps`; then the recorder opens * `url` again and the take begins where the setup left it. A `type` * step's text may be `{ env: 'NAME' }`, read at run time and never logged * or stored. */ setup?: SetupStep[]; /** * Run AFTER the take, off camera, with the same verbs as `setup`: what * the take created in the product (an API key, a project, an invite) * removed again. They run once the screencast has stopped, on the take's * own page, after a rehearsal too, and when the take stops early or * throws after its first step. A failing teardown never fails the take; * it stops at the step that failed and is reported. */ teardown?: SetupStep[]; /** * When the first page counts as ready for step 1: `dom` (default), * once its DOM has made no change for a beat after `load`, at most 8 s; * `networkidle`, once the network has gone quiet, at most 45 s, which a * page holding a socket open never does. `--ready` overrides. */ ready?: ReadyMode; /** * Every gesture waits on the app after it (`settle` on a step overrides): * a canvas that falls behind under load finishes the last stroke before * the next one starts. */ settle?: boolean; steps: ActionStep[]; /** * Other people on the page, OFF CAMERA: each a browser context of its * own (its own storage state, so its own user) on the same `url`, driven * by its own steps, each started `with` a take step or `after` one (by * id). Only the take's page is filmed, and only its own steps make the * cursor track; a peer's work reaches the footage through the app's own * sync. A hosted take refuses peers. */ peers?: Peer[]; } type ActionStep = ({ do: 'wait'; ms: number; } /** * Rest the pointer on `selector`'s centre, or on the viewport point * (`x`, `y`) when no selector names the spot (a place on a canvas). */ | { do: 'hover'; selector?: string; x?: number; y?: number; ms?: number; } /** * Press `selector`'s centre, or the viewport point (`x`, `y`). `ms` is * the settle after the press (default 150). `count` 2 or 3 is a real * double or triple click; `button` presses the right or middle one; * `modifiers` are held for the press (a Shift-click) and released after. */ | { do: 'click'; selector?: string; x?: number; y?: number; ms?: number; count?: 1 | 2 | 3; button?: ClickButton; modifiers?: DragModifier[]; } /** * Type into `selector`. The recorder clicks the field first, which is what * opens the typing zoom on it; `focus: false` types into the field as it is * already focused, for a keystroke that follows earlier typing (a submitting * Enter) rather than starting it — a second click there rings a click effect * on empty space beside the text. */ | { do: 'type'; /** * The field. A page's type always names one. A desktop script's may * leave it out with `focus: false`, to type where the keyboard is. */ selector?: string; text: string; delayMs?: number; focus?: boolean; /** * Select the field's value before typing, so what is typed REPLACES * it (a form that opens filled in, a search box with the last query). */ replace?: boolean; /** * Where the caret goes after the focusing click, before the first * character: `end` or `start` of the field (a code editor line is * typed at its end; a click lands the caret where the pointer hit). */ at?: 'end' | 'start'; /** the settle after the last character (default 150) */ ms?: number; } /** * A key, a chord or a sequence, each recorded as a typing ping where the * pointer is (or on `selector` when given, with no click), never as the * key itself. `key` names one control key (Escape closes what a click * opened, Enter submits what was typed); `keys` names a chord * (`"Shift+D"`, `"Mod+Z"`, with `Mod` Meta on macOS and Control * elsewhere), a plain key (`"r"`, a tool's shortcut) or a sequence * (`["v", "Escape"]`). Words are typed with `type`. */ | { do: 'press'; key?: PressKey; keys?: string | string[]; selector?: string; ms?: number; } /** `ms` is the settle after the scroll lands (default 200). */ | { do: 'scroll'; dy: number; ms?: number; } | { do: 'move'; x: number; y: number; } /** * Press-move-release — real edits (drag an element on the stage canvas, * slide a range input, move a timeline clip). Start = the selector's center * when given, else (x, y); end = (tx, ty); eased over ms (default 700). * `path` draws instead: viewport points (inline, or a file beside the * actions file), the press at the first and the release at the last, * replayed by the points' own times or evenly over ms. `modifiers` are * held for the whole drag. */ | { do: 'drag'; selector?: string; x?: number; y?: number; tx?: number; ty?: number; path?: PathPoint[] | string; modifiers?: DragModifier[]; ms?: number; } /** * Put words or a file (an image, an SVG) on the clipboard and paste it * the way a person's ⌘V does, into `selector` (clicked first) or where * the focus is. A file is read beside the actions file, by a plain name. */ | { do: 'paste'; selector?: string; text?: string; file?: string; ms?: number; } /** * Check that the page is as the flow expects, with no cursor move: an * element visible (`selector`; with `enabled`, enabled or disabled), some * visible text containing `text`, `gone` no longer visible, or `js`, an * expression evaluated in the page that holds when its value is truthy * (with `equals`, when its value equals that one): the state a canvas * app keeps in script, never in the DOM. Exactly one of the four. Waits * up to `timeout` seconds (default 5); a condition that never holds is a * skip with its reason, which names the value a `js` last answered. */ | { do: 'expect'; selector?: string; text?: string; gone?: string; enabled?: boolean; js?: string; equals?: unknown; timeout?: number; } /** * Wait OFF CAMERA for something slow (a render, a generated result, a * deploy): the capture stops, the predicate is polled every `poll` * seconds (default 2) for up to `timeout` (default 600), reloading the * page between polls when `reload` is set, and the capture resumes when * it holds. The footage has no gap and no frozen stretch; the cut lands * in `meta.skips[]`. On timeout, `onTimeout: "fail"` (the default) stops * the take and `"continue"` resumes it. */ | { do: 'await'; until: AwaitUntil; timeout?: number; poll?: number; reload?: boolean; onTimeout?: 'fail' | 'continue'; } /** * Keep a file the page makes: click `selector` and wait for the * browser's download, or fetch the `currentSrc` of the video, audio or * img element `src` names, with the page's own cookies. Saved under the * take's `outputs/` as `as`, else the name the page suggested, and listed * in `meta.outputs[]`. */ | { do: 'download'; selector?: string; src?: string; as?: string; }) & { /** * `"spend"`: the step costs something real (credits, a purchase, a * message sent). Only a click, a press or a type carries it, and it * needs an `id`. A rehearsal hovers it and never presses it; a recording * presses it only when the command names it (`--confirm `) and * refuses before capturing anything otherwise. */ guard?: StepGuard; /** * Optional stable identity: anchors in doc.json name a step by this * id (else by index), so a step can move or gain neighbours across script * edits without breaking the cut anchored to it. Unique when present. */ id?: string; /** * A beat's caption, two to eight words: `vos deliver` lands it as a * lower-third at this step's moment on the cuts that take words, and * `vos actions script` leads the beat with it. */ caption?: string; /** * The cut's camera on this step: `true` marks the step as its beat's * payoff, the moment worth the zoom (`vos plan --zooms per-beat` keeps * the proposal on it, and only it); `false` means never zoom here (the * planner's proposal on it is rejected). The planner still decides the * level and the focus; a mark never invents a zoom. On a gesture only * (ZOOM_MARK_VERBS). */ zoom?: boolean; /** * `true` on the ONE step that is the film's payoff: the reveal, the * result, the moment the music should open up on. `vos music pick` and * `vos score` land the bed's swell where this step plays. Without it the * payoff is the last step marked `zoom: true`, which is the right guess * when the last zoom is the reveal and the wrong one when the reveal * plays wide. */ payoff?: boolean; /** * A selector whose words the recorder keeps once the step has settled * (`meta.steps[].text`: trimmed, whitespace collapsed, at most 2 KB), so * a layer quotes the take instead of a replay: the URL a share button * minted, the code a dialog printed, the status a request answered. On * a click it reads after the click's settle, so what the click opened is * what is read. Only what the flow names, never a secret it did not. */ read?: string; /** * After the gesture, wait until the page has made no DOM change and * painted no new frame for a beat (at most a few seconds): an app that * falls behind catches up before the next step. The script's top-level * `settle` is the default. */ settle?: boolean; }; /** What an `await` waits for: exactly one of the four (`equals` rides with `js`). */ interface AwaitUntil { selector?: string; text?: string; gone?: string; js?: string; equals?: unknown; } /** The guards a step may carry: one today, a step that spends. */ declare const STEP_GUARDS: readonly ["spend"]; type StepGuard = (typeof STEP_GUARDS)[number]; /** The verbs a `zoom` mark may sit on: the gestures a camera can be about. */ declare const ZOOM_MARK_VERBS: readonly string[]; /** How long an `expect` waits by default, in seconds. */ declare const EXPECT_TIMEOUT_S = 5; /** An `await`'s defaults, in seconds. */ declare const AWAIT_TIMEOUT_S = 600; declare const AWAIT_POLL_S = 2; /** How long a `download` click waits for the browser's download, in seconds. */ declare const DOWNLOAD_TIMEOUT_S = 30; /** The keys a `press` step may name: navigation and control, never a character. */ declare const PRESS_KEYS: readonly ["Escape", "Enter", "Tab", "Backspace", "Delete", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown", "Space"]; type PressKey = (typeof PRESS_KEYS)[number]; /** * Structural validation with actionable messages. Returns [] when valid. * `desktop` says the script is a desktop app's when it does not name one * itself (`vos record --app` with a script that has no `app`). */ declare function validateActions(value: unknown, opts?: { desktop?: boolean; }): string[]; /** * Why a name is not one a download may be saved under, or null. A plain * file name only: the file lands in the take's `outputs/` and nowhere * else, so no separator, no `..`, nothing hidden, nothing empty. */ declare function fileNameProblem(name: string): string | null; /** A guarded step of a script: where it is, what it is, the id that confirms it. */ interface GuardedStep { step: number; id: string; do: string; guard: StepGuard; } /** The guarded steps of a script, in order. */ declare function guardedSteps(actions: Pick): GuardedStep[]; /** * Whether a recording may run with the confirmations it was given: every * guarded step named by `--confirm`, and every name a guarded step. A * refusal is one sentence naming the steps and the flag, said before * anything is captured. */ declare function guardVerdict(actions: Pick & Pick, 'app'>, confirm: readonly string[]): { ok: true; } | { ok: false; unconfirmed: string[]; unknown: string[]; message: string; }; /** * What a hosted recorder cannot do with a script, in words, or []: a * guarded step has nobody to confirm it on a fleet, a download has no * take directory to land in there, and a `js` check is code a stranger's * script would run in the fleet's browser. */ declare function hostedRefusals(actions: Pick): string[]; /** * The files a script names beside itself, in order: a drag's path file * and a paste's file. A host reads them before anything is captured. */ declare function scriptFiles(actions: Pick): { step: number; name: string; as: 'path' | 'paste'; }[]; /** * The wall check: did the recorder land where it was asked, or in front of * a sign-in? A take of a product behind a login, recorded without a session, * used to succeed: the footage was the login page (or wherever the site * sends a stranger), and the only symptom was a skipped selector. This says * it in words, before a frame is captured and before a re-record clears the * footage it would have replaced. * * Pure: the recorder gathers the evidence, this decides. A heuristic is * acceptable because both failure directions are cheap: a false refusal * costs one flag (`--allow-wall`), a false pass costs what every such take * cost before. */ /** What the recorder saw once the first navigation settled. */ interface Arrival { askedUrl: string; landedUrl: string; /** HTTP status of the main document, when the navigation produced one. */ status?: number; /** `input[type=password]` fields that are visible on the page. */ passwordFields: number; /** A password field marked `autocomplete="new-password"` (a settings or sign-up form). */ newPasswordField: boolean; /** A visible one-time-code field (`autocomplete="one-time-code"`). */ oneTimeCodeField: boolean; } type WallKind = /** the asked URL answered 401 or 403 */ 'status' /** landed on an identity provider's host */ | 'idp' /** landed on a sign-in form or a sign-in path */ | 'signin' /** sent somewhere else, with no sign-in in sight (a site that shows strangers a public page) */ | 'redirect'; interface WallVerdict { kind: WallKind; /** * `hard` is refused always; `soft` is refused under `--strict` and said as * a warning otherwise, because a redirect alone is not proof of a wall. */ level: 'hard' | 'soft'; /** origin + path, never the query or hash (they can carry tokens). */ asked: string; landed: string; message: string; } declare function isIdpHost(host: string): boolean; declare function isSignInPath(pathname: string): boolean; /** * Sent AWAY, as opposed to sent deeper. `/` → `/en`, `/docs` → `/docs/start` * and `/pricing` → `/en/pricing` are a site arranging itself; `/dashboard` → * `/gallery` is a site declining to show the page. `www.` and the apex are * one host. */ declare function redirectedAway(asked: URL, landed: URL): boolean; declare function wallVerdict(a: Arrival): WallVerdict | null; /** A take refused at the wall. Carries the verdict for `--json`. */ declare class WallError extends Error { verdict: WallVerdict; constructor(verdict: WallVerdict); } /** * Evidence gathered in the page. A STRING, never a function: a serialized * function picks up the bundler's `__name` helper and dies in the page. */ declare const WALL_PROBE = "(() => {\n const shown = (el) => {\n const r = el.getBoundingClientRect()\n if (r.width < 2 || r.height < 2) return false\n const s = getComputedStyle(el)\n return s.visibility !== 'hidden' && s.display !== 'none'\n }\n const pw = [...document.querySelectorAll('input[type=\"password\"]')].filter(shown)\n const otp = [...document.querySelectorAll('input[autocomplete=\"one-time-code\"]')].filter(shown)\n return {\n passwordFields: pw.length,\n newPasswordField: pw.some((el) => (el.getAttribute('autocomplete') || '').includes('new-password')),\n oneTimeCodeField: otp.length > 0,\n }\n})()"; /** * The recorder — a browser drives the action script while: * - CDP Page.startScreencast collects JPEG frames (epoch-timestamped; * hold-last-frame gaps are filled at encode time), and * - every dispatched input is logged as a CursorEvent (the synthesized track: * exact coords, exact times, fresh element rects — no capture needed). * * The MECHANISM, host-free (AN4): the browser arrives as a structural driver * (a launched Node Playwright browser from the CLI, a connected * @cloudflare/playwright browser from the fleet), frames leave through a * sink, the platform and the setup env are handed in, and nothing here * touches a filesystem or a process. The CLI's `recordTake` wraps this with * a take directory; the fleet's consumer wraps it with R2. Both produce the * same events, meta and frame index for the same script. */ /** How often a long `await` says it is still waiting, in ms. */ declare const AWAIT_HEARTBEAT_MS = 30000; /** An `await` that held sooner than this cut nothing: no skip, no segment split. */ declare const MIN_SKIP_MS = 250; /** * The headers a request carries, or null to leave it alone: a job's * headers (a preview's bypass token) go to the ORIGIN the take is of and * nowhere else, since the recorded page embeds whatever third parties it * likes and a redirect can land anywhere. */ declare function headersFor(requestUrl: string, entryUrl: string, headers: Record): Record | null; /** A page URL as a take keeps it: origin and path, never a query or a hash. */ declare function publicUrl(u: string): string; interface FrameRec { file: string; /** ms since t0 */ tMs: number; } interface SkippedStep { /** index into actions.steps */ step: number; id?: string; do: string; selector: string; /** why, when it is not a selector that never appeared: an expect that never held, a download that never came */ reason?: string; /** A PEER's step (`peers[].id`): `step` is then an index into that peer's steps. */ peer?: string; } /** A click whose target was disabled when it was pressed: the press happened, and likely did nothing. */ interface DisabledClick { step: number; id?: string; selector: string; } /** An `await` that timed out with `onTimeout: "fail"`: the take stopped there. */ interface StoppedTake { step: number; id?: string; reason: string; } /** Thrown before anything is captured: a guarded step the command did not confirm, a download with nowhere to land. */ declare class RecordRefusedError extends Error { constructor(message: string); } /** A stretch with no screencast frames — the page pixels did not change. */ interface FreezeSpan { /** seconds into the take */ from: number; to: number; ms: number; } interface RecordResult { events: CursorEvent[]; frames: FrameRec[]; meta: RecordingMeta; /** The take's pace: what the script asked, what the gestures added, what the page cost. */ pace: PaceReport; /** steps whose selector never became visible — the take continued without them. */ skipped: SkippedStep[]; /** `ready: "networkidle"` was asked for and the first load never reached it (recording proceeded anyway). */ navTimeout: boolean; /** How the first load settled before step 1. */ ready: ReadyReport; /** A wall the caller let through; null when the recorder landed where it was asked. */ wall: WallVerdict | null; /** Sensitive-looking text seen in the frame (kind + place, never the string). */ exposures: NonNullable; /** * INFORMATION, never a failure and never in `exposures`: the signed-in * account's own name and its recent-items lists (also `meta.notices`). */ notices: NonNullable; /** The script's masks with how many elements each reached; hits 0 hid nothing. */ masks: NonNullable; /** * Smoothness telemetry: stretches ≥400ms with no visual change. Frozen * footage is the #1 enemy of a smooth product video — either the flow should * keep motion in frame (animate, hover a preview, scroll) or the doc should * trim/speed through these. freezePct = share of the take that is frozen. */ freezes: FreezeSpan[]; freezePct: number; /** * The smoothness WARNING: still footage under a parked cursor past the * beat it takes to read what changed, per step (`deadTime`). A still page * being read is content; this is the part of a hold nobody is reading. */ dead: DeadReport; /** The take reached --max-duration and stopped there; later steps did not run. */ capped: boolean; /** Clicks pressed on a disabled target (reported; `--strict` fails on them). */ disabled: DisabledClick[]; /** The ids of the guarded steps this take pressed, because the command named them. */ confirmed: string[]; /** The cuts `await` steps made (also `meta.skips`). */ skips: RecordingSkip[]; /** The files `download` steps kept (also `meta.outputs`). */ outputs: RecordingOutput[]; /** The sound the page played, each heard stretch in footage seconds (also `meta.media`). */ media: NonNullable; /** An `await` timed out and the take stopped there; null when it ran to the end. */ stopped: StoppedTake | null; /** The page's own console errors, each distinct one with its full text and how often it came. */ pageErrors: PageError[]; /** * Paced gestures that ran more than a fifth past their script (a drag's * travel, a path's timing, typing, a key sequence): the page could not * keep up with what it was sent. Also on `meta.steps[].overrunMs`. */ overruns: StepOverrun[]; /** The actions as recorded, `url` resolved: what a take directory writes back. */ actions: ActionsFile; /** What each peer did, off camera (also `meta.peers`); [] with none. */ peers: PeerRun[]; /** * What the script's `teardown` did after the take, off camera; null when * it has none. A failure here is reported and never fails the take. */ teardown: TeardownReport | null; } interface RecordOpts { /** Stop the capture at this many seconds (the hosted cap). */ maxDurationSeconds?: number; /** * Path to a Playwright storage state (cookies + origin storage), so the * recorder drives a SIGNED-IN product. A demo of anything behind a login * needs it, and a sign-in form cannot always be scripted (an emailed code, * an SSO hop). Export one from a real browser, or with * `context.storageState({ path })`. */ storageState?: string; /** * REHEARSE the flow: every step runs against the real page, in order, * because a later selector usually exists only after an earlier click. But * nothing is captured (no screencast, no frames), nothing is written, the * pointer lands instead of travelling and every pause is cut to a beat, so * a script that misses a selector says so in seconds instead of after a * full real-time take and its encode. Selector lookups keep their whole * timeout, so a miss here is a miss in the take. */ dryRun?: boolean; /** * Called once the first navigation has settled, BEFORE a frame is captured. * The caller judges the wall here and only then prepares the take * directory, so a take refused at a sign-in never clears the footage a * re-record would have replaced. A throw closes the context and propagates. */ onArrival?: (arrival: Arrival) => Promise | WallVerdict | null | void; /** Extra request headers on every request (`--header name=value`). */ headers?: Record; /** * A ready-made context to record IN, instead of one made from `browser`: * `--session `, a persistent profile the person signed in to. The * recorder still sizes the viewport and closes it at the end. */ context?: RecorderContext; /** * The environment a setup's and a teardown's `{ env }` texts resolve * from: the shell's for the CLI, the job's own map on the fleet. Absent * means no env at all, so a setup that reads one fails in words, and a * teardown that reads one refuses the take before it begins. */ env?: Record; /** The platform the take is recorded on, for `meta.platform`. */ platform?: RecordingMeta['platform']; /** * The ids of the guarded steps this recording may press (`--confirm`). * A guarded step not named here refuses the take before anything is * captured; a rehearsal hovers every guarded step and presses none. */ confirm?: readonly string[]; /** * Where a `download` step's file goes. A host that hands in none cannot * keep a download: such a script is refused before anything is captured. * A rehearsal fetches the file and keeps nothing. */ outputs?: OutputSink; /** * Where the sound the page played is kept, fetched with the page's own * cookies at the end of the take. A host that hands in none still * records `meta.media`, with no file; a rehearsal fetches nothing. */ sounds?: SoundSink; /** * The files the script names beside itself (a drag's path file, a * paste's file). A host that hands in none cannot run such a step: the * script is refused before anything is captured. */ files?: ScriptFiles; /** Print every page error whole, each time it comes; by default one cut line per distinct error. */ verbose?: boolean; /** * Structured progress for a host that reports it (the CLI's `--json`): * an `await`'s start, a heartbeat while it waits, and its end. */ onEvent?: (event: Record) => void; /** * A step the page stopped answering in (it ran into its bound) stops the * take there, as an `await` that timed out does (`--strict`). Without * it the step is a skip and the take goes on. */ stopOnHang?: boolean; /** How often a long `await` reports it is still waiting (default 30 s). */ awaitHeartbeatMs?: number; /** * Where a peer's `storageState` is read from: the CLI resolves the name * from the actions file's directory to a path the browser opens, and * throws in words when there is none. A host that hands in none cannot * sign a peer in, and such a script is refused before anything is * captured. */ peerStorageState?: (name: string) => Promise | string; /** * In a rehearsal only: stop after the step with this `id` and hand the * page, as that step left it, to `at` (`vos look --until`). The steps * after it never run; the teardown still does, since the walk clicked * for real. Ignored by a take. */ until?: { id: string; at: (page: RecorderPage) => Promise; }; } /** * The expression a scroll tick evaluates: move the first scrollable * ancestor of the element under the cursor by `dy`, else the window, the * container a wheel at that point would have moved. A string, so no host * helper (`__name`) has to exist in the page. */ declare function scrollByScript(x: number, y: number, dy: number): string; /** Minimal JPEG SOF parse for real encoded dimensions. */ declare function jpegDims(buf: Uint8Array): { w: number; h: number; } | null; /** Base64 to bytes without Node's Buffer, so the fleet's isolate runs it too. */ declare function base64Bytes(data: string): Uint8Array; declare function recordTake(browser: RecorderBrowser, url: string, actions: ActionsFile, sink: FrameSink, log: (msg: string) => void, opts?: RecordOpts): Promise; /** Why a step ended at its bound, with the real time it took. */ declare function hangReason(verb: string, ms: number, boundMs: number): string; declare function extForType(type: string | undefined): string; /** A download's type from its name's extension, as `{ contentType }`, or `{}` when the extension says nothing. */ declare function typeOfName(name: string): { contentType?: string; }; /** * The recording cap as the recorder applies it, pure. WHAT the cap is * (the hosted plan's number, read from `GET /api/limits`) is a vos.so fact * and stays in the CLI's platform client; the recorder only knows a number * of seconds and stops there. */ /** True once the take has reached the cap — the recorder stops driving steps. */ declare function capReached(elapsedMs: number, capSeconds: number): boolean; /** A wait step never sleeps past the cap. */ declare function clampWait(waitMs: number, elapsedMs: number, capSeconds: number): number; /** `30 min`, `1 h 30 min`, `45 s` — the duration cap in words. */ declare function formatDurationCap(seconds: number): string; /** The one line printed when the cap stopped the take. */ declare function cappedLine(capSeconds: number): string; /** * Frames → CFR WebM, as a PAGE. The VFR screencast JPEGs are drawn * hold-last-frame onto a canvas at a fixed 30fps and encoded with * mediabunny (WebCodecs) inside a headless page — no ffmpeg dependency. * The CLI serves the take directory to it and reads the bytes back through * its own `/save`; the fleet serves the frames through the ingest route and * the page PUTs the recording to the same route. One page, two hosts: the * URLs and the way out are the host's, the encode is not. */ interface EncodePageOptions { /** Where `frames.json` (the index `[{file, tMs}]`) is fetched from. */ framesIndexUrl: string; /** Where `meta.json` is fetched from. */ metaUrl: string; /** `` is each JPEG. */ framesBaseUrl: string; /** The way out: a POST to the CLI's take server, or a PUT to the ingest route. */ save: { method: 'POST' | 'PUT'; url: string; }; /** Optional `?rt=`-style query the frame fetches must carry (the fleet's token). */ frameQuery?: string; /** Where mediabunny loads from (a host's mirror); esm.sh by default. */ mediabunnyUrl?: string; } declare function buildEncodePage(o: EncodePageOptions): string; interface FreshPlanOptions { /** The backdrop the document opens on; absent keeps the bare frame. */ backdrop?: Backdrop | null; /** A digest's activity bins, when one exists (the speed planner's witness). */ activity?: readonly number[] | null; } declare function planFreshTake(artifact: RecordingArtifact, recordingName: string, opts?: FreshPlanOptions): ProjectDoc; /** * The export a FRESH document opens on, sized to what the footage holds: * the ingest's default resolution, or the largest the recording supports * without upscaling when that is less (a 1280×720 take exports 720p, not a * 1080p that `vos validate` then warns upscales). Never raised. In place, * and returned. */ declare function withFittingExport(doc: ProjectDoc): ProjectDoc; /** * The sound the page played (`meta.media`) as the document's audio: one * clip per heard stretch, keyed to the fetched file, placed at the OUTPUT * time of the footage moment it was heard (through the segments, the speed * spans and the freezes), stamped `source: 'page'`. A re-plan replaces only * those clips, so a clip someone added stays. An auto speed span over a * heard stretch is dropped first, or the footage would race ahead of what * the page was saying. A stretch with no fetched file (a hosted take, a * fetch that failed) places nothing. In place, and returned. */ declare function withPageSound(doc: ProjectDoc, media: readonly RecordingPageMedia[] | undefined): ProjectDoc; /** * The footage's segments split at every cut an `await` made * (`meta.skips[].at`, source seconds), so each cut is a real segment * boundary: the timeline shows it, a transition can sit on it, a trim can * take either side. A cut at an edge or outside a segment splits nothing, * and a segment of another media is left alone. A split segment keeps its * arrival on its first piece and its leaving on its last. */ declare function splitSegmentsAtSkips(segments: ProjectDoc['segments'], skips: readonly { at: number; }[] | undefined): ProjectDoc['segments']; /** The most a download keeps: a file the page made, never a disk's worth. */ declare const OUTPUT_MAX_BYTES: number; /** * A name the page suggested, made plain: its last path segment, control * characters and leading dots removed, or `fallback` when nothing usable * is left. A page chooses this name, so it is cleaned, never trusted. */ declare function plainName(suggested: string, fallback: string): string; /** The file name a URL's path ends in, decoded, or ''. */ declare function nameFromUrl(url: string): string; /** * The name a download is saved under: the step's `as` when it gave one, * else the page's suggestion made plain, made unique among the names this * take already used (`clip.mp4`, `clip-2.mp4`). */ declare function outputName(asked: string | undefined, suggested: string, fallback: string, used: ReadonlySet): string; /** Read a stream of byte chunks whole, refusing past `max` bytes. */ declare function readAllBytes(stream: AsyncIterable, max?: number): Promise; /** * Read a media element's source, run in the page on the element the * step's selector matched through the locator engine: its `currentSrc` * (what it is actually playing), else its `src`, else the attribute; '' * while it has none yet. Self-contained, since it is serialized into the * page. */ declare const readMediaSource: (el: RecorderMediaElement) => string; /** * The expression that fetches a URL inside the page, for what the page * alone can read (a `blob:` or a `data:` source): base64 and the type, or * an error in words. Same-origin requests carry the page's cookies. */ declare function fetchInPageScript(url: string): string; /** * The take's clock: ONE path from a wall-clock instant to footage time, * for the cursor events and for every screencast frame alike. * * Footage time is wall time since `t0` minus every off-camera stretch (an * `await`) that began before the instant; an instant inside a stretch reads * as the stretch's start, which is where the cut is. A frame is placed by * the instant it was CAPTURED, never by when its callback ran: a frame in * flight when the capture paused lands after the resume and must still sit * before the cut. * * Frame times are strictly increasing. The screencast does not promise it: * a frame can arrive after a later one, and a frame without a capture * timestamp is stamped by its arrival, a second clock. A frame whose time * is not later than the last one kept holds older pixels than what the * footage already shows, so it is DROPPED (never re-stamped forward, which * would put a stale picture after a newer one). */ declare class TakeClock { readonly t0: number; private readonly pauses; private lastFrameMs; constructor(t0: number); /** Footage ms at a wall-clock instant (`Date.now()` space). */ footageMs(wallMs: number): number; /** The camera stops at this instant; returns the cut's footage ms. */ pause(wallMs: number): number; /** The camera rolls again; returns the wall ms the stretch lasted. */ resume(wallMs: number): number; /** * The parts of a wall-clock stretch the camera saw: each sub-stretch * outside every off-camera wait, as its wall start (`wallMs`), its * footage start (`atMs`) and its length. A stretch an `await` cut in two * comes back as two; one wholly off camera as none. */ onCamera(fromWall: number, toWall: number): { wallMs: number; atMs: number; ms: number; }[]; /** * A captured frame's footage ms, or null when it is not later than the * last frame kept (the frame is dropped; see the module comment). */ placeFrame(captureWallMs: number): number | null; } interface SurfaceSize { width: number; height: number; } interface SurfaceFit { before: SurfaceSize; after: SurfaceSize; } /** * Make the surface the viewport. Returns what it measured, or null when * nothing could be measured; never throws, because a take made as before * is better than no take. */ declare function fitSurfaceToViewport(cdp: RecorderCdp, width: number, height: number): Promise; /** * The sound a page plays during a take. The recorder captures frames, and * a product's sound (a voice preview, a video playing in the page) would * be lost with nothing to say it was there. Most of it is a media element, * so the recorder watches every `