| 875 | |
| 876 | /** The steps that fire nothing, side by side — a screen's handlers are siblings, not a hierarchy. */ |
| 877 | const flat = (list: string[]): { pos: Map<string, { x: number; line: number }>; lines: number; width: number } => { |
| 878 | const pos = new Map<string, { x: number; line: number }>(); |
| 879 | let line = 0; |
| 880 | let width = 0; |
| 881 | let lx = 0; |
| 882 | for (const id of list) { |
| 883 | const bw = widthOf(id); |
| 884 | if (lx > 0 && lx + bw > lineMax) { |
| 885 | line += 1; |
| 886 | lx = 0; |
| 887 | } |
| 888 | pos.set(id, { x: lx, line }); |
| 889 | width = Math.max(width, lx + bw); |
| 890 | lx += bw + NODE_GAP; |
| 891 | } |
| 892 | return { pos, lines: list.length === 0 ? 0 : line + 1, width }; |
| 893 | }; |
| 894 | |
| 895 | // The region's blocks, in the walk's order: everything that fires |
| 896 | // nothing first, as one spread, then a cluster per step that does. |