// `rnx get-layout` — bounding boxes for visible meaningful elements on the // current screen. focused on the layout numbers a designer checks: on-screen // box (x/y/w/h). pass --styling for computed borderRadius, per-side padding, // fontSize, visual style fields, and native rendered text contrast. pass // --filter to narrow to the elements whose text/testID/role/selector // match — fewer rows, full detail on each, which is how you read one area's // styling without the whole screen. // // the extraction + formatting live in the shared `./core` kernel // (inspectGetLayout / formatLayoutElements) so this CLI command and the agent's // app_get_layout tool produce identical output. the CLI-side job is just: // optional preflight for in-flight screen transitions, call the kernel, print. import { formatLayoutElements, inspectGetLayout } from './core' import { maybeWaitForStartedScreenTransitions, printJson, wantsJson } from './shared' import type { WsBridge } from '../../ws-bridge' export async function runGetLayoutSubcommand(opts: { bridge: WsBridge args: string[] }): Promise { const { bridge, args } = opts const jsonOut = wantsJson(args) await maybeWaitForStartedScreenTransitions(bridge, { verbose: !jsonOut }) const styling = args.includes('--styling') const filterIndex = args.indexOf('--filter') const filter = filterIndex >= 0 ? args[filterIndex + 1] : undefined const elements = await inspectGetLayout(bridge, { styling, filter }).catch( (error: unknown) => { if ( styling && error instanceof Error && (error.message === 'unsupported RNX Cloud command type: evaluate' || error.message.includes('requires the debug scope')) ) { throw new Error( 'get layout --styling is unavailable on a remote simulator; rerun without --styling or use a local sim', ) } throw error }, ) if (jsonOut) { printJson({ count: elements.length, elements }) return } console.log( ` layout (${elements.length} element${elements.length === 1 ? '' : 's'}):\n`, ) // styling fields (including native rendered text contrast) are opt-in via // --styling so the default inspect output stays scannable. console.log(formatLayoutElements(elements, { styling })) }