BrowserAdapter speaks yaw/2.1 signaling + WebRTC protocol entirely in the browser (libsodium-wrappers for Ed25519/X25519). Identity stored in localStorage; peers connect via any waste/yaw2 anchor. When served from a non-localhost origin the app defaults to browser mode. On localhost the daemon adapter is tried first with a one-click switch to browser mode. config.js (gitignored, served by anchor) lets the host pre-inject signalURL and other defaults. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
841 B
TypeScript
29 lines
841 B
TypeScript
import { useEffect } from 'react'
|
|
import { useWaste } from './store'
|
|
import { Onboarding } from './pages/Onboarding'
|
|
import { Chat } from './pages/Chat'
|
|
import './App.css'
|
|
|
|
// When served from the anchor (non-localhost), default to browser mode.
|
|
// When running locally, try the daemon first.
|
|
const isLocal = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
|
const DAEMON_WS = import.meta.env.VITE_DAEMON_WS ?? 'ws://127.0.0.1:17338'
|
|
|
|
export default function App() {
|
|
const { connect, connectBrowser, daemonStatus, localPeer } = useWaste()
|
|
|
|
useEffect(() => {
|
|
if (isLocal) {
|
|
connect(DAEMON_WS)
|
|
} else {
|
|
connectBrowser()
|
|
}
|
|
}, [connect, connectBrowser])
|
|
|
|
if (daemonStatus !== 'connected' || !localPeer) {
|
|
return <Onboarding status={daemonStatus} />
|
|
}
|
|
|
|
return <Chat />
|
|
}
|