(channelPath: string = LIVE_CHANNEL_PATH)
| 24 | * instead of throwing. |
| 25 | */ |
| 26 | export function liveReloadClientScript(channelPath: string = LIVE_CHANNEL_PATH): string { |
| 27 | const ch = JSON.stringify(channelPath); |
| 28 | return ( |
| 29 | `<script>(function(){try{` + |
| 30 | `var es=new EventSource(${ch});` + |
| 31 | `es.addEventListener('reload',function(){location.reload();});` + |
| 32 | `es.onerror=function(){/* EventSource auto-reconnects via the server's retry hint */};` + |
| 33 | `}catch(e){/* no EventSource → static page, no live reload */}})();</script>` |
| 34 | ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Inject the live-reload client into a built preview page. Insert just before `</body>` |
no outgoing calls
no test coverage detected