()
| 8836 | return url.toString(); |
| 8837 | } |
| 8838 | function sendJSON(msg) { |
| 8839 | if ((ws == null ? void 0 : ws.readyState) === WebSocket.OPEN) ws.send(JSON.stringify(msg)); |
| 8840 | } |
| 8841 | function connect() { |
| 8842 | setStatus("connecting"); |
| 8843 | ws = new WebSocket(getWsUrl()); |
| 8844 | ws.addEventListener("open", () => { |
| 8845 | connected = true; |
| 8846 | reconnectDelay = RECONNECT_BASE_MS; |
| 8847 | setStatus("connected"); |
| 8848 | hideOverlay(loadingOverlay); |
| 8849 | hideOverlay(reconnectOverlay); |
| 8850 | fitAddon.fit(); |
| 8851 | sendJSON({ type: "resize", cols: term.cols, rows: term.rows }); |
| 8852 | startPing(); |
| 8853 | }); |
| 8854 | ws.addEventListener("message", ({ data }) => { |
| 8855 | if (data.startsWith("{")) { |
| 8856 | try { |
| 8857 | handleControlMessage(JSON.parse(data)); |
| 8858 | return; |
| 8859 | } catch { |
| 8860 | } |
| 8861 | } |
| 8862 | term.write(data); |
| 8863 | }); |
| 8864 | ws.addEventListener("close", onDisconnect); |
| 8865 | ws.addEventListener("error", () => { |
| 8866 | }); |
| 8867 | } |
no test coverage detected