* Extracts content from the first complete frame in Ink's output. * Ink with non-TTY stdout outputs multiple frames, each wrapped in DEC synchronized * update sequences ([?2026h ... [?2026l). We only want the first frame's content.
(output: string)
| 60 | * update sequences ([?2026h ... [?2026l). We only want the first frame's content. |
| 61 | */ |
| 62 | function extractFirstFrame(output: string): string { |
| 63 | const startIndex = output.indexOf(SYNC_START); |
| 64 | if (startIndex === -1) return output; |
| 65 | const contentStart = startIndex + SYNC_START.length; |
| 66 | const endIndex = output.indexOf(SYNC_END, contentStart); |
| 67 | if (endIndex === -1) return output; |
| 68 | return output.slice(contentStart, endIndex); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Renders a React node to a string with ANSI escape codes (for terminal output). |
no outgoing calls
no test coverage detected