ec-node: WebTransport publish + web hang-watch

This commit is contained in:
every.channel 2026-02-16 12:54:42 -05:00
parent 791c7beee7
commit 339aef50e0
No known key found for this signature in database
19 changed files with 1355 additions and 2229 deletions

1857
apps/web/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,14 +0,0 @@
[package]
name = "ec-web"
version = "0.0.0"
edition = "2021"
[dependencies]
dioxus = { version = "0.6", features = ["web"] }
js-sys = "0.3"
serde = { version = "1", features = ["derive"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
web-sys = { version = "0.3", features = ["Window", "Navigator", "Clipboard"] }
[workspace]

View file

@ -1,6 +1,8 @@
# every.channel web site (static)
This is a static web site built in Rust with Dioxus and compiled to WASM.
This is a static web watcher site.
It embeds the upstream `@kixelated/hang` WebTransport player component (`<hang-watch>`).
## Dev
@ -15,4 +17,3 @@ nix develop -c bash -lc 'cd apps/web && trunk serve --port 1421 --public-url /'
```bash
nix develop -c bash -lc 'cd apps/web && trunk build --release --public-url /'
```

181
apps/web/app.js Normal file
View file

@ -0,0 +1,181 @@
// every.channel web watcher
//
// This uses the upstream hang web component (WebTransport + WebCodecs).
// It is intentionally dependency-light: no framework, no bundler.
import "https://cdn.jsdelivr.net/npm/@kixelated/hang@0.7.0/watch/element.js";
const DEFAULT_RELAY_URL = "https://relay.cloudflare.mediaoverquic.com/";
function $(id) {
const el = document.getElementById(id);
if (!el) throw new Error(`missing element: ${id}`);
return el;
}
function normalizeRelayUrl(s) {
const trimmed = (s || "").trim();
if (!trimmed) return DEFAULT_RELAY_URL;
// Ensure trailing slash so relative fetches behave consistently.
return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
}
function normalizeName(s) {
return (s || "").trim();
}
function currentShareLink(relayUrl, name) {
const u = new URL(window.location.href);
u.pathname = "/watch";
u.searchParams.set("url", relayUrl);
u.searchParams.set("name", name);
// Avoid leaking other params.
for (const k of [...u.searchParams.keys()]) {
if (k !== "url" && k !== "name") u.searchParams.delete(k);
}
return u.toString();
}
function setHint(text, kind) {
const el = $("hint");
el.textContent = text || "";
el.dataset.kind = kind || "";
}
function setShareLink(text) {
const el = $("shareLink");
el.textContent = text || "";
}
function mountPlayer(relayUrl, name) {
const mount = $("playerMount");
mount.textContent = "";
const watch = document.createElement("hang-watch");
watch.setAttribute("url", relayUrl);
watch.setAttribute("name", name);
watch.setAttribute("controls", "");
// A canvas enables video rendering. Without it, only audio is played.
const canvas = document.createElement("canvas");
canvas.className = "canvas";
watch.appendChild(canvas);
mount.appendChild(watch);
}
async function copyToClipboard(text) {
if (!text) return;
if (navigator.clipboard && navigator.clipboard.writeText) {
await navigator.clipboard.writeText(text);
return;
}
// Fallback: best-effort.
const ta = document.createElement("textarea");
ta.value = text;
document.body.appendChild(ta);
ta.select();
document.execCommand("copy");
document.body.removeChild(ta);
}
function readParams() {
const u = new URL(window.location.href);
const relay = u.searchParams.get("url");
const name = u.searchParams.get("name");
return {
relayUrl: normalizeRelayUrl(relay || DEFAULT_RELAY_URL),
name: normalizeName(name || ""),
};
}
function writeParams(relayUrl, name) {
const u = new URL(window.location.href);
u.pathname = "/watch";
u.searchParams.set("url", relayUrl);
u.searchParams.set("name", name);
window.history.replaceState({}, "", u.toString());
}
function hasWebTransport() {
return typeof window.WebTransport !== "undefined";
}
function main() {
const relayInput = $("relayUrl");
const nameInput = $("broadcastName");
const watchBtn = $("watchBtn");
const copyBtn = $("copyLinkBtn");
const initial = readParams();
relayInput.value = initial.relayUrl;
nameInput.value = initial.name;
function updateSharePreview() {
const relayUrl = normalizeRelayUrl(relayInput.value);
const name = normalizeName(nameInput.value);
if (!name) {
setShareLink("");
return;
}
setShareLink(currentShareLink(relayUrl, name));
}
function start() {
const relayUrl = normalizeRelayUrl(relayInput.value);
const name = normalizeName(nameInput.value);
updateSharePreview();
if (!name) {
setHint("Enter a broadcast name to watch.", "warn");
return;
}
if (!hasWebTransport()) {
setHint(
"WebTransport is not available in this browser. Try Chrome or Firefox Nightly. Safari support is still incomplete.",
"warn",
);
return;
}
writeParams(relayUrl, name);
setHint(`Connecting to relay and subscribing: ${name}`, "ok");
mountPlayer(relayUrl, name);
}
relayInput.addEventListener("input", updateSharePreview);
nameInput.addEventListener("input", updateSharePreview);
watchBtn.addEventListener("click", start);
nameInput.addEventListener("keydown", (e) => {
if (e.key === "Enter") start();
});
copyBtn.addEventListener("click", async () => {
const relayUrl = normalizeRelayUrl(relayInput.value);
const name = normalizeName(nameInput.value);
if (!name) {
setHint("Enter a broadcast name first.", "warn");
return;
}
const link = currentShareLink(relayUrl, name);
try {
await copyToClipboard(link);
setHint("Link copied.", "ok");
setShareLink(link);
} catch (e) {
setHint(`Copy failed: ${String(e)}`, "warn");
setShareLink(link);
}
});
updateSharePreview();
// Auto-start if a name was provided.
if (initial.name) start();
}
main();

View file

@ -9,9 +9,58 @@
content="Watch and share free over-the-air TV. Local first, global when you want."
/>
<link data-trunk rel="css" href="style.css" />
<link data-trunk rel="rust" data-wasm-opt="z" />
<link data-trunk rel="copy-file" href="app.js" />
</head>
<body>
<div id="main"></div>
<main class="shell">
<header class="top">
<div class="brand">
<div class="brand-title">every.channel</div>
<div class="brand-subtitle">Watch live streams over WebTransport.</div>
</div>
<div class="badge" title="MoQ over WebTransport">
WebTransport
</div>
</header>
<section class="panel">
<div class="panel-title">Watch</div>
<div class="row">
<label class="field">
<div class="label">Relay URL</div>
<input id="relayUrl" class="input" type="text" spellcheck="false" />
</label>
<label class="field">
<div class="label">Broadcast name</div>
<input id="broadcastName" class="input" type="text" spellcheck="false" />
</label>
<button id="watchBtn" class="btn">Watch</button>
</div>
<div class="hint" id="hint"></div>
<div class="row share">
<button id="copyLinkBtn" class="btn secondary">Copy link</button>
<div class="shareLink" id="shareLink" aria-live="polite"></div>
</div>
</section>
<section class="player">
<div class="tv">
<div class="tv-glow"></div>
<div class="tv-frame">
<div id="playerMount" class="mount"></div>
<div class="tv-scanlines" aria-hidden="true"></div>
</div>
</div>
</section>
<footer class="foot">
<div class="foot-left">AGPLv3</div>
<div class="foot-right">
For Safari: WebTransport is behind a Developer/Advanced feature flag and may be incomplete.
</div>
</footer>
</main>
<script type="module" src="app.js"></script>
</body>
</html>

View file

@ -1,125 +0,0 @@
use dioxus::prelude::*;
use wasm_bindgen_futures::JsFuture;
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
let mut link = use_signal(|| "".to_string());
let mut status = use_signal(|| "".to_string());
rsx! {
div { class: "page",
header { class: "top",
div { class: "brand",
div { class: "brand-title", "every.channel" }
div { class: "brand-subtitle",
"Watch and share free over-the-air TV. Local first, global when you want."
}
}
nav { class: "nav",
a { href: "#watch", "Watch" }
a { href: "#directory", "Directory" }
a { href: "#join", "Join" }
a { href: "#about", "Info" }
}
}
div { class: "grid",
section { class: "card section", id: "watch",
div { class: "card-title", "Watch" }
div { class: "h1", "Watch a link" }
div { class: "p",
"Got a link from a friend? Paste it here to copy, then open the desktop app."
}
div { class: "row",
input {
class: "input",
placeholder: "every.channel://watch?...",
value: "{link.read()}",
oninput: move |evt| link.set(evt.value()),
}
button {
class: "btn primary",
onclick: move |_| {
let value = link.read().trim().to_string();
if value.is_empty() {
status.set("Paste a link first".to_string());
return;
}
let mut status = status.clone();
spawn(async move {
match copy_to_clipboard(value).await {
Ok(_) => status.set("Copied! Open the app and paste under Watch a Link.".to_string()),
Err(err) => status.set(format!("Copy failed: {err}")),
}
});
},
"Copy"
}
}
if !status.read().is_empty() {
div { class: "kicker",
span { class: "dot" }
span { "{status.read()}" }
}
}
}
section { class: "card section", id: "directory",
div { class: "card-title", "Directory" }
div { class: "h1", "Find channels from people you trust" }
div { class: "p",
"The directory is opt-in. You choose what to share and who to connect with."
}
div { class: "kicker",
span { class: "dot" }
span { "Enable Nearby or Public reach in the app to find others." }
}
}
section { class: "card section", id: "join",
div { class: "card-title", "Join" }
div { class: "h1", "Run your own" }
div { class: "p",
"Anyone can watch, share, and relay. Works with HDHomeRun, Linux TV tuners, and live streams."
}
div { class: "kicker",
span { class: "dot" }
span { "Desktop app and CLI available now." }
}
}
section { class: "card section", id: "about",
div { class: "card-title", "About" }
div { class: "h1", "A small promise" }
div { class: "p",
"TV signals are just waves in the air. This project makes it easier to pick them up and share them with others."
}
div { class: "kicker",
span { class: "dot" }
span { "Open source. No central server." }
}
}
}
footer { class: "footer",
span { "AGPLv3" }
span { "every.channel" }
a { href: "https://every.channel", "every.channel" }
}
}
}
}
async fn copy_to_clipboard(text: String) -> Result<(), String> {
let window = web_sys::window().ok_or_else(|| "window unavailable".to_string())?;
let clipboard = window.navigator().clipboard();
let promise = clipboard.write_text(&text);
JsFuture::from(promise)
.await
.map_err(|err| format!("clipboard write rejected: {err:?}"))?;
Ok(())
}

View file

@ -1,285 +1,272 @@
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500&display=swap");
:root {
color-scheme: light;
--bg: #f8f5f0;
--bg-muted: #f2ede5;
--card: rgba(255, 255, 255, 0.82);
--ink: #1a1814;
--ink-muted: #5c574d;
--border: rgba(26, 24, 20, 0.10);
--shadow: 0 16px 40px rgba(26, 24, 20, 0.10);
--accent: #18a89b;
--accent-ink: #0c6f68;
--warm: #d4915a;
--warm-muted: rgba(232, 160, 92, 0.12);
font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
font-feature-settings: "ss01" 1;
--bg0: #0b0f14;
--bg1: #0f1720;
--panel: rgba(255, 255, 255, 0.06);
--panel2: rgba(255, 255, 255, 0.08);
--text: rgba(255, 255, 255, 0.92);
--muted: rgba(255, 255, 255, 0.65);
--faint: rgba(255, 255, 255, 0.45);
--line: rgba(255, 255, 255, 0.12);
--accent: #ffb86c;
--accent2: #6ee7ff;
--ok: #7cf7a2;
--warn: #ffd36e;
--shadow: rgba(0, 0, 0, 0.55);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
}
body {
min-height: 100vh;
color: var(--ink);
background: linear-gradient(168deg, #fdfaf5 0%, #f8f5f0 35%, #f4f1ec 70%, #f0ece6 100%);
margin: 0;
color: var(--text);
background:
radial-gradient(1200px 700px at 15% 10%, rgba(255, 184, 108, 0.16), transparent 55%),
radial-gradient(900px 600px at 85% 20%, rgba(110, 231, 255, 0.12), transparent 60%),
radial-gradient(900px 900px at 50% 120%, rgba(255, 255, 255, 0.08), transparent 55%),
linear-gradient(180deg, var(--bg0), var(--bg1));
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
"Segoe UI Emoji";
}
/* Subtle "old TV" nod: soft phosphor glow and faint scanlines */
body::before {
content: "";
position: fixed;
inset: 0;
background-image:
radial-gradient(ellipse 80% 60% at 15% 10%, rgba(232, 160, 92, 0.08), transparent 50%),
radial-gradient(ellipse 60% 50% at 85% 15%, rgba(24, 168, 155, 0.06), transparent 45%),
radial-gradient(ellipse 70% 40% at 50% 90%, rgba(232, 160, 92, 0.05), transparent 50%),
repeating-linear-gradient(
0deg,
transparent 0px,
transparent 2px,
rgba(26, 24, 20, 0.012) 2px,
rgba(26, 24, 20, 0.012) 4px
);
pointer-events: none;
z-index: -1;
}
#main {
min-height: 100vh;
}
.page {
max-width: 1120px;
.shell {
max-width: 1100px;
margin: 0 auto;
padding: 24px clamp(16px, 4vw, 40px) 40px;
display: flex;
flex-direction: column;
gap: 20px;
animation: fadeIn 0.5s ease-out;
padding: 28px 18px 22px;
display: grid;
gap: 16px;
}
.top {
display: flex;
align-items: flex-start;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
}
.brand {
display: flex;
flex-direction: column;
gap: 4px;
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 16px;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04));
box-shadow: 0 18px 38px var(--shadow);
}
.brand-title {
font-size: clamp(24px, 2.6vw, 30px);
font-weight: 600;
letter-spacing: -0.025em;
color: var(--ink);
font-weight: 800;
letter-spacing: -0.02em;
font-size: 22px;
line-height: 1.05;
}
.brand-subtitle {
font-size: 12px;
color: var(--ink-muted);
max-width: 44ch;
line-height: 1.4;
margin-top: 4px;
color: var(--muted);
font-size: 13px;
}
.nav {
display: flex;
gap: 5px;
flex-wrap: wrap;
justify-content: flex-end;
}
.nav a {
text-decoration: none;
color: var(--ink-muted);
.badge {
padding: 8px 10px;
font-size: 12px;
font-weight: 500;
padding: 6px 10px;
color: rgba(0, 0, 0, 0.78);
background: linear-gradient(135deg, var(--accent), var(--accent2));
border-radius: 999px;
border: 1px solid var(--border);
background: rgba(255, 255, 255, 0.65);
transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
font-weight: 700;
}
.nav a:hover {
transform: translateY(-1px);
background: rgba(255, 255, 255, 0.9);
color: var(--ink);
box-shadow: 0 8px 20px rgba(26, 24, 20, 0.06);
}
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 14px;
}
@media (max-width: 720px) {
.grid {
grid-template-columns: 1fr;
}
}
.card {
.panel {
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 16px;
border: 1px solid var(--border);
background: var(--card);
box-shadow: var(--shadow);
padding: 18px;
backdrop-filter: blur(12px);
background: var(--panel);
box-shadow: 0 18px 38px var(--shadow);
}
.card-title {
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.12em;
color: var(--ink-muted);
margin-bottom: 8px;
}
.h1 {
font-size: clamp(16px, 1.8vw, 19px);
font-weight: 600;
letter-spacing: -0.015em;
margin-bottom: 8px;
line-height: 1.3;
}
.p {
.panel-title {
font-size: 12px;
line-height: 1.5;
color: var(--ink-muted);
letter-spacing: 0.22em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 12px;
}
.row {
display: grid;
grid-template-columns: 1fr auto;
gap: 6px;
margin-top: 10px;
grid-template-columns: 1.15fr 1fr auto;
gap: 10px;
align-items: end;
}
.field .label {
font-size: 12px;
color: var(--muted);
margin-bottom: 6px;
}
.input {
border: 1px solid var(--border);
border-radius: 10px;
padding: 8px 10px;
font-size: 11px;
background: rgba(242, 237, 229, 0.6);
color: var(--ink);
width: 100%;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(0, 0, 0, 0.28);
color: var(--text);
outline: none;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.input:focus {
outline: none;
border-color: rgba(24, 168, 155, 0.4);
box-shadow: 0 0 0 3px rgba(24, 168, 155, 0.08);
border-color: rgba(255, 184, 108, 0.55);
box-shadow: 0 0 0 3px rgba(255, 184, 108, 0.16);
}
.btn {
border: 1px solid var(--border);
border-radius: 10px;
padding: 8px 12px;
font-size: 11px;
font-weight: 500;
padding: 11px 14px;
border-radius: 12px;
border: 1px solid rgba(255, 184, 108, 0.35);
background: linear-gradient(180deg, rgba(255, 184, 108, 0.22), rgba(255, 184, 108, 0.12));
color: var(--text);
font-weight: 700;
cursor: pointer;
background: rgba(255, 255, 255, 0.85);
color: var(--ink);
transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}
.btn:hover {
transform: translateY(-1px);
box-shadow: 0 6px 16px rgba(26, 24, 20, 0.06);
border-color: rgba(255, 184, 108, 0.55);
background: linear-gradient(180deg, rgba(255, 184, 108, 0.28), rgba(255, 184, 108, 0.14));
}
.btn.primary {
background: var(--accent-ink);
color: #fff;
border-color: rgba(12, 111, 104, 0.3);
.btn:active {
transform: translateY(0);
}
.btn.primary:hover {
box-shadow: 0 6px 16px rgba(12, 111, 104, 0.2);
.btn.secondary {
border-color: rgba(255, 255, 255, 0.18);
background: rgba(255, 255, 255, 0.06);
}
.kicker {
.hint {
margin-top: 10px;
font-size: 13px;
color: var(--muted);
min-height: 18px;
}
.hint[data-kind="ok"] {
color: var(--ok);
}
.hint[data-kind="warn"] {
color: var(--warn);
}
.share {
margin-top: 8px;
display: inline-flex;
grid-template-columns: auto 1fr;
align-items: center;
gap: 6px;
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--border);
background: var(--warm-muted);
color: var(--ink-muted);
font-size: 11px;
}
.dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--warm);
box-shadow: 0 0 0 3px rgba(232, 160, 92, 0.2);
.shareLink {
color: var(--faint);
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 4px;
}
.section {
scroll-margin-top: 12px;
.player {
padding: 0;
}
code {
font-family: "IBM Plex Mono", ui-monospace, monospace;
font-size: 0.9em;
background: rgba(26, 24, 20, 0.05);
padding: 2px 5px;
border-radius: 4px;
.tv {
position: relative;
border-radius: 24px;
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.14);
background:
radial-gradient(900px 500px at 10% 10%, rgba(255, 184, 108, 0.10), transparent 55%),
radial-gradient(700px 500px at 90% 10%, rgba(110, 231, 255, 0.08), transparent 58%),
linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.10));
box-shadow: 0 28px 70px rgba(0, 0, 0, 0.62);
}
.footer {
margin-top: 6px;
padding-top: 12px;
border-top: 1px solid var(--border);
font-size: 10px;
color: var(--ink-muted);
.tv-glow {
position: absolute;
inset: -40px -20px -20px -20px;
background:
radial-gradient(350px 220px at 18% 22%, rgba(255, 184, 108, 0.18), transparent 70%),
radial-gradient(320px 220px at 82% 26%, rgba(110, 231, 255, 0.14), transparent 72%);
filter: blur(18px);
opacity: 0.95;
pointer-events: none;
}
.tv-frame {
position: relative;
border-radius: 18px;
padding: 12px;
background:
linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.22));
border: 1px solid rgba(255, 255, 255, 0.12);
}
.mount {
aspect-ratio: 16 / 9;
width: 100%;
border-radius: 12px;
overflow: hidden;
background: #000;
border: 1px solid rgba(255, 255, 255, 0.14);
}
.canvas {
width: 100%;
height: 100%;
display: block;
}
.tv-scanlines {
position: absolute;
inset: 12px;
border-radius: 12px;
background: repeating-linear-gradient(
to bottom,
rgba(255, 255, 255, 0.03),
rgba(255, 255, 255, 0.03) 1px,
rgba(0, 0, 0, 0.00) 3px,
rgba(0, 0, 0, 0.00) 6px
);
mix-blend-mode: overlay;
pointer-events: none;
opacity: 0.25;
}
.foot {
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: space-between;
gap: 12px;
padding: 10px 2px 0;
color: var(--faint);
font-size: 12px;
}
.footer a {
color: var(--ink-muted);
text-decoration: none;
}
.footer a:hover {
color: var(--ink);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(4px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 720px) {
.top {
flex-direction: column;
@media (max-width: 900px) {
.row {
grid-template-columns: 1fr;
align-items: stretch;
}
.nav {
justify-content: flex-start;
.share {
grid-template-columns: 1fr;
}
.badge {
display: none;
}
.foot {
flex-direction: column;
}
}