Add TeaSpeak/GTS support, multi-join & GTS theme

Adds TeaSpeak/GreenTeaSpeak protocol support and multi-join session tabs plus a GreenteaSpeak UI theme. Key changes: connector (Rust) supports --server-type, privilege key, server variables, license formatting, Query-client filtering and extra metrics; gateway accepts serverType/privilegeKey, optional static serving (WEB_STATIC), and per-tab /ws sessions; web frontend: multi-session parking (connectionSessions), channel spacer parsing, talk-lamp UI, extended server connection info, connect dialog serverType/privilegeKey, GreenteaSpeak CSS & chrome, i18n updates, and demo updates. Also adds docs/teaspeak.md and dependency num-traits.
This commit is contained in:
Nico B. committed 2026-09-05 22:45:21 +02:00
1 parent 804fa44ab6
commit e9ee12c7b5
20 files changed
+3279 -209

No files matched your search

+204 -3
View File
@@ -1178,6 +1178,23 @@
color: var(--text-muted);
}
/* GreenTeaSpeak / TeaSpeak license badge colors (ids 0–3) */
.ts-license-label.ts-license-0 {
color: #9a9aa3;
}
.ts-license-label.ts-license-1 {
color: #8fbf7a;
}
.ts-license-label.ts-license-2 {
color: #d4b45a;
}
.ts-license-label.ts-license-3 {
color: #6eb0e0;
}
.ts-info-connection-link {
margin-top: 0.5rem;
background: none;
@@ -1197,6 +1214,10 @@
width: 380px;
}
.ts-connection-info-dialog.ts-server-conn-info {
width: min(520px, 94vw);
}
.ts-connection-info-loading {
padding: 1rem;
text-align: center;
@@ -1214,6 +1235,32 @@
color: var(--text-muted);
}
.ts-server-conn-table {
width: 100%;
margin-top: 0.85rem;
border-collapse: collapse;
font-size: 12px;
}
.ts-server-conn-table th,
.ts-server-conn-table td {
padding: 0.3rem 0.4rem;
text-align: right;
border-bottom: 1px solid var(--border);
}
.ts-server-conn-table th:first-child,
.ts-server-conn-table td:first-child {
text-align: left;
color: var(--text-muted);
}
.ts-server-conn-table th {
font-style: italic;
font-weight: 600;
color: var(--text-muted);
}
.ts-row-selected {
background: var(--row-hover);
outline: 1px solid var(--border);
@@ -1259,9 +1306,118 @@
background: var(--row-hover);
}
/* Channel spacers ([cspacer], [*spacer01], …) — GreenTeaSpeak / TS parity */
.ts-channel-row.ts-spacer {
position: relative;
justify-content: center;
min-height: 19px;
color: var(--text);
cursor: pointer;
}
.ts-channel-row.ts-spacer:hover {
background: var(--row-hover);
}
.ts-channel-row.ts-spacer .ts-spacer-label {
position: absolute;
left: 0.35rem;
right: 0.35rem;
overflow: hidden;
white-space: nowrap;
text-align: center;
pointer-events: none;
}
.ts-channel-row.ts-spacer-align-left .ts-spacer-label {
text-align: left;
}
.ts-channel-row.ts-spacer-align-right .ts-spacer-label {
text-align: right;
}
.ts-channel-row.ts-spacer-align-center .ts-spacer-label,
.ts-channel-row.ts-spacer-align-repetitive .ts-spacer-label {
text-align: center;
}
.ts-channel-row.ts-spacer-align-repetitive .ts-spacer-label {
text-overflow: clip;
}
.ts-channel-row.ts-spacer-line .ts-spacer-line-rule {
position: absolute;
left: 0.5rem;
right: 0.5rem;
top: 50%;
height: 0;
border-top: 1px solid currentColor;
opacity: 0.7;
overflow: hidden;
pointer-events: none;
}
.ts-channel-row.ts-spacer-boxart .ts-spacer-label {
font-family: Consolas, "Courier New", monospace;
letter-spacing: 0.02em;
}
.ts-tree-expander {
display: grid;
place-items: center;
width: 12px;
height: 16px;
flex: 0 0 12px;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
}
.ts-tree-expander span {
width: 0;
height: 0;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 5px solid #c8c8c8;
}
.ts-tree-expander-collapsed span {
border-top: 3px solid transparent;
border-bottom: 3px solid transparent;
border-left: 5px solid #c8c8c8;
border-right: 0;
}
.ts-tree-expander-empty {
visibility: hidden;
cursor: default;
}
.ts-client-status-leading {
display: inline-flex;
align-items: center;
gap: 0.1rem;
flex-shrink: 0;
}
.ts-client-status-leading:empty {
display: none;
}
.ts-tree-label {
overflow: hidden;
text-overflow: ellipsis;
}
.ts-tree-list-root {
padding-left: 0.15rem;
}
.ts-client-row {
color: var(--client-text);
padding-left: 0.65rem;
padding-left: 0;
}
.ts-client-row.ts-self {
@@ -1278,9 +1434,50 @@
}
.ts-client-row.ts-talking {
outline: 1px solid #4caf50;
outline: 1px solid color-mix(in srgb, #4caf50 55%, transparent);
border-radius: 2px;
background: color-mix(in srgb, #4caf50 15%, transparent);
background: color-mix(in srgb, #4caf50 10%, transparent);
}
/* Talk lamps (GTS2-style status orbs left of the nickname) */
.ts-talk-lamp {
display: inline-flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
flex-shrink: 0;
border-radius: 50%;
box-sizing: border-box;
}
.ts-talk-lamp-idle {
background:
radial-gradient(circle at 32% 28%, #9fd0ff 0%, #3a7ec4 45%, #1a4a7a 100%);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.55),
inset 0 -1px 2px rgba(0, 0, 0, 0.35),
0 0 0 1px rgba(0, 0, 0, 0.25);
}
.ts-talk-lamp-talking {
background:
radial-gradient(circle at 32% 28%, #c8f59a 0%, #4caf50 42%, #1e7a28 100%);
box-shadow:
inset 0 1px 1px rgba(255, 255, 255, 0.6),
inset 0 -1px 2px rgba(0, 0, 0, 0.3),
0 0 4px rgba(76, 175, 80, 0.55),
0 0 0 1px rgba(0, 0, 0, 0.2);
}
.ts-talk-lamp-muted {
border-radius: 0;
background: transparent;
box-shadow: none;
}
.ts-talk-lamp-muted svg {
display: block;
}
.ts-client-icons {
@@ -2416,6 +2613,10 @@
box-shadow: inset 0 0 0 1px #7fb0e8;
}
.ts-design-theme-swatch-greenteaspeak {
background: linear-gradient(135deg, #1f2329 40%, #6fbf5c 40%, #386896 70%, #c8b882 70%);
}
.ts-design-theme-card-name {
font-weight: 600;
font-size: 13px;
+947 -172
View File
File diff suppressed because it is too large. Load diff
+328
View File
@@ -0,0 +1,328 @@
/**
* Multi-join session bookkeeping. The active tab keeps its UI in React state
* (App.tsx); inactive tabs park a snapshot here and keep their WebSocket alive.
* Audio is intentionally active-tab-only (see README / known limits).
*/
export type ConnectionSessionId = string;
export type SelectedItem =
| { type: "server" }
| { type: "channel"; id: number }
| { type: "client"; id: number };
export type ChatEntry = { from: string; message: string; isLog?: boolean };
export type PmMessage = { fromSelf: boolean; message: string };
export type PmThread = {
partnerId: number;
partnerName: string;
messages: PmMessage[];
unread: boolean;
};
export type ActiveChatTab = "channel" | "server" | number;
export type PokeNotice = { id: number; from: string; message: string };
export type LogEntry = { text: string; kind: "info" | "error" };
export type ChannelInfo = {
id: number;
parent: number;
order: number;
name: string;
topic: string;
codec: string;
maxClients: number | null;
hasPassword: boolean;
};
export type ClientInfo = {
id: number;
channel: number;
name: string;
inputMuted: boolean;
outputMuted: boolean;
inputHardwareEnabled: boolean;
away: boolean;
awayMessage: string;
isChannelCommander: boolean;
country: string;
uid: string;
databaseId: number;
channelGroup: number;
serverGroups: number[];
hasTalkPower: boolean;
};
export type WhisperLogEntry = {
id: number;
timestamp: number;
description: string;
};
/** Snapshot of per-connection UI state for a parked (inactive) tab. */
export type ParkedSessionState = {
host: string;
nickname: string;
connected: boolean;
connecting: boolean;
connectError: string | null;
channels: ChannelInfo[];
clients: ClientInfo[];
ownClientId: number | null;
serverName: string;
serverMaxClients: number;
serverClientsOnline: number;
serverChannelsOnline: number;
serverVersion: string;
serverLicense: string;
serverLicenseId: number;
serverBannerUrl: string;
serverWelcomeMessage: string;
selected: SelectedItem | null;
chat: ChatEntry[];
serverChat: ChatEntry[];
pmThreads: Record<number, PmThread>;
pokes: PokeNotice[];
chatTab: ActiveChatTab;
talkers: number[];
whisperChannelIds: number[];
whisperClientIds: number[];
whisperLog: WhisperLogEntry[];
log: LogEntry[];
hasConnected: boolean;
previousClients: ClientInfo[] | null;
};
export type SessionTabInfo = {
id: ConnectionSessionId;
label: string;
connected: boolean;
connecting: boolean;
};
export type SessionSocket = WebSocket | { close: () => void; readyState: number; send: (data: string) => void };
export type SessionRecord = {
id: ConnectionSessionId;
socket: SessionSocket | null;
/** null while this session is the active React UI. */
parked: ParkedSessionState | null;
};
export function emptyParkedState(partial?: Partial<ParkedSessionState>): ParkedSessionState {
return {
host: "",
nickname: "",
connected: false,
connecting: false,
connectError: null,
channels: [],
clients: [],
ownClientId: null,
serverName: "",
serverMaxClients: 0,
serverClientsOnline: 0,
serverChannelsOnline: 0,
serverVersion: "",
serverLicense: "",
serverLicenseId: 0,
serverBannerUrl: "",
serverWelcomeMessage: "",
selected: null,
chat: [],
serverChat: [],
pmThreads: {},
pokes: [],
chatTab: "channel",
talkers: [],
whisperChannelIds: [],
whisperClientIds: [],
whisperLog: [],
log: [],
hasConnected: false,
previousClients: null,
...partial,
};
}
export function sessionLabel(state: Pick<ParkedSessionState, "serverName" | "host">): string {
const name = state.serverName.trim() || state.host.trim();
return name || "…";
}
/** Apply a gateway event to a parked session. Returns whether the tab label may have changed. */
export function applyParkedGatewayEvent(
state: ParkedSessionState,
data: { type: string; [key: string]: unknown },
opts: { connectNickname: string; chatTab: ActiveChatTab }
): { state: ParkedSessionState; labelChanged: boolean } {
let labelChanged = false;
switch (data.type) {
case "connected": {
const serverName = String(data.serverName ?? "");
labelChanged = serverName !== state.serverName;
return {
labelChanged,
state: {
...state,
connecting: false,
connectError: null,
connected: true,
hasConnected: true,
serverName,
serverMaxClients: Number(data.serverMaxClients) || 0,
serverClientsOnline: 0,
serverChannelsOnline: 0,
serverVersion: String(data.serverVersion ?? ""),
serverLicense: String(data.serverLicense ?? ""),
serverLicenseId: typeof data.serverLicenseId === "number" ? data.serverLicenseId : 0,
serverBannerUrl: String(data.serverBannerUrl ?? ""),
serverWelcomeMessage: String(data.welcomeMessage ?? ""),
selected: { type: "server" },
serverChat: [
...state.serverChat,
{ from: "Server", message: String(data.welcomeMessage ?? "") },
],
previousClients: null,
},
};
}
case "channels": {
const newClients = (data.clients as ClientInfo[]) ?? [];
const ownClientId =
typeof data.ownClientId === "number" && data.ownClientId > 0
? data.ownClientId
: state.ownClientId;
return {
labelChanged: false,
state: {
...state,
channels: (data.channels as ChannelInfo[]) ?? state.channels,
clients: newClients,
ownClientId,
serverMaxClients:
typeof data.serverMaxClients === "number" && data.serverMaxClients > 0
? data.serverMaxClients
: state.serverMaxClients,
serverClientsOnline:
typeof data.serverClientsOnline === "number" && data.serverClientsOnline >= 0
? data.serverClientsOnline
: state.serverClientsOnline,
serverChannelsOnline:
typeof data.serverChannelsOnline === "number" && data.serverChannelsOnline >= 0
? data.serverChannelsOnline
: state.serverChannelsOnline,
previousClients: newClients,
},
};
}
case "chatMessage":
return {
labelChanged: false,
state: {
...state,
chat: [...state.chat, { from: String(data.from), message: String(data.message) }],
},
};
case "serverMessage":
return {
labelChanged: false,
state: {
...state,
serverChat: [
...state.serverChat,
{ from: String(data.from), message: String(data.message) },
],
},
};
case "privateMessage": {
const partnerId = Number(data.partnerId);
const existing = state.pmThreads[partnerId];
const thread: PmThread = existing ?? {
partnerId,
partnerName: String(data.partnerName),
messages: [],
unread: false,
};
return {
labelChanged: false,
state: {
...state,
pmThreads: {
...state.pmThreads,
[partnerId]: {
...thread,
partnerName: String(data.partnerName),
messages: [
...thread.messages,
{ fromSelf: Boolean(data.fromSelf), message: String(data.message) },
],
unread:
thread.unread || (!data.fromSelf && opts.chatTab !== partnerId),
},
},
},
};
}
case "talkers":
return {
labelChanged: false,
state: {
...state,
talkers: Array.isArray(data.clients) ? (data.clients as number[]) : [],
},
};
case "poke": {
const id = Date.now() + Math.floor(Math.random() * 1000);
return {
labelChanged: false,
state: {
...state,
pokes: [
...state.pokes,
{ id, from: String(data.from), message: String(data.message ?? "") },
],
},
};
}
case "disconnected":
return {
labelChanged: true,
state: {
...emptyParkedState({
host: state.host,
nickname: state.nickname,
}),
connecting: false,
connected: false,
hasConnected: false,
log: [
...state.log,
{ text: `Disconnected: ${String(data.reason ?? "")}`, kind: "info" },
],
},
};
case "error":
if (state.hasConnected) {
return {
labelChanged: false,
state: {
...state,
log: [...state.log, { text: String(data.message), kind: "error" }],
},
};
}
return {
labelChanged: false,
state: {
...state,
connecting: false,
connectError: String(data.message),
},
};
case "audioOut":
// Background tabs never play audio (active-tab-only shortcut).
return { state, labelChanged: false };
default:
return { state, labelChanged: false };
}
}
+10 -1
View File
@@ -228,6 +228,7 @@ export class DemoSocket {
serverMaxClients: 32,
serverVersion: "3.13.7 [Build: demo]",
serverLicense: "Demo License",
serverLicenseId: 2,
serverBannerUrl: null,
welcomeMessage: "This is a simulated demo - no real TeamSpeak server is involved. Connect with any name/address you like.",
});
@@ -620,6 +621,14 @@ export class DemoSocket {
serverGroups: [...this.selfServerGroups],
hasTalkPower: true,
};
this.emit({ type: "channels", channels: DEMO_CHANNELS, clients: [self, ...DEMO_NPCS] });
this.emit({
type: "channels",
channels: DEMO_CHANNELS,
clients: [self, ...DEMO_NPCS],
ownClientId: SELF_ID,
serverMaxClients: 32,
serverClientsOnline: 1 + DEMO_NPCS.length,
serverChannelsOnline: DEMO_CHANNELS.length,
});
}
}
+56
View File
@@ -77,6 +77,10 @@ const translations: Record<Lang, Record<string, string>> = {
"connect.channelPassword": "Channel Passwort:",
"connect.playbackProfile": "Wiedergabeprofil:",
"connect.onetimeGrant": "Einmalige Berechtigung:",
"connect.serverType": "Server-Typ:",
"connect.serverType.auto": "Auto",
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.hotkeyProfile": "Hotkeyprofil:",
"connect.soundPack": "Sound Pack:",
"connect.more": "Mehr",
@@ -151,6 +155,18 @@ const translations: Record<Lang, Record<string, string>> = {
"connectionInfo.unavailable": "Keine Antwort vom Server (fehlende Berechtigung?).",
"connectionInfo.ping": "Ping:",
"connectionInfo.connectedSince": "Verbunden seit:",
"connectionInfo.uptime": "Uptime:",
"connectionInfo.name": "Name:",
"connectionInfo.avgPing": "Mittlerer Ping:",
"connectionInfo.avgPacketLoss": "Mittlerer Paketverlust:",
"connectionInfo.incoming": "Eingehend",
"connectionInfo.outgoing": "Ausgehend",
"connectionInfo.packetsTransferred": "Übertragene Pakete",
"connectionInfo.bytesTransferred": "Übertragene Bytes",
"connectionInfo.bandwidthLastSecond": "Bandbreite letzte Sekunde",
"connectionInfo.bandwidthLastMinute": "Bandbreite letzte Minute",
"connectionInfo.ftBandwidth": "Dateitransfer Bandbreite",
"connectionInfo.ftBytes": "Dateitransfer übertragene Bytes",
"connectionInfo.ip": "IP-Adresse:",
"connectionInfo.packetLoss": "Paketverlust:",
"connectionInfo.packetsSent": "Pakete gesendet:",
@@ -228,6 +244,8 @@ const translations: Record<Lang, Record<string, string>> = {
"design.theme.standard.desc": "Das originale WebSpeak3-Design.",
"design.theme.nova": "Nova",
"design.theme.nova.desc": "Moderneres, dunkles Design mit abgerundeten Elementen.",
"design.theme.greenteaspeak": "GreenTeaSpeak",
"design.theme.greenteaspeak.desc": "Klassisches GreenTeaSpeak-Client-Layout mit dunklen Panels und goldener Menüleiste.",
"design.status.connected": "Verbunden",
"design.custom.new": "+ Neues Design",
"design.custom.import": "Design importieren",
@@ -302,19 +320,28 @@ const translations: Record<Lang, Record<string, string>> = {
"info.currentChannels": "Aktuelle Channel:",
"info.topic": "Topic:",
"info.audioCodec": "Audio Codec:",
"info.spacer": "Spacer:",
"info.rawName": "Rohname:",
"info.passwordProtected": "Passwort geschützt:",
"info.clients": "Clients:",
"info.country": "Land:",
"info.muted": "Mikrofon stumm:",
"info.outputMuted": "Lautsprecher stumm:",
"info.serverGroups": "Servergruppen:",
"info.yes": "Ja",
"info.no": "Nein",
"tree.notConnected": "Nicht verbunden",
"tree.clickToSelect": "Klicken zum Auswählen, Doppelklick zum Beitreten",
"tree.clickToJoin": "Doppelklick zum Beitreten",
"tree.joinNotConnected": "Nicht verbunden — Channel-Wechsel nicht möglich",
"tree.passwordProtected": "Passwortgeschützt",
"tree.privateChatWith": "Privater Chat mit",
"tree.poke": "Anstupsen",
"tree.channelCommander": "Channel Commander",
"tree.away": "Abwesend",
"tree.micMuted": "Mikrofon stummgeschaltet",
"tree.talking": "Spricht",
"tree.noTalkPower": "Keine Redeerlaubnis in diesem Channel",
"tree.soundMuted": "Ton stummgeschaltet (deafened)",
@@ -459,6 +486,7 @@ const translations: Record<Lang, Record<string, string>> = {
"permsEditor.searchPermission": "Recht suchen...",
"dialog.ok": "OK",
"channelContext.join": "Channel wechseln",
"channelContext.files": "Dateien...",
"fileBrowser.title": "Dateitransfers",
"fileBrowser.up": "Nach oben",
@@ -601,6 +629,10 @@ const translations: Record<Lang, Record<string, string>> = {
"connect.channelPassword": "Channel password:",
"connect.playbackProfile": "Playback profile:",
"connect.onetimeGrant": "One-time privilege key:",
"connect.serverType": "Server type:",
"connect.serverType.auto": "Auto",
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.hotkeyProfile": "Hotkey profile:",
"connect.soundPack": "Sound pack:",
"connect.more": "More",
@@ -675,6 +707,18 @@ const translations: Record<Lang, Record<string, string>> = {
"connectionInfo.unavailable": "No response from the server (missing permission?).",
"connectionInfo.ping": "Ping:",
"connectionInfo.connectedSince": "Connected since:",
"connectionInfo.uptime": "Uptime:",
"connectionInfo.name": "Name:",
"connectionInfo.avgPing": "Average ping:",
"connectionInfo.avgPacketLoss": "Average packet loss:",
"connectionInfo.incoming": "Incoming",
"connectionInfo.outgoing": "Outgoing",
"connectionInfo.packetsTransferred": "Packets transferred",
"connectionInfo.bytesTransferred": "Bytes transferred",
"connectionInfo.bandwidthLastSecond": "Bandwidth last second",
"connectionInfo.bandwidthLastMinute": "Bandwidth last minute",
"connectionInfo.ftBandwidth": "File transfer bandwidth",
"connectionInfo.ftBytes": "File transfer bytes",
"connectionInfo.ip": "IP address:",
"connectionInfo.packetLoss": "Packet loss:",
"connectionInfo.packetsSent": "Packets sent:",
@@ -752,6 +796,8 @@ const translations: Record<Lang, Record<string, string>> = {
"design.theme.standard.desc": "The original WebSpeak3 design.",
"design.theme.nova": "Nova",
"design.theme.nova.desc": "A more modern, dark design with rounded elements.",
"design.theme.greenteaspeak": "GreenTeaSpeak",
"design.theme.greenteaspeak.desc": "Classic GreenTeaSpeak client layout with dark panels and a gold menu bar.",
"design.status.connected": "Connected",
"design.custom.new": "+ New design",
"design.custom.import": "Import design",
@@ -826,19 +872,28 @@ const translations: Record<Lang, Record<string, string>> = {
"info.currentChannels": "Current channels:",
"info.topic": "Topic:",
"info.audioCodec": "Audio codec:",
"info.spacer": "Spacer:",
"info.rawName": "Raw name:",
"info.passwordProtected": "Password protected:",
"info.clients": "Clients:",
"info.country": "Country:",
"info.muted": "Microphone muted:",
"info.outputMuted": "Speakers muted:",
"info.serverGroups": "Server groups:",
"info.yes": "Yes",
"info.no": "No",
"tree.notConnected": "Not connected",
"tree.clickToSelect": "Click to select, double-click to join",
"tree.clickToJoin": "Double-click to join",
"tree.joinNotConnected": "Not connected — cannot switch channel",
"tree.passwordProtected": "Password protected",
"tree.privateChatWith": "Private chat with",
"tree.poke": "Poke",
"tree.channelCommander": "Channel commander",
"tree.away": "Away",
"tree.micMuted": "Microphone muted",
"tree.talking": "Talking",
"tree.noTalkPower": "No talk power in this channel",
"tree.soundMuted": "Sound muted (deafened)",
@@ -983,6 +1038,7 @@ const translations: Record<Lang, Record<string, string>> = {
"permsEditor.searchPermission": "Search permission...",
"dialog.ok": "OK",
"channelContext.join": "Switch to channel",
"channelContext.files": "Files...",
"fileBrowser.title": "File Transfers",
"fileBrowser.up": "Up",
+114
View File
@@ -0,0 +1,114 @@
/** TeamSpeak / TeaSpeak / GreenTeaSpeak channel spacer helpers.
*
* Mirrors GreenTeaSpeak `ChannelTreeBuilder.parseChannelName` / oldclient
* `ChannelNameParser`: only root channels, tag must contain "spacer", alignment
* prefix l/c/r/* (empty → left), unique id after "spacer" may be any string
* (e.g. `[*spacer01]`, `[cspacerabc]`).
*/
export type SpacerAlignment = "left" | "center" | "right" | "repetitive";
export type ParsedChannelName = {
/** Label shown in the tree (tag stripped for spacers). */
name: string;
alignment: SpacerAlignment | null;
};
/** Pure line fillers that look better as a CSS rule than raw `---` / `***`. */
const LINE_FILLER_RE = /^[\-\u2013\u2014\u2500\u2501\u2550=\*\.·_\s]+$/;
/** Corners / verticals of box-frame spacers (not pure horizontal fills). */
const BOX_FRAME_RE = /[╔╗╚╝╒╓╕╖╘╙╛╜┌┐└┘├┤┬┴┼║│╟╢╤╧╪╫╬╒╓╕╖╘╙╛╜]/;
export function parseChannelName(name: string, isRoot: boolean): ParsedChannelName {
if (!isRoot || name.length < 3 || name.charAt(0) !== "[") {
return { name, alignment: null };
}
const end = name.indexOf("]");
if (end === -1) return { name, alignment: null };
let options = name.substring(1, end);
const spacerIndex = options.indexOf("spacer");
if (spacerIndex === -1) return { name, alignment: null };
options = options.substring(0, spacerIndex);
if (options.length === 0) {
options = "l";
} else if (options.length > 1) {
options = options.charAt(0);
}
const alignmentByPrefix: Record<string, SpacerAlignment> = {
l: "left",
c: "center",
r: "right",
"*": "repetitive",
};
const alignment = alignmentByPrefix[options];
if (!alignment) return { name, alignment: null };
return {
name: name.substring(end + 1),
alignment,
};
}
/** Same as oldclient `ChannelName`: repeat filler until it fills the tree row. */
export function expandRepetitiveSpacerName(name: string): string {
if (!name.length) return name;
let expanded = name;
while (expanded.length < 8000) {
expanded += expanded;
}
return expanded;
}
export function isLineSpacerFiller(text: string): boolean {
const trimmed = text.trim();
return trimmed.length > 0 && LINE_FILLER_RE.test(trimmed);
}
export function hasBoxArtChars(text: string): boolean {
return BOX_FRAME_RE.test(text);
}
export function spacerDisplayName(rawName: string, isRoot: boolean): {
label: string;
alignment: SpacerAlignment | null;
isSpacer: boolean;
/** Repetitive `---` / `***` / `═══` → render as CSS line, not character soup. */
isLine: boolean;
/** Box-frame spacers (╔╗ / ═) need monospace for GTS look. */
isBoxArt: boolean;
} {
const parsed = parseChannelName(rawName, isRoot);
if (!parsed.alignment) {
return {
label: rawName,
alignment: null,
isSpacer: false,
isLine: false,
isBoxArt: false,
};
}
const isBoxArt = hasBoxArtChars(parsed.name);
const isLine =
!isBoxArt &&
isLineSpacerFiller(parsed.name) &&
(parsed.alignment === "repetitive" || parsed.alignment === "center");
let label = parsed.name;
if (parsed.alignment === "repetitive" && !isLine) {
label = expandRepetitiveSpacerName(parsed.name);
}
return {
label,
alignment: parsed.alignment,
isSpacer: true,
isLine,
isBoxArt,
};
}
+34
View File
@@ -63,6 +63,10 @@ export const zhCN: Record<string, string> = {
"connect.channelPassword": "频道密码:",
"connect.playbackProfile": "播放配置:",
"connect.onetimeGrant": "一次性权限密钥:",
"connect.serverType": "服务器类型:",
"connect.serverType.auto": "自动",
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.hotkeyProfile": "快捷键配置:",
"connect.sendMyTeamSpeakId": "发送 myTeamSpeak ID",
"connect.soundPack": "声音包:",
@@ -138,6 +142,18 @@ export const zhCN: Record<string, string> = {
"connectionInfo.unavailable": "服务器无响应(可能缺少权限)。",
"connectionInfo.ping": "延迟:",
"connectionInfo.connectedSince": "连接时间:",
"connectionInfo.uptime": "运行时间:",
"connectionInfo.name": "名称:",
"connectionInfo.avgPing": "平均延迟:",
"connectionInfo.avgPacketLoss": "平均丢包率:",
"connectionInfo.incoming": "传入",
"connectionInfo.outgoing": "传出",
"connectionInfo.packetsTransferred": "传输数据包",
"connectionInfo.bytesTransferred": "传输字节",
"connectionInfo.bandwidthLastSecond": "上一秒带宽",
"connectionInfo.bandwidthLastMinute": "上一分钟带宽",
"connectionInfo.ftBandwidth": "文件传输带宽",
"connectionInfo.ftBytes": "文件传输字节",
"connectionInfo.ip": "IP 地址:",
"connectionInfo.packetLoss": "丢包率:",
"connectionInfo.packetsSent": "已发送数据包:",
@@ -211,6 +227,14 @@ export const zhCN: Record<string, string> = {
"options.section.wiedergabe": "播放",
"options.section.aufnahme": "录音",
"options.section.design": "外观",
"design.subtitle": "选择应用外观。",
"design.theme.standard": "标准",
"design.theme.standard.desc": "原始 WebSpeak3 设计。",
"design.theme.nova": "Nova",
"design.theme.nova.desc": "更现代的深色设计,带圆角元素。",
"design.theme.greenteaspeak": "GreenTeaSpeak",
"design.theme.greenteaspeak.desc": "经典 GreenTeaSpeak 客户端布局:深色面板与金色菜单栏。",
"design.status.connected": "已连接",
"options.section.erweiterungen": "扩展",
"options.section.hotkeys": "快捷键",
"options.section.whispern": "悄悄话",
@@ -267,19 +291,28 @@ export const zhCN: Record<string, string> = {
"info.currentChannels": "当前频道:",
"info.topic": "主题:",
"info.audioCodec": "音频编解码器:",
"info.spacer": "间隔符:",
"info.rawName": "原始名称:",
"info.passwordProtected": "密码保护:",
"info.clients": "用户:",
"info.country": "国家:",
"info.muted": "麦克风静音:",
"info.outputMuted": "扬声器静音:",
"info.serverGroups": "服务器组:",
"info.yes": "是",
"info.no": "否",
"tree.notConnected": "未连接",
"tree.clickToSelect": "单击选择,双击加入",
"tree.clickToJoin": "双击加入",
"tree.joinNotConnected": "未连接 — 无法切换频道",
"tree.passwordProtected": "受密码保护",
"tree.privateChatWith": "与其私聊",
"tree.poke": "戳一戳",
"tree.channelCommander": "频道指挥官",
"tree.away": "离开",
"tree.micMuted": "麦克风已静音",
"tree.talking": "正在说话",
"tree.noTalkPower": "在此频道中没有发言权限",
"tree.soundMuted": "声音已关闭(拒听)",
@@ -424,6 +457,7 @@ export const zhCN: Record<string, string> = {
"permsEditor.searchPermission": "搜索权限...",
"dialog.ok": "确定",
"channelContext.join": "切换到频道",
"channelContext.files": "文件...",
"fileBrowser.title": "文件传输",
"fileBrowser.up": "上一级",
+1
View File
@@ -1,6 +1,7 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import './styles/greenteaspeak.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,87 @@
import type { ReactNode } from "react";
export type ConnectionTabItem = {
id: string;
label: string;
connected?: boolean;
connecting?: boolean;
};
export type GreenteaSpeakChromeProps = {
/** @deprecated Prefer `tabs` + `activeTabId` for multi-join. */
connected?: boolean;
/** @deprecated Prefer `tabs`. */
serverName?: string;
tabs?: ConnectionTabItem[];
activeTabId?: string | null;
onSelectTab?: (id: string) => void;
onCloseTab?: (id: string) => void;
children?: ReactNode;
};
/**
* GTS branding chrome: connection-tab strip (multi-join) + brand label when empty.
* Renders children unchanged — WebSpeak keeps its own React state/handlers.
*/
export function GreenteaSpeakChrome({
connected,
serverName,
tabs,
activeTabId,
onSelectTab,
onCloseTab,
children,
}: GreenteaSpeakChromeProps) {
const resolvedTabs: ConnectionTabItem[] =
tabs ??
(connected
? [{ id: "legacy", label: (serverName ?? "").trim() || "GreenTeaSpeak", connected: true }]
: []);
const hasTabs = resolvedTabs.length > 0;
return (
<>
{hasTabs ? (
<div className="gts-connection-tabs" role="tablist" aria-label="Server-Verbindungen">
{resolvedTabs.map((tab) => {
const isActive = tab.id === (activeTabId ?? resolvedTabs[0]?.id);
return (
<div
key={tab.id}
role="tab"
aria-selected={isActive}
className={`gts-connection-tab${isActive ? " gts-connection-tab-active" : ""}${
tab.connecting ? " gts-connection-tab-connecting" : ""
}`}
onClick={() => onSelectTab?.(tab.id)}
title={tab.label}
>
<span className="gts-connection-tab-label">{tab.label}</span>
{onCloseTab ? (
<button
type="button"
className="gts-connection-tab-close"
title="Verbindung trennen"
aria-label={`Tab schließen: ${tab.label}`}
onClick={(e) => {
e.stopPropagation();
onCloseTab(tab.id);
}}
>
×
</button>
) : null}
</div>
);
})}
</div>
) : (
<div className="gts-connection-tabs gts-brand-strip">
<span className="gts-brand-label">GreenTeaSpeak</span>
</div>
)}
{children}
</>
);
}
@@ -0,0 +1,56 @@
/**
* Maps WebSpeak gateway WebSocket payloads to the shape the GreenTeaSpeak
* shell expects. The browser UI still uses App.tsx state; this module is the
* contract layer so GTS chrome never talks to Electron IPC.
*/
export type GatewayServerType = "auto" | "teamspeak" | "teaspeak";
export type GatewayConnectPayload = {
type: "connect";
host: string;
nickname: string;
serverPassword?: string;
channelPassword?: string;
defaultChannel?: string;
identity?: string;
privilegeKey?: string;
serverType?: GatewayServerType;
};
export type GatewayOutboundAction =
| GatewayConnectPayload
| { type: "disconnect" }
| { type: "switchChannel"; channelId: number }
| { type: "sendChat"; message: string; target?: "channel" | "server" | number }
| { type: string; [key: string]: unknown };
/** Build the connect message sent on the WebSpeak gateway socket. */
export function buildGatewayConnect(input: {
host: string;
nickname: string;
serverPassword?: string;
channelPassword?: string;
defaultChannel?: string;
identity?: string;
privilegeKey?: string;
serverType?: GatewayServerType;
}): GatewayConnectPayload {
return {
type: "connect",
host: input.host.trim(),
nickname: input.nickname.trim(),
serverPassword: input.serverPassword?.trim() || undefined,
channelPassword: input.channelPassword?.trim() || undefined,
defaultChannel: input.defaultChannel?.trim() || undefined,
identity: input.identity || undefined,
privilegeKey: input.privilegeKey?.trim() || undefined,
serverType: input.serverType || "auto",
};
}
export function sendGatewayAction(ws: WebSocket | null, action: GatewayOutboundAction): boolean {
if (!ws || ws.readyState !== WebSocket.OPEN) return false;
ws.send(JSON.stringify(action));
return true;
}
+19
View File
@@ -0,0 +1,19 @@
export const GREENTEASPEAK_THEME_ID = "greenteaspeak" as const;
export function isGreenteaSpeakTheme(theme: string): boolean {
return theme === GREENTEASPEAK_THEME_ID;
}
export {
GreenteaSpeakChrome,
type GreenteaSpeakChromeProps,
type ConnectionTabItem,
} from "./GreenteaSpeakChrome";
export {
buildGatewayConnect,
sendGatewayAction,
type GatewayConnectPayload,
type GatewayOutboundAction,
type GatewayServerType,
} from "./gatewayAdapter";