/** * Where a publish's QR code goes: the terminal when someone is looking at it, a file when nobody * is. * * This module exists because the two are one decision, not two. `qr-terminal.ts` refuses a * non-TTY for a good reason — escape sequences in a captured stream are noise — but refusing to * DRAW is not the same as having nothing to offer, and for this CLI the captured stream is the * common case. The pro lane is driven by an agent, so stdout is a pipe on almost every real * publish, and the creator who would scan the code never sees the terminal at all. Gating the * feature on `isTTY` alone turned it off exactly where the URL is most worth handing over. * * So: draw it if it can be drawn, and write `.bitmagic/publish-qr.png` whenever it cannot. That * covers the pipe, and also the two smaller cases with the same shape — `TERM=dumb`, and a * terminal too narrow to hold the code unwrapped — where a person is present but still has nothing * to scan. A terminal that draws successfully writes no file: it already did the job. * * `.bitmagic/` is excluded from the publish fingerprint (`EXCLUDED_DIRS` in * `@bitmagic/asset-core/publish-source`), so writing here cannot invalidate the verify the gate * just checked. */ import { type TerminalQrEnv } from './qr-terminal.js'; /** Where a publish leaves its QR image. One per project, overwritten each publish. */ export declare function publishQrPath(root: string): string; /** * Where `bitmagic dev --mobile` leaves its QR image. * * A separate file from the publish one because the two URLs are different promises — the published * game outlives the session, the LAN address dies with it — and a creator who scanned the wrong one * would get a game that either is not there or is not the one they are editing. `dev` is ALSO the * command most likely to need the file rather than the drawing: an agent starts it as a background * task, so its stdout is a pipe on nearly every real run. */ export declare function devQrPath(root: string): string; export interface EmitQrOptions { /** The project root. The image lands in its `.bitmagic/`. */ root: string; /** `--json`: stdout carries exactly one document, so nothing is ever drawn. */ json: boolean; /** `--no-qr`. Suppresses the drawing AND the file — it means "not this time", not "not here". */ disabled: boolean; env?: TerminalQrEnv; isTTY?: boolean; columns?: number | undefined; write?: (chunk: string) => void; /** Seam for the test; production writes to disk. */ writeFile?: (file: string, bytes: Buffer) => void; /** Where the image goes when one is written. Defaults to `publishQrPath(root)`. */ file?: string; } /** * Show `url` as a QR code however this run can, and return the image path when one was written. * * Never throws and never reports failure as an error: the caller has already printed the URL, and * a code that could not be produced costs the creator a retype, not a publish. */ export declare function emitQr(url: string, options: EmitQrOptions): string | null;