Compare commits
No commits in common. "main" and "ssh-install" have entirely different histories.
main
...
ssh-instal
25
README.md
25
README.md
|
|
@ -4,28 +4,11 @@ Toes is a personal web server you run in your home.
|
|||
|
||||
Plug it in, turn it on, and forget about the cloud.
|
||||
|
||||
## setup
|
||||
## quickstart
|
||||
|
||||
Toes runs on a Raspberry Pi. You'll need:
|
||||
|
||||
- A Raspberry Pi running Raspberry Pi OS
|
||||
- A `toes` user with passwordless sudo
|
||||
|
||||
SSH into your Pi as the `toes` user and run:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://toes.dev/install | bash
|
||||
```
|
||||
|
||||
This will:
|
||||
|
||||
1. Install system dependencies (git, fish shell, networking tools)
|
||||
2. Install Bun and grant it network binding capabilities
|
||||
3. Clone and build the toes server
|
||||
4. Set up bundled apps (clock, code, cron, env, stats, versions)
|
||||
5. Install and enable a systemd service for auto-start
|
||||
|
||||
Once complete, visit `http://<hostname>.local` on your local network.
|
||||
1. Plug in and turn on your Toes computer.
|
||||
2. Tell Toes about your WiFi by <using dark @probablycorey magick>.
|
||||
3. Visit https://toes.local to get started!
|
||||
|
||||
## features
|
||||
- Hosts bun/hono/hype webapps - both SSR and SPA.
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "toes-install",
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.9.3",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@types/bun": ["@types/bun@1.3.9", "https://npm.nose.space/@types/bun/-/bun-1.3.9.tgz", { "dependencies": { "bun-types": "1.3.9" } }, "sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw=="],
|
||||
|
||||
"@types/node": ["@types/node@25.3.2", "https://npm.nose.space/@types/node/-/node-25.3.2.tgz", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-RpV6r/ij22zRRdyBPcxDeKAzH43phWVKEjL2iksqo1Vz3CuBUrgmPpPhALKiRfU7OMCmeeO9vECBMsV0hMTG8Q=="],
|
||||
|
||||
"bun-types": ["bun-types@1.3.9", "https://npm.nose.space/bun-types/-/bun-types-1.3.9.tgz", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="],
|
||||
|
||||
"typescript": ["typescript@5.9.3", "https://npm.nose.space/typescript/-/typescript-5.9.3.tgz", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"undici-types": ["undici-types@7.18.2", "https://npm.nose.space/undici-types/-/undici-types-7.18.2.tgz", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ set -euo pipefail
|
|||
|
||||
##
|
||||
# toes installer
|
||||
# Usage: curl -sSL https://toes.dev/install | bash
|
||||
# Usage: curl -sSL https://toes.space/install | bash
|
||||
# Must be run as the 'toes' user.
|
||||
|
||||
DEST=~/toes
|
||||
|
|
@ -91,16 +91,12 @@ echo ">> Installing bundled apps"
|
|||
BUNDLED_APPS="clock code cron env stats versions"
|
||||
for app in $BUNDLED_APPS; do
|
||||
if [ -d "$DEST/apps/$app" ]; then
|
||||
if [ -d ~/apps/"$app" ]; then
|
||||
echo " $app (exists, skipping)"
|
||||
continue
|
||||
fi
|
||||
echo " $app"
|
||||
cp -r "$DEST/apps/$app" ~/apps/
|
||||
version_dir=$(ls -1 ~/apps/"$app" | grep -E '^[0-9]{8}-[0-9]{6}$' | sort -r | head -1)
|
||||
version_dir=$(ls -1 ~/apps/$app | grep -E '^[0-9]{8}-[0-9]{6}$' | sort -r | head -1)
|
||||
if [ -n "$version_dir" ]; then
|
||||
ln -sfn "$version_dir" ~/apps/"$app"/current
|
||||
(cd ~/apps/"$app"/current && bun install --frozen-lockfile) > /dev/null 2>&1 || true
|
||||
ln -sfn "$version_dir" ~/apps/$app/current
|
||||
(cd ~/apps/$app/current && bun install --frozen-lockfile) > /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"name": "toes-install",
|
||||
"version": "0.0.1",
|
||||
"description": "install toes",
|
||||
"module": "server.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "bun run server.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ Bun.serve({
|
|||
headers: { "content-type": "text/plain" },
|
||||
})
|
||||
}
|
||||
return new Response("404 Not Found", { status: 404 })
|
||||
return new Response("toes", { status: 404 })
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"exclude": ["apps", "templates"],
|
||||
"compilerOptions": {
|
||||
// Environment setup & latest features
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM"
|
||||
],
|
||||
"target": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "hono/jsx",
|
||||
"allowJs": true,
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"$*": [
|
||||
"./src/server/*"
|
||||
],
|
||||
"@*": [
|
||||
"./src/shared/*"
|
||||
],
|
||||
"%*": [
|
||||
"./src/lib/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ TOES_USER="${TOES_USER:-toes}"
|
|||
HOST="${HOST:-toes.local}"
|
||||
SSH_HOST="$TOES_USER@$HOST"
|
||||
URL="${URL:-http://$HOST}"
|
||||
DEST="${DEST:-$HOME/toes}"
|
||||
DATA_DIR="${DATA_DIR:-$HOME/data}"
|
||||
APPS_DIR="${APPS_DIR:-$HOME/apps}"
|
||||
DEST="${DEST:-~/toes}"
|
||||
DATA_DIR="${DATA_DIR:-~/data}"
|
||||
APPS_DIR="${APPS_DIR:-~/apps}"
|
||||
|
||||
mkdir -p "$DEST" "$DATA_DIR" "$APPS_DIR"
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@ import { define } from '@because/forge'
|
|||
import type { App } from '../../shared/types'
|
||||
import { buildAppUrl } from '../../shared/urls'
|
||||
import { restartApp, shareApp, startApp, stopApp, unshareApp } from '../api'
|
||||
import { openDeleteAppModal, openRenameAppModal } from '../modals'
|
||||
import { apps, getSelectedTab, isNarrow, setMobileSidebar } from '../state'
|
||||
import { openAppSelectorModal, openDeleteAppModal, openRenameAppModal } from '../modals'
|
||||
import { apps, getSelectedTab, isNarrow } from '../state'
|
||||
import {
|
||||
ActionBar,
|
||||
AppSelectorChevron,
|
||||
Button,
|
||||
ClickableAppName,
|
||||
HamburgerButton,
|
||||
HamburgerLine,
|
||||
HeaderActions,
|
||||
InfoLabel,
|
||||
InfoRow,
|
||||
|
|
@ -53,15 +52,14 @@ export function AppDetail({ app, render }: { app: App, render: () => void }) {
|
|||
<Main>
|
||||
<MainHeader>
|
||||
<MainTitle>
|
||||
{isNarrow && (
|
||||
<HamburgerButton onClick={() => { setMobileSidebar(true); render() }} title="Show apps">
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
</HamburgerButton>
|
||||
)}
|
||||
<OpenEmojiPicker app={app} render={render}>{app.icon}</OpenEmojiPicker>
|
||||
|
||||
<ClickableAppName onClick={() => openRenameAppModal(app)}>{app.name}</ClickableAppName>
|
||||
{isNarrow && (
|
||||
<AppSelectorChevron onClick={() => openAppSelectorModal(render)}>
|
||||
▼
|
||||
</AppSelectorChevron>
|
||||
)}
|
||||
</MainTitle>
|
||||
<HeaderActions>
|
||||
{!app.tool && (
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import type { CSSProperties } from 'hono/jsx'
|
|||
import {
|
||||
apps,
|
||||
selectedApp,
|
||||
setSelectedApp,
|
||||
setSidebarSection,
|
||||
sidebarSection,
|
||||
} from '../state'
|
||||
|
|
@ -16,13 +17,19 @@ import {
|
|||
interface AppSelectorProps {
|
||||
render: () => void
|
||||
onSelect?: () => void
|
||||
onDashboard?: () => void
|
||||
collapsed?: boolean
|
||||
large?: boolean
|
||||
switcherStyle?: CSSProperties
|
||||
listStyle?: CSSProperties
|
||||
}
|
||||
|
||||
export function AppSelector({ render, onSelect, collapsed, large, switcherStyle, listStyle }: AppSelectorProps) {
|
||||
export function AppSelector({ render, onSelect, onDashboard, collapsed, switcherStyle, listStyle }: AppSelectorProps) {
|
||||
const selectApp = (name: string) => {
|
||||
setSelectedApp(name)
|
||||
onSelect?.()
|
||||
render()
|
||||
}
|
||||
|
||||
const switchSection = (section: 'apps' | 'tools') => {
|
||||
setSidebarSection(section)
|
||||
render()
|
||||
|
|
@ -36,18 +43,18 @@ export function AppSelector({ render, onSelect, collapsed, large, switcherStyle,
|
|||
<>
|
||||
{!collapsed && toolApps.length > 0 && (
|
||||
<SectionSwitcher style={switcherStyle}>
|
||||
<SectionTab active={sidebarSection === 'apps' ? true : undefined} large={large || undefined} onClick={() => switchSection('apps')}>
|
||||
<SectionTab active={sidebarSection === 'apps' ? true : undefined} onClick={() => switchSection('apps')}>
|
||||
Apps
|
||||
</SectionTab>
|
||||
<SectionTab active={sidebarSection === 'tools' ? true : undefined} large={large || undefined} onClick={() => switchSection('tools')}>
|
||||
<SectionTab active={sidebarSection === 'tools' ? true : undefined} onClick={() => switchSection('tools')}>
|
||||
Tools
|
||||
</SectionTab>
|
||||
</SectionSwitcher>
|
||||
)}
|
||||
<AppList style={listStyle}>
|
||||
{collapsed && (
|
||||
{collapsed && onDashboard && (
|
||||
<AppItem
|
||||
href="/"
|
||||
onClick={onDashboard}
|
||||
selected={!selectedApp ? true : undefined}
|
||||
style={{ justifyContent: 'center', padding: '10px 12px' }}
|
||||
title="Toes"
|
||||
|
|
@ -58,9 +65,7 @@ export function AppSelector({ render, onSelect, collapsed, large, switcherStyle,
|
|||
{activeApps.map(app => (
|
||||
<AppItem
|
||||
key={app.name}
|
||||
href={`/app/${app.name}`}
|
||||
onClick={onSelect}
|
||||
large={large || undefined}
|
||||
onClick={() => selectApp(app.name)}
|
||||
selected={app.name === selectedApp ? true : undefined}
|
||||
style={collapsed ? { justifyContent: 'center', padding: '10px 12px' } : undefined}
|
||||
title={collapsed ? app.name : undefined}
|
||||
|
|
@ -69,7 +74,7 @@ export function AppSelector({ render, onSelect, collapsed, large, switcherStyle,
|
|||
<span style={{ fontSize: 18 }}>{app.icon}</span>
|
||||
) : (
|
||||
<>
|
||||
<span style={{ fontSize: large ? 20 : 14 }}>{app.icon}</span>
|
||||
<span style={{ fontSize: 14 }}>{app.icon}</span>
|
||||
{app.name}
|
||||
<StatusDot state={app.state} data-app={app.name} data-state={app.state} style={{ marginLeft: 'auto' }} />
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -1,48 +1,13 @@
|
|||
import { Styles } from '@because/forge'
|
||||
import { openNewAppModal } from '../modals'
|
||||
import { apps, currentView, isNarrow, mobileSidebar, selectedApp, setMobileSidebar } from '../state'
|
||||
import {
|
||||
HamburgerButton,
|
||||
HamburgerLine,
|
||||
Layout,
|
||||
Main,
|
||||
MainContent as MainContentContainer,
|
||||
MainHeader,
|
||||
MainTitle,
|
||||
NewAppButton,
|
||||
} from '../styles'
|
||||
import { apps, currentView, isNarrow, selectedApp } from '../state'
|
||||
import { Layout } from '../styles'
|
||||
import { AppDetail } from './AppDetail'
|
||||
import { AppSelector } from './AppSelector'
|
||||
import { DashboardLanding } from './DashboardLanding'
|
||||
import { Modal } from './modal'
|
||||
import { SettingsPage } from './SettingsPage'
|
||||
import { Sidebar } from './Sidebar'
|
||||
|
||||
function MobileSidebar({ render }: { render: () => void }) {
|
||||
return (
|
||||
<Main>
|
||||
<MainHeader>
|
||||
<MainTitle>
|
||||
<HamburgerButton onClick={() => { setMobileSidebar(false); render() }} title="Hide apps">
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
</HamburgerButton>
|
||||
<a href="/" style={{ textDecoration: 'none', color: 'inherit' }}>🐾 Toes</a>
|
||||
</MainTitle>
|
||||
</MainHeader>
|
||||
<MainContentContainer>
|
||||
<AppSelector render={render} large />
|
||||
<div style={{ padding: '12px 16px' }}>
|
||||
<NewAppButton onClick={openNewAppModal}>+ New App</NewAppButton>
|
||||
</div>
|
||||
</MainContentContainer>
|
||||
</Main>
|
||||
)
|
||||
}
|
||||
|
||||
function MainContent({ render }: { render: () => void }) {
|
||||
if (isNarrow && mobileSidebar) return <MobileSidebar render={render} />
|
||||
const selected = apps.find(a => a.name === selectedApp)
|
||||
if (selected) return <AppDetail app={selected} render={render} />
|
||||
if (currentView === 'settings') return <SettingsPage render={render} />
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { useEffect } from 'hono/jsx'
|
||||
import { navigate } from '../router'
|
||||
import { dashboardTab, isNarrow, setMobileSidebar } from '../state'
|
||||
import { openAppSelectorModal } from '../modals'
|
||||
import { dashboardTab, isNarrow, setCurrentView, setDashboardTab, setSelectedApp } from '../state'
|
||||
import {
|
||||
HamburgerButton,
|
||||
HamburgerLine,
|
||||
AppSelectorChevron,
|
||||
DashboardContainer,
|
||||
DashboardHeader,
|
||||
DashboardTitle,
|
||||
|
|
@ -26,11 +25,14 @@ export function DashboardLanding({ render }: { render: () => void }) {
|
|||
const narrow = isNarrow || undefined
|
||||
|
||||
const openSettings = () => {
|
||||
navigate('/settings')
|
||||
setSelectedApp(null)
|
||||
setCurrentView('settings')
|
||||
render()
|
||||
}
|
||||
|
||||
const switchTab = (tab: typeof dashboardTab) => {
|
||||
navigate(tab === 'urls' ? '/' : `/${tab}`)
|
||||
setDashboardTab(tab)
|
||||
render()
|
||||
if (tab === 'logs') scrollLogsToBottom()
|
||||
}
|
||||
|
||||
|
|
@ -43,20 +45,14 @@ export function DashboardLanding({ render }: { render: () => void }) {
|
|||
>
|
||||
⚙️
|
||||
</SettingsGear>
|
||||
{isNarrow && (
|
||||
<HamburgerButton
|
||||
onClick={() => { setMobileSidebar(true); render() }}
|
||||
title="Show apps"
|
||||
style={{ position: 'absolute', top: 16, left: 16 }}
|
||||
>
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
<HamburgerLine />
|
||||
</HamburgerButton>
|
||||
)}
|
||||
<DashboardHeader>
|
||||
<DashboardTitle narrow={narrow}>
|
||||
🐾 Toes
|
||||
{isNarrow && (
|
||||
<AppSelectorChevron onClick={() => openAppSelectorModal(render)}>
|
||||
▼
|
||||
</AppSelectorChevron>
|
||||
)}
|
||||
</DashboardTitle>
|
||||
</DashboardHeader>
|
||||
|
||||
|
|
@ -67,7 +63,7 @@ export function DashboardLanding({ render }: { render: () => void }) {
|
|||
</TabBar>
|
||||
|
||||
<TabContent active={dashboardTab === 'urls' || undefined}>
|
||||
<Urls render={render} />
|
||||
<Urls />
|
||||
</TabContent>
|
||||
|
||||
<TabContent active={dashboardTab === 'logs' || undefined}>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { App } from '../../shared/types'
|
||||
import { navigate } from '../router'
|
||||
import { apps, getSelectedTab } from '../state'
|
||||
import { apps, getSelectedTab, setSelectedTab } from '../state'
|
||||
import { Tab, TabBar } from '../styles'
|
||||
import { resetToolIframe } from '../tool-iframes'
|
||||
|
||||
|
|
@ -13,7 +12,8 @@ export function Nav({ app, render }: { app: App; render: () => void }) {
|
|||
resetToolIframe(tab, app.name)
|
||||
return
|
||||
}
|
||||
navigate(tab === 'overview' ? `/app/${app.name}` : `/app/${app.name}/${tab}`)
|
||||
setSelectedTab(app.name, tab)
|
||||
render()
|
||||
}
|
||||
|
||||
// Find all tools
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect, useState } from 'hono/jsx'
|
||||
import { getWifiConfig, saveWifiConfig } from '../api'
|
||||
import { navigate } from '../router'
|
||||
import { setCurrentView } from '../state'
|
||||
import {
|
||||
Button,
|
||||
DashboardInstallCmd,
|
||||
|
|
@ -31,7 +31,8 @@ export function SettingsPage({ render }: { render: () => void }) {
|
|||
}, [])
|
||||
|
||||
const goBack = () => {
|
||||
navigate('/')
|
||||
setCurrentView('dashboard')
|
||||
render()
|
||||
}
|
||||
|
||||
const handleSave = async (e: Event) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { openNewAppModal } from '../modals'
|
||||
import {
|
||||
setCurrentView,
|
||||
setSelectedApp,
|
||||
setSidebarCollapsed,
|
||||
sidebarCollapsed,
|
||||
} from '../state'
|
||||
|
|
@ -15,6 +17,12 @@ import {
|
|||
import { AppSelector } from './AppSelector'
|
||||
|
||||
export function Sidebar({ render }: { render: () => void }) {
|
||||
const goToDashboard = () => {
|
||||
setSelectedApp(null)
|
||||
setCurrentView('dashboard')
|
||||
render()
|
||||
}
|
||||
|
||||
const toggleSidebar = () => {
|
||||
setSidebarCollapsed(!sidebarCollapsed)
|
||||
render()
|
||||
|
|
@ -32,7 +40,7 @@ export function Sidebar({ render }: { render: () => void }) {
|
|||
</div>
|
||||
) : (
|
||||
<Logo>
|
||||
<LogoLink href="/" title="Go to dashboard">
|
||||
<LogoLink onClick={goToDashboard} title="Go to dashboard">
|
||||
🐾 Toes
|
||||
</LogoLink>
|
||||
<HamburgerButton onClick={toggleSidebar} title="Hide sidebar">
|
||||
|
|
@ -42,7 +50,7 @@ export function Sidebar({ render }: { render: () => void }) {
|
|||
</HamburgerButton>
|
||||
</Logo>
|
||||
)}
|
||||
<AppSelector render={render} collapsed={sidebarCollapsed} />
|
||||
<AppSelector render={render} collapsed={sidebarCollapsed} onDashboard={goToDashboard} />
|
||||
{!sidebarCollapsed && (
|
||||
<SidebarFooter>
|
||||
<NewAppButton onClick={openNewAppModal}>+ New App</NewAppButton>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
import { buildAppUrl } from '../../shared/urls'
|
||||
import { navigate } from '../router'
|
||||
import { apps, isNarrow } from '../state'
|
||||
import { apps } from '../state'
|
||||
import {
|
||||
EmptyState,
|
||||
Tile,
|
||||
TileGrid,
|
||||
TileIcon,
|
||||
TileName,
|
||||
TileStatus,
|
||||
StatusDot,
|
||||
UrlLeft,
|
||||
UrlLink,
|
||||
UrlList,
|
||||
UrlPort,
|
||||
UrlRow,
|
||||
} from '../styles'
|
||||
|
||||
export function Urls({ render }: { render: () => void }) {
|
||||
export function Urls() {
|
||||
const nonTools = apps.filter(a => !a.tool)
|
||||
|
||||
if (nonTools.length === 0) {
|
||||
|
|
@ -18,31 +18,25 @@ export function Urls({ render }: { render: () => void }) {
|
|||
}
|
||||
|
||||
return (
|
||||
<TileGrid narrow={isNarrow || undefined}>
|
||||
<UrlList>
|
||||
{nonTools.map(app => {
|
||||
const url = app.tunnelUrl || buildAppUrl(app.name, location.origin)
|
||||
const url = buildAppUrl(app.name, location.origin)
|
||||
const running = app.state === 'running'
|
||||
const appPage = `/app/${app.name}`
|
||||
|
||||
const openAppPage = (e: MouseEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
navigate(appPage)
|
||||
}
|
||||
|
||||
return (
|
||||
<Tile
|
||||
key={app.name}
|
||||
href={running ? url : appPage}
|
||||
target={running ? '_blank' : undefined}
|
||||
narrow={isNarrow || undefined}
|
||||
>
|
||||
<TileStatus state={app.state} onClick={openAppPage} />
|
||||
<TileIcon>{app.icon}</TileIcon>
|
||||
<TileName>{app.name}</TileName>
|
||||
</Tile>
|
||||
<UrlRow key={app.name}>
|
||||
<UrlLeft>
|
||||
<StatusDot state={app.state} />
|
||||
{running ? (
|
||||
<UrlLink href={url} target="_blank">{url}</UrlLink>
|
||||
) : (
|
||||
<span style={{ color: 'var(--colors-textFaint)' }}>{app.name}</span>
|
||||
)}
|
||||
</UrlLeft>
|
||||
{app.port ? <UrlPort>:{app.port}</UrlPort> : null}
|
||||
</UrlRow>
|
||||
)
|
||||
})}
|
||||
</TileGrid>
|
||||
</UrlList>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { render as renderApp } from 'hono/jsx/dom'
|
||||
import { Dashboard } from './components'
|
||||
import { apps, getSelectedTab, selectedApp, setApps, setIsNarrow, setSelectedApp } from './state'
|
||||
import { initModal } from './components/modal'
|
||||
import { initRouter, navigate } from './router'
|
||||
import { apps, getSelectedTab, selectedApp, setApps, setIsNarrow } from './state'
|
||||
import { initToolIframes, updateToolIframes } from './tool-iframes'
|
||||
import { initUpdate } from './update'
|
||||
|
||||
|
|
@ -42,16 +41,14 @@ narrowQuery.addEventListener('change', e => {
|
|||
render()
|
||||
})
|
||||
|
||||
// Initialize router (sets initial state from URL and renders)
|
||||
initRouter(render)
|
||||
|
||||
// SSE connection
|
||||
const events = new EventSource('/api/apps/stream')
|
||||
events.onmessage = e => {
|
||||
const prev = apps
|
||||
setApps(JSON.parse(e.data))
|
||||
|
||||
if (selectedApp && !apps.some(a => a.name === selectedApp)) {
|
||||
navigate('/')
|
||||
setSelectedApp(null)
|
||||
}
|
||||
|
||||
render()
|
||||
|
|
|
|||
17
src/client/modals/AppSelector.tsx
Normal file
17
src/client/modals/AppSelector.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { closeModal, openModal } from '../components/modal'
|
||||
import { AppSelector } from '../components/AppSelector'
|
||||
|
||||
let renderFn: () => void
|
||||
|
||||
export function openAppSelectorModal(render: () => void) {
|
||||
renderFn = render
|
||||
|
||||
openModal('Select App', () => (
|
||||
<AppSelector
|
||||
render={renderFn}
|
||||
onSelect={closeModal}
|
||||
switcherStyle={{ padding: '0 0 12px', marginLeft: -20, marginRight: -20, paddingLeft: 20, paddingRight: 20, marginBottom: 8 }}
|
||||
listStyle={{ maxHeight: 300, overflow: 'auto' }}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import type { App } from '../../shared/types'
|
||||
import { closeModal, openModal, rerenderModal } from '../components/modal'
|
||||
import { navigate } from '../router'
|
||||
import { selectedApp } from '../state'
|
||||
import { selectedApp, setSelectedApp } from '../state'
|
||||
import { Button, Form, FormActions, FormError, FormField, FormInput, FormLabel } from '../styles'
|
||||
import { theme } from '../themes'
|
||||
|
||||
|
|
@ -33,11 +32,11 @@ async function deleteApp(input: HTMLInputElement) {
|
|||
throw new Error(`Failed to delete app: ${res.statusText}`)
|
||||
}
|
||||
|
||||
// Success - close modal and navigate to dashboard
|
||||
closeModal()
|
||||
// Success - close modal and clear selection
|
||||
if (selectedApp === deleteAppTarget.name) {
|
||||
navigate('/')
|
||||
setSelectedApp(null)
|
||||
}
|
||||
closeModal()
|
||||
} catch (err) {
|
||||
deleteAppError = err instanceof Error ? err.message : 'Failed to delete app'
|
||||
deleteAppDeleting = false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { closeModal, openModal, rerenderModal } from '../components/modal'
|
||||
import { navigate } from '../router'
|
||||
import { apps } from '../state'
|
||||
import { apps, setSelectedApp } from '../state'
|
||||
import { Button, Form, FormActions, FormCheckbox, FormCheckboxField, FormCheckboxLabel, FormError, FormField, FormInput, FormLabel, FormSelect } from '../styles'
|
||||
|
||||
type TemplateType = 'ssr' | 'spa' | 'bare'
|
||||
|
|
@ -49,9 +48,9 @@ async function createNewApp() {
|
|||
throw new Error(data.error || 'Failed to create app')
|
||||
}
|
||||
|
||||
// Success - close modal and navigate to the new app
|
||||
// Success - close modal and select the new app
|
||||
setSelectedApp(name)
|
||||
closeModal()
|
||||
navigate(`/app/${name}`)
|
||||
} catch (err) {
|
||||
newAppError = err instanceof Error ? err.message : 'Failed to create app'
|
||||
newAppCreating = false
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { App } from '../../shared/types'
|
||||
import { closeModal, openModal, rerenderModal } from '../components/modal'
|
||||
import { navigate } from '../router'
|
||||
import { apps } from '../state'
|
||||
import { apps, setSelectedApp } from '../state'
|
||||
import { Button, Form, FormActions, FormError, FormField, FormInput, FormLabel } from '../styles'
|
||||
|
||||
let renameAppError = ''
|
||||
|
|
@ -59,9 +58,9 @@ async function doRenameApp(input: HTMLInputElement) {
|
|||
throw new Error(data.error || 'Failed to rename app')
|
||||
}
|
||||
|
||||
// Success - close modal and navigate to renamed app
|
||||
// Success - update selection and close modal
|
||||
setSelectedApp(data.name || newName)
|
||||
closeModal()
|
||||
navigate(`/app/${data.name || newName}`)
|
||||
} catch (err) {
|
||||
renameAppError = err instanceof Error ? err.message : 'Failed to rename app'
|
||||
renameAppRenaming = false
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
export { openAppSelectorModal } from './AppSelector'
|
||||
export { openDeleteAppModal } from './DeleteApp'
|
||||
export { openNewAppModal } from './NewApp'
|
||||
export { openRenameAppModal } from './RenameApp'
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
import { setCurrentView, setDashboardTab, setMobileSidebar, setSelectedApp, setSelectedTab } from './state'
|
||||
|
||||
let _render: () => void
|
||||
|
||||
export function navigate(href: string) {
|
||||
history.pushState(null, '', href)
|
||||
route()
|
||||
}
|
||||
|
||||
export function initRouter(render: () => void) {
|
||||
_render = render
|
||||
|
||||
// Intercept link clicks
|
||||
document.addEventListener('click', e => {
|
||||
const a = (e.target as Element).closest('a')
|
||||
if (!a || !a.href || a.origin !== location.origin || a.target === '_blank') return
|
||||
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return
|
||||
e.preventDefault()
|
||||
history.pushState(null, '', a.href)
|
||||
route()
|
||||
})
|
||||
|
||||
// Handle back/forward
|
||||
window.addEventListener('popstate', route)
|
||||
|
||||
// Initial route from URL
|
||||
route()
|
||||
}
|
||||
|
||||
function route() {
|
||||
setMobileSidebar(false)
|
||||
const path = location.pathname
|
||||
|
||||
if (path.startsWith('/app/')) {
|
||||
const rest = decodeURIComponent(path.slice(5))
|
||||
const slashIdx = rest.indexOf('/')
|
||||
const name = slashIdx === -1 ? rest : rest.slice(0, slashIdx)
|
||||
const tab = slashIdx === -1 ? 'overview' : rest.slice(slashIdx + 1)
|
||||
setSelectedApp(name)
|
||||
setSelectedTab(name, tab)
|
||||
setCurrentView('dashboard')
|
||||
} else if (path === '/settings') {
|
||||
setSelectedApp(null)
|
||||
setCurrentView('settings')
|
||||
} else if (path === '/logs') {
|
||||
setSelectedApp(null)
|
||||
setDashboardTab('logs')
|
||||
setCurrentView('dashboard')
|
||||
} else if (path === '/metrics') {
|
||||
setSelectedApp(null)
|
||||
setDashboardTab('metrics')
|
||||
setCurrentView('dashboard')
|
||||
} else {
|
||||
setSelectedApp(null)
|
||||
setDashboardTab('urls')
|
||||
setCurrentView('dashboard')
|
||||
}
|
||||
|
||||
_render()
|
||||
}
|
||||
|
|
@ -5,21 +5,21 @@ export type DashboardTab = 'urls' | 'logs' | 'metrics'
|
|||
// UI state (survives re-renders)
|
||||
export let currentView: 'dashboard' | 'settings' = 'dashboard'
|
||||
export let isNarrow: boolean = window.matchMedia('(max-width: 768px)').matches
|
||||
export let selectedApp: string | null = null
|
||||
export let selectedApp: string | null = localStorage.getItem('selectedApp')
|
||||
export let sidebarCollapsed: boolean = localStorage.getItem('sidebarCollapsed') === 'true'
|
||||
export let dashboardTab: DashboardTab = 'urls'
|
||||
export let mobileSidebar: boolean = false
|
||||
export let dashboardTab: DashboardTab = (localStorage.getItem('dashboardTab') as DashboardTab) || 'urls'
|
||||
export let sidebarSection: 'apps' | 'tools' = (localStorage.getItem('sidebarSection') as 'apps' | 'tools') || 'apps'
|
||||
|
||||
// Server state (from SSE)
|
||||
export let apps: App[] = []
|
||||
|
||||
// Tab state
|
||||
export let appTabs: Record<string, string> = {}
|
||||
export let appTabs: Record<string, string> = JSON.parse(localStorage.getItem('appTabs') || '{}')
|
||||
|
||||
// State setters
|
||||
export function setDashboardTab(tab: DashboardTab) {
|
||||
dashboardTab = tab
|
||||
localStorage.setItem('dashboardTab', tab)
|
||||
}
|
||||
|
||||
export function setCurrentView(view: 'dashboard' | 'settings') {
|
||||
|
|
@ -28,16 +28,17 @@ export function setCurrentView(view: 'dashboard' | 'settings') {
|
|||
|
||||
export function setSelectedApp(name: string | null) {
|
||||
selectedApp = name
|
||||
if (name) {
|
||||
localStorage.setItem('selectedApp', name)
|
||||
} else {
|
||||
localStorage.removeItem('selectedApp')
|
||||
}
|
||||
}
|
||||
|
||||
export function setIsNarrow(narrow: boolean) {
|
||||
isNarrow = narrow
|
||||
}
|
||||
|
||||
export function setMobileSidebar(open: boolean) {
|
||||
mobileSidebar = open
|
||||
}
|
||||
|
||||
export function setSidebarCollapsed(collapsed: boolean) {
|
||||
sidebarCollapsed = collapsed
|
||||
localStorage.setItem('sidebarCollapsed', String(collapsed))
|
||||
|
|
@ -58,4 +59,5 @@ export const getSelectedTab = (appName: string | null) =>
|
|||
export function setSelectedTab(appName: string | null, tab: string) {
|
||||
if (!appName) return
|
||||
appTabs[appName] = tab
|
||||
localStorage.setItem('appTabs', JSON.stringify(appTabs))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export const GaugeValue = define('GaugeValue', {
|
|||
// Unified Logs Section
|
||||
export const LogsSection = define('LogsSection', {
|
||||
width: '100%',
|
||||
maxWidth: 800,
|
||||
flex: 1,
|
||||
minHeight: 0,
|
||||
display: 'flex',
|
||||
|
|
@ -202,85 +203,58 @@ export const LogStatus = define('LogStatus', {
|
|||
},
|
||||
})
|
||||
|
||||
// App Tiles Grid
|
||||
export const TileGrid = define('TileGrid', {
|
||||
width: '100%',
|
||||
maxWidth: 900,
|
||||
margin: '0 auto',
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(auto-fill, minmax(240px, 1fr))',
|
||||
gap: 20,
|
||||
variants: {
|
||||
narrow: { gridTemplateColumns: '1fr' },
|
||||
// URL List
|
||||
export const UrlLeft = define('UrlLeft', {
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
minWidth: 0,
|
||||
})
|
||||
|
||||
export const UrlLink = define('UrlLink', {
|
||||
base: 'a',
|
||||
color: theme('colors-link'),
|
||||
textDecoration: 'none',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
selectors: {
|
||||
'&:hover': { textDecoration: 'underline' },
|
||||
},
|
||||
})
|
||||
|
||||
export const Tile = define('Tile', {
|
||||
base: 'a',
|
||||
position: 'relative',
|
||||
export const UrlList = define('UrlList', {
|
||||
width: '100%',
|
||||
minWidth: 400,
|
||||
maxWidth: 800,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
padding: '28px 20px 24px',
|
||||
background: theme('colors-bgElement'),
|
||||
border: `1px solid ${theme('colors-border')}`,
|
||||
borderRadius: theme('radius-md'),
|
||||
textDecoration: 'none',
|
||||
cursor: 'pointer',
|
||||
overflow: 'hidden',
|
||||
})
|
||||
|
||||
export const UrlPort = define('UrlPort', {
|
||||
fontFamily: theme('fonts-mono'),
|
||||
fontSize: 12,
|
||||
color: theme('colors-textFaint'),
|
||||
flexShrink: 0,
|
||||
})
|
||||
|
||||
export const UrlRow = define('UrlRow', {
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
padding: '10px 16px',
|
||||
fontFamily: theme('fonts-mono'),
|
||||
fontSize: 13,
|
||||
selectors: {
|
||||
'&:hover': {
|
||||
background: theme('colors-bgHover'),
|
||||
borderColor: theme('colors-textFaint'),
|
||||
},
|
||||
},
|
||||
variants: {
|
||||
narrow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
padding: '16px 20px',
|
||||
gap: 16,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const TileIcon = define('TileIcon', {
|
||||
fontSize: 48,
|
||||
lineHeight: 1,
|
||||
userSelect: 'none',
|
||||
})
|
||||
|
||||
export const TileName = define('TileName', {
|
||||
fontSize: 15,
|
||||
fontWeight: 600,
|
||||
color: theme('colors-text'),
|
||||
textAlign: 'center',
|
||||
})
|
||||
|
||||
export const TilePort = define('TilePort', {
|
||||
fontFamily: theme('fonts-mono'),
|
||||
fontSize: 13,
|
||||
color: theme('colors-textFaint'),
|
||||
})
|
||||
|
||||
export const TileStatus = define('TileStatus', {
|
||||
position: 'absolute',
|
||||
top: 8,
|
||||
right: 8,
|
||||
width: 2,
|
||||
height: 2,
|
||||
borderRadius: '50%',
|
||||
cursor: 'pointer',
|
||||
padding: 4,
|
||||
backgroundClip: 'content-box',
|
||||
variants: {
|
||||
state: {
|
||||
error: { background: theme('colors-statusInvalid') },
|
||||
invalid: { background: theme('colors-statusInvalid') },
|
||||
stopped: { background: theme('colors-statusStopped') },
|
||||
starting: { background: theme('colors-statusStarting') },
|
||||
running: { background: theme('colors-statusRunning') },
|
||||
stopping: { background: theme('colors-statusStarting') },
|
||||
'&:not(:last-child)': {
|
||||
borderBottom: `1px solid ${theme('colors-border')}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@ export {
|
|||
LogStatus,
|
||||
LogText,
|
||||
LogTimestamp,
|
||||
Tile,
|
||||
TileGrid,
|
||||
TileIcon,
|
||||
TileName,
|
||||
TilePort,
|
||||
TileStatus,
|
||||
UrlLeft,
|
||||
UrlLink,
|
||||
UrlList,
|
||||
UrlPort,
|
||||
UrlRow,
|
||||
VitalCard,
|
||||
VitalLabel,
|
||||
VitalsSection,
|
||||
|
|
@ -29,6 +28,7 @@ export { Form, FormActions, FormCheckbox, FormCheckboxField, FormCheckboxLabel,
|
|||
export {
|
||||
AppItem,
|
||||
AppList,
|
||||
AppSelectorChevron,
|
||||
ClickableAppName,
|
||||
DashboardContainer,
|
||||
DashboardHeader,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@ export const Logo = define('Logo', {
|
|||
})
|
||||
|
||||
export const LogoLink = define('LogoLink', {
|
||||
base: 'a',
|
||||
cursor: 'pointer',
|
||||
color: 'inherit',
|
||||
textDecoration: 'none',
|
||||
borderRadius: theme('radius-md'),
|
||||
padding: '4px 8px',
|
||||
margin: '-4px -8px',
|
||||
|
|
@ -106,7 +103,6 @@ export const SectionTab = define('SectionTab', {
|
|||
background: theme('colors-bgSelected'),
|
||||
color: theme('colors-text'),
|
||||
},
|
||||
large: { fontSize: 14, padding: '8px 12px' },
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -116,7 +112,6 @@ export const AppList = define('AppList', {
|
|||
})
|
||||
|
||||
export const AppItem = define('AppItem', {
|
||||
base: 'a',
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
|
|
@ -130,7 +125,6 @@ export const AppItem = define('AppItem', {
|
|||
'&:hover': { background: theme('colors-bgHover'), color: theme('colors-text') },
|
||||
},
|
||||
variants: {
|
||||
large: { fontSize: 18, padding: '12px 16px', gap: 12 },
|
||||
selected: { background: theme('colors-bgSelected'), color: theme('colors-text'), fontWeight: 500 },
|
||||
},
|
||||
})
|
||||
|
|
@ -172,6 +166,20 @@ export const MainTitle = define('MainTitle', {
|
|||
margin: 0,
|
||||
})
|
||||
|
||||
export const AppSelectorChevron = define('AppSelectorChevron', {
|
||||
base: 'button',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
padding: '4px 8px',
|
||||
marginLeft: 4,
|
||||
fontSize: 14,
|
||||
color: theme('colors-textMuted'),
|
||||
selectors: {
|
||||
'&:hover': { color: theme('colors-text') },
|
||||
},
|
||||
})
|
||||
|
||||
export const ClickableAppName = define('ClickableAppName', {
|
||||
cursor: 'pointer',
|
||||
borderRadius: theme('radius-md'),
|
||||
|
|
@ -225,7 +233,6 @@ export const DashboardContainer = define('DashboardContainer', {
|
|||
|
||||
export const DashboardHeader = define('DashboardHeader', {
|
||||
textAlign: 'center',
|
||||
width: '100%',
|
||||
})
|
||||
|
||||
export const DashboardTitle = define('DashboardTitle', {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@ export const TabContent = define('TabContent', {
|
|||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ const router = Hype.router()
|
|||
// individual events so apps can react to specific lifecycle changes.
|
||||
router.sse('/stream', (send) => {
|
||||
const unsub = onEvent(event => send(event))
|
||||
const heartbeat = setInterval(() => send('', 'ping'), 60_000)
|
||||
return () => {
|
||||
clearInterval(heartbeat)
|
||||
unsub()
|
||||
}
|
||||
return unsub
|
||||
})
|
||||
|
||||
export default router
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import systemRouter from './api/system'
|
|||
import { Hype } from '@because/hype'
|
||||
import { cleanupStalePublishers } from './mdns'
|
||||
import { extractSubdomain, proxySubdomain, proxyWebSocket, websocket } from './proxy'
|
||||
import { Shell } from './shell'
|
||||
import type { Server } from 'bun'
|
||||
import type { WsData } from './proxy'
|
||||
|
||||
|
|
@ -114,13 +113,6 @@ app.get('/dist/:file', async c => {
|
|||
})
|
||||
})
|
||||
|
||||
// SPA routes — serve the shell for all client-side paths
|
||||
app.get('/app/:name/:tab', c => c.html(<Shell />))
|
||||
app.get('/app/:name', c => c.html(<Shell />))
|
||||
app.get('/logs', c => c.html(<Shell />))
|
||||
app.get('/metrics', c => c.html(<Shell />))
|
||||
app.get('/settings', c => c.html(<Shell />))
|
||||
|
||||
cleanupStalePublishers()
|
||||
await initApps()
|
||||
|
||||
|
|
|
|||
|
|
@ -146,19 +146,18 @@ export function renameTunnelConfig(oldName: string, newName: string) {
|
|||
saveConfig(config)
|
||||
}
|
||||
|
||||
function cancelReconnect(appName: string, resetAttempts = true) {
|
||||
function cancelReconnect(appName: string) {
|
||||
const timer = _reconnectTimers.get(appName)
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
_reconnectTimers.delete(appName)
|
||||
}
|
||||
if (resetAttempts) _reconnectAttempts.delete(appName)
|
||||
_reconnectAttempts.delete(appName)
|
||||
}
|
||||
|
||||
function openTunnel(appName: string, port: number, subdomain?: string, isReconnect = false) {
|
||||
function openTunnel(appName: string, port: number, subdomain?: string) {
|
||||
// Cancel any pending reconnect timer to prevent duplicate loops
|
||||
// but preserve attempts counter during reconnection so backoff works
|
||||
cancelReconnect(appName, !isReconnect)
|
||||
cancelReconnect(appName)
|
||||
|
||||
// Close existing tunnel if any
|
||||
const existing = _tunnels.get(appName)
|
||||
|
|
@ -233,7 +232,7 @@ function openTunnel(appName: string, port: number, subdomain?: string, isReconne
|
|||
const config = loadConfig()
|
||||
if (!config[appName]) return
|
||||
hostLog(`Tunnel reconnecting: ${appName}`)
|
||||
openTunnel(appName, port, config[appName]?.subdomain, true)
|
||||
openTunnel(appName, port, config[appName]?.subdomain)
|
||||
}, delay)
|
||||
|
||||
_reconnectTimers.set(appName, timer)
|
||||
|
|
|
|||
|
|
@ -35,10 +35,8 @@ function ensureConnection() {
|
|||
buf = lines.pop()!
|
||||
for (const line of lines) {
|
||||
if (!line.startsWith('data: ')) continue
|
||||
const payload = line.slice(6)
|
||||
if (!payload) continue
|
||||
try {
|
||||
const event: ToesEvent = JSON.parse(payload)
|
||||
const event: ToesEvent = JSON.parse(line.slice(6))
|
||||
_listeners.forEach(l => {
|
||||
if (l.types.includes(event.type)) l.callback(event)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user