UNPKG

overmind-devtools-client

Version:
87 lines (80 loc) 2.83 kB
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Overmind DevTools</title> <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Nunito:400,700" rel="stylesheet" /> <script> // Port configuration injected by webpack template window.__OVERMIND_DEVTOOLS_BACKEND_PORT__ = '<%= PORT %>' const vscode = window.vscode || (window.acquireVsCodeApi && window.acquireVsCodeApi()) const isVSCodeExtension = typeof window !== 'undefined' && (window.vscode !== undefined || typeof window.acquireVsCodeApi === 'function') const isElectron = isVSCodeExtension ? false : typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer' && !!window.process.versions?.electron function onPortSubmit(newPort) { if (isVSCodeExtension) { try { vscode.postMessage({ command: 'newPort', text: newPort }) } catch (err) { console.error('Failed to send message to VSCode:', err) } } else if (isElectron) { try { const { ipcRenderer } = window.require('electron') ipcRenderer.send('newPort', newPort) } catch (err) { window.location.href = `${window.location.origin}${window.location.pathname}?port=${newPort}` } } else { window.location.href = `${window.location.origin}${window.location.pathname}?port=${newPort}` } } function onRestart() { if (isVSCodeExtension) { try { vscode.postMessage({ command: 'restart' }) } catch (err) { console.error('Failed to send restart message to VSCode:', err) } } else if (isElectron) { try { const { ipcRenderer } = window.require('electron') ipcRenderer.send('restart') } catch (err) { console.error('Failed to send restart message in Electron:', err) } } } function handleFormSubmit(event) { event.preventDefault() var input = document.querySelector('#port-input') var port = input.value input.setAttribute('disabled', true) if (isNaN(port) || port < 1 || port > 65535) { alert('Please enter a valid port number (1-65535)') input.removeAttribute('disabled') return } onPortSubmit(port) } </script> </head> <body></body> </html>