()
| 196 | |
| 197 | // animate response to make it looks smooth |
| 198 | function animateResponseText() { |
| 199 | if (finished || controller.signal.aborted) { |
| 200 | responseText += remainText; |
| 201 | console.log("[Response Animation] finished"); |
| 202 | if (responseText?.length === 0) { |
| 203 | options.onError?.(new Error("empty response from server")); |
| 204 | } |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | if (remainText.length > 0) { |
| 209 | const fetchCount = Math.max(1, Math.round(remainText.length / 60)); |
| 210 | const fetchText = remainText.slice(0, fetchCount); |
| 211 | responseText += fetchText; |
| 212 | remainText = remainText.slice(fetchCount); |
| 213 | options.onUpdate?.(responseText, fetchText); |
| 214 | } |
| 215 | |
| 216 | requestAnimationFrame(animateResponseText); |
| 217 | } |
| 218 | |
| 219 | // start animaion |
| 220 | animateResponseText(); |
no outgoing calls
no test coverage detected