/** * Drawing a QR code into the terminal, so the URL `bitmagic publish` just printed can be scanned * off the screen instead of retyped into a phone. The Creator has had this since it shipped — the * publish dialog ends on a QR — and the CLI's publish is the same moment: `--visibility private` * puts a real, phone-reachable URL on a game nobody else can find, which is exactly a "try it on * my phone" build. * * The contract is `inline-image.ts`'s, deliberately: the code is strictly ADDITIONAL. The caller * prints the URL first, unconditionally; this either draws underneath it or does nothing at all. It * never replaces a line and it never reports failure as an error, because an agent tool is usually * what reads this output. * * That last clause is also why nothing should call this module directly. Refusing to DRAW into a * pipe is right; having nothing to offer when there is one is not, and since an agent drives most * publishes, the pipe is the common case rather than the edge. `qr-output.ts` owns that decision — * it asks this module first and falls back to a PNG file — and `bitmagic publish` goes through it. * * Where it DIVERGES from that file is the gate. `supportsInlineImage` is an allowlist of terminals * known to implement the iTerm2 protocol, because the ones that do not print a screenful of raw * base64. Nothing here is exotic: half-block characters and SGR colour are universal, and tmux * passes both through rather than swallowing them. So the gate below asks what the terminal can do * — is it a terminal at all, is it wide enough — and never who it is. */ export interface TerminalQrEnv { TERM?: string | undefined; BITMAGIC_NO_QR?: string | undefined; } /** * Whether this terminal can show a scannable code at all. * * Not an allowlist — see the file header. `TERM=dumb` is the one terminal that answers no on its * own behalf, and a non-TTY means something is reading this rather than looking at it — which is a * reason not to paint escape sequences, NOT a reason to withhold the code. `qr-output.ts` writes an * image for every case this function turns down. */ export declare function supportsTerminalQr(env: TerminalQrEnv, isTTY: boolean): boolean; /** How many columns the drawn code occupies, quiet zone included. */ export declare function terminalQrWidth(matrix: boolean[][]): number; /** * The code as terminal lines, quiet zone included and each line self-contained. * * Exported so a test can read the output without a TTY. The padded symbol has an odd number of * module rows — the module count is always odd and the quiet zone adds an even number — so the * final terminal row pairs its top half against a light row that is not in the symbol. That is * correct rather than a rounding artefact: it reads as one more row of quiet zone. */ export declare function terminalQrLines(matrix: boolean[][]): string[]; export interface RenderTerminalQrOptions { env?: TerminalQrEnv; isTTY?: boolean; /** Terminal width. Undefined means unknown, which is treated as wide enough. */ columns?: number | undefined; write?: (chunk: string) => void; caption?: string; } /** * Draw `text` as a QR code if this terminal can show one. Returns whether anything was drawn, so a * caller can decide what else to say — never throws, and never writes when unsupported. * * The caption and the code go out in a single write, so the creator never sees an invitation to * scan with nothing under it. */ export declare function renderTerminalQr(text: string, options?: RenderTerminalQrOptions): boolean;