(input: {
term: Term | undefined
addon: SerializeAddon | undefined
cursor: number
id: string
onCleanup?: (pty: Partial<LocalPTY> & { id: string }) => void
})
| 128 | } |
| 129 | |
| 130 | const persistTerminal = (input: { |
| 131 | term: Term | undefined |
| 132 | addon: SerializeAddon | undefined |
| 133 | cursor: number |
| 134 | id: string |
| 135 | onCleanup?: (pty: Partial<LocalPTY> & { id: string }) => void |
| 136 | }) => { |
| 137 | if (!input.addon || !input.onCleanup || !input.term) return |
| 138 | const buffer = (() => { |
| 139 | try { |
| 140 | return input.addon.serialize() |
| 141 | } catch { |
| 142 | debugTerminal("failed to serialize terminal buffer") |
| 143 | return "" |
| 144 | } |
| 145 | })() |
| 146 | |
| 147 | input.onCleanup({ |
| 148 | id: input.id, |
| 149 | buffer, |
| 150 | cursor: input.cursor, |
| 151 | rows: input.term.rows, |
| 152 | cols: input.term.cols, |
| 153 | scrollY: input.term.getViewportY(), |
| 154 | }) |
| 155 | } |
| 156 | |
| 157 | export const Terminal = (props: TerminalProps) => { |
| 158 | const platform = usePlatform() |
no test coverage detected