| 1 | import { desktopHost } from "./desktopHost"; |
| 2 | |
| 3 | // Prove both the renderer and the host bridge are alive. The native recovery |
| 4 | // coordinator requires a post-reload report within ten seconds. |
| 5 | export function installDesktopWebViewHeartbeat(): void { |
| 6 | const reportReady = () => { |
| 7 | const bindings = desktopHost().app; |
| 8 | const report = bindings?.ReportDesktopWebViewReady; |
| 9 | if (typeof report === "function") void Promise.resolve(report.call(bindings)).catch(() => undefined); |
| 10 | }; |
| 11 | requestAnimationFrame(reportReady); |
| 12 | window.setInterval(reportReady, 3_000); |
| 13 | window.addEventListener("pageshow", reportReady); |
| 14 | document.addEventListener("visibilitychange", () => { |
| 15 | if (document.visibilityState === "visible") reportReady(); |
| 16 | }); |
| 17 | } |
| 18 |