(args: {
altScreen: boolean
terminalWidth: number
terminalHeight: number
renderPath: string
prev: Frame
next: Frame
diff: Diff
optimized: Diff
bytesWritten: number
})
| 173 | } |
| 174 | |
| 175 | capture(args: { |
| 176 | altScreen: boolean |
| 177 | terminalWidth: number |
| 178 | terminalHeight: number |
| 179 | renderPath: string |
| 180 | prev: Frame |
| 181 | next: Frame |
| 182 | diff: Diff |
| 183 | optimized: Diff |
| 184 | bytesWritten: number |
| 185 | }): void { |
| 186 | const isFull = this.fullCaptureRemaining > 0 |
| 187 | |
| 188 | const entry: CheapFrameTrace = { |
| 189 | frameId: this.frameId++, |
| 190 | timestamp: performance.now(), |
| 191 | terminalWidth: args.terminalWidth, |
| 192 | terminalHeight: args.terminalHeight, |
| 193 | altScreen: args.altScreen, |
| 194 | renderPath: args.renderPath, |
| 195 | prev: snapshotFrame(args.prev), |
| 196 | next: snapshotFrame(args.next), |
| 197 | diffPatchCounts: countPatchTypes(args.diff), |
| 198 | optimizedPatchCounts: countPatchTypes(args.optimized), |
| 199 | bytesWritten: args.bytesWritten, |
| 200 | } |
| 201 | |
| 202 | if (isFull) { |
| 203 | const full = entry as FullFrameTrace |
| 204 | full.prevRowHashes = [] |
| 205 | full.nextRowHashes = [] |
| 206 | for (let y = 0; y < args.prev.screen.height; y++) { |
| 207 | full.prevRowHashes.push(hashRow(args.prev.screen, y)) |
| 208 | } |
| 209 | for (let y = 0; y < args.next.screen.height; y++) { |
| 210 | full.nextRowHashes.push(hashRow(args.next.screen, y)) |
| 211 | } |
| 212 | |
| 213 | full.prevRows = rowsToStrings(args.prev.screen) |
| 214 | full.nextRows = rowsToStrings(args.next.screen) |
| 215 | full.ansiBytesHash = createHash('sha256') |
| 216 | .update(serializeOptimizedToAnsiForTesting(args.optimized)) |
| 217 | .digest('hex') |
| 218 | .slice(0, 16) |
| 219 | |
| 220 | this.fullCaptureRemaining-- |
| 221 | |
| 222 | if (this.fullCaptureRemaining === 0) { |
| 223 | // Full window closed silently; next /render-trace will dump it. |
| 224 | this.fullCaptureArmedAt = 0 |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | this.buffer[this.writeHead] = entry |
| 229 | this.writeHead = (this.writeHead + 1) % RING_SIZE |
| 230 | if (this.writeHead === 0) this.hasWrapped = true |
| 231 | } |
| 232 |
nothing calls this directly
no test coverage detected