Compare commits

...
Author SHA1 Message Date
MoepchiandClaude Opus 5.5 bbb44b3eaa fix(gateway): don't let clients pick their IP behind TRUST_PROXY
TRUST_PROXY=1 trusted CF-Connecting-IP and the first X-Forwarded-For
entry, both of which a client can send itself when the proxy in front
isn't Cloudflare (nginx's $proxy_add_x_forwarded_for only appends), so
per-IP limits could be sidestepped. Now TRUST_PROXY=1 takes the last
X-Forwarded-For entry (the one the proxy appended), and the new
TRUST_PROXY=cloudflare takes only CF-Connecting-IP. The bundled compose
file (cloudflared) switches to cloudflare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-05 18:31:13 +00:00
MoepchiandClaude Opus 5.5 bda908029b docs: link the wiki's full environment variable list from the README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-05 18:14:27 +00:00
MoepchiandClaude Opus 5.5 45e4af026f feat: offer ALLOWED_SERVERS as a dropdown or locked address field
With ALLOWED_SERVERS set, the gateway now passes the list to the web client
it serves, and the connect dialog shows a dropdown of those servers instead
of a free-text address, or a locked field when only one is allowed.
SERVER_PICKER=0 keeps the plain text field; lists with *. wildcards can't be
enumerated and keep it too. Entries may now carry a port, which is the
address offered in the dialog (the allowlist still ignores ports).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-05 15:06:45 +00:00
MoepchiandClaude Opus 5.5 ef0e3fad7d feat: more BBCode tags, basic Markdown and an opt-in for chat images
Chat now renders [size], [left]/[center]/[right], [list]/[*], [hr] and
[noparse] plus the Markdown TS6 sends (emphasis, code, links, images,
quotes, lists, headings, rules, escapes). [img] stays a link unless
"Load images in chat" is enabled in Options -> Application (off by
default, since loading reveals the reader's IP to the image host).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-04 11:09:05 +00:00
MoepchiandClaude Opus 5.5 839e26e4a3 feat: send links as [URL]...[/URL] like the native clients
Native TeamSpeak clients wrap links in [URL] tags when sending and only
link tagged ones, so a bare URL typed in the web client stayed plain
text for them. Chat and offline messages now wrap bare http(s) URLs;
links that are already tagged are left alone.

Also stops the collected-URLs list from picking up "[/URL]" as part of
a link, by sharing the renderer's URL pattern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-04 10:32:10 +00:00
MoepchiandClaude Opus 5.5 e37e090ab2 feat: render BBCode in chat messages
Server, channel and private chat now render [b] [i] [u] [s] [color]
[url] (and [img] as a plain link), and bare http(s) URLs become links -
the welcome message's [URL]...[/URL] showed up as raw text before.
Built as React elements, so message text can't inject markup; only
http(s) links are allowed and [color] only takes a name or hex value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-04 10:29:05 +00:00
MoepchiandClaude Opus 5.5 9b836d5830 Fix server-edited log spam and chat panel growing with its lines
The 20s servergetvariables poll is answered with notifyserverupdated,
which tsclientlib applies as a PropertyChanged per field even when
nothing changed - so every poll logged "server settings changed".
Only log for notifyserveredited, the one that carries an invoker.

In the classic design .ts-chat-panel lacked min-height: 0, so the
message list grew with every line instead of scrolling, pushing the
chat input off-screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-04 09:33:33 +00:00
MoepchiandClaude Opus 5.5 d36b94a496 feat: arrow-key tree and menus, real buttons, contrast fixes
Accessibility stage 2.

- The channel tree is an ARIA tree with one Tab stop. Up/Down/Home/End walk
  the visible rows, Left/Right collapse, expand, or jump to parent and first
  child, and selection follows focus. The server row is focusable too.
- Menu bar entries are buttons with aria-expanded. Dropdown and context
  menus focus their first item on open, move with the arrow keys (except
  inside the volume slider), and Escape returns focus to the opener.
- Bookmark and contact list items, chat tabs and server tabs work from the
  keyboard (Delete closes a tab, since its × can't be a nested button).
- <main> landmark and a level-1 heading for screen-reader navigation.

An axe-core scan of the connected UI in every built-in design turned up
contrast failures, three of them real bugs: the active server tab, the
update toast and the feedback bubble sit on a fixed dark background but used
the theme's text colour, so the light theme showed dark-on-dark text. Also
darkens the light theme's muted text, the donate button, and lifts
GreenTeaSpeak's muted grey to 4.5:1 (its selection colour stays native).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-10-04 09:19:24 +00:00
15 changed files with 662 additions and 116 deletions

No files matched your search

+5 -4
View File
@@ -82,7 +82,7 @@ not need to be installed on the same machine, modified, or operated by you.
| 🌗 **Dark / light theme** | Clean, modern UI that adapts to your preference |
| 🔁 **Multi-join (server tabs)** | Several connections in parallel — one tab per server, like GreenTeaSpeak 2. Audio stays on the active tab |
| 🔁 **Seamless reconnect** | Switch or add connections mid-session without tearing down unrelated tabs; dropped connections come back on their own, with the channel tree intact |
| ⌨️ **Keyboard basics** | Tab through the tree (Enter joins, context-menu key opens the menu), focus-trapped dialogs, labelled toolbar buttons |
| ⌨️ **Keyboard & screen readers** | Arrow keys through the channel tree (exposed as an ARIA tree) and through menus, Enter joins, context-menu key opens the menu; focus-trapped dialogs, labelled toolbar buttons |
| 🍵 **GreenTeaSpeak support** | Connects to real GreenTeaSpeak servers (not just TS3/TS6/TeaSpeak), plus an optional GTS-styled UI chrome (dark panels, gold menu bar, connection-tab strip) alongside the default look |
| 🖥️ **Screen streaming to/from TS6** | <sub>**ALPHA · UNSTABLE**</sub> Share your screen to native TeamSpeak 6 clients and watch theirs. Built on TS6's undocumented Stream/Call protocol — expect it to break; see [Roadmap](ROADMAP.md) |
@@ -187,7 +187,7 @@ The **Design Store** (browse/upload community themes) points at the maintainer's
#### Environment variables
All optional; add them under `environment:` in your compose override next to `PORT`.
All optional; add them under `environment:` in your compose override next to `PORT`. These are the common ones - the full list (logging, feedback form, Design Store details, build-time variables) is on the wiki's [Configuration & Environment Variables](https://github.com/Moepchi/webspeak3/wiki/Configuration-and-Environment-Variables) page.
| Variable | Default | Purpose |
|---|---|---|
@@ -201,12 +201,13 @@ All optional; add them under `environment:` in your compose override next to `PO
| `STORE_DATA_FILE` | `store-themes.json` in the container's working dir | Where submitted themes (including screenshots) are stored. Mount a volume over this path if they should survive a container recreate. |
| `STORE_ALLOWED_ORIGIN` | `*` | CORS origin allowed to call the store endpoint, if you want to restrict it to your own frontend's origin. |
| `STORE_ADMIN_TOKEN` | unset | Bearer token for moderation. New submissions wait as "pending" until approved on the review page at `/api/store/admin` (enter the token there); the token holder's own submissions and the reserved author name(s) skip the queue. Without it, nothing ever gets published. Submitted CSS is also checked server-side: no `@import`/`@font-face`, no external `url()` — only inline `data:` images. |
| `ALLOWED_SERVERS` | unset (any server) | Comma-separated list of server addresses this gateway is allowed to connect to (e.g. `ts.example.com,*.example.net`). A port is matched separately from the host, so listing `ts.example.com` allows any port on it. An entry starting with `*.` matches any subdomain (`*.example.com` allows `ts.example.com`, not `example.com` itself - list that separately too if it should also be reachable). Locks a self-hosted instance down to specific server(s) instead of acting as a general "connect anywhere" client; a rejected `connect` gets an error back before any connector process is even spawned. |
| `ALLOWED_SERVERS` | unset (any server) | Comma-separated list of server addresses this gateway is allowed to connect to (e.g. `ts.example.com,*.example.net`). A port is matched separately from the host, so listing `ts.example.com` allows any port on it. An entry starting with `*.` matches any subdomain (`*.example.com` allows `ts.example.com`, not `example.com` itself - list that separately too if it should also be reachable). Locks a self-hosted instance down to specific server(s) instead of acting as a general "connect anywhere" client; a rejected `connect` gets an error back before any connector process is even spawned. An entry may carry a port (`ts.example.com:9988`): it still allows every port, but that's the address the connect dialog offers (see `SERVER_PICKER`). |
| `SERVER_PICKER` | on | With `ALLOWED_SERVERS` set (and no `*.` entries in it), the connect dialog's address field becomes a dropdown of those servers, or a locked field if there's only one. Set to `0` for the plain text field instead. Only works when the gateway serves the web client itself (the Docker image does). |
| `ALLOW_PRIVATE_TARGETS` | off | By default the gateway refuses to connect to private/internal addresses (loopback, `10.x`, `192.168.x`, CGNAT, link-local, …), no matter how they were reached (IP, DNS, SRV, TSDNS, nickname, file-transfer redirect), so it can't be abused to probe the network it runs in. **If your TeamSpeak server is on the same LAN as the gateway, set this to `1`.** |
| `TURN_URLS` | unset | Comma-separated TURN URLs (e.g. `turn:turn.example.com:3478`) offered to browsers for screen streams, for viewers or publishers behind NATs where direct P2P fails. Pair with `TURN_SECRET` (coturn's `use-auth-secret`; each browser gets its own credential valid for 24 h) or with static `TURN_USERNAME` / `TURN_CREDENTIAL`, which every visitor can read. |
| `ALLOWED_ORIGINS` | unset (any origin) | Comma-separated list of web origins allowed to open `/ws` (e.g. `https://client.example.com`). Stops other websites from silently using your gateway as their relay. |
| `MAX_CONNECTIONS_PER_IP` / `MAX_CONNECTIONS` | `10` / `300` | Concurrent `/ws` connections per client IP and in total (each can hold a live TeamSpeak session). `0` disables a limit. |
| `TRUST_PROXY` | off | Set to `1` when the gateway is **only** reachable through a reverse proxy/tunnel (e.g. cloudflared): per-IP limits then use `CF-Connecting-IP` / `X-Forwarded-For` instead of the proxy's own address. Don't set it on a directly exposed gateway - clients could then spoof their IP. |
| `TRUST_PROXY` | off | Only when the gateway is reachable **solely** through a proxy/tunnel, so per-IP limits see the real client instead of the proxy: `cloudflare` (Cloudflare Tunnel or proxy) uses `CF-Connecting-IP`; `1` (your own nginx/Caddy/Traefik) uses the last `X-Forwarded-For` entry, the one your proxy appended. Don't set it on a directly exposed gateway - clients could then fake their IP. |
> **Trust model:** the gateway speaks the TeamSpeak protocol on the user's behalf, so whoever runs it necessarily handles their identity key, server/channel passwords and privilege keys (they're kept out of process listings, but the operator can still see them). Only use gateways you trust, and serve them over HTTPS/WSS (`TLS_CERT`/`TLS_KEY` or a TLS-terminating proxy) - plain HTTP exposes all of that on the wire. File uploads are limited to 24 MiB, downloads to 25 MiB.
+9 -6
View File
@@ -49,14 +49,17 @@ This roadmap is intentionally outcome-focused. It does not promise fixed dates.
Basics are in place: the UI language sets the document's `lang`/`dir`,
dialogs take focus on open, keep Tab inside, close on Escape, and hand focus
back; toolbar icon buttons are labelled; channel and client rows are
focusable (Enter joins a channel or opens a private chat, Space selects,
the context-menu key or Shift+F10 opens the menu with focus in it). Still to do:
back; toolbar icon and menu bar buttons are real, labelled buttons. The
channel tree is an ARIA tree with one Tab stop: arrow keys walk it (selection
follows focus), Left/Right collapse, expand and jump to parent or child,
Enter joins a channel or opens a private chat, and the context-menu key or
Shift+F10 opens the menu. Menus take focus on open, move with the arrow keys,
and Escape hands focus back to the button that opened them. An axe-core scan
of the connected UI is clean in every built-in design except for landmark
best practices and GreenTeaSpeak's native selection colours. Still to do:
- Replace the remaining clickable `<div>`s with real buttons
- Arrow-key navigation through the tree and menus
- Do a full screen-reader pass (NVDA/VoiceOver) through a real connect
session to find what else is missing
session to find what else is missing (e.g. announcing who is talking)
### Deployment experience
+4
View File
@@ -584,6 +584,10 @@ fn log_book_event(con: &data::Connection, event: &BookEvent) {
| PropertyId::ServerCodecEncryptionMode
| PropertyId::ServerTempChannelDefaultDeleteDelay
| PropertyId::ServerPrioritySpeakerDimmModificator,
// Only notifyserveredited carries an invoker; the 20s
// servergetvariables poll answers with notifyserverupdated, which
// rewrites every field (changed or not) without one.
invoker: Some(_),
..
} => {
emit_server_log(ServerLogEntry::ServerEdited);
+3 -2
View File
@@ -9,8 +9,9 @@ services:
# This file publishes no port - the gateway is only reachable through
# the cloudflared tunnel below, so the client IP it forwards can be
# trusted (per-IP limits would otherwise see every user as the tunnel).
# Remove this if you publish a port directly instead.
- TRUST_PROXY=1
# Remove this if you publish a port directly instead; behind your own
# reverse proxy use TRUST_PROXY=1.
- TRUST_PROXY=cloudflare
# Nothing in here needs Linux capabilities (unprivileged port, plain
# TCP/UDP sockets), so drop them all.
cap_drop: [ALL]
+10 -2
View File
@@ -54,8 +54,8 @@ function isServerAllowed(host: unknown): boolean {
return ALLOWED_SERVERS.some((entry) => {
// "*.example.com" matches any subdomain (TLS-wildcard-style: not the
// bare apex itself - list that separately if it should be allowed too).
if (entry.startsWith("*.")) return target.endsWith(entry.slice(1));
return target === entry;
if (entry.startsWith("*.")) return target.endsWith(stripPort(entry).slice(1));
return target === stripPort(entry);
});
}
@@ -134,9 +134,17 @@ function turnServers() {
// issue #12): set on the container, these end up in the served index.html as
// <meta> tags the client reads at startup, so changing them needs no rebuild.
// Meta tags rather than an inline script, which CONTENT_SECURITY_POLICY forbids.
// The allowlist goes along so the client can offer it as a dropdown (or a
// locked field for a single entry) instead of a free-text address; not with
// wildcards, which can't be listed, nor with SERVER_PICKER=0.
const SERVER_PICKER =
process.env.SERVER_PICKER !== "0" && !ALLOWED_SERVERS.some((e) => e.startsWith("*."))
? ALLOWED_SERVERS.join(",")
: undefined;
const RUNTIME_CONFIG_META = Object.entries({
"webspeak3-default-server": process.env.DEFAULT_SERVER,
"webspeak3-default-channel": process.env.DEFAULT_CHANNEL,
"webspeak3-allowed-servers": SERVER_PICKER,
})
.flatMap(([name, value]) =>
value ? [`<meta name="${name}" content="${value.replace(/[&"<>]/g, (c) => `&#${c.charCodeAt(0)};`)}">`] : [],
+12 -11
View File
@@ -1,19 +1,20 @@
import type { IncomingMessage } from "node:http";
// Behind a reverse proxy / tunnel (e.g. cloudflared) every request arrives
// from the proxy's own address, so per-IP limits would lump all users into
// one bucket. TRUST_PROXY=1 makes us read the client IP the proxy reports
// instead - only set it when the gateway is reachable *solely* through that
// proxy, otherwise anyone can send the header and pick their own "IP".
const TRUST_PROXY = process.env.TRUST_PROXY === "1";
// Behind a reverse proxy / tunnel every request arrives from the proxy's own
// address, so per-IP limits would lump all users into one bucket. Only set
// TRUST_PROXY when the gateway is reachable *solely* through that proxy:
// - "cloudflare": CF-Connecting-IP, which Cloudflare always sets itself.
// - "1": the last X-Forwarded-For entry, the one our own proxy appended;
// anything before it came from the client and can be made up.
const TRUST_PROXY = process.env.TRUST_PROXY;
export function clientIp(req: IncomingMessage): string {
if (TRUST_PROXY) {
if (TRUST_PROXY === "cloudflare") {
const cf = req.headers["cf-connecting-ip"];
if (typeof cf === "string" && cf) return cf.trim();
const xff = req.headers["x-forwarded-for"];
const first = (Array.isArray(xff) ? xff[0] : xff)?.split(",")[0]?.trim();
if (first) return first;
if (typeof cf === "string" && cf.trim()) return cf.trim();
} else if (TRUST_PROXY === "1") {
const last = String(req.headers["x-forwarded-for"] ?? "").split(",").at(-1)?.trim();
if (last) return last;
}
return (req.socket.remoteAddress ?? "unknown").replace(/^::ffff:/, "");
}
+82 -8
View File
@@ -12,7 +12,7 @@
--border: #b7bcc3;
--border-soft: #d3d7db;
--text: #1a1a1a;
--text-muted: #888;
--text-muted: #6b6b6b;
--accent: #2b4a6b;
--input-bg: #ffffff;
--input-text: #1a1a1a;
@@ -2016,11 +2016,32 @@
box-sizing: border-box;
}
.ts-app .ts-row:focus-visible {
.ts-app .ts-row:focus-visible,
.ts-plain-button:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -2px;
}
/* A real <button> that looks like the <span>/<li> text it replaced. :where()
keeps this at zero specificity, so every theme rule still wins. */
:where(.ts-plain-button) {
font: inherit;
color: inherit;
background: none;
border: 0;
padding: 0;
margin: 0;
cursor: inherit;
text-align: inherit;
}
:where(li > .ts-plain-button) {
display: block;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.ts-tree-search {
box-sizing: border-box;
width: 100%;
@@ -2372,6 +2393,8 @@
display: flex;
flex-direction: column;
min-width: 0;
/* without this the panel grows with its lines instead of scrolling them */
min-height: 0;
}
.ts-chat-tabs {
@@ -2429,6 +2452,55 @@
word-break: break-word;
}
.ts-chat-bubble a {
color: var(--accent);
text-decoration: underline;
}
.ts-chat-bubble code {
font-family: ui-monospace, monospace;
font-size: 0.95em;
padding: 0 0.25em;
border: 1px solid var(--border-soft);
border-radius: 3px;
}
.ts-bb-list {
margin: 0.15em 0;
padding-left: 1.6em;
}
.ts-bb-quote {
margin: 0.15em 0;
padding-left: 0.6em;
border-left: 3px solid var(--border-soft);
}
.ts-bb-hr {
border: 0;
border-top: 1px solid var(--border-soft);
margin: 0.3em 0;
}
.ts-bb-h {
font-weight: bold;
font-size: 1.1em;
}
.ts-bb-h1 {
font-size: 1.4em;
}
.ts-bb-h2 {
font-size: 1.2em;
}
.ts-bb-img {
max-width: 100%;
max-height: 240px;
vertical-align: middle;
}
.ts-chat-from {
font-weight: 600;
color: var(--accent);
@@ -3847,6 +3919,8 @@
pointer-events: none;
}
/* No theme defines --panel-bg, so the update toast and the feedback bubble
are always dark: their text colors are fixed, not the theme's. */
.ts-update-toast {
position: fixed;
left: 50%;
@@ -3857,7 +3931,7 @@
align-items: center;
gap: 0.6rem;
background: var(--panel-bg, #23262e);
color: var(--text, #eee);
color: #eee;
border: 1px solid var(--border);
border-radius: 0.5rem;
padding: 0.6rem 0.7rem 0.6rem 0.9rem;
@@ -3877,7 +3951,7 @@
.ts-update-toast-dismiss {
background: transparent !important;
color: var(--text-muted, #999) !important;
color: #aaa !important;
border: none !important;
padding: 0 0.2rem !important;
font-size: 12px;
@@ -3935,7 +4009,7 @@
padding: 0 0.85rem;
border-radius: 999px;
border: 1px solid rgba(255, 255, 255, 0.18);
background: #ff5e5b;
background: #d6403d; /* Ko-fi red, darkened to 4.5:1 for the white label */
color: #fff;
font-size: 12px;
font-weight: 600;
@@ -3947,7 +4021,7 @@
}
.ts-donate-fab:hover {
background: #ff4b47;
background: #c4362f;
transform: scale(1.06);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
@@ -3961,7 +4035,7 @@
position: relative;
max-width: 13rem;
background: var(--panel-bg, #23262e);
color: var(--text, #eee);
color: #eee;
border: 1px solid var(--border);
border-radius: 0.6rem;
padding: 0.5rem 0.7rem;
@@ -3993,7 +4067,7 @@
border-radius: 50%;
border: 1px solid var(--border);
background: var(--panel-bg, #23262e);
color: var(--text-muted, #999);
color: #aaa;
font-size: 10px;
line-height: 1;
display: flex;
+222 -62
View File
@@ -50,6 +50,57 @@ function useBackdropDismiss(onDismiss: () => void) {
},
};
}
/** Callback ref for a dropdown menu: focus its first item when it opens.
* Module-level so React calls it once per mount, not on every render. */
function focusFirstItem(el: HTMLElement | null) {
el?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
}
/** onKeyDown for dropdown and context menus: Up/Down/Home/End move between
* items, and Escape puts focus back on the button that opened the menu
* before the window-level Escape listener closes it. */
function handleMenuKeyDown(e: React.KeyboardEvent<HTMLElement>) {
if (e.key === "Escape") {
e.currentTarget.parentElement?.querySelector<HTMLElement>(":scope > button[aria-expanded]")?.focus();
return;
}
// Arrows belong to sliders, text fields and selects (the volume slider).
if ((e.target as HTMLElement).matches("input:not([type=checkbox]), select, textarea")) return;
const items = [...e.currentTarget.querySelectorAll<HTMLElement>(FOCUSABLE)];
const i = items.indexOf(document.activeElement as HTMLElement);
const next =
e.key === "ArrowDown" ? items[(i + 1) % items.length]
: e.key === "ArrowUp" ? items[(i - 1 + items.length) % items.length]
: e.key === "Home" ? items[0]
: e.key === "End" ? items[items.length - 1]
: undefined;
if (!next) return;
e.preventDefault();
next.focus();
}
/** onKeyDown for the tree panel (server row + channel tree): Up/Down/Home/End
* walk the visible rows, Left goes to the parent row and Right into an open
* channel. A channel row handles Left/Right itself first when it can
* collapse or expand, and marks the event as handled. */
function handleTreeKeyDown(e: React.KeyboardEvent<HTMLElement>) {
const row = e.target as HTMLElement;
if (e.defaultPrevented || !row.classList.contains("ts-row")) return;
const rows = [...e.currentTarget.querySelectorAll<HTMLElement>(".ts-row[tabindex]")];
const i = rows.indexOf(row);
const next =
e.key === "ArrowDown" ? rows[i + 1]
: e.key === "ArrowUp" ? rows[i - 1]
: e.key === "Home" ? rows[0]
: e.key === "End" ? rows[rows.length - 1]
: e.key === "ArrowLeft" ? (row.closest("ul")?.closest("li")?.querySelector<HTMLElement>(":scope > .ts-row") ?? rows[0])
: e.key === "ArrowRight" ? row.closest("li")?.querySelector<HTMLElement>(":scope > ul .ts-row")
: undefined;
if (next === undefined && !["ArrowDown", "ArrowUp", "ArrowRight"].includes(e.key)) return;
e.preventDefault();
next?.focus();
}
import {
AudioPlayer,
MicCapture,
@@ -92,6 +143,7 @@ import {
GreenteaSpeakChrome,
isGreenteaSpeakTheme,
} from "./themes/greenteaspeak";
import { BARE_URL_REGEX, renderBbcode, wrapUrls } from "./lib/bbcode";
import { parseChannelName, spacerDisplayName } from "./lib/spacer";
import {
applyParkedGatewayEvent,
@@ -205,6 +257,9 @@ const runtimeConfig = (name: string) =>
document.querySelector<HTMLMetaElement>(`meta[name="webspeak3-${name}"]`)?.content;
const DEFAULT_SERVER = runtimeConfig("default-server") || import.meta.env.VITE_DEFAULT_SERVER || null;
const DEFAULT_CHANNEL = runtimeConfig("default-channel") || import.meta.env.VITE_DEFAULT_CHANNEL || "";
// The gateway admin's ALLOWED_SERVERS (unless SERVER_PICKER=0): one server
// locks the address field to it, several turn it into a dropdown.
const SERVER_CHOICES = runtimeConfig("allowed-servers")?.split(",").filter(Boolean) ?? [];
// Terms of use, own-hosted instance only (see TODO.md #2/#7.1). Versioned so
// a rule change can re-surface the modal: bump TOS_VERSION and everyone who
@@ -504,6 +559,8 @@ const AWAY_PRESETS_KEY = "webspeak3:away-presets";
/** "off" hides the server banner: it loads from whatever host the server
* admin picked, which then sees the viewer's IP (review S12). */
const SERVER_BANNER_KEY = "webspeak3:server-banner";
// Off by default: an inline chat image loads from whatever host the sender picked.
const CHAT_IMAGES_KEY = "webspeak3:chat-images";
const DISCONNECT_MESSAGE_KEY = "webspeak3:disconnect-message";
const COLLECTED_URLS_KEY = "webspeak3:collected-urls";
@@ -523,8 +580,6 @@ function loadCollectedUrls(): CollectedUrl[] {
}
}
const URL_REGEX = /https?:\/\/[^\s<>"]+/g;
type LogLevel = "critical" | "error" | "warning" | "info" | "debug";
interface ClientLogEntry {
@@ -953,6 +1008,7 @@ function ChannelTree({
selected,
sessionKey,
expandAll,
level = 1,
onSelectItem,
onSwitchChannel,
onOpenPrivateChat,
@@ -973,6 +1029,8 @@ function ChannelTree({
sessionKey: string;
/** While searching: show every match, ignoring channels the user collapsed. */
expandAll?: boolean;
/** aria-level of this list's channels; their clients sit one deeper. */
level?: number;
onSelectItem: (item: SelectedItem) => void;
onSwitchChannel: (channelId: number) => void;
onOpenPrivateChat: (clientId: number, clientName: string) => void;
@@ -1006,25 +1064,38 @@ function ChannelTree({
};
return (
<ul className={`ts-tree-list${parent === 0 ? " ts-tree-list-root" : ""}`}>
{children.map((channel) => {
<ul
className={`ts-tree-list${parent === 0 ? " ts-tree-list-root" : ""}`}
role={parent === 0 ? "tree" : "group"}
aria-label={parent === 0 ? t("tree.label") : undefined}
>
{children.map((channel, index) => {
const isRoot = parent === 0;
const spacer = spacerDisplayName(channel.name, isRoot);
const channelClients = clients.filter((c) => c.channel === channel.id);
const hasSubChannels = channels.some((c) => c.parent === channel.id);
const hasChildren = channelClients.length > 0 || hasSubChannels;
const isCollapsed = !expandAll && collapsed.has(channel.id);
const isSelected = selected?.type === "channel" && selected.id === channel.id;
// One Tab stop for the whole tree (arrow keys move inside it, see
// handleTreeKeyDown): the selected row, or the first channel while
// nothing in the tree is selected.
const isTabStop = isSelected || (parent === 0 && index === 0 && selected?.type !== "channel" && selected?.type !== "client");
const spacerClass = spacer.isSpacer
? ` ts-spacer ts-spacer-align-${spacer.alignment}${spacer.isLine ? " ts-spacer-line" : ""}${
spacer.isBoxArt ? " ts-spacer-boxart" : ""
}`
: "";
return (
<li key={channel.id}>
<li key={channel.id} role="none">
<div
className={`ts-row ts-channel-row${spacerClass}${
selected?.type === "channel" && selected.id === channel.id ? " ts-row-selected" : ""
isSelected ? " ts-row-selected" : ""
}${dragOverChannelId === channel.id ? " ts-drop-target" : ""}`}
role="treeitem"
aria-level={level}
aria-selected={isSelected}
aria-expanded={hasChildren ? !isCollapsed : undefined}
onClick={() => {
onSelectItem({ type: "channel", id: channel.id });
// Manual double-click: native dblclick is often lost when the first
@@ -1045,7 +1116,10 @@ function ChannelTree({
onSwitchChannel(channel.id);
}}
onContextMenu={(e) => onChannelContextMenu(e, channel.id, channel.name)}
tabIndex={0}
tabIndex={isTabStop ? 0 : -1}
onFocus={(e) => {
if (e.target === e.currentTarget && !isSelected) onSelectItem({ type: "channel", id: channel.id });
}}
onKeyDown={(e) => {
if (e.target !== e.currentTarget) return;
if (e.key === "Enter") onSwitchChannel(channel.id);
@@ -1081,7 +1155,7 @@ function ChannelTree({
className={`ts-tree-expander${hasChildren ? "" : " ts-tree-expander-empty"}${
isCollapsed ? " ts-tree-expander-collapsed" : ""
}`}
aria-label={isCollapsed ? t("tree.expand") : t("tree.collapse")}
aria-hidden="true"
tabIndex={-1}
onMouseDown={(e) => {
// Keep focus on the row so a nearby double-click still joins.
@@ -1112,9 +1186,11 @@ function ChannelTree({
)}
</div>
{!isCollapsed && (
<ul className="ts-tree-list">
{channelClients.map((c) => (
<li key={c.id}>
<ul className="ts-tree-list" role="group">
{channelClients.map((c) => {
const clientSelected = selected?.type === "client" && selected.id === c.id;
return (
<li key={c.id} role="none">
<div
className={`ts-row ts-client-row${c.id === ownClientId ? " ts-self" : ""}${
talkers.has(c.id) &&
@@ -1123,7 +1199,10 @@ function ChannelTree({
c.inputHardwareEnabled
? " ts-talking"
: ""
}${selected?.type === "client" && selected.id === c.id ? " ts-row-selected" : ""}`}
}${clientSelected ? " ts-row-selected" : ""}`}
role="treeitem"
aria-level={level + 1}
aria-selected={clientSelected}
draggable
onDragStart={(e) => {
const payload: ClientDragPayload = {
@@ -1141,7 +1220,10 @@ function ChannelTree({
c.id === ownClientId ? undefined : () => onOpenPrivateChat(c.id, c.name)
}
onContextMenu={(e) => onClientContextMenu(e, c.id, c.name, c.id === ownClientId)}
tabIndex={0}
tabIndex={clientSelected ? 0 : -1}
onFocus={(e) => {
if (e.target === e.currentTarget && !clientSelected) onSelectItem({ type: "client", id: c.id });
}}
onKeyDown={(e) => {
if (e.key === "Enter" && c.id !== ownClientId) onOpenPrivateChat(c.id, c.name);
else if (e.key === " ") onSelectItem({ type: "client", id: c.id });
@@ -1211,7 +1293,8 @@ function ChannelTree({
</span>
</div>
</li>
))}
);
})}
</ul>
)}
{!isCollapsed && (
@@ -1226,6 +1309,7 @@ function ChannelTree({
selected={selected}
sessionKey={sessionKey}
expandAll={expandAll}
level={level + 1}
onSelectItem={onSelectItem}
onSwitchChannel={onSwitchChannel}
onOpenPrivateChat={onOpenPrivateChat}
@@ -1575,7 +1659,20 @@ function ConnectDialog({
<div className="ts-dialog-row">
<label className="ts-dialog-field ts-dialog-field-grow">
{t("connect.serverAddress")}
<input autoFocus value={host} onChange={(e) => onHostChange(e.target.value)} />
{SERVER_CHOICES.length > 1 ? (
<select autoFocus value={host} onChange={(e) => onHostChange(e.target.value)}>
{SERVER_CHOICES.map((s) => (
<option key={s}>{s}</option>
))}
</select>
) : (
<input
autoFocus
value={host}
disabled={SERVER_CHOICES.length === 1}
onChange={(e) => onHostChange(e.target.value)}
/>
)}
</label>
<label className="ts-dialog-field">
{t("connect.serverPassword")}
@@ -2612,7 +2709,9 @@ function FavoritesDialog({
className={`ts-favorites-list-item${f.id === selectedId ? " ts-favorites-list-item-selected" : ""}`}
onClick={() => setSelectedId(f.id)}
>
{f.bookmarkName || t("favorites.unnamed")}
<button type="button" className="ts-plain-button" aria-current={f.id === selectedId}>
{f.bookmarkName || t("favorites.unnamed")}
</button>
</li>
))}
</ul>
@@ -4928,9 +5027,11 @@ function ContactsDialog({
className={`ts-contacts-list-item ts-contacts-category-${c.category}${c.uid === selectedUid ? " ts-contacts-list-item-selected" : ""}`}
onClick={() => setSelectedUid(c.uid)}
>
{onlineClients.some((cl) => cl.uid === c.uid) && <span className="ts-contacts-online-dot" />}
{displayName(c)}
{c.ignored && " 🚫"}
<button type="button" className="ts-plain-button" aria-current={c.uid === selectedUid}>
{onlineClients.some((cl) => cl.uid === c.uid) && <span className="ts-contacts-online-dot" />}
{displayName(c)}
{c.ignored && " 🚫"}
</button>
</li>
))}
{draft.length === 0 && <li className="ts-contacts-list-empty">{t("contacts.empty")}</li>}
@@ -5342,9 +5443,13 @@ function AufnahmePanel({ audio }: { audio: AudioSettings }) {
function AnwendungPanel({
showServerBanner,
onShowServerBannerChange,
chatImages,
onChatImagesChange,
}: {
showServerBanner: boolean;
onShowServerBannerChange: (on: boolean) => void;
chatImages: boolean;
onChatImagesChange: (on: boolean) => void;
}) {
const t = useT();
const { langPref, setLangPref } = useLanguage();
@@ -5372,6 +5477,11 @@ function AnwendungPanel({
{t("app.serverBanner")}
</label>
<p className="ts-options-hint">{t("app.serverBanner.hint")}</p>
<label className="ts-options-checkbox">
<input type="checkbox" checked={chatImages} onChange={(e) => onChatImagesChange(e.target.checked)} />
{t("app.chatImages")}
</label>
<p className="ts-options-hint">{t("app.chatImages.hint")}</p>
</>
);
}
@@ -6163,6 +6273,8 @@ function OptionsDialog({
onDeleteCustomTheme,
showServerBanner,
onShowServerBannerChange,
chatImages,
onChatImagesChange,
}: {
section: string;
onSectionChange: (id: string) => void;
@@ -6175,6 +6287,8 @@ function OptionsDialog({
onDeleteCustomTheme: (id: string) => void;
showServerBanner: boolean;
onShowServerBannerChange: (on: boolean) => void;
chatImages: boolean;
onChatImagesChange: (on: boolean) => void;
}) {
const t = useT();
const active = OPTIONS_SECTIONS.find((s) => s.id === section) ?? OPTIONS_SECTIONS[0];
@@ -6203,7 +6317,12 @@ function OptionsDialog({
</div>
<div className="ts-options-content">
{active.id === "anwendung" ? (
<AnwendungPanel showServerBanner={showServerBanner} onShowServerBannerChange={onShowServerBannerChange} />
<AnwendungPanel
showServerBanner={showServerBanner}
onShowServerBannerChange={onShowServerBannerChange}
chatImages={chatImages}
onChatImagesChange={onChatImagesChange}
/>
) : active.id === "wiedergabe" ? (
<WiedergabePanel audio={audio} />
) : active.id === "aufnahme" ? (
@@ -6554,6 +6673,7 @@ function AppInner() {
const [serverLicenseId, setServerLicenseId] = useState(0);
const [serverBannerUrl, setServerBannerUrl] = useState("");
const [showServerBanner, setShowServerBanner] = useState(() => localStorage.getItem(SERVER_BANNER_KEY) !== "off");
const [chatImages, setChatImages] = useState(() => localStorage.getItem(CHAT_IMAGES_KEY) === "on");
const [serverWelcomeMessage, setServerWelcomeMessage] = useState("");
const [serverEditOpen, setServerEditOpen] = useState(false);
const [serverProtocolLogOpen, setServerProtocolLogOpen] = useState(false);
@@ -6877,7 +6997,7 @@ function AppInner() {
};
const recordUrlsFromMessage = (message: string, sender: string) => {
const found = message.match(URL_REGEX);
const found = message.match(BARE_URL_REGEX);
if (!found) return;
const now = Date.now();
setCollectedUrls((prev) => {
@@ -7864,6 +7984,10 @@ function AppInner() {
};
};
// A remembered or favorite host outside the admin's list isn't one of the
// choices; fall back to the first.
const dialogHost = SERVER_CHOICES.length && !SERVER_CHOICES.includes(host) ? SERVER_CHOICES[0] : host;
const handleConnect = (overrides?: {
host?: string;
nickname?: string;
@@ -8906,7 +9030,7 @@ function AppInner() {
}, [chatInput, designTheme, connected]);
const handleSendChat = () => {
const message = chatInput.trim();
const message = wrapUrls(chatInput.trim());
if (!message) return;
if (activeTab === "channel") {
socketRef.current?.send(JSON.stringify({ type: "sendChatMessage", message }));
@@ -9323,7 +9447,7 @@ function AppInner() {
};
const handleSendOfflineMessage = (clientUid: string, subject: string, message: string) => {
socketRef.current?.send(JSON.stringify({ type: "sendOfflineMessage", clientUid, subject, message }));
socketRef.current?.send(JSON.stringify({ type: "sendOfflineMessage", clientUid, subject, message: wrapUrls(message) }));
};
const handleClientContextMenu = (
@@ -9745,6 +9869,7 @@ function AppInner() {
className="ts-icon-button ts-nova-menu-toggle"
onClick={() => setNovaMenuOpen((v) => !v)}
aria-label={t("menu.connections")}
aria-expanded={novaMenuOpen}
>
☰
</button>
@@ -9755,14 +9880,16 @@ function AppInner() {
}`}
>
<div className="ts-menubar-dropdown" ref={connectionsMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={connectionsMenuOpen}
onClick={() => setConnectionsMenuOpen((v) => !v)}
>
{t("menu.connections")}
</span>
</button>
{connectionsMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button
className="ts-menu-item"
disabled={connecting}
@@ -9802,14 +9929,16 @@ function AppInner() {
)}
</div>
<div className="ts-menubar-dropdown" ref={favoritesMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={favoritesMenuOpen}
onClick={() => setFavoritesMenuOpen((v) => !v)}
>
{t("menu.favorites")}
</span>
</button>
{favoritesMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button className="ts-menu-item" onClick={openAddFavorite}>
<span className="ts-menu-item-icon">⭐</span>
<span className="ts-menu-item-label">{t("menu.favorites.add")}</span>
@@ -9838,14 +9967,16 @@ function AppInner() {
)}
</div>
<div className="ts-menubar-dropdown" ref={selfMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={selfMenuOpen}
onClick={() => setSelfMenuOpen((v) => !v)}
>
{t("menu.self")}
</span>
</button>
{selfMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🎙️</span>
<span className="ts-menu-item-label">{t("menu.self.recordingProfile")}</span>
@@ -9942,14 +10073,16 @@ function AppInner() {
)}
</div>
<div className="ts-menubar-dropdown" ref={rightsMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={rightsMenuOpen}
onClick={() => setRightsMenuOpen((v) => !v)}
>
{t("menu.rights")}
</span>
</button>
{rightsMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button
className="ts-menu-item"
onClick={() => {
@@ -10010,14 +10143,16 @@ function AppInner() {
)}
</div>
<div className="ts-menubar-dropdown" ref={extrasMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={extrasMenuOpen}
onClick={() => setExtrasMenuOpen((v) => !v)}
>
{t("menu.extras")}
</span>
</button>
{extrasMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button
className="ts-menu-item"
onClick={() => {
@@ -10185,22 +10320,25 @@ function AppInner() {
)}
</div>
{IS_OWN_HOSTED_INSTANCE && (
<span
className="ts-menubar-item"
<button
type="button"
className="ts-menubar-item ts-plain-button"
onClick={() => setFeedbackOpen(true)}
>
💬 {t("menu.extras.feedback")}
</span>
</button>
)}
<div className="ts-menubar-dropdown" ref={helpMenuRef}>
<span
className="ts-menubar-item ts-menubar-item-active"
<button
type="button"
className="ts-menubar-item ts-menubar-item-active ts-plain-button"
aria-expanded={helpMenuOpen}
onClick={() => setHelpMenuOpen((v) => !v)}
>
{t("menu.help")}
</span>
</button>
{helpMenuOpen && (
<div className="ts-menu">
<div className="ts-menu" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<a
className="ts-menu-item"
href="https://webspeak3.de"
@@ -10319,7 +10457,7 @@ function AppInner() {
▾
</button>
{awayMenuOpen && (
<div className="ts-menu ts-menu-away">
<div className="ts-menu ts-menu-away" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<button
className="ts-menu-item"
onClick={() => {
@@ -10371,7 +10509,7 @@ function AppInner() {
🤫
</button>
{whisperMenuOpen && (
<div className="ts-menu ts-menu-away">
<div className="ts-menu ts-menu-away" ref={focusFirstItem} onKeyDown={handleMenuKeyDown}>
<div className="ts-context-menu-title">{t("whisper.channels")}</div>
{channels.map((ch) => (
<label key={ch.id} className="ts-menu-item">
@@ -10499,7 +10637,7 @@ function AppInner() {
{theme === "dark" ? "☀️" : "🌙"}
</button>
<img src={`${import.meta.env.BASE_URL}logo.png`} alt="" className="ts-app-logo" />
<span className="ts-app-title">WebSpeak3</span>
<span className="ts-app-title" role="heading" aria-level={1}>WebSpeak3</span>
</div>
</div>
@@ -10515,7 +10653,7 @@ function AppInner() {
{connectDialogOpen && (
<ConnectDialog
host={host}
host={dialogHost}
nickname={nickname}
serverPassword={serverPassword}
channelPassword={channelPassword}
@@ -10535,8 +10673,8 @@ function AppInner() {
onServerTypeChange={setServerType}
onActiveIdentityChange={handleActiveIdentityChange}
onToggleExpanded={() => setConnectDialogExpanded((v) => !v)}
onConnect={() => handleConnect()}
onConnectNewTab={() => handleConnect()}
onConnect={() => handleConnect({ host: dialogHost })}
onConnectNewTab={() => handleConnect({ host: dialogHost })}
canOpenNewTab={sessionTabs.length > 0 || connected}
onCancel={novaSplash ? () => {} : () => setConnectDialogOpen(false)}
nova={designTheme === "nova"}
@@ -10832,6 +10970,15 @@ function AppInner() {
/* private mode: setting just doesn't persist */
}
}}
chatImages={chatImages}
onChatImagesChange={(on) => {
setChatImages(on);
try {
localStorage.setItem(CHAT_IMAGES_KEY, on ? "on" : "off");
} catch {
/* private mode: setting just doesn't persist */
}
}}
audio={{
outputDevices,
outputDeviceId,
@@ -11108,6 +11255,7 @@ function AppInner() {
<div
ref={clientContextMenuRef}
className="ts-context-menu"
onKeyDown={handleMenuKeyDown}
style={{ top: clientContextMenu.y, left: clientContextMenu.x }}
>
<div className="ts-context-menu-title">{clientContextMenu.clientName}</div>
@@ -11304,6 +11452,7 @@ function AppInner() {
<div
ref={serverContextMenuRef}
className="ts-context-menu"
onKeyDown={handleMenuKeyDown}
style={{ top: serverContextMenu.y, left: serverContextMenu.x }}
>
<div className="ts-context-menu-title">{serverName || host}</div>
@@ -11406,6 +11555,7 @@ function AppInner() {
<div
ref={channelContextMenuRef}
className="ts-context-menu"
onKeyDown={handleMenuKeyDown}
style={{ top: channelContextMenu.y, left: channelContextMenu.x }}
>
<div className="ts-context-menu-title">{channelContextMenu.channelName}</div>
@@ -11439,15 +11589,19 @@ function AppInner() {
</div>
)}
<div className="ts-body">
<main className="ts-body">
<div className="ts-upper" style={{ height: upperHeight }}>
<div className="ts-tree-panel" style={{ width: treeWidth }}>
<div className="ts-tree-panel" style={{ width: treeWidth }} onKeyDown={handleTreeKeyDown}>
{connected ? (
<>
<div
className={`ts-row ts-server-row${selected?.type === "server" ? " ts-row-selected" : ""}`}
onClick={() => handleSelectItem({ type: "server" })}
onContextMenu={handleServerContextMenu}
tabIndex={0}
onFocus={(e) => {
if (e.target === e.currentTarget && selected?.type !== "server") handleSelectItem({ type: "server" });
}}
>
<ServerIcon />
<span>{serverName || host}</span>
@@ -11541,7 +11695,7 @@ function AppInner() {
className={`ts-chat-line${entry.from === ownClient?.name ? " ts-chat-line-self" : ""}`}
>
<span className="ts-chat-from">{entry.from}:</span>{" "}
<span className="ts-chat-bubble">{entry.message}</span>
<span className="ts-chat-bubble">{renderBbcode(entry.message, { images: chatImages })}</span>
</div>
))
: activeTab === "server"
@@ -11556,7 +11710,7 @@ function AppInner() {
className={`ts-chat-line${entry.from === ownClient?.name ? " ts-chat-line-self" : ""}`}
>
<span className="ts-chat-from">{entry.from}:</span>{" "}
<span className="ts-chat-bubble">{entry.message}</span>
<span className="ts-chat-bubble">{renderBbcode(entry.message, { images: chatImages })}</span>
</div>
)
)
@@ -11565,7 +11719,7 @@ function AppInner() {
<span className="ts-chat-from">
{entry.fromSelf ? t("chat.you") : pmThreads[activeTab].partnerName}:
</span>{" "}
<span className="ts-chat-bubble">{entry.message}</span>
<span className="ts-chat-bubble">{renderBbcode(entry.message, { images: chatImages })}</span>
</div>
))}
<div ref={chatEndRef} />
@@ -11590,9 +11744,15 @@ function AppInner() {
thread.unread ? " ts-chat-tab-unread" : ""
}`}
onClick={() => setActiveTab(thread.partnerId)}
aria-keyshortcuts="Delete"
onKeyDown={(e) => {
// The × can't be its own button inside this one; Delete closes from the keyboard.
if (e.key === "Delete") handleClosePrivateChat(thread.partnerId);
}}
>
{thread.partnerName}
<span
aria-hidden="true"
className="ts-chat-tab-close"
onClick={(e) => {
e.stopPropagation();
@@ -11632,7 +11792,7 @@ function AppInner() {
</button>
</div>
</div>
</div>
</main>
<div className="ts-log">
{log.slice(-50).map((entry, i) => {
+281
View File
@@ -0,0 +1,281 @@
import { Fragment, type ReactNode } from "react";
// TeamSpeak chat text -> React elements (never HTML strings, so message text
// can't inject markup). Understands the TS3/TS6 BBCode tags plus the basic
// Markdown TS6 sends: Markdown is first rewritten into BBCode, then a single
// parser renders both. Unknown tags stay literal, unclosed tags close at the end.
// ponytail: no [table], nested Markdown lists/quotes, ==highlight==, ||spoiler||,
// math or mermaid - add them once people actually send them.
const TAG_REGEX =
/\[(\/?)(b|i|u|s|url|img|color|size|left|center|right|list|\*|hr|noparse|md-code|md-quote|md-h)(?:=([^\]]*))?\]/gi;
const BLOCK_TAGS = new Set(["left", "center", "right", "list", "*", "hr", "md-quote", "md-h"]);
export const BARE_URL_REGEX = /https?:\/\/[^\s<>"\[\]]+/g;
const COLOR_REGEX = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z]+)$/i;
const LIST_STYLES: Record<string, string> = { "1": "decimal", a: "lower-alpha", A: "upper-alpha", i: "lower-roman", I: "upper-roman" };
// Spans Markdown must not touch: noparse, tagged links, inline code, Markdown
// links/images, <autolinks>, bare URLs and backslash escapes.
const MD_SPANS = new RegExp(
[
String.raw`\[noparse\][\s\S]*?\[\/noparse\]`,
String.raw`\[(url|img)(?:=[^\]]*)?\][\s\S]*?\[\/\1\]`,
String.raw`\x60([^\x60\n]+)\x60`,
String.raw`(!?)\[([^\]\n]*)\]\(<?(https?:\/\/[^\s)>]+)>?(?:\s[^)\n]*)?\)`,
String.raw`<(https?:\/\/[^\s>]+)>`,
BARE_URL_REGEX.source,
String.raw`\\([\\\x60*_{}\[\]()#+\-.!~>|=])`,
].join("|"),
"gi",
);
// Outgoing: an already-tagged link or Markdown span (left alone) or a bare URL (wrapped).
const WRAP_REGEX = new RegExp(
String.raw`(\[(url|img)(?:=[^\]]*)?\][\s\S]*?\[\/\2\]|!?\[[^\]\n]*\]\([^)\n]*\)|\x60[^\x60\n]*\x60|<https?:\/\/[^\s>]+>)|` +
BARE_URL_REGEX.source,
"gi",
);
interface Node {
tag: string;
arg?: string;
children: (Node | string)[];
}
export interface RenderOptions {
/** Load [img] / ![](...) inline. Off: they render as links, so no remote host sees the reader's IP. */
images?: boolean;
}
function emphasis(s: string): string {
return s
.replace(/\*\*(?=\S)([^\n]*?\S)\*\*/g, "[b]$1[/b]")
.replace(/~~(?=\S)([^\n]*?\S)~~/g, "[s]$1[/s]")
.replace(/\+\+(?=\S)([^\n]*?\S)\+\+/g, "[u]$1[/u]")
.replace(/(^|[^\w*[])\*(?=[^\s\]])([^*\n]*?\S)\*(?![\w*])/g, "$1[i]$2[/i]")
.replace(/(^|[^\w_[])_(?=[^\s\]])([^_\n]*?\S)_(?![\w_])/g, "$1[i]$2[/i]");
}
function markdownInline(text: string): string {
let out = "";
let last = 0;
for (const m of text.matchAll(MD_SPANS)) {
out += emphasis(text.slice(last, m.index));
last = m.index + m[0].length;
if (m[2] !== undefined) out += `[md-code][noparse]${m[2]}[/noparse][/md-code]`;
else if (m[5] !== undefined) out += m[3] ? `[img]${m[5]}[/img]` : `[url=${m[5]}]${m[4] || m[5]}[/url]`;
else if (m[6] !== undefined) out += m[6];
else if (m[7] !== undefined) out += `[noparse]${m[7]}[/noparse]`;
else out += m[0];
}
return out + emphasis(text.slice(last));
}
// Line-based Markdown blocks (TS6: one line is one paragraph): lists, quotes,
// headings and rules. Consecutive list/quote lines are grouped.
function markdownBlocks(text: string): string {
const out: { block: boolean; s: string }[] = [];
let group = null as { kind: string; items: string[] } | null;
const flush = () => {
if (!group) return;
const s =
group.kind === "quote"
? `[md-quote]${group.items.join("\n")}[/md-quote]`
: `[list${group.kind === "ol" ? "=1" : ""}]${group.items.map((i) => `[*]${i}`).join("")}[/list]`;
out.push({ block: true, s });
group = null;
};
for (const line of text.split("\n")) {
const item = /^\s*([-*+]|\d+[.)])\s+(.*)$/.exec(line);
const quote = /^>(?:\s(.*))?$/.exec(line);
const kind = item ? (/\d/.test(item[1]) ? "ol" : "ul") : quote ? "quote" : null;
if (kind) {
if (group?.kind !== kind) flush();
group ??= { kind, items: [] };
group.items.push(item ? item[2] : (quote![1] ?? ""));
continue;
}
flush();
const heading = /^(#{1,3})\s+(.+)$/.exec(line);
if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) out.push({ block: true, s: "[hr]" });
else if (heading) out.push({ block: true, s: `[md-h=${heading[1].length}]${heading[2]}[/md-h]` });
else out.push({ block: false, s: line });
}
flush();
return out.map((e, i) => (i > 0 && !e.block && !out[i - 1].block ? "\n" : "") + e.s).join("");
}
function parse(text: string): Node {
const root: Node = { tag: "", children: [] };
const stack = [root];
const re = new RegExp(TAG_REGEX.source, "gi");
let last = 0;
for (let m; (m = re.exec(text)); ) {
const top = stack[stack.length - 1];
if (m.index > last) top.children.push(text.slice(last, m.index));
last = re.lastIndex;
const tag = m[2].toLowerCase();
if (m[1]) {
const at = stack.findLastIndex((n) => n.tag === tag);
if (at > 0) stack.length = at;
else top.children.push(m[0]);
} else if (tag === "noparse") {
const end = text.toLowerCase().indexOf("[/noparse]", last);
const stop = end < 0 ? text.length : end;
top.children.push({ tag, children: [text.slice(last, stop)] });
last = re.lastIndex = end < 0 ? stop : end + "[/noparse]".length;
} else if (tag === "hr") {
top.children.push({ tag, children: [] });
} else if (tag === "*") {
const at = stack.findLastIndex((n) => n.tag === "list");
if (at > 0) {
stack.length = at + 1;
const li: Node = { tag, children: [] };
stack[at].children.push(li);
stack.push(li);
} else top.children.push(m[0]);
} else {
const node: Node = { tag, arg: m[3], children: [] };
top.children.push(node);
stack.push(node);
}
}
if (last < text.length) stack[stack.length - 1].children.push(text.slice(last));
return root;
}
function safeHref(raw: string): string | null {
const url = raw.trim();
return /^https?:\/\//i.test(url) ? url : /^www\./i.test(url) ? `https://${url}` : null;
}
function link(href: string, children: ReactNode, key: number) {
return (
<a key={key} href={href} target="_blank" rel="noopener noreferrer">
{children}
</a>
);
}
function textNode(text: string, key: number, linkUrls = true): ReactNode {
const parts: ReactNode[] = [];
text.split("\n").forEach((line, li) => {
if (li > 0) parts.push(<br key={`br${li}`} />);
let last = 0;
if (linkUrls) {
for (const m of line.matchAll(BARE_URL_REGEX)) {
if (m.index > last) parts.push(line.slice(last, m.index));
parts.push(link(m[0], m[0], li * 10000 + m.index));
last = m.index + m[0].length;
}
}
if (last < line.length) parts.push(line.slice(last));
});
return parts.length === 1 && typeof parts[0] === "string" ? parts[0] : <Fragment key={key}>{parts}</Fragment>;
}
function textOf(node: Node): string {
return node.children.map((c) => (typeof c === "string" ? c : textOf(c))).join("");
}
function fontSize(arg: string | undefined): string | undefined {
const rel = /^([+-])(\d)$/.exec(arg ?? "");
if (rel) return `${Math.min(2, Math.max(0.6, 1 + (rel[1] === "+" ? 1 : -1) * Number(rel[2]) * 0.2))}em`;
return /^\d{1,3}$/.test(arg ?? "") ? `${Math.min(28, Math.max(6, Number(arg)))}pt` : undefined;
}
function render(node: Node, key: number, opts: RenderOptions): ReactNode {
const isBlock = (c: Node | string | undefined) => typeof c === "object" && BLOCK_TAGS.has(c.tag);
const kids = () =>
node.children.map((c, i, all) => {
if (typeof c !== "string") return render(c, i, opts);
// Line breaks around block elements are already breaks; drop them.
let s = c;
if (i === 0 ? isBlock(node) : isBlock(all[i - 1])) s = s.replace(/^\n/, "");
if (i === all.length - 1 ? isBlock(node) : isBlock(all[i + 1])) s = s.replace(/\n$/, "");
if (node.tag === "list" && !s.trim()) return null;
return textNode(s, i);
});
switch (node.tag) {
case "b":
return <strong key={key}>{kids()}</strong>;
case "i":
return <em key={key}>{kids()}</em>;
case "u":
return <u key={key}>{kids()}</u>;
case "s":
return <s key={key}>{kids()}</s>;
case "color":
return (
<span key={key} style={node.arg && COLOR_REGEX.test(node.arg) ? { color: node.arg } : undefined}>
{kids()}
</span>
);
case "size":
return (
<span key={key} style={{ fontSize: fontSize(node.arg) }}>
{kids()}
</span>
);
case "left":
case "center":
case "right":
return (
<div key={key} style={{ textAlign: node.tag }}>
{kids()}
</div>
);
case "list": {
const style = node.arg ? LIST_STYLES[node.arg] : undefined;
return style ? (
<ol key={key} className="ts-bb-list" style={{ listStyleType: style }}>
{kids()}
</ol>
) : (
<ul key={key} className="ts-bb-list">
{kids()}
</ul>
);
}
case "*":
return <li key={key}>{kids()}</li>;
case "hr":
return <hr key={key} className="ts-bb-hr" />;
case "noparse":
return textNode(textOf(node), key, false);
case "md-code":
return <code key={key}>{kids()}</code>;
case "md-quote":
return (
<blockquote key={key} className="ts-bb-quote">
{kids()}
</blockquote>
);
case "md-h":
return (
<div key={key} className={`ts-bb-h ts-bb-h${node.arg}`}>
{kids()}
</div>
);
case "url":
case "img": {
const href = safeHref(node.arg ?? textOf(node));
// Plain-text label: a linkified URL or nested tag inside <a> would nest links.
const label = textOf(node);
if (!href) return <span key={key}>{label}</span>;
if (node.tag === "img" && opts.images)
return link(href, <img className="ts-bb-img" src={href} alt="" loading="lazy" referrerPolicy="no-referrer" />, key);
return link(href, label, key);
}
default:
return <Fragment key={key}>{kids()}</Fragment>;
}
}
export function renderBbcode(text: string, opts: RenderOptions = {}): ReactNode {
return render(parse(markdownInline(markdownBlocks(text.replace(/\r\n?/g, "\n")))), 0, opts);
}
// Outgoing: native clients send links as [URL]...[/URL] and only link those.
export function wrapUrls(text: string): string {
return text.replace(WRAP_REGEX, (m, kept) => (kept ? m : `[URL]${m}[/URL]`));
}
+3 -3
View File
@@ -341,6 +341,8 @@
"app.language.helpTranslate": "Fehlt deine Sprache oder eine Übersetzung ist ungenau? Hilf mit auf Weblate →",
"app.serverBanner": "Server-Banner anzeigen",
"app.serverBanner.hint": "Das Banner lädt direkt von der Adresse, die der Serverbetreiber eingetragen hat. Dieser Host sieht dabei deine IP-Adresse.",
"app.chatImages": "Bilder im Chat laden",
"app.chatImages.hint": "Bilder aus [img]-Tags und Markdown laden direkt von der Adresse, die der Absender gewählt hat, und dieser Host sieht deine IP-Adresse. Ausgeschaltet erscheinen sie als Link.",
"playback.title": "Wiedergabe",
"playback.subtitle": "Ändern der Wiedergabeeinstellungen",
"playback.profile": "Profile",
@@ -391,6 +393,7 @@
"info.no": "Nein",
"tree.noMatches": "Keine Treffer",
"tree.search": "Kanäle und Nutzer suchen",
"tree.label": "Kanäle",
"tree.notConnected": "Nicht verbunden",
"tree.clickToSelect": "Klicken zum Auswählen, Doppelklick zum Beitreten",
"tree.clickToJoin": "Doppelklick zum Beitreten",
@@ -659,10 +662,7 @@
"nachrichten.message": "Nachricht",
"nachrichten.add": "Hinzufügen",
"nachrichten.delete": "Löschen",
"tree.expand": "Aufklappen",
"tree.collapse": "Zuklappen",
"tabs.disconnect": "Verbindung trennen",
"tabs.closeTab": "Tab schließen: {label}",
"identity.importInvalid": "„{file}“ ist keine gültige Identitätsdatei.",
"log.fileTransferFailed": "Dateiübertragung fehlgeschlagen:",
"log.serverReconnecting": "Verbindung zum Server verloren, verbinde neu…",
+3 -3
View File
@@ -341,6 +341,8 @@
"app.language.helpTranslate": "Missing your language or spotted a wrong translation? Help out on Weblate →",
"app.serverBanner": "Show server banners",
"app.serverBanner.hint": "The banner loads straight from the address the server admin set, and that host sees your IP address.",
"app.chatImages": "Load images in chat",
"app.chatImages.hint": "Images from [img] tags and Markdown load straight from the address the sender picked, and that host sees your IP address. When off, they show as links.",
"playback.title": "Playback",
"playback.subtitle": "Change your playback settings",
"playback.profile": "Profile",
@@ -391,6 +393,7 @@
"info.no": "No",
"tree.noMatches": "No matches",
"tree.search": "Search channels and users",
"tree.label": "Channels",
"tree.notConnected": "Not connected",
"tree.clickToSelect": "Click to select, double-click to join",
"tree.clickToJoin": "Double-click to join",
@@ -659,10 +662,7 @@
"nachrichten.message": "Message",
"nachrichten.add": "Add",
"nachrichten.delete": "Delete",
"tree.expand": "Expand",
"tree.collapse": "Collapse",
"tabs.disconnect": "Disconnect",
"tabs.closeTab": "Close tab: {label}",
"identity.importInvalid": "\"{file}\" is not a valid identity file.",
"log.fileTransferFailed": "File transfer failed:",
"log.serverReconnecting": "Connection to the server lost, reconnecting…",
+3 -3
View File
@@ -341,6 +341,8 @@
"app.language.helpTranslate": "زبان شما موجود نیست یا ترجمه‌ای اشتباه دیدید؟ در Weblate کمک کنید →",
"app.serverBanner": "نمایش بنر سرور",
"app.serverBanner.hint": "بنر مستقیماً از نشانی‌ای بارگیری می‌شود که مدیر سرور تعیین کرده است و آن میزبان نشانی IP شما را می‌بیند.",
"app.chatImages": "بارگیری تصاویر در گفتگو",
"app.chatImages.hint": "تصاویر برچسب‌های [img] و مارک‌داون مستقیماً از نشانی‌ای که فرستنده انتخاب کرده بارگیری می‌شوند و آن میزبان نشانی IP شما را می‌بیند. در حالت خاموش به‌صورت پیوند نمایش داده می‌شوند.",
"playback.title": "پخش",
"playback.subtitle": "تنظیمات پخش را تغییر بده",
"playback.profile": "پروفایل",
@@ -390,6 +392,7 @@
"info.no": "خیر",
"tree.noMatches": "نتیجه‌ای یافت نشد",
"tree.search": "جستجوی کانال‌ها و کاربران",
"tree.label": "کانال‌ها",
"tree.notConnected": "متصل نیست",
"tree.clickToSelect": "برای انتخاب کلیک کن، برای ورود دوبار کلیک کن",
"tree.clickToJoin": "برای ورود دوبار کلیک کن",
@@ -658,10 +661,7 @@
"nachrichten.message": "پیام",
"nachrichten.add": "افزودن",
"nachrichten.delete": "حذف",
"tree.expand": "باز کردن",
"tree.collapse": "بستن",
"tabs.disconnect": "قطع اتصال",
"tabs.closeTab": "بستن زبانه: {label}",
"identity.importInvalid": "«{file}» یک فایل هویت معتبر نیست.",
"log.fileTransferFailed": "انتقال فایل ناموفق بود:",
"log.serverReconnecting": "اتصال به سرور قطع شد، در حال اتصال دوباره…",
+3 -3
View File
@@ -244,6 +244,8 @@
"app.language.helpTranslate": "没有你的语言,或发现翻译有误?欢迎到 Weblate 参与改进 →",
"app.serverBanner": "显示服务器横幅",
"app.serverBanner.hint": "横幅直接从服务器管理员设置的地址加载,该主机会看到你的 IP 地址。",
"app.chatImages": "在聊天中加载图片",
"app.chatImages.hint": "[img] 标签和 Markdown 中的图片直接从发送者指定的地址加载,该主机会看到你的 IP 地址。关闭时显示为链接。",
"playback.title": "播放",
"playback.subtitle": "更改播放设置",
"playback.profile": "配置",
@@ -292,6 +294,7 @@
"info.no": "否",
"tree.noMatches": "无匹配结果",
"tree.search": "搜索频道和用户",
"tree.label": "频道",
"tree.notConnected": "未连接",
"tree.clickToSelect": "单击选择,双击加入",
"tree.clickToJoin": "双击加入",
@@ -658,10 +661,7 @@
"stream.state.failed": "连接失败",
"stream.state.closed": "已结束",
"clientContext.watchStream": "观看直播",
"tree.expand": "展开",
"tree.collapse": "折叠",
"tabs.disconnect": "断开连接",
"tabs.closeTab": "关闭标签页:{label}",
"identity.importInvalid": "“{file}”不是有效的身份文件。",
"log.fileTransferFailed": "文件传输失败:",
"log.serverReconnecting": "与服务器的连接已断开,正在重新连接…",
+9 -5
View File
@@ -23,7 +23,7 @@
--gts-border: #1c1f24;
--border-light: #3a4450;
--gts-text: #d7dee6;
--gts-text-muted: #7a8490;
--gts-text-muted: #8a94a0; /* native #7a8490, lifted to 4.5:1 on the panel */
--menu-text: #c8b882;
--menu-hover: #c8b882;
--menu-hover-text: #1a1a1a;
@@ -34,7 +34,7 @@
--error: #e62222;
--selection: #4a5560;
--selection-tree: #5a7ea0;
--server-log-text: #7a8490;
--server-log-text: #8a94a0;
--chat-separator: #1c1f24;
--chat-separator-selected: #4a5560;
--tree-fg: #d1d1d1;
@@ -375,7 +375,10 @@
color: var(--gts-text);
}
/* Multi-join tabs for Standard / Nova (same strip, slightly softer chrome) */
/* Multi-join tabs for Standard / Nova (same strip, slightly softer chrome).
Only GTS defines --bg-app/--bg-toolbar/--bg-panel, so this strip is always
dark here: its text colors are fixed, not the theme's --text (which is dark
in the light theme and made the active tab unreadable). */
.ts-app:not(.ts-design-greenteaspeak) .gts-connection-tabs {
display: flex;
gap: 1px;
@@ -396,7 +399,7 @@
background: var(--bg-toolbar, #2a2a2a);
border: 1px solid var(--border, #444);
border-bottom: none;
color: var(--text-muted, #aaa);
color: #aaa;
padding: 0 4px 0 10px;
max-width: 280px;
height: 100%;
@@ -408,7 +411,7 @@
.ts-app:not(.ts-design-greenteaspeak) .gts-connection-tab-active {
background: var(--bg-panel, #333);
color: var(--text, #eee);
color: #eee;
border-color: #b0b8c0;
}
@@ -422,6 +425,7 @@
.ts-app:not(.ts-design-greenteaspeak) .gts-connection-tab-close {
flex-shrink: 0;
text-align: center;
width: 16px;
height: 16px;
padding: 0;
@@ -57,22 +57,31 @@ export function GreenteaSpeakChrome({
tab.connecting ? " gts-connection-tab-connecting" : ""
}`}
onClick={() => onSelectTab?.(tab.id)}
tabIndex={0}
aria-keyshortcuts={onCloseTab ? "Delete" : undefined}
onKeyDown={(e) => {
if (e.target !== e.currentTarget) return;
// The × below is mouse-only (a button can't sit inside a tab); Delete closes.
if (e.key === "Delete" && onCloseTab) onCloseTab(tab.id);
else if (e.key === "Enter" || e.key === " ") onSelectTab?.(tab.id);
else return;
e.preventDefault();
}}
title={tab.label}
>
<span className="gts-connection-tab-label">{tab.label}</span>
{onCloseTab ? (
<button
type="button"
<span
className="gts-connection-tab-close"
aria-hidden="true"
title={t("tabs.disconnect")}
aria-label={t("tabs.closeTab", { label: tab.label })}
onClick={(e) => {
e.stopPropagation();
onCloseTab(tab.id);
}}
>
×
</button>
</span>
) : null}
</div>
);